From 2afb22b7e1ebcbe40373ff7e0efae7d207c655a9 Mon Sep 17 00:00:00 2001 From: Chris Johns Date: Sat, 23 Dec 2017 18:18:56 +1100 Subject: Remove make preinstall A speciality of the RTEMS build system was the make preinstall step. It copied header files from arbitrary locations into the build tree. The header files were included via the -Bsome/build/tree/path GCC command line option. This has at least seven problems: * The make preinstall step itself needs time and disk space. * Errors in header files show up in the build tree copy. This makes it hard for editors to open the right file to fix the error. * There is no clear relationship between source and build tree header files. This makes an audit of the build process difficult. * The visibility of all header files in the build tree makes it difficult to enforce API barriers. For example it is discouraged to use BSP-specifics in the cpukit. * An introduction of a new build system is difficult. * Include paths specified by the -B option are system headers. This may suppress warnings. * The parallel build had sporadic failures on some hosts. This patch removes the make preinstall step. All installed header files are moved to dedicated include directories in the source tree. Let @RTEMS_CPU@ be the target architecture, e.g. arm, powerpc, sparc, etc. Let @RTEMS_BSP_FAMILIY@ be a BSP family base directory, e.g. erc32, imx, qoriq, etc. The new cpukit include directories are: * cpukit/include * cpukit/score/cpu/@RTEMS_CPU@/include * cpukit/libnetworking The new BSP include directories are: * bsps/include * bsps/@RTEMS_CPU@/include * bsps/@RTEMS_CPU@/@RTEMS_BSP_FAMILIY@/include There are build tree include directories for generated files. The include directory order favours the most general header file, e.g. it is not possible to override general header files via the include path order. The "bootstrap -p" option was removed. The new "bootstrap -H" option should be used to regenerate the "headers.am" files. Update #3254. --- cpukit/Makefile.am | 227 +- cpukit/acinclude.m4 | 21 +- cpukit/aclocal/check-networking.m4 | 4 +- cpukit/aclocal/prog-cc.m4 | 5 +- cpukit/aclocal/rtems-bsp-includes.m4 | 13 + cpukit/aclocal/rtems-build-top.m4 | 12 + cpukit/aclocal/rtems-includes.m4 | 23 + cpukit/aclocal/rtems-source-top.m4 | 8 + cpukit/automake/compile.am | 2 + cpukit/automake/local.am | 5 +- cpukit/automake/subdirs.am | 24 +- cpukit/configure.ac | 8 +- cpukit/dev/Makefile.am | 34 - cpukit/dev/include/dev/i2c/eeprom.h | 58 - cpukit/dev/include/dev/i2c/fpga-i2c-slave.h | 25 - cpukit/dev/include/dev/i2c/gpio-nxp-pca9535.h | 123 - cpukit/dev/include/dev/i2c/i2c.h | 432 --- cpukit/dev/include/dev/i2c/sensor-lm75a.h | 125 - cpukit/dev/include/dev/i2c/switch-nxp-pca9548a.h | 68 - cpukit/dev/include/dev/i2c/ti-ads-16bit-adc.h | 203 -- cpukit/dev/include/dev/i2c/ti-lm25066a.h | 190 -- cpukit/dev/include/dev/i2c/ti-tmp112.h | 109 - cpukit/dev/include/dev/i2c/xilinx-axi-i2c.h | 86 - cpukit/dev/include/dev/serial/sc16is752.h | 262 -- cpukit/dev/include/dev/spi/spi.h | 216 -- cpukit/dev/include/linux/i2c-dev.h | 137 - cpukit/dev/include/linux/i2c.h | 275 -- cpukit/dev/include/linux/spi/spidev.h | 268 -- cpukit/dev/preinstall.am | 105 - cpukit/dtc/libfdt/Makefile.am | 3 - cpukit/dtc/libfdt/fdt.h | 111 - cpukit/dtc/libfdt/libfdt.h | 1653 --------- cpukit/dtc/libfdt/libfdt_env.h | 111 - cpukit/dtc/libfdt/preinstall.am | 32 - cpukit/ftpd/Makefile.am | 6 +- cpukit/ftpd/ftpd.h | 74 - cpukit/ftpd/preinstall.am | 25 - cpukit/headers.am | 474 +++ cpukit/include/adainclude/preinstall.am | 177 - cpukit/include/aio.h | 193 ++ cpukit/include/dev/i2c/eeprom.h | 58 + cpukit/include/dev/i2c/fpga-i2c-slave.h | 25 + cpukit/include/dev/i2c/gpio-nxp-pca9535.h | 123 + cpukit/include/dev/i2c/i2c.h | 432 +++ cpukit/include/dev/i2c/sensor-lm75a.h | 125 + cpukit/include/dev/i2c/switch-nxp-pca9548a.h | 68 + cpukit/include/dev/i2c/ti-ads-16bit-adc.h | 203 ++ cpukit/include/dev/i2c/ti-lm25066a.h | 190 ++ cpukit/include/dev/i2c/ti-tmp112.h | 109 + cpukit/include/dev/i2c/xilinx-axi-i2c.h | 86 + cpukit/include/dev/serial/sc16is752.h | 262 ++ cpukit/include/dev/spi/spi.h | 216 ++ cpukit/include/dlfcn.h | 112 + cpukit/include/drvmgr/drvmgr.h | 988 ++++++ cpukit/include/drvmgr/drvmgr_confdefs.h | 258 ++ cpukit/include/drvmgr/drvmgr_list.h | 78 + cpukit/include/drvmgr/pci_bus.h | 161 + cpukit/include/fdt.h | 111 + cpukit/include/libfdt.h | 1653 +++++++++ cpukit/include/libfdt_env.h | 111 + cpukit/include/librtemsNfs.h | 234 ++ cpukit/include/link.h | 45 + cpukit/include/link_elf.h | 79 + cpukit/include/linux/i2c-dev.h | 137 + cpukit/include/linux/i2c.h | 275 ++ cpukit/include/linux/spi/spidev.h | 268 ++ cpukit/include/machine/_kernel_cpuset.h | 0 cpukit/include/machine/_kernel_param.h | 29 + cpukit/include/machine/_kernel_time.h | 173 + cpukit/include/machine/_kernel_types.h | 34 + cpukit/include/machine/_timecounter.h | 53 + cpukit/include/md4.h | 56 + cpukit/include/md5.h | 71 + cpukit/include/mghttpd/mongoose.h | 390 +++ cpukit/include/mqueue.h | 218 ++ cpukit/include/pci.h | 114 + cpukit/include/pci/access.h | 258 ++ cpukit/include/pci/cfg.h | 254 ++ cpukit/include/pci/cfg_auto.h | 58 + cpukit/include/pci/cfg_peripheral.h | 19 + cpukit/include/pci/cfg_read.h | 21 + cpukit/include/pci/cfg_static.h | 21 + cpukit/include/pci/ids.h | 827 +++++ cpukit/include/pci/ids_extra.h | 22 + cpukit/include/pci/irq.h | 118 + cpukit/include/pci/pcireg.h | 931 +++++ cpukit/include/rpc/auth.h | 262 ++ cpukit/include/rpc/auth_unix.h | 85 + cpukit/include/rpc/clnt.h | 310 ++ cpukit/include/rpc/clnt_soc.h | 109 + cpukit/include/rpc/clnt_stat.h | 84 + cpukit/include/rpc/pmap_clnt.h | 89 + cpukit/include/rpc/pmap_prot.h | 105 + cpukit/include/rpc/pmap_rmt.h | 64 + cpukit/include/rpc/rpc.h | 118 + cpukit/include/rpc/rpc_com.h | 65 + cpukit/include/rpc/rpc_msg.h | 205 ++ cpukit/include/rpc/rpcent.h | 71 + cpukit/include/rpc/svc.h | 297 ++ cpukit/include/rpc/svc_auth.h | 58 + cpukit/include/rpc/svc_soc.h | 125 + cpukit/include/rpc/types.h | 68 + cpukit/include/rpc/xdr.h | 312 ++ cpukit/include/rtems.h | 192 ++ cpukit/include/rtems/assoc.h | 204 ++ cpukit/include/rtems/bdbuf.h | 699 ++++ cpukit/include/rtems/bdpart.h | 411 +++ cpukit/include/rtems/blkdev.h | 460 +++ cpukit/include/rtems/bsd.h | 141 + cpukit/include/rtems/bspcmdline.h | 131 + cpukit/include/rtems/capture-cli.h | 53 + cpukit/include/rtems/capture.h | 1122 ++++++ cpukit/include/rtems/captureimpl.h | 185 + cpukit/include/rtems/cbs.h | 244 ++ cpukit/include/rtems/chain.h | 789 +++++ cpukit/include/rtems/confdefs.h | 3587 ++++++++++++++++++++ cpukit/include/rtems/config.h | 397 +++ cpukit/include/rtems/counter.h | 160 + cpukit/include/rtems/cpuuse.h | 88 + .../include/rtems/debugger/rtems-debugger-remote.h | 72 + .../include/rtems/debugger/rtems-debugger-server.h | 217 ++ cpukit/include/rtems/devfs.h | 255 ++ cpukit/include/rtems/deviceio.h | 88 + cpukit/include/rtems/devnull.h | 84 + cpukit/include/rtems/devzero.h | 92 + cpukit/include/rtems/diskdevs.h | 511 +++ cpukit/include/rtems/dosfs.h | 433 +++ cpukit/include/rtems/dumpbuf.h | 52 + cpukit/include/rtems/error.h | 135 + cpukit/include/rtems/extension.h | 245 ++ cpukit/include/rtems/extensionimpl.h | 53 + cpukit/include/rtems/fatal.h | 134 + cpukit/include/rtems/fb.h | 101 + cpukit/include/rtems/flashdisk.h | 460 +++ cpukit/include/rtems/fsmount.h | 211 ++ cpukit/include/rtems/ftpd.h | 74 + cpukit/include/rtems/gxx_wrappers.h | 80 + cpukit/include/rtems/ide_part_table.h | 207 ++ cpukit/include/rtems/imfs.h | 946 ++++++ cpukit/include/rtems/init.h | 69 + cpukit/include/rtems/io.h | 254 ++ cpukit/include/rtems/ioimpl.h | 65 + cpukit/include/rtems/iosupp.h | 46 + cpukit/include/rtems/jffs2.h | 604 ++++ cpukit/include/rtems/libcsupport.h | 193 ++ cpukit/include/rtems/libi2c.h | 508 +++ cpukit/include/rtems/libio.h | 1967 +++++++++++ cpukit/include/rtems/libio_.h | 1049 ++++++ cpukit/include/rtems/linkersets.h | 129 + cpukit/include/rtems/malloc.h | 201 ++ cpukit/include/rtems/media.h | 517 +++ cpukit/include/rtems/monitor.h | 528 +++ cpukit/include/rtems/mouse_parser.h | 121 + cpukit/include/rtems/mptables.h | 32 + cpukit/include/rtems/mw_uid.h | 194 ++ cpukit/include/rtems/nvdisk-sram.h | 23 + cpukit/include/rtems/nvdisk.h | 211 ++ cpukit/include/rtems/passwd.h | 25 + cpukit/include/rtems/pipe.h | 133 + cpukit/include/rtems/posix/aio_misc.h | 113 + cpukit/include/rtems/posix/barrierimpl.h | 99 + cpukit/include/rtems/posix/condimpl.h | 184 + cpukit/include/rtems/posix/config.h | 120 + cpukit/include/rtems/posix/key.h | 95 + cpukit/include/rtems/posix/keyimpl.h | 177 + cpukit/include/rtems/posix/mmanimpl.h | 56 + cpukit/include/rtems/posix/mqueue.h | 71 + cpukit/include/rtems/posix/mqueueimpl.h | 183 + cpukit/include/rtems/posix/muteximpl.h | 487 +++ cpukit/include/rtems/posix/posixapi.h | 146 + cpukit/include/rtems/posix/priorityimpl.h | 109 + cpukit/include/rtems/posix/psignal.h | 35 + cpukit/include/rtems/posix/psignalimpl.h | 140 + cpukit/include/rtems/posix/pthread.h | 55 + cpukit/include/rtems/posix/pthreadattrimpl.h | 95 + cpukit/include/rtems/posix/pthreadimpl.h | 129 + cpukit/include/rtems/posix/ptimer.h | 88 + cpukit/include/rtems/posix/rwlockimpl.h | 64 + cpukit/include/rtems/posix/semaphore.h | 56 + cpukit/include/rtems/posix/semaphoreimpl.h | 143 + cpukit/include/rtems/posix/shm.h | 213 ++ cpukit/include/rtems/posix/shmimpl.h | 135 + cpukit/include/rtems/posix/sigset.h | 45 + cpukit/include/rtems/posix/spinlockimpl.h | 58 + cpukit/include/rtems/posix/threadsup.h | 98 + cpukit/include/rtems/posix/timer.h | 60 + cpukit/include/rtems/posix/timerimpl.h | 134 + cpukit/include/rtems/profiling.h | 333 ++ cpukit/include/rtems/pty.h | 76 + cpukit/include/rtems/qreslib.h | 269 ++ cpukit/include/rtems/ramdisk.h | 227 ++ cpukit/include/rtems/rbheap.h | 268 ++ cpukit/include/rtems/rbtree.h | 456 +++ cpukit/include/rtems/rfs/rtems-rfs-bitmaps.h | 326 ++ cpukit/include/rtems/rfs/rtems-rfs-block-pos.h | 242 ++ cpukit/include/rtems/rfs/rtems-rfs-block.h | 344 ++ cpukit/include/rtems/rfs/rtems-rfs-buffer.h | 283 ++ cpukit/include/rtems/rfs/rtems-rfs-data.h | 89 + cpukit/include/rtems/rfs/rtems-rfs-dir-hash.h | 36 + cpukit/include/rtems/rfs/rtems-rfs-dir.h | 209 ++ .../include/rtems/rfs/rtems-rfs-file-system-fwd.h | 29 + cpukit/include/rtems/rfs/rtems-rfs-file-system.h | 410 +++ cpukit/include/rtems/rfs/rtems-rfs-file.h | 416 +++ cpukit/include/rtems/rfs/rtems-rfs-group.h | 181 + cpukit/include/rtems/rfs/rtems-rfs-inode.h | 728 ++++ cpukit/include/rtems/rfs/rtems-rfs-link.h | 124 + cpukit/include/rtems/rfs/rtems-rfs-mutex.h | 116 + cpukit/include/rtems/rfs/rtems-rfs-trace.h | 135 + cpukit/include/rtems/ringbuf.h | 63 + cpukit/include/rtems/rtems-debugger.h | 81 + cpukit/include/rtems/rtems-fdt-shell.h | 42 + cpukit/include/rtems/rtems-fdt.h | 621 ++++ cpukit/include/rtems/rtems-rfs-format.h | 90 + cpukit/include/rtems/rtems-rfs-shell.h | 48 + cpukit/include/rtems/rtems-rfs.h | 38 + cpukit/include/rtems/rtems/asr.h | 156 + cpukit/include/rtems/rtems/asrimpl.h | 99 + cpukit/include/rtems/rtems/attr.h | 191 ++ cpukit/include/rtems/rtems/attrimpl.h | 263 ++ cpukit/include/rtems/rtems/barrier.h | 173 + cpukit/include/rtems/rtems/barrierimpl.h | 92 + cpukit/include/rtems/rtems/cache.h | 370 ++ cpukit/include/rtems/rtems/clock.h | 318 ++ cpukit/include/rtems/rtems/config.h | 142 + cpukit/include/rtems/rtems/dpmem.h | 179 + cpukit/include/rtems/rtems/dpmemimpl.h | 85 + cpukit/include/rtems/rtems/event.h | 526 +++ cpukit/include/rtems/rtems/eventimpl.h | 146 + cpukit/include/rtems/rtems/eventmp.h | 101 + cpukit/include/rtems/rtems/intr.h | 373 ++ cpukit/include/rtems/rtems/mainpage.h | 927 +++++ cpukit/include/rtems/rtems/message.h | 270 ++ cpukit/include/rtems/rtems/messageimpl.h | 120 + cpukit/include/rtems/rtems/modes.h | 132 + cpukit/include/rtems/rtems/modesimpl.h | 146 + cpukit/include/rtems/rtems/mp.h | 54 + cpukit/include/rtems/rtems/msgmp.h | 211 ++ cpukit/include/rtems/rtems/object.h | 370 ++ cpukit/include/rtems/rtems/options.h | 83 + cpukit/include/rtems/rtems/optionsimpl.h | 67 + cpukit/include/rtems/rtems/part.h | 174 + cpukit/include/rtems/rtems/partimpl.h | 223 ++ cpukit/include/rtems/rtems/partmp.h | 144 + cpukit/include/rtems/rtems/ratemon.h | 430 +++ cpukit/include/rtems/rtems/ratemonimpl.h | 158 + cpukit/include/rtems/rtems/region.h | 298 ++ cpukit/include/rtems/rtems/regionimpl.h | 142 + cpukit/include/rtems/rtems/sem.h | 278 ++ cpukit/include/rtems/rtems/semimpl.h | 120 + cpukit/include/rtems/rtems/semmp.h | 171 + cpukit/include/rtems/rtems/signal.h | 83 + cpukit/include/rtems/rtems/signalimpl.h | 51 + cpukit/include/rtems/rtems/signalmp.h | 98 + cpukit/include/rtems/rtems/smp.h | 78 + cpukit/include/rtems/rtems/status.h | 263 ++ cpukit/include/rtems/rtems/statusimpl.h | 64 + cpukit/include/rtems/rtems/support.h | 170 + cpukit/include/rtems/rtems/taskmp.h | 132 + cpukit/include/rtems/rtems/tasks.h | 716 ++++ cpukit/include/rtems/rtems/tasksimpl.h | 131 + cpukit/include/rtems/rtems/timer.h | 384 +++ cpukit/include/rtems/rtems/timerimpl.h | 209 ++ cpukit/include/rtems/rtems/types.h | 235 ++ cpukit/include/rtems/rtemsdialer.h | 24 + cpukit/include/rtems/rtemspppd.h | 49 + cpukit/include/rtems/rtl/dlfcn-shell.h | 17 + cpukit/include/rtems/rtl/rap-shell.h | 14 + cpukit/include/rtems/rtl/rap.h | 115 + cpukit/include/rtems/rtl/rtl-allocator.h | 181 + cpukit/include/rtems/rtl/rtl-fwd.h | 33 + cpukit/include/rtems/rtl/rtl-indirect-ptr.h | 235 ++ cpukit/include/rtems/rtl/rtl-obj-cache.h | 132 + cpukit/include/rtems/rtl/rtl-obj-comp.h | 122 + cpukit/include/rtems/rtl/rtl-obj-fwd.h | 39 + cpukit/include/rtems/rtl/rtl-obj.h | 635 ++++ cpukit/include/rtems/rtl/rtl-sym.h | 135 + cpukit/include/rtems/rtl/rtl-trace.h | 102 + cpukit/include/rtems/rtl/rtl-unresolved.h | 212 ++ cpukit/include/rtems/rtl/rtl.h | 321 ++ cpukit/include/rtems/scheduler.h | 247 ++ cpukit/include/rtems/score/address.h | 200 ++ cpukit/include/rtems/score/apimutex.h | 109 + cpukit/include/rtems/score/assert.h | 108 + cpukit/include/rtems/score/atomic.h | 156 + cpukit/include/rtems/score/basedefs.h | 415 +++ cpukit/include/rtems/score/chain.h | 102 + cpukit/include/rtems/score/chainimpl.h | 1123 ++++++ cpukit/include/rtems/score/context.h | 163 + cpukit/include/rtems/score/copyrt.h | 44 + cpukit/include/rtems/score/corebarrier.h | 91 + cpukit/include/rtems/score/corebarrierimpl.h | 173 + cpukit/include/rtems/score/coremsg.h | 185 + cpukit/include/rtems/score/coremsgimpl.h | 494 +++ cpukit/include/rtems/score/coremutex.h | 104 + cpukit/include/rtems/score/coremuteximpl.h | 447 +++ cpukit/include/rtems/score/corerwlockimpl.h | 182 + cpukit/include/rtems/score/coresem.h | 61 + cpukit/include/rtems/score/coresemimpl.h | 207 ++ cpukit/include/rtems/score/cpustdatomic.h | 682 ++++ cpukit/include/rtems/score/freechain.h | 111 + cpukit/include/rtems/score/heap.h | 518 +++ cpukit/include/rtems/score/heapimpl.h | 601 ++++ cpukit/include/rtems/score/interr.h | 268 ++ cpukit/include/rtems/score/io.h | 46 + cpukit/include/rtems/score/isr.h | 155 + cpukit/include/rtems/score/isrlevel.h | 153 + cpukit/include/rtems/score/isrlock.h | 439 +++ cpukit/include/rtems/score/mpci.h | 135 + cpukit/include/rtems/score/mpciimpl.h | 326 ++ cpukit/include/rtems/score/mppkt.h | 121 + cpukit/include/rtems/score/mrsp.h | 79 + cpukit/include/rtems/score/mrspimpl.h | 384 +++ cpukit/include/rtems/score/muteximpl.h | 37 + cpukit/include/rtems/score/object.h | 469 +++ cpukit/include/rtems/score/objectimpl.h | 1002 ++++++ cpukit/include/rtems/score/objectmp.h | 197 ++ cpukit/include/rtems/score/onceimpl.h | 52 + cpukit/include/rtems/score/percpu.h | 851 +++++ cpukit/include/rtems/score/priority.h | 203 ++ cpukit/include/rtems/score/prioritybitmap.h | 79 + cpukit/include/rtems/score/prioritybitmapimpl.h | 215 ++ cpukit/include/rtems/score/priorityimpl.h | 435 +++ cpukit/include/rtems/score/processormask.h | 290 ++ cpukit/include/rtems/score/profiling.h | 140 + cpukit/include/rtems/score/protectedheap.h | 172 + cpukit/include/rtems/score/rbtree.h | 568 ++++ cpukit/include/rtems/score/rbtreeimpl.h | 72 + cpukit/include/rtems/score/scheduler.h | 556 +++ cpukit/include/rtems/score/schedulercbs.h | 346 ++ cpukit/include/rtems/score/schedulercbsimpl.h | 59 + cpukit/include/rtems/score/scheduleredf.h | 197 ++ cpukit/include/rtems/score/scheduleredfimpl.h | 164 + cpukit/include/rtems/score/scheduleredfsmp.h | 200 ++ cpukit/include/rtems/score/schedulerimpl.h | 1203 +++++++ cpukit/include/rtems/score/schedulernode.h | 217 ++ cpukit/include/rtems/score/schedulernodeimpl.h | 146 + cpukit/include/rtems/score/schedulerpriority.h | 163 + .../rtems/score/schedulerpriorityaffinitysmp.h | 181 + cpukit/include/rtems/score/schedulerpriorityimpl.h | 241 ++ cpukit/include/rtems/score/schedulerprioritysmp.h | 171 + .../include/rtems/score/schedulerprioritysmpimpl.h | 184 + cpukit/include/rtems/score/schedulersimple.h | 126 + cpukit/include/rtems/score/schedulersimpleimpl.h | 103 + cpukit/include/rtems/score/schedulersimplesmp.h | 155 + cpukit/include/rtems/score/schedulersmp.h | 127 + cpukit/include/rtems/score/schedulersmpimpl.h | 1482 ++++++++ cpukit/include/rtems/score/schedulerstrongapa.h | 171 + cpukit/include/rtems/score/semaphoreimpl.h | 73 + cpukit/include/rtems/score/smp.h | 64 + cpukit/include/rtems/score/smpbarrier.h | 125 + cpukit/include/rtems/score/smpimpl.h | 354 ++ cpukit/include/rtems/score/smplock.h | 327 ++ cpukit/include/rtems/score/smplockmcs.h | 262 ++ cpukit/include/rtems/score/smplockseq.h | 176 + cpukit/include/rtems/score/smplockstats.h | 277 ++ cpukit/include/rtems/score/smplockticket.h | 187 + cpukit/include/rtems/score/stack.h | 69 + cpukit/include/rtems/score/stackimpl.h | 99 + cpukit/include/rtems/score/states.h | 50 + cpukit/include/rtems/score/statesimpl.h | 283 ++ cpukit/include/rtems/score/status.h | 129 + cpukit/include/rtems/score/sysstate.h | 119 + cpukit/include/rtems/score/thread.h | 935 +++++ cpukit/include/rtems/score/threaddispatch.h | 281 ++ cpukit/include/rtems/score/threadimpl.h | 1969 +++++++++++ cpukit/include/rtems/score/threadmp.h | 113 + cpukit/include/rtems/score/threadq.h | 595 ++++ cpukit/include/rtems/score/threadqimpl.h | 1265 +++++++ cpukit/include/rtems/score/timecounter.h | 244 ++ cpukit/include/rtems/score/timecounterimpl.h | 50 + cpukit/include/rtems/score/timespec.h | 272 ++ cpukit/include/rtems/score/timestamp.h | 323 ++ cpukit/include/rtems/score/tls.h | 217 ++ cpukit/include/rtems/score/tod.h | 32 + cpukit/include/rtems/score/todimpl.h | 304 ++ cpukit/include/rtems/score/userext.h | 273 ++ cpukit/include/rtems/score/userextimpl.h | 369 ++ cpukit/include/rtems/score/watchdog.h | 166 + cpukit/include/rtems/score/watchdogimpl.h | 574 ++++ cpukit/include/rtems/score/wkspace.h | 138 + cpukit/include/rtems/serdbg.h | 151 + cpukit/include/rtems/serdbgcnf.h | 91 + cpukit/include/rtems/serial_mouse.h | 169 + cpukit/include/rtems/seterr.h | 53 + cpukit/include/rtems/shell.h | 385 +++ cpukit/include/rtems/shellconfig.h | 554 +++ cpukit/include/rtems/sparse-disk.h | 137 + cpukit/include/rtems/spurious.h | 42 + cpukit/include/rtems/stackchk.h | 139 + cpukit/include/rtems/stdio-redirect.h | 115 + cpukit/include/rtems/stringto.h | 262 ++ cpukit/include/rtems/sysinit.h | 118 + cpukit/include/rtems/system.h | 66 + cpukit/include/rtems/telnetd.h | 110 + cpukit/include/rtems/termios_printk.h | 101 + cpukit/include/rtems/termios_printk_cnf.h | 81 + cpukit/include/rtems/termiostypes.h | 602 ++++ cpukit/include/rtems/test.h | 314 ++ cpukit/include/rtems/timecounter.h | 335 ++ cpukit/include/rtems/timespec.h | 305 ++ cpukit/include/rtems/tod.h | 70 + .../include/rtems/trace/rtems-trace-buffer-vars.h | 148 + cpukit/include/rtems/untar.h | 260 ++ cpukit/include/rtems/version.h | 77 + cpukit/include/rtems/vmeintr.h | 59 + cpukit/include/sha256.h | 50 + cpukit/include/sha512.h | 50 + cpukit/include/sys/_ffcounter.h | 42 + cpukit/include/sys/cdefs_elf.h | 152 + cpukit/include/sys/event.h | 303 ++ cpukit/include/sys/exec_elf.h | 1101 ++++++ cpukit/include/sys/poll.h | 104 + cpukit/include/sys/statvfs.h | 60 + cpukit/include/sys/timeffc.h | 391 +++ cpukit/include/sys/timepps.h | 266 ++ cpukit/include/sys/timetc.h | 105 + cpukit/include/sys/timex.h | 171 + cpukit/include/sys/utsname.h | 76 + cpukit/include/utf8proc/utf8proc.h | 385 +++ cpukit/include/uuid/uuid.h | 103 + cpukit/include/xz.h | 304 ++ cpukit/include/zlib.h | 1613 +++++++++ cpukit/libblock/include/rtems/bdbuf.h | 699 ---- cpukit/libblock/include/rtems/bdpart.h | 411 --- cpukit/libblock/include/rtems/blkdev.h | 460 --- cpukit/libblock/include/rtems/diskdevs.h | 511 --- cpukit/libblock/include/rtems/flashdisk.h | 460 --- cpukit/libblock/include/rtems/ide_part_table.h | 207 -- cpukit/libblock/include/rtems/media.h | 517 --- cpukit/libblock/include/rtems/nvdisk-sram.h | 23 - cpukit/libblock/include/rtems/nvdisk.h | 211 -- cpukit/libblock/include/rtems/ramdisk.h | 227 -- cpukit/libblock/include/rtems/sparse-disk.h | 137 - cpukit/libcrypt/Makefile.am | 3 - cpukit/libcrypt/preinstall.am | 15 - cpukit/libcsupport/Makefile.am | 26 - cpukit/libcsupport/include/iosupp.h | 46 - .../libcsupport/include/machine/_kernel_cpuset.h | 0 cpukit/libcsupport/include/machine/_kernel_param.h | 29 - cpukit/libcsupport/include/machine/_kernel_time.h | 173 - cpukit/libcsupport/include/machine/_kernel_types.h | 34 - cpukit/libcsupport/include/machine/_timecounter.h | 53 - cpukit/libcsupport/include/ringbuf.h | 63 - cpukit/libcsupport/include/rtems/assoc.h | 204 -- cpukit/libcsupport/include/rtems/deviceio.h | 88 - cpukit/libcsupport/include/rtems/error.h | 135 - cpukit/libcsupport/include/rtems/gxx_wrappers.h | 80 - cpukit/libcsupport/include/rtems/libcsupport.h | 193 -- cpukit/libcsupport/include/rtems/libio.h | 1967 ----------- cpukit/libcsupport/include/rtems/libio_.h | 1049 ------ cpukit/libcsupport/include/rtems/malloc.h | 201 -- cpukit/libcsupport/include/rtems/termiostypes.h | 602 ---- cpukit/libcsupport/include/rtems/tod.h | 70 - cpukit/libcsupport/include/spurious.h | 42 - cpukit/libcsupport/include/sys/event.h | 303 -- cpukit/libcsupport/include/sys/poll.h | 104 - cpukit/libcsupport/include/sys/statvfs.h | 60 - cpukit/libcsupport/include/sys/utsname.h | 76 - cpukit/libcsupport/include/vmeintr.h | 59 - cpukit/libcsupport/preinstall.am | 101 - cpukit/libdebugger/Makefile.am | 5 +- cpukit/libdebugger/preinstall.am | 9 - cpukit/libdebugger/rtems-debugger-remote.h | 72 - cpukit/libdebugger/rtems-debugger-server.h | 217 -- cpukit/libdebugger/rtems-debugger.h | 81 - cpukit/libdl/Makefile.am | 5 +- cpukit/libdl/dlfcn-shell.h | 17 - cpukit/libdl/dlfcn.h | 112 - .../libdl/include/arch/arm/machine/elf_machdep.h | 132 - .../libdl/include/arch/bfin/machine/elf_machdep.h | 28 - .../libdl/include/arch/h8300/machine/elf_machdep.h | 59 - .../libdl/include/arch/i386/machine/elf_machdep.h | 63 - .../libdl/include/arch/lm32/machine/elf_machdep.h | 34 - .../libdl/include/arch/m68k/machine/elf_machdep.h | 47 - .../libdl/include/arch/mips/machine/elf_machdep.h | 199 -- .../libdl/include/arch/moxie/machine/elf_machdep.h | 15 - .../libdl/include/arch/nios2/machine/elf_machdep.h | 46 - .../include/arch/powerpc/machine/elf_machdep.h | 105 - .../libdl/include/arch/sparc/machine/elf_machdep.h | 92 - .../libdl/include/arch/v850/machine/elf_machdep.h | 74 - cpukit/libdl/include/link.h | 45 - cpukit/libdl/include/link_elf.h | 79 - cpukit/libdl/include/sys/cdefs_elf.h | 152 - cpukit/libdl/include/sys/exec_elf.h | 1101 ------ cpukit/libdl/preinstall.am | 7 - cpukit/libdl/rap-shell.h | 14 - cpukit/libdl/rap.h | 115 - cpukit/libdl/rtl-allocator.h | 181 - cpukit/libdl/rtl-fwd.h | 33 - cpukit/libdl/rtl-indirect-ptr.h | 235 -- cpukit/libdl/rtl-obj-cache.h | 132 - cpukit/libdl/rtl-obj-comp.h | 122 - cpukit/libdl/rtl-obj-fwd.h | 39 - cpukit/libdl/rtl-obj.h | 635 ---- cpukit/libdl/rtl-sym.h | 135 - cpukit/libdl/rtl-trace.h | 102 - cpukit/libdl/rtl-unresolved.h | 212 -- cpukit/libdl/rtl.h | 321 -- cpukit/libdrvmgr/drvmgr.h | 988 ------ cpukit/libdrvmgr/drvmgr_confdefs.h | 258 -- cpukit/libdrvmgr/drvmgr_list.h | 78 - cpukit/libfs/Makefile.am | 6 +- cpukit/libfs/preinstall.am | 24 - cpukit/libfs/src/devfs/devfs.h | 255 -- cpukit/libfs/src/dosfs/dosfs.h | 433 --- cpukit/libfs/src/imfs/imfs.h | 946 ------ cpukit/libfs/src/jffs2/include/rtems/jffs2.h | 604 ---- cpukit/libfs/src/nfsclient/Makefile.am | 8 +- cpukit/libfs/src/nfsclient/preinstall.am | 51 - cpukit/libfs/src/nfsclient/src/librtemsNfs.h | 234 -- cpukit/libfs/src/pipe/pipe.h | 133 - cpukit/libfs/src/rfs/rtems-rfs-bitmaps.h | 326 -- cpukit/libfs/src/rfs/rtems-rfs-block-pos.h | 242 -- cpukit/libfs/src/rfs/rtems-rfs-block.h | 344 -- cpukit/libfs/src/rfs/rtems-rfs-buffer.h | 283 -- cpukit/libfs/src/rfs/rtems-rfs-data.h | 89 - cpukit/libfs/src/rfs/rtems-rfs-dir-hash.h | 36 - cpukit/libfs/src/rfs/rtems-rfs-dir.h | 209 -- cpukit/libfs/src/rfs/rtems-rfs-file-system-fwd.h | 29 - cpukit/libfs/src/rfs/rtems-rfs-file-system.h | 410 --- cpukit/libfs/src/rfs/rtems-rfs-file.h | 416 --- cpukit/libfs/src/rfs/rtems-rfs-format.h | 90 - cpukit/libfs/src/rfs/rtems-rfs-group.h | 181 - cpukit/libfs/src/rfs/rtems-rfs-inode.h | 728 ---- cpukit/libfs/src/rfs/rtems-rfs-link.h | 124 - cpukit/libfs/src/rfs/rtems-rfs-mutex.h | 116 - cpukit/libfs/src/rfs/rtems-rfs-shell.h | 48 - cpukit/libfs/src/rfs/rtems-rfs-trace.h | 135 - cpukit/libfs/src/rfs/rtems-rfs.h | 38 - cpukit/libi2c/libi2c.h | 508 --- cpukit/libmd/Makefile.am | 7 - cpukit/libmd/md4.h | 56 - cpukit/libmd/md5.h | 71 - cpukit/libmd/preinstall.am | 38 - cpukit/libmd/sha256.h | 50 - cpukit/libmd/sha512.h | 50 - cpukit/libmisc/Makefile.am | 1 - cpukit/libmisc/bspcmdline/bspcmdline.h | 131 - cpukit/libmisc/capture/capture-cli.h | 53 - cpukit/libmisc/capture/capture.h | 1122 ------ cpukit/libmisc/capture/captureimpl.h | 185 - cpukit/libmisc/capture/rtems-trace-buffer-vars.h | 148 - cpukit/libmisc/cpuuse/cpuuse.h | 88 - cpukit/libmisc/devnull/devnull.h | 84 - cpukit/libmisc/devnull/devzero.h | 92 - cpukit/libmisc/dumpbuf/dumpbuf.h | 52 - cpukit/libmisc/fb/fb.h | 101 - cpukit/libmisc/fb/mw_uid.h | 194 -- cpukit/libmisc/fsmount/fsmount.h | 211 -- cpukit/libmisc/monitor/monitor.h | 528 --- cpukit/libmisc/mouse/mouse_parser.h | 121 - cpukit/libmisc/mouse/serial_mouse.h | 169 - cpukit/libmisc/preinstall.am | 9 - cpukit/libmisc/redirector/stdio-redirect.h | 115 - cpukit/libmisc/rtems-fdt/rtems-fdt-shell.h | 42 - cpukit/libmisc/rtems-fdt/rtems-fdt.h | 621 ---- cpukit/libmisc/serdbg/serdbg.h | 151 - cpukit/libmisc/serdbg/serdbgcnf.h | 91 - cpukit/libmisc/serdbg/termios_printk.h | 101 - cpukit/libmisc/serdbg/termios_printk_cnf.h | 81 - cpukit/libmisc/shell/shell.h | 385 --- cpukit/libmisc/shell/shellconfig.h | 554 --- cpukit/libmisc/stackchk/stackchk.h | 139 - cpukit/libmisc/stringto/stringto.h | 262 -- cpukit/libmisc/testsupport/test.h | 314 -- cpukit/libmisc/untar/untar.h | 260 -- cpukit/libmisc/utf8proc/utf8proc.h | 385 --- cpukit/libmisc/uuid/uuid.h | 103 - cpukit/libmisc/xz/xz.h | 304 -- cpukit/libnetworking/Makefile.am | 124 +- cpukit/libnetworking/headers.am | 131 + cpukit/libnetworking/preinstall.am | 424 --- cpukit/libnetworking/sys/poll.h | 104 - cpukit/libpci/Makefile.am | 12 - cpukit/libpci/pci.h | 114 - cpukit/libpci/pci/access.h | 258 -- cpukit/libpci/pci/cfg.h | 254 -- cpukit/libpci/pci/cfg_auto.h | 58 - cpukit/libpci/pci/cfg_peripheral.h | 19 - cpukit/libpci/pci/cfg_read.h | 21 - cpukit/libpci/pci/cfg_static.h | 21 - cpukit/libpci/pci/ids.h | 827 ----- cpukit/libpci/pci/ids_extra.h | 22 - cpukit/libpci/pci/irq.h | 118 - cpukit/libpci/pci/pcireg.h | 931 ----- cpukit/libpci/pci_bus.h | 161 - cpukit/libpci/preinstall.am | 79 - cpukit/libqos/qreslib.h | 269 -- cpukit/librpc/Makefile.am | 21 - cpukit/librpc/include/rpc/auth.h | 262 -- cpukit/librpc/include/rpc/auth_unix.h | 85 - cpukit/librpc/include/rpc/clnt.h | 310 -- cpukit/librpc/include/rpc/clnt_soc.h | 109 - cpukit/librpc/include/rpc/clnt_stat.h | 84 - cpukit/librpc/include/rpc/pmap_clnt.h | 89 - cpukit/librpc/include/rpc/pmap_prot.h | 105 - cpukit/librpc/include/rpc/pmap_rmt.h | 64 - cpukit/librpc/include/rpc/rpc.h | 118 - cpukit/librpc/include/rpc/rpc_com.h | 65 - cpukit/librpc/include/rpc/rpc_msg.h | 205 -- cpukit/librpc/include/rpc/rpcent.h | 71 - cpukit/librpc/include/rpc/svc.h | 297 -- cpukit/librpc/include/rpc/svc_auth.h | 58 - cpukit/librpc/include/rpc/svc_soc.h | 125 - cpukit/librpc/include/rpc/types.h | 68 - cpukit/librpc/include/rpc/xdr.h | 312 -- cpukit/librpc/preinstall.am | 89 - cpukit/libstdthreads/Makefile.am | 2 - cpukit/mghttpd/Makefile.am | 9 +- cpukit/mghttpd/mongoose.h | 390 --- cpukit/mghttpd/preinstall.am | 41 - cpukit/posix/Makefile.am | 37 - cpukit/posix/include/aio.h | 193 -- cpukit/posix/include/mqueue.h | 218 -- cpukit/posix/include/rtems/posix/aio_misc.h | 113 - cpukit/posix/include/rtems/posix/barrierimpl.h | 99 - cpukit/posix/include/rtems/posix/condimpl.h | 184 - cpukit/posix/include/rtems/posix/config.h | 120 - cpukit/posix/include/rtems/posix/key.h | 95 - cpukit/posix/include/rtems/posix/keyimpl.h | 177 - cpukit/posix/include/rtems/posix/mmanimpl.h | 56 - cpukit/posix/include/rtems/posix/mqueue.h | 71 - cpukit/posix/include/rtems/posix/mqueueimpl.h | 183 - cpukit/posix/include/rtems/posix/muteximpl.h | 487 --- cpukit/posix/include/rtems/posix/posixapi.h | 146 - cpukit/posix/include/rtems/posix/priorityimpl.h | 109 - cpukit/posix/include/rtems/posix/psignal.h | 35 - cpukit/posix/include/rtems/posix/psignalimpl.h | 140 - cpukit/posix/include/rtems/posix/pthread.h | 55 - cpukit/posix/include/rtems/posix/pthreadattrimpl.h | 95 - cpukit/posix/include/rtems/posix/pthreadimpl.h | 129 - cpukit/posix/include/rtems/posix/ptimer.h | 88 - cpukit/posix/include/rtems/posix/rwlockimpl.h | 64 - cpukit/posix/include/rtems/posix/semaphore.h | 56 - cpukit/posix/include/rtems/posix/semaphoreimpl.h | 143 - cpukit/posix/include/rtems/posix/shm.h | 213 -- cpukit/posix/include/rtems/posix/shmimpl.h | 135 - cpukit/posix/include/rtems/posix/sigset.h | 45 - cpukit/posix/include/rtems/posix/spinlockimpl.h | 58 - cpukit/posix/include/rtems/posix/threadsup.h | 98 - cpukit/posix/include/rtems/posix/timer.h | 60 - cpukit/posix/include/rtems/posix/timerimpl.h | 134 - cpukit/posix/preinstall.am | 146 - cpukit/pppd/Makefile.am | 9 +- cpukit/pppd/preinstall.am | 43 - cpukit/pppd/rtemsdialer.h | 24 - cpukit/pppd/rtemspppd.h | 49 - cpukit/preinstall.am | 751 ---- cpukit/rtems/Makefile.am | 55 - cpukit/rtems/include/rtems.h | 192 -- cpukit/rtems/include/rtems/rtems/asr.h | 156 - cpukit/rtems/include/rtems/rtems/asrimpl.h | 99 - cpukit/rtems/include/rtems/rtems/attr.h | 191 -- cpukit/rtems/include/rtems/rtems/attrimpl.h | 263 -- cpukit/rtems/include/rtems/rtems/barrier.h | 173 - cpukit/rtems/include/rtems/rtems/barrierimpl.h | 92 - cpukit/rtems/include/rtems/rtems/cache.h | 370 -- cpukit/rtems/include/rtems/rtems/clock.h | 318 -- cpukit/rtems/include/rtems/rtems/config.h | 142 - cpukit/rtems/include/rtems/rtems/dpmem.h | 179 - cpukit/rtems/include/rtems/rtems/dpmemimpl.h | 85 - cpukit/rtems/include/rtems/rtems/event.h | 526 --- cpukit/rtems/include/rtems/rtems/eventimpl.h | 146 - cpukit/rtems/include/rtems/rtems/eventmp.h | 101 - cpukit/rtems/include/rtems/rtems/intr.h | 373 -- cpukit/rtems/include/rtems/rtems/message.h | 270 -- cpukit/rtems/include/rtems/rtems/messageimpl.h | 120 - cpukit/rtems/include/rtems/rtems/modes.h | 132 - cpukit/rtems/include/rtems/rtems/modesimpl.h | 146 - cpukit/rtems/include/rtems/rtems/mp.h | 54 - cpukit/rtems/include/rtems/rtems/msgmp.h | 211 -- cpukit/rtems/include/rtems/rtems/object.h | 370 -- cpukit/rtems/include/rtems/rtems/options.h | 83 - cpukit/rtems/include/rtems/rtems/optionsimpl.h | 67 - cpukit/rtems/include/rtems/rtems/part.h | 174 - cpukit/rtems/include/rtems/rtems/partimpl.h | 223 -- cpukit/rtems/include/rtems/rtems/partmp.h | 144 - cpukit/rtems/include/rtems/rtems/ratemon.h | 430 --- cpukit/rtems/include/rtems/rtems/ratemonimpl.h | 158 - cpukit/rtems/include/rtems/rtems/region.h | 298 -- cpukit/rtems/include/rtems/rtems/regionimpl.h | 142 - cpukit/rtems/include/rtems/rtems/sem.h | 278 -- cpukit/rtems/include/rtems/rtems/semimpl.h | 120 - cpukit/rtems/include/rtems/rtems/semmp.h | 171 - cpukit/rtems/include/rtems/rtems/signal.h | 83 - cpukit/rtems/include/rtems/rtems/signalimpl.h | 51 - cpukit/rtems/include/rtems/rtems/signalmp.h | 98 - cpukit/rtems/include/rtems/rtems/smp.h | 78 - cpukit/rtems/include/rtems/rtems/status.h | 263 -- cpukit/rtems/include/rtems/rtems/statusimpl.h | 64 - cpukit/rtems/include/rtems/rtems/support.h | 170 - cpukit/rtems/include/rtems/rtems/taskmp.h | 132 - cpukit/rtems/include/rtems/rtems/tasks.h | 716 ---- cpukit/rtems/include/rtems/rtems/tasksimpl.h | 131 - cpukit/rtems/include/rtems/rtems/timer.h | 384 --- cpukit/rtems/include/rtems/rtems/timerimpl.h | 209 -- cpukit/rtems/include/rtems/rtems/types.h | 235 -- cpukit/rtems/mainpage.h | 927 ----- cpukit/rtems/preinstall.am | 222 -- cpukit/sapi/Makefile.am | 24 - cpukit/sapi/include/confdefs.h | 3587 -------------------- cpukit/sapi/include/rtems/bsd.h | 141 - cpukit/sapi/include/rtems/cbs.h | 244 -- cpukit/sapi/include/rtems/chain.h | 789 ----- cpukit/sapi/include/rtems/config.h | 397 --- cpukit/sapi/include/rtems/counter.h | 160 - cpukit/sapi/include/rtems/extension.h | 245 -- cpukit/sapi/include/rtems/extensionimpl.h | 53 - cpukit/sapi/include/rtems/fatal.h | 134 - cpukit/sapi/include/rtems/init.h | 69 - cpukit/sapi/include/rtems/io.h | 254 -- cpukit/sapi/include/rtems/ioimpl.h | 65 - cpukit/sapi/include/rtems/mptables.h | 32 - cpukit/sapi/include/rtems/profiling.h | 333 -- cpukit/sapi/include/rtems/rbheap.h | 268 -- cpukit/sapi/include/rtems/rbtree.h | 456 --- cpukit/sapi/include/rtems/scheduler.h | 247 -- cpukit/sapi/include/rtems/timecounter.h | 335 -- cpukit/sapi/include/rtems/timespec.h | 305 -- cpukit/sapi/include/rtems/version.h | 77 - cpukit/sapi/preinstall.am | 100 - cpukit/score/Makefile.am | 127 +- cpukit/score/cpu/arm/Makefile.am | 18 +- cpukit/score/cpu/arm/headers.am | 24 + cpukit/score/cpu/arm/include/machine/elf_machdep.h | 132 + cpukit/score/cpu/arm/include/rtems/asm.h | 231 ++ cpukit/score/cpu/arm/include/rtems/score/arm.h | 94 + cpukit/score/cpu/arm/include/rtems/score/armv4.h | 98 + cpukit/score/cpu/arm/include/rtems/score/armv7m.h | 620 ++++ cpukit/score/cpu/arm/include/rtems/score/cpu.h | 702 ++++ cpukit/score/cpu/arm/include/rtems/score/cpu_asm.h | 39 + .../score/cpu/arm/include/rtems/score/cpuatomic.h | 14 + cpukit/score/cpu/arm/include/rtems/score/cpuimpl.h | 111 + cpukit/score/cpu/arm/include/rtems/score/types.h | 51 + cpukit/score/cpu/arm/preinstall.am | 70 - cpukit/score/cpu/arm/rtems/asm.h | 231 -- cpukit/score/cpu/arm/rtems/score/arm.h | 94 - cpukit/score/cpu/arm/rtems/score/armv4.h | 98 - cpukit/score/cpu/arm/rtems/score/armv7m.h | 620 ---- cpukit/score/cpu/arm/rtems/score/cpu.h | 702 ---- cpukit/score/cpu/arm/rtems/score/cpu_asm.h | 39 - cpukit/score/cpu/arm/rtems/score/cpuatomic.h | 14 - cpukit/score/cpu/arm/rtems/score/cpuimpl.h | 111 - cpukit/score/cpu/arm/rtems/score/types.h | 51 - cpukit/score/cpu/bfin/Makefile.am | 18 +- cpukit/score/cpu/bfin/headers.am | 24 + .../score/cpu/bfin/include/machine/elf_machdep.h | 28 + cpukit/score/cpu/bfin/include/rtems/asm.h | 127 + cpukit/score/cpu/bfin/include/rtems/bfin/bf52x.h | 430 +++ cpukit/score/cpu/bfin/include/rtems/bfin/bf533.h | 396 +++ cpukit/score/cpu/bfin/include/rtems/bfin/bfin.h | 88 + cpukit/score/cpu/bfin/include/rtems/score/bfin.h | 69 + cpukit/score/cpu/bfin/include/rtems/score/cpu.h | 1001 ++++++ .../score/cpu/bfin/include/rtems/score/cpu_asm.h | 27 + .../score/cpu/bfin/include/rtems/score/cpuatomic.h | 14 + .../score/cpu/bfin/include/rtems/score/cpuimpl.h | 34 + cpukit/score/cpu/bfin/include/rtems/score/types.h | 49 + cpukit/score/cpu/bfin/preinstall.am | 70 - cpukit/score/cpu/bfin/rtems/asm.h | 127 - cpukit/score/cpu/bfin/rtems/bfin/bf52x.h | 430 --- cpukit/score/cpu/bfin/rtems/bfin/bf533.h | 396 --- cpukit/score/cpu/bfin/rtems/bfin/bfin.h | 88 - cpukit/score/cpu/bfin/rtems/score/bfin.h | 69 - cpukit/score/cpu/bfin/rtems/score/cpu.h | 1001 ------ cpukit/score/cpu/bfin/rtems/score/cpu_asm.h | 27 - cpukit/score/cpu/bfin/rtems/score/cpuatomic.h | 14 - cpukit/score/cpu/bfin/rtems/score/cpuimpl.h | 34 - cpukit/score/cpu/bfin/rtems/score/types.h | 49 - cpukit/score/cpu/epiphany/Makefile.am | 17 +- cpukit/score/cpu/epiphany/headers.am | 15 + cpukit/score/cpu/epiphany/include/rtems/asm.h | 120 + .../score/cpu/epiphany/include/rtems/score/cpu.h | 873 +++++ .../cpu/epiphany/include/rtems/score/cpu_asm.h | 74 + .../cpu/epiphany/include/rtems/score/cpuatomic.h | 14 + .../cpu/epiphany/include/rtems/score/cpuimpl.h | 34 + .../include/rtems/score/epiphany-utility.h | 180 + .../cpu/epiphany/include/rtems/score/epiphany.h | 64 + .../score/cpu/epiphany/include/rtems/score/types.h | 67 + cpukit/score/cpu/epiphany/preinstall.am | 57 - cpukit/score/cpu/epiphany/rtems/asm.h | 120 - cpukit/score/cpu/epiphany/rtems/score/cpu.h | 873 ----- cpukit/score/cpu/epiphany/rtems/score/cpu_asm.h | 74 - cpukit/score/cpu/epiphany/rtems/score/cpuatomic.h | 14 - cpukit/score/cpu/epiphany/rtems/score/cpuimpl.h | 34 - .../cpu/epiphany/rtems/score/epiphany-utility.h | 180 - cpukit/score/cpu/epiphany/rtems/score/epiphany.h | 64 - cpukit/score/cpu/epiphany/rtems/score/types.h | 67 - cpukit/score/cpu/h8300/headers.am | 5 + .../score/cpu/h8300/include/machine/elf_machdep.h | 59 + cpukit/score/cpu/i386/Makefile.am | 15 +- cpukit/score/cpu/i386/headers.am | 20 + .../score/cpu/i386/include/machine/elf_machdep.h | 63 + cpukit/score/cpu/i386/include/rtems/asm.h | 140 + cpukit/score/cpu/i386/include/rtems/score/cpu.h | 700 ++++ .../score/cpu/i386/include/rtems/score/cpuatomic.h | 14 + .../score/cpu/i386/include/rtems/score/cpuimpl.h | 34 + cpukit/score/cpu/i386/include/rtems/score/i386.h | 670 ++++ cpukit/score/cpu/i386/include/rtems/score/idtr.h | 66 + .../cpu/i386/include/rtems/score/interrupts.h | 85 + .../score/cpu/i386/include/rtems/score/registers.h | 72 + cpukit/score/cpu/i386/include/rtems/score/types.h | 46 + cpukit/score/cpu/i386/preinstall.am | 61 - cpukit/score/cpu/i386/rtems/asm.h | 140 - cpukit/score/cpu/i386/rtems/score/cpu.h | 700 ---- cpukit/score/cpu/i386/rtems/score/cpuatomic.h | 14 - cpukit/score/cpu/i386/rtems/score/cpuimpl.h | 34 - cpukit/score/cpu/i386/rtems/score/i386.h | 670 ---- cpukit/score/cpu/i386/rtems/score/idtr.h | 66 - cpukit/score/cpu/i386/rtems/score/interrupts.h | 85 - cpukit/score/cpu/i386/rtems/score/registers.h | 72 - cpukit/score/cpu/i386/rtems/score/types.h | 46 - cpukit/score/cpu/lm32/Makefile.am | 13 +- cpukit/score/cpu/lm32/headers.am | 18 + .../score/cpu/lm32/include/machine/elf_machdep.h | 34 + cpukit/score/cpu/lm32/include/rtems/asm.h | 127 + cpukit/score/cpu/lm32/include/rtems/score/cpu.h | 1035 ++++++ .../score/cpu/lm32/include/rtems/score/cpu_asm.h | 74 + .../score/cpu/lm32/include/rtems/score/cpuatomic.h | 14 + .../score/cpu/lm32/include/rtems/score/cpuimpl.h | 34 + cpukit/score/cpu/lm32/include/rtems/score/lm32.h | 112 + cpukit/score/cpu/lm32/include/rtems/score/types.h | 46 + cpukit/score/cpu/lm32/preinstall.am | 53 - cpukit/score/cpu/lm32/rtems/asm.h | 127 - cpukit/score/cpu/lm32/rtems/score/cpu.h | 1035 ------ cpukit/score/cpu/lm32/rtems/score/cpu_asm.h | 74 - cpukit/score/cpu/lm32/rtems/score/cpuatomic.h | 14 - cpukit/score/cpu/lm32/rtems/score/cpuimpl.h | 34 - cpukit/score/cpu/lm32/rtems/score/lm32.h | 112 - cpukit/score/cpu/lm32/rtems/score/types.h | 46 - cpukit/score/cpu/m32c/Makefile.am | 15 +- cpukit/score/cpu/m32c/headers.am | 17 + cpukit/score/cpu/m32c/include/rtems/asm.h | 124 + cpukit/score/cpu/m32c/include/rtems/score/cpu.h | 985 ++++++ .../score/cpu/m32c/include/rtems/score/cpu_asm.h | 72 + .../score/cpu/m32c/include/rtems/score/cpuatomic.h | 14 + .../score/cpu/m32c/include/rtems/score/cpuimpl.h | 34 + cpukit/score/cpu/m32c/include/rtems/score/m32c.h | 76 + cpukit/score/cpu/m32c/include/rtems/score/types.h | 49 + cpukit/score/cpu/m32c/include/varvects.h | 58 + cpukit/score/cpu/m32c/preinstall.am | 62 - cpukit/score/cpu/m32c/rtems/asm.h | 124 - cpukit/score/cpu/m32c/rtems/score/cpu.h | 985 ------ cpukit/score/cpu/m32c/rtems/score/cpu_asm.h | 72 - cpukit/score/cpu/m32c/rtems/score/cpuatomic.h | 14 - cpukit/score/cpu/m32c/rtems/score/cpuimpl.h | 34 - cpukit/score/cpu/m32c/rtems/score/m32c.h | 76 - cpukit/score/cpu/m32c/rtems/score/types.h | 49 - cpukit/score/cpu/m32c/varvects.h | 58 - cpukit/score/cpu/m68k/Makefile.am | 18 +- cpukit/score/cpu/m68k/headers.am | 24 + .../score/cpu/m68k/include/machine/elf_machdep.h | 47 + cpukit/score/cpu/m68k/include/rtems/asm.h | 152 + cpukit/score/cpu/m68k/include/rtems/m68k/m68302.h | 659 ++++ cpukit/score/cpu/m68k/include/rtems/m68k/m68360.h | 899 +++++ cpukit/score/cpu/m68k/include/rtems/m68k/qsm.h | 204 ++ cpukit/score/cpu/m68k/include/rtems/m68k/sim.h | 333 ++ cpukit/score/cpu/m68k/include/rtems/score/cpu.h | 735 ++++ .../score/cpu/m68k/include/rtems/score/cpuatomic.h | 14 + .../score/cpu/m68k/include/rtems/score/cpuimpl.h | 34 + cpukit/score/cpu/m68k/include/rtems/score/m68k.h | 502 +++ cpukit/score/cpu/m68k/include/rtems/score/types.h | 43 + cpukit/score/cpu/m68k/preinstall.am | 70 - cpukit/score/cpu/m68k/rtems/asm.h | 152 - cpukit/score/cpu/m68k/rtems/m68k/m68302.h | 659 ---- cpukit/score/cpu/m68k/rtems/m68k/m68360.h | 899 ----- cpukit/score/cpu/m68k/rtems/m68k/qsm.h | 204 -- cpukit/score/cpu/m68k/rtems/m68k/sim.h | 333 -- cpukit/score/cpu/m68k/rtems/score/cpu.h | 735 ---- cpukit/score/cpu/m68k/rtems/score/cpuatomic.h | 14 - cpukit/score/cpu/m68k/rtems/score/cpuimpl.h | 34 - cpukit/score/cpu/m68k/rtems/score/m68k.h | 502 --- cpukit/score/cpu/m68k/rtems/score/types.h | 43 - cpukit/score/cpu/mips/Makefile.am | 16 +- cpukit/score/cpu/mips/headers.am | 22 + .../score/cpu/mips/include/machine/elf_machdep.h | 199 ++ cpukit/score/cpu/mips/include/rtems/asm.h | 160 + cpukit/score/cpu/mips/include/rtems/mips/idtcpu.h | 708 ++++ cpukit/score/cpu/mips/include/rtems/mips/iregdef.h | 337 ++ cpukit/score/cpu/mips/include/rtems/score/cpu.h | 1010 ++++++ .../score/cpu/mips/include/rtems/score/cpuatomic.h | 14 + .../score/cpu/mips/include/rtems/score/cpuimpl.h | 34 + cpukit/score/cpu/mips/include/rtems/score/mips.h | 299 ++ cpukit/score/cpu/mips/include/rtems/score/types.h | 56 + cpukit/score/cpu/mips/preinstall.am | 62 - cpukit/score/cpu/mips/rtems/asm.h | 160 - cpukit/score/cpu/mips/rtems/mips/idtcpu.h | 708 ---- cpukit/score/cpu/mips/rtems/mips/iregdef.h | 337 -- cpukit/score/cpu/mips/rtems/score/cpu.h | 1010 ------ cpukit/score/cpu/mips/rtems/score/cpuatomic.h | 14 - cpukit/score/cpu/mips/rtems/score/cpuimpl.h | 34 - cpukit/score/cpu/mips/rtems/score/mips.h | 299 -- cpukit/score/cpu/mips/rtems/score/types.h | 56 - cpukit/score/cpu/moxie/Makefile.am | 11 +- cpukit/score/cpu/moxie/headers.am | 17 + .../score/cpu/moxie/include/machine/elf_machdep.h | 15 + cpukit/score/cpu/moxie/include/rtems/asm.h | 116 + cpukit/score/cpu/moxie/include/rtems/score/cpu.h | 852 +++++ .../cpu/moxie/include/rtems/score/cpuatomic.h | 14 + .../score/cpu/moxie/include/rtems/score/cpuimpl.h | 34 + cpukit/score/cpu/moxie/include/rtems/score/moxie.h | 43 + cpukit/score/cpu/moxie/include/rtems/score/types.h | 56 + cpukit/score/cpu/moxie/preinstall.am | 49 - cpukit/score/cpu/moxie/rtems/asm.h | 116 - cpukit/score/cpu/moxie/rtems/score/cpu.h | 852 ----- cpukit/score/cpu/moxie/rtems/score/cpuatomic.h | 14 - cpukit/score/cpu/moxie/rtems/score/cpuimpl.h | 34 - cpukit/score/cpu/moxie/rtems/score/moxie.h | 43 - cpukit/score/cpu/moxie/rtems/score/types.h | 56 - cpukit/score/cpu/nios2/Makefile.am | 18 +- cpukit/score/cpu/nios2/headers.am | 20 + .../score/cpu/nios2/include/machine/elf_machdep.h | 46 + cpukit/score/cpu/nios2/include/rtems/asm.h | 98 + cpukit/score/cpu/nios2/include/rtems/score/cpu.h | 372 ++ .../score/cpu/nios2/include/rtems/score/cpu_asm.h | 74 + .../cpu/nios2/include/rtems/score/cpuatomic.h | 14 + .../score/cpu/nios2/include/rtems/score/cpuimpl.h | 34 + .../nios2/include/rtems/score/nios2-count-zeros.h | 70 + .../cpu/nios2/include/rtems/score/nios2-utility.h | 516 +++ cpukit/score/cpu/nios2/include/rtems/score/nios2.h | 65 + cpukit/score/cpu/nios2/include/rtems/score/types.h | 46 + cpukit/score/cpu/nios2/preinstall.am | 61 - cpukit/score/cpu/nios2/rtems/asm.h | 98 - cpukit/score/cpu/nios2/rtems/score/cpu.h | 372 -- cpukit/score/cpu/nios2/rtems/score/cpu_asm.h | 74 - cpukit/score/cpu/nios2/rtems/score/cpuatomic.h | 14 - cpukit/score/cpu/nios2/rtems/score/cpuimpl.h | 34 - .../cpu/nios2/rtems/score/nios2-count-zeros.h | 70 - cpukit/score/cpu/nios2/rtems/score/nios2-utility.h | 516 --- cpukit/score/cpu/nios2/rtems/score/nios2.h | 65 - cpukit/score/cpu/nios2/rtems/score/types.h | 46 - cpukit/score/cpu/no_cpu/Makefile.am | 12 +- cpukit/score/cpu/no_cpu/headers.am | 13 + cpukit/score/cpu/no_cpu/include/rtems/asm.h | 133 + cpukit/score/cpu/no_cpu/include/rtems/score/cpu.h | 1501 ++++++++ .../score/cpu/no_cpu/include/rtems/score/cpu_asm.h | 74 + .../score/cpu/no_cpu/include/rtems/score/cpuimpl.h | 82 + .../score/cpu/no_cpu/include/rtems/score/no_cpu.h | 67 + .../score/cpu/no_cpu/include/rtems/score/types.h | 43 + cpukit/score/cpu/no_cpu/preinstall.am | 49 - cpukit/score/cpu/no_cpu/rtems/asm.h | 133 - cpukit/score/cpu/no_cpu/rtems/score/cpu.h | 1501 -------- cpukit/score/cpu/no_cpu/rtems/score/cpu_asm.h | 74 - cpukit/score/cpu/no_cpu/rtems/score/cpuimpl.h | 82 - cpukit/score/cpu/no_cpu/rtems/score/no_cpu.h | 67 - cpukit/score/cpu/no_cpu/rtems/score/types.h | 43 - cpukit/score/cpu/or1k/Makefile.am | 17 +- cpukit/score/cpu/or1k/headers.am | 15 + cpukit/score/cpu/or1k/include/rtems/asm.h | 99 + cpukit/score/cpu/or1k/include/rtems/score/cpu.h | 872 +++++ .../score/cpu/or1k/include/rtems/score/cpu_asm.h | 74 + .../score/cpu/or1k/include/rtems/score/cpuatomic.h | 14 + .../score/cpu/or1k/include/rtems/score/cpuimpl.h | 34 + .../cpu/or1k/include/rtems/score/or1k-utility.h | 396 +++ cpukit/score/cpu/or1k/include/rtems/score/or1k.h | 49 + cpukit/score/cpu/or1k/include/rtems/score/types.h | 53 + cpukit/score/cpu/or1k/preinstall.am | 57 - cpukit/score/cpu/or1k/rtems/asm.h | 99 - cpukit/score/cpu/or1k/rtems/score/cpu.h | 872 ----- cpukit/score/cpu/or1k/rtems/score/cpu_asm.h | 74 - cpukit/score/cpu/or1k/rtems/score/cpuatomic.h | 14 - cpukit/score/cpu/or1k/rtems/score/cpuimpl.h | 34 - cpukit/score/cpu/or1k/rtems/score/or1k-utility.h | 396 --- cpukit/score/cpu/or1k/rtems/score/or1k.h | 49 - cpukit/score/cpu/or1k/rtems/score/types.h | 53 - cpukit/score/cpu/powerpc/Makefile.am | 15 +- cpukit/score/cpu/powerpc/headers.am | 21 + .../cpu/powerpc/include/machine/elf_machdep.h | 105 + cpukit/score/cpu/powerpc/include/rtems/asm.h | 310 ++ .../cpu/powerpc/include/rtems/powerpc/registers.h | 774 +++++ cpukit/score/cpu/powerpc/include/rtems/score/cpu.h | 1257 +++++++ .../cpu/powerpc/include/rtems/score/cpuatomic.h | 14 + .../cpu/powerpc/include/rtems/score/cpuimpl.h | 247 ++ .../cpu/powerpc/include/rtems/score/powerpc.h | 187 + .../score/cpu/powerpc/include/rtems/score/types.h | 62 + cpukit/score/cpu/powerpc/preinstall.am | 58 - cpukit/score/cpu/powerpc/rtems/asm.h | 310 -- cpukit/score/cpu/powerpc/rtems/powerpc/registers.h | 774 ----- cpukit/score/cpu/powerpc/rtems/score/cpu.h | 1257 ------- cpukit/score/cpu/powerpc/rtems/score/cpuatomic.h | 14 - cpukit/score/cpu/powerpc/rtems/score/cpuimpl.h | 247 -- cpukit/score/cpu/powerpc/rtems/score/powerpc.h | 187 - cpukit/score/cpu/powerpc/rtems/score/types.h | 62 - cpukit/score/cpu/riscv/Makefile.am | 14 +- cpukit/score/cpu/riscv/headers.am | 15 + cpukit/score/cpu/riscv/include/rtems/asm.h | 120 + cpukit/score/cpu/riscv/include/rtems/score/cpu.h | 604 ++++ .../score/cpu/riscv/include/rtems/score/cpu_asm.h | 90 + .../cpu/riscv/include/rtems/score/cpuatomic.h | 31 + .../score/cpu/riscv/include/rtems/score/cpuimpl.h | 51 + .../cpu/riscv/include/rtems/score/riscv-utility.h | 1526 +++++++++ cpukit/score/cpu/riscv/include/rtems/score/riscv.h | 66 + cpukit/score/cpu/riscv/include/rtems/score/types.h | 70 + cpukit/score/cpu/riscv/preinstall.am | 57 - cpukit/score/cpu/riscv/rtems/asm.h | 120 - cpukit/score/cpu/riscv/rtems/score/cpu.h | 604 ---- cpukit/score/cpu/riscv/rtems/score/cpu_asm.h | 90 - cpukit/score/cpu/riscv/rtems/score/cpuatomic.h | 31 - cpukit/score/cpu/riscv/rtems/score/cpuimpl.h | 51 - cpukit/score/cpu/riscv/rtems/score/riscv-utility.h | 1526 --------- cpukit/score/cpu/riscv/rtems/score/riscv.h | 66 - cpukit/score/cpu/riscv/rtems/score/types.h | 70 - cpukit/score/cpu/sh/Makefile.am | 13 +- cpukit/score/cpu/sh/headers.am | 14 + cpukit/score/cpu/sh/include/rtems/asm.h | 137 + cpukit/score/cpu/sh/include/rtems/score/cpu.h | 738 ++++ .../score/cpu/sh/include/rtems/score/cpuatomic.h | 14 + cpukit/score/cpu/sh/include/rtems/score/cpuimpl.h | 34 + cpukit/score/cpu/sh/include/rtems/score/sh.h | 277 ++ cpukit/score/cpu/sh/include/rtems/score/sh_io.h | 51 + cpukit/score/cpu/sh/include/rtems/score/types.h | 56 + cpukit/score/cpu/sh/preinstall.am | 53 - cpukit/score/cpu/sh/rtems/asm.h | 137 - cpukit/score/cpu/sh/rtems/score/cpu.h | 738 ---- cpukit/score/cpu/sh/rtems/score/cpuatomic.h | 14 - cpukit/score/cpu/sh/rtems/score/cpuimpl.h | 34 - cpukit/score/cpu/sh/rtems/score/sh.h | 277 -- cpukit/score/cpu/sh/rtems/score/sh_io.h | 51 - cpukit/score/cpu/sh/rtems/score/types.h | 56 - cpukit/score/cpu/sparc/Makefile.am | 16 +- cpukit/score/cpu/sparc/headers.am | 22 + .../score/cpu/sparc/include/machine/elf_machdep.h | 92 + cpukit/score/cpu/sparc/include/rtems/asm.h | 120 + cpukit/score/cpu/sparc/include/rtems/score/cpu.h | 1202 +++++++ .../cpu/sparc/include/rtems/score/cpuatomic.h | 14 + .../score/cpu/sparc/include/rtems/score/cpuimpl.h | 155 + cpukit/score/cpu/sparc/include/rtems/score/sparc.h | 418 +++ .../cpu/sparc/include/rtems/score/sparcimpl.h | 90 + cpukit/score/cpu/sparc/include/rtems/score/types.h | 53 + cpukit/score/cpu/sparc/preinstall.am | 62 - cpukit/score/cpu/sparc/rtems/asm.h | 120 - cpukit/score/cpu/sparc/rtems/score/cpu.h | 1202 ------- cpukit/score/cpu/sparc/rtems/score/cpuatomic.h | 14 - cpukit/score/cpu/sparc/rtems/score/cpuimpl.h | 155 - cpukit/score/cpu/sparc/rtems/score/sparc.h | 418 --- cpukit/score/cpu/sparc/rtems/score/sparcimpl.h | 90 - cpukit/score/cpu/sparc/rtems/score/types.h | 53 - cpukit/score/cpu/sparc64/Makefile.am | 12 +- cpukit/score/cpu/sparc64/headers.am | 13 + cpukit/score/cpu/sparc64/include/rtems/asm.h | 103 + cpukit/score/cpu/sparc64/include/rtems/score/cpu.h | 1051 ++++++ .../cpu/sparc64/include/rtems/score/cpuatomic.h | 14 + .../cpu/sparc64/include/rtems/score/cpuimpl.h | 34 + .../cpu/sparc64/include/rtems/score/sparc64.h | 342 ++ .../score/cpu/sparc64/include/rtems/score/types.h | 45 + cpukit/score/cpu/sparc64/preinstall.am | 49 - cpukit/score/cpu/sparc64/rtems/asm.h | 103 - cpukit/score/cpu/sparc64/rtems/score/cpu.h | 1051 ------ cpukit/score/cpu/sparc64/rtems/score/cpuatomic.h | 14 - cpukit/score/cpu/sparc64/rtems/score/cpuimpl.h | 34 - cpukit/score/cpu/sparc64/rtems/score/sparc64.h | 342 -- cpukit/score/cpu/sparc64/rtems/score/types.h | 45 - cpukit/score/cpu/v850/Makefile.am | 12 +- cpukit/score/cpu/v850/headers.am | 18 + .../score/cpu/v850/include/machine/elf_machdep.h | 74 + cpukit/score/cpu/v850/include/rtems/asm.h | 127 + cpukit/score/cpu/v850/include/rtems/score/cpu.h | 951 ++++++ .../score/cpu/v850/include/rtems/score/cpu_asm.h | 70 + .../score/cpu/v850/include/rtems/score/cpuatomic.h | 14 + .../score/cpu/v850/include/rtems/score/cpuimpl.h | 34 + cpukit/score/cpu/v850/include/rtems/score/types.h | 43 + cpukit/score/cpu/v850/include/rtems/score/v850.h | 137 + cpukit/score/cpu/v850/preinstall.am | 53 - cpukit/score/cpu/v850/rtems/asm.h | 127 - cpukit/score/cpu/v850/rtems/score/cpu.h | 951 ------ cpukit/score/cpu/v850/rtems/score/cpu_asm.h | 70 - cpukit/score/cpu/v850/rtems/score/cpuatomic.h | 14 - cpukit/score/cpu/v850/rtems/score/cpuimpl.h | 34 - cpukit/score/cpu/v850/rtems/score/types.h | 43 - cpukit/score/cpu/v850/rtems/score/v850.h | 137 - cpukit/score/include/rtems/linkersets.h | 129 - cpukit/score/include/rtems/score/address.h | 200 -- cpukit/score/include/rtems/score/apimutex.h | 109 - cpukit/score/include/rtems/score/assert.h | 108 - cpukit/score/include/rtems/score/atomic.h | 156 - cpukit/score/include/rtems/score/basedefs.h | 415 --- cpukit/score/include/rtems/score/chain.h | 102 - cpukit/score/include/rtems/score/chainimpl.h | 1123 ------ cpukit/score/include/rtems/score/context.h | 163 - cpukit/score/include/rtems/score/copyrt.h | 44 - cpukit/score/include/rtems/score/corebarrier.h | 91 - cpukit/score/include/rtems/score/corebarrierimpl.h | 173 - cpukit/score/include/rtems/score/coremsg.h | 185 - cpukit/score/include/rtems/score/coremsgimpl.h | 494 --- cpukit/score/include/rtems/score/coremutex.h | 104 - cpukit/score/include/rtems/score/coremuteximpl.h | 447 --- cpukit/score/include/rtems/score/corerwlockimpl.h | 182 - cpukit/score/include/rtems/score/coresem.h | 61 - cpukit/score/include/rtems/score/coresemimpl.h | 207 -- cpukit/score/include/rtems/score/cpustdatomic.h | 682 ---- cpukit/score/include/rtems/score/freechain.h | 111 - cpukit/score/include/rtems/score/heap.h | 518 --- cpukit/score/include/rtems/score/heapimpl.h | 601 ---- cpukit/score/include/rtems/score/interr.h | 268 -- cpukit/score/include/rtems/score/io.h | 46 - cpukit/score/include/rtems/score/isr.h | 155 - cpukit/score/include/rtems/score/isrlevel.h | 153 - cpukit/score/include/rtems/score/isrlock.h | 439 --- cpukit/score/include/rtems/score/mpci.h | 135 - cpukit/score/include/rtems/score/mpciimpl.h | 326 -- cpukit/score/include/rtems/score/mppkt.h | 121 - cpukit/score/include/rtems/score/mrsp.h | 79 - cpukit/score/include/rtems/score/mrspimpl.h | 384 --- cpukit/score/include/rtems/score/muteximpl.h | 37 - cpukit/score/include/rtems/score/object.h | 469 --- cpukit/score/include/rtems/score/objectimpl.h | 1002 ------ cpukit/score/include/rtems/score/objectmp.h | 197 -- cpukit/score/include/rtems/score/onceimpl.h | 52 - cpukit/score/include/rtems/score/percpu.h | 851 ----- cpukit/score/include/rtems/score/priority.h | 203 -- cpukit/score/include/rtems/score/prioritybitmap.h | 79 - .../score/include/rtems/score/prioritybitmapimpl.h | 215 -- cpukit/score/include/rtems/score/priorityimpl.h | 435 --- cpukit/score/include/rtems/score/processormask.h | 290 -- cpukit/score/include/rtems/score/profiling.h | 140 - cpukit/score/include/rtems/score/protectedheap.h | 172 - cpukit/score/include/rtems/score/rbtree.h | 568 ---- cpukit/score/include/rtems/score/rbtreeimpl.h | 72 - cpukit/score/include/rtems/score/scheduler.h | 556 --- cpukit/score/include/rtems/score/schedulercbs.h | 346 -- .../score/include/rtems/score/schedulercbsimpl.h | 59 - cpukit/score/include/rtems/score/scheduleredf.h | 197 -- .../score/include/rtems/score/scheduleredfimpl.h | 164 - cpukit/score/include/rtems/score/scheduleredfsmp.h | 200 -- cpukit/score/include/rtems/score/schedulerimpl.h | 1203 ------- cpukit/score/include/rtems/score/schedulernode.h | 217 -- .../score/include/rtems/score/schedulernodeimpl.h | 146 - .../score/include/rtems/score/schedulerpriority.h | 163 - .../rtems/score/schedulerpriorityaffinitysmp.h | 181 - .../include/rtems/score/schedulerpriorityimpl.h | 241 -- .../include/rtems/score/schedulerprioritysmp.h | 171 - .../include/rtems/score/schedulerprioritysmpimpl.h | 184 - cpukit/score/include/rtems/score/schedulersimple.h | 126 - .../include/rtems/score/schedulersimpleimpl.h | 103 - .../score/include/rtems/score/schedulersimplesmp.h | 155 - cpukit/score/include/rtems/score/schedulersmp.h | 127 - .../score/include/rtems/score/schedulersmpimpl.h | 1482 -------- .../score/include/rtems/score/schedulerstrongapa.h | 171 - cpukit/score/include/rtems/score/semaphoreimpl.h | 73 - cpukit/score/include/rtems/score/smp.h | 64 - cpukit/score/include/rtems/score/smpbarrier.h | 125 - cpukit/score/include/rtems/score/smpimpl.h | 354 -- cpukit/score/include/rtems/score/smplock.h | 327 -- cpukit/score/include/rtems/score/smplockmcs.h | 262 -- cpukit/score/include/rtems/score/smplockseq.h | 176 - cpukit/score/include/rtems/score/smplockstats.h | 277 -- cpukit/score/include/rtems/score/smplockticket.h | 187 - cpukit/score/include/rtems/score/stack.h | 69 - cpukit/score/include/rtems/score/stackimpl.h | 99 - cpukit/score/include/rtems/score/states.h | 50 - cpukit/score/include/rtems/score/statesimpl.h | 283 -- cpukit/score/include/rtems/score/status.h | 129 - cpukit/score/include/rtems/score/sysstate.h | 119 - cpukit/score/include/rtems/score/thread.h | 935 ----- cpukit/score/include/rtems/score/threaddispatch.h | 281 -- cpukit/score/include/rtems/score/threadimpl.h | 1969 ----------- cpukit/score/include/rtems/score/threadmp.h | 113 - cpukit/score/include/rtems/score/threadq.h | 595 ---- cpukit/score/include/rtems/score/threadqimpl.h | 1265 ------- cpukit/score/include/rtems/score/timecounter.h | 244 -- cpukit/score/include/rtems/score/timecounterimpl.h | 50 - cpukit/score/include/rtems/score/timespec.h | 272 -- cpukit/score/include/rtems/score/timestamp.h | 323 -- cpukit/score/include/rtems/score/tls.h | 217 -- cpukit/score/include/rtems/score/tod.h | 32 - cpukit/score/include/rtems/score/todimpl.h | 304 -- cpukit/score/include/rtems/score/userext.h | 273 -- cpukit/score/include/rtems/score/userextimpl.h | 369 -- cpukit/score/include/rtems/score/watchdog.h | 166 - cpukit/score/include/rtems/score/watchdogimpl.h | 574 ---- cpukit/score/include/rtems/score/wkspace.h | 138 - cpukit/score/include/rtems/seterr.h | 53 - cpukit/score/include/rtems/sysinit.h | 118 - cpukit/score/include/rtems/system.h | 66 - cpukit/score/include/sys/_ffcounter.h | 42 - cpukit/score/include/sys/timeffc.h | 391 --- cpukit/score/include/sys/timepps.h | 266 -- cpukit/score/include/sys/timetc.h | 105 - cpukit/score/include/sys/timex.h | 171 - cpukit/score/preinstall.am | 472 --- cpukit/telnetd/Makefile.am | 9 +- cpukit/telnetd/passwd.h | 25 - cpukit/telnetd/preinstall.am | 49 - cpukit/telnetd/pty.h | 76 - cpukit/telnetd/telnetd.h | 110 - cpukit/wrapup/Makefile.am | 6 +- cpukit/wrapup/preinstall.am | 24 - cpukit/zlib/Makefile.am | 8 +- cpukit/zlib/preinstall.am | 38 - cpukit/zlib/zlib.h | 1613 --------- 1189 files changed, 131699 insertions(+), 135860 deletions(-) create mode 100644 cpukit/aclocal/rtems-bsp-includes.m4 create mode 100644 cpukit/aclocal/rtems-build-top.m4 create mode 100644 cpukit/aclocal/rtems-includes.m4 create mode 100644 cpukit/aclocal/rtems-source-top.m4 delete mode 100644 cpukit/dev/include/dev/i2c/eeprom.h delete mode 100644 cpukit/dev/include/dev/i2c/fpga-i2c-slave.h delete mode 100644 cpukit/dev/include/dev/i2c/gpio-nxp-pca9535.h delete mode 100644 cpukit/dev/include/dev/i2c/i2c.h delete mode 100644 cpukit/dev/include/dev/i2c/sensor-lm75a.h delete mode 100644 cpukit/dev/include/dev/i2c/switch-nxp-pca9548a.h delete mode 100644 cpukit/dev/include/dev/i2c/ti-ads-16bit-adc.h delete mode 100644 cpukit/dev/include/dev/i2c/ti-lm25066a.h delete mode 100644 cpukit/dev/include/dev/i2c/ti-tmp112.h delete mode 100644 cpukit/dev/include/dev/i2c/xilinx-axi-i2c.h delete mode 100644 cpukit/dev/include/dev/serial/sc16is752.h delete mode 100644 cpukit/dev/include/dev/spi/spi.h delete mode 100644 cpukit/dev/include/linux/i2c-dev.h delete mode 100644 cpukit/dev/include/linux/i2c.h delete mode 100644 cpukit/dev/include/linux/spi/spidev.h delete mode 100644 cpukit/dev/preinstall.am delete mode 100644 cpukit/dtc/libfdt/fdt.h delete mode 100644 cpukit/dtc/libfdt/libfdt.h delete mode 100644 cpukit/dtc/libfdt/libfdt_env.h delete mode 100644 cpukit/dtc/libfdt/preinstall.am delete mode 100644 cpukit/ftpd/ftpd.h delete mode 100644 cpukit/ftpd/preinstall.am create mode 100644 cpukit/headers.am delete mode 100644 cpukit/include/adainclude/preinstall.am create mode 100644 cpukit/include/aio.h create mode 100644 cpukit/include/dev/i2c/eeprom.h create mode 100644 cpukit/include/dev/i2c/fpga-i2c-slave.h create mode 100644 cpukit/include/dev/i2c/gpio-nxp-pca9535.h create mode 100644 cpukit/include/dev/i2c/i2c.h create mode 100644 cpukit/include/dev/i2c/sensor-lm75a.h create mode 100644 cpukit/include/dev/i2c/switch-nxp-pca9548a.h create mode 100644 cpukit/include/dev/i2c/ti-ads-16bit-adc.h create mode 100644 cpukit/include/dev/i2c/ti-lm25066a.h create mode 100644 cpukit/include/dev/i2c/ti-tmp112.h create mode 100644 cpukit/include/dev/i2c/xilinx-axi-i2c.h create mode 100644 cpukit/include/dev/serial/sc16is752.h create mode 100644 cpukit/include/dev/spi/spi.h create mode 100644 cpukit/include/dlfcn.h create mode 100644 cpukit/include/drvmgr/drvmgr.h create mode 100644 cpukit/include/drvmgr/drvmgr_confdefs.h create mode 100644 cpukit/include/drvmgr/drvmgr_list.h create mode 100644 cpukit/include/drvmgr/pci_bus.h create mode 100644 cpukit/include/fdt.h create mode 100644 cpukit/include/libfdt.h create mode 100644 cpukit/include/libfdt_env.h create mode 100644 cpukit/include/librtemsNfs.h create mode 100644 cpukit/include/link.h create mode 100644 cpukit/include/link_elf.h create mode 100644 cpukit/include/linux/i2c-dev.h create mode 100644 cpukit/include/linux/i2c.h create mode 100644 cpukit/include/linux/spi/spidev.h create mode 100644 cpukit/include/machine/_kernel_cpuset.h create mode 100644 cpukit/include/machine/_kernel_param.h create mode 100644 cpukit/include/machine/_kernel_time.h create mode 100644 cpukit/include/machine/_kernel_types.h create mode 100644 cpukit/include/machine/_timecounter.h create mode 100644 cpukit/include/md4.h create mode 100644 cpukit/include/md5.h create mode 100644 cpukit/include/mghttpd/mongoose.h create mode 100644 cpukit/include/mqueue.h create mode 100644 cpukit/include/pci.h create mode 100644 cpukit/include/pci/access.h create mode 100644 cpukit/include/pci/cfg.h create mode 100644 cpukit/include/pci/cfg_auto.h create mode 100644 cpukit/include/pci/cfg_peripheral.h create mode 100644 cpukit/include/pci/cfg_read.h create mode 100644 cpukit/include/pci/cfg_static.h create mode 100644 cpukit/include/pci/ids.h create mode 100644 cpukit/include/pci/ids_extra.h create mode 100644 cpukit/include/pci/irq.h create mode 100644 cpukit/include/pci/pcireg.h create mode 100644 cpukit/include/rpc/auth.h create mode 100644 cpukit/include/rpc/auth_unix.h create mode 100644 cpukit/include/rpc/clnt.h create mode 100644 cpukit/include/rpc/clnt_soc.h create mode 100644 cpukit/include/rpc/clnt_stat.h create mode 100644 cpukit/include/rpc/pmap_clnt.h create mode 100644 cpukit/include/rpc/pmap_prot.h create mode 100644 cpukit/include/rpc/pmap_rmt.h create mode 100644 cpukit/include/rpc/rpc.h create mode 100644 cpukit/include/rpc/rpc_com.h create mode 100644 cpukit/include/rpc/rpc_msg.h create mode 100644 cpukit/include/rpc/rpcent.h create mode 100644 cpukit/include/rpc/svc.h create mode 100644 cpukit/include/rpc/svc_auth.h create mode 100644 cpukit/include/rpc/svc_soc.h create mode 100644 cpukit/include/rpc/types.h create mode 100644 cpukit/include/rpc/xdr.h create mode 100644 cpukit/include/rtems.h create mode 100644 cpukit/include/rtems/assoc.h create mode 100644 cpukit/include/rtems/bdbuf.h create mode 100644 cpukit/include/rtems/bdpart.h create mode 100644 cpukit/include/rtems/blkdev.h create mode 100644 cpukit/include/rtems/bsd.h create mode 100644 cpukit/include/rtems/bspcmdline.h create mode 100644 cpukit/include/rtems/capture-cli.h create mode 100644 cpukit/include/rtems/capture.h create mode 100644 cpukit/include/rtems/captureimpl.h create mode 100644 cpukit/include/rtems/cbs.h create mode 100644 cpukit/include/rtems/chain.h create mode 100755 cpukit/include/rtems/confdefs.h create mode 100644 cpukit/include/rtems/config.h create mode 100644 cpukit/include/rtems/counter.h create mode 100644 cpukit/include/rtems/cpuuse.h create mode 100644 cpukit/include/rtems/debugger/rtems-debugger-remote.h create mode 100644 cpukit/include/rtems/debugger/rtems-debugger-server.h create mode 100644 cpukit/include/rtems/devfs.h create mode 100644 cpukit/include/rtems/deviceio.h create mode 100644 cpukit/include/rtems/devnull.h create mode 100644 cpukit/include/rtems/devzero.h create mode 100644 cpukit/include/rtems/diskdevs.h create mode 100644 cpukit/include/rtems/dosfs.h create mode 100644 cpukit/include/rtems/dumpbuf.h create mode 100644 cpukit/include/rtems/error.h create mode 100644 cpukit/include/rtems/extension.h create mode 100644 cpukit/include/rtems/extensionimpl.h create mode 100644 cpukit/include/rtems/fatal.h create mode 100644 cpukit/include/rtems/fb.h create mode 100644 cpukit/include/rtems/flashdisk.h create mode 100644 cpukit/include/rtems/fsmount.h create mode 100644 cpukit/include/rtems/ftpd.h create mode 100644 cpukit/include/rtems/gxx_wrappers.h create mode 100644 cpukit/include/rtems/ide_part_table.h create mode 100644 cpukit/include/rtems/imfs.h create mode 100644 cpukit/include/rtems/init.h create mode 100644 cpukit/include/rtems/io.h create mode 100644 cpukit/include/rtems/ioimpl.h create mode 100644 cpukit/include/rtems/iosupp.h create mode 100644 cpukit/include/rtems/jffs2.h create mode 100644 cpukit/include/rtems/libcsupport.h create mode 100644 cpukit/include/rtems/libi2c.h create mode 100644 cpukit/include/rtems/libio.h create mode 100644 cpukit/include/rtems/libio_.h create mode 100644 cpukit/include/rtems/linkersets.h create mode 100644 cpukit/include/rtems/malloc.h create mode 100644 cpukit/include/rtems/media.h create mode 100644 cpukit/include/rtems/monitor.h create mode 100644 cpukit/include/rtems/mouse_parser.h create mode 100644 cpukit/include/rtems/mptables.h create mode 100644 cpukit/include/rtems/mw_uid.h create mode 100644 cpukit/include/rtems/nvdisk-sram.h create mode 100644 cpukit/include/rtems/nvdisk.h create mode 100644 cpukit/include/rtems/passwd.h create mode 100644 cpukit/include/rtems/pipe.h create mode 100644 cpukit/include/rtems/posix/aio_misc.h create mode 100644 cpukit/include/rtems/posix/barrierimpl.h create mode 100644 cpukit/include/rtems/posix/condimpl.h create mode 100644 cpukit/include/rtems/posix/config.h create mode 100644 cpukit/include/rtems/posix/key.h create mode 100644 cpukit/include/rtems/posix/keyimpl.h create mode 100644 cpukit/include/rtems/posix/mmanimpl.h create mode 100644 cpukit/include/rtems/posix/mqueue.h create mode 100644 cpukit/include/rtems/posix/mqueueimpl.h create mode 100644 cpukit/include/rtems/posix/muteximpl.h create mode 100644 cpukit/include/rtems/posix/posixapi.h create mode 100644 cpukit/include/rtems/posix/priorityimpl.h create mode 100644 cpukit/include/rtems/posix/psignal.h create mode 100644 cpukit/include/rtems/posix/psignalimpl.h create mode 100644 cpukit/include/rtems/posix/pthread.h create mode 100644 cpukit/include/rtems/posix/pthreadattrimpl.h create mode 100644 cpukit/include/rtems/posix/pthreadimpl.h create mode 100644 cpukit/include/rtems/posix/ptimer.h create mode 100644 cpukit/include/rtems/posix/rwlockimpl.h create mode 100644 cpukit/include/rtems/posix/semaphore.h create mode 100644 cpukit/include/rtems/posix/semaphoreimpl.h create mode 100644 cpukit/include/rtems/posix/shm.h create mode 100644 cpukit/include/rtems/posix/shmimpl.h create mode 100644 cpukit/include/rtems/posix/sigset.h create mode 100644 cpukit/include/rtems/posix/spinlockimpl.h create mode 100644 cpukit/include/rtems/posix/threadsup.h create mode 100644 cpukit/include/rtems/posix/timer.h create mode 100644 cpukit/include/rtems/posix/timerimpl.h create mode 100644 cpukit/include/rtems/profiling.h create mode 100644 cpukit/include/rtems/pty.h create mode 100644 cpukit/include/rtems/qreslib.h create mode 100644 cpukit/include/rtems/ramdisk.h create mode 100644 cpukit/include/rtems/rbheap.h create mode 100644 cpukit/include/rtems/rbtree.h create mode 100644 cpukit/include/rtems/rfs/rtems-rfs-bitmaps.h create mode 100644 cpukit/include/rtems/rfs/rtems-rfs-block-pos.h create mode 100644 cpukit/include/rtems/rfs/rtems-rfs-block.h create mode 100644 cpukit/include/rtems/rfs/rtems-rfs-buffer.h create mode 100644 cpukit/include/rtems/rfs/rtems-rfs-data.h create mode 100644 cpukit/include/rtems/rfs/rtems-rfs-dir-hash.h create mode 100644 cpukit/include/rtems/rfs/rtems-rfs-dir.h create mode 100644 cpukit/include/rtems/rfs/rtems-rfs-file-system-fwd.h create mode 100644 cpukit/include/rtems/rfs/rtems-rfs-file-system.h create mode 100644 cpukit/include/rtems/rfs/rtems-rfs-file.h create mode 100644 cpukit/include/rtems/rfs/rtems-rfs-group.h create mode 100644 cpukit/include/rtems/rfs/rtems-rfs-inode.h create mode 100644 cpukit/include/rtems/rfs/rtems-rfs-link.h create mode 100644 cpukit/include/rtems/rfs/rtems-rfs-mutex.h create mode 100644 cpukit/include/rtems/rfs/rtems-rfs-trace.h create mode 100644 cpukit/include/rtems/ringbuf.h create mode 100644 cpukit/include/rtems/rtems-debugger.h create mode 100644 cpukit/include/rtems/rtems-fdt-shell.h create mode 100644 cpukit/include/rtems/rtems-fdt.h create mode 100644 cpukit/include/rtems/rtems-rfs-format.h create mode 100644 cpukit/include/rtems/rtems-rfs-shell.h create mode 100644 cpukit/include/rtems/rtems-rfs.h create mode 100644 cpukit/include/rtems/rtems/asr.h create mode 100644 cpukit/include/rtems/rtems/asrimpl.h create mode 100644 cpukit/include/rtems/rtems/attr.h create mode 100644 cpukit/include/rtems/rtems/attrimpl.h create mode 100644 cpukit/include/rtems/rtems/barrier.h create mode 100644 cpukit/include/rtems/rtems/barrierimpl.h create mode 100644 cpukit/include/rtems/rtems/cache.h create mode 100644 cpukit/include/rtems/rtems/clock.h create mode 100644 cpukit/include/rtems/rtems/config.h create mode 100644 cpukit/include/rtems/rtems/dpmem.h create mode 100644 cpukit/include/rtems/rtems/dpmemimpl.h create mode 100644 cpukit/include/rtems/rtems/event.h create mode 100644 cpukit/include/rtems/rtems/eventimpl.h create mode 100644 cpukit/include/rtems/rtems/eventmp.h create mode 100644 cpukit/include/rtems/rtems/intr.h create mode 100644 cpukit/include/rtems/rtems/mainpage.h create mode 100644 cpukit/include/rtems/rtems/message.h create mode 100644 cpukit/include/rtems/rtems/messageimpl.h create mode 100644 cpukit/include/rtems/rtems/modes.h create mode 100644 cpukit/include/rtems/rtems/modesimpl.h create mode 100644 cpukit/include/rtems/rtems/mp.h create mode 100644 cpukit/include/rtems/rtems/msgmp.h create mode 100644 cpukit/include/rtems/rtems/object.h create mode 100644 cpukit/include/rtems/rtems/options.h create mode 100644 cpukit/include/rtems/rtems/optionsimpl.h create mode 100644 cpukit/include/rtems/rtems/part.h create mode 100644 cpukit/include/rtems/rtems/partimpl.h create mode 100644 cpukit/include/rtems/rtems/partmp.h create mode 100644 cpukit/include/rtems/rtems/ratemon.h create mode 100644 cpukit/include/rtems/rtems/ratemonimpl.h create mode 100644 cpukit/include/rtems/rtems/region.h create mode 100644 cpukit/include/rtems/rtems/regionimpl.h create mode 100644 cpukit/include/rtems/rtems/sem.h create mode 100644 cpukit/include/rtems/rtems/semimpl.h create mode 100644 cpukit/include/rtems/rtems/semmp.h create mode 100644 cpukit/include/rtems/rtems/signal.h create mode 100644 cpukit/include/rtems/rtems/signalimpl.h create mode 100644 cpukit/include/rtems/rtems/signalmp.h create mode 100644 cpukit/include/rtems/rtems/smp.h create mode 100644 cpukit/include/rtems/rtems/status.h create mode 100644 cpukit/include/rtems/rtems/statusimpl.h create mode 100644 cpukit/include/rtems/rtems/support.h create mode 100644 cpukit/include/rtems/rtems/taskmp.h create mode 100644 cpukit/include/rtems/rtems/tasks.h create mode 100644 cpukit/include/rtems/rtems/tasksimpl.h create mode 100644 cpukit/include/rtems/rtems/timer.h create mode 100644 cpukit/include/rtems/rtems/timerimpl.h create mode 100644 cpukit/include/rtems/rtems/types.h create mode 100644 cpukit/include/rtems/rtemsdialer.h create mode 100644 cpukit/include/rtems/rtemspppd.h create mode 100644 cpukit/include/rtems/rtl/dlfcn-shell.h create mode 100644 cpukit/include/rtems/rtl/rap-shell.h create mode 100644 cpukit/include/rtems/rtl/rap.h create mode 100644 cpukit/include/rtems/rtl/rtl-allocator.h create mode 100644 cpukit/include/rtems/rtl/rtl-fwd.h create mode 100644 cpukit/include/rtems/rtl/rtl-indirect-ptr.h create mode 100644 cpukit/include/rtems/rtl/rtl-obj-cache.h create mode 100644 cpukit/include/rtems/rtl/rtl-obj-comp.h create mode 100644 cpukit/include/rtems/rtl/rtl-obj-fwd.h create mode 100644 cpukit/include/rtems/rtl/rtl-obj.h create mode 100644 cpukit/include/rtems/rtl/rtl-sym.h create mode 100644 cpukit/include/rtems/rtl/rtl-trace.h create mode 100644 cpukit/include/rtems/rtl/rtl-unresolved.h create mode 100644 cpukit/include/rtems/rtl/rtl.h create mode 100644 cpukit/include/rtems/scheduler.h create mode 100644 cpukit/include/rtems/score/address.h create mode 100644 cpukit/include/rtems/score/apimutex.h create mode 100644 cpukit/include/rtems/score/assert.h create mode 100644 cpukit/include/rtems/score/atomic.h create mode 100644 cpukit/include/rtems/score/basedefs.h create mode 100644 cpukit/include/rtems/score/chain.h create mode 100644 cpukit/include/rtems/score/chainimpl.h create mode 100644 cpukit/include/rtems/score/context.h create mode 100644 cpukit/include/rtems/score/copyrt.h create mode 100644 cpukit/include/rtems/score/corebarrier.h create mode 100644 cpukit/include/rtems/score/corebarrierimpl.h create mode 100644 cpukit/include/rtems/score/coremsg.h create mode 100644 cpukit/include/rtems/score/coremsgimpl.h create mode 100644 cpukit/include/rtems/score/coremutex.h create mode 100644 cpukit/include/rtems/score/coremuteximpl.h create mode 100644 cpukit/include/rtems/score/corerwlockimpl.h create mode 100644 cpukit/include/rtems/score/coresem.h create mode 100644 cpukit/include/rtems/score/coresemimpl.h create mode 100644 cpukit/include/rtems/score/cpustdatomic.h create mode 100644 cpukit/include/rtems/score/freechain.h create mode 100644 cpukit/include/rtems/score/heap.h create mode 100644 cpukit/include/rtems/score/heapimpl.h create mode 100644 cpukit/include/rtems/score/interr.h create mode 100644 cpukit/include/rtems/score/io.h create mode 100644 cpukit/include/rtems/score/isr.h create mode 100644 cpukit/include/rtems/score/isrlevel.h create mode 100644 cpukit/include/rtems/score/isrlock.h create mode 100644 cpukit/include/rtems/score/mpci.h create mode 100644 cpukit/include/rtems/score/mpciimpl.h create mode 100644 cpukit/include/rtems/score/mppkt.h create mode 100644 cpukit/include/rtems/score/mrsp.h create mode 100644 cpukit/include/rtems/score/mrspimpl.h create mode 100644 cpukit/include/rtems/score/muteximpl.h create mode 100644 cpukit/include/rtems/score/object.h create mode 100644 cpukit/include/rtems/score/objectimpl.h create mode 100644 cpukit/include/rtems/score/objectmp.h create mode 100644 cpukit/include/rtems/score/onceimpl.h create mode 100644 cpukit/include/rtems/score/percpu.h create mode 100644 cpukit/include/rtems/score/priority.h create mode 100644 cpukit/include/rtems/score/prioritybitmap.h create mode 100644 cpukit/include/rtems/score/prioritybitmapimpl.h create mode 100644 cpukit/include/rtems/score/priorityimpl.h create mode 100644 cpukit/include/rtems/score/processormask.h create mode 100644 cpukit/include/rtems/score/profiling.h create mode 100644 cpukit/include/rtems/score/protectedheap.h create mode 100644 cpukit/include/rtems/score/rbtree.h create mode 100644 cpukit/include/rtems/score/rbtreeimpl.h create mode 100644 cpukit/include/rtems/score/scheduler.h create mode 100644 cpukit/include/rtems/score/schedulercbs.h create mode 100644 cpukit/include/rtems/score/schedulercbsimpl.h create mode 100644 cpukit/include/rtems/score/scheduleredf.h create mode 100644 cpukit/include/rtems/score/scheduleredfimpl.h create mode 100644 cpukit/include/rtems/score/scheduleredfsmp.h create mode 100644 cpukit/include/rtems/score/schedulerimpl.h create mode 100644 cpukit/include/rtems/score/schedulernode.h create mode 100644 cpukit/include/rtems/score/schedulernodeimpl.h create mode 100644 cpukit/include/rtems/score/schedulerpriority.h create mode 100644 cpukit/include/rtems/score/schedulerpriorityaffinitysmp.h create mode 100644 cpukit/include/rtems/score/schedulerpriorityimpl.h create mode 100644 cpukit/include/rtems/score/schedulerprioritysmp.h create mode 100644 cpukit/include/rtems/score/schedulerprioritysmpimpl.h create mode 100644 cpukit/include/rtems/score/schedulersimple.h create mode 100644 cpukit/include/rtems/score/schedulersimpleimpl.h create mode 100644 cpukit/include/rtems/score/schedulersimplesmp.h create mode 100644 cpukit/include/rtems/score/schedulersmp.h create mode 100644 cpukit/include/rtems/score/schedulersmpimpl.h create mode 100644 cpukit/include/rtems/score/schedulerstrongapa.h create mode 100644 cpukit/include/rtems/score/semaphoreimpl.h create mode 100644 cpukit/include/rtems/score/smp.h create mode 100644 cpukit/include/rtems/score/smpbarrier.h create mode 100644 cpukit/include/rtems/score/smpimpl.h create mode 100644 cpukit/include/rtems/score/smplock.h create mode 100644 cpukit/include/rtems/score/smplockmcs.h create mode 100644 cpukit/include/rtems/score/smplockseq.h create mode 100644 cpukit/include/rtems/score/smplockstats.h create mode 100644 cpukit/include/rtems/score/smplockticket.h create mode 100644 cpukit/include/rtems/score/stack.h create mode 100644 cpukit/include/rtems/score/stackimpl.h create mode 100644 cpukit/include/rtems/score/states.h create mode 100644 cpukit/include/rtems/score/statesimpl.h create mode 100644 cpukit/include/rtems/score/status.h create mode 100644 cpukit/include/rtems/score/sysstate.h create mode 100644 cpukit/include/rtems/score/thread.h create mode 100644 cpukit/include/rtems/score/threaddispatch.h create mode 100644 cpukit/include/rtems/score/threadimpl.h create mode 100644 cpukit/include/rtems/score/threadmp.h create mode 100644 cpukit/include/rtems/score/threadq.h create mode 100644 cpukit/include/rtems/score/threadqimpl.h create mode 100644 cpukit/include/rtems/score/timecounter.h create mode 100644 cpukit/include/rtems/score/timecounterimpl.h create mode 100644 cpukit/include/rtems/score/timespec.h create mode 100644 cpukit/include/rtems/score/timestamp.h create mode 100644 cpukit/include/rtems/score/tls.h create mode 100644 cpukit/include/rtems/score/tod.h create mode 100644 cpukit/include/rtems/score/todimpl.h create mode 100644 cpukit/include/rtems/score/userext.h create mode 100644 cpukit/include/rtems/score/userextimpl.h create mode 100644 cpukit/include/rtems/score/watchdog.h create mode 100644 cpukit/include/rtems/score/watchdogimpl.h create mode 100644 cpukit/include/rtems/score/wkspace.h create mode 100644 cpukit/include/rtems/serdbg.h create mode 100644 cpukit/include/rtems/serdbgcnf.h create mode 100644 cpukit/include/rtems/serial_mouse.h create mode 100644 cpukit/include/rtems/seterr.h create mode 100644 cpukit/include/rtems/shell.h create mode 100644 cpukit/include/rtems/shellconfig.h create mode 100644 cpukit/include/rtems/sparse-disk.h create mode 100644 cpukit/include/rtems/spurious.h create mode 100644 cpukit/include/rtems/stackchk.h create mode 100644 cpukit/include/rtems/stdio-redirect.h create mode 100644 cpukit/include/rtems/stringto.h create mode 100644 cpukit/include/rtems/sysinit.h create mode 100644 cpukit/include/rtems/system.h create mode 100644 cpukit/include/rtems/telnetd.h create mode 100644 cpukit/include/rtems/termios_printk.h create mode 100644 cpukit/include/rtems/termios_printk_cnf.h create mode 100644 cpukit/include/rtems/termiostypes.h create mode 100644 cpukit/include/rtems/test.h create mode 100644 cpukit/include/rtems/timecounter.h create mode 100644 cpukit/include/rtems/timespec.h create mode 100644 cpukit/include/rtems/tod.h create mode 100644 cpukit/include/rtems/trace/rtems-trace-buffer-vars.h create mode 100644 cpukit/include/rtems/untar.h create mode 100644 cpukit/include/rtems/version.h create mode 100644 cpukit/include/rtems/vmeintr.h create mode 100644 cpukit/include/sha256.h create mode 100644 cpukit/include/sha512.h create mode 100644 cpukit/include/sys/_ffcounter.h create mode 100644 cpukit/include/sys/cdefs_elf.h create mode 100644 cpukit/include/sys/event.h create mode 100644 cpukit/include/sys/exec_elf.h create mode 100644 cpukit/include/sys/poll.h create mode 100644 cpukit/include/sys/statvfs.h create mode 100644 cpukit/include/sys/timeffc.h create mode 100644 cpukit/include/sys/timepps.h create mode 100644 cpukit/include/sys/timetc.h create mode 100644 cpukit/include/sys/timex.h create mode 100644 cpukit/include/sys/utsname.h create mode 100644 cpukit/include/utf8proc/utf8proc.h create mode 100644 cpukit/include/uuid/uuid.h create mode 100644 cpukit/include/xz.h create mode 100644 cpukit/include/zlib.h delete mode 100644 cpukit/libblock/include/rtems/bdbuf.h delete mode 100644 cpukit/libblock/include/rtems/bdpart.h delete mode 100644 cpukit/libblock/include/rtems/blkdev.h delete mode 100644 cpukit/libblock/include/rtems/diskdevs.h delete mode 100644 cpukit/libblock/include/rtems/flashdisk.h delete mode 100644 cpukit/libblock/include/rtems/ide_part_table.h delete mode 100644 cpukit/libblock/include/rtems/media.h delete mode 100644 cpukit/libblock/include/rtems/nvdisk-sram.h delete mode 100644 cpukit/libblock/include/rtems/nvdisk.h delete mode 100644 cpukit/libblock/include/rtems/ramdisk.h delete mode 100644 cpukit/libblock/include/rtems/sparse-disk.h delete mode 100644 cpukit/libcrypt/preinstall.am delete mode 100644 cpukit/libcsupport/include/iosupp.h delete mode 100644 cpukit/libcsupport/include/machine/_kernel_cpuset.h delete mode 100644 cpukit/libcsupport/include/machine/_kernel_param.h delete mode 100644 cpukit/libcsupport/include/machine/_kernel_time.h delete mode 100644 cpukit/libcsupport/include/machine/_kernel_types.h delete mode 100644 cpukit/libcsupport/include/machine/_timecounter.h delete mode 100644 cpukit/libcsupport/include/ringbuf.h delete mode 100644 cpukit/libcsupport/include/rtems/assoc.h delete mode 100644 cpukit/libcsupport/include/rtems/deviceio.h delete mode 100644 cpukit/libcsupport/include/rtems/error.h delete mode 100644 cpukit/libcsupport/include/rtems/gxx_wrappers.h delete mode 100644 cpukit/libcsupport/include/rtems/libcsupport.h delete mode 100644 cpukit/libcsupport/include/rtems/libio.h delete mode 100644 cpukit/libcsupport/include/rtems/libio_.h delete mode 100644 cpukit/libcsupport/include/rtems/malloc.h delete mode 100644 cpukit/libcsupport/include/rtems/termiostypes.h delete mode 100644 cpukit/libcsupport/include/rtems/tod.h delete mode 100644 cpukit/libcsupport/include/spurious.h delete mode 100644 cpukit/libcsupport/include/sys/event.h delete mode 100644 cpukit/libcsupport/include/sys/poll.h delete mode 100644 cpukit/libcsupport/include/sys/statvfs.h delete mode 100644 cpukit/libcsupport/include/sys/utsname.h delete mode 100644 cpukit/libcsupport/include/vmeintr.h delete mode 100644 cpukit/libcsupport/preinstall.am delete mode 100644 cpukit/libdebugger/preinstall.am delete mode 100644 cpukit/libdebugger/rtems-debugger-remote.h delete mode 100644 cpukit/libdebugger/rtems-debugger-server.h delete mode 100644 cpukit/libdebugger/rtems-debugger.h delete mode 100644 cpukit/libdl/dlfcn-shell.h delete mode 100644 cpukit/libdl/dlfcn.h delete mode 100644 cpukit/libdl/include/arch/arm/machine/elf_machdep.h delete mode 100644 cpukit/libdl/include/arch/bfin/machine/elf_machdep.h delete mode 100644 cpukit/libdl/include/arch/h8300/machine/elf_machdep.h delete mode 100644 cpukit/libdl/include/arch/i386/machine/elf_machdep.h delete mode 100644 cpukit/libdl/include/arch/lm32/machine/elf_machdep.h delete mode 100644 cpukit/libdl/include/arch/m68k/machine/elf_machdep.h delete mode 100644 cpukit/libdl/include/arch/mips/machine/elf_machdep.h delete mode 100644 cpukit/libdl/include/arch/moxie/machine/elf_machdep.h delete mode 100644 cpukit/libdl/include/arch/nios2/machine/elf_machdep.h delete mode 100644 cpukit/libdl/include/arch/powerpc/machine/elf_machdep.h delete mode 100644 cpukit/libdl/include/arch/sparc/machine/elf_machdep.h delete mode 100644 cpukit/libdl/include/arch/v850/machine/elf_machdep.h delete mode 100644 cpukit/libdl/include/link.h delete mode 100644 cpukit/libdl/include/link_elf.h delete mode 100644 cpukit/libdl/include/sys/cdefs_elf.h delete mode 100644 cpukit/libdl/include/sys/exec_elf.h delete mode 100644 cpukit/libdl/preinstall.am delete mode 100644 cpukit/libdl/rap-shell.h delete mode 100644 cpukit/libdl/rap.h delete mode 100644 cpukit/libdl/rtl-allocator.h delete mode 100644 cpukit/libdl/rtl-fwd.h delete mode 100644 cpukit/libdl/rtl-indirect-ptr.h delete mode 100644 cpukit/libdl/rtl-obj-cache.h delete mode 100644 cpukit/libdl/rtl-obj-comp.h delete mode 100644 cpukit/libdl/rtl-obj-fwd.h delete mode 100644 cpukit/libdl/rtl-obj.h delete mode 100644 cpukit/libdl/rtl-sym.h delete mode 100644 cpukit/libdl/rtl-trace.h delete mode 100644 cpukit/libdl/rtl-unresolved.h delete mode 100644 cpukit/libdl/rtl.h delete mode 100644 cpukit/libdrvmgr/drvmgr.h delete mode 100644 cpukit/libdrvmgr/drvmgr_confdefs.h delete mode 100644 cpukit/libdrvmgr/drvmgr_list.h delete mode 100644 cpukit/libfs/preinstall.am delete mode 100644 cpukit/libfs/src/devfs/devfs.h delete mode 100644 cpukit/libfs/src/dosfs/dosfs.h delete mode 100644 cpukit/libfs/src/imfs/imfs.h delete mode 100644 cpukit/libfs/src/jffs2/include/rtems/jffs2.h delete mode 100644 cpukit/libfs/src/nfsclient/preinstall.am delete mode 100644 cpukit/libfs/src/nfsclient/src/librtemsNfs.h delete mode 100644 cpukit/libfs/src/pipe/pipe.h delete mode 100644 cpukit/libfs/src/rfs/rtems-rfs-bitmaps.h delete mode 100644 cpukit/libfs/src/rfs/rtems-rfs-block-pos.h delete mode 100644 cpukit/libfs/src/rfs/rtems-rfs-block.h delete mode 100644 cpukit/libfs/src/rfs/rtems-rfs-buffer.h delete mode 100644 cpukit/libfs/src/rfs/rtems-rfs-data.h delete mode 100644 cpukit/libfs/src/rfs/rtems-rfs-dir-hash.h delete mode 100644 cpukit/libfs/src/rfs/rtems-rfs-dir.h delete mode 100644 cpukit/libfs/src/rfs/rtems-rfs-file-system-fwd.h delete mode 100644 cpukit/libfs/src/rfs/rtems-rfs-file-system.h delete mode 100644 cpukit/libfs/src/rfs/rtems-rfs-file.h delete mode 100644 cpukit/libfs/src/rfs/rtems-rfs-format.h delete mode 100644 cpukit/libfs/src/rfs/rtems-rfs-group.h delete mode 100644 cpukit/libfs/src/rfs/rtems-rfs-inode.h delete mode 100644 cpukit/libfs/src/rfs/rtems-rfs-link.h delete mode 100644 cpukit/libfs/src/rfs/rtems-rfs-mutex.h delete mode 100644 cpukit/libfs/src/rfs/rtems-rfs-shell.h delete mode 100644 cpukit/libfs/src/rfs/rtems-rfs-trace.h delete mode 100644 cpukit/libfs/src/rfs/rtems-rfs.h delete mode 100644 cpukit/libi2c/libi2c.h delete mode 100644 cpukit/libmd/md4.h delete mode 100644 cpukit/libmd/md5.h delete mode 100644 cpukit/libmd/preinstall.am delete mode 100644 cpukit/libmd/sha256.h delete mode 100644 cpukit/libmd/sha512.h delete mode 100644 cpukit/libmisc/bspcmdline/bspcmdline.h delete mode 100644 cpukit/libmisc/capture/capture-cli.h delete mode 100644 cpukit/libmisc/capture/capture.h delete mode 100644 cpukit/libmisc/capture/captureimpl.h delete mode 100644 cpukit/libmisc/capture/rtems-trace-buffer-vars.h delete mode 100644 cpukit/libmisc/cpuuse/cpuuse.h delete mode 100644 cpukit/libmisc/devnull/devnull.h delete mode 100644 cpukit/libmisc/devnull/devzero.h delete mode 100644 cpukit/libmisc/dumpbuf/dumpbuf.h delete mode 100644 cpukit/libmisc/fb/fb.h delete mode 100644 cpukit/libmisc/fb/mw_uid.h delete mode 100644 cpukit/libmisc/fsmount/fsmount.h delete mode 100644 cpukit/libmisc/monitor/monitor.h delete mode 100644 cpukit/libmisc/mouse/mouse_parser.h delete mode 100644 cpukit/libmisc/mouse/serial_mouse.h delete mode 100644 cpukit/libmisc/preinstall.am delete mode 100644 cpukit/libmisc/redirector/stdio-redirect.h delete mode 100644 cpukit/libmisc/rtems-fdt/rtems-fdt-shell.h delete mode 100644 cpukit/libmisc/rtems-fdt/rtems-fdt.h delete mode 100644 cpukit/libmisc/serdbg/serdbg.h delete mode 100644 cpukit/libmisc/serdbg/serdbgcnf.h delete mode 100644 cpukit/libmisc/serdbg/termios_printk.h delete mode 100644 cpukit/libmisc/serdbg/termios_printk_cnf.h delete mode 100644 cpukit/libmisc/shell/shell.h delete mode 100644 cpukit/libmisc/shell/shellconfig.h delete mode 100644 cpukit/libmisc/stackchk/stackchk.h delete mode 100644 cpukit/libmisc/stringto/stringto.h delete mode 100644 cpukit/libmisc/testsupport/test.h delete mode 100644 cpukit/libmisc/untar/untar.h delete mode 100644 cpukit/libmisc/utf8proc/utf8proc.h delete mode 100644 cpukit/libmisc/uuid/uuid.h delete mode 100644 cpukit/libmisc/xz/xz.h create mode 100644 cpukit/libnetworking/headers.am delete mode 100644 cpukit/libnetworking/preinstall.am delete mode 100644 cpukit/libnetworking/sys/poll.h delete mode 100644 cpukit/libpci/pci.h delete mode 100644 cpukit/libpci/pci/access.h delete mode 100644 cpukit/libpci/pci/cfg.h delete mode 100644 cpukit/libpci/pci/cfg_auto.h delete mode 100644 cpukit/libpci/pci/cfg_peripheral.h delete mode 100644 cpukit/libpci/pci/cfg_read.h delete mode 100644 cpukit/libpci/pci/cfg_static.h delete mode 100644 cpukit/libpci/pci/ids.h delete mode 100644 cpukit/libpci/pci/ids_extra.h delete mode 100644 cpukit/libpci/pci/irq.h delete mode 100644 cpukit/libpci/pci/pcireg.h delete mode 100644 cpukit/libpci/pci_bus.h delete mode 100644 cpukit/libpci/preinstall.am delete mode 100644 cpukit/libqos/qreslib.h delete mode 100644 cpukit/librpc/include/rpc/auth.h delete mode 100644 cpukit/librpc/include/rpc/auth_unix.h delete mode 100644 cpukit/librpc/include/rpc/clnt.h delete mode 100644 cpukit/librpc/include/rpc/clnt_soc.h delete mode 100644 cpukit/librpc/include/rpc/clnt_stat.h delete mode 100644 cpukit/librpc/include/rpc/pmap_clnt.h delete mode 100644 cpukit/librpc/include/rpc/pmap_prot.h delete mode 100644 cpukit/librpc/include/rpc/pmap_rmt.h delete mode 100644 cpukit/librpc/include/rpc/rpc.h delete mode 100644 cpukit/librpc/include/rpc/rpc_com.h delete mode 100644 cpukit/librpc/include/rpc/rpc_msg.h delete mode 100644 cpukit/librpc/include/rpc/rpcent.h delete mode 100644 cpukit/librpc/include/rpc/svc.h delete mode 100644 cpukit/librpc/include/rpc/svc_auth.h delete mode 100644 cpukit/librpc/include/rpc/svc_soc.h delete mode 100644 cpukit/librpc/include/rpc/types.h delete mode 100644 cpukit/librpc/include/rpc/xdr.h delete mode 100644 cpukit/librpc/preinstall.am delete mode 100644 cpukit/mghttpd/mongoose.h delete mode 100644 cpukit/mghttpd/preinstall.am delete mode 100644 cpukit/posix/include/aio.h delete mode 100644 cpukit/posix/include/mqueue.h delete mode 100644 cpukit/posix/include/rtems/posix/aio_misc.h delete mode 100644 cpukit/posix/include/rtems/posix/barrierimpl.h delete mode 100644 cpukit/posix/include/rtems/posix/condimpl.h delete mode 100644 cpukit/posix/include/rtems/posix/config.h delete mode 100644 cpukit/posix/include/rtems/posix/key.h delete mode 100644 cpukit/posix/include/rtems/posix/keyimpl.h delete mode 100644 cpukit/posix/include/rtems/posix/mmanimpl.h delete mode 100644 cpukit/posix/include/rtems/posix/mqueue.h delete mode 100644 cpukit/posix/include/rtems/posix/mqueueimpl.h delete mode 100644 cpukit/posix/include/rtems/posix/muteximpl.h delete mode 100644 cpukit/posix/include/rtems/posix/posixapi.h delete mode 100644 cpukit/posix/include/rtems/posix/priorityimpl.h delete mode 100644 cpukit/posix/include/rtems/posix/psignal.h delete mode 100644 cpukit/posix/include/rtems/posix/psignalimpl.h delete mode 100644 cpukit/posix/include/rtems/posix/pthread.h delete mode 100644 cpukit/posix/include/rtems/posix/pthreadattrimpl.h delete mode 100644 cpukit/posix/include/rtems/posix/pthreadimpl.h delete mode 100644 cpukit/posix/include/rtems/posix/ptimer.h delete mode 100644 cpukit/posix/include/rtems/posix/rwlockimpl.h delete mode 100644 cpukit/posix/include/rtems/posix/semaphore.h delete mode 100644 cpukit/posix/include/rtems/posix/semaphoreimpl.h delete mode 100644 cpukit/posix/include/rtems/posix/shm.h delete mode 100644 cpukit/posix/include/rtems/posix/shmimpl.h delete mode 100644 cpukit/posix/include/rtems/posix/sigset.h delete mode 100644 cpukit/posix/include/rtems/posix/spinlockimpl.h delete mode 100644 cpukit/posix/include/rtems/posix/threadsup.h delete mode 100644 cpukit/posix/include/rtems/posix/timer.h delete mode 100644 cpukit/posix/include/rtems/posix/timerimpl.h delete mode 100644 cpukit/posix/preinstall.am delete mode 100644 cpukit/pppd/preinstall.am delete mode 100644 cpukit/pppd/rtemsdialer.h delete mode 100644 cpukit/pppd/rtemspppd.h delete mode 100644 cpukit/preinstall.am delete mode 100644 cpukit/rtems/include/rtems.h delete mode 100644 cpukit/rtems/include/rtems/rtems/asr.h delete mode 100644 cpukit/rtems/include/rtems/rtems/asrimpl.h delete mode 100644 cpukit/rtems/include/rtems/rtems/attr.h delete mode 100644 cpukit/rtems/include/rtems/rtems/attrimpl.h delete mode 100644 cpukit/rtems/include/rtems/rtems/barrier.h delete mode 100644 cpukit/rtems/include/rtems/rtems/barrierimpl.h delete mode 100644 cpukit/rtems/include/rtems/rtems/cache.h delete mode 100644 cpukit/rtems/include/rtems/rtems/clock.h delete mode 100644 cpukit/rtems/include/rtems/rtems/config.h delete mode 100644 cpukit/rtems/include/rtems/rtems/dpmem.h delete mode 100644 cpukit/rtems/include/rtems/rtems/dpmemimpl.h delete mode 100644 cpukit/rtems/include/rtems/rtems/event.h delete mode 100644 cpukit/rtems/include/rtems/rtems/eventimpl.h delete mode 100644 cpukit/rtems/include/rtems/rtems/eventmp.h delete mode 100644 cpukit/rtems/include/rtems/rtems/intr.h delete mode 100644 cpukit/rtems/include/rtems/rtems/message.h delete mode 100644 cpukit/rtems/include/rtems/rtems/messageimpl.h delete mode 100644 cpukit/rtems/include/rtems/rtems/modes.h delete mode 100644 cpukit/rtems/include/rtems/rtems/modesimpl.h delete mode 100644 cpukit/rtems/include/rtems/rtems/mp.h delete mode 100644 cpukit/rtems/include/rtems/rtems/msgmp.h delete mode 100644 cpukit/rtems/include/rtems/rtems/object.h delete mode 100644 cpukit/rtems/include/rtems/rtems/options.h delete mode 100644 cpukit/rtems/include/rtems/rtems/optionsimpl.h delete mode 100644 cpukit/rtems/include/rtems/rtems/part.h delete mode 100644 cpukit/rtems/include/rtems/rtems/partimpl.h delete mode 100644 cpukit/rtems/include/rtems/rtems/partmp.h delete mode 100644 cpukit/rtems/include/rtems/rtems/ratemon.h delete mode 100644 cpukit/rtems/include/rtems/rtems/ratemonimpl.h delete mode 100644 cpukit/rtems/include/rtems/rtems/region.h delete mode 100644 cpukit/rtems/include/rtems/rtems/regionimpl.h delete mode 100644 cpukit/rtems/include/rtems/rtems/sem.h delete mode 100644 cpukit/rtems/include/rtems/rtems/semimpl.h delete mode 100644 cpukit/rtems/include/rtems/rtems/semmp.h delete mode 100644 cpukit/rtems/include/rtems/rtems/signal.h delete mode 100644 cpukit/rtems/include/rtems/rtems/signalimpl.h delete mode 100644 cpukit/rtems/include/rtems/rtems/signalmp.h delete mode 100644 cpukit/rtems/include/rtems/rtems/smp.h delete mode 100644 cpukit/rtems/include/rtems/rtems/status.h delete mode 100644 cpukit/rtems/include/rtems/rtems/statusimpl.h delete mode 100644 cpukit/rtems/include/rtems/rtems/support.h delete mode 100644 cpukit/rtems/include/rtems/rtems/taskmp.h delete mode 100644 cpukit/rtems/include/rtems/rtems/tasks.h delete mode 100644 cpukit/rtems/include/rtems/rtems/tasksimpl.h delete mode 100644 cpukit/rtems/include/rtems/rtems/timer.h delete mode 100644 cpukit/rtems/include/rtems/rtems/timerimpl.h delete mode 100644 cpukit/rtems/include/rtems/rtems/types.h delete mode 100644 cpukit/rtems/mainpage.h delete mode 100644 cpukit/rtems/preinstall.am delete mode 100755 cpukit/sapi/include/confdefs.h delete mode 100644 cpukit/sapi/include/rtems/bsd.h delete mode 100644 cpukit/sapi/include/rtems/cbs.h delete mode 100644 cpukit/sapi/include/rtems/chain.h delete mode 100644 cpukit/sapi/include/rtems/config.h delete mode 100644 cpukit/sapi/include/rtems/counter.h delete mode 100644 cpukit/sapi/include/rtems/extension.h delete mode 100644 cpukit/sapi/include/rtems/extensionimpl.h delete mode 100644 cpukit/sapi/include/rtems/fatal.h delete mode 100644 cpukit/sapi/include/rtems/init.h delete mode 100644 cpukit/sapi/include/rtems/io.h delete mode 100644 cpukit/sapi/include/rtems/ioimpl.h delete mode 100644 cpukit/sapi/include/rtems/mptables.h delete mode 100644 cpukit/sapi/include/rtems/profiling.h delete mode 100644 cpukit/sapi/include/rtems/rbheap.h delete mode 100644 cpukit/sapi/include/rtems/rbtree.h delete mode 100644 cpukit/sapi/include/rtems/scheduler.h delete mode 100644 cpukit/sapi/include/rtems/timecounter.h delete mode 100644 cpukit/sapi/include/rtems/timespec.h delete mode 100644 cpukit/sapi/include/rtems/version.h delete mode 100644 cpukit/sapi/preinstall.am create mode 100644 cpukit/score/cpu/arm/headers.am create mode 100644 cpukit/score/cpu/arm/include/machine/elf_machdep.h create mode 100644 cpukit/score/cpu/arm/include/rtems/asm.h create mode 100755 cpukit/score/cpu/arm/include/rtems/score/arm.h create mode 100644 cpukit/score/cpu/arm/include/rtems/score/armv4.h create mode 100644 cpukit/score/cpu/arm/include/rtems/score/armv7m.h create mode 100644 cpukit/score/cpu/arm/include/rtems/score/cpu.h create mode 100644 cpukit/score/cpu/arm/include/rtems/score/cpu_asm.h create mode 100644 cpukit/score/cpu/arm/include/rtems/score/cpuatomic.h create mode 100644 cpukit/score/cpu/arm/include/rtems/score/cpuimpl.h create mode 100644 cpukit/score/cpu/arm/include/rtems/score/types.h delete mode 100644 cpukit/score/cpu/arm/preinstall.am delete mode 100644 cpukit/score/cpu/arm/rtems/asm.h delete mode 100755 cpukit/score/cpu/arm/rtems/score/arm.h delete mode 100644 cpukit/score/cpu/arm/rtems/score/armv4.h delete mode 100644 cpukit/score/cpu/arm/rtems/score/armv7m.h delete mode 100644 cpukit/score/cpu/arm/rtems/score/cpu.h delete mode 100644 cpukit/score/cpu/arm/rtems/score/cpu_asm.h delete mode 100644 cpukit/score/cpu/arm/rtems/score/cpuatomic.h delete mode 100644 cpukit/score/cpu/arm/rtems/score/cpuimpl.h delete mode 100644 cpukit/score/cpu/arm/rtems/score/types.h create mode 100644 cpukit/score/cpu/bfin/headers.am create mode 100644 cpukit/score/cpu/bfin/include/machine/elf_machdep.h create mode 100644 cpukit/score/cpu/bfin/include/rtems/asm.h create mode 100644 cpukit/score/cpu/bfin/include/rtems/bfin/bf52x.h create mode 100644 cpukit/score/cpu/bfin/include/rtems/bfin/bf533.h create mode 100644 cpukit/score/cpu/bfin/include/rtems/bfin/bfin.h create mode 100644 cpukit/score/cpu/bfin/include/rtems/score/bfin.h create mode 100644 cpukit/score/cpu/bfin/include/rtems/score/cpu.h create mode 100644 cpukit/score/cpu/bfin/include/rtems/score/cpu_asm.h create mode 100644 cpukit/score/cpu/bfin/include/rtems/score/cpuatomic.h create mode 100644 cpukit/score/cpu/bfin/include/rtems/score/cpuimpl.h create mode 100644 cpukit/score/cpu/bfin/include/rtems/score/types.h delete mode 100644 cpukit/score/cpu/bfin/preinstall.am delete mode 100644 cpukit/score/cpu/bfin/rtems/asm.h delete mode 100644 cpukit/score/cpu/bfin/rtems/bfin/bf52x.h delete mode 100644 cpukit/score/cpu/bfin/rtems/bfin/bf533.h delete mode 100644 cpukit/score/cpu/bfin/rtems/bfin/bfin.h delete mode 100644 cpukit/score/cpu/bfin/rtems/score/bfin.h delete mode 100644 cpukit/score/cpu/bfin/rtems/score/cpu.h delete mode 100644 cpukit/score/cpu/bfin/rtems/score/cpu_asm.h delete mode 100644 cpukit/score/cpu/bfin/rtems/score/cpuatomic.h delete mode 100644 cpukit/score/cpu/bfin/rtems/score/cpuimpl.h delete mode 100644 cpukit/score/cpu/bfin/rtems/score/types.h create mode 100644 cpukit/score/cpu/epiphany/headers.am create mode 100644 cpukit/score/cpu/epiphany/include/rtems/asm.h create mode 100644 cpukit/score/cpu/epiphany/include/rtems/score/cpu.h create mode 100644 cpukit/score/cpu/epiphany/include/rtems/score/cpu_asm.h create mode 100644 cpukit/score/cpu/epiphany/include/rtems/score/cpuatomic.h create mode 100644 cpukit/score/cpu/epiphany/include/rtems/score/cpuimpl.h create mode 100644 cpukit/score/cpu/epiphany/include/rtems/score/epiphany-utility.h create mode 100644 cpukit/score/cpu/epiphany/include/rtems/score/epiphany.h create mode 100644 cpukit/score/cpu/epiphany/include/rtems/score/types.h delete mode 100644 cpukit/score/cpu/epiphany/preinstall.am delete mode 100644 cpukit/score/cpu/epiphany/rtems/asm.h delete mode 100644 cpukit/score/cpu/epiphany/rtems/score/cpu.h delete mode 100644 cpukit/score/cpu/epiphany/rtems/score/cpu_asm.h delete mode 100644 cpukit/score/cpu/epiphany/rtems/score/cpuatomic.h delete mode 100644 cpukit/score/cpu/epiphany/rtems/score/cpuimpl.h delete mode 100644 cpukit/score/cpu/epiphany/rtems/score/epiphany-utility.h delete mode 100644 cpukit/score/cpu/epiphany/rtems/score/epiphany.h delete mode 100644 cpukit/score/cpu/epiphany/rtems/score/types.h create mode 100644 cpukit/score/cpu/h8300/headers.am create mode 100644 cpukit/score/cpu/h8300/include/machine/elf_machdep.h create mode 100644 cpukit/score/cpu/i386/headers.am create mode 100644 cpukit/score/cpu/i386/include/machine/elf_machdep.h create mode 100644 cpukit/score/cpu/i386/include/rtems/asm.h create mode 100644 cpukit/score/cpu/i386/include/rtems/score/cpu.h create mode 100644 cpukit/score/cpu/i386/include/rtems/score/cpuatomic.h create mode 100644 cpukit/score/cpu/i386/include/rtems/score/cpuimpl.h create mode 100644 cpukit/score/cpu/i386/include/rtems/score/i386.h create mode 100644 cpukit/score/cpu/i386/include/rtems/score/idtr.h create mode 100644 cpukit/score/cpu/i386/include/rtems/score/interrupts.h create mode 100644 cpukit/score/cpu/i386/include/rtems/score/registers.h create mode 100644 cpukit/score/cpu/i386/include/rtems/score/types.h delete mode 100644 cpukit/score/cpu/i386/preinstall.am delete mode 100644 cpukit/score/cpu/i386/rtems/asm.h delete mode 100644 cpukit/score/cpu/i386/rtems/score/cpu.h delete mode 100644 cpukit/score/cpu/i386/rtems/score/cpuatomic.h delete mode 100644 cpukit/score/cpu/i386/rtems/score/cpuimpl.h delete mode 100644 cpukit/score/cpu/i386/rtems/score/i386.h delete mode 100644 cpukit/score/cpu/i386/rtems/score/idtr.h delete mode 100644 cpukit/score/cpu/i386/rtems/score/interrupts.h delete mode 100644 cpukit/score/cpu/i386/rtems/score/registers.h delete mode 100644 cpukit/score/cpu/i386/rtems/score/types.h create mode 100644 cpukit/score/cpu/lm32/headers.am create mode 100644 cpukit/score/cpu/lm32/include/machine/elf_machdep.h create mode 100644 cpukit/score/cpu/lm32/include/rtems/asm.h create mode 100644 cpukit/score/cpu/lm32/include/rtems/score/cpu.h create mode 100644 cpukit/score/cpu/lm32/include/rtems/score/cpu_asm.h create mode 100644 cpukit/score/cpu/lm32/include/rtems/score/cpuatomic.h create mode 100644 cpukit/score/cpu/lm32/include/rtems/score/cpuimpl.h create mode 100644 cpukit/score/cpu/lm32/include/rtems/score/lm32.h create mode 100644 cpukit/score/cpu/lm32/include/rtems/score/types.h delete mode 100644 cpukit/score/cpu/lm32/preinstall.am delete mode 100644 cpukit/score/cpu/lm32/rtems/asm.h delete mode 100644 cpukit/score/cpu/lm32/rtems/score/cpu.h delete mode 100644 cpukit/score/cpu/lm32/rtems/score/cpu_asm.h delete mode 100644 cpukit/score/cpu/lm32/rtems/score/cpuatomic.h delete mode 100644 cpukit/score/cpu/lm32/rtems/score/cpuimpl.h delete mode 100644 cpukit/score/cpu/lm32/rtems/score/lm32.h delete mode 100644 cpukit/score/cpu/lm32/rtems/score/types.h create mode 100644 cpukit/score/cpu/m32c/headers.am create mode 100644 cpukit/score/cpu/m32c/include/rtems/asm.h create mode 100644 cpukit/score/cpu/m32c/include/rtems/score/cpu.h create mode 100644 cpukit/score/cpu/m32c/include/rtems/score/cpu_asm.h create mode 100644 cpukit/score/cpu/m32c/include/rtems/score/cpuatomic.h create mode 100644 cpukit/score/cpu/m32c/include/rtems/score/cpuimpl.h create mode 100644 cpukit/score/cpu/m32c/include/rtems/score/m32c.h create mode 100644 cpukit/score/cpu/m32c/include/rtems/score/types.h create mode 100644 cpukit/score/cpu/m32c/include/varvects.h delete mode 100644 cpukit/score/cpu/m32c/preinstall.am delete mode 100644 cpukit/score/cpu/m32c/rtems/asm.h delete mode 100644 cpukit/score/cpu/m32c/rtems/score/cpu.h delete mode 100644 cpukit/score/cpu/m32c/rtems/score/cpu_asm.h delete mode 100644 cpukit/score/cpu/m32c/rtems/score/cpuatomic.h delete mode 100644 cpukit/score/cpu/m32c/rtems/score/cpuimpl.h delete mode 100644 cpukit/score/cpu/m32c/rtems/score/m32c.h delete mode 100644 cpukit/score/cpu/m32c/rtems/score/types.h delete mode 100644 cpukit/score/cpu/m32c/varvects.h create mode 100644 cpukit/score/cpu/m68k/headers.am create mode 100644 cpukit/score/cpu/m68k/include/machine/elf_machdep.h create mode 100644 cpukit/score/cpu/m68k/include/rtems/asm.h create mode 100644 cpukit/score/cpu/m68k/include/rtems/m68k/m68302.h create mode 100644 cpukit/score/cpu/m68k/include/rtems/m68k/m68360.h create mode 100644 cpukit/score/cpu/m68k/include/rtems/m68k/qsm.h create mode 100644 cpukit/score/cpu/m68k/include/rtems/m68k/sim.h create mode 100644 cpukit/score/cpu/m68k/include/rtems/score/cpu.h create mode 100644 cpukit/score/cpu/m68k/include/rtems/score/cpuatomic.h create mode 100644 cpukit/score/cpu/m68k/include/rtems/score/cpuimpl.h create mode 100644 cpukit/score/cpu/m68k/include/rtems/score/m68k.h create mode 100644 cpukit/score/cpu/m68k/include/rtems/score/types.h delete mode 100644 cpukit/score/cpu/m68k/preinstall.am delete mode 100644 cpukit/score/cpu/m68k/rtems/asm.h delete mode 100644 cpukit/score/cpu/m68k/rtems/m68k/m68302.h delete mode 100644 cpukit/score/cpu/m68k/rtems/m68k/m68360.h delete mode 100644 cpukit/score/cpu/m68k/rtems/m68k/qsm.h delete mode 100644 cpukit/score/cpu/m68k/rtems/m68k/sim.h delete mode 100644 cpukit/score/cpu/m68k/rtems/score/cpu.h delete mode 100644 cpukit/score/cpu/m68k/rtems/score/cpuatomic.h delete mode 100644 cpukit/score/cpu/m68k/rtems/score/cpuimpl.h delete mode 100644 cpukit/score/cpu/m68k/rtems/score/m68k.h delete mode 100644 cpukit/score/cpu/m68k/rtems/score/types.h create mode 100644 cpukit/score/cpu/mips/headers.am create mode 100644 cpukit/score/cpu/mips/include/machine/elf_machdep.h create mode 100644 cpukit/score/cpu/mips/include/rtems/asm.h create mode 100644 cpukit/score/cpu/mips/include/rtems/mips/idtcpu.h create mode 100644 cpukit/score/cpu/mips/include/rtems/mips/iregdef.h create mode 100644 cpukit/score/cpu/mips/include/rtems/score/cpu.h create mode 100644 cpukit/score/cpu/mips/include/rtems/score/cpuatomic.h create mode 100644 cpukit/score/cpu/mips/include/rtems/score/cpuimpl.h create mode 100644 cpukit/score/cpu/mips/include/rtems/score/mips.h create mode 100644 cpukit/score/cpu/mips/include/rtems/score/types.h delete mode 100644 cpukit/score/cpu/mips/preinstall.am delete mode 100644 cpukit/score/cpu/mips/rtems/asm.h delete mode 100644 cpukit/score/cpu/mips/rtems/mips/idtcpu.h delete mode 100644 cpukit/score/cpu/mips/rtems/mips/iregdef.h delete mode 100644 cpukit/score/cpu/mips/rtems/score/cpu.h delete mode 100644 cpukit/score/cpu/mips/rtems/score/cpuatomic.h delete mode 100644 cpukit/score/cpu/mips/rtems/score/cpuimpl.h delete mode 100644 cpukit/score/cpu/mips/rtems/score/mips.h delete mode 100644 cpukit/score/cpu/mips/rtems/score/types.h create mode 100644 cpukit/score/cpu/moxie/headers.am create mode 100644 cpukit/score/cpu/moxie/include/machine/elf_machdep.h create mode 100644 cpukit/score/cpu/moxie/include/rtems/asm.h create mode 100644 cpukit/score/cpu/moxie/include/rtems/score/cpu.h create mode 100644 cpukit/score/cpu/moxie/include/rtems/score/cpuatomic.h create mode 100644 cpukit/score/cpu/moxie/include/rtems/score/cpuimpl.h create mode 100644 cpukit/score/cpu/moxie/include/rtems/score/moxie.h create mode 100644 cpukit/score/cpu/moxie/include/rtems/score/types.h delete mode 100644 cpukit/score/cpu/moxie/preinstall.am delete mode 100644 cpukit/score/cpu/moxie/rtems/asm.h delete mode 100644 cpukit/score/cpu/moxie/rtems/score/cpu.h delete mode 100644 cpukit/score/cpu/moxie/rtems/score/cpuatomic.h delete mode 100644 cpukit/score/cpu/moxie/rtems/score/cpuimpl.h delete mode 100644 cpukit/score/cpu/moxie/rtems/score/moxie.h delete mode 100644 cpukit/score/cpu/moxie/rtems/score/types.h create mode 100644 cpukit/score/cpu/nios2/headers.am create mode 100644 cpukit/score/cpu/nios2/include/machine/elf_machdep.h create mode 100644 cpukit/score/cpu/nios2/include/rtems/asm.h create mode 100644 cpukit/score/cpu/nios2/include/rtems/score/cpu.h create mode 100644 cpukit/score/cpu/nios2/include/rtems/score/cpu_asm.h create mode 100644 cpukit/score/cpu/nios2/include/rtems/score/cpuatomic.h create mode 100644 cpukit/score/cpu/nios2/include/rtems/score/cpuimpl.h create mode 100644 cpukit/score/cpu/nios2/include/rtems/score/nios2-count-zeros.h create mode 100644 cpukit/score/cpu/nios2/include/rtems/score/nios2-utility.h create mode 100644 cpukit/score/cpu/nios2/include/rtems/score/nios2.h create mode 100644 cpukit/score/cpu/nios2/include/rtems/score/types.h delete mode 100644 cpukit/score/cpu/nios2/preinstall.am delete mode 100644 cpukit/score/cpu/nios2/rtems/asm.h delete mode 100644 cpukit/score/cpu/nios2/rtems/score/cpu.h delete mode 100644 cpukit/score/cpu/nios2/rtems/score/cpu_asm.h delete mode 100644 cpukit/score/cpu/nios2/rtems/score/cpuatomic.h delete mode 100644 cpukit/score/cpu/nios2/rtems/score/cpuimpl.h delete mode 100644 cpukit/score/cpu/nios2/rtems/score/nios2-count-zeros.h delete mode 100644 cpukit/score/cpu/nios2/rtems/score/nios2-utility.h delete mode 100644 cpukit/score/cpu/nios2/rtems/score/nios2.h delete mode 100644 cpukit/score/cpu/nios2/rtems/score/types.h create mode 100644 cpukit/score/cpu/no_cpu/headers.am create mode 100644 cpukit/score/cpu/no_cpu/include/rtems/asm.h create mode 100644 cpukit/score/cpu/no_cpu/include/rtems/score/cpu.h create mode 100644 cpukit/score/cpu/no_cpu/include/rtems/score/cpu_asm.h create mode 100644 cpukit/score/cpu/no_cpu/include/rtems/score/cpuimpl.h create mode 100644 cpukit/score/cpu/no_cpu/include/rtems/score/no_cpu.h create mode 100644 cpukit/score/cpu/no_cpu/include/rtems/score/types.h delete mode 100644 cpukit/score/cpu/no_cpu/preinstall.am delete mode 100644 cpukit/score/cpu/no_cpu/rtems/asm.h delete mode 100644 cpukit/score/cpu/no_cpu/rtems/score/cpu.h delete mode 100644 cpukit/score/cpu/no_cpu/rtems/score/cpu_asm.h delete mode 100644 cpukit/score/cpu/no_cpu/rtems/score/cpuimpl.h delete mode 100644 cpukit/score/cpu/no_cpu/rtems/score/no_cpu.h delete mode 100644 cpukit/score/cpu/no_cpu/rtems/score/types.h create mode 100644 cpukit/score/cpu/or1k/headers.am create mode 100644 cpukit/score/cpu/or1k/include/rtems/asm.h create mode 100644 cpukit/score/cpu/or1k/include/rtems/score/cpu.h create mode 100644 cpukit/score/cpu/or1k/include/rtems/score/cpu_asm.h create mode 100644 cpukit/score/cpu/or1k/include/rtems/score/cpuatomic.h create mode 100644 cpukit/score/cpu/or1k/include/rtems/score/cpuimpl.h create mode 100644 cpukit/score/cpu/or1k/include/rtems/score/or1k-utility.h create mode 100644 cpukit/score/cpu/or1k/include/rtems/score/or1k.h create mode 100644 cpukit/score/cpu/or1k/include/rtems/score/types.h delete mode 100644 cpukit/score/cpu/or1k/preinstall.am delete mode 100644 cpukit/score/cpu/or1k/rtems/asm.h delete mode 100644 cpukit/score/cpu/or1k/rtems/score/cpu.h delete mode 100644 cpukit/score/cpu/or1k/rtems/score/cpu_asm.h delete mode 100644 cpukit/score/cpu/or1k/rtems/score/cpuatomic.h delete mode 100644 cpukit/score/cpu/or1k/rtems/score/cpuimpl.h delete mode 100644 cpukit/score/cpu/or1k/rtems/score/or1k-utility.h delete mode 100644 cpukit/score/cpu/or1k/rtems/score/or1k.h delete mode 100644 cpukit/score/cpu/or1k/rtems/score/types.h create mode 100644 cpukit/score/cpu/powerpc/headers.am create mode 100644 cpukit/score/cpu/powerpc/include/machine/elf_machdep.h create mode 100644 cpukit/score/cpu/powerpc/include/rtems/asm.h create mode 100644 cpukit/score/cpu/powerpc/include/rtems/powerpc/registers.h create mode 100644 cpukit/score/cpu/powerpc/include/rtems/score/cpu.h create mode 100644 cpukit/score/cpu/powerpc/include/rtems/score/cpuatomic.h create mode 100644 cpukit/score/cpu/powerpc/include/rtems/score/cpuimpl.h create mode 100644 cpukit/score/cpu/powerpc/include/rtems/score/powerpc.h create mode 100644 cpukit/score/cpu/powerpc/include/rtems/score/types.h delete mode 100644 cpukit/score/cpu/powerpc/preinstall.am delete mode 100644 cpukit/score/cpu/powerpc/rtems/asm.h delete mode 100644 cpukit/score/cpu/powerpc/rtems/powerpc/registers.h delete mode 100644 cpukit/score/cpu/powerpc/rtems/score/cpu.h delete mode 100644 cpukit/score/cpu/powerpc/rtems/score/cpuatomic.h delete mode 100644 cpukit/score/cpu/powerpc/rtems/score/cpuimpl.h delete mode 100644 cpukit/score/cpu/powerpc/rtems/score/powerpc.h delete mode 100644 cpukit/score/cpu/powerpc/rtems/score/types.h create mode 100644 cpukit/score/cpu/riscv/headers.am create mode 100644 cpukit/score/cpu/riscv/include/rtems/asm.h create mode 100644 cpukit/score/cpu/riscv/include/rtems/score/cpu.h create mode 100644 cpukit/score/cpu/riscv/include/rtems/score/cpu_asm.h create mode 100644 cpukit/score/cpu/riscv/include/rtems/score/cpuatomic.h create mode 100644 cpukit/score/cpu/riscv/include/rtems/score/cpuimpl.h create mode 100644 cpukit/score/cpu/riscv/include/rtems/score/riscv-utility.h create mode 100644 cpukit/score/cpu/riscv/include/rtems/score/riscv.h create mode 100644 cpukit/score/cpu/riscv/include/rtems/score/types.h delete mode 100644 cpukit/score/cpu/riscv/preinstall.am delete mode 100644 cpukit/score/cpu/riscv/rtems/asm.h delete mode 100644 cpukit/score/cpu/riscv/rtems/score/cpu.h delete mode 100644 cpukit/score/cpu/riscv/rtems/score/cpu_asm.h delete mode 100644 cpukit/score/cpu/riscv/rtems/score/cpuatomic.h delete mode 100644 cpukit/score/cpu/riscv/rtems/score/cpuimpl.h delete mode 100644 cpukit/score/cpu/riscv/rtems/score/riscv-utility.h delete mode 100644 cpukit/score/cpu/riscv/rtems/score/riscv.h delete mode 100644 cpukit/score/cpu/riscv/rtems/score/types.h create mode 100644 cpukit/score/cpu/sh/headers.am create mode 100644 cpukit/score/cpu/sh/include/rtems/asm.h create mode 100644 cpukit/score/cpu/sh/include/rtems/score/cpu.h create mode 100644 cpukit/score/cpu/sh/include/rtems/score/cpuatomic.h create mode 100644 cpukit/score/cpu/sh/include/rtems/score/cpuimpl.h create mode 100644 cpukit/score/cpu/sh/include/rtems/score/sh.h create mode 100644 cpukit/score/cpu/sh/include/rtems/score/sh_io.h create mode 100644 cpukit/score/cpu/sh/include/rtems/score/types.h delete mode 100644 cpukit/score/cpu/sh/preinstall.am delete mode 100644 cpukit/score/cpu/sh/rtems/asm.h delete mode 100644 cpukit/score/cpu/sh/rtems/score/cpu.h delete mode 100644 cpukit/score/cpu/sh/rtems/score/cpuatomic.h delete mode 100644 cpukit/score/cpu/sh/rtems/score/cpuimpl.h delete mode 100644 cpukit/score/cpu/sh/rtems/score/sh.h delete mode 100644 cpukit/score/cpu/sh/rtems/score/sh_io.h delete mode 100644 cpukit/score/cpu/sh/rtems/score/types.h create mode 100644 cpukit/score/cpu/sparc/headers.am create mode 100644 cpukit/score/cpu/sparc/include/machine/elf_machdep.h create mode 100644 cpukit/score/cpu/sparc/include/rtems/asm.h create mode 100644 cpukit/score/cpu/sparc/include/rtems/score/cpu.h create mode 100644 cpukit/score/cpu/sparc/include/rtems/score/cpuatomic.h create mode 100644 cpukit/score/cpu/sparc/include/rtems/score/cpuimpl.h create mode 100644 cpukit/score/cpu/sparc/include/rtems/score/sparc.h create mode 100644 cpukit/score/cpu/sparc/include/rtems/score/sparcimpl.h create mode 100644 cpukit/score/cpu/sparc/include/rtems/score/types.h delete mode 100644 cpukit/score/cpu/sparc/preinstall.am delete mode 100644 cpukit/score/cpu/sparc/rtems/asm.h delete mode 100644 cpukit/score/cpu/sparc/rtems/score/cpu.h delete mode 100644 cpukit/score/cpu/sparc/rtems/score/cpuatomic.h delete mode 100644 cpukit/score/cpu/sparc/rtems/score/cpuimpl.h delete mode 100644 cpukit/score/cpu/sparc/rtems/score/sparc.h delete mode 100644 cpukit/score/cpu/sparc/rtems/score/sparcimpl.h delete mode 100644 cpukit/score/cpu/sparc/rtems/score/types.h create mode 100644 cpukit/score/cpu/sparc64/headers.am create mode 100644 cpukit/score/cpu/sparc64/include/rtems/asm.h create mode 100644 cpukit/score/cpu/sparc64/include/rtems/score/cpu.h create mode 100644 cpukit/score/cpu/sparc64/include/rtems/score/cpuatomic.h create mode 100644 cpukit/score/cpu/sparc64/include/rtems/score/cpuimpl.h create mode 100644 cpukit/score/cpu/sparc64/include/rtems/score/sparc64.h create mode 100644 cpukit/score/cpu/sparc64/include/rtems/score/types.h delete mode 100644 cpukit/score/cpu/sparc64/preinstall.am delete mode 100644 cpukit/score/cpu/sparc64/rtems/asm.h delete mode 100644 cpukit/score/cpu/sparc64/rtems/score/cpu.h delete mode 100644 cpukit/score/cpu/sparc64/rtems/score/cpuatomic.h delete mode 100644 cpukit/score/cpu/sparc64/rtems/score/cpuimpl.h delete mode 100644 cpukit/score/cpu/sparc64/rtems/score/sparc64.h delete mode 100644 cpukit/score/cpu/sparc64/rtems/score/types.h create mode 100644 cpukit/score/cpu/v850/headers.am create mode 100644 cpukit/score/cpu/v850/include/machine/elf_machdep.h create mode 100644 cpukit/score/cpu/v850/include/rtems/asm.h create mode 100644 cpukit/score/cpu/v850/include/rtems/score/cpu.h create mode 100644 cpukit/score/cpu/v850/include/rtems/score/cpu_asm.h create mode 100644 cpukit/score/cpu/v850/include/rtems/score/cpuatomic.h create mode 100644 cpukit/score/cpu/v850/include/rtems/score/cpuimpl.h create mode 100644 cpukit/score/cpu/v850/include/rtems/score/types.h create mode 100644 cpukit/score/cpu/v850/include/rtems/score/v850.h delete mode 100644 cpukit/score/cpu/v850/preinstall.am delete mode 100644 cpukit/score/cpu/v850/rtems/asm.h delete mode 100644 cpukit/score/cpu/v850/rtems/score/cpu.h delete mode 100644 cpukit/score/cpu/v850/rtems/score/cpu_asm.h delete mode 100644 cpukit/score/cpu/v850/rtems/score/cpuatomic.h delete mode 100644 cpukit/score/cpu/v850/rtems/score/cpuimpl.h delete mode 100644 cpukit/score/cpu/v850/rtems/score/types.h delete mode 100644 cpukit/score/cpu/v850/rtems/score/v850.h delete mode 100644 cpukit/score/include/rtems/linkersets.h delete mode 100644 cpukit/score/include/rtems/score/address.h delete mode 100644 cpukit/score/include/rtems/score/apimutex.h delete mode 100644 cpukit/score/include/rtems/score/assert.h delete mode 100644 cpukit/score/include/rtems/score/atomic.h delete mode 100644 cpukit/score/include/rtems/score/basedefs.h delete mode 100644 cpukit/score/include/rtems/score/chain.h delete mode 100644 cpukit/score/include/rtems/score/chainimpl.h delete mode 100644 cpukit/score/include/rtems/score/context.h delete mode 100644 cpukit/score/include/rtems/score/copyrt.h delete mode 100644 cpukit/score/include/rtems/score/corebarrier.h delete mode 100644 cpukit/score/include/rtems/score/corebarrierimpl.h delete mode 100644 cpukit/score/include/rtems/score/coremsg.h delete mode 100644 cpukit/score/include/rtems/score/coremsgimpl.h delete mode 100644 cpukit/score/include/rtems/score/coremutex.h delete mode 100644 cpukit/score/include/rtems/score/coremuteximpl.h delete mode 100644 cpukit/score/include/rtems/score/corerwlockimpl.h delete mode 100644 cpukit/score/include/rtems/score/coresem.h delete mode 100644 cpukit/score/include/rtems/score/coresemimpl.h delete mode 100644 cpukit/score/include/rtems/score/cpustdatomic.h delete mode 100644 cpukit/score/include/rtems/score/freechain.h delete mode 100644 cpukit/score/include/rtems/score/heap.h delete mode 100644 cpukit/score/include/rtems/score/heapimpl.h delete mode 100644 cpukit/score/include/rtems/score/interr.h delete mode 100644 cpukit/score/include/rtems/score/io.h delete mode 100644 cpukit/score/include/rtems/score/isr.h delete mode 100644 cpukit/score/include/rtems/score/isrlevel.h delete mode 100644 cpukit/score/include/rtems/score/isrlock.h delete mode 100644 cpukit/score/include/rtems/score/mpci.h delete mode 100644 cpukit/score/include/rtems/score/mpciimpl.h delete mode 100644 cpukit/score/include/rtems/score/mppkt.h delete mode 100644 cpukit/score/include/rtems/score/mrsp.h delete mode 100644 cpukit/score/include/rtems/score/mrspimpl.h delete mode 100644 cpukit/score/include/rtems/score/muteximpl.h delete mode 100644 cpukit/score/include/rtems/score/object.h delete mode 100644 cpukit/score/include/rtems/score/objectimpl.h delete mode 100644 cpukit/score/include/rtems/score/objectmp.h delete mode 100644 cpukit/score/include/rtems/score/onceimpl.h delete mode 100644 cpukit/score/include/rtems/score/percpu.h delete mode 100644 cpukit/score/include/rtems/score/priority.h delete mode 100644 cpukit/score/include/rtems/score/prioritybitmap.h delete mode 100644 cpukit/score/include/rtems/score/prioritybitmapimpl.h delete mode 100644 cpukit/score/include/rtems/score/priorityimpl.h delete mode 100644 cpukit/score/include/rtems/score/processormask.h delete mode 100644 cpukit/score/include/rtems/score/profiling.h delete mode 100644 cpukit/score/include/rtems/score/protectedheap.h delete mode 100644 cpukit/score/include/rtems/score/rbtree.h delete mode 100644 cpukit/score/include/rtems/score/rbtreeimpl.h delete mode 100644 cpukit/score/include/rtems/score/scheduler.h delete mode 100644 cpukit/score/include/rtems/score/schedulercbs.h delete mode 100644 cpukit/score/include/rtems/score/schedulercbsimpl.h delete mode 100644 cpukit/score/include/rtems/score/scheduleredf.h delete mode 100644 cpukit/score/include/rtems/score/scheduleredfimpl.h delete mode 100644 cpukit/score/include/rtems/score/scheduleredfsmp.h delete mode 100644 cpukit/score/include/rtems/score/schedulerimpl.h delete mode 100644 cpukit/score/include/rtems/score/schedulernode.h delete mode 100644 cpukit/score/include/rtems/score/schedulernodeimpl.h delete mode 100644 cpukit/score/include/rtems/score/schedulerpriority.h delete mode 100644 cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h delete mode 100644 cpukit/score/include/rtems/score/schedulerpriorityimpl.h delete mode 100644 cpukit/score/include/rtems/score/schedulerprioritysmp.h delete mode 100644 cpukit/score/include/rtems/score/schedulerprioritysmpimpl.h delete mode 100644 cpukit/score/include/rtems/score/schedulersimple.h delete mode 100644 cpukit/score/include/rtems/score/schedulersimpleimpl.h delete mode 100644 cpukit/score/include/rtems/score/schedulersimplesmp.h delete mode 100644 cpukit/score/include/rtems/score/schedulersmp.h delete mode 100644 cpukit/score/include/rtems/score/schedulersmpimpl.h delete mode 100644 cpukit/score/include/rtems/score/schedulerstrongapa.h delete mode 100644 cpukit/score/include/rtems/score/semaphoreimpl.h delete mode 100644 cpukit/score/include/rtems/score/smp.h delete mode 100644 cpukit/score/include/rtems/score/smpbarrier.h delete mode 100644 cpukit/score/include/rtems/score/smpimpl.h delete mode 100644 cpukit/score/include/rtems/score/smplock.h delete mode 100644 cpukit/score/include/rtems/score/smplockmcs.h delete mode 100644 cpukit/score/include/rtems/score/smplockseq.h delete mode 100644 cpukit/score/include/rtems/score/smplockstats.h delete mode 100644 cpukit/score/include/rtems/score/smplockticket.h delete mode 100644 cpukit/score/include/rtems/score/stack.h delete mode 100644 cpukit/score/include/rtems/score/stackimpl.h delete mode 100644 cpukit/score/include/rtems/score/states.h delete mode 100644 cpukit/score/include/rtems/score/statesimpl.h delete mode 100644 cpukit/score/include/rtems/score/status.h delete mode 100644 cpukit/score/include/rtems/score/sysstate.h delete mode 100644 cpukit/score/include/rtems/score/thread.h delete mode 100644 cpukit/score/include/rtems/score/threaddispatch.h delete mode 100644 cpukit/score/include/rtems/score/threadimpl.h delete mode 100644 cpukit/score/include/rtems/score/threadmp.h delete mode 100644 cpukit/score/include/rtems/score/threadq.h delete mode 100644 cpukit/score/include/rtems/score/threadqimpl.h delete mode 100644 cpukit/score/include/rtems/score/timecounter.h delete mode 100644 cpukit/score/include/rtems/score/timecounterimpl.h delete mode 100644 cpukit/score/include/rtems/score/timespec.h delete mode 100644 cpukit/score/include/rtems/score/timestamp.h delete mode 100644 cpukit/score/include/rtems/score/tls.h delete mode 100644 cpukit/score/include/rtems/score/tod.h delete mode 100644 cpukit/score/include/rtems/score/todimpl.h delete mode 100644 cpukit/score/include/rtems/score/userext.h delete mode 100644 cpukit/score/include/rtems/score/userextimpl.h delete mode 100644 cpukit/score/include/rtems/score/watchdog.h delete mode 100644 cpukit/score/include/rtems/score/watchdogimpl.h delete mode 100644 cpukit/score/include/rtems/score/wkspace.h delete mode 100644 cpukit/score/include/rtems/seterr.h delete mode 100644 cpukit/score/include/rtems/sysinit.h delete mode 100644 cpukit/score/include/rtems/system.h delete mode 100644 cpukit/score/include/sys/_ffcounter.h delete mode 100644 cpukit/score/include/sys/timeffc.h delete mode 100644 cpukit/score/include/sys/timepps.h delete mode 100644 cpukit/score/include/sys/timetc.h delete mode 100644 cpukit/score/include/sys/timex.h delete mode 100644 cpukit/score/preinstall.am delete mode 100644 cpukit/telnetd/passwd.h delete mode 100644 cpukit/telnetd/preinstall.am delete mode 100644 cpukit/telnetd/pty.h delete mode 100644 cpukit/telnetd/telnetd.h delete mode 100644 cpukit/wrapup/preinstall.am delete mode 100644 cpukit/zlib/preinstall.am delete mode 100644 cpukit/zlib/zlib.h (limited to 'cpukit') diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am index d317fbba1c..636663e93e 100644 --- a/cpukit/Makefile.am +++ b/cpukit/Makefile.am @@ -29,292 +29,67 @@ _SUBDIRS += telnetd _SUBDIRS += pppd _SUBDIRS += mghttpd -noinst_DATA = preinstall-stamp -preinstall-stamp: - $(MAKE) $(AM_MAKEFLAGS) preinstall - touch preinstall-stamp -CLEANFILES = preinstall-stamp - -include_HEADERS = -include_HEADERS += include/endian.h -include_HEADERS += include/zconf.h - -include_rtemsdir = $(includedir)/rtems -include_rtems_HEADERS = - -include_rtems_rtemsdir = $(includedir)/rtems/rtems -include_rtems_rtems_HEADERS = - -include_uuiddir = $(includedir)/uuid -include_uuid_HEADERS = libmisc/uuid/uuid.h - -include_utf8procdir = $(includedir)/utf8proc -include_utf8proc_HEADERS = libmisc/utf8proc/utf8proc.h - -include_sysdir = $(includedir)/sys -include_sys_HEADERS = - -include_HEADERS += include/crypt.h -include_HEADERS += include/memory.h - -include_HEADERS += libmisc/xz/xz.h - -include_sys_HEADERS += libcsupport/include/sys/event.h -include_sys_HEADERS += libcsupport/include/sys/poll.h -include_sys_HEADERS += libcsupport/include/sys/statvfs.h -include_sys_HEADERS += libcsupport/include/sys/utsname.h - -include_sys_HEADERS += include/sys/endian.h -include_sys_HEADERS += include/sys/priority.h - if LIBNETWORKING -include_rtems_bsdnetdir = $(includedir)/rtems/bsdnet -include_rtems_bsdnet_HEADERS = libnetworking/rtems/bsdnet/servers.h -include_rtems_bsdnet_HEADERS += libnetworking/rtems/bsdnet/_types.h endif if LIBDL -include_HEADERS += libdl/dlfcn.h -include_HEADERS += libdl/include/link.h -include_HEADERS += libdl/include/link_elf.h -include_sys_HEADERS += libdl/include/sys/cdefs_elf.h -include_sys_HEADERS += libdl/include/sys/exec_elf.h -include_arch_machinedir = $(includedir)/machine -include_arch_machine_HEADERS = -include_arch_machine_HEADERS += libdl/include/arch/@RTEMS_CPU@/machine/elf_machdep.h -include_rtems_rtldir = $(includedir)/rtems/rtl -include_rtems_rtl_HEADERS = -include_rtems_rtl_HEADERS += libdl/dlfcn-shell.h -include_rtems_rtl_HEADERS += libdl/rtl.h libdl/rtl-allocator.h libdl/rtl-obj-fwd.h -include_rtems_rtl_HEADERS += libdl/rtl-fwd.h libdl/rtl-obj.h libdl/rtl-obj-cache.h -include_rtems_rtl_HEADERS += libdl/rtl-obj-comp.h libdl/rtl-unresolved.h -include_rtems_rtl_HEADERS += libdl/rtl-indirect-ptr.h libdl/rtl-sym.h libdl/rtl-trace.h -include_rtems_rtl_HEADERS += libdl/rap.h libdl/rap-shell.h endif if LIBDEBUGGER -include_rtems_HEADERS += libdebugger/rtems-debugger.h -include_rtems_debuggerdir = $(includedir)/rtems/debugger -include_rtems_debugger_HEADERS = -include_rtems_debugger_HEADERS += libdebugger/rtems-debugger-server.h -include_rtems_debugger_HEADERS += libdebugger/rtems-debugger-remote.h endif -include_rtems_HEADERS += include/rtems/bspIo.h -include_rtems_HEADERS += include/rtems/inttypes.h -include_rtems_HEADERS += include/rtems/print.h -include_rtems_HEADERS += include/rtems/printer.h -include_rtems_HEADERS += include/rtems/userenv.h -include_rtems_HEADERS += include/rtems/fs.h if !LIBPCI -include_rtems_HEADERS += include/rtems/pci.h endif -include_rtems_HEADERS += include/rtems/concat.h -include_rtems_HEADERS += include/rtems/status-checks.h - -include_rtems_HEADERS += include/rtems/endian.h - -include_rtems_HEADERS += include/rtems/btimer.h -include_rtems_HEADERS += include/rtems/console.h -include_rtems_HEADERS += include/rtems/clockdrv.h -include_rtems_HEADERS += include/rtems/framebuffer.h -include_rtems_HEADERS += include/rtems/rtc.h -include_rtems_HEADERS += include/rtems/watchdogdrv.h - ## should be conditional and only installed for PowerPC, x86, and ARM -include_rtems_HEADERS += include/rtems/irq.h - -include_rtems_HEADERS += include/rtems/irq-extension.h - ## libfs -include_rtems_HEADERS += libfs/src/imfs/imfs.h - ## POSIX FIFO/pipe -include_rtems_HEADERS += libfs/src/pipe/pipe.h - ## devfs -include_rtems_HEADERS += libfs/src/devfs/devfs.h - if LIBDOSFS -include_rtems_HEADERS += libfs/src/dosfs/dosfs.h endif # RFS -include_rtems_HEADERS += libfs/src/rfs/rtems-rfs.h -include_rtems_HEADERS += libfs/src/rfs/rtems-rfs-format.h -include_rtems_HEADERS += libfs/src/rfs/rtems-rfs-shell.h - -include_rtems_rfsdir = $(include_rtemsdir)/rfs -include_rtems_rfs_HEADERS = -include_rtems_rfs_HEADERS += libfs/src/rfs/rtems-rfs-bitmaps.h -include_rtems_rfs_HEADERS += libfs/src/rfs/rtems-rfs-block-pos.h -include_rtems_rfs_HEADERS += libfs/src/rfs/rtems-rfs-block.h -include_rtems_rfs_HEADERS += libfs/src/rfs/rtems-rfs-buffer.h -include_rtems_rfs_HEADERS += libfs/src/rfs/rtems-rfs-data.h -include_rtems_rfs_HEADERS += libfs/src/rfs/rtems-rfs-dir.h -include_rtems_rfs_HEADERS += libfs/src/rfs/rtems-rfs-dir-hash.h -include_rtems_rfs_HEADERS += libfs/src/rfs/rtems-rfs-file.h -include_rtems_rfs_HEADERS += libfs/src/rfs/rtems-rfs-file-system-fwd.h -include_rtems_rfs_HEADERS += libfs/src/rfs/rtems-rfs-file-system.h -include_rtems_rfs_HEADERS += libfs/src/rfs/rtems-rfs-group.h -include_rtems_rfs_HEADERS += libfs/src/rfs/rtems-rfs-inode.h -include_rtems_rfs_HEADERS += libfs/src/rfs/rtems-rfs-link.h -include_rtems_rfs_HEADERS += libfs/src/rfs/rtems-rfs-mutex.h -include_rtems_rfs_HEADERS += libfs/src/rfs/rtems-rfs-trace.h - # JFFS2 -include_rtems_HEADERS += libfs/src/jffs2/include/rtems/jffs2.h - ## libblock -include_rtems_HEADERS += libblock/include/rtems/bdbuf.h -include_rtems_HEADERS += libblock/include/rtems/blkdev.h -include_rtems_HEADERS += libblock/include/rtems/diskdevs.h -include_rtems_HEADERS += libblock/include/rtems/flashdisk.h -include_rtems_HEADERS += libblock/include/rtems/ramdisk.h -include_rtems_HEADERS += libblock/include/rtems/nvdisk.h -include_rtems_HEADERS += libblock/include/rtems/nvdisk-sram.h -include_rtems_HEADERS += libblock/include/rtems/sparse-disk.h -include_rtems_HEADERS += libblock/include/rtems/ide_part_table.h -include_rtems_HEADERS += libblock/include/rtems/bdpart.h -include_rtems_HEADERS += libblock/include/rtems/media.h - ## ftpd if LIBNETWORKING -include_rtems_HEADERS += ftpd/ftpd.h endif ## bspcmdline -include_rtems_HEADERS += libmisc/bspcmdline/bspcmdline.h - ## capture -include_rtems_HEADERS += libmisc/capture/capture.h -include_rtems_HEADERS += libmisc/capture/capture-cli.h -include_rtems_HEADERS += libmisc/capture/captureimpl.h - # tracing headers -include_rtems_tracedir = $(include_rtemsdir)/trace -include_rtems_trace_HEADERS = -include_rtems_trace_HEADERS += libmisc/capture/rtems-trace-buffer-vars.h - ## cpuuse -include_rtems_HEADERS += libmisc/cpuuse/cpuuse.h - ## devnull -include_rtems_HEADERS += libmisc/devnull/devnull.h -include_rtems_HEADERS += libmisc/devnull/devzero.h - ## dumpbuf -include_rtems_HEADERS += libmisc/dumpbuf/dumpbuf.h - ## rtemsfdt -include_rtems_HEADERS += libmisc/rtems-fdt/rtems-fdt.h -include_rtems_HEADERS += libmisc/rtems-fdt/rtems-fdt-shell.h - ## monitor -include_rtems_HEADERS += libmisc/monitor/monitor.h - ## fb -include_rtems_HEADERS += libmisc/fb/fb.h -include_rtems_HEADERS += libmisc/fb/mw_uid.h - ## mouse -include_rtems_HEADERS += libmisc/mouse/mouse_parser.h -include_rtems_HEADERS += libmisc/mouse/serial_mouse.h - ## libqos -include_rtems_HEADERS += libqos/qreslib.h - ## redirector -include_rtems_HEADERS += libmisc/redirector/stdio-redirect.h ## shell if LIBSHELL -include_rtems_HEADERS += libmisc/shell/shell.h -include_rtems_HEADERS += libmisc/shell/shellconfig.h endif ## stringto -include_rtems_HEADERS += libmisc/stringto/stringto.h - ## testsupport -include_rtems_HEADERS += libmisc/testsupport/test.h - ## i2c -include_rtems_HEADERS += libi2c/libi2c.h - ## serdbg if LIBSERDBG -include_rtems_HEADERS += libmisc/serdbg/serdbgcnf.h -include_rtems_HEADERS += libmisc/serdbg/serdbg.h -include_rtems_HEADERS += libmisc/serdbg/termios_printk_cnf.h -include_rtems_HEADERS += libmisc/serdbg/termios_printk.h endif ## stackchk -include_rtems_HEADERS += libmisc/stackchk/stackchk.h - ## libuntar -include_rtems_HEADERS += libmisc/untar/untar.h - ## fsmount -include_rtems_HEADERS += libmisc/fsmount/fsmount.h - -include_rtems_HEADERS += include/rtems/tm27-default.h - ## Driver manager if LIBDRVMGR -include_drvmgrdir = $(includedir)/drvmgr -include_drvmgr_HEADERS = libdrvmgr/drvmgr.h -include_drvmgr_HEADERS += libdrvmgr/drvmgr_confdefs.h -include_drvmgr_HEADERS += libdrvmgr/drvmgr_list.h endif if LIBGNAT -include_adaincludedir = $(includedir)/adainclude -include_adainclude_HEADERS = -include_adainclude_HEADERS += include/adainclude/rtems.adb -include_adainclude_HEADERS += include/adainclude/rtems.ads -include_adainclude_HEADERS += include/adainclude/rtems-barrier.adb -include_adainclude_HEADERS += include/adainclude/rtems-barrier.ads -include_adainclude_HEADERS += include/adainclude/rtems-clock.adb -include_adainclude_HEADERS += include/adainclude/rtems-clock.ads -include_adainclude_HEADERS += include/adainclude/rtems-cpu_usage.ads -include_adainclude_HEADERS += include/adainclude/rtems-event.adb -include_adainclude_HEADERS += include/adainclude/rtems-event.ads -include_adainclude_HEADERS += include/adainclude/rtems-extension.adb -include_adainclude_HEADERS += include/adainclude/rtems-extension.ads -include_adainclude_HEADERS += include/adainclude/rtems-fatal.adb -include_adainclude_HEADERS += include/adainclude/rtems-fatal.ads -include_adainclude_HEADERS += include/adainclude/rtems-interrupt.ads -include_adainclude_HEADERS += include/adainclude/rtems-io.adb -include_adainclude_HEADERS += include/adainclude/rtems-io.ads -include_adainclude_HEADERS += include/adainclude/rtems-message_queue.adb -include_adainclude_HEADERS += include/adainclude/rtems-message_queue.ads -include_adainclude_HEADERS += include/adainclude/rtems-multiprocessing.adb -include_adainclude_HEADERS += include/adainclude/rtems-multiprocessing.ads -include_adainclude_HEADERS += include/adainclude/rtems-object.adb -include_adainclude_HEADERS += include/adainclude/rtems-object.ads -include_adainclude_HEADERS += include/adainclude/rtems-partition.adb -include_adainclude_HEADERS += include/adainclude/rtems-partition.ads -include_adainclude_HEADERS += include/adainclude/rtems-port.adb -include_adainclude_HEADERS += include/adainclude/rtems-port.ads -include_adainclude_HEADERS += include/adainclude/rtems-rate_monotonic.adb -include_adainclude_HEADERS += include/adainclude/rtems-rate_monotonic.ads -include_adainclude_HEADERS += include/adainclude/rtems-region.adb -include_adainclude_HEADERS += include/adainclude/rtems-region.ads -include_adainclude_HEADERS += include/adainclude/rtems-semaphore.adb -include_adainclude_HEADERS += include/adainclude/rtems-semaphore.ads -include_adainclude_HEADERS += include/adainclude/rtems-signal.adb -include_adainclude_HEADERS += include/adainclude/rtems-signal.ads -include_adainclude_HEADERS += include/adainclude/rtems-stack_checker.ads -include_adainclude_HEADERS += include/adainclude/rtems-tasks.adb -include_adainclude_HEADERS += include/adainclude/rtems-tasks.ads -include_adainclude_HEADERS += include/adainclude/rtems-timer.adb -include_adainclude_HEADERS += include/adainclude/rtems-timer.ads endif ## HACK: doxygen filter. EXTRA_DIST = doxy-filter -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/subdirs.am include $(top_srcdir)/automake/local.am +include $(srcdir)/headers.am diff --git a/cpukit/acinclude.m4 b/cpukit/acinclude.m4 index da6084de90..f1889b6677 100644 --- a/cpukit/acinclude.m4 +++ b/cpukit/acinclude.m4 @@ -36,26 +36,27 @@ _ACEOF ]) AC_DEFUN([_RTEMS_CPUOPT_FINI],[ +AC_REQUIRE([RTEMS_BUILD_TOP]) cat >>cpuopts.tmp <<\_ACEOF #endif /* _RTEMS_SCORE_CPUOPTS_H */ _ACEOF -AS_MKDIR_P(score/include/rtems/score) -AS_IF([test -f score/include/rtems/score/cpuopts.h], +AS_MKDIR_P(${RTEMS_BUILD_ROOT}/include/rtems/score) +AS_IF([test -f ${RTEMS_BUILD_ROOT}/include/rtems/score/cpuopts.h], [ - AS_IF([cmp -s score/include/rtems/score/cpuopts.h cpuopts.tmp 2>/dev/null], + AS_IF([cmp -s ${RTEMS_BUILD_ROOT}/include/rtems/score/cpuopts.h cpuopts.tmp 2>/dev/null], [ - AC_MSG_NOTICE([score/include/rtems/score/cpuopts.h is unchanged]) + AC_MSG_NOTICE([${RTEMS_BUILD_ROOT}/include/rtems/score/cpuopts.h is unchanged]) rm -f cpuopts.tmp ],[ - AC_MSG_NOTICE([creating score/include/rtems/score/cpuopts.h]) - rm -f score/include/rtems/score/cpuopts.h - mv cpuopts.tmp score/include/rtems/score/cpuopts.h + AC_MSG_NOTICE([creating ${RTEMS_BUILD_ROOT}/include/rtems/score/cpuopts.h]) + rm -f ${RTEMS_BUILD_ROOT}/include/rtems/score/cpuopts.h + mv cpuopts.tmp ${RTEMS_BUILD_ROOT}/include/rtems/score/cpuopts.h ]) ],[ - AC_MSG_NOTICE([creating score/include/rtems/score/cpuopts.h]) - rm -f score/include/rtems/score/cpuopts.h - mv cpuopts.tmp score/include/rtems/score/cpuopts.h + AC_MSG_NOTICE([creating ${RTEMS_BUILD_ROOT}/include/rtems/score/cpuopts.h]) + rm -f ${RTEMS_BUILD_ROOT}/include/rtems/score/cpuopts.h + mv cpuopts.tmp ${RTEMS_BUILD_ROOT}/include/rtems/score/cpuopts.h ]) ]) diff --git a/cpukit/aclocal/check-networking.m4 b/cpukit/aclocal/check-networking.m4 index e15cf05aca..72730d2084 100644 --- a/cpukit/aclocal/check-networking.m4 +++ b/cpukit/aclocal/check-networking.m4 @@ -3,6 +3,7 @@ AC_DEFUN([RTEMS_CHECK_NETWORKING], [dnl AC_REQUIRE([RTEMS_CANONICAL_TARGET_CPU])dnl AC_REQUIRE([RTEMS_ENABLE_NETWORKING])dnl +AC_REQUIRE([RTEMS_INCLUDES])dnl AC_CACHE_CHECK([whether CPU supports networking], rtems_cv_HAS_NETWORKING, @@ -23,7 +24,8 @@ AC_CACHE_CHECK([whether CPU supports networking], && test x"$ac_cv_type_uint32_t" = xyes \ && test x"$ac_cv_type_int64_t" = xyes \ && test x"$ac_cv_type_uint64_t" = xyes], - [rtems_cv_HAS_NETWORKING=yes], + [rtems_cv_HAS_NETWORKING=yes + RTEMS_CPPFLAGS="${RTEMS_CPPFLAGS} -I${RTEMS_SOURCE_ROOT}/cpukit/libnetworking"], [rtems_cv_HAS_NETWORKING=no]) ],[ rtems_cv_HAS_NETWORKING=disabled diff --git a/cpukit/aclocal/prog-cc.m4 b/cpukit/aclocal/prog-cc.m4 index 659a682558..9006e0e53a 100644 --- a/cpukit/aclocal/prog-cc.m4 +++ b/cpukit/aclocal/prog-cc.m4 @@ -29,11 +29,10 @@ test "$rtems_cv_gcc_pipe" = "yes" && CC="$CC --pipe" AS_IF([test "$GCC" = yes && test "$rtems_cv_CFLAGS_set" != set], [CFLAGS="$CFLAGS -Wall -Wimplicit-function-declaration -Wstrict-prototypes -Wnested-externs"]) -RTEMS_CPPFLAGS="-I\$(top_builddir) -I\$(PROJECT_INCLUDE)" -AC_SUBST(RTEMS_CPPFLAGS) - AS_IF([test "$GCC" = yes],[ RTEMS_RELLDFLAGS="-qnolinkcmds -nostdlib -r" ]) AC_SUBST(RTEMS_RELLDFLAGS) + +RTEMS_INCLUDES ]) diff --git a/cpukit/aclocal/rtems-bsp-includes.m4 b/cpukit/aclocal/rtems-bsp-includes.m4 new file mode 100644 index 0000000000..2248211192 --- /dev/null +++ b/cpukit/aclocal/rtems-bsp-includes.m4 @@ -0,0 +1,13 @@ +dnl +dnl RTEMS Include paths. +dnl +AC_DEFUN([RTEMS_BSP_INCLUDES], +[ +AC_REQUIRE([RTEMS_SOURCE_TOP]) +AC_REQUIRE([RTEMS_BUILD_TOP]) +RTEMS_BSP_CPPFLAGS="-I${RTEMS_BUILD_ROOT}/lib/libbsp/\$(RTEMS_CPU)/\$(RTEMS_BSP_FAMILY)/include \ +-I${RTEMS_SOURCE_ROOT}/bsps/include \ +-I${RTEMS_SOURCE_ROOT}/bsps/\$(RTEMS_CPU)/include \ +-I${RTEMS_SOURCE_ROOT}/bsps/\$(RTEMS_CPU)/\$(RTEMS_BSP_FAMILY)/include" +AC_SUBST([RTEMS_BSP_CPPFLAGS]) +]) diff --git a/cpukit/aclocal/rtems-build-top.m4 b/cpukit/aclocal/rtems-build-top.m4 new file mode 100644 index 0000000000..5708119c14 --- /dev/null +++ b/cpukit/aclocal/rtems-build-top.m4 @@ -0,0 +1,12 @@ +dnl +dnl RTEMS_BUILD_TOP($1) +dnl +AC_DEFUN([RTEMS_BUILD_TOP], +[dnl +# +# This is a copy of the horrible hack in rtems-top.m4 and it is simpler to +# copy it that attempt to clean this crap up. +# +RTEMS_BUILD_ROOT="${with_rtems_build_top}" +AC_SUBST([RTEMS_BUILD_ROOT]) +])dnl diff --git a/cpukit/aclocal/rtems-includes.m4 b/cpukit/aclocal/rtems-includes.m4 new file mode 100644 index 0000000000..ca4ebed581 --- /dev/null +++ b/cpukit/aclocal/rtems-includes.m4 @@ -0,0 +1,23 @@ +dnl +dnl RTEMS Include paths. +dnl +AC_DEFUN([RTEMS_INCLUDES], +[ +AC_REQUIRE([RTEMS_SOURCE_TOP]) +AC_REQUIRE([RTEMS_BUILD_TOP]) + +# Was CFLAGS set? +rtems_cv_CFLAGS_set="${CFLAGS+set}" + +RTEMS_INCLUDE_CPUKIT="-I${RTEMS_SOURCE_ROOT}/cpukit/include" +RTEMS_INCLUDE_CPUKIT_ARCH="-I${RTEMS_SOURCE_ROOT}/cpukit/score/cpu/\$(RTEMS_CPU)/include" + +RTEMS_CPUKIT_INCLUDE="${RTEMS_INCLUDE_CPUKIT} ${RTEMS_INCLUDE_CPUKIT_ARCH}" +RTEMS_BUILD_INCLUDE="-I\$(top_builddir) -I${RTEMS_BUILD_ROOT}/include" + +RTEMS_INCLUDE="${RTEMS_BUILD_INCLUDE} ${RTEMS_CPUKIT_INCLUDE}" + +RTEMS_CPPFLAGS="${RTEMS_INCLUDE}" + +AC_SUBST([RTEMS_CPPFLAGS]) +]) diff --git a/cpukit/aclocal/rtems-source-top.m4 b/cpukit/aclocal/rtems-source-top.m4 new file mode 100644 index 0000000000..d1460ae82d --- /dev/null +++ b/cpukit/aclocal/rtems-source-top.m4 @@ -0,0 +1,8 @@ +dnl +dnl RTEMS_SOURCE_TOP +dnl +AC_DEFUN([RTEMS_SOURCE_TOP], +[dnl +RTEMS_SOURCE_ROOT="${with_rtems_source_top}" +AC_SUBST([RTEMS_SOURCE_ROOT]) +])dnl diff --git a/cpukit/automake/compile.am b/cpukit/automake/compile.am index ace3d9045b..4fc133e7aa 100644 --- a/cpukit/automake/compile.am +++ b/cpukit/automake/compile.am @@ -1,3 +1,5 @@ AM_CPPFLAGS = @RTEMS_CPPFLAGS@ AM_CFLAGS = AM_CCASFLAGS = @RTEMS_CCASFLAGS@ + +ARFLAGS = crD diff --git a/cpukit/automake/local.am b/cpukit/automake/local.am index c2bfbfdb98..3815a7d086 100644 --- a/cpukit/automake/local.am +++ b/cpukit/automake/local.am @@ -1,3 +1,2 @@ -preinstall-am: $(PREINSTALL_FILES) -preinstall: preinstall-am -.PHONY: preinstall preinstall-am + +all-local: $(TMPINSTALL_FILES) diff --git a/cpukit/automake/subdirs.am b/cpukit/automake/subdirs.am index 867704460f..8c7be70e60 100644 --- a/cpukit/automake/subdirs.am +++ b/cpukit/automake/subdirs.am @@ -14,29 +14,7 @@ SUBDIRS_no_dot = $(filter-out .,$(_SUBDIRS)) SUBDIRS_no_dot_no_wrapup = $(filter-out wrapup,$(SUBDIRS_no_dot)) SUBDIRS_wrapup = $(filter wrapup,$(SUBDIRS_no_dot)) -SUBDIR_TARGET = $(subst /,-,$1) -PREINSTALL_TARGET = preinstall-$(call SUBDIR_TARGET,$(1)) - -preintstall_targets = $(if "$(SUBDIRS_dot)" ".",preinstall-dot) $(foreach D,$(SUBDIRS_no_dot),$(call PREINSTALL_TARGET,$(D))) - -define PREINSTALL_DIR -.PHONY: $1 -$1: - @+set fnord $(MAKEFLAGS); amf=$$$$2; \ - subdir=$(2); \ - subdir_label=`echo $(1) | sed -e 's/preinstall-//'`; \ - target=`echo $$@ | sed -e 's/-recursive//' -e "s/-$$$${subdir_label}//"`$(3); \ - echo "Making $$$$target in $$$$subdir"; \ - (cd $$$$subdir && $(MAKE) $(AM_MAKEFLAGS) $$$$target) \ - || case "$$$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; -endef - -$(if "$(SUBDIRS_dot)" ".",$(eval $(call PREINSTALL_DIR,preinstall-dot,.,-am))) - -$(foreach D,$(SUBDIRS_no_dot),$(eval $(call PREINSTALL_DIR,$(call PREINSTALL_TARGET,$(D)),$(D)))) - preinstall: $(preintstall_targets) -.PHONY: preinstall define CPUKITDIR .PHONY: $1 @@ -71,4 +49,4 @@ $(foreach D,$(SUBDIRS_no_dot),$(eval $(call CPUKITDIR,$(D),$(D)))) # $(if "$(SUBDIRS_wrapup)" "wrapup",wrapup: dot $(foreach D,$(SUBDIRS_no_dot_no_wrapup),$(D)),) -all-local: preinstall $(if "$(SUBDIRS_dot)" ".",dot) $(SUBDIRS_no_dot) +all-local: $(if "$(SUBDIRS_dot)" ".",dot) $(SUBDIRS_no_dot) diff --git a/cpukit/configure.ac b/cpukit/configure.ac index 382fee64a7..8435e138ea 100644 --- a/cpukit/configure.ac +++ b/cpukit/configure.ac @@ -4,13 +4,14 @@ AC_PREREQ([2.69]) AC_INIT([rtems-cpukit],[_RTEMS_VERSION],[https://devel.rtems.org/newticket]) AC_CONFIG_SRCDIR([score]) RTEMS_TOP([..],[]) +RTEMS_SOURCE_TOP +RTEMS_BUILD_TOP RTEMS_CANONICAL_TARGET_CPU AM_INIT_AUTOMAKE([no-define nostdinc subdir-objects foreign 1.12.2]) AM_MAINTAINER_MODE -RTEMS_ENABLE_MULTILIB RTEMS_ENABLE_MULTIPROCESSING RTEMS_ENABLE_POSIX RTEMS_ENABLE_RTEMS_DEBUG @@ -489,9 +490,4 @@ pppd/Makefile mghttpd/Makefile wrapup/Makefile]) -AC_CONFIG_COMMANDS([preinstall-stamp], -[test -z "$with_multisubdir" && ${MAKE} preinstall-stamp], -[MAKE=${MAKE} -with_multisubdir="$with_multisubdir"]) - AC_OUTPUT diff --git a/cpukit/dev/Makefile.am b/cpukit/dev/Makefile.am index b60e035fdb..f499bbb948 100644 --- a/cpukit/dev/Makefile.am +++ b/cpukit/dev/Makefile.am @@ -1,39 +1,6 @@ include $(top_srcdir)/automake/compile.am include $(top_srcdir)/automake/multilib.am -include_devdir = $(includedir)/dev -include_dev_HEADERS = - -include_dev_i2cdir = $(includedir)/dev/i2c -include_dev_i2c_HEADERS = -include_dev_i2c_HEADERS += include/dev/i2c/eeprom.h -include_dev_i2c_HEADERS += include/dev/i2c/fpga-i2c-slave.h -include_dev_i2c_HEADERS += include/dev/i2c/gpio-nxp-pca9535.h -include_dev_i2c_HEADERS += include/dev/i2c/i2c.h -include_dev_i2c_HEADERS += include/dev/i2c/sensor-lm75a.h -include_dev_i2c_HEADERS += include/dev/i2c/switch-nxp-pca9548a.h -include_dev_i2c_HEADERS += include/dev/i2c/xilinx-axi-i2c.h -include_dev_i2c_HEADERS += include/dev/i2c/ti-ads-16bit-adc.h -include_dev_i2c_HEADERS += include/dev/i2c/ti-lm25066a.h -include_dev_i2c_HEADERS += include/dev/i2c/ti-tmp112.h - -include_dev_spidir = $(includedir)/dev/spi -include_dev_spi_HEADERS = -include_dev_spi_HEADERS += include/dev/spi/spi.h - -include_dev_serialdir = $(includedir)/dev/serial -include_dev_serial_HEADERS = -include_dev_serial_HEADERS += include/dev/serial/sc16is752.h - -include_linuxdir = $(includedir)/linux -include_linux_HEADERS = -include_linux_HEADERS += include/linux/i2c.h -include_linux_HEADERS += include/linux/i2c-dev.h - -include_linux_spidir = $(includedir)/linux/spi -include_linux_spi_HEADERS = -include_linux_spi_HEADERS += include/linux/spi/spidev.h - noinst_LIBRARIES = libdev.a libdev_a_SOURCES = @@ -53,5 +20,4 @@ libdev_a_SOURCES += serial/sc16is752.c libdev_a_SOURCES += serial/sc16is752-spi.c libdev_a_SOURCES += serial/sc16is752-regs.h -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am diff --git a/cpukit/dev/include/dev/i2c/eeprom.h b/cpukit/dev/include/dev/i2c/eeprom.h deleted file mode 100644 index 73df5ad9f4..0000000000 --- a/cpukit/dev/include/dev/i2c/eeprom.h +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @file - * - * @brief EEPROM Driver API - * - * @ingroup I2CEEPROM - */ - -/* - * Copyright (c) 2014 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _DEV_I2C_EEPROM_H -#define _DEV_I2C_EEPROM_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup I2CEEPROM EEPROM Driver - * - * @ingroup I2CDevice - * - * @brief Driver for EEPROM device. - * - * @{ - */ - -int i2c_dev_register_eeprom( - const char *bus_path, - const char *dev_path, - uint16_t i2c_address, - uint16_t address_bytes, - uint16_t page_size_in_bytes, - uint32_t size_in_bytes, - uint32_t program_timeout_in_ms -); - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _DEV_I2C_EEPROM_H */ diff --git a/cpukit/dev/include/dev/i2c/fpga-i2c-slave.h b/cpukit/dev/include/dev/i2c/fpga-i2c-slave.h deleted file mode 100644 index c10b26ac5b..0000000000 --- a/cpukit/dev/include/dev/i2c/fpga-i2c-slave.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2016-2017 Chris Johns - * All rights reserved. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -/* - * I2C slave for testing: - * https://github.com/oetr/FPGA-I2C-Slave - */ - -#ifndef FPGA_I2C_SLAVE_H -#define FPGA_I2C_SLAVE_H - -#include - -int i2c_dev_register_fpga_i2c_slave(const char* bus_path, - const char* dev_path, - uint16_t address, - size_t size); - -#endif diff --git a/cpukit/dev/include/dev/i2c/gpio-nxp-pca9535.h b/cpukit/dev/include/dev/i2c/gpio-nxp-pca9535.h deleted file mode 100644 index 1ebc1a3d4d..0000000000 --- a/cpukit/dev/include/dev/i2c/gpio-nxp-pca9535.h +++ /dev/null @@ -1,123 +0,0 @@ -/** - * @file - * - * @brief GPIO NXP PCA9535 Driver API - * - * @ingroup I2CGPIONXPPCA9535 - */ - -/* - * Copyright (c) 2014 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _DEV_I2C_GPIO_NXP_PCA9539_H -#define _DEV_I2C_GPIO_NXP_PCA9539_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup I2CGPIONXPPCA9535 GPIO NXP PCA9535 Driver - * - * @ingroup I2CDevice - * - * @brief Driver for NXP PCA9535 16-bit GPIO device. - * - * @{ - */ - -int i2c_dev_register_gpio_nxp_pca9535( - const char *bus_path, - const char *dev_path, - uint16_t address -); - -#define GPIO_NXP_PCA9535_GET_INPUT (I2C_DEV_IO_CONTROL + 0) - -#define GPIO_NXP_PCA9535_GET_OUTPUT (I2C_DEV_IO_CONTROL + 1) - -#define GPIO_NXP_PCA9535_SET_OUTPUT (I2C_DEV_IO_CONTROL + 2) - -#define GPIO_NXP_PCA9535_CLEAR_AND_SET_OUTPUT (I2C_DEV_IO_CONTROL + 3) - -#define GPIO_NXP_PCA9535_GET_POL_INV (I2C_DEV_IO_CONTROL + 4) - -#define GPIO_NXP_PCA9535_SET_POL_INV (I2C_DEV_IO_CONTROL + 5) - -#define GPIO_NXP_PCA9535_GET_CONFIG (I2C_DEV_IO_CONTROL + 6) - -#define GPIO_NXP_PCA9535_SET_CONFIG (I2C_DEV_IO_CONTROL + 7) - -static inline int gpio_nxp_pca9535_get_input(int fd, uint16_t *val) -{ - return ioctl(fd, GPIO_NXP_PCA9535_GET_INPUT, val); -} - -static inline int gpio_nxp_pca9535_get_output(int fd, uint16_t *val) -{ - return ioctl(fd, GPIO_NXP_PCA9535_GET_OUTPUT, val); -} - -static inline int gpio_nxp_pca9535_set_output(int fd, uint16_t val) -{ - return ioctl(fd, GPIO_NXP_PCA9535_SET_OUTPUT, (void *)(uintptr_t) val); -} - -static inline int gpio_nxp_pca9535_clear_and_set_output( - int fd, - uint16_t clear, - uint16_t set -) -{ - uint32_t clear_and_set = ((uint32_t) set << 16) | (uint32_t) clear; - - return ioctl( - fd, - GPIO_NXP_PCA9535_CLEAR_AND_SET_OUTPUT, - (void *)(uintptr_t) clear_and_set - ); -} - -static inline int gpio_nxp_pca9535_get_polarity_inversion( - int fd, - uint16_t *val -) -{ - return ioctl(fd, GPIO_NXP_PCA9535_GET_POL_INV, val); -} - -static inline int gpio_nxp_pca9535_set_polarity_inversion(int fd, uint16_t val) -{ - return ioctl(fd, GPIO_NXP_PCA9535_SET_POL_INV, (void *)(uintptr_t) val); -} - -static inline int gpio_nxp_pca9535_get_config(int fd, uint16_t *val) -{ - return ioctl(fd, GPIO_NXP_PCA9535_GET_CONFIG, val); -} - -static inline int gpio_nxp_pca9535_set_config(int fd, uint16_t val) -{ - return ioctl(fd, GPIO_NXP_PCA9535_SET_CONFIG, (void *)(uintptr_t) val); -} - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _DEV_I2C_GPIO_NXP_PCA9539_H */ diff --git a/cpukit/dev/include/dev/i2c/i2c.h b/cpukit/dev/include/dev/i2c/i2c.h deleted file mode 100644 index 2ace4fcf64..0000000000 --- a/cpukit/dev/include/dev/i2c/i2c.h +++ /dev/null @@ -1,432 +0,0 @@ -/** - * @file - * - * @brief Inter-Integrated Circuit (I2C) Driver API - * - * @ingroup I2C - */ - -/* - * Copyright (c) 2014 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _DEV_I2C_I2C_H -#define _DEV_I2C_I2C_H - -#include -#include - -#include -#include - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -typedef struct i2c_msg i2c_msg; - -typedef struct i2c_bus i2c_bus; - -typedef struct i2c_dev i2c_dev; - -typedef struct i2c_rdwr_ioctl_data i2c_rdwr_ioctl_data; - -/** - * @defgroup I2C Inter-Integrated Circuit (I2C) Driver - * - * @brief Inter-Integrated Circuit (I2C) bus and device driver support. - * - * @{ - */ - -/** - * @defgroup I2CBus I2C Bus Driver - * - * @ingroup I2C - * - * @{ - */ - -/** - * @name I2C IO Control Commands - * - * @{ - */ - -/** - * @brief Obtains the bus. - * - * This command has no argument. - */ -#define I2C_BUS_OBTAIN 0x800 - -/** - * @brief Releases the bus. - * - * This command has no argument. - */ -#define I2C_BUS_RELEASE 0x801 - -/** - * @brief Gets the bus control. - * - * The argument type is a pointer to i2c_bus pointer. - */ -#define I2C_BUS_GET_CONTROL 0x802 - -/** - * @brief Sets the bus clock in Hz. - * - * The argument type is unsigned long. - */ -#define I2C_BUS_SET_CLOCK 0x803 - -/** @} */ - -/** - * @brief Default I2C bus clock in Hz. - */ -#define I2C_BUS_CLOCK_DEFAULT 100000 - -/** - * @brief I2C bus control. - */ -struct i2c_bus { - /** - * @brief Transfers I2C messages. - * - * @param[in] bus The bus control. - * @param[in] msgs The messages to transfer. - * @param[in] msg_count The count of messages to transfer. It must be - * positive. - * - * @retval 0 Successful operation. - * @retval negative Negative error number in case of an error. - */ - int (*transfer)(i2c_bus *bus, i2c_msg *msgs, uint32_t msg_count); - - /** - * @brief Sets the bus clock. - * - * @param[in] bus The bus control. - * @param[in] clock The desired bus clock in Hz. - * - * @retval 0 Successful operation. - * @retval negative Negative error number in case of an error. - */ - int (*set_clock)(i2c_bus *bus, unsigned long clock); - - /** - * @brief Destroys the bus. - * - * @param[in] bus The bus control. - */ - void (*destroy)(i2c_bus *bus); - - /** - * @brief Mutex to protect the bus access. - */ - rtems_id mutex; - - /** - * @brief Default slave device address. - */ - uint16_t default_address; - - /** - * @brief Use 10-bit addresses. - */ - bool ten_bit_address; - - /** - * @brief Use SMBus PEC. - */ - bool use_pec; - - /** - * @brief Transfer retry count. - */ - unsigned long retries; - - /** - * @brief Transaction timeout in ticks. - */ - rtems_interval timeout; - - /** - * @brief Controller functionality. - */ - unsigned long functionality; -}; - -/** - * @brief Initializes a bus control. - * - * After a sucessful initialization the bus control must be destroyed via - * i2c_bus_destroy(). A registered bus control will be automatically destroyed - * in case the device file is unlinked. Make sure to call i2c_bus_destroy() in - * a custom destruction handler. - * - * @param[in] bus The bus control. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The errno is set to indicate the error. - * - * @see i2c_bus_register() - */ -int i2c_bus_init(i2c_bus *bus); - -/** - * @brief Allocates a bus control from the heap and initializes it. - * - * After a sucessful allocation and initialization the bus control must be - * destroyed via i2c_bus_destroy_and_free(). A registered bus control will be - * automatically destroyed in case the device file is unlinked. Make sure to - * call i2c_bus_destroy_and_free() in a custom destruction handler. - * - * @param[in] size The size of the bus control. This enables the addition of - * bus controller specific data to the base bus control. The bus control is - * zero initialized. - * - * @retval non-NULL The new bus control. - * @retval NULL An error occurred. The errno is set to indicate the error. - * - * @see i2c_bus_register() - */ -i2c_bus *i2c_bus_alloc_and_init(size_t size); - -/** - * @brief Destroys a bus control. - * - * @param[in] bus The bus control. - */ -void i2c_bus_destroy(i2c_bus *bus); - -/** - * @brief Destroys a bus control and frees its memory. - * - * @param[in] bus The bus control. - */ -void i2c_bus_destroy_and_free(i2c_bus *bus); - -/** - * @brief Registers a bus control. - * - * This function claims ownership of the bus control regardless if the - * registration is successful or not. - * - * @param[in] bus The bus control. - * @param[in] bus_path The path to the bus device file. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The errno is set to indicate the error. - */ -int i2c_bus_register( - i2c_bus *bus, - const char *bus_path -); - -/** - * @brief Obtains the bus. - * - * @param[in] bus The bus control. - */ -void i2c_bus_obtain(i2c_bus *bus); - -/** - * @brief Releases the bus. - * - * @param[in] bus The bus control. - */ -void i2c_bus_release(i2c_bus *bus); - -/** - * @brief Transfers I2C messages. - * - * The bus is obtained before the transfer and released afterwards. - * - * @param[in] bus The bus control. - * @param[in] msgs The messages to transfer. - * @param[in] msg_count The count of messages to transfer. It must be - * positive. - * - * @retval 0 Successful operation. - * @retval negative Negative error number in case of an error. - */ -int i2c_bus_transfer(i2c_bus *bus, i2c_msg *msgs, uint32_t msg_count); - -/** @} */ - -/** - * @defgroup I2CDevice I2C Device Driver - * - * @ingroup I2C - * - * @{ - */ - -/** - * @brief Base number for device IO control commands. - */ -#define I2C_DEV_IO_CONTROL 0x900 - -/** - * @brief I2C slave device control. - */ -struct i2c_dev { - /** - * @brief Reads from the device. - * - * @retval non-negative Bytes transferred from device. - * @retval negative Negative error number in case of an error. - */ - ssize_t (*read)(i2c_dev *dev, void *buf, size_t n, off_t offset); - - /** - * @brief Writes to the device. - * - * @retval non-negative Bytes transferred to device. - * @retval negative Negative error number in case of an error. - */ - ssize_t (*write)(i2c_dev *dev, const void *buf, size_t n, off_t offset); - - /** - * @brief Device IO control. - * - * @retval 0 Successful operation. - * @retval negative Negative error number in case of an error. - */ - int (*ioctl)(i2c_dev *dev, ioctl_command_t command, void *arg); - - /** - * @brief Gets the file size. - */ - off_t (*get_size)(i2c_dev *dev); - - /** - * @brief Gets the file block size. - */ - blksize_t (*get_block_size)(i2c_dev *dev); - - /** - * @brief Destroys the device. - */ - void (*destroy)(i2c_dev *dev); - - /** - * @brief The bus control. - */ - i2c_bus *bus; - - /** - * @brief The device address. - */ - uint16_t address; - - /** - * @brief File descriptor of the bus. - * - * This prevents destruction of the bus since we hold a reference to it with - * this. - */ - int bus_fd; -}; - - -/** - * @brief Initializes a device control. - * - * After a sucessful initialization the device control must be destroyed via - * i2c_dev_destroy(). A registered device control will be automatically - * destroyed in case the device file is unlinked. Make sure to call - * i2c_dev_destroy_and_free() in a custom destruction handler. - * - * @param[in] device The device control. - * @param[in] bus_path The path to the bus device file. - * @param[in] address The address of the device. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The errno is set to indicate the error. - * - * @see i2c_dev_register() - */ -int i2c_dev_init(i2c_dev *dev, const char *bus_path, uint16_t address); - -/** - * @brief Allocates a device control from the heap and initializes it. - * - * After a sucessful allocation and initialization the device control must be - * destroyed via i2c_dev_destroy_and_free(). A registered device control will - * be automatically destroyed in case the device file is unlinked. Make sure - * to call i2c_dev_destroy_and_free() in a custom destruction handler. - * - * @param[in] size The size of the device control. This enables the addition - * of device specific data to the base device control. The device control is - * zero initialized. - * @param[in] bus_path The path to the bus device file. - * @param[in] address The address of the device. - * - * @retval non-NULL The new device control. - * @retval NULL An error occurred. The errno is set to indicate the error. - * - * @see i2c_dev_register() - */ -i2c_dev *i2c_dev_alloc_and_init( - size_t size, - const char *bus_path, - uint16_t address -); - -/** - * @brief Destroys a device control. - * - * @param[in] dev The device control. - */ -void i2c_dev_destroy(i2c_dev *dev); - -/** - * @brief Destroys a device control and frees its memory. - * - * @param[in] dev The device control. - */ -void i2c_dev_destroy_and_free(i2c_dev *dev); - -/** - * @brief Registers a device control. - * - * This function claims ownership of the device control regardless if the - * registration is successful or not. - * - * @param[in] dev The dev control. - * @param[in] dev_path The path to the device file of the device. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The errno is set to indicate the error. - */ -int i2c_dev_register( - i2c_dev *dev, - const char *dev_path -); - -/** @} */ /* end of i2c device driver */ - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _DEV_I2C_I2C_H */ diff --git a/cpukit/dev/include/dev/i2c/sensor-lm75a.h b/cpukit/dev/include/dev/i2c/sensor-lm75a.h deleted file mode 100644 index e1957dad19..0000000000 --- a/cpukit/dev/include/dev/i2c/sensor-lm75a.h +++ /dev/null @@ -1,125 +0,0 @@ -/** - * @file - * - * @brief Temperature Sensor LM75A Driver API - * - * @ingroup I2CSensorLM75A - */ - -/* - * Copyright (c) 2017 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _DEV_I2C_SENSOR_LM75A_H -#define _DEV_I2C_SENSOR_LM75A_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup I2CSensorLM75A Temperature Sensor LM75A Driver - * - * @ingroup I2CDevice - * - * @brief Driver for NXP or Texas Instruments LM75A temperature sensor. - * - * @{ - */ - -int i2c_dev_register_sensor_lm75a( - const char *bus_path, - const char *dev_path, - uint16_t address -); - -typedef enum { - SENSOR_LM75A_GET_CONF = I2C_DEV_IO_CONTROL, - SENSOR_LM75A_SET_CONF, - SENSOR_LM75A_CLEAR_AND_SET_CONF, - SENSOR_LM75A_GET_TEMP, - SENSOR_LM75A_GET_TOS, - SENSOR_LM75A_SET_TOS, - SENSOR_LM75A_GET_THYST, - SENSOR_LM75A_SET_THYST -} sensor_lm75a_command; - -static inline int sensor_lm75a_get_conf(int fd, uint8_t *val) -{ - return ioctl(fd, SENSOR_LM75A_GET_CONF, val); -} - -static inline int sensor_lm75a_set_conf(int fd, uint8_t val) -{ - return ioctl(fd, SENSOR_LM75A_SET_CONF, (void *)(uintptr_t) val); -} - -static inline int sensor_lm75a_clear_and_set_conf( - int fd, - uint8_t clear, - uint8_t set -) -{ - uint16_t clear_and_set = (uint16_t) (((uint16_t) set << 8) | clear); - - return ioctl( - fd, - SENSOR_LM75A_CLEAR_AND_SET_CONF, - (void *)(uintptr_t) clear_and_set - ); -} - -static inline int sensor_lm75a_get_temp(int fd, int16_t *val) -{ - return ioctl(fd, SENSOR_LM75A_GET_TEMP, val); -} - -static inline int sensor_lm75a_get_temp_celsius(int fd, double *celsius) -{ - int rv; - int16_t val; - - rv = ioctl(fd, SENSOR_LM75A_GET_TEMP, &val); - *celsius = (((int) val) >> 5) * 0.125; - return rv; -} - -static inline int sensor_lm75a_get_tos(int fd, uint16_t *val) -{ - return ioctl(fd, SENSOR_LM75A_GET_TOS, val); -} - -static inline int sensor_lm75a_set_tos(int fd, uint16_t val) -{ - return ioctl(fd, SENSOR_LM75A_SET_TOS, (void *)(uintptr_t) val); -} - -static inline int sensor_lm75a_get_thyst(int fd, uint16_t *val) -{ - return ioctl(fd, SENSOR_LM75A_GET_THYST, val); -} - -static inline int sensor_lm75a_set_thyst(int fd, uint16_t val) -{ - return ioctl(fd, SENSOR_LM75A_SET_THYST, (void *)(uintptr_t) val); -} - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _DEV_I2C_SENSOR_LM75A_H */ diff --git a/cpukit/dev/include/dev/i2c/switch-nxp-pca9548a.h b/cpukit/dev/include/dev/i2c/switch-nxp-pca9548a.h deleted file mode 100644 index ce8ef2c809..0000000000 --- a/cpukit/dev/include/dev/i2c/switch-nxp-pca9548a.h +++ /dev/null @@ -1,68 +0,0 @@ -/** - * @file - * - * @brief Switch NXP PCA9548A Driver API - * - * @ingroup I2CSWITCHNXPPCA9548A - */ - -/* - * Copyright (c) 2014 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _DEV_I2C_SWITCH_NXP_PCA9548A_H -#define _DEV_I2C_SWITCH_NXP_PCA9548A_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup I2CSWITCHNXPPCA9548A Switch NXP PCA9535 Driver - * - * @ingroup I2CDevice - * - * @brief Driver for NXP PCA9548A 8-channel switch device. - * - * @{ - */ - -int i2c_dev_register_switch_nxp_pca9548a( - const char *bus_path, - const char *dev_path, - uint16_t address -); - -#define SWITCH_NXP_PCA9548A_GET_CONTROL (I2C_DEV_IO_CONTROL + 0) - -#define SWITCH_NXP_PCA9548A_SET_CONTROL (I2C_DEV_IO_CONTROL + 1) - -static inline int switch_nxp_pca9548a_get_control(int fd, uint8_t *val) -{ - return ioctl(fd, SWITCH_NXP_PCA9548A_GET_CONTROL, val); -} - -static inline int switch_nxp_pca9548a_set_control(int fd, uint8_t val) -{ - return ioctl(fd, SWITCH_NXP_PCA9548A_SET_CONTROL, (void *)(uintptr_t) val); -} - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _DEV_I2C_SWITCH_NXP_PCA9548A_H */ diff --git a/cpukit/dev/include/dev/i2c/ti-ads-16bit-adc.h b/cpukit/dev/include/dev/i2c/ti-ads-16bit-adc.h deleted file mode 100644 index 40d680da88..0000000000 --- a/cpukit/dev/include/dev/i2c/ti-ads-16bit-adc.h +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (c) 2016-2017 Chris Johns - * All rights reserved. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -/* - * TI ADS1113 and ADS1115. - * http://www.ti.com/product/ads1113/description - */ - -#ifndef TI_ADS1113_ADS1115_H -#define TI_ADS1113_ADS1115_H - -#include - -/* - * Supported devices. Please others once tested. - */ -typedef enum { - TI_ADS1113, - TI_ADS1114, - TI_ADS1115 -} ti_ads_adc; - -/* - * Multiplexer interface. Avalable on ADS1115. - */ -typedef enum { - TI_ADS_MUX_ApA0_AnA1 = 0, /* default */ - TI_ADS_MUX_ApA0_AnA3 = 1, - TI_ADS_MUX_ApA1_AnA3 = 2, - TI_ADS_MUX_ApA2_AnA3 = 3, - TI_ADS_MUX_ApA0_AnGND = 4, - TI_ADS_MUX_ApA1_AnGND = 5, - TI_ADS_MUX_ApA2_AnGND = 6, - TI_ADS_MUX_ApA3_AnGND = 7 -} ti_ads_adc_mux; - -/* - * Programmable Gain Amplifier. Avalable on ADS1114 and ADS1115. - */ -typedef enum { - TI_ADS_PGA_FS_6_144V = 0, - TI_ADS_PGA_FS_4_096V = 1, - TI_ADS_PGA_FS_2_048V = 2, /* default */ - TI_ADS_PGA_FS_1_024V = 3, - TI_ADS_PGA_FS_0_512V = 4, - TI_ADS_PGA_FS_0_256V = 5, - TI_ADS_PGA_FS_0_256V_2 = 6, - TI_ADS_PGA_FS_0_256V_3 = 7, -} ti_ads_adc_pga; - -/* - * Mode. - */ -typedef enum { - TI_ADS_MODE_CONTINUOUS = 0, - TI_ADS_MODE_SINGLE_SHOT = 1, /* default */ -} ti_ads_adc_mode; - -/* - * Data rate. - */ -typedef enum { - TI_ADS_DATARATE_8SPS = 0, - TI_ADS_DATARATE_16SPS = 1, - TI_ADS_DATARATE_32SPS = 2, - TI_ADS_DATARATE_64SPS = 3, - TI_ADS_DATARATE_128SPS = 4, /* default */ - TI_ADS_DATARATE_250SPS = 5, - TI_ADS_DATARATE_475SPS = 6, - TI_ADS_DATARATE_860SPS = 7, -} ti_ads_adc_data_rate; - -/* - * Comparitor interface. Avalable on ADS1114 and ADS1115. - * - * Create a value to write. - */ -#define TI_ADS_COMP_MODE_HYSTERESIS (0 << 4) /* default */ -#define TI_ADS_COMP_MODE_WINDOW (1 << 4) -#define TI_ADS_COMP_POL_ACTIVE_LOW (0 << 3) /* default */ -#define TI_ADS_COMP_POL_ACTIVE_HIGH (1 << 3) -#define TI_ADS_COMP_LAT_NON_LATCHING (0 << 2) /* default */ -#define TI_ADS_COMP_LAT_LATCHING (1 << 2) -#define TI_ADS_COMP_QUE_DISABLE_COMP (3 << 0) /* default */ -#define TI_ADS_COMP_QUE_AFTER_4 (2 << 0) -#define TI_ADS_COMP_QUE_AFTER_2 (1 << 0) -#define TI_ADS_COMP_QUE_AFTER_1 (0 << 0) - -/* - * IO control interface. - * - * Note: if in Power-down single-shot mode (default) a conversion requires the - * device to power up and perform a conversion and this can take - * while. The TI_ADS_ADC_GET_CONV_WAIT call sets the micro-seconds to - * wait between polls. The actual rate will depend on the system tick. - */ -#define TI_ADS_ADC_GET_CONVERSION (I2C_DEV_IO_CONTROL + 0) -#define TI_ADS_ADC_SET_MUX (I2C_DEV_IO_CONTROL + 1) -#define TI_ADS_ADC_SET_PGA (I2C_DEV_IO_CONTROL + 2) -#define TI_ADS_ADC_SET_MODE (I2C_DEV_IO_CONTROL + 3) -#define TI_ADS_ADC_SET_DATA_RATE (I2C_DEV_IO_CONTROL + 4) -#define TI_ADS_ADC_SET_COMP (I2C_DEV_IO_CONTROL + 5) -#define TI_ADS_ADC_SET_LO_THRESH (I2C_DEV_IO_CONTROL + 6) -#define TI_ADS_ADC_SET_HI_THRESH (I2C_DEV_IO_CONTROL + 7) -#define TI_ADS_ADC_SET_CONV_WAIT (I2C_DEV_IO_CONTROL + 8) - -/* - * Register the device. - */ -int i2c_dev_register_ti_ads_adc(const char* bus_path, - const char* dev_path, - uint16_t address, - ti_ads_adc device); - -/* - * Perform a conversion. If the mode is single shot a single shot conversion is - * started and the call waits for the conversion to complete. - */ -static inline int -ti_ads_adc_convert(int fd, uint16_t* sample) -{ - return ioctl(fd, TI_ADS_ADC_GET_CONVERSION, sample); -} - -/* - * Set the multipler. - */ -static inline int -ti_ads_adc_set_mux(int fd, ti_ads_adc_mux mux) -{ - return ioctl(fd, TI_ADS_ADC_SET_MUX, (void *)(uintptr_t) mux); -} - -/* - * Set the PGA. - */ -static inline int -ti_ads_adc_set_pga(int fd, ti_ads_adc_pga pga) -{ - return ioctl(fd, TI_ADS_ADC_SET_PGA, (void *)(uintptr_t) pga); -} - -/* - * Set the mode. - */ -static inline int -ti_ads_adc_set_mode(int fd, ti_ads_adc_mode mode) -{ - return ioctl(fd, TI_ADS_ADC_SET_MODE, (void *)(uintptr_t) mode); -} - -/* - * Set the data rate. - */ -static inline int -ti_ads_adc_set_data_rate(int fd, ti_ads_adc_data_rate rate) -{ - return ioctl(fd, TI_ADS_ADC_SET_DATA_RATE, (void *)(uintptr_t) rate); -} - -/* - * Configure the comparator. - */ -static inline int -ti_ads_adc_set_comparator(int fd, uint16_t comp) -{ - return ioctl(fd, TI_ADS_ADC_SET_COMP, (void *)(uintptr_t) comp); -} - -/* - * Set the lower threshold. - */ -static inline int -ti_ads_adc_set_low_threshold(int fd, uint16_t level) -{ - return ioctl(fd, TI_ADS_ADC_SET_LO_THRESH, (void *)(uintptr_t) level); -} - -/* - * Set the upper threshold. - */ -static inline int -ti_ads_adc_set_high_threshold(int fd, uint16_t level) -{ - return ioctl(fd, TI_ADS_ADC_SET_HI_THRESH, (void *)(uintptr_t) level); -} - -/* - * Set the conversion poll wait period. - */ -static inline int -ti_ads_adc_set_conversion_poll_wait(int fd, uint32_t micro_seconds) -{ - return ioctl(fd, TI_ADS_ADC_SET_CONV_WAIT, (void *)(uintptr_t) micro_seconds); -} - -#endif diff --git a/cpukit/dev/include/dev/i2c/ti-lm25066a.h b/cpukit/dev/include/dev/i2c/ti-lm25066a.h deleted file mode 100644 index 4429f0fc70..0000000000 --- a/cpukit/dev/include/dev/i2c/ti-lm25066a.h +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (c) 2016-2017 Chris Johns - * All rights reserved. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -/* - * TI LM25066A - * http://www.ti.com/product/LM25066A - */ - -#ifndef TI_LM25066A_H -#define TI_LM25066A_H - -#include - -/* - * PM Bus Command interface. - * - * The keys are: - * IO : IO direction R=read W=write - * SZ : Size in bytes. - */ -typedef enum -{ /* IO SZ Name */ - TI_LM25066A_OPERATION = 0, /* R 1 PMBus */ - TI_LM25066A_CLEAR_FAULTS = 1, /* W 0 PMBus */ - TI_LM25066A_CAPABILITY = 2, /* R 1 PMBus */ - TI_LM25066A_VOUT_UV_WARN_LIMIT = 3, /* RW 2 PMBus */ - TI_LM25066A_OT_FAULT_LIMIT = 4, /* RW 2 PMBus */ - TI_LM25066A_OT_WARN_LIMIT = 5, /* RW 2 PMBus */ - TI_LM25066A_VIN_OV_WARN_LIMIT = 6, /* RW 2 PMBus */ - TI_LM25066A_VIN_UV_WARN_LIMIT = 7, /* RW 2 PMBus */ - TI_LM25066A_STATUS_BYTE = 8, /* R 1 PMBus */ - TI_LM25066A_STATUS_WORD = 9, /* R 2 PMBus */ - TI_LM25066A_STATUS_VOUT = 10, /* R 1 PMBus */ - TI_LM25066A_STATUS_INPUT = 11, /* R 1 PMBus */ - TI_LM25066A_STATUS_TEMPERATURE = 12, /* R 1 PMBus */ - TI_LM25066A_STATUS_CML = 13, /* R 1 PMBus */ - TI_LM25066A_STATUS_MFR_SPECIFIC = 14, /* R 1 PMBus */ - TI_LM25066A_READ_VIN = 15, /* R 2 PMBus */ - TI_LM25066A_READ_VOUT = 16, /* R 2 PMBus */ - TI_LM25066A_READ_TEMPERATURE_1 = 17, /* R 2 PMBus */ - TI_LM25066A_MFR_ID = 18, /* R 3 PMBus */ - TI_LM25066A_MFR_MODEL = 19, /* R 8 PMBus */ - TI_LM25066A_MFR_REVISION = 20, /* R 2 PMBus */ - TI_LM25066A_MFR_READ_VAUX = 21, /* R 2 MFR_SPECIFIC_00 */ - TI_LM25066A_MFR_READ_IIN = 22, /* R 2 MFR_SPECIFIC_01 */ - TI_LM25066A_MFR_READ_PIN = 23, /* R 2 MFR_SPECIFIC_02 */ - TI_LM25066A_MFR_IIN_OC_WARN_LIMIT = 24, /* RW 2 MFR_SPECIFIC_03 */ - TI_LM25066A_MFR_PIN_OP_WARN_LIMIT = 25, /* RW 2 MFR_SPECIFIC_04 */ - TI_LM25066A_MFR_PIN_PEAK = 26, /* R 2 MFR_SPECIFIC_05 */ - TI_LM25066A_MFR_CLEAR_PIN_PEAK = 27, /* W 0 MFR_SPECIFIC_06 */ - TI_LM25066A_MFR_GATE_MASK = 28, /* RW 1 MFR_SPECIFIC_07 */ - TI_LM25066A_MFR_ALERT_MASK = 29, /* RW 2 MFR_SPECIFIC_08 */ - TI_LM25066A_MFR_DEVICE_SETUP = 30, /* RW 1 MFR_SPECIFIC_09 */ - TI_LM25066A_MFR_BLOCK_READ = 31, /* R 12 MFR_SPECIFIC_10 */ - TI_LM25066A_MFR_SAMPLES_FOR_AVG = 32, /* RW 1 MFR_SPECIFIC_11 */ - TI_LM25066A_MFR_READ_AVG_VIN = 33, /* R 2 MFR_SPECIFIC_12 */ - TI_LM25066A_MFR_READ_AVG_VOUT = 34, /* R 2 MFR_SPECIFIC_13 */ - TI_LM25066A_MFR_READ_AVG_IIN = 35, /* R 2 MFR_SPECIFIC_14 */ - TI_LM25066A_MFR_READ_AVG_PIN = 36, /* R 2 MFR_SPECIFIC_15 */ - TI_LM25066A_MFR_BLACK_BOX_READ = 37, /* R 12 MFR_SPECIFIC_16 */ - TI_LM25066A_MFR_DIAGNOSTIC_WORD_READ = 38, /* R 2 MFR_SPECIFIC_17 */ - TI_LM25066A_MFR_AVG_BLOCK_READ = 39, /* R 12 MFR_SPECIFIC_18 */ -} ti_lm25066a_cmd; - -/* - * Real world converters. Page 46 of the datasheet discusses reading and - * writing telemtry data and obtaining the real world values. There are 8 - * separate conversions using the same formula. - * - * The formula is: - * - * 1 -R - * X = - (Y x 10 - b) - * m - * - * X: the calculated "real world" value (volts, amps, watt, etc.) - * m: the slope coefficient - * Y: a two byte two's complement integer received from device - * b: the offset, a two byte two's complement integer - * R: the exponent, a one byte two's complement integer - * - * R in the table is inverted because we cannot store 0.01 in an int. This - * makes the equation: - * - * 1 Y - * X = - (- - b) - * m R - * - * The R value lets the integer result have decimal places. - * - * There are 8 conversion table entries listed in Table 41 of the - * data sheet. They are: - * - * 1. READ_VIN, READ_AVG_VIN, VIN_OV_WARN_LIMIT, VIN_UV_WARN_LIMIT - * 2. READ_VOUT, READ_AVG_VOUT, VOUT_UV_WARN_LIMIT - * 3. READ_VAUX - * 4.GND READ_IIN, READ_AVG_IIN, MFR_IIN_OC_WARN_LIMIT - * 4.VDD READ_IIN, READ_AVG_IIN, MFR_IIN_OC_WARN_LIMIT - * 5.GND READ_PIN, READ_AVG_PIN, READ_PIN_PEAK, MFR_PIN_OP_WARN_LIMIT - * 5.VCC READ_PIN, READ_AVG_PIN, READ_PIN_PEAK, MFR_PIN_OP_WARN_LIMIT - * 6. READ_TEMPERATURE_1, OT_WARN_LIMIT, OT_FAULT_LIMIT - * - * You need to provide 6 sets of conversion factors. Row 4 and 5 depend on how - * the device is wired. The driver will use the matching table row to convert - * the 2-complement 12 bit to a real world value. - */ -#define TI_LM25066A_CONVERSION_SIZE (6) -typedef struct -{ - int m; /* The slope coefficient */ - int b; /* The offset */ - int R; /* The inverted power of 10 of -R */ -} ti_lm25066a_conversion; - -/* - * IO control interface. - */ -#define TI_LM25066A_GET (I2C_DEV_IO_CONTROL + 0) -#define TI_LM25066A_SET (I2C_DEV_IO_CONTROL + 1) - -/* - * IO data types. - */ -typedef enum -{ - TI_LM25066A_8BIT = 0, - TI_LM25066A_16BIT = 1, - TI_LM25066A_VALUE = 2, - TI_LM25066A_VALUES = 3, - TI_LM25066A_STRING = 4, - TI_LM25066A_RAW = 5 -} ti_lm25066a_data; - -/* - * Struct to move data into and out of the driver. - */ -typedef struct -{ - ti_lm25066a_cmd cmd; - ti_lm25066a_data type; - union { - uint8_t u8; - uint16_t u16; - int value; - int values[6]; - char string[9]; - uint8_t* raw; - } data; -} ti_lm25066a_io; - -/* - * Register the device. - * - * The conversions table has 6 columns. - * - * The values are an integer so the decimal_point value scales the value so it - * can fit in an integer with the required number of decimal points. - */ -int i2c_dev_register_ti_lm25066a(const char* bus_path, - const char* dev_path, - uint16_t address, - const ti_lm25066a_conversion* const conversions, - const int decimal_points); - -/* - * Get. - */ -static inline int -ti_lm25066a_get(int fd, ti_lm25066a_io* io) -{ - return ioctl(fd, TI_LM25066A_GET, io); -} - -/* - * Set. - */ -static inline int -ti_lm25066a_set(int fd, ti_lm25066a_io* io) -{ - return ioctl(fd, TI_LM25066A_SET, io); -} - - -#endif diff --git a/cpukit/dev/include/dev/i2c/ti-tmp112.h b/cpukit/dev/include/dev/i2c/ti-tmp112.h deleted file mode 100644 index 1b80fa6994..0000000000 --- a/cpukit/dev/include/dev/i2c/ti-tmp112.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2016-2017 Chris Johns - * All rights reserved. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -/* - * TI TMP112 - * http://www.ti.com/product/TMP112 - */ - -#ifndef TI_TMP112_H -#define TI_TMP112_H - -#include - -/* - * Confirguration. - */ -#define TI_TMP112_CR_0_25Hz (0 << 6) -#define TI_TMP112_CR_1Hz (1 << 6) -#define TI_TMP112_CR_4Hz (2 << 6) /* default */ -#define TI_TMP112_CR_8Hz (3 << 6) -#define TI_TMP112_EM_NORMAL (0 << 4) /* default */ -#define TI_TMP112_EM_EXTENDED (1 << 4) -#define TI_TMP112_SD_ON (0 << 8) /* default */ -#define TI_TMP112_SD_SHUTDOWN (1 << 8) -#define TI_TMP112_TM_COMPARATOR (0 << 9) /* default */ -#define TI_TMP112_TM_INTERRUPT (1 << 9) -#define TI_TMP112_POL_ALERT_LOW (0 << 10) /* default */ -#define TI_TMP112_POL_ALERT_HIGH (1 << 10) -#define TI_TMP112_FQL_1 (0 << 11) /* default */ -#define TI_TMP112_FQL_2 (1 << 11) -#define TI_TMP112_FQL_4 (2 << 11) -#define TI_TMP112_FQL_6 (3 << 11) - -/* - * IO control interface. - */ -#define TI_TMP112_GET_TEMP (I2C_DEV_IO_CONTROL + 0) -#define TI_TMP112_GET_TEMP_RAW (I2C_DEV_IO_CONTROL + 1) -#define TI_TMP112_SET_CONFIG (I2C_DEV_IO_CONTROL + 2) -#define TI_TMP112_SET_LOW_TEMP (I2C_DEV_IO_CONTROL + 3) -#define TI_TMP112_SET_HIGH_TEMP (I2C_DEV_IO_CONTROL + 4) - -/* - * Register the device. - */ -int i2c_dev_register_ti_tmp112(const char* bus_path, - const char* dev_path, - uint16_t address); - -/* - * Get the temperature in degrees C x 10000. To print you would so: - * - * printf("Temperature is %3d.%04d\n", temp / 10000, temp % 10000); - * - * If the device is shutdown a single conversion is made waiting for the - * conversion to complete. - */ -static inline int -ti_tmp112_get_temperature(int fd, int* temp) -{ - return ioctl(fd, TI_TMP112_GET_TEMP, temp); -} - -/* - * Get the temperature as the raw register value. - * - * If the device is shutdown a single conversion is made waiting for the - * conversion to complete. - */ -static inline int -ti_tmp112_get_temperature_raw(int fd, unsigned int* temp) -{ - return ioctl(fd, TI_TMP112_GET_TEMP_RAW, temp); -} - -/* - * Set the configuration. - */ -static inline int -ti_tmp112_adc_set_config(int fd, uint16_t config) -{ - return ioctl(fd, TI_TMP112_SET_CONFIG, (void *)(uintptr_t) config); -} - -/* - * Set the low temperature. - */ -static inline int -ti_tmp112_set_low_temperator(int fd, uint16_t temp) -{ - return ioctl(fd, TI_TMP112_SET_LOW_TEMP, (void *)(uintptr_t) temp); -} - -/* - * Set the high temperature. - */ -static inline int -ti_tmp112_adc_set_high_threshold(int fd, uint16_t level) -{ - return ioctl(fd, TI_TMP112_SET_HIGH_TEMP, (void *)(uintptr_t) level); -} - -#endif diff --git a/cpukit/dev/include/dev/i2c/xilinx-axi-i2c.h b/cpukit/dev/include/dev/i2c/xilinx-axi-i2c.h deleted file mode 100644 index fafac346ec..0000000000 --- a/cpukit/dev/include/dev/i2c/xilinx-axi-i2c.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2016-2017 Chris Johns All rights reserved. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -/* - * Xilinx AXI IIC Interface v2.0. See PG090.pdf. - * - * Note, only master support is provided and no dynamic mode by design. - * - * The clock set up is to be handled by the IP integrator. There are too many - * factors handling this in software. - */ - - -#ifndef XILINX_AXI_I2C_H -#define XILINX_AXI_I2C_H - -#include - -/* - * The PL integrator controls the timing. This interface allows software to - * override those settings. It pays to check the timing with ChipScope. - * - * If you set the AXI bus frequency you can use the clock speed ioctl call to - * change the speed dymanically. The ioctl call overrides the defaults passed - * in. - * - * Set the valid mask to the values that are to be set. - */ -#define XILINX_AIX_I2C_AXI_CLOCK (1 << 0) -#define XILINX_AIX_I2C_TSUSTA (1 << 1) -#define XILINX_AIX_I2C_TSUSTO (1 << 2) -#define XILINX_AIX_I2C_THDSTA (1 << 3) -#define XILINX_AIX_I2C_TSUDAT (1 << 4) -#define XILINX_AIX_I2C_TBUF (1 << 5) -#define XILINX_AIX_I2C_THIGH (1 << 6) -#define XILINX_AIX_I2C_TLOW (1 << 7) -#define XILINX_AIX_I2C_THDDAT (1 << 8) -#define XILINX_AIX_I2C_ALL_REGS (XILINX_AIX_I2C_TSUSTA | \ - XILINX_AIX_I2C_TSUSTO | \ - XILINX_AIX_I2C_THDSTA | \ - XILINX_AIX_I2C_TSUDAT | \ - XILINX_AIX_I2C_TBUF | \ - XILINX_AIX_I2C_THIGH | \ - XILINX_AIX_I2C_TLOW | \ - XILINX_AIX_I2C_THDDAT) -typedef struct -{ - uint32_t valid_mask; - uint32_t AXI_CLOCK; - uint32_t SCL_INERTIAL_DELAY; - uint32_t TSUSTA; - uint32_t TSUSTO; - uint32_t THDSTA; - uint32_t TSUDAT; - uint32_t TBUF; - uint32_t THIGH; - uint32_t TLOW; - uint32_t THDDAT; -} xilinx_aix_i2c_timing; - -/* - * Register the driver. - * - * The driver can multipex a number of I2C buses (in master mode only) using - * the GPO port. The PL designer can use the output pins to select a bus. This - * is useful if connecting a number of slave devices that have limit selectable - * addresses. - * - * @param bus_path The driver's device path. - * @param register_base AXI base address. - * @param irq AXI FPGA interrupt. - * @param gpio_address Bits 12:15 of a slave address it written to the GPO. - * @param timing Override the default timing. NULL means no changes. - */ -int i2c_bus_register_xilinx_aix_i2c(const char* bus_path, - uintptr_t register_base, - rtems_vector_number irq, - bool ten_gpio, - const xilinx_aix_i2c_timing* timing); - -#endif diff --git a/cpukit/dev/include/dev/serial/sc16is752.h b/cpukit/dev/include/dev/serial/sc16is752.h deleted file mode 100644 index 7e5b47aaa2..0000000000 --- a/cpukit/dev/include/dev/serial/sc16is752.h +++ /dev/null @@ -1,262 +0,0 @@ -/* - * Copyright (c) 2016 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _DEV_SERIAL_SC16IS752_H -#define _DEV_SERIAL_SC16IS752_H - -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup SC16IS752 SC16IS752 Serial Device Driver - * - * @ingroup TermiostypesSupport - */ - -typedef enum { - SC16IS752_MODE_RS232, - SC16IS752_MODE_RS485 -} sc16is752_mode; - -typedef struct sc16is752_context sc16is752_context; - -/** - * @brief SC16IS752 device context. - */ -struct sc16is752_context { - rtems_termios_device_context base; - - /** - * @brief Writes a register. - * - * Internal handler. - */ - int (*write_reg)( - sc16is752_context *ctx, - uint8_t addr, - const uint8_t *data, - size_t len - ); - - /** - * @brief Reads a register. - * - * Internal handler. - */ - int (*read_reg)( - sc16is752_context *ctx, - uint8_t addr, - uint8_t *data, - size_t len - ); - - /** - * @brief Reads two registers. - * - * Internal handler. - */ - int (*read_2_reg)( - sc16is752_context *ctx, - uint8_t addr_0, - uint8_t addr_1, - uint8_t data[2] - ); - - /** - * @brief First open. - * - * Internal handler. - */ - bool (*first_open)(sc16is752_context *ctx); - - /** - * @brief Last close. - * - * Internal handler. - */ - void (*last_close)(sc16is752_context *ctx); - - /** - * @brief Shall install the interrupt handler. - * - * Must be initialized by the user before the device creation. - */ - bool (*install_irq)(sc16is752_context *ctx); - - /** - * @brief Shall remove the interrupt handler. - * - * Must be initialized by the user before the device creation. - */ - void (*remove_irq)(sc16is752_context *ctx); - - /** - * @brief Device mode. - * - * Must be initialized by the user before the device creation. - */ - sc16is752_mode mode; - - /** - * @brief Input frequency in Hertz (dependent on crystal, see XTAL1 and XTAL2 - * pins). - * - * Must be initialized by the user before the device creation. - */ - uint32_t input_frequency; - - /** - * @brief Corresponding Termios structure. - * - * Internal variable. - */ - rtems_termios_tty *tty; - - /** - * @brief Shadow Interrupt Enable Register (IER). - * - * Internal variable. - */ - uint8_t ier; - - /** - * @brief Characters placed into transmit FIFO. - * - * Internal variable. - */ - uint8_t tx_in_progress; - - /** - * @brief Count of free characters in the transmit FIFO. - * - * Internal variable. - */ - uint8_t tx_fifo_free; - - /** - * @brief Shadow Line Control Register (LCR). - * - * Internal variable. - */ - uint8_t lcr; - - /** - * @brief Shadow Extra Features Control Register (EFCR). - * - * Internal variable. - */ - uint8_t efcr; -}; - -/** - * @brief SC16IS752 SPI context. - */ -typedef struct { - sc16is752_context base; - - /** - * @brief The SPI bus device file descriptor. - * - * Internal variable. - */ - int fd; - - /** - * @brief The SPI device chip select. - * - * Must be initialized by the user before the call to sc16is752_spi_create(). - */ - uint8_t cs; - - /** - * @brief The SPI bus speed in Hertz. - * - * Must be initialized by the user before the call to sc16is752_spi_create(). - */ - uint32_t speed_hz; - - /** - * @brief The SPI bus device path. - * - * Must be initialized by the user before the call to sc16is752_spi_create(). - */ - const char *spi_path; -} sc16is752_spi_context; - -/** - * @brief SC16IS752 I2C context. - */ -typedef struct { - sc16is752_context base; - - /** - * @brief The I2C bus device file descriptor. - * - * Internal variable. - */ - int fd; - - /** - * @brief The I2C bus device path. - * - * Must be initialized before the call to sc16is752_i2c_create(). - */ - const char *bus_path; -} sc16is752_i2c_context; - -const rtems_termios_device_handler sc16is752_termios_handler; - -/** - * @brief The interrupt handler for receive and transmit operations. - * - * @param[in] arg The device context. - */ -void sc16is752_interrupt_handler(void *arg); - -/** - * @brief Creates an SPI connected SC16IS752 device. - * - * @param[in] ctx The SPI SC16IS752 device context. - * @param[in] device_path The device file path for the new device. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval other See rtems_termios_device_install(). - */ -rtems_status_code sc16is752_spi_create( - sc16is752_spi_context *ctx, - const char *device_path -); - -/** - * @brief Enables the sleep mode if non-zero, otherwise disables it. - * - * The sleep mode is disabled by default. - */ -#define SC16IS752_SET_SLEEP_MODE _IOW('d', 0, int) - -/** - * @brief Returns non-zero in case the sleep mode is enabled, otherwise zero. - */ -#define SC16IS752_GET_SLEEP_MODE _IOR('d', 0, int) - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _DEV_SERIAL_SC16IS752_H */ diff --git a/cpukit/dev/include/dev/spi/spi.h b/cpukit/dev/include/dev/spi/spi.h deleted file mode 100644 index 66bbac2427..0000000000 --- a/cpukit/dev/include/dev/spi/spi.h +++ /dev/null @@ -1,216 +0,0 @@ -/** - * @file - * - * @brief Serial Peripheral Interface (SPI) Driver API - * - * @ingroup SPI - */ - -/* - * Copyright (c) 2016 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _DEV_SPI_SPI_H -#define _DEV_SPI_SPI_H - -#include - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -typedef struct spi_ioc_transfer spi_ioc_transfer; - -typedef struct spi_bus spi_bus; - -/** - * @defgroup SPI Serial Peripheral Interface (SPI) Driver - * - * @brief Serial Peripheral Interface (SPI) bus driver support. - * - * @{ - */ - -/** - * @brief Obtains the bus. - * - * This command has no argument. - */ -#define SPI_BUS_OBTAIN _IO(SPI_IOC_MAGIC, 13) - -/** - * @brief Releases the bus. - * - * This command has no argument. - */ -#define SPI_BUS_RELEASE _IO(SPI_IOC_MAGIC, 23) - -/** - * @brief SPI bus control. - */ -struct spi_bus { - /** - * @brief Transfers SPI messages. - * - * @param[in] bus The bus control. - * @param[in] msgs The messages to transfer. - * @param[in] msg_count The count of messages to transfer. It must be - * positive. - * - * @retval 0 Successful operation. - * @retval negative Negative error number in case of an error. - */ - int (*transfer)(spi_bus *bus, const spi_ioc_transfer *msgs, uint32_t msg_count); - - /** - * @brief Checks if maximum speed and bits per word are in a valid range - * for the device - * - * @param[in] bus The bus control. - * - * @retval 0 Successful operation. - * @retval negative Negative error number in case of an error. - */ - int (*setup)(spi_bus *bus); - - /** - * @brief Destroys the bus. - * - * @param[in] bus The bus control. - */ - void (*destroy)(spi_bus *bus); - - /** - * @brief Mutex to protect the bus access. - */ - rtems_id mutex; - - /** - * @brief Maximum Speed in Hz - */ - uint32_t max_speed_hz; - - /** - * @brief Indicates the speed of the current device message. - */ - uint32_t speed_hz; - - /** - * @brief Indicates if chip select must be set high after transfer. - */ - bool cs_change; - - /** - * @brief Indicates which device is selected by chip select - */ - uint8_t cs; - - /** - * @brief Indicates the bits per word used on the device. - */ - uint8_t bits_per_word; - - /** - * @brief Indicates if LSB is supposed to be transmitted first. - */ - bool lsb_first; - - /** - * @brief Current mode. - */ - uint32_t mode; - - /** - * @brief Indicates the delay between transfers on different chip select - * devices. - */ - uint16_t delay_usecs; -}; - -/** - * @brief Initializes a bus control. - * - * After a sucessful initialization the bus control must be destroyed via - * spi_bus_destroy(). A registered bus control will be automatically destroyed - * in case the device file is unlinked. Make sure to call spi_bus_destroy() in - * a custom destruction handler. - * - * @param[in] bus The bus control. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The errno is set to indicate the error. - * - * @see spi_bus_register() - */ -int spi_bus_init(spi_bus *bus); - -/** - * @brief Allocates a bus control from the heap and initializes it. - * - * After a sucessful allocation and initialization the bus control must be - * destroyed via spi_bus_destroy_and_free(). A registered bus control will be - * automatically destroyed in case the device file is unlinked. Make sure to - * call spi_bus_destroy_and_free() in a custom destruction handler. - * - * @param[in] size The size of the bus control. This enables the addition of - * bus controller specific data to the base bus control. The bus control is - * zero initialized. - * - * @retval non-NULL The new bus control. - * @retval NULL An error occurred. The errno is set to indicate the error. - * - * @see spi_bus_register() - */ -spi_bus *spi_bus_alloc_and_init(size_t size); - -/** - * @brief Destroys a bus control. - * - * @param[in] bus The bus control. - */ -void spi_bus_destroy(spi_bus *bus); - -/** - * @brief Destroys a bus control and frees its memory. - * - * @param[in] bus The bus control. - */ -void spi_bus_destroy_and_free(spi_bus *bus); - -/** - * @brief Registers a bus control. - * - * This function claims ownership of the bus control regardless if the - * registration is successful or not. - * - * @param[in] bus The bus control. - * @param[in] bus_path The path to the bus device file. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The errno is set to indicate the error. - */ -int spi_bus_register( - spi_bus *bus, - const char *bus_path -); - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _DEV_SPI_SPI_H */ diff --git a/cpukit/dev/include/linux/i2c-dev.h b/cpukit/dev/include/linux/i2c-dev.h deleted file mode 100644 index c0db3fe06c..0000000000 --- a/cpukit/dev/include/linux/i2c-dev.h +++ /dev/null @@ -1,137 +0,0 @@ -/** - * @file - * - * @brief RTEMS Port of Linux I2C Device API - * - * @ingroup I2CLinux - */ - -/* - * Copyright (c) 2014 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _UAPI_LINUX_I2C_DEV_H -#define _UAPI_LINUX_I2C_DEV_H - -#include - -/** - * @addtogroup I2CLinux - * - * @{ - */ - -/** - * @name I2C IO Control Commands - * - * @{ - */ - -/** - * @brief Sets the count of transfer retries in case a slave - * device does not acknowledge a transaction. - * - * The argument type is unsigned long. - */ -#define I2C_RETRIES 0x701 - -/** - * @brief Sets the transfer timeout in 10ms units. - * - * The argument type is unsigned long. - */ -#define I2C_TIMEOUT 0x702 - -/** - * @brief Sets the slave address. - * - * It is an error to set a slave address already used by another slave device. - * - * The argument type is unsigned long. - */ -#define I2C_SLAVE 0x703 - -/** - * @brief Forces setting the slave address. - * - * The argument type is unsigned long. - */ -#define I2C_SLAVE_FORCE 0x706 - -/** - * @brief Enables 10-bit addresses if argument is non-zero, otherwise - * disables 10-bit addresses. - * - * The argument type is unsigned long. - */ -#define I2C_TENBIT 0x704 - -/** - * @brief Gets the I2C controller functionality information. - * - * The argument type is a pointer to an unsigned long. - */ -#define I2C_FUNCS 0x705 - -/** - * @brief Performs a combined read/write transfer. - * - * Only one stop condition is signalled. - * - * The argument type is a pointer to struct i2c_rdwr_ioctl_data. - */ -#define I2C_RDWR 0x707 - -/** - * @brief Enables System Management Bus (SMBus) Packet Error Checking (PEC) - * if argument is non-zero, otherwise disables PEC. - * - * The argument type is unsigned long. - */ -#define I2C_PEC 0x708 - -/** - * @brief Performs an SMBus transfer. - * - * The argument type is a pointer to struct i2c_smbus_ioctl_data. - */ -#define I2C_SMBUS 0x720 - -/** @} */ - -/** - * @brief Argument type for I2C_SMBUS IO control call. - */ -struct i2c_smbus_ioctl_data { - uint8_t read_write; - uint8_t command; - uint32_t size; - union i2c_smbus_data *data; -}; - -/** - * @brief Argument type for I2C_RDWR IO control call. - */ -struct i2c_rdwr_ioctl_data { - struct i2c_msg *msgs; - uint32_t nmsgs; -}; - -/** - * @brief Maximum count of messages for one IO control call. - */ -#define I2C_RDRW_IOCTL_MAX_MSGS 42 - -/** @} */ - -#endif /* _UAPI_LINUX_I2C_DEV_H */ diff --git a/cpukit/dev/include/linux/i2c.h b/cpukit/dev/include/linux/i2c.h deleted file mode 100644 index b113545cce..0000000000 --- a/cpukit/dev/include/linux/i2c.h +++ /dev/null @@ -1,275 +0,0 @@ -/** - * @file - * - * @brief RTEMS Port of Linux I2C API - * - * @ingroup I2CLinux - */ - -/* - * Copyright (c) 2014 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _UAPI_LINUX_I2C_H -#define _UAPI_LINUX_I2C_H - -#include - -/** - * @defgroup I2CLinux Linux I2C User-Space API - * - * @ingroup I2C - * - * @brief RTEMS port of Linux I2C user-space API. - * - * Additional documentation is available through the Linux sources, see: - * - * - /usr/src/linux/include/uapi/linux/i2c.h, - * - /usr/src/linux/include/uapi/linux/i2c-dev.h - * - https://www.kernel.org/doc/Documentation/i2c/i2c-protocol - * - https://www.kernel.org/doc/Documentation/i2c/dev-interface - * - * @{ - */ - -/** - * @name I2C Message Flags - * - * @{ - */ - -/** - * @brief I2C message flag to indicate a 10-bit address. - * - * The controller must support this as indicated by the I2C_FUNC_10BIT_ADDR - * functionality. - * - * @see i2c_msg. - */ -#define I2C_M_TEN 0x0010 - -/** - * @brief I2C message flag to indicate a read transfer (from slave to master). - * - * @see i2c_msg. - */ -#define I2C_M_RD 0x0001 - -/** - * @brief I2C message flag to signal a stop condition even if this is not the - * last message. - * - * The controller must support this as indicated by the - * @ref I2C_FUNC_PROTOCOL_MANGLING functionality. - * - * @see i2c_msg. - */ -#define I2C_M_STOP 0x8000 - -/** - * @brief I2C message flag to omit start condition and slave address. - * - * The controller must support this as indicated by the - * @ref I2C_FUNC_NOSTART functionality. - * - * @see i2c_msg. - */ -#define I2C_M_NOSTART 0x4000 - -/** - * @brief I2C message flag to reverse the direction flag. - * - * The controller must support this as indicated by the - * @ref I2C_FUNC_PROTOCOL_MANGLING functionality. - * - * @see i2c_msg. - */ -#define I2C_M_REV_DIR_ADDR 0x2000 - -/** - * @brief I2C message flag to ignore a non-acknowledge. - * - * The controller must support this as indicated by the - * @ref I2C_FUNC_PROTOCOL_MANGLING functionality. - * - * @see i2c_msg. - */ -#define I2C_M_IGNORE_NAK 0x1000 - -/** - * @brief I2C message flag to omit a master acknowledge/non-acknowledge in a - * read transfer. - * - * The controller must support this as indicated by the - * @ref I2C_FUNC_PROTOCOL_MANGLING functionality. - * - * @see i2c_msg. - */ -#define I2C_M_NO_RD_ACK 0x0800 - -/** - * @brief I2C message flag to indicate that the message data length is the - * first received byte. - * - * The message data buffer must be large enough to store up to 32 bytes, the - * initial length byte and the SMBus PEC (if used). Initialize the message - * length to one. The message length is incremented by the count of received - * data bytes. - * - * @see i2c_msg. - */ -#define I2C_M_RECV_LEN 0x0400 - -/** @} */ - -/** - * @brief I2C transfer message. - */ -struct i2c_msg { - /** - * @brief The slave address. - * - * In case the @ref I2C_M_TEN flag is set, then this is a 10-bit address, - * otherwise it is a 7-bit address. - */ - uint16_t addr; - - /** - * @brief The message flags. - * - * Valid flags are - * - @ref I2C_M_TEN, - * - @ref I2C_M_RD, - * - @ref I2C_M_STOP, - * - @ref I2C_M_NOSTART, - * - @ref I2C_M_REV_DIR_ADDR, - * - @ref I2C_M_IGNORE_NAK, - * - @ref I2C_M_NO_RD_ACK, and - * - @ref I2C_M_RECV_LEN. - */ - uint16_t flags; - - /** - * @brief The message data length in bytes. - */ - uint16_t len; - - /** - * @brief Pointer to the message data. - */ - uint8_t *buf; -}; - -/** - * @name I2C Controller Functionality - * - * @{ - */ - -#define I2C_FUNC_I2C 0x00000001 -#define I2C_FUNC_10BIT_ADDR 0x00000002 -#define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 -#define I2C_FUNC_SMBUS_PEC 0x00000008 -#define I2C_FUNC_NOSTART 0x00000010 -#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 -#define I2C_FUNC_SMBUS_QUICK 0x00010000 -#define I2C_FUNC_SMBUS_READ_BYTE 0x00020000 -#define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000 -#define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000 -#define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000 -#define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000 -#define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000 -#define I2C_FUNC_SMBUS_PROC_CALL 0x00800000 -#define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000 -#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000 -#define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 -#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 - -#define I2C_FUNC_SMBUS_BYTE \ - (I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE) - -#define I2C_FUNC_SMBUS_BYTE_DATA \ - (I2C_FUNC_SMBUS_READ_BYTE_DATA | I2C_FUNC_SMBUS_WRITE_BYTE_DATA) - -#define I2C_FUNC_SMBUS_WORD_DATA \ - (I2C_FUNC_SMBUS_READ_WORD_DATA | I2C_FUNC_SMBUS_WRITE_WORD_DATA) - -#define I2C_FUNC_SMBUS_BLOCK_DATA \ - (I2C_FUNC_SMBUS_READ_BLOCK_DATA | I2C_FUNC_SMBUS_WRITE_BLOCK_DATA) - -#define I2C_FUNC_SMBUS_I2C_BLOCK \ - (I2C_FUNC_SMBUS_READ_I2C_BLOCK | I2C_FUNC_SMBUS_WRITE_I2C_BLOCK) - -#define I2C_FUNC_SMBUS_EMUL \ - (I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA \ - | I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_PROC_CALL \ - | I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | I2C_FUNC_SMBUS_I2C_BLOCK \ - | I2C_FUNC_SMBUS_PEC) - -/** @} */ - -/** - * @brief Maximum SMBus data block count. - */ -#define I2C_SMBUS_BLOCK_MAX 32 - -/** - * @brief SMBus data. - */ -union i2c_smbus_data { - uint8_t byte; - uint16_t word; - uint8_t block[I2C_SMBUS_BLOCK_MAX + 2]; -}; - -/** - * @name SMBus Transfer Read and Write Markers - * - * @{ - */ - -#define I2C_SMBUS_READ 1 - -#define I2C_SMBUS_WRITE 0 - -/** @} */ - -/** - * @name SMBus Transaction Types - * - * @{ - */ - -#define I2C_SMBUS_QUICK 0 - -#define I2C_SMBUS_BYTE 1 - -#define I2C_SMBUS_BYTE_DATA 2 - -#define I2C_SMBUS_WORD_DATA 3 - -#define I2C_SMBUS_PROC_CALL 4 - -#define I2C_SMBUS_BLOCK_DATA 5 - -#define I2C_SMBUS_I2C_BLOCK_BROKEN 6 - -#define I2C_SMBUS_BLOCK_PROC_CALL 7 - -#define I2C_SMBUS_I2C_BLOCK_DATA 8 - -/** @} */ - -/** @} */ - -#endif /* _UAPI_LINUX_I2C_H */ diff --git a/cpukit/dev/include/linux/spi/spidev.h b/cpukit/dev/include/linux/spi/spidev.h deleted file mode 100644 index e2fdb4b7e1..0000000000 --- a/cpukit/dev/include/linux/spi/spidev.h +++ /dev/null @@ -1,268 +0,0 @@ -/** - * @file - * - * @brief RTEMS Port of Linux SPI API - * - * @ingroup SPILinux - */ - -/* - * Copyright (c) 2016 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _UAPI_LINUX_SPI_H -#define _UAPI_LINUX_SPI_H - -#include -#include -#include - -/** - * @defgroup SPILinux Linux SPI User-Space API - * - * @ingroup SPI - * - * @brief RTEMS port of Linux SPI user-space API. - * - * Additional documentation is available through the Linux sources, see - * - * /usr/src/linux/include/uapi/linux/spidev.h. - * - * @{ - */ - -/** - * @name SPI Transfer Flags - * - * @{ - */ - -/** - * @brief SPI transfer flag which sets the clock phase. - */ -#define SPI_CPHA 0x01 - -/** - * @brief SPI transfer flag which sets the clock polarity. - */ -#define SPI_CPOL 0x02 - -/** - * @brief SPI transfer flag which sets SPI Mode 0 (clock starts low, sample on - * leading edge). - */ -#define SPI_MODE_0 0 - -/** - * @brief SPI transfer flag which sets SPI Mode 0 (clock starts low, sample on - * trailing edge). - */ -#define SPI_MODE_1 SPI_CPHA - -/** - * @brief SPI transfer flag which sets SPI Mode 0 (clock starts high, sample on - * leading edge). - */ -#define SPI_MODE_2 SPI_CPOL - -/** - * @brief SPI transfer flag which sets SPI Mode 0 (clock starts high, sample on - * trailing edge). - */ -#define SPI_MODE_3 (SPI_CPOL | SPI_CPHA) - -/** - * @brief SPI transfer flag which selects the device by setting the chip select - * line. - */ -#define SPI_CS_HIGH 0x04 - -/** - * @brief SPI transfer flag which triggers data transmission with the LSB being - * sent first. - */ -#define SPI_LSB_FIRST 0x08 - -/** - * @brief SPI transfer flag which uses a shared wire for master input/slave - * output as well as master output/slave input. - */ -#define SPI_3WIRE 0x10 - -/** - * @brief SPI transfer flag which initiates the loopback mode. - */ -#define SPI_LOOP 0x20 - -/** - * @brief SPI transfer flag which indicates that no chip select is needed due to - * only one device on the bus. - */ -#define SPI_NO_CS 0x40 - -/** - * @brief SPI transfer flag which pulls the slave to low level during pause. - */ -#define SPI_READY 0x80 - -/** - * @brief SPI transfer flag which sets up dual mode for transmission. - */ -#define SPI_TX_DUAL 0x100 - -/** - * @brief SPI transfer flag which sets up quad mode for transmission. - */ -#define SPI_TX_QUAD 0x200 - -/** - * @brief SPI transfer flag which sets up dual mode for reception. - */ -#define SPI_RX_DUAL 0x400 - -/** - * @brief SPI transfer flag which sets up quad mode for reception. - */ -#define SPI_RX_QUAD 0x800 - -/** @} */ - -#define SPI_IOC_MAGIC 's' - -/** - * @brief SPI transfer message. - */ -struct spi_ioc_transfer { - /** - * @brief Buffer for receive data. - */ - void *rx_buf; - - /** - * @brief Buffer for transmit data. - */ - const void *tx_buf; - - /** - * @brief Length of receive and transmit buffers in bytes. - */ - size_t len; - - /** - * @brief Sets the bit-rate of the device. - */ - uint32_t speed_hz; - - /** - * @brief Sets the delay after a transfer before the chip select status is - * changed and the next transfer is triggered. - */ - uint16_t delay_usecs; - - /** - * @brief Sets the device wordsize. - */ - uint8_t bits_per_word; - - /** - * @brief If true, device is deselected after transfer ended and before a new - * transfer is started. - */ - uint8_t cs_change; - - /** - * @brief Amount of bits that are used for reading. - */ - uint8_t rx_nbits; - - /** - * @brief Amount of bits that are used for writing. - */ - uint8_t tx_nbits; - - /** - * @brief Sets one of the possible modes that can be used for SPI transfers - * (dependent on clock phase and polarity). - */ - uint32_t mode; - - /** - * @brief Indicates which device is currently used. - */ - uint8_t cs; -}; - -/** - * @brief Calculates the size of the SPI message array. - */ -#define SPI_MSGSIZE(n) \ - (((n) * sizeof(struct spi_ioc_transfer) < IOCPARM_MAX) ? \ - (n) * sizeof(struct spi_ioc_transfer) : 0) - -/** - * @brief Transfers an array with SPI messages. - */ -#define SPI_IOC_MESSAGE(n) _IOW(SPI_IOC_MAGIC, 0, char[SPI_MSGSIZE(n)]) - -/** - * @brief Reads the least-significant 8-bits of the SPI default mode. - */ -#define SPI_IOC_RD_MODE _IOR(SPI_IOC_MAGIC, 1, uint8_t) - -/** - * @brief Writes the SPI default mode (the most-significant 24-bits of the mode are - * set to zero). - */ -#define SPI_IOC_WR_MODE _IOW(SPI_IOC_MAGIC, 1, uint8_t) - -/** - * @brief Reads the SPI default least-significant bit first setting. - */ -#define SPI_IOC_RD_LSB_FIRST _IOR(SPI_IOC_MAGIC, 2, uint8_t) - -/** - * @brief Writes the SPI default least-significant-bit first setting. - */ -#define SPI_IOC_WR_LSB_FIRST _IOW(SPI_IOC_MAGIC, 2, uint8_t) - -/** - * @brief Reads the SPI default bits per word. - */ -#define SPI_IOC_RD_BITS_PER_WORD _IOR(SPI_IOC_MAGIC, 3, uint8_t) - -/** - * @brief Writes the SPI default bits per word. - */ -#define SPI_IOC_WR_BITS_PER_WORD _IOW(SPI_IOC_MAGIC, 3, uint8_t) - -/** - * @brief Reads the SPI default speed in Hz. - */ -#define SPI_IOC_RD_MAX_SPEED_HZ _IOR(SPI_IOC_MAGIC, 4, uint32_t) - -/** - * @brief Writes the SPI default speed in Hz. - */ -#define SPI_IOC_WR_MAX_SPEED_HZ _IOW(SPI_IOC_MAGIC, 4, uint32_t) - -/** - * @brief Reads the full 32-bit SPI default mode. - */ -#define SPI_IOC_RD_MODE32 _IOR(SPI_IOC_MAGIC, 5, uint32_t) - -/** - * @brief Writes the full 32-bit SPI default mode. - */ -#define SPI_IOC_WR_MODE32 _IOW(SPI_IOC_MAGIC, 5, uint32_t) - -#endif /* _UAPI_LINUX_SPI_H */ diff --git a/cpukit/dev/preinstall.am b/cpukit/dev/preinstall.am deleted file mode 100644 index 4cb1dce127..0000000000 --- a/cpukit/dev/preinstall.am +++ /dev/null @@ -1,105 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -$(PROJECT_INCLUDE)/dev/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/dev - @: > $(PROJECT_INCLUDE)/dev/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/dev/$(dirstamp) - -$(PROJECT_INCLUDE)/dev/i2c/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/dev/i2c - @: > $(PROJECT_INCLUDE)/dev/i2c/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/dev/i2c/$(dirstamp) - -$(PROJECT_INCLUDE)/dev/i2c/eeprom.h: include/dev/i2c/eeprom.h $(PROJECT_INCLUDE)/dev/i2c/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/dev/i2c/eeprom.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/dev/i2c/eeprom.h - -$(PROJECT_INCLUDE)/dev/i2c/fpga-i2c-slave.h: include/dev/i2c/fpga-i2c-slave.h $(PROJECT_INCLUDE)/dev/i2c/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/dev/i2c/fpga-i2c-slave.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/dev/i2c/fpga-i2c-slave.h - -$(PROJECT_INCLUDE)/dev/i2c/gpio-nxp-pca9535.h: include/dev/i2c/gpio-nxp-pca9535.h $(PROJECT_INCLUDE)/dev/i2c/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/dev/i2c/gpio-nxp-pca9535.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/dev/i2c/gpio-nxp-pca9535.h - -$(PROJECT_INCLUDE)/dev/i2c/i2c.h: include/dev/i2c/i2c.h $(PROJECT_INCLUDE)/dev/i2c/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/dev/i2c/i2c.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/dev/i2c/i2c.h - -$(PROJECT_INCLUDE)/dev/i2c/sensor-lm75a.h: include/dev/i2c/sensor-lm75a.h $(PROJECT_INCLUDE)/dev/i2c/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/dev/i2c/sensor-lm75a.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/dev/i2c/sensor-lm75a.h - -$(PROJECT_INCLUDE)/dev/i2c/switch-nxp-pca9548a.h: include/dev/i2c/switch-nxp-pca9548a.h $(PROJECT_INCLUDE)/dev/i2c/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/dev/i2c/switch-nxp-pca9548a.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/dev/i2c/switch-nxp-pca9548a.h - -$(PROJECT_INCLUDE)/dev/i2c/xilinx-axi-i2c.h: include/dev/i2c/xilinx-axi-i2c.h $(PROJECT_INCLUDE)/dev/i2c/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/dev/i2c/xilinx-axi-i2c.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/dev/i2c/xilinx-axi-i2c.h - -$(PROJECT_INCLUDE)/dev/i2c/ti-ads-16bit-adc.h: include/dev/i2c/ti-ads-16bit-adc.h $(PROJECT_INCLUDE)/dev/i2c/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/dev/i2c/ti-ads-16bit-adc.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/dev/i2c/ti-ads-16bit-adc.h - -$(PROJECT_INCLUDE)/dev/i2c/ti-lm25066a.h: include/dev/i2c/ti-lm25066a.h $(PROJECT_INCLUDE)/dev/i2c/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/dev/i2c/ti-lm25066a.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/dev/i2c/ti-lm25066a.h - -$(PROJECT_INCLUDE)/dev/i2c/ti-tmp112.h: include/dev/i2c/ti-tmp112.h $(PROJECT_INCLUDE)/dev/i2c/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/dev/i2c/ti-tmp112.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/dev/i2c/ti-tmp112.h - -$(PROJECT_INCLUDE)/dev/spi/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/dev/spi - @: > $(PROJECT_INCLUDE)/dev/spi/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/dev/spi/$(dirstamp) - -$(PROJECT_INCLUDE)/dev/spi/spi.h: include/dev/spi/spi.h $(PROJECT_INCLUDE)/dev/spi/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/dev/spi/spi.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/dev/spi/spi.h - -$(PROJECT_INCLUDE)/dev/serial/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/dev/serial - @: > $(PROJECT_INCLUDE)/dev/serial/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/dev/serial/$(dirstamp) - -$(PROJECT_INCLUDE)/dev/serial/sc16is752.h: include/dev/serial/sc16is752.h $(PROJECT_INCLUDE)/dev/serial/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/dev/serial/sc16is752.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/dev/serial/sc16is752.h - -$(PROJECT_INCLUDE)/linux/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/linux - @: > $(PROJECT_INCLUDE)/linux/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/linux/$(dirstamp) - -$(PROJECT_INCLUDE)/linux/i2c.h: include/linux/i2c.h $(PROJECT_INCLUDE)/linux/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/linux/i2c.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/linux/i2c.h - -$(PROJECT_INCLUDE)/linux/i2c-dev.h: include/linux/i2c-dev.h $(PROJECT_INCLUDE)/linux/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/linux/i2c-dev.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/linux/i2c-dev.h - -$(PROJECT_INCLUDE)/linux/spi/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/linux/spi - @: > $(PROJECT_INCLUDE)/linux/spi/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/linux/spi/$(dirstamp) - -$(PROJECT_INCLUDE)/linux/spi/spidev.h: include/linux/spi/spidev.h $(PROJECT_INCLUDE)/linux/spi/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/linux/spi/spidev.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/linux/spi/spidev.h - diff --git a/cpukit/dtc/libfdt/Makefile.am b/cpukit/dtc/libfdt/Makefile.am index 687d226f0f..0782303891 100644 --- a/cpukit/dtc/libfdt/Makefile.am +++ b/cpukit/dtc/libfdt/Makefile.am @@ -1,7 +1,5 @@ include $(top_srcdir)/automake/compile.am -include_HEADERS = fdt.h libfdt.h libfdt_env.h - noinst_LIBRARIES = libfdt.a libfdt_a_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir) @@ -15,5 +13,4 @@ libfdt_a_SOURCES += fdt_strerror.c libfdt_a_SOURCES += fdt_sw.c libfdt_a_SOURCES += fdt_wip.c -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am diff --git a/cpukit/dtc/libfdt/fdt.h b/cpukit/dtc/libfdt/fdt.h deleted file mode 100644 index 526aedb515..0000000000 --- a/cpukit/dtc/libfdt/fdt.h +++ /dev/null @@ -1,111 +0,0 @@ -#ifndef _FDT_H -#define _FDT_H -/* - * libfdt - Flat Device Tree manipulation - * Copyright (C) 2006 David Gibson, IBM Corporation. - * Copyright 2012 Kim Phillips, Freescale Semiconductor. - * - * libfdt is dual licensed: you can use it either under the terms of - * the GPL, or the BSD license, at your option. - * - * a) This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, - * MA 02110-1301 USA - * - * Alternatively, - * - * b) Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __ASSEMBLY__ - -struct fdt_header { - fdt32_t magic; /* magic word FDT_MAGIC */ - fdt32_t totalsize; /* total size of DT block */ - fdt32_t off_dt_struct; /* offset to structure */ - fdt32_t off_dt_strings; /* offset to strings */ - fdt32_t off_mem_rsvmap; /* offset to memory reserve map */ - fdt32_t version; /* format version */ - fdt32_t last_comp_version; /* last compatible version */ - - /* version 2 fields below */ - fdt32_t boot_cpuid_phys; /* Which physical CPU id we're - booting on */ - /* version 3 fields below */ - fdt32_t size_dt_strings; /* size of the strings block */ - - /* version 17 fields below */ - fdt32_t size_dt_struct; /* size of the structure block */ -}; - -struct fdt_reserve_entry { - fdt64_t address; - fdt64_t size; -}; - -struct fdt_node_header { - fdt32_t tag; - char name[0]; -}; - -struct fdt_property { - fdt32_t tag; - fdt32_t len; - fdt32_t nameoff; - char data[0]; -}; - -#endif /* !__ASSEMBLY */ - -#define FDT_MAGIC 0xd00dfeed /* 4: version, 4: total size */ -#define FDT_TAGSIZE sizeof(fdt32_t) - -#define FDT_BEGIN_NODE 0x1 /* Start node: full name */ -#define FDT_END_NODE 0x2 /* End node */ -#define FDT_PROP 0x3 /* Property: name off, - size, content */ -#define FDT_NOP 0x4 /* nop */ -#define FDT_END 0x9 - -#define FDT_V1_SIZE (7*sizeof(fdt32_t)) -#define FDT_V2_SIZE (FDT_V1_SIZE + sizeof(fdt32_t)) -#define FDT_V3_SIZE (FDT_V2_SIZE + sizeof(fdt32_t)) -#define FDT_V16_SIZE FDT_V3_SIZE -#define FDT_V17_SIZE (FDT_V16_SIZE + sizeof(fdt32_t)) - -#endif /* _FDT_H */ diff --git a/cpukit/dtc/libfdt/libfdt.h b/cpukit/dtc/libfdt/libfdt.h deleted file mode 100644 index 78adb1232e..0000000000 --- a/cpukit/dtc/libfdt/libfdt.h +++ /dev/null @@ -1,1653 +0,0 @@ -#ifndef _LIBFDT_H -#define _LIBFDT_H -/* - * libfdt - Flat Device Tree manipulation - * Copyright (C) 2006 David Gibson, IBM Corporation. - * - * libfdt is dual licensed: you can use it either under the terms of - * the GPL, or the BSD license, at your option. - * - * a) This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, - * MA 02110-1301 USA - * - * Alternatively, - * - * b) Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include - -#define FDT_FIRST_SUPPORTED_VERSION 0x10 -#define FDT_LAST_SUPPORTED_VERSION 0x11 - -/* Error codes: informative error codes */ -#define FDT_ERR_NOTFOUND 1 - /* FDT_ERR_NOTFOUND: The requested node or property does not exist */ -#define FDT_ERR_EXISTS 2 - /* FDT_ERR_EXISTS: Attemped to create a node or property which - * already exists */ -#define FDT_ERR_NOSPACE 3 - /* FDT_ERR_NOSPACE: Operation needed to expand the device - * tree, but its buffer did not have sufficient space to - * contain the expanded tree. Use fdt_open_into() to move the - * device tree to a buffer with more space. */ - -/* Error codes: codes for bad parameters */ -#define FDT_ERR_BADOFFSET 4 - /* FDT_ERR_BADOFFSET: Function was passed a structure block - * offset which is out-of-bounds, or which points to an - * unsuitable part of the structure for the operation. */ -#define FDT_ERR_BADPATH 5 - /* FDT_ERR_BADPATH: Function was passed a badly formatted path - * (e.g. missing a leading / for a function which requires an - * absolute path) */ -#define FDT_ERR_BADPHANDLE 6 - /* FDT_ERR_BADPHANDLE: Function was passed an invalid phandle - * value. phandle values of 0 and -1 are not permitted. */ -#define FDT_ERR_BADSTATE 7 - /* FDT_ERR_BADSTATE: Function was passed an incomplete device - * tree created by the sequential-write functions, which is - * not sufficiently complete for the requested operation. */ - -/* Error codes: codes for bad device tree blobs */ -#define FDT_ERR_TRUNCATED 8 - /* FDT_ERR_TRUNCATED: Structure block of the given device tree - * ends without an FDT_END tag. */ -#define FDT_ERR_BADMAGIC 9 - /* FDT_ERR_BADMAGIC: Given "device tree" appears not to be a - * device tree at all - it is missing the flattened device - * tree magic number. */ -#define FDT_ERR_BADVERSION 10 - /* FDT_ERR_BADVERSION: Given device tree has a version which - * can't be handled by the requested operation. For - * read-write functions, this may mean that fdt_open_into() is - * required to convert the tree to the expected version. */ -#define FDT_ERR_BADSTRUCTURE 11 - /* FDT_ERR_BADSTRUCTURE: Given device tree has a corrupt - * structure block or other serious error (e.g. misnested - * nodes, or subnodes preceding properties). */ -#define FDT_ERR_BADLAYOUT 12 - /* FDT_ERR_BADLAYOUT: For read-write functions, the given - * device tree has it's sub-blocks in an order that the - * function can't handle (memory reserve map, then structure, - * then strings). Use fdt_open_into() to reorganize the tree - * into a form suitable for the read-write operations. */ - -/* "Can't happen" error indicating a bug in libfdt */ -#define FDT_ERR_INTERNAL 13 - /* FDT_ERR_INTERNAL: libfdt has failed an internal assertion. - * Should never be returned, if it is, it indicates a bug in - * libfdt itself. */ - -/* Errors in device tree content */ -#define FDT_ERR_BADNCELLS 14 - /* FDT_ERR_BADNCELLS: Device tree has a #address-cells, #size-cells - * or similar property with a bad format or value */ - -#define FDT_ERR_BADVALUE 15 - /* FDT_ERR_BADVALUE: Device tree has a property with an unexpected - * value. For example: a property expected to contain a string list - * is not NUL-terminated within the length of its value. */ - -#define FDT_ERR_MAX 15 - -/**********************************************************************/ -/* Low-level functions (you probably don't need these) */ -/**********************************************************************/ - -const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int checklen); -static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen) -{ - return (void *)(uintptr_t)fdt_offset_ptr(fdt, offset, checklen); -} - -uint32_t fdt_next_tag(const void *fdt, int offset, int *nextoffset); - -/**********************************************************************/ -/* Traversal functions */ -/**********************************************************************/ - -int fdt_next_node(const void *fdt, int offset, int *depth); - -/** - * fdt_first_subnode() - get offset of first direct subnode - * - * @fdt: FDT blob - * @offset: Offset of node to check - * @return offset of first subnode, or -FDT_ERR_NOTFOUND if there is none - */ -int fdt_first_subnode(const void *fdt, int offset); - -/** - * fdt_next_subnode() - get offset of next direct subnode - * - * After first calling fdt_first_subnode(), call this function repeatedly to - * get direct subnodes of a parent node. - * - * @fdt: FDT blob - * @offset: Offset of previous subnode - * @return offset of next subnode, or -FDT_ERR_NOTFOUND if there are no more - * subnodes - */ -int fdt_next_subnode(const void *fdt, int offset); - -/**********************************************************************/ -/* General functions */ -/**********************************************************************/ - -#define fdt_get_header(fdt, field) \ - (fdt32_to_cpu(((const struct fdt_header *)(fdt))->field)) -#define fdt_magic(fdt) (fdt_get_header(fdt, magic)) -#define fdt_totalsize(fdt) (fdt_get_header(fdt, totalsize)) -#define fdt_off_dt_struct(fdt) (fdt_get_header(fdt, off_dt_struct)) -#define fdt_off_dt_strings(fdt) (fdt_get_header(fdt, off_dt_strings)) -#define fdt_off_mem_rsvmap(fdt) (fdt_get_header(fdt, off_mem_rsvmap)) -#define fdt_version(fdt) (fdt_get_header(fdt, version)) -#define fdt_last_comp_version(fdt) (fdt_get_header(fdt, last_comp_version)) -#define fdt_boot_cpuid_phys(fdt) (fdt_get_header(fdt, boot_cpuid_phys)) -#define fdt_size_dt_strings(fdt) (fdt_get_header(fdt, size_dt_strings)) -#define fdt_size_dt_struct(fdt) (fdt_get_header(fdt, size_dt_struct)) - -#define __fdt_set_hdr(name) \ - static inline void fdt_set_##name(void *fdt, uint32_t val) \ - { \ - struct fdt_header *fdth = (struct fdt_header*)fdt; \ - fdth->name = cpu_to_fdt32(val); \ - } -__fdt_set_hdr(magic); -__fdt_set_hdr(totalsize); -__fdt_set_hdr(off_dt_struct); -__fdt_set_hdr(off_dt_strings); -__fdt_set_hdr(off_mem_rsvmap); -__fdt_set_hdr(version); -__fdt_set_hdr(last_comp_version); -__fdt_set_hdr(boot_cpuid_phys); -__fdt_set_hdr(size_dt_strings); -__fdt_set_hdr(size_dt_struct); -#undef __fdt_set_hdr - -/** - * fdt_check_header - sanity check a device tree or possible device tree - * @fdt: pointer to data which might be a flattened device tree - * - * fdt_check_header() checks that the given buffer contains what - * appears to be a flattened device tree with sane information in its - * header. - * - * returns: - * 0, if the buffer appears to contain a valid device tree - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, standard meanings, as above - */ -int fdt_check_header(const void *fdt); - -/** - * fdt_move - move a device tree around in memory - * @fdt: pointer to the device tree to move - * @buf: pointer to memory where the device is to be moved - * @bufsize: size of the memory space at buf - * - * fdt_move() relocates, if possible, the device tree blob located at - * fdt to the buffer at buf of size bufsize. The buffer may overlap - * with the existing device tree blob at fdt. Therefore, - * fdt_move(fdt, fdt, fdt_totalsize(fdt)) - * should always succeed. - * - * returns: - * 0, on success - * -FDT_ERR_NOSPACE, bufsize is insufficient to contain the device tree - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, standard meanings - */ -int fdt_move(const void *fdt, void *buf, int bufsize); - -/**********************************************************************/ -/* Read-only functions */ -/**********************************************************************/ - -/** - * fdt_string - retrieve a string from the strings block of a device tree - * @fdt: pointer to the device tree blob - * @stroffset: offset of the string within the strings block (native endian) - * - * fdt_string() retrieves a pointer to a single string from the - * strings block of the device tree blob at fdt. - * - * returns: - * a pointer to the string, on success - * NULL, if stroffset is out of bounds - */ -const char *fdt_string(const void *fdt, int stroffset); - -/** - * fdt_num_mem_rsv - retrieve the number of memory reserve map entries - * @fdt: pointer to the device tree blob - * - * Returns the number of entries in the device tree blob's memory - * reservation map. This does not include the terminating 0,0 entry - * or any other (0,0) entries reserved for expansion. - * - * returns: - * the number of entries - */ -int fdt_num_mem_rsv(const void *fdt); - -/** - * fdt_get_mem_rsv - retrieve one memory reserve map entry - * @fdt: pointer to the device tree blob - * @address, @size: pointers to 64-bit variables - * - * On success, *address and *size will contain the address and size of - * the n-th reserve map entry from the device tree blob, in - * native-endian format. - * - * returns: - * 0, on success - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, standard meanings - */ -int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size); - -/** - * fdt_subnode_offset_namelen - find a subnode based on substring - * @fdt: pointer to the device tree blob - * @parentoffset: structure block offset of a node - * @name: name of the subnode to locate - * @namelen: number of characters of name to consider - * - * Identical to fdt_subnode_offset(), but only examine the first - * namelen characters of name for matching the subnode name. This is - * useful for finding subnodes based on a portion of a larger string, - * such as a full path. - */ -int fdt_subnode_offset_namelen(const void *fdt, int parentoffset, - const char *name, int namelen); -/** - * fdt_subnode_offset - find a subnode of a given node - * @fdt: pointer to the device tree blob - * @parentoffset: structure block offset of a node - * @name: name of the subnode to locate - * - * fdt_subnode_offset() finds a subnode of the node at structure block - * offset parentoffset with the given name. name may include a unit - * address, in which case fdt_subnode_offset() will find the subnode - * with that unit address, or the unit address may be omitted, in - * which case fdt_subnode_offset() will find an arbitrary subnode - * whose name excluding unit address matches the given name. - * - * returns: - * structure block offset of the requested subnode (>=0), on success - * -FDT_ERR_NOTFOUND, if the requested subnode does not exist - * -FDT_ERR_BADOFFSET, if parentoffset did not point to an FDT_BEGIN_NODE tag - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, - * -FDT_ERR_TRUNCATED, standard meanings. - */ -int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name); - -/** - * fdt_path_offset_namelen - find a tree node by its full path - * @fdt: pointer to the device tree blob - * @path: full path of the node to locate - * @namelen: number of characters of path to consider - * - * Identical to fdt_path_offset(), but only consider the first namelen - * characters of path as the path name. - */ -int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen); - -/** - * fdt_path_offset - find a tree node by its full path - * @fdt: pointer to the device tree blob - * @path: full path of the node to locate - * - * fdt_path_offset() finds a node of a given path in the device tree. - * Each path component may omit the unit address portion, but the - * results of this are undefined if any such path component is - * ambiguous (that is if there are multiple nodes at the relevant - * level matching the given component, differentiated only by unit - * address). - * - * returns: - * structure block offset of the node with the requested path (>=0), on success - * -FDT_ERR_BADPATH, given path does not begin with '/' or is invalid - * -FDT_ERR_NOTFOUND, if the requested node does not exist - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, - * -FDT_ERR_TRUNCATED, standard meanings. - */ -int fdt_path_offset(const void *fdt, const char *path); - -/** - * fdt_get_name - retrieve the name of a given node - * @fdt: pointer to the device tree blob - * @nodeoffset: structure block offset of the starting node - * @lenp: pointer to an integer variable (will be overwritten) or NULL - * - * fdt_get_name() retrieves the name (including unit address) of the - * device tree node at structure block offset nodeoffset. If lenp is - * non-NULL, the length of this name is also returned, in the integer - * pointed to by lenp. - * - * returns: - * pointer to the node's name, on success - * If lenp is non-NULL, *lenp contains the length of that name (>=0) - * NULL, on error - * if lenp is non-NULL *lenp contains an error code (<0): - * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, standard meanings - */ -const char *fdt_get_name(const void *fdt, int nodeoffset, int *lenp); - -/** - * fdt_first_property_offset - find the offset of a node's first property - * @fdt: pointer to the device tree blob - * @nodeoffset: structure block offset of a node - * - * fdt_first_property_offset() finds the first property of the node at - * the given structure block offset. - * - * returns: - * structure block offset of the property (>=0), on success - * -FDT_ERR_NOTFOUND, if the requested node has no properties - * -FDT_ERR_BADOFFSET, if nodeoffset did not point to an FDT_BEGIN_NODE tag - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, - * -FDT_ERR_TRUNCATED, standard meanings. - */ -int fdt_first_property_offset(const void *fdt, int nodeoffset); - -/** - * fdt_next_property_offset - step through a node's properties - * @fdt: pointer to the device tree blob - * @offset: structure block offset of a property - * - * fdt_next_property_offset() finds the property immediately after the - * one at the given structure block offset. This will be a property - * of the same node as the given property. - * - * returns: - * structure block offset of the next property (>=0), on success - * -FDT_ERR_NOTFOUND, if the given property is the last in its node - * -FDT_ERR_BADOFFSET, if nodeoffset did not point to an FDT_PROP tag - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, - * -FDT_ERR_TRUNCATED, standard meanings. - */ -int fdt_next_property_offset(const void *fdt, int offset); - -/** - * fdt_get_property_by_offset - retrieve the property at a given offset - * @fdt: pointer to the device tree blob - * @offset: offset of the property to retrieve - * @lenp: pointer to an integer variable (will be overwritten) or NULL - * - * fdt_get_property_by_offset() retrieves a pointer to the - * fdt_property structure within the device tree blob at the given - * offset. If lenp is non-NULL, the length of the property value is - * also returned, in the integer pointed to by lenp. - * - * returns: - * pointer to the structure representing the property - * if lenp is non-NULL, *lenp contains the length of the property - * value (>=0) - * NULL, on error - * if lenp is non-NULL, *lenp contains an error code (<0): - * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_PROP tag - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, - * -FDT_ERR_TRUNCATED, standard meanings - */ -const struct fdt_property *fdt_get_property_by_offset(const void *fdt, - int offset, - int *lenp); - -/** - * fdt_get_property_namelen - find a property based on substring - * @fdt: pointer to the device tree blob - * @nodeoffset: offset of the node whose property to find - * @name: name of the property to find - * @namelen: number of characters of name to consider - * @lenp: pointer to an integer variable (will be overwritten) or NULL - * - * Identical to fdt_get_property(), but only examine the first namelen - * characters of name for matching the property name. - */ -const struct fdt_property *fdt_get_property_namelen(const void *fdt, - int nodeoffset, - const char *name, - int namelen, int *lenp); - -/** - * fdt_get_property - find a given property in a given node - * @fdt: pointer to the device tree blob - * @nodeoffset: offset of the node whose property to find - * @name: name of the property to find - * @lenp: pointer to an integer variable (will be overwritten) or NULL - * - * fdt_get_property() retrieves a pointer to the fdt_property - * structure within the device tree blob corresponding to the property - * named 'name' of the node at offset nodeoffset. If lenp is - * non-NULL, the length of the property value is also returned, in the - * integer pointed to by lenp. - * - * returns: - * pointer to the structure representing the property - * if lenp is non-NULL, *lenp contains the length of the property - * value (>=0) - * NULL, on error - * if lenp is non-NULL, *lenp contains an error code (<0): - * -FDT_ERR_NOTFOUND, node does not have named property - * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, - * -FDT_ERR_TRUNCATED, standard meanings - */ -const struct fdt_property *fdt_get_property(const void *fdt, int nodeoffset, - const char *name, int *lenp); -static inline struct fdt_property *fdt_get_property_w(void *fdt, int nodeoffset, - const char *name, - int *lenp) -{ - return (struct fdt_property *)(uintptr_t) - fdt_get_property(fdt, nodeoffset, name, lenp); -} - -/** - * fdt_getprop_by_offset - retrieve the value of a property at a given offset - * @fdt: pointer to the device tree blob - * @ffset: offset of the property to read - * @namep: pointer to a string variable (will be overwritten) or NULL - * @lenp: pointer to an integer variable (will be overwritten) or NULL - * - * fdt_getprop_by_offset() retrieves a pointer to the value of the - * property at structure block offset 'offset' (this will be a pointer - * to within the device blob itself, not a copy of the value). If - * lenp is non-NULL, the length of the property value is also - * returned, in the integer pointed to by lenp. If namep is non-NULL, - * the property's namne will also be returned in the char * pointed to - * by namep (this will be a pointer to within the device tree's string - * block, not a new copy of the name). - * - * returns: - * pointer to the property's value - * if lenp is non-NULL, *lenp contains the length of the property - * value (>=0) - * if namep is non-NULL *namep contiains a pointer to the property - * name. - * NULL, on error - * if lenp is non-NULL, *lenp contains an error code (<0): - * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_PROP tag - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, - * -FDT_ERR_TRUNCATED, standard meanings - */ -const void *fdt_getprop_by_offset(const void *fdt, int offset, - const char **namep, int *lenp); - -/** - * fdt_getprop_namelen - get property value based on substring - * @fdt: pointer to the device tree blob - * @nodeoffset: offset of the node whose property to find - * @name: name of the property to find - * @namelen: number of characters of name to consider - * @lenp: pointer to an integer variable (will be overwritten) or NULL - * - * Identical to fdt_getprop(), but only examine the first namelen - * characters of name for matching the property name. - */ -const void *fdt_getprop_namelen(const void *fdt, int nodeoffset, - const char *name, int namelen, int *lenp); - -/** - * fdt_getprop - retrieve the value of a given property - * @fdt: pointer to the device tree blob - * @nodeoffset: offset of the node whose property to find - * @name: name of the property to find - * @lenp: pointer to an integer variable (will be overwritten) or NULL - * - * fdt_getprop() retrieves a pointer to the value of the property - * named 'name' of the node at offset nodeoffset (this will be a - * pointer to within the device blob itself, not a copy of the value). - * If lenp is non-NULL, the length of the property value is also - * returned, in the integer pointed to by lenp. - * - * returns: - * pointer to the property's value - * if lenp is non-NULL, *lenp contains the length of the property - * value (>=0) - * NULL, on error - * if lenp is non-NULL, *lenp contains an error code (<0): - * -FDT_ERR_NOTFOUND, node does not have named property - * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, - * -FDT_ERR_TRUNCATED, standard meanings - */ -const void *fdt_getprop(const void *fdt, int nodeoffset, - const char *name, int *lenp); -static inline void *fdt_getprop_w(void *fdt, int nodeoffset, - const char *name, int *lenp) -{ - return (void *)(uintptr_t)fdt_getprop(fdt, nodeoffset, name, lenp); -} - -/** - * fdt_get_phandle - retrieve the phandle of a given node - * @fdt: pointer to the device tree blob - * @nodeoffset: structure block offset of the node - * - * fdt_get_phandle() retrieves the phandle of the device tree node at - * structure block offset nodeoffset. - * - * returns: - * the phandle of the node at nodeoffset, on success (!= 0, != -1) - * 0, if the node has no phandle, or another error occurs - */ -uint32_t fdt_get_phandle(const void *fdt, int nodeoffset); - -/** - * fdt_get_alias_namelen - get alias based on substring - * @fdt: pointer to the device tree blob - * @name: name of the alias th look up - * @namelen: number of characters of name to consider - * - * Identical to fdt_get_alias(), but only examine the first namelen - * characters of name for matching the alias name. - */ -const char *fdt_get_alias_namelen(const void *fdt, - const char *name, int namelen); - -/** - * fdt_get_alias - retreive the path referenced by a given alias - * @fdt: pointer to the device tree blob - * @name: name of the alias th look up - * - * fdt_get_alias() retrieves the value of a given alias. That is, the - * value of the property named 'name' in the node /aliases. - * - * returns: - * a pointer to the expansion of the alias named 'name', if it exists - * NULL, if the given alias or the /aliases node does not exist - */ -const char *fdt_get_alias(const void *fdt, const char *name); - -/** - * fdt_get_path - determine the full path of a node - * @fdt: pointer to the device tree blob - * @nodeoffset: offset of the node whose path to find - * @buf: character buffer to contain the returned path (will be overwritten) - * @buflen: size of the character buffer at buf - * - * fdt_get_path() computes the full path of the node at offset - * nodeoffset, and records that path in the buffer at buf. - * - * NOTE: This function is expensive, as it must scan the device tree - * structure from the start to nodeoffset. - * - * returns: - * 0, on success - * buf contains the absolute path of the node at - * nodeoffset, as a NUL-terminated string. - * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag - * -FDT_ERR_NOSPACE, the path of the given node is longer than (bufsize-1) - * characters and will not fit in the given buffer. - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, standard meanings - */ -int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen); - -/** - * fdt_supernode_atdepth_offset - find a specific ancestor of a node - * @fdt: pointer to the device tree blob - * @nodeoffset: offset of the node whose parent to find - * @supernodedepth: depth of the ancestor to find - * @nodedepth: pointer to an integer variable (will be overwritten) or NULL - * - * fdt_supernode_atdepth_offset() finds an ancestor of the given node - * at a specific depth from the root (where the root itself has depth - * 0, its immediate subnodes depth 1 and so forth). So - * fdt_supernode_atdepth_offset(fdt, nodeoffset, 0, NULL); - * will always return 0, the offset of the root node. If the node at - * nodeoffset has depth D, then: - * fdt_supernode_atdepth_offset(fdt, nodeoffset, D, NULL); - * will return nodeoffset itself. - * - * NOTE: This function is expensive, as it must scan the device tree - * structure from the start to nodeoffset. - * - * returns: - - * structure block offset of the node at node offset's ancestor - * of depth supernodedepth (>=0), on success - * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag -* -FDT_ERR_NOTFOUND, supernodedepth was greater than the depth of nodeoffset - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, standard meanings - */ -int fdt_supernode_atdepth_offset(const void *fdt, int nodeoffset, - int supernodedepth, int *nodedepth); - -/** - * fdt_node_depth - find the depth of a given node - * @fdt: pointer to the device tree blob - * @nodeoffset: offset of the node whose parent to find - * - * fdt_node_depth() finds the depth of a given node. The root node - * has depth 0, its immediate subnodes depth 1 and so forth. - * - * NOTE: This function is expensive, as it must scan the device tree - * structure from the start to nodeoffset. - * - * returns: - * depth of the node at nodeoffset (>=0), on success - * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, standard meanings - */ -int fdt_node_depth(const void *fdt, int nodeoffset); - -/** - * fdt_parent_offset - find the parent of a given node - * @fdt: pointer to the device tree blob - * @nodeoffset: offset of the node whose parent to find - * - * fdt_parent_offset() locates the parent node of a given node (that - * is, it finds the offset of the node which contains the node at - * nodeoffset as a subnode). - * - * NOTE: This function is expensive, as it must scan the device tree - * structure from the start to nodeoffset, *twice*. - * - * returns: - * structure block offset of the parent of the node at nodeoffset - * (>=0), on success - * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, standard meanings - */ -int fdt_parent_offset(const void *fdt, int nodeoffset); - -/** - * fdt_node_offset_by_prop_value - find nodes with a given property value - * @fdt: pointer to the device tree blob - * @startoffset: only find nodes after this offset - * @propname: property name to check - * @propval: property value to search for - * @proplen: length of the value in propval - * - * fdt_node_offset_by_prop_value() returns the offset of the first - * node after startoffset, which has a property named propname whose - * value is of length proplen and has value equal to propval; or if - * startoffset is -1, the very first such node in the tree. - * - * To iterate through all nodes matching the criterion, the following - * idiom can be used: - * offset = fdt_node_offset_by_prop_value(fdt, -1, propname, - * propval, proplen); - * while (offset != -FDT_ERR_NOTFOUND) { - * // other code here - * offset = fdt_node_offset_by_prop_value(fdt, offset, propname, - * propval, proplen); - * } - * - * Note the -1 in the first call to the function, if 0 is used here - * instead, the function will never locate the root node, even if it - * matches the criterion. - * - * returns: - * structure block offset of the located node (>= 0, >startoffset), - * on success - * -FDT_ERR_NOTFOUND, no node matching the criterion exists in the - * tree after startoffset - * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, standard meanings - */ -int fdt_node_offset_by_prop_value(const void *fdt, int startoffset, - const char *propname, - const void *propval, int proplen); - -/** - * fdt_node_offset_by_phandle - find the node with a given phandle - * @fdt: pointer to the device tree blob - * @phandle: phandle value - * - * fdt_node_offset_by_phandle() returns the offset of the node - * which has the given phandle value. If there is more than one node - * in the tree with the given phandle (an invalid tree), results are - * undefined. - * - * returns: - * structure block offset of the located node (>= 0), on success - * -FDT_ERR_NOTFOUND, no node with that phandle exists - * -FDT_ERR_BADPHANDLE, given phandle value was invalid (0 or -1) - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, standard meanings - */ -int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle); - -/** - * fdt_node_check_compatible: check a node's compatible property - * @fdt: pointer to the device tree blob - * @nodeoffset: offset of a tree node - * @compatible: string to match against - * - * - * fdt_node_check_compatible() returns 0 if the given node contains a - * 'compatible' property with the given string as one of its elements, - * it returns non-zero otherwise, or on error. - * - * returns: - * 0, if the node has a 'compatible' property listing the given string - * 1, if the node has a 'compatible' property, but it does not list - * the given string - * -FDT_ERR_NOTFOUND, if the given node has no 'compatible' property - * -FDT_ERR_BADOFFSET, if nodeoffset does not refer to a BEGIN_NODE tag - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, standard meanings - */ -int fdt_node_check_compatible(const void *fdt, int nodeoffset, - const char *compatible); - -/** - * fdt_node_offset_by_compatible - find nodes with a given 'compatible' value - * @fdt: pointer to the device tree blob - * @startoffset: only find nodes after this offset - * @compatible: 'compatible' string to match against - * - * fdt_node_offset_by_compatible() returns the offset of the first - * node after startoffset, which has a 'compatible' property which - * lists the given compatible string; or if startoffset is -1, the - * very first such node in the tree. - * - * To iterate through all nodes matching the criterion, the following - * idiom can be used: - * offset = fdt_node_offset_by_compatible(fdt, -1, compatible); - * while (offset != -FDT_ERR_NOTFOUND) { - * // other code here - * offset = fdt_node_offset_by_compatible(fdt, offset, compatible); - * } - * - * Note the -1 in the first call to the function, if 0 is used here - * instead, the function will never locate the root node, even if it - * matches the criterion. - * - * returns: - * structure block offset of the located node (>= 0, >startoffset), - * on success - * -FDT_ERR_NOTFOUND, no node matching the criterion exists in the - * tree after startoffset - * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, standard meanings - */ -int fdt_node_offset_by_compatible(const void *fdt, int startoffset, - const char *compatible); - -/** - * fdt_stringlist_contains - check a string list property for a string - * @strlist: Property containing a list of strings to check - * @listlen: Length of property - * @str: String to search for - * - * This is a utility function provided for convenience. The list contains - * one or more strings, each terminated by \0, as is found in a device tree - * "compatible" property. - * - * @return: 1 if the string is found in the list, 0 not found, or invalid list - */ -int fdt_stringlist_contains(const char *strlist, int listlen, const char *str); - -/** - * fdt_stringlist_count - count the number of strings in a string list - * @fdt: pointer to the device tree blob - * @nodeoffset: offset of a tree node - * @property: name of the property containing the string list - * @return: - * the number of strings in the given property - * -FDT_ERR_BADVALUE if the property value is not NUL-terminated - * -FDT_ERR_NOTFOUND if the property does not exist - */ -int fdt_stringlist_count(const void *fdt, int nodeoffset, const char *property); - -/** - * fdt_stringlist_search - find a string in a string list and return its index - * @fdt: pointer to the device tree blob - * @nodeoffset: offset of a tree node - * @property: name of the property containing the string list - * @string: string to look up in the string list - * - * Note that it is possible for this function to succeed on property values - * that are not NUL-terminated. That's because the function will stop after - * finding the first occurrence of @string. This can for example happen with - * small-valued cell properties, such as #address-cells, when searching for - * the empty string. - * - * @return: - * the index of the string in the list of strings - * -FDT_ERR_BADVALUE if the property value is not NUL-terminated - * -FDT_ERR_NOTFOUND if the property does not exist or does not contain - * the given string - */ -int fdt_stringlist_search(const void *fdt, int nodeoffset, const char *property, - const char *string); - -/** - * fdt_stringlist_get() - obtain the string at a given index in a string list - * @fdt: pointer to the device tree blob - * @nodeoffset: offset of a tree node - * @property: name of the property containing the string list - * @index: index of the string to return - * @lenp: return location for the string length or an error code on failure - * - * Note that this will successfully extract strings from properties with - * non-NUL-terminated values. For example on small-valued cell properties - * this function will return the empty string. - * - * If non-NULL, the length of the string (on success) or a negative error-code - * (on failure) will be stored in the integer pointer to by lenp. - * - * @return: - * A pointer to the string at the given index in the string list or NULL on - * failure. On success the length of the string will be stored in the memory - * location pointed to by the lenp parameter, if non-NULL. On failure one of - * the following negative error codes will be returned in the lenp parameter - * (if non-NULL): - * -FDT_ERR_BADVALUE if the property value is not NUL-terminated - * -FDT_ERR_NOTFOUND if the property does not exist - */ -const char *fdt_stringlist_get(const void *fdt, int nodeoffset, - const char *property, int index, - int *lenp); - -/**********************************************************************/ -/* Read-only functions (addressing related) */ -/**********************************************************************/ - -/** - * FDT_MAX_NCELLS - maximum value for #address-cells and #size-cells - * - * This is the maximum value for #address-cells, #size-cells and - * similar properties that will be processed by libfdt. IEE1275 - * requires that OF implementations handle values up to 4. - * Implementations may support larger values, but in practice higher - * values aren't used. - */ -#define FDT_MAX_NCELLS 4 - -/** - * fdt_address_cells - retrieve address size for a bus represented in the tree - * @fdt: pointer to the device tree blob - * @nodeoffset: offset of the node to find the address size for - * - * When the node has a valid #address-cells property, returns its value. - * - * returns: - * 0 <= n < FDT_MAX_NCELLS, on success - * 2, if the node has no #address-cells property - * -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid #address-cells property - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, - * -FDT_ERR_TRUNCATED, standard meanings - */ -int fdt_address_cells(const void *fdt, int nodeoffset); - -/** - * fdt_size_cells - retrieve address range size for a bus represented in the - * tree - * @fdt: pointer to the device tree blob - * @nodeoffset: offset of the node to find the address range size for - * - * When the node has a valid #size-cells property, returns its value. - * - * returns: - * 0 <= n < FDT_MAX_NCELLS, on success - * 2, if the node has no #address-cells property - * -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid #size-cells property - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, - * -FDT_ERR_TRUNCATED, standard meanings - */ -int fdt_size_cells(const void *fdt, int nodeoffset); - - -/**********************************************************************/ -/* Write-in-place functions */ -/**********************************************************************/ - -/** - * fdt_setprop_inplace - change a property's value, but not its size - * @fdt: pointer to the device tree blob - * @nodeoffset: offset of the node whose property to change - * @name: name of the property to change - * @val: pointer to data to replace the property value with - * @len: length of the property value - * - * fdt_setprop_inplace() replaces the value of a given property with - * the data in val, of length len. This function cannot change the - * size of a property, and so will only work if len is equal to the - * current length of the property. - * - * This function will alter only the bytes in the blob which contain - * the given property value, and will not alter or move any other part - * of the tree. - * - * returns: - * 0, on success - * -FDT_ERR_NOSPACE, if len is not equal to the property's current length - * -FDT_ERR_NOTFOUND, node does not have the named property - * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, - * -FDT_ERR_TRUNCATED, standard meanings - */ -int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name, - const void *val, int len); - -/** - * fdt_setprop_inplace_u32 - change the value of a 32-bit integer property - * @fdt: pointer to the device tree blob - * @nodeoffset: offset of the node whose property to change - * @name: name of the property to change - * @val: 32-bit integer value to replace the property with - * - * fdt_setprop_inplace_u32() replaces the value of a given property - * with the 32-bit integer value in val, converting val to big-endian - * if necessary. This function cannot change the size of a property, - * and so will only work if the property already exists and has length - * 4. - * - * This function will alter only the bytes in the blob which contain - * the given property value, and will not alter or move any other part - * of the tree. - * - * returns: - * 0, on success - * -FDT_ERR_NOSPACE, if the property's length is not equal to 4 - * -FDT_ERR_NOTFOUND, node does not have the named property - * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, - * -FDT_ERR_TRUNCATED, standard meanings - */ -static inline int fdt_setprop_inplace_u32(void *fdt, int nodeoffset, - const char *name, uint32_t val) -{ - fdt32_t tmp = cpu_to_fdt32(val); - return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp, sizeof(tmp)); -} - -/** - * fdt_setprop_inplace_u64 - change the value of a 64-bit integer property - * @fdt: pointer to the device tree blob - * @nodeoffset: offset of the node whose property to change - * @name: name of the property to change - * @val: 64-bit integer value to replace the property with - * - * fdt_setprop_inplace_u64() replaces the value of a given property - * with the 64-bit integer value in val, converting val to big-endian - * if necessary. This function cannot change the size of a property, - * and so will only work if the property already exists and has length - * 8. - * - * This function will alter only the bytes in the blob which contain - * the given property value, and will not alter or move any other part - * of the tree. - * - * returns: - * 0, on success - * -FDT_ERR_NOSPACE, if the property's length is not equal to 8 - * -FDT_ERR_NOTFOUND, node does not have the named property - * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, - * -FDT_ERR_TRUNCATED, standard meanings - */ -static inline int fdt_setprop_inplace_u64(void *fdt, int nodeoffset, - const char *name, uint64_t val) -{ - fdt64_t tmp = cpu_to_fdt64(val); - return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp, sizeof(tmp)); -} - -/** - * fdt_setprop_inplace_cell - change the value of a single-cell property - * - * This is an alternative name for fdt_setprop_inplace_u32() - */ -static inline int fdt_setprop_inplace_cell(void *fdt, int nodeoffset, - const char *name, uint32_t val) -{ - return fdt_setprop_inplace_u32(fdt, nodeoffset, name, val); -} - -/** - * fdt_nop_property - replace a property with nop tags - * @fdt: pointer to the device tree blob - * @nodeoffset: offset of the node whose property to nop - * @name: name of the property to nop - * - * fdt_nop_property() will replace a given property's representation - * in the blob with FDT_NOP tags, effectively removing it from the - * tree. - * - * This function will alter only the bytes in the blob which contain - * the property, and will not alter or move any other part of the - * tree. - * - * returns: - * 0, on success - * -FDT_ERR_NOTFOUND, node does not have the named property - * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, - * -FDT_ERR_TRUNCATED, standard meanings - */ -int fdt_nop_property(void *fdt, int nodeoffset, const char *name); - -/** - * fdt_nop_node - replace a node (subtree) with nop tags - * @fdt: pointer to the device tree blob - * @nodeoffset: offset of the node to nop - * - * fdt_nop_node() will replace a given node's representation in the - * blob, including all its subnodes, if any, with FDT_NOP tags, - * effectively removing it from the tree. - * - * This function will alter only the bytes in the blob which contain - * the node and its properties and subnodes, and will not alter or - * move any other part of the tree. - * - * returns: - * 0, on success - * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, - * -FDT_ERR_TRUNCATED, standard meanings - */ -int fdt_nop_node(void *fdt, int nodeoffset); - -/**********************************************************************/ -/* Sequential write functions */ -/**********************************************************************/ - -int fdt_create(void *buf, int bufsize); -int fdt_resize(void *fdt, void *buf, int bufsize); -int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size); -int fdt_finish_reservemap(void *fdt); -int fdt_begin_node(void *fdt, const char *name); -int fdt_property(void *fdt, const char *name, const void *val, int len); -static inline int fdt_property_u32(void *fdt, const char *name, uint32_t val) -{ - fdt32_t tmp = cpu_to_fdt32(val); - return fdt_property(fdt, name, &tmp, sizeof(tmp)); -} -static inline int fdt_property_u64(void *fdt, const char *name, uint64_t val) -{ - fdt64_t tmp = cpu_to_fdt64(val); - return fdt_property(fdt, name, &tmp, sizeof(tmp)); -} -static inline int fdt_property_cell(void *fdt, const char *name, uint32_t val) -{ - return fdt_property_u32(fdt, name, val); -} -#define fdt_property_string(fdt, name, str) \ - fdt_property(fdt, name, str, strlen(str)+1) -int fdt_end_node(void *fdt); -int fdt_finish(void *fdt); - -/**********************************************************************/ -/* Read-write functions */ -/**********************************************************************/ - -int fdt_create_empty_tree(void *buf, int bufsize); -int fdt_open_into(const void *fdt, void *buf, int bufsize); -int fdt_pack(void *fdt); - -/** - * fdt_add_mem_rsv - add one memory reserve map entry - * @fdt: pointer to the device tree blob - * @address, @size: 64-bit values (native endian) - * - * Adds a reserve map entry to the given blob reserving a region at - * address address of length size. - * - * This function will insert data into the reserve map and will - * therefore change the indexes of some entries in the table. - * - * returns: - * 0, on success - * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to - * contain the new reservation entry - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, - * -FDT_ERR_BADLAYOUT, - * -FDT_ERR_TRUNCATED, standard meanings - */ -int fdt_add_mem_rsv(void *fdt, uint64_t address, uint64_t size); - -/** - * fdt_del_mem_rsv - remove a memory reserve map entry - * @fdt: pointer to the device tree blob - * @n: entry to remove - * - * fdt_del_mem_rsv() removes the n-th memory reserve map entry from - * the blob. - * - * This function will delete data from the reservation table and will - * therefore change the indexes of some entries in the table. - * - * returns: - * 0, on success - * -FDT_ERR_NOTFOUND, there is no entry of the given index (i.e. there - * are less than n+1 reserve map entries) - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, - * -FDT_ERR_BADLAYOUT, - * -FDT_ERR_TRUNCATED, standard meanings - */ -int fdt_del_mem_rsv(void *fdt, int n); - -/** - * fdt_set_name - change the name of a given node - * @fdt: pointer to the device tree blob - * @nodeoffset: structure block offset of a node - * @name: name to give the node - * - * fdt_set_name() replaces the name (including unit address, if any) - * of the given node with the given string. NOTE: this function can't - * efficiently check if the new name is unique amongst the given - * node's siblings; results are undefined if this function is invoked - * with a name equal to one of the given node's siblings. - * - * This function may insert or delete data from the blob, and will - * therefore change the offsets of some existing nodes. - * - * returns: - * 0, on success - * -FDT_ERR_NOSPACE, there is insufficient free space in the blob - * to contain the new name - * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, standard meanings - */ -int fdt_set_name(void *fdt, int nodeoffset, const char *name); - -/** - * fdt_setprop - create or change a property - * @fdt: pointer to the device tree blob - * @nodeoffset: offset of the node whose property to change - * @name: name of the property to change - * @val: pointer to data to set the property value to - * @len: length of the property value - * - * fdt_setprop() sets the value of the named property in the given - * node to the given value and length, creating the property if it - * does not already exist. - * - * This function may insert or delete data from the blob, and will - * therefore change the offsets of some existing nodes. - * - * returns: - * 0, on success - * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to - * contain the new property value - * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag - * -FDT_ERR_BADLAYOUT, - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, - * -FDT_ERR_BADLAYOUT, - * -FDT_ERR_TRUNCATED, standard meanings - */ -int fdt_setprop(void *fdt, int nodeoffset, const char *name, - const void *val, int len); - -/** - * fdt_setprop_u32 - set a property to a 32-bit integer - * @fdt: pointer to the device tree blob - * @nodeoffset: offset of the node whose property to change - * @name: name of the property to change - * @val: 32-bit integer value for the property (native endian) - * - * fdt_setprop_u32() sets the value of the named property in the given - * node to the given 32-bit integer value (converting to big-endian if - * necessary), or creates a new property with that value if it does - * not already exist. - * - * This function may insert or delete data from the blob, and will - * therefore change the offsets of some existing nodes. - * - * returns: - * 0, on success - * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to - * contain the new property value - * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag - * -FDT_ERR_BADLAYOUT, - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, - * -FDT_ERR_BADLAYOUT, - * -FDT_ERR_TRUNCATED, standard meanings - */ -static inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name, - uint32_t val) -{ - fdt32_t tmp = cpu_to_fdt32(val); - return fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp)); -} - -/** - * fdt_setprop_u64 - set a property to a 64-bit integer - * @fdt: pointer to the device tree blob - * @nodeoffset: offset of the node whose property to change - * @name: name of the property to change - * @val: 64-bit integer value for the property (native endian) - * - * fdt_setprop_u64() sets the value of the named property in the given - * node to the given 64-bit integer value (converting to big-endian if - * necessary), or creates a new property with that value if it does - * not already exist. - * - * This function may insert or delete data from the blob, and will - * therefore change the offsets of some existing nodes. - * - * returns: - * 0, on success - * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to - * contain the new property value - * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag - * -FDT_ERR_BADLAYOUT, - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, - * -FDT_ERR_BADLAYOUT, - * -FDT_ERR_TRUNCATED, standard meanings - */ -static inline int fdt_setprop_u64(void *fdt, int nodeoffset, const char *name, - uint64_t val) -{ - fdt64_t tmp = cpu_to_fdt64(val); - return fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp)); -} - -/** - * fdt_setprop_cell - set a property to a single cell value - * - * This is an alternative name for fdt_setprop_u32() - */ -static inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name, - uint32_t val) -{ - return fdt_setprop_u32(fdt, nodeoffset, name, val); -} - -/** - * fdt_setprop_string - set a property to a string value - * @fdt: pointer to the device tree blob - * @nodeoffset: offset of the node whose property to change - * @name: name of the property to change - * @str: string value for the property - * - * fdt_setprop_string() sets the value of the named property in the - * given node to the given string value (using the length of the - * string to determine the new length of the property), or creates a - * new property with that value if it does not already exist. - * - * This function may insert or delete data from the blob, and will - * therefore change the offsets of some existing nodes. - * - * returns: - * 0, on success - * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to - * contain the new property value - * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag - * -FDT_ERR_BADLAYOUT, - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, - * -FDT_ERR_BADLAYOUT, - * -FDT_ERR_TRUNCATED, standard meanings - */ -#define fdt_setprop_string(fdt, nodeoffset, name, str) \ - fdt_setprop((fdt), (nodeoffset), (name), (str), strlen(str)+1) - -/** - * fdt_appendprop - append to or create a property - * @fdt: pointer to the device tree blob - * @nodeoffset: offset of the node whose property to change - * @name: name of the property to append to - * @val: pointer to data to append to the property value - * @len: length of the data to append to the property value - * - * fdt_appendprop() appends the value to the named property in the - * given node, creating the property if it does not already exist. - * - * This function may insert data into the blob, and will therefore - * change the offsets of some existing nodes. - * - * returns: - * 0, on success - * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to - * contain the new property value - * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag - * -FDT_ERR_BADLAYOUT, - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, - * -FDT_ERR_BADLAYOUT, - * -FDT_ERR_TRUNCATED, standard meanings - */ -int fdt_appendprop(void *fdt, int nodeoffset, const char *name, - const void *val, int len); - -/** - * fdt_appendprop_u32 - append a 32-bit integer value to a property - * @fdt: pointer to the device tree blob - * @nodeoffset: offset of the node whose property to change - * @name: name of the property to change - * @val: 32-bit integer value to append to the property (native endian) - * - * fdt_appendprop_u32() appends the given 32-bit integer value - * (converting to big-endian if necessary) to the value of the named - * property in the given node, or creates a new property with that - * value if it does not already exist. - * - * This function may insert data into the blob, and will therefore - * change the offsets of some existing nodes. - * - * returns: - * 0, on success - * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to - * contain the new property value - * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag - * -FDT_ERR_BADLAYOUT, - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, - * -FDT_ERR_BADLAYOUT, - * -FDT_ERR_TRUNCATED, standard meanings - */ -static inline int fdt_appendprop_u32(void *fdt, int nodeoffset, - const char *name, uint32_t val) -{ - fdt32_t tmp = cpu_to_fdt32(val); - return fdt_appendprop(fdt, nodeoffset, name, &tmp, sizeof(tmp)); -} - -/** - * fdt_appendprop_u64 - append a 64-bit integer value to a property - * @fdt: pointer to the device tree blob - * @nodeoffset: offset of the node whose property to change - * @name: name of the property to change - * @val: 64-bit integer value to append to the property (native endian) - * - * fdt_appendprop_u64() appends the given 64-bit integer value - * (converting to big-endian if necessary) to the value of the named - * property in the given node, or creates a new property with that - * value if it does not already exist. - * - * This function may insert data into the blob, and will therefore - * change the offsets of some existing nodes. - * - * returns: - * 0, on success - * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to - * contain the new property value - * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag - * -FDT_ERR_BADLAYOUT, - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, - * -FDT_ERR_BADLAYOUT, - * -FDT_ERR_TRUNCATED, standard meanings - */ -static inline int fdt_appendprop_u64(void *fdt, int nodeoffset, - const char *name, uint64_t val) -{ - fdt64_t tmp = cpu_to_fdt64(val); - return fdt_appendprop(fdt, nodeoffset, name, &tmp, sizeof(tmp)); -} - -/** - * fdt_appendprop_cell - append a single cell value to a property - * - * This is an alternative name for fdt_appendprop_u32() - */ -static inline int fdt_appendprop_cell(void *fdt, int nodeoffset, - const char *name, uint32_t val) -{ - return fdt_appendprop_u32(fdt, nodeoffset, name, val); -} - -/** - * fdt_appendprop_string - append a string to a property - * @fdt: pointer to the device tree blob - * @nodeoffset: offset of the node whose property to change - * @name: name of the property to change - * @str: string value to append to the property - * - * fdt_appendprop_string() appends the given string to the value of - * the named property in the given node, or creates a new property - * with that value if it does not already exist. - * - * This function may insert data into the blob, and will therefore - * change the offsets of some existing nodes. - * - * returns: - * 0, on success - * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to - * contain the new property value - * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag - * -FDT_ERR_BADLAYOUT, - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, - * -FDT_ERR_BADLAYOUT, - * -FDT_ERR_TRUNCATED, standard meanings - */ -#define fdt_appendprop_string(fdt, nodeoffset, name, str) \ - fdt_appendprop((fdt), (nodeoffset), (name), (str), strlen(str)+1) - -/** - * fdt_delprop - delete a property - * @fdt: pointer to the device tree blob - * @nodeoffset: offset of the node whose property to nop - * @name: name of the property to nop - * - * fdt_del_property() will delete the given property. - * - * This function will delete data from the blob, and will therefore - * change the offsets of some existing nodes. - * - * returns: - * 0, on success - * -FDT_ERR_NOTFOUND, node does not have the named property - * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag - * -FDT_ERR_BADLAYOUT, - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, - * -FDT_ERR_TRUNCATED, standard meanings - */ -int fdt_delprop(void *fdt, int nodeoffset, const char *name); - -/** - * fdt_add_subnode_namelen - creates a new node based on substring - * @fdt: pointer to the device tree blob - * @parentoffset: structure block offset of a node - * @name: name of the subnode to locate - * @namelen: number of characters of name to consider - * - * Identical to fdt_add_subnode(), but use only the first namelen - * characters of name as the name of the new node. This is useful for - * creating subnodes based on a portion of a larger string, such as a - * full path. - */ -int fdt_add_subnode_namelen(void *fdt, int parentoffset, - const char *name, int namelen); - -/** - * fdt_add_subnode - creates a new node - * @fdt: pointer to the device tree blob - * @parentoffset: structure block offset of a node - * @name: name of the subnode to locate - * - * fdt_add_subnode() creates a new node as a subnode of the node at - * structure block offset parentoffset, with the given name (which - * should include the unit address, if any). - * - * This function will insert data into the blob, and will therefore - * change the offsets of some existing nodes. - - * returns: - * structure block offset of the created nodeequested subnode (>=0), on success - * -FDT_ERR_NOTFOUND, if the requested subnode does not exist - * -FDT_ERR_BADOFFSET, if parentoffset did not point to an FDT_BEGIN_NODE tag - * -FDT_ERR_EXISTS, if the node at parentoffset already has a subnode of - * the given name - * -FDT_ERR_NOSPACE, if there is insufficient free space in the - * blob to contain the new node - * -FDT_ERR_NOSPACE - * -FDT_ERR_BADLAYOUT - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, - * -FDT_ERR_TRUNCATED, standard meanings. - */ -int fdt_add_subnode(void *fdt, int parentoffset, const char *name); - -/** - * fdt_del_node - delete a node (subtree) - * @fdt: pointer to the device tree blob - * @nodeoffset: offset of the node to nop - * - * fdt_del_node() will remove the given node, including all its - * subnodes if any, from the blob. - * - * This function will delete data from the blob, and will therefore - * change the offsets of some existing nodes. - * - * returns: - * 0, on success - * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag - * -FDT_ERR_BADLAYOUT, - * -FDT_ERR_BADMAGIC, - * -FDT_ERR_BADVERSION, - * -FDT_ERR_BADSTATE, - * -FDT_ERR_BADSTRUCTURE, - * -FDT_ERR_TRUNCATED, standard meanings - */ -int fdt_del_node(void *fdt, int nodeoffset); - -/**********************************************************************/ -/* Debugging / informational functions */ -/**********************************************************************/ - -const char *fdt_strerror(int errval); - -#endif /* _LIBFDT_H */ diff --git a/cpukit/dtc/libfdt/libfdt_env.h b/cpukit/dtc/libfdt/libfdt_env.h deleted file mode 100644 index 9dea97dfff..0000000000 --- a/cpukit/dtc/libfdt/libfdt_env.h +++ /dev/null @@ -1,111 +0,0 @@ -#ifndef _LIBFDT_ENV_H -#define _LIBFDT_ENV_H -/* - * libfdt - Flat Device Tree manipulation - * Copyright (C) 2006 David Gibson, IBM Corporation. - * Copyright 2012 Kim Phillips, Freescale Semiconductor. - * - * libfdt is dual licensed: you can use it either under the terms of - * the GPL, or the BSD license, at your option. - * - * a) This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, - * MA 02110-1301 USA - * - * Alternatively, - * - * b) Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include - -#ifdef __CHECKER__ -#define __force __attribute__((force)) -#define __bitwise __attribute__((bitwise)) -#else -#define __force -#define __bitwise -#endif - -typedef uint16_t __bitwise fdt16_t; -typedef uint32_t __bitwise fdt32_t; -typedef uint64_t __bitwise fdt64_t; - -#define EXTRACT_BYTE(x, n) ((unsigned long long)((uint8_t *)&x)[n]) -#define CPU_TO_FDT16(x) ((EXTRACT_BYTE(x, 0) << 8) | EXTRACT_BYTE(x, 1)) -#define CPU_TO_FDT32(x) ((EXTRACT_BYTE(x, 0) << 24) | (EXTRACT_BYTE(x, 1) << 16) | \ - (EXTRACT_BYTE(x, 2) << 8) | EXTRACT_BYTE(x, 3)) -#define CPU_TO_FDT64(x) ((EXTRACT_BYTE(x, 0) << 56) | (EXTRACT_BYTE(x, 1) << 48) | \ - (EXTRACT_BYTE(x, 2) << 40) | (EXTRACT_BYTE(x, 3) << 32) | \ - (EXTRACT_BYTE(x, 4) << 24) | (EXTRACT_BYTE(x, 5) << 16) | \ - (EXTRACT_BYTE(x, 6) << 8) | EXTRACT_BYTE(x, 7)) - -static inline uint16_t fdt16_to_cpu(fdt16_t x) -{ - return (__force uint16_t)CPU_TO_FDT16(x); -} -static inline fdt16_t cpu_to_fdt16(uint16_t x) -{ - return (__force fdt16_t)CPU_TO_FDT16(x); -} - -static inline uint32_t fdt32_to_cpu(fdt32_t x) -{ - return (__force uint32_t)CPU_TO_FDT32(x); -} -static inline fdt32_t cpu_to_fdt32(uint32_t x) -{ - return (__force fdt32_t)CPU_TO_FDT32(x); -} - -static inline uint64_t fdt64_to_cpu(fdt64_t x) -{ - return (__force uint64_t)CPU_TO_FDT64(x); -} -static inline fdt64_t cpu_to_fdt64(uint64_t x) -{ - return (__force fdt64_t)CPU_TO_FDT64(x); -} -#undef CPU_TO_FDT64 -#undef CPU_TO_FDT32 -#undef CPU_TO_FDT16 -#undef EXTRACT_BYTE - -#endif /* _LIBFDT_ENV_H */ diff --git a/cpukit/dtc/libfdt/preinstall.am b/cpukit/dtc/libfdt/preinstall.am deleted file mode 100644 index 36b61f247d..0000000000 --- a/cpukit/dtc/libfdt/preinstall.am +++ /dev/null @@ -1,32 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -$(PROJECT_INCLUDE)/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE) - @: > $(PROJECT_INCLUDE)/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/$(dirstamp) - -$(PROJECT_INCLUDE)/fdt.h: fdt.h $(PROJECT_INCLUDE)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/fdt.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/fdt.h - -$(PROJECT_INCLUDE)/libfdt.h: libfdt.h $(PROJECT_INCLUDE)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libfdt.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/libfdt.h - -$(PROJECT_INCLUDE)/libfdt_env.h: libfdt_env.h $(PROJECT_INCLUDE)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libfdt_env.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/libfdt_env.h - diff --git a/cpukit/ftpd/Makefile.am b/cpukit/ftpd/Makefile.am index 24a2815a97..fbb78650d6 100644 --- a/cpukit/ftpd/Makefile.am +++ b/cpukit/ftpd/Makefile.am @@ -2,8 +2,12 @@ include $(top_srcdir)/automake/compile.am if LIBNETWORKING project_lib_LIBRARIES = libftpd.a + +$(PROJECT_LIB)/libftpd.a: libftpd.a + $(INSTALL_DATA) $< $(PROJECT_LIB)/libftpd.a +TMPINSTALL_FILES = $(PROJECT_LIB)/libftpd.a + libftpd_a_SOURCES = ftpd.c ftpd.h endif -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am diff --git a/cpukit/ftpd/ftpd.h b/cpukit/ftpd/ftpd.h deleted file mode 100644 index f33ca59d3a..0000000000 --- a/cpukit/ftpd/ftpd.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * FTP Server Information - */ - -#ifndef _RTEMS_FTPD_H -#define _RTEMS_FTPD_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define FTPD_CONTROL_PORT 21 - -/* Various buffer sizes */ -enum { - FTPD_BUFSIZE = 256, /* Size for temporary buffers */ - FTPD_DATASIZE = 4 * 1024, /* Size for file transfer buffers */ - FTPD_STACKSIZE = RTEMS_MINIMUM_STACK_SIZE + FTPD_DATASIZE /* Tasks stack size */ -}; - -/* FTPD access control flags */ -enum -{ - FTPD_NO_WRITE = 0x1, - FTPD_NO_READ = 0x2, - FTPD_NO_RW = FTPD_NO_WRITE | FTPD_NO_READ -}; - -typedef int (*rtems_ftpd_hookfunction)(char *, size_t); - -#include - -struct rtems_ftpd_hook -{ - char *filename; - rtems_ftpd_hookfunction hook_function; -}; - -struct rtems_ftpd_configuration -{ - rtems_task_priority priority; /* FTPD task priority */ - unsigned long max_hook_filesize; /* Maximum buffersize */ - /* for hooks */ - int port; /* Well-known port */ - struct rtems_ftpd_hook *hooks; /* List of hooks */ - char const *root; /* Root for FTPD or 0 for / */ - int tasks_count; /* Max. connections */ - int idle; /* Idle timeout in seoconds - or 0 for no (inf) timeout */ - int access; /* 0 - r/w, 1 - read-only, - 2 - write-only, - 3 - browse-only */ - rtems_shell_login_check_t login; /* Login check or 0 to ignore - user/passwd. */ -}; - -/* - * Reply codes. - */ -#define PRELIM 1 /* positive preliminary */ -#define COMPLETE 2 /* positive completion */ -#define CONTINUE 3 /* positive intermediate */ -#define TRANSIENT 4 /* transient negative completion */ -#define ERROR 5 /* permanent negative completion */ - -int rtems_initialize_ftpd(void); - -#ifdef __cplusplus -} -#endif - -#endif /* _RTEMS_FTPD_H */ diff --git a/cpukit/ftpd/preinstall.am b/cpukit/ftpd/preinstall.am deleted file mode 100644 index 85ae87d6db..0000000000 --- a/cpukit/ftpd/preinstall.am +++ /dev/null @@ -1,25 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-local: $(TMPINSTALL_FILES) - -TMPINSTALL_FILES = -CLEANFILES = $(TMPINSTALL_FILES) - -$(PROJECT_LIB)/$(dirstamp): - @$(MKDIR_P) $(PROJECT_LIB) - @: > $(PROJECT_LIB)/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_LIB)/$(dirstamp) - -if LIBNETWORKING -$(PROJECT_LIB)/libftpd.a: libftpd.a $(PROJECT_LIB)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_LIB)/libftpd.a -TMPINSTALL_FILES += $(PROJECT_LIB)/libftpd.a -endif diff --git a/cpukit/headers.am b/cpukit/headers.am new file mode 100644 index 0000000000..c486c3f51f --- /dev/null +++ b/cpukit/headers.am @@ -0,0 +1,474 @@ +## This file was generated by "./boostrap -H". + +include_HEADERS = +include_HEADERS += include/aio.h +include_HEADERS += include/crypt.h +include_HEADERS += include/dlfcn.h +include_HEADERS += include/endian.h +include_HEADERS += include/fdt.h +include_HEADERS += include/libfdt.h +include_HEADERS += include/libfdt_env.h +include_HEADERS += include/librtemsNfs.h +include_HEADERS += include/link.h +include_HEADERS += include/link_elf.h +include_HEADERS += include/md4.h +include_HEADERS += include/md5.h +include_HEADERS += include/memory.h +include_HEADERS += include/mqueue.h +include_HEADERS += include/pci.h +include_HEADERS += include/rtems.h +include_HEADERS += include/sha256.h +include_HEADERS += include/sha512.h +include_HEADERS += include/xz.h +include_HEADERS += include/zconf.h +include_HEADERS += include/zlib.h + +include_dev_i2cdir = $(includedir)/dev/i2c +include_dev_i2c_HEADERS = +include_dev_i2c_HEADERS += include/dev/i2c/eeprom.h +include_dev_i2c_HEADERS += include/dev/i2c/fpga-i2c-slave.h +include_dev_i2c_HEADERS += include/dev/i2c/gpio-nxp-pca9535.h +include_dev_i2c_HEADERS += include/dev/i2c/i2c.h +include_dev_i2c_HEADERS += include/dev/i2c/sensor-lm75a.h +include_dev_i2c_HEADERS += include/dev/i2c/switch-nxp-pca9548a.h +include_dev_i2c_HEADERS += include/dev/i2c/ti-ads-16bit-adc.h +include_dev_i2c_HEADERS += include/dev/i2c/ti-lm25066a.h +include_dev_i2c_HEADERS += include/dev/i2c/ti-tmp112.h +include_dev_i2c_HEADERS += include/dev/i2c/xilinx-axi-i2c.h + +include_dev_serialdir = $(includedir)/dev/serial +include_dev_serial_HEADERS = +include_dev_serial_HEADERS += include/dev/serial/sc16is752.h + +include_dev_spidir = $(includedir)/dev/spi +include_dev_spi_HEADERS = +include_dev_spi_HEADERS += include/dev/spi/spi.h + +include_drvmgrdir = $(includedir)/drvmgr +include_drvmgr_HEADERS = +include_drvmgr_HEADERS += include/drvmgr/drvmgr.h +include_drvmgr_HEADERS += include/drvmgr/drvmgr_confdefs.h +include_drvmgr_HEADERS += include/drvmgr/drvmgr_list.h +include_drvmgr_HEADERS += include/drvmgr/pci_bus.h + +include_linuxdir = $(includedir)/linux +include_linux_HEADERS = +include_linux_HEADERS += include/linux/i2c-dev.h +include_linux_HEADERS += include/linux/i2c.h + +include_linux_spidir = $(includedir)/linux/spi +include_linux_spi_HEADERS = +include_linux_spi_HEADERS += include/linux/spi/spidev.h + +include_machinedir = $(includedir)/machine +include_machine_HEADERS = +include_machine_HEADERS += include/machine/_kernel_cpuset.h +include_machine_HEADERS += include/machine/_kernel_param.h +include_machine_HEADERS += include/machine/_kernel_time.h +include_machine_HEADERS += include/machine/_kernel_types.h +include_machine_HEADERS += include/machine/_timecounter.h + +include_mghttpddir = $(includedir)/mghttpd +include_mghttpd_HEADERS = +include_mghttpd_HEADERS += include/mghttpd/mongoose.h + +include_pcidir = $(includedir)/pci +include_pci_HEADERS = +include_pci_HEADERS += include/pci/access.h +include_pci_HEADERS += include/pci/cfg.h +include_pci_HEADERS += include/pci/cfg_auto.h +include_pci_HEADERS += include/pci/cfg_peripheral.h +include_pci_HEADERS += include/pci/cfg_read.h +include_pci_HEADERS += include/pci/cfg_static.h +include_pci_HEADERS += include/pci/ids.h +include_pci_HEADERS += include/pci/ids_extra.h +include_pci_HEADERS += include/pci/irq.h +include_pci_HEADERS += include/pci/pcireg.h + +include_rpcdir = $(includedir)/rpc +include_rpc_HEADERS = +include_rpc_HEADERS += include/rpc/auth.h +include_rpc_HEADERS += include/rpc/auth_unix.h +include_rpc_HEADERS += include/rpc/clnt.h +include_rpc_HEADERS += include/rpc/clnt_soc.h +include_rpc_HEADERS += include/rpc/clnt_stat.h +include_rpc_HEADERS += include/rpc/pmap_clnt.h +include_rpc_HEADERS += include/rpc/pmap_prot.h +include_rpc_HEADERS += include/rpc/pmap_rmt.h +include_rpc_HEADERS += include/rpc/rpc.h +include_rpc_HEADERS += include/rpc/rpc_com.h +include_rpc_HEADERS += include/rpc/rpc_msg.h +include_rpc_HEADERS += include/rpc/rpcent.h +include_rpc_HEADERS += include/rpc/svc.h +include_rpc_HEADERS += include/rpc/svc_auth.h +include_rpc_HEADERS += include/rpc/svc_soc.h +include_rpc_HEADERS += include/rpc/types.h +include_rpc_HEADERS += include/rpc/xdr.h + +include_rtemsdir = $(includedir)/rtems +include_rtems_HEADERS = +include_rtems_HEADERS += include/rtems/assoc.h +include_rtems_HEADERS += include/rtems/bdbuf.h +include_rtems_HEADERS += include/rtems/bdpart.h +include_rtems_HEADERS += include/rtems/blkdev.h +include_rtems_HEADERS += include/rtems/bsd.h +include_rtems_HEADERS += include/rtems/bspIo.h +include_rtems_HEADERS += include/rtems/bspcmdline.h +include_rtems_HEADERS += include/rtems/btimer.h +include_rtems_HEADERS += include/rtems/capture-cli.h +include_rtems_HEADERS += include/rtems/capture.h +include_rtems_HEADERS += include/rtems/captureimpl.h +include_rtems_HEADERS += include/rtems/cbs.h +include_rtems_HEADERS += include/rtems/chain.h +include_rtems_HEADERS += include/rtems/clockdrv.h +include_rtems_HEADERS += include/rtems/concat.h +include_rtems_HEADERS += include/rtems/confdefs.h +include_rtems_HEADERS += include/rtems/config.h +include_rtems_HEADERS += include/rtems/console.h +include_rtems_HEADERS += include/rtems/counter.h +include_rtems_HEADERS += include/rtems/cpuuse.h +include_rtems_HEADERS += include/rtems/devfs.h +include_rtems_HEADERS += include/rtems/deviceio.h +include_rtems_HEADERS += include/rtems/devnull.h +include_rtems_HEADERS += include/rtems/devzero.h +include_rtems_HEADERS += include/rtems/diskdevs.h +include_rtems_HEADERS += include/rtems/dosfs.h +include_rtems_HEADERS += include/rtems/dumpbuf.h +include_rtems_HEADERS += include/rtems/endian.h +include_rtems_HEADERS += include/rtems/error.h +include_rtems_HEADERS += include/rtems/extension.h +include_rtems_HEADERS += include/rtems/extensionimpl.h +include_rtems_HEADERS += include/rtems/fatal.h +include_rtems_HEADERS += include/rtems/fb.h +include_rtems_HEADERS += include/rtems/flashdisk.h +include_rtems_HEADERS += include/rtems/framebuffer.h +include_rtems_HEADERS += include/rtems/fs.h +include_rtems_HEADERS += include/rtems/fsmount.h +include_rtems_HEADERS += include/rtems/ftpd.h +include_rtems_HEADERS += include/rtems/gxx_wrappers.h +include_rtems_HEADERS += include/rtems/ide_part_table.h +include_rtems_HEADERS += include/rtems/imfs.h +include_rtems_HEADERS += include/rtems/init.h +include_rtems_HEADERS += include/rtems/inttypes.h +include_rtems_HEADERS += include/rtems/io.h +include_rtems_HEADERS += include/rtems/ioimpl.h +include_rtems_HEADERS += include/rtems/iosupp.h +include_rtems_HEADERS += include/rtems/irq-extension.h +include_rtems_HEADERS += include/rtems/irq.h +include_rtems_HEADERS += include/rtems/jffs2.h +include_rtems_HEADERS += include/rtems/libcsupport.h +include_rtems_HEADERS += include/rtems/libi2c.h +include_rtems_HEADERS += include/rtems/libio.h +include_rtems_HEADERS += include/rtems/libio_.h +include_rtems_HEADERS += include/rtems/linkersets.h +include_rtems_HEADERS += include/rtems/malloc.h +include_rtems_HEADERS += include/rtems/media.h +include_rtems_HEADERS += include/rtems/monitor.h +include_rtems_HEADERS += include/rtems/mouse_parser.h +include_rtems_HEADERS += include/rtems/mptables.h +include_rtems_HEADERS += include/rtems/mw_uid.h +include_rtems_HEADERS += include/rtems/nvdisk-sram.h +include_rtems_HEADERS += include/rtems/nvdisk.h +include_rtems_HEADERS += include/rtems/passwd.h +include_rtems_HEADERS += include/rtems/pci.h +include_rtems_HEADERS += include/rtems/pipe.h +include_rtems_HEADERS += include/rtems/print.h +include_rtems_HEADERS += include/rtems/printer.h +include_rtems_HEADERS += include/rtems/profiling.h +include_rtems_HEADERS += include/rtems/pty.h +include_rtems_HEADERS += include/rtems/qreslib.h +include_rtems_HEADERS += include/rtems/ramdisk.h +include_rtems_HEADERS += include/rtems/rbheap.h +include_rtems_HEADERS += include/rtems/rbtree.h +include_rtems_HEADERS += include/rtems/ringbuf.h +include_rtems_HEADERS += include/rtems/rtc.h +include_rtems_HEADERS += include/rtems/rtems-debugger.h +include_rtems_HEADERS += include/rtems/rtems-fdt-shell.h +include_rtems_HEADERS += include/rtems/rtems-fdt.h +include_rtems_HEADERS += include/rtems/rtems-rfs-format.h +include_rtems_HEADERS += include/rtems/rtems-rfs-shell.h +include_rtems_HEADERS += include/rtems/rtems-rfs.h +include_rtems_HEADERS += include/rtems/rtemsdialer.h +include_rtems_HEADERS += include/rtems/rtemspppd.h +include_rtems_HEADERS += include/rtems/scheduler.h +include_rtems_HEADERS += include/rtems/serdbg.h +include_rtems_HEADERS += include/rtems/serdbgcnf.h +include_rtems_HEADERS += include/rtems/serial_mouse.h +include_rtems_HEADERS += include/rtems/seterr.h +include_rtems_HEADERS += include/rtems/shell.h +include_rtems_HEADERS += include/rtems/shellconfig.h +include_rtems_HEADERS += include/rtems/sparse-disk.h +include_rtems_HEADERS += include/rtems/spurious.h +include_rtems_HEADERS += include/rtems/stackchk.h +include_rtems_HEADERS += include/rtems/status-checks.h +include_rtems_HEADERS += include/rtems/stdio-redirect.h +include_rtems_HEADERS += include/rtems/stringto.h +include_rtems_HEADERS += include/rtems/sysinit.h +include_rtems_HEADERS += include/rtems/system.h +include_rtems_HEADERS += include/rtems/telnetd.h +include_rtems_HEADERS += include/rtems/termios_printk.h +include_rtems_HEADERS += include/rtems/termios_printk_cnf.h +include_rtems_HEADERS += include/rtems/termiostypes.h +include_rtems_HEADERS += include/rtems/test.h +include_rtems_HEADERS += include/rtems/timecounter.h +include_rtems_HEADERS += include/rtems/timespec.h +include_rtems_HEADERS += include/rtems/tm27-default.h +include_rtems_HEADERS += include/rtems/tod.h +include_rtems_HEADERS += include/rtems/untar.h +include_rtems_HEADERS += include/rtems/userenv.h +include_rtems_HEADERS += include/rtems/version.h +include_rtems_HEADERS += include/rtems/vmeintr.h +include_rtems_HEADERS += include/rtems/watchdogdrv.h + +include_rtems_debuggerdir = $(includedir)/rtems/debugger +include_rtems_debugger_HEADERS = +include_rtems_debugger_HEADERS += include/rtems/debugger/rtems-debugger-remote.h +include_rtems_debugger_HEADERS += include/rtems/debugger/rtems-debugger-server.h + +include_rtems_posixdir = $(includedir)/rtems/posix +include_rtems_posix_HEADERS = +include_rtems_posix_HEADERS += include/rtems/posix/aio_misc.h +include_rtems_posix_HEADERS += include/rtems/posix/barrierimpl.h +include_rtems_posix_HEADERS += include/rtems/posix/condimpl.h +include_rtems_posix_HEADERS += include/rtems/posix/config.h +include_rtems_posix_HEADERS += include/rtems/posix/key.h +include_rtems_posix_HEADERS += include/rtems/posix/keyimpl.h +include_rtems_posix_HEADERS += include/rtems/posix/mmanimpl.h +include_rtems_posix_HEADERS += include/rtems/posix/mqueue.h +include_rtems_posix_HEADERS += include/rtems/posix/mqueueimpl.h +include_rtems_posix_HEADERS += include/rtems/posix/muteximpl.h +include_rtems_posix_HEADERS += include/rtems/posix/posixapi.h +include_rtems_posix_HEADERS += include/rtems/posix/priorityimpl.h +include_rtems_posix_HEADERS += include/rtems/posix/psignal.h +include_rtems_posix_HEADERS += include/rtems/posix/psignalimpl.h +include_rtems_posix_HEADERS += include/rtems/posix/pthread.h +include_rtems_posix_HEADERS += include/rtems/posix/pthreadattrimpl.h +include_rtems_posix_HEADERS += include/rtems/posix/pthreadimpl.h +include_rtems_posix_HEADERS += include/rtems/posix/ptimer.h +include_rtems_posix_HEADERS += include/rtems/posix/rwlockimpl.h +include_rtems_posix_HEADERS += include/rtems/posix/semaphore.h +include_rtems_posix_HEADERS += include/rtems/posix/semaphoreimpl.h +include_rtems_posix_HEADERS += include/rtems/posix/shm.h +include_rtems_posix_HEADERS += include/rtems/posix/shmimpl.h +include_rtems_posix_HEADERS += include/rtems/posix/sigset.h +include_rtems_posix_HEADERS += include/rtems/posix/spinlockimpl.h +include_rtems_posix_HEADERS += include/rtems/posix/threadsup.h +include_rtems_posix_HEADERS += include/rtems/posix/timer.h +include_rtems_posix_HEADERS += include/rtems/posix/timerimpl.h + +include_rtems_rfsdir = $(includedir)/rtems/rfs +include_rtems_rfs_HEADERS = +include_rtems_rfs_HEADERS += include/rtems/rfs/rtems-rfs-bitmaps.h +include_rtems_rfs_HEADERS += include/rtems/rfs/rtems-rfs-block-pos.h +include_rtems_rfs_HEADERS += include/rtems/rfs/rtems-rfs-block.h +include_rtems_rfs_HEADERS += include/rtems/rfs/rtems-rfs-buffer.h +include_rtems_rfs_HEADERS += include/rtems/rfs/rtems-rfs-data.h +include_rtems_rfs_HEADERS += include/rtems/rfs/rtems-rfs-dir-hash.h +include_rtems_rfs_HEADERS += include/rtems/rfs/rtems-rfs-dir.h +include_rtems_rfs_HEADERS += include/rtems/rfs/rtems-rfs-file-system-fwd.h +include_rtems_rfs_HEADERS += include/rtems/rfs/rtems-rfs-file-system.h +include_rtems_rfs_HEADERS += include/rtems/rfs/rtems-rfs-file.h +include_rtems_rfs_HEADERS += include/rtems/rfs/rtems-rfs-group.h +include_rtems_rfs_HEADERS += include/rtems/rfs/rtems-rfs-inode.h +include_rtems_rfs_HEADERS += include/rtems/rfs/rtems-rfs-link.h +include_rtems_rfs_HEADERS += include/rtems/rfs/rtems-rfs-mutex.h +include_rtems_rfs_HEADERS += include/rtems/rfs/rtems-rfs-trace.h + +include_rtems_rtemsdir = $(includedir)/rtems/rtems +include_rtems_rtems_HEADERS = +include_rtems_rtems_HEADERS += include/rtems/rtems/asr.h +include_rtems_rtems_HEADERS += include/rtems/rtems/asrimpl.h +include_rtems_rtems_HEADERS += include/rtems/rtems/attr.h +include_rtems_rtems_HEADERS += include/rtems/rtems/attrimpl.h +include_rtems_rtems_HEADERS += include/rtems/rtems/barrier.h +include_rtems_rtems_HEADERS += include/rtems/rtems/barrierimpl.h +include_rtems_rtems_HEADERS += include/rtems/rtems/cache.h +include_rtems_rtems_HEADERS += include/rtems/rtems/clock.h +include_rtems_rtems_HEADERS += include/rtems/rtems/config.h +include_rtems_rtems_HEADERS += include/rtems/rtems/dpmem.h +include_rtems_rtems_HEADERS += include/rtems/rtems/dpmemimpl.h +include_rtems_rtems_HEADERS += include/rtems/rtems/event.h +include_rtems_rtems_HEADERS += include/rtems/rtems/eventimpl.h +include_rtems_rtems_HEADERS += include/rtems/rtems/eventmp.h +include_rtems_rtems_HEADERS += include/rtems/rtems/intr.h +include_rtems_rtems_HEADERS += include/rtems/rtems/mainpage.h +include_rtems_rtems_HEADERS += include/rtems/rtems/message.h +include_rtems_rtems_HEADERS += include/rtems/rtems/messageimpl.h +include_rtems_rtems_HEADERS += include/rtems/rtems/modes.h +include_rtems_rtems_HEADERS += include/rtems/rtems/modesimpl.h +include_rtems_rtems_HEADERS += include/rtems/rtems/mp.h +include_rtems_rtems_HEADERS += include/rtems/rtems/msgmp.h +include_rtems_rtems_HEADERS += include/rtems/rtems/object.h +include_rtems_rtems_HEADERS += include/rtems/rtems/options.h +include_rtems_rtems_HEADERS += include/rtems/rtems/optionsimpl.h +include_rtems_rtems_HEADERS += include/rtems/rtems/part.h +include_rtems_rtems_HEADERS += include/rtems/rtems/partimpl.h +include_rtems_rtems_HEADERS += include/rtems/rtems/partmp.h +include_rtems_rtems_HEADERS += include/rtems/rtems/ratemon.h +include_rtems_rtems_HEADERS += include/rtems/rtems/ratemonimpl.h +include_rtems_rtems_HEADERS += include/rtems/rtems/region.h +include_rtems_rtems_HEADERS += include/rtems/rtems/regionimpl.h +include_rtems_rtems_HEADERS += include/rtems/rtems/sem.h +include_rtems_rtems_HEADERS += include/rtems/rtems/semimpl.h +include_rtems_rtems_HEADERS += include/rtems/rtems/semmp.h +include_rtems_rtems_HEADERS += include/rtems/rtems/signal.h +include_rtems_rtems_HEADERS += include/rtems/rtems/signalimpl.h +include_rtems_rtems_HEADERS += include/rtems/rtems/signalmp.h +include_rtems_rtems_HEADERS += include/rtems/rtems/smp.h +include_rtems_rtems_HEADERS += include/rtems/rtems/status.h +include_rtems_rtems_HEADERS += include/rtems/rtems/statusimpl.h +include_rtems_rtems_HEADERS += include/rtems/rtems/support.h +include_rtems_rtems_HEADERS += include/rtems/rtems/taskmp.h +include_rtems_rtems_HEADERS += include/rtems/rtems/tasks.h +include_rtems_rtems_HEADERS += include/rtems/rtems/tasksimpl.h +include_rtems_rtems_HEADERS += include/rtems/rtems/timer.h +include_rtems_rtems_HEADERS += include/rtems/rtems/timerimpl.h +include_rtems_rtems_HEADERS += include/rtems/rtems/types.h + +include_rtems_rtldir = $(includedir)/rtems/rtl +include_rtems_rtl_HEADERS = +include_rtems_rtl_HEADERS += include/rtems/rtl/dlfcn-shell.h +include_rtems_rtl_HEADERS += include/rtems/rtl/rap-shell.h +include_rtems_rtl_HEADERS += include/rtems/rtl/rap.h +include_rtems_rtl_HEADERS += include/rtems/rtl/rtl-allocator.h +include_rtems_rtl_HEADERS += include/rtems/rtl/rtl-fwd.h +include_rtems_rtl_HEADERS += include/rtems/rtl/rtl-indirect-ptr.h +include_rtems_rtl_HEADERS += include/rtems/rtl/rtl-obj-cache.h +include_rtems_rtl_HEADERS += include/rtems/rtl/rtl-obj-comp.h +include_rtems_rtl_HEADERS += include/rtems/rtl/rtl-obj-fwd.h +include_rtems_rtl_HEADERS += include/rtems/rtl/rtl-obj.h +include_rtems_rtl_HEADERS += include/rtems/rtl/rtl-sym.h +include_rtems_rtl_HEADERS += include/rtems/rtl/rtl-trace.h +include_rtems_rtl_HEADERS += include/rtems/rtl/rtl-unresolved.h +include_rtems_rtl_HEADERS += include/rtems/rtl/rtl.h + +include_rtems_scoredir = $(includedir)/rtems/score +include_rtems_score_HEADERS = +include_rtems_score_HEADERS += include/rtems/score/address.h +include_rtems_score_HEADERS += include/rtems/score/apimutex.h +include_rtems_score_HEADERS += include/rtems/score/assert.h +include_rtems_score_HEADERS += include/rtems/score/atomic.h +include_rtems_score_HEADERS += include/rtems/score/basedefs.h +include_rtems_score_HEADERS += include/rtems/score/chain.h +include_rtems_score_HEADERS += include/rtems/score/chainimpl.h +include_rtems_score_HEADERS += include/rtems/score/context.h +include_rtems_score_HEADERS += include/rtems/score/copyrt.h +include_rtems_score_HEADERS += include/rtems/score/corebarrier.h +include_rtems_score_HEADERS += include/rtems/score/corebarrierimpl.h +include_rtems_score_HEADERS += include/rtems/score/coremsg.h +include_rtems_score_HEADERS += include/rtems/score/coremsgimpl.h +include_rtems_score_HEADERS += include/rtems/score/coremutex.h +include_rtems_score_HEADERS += include/rtems/score/coremuteximpl.h +include_rtems_score_HEADERS += include/rtems/score/corerwlockimpl.h +include_rtems_score_HEADERS += include/rtems/score/coresem.h +include_rtems_score_HEADERS += include/rtems/score/coresemimpl.h +include_rtems_score_HEADERS += include/rtems/score/cpustdatomic.h +include_rtems_score_HEADERS += include/rtems/score/freechain.h +include_rtems_score_HEADERS += include/rtems/score/heap.h +include_rtems_score_HEADERS += include/rtems/score/heapimpl.h +include_rtems_score_HEADERS += include/rtems/score/interr.h +include_rtems_score_HEADERS += include/rtems/score/io.h +include_rtems_score_HEADERS += include/rtems/score/isr.h +include_rtems_score_HEADERS += include/rtems/score/isrlevel.h +include_rtems_score_HEADERS += include/rtems/score/isrlock.h +include_rtems_score_HEADERS += include/rtems/score/mpci.h +include_rtems_score_HEADERS += include/rtems/score/mpciimpl.h +include_rtems_score_HEADERS += include/rtems/score/mppkt.h +include_rtems_score_HEADERS += include/rtems/score/mrsp.h +include_rtems_score_HEADERS += include/rtems/score/mrspimpl.h +include_rtems_score_HEADERS += include/rtems/score/muteximpl.h +include_rtems_score_HEADERS += include/rtems/score/object.h +include_rtems_score_HEADERS += include/rtems/score/objectimpl.h +include_rtems_score_HEADERS += include/rtems/score/objectmp.h +include_rtems_score_HEADERS += include/rtems/score/onceimpl.h +include_rtems_score_HEADERS += include/rtems/score/percpu.h +include_rtems_score_HEADERS += include/rtems/score/priority.h +include_rtems_score_HEADERS += include/rtems/score/prioritybitmap.h +include_rtems_score_HEADERS += include/rtems/score/prioritybitmapimpl.h +include_rtems_score_HEADERS += include/rtems/score/priorityimpl.h +include_rtems_score_HEADERS += include/rtems/score/processormask.h +include_rtems_score_HEADERS += include/rtems/score/profiling.h +include_rtems_score_HEADERS += include/rtems/score/protectedheap.h +include_rtems_score_HEADERS += include/rtems/score/rbtree.h +include_rtems_score_HEADERS += include/rtems/score/rbtreeimpl.h +include_rtems_score_HEADERS += include/rtems/score/scheduler.h +include_rtems_score_HEADERS += include/rtems/score/schedulercbs.h +include_rtems_score_HEADERS += include/rtems/score/schedulercbsimpl.h +include_rtems_score_HEADERS += include/rtems/score/scheduleredf.h +include_rtems_score_HEADERS += include/rtems/score/scheduleredfimpl.h +include_rtems_score_HEADERS += include/rtems/score/scheduleredfsmp.h +include_rtems_score_HEADERS += include/rtems/score/schedulerimpl.h +include_rtems_score_HEADERS += include/rtems/score/schedulernode.h +include_rtems_score_HEADERS += include/rtems/score/schedulernodeimpl.h +include_rtems_score_HEADERS += include/rtems/score/schedulerpriority.h +include_rtems_score_HEADERS += include/rtems/score/schedulerpriorityaffinitysmp.h +include_rtems_score_HEADERS += include/rtems/score/schedulerpriorityimpl.h +include_rtems_score_HEADERS += include/rtems/score/schedulerprioritysmp.h +include_rtems_score_HEADERS += include/rtems/score/schedulerprioritysmpimpl.h +include_rtems_score_HEADERS += include/rtems/score/schedulersimple.h +include_rtems_score_HEADERS += include/rtems/score/schedulersimpleimpl.h +include_rtems_score_HEADERS += include/rtems/score/schedulersimplesmp.h +include_rtems_score_HEADERS += include/rtems/score/schedulersmp.h +include_rtems_score_HEADERS += include/rtems/score/schedulersmpimpl.h +include_rtems_score_HEADERS += include/rtems/score/schedulerstrongapa.h +include_rtems_score_HEADERS += include/rtems/score/semaphoreimpl.h +include_rtems_score_HEADERS += include/rtems/score/smp.h +include_rtems_score_HEADERS += include/rtems/score/smpbarrier.h +include_rtems_score_HEADERS += include/rtems/score/smpimpl.h +include_rtems_score_HEADERS += include/rtems/score/smplock.h +include_rtems_score_HEADERS += include/rtems/score/smplockmcs.h +include_rtems_score_HEADERS += include/rtems/score/smplockseq.h +include_rtems_score_HEADERS += include/rtems/score/smplockstats.h +include_rtems_score_HEADERS += include/rtems/score/smplockticket.h +include_rtems_score_HEADERS += include/rtems/score/stack.h +include_rtems_score_HEADERS += include/rtems/score/stackimpl.h +include_rtems_score_HEADERS += include/rtems/score/states.h +include_rtems_score_HEADERS += include/rtems/score/statesimpl.h +include_rtems_score_HEADERS += include/rtems/score/status.h +include_rtems_score_HEADERS += include/rtems/score/sysstate.h +include_rtems_score_HEADERS += include/rtems/score/thread.h +include_rtems_score_HEADERS += include/rtems/score/threaddispatch.h +include_rtems_score_HEADERS += include/rtems/score/threadimpl.h +include_rtems_score_HEADERS += include/rtems/score/threadmp.h +include_rtems_score_HEADERS += include/rtems/score/threadq.h +include_rtems_score_HEADERS += include/rtems/score/threadqimpl.h +include_rtems_score_HEADERS += include/rtems/score/timecounter.h +include_rtems_score_HEADERS += include/rtems/score/timecounterimpl.h +include_rtems_score_HEADERS += include/rtems/score/timespec.h +include_rtems_score_HEADERS += include/rtems/score/timestamp.h +include_rtems_score_HEADERS += include/rtems/score/tls.h +include_rtems_score_HEADERS += include/rtems/score/tod.h +include_rtems_score_HEADERS += include/rtems/score/todimpl.h +include_rtems_score_HEADERS += include/rtems/score/userext.h +include_rtems_score_HEADERS += include/rtems/score/userextimpl.h +include_rtems_score_HEADERS += include/rtems/score/watchdog.h +include_rtems_score_HEADERS += include/rtems/score/watchdogimpl.h +include_rtems_score_HEADERS += include/rtems/score/wkspace.h + +include_rtems_tracedir = $(includedir)/rtems/trace +include_rtems_trace_HEADERS = +include_rtems_trace_HEADERS += include/rtems/trace/rtems-trace-buffer-vars.h + +include_sysdir = $(includedir)/sys +include_sys_HEADERS = +include_sys_HEADERS += include/sys/_ffcounter.h +include_sys_HEADERS += include/sys/cdefs_elf.h +include_sys_HEADERS += include/sys/endian.h +include_sys_HEADERS += include/sys/event.h +include_sys_HEADERS += include/sys/exec_elf.h +include_sys_HEADERS += include/sys/poll.h +include_sys_HEADERS += include/sys/priority.h +include_sys_HEADERS += include/sys/statvfs.h +include_sys_HEADERS += include/sys/timeffc.h +include_sys_HEADERS += include/sys/timepps.h +include_sys_HEADERS += include/sys/timetc.h +include_sys_HEADERS += include/sys/timex.h +include_sys_HEADERS += include/sys/utsname.h + +include_utf8procdir = $(includedir)/utf8proc +include_utf8proc_HEADERS = +include_utf8proc_HEADERS += include/utf8proc/utf8proc.h + +include_uuiddir = $(includedir)/uuid +include_uuid_HEADERS = +include_uuid_HEADERS += include/uuid/uuid.h diff --git a/cpukit/include/adainclude/preinstall.am b/cpukit/include/adainclude/preinstall.am deleted file mode 100644 index e41443a862..0000000000 --- a/cpukit/include/adainclude/preinstall.am +++ /dev/null @@ -1,177 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -if RTEMS_ADA -$(PROJECT_INCLUDE)/adainclude/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/adainclude - @: > $(PROJECT_INCLUDE)/adainclude/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - -$(PROJECT_INCLUDE)/adainclude/rtems.adb: rtems.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems.adb - -$(PROJECT_INCLUDE)/adainclude/rtems.ads: rtems.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-barrier.adb: rtems-barrier.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-barrier.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-barrier.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-barrier.ads: rtems-barrier.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-barrier.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-barrier.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-clock.adb: rtems-clock.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-clock.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-clock.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-clock.ads: rtems-clock.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-clock.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-clock.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-cpu_usage.ads: rtems-cpu_usage.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-cpu_usage.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-cpu_usage.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-event.adb: rtems-event.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-event.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-event.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-event.ads: rtems-event.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-event.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-event.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-extension.adb: rtems-extension.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-extension.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-extension.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-extension.ads: rtems-extension.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-extension.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-extension.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-fatal.adb: rtems-fatal.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-fatal.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-fatal.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-fatal.ads: rtems-fatal.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-fatal.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-fatal.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-interrupt.ads: rtems-interrupt.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-interrupt.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-interrupt.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-io.adb: rtems-io.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-io.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-io.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-io.ads: rtems-io.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-io.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-io.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-message_queue.adb: rtems-message_queue.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-message_queue.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-message_queue.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-message_queue.ads: rtems-message_queue.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-message_queue.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-message_queue.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-multiprocessing.adb: rtems-multiprocessing.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-multiprocessing.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-multiprocessing.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-multiprocessing.ads: rtems-multiprocessing.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-multiprocessing.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-multiprocessing.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-object.adb: rtems-object.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-object.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-object.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-object.ads: rtems-object.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-object.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-object.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-partition.adb: rtems-partition.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-partition.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-partition.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-partition.ads: rtems-partition.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-partition.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-partition.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-port.adb: rtems-port.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-port.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-port.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-port.ads: rtems-port.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-port.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-port.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-rate_monotonic.adb: rtems-rate_monotonic.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-rate_monotonic.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-rate_monotonic.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-rate_monotonic.ads: rtems-rate_monotonic.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-rate_monotonic.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-rate_monotonic.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-region.adb: rtems-region.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-region.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-region.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-region.ads: rtems-region.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-region.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-region.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-semaphore.adb: rtems-semaphore.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-semaphore.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-semaphore.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-semaphore.ads: rtems-semaphore.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-semaphore.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-semaphore.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-signal.adb: rtems-signal.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-signal.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-signal.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-signal.ads: rtems-signal.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-signal.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-signal.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-stack_checker.ads: rtems-stack_checker.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-stack_checker.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-stack_checker.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-tasks.adb: rtems-tasks.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-tasks.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-tasks.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-tasks.ads: rtems-tasks.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-tasks.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-tasks.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-timer.adb: rtems-timer.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-timer.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-timer.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-timer.ads: rtems-timer.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-timer.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-timer.ads -endif diff --git a/cpukit/include/aio.h b/cpukit/include/aio.h new file mode 100644 index 0000000000..95ed0fdb6c --- /dev/null +++ b/cpukit/include/aio.h @@ -0,0 +1,193 @@ +/** + * @file + * + * @brief POSIX Asynchronous Input and Output + * + * This file contains the definitions related to POSIX Asynchronous + * Input and Output, + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _AIO_H +#define _AIO_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup POSIX_AIO POSIX Asynchronous I/O Support + * + * @ingroup POSIXAPI + * + * @brief POSIX Asynchronous Input and Output + * + */ +/**@{**/ + +#if defined(_POSIX_ASYNCHRONOUS_IO) + +/* + * 6.7.1 Data Definitions for Asynchronous Input and Output, + * P1003.1b-1993, p. 151 + */ + +#include +#include +#include +#include + +/* + * 6.7.1.2 Manifest Constants, P1003.1b-1993, p. 153 + */ + +#define AIO_CANCELED 0 /* all requested operations have been canceled */ +#define AIO_NOTCANCELED 1 /* some of the operations could not be canceled */ + /* since they are in progress */ +#define AIO_ALLDONE 2 /* none of the requested operations could be */ + /* canceled since they are already complete */ + +/* lio_listio() options */ + +/* + * LIO modes + */ +#define LIO_WAIT 0 /* calling process is to suspend until the */ + /* operation is complete */ +#define LIO_NOWAIT 1 /* calling process is to continue execution while */ + /* the operation is performed and no notification */ + /* shall be given when the operation is completed */ + +/* + * LIO opcodes + */ +#define LIO_NOP 0 /* no transfer is requested */ +#define LIO_READ 1 /* request a read() */ +#define LIO_WRITE 2 /* request a write() */ +#define LIO_SYNC 3 /* needed by aio_fsync() */ + +/* + * 6.7.1.1 Asynchronous I/O Control Block, P1003.1b-1993, p. 151 + */ + +struct aiocb { + /* public */ + int aio_fildes; /* File descriptor */ + off_t aio_offset; /* File offset */ + volatile void *aio_buf; /* Location of buffer */ + size_t aio_nbytes; /* Length of transfer */ + int aio_reqprio; /* Request priority offset */ + struct sigevent aio_sigevent; /* Signal number and value */ + int aio_lio_opcode; /* Operation to be performed */ + /* private */ + int error_code; /* Used for aio_error() */ + ssize_t return_value; /* Used for aio_return() */ +}; + +/* + * 6.7.2 Asynchronous Read, P1003.1b-1993, p. 154 + */ + +int aio_read( + struct aiocb *aiocbp +); + +/* + * 6.7.3 Asynchronous Write, P1003.1b-1993, p. 155 + */ + +int aio_write( + struct aiocb *aiocbp +); + +/* + * 6.7.4 List Directed I/O, P1003.1b-1993, p. 158 + */ + +int lio_listio( + int mode, + struct aiocb *__restrict const list[__restrict], + int nent, + struct sigevent *__restrict sig +); + +/* + * 6.7.5 Retrieve Error of Asynchronous I/O Operation, P1003.1b-1993, p. 161 + */ + +int aio_error( + const struct aiocb *aiocbp +); + +/* + * 6.7.6 Retrieve Return Status of Asynchronous I/O Operation, + * P1003.1b-1993, p. 162 + */ + +ssize_t aio_return( + const struct aiocb *aiocbp +); + +/** + * @brief Cancel asynchronous I/O operation. + * + * 6.7.7 Cancel Asynchronous I/O Operation, P1003.1b-1993, p. 163 + * + * @param[in] filedes is the file descriptor + * @param[in] aiocbp is a pointer to the asynchronous I/O control block + * + * @retval AIO_CANCELED The requested operation(s) were canceled. + * @retval AIO_NOTCANCELED Some of the requested operation(s) cannot be + * canceled since they are in progress. + * @retval AIO_ALLDONE None of the requested operation(s) could be canceled + * since they are already complete + */ +int aio_cancel( + int filedes, + struct aiocb *aiocbp +); + +/* + * 6.7.7 Wait for Asynchronous I/O Request, P1003.1b-1993, p. 164 + */ + +int aio_suspend( + const struct aiocb * const list[], + int nent, + const struct timespec *timeout +); + +#if defined(_POSIX_SYNCHRONIZED_IO) + +/* + * 6.7.9 Asynchronous File Synchronization, P1003.1b-1993, p. 166 + */ + +int aio_fsync( + int op, + struct aiocb *aiocbp +); + +#endif /* _POSIX_SYNCHRONIZED_IO */ + +#endif /* _POSIX_ASYNCHRONOUS_IO */ + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/dev/i2c/eeprom.h b/cpukit/include/dev/i2c/eeprom.h new file mode 100644 index 0000000000..73df5ad9f4 --- /dev/null +++ b/cpukit/include/dev/i2c/eeprom.h @@ -0,0 +1,58 @@ +/** + * @file + * + * @brief EEPROM Driver API + * + * @ingroup I2CEEPROM + */ + +/* + * Copyright (c) 2014 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _DEV_I2C_EEPROM_H +#define _DEV_I2C_EEPROM_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup I2CEEPROM EEPROM Driver + * + * @ingroup I2CDevice + * + * @brief Driver for EEPROM device. + * + * @{ + */ + +int i2c_dev_register_eeprom( + const char *bus_path, + const char *dev_path, + uint16_t i2c_address, + uint16_t address_bytes, + uint16_t page_size_in_bytes, + uint32_t size_in_bytes, + uint32_t program_timeout_in_ms +); + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _DEV_I2C_EEPROM_H */ diff --git a/cpukit/include/dev/i2c/fpga-i2c-slave.h b/cpukit/include/dev/i2c/fpga-i2c-slave.h new file mode 100644 index 0000000000..c10b26ac5b --- /dev/null +++ b/cpukit/include/dev/i2c/fpga-i2c-slave.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2016-2017 Chris Johns + * All rights reserved. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +/* + * I2C slave for testing: + * https://github.com/oetr/FPGA-I2C-Slave + */ + +#ifndef FPGA_I2C_SLAVE_H +#define FPGA_I2C_SLAVE_H + +#include + +int i2c_dev_register_fpga_i2c_slave(const char* bus_path, + const char* dev_path, + uint16_t address, + size_t size); + +#endif diff --git a/cpukit/include/dev/i2c/gpio-nxp-pca9535.h b/cpukit/include/dev/i2c/gpio-nxp-pca9535.h new file mode 100644 index 0000000000..1ebc1a3d4d --- /dev/null +++ b/cpukit/include/dev/i2c/gpio-nxp-pca9535.h @@ -0,0 +1,123 @@ +/** + * @file + * + * @brief GPIO NXP PCA9535 Driver API + * + * @ingroup I2CGPIONXPPCA9535 + */ + +/* + * Copyright (c) 2014 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _DEV_I2C_GPIO_NXP_PCA9539_H +#define _DEV_I2C_GPIO_NXP_PCA9539_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup I2CGPIONXPPCA9535 GPIO NXP PCA9535 Driver + * + * @ingroup I2CDevice + * + * @brief Driver for NXP PCA9535 16-bit GPIO device. + * + * @{ + */ + +int i2c_dev_register_gpio_nxp_pca9535( + const char *bus_path, + const char *dev_path, + uint16_t address +); + +#define GPIO_NXP_PCA9535_GET_INPUT (I2C_DEV_IO_CONTROL + 0) + +#define GPIO_NXP_PCA9535_GET_OUTPUT (I2C_DEV_IO_CONTROL + 1) + +#define GPIO_NXP_PCA9535_SET_OUTPUT (I2C_DEV_IO_CONTROL + 2) + +#define GPIO_NXP_PCA9535_CLEAR_AND_SET_OUTPUT (I2C_DEV_IO_CONTROL + 3) + +#define GPIO_NXP_PCA9535_GET_POL_INV (I2C_DEV_IO_CONTROL + 4) + +#define GPIO_NXP_PCA9535_SET_POL_INV (I2C_DEV_IO_CONTROL + 5) + +#define GPIO_NXP_PCA9535_GET_CONFIG (I2C_DEV_IO_CONTROL + 6) + +#define GPIO_NXP_PCA9535_SET_CONFIG (I2C_DEV_IO_CONTROL + 7) + +static inline int gpio_nxp_pca9535_get_input(int fd, uint16_t *val) +{ + return ioctl(fd, GPIO_NXP_PCA9535_GET_INPUT, val); +} + +static inline int gpio_nxp_pca9535_get_output(int fd, uint16_t *val) +{ + return ioctl(fd, GPIO_NXP_PCA9535_GET_OUTPUT, val); +} + +static inline int gpio_nxp_pca9535_set_output(int fd, uint16_t val) +{ + return ioctl(fd, GPIO_NXP_PCA9535_SET_OUTPUT, (void *)(uintptr_t) val); +} + +static inline int gpio_nxp_pca9535_clear_and_set_output( + int fd, + uint16_t clear, + uint16_t set +) +{ + uint32_t clear_and_set = ((uint32_t) set << 16) | (uint32_t) clear; + + return ioctl( + fd, + GPIO_NXP_PCA9535_CLEAR_AND_SET_OUTPUT, + (void *)(uintptr_t) clear_and_set + ); +} + +static inline int gpio_nxp_pca9535_get_polarity_inversion( + int fd, + uint16_t *val +) +{ + return ioctl(fd, GPIO_NXP_PCA9535_GET_POL_INV, val); +} + +static inline int gpio_nxp_pca9535_set_polarity_inversion(int fd, uint16_t val) +{ + return ioctl(fd, GPIO_NXP_PCA9535_SET_POL_INV, (void *)(uintptr_t) val); +} + +static inline int gpio_nxp_pca9535_get_config(int fd, uint16_t *val) +{ + return ioctl(fd, GPIO_NXP_PCA9535_GET_CONFIG, val); +} + +static inline int gpio_nxp_pca9535_set_config(int fd, uint16_t val) +{ + return ioctl(fd, GPIO_NXP_PCA9535_SET_CONFIG, (void *)(uintptr_t) val); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _DEV_I2C_GPIO_NXP_PCA9539_H */ diff --git a/cpukit/include/dev/i2c/i2c.h b/cpukit/include/dev/i2c/i2c.h new file mode 100644 index 0000000000..2ace4fcf64 --- /dev/null +++ b/cpukit/include/dev/i2c/i2c.h @@ -0,0 +1,432 @@ +/** + * @file + * + * @brief Inter-Integrated Circuit (I2C) Driver API + * + * @ingroup I2C + */ + +/* + * Copyright (c) 2014 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _DEV_I2C_I2C_H +#define _DEV_I2C_I2C_H + +#include +#include + +#include +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +typedef struct i2c_msg i2c_msg; + +typedef struct i2c_bus i2c_bus; + +typedef struct i2c_dev i2c_dev; + +typedef struct i2c_rdwr_ioctl_data i2c_rdwr_ioctl_data; + +/** + * @defgroup I2C Inter-Integrated Circuit (I2C) Driver + * + * @brief Inter-Integrated Circuit (I2C) bus and device driver support. + * + * @{ + */ + +/** + * @defgroup I2CBus I2C Bus Driver + * + * @ingroup I2C + * + * @{ + */ + +/** + * @name I2C IO Control Commands + * + * @{ + */ + +/** + * @brief Obtains the bus. + * + * This command has no argument. + */ +#define I2C_BUS_OBTAIN 0x800 + +/** + * @brief Releases the bus. + * + * This command has no argument. + */ +#define I2C_BUS_RELEASE 0x801 + +/** + * @brief Gets the bus control. + * + * The argument type is a pointer to i2c_bus pointer. + */ +#define I2C_BUS_GET_CONTROL 0x802 + +/** + * @brief Sets the bus clock in Hz. + * + * The argument type is unsigned long. + */ +#define I2C_BUS_SET_CLOCK 0x803 + +/** @} */ + +/** + * @brief Default I2C bus clock in Hz. + */ +#define I2C_BUS_CLOCK_DEFAULT 100000 + +/** + * @brief I2C bus control. + */ +struct i2c_bus { + /** + * @brief Transfers I2C messages. + * + * @param[in] bus The bus control. + * @param[in] msgs The messages to transfer. + * @param[in] msg_count The count of messages to transfer. It must be + * positive. + * + * @retval 0 Successful operation. + * @retval negative Negative error number in case of an error. + */ + int (*transfer)(i2c_bus *bus, i2c_msg *msgs, uint32_t msg_count); + + /** + * @brief Sets the bus clock. + * + * @param[in] bus The bus control. + * @param[in] clock The desired bus clock in Hz. + * + * @retval 0 Successful operation. + * @retval negative Negative error number in case of an error. + */ + int (*set_clock)(i2c_bus *bus, unsigned long clock); + + /** + * @brief Destroys the bus. + * + * @param[in] bus The bus control. + */ + void (*destroy)(i2c_bus *bus); + + /** + * @brief Mutex to protect the bus access. + */ + rtems_id mutex; + + /** + * @brief Default slave device address. + */ + uint16_t default_address; + + /** + * @brief Use 10-bit addresses. + */ + bool ten_bit_address; + + /** + * @brief Use SMBus PEC. + */ + bool use_pec; + + /** + * @brief Transfer retry count. + */ + unsigned long retries; + + /** + * @brief Transaction timeout in ticks. + */ + rtems_interval timeout; + + /** + * @brief Controller functionality. + */ + unsigned long functionality; +}; + +/** + * @brief Initializes a bus control. + * + * After a sucessful initialization the bus control must be destroyed via + * i2c_bus_destroy(). A registered bus control will be automatically destroyed + * in case the device file is unlinked. Make sure to call i2c_bus_destroy() in + * a custom destruction handler. + * + * @param[in] bus The bus control. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The errno is set to indicate the error. + * + * @see i2c_bus_register() + */ +int i2c_bus_init(i2c_bus *bus); + +/** + * @brief Allocates a bus control from the heap and initializes it. + * + * After a sucessful allocation and initialization the bus control must be + * destroyed via i2c_bus_destroy_and_free(). A registered bus control will be + * automatically destroyed in case the device file is unlinked. Make sure to + * call i2c_bus_destroy_and_free() in a custom destruction handler. + * + * @param[in] size The size of the bus control. This enables the addition of + * bus controller specific data to the base bus control. The bus control is + * zero initialized. + * + * @retval non-NULL The new bus control. + * @retval NULL An error occurred. The errno is set to indicate the error. + * + * @see i2c_bus_register() + */ +i2c_bus *i2c_bus_alloc_and_init(size_t size); + +/** + * @brief Destroys a bus control. + * + * @param[in] bus The bus control. + */ +void i2c_bus_destroy(i2c_bus *bus); + +/** + * @brief Destroys a bus control and frees its memory. + * + * @param[in] bus The bus control. + */ +void i2c_bus_destroy_and_free(i2c_bus *bus); + +/** + * @brief Registers a bus control. + * + * This function claims ownership of the bus control regardless if the + * registration is successful or not. + * + * @param[in] bus The bus control. + * @param[in] bus_path The path to the bus device file. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The errno is set to indicate the error. + */ +int i2c_bus_register( + i2c_bus *bus, + const char *bus_path +); + +/** + * @brief Obtains the bus. + * + * @param[in] bus The bus control. + */ +void i2c_bus_obtain(i2c_bus *bus); + +/** + * @brief Releases the bus. + * + * @param[in] bus The bus control. + */ +void i2c_bus_release(i2c_bus *bus); + +/** + * @brief Transfers I2C messages. + * + * The bus is obtained before the transfer and released afterwards. + * + * @param[in] bus The bus control. + * @param[in] msgs The messages to transfer. + * @param[in] msg_count The count of messages to transfer. It must be + * positive. + * + * @retval 0 Successful operation. + * @retval negative Negative error number in case of an error. + */ +int i2c_bus_transfer(i2c_bus *bus, i2c_msg *msgs, uint32_t msg_count); + +/** @} */ + +/** + * @defgroup I2CDevice I2C Device Driver + * + * @ingroup I2C + * + * @{ + */ + +/** + * @brief Base number for device IO control commands. + */ +#define I2C_DEV_IO_CONTROL 0x900 + +/** + * @brief I2C slave device control. + */ +struct i2c_dev { + /** + * @brief Reads from the device. + * + * @retval non-negative Bytes transferred from device. + * @retval negative Negative error number in case of an error. + */ + ssize_t (*read)(i2c_dev *dev, void *buf, size_t n, off_t offset); + + /** + * @brief Writes to the device. + * + * @retval non-negative Bytes transferred to device. + * @retval negative Negative error number in case of an error. + */ + ssize_t (*write)(i2c_dev *dev, const void *buf, size_t n, off_t offset); + + /** + * @brief Device IO control. + * + * @retval 0 Successful operation. + * @retval negative Negative error number in case of an error. + */ + int (*ioctl)(i2c_dev *dev, ioctl_command_t command, void *arg); + + /** + * @brief Gets the file size. + */ + off_t (*get_size)(i2c_dev *dev); + + /** + * @brief Gets the file block size. + */ + blksize_t (*get_block_size)(i2c_dev *dev); + + /** + * @brief Destroys the device. + */ + void (*destroy)(i2c_dev *dev); + + /** + * @brief The bus control. + */ + i2c_bus *bus; + + /** + * @brief The device address. + */ + uint16_t address; + + /** + * @brief File descriptor of the bus. + * + * This prevents destruction of the bus since we hold a reference to it with + * this. + */ + int bus_fd; +}; + + +/** + * @brief Initializes a device control. + * + * After a sucessful initialization the device control must be destroyed via + * i2c_dev_destroy(). A registered device control will be automatically + * destroyed in case the device file is unlinked. Make sure to call + * i2c_dev_destroy_and_free() in a custom destruction handler. + * + * @param[in] device The device control. + * @param[in] bus_path The path to the bus device file. + * @param[in] address The address of the device. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The errno is set to indicate the error. + * + * @see i2c_dev_register() + */ +int i2c_dev_init(i2c_dev *dev, const char *bus_path, uint16_t address); + +/** + * @brief Allocates a device control from the heap and initializes it. + * + * After a sucessful allocation and initialization the device control must be + * destroyed via i2c_dev_destroy_and_free(). A registered device control will + * be automatically destroyed in case the device file is unlinked. Make sure + * to call i2c_dev_destroy_and_free() in a custom destruction handler. + * + * @param[in] size The size of the device control. This enables the addition + * of device specific data to the base device control. The device control is + * zero initialized. + * @param[in] bus_path The path to the bus device file. + * @param[in] address The address of the device. + * + * @retval non-NULL The new device control. + * @retval NULL An error occurred. The errno is set to indicate the error. + * + * @see i2c_dev_register() + */ +i2c_dev *i2c_dev_alloc_and_init( + size_t size, + const char *bus_path, + uint16_t address +); + +/** + * @brief Destroys a device control. + * + * @param[in] dev The device control. + */ +void i2c_dev_destroy(i2c_dev *dev); + +/** + * @brief Destroys a device control and frees its memory. + * + * @param[in] dev The device control. + */ +void i2c_dev_destroy_and_free(i2c_dev *dev); + +/** + * @brief Registers a device control. + * + * This function claims ownership of the device control regardless if the + * registration is successful or not. + * + * @param[in] dev The dev control. + * @param[in] dev_path The path to the device file of the device. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The errno is set to indicate the error. + */ +int i2c_dev_register( + i2c_dev *dev, + const char *dev_path +); + +/** @} */ /* end of i2c device driver */ + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _DEV_I2C_I2C_H */ diff --git a/cpukit/include/dev/i2c/sensor-lm75a.h b/cpukit/include/dev/i2c/sensor-lm75a.h new file mode 100644 index 0000000000..e1957dad19 --- /dev/null +++ b/cpukit/include/dev/i2c/sensor-lm75a.h @@ -0,0 +1,125 @@ +/** + * @file + * + * @brief Temperature Sensor LM75A Driver API + * + * @ingroup I2CSensorLM75A + */ + +/* + * Copyright (c) 2017 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _DEV_I2C_SENSOR_LM75A_H +#define _DEV_I2C_SENSOR_LM75A_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup I2CSensorLM75A Temperature Sensor LM75A Driver + * + * @ingroup I2CDevice + * + * @brief Driver for NXP or Texas Instruments LM75A temperature sensor. + * + * @{ + */ + +int i2c_dev_register_sensor_lm75a( + const char *bus_path, + const char *dev_path, + uint16_t address +); + +typedef enum { + SENSOR_LM75A_GET_CONF = I2C_DEV_IO_CONTROL, + SENSOR_LM75A_SET_CONF, + SENSOR_LM75A_CLEAR_AND_SET_CONF, + SENSOR_LM75A_GET_TEMP, + SENSOR_LM75A_GET_TOS, + SENSOR_LM75A_SET_TOS, + SENSOR_LM75A_GET_THYST, + SENSOR_LM75A_SET_THYST +} sensor_lm75a_command; + +static inline int sensor_lm75a_get_conf(int fd, uint8_t *val) +{ + return ioctl(fd, SENSOR_LM75A_GET_CONF, val); +} + +static inline int sensor_lm75a_set_conf(int fd, uint8_t val) +{ + return ioctl(fd, SENSOR_LM75A_SET_CONF, (void *)(uintptr_t) val); +} + +static inline int sensor_lm75a_clear_and_set_conf( + int fd, + uint8_t clear, + uint8_t set +) +{ + uint16_t clear_and_set = (uint16_t) (((uint16_t) set << 8) | clear); + + return ioctl( + fd, + SENSOR_LM75A_CLEAR_AND_SET_CONF, + (void *)(uintptr_t) clear_and_set + ); +} + +static inline int sensor_lm75a_get_temp(int fd, int16_t *val) +{ + return ioctl(fd, SENSOR_LM75A_GET_TEMP, val); +} + +static inline int sensor_lm75a_get_temp_celsius(int fd, double *celsius) +{ + int rv; + int16_t val; + + rv = ioctl(fd, SENSOR_LM75A_GET_TEMP, &val); + *celsius = (((int) val) >> 5) * 0.125; + return rv; +} + +static inline int sensor_lm75a_get_tos(int fd, uint16_t *val) +{ + return ioctl(fd, SENSOR_LM75A_GET_TOS, val); +} + +static inline int sensor_lm75a_set_tos(int fd, uint16_t val) +{ + return ioctl(fd, SENSOR_LM75A_SET_TOS, (void *)(uintptr_t) val); +} + +static inline int sensor_lm75a_get_thyst(int fd, uint16_t *val) +{ + return ioctl(fd, SENSOR_LM75A_GET_THYST, val); +} + +static inline int sensor_lm75a_set_thyst(int fd, uint16_t val) +{ + return ioctl(fd, SENSOR_LM75A_SET_THYST, (void *)(uintptr_t) val); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _DEV_I2C_SENSOR_LM75A_H */ diff --git a/cpukit/include/dev/i2c/switch-nxp-pca9548a.h b/cpukit/include/dev/i2c/switch-nxp-pca9548a.h new file mode 100644 index 0000000000..ce8ef2c809 --- /dev/null +++ b/cpukit/include/dev/i2c/switch-nxp-pca9548a.h @@ -0,0 +1,68 @@ +/** + * @file + * + * @brief Switch NXP PCA9548A Driver API + * + * @ingroup I2CSWITCHNXPPCA9548A + */ + +/* + * Copyright (c) 2014 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _DEV_I2C_SWITCH_NXP_PCA9548A_H +#define _DEV_I2C_SWITCH_NXP_PCA9548A_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup I2CSWITCHNXPPCA9548A Switch NXP PCA9535 Driver + * + * @ingroup I2CDevice + * + * @brief Driver for NXP PCA9548A 8-channel switch device. + * + * @{ + */ + +int i2c_dev_register_switch_nxp_pca9548a( + const char *bus_path, + const char *dev_path, + uint16_t address +); + +#define SWITCH_NXP_PCA9548A_GET_CONTROL (I2C_DEV_IO_CONTROL + 0) + +#define SWITCH_NXP_PCA9548A_SET_CONTROL (I2C_DEV_IO_CONTROL + 1) + +static inline int switch_nxp_pca9548a_get_control(int fd, uint8_t *val) +{ + return ioctl(fd, SWITCH_NXP_PCA9548A_GET_CONTROL, val); +} + +static inline int switch_nxp_pca9548a_set_control(int fd, uint8_t val) +{ + return ioctl(fd, SWITCH_NXP_PCA9548A_SET_CONTROL, (void *)(uintptr_t) val); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _DEV_I2C_SWITCH_NXP_PCA9548A_H */ diff --git a/cpukit/include/dev/i2c/ti-ads-16bit-adc.h b/cpukit/include/dev/i2c/ti-ads-16bit-adc.h new file mode 100644 index 0000000000..40d680da88 --- /dev/null +++ b/cpukit/include/dev/i2c/ti-ads-16bit-adc.h @@ -0,0 +1,203 @@ +/* + * Copyright (c) 2016-2017 Chris Johns + * All rights reserved. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +/* + * TI ADS1113 and ADS1115. + * http://www.ti.com/product/ads1113/description + */ + +#ifndef TI_ADS1113_ADS1115_H +#define TI_ADS1113_ADS1115_H + +#include + +/* + * Supported devices. Please others once tested. + */ +typedef enum { + TI_ADS1113, + TI_ADS1114, + TI_ADS1115 +} ti_ads_adc; + +/* + * Multiplexer interface. Avalable on ADS1115. + */ +typedef enum { + TI_ADS_MUX_ApA0_AnA1 = 0, /* default */ + TI_ADS_MUX_ApA0_AnA3 = 1, + TI_ADS_MUX_ApA1_AnA3 = 2, + TI_ADS_MUX_ApA2_AnA3 = 3, + TI_ADS_MUX_ApA0_AnGND = 4, + TI_ADS_MUX_ApA1_AnGND = 5, + TI_ADS_MUX_ApA2_AnGND = 6, + TI_ADS_MUX_ApA3_AnGND = 7 +} ti_ads_adc_mux; + +/* + * Programmable Gain Amplifier. Avalable on ADS1114 and ADS1115. + */ +typedef enum { + TI_ADS_PGA_FS_6_144V = 0, + TI_ADS_PGA_FS_4_096V = 1, + TI_ADS_PGA_FS_2_048V = 2, /* default */ + TI_ADS_PGA_FS_1_024V = 3, + TI_ADS_PGA_FS_0_512V = 4, + TI_ADS_PGA_FS_0_256V = 5, + TI_ADS_PGA_FS_0_256V_2 = 6, + TI_ADS_PGA_FS_0_256V_3 = 7, +} ti_ads_adc_pga; + +/* + * Mode. + */ +typedef enum { + TI_ADS_MODE_CONTINUOUS = 0, + TI_ADS_MODE_SINGLE_SHOT = 1, /* default */ +} ti_ads_adc_mode; + +/* + * Data rate. + */ +typedef enum { + TI_ADS_DATARATE_8SPS = 0, + TI_ADS_DATARATE_16SPS = 1, + TI_ADS_DATARATE_32SPS = 2, + TI_ADS_DATARATE_64SPS = 3, + TI_ADS_DATARATE_128SPS = 4, /* default */ + TI_ADS_DATARATE_250SPS = 5, + TI_ADS_DATARATE_475SPS = 6, + TI_ADS_DATARATE_860SPS = 7, +} ti_ads_adc_data_rate; + +/* + * Comparitor interface. Avalable on ADS1114 and ADS1115. + * + * Create a value to write. + */ +#define TI_ADS_COMP_MODE_HYSTERESIS (0 << 4) /* default */ +#define TI_ADS_COMP_MODE_WINDOW (1 << 4) +#define TI_ADS_COMP_POL_ACTIVE_LOW (0 << 3) /* default */ +#define TI_ADS_COMP_POL_ACTIVE_HIGH (1 << 3) +#define TI_ADS_COMP_LAT_NON_LATCHING (0 << 2) /* default */ +#define TI_ADS_COMP_LAT_LATCHING (1 << 2) +#define TI_ADS_COMP_QUE_DISABLE_COMP (3 << 0) /* default */ +#define TI_ADS_COMP_QUE_AFTER_4 (2 << 0) +#define TI_ADS_COMP_QUE_AFTER_2 (1 << 0) +#define TI_ADS_COMP_QUE_AFTER_1 (0 << 0) + +/* + * IO control interface. + * + * Note: if in Power-down single-shot mode (default) a conversion requires the + * device to power up and perform a conversion and this can take + * while. The TI_ADS_ADC_GET_CONV_WAIT call sets the micro-seconds to + * wait between polls. The actual rate will depend on the system tick. + */ +#define TI_ADS_ADC_GET_CONVERSION (I2C_DEV_IO_CONTROL + 0) +#define TI_ADS_ADC_SET_MUX (I2C_DEV_IO_CONTROL + 1) +#define TI_ADS_ADC_SET_PGA (I2C_DEV_IO_CONTROL + 2) +#define TI_ADS_ADC_SET_MODE (I2C_DEV_IO_CONTROL + 3) +#define TI_ADS_ADC_SET_DATA_RATE (I2C_DEV_IO_CONTROL + 4) +#define TI_ADS_ADC_SET_COMP (I2C_DEV_IO_CONTROL + 5) +#define TI_ADS_ADC_SET_LO_THRESH (I2C_DEV_IO_CONTROL + 6) +#define TI_ADS_ADC_SET_HI_THRESH (I2C_DEV_IO_CONTROL + 7) +#define TI_ADS_ADC_SET_CONV_WAIT (I2C_DEV_IO_CONTROL + 8) + +/* + * Register the device. + */ +int i2c_dev_register_ti_ads_adc(const char* bus_path, + const char* dev_path, + uint16_t address, + ti_ads_adc device); + +/* + * Perform a conversion. If the mode is single shot a single shot conversion is + * started and the call waits for the conversion to complete. + */ +static inline int +ti_ads_adc_convert(int fd, uint16_t* sample) +{ + return ioctl(fd, TI_ADS_ADC_GET_CONVERSION, sample); +} + +/* + * Set the multipler. + */ +static inline int +ti_ads_adc_set_mux(int fd, ti_ads_adc_mux mux) +{ + return ioctl(fd, TI_ADS_ADC_SET_MUX, (void *)(uintptr_t) mux); +} + +/* + * Set the PGA. + */ +static inline int +ti_ads_adc_set_pga(int fd, ti_ads_adc_pga pga) +{ + return ioctl(fd, TI_ADS_ADC_SET_PGA, (void *)(uintptr_t) pga); +} + +/* + * Set the mode. + */ +static inline int +ti_ads_adc_set_mode(int fd, ti_ads_adc_mode mode) +{ + return ioctl(fd, TI_ADS_ADC_SET_MODE, (void *)(uintptr_t) mode); +} + +/* + * Set the data rate. + */ +static inline int +ti_ads_adc_set_data_rate(int fd, ti_ads_adc_data_rate rate) +{ + return ioctl(fd, TI_ADS_ADC_SET_DATA_RATE, (void *)(uintptr_t) rate); +} + +/* + * Configure the comparator. + */ +static inline int +ti_ads_adc_set_comparator(int fd, uint16_t comp) +{ + return ioctl(fd, TI_ADS_ADC_SET_COMP, (void *)(uintptr_t) comp); +} + +/* + * Set the lower threshold. + */ +static inline int +ti_ads_adc_set_low_threshold(int fd, uint16_t level) +{ + return ioctl(fd, TI_ADS_ADC_SET_LO_THRESH, (void *)(uintptr_t) level); +} + +/* + * Set the upper threshold. + */ +static inline int +ti_ads_adc_set_high_threshold(int fd, uint16_t level) +{ + return ioctl(fd, TI_ADS_ADC_SET_HI_THRESH, (void *)(uintptr_t) level); +} + +/* + * Set the conversion poll wait period. + */ +static inline int +ti_ads_adc_set_conversion_poll_wait(int fd, uint32_t micro_seconds) +{ + return ioctl(fd, TI_ADS_ADC_SET_CONV_WAIT, (void *)(uintptr_t) micro_seconds); +} + +#endif diff --git a/cpukit/include/dev/i2c/ti-lm25066a.h b/cpukit/include/dev/i2c/ti-lm25066a.h new file mode 100644 index 0000000000..4429f0fc70 --- /dev/null +++ b/cpukit/include/dev/i2c/ti-lm25066a.h @@ -0,0 +1,190 @@ +/* + * Copyright (c) 2016-2017 Chris Johns + * All rights reserved. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +/* + * TI LM25066A + * http://www.ti.com/product/LM25066A + */ + +#ifndef TI_LM25066A_H +#define TI_LM25066A_H + +#include + +/* + * PM Bus Command interface. + * + * The keys are: + * IO : IO direction R=read W=write + * SZ : Size in bytes. + */ +typedef enum +{ /* IO SZ Name */ + TI_LM25066A_OPERATION = 0, /* R 1 PMBus */ + TI_LM25066A_CLEAR_FAULTS = 1, /* W 0 PMBus */ + TI_LM25066A_CAPABILITY = 2, /* R 1 PMBus */ + TI_LM25066A_VOUT_UV_WARN_LIMIT = 3, /* RW 2 PMBus */ + TI_LM25066A_OT_FAULT_LIMIT = 4, /* RW 2 PMBus */ + TI_LM25066A_OT_WARN_LIMIT = 5, /* RW 2 PMBus */ + TI_LM25066A_VIN_OV_WARN_LIMIT = 6, /* RW 2 PMBus */ + TI_LM25066A_VIN_UV_WARN_LIMIT = 7, /* RW 2 PMBus */ + TI_LM25066A_STATUS_BYTE = 8, /* R 1 PMBus */ + TI_LM25066A_STATUS_WORD = 9, /* R 2 PMBus */ + TI_LM25066A_STATUS_VOUT = 10, /* R 1 PMBus */ + TI_LM25066A_STATUS_INPUT = 11, /* R 1 PMBus */ + TI_LM25066A_STATUS_TEMPERATURE = 12, /* R 1 PMBus */ + TI_LM25066A_STATUS_CML = 13, /* R 1 PMBus */ + TI_LM25066A_STATUS_MFR_SPECIFIC = 14, /* R 1 PMBus */ + TI_LM25066A_READ_VIN = 15, /* R 2 PMBus */ + TI_LM25066A_READ_VOUT = 16, /* R 2 PMBus */ + TI_LM25066A_READ_TEMPERATURE_1 = 17, /* R 2 PMBus */ + TI_LM25066A_MFR_ID = 18, /* R 3 PMBus */ + TI_LM25066A_MFR_MODEL = 19, /* R 8 PMBus */ + TI_LM25066A_MFR_REVISION = 20, /* R 2 PMBus */ + TI_LM25066A_MFR_READ_VAUX = 21, /* R 2 MFR_SPECIFIC_00 */ + TI_LM25066A_MFR_READ_IIN = 22, /* R 2 MFR_SPECIFIC_01 */ + TI_LM25066A_MFR_READ_PIN = 23, /* R 2 MFR_SPECIFIC_02 */ + TI_LM25066A_MFR_IIN_OC_WARN_LIMIT = 24, /* RW 2 MFR_SPECIFIC_03 */ + TI_LM25066A_MFR_PIN_OP_WARN_LIMIT = 25, /* RW 2 MFR_SPECIFIC_04 */ + TI_LM25066A_MFR_PIN_PEAK = 26, /* R 2 MFR_SPECIFIC_05 */ + TI_LM25066A_MFR_CLEAR_PIN_PEAK = 27, /* W 0 MFR_SPECIFIC_06 */ + TI_LM25066A_MFR_GATE_MASK = 28, /* RW 1 MFR_SPECIFIC_07 */ + TI_LM25066A_MFR_ALERT_MASK = 29, /* RW 2 MFR_SPECIFIC_08 */ + TI_LM25066A_MFR_DEVICE_SETUP = 30, /* RW 1 MFR_SPECIFIC_09 */ + TI_LM25066A_MFR_BLOCK_READ = 31, /* R 12 MFR_SPECIFIC_10 */ + TI_LM25066A_MFR_SAMPLES_FOR_AVG = 32, /* RW 1 MFR_SPECIFIC_11 */ + TI_LM25066A_MFR_READ_AVG_VIN = 33, /* R 2 MFR_SPECIFIC_12 */ + TI_LM25066A_MFR_READ_AVG_VOUT = 34, /* R 2 MFR_SPECIFIC_13 */ + TI_LM25066A_MFR_READ_AVG_IIN = 35, /* R 2 MFR_SPECIFIC_14 */ + TI_LM25066A_MFR_READ_AVG_PIN = 36, /* R 2 MFR_SPECIFIC_15 */ + TI_LM25066A_MFR_BLACK_BOX_READ = 37, /* R 12 MFR_SPECIFIC_16 */ + TI_LM25066A_MFR_DIAGNOSTIC_WORD_READ = 38, /* R 2 MFR_SPECIFIC_17 */ + TI_LM25066A_MFR_AVG_BLOCK_READ = 39, /* R 12 MFR_SPECIFIC_18 */ +} ti_lm25066a_cmd; + +/* + * Real world converters. Page 46 of the datasheet discusses reading and + * writing telemtry data and obtaining the real world values. There are 8 + * separate conversions using the same formula. + * + * The formula is: + * + * 1 -R + * X = - (Y x 10 - b) + * m + * + * X: the calculated "real world" value (volts, amps, watt, etc.) + * m: the slope coefficient + * Y: a two byte two's complement integer received from device + * b: the offset, a two byte two's complement integer + * R: the exponent, a one byte two's complement integer + * + * R in the table is inverted because we cannot store 0.01 in an int. This + * makes the equation: + * + * 1 Y + * X = - (- - b) + * m R + * + * The R value lets the integer result have decimal places. + * + * There are 8 conversion table entries listed in Table 41 of the + * data sheet. They are: + * + * 1. READ_VIN, READ_AVG_VIN, VIN_OV_WARN_LIMIT, VIN_UV_WARN_LIMIT + * 2. READ_VOUT, READ_AVG_VOUT, VOUT_UV_WARN_LIMIT + * 3. READ_VAUX + * 4.GND READ_IIN, READ_AVG_IIN, MFR_IIN_OC_WARN_LIMIT + * 4.VDD READ_IIN, READ_AVG_IIN, MFR_IIN_OC_WARN_LIMIT + * 5.GND READ_PIN, READ_AVG_PIN, READ_PIN_PEAK, MFR_PIN_OP_WARN_LIMIT + * 5.VCC READ_PIN, READ_AVG_PIN, READ_PIN_PEAK, MFR_PIN_OP_WARN_LIMIT + * 6. READ_TEMPERATURE_1, OT_WARN_LIMIT, OT_FAULT_LIMIT + * + * You need to provide 6 sets of conversion factors. Row 4 and 5 depend on how + * the device is wired. The driver will use the matching table row to convert + * the 2-complement 12 bit to a real world value. + */ +#define TI_LM25066A_CONVERSION_SIZE (6) +typedef struct +{ + int m; /* The slope coefficient */ + int b; /* The offset */ + int R; /* The inverted power of 10 of -R */ +} ti_lm25066a_conversion; + +/* + * IO control interface. + */ +#define TI_LM25066A_GET (I2C_DEV_IO_CONTROL + 0) +#define TI_LM25066A_SET (I2C_DEV_IO_CONTROL + 1) + +/* + * IO data types. + */ +typedef enum +{ + TI_LM25066A_8BIT = 0, + TI_LM25066A_16BIT = 1, + TI_LM25066A_VALUE = 2, + TI_LM25066A_VALUES = 3, + TI_LM25066A_STRING = 4, + TI_LM25066A_RAW = 5 +} ti_lm25066a_data; + +/* + * Struct to move data into and out of the driver. + */ +typedef struct +{ + ti_lm25066a_cmd cmd; + ti_lm25066a_data type; + union { + uint8_t u8; + uint16_t u16; + int value; + int values[6]; + char string[9]; + uint8_t* raw; + } data; +} ti_lm25066a_io; + +/* + * Register the device. + * + * The conversions table has 6 columns. + * + * The values are an integer so the decimal_point value scales the value so it + * can fit in an integer with the required number of decimal points. + */ +int i2c_dev_register_ti_lm25066a(const char* bus_path, + const char* dev_path, + uint16_t address, + const ti_lm25066a_conversion* const conversions, + const int decimal_points); + +/* + * Get. + */ +static inline int +ti_lm25066a_get(int fd, ti_lm25066a_io* io) +{ + return ioctl(fd, TI_LM25066A_GET, io); +} + +/* + * Set. + */ +static inline int +ti_lm25066a_set(int fd, ti_lm25066a_io* io) +{ + return ioctl(fd, TI_LM25066A_SET, io); +} + + +#endif diff --git a/cpukit/include/dev/i2c/ti-tmp112.h b/cpukit/include/dev/i2c/ti-tmp112.h new file mode 100644 index 0000000000..1b80fa6994 --- /dev/null +++ b/cpukit/include/dev/i2c/ti-tmp112.h @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2016-2017 Chris Johns + * All rights reserved. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +/* + * TI TMP112 + * http://www.ti.com/product/TMP112 + */ + +#ifndef TI_TMP112_H +#define TI_TMP112_H + +#include + +/* + * Confirguration. + */ +#define TI_TMP112_CR_0_25Hz (0 << 6) +#define TI_TMP112_CR_1Hz (1 << 6) +#define TI_TMP112_CR_4Hz (2 << 6) /* default */ +#define TI_TMP112_CR_8Hz (3 << 6) +#define TI_TMP112_EM_NORMAL (0 << 4) /* default */ +#define TI_TMP112_EM_EXTENDED (1 << 4) +#define TI_TMP112_SD_ON (0 << 8) /* default */ +#define TI_TMP112_SD_SHUTDOWN (1 << 8) +#define TI_TMP112_TM_COMPARATOR (0 << 9) /* default */ +#define TI_TMP112_TM_INTERRUPT (1 << 9) +#define TI_TMP112_POL_ALERT_LOW (0 << 10) /* default */ +#define TI_TMP112_POL_ALERT_HIGH (1 << 10) +#define TI_TMP112_FQL_1 (0 << 11) /* default */ +#define TI_TMP112_FQL_2 (1 << 11) +#define TI_TMP112_FQL_4 (2 << 11) +#define TI_TMP112_FQL_6 (3 << 11) + +/* + * IO control interface. + */ +#define TI_TMP112_GET_TEMP (I2C_DEV_IO_CONTROL + 0) +#define TI_TMP112_GET_TEMP_RAW (I2C_DEV_IO_CONTROL + 1) +#define TI_TMP112_SET_CONFIG (I2C_DEV_IO_CONTROL + 2) +#define TI_TMP112_SET_LOW_TEMP (I2C_DEV_IO_CONTROL + 3) +#define TI_TMP112_SET_HIGH_TEMP (I2C_DEV_IO_CONTROL + 4) + +/* + * Register the device. + */ +int i2c_dev_register_ti_tmp112(const char* bus_path, + const char* dev_path, + uint16_t address); + +/* + * Get the temperature in degrees C x 10000. To print you would so: + * + * printf("Temperature is %3d.%04d\n", temp / 10000, temp % 10000); + * + * If the device is shutdown a single conversion is made waiting for the + * conversion to complete. + */ +static inline int +ti_tmp112_get_temperature(int fd, int* temp) +{ + return ioctl(fd, TI_TMP112_GET_TEMP, temp); +} + +/* + * Get the temperature as the raw register value. + * + * If the device is shutdown a single conversion is made waiting for the + * conversion to complete. + */ +static inline int +ti_tmp112_get_temperature_raw(int fd, unsigned int* temp) +{ + return ioctl(fd, TI_TMP112_GET_TEMP_RAW, temp); +} + +/* + * Set the configuration. + */ +static inline int +ti_tmp112_adc_set_config(int fd, uint16_t config) +{ + return ioctl(fd, TI_TMP112_SET_CONFIG, (void *)(uintptr_t) config); +} + +/* + * Set the low temperature. + */ +static inline int +ti_tmp112_set_low_temperator(int fd, uint16_t temp) +{ + return ioctl(fd, TI_TMP112_SET_LOW_TEMP, (void *)(uintptr_t) temp); +} + +/* + * Set the high temperature. + */ +static inline int +ti_tmp112_adc_set_high_threshold(int fd, uint16_t level) +{ + return ioctl(fd, TI_TMP112_SET_HIGH_TEMP, (void *)(uintptr_t) level); +} + +#endif diff --git a/cpukit/include/dev/i2c/xilinx-axi-i2c.h b/cpukit/include/dev/i2c/xilinx-axi-i2c.h new file mode 100644 index 0000000000..fafac346ec --- /dev/null +++ b/cpukit/include/dev/i2c/xilinx-axi-i2c.h @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2016-2017 Chris Johns All rights reserved. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +/* + * Xilinx AXI IIC Interface v2.0. See PG090.pdf. + * + * Note, only master support is provided and no dynamic mode by design. + * + * The clock set up is to be handled by the IP integrator. There are too many + * factors handling this in software. + */ + + +#ifndef XILINX_AXI_I2C_H +#define XILINX_AXI_I2C_H + +#include + +/* + * The PL integrator controls the timing. This interface allows software to + * override those settings. It pays to check the timing with ChipScope. + * + * If you set the AXI bus frequency you can use the clock speed ioctl call to + * change the speed dymanically. The ioctl call overrides the defaults passed + * in. + * + * Set the valid mask to the values that are to be set. + */ +#define XILINX_AIX_I2C_AXI_CLOCK (1 << 0) +#define XILINX_AIX_I2C_TSUSTA (1 << 1) +#define XILINX_AIX_I2C_TSUSTO (1 << 2) +#define XILINX_AIX_I2C_THDSTA (1 << 3) +#define XILINX_AIX_I2C_TSUDAT (1 << 4) +#define XILINX_AIX_I2C_TBUF (1 << 5) +#define XILINX_AIX_I2C_THIGH (1 << 6) +#define XILINX_AIX_I2C_TLOW (1 << 7) +#define XILINX_AIX_I2C_THDDAT (1 << 8) +#define XILINX_AIX_I2C_ALL_REGS (XILINX_AIX_I2C_TSUSTA | \ + XILINX_AIX_I2C_TSUSTO | \ + XILINX_AIX_I2C_THDSTA | \ + XILINX_AIX_I2C_TSUDAT | \ + XILINX_AIX_I2C_TBUF | \ + XILINX_AIX_I2C_THIGH | \ + XILINX_AIX_I2C_TLOW | \ + XILINX_AIX_I2C_THDDAT) +typedef struct +{ + uint32_t valid_mask; + uint32_t AXI_CLOCK; + uint32_t SCL_INERTIAL_DELAY; + uint32_t TSUSTA; + uint32_t TSUSTO; + uint32_t THDSTA; + uint32_t TSUDAT; + uint32_t TBUF; + uint32_t THIGH; + uint32_t TLOW; + uint32_t THDDAT; +} xilinx_aix_i2c_timing; + +/* + * Register the driver. + * + * The driver can multipex a number of I2C buses (in master mode only) using + * the GPO port. The PL designer can use the output pins to select a bus. This + * is useful if connecting a number of slave devices that have limit selectable + * addresses. + * + * @param bus_path The driver's device path. + * @param register_base AXI base address. + * @param irq AXI FPGA interrupt. + * @param gpio_address Bits 12:15 of a slave address it written to the GPO. + * @param timing Override the default timing. NULL means no changes. + */ +int i2c_bus_register_xilinx_aix_i2c(const char* bus_path, + uintptr_t register_base, + rtems_vector_number irq, + bool ten_gpio, + const xilinx_aix_i2c_timing* timing); + +#endif diff --git a/cpukit/include/dev/serial/sc16is752.h b/cpukit/include/dev/serial/sc16is752.h new file mode 100644 index 0000000000..7e5b47aaa2 --- /dev/null +++ b/cpukit/include/dev/serial/sc16is752.h @@ -0,0 +1,262 @@ +/* + * Copyright (c) 2016 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _DEV_SERIAL_SC16IS752_H +#define _DEV_SERIAL_SC16IS752_H + +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup SC16IS752 SC16IS752 Serial Device Driver + * + * @ingroup TermiostypesSupport + */ + +typedef enum { + SC16IS752_MODE_RS232, + SC16IS752_MODE_RS485 +} sc16is752_mode; + +typedef struct sc16is752_context sc16is752_context; + +/** + * @brief SC16IS752 device context. + */ +struct sc16is752_context { + rtems_termios_device_context base; + + /** + * @brief Writes a register. + * + * Internal handler. + */ + int (*write_reg)( + sc16is752_context *ctx, + uint8_t addr, + const uint8_t *data, + size_t len + ); + + /** + * @brief Reads a register. + * + * Internal handler. + */ + int (*read_reg)( + sc16is752_context *ctx, + uint8_t addr, + uint8_t *data, + size_t len + ); + + /** + * @brief Reads two registers. + * + * Internal handler. + */ + int (*read_2_reg)( + sc16is752_context *ctx, + uint8_t addr_0, + uint8_t addr_1, + uint8_t data[2] + ); + + /** + * @brief First open. + * + * Internal handler. + */ + bool (*first_open)(sc16is752_context *ctx); + + /** + * @brief Last close. + * + * Internal handler. + */ + void (*last_close)(sc16is752_context *ctx); + + /** + * @brief Shall install the interrupt handler. + * + * Must be initialized by the user before the device creation. + */ + bool (*install_irq)(sc16is752_context *ctx); + + /** + * @brief Shall remove the interrupt handler. + * + * Must be initialized by the user before the device creation. + */ + void (*remove_irq)(sc16is752_context *ctx); + + /** + * @brief Device mode. + * + * Must be initialized by the user before the device creation. + */ + sc16is752_mode mode; + + /** + * @brief Input frequency in Hertz (dependent on crystal, see XTAL1 and XTAL2 + * pins). + * + * Must be initialized by the user before the device creation. + */ + uint32_t input_frequency; + + /** + * @brief Corresponding Termios structure. + * + * Internal variable. + */ + rtems_termios_tty *tty; + + /** + * @brief Shadow Interrupt Enable Register (IER). + * + * Internal variable. + */ + uint8_t ier; + + /** + * @brief Characters placed into transmit FIFO. + * + * Internal variable. + */ + uint8_t tx_in_progress; + + /** + * @brief Count of free characters in the transmit FIFO. + * + * Internal variable. + */ + uint8_t tx_fifo_free; + + /** + * @brief Shadow Line Control Register (LCR). + * + * Internal variable. + */ + uint8_t lcr; + + /** + * @brief Shadow Extra Features Control Register (EFCR). + * + * Internal variable. + */ + uint8_t efcr; +}; + +/** + * @brief SC16IS752 SPI context. + */ +typedef struct { + sc16is752_context base; + + /** + * @brief The SPI bus device file descriptor. + * + * Internal variable. + */ + int fd; + + /** + * @brief The SPI device chip select. + * + * Must be initialized by the user before the call to sc16is752_spi_create(). + */ + uint8_t cs; + + /** + * @brief The SPI bus speed in Hertz. + * + * Must be initialized by the user before the call to sc16is752_spi_create(). + */ + uint32_t speed_hz; + + /** + * @brief The SPI bus device path. + * + * Must be initialized by the user before the call to sc16is752_spi_create(). + */ + const char *spi_path; +} sc16is752_spi_context; + +/** + * @brief SC16IS752 I2C context. + */ +typedef struct { + sc16is752_context base; + + /** + * @brief The I2C bus device file descriptor. + * + * Internal variable. + */ + int fd; + + /** + * @brief The I2C bus device path. + * + * Must be initialized before the call to sc16is752_i2c_create(). + */ + const char *bus_path; +} sc16is752_i2c_context; + +const rtems_termios_device_handler sc16is752_termios_handler; + +/** + * @brief The interrupt handler for receive and transmit operations. + * + * @param[in] arg The device context. + */ +void sc16is752_interrupt_handler(void *arg); + +/** + * @brief Creates an SPI connected SC16IS752 device. + * + * @param[in] ctx The SPI SC16IS752 device context. + * @param[in] device_path The device file path for the new device. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval other See rtems_termios_device_install(). + */ +rtems_status_code sc16is752_spi_create( + sc16is752_spi_context *ctx, + const char *device_path +); + +/** + * @brief Enables the sleep mode if non-zero, otherwise disables it. + * + * The sleep mode is disabled by default. + */ +#define SC16IS752_SET_SLEEP_MODE _IOW('d', 0, int) + +/** + * @brief Returns non-zero in case the sleep mode is enabled, otherwise zero. + */ +#define SC16IS752_GET_SLEEP_MODE _IOR('d', 0, int) + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _DEV_SERIAL_SC16IS752_H */ diff --git a/cpukit/include/dev/spi/spi.h b/cpukit/include/dev/spi/spi.h new file mode 100644 index 0000000000..66bbac2427 --- /dev/null +++ b/cpukit/include/dev/spi/spi.h @@ -0,0 +1,216 @@ +/** + * @file + * + * @brief Serial Peripheral Interface (SPI) Driver API + * + * @ingroup SPI + */ + +/* + * Copyright (c) 2016 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _DEV_SPI_SPI_H +#define _DEV_SPI_SPI_H + +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +typedef struct spi_ioc_transfer spi_ioc_transfer; + +typedef struct spi_bus spi_bus; + +/** + * @defgroup SPI Serial Peripheral Interface (SPI) Driver + * + * @brief Serial Peripheral Interface (SPI) bus driver support. + * + * @{ + */ + +/** + * @brief Obtains the bus. + * + * This command has no argument. + */ +#define SPI_BUS_OBTAIN _IO(SPI_IOC_MAGIC, 13) + +/** + * @brief Releases the bus. + * + * This command has no argument. + */ +#define SPI_BUS_RELEASE _IO(SPI_IOC_MAGIC, 23) + +/** + * @brief SPI bus control. + */ +struct spi_bus { + /** + * @brief Transfers SPI messages. + * + * @param[in] bus The bus control. + * @param[in] msgs The messages to transfer. + * @param[in] msg_count The count of messages to transfer. It must be + * positive. + * + * @retval 0 Successful operation. + * @retval negative Negative error number in case of an error. + */ + int (*transfer)(spi_bus *bus, const spi_ioc_transfer *msgs, uint32_t msg_count); + + /** + * @brief Checks if maximum speed and bits per word are in a valid range + * for the device + * + * @param[in] bus The bus control. + * + * @retval 0 Successful operation. + * @retval negative Negative error number in case of an error. + */ + int (*setup)(spi_bus *bus); + + /** + * @brief Destroys the bus. + * + * @param[in] bus The bus control. + */ + void (*destroy)(spi_bus *bus); + + /** + * @brief Mutex to protect the bus access. + */ + rtems_id mutex; + + /** + * @brief Maximum Speed in Hz + */ + uint32_t max_speed_hz; + + /** + * @brief Indicates the speed of the current device message. + */ + uint32_t speed_hz; + + /** + * @brief Indicates if chip select must be set high after transfer. + */ + bool cs_change; + + /** + * @brief Indicates which device is selected by chip select + */ + uint8_t cs; + + /** + * @brief Indicates the bits per word used on the device. + */ + uint8_t bits_per_word; + + /** + * @brief Indicates if LSB is supposed to be transmitted first. + */ + bool lsb_first; + + /** + * @brief Current mode. + */ + uint32_t mode; + + /** + * @brief Indicates the delay between transfers on different chip select + * devices. + */ + uint16_t delay_usecs; +}; + +/** + * @brief Initializes a bus control. + * + * After a sucessful initialization the bus control must be destroyed via + * spi_bus_destroy(). A registered bus control will be automatically destroyed + * in case the device file is unlinked. Make sure to call spi_bus_destroy() in + * a custom destruction handler. + * + * @param[in] bus The bus control. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The errno is set to indicate the error. + * + * @see spi_bus_register() + */ +int spi_bus_init(spi_bus *bus); + +/** + * @brief Allocates a bus control from the heap and initializes it. + * + * After a sucessful allocation and initialization the bus control must be + * destroyed via spi_bus_destroy_and_free(). A registered bus control will be + * automatically destroyed in case the device file is unlinked. Make sure to + * call spi_bus_destroy_and_free() in a custom destruction handler. + * + * @param[in] size The size of the bus control. This enables the addition of + * bus controller specific data to the base bus control. The bus control is + * zero initialized. + * + * @retval non-NULL The new bus control. + * @retval NULL An error occurred. The errno is set to indicate the error. + * + * @see spi_bus_register() + */ +spi_bus *spi_bus_alloc_and_init(size_t size); + +/** + * @brief Destroys a bus control. + * + * @param[in] bus The bus control. + */ +void spi_bus_destroy(spi_bus *bus); + +/** + * @brief Destroys a bus control and frees its memory. + * + * @param[in] bus The bus control. + */ +void spi_bus_destroy_and_free(spi_bus *bus); + +/** + * @brief Registers a bus control. + * + * This function claims ownership of the bus control regardless if the + * registration is successful or not. + * + * @param[in] bus The bus control. + * @param[in] bus_path The path to the bus device file. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The errno is set to indicate the error. + */ +int spi_bus_register( + spi_bus *bus, + const char *bus_path +); + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _DEV_SPI_SPI_H */ diff --git a/cpukit/include/dlfcn.h b/cpukit/include/dlfcn.h new file mode 100644 index 0000000000..1ac3ba1330 --- /dev/null +++ b/cpukit/include/dlfcn.h @@ -0,0 +1,112 @@ +/* $NetBSD: dlfcn.h,v 1.21 2010/01/07 07:35:35 skrll Exp $ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Paul Kranenburg. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _DLFCN_H_ +#define _DLFCN_H_ + +//#include +#include + +#if defined(_NETBSD_SOURCE) +typedef struct _dl_info { + const char *dli_fname; /* File defining the symbol */ + void *dli_fbase; /* Base address */ + const char *dli_sname; /* Symbol name */ + const void *dli_saddr; /* Symbol address */ +} Dl_info; +#endif /* defined(_NETBSD_SOURCE) */ + +/* + * User interface to the run-time linker. + */ +__BEGIN_DECLS +void *dlopen(const char *, int); +int dlclose(void *); +void *dlsym(void * __restrict, const char * __restrict); +#if defined(_NETBSD_SOURCE) +int dladdr(void * __restrict, Dl_info * __restrict); +int dlctl(void *, int, void *); +#endif +int dlinfo(void *, int, void *); +const char *dlerror(void); +__END_DECLS + +/* Values for dlopen `mode'. */ +#define RTLD_LAZY 1 +#define RTLD_NOW 2 +#define RTLD_GLOBAL 0x100 /* Allow global searches in object */ +#define RTLD_LOCAL 0x200 +#if defined(_NETBSD_SOURCE) +#define DL_LAZY RTLD_LAZY /* Compat */ +#endif + +/* + * Special handle arguments for dlsym(). + */ +#define RTLD_NEXT ((void *) -1) /* Search subsequent objects. */ +#define RTLD_DEFAULT ((void *) -2) /* Use default search algorithm. */ +#define RTLD_SELF ((void *) -3) /* Search the caller itself. */ + +/* + * dlctl() commands + */ +#if defined(_NETBSD_SOURCE) +#define DL_GETERRNO 1 +#define DL_GETSYMBOL 2 +#if 0 +#define DL_SETSRCHPATH x +#define DL_GETLIST x +#define DL_GETREFCNT x +#define DL_GETLOADADDR x +#endif /* 0 */ +#endif /* defined(_NETBSD_SOURCE) */ + +/* + * dlinfo() commands + * + * From Solaris: http://docs.sun.com/app/docs/doc/816-5168/dlinfo-3c?a=view + */ +#define RTLD_DI_UNRESOLVED 10 +#if defined(_NETBSD_SOURCE) +#define RTLD_DI_LINKMAP 3 +#if 0 +#define RTLD_DI_ARGSINFO 1 +#define RTLD_DI_CONFIGADDR 2 +#define RTLD_DI_LMID 4 +#define RTLD_DI_SERINFO 5 +#define RTLD_DI_SERINFOSIZE 6 +#define RTLD_DI_ORIGIN 7 +#define RTLD_DI_GETSIGNAL 8 +#define RTLD_DI_SETSIGNAL 9 +#endif +#endif /* _NETBSD_SOURCE */ + +#endif /* !defined(_DLFCN_H_) */ diff --git a/cpukit/include/drvmgr/drvmgr.h b/cpukit/include/drvmgr/drvmgr.h new file mode 100644 index 0000000000..cb8f4a5f5a --- /dev/null +++ b/cpukit/include/drvmgr/drvmgr.h @@ -0,0 +1,988 @@ +/* Driver Manager Interface. + * + * COPYRIGHT (c) 2009 Cobham Gaisler AB. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _DRIVER_MANAGER_H_ +#define _DRIVER_MANAGER_H_ + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/*** Configure Driver manager ***/ + +/* Define the number of initialization levels of device drivers */ +#define DRVMGR_LEVEL_MAX 4 + +/* Default to use semahpores for protection. Initialization works without + * locks and after initialization too if devices are not removed. + */ +#ifndef DRVMGR_USE_LOCKS +#define DRVMGR_USE_LOCKS 1 +#endif + +struct drvmgr_dev; /* Device */ +struct drvmgr_bus; /* Bus */ +struct drvmgr_drv; /* Driver */ + +/*** List Interface shortcuts ***/ +#define BUS_LIST_HEAD(list) LIST_HEAD(list, struct drvmgr_bus) +#define BUS_LIST_TAIL(list) LIST_TAIL(list, struct drvmgr_bus) +#define DEV_LIST_HEAD(list) LIST_HEAD(list, struct drvmgr_dev) +#define DEV_LIST_TAIL(list) LIST_TAIL(list, struct drvmgr_dev) +#define DRV_LIST_HEAD(list) LIST_HEAD(list, struct drvmgr_drv) +#define DRV_LIST_TAIL(list) LIST_TAIL(list, struct drvmgr_drv) + +/*** Bus indentification ***/ +#define DRVMGR_BUS_TYPE_NONE 0 /* Not a valid bus */ +#define DRVMGR_BUS_TYPE_ROOT 1 /* Hard coded bus */ +#define DRVMGR_BUS_TYPE_PCI 2 /* PCI bus */ +#define DRVMGR_BUS_TYPE_AMBAPP 3 /* AMBA Plug & Play bus */ +#define DRVMGR_BUS_TYPE_LEON2_AMBA 4 /* LEON2 hardcoded bus */ +#define DRVMGR_BUS_TYPE_AMBAPP_DIST 5 /* Distibuted AMBA Plug & Play bus accessed using a communication interface */ +#define DRVMGR_BUS_TYPE_SPW_RMAP 6 /* SpaceWire Network bus */ +#define DRVMGR_BUS_TYPE_AMBAPP_RMAP 7 /* SpaceWire RMAP accessed AMBA Plug & Play bus */ + +enum { + DRVMGR_OBJ_NONE = 0, + DRVMGR_OBJ_DRV = 1, + DRVMGR_OBJ_BUS = 2, + DRVMGR_OBJ_DEV = 3, +}; + +/*** Driver indentification *** + * + * 64-bit identification integer definition + * * Bus ID 8-bit [7..0] + * * Reserved 8-bit field [63..56] + * * Device ID specific for bus type 48-bit [55..8] (Different buses have + * different unique identifications for hardware/driver.) + * + * ID Rules + * * A root bus driver must always have device ID set to 0. There can only by + * one root bus driver for a certain bus type. + * * A Driver ID must identify a unique hardware core + * + */ + +/* Bus ID Mask */ +#define DRIVER_ID_BUS_MASK 0x00000000000000FFULL + +/* Reserved Mask for future use */ +#define DRIVER_ID_RSV_MASK 0xFF00000000000000ULL + +/* Reserved Mask for future use */ +#define DRIVER_ID_DEV_MASK 0x00FFFFFFFFFFFF00ULL + +/* Set Bus ID Mask. */ +#define DRIVER_ID(busid, devid) ((unsigned long long) \ + ((((unsigned long long)(devid) << 8) & DRIVER_ID_DEV_MASK) | \ + ((unsigned long long)(busid) & DRIVER_ID_BUS_MASK))) + +/* Get IDs */ +#define DRIVER_BUSID_GET(id) ((unsigned long long)(id) & DRIVER_ID_BUS_MASK) +#define DRIVER_DEVID_GET(id) (((unsigned long long)(id) & DRIVER_ID_DEV_MASK) >> 8) + +#define DRIVER_ROOTBUS_ID(bus_type) DRIVER_ID(bus_type, 0) + +/*** Root Bus drivers ***/ + +/* Generic Hard coded Root bus: Driver ID */ +#define DRIVER_ROOT_ID DRIVER_ROOTBUS_ID(DRVMGR_BUS_TYPE_ROOT) + +/* PCI Plug & Play bus: Driver ID */ +#define DRIVER_PCIBUS_ID DRIVER_ROOTBUS_ID(DRVMGR_BUS_TYPE_PCI) + +/* AMBA Plug & Play bus: Driver ID */ +#define DRIVER_GRLIB_AMBAPP_ID DRIVER_ROOTBUS_ID(DRVMGR_BUS_TYPE_AMBAPP) + +/* AMBA Hard coded bus: Driver ID */ +#define DRIVER_LEON2_AMBA_ID DRIVER_ROOTBUS_ID(DRVMGR_BUS_TYPE_LEON2_AMBA) + +/* Distributed AMBA Plug & Play bus: Driver ID */ +#define DRIVER_AMBAPP_DIST_ID DRIVER_ROOTBUS_ID(DRVMGR_BUS_TYPE_AMBAPP_DIST) + +/*! Bus parameters used by driver interface functions to aquire information + * about bus. All Bus drivers should implement the operation 'get_params' so + * that the driver interface routines can access bus dependent information in + * an non-dependent way. + */ +struct drvmgr_bus_params { + char *dev_prefix; /*!< Optional name prefix */ +}; + +/* Interrupt Service Routine (ISR) */ +typedef void (*drvmgr_isr)(void *arg); + +/*! Bus operations */ +struct drvmgr_bus_ops { + /* Functions used internally within driver manager */ + int (*init[DRVMGR_LEVEL_MAX])(struct drvmgr_bus *); + int (*remove)(struct drvmgr_bus *); + int (*unite)(struct drvmgr_drv *, struct drvmgr_dev *); /*!< Unite Hardware Device with Driver */ + + /* Functions called indirectly from drivers */ + int (*int_register)(struct drvmgr_dev *, int index, const char *info, drvmgr_isr isr, void *arg); + int (*int_unregister)(struct drvmgr_dev *, int index, drvmgr_isr isr, void *arg); + int (*int_clear)(struct drvmgr_dev *, int index); + int (*int_mask)(struct drvmgr_dev *, int index); + int (*int_unmask)(struct drvmgr_dev *, int index); +#ifdef RTEMS_SMP + int (*int_set_affinity)(struct drvmgr_dev *, int index, + const Processor_mask *cpus); +#endif + + /* Get Parameters */ + int (*get_params)(struct drvmgr_dev *, struct drvmgr_bus_params *); + /* Get Frequency of Bus */ + int (*get_freq)(struct drvmgr_dev*, int, unsigned int*); + /*! Function called to request information about a device. The bus + * driver interpret the bus-specific information about the device. + */ + void (*get_info_dev)(struct drvmgr_dev *, + void (*print)(void *p, char *str), void *p); +}; +#define BUS_OPS_NUM (sizeof(struct drvmgr_bus_ops)/sizeof(void (*)(void))) + +struct drvmgr_func { + int funcid; + void *func; +}; +#define DRVMGR_FUNC(_ID_, _FUNC_) {(int)(_ID_), (void *)(_FUNC_)} +#define DRVMGR_FUNC_END {0, NULL} + +/*** Resource definitions *** + * + * Overview of structures: + * All bus resources entries (_bus_res) are linked together per bus + * (bus_info->reslist). One bus resource entry has a pointer to an array of + * driver resources (_drv_res). One driver resouces is made out of an array + * of keys (drvmgr_key). All keys belongs to the same driver and harwdare + * device. Each key has a Name, Type ID and Data interpreted differently + * depending on the Type ID (union drvmgr_key_value). + * + */ + +/* Key Data Types */ +enum drvmgr_kt { + DRVMGR_KT_ANY = -1, + DRVMGR_KT_NONE = 0, + DRVMGR_KT_INT = 1, + DRVMGR_KT_STRING = 2, + DRVMGR_KT_POINTER = 3, +}; + +#define DRVMGR_KEY_EMPTY {NULL, DRVMGR_KT_NONE, {0}} +#define DRVMGR_RES_EMPTY {0, 0, NULL} +#define MMAP_EMPTY {0, 0, 0} + +/*! Union of different values */ +union drvmgr_key_value { + unsigned int i; /*!< Key data type UNSIGNED INTEGER */ + char *str; /*!< Key data type STRING */ + void *ptr; /*!< Key data type ADDRESS/POINTER */ +}; + +/* One key. One Value. Holding information relevant to the driver. */ +struct drvmgr_key { + char *key_name; /* Name of key */ + enum drvmgr_kt key_type; /* How to interpret key_value */ + union drvmgr_key_value key_value; /* The value or pointer to value */ +}; + +/*! Driver resource entry, Driver resources for a certain device instance, + * containing a number of keys where each key hold the data of interest. + */ +struct drvmgr_drv_res { + uint64_t drv_id; /*!< Identifies the driver this resource is aiming */ + int minor_bus; /*!< Indentifies a specfic device */ + struct drvmgr_key *keys; /*!< First key in key array, ended with KEY_EMPTY */ +}; + +/*! Bus resource list node */ +struct drvmgr_bus_res { + struct drvmgr_bus_res *next; /*!< Next resource node in list */ + struct drvmgr_drv_res resource[]; /*!< Array of resources, one per device instance */ +}; + +/*! MAP entry. Describes an linear address space translation. Untranslated + * Start, Translated Start and length. + * + * Used by bus drivers to describe the address translation needed for + * the translation driver interface. + */ +struct drvmgr_map_entry { + char *name; /*!< Map Name */ + unsigned int size; /*!< Size of map window */ + char *from_adr; /*!< Start address of access window used + * to reach into remote bus */ + char *to_adr; /*!< Start address of remote system + * address range */ +}; +#define DRVMGR_TRANSLATE_ONE2ONE NULL +#define DRVMGR_TRANSLATE_NO_BRIDGE ((void *)1) /* No bridge, error */ + +/*! Bus information. Describes a bus. */ +struct drvmgr_bus { + int obj_type; /*!< DRVMGR_OBJ_BUS */ + unsigned char bus_type; /*!< Type of bus */ + unsigned char depth; /*!< Bus level distance from root bus */ + struct drvmgr_bus *next; /*!< Next Bus */ + struct drvmgr_dev *dev; /*!< Bus device, the hardware... */ + void *priv; /*!< Private data structure used by BUS driver */ + struct drvmgr_dev *children; /*!< Hardware devices on this bus */ + struct drvmgr_bus_ops *ops; /*!< Bus operations supported by this bus driver */ + struct drvmgr_func *funcs; /*!< Extra operations */ + int dev_cnt; /*!< Number of devices this bus has */ + struct drvmgr_bus_res *reslist; /*!< Bus resources, head of a linked list of resources. */ + struct drvmgr_map_entry *maps_up; /*!< Map Translation, array of address spaces upstreams to CPU */ + struct drvmgr_map_entry *maps_down; /*!< Map Translation, array of address spaces downstreams to Hardware */ + + /* Bus status */ + int level; /*!< Initialization Level of Bus */ + int state; /*!< Init State of Bus, BUS_STATE_* */ + int error; /*!< Return code from bus->ops->initN() */ +}; + +/* States of a bus */ +#define BUS_STATE_INIT_FAILED 0x00000001 /* Initialization Failed */ +#define BUS_STATE_LIST_INACTIVE 0x00001000 /* In inactive bus list */ +#define BUS_STATE_DEPEND_FAILED 0x00000004 /* Device init failed */ + +/* States of a device */ +#define DEV_STATE_INIT_FAILED 0x00000001 /* Initialization Failed */ +#define DEV_STATE_INIT_DONE 0x00000002 /* All init levels completed */ +#define DEV_STATE_DEPEND_FAILED 0x00000004 /* Parent Bus init failed */ +#define DEV_STATE_UNITED 0x00000100 /* Device United with Device Driver */ +#define DEV_STATE_REMOVED 0x00000200 /* Device has been removed (unregistered) */ +#define DEV_STATE_IGNORED 0x00000400 /* Device was ignored according to user's request, the device + * was never reported to it's driver (as expected). + */ +#define DEV_STATE_LIST_INACTIVE 0x00001000 /* In inactive device list */ + +/*! Device information */ +struct drvmgr_dev { + int obj_type; /*!< DRVMGR_OBJ_DEV */ + struct drvmgr_dev *next; /*!< Next device */ + struct drvmgr_dev *next_in_bus; /*!< Next device on the same bus */ + struct drvmgr_dev *next_in_drv; /*!< Next device using the same driver */ + + struct drvmgr_drv *drv; /*!< The driver owning this device */ + struct drvmgr_bus *parent; /*!< Bus that this device resides on */ + short minor_drv; /*!< Device number within driver */ + short minor_bus; /*!< Device number on bus (for device separation) */ + char *name; /*!< Name of Device Hardware */ + void *priv; /*!< Pointer to driver private device structure */ + void *businfo; /*!< Host bus specific information */ + struct drvmgr_bus *bus; /*!< Pointer to bus, set only if this is a bridge */ + + /* Device Status */ + unsigned int state; /*!< State of device, see DEV_STATE_* */ + int level; /*!< Init Level */ + int error; /*!< Error state returned by driver */ +}; + +/*! Driver operations, function pointers. */ +struct drvmgr_drv_ops { + int (*init[DRVMGR_LEVEL_MAX])(struct drvmgr_dev *); /*! Function doing Init Stage 1 of a hardware device */ + int (*remove)(struct drvmgr_dev *); /*! Function called when device instance is to be removed */ + int (*info)(struct drvmgr_dev *, void (*print)(void *p, char *str), void *p, int, char *argv[]);/*! Function called to request information about a device or driver */ +}; +#define DRVMGR_OPS_NUM(x) (sizeof(x)/sizeof(void (*)(void))) + +/*! Device driver description */ +struct drvmgr_drv { + int obj_type; /*!< DRVMGR_OBJ_DRV */ + struct drvmgr_drv *next; /*!< Next Driver */ + struct drvmgr_dev *dev; /*!< Devices using this driver */ + + uint64_t drv_id; /*!< Unique Driver ID */ + char *name; /*!< Name of Driver */ + int bus_type; /*!< Type of Bus this driver supports */ + struct drvmgr_drv_ops *ops; /*!< Driver operations */ + struct drvmgr_func *funcs; /*!< Extra Operations */ + unsigned int dev_cnt; /*!< Number of devices in dev */ + unsigned int dev_priv_size; /*!< If non-zero DRVMGR will allocate memory for dev->priv */ +}; + +/*! Structure defines a function pointer called when driver manager is ready + * for drivers to register themselfs. Used to select drivers available to the + * driver manager. + */ +typedef void (*drvmgr_drv_reg_func)(void); + +/*** DRIVER | DEVICE | BUS FUNCTIONS ***/ + +/* Return Codes */ +enum { + DRVMGR_OK = 0, /* Sucess */ + DRVMGR_NOMEM = 1, /* Memory allocation error */ + DRVMGR_EIO = 2, /* I/O error */ + DRVMGR_EINVAL = 3, /* Invalid parameter */ + DRVMGR_ENOSYS = 4, + DRVMGR_TIMEDOUT = 5, /* Operation timeout error */ + DRVMGR_EBUSY = 6, + DRVMGR_ENORES = 7, /* Not enough resources */ + DRVMGR_FAIL = -1 /* Unspecified failure */ +}; + +/*! Initialize data structures of the driver management system. + * Calls predefined register driver functions so that drivers can + * register themselves. + */ +extern void _DRV_Manager_initialization(void); + +/*! Take all devices into init level 'level', all devices registered later + * will directly be taken into this level as well, ensuring that all + * registerd devices has been taken into the level. + * + */ +extern void _DRV_Manager_init_level(int level); + +/*! This function must be defined by the BSP when the driver manager is enabled + * and initialized during BSP initialization. The function is called after a + * init level is reached the first time by the driver manager. + */ +extern void bsp_driver_level_hook(int level); + +/*! Init driver manager all in one go, will call _DRV_Manager_initialization(), + * then _DRV_Manager_init_level([1..DRVMGR_LEVEL_MAX]). + * Typically called from Init task when user wants to initilize driver + * manager after startup, otherwise not used. + */ +extern int drvmgr_init(void); + +/* Take registered buses and devices into the correct init level, + * this function is called from _init_level() so normally + * we don't need to call it directly. + */ +extern void drvmgr_init_update(void); + +/*! Register Root Bus device driver */ +extern int drvmgr_root_drv_register(struct drvmgr_drv *drv); + +/*! Register a driver */ +extern int drvmgr_drv_register(struct drvmgr_drv *drv); + +/*! Register a device */ +extern int drvmgr_dev_register(struct drvmgr_dev *dev); + +/*! Remove a device, and all its children devices if device is a bus device. The + * device driver will be requested to remove the device and once gone from bus, + * device and driver list the device is put into a inactive list for debugging + * (this is optional by using remove argument). + * + * Removing the Root Bus Device is not supported. + * + * \param remove If non-zero the device will be deallocated, and not put into + * the inacitve list. + */ +extern int drvmgr_dev_unregister(struct drvmgr_dev *dev); + +/*! Register a bus */ +extern int drvmgr_bus_register(struct drvmgr_bus *bus); + +/*! Unregister a bus */ +extern int drvmgr_bus_unregister(struct drvmgr_bus *bus); + +/*! Unregister all child devices of a bus. + * + * This function is called from the bus driver, from a "safe" state where + * devices will not be added or removed on this particular bus at this time + */ +extern int drvmgr_children_unregister(struct drvmgr_bus *bus); + +/* Separate a device from the driver it has been united with */ +extern int drvmgr_dev_drv_separate(struct drvmgr_dev *dev); + +/*! Allocate a device structure, if no memory available + * rtems_error_fatal_occurred is called. + * The 'extra' argment tells how many bytes extra space is to be allocated after + * the device structure, this is typically used for "businfo" structures. The extra + * space is always aligned to a 4-byte boundary. + */ +extern int drvmgr_alloc_dev(struct drvmgr_dev **pdev, int extra); + +/*! Allocate a bus structure, if no memory available rtems_error_fatal_occurred + * is called. + * The 'extra' argment tells how many bytes extra space is to be allocated after + * the device structure, this is typically used for "businfo" structures. The + * extra space is always aligned to a 4-byte boundary. + */ +extern int drvmgr_alloc_bus(struct drvmgr_bus **pbus, int extra); + +/*** DRIVER RESOURCE FUNCTIONS ***/ + +/*! Add resources to a bus, typically used by a bus driver. + * + * \param bus The Bus to add the resources to. + * \param res An array with Driver resources, all together are called bus + * resources. + */ +extern void drvmgr_bus_res_add(struct drvmgr_bus *bus, + struct drvmgr_bus_res *bres); + +/*! Find all the resource keys for a device among all driver resources on a + * bus. Typically used by a device driver to get configuration options. + * + * \param dev Device to find resources for + * \param key Location where the pointer to the driver resource array (drvmgr_drv_res->keys) is stored. + */ +extern int drvmgr_keys_get(struct drvmgr_dev *dev, struct drvmgr_key **keys); + +/*! Return the one key that matches key name from a driver keys array. The keys + * can be obtained using drvmgr_keys_get(). + * + * \param keys An array of keys ended with DRVMGR_KEY_EMPTY to search among. + * \param key_name Name of key to search for among the keys. + */ +extern struct drvmgr_key *drvmgr_key_get(struct drvmgr_key *keys, char *key_name); + +/*! Extract key value from the key in the keys array matching name and type. + * + * This function calls drvmgr_keys_get to get the key requested (from key + * name), then determines if the type is correct. A pointer to the key value + * is returned. + * + * \param keys An array of keys ended with DRVMGR_KEY_EMPTY to search among. + * \param key_name Name of key to search for among the keys. + * \param key_type Data Type of value. INTEGER, ADDRESS, STRING. + * \return Returns NULL if no value found matching Key Name and Key + * Type. + */ +extern union drvmgr_key_value *drvmgr_key_val_get( + struct drvmgr_key *keys, + char *key_name, + enum drvmgr_kt key_type); + +/*! Get key value from the bus resources matching [device, key name, key type] + * if no matching key is found NULL is returned. + * + * This is typically used by device drivers to find a particular device + * resource. + * + * \param dev The device to search resource for. + * \param key_name The key name to search for + * \param key_type The key type expected. + * \return Returns NULL if no value found matching Key Name and + * Key Type was found for device. + */ +extern union drvmgr_key_value *drvmgr_dev_key_get( + struct drvmgr_dev *dev, + char *key_name, + enum drvmgr_kt key_type); + +/*** DRIVER INTERACE USED TO REQUEST INFORMATION/SERVICES FROM BUS DRIVER ***/ + +/*! Get parent bus */ +RTEMS_INLINE_ROUTINE struct drvmgr_bus *drvmgr_get_parent( + struct drvmgr_dev *dev) +{ + if (dev) + return dev->parent; + else + return NULL; +} + +/*! Get Driver of device */ +RTEMS_INLINE_ROUTINE struct drvmgr_drv *drvmgr_get_drv(struct drvmgr_dev *dev) +{ + if (dev) + return dev->drv; + else + return NULL; +} + +/*! Calls func() for every device found in the device tree, regardless of + * device state or if a driver is assigned. With the options argument the user + * can decide to do either a depth-first or a breadth-first search. + * + * If the function func() returns a non-zero value then for_each_dev will + * return imediatly with the same return value as func() returned. + * + * \param func Function called on each device + * \param arg Custom function argument + * \param options Search Options, see DRVMGR_FED_* + * + */ +#define DRVMGR_FED_BF 1 /* Breadth-first search */ +#define DRVMGR_FED_DF 0 /* Depth first search */ +extern int drvmgr_for_each_dev( + int (*func)(struct drvmgr_dev *dev, void *arg), + void *arg, + int options); + +/*! Get Device pointer from Driver and Driver minor number + * + * \param drv Driver the device is united with. + * \param minor Driver minor number assigned to device. + * \param pdev Location where the Device point will be stored. + * \return Zero on success. -1 on failure, when device was not + * found in driver device list. + */ +extern int drvmgr_get_dev( + struct drvmgr_drv *drv, + int minor, + struct drvmgr_dev **pdev); + +/*! Get Bus frequency in Hertz. Frequency is stored into address of freq_hz. + * + * \param dev The Device to get Bus frequency for. + * \param options Bus-type specific options + * \param freq_hz Location where Bus Frequency will be stored. + */ +extern int drvmgr_freq_get( + struct drvmgr_dev *dev, + int options, + unsigned int *freq_hz); + +/*! Return 0 if dev is not located on the root bus, 1 if on root bus */ +extern int drvmgr_on_rootbus(struct drvmgr_dev *dev); + +/*! Get device name prefix, this name can be used to register a unique name in + * the bus->error filesystem or to get an idea where the device is located. + * + * \param dev The Device to get the device Prefix for. + * \param dev_prefix Location where the prefix will be stored. + */ +extern int drvmgr_get_dev_prefix(struct drvmgr_dev *dev, char *dev_prefix); + +/*! Register a shared interrupt handler. Since this service is shared among + * interrupt drivers/handlers the handler[arg] must be installed before the + * interrupt can be cleared or disabled. The handler is by default disabled + * after registration. + * + * \param index Index is used to identify the IRQ number if hardware has + * multiple IRQ sources. Normally Index is set to 0 to + * indicated the first and only IRQ source. + * A negative index is interpreted as a absolute bus IRQ + * number. + * \param isr Interrupt Service Routine. + * \param arg Optional ISR argument. + */ +extern int drvmgr_interrupt_register( + struct drvmgr_dev *dev, + int index, + const char *info, + drvmgr_isr isr, + void *arg); + +/*! Unregister an interrupt handler. This also disables the interrupt before + * unregistering the interrupt handler. + * \param index Index is used to identify the IRQ number if hardware has + * multiple IRQ sources. Normally Index is set to 0 to + * indicated the first and only IRQ source. + * A negative index is interpreted as a absolute bus IRQ + * number. + * \param isr Interrupt Service Routine, previously registered. + * \param arg Optional ISR argument, previously registered. + */ +extern int drvmgr_interrupt_unregister( + struct drvmgr_dev *dev, + int index, + drvmgr_isr isr, + void *arg); + +/*! Clear (ACK) pending interrupt + * + * \param dev Device to clear interrupt for. + * \param index Index is used to identify the IRQ number if hardware has multiple IRQ sources. + * Normally Index is set to 0 to indicated the first and only IRQ source. + * A negative index is interpreted as a absolute bus IRQ number. + * \param isr Interrupt Service Routine, previously registered. + * \param arg Optional ISR argument, previously registered. + */ +extern int drvmgr_interrupt_clear( + struct drvmgr_dev *dev, + int index); + +/*! Force unmasking/enableing an interrupt on the interrupt controller, this is not normally used, + * if used the caller has masked/disabled the interrupt just before. + * + * \param dev Device to clear interrupt for. + * \param index Index is used to identify the IRQ number if hardware has multiple IRQ sources. + * Normally Index is set to 0 to indicated the first and only IRQ source. + * A negative index is interpreted as a absolute bus IRQ number. + * \param isr Interrupt Service Routine, previously registered. + * \param arg Optional ISR argument, previously registered. + */ +extern int drvmgr_interrupt_unmask( + struct drvmgr_dev *dev, + int index); + +/*! Force masking/disable an interrupt on the interrupt controller, this is not normally performed + * since this will stop all other (shared) ISRs to be disabled until _unmask() is called. + * + * \param dev Device to mask interrupt for. + * \param index Index is used to identify the IRQ number if hardware has multiple IRQ sources. + * Normally Index is set to 0 to indicated the first and only IRQ source. + * A negative index is interpreted as a absolute bus IRQ number. + */ +extern int drvmgr_interrupt_mask( + struct drvmgr_dev *dev, + int index); + +/*! Force masking/disable an interrupt on the interrupt controller, this is not normally performed + * since this will stop all other (shared) ISRs to be disabled until _unmask() is called. + * + * \param dev Device to mask interrupt for. + * \param index Index is used to identify the IRQ number if hardware has multiple IRQ sources. + * Normally Index is set to 0 to indicated the first and only IRQ source. + * A negative index is interpreted as a absolute bus IRQ number. + */ +#ifdef RTEMS_SMP +extern int drvmgr_interrupt_set_affinity( + struct drvmgr_dev *dev, + int index, + const Processor_mask *cpus); +#endif + +/*! drvmgr_translate() translation options */ +enum drvmgr_tr_opts { + /* Translate CPU RAM Address (input) to DMA unit accessible address + * (output), this is an upstreams translation in reverse order. + * + * Typical Usage: + * It is common to translate a CPU accessible RAM address to an + * address that DMA units can access over bridges. + */ + CPUMEM_TO_DMA = 0x0, + + /* Translate DMA Unit Accessible address mapped to CPU RAM (input) to + * CPU accessible address (output). This is an upstreams translation. + * + * Typical Usage (not often used): + * The DMA unit descriptors contain pointers to DMA buffers located at + * CPU RAM addresses that the DMA unit can access, the CPU processes + * the descriptors and want to access the data but a translation back + * to CPU address is required. + */ + CPUMEM_FROM_DMA = 0x1, + + /* Translate DMA Memory Address (input) to CPU accessible address + * (output), this is a downstreams translation in reverse order. + * + * Typical Usage: + * A PCI network card puts packets into its memory not doing DMA over + * PCI, in order for the CPU to access them the PCI address must be + * translated. + */ + DMAMEM_TO_CPU = 0x2, + + /* Translate CPU accessible address (input) mapped to DMA Memory Address + * to DMA Unit accessible address (output). This is a downstreams + * translation. + */ + DMAMEM_FROM_CPU = 0x3, +}; +#define DRVMGR_TR_REVERSE 0x1 /* do reverse translation direction order */ +#define DRVMGR_TR_PATH 0x2 /* 0x0=down-stream 0x2=up-stream address path */ + +/*! Translate an address on one bus to an address on another bus. + * + * The device determines source or destination bus, the root bus is always + * the other bus. It is assumed that the CPU is located on the root bus or + * that it can access it without address translation (mapped 1:1). The CPU + * is thus assumed to be located on level 0 top most in the bus hierarchy. + * + * If no map is present in the bus driver src_address is translated 1:1 + * (just copied). + * + * Addresses are typically converted up-streams from the DMA unit towards the + * CPU (DMAMEM_TO_CPU) or down-streams towards DMA hardware from the CPU + * (CPUMEM_TO_DMA) over one or multiple bridges depending on bus architecture. + * See 'enum drvmgr_tr_opts' for other translation direction options. + * For example: + * Two common operations is to translate a CPU accessible RAM address to an + * address that DMA units can access (dev=DMA-unit, CPUMEM_TO_DMA, + * src_address=CPU-RAM-ADR) and to translate an address of a PCI resource for + * example RAM mapped into a PCI BAR to an CPU accessible address + * (dev=PCI-device, DMAMEM_TO_CPU, src_address=PCI-BAR-ADR). + * + * Source address is translated and the result is put into *dst_address, if + * the address is not accessible on the other bus -1 is returned. + * + * \param dev Device to translate addresses for + * \param options Tanslation direction options, see enum drvmgr_tr_opts + * \param src_address Address to translate + * \param dst_address Location where translated address is stored + * + * Returns 0 if unable to translate. The remaining length from the given + * address of the map is returned on success, for example if a map starts + * at 0x40000000 of size 0x100000 the result will be 0x40000 if the address + * was translated into 0x400C0000. + * If dev is on root-bus no translation is performed 0xffffffff is returned + * and src_address is stored in *dst_address. + */ +extern unsigned int drvmgr_translate( + struct drvmgr_dev *dev, + unsigned int options, + void *src_address, + void **dst_address); + +/* Translate addresses between buses, used internally to implement + * drvmgr_translate. Function is not limited to translate from/to root bus + * where CPU is resident, however buses must be on a straight path relative + * to each other (parent of parent of parent and so on). + * + * \param from src_address is given for this bus + * \param to src_address is translated to this bus + * \param reverse Selects translation method, if map entries are used in + * the reverse order (map_up->to is used as map_up->from) + * \param src_address Address to be translated + * \param dst_address Translated address is stored here on success (return=0) + * + * Returns 0 if unable to translate. The remaining length from the given + * address of the map is returned on success and the result is stored into + * *dst_address. For example if a map starts at 0x40000000 of size 0x100000 + * the result will be 0x40000 if the address was translated into 0x400C0000. + * If dev is on root-bus no translation is performed 0xffffffff is returned. + * and src_address is stored in *dst_address. + */ +extern unsigned int drvmgr_translate_bus( + struct drvmgr_bus *from, + struct drvmgr_bus *to, + int reverse, + void *src_address, + void **dst_address); + +/* Calls drvmgr_translate() to translate an address range and checks the result, + * a printout is generated if the check fails. All parameters are passed on to + * drvmgr_translate() except for size, see paramters of drvmgr_translate(). + * + * If size=0 only the starting address is not checked. + * + * If mapping failes a non-zero result is returned. + */ +extern int drvmgr_translate_check( + struct drvmgr_dev *dev, + unsigned int options, + void *src_address, + void **dst_address, + unsigned int size); + +/*! Get function pointer from Device Driver or Bus Driver. + * + * Returns 0 if function is available + */ +extern int drvmgr_func_get(void *obj, int funcid, void **func); + +/*! Lookup function and call it directly with the four optional arguments */ +extern int drvmgr_func_call(void *obj, int funcid, void *a, void *b, void *c, void *d); + +/* Builds a Function ID. + * + * Used to request optional functions by a bus or device driver + */ +#define DRVMGR_FUNCID(major, minor) ((((major) & 0xfff) << 20) | ((minor) & 0xfffff)) +#define DRVMGR_FUNCID_NONE 0 +#define DRVMGR_FUNCID_END DRVMGR_FUNCID(DRVMGR_FUNCID_NONE, 0) + +/* Major Function ID. Most significant 12-bits. */ +enum { + FUNCID_NONE = 0x000, + FUNCID_RW = 0x001, /* Read/Write functions */ +}; + +/* Select Sub-Function Read/Write function by ID */ +#define RW_SIZE_1 0x00001 /* Access Size */ +#define RW_SIZE_2 0x00002 +#define RW_SIZE_4 0x00004 +#define RW_SIZE_8 0x00008 +#define RW_SIZE_ANY 0x00000 +#define RW_SIZE(id) ((unsigned int)(id) & 0xf) + +#define RW_DIR_ANY 0x00000 /* Access Direction */ +#define RW_READ 0x00000 /* Read */ +#define RW_WRITE 0x00010 /* Write */ +#define RW_SET 0x00020 /* Write with same value (memset) */ +#define RW_DIR(id) (((unsigned int)(id) >> 4) & 0x3) + +#define RW_RAW 0x00000 /* Raw access - no swapping (machine default) */ +#define RW_LITTLE 0x00040 /* Little Endian */ +#define RW_BIG 0x00080 /* Big Endian */ +#define RW_ENDIAN(id) (((unsigned int)(id) >> 6) & 0x3) + +#define RW_TYPE_ANY 0x00000 /* Access type */ +#define RW_REG 0x00100 +#define RW_MEM 0x00200 +#define RW_MEMREG 0x00300 +#define RW_CFG 0x00400 +#define RW_TYPE(id) (((unsigned int)(id) >> 8) & 0xf) + +#define RW_ARG 0x01000 /* Optional Argument */ +#define RW_ERR 0x02000 /* Optional Error Handler */ + +/* Build a Read/Write function ID */ +#define DRVMGR_RWFUNC(minor) DRVMGR_FUNCID(FUNCID_RW, minor) + +/* Argument to Read/Write functions, the "void *arg" pointer is returned by + * RW_ARG. If NULL is returned no argument is needed. + */ +struct drvmgr_rw_arg { + void *arg; + struct drvmgr_dev *dev; +}; + +/* Standard Read/Write function types */ +typedef uint8_t (*drvmgr_r8)(uint8_t *srcadr); +typedef uint16_t (*drvmgr_r16)(uint16_t *srcadr); +typedef uint32_t (*drvmgr_r32)(uint32_t *srcadr); +typedef uint64_t (*drvmgr_r64)(uint64_t *srcadr); +typedef void (*drvmgr_w8)(uint8_t *dstadr, uint8_t data); +typedef void (*drvmgr_w16)(uint16_t *dstadr, uint16_t data); +typedef void (*drvmgr_w32)(uint32_t *dstadr, uint32_t data); +typedef void (*drvmgr_w64)(uint64_t *dstadr, uint64_t data); +/* READ/COPY a memory area located on bus into CPU memory. + * From 'src' (remote) to the destination 'dest' (local), n=number of bytes + */ +typedef int (*drvmgr_rmem)(void *dest, const void *src, int n); +/* WRITE/COPY a user buffer located in CPU memory to a location on the bus. + * From 'src' (local) to the destination 'dest' (remote), n=number of bytes + */ +typedef int (*drvmgr_wmem)(void *dest, const void *src, int n); +/* Set a memory area to the byte value given in c, see LIBC memset(). Memset is + * implemented by calling wmem() multiple times with a "large" buffer. + */ +typedef int (*drvmgr_memset)(void *dstadr, int c, size_t n); + +/* Read/Write function types with additional argument */ +typedef uint8_t (*drvmgr_r8_arg)(uint8_t *srcadr, void *a); +typedef uint16_t (*drvmgr_r16_arg)(uint16_t *srcadr, void *a); +typedef uint32_t (*drvmgr_r32_arg)(uint32_t *srcadr, void *a); +typedef uint64_t (*drvmgr_r64_arg)(uint64_t *srcadr, void *a); +typedef void (*drvmgr_w8_arg)(uint8_t *dstadr, uint8_t data, void *a); +typedef void (*drvmgr_w16_arg)(uint16_t *dstadr, uint16_t data, void *a); +typedef void (*drvmgr_w32_arg)(uint32_t *dstadr, uint32_t data, void *a); +typedef void (*drvmgr_w64_arg)(uint64_t *dstadr, uint64_t data, void *a); +typedef int (*drvmgr_rmem_arg)(void *dest, const void *src, int n, void *a); +typedef int (*drvmgr_wmem_arg)(void *dest, const void *src, int n, void *a); +typedef int (*drvmgr_memset_arg)(void *dstadr, int c, size_t n, void *a); + +/* Report an error to the parent bus of the device */ +typedef void (*drvmgr_rw_err)(struct drvmgr_rw_arg *a, struct drvmgr_bus *bus, + int funcid, void *adr); + +/* Helper function for buses that implement the memset() over wmem() */ +extern void drvmgr_rw_memset( + void *dstadr, + int c, + size_t n, + void *a, + drvmgr_wmem_arg wmem + ); + +/*** PRINT INFORMATION ABOUT DRIVER MANAGER ***/ + +/*! Calls func() for every device found matching the search requirements of + * set_mask and clr_mask. Each bit set in set_mask must be set in the + * device state bit mask (dev->state), and Each bit in the clr_mask must + * be cleared in the device state bit mask (dev->state). There are three + * special cases: + * + * 1. If state_set_mask and state_clr_mask are zero the state bits are + * ignored and all cores are treated as a match. + * + * 2. If state_set_mask is zero the function func will not be called due to + * a bit being set in the state mask. + * + * 3. If state_clr_mask is zero the function func will not be called due to + * a bit being cleared in the state mask. + * + * If the function func() returns a non-zero value then for_each_dev will + * return imediatly with the same return value as func() returned. + * + * \param devlist The list to iterate though searching for devices. + * \param state_set_mask Defines the bits that must be set in dev->state + * \param state_clr_mask Defines the bits that must be cleared in dev->state + * \param func Function called on each + * + */ +extern int drvmgr_for_each_listdev( + struct drvmgr_list *devlist, + unsigned int state_set_mask, + unsigned int state_clr_mask, + int (*func)(struct drvmgr_dev *dev, void *arg), + void *arg); + +/* Print all devices */ +#define PRINT_DEVS_FAILED 0x01 /* Failed during initialization */ +#define PRINT_DEVS_ASSIGNED 0x02 /* Driver assigned */ +#define PRINT_DEVS_UNASSIGNED 0x04 /* Driver not assigned */ +#define PRINT_DEVS_IGNORED 0x08 /* Device ignored on user's request */ +#define PRINT_DEVS_ALL (PRINT_DEVS_FAILED | \ + PRINT_DEVS_ASSIGNED | \ + PRINT_DEVS_UNASSIGNED |\ + PRINT_DEVS_IGNORED) + +/*! Print number of devices, buses and drivers */ +extern void drvmgr_summary(void); + +/*! Print devices with certain condictions met according to 'options' */ +extern void drvmgr_print_devs(unsigned int options); + +/*! Print device/bus topology */ +extern void drvmgr_print_topo(void); + +/*! Print the memory usage + * Only accounts for data structures. Not for the text size. + */ +extern void drvmgr_print_mem(void); + +#define OPTION_DEV_GENINFO 0x00000001 +#define OPTION_DEV_BUSINFO 0x00000002 +#define OPTION_DEV_DRVINFO 0x00000004 +#define OPTION_DRV_DEVS 0x00000100 +#define OPTION_BUS_DEVS 0x00010000 +#define OPTION_RECURSIVE 0x01000000 +#define OPTION_INFO_ALL 0xffffffff + +/*! Print information about a driver manager object (device, driver, bus) */ +extern void drvmgr_info(void *id, unsigned int options); + +/*! Get information about a device */ +extern void drvmgr_info_dev(struct drvmgr_dev *dev, unsigned int options); + +/*! Get information about a bus */ +extern void drvmgr_info_bus(struct drvmgr_bus *bus, unsigned int options); + +/*! Get information about a driver */ +extern void drvmgr_info_drv(struct drvmgr_drv *drv, unsigned int options); + +/*! Get information about all devices on a bus */ +extern void drvmgr_info_devs_on_bus(struct drvmgr_bus *bus, unsigned int options); + +/*! Get information about all devices in the system (on all buses) */ +extern void drvmgr_info_devs(unsigned int options); + +/*! Get information about all drivers in the system */ +extern void drvmgr_info_drvs(unsigned int options); + +/*! Get information about all buses in the system */ +extern void drvmgr_info_buses(unsigned int options); + +/*! Get Driver by Driver ID */ +extern struct drvmgr_drv *drvmgr_drv_by_id(uint64_t id); + +/*! Get Driver by Driver Name */ +extern struct drvmgr_drv *drvmgr_drv_by_name(const char *name); + +/*! Get Device by Device Name */ +extern struct drvmgr_dev *drvmgr_dev_by_name(const char *name); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/include/drvmgr/drvmgr_confdefs.h b/cpukit/include/drvmgr/drvmgr_confdefs.h new file mode 100644 index 0000000000..82829bd8aa --- /dev/null +++ b/cpukit/include/drvmgr/drvmgr_confdefs.h @@ -0,0 +1,258 @@ +/* Driver Manager Configuration file. + * + * COPYRIGHT (c) 2009 Cobham Gaisler AB. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +/* + * The configuration consist of an array with function pointers that + * register one or more drivers that will be used by the Driver Manger. + * + * The Functions are called in the order they are declared. + * + */ + +#ifndef _DRIVER_MANAGER_CONFDEFS_H_ +#define _DRIVER_MANAGER_CONFDEFS_H_ + +#include "drvmgr.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern drvmgr_drv_reg_func drvmgr_drivers[]; + +#ifdef CONFIGURE_INIT + +/*** AMBA Plug & Play Drivers ***/ +extern void gptimer_register_drv(void); +extern void apbuart_cons_register_drv(void); +extern void greth_register_drv(void); +extern void grspw_register_drv(void); +extern void grspw2_register_drv(void); +extern void grcan_register_drv(void); +extern void occan_register_drv(void); +extern void gr1553_register(void); +extern void gr1553bc_register(void); +extern void gr1553bm_register(void); +extern void gr1553rt_register(void); +extern void b1553brm_register_drv(void); +extern void b1553rt_register_drv(void); +extern void grtm_register_drv(void); +extern void grtc_register_drv(void); +extern void pcif_register_drv(void); +extern void grpci_register_drv(void); +extern void mctrl_register_drv(void); +extern void l2cache_register_drv(void); +extern void griommu_register_drv(void); +extern void grpci2_register_drv(void); +extern void spictrl_register_drv(void); +extern void i2cmst_register_drv(void); +extern void grgpio_register_drv(void); +extern void grpwm_register_drv(void); +extern void gradcdac_register_drv(void); +extern void spwcuc_register(void); +extern void grctm_register(void); +extern void router_register_drv(void); +extern void ahbstat_register_drv(void); +extern void memscrub_register_drv(void); +extern void l4stat_register_drv(void); + + +/*** LEON2 AMBA Hard coded bus Drivers ***/ +extern void at697pci_register_drv(void); +extern void ambapp_leon2_register(void); + + +/*** PCI Bus Drivers (PCI Target drivers) ***/ +extern void gr_rasta_adcdac_register_drv(void); +extern void gr_rasta_io_register_drv(void); +extern void gr_rasta_tmtc_register_drv(void); +extern void gr701_register_drv(void); +extern void gr_tmtc_1553_register_drv(void); +extern void gr_rasta_spw_router_register_drv(void); +extern void gr_cpci_leon4_n2x_register_drv(void); +extern void gr_cpci_gr740_register_drv(void); + + +/* CONFIGURE DRIVER MANAGER */ +drvmgr_drv_reg_func drvmgr_drivers[] = { + /*** AMBA Plug & Play Drivers ***/ +#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER + gptimer_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART + apbuart_cons_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRETH + greth_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW + grspw_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW2 + grspw2_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRCAN + grcan_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_OCCAN + occan_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GR1553B + gr1553_register, +#endif +#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GR1553BC + gr1553bc_register, +#endif +#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GR1553BM + gr1553bm_register, +#endif +#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GR1553RT + gr1553rt_register, +#endif +#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_B1553BRM + b1553brm_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_B1553RT + b1553rt_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRTM + grtm_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRTC + grtc_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_PCIF + pcif_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRPCI + grpci_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRPCI2 + grpci2_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_AMBAPP_MCTRL + mctrl_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_L2CACHE + l2cache_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRIOMMU + griommu_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_SPICTRL + spictrl_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_I2CMST + i2cmst_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRGPIO + grgpio_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRPWM + grpwm_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRADCDAC + gradcdac_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_SPWCUC + spwcuc_register, +#endif +#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRCTM + grctm_register, +#endif +#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_SPW_ROUTER + router_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_AHBSTAT + ahbstat_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_MEMSCRUB + memscrub_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_L4STAT + l4stat_register_drv, +#endif + + /*** LEON2 AMBA Drivers ***/ +#ifdef CONFIGURE_DRIVER_LEON2_AT697PCI + at697pci_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_LEON2_AMBAPP + ambapp_leon2_register, +#endif + + /*** PCI Target Drivers ***/ +#ifdef CONFIGURE_DRIVER_PCI_GR_RASTA_ADCDAC + gr_rasta_adcdac_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_PCI_GR_RASTA_IO + gr_rasta_io_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_PCI_GR_RASTA_TMTC + gr_rasta_tmtc_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_PCI_GR_701 + gr701_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_PCI_GR_TMTC_1553 + gr_tmtc_1553_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_PCI_GR_RASTA_SPW_ROUTER + gr_rasta_spw_router_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_PCI_GR_LEON4_N2X + gr_cpci_leon4_n2x_register_drv, +#endif +#ifdef CONFIGURE_DRIVER_PCI_GR_CPCI_GR740 + gr_cpci_gr740_register_drv, +#endif + + +/* Macros for adding custom drivers without needing to recompile + * kernel. + */ +#ifdef CONFIGURE_DRIVER_CUSTOM1 + DRIVER_CUSTOM1_REG, +#endif +#ifdef CONFIGURE_DRIVER_CUSTOM2 + DRIVER_CUSTOM2_REG, +#endif +#ifdef CONFIGURE_DRIVER_CUSTOM3 + DRIVER_CUSTOM3_REG, +#endif +#ifdef CONFIGURE_DRIVER_CUSTOM4 + DRIVER_CUSTOM4_REG, +#endif +#ifdef CONFIGURE_DRIVER_CUSTOM5 + DRIVER_CUSTOM5_REG, +#endif +#ifdef CONFIGURE_DRIVER_CUSTOM6 + DRIVER_CUSTOM6_REG, +#endif +#ifdef CONFIGURE_DRIVER_CUSTOM7 + DRIVER_CUSTOM7_REG, +#endif +#ifdef CONFIGURE_DRIVER_CUSTOM8 + DRIVER_CUSTOM8_REG, +#endif +#ifdef CONFIGURE_DRIVER_CUSTOM9 + DRIVER_CUSTOM9_REG, +#endif + + /* End array with NULL */ + NULL +}; + +#endif /* CONFIGURE_INIT */ + +#ifdef __cplusplus +} +#endif + +#endif /* _DRIVER_MANAGER_CONFDEFS_H_ */ diff --git a/cpukit/include/drvmgr/drvmgr_list.h b/cpukit/include/drvmgr/drvmgr_list.h new file mode 100644 index 0000000000..76028fb5bd --- /dev/null +++ b/cpukit/include/drvmgr/drvmgr_list.h @@ -0,0 +1,78 @@ +/* Linked list help functions used by driver manager. + * + * COPYRIGHT (c) 2009 Cobham Gaisler AB. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +/* + * Help functions for the Driver Manager. Implements a singly linked list + * with head and tail pointers for fast insertions/deletions to head and + * tail in list. + */ + +#ifndef _DRVIVER_MANAGER_LIST_H_ +#define _DRVIVER_MANAGER_LIST_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/*! List description, Singly link list with head and tail pointers. */ +struct drvmgr_list { + void *head; /*!< First entry in queue */ + void *tail; /*!< Last entry in queue */ + int ofs; /*!< Offset into head and tail to find next field */ +}; + +/* Static initialization of list */ +#define LIST_INITIALIZER(type, field) {NULL, NULL, offsetof(type, field)} + +/* Return the first element in list */ +#define LIST_HEAD(list, type) ((type *)(list)->head) + +/* Return the last element in list */ +#define LIST_TAIL(list, type) ((type *)(list)->tail) + +/* Get the next pointer of an entry */ +#define LIST_FIELD(list, entry) (*(void **)((char *)(entry) + (list)->ofs)) + +/* Return the next emlement in list */ +#define LIST_NEXT(list, entry, type) ((type *)(LIST_FIELD(list, entry))) + +/* Iterate through all entries in list */ +#define LIST_FOR_EACH(list, entry, type) \ + for (entry = LIST_HEAD(list, type); \ + entry; \ + entry = LIST_NEXT(list, entry, type)) + +/*! Initialize a list during runtime + * + * \param list The list to initialize + * \param offset The number of bytes into the entry structure the next pointer + * is found + */ +extern void drvmgr_list_init(struct drvmgr_list *list, int offset); + +/*! Clear list */ +extern void drvmgr_list_empty(struct drvmgr_list *list); + +/*! Add entry to front of list */ +extern void drvmgr_list_add_head(struct drvmgr_list *list, void *entry); + +/*! Add entry to end of list */ +extern void drvmgr_list_add_tail(struct drvmgr_list *list, void *entry); + +/*! Remove entry from front of list */ +extern void drvmgr_list_remove_head(struct drvmgr_list *list); + +/*! Remove entry from anywhere in list */ +extern void drvmgr_list_remove(struct drvmgr_list *list, void *entry); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/include/drvmgr/pci_bus.h b/cpukit/include/drvmgr/pci_bus.h new file mode 100644 index 0000000000..b426010da5 --- /dev/null +++ b/cpukit/include/drvmgr/pci_bus.h @@ -0,0 +1,161 @@ +/* PCI bus driver Interface. + * + * COPYRIGHT (c) 2008 Cobham Gaisler AB. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + */ + +/* General part of drvmgr PCI Bus driver. The driver is typically + * initialized from the PCI host driver separating the host + * driver from the common parts in PCI drivers. + * The PCI library must be initialized before starting the + * PCI bus driver. The PCI library have set up BARs and + * assigned system IRQs for targets. + * This PCI bus driver rely on the PCI library (pci.c) for + * interrupt registeration (pci_interrupt_register) and PCI + * target set up. + */ + +#ifndef __PCI_BUS_H__ +#define __PCI_BUS_H__ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* PCI Driver ID generation (VENDOR: 16-bit, DEVICE: 16-bit) */ +#define DRIVER_PCI_ID(vendor, device) \ + DRIVER_ID(DRVMGR_BUS_TYPE_PCI, \ + ((((vendor) & 0xffff) << 16) | ((device) & 0xffff))) + +/* PCI Driver ID generation (CLASS: 24-bit) */ +#define DRIVER_PCI_CLASS(class) \ + DRIVER_ID(DRVMGR_BUS_TYPE_PCI, ((1 << 32) | ((class) & 0xffffff))) + +/* PCI driver IDs (DRIVER_PCI_VENDOR_DEVICE or DRIVER_PCI_CLASS_NAME) */ +#define DRIVER_PCI_GAISLER_RASTAIO_ID DRIVER_PCI_ID(PCIID_VENDOR_GAISLER, PCIID_DEVICE_GR_RASTA_IO) +#define DRIVER_PCI_GAISLER_RASTATMTC_ID DRIVER_PCI_ID(PCIID_VENDOR_GAISLER, PCIID_DEVICE_GR_RASTA_TMTC) +#define DRIVER_PCI_GAISLER_GR701_ID DRIVER_PCI_ID(PCIID_VENDOR_GAISLER, PCIID_DEVICE_GR_701) +#define DRIVER_PCI_GAISLER_RASTAADCDAC_ID DRIVER_PCI_ID(PCIID_VENDOR_GAISLER, PCIID_DEVICE_GR_RASTA_ADCDAC) +#define DRIVER_PCI_GAISLER_TMTC_1553_ID DRIVER_PCI_ID(PCIID_VENDOR_GAISLER, PCIID_DEVICE_GR_TMTC_1553) +#define DRIVER_PCI_GAISLER_RASTA_SPW_ROUTER_ID DRIVER_PCI_ID(PCIID_VENDOR_GAISLER, PCIID_DEVICE_GR_RASTA_SPW_RTR) +#define DRIVER_PCI_GAISLER_LEON4_N2X_ID DRIVER_PCI_ID(PCIID_VENDOR_GAISLER, PCIID_DEVICE_GR_LEON4_N2X) +#define DRIVER_PCI_GAISLER_CPCI_GR740_ID DRIVER_PCI_ID(PCIID_VENDOR_GAISLER, PCIID_DEVICE_GR_CPCI_GR740) + +struct pci_dev_id { + uint16_t vendor; + uint16_t device; + uint16_t subvendor; + uint16_t subdevice; + uint32_t class; /* 24 lower bits */ +}; + +struct pci_dev_id_match { + uint16_t vendor; + uint16_t device; + uint16_t subvendor; + uint16_t subdevice; + uint32_t class; /* 24 lower bits */ + uint32_t class_mask; /* 24 lower bits */ +}; +#define PCIID_DEVVEND(vendor, device) \ + {vendor, device, PCI_ID_ANY, PCI_ID_ANY, 0, 0} +#define PCIID_END_TABLE {0, 0, 0, 0, 0, 0} + +enum { + /* A Device has up to 6 BARs and an optional ROM BAR */ + PCIDEV_RES_BAR1 = 0, + PCIDEV_RES_BAR2 = 1, + PCIDEV_RES_BAR3 = 2, + PCIDEV_RES_BAR4 = 3, + PCIDEV_RES_BAR5 = 4, + PCIDEV_RES_BAR6 = 5, + PCIDEV_RES_ROM = 6, +}; +/* Maximum Number of Resources of a device */ +#define PCIDEV_RES_CNT (PCIDEV_RES_ROM + 1) + +/* IO, MEMIO or MEM resource. Can be BAR, ROM or Bridge Window */ +struct pcibus_res { + uint32_t address; /* Base Address, CPU accessible */ + uint32_t size; /* 0=Unimplemented, 0!=Resource Size */ + struct pci_res *res; /* PCI-layer resource */ +}; + +struct pci_dev_info { + struct pci_dev_id id; + uint8_t rev; + uint8_t irq; /* 0 = NO IRQ */ + pci_dev_t pcidev; + struct pcibus_res resources[PCIDEV_RES_CNT]; + struct pci_dev *pci_device; +}; + +struct pci_drv_info { + struct drvmgr_drv general; /* General bus info */ + /* PCI specific bus information */ + struct pci_dev_id_match *ids; /* Supported hardware */ +}; + +/* Access routines */ +struct pcibus_regmem_ops { + drvmgr_r8 r8; + drvmgr_r16 r16; + drvmgr_r32 r32; + drvmgr_r64 r64; + drvmgr_w8 w8; + drvmgr_w16 w16; + drvmgr_w32 w32; + drvmgr_w64 w64; +}; + +/* Let driver configure PCI bus driver */ +struct pcibus_config { + struct drvmgr_map_entry *maps_up; + struct drvmgr_map_entry *maps_down; +}; + +/* PCI Configuration Space Access - Not implemented (use PCI Lib directly) */ +#define PCI_FUNC_CFG_R8 DRVMGR_RWFUNC(RW_SIZE_1|RW_READ|RW_CFG) +#define PCI_FUNC_CFG_R16 DRVMGR_RWFUNC(RW_SIZE_2|RW_READ|RW_CFG) +#define PCI_FUNC_CFG_R32 DRVMGR_RWFUNC(RW_SIZE_4|RW_READ|RW_CFG) +#define PCI_FUNC_CFG_W8 DRVMGR_RWFUNC(RW_SIZE_1|RW_WRITE|RW_CFG) +#define PCI_FUNC_CFG_W16 DRVMGR_RWFUNC(RW_SIZE_2|RW_WRITE|RW_CFG) +#define PCI_FUNC_CFG_W32 DRVMGR_RWFUNC(RW_SIZE_4|RW_WRITE|RW_CFG) + +/* PCI I/O Register Access - Not implemented (use PCI Lib directly) */ +#define PCI_FUNC_IO_R8 DRVMGR_RWFUNC(RW_SIZE_1|RW_READ|RW_IO) +#define PCI_FUNC_IO_R16 DRVMGR_RWFUNC(RW_SIZE_2|RW_READ|RW_IO) +#define PCI_FUNC_IO_R32 DRVMGR_RWFUNC(RW_SIZE_4|RW_READ|RW_IO) +#define PCI_FUNC_IO_W8 DRVMGR_RWFUNC(RW_SIZE_1|RW_WRITE|RW_IO) +#define PCI_FUNC_IO_W16 DRVMGR_RWFUNC(RW_SIZE_2|RW_WRITE|RW_IO) +#define PCI_FUNC_IO_W32 DRVMGR_RWFUNC(RW_SIZE_4|RW_WRITE|RW_IO) + +/* PCI Register Access over Memory Space (Little Endian) */ +#define PCI_FUNC_MREG_R8 DRVMGR_RWFUNC(RW_SIZE_1|RW_READ|RW_MEMREG) +#define PCI_FUNC_MREG_R16 DRVMGR_RWFUNC(RW_SIZE_2|RW_READ|RW_MEMREG|RW_LITTLE) +#define PCI_FUNC_MREG_R32 DRVMGR_RWFUNC(RW_SIZE_4|RW_READ|RW_MEMREG|RW_LITTLE) +#define PCI_FUNC_MREG_W8 DRVMGR_RWFUNC(RW_SIZE_1|RW_WRITE|RW_MEMREG) +#define PCI_FUNC_MREG_W16 DRVMGR_RWFUNC(RW_SIZE_2|RW_WRITE|RW_MEMREG|RW_LITTLE) +#define PCI_FUNC_MREG_W32 DRVMGR_RWFUNC(RW_SIZE_4|RW_WRITE|RW_MEMREG|RW_LITTLE) + +/* Weak default PCI driver resources, override this from project configuration + * to set PCI Bus resources used to configure PCI device drivers. + */ +extern struct drvmgr_bus_res pcibus_drv_resources; + +/* Attach a PCI bus on top of a PCI Host device */ +extern int pcibus_register(struct drvmgr_dev *dev, struct pcibus_config *cfg); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/include/fdt.h b/cpukit/include/fdt.h new file mode 100644 index 0000000000..526aedb515 --- /dev/null +++ b/cpukit/include/fdt.h @@ -0,0 +1,111 @@ +#ifndef _FDT_H +#define _FDT_H +/* + * libfdt - Flat Device Tree manipulation + * Copyright (C) 2006 David Gibson, IBM Corporation. + * Copyright 2012 Kim Phillips, Freescale Semiconductor. + * + * libfdt is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * + * a) This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, + * MA 02110-1301 USA + * + * Alternatively, + * + * b) Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __ASSEMBLY__ + +struct fdt_header { + fdt32_t magic; /* magic word FDT_MAGIC */ + fdt32_t totalsize; /* total size of DT block */ + fdt32_t off_dt_struct; /* offset to structure */ + fdt32_t off_dt_strings; /* offset to strings */ + fdt32_t off_mem_rsvmap; /* offset to memory reserve map */ + fdt32_t version; /* format version */ + fdt32_t last_comp_version; /* last compatible version */ + + /* version 2 fields below */ + fdt32_t boot_cpuid_phys; /* Which physical CPU id we're + booting on */ + /* version 3 fields below */ + fdt32_t size_dt_strings; /* size of the strings block */ + + /* version 17 fields below */ + fdt32_t size_dt_struct; /* size of the structure block */ +}; + +struct fdt_reserve_entry { + fdt64_t address; + fdt64_t size; +}; + +struct fdt_node_header { + fdt32_t tag; + char name[0]; +}; + +struct fdt_property { + fdt32_t tag; + fdt32_t len; + fdt32_t nameoff; + char data[0]; +}; + +#endif /* !__ASSEMBLY */ + +#define FDT_MAGIC 0xd00dfeed /* 4: version, 4: total size */ +#define FDT_TAGSIZE sizeof(fdt32_t) + +#define FDT_BEGIN_NODE 0x1 /* Start node: full name */ +#define FDT_END_NODE 0x2 /* End node */ +#define FDT_PROP 0x3 /* Property: name off, + size, content */ +#define FDT_NOP 0x4 /* nop */ +#define FDT_END 0x9 + +#define FDT_V1_SIZE (7*sizeof(fdt32_t)) +#define FDT_V2_SIZE (FDT_V1_SIZE + sizeof(fdt32_t)) +#define FDT_V3_SIZE (FDT_V2_SIZE + sizeof(fdt32_t)) +#define FDT_V16_SIZE FDT_V3_SIZE +#define FDT_V17_SIZE (FDT_V16_SIZE + sizeof(fdt32_t)) + +#endif /* _FDT_H */ diff --git a/cpukit/include/libfdt.h b/cpukit/include/libfdt.h new file mode 100644 index 0000000000..78adb1232e --- /dev/null +++ b/cpukit/include/libfdt.h @@ -0,0 +1,1653 @@ +#ifndef _LIBFDT_H +#define _LIBFDT_H +/* + * libfdt - Flat Device Tree manipulation + * Copyright (C) 2006 David Gibson, IBM Corporation. + * + * libfdt is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * + * a) This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, + * MA 02110-1301 USA + * + * Alternatively, + * + * b) Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include + +#define FDT_FIRST_SUPPORTED_VERSION 0x10 +#define FDT_LAST_SUPPORTED_VERSION 0x11 + +/* Error codes: informative error codes */ +#define FDT_ERR_NOTFOUND 1 + /* FDT_ERR_NOTFOUND: The requested node or property does not exist */ +#define FDT_ERR_EXISTS 2 + /* FDT_ERR_EXISTS: Attemped to create a node or property which + * already exists */ +#define FDT_ERR_NOSPACE 3 + /* FDT_ERR_NOSPACE: Operation needed to expand the device + * tree, but its buffer did not have sufficient space to + * contain the expanded tree. Use fdt_open_into() to move the + * device tree to a buffer with more space. */ + +/* Error codes: codes for bad parameters */ +#define FDT_ERR_BADOFFSET 4 + /* FDT_ERR_BADOFFSET: Function was passed a structure block + * offset which is out-of-bounds, or which points to an + * unsuitable part of the structure for the operation. */ +#define FDT_ERR_BADPATH 5 + /* FDT_ERR_BADPATH: Function was passed a badly formatted path + * (e.g. missing a leading / for a function which requires an + * absolute path) */ +#define FDT_ERR_BADPHANDLE 6 + /* FDT_ERR_BADPHANDLE: Function was passed an invalid phandle + * value. phandle values of 0 and -1 are not permitted. */ +#define FDT_ERR_BADSTATE 7 + /* FDT_ERR_BADSTATE: Function was passed an incomplete device + * tree created by the sequential-write functions, which is + * not sufficiently complete for the requested operation. */ + +/* Error codes: codes for bad device tree blobs */ +#define FDT_ERR_TRUNCATED 8 + /* FDT_ERR_TRUNCATED: Structure block of the given device tree + * ends without an FDT_END tag. */ +#define FDT_ERR_BADMAGIC 9 + /* FDT_ERR_BADMAGIC: Given "device tree" appears not to be a + * device tree at all - it is missing the flattened device + * tree magic number. */ +#define FDT_ERR_BADVERSION 10 + /* FDT_ERR_BADVERSION: Given device tree has a version which + * can't be handled by the requested operation. For + * read-write functions, this may mean that fdt_open_into() is + * required to convert the tree to the expected version. */ +#define FDT_ERR_BADSTRUCTURE 11 + /* FDT_ERR_BADSTRUCTURE: Given device tree has a corrupt + * structure block or other serious error (e.g. misnested + * nodes, or subnodes preceding properties). */ +#define FDT_ERR_BADLAYOUT 12 + /* FDT_ERR_BADLAYOUT: For read-write functions, the given + * device tree has it's sub-blocks in an order that the + * function can't handle (memory reserve map, then structure, + * then strings). Use fdt_open_into() to reorganize the tree + * into a form suitable for the read-write operations. */ + +/* "Can't happen" error indicating a bug in libfdt */ +#define FDT_ERR_INTERNAL 13 + /* FDT_ERR_INTERNAL: libfdt has failed an internal assertion. + * Should never be returned, if it is, it indicates a bug in + * libfdt itself. */ + +/* Errors in device tree content */ +#define FDT_ERR_BADNCELLS 14 + /* FDT_ERR_BADNCELLS: Device tree has a #address-cells, #size-cells + * or similar property with a bad format or value */ + +#define FDT_ERR_BADVALUE 15 + /* FDT_ERR_BADVALUE: Device tree has a property with an unexpected + * value. For example: a property expected to contain a string list + * is not NUL-terminated within the length of its value. */ + +#define FDT_ERR_MAX 15 + +/**********************************************************************/ +/* Low-level functions (you probably don't need these) */ +/**********************************************************************/ + +const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int checklen); +static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen) +{ + return (void *)(uintptr_t)fdt_offset_ptr(fdt, offset, checklen); +} + +uint32_t fdt_next_tag(const void *fdt, int offset, int *nextoffset); + +/**********************************************************************/ +/* Traversal functions */ +/**********************************************************************/ + +int fdt_next_node(const void *fdt, int offset, int *depth); + +/** + * fdt_first_subnode() - get offset of first direct subnode + * + * @fdt: FDT blob + * @offset: Offset of node to check + * @return offset of first subnode, or -FDT_ERR_NOTFOUND if there is none + */ +int fdt_first_subnode(const void *fdt, int offset); + +/** + * fdt_next_subnode() - get offset of next direct subnode + * + * After first calling fdt_first_subnode(), call this function repeatedly to + * get direct subnodes of a parent node. + * + * @fdt: FDT blob + * @offset: Offset of previous subnode + * @return offset of next subnode, or -FDT_ERR_NOTFOUND if there are no more + * subnodes + */ +int fdt_next_subnode(const void *fdt, int offset); + +/**********************************************************************/ +/* General functions */ +/**********************************************************************/ + +#define fdt_get_header(fdt, field) \ + (fdt32_to_cpu(((const struct fdt_header *)(fdt))->field)) +#define fdt_magic(fdt) (fdt_get_header(fdt, magic)) +#define fdt_totalsize(fdt) (fdt_get_header(fdt, totalsize)) +#define fdt_off_dt_struct(fdt) (fdt_get_header(fdt, off_dt_struct)) +#define fdt_off_dt_strings(fdt) (fdt_get_header(fdt, off_dt_strings)) +#define fdt_off_mem_rsvmap(fdt) (fdt_get_header(fdt, off_mem_rsvmap)) +#define fdt_version(fdt) (fdt_get_header(fdt, version)) +#define fdt_last_comp_version(fdt) (fdt_get_header(fdt, last_comp_version)) +#define fdt_boot_cpuid_phys(fdt) (fdt_get_header(fdt, boot_cpuid_phys)) +#define fdt_size_dt_strings(fdt) (fdt_get_header(fdt, size_dt_strings)) +#define fdt_size_dt_struct(fdt) (fdt_get_header(fdt, size_dt_struct)) + +#define __fdt_set_hdr(name) \ + static inline void fdt_set_##name(void *fdt, uint32_t val) \ + { \ + struct fdt_header *fdth = (struct fdt_header*)fdt; \ + fdth->name = cpu_to_fdt32(val); \ + } +__fdt_set_hdr(magic); +__fdt_set_hdr(totalsize); +__fdt_set_hdr(off_dt_struct); +__fdt_set_hdr(off_dt_strings); +__fdt_set_hdr(off_mem_rsvmap); +__fdt_set_hdr(version); +__fdt_set_hdr(last_comp_version); +__fdt_set_hdr(boot_cpuid_phys); +__fdt_set_hdr(size_dt_strings); +__fdt_set_hdr(size_dt_struct); +#undef __fdt_set_hdr + +/** + * fdt_check_header - sanity check a device tree or possible device tree + * @fdt: pointer to data which might be a flattened device tree + * + * fdt_check_header() checks that the given buffer contains what + * appears to be a flattened device tree with sane information in its + * header. + * + * returns: + * 0, if the buffer appears to contain a valid device tree + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, standard meanings, as above + */ +int fdt_check_header(const void *fdt); + +/** + * fdt_move - move a device tree around in memory + * @fdt: pointer to the device tree to move + * @buf: pointer to memory where the device is to be moved + * @bufsize: size of the memory space at buf + * + * fdt_move() relocates, if possible, the device tree blob located at + * fdt to the buffer at buf of size bufsize. The buffer may overlap + * with the existing device tree blob at fdt. Therefore, + * fdt_move(fdt, fdt, fdt_totalsize(fdt)) + * should always succeed. + * + * returns: + * 0, on success + * -FDT_ERR_NOSPACE, bufsize is insufficient to contain the device tree + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, standard meanings + */ +int fdt_move(const void *fdt, void *buf, int bufsize); + +/**********************************************************************/ +/* Read-only functions */ +/**********************************************************************/ + +/** + * fdt_string - retrieve a string from the strings block of a device tree + * @fdt: pointer to the device tree blob + * @stroffset: offset of the string within the strings block (native endian) + * + * fdt_string() retrieves a pointer to a single string from the + * strings block of the device tree blob at fdt. + * + * returns: + * a pointer to the string, on success + * NULL, if stroffset is out of bounds + */ +const char *fdt_string(const void *fdt, int stroffset); + +/** + * fdt_num_mem_rsv - retrieve the number of memory reserve map entries + * @fdt: pointer to the device tree blob + * + * Returns the number of entries in the device tree blob's memory + * reservation map. This does not include the terminating 0,0 entry + * or any other (0,0) entries reserved for expansion. + * + * returns: + * the number of entries + */ +int fdt_num_mem_rsv(const void *fdt); + +/** + * fdt_get_mem_rsv - retrieve one memory reserve map entry + * @fdt: pointer to the device tree blob + * @address, @size: pointers to 64-bit variables + * + * On success, *address and *size will contain the address and size of + * the n-th reserve map entry from the device tree blob, in + * native-endian format. + * + * returns: + * 0, on success + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, standard meanings + */ +int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size); + +/** + * fdt_subnode_offset_namelen - find a subnode based on substring + * @fdt: pointer to the device tree blob + * @parentoffset: structure block offset of a node + * @name: name of the subnode to locate + * @namelen: number of characters of name to consider + * + * Identical to fdt_subnode_offset(), but only examine the first + * namelen characters of name for matching the subnode name. This is + * useful for finding subnodes based on a portion of a larger string, + * such as a full path. + */ +int fdt_subnode_offset_namelen(const void *fdt, int parentoffset, + const char *name, int namelen); +/** + * fdt_subnode_offset - find a subnode of a given node + * @fdt: pointer to the device tree blob + * @parentoffset: structure block offset of a node + * @name: name of the subnode to locate + * + * fdt_subnode_offset() finds a subnode of the node at structure block + * offset parentoffset with the given name. name may include a unit + * address, in which case fdt_subnode_offset() will find the subnode + * with that unit address, or the unit address may be omitted, in + * which case fdt_subnode_offset() will find an arbitrary subnode + * whose name excluding unit address matches the given name. + * + * returns: + * structure block offset of the requested subnode (>=0), on success + * -FDT_ERR_NOTFOUND, if the requested subnode does not exist + * -FDT_ERR_BADOFFSET, if parentoffset did not point to an FDT_BEGIN_NODE tag + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, + * -FDT_ERR_TRUNCATED, standard meanings. + */ +int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name); + +/** + * fdt_path_offset_namelen - find a tree node by its full path + * @fdt: pointer to the device tree blob + * @path: full path of the node to locate + * @namelen: number of characters of path to consider + * + * Identical to fdt_path_offset(), but only consider the first namelen + * characters of path as the path name. + */ +int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen); + +/** + * fdt_path_offset - find a tree node by its full path + * @fdt: pointer to the device tree blob + * @path: full path of the node to locate + * + * fdt_path_offset() finds a node of a given path in the device tree. + * Each path component may omit the unit address portion, but the + * results of this are undefined if any such path component is + * ambiguous (that is if there are multiple nodes at the relevant + * level matching the given component, differentiated only by unit + * address). + * + * returns: + * structure block offset of the node with the requested path (>=0), on success + * -FDT_ERR_BADPATH, given path does not begin with '/' or is invalid + * -FDT_ERR_NOTFOUND, if the requested node does not exist + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, + * -FDT_ERR_TRUNCATED, standard meanings. + */ +int fdt_path_offset(const void *fdt, const char *path); + +/** + * fdt_get_name - retrieve the name of a given node + * @fdt: pointer to the device tree blob + * @nodeoffset: structure block offset of the starting node + * @lenp: pointer to an integer variable (will be overwritten) or NULL + * + * fdt_get_name() retrieves the name (including unit address) of the + * device tree node at structure block offset nodeoffset. If lenp is + * non-NULL, the length of this name is also returned, in the integer + * pointed to by lenp. + * + * returns: + * pointer to the node's name, on success + * If lenp is non-NULL, *lenp contains the length of that name (>=0) + * NULL, on error + * if lenp is non-NULL *lenp contains an error code (<0): + * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, standard meanings + */ +const char *fdt_get_name(const void *fdt, int nodeoffset, int *lenp); + +/** + * fdt_first_property_offset - find the offset of a node's first property + * @fdt: pointer to the device tree blob + * @nodeoffset: structure block offset of a node + * + * fdt_first_property_offset() finds the first property of the node at + * the given structure block offset. + * + * returns: + * structure block offset of the property (>=0), on success + * -FDT_ERR_NOTFOUND, if the requested node has no properties + * -FDT_ERR_BADOFFSET, if nodeoffset did not point to an FDT_BEGIN_NODE tag + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, + * -FDT_ERR_TRUNCATED, standard meanings. + */ +int fdt_first_property_offset(const void *fdt, int nodeoffset); + +/** + * fdt_next_property_offset - step through a node's properties + * @fdt: pointer to the device tree blob + * @offset: structure block offset of a property + * + * fdt_next_property_offset() finds the property immediately after the + * one at the given structure block offset. This will be a property + * of the same node as the given property. + * + * returns: + * structure block offset of the next property (>=0), on success + * -FDT_ERR_NOTFOUND, if the given property is the last in its node + * -FDT_ERR_BADOFFSET, if nodeoffset did not point to an FDT_PROP tag + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, + * -FDT_ERR_TRUNCATED, standard meanings. + */ +int fdt_next_property_offset(const void *fdt, int offset); + +/** + * fdt_get_property_by_offset - retrieve the property at a given offset + * @fdt: pointer to the device tree blob + * @offset: offset of the property to retrieve + * @lenp: pointer to an integer variable (will be overwritten) or NULL + * + * fdt_get_property_by_offset() retrieves a pointer to the + * fdt_property structure within the device tree blob at the given + * offset. If lenp is non-NULL, the length of the property value is + * also returned, in the integer pointed to by lenp. + * + * returns: + * pointer to the structure representing the property + * if lenp is non-NULL, *lenp contains the length of the property + * value (>=0) + * NULL, on error + * if lenp is non-NULL, *lenp contains an error code (<0): + * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_PROP tag + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, + * -FDT_ERR_TRUNCATED, standard meanings + */ +const struct fdt_property *fdt_get_property_by_offset(const void *fdt, + int offset, + int *lenp); + +/** + * fdt_get_property_namelen - find a property based on substring + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node whose property to find + * @name: name of the property to find + * @namelen: number of characters of name to consider + * @lenp: pointer to an integer variable (will be overwritten) or NULL + * + * Identical to fdt_get_property(), but only examine the first namelen + * characters of name for matching the property name. + */ +const struct fdt_property *fdt_get_property_namelen(const void *fdt, + int nodeoffset, + const char *name, + int namelen, int *lenp); + +/** + * fdt_get_property - find a given property in a given node + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node whose property to find + * @name: name of the property to find + * @lenp: pointer to an integer variable (will be overwritten) or NULL + * + * fdt_get_property() retrieves a pointer to the fdt_property + * structure within the device tree blob corresponding to the property + * named 'name' of the node at offset nodeoffset. If lenp is + * non-NULL, the length of the property value is also returned, in the + * integer pointed to by lenp. + * + * returns: + * pointer to the structure representing the property + * if lenp is non-NULL, *lenp contains the length of the property + * value (>=0) + * NULL, on error + * if lenp is non-NULL, *lenp contains an error code (<0): + * -FDT_ERR_NOTFOUND, node does not have named property + * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, + * -FDT_ERR_TRUNCATED, standard meanings + */ +const struct fdt_property *fdt_get_property(const void *fdt, int nodeoffset, + const char *name, int *lenp); +static inline struct fdt_property *fdt_get_property_w(void *fdt, int nodeoffset, + const char *name, + int *lenp) +{ + return (struct fdt_property *)(uintptr_t) + fdt_get_property(fdt, nodeoffset, name, lenp); +} + +/** + * fdt_getprop_by_offset - retrieve the value of a property at a given offset + * @fdt: pointer to the device tree blob + * @ffset: offset of the property to read + * @namep: pointer to a string variable (will be overwritten) or NULL + * @lenp: pointer to an integer variable (will be overwritten) or NULL + * + * fdt_getprop_by_offset() retrieves a pointer to the value of the + * property at structure block offset 'offset' (this will be a pointer + * to within the device blob itself, not a copy of the value). If + * lenp is non-NULL, the length of the property value is also + * returned, in the integer pointed to by lenp. If namep is non-NULL, + * the property's namne will also be returned in the char * pointed to + * by namep (this will be a pointer to within the device tree's string + * block, not a new copy of the name). + * + * returns: + * pointer to the property's value + * if lenp is non-NULL, *lenp contains the length of the property + * value (>=0) + * if namep is non-NULL *namep contiains a pointer to the property + * name. + * NULL, on error + * if lenp is non-NULL, *lenp contains an error code (<0): + * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_PROP tag + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, + * -FDT_ERR_TRUNCATED, standard meanings + */ +const void *fdt_getprop_by_offset(const void *fdt, int offset, + const char **namep, int *lenp); + +/** + * fdt_getprop_namelen - get property value based on substring + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node whose property to find + * @name: name of the property to find + * @namelen: number of characters of name to consider + * @lenp: pointer to an integer variable (will be overwritten) or NULL + * + * Identical to fdt_getprop(), but only examine the first namelen + * characters of name for matching the property name. + */ +const void *fdt_getprop_namelen(const void *fdt, int nodeoffset, + const char *name, int namelen, int *lenp); + +/** + * fdt_getprop - retrieve the value of a given property + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node whose property to find + * @name: name of the property to find + * @lenp: pointer to an integer variable (will be overwritten) or NULL + * + * fdt_getprop() retrieves a pointer to the value of the property + * named 'name' of the node at offset nodeoffset (this will be a + * pointer to within the device blob itself, not a copy of the value). + * If lenp is non-NULL, the length of the property value is also + * returned, in the integer pointed to by lenp. + * + * returns: + * pointer to the property's value + * if lenp is non-NULL, *lenp contains the length of the property + * value (>=0) + * NULL, on error + * if lenp is non-NULL, *lenp contains an error code (<0): + * -FDT_ERR_NOTFOUND, node does not have named property + * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, + * -FDT_ERR_TRUNCATED, standard meanings + */ +const void *fdt_getprop(const void *fdt, int nodeoffset, + const char *name, int *lenp); +static inline void *fdt_getprop_w(void *fdt, int nodeoffset, + const char *name, int *lenp) +{ + return (void *)(uintptr_t)fdt_getprop(fdt, nodeoffset, name, lenp); +} + +/** + * fdt_get_phandle - retrieve the phandle of a given node + * @fdt: pointer to the device tree blob + * @nodeoffset: structure block offset of the node + * + * fdt_get_phandle() retrieves the phandle of the device tree node at + * structure block offset nodeoffset. + * + * returns: + * the phandle of the node at nodeoffset, on success (!= 0, != -1) + * 0, if the node has no phandle, or another error occurs + */ +uint32_t fdt_get_phandle(const void *fdt, int nodeoffset); + +/** + * fdt_get_alias_namelen - get alias based on substring + * @fdt: pointer to the device tree blob + * @name: name of the alias th look up + * @namelen: number of characters of name to consider + * + * Identical to fdt_get_alias(), but only examine the first namelen + * characters of name for matching the alias name. + */ +const char *fdt_get_alias_namelen(const void *fdt, + const char *name, int namelen); + +/** + * fdt_get_alias - retreive the path referenced by a given alias + * @fdt: pointer to the device tree blob + * @name: name of the alias th look up + * + * fdt_get_alias() retrieves the value of a given alias. That is, the + * value of the property named 'name' in the node /aliases. + * + * returns: + * a pointer to the expansion of the alias named 'name', if it exists + * NULL, if the given alias or the /aliases node does not exist + */ +const char *fdt_get_alias(const void *fdt, const char *name); + +/** + * fdt_get_path - determine the full path of a node + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node whose path to find + * @buf: character buffer to contain the returned path (will be overwritten) + * @buflen: size of the character buffer at buf + * + * fdt_get_path() computes the full path of the node at offset + * nodeoffset, and records that path in the buffer at buf. + * + * NOTE: This function is expensive, as it must scan the device tree + * structure from the start to nodeoffset. + * + * returns: + * 0, on success + * buf contains the absolute path of the node at + * nodeoffset, as a NUL-terminated string. + * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag + * -FDT_ERR_NOSPACE, the path of the given node is longer than (bufsize-1) + * characters and will not fit in the given buffer. + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, standard meanings + */ +int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen); + +/** + * fdt_supernode_atdepth_offset - find a specific ancestor of a node + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node whose parent to find + * @supernodedepth: depth of the ancestor to find + * @nodedepth: pointer to an integer variable (will be overwritten) or NULL + * + * fdt_supernode_atdepth_offset() finds an ancestor of the given node + * at a specific depth from the root (where the root itself has depth + * 0, its immediate subnodes depth 1 and so forth). So + * fdt_supernode_atdepth_offset(fdt, nodeoffset, 0, NULL); + * will always return 0, the offset of the root node. If the node at + * nodeoffset has depth D, then: + * fdt_supernode_atdepth_offset(fdt, nodeoffset, D, NULL); + * will return nodeoffset itself. + * + * NOTE: This function is expensive, as it must scan the device tree + * structure from the start to nodeoffset. + * + * returns: + + * structure block offset of the node at node offset's ancestor + * of depth supernodedepth (>=0), on success + * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag +* -FDT_ERR_NOTFOUND, supernodedepth was greater than the depth of nodeoffset + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, standard meanings + */ +int fdt_supernode_atdepth_offset(const void *fdt, int nodeoffset, + int supernodedepth, int *nodedepth); + +/** + * fdt_node_depth - find the depth of a given node + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node whose parent to find + * + * fdt_node_depth() finds the depth of a given node. The root node + * has depth 0, its immediate subnodes depth 1 and so forth. + * + * NOTE: This function is expensive, as it must scan the device tree + * structure from the start to nodeoffset. + * + * returns: + * depth of the node at nodeoffset (>=0), on success + * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, standard meanings + */ +int fdt_node_depth(const void *fdt, int nodeoffset); + +/** + * fdt_parent_offset - find the parent of a given node + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node whose parent to find + * + * fdt_parent_offset() locates the parent node of a given node (that + * is, it finds the offset of the node which contains the node at + * nodeoffset as a subnode). + * + * NOTE: This function is expensive, as it must scan the device tree + * structure from the start to nodeoffset, *twice*. + * + * returns: + * structure block offset of the parent of the node at nodeoffset + * (>=0), on success + * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, standard meanings + */ +int fdt_parent_offset(const void *fdt, int nodeoffset); + +/** + * fdt_node_offset_by_prop_value - find nodes with a given property value + * @fdt: pointer to the device tree blob + * @startoffset: only find nodes after this offset + * @propname: property name to check + * @propval: property value to search for + * @proplen: length of the value in propval + * + * fdt_node_offset_by_prop_value() returns the offset of the first + * node after startoffset, which has a property named propname whose + * value is of length proplen and has value equal to propval; or if + * startoffset is -1, the very first such node in the tree. + * + * To iterate through all nodes matching the criterion, the following + * idiom can be used: + * offset = fdt_node_offset_by_prop_value(fdt, -1, propname, + * propval, proplen); + * while (offset != -FDT_ERR_NOTFOUND) { + * // other code here + * offset = fdt_node_offset_by_prop_value(fdt, offset, propname, + * propval, proplen); + * } + * + * Note the -1 in the first call to the function, if 0 is used here + * instead, the function will never locate the root node, even if it + * matches the criterion. + * + * returns: + * structure block offset of the located node (>= 0, >startoffset), + * on success + * -FDT_ERR_NOTFOUND, no node matching the criterion exists in the + * tree after startoffset + * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, standard meanings + */ +int fdt_node_offset_by_prop_value(const void *fdt, int startoffset, + const char *propname, + const void *propval, int proplen); + +/** + * fdt_node_offset_by_phandle - find the node with a given phandle + * @fdt: pointer to the device tree blob + * @phandle: phandle value + * + * fdt_node_offset_by_phandle() returns the offset of the node + * which has the given phandle value. If there is more than one node + * in the tree with the given phandle (an invalid tree), results are + * undefined. + * + * returns: + * structure block offset of the located node (>= 0), on success + * -FDT_ERR_NOTFOUND, no node with that phandle exists + * -FDT_ERR_BADPHANDLE, given phandle value was invalid (0 or -1) + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, standard meanings + */ +int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle); + +/** + * fdt_node_check_compatible: check a node's compatible property + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of a tree node + * @compatible: string to match against + * + * + * fdt_node_check_compatible() returns 0 if the given node contains a + * 'compatible' property with the given string as one of its elements, + * it returns non-zero otherwise, or on error. + * + * returns: + * 0, if the node has a 'compatible' property listing the given string + * 1, if the node has a 'compatible' property, but it does not list + * the given string + * -FDT_ERR_NOTFOUND, if the given node has no 'compatible' property + * -FDT_ERR_BADOFFSET, if nodeoffset does not refer to a BEGIN_NODE tag + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, standard meanings + */ +int fdt_node_check_compatible(const void *fdt, int nodeoffset, + const char *compatible); + +/** + * fdt_node_offset_by_compatible - find nodes with a given 'compatible' value + * @fdt: pointer to the device tree blob + * @startoffset: only find nodes after this offset + * @compatible: 'compatible' string to match against + * + * fdt_node_offset_by_compatible() returns the offset of the first + * node after startoffset, which has a 'compatible' property which + * lists the given compatible string; or if startoffset is -1, the + * very first such node in the tree. + * + * To iterate through all nodes matching the criterion, the following + * idiom can be used: + * offset = fdt_node_offset_by_compatible(fdt, -1, compatible); + * while (offset != -FDT_ERR_NOTFOUND) { + * // other code here + * offset = fdt_node_offset_by_compatible(fdt, offset, compatible); + * } + * + * Note the -1 in the first call to the function, if 0 is used here + * instead, the function will never locate the root node, even if it + * matches the criterion. + * + * returns: + * structure block offset of the located node (>= 0, >startoffset), + * on success + * -FDT_ERR_NOTFOUND, no node matching the criterion exists in the + * tree after startoffset + * -FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, standard meanings + */ +int fdt_node_offset_by_compatible(const void *fdt, int startoffset, + const char *compatible); + +/** + * fdt_stringlist_contains - check a string list property for a string + * @strlist: Property containing a list of strings to check + * @listlen: Length of property + * @str: String to search for + * + * This is a utility function provided for convenience. The list contains + * one or more strings, each terminated by \0, as is found in a device tree + * "compatible" property. + * + * @return: 1 if the string is found in the list, 0 not found, or invalid list + */ +int fdt_stringlist_contains(const char *strlist, int listlen, const char *str); + +/** + * fdt_stringlist_count - count the number of strings in a string list + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of a tree node + * @property: name of the property containing the string list + * @return: + * the number of strings in the given property + * -FDT_ERR_BADVALUE if the property value is not NUL-terminated + * -FDT_ERR_NOTFOUND if the property does not exist + */ +int fdt_stringlist_count(const void *fdt, int nodeoffset, const char *property); + +/** + * fdt_stringlist_search - find a string in a string list and return its index + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of a tree node + * @property: name of the property containing the string list + * @string: string to look up in the string list + * + * Note that it is possible for this function to succeed on property values + * that are not NUL-terminated. That's because the function will stop after + * finding the first occurrence of @string. This can for example happen with + * small-valued cell properties, such as #address-cells, when searching for + * the empty string. + * + * @return: + * the index of the string in the list of strings + * -FDT_ERR_BADVALUE if the property value is not NUL-terminated + * -FDT_ERR_NOTFOUND if the property does not exist or does not contain + * the given string + */ +int fdt_stringlist_search(const void *fdt, int nodeoffset, const char *property, + const char *string); + +/** + * fdt_stringlist_get() - obtain the string at a given index in a string list + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of a tree node + * @property: name of the property containing the string list + * @index: index of the string to return + * @lenp: return location for the string length or an error code on failure + * + * Note that this will successfully extract strings from properties with + * non-NUL-terminated values. For example on small-valued cell properties + * this function will return the empty string. + * + * If non-NULL, the length of the string (on success) or a negative error-code + * (on failure) will be stored in the integer pointer to by lenp. + * + * @return: + * A pointer to the string at the given index in the string list or NULL on + * failure. On success the length of the string will be stored in the memory + * location pointed to by the lenp parameter, if non-NULL. On failure one of + * the following negative error codes will be returned in the lenp parameter + * (if non-NULL): + * -FDT_ERR_BADVALUE if the property value is not NUL-terminated + * -FDT_ERR_NOTFOUND if the property does not exist + */ +const char *fdt_stringlist_get(const void *fdt, int nodeoffset, + const char *property, int index, + int *lenp); + +/**********************************************************************/ +/* Read-only functions (addressing related) */ +/**********************************************************************/ + +/** + * FDT_MAX_NCELLS - maximum value for #address-cells and #size-cells + * + * This is the maximum value for #address-cells, #size-cells and + * similar properties that will be processed by libfdt. IEE1275 + * requires that OF implementations handle values up to 4. + * Implementations may support larger values, but in practice higher + * values aren't used. + */ +#define FDT_MAX_NCELLS 4 + +/** + * fdt_address_cells - retrieve address size for a bus represented in the tree + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node to find the address size for + * + * When the node has a valid #address-cells property, returns its value. + * + * returns: + * 0 <= n < FDT_MAX_NCELLS, on success + * 2, if the node has no #address-cells property + * -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid #address-cells property + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, + * -FDT_ERR_TRUNCATED, standard meanings + */ +int fdt_address_cells(const void *fdt, int nodeoffset); + +/** + * fdt_size_cells - retrieve address range size for a bus represented in the + * tree + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node to find the address range size for + * + * When the node has a valid #size-cells property, returns its value. + * + * returns: + * 0 <= n < FDT_MAX_NCELLS, on success + * 2, if the node has no #address-cells property + * -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid #size-cells property + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, + * -FDT_ERR_TRUNCATED, standard meanings + */ +int fdt_size_cells(const void *fdt, int nodeoffset); + + +/**********************************************************************/ +/* Write-in-place functions */ +/**********************************************************************/ + +/** + * fdt_setprop_inplace - change a property's value, but not its size + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node whose property to change + * @name: name of the property to change + * @val: pointer to data to replace the property value with + * @len: length of the property value + * + * fdt_setprop_inplace() replaces the value of a given property with + * the data in val, of length len. This function cannot change the + * size of a property, and so will only work if len is equal to the + * current length of the property. + * + * This function will alter only the bytes in the blob which contain + * the given property value, and will not alter or move any other part + * of the tree. + * + * returns: + * 0, on success + * -FDT_ERR_NOSPACE, if len is not equal to the property's current length + * -FDT_ERR_NOTFOUND, node does not have the named property + * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, + * -FDT_ERR_TRUNCATED, standard meanings + */ +int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name, + const void *val, int len); + +/** + * fdt_setprop_inplace_u32 - change the value of a 32-bit integer property + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node whose property to change + * @name: name of the property to change + * @val: 32-bit integer value to replace the property with + * + * fdt_setprop_inplace_u32() replaces the value of a given property + * with the 32-bit integer value in val, converting val to big-endian + * if necessary. This function cannot change the size of a property, + * and so will only work if the property already exists and has length + * 4. + * + * This function will alter only the bytes in the blob which contain + * the given property value, and will not alter or move any other part + * of the tree. + * + * returns: + * 0, on success + * -FDT_ERR_NOSPACE, if the property's length is not equal to 4 + * -FDT_ERR_NOTFOUND, node does not have the named property + * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, + * -FDT_ERR_TRUNCATED, standard meanings + */ +static inline int fdt_setprop_inplace_u32(void *fdt, int nodeoffset, + const char *name, uint32_t val) +{ + fdt32_t tmp = cpu_to_fdt32(val); + return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp, sizeof(tmp)); +} + +/** + * fdt_setprop_inplace_u64 - change the value of a 64-bit integer property + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node whose property to change + * @name: name of the property to change + * @val: 64-bit integer value to replace the property with + * + * fdt_setprop_inplace_u64() replaces the value of a given property + * with the 64-bit integer value in val, converting val to big-endian + * if necessary. This function cannot change the size of a property, + * and so will only work if the property already exists and has length + * 8. + * + * This function will alter only the bytes in the blob which contain + * the given property value, and will not alter or move any other part + * of the tree. + * + * returns: + * 0, on success + * -FDT_ERR_NOSPACE, if the property's length is not equal to 8 + * -FDT_ERR_NOTFOUND, node does not have the named property + * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, + * -FDT_ERR_TRUNCATED, standard meanings + */ +static inline int fdt_setprop_inplace_u64(void *fdt, int nodeoffset, + const char *name, uint64_t val) +{ + fdt64_t tmp = cpu_to_fdt64(val); + return fdt_setprop_inplace(fdt, nodeoffset, name, &tmp, sizeof(tmp)); +} + +/** + * fdt_setprop_inplace_cell - change the value of a single-cell property + * + * This is an alternative name for fdt_setprop_inplace_u32() + */ +static inline int fdt_setprop_inplace_cell(void *fdt, int nodeoffset, + const char *name, uint32_t val) +{ + return fdt_setprop_inplace_u32(fdt, nodeoffset, name, val); +} + +/** + * fdt_nop_property - replace a property with nop tags + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node whose property to nop + * @name: name of the property to nop + * + * fdt_nop_property() will replace a given property's representation + * in the blob with FDT_NOP tags, effectively removing it from the + * tree. + * + * This function will alter only the bytes in the blob which contain + * the property, and will not alter or move any other part of the + * tree. + * + * returns: + * 0, on success + * -FDT_ERR_NOTFOUND, node does not have the named property + * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, + * -FDT_ERR_TRUNCATED, standard meanings + */ +int fdt_nop_property(void *fdt, int nodeoffset, const char *name); + +/** + * fdt_nop_node - replace a node (subtree) with nop tags + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node to nop + * + * fdt_nop_node() will replace a given node's representation in the + * blob, including all its subnodes, if any, with FDT_NOP tags, + * effectively removing it from the tree. + * + * This function will alter only the bytes in the blob which contain + * the node and its properties and subnodes, and will not alter or + * move any other part of the tree. + * + * returns: + * 0, on success + * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, + * -FDT_ERR_TRUNCATED, standard meanings + */ +int fdt_nop_node(void *fdt, int nodeoffset); + +/**********************************************************************/ +/* Sequential write functions */ +/**********************************************************************/ + +int fdt_create(void *buf, int bufsize); +int fdt_resize(void *fdt, void *buf, int bufsize); +int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size); +int fdt_finish_reservemap(void *fdt); +int fdt_begin_node(void *fdt, const char *name); +int fdt_property(void *fdt, const char *name, const void *val, int len); +static inline int fdt_property_u32(void *fdt, const char *name, uint32_t val) +{ + fdt32_t tmp = cpu_to_fdt32(val); + return fdt_property(fdt, name, &tmp, sizeof(tmp)); +} +static inline int fdt_property_u64(void *fdt, const char *name, uint64_t val) +{ + fdt64_t tmp = cpu_to_fdt64(val); + return fdt_property(fdt, name, &tmp, sizeof(tmp)); +} +static inline int fdt_property_cell(void *fdt, const char *name, uint32_t val) +{ + return fdt_property_u32(fdt, name, val); +} +#define fdt_property_string(fdt, name, str) \ + fdt_property(fdt, name, str, strlen(str)+1) +int fdt_end_node(void *fdt); +int fdt_finish(void *fdt); + +/**********************************************************************/ +/* Read-write functions */ +/**********************************************************************/ + +int fdt_create_empty_tree(void *buf, int bufsize); +int fdt_open_into(const void *fdt, void *buf, int bufsize); +int fdt_pack(void *fdt); + +/** + * fdt_add_mem_rsv - add one memory reserve map entry + * @fdt: pointer to the device tree blob + * @address, @size: 64-bit values (native endian) + * + * Adds a reserve map entry to the given blob reserving a region at + * address address of length size. + * + * This function will insert data into the reserve map and will + * therefore change the indexes of some entries in the table. + * + * returns: + * 0, on success + * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to + * contain the new reservation entry + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, + * -FDT_ERR_BADLAYOUT, + * -FDT_ERR_TRUNCATED, standard meanings + */ +int fdt_add_mem_rsv(void *fdt, uint64_t address, uint64_t size); + +/** + * fdt_del_mem_rsv - remove a memory reserve map entry + * @fdt: pointer to the device tree blob + * @n: entry to remove + * + * fdt_del_mem_rsv() removes the n-th memory reserve map entry from + * the blob. + * + * This function will delete data from the reservation table and will + * therefore change the indexes of some entries in the table. + * + * returns: + * 0, on success + * -FDT_ERR_NOTFOUND, there is no entry of the given index (i.e. there + * are less than n+1 reserve map entries) + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, + * -FDT_ERR_BADLAYOUT, + * -FDT_ERR_TRUNCATED, standard meanings + */ +int fdt_del_mem_rsv(void *fdt, int n); + +/** + * fdt_set_name - change the name of a given node + * @fdt: pointer to the device tree blob + * @nodeoffset: structure block offset of a node + * @name: name to give the node + * + * fdt_set_name() replaces the name (including unit address, if any) + * of the given node with the given string. NOTE: this function can't + * efficiently check if the new name is unique amongst the given + * node's siblings; results are undefined if this function is invoked + * with a name equal to one of the given node's siblings. + * + * This function may insert or delete data from the blob, and will + * therefore change the offsets of some existing nodes. + * + * returns: + * 0, on success + * -FDT_ERR_NOSPACE, there is insufficient free space in the blob + * to contain the new name + * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, standard meanings + */ +int fdt_set_name(void *fdt, int nodeoffset, const char *name); + +/** + * fdt_setprop - create or change a property + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node whose property to change + * @name: name of the property to change + * @val: pointer to data to set the property value to + * @len: length of the property value + * + * fdt_setprop() sets the value of the named property in the given + * node to the given value and length, creating the property if it + * does not already exist. + * + * This function may insert or delete data from the blob, and will + * therefore change the offsets of some existing nodes. + * + * returns: + * 0, on success + * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to + * contain the new property value + * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag + * -FDT_ERR_BADLAYOUT, + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, + * -FDT_ERR_BADLAYOUT, + * -FDT_ERR_TRUNCATED, standard meanings + */ +int fdt_setprop(void *fdt, int nodeoffset, const char *name, + const void *val, int len); + +/** + * fdt_setprop_u32 - set a property to a 32-bit integer + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node whose property to change + * @name: name of the property to change + * @val: 32-bit integer value for the property (native endian) + * + * fdt_setprop_u32() sets the value of the named property in the given + * node to the given 32-bit integer value (converting to big-endian if + * necessary), or creates a new property with that value if it does + * not already exist. + * + * This function may insert or delete data from the blob, and will + * therefore change the offsets of some existing nodes. + * + * returns: + * 0, on success + * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to + * contain the new property value + * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag + * -FDT_ERR_BADLAYOUT, + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, + * -FDT_ERR_BADLAYOUT, + * -FDT_ERR_TRUNCATED, standard meanings + */ +static inline int fdt_setprop_u32(void *fdt, int nodeoffset, const char *name, + uint32_t val) +{ + fdt32_t tmp = cpu_to_fdt32(val); + return fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp)); +} + +/** + * fdt_setprop_u64 - set a property to a 64-bit integer + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node whose property to change + * @name: name of the property to change + * @val: 64-bit integer value for the property (native endian) + * + * fdt_setprop_u64() sets the value of the named property in the given + * node to the given 64-bit integer value (converting to big-endian if + * necessary), or creates a new property with that value if it does + * not already exist. + * + * This function may insert or delete data from the blob, and will + * therefore change the offsets of some existing nodes. + * + * returns: + * 0, on success + * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to + * contain the new property value + * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag + * -FDT_ERR_BADLAYOUT, + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, + * -FDT_ERR_BADLAYOUT, + * -FDT_ERR_TRUNCATED, standard meanings + */ +static inline int fdt_setprop_u64(void *fdt, int nodeoffset, const char *name, + uint64_t val) +{ + fdt64_t tmp = cpu_to_fdt64(val); + return fdt_setprop(fdt, nodeoffset, name, &tmp, sizeof(tmp)); +} + +/** + * fdt_setprop_cell - set a property to a single cell value + * + * This is an alternative name for fdt_setprop_u32() + */ +static inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name, + uint32_t val) +{ + return fdt_setprop_u32(fdt, nodeoffset, name, val); +} + +/** + * fdt_setprop_string - set a property to a string value + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node whose property to change + * @name: name of the property to change + * @str: string value for the property + * + * fdt_setprop_string() sets the value of the named property in the + * given node to the given string value (using the length of the + * string to determine the new length of the property), or creates a + * new property with that value if it does not already exist. + * + * This function may insert or delete data from the blob, and will + * therefore change the offsets of some existing nodes. + * + * returns: + * 0, on success + * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to + * contain the new property value + * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag + * -FDT_ERR_BADLAYOUT, + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, + * -FDT_ERR_BADLAYOUT, + * -FDT_ERR_TRUNCATED, standard meanings + */ +#define fdt_setprop_string(fdt, nodeoffset, name, str) \ + fdt_setprop((fdt), (nodeoffset), (name), (str), strlen(str)+1) + +/** + * fdt_appendprop - append to or create a property + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node whose property to change + * @name: name of the property to append to + * @val: pointer to data to append to the property value + * @len: length of the data to append to the property value + * + * fdt_appendprop() appends the value to the named property in the + * given node, creating the property if it does not already exist. + * + * This function may insert data into the blob, and will therefore + * change the offsets of some existing nodes. + * + * returns: + * 0, on success + * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to + * contain the new property value + * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag + * -FDT_ERR_BADLAYOUT, + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, + * -FDT_ERR_BADLAYOUT, + * -FDT_ERR_TRUNCATED, standard meanings + */ +int fdt_appendprop(void *fdt, int nodeoffset, const char *name, + const void *val, int len); + +/** + * fdt_appendprop_u32 - append a 32-bit integer value to a property + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node whose property to change + * @name: name of the property to change + * @val: 32-bit integer value to append to the property (native endian) + * + * fdt_appendprop_u32() appends the given 32-bit integer value + * (converting to big-endian if necessary) to the value of the named + * property in the given node, or creates a new property with that + * value if it does not already exist. + * + * This function may insert data into the blob, and will therefore + * change the offsets of some existing nodes. + * + * returns: + * 0, on success + * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to + * contain the new property value + * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag + * -FDT_ERR_BADLAYOUT, + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, + * -FDT_ERR_BADLAYOUT, + * -FDT_ERR_TRUNCATED, standard meanings + */ +static inline int fdt_appendprop_u32(void *fdt, int nodeoffset, + const char *name, uint32_t val) +{ + fdt32_t tmp = cpu_to_fdt32(val); + return fdt_appendprop(fdt, nodeoffset, name, &tmp, sizeof(tmp)); +} + +/** + * fdt_appendprop_u64 - append a 64-bit integer value to a property + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node whose property to change + * @name: name of the property to change + * @val: 64-bit integer value to append to the property (native endian) + * + * fdt_appendprop_u64() appends the given 64-bit integer value + * (converting to big-endian if necessary) to the value of the named + * property in the given node, or creates a new property with that + * value if it does not already exist. + * + * This function may insert data into the blob, and will therefore + * change the offsets of some existing nodes. + * + * returns: + * 0, on success + * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to + * contain the new property value + * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag + * -FDT_ERR_BADLAYOUT, + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, + * -FDT_ERR_BADLAYOUT, + * -FDT_ERR_TRUNCATED, standard meanings + */ +static inline int fdt_appendprop_u64(void *fdt, int nodeoffset, + const char *name, uint64_t val) +{ + fdt64_t tmp = cpu_to_fdt64(val); + return fdt_appendprop(fdt, nodeoffset, name, &tmp, sizeof(tmp)); +} + +/** + * fdt_appendprop_cell - append a single cell value to a property + * + * This is an alternative name for fdt_appendprop_u32() + */ +static inline int fdt_appendprop_cell(void *fdt, int nodeoffset, + const char *name, uint32_t val) +{ + return fdt_appendprop_u32(fdt, nodeoffset, name, val); +} + +/** + * fdt_appendprop_string - append a string to a property + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node whose property to change + * @name: name of the property to change + * @str: string value to append to the property + * + * fdt_appendprop_string() appends the given string to the value of + * the named property in the given node, or creates a new property + * with that value if it does not already exist. + * + * This function may insert data into the blob, and will therefore + * change the offsets of some existing nodes. + * + * returns: + * 0, on success + * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to + * contain the new property value + * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag + * -FDT_ERR_BADLAYOUT, + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, + * -FDT_ERR_BADLAYOUT, + * -FDT_ERR_TRUNCATED, standard meanings + */ +#define fdt_appendprop_string(fdt, nodeoffset, name, str) \ + fdt_appendprop((fdt), (nodeoffset), (name), (str), strlen(str)+1) + +/** + * fdt_delprop - delete a property + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node whose property to nop + * @name: name of the property to nop + * + * fdt_del_property() will delete the given property. + * + * This function will delete data from the blob, and will therefore + * change the offsets of some existing nodes. + * + * returns: + * 0, on success + * -FDT_ERR_NOTFOUND, node does not have the named property + * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag + * -FDT_ERR_BADLAYOUT, + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, + * -FDT_ERR_TRUNCATED, standard meanings + */ +int fdt_delprop(void *fdt, int nodeoffset, const char *name); + +/** + * fdt_add_subnode_namelen - creates a new node based on substring + * @fdt: pointer to the device tree blob + * @parentoffset: structure block offset of a node + * @name: name of the subnode to locate + * @namelen: number of characters of name to consider + * + * Identical to fdt_add_subnode(), but use only the first namelen + * characters of name as the name of the new node. This is useful for + * creating subnodes based on a portion of a larger string, such as a + * full path. + */ +int fdt_add_subnode_namelen(void *fdt, int parentoffset, + const char *name, int namelen); + +/** + * fdt_add_subnode - creates a new node + * @fdt: pointer to the device tree blob + * @parentoffset: structure block offset of a node + * @name: name of the subnode to locate + * + * fdt_add_subnode() creates a new node as a subnode of the node at + * structure block offset parentoffset, with the given name (which + * should include the unit address, if any). + * + * This function will insert data into the blob, and will therefore + * change the offsets of some existing nodes. + + * returns: + * structure block offset of the created nodeequested subnode (>=0), on success + * -FDT_ERR_NOTFOUND, if the requested subnode does not exist + * -FDT_ERR_BADOFFSET, if parentoffset did not point to an FDT_BEGIN_NODE tag + * -FDT_ERR_EXISTS, if the node at parentoffset already has a subnode of + * the given name + * -FDT_ERR_NOSPACE, if there is insufficient free space in the + * blob to contain the new node + * -FDT_ERR_NOSPACE + * -FDT_ERR_BADLAYOUT + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, + * -FDT_ERR_TRUNCATED, standard meanings. + */ +int fdt_add_subnode(void *fdt, int parentoffset, const char *name); + +/** + * fdt_del_node - delete a node (subtree) + * @fdt: pointer to the device tree blob + * @nodeoffset: offset of the node to nop + * + * fdt_del_node() will remove the given node, including all its + * subnodes if any, from the blob. + * + * This function will delete data from the blob, and will therefore + * change the offsets of some existing nodes. + * + * returns: + * 0, on success + * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag + * -FDT_ERR_BADLAYOUT, + * -FDT_ERR_BADMAGIC, + * -FDT_ERR_BADVERSION, + * -FDT_ERR_BADSTATE, + * -FDT_ERR_BADSTRUCTURE, + * -FDT_ERR_TRUNCATED, standard meanings + */ +int fdt_del_node(void *fdt, int nodeoffset); + +/**********************************************************************/ +/* Debugging / informational functions */ +/**********************************************************************/ + +const char *fdt_strerror(int errval); + +#endif /* _LIBFDT_H */ diff --git a/cpukit/include/libfdt_env.h b/cpukit/include/libfdt_env.h new file mode 100644 index 0000000000..9dea97dfff --- /dev/null +++ b/cpukit/include/libfdt_env.h @@ -0,0 +1,111 @@ +#ifndef _LIBFDT_ENV_H +#define _LIBFDT_ENV_H +/* + * libfdt - Flat Device Tree manipulation + * Copyright (C) 2006 David Gibson, IBM Corporation. + * Copyright 2012 Kim Phillips, Freescale Semiconductor. + * + * libfdt is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * + * a) This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, + * MA 02110-1301 USA + * + * Alternatively, + * + * b) Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include + +#ifdef __CHECKER__ +#define __force __attribute__((force)) +#define __bitwise __attribute__((bitwise)) +#else +#define __force +#define __bitwise +#endif + +typedef uint16_t __bitwise fdt16_t; +typedef uint32_t __bitwise fdt32_t; +typedef uint64_t __bitwise fdt64_t; + +#define EXTRACT_BYTE(x, n) ((unsigned long long)((uint8_t *)&x)[n]) +#define CPU_TO_FDT16(x) ((EXTRACT_BYTE(x, 0) << 8) | EXTRACT_BYTE(x, 1)) +#define CPU_TO_FDT32(x) ((EXTRACT_BYTE(x, 0) << 24) | (EXTRACT_BYTE(x, 1) << 16) | \ + (EXTRACT_BYTE(x, 2) << 8) | EXTRACT_BYTE(x, 3)) +#define CPU_TO_FDT64(x) ((EXTRACT_BYTE(x, 0) << 56) | (EXTRACT_BYTE(x, 1) << 48) | \ + (EXTRACT_BYTE(x, 2) << 40) | (EXTRACT_BYTE(x, 3) << 32) | \ + (EXTRACT_BYTE(x, 4) << 24) | (EXTRACT_BYTE(x, 5) << 16) | \ + (EXTRACT_BYTE(x, 6) << 8) | EXTRACT_BYTE(x, 7)) + +static inline uint16_t fdt16_to_cpu(fdt16_t x) +{ + return (__force uint16_t)CPU_TO_FDT16(x); +} +static inline fdt16_t cpu_to_fdt16(uint16_t x) +{ + return (__force fdt16_t)CPU_TO_FDT16(x); +} + +static inline uint32_t fdt32_to_cpu(fdt32_t x) +{ + return (__force uint32_t)CPU_TO_FDT32(x); +} +static inline fdt32_t cpu_to_fdt32(uint32_t x) +{ + return (__force fdt32_t)CPU_TO_FDT32(x); +} + +static inline uint64_t fdt64_to_cpu(fdt64_t x) +{ + return (__force uint64_t)CPU_TO_FDT64(x); +} +static inline fdt64_t cpu_to_fdt64(uint64_t x) +{ + return (__force fdt64_t)CPU_TO_FDT64(x); +} +#undef CPU_TO_FDT64 +#undef CPU_TO_FDT32 +#undef CPU_TO_FDT16 +#undef EXTRACT_BYTE + +#endif /* _LIBFDT_ENV_H */ diff --git a/cpukit/include/librtemsNfs.h b/cpukit/include/librtemsNfs.h new file mode 100644 index 0000000000..530eee2144 --- /dev/null +++ b/cpukit/include/librtemsNfs.h @@ -0,0 +1,234 @@ +/** + * @file + * + * @brief Public Interface to the NFS Client Library for RTEMS + * + * @ingroup rtems-nfsclient + */ + +/* + * Author: Till Straumann 2002-2003 + * + * Authorship + * ---------- + * This software (NFS-2 client implementation for RTEMS) was created by + * Till Straumann , 2002-2007, + * Stanford Linear Accelerator Center, Stanford University. + * + * Acknowledgement of sponsorship + * ------------------------------ + * The NFS-2 client implementation for RTEMS was produced by + * the Stanford Linear Accelerator Center, Stanford University, + * under Contract DE-AC03-76SFO0515 with the Department of Energy. + * + * Government disclaimer of liability + * ---------------------------------- + * Neither the United States nor the United States Department of Energy, + * nor any of their employees, makes any warranty, express or implied, or + * assumes any legal liability or responsibility for the accuracy, + * completeness, or usefulness of any data, apparatus, product, or process + * disclosed, or represents that its use would not infringe privately owned + * rights. + * + * Stanford disclaimer of liability + * -------------------------------- + * Stanford University makes no representations or warranties, express or + * implied, nor assumes any liability for the use of this software. + * + * Stanford disclaimer of copyright + * -------------------------------- + * Stanford University, owner of the copyright, hereby disclaims its + * copyright and all other rights in this software. Hence, anyone may + * freely use it for any purpose without restriction. + * + * Maintenance of notices + * ---------------------- + * In the interest of clarity regarding the origin and status of this + * SLAC software, this and all the preceding Stanford University notices + * are to remain affixed to any copy or derivative of this software made + * or distributed by the recipient and are to be affixed to any copy of + * software made or distributed by the recipient that contains a copy or + * derivative of this software. + * + * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03 + */ + +#ifndef LIB_RTEMS_NFS_CLIENT_H +#define LIB_RTEMS_NFS_CLIENT_H + +/** + * @defgroup rtems-nfsclient NFS Client Library + * + * @ingroup nfsclient + * @{ + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** RPCIO driver interface. + * If you need RPCIO for other purposes than NFS + * you may want to include +#include "rpcio.h" + */ + +/** Priority of daemon; may be setup prior to calling rpcUdpInit(); + * otherwise the network task priority from the rtems_bsdnet_config + * is used... + */ +extern rtems_task_priority rpciodPriority; + +#ifdef RTEMS_SMP +/** CPU affinity of daemon; may be setup prior to calling rpcUdpInit(); + * otherwise the network task CPU affinity from the rtems_bsdnet_config + * is used... + */ +extern const cpu_set_t *rpciodCpuset; +extern size_t rpciodCpusetSize; +#endif + +/** + * @brief Sets the XIDs of the RPC transaction hash table. + * + * The active RPC transactions are stored in a hash table. Each table entry + * contains the XID of its corresponding transaction. The XID consists of two + * parts. The lower part is determined by the hash table index. The upper + * part is incremented in each send operation. + * + * This function sets the upper part of the XID in all hash table entries. + * This can be used to ensure that the XIDs are not reused in a short interval + * for example during a boot process or after resets. + * + * @param[in] xid The upper part is used to set the upper XID part of the hash + * table entries. + */ +void +rpcSetXIDs(uint32_t xid); + +/** Initialize the driver. + * + * Note, called in nfsfs initialise when mount is called. + * + * @retval 0 on success, -1 on failure + */ +int +rpcUdpInit(void); + +/** + * @brief RPC cleanup and stop. + * + * @retval 0 on success, nonzero if still in use + */ +int +rpcUdpCleanup(void); + +/** NFS driver interface */ + +/** + * @brief Initialize the NFS driver. + * + * The RPCIO driver must have been initialized prior to calling this. + * + * Note, called in nfsfs initialise when mount is called with defaults. + * + * ARGS: depth of the small and big + * transaction pools, i.e. how + * many transactions (buffers) + * should always be kept around. + * + * (If more transactions are needed, + * they are created and destroyed + * on the fly). + * + * Supply zero values to have the + * driver chose reasonable defaults. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The errno is set to indicate the error. + */ +int +nfsInit(int smallPoolDepth, int bigPoolDepth); + +/** + * @brief Driver cleanup code. + * + * @retval 0 on success, nonzero if still in use + */ +int +nfsCleanup(void); + +/** + * @brief Dump a list of the currently mounted NFS to a file. + * + * Dump a list of the currently mounted NFS to a file + * (stdout is used in case f==NULL) + */ +int +nfsMountsShow(FILE *f); + +/** + * @brief Filesystem mount table mount handler. + * + * Filesystem mount table mount handler. Do not call, use the mount call. + */ +int +rtems_nfs_initialize(rtems_filesystem_mount_table_entry_t *mt_entry, + const void *data); + +/** + * @brief A utility routine to find the path leading to a + * rtems_filesystem_location_info_t node. + * + * This should really be present in libcsupport... + * + * @param[in] 'loc' and a buffer 'buf' (length 'len') to hold the path. + * + * @param[out] path copied into 'buf' + * + * @retval 0 on success, RTEMS error code on error. + */ +rtems_status_code +rtems_filesystem_resolve_location(char *buf, int len, rtems_filesystem_location_info_t *loc); + +/** + * @brief Set the timeout (initial default: 10s) for NFS and mount calls. + * + * Set the timeout (initial default: 10s) for NFS and mount calls. + * + * @retval 0 on success, nonzero if the requested timeout is less than + * a clock tick or if the system clock rate cannot be determined. + */ + +int +nfsSetTimeout(uint32_t timeout_ms); + +/** Read current timeout (in milliseconds) */ +uint32_t +nfsGetTimeout(void); + +#ifdef __cplusplus +} +#endif + +/** @} */ +#endif diff --git a/cpukit/include/link.h b/cpukit/include/link.h new file mode 100644 index 0000000000..c93efd9e78 --- /dev/null +++ b/cpukit/include/link.h @@ -0,0 +1,45 @@ +/* $NetBSD: link.h,v 1.13 2008/04/28 20:22:54 martin Exp $ */ + +/*- + * Copyright (c) 1999 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, + * NASA Ames Research Center. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _LINK_H_ +#define _LINK_H_ + +/* + * Pull in the correct definitions for our toolchain target. + */ +#ifdef __ELF__ +#include +#else +#include +#endif + +#endif /* _LINK_H_ */ diff --git a/cpukit/include/link_elf.h b/cpukit/include/link_elf.h new file mode 100644 index 0000000000..d2691b68b0 --- /dev/null +++ b/cpukit/include/link_elf.h @@ -0,0 +1,79 @@ +/* $NetBSD: link_elf.h,v 1.8 2009/11/04 19:28:03 pooka Exp $ */ + +/* + * This only exists for GDB. + */ + +#ifndef _LINK_ELF_H_ +#define _LINK_ELF_H_ + +#include + +#include +#include +#include + +enum sections +{ + rap_text = 0, + rap_const = 1, + rap_ctor = 2, + rap_dtor = 3, + rap_data = 4, + rap_bss = 5, + rap_secs = 6 +}; + +/** + * Object details. + */ +typedef struct +{ + const char* name; /**< Section name. */ + uint32_t offset; /**< The offset in the elf file. */ + uint32_t size; /**< The size of the section. */ + uint32_t rap_id; /**< Which obj does this section belongs to. */ +}section_detail; + +/** + * link map structure will be used for GDB support. + */ +struct link_map { + const char* name; /**< Name of the obj. */ + uint32_t sec_num; /**< The count of section. */ + section_detail* sec_detail; /**< The section details. */ + uint32_t* sec_addr[rap_secs]; /**< The RAP section addr. */ + uint32_t rpathlen; /**< The length of the path. */ + char* rpath; /**< The path of object files. */ + struct link_map* l_next; /**< Linked list of mapped libs. */ + struct link_map* l_prev; +}; + +/** + * r_debug is used to manage the debug related structures. + */ +struct r_debug { + int r_version; /* not used */ + struct link_map *r_map; /* list of loaded images */ + enum { + RT_CONSISTENT, /* things are stable */ + RT_ADD, /* adding a shared library */ + RT_DELETE /* removing a shared library */ + } r_state; +}; + +/* + * stub function. It is empty. + */ +void _rtld_debug_state (void); + +/* + * add link map to the list. + */ +int _rtld_linkmap_add (rtems_rtl_obj_t* obj); + +/* + * Remove link map from the list. + */ +void _rtld_linkmap_delete (rtems_rtl_obj_t* obj); +#endif /* _LINK_ELF_H_ */ diff --git a/cpukit/include/linux/i2c-dev.h b/cpukit/include/linux/i2c-dev.h new file mode 100644 index 0000000000..c0db3fe06c --- /dev/null +++ b/cpukit/include/linux/i2c-dev.h @@ -0,0 +1,137 @@ +/** + * @file + * + * @brief RTEMS Port of Linux I2C Device API + * + * @ingroup I2CLinux + */ + +/* + * Copyright (c) 2014 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _UAPI_LINUX_I2C_DEV_H +#define _UAPI_LINUX_I2C_DEV_H + +#include + +/** + * @addtogroup I2CLinux + * + * @{ + */ + +/** + * @name I2C IO Control Commands + * + * @{ + */ + +/** + * @brief Sets the count of transfer retries in case a slave + * device does not acknowledge a transaction. + * + * The argument type is unsigned long. + */ +#define I2C_RETRIES 0x701 + +/** + * @brief Sets the transfer timeout in 10ms units. + * + * The argument type is unsigned long. + */ +#define I2C_TIMEOUT 0x702 + +/** + * @brief Sets the slave address. + * + * It is an error to set a slave address already used by another slave device. + * + * The argument type is unsigned long. + */ +#define I2C_SLAVE 0x703 + +/** + * @brief Forces setting the slave address. + * + * The argument type is unsigned long. + */ +#define I2C_SLAVE_FORCE 0x706 + +/** + * @brief Enables 10-bit addresses if argument is non-zero, otherwise + * disables 10-bit addresses. + * + * The argument type is unsigned long. + */ +#define I2C_TENBIT 0x704 + +/** + * @brief Gets the I2C controller functionality information. + * + * The argument type is a pointer to an unsigned long. + */ +#define I2C_FUNCS 0x705 + +/** + * @brief Performs a combined read/write transfer. + * + * Only one stop condition is signalled. + * + * The argument type is a pointer to struct i2c_rdwr_ioctl_data. + */ +#define I2C_RDWR 0x707 + +/** + * @brief Enables System Management Bus (SMBus) Packet Error Checking (PEC) + * if argument is non-zero, otherwise disables PEC. + * + * The argument type is unsigned long. + */ +#define I2C_PEC 0x708 + +/** + * @brief Performs an SMBus transfer. + * + * The argument type is a pointer to struct i2c_smbus_ioctl_data. + */ +#define I2C_SMBUS 0x720 + +/** @} */ + +/** + * @brief Argument type for I2C_SMBUS IO control call. + */ +struct i2c_smbus_ioctl_data { + uint8_t read_write; + uint8_t command; + uint32_t size; + union i2c_smbus_data *data; +}; + +/** + * @brief Argument type for I2C_RDWR IO control call. + */ +struct i2c_rdwr_ioctl_data { + struct i2c_msg *msgs; + uint32_t nmsgs; +}; + +/** + * @brief Maximum count of messages for one IO control call. + */ +#define I2C_RDRW_IOCTL_MAX_MSGS 42 + +/** @} */ + +#endif /* _UAPI_LINUX_I2C_DEV_H */ diff --git a/cpukit/include/linux/i2c.h b/cpukit/include/linux/i2c.h new file mode 100644 index 0000000000..b113545cce --- /dev/null +++ b/cpukit/include/linux/i2c.h @@ -0,0 +1,275 @@ +/** + * @file + * + * @brief RTEMS Port of Linux I2C API + * + * @ingroup I2CLinux + */ + +/* + * Copyright (c) 2014 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _UAPI_LINUX_I2C_H +#define _UAPI_LINUX_I2C_H + +#include + +/** + * @defgroup I2CLinux Linux I2C User-Space API + * + * @ingroup I2C + * + * @brief RTEMS port of Linux I2C user-space API. + * + * Additional documentation is available through the Linux sources, see: + * + * - /usr/src/linux/include/uapi/linux/i2c.h, + * - /usr/src/linux/include/uapi/linux/i2c-dev.h + * - https://www.kernel.org/doc/Documentation/i2c/i2c-protocol + * - https://www.kernel.org/doc/Documentation/i2c/dev-interface + * + * @{ + */ + +/** + * @name I2C Message Flags + * + * @{ + */ + +/** + * @brief I2C message flag to indicate a 10-bit address. + * + * The controller must support this as indicated by the I2C_FUNC_10BIT_ADDR + * functionality. + * + * @see i2c_msg. + */ +#define I2C_M_TEN 0x0010 + +/** + * @brief I2C message flag to indicate a read transfer (from slave to master). + * + * @see i2c_msg. + */ +#define I2C_M_RD 0x0001 + +/** + * @brief I2C message flag to signal a stop condition even if this is not the + * last message. + * + * The controller must support this as indicated by the + * @ref I2C_FUNC_PROTOCOL_MANGLING functionality. + * + * @see i2c_msg. + */ +#define I2C_M_STOP 0x8000 + +/** + * @brief I2C message flag to omit start condition and slave address. + * + * The controller must support this as indicated by the + * @ref I2C_FUNC_NOSTART functionality. + * + * @see i2c_msg. + */ +#define I2C_M_NOSTART 0x4000 + +/** + * @brief I2C message flag to reverse the direction flag. + * + * The controller must support this as indicated by the + * @ref I2C_FUNC_PROTOCOL_MANGLING functionality. + * + * @see i2c_msg. + */ +#define I2C_M_REV_DIR_ADDR 0x2000 + +/** + * @brief I2C message flag to ignore a non-acknowledge. + * + * The controller must support this as indicated by the + * @ref I2C_FUNC_PROTOCOL_MANGLING functionality. + * + * @see i2c_msg. + */ +#define I2C_M_IGNORE_NAK 0x1000 + +/** + * @brief I2C message flag to omit a master acknowledge/non-acknowledge in a + * read transfer. + * + * The controller must support this as indicated by the + * @ref I2C_FUNC_PROTOCOL_MANGLING functionality. + * + * @see i2c_msg. + */ +#define I2C_M_NO_RD_ACK 0x0800 + +/** + * @brief I2C message flag to indicate that the message data length is the + * first received byte. + * + * The message data buffer must be large enough to store up to 32 bytes, the + * initial length byte and the SMBus PEC (if used). Initialize the message + * length to one. The message length is incremented by the count of received + * data bytes. + * + * @see i2c_msg. + */ +#define I2C_M_RECV_LEN 0x0400 + +/** @} */ + +/** + * @brief I2C transfer message. + */ +struct i2c_msg { + /** + * @brief The slave address. + * + * In case the @ref I2C_M_TEN flag is set, then this is a 10-bit address, + * otherwise it is a 7-bit address. + */ + uint16_t addr; + + /** + * @brief The message flags. + * + * Valid flags are + * - @ref I2C_M_TEN, + * - @ref I2C_M_RD, + * - @ref I2C_M_STOP, + * - @ref I2C_M_NOSTART, + * - @ref I2C_M_REV_DIR_ADDR, + * - @ref I2C_M_IGNORE_NAK, + * - @ref I2C_M_NO_RD_ACK, and + * - @ref I2C_M_RECV_LEN. + */ + uint16_t flags; + + /** + * @brief The message data length in bytes. + */ + uint16_t len; + + /** + * @brief Pointer to the message data. + */ + uint8_t *buf; +}; + +/** + * @name I2C Controller Functionality + * + * @{ + */ + +#define I2C_FUNC_I2C 0x00000001 +#define I2C_FUNC_10BIT_ADDR 0x00000002 +#define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 +#define I2C_FUNC_SMBUS_PEC 0x00000008 +#define I2C_FUNC_NOSTART 0x00000010 +#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 +#define I2C_FUNC_SMBUS_QUICK 0x00010000 +#define I2C_FUNC_SMBUS_READ_BYTE 0x00020000 +#define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000 +#define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000 +#define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000 +#define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000 +#define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000 +#define I2C_FUNC_SMBUS_PROC_CALL 0x00800000 +#define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000 +#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000 +#define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 +#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 + +#define I2C_FUNC_SMBUS_BYTE \ + (I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE) + +#define I2C_FUNC_SMBUS_BYTE_DATA \ + (I2C_FUNC_SMBUS_READ_BYTE_DATA | I2C_FUNC_SMBUS_WRITE_BYTE_DATA) + +#define I2C_FUNC_SMBUS_WORD_DATA \ + (I2C_FUNC_SMBUS_READ_WORD_DATA | I2C_FUNC_SMBUS_WRITE_WORD_DATA) + +#define I2C_FUNC_SMBUS_BLOCK_DATA \ + (I2C_FUNC_SMBUS_READ_BLOCK_DATA | I2C_FUNC_SMBUS_WRITE_BLOCK_DATA) + +#define I2C_FUNC_SMBUS_I2C_BLOCK \ + (I2C_FUNC_SMBUS_READ_I2C_BLOCK | I2C_FUNC_SMBUS_WRITE_I2C_BLOCK) + +#define I2C_FUNC_SMBUS_EMUL \ + (I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA \ + | I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_PROC_CALL \ + | I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | I2C_FUNC_SMBUS_I2C_BLOCK \ + | I2C_FUNC_SMBUS_PEC) + +/** @} */ + +/** + * @brief Maximum SMBus data block count. + */ +#define I2C_SMBUS_BLOCK_MAX 32 + +/** + * @brief SMBus data. + */ +union i2c_smbus_data { + uint8_t byte; + uint16_t word; + uint8_t block[I2C_SMBUS_BLOCK_MAX + 2]; +}; + +/** + * @name SMBus Transfer Read and Write Markers + * + * @{ + */ + +#define I2C_SMBUS_READ 1 + +#define I2C_SMBUS_WRITE 0 + +/** @} */ + +/** + * @name SMBus Transaction Types + * + * @{ + */ + +#define I2C_SMBUS_QUICK 0 + +#define I2C_SMBUS_BYTE 1 + +#define I2C_SMBUS_BYTE_DATA 2 + +#define I2C_SMBUS_WORD_DATA 3 + +#define I2C_SMBUS_PROC_CALL 4 + +#define I2C_SMBUS_BLOCK_DATA 5 + +#define I2C_SMBUS_I2C_BLOCK_BROKEN 6 + +#define I2C_SMBUS_BLOCK_PROC_CALL 7 + +#define I2C_SMBUS_I2C_BLOCK_DATA 8 + +/** @} */ + +/** @} */ + +#endif /* _UAPI_LINUX_I2C_H */ diff --git a/cpukit/include/linux/spi/spidev.h b/cpukit/include/linux/spi/spidev.h new file mode 100644 index 0000000000..e2fdb4b7e1 --- /dev/null +++ b/cpukit/include/linux/spi/spidev.h @@ -0,0 +1,268 @@ +/** + * @file + * + * @brief RTEMS Port of Linux SPI API + * + * @ingroup SPILinux + */ + +/* + * Copyright (c) 2016 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _UAPI_LINUX_SPI_H +#define _UAPI_LINUX_SPI_H + +#include +#include +#include + +/** + * @defgroup SPILinux Linux SPI User-Space API + * + * @ingroup SPI + * + * @brief RTEMS port of Linux SPI user-space API. + * + * Additional documentation is available through the Linux sources, see + * + * /usr/src/linux/include/uapi/linux/spidev.h. + * + * @{ + */ + +/** + * @name SPI Transfer Flags + * + * @{ + */ + +/** + * @brief SPI transfer flag which sets the clock phase. + */ +#define SPI_CPHA 0x01 + +/** + * @brief SPI transfer flag which sets the clock polarity. + */ +#define SPI_CPOL 0x02 + +/** + * @brief SPI transfer flag which sets SPI Mode 0 (clock starts low, sample on + * leading edge). + */ +#define SPI_MODE_0 0 + +/** + * @brief SPI transfer flag which sets SPI Mode 0 (clock starts low, sample on + * trailing edge). + */ +#define SPI_MODE_1 SPI_CPHA + +/** + * @brief SPI transfer flag which sets SPI Mode 0 (clock starts high, sample on + * leading edge). + */ +#define SPI_MODE_2 SPI_CPOL + +/** + * @brief SPI transfer flag which sets SPI Mode 0 (clock starts high, sample on + * trailing edge). + */ +#define SPI_MODE_3 (SPI_CPOL | SPI_CPHA) + +/** + * @brief SPI transfer flag which selects the device by setting the chip select + * line. + */ +#define SPI_CS_HIGH 0x04 + +/** + * @brief SPI transfer flag which triggers data transmission with the LSB being + * sent first. + */ +#define SPI_LSB_FIRST 0x08 + +/** + * @brief SPI transfer flag which uses a shared wire for master input/slave + * output as well as master output/slave input. + */ +#define SPI_3WIRE 0x10 + +/** + * @brief SPI transfer flag which initiates the loopback mode. + */ +#define SPI_LOOP 0x20 + +/** + * @brief SPI transfer flag which indicates that no chip select is needed due to + * only one device on the bus. + */ +#define SPI_NO_CS 0x40 + +/** + * @brief SPI transfer flag which pulls the slave to low level during pause. + */ +#define SPI_READY 0x80 + +/** + * @brief SPI transfer flag which sets up dual mode for transmission. + */ +#define SPI_TX_DUAL 0x100 + +/** + * @brief SPI transfer flag which sets up quad mode for transmission. + */ +#define SPI_TX_QUAD 0x200 + +/** + * @brief SPI transfer flag which sets up dual mode for reception. + */ +#define SPI_RX_DUAL 0x400 + +/** + * @brief SPI transfer flag which sets up quad mode for reception. + */ +#define SPI_RX_QUAD 0x800 + +/** @} */ + +#define SPI_IOC_MAGIC 's' + +/** + * @brief SPI transfer message. + */ +struct spi_ioc_transfer { + /** + * @brief Buffer for receive data. + */ + void *rx_buf; + + /** + * @brief Buffer for transmit data. + */ + const void *tx_buf; + + /** + * @brief Length of receive and transmit buffers in bytes. + */ + size_t len; + + /** + * @brief Sets the bit-rate of the device. + */ + uint32_t speed_hz; + + /** + * @brief Sets the delay after a transfer before the chip select status is + * changed and the next transfer is triggered. + */ + uint16_t delay_usecs; + + /** + * @brief Sets the device wordsize. + */ + uint8_t bits_per_word; + + /** + * @brief If true, device is deselected after transfer ended and before a new + * transfer is started. + */ + uint8_t cs_change; + + /** + * @brief Amount of bits that are used for reading. + */ + uint8_t rx_nbits; + + /** + * @brief Amount of bits that are used for writing. + */ + uint8_t tx_nbits; + + /** + * @brief Sets one of the possible modes that can be used for SPI transfers + * (dependent on clock phase and polarity). + */ + uint32_t mode; + + /** + * @brief Indicates which device is currently used. + */ + uint8_t cs; +}; + +/** + * @brief Calculates the size of the SPI message array. + */ +#define SPI_MSGSIZE(n) \ + (((n) * sizeof(struct spi_ioc_transfer) < IOCPARM_MAX) ? \ + (n) * sizeof(struct spi_ioc_transfer) : 0) + +/** + * @brief Transfers an array with SPI messages. + */ +#define SPI_IOC_MESSAGE(n) _IOW(SPI_IOC_MAGIC, 0, char[SPI_MSGSIZE(n)]) + +/** + * @brief Reads the least-significant 8-bits of the SPI default mode. + */ +#define SPI_IOC_RD_MODE _IOR(SPI_IOC_MAGIC, 1, uint8_t) + +/** + * @brief Writes the SPI default mode (the most-significant 24-bits of the mode are + * set to zero). + */ +#define SPI_IOC_WR_MODE _IOW(SPI_IOC_MAGIC, 1, uint8_t) + +/** + * @brief Reads the SPI default least-significant bit first setting. + */ +#define SPI_IOC_RD_LSB_FIRST _IOR(SPI_IOC_MAGIC, 2, uint8_t) + +/** + * @brief Writes the SPI default least-significant-bit first setting. + */ +#define SPI_IOC_WR_LSB_FIRST _IOW(SPI_IOC_MAGIC, 2, uint8_t) + +/** + * @brief Reads the SPI default bits per word. + */ +#define SPI_IOC_RD_BITS_PER_WORD _IOR(SPI_IOC_MAGIC, 3, uint8_t) + +/** + * @brief Writes the SPI default bits per word. + */ +#define SPI_IOC_WR_BITS_PER_WORD _IOW(SPI_IOC_MAGIC, 3, uint8_t) + +/** + * @brief Reads the SPI default speed in Hz. + */ +#define SPI_IOC_RD_MAX_SPEED_HZ _IOR(SPI_IOC_MAGIC, 4, uint32_t) + +/** + * @brief Writes the SPI default speed in Hz. + */ +#define SPI_IOC_WR_MAX_SPEED_HZ _IOW(SPI_IOC_MAGIC, 4, uint32_t) + +/** + * @brief Reads the full 32-bit SPI default mode. + */ +#define SPI_IOC_RD_MODE32 _IOR(SPI_IOC_MAGIC, 5, uint32_t) + +/** + * @brief Writes the full 32-bit SPI default mode. + */ +#define SPI_IOC_WR_MODE32 _IOW(SPI_IOC_MAGIC, 5, uint32_t) + +#endif /* _UAPI_LINUX_SPI_H */ diff --git a/cpukit/include/machine/_kernel_cpuset.h b/cpukit/include/machine/_kernel_cpuset.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/cpukit/include/machine/_kernel_param.h b/cpukit/include/machine/_kernel_param.h new file mode 100644 index 0000000000..183bb895a2 --- /dev/null +++ b/cpukit/include/machine/_kernel_param.h @@ -0,0 +1,29 @@ +#include +#include +#include +#include + +#ifndef FALSE +#define FALSE 0 +#endif +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef _BYTEORDER_PROTOTYPED +#define _BYTEORDER_PROTOTYPED +__BEGIN_DECLS +__uint32_t htonl(__uint32_t); +__uint16_t htons(__uint16_t); +__uint32_t ntohl(__uint32_t); +__uint16_t ntohs(__uint16_t); +__END_DECLS +#endif + +#ifndef _BYTEORDER_FUNC_DEFINED +#define _BYTEORDER_FUNC_DEFINED +#define htonl(x) __htonl(x) +#define htons(x) __htons(x) +#define ntohl(x) __ntohl(x) +#define ntohs(x) __ntohs(x) +#endif /* !_BYTEORDER_FUNC_DEFINED */ diff --git a/cpukit/include/machine/_kernel_time.h b/cpukit/include/machine/_kernel_time.h new file mode 100644 index 0000000000..8200b6a73e --- /dev/null +++ b/cpukit/include/machine/_kernel_time.h @@ -0,0 +1,173 @@ +/*- + * Copyright (c) 2016 embedded brains GmbH + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if !defined(_SYS_TIME_H_) || !defined(_KERNEL) +#error "must be included via in kernel space" +#endif + +#include + +/* Operations on timespecs */ +#define timespecclear(tvp) ((tvp)->tv_sec = (tvp)->tv_nsec = 0) +#define timespecisset(tvp) ((tvp)->tv_sec || (tvp)->tv_nsec) +#define timespeccmp(tvp, uvp, cmp) \ + (((tvp)->tv_sec == (uvp)->tv_sec) ? \ + ((tvp)->tv_nsec cmp (uvp)->tv_nsec) : \ + ((tvp)->tv_sec cmp (uvp)->tv_sec)) +#define timespecadd(vvp, uvp) \ + do { \ + (vvp)->tv_sec += (uvp)->tv_sec; \ + (vvp)->tv_nsec += (uvp)->tv_nsec; \ + if ((vvp)->tv_nsec >= 1000000000) { \ + (vvp)->tv_sec++; \ + (vvp)->tv_nsec -= 1000000000; \ + } \ + } while (0) +#define timespecsub(vvp, uvp) \ + do { \ + (vvp)->tv_sec -= (uvp)->tv_sec; \ + (vvp)->tv_nsec -= (uvp)->tv_nsec; \ + if ((vvp)->tv_nsec < 0) { \ + (vvp)->tv_sec--; \ + (vvp)->tv_nsec += 1000000000; \ + } \ + } while (0) + +/* Operations on timevals. */ + +#define timevalclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0) +#define timevalisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) +#define timevalcmp(tvp, uvp, cmp) \ + (((tvp)->tv_sec == (uvp)->tv_sec) ? \ + ((tvp)->tv_usec cmp (uvp)->tv_usec) : \ + ((tvp)->tv_sec cmp (uvp)->tv_sec)) + +/* timevaladd and timevalsub are not inlined */ + +/* + * Kernel to clock driver interface. + */ +void inittodr(time_t base); +void resettodr(void); + +#define time_second _Timecounter_Time_second +#define time_uptime _Timecounter_Time_uptime +extern struct timeval boottime; +extern struct bintime tc_tick_bt; +extern sbintime_t tc_tick_sbt; +extern struct bintime tick_bt; +extern sbintime_t tick_sbt; +extern int tc_precexp; +extern int tc_timepercentage; +extern struct bintime bt_timethreshold; +extern struct bintime bt_tickthreshold; +extern sbintime_t sbt_timethreshold; +extern sbintime_t sbt_tickthreshold; + +/* + * Functions for looking at our clock: [get]{bin,nano,micro}[up]time() + * + * Functions without the "get" prefix returns the best timestamp + * we can produce in the given format. + * + * "bin" == struct bintime == seconds + 64 bit fraction of seconds. + * "nano" == struct timespec == seconds + nanoseconds. + * "micro" == struct timeval == seconds + microseconds. + * + * Functions containing "up" returns time relative to boot and + * should be used for calculating time intervals. + * + * Functions without "up" returns UTC time. + * + * Functions with the "get" prefix returns a less precise result + * much faster than the functions without "get" prefix and should + * be used where a precision of 1/hz seconds is acceptable or where + * performance is priority. (NB: "precision", _not_ "resolution" !) + */ + +#define binuptime(_bt) _Timecounter_Binuptime(_bt) +#define nanouptime(_tsp) _Timecounter_Nanouptime(_tsp) +#define microuptime(_tvp) _Timecounter_Microuptime(_tvp) + +static __inline sbintime_t +sbinuptime(void) +{ + struct bintime _bt; + + binuptime(&_bt); + return (bttosbt(_bt)); +} + +#define bintime(_bt) _Timecounter_Bintime(_bt) +#define nanotime(_tsp) _Timecounter_Nanotime(_tsp) +#define microtime(_tvp) _Timecounter_Microtime(_tvp) + +#define getbinuptime(_bt) _Timecounter_Getbinuptime(_bt) +#define getnanouptime(_tsp) _Timecounter_Getnanouptime(_tsp) +#define getmicrouptime(_tvp) _Timecounter_Getmicrouptime(_tvp) + +static __inline sbintime_t +getsbinuptime(void) +{ + struct bintime _bt; + + getbinuptime(&_bt); + return (bttosbt(_bt)); +} + +#define getbintime(_bt) _Timecounter_Getbintime(_bt) +#define getnanotime(_tsp) _Timecounter_Getnanotime(_tsp) +#define getmicrotime(_tvp) _Timecounter_Getmicrotime(_tvp) + +#define getboottime(_tvp) _Timecounter_Getboottime(_tvp) +#define getboottimebin(_bt) _Timecounter_Getboottimebin(_bt) + +/* Other functions */ +int itimerdecr(struct itimerval *itp, int usec); +int itimerfix(struct timeval *tv); +int ppsratecheck(struct timeval *, int *, int); +int ratecheck(struct timeval *, const struct timeval *); +void timevaladd(struct timeval *t1, const struct timeval *t2); +void timevalsub(struct timeval *t1, const struct timeval *t2); +int tvtohz(struct timeval *tv); + +#define TC_DEFAULTPERC 5 + +#define BT2FREQ(bt) \ + (((uint64_t)0x8000000000000000 + ((bt)->frac >> 2)) / \ + ((bt)->frac >> 1)) + +#define SBT2FREQ(sbt) ((SBT_1S + ((sbt) >> 1)) / (sbt)) + +#define FREQ2BT(freq, bt) \ +{ \ + (bt)->sec = 0; \ + (bt)->frac = ((uint64_t)0x8000000000000000 / (freq)) << 1; \ +} + +#define TIMESEL(sbt, sbt2) \ + (((sbt2) >= sbt_timethreshold) ? \ + ((*(sbt) = getsbinuptime()), 1) : ((*(sbt) = sbinuptime()), 0)) diff --git a/cpukit/include/machine/_kernel_types.h b/cpukit/include/machine/_kernel_types.h new file mode 100644 index 0000000000..892ec413d5 --- /dev/null +++ b/cpukit/include/machine/_kernel_types.h @@ -0,0 +1,34 @@ +/*- + * Copyright (c) 2016 embedded brains GmbH + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if !defined(_SYS_TYPES_H) || !defined(_KERNEL) +#error "must be included via in kernel space" +#endif + +typedef int boolean_t; +typedef struct device *device_t; +typedef char vm_memattr_t; /* memory attribute codes */ +typedef struct vm_page *vm_page_t; diff --git a/cpukit/include/machine/_timecounter.h b/cpukit/include/machine/_timecounter.h new file mode 100644 index 0000000000..fb974f13c1 --- /dev/null +++ b/cpukit/include/machine/_timecounter.h @@ -0,0 +1,53 @@ +/*- + * Copyright (c) 2016 embedded brains GmbH + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _SYS_TIME_H_ +#error " must be included first" +#endif /* !_SYS_TIME_H_ */ + +#ifndef _MACHINE__TIMECOUNTER_H_ +#define _MACHINE__TIMECOUNTER_H_ + +__BEGIN_DECLS +extern volatile time_t _Timecounter_Time_second; +extern volatile int32_t _Timecounter_Time_uptime; +extern struct bintime _Timecounter_Boottimebin; + +void _Timecounter_Binuptime(struct bintime *); +void _Timecounter_Nanouptime(struct timespec *); +void _Timecounter_Microuptime(struct timeval *); +void _Timecounter_Bintime(struct bintime *); +void _Timecounter_Nanotime(struct timespec *); +void _Timecounter_Microtime(struct timeval *); +void _Timecounter_Getbinuptime(struct bintime *); +void _Timecounter_Getnanouptime(struct timespec *); +void _Timecounter_Getmicrouptime(struct timeval *); +void _Timecounter_Getbintime(struct bintime *); +void _Timecounter_Getnanotime(struct timespec *); +void _Timecounter_Getmicrotime(struct timeval *); +__END_DECLS + +#endif /* _MACHINE__TIMECOUNTER_H_ */ diff --git a/cpukit/include/md4.h b/cpukit/include/md4.h new file mode 100644 index 0000000000..c5ae2f13ef --- /dev/null +++ b/cpukit/include/md4.h @@ -0,0 +1,56 @@ +/* +** ******************************************************************** +** md4.h -- Header file for implementation of ** +** MD4 Message Digest Algorithm ** +** Updated: 2/13/90 by Ronald L. Rivest ** +** (C) 1990 RSA Data Security, Inc. ** +** ******************************************************************** +*/ + +#include + +/* MDstruct is the data structure for a message digest computation. +*/ +typedef struct { + uint32_t buffer[4]; /* Holds 4-word result of MD computation */ + uint8_t count[8]; /* Number of bits processed so far */ + uint32_t done; /* Nonzero means MD computation finished */ +} MD4_CTX; + +/* MD4Init(MD4_CTX *) +** Initialize the MD4_CTX prepatory to doing a message digest +** computation. +*/ +extern void MD4Init(MD4_CTX *MD); + +/* MD4Update(MD,X,count) +** Input: X -- a pointer to an array of unsigned characters. +** count -- the number of bits of X to use (an unsigned int). +** Updates MD using the first "count" bits of X. +** The array pointed to by X is not modified. +** If count is not a multiple of 8, MD4Update uses high bits of +** last byte. +** This is the basic input routine for a user. +** The routine terminates the MD computation when count < 512, so +** every MD computation should end with one call to MD4Update with a +** count less than 512. Zero is OK for a count. +*/ +extern void MD4Update(MD4_CTX *MD, unsigned char *X, unsigned int count); + +/* MD4Print(MD) +** Prints message digest buffer MD as 32 hexadecimal digits. +** Order is from low-order byte of buffer[0] to high-order byte +** of buffer[3]. +** Each byte is printed with high-order hexadecimal digit first. +*/ +extern void MD4Print(MD4_CTX *); + +/* MD4Final(buf, MD) +** Returns message digest from MD and terminates the message +** digest computation. +*/ +extern void MD4Final(unsigned char *, MD4_CTX *); + +/* +** End of md4.h +****************************(cut)***********************************/ diff --git a/cpukit/include/md5.h b/cpukit/include/md5.h new file mode 100644 index 0000000000..ca48d61d7b --- /dev/null +++ b/cpukit/include/md5.h @@ -0,0 +1,71 @@ +/* + *********************************************************************** + ** md5.h -- header file for implementation of MD5 ** + ** RSA Data Security, Inc. MD5 Message-Digest Algorithm ** + ** Created: 2/17/90 RLR ** + ** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version ** + ** Revised (for MD5): RLR 4/27/91 ** + ** -- G modified to have y&~z instead of y&z ** + ** -- FF, GG, HH modified to add in last register done ** + ** -- Access pattern: round 2 works mod 5, round 3 works mod 3 ** + ** -- distinct additive constant for each step ** + ** -- round 4 added, working mod 7 ** + *********************************************************************** + */ + +/* + *********************************************************************** + ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. ** + ** ** + ** License to copy and use this software is granted provided that ** + ** it is identified as the "RSA Data Security, Inc. MD5 Message- ** + ** Digest Algorithm" in all material mentioning or referencing this ** + ** software or this function. ** + ** ** + ** License is also granted to make and use derivative works ** + ** provided that such works are identified as "derived from the RSA ** + ** Data Security, Inc. MD5 Message-Digest Algorithm" in all ** + ** material mentioning or referencing the derived work. ** + ** ** + ** RSA Data Security, Inc. makes no representations concerning ** + ** either the merchantability of this software or the suitability ** + ** of this software for any particular purpose. It is provided "as ** + ** is" without express or implied warranty of any kind. ** + ** ** + ** These notices must be retained in any copies of any part of this ** + ** documentation and/or software. ** + *********************************************************************** + */ + +#ifndef __MD5_INCLUDE__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* typedef a 32-bit type */ +typedef uint32_t UINT4; + +#define MD5_BLOCK_LENGTH 64 +#define MD5_DIGEST_LENGTH 16 + +/* Data structure for MD5 (Message-Digest) computation */ +typedef struct { + UINT4 i[2]; /* number of _bits_ handled mod 2^64 */ + UINT4 buf[4]; /* scratch buffer */ + unsigned char in[64]; /* input buffer */ + unsigned char digest[16]; /* actual digest after MD5Final call */ +} MD5_CTX; + +void MD5Init (MD5_CTX *); +void MD5Update (MD5_CTX *, const void *, unsigned int); +void MD5Final (unsigned char [16], MD5_CTX *); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#define __MD5_INCLUDE__ +#endif /* __MD5_INCLUDE__ */ diff --git a/cpukit/include/mghttpd/mongoose.h b/cpukit/include/mghttpd/mongoose.h new file mode 100644 index 0000000000..330ed6701b --- /dev/null +++ b/cpukit/include/mghttpd/mongoose.h @@ -0,0 +1,390 @@ +// Copyright (c) 2004-2012 Sergey Lyubka +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#ifndef MONGOOSE_HEADER_INCLUDED +#define MONGOOSE_HEADER_INCLUDED + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +struct mg_context; // Handle for the HTTP service itself +struct mg_connection; // Handle for the individual connection + + +// This structure contains information about the HTTP request. +struct mg_request_info { + const char *request_method; // "GET", "POST", etc + const char *uri; // URL-decoded URI + const char *http_version; // E.g. "1.0", "1.1" + const char *query_string; // URL part after '?', not including '?', or NULL + const char *remote_user; // Authenticated user, or NULL if no auth used + long remote_ip; // Client's IP address + int remote_port; // Client's port + int is_ssl; // 1 if SSL-ed, 0 if not + void *user_data; // User data pointer passed to mg_start() + void *conn_data; // Connection-specific user data + + int num_headers; // Number of HTTP headers + struct mg_header { + const char *name; // HTTP header name + const char *value; // HTTP header value + } http_headers[64]; // Maximum 64 headers +}; + + +// This structure needs to be passed to mg_start(), to let mongoose know +// which callbacks to invoke. For detailed description, see +// https://github.com/valenok/mongoose/blob/master/UserManual.md +struct mg_callbacks { + // Called when mongoose has received new HTTP request. + // If callback returns non-zero, + // callback must process the request by sending valid HTTP headers and body, + // and mongoose will not do any further processing. + // If callback returns 0, mongoose processes the request itself. In this case, + // callback must not send any data to the client. + int (*begin_request)(struct mg_connection *); + + // Called when mongoose has finished processing request. + void (*end_request)(const struct mg_connection *, int reply_status_code); + + // Called when mongoose is about to log a message. If callback returns + // non-zero, mongoose does not log anything. + int (*log_message)(const struct mg_connection *, const char *message); + + // Called when mongoose initializes SSL library. + int (*init_ssl)(void *ssl_context, void *user_data); + + // Called when websocket request is received, before websocket handshake. + // If callback returns 0, mongoose proceeds with handshake, otherwise + // cinnection is closed immediately. + int (*websocket_connect)(const struct mg_connection *); + + // Called when websocket handshake is successfully completed, and + // connection is ready for data exchange. + void (*websocket_ready)(struct mg_connection *); + + // Called when data frame has been received from the client. + // Parameters: + // bits: first byte of the websocket frame, see websocket RFC at + // http://tools.ietf.org/html/rfc6455, section 5.2 + // data, data_len: payload, with mask (if any) already applied. + // Return value: + // non-0: keep this websocket connection opened. + // 0: close this websocket connection. + int (*websocket_data)(struct mg_connection *, int bits, + char *data, size_t data_len); + + // Called when mongoose tries to open a file. Used to intercept file open + // calls, and serve file data from memory instead. + // Parameters: + // path: Full path to the file to open. + // data_len: Placeholder for the file size, if file is served from memory. + // Return value: + // NULL: do not serve file from memory, proceed with normal file open. + // non-NULL: pointer to the file contents in memory. data_len must be + // initilized with the size of the memory block. + const char * (*open_file)(const struct mg_connection *, + const char *path, size_t *data_len); + + // Called when mongoose is about to serve Lua server page (.lp file), if + // Lua support is enabled. + // Parameters: + // lua_context: "lua_State *" pointer. + void (*init_lua)(struct mg_connection *, void *lua_context); + + // Called when mongoose has uploaded a file to a temporary directory as a + // result of mg_upload() call. + // Parameters: + // file_file: full path name to the uploaded file. + void (*upload)(struct mg_connection *, const char *file_name); + + // Called when mongoose is about to send HTTP error to the client. + // Implementing this callback allows to create custom error pages. + // Parameters: + // status: HTTP error status code. + int (*http_error)(struct mg_connection *, int status); +}; + +// Start web server. +// +// Parameters: +// callbacks: mg_callbacks structure with user-defined callbacks. +// options: NULL terminated list of option_name, option_value pairs that +// specify Mongoose configuration parameters. +// +// Side-effects: on UNIX, ignores SIGCHLD and SIGPIPE signals. If custom +// processing is required for these, signal handlers must be set up +// after calling mg_start(). +// +// +// Example: +// const char *options[] = { +// "document_root", "/var/www", +// "listening_ports", "80,443s", +// NULL +// }; +// struct mg_context *ctx = mg_start(&my_func, NULL, options); +// +// Refer to https://github.com/valenok/mongoose/blob/master/UserManual.md +// for the list of valid option and their possible values. +// +// Return: +// web server context, or NULL on error. +struct mg_context *mg_start(const struct mg_callbacks *callbacks, + void *user_data, + const char **configuration_options); + + +// Stop the web server. +// +// Must be called last, when an application wants to stop the web server and +// release all associated resources. This function blocks until all Mongoose +// threads are stopped. Context pointer becomes invalid. +void mg_stop(struct mg_context *); + + +// Get the value of particular configuration parameter. +// The value returned is read-only. Mongoose does not allow changing +// configuration at run time. +// If given parameter name is not valid, NULL is returned. For valid +// names, return value is guaranteed to be non-NULL. If parameter is not +// set, zero-length string is returned. +const char *mg_get_option(const struct mg_context *ctx, const char *name); + + +// Return array of strings that represent valid configuration options. +// For each option, option name and default value is returned, i.e. the +// number of entries in the array equals to number_of_options x 2. +// Array is NULL terminated. +const char **mg_get_valid_option_names(void); + + +// Add, edit or delete the entry in the passwords file. +// +// This function allows an application to manipulate .htpasswd files on the +// fly by adding, deleting and changing user records. This is one of the +// several ways of implementing authentication on the server side. For another, +// cookie-based way please refer to the examples/chat.c in the source tree. +// +// If password is not NULL, entry is added (or modified if already exists). +// If password is NULL, entry is deleted. +// +// Return: +// 1 on success, 0 on error. +int mg_modify_passwords_file(const char *passwords_file_name, + const char *domain, + const char *user, + const char *password); + + +// Return information associated with the request. +struct mg_request_info *mg_get_request_info(struct mg_connection *); + + +// Send data to the client. +// Return: +// 0 when the connection has been closed +// -1 on error +// >0 number of bytes written on success +int mg_write(struct mg_connection *, const void *buf, size_t len); + + +// Send data to a websocket client wrapped in a websocket frame. +// It is unsafe to read/write to this connection from another thread. +// This function is available when mongoose is compiled with -DUSE_WEBSOCKET +// +// Return: +// 0 when the connection has been closed +// -1 on error +// >0 number of bytes written on success +int mg_websocket_write(struct mg_connection* conn, int opcode, + const char *data, size_t data_len); + +// Opcodes, from http://tools.ietf.org/html/rfc6455 +enum { + WEBSOCKET_OPCODE_CONTINUATION = 0x0, + WEBSOCKET_OPCODE_TEXT = 0x1, + WEBSOCKET_OPCODE_BINARY = 0x2, + WEBSOCKET_OPCODE_CONNECTION_CLOSE = 0x8, + WEBSOCKET_OPCODE_PING = 0x9, + WEBSOCKET_OPCODE_PONG = 0xa +}; + + +// Macros for enabling compiler-specific checks for printf-like arguments. +#undef PRINTF_FORMAT_STRING +#if defined(_MSC_VER) && _MSC_VER >= 1400 +#include +#if defined(_MSC_VER) && _MSC_VER > 1400 +#define PRINTF_FORMAT_STRING(s) _Printf_format_string_ s +#else +#define PRINTF_FORMAT_STRING(s) __format_string s +#endif +#else +#define PRINTF_FORMAT_STRING(s) s +#endif + +#ifdef __GNUC__ +#define PRINTF_ARGS(x, y) __attribute__((format(printf, x, y))) +#else +#define PRINTF_ARGS(x, y) +#endif + +// Send data to the client using printf() semantics. +// +// Works exactly like mg_write(), but allows to do message formatting. +int mg_printf(struct mg_connection *, + PRINTF_FORMAT_STRING(const char *fmt), ...) PRINTF_ARGS(2, 3); +#ifdef __rtems__ +struct rtems_printer; +void rtems_print_printer_mg_printf(struct rtems_printer *, struct mg_connection *); +#endif /* __rtems__ */ + + +// Send contents of the entire file together with HTTP headers. +void mg_send_file(struct mg_connection *conn, const char *path); + + +// Read data from the remote end, return number of bytes read. +// Return: +// 0 connection has been closed by peer. No more data could be read. +// < 0 read error. No more data could be read from the connection. +// > 0 number of bytes read into the buffer. +int mg_read(struct mg_connection *, void *buf, size_t len); + + +// Get the value of particular HTTP header. +// +// This is a helper function. It traverses request_info->http_headers array, +// and if the header is present in the array, returns its value. If it is +// not present, NULL is returned. +const char *mg_get_header(const struct mg_connection *, const char *name); + + +// Get a value of particular form variable. +// +// Parameters: +// data: pointer to form-uri-encoded buffer. This could be either POST data, +// or request_info.query_string. +// data_len: length of the encoded data. +// var_name: variable name to decode from the buffer +// dst: destination buffer for the decoded variable +// dst_len: length of the destination buffer +// +// Return: +// On success, length of the decoded variable. +// On error: +// -1 (variable not found). +// -2 (destination buffer is NULL, zero length or too small to hold the +// decoded variable). +// +// Destination buffer is guaranteed to be '\0' - terminated if it is not +// NULL or zero length. +int mg_get_var(const char *data, size_t data_len, + const char *var_name, char *dst, size_t dst_len); + +// Fetch value of certain cookie variable into the destination buffer. +// +// Destination buffer is guaranteed to be '\0' - terminated. In case of +// failure, dst[0] == '\0'. Note that RFC allows many occurrences of the same +// parameter. This function returns only first occurrence. +// +// Return: +// On success, value length. +// On error: +// -1 (either "Cookie:" header is not present at all or the requested +// parameter is not found). +// -2 (destination buffer is NULL, zero length or too small to hold the +// value). +int mg_get_cookie(const char *cookie, const char *var_name, + char *buf, size_t buf_len); + + +// Download data from the remote web server. +// host: host name to connect to, e.g. "foo.com", or "10.12.40.1". +// port: port number, e.g. 80. +// use_ssl: wether to use SSL connection. +// error_buffer, error_buffer_size: error message placeholder. +// request_fmt,...: HTTP request. +// Return: +// On success, valid pointer to the new connection, suitable for mg_read(). +// On error, NULL. error_buffer contains error message. +// Example: +// char ebuf[100]; +// struct mg_connection *conn; +// conn = mg_download("google.com", 80, 0, ebuf, sizeof(ebuf), +// "%s", "GET / HTTP/1.0\r\nHost: google.com\r\n\r\n"); +struct mg_connection *mg_download(const char *host, int port, int use_ssl, + char *error_buffer, size_t error_buffer_size, + PRINTF_FORMAT_STRING(const char *request_fmt), + ...) PRINTF_ARGS(6, 7); + + +// Close the connection opened by mg_download(). +void mg_close_connection(struct mg_connection *conn); + + +// File upload functionality. Each uploaded file gets saved into a temporary +// file and MG_UPLOAD event is sent. +// Return number of uploaded files. +int mg_upload(struct mg_connection *conn, const char *destination_dir); + + +// Convenience function -- create detached thread. +// Return: 0 on success, non-0 on error. +typedef void * (*mg_thread_func_t)(void *); +int mg_start_thread(mg_thread_func_t f, void *p); + + +// Return builtin mime type for the given file name. +// For unrecognized extensions, "text/plain" is returned. +const char *mg_get_builtin_mime_type(const char *file_name); + + +// Return Mongoose version. +const char *mg_version(void); + +// URL-decode input buffer into destination buffer. +// 0-terminate the destination buffer. +// form-url-encoded data differs from URI encoding in a way that it +// uses '+' as character for space, see RFC 1866 section 8.2.1 +// http://ftp.ics.uci.edu/pub/ietf/html/rfc1866.txt +// Return: length of the decoded data, or -1 if dst buffer is too small. +int mg_url_decode(const char *src, int src_len, char *dst, + int dst_len, int is_form_url_encoded); + +// MD5 hash given strings. +// Buffer 'buf' must be 33 bytes long. Varargs is a NULL terminated list of +// ASCIIz strings. When function returns, buf will contain human-readable +// MD5 hash. Example: +// char buf[33]; +// mg_md5(buf, "aa", "bb", NULL); +char *mg_md5(char buf[33], ...); + + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // MONGOOSE_HEADER_INCLUDED diff --git a/cpukit/include/mqueue.h b/cpukit/include/mqueue.h new file mode 100644 index 0000000000..36733a4730 --- /dev/null +++ b/cpukit/include/mqueue.h @@ -0,0 +1,218 @@ +/** + * @file + * + * @brief POSIX Message Queues + * + * This file contains the definitions related to POSIX Message Queues. + * + * The structure of the routines is identical to that of POSIX + * Message_queues to leave the option of having unnamed message + * queues at a future date. They are currently not part of the + * POSIX standard but unnamed message_queues are. This is also + * the reason for the apparently unnecessary tracking of + * the process_shared attribute. [In addition to the fact that + * it would be trivial to add pshared to the mq_attr structure + * and have process private message queues.] + * + * This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open + * time. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _MQUEUE_H +#define _MQUEUE_H + + +#include + +#if defined(_POSIX_MESSAGE_PASSING) + +#include + +#include +#include + +/** + * @defgroup POSIX_MQUEUE POSIX Message Queues + * + * @ingroup POSIXAPI + * + */ +/**@{**/ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * 15.1.1 Data Structures, P1003.1b-1993, p. 271 + */ + +/** + * Message queue id type. + * + * NOTE: Use uint32_t since all POSIX Ids are 32-bit currently. + */ +typedef uint32_t mqd_t; + +/** + * This is the message queue attributes structure. + */ +struct mq_attr { + /** This is the message queue flags */ + long mq_flags; + /** This is the maximum number of messages */ + long mq_maxmsg; + /** This is the maximum message size */ + long mq_msgsize; + /** This is the mumber of messages currently queued */ + long mq_curmsgs; +}; + +/** + * 15.2.2 Open a Message Queue, P1003.1b-1993, p. 272 + */ +mqd_t mq_open( + const char *name, + int oflag, + ... +); + +/** + * 15.2.2 Close a Message Queue, P1003.1b-1993, p. 275 + */ +int mq_close( + mqd_t mqdes +); + +/** + * @brief Remove a message queue. + * + * 15.2.2 Remove a Message Queue, P1003.1b-1993, p. 276 + * + * NOTE: The structure of the routines is identical to that of POSIX + * Message_queues to leave the option of having unnamed message + * queues at a future date. They are currently not part of the + * POSIX standard but unnamed message_queues are. This is also + * the reason for the apparently unnecessary tracking of + * the process_shared attribute. [In addition to the fact that + * it would be trivial to add pshared to the mq_attr structure + * and have process private message queues.] + * + * This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open + * time. + */ +int mq_unlink( + const char *name +); + +/** + * 15.2.4 Send a Message to a Message Queue, P1003.1b-1993, p. 277 + * + * NOTE; P1003.4b/D8, p. 45 adds mq_timedsend(). + */ +int mq_send( + mqd_t mqdes, + const char *msg_ptr, + size_t msg_len, + unsigned int msg_prio +); + +#if defined(_POSIX_TIMEOUTS) + +#include + +/** + * @brief Send a message to a message queue. + * + * @see mq_send() + */ +int mq_timedsend( + mqd_t mqdes, + const char *msg_ptr, + size_t msg_len, + unsigned int msg_prio, + const struct timespec *abstime +); + +#endif /* _POSIX_TIMEOUTS */ + +/** + * @brief Receive a message from a message queue. + * + * 15.2.5 Receive a Message From a Message Queue, P1003.1b-1993, p. 279 + * + * NOTE: P1003.4b/D8, p. 45 adds mq_timedreceive(). + */ +ssize_t mq_receive( + mqd_t mqdes, + char *msg_ptr, + size_t msg_len, + unsigned int *msg_prio +); + +#if defined(_POSIX_TIMEOUTS) + +ssize_t mq_timedreceive( + mqd_t mqdes, + char *__restrict msg_ptr, + size_t msg_len, + unsigned int *__restrict msg_prio, + const struct timespec *__restrict abstime +); + +#endif /* _POSIX_TIMEOUTS */ + +#if defined(_POSIX_REALTIME_SIGNALS) + +/** + * @brief Notify process that a message is available on a queue. + * + * 15.2.6 Notify Process that a Message is Available on a Queue, + * P1003.1b-1993, p. 280 + */ +int mq_notify( + mqd_t mqdes, + const struct sigevent *notification +); + +#endif /* _POSIX_REALTIME_SIGNALS */ + +/** + * @brief Set message queue attributes. + * + * 15.2.7 Set Message Queue Attributes, P1003.1b-1993, p. 281 + */ +int mq_setattr( + mqd_t mqdes, + const struct mq_attr *__restrict mqstat, + struct mq_attr *__restrict omqstat +); + +/* + * 15.2.8 Get Message Queue Attributes, P1003.1b-1993, p. 283 + */ + +int mq_getattr( + mqd_t mqdes, + struct mq_attr *mqstat +); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* _POSIX_MESSAGE_PASSING */ + +#endif +/* end of include file */ diff --git a/cpukit/include/pci.h b/cpukit/include/pci.h new file mode 100644 index 0000000000..a0e008a2d0 --- /dev/null +++ b/cpukit/include/pci.h @@ -0,0 +1,114 @@ +/* + * PCI library. Defines in this file was taken from FreeBSD and auto-generated + * pci_ids.h reused from RTEMS. + * + * COPYRIGHT (c) 2009 Cobham Gaisler AB. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef __PCI_H__ +#define __PCI_H__ + +#include +#include + +#define PCI_INVALID_VENDORDEVICEID 0xffffffff + +#define PCID_CLASS(class, dev) ((class << 8) | dev) +#define PCID_PCI2PCI_BRIDGE PCID_CLASS(PCIC_BRIDGE, PCIS_BRIDGE_PCI) + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* The PCI Library have the following build time configuration options. It is + * up to the BSP header file (bsp.h) to set options properly. + * + * BSP_PCI_BIG_ENDIAN - Access inline routines will be for a big-endian PCI + * bus, if not defined the routines will assume that + * PCI is as the standard defines: little-endian. + * + * Note that drivers may be run-time configurable, + * meaning that they may adopt to either big-endian or + * little-endian PCI bus, the host driver or BSP may + * detect endianness during run-time. + */ + +/* Error return values */ +enum { + PCISTS_ERR = -1, /* Undefined Error */ + PCISTS_OK = 0, + PCISTS_EINVAL = 1, /* Bad input arguments */ + PCISTS_MSTABRT = 2, /* CFG space access error (can be ignored) */ +}; + +/* PCI System type can be used to determine system for drivers. Normally + * the system is Host, but the peripheral configuration library also supports + * being PCI peripheral not allowed to access configuration space. + * + * The active configuration Library set this variable. + */ +enum pci_system_type { + PCI_SYSTEM_NONE = 0, + PCI_SYSTEM_HOST = 1, + PCI_SYSTEM_PERIPHERAL = 2, +}; +extern enum pci_system_type pci_system_type; + +/* PCI Bus Endianness. The PCI specification is little endian, however on some + * embedded systems (AT697-LEON2 for example) the PCI bus is defined as big + * endian (non-standard) in order to avoid byte-twisting. + */ +enum { + PCI_LITTLE_ENDIAN = 0, + PCI_BIG_ENDIAN = 1, +}; +extern int pci_endian; + +/* Return the number of PCI busses in the system */ +extern int pci_bus_count(void); + +/* Scan the PCI bus and print the PCI device/functions/bridges and their + * current resources and size to the system console. + */ +extern void pci_print(void); + +/* Print current configuration of a single PCI device by reading PCI + * configuration space + */ +extern void pci_print_dev(pci_dev_t dev); +extern void pci_print_device(int bus, int slot, int function); + +/*** PCI Configuration Space direct access routines ***/ + +/* Function iterates over all PCI buses/devices/functions and calls + * func(PCIDEV,arg) for each present device. The iteration is stopped if + * func() returns non-zero result the same result is returned. As long + * as func() returns zero the function will keep on iterating, when all + * devices has been processed the function return zero. + * + * The function iterates over all devices/functions on all buses by accessing + * configuration space directly (PCI RAM data structures not used). This + * function is valid to call after PCI buses have been enumrated. + */ +extern int pci_for_each(int (*func)(pci_dev_t, void*), void *arg); + +/* Get PCI Configuration space BUS|SLOT|FUNC for a device matching PCI + * Vendor, Device and instance number 'index'. + * + * Return Values + * -1 pci_find_dev did not find a device matching the criterion. + * 0 device was found, *pdev was updated with the device's BUS|SLOT|FUNC + */ +extern int pci_find(uint16_t ven, uint16_t dev, int index, pci_dev_t *pdev); + +#ifdef __cplusplus +} +#endif + +#endif /* __PCI_H__ */ diff --git a/cpukit/include/pci/access.h b/cpukit/include/pci/access.h new file mode 100644 index 0000000000..4337db30c3 --- /dev/null +++ b/cpukit/include/pci/access.h @@ -0,0 +1,258 @@ +/* Routines to access PCI memory/configuration space and other PCI related + * functions the PCI Library provides. + * + * COPYRIGHT (c) 2010 Cobham Gaisler AB. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + + +#ifndef __PCI_ACCESS_H__ +#define __PCI_ACCESS_H__ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Identification of a PCI configuration space device (16-bit) */ +typedef uint16_t pci_dev_t; +/* Create a PCI Configuration Space ID */ +#define PCI_DEV(bus, slot, func) (((bus)<<8) | ((slot)<<3) | (func)) +/* Get Bus of a PCI Configuration Space ID */ +#define PCI_DEV_BUS(dev) (((dev) >> 8) & 0xff) +/* Get Slot/Device of a PCI Configuration Space ID */ +#define PCI_DEV_SLOT(dev) (((dev) >> 3) & 0x1f) +/* Get Function of a PCI Configuration Space ID */ +#define PCI_DEV_FUNC(dev) ((dev) & 0x7) +/* Get Device and Function of a PCI Configuration Space ID */ +#define PCI_DEV_DEVFUNC(dev) ((dev) & 0xff) +/* Expand Device into argument lists */ +#define PCI_DEV_EXPAND(dev) PCI_DEV_BUS((dev)), PCI_DEV_SLOT((dev)), PCI_DEV_FUNC((dev)) + +/* Configuration Space Read/Write Operations */ +struct pci_cfg_ops { + /* Configuration Space Access and Setup Routines */ + int (*read8)(pci_dev_t dev, int ofs, uint8_t *data); + int (*read16)(pci_dev_t dev, int ofs, uint16_t *data); + int (*read32)(pci_dev_t dev, int ofs, uint32_t *data); + int (*write8)(pci_dev_t dev, int ofs, uint8_t data); + int (*write16)(pci_dev_t dev, int ofs, uint16_t data); + int (*write32)(pci_dev_t dev, int ofs, uint32_t data); +}; + +/* Read a register over PCI I/O Space, and swap it if necessary (due to + * PCI endianness) + */ +struct pci_io_ops { + uint8_t (*read8)(uint8_t *adr); + uint16_t(*read16)(uint16_t *adr); + uint32_t (*read32)(uint32_t *adr); + void (*write8)(uint8_t *adr, uint8_t data); + void (*write16)(uint16_t *adr, uint16_t data); + void (*write32)(uint32_t *adr, uint32_t data); +}; + +/* Read a register over PCI Memory Space (non-prefetchable memory), and + * swap it if necessary (due to PCI endianness) + */ +struct pci_memreg_ops { + uint8_t (*ld8)(uint8_t *adr); + void (*st8)(uint8_t *adr, uint8_t data); + + uint16_t(*ld_le16)(uint16_t *adr); + void (*st_le16)(uint16_t *adr, uint16_t data); + uint16_t(*ld_be16)(uint16_t *adr); + void (*st_be16)(uint16_t *adr, uint16_t data); + + uint32_t (*ld_le32)(uint32_t *adr); + void (*st_le32)(uint32_t *adr, uint32_t data); + uint32_t (*ld_be32)(uint32_t *adr); + void (*st_be32)(uint32_t *adr, uint32_t data); +}; + +typedef uint8_t (*pci_ld8_t)(uint8_t *adr); +typedef void (*pci_st8_t)(uint8_t *adr, uint8_t data); +typedef uint16_t(pci_ld16_t)(uint16_t *adr); +typedef void (*pci_st16_t)(uint16_t *adr, uint16_t data); +typedef uint32_t (*pci_ld32_t)(uint32_t *adr); +typedef void (*pci_st32_t)(uint32_t *adr, uint32_t data); + +struct pci_access_drv { + /* Configuration */ + struct pci_cfg_ops cfg; + + /* I/O Access operations */ + struct pci_io_ops io; + + /* Registers over Memory Access operations. Note that these funcs + * are only for code that need to be compatible with both Big-Endian + * and Little-Endian PCI bus or for some other reason need function + * pointers to access functions. Normally drivers use the inline + * functions for Registers-over-Memory access to avoid extra function + * call. + */ + struct pci_memreg_ops *memreg; + + /* Translate from PCI address to CPU address (dir=0). Translate + * CPU address to PCI address (dir!=0). The address will can be + * used to perform I/O access or memory access by CPU or PCI DMA + * peripheral. + * + * address In/Out. CPU address or PCI address. + * type Access type. 1=I/O, 2=MEMIO, 3=MEM + * dir Translate direction. 0=PCI-to-CPU, 0!=CPU-to-PCI, + * + * Return Value + * 0 = Success + * -1 = Requested Address not mapped into other address space + * i.e. not accessible + */ + int (*translate)(uint32_t *address, int type, int dir); +}; + +/* Access Routines valid after a PCI-Access-Driver has registered */ +extern struct pci_access_drv pci_access_ops; + +/* Register PCI Access Driver */ +extern int pci_access_drv_register(struct pci_access_drv *drv); + +/* Set/unset bits in command and status register of a PCI device */ +extern void pci_modify_cmdsts(pci_dev_t dev, uint32_t mask, uint32_t val); + +/* Enable Memory in command register */ +RTEMS_INLINE_ROUTINE void pci_mem_enable(pci_dev_t dev) +{ + pci_modify_cmdsts(dev, PCIM_CMD_MEMEN, PCIM_CMD_MEMEN); +} + +RTEMS_INLINE_ROUTINE void pci_mem_disable(pci_dev_t dev) +{ + pci_modify_cmdsts(dev, PCIM_CMD_MEMEN, 0); +} + +RTEMS_INLINE_ROUTINE void pci_io_enable(pci_dev_t dev) +{ + pci_modify_cmdsts(dev, PCIM_CMD_PORTEN, PCIM_CMD_PORTEN); +} + +RTEMS_INLINE_ROUTINE void pci_io_disable(pci_dev_t dev) +{ + pci_modify_cmdsts(dev, PCIM_CMD_PORTEN, 0); +} + +RTEMS_INLINE_ROUTINE void pci_master_enable(pci_dev_t dev) +{ + pci_modify_cmdsts(dev, PCIM_CMD_BUSMASTEREN, PCIM_CMD_BUSMASTEREN); +} + +RTEMS_INLINE_ROUTINE void pci_master_disable(pci_dev_t dev) +{ + pci_modify_cmdsts(dev, PCIM_CMD_BUSMASTEREN, 0); +} + +/* Configuration Space Access Read Routines */ +extern int pci_cfg_r8(pci_dev_t dev, int ofs, uint8_t *data); +extern int pci_cfg_r16(pci_dev_t dev, int ofs, uint16_t *data); +extern int pci_cfg_r32(pci_dev_t dev, int ofs, uint32_t *data); + +/* Configuration Space Access Write Routines */ +extern int pci_cfg_w8(pci_dev_t dev, int ofs, uint8_t data); +extern int pci_cfg_w16(pci_dev_t dev, int ofs, uint16_t data); +extern int pci_cfg_w32(pci_dev_t dev, int ofs, uint32_t data); + +/* Read a register over PCI I/O Space */ +extern uint8_t pci_io_r8(uint32_t adr); +extern uint16_t pci_io_r16(uint32_t adr); +extern uint32_t pci_io_r32(uint32_t adr); + +/* Write a register over PCI I/O Space */ +extern void pci_io_w8(uint32_t adr, uint8_t data); +extern void pci_io_w16(uint32_t adr, uint16_t data); +extern void pci_io_w32(uint32_t adr, uint32_t data); + +/* Translate PCI address into CPU accessible address */ +RTEMS_INLINE_ROUTINE int pci_pci2cpu(uint32_t *address, int type) +{ + return pci_access_ops.translate(address, type, 0); +} + +/* Translate CPU accessible address into PCI address (for DMA) */ +RTEMS_INLINE_ROUTINE int pci_cpu2pci(uint32_t *address, int type) +{ + return pci_access_ops.translate(address, type, 1); +} + +/*** Read/Write a register over PCI Memory Space ***/ + +RTEMS_INLINE_ROUTINE uint8_t pci_ld8(volatile uint8_t *addr) +{ + return *addr; +} + +RTEMS_INLINE_ROUTINE void pci_st8(volatile uint8_t *addr, uint8_t val) +{ + *addr = val; +} + +/* Registers-over-Memory Space access routines. The routines are not inlined + * so it is possible during run-time to select which function implemention + * to use. The use of these functions are not recommended since it will have a + * performance penalty. + * + * 8-bit accesses are the same for Little and Big endian PCI buses. + */ +uint8_t pci_mem_ld8(uint8_t *adr); +void pci_mem_st8(uint8_t *adr, uint8_t data); +/* Registers-over-Memory Space - Generic Big endian PCI bus definitions */ +uint16_t pci_mem_be_ld_le16(uint16_t *adr); +uint16_t pci_mem_be_ld_be16(uint16_t *adr); +uint32_t pci_mem_be_ld_le32(uint32_t *adr); +uint32_t pci_mem_be_ld_be32(uint32_t *adr); +void pci_mem_be_st_le16(uint16_t *adr, uint16_t data); +void pci_mem_be_st_be16(uint16_t *adr, uint16_t data); +void pci_mem_be_st_le32(uint32_t *adr, uint32_t data); +void pci_mem_be_st_be32(uint32_t *adr, uint32_t data); +/* Registers-over-Memory Space - Generic Little endian PCI bus definitions */ +uint16_t pci_mem_le_ld_le16(uint16_t *adr); +uint16_t pci_mem_le_ld_be16(uint16_t *adr); +uint32_t pci_mem_le_ld_le32(uint32_t *adr); +uint32_t pci_mem_le_ld_be32(uint32_t *adr); +void pci_mem_le_st_le16(uint16_t *adr, uint16_t data); +void pci_mem_le_st_be16(uint16_t *adr, uint16_t data); +void pci_mem_le_st_le32(uint32_t *adr, uint32_t data); +void pci_mem_le_st_be32(uint32_t *adr, uint32_t data); + +/* Get Read/Write function for accessing a register over PCI Memory Space + * (non-inline functions). + * + * Arguments + * wr 0(Read), 1(Write) + * size 1(Byte), 2(Word), 4(Double Word) + * func Where function pointer will be stored + * endian PCI_LITTLE_ENDIAN or PCI_BIG_ENDIAN + * type 1(I/O), 3(REG over MEM), 4(CFG) + * + * Return + * 0 Found function + * others No such function defined by host driver or BSP + */ +extern int pci_access_func(int wr, int size, void **func, int endian, int type); + +/* Predefined functions for Host drivers or BSPs that define the + * register-over-memory space functions operations. + */ +extern struct pci_memreg_ops pci_mem_le_ops; /* For Little-Endian PCI bus */ +extern struct pci_memreg_ops pci_mem_be_ops; /* For Big-Endian PCI bus */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__PCI_ACCESS_H__ */ diff --git a/cpukit/include/pci/cfg.h b/cpukit/include/pci/cfg.h new file mode 100644 index 0000000000..1f55c85971 --- /dev/null +++ b/cpukit/include/pci/cfg.h @@ -0,0 +1,254 @@ +/* PCI Configuration Library + * + * COPYRIGHT (c) 2010 Cobham Gaisler AB. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +/* Four versions of the library exists: + * - auto configuration (default) + * - read configuration from PnP (inherit BIOS set up) + * - static configuration (user defined config) + * - peripheral configuration, no CFG space accesses are possible instead a + * device tree known at compile-time have been built in. + * all versions are defined through here. + */ + +#ifndef __PCI_CFG_H__ +#define __PCI_CFG_H__ + +#include + +/* PCI Configuration library */ + +/* Return the number of PCI buses in system */ +extern int pci_bus_count(void); + +/* PCI Address assigned to BARs which failed to fit into the PCI Window or + * is disabled by any other cause. + */ +extern uint32_t pci_invalid_address; + +/* PCI Configuration Library of the system */ +enum { + PCI_CONFIG_LIB_NONE = 0, + PCI_CONFIG_LIB_AUTO = 1, + PCI_CONFIG_LIB_STATIC = 2, + PCI_CONFIG_LIB_READ = 3, + PCI_CONFIG_LIB_PERIPHERAL = 4, +}; +extern const int pci_config_lib_type; + +/* Configuration library function pointers, these are set in + * by project configuration or by the BSP. The configuration will pull in the + * PCI Library needed and the PCI initialization functions will call these + * functions on initialization from the host driver. + */ +extern int (*pci_config_lib_init)(void); +extern void (*pci_config_lib_register)(void *config); + +/* Configure PCI devices and bridges, and setup the RAM data structures + * describing the PCI devices currently present in the system. + * + * Returns 0 on success, -1 on failure. + */ +extern int pci_config_init(void); + +/* Register a config-library specific configuration used by the libarary in + * pci_config_init(). + */ +extern void pci_config_register(void *config); + +/* Print current PCI configuration (C-code) to terminal, can be used in + * static and peripheral PCI configuration library. The configuration is + * taken from the current configuration library setup. + */ +extern void pci_cfg_print(void); + +struct pci_bus; /* Bridge Device and secondary bus information */ +struct pci_dev; /* Device/function */ +struct pci_res; /* Resource: BAR, ROM or Bridge Window */ + +/* The Host Bridge and all subdevices (the PCI RAM data structure) */ +extern struct pci_bus pci_hb; + +/* Arguments for pci_for_each_child() search option */ +#define SEARCH_CHILDREN 0 /* direct children of bus only */ +#define SEARCH_DEPTH 1 /* all children of bus */ + +/* Iterate over all PCI devices on a bus (see search options) and call func(), + * iteration is stopped if a non-zero value is returned by func(). + * + * The function iterates over the PCI RAM data structure, it is not + * available until after all devices have been found and pci_hb is populated, + * typically after pci_config_init() is called. + * + * search options: 0 (no child buses), 1 (depth first, recursive) + * + * Return Values + * 0 All PCI devices were processed, func() returned 0 on every call + * X func() returned non-zero X value, the search was stopped + */ +extern int pci_for_each_child( + struct pci_bus *bus, + int (*func)(struct pci_dev *, void *arg), + void *arg, + int search); + +/* Depth first search of all PCI devices in PCI RAM data structure and call + * func(dev, arg), iteration is stopped if a non-zero value is returned by + * func(). + * + * The function iterates over the PCI RAM data structure, it is not + * available until after all devices have been found and pci_hb is populated, + * typically after pci_config_init() is called. + * + * Return Values + * 0 All PCI devices were processed, func() returned 0 on every call + * X func() returned non-zero X value, the search was stopped + */ +extern int pci_for_each_dev( + int (*func)(struct pci_dev *, void *arg), + void *arg); + +/* Get PCI device from RAM device tree for a device matching PCI Vendor, Device + * and instance number 'index'. + * + * Return Values + * -1 pci_find_dev did not find a device matching the criterion. + * 0 device was found, *ppdev was updated with the PCI device address + */ +extern int pci_find_dev(uint16_t ven, uint16_t dev, int index, + struct pci_dev **ppdev); + +/* Get PCI device from RAM device tree by BUS|SLOT|FUNC. + * + * Return Values + * -1 pci_get_dev did not find a device matching the criterion + * 0 device was found, *ppdev was updated with the PCI device address + */ +extern int pci_get_dev(pci_dev_t pcidev, struct pci_dev **ppdev); + +/* Resource flags */ +#define PCI_RES_IO 1 +#define PCI_RES_MEMIO 2 +#define PCI_RES_MEM_PREFETCH 1 +#define PCI_RES_MEM (PCI_RES_MEMIO | PCI_RES_MEM_PREFETCH) +#define PCI_RES_TYPE_MASK 0x3 +#define PCI_RES_IO32 0x08 +#define PCI_RES_FAIL 0x10 /* Alloc Failed */ + +/* BAR Resouces entry */ +struct pci_res { + struct pci_res *next; + uint32_t size; + uint32_t boundary; + unsigned char flags; /* I/O, MEM or MEMIO */ + unsigned char bar; + + /* Assigned Resource (PCI address), zero if not assigned */ + uint32_t start; + uint32_t end; +}; + +/* Get Device from resource pointer. bar is the index of the pci_dev.resources + * array and used to get the device base address of which the resource is + * associated with. + */ +#define RES2DEV(res) ((struct pci_dev *) \ + ((uintptr_t)res - (uintptr_t)(res->bar * (sizeof(struct pci_res))))) + +/* Device flags */ +#define PCI_DEV_BRIDGE 0x01 /* Device is a Bridge (struct pci_bus) */ +#define PCI_DEV_RES_FAIL 0x02 /* Resource alloction for device BARs failed */ + +/* Bus Flags */ +#define PCI_BUS_IO 0x01 /* 16-bit I/O address decoding */ +#define PCI_BUS_MEMIO 0x02 /* Bus support non-prefetchable mem (always) */ +#define PCI_BUS_MEM 0x04 /* Bus support prefetchable memory space */ +#define PCI_BUS_IO32 0x08 /* 32-bit I/O address decoding */ + +#define BRIDGE_RES_COUNT 2 /* Number of BAR resources a bridge can have */ +#define BUS_RES_START BRIDGE_RES_COUNT + +/* Bus Resources Array */ +enum { + BUS_RES_IO = 0, + BUS_RES_MEMIO = 1, + BUS_RES_MEM = 2, +}; + +/* Device Resource array index meaning */ +enum { + /* A Device has up to 6 BARs and an optional ROM BAR */ + DEV_RES_BAR1 = 0, + DEV_RES_BAR2 = 1, + DEV_RES_BAR3 = 2, + DEV_RES_BAR4 = 3, + DEV_RES_BAR5 = 4, + DEV_RES_BAR6 = 5, + DEV_RES_ROM = 6, + + /* Bridges have 2 BARs (BAR1 and BAR2) and 3 Windows to secondary bus + * and an optional ROM BAR + */ + BRIDGE_RES_BAR1 = 0, + BRIDGE_RES_BAR2 = 1, + BRIDGE_RES_IO = 2, + BRIDGE_RES_MEMIO = 3, + BRIDGE_RES_MEM = 4, + BRIDGE_RES_UNUSED1 = 5, + BRIDGE_RES_ROM = 6, +}; + +/* Maximum Number of Resources of a device */ +#define DEV_RES_CNT (DEV_RES_ROM + 1) + +/* PCI Device (Bus|Slot|Function) description */ +struct pci_dev { + struct pci_res resources[DEV_RES_CNT]; /* must be topmost field */ + struct pci_dev *next; + struct pci_bus *bus; + pci_dev_t busdevfun; + uint8_t flags; + uint8_t sysirq; + uint16_t vendor; + uint16_t device; + uint16_t subvendor; + uint16_t subdevice; + uint32_t classrev; + + /* static configuration settings */ + uint16_t command; +}; + +/* PCI Bus description */ +struct pci_bus { + struct pci_dev dev; /* PCI Bridge */ + struct pci_dev *devs; /* Devices on child (secondary) Bus */ + unsigned int flags; + + /* Bridge Information */ + int num; /* Bus number (0=Root-PCI-bus) */ + int pri; /* Primary Bus Number */ + int sord; /* Subordinate Buses (Child bus count) */ + +#if defined(PCI_CFG_AUTO_LIB) + /* Resources of devices on bus. USED INTERNALLY IN AUTO-CFG LIBRARY. + * + * BUS_RES_IO = 0: I/O resources + * BUS_RES_MEMIO = 1: Prefetchable memory resources + * BUS_RES_MEM = 2: Non-Prefetchable memory resources + */ + struct pci_res *busres[3]; +#endif +}; + +#include +#include +#include +#include + +#endif diff --git a/cpukit/include/pci/cfg_auto.h b/cpukit/include/pci/cfg_auto.h new file mode 100644 index 0000000000..e374e2e2d4 --- /dev/null +++ b/cpukit/include/pci/cfg_auto.h @@ -0,0 +1,58 @@ +/* PCI Auto Configuration Library + * + * COPYRIGHT (c) 2010 Cobham Gaisler AB. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef __PCI_CFG_AUTO_H__ +#define __PCI_CFG_AUTO_H__ + +#define CFGOPT_NOSETUP_IRQ 0x1 /* Skip IRQ setup */ + +/* PCI Memory Layout setup, used by the auto-config library in order to + * determine the addresses of PCI BARs and Buses. + * + * All addresses are in PCI address space, the actual address the CPU access + * may be different, and taken care of elsewhere. + */ +struct pci_auto_setup { + int options; + + /* PCI prefetchable Memory space (OPTIONAL) */ + uint32_t mem_start; + uint32_t mem_size; /* 0 = Use MEMIO space for prefetchable mem BARs */ + + /* PCI non-prefetchable Memory */ + uint32_t memio_start; + uint32_t memio_size; + + /* PCI I/O space (OPTIONAL) */ + uint32_t io_start; + uint32_t io_size; /* 0 = No I/O space */ + + /* Get System IRQ connected to a PCI line of a PCI device on bus0. + * The return IRQ value zero equals no IRQ (IRQ disabled). + */ + uint8_t (*irq_map)(pci_dev_t dev, int irq_pin); + + /* IRQ Bridge routing. Returns the interrupt pin (0..3 = A..D) that + * a device is connected to on parent bus. + */ + int (*irq_route)(pci_dev_t dev, int irq_pin); +}; + +/* Do PCI initialization: Enumrate buses, scan buses for devices, assign + * I/O MEM and MEMIO resources, assign IRQ and so on. + */ +extern int pci_config_auto(void); + +/* Register a configuration for the auto library (struct pci_auto_setup *) */ +extern void pci_config_auto_register(void *config); + +/* PCI memory map */ +extern struct pci_auto_setup pci_auto_cfg; + +#endif diff --git a/cpukit/include/pci/cfg_peripheral.h b/cpukit/include/pci/cfg_peripheral.h new file mode 100644 index 0000000000..f05c8257c6 --- /dev/null +++ b/cpukit/include/pci/cfg_peripheral.h @@ -0,0 +1,19 @@ +/* PCI Peripheral Configuration Library + * + * COPYRIGHT (c) 2010 Cobham Gaisler AB. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef __PCI_CFG_PERIPHERAL_H__ +#define __PCI_CFG_PERIPHERAL_H__ + +/* The user must provide a PCI configuration using the "struct pci_bus pci_hb" + * structure. Nothing else than setting pci_system_type and pci_bus_cnt is done + * by the peripheral library. + */ +extern int pci_config_peripheral(void); + +#endif diff --git a/cpukit/include/pci/cfg_read.h b/cpukit/include/pci/cfg_read.h new file mode 100644 index 0000000000..3dd7678279 --- /dev/null +++ b/cpukit/include/pci/cfg_read.h @@ -0,0 +1,21 @@ +/* PCI Read Configuration Library. Read current config that bootloader/BIOS + * has setup. + * + * COPYRIGHT (c) 2010 Cobham Gaisler AB. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + + +#ifndef __PCI_CFG_READ_H__ +#define __PCI_CFG_READ_H__ + +/* Build PCI device tree in "struct pci_bus pci_hb" according to current setup + * in hardware. Devices/buses are created by reading the resource assignments + * that the BIOS/bootloader has already setup for us. + */ +extern int pci_config_read(void); + +#endif diff --git a/cpukit/include/pci/cfg_static.h b/cpukit/include/pci/cfg_static.h new file mode 100644 index 0000000000..62ee0dad7d --- /dev/null +++ b/cpukit/include/pci/cfg_static.h @@ -0,0 +1,21 @@ +/* Static PCI Auto Configuration Library + * + * COPYRIGHT (c) 2010 Cobham Gaisler AB. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef __PCI_CFG_STATIC_H__ +#define __PCI_CFG_STATIC_H__ + +/* This function initializes all buses and device accorind to a user defined + * "static" configuration. The configuration can manually created with C + * data structures. Or it can be automatically created on a running target + * using the pci_cfg_print() routine after the AUTO or READ Configuration + * Library has setup the PCI bus + */ +extern int pci_config_static(void); + +#endif diff --git a/cpukit/include/pci/ids.h b/cpukit/include/pci/ids.h new file mode 100644 index 0000000000..88e1ad5e3e --- /dev/null +++ b/cpukit/include/pci/ids.h @@ -0,0 +1,827 @@ +/* + * Copyright 1994, Drew Eckhardt + * Copyright 1997, 1998 Martin Mares + * + * This file comes from the auto-generated PCI IDs part of the + * cpukit/include/rtems/pci.h. + * Copyright 2009, Cobham Gaisler AB + * + * For more information, please consult the following manuals (look at + * http://www.pcisig.com/ for how to get them): + * + * PCI BIOS Specification + * PCI Local Bus Specification + * PCI to PCI Bridge Specification + * PCI System Design Guide + */ + +/* PCI Vendor and card ID's: sort these numerically according to vendor + * (and according to card ID within vendor). Send all updates to + * . + */ + +/* For the future this file should be generated + * from the PCI IDS database at http://pciids.sourceforge.net/ ? + */ + +#ifndef __PCI_IDS_H__ +#define __PCI_IDS_H__ + +/* Include non-public PCI ids (not auto generated) */ +#include + +/* Not a valid ID, used to match any device ID */ +#define PCI_ID_ANY 0xffff + +/* + * Vendor and card ID's: sort these numerically according to vendor + * (and according to card ID within vendor). Send all updates to + * . + */ +#define PCIR_VENDOR_COMPAQ 0x0e11 +#define PCIR_DEVICE_COMPAQ_1280 0x3033 +#define PCIR_DEVICE_COMPAQ_TRIFLEX 0x4000 +#define PCIR_DEVICE_COMPAQ_SMART2P 0xae10 +#define PCIR_DEVICE_COMPAQ_NETEL100 0xae32 +#define PCIR_DEVICE_COMPAQ_NETEL10 0xae34 +#define PCIR_DEVICE_COMPAQ_NETFLEX3I 0xae35 +#define PCIR_DEVICE_COMPAQ_NETEL100D 0xae40 +#define PCIR_DEVICE_COMPAQ_NETEL100PI 0xae43 +#define PCIR_DEVICE_COMPAQ_NETEL100I 0xb011 +#define PCIR_DEVICE_COMPAQ_THUNDER 0xf130 +#define PCIR_DEVICE_COMPAQ_NETFLEX3B 0xf150 + +#define PCIR_VENDOR_NCR 0x1000 +#define PCIR_DEVICE_NCR_53C810 0x0001 +#define PCIR_DEVICE_NCR_53C820 0x0002 +#define PCIR_DEVICE_NCR_53C825 0x0003 +#define PCIR_DEVICE_NCR_53C815 0x0004 +#define PCIR_DEVICE_NCR_53C860 0x0006 +#define PCIR_DEVICE_NCR_53C896 0x000b +#define PCIR_DEVICE_NCR_53C895 0x000c +#define PCIR_DEVICE_NCR_53C885 0x000d +#define PCIR_DEVICE_NCR_53C875 0x000f +#define PCIR_DEVICE_NCR_53C875J 0x008f + +#define PCIR_VENDOR_ATI 0x1002 +#define PCIR_DEVICE_ATI_68800 0x4158 +#define PCIR_DEVICE_ATI_215CT222 0x4354 +#define PCIR_DEVICE_ATI_210888CX 0x4358 +#define PCIR_DEVICE_ATI_215GB 0x4742 +#define PCIR_DEVICE_ATI_215GD 0x4744 +#define PCIR_DEVICE_ATI_215GI 0x4749 +#define PCIR_DEVICE_ATI_215GP 0x4750 +#define PCIR_DEVICE_ATI_215GQ 0x4751 +#define PCIR_DEVICE_ATI_215GT 0x4754 +#define PCIR_DEVICE_ATI_215GTB 0x4755 +#define PCIR_DEVICE_ATI_210888GX 0x4758 +#define PCIR_DEVICE_ATI_215LG 0x4c47 +#define PCIR_DEVICE_ATI_264LT 0x4c54 +#define PCIR_DEVICE_ATI_264VT 0x5654 + +#define PCIR_VENDOR_VLSI 0x1004 +#define PCIR_DEVICE_VLSI_82C592 0x0005 +#define PCIR_DEVICE_VLSI_82C593 0x0006 +#define PCIR_DEVICE_VLSI_82C594 0x0007 +#define PCIR_DEVICE_VLSI_82C597 0x0009 +#define PCIR_DEVICE_VLSI_82C541 0x000c +#define PCIR_DEVICE_VLSI_82C543 0x000d +#define PCIR_DEVICE_VLSI_82C532 0x0101 +#define PCIR_DEVICE_VLSI_82C534 0x0102 +#define PCIR_DEVICE_VLSI_82C535 0x0104 +#define PCIR_DEVICE_VLSI_82C147 0x0105 +#define PCIR_DEVICE_VLSI_VAS96011 0x0702 + +#define PCIR_VENDOR_ADL 0x1005 +#define PCIR_DEVICE_ADL_2301 0x2301 + +#define PCIR_VENDOR_NS 0x100b +#define PCIR_DEVICE_NS_87415 0x0002 +#define PCIR_DEVICE_NS_87410 0xd001 + +#define PCIR_VENDOR_TSENG 0x100c +#define PCIR_DEVICE_TSENG_W32P_2 0x3202 +#define PCIR_DEVICE_TSENG_W32P_b 0x3205 +#define PCIR_DEVICE_TSENG_W32P_c 0x3206 +#define PCIR_DEVICE_TSENG_W32P_d 0x3207 +#define PCIR_DEVICE_TSENG_ET6000 0x3208 + +#define PCIR_VENDOR_WEITEK 0x100e +#define PCIR_DEVICE_WEITEK_P9000 0x9001 +#define PCIR_DEVICE_WEITEK_P9100 0x9100 + +#define PCIR_VENDOR_DEC 0x1011 +#define PCIR_DEVICE_DEC_BRD 0x0001 +#define PCIR_DEVICE_DEC_TULIP 0x0002 +#define PCIR_DEVICE_DEC_TGA 0x0004 +#define PCIR_DEVICE_DEC_TULIP_FAST 0x0009 +#define PCIR_DEVICE_DEC_TGA2 0x000D +#define PCIR_DEVICE_DEC_FDDI 0x000F +#define PCIR_DEVICE_DEC_TULIP_PLUS 0x0014 +#define PCIR_DEVICE_DEC_21142 0x0019 +#define PCIR_DEVICE_DEC_21052 0x0021 +#define PCIR_DEVICE_DEC_21150 0x0022 +#define PCIR_DEVICE_DEC_21152 0x0024 + +#define PCIR_VENDOR_CIRRUS 0x1013 +#define PCIR_DEVICE_CIRRUS_7548 0x0038 +#define PCIR_DEVICE_CIRRUS_5430 0x00a0 +#define PCIR_DEVICE_CIRRUS_5434_4 0x00a4 +#define PCIR_DEVICE_CIRRUS_5434_8 0x00a8 +#define PCIR_DEVICE_CIRRUS_5436 0x00ac +#define PCIR_DEVICE_CIRRUS_5446 0x00b8 +#define PCIR_DEVICE_CIRRUS_5480 0x00bc +#define PCIR_DEVICE_CIRRUS_5464 0x00d4 +#define PCIR_DEVICE_CIRRUS_5465 0x00d6 +#define PCIR_DEVICE_CIRRUS_6729 0x1100 +#define PCIR_DEVICE_CIRRUS_6832 0x1110 +#define PCIR_DEVICE_CIRRUS_7542 0x1200 +#define PCIR_DEVICE_CIRRUS_7543 0x1202 +#define PCIR_DEVICE_CIRRUS_7541 0x1204 + +#define PCIR_VENDOR_IBM 0x1014 +#define PCIR_DEVICE_IBM_FIRE_CORAL 0x000a +#define PCIR_DEVICE_IBM_TR 0x0018 +#define PCIR_DEVICE_IBM_82G2675 0x001d +#define PCIR_DEVICE_IBM_MCA 0x0020 +#define PCIR_DEVICE_IBM_82351 0x0022 +#define PCIR_DEVICE_IBM_SERVERAID 0x002e +#define PCIR_DEVICE_IBM_TR_WAKE 0x003e +#define PCIR_DEVICE_IBM_MPIC 0x0046 +#define PCIR_DEVICE_IBM_3780IDSP 0x007d +#define PCIR_DEVICE_IBM_MPIC_2 0xffff + +#define PCIR_VENDOR_WD 0x101c +#define PCIR_DEVICE_WD_7197 0x3296 + +#define PCIR_VENDOR_AMD 0x1022 +#define PCIR_DEVICE_AMD_LANCE 0x2000 +#define PCIR_DEVICE_AMD_SCSI 0x2020 + +#define PCIR_VENDOR_TRIDENT 0x1023 +#define PCIR_DEVICE_TRIDENT_9397 0x9397 +#define PCIR_DEVICE_TRIDENT_9420 0x9420 +#define PCIR_DEVICE_TRIDENT_9440 0x9440 +#define PCIR_DEVICE_TRIDENT_9660 0x9660 +#define PCIR_DEVICE_TRIDENT_9750 0x9750 + +#define PCIR_VENDOR_AI 0x1025 +#define PCIR_DEVICE_AI_M1435 0x1435 + +#define PCIR_VENDOR_MATROX 0x102B +#define PCIR_DEVICE_MATROX_MGA_2 0x0518 +#define PCIR_DEVICE_MATROX_MIL 0x0519 +#define PCIR_DEVICE_MATROX_MYS 0x051A +#define PCIR_DEVICE_MATROX_MIL_2 0x051b +#define PCIR_DEVICE_MATROX_MIL_2_AGP 0x051f +#define PCIR_DEVICE_MATROX_MGA_IMP 0x0d10 + +#define PCIR_VENDOR_CT 0x102c +#define PCIR_DEVICE_CT_65545 0x00d8 +#define PCIR_DEVICE_CT_65548 0x00dc +#define PCIR_DEVICE_CT_65550 0x00e0 +#define PCIR_DEVICE_CT_65554 0x00e4 +#define PCIR_DEVICE_CT_65555 0x00e5 + +#define PCIR_VENDOR_MIRO 0x1031 +#define PCIR_DEVICE_MIRO_36050 0x5601 + +#define PCIR_VENDOR_NEC 0x1033 +#define PCIR_DEVICE_NEC_PCX2 0x0046 + +#define PCIR_VENDOR_FD 0x1036 +#define PCIR_DEVICE_FD_36C70 0x0000 + +#define PCIR_VENDOR_SI 0x1039 +#define PCIR_DEVICE_SI_5591_AGP 0x0001 +#define PCIR_DEVICE_SI_6202 0x0002 +#define PCIR_DEVICE_SI_503 0x0008 +#define PCIR_DEVICE_SI_ACPI 0x0009 +#define PCIR_DEVICE_SI_5597_VGA 0x0200 +#define PCIR_DEVICE_SI_6205 0x0205 +#define PCIR_DEVICE_SI_501 0x0406 +#define PCIR_DEVICE_SI_496 0x0496 +#define PCIR_DEVICE_SI_601 0x0601 +#define PCIR_DEVICE_SI_5107 0x5107 +#define PCIR_DEVICE_SI_5511 0x5511 +#define PCIR_DEVICE_SI_5513 0x5513 +#define PCIR_DEVICE_SI_5571 0x5571 +#define PCIR_DEVICE_SI_5591 0x5591 +#define PCIR_DEVICE_SI_5597 0x5597 +#define PCIR_DEVICE_SI_7001 0x7001 + +#define PCIR_VENDOR_HP 0x103c +#define PCIR_DEVICE_HP_J2585A 0x1030 +#define PCIR_DEVICE_HP_J2585B 0x1031 + +#define PCIR_VENDOR_PCTECH 0x1042 +#define PCIR_DEVICE_PCTECH_RZ1000 0x1000 +#define PCIR_DEVICE_PCTECH_RZ1001 0x1001 +#define PCIR_DEVICE_PCTECH_SAMURAI_0 0x3000 +#define PCIR_DEVICE_PCTECH_SAMURAI_1 0x3010 +#define PCIR_DEVICE_PCTECH_SAMURAI_IDE 0x3020 + +#define PCIR_VENDOR_DPT 0x1044 +#define PCIR_DEVICE_DPT 0xa400 + +#define PCIR_VENDOR_OPTI 0x1045 +#define PCIR_DEVICE_OPTI_92C178 0xc178 +#define PCIR_DEVICE_OPTI_82C557 0xc557 +#define PCIR_DEVICE_OPTI_82C558 0xc558 +#define PCIR_DEVICE_OPTI_82C621 0xc621 +#define PCIR_DEVICE_OPTI_82C700 0xc700 +#define PCIR_DEVICE_OPTI_82C701 0xc701 +#define PCIR_DEVICE_OPTI_82C814 0xc814 +#define PCIR_DEVICE_OPTI_82C822 0xc822 +#define PCIR_DEVICE_OPTI_82C825 0xd568 + +#define PCIR_VENDOR_SGS 0x104a +#define PCIR_DEVICE_SGS_2000 0x0008 +#define PCIR_DEVICE_SGS_1764 0x0009 + +#define PCIR_VENDOR_BUSLOGIC 0x104B +#define PCIR_DEVICE_BUSLOGIC_MULTIMASTER_NC 0x0140 +#define PCIR_DEVICE_BUSLOGIC_MULTIMASTER 0x1040 +#define PCIR_DEVICE_BUSLOGIC_FLASHPOINT 0x8130 + +#define PCIR_VENDOR_TI 0x104c +#define PCIR_DEVICE_TI_TVP4010 0x3d04 +#define PCIR_DEVICE_TI_TVP4020 0x3d07 +#define PCIR_DEVICE_TI_PCI1130 0xac12 +#define PCIR_DEVICE_TI_PCI1031 0xac13 +#define PCIR_DEVICE_TI_PCI1131 0xac15 +#define PCIR_DEVICE_TI_PCI1250 0xac16 +#define PCIR_DEVICE_TI_PCI1220 0xac17 + +#define PCIR_VENDOR_OAK 0x104e +#define PCIR_DEVICE_OAK_OTI107 0x0107 + +/* Winbond have two vendor IDs! See 0x10ad as well */ +#define PCIR_VENDOR_WINBOND2 0x1050 +#define PCIR_DEVICE_WINBOND2_89C940 0x0940 + +#define PCIR_VENDOR_MOTOROLA 0x1057 +#define PCIR_DEVICE_MOTOROLA_MPC105 0x0001 +#define PCIR_DEVICE_MOTOROLA_MPC106 0x0002 +#define PCIR_DEVICE_MOTOROLA_RAVEN 0x4801 + +#define PCIR_VENDOR_PROMISE 0x105a +#define PCIR_DEVICE_PROMISE_20246 0x4d33 +#define PCIR_DEVICE_PROMISE_5300 0x5300 + +#define PCIR_VENDOR_N9 0x105d +#define PCIR_DEVICE_N9_I128 0x2309 +#define PCIR_DEVICE_N9_I128_2 0x2339 +#define PCIR_DEVICE_N9_I128_T2R 0x493d + +#define PCIR_VENDOR_UMC 0x1060 +#define PCIR_DEVICE_UMC_UM8673F 0x0101 +#define PCIR_DEVICE_UMC_UM8891A 0x0891 +#define PCIR_DEVICE_UMC_UM8886BF 0x673a +#define PCIR_DEVICE_UMC_UM8886A 0x886a +#define PCIR_DEVICE_UMC_UM8881F 0x8881 +#define PCIR_DEVICE_UMC_UM8886F 0x8886 +#define PCIR_DEVICE_UMC_UM9017F 0x9017 +#define PCIR_DEVICE_UMC_UM8886N 0xe886 +#define PCIR_DEVICE_UMC_UM8891N 0xe891 + +#define PCIR_VENDOR_X 0x1061 +#define PCIR_DEVICE_X_AGX016 0x0001 + +#define PCIR_VENDOR_PICOP 0x1066 +#define PCIR_DEVICE_PICOP_PT86C52X 0x0001 +#define PCIR_DEVICE_PICOP_PT80C524 0x8002 + +#define PCIR_VENDOR_APPLE 0x106b +#define PCIR_DEVICE_APPLE_BANDIT 0x0001 +#define PCIR_DEVICE_APPLE_GC 0x0002 +#define PCIR_DEVICE_APPLE_HYDRA 0x000e + +#define PCIR_VENDOR_NEXGEN 0x1074 +#define PCIR_DEVICE_NEXGEN_82C501 0x4e78 + +#define PCIR_VENDOR_QLOGIC 0x1077 +#define PCIR_DEVICE_QLOGIC_ISP1020 0x1020 +#define PCIR_DEVICE_QLOGIC_ISP1022 0x1022 + +#define PCIR_VENDOR_CYRIX 0x1078 +#define PCIR_DEVICE_CYRIX_5510 0x0000 +#define PCIR_DEVICE_CYRIX_PCI_MASTER 0x0001 +#define PCIR_DEVICE_CYRIX_5520 0x0002 +#define PCIR_DEVICE_CYRIX_5530_LEGACY 0x0100 +#define PCIR_DEVICE_CYRIX_5530_SMI 0x0101 +#define PCIR_DEVICE_CYRIX_5530_IDE 0x0102 +#define PCIR_DEVICE_CYRIX_5530_AUDIO 0x0103 +#define PCIR_DEVICE_CYRIX_5530_VIDEO 0x0104 + +#define PCIR_VENDOR_LEADTEK 0x107d +#define PCIR_DEVICE_LEADTEK_805 0x0000 + +#define PCIR_VENDOR_CONTAQ 0x1080 +#define PCIR_DEVICE_CONTAQ_82C599 0x0600 +#define PCIR_DEVICE_CONTAQ_82C693 0xc693 + +#define PCIR_VENDOR_FOREX 0x1083 + +#define PCIR_VENDOR_OLICOM 0x108d +#define PCIR_DEVICE_OLICOM_OC3136 0x0001 +#define PCIR_DEVICE_OLICOM_OC2315 0x0011 +#define PCIR_DEVICE_OLICOM_OC2325 0x0012 +#define PCIR_DEVICE_OLICOM_OC2183 0x0013 +#define PCIR_DEVICE_OLICOM_OC2326 0x0014 +#define PCIR_DEVICE_OLICOM_OC6151 0x0021 + +#define PCIR_VENDOR_SUN 0x108e +#define PCIR_DEVICE_SUN_EBUS 0x1000 +#define PCIR_DEVICE_SUN_HAPPYMEAL 0x1001 +#define PCIR_DEVICE_SUN_SIMBA 0x5000 +#define PCIR_DEVICE_SUN_PBM 0x8000 +#define PCIR_DEVICE_SUN_SABRE 0xa000 + +#define PCIR_VENDOR_CMD 0x1095 +#define PCIR_DEVICE_CMD_640 0x0640 +#define PCIR_DEVICE_CMD_643 0x0643 +#define PCIR_DEVICE_CMD_646 0x0646 +#define PCIR_DEVICE_CMD_647 0x0647 +#define PCIR_DEVICE_CMD_670 0x0670 + +#define PCIR_VENDOR_VISION 0x1098 +#define PCIR_DEVICE_VISION_QD8500 0x0001 +#define PCIR_DEVICE_VISION_QD8580 0x0002 + +#define PCIR_VENDOR_BROOKTREE 0x109e +#define PCIR_DEVICE_BROOKTREE_848 0x0350 +#define PCIR_DEVICE_BROOKTREE_849A 0x0351 +#define PCIR_DEVICE_BROOKTREE_8474 0x8474 + +#define PCIR_VENDOR_SIERRA 0x10a8 +#define PCIR_DEVICE_SIERRA_STB 0x0000 + +#define PCIR_VENDOR_ACC 0x10aa +#define PCIR_DEVICE_ACC_2056 0x0000 + +#define PCIR_VENDOR_WINBOND 0x10ad +#define PCIR_DEVICE_WINBOND_83769 0x0001 +#define PCIR_DEVICE_WINBOND_82C105 0x0105 +#define PCIR_DEVICE_WINBOND_83C553 0x0565 + +#define PCIR_VENDOR_DATABOOK 0x10b3 +#define PCIR_DEVICE_DATABOOK_87144 0xb106 + +#define PCIR_VENDOR_PLX 0x10b5 +#define PCIR_DEVICE_PLX_9050 0x9050 +#define PCIR_DEVICE_PLX_9060 0x9060 +#define PCIR_DEVICE_PLX_9060ES 0x906E +#define PCIR_DEVICE_PLX_9060SD 0x906D +#define PCIR_DEVICE_PLX_9080 0x9080 + +#define PCIR_VENDOR_MADGE 0x10b6 +#define PCIR_DEVICE_MADGE_MK2 0x0002 +#define PCIR_DEVICE_MADGE_C155S 0x1001 + +#define PCIR_VENDOR_3COM 0x10b7 +#define PCIR_DEVICE_3COM_3C339 0x3390 +#define PCIR_DEVICE_3COM_3C590 0x5900 +#define PCIR_DEVICE_3COM_3C595TX 0x5950 +#define PCIR_DEVICE_3COM_3C595T4 0x5951 +#define PCIR_DEVICE_3COM_3C595MII 0x5952 +#define PCIR_DEVICE_3COM_3C900TPO 0x9000 +#define PCIR_DEVICE_3COM_3C900COMBO 0x9001 +#define PCIR_DEVICE_3COM_3C905TX 0x9050 +#define PCIR_DEVICE_3COM_3C905T4 0x9051 +#define PCIR_DEVICE_3COM_3C905B_TX 0x9055 + +#define PCIR_VENDOR_SMC 0x10b8 +#define PCIR_DEVICE_SMC_EPIC100 0x0005 + +#define PCIR_VENDOR_AL 0x10b9 +#define PCIR_DEVICE_AL_M1445 0x1445 +#define PCIR_DEVICE_AL_M1449 0x1449 +#define PCIR_DEVICE_AL_M1451 0x1451 +#define PCIR_DEVICE_AL_M1461 0x1461 +#define PCIR_DEVICE_AL_M1489 0x1489 +#define PCIR_DEVICE_AL_M1511 0x1511 +#define PCIR_DEVICE_AL_M1513 0x1513 +#define PCIR_DEVICE_AL_M1521 0x1521 +#define PCIR_DEVICE_AL_M1523 0x1523 +#define PCIR_DEVICE_AL_M1531 0x1531 +#define PCIR_DEVICE_AL_M1533 0x1533 +#define PCIR_DEVICE_AL_M3307 0x3307 +#define PCIR_DEVICE_AL_M4803 0x5215 +#define PCIR_DEVICE_AL_M5219 0x5219 +#define PCIR_DEVICE_AL_M5229 0x5229 +#define PCIR_DEVICE_AL_M5237 0x5237 +#define PCIR_DEVICE_AL_M7101 0x7101 + +#define PCIR_VENDOR_MITSUBISHI 0x10ba + +#define PCIR_VENDOR_SURECOM 0x10bd +#define PCIR_DEVICE_SURECOM_NE34 0x0e34 + +#define PCIR_VENDOR_NEOMAGIC 0x10c8 +#define PCIR_DEVICE_NEOMAGIC_MAGICGRAPH_NM2070 0x0001 +#define PCIR_DEVICE_NEOMAGIC_MAGICGRAPH_128V 0x0002 +#define PCIR_DEVICE_NEOMAGIC_MAGICGRAPH_128ZV 0x0003 +#define PCIR_DEVICE_NEOMAGIC_MAGICGRAPH_NM2160 0x0004 + +#define PCIR_VENDOR_ASP 0x10cd +#define PCIR_DEVICE_ASP_ABP940 0x1200 +#define PCIR_DEVICE_ASP_ABP940U 0x1300 +#define PCIR_DEVICE_ASP_ABP940UW 0x2300 + +#define PCIR_VENDOR_MACRONIX 0x10d9 +#define PCIR_DEVICE_MACRONIX_MX98713 0x0512 +#define PCIR_DEVICE_MACRONIX_MX987x5 0x0531 + +#define PCIR_VENDOR_CERN 0x10dc +#define PCIR_DEVICE_CERN_SPSB_PMC 0x0001 +#define PCIR_DEVICE_CERN_SPSB_PCI 0x0002 +#define PCIR_DEVICE_CERN_HIPPI_DST 0x0021 +#define PCIR_DEVICE_CERN_HIPPI_SRC 0x0022 + +#define PCIR_VENDOR_NVIDIA 0x10de + +#define PCIR_VENDOR_IMS 0x10e0 +#define PCIR_DEVICE_IMS_8849 0x8849 + +#define PCIR_VENDOR_TEKRAM2 0x10e1 +#define PCIR_DEVICE_TEKRAM2_690c 0x690c + +#define PCIR_VENDOR_TUNDRA 0x10e3 +#define PCIR_DEVICE_TUNDRA_CA91C042 0x0000 + +#define PCIR_VENDOR_AMCC 0x10e8 +#define PCIR_DEVICE_AMCC_MYRINET 0x8043 +#define PCIR_DEVICE_AMCC_PARASTATION 0x8062 +#define PCIR_DEVICE_AMCC_S5933 0x807d +#define PCIR_DEVICE_AMCC_S5933_HEPC3 0x809c + +#define PCIR_VENDOR_INTERG 0x10ea +#define PCIR_DEVICE_INTERG_1680 0x1680 +#define PCIR_DEVICE_INTERG_1682 0x1682 + +#define PCIR_VENDOR_REALTEK 0x10ec +#define PCIR_DEVICE_REALTEK_8029 0x8029 +#define PCIR_DEVICE_REALTEK_8129 0x8129 +#define PCIR_DEVICE_REALTEK_8139 0x8139 + +#define PCIR_VENDOR_TRUEVISION 0x10fa +#define PCIR_DEVICE_TRUEVISION_T1000 0x000c + +#define PCIR_VENDOR_INIT 0x1101 +#define PCIR_DEVICE_INIT_320P 0x9100 +#define PCIR_DEVICE_INIT_360P 0x9500 + +#define PCIR_VENDOR_TTI 0x1103 +#define PCIR_DEVICE_TTI_HPT343 0x0003 + +#define PCIR_VENDOR_VIA 0x1106 +#define PCIR_DEVICE_VIA_82C505 0x0505 +#define PCIR_DEVICE_VIA_82C561 0x0561 +#define PCIR_DEVICE_VIA_82C586_1 0x0571 +#define PCIR_DEVICE_VIA_82C576 0x0576 +#define PCIR_DEVICE_VIA_82C585 0x0585 +#define PCIR_DEVICE_VIA_82C586_0 0x0586 +#define PCIR_DEVICE_VIA_82C595 0x0595 +#define PCIR_DEVICE_VIA_82C597_0 0x0597 +#define PCIR_DEVICE_VIA_82C926 0x0926 +#define PCIR_DEVICE_VIA_82C416 0x1571 +#define PCIR_DEVICE_VIA_82C595_97 0x1595 +#define PCIR_DEVICE_VIA_82C586_2 0x3038 +#define PCIR_DEVICE_VIA_82C586_3 0x3040 +#define PCIR_DEVICE_VIA_86C100A 0x6100 +#define PCIR_DEVICE_VIA_82C597_1 0x8597 + +#define PCIR_VENDOR_VORTEX 0x1119 +#define PCIR_DEVICE_VORTEX_GDT60x0 0x0000 +#define PCIR_DEVICE_VORTEX_GDT6000B 0x0001 +#define PCIR_DEVICE_VORTEX_GDT6x10 0x0002 +#define PCIR_DEVICE_VORTEX_GDT6x20 0x0003 +#define PCIR_DEVICE_VORTEX_GDT6530 0x0004 +#define PCIR_DEVICE_VORTEX_GDT6550 0x0005 +#define PCIR_DEVICE_VORTEX_GDT6x17 0x0006 +#define PCIR_DEVICE_VORTEX_GDT6x27 0x0007 +#define PCIR_DEVICE_VORTEX_GDT6537 0x0008 +#define PCIR_DEVICE_VORTEX_GDT6557 0x0009 +#define PCIR_DEVICE_VORTEX_GDT6x15 0x000a +#define PCIR_DEVICE_VORTEX_GDT6x25 0x000b +#define PCIR_DEVICE_VORTEX_GDT6535 0x000c +#define PCIR_DEVICE_VORTEX_GDT6555 0x000d +#define PCIR_DEVICE_VORTEX_GDT6x17RP 0x0100 +#define PCIR_DEVICE_VORTEX_GDT6x27RP 0x0101 +#define PCIR_DEVICE_VORTEX_GDT6537RP 0x0102 +#define PCIR_DEVICE_VORTEX_GDT6557RP 0x0103 +#define PCIR_DEVICE_VORTEX_GDT6x11RP 0x0104 +#define PCIR_DEVICE_VORTEX_GDT6x21RP 0x0105 +#define PCIR_DEVICE_VORTEX_GDT6x17RP1 0x0110 +#define PCIR_DEVICE_VORTEX_GDT6x27RP1 0x0111 +#define PCIR_DEVICE_VORTEX_GDT6537RP1 0x0112 +#define PCIR_DEVICE_VORTEX_GDT6557RP1 0x0113 +#define PCIR_DEVICE_VORTEX_GDT6x11RP1 0x0114 +#define PCIR_DEVICE_VORTEX_GDT6x21RP1 0x0115 +#define PCIR_DEVICE_VORTEX_GDT6x17RP2 0x0120 +#define PCIR_DEVICE_VORTEX_GDT6x27RP2 0x0121 +#define PCIR_DEVICE_VORTEX_GDT6537RP2 0x0122 +#define PCIR_DEVICE_VORTEX_GDT6557RP2 0x0123 +#define PCIR_DEVICE_VORTEX_GDT6x11RP2 0x0124 +#define PCIR_DEVICE_VORTEX_GDT6x21RP2 0x0125 + +#define PCIR_VENDOR_EF 0x111a +#define PCIR_DEVICE_EF_ATM_FPGA 0x0000 +#define PCIR_DEVICE_EF_ATM_ASIC 0x0002 + +#define PCIR_VENDOR_FORE 0x1127 +#define PCIR_DEVICE_FORE_PCA200PC 0x0210 +#define PCIR_DEVICE_FORE_PCA200E 0x0300 + +#define PCIR_VENDOR_IMAGINGTECH 0x112f +#define PCIR_DEVICE_IMAGINGTECH_ICPCI 0x0000 + +#define PCIR_VENDOR_PHILIPS 0x1131 +#define PCIR_DEVICE_PHILIPS_SAA7145 0x7145 +#define PCIR_DEVICE_PHILIPS_SAA7146 0x7146 + +#define PCIR_VENDOR_CYCLONE 0x113c +#define PCIR_DEVICE_CYCLONE_SDK 0x0001 + +#define PCIR_VENDOR_ALLIANCE 0x1142 +#define PCIR_DEVICE_ALLIANCE_PROMOTIO 0x3210 +#define PCIR_DEVICE_ALLIANCE_PROVIDEO 0x6422 +#define PCIR_DEVICE_ALLIANCE_AT24 0x6424 +#define PCIR_DEVICE_ALLIANCE_AT3D 0x643d + +#define PCIR_VENDOR_SK 0x1148 +#define PCIR_DEVICE_SK_FP 0x4000 +#define PCIR_DEVICE_SK_TR 0x4200 +#define PCIR_DEVICE_SK_GE 0x4300 + +#define PCIR_VENDOR_VMIC 0x114a +#define PCIR_DEVICE_VMIC_VME 0x7587 + +#define PCIR_VENDOR_DIGI 0x114f +#define PCIR_DEVICE_DIGI_EPC 0x0002 +#define PCIR_DEVICE_DIGI_RIGHTSWITCH 0x0003 +#define PCIR_DEVICE_DIGI_XEM 0x0004 +#define PCIR_DEVICE_DIGI_XR 0x0005 +#define PCIR_DEVICE_DIGI_CX 0x0006 +#define PCIR_DEVICE_DIGI_XRJ 0x0009 +#define PCIR_DEVICE_DIGI_EPCJ 0x000a +#define PCIR_DEVICE_DIGI_XR_920 0x0027 + +#define PCIR_VENDOR_MUTECH 0x1159 +#define PCIR_DEVICE_MUTECH_MV1000 0x0001 + +#define PCIR_VENDOR_RENDITION 0x1163 +#define PCIR_DEVICE_RENDITION_VERITE 0x0001 +#define PCIR_DEVICE_RENDITION_VERITE2100 0x2000 + +#define PCIR_VENDOR_TOSHIBA 0x1179 +#define PCIR_DEVICE_TOSHIBA_601 0x0601 +#define PCIR_DEVICE_TOSHIBA_TOPIC95 0x060a +#define PCIR_DEVICE_TOSHIBA_TOPIC97 0x060f + +#define PCIR_VENDOR_RICOH 0x1180 +#define PCIR_DEVICE_RICOH_RL5C465 0x0465 +#define PCIR_DEVICE_RICOH_RL5C466 0x0466 +#define PCIR_DEVICE_RICOH_RL5C475 0x0475 +#define PCIR_DEVICE_RICOH_RL5C478 0x0478 + +#define PCIR_VENDOR_ARTOP 0x1191 +#define PCIR_DEVICE_ARTOP_ATP8400 0x0004 +#define PCIR_DEVICE_ARTOP_ATP850UF 0x0005 + +#define PCIR_VENDOR_ZEITNET 0x1193 +#define PCIR_DEVICE_ZEITNET_1221 0x0001 +#define PCIR_DEVICE_ZEITNET_1225 0x0002 + +#define PCIR_VENDOR_OMEGA 0x119b +#define PCIR_DEVICE_OMEGA_82C092G 0x1221 + +#define PCIR_VENDOR_LITEON 0x11ad +#define PCIR_DEVICE_LITEON_LNE100TX 0x0002 + +#define PCIR_VENDOR_NP 0x11bc +#define PCIR_DEVICE_NP_PCI_FDDI 0x0001 + +#define PCIR_VENDOR_ATT 0x11c1 +#define PCIR_DEVICE_ATT_L56XMF 0x0440 + +#define PCIR_VENDOR_SPECIALIX 0x11cb +#define PCIR_DEVICE_SPECIALIX_IO8 0x2000 +#define PCIR_DEVICE_SPECIALIX_XIO 0x4000 +#define PCIR_DEVICE_SPECIALIX_RIO 0x8000 + +#define PCIR_VENDOR_AURAVISION 0x11d1 +#define PCIR_DEVICE_AURAVISION_VXP524 0x01f7 + +#define PCIR_VENDOR_IKON 0x11d5 +#define PCIR_DEVICE_IKON_10115 0x0115 +#define PCIR_DEVICE_IKON_10117 0x0117 + +#define PCIR_VENDOR_ZORAN 0x11de +#define PCIR_DEVICE_ZORAN_36057 0x6057 +#define PCIR_DEVICE_ZORAN_36120 0x6120 + +#define PCIR_VENDOR_KINETIC 0x11f4 +#define PCIR_DEVICE_KINETIC_2915 0x2915 + +#define PCIR_VENDOR_COMPEX 0x11f6 +#define PCIR_DEVICE_COMPEX_ENET100VG4 0x0112 +#define PCIR_DEVICE_COMPEX_RL2000 0x1401 + +#define PCIR_VENDOR_RP 0x11fe +#define PCIR_DEVICE_RP32INTF 0x0001 +#define PCIR_DEVICE_RP8INTF 0x0002 +#define PCIR_DEVICE_RP16INTF 0x0003 +#define PCIR_DEVICE_RP4QUAD 0x0004 +#define PCIR_DEVICE_RP8OCTA 0x0005 +#define PCIR_DEVICE_RP8J 0x0006 +#define PCIR_DEVICE_RPP4 0x000A +#define PCIR_DEVICE_RPP8 0x000B +#define PCIR_DEVICE_RP8M 0x000C + +#define PCIR_VENDOR_CYCLADES 0x120e +#define PCIR_DEVICE_CYCLOM_Y_Lo 0x0100 +#define PCIR_DEVICE_CYCLOM_Y_Hi 0x0101 +#define PCIR_DEVICE_CYCLOM_Z_Lo 0x0200 +#define PCIR_DEVICE_CYCLOM_Z_Hi 0x0201 + +#define PCIR_VENDOR_ESSENTIAL 0x120f +#define PCIR_DEVICE_ESSENTIAL_ROADRUNNER 0x0001 + +#define PCIR_VENDOR_O2 0x1217 +#define PCIR_DEVICE_O2_6729 0x6729 +#define PCIR_DEVICE_O2_6730 0x673a +#define PCIR_DEVICE_O2_6832 0x6832 +#define PCIR_DEVICE_O2_6836 0x6836 + +#define PCIR_VENDOR_3DFX 0x121a +#define PCIR_DEVICE_3DFX_VOODOO 0x0001 +#define PCIR_DEVICE_3DFX_VOODOO2 0x0002 + +#define PCIR_VENDOR_SIGMADES 0x1236 +#define PCIR_DEVICE_SIGMADES_6425 0x6401 + +#define PCIR_VENDOR_CCUBE 0x123f + +#define PCIR_VENDOR_DIPIX 0x1246 + +#define PCIR_VENDOR_STALLION 0x124d +#define PCIR_DEVICE_STALLION_ECHPCI832 0x0000 +#define PCIR_DEVICE_STALLION_ECHPCI864 0x0002 +#define PCIR_DEVICE_STALLION_EIOPCI 0x0003 + +#define PCIR_VENDOR_OPTIBASE 0x1255 +#define PCIR_DEVICE_OPTIBASE_FORGE 0x1110 +#define PCIR_DEVICE_OPTIBASE_FUSION 0x1210 +#define PCIR_DEVICE_OPTIBASE_VPLEX 0x2110 +#define PCIR_DEVICE_OPTIBASE_VPLEXCC 0x2120 +#define PCIR_DEVICE_OPTIBASE_VQUEST 0x2130 + +#define PCIR_VENDOR_SATSAGEM 0x1267 +#define PCIR_DEVICE_SATSAGEM_PCR2101 0x5352 +#define PCIR_DEVICE_SATSAGEM_TELSATTURBO 0x5a4b + +#define PCIR_VENDOR_HUGHES 0x1273 +#define PCIR_DEVICE_HUGHES_DIRECPC 0x0002 + +#define PCIR_VENDOR_ENSONIQ 0x1274 +#define PCIR_DEVICE_ENSONIQ_AUDIOPCI 0x5000 + +#define PCIR_VENDOR_ALTEON 0x12ae +#define PCIR_DEVICE_ALTEON_ACENIC 0x0001 + +#define PCIR_VENDOR_PICTUREL 0x12c5 +#define PCIR_DEVICE_PICTUREL_PCIVST 0x0081 + +#define PCIR_VENDOR_NVIDIA_SGS 0x12d2 +#define PCIR_DEVICE_NVIDIA_SGS_RIVA128 0x0018 + +#define PCIR_VENDOR_CBOARDS 0x1307 +#define PCIR_DEVICE_CBOARDS_DAS1602_16 0x0001 + +#define PCIR_VENDOR_SYMPHONY 0x1c1c +#define PCIR_DEVICE_SYMPHONY_101 0x0001 + +#define PCIR_VENDOR_TEKRAM 0x1de1 +#define PCIR_DEVICE_TEKRAM_DC290 0xdc29 + +#define PCIR_VENDOR_3DLABS 0x3d3d +#define PCIR_DEVICE_3DLABS_300SX 0x0001 +#define PCIR_DEVICE_3DLABS_500TX 0x0002 +#define PCIR_DEVICE_3DLABS_DELTA 0x0003 +#define PCIR_DEVICE_3DLABS_PERMEDIA 0x0004 +#define PCIR_DEVICE_3DLABS_MX 0x0006 + +#define PCIR_VENDOR_AVANCE 0x4005 +#define PCIR_DEVICE_AVANCE_ALG2064 0x2064 +#define PCIR_DEVICE_AVANCE_2302 0x2302 + +#define PCIR_VENDOR_NETVIN 0x4a14 +#define PCIR_DEVICE_NETVIN_NV5000SC 0x5000 + +#define PCIR_VENDOR_S3 0x5333 +#define PCIR_DEVICE_S3_PLATO_PXS 0x0551 +#define PCIR_DEVICE_S3_ViRGE 0x5631 +#define PCIR_DEVICE_S3_TRIO 0x8811 +#define PCIR_DEVICE_S3_AURORA64VP 0x8812 +#define PCIR_DEVICE_S3_TRIO64UVP 0x8814 +#define PCIR_DEVICE_S3_ViRGE_VX 0x883d +#define PCIR_DEVICE_S3_868 0x8880 +#define PCIR_DEVICE_S3_928 0x88b0 +#define PCIR_DEVICE_S3_864_1 0x88c0 +#define PCIR_DEVICE_S3_864_2 0x88c1 +#define PCIR_DEVICE_S3_964_1 0x88d0 +#define PCIR_DEVICE_S3_964_2 0x88d1 +#define PCIR_DEVICE_S3_968 0x88f0 +#define PCIR_DEVICE_S3_TRIO64V2 0x8901 +#define PCIR_DEVICE_S3_PLATO_PXG 0x8902 +#define PCIR_DEVICE_S3_ViRGE_DXGX 0x8a01 +#define PCIR_DEVICE_S3_ViRGE_GX2 0x8a10 +#define PCIR_DEVICE_S3_ViRGE_MX 0x8c01 +#define PCIR_DEVICE_S3_ViRGE_MXP 0x8c02 +#define PCIR_DEVICE_S3_ViRGE_MXPMV 0x8c03 +#define PCIR_DEVICE_S3_SONICVIBES 0xca00 + +#define PCIR_VENDOR_INTEL 0x8086 +#define PCIR_DEVICE_INTEL_82375 0x0482 +#define PCIR_DEVICE_INTEL_82424 0x0483 +#define PCIR_DEVICE_INTEL_82378 0x0484 +#define PCIR_DEVICE_INTEL_82430 0x0486 +#define PCIR_DEVICE_INTEL_82434 0x04a3 +#define PCIR_DEVICE_INTEL_82092AA_0 0x1221 +#define PCIR_DEVICE_INTEL_82092AA_1 0x1222 +#define PCIR_DEVICE_INTEL_7116 0x1223 +#define PCIR_DEVICE_INTEL_82596 0x1226 +#define PCIR_DEVICE_INTEL_82865 0x1227 +#define PCIR_DEVICE_INTEL_82557 0x1229 +#define PCIR_DEVICE_INTEL_82437 0x122d +#define PCIR_DEVICE_INTEL_82371FB_0 0x122e +#define PCIR_DEVICE_INTEL_82371FB_1 0x1230 +#define PCIR_DEVICE_INTEL_82371MX 0x1234 +#define PCIR_DEVICE_INTEL_82437MX 0x1235 +#define PCIR_DEVICE_INTEL_82441 0x1237 +#define PCIR_DEVICE_INTEL_82380FB 0x124b +#define PCIR_DEVICE_INTEL_82439 0x1250 +#define PCIR_DEVICE_INTEL_82371SB_0 0x7000 +#define PCIR_DEVICE_INTEL_82371SB_1 0x7010 +#define PCIR_DEVICE_INTEL_82371SB_2 0x7020 +#define PCIR_DEVICE_INTEL_82437VX 0x7030 +#define PCIR_DEVICE_INTEL_82439TX 0x7100 +#define PCIR_DEVICE_INTEL_82371AB_0 0x7110 +#define PCIR_DEVICE_INTEL_82371AB 0x7111 +#define PCIR_DEVICE_INTEL_82371AB_2 0x7112 +#define PCIR_DEVICE_INTEL_82371AB_3 0x7113 +#define PCIR_DEVICE_INTEL_82443LX_0 0x7180 +#define PCIR_DEVICE_INTEL_82443LX_1 0x7181 +#define PCIR_DEVICE_INTEL_82443BX_0 0x7190 +#define PCIR_DEVICE_INTEL_82443BX_1 0x7191 +#define PCIR_DEVICE_INTEL_82443BX_2 0x7192 +#define PCIR_DEVICE_INTEL_P6 0x84c4 +#define PCIR_DEVICE_INTEL_82450GX 0x84c5 + +#define PCIR_VENDOR_KTI 0x8e2e +#define PCIR_DEVICE_KTI_ET32P2 0x3000 + +#define PCIR_VENDOR_ADAPTEC 0x9004 +#define PCIR_DEVICE_ADAPTEC_7810 0x1078 +#define PCIR_DEVICE_ADAPTEC_7850 0x5078 +#define PCIR_DEVICE_ADAPTEC_7855 0x5578 +#define PCIR_DEVICE_ADAPTEC_5800 0x5800 +#define PCIR_DEVICE_ADAPTEC_1480A 0x6075 +#define PCIR_DEVICE_ADAPTEC_7860 0x6078 +#define PCIR_DEVICE_ADAPTEC_7861 0x6178 +#define PCIR_DEVICE_ADAPTEC_7870 0x7078 +#define PCIR_DEVICE_ADAPTEC_7871 0x7178 +#define PCIR_DEVICE_ADAPTEC_7872 0x7278 +#define PCIR_DEVICE_ADAPTEC_7873 0x7378 +#define PCIR_DEVICE_ADAPTEC_7874 0x7478 +#define PCIR_DEVICE_ADAPTEC_7895 0x7895 +#define PCIR_DEVICE_ADAPTEC_7880 0x8078 +#define PCIR_DEVICE_ADAPTEC_7881 0x8178 +#define PCIR_DEVICE_ADAPTEC_7882 0x8278 +#define PCIR_DEVICE_ADAPTEC_7883 0x8378 +#define PCIR_DEVICE_ADAPTEC_7884 0x8478 +#define PCIR_DEVICE_ADAPTEC_1030 0x8b78 + +#define PCIR_VENDOR_ADAPTEC2 0x9005 +#define PCIR_DEVICE_ADAPTEC2_2940U2 0x0010 +#define PCIR_DEVICE_ADAPTEC2_7890 0x001f +#define PCIR_DEVICE_ADAPTEC2_3940U2 0x0050 +#define PCIR_DEVICE_ADAPTEC2_7896 0x005f + +#define PCIR_VENDOR_ATRONICS 0x907f +#define PCIR_DEVICE_ATRONICS_2015 0x2015 + +#define PCIR_VENDOR_HOLTEK 0x9412 +#define PCIR_DEVICE_HOLTEK_6565 0x6565 + +#define PCIR_VENDOR_TIGERJET 0xe159 +#define PCIR_DEVICE_TIGERJET_300 0x0001 + +#define PCIR_VENDOR_ARK 0xedd8 +#define PCIR_DEVICE_ARK_STING 0xa091 +#define PCIR_DEVICE_ARK_STINGARK 0xa099 +#define PCIR_DEVICE_ARK_2000MT 0xa0a1 + +#endif /* !__PCI_IDS_H__ */ diff --git a/cpukit/include/pci/ids_extra.h b/cpukit/include/pci/ids_extra.h new file mode 100644 index 0000000000..0b85fe2764 --- /dev/null +++ b/cpukit/include/pci/ids_extra.h @@ -0,0 +1,22 @@ +/* RTEMS local PCI data base */ + +/* Only included from pci_ids.h */ +#ifndef __PCI_IDS_H__ +#error pci/ids_extra.h should only be included from pci/ids.h +#endif + +/* Gaisler PCI IDs */ +#define PCIID_VENDOR_GAISLER 0x1AC8 +#define PCIID_VENDOR_GAISLER_OLD 0x16E3 + +/* Gaisler PCI Devices */ +#define PCIID_DEVICE_GR_RASTA_IO 0x0010 /* GR-RASTA-IO */ +#define PCIID_DEVICE_GR_RASTA_IO_OLD 0x0210 /* old GR-RASTA-IO ID*/ +#define PCIID_DEVICE_GR_RASTA_TMTC 0x0011 /* GR-RASTA-TMTC */ +#define PCIID_DEVICE_GR_RASTA_ADCDAC 0x0014 /* GR-RASTA-ADCDAC */ +#define PCIID_DEVICE_GR_701 0x0701 /* GR-701 */ +#define PCIID_DEVICE_GR_TMTC_1553 0x0198 /* GR-TMTC-1553 */ +#define PCIID_DEVICE_GR_RASTA_SPW_RTR 0x0062 /* GR-RASTA-SPW-ROUTER */ +#define PCIID_DEVICE_GR_LEON4_N2X 0x0061 /* GR-CPCI-LEON4-N2X */ +#define PCIID_DEVICE_GR_NGMP_PROTO 0x0064 /* GR-NGMP_PROTO */ +#define PCIID_DEVICE_GR_CPCI_GR740 0x0740 /* GR-CPCI-GR740 */ diff --git a/cpukit/include/pci/irq.h b/cpukit/include/pci/irq.h new file mode 100644 index 0000000000..7622201fd6 --- /dev/null +++ b/cpukit/include/pci/irq.h @@ -0,0 +1,118 @@ +/* PCI IRQ Library + * + * COPYRIGHT (c) 2010 Cobham Gaisler AB. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +/* IRQ handling does not have so much with PCI to do, this library depends + * on the BSP to implement shared interrupts. + */ + +#ifndef __PCI_IRQ_H__ +#define __PCI_IRQ_H__ + +#include +#include + +/* + * FIXME: This should be available via the IRQ extensions API. + * + * https://devel.rtems.org/ticket/3269 + */ +void BSP_shared_interrupt_clear(int irq); +void BSP_shared_interrupt_unmask(int irq); +void BSP_shared_interrupt_mask(int irq); + +/* PCI Handler (ISR) called when IRQ is generated by any of the PCI devices + * connected to the same PCI IRQ Pin. This has been defined the same way as + * rtems_interrupt_handler in order for BSPs to "direct-map" the register + * and unregister functions rtems_interrupt_handler_install/remove + */ +typedef void (*pci_isr)(void *arg); + +/* Get assigned system IRQ to a PCI Device. If no IRQ 0 is returned */ +extern int pci_dev_irq(pci_dev_t dev); + +/* Register shared PCI IRQ handler, but does not enable it. The system interrupt + * number is read from the PCI board's PCI configuration space header iline + * field. The iline field is initialized by the PCI subsystem during start up, + * the ipin field is translated into a system IRQ and written to iline. The + * board's driver should use the iline field as the irq argument to this + * function. + * + * Arguments + * irq System IRQ number, normally taken from the PCI configuration area + * isr Function pointer to the ISR + * arg Second argument to function isr + */ +RTEMS_INLINE_ROUTINE int pci_interrupt_register(int irq, const char *info, + pci_isr isr, void *arg) +{ + return rtems_interrupt_handler_install(irq, info, + RTEMS_INTERRUPT_SHARED, isr, + arg); +} + +/* Unregister previously registered shared PCI IRQ handler + * + * Arguments + * irq System IRQ number, normally taken from the PCI configuration area + * isr Function pointer to the ISR + * arg Second argument to function isr + */ +RTEMS_INLINE_ROUTINE int pci_interrupt_unregister(int irq, pci_isr isr, + void *arg) +{ + return rtems_interrupt_handler_remove(irq, isr, arg); +} + +/* Enable shared PCI IRQ handler. This function will unmask the interrupt + * controller and mark this interrupt handler ready to handle interrupts. Note + * that since it is a shared interrupt handler service the interrupt may + * already be enabled, however no calls to this specific handler is made + * until it is enabled. + * + * Arguments + * irq System IRQ number, normally taken from the PCI configuration area + * isr Function pointer to the ISR + * arg Second argument to function isr + */ +RTEMS_INLINE_ROUTINE void pci_interrupt_unmask(int irq) +{ + BSP_shared_interrupt_unmask(irq); +} + +/* Disable shared PCI IRQ handler. This function will mask the interrupt + * controller and mark this interrupt handler not ready to receive interrupts. + * Note that since it is a shared interrupt handler service the interrupt may + * still be enabled, however no calls to this specific handler is made + * while it is disabled. + * + * Arguments + * irq System IRQ number, normally taken from the PCI configuration area + * isr Function pointer to the ISR + * arg Second argument to function isr + */ +RTEMS_INLINE_ROUTINE void pci_interrupt_mask(int irq) +{ + BSP_shared_interrupt_mask(irq); +} + +/* Acknowledge the interrupt controller by writing to the interrupt controller. + * Note that since it is a shared interrupt handler service, clearing the + * interrupt source may affect other ISRs registered to this IRQ. + * + * Arguments + * irq System IRQ number, normally taken from the PCI configuration area + * isr Function pointer to the ISR + * arg Second argument to function isr + */ +RTEMS_INLINE_ROUTINE void pci_interrupt_clear(int irq) +{ + BSP_shared_interrupt_clear(irq); +} + +#endif /* !__PCI_IRQ_H__ */ diff --git a/cpukit/include/pci/pcireg.h b/cpukit/include/pci/pcireg.h new file mode 100644 index 0000000000..f2b2b74cf0 --- /dev/null +++ b/cpukit/include/pci/pcireg.h @@ -0,0 +1,931 @@ +/*- + * Copyright (c) 1997, Stefan Esser + * All rights reserved. + * + * New PCI library written from scratch. Defines in this file was taken from + * FreeBSD commit f1d6f4778d2044502209708bc167c05f9aa48615. + * auto-generated pci_ids.h also reused from RTEMS. + * Copyright 2009, Cobham Gaisler AB + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + * + */ + +#ifndef __PCI_REG_H__ +#define __PCI_REG_H__ + +/* + * PCIM_xxx: mask to locate subfield in register + * PCIR_xxx: config register offset + * PCIC_xxx: device class + * PCIS_xxx: device subclass + * PCIP_xxx: device programming interface + * PCIV_xxx: PCI vendor ID (only required to fixup ancient devices) + * PCID_xxx: device ID + * PCIY_xxx: capability identification number + * PCIZ_xxx: extended capability identification number + */ + +/* some PCI bus constants */ +#define PCI_DOMAINMAX 65535 /* highest supported domain number */ +#define PCI_BUSMAX 255 /* highest supported bus number */ +#define PCI_SLOTMAX 31 /* highest supported slot number */ +#define PCI_FUNCMAX 7 /* highest supported function number */ +#define PCI_REGMAX 255 /* highest supported config register addr. */ +#define PCIE_REGMAX 4095 /* highest supported config register addr. */ +#define PCI_MAXHDRTYPE 2 + +#define PCIE_ARI_SLOTMAX 0 +#define PCIE_ARI_FUNCMAX 255 + +#define PCI_RID_BUS_SHIFT 8 +#define PCI_RID_SLOT_SHIFT 3 +#define PCI_RID_FUNC_SHIFT 0 + +#define PCI_RID(bus, slot, func) \ + ((((bus) & PCI_BUSMAX) << PCI_RID_BUS_SHIFT) | \ + (((slot) & PCI_SLOTMAX) << PCI_RID_SLOT_SHIFT) | \ + (((func) & PCI_FUNCMAX) << PCI_RID_FUNC_SHIFT)) + +#define PCI_ARI_RID(bus, func) \ + ((((bus) & PCI_BUSMAX) << PCI_RID_BUS_SHIFT) | \ + (((func) & PCIE_ARI_FUNCMAX) << PCI_RID_FUNC_SHIFT)) + +#define PCI_RID2BUS(rid) (((rid) >> PCI_RID_BUS_SHIFT) & PCI_BUSMAX) +#define PCI_RID2SLOT(rid) (((rid) >> PCI_RID_SLOT_SHIFT) & PCI_SLOTMAX) +#define PCI_RID2FUNC(rid) (((rid) >> PCI_RID_FUNC_SHIFT) & PCI_FUNCMAX) + +#define PCIE_ARI_SLOT(func) (((func) >> PCI_RID_SLOT_SHIFT) & PCI_SLOTMAX) +#define PCIE_ARI_FUNC(func) (((func) >> PCI_RID_FUNC_SHIFT) & PCI_FUNCMAX) + +/* PCI config header registers for all devices */ + +#define PCIR_DEVVENDOR 0x00 +#define PCIR_VENDOR 0x00 +#define PCIR_DEVICE 0x02 +#define PCIR_COMMAND 0x04 +#define PCIM_CMD_PORTEN 0x0001 +#define PCIM_CMD_MEMEN 0x0002 +#define PCIM_CMD_BUSMASTEREN 0x0004 +#define PCIM_CMD_SPECIALEN 0x0008 +#define PCIM_CMD_MWRICEN 0x0010 +#define PCIM_CMD_PERRESPEN 0x0040 +#define PCIM_CMD_SERRESPEN 0x0100 +#define PCIM_CMD_BACKTOBACK 0x0200 +#define PCIM_CMD_INTxDIS 0x0400 +#define PCIR_STATUS 0x06 +#define PCIM_STATUS_INTxSTATE 0x0008 +#define PCIM_STATUS_CAPPRESENT 0x0010 +#define PCIM_STATUS_66CAPABLE 0x0020 +#define PCIM_STATUS_BACKTOBACK 0x0080 +#define PCIM_STATUS_MDPERR 0x0100 +#define PCIM_STATUS_SEL_FAST 0x0000 +#define PCIM_STATUS_SEL_MEDIMUM 0x0200 +#define PCIM_STATUS_SEL_SLOW 0x0400 +#define PCIM_STATUS_SEL_MASK 0x0600 +#define PCIM_STATUS_STABORT 0x0800 +#define PCIM_STATUS_RTABORT 0x1000 +#define PCIM_STATUS_RMABORT 0x2000 +#define PCIM_STATUS_SERR 0x4000 +#define PCIM_STATUS_PERR 0x8000 +#define PCIR_REVID 0x08 +#define PCIR_PROGIF 0x09 +#define PCIR_SUBCLASS 0x0a +#define PCIR_CLASS 0x0b +#define PCIR_CACHELNSZ 0x0c +#define PCIR_LATTIMER 0x0d +#define PCIR_HDRTYPE 0x0e +#define PCIM_HDRTYPE 0x7f +#define PCIM_HDRTYPE_NORMAL 0x00 +#define PCIM_HDRTYPE_BRIDGE 0x01 +#define PCIM_HDRTYPE_CARDBUS 0x02 +#define PCIM_MFDEV 0x80 +#define PCIR_BIST 0x0f + +/* Capability Register Offsets */ + +#define PCICAP_ID 0x0 +#define PCICAP_NEXTPTR 0x1 + +/* Capability Identification Numbers */ + +#define PCIY_PMG 0x01 /* PCI Power Management */ +#define PCIY_AGP 0x02 /* AGP */ +#define PCIY_VPD 0x03 /* Vital Product Data */ +#define PCIY_SLOTID 0x04 /* Slot Identification */ +#define PCIY_MSI 0x05 /* Message Signaled Interrupts */ +#define PCIY_CHSWP 0x06 /* CompactPCI Hot Swap */ +#define PCIY_PCIX 0x07 /* PCI-X */ +#define PCIY_HT 0x08 /* HyperTransport */ +#define PCIY_VENDOR 0x09 /* Vendor Unique */ +#define PCIY_DEBUG 0x0a /* Debug port */ +#define PCIY_CRES 0x0b /* CompactPCI central resource control */ +#define PCIY_HOTPLUG 0x0c /* PCI Hot-Plug */ +#define PCIY_SUBVENDOR 0x0d /* PCI-PCI bridge subvendor ID */ +#define PCIY_AGP8X 0x0e /* AGP 8x */ +#define PCIY_SECDEV 0x0f /* Secure Device */ +#define PCIY_EXPRESS 0x10 /* PCI Express */ +#define PCIY_MSIX 0x11 /* MSI-X */ +#define PCIY_SATA 0x12 /* SATA */ +#define PCIY_PCIAF 0x13 /* PCI Advanced Features */ + +/* Extended Capability Register Fields */ + +#define PCIR_EXTCAP 0x100 +#define PCIM_EXTCAP_ID 0x0000ffff +#define PCIM_EXTCAP_VER 0x000f0000 +#define PCIM_EXTCAP_NEXTPTR 0xfff00000 +#define PCI_EXTCAP_ID(ecap) ((ecap) & PCIM_EXTCAP_ID) +#define PCI_EXTCAP_VER(ecap) (((ecap) & PCIM_EXTCAP_VER) >> 16) +#define PCI_EXTCAP_NEXTPTR(ecap) (((ecap) & PCIM_EXTCAP_NEXTPTR) >> 20) + +/* Extended Capability Identification Numbers */ + +#define PCIZ_AER 0x0001 /* Advanced Error Reporting */ +#define PCIZ_VC 0x0002 /* Virtual Channel if MFVC Ext Cap not set */ +#define PCIZ_SERNUM 0x0003 /* Device Serial Number */ +#define PCIZ_PWRBDGT 0x0004 /* Power Budgeting */ +#define PCIZ_RCLINK_DCL 0x0005 /* Root Complex Link Declaration */ +#define PCIZ_RCLINK_CTL 0x0006 /* Root Complex Internal Link Control */ +#define PCIZ_RCEC_ASSOC 0x0007 /* Root Complex Event Collector Association */ +#define PCIZ_MFVC 0x0008 /* Multi-Function Virtual Channel */ +#define PCIZ_VC2 0x0009 /* Virtual Channel if MFVC Ext Cap set */ +#define PCIZ_RCRB 0x000a /* RCRB Header */ +#define PCIZ_VENDOR 0x000b /* Vendor Unique */ +#define PCIZ_CAC 0x000c /* Configuration Access Correction -- obsolete */ +#define PCIZ_ACS 0x000d /* Access Control Services */ +#define PCIZ_ARI 0x000e /* Alternative Routing-ID Interpretation */ +#define PCIZ_ATS 0x000f /* Address Translation Services */ +#define PCIZ_SRIOV 0x0010 /* Single Root IO Virtualization */ +#define PCIZ_MRIOV 0x0011 /* Multiple Root IO Virtualization */ +#define PCIZ_MULTICAST 0x0012 /* Multicast */ +#define PCIZ_PAGE_REQ 0x0013 /* Page Request */ +#define PCIZ_AMD 0x0014 /* Reserved for AMD */ +#define PCIZ_RESIZE_BAR 0x0015 /* Resizable BAR */ +#define PCIZ_DPA 0x0016 /* Dynamic Power Allocation */ +#define PCIZ_TPH_REQ 0x0017 /* TPH Requester */ +#define PCIZ_LTR 0x0018 /* Latency Tolerance Reporting */ +#define PCIZ_SEC_PCIE 0x0019 /* Secondary PCI Express */ +#define PCIZ_PMUX 0x001a /* Protocol Multiplexing */ +#define PCIZ_PASID 0x001b /* Process Address Space ID */ +#define PCIZ_LN_REQ 0x001c /* LN Requester */ +#define PCIZ_DPC 0x001d /* Downstream Porto Containment */ +#define PCIZ_L1PM 0x001e /* L1 PM Substates */ + +/* config registers for header type 0 devices */ + +#define PCIR_BARS 0x10 +#define PCIR_BAR(x) (PCIR_BARS + (x) * 4) +#define PCIR_MAX_BAR_0 5 +#define PCI_RID2BAR(rid) (((rid) - PCIR_BARS) / 4) +#define PCI_BAR_IO(x) (((x) & PCIM_BAR_SPACE) == PCIM_BAR_IO_SPACE) +#define PCI_BAR_MEM(x) (((x) & PCIM_BAR_SPACE) == PCIM_BAR_MEM_SPACE) +#define PCIM_BAR_SPACE 0x00000001 +#define PCIM_BAR_MEM_SPACE 0 +#define PCIM_BAR_IO_SPACE 1 +#define PCIM_BAR_MEM_TYPE 0x00000006 +#define PCIM_BAR_MEM_32 0 +#define PCIM_BAR_MEM_1MB 2 /* Locate below 1MB in PCI <= 2.1 */ +#define PCIM_BAR_MEM_64 4 +#define PCIM_BAR_MEM_PREFETCH 0x00000008 +#define PCIM_BAR_MEM_BASE 0xfffffffffffffff0ULL +#define PCIM_BAR_IO_RESERVED 0x00000002 +#define PCIM_BAR_IO_BASE 0xfffffffc +#define PCIR_CIS 0x28 +#define PCIM_CIS_ASI_MASK 0x00000007 +#define PCIM_CIS_ASI_CONFIG 0 +#define PCIM_CIS_ASI_BAR0 1 +#define PCIM_CIS_ASI_BAR1 2 +#define PCIM_CIS_ASI_BAR2 3 +#define PCIM_CIS_ASI_BAR3 4 +#define PCIM_CIS_ASI_BAR4 5 +#define PCIM_CIS_ASI_BAR5 6 +#define PCIM_CIS_ASI_ROM 7 +#define PCIM_CIS_ADDR_MASK 0x0ffffff8 +#define PCIM_CIS_ROM_MASK 0xf0000000 +#define PCIM_CIS_CONFIG_MASK 0xff +#define PCIR_SUBVEND_0 0x2c +#define PCIR_SUBDEV_0 0x2e +#define PCIR_BIOS 0x30 +#define PCIM_BIOS_ENABLE 0x01 +#define PCIM_BIOS_ADDR_MASK 0xfffff800 +#define PCIR_CAP_PTR 0x34 +#define PCIR_INTLINE 0x3c +#define PCIR_INTPIN 0x3d +#define PCIR_MINGNT 0x3e +#define PCIR_MAXLAT 0x3f + +/* config registers for header type 1 (PCI-to-PCI bridge) devices */ + +#define PCIR_MAX_BAR_1 1 +#define PCIR_SECSTAT_1 0x1e + +#define PCIR_PRIBUS_1 0x18 +#define PCIR_SECBUS_1 0x19 +#define PCIR_SUBBUS_1 0x1a +#define PCIR_SECLAT_1 0x1b + +#define PCIR_IOBASEL_1 0x1c +#define PCIR_IOLIMITL_1 0x1d +#define PCIR_IOBASEH_1 0x30 +#define PCIR_IOLIMITH_1 0x32 +#define PCIM_BRIO_16 0x0 +#define PCIM_BRIO_32 0x1 +#define PCIM_BRIO_MASK 0xf + +#define PCIR_MEMBASE_1 0x20 +#define PCIR_MEMLIMIT_1 0x22 + +#define PCIR_PMBASEL_1 0x24 +#define PCIR_PMLIMITL_1 0x26 +#define PCIR_PMBASEH_1 0x28 +#define PCIR_PMLIMITH_1 0x2c +#define PCIM_BRPM_32 0x0 +#define PCIM_BRPM_64 0x1 +#define PCIM_BRPM_MASK 0xf + +#define PCIR_BIOS_1 0x38 +#define PCIR_BRIDGECTL_1 0x3e + +/* config registers for header type 2 (CardBus) devices */ + +#define PCIR_MAX_BAR_2 0 +#define PCIR_CAP_PTR_2 0x14 +#define PCIR_SECSTAT_2 0x16 + +#define PCIR_PRIBUS_2 0x18 +#define PCIR_SECBUS_2 0x19 +#define PCIR_SUBBUS_2 0x1a +#define PCIR_SECLAT_2 0x1b + +#define PCIR_MEMBASE0_2 0x1c +#define PCIR_MEMLIMIT0_2 0x20 +#define PCIR_MEMBASE1_2 0x24 +#define PCIR_MEMLIMIT1_2 0x28 +#define PCIR_IOBASE0_2 0x2c +#define PCIR_IOLIMIT0_2 0x30 +#define PCIR_IOBASE1_2 0x34 +#define PCIR_IOLIMIT1_2 0x38 + +#define PCIR_BRIDGECTL_2 0x3e + +#define PCIR_SUBVEND_2 0x40 +#define PCIR_SUBDEV_2 0x42 + +#define PCIR_PCCARDIF_2 0x44 + +/* PCI device class, subclass and programming interface definitions */ + +#define PCIC_OLD 0x00 +#define PCIS_OLD_NONVGA 0x00 +#define PCIS_OLD_VGA 0x01 + +#define PCIC_STORAGE 0x01 +#define PCIS_STORAGE_SCSI 0x00 +#define PCIS_STORAGE_IDE 0x01 +#define PCIP_STORAGE_IDE_MODEPRIM 0x01 +#define PCIP_STORAGE_IDE_PROGINDPRIM 0x02 +#define PCIP_STORAGE_IDE_MODESEC 0x04 +#define PCIP_STORAGE_IDE_PROGINDSEC 0x08 +#define PCIP_STORAGE_IDE_MASTERDEV 0x80 +#define PCIS_STORAGE_FLOPPY 0x02 +#define PCIS_STORAGE_IPI 0x03 +#define PCIS_STORAGE_RAID 0x04 +#define PCIS_STORAGE_ATA_ADMA 0x05 +#define PCIS_STORAGE_SATA 0x06 +#define PCIP_STORAGE_SATA_AHCI_1_0 0x01 +#define PCIS_STORAGE_SAS 0x07 +#define PCIS_STORAGE_NVM 0x08 +#define PCIP_STORAGE_NVM_NVMHCI_1_0 0x01 +#define PCIP_STORAGE_NVM_ENTERPRISE_NVMHCI_1_0 0x02 +#define PCIS_STORAGE_OTHER 0x80 + +#define PCIC_NETWORK 0x02 +#define PCIS_NETWORK_ETHERNET 0x00 +#define PCIS_NETWORK_TOKENRING 0x01 +#define PCIS_NETWORK_FDDI 0x02 +#define PCIS_NETWORK_ATM 0x03 +#define PCIS_NETWORK_ISDN 0x04 +#define PCIS_NETWORK_WORLDFIP 0x05 +#define PCIS_NETWORK_PICMG 0x06 +#define PCIS_NETWORK_OTHER 0x80 + +#define PCIC_DISPLAY 0x03 +#define PCIS_DISPLAY_VGA 0x00 +#define PCIS_DISPLAY_XGA 0x01 +#define PCIS_DISPLAY_3D 0x02 +#define PCIS_DISPLAY_OTHER 0x80 + +#define PCIC_MULTIMEDIA 0x04 +#define PCIS_MULTIMEDIA_VIDEO 0x00 +#define PCIS_MULTIMEDIA_AUDIO 0x01 +#define PCIS_MULTIMEDIA_TELE 0x02 +#define PCIS_MULTIMEDIA_HDA 0x03 +#define PCIS_MULTIMEDIA_OTHER 0x80 + +#define PCIC_MEMORY 0x05 +#define PCIS_MEMORY_RAM 0x00 +#define PCIS_MEMORY_FLASH 0x01 +#define PCIS_MEMORY_OTHER 0x80 + +#define PCIC_BRIDGE 0x06 +#define PCIS_BRIDGE_HOST 0x00 +#define PCIS_BRIDGE_ISA 0x01 +#define PCIS_BRIDGE_EISA 0x02 +#define PCIS_BRIDGE_MCA 0x03 +#define PCIS_BRIDGE_PCI 0x04 +#define PCIP_BRIDGE_PCI_SUBTRACTIVE 0x01 +#define PCIS_BRIDGE_PCMCIA 0x05 +#define PCIS_BRIDGE_NUBUS 0x06 +#define PCIS_BRIDGE_CARDBUS 0x07 +#define PCIS_BRIDGE_RACEWAY 0x08 +#define PCIS_BRIDGE_PCI_TRANSPARENT 0x09 +#define PCIS_BRIDGE_INFINIBAND 0x0a +#define PCIS_BRIDGE_OTHER 0x80 + +#define PCIC_SIMPLECOMM 0x07 +#define PCIS_SIMPLECOMM_UART 0x00 +#define PCIP_SIMPLECOMM_UART_8250 0x00 +#define PCIP_SIMPLECOMM_UART_16450A 0x01 +#define PCIP_SIMPLECOMM_UART_16550A 0x02 +#define PCIP_SIMPLECOMM_UART_16650A 0x03 +#define PCIP_SIMPLECOMM_UART_16750A 0x04 +#define PCIP_SIMPLECOMM_UART_16850A 0x05 +#define PCIP_SIMPLECOMM_UART_16950A 0x06 +#define PCIS_SIMPLECOMM_PAR 0x01 +#define PCIS_SIMPLECOMM_MULSER 0x02 +#define PCIS_SIMPLECOMM_MODEM 0x03 +#define PCIS_SIMPLECOMM_GPIB 0x04 +#define PCIS_SIMPLECOMM_SMART_CARD 0x05 +#define PCIS_SIMPLECOMM_OTHER 0x80 + +#define PCIC_BASEPERIPH 0x08 +#define PCIS_BASEPERIPH_PIC 0x00 +#define PCIP_BASEPERIPH_PIC_8259A 0x00 +#define PCIP_BASEPERIPH_PIC_ISA 0x01 +#define PCIP_BASEPERIPH_PIC_EISA 0x02 +#define PCIP_BASEPERIPH_PIC_IO_APIC 0x10 +#define PCIP_BASEPERIPH_PIC_IOX_APIC 0x20 +#define PCIS_BASEPERIPH_DMA 0x01 +#define PCIS_BASEPERIPH_TIMER 0x02 +#define PCIS_BASEPERIPH_RTC 0x03 +#define PCIS_BASEPERIPH_PCIHOT 0x04 +#define PCIS_BASEPERIPH_SDHC 0x05 +#define PCIS_BASEPERIPH_IOMMU 0x06 +#define PCIS_BASEPERIPH_OTHER 0x80 + +#define PCIC_INPUTDEV 0x09 +#define PCIS_INPUTDEV_KEYBOARD 0x00 +#define PCIS_INPUTDEV_DIGITIZER 0x01 +#define PCIS_INPUTDEV_MOUSE 0x02 +#define PCIS_INPUTDEV_SCANNER 0x03 +#define PCIS_INPUTDEV_GAMEPORT 0x04 +#define PCIS_INPUTDEV_OTHER 0x80 + +#define PCIC_DOCKING 0x0a +#define PCIS_DOCKING_GENERIC 0x00 +#define PCIS_DOCKING_OTHER 0x80 + +#define PCIC_PROCESSOR 0x0b +#define PCIS_PROCESSOR_386 0x00 +#define PCIS_PROCESSOR_486 0x01 +#define PCIS_PROCESSOR_PENTIUM 0x02 +#define PCIS_PROCESSOR_ALPHA 0x10 +#define PCIS_PROCESSOR_POWERPC 0x20 +#define PCIS_PROCESSOR_MIPS 0x30 +#define PCIS_PROCESSOR_COPROC 0x40 + +#define PCIC_SERIALBUS 0x0c +#define PCIS_SERIALBUS_FW 0x00 +#define PCIS_SERIALBUS_ACCESS 0x01 +#define PCIS_SERIALBUS_SSA 0x02 +#define PCIS_SERIALBUS_USB 0x03 +#define PCIP_SERIALBUS_USB_UHCI 0x00 +#define PCIP_SERIALBUS_USB_OHCI 0x10 +#define PCIP_SERIALBUS_USB_EHCI 0x20 +#define PCIP_SERIALBUS_USB_XHCI 0x30 +#define PCIP_SERIALBUS_USB_DEVICE 0xfe +#define PCIS_SERIALBUS_FC 0x04 +#define PCIS_SERIALBUS_SMBUS 0x05 +#define PCIS_SERIALBUS_INFINIBAND 0x06 +#define PCIS_SERIALBUS_IPMI 0x07 +#define PCIP_SERIALBUS_IPMI_SMIC 0x00 +#define PCIP_SERIALBUS_IPMI_KCS 0x01 +#define PCIP_SERIALBUS_IPMI_BT 0x02 +#define PCIS_SERIALBUS_SERCOS 0x08 +#define PCIS_SERIALBUS_CANBUS 0x09 + +#define PCIC_WIRELESS 0x0d +#define PCIS_WIRELESS_IRDA 0x00 +#define PCIS_WIRELESS_IR 0x01 +#define PCIS_WIRELESS_RF 0x10 +#define PCIS_WIRELESS_BLUETOOTH 0x11 +#define PCIS_WIRELESS_BROADBAND 0x12 +#define PCIS_WIRELESS_80211A 0x20 +#define PCIS_WIRELESS_80211B 0x21 +#define PCIS_WIRELESS_OTHER 0x80 + +#define PCIC_INTELLIIO 0x0e +#define PCIS_INTELLIIO_I2O 0x00 + +#define PCIC_SATCOM 0x0f +#define PCIS_SATCOM_TV 0x01 +#define PCIS_SATCOM_AUDIO 0x02 +#define PCIS_SATCOM_VOICE 0x03 +#define PCIS_SATCOM_DATA 0x04 + +#define PCIC_CRYPTO 0x10 +#define PCIS_CRYPTO_NETCOMP 0x00 +#define PCIS_CRYPTO_ENTERTAIN 0x10 +#define PCIS_CRYPTO_OTHER 0x80 + +#define PCIC_DASP 0x11 +#define PCIS_DASP_DPIO 0x00 +#define PCIS_DASP_PERFCNTRS 0x01 +#define PCIS_DASP_COMM_SYNC 0x10 +#define PCIS_DASP_MGMT_CARD 0x20 +#define PCIS_DASP_OTHER 0x80 + +#define PCIC_OTHER 0xff + +/* Bridge Control Values. */ +#define PCIB_BCR_PERR_ENABLE 0x0001 +#define PCIB_BCR_SERR_ENABLE 0x0002 +#define PCIB_BCR_ISA_ENABLE 0x0004 +#define PCIB_BCR_VGA_ENABLE 0x0008 +#define PCIB_BCR_MASTER_ABORT_MODE 0x0020 +#define PCIB_BCR_SECBUS_RESET 0x0040 +#define PCIB_BCR_SECBUS_BACKTOBACK 0x0080 +#define PCIB_BCR_PRI_DISCARD_TIMEOUT 0x0100 +#define PCIB_BCR_SEC_DISCARD_TIMEOUT 0x0200 +#define PCIB_BCR_DISCARD_TIMER_STATUS 0x0400 +#define PCIB_BCR_DISCARD_TIMER_SERREN 0x0800 + +/* PCI power manangement */ +#define PCIR_POWER_CAP 0x2 +#define PCIM_PCAP_SPEC 0x0007 +#define PCIM_PCAP_PMEREQCLK 0x0008 +#define PCIM_PCAP_DEVSPECINIT 0x0020 +#define PCIM_PCAP_AUXPWR_0 0x0000 +#define PCIM_PCAP_AUXPWR_55 0x0040 +#define PCIM_PCAP_AUXPWR_100 0x0080 +#define PCIM_PCAP_AUXPWR_160 0x00c0 +#define PCIM_PCAP_AUXPWR_220 0x0100 +#define PCIM_PCAP_AUXPWR_270 0x0140 +#define PCIM_PCAP_AUXPWR_320 0x0180 +#define PCIM_PCAP_AUXPWR_375 0x01c0 +#define PCIM_PCAP_AUXPWRMASK 0x01c0 +#define PCIM_PCAP_D1SUPP 0x0200 +#define PCIM_PCAP_D2SUPP 0x0400 +#define PCIM_PCAP_D0PME 0x0800 +#define PCIM_PCAP_D1PME 0x1000 +#define PCIM_PCAP_D2PME 0x2000 +#define PCIM_PCAP_D3PME_HOT 0x4000 +#define PCIM_PCAP_D3PME_COLD 0x8000 + +#define PCIR_POWER_STATUS 0x4 +#define PCIM_PSTAT_D0 0x0000 +#define PCIM_PSTAT_D1 0x0001 +#define PCIM_PSTAT_D2 0x0002 +#define PCIM_PSTAT_D3 0x0003 +#define PCIM_PSTAT_DMASK 0x0003 +#define PCIM_PSTAT_NOSOFTRESET 0x0008 +#define PCIM_PSTAT_PMEENABLE 0x0100 +#define PCIM_PSTAT_D0POWER 0x0000 +#define PCIM_PSTAT_D1POWER 0x0200 +#define PCIM_PSTAT_D2POWER 0x0400 +#define PCIM_PSTAT_D3POWER 0x0600 +#define PCIM_PSTAT_D0HEAT 0x0800 +#define PCIM_PSTAT_D1HEAT 0x0a00 +#define PCIM_PSTAT_D2HEAT 0x0c00 +#define PCIM_PSTAT_D3HEAT 0x0e00 +#define PCIM_PSTAT_DATASELMASK 0x1e00 +#define PCIM_PSTAT_DATAUNKN 0x0000 +#define PCIM_PSTAT_DATADIV10 0x2000 +#define PCIM_PSTAT_DATADIV100 0x4000 +#define PCIM_PSTAT_DATADIV1000 0x6000 +#define PCIM_PSTAT_DATADIVMASK 0x6000 +#define PCIM_PSTAT_PME 0x8000 + +#define PCIR_POWER_BSE 0x6 +#define PCIM_PMCSR_BSE_D3B3 0x00 +#define PCIM_PMCSR_BSE_D3B2 0x40 +#define PCIM_PMCSR_BSE_BPCCE 0x80 + +#define PCIR_POWER_DATA 0x7 + +/* VPD capability registers */ +#define PCIR_VPD_ADDR 0x2 +#define PCIR_VPD_DATA 0x4 + +/* PCI Message Signalled Interrupts (MSI) */ +#define PCIR_MSI_CTRL 0x2 +#define PCIM_MSICTRL_VECTOR 0x0100 +#define PCIM_MSICTRL_64BIT 0x0080 +#define PCIM_MSICTRL_MME_MASK 0x0070 +#define PCIM_MSICTRL_MME_1 0x0000 +#define PCIM_MSICTRL_MME_2 0x0010 +#define PCIM_MSICTRL_MME_4 0x0020 +#define PCIM_MSICTRL_MME_8 0x0030 +#define PCIM_MSICTRL_MME_16 0x0040 +#define PCIM_MSICTRL_MME_32 0x0050 +#define PCIM_MSICTRL_MMC_MASK 0x000E +#define PCIM_MSICTRL_MMC_1 0x0000 +#define PCIM_MSICTRL_MMC_2 0x0002 +#define PCIM_MSICTRL_MMC_4 0x0004 +#define PCIM_MSICTRL_MMC_8 0x0006 +#define PCIM_MSICTRL_MMC_16 0x0008 +#define PCIM_MSICTRL_MMC_32 0x000A +#define PCIM_MSICTRL_MSI_ENABLE 0x0001 +#define PCIR_MSI_ADDR 0x4 +#define PCIR_MSI_ADDR_HIGH 0x8 +#define PCIR_MSI_DATA 0x8 +#define PCIR_MSI_DATA_64BIT 0xc +#define PCIR_MSI_MASK 0x10 +#define PCIR_MSI_PENDING 0x14 + +/* PCI-X definitions */ + +/* For header type 0 devices */ +#define PCIXR_COMMAND 0x2 +#define PCIXM_COMMAND_DPERR_E 0x0001 /* Data Parity Error Recovery */ +#define PCIXM_COMMAND_ERO 0x0002 /* Enable Relaxed Ordering */ +#define PCIXM_COMMAND_MAX_READ 0x000c /* Maximum Burst Read Count */ +#define PCIXM_COMMAND_MAX_READ_512 0x0000 +#define PCIXM_COMMAND_MAX_READ_1024 0x0004 +#define PCIXM_COMMAND_MAX_READ_2048 0x0008 +#define PCIXM_COMMAND_MAX_READ_4096 0x000c +#define PCIXM_COMMAND_MAX_SPLITS 0x0070 /* Maximum Split Transactions */ +#define PCIXM_COMMAND_MAX_SPLITS_1 0x0000 +#define PCIXM_COMMAND_MAX_SPLITS_2 0x0010 +#define PCIXM_COMMAND_MAX_SPLITS_3 0x0020 +#define PCIXM_COMMAND_MAX_SPLITS_4 0x0030 +#define PCIXM_COMMAND_MAX_SPLITS_8 0x0040 +#define PCIXM_COMMAND_MAX_SPLITS_12 0x0050 +#define PCIXM_COMMAND_MAX_SPLITS_16 0x0060 +#define PCIXM_COMMAND_MAX_SPLITS_32 0x0070 +#define PCIXM_COMMAND_VERSION 0x3000 +#define PCIXR_STATUS 0x4 +#define PCIXM_STATUS_DEVFN 0x000000FF +#define PCIXM_STATUS_BUS 0x0000FF00 +#define PCIXM_STATUS_64BIT 0x00010000 +#define PCIXM_STATUS_133CAP 0x00020000 +#define PCIXM_STATUS_SC_DISCARDED 0x00040000 +#define PCIXM_STATUS_UNEXP_SC 0x00080000 +#define PCIXM_STATUS_COMPLEX_DEV 0x00100000 +#define PCIXM_STATUS_MAX_READ 0x00600000 +#define PCIXM_STATUS_MAX_READ_512 0x00000000 +#define PCIXM_STATUS_MAX_READ_1024 0x00200000 +#define PCIXM_STATUS_MAX_READ_2048 0x00400000 +#define PCIXM_STATUS_MAX_READ_4096 0x00600000 +#define PCIXM_STATUS_MAX_SPLITS 0x03800000 +#define PCIXM_STATUS_MAX_SPLITS_1 0x00000000 +#define PCIXM_STATUS_MAX_SPLITS_2 0x00800000 +#define PCIXM_STATUS_MAX_SPLITS_3 0x01000000 +#define PCIXM_STATUS_MAX_SPLITS_4 0x01800000 +#define PCIXM_STATUS_MAX_SPLITS_8 0x02000000 +#define PCIXM_STATUS_MAX_SPLITS_12 0x02800000 +#define PCIXM_STATUS_MAX_SPLITS_16 0x03000000 +#define PCIXM_STATUS_MAX_SPLITS_32 0x03800000 +#define PCIXM_STATUS_MAX_CUM_READ 0x1C000000 +#define PCIXM_STATUS_RCVD_SC_ERR 0x20000000 +#define PCIXM_STATUS_266CAP 0x40000000 +#define PCIXM_STATUS_533CAP 0x80000000 + +/* For header type 1 devices (PCI-X bridges) */ +#define PCIXR_SEC_STATUS 0x2 +#define PCIXM_SEC_STATUS_64BIT 0x0001 +#define PCIXM_SEC_STATUS_133CAP 0x0002 +#define PCIXM_SEC_STATUS_SC_DISC 0x0004 +#define PCIXM_SEC_STATUS_UNEXP_SC 0x0008 +#define PCIXM_SEC_STATUS_SC_OVERRUN 0x0010 +#define PCIXM_SEC_STATUS_SR_DELAYED 0x0020 +#define PCIXM_SEC_STATUS_BUS_MODE 0x03c0 +#define PCIXM_SEC_STATUS_VERSION 0x3000 +#define PCIXM_SEC_STATUS_266CAP 0x4000 +#define PCIXM_SEC_STATUS_533CAP 0x8000 +#define PCIXR_BRIDGE_STATUS 0x4 +#define PCIXM_BRIDGE_STATUS_DEVFN 0x000000FF +#define PCIXM_BRIDGE_STATUS_BUS 0x0000FF00 +#define PCIXM_BRIDGE_STATUS_64BIT 0x00010000 +#define PCIXM_BRIDGE_STATUS_133CAP 0x00020000 +#define PCIXM_BRIDGE_STATUS_SC_DISCARDED 0x00040000 +#define PCIXM_BRIDGE_STATUS_UNEXP_SC 0x00080000 +#define PCIXM_BRIDGE_STATUS_SC_OVERRUN 0x00100000 +#define PCIXM_BRIDGE_STATUS_SR_DELAYED 0x00200000 +#define PCIXM_BRIDGE_STATUS_DEVID_MSGCAP 0x20000000 +#define PCIXM_BRIDGE_STATUS_266CAP 0x40000000 +#define PCIXM_BRIDGE_STATUS_533CAP 0x80000000 + +/* HT (HyperTransport) Capability definitions */ +#define PCIR_HT_COMMAND 0x2 +#define PCIM_HTCMD_CAP_MASK 0xf800 /* Capability type. */ +#define PCIM_HTCAP_SLAVE 0x0000 /* 000xx */ +#define PCIM_HTCAP_HOST 0x2000 /* 001xx */ +#define PCIM_HTCAP_SWITCH 0x4000 /* 01000 */ +#define PCIM_HTCAP_INTERRUPT 0x8000 /* 10000 */ +#define PCIM_HTCAP_REVISION_ID 0x8800 /* 10001 */ +#define PCIM_HTCAP_UNITID_CLUMPING 0x9000 /* 10010 */ +#define PCIM_HTCAP_EXT_CONFIG_SPACE 0x9800 /* 10011 */ +#define PCIM_HTCAP_ADDRESS_MAPPING 0xa000 /* 10100 */ +#define PCIM_HTCAP_MSI_MAPPING 0xa800 /* 10101 */ +#define PCIM_HTCAP_DIRECT_ROUTE 0xb000 /* 10110 */ +#define PCIM_HTCAP_VCSET 0xb800 /* 10111 */ +#define PCIM_HTCAP_RETRY_MODE 0xc000 /* 11000 */ +#define PCIM_HTCAP_X86_ENCODING 0xc800 /* 11001 */ +#define PCIM_HTCAP_GEN3 0xd000 /* 11010 */ +#define PCIM_HTCAP_FLE 0xd800 /* 11011 */ +#define PCIM_HTCAP_PM 0xe000 /* 11100 */ +#define PCIM_HTCAP_HIGH_NODE_COUNT 0xe800 /* 11101 */ + +/* HT MSI Mapping Capability definitions. */ +#define PCIM_HTCMD_MSI_ENABLE 0x0001 +#define PCIM_HTCMD_MSI_FIXED 0x0002 +#define PCIR_HTMSI_ADDRESS_LO 0x4 +#define PCIR_HTMSI_ADDRESS_HI 0x8 + +/* PCI Vendor capability definitions */ +#define PCIR_VENDOR_LENGTH 0x2 +#define PCIR_VENDOR_DATA 0x3 + +/* PCI EHCI Debug Port definitions */ +#define PCIR_DEBUG_PORT 0x2 +#define PCIM_DEBUG_PORT_OFFSET 0x1FFF +#define PCIM_DEBUG_PORT_BAR 0xe000 + +/* PCI-PCI Bridge Subvendor definitions */ +#define PCIR_SUBVENDCAP_ID 0x4 + +/* PCI Express definitions */ +#define PCIER_FLAGS 0x2 +#define PCIEM_FLAGS_VERSION 0x000F +#define PCIEM_FLAGS_TYPE 0x00F0 +#define PCIEM_TYPE_ENDPOINT 0x0000 +#define PCIEM_TYPE_LEGACY_ENDPOINT 0x0010 +#define PCIEM_TYPE_ROOT_PORT 0x0040 +#define PCIEM_TYPE_UPSTREAM_PORT 0x0050 +#define PCIEM_TYPE_DOWNSTREAM_PORT 0x0060 +#define PCIEM_TYPE_PCI_BRIDGE 0x0070 +#define PCIEM_TYPE_PCIE_BRIDGE 0x0080 +#define PCIEM_TYPE_ROOT_INT_EP 0x0090 +#define PCIEM_TYPE_ROOT_EC 0x00a0 +#define PCIEM_FLAGS_SLOT 0x0100 +#define PCIEM_FLAGS_IRQ 0x3e00 +#define PCIER_DEVICE_CAP 0x4 +#define PCIEM_CAP_MAX_PAYLOAD 0x00000007 +#define PCIEM_CAP_PHANTHOM_FUNCS 0x00000018 +#define PCIEM_CAP_EXT_TAG_FIELD 0x00000020 +#define PCIEM_CAP_L0S_LATENCY 0x000001c0 +#define PCIEM_CAP_L1_LATENCY 0x00000e00 +#define PCIEM_CAP_ROLE_ERR_RPT 0x00008000 +#define PCIEM_CAP_SLOT_PWR_LIM_VAL 0x03fc0000 +#define PCIEM_CAP_SLOT_PWR_LIM_SCALE 0x0c000000 +#define PCIEM_CAP_FLR 0x10000000 +#define PCIER_DEVICE_CTL 0x8 +#define PCIEM_CTL_COR_ENABLE 0x0001 +#define PCIEM_CTL_NFER_ENABLE 0x0002 +#define PCIEM_CTL_FER_ENABLE 0x0004 +#define PCIEM_CTL_URR_ENABLE 0x0008 +#define PCIEM_CTL_RELAXED_ORD_ENABLE 0x0010 +#define PCIEM_CTL_MAX_PAYLOAD 0x00e0 +#define PCIEM_CTL_EXT_TAG_FIELD 0x0100 +#define PCIEM_CTL_PHANTHOM_FUNCS 0x0200 +#define PCIEM_CTL_AUX_POWER_PM 0x0400 +#define PCIEM_CTL_NOSNOOP_ENABLE 0x0800 +#define PCIEM_CTL_MAX_READ_REQUEST 0x7000 +#define PCIEM_CTL_BRDG_CFG_RETRY 0x8000 /* PCI-E - PCI/PCI-X bridges */ +#define PCIEM_CTL_INITIATE_FLR 0x8000 /* FLR capable endpoints */ +#define PCIER_DEVICE_STA 0xa +#define PCIEM_STA_CORRECTABLE_ERROR 0x0001 +#define PCIEM_STA_NON_FATAL_ERROR 0x0002 +#define PCIEM_STA_FATAL_ERROR 0x0004 +#define PCIEM_STA_UNSUPPORTED_REQ 0x0008 +#define PCIEM_STA_AUX_POWER 0x0010 +#define PCIEM_STA_TRANSACTION_PND 0x0020 +#define PCIER_LINK_CAP 0xc +#define PCIEM_LINK_CAP_MAX_SPEED 0x0000000f +#define PCIEM_LINK_CAP_MAX_WIDTH 0x000003f0 +#define PCIEM_LINK_CAP_ASPM 0x00000c00 +#define PCIEM_LINK_CAP_L0S_EXIT 0x00007000 +#define PCIEM_LINK_CAP_L1_EXIT 0x00038000 +#define PCIEM_LINK_CAP_CLOCK_PM 0x00040000 +#define PCIEM_LINK_CAP_SURPRISE_DOWN 0x00080000 +#define PCIEM_LINK_CAP_DL_ACTIVE 0x00100000 +#define PCIEM_LINK_CAP_LINK_BW_NOTIFY 0x00200000 +#define PCIEM_LINK_CAP_ASPM_COMPLIANCE 0x00400000 +#define PCIEM_LINK_CAP_PORT 0xff000000 +#define PCIER_LINK_CTL 0x10 +#define PCIEM_LINK_CTL_ASPMC_DIS 0x0000 +#define PCIEM_LINK_CTL_ASPMC_L0S 0x0001 +#define PCIEM_LINK_CTL_ASPMC_L1 0x0002 +#define PCIEM_LINK_CTL_ASPMC 0x0003 +#define PCIEM_LINK_CTL_RCB 0x0008 +#define PCIEM_LINK_CTL_LINK_DIS 0x0010 +#define PCIEM_LINK_CTL_RETRAIN_LINK 0x0020 +#define PCIEM_LINK_CTL_COMMON_CLOCK 0x0040 +#define PCIEM_LINK_CTL_EXTENDED_SYNC 0x0080 +#define PCIEM_LINK_CTL_ECPM 0x0100 +#define PCIEM_LINK_CTL_HAWD 0x0200 +#define PCIEM_LINK_CTL_LBMIE 0x0400 +#define PCIEM_LINK_CTL_LABIE 0x0800 +#define PCIER_LINK_STA 0x12 +#define PCIEM_LINK_STA_SPEED 0x000f +#define PCIEM_LINK_STA_WIDTH 0x03f0 +#define PCIEM_LINK_STA_TRAINING_ERROR 0x0400 +#define PCIEM_LINK_STA_TRAINING 0x0800 +#define PCIEM_LINK_STA_SLOT_CLOCK 0x1000 +#define PCIEM_LINK_STA_DL_ACTIVE 0x2000 +#define PCIEM_LINK_STA_LINK_BW_MGMT 0x4000 +#define PCIEM_LINK_STA_LINK_AUTO_BW 0x8000 +#define PCIER_SLOT_CAP 0x14 +#define PCIEM_SLOT_CAP_APB 0x00000001 +#define PCIEM_SLOT_CAP_PCP 0x00000002 +#define PCIEM_SLOT_CAP_MRLSP 0x00000004 +#define PCIEM_SLOT_CAP_AIP 0x00000008 +#define PCIEM_SLOT_CAP_PIP 0x00000010 +#define PCIEM_SLOT_CAP_HPS 0x00000020 +#define PCIEM_SLOT_CAP_HPC 0x00000040 +#define PCIEM_SLOT_CAP_SPLV 0x00007f80 +#define PCIEM_SLOT_CAP_SPLS 0x00018000 +#define PCIEM_SLOT_CAP_EIP 0x00020000 +#define PCIEM_SLOT_CAP_NCCS 0x00040000 +#define PCIEM_SLOT_CAP_PSN 0xfff80000 +#define PCIER_SLOT_CTL 0x18 +#define PCIEM_SLOT_CTL_ABPE 0x0001 +#define PCIEM_SLOT_CTL_PFDE 0x0002 +#define PCIEM_SLOT_CTL_MRLSCE 0x0004 +#define PCIEM_SLOT_CTL_PDCE 0x0008 +#define PCIEM_SLOT_CTL_CCIE 0x0010 +#define PCIEM_SLOT_CTL_HPIE 0x0020 +#define PCIEM_SLOT_CTL_AIC 0x00c0 +#define PCIEM_SLOT_CTL_PIC 0x0300 +#define PCIEM_SLOT_CTL_PCC 0x0400 +#define PCIEM_SLOT_CTL_EIC 0x0800 +#define PCIEM_SLOT_CTL_DLLSCE 0x1000 +#define PCIER_SLOT_STA 0x1a +#define PCIEM_SLOT_STA_ABP 0x0001 +#define PCIEM_SLOT_STA_PFD 0x0002 +#define PCIEM_SLOT_STA_MRLSC 0x0004 +#define PCIEM_SLOT_STA_PDC 0x0008 +#define PCIEM_SLOT_STA_CC 0x0010 +#define PCIEM_SLOT_STA_MRLSS 0x0020 +#define PCIEM_SLOT_STA_PDS 0x0040 +#define PCIEM_SLOT_STA_EIS 0x0080 +#define PCIEM_SLOT_STA_DLLSC 0x0100 +#define PCIER_ROOT_CTL 0x1c +#define PCIEM_ROOT_CTL_SERR_CORR 0x0001 +#define PCIEM_ROOT_CTL_SERR_NONFATAL 0x0002 +#define PCIEM_ROOT_CTL_SERR_FATAL 0x0004 +#define PCIEM_ROOT_CTL_PME 0x0008 +#define PCIEM_ROOT_CTL_CRS_VIS 0x0010 +#define PCIER_ROOT_CAP 0x1e +#define PCIEM_ROOT_CAP_CRS_VIS 0x0001 +#define PCIER_ROOT_STA 0x20 +#define PCIEM_ROOT_STA_PME_REQID_MASK 0x0000ffff +#define PCIEM_ROOT_STA_PME_STATUS 0x00010000 +#define PCIEM_ROOT_STA_PME_PEND 0x00020000 +#define PCIER_DEVICE_CAP2 0x24 +#define PCIEM_CAP2_ARI 0x20 +#define PCIER_DEVICE_CTL2 0x28 +#define PCIEM_CTL2_COMP_TIMEOUT_VAL 0x000f +#define PCIEM_CTL2_COMP_TIMEOUT_DIS 0x0010 +#define PCIEM_CTL2_ARI 0x0020 +#define PCIEM_CTL2_ATOMIC_REQ_ENABLE 0x0040 +#define PCIEM_CTL2_ATOMIC_EGR_BLOCK 0x0080 +#define PCIEM_CTL2_ID_ORDERED_REQ_EN 0x0100 +#define PCIEM_CTL2_ID_ORDERED_CMP_EN 0x0200 +#define PCIEM_CTL2_LTR_ENABLE 0x0400 +#define PCIEM_CTL2_OBFF 0x6000 +#define PCIEM_OBFF_DISABLE 0x0000 +#define PCIEM_OBFF_MSGA_ENABLE 0x2000 +#define PCIEM_OBFF_MSGB_ENABLE 0x4000 +#define PCIEM_OBFF_WAKE_ENABLE 0x6000 +#define PCIEM_CTL2_END2END_TLP 0x8000 +#define PCIER_DEVICE_STA2 0x2a +#define PCIER_LINK_CAP2 0x2c +#define PCIER_LINK_CTL2 0x30 +#define PCIER_LINK_STA2 0x32 +#define PCIER_SLOT_CAP2 0x34 +#define PCIER_SLOT_CTL2 0x38 +#define PCIER_SLOT_STA2 0x3a + +/* MSI-X definitions */ +#define PCIR_MSIX_CTRL 0x2 +#define PCIM_MSIXCTRL_MSIX_ENABLE 0x8000 +#define PCIM_MSIXCTRL_FUNCTION_MASK 0x4000 +#define PCIM_MSIXCTRL_TABLE_SIZE 0x07FF +#define PCIR_MSIX_TABLE 0x4 +#define PCIR_MSIX_PBA 0x8 +#define PCIM_MSIX_BIR_MASK 0x7 +#define PCIM_MSIX_BIR_BAR_10 0 +#define PCIM_MSIX_BIR_BAR_14 1 +#define PCIM_MSIX_BIR_BAR_18 2 +#define PCIM_MSIX_BIR_BAR_1C 3 +#define PCIM_MSIX_BIR_BAR_20 4 +#define PCIM_MSIX_BIR_BAR_24 5 +#define PCIM_MSIX_VCTRL_MASK 0x1 + +/* PCI Advanced Features definitions */ +#define PCIR_PCIAF_CAP 0x3 +#define PCIM_PCIAFCAP_TP 0x01 +#define PCIM_PCIAFCAP_FLR 0x02 +#define PCIR_PCIAF_CTRL 0x4 +#define PCIR_PCIAFCTRL_FLR 0x01 +#define PCIR_PCIAF_STATUS 0x5 +#define PCIR_PCIAFSTATUS_TP 0x01 + +/* Advanced Error Reporting */ +#define PCIR_AER_UC_STATUS 0x04 +#define PCIM_AER_UC_TRAINING_ERROR 0x00000001 +#define PCIM_AER_UC_DL_PROTOCOL_ERROR 0x00000010 +#define PCIM_AER_UC_SURPRISE_LINK_DOWN 0x00000020 +#define PCIM_AER_UC_POISONED_TLP 0x00001000 +#define PCIM_AER_UC_FC_PROTOCOL_ERROR 0x00002000 +#define PCIM_AER_UC_COMPLETION_TIMEOUT 0x00004000 +#define PCIM_AER_UC_COMPLETER_ABORT 0x00008000 +#define PCIM_AER_UC_UNEXPECTED_COMPLETION 0x00010000 +#define PCIM_AER_UC_RECEIVER_OVERFLOW 0x00020000 +#define PCIM_AER_UC_MALFORMED_TLP 0x00040000 +#define PCIM_AER_UC_ECRC_ERROR 0x00080000 +#define PCIM_AER_UC_UNSUPPORTED_REQUEST 0x00100000 +#define PCIM_AER_UC_ACS_VIOLATION 0x00200000 +#define PCIM_AER_UC_INTERNAL_ERROR 0x00400000 +#define PCIM_AER_UC_MC_BLOCKED_TLP 0x00800000 +#define PCIM_AER_UC_ATOMIC_EGRESS_BLK 0x01000000 +#define PCIM_AER_UC_TLP_PREFIX_BLOCKED 0x02000000 +#define PCIR_AER_UC_MASK 0x08 /* Shares bits with UC_STATUS */ +#define PCIR_AER_UC_SEVERITY 0x0c /* Shares bits with UC_STATUS */ +#define PCIR_AER_COR_STATUS 0x10 +#define PCIM_AER_COR_RECEIVER_ERROR 0x00000001 +#define PCIM_AER_COR_BAD_TLP 0x00000040 +#define PCIM_AER_COR_BAD_DLLP 0x00000080 +#define PCIM_AER_COR_REPLAY_ROLLOVER 0x00000100 +#define PCIM_AER_COR_REPLAY_TIMEOUT 0x00001000 +#define PCIM_AER_COR_ADVISORY_NF_ERROR 0x00002000 +#define PCIM_AER_COR_INTERNAL_ERROR 0x00004000 +#define PCIM_AER_COR_HEADER_LOG_OVFLOW 0x00008000 +#define PCIR_AER_COR_MASK 0x14 /* Shares bits with COR_STATUS */ +#define PCIR_AER_CAP_CONTROL 0x18 +#define PCIM_AER_FIRST_ERROR_PTR 0x0000001f +#define PCIM_AER_ECRC_GEN_CAPABLE 0x00000020 +#define PCIM_AER_ECRC_GEN_ENABLE 0x00000040 +#define PCIM_AER_ECRC_CHECK_CAPABLE 0x00000080 +#define PCIM_AER_ECRC_CHECK_ENABLE 0x00000100 +#define PCIM_AER_MULT_HDR_CAPABLE 0x00000200 +#define PCIM_AER_MULT_HDR_ENABLE 0x00000400 +#define PCIM_AER_TLP_PREFIX_LOG_PRESENT 0x00000800 +#define PCIR_AER_HEADER_LOG 0x1c +#define PCIR_AER_ROOTERR_CMD 0x2c /* Only for root complex ports */ +#define PCIM_AER_ROOTERR_COR_ENABLE 0x00000001 +#define PCIM_AER_ROOTERR_NF_ENABLE 0x00000002 +#define PCIM_AER_ROOTERR_F_ENABLE 0x00000004 +#define PCIR_AER_ROOTERR_STATUS 0x30 /* Only for root complex ports */ +#define PCIM_AER_ROOTERR_COR_ERR 0x00000001 +#define PCIM_AER_ROOTERR_MULTI_COR_ERR 0x00000002 +#define PCIM_AER_ROOTERR_UC_ERR 0x00000004 +#define PCIM_AER_ROOTERR_MULTI_UC_ERR 0x00000008 +#define PCIM_AER_ROOTERR_FIRST_UC_FATAL 0x00000010 +#define PCIM_AER_ROOTERR_NF_ERR 0x00000020 +#define PCIM_AER_ROOTERR_F_ERR 0x00000040 +#define PCIM_AER_ROOTERR_INT_MESSAGE 0xf8000000 +#define PCIR_AER_COR_SOURCE_ID 0x34 /* Only for root complex ports */ +#define PCIR_AER_ERR_SOURCE_ID 0x36 /* Only for root complex ports */ +#define PCIR_AER_TLP_PREFIX_LOG 0x38 /* Only for TLP prefix functions */ + +/* Virtual Channel definitions */ +#define PCIR_VC_CAP1 0x04 +#define PCIM_VC_CAP1_EXT_COUNT 0x00000007 +#define PCIM_VC_CAP1_LOWPRI_EXT_COUNT 0x00000070 +#define PCIR_VC_CAP2 0x08 +#define PCIR_VC_CONTROL 0x0C +#define PCIR_VC_STATUS 0x0E +#define PCIR_VC_RESOURCE_CAP(n) (0x10 + (n) * 0x0C) +#define PCIR_VC_RESOURCE_CTL(n) (0x14 + (n) * 0x0C) +#define PCIR_VC_RESOURCE_STA(n) (0x18 + (n) * 0x0C) + +/* Serial Number definitions */ +#define PCIR_SERIAL_LOW 0x04 +#define PCIR_SERIAL_HIGH 0x08 + +#endif /* __PCI_REG_H__*/ diff --git a/cpukit/include/rpc/auth.h b/cpukit/include/rpc/auth.h new file mode 100644 index 0000000000..13432bd5d0 --- /dev/null +++ b/cpukit/include/rpc/auth.h @@ -0,0 +1,262 @@ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)auth.h 1.17 88/02/08 SMI + * from: @(#)auth.h 2.3 88/08/07 4.0 RPCSRC + * $FreeBSD: src/include/rpc/auth.h,v 1.15 1999/08/27 23:45:02 peter Exp $ + */ + +/* + * auth.h, Authentication interface. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + * + * The data structures are completely opaque to the client. The client + * is required to pass a AUTH * to routines that create rpc + * "sessions". + */ + +#ifndef _RPC_AUTH_H +#define _RPC_AUTH_H +#include +#include +#include + +#define MAX_AUTH_BYTES 400 +#define MAXNETNAMELEN 255 /* maximum length of network user's name */ + +/* + * Status returned from authentication check + */ +enum auth_stat { + AUTH_OK=0, + /* + * failed at remote end + */ + AUTH_BADCRED=1, /* bogus credentials (seal broken) */ + AUTH_REJECTEDCRED=2, /* client should begin new session */ + AUTH_BADVERF=3, /* bogus verifier (seal broken) */ + AUTH_REJECTEDVERF=4, /* verifier expired or was replayed */ + AUTH_TOOWEAK=5, /* rejected due to security reasons */ + /* + * failed locally + */ + AUTH_INVALIDRESP=6, /* bogus response verifier */ + AUTH_FAILED=7, /* some unknown reason */ + _AUTH_STAT = 0xffffffff +}; + +union des_block { + struct { + u_int32_t high; + u_int32_t low; + } key; + char c[8]; +}; +typedef union des_block des_block; +__BEGIN_DECLS +extern bool_t xdr_des_block (XDR *, des_block *); +__END_DECLS + +/* + * Authentication info. Opaque to client. + */ +struct opaque_auth { + enum_t oa_flavor; /* flavor of auth */ + caddr_t oa_base; /* address of more auth stuff */ + u_int oa_length; /* not to exceed MAX_AUTH_BYTES */ +}; +__BEGIN_DECLS +bool_t xdr_opaque_auth (XDR *xdrs, struct opaque_auth *ap); +__END_DECLS + + +/* + * Auth handle, interface to client side authenticators. + */ +typedef struct __rpc_auth { + struct opaque_auth ah_cred; + struct opaque_auth ah_verf; + union des_block ah_key; + struct auth_ops { + void (*ah_nextverf) (struct __rpc_auth *); + /* nextverf & serialize */ + int (*ah_marshal) (struct __rpc_auth *, XDR *); + /* validate verifier */ + int (*ah_validate) (struct __rpc_auth *, + struct opaque_auth *); + /* refresh credentials */ + int (*ah_refresh) (struct __rpc_auth *); + /* destroy this structure */ + void (*ah_destroy) (struct __rpc_auth *); + } *ah_ops; + caddr_t ah_private; +} AUTH; + + +/* + * Authentication ops. + * The ops and the auth handle provide the interface to the authenticators. + * + * AUTH *auth; + * XDR *xdrs; + * struct opaque_auth verf; + */ +#define AUTH_NEXTVERF(auth) \ + ((*((auth)->ah_ops->ah_nextverf))(auth)) +#define auth_nextverf(auth) \ + ((*((auth)->ah_ops->ah_nextverf))(auth)) + +#define AUTH_MARSHALL(auth, xdrs) \ + ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) +#define auth_marshall(auth, xdrs) \ + ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) + +#define AUTH_VALIDATE(auth, verfp) \ + ((*((auth)->ah_ops->ah_validate))((auth), verfp)) +#define auth_validate(auth, verfp) \ + ((*((auth)->ah_ops->ah_validate))((auth), verfp)) + +#define AUTH_REFRESH(auth) \ + ((*((auth)->ah_ops->ah_refresh))(auth)) +#define auth_refresh(auth) \ + ((*((auth)->ah_ops->ah_refresh))(auth)) + +#define AUTH_DESTROY(auth) \ + ((*((auth)->ah_ops->ah_destroy))(auth)) +#define auth_destroy(auth) \ + ((*((auth)->ah_ops->ah_destroy))(auth)) + + +extern struct opaque_auth _null_auth; + +/* + * These are the various implementations of client side authenticators. + */ + +/* + * Unix style authentication + * AUTH *authunix_create(machname, uid, gid, len, aup_gids) + * char *machname; + * int uid; + * int gid; + * int len; + * int *aup_gids; + */ +__BEGIN_DECLS +struct sockaddr_in; +extern AUTH *authunix_create (char *, int, int, int, int *); +extern AUTH *authunix_create_default (void); +extern AUTH *authnone_create (void); +__END_DECLS + +/* Forward compatibility with TI-RPC */ +#define authsys_create authunix_create +#define authsys_create_default authunix_create_default + +/* + * DES style authentication + * AUTH *authdes_create(servername, window, timehost, ckey) + * char *servername; - network name of server + * u_int window; - time to live + * struct sockaddr *timehost; - optional hostname to sync with + * des_block *ckey; - optional conversation key to use + */ +__BEGIN_DECLS +extern AUTH *authdes_create ( char *, u_int, struct sockaddr *, des_block * ); +#ifdef NOTYET +/* + * TI-RPC supports this call, but it requires the inclusion of + * NIS+-specific headers which would require the inclusion of other + * headers which would result in a tangled mess. For now, the NIS+ + * code prototypes this routine internally. + */ +extern AUTH *authdes_pk_create ( char *, netobj *, u_int, + struct sockaddr *, des_block *, + nis_server * ); +#endif +__END_DECLS + +/* + * Netname manipulation routines. + */ +__BEGIN_DECLS +extern int netname2user ( char *, uid_t *, gid_t *, int *, gid_t *); +extern int netname2host ( char *, char *, int ); +extern int getnetname ( char * ); +extern int user2netname ( char *, uid_t, char * ); +extern int host2netname ( char *, char *, char * ); +extern void passwd2des ( char *, char * ); +__END_DECLS + +/* + * Keyserv interface routines. + * XXX Should not be here. + */ +#ifndef HEXKEYBYTES +#define HEXKEYBYTES 48 +#endif +typedef char kbuf[HEXKEYBYTES]; +typedef char *namestr; + +struct netstarg { + kbuf st_priv_key; + kbuf st_pub_key; + namestr st_netname; +}; + +__BEGIN_DECLS +extern int key_decryptsession ( const char *, des_block * ); +extern int key_decryptsession_pk ( char *, netobj *, des_block * ); +extern int key_encryptsession ( const char *, des_block * ); +extern int key_encryptsession_pk ( char *, netobj *, des_block * ); +extern int key_gendes ( des_block * ); +extern int key_setsecret ( const char * ); +extern int key_secretkey_is_set ( void ); +extern int key_setnet ( struct netstarg * ); +extern int key_get_conv ( char *, des_block * ); +__END_DECLS + +/* + * Publickey routines. + */ +__BEGIN_DECLS +extern int getpublickey ( char *, char * ); +extern int getpublicandprivatekey ( char *, char * ); +extern int getsecretkey ( char *, char *, char * ); +__END_DECLS + + +#define AUTH_NONE 0 /* no authentication */ +#define AUTH_NULL 0 /* backward compatibility */ +#define AUTH_UNIX 1 /* unix style (uid, gids) */ +#define AUTH_SYS 1 /* forward compatibility */ +#define AUTH_SHORT 2 /* short hand unix style */ +#define AUTH_DES 3 /* des style (encrypted timestamps) */ + +#endif /* !_RPC_AUTH_H */ diff --git a/cpukit/include/rpc/auth_unix.h b/cpukit/include/rpc/auth_unix.h new file mode 100644 index 0000000000..f822f3dd60 --- /dev/null +++ b/cpukit/include/rpc/auth_unix.h @@ -0,0 +1,85 @@ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)auth_unix.h 1.8 88/02/08 SMI + * from: @(#)auth_unix.h 2.2 88/07/29 4.0 RPCSRC + * $FreeBSD: src/include/rpc/auth_unix.h,v 1.10 1999/08/27 23:45:03 peter Exp $ + */ + +/* + * auth_unix.h, Protocol for UNIX style authentication parameters for RPC + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +/* + * The system is very weak. The client uses no encryption for it + * credentials and only sends null verifiers. The server sends backs + * null verifiers or optionally a verifier that suggests a new short hand + * for the credentials. + */ + +#ifndef _RPC_AUTH_UNIX_H +#define _RPC_AUTH_UNIX_H +#include +#include /* opaque_auth */ + +/* The machine name is part of a credential; it may not exceed 255 bytes */ +#define MAX_MACHINE_NAME 255 + +/* gids compose part of a credential; there may not be more than 16 of them */ +#define NGRPS 16 + +/* + * Unix style credentials. + */ +struct authunix_parms { + u_long aup_time; + char *aup_machname; + int aup_uid; + int aup_gid; + u_int aup_len; + int *aup_gids; +}; + +#define authsys_parms authunix_parms + +__BEGIN_DECLS +extern bool_t xdr_authunix_parms(XDR *, struct authunix_parms *); +__END_DECLS + +/* + * If a response verifier has flavor AUTH_SHORT, + * then the body of the response verifier encapsulates the following structure; + * again it is serialized in the obvious fashion. + */ +struct short_hand_verf { + struct opaque_auth new_cred; +}; + +#endif /* !_RPC_AUTH_UNIX_H */ diff --git a/cpukit/include/rpc/clnt.h b/cpukit/include/rpc/clnt.h new file mode 100644 index 0000000000..3042abe1b6 --- /dev/null +++ b/cpukit/include/rpc/clnt.h @@ -0,0 +1,310 @@ +/* $NetBSD: clnt.h,v 1.14 2000/06/02 22:57:55 fvdl Exp $ */ + +/* + * The contents of this file are subject to the Sun Standards + * License Version 1.0 the (the "License";) You may not use + * this file except in compliance with the License. You may + * obtain a copy of the License at lib/libc/rpc/LICENSE + * + * Software distributed under the License is distributed on + * an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either + * express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * The Original Code is Copyright 1998 by Sun Microsystems, Inc + * + * The Initial Developer of the Original Code is: Sun + * Microsystems, Inc. + * + * All Rights Reserved. + * + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)clnt.h 1.31 94/04/29 SMI + * from: @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC + * $FreeBSD: src/include/rpc/clnt.h,v 1.21 2003/01/24 01:47:55 fjoe Exp $ + */ + +/* + * clnt.h - Client side remote procedure call interface. + * + * Copyright (c) 1986-1991,1994-1999 by Sun Microsystems, Inc. + * All rights reserved. + */ + + +#ifndef _RPC_CLNT_H_ +#define _RPC_CLNT_H_ +#include +#include +#include +#include /* auth_stat */ + +/* + * Error info. + */ +struct rpc_err { + enum clnt_stat re_status; + union { + int RE_errno; /* related system error */ + enum auth_stat RE_why; /* why the auth error occurred */ + struct { + rpcvers_t low; /* lowest version supported */ + rpcvers_t high; /* highest version supported */ + } RE_vers; + struct { /* maybe meaningful if RPC_FAILED */ + int32_t s1; + int32_t s2; + } RE_lb; /* life boot & debugging only */ + } ru; +#define re_errno ru.RE_errno +#define re_why ru.RE_why +#define re_vers ru.RE_vers +#define re_lb ru.RE_lb +}; + + +/* + * Client rpc handle. + * Created by individual implementations + * Client is responsible for initializing auth, see e.g. auth_none.c. + */ +typedef struct __rpc_client { + AUTH *cl_auth; /* authenticator */ + struct clnt_ops { + /* call remote procedure */ + enum clnt_stat (*cl_call)(struct __rpc_client *, + rpcproc_t, xdrproc_t, void *, xdrproc_t, + void *, struct timeval); + /* abort a call */ + void (*cl_abort)(void); + /* get specific error code */ + void (*cl_geterr)(struct __rpc_client *, + struct rpc_err *); + /* frees results */ + bool_t (*cl_freeres)(struct __rpc_client *, + xdrproc_t, void *); + /* destroy this structure */ + void (*cl_destroy)(struct __rpc_client *); + /* the ioctl() of rpc */ + bool_t (*cl_control)(struct __rpc_client *, int, + char *); + } *cl_ops; + void *cl_private; /* private stuff */ +} CLIENT; + +#define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */ + +/* + * client side rpc interface ops + * + * Parameter types are: + * + */ + +/* + * enum clnt_stat + * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout) + * CLIENT *rh; + * rpcproc_t proc; + * xdrproc_t xargs; + * void *argsp; + * xdrproc_t xres; + * void *resp; + * struct timeval timeout; + */ +#define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \ + ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, \ + argsp, xres, resp, secs)) +#define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \ + ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, \ + argsp, xres, resp, secs)) + +/* + * void + * CLNT_ABORT(rh); + * CLIENT *rh; + */ +#define CLNT_ABORT(rh) ((*(rh)->cl_ops->cl_abort)(rh)) +#define clnt_abort(rh) ((*(rh)->cl_ops->cl_abort)(rh)) + +/* + * struct rpc_err + * CLNT_GETERR(rh); + * CLIENT *rh; + */ +#define CLNT_GETERR(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) +#define clnt_geterr(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) + + +/* + * bool_t + * CLNT_FREERES(rh, xres, resp); + * CLIENT *rh; + * xdrproc_t xres; + * void *resp; + */ +#define CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) +#define clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) + +/* + * bool_t + * CLNT_CONTROL(cl, request, info) + * CLIENT *cl; + * u_int request; + * char *info; + */ +#define CLNT_CONTROL(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) +#define clnt_control(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) + +/* + * control operations that apply to udp, tcp and unix transports + * + * Note: options marked XXX are no-ops in this implementation of RPC. + * The are present in TI-RPC but can't be implemented here since they + * depend on the presence of STREAMS/TLI, which we don't have. + * + */ +#define CLSET_TIMEOUT 1 /* set timeout (timeval) */ +#define CLGET_TIMEOUT 2 /* get timeout (timeval) */ +#define CLGET_SERVER_ADDR 3 /* get server's address (sockaddr) */ +#define CLGET_FD 6 /* get connections file descriptor */ +#define CLGET_SVC_ADDR 7 /* get server's address (netbuf) */ +#define CLSET_FD_CLOSE 8 /* close fd while clnt_destroy */ +#define CLSET_FD_NCLOSE 9 /* Do not close fd while clnt_destroy */ +#define CLGET_XID 10 /* Get xid */ +#define CLSET_XID 11 /* Set xid */ +#define CLGET_VERS 12 /* Get version number */ +#define CLSET_VERS 13 /* Set version number */ +#define CLGET_PROG 14 /* Get program number */ +#define CLSET_PROG 15 /* Set program number */ +#define CLSET_SVC_ADDR 16 /* get server's address (netbuf) XXX */ +#define CLSET_PUSH_TIMOD 17 /* push timod if not already present XXX */ +#define CLSET_POP_TIMOD 18 /* pop timod XXX */ + +/* + * Connectionless only control operations + */ +#define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */ +#define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */ + +/* + * Operations which GSSAPI needs. (Bletch.) + */ +#define CLGET_LOCAL_ADDR 19 /* get local addr (sockaddr) */ + + +/* + * void + * CLNT_DESTROY(rh); + * CLIENT *rh; + */ +#define CLNT_DESTROY(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) +#define clnt_destroy(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) + + +/* + * RPCTEST is a test program which is accessible on every rpc + * transport/port. It is used for testing, performance evaluation, + * and network administration. + */ + +#define RPCTEST_PROGRAM ((rpcprog_t)1) +#define RPCTEST_VERSION ((rpcvers_t)1) +#define RPCTEST_NULL_PROC ((rpcproc_t)2) +#define RPCTEST_NULL_BATCH_PROC ((rpcproc_t)3) + +/* + * By convention, procedure 0 takes null arguments and returns them + */ + +#define NULLPROC ((rpcproc_t)0) + +/* + * Below are the client handle creation routines for the various + * implementations of client side rpc. They can return NULL if a + * creation failure occurs. + */ + +/* + * Generic client creation routine. Supported protocols are "udp", "tcp" + * and "unix". + */ +__BEGIN_DECLS +extern CLIENT *clnt_create(const char *, const rpcprog_t, const rpcvers_t, + const char *); +__END_DECLS + +/* + * Added for compatibility to old rpc 4.0. Obsoleted by clnt_vc_create(). + */ +__BEGIN_DECLS +extern CLIENT *clntunix_create(struct sockaddr_un *, + u_long, u_long, int *, u_int, u_int); +__END_DECLS + + +/* + * Print why creation failed + */ +__BEGIN_DECLS +extern void clnt_pcreateerror(const char *); /* stderr */ +extern char *clnt_spcreateerror(const char *); /* string */ +__END_DECLS + +/* + * Like clnt_perror(), but is more verbose in its output + */ +__BEGIN_DECLS +extern void clnt_perrno(enum clnt_stat); /* stderr */ +extern char *clnt_sperrno(enum clnt_stat); /* string */ +__END_DECLS + +/* + * Print an English error message, given the client error code + */ +__BEGIN_DECLS +extern void clnt_perror(CLIENT *, const char *); /* stderr */ +extern char *clnt_sperror(CLIENT *, const char *); /* string */ +__END_DECLS + + +/* + * If a creation fails, the following allows the user to figure out why. + */ +struct rpc_createerr { + enum clnt_stat cf_stat; + struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */ +}; + +extern struct rpc_createerr rpc_createerr; + +/* For backward compatibility */ +#include + +#endif /* !_RPC_CLNT_H_ */ diff --git a/cpukit/include/rpc/clnt_soc.h b/cpukit/include/rpc/clnt_soc.h new file mode 100644 index 0000000000..9aa99b88ba --- /dev/null +++ b/cpukit/include/rpc/clnt_soc.h @@ -0,0 +1,109 @@ +/* $NetBSD: clnt_soc.h,v 1.1 2000/06/02 22:57:55 fvdl Exp $ */ +/* $FreeBSD: src/include/rpc/clnt_soc.h,v 1.2 2002/03/23 17:24:55 imp Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* + * Copyright (c) 1984 - 1991 by Sun Microsystems, Inc. + */ + +/* + * clnt.h - Client side remote procedure call interface. + */ + +#ifndef _RPC_CLNT_SOC_H +#define _RPC_CLNT_SOC_H + +#include + +/* derived from clnt_soc.h 1.3 88/12/17 SMI */ + +/* + * All the following declarations are only for backward compatibility + * with TS-RPC. + */ + +#include +#include + +#define UDPMSGSIZE 8800 /* rpc imposed limit on udp msg size */ + +/* + * TCP based rpc + * CLIENT * + * clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz) + * struct sockaddr_in *raddr; + * u_long prog; + * u_long version; + * register int *sockp; + * u_int sendsz; + * u_int recvsz; + */ +__BEGIN_DECLS +extern CLIENT *clnttcp_create(struct sockaddr_in *, u_long, u_long, int *, + u_int, u_int); +__END_DECLS + +/* + * Raw (memory) rpc. + */ +__BEGIN_DECLS +extern CLIENT *clntraw_create(u_long, u_long); +__END_DECLS + + +/* + * UDP based rpc. + * CLIENT * + * clntudp_create(raddr, program, version, wait, sockp) + * struct sockaddr_in *raddr; + * u_long program; + * u_long version; + * struct timeval wait; + * int *sockp; + * + * Same as above, but you specify max packet sizes. + * CLIENT * + * clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz) + * struct sockaddr_in *raddr; + * u_long program; + * u_long version; + * struct timeval wait; + * int *sockp; + * u_int sendsz; + * u_int recvsz; + */ +__BEGIN_DECLS +extern CLIENT *clntudp_create(struct sockaddr_in *, u_long, u_long, + struct timeval, int *); +extern CLIENT *clntudp_bufcreate(struct sockaddr_in *, u_long, u_long, + struct timeval, int *, u_int, u_int); +__END_DECLS + +#endif /* _RPC_CLNT_SOC_H */ diff --git a/cpukit/include/rpc/clnt_stat.h b/cpukit/include/rpc/clnt_stat.h new file mode 100644 index 0000000000..2c68745407 --- /dev/null +++ b/cpukit/include/rpc/clnt_stat.h @@ -0,0 +1,84 @@ +/* $FreeBSD: src/include/rpc/clnt_stat.h,v 1.2 2001/03/20 08:20:50 alfred Exp $ */ +/* + * Copyright (c) 1986 - 1991, 1994, 1996, 1997 by Sun Microsystems, Inc. + * All rights reserved. + */ + +/* + * clnt_stat.h - Client side remote procedure call enum + * + */ + +#ifndef _RPC_CLNT_STAT_H +#define _RPC_CLNT_STAT_H + +/* #pragma ident "@(#)clnt_stat.h 1.2 97/04/28 SMI" */ + +#ifdef __cplusplus +extern "C" { +#endif + +enum clnt_stat { + RPC_SUCCESS = 0, /* call succeeded */ + /* + * local errors + */ + RPC_CANTENCODEARGS = 1, /* can't encode arguments */ + RPC_CANTDECODERES = 2, /* can't decode results */ + RPC_CANTSEND = 3, /* failure in sending call */ + RPC_CANTRECV = 4, + /* failure in receiving result */ + RPC_TIMEDOUT = 5, /* call timed out */ + RPC_INTR = 18, /* call interrupted */ + RPC_UDERROR = 23, /* recv got uderr indication */ + /* + * remote errors + */ + RPC_VERSMISMATCH = 6, /* rpc versions not compatible */ + RPC_AUTHERROR = 7, /* authentication error */ + RPC_PROGUNAVAIL = 8, /* program not available */ + RPC_PROGVERSMISMATCH = 9, /* program version mismatched */ + RPC_PROCUNAVAIL = 10, /* procedure unavailable */ + RPC_CANTDECODEARGS = 11, /* decode arguments error */ + RPC_SYSTEMERROR = 12, /* generic "other problem" */ + + /* + * rpc_call & clnt_create errors + */ + RPC_UNKNOWNHOST = 13, /* unknown host name */ + RPC_UNKNOWNPROTO = 17, /* unknown protocol */ + RPC_UNKNOWNADDR = 19, /* Remote address unknown */ + RPC_NOBROADCAST = 21, /* Broadcasting not supported */ + + /* + * rpcbind errors + */ + RPC_RPCBFAILURE = 14, /* the pmapper failed in its call */ +#define RPC_PMAPFAILURE RPC_RPCBFAILURE + RPC_PROGNOTREGISTERED = 15, /* remote program is not registered */ + RPC_N2AXLATEFAILURE = 22, + /* Name to address translation failed */ + /* + * Misc error in the TLI library + */ + RPC_TLIERROR = 20, + /* + * unspecified error + */ + RPC_FAILED = 16, + /* + * asynchronous errors + */ + RPC_INPROGRESS = 24, + RPC_STALERACHANDLE = 25, + RPC_CANTCONNECT = 26, /* couldn't make connection (cots) */ + RPC_XPRTFAILED = 27, /* received discon from remote (cots) */ + RPC_CANTCREATESTREAM = 28, /* can't push rpc module (cots) */ + _CLNT_STAT = 0xffffffff +}; + +#ifdef __cplusplus +} +#endif + +#endif /* !_RPC_CLNT_STAT_H */ diff --git a/cpukit/include/rpc/pmap_clnt.h b/cpukit/include/rpc/pmap_clnt.h new file mode 100644 index 0000000000..86fff6be4f --- /dev/null +++ b/cpukit/include/rpc/pmap_clnt.h @@ -0,0 +1,89 @@ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)pmap_clnt.h 1.11 88/02/08 SMI + * from: @(#)pmap_clnt.h 2.1 88/07/29 4.0 RPCSRC + * $FreeBSD: src/include/rpc/pmap_clnt.h,v 1.11 1999/08/27 23:45:04 peter Exp $ + */ + +/* + * pmap_clnt.h + * Supplies C routines to get to portmap services. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +/* + * Usage: + * success = pmap_set(program, version, protocol, port); + * success = pmap_unset(program, version); + * port = pmap_getport(address, program, version, protocol); + * head = pmap_getmaps(address); + * clnt_stat = pmap_rmtcall(address, program, version, procedure, + * xdrargs, argsp, xdrres, resp, tout, port_ptr) + * (works for udp only.) + * clnt_stat = clnt_broadcast(program, version, procedure, + * xdrargs, argsp, xdrres, resp, eachresult) + * (like pmap_rmtcall, except the call is broadcasted to all + * locally connected nets. For each valid response received, + * the procedure eachresult is called. Its form is: + * done = eachresult(resp, raddr) + * bool_t done; + * caddr_t resp; + * struct sockaddr_in raddr; + * where resp points to the results of the call and raddr is the + * address if the responder to the broadcast. + */ + +#ifndef _RPC_PMAPCLNT_H +#define _RPC_PMAPCLNT_H + +#include +#include /* struct sockaddr_in */ +#include +#include /* xdrproc_t */ + +__BEGIN_DECLS +extern bool_t pmap_set (u_long, u_long, int, int); +extern bool_t pmap_unset (u_long, u_long); +extern struct pmaplist *pmap_getmaps (struct sockaddr_in *); +extern enum clnt_stat pmap_rmtcall (struct sockaddr_in *, + u_long, u_long, u_long, + xdrproc_t, caddr_t, + xdrproc_t, caddr_t, + struct timeval, u_long *); +extern enum clnt_stat clnt_broadcast (u_long, u_long, u_long, + xdrproc_t, char *, + xdrproc_t, char *, + bool_t (*) (caddr_t, + struct sockaddr_in *)); +extern u_short pmap_getport (struct sockaddr_in *, + u_long, u_long, u_int); +__END_DECLS + +#endif /* !_RPC_PMAPCLNT_H */ diff --git a/cpukit/include/rpc/pmap_prot.h b/cpukit/include/rpc/pmap_prot.h new file mode 100644 index 0000000000..14720e8cbd --- /dev/null +++ b/cpukit/include/rpc/pmap_prot.h @@ -0,0 +1,105 @@ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)pmap_prot.h 1.14 88/02/08 SMI + * from: @(#)pmap_prot.h 2.1 88/07/29 4.0 RPCSRC + * $FreeBSD: src/include/rpc/pmap_prot.h,v 1.10 1999/08/27 23:45:04 peter Exp $ + */ + +/* + * pmap_prot.h + * Protocol for the local binder service, or pmap. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + * + * The following procedures are supported by the protocol: + * + * PMAPPROC_NULL() returns () + * takes nothing, returns nothing + * + * PMAPPROC_SET(struct pmap) returns (bool_t) + * TRUE is success, FALSE is failure. Registers the tuple + * [prog, vers, prot, port]. + * + * PMAPPROC_UNSET(struct pmap) returns (bool_t) + * TRUE is success, FALSE is failure. Un-registers pair + * [prog, vers]. prot and port are ignored. + * + * PMAPPROC_GETPORT(struct pmap) returns (long unsigned). + * 0 is failure. Otherwise returns the port number where the pair + * [prog, vers] is registered. It may lie! + * + * PMAPPROC_DUMP() RETURNS (struct pmaplist *) + * + * PMAPPROC_CALLIT(unsigned, unsigned, unsigned, string<>) + * RETURNS (port, string<>); + * usage: encapsulatedresults = PMAPPROC_CALLIT(prog, vers, proc, encapsulatedargs); + * Calls the procedure on the local machine. If it is not registered, + * this procedure is quite; ie it does not return error information!!! + * This procedure only is supported on rpc/udp and calls via + * rpc/udp. This routine only passes null authentication parameters. + * This file has no interface to xdr routines for PMAPPROC_CALLIT. + * + * The service supports remote procedure calls on udp/ip or tcp/ip socket 111. + */ + +#ifndef _RPC_PMAPPROT_H +#define _RPC_PMAPPROT_H +#include +#include + +#define PMAPPORT ((u_short)111) +#define PMAPPROG ((u_long)100000) +#define PMAPVERS ((u_long)2) +#define PMAPVERS_PROTO ((u_long)2) +#define PMAPVERS_ORIG ((u_long)1) +#define PMAPPROC_NULL ((u_long)0) +#define PMAPPROC_SET ((u_long)1) +#define PMAPPROC_UNSET ((u_long)2) +#define PMAPPROC_GETPORT ((u_long)3) +#define PMAPPROC_DUMP ((u_long)4) +#define PMAPPROC_CALLIT ((u_long)5) + +struct pmap { + long unsigned pm_prog; + long unsigned pm_vers; + long unsigned pm_prot; + long unsigned pm_port; +}; + +struct pmaplist { + struct pmap pml_map; + struct pmaplist *pml_next; +}; + +__BEGIN_DECLS +extern bool_t xdr_pmap (XDR *, struct pmap *); +extern bool_t xdr_pmaplist (XDR *, struct pmaplist **); +__END_DECLS + +#endif /* !_RPC_PMAPPROT_H */ diff --git a/cpukit/include/rpc/pmap_rmt.h b/cpukit/include/rpc/pmap_rmt.h new file mode 100644 index 0000000000..a5ea404f45 --- /dev/null +++ b/cpukit/include/rpc/pmap_rmt.h @@ -0,0 +1,64 @@ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)pmap_rmt.h 1.2 88/02/08 SMI + * from: @(#)pmap_rmt.h 2.1 88/07/29 4.0 RPCSRC + * $FreeBSD: src/include/rpc/pmap_rmt.h,v 1.10 1999/08/27 23:45:05 peter Exp $ + */ + +/* + * Structures and XDR routines for parameters to and replies from + * the portmapper remote-call-service. + * + * Copyright (C) 1986, Sun Microsystems, Inc. + */ + +#ifndef _RPC_PMAPRMT_H +#define _RPC_PMAPRMT_H +#include +#include + +struct rmtcallargs { + u_long prog, vers, proc, arglen; + caddr_t args_ptr; + xdrproc_t xdr_args; +}; + +struct rmtcallres { + u_long *port_ptr; + u_long resultslen; + caddr_t results_ptr; + xdrproc_t xdr_results; +}; + +__BEGIN_DECLS +extern bool_t xdr_rmtcall_args (XDR *, struct rmtcallargs *); +extern bool_t xdr_rmtcallres (XDR *, struct rmtcallres *); +__END_DECLS + +#endif /* !_RPC_PMAPRMT_H */ diff --git a/cpukit/include/rpc/rpc.h b/cpukit/include/rpc/rpc.h new file mode 100644 index 0000000000..20065efd4d --- /dev/null +++ b/cpukit/include/rpc/rpc.h @@ -0,0 +1,118 @@ +/* $NetBSD: rpc.h,v 1.13 2000/06/02 22:57:56 fvdl Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)rpc.h 1.9 88/02/08 SMI + * from: @(#)rpc.h 2.4 89/07/11 4.0 RPCSRC + * $FreeBSD: src/include/rpc/rpc.h,v 1.17 2002/03/23 17:24:55 imp Exp $ + */ + +/* + * rpc.h, Just includes the billions of rpc header files necessary to + * do remote procedure calling. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ +#ifndef _RPC_RPC_H +#define _RPC_RPC_H + +#include /* some typedefs */ +#include + +/* external data representation interfaces */ +#include /* generic (de)serializer */ + +/* Client side only authentication */ +#include /* generic authenticator (client side) */ + +/* Client side (mostly) remote procedure call */ +#include /* generic rpc stuff */ + +/* semi-private protocol headers */ +#include /* protocol for rpc messages */ +#include /* protocol for unix style cred */ + +/* Server side only remote procedure callee */ +#include /* service manager and multiplexer */ +#include /* service side authenticator */ + +#include + +__BEGIN_DECLS +extern int get_myaddress(struct sockaddr_in *); +extern int bindresvport(int, struct sockaddr_in *); +extern int bindresvport_sa(int, struct sockaddr *); +__END_DECLS + +int rtems_rpc_task_init (void); +int rtems_rpc_start_portmapper (int priority); + +#ifdef _RTEMS_RPC_INTERNAL_ +/* + * Multi-threaded support + * Group all global and static variables into a single spot. + * This area will be allocated on a per-task basis + */ +struct _rtems_rpc_task_variables { + int svc_svc_maxfd; + fd_set svc_svc_fdset; + SVCXPRT ** svc_xports; + int svc_xportssize; + int svc__svc_fdsetsize; + fd_set *svc__svc_fdset; + struct svc_callout *svc_svc_head; + + char *clnt_perror_buf; + + struct clnt_raw_private *clnt_raw_private; + + void *call_rpc_private; + + struct call_rpc_private *svc_raw_private; + + struct prog_lst *svc_simple_proglst; + struct prog_lst *svc_simple_pl; + SVCXPRT *svc_simple_transp; + + char *rpcdname_default_domain; + + struct authsvc *svc_auths_Auths; +}; + +struct _rtems_rpc_task_variables *rtems_rpc_task_variables_get(void); +#define rtems_rpc_task_variables rtems_rpc_task_variables_get() + +#define svc_maxfd (rtems_rpc_task_variables->svc_svc_maxfd) +#define svc_fdset (rtems_rpc_task_variables->svc_svc_fdset) +#define __svc_fdsetsize (rtems_rpc_task_variables->svc__svc_fdsetsize) +#define __svc_fdset (rtems_rpc_task_variables->svc__svc_fdset) + +#endif /* _RTEMS_RPC_INTERNAL_ */ + +#endif /* !_RPC_RPC_H */ diff --git a/cpukit/include/rpc/rpc_com.h b/cpukit/include/rpc/rpc_com.h new file mode 100644 index 0000000000..9a1ce453ab --- /dev/null +++ b/cpukit/include/rpc/rpc_com.h @@ -0,0 +1,65 @@ +/* $NetBSD: rpc_com.h,v 1.3 2000/12/10 04:10:08 christos Exp $ */ +/* $FreeBSD: src/include/rpc/rpc_com.h,v 1.6 2003/01/16 07:13:51 mbr Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. + */ + +/* + * rpc_com.h, Common definitions for both the server and client side. + * All for the topmost layer of rpc + * + */ + +#ifndef _RPC_RPCCOM_H +#define _RPC_RPCCOM_H + +#include + +/* #pragma ident "@(#)rpc_com.h 1.11 93/07/05 SMI" */ + +/* + * The max size of the transport, if the size cannot be determined + * by other means. + */ +#define RPC_MAXDATASIZE 9000 +#define RPC_MAXADDRSIZE 1024 + +__BEGIN_DECLS +extern u_int __rpc_get_a_size(int); +extern u_int __rpc_get_t_size(int, long); +extern int __rpc_dtbsize(void); +extern int _rpc_dtablesize(void); +extern int _rpc_get_default_domain(char **); +__END_DECLS + +#endif /* _RPC_RPCCOM_H */ diff --git a/cpukit/include/rpc/rpc_msg.h b/cpukit/include/rpc/rpc_msg.h new file mode 100644 index 0000000000..63a1f360a0 --- /dev/null +++ b/cpukit/include/rpc/rpc_msg.h @@ -0,0 +1,205 @@ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)rpc_msg.h 1.7 86/07/16 SMI + * from: @(#)rpc_msg.h 2.1 88/07/29 4.0 RPCSRC + * $FreeBSD: src/include/rpc/rpc_msg.h,v 1.15 2003/01/01 18:48:42 schweikh Exp $ + */ + +/* + * rpc_msg.h + * rpc message definition + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_RPC_MSG_H +#define _RPC_RPC_MSG_H + +#include +#include /* xdrproc_t */ +#include /* opaque_auth */ + +struct rpc_err; /* forward */ + +#define RPC_MSG_VERSION ((u_int32_t) 2) +#define RPC_SERVICE_PORT ((u_short) 2048) + +/* + * Bottom up definition of an rpc message. + * NOTE: call and reply use the same overall stuct but + * different parts of unions within it. + */ + +enum msg_type { + CALL=0, + REPLY=1, + _MSG_TYPE = 0xffffffff +}; + +enum reply_stat { + MSG_ACCEPTED=0, + MSG_DENIED=1, + _REPLY_STAT = 0xffffffff +}; + +enum accept_stat { + SUCCESS=0, + PROG_UNAVAIL=1, + PROG_MISMATCH=2, + PROC_UNAVAIL=3, + GARBAGE_ARGS=4, + SYSTEM_ERR=5, + _ACCEPT_STAT = 0xffffffff +}; + +enum reject_stat { + RPC_MISMATCH=0, + AUTH_ERROR=1, + _REJECT_STAT = 0xffffffff +}; + +/* + * Reply part of an rpc exchange + */ + +/* + * Reply to an rpc request that was accepted by the server. + * Note: there could be an error even though the request was + * accepted. + */ +struct accepted_reply { + struct opaque_auth ar_verf; + enum accept_stat ar_stat; + union { + struct { + rpcvers_t low; + rpcvers_t high; + } AR_versions; + struct { + caddr_t where; + xdrproc_t proc; + } AR_results; + /* and many other null cases */ + } ru; +#define ar_results ru.AR_results +#define ar_vers ru.AR_versions +}; + +/* + * Reply to an rpc request that was rejected by the server. + */ +struct rejected_reply { + enum reject_stat rj_stat; + union { + struct { + rpcvers_t low; + rpcvers_t high; + } RJ_versions; + enum auth_stat RJ_why; /* why authentication did not work */ + } ru; +#define rj_vers ru.RJ_versions +#define rj_why ru.RJ_why +}; + +/* + * Body of a reply to an rpc request. + */ +struct reply_body { + enum reply_stat rp_stat; + union { + struct accepted_reply RP_ar; + struct rejected_reply RP_dr; + } ru; +#define rp_acpt ru.RP_ar +#define rp_rjct ru.RP_dr +}; + +/* + * Body of an rpc request call. + */ +struct call_body { + rpcvers_t cb_rpcvers; /* must be equal to two */ + rpcprog_t cb_prog; + rpcvers_t cb_vers; + rpcproc_t cb_proc; + struct opaque_auth cb_cred; + struct opaque_auth cb_verf; /* protocol specific - provided by client */ +}; + +/* + * The rpc message + */ +struct rpc_msg { + u_int32_t rm_xid; + enum msg_type rm_direction; + union { + struct call_body RM_cmb; + struct reply_body RM_rmb; + } ru; +#define rm_call ru.RM_cmb +#define rm_reply ru.RM_rmb +}; +#define acpted_rply ru.RM_rmb.ru.RP_ar +#define rjcted_rply ru.RM_rmb.ru.RP_dr + +__BEGIN_DECLS +/* + * XDR routine to handle a rpc message. + * xdr_callmsg(xdrs, cmsg) + * XDR *xdrs; + * struct rpc_msg *cmsg; + */ +extern bool_t xdr_callmsg(XDR *, struct rpc_msg *); + +/* + * XDR routine to pre-serialize the static part of a rpc message. + * xdr_callhdr(xdrs, cmsg) + * XDR *xdrs; + * struct rpc_msg *cmsg; + */ +extern bool_t xdr_callhdr(XDR *, struct rpc_msg *); + +/* + * XDR routine to handle a rpc reply. + * xdr_replymsg(xdrs, rmsg) + * XDR *xdrs; + * struct rpc_msg *rmsg; + */ +extern bool_t xdr_replymsg(XDR *, struct rpc_msg *); + +/* + * Fills in the error part of a reply message. + * _seterr_reply(msg, error) + * struct rpc_msg *msg; + * struct rpc_err *error; + */ +extern void _seterr_reply(struct rpc_msg *, struct rpc_err *); +__END_DECLS + +#endif /* !_RPC_RPC_MSG_H */ diff --git a/cpukit/include/rpc/rpcent.h b/cpukit/include/rpc/rpcent.h new file mode 100644 index 0000000000..1cf4161b81 --- /dev/null +++ b/cpukit/include/rpc/rpcent.h @@ -0,0 +1,71 @@ +/* $NetBSD: rpcent.h,v 1.1 2000/06/02 22:57:56 fvdl Exp $ */ +/* $FreeBSD: src/include/rpc/rpcent.h,v 1.2 2002/03/23 17:24:55 imp Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* + * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. + */ + +/* + * rpcent.h, + * For converting rpc program numbers to names etc. + * + */ + +#ifndef _RPC_RPCENT_H +#define _RPC_RPCENT_H + +#include + +/* #pragma ident "@(#)rpcent.h 1.13 94/04/25 SMI" */ +/* @(#)rpcent.h 1.1 88/12/06 SMI */ + + +struct rpcent { + char *r_name; /* name of server for this rpc program */ + char **r_aliases; /* alias list */ + int r_number; /* rpc program number */ +}; + +__BEGIN_DECLS +extern struct rpcent *getrpcbyname_r(const char *, struct rpcent *, + char *, int); +extern struct rpcent *getrpcbynumber_r(int, struct rpcent *, char *, int); +extern struct rpcent *getrpcent_r(struct rpcent *, char *, int); + +/* Old interfaces that return a pointer to a static area; MT-unsafe */ +extern struct rpcent *getrpcbyname(char *); +extern struct rpcent *getrpcbynumber(int); +extern struct rpcent *getrpcent(void); +extern void setrpcent(int); +extern void endrpcent(void); +__END_DECLS + +#endif /* !_RPC_CENT_H */ diff --git a/cpukit/include/rpc/svc.h b/cpukit/include/rpc/svc.h new file mode 100644 index 0000000000..0808dddc5c --- /dev/null +++ b/cpukit/include/rpc/svc.h @@ -0,0 +1,297 @@ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)svc.h 1.35 88/12/17 SMI + * from: @(#)svc.h 1.27 94/04/25 SMI + * $FreeBSD: src/include/rpc/svc.h,v 1.24 2003/06/15 10:32:01 mbr Exp $ + */ + +/* + * svc.h, Server-side remote procedure call interface. + * + * Copyright (C) 1986-1993 by Sun Microsystems, Inc. + */ + +#ifndef _RPC_SVC_H +#define _RPC_SVC_H + +#include +#include +#include /* xdrproc_t */ +#include /* fd_set */ +#include /* socklen_t */ +#include /* struct sockaddr_in */ +#include /* auth_stat */ + +/* + * This interface must manage two items concerning remote procedure calling: + * + * 1) An arbitrary number of transport connections upon which rpc requests + * are received. The two most notable transports are TCP and UDP; they are + * created and registered by routines in svc_tcp.c and svc_udp.c, respectively; + * they in turn call xprt_register and xprt_unregister. + * + * 2) An arbitrary number of locally registered services. Services are + * described by the following four data: program number, version number, + * "service dispatch" function, a transport handle, and a boolean that + * indicates whether or not the exported program should be registered with a + * local binder service; if true the program's number and version and the + * port number from the transport handle are registered with the binder. + * These data are registered with the rpc svc system via svc_register. + * + * A service's dispatch function is called whenever an rpc request comes in + * on a transport. The request's program and version numbers must match + * those of the registered service. The dispatch function is passed two + * parameters, struct svc_req * and SVCXPRT *, defined below. + */ + +enum xprt_stat { + XPRT_DIED, + XPRT_MOREREQS, + XPRT_IDLE, + _XPRT_STAT = 0xffffffff +}; + +struct rpc_msg; + +/* + * Server side transport handle + */ +typedef struct __rpc_svcxprt { + int xp_sock; + u_short xp_port; /* associated port number */ + struct xp_ops { + /* receive incoming requests */ + bool_t (*xp_recv)(struct __rpc_svcxprt *, struct rpc_msg *); + /* get transport status */ + enum xprt_stat (*xp_stat)(struct __rpc_svcxprt *); + /* get arguments */ + bool_t (*xp_getargs)(struct __rpc_svcxprt *, xdrproc_t, + caddr_t args_ptr); + /* send reply */ + bool_t (*xp_reply)(struct __rpc_svcxprt *, struct rpc_msg *); + /* free mem allocated for args */ + bool_t (*xp_freeargs)(struct __rpc_svcxprt *, xdrproc_t, + caddr_t args_ptr); + /* destroy this struct */ + void (*xp_destroy)(struct __rpc_svcxprt *); + } *xp_ops; + socklen_t xp_addrlen; /* length of remote address */ + struct sockaddr_in xp_raddr; /* remote addr. (backward ABI compat) */ + struct opaque_auth xp_verf; /* raw response verifier */ + void *xp_p1; /* private: for use by svc ops */ + void *xp_p2; /* private: for use by svc ops */ +} SVCXPRT; + +/* + * Service request + */ +struct svc_req { + u_int32_t rq_prog; /* service program number */ + u_int32_t rq_vers; /* service protocol version */ + u_int32_t rq_proc; /* the desired procedure */ + struct opaque_auth rq_cred; /* raw creds from the wire */ + caddr_t rq_clntcred; /* read only cooked cred */ + SVCXPRT *rq_xprt; /* associated transport */ +}; + + +/* + * Operations defined on an SVCXPRT handle + * + * SVCXPRT *xprt; + * struct rpc_msg *msg; + * xdrproc_t xargs; + * caddr_t argsp; + */ +#define SVC_RECV(xprt, msg) \ + (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) +#define svc_recv(xprt, msg) \ + (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) + +#define SVC_STAT(xprt) \ + (*(xprt)->xp_ops->xp_stat)(xprt) +#define svc_stat(xprt) \ + (*(xprt)->xp_ops->xp_stat)(xprt) + +#define SVC_GETARGS(xprt, xargs, argsp) \ + (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) +#define svc_getargs(xprt, xargs, argsp) \ + (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) + +#define SVC_REPLY(xprt, msg) \ + (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) +#define svc_reply(xprt, msg) \ + (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) + +#define SVC_FREEARGS(xprt, xargs, argsp) \ + (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) +#define svc_freeargs(xprt, xargs, argsp) \ + (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) + +#define SVC_DESTROY(xprt) \ + (*(xprt)->xp_ops->xp_destroy)(xprt) +#define svc_destroy(xprt) \ + (*(xprt)->xp_ops->xp_destroy)(xprt) + +/* + * Transport registration. + * + * xprt_register(xprt) + * SVCXPRT *xprt; + */ +__BEGIN_DECLS +extern void xprt_register(SVCXPRT *); +__END_DECLS + +/* + * Transport un-register + * + * xprt_unregister(xprt) + * SVCXPRT *xprt; + */ +__BEGIN_DECLS +extern void xprt_unregister(SVCXPRT *); +__END_DECLS + + +/* + * When the service routine is called, it must first check to see if it + * knows about the procedure; if not, it should call svcerr_noproc + * and return. If so, it should deserialize its arguments via + * SVC_GETARGS (defined above). If the deserialization does not work, + * svcerr_decode should be called followed by a return. Successful + * decoding of the arguments should be followed the execution of the + * procedure's code and a call to svc_sendreply. + * + * Also, if the service refuses to execute the procedure due to too- + * weak authentication parameters, svcerr_weakauth should be called. + * Note: do not confuse access-control failure with weak authentication! + * + * NB: In pure implementations of rpc, the caller always waits for a reply + * msg. This message is sent when svc_sendreply is called. + * Therefore pure service implementations should always call + * svc_sendreply even if the function logically returns void; use + * xdr.h - xdr_void for the xdr routine. HOWEVER, tcp based rpc allows + * for the abuse of pure rpc via batched calling or pipelining. In the + * case of a batched call, svc_sendreply should NOT be called since + * this would send a return message, which is what batching tries to avoid. + * It is the service/protocol writer's responsibility to know which calls are + * batched and which are not. Warning: responding to batch calls may + * deadlock the caller and server processes! + */ + +__BEGIN_DECLS +extern bool_t svc_sendreply(SVCXPRT *, xdrproc_t, void *); +extern void svcerr_decode(SVCXPRT *); +extern void svcerr_weakauth(SVCXPRT *); +extern void svcerr_noproc(SVCXPRT *); +extern void svcerr_progvers(SVCXPRT *, rpcvers_t, rpcvers_t); +extern void svcerr_auth(SVCXPRT *, enum auth_stat); +extern void svcerr_noprog(SVCXPRT *); +extern void svcerr_systemerr(SVCXPRT *); +__END_DECLS + +/* + * Lowest level dispatching -OR- who owns this process anyway. + * Somebody has to wait for incoming requests and then call the correct + * service routine. The routine svc_run does infinite waiting; i.e., + * svc_run never returns. + * Since another (co-existant) package may wish to selectively wait for + * incoming calls or other events outside of the rpc architecture, the + * routine svc_getreq is provided. It must be passed readfds, the + * "in-place" results of a select system call (see select, section 2). + */ + +/* + * Global keeper of rpc service descriptors in use + * dynamic; must be inspected before each call to select + */ +extern int svc_maxfd; +extern fd_set svc_fdset; +#define svc_fds svc_fdset.fds_bits[0] /* compatibility */ + +#ifndef _KERNEL +/* + * a small program implemented by the svc_rpc implementation itself; + * also see clnt.h for protocol numbers. + */ +__BEGIN_DECLS +extern void rpctest_service(void); +__END_DECLS +#endif + +__BEGIN_DECLS +extern void svc_getreq(int); +extern void svc_getreqset(fd_set *); +extern void svc_getreqset2(fd_set *, int); /* XXX: nonstd, undoc */ +extern void svc_run(void); +__END_DECLS + +/* + * Socket to use on svcxxx_create call to get default socket + */ +#define RPC_ANYSOCK -1 +#define RPC_ANYFD RPC_ANYSOCK + +/* + * These are the existing service side transport implementations + */ + +__BEGIN_DECLS +/* + * Transport independent svc_create routine. + */ + +/* + * Connectionless and connectionful create routines + */ + +extern SVCXPRT *svc_vc_create(const int, const u_int, const u_int); +/* + * const int fd; -- open connection end point + * const u_int sendsize; -- max send size + * const u_int recvsize; -- max recv size + */ + +/* + * Added for compatibility to old rpc 4.0. Obsoleted by svc_vc_create(). + */ +extern SVCXPRT *svcunix_create(int, u_int, u_int, char *); + +/* + * Added for compatibility to old rpc 4.0. Obsoleted by svc_fd_create(). + */ +extern SVCXPRT *svcunixfd_create(int, u_int, u_int); +__END_DECLS + + +/* for backward compatibility */ +#include + +#endif /* !_RPC_SVC_H */ diff --git a/cpukit/include/rpc/svc_auth.h b/cpukit/include/rpc/svc_auth.h new file mode 100644 index 0000000000..846752c294 --- /dev/null +++ b/cpukit/include/rpc/svc_auth.h @@ -0,0 +1,58 @@ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)svc_auth.h 1.6 86/07/16 SMI + * from: @(#)svc_auth.h 2.1 88/07/29 4.0 RPCSRC + * $FreeBSD: src/include/rpc/svc_auth.h,v 1.12 1999/08/27 23:45:05 peter Exp $ + */ + +/* + * svc_auth.h, Service side of rpc authentication. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_SVCAUTH_H +#define _RPC_SVCAUTH_H + +#include + +struct rpc_msg; +struct svc_req; + +/* + * Server side authenticator + */ +__BEGIN_DECLS +extern enum auth_stat _authenticate (struct svc_req *, struct rpc_msg *); +extern int svc_auth_reg (int, enum auth_stat (*)(struct svc_req *, + struct rpc_msg *)); +extern enum auth_stat _svcauth_des (struct svc_req *, struct rpc_msg *); +__END_DECLS + +#endif /* !_RPC_SVCAUTH_H */ diff --git a/cpukit/include/rpc/svc_soc.h b/cpukit/include/rpc/svc_soc.h new file mode 100644 index 0000000000..5b36fb46ef --- /dev/null +++ b/cpukit/include/rpc/svc_soc.h @@ -0,0 +1,125 @@ +/* $NetBSD: svc_soc.h,v 1.1 2000/06/02 22:57:57 fvdl Exp $ */ +/* $FreeBSD: src/include/rpc/svc_soc.h,v 1.2 2002/03/23 17:24:55 imp Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* + * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. + */ + +/* + * svc.h, Server-side remote procedure call interface. + */ + +#ifndef _RPC_SVC_SOC_H +#define _RPC_SVC_SOC_H +#include +#include +#include /* SVCXPRT */ + +/* #pragma ident "@(#)svc_soc.h 1.11 94/04/25 SMI" */ +/* svc_soc.h 1.8 89/05/01 SMI */ + +/* + * All the following declarations are only for backward compatibility + * with TS-RPC + */ + +/* + * Approved way of getting address of caller + */ +#define svc_getcaller(x) (&(x)->xp_raddr) + +/* + * Service registration + * + * svc_register(xprt, prog, vers, dispatch, protocol) + * SVCXPRT *xprt; + * u_long prog; + * u_long vers; + * void (*dispatch)(); + * int protocol; like TCP or UDP, zero means do not register + */ +__BEGIN_DECLS +extern bool_t svc_register(SVCXPRT *, u_long, u_long, + void (*)(struct svc_req *, SVCXPRT *), int); +__END_DECLS + +/* + * Service un-registration + * + * svc_unregister(prog, vers) + * u_long prog; + * u_long vers; + */ +__BEGIN_DECLS +extern void svc_unregister(u_long, u_long); +__END_DECLS + + +/* + * Memory based rpc for testing and timing. + */ +__BEGIN_DECLS +extern SVCXPRT *svcraw_create(void); +__END_DECLS + + +/* + * Udp based rpc. + */ +__BEGIN_DECLS +extern SVCXPRT *svcudp_create(int); +extern SVCXPRT *svcudp_bufcreate(int, u_int, u_int); +__END_DECLS + + +/* + * Tcp based rpc. + */ +__BEGIN_DECLS +extern SVCXPRT *svctcp_create(int, u_int, u_int); +__END_DECLS + +/* + * Fd based rpc. + */ +__BEGIN_DECLS +extern SVCXPRT *svcfd_create(int, u_int, u_int); +__END_DECLS + +/* + * AF_UNIX socket based rpc. + */ +__BEGIN_DECLS +extern SVCXPRT *svcunix_create (int, u_int, u_int, char *); +extern SVCXPRT *svcunixfd_create (int, u_int, u_int); +__END_DECLS + +#endif /* !_RPC_SVC_SOC_H */ diff --git a/cpukit/include/rpc/types.h b/cpukit/include/rpc/types.h new file mode 100644 index 0000000000..05375d32e9 --- /dev/null +++ b/cpukit/include/rpc/types.h @@ -0,0 +1,68 @@ +/* $NetBSD: types.h,v 1.13 2000/06/13 01:02:44 thorpej Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)types.h 1.18 87/07/24 SMI + * from: @(#)types.h 2.3 88/08/15 4.0 RPCSRC + * $FreeBSD: src/include/rpc/types.h,v 1.11 2003/12/07 21:10:06 marcel Exp $ + */ + +/* + * Rpc additions to + */ +#ifndef _RPC_TYPES_H +#define _RPC_TYPES_H + +#include + +typedef int32_t bool_t; +typedef int32_t enum_t; + +typedef uint32_t rpcprog_t; +typedef uint32_t rpcvers_t; +typedef uint32_t rpcproc_t; +typedef uint32_t rpcprot_t; +typedef uint32_t rpcport_t; +typedef int32_t rpc_inline_t; + +#define __dontcare__ -1 + +#ifndef FALSE +# define FALSE (0) +#endif +#ifndef TRUE +# define TRUE (1) +#endif + +#define mem_alloc(bsize) malloc(bsize) +#define mem_free(ptr, bsize) free(ptr) + +#include + +#endif /* !_RPC_TYPES_H */ diff --git a/cpukit/include/rpc/xdr.h b/cpukit/include/rpc/xdr.h new file mode 100644 index 0000000000..30f2bccc0c --- /dev/null +++ b/cpukit/include/rpc/xdr.h @@ -0,0 +1,312 @@ +/* $NetBSD: xdr.h,v 1.19 2000/07/17 05:00:45 matt Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)xdr.h 1.19 87/04/22 SMI + * from: @(#)xdr.h 2.2 88/07/29 4.0 RPCSRC + * $FreeBSD: src/include/rpc/xdr.h,v 1.23 2003/03/07 13:19:40 nectar Exp $ + */ + +/* + * xdr.h, External Data Representation Serialization Routines. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_XDR_H +#define _RPC_XDR_H + +#include + +#include + +/* + * XDR provides a conventional way for converting between C data + * types and an external bit-string representation. Library supplied + * routines provide for the conversion on built-in C data types. These + * routines and utility routines defined here are used to help implement + * a type encode/decode routine for each user-defined type. + * + * Each data type provides a single procedure which takes two arguments: + * + * bool_t + * xdrproc(xdrs, argresp) + * XDR *xdrs; + * *argresp; + * + * xdrs is an instance of a XDR handle, to which or from which the data + * type is to be converted. argresp is a pointer to the structure to be + * converted. The XDR handle contains an operation field which indicates + * which of the operations (ENCODE, DECODE * or FREE) is to be performed. + * + * XDR_DECODE may allocate space if the pointer argresp is null. This + * data can be freed with the XDR_FREE operation. + * + * We write only one procedure per data type to make it easy + * to keep the encode and decode procedures for a data type consistent. + * In many cases the same code performs all operations on a user defined type, + * because all the hard work is done in the component type routines. + * decode as a series of calls on the nested data types. + */ + +/* + * Xdr operations. XDR_ENCODE causes the type to be encoded into the + * stream. XDR_DECODE causes the type to be extracted from the stream. + * XDR_FREE can be used to release the space allocated by an XDR_DECODE + * request. + */ +enum xdr_op { + XDR_ENCODE=0, + XDR_DECODE=1, + XDR_FREE=2 +}; + +/* + * This is the number of bytes per unit of external data. + */ +#define BYTES_PER_XDR_UNIT (4) +#define RNDUP(x) ((((x) + BYTES_PER_XDR_UNIT - 1) / BYTES_PER_XDR_UNIT) \ + * BYTES_PER_XDR_UNIT) + +/* + * The XDR handle. + * Contains operation which is being applied to the stream, + * an operations vector for the particular implementation (e.g. see xdr_mem.c), + * and two private fields for the use of the particular implementation. + */ +typedef struct __rpc_xdr { + enum xdr_op x_op; /* operation; fast additional param */ + const struct xdr_ops { + /* get a long from underlying stream */ + bool_t (*x_getlong)(struct __rpc_xdr *, long *); + /* put a long to " */ + bool_t (*x_putlong)(struct __rpc_xdr *, const long *); + /* get some bytes from " */ + bool_t (*x_getbytes)(struct __rpc_xdr *, char *, u_int); + /* put some bytes to " */ + bool_t (*x_putbytes)(struct __rpc_xdr *, const char *, u_int); + /* returns bytes off from beginning */ + u_int (*x_getpostn)(struct __rpc_xdr *); + /* lets you reposition the stream */ + bool_t (*x_setpostn)(struct __rpc_xdr *, u_int); + /* buf quick ptr to buffered data */ + int32_t *(*x_inline)(struct __rpc_xdr *, u_int); + /* free privates of this xdr_stream */ + void (*x_destroy)(struct __rpc_xdr *); + } *x_ops; + char * x_public; /* users' data */ + void * x_private; /* pointer to private data */ + char * x_base; /* private used for position info */ + u_int x_handy; /* extra private word */ +} XDR; + +/* + * A xdrproc_t exists for each data type which is to be encoded or decoded. + * + * The second argument to the xdrproc_t is a pointer to an opaque pointer. + * The opaque pointer generally points to a structure of the data type + * to be decoded. If this pointer is 0, then the type routines should + * allocate dynamic storage of the appropriate size and return it. + */ +typedef bool_t (*xdrproc_t) (XDR *, void *, ...); + +/* + * Operations defined on a XDR handle + * + * XDR *xdrs; + * long *longp; + * caddr_t addr; + * u_int len; + * u_int pos; + */ +#define XDR_GETLONG(xdrs, longp) \ + (*(xdrs)->x_ops->x_getlong)(xdrs, longp) +#define xdr_getlong(xdrs, longp) \ + (*(xdrs)->x_ops->x_getlong)(xdrs, longp) + +#define XDR_PUTLONG(xdrs, longp) \ + (*(xdrs)->x_ops->x_putlong)(xdrs, longp) +#define xdr_putlong(xdrs, longp) \ + (*(xdrs)->x_ops->x_putlong)(xdrs, longp) + +#define XDR_GETBYTES(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) +#define xdr_getbytes(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) + +#define XDR_PUTBYTES(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) +#define xdr_putbytes(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) + +#define XDR_GETPOS(xdrs) \ + (*(xdrs)->x_ops->x_getpostn)(xdrs) +#define xdr_getpos(xdrs) \ + (*(xdrs)->x_ops->x_getpostn)(xdrs) + +#define XDR_SETPOS(xdrs, pos) \ + (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) +#define xdr_setpos(xdrs, pos) \ + (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) + +#define XDR_INLINE(xdrs, len) \ + (*(xdrs)->x_ops->x_inline)(xdrs, len) +#define xdr_inline(xdrs, len) \ + (*(xdrs)->x_ops->x_inline)(xdrs, len) + +#define XDR_DESTROY(xdrs) \ + if ((xdrs)->x_ops->x_destroy) \ + (*(xdrs)->x_ops->x_destroy)(xdrs) +#define xdr_destroy(xdrs) \ + if ((xdrs)->x_ops->x_destroy) \ + (*(xdrs)->x_ops->x_destroy)(xdrs) + +/* + * Support struct for discriminated unions. + * You create an array of xdrdiscrim structures, terminated with + * an entry with a null procedure pointer. The xdr_union routine gets + * the discriminant value and then searches the array of structures + * for a matching value. If a match is found the associated xdr routine + * is called to handle that part of the union. If there is + * no match, then a default routine may be called. + * If there is no match and no default routine it is an error. + */ +#define NULL_xdrproc_t ((xdrproc_t)0) +struct xdr_discrim { + int value; + xdrproc_t proc; +}; + +/* + * In-line routines for fast encode/decode of primitive data types. + * Caveat emptor: these use single memory cycles to get the + * data from the underlying buffer, and will fail to operate + * properly if the data is not aligned. The standard way to use these + * is to say: + * if ((buf = XDR_INLINE(xdrs, count)) == NULL) + * return (FALSE); + * <<< macro calls >>> + * where ``count'' is the number of bytes of data occupied + * by the primitive data types. + * + * N.B. and frozen for all time: each data type here uses 4 bytes + * of external representation. + */ +#define IXDR_GET_LONG(buf) ((long)ntohl((u_long)*(buf)++)) +#define IXDR_PUT_LONG(buf, v) (*(buf)++ = (long)htonl((u_long)v)) + +#define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_LONG(buf)) +#define IXDR_GET_ENUM(buf, t) ((t)IXDR_GET_LONG(buf)) +#define IXDR_GET_U_LONG(buf) ((u_long)IXDR_GET_LONG(buf)) +#define IXDR_GET_SHORT(buf) ((short)IXDR_GET_LONG(buf)) +#define IXDR_GET_U_SHORT(buf) ((u_short)IXDR_GET_LONG(buf)) + +#define IXDR_PUT_BOOL(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) +#define IXDR_PUT_ENUM(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) +#define IXDR_PUT_U_LONG(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) +#define IXDR_PUT_SHORT(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) +#define IXDR_PUT_U_SHORT(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) + +/* + * These are the "generic" xdr routines. + */ +__BEGIN_DECLS +extern bool_t xdr_void(void); +extern bool_t xdr_int(XDR *, int *); +extern bool_t xdr_u_int(XDR *, u_int *); +extern bool_t xdr_long(XDR *, long *); +extern bool_t xdr_u_long(XDR *, u_long *); +extern bool_t xdr_short(XDR *, short *); +extern bool_t xdr_u_short(XDR *, u_short *); +extern bool_t xdr_int16_t(XDR *, int16_t *); +extern bool_t xdr_u_int16_t(XDR *, u_int16_t *); +extern bool_t xdr_int32_t(XDR *, int32_t *); +extern bool_t xdr_u_int32_t(XDR *, u_int32_t *); +extern bool_t xdr_int64_t(XDR *, int64_t *); +extern bool_t xdr_u_int64_t(XDR *, u_int64_t *); +extern bool_t xdr_bool(XDR *, bool_t *); +extern bool_t xdr_enum(XDR *, enum_t *); +extern bool_t xdr_array(XDR *, char **, u_int *, u_int, u_int, xdrproc_t); +extern bool_t xdr_bytes(XDR *, char **, u_int *, u_int); +extern bool_t xdr_opaque(XDR *, caddr_t, u_int); +extern bool_t xdr_string(XDR *, char **, u_int); +extern bool_t xdr_union(XDR *, enum_t *, char *, const struct xdr_discrim *, xdrproc_t); +extern unsigned long xdr_sizeof (xdrproc_t, void *); +extern bool_t xdr_char(XDR *, char *); +extern bool_t xdr_u_char(XDR *, u_char *); +extern bool_t xdr_vector(XDR *, char *, u_int, u_int, xdrproc_t); +extern bool_t xdr_float(XDR *, float *); +extern bool_t xdr_double(XDR *, double *); +extern bool_t xdr_reference(XDR *, caddr_t *, u_int, xdrproc_t); +extern bool_t xdr_pointer(XDR *, caddr_t *, u_int, xdrproc_t); +extern bool_t xdr_wrapstring(XDR *, char **); +extern void xdr_free(xdrproc_t, char *); +__END_DECLS + +/* + * Common opaque bytes objects used by many rpc protocols; + * declared here due to commonality. + */ +#define MAX_NETOBJ_SZ 1024 +struct netobj { + u_int n_len; + char *n_bytes; +}; +typedef struct netobj netobj; +extern bool_t xdr_netobj(XDR *, struct netobj *); + +/* + * These are the public routines for the various implementations of + * xdr streams. + */ +__BEGIN_DECLS +/* XDR using memory buffers */ +extern void xdrmem_create(XDR *, char *, u_int, enum xdr_op); + +/* XDR using stdio library */ +#ifdef _STDIO_H_ +extern void xdrstdio_create(XDR *, FILE *, enum xdr_op); +#endif + +/* XDR pseudo records for tcp */ +extern void xdrrec_create(XDR *, u_int, u_int, char *, + int (*) (caddr_t, caddr_t, int), + int (*) (caddr_t, caddr_t, int)); + +/* make end of xdr record */ +extern bool_t xdrrec_endofrecord(XDR *, bool_t); + +/* move to beginning of next record */ +extern bool_t xdrrec_skiprecord(XDR *); + +/* true if no more input */ +extern bool_t xdrrec_eof(XDR *); +__END_DECLS + +#endif /* !_RPC_XDR_H */ diff --git a/cpukit/include/rtems.h b/cpukit/include/rtems.h new file mode 100644 index 0000000000..8e536b449a --- /dev/null +++ b/cpukit/include/rtems.h @@ -0,0 +1,192 @@ +/** + * @file + * + * @defgroup ClassicRTEMS RTEMS Classic API + * + * @brief RTEMS Classic API + * + * the Public Interface to the RTEMS Classic API + */ + +/* COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_H +#define _RTEMS_H + +/** + * @defgroup ClassicRTEMS RTEMS Classic API + * + * RTEMS Classic API definitions and modules. + */ +/**@{*/ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(RTEMS_MULTIPROCESSING) +#include +#endif +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Returns the pointer to the RTEMS version string. + */ +const char *rtems_get_version_string(void); + +/** + * @brief Indicates whether this processor variant has hardware floating point + * support. + */ +#define RTEMS_HAS_HARDWARE_FP CPU_HARDWARE_FP + +/********************************************************************** + * CONSTANTS WHICH MAY BE USED IN OBJECT NAME TO ID SEARCHES + **********************************************************************/ + +/** + * @brief Indicates that a search is across all nodes. + */ +#define RTEMS_SEARCH_ALL_NODES OBJECTS_SEARCH_ALL_NODES + +/** + * @brief Indicates that a search is across all nodes except the one the call + * is made from. + */ +#define RTEMS_SEARCH_OTHER_NODES OBJECTS_SEARCH_OTHER_NODES + +/** + * @brief Indicates that the search is to be restricted to the local node. + */ +#define RTEMS_SEARCH_LOCAL_NODE OBJECTS_SEARCH_LOCAL_NODE + +/** + * @brief Indicates that the caller wants to obtain the name of the currently + * executing thread. + * + * This constant is only meaningful when obtaining the name of a task. + */ +#define RTEMS_WHO_AM_I OBJECTS_WHO_AM_I + +/********************************************************************** + * Parameters and return Id's for _Objects_Get_next + **********************************************************************/ + +/** + * @brief Lowest valid index value for the index portion of an object + * identifier. + */ +#define RTEMS_OBJECT_ID_INITIAL_INDEX OBJECTS_ID_INITIAL_INDEX + +/** + * @brief Maximum valid index value for the index portion of an object + * identifier. + */ +#define RTEMS_OBJECT_ID_FINAL_INDEX OBJECTS_ID_FINAL_INDEX + +/** + * @brief Returns the identifier of the object with the lowest valid index + * value. + * + * The object is specified by the API @a _api, the object class @a _class and + * the node @a _node where the object resides. + */ +#define RTEMS_OBJECT_ID_INITIAL(_api, _class, _node) \ + OBJECTS_ID_INITIAL(_api, _class, _node) + +/** + * @brief Maximum valid object identifier. + */ +#define RTEMS_OBJECT_ID_FINAL OBJECTS_ID_FINAL + +/** + * @brief Minimum stack size which every thread must exceed. + * + * It is the minimum stack size recommended for use on this processor. This + * value is selected by the RTEMS developers conservatively to minimize the + * risk of blown stacks for most user applications. Using this constant when + * specifying the task stack size, indicates that the stack size will be at + * least RTEMS_MINIMUM_STACK_SIZE bytes in size. If the user configured minimum + * stack size is larger than the recommended minimum, then it will be used. + */ +#define RTEMS_MINIMUM_STACK_SIZE STACK_MINIMUM_SIZE + +/** + * @brief Specifies that the task should be created with the configured minimum + * stack size. + * + * Using this constant when specifying the task stack size indicates that this + * task is to be created with a stack size of the minimum stack size that was + * configured by the application. If not explicitly configured by the + * application, the default configured minimum stack size is the processor + * dependent value RTEMS_MINIMUM_STACK_SIZE. Since this uses the configured + * minimum stack size value, you may get a stack size that is smaller or larger + * than the recommended minimum. This can be used to provide large stacks for + * all tasks on complex applications or small stacks on applications that are + * trying to conserve memory. + */ +#define RTEMS_CONFIGURED_MINIMUM_STACK_SIZE 0 + +/** + * @brief Constant for indefinite wait. + * + * This is actually an illegal interval value. + */ +#define RTEMS_NO_TIMEOUT ((rtems_interval) WATCHDOG_NO_TIMEOUT) + +/** + * @brief An MPCI must support packets of at least this size. + */ +#define RTEMS_MINIMUM_PACKET_SIZE MP_PACKET_MINIMUM_PACKET_SIZE + +/** + * @brief Defines the count of @c uint32_t numbers in a packet which must be + * converted to native format in a heterogeneous system. + * + * In packets longer than this value, some of the extra data may be a user + * message buffer which is not automatically endian swapped. + */ +#define RTEMS_MINIMUN_HETERO_CONVERSION MP_PACKET_MINIMUN_HETERO_CONVERSION + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/assoc.h b/cpukit/include/rtems/assoc.h new file mode 100644 index 0000000000..345761758a --- /dev/null +++ b/cpukit/include/rtems/assoc.h @@ -0,0 +1,204 @@ +/** + * @file rtems/assoc.h + * + * @brief RTEMS Associativity Routines + * + * RTEMS associativity routines. Mainly used to convert a value from + * one space to another (eg: our errno's to host errno's and vice-versa) + */ + + +#ifndef _RTEMS_RTEMS_ASSOC_H +#define _RTEMS_RTEMS_ASSOC_H + +/** + * @defgroup Associativity Associativity Routines + */ +/**@{*/ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + const char *name; + uint32_t local_value; + uint32_t remote_value; +} rtems_assoc_t; + +/* + * Flag/marker for optional default value in each table + */ + +#define RTEMS_ASSOC_DEFAULT_NAME "(default)" + +/** + * @brief RTEMS Associate Pointer by Name + */ +const rtems_assoc_t *rtems_assoc_ptr_by_name( + const rtems_assoc_t *, + const char * +); + +/** + * @brief RTEMS Associate Pointer by Remote + */ +const rtems_assoc_t *rtems_assoc_ptr_by_remote( + const rtems_assoc_t *, + uint32_t +); + +uint32_t rtems_assoc_remote_by_local( + const rtems_assoc_t *, + uint32_t +); + +/** + * @brief RTEMS Associate Local by Remote + */ +uint32_t rtems_assoc_local_by_remote( + const rtems_assoc_t *, + uint32_t +); + +/** + * @brief RTEMS Associate Remote by Name + */ +uint32_t rtems_assoc_remote_by_name( + const rtems_assoc_t *, + const char * +); + +/** + * @brief RTEMS Associate Local by Name + */ +uint32_t rtems_assoc_local_by_name( + const rtems_assoc_t *, + const char * +); + +/** + * @brief RTEMS Associate Name by Local + */ +const char *rtems_assoc_name_by_local( + const rtems_assoc_t *, + uint32_t +); + +/** + * @brief RTEMS Associate Name by Remote + */ +const char *rtems_assoc_name_by_remote( + const rtems_assoc_t *, + uint32_t +); + +/** + * @brief RTEMS Assoc Routines + */ +uint32_t rtems_assoc_remote_by_local_bitfield( + const rtems_assoc_t *, + uint32_t +); + +/** + * @brief RTEMS Associate Name by Local Bitfield + */ +char *rtems_assoc_name_by_local_bitfield( + const rtems_assoc_t *, + uint32_t , + char * +); + +/** + * @brief RTEMS Associate Name by Remote Bitfield + */ +char *rtems_assoc_name_by_remote_bitfield( + const rtems_assoc_t *, + uint32_t , + char * +); + +uint32_t rtems_assoc_local_by_remote_bitfield( + const rtems_assoc_t *, + uint32_t +); + +/** + * @brief RTEMS Associate Pointer by Local + */ +const rtems_assoc_t *rtems_assoc_ptr_by_local( + const rtems_assoc_t *ap, + uint32_t local_value +); + +#if defined(INSIDE_ASSOC) + +#define rtems_assoc_is_default(_ap) \ + ((_ap)->name && !strcmp((_ap)->name, RTEMS_ASSOC_DEFAULT_NAME)) + +/** + * @brief RTEMS Associate Bad Name + * + * what to return if a value is not found + * this is not reentrant, but it really shouldn't be invoked anyway + */ +const char *rtems_assoc_name_bad( + uint32_t bad_value +); +#endif + +typedef struct { + uint32_t bits; + const char *name; +} rtems_assoc_32_pair; + +/** + * @brief Converts the specified value into a text representation. + * + * @param[in] value The value to convert. + * @param[in] buffer The buffer for the text representation. + * @param[in] buffer_size The buffer size in characters. + * @param[in] pairs Names for particular bits. + * @param[in] pair_count Count of pairs. + * @param[in] separator Separator between individual names. + * @param[in] fallback Fallback value in case no bits contained in the pairs + * are set in the value. + * + * @retval The length of the text representation. May be greater than or equal + * to the buffer size if truncation occurred. + */ +size_t rtems_assoc_32_to_string( + uint32_t value, + char *buffer, + size_t buffer_size, + const rtems_assoc_32_pair *pairs, + size_t pair_count, + const char *separator, + const char *fallback +); + +/** + * @brief Converts the specified thread states into a text representation. + * + * @param[in] states The thread states to convert. + * @param[in] buffer The buffer for the text representation. + * @param[in] buffer_size The buffer size in characters. + * + * @retval The length of the text representation. May be greater than or equal + * to the buffer size if truncation occurred. + */ +size_t rtems_assoc_thread_states_to_string( + uint32_t states, + char *buffer, + size_t buffer_size +); + +#ifdef __cplusplus +} +#endif +/**@}*/ +#endif /* ! _RTEMS_RTEMS_ASSOC_H */ diff --git a/cpukit/include/rtems/bdbuf.h b/cpukit/include/rtems/bdbuf.h new file mode 100644 index 0000000000..edec05e099 --- /dev/null +++ b/cpukit/include/rtems/bdbuf.h @@ -0,0 +1,699 @@ +/** + * @file + * + * @ingroup rtems_bdbuf + * @brief Block Device Buffer Management + */ + +/* + * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia + * Author: Victor V. Vengerov + * + * Copyright (C) 2008,2009 Chris Johns + * Rewritten to remove score mutex access. Fixes many performance + * issues. + * Change to support demand driven variable buffer sizes. + * + * Copyright (c) 2009-2012 embedded brains GmbH. + */ + +#ifndef _RTEMS_BDBUF_H +#define _RTEMS_BDBUF_H + +#include +#include +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup rtems_libblock Block Device Library + * + * Block device modules. + */ + +/** + * @defgroup rtems_bdbuf Block Device Buffer Management + * + * @ingroup rtems_libblock + * + * The Block Device Buffer Management implements a cache between the disk + * devices and file systems. The code provides read-ahead and write queuing to + * the drivers and fast cache look-up using an AVL tree. + * + * The block size used by a file system can be set at runtime and must be a + * multiple of the disk device block size. The disk device's physical block + * size is called the media block size. The file system can set the block size + * it uses to a larger multiple of the media block size. The driver must be + * able to handle buffers sizes larger than one media block. + * + * The user configures the amount of memory to be used as buffers in the cache, + * and the minimum and maximum buffer size. The cache will allocate additional + * memory for the buffer descriptors and groups. There are enough buffer + * descriptors allocated so all the buffer memory can be used as minimum sized + * buffers. + * + * The cache is a single pool of buffers. The buffer memory is divided into + * groups where the size of buffer memory allocated to a group is the maximum + * buffer size. A group's memory can be divided down into small buffer sizes + * that are a multiple of 2 of the minimum buffer size. A group is the minimum + * allocation unit for buffers of a specific size. If a buffer of maximum size + * is request the group will have a single buffer. If a buffer of minimum size + * is requested the group is divided into minimum sized buffers and the + * remaining buffers are held ready for use. A group keeps track of which + * buffers are with a file system or driver and groups who have buffer in use + * cannot be realloced. Groups with no buffers in use can be taken and + * realloced to a new size. This is how buffers of different sizes move around + * the cache. + + * The buffers are held in various lists in the cache. All buffers follow this + * state machine: + * + * @dot + * digraph state { + * size="16,8"; + * f [label="FREE",style="filled",fillcolor="aquamarine"]; + * e [label="EMPTY",style="filled",fillcolor="seagreen"]; + * c [label="CACHED",style="filled",fillcolor="chartreuse"]; + * ac [label="ACCESS CACHED",style="filled",fillcolor="royalblue"]; + * am [label="ACCESS MODIFIED",style="filled",fillcolor="royalblue"]; + * ae [label="ACCESS EMPTY",style="filled",fillcolor="royalblue"]; + * ap [label="ACCESS PURGED",style="filled",fillcolor="royalblue"]; + * t [label="TRANSFER",style="filled",fillcolor="red"]; + * tp [label="TRANSFER PURGED",style="filled",fillcolor="red"]; + * s [label="SYNC",style="filled",fillcolor="red"]; + * m [label="MODIFIED",style="filled",fillcolor="gold"]; + * i [label="INITIAL"]; + * + * legend_transfer [label="Transfer Wake-Up",fontcolor="red",shape="none"]; + * legend_access [label="Access Wake-Up",fontcolor="royalblue",shape="none"]; + * + * i -> f [label="Init"]; + * f -> e [label="Buffer Recycle"]; + * e -> ae [label="Get"]; + * e -> t [label="Read"]; + * e -> f [label="Nobody Waits"]; + * c -> ac [label="Get\nRead"]; + * c -> e [label="Buffer Recycle\nPurge"]; + * c -> f [label="Reallocate\nBlock Size Changed"]; + * t -> c [label="Transfer Done",color="red",fontcolor="red"]; + * t -> e [label="Transfer Error",color="red",fontcolor="red"]; + * t -> tp [label="Purge"]; + * tp -> e [label="Transfer Done\nTransfer Error",color="red",fontcolor="red"]; + * m -> t [label="Swapout"]; + * m -> s [label="Block Size Changed"]; + * m -> am [label="Get\nRead"]; + * m -> e [label="Purge"]; + * ac -> m [label="Release Modified",color="royalblue",fontcolor="royalblue"]; + * ac -> s [label="Sync",color="royalblue",fontcolor="royalblue"]; + * ac -> c [label="Release",color="royalblue",fontcolor="royalblue"]; + * ac -> ap [label="Purge"]; + * am -> m [label="Release\nRelease Modified",color="royalblue",fontcolor="royalblue"]; + * am -> s [label="Sync",color="royalblue",fontcolor="royalblue"]; + * am -> ap [label="Purge"]; + * ae -> m [label="Release Modified",color="royalblue",fontcolor="royalblue"]; + * ae -> s [label="Sync",color="royalblue",fontcolor="royalblue"]; + * ae -> e [label="Release",color="royalblue",fontcolor="royalblue"]; + * ae -> ap [label="Purge"]; + * ap -> e [label="Release\nRelease Modified\nSync",color="royalblue",fontcolor="royalblue"]; + * s -> t [label="Swapout"]; + * s -> e [label="Purge",color="red",fontcolor="red"]; + * } + * @enddot + * + * Empty or cached buffers are added to the LRU list and removed from this + * queue when a caller requests a buffer. This is referred to as getting a + * buffer in the code and the event get in the state diagram. The buffer is + * assigned to a block and inserted to the AVL based on the block/device key. + * If the block is to be read by the user and not in the cache it is transfered + * from the disk into memory. If no buffers are on the LRU list the modified + * list is checked. If buffers are on the modified the swap out task will be + * woken. The request blocks until a buffer is available for recycle. + * + * A block being accessed is given to the file system layer and not accessible + * to another requester until released back to the cache. The same goes to a + * buffer in the transfer state. The transfer state means being read or + * written. If the file system has modified the block and releases it as + * modified it placed on the cache's modified list and a hold timer + * initialised. The buffer is held for the hold time before being written to + * disk. Buffers are held for a configurable period of time on the modified + * list as a write sets the state to transfer and this locks the buffer out + * from the file system until the write completes. Buffers are often accessed + * and modified in a series of small updates so if sent to the disk when + * released as modified the user would have to block waiting until it had been + * written. This would be a performance problem. + * + * The code performs multiple block reads and writes. Multiple block reads or + * read-ahead increases performance with hardware that supports it. It also + * helps with a large cache as the disk head movement is reduced. It however + * is a speculative operation so excessive use can remove valuable and needed + * blocks from the cache. The read-ahead is triggered after two misses of + * ascending consecutive blocks or a read hit of a block read by the + * most-resent read-ahead transfer. The read-ahead works per disk, but all + * transfers are issued by the read-ahead task. + * + * The cache has the following lists of buffers: + * - LRU: Accessed or transfered buffers released in least recently used + * order. Empty buffers will be placed to the front. + * - Modified: Buffers waiting to be written to disk. + * - Sync: Buffers to be synchronized with the disk. + * + * A cache look-up will be performed to find a suitable buffer. A suitable + * buffer is one that matches the same allocation size as the device the buffer + * is for. The a buffer's group has no buffers in use with the file system or + * driver the group is reallocated. This means the buffers in the group are + * invalidated, resized and placed on the LRU queue. There is a performance + * issue with this design. The reallocation of a group may forced recently + * accessed buffers out of the cache when they should not. The design should be + * change to have groups on a LRU list if they have no buffers in use. + */ +/**@{**/ + +#if defined(RTEMS_POSIX_API) + /* + * Use the PTHREAD mutexes and condition variables if available. This helps + * on SMP configurations to avoid the home grown condition variables via + * disabled preemption. + */ + #define RTEMS_BDBUF_USE_PTHREAD +#endif + +/** + * @brief State of a buffer of the cache. + * + * The state has several implications. Depending on the state a buffer can be + * in the AVL tree, in a list, in use by an entity and a group user or not. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
StateValid DataAVL TreeLRU ListModified ListSynchronization ListGroup UserExternal User
FREEX
EMPTYX
CACHEDXXX
ACCESS CACHEDXXXX
ACCESS MODIFIEDXXXX
ACCESS EMPTYXXX
ACCESS PURGEDXXX
MODIFIEDXXXX
SYNCXXXX
TRANSFERXXXX
TRANSFER PURGEDXXX
+ */ +typedef enum +{ + /** + * @brief Free. + */ + RTEMS_BDBUF_STATE_FREE = 0, + + /** + * @brief Empty. + */ + RTEMS_BDBUF_STATE_EMPTY, + + /** + * @brief Cached. + */ + RTEMS_BDBUF_STATE_CACHED, + + /** + * @brief Accessed by upper layer with cached data. + */ + RTEMS_BDBUF_STATE_ACCESS_CACHED, + + /** + * @brief Accessed by upper layer with modified data. + */ + RTEMS_BDBUF_STATE_ACCESS_MODIFIED, + + /** + * @brief Accessed by upper layer with invalid data. + */ + RTEMS_BDBUF_STATE_ACCESS_EMPTY, + + /** + * @brief Accessed by upper layer with purged data. + */ + RTEMS_BDBUF_STATE_ACCESS_PURGED, + + /** + * @brief Modified by upper layer. + */ + RTEMS_BDBUF_STATE_MODIFIED, + + /** + * @brief Scheduled for synchronization. + */ + RTEMS_BDBUF_STATE_SYNC, + + /** + * @brief In transfer by block device driver. + */ + RTEMS_BDBUF_STATE_TRANSFER, + + /** + * @brief In transfer by block device driver and purged. + */ + RTEMS_BDBUF_STATE_TRANSFER_PURGED +} rtems_bdbuf_buf_state; + +/** + * Forward reference to the block. + */ +struct rtems_bdbuf_group; +typedef struct rtems_bdbuf_group rtems_bdbuf_group; + +/** + * To manage buffers we using buffer descriptors (BD). A BD holds a buffer plus + * a range of other information related to managing the buffer in the cache. To + * speed-up buffer lookup descriptors are organized in AVL-Tree. The fields + * 'dd' and 'block' are search keys. + */ +typedef struct rtems_bdbuf_buffer +{ + rtems_chain_node link; /**< Link the BD onto a number of lists. */ + + struct rtems_bdbuf_avl_node + { + struct rtems_bdbuf_buffer* left; /**< Left Child */ + struct rtems_bdbuf_buffer* right; /**< Right Child */ + signed char cache; /**< Cache */ + signed char bal; /**< The balance of the sub-tree */ + } avl; + + rtems_disk_device *dd; /**< disk device */ + + rtems_blkdev_bnum block; /**< block number on the device */ + + unsigned char* buffer; /**< Pointer to the buffer memory area */ + + rtems_bdbuf_buf_state state; /**< State of the buffer. */ + + uint32_t waiters; /**< The number of threads waiting on this + * buffer. */ + rtems_bdbuf_group* group; /**< Pointer to the group of BDs this BD is + * part of. */ + uint32_t hold_timer; /**< Timer to indicate how long a buffer + * has been held in the cache modified. */ + + int references; /**< Allow reference counting by owner. */ + void* user; /**< User data. */ +} rtems_bdbuf_buffer; + +/** + * A group is a continuous block of buffer descriptors. A group covers the + * maximum configured buffer size and is the allocation size for the buffers to + * a specific buffer size. If you allocate a buffer to be a specific size, all + * buffers in the group, if there are more than 1 will also be that size. The + * number of buffers in a group is a multiple of 2, ie 1, 2, 4, 8, etc. + */ +struct rtems_bdbuf_group +{ + rtems_chain_node link; /**< Link the groups on a LRU list if they + * have no buffers in use. */ + size_t bds_per_group; /**< The number of BD allocated to this + * group. This value must be a multiple of + * 2. */ + uint32_t users; /**< How many users the block has. */ + rtems_bdbuf_buffer* bdbuf; /**< First BD this block covers. */ +}; + +/** + * Buffering configuration definition. See confdefs.h for support on using this + * structure. + */ +typedef struct rtems_bdbuf_config { + uint32_t max_read_ahead_blocks; /**< Number of blocks to read + * ahead. */ + uint32_t max_write_blocks; /**< Number of blocks to write + * at once. */ + rtems_task_priority swapout_priority; /**< Priority of the swap out + * task. */ + uint32_t swapout_period; /**< Period swap-out checks buf + * timers. */ + uint32_t swap_block_hold; /**< Period a buffer is held. */ + size_t swapout_workers; /**< The number of worker + * threads for the swap-out + * task. */ + rtems_task_priority swapout_worker_priority; /**< Priority of the swap out + * task. */ + size_t task_stack_size; /**< Task stack size for swap-out + * task and worker threads. */ + size_t size; /**< Size of memory in the + * cache */ + uint32_t buffer_min; /**< Minimum buffer size. */ + uint32_t buffer_max; /**< Maximum buffer size + * supported. It is also the + * allocation size. */ + rtems_task_priority read_ahead_priority; /**< Priority of the read-ahead + * task. */ +} rtems_bdbuf_config; + +/** + * External reference to the configuration. + * + * The configuration is provided by the application. + */ +extern const rtems_bdbuf_config rtems_bdbuf_configuration; + +/** + * The default value for the maximum read-ahead blocks disables the read-ahead + * feature. + */ +#define RTEMS_BDBUF_MAX_READ_AHEAD_BLOCKS_DEFAULT 0 + +/** + * Default maximum number of blocks to write at once. + */ +#define RTEMS_BDBUF_MAX_WRITE_BLOCKS_DEFAULT 16 + +/** + * Default swap-out task priority. + */ +#define RTEMS_BDBUF_SWAPOUT_TASK_PRIORITY_DEFAULT 15 + +/** + * Default swap-out task swap period in milli seconds. + */ +#define RTEMS_BDBUF_SWAPOUT_TASK_SWAP_PERIOD_DEFAULT 250 + +/** + * Default swap-out task block hold time in milli seconds. + */ +#define RTEMS_BDBUF_SWAPOUT_TASK_BLOCK_HOLD_DEFAULT 1000 + +/** + * Default swap-out worker tasks. Currently disabled. + */ +#define RTEMS_BDBUF_SWAPOUT_WORKER_TASKS_DEFAULT 0 + +/** + * Default swap-out worker task priority. The same as the swap-out task. + */ +#define RTEMS_BDBUF_SWAPOUT_WORKER_TASK_PRIORITY_DEFAULT \ + RTEMS_BDBUF_SWAPOUT_TASK_PRIORITY_DEFAULT + +/** + * Default read-ahead task priority. The same as the swap-out task. + */ +#define RTEMS_BDBUF_READ_AHEAD_TASK_PRIORITY_DEFAULT \ + RTEMS_BDBUF_SWAPOUT_TASK_PRIORITY_DEFAULT + +/** + * Default task stack size for swap-out and worker tasks. + */ +#define RTEMS_BDBUF_TASK_STACK_SIZE_DEFAULT RTEMS_MINIMUM_STACK_SIZE + +/** + * Default size of memory allocated to the cache. + */ +#define RTEMS_BDBUF_CACHE_MEMORY_SIZE_DEFAULT (64 * 512) + +/** + * Default minimum size of buffers. + */ +#define RTEMS_BDBUF_BUFFER_MIN_SIZE_DEFAULT (512) + +/** + * Default maximum size of buffers. + */ +#define RTEMS_BDBUF_BUFFER_MAX_SIZE_DEFAULT (4096) + +/** + * Prepare buffering layer to work - initialize buffer descritors and (if it is + * neccessary) buffers. After initialization all blocks is placed into the + * ready state. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_CALLED_FROM_ISR Called from an interrupt context. + * @retval RTEMS_INVALID_NUMBER The buffer maximum is not an integral multiple + * of the buffer minimum. The maximum read-ahead blocks count is too large. + * @retval RTEMS_RESOURCE_IN_USE Already initialized. + * @retval RTEMS_UNSATISFIED Not enough resources. + */ +rtems_status_code +rtems_bdbuf_init (void); + +/** + * Get block buffer for data to be written into. The buffers is set to the + * access or modified access state. If the buffer is in the cache and modified + * the state is access modified else the state is access. This buffer contents + * are not initialised if the buffer is not already in the cache. If the block + * is already resident in memory it is returned how-ever if not in memory the + * buffer is not read from disk. This call is used when writing the whole block + * on a disk rather than just changing a part of it. If there is no buffers + * available this call will block. A buffer obtained with this call will not be + * involved in a transfer request and will not be returned to another user + * until released. If the buffer is already with a user when this call is made + * the call is blocked until the buffer is returned. The highest priority + * waiter will obtain the buffer first. + * + * The block number is the linear block number. This is relative to the start + * of the partition on the media. + * + * Before you can use this function, the rtems_bdbuf_init() routine must be + * called at least once to initialize the cache, otherwise a fatal error will + * occur. + * + * @param dd [in] The disk device. + * @param block [in] Linear media block number. + * @param bd [out] Reference to the buffer descriptor pointer. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_ID Invalid block number. + */ +rtems_status_code +rtems_bdbuf_get ( + rtems_disk_device *dd, + rtems_blkdev_bnum block, + rtems_bdbuf_buffer** bd +); + +/** + * Get the block buffer and if not already in the cache read from the disk. If + * specified block already cached return. The buffer is set to the access or + * modified access state. If the buffer is in the cache and modified the state + * is access modified else the state is access. If block is already being read + * from disk for being written to disk this call blocks. If the buffer is + * waiting to be written it is removed from modified queue and returned to the + * user. If the buffer is not in the cache a new buffer is obtained and the + * data read from disk. The call may block until these operations complete. A + * buffer obtained with this call will not be involved in a transfer request + * and will not be returned to another user until released. If the buffer is + * already with a user when this call is made the call is blocked until the + * buffer is returned. The highest priority waiter will obtain the buffer + * first. + * + * Before you can use this function, the rtems_bdbuf_init() routine must be + * called at least once to initialize the cache, otherwise a fatal error will + * occur. + * + * @param dd [in] The disk device. + * @param block [in] Linear media block number. + * @param bd [out] Reference to the buffer descriptor pointer. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_ID Invalid block number. + * @retval RTEMS_IO_ERROR IO error. + */ +rtems_status_code +rtems_bdbuf_read ( + rtems_disk_device *dd, + rtems_blkdev_bnum block, + rtems_bdbuf_buffer** bd +); + +/** + * Release the buffer obtained by a read call back to the cache. If the buffer + * was obtained by a get call and was not already in the cache the release + * modified call should be used. A buffer released with this call obtained by a + * get call may not be in sync with the contents on disk. If the buffer was in + * the cache and modified before this call it will be returned to the modified + * queue. The buffers is returned to the end of the LRU list. + * + * Before you can use this function, the rtems_bdbuf_init() routine must be + * called at least once to initialize the cache, otherwise a fatal error will + * occur. + * + * @param bd [in] Reference to the buffer descriptor. The buffer descriptor + * reference must not be @c NULL and must be obtained via rtems_bdbuf_get() or + * rtems_bdbuf_read(). + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_ADDRESS The reference is NULL. + */ +rtems_status_code +rtems_bdbuf_release (rtems_bdbuf_buffer* bd); + +/** + * Release the buffer allocated with a get or read call placing it on the + * modified list. If the buffer was not released modified before the hold + * timer is set to the configuration value. If the buffer had been released + * modified before but not written to disk the hold timer is not updated. The + * buffer will be written to disk when the hold timer has expired, there are + * not more buffers available in the cache and a get or read buffer needs one + * or a sync call has been made. If the buffer is obtained with a get or read + * before the hold timer has expired the buffer will be returned to the user. + * + * Before you can use this function, the rtems_bdbuf_init() routine must be + * called at least once to initialize the cache, otherwise a fatal error will + * occur. + * + * @param bd [in] Reference to the buffer descriptor. The buffer descriptor + * reference must not be @c NULL and must be obtained via rtems_bdbuf_get() or + * rtems_bdbuf_read(). + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_ADDRESS The reference is NULL. + */ +rtems_status_code +rtems_bdbuf_release_modified (rtems_bdbuf_buffer* bd); + +/** + * Release the buffer as modified and wait until it has been synchronized with + * the disk by writing it. This buffer will be the first to be transfer to disk + * and other buffers may also be written if the maximum number of blocks in a + * requests allows it. + * + * @note This code does not lock the sync mutex and stop additions to the + * modified queue. + * + * Before you can use this function, the rtems_bdbuf_init() routine must be + * called at least once to initialize the cache, otherwise a fatal error will + * occur. + * + * @param bd [in] Reference to the buffer descriptor. The buffer descriptor + * reference must not be @c NULL and must be obtained via rtems_bdbuf_get() or + * rtems_bdbuf_read(). + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_ADDRESS The reference is NULL. + */ +rtems_status_code +rtems_bdbuf_sync (rtems_bdbuf_buffer* bd); + +/** + * Synchronize all modified buffers for this device with the disk and wait + * until the transfers have completed. The sync mutex for the cache is locked + * stopping the addition of any further modified buffers. It is only the + * currently modified buffers that are written. + * + * @note Nesting calls to sync multiple devices will be handled sequentially. A + * nested call will be blocked until the first sync request has complete. + * + * Before you can use this function, the rtems_bdbuf_init() routine must be + * called at least once to initialize the cache, otherwise a fatal error will + * occur. + * + * @param dd [in] The disk device. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + */ +rtems_status_code +rtems_bdbuf_syncdev (rtems_disk_device *dd); + +/** + * @brief Purges all buffers corresponding to the disk device @a dd. + * + * This may result in loss of data. The read-ahead state of this device is reset. + * + * Before you can use this function, the rtems_bdbuf_init() routine must be + * called at least once to initialize the cache, otherwise a fatal error will + * occur. + * + * @param dd [in] The disk device. + */ +void +rtems_bdbuf_purge_dev (rtems_disk_device *dd); + +/** + * @brief Sets the block size of a disk device. + * + * This will set the block size derived fields of the disk device. If + * requested the disk device is synchronized before the block size change + * occurs. Since the cache is unlocked during the synchronization operation + * some tasks may access the disk device in the meantime. This may result in + * loss of data. After the synchronization the disk device is purged to ensure + * a consistent cache state and the block size change occurs. This also resets + * the read-ahead state of this disk device. Due to the purge operation this + * may result in loss of data. + * + * Before you can use this function, the rtems_bdbuf_init() routine must be + * called at least once to initialize the cache, otherwise a fatal error will + * occur. + * + * @param dd [in, out] The disk device. + * @param block_size [in] The new block size in bytes. + * @param sync [in] If @c true, then synchronize the disk device before the + * block size change. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_NUMBER Invalid block size. + */ +rtems_status_code +rtems_bdbuf_set_block_size (rtems_disk_device *dd, + uint32_t block_size, + bool sync); + +/** + * @brief Returns the block device statistics. + */ +void +rtems_bdbuf_get_device_stats (const rtems_disk_device *dd, + rtems_blkdev_stats *stats); + +/** + * @brief Resets the block device statistics. + */ +void +rtems_bdbuf_reset_device_stats (rtems_disk_device *dd); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/include/rtems/bdpart.h b/cpukit/include/rtems/bdpart.h new file mode 100644 index 0000000000..8886c3614d --- /dev/null +++ b/cpukit/include/rtems/bdpart.h @@ -0,0 +1,411 @@ +/** + * @file + * + * @ingroup rtems_bdpart + * + * @brief Block Device Partition Management + */ + +/* + * Copyright (c) 2009-2012 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Obere Lagerstr. 30 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef RTEMS_BDPART_H +#define RTEMS_BDPART_H + +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup rtems_bdpart Block Device Partition Management + * + * @ingroup rtems_libblock + * + * @brief This module provides functions to manage partitions of a disk device. + * + * A @ref rtems_disk "disk" is a set of blocks which are identified by a + * consecutive set of non-negative integers starting at zero. There are also + * logical disks which contain a subset of consecutive disk blocks. The + * logical disks are used to represent the partitions of a disk. The disk + * devices are accessed via the @ref rtems_disk "block device buffer module". + * + * The partition format on the physical disk will be converted to an internal + * representation. It is possible to convert the internal representation into + * a specific output format and write it to the physical disk. One of the + * constrains for the internal representation was to support the GPT format + * easily. + * + * Currently two physical partition formats are supported. These are the MBR + * and the GPT format. Please note that the GPT support is not implemented. + * With MBR format we mean the partition format of the wide spread IBM + * PC-compatible systems. The GPT format is defined in the Extensible Firmware + * Interface (EFI). + * + * The most common task will be to read the partition information of a disk and + * register logical disks for each partition. This can be done with the + * rtems_bdpart_register_from_disk() function. Afterwards you can + * @ref rtems_fsmount "mount" the file systems within the partitions. + * + * You can read the partition information from a disk with rtems_bdpart_read() + * and write it to the disk with rtems_bdpart_write(). + * + * To create a partition table from scratch for a disk use + * rtems_bdpart_create(). + * + * You can access some disk functions with the shell command @c fdisk. + * + * References used to create this module: + * - Universally Unique Identifier + * - Globally Unique Identifier + * - Disk Paritioning + * - GUID Partition Table + * - Master Boot Record + * - Extended Boot Record + * - Cylinder Head Sector + * - Partition Types + */ +/**@{**/ + +/** + * @name MBR Partition Types and Flags + */ +/**@{**/ + +#define RTEMS_BDPART_MBR_EMPTY 0x0U + +#define RTEMS_BDPART_MBR_FAT_12 0x1U + +#define RTEMS_BDPART_MBR_FAT_16 0x4U + +#define RTEMS_BDPART_MBR_FAT_16_LBA 0xeU + +#define RTEMS_BDPART_MBR_FAT_32 0xbU + +#define RTEMS_BDPART_MBR_FAT_32_LBA 0xcU + +#define RTEMS_BDPART_MBR_EXTENDED 0x5U + +#define RTEMS_BDPART_MBR_DATA 0xdaU + +#define RTEMS_BDPART_MBR_GPT 0xeeU + +#define RTEMS_BDPART_MBR_FLAG_ACTIVE 0x80U + +/** @} */ + +/** + * Recommended maximum partition table size. + */ +#define RTEMS_BDPART_PARTITION_NUMBER_HINT 16 + +/** + * Partition description. + */ +typedef struct rtems_bdpart_partition { + /** + * Block index for partition begin. + */ + rtems_blkdev_bnum begin; + + /** + * Block index for partition end (this block is not a part of the partition). + */ + rtems_blkdev_bnum end; + + /** + * Partition type. + */ + uuid_t type; + + /** + * Partition ID. + */ + uuid_t id; + + /** + * Partition flags. + */ + uint64_t flags; +} rtems_bdpart_partition; + +/** + * Disk format for the partition tables. + */ +typedef enum { + /** + * Type value for MBR format. + */ + RTEMS_BDPART_FORMAT_MBR, + + /** + * Type value for GPT format. + */ + RTEMS_BDPART_FORMAT_GPT +} rtems_bdpart_format_type; + +/** + * Disk format description. + */ +typedef union { + /** + * Format type. + */ + rtems_bdpart_format_type type; + + /** + * MBR format fields. + */ + struct { + rtems_bdpart_format_type type; + + /** + * Disk ID in MBR at offset 440. + */ + uint32_t disk_id; + + /** + * This option is used for partition table creation and validation checks + * before a write to the disk. It ensures that the first primary + * partition and the logical partitions start at head one and sector one + * under the virtual one head and 63 sectors geometry. Each begin and + * end of a partition will be aligned to the virtual cylinder boundary. + */ + bool dos_compatibility; + } mbr; + + /** + * GPT format fields. + */ + struct { + rtems_bdpart_format_type type; + + /** + * Disk ID in GPT header. + */ + uuid_t disk_id; + } gpt; +} rtems_bdpart_format; + +/** + * @brief Reads the partition information from the physical disk device with + * name @a disk_name. + * + * The partition information will be stored in the partition table + * @a partitions with a maximum of @a count partitions. The number of actual + * partitions will be stored in @a count. If there are more partitions than + * space for storage an error status will be returned. The partition table + * format recognized on the disk will be stored in @a format. + */ +rtems_status_code rtems_bdpart_read( + const char *disk_name, + rtems_bdpart_format *format, + rtems_bdpart_partition *partitions, + size_t *count +); + +/** + * @brief Sorts the partition table @a partitions with @a count partitions to + * have ascending begin blocks + */ +void rtems_bdpart_sort( rtems_bdpart_partition *partitions, size_t count); + +/** + * @brief Writes the partition table to the physical disk device with name + * @a disk_name. + * + * The partition table @a partitions with @a count partitions will be written + * to the disk. The output format for the partition table on the disk is + * specified by @a format. There are some consistency checks applied to the + * partition table. The partition table must be sorted such that the begin + * blocks are in ascending order. This can be done with the + * rtems_bdpart_sort() function. The partitions must not overlap. The + * partitions must have a positive size. The partitions must be within the + * disk. Depending on the output format there are additional constrains. + */ +rtems_status_code rtems_bdpart_write( + const char *disk_name, + const rtems_bdpart_format *format, + const rtems_bdpart_partition *partitions, + size_t count +); + +/** + * @brief Creates a partition table in @a partitions with @a count partitions + * for the physical disk device with name @a disk_name. + * + * The array of positive integer weights in @a distribution must have exactly + * @a count elements. The weights in the distribution array are summed up. + * Each weight is then divided by the sum to obtain the disk fraction which + * forms the corresponding partition. The partition boundaries are generated + * with respect to the output format in @a format. + */ +rtems_status_code rtems_bdpart_create( + const char *disk_name, + const rtems_bdpart_format *format, + rtems_bdpart_partition *partitions, + const unsigned *distribution, + size_t count +); + +/** + * @brief Registers the partitions as logical disks for the physical disk + * device with name @a disk_name. + * + * For each partition of the partition table @a partitions with @a count + * partitions a logical disk is registered. The partition number equals the + * partition table index plus one. The name of the logical disk device is the + * concatenation of the physical disk device name and the partition number. + * + * @see rtems_blkdev_create_partition(). + */ +rtems_status_code rtems_bdpart_register( + const char *disk_name, + const rtems_bdpart_partition *partitions, + size_t count +); + +/** + * @a brief Reads the partition table from the disk device with name @a + * disk_name and registers the partitions as logical disks. + * + * @see rtems_bdpart_register() and rtems_fsmount(). + */ +rtems_status_code rtems_bdpart_register_from_disk( const char *disk_name); + +/** + * @brief Deletes the logical disks associated with the partitions of the disk + * device with name @a disk_name. + * + * The partition table @a partitions with @a count partitions will be used to + * determine which disks need to be deleted. It may be obtained from + * rtems_bdpart_read(). + */ +rtems_status_code rtems_bdpart_unregister( + const char *disk_name, + const rtems_bdpart_partition *partitions, + size_t count +); + +/** + * @brief Mounts all supported file systems inside the logical disks derived + * from the partitions of the physical disk device with name @a disk_name. + * + * For each partition in the partition table @a partitions with @a count + * partitions it will be checked if it contains a supported file system. In + * this case a mount point derived from the disk name will be created in the + * mount base path @a mount_base. The file system will be mounted there. The + * partition number equals the partition table index plus one. The mount point + * name for each partition will be the concatenation of the mount base path, + * the disk device file name and the parition number. + * + * @see rtems_bdpart_read(). + */ +rtems_status_code rtems_bdpart_mount( + const char *disk_name, + const rtems_bdpart_partition *partitions, + size_t count, + const char *mount_base +); + +/** + * @brief Unmounts all file systems mounted with rtems_bdpart_mount(). + */ +rtems_status_code rtems_bdpart_unmount( + const char *disk_name, + const rtems_bdpart_partition *partitions, + size_t count, + const char *mount_base +); + +/** + * @brief Prints the partition table @a partitions with @a count partitions to + * standard output. + */ +void rtems_bdpart_dump( const rtems_bdpart_partition *partitions, size_t count); + +/** + * @brief Returns the partition type for the MBR partition type value + * @a mbr_type in @a type. + */ +void rtems_bdpart_to_partition_type( uint8_t mbr_type, uuid_t type); + +/** + * @brief Converts the partition type in @a type to the MBR partition type. + * + * The result will be stored in @a mbr_type. Returns @c true in case of a + * successful convertion and otherwise @c false. Both arguments must not be + * @c NULL. + */ +bool rtems_bdpart_to_mbr_partition_type( + const uuid_t type, + uint8_t *mbr_type +); + +/** @} */ + +#define RTEMS_BDPART_MBR_CYLINDER_SIZE 63 + +#define RTEMS_BDPART_NUMBER_SIZE 4 + +#define RTEMS_BDPART_BLOCK_SIZE 512 + +#define RTEMS_BDPART_MBR_TABLE_ENTRY_SIZE 16 + +#define RTEMS_BDPART_MBR_OFFSET_TABLE_0 446 + +#define RTEMS_BDPART_MBR_OFFSET_TABLE_1 \ + (RTEMS_BDPART_MBR_OFFSET_TABLE_0 + RTEMS_BDPART_MBR_TABLE_ENTRY_SIZE) + +#define RTEMS_BDPART_MBR_OFFSET_DISK_ID 440 + +#define RTEMS_BDPART_MBR_OFFSET_SIGNATURE_0 510 + +#define RTEMS_BDPART_MBR_OFFSET_SIGNATURE_1 511 + +#define RTEMS_BDPART_MBR_SIGNATURE_0 0x55U + +#define RTEMS_BDPART_MBR_SIGNATURE_1 0xaaU + +#define RTEMS_BDPART_MBR_OFFSET_BEGIN 8 + +#define RTEMS_BDPART_MBR_OFFSET_SIZE 12 + +#define RTEMS_BDPART_MBR_OFFSET_TYPE 4 + +#define RTEMS_BDPART_MBR_OFFSET_FLAGS 0 + +static inline uint8_t rtems_bdpart_mbr_partition_type( + const uuid_t type +) +{ + return type [0]; +} + +rtems_status_code rtems_bdpart_get_disk_data( + const char *disk_name, + int *fd_ptr, + rtems_disk_device **dd_ptr, + rtems_blkdev_bnum *disk_end +); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RTEMS_BDPART_H */ diff --git a/cpukit/include/rtems/blkdev.h b/cpukit/include/rtems/blkdev.h new file mode 100644 index 0000000000..3f829e6068 --- /dev/null +++ b/cpukit/include/rtems/blkdev.h @@ -0,0 +1,460 @@ +/** + * @file + * + * @ingroup rtems_blkdev + * + * @brief Block Device Management + */ + +/* + * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia + * Author: Victor V. Vengerov + */ + +#ifndef _RTEMS_BLKDEV_H +#define _RTEMS_BLKDEV_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup rtems_blkdev Block Device Management + * + * @ingroup rtems_libblock + * + * Interface between device drivers and the + * @ref rtems_bdbuf "block device buffer module". + * + * The heart of the block device driver is the @ref RTEMS_BLKIO_REQUEST IO + * control. This call puts IO @ref rtems_blkdev_request "requests" to the block + * device for asynchronous processing. When a driver executes a request, it + * invokes the request done callback function to finish the request. + */ +/**@{**/ + +/** + * @brief Block device request type. + * + * @warning The sync request is an IO one and only used from the cache. Use the + * Block IO when operating at the device level. We need a sync request + * to avoid requests looping for ever. + */ +typedef enum rtems_blkdev_request_op { + RTEMS_BLKDEV_REQ_READ, /**< Read the requested blocks of data. */ + RTEMS_BLKDEV_REQ_WRITE, /**< Write the requested blocks of data. */ + RTEMS_BLKDEV_REQ_SYNC /**< Sync any data with the media. */ +} rtems_blkdev_request_op; + +struct rtems_blkdev_request; + +/** + * @brief Block device request done callback function type. + */ +typedef void (*rtems_blkdev_request_cb)( + struct rtems_blkdev_request *req, + rtems_status_code status +); + +/** + * @brief Block device scatter or gather buffer structure. + */ +typedef struct rtems_blkdev_sg_buffer { + /** + * Block index. + */ + rtems_blkdev_bnum block; + + /** + * Buffer length. + */ + uint32_t length; + + /** + * Buffer pointer. + */ + void *buffer; + + /** + * User pointer. + */ + void *user; +} rtems_blkdev_sg_buffer; + +/** + * @brief The block device transfer request is used to read or write a number + * of blocks from or to the device. + * + * Transfer requests are issued to the disk device driver with the + * @ref RTEMS_BLKIO_REQUEST IO control. The transfer request completion status + * must be signalled with rtems_blkdev_request_done(). This function must be + * called exactly once per request. The return value of the IO control will be + * ignored for transfer requests. + * + * @see rtems_blkdev_create(). + */ +typedef struct rtems_blkdev_request { + /** + * Block device operation (read or write). + */ + rtems_blkdev_request_op req; + + /** + * Request done callback function. + */ + rtems_blkdev_request_cb done; + + /** + * Argument to be passed to callback function. + */ + void *done_arg; + + /** + * Last IO operation completion status. + */ + rtems_status_code status; + + /** + * Number of blocks for this request. + */ + uint32_t bufnum; + + /** + * The task requesting the IO operation. + */ + rtems_id io_task; + + /* + * TODO: The use of these req blocks is not a great design. The req is a + * struct with a single 'bufs' declared in the req struct and the + * others are added in the outer level struct. This relies on the + * structs joining as a single array and that assumes the compiler + * packs the structs. Why not just place on a list ? The BD has a + * node that can be used. + */ + + /** + * List of scatter or gather buffers. + */ + rtems_blkdev_sg_buffer bufs[RTEMS_ZERO_LENGTH_ARRAY]; +} rtems_blkdev_request; + +/** + * @brief Signals transfer request completion status. + * + * This function must be called exactly once per request. + * + * @param[in,out] req The transfer request. + * @param[in] status The status of the operation should be + * - @c RTEMS_SUCCESSFUL, if the operation was successful, + * - @c RTEMS_IO_ERROR, if some sort of input or output error occurred, or + * - @c RTEMS_UNSATISFIED, if media is no more present. + */ +static inline void rtems_blkdev_request_done( + rtems_blkdev_request *req, + rtems_status_code status +) +{ + (*req->done)(req, status); +} + +/** + * @brief The start block in a request. + * + * Only valid if the driver has returned the + * @ref RTEMS_BLKDEV_CAP_MULTISECTOR_CONT capability. + */ +#define RTEMS_BLKDEV_START_BLOCK(req) (req->bufs[0].block) + +/** + * @name IO Control Request Codes + */ +/**@{**/ + +#define RTEMS_BLKIO_REQUEST _IOWR('B', 1, rtems_blkdev_request) +#define RTEMS_BLKIO_GETMEDIABLKSIZE _IOR('B', 2, uint32_t) +#define RTEMS_BLKIO_GETBLKSIZE _IOR('B', 3, uint32_t) +#define RTEMS_BLKIO_SETBLKSIZE _IOW('B', 4, uint32_t) +#define RTEMS_BLKIO_GETSIZE _IOR('B', 5, rtems_blkdev_bnum) +#define RTEMS_BLKIO_SYNCDEV _IO('B', 6) +#define RTEMS_BLKIO_DELETED _IO('B', 7) +#define RTEMS_BLKIO_CAPABILITIES _IO('B', 8) +#define RTEMS_BLKIO_GETDISKDEV _IOR('B', 9, rtems_disk_device *) +#define RTEMS_BLKIO_PURGEDEV _IO('B', 10) +#define RTEMS_BLKIO_GETDEVSTATS _IOR('B', 11, rtems_blkdev_stats *) +#define RTEMS_BLKIO_RESETDEVSTATS _IO('B', 12) + +/** @} */ + +static inline int rtems_disk_fd_get_media_block_size( + int fd, + uint32_t *media_block_size +) +{ + return ioctl(fd, RTEMS_BLKIO_GETMEDIABLKSIZE, media_block_size); +} + +static inline int rtems_disk_fd_get_block_size(int fd, uint32_t *block_size) +{ + return ioctl(fd, RTEMS_BLKIO_GETBLKSIZE, block_size); +} + +static inline int rtems_disk_fd_set_block_size(int fd, uint32_t block_size) +{ + return ioctl(fd, RTEMS_BLKIO_SETBLKSIZE, &block_size); +} + +static inline int rtems_disk_fd_get_block_count( + int fd, + rtems_blkdev_bnum *block_count +) +{ + return ioctl(fd, RTEMS_BLKIO_GETSIZE, block_count); +} + +static inline int rtems_disk_fd_get_disk_device( + int fd, + rtems_disk_device **dd_ptr +) +{ + return ioctl(fd, RTEMS_BLKIO_GETDISKDEV, dd_ptr); +} + +static inline int rtems_disk_fd_sync(int fd) +{ + return ioctl(fd, RTEMS_BLKIO_SYNCDEV); +} + +static inline int rtems_disk_fd_purge(int fd) +{ + return ioctl(fd, RTEMS_BLKIO_PURGEDEV); +} + +static inline int rtems_disk_fd_get_device_stats( + int fd, + rtems_blkdev_stats *stats +) +{ + return ioctl(fd, RTEMS_BLKIO_GETDEVSTATS, stats); +} + +static inline int rtems_disk_fd_reset_device_stats(int fd) +{ + return ioctl(fd, RTEMS_BLKIO_RESETDEVSTATS); +} + +/** + * @name Block Device Driver Capabilities + */ +/**@{**/ + +/** + * @brief Only consecutive multi-sector buffer requests are supported. + * + * This option means the cache will only supply multiple buffers that are + * inorder so the ATA multi-sector command for example can be used. This is a + * hack to work around the current ATA driver. + */ +#define RTEMS_BLKDEV_CAP_MULTISECTOR_CONT (1 << 0) + +/** + * @brief The driver will accept a sync call. + * + * A sync call is made to a driver after a bdbuf cache sync has finished. + */ +#define RTEMS_BLKDEV_CAP_SYNC (1 << 1) + +/** @} */ + +/** + * @brief Common IO control primitive. + * + * Use this in all block devices to handle the common set of IO control + * requests. + */ +int +rtems_blkdev_ioctl(rtems_disk_device *dd, uint32_t req, void *argp); + +/** + * @brief Creates a block device. + * + * The block size is set to the media block size. + * + * @param[in] device The path for the new block device. + * @param[in] media_block_size The media block size in bytes. Must be positive. + * @param[in] media_block_count The media block count. Must be positive. + * @param[in] handler The block device IO control handler. Must not be @c NULL. + * @param[in] driver_data The block device driver data. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_NUMBER Media block size or count is not positive. + * @retval RTEMS_NO_MEMORY Not enough memory. + * @retval RTEMS_UNSATISFIED Cannot create generic device node. + * + * @see rtems_blkdev_create_partition(), rtems_bdbuf_set_block_size(), and + * rtems_blkdev_request. + */ +rtems_status_code rtems_blkdev_create( + const char *device, + uint32_t media_block_size, + rtems_blkdev_bnum media_block_count, + rtems_block_device_ioctl handler, + void *driver_data +); + +/** + * @brief Creates a partition within a parent block device. + * + * A partition manages a subset of consecutive blocks contained in a parent block + * device. The blocks must be within the range of blocks managed by the + * associated parent block device. The media block size and IO control + * handler are inherited by the parent block device. The block size is set to + * the media block size. + * + * @param[in] partition The path for the new partition device. + * @param[in] parent_block_device The parent block device path. + * @param[in] media_block_begin The media block begin of the partition within + * the parent block device. + * @param[in] media_block_count The media block count of the partition. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_ID Block device node does not exist. + * @retval RTEMS_INVALID_NODE File system node is not a block device. + * @retval RTEMS_NOT_IMPLEMENTED Block device implementation is incomplete. + * @retval RTEMS_INVALID_NUMBER Block begin or block count is invalid. + * @retval RTEMS_NO_MEMORY Not enough memory. + * @retval RTEMS_UNSATISFIED Cannot create generic device node. + * + * @see rtems_blkdev_create() and rtems_bdbuf_set_block_size(). + */ +rtems_status_code rtems_blkdev_create_partition( + const char *partition, + const char *parent_block_device, + rtems_blkdev_bnum media_block_begin, + rtems_blkdev_bnum media_block_count +); + +/** + * @brief Prints the block device statistics. + */ +void rtems_blkdev_print_stats( + const rtems_blkdev_stats *stats, + uint32_t media_block_size, + uint32_t media_block_count, + uint32_t block_size, + const rtems_printer* printer +); + +/** + * @brief Block device statistics command. + */ +void rtems_blkstats( + const rtems_printer *printer, + const char *device, + bool reset +); + +/** @} */ + +/** + * @defgroup rtems_blkdev_generic Generic Disk Device + * + * @ingroup rtems_blkdev + * + * Generic disk device operations for standard RTEMS IO drivers. + */ +/**@{**/ + +/** + * The device driver interface conventions suppose that a driver may contain an + * initialize, open, close, read, write and IO control entry points. These + * primitives (except initialize) can be implemented in a generic fashion based + * upon the supplied block device driver IO control handler. Every block device + * driver should provide an initialize entry point, which registers the + * appropriate IO control handler. + */ +#define RTEMS_GENERIC_BLOCK_DEVICE_DRIVER_ENTRIES \ + rtems_blkdev_generic_open, \ + rtems_blkdev_generic_close, \ + rtems_blkdev_generic_read, \ + rtems_blkdev_generic_write, \ + rtems_blkdev_generic_ioctl + +/** + * Generic block device read primitive. + * + * Implemented using block device buffer management primitives. + */ +rtems_device_driver +rtems_blkdev_generic_read( + rtems_device_major_number major, + rtems_device_minor_number minor, + void * arg +); + +/** + * Generic block device write primitive. + * + * Implemented using block device buffer management primitives. + */ +rtems_device_driver +rtems_blkdev_generic_write( + rtems_device_major_number major, + rtems_device_minor_number minor, + void * arg +); + +/** + * Generic block device open primitive. + * + * Implemented using block device buffer management primitives. + */ +rtems_device_driver +rtems_blkdev_generic_open( + rtems_device_major_number major, + rtems_device_minor_number minor, + void * arg +); + +/** + * Generic block device close primitive. + * + * Implemented using block device buffer management primitives. + */ +rtems_device_driver +rtems_blkdev_generic_close( + rtems_device_major_number major, + rtems_device_minor_number minor, + void * arg +); + +/** + * Generic block device IO control primitive. + * + * Implemented using block device buffer management primitives. + */ +rtems_device_driver +rtems_blkdev_generic_ioctl( + rtems_device_major_number major, + rtems_device_minor_number minor, + void * arg +); + +/** + * @brief Generic block operations driver address table. + */ +extern const rtems_driver_address_table rtems_blkdev_generic_ops; + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/include/rtems/bsd.h b/cpukit/include/rtems/bsd.h new file mode 100644 index 0000000000..0c44e3787d --- /dev/null +++ b/cpukit/include/rtems/bsd.h @@ -0,0 +1,141 @@ +/** + * @file + * + * @ingroup BSD + * + * @brief BSD Compatibility API + */ + +/* + * Copyright (c) 2015 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_BSD_H +#define _RTEMS_BSD_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup BSD BSD Compatibility Support + * + * @{ + */ + +/** + * @copydoc _Timecounter_Bintime() + */ +RTEMS_INLINE_ROUTINE void rtems_bsd_bintime( struct bintime *bt ) +{ + _Timecounter_Bintime( bt ); +} + +/** + * @copydoc _Timecounter_Nanotime() + */ +RTEMS_INLINE_ROUTINE void rtems_bsd_nanotime( struct timespec *ts ) +{ + _Timecounter_Nanotime( ts ); +} + +/** + * @copydoc _Timecounter_Microtime() + */ +RTEMS_INLINE_ROUTINE void rtems_bsd_microtime( struct timeval *tv ) +{ + _Timecounter_Microtime( tv ); +} + +/** + * @copydoc _Timecounter_Binuptime() + */ +RTEMS_INLINE_ROUTINE void rtems_bsd_binuptime( struct bintime *bt ) +{ + _Timecounter_Binuptime( bt ); +} + +/** + * @copydoc _Timecounter_Nanouptime() + */ +RTEMS_INLINE_ROUTINE void rtems_bsd_nanouptime( struct timespec *ts ) +{ + _Timecounter_Nanouptime( ts ); +} + +/** + * @copydoc _Timecounter_Microtime() + */ +RTEMS_INLINE_ROUTINE void rtems_bsd_microuptime( struct timeval *tv ) +{ + _Timecounter_Microuptime( tv ); +} + +/** + * @copydoc _Timecounter_Getbintime() + */ +RTEMS_INLINE_ROUTINE void rtems_bsd_getbintime( struct bintime *bt ) +{ + _Timecounter_Getbintime( bt ); +} + +/** + * @copydoc _Timecounter_Getnanotime() + */ +RTEMS_INLINE_ROUTINE void rtems_bsd_getnanotime( struct timespec *ts ) +{ + _Timecounter_Getnanotime( ts ); +} + +/** + * @copydoc _Timecounter_Getmicrotime() + */ +RTEMS_INLINE_ROUTINE void rtems_bsd_getmicrotime( struct timeval *tv ) +{ + _Timecounter_Getmicrotime( tv ); +} + +/** + * @copydoc _Timecounter_Getbinuptime() + */ +RTEMS_INLINE_ROUTINE void rtems_bsd_getbinuptime( struct bintime *bt ) +{ + _Timecounter_Getbinuptime( bt ); +} + +/** + * @copydoc _Timecounter_Getnanouptime() + */ +RTEMS_INLINE_ROUTINE void rtems_bsd_getnanouptime( struct timespec *ts ) +{ + _Timecounter_Getnanouptime( ts ); +} + +/** + * @copydoc _Timecounter_Getmicrouptime() + */ +RTEMS_INLINE_ROUTINE void rtems_bsd_getmicrouptime( struct timeval *tv ) +{ + _Timecounter_Getmicrouptime( tv ); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_BSD_H */ diff --git a/cpukit/include/rtems/bspcmdline.h b/cpukit/include/rtems/bspcmdline.h new file mode 100644 index 0000000000..51916ff26a --- /dev/null +++ b/cpukit/include/rtems/bspcmdline.h @@ -0,0 +1,131 @@ +/** + * @file rtems/bspcmdline.h + * + * @defgroup BSPCommandLine BSP Command Line Helpers + * + * @ingroup libmisc + * @brief BSP Command Line Handler + * + * This include file contains all prototypes and specifications + * related to the BSP Command Line String and associated helper + * routines. The helpers are useful for locating command line + * type arguments (e.g. --mode) and their associated right + * hand side (e.g. FAST in --mode=FAST). + */ + +/* + * COPYRIGHT (c) 1989-2009. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef __BSP_COMMAND_LINE_h +#define __BSP_COMMAND_LINE_h + +/** + * @defgroup BSPCommandLine BSP Command Line Helpers + * + * The BSP Command Line Handler provides a set of routines which assist + * in examining and decoding the Command Line String passed to the BSP + * at boot time. + */ +/**@{*/ + +#include /* for size_t */ + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * @brief Obtain Pointer to BSP Boot Command String + * + * This method returns a pointer to the BSP Boot Command String. It + * is as likely to be NULL as point to a string as most BSPs do not + * have a start environment that provides a boot string. + * + * @retval This method returns the pointer to the BSP Boot Command String. + */ +const char *rtems_bsp_cmdline_get(void); + +/** + * @brief Obtain COPY of the Entire Matching Argument + * + * This method searches for the argument @a name in the BSP Boot Command + * String and returns a copy of the entire string associated with it in + * @a value up to a string of @a length. This will include the argument + * and any right hand side portion of the string. For example, one might + * be returned --mode=FAST if + * searching for --mode. + * + * @param[in] name is the arugment to search for + * @param[in] value points to where the contents will + * be placed if located. + * @param[in] length is the maximum length to copy + * + * @return This method returns NULL if not found and + * @a value if found. + */ +const char *rtems_bsp_cmdline_get_param( + const char *name, + char *value, + size_t length +); + + +/** + * @brief Obtain COPY of the Right Hand Side of the Matching Argument + * + * This method searches for the argument @a name in + * the BSP Boot Command String and returns the right hand side + * associated with it in @a value up to a maximum string @a length. + * This will NOT include the argument but only any right hand side + * portion of the string. * For example, one might be returned FAST if + * searching for --mode. + * + * @param[in] name is the arugment to search for + * @param[in] value points to where the contents will + * be placed if located. + * @param[in] length is the maximum length to copy + * + * @retval This method returns NULL if not found and + * @a value if found. + */ +const char *rtems_bsp_cmdline_get_param_rhs( + const char *name, + char *value, + size_t length +); + +/** + * @brief Obtain Pointer to the Entire Matching Argument + * + * This method searches for the argument @a name in + * the BSP Boot Command String and returns a pointer to the + * entire string associated with it. This will include the + * argument and any right hand side portion of the string. + * For example, one might be returned --mode=FAST if + * searching for --mode. + * + * @param[in] name is the arugment to search for + * + * @retval This method returns NULL if not found and a pointer + * into the BSP Boot Command String if found. + * + * @note The pointer will be to the original BSP Command + * Line string. Exercise caution when using this. + */ +const char *rtems_bsp_cmdline_get_param_raw( + const char *name +); + +#ifdef __cplusplus +} +#endif + +/**@}*/ +#endif diff --git a/cpukit/include/rtems/capture-cli.h b/cpukit/include/rtems/capture-cli.h new file mode 100644 index 0000000000..55749b7cb1 --- /dev/null +++ b/cpukit/include/rtems/capture-cli.h @@ -0,0 +1,53 @@ +/** + * @file rtems/capture-cli.h + * + * This is the Target Interface Command Line Interface. You need + * start the RTEMS monitor. + */ + +/* + ------------------------------------------------------------------------ + + Copyright 2002, 2016 Chris Johns . + All rights reserved. + + COPYRIGHT (c) 1989-2014. + On-Line Applications Research Corporation (OAR). + + The license and distribution terms for this file may be + found in the file LICENSE in this distribution. + + This software with is provided ``as is'' and with NO WARRANTY. + + ------------------------------------------------------------------------ + + RTEMS Performance Monitoring and Measurement Framework. + + This is the Target Interface Command Line Interface. You need + start the RTEMS monitor. + +*/ + +#ifndef __CAPTURE_CLI_H_ +#define __CAPTURE_CLI_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/** + * rtems_capture_cli_init + * + * This function initialises the command line interface to the capture + * engine. + */ +rtems_status_code +rtems_capture_cli_init (rtems_capture_timestamp timestamp); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/include/rtems/capture.h b/cpukit/include/rtems/capture.h new file mode 100644 index 0000000000..f847ee0424 --- /dev/null +++ b/cpukit/include/rtems/capture.h @@ -0,0 +1,1122 @@ +/** + * @file rtems/capture.h + * + * @brief Capture Engine Component of the RTEMS Measurement and + * Monitoring System + * + * This is the Capture Engine component of the RTEMS Measurement and + * Monitoring system. + */ + +/* + ------------------------------------------------------------------------ + + Copyright 2002, 2016 Chris Johns . + All rights reserved. + + COPYRIGHT (c) 1989-2014 + On-Line Applications Research Corporation (OAR). + + The license and distribution terms for this file may be + found in the file LICENSE in this distribution. + + This software with is provided ``as is'' and with NO WARRANTY. + + ------------------------------------------------------------------------ + + RTEMS Performance Monitoring and Measurement Framework. + This is the Capture Engine component. + +*/ + +#ifndef __CAPTURE_H_ +#define __CAPTURE_H_ + +#include +#include +#include + +/** + * @defgroup libmisc_capture RTEMS Capture Engine + * + * @ingroup libmisc + * + * Capture Engine Component of the RTEMS Measurement and Monitoring System + */ +/**@{*/ +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Global capture flags. + */ +#define RTEMS_CAPTURE_INIT (1u << 0) +#define RTEMS_CAPTURE_ON (1U << 1) +#define RTEMS_CAPTURE_NO_MEMORY (1U << 2) +#define RTEMS_CAPTURE_TRIGGERED (1U << 3) +#define RTEMS_CAPTURE_GLOBAL_WATCH (1U << 4) +#define RTEMS_CAPTURE_ONLY_MONITOR (1U << 5) + +/* + * Per-CPU capture flags. + */ +#define RTEMS_CAPTURE_OVERFLOW (1U << 0) +#define RTEMS_CAPTURE_READER_ACTIVE (1U << 1) +#define RTEMS_CAPTURE_READER_WAITING (1U << 2) + +/** + * The number of tasks in a trigger group. + */ +#define RTEMS_CAPTURE_TRIGGER_TASKS (32) + +/** + * @brief A capture timestamp. + * + * This is a nanosecond capture timestamp + */ +typedef uint64_t rtems_capture_time; + +/** + * @brief Task id and mask for the from trigger. + * + * A from capture is a task id and a mask for the type of + * from trigger we are interested in. The mask uses the same + * bit maps as the flags field in the control structure. There + * will only be a from type trigger if the flags in the control + * structure has the specific *_BY bit set. + */ +typedef struct rtems_capture_from +{ + rtems_name name; + rtems_id id; + uint32_t trigger; +} rtems_capture_from; + +/** + * @brief Capture control structure for a group of tasks. + * + * RTEMS control holds the trigger and watch configuration for a group of + * tasks with the same name. The flags hold global control flags. + * + * The to_triggers fields holds triggers TO this task. The from_triggers holds + * triggers from this task. The by_triggers is an OR or triggers which are + * caused BY the task listed TO this task. The by_valid flag which entries + * in by are valid. + */ +typedef struct rtems_capture_control +{ + rtems_name name; + rtems_id id; + uint32_t flags; + uint32_t to_triggers; + uint32_t from_triggers; + uint32_t by_triggers; + uint32_t by_valid; + rtems_capture_from by[RTEMS_CAPTURE_TRIGGER_TASKS]; + struct rtems_capture_control* next; +} rtems_capture_control; + +/** + * The from_valid mask. + */ +#define RTEMS_CAPTURE_CONTROL_FROM_MASK(_s) \ + (UINT32_C(1) << (RTEMS_CAPTURE_TRIGGER_TASKS - ((_s) + 1))) + +/** + * Control flags. + */ +#define RTEMS_CAPTURE_WATCH (1U << 0) + +/** + * Control triggers. + */ +#define RTEMS_CAPTURE_SWITCH (1 << 0) +#define RTEMS_CAPTURE_CREATE (1 << 1) +#define RTEMS_CAPTURE_START (1 << 2) +#define RTEMS_CAPTURE_RESTART (1 << 3) +#define RTEMS_CAPTURE_DELETE (1 << 4) +#define RTEMS_CAPTURE_BEGIN (1 << 5) +#define RTEMS_CAPTURE_EXITTED (1 << 6) +#define RTEMS_CAPTURE_TERMINATED (1 << 7) + +#define RTEMS_CAPTURE_FROM_TRIGS (RTEMS_CAPTURE_SWITCH | \ + RTEMS_CAPTURE_CREATE | \ + RTEMS_CAPTURE_START | \ + RTEMS_CAPTURE_RESTART | \ + RTEMS_CAPTURE_DELETE) + +#define RTEMS_CAPTURE_TO_TRIGS (RTEMS_CAPTURE_SWITCH | \ + RTEMS_CAPTURE_CREATE | \ + RTEMS_CAPTURE_START | \ + RTEMS_CAPTURE_RESTART | \ + RTEMS_CAPTURE_DELETE | \ + RTEMS_CAPTURE_BEGIN | \ + RTEMS_CAPTURE_EXITTED) + +/** + * Task flags. + */ +#define RTEMS_CAPTURE_TRACED (1U << 0) +#define RTEMS_CAPTURE_INIT_TASK (1U << 1) +#define RTEMS_CAPTURE_RECORD_TASK (1U << 2) + +/* + * @brief Capture record. + * + * This is a record that is written into + * the buffer. The events includes the priority of the task + * at the time of the context switch. + */ +typedef struct rtems_capture_record +{ + size_t size; + uint32_t events; + rtems_id task_id; + rtems_capture_time time; +} RTEMS_PACKED rtems_capture_record; + +/* + * @brief Capture task record. + * + * This is a record that is written into + * the buffer. The events includes the priority of the task + * at the time of the context switch. + */ +typedef struct rtems_capture_task_record +{ + rtems_name name; + rtems_task_priority start_priority; + uint32_t stack_size; +} RTEMS_PACKED rtems_capture_task_record; + +/** + * The capture record event flags. + */ +#define RTEMS_CAPTURE_REAL_PRI_EVENT_MASK UINT32_C (0x000000ff) +#define RTEMS_CAPTURE_CURR_PRI_EVENT_MASK UINT32_C (0x0000ff00) +#define RTEMS_CAPTURE_REAL_PRIORITY_EVENT (0) +#define RTEMS_CAPTURE_CURR_PRIORITY_EVENT (8) +#define RTEMS_CAPTURE_EVENT_START (16) +#define RTEMS_CAPTURE_CREATED_BY_EVENT UINT32_C (0x00010000) +#define RTEMS_CAPTURE_CREATED_EVENT UINT32_C (0x00020000) +#define RTEMS_CAPTURE_STARTED_BY_EVENT UINT32_C (0x00040000) +#define RTEMS_CAPTURE_STARTED_EVENT UINT32_C (0x00080000) +#define RTEMS_CAPTURE_RESTARTED_BY_EVENT UINT32_C (0x00100000) +#define RTEMS_CAPTURE_RESTARTED_EVENT UINT32_C (0x00200000) +#define RTEMS_CAPTURE_DELETED_BY_EVENT UINT32_C (0x00400000) +#define RTEMS_CAPTURE_DELETED_EVENT UINT32_C (0x00800000) +#define RTEMS_CAPTURE_TERMINATED_EVENT UINT32_C (0x01000000) +#define RTEMS_CAPTURE_BEGIN_EVENT UINT32_C (0x02000000) +#define RTEMS_CAPTURE_EXITTED_EVENT UINT32_C (0x04000000) +#define RTEMS_CAPTURE_SWITCHED_OUT_EVENT UINT32_C (0x08000000) +#define RTEMS_CAPTURE_SWITCHED_IN_EVENT UINT32_C (0x10000000) +#define RTEMS_CAPTURE_TIMESTAMP UINT32_C (0x20000000) +#define RTEMS_CAPTURE_EVENT_END (29) + +/** + * @brief Capture trigger modes + * + * The types of trigger modes that exist. + */ +typedef enum rtems_capture_trigger_mode +{ + rtems_capture_to_any, + rtems_capture_from_any, + rtems_capture_from_to +} rtems_capture_trigger_mode; + +/** + * @brief Capture trigger. + * + * The types of triggers that exist. + */ +typedef enum rtems_capture_trigger +{ + rtems_capture_switch, + rtems_capture_create, + rtems_capture_start, + rtems_capture_restart, + rtems_capture_delete, + rtems_capture_begin, + rtems_capture_exitted, + rtems_capture_terminated +} rtems_capture_trigger; + +/** + * @brief Capture timestamp callout handler. + * + * This defines the callout handler to obtain a time stamp. The + * value returned is time count since the last read. + * + */ + +typedef void (*rtems_capture_timestamp)(rtems_capture_time* time); + +/** + * @brief Capture record lock context. + * + * This structure is used to lock a per CPU buffer when opeining recording. The + * per CPU buffer is held locked until the record close is called. Locking + * masks interrupts so use this lock only when needed and do not hold it for + * long. + * + * The lock first masks the CPU interrupt before taking the interrupt + * lock. This stops a thread context taking the lock and then an interrupt on + * the same CPU attempting to take the lock so creating a deadlock. + * + */ +typedef struct { + rtems_interrupt_lock_context lock_context; + rtems_interrupt_lock* lock; +} rtems_capture_record_lock_context; + +/** + * @brief Capture open + * + * This function initialises the realtime trace manager allocating the + * capture buffer. It is assumed we have a working heap at stage of + * initialisation. + * + * @param[in] size The number of capture records to define. + * @param[in] timestamp The timestamp callout handler to use. If the + * the handler is NULL a default nano-second timestamp + * will be used. + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + */ +rtems_status_code rtems_capture_open (uint32_t size, + rtems_capture_timestamp timestamp); + +/** + * @brief Capture close + * + * This function shutdowns the tracer and release any claimed + * resources. + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + */ +rtems_status_code rtems_capture_close (void); + +/** + * @brief Capture control trace enable/disable. + * + * This function allows control of tracing at a global level. + * + * @param[in] enable The trace enable/disable flag. + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + */ +rtems_status_code rtems_capture_set_control (bool enable); + +/** + * @brief Capture monitor enable/disable. + * + * This function enable the monitor mode. When in the monitor mode + * the tasks are monitored but no data is saved. This can be used + * to profile the load on a system. + * + * @param[in] enable The monitor enable/disable flag. + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + */ +rtems_status_code rtems_capture_set_monitor (bool enable); + +/* + * @brief Capture flush trace buffer. + * + * This function flushes the trace buffer. The prime parameter allows the + * capture engine to also be primed again. + * + * @param[in] prime The prime after flush flag. + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + */ +rtems_status_code rtems_capture_flush (bool prime); + +/** + * @brief Capture add watch + * + * This function defines a watch for a specific task given a name. A watch + * causes it to be traced either in or out of context. The watch can be + * optionally enabled or disabled with the set routine. It is disabled by + * default. + * + * @param[in] name The name of the @a capture_controls entry + * @param[in] id The id of the @a capture_controls entry. + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + */ +rtems_status_code rtems_capture_watch_add (rtems_name name, rtems_id id); + +/** + * @brief Capture delete watch. + * + * This function removes a watch for a specific task given a name. The task + * description will still exist if referenced by a trace record in the trace + * buffer or a global watch is defined. + * + * @param[in] name The name of the @a capture_controls entry + * @param[in] id The id of the @a capture_controls entry. + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + */ +rtems_status_code rtems_capture_watch_del (rtems_name name, rtems_id id); + +/** + * @brief Capture enable/disable watch. + * + * This function allows control of a watch. The watch can be enabled or + * disabled. + * + * @param[in] name The name of the @a capture_controls entry + * @param[in] id The id of the @a capture_controls entry. + * @param[in] enable The enable/disable flag for the watch. + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + */ +rtems_status_code rtems_capture_watch_ctrl (rtems_name name, + rtems_id id, + bool enable); + +/** + * @brief Capture enable/disable global watch. + * + * This function allows control of a global watch. The watch can + * be enabled or disabled. A global watch configures all tasks below + * the ceiling and above the floor to be traced. + * + * @param[in] enable The enable/disable flag for the watch. + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + */ +rtems_status_code rtems_capture_watch_global (bool enable); + +/** + * @brief Get global watch state + * + * This function returns the global watch state. + * + * @retval This method returns true if the global watch + * is on. Otherwise, it returns false. + */ +bool rtems_capture_watch_global_on (void); + +/** + * @brief Set watch ceiling. + * + * This function sets a watch ceiling. Events from tasks at or greater + * than the ceiling priority are ignored. This is a simple way to + * monitor an application and exclude system tasks running at a higher + * priority level. + * + * @param[in] ceiling specifies the priority level immediately above + * that at which events from tasks are not captured. + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + */ +rtems_status_code rtems_capture_watch_ceiling (rtems_task_priority ceiling); + +/** + * @brief Get watch ceiling. + * + * This function gets the watch ceiling. + * + * @retval The priority level immediately above that at which events + * from tasks are not captured. + */ +rtems_task_priority rtems_capture_watch_get_ceiling (void); + +/** + * @brief Capture set watch floor. + * + * This function sets a watch floor. Tasks at or less than the + * floor priority are not watched. This is a simple way to monitor + * an application and exclude system tasks running at a lower + * priority level. + * + * @param[in] floor specifies the priority level immediately below + * that at which events from tasks are not captured. + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + */ +rtems_status_code rtems_capture_watch_floor (rtems_task_priority floor); + +/** + * @brief Capture set watch floor + * + * This function gets the watch floor. + * + * @retval The priority level immediately below + * that at which events from tasks are not captured. + */ +rtems_task_priority rtems_capture_watch_get_floor (void); + +/** + * @brief Capture set trigger + * + * This function sets a trigger. + * + * This set trigger routine will create a trace control for the + * target task. The task list is searched and any existing tasks + * are linked to the new control. + * + * We can have a number of tasks that have the same name so we + * search using names. This means a number of tasks can be + * linked to single control. + * + * Some events captured such as context switch include two + * tasks. These are referred to as being "from" and "to" + * Some events may only have one task specified. + * + * @param[in] from_name specifies the name of the from task. + * @param[in] from_id specifies the id of the from task. + * @param[in] to_name specifies the name of the to task. + * @param[in] to_id specifies the id of the to task. + * @param[in] mode specifies the trigger mode. + * @param[in] trigger specifies the type of trigger. + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + */ +rtems_status_code +rtems_capture_set_trigger (rtems_name from_name, + rtems_id from_id, + rtems_name to_name, + rtems_id to_id, + rtems_capture_trigger_mode mode, + rtems_capture_trigger trigger); + +/** + * @brief Capture clear trigger. + * + * This function clears a trigger. + * + * This clear trigger routine will not clear a watch. + * + * @param[in] from_name specifies the name of the from task. + * @param[in] from_id specifies the id of the from task. + * @param[in] to_name specifies the name of the to task. + * @param[in] to_id specifies the id of the to task. + * @param[in] mode specifies the trigger mode. + * @param[in] trigger specifies the type of trigger. + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + */ +rtems_status_code +rtems_capture_clear_trigger (rtems_name from_name, + rtems_id from_id, + rtems_name to_name, + rtems_id to_id, + rtems_capture_trigger_mode mode, + rtems_capture_trigger trigger); + +/** + * @brief Capture read records from capture buffer + * + * This function reads a number of records from the capture buffer. + * + * The function returns the number of record that is has that are + * in a continous block of memory. If the number of available records + * wrap then only those records are provided. This removes the need for + * caller to be concerned about buffer wrappings. If the number of + * requested records cannot be met due to the wrapping of the records + * less than the specified number will be returned. + * + * The user must release the records. This is achieved with a call to + * rtems_capture_release. Calls this function without a release will + * result in at least the same number of records being released. + * + * @param[in] cpu The cpu number that the records were recorded on + * @param[out] read will contain the number of records read + * @param[out] recs The capture records that are read. + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + */ +rtems_status_code rtems_capture_read (uint32_t cpu, + size_t* read, + const void** recs); + +/** + * @brief Capture release records. + * + * This function releases the requested number of record slots back + * to the capture engine. The count must match the number read. + * + * @param[in] count The number of record slots to release + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + */ +rtems_status_code rtems_capture_release (uint32_t cpu, uint32_t count); + +/** + * @brief Capture filter + * + * This function this function specifies if the given task and events should be + * logged. + * + * @param[in] task specifies the capture task control block + * @param[in] events specifies the events + * + * @retval This method returns true if this data should be filtered from the + * log. It returns false if this data should be logged. + */ +bool rtems_capture_filter (rtems_tcb* task, uint32_t events); + +/** + * @brief Capture returns the current time. + * + * This function returns the current time. If a handler is provided + * by the user the time is gotten from that. + * + * @param[in] time specifies the capture time + * + * @retval This method returns a nano-second time if no user handler + * is provided. Otherwise, it returns a resolution defined by the handler. + */ +void rtems_capture_get_time (rtems_capture_time* time); + +/** + * @brief Capture get event text. + * + * This function returns a string for an event based on the bit in the + * event. The functions takes the bit offset as a number not the bit + * set in a bit map. + * + * @param[in] event specifies the event to describe + * + * @retval This method returns a string description of the given event. + */ +const char* rtems_capture_event_text (int event); + +/** + * @brief Capture initialize task + * + * This function initializes capture control in the tcb. + * + * @param[in] tcb is the task control block for the task + */ +void rtems_capture_initialize_task (rtems_tcb* tcb); + +/** + * @brief Capture record task. + * + * This function records a new capture task record. + * + * @param[in] tcb is the task control block for the task + */ +void rtems_capture_record_task (rtems_tcb* tcb); + +/** + * @brief Capture record lock. + * + * This does a lock acquire which will remain in effect until + * rtems_capture_record_unlock is called. + * + * @param[out] context specifies the record context + */ +void rtems_capture_record_lock (rtems_capture_record_lock_context* context); + +/** + * @brief Capture record unlock. + * + * This unlocks the record lock. + * + * @param[in] context specifies the record context + */ +void rtems_capture_record_unlock (rtems_capture_record_lock_context* context); + +/** + * @brief Capture record open. + * + * This function allocates a record and fills in the header information. It + * does a lock acquire which will remain in effect until + * rtems_capture_record_close is called. The size is the amount of user data + * being recorded. The record header is internally managed. + * + * @param[in] task specifies the caputre task block + * @param[in] events specifies the events + * @param[in] size specifies the user's capture data size + * @param[out] context specifies the record context + * + * @retval This method returns a pointer to the next location in + * the capture record to store data. + */ +void* rtems_capture_record_open (rtems_tcb* task, + uint32_t events, + size_t size, + rtems_capture_record_lock_context* context); + +/** + * @brief Capture record close. + * + * This function closes writing to capure record and releases the lock that was + * held on the per CPU buffer. + * + * @param[out] context specifies the record context + */ +void rtems_capture_record_close (rtems_capture_record_lock_context* context); + +/** + * @brief Capture append to record to the per CPU buffer. + * + * This function appends data of a specifed size into a capture buffer. + * + * @param[in] rec specifies the next write point in the capture record + * @param[in] data specifies the data to write + * @param[in] size specifies the size of the data + * + * @retval This method returns the next write point in the capture record. + */ +static inline void* +rtems_capture_record_append (void* rec, const void* data, size_t size) +{ + memcpy (rec, data, size); + return ((uint8_t*) rec) + size; +} + +/** + * @brief Capture read a record from the per CPU buffer. + * + * This function reads data of a specifed size from a capture buffer. + * + * @param[in] rec specifies the next read point in the capture record + * @param[in] data specifies where to write the data + * @param[in] size specifies the size of the data + * + * @retval This method returns the next write point in the capture record. + */ +static inline void* +rtems_capture_record_extract (const void* rec, void* data, size_t size) +{ + memcpy (data, rec, size); + return ((uint8_t*) rec) + size; +} + +/** + * @brief Capture task recorded + * + * This function returns true if this task information has been + * recorded. + * + * @param[in] tcb is the task control block for the task + */ +static inline bool rtems_capture_task_recorded (rtems_tcb* tcb) { + return ((tcb->Capture.flags & RTEMS_CAPTURE_RECORD_TASK) != 0); +} + +/** + * @brief Capture task initialized + * + * This function returns true if this task information has been + * initialized. + * + * @param[in] tcb is the task control block for the task + */ +static inline bool rtems_capture_task_initialized (rtems_tcb* tcb) { + return ((tcb->Capture.flags & RTEMS_CAPTURE_INIT_TASK) != 0); +} + +/** + * @brief Capture get task id. + * + * This function returns the task id. + * + * @param[in] task The capture task. + * + * @retval This function returns the task id. + */ +static inline rtems_id +rtems_capture_task_id (rtems_tcb* tcb) +{ + return tcb->Object.id; +} + +/** + * @brief Capture get task API. + * + * This function returns the task API as an int. + * + * @param[in] task The capture task. + * + * @retval This function returns the task API as an int. + */ +static inline int +rtems_capture_task_api (rtems_id id) +{ + return _Objects_Get_API (id); +} + +/** + * @brief Capture get task state. + * + * This function returns the task state. + * + * @param[in] task The capture task. + * + * @retval This function returns the task state. + */ +static inline States_Control +rtems_capture_task_state (rtems_tcb* tcb) +{ + if (tcb) + return tcb->current_state; + return 0; +} + +/** + * @brief Capture get task name. + * + * This function returns the task name. + * + * @param[in] task The capture task. + * + * @retval This function returns the task name. + */ +static inline rtems_name +rtems_capture_task_name (rtems_tcb* tcb) +{ + rtems_name name; + rtems_object_get_classic_name( tcb->Object.id, &name ); + return name; +} + +/** + * @brief Capture get task flags. + * + * This function returns the task flags. + * + * @param[in] task The capture task. + * + * @retval This function returns the task flags. + */ +static inline uint32_t +rtems_capture_task_flags (rtems_tcb* tcb) +{ + return tcb->Capture.flags; +} + +/** + * @brief Capture get task control + * + * This function returns the task control if present. + * + * @param[in] task The capture task. + * + * @retval This function returns the task control if present. + */ +static inline rtems_capture_control* +rtems_capture_task_control (rtems_tcb* tcb) +{ + return tcb->Capture.control; +} + +/** + * @brief Capture get task control flags. + * + * This function returns the task control flags if a control is present. + * + * @param[in] task The capture task. + * + * @retval This function returns the task control flags if a control is present. + */ +static inline uint32_t +rtems_capture_task_control_flags (rtems_tcb* tcb) +{ + rtems_capture_control* control = tcb->Capture.control; + if (!control) + return 0; + return control->flags; +} + +/** + * @brief Capture get task start priority. + * + * This function returns the tasks start priority. The tracer needs this + * to track where the task's priority goes. + * + * @param[in] task The capture task. + * + * @retval This function returns the tasks start priority. The tracer needs this + * to track where the task's priority goes. + */ +static inline rtems_task_priority +rtems_capture_task_start_priority (rtems_tcb* tcb) +{ + return _RTEMS_Priority_From_core (_Thread_Scheduler_get_home( tcb ), + tcb->Start.initial_priority); +} + +/** + * @brief Capture get task real priority. + * + * This function returns the tasks real priority. + * + * @param[in] task The capture task. + * + * @retval This function returns the tasks real priority. + */ +static inline rtems_task_priority +rtems_capture_task_real_priority (rtems_tcb* tcb) +{ + return tcb->Real_priority.priority; +} + +/** + * @brief Capture get task current priority. + * + * This function returns the tasks current priority. + * + * @param[in] task The capture task. + * + * @retval This function returns the tasks current priority. + */ +static inline rtems_task_priority +rtems_capture_task_curr_priority (rtems_tcb* tcb) +{ + return _Thread_Get_priority (tcb); +} + +/** + * @brief Capture get control list. + * + * This function returns the head of the list of controls in the + * capture engine. + * + * @retval This function returns the head of the list of controls in the + * capture engine. + */ +rtems_capture_control* +rtems_capture_get_control_list (void); + +/** + * @brief Capture get next capture control. + * + * This function returns the pointer to the next control in the list. The + * pointer NULL terminates the list. + * + * @param[in] control the current capture control. + * + * @retval This function returns the pointer to the next control in the list. The + * pointer NULL terminates the list. + */ +static inline rtems_capture_control* +rtems_capture_next_control (rtems_capture_control* control) +{ + return control->next; +} + +/** + * @brief Capture get capture control id. + * + * This function returns the control id. + * + * @param[in] control the capture control. + * + * @retval This function returns the control id. + */ +static inline rtems_id +rtems_capture_control_id (rtems_capture_control* control) +{ + return control->id; +} + +/** + * @brief Capture get capture control name. + * + * This function returns the control name. + * + * @param[in] control the capture control. + * + * @retval This function returns the control name. + */ +static inline rtems_name +rtems_capture_control_name (rtems_capture_control* control) +{ + return control->name; +} + +/** + * @brief Capture get capture control flags. + * + * This function returns the control flags. + * + * @param[in] control the capture control. + * + * @retval This function returns the control flags. + */ +static inline uint32_t +rtems_capture_control_flags (rtems_capture_control* control) +{ + return control->flags; +} + +/** + * @brief Capture get capture control to triggers. + * + * This function returns the task control to triggers. + * + * @param[in] control the capture control. + * + * @retval This function returns the task control to triggers. + */ +static inline uint32_t +rtems_capture_control_to_triggers (rtems_capture_control* control) +{ + return control->to_triggers; +} + +/** + * @brief Capture get capture control from triggers. + * + * This function returns the task control from triggers. + * + * @param[in] control the capture control. + * + * @retval This function returns the task control from triggers. + */ +static inline uint32_t +rtems_capture_control_from_triggers (rtems_capture_control* control) +{ + return control->from_triggers; +} + +/** + * @brief Capture get capture control by triggers. + * + * This function returns the task control by triggers. + * + * @param[in] control the capture control. + * + * @retval This function returns the task control by triggers. + */ +static inline uint32_t +rtems_capture_control_all_by_triggers (rtems_capture_control* control) +{ + return control->by_triggers; +} + +/** + * @brief Capture get capture control valid by flags. + * + * This function returns the control valid BY flags. + * + * @param[in] control The capture control. + * @param[in] slot The slot. + * + * @retval This function returns the control valid BY flags. + */ +static inline int +rtems_capture_control_by_valid (rtems_capture_control* control, int slot) +{ + return control->by_valid & RTEMS_CAPTURE_CONTROL_FROM_MASK (slot); +} + +/** + * @brief Capture get capture control by task name. + * + * This function returns the control @a by task name. + * + * @param[in] control The capture control. + * @param[in] by The by index. + * + * @retval This function returns the control @a by task name. + */ +static inline rtems_name +rtems_capture_control_by_name (rtems_capture_control* control, int by) +{ + if (by < RTEMS_CAPTURE_TRIGGER_TASKS) + return control->by[by].name; + return control->by[0].name; +} + +/** + * @brief Capture get capture control by task id. + * + * This function returns the control @a by task id + * + * @retval This function returns the control @a by task id. + */ +static inline rtems_id +rtems_capture_control_by_id (rtems_capture_control* control, int by) +{ + if (by < RTEMS_CAPTURE_TRIGGER_TASKS) + return control->by[by].id; + return control->by[0].id; +} + +/** + * @brief Capture get capture control by task triggers. + * + * This function returns the control @a by task triggers. + * + * @retval This function returns the control @a by task triggers. + */ +static inline uint32_t +rtems_capture_control_by_triggers (rtems_capture_control* control, + int by) +{ + if (by < RTEMS_CAPTURE_TRIGGER_TASKS) + return control->by[by].trigger; + return control->by[0].trigger; +} + +/** + * @brief Capture get capture control count. + * + * This function returns the number of controls the capture + * engine has. + * + * @retval This function returns the number of controls the capture + * engine has. + */ +static inline uint32_t +rtems_capture_control_count (void) +{ + rtems_capture_control* control = rtems_capture_get_control_list (); + uint32_t count = 0; + + while (control) + { + count++; + control = rtems_capture_next_control (control); + } + + return count; +} + +#ifdef __cplusplus +} +#endif +/**@}*/ + +#endif diff --git a/cpukit/include/rtems/captureimpl.h b/cpukit/include/rtems/captureimpl.h new file mode 100644 index 0000000000..4c4cbe66c3 --- /dev/null +++ b/cpukit/include/rtems/captureimpl.h @@ -0,0 +1,185 @@ +/** + * @file rtems/captureimpl.h + * + * @brief Capture Implementation file + * + * This file contains an interface between the capture engine and + * capture user extension methods. + */ + +/* + ------------------------------------------------------------------------ + + Copyright 2002, 2016 Chris Johns . + All rights reserved. + + COPYRIGHT (c) 1989-2014. + On-Line Applications Research Corporation (OAR). + + The license and distribution terms for this file may be + found in the file LICENSE in this distribution. + + This software with is provided ``as is'' and with NO WARRANTY. + + ------------------------------------------------------------------------ + + RTEMS Performance Monitoring and Measurement Framework. + This is the Capture Engine component. + +*/ + +#ifndef __CAPTUREIMPL_H_ +#define __CAPTUREIMPL_H_ + +#include "capture.h" + +/**@{*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Capture set extension index. + * + * This function is used to set the extension index + * for the capture engine. + * + * @param[in] index specifies the extension index to be + * used for capture engine data. + */ +void rtems_capture_set_extension_index(int index); + +/** + * @brief Capture get extension index. + * + * This function rturns the extension index for the + * capture engine. + * + * @retval This method returns the extension index. + */ +int rtems_capture_get_extension_index(void); + +/** + * @brief Capture get flags. + * + * This function gets the current flag settings + * for the capture engine. + * + * @retval This method returns the global capture + * flags. + * + */ +uint32_t rtems_capture_get_flags(void); + +/** + * @brief Capture set flags. + * + * This function sets a flag in the capture engine + * + * @param[in] mask specifies the flag to set + */ +void rtems_capture_set_flags(uint32_t mask); + +/** + * @brief Capture user extension open. + * + * This function creates the capture user extensions. + * + * + * @retval This method returns RTEMS_SUCCESSFUL upon successful + * creation of the user extensions. + */ +rtems_status_code rtems_capture_user_extension_open(void); + +/** + * @brief Capture user extension close. + * + * This function closes the capture user extensions. + * + * @retval This method returns RTEMS_SUCCESSFUL upon a successful + * delete of the user extensions. + */ +rtems_status_code rtems_capture_user_extension_close(void); + +/** + * @brief Capture check trigger. + * + * This function checks if we have triggered or if this event is a + * cause of a trigger. + * + * @param[in] ft specifies specifices the capture from task + * @param[in] tt specifies specifices the capture to task + * @param[in] events specifies the events + * + * @retval This method returns true if we have triggered or + * if the event is a cause of a trigger. + */ +bool rtems_capture_trigger_fired (rtems_tcb* ft, + rtems_tcb* tt, + uint32_t events); + +/** + * @brief Capture print trace records. + * + * This function reads, prints and releases up to + * total trace records in either a csv format or an + * ascii table format. + * + * @param[in] total specifies the number of records to print + * @param[in] csv specifies a comma seperated value format + */ +void rtems_capture_print_trace_records ( int total, bool csv ); + +/** + * @brief Capture print timestamp. + * + * This function prints uptime in a timestamp format. + * + * @param[in] uptime specifies the timestamp to print + */ +void rtems_capture_print_timestamp (uint64_t uptime); + +/** + * @brief Capture print record task. + * + * This function prints a capture record task. This + * record contains information to identify a task. It + * is refrenced in other records by the task id. + * + * @param[in] cpu specifies the cpu the cpu the record was logged on. + * @param[in] rec specifies the task record. + */ +void rtems_capture_print_record_task(int cpu, + const rtems_capture_record* rec, + const rtems_capture_task_record* task_rec); + +/** + * @brief Capture print capture record. + * + * This function prints a user extension + * capture record. + * + * @param[in] cpu specifies the cpu the cpu the record was logged on. + * @param[in] rec specifies the record. + * @param[in] diff specifies the time between this and the last capture record. + * @param[in] name specifies the name of the task, NULL if none. + * @param[in] task_count number of tasks to search for. + */ +void rtems_capture_print_record_capture(int cpu, + const rtems_capture_record* rec, + uint64_t diff, + const rtems_name* name); + +/** + * @brief Capture print watch list + * + * This function prints a capture watch list + */ +void rtems_capture_print_watch_list (void); + +#ifdef __cplusplus +} +#endif +/**@}*/ + +#endif diff --git a/cpukit/include/rtems/cbs.h b/cpukit/include/rtems/cbs.h new file mode 100644 index 0000000000..a42061ddc0 --- /dev/null +++ b/cpukit/include/rtems/cbs.h @@ -0,0 +1,244 @@ +/** + * @file + * + * @brief Constants and Structures Associated + * with the CBS library in RTEMS + * + * This include file contains all the constants and structures associated + * with the CBS library in RTEMS. + */ + +/* + * Copyright (C) 2011 Petr Benes. + * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef CONFIGURE_SCHEDULER_CBS + #error "cbs.h available only with CONFIGURE_SCHEDULER_CBS" +#endif + +#ifndef _RTEMS_CBS_H +#define _RTEMS_CBS_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Return codes. */ +#define RTEMS_CBS_OK SCHEDULER_CBS_OK +#define RTEMS_CBS_ERROR_GENERIC SCHEDULER_CBS_ERROR_GENERIC +#define RTEMS_CBS_ERROR_NO_MEMORY SCHEDULER_CBS_ERROR_NO_MEMORY +#define RTEMS_CBS_ERROR_INVALID_PARAMETER SCHEDULER_CBS_ERROR_INVALID_PARAM +#define RTEMS_CBS_ERROR_UNAUTHORIZED SCHEDULER_CBS_ERROR_UNAUTHORIZED +#define RTEMS_CBS_ERROR_UNIMPLEMENTED SCHEDULER_CBS_ERROR_UNIMPLEMENTED +#define RTEMS_CBS_ERROR_MISSING_COMPONENT SCHEDULER_CBS_ERROR_MISSING_COMPONENT +#define RTEMS_CBS_ERROR_INCONSISTENT_STATE SCHEDULER_CBS_ERROR_INCONSISTENT_STATE +#define RTEMS_CBS_ERROR_SYSTEM_OVERLOAD SCHEDULER_CBS_ERROR_SYSTEM_OVERLOAD +#define RTEMS_CBS_ERROR_INTERNAL_ERROR SCHEDULER_CBS_ERROR_INTERNAL_ERROR +#define RTEMS_CBS_ERROR_NOT_FOUND SCHEDULER_CBS_ERROR_NOT_FOUND +#define RTEMS_CBS_ERROR_FULL SCHEDULER_CBS_ERROR_FULL +#define RTEMS_CBS_ERROR_EMPTY SCHEDULER_CBS_ERROR_EMPTY +#define RTEMS_CBS_ERROR_NOSERVER SCHEDULER_CBS_ERROR_NOSERVER + +/** Callback function invoked when a budget overrun of a task occurs. */ +typedef Scheduler_CBS_Budget_overrun rtems_cbs_budget_overrun; + +/** Server id. */ +typedef Scheduler_CBS_Server_id rtems_cbs_server_id; + +/** Server parameters. */ +typedef Scheduler_CBS_Parameters rtems_cbs_parameters; + +/** + * @brief Initialize the CBS library. + * + * Initializes the CBS library. + * + * @return status code. + */ +RTEMS_INLINE_ROUTINE int rtems_cbs_initialize ( void ) +{ + return _Scheduler_CBS_Initialize(); +} + +/** + * @brief Cleanup resources associated to the CBS Library + * + * Cleanup resources associated to the CBS Library. + * + * @return status code. + */ +RTEMS_INLINE_ROUTINE int rtems_cbs_cleanup ( void ) +{ + return _Scheduler_CBS_Cleanup(); +} + +/** + * @brief Create a new server with specified parameters. + * + * Create a new server with specified parameters. + * + * @return status code. + */ +RTEMS_INLINE_ROUTINE int rtems_cbs_create_server ( + rtems_cbs_parameters *params, + rtems_cbs_budget_overrun budget_overrun_callback, + rtems_cbs_server_id *server_id +) +{ + return _Scheduler_CBS_Create_server( + params, + budget_overrun_callback, + server_id + ); +} + +/** + * @brief Attach a task to an already existing server. + * + * Attach a task to an already existing server. + * + * @return status code. + */ +RTEMS_INLINE_ROUTINE int rtems_cbs_attach_thread ( + rtems_cbs_server_id server_id, + rtems_id task_id +) +{ + return _Scheduler_CBS_Attach_thread( server_id, task_id ); +} + +/** + * @brief Detach from the CBS server. + * + * Detach from the CBS Server. + * + * @return status code. + */ +RTEMS_INLINE_ROUTINE int rtems_cbs_detach_thread ( + rtems_cbs_server_id server_id, + rtems_id task_id +) +{ + return _Scheduler_CBS_Detach_thread( server_id, task_id ); +} + +/** + * @brief Detach all tasks from a server and destroy it. + * + * Detach all tasks from a server and destroy it. + * + * @return status code. + */ +RTEMS_INLINE_ROUTINE int rtems_cbs_destroy_server ( + rtems_cbs_server_id server_id +) +{ + return _Scheduler_CBS_Destroy_server( server_id ); +} + +/** + * @brief Get CBS server id. + * + * Get a thread server id, or RTEMS_CBS_E_NOT_FOUND if it is not + * attached to any server. + * + * @return status code. + */ +RTEMS_INLINE_ROUTINE int rtems_cbs_get_server_id ( + rtems_id task_id, + rtems_cbs_server_id *server_id +) +{ + return _Scheduler_CBS_Get_server_id( task_id, server_id ); +} + +/** + * @brief Get CBS parameters. + * + * Retrieve CBS scheduling parameters. + * + * @return status code. + */ +RTEMS_INLINE_ROUTINE int rtems_cbs_get_parameters ( + rtems_cbs_server_id server_id, + rtems_cbs_parameters *params +) +{ + return _Scheduler_CBS_Get_parameters( server_id, params ); +} + +/** + * @brief Set CBS parameters. + * + * Change CBS scheduling parameters. + * + * @return status code. + */ +RTEMS_INLINE_ROUTINE int rtems_cbs_set_parameters ( + rtems_cbs_server_id server_id, + rtems_cbs_parameters *params +) +{ + return _Scheduler_CBS_Set_parameters( server_id, params ); +} + +/** + * @brief Get the CBS get execution time. + * + * Retrieve time info relative to the current server. + * + * @return status code. + */ +RTEMS_INLINE_ROUTINE int rtems_cbs_get_execution_time ( + rtems_cbs_server_id server_id, + time_t *exec_time, + time_t *abs_time +) +{ + return _Scheduler_CBS_Get_execution_time( server_id, exec_time, abs_time ); +} + +/** + * @brief Get the remaining CBS budget. + * + * Retrieve remaining budget for the current server instance. + * + * @return status code. + */ +RTEMS_INLINE_ROUTINE int rtems_cbs_get_remaining_budget ( + rtems_cbs_server_id server_id, + time_t *remaining_budget +) +{ + return _Scheduler_CBS_Get_remaining_budget( server_id, remaining_budget ); +} + +/** + * @brief Get the approved CBS budget. + * + * Retrieve the budget that has been approved for the subsequent + * server instances. + * + * @return status code. + */ +RTEMS_INLINE_ROUTINE int rtems_cbs_get_approved_budget ( + rtems_cbs_server_id server_id, + time_t *appr_budget +) +{ + return _Scheduler_CBS_Get_approved_budget( server_id, appr_budget ); +} + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/chain.h b/cpukit/include/rtems/chain.h new file mode 100644 index 0000000000..f0e7ee4f40 --- /dev/null +++ b/cpukit/include/rtems/chain.h @@ -0,0 +1,789 @@ +/** + * @file + * + * @brief Chain API + */ + +/* + * Copyright (c) 2010-2014 embedded brains GmbH. + * + * COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_CHAIN_H +#define _RTEMS_CHAIN_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicChains Chains + * + * @ingroup ClassicRTEMS + * + * @brief Chain API + */ +/**@{**/ + +typedef Chain_Node rtems_chain_node; + +typedef Chain_Control rtems_chain_control; + +/** + * @brief Chain initializer for an empty chain with designator @a name. + */ +#define RTEMS_CHAIN_INITIALIZER_EMPTY( name ) \ + CHAIN_INITIALIZER_EMPTY( name ) + +/** + * @brief Chain initializer for a chain with one @a node. + * + * @see RTEMS_CHAIN_NODE_INITIALIZER_ONE_NODE_CHAIN(). + */ +#define RTEMS_CHAIN_INITIALIZER_ONE_NODE( node ) \ + CHAIN_INITIALIZER_ONE_NODE( node ) + +/** + * @brief Chain node initializer for a @a chain containing exactly this node. + * + * @see RTEMS_CHAIN_INITIALIZER_ONE_NODE(). + */ +#define RTEMS_CHAIN_NODE_INITIALIZER_ONE_NODE_CHAIN( chain ) \ + CHAIN_NODE_INITIALIZER_ONE_NODE_CHAIN( chain ) + +/** + * @brief Chain definition for an empty chain with designator @a name. + */ +#define RTEMS_CHAIN_DEFINE_EMPTY( name ) \ + rtems_chain_control name = RTEMS_CHAIN_INITIALIZER_EMPTY( name ) + +/** + * @brief Appends the @a node to the @a chain and sends the @a events to the + * @a task if the @a chain was empty before the append. + * + * @see rtems_chain_append_with_empty_check() and rtems_event_send(). + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_ID No such task. + */ +rtems_status_code rtems_chain_append_with_notification( + rtems_chain_control *chain, + rtems_chain_node *node, + rtems_id task, + rtems_event_set events +); + +/** + * @brief Prepends the @a node to the @a chain and sends the @a events to the + * @a task if the @a chain was empty before the prepend. + * + * @see rtems_chain_prepend_with_empty_check() and rtems_event_send(). + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_ID No such task. + */ +rtems_status_code rtems_chain_prepend_with_notification( + rtems_chain_control *chain, + rtems_chain_node *node, + rtems_id task, + rtems_event_set events +); + +/** + * @brief Gets the first @a node of the @a chain and sends the @a events to the + * @a task if the @a chain is empty after the get. + * + * @see rtems_chain_get_with_empty_check() and rtems_event_send(). + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_ID No such task. + */ +rtems_status_code rtems_chain_get_with_notification( + rtems_chain_control *chain, + rtems_id task, + rtems_event_set events, + rtems_chain_node **node +); + +/** + * @brief Gets the first @a node of the @a chain and sends the @a events to the + * @a task if the @a chain is empty afterwards. + * + * @see rtems_chain_get() and rtems_event_receive(). + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_TIMEOUT Timeout. + */ +rtems_status_code rtems_chain_get_with_wait( + rtems_chain_control *chain, + rtems_event_set events, + rtems_interval timeout, + rtems_chain_node **node +); + +/** + * @brief Initialize a chain Header. + * + * This routine initializes @a the_chain structure to manage the + * contiguous array of @a number_nodes nodes which starts at + * @a starting_address. Each node is of @a node_size bytes. + * + * @param[in] the_chain specifies the chain to initialize + * @param[in] starting_address is the starting address of the array + * of elements + * @param[in] number_nodes is the number of nodes that will be in the chain + * @param[in] node_size is the size of each node + */ +RTEMS_INLINE_ROUTINE void rtems_chain_initialize( + rtems_chain_control *the_chain, + void *starting_address, + size_t number_nodes, + size_t node_size +) +{ + _Chain_Initialize( + the_chain, + starting_address, + number_nodes, + node_size + ); +} + +/** + * @brief Initialize this chain as empty. + * + * This routine initializes the specified chain to contain zero nodes. + * + * @param[in] the_chain is the chain to be initialized. + */ +RTEMS_INLINE_ROUTINE void rtems_chain_initialize_empty( + rtems_chain_control *the_chain +) +{ + _Chain_Initialize_empty( the_chain ); +} + +/** + * @brief Set off chain. + * + * This function sets the next and previous fields of the @a node to NULL + * indicating the @a node is not part of a chain. + * + * @param[in] node the node set to off chain. + */ +RTEMS_INLINE_ROUTINE void rtems_chain_set_off_chain( + rtems_chain_node *node +) +{ + _Chain_Set_off_chain( node ); +} + +/** + * @brief Initializes a chain node. + * + * In debug configurations, the node is set off chain. In all other + * configurations, this function does nothing. + * + * @param[in] the_node The chain node to initialize. + */ +RTEMS_INLINE_ROUTINE void rtems_chain_initialize_node( + rtems_chain_node *node +) +{ + _Chain_Initialize_node( node ); +} + +/** + * @brief Is the node off chain. + * + * This function returns true if the @a node is not on a chain. A @a node is + * off chain if the next and previous fields are set to NULL. + * + * @param[in] node is the node off chain. + * + * @retval true The node is off chain. + * @retval false The node is not off chain. + */ +RTEMS_INLINE_ROUTINE bool rtems_chain_is_node_off_chain( + const rtems_chain_node *node +) +{ + return _Chain_Is_node_off_chain( node ); +} + +/** + * @brief Is the chain node pointer NULL. + * + * This function returns true if the_node is NULL and false otherwise. + * + * @param[in] the_node is the node pointer to check. + * + * @retval true The chain node pointer is NULL. + * @retval false The chain node pointer is not NULL. + */ +RTEMS_INLINE_ROUTINE bool rtems_chain_is_null_node( + const rtems_chain_node *the_node +) +{ + return _Chain_Is_null_node( the_node ); +} + +/** + * @brief Return pointer to Chain Head + * + * This function returns a pointer to the first node on the chain. + * + * @param[in] the_chain is the chain to be operated upon. + * + * @return This method returns the permanent node of the chain. + */ +RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_head( + rtems_chain_control *the_chain +) +{ + return _Chain_Head( the_chain ); +} + +/** + * @brief Return pointer to immutable Chain Head + * + * This function returns a pointer to the head node on the chain. + * + * @param[in] the_chain is the chain to be operated upon. + * + * @return This method returns the permanent head node of the chain. + */ +RTEMS_INLINE_ROUTINE const rtems_chain_node *rtems_chain_immutable_head( + const rtems_chain_control *the_chain +) +{ + return _Chain_Immutable_head( the_chain ); +} + +/** + * @brief Return pointer to Chain Tail + * + * This function returns a pointer to the tail node on the chain. + * + * @param[in] the_chain is the chain to be operated upon. + * + * @return This method returns the permanent tail node of the chain. + */ +RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_tail( + rtems_chain_control *the_chain +) +{ + return _Chain_Tail( the_chain ); +} + +/** + * @brief Return pointer to immutable Chain Tail + * + * This function returns a pointer to the tail node on the chain. + * + * @param[in] the_chain is the chain to be operated upon. + * + * @return This method returns the permanent tail node of the chain. + */ +RTEMS_INLINE_ROUTINE const rtems_chain_node *rtems_chain_immutable_tail( + const rtems_chain_control *the_chain +) +{ + return _Chain_Immutable_tail( the_chain ); +} + +/** + * @brief Return pointer to Chain's First node after the permanent head. + * + * This function returns a pointer to the first node on the chain after the + * head. + * + * @param[in] the_chain is the chain to be operated upon. + * + * @return This method returns the first node of the chain. + */ +RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_first( + const rtems_chain_control *the_chain +) +{ + return _Chain_First( the_chain ); +} + +/** + * @brief Return pointer to immutable Chain's First node + * + * This function returns a pointer to the first node on the chain after the + * head. + * + * @param[in] the_chain is the chain to be operated upon. + * + * @return This method returns the first node of the chain. + */ +RTEMS_INLINE_ROUTINE const rtems_chain_node *rtems_chain_immutable_first( + const rtems_chain_control *the_chain +) +{ + return _Chain_Immutable_first( the_chain ); +} + +/** + * @brief Return pointer to Chain's Last node before the permanent tail. + * + * This function returns a pointer to the last node on the chain just before + * the tail. + * + * @param[in] the_chain is the chain to be operated upon. + * + * @return This method returns the last node of the chain. + */ +RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_last( + const rtems_chain_control *the_chain +) +{ + return _Chain_Last( the_chain ); +} + +/** + * @brief Return pointer to immutable Chain's Last node + * + * This function returns a pointer to the last node on the chain just before + * the tail. + * + * @param[in] the_chain is the chain to be operated upon. + * + * @return This method returns the last node of the chain. + */ +RTEMS_INLINE_ROUTINE const rtems_chain_node *rtems_chain_immutable_last( + const rtems_chain_control *the_chain +) +{ + return _Chain_Immutable_last( the_chain ); +} + +/** + * @brief Return pointer the next node from this node + * + * This function returns a pointer to the next node after this node. + * + * @param[in] the_node is the node to be operated upon. + * + * @return This method returns the next node on the chain. + */ +RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_next( + const rtems_chain_node *the_node +) +{ + return _Chain_Next( the_node ); +} + +/** + * @brief Return pointer the immutable next node from this node + * + * This function returns a pointer to the next node after this node. + * + * @param[in] the_node is the node to be operated upon. + * + * @return This method returns the next node on the chain. + */ +RTEMS_INLINE_ROUTINE const rtems_chain_node *rtems_chain_immutable_next( + const rtems_chain_node *the_node +) +{ + return _Chain_Immutable_next( the_node ); +} + +/** + * @brief Return pointer the previous node from this node + * + * This function returns a pointer to the previous node on this chain. + * + * @param[in] the_node is the node to be operated upon. + * + * @return This method returns the previous node on the chain. + */ +RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_previous( + const rtems_chain_node *the_node +) +{ + return _Chain_Previous( the_node ); +} + +/** + * @brief Return pointer the immutable previous node from this node. + * + * This function returns a pointer to the previous node on this chain. + * + * @param[in] the_node is the node to be operated upon. + * + * @return This method returns the previous node on the chain. + */ +RTEMS_INLINE_ROUTINE const rtems_chain_node *rtems_chain_immutable_previous( + const rtems_chain_node *the_node +) +{ + return _Chain_Immutable_previous( the_node ); +} + +/** + * @brief Are Two nodes equal. + * + * This function returns true if @a left and @a right are equal, + * and false otherwise. + * + * @param[in] left is the node on the left hand side of the comparison. + * @param[in] right is the node on the left hand side of the comparison. + * + * @retval true @a left is equal to @a right. + * @retval false @a left is not equal to @a right + */ +RTEMS_INLINE_ROUTINE bool rtems_chain_are_nodes_equal( + const rtems_chain_node *left, + const rtems_chain_node *right +) +{ + return _Chain_Are_nodes_equal( left, right ); +} + +/** + * @brief Is the chain empty + * + * This function returns true if there a no nodes on @a the_chain and + * false otherwise. + * + * @param[in] the_chain is the chain to be operated upon. + * + * @retval true The chain is empty. + * @retval false The chain is not empty. + */ +RTEMS_INLINE_ROUTINE bool rtems_chain_is_empty( + const rtems_chain_control *the_chain +) +{ + return _Chain_Is_empty( the_chain ); +} + +/** + * @brief Is this the first node on the chain. + * + * This function returns true if the_node is the first node on a chain and + * false otherwise. + * + * @param[in] the_node is the node the caller wants to know if it is + * the first node on a chain. + * + * @retval true @a the_node is the first node on a chain. + * @retval false @a the_node is not the first node on a chain. + */ +RTEMS_INLINE_ROUTINE bool rtems_chain_is_first( + const rtems_chain_node *the_node +) +{ + return _Chain_Is_first( the_node ); +} + +/** + * @brief Is this the last node on the chain. + * + * This function returns true if @a the_node is the last node on a chain and + * false otherwise. + * + * @param[in] the_node is the node to check as the last node. + * + * @retval true @a the_node is the last node on a chain. + * @retval false @a the_node is not the last node on a chain + */ +RTEMS_INLINE_ROUTINE bool rtems_chain_is_last( + const rtems_chain_node *the_node +) +{ + return _Chain_Is_last( the_node ); +} + +/** + * @brief Does this chain have only one node. + * + * This function returns true if there is only one node on @a the_chain and + * false otherwise. + * + * @param[in] the_chain is the chain to be operated upon. + * + * @retval true The chain has only one node. + * @retval false The chain has more than one nodes. + */ +RTEMS_INLINE_ROUTINE bool rtems_chain_has_only_one_node( + const rtems_chain_control *the_chain +) +{ + return _Chain_Has_only_one_node( the_chain ); +} + +/** + * @brief Is this node the chain head. + * + * This function returns true if @a the_node is the head of the_chain and + * false otherwise. + * + * @param[in] the_chain is the chain to be operated upon. + * @param[in] the_node is the node to check for being the Chain Head. + * + * @retval true @a the_node is the head of @a the_chain. + * @retval false @a the_node is not the head of @a the_chain. + */ +RTEMS_INLINE_ROUTINE bool rtems_chain_is_head( + const rtems_chain_control *the_chain, + const rtems_chain_node *the_node +) +{ + return _Chain_Is_head( the_chain, the_node ); +} + +/** + * @brief Is this node the chain tail. + * + * This function returns true if the_node is the tail of the_chain and + * false otherwise. + * + * @param[in] the_chain is the chain to be operated upon. + * @param[in] the_node is the node to check for being the Chain Tail. + * + * @retval true @a the_node is the tail of @a the_chain. + * @retval false @a the_node is not the tail of @a the_chain. + */ +RTEMS_INLINE_ROUTINE bool rtems_chain_is_tail( + const rtems_chain_control *the_chain, + const rtems_chain_node *the_node +) +{ + return _Chain_Is_tail( the_chain, the_node ); +} + +/** + * @brief Extract the specified node from a chain. + * + * This routine extracts @a the_node from the chain on which it resides. + * It disables interrupts to ensure the atomicity of the + * extract operation. + * + * @arg the_node specifies the node to extract + */ +void rtems_chain_extract( + rtems_chain_node *the_node +); + +/** + * @brief Extract the specified node from a chain (unprotected). + * + * This routine extracts @a the_node from the chain on which it resides. + * + * NOTE: It does NOT disable interrupts to ensure the atomicity of the + * append operation. + */ +RTEMS_INLINE_ROUTINE void rtems_chain_extract_unprotected( + rtems_chain_node *the_node +) +{ + _Chain_Extract_unprotected( the_node ); +} + +/** + * @brief Obtain the first node on a chain. + * + * This function removes the first node from @a the_chain and returns + * a pointer to that node. If @a the_chain is empty, then NULL is returned. + * + * @return This method returns a pointer a node. If a node was removed, + * then a pointer to that node is returned. If @a the_chain was + * empty, then NULL is returned. + * + * NOTE: It disables interrupts to ensure the atomicity of the get operation. + */ +rtems_chain_node *rtems_chain_get( + rtems_chain_control *the_chain +); + +/** + * @brief See _Chain_Get_unprotected(). + */ +RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_get_unprotected( + rtems_chain_control *the_chain +) +{ + return _Chain_Get_unprotected( the_chain ); +} + +/** + * @brief See _Chain_Get_first_unprotected(). + */ +RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_get_first_unprotected( + rtems_chain_control *the_chain +) +{ + return _Chain_Get_first_unprotected( the_chain ); +} + +/** + * @brief Insert a node on a chain + * + * This routine inserts @a the_node on a chain immediately following + * @a after_node. + * + * NOTE: It disables interrupts to ensure the atomicity + * of the extract operation. + */ +void rtems_chain_insert( + rtems_chain_node *after_node, + rtems_chain_node *the_node +); + +/** + * @brief See _Chain_Insert_unprotected(). + */ +RTEMS_INLINE_ROUTINE void rtems_chain_insert_unprotected( + rtems_chain_node *after_node, + rtems_chain_node *the_node +) +{ + _Chain_Insert_unprotected( after_node, the_node ); +} + +/** + * @brief Append a node on the end of a chain. + * + * This routine appends @a the_node onto the end of @a the_chain. + * + * NOTE: It disables interrupts to ensure the atomicity of the + * append operation. + */ +void rtems_chain_append( + rtems_chain_control *the_chain, + rtems_chain_node *the_node +); + +/** + * @brief Append a node on the end of a chain (unprotected). + * + * This routine appends @a the_node onto the end of @a the_chain. + * + * NOTE: It does NOT disable interrupts to ensure the atomicity of the + * append operation. + */ +RTEMS_INLINE_ROUTINE void rtems_chain_append_unprotected( + rtems_chain_control *the_chain, + rtems_chain_node *the_node +) +{ + _Chain_Append_unprotected( the_chain, the_node ); +} + +/** + * @brief Prepend a node. + * + * This routine prepends the_node onto the front of the_chain. + * + * @param[in] the_chain is the chain to be operated upon. + * @param[in] the_node is the node to be prepended. + * + * NOTE: It disables interrupts to ensure the atomicity of the + * prepend operation. + */ +void rtems_chain_prepend( + rtems_chain_control *the_chain, + rtems_chain_node *the_node +); + +/** + * @brief Prepend a node (unprotected). + * + * This routine prepends the_node onto the front of the_chain. + * + * @param[in] the_chain is the chain to be operated upon. + * @param[in] the_node is the node to be prepended. + * + * NOTE: It does NOT disable interrupts to ensure the atomicity of the + * prepend operation. + */ +RTEMS_INLINE_ROUTINE void rtems_chain_prepend_unprotected( + rtems_chain_control *the_chain, + rtems_chain_node *the_node +) +{ + _Chain_Prepend_unprotected( the_chain, the_node ); +} + +/** + * @brief Checks if the @a chain is empty and appends the @a node. + * + * Interrupts are disabled to ensure the atomicity of the operation. + * + * @retval true The chain was empty before the append. + * @retval false The chain contained at least one node before the append. + */ +bool rtems_chain_append_with_empty_check( + rtems_chain_control *chain, + rtems_chain_node *node +); + +/** + * @brief Checks if the @a chain is empty and prepends the @a node. + * + * Interrupts are disabled to ensure the atomicity of the operation. + * + * @retval true The chain was empty before the prepend. + * @retval false The chain contained at least one node before the prepend. + */ +bool rtems_chain_prepend_with_empty_check( + rtems_chain_control *chain, + rtems_chain_node *node +); + +/** + * @brief Tries to get the first @a node and check if the @a chain is empty + * afterwards. + * + * This function removes the first node from the @a chain and returns a pointer + * to that node in @a node. If the @a chain is empty, then @c NULL is returned. + * + * Interrupts are disabled to ensure the atomicity of the operation. + * + * @retval true The chain is empty after the node removal. + * @retval false The chain contained at least one node after the node removal. + */ +bool rtems_chain_get_with_empty_check( + rtems_chain_control *chain, + rtems_chain_node **node +); + +/** + * @brief Returns the node count of the chain. + * + * @param[in] chain The chain. + * + * @note It does NOT disable interrupts to ensure the atomicity of the + * operation. + * + * @return The node count of the chain. + */ +RTEMS_INLINE_ROUTINE size_t rtems_chain_node_count_unprotected( + const rtems_chain_control *chain +) +{ + return _Chain_Node_count_unprotected( chain ); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/confdefs.h b/cpukit/include/rtems/confdefs.h new file mode 100755 index 0000000000..1c993dd099 --- /dev/null +++ b/cpukit/include/rtems/confdefs.h @@ -0,0 +1,3587 @@ +/** + * @file + * + * @brief Configuration Table Template that will be Instantiated + * by an Application + * + * This include file contains the configuration table template that will + * be instantiated by an application based on the setting of a number + * of macros. The macros are documented in the Configuring a System + * chapter of the Classic API User's Guide + */ + +/* + * COPYRIGHT (c) 1989-2015. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef __CONFIGURATION_TEMPLATE_h +#define __CONFIGURATION_TEMPLATE_h + +/* + * Include the executive's configuration + */ +#include +#include +#include +#include +#include +#include +#include + +#ifdef CONFIGURE_DISABLE_BSP_SETTINGS + #undef BSP_DEFAULT_UNIFIED_WORK_AREAS + #undef BSP_IDLE_TASK_BODY + #undef BSP_IDLE_TASK_STACK_SIZE + #undef BSP_INITIAL_EXTENSION + #undef BSP_INTERRUPT_STACK_SIZE + #undef BSP_MAXIMUM_DEVICES + #undef BSP_ZERO_WORKSPACE_AUTOMATICALLY + #undef CONFIGURE_BSP_PREREQUISITE_DRIVERS + #undef CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK +#else + #include +#endif + +#ifdef RTEMS_NEWLIB + #include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Internal defines must be prefixed with _CONFIGURE to distinguish them from + * user-provided options which use a CONFIGURE prefix. + */ + +/** + * @defgroup Configuration RTEMS Configuration + * + * This module contains all RTEMS Configuration parameters. + * + * The model is to estimate the memory required for each configured item + * and sum those estimates. The estimate can be too high or too low for + * a variety of reasons: + * + * Reasons estimate is too high: + * + FP contexts (not all tasks are FP) + * + * Reasons estimate is too low: + * + stacks greater than minimum size + * + messages + * + application must account for device driver resources + * + application must account for add-on library resource requirements + * + * NOTE: Eventually this may be able to take into account some of + * the above. This procedure has evolved from just enough to + * support the RTEMS Test Suites into something that can be + * used remarkably reliably by most applications. + */ + +/** + * This is the Classic API initialization tasks table. + */ +extern rtems_initialization_tasks_table Initialization_tasks[]; + +#if defined(RTEMS_MULTIPROCESSING) + /** + * This it the distributed multiprocessing configuration table. + */ + extern rtems_multiprocessing_table Multiprocessing_configuration; +#endif + +#ifdef RTEMS_POSIX_API + /** + * This it the POSIX API configuration table. + */ + extern posix_api_configuration_table Configuration_POSIX_API; +#endif + +/** + * This macro determines whether the RTEMS reentrancy support for + * the Newlib C Library is enabled. + */ +#ifdef RTEMS_SCHEDSIM + #undef RTEMS_NEWLIB +#endif + +#if (defined(RTEMS_NEWLIB) && !defined(CONFIGURE_DISABLE_NEWLIB_REENTRANCY)) + #define _CONFIGURE_NEWLIB_EXTENSION 1 +#else + #define _CONFIGURE_NEWLIB_EXTENSION 0 +#endif + +#ifndef RTEMS_SCHEDSIM +#include + +#ifdef CONFIGURE_INIT + #ifndef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM + RTEMS_SYSINIT_ITEM( + rtems_filesystem_initialize, + RTEMS_SYSINIT_ROOT_FILESYSTEM, + RTEMS_SYSINIT_ORDER_MIDDLE + ); + #endif +#endif +#endif + +/** + * This macro defines the number of POSIX file descriptors allocated + * and managed by libio. These are the "integer" file descriptors that + * are used by calls like open(2) and read(2). + */ +#ifndef CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS + #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 3 +#endif + +/* + * POSIX key count used by the IO library. + */ +#define _CONFIGURE_LIBIO_POSIX_KEYS 1 + +#ifdef CONFIGURE_INIT + rtems_libio_t rtems_libio_iops[CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS]; + + /** + * When instantiating the configuration tables, this variable is + * initialized to specify the maximum number of file descriptors. + */ + const uint32_t rtems_libio_number_iops = RTEMS_ARRAY_SIZE(rtems_libio_iops); +#endif + +/* + * This macro determines if termios is disabled by this application. + * This only means that resources will not be reserved. If you end + * up using termios, it will fail. + */ +#ifdef CONFIGURE_TERMIOS_DISABLED + #define _CONFIGURE_TERMIOS_SEMAPHORES 0 +#else + /** + * This macro specifies the number of serial or PTY ports that will + * use termios. + */ + #ifndef CONFIGURE_NUMBER_OF_TERMIOS_PORTS + #define CONFIGURE_NUMBER_OF_TERMIOS_PORTS 1 + #endif + + /* + * This macro reserves the number of semaphores required by termios + * based upon the number of communication ports that will use it. + */ + #define _CONFIGURE_TERMIOS_SEMAPHORES \ + ((CONFIGURE_NUMBER_OF_TERMIOS_PORTS * 4) + 1) +#endif + +/** + * This macro specifies the number of PTYs that can be concurrently + * active. + */ +#ifndef CONFIGURE_MAXIMUM_PTYS + #define CONFIGURE_MAXIMUM_PTYS 0 +#endif + +/** + * This variable contains the maximum number of PTYs that can be + * concurrently active. + */ +#ifdef CONFIGURE_INIT + int rtems_telnetd_maximum_ptys = CONFIGURE_MAXIMUM_PTYS; +#else + extern int rtems_telnetd_maximum_ptys; +#endif + +#ifdef CONFIGURE_SMP_MAXIMUM_PROCESSORS + #warning "CONFIGURE_SMP_MAXIMUM_PROCESSORS has been renamed to CONFIGURE_MAXIMUM_PROCESSORS since RTEMS 5.1" + #define CONFIGURE_MAXIMUM_PROCESSORS CONFIGURE_SMP_MAXIMUM_PROCESSORS +#endif + +#ifndef CONFIGURE_MAXIMUM_PROCESSORS + #define CONFIGURE_MAXIMUM_PROCESSORS 1 +#endif + +/* + * An internal define to indicate that this is an SMP application + * configuration. + */ +#ifdef RTEMS_SMP + #if !defined(CONFIGURE_DISABLE_SMP_CONFIGURATION) + #define _CONFIGURE_SMP_APPLICATION + #elif CONFIGURE_MAXIMUM_PROCESSORS > 1 + #error "CONFIGURE_DISABLE_SMP_CONFIGURATION and CONFIGURE_MAXIMUM_PROCESSORS > 1 makes no sense" + #endif +#endif + +#ifdef CONFIGURE_SMP_APPLICATION + #warning "CONFIGURE_SMP_APPLICATION is obsolete since RTEMS 5.1" +#endif + +/* + * This sets up the resources for the FIFOs/pipes. + */ + +/** + * This is specified to configure the maximum number of POSIX FIFOs. + */ +#if !defined(CONFIGURE_MAXIMUM_FIFOS) + #define CONFIGURE_MAXIMUM_FIFOS 0 +#endif + +/** + * This is specified to configure the maximum number of POSIX named pipes. + */ +#if !defined(CONFIGURE_MAXIMUM_PIPES) + #define CONFIGURE_MAXIMUM_PIPES 0 +#endif + +/* + * This specifies the number of barriers required for the configured + * number of FIFOs and named pipes. + */ +#if CONFIGURE_MAXIMUM_FIFOS > 0 || CONFIGURE_MAXIMUM_PIPES > 0 + #define _CONFIGURE_BARRIERS_FOR_FIFOS \ + (2 * (CONFIGURE_MAXIMUM_FIFOS + CONFIGURE_MAXIMUM_PIPES)) +#else + #define _CONFIGURE_BARRIERS_FOR_FIFOS 0 +#endif + +/* + * This specifies the number of semaphores required for the configured + * number of FIFOs and named pipes. + */ +#if CONFIGURE_MAXIMUM_FIFOS > 0 || CONFIGURE_MAXIMUM_PIPES > 0 + #define _CONFIGURE_SEMAPHORES_FOR_FIFOS \ + (1 + (CONFIGURE_MAXIMUM_FIFOS + CONFIGURE_MAXIMUM_PIPES)) +#else + #define _CONFIGURE_SEMAPHORES_FOR_FIFOS 0 +#endif + +/** + * @defgroup ConfigFilesystems Filesystems and Mount Table Configuration + * + * @ingroup Configuration + * + * Defines to control the file system: + * + * - CONFIGURE_APPLICATION_DISABLE_FILESYSTEM: + * Disable the RTEMS filesystems. You get an empty DEVFS. + * + * - CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM: + * Use the DEVFS as the root file system. Limited functions are + * provided when this is used. + * + * - CONFIGURE_FILESYSTEM_ALL: + * Add file filesystems to the default filesystem table. + * + * List of available file systems. You can define as many as you like: + * - CONFIGURE_FILESYSTEM_IMFS - In Memory File System (IMFS) + * - CONFIGURE_FILESYSTEM_DEVFS - Device File System (DSVFS) + * - CONFIGURE_FILESYSTEM_TFTPFS - TFTP File System, networking enabled + * - CONFIGURE_FILESYSTEM_FTPFS - FTP File System, networking enabled + * - CONFIGURE_FILESYSTEM_NFS - Network File System, networking enabled + * - CONFIGURE_FILESYSTEM_DOSFS - DOS File System, uses libblock + * - CONFIGURE_FILESYSTEM_RFS - RTEMS File System (RFS), uses libblock + * - CONFIGURE_FILESYSTEM_JFFS2 - Journalling Flash File System, Version 2 + * + * Combinations: + * + * - If nothing is defined the base file system is the IMFS. + * + * - If CONFIGURE_APPLICATION_DISABLE_FILESYSTEM is defined all filesystems + * are disabled by force. + * + * - If CONFIGURE_USE_DEV_AS_BASE_FILESYSTEM is defined all filesystems + * are disabled by force and DEVFS is defined. + */ +/**@{*/ + +#ifdef CONFIGURE_INIT + + /* + * Include all file systems. Do this before checking if the filesystem has + * been disabled. + */ + #ifdef CONFIGURE_FILESYSTEM_ALL + #define CONFIGURE_FILESYSTEM_IMFS + #define CONFIGURE_FILESYSTEM_DEVFS + #define CONFIGURE_FILESYSTEM_TFTPFS + #define CONFIGURE_FILESYSTEM_FTPFS + #define CONFIGURE_FILESYSTEM_NFS + #define CONFIGURE_FILESYSTEM_DOSFS + #define CONFIGURE_FILESYSTEM_RFS + #define CONFIGURE_FILESYSTEM_JFFS2 + #endif + + /* + * If disabling the file system, give a compile error if the user has + * configured other filesystem parameters. + */ + #if defined(CONFIGURE_APPLICATION_DISABLE_FILESYSTEM) + #if defined(CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM) + #error "Filesystem disabled and a base filesystem configured." + #endif + + #if defined(CONFIGURE_FILESYSTEM_IMFS) || \ + defined(CONFIGURE_FILESYSTEM_DEVFS) || \ + defined(CONFIGURE_FILESYSTEM_TFTPFS) || \ + defined(CONFIGURE_FILESYSTEM_FTPFS) || \ + defined(CONFIGURE_FILESYSTEM_NFS) || \ + defined(CONFIGURE_FILESYSTEM_DOSFS) || \ + defined(CONFIGURE_FILESYSTEM_RFS) || \ + defined(CONFIGURE_FILESYSTEM_JFFS2) + #error "Filesystem disabled and a filesystem configured." + #endif + #endif + + /* + * If the base filesystem is DEVFS define it else define IMFS. + * We will have either DEVFS or IMFS defined after this. + */ + #if !defined(CONFIGURE_APPLICATION_DISABLE_FILESYSTEM) + #if defined(CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM) + #define CONFIGURE_FILESYSTEM_DEVFS + #endif + #endif + +#endif + +#ifndef RTEMS_SCHEDSIM +/** + * IMFS + */ +#include + +/** + * This specifies the number of bytes per block for files within the IMFS. + * There are a maximum number of blocks per file so this dictates the maximum + * size of a file. This has to be balanced with the unused portion of each + * block that might be wasted. + */ +#ifndef CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK + #define CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK \ + IMFS_MEMFILE_DEFAULT_BYTES_PER_BLOCK +#endif + +/** + * This defines the IMFS file system table entry. + */ +#if !defined(CONFIGURE_FILESYSTEM_ENTRY_IMFS) && \ + defined(CONFIGURE_FILESYSTEM_IMFS) + #define CONFIGURE_FILESYSTEM_ENTRY_IMFS \ + { RTEMS_FILESYSTEM_TYPE_IMFS, IMFS_initialize } +#endif +#endif + +#ifdef CONFIGURE_USE_MINIIMFS_AS_BASE_FILESYSTEM + #define CONFIGURE_IMFS_DISABLE_CHMOD + #define CONFIGURE_IMFS_DISABLE_CHOWN + #define CONFIGURE_IMFS_DISABLE_UTIME + #define CONFIGURE_IMFS_DISABLE_LINK + #define CONFIGURE_IMFS_DISABLE_SYMLINK + #define CONFIGURE_IMFS_DISABLE_READLINK + #define CONFIGURE_IMFS_DISABLE_RENAME + #define CONFIGURE_IMFS_DISABLE_UNMOUNT +#endif + +/** + * DEVFS + */ +#if !defined(CONFIGURE_FILESYSTEM_ENTRY_DEVFS) && \ + defined(CONFIGURE_FILESYSTEM_DEVFS) +#include + #define CONFIGURE_FILESYSTEM_ENTRY_DEVFS \ + { RTEMS_FILESYSTEM_TYPE_DEVFS, devFS_initialize } +#endif + +/** + * FTPFS + */ +#if !defined(CONFIGURE_FILESYSTEM_ENTRY_FTPFS) && \ + defined(CONFIGURE_FILESYSTEM_FTPFS) + #include + #define CONFIGURE_FILESYSTEM_ENTRY_FTPFS \ + { RTEMS_FILESYSTEM_TYPE_FTPFS, rtems_ftpfs_initialize } +#endif + +/** + * TFTPFS + */ +#if !defined(CONFIGURE_FILESYSTEM_ENTRY_TFTPFS) && \ + defined(CONFIGURE_FILESYSTEM_TFTPFS) + #include + #define CONFIGURE_FILESYSTEM_ENTRY_TFTPFS \ + { RTEMS_FILESYSTEM_TYPE_TFTPFS, rtems_tftpfs_initialize } +#endif + +/** + * NFS + */ +#if !defined(CONFIGURE_FILESYSTEM_ENTRY_NFS) && \ + defined(CONFIGURE_FILESYSTEM_NFS) + #include + #if !defined(CONFIGURE_MAXIMUM_NFS_MOUNTS) + #define CONFIGURE_MAXIMUM_NFS_MOUNTS 1 + #endif + #define CONFIGURE_FILESYSTEM_ENTRY_NFS \ + { RTEMS_FILESYSTEM_TYPE_NFS, rtems_nfs_initialize } + #define _CONFIGURE_SEMAPHORES_FOR_NFS ((CONFIGURE_MAXIMUM_NFS_MOUNTS * 2) + 1) +#else + #define _CONFIGURE_SEMAPHORES_FOR_NFS 0 +#endif + +/** + * DOSFS + */ +#if !defined(CONFIGURE_FILESYSTEM_ENTRY_DOSFS) && \ + defined(CONFIGURE_FILESYSTEM_DOSFS) + #include + #if !defined(CONFIGURE_MAXIMUM_DOSFS_MOUNTS) + #define CONFIGURE_MAXIMUM_DOSFS_MOUNTS 1 + #endif + #define CONFIGURE_FILESYSTEM_ENTRY_DOSFS \ + { RTEMS_FILESYSTEM_TYPE_DOSFS, rtems_dosfs_initialize } + #define _CONFIGURE_SEMAPHORES_FOR_DOSFS CONFIGURE_MAXIMUM_DOSFS_MOUNTS +#else + #define _CONFIGURE_SEMAPHORES_FOR_DOSFS 0 +#endif + +/** + * RFS + */ +#if !defined(CONFIGURE_FILESYSTEM_ENTRY_RFS) && \ + defined(CONFIGURE_FILESYSTEM_RFS) + #include + #if !defined(CONFIGURE_MAXIMUM_RFS_MOUNTS) + #define CONFIGURE_MAXIMUM_RFS_MOUNTS 1 + #endif + #define CONFIGURE_FILESYSTEM_ENTRY_RFS \ + { RTEMS_FILESYSTEM_TYPE_RFS, rtems_rfs_rtems_initialise } + #define _CONFIGURE_SEMAPHORES_FOR_RFS CONFIGURE_MAXIMUM_RFS_MOUNTS +#else + #define _CONFIGURE_SEMAPHORES_FOR_RFS 0 +#endif + +/** + * JFFS2 + */ +#if !defined(CONFIGURE_FILESYSTEM_ENTRY_JFFS2) && \ + defined(CONFIGURE_FILESYSTEM_JFFS2) + #include + #if !defined(CONFIGURE_MAXIMUM_JFFS2_MOUNTS) + #define CONFIGURE_MAXIMUM_JFFS2_MOUNTS 1 + #endif + #define CONFIGURE_FILESYSTEM_ENTRY_JFFS2 \ + { RTEMS_FILESYSTEM_TYPE_JFFS2, rtems_jffs2_initialize } + #define _CONFIGURE_SEMAPHORES_FOR_JFFS2 CONFIGURE_MAXIMUM_JFFS2_MOUNTS +#else + #define _CONFIGURE_SEMAPHORES_FOR_JFFS2 0 +#endif + +/** + * This computes the number of semaphores required for the various + * file systems including the FIFO plugin to the IMFS. + */ +#define _CONFIGURE_SEMAPHORES_FOR_FILE_SYSTEMS \ + (_CONFIGURE_SEMAPHORES_FOR_FIFOS + \ + _CONFIGURE_SEMAPHORES_FOR_NFS + \ + _CONFIGURE_SEMAPHORES_FOR_DOSFS + \ + _CONFIGURE_SEMAPHORES_FOR_RFS + \ + _CONFIGURE_SEMAPHORES_FOR_JFFS2) + +#ifdef CONFIGURE_INIT + + /** + * DEVFS variables. + * + * The number of individual devices that may be registered + * in the system or the CONFIGURE_MAXIMUM_DEVICES variable + * is defaulted to 4 when a filesystem is enabled, unless + * the bsp overwrides this. In which case the value is set + * to BSP_MAXIMUM_DEVICES. + */ + #ifdef CONFIGURE_FILESYSTEM_DEVFS + #ifndef CONFIGURE_MAXIMUM_DEVICES + #if defined(BSP_MAXIMUM_DEVICES) + #define CONFIGURE_MAXIMUM_DEVICES BSP_MAXIMUM_DEVICES + #else + #define CONFIGURE_MAXIMUM_DEVICES 4 + #endif + #endif + #include + #endif + + /** + * Table termination record. + */ + #define CONFIGURE_FILESYSTEM_NULL { NULL, NULL } + +#ifndef RTEMS_SCHEDSIM + #if !defined(CONFIGURE_APPLICATION_DISABLE_FILESYSTEM) && \ + !defined(CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM) + int imfs_rq_memfile_bytes_per_block = + CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK; + #endif + + /** + * The default file system table. Must be terminated with the NULL entry if + * you provide your own. + */ + #if !defined(CONFIGURE_HAS_OWN_FILESYSTEM_TABLE) && \ + !defined(CONFIGURE_APPLICATION_DISABLE_FILESYSTEM) + const rtems_filesystem_table_t rtems_filesystem_table[] = { + #if !defined(CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM) + { "/", IMFS_initialize_support }, + #endif + #if defined(CONFIGURE_FILESYSTEM_IMFS) && \ + defined(CONFIGURE_FILESYSTEM_ENTRY_IMFS) + CONFIGURE_FILESYSTEM_ENTRY_IMFS, + #endif + #if defined(CONFIGURE_FILESYSTEM_DEVFS) && \ + defined(CONFIGURE_FILESYSTEM_ENTRY_DEVFS) + CONFIGURE_FILESYSTEM_ENTRY_DEVFS, + #endif + #if defined(CONFIGURE_FILESYSTEM_TFTPFS) && \ + defined(CONFIGURE_FILESYSTEM_ENTRY_TFTPFS) + CONFIGURE_FILESYSTEM_ENTRY_TFTPFS, + #endif + #if defined(CONFIGURE_FILESYSTEM_FTPFS) && \ + defined(CONFIGURE_FILESYSTEM_ENTRY_FTPFS) + CONFIGURE_FILESYSTEM_ENTRY_FTPFS, + #endif + #if defined(CONFIGURE_FILESYSTEM_NFS) && \ + defined(CONFIGURE_FILESYSTEM_ENTRY_NFS) + CONFIGURE_FILESYSTEM_ENTRY_NFS, + #endif + #if defined(CONFIGURE_FILESYSTEM_DOSFS) && \ + defined(CONFIGURE_FILESYSTEM_ENTRY_DOSFS) + CONFIGURE_FILESYSTEM_ENTRY_DOSFS, + #endif + #if defined(CONFIGURE_FILESYSTEM_RFS) && \ + defined(CONFIGURE_FILESYSTEM_ENTRY_RFS) + CONFIGURE_FILESYSTEM_ENTRY_RFS, + #endif + #if defined(CONFIGURE_FILESYSTEM_JFFS2) && \ + defined(CONFIGURE_FILESYSTEM_ENTRY_JFFS2) + CONFIGURE_FILESYSTEM_ENTRY_JFFS2, + #endif + CONFIGURE_FILESYSTEM_NULL + }; + #endif + + #if !defined(CONFIGURE_HAS_OWN_MOUNT_TABLE) && \ + !defined(CONFIGURE_APPLICATION_DISABLE_FILESYSTEM) + #if defined(CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM) + static devFS_node devFS_root_filesystem_nodes [CONFIGURE_MAXIMUM_DEVICES]; + static const devFS_data devFS_root_filesystem_data = { + devFS_root_filesystem_nodes, + CONFIGURE_MAXIMUM_DEVICES + }; + #else + static IMFS_fs_info_t _Configure_IMFS_fs_info; + + static const rtems_filesystem_operations_table _Configure_IMFS_ops = { + rtems_filesystem_default_lock, + rtems_filesystem_default_unlock, + IMFS_eval_path, + #ifdef CONFIGURE_IMFS_DISABLE_LINK + rtems_filesystem_default_link, + #else + IMFS_link, + #endif + rtems_filesystem_default_are_nodes_equal, + #ifdef CONFIGURE_IMFS_DISABLE_MKNOD + rtems_filesystem_default_mknod, + #else + IMFS_mknod, + #endif + #ifdef CONFIGURE_IMFS_DISABLE_RMNOD + rtems_filesystem_default_rmnod, + #else + IMFS_rmnod, + #endif + #ifdef CONFIGURE_IMFS_DISABLE_CHMOD + rtems_filesystem_default_fchmod, + #else + IMFS_fchmod, + #endif + #ifdef CONFIGURE_IMFS_DISABLE_CHOWN + rtems_filesystem_default_chown, + #else + IMFS_chown, + #endif + IMFS_node_clone, + IMFS_node_free, + #ifdef CONFIGURE_IMFS_DISABLE_MOUNT + rtems_filesystem_default_mount, + #else + IMFS_mount, + #endif + #ifdef CONFIGURE_IMFS_DISABLE_UNMOUNT + rtems_filesystem_default_unmount, + #else + IMFS_unmount, + #endif + rtems_filesystem_default_fsunmount, + #ifdef CONFIGURE_IMFS_DISABLE_UTIME + rtems_filesystem_default_utime, + #else + IMFS_utime, + #endif + #ifdef CONFIGURE_IMFS_DISABLE_SYMLINK + rtems_filesystem_default_symlink, + #else + IMFS_symlink, + #endif + #ifdef CONFIGURE_IMFS_DISABLE_READLINK + rtems_filesystem_default_readlink, + #else + IMFS_readlink, + #endif + #ifdef CONFIGURE_IMFS_DISABLE_RENAME + rtems_filesystem_default_rename, + #else + IMFS_rename, + #endif + rtems_filesystem_default_statvfs + }; + + static const IMFS_mknod_controls _Configure_IMFS_mknod_controls = { + #ifdef CONFIGURE_IMFS_DISABLE_READDIR + &IMFS_mknod_control_dir_minimal, + #else + &IMFS_mknod_control_dir_default, + #endif + &IMFS_mknod_control_device, + #ifdef CONFIGURE_IMFS_DISABLE_MKNOD_FILE + &IMFS_mknod_control_enosys, + #else + &IMFS_mknod_control_memfile, + #endif + #if CONFIGURE_MAXIMUM_FIFOS > 0 || CONFIGURE_MAXIMUM_PIPES > 0 + &IMFS_mknod_control_fifo + #else + &IMFS_mknod_control_enosys + #endif + }; + + static const IMFS_mount_data _Configure_IMFS_mount_data = { + &_Configure_IMFS_fs_info, + &_Configure_IMFS_ops, + &_Configure_IMFS_mknod_controls + }; + #endif + + const rtems_filesystem_mount_configuration + rtems_filesystem_root_configuration = { + NULL, + NULL, + #if defined(CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM) + RTEMS_FILESYSTEM_TYPE_DEVFS, + #else + "/", + #endif + RTEMS_FILESYSTEM_READ_WRITE, + #if defined(CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM) + &devFS_root_filesystem_data + #else + &_Configure_IMFS_mount_data + #endif + }; + #endif + +#endif +#endif +/**@}*/ /* end of file system group */ + +/* + * STACK_CHECKER_ON was still available in 4.9 so give a warning for now. + */ +#if defined(STACK_CHECKER_ON) + #define CONFIGURE_STACK_CHECKER_ENABLED + #warning "STACK_CHECKER_ON deprecated -- use CONFIGURE_STACK_CHECKER_ENABLED" +#endif + +/** + * This configures the stack checker user extension. + */ +#ifdef CONFIGURE_STACK_CHECKER_ENABLED + #define _CONFIGURE_STACK_CHECKER_EXTENSION 1 +#else + #define _CONFIGURE_STACK_CHECKER_EXTENSION 0 +#endif + +/** + * @brief Maximum priority configuration. + * + * This configures the maximum priority value that + * a task may have. + * + * The following applies to the data space requirements + * of the Priority Scheduler. + * + * By reducing the number of priorities in a system, + * the amount of RAM required by RTEMS can be significantly + * reduced. RTEMS allocates a Chain_Control structure per + * priority and this structure contains 3 pointers. So + * the default is (256 * 12) = 3K on 32-bit architectures. + * + * This must be one less than a power of 2 between + * 4 and 256. Valid values along with the application + * priority levels and memory saved when pointers are + * 32-bits in size are: + * + * + 3, 2 application priorities, 3024 bytes saved + * + 7, 5 application priorities, 2976 bytes saved + * + 15, 13 application priorities, 2880 bytes saved + * + 31, 29 application priorities, 2688 bytes saved + * + 63, 61 application priorities, 2304 bytes saved + * + 127, 125 application priorities, 1536 bytes saved + * + 255, 253 application priorities, 0 bytes saved + * + * It is specified in terms of Classic API priority values. + */ +#ifndef CONFIGURE_MAXIMUM_PRIORITY + #define CONFIGURE_MAXIMUM_PRIORITY PRIORITY_DEFAULT_MAXIMUM +#endif + +/** + * @defgroup ConfigScheduler Scheduler configuration + * + * @ingroup Configuration + * + * The scheduler configuration allows an application to select the + * scheduling policy to use. The supported configurations are: + * + * - CONFIGURE_SCHEDULER_PRIORITY - Deterministic Priority Scheduler + * - CONFIGURE_SCHEDULER_PRIORITY_SMP - Deterministic Priority SMP Scheduler + * - CONFIGURE_SCHEDULER_PRIORITY_AFFINITY_SMP - Deterministic + * Priority SMP Affinity Scheduler + * - CONFIGURE_SCHEDULER_STRONG_APA - Strong APA Scheduler + * - CONFIGURE_SCHEDULER_SIMPLE - Light-weight Priority Scheduler + * - CONFIGURE_SCHEDULER_SIMPLE_SMP - Simple SMP Priority Scheduler + * - CONFIGURE_SCHEDULER_EDF - EDF Scheduler + * - CONFIGURE_SCHEDULER_EDF_SMP - EDF SMP Scheduler + * - CONFIGURE_SCHEDULER_CBS - CBS Scheduler + * - CONFIGURE_SCHEDULER_USER - user provided scheduler + * + * If no configuration is specified by the application in a uniprocessor + * configuration, then CONFIGURE_SCHEDULER_PRIORITY is the default. + * + * If no configuration is specified by the application in SMP + * configuration, then CONFIGURE_SCHEDULER_PRIORITY_SMP is the default. + * + * An application can define its own scheduling policy by defining + * CONFIGURE_SCHEDULER_USER and the following: + * + * - CONFIGURE_SCHEDULER_CONTEXT + * - CONFIGURE_SCHEDULER_CONTROLS + * - CONFIGURE_SCHEDULER_USER_PER_THREAD + */ + +#if !defined(CONFIGURE_SCHEDULER_USER) && \ + !defined(CONFIGURE_SCHEDULER_PRIORITY) && \ + !defined(CONFIGURE_SCHEDULER_PRIORITY_SMP) && \ + !defined(CONFIGURE_SCHEDULER_PRIORITY_AFFINITY_SMP) && \ + !defined(CONFIGURE_SCHEDULER_STRONG_APA) && \ + !defined(CONFIGURE_SCHEDULER_SIMPLE) && \ + !defined(CONFIGURE_SCHEDULER_SIMPLE_SMP) && \ + !defined(CONFIGURE_SCHEDULER_EDF) && \ + !defined(CONFIGURE_SCHEDULER_EDF_SMP) && \ + !defined(CONFIGURE_SCHEDULER_CBS) + #if defined(RTEMS_SMP) && CONFIGURE_MAXIMUM_PROCESSORS > 1 + /** + * If no scheduler is specified in an SMP configuration, the + * EDF scheduler is default. + */ + #define CONFIGURE_SCHEDULER_EDF_SMP + #else + /** + * If no scheduler is specified in a uniprocessor configuration, the + * priority scheduler is default. + */ + #define CONFIGURE_SCHEDULER_PRIORITY + #endif +#endif + +#include + +/* + * If the Priority Scheduler is selected, then configure for it. + */ +#if defined(CONFIGURE_SCHEDULER_PRIORITY) + #if !defined(CONFIGURE_SCHEDULER_NAME) + /** Configure the name of the scheduler instance */ + #define CONFIGURE_SCHEDULER_NAME rtems_build_name('U', 'P', 'D', ' ') + #endif + + #if !defined(CONFIGURE_SCHEDULER_CONTROLS) + /** Configure the context needed by the scheduler instance */ + #define CONFIGURE_SCHEDULER_CONTEXT \ + RTEMS_SCHEDULER_CONTEXT_PRIORITY( \ + dflt, \ + CONFIGURE_MAXIMUM_PRIORITY + 1 \ + ) + + /** Configure the controls for this scheduler instance */ + #define CONFIGURE_SCHEDULER_CONTROLS \ + RTEMS_SCHEDULER_CONTROL_PRIORITY(dflt, CONFIGURE_SCHEDULER_NAME) + #endif +#endif + +/* + * If the Deterministic Priority SMP Scheduler is selected, then configure for + * it. + */ +#if defined(CONFIGURE_SCHEDULER_PRIORITY_SMP) + #if !defined(CONFIGURE_SCHEDULER_NAME) + /** Configure the name of the scheduler instance */ + #define CONFIGURE_SCHEDULER_NAME rtems_build_name('M', 'P', 'D', ' ') + #endif + + #if !defined(CONFIGURE_SCHEDULER_CONTROLS) + /** Configure the context needed by the scheduler instance */ + #define CONFIGURE_SCHEDULER_CONTEXT \ + RTEMS_SCHEDULER_CONTEXT_PRIORITY_SMP( \ + dflt, \ + CONFIGURE_MAXIMUM_PRIORITY + 1 \ + ) + + /** Configure the controls for this scheduler instance */ + #define CONFIGURE_SCHEDULER_CONTROLS \ + RTEMS_SCHEDULER_CONTROL_PRIORITY_SMP(dflt, CONFIGURE_SCHEDULER_NAME) + #endif +#endif + +/* + * If the Deterministic Priority Affinity SMP Scheduler is selected, then configure for + * it. + */ +#if defined(CONFIGURE_SCHEDULER_PRIORITY_AFFINITY_SMP) + #if !defined(CONFIGURE_SCHEDULER_NAME) + /** Configure the name of the scheduler instance */ + #define CONFIGURE_SCHEDULER_NAME rtems_build_name('M', 'P', 'A', ' ') + #endif + + #if !defined(CONFIGURE_SCHEDULER_CONTROLS) + /** Configure the context needed by the scheduler instance */ + #define CONFIGURE_SCHEDULER_CONTEXT \ + RTEMS_SCHEDULER_CONTEXT_PRIORITY_AFFINITY_SMP( \ + dflt, \ + CONFIGURE_MAXIMUM_PRIORITY + 1 \ + ) + + /** Configure the controls for this scheduler instance */ + #define CONFIGURE_SCHEDULER_CONTROLS \ + RTEMS_SCHEDULER_CONTROL_PRIORITY_AFFINITY_SMP( \ + dflt, \ + CONFIGURE_SCHEDULER_NAME \ + ) + #endif +#endif + +/* + * If the Strong APA Scheduler is selected, then configure for + * it. + */ +#if defined(CONFIGURE_SCHEDULER_STRONG_APA) + #if !defined(CONFIGURE_SCHEDULER_NAME) + /** Configure the name of the scheduler instance */ + #define CONFIGURE_SCHEDULER_NAME rtems_build_name('M', 'A', 'P', 'A') + #endif + + #if !defined(CONFIGURE_SCHEDULER_CONTROLS) + /** Configure the context needed by the scheduler instance */ + #define CONFIGURE_SCHEDULER_CONTEXT \ + RTEMS_SCHEDULER_CONTEXT_STRONG_APA( \ + dflt, \ + CONFIGURE_MAXIMUM_PRIORITY + 1 \ + ) + + /** Configure the controls for this scheduler instance */ + #define CONFIGURE_SCHEDULER_CONTROLS \ + RTEMS_SCHEDULER_CONTROL_STRONG_APA(dflt, CONFIGURE_SCHEDULER_NAME) + #endif +#endif + +/* + * If the Simple Priority Scheduler is selected, then configure for it. + */ +#if defined(CONFIGURE_SCHEDULER_SIMPLE) + #if !defined(CONFIGURE_SCHEDULER_NAME) + /** Configure the name of the scheduler instance */ + #define CONFIGURE_SCHEDULER_NAME rtems_build_name('U', 'P', 'S', ' ') + #endif + + #if !defined(CONFIGURE_SCHEDULER_CONTROLS) + /** Configure the context needed by the scheduler instance */ + #define CONFIGURE_SCHEDULER_CONTEXT RTEMS_SCHEDULER_CONTEXT_SIMPLE(dflt) + + /** Configure the controls for this scheduler instance */ + #define CONFIGURE_SCHEDULER_CONTROLS \ + RTEMS_SCHEDULER_CONTROL_SIMPLE(dflt, CONFIGURE_SCHEDULER_NAME) + #endif +#endif + +/* + * If the Simple SMP Priority Scheduler is selected, then configure for it. + */ +#if defined(CONFIGURE_SCHEDULER_SIMPLE_SMP) + #if !defined(CONFIGURE_SCHEDULER_NAME) + /** Configure the name of the scheduler instance */ + #define CONFIGURE_SCHEDULER_NAME rtems_build_name('M', 'P', 'S', ' ') + #endif + + #if !defined(CONFIGURE_SCHEDULER_CONTROLS) + /** Configure the context needed by the scheduler instance */ + #define CONFIGURE_SCHEDULER_CONTEXT \ + RTEMS_SCHEDULER_CONTEXT_SIMPLE_SMP(dflt) + + /** Configure the controls for this scheduler instance */ + #define CONFIGURE_SCHEDULER_CONTROLS \ + RTEMS_SCHEDULER_CONTROL_SIMPLE_SMP(dflt, CONFIGURE_SCHEDULER_NAME) + #endif +#endif + +/* + * If the EDF Scheduler is selected, then configure for it. + */ +#if defined(CONFIGURE_SCHEDULER_EDF) + #if !defined(CONFIGURE_SCHEDULER_NAME) + /** Configure the name of the scheduler instance */ + #define CONFIGURE_SCHEDULER_NAME rtems_build_name('U', 'E', 'D', 'F') + #endif + + #if !defined(CONFIGURE_SCHEDULER_CONTROLS) + /** Configure the context needed by the scheduler instance */ + #define CONFIGURE_SCHEDULER_CONTEXT RTEMS_SCHEDULER_CONTEXT_EDF(dflt) + + /** Configure the controls for this scheduler instance */ + #define CONFIGURE_SCHEDULER_CONTROLS \ + RTEMS_SCHEDULER_CONTROL_EDF(dflt, CONFIGURE_SCHEDULER_NAME) + #endif +#endif + +/* + * If the EDF SMP Scheduler is selected, then configure for it. + */ +#if defined(CONFIGURE_SCHEDULER_EDF_SMP) + #if !defined(CONFIGURE_SCHEDULER_NAME) + /** Configure the name of the scheduler instance */ + #define CONFIGURE_SCHEDULER_NAME rtems_build_name('M', 'E', 'D', 'F') + #endif + + #if !defined(CONFIGURE_SCHEDULER_CONTROLS) + /** Configure the context needed by the scheduler instance */ + #define CONFIGURE_SCHEDULER_CONTEXT \ + RTEMS_SCHEDULER_CONTEXT_EDF_SMP(dflt, CONFIGURE_MAXIMUM_PROCESSORS) + + /** Configure the controls for this scheduler instance */ + #define CONFIGURE_SCHEDULER_CONTROLS \ + RTEMS_SCHEDULER_CONTROL_EDF_SMP(dflt, CONFIGURE_SCHEDULER_NAME) + #endif +#endif + +/* + * If the CBS Scheduler is selected, then configure for it. + */ +#if defined(CONFIGURE_SCHEDULER_CBS) + #if !defined(CONFIGURE_SCHEDULER_NAME) + /** Configure the name of the scheduler instance */ + #define CONFIGURE_SCHEDULER_NAME rtems_build_name('U', 'C', 'B', 'S') + #endif + + #if !defined(CONFIGURE_SCHEDULER_CONTROLS) + /** Configure the context needed by the scheduler instance */ + #define CONFIGURE_SCHEDULER_CONTEXT RTEMS_SCHEDULER_CONTEXT_CBS(dflt) + + /** Configure the controls for this scheduler instance */ + #define CONFIGURE_SCHEDULER_CONTROLS \ + RTEMS_SCHEDULER_CONTROL_CBS(dflt, CONFIGURE_SCHEDULER_NAME) + #endif + + #ifndef CONFIGURE_CBS_MAXIMUM_SERVERS + #define CONFIGURE_CBS_MAXIMUM_SERVERS CONFIGURE_MAXIMUM_TASKS + #endif + + #ifdef CONFIGURE_INIT + const uint32_t _Scheduler_CBS_Maximum_servers = + CONFIGURE_CBS_MAXIMUM_SERVERS; + + Scheduler_CBS_Server + _Scheduler_CBS_Server_list[ CONFIGURE_CBS_MAXIMUM_SERVERS ]; + #endif +#endif + +/* + * Set up the scheduler entry points table. The scheduling code uses + * this code to know which scheduler is configured by the user. + */ +#ifdef CONFIGURE_INIT + #if defined(CONFIGURE_SCHEDULER_CONTEXT) + CONFIGURE_SCHEDULER_CONTEXT; + #endif + + const Scheduler_Control _Scheduler_Table[] = { + CONFIGURE_SCHEDULER_CONTROLS + }; + + #define CONFIGURE_SCHEDULER_COUNT RTEMS_ARRAY_SIZE( _Scheduler_Table ) + + #if defined(RTEMS_SMP) + const size_t _Scheduler_Count = CONFIGURE_SCHEDULER_COUNT; + + const Scheduler_Assignment _Scheduler_Initial_assignments[] = { + #if defined(CONFIGURE_SMP_SCHEDULER_ASSIGNMENTS) + CONFIGURE_SMP_SCHEDULER_ASSIGNMENTS + #else + #define _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT \ + RTEMS_SCHEDULER_ASSIGN( \ + 0, \ + RTEMS_SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL \ + ) + _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #if CONFIGURE_MAXIMUM_PROCESSORS >= 2 + , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #endif + #if CONFIGURE_MAXIMUM_PROCESSORS >= 3 + , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #endif + #if CONFIGURE_MAXIMUM_PROCESSORS >= 4 + , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #endif + #if CONFIGURE_MAXIMUM_PROCESSORS >= 5 + , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #endif + #if CONFIGURE_MAXIMUM_PROCESSORS >= 6 + , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #endif + #if CONFIGURE_MAXIMUM_PROCESSORS >= 7 + , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #endif + #if CONFIGURE_MAXIMUM_PROCESSORS >= 8 + , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #endif + #if CONFIGURE_MAXIMUM_PROCESSORS >= 9 + , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #endif + #if CONFIGURE_MAXIMUM_PROCESSORS >= 10 + , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #endif + #if CONFIGURE_MAXIMUM_PROCESSORS >= 11 + , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #endif + #if CONFIGURE_MAXIMUM_PROCESSORS >= 12 + , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #endif + #if CONFIGURE_MAXIMUM_PROCESSORS >= 13 + , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #endif + #if CONFIGURE_MAXIMUM_PROCESSORS >= 14 + , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #endif + #if CONFIGURE_MAXIMUM_PROCESSORS >= 15 + , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #endif + #if CONFIGURE_MAXIMUM_PROCESSORS >= 16 + , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #endif + #if CONFIGURE_MAXIMUM_PROCESSORS >= 17 + , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #endif + #if CONFIGURE_MAXIMUM_PROCESSORS >= 18 + , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #endif + #if CONFIGURE_MAXIMUM_PROCESSORS >= 19 + , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #endif + #if CONFIGURE_MAXIMUM_PROCESSORS >= 20 + , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #endif + #if CONFIGURE_MAXIMUM_PROCESSORS >= 21 + , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #endif + #if CONFIGURE_MAXIMUM_PROCESSORS >= 22 + , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #endif + #if CONFIGURE_MAXIMUM_PROCESSORS >= 23 + , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #endif + #if CONFIGURE_MAXIMUM_PROCESSORS >= 24 + , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #endif + #if CONFIGURE_MAXIMUM_PROCESSORS >= 25 + , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #endif + #if CONFIGURE_MAXIMUM_PROCESSORS >= 26 + , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #endif + #if CONFIGURE_MAXIMUM_PROCESSORS >= 27 + , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #endif + #if CONFIGURE_MAXIMUM_PROCESSORS >= 28 + , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #endif + #if CONFIGURE_MAXIMUM_PROCESSORS >= 29 + , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #endif + #if CONFIGURE_MAXIMUM_PROCESSORS >= 30 + , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #endif + #if CONFIGURE_MAXIMUM_PROCESSORS >= 31 + , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #endif + #if CONFIGURE_MAXIMUM_PROCESSORS >= 32 + , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #endif + #undef _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT + #endif + }; + + RTEMS_STATIC_ASSERT( + CONFIGURE_MAXIMUM_PROCESSORS + == RTEMS_ARRAY_SIZE( _Scheduler_Initial_assignments ), + _Scheduler_Initial_assignments + ); + #endif +#endif +/**@}*/ /* end of Scheduler Configuration */ + +/** + * @defgroup ConfigurationIdle IDLE Thread Configuration + * + * @addtogroup Configuration + * + * This module contains configuration parameters related to the + * set of IDLE threads. On a uniprocessor system, there is one + * IDLE thread. On an SMP system, there is one for each core. + */ + +/* + * If you said the IDLE task was going to do application initialization + * and didn't override the IDLE body, then something is amiss. + */ +#if (defined(CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION) && \ + !defined(CONFIGURE_IDLE_TASK_BODY)) + #error "CONFIGURE_ERROR: You did not override the IDLE task body." +#endif + +/** + * @brief Idle task body configuration. + * + * There is a default IDLE thread body provided by RTEMS which + * has the possibility of being CPU specific. There may be a + * BSP specific override of the RTEMS default body and in turn, + * the application may override and provide its own. + */ +#ifndef CONFIGURE_IDLE_TASK_BODY + #if defined(BSP_IDLE_TASK_BODY) + #define CONFIGURE_IDLE_TASK_BODY BSP_IDLE_TASK_BODY + #elif (CPU_PROVIDES_IDLE_THREAD_BODY == TRUE) + #define CONFIGURE_IDLE_TASK_BODY _CPU_Thread_Idle_body + #else + /* only instantiate and compile if used */ + #ifdef CONFIGURE_INIT + void *_Thread_Idle_body(uintptr_t ignored) + { + for( ; ; ) ; + return 0; /* to avoid warning */ + } + #endif + #define CONFIGURE_IDLE_TASK_BODY _Thread_Idle_body + #endif +#endif +/**@}*/ /* end of IDLE thread configuration */ + +/** + * @defgroup ConfigurationStackSize Configuration Thread Stack Size + * + * @addtogroup Configuration + * + * This module contains parameters related to thread aand interrupt stacks. + */ + +/** + * By default, use the minimum stack size requested by this port. + */ +#ifndef CONFIGURE_MINIMUM_TASK_STACK_SIZE + #define CONFIGURE_MINIMUM_TASK_STACK_SIZE CPU_STACK_MINIMUM_SIZE +#endif + +/** + * This specifies the default POSIX thread stack size. By default, it is + * twice that recommended for the port. + */ +#define CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE \ + (2 * CONFIGURE_MINIMUM_TASK_STACK_SIZE) + +/** + * @brief Idle task stack size configuration. + * + * By default, the IDLE task will have a stack of minimum size. + * The BSP or application may override this value. + */ +#ifndef CONFIGURE_IDLE_TASK_STACK_SIZE + #ifdef BSP_IDLE_TASK_STACK_SIZE + #define CONFIGURE_IDLE_TASK_STACK_SIZE BSP_IDLE_TASK_STACK_SIZE + #else + #define CONFIGURE_IDLE_TASK_STACK_SIZE CONFIGURE_MINIMUM_TASK_STACK_SIZE + #endif +#endif +#if CONFIGURE_IDLE_TASK_STACK_SIZE < CONFIGURE_MINIMUM_TASK_STACK_SIZE + #error "CONFIGURE_IDLE_TASK_STACK_SIZE less than CONFIGURE_MINIMUM_TASK_STACK_SIZE" +#endif + +/** + * @brief Interrupt stack size configuration. + * + * By default, the interrupt stack will be of minimum size. + * The BSP or application may override this value. + */ +#ifndef CONFIGURE_INTERRUPT_STACK_SIZE + #ifdef BSP_INTERRUPT_STACK_SIZE + #define CONFIGURE_INTERRUPT_STACK_SIZE BSP_INTERRUPT_STACK_SIZE + #else + #define CONFIGURE_INTERRUPT_STACK_SIZE CONFIGURE_MINIMUM_TASK_STACK_SIZE + #endif +#endif + +/** + * This reserves memory for the interrupt stack if it is to be allocated + * by RTEMS rather than the BSP. + * + * @todo Try to get to the point where all BSPs support allocating the + * memory from the Workspace. + */ +#if (CPU_ALLOCATE_INTERRUPT_STACK == 0) + #define _CONFIGURE_INTERRUPT_STACK_MEMORY 0 +#else + #define _CONFIGURE_INTERRUPT_STACK_MEMORY \ + _Configure_From_workspace( CONFIGURE_INTERRUPT_STACK_SIZE ) +#endif + +/** + * Configure the very much optional task stack allocator initialization + */ +#ifndef CONFIGURE_TASK_STACK_ALLOCATOR_INIT + #define CONFIGURE_TASK_STACK_ALLOCATOR_INIT NULL +#endif + +/* + * Configure the very much optional task stack allocator and deallocator. + */ +#if !defined(CONFIGURE_TASK_STACK_ALLOCATOR) \ + && !defined(CONFIGURE_TASK_STACK_DEALLOCATOR) + /** + * This specifies the task stack allocator method. + */ + #define CONFIGURE_TASK_STACK_ALLOCATOR _Workspace_Allocate + /** + * This specifies the task stack deallocator method. + */ + #define CONFIGURE_TASK_STACK_DEALLOCATOR _Workspace_Free +#elif (defined(CONFIGURE_TASK_STACK_ALLOCATOR) \ + && !defined(CONFIGURE_TASK_STACK_DEALLOCATOR)) \ + || (!defined(CONFIGURE_TASK_STACK_ALLOCATOR) \ + && defined(CONFIGURE_TASK_STACK_DEALLOCATOR)) + #error "CONFIGURE_TASK_STACK_ALLOCATOR and CONFIGURE_TASK_STACK_DEALLOCATOR must be both defined or both undefined" +#endif +/**@}*/ /* end of thread/interrupt stack configuration */ + +/** + * @addtogroup Configuration + */ +/**@{*/ + +/** + * Should the RTEMS Workspace and C Program Heap be cleared automatically + * at system start up? + */ +#ifndef CONFIGURE_ZERO_WORKSPACE_AUTOMATICALLY + #ifdef BSP_ZERO_WORKSPACE_AUTOMATICALLY + #define CONFIGURE_ZERO_WORKSPACE_AUTOMATICALLY \ + BSP_ZERO_WORKSPACE_AUTOMATICALLY + #else + #define CONFIGURE_ZERO_WORKSPACE_AUTOMATICALLY FALSE + #endif +#endif +/**@}*/ /* end of add to group Configuration */ + +/** + * @defgroup ConfigurationMalloc RTEMS Malloc configuration + * + * This module contains parameters related to configuration of the RTEMS + * Malloc implementation. + */ +/**@{*/ +#include + +#ifdef CONFIGURE_INIT + /** + * By default, RTEMS uses separate heaps for the RTEMS Workspace and + * the C Program Heap. The application can choose optionally to combine + * these to provide one larger memory pool. This is particularly + * useful in combination with the unlimited objects configuration. + */ + #ifdef CONFIGURE_UNIFIED_WORK_AREAS + Heap_Control *RTEMS_Malloc_Heap = &_Workspace_Area; + #else + Heap_Control RTEMS_Malloc_Area; + Heap_Control *RTEMS_Malloc_Heap = &RTEMS_Malloc_Area; + #endif +#endif + +#ifdef CONFIGURE_INIT + /** + * This configures the sbrk() support for the malloc family. + * By default it is assumed that the BSP provides all available + * RAM to the malloc family implementation so sbrk()'ing to get + * more memory would always fail anyway. + */ + const rtems_heap_extend_handler rtems_malloc_extend_handler = + #ifdef CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK + rtems_heap_extend_via_sbrk; + #else + rtems_heap_null_extend; + #endif +#endif + +#ifdef CONFIGURE_INIT + /** + * This configures the malloc family plugin which dirties memory + * allocated. This is helpful for finding unitialized data structure + * problems. + */ + rtems_malloc_dirtier_t rtems_malloc_dirty_helper = + #if defined(CONFIGURE_MALLOC_DIRTY) + rtems_malloc_dirty_memory; + #else + NULL; + #endif +#endif +/**@}*/ /* end of Malloc Configuration */ + +/** + * @defgroup ConfigurationHelpers Configuration Helpers + * + * @ingroup Configuration + * + * This module contains items which are used internally to ease + * the configuration calculations. + */ +/**@{*/ + +/** + * Zero of one returns 0 if the parameter is 0 else 1 is returned. + */ +#define _Configure_Zero_or_One(_number) ((_number) ? 1 : 0) + +/** + * General helper to align up a value. + */ +#define _Configure_Align_up(_val, _align) \ + (((_val) + (_align) - 1) - ((_val) + (_align) - 1) % (_align)) + +#define _CONFIGURE_HEAP_MIN_BLOCK_SIZE \ + _Configure_Align_up(sizeof(Heap_Block), CPU_HEAP_ALIGNMENT) + +/** + * This is a helper macro used in calculations in this file. It is used + * to noted when an element is allocated from the RTEMS Workspace and adds + * a factor to account for heap overhead plus an alignment factor that + * may be applied. + */ +#define _Configure_From_workspace(_size) \ + (ssize_t) (_Configure_Zero_or_One(_size) * \ + _Configure_Align_up(_size + HEAP_BLOCK_HEADER_SIZE, \ + _CONFIGURE_HEAP_MIN_BLOCK_SIZE)) + +/** + * This is a helper macro used in stack space calculations in this file. It + * may be provided by the application in case a special task stack allocator + * is used. The default is allocation from the RTEMS Workspace. + */ +#ifdef CONFIGURE_TASK_STACK_FROM_ALLOCATOR + #define _Configure_From_stackspace(_stack_size) \ + CONFIGURE_TASK_STACK_FROM_ALLOCATOR(_stack_size) +#else + #define _Configure_From_stackspace(_stack_size) \ + _Configure_From_workspace(_stack_size) +#endif + +/** + * Do not use the unlimited bit as part of the multiplication + * for memory usage. + */ +#define _Configure_Max_Objects(_max) \ + (_Configure_Zero_or_One(_max) * rtems_resource_maximum_per_allocation(_max)) + +/** + * This macro accounts for how memory for a set of configured objects is + * allocated from the Executive Workspace. + * + * NOTE: It does NOT attempt to address the more complex case of unlimited + * objects. + */ +#define _Configure_Object_RAM(_number, _size) ( \ + _Configure_From_workspace(_Configure_Max_Objects(_number) * (_size)) + \ + _Configure_From_workspace( \ + _Configure_Zero_or_One(_number) * ( \ + (_Configure_Max_Objects(_number) + 1) * sizeof(Objects_Control *) + \ + _Configure_Align_up(sizeof(void *), CPU_ALIGNMENT) + \ + _Configure_Align_up(sizeof(uint32_t), CPU_ALIGNMENT) \ + ) \ + ) \ + ) +/**@}*/ + +/** + * @defgroup ConfigurationInitTasksTable Initialization Tasks Configuration + * + * @addtogroup Configuration + * + * This group contains the elements needed to define the Classic API + * Initialization Tasks Table. + * + * Default User Initialization Task Table. This table guarantees that + * one user initialization table is defined. + */ +#ifdef CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#ifdef CONFIGURE_HAS_OWN_INIT_TASK_TABLE + +/* + * The user is defining their own table information and setting the + * appropriate variables. + */ + +#else + +/** + * When using the default Classic API Initialization Tasks Table, this is + * used to specify the name of the single Classic API task. + */ +#ifndef CONFIGURE_INIT_TASK_NAME + #define CONFIGURE_INIT_TASK_NAME rtems_build_name('U', 'I', '1', ' ') +#endif + +/** + * When using the default Classic API Initialization Tasks Table, this is + * used to specify the stack size of the single Classic API task. + */ +#ifndef CONFIGURE_INIT_TASK_STACK_SIZE + #define CONFIGURE_INIT_TASK_STACK_SIZE CONFIGURE_MINIMUM_TASK_STACK_SIZE +#endif + +/** + * When using the default Classic API Initialization Tasks Table, this is + * used to specify the priority of the single Classic API task. + */ +#ifndef CONFIGURE_INIT_TASK_PRIORITY + #define CONFIGURE_INIT_TASK_PRIORITY 1 +#endif + +/** + * When using the default Classic API Initialization Tasks Table, this is + * used to specify the attributes size of the single Classic API task. + */ +#ifndef CONFIGURE_INIT_TASK_ATTRIBUTES + #define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_DEFAULT_ATTRIBUTES +#endif + +/** + * When using the default Classic API Initialization Tasks Table, this is + * used to specify the entry point of the single Classic API task. + */ +#ifndef CONFIGURE_INIT_TASK_ENTRY_POINT + #ifdef __cplusplus + extern "C" { + #endif + rtems_task Init (rtems_task_argument ); + #ifdef __cplusplus + } + #endif + #define CONFIGURE_INIT_TASK_ENTRY_POINT Init + extern const char* bsp_boot_cmdline; + #define CONFIGURE_INIT_TASK_ARGUMENTS ((rtems_task_argument) &bsp_boot_cmdline) +#endif + +/** + * When using the default Classic API Initialization Tasks Table, this is + * used to specify the initial execution mode of the single Classic API task. + */ +#ifndef CONFIGURE_INIT_TASK_INITIAL_MODES + #ifdef _CONFIGURE_SMP_APPLICATION + #define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_DEFAULT_MODES + #else + #define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_NO_PREEMPT + #endif +#endif + +/** + * When using the default Classic API Initialization Tasks Table, this is + * used to specify the initial argument to the single Classic API task. + */ +#ifndef CONFIGURE_INIT_TASK_ARGUMENTS + #define CONFIGURE_INIT_TASK_ARGUMENTS 0 +#endif + +#ifdef CONFIGURE_INIT + rtems_initialization_tasks_table Initialization_tasks[] = { + { CONFIGURE_INIT_TASK_NAME, + CONFIGURE_INIT_TASK_STACK_SIZE, + CONFIGURE_INIT_TASK_PRIORITY, + CONFIGURE_INIT_TASK_ATTRIBUTES, + CONFIGURE_INIT_TASK_ENTRY_POINT, + CONFIGURE_INIT_TASK_INITIAL_MODES, + CONFIGURE_INIT_TASK_ARGUMENTS + } + }; +#endif + +/** + * This is the name of the Initialization Tasks Table generated. + */ +#define CONFIGURE_INIT_TASK_TABLE Initialization_tasks + +/* + * This is the size of the Initialization Tasks Table generated. + */ +#define CONFIGURE_INIT_TASK_TABLE_SIZE \ + RTEMS_ARRAY_SIZE(CONFIGURE_INIT_TASK_TABLE) + +#endif /* CONFIGURE_HAS_OWN_INIT_TASK_TABLE */ + +#else /* CONFIGURE_RTEMS_INIT_TASKS_TABLE */ + +/* + * This is the name of the Initialization Task when none is configured. + */ +#define CONFIGURE_INIT_TASK_TABLE NULL + +/* + * This is the size of the Initialization Task when none is configured. + */ +#define CONFIGURE_INIT_TASK_TABLE_SIZE 0 + +/* + * This is the stack size of the Initialization Task when none is configured. + */ +#define CONFIGURE_INIT_TASK_STACK_SIZE 0 + +#endif +/**@}*/ /* end of Classic API Initialization Tasks Table */ + +/** + * @defgroup ConfigurationDriverTable Device Driver Table Configuration + * + * @addtogroup Configuration + * + * This group contains parameters related to generating a Device Driver + * Table. + * + * Default Device Driver Table. Each driver needed by the test is explicitly + * choosen by the application. There is always a null driver entry. + */ +/**@{*/ + +/** + * This is an empty device driver slot. + */ +#define NULL_DRIVER_TABLE_ENTRY \ + { NULL, NULL, NULL, NULL, NULL, NULL } + +#if defined(CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER) && \ + defined(CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER) +#error "CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER and CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER are mutually exclusive" +#endif + +#ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER + #include +#endif + +#ifdef CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER + #include + + #ifdef CONFIGURE_INIT + RTEMS_SYSINIT_ITEM( + _Console_simple_Initialize, + RTEMS_SYSINIT_DEVICE_DRIVERS, + RTEMS_SYSINIT_ORDER_SECOND + ); + #endif +#endif + +#ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + #include +#endif + +#ifdef CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER + #include +#endif + +#ifdef CONFIGURE_APPLICATION_NEEDS_RTC_DRIVER + #include +#endif + +#ifdef CONFIGURE_APPLICATION_NEEDS_WATCHDOG_DRIVER + #include +#endif + +#ifdef CONFIGURE_APPLICATION_NEEDS_FRAME_BUFFER_DRIVER + #include +#endif + +#ifdef CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER + #include +#endif + +#ifdef CONFIGURE_APPLICATION_NEEDS_ZERO_DRIVER + #include +#endif + +#ifdef CONFIGURE_APPLICATION_NEEDS_IDE_DRIVER + /* the ide driver needs the ATA driver */ + #ifndef CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER + #define CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER + #endif + #include +#endif + +#ifdef CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER + #include +#endif + +#ifndef CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE + +/** + * This specifies the maximum number of device drivers that + * can be installed in the system at one time. It must account + * for both the statically and dynamically installed drivers. + */ +#ifndef CONFIGURE_MAXIMUM_DRIVERS + #define CONFIGURE_MAXIMUM_DRIVERS +#endif + +#ifdef CONFIGURE_INIT + rtems_driver_address_table + _IO_Driver_address_table[ CONFIGURE_MAXIMUM_DRIVERS ] = { + #ifdef CONFIGURE_BSP_PREREQUISITE_DRIVERS + CONFIGURE_BSP_PREREQUISITE_DRIVERS, + #endif + #ifdef CONFIGURE_APPLICATION_PREREQUISITE_DRIVERS + CONFIGURE_APPLICATION_PREREQUISITE_DRIVERS, + #endif + #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER + CONSOLE_DRIVER_TABLE_ENTRY, + #endif + #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER + CLOCK_DRIVER_TABLE_ENTRY, + #endif + #ifdef CONFIGURE_APPLICATION_NEEDS_RTC_DRIVER + RTC_DRIVER_TABLE_ENTRY, + #endif + #ifdef CONFIGURE_APPLICATION_NEEDS_WATCHDOG_DRIVER + WATCHDOG_DRIVER_TABLE_ENTRY, + #endif + #ifdef CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER + DEVNULL_DRIVER_TABLE_ENTRY, + #endif + #ifdef CONFIGURE_APPLICATION_NEEDS_ZERO_DRIVER + DEVZERO_DRIVER_TABLE_ENTRY, + #endif + #ifdef CONFIGURE_APPLICATION_NEEDS_IDE_DRIVER + IDE_CONTROLLER_DRIVER_TABLE_ENTRY, + #endif + #ifdef CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER + ATA_DRIVER_TABLE_ENTRY, + #endif + #ifdef CONFIGURE_APPLICATION_NEEDS_FRAME_BUFFER_DRIVER + FRAME_BUFFER_DRIVER_TABLE_ENTRY, + #endif + #ifdef CONFIGURE_APPLICATION_EXTRA_DRIVERS + CONFIGURE_APPLICATION_EXTRA_DRIVERS, + #endif + #ifdef CONFIGURE_APPLICATION_NEEDS_NULL_DRIVER + NULL_DRIVER_TABLE_ENTRY + #elif !defined(CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER) && \ + !defined(CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER) && \ + !defined(CONFIGURE_APPLICATION_NEEDS_RTC_DRIVER) && \ + !defined(CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER) && \ + !defined(CONFIGURE_APPLICATION_NEEDS_ZERO_DRIVER) && \ + !defined(CONFIGURE_APPLICATION_NEEDS_IDE_DRIVER) && \ + !defined(CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER) && \ + !defined(CONFIGURE_APPLICATION_NEEDS_FRAME_BUFFER_DRIVER) && \ + !defined(CONFIGURE_APPLICATION_EXTRA_DRIVERS) + NULL_DRIVER_TABLE_ENTRY + #endif + }; + + const size_t _IO_Number_of_drivers = + RTEMS_ARRAY_SIZE( _IO_Driver_address_table ); +#endif + +#endif /* CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE */ + +#ifdef CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER + /* + * configure the priority of the ATA driver task + */ + #ifndef CONFIGURE_ATA_DRIVER_TASK_PRIORITY + #define CONFIGURE_ATA_DRIVER_TASK_PRIORITY ATA_DRIVER_TASK_DEFAULT_PRIORITY + #endif + #ifdef CONFIGURE_INIT + rtems_task_priority rtems_ata_driver_task_priority + = CONFIGURE_ATA_DRIVER_TASK_PRIORITY; + #endif /* CONFIGURE_INIT */ +#endif +/**@}*/ /* end of Device Driver Table Configuration */ + +/** + * @defgroup ConfigurationLibBlock Configuration of LIBBLOCK + * + * @addtogroup Configuration + * + * This module contains parameters related to the LIBBLOCK buffering + * and caching subsystem. It requires tasks to swap out data to be + * written to non-volatile storage. + */ +/**@{*/ +#ifdef CONFIGURE_APPLICATION_NEEDS_LIBBLOCK + #include + /* + * configure the bdbuf cache parameters + */ + #ifndef CONFIGURE_BDBUF_MAX_READ_AHEAD_BLOCKS + #define CONFIGURE_BDBUF_MAX_READ_AHEAD_BLOCKS \ + RTEMS_BDBUF_MAX_READ_AHEAD_BLOCKS_DEFAULT + #endif + #ifndef CONFIGURE_BDBUF_MAX_WRITE_BLOCKS + #define CONFIGURE_BDBUF_MAX_WRITE_BLOCKS \ + RTEMS_BDBUF_MAX_WRITE_BLOCKS_DEFAULT + #endif + #ifndef CONFIGURE_SWAPOUT_TASK_PRIORITY + #define CONFIGURE_SWAPOUT_TASK_PRIORITY \ + RTEMS_BDBUF_SWAPOUT_TASK_PRIORITY_DEFAULT + #endif + #ifndef CONFIGURE_SWAPOUT_SWAP_PERIOD + #define CONFIGURE_SWAPOUT_SWAP_PERIOD \ + RTEMS_BDBUF_SWAPOUT_TASK_SWAP_PERIOD_DEFAULT + #endif + #ifndef CONFIGURE_SWAPOUT_BLOCK_HOLD + #define CONFIGURE_SWAPOUT_BLOCK_HOLD \ + RTEMS_BDBUF_SWAPOUT_TASK_BLOCK_HOLD_DEFAULT + #endif + #ifndef CONFIGURE_SWAPOUT_WORKER_TASKS + #define CONFIGURE_SWAPOUT_WORKER_TASKS \ + RTEMS_BDBUF_SWAPOUT_WORKER_TASKS_DEFAULT + #endif + #ifndef CONFIGURE_SWAPOUT_WORKER_TASK_PRIORITY + #define CONFIGURE_SWAPOUT_WORKER_TASK_PRIORITY \ + RTEMS_BDBUF_SWAPOUT_WORKER_TASK_PRIORITY_DEFAULT + #endif + #ifndef CONFIGURE_BDBUF_TASK_STACK_SIZE + #define CONFIGURE_BDBUF_TASK_STACK_SIZE \ + RTEMS_BDBUF_TASK_STACK_SIZE_DEFAULT + #endif + #ifndef CONFIGURE_BDBUF_CACHE_MEMORY_SIZE + #define CONFIGURE_BDBUF_CACHE_MEMORY_SIZE \ + RTEMS_BDBUF_CACHE_MEMORY_SIZE_DEFAULT + #endif + #ifndef CONFIGURE_BDBUF_BUFFER_MIN_SIZE + #define CONFIGURE_BDBUF_BUFFER_MIN_SIZE \ + RTEMS_BDBUF_BUFFER_MIN_SIZE_DEFAULT + #endif + #ifndef CONFIGURE_BDBUF_BUFFER_MAX_SIZE + #define CONFIGURE_BDBUF_BUFFER_MAX_SIZE \ + RTEMS_BDBUF_BUFFER_MAX_SIZE_DEFAULT + #endif + #ifndef CONFIGURE_BDBUF_READ_AHEAD_TASK_PRIORITY + #define CONFIGURE_BDBUF_READ_AHEAD_TASK_PRIORITY \ + RTEMS_BDBUF_READ_AHEAD_TASK_PRIORITY_DEFAULT + #endif + #ifdef CONFIGURE_INIT + const rtems_bdbuf_config rtems_bdbuf_configuration = { + CONFIGURE_BDBUF_MAX_READ_AHEAD_BLOCKS, + CONFIGURE_BDBUF_MAX_WRITE_BLOCKS, + CONFIGURE_SWAPOUT_TASK_PRIORITY, + CONFIGURE_SWAPOUT_SWAP_PERIOD, + CONFIGURE_SWAPOUT_BLOCK_HOLD, + CONFIGURE_SWAPOUT_WORKER_TASKS, + CONFIGURE_SWAPOUT_WORKER_TASK_PRIORITY, + CONFIGURE_BDBUF_TASK_STACK_SIZE, + CONFIGURE_BDBUF_CACHE_MEMORY_SIZE, + CONFIGURE_BDBUF_BUFFER_MIN_SIZE, + CONFIGURE_BDBUF_BUFFER_MAX_SIZE, + CONFIGURE_BDBUF_READ_AHEAD_TASK_PRIORITY + }; + #endif + + #define _CONFIGURE_LIBBLOCK_TASKS \ + (1 + CONFIGURE_SWAPOUT_WORKER_TASKS + \ + (CONFIGURE_BDBUF_MAX_READ_AHEAD_BLOCKS != 0)) + + #define _CONFIGURE_LIBBLOCK_TASK_EXTRA_STACKS \ + (_CONFIGURE_LIBBLOCK_TASKS * \ + (CONFIGURE_BDBUF_TASK_STACK_SIZE <= CONFIGURE_MINIMUM_TASK_STACK_SIZE ? \ + 0 : CONFIGURE_BDBUF_TASK_STACK_SIZE - CONFIGURE_MINIMUM_TASK_STACK_SIZE)) + + #ifdef RTEMS_BDBUF_USE_PTHREAD + /* + * Semaphores: + * o disk lock + */ + #define _CONFIGURE_LIBBLOCK_SEMAPHORES 1 + #else + /* + * Semaphores: + * o disk lock + * o bdbuf lock + * o bdbuf sync lock + * o bdbuf access condition + * o bdbuf transfer condition + * o bdbuf buffer condition + */ + #define _CONFIGURE_LIBBLOCK_SEMAPHORES 6 + #endif + + #if defined(CONFIGURE_HAS_OWN_BDBUF_TABLE) || \ + defined(CONFIGURE_BDBUF_BUFFER_SIZE) || \ + defined(CONFIGURE_BDBUF_BUFFER_COUNT) + #error BDBUF Cache does not use a buffer configuration table. Please remove. + #endif +#else + /** This specifies the number of libblock tasks. */ + #define _CONFIGURE_LIBBLOCK_TASKS 0 + /** This specifies the extra stack space configured for libblock tasks. */ + #define _CONFIGURE_LIBBLOCK_TASK_EXTRA_STACKS 0 + /** This specifies the number of Classic API semaphores needed by libblock. */ + #define _CONFIGURE_LIBBLOCK_SEMAPHORES 0 +#endif /* CONFIGURE_APPLICATION_NEEDS_LIBBLOCK */ +/**@}*/ + +/** + * @defgroup ConfigurationMultiprocessing Multiprocessing Configuration + * + * @addtogroup Configuration + * + * This module contains the parameters related to the Multiprocessing + * configuration of RTEMS. + * + * In a single processor or SMP configuration, only two parameters are + * needed and they are defaulted. The user should not have to specify + * any parameters. + */ +/**@{*/ + +/** + * This defines the extra stack space required for the MPCI server thread. + */ +#ifndef CONFIGURE_EXTRA_MPCI_RECEIVE_SERVER_STACK + #define CONFIGURE_EXTRA_MPCI_RECEIVE_SERVER_STACK 0 +#endif + +/** + * This defines the timers required for the shared memory driver in + * a multiprocessing configuration. + */ +#ifndef _CONFIGURE_TIMER_FOR_SHARED_MEMORY_DRIVER + #define _CONFIGURE_TIMER_FOR_SHARED_MEMORY_DRIVER 0 +#endif + + +#if defined(RTEMS_MULTIPROCESSING) + /* + * Default Multiprocessing Configuration Table. The defaults are + * appropriate for most of the RTEMS Multiprocessor Test Suite. Each + * value may be overridden within each test to customize the environment. + */ + + #ifdef CONFIGURE_MP_APPLICATION + #define _CONFIGURE_TIMER_FOR_SHARED_MEMORY_DRIVER 1 + + #ifndef CONFIGURE_HAS_OWN_MULTIPROCESSING_TABLE + + #ifndef CONFIGURE_MP_NODE_NUMBER + #define CONFIGURE_MP_NODE_NUMBER NODE_NUMBER + #endif + + #ifndef CONFIGURE_MP_MAXIMUM_NODES + #define CONFIGURE_MP_MAXIMUM_NODES 2 + #endif + + #ifndef CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS + #define CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS 32 + #endif + #define _CONFIGURE_MEMORY_FOR_GLOBAL_OBJECTS(_global_objects) \ + _Configure_From_workspace( \ + (_global_objects) * sizeof(Objects_MP_Control) \ + ) + + #ifndef CONFIGURE_MP_MAXIMUM_PROXIES + #define CONFIGURE_MP_MAXIMUM_PROXIES 32 + #endif + #define _CONFIGURE_MEMORY_FOR_PROXIES(_proxies) \ + _Configure_From_workspace((_proxies) \ + * (sizeof(Thread_Proxy_control) \ + + THREAD_QUEUE_HEADS_SIZE(CONFIGURE_SCHEDULER_COUNT))) + + #ifndef CONFIGURE_MP_MPCI_TABLE_POINTER + #include + #define CONFIGURE_MP_MPCI_TABLE_POINTER &MPCI_table + #endif + + #ifdef CONFIGURE_INIT + rtems_multiprocessing_table Multiprocessing_configuration = { + CONFIGURE_MP_NODE_NUMBER, /* local node number */ + CONFIGURE_MP_MAXIMUM_NODES, /* maximum # nodes */ + CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS, /* maximum # global objects */ + CONFIGURE_MP_MAXIMUM_PROXIES, /* maximum # proxies */ + CONFIGURE_EXTRA_MPCI_RECEIVE_SERVER_STACK, /* MPCI stack > minimum */ + CONFIGURE_MP_MPCI_TABLE_POINTER /* ptr to MPCI config table */ + }; + #endif + + #define CONFIGURE_MULTIPROCESSING_TABLE &Multiprocessing_configuration + + #define _CONFIGURE_MPCI_RECEIVE_SERVER_COUNT 1 + + #endif /* CONFIGURE_HAS_OWN_MULTIPROCESSING_TABLE */ + + #else + + #define CONFIGURE_MULTIPROCESSING_TABLE NULL + + #define _CONFIGURE_MPCI_RECEIVE_SERVER_COUNT 0 + + #endif /* CONFIGURE_MP_APPLICATION */ +#else + #define _CONFIGURE_MPCI_RECEIVE_SERVER_COUNT 0 +#endif /* RTEMS_MULTIPROCESSING */ +/**@}*/ /* end of Multiprocessing Configuration */ + +/** + * This macro specifies that the user wants to use unlimited objects for any + * classic or posix objects that have not already been given resource limits. + */ +#if defined(CONFIGURE_UNLIMITED_OBJECTS) + #if !defined(CONFIGURE_UNIFIED_WORK_AREAS) && \ + !defined(CONFIGURE_EXECUTIVE_RAM_SIZE) && \ + !defined(CONFIGURE_MEMORY_OVERHEAD) + #error "CONFIGURE_UNLIMITED_OBJECTS requires a unified work area, an executive RAM size, or a defined workspace memory overhead" + #endif + + #if !defined(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) + /** + * This macro specifies a default allocation size for when auto-extending + * unlimited objects if none was given by the user. + */ + #define CONFIGURE_UNLIMITED_ALLOCATION_SIZE 8 + #endif + #if !defined(CONFIGURE_MAXIMUM_TASKS) + #define CONFIGURE_MAXIMUM_TASKS \ + rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) + #endif + #if !defined(CONFIGURE_MAXIMUM_TIMERS) + #define CONFIGURE_MAXIMUM_TIMERS \ + rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) + #endif + #if !defined(CONFIGURE_MAXIMUM_SEMAPHORES) + #define CONFIGURE_MAXIMUM_SEMAPHORES \ + rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) + #endif + #if !defined(CONFIGURE_MAXIMUM_MESSAGE_QUEUES) + #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES \ + rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) + #endif + #if !defined(CONFIGURE_MAXIMUM_PARTITIONS) + #define CONFIGURE_MAXIMUM_PARTITIONS \ + rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) + #endif + #if !defined(CONFIGURE_MAXIMUM_REGIONS) + #define CONFIGURE_MAXIMUM_REGIONS \ + rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) + #endif + #if !defined(CONFIGURE_MAXIMUM_PORTS) + #define CONFIGURE_MAXIMUM_PORTS \ + rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) + #endif + #if !defined(CONFIGURE_MAXIMUM_PERIODS) + #define CONFIGURE_MAXIMUM_PERIODS \ + rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) + #endif + #if !defined(CONFIGURE_MAXIMUM_BARRIERS) + #define CONFIGURE_MAXIMUM_BARRIERS \ + rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) + #endif + #if !defined(CONFIGURE_MAXIMUM_POSIX_KEYS) + #define CONFIGURE_MAXIMUM_POSIX_KEYS \ + rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) + #endif + #if !defined(CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS) + #define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS \ + rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) + #endif + + #ifdef RTEMS_POSIX_API + #if !defined(CONFIGURE_MAXIMUM_POSIX_THREADS) + #define CONFIGURE_MAXIMUM_POSIX_THREADS \ + rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) + #endif + #if !defined(CONFIGURE_MAXIMUM_POSIX_TIMERS) + #define CONFIGURE_MAXIMUM_POSIX_TIMERS \ + rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) + #endif +/* + #if !defined(CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS) + #define CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS \ + rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) + #endif +*/ + #if !defined(CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES) + #define CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES \ + rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) + #endif + #if !defined(CONFIGURE_MAXIMUM_POSIX_SEMAPHORES) + #define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES \ + rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) + #endif + #if !defined(CONFIGURE_MAXIMUM_POSIX_SHMS) + #define CONFIGURE_MAXIMUM_POSIX_SHMS \ + rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) + #endif + #endif /* RTEMS_POSIX_API */ +#endif /* CONFIGURE_UNLIMITED_OBJECTS */ + + +/** + * @defgroup ConfigurationClassicAPI Classic API Configuration + * + * @ingroup Configuration + * + * This module contains the parameters related to configuration + * of the Classic API services. + */ +/**@{*/ +#ifndef CONFIGURE_HAS_OWN_CONFIGURATION_TABLE + + /** This configures the maximum number of Classic API tasks. */ + #ifndef CONFIGURE_MAXIMUM_TASKS + #define CONFIGURE_MAXIMUM_TASKS 0 + #endif + + /* + * This is calculated to account for the maximum number of Classic API + * tasks used by the application and configured RTEMS capabilities. + */ + #define _CONFIGURE_TASKS \ + (CONFIGURE_MAXIMUM_TASKS + _CONFIGURE_LIBBLOCK_TASKS) + + #ifndef CONFIGURE_MAXIMUM_TIMERS + /** This specifies the maximum number of Classic API timers. */ + #define CONFIGURE_MAXIMUM_TIMERS 0 + /* + * This macro is calculated to specify the memory required for + * Classic API timers. + */ + #define _CONFIGURE_MEMORY_FOR_TIMERS(_timers) 0 + #else + #define _CONFIGURE_MEMORY_FOR_TIMERS(_timers) \ + _Configure_Object_RAM(_timers, sizeof(Timer_Control) ) + #endif + + #ifndef CONFIGURE_MAXIMUM_SEMAPHORES + /** This specifies the maximum number of Classic API semaphores. */ + #define CONFIGURE_MAXIMUM_SEMAPHORES 0 + #endif + + /* + * This specifies the number of Classic API semaphores required + */ + #ifdef RTEMS_NETWORKING + #define _CONFIGURE_NETWORKING_SEMAPHORES 1 + #else + #define _CONFIGURE_NETWORKING_SEMAPHORES 0 + #endif + + /* + * This macro is calculated to specify the number of Classic API + * semaphores required by the application and configured RTEMS + * capabilities. + */ + #define _CONFIGURE_SEMAPHORES \ + (CONFIGURE_MAXIMUM_SEMAPHORES + \ + _CONFIGURE_TERMIOS_SEMAPHORES + _CONFIGURE_LIBBLOCK_SEMAPHORES + \ + _CONFIGURE_SEMAPHORES_FOR_FILE_SYSTEMS + \ + _CONFIGURE_NETWORKING_SEMAPHORES) + + /* + * This macro is calculated to specify the memory required for + * Classic API Semaphores using MRSP. This is only available in + * SMP configurations. + */ + #if !defined(RTEMS_SMP) || \ + !defined(CONFIGURE_MAXIMUM_MRSP_SEMAPHORES) + #define _CONFIGURE_MEMORY_FOR_MRSP_SEMAPHORES 0 + #else + #define _CONFIGURE_MEMORY_FOR_MRSP_SEMAPHORES \ + CONFIGURE_MAXIMUM_MRSP_SEMAPHORES * \ + _Configure_From_workspace( \ + RTEMS_ARRAY_SIZE(_Scheduler_Table) * sizeof(Priority_Control) \ + ) + #endif + + /* + * This macro is calculated to specify the memory required for + * Classic API Semaphores. + * + * If there are no user or support semaphores defined, then we can assume + * that no memory need be allocated at all for semaphores. + */ + #if _CONFIGURE_SEMAPHORES == 0 + #define _CONFIGURE_MEMORY_FOR_SEMAPHORES(_semaphores) 0 + #else + #define _CONFIGURE_MEMORY_FOR_SEMAPHORES(_semaphores) \ + _Configure_Object_RAM(_semaphores, sizeof(Semaphore_Control) ) + \ + _CONFIGURE_MEMORY_FOR_MRSP_SEMAPHORES + #endif + + #ifndef CONFIGURE_MAXIMUM_MESSAGE_QUEUES + /** + * This configuration parameter specifies the maximum number of + * Classic API Message Queues. + */ + #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 0 + /* + * This macro is calculated to specify the RTEMS Workspace required for + * the Classic API Message Queues. + */ + #define _CONFIGURE_MEMORY_FOR_MESSAGE_QUEUES(_queues) 0 + #else + #define _CONFIGURE_MEMORY_FOR_MESSAGE_QUEUES(_queues) \ + _Configure_Object_RAM(_queues, sizeof(Message_queue_Control) ) + #endif + + #ifndef CONFIGURE_MAXIMUM_PARTITIONS + /** + * This configuration parameter specifies the maximum number of + * Classic API Partitions. + */ + #define CONFIGURE_MAXIMUM_PARTITIONS 0 + /* + * This macro is calculated to specify the memory required for + * Classic API + */ + #define _CONFIGURE_MEMORY_FOR_PARTITIONS(_partitions) 0 + #else + #define _CONFIGURE_MEMORY_FOR_PARTITIONS(_partitions) \ + _Configure_Object_RAM(_partitions, sizeof(Partition_Control) ) + #endif + + #ifndef CONFIGURE_MAXIMUM_REGIONS + /** + * This configuration parameter specifies the maximum number of + * Classic API Regions. + */ + #define CONFIGURE_MAXIMUM_REGIONS 0 + /* + * This macro is calculated to specify the memory required for + * Classic API Regions. + */ + #define _CONFIGURE_MEMORY_FOR_REGIONS(_regions) 0 + #else + #define _CONFIGURE_MEMORY_FOR_REGIONS(_regions) \ + _Configure_Object_RAM(_regions, sizeof(Region_Control) ) + #endif + + #ifndef CONFIGURE_MAXIMUM_PORTS + /** + * This configuration parameter specifies the maximum number of + * Classic API Dual-Ported Memory Ports. + */ + #define CONFIGURE_MAXIMUM_PORTS 0 + /** + * This macro is calculated to specify the memory required for + * Classic API Dual-Ported Memory Ports. + */ + #define _CONFIGURE_MEMORY_FOR_PORTS(_ports) 0 + #else + #define _CONFIGURE_MEMORY_FOR_PORTS(_ports) \ + _Configure_Object_RAM(_ports, sizeof(Dual_ported_memory_Control) ) + #endif + + #ifndef CONFIGURE_MAXIMUM_PERIODS + /** + * This configuration parameter specifies the maximum number of + * Classic API Rate Monotonic Periods. + */ + #define CONFIGURE_MAXIMUM_PERIODS 0 + /* + * This macro is calculated to specify the memory required for + * Classic API Rate Monotonic Periods. + */ + #define _CONFIGURE_MEMORY_FOR_PERIODS(_periods) 0 +#else + #define _CONFIGURE_MEMORY_FOR_PERIODS(_periods) \ + _Configure_Object_RAM(_periods, sizeof(Rate_monotonic_Control) ) + #endif + + /** + * This configuration parameter specifies the maximum number of + * Classic API Barriers. + */ + #ifndef CONFIGURE_MAXIMUM_BARRIERS + #define CONFIGURE_MAXIMUM_BARRIERS 0 + #endif + + /* + * This macro is calculated to specify the number of Classic API + * Barriers required by the application and configured capabilities. + */ + #define _CONFIGURE_BARRIERS \ + (CONFIGURE_MAXIMUM_BARRIERS + _CONFIGURE_BARRIERS_FOR_FIFOS) + + /* + * This macro is calculated to specify the memory required for + * Classic API Barriers. + */ + #if _CONFIGURE_BARRIERS == 0 + #define _CONFIGURE_MEMORY_FOR_BARRIERS(_barriers) 0 + #else + #define _CONFIGURE_MEMORY_FOR_BARRIERS(_barriers) \ + _Configure_Object_RAM(_barriers, sizeof(Barrier_Control) ) + #endif + + #ifndef CONFIGURE_MAXIMUM_USER_EXTENSIONS + /** + * This configuration parameter specifies the maximum number of + * Classic API User Extensions. + */ + #define CONFIGURE_MAXIMUM_USER_EXTENSIONS 0 + /* + * This macro is calculated to specify the memory required for + * Classic API User Extensions. + */ + #define _CONFIGURE_MEMORY_FOR_USER_EXTENSIONS(_extensions) 0 + #else + #define _CONFIGURE_MEMORY_FOR_USER_EXTENSIONS(_extensions) \ + _Configure_Object_RAM(_extensions, sizeof(Extension_Control) ) + #endif + /**@}*/ /* end of Classic API Configuration */ + + /** + * @defgroup ConfigurationGeneral General System Configuration + * + * @ingroup Configuration + * + * This module contains configuration parameters that are independent + * of any API but impact general system configuration. + */ + /**@{*/ + + /** The configures the number of microseconds per clock tick. */ + #ifndef CONFIGURE_MICROSECONDS_PER_TICK + #define CONFIGURE_MICROSECONDS_PER_TICK \ + RTEMS_MILLISECONDS_TO_MICROSECONDS(10) + #endif + + #if 1000000 % CONFIGURE_MICROSECONDS_PER_TICK != 0 + #warning "The clock ticks per second is not an integer" + #endif + + #if CONFIGURE_MICROSECONDS_PER_TICK <= 0 + #error "The CONFIGURE_MICROSECONDS_PER_TICK must be positive" + #endif + + #define _CONFIGURE_TICKS_PER_SECOND (1000000 / CONFIGURE_MICROSECONDS_PER_TICK) + + /** The configures the number of clock ticks per timeslice. */ + #ifndef CONFIGURE_TICKS_PER_TIMESLICE + #define CONFIGURE_TICKS_PER_TIMESLICE 50 + #endif + +/**@}*/ /* end of General Configuration */ + +/* + * Initial Extension Set + */ + +#ifdef CONFIGURE_INIT +#ifdef CONFIGURE_STACK_CHECKER_ENABLED +#include +#endif +#include + +#if defined(BSP_INITIAL_EXTENSION) || \ + defined(CONFIGURE_INITIAL_EXTENSIONS) || \ + defined(CONFIGURE_STACK_CHECKER_ENABLED) || \ + (defined(RTEMS_NEWLIB) && !defined(CONFIGURE_DISABLE_NEWLIB_REENTRANCY)) + static const rtems_extensions_table Configuration_Initial_Extensions[] = { + #if !defined(CONFIGURE_DISABLE_NEWLIB_REENTRANCY) + RTEMS_NEWLIB_EXTENSION, + #endif + #if defined(CONFIGURE_STACK_CHECKER_ENABLED) + RTEMS_STACK_CHECKER_EXTENSION, + #endif + #if defined(CONFIGURE_INITIAL_EXTENSIONS) + CONFIGURE_INITIAL_EXTENSIONS, + #endif + #if defined(BSP_INITIAL_EXTENSION) + BSP_INITIAL_EXTENSION + #endif + }; + + #define CONFIGURE_INITIAL_EXTENSION_TABLE Configuration_Initial_Extensions + #define _CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS \ + RTEMS_ARRAY_SIZE(Configuration_Initial_Extensions) + + RTEMS_SYSINIT_ITEM( + _User_extensions_Handler_initialization, + RTEMS_SYSINIT_INITIAL_EXTENSIONS, + RTEMS_SYSINIT_ORDER_MIDDLE + ); +#else + #define CONFIGURE_INITIAL_EXTENSION_TABLE NULL + #define _CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS 0 +#endif + +#if defined(RTEMS_NEWLIB) + struct _reent *__getreent(void) + { + #ifdef CONFIGURE_DISABLE_NEWLIB_REENTRANCY + return _GLOBAL_REENT; + #else + return _Thread_Get_executing()->libc_reent; + #endif + } +#endif + +#endif + +/** + * @defgroup ConfigurationPOSIXAPI POSIX API Configuration Parameters + * + * This module contains the parameters related to configuration + * of the POSIX API services. + */ +/**@{*/ + +#include + +/** + * This configuration parameter specifies the maximum number of + * POSIX API keys. + * + * POSIX Keys are available whether or not the POSIX API is enabled. + */ +#ifndef CONFIGURE_MAXIMUM_POSIX_KEYS + #define CONFIGURE_MAXIMUM_POSIX_KEYS 0 +#endif + +/* + * This macro is calculated to specify the memory required for + * POSIX API key/value pairs. + */ +#ifndef CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS + #define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS \ + (CONFIGURE_MAXIMUM_POSIX_KEYS * \ + (CONFIGURE_MAXIMUM_POSIX_THREADS + CONFIGURE_MAXIMUM_TASKS)) +#endif + +/* + * This macro is calculated to specify the total number of + * POSIX API keys required by the application and configured + * system capabilities. + */ +#define _CONFIGURE_POSIX_KEYS \ + (CONFIGURE_MAXIMUM_POSIX_KEYS + _CONFIGURE_LIBIO_POSIX_KEYS) + +/* + * This macro is calculated to specify the memory required for + * POSIX API keys. + */ +#define _CONFIGURE_MEMORY_FOR_POSIX_KEYS(_keys, _key_value_pairs) \ + (_Configure_Object_RAM(_keys, sizeof(POSIX_Keys_Control) ) \ + + _Configure_From_workspace( \ + _Configure_Max_Objects(_key_value_pairs) \ + * sizeof(POSIX_Keys_Key_value_pair))) + +/* + * The rest of the POSIX threads API features are only available when + * POSIX is enabled. + */ +#ifdef RTEMS_POSIX_API + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + + /* + * Account for the object control structures plus the name + * of the object to be duplicated. + */ + #define _Configure_POSIX_Named_Object_RAM(_number, _size) \ + (_Configure_Object_RAM(_number, _size) \ + + _Configure_Max_Objects(_number) \ + * _Configure_From_workspace(_POSIX_PATH_MAX + 1)) + + /** + * This configuration parameter specifies the maximum number of + * POSIX API threads. + */ + #ifndef CONFIGURE_MAXIMUM_POSIX_THREADS + #define CONFIGURE_MAXIMUM_POSIX_THREADS 0 + #endif + + /** + * This configuration parameter specifies the maximum number of + * POSIX API timers. + */ + #ifndef CONFIGURE_MAXIMUM_POSIX_TIMERS + #define CONFIGURE_MAXIMUM_POSIX_TIMERS 0 + #endif + + /* + * This macro is calculated to specify the memory required for + * POSIX API timers. + */ + #define _CONFIGURE_MEMORY_FOR_POSIX_TIMERS(_timers) \ + _Configure_Object_RAM(_timers, sizeof(POSIX_Timer_Control) ) + + /** + * This configuration parameter specifies the maximum number of + * POSIX API queued signals. + */ + #ifndef CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS + #define CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS 0 + #endif + + /* + * This macro is calculated to specify the memory required for + * POSIX API queued signals. + */ + #define _CONFIGURE_MEMORY_FOR_POSIX_QUEUED_SIGNALS(_queued_signals) \ + _Configure_From_workspace( \ + (_queued_signals) * (sizeof(POSIX_signals_Siginfo_node)) ) + + /** + * This configuration parameter specifies the maximum number of + * POSIX API message queues. + */ + #ifndef CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES + #define CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES 0 + #endif + + /* + * This macro is calculated to specify the memory required for + * POSIX API message queues. + */ + #define _CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUES(_message_queues) \ + _Configure_POSIX_Named_Object_RAM( \ + _message_queues, sizeof(POSIX_Message_queue_Control) ) + + /** + * This configuration parameter specifies the maximum number of + * POSIX API semaphores. + */ + #ifndef CONFIGURE_MAXIMUM_POSIX_SEMAPHORES + #define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES 0 + #endif + + /* + * This macro is calculated to specify the memory required for + * POSIX API semaphores. + */ + #define _CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES(_semaphores) \ + _Configure_POSIX_Named_Object_RAM( \ + _semaphores, sizeof(POSIX_Semaphore_Control) ) + + /** + * Configure the maximum number of POSIX shared memory objects. + */ + #if !defined(CONFIGURE_MAXIMUM_POSIX_SHMS) + #define CONFIGURE_MAXIMUM_POSIX_SHMS 0 + #else + #ifdef CONFIGURE_INIT + #if !defined(CONFIGURE_HAS_OWN_POSIX_SHM_OBJECT_OPERATIONS) + const POSIX_Shm_Object_operations _POSIX_Shm_Object_operations = { + _POSIX_Shm_Object_create_from_workspace, + _POSIX_Shm_Object_resize_from_workspace, + _POSIX_Shm_Object_delete_from_workspace, + _POSIX_Shm_Object_read_from_workspace, + _POSIX_Shm_Object_mmap_from_workspace + }; + #endif + #endif + #endif + + /* + * This macro is calculated to specify the memory required for + * POSIX API shared memory. + */ + #define _CONFIGURE_MEMORY_FOR_POSIX_SHMS(_shms) \ + _Configure_POSIX_Named_Object_RAM(_shms, sizeof(POSIX_Shm_Control) ) + + + #ifdef CONFIGURE_POSIX_INIT_THREAD_TABLE + + #ifdef CONFIGURE_POSIX_HAS_OWN_INIT_THREAD_TABLE + + /* + * The user is defining their own table information and setting the + * appropriate variables for the POSIX Initialization Thread Table. + */ + + #else + + #ifndef CONFIGURE_POSIX_INIT_THREAD_ENTRY_POINT + #define CONFIGURE_POSIX_INIT_THREAD_ENTRY_POINT POSIX_Init + #endif + + #ifndef CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE + #define CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE \ + CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE + #endif + + #ifdef CONFIGURE_INIT + posix_initialization_threads_table POSIX_Initialization_threads[] = { + { CONFIGURE_POSIX_INIT_THREAD_ENTRY_POINT, \ + CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE } + }; + #endif + + #define CONFIGURE_POSIX_INIT_THREAD_TABLE_NAME \ + POSIX_Initialization_threads + + #define CONFIGURE_POSIX_INIT_THREAD_TABLE_SIZE \ + RTEMS_ARRAY_SIZE(CONFIGURE_POSIX_INIT_THREAD_TABLE_NAME) + + #endif /* CONFIGURE_POSIX_HAS_OWN_INIT_TASK_TABLE */ + + #else /* CONFIGURE_POSIX_INIT_THREAD_TABLE */ + + #define CONFIGURE_POSIX_INIT_THREAD_TABLE_NAME NULL + #define CONFIGURE_POSIX_INIT_THREAD_TABLE_SIZE 0 + + #endif + +#else + + /** + * This configuration parameter specifies the maximum number of + * POSIX API threads. + */ + #define CONFIGURE_MAXIMUM_POSIX_THREADS 0 + +#endif /* RTEMS_POSIX_API */ + +/** + * This configuration parameter specifies the stack size of the + * POSIX API Initialization thread (if used). + */ +#ifndef CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE + #define CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE 0 +#endif +/**@}*/ /* end of POSIX API Configuration */ + +/** + * @defgroup ConfigurationGNAT GNAT/RTEMS Configuration + * + * @addtogroup Configuration + * + * This modules includes configuration parameters for applications which + * use GNAT/RTEMS. GNAT implements each Ada task as a POSIX thread. + */ +/**@{*/ +#ifdef CONFIGURE_GNAT_RTEMS + /** + * This is the maximum number of Ada tasks which can be concurrently + * in existence. Twenty (20) are required to run all tests in the + * ACATS (formerly ACVC). + */ + #ifndef CONFIGURE_MAXIMUM_ADA_TASKS + #define CONFIGURE_MAXIMUM_ADA_TASKS 20 + #endif + + /** + * This is the number of non-Ada tasks which invoked Ada code. + */ + #ifndef CONFIGURE_MAXIMUM_FAKE_ADA_TASKS + #define CONFIGURE_MAXIMUM_FAKE_ADA_TASKS 0 + #endif +#else + /** This defines he number of POSIX mutexes GNAT needs. */ + /** This defines he number of Ada tasks needed by the application. */ + #define CONFIGURE_MAXIMUM_ADA_TASKS 0 + /** + * This defines he number of non-Ada tasks/threads that will invoke + * Ada subprograms or functions. + */ + #define CONFIGURE_MAXIMUM_FAKE_ADA_TASKS 0 +#endif +/**@}*/ /* end of GNAT Configuration */ + +/** + * @defgroup ConfigurationGo GCC Go Configuration + * + * @addtogroup Configuration + * + * This modules includes configuration parameters for applications which + * use GCC Go. + */ +/**@{*/ +#ifdef CONFIGURE_ENABLE_GO + + #ifndef CONFIGURE_MAXIMUM_POSIX_THREADS + #define CONFIGURE_MAXIMUM_POSIX_THREADS 1 + #endif + + #ifndef CONFIGURE_MAXIMUM_GOROUTINES + #define CONFIGURE_MAXIMUM_GOROUTINES 400 + #endif + + #ifndef CONFIGURE_MAXIMUM_GO_CHANNELS + #define CONFIGURE_MAXIMUM_GO_CHANNELS 500 + #endif + +#else + /** This specifies the maximum number of Go co-routines. */ + #define CONFIGURE_MAXIMUM_GOROUTINES 0 + + /** This specifies the maximum number of Go channels required. */ + #define CONFIGURE_MAXIMUM_GO_CHANNELS 0 +#endif +/**@}*/ /* end of Go Configuration */ + +/** + * This is so we can account for tasks with stacks greater than minimum + * size. This is in bytes. + */ +#ifndef CONFIGURE_EXTRA_TASK_STACKS + #define CONFIGURE_EXTRA_TASK_STACKS 0 +#endif + +/** + * This macro provides a summation of the various POSIX thread requirements. + */ +#define _CONFIGURE_POSIX_THREADS \ + (CONFIGURE_MAXIMUM_POSIX_THREADS + \ + CONFIGURE_MAXIMUM_ADA_TASKS + \ + CONFIGURE_MAXIMUM_GOROUTINES) + +#ifdef RTEMS_POSIX_API + /* + * This macro is calculated to specify the memory required for + * the POSIX API in its entirety. + */ + #define _CONFIGURE_MEMORY_FOR_POSIX \ + (_CONFIGURE_MEMORY_FOR_POSIX_QUEUED_SIGNALS( \ + CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS) + \ + _CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUES( \ + CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES) + \ + _CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES( \ + CONFIGURE_MAXIMUM_POSIX_SEMAPHORES) + \ + _CONFIGURE_MEMORY_FOR_POSIX_SHMS( \ + CONFIGURE_MAXIMUM_POSIX_SHMS) + \ + _CONFIGURE_MEMORY_FOR_POSIX_TIMERS(CONFIGURE_MAXIMUM_POSIX_TIMERS)) +#else + /* + * This macro is calculated to specify the memory required for + * the POSIX API in its entirety. + */ + #define _CONFIGURE_MEMORY_FOR_POSIX 0 +#endif + +/* + * We must be able to split the free block used for the second last allocation + * into two parts so that we have a free block for the last allocation. See + * _Heap_Block_split(). + */ +#define _CONFIGURE_HEAP_HANDLER_OVERHEAD \ + _Configure_Align_up( HEAP_BLOCK_HEADER_SIZE, CPU_HEAP_ALIGNMENT ) + +/* + * Calculate the RAM size based on the maximum number of objects configured. + */ +#ifndef CONFIGURE_EXECUTIVE_RAM_SIZE + +/* + * Account for allocating the following per object + * + array of object control structures + * + local pointer table -- pointer per object plus a zero'th + * entry in the local pointer table. + */ +#define _CONFIGURE_MEMORY_FOR_TASKS(_tasks, _number_FP_tasks) \ + ( \ + _Configure_Object_RAM(_tasks, sizeof(Configuration_Thread_control)) \ + + _Configure_From_workspace(_Configure_Max_Objects(_tasks) \ + * THREAD_QUEUE_HEADS_SIZE(CONFIGURE_SCHEDULER_COUNT)) \ + + _Configure_Max_Objects(_number_FP_tasks) \ + * _Configure_From_workspace(CONTEXT_FP_SIZE) \ + ) + +/* + * This defines the amount of memory configured for the multiprocessing + * support required by this application. + */ +#ifdef CONFIGURE_MP_APPLICATION + #define _CONFIGURE_MEMORY_FOR_MP \ + (_CONFIGURE_MEMORY_FOR_PROXIES(CONFIGURE_MP_MAXIMUM_PROXIES) + \ + _CONFIGURE_MEMORY_FOR_GLOBAL_OBJECTS(CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS)) +#else + #define _CONFIGURE_MEMORY_FOR_MP 0 +#endif + +/** + * The following macro is used to calculate the memory allocated by RTEMS + * for the message buffers associated with a particular message queue. + * There is a fixed amount of overhead per message. + */ +#define CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(_messages, _size) \ + _Configure_From_workspace( \ + (_messages) * (_Configure_Align_up(_size, sizeof(uintptr_t)) \ + + sizeof(CORE_message_queue_Buffer_control))) + +/* + * This macro is set to the amount of memory required for pending message + * buffers in bytes. It should be constructed by adding together a + * set of values determined by CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE. + */ +#ifndef CONFIGURE_MESSAGE_BUFFER_MEMORY + #define CONFIGURE_MESSAGE_BUFFER_MEMORY 0 +#endif + +/** + * This macro is available just in case the confdefs.h file underallocates + * memory for a particular application. This lets the user add some extra + * memory in case something broken and underestimates. + * + * It is also possible for cases where confdefs.h overallocates memory, + * you could substract memory from the allocated. The estimate is just + * that, an estimate, and assumes worst case alignment and padding on + * each allocated element. So in some cases it could be too conservative. + * + * NOTE: Historically this was used for message buffers. + */ +#ifndef CONFIGURE_MEMORY_OVERHEAD + #define CONFIGURE_MEMORY_OVERHEAD 0 +#endif + +/** + * This calculates the amount of memory reserved for the IDLE tasks. + * In an SMP system, each CPU core has its own idle task. + */ +#define _CONFIGURE_IDLE_TASKS_COUNT CONFIGURE_MAXIMUM_PROCESSORS + +/** + * This defines the formula used to compute the amount of memory + * reserved for internal task control structures. + */ +#if CPU_IDLE_TASK_IS_FP == TRUE + #define _CONFIGURE_MEMORY_FOR_INTERNAL_TASKS \ + _CONFIGURE_MEMORY_FOR_TASKS( \ + _CONFIGURE_IDLE_TASKS_COUNT + _CONFIGURE_MPCI_RECEIVE_SERVER_COUNT, \ + _CONFIGURE_IDLE_TASKS_COUNT + _CONFIGURE_MPCI_RECEIVE_SERVER_COUNT \ + ) +#else + #define _CONFIGURE_MEMORY_FOR_INTERNAL_TASKS \ + _CONFIGURE_MEMORY_FOR_TASKS( \ + _CONFIGURE_IDLE_TASKS_COUNT + _CONFIGURE_MPCI_RECEIVE_SERVER_COUNT, \ + _CONFIGURE_MPCI_RECEIVE_SERVER_COUNT \ + ) +#endif + +/** + * This macro accounts for general RTEMS system overhead. + */ +#define _CONFIGURE_MEMORY_FOR_SYSTEM_OVERHEAD \ + ( _CONFIGURE_MEMORY_FOR_INTERNAL_TASKS + \ + _CONFIGURE_INTERRUPT_STACK_MEMORY \ + ) + +/** + * This macro reserves the memory required by the statically configured + * user extensions. + */ +#define _CONFIGURE_MEMORY_FOR_STATIC_EXTENSIONS \ + (_CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS == 0 ? 0 : \ + _Configure_From_workspace( \ + _CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS \ + * sizeof(User_extensions_Switch_control) \ + )) + +/** + * This macro provides a summation of the memory required by the + * Classic API as configured. + */ +#define _CONFIGURE_MEMORY_FOR_CLASSIC \ + (_CONFIGURE_MEMORY_FOR_TIMERS(CONFIGURE_MAXIMUM_TIMERS + \ + _CONFIGURE_TIMER_FOR_SHARED_MEMORY_DRIVER ) + \ + _CONFIGURE_MEMORY_FOR_SEMAPHORES(_CONFIGURE_SEMAPHORES) + \ + _CONFIGURE_MEMORY_FOR_MESSAGE_QUEUES(CONFIGURE_MAXIMUM_MESSAGE_QUEUES) + \ + _CONFIGURE_MEMORY_FOR_PARTITIONS(CONFIGURE_MAXIMUM_PARTITIONS) + \ + _CONFIGURE_MEMORY_FOR_REGIONS( CONFIGURE_MAXIMUM_REGIONS ) + \ + _CONFIGURE_MEMORY_FOR_PORTS(CONFIGURE_MAXIMUM_PORTS) + \ + _CONFIGURE_MEMORY_FOR_PERIODS(CONFIGURE_MAXIMUM_PERIODS) + \ + _CONFIGURE_MEMORY_FOR_BARRIERS(_CONFIGURE_BARRIERS) + \ + _CONFIGURE_MEMORY_FOR_USER_EXTENSIONS(CONFIGURE_MAXIMUM_USER_EXTENSIONS) \ + ) + +/* + * This macro provides a summation of the memory required by SMP as configured. + */ +#if defined(RTEMS_SMP) + #define _CONFIGURE_MEMORY_FOR_SMP \ + (CONFIGURE_MAXIMUM_PROCESSORS * \ + _Configure_From_workspace( CONFIGURE_INTERRUPT_STACK_SIZE ) \ + ) +#else + #define _CONFIGURE_MEMORY_FOR_SMP 0 +#endif + +/** + * This calculates the memory required for the executive workspace. + * + * This is an internal parameter. + */ +#define CONFIGURE_EXECUTIVE_RAM_SIZE \ +( \ + _CONFIGURE_MEMORY_FOR_SYSTEM_OVERHEAD + \ + _CONFIGURE_MEMORY_FOR_TASKS( \ + _CONFIGURE_TASKS, _CONFIGURE_TASKS) + \ + _CONFIGURE_MEMORY_FOR_TASKS( \ + _CONFIGURE_POSIX_THREADS, _CONFIGURE_POSIX_THREADS) + \ + _CONFIGURE_MEMORY_FOR_CLASSIC + \ + _CONFIGURE_MEMORY_FOR_POSIX_KEYS( \ + _CONFIGURE_POSIX_KEYS, \ + CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS ) + \ + _CONFIGURE_MEMORY_FOR_POSIX + \ + _CONFIGURE_MEMORY_FOR_STATIC_EXTENSIONS + \ + _CONFIGURE_MEMORY_FOR_MP + \ + _CONFIGURE_MEMORY_FOR_SMP + \ + CONFIGURE_MESSAGE_BUFFER_MEMORY + \ + (CONFIGURE_MEMORY_OVERHEAD * 1024) + \ + _CONFIGURE_HEAP_HANDLER_OVERHEAD \ +) + +/* + * Now account for any extra memory that initialization tasks or threads + * may have requested. + */ + +/* + * This accounts for any extra memory required by the Classic API + * Initialization Task. + */ +#if (CONFIGURE_INIT_TASK_STACK_SIZE > CONFIGURE_MINIMUM_TASK_STACK_SIZE) + #define _CONFIGURE_INITIALIZATION_THREADS_STACKS_CLASSIC_PART \ + (CONFIGURE_INIT_TASK_STACK_SIZE - CONFIGURE_MINIMUM_TASK_STACK_SIZE) +#else + #define _CONFIGURE_INITIALIZATION_THREADS_STACKS_CLASSIC_PART 0 +#endif + +/* + * This accounts for any extra memory required by the POSIX API + * Initialization Thread. + */ +#if defined(RTEMS_POSIX_API) && \ + (CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE > \ + CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE) + #define _CONFIGURE_INITIALIZATION_THREADS_STACKS_POSIX_PART \ + (CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE - \ + CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE) +#else + #define _CONFIGURE_INITIALIZATION_THREADS_STACKS_POSIX_PART 0 +#endif + +/* + * This macro provides a summation of the various initialization task + * and thread stack requirements. + */ +#define _CONFIGURE_INITIALIZATION_THREADS_EXTRA_STACKS \ + (_CONFIGURE_INITIALIZATION_THREADS_STACKS_CLASSIC_PART + \ + _CONFIGURE_INITIALIZATION_THREADS_STACKS_POSIX_PART) + +/* + * This macro is calculated to specify the memory required for + * the Idle tasks(s) stack. + */ +#define _CONFIGURE_IDLE_TASKS_STACK \ + (_CONFIGURE_IDLE_TASKS_COUNT * \ + _Configure_From_stackspace( CONFIGURE_IDLE_TASK_STACK_SIZE ) ) + +/* + * This macro is calculated to specify the stack memory required for the MPCI + * task. + */ +#define _CONFIGURE_MPCI_RECEIVE_SERVER_STACK \ + (_CONFIGURE_MPCI_RECEIVE_SERVER_COUNT * \ + _Configure_From_stackspace(CONFIGURE_MINIMUM_TASK_STACK_SIZE)) + +/* + * This macro is calculated to specify the memory required for + * the stacks of all tasks. + */ +#define _CONFIGURE_TASKS_STACK \ + (_Configure_Max_Objects( _CONFIGURE_TASKS ) * \ + _Configure_From_stackspace( CONFIGURE_MINIMUM_TASK_STACK_SIZE ) ) + +/* + * This macro is calculated to specify the memory required for + * the stacks of all POSIX threads. + */ +#define _CONFIGURE_POSIX_THREADS_STACK \ + (_Configure_Max_Objects( CONFIGURE_MAXIMUM_POSIX_THREADS ) * \ + _Configure_From_stackspace( CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE ) ) + +/* + * This macro is calculated to specify the memory required for + * the stacks of all Ada tasks. + */ +#define _CONFIGURE_ADA_TASKS_STACK \ + (_Configure_Max_Objects( CONFIGURE_MAXIMUM_ADA_TASKS ) * \ + _Configure_From_stackspace( CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE ) ) + +/* + * This macro is calculated to specify the memory required for + * the stacks of all Go routines. + */ +#define _CONFIGURE_GOROUTINES_STACK \ + (_Configure_Max_Objects( CONFIGURE_MAXIMUM_GOROUTINES ) * \ + _Configure_From_stackspace( CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE ) ) + +#else /* CONFIGURE_EXECUTIVE_RAM_SIZE */ + +#define _CONFIGURE_IDLE_TASKS_STACK 0 +#define _CONFIGURE_MPCI_RECEIVE_SERVER_STACK 0 +#define _CONFIGURE_INITIALIZATION_THREADS_EXTRA_STACKS 0 +#define _CONFIGURE_TASKS_STACK 0 +#define _CONFIGURE_POSIX_THREADS_STACK 0 +#define _CONFIGURE_GOROUTINES_STACK 0 +#define _CONFIGURE_ADA_TASKS_STACK 0 + +#if CONFIGURE_EXTRA_MPCI_RECEIVE_SERVER_STACK != 0 + #error "CONFIGURE_EXECUTIVE_RAM_SIZE defined with request for CONFIGURE_EXTRA_MPCI_RECEIVE_SERVER_STACK" +#endif + +#if CONFIGURE_EXTRA_TASK_STACKS != 0 + #error "CONFIGURE_EXECUTIVE_RAM_SIZE defined with request for CONFIGURE_EXTRA_TASK_STACKS" +#endif + +#endif /* CONFIGURE_EXECUTIVE_RAM_SIZE */ + +/* + * This macro is calculated to specify the memory required for + * all tasks and threads of all varieties. + */ +#define _CONFIGURE_STACK_SPACE_SIZE \ + ( \ + _CONFIGURE_IDLE_TASKS_STACK + \ + _CONFIGURE_MPCI_RECEIVE_SERVER_STACK + \ + _CONFIGURE_INITIALIZATION_THREADS_EXTRA_STACKS + \ + _CONFIGURE_TASKS_STACK + \ + _CONFIGURE_POSIX_THREADS_STACK + \ + _CONFIGURE_GOROUTINES_STACK + \ + _CONFIGURE_ADA_TASKS_STACK + \ + CONFIGURE_EXTRA_MPCI_RECEIVE_SERVER_STACK + \ + _CONFIGURE_LIBBLOCK_TASK_EXTRA_STACKS + \ + CONFIGURE_EXTRA_TASK_STACKS + \ + _CONFIGURE_HEAP_HANDLER_OVERHEAD \ + ) + +#ifndef CONFIGURE_MAXIMUM_THREAD_NAME_SIZE + #define CONFIGURE_MAXIMUM_THREAD_NAME_SIZE 16 +#endif + +#ifdef CONFIGURE_INIT + typedef union { + Scheduler_Node Base; + #ifdef CONFIGURE_SCHEDULER_CBS + Scheduler_CBS_Node CBS; + #endif + #ifdef CONFIGURE_SCHEDULER_EDF + Scheduler_EDF_Node EDF; + #endif + #ifdef CONFIGURE_SCHEDULER_EDF_SMP + Scheduler_EDF_SMP_Node EDF_SMP; + #endif + #ifdef CONFIGURE_SCHEDULER_PRIORITY + Scheduler_priority_Node Priority; + #endif + #ifdef CONFIGURE_SCHEDULER_SIMPLE_SMP + Scheduler_SMP_Node Simple_SMP; + #endif + #ifdef CONFIGURE_SCHEDULER_PRIORITY_SMP + Scheduler_priority_SMP_Node Priority_SMP; + #endif + #ifdef CONFIGURE_SCHEDULER_PRIORITY_AFFINITY_SMP + Scheduler_priority_affinity_SMP_Node Priority_affinity_SMP; + #endif + #ifdef CONFIGURE_SCHEDULER_STRONG_APA + Scheduler_strong_APA_Node Strong_APA; + #endif + #ifdef CONFIGURE_SCHEDULER_USER_PER_THREAD + CONFIGURE_SCHEDULER_USER_PER_THREAD User; + #endif + } Configuration_Scheduler_node; + + #ifdef RTEMS_SMP + const size_t _Scheduler_Node_size = sizeof( Configuration_Scheduler_node ); + #endif + + const size_t _Thread_Maximum_name_size = CONFIGURE_MAXIMUM_THREAD_NAME_SIZE; + + typedef struct { + Thread_Control Control; + #if CONFIGURE_MAXIMUM_USER_EXTENSIONS > 0 + void *extensions[ CONFIGURE_MAXIMUM_USER_EXTENSIONS + 1 ]; + #endif + Configuration_Scheduler_node Scheduler_nodes[ CONFIGURE_SCHEDULER_COUNT ]; + RTEMS_API_Control API_RTEMS; + #ifdef RTEMS_POSIX_API + POSIX_API_Control API_POSIX; + #endif + #if CONFIGURE_MAXIMUM_THREAD_NAME_SIZE > 1 + char name[ CONFIGURE_MAXIMUM_THREAD_NAME_SIZE ]; + #endif + #if !defined(RTEMS_SCHEDSIM) \ + && defined(RTEMS_NEWLIB) \ + && !defined(CONFIGURE_DISABLE_NEWLIB_REENTRANCY) + struct _reent Newlib; + #else + struct { /* Empty */ } Newlib; + #endif + } Configuration_Thread_control; + + const size_t _Thread_Control_size = sizeof( Configuration_Thread_control ); + + const Thread_Control_add_on _Thread_Control_add_ons[] = { + { + offsetof( Configuration_Thread_control, Control.Scheduler.nodes ), + offsetof( Configuration_Thread_control, Scheduler_nodes ) + }, { + offsetof( + Configuration_Thread_control, + Control.API_Extensions[ THREAD_API_RTEMS ] + ), + offsetof( Configuration_Thread_control, API_RTEMS ) + }, { + offsetof( + Configuration_Thread_control, + Control.libc_reent + ), + offsetof( Configuration_Thread_control, Newlib ) + } + #if CONFIGURE_MAXIMUM_THREAD_NAME_SIZE > 1 + , { + offsetof( + Configuration_Thread_control, + Control.Join_queue.Queue.name + ), + offsetof( Configuration_Thread_control, name ) + } + #endif + #ifdef RTEMS_POSIX_API + , { + offsetof( + Configuration_Thread_control, + Control.API_Extensions[ THREAD_API_POSIX ] + ), + offsetof( Configuration_Thread_control, API_POSIX ) + } + #endif + }; + + const size_t _Thread_Control_add_on_count = + RTEMS_ARRAY_SIZE( _Thread_Control_add_ons ); + + const uint32_t _Watchdog_Nanoseconds_per_tick = + 1000 * CONFIGURE_MICROSECONDS_PER_TICK; + + const uint32_t _Watchdog_Ticks_per_second = _CONFIGURE_TICKS_PER_SECOND; + + const uint64_t _Watchdog_Monotonic_max_seconds = + UINT64_MAX / _CONFIGURE_TICKS_PER_SECOND; + + /** + * This is the Classic API Configuration Table. + */ + rtems_api_configuration_table Configuration_RTEMS_API = { + _CONFIGURE_TASKS, + CONFIGURE_MAXIMUM_TIMERS + _CONFIGURE_TIMER_FOR_SHARED_MEMORY_DRIVER, + _CONFIGURE_SEMAPHORES, + CONFIGURE_MAXIMUM_MESSAGE_QUEUES, + CONFIGURE_MAXIMUM_PARTITIONS, + CONFIGURE_MAXIMUM_REGIONS, + CONFIGURE_MAXIMUM_PORTS, + CONFIGURE_MAXIMUM_PERIODS, + _CONFIGURE_BARRIERS, + CONFIGURE_INIT_TASK_TABLE_SIZE, + CONFIGURE_INIT_TASK_TABLE + }; + + #ifdef RTEMS_POSIX_API + /** + * This is the POSIX API Configuration Table. + */ + posix_api_configuration_table Configuration_POSIX_API = { + _CONFIGURE_POSIX_THREADS, + CONFIGURE_MAXIMUM_POSIX_TIMERS, + CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS, + CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES, + CONFIGURE_MAXIMUM_POSIX_SEMAPHORES, + CONFIGURE_MAXIMUM_POSIX_SHMS, + CONFIGURE_POSIX_INIT_THREAD_TABLE_SIZE, + CONFIGURE_POSIX_INIT_THREAD_TABLE_NAME + }; + #endif + + /** + * This variable specifies the minimum stack size for tasks in an RTEMS + * application. + * + * NOTE: This is left as a simple uint32_t so it can be externed as + * needed without requring being high enough logical to + * include the full configuration table. + */ + uint32_t rtems_minimum_stack_size = + CONFIGURE_MINIMUM_TASK_STACK_SIZE; + + /** + * This is the primary Configuration Table for this application. + */ + const rtems_configuration_table Configuration = { + CONFIGURE_EXECUTIVE_RAM_SIZE, /* required RTEMS workspace */ + _CONFIGURE_STACK_SPACE_SIZE, /* required stack space */ + CONFIGURE_MAXIMUM_USER_EXTENSIONS, /* maximum dynamic extensions */ + _CONFIGURE_POSIX_KEYS, /* POSIX keys are always */ + CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS, /* enabled */ + CONFIGURE_MICROSECONDS_PER_TICK, /* microseconds per clock tick */ + CONFIGURE_TICKS_PER_TIMESLICE, /* ticks per timeslice quantum */ + CONFIGURE_IDLE_TASK_BODY, /* user's IDLE task */ + CONFIGURE_IDLE_TASK_STACK_SIZE, /* IDLE task stack size */ + CONFIGURE_INTERRUPT_STACK_SIZE, /* interrupt stack size */ + CONFIGURE_TASK_STACK_ALLOCATOR_INIT, /* stack allocator init */ + CONFIGURE_TASK_STACK_ALLOCATOR, /* stack allocator */ + CONFIGURE_TASK_STACK_DEALLOCATOR, /* stack deallocator */ + CONFIGURE_ZERO_WORKSPACE_AUTOMATICALLY, /* true to clear memory */ + #ifdef CONFIGURE_UNIFIED_WORK_AREAS /* true for unified work areas */ + true, + #else + false, + #endif + #ifdef CONFIGURE_TASK_STACK_ALLOCATOR_AVOIDS_WORK_SPACE /* true to avoid + work space for thread stack + allocation */ + true, + #else + false, + #endif + #ifdef RTEMS_SMP + #ifdef _CONFIGURE_SMP_APPLICATION + true, + #else + false, + #endif + #endif + _CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS, /* number of static extensions */ + CONFIGURE_INITIAL_EXTENSION_TABLE, /* pointer to static extensions */ + #if defined(RTEMS_MULTIPROCESSING) + CONFIGURE_MULTIPROCESSING_TABLE, /* pointer to MP config table */ + #endif + #ifdef RTEMS_SMP + CONFIGURE_MAXIMUM_PROCESSORS, + #endif + }; +#endif + +#endif /* CONFIGURE_HAS_OWN_CONFIGURATION_TABLE */ + +#if defined(RTEMS_SMP) + /* + * Instantiate the Per CPU information based upon the user configuration. + */ + #if defined(CONFIGURE_INIT) + Per_CPU_Control_envelope _Per_CPU_Information[CONFIGURE_MAXIMUM_PROCESSORS]; + #endif + +#endif + +/* + * If the user has configured a set of Classic API Initialization Tasks, + * then we need to install the code that runs that loop. + */ +#ifdef CONFIGURE_INIT + #if defined(CONFIGURE_RTEMS_INIT_TASKS_TABLE) || \ + defined(CONFIGURE_HAS_OWN_INIT_TASK_TABLE) + RTEMS_SYSINIT_ITEM( + _RTEMS_tasks_Initialize_user_tasks_body, + RTEMS_SYSINIT_CLASSIC_USER_TASKS, + RTEMS_SYSINIT_ORDER_MIDDLE + ); + #endif +#endif + +/* + * If the user has configured a set of POSIX Initialization Threads, + * then we need to install the code that runs that loop. + */ +#ifdef RTEMS_POSIX_API + #ifdef CONFIGURE_INIT + #if defined(CONFIGURE_POSIX_INIT_THREAD_TABLE) || \ + defined(CONFIGURE_POSIX_HAS_OWN_INIT_THREAD_TABLE) + RTEMS_SYSINIT_ITEM( + _POSIX_Threads_Initialize_user_threads_body, + RTEMS_SYSINIT_POSIX_USER_THREADS, + RTEMS_SYSINIT_ORDER_MIDDLE + ); + #endif + #endif +#endif + +/* + * Select PCI Configuration Library + */ +#ifdef RTEMS_PCI_CONFIG_LIB + #ifdef CONFIGURE_INIT + #define PCI_LIB_NONE 0 + #define PCI_LIB_AUTO 1 + #define PCI_LIB_STATIC 2 + #define PCI_LIB_READ 3 + #define PCI_LIB_PERIPHERAL 4 + #if CONFIGURE_PCI_LIB == PCI_LIB_AUTO + #define PCI_CFG_AUTO_LIB + #include + struct pci_bus pci_hb; + #define PCI_LIB_INIT pci_config_auto + #define PCI_LIB_CONFIG pci_config_auto_register + #elif CONFIGURE_PCI_LIB == PCI_LIB_STATIC + #define PCI_CFG_STATIC_LIB + #include + #define PCI_LIB_INIT pci_config_static + #define PCI_LIB_CONFIG NULL + /* Let user define PCI configuration (struct pci_bus pci_hb) */ + #elif CONFIGURE_PCI_LIB == PCI_LIB_READ + #define PCI_CFG_READ_LIB + #include + #define PCI_LIB_INIT pci_config_read + #define PCI_LIB_CONFIG NULL + struct pci_bus pci_hb; + #elif CONFIGURE_PCI_LIB == PCI_LIB_PERIPHERAL + #define PCI_LIB_INIT pci_config_peripheral + #define PCI_LIB_CONFIG NULL + /* Let user define PCI configuration (struct pci_bus pci_hb) */ + #elif CONFIGURE_PCI_LIB == PCI_LIB_NONE + #define PCI_LIB_INIT NULL + #define PCI_LIB_CONFIG NULL + /* No PCI Configuration at all, user can use/debug access routines */ + #else + #error NO PCI LIBRARY DEFINED + #endif + + const int pci_config_lib_type = CONFIGURE_PCI_LIB; + int (*pci_config_lib_init)(void) = PCI_LIB_INIT; + void (*pci_config_lib_register)(void *config) = PCI_LIB_CONFIG; + #endif +#endif + +#ifdef __cplusplus +} +#endif + +/****************************************************************** + ****************************************************************** + ****************************************************************** + * CONFIGURATION WARNINGS AND ERROR CHECKING * + ****************************************************************** + ****************************************************************** + ****************************************************************** + */ + +#if defined(CONFIGURE_CONFDEFS_DEBUG) && defined(CONFIGURE_INIT) + /** + * This is a debug mechanism, so if you need to, the executable will + * have a structure with various partial values. Add to this as you + * need to. Viewing this structure in gdb combined with dumping + * the Configuration structures generated should help a lot in tracing + * down errors and analyzing where over and under allocations are. + */ + typedef struct { + uint32_t SYSTEM_OVERHEAD; + uint32_t STATIC_EXTENSIONS; + uint32_t INITIALIZATION_THREADS_STACKS; + + uint32_t PER_INTEGER_TASK; + uint32_t FP_OVERHEAD; + uint32_t CLASSIC; + uint32_t POSIX; + + /* System overhead pieces */ + uint32_t INTERRUPT_STACK_MEMORY; + uint32_t MEMORY_FOR_IDLE_TASK; + + /* Classic API Pieces */ + uint32_t CLASSIC_TASKS; + uint32_t TIMERS; + uint32_t SEMAPHORES; + uint32_t MESSAGE_QUEUES; + uint32_t PARTITIONS; + uint32_t REGIONS; + uint32_t PORTS; + uint32_t PERIODS; + uint32_t BARRIERS; + uint32_t USER_EXTENSIONS; + + /* POSIX API managers that are always enabled */ + uint32_t POSIX_KEYS; + +#ifdef RTEMS_POSIX_API + /* POSIX API Pieces */ + uint32_t POSIX_TIMERS; + uint32_t POSIX_QUEUED_SIGNALS; + uint32_t POSIX_MESSAGE_QUEUES; + uint32_t POSIX_SEMAPHORES; + uint32_t POSIX_SHMS; +#endif + + /* Stack space sizes */ + uint32_t IDLE_TASKS_STACK; + uint32_t INITIALIZATION_THREADS_EXTRA_STACKS; + uint32_t TASKS_STACK; + uint32_t POSIX_THREADS_STACK; + uint32_t GOROUTINES_STACK; + uint32_t ADA_TASKS_STACK; + uint32_t EXTRA_MPCI_RECEIVE_SERVER_STACK; + uint32_t EXTRA_TASK_STACKS; + } Configuration_Debug_t; + + Configuration_Debug_t Configuration_Memory_Debug = { + /* General Information */ + _CONFIGURE_MEMORY_FOR_SYSTEM_OVERHEAD, + _CONFIGURE_MEMORY_FOR_STATIC_EXTENSIONS, + _CONFIGURE_INITIALIZATION_THREADS_EXTRA_STACKS, + _CONFIGURE_MEMORY_FOR_TASKS(1, 0), + _CONFIGURE_MEMORY_FOR_TASKS(0, 1), + _CONFIGURE_MEMORY_FOR_CLASSIC, + _CONFIGURE_MEMORY_FOR_POSIX, + + /* System overhead pieces */ + _CONFIGURE_INTERRUPT_STACK_MEMORY, + _CONFIGURE_MEMORY_FOR_INTERNAL_TASKS, + + /* Classic API Pieces */ + _CONFIGURE_MEMORY_FOR_TASKS(CONFIGURE_MAXIMUM_TASKS, 0), + _CONFIGURE_MEMORY_FOR_TIMERS(CONFIGURE_MAXIMUM_TIMERS), + _CONFIGURE_MEMORY_FOR_SEMAPHORES(_CONFIGURE_SEMAPHORES), + _CONFIGURE_MEMORY_FOR_MESSAGE_QUEUES(CONFIGURE_MAXIMUM_MESSAGE_QUEUES), + _CONFIGURE_MEMORY_FOR_PARTITIONS(CONFIGURE_MAXIMUM_PARTITIONS), + _CONFIGURE_MEMORY_FOR_REGIONS( CONFIGURE_MAXIMUM_REGIONS ), + _CONFIGURE_MEMORY_FOR_PORTS(CONFIGURE_MAXIMUM_PORTS), + _CONFIGURE_MEMORY_FOR_PERIODS(CONFIGURE_MAXIMUM_PERIODS), + _CONFIGURE_MEMORY_FOR_BARRIERS(_CONFIGURE_BARRIERS), + _CONFIGURE_MEMORY_FOR_USER_EXTENSIONS(CONFIGURE_MAXIMUM_USER_EXTENSIONS), + _CONFIGURE_MEMORY_FOR_POSIX_KEYS( _CONFIGURE_POSIX_KEYS, \ + CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS ), + +#ifdef RTEMS_POSIX_API + /* POSIX API Pieces */ + _CONFIGURE_MEMORY_FOR_POSIX_QUEUED_SIGNALS( + CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS ), + _CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUES( + CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES ), + _CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES( CONFIGURE_MAXIMUM_POSIX_SEMAPHORES ), + _CONFIGURE_MEMORY_FOR_POSIX_SHMS( CONFIGURE_MAXIMUM_POSIX_SHMS ), + _CONFIGURE_MEMORY_FOR_POSIX_TIMERS( CONFIGURE_MAXIMUM_POSIX_TIMERS ), +#endif + + /* Stack space sizes */ + _CONFIGURE_IDLE_TASKS_STACK, + _CONFIGURE_INITIALIZATION_THREADS_EXTRA_STACKS, + _CONFIGURE_TASKS_STACK, + _CONFIGURE_POSIX_THREADS_STACK, + _CONFIGURE_GOROUTINES_STACK, + _CONFIGURE_ADA_TASKS_STACK, + CONFIGURE_EXTRA_MPCI_RECEIVE_SERVER_STACK, + CONFIGURE_EXTRA_TASK_STACKS + }; +#endif + +/* + * Make sure a task/thread of some sort is configured. + * + * When analyzing RTEMS to find the smallest possible of memory + * that must be allocated, you probably do want to configure 0 + * tasks/threads so there is a smaller set of calls to _Workspace_Allocate + * to analyze. + */ +#if !defined(CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION) + #if (CONFIGURE_MAXIMUM_TASKS == 0) && \ + (CONFIGURE_MAXIMUM_POSIX_THREADS == 0) && \ + (CONFIGURE_MAXIMUM_ADA_TASKS == 0) && \ + (CONFIGURE_MAXIMUM_GOROUTINES == 0) + #error "CONFIGURATION ERROR: No tasks or threads configured!!" + #endif +#endif + +#ifndef RTEMS_SCHEDSIM +/* + * Make sure at least one of the initialization task/thread + * tables was defined. + */ +#if !defined(CONFIGURE_RTEMS_INIT_TASKS_TABLE) && \ + !defined(CONFIGURE_POSIX_INIT_THREAD_TABLE) && \ + !defined(CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION) +#error "CONFIGURATION ERROR: No initialization tasks or threads configured!!" +#endif +#endif + +/* + * If the user is trying to configure a multiprocessing application and + * RTEMS was not configured and built multiprocessing, then error out. + */ +#if defined(CONFIGURE_MP_APPLICATION) && \ + !defined(RTEMS_MULTIPROCESSING) +#error "CONFIGURATION ERROR: RTEMS not configured for multiprocessing!!" +#endif + +/* + * If an attempt was made to configure POSIX objects and + * the POSIX API was not configured into RTEMS, error out. + * + * @note POSIX Keys are always available so the parameters + * CONFIGURE_MAXIMUM_POSIX_KEYS and + * CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS are not in this list. + */ +#if !defined(RTEMS_POSIX_API) + #if ((CONFIGURE_MAXIMUM_POSIX_THREADS != 0) || \ + (CONFIGURE_MAXIMUM_POSIX_TIMERS != 0) || \ + (CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS != 0) || \ + (CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES != 0) || \ + (CONFIGURE_MAXIMUM_POSIX_SEMAPHORES != 0) || \ + (CONFIGURE_MAXIMUM_POSIX_SHMS != 0) || \ + defined(CONFIGURE_POSIX_INIT_THREAD_TABLE)) + #error "CONFIGURATION ERROR: POSIX API support not configured!!" + #endif +#endif + +#if !defined(RTEMS_SCHEDSIM) + #if !defined(CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE) + /* + * You must either explicity include or exclude the clock driver. + * It is such a common newbie error to leave it out. Maybe this + * will put an end to it. + * + * NOTE: If you are using the timer driver, it is considered + * mutually exclusive with the clock driver because the + * drivers are assumed to use the same "timer" hardware + * on many boards. + */ + #if !defined(CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER) && \ + !defined(CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER) && \ + !defined(CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER) + #error "CONFIGURATION ERROR: Do you want the clock driver or not?!?" + #endif + + /* + * Only one of the following three configuration parameters should be + * defined at a time. + */ + #if ((defined(CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER) + \ + defined(CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER) + \ + defined(CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER)) > 1) + #error "CONFIGURATION ERROR: More than one clock/timer driver configuration parameter specified?!?" + #endif + #endif /* !defined(CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE) */ +#endif /* !defined(RTEMS_SCHEDSIM) */ + +/* + * These names have been obsoleted so make the user application stop compiling + */ +#if defined(CONFIGURE_TEST_NEEDS_TIMER_DRIVER) || \ + defined(CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER) || \ + defined(CONFIGURE_TEST_NEEDS_CLOCK_DRIVER) || \ + defined(CONFIGURE_TEST_NEEDS_RTC_DRIVER) || \ + defined(CONFIGURE_TEST_NEEDS_STUB_DRIVER) +#error "CONFIGURATION ERROR: CONFIGURE_TEST_XXX constants are obsolete" +#endif + +/* + * Validate the configured maximum priority + */ +#if ((CONFIGURE_MAXIMUM_PRIORITY != 3) && \ + (CONFIGURE_MAXIMUM_PRIORITY != 7) && \ + (CONFIGURE_MAXIMUM_PRIORITY != 15) && \ + (CONFIGURE_MAXIMUM_PRIORITY != 31) && \ + (CONFIGURE_MAXIMUM_PRIORITY != 63) && \ + (CONFIGURE_MAXIMUM_PRIORITY != 127) && \ + (CONFIGURE_MAXIMUM_PRIORITY != 255)) + #error "Maximum priority is not 1 less than a power of 2 between 4 and 256" +#endif + +#if (CONFIGURE_MAXIMUM_PRIORITY > PRIORITY_DEFAULT_MAXIMUM) + #error "Maximum priority configured higher than supported by target." +#endif + +#ifdef CONFIGURE_MAXIMUM_POSIX_BARRIERS + #warning "The CONFIGURE_MAXIMUM_POSIX_BARRIERS configuration option is obsolete since RTEMS 5.1" +#endif + +#ifdef CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES + #warning "The CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES configuration option is obsolete since RTEMS 5.1" +#endif + +#ifdef CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUE_DESCRIPTORS + #warning "The CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUE_DESCRIPTORS configuration option is obsolete since RTEMS 5.1" +#endif + +#ifdef CONFIGURE_MAXIMUM_POSIX_MUTEXES + #warning "The CONFIGURE_MAXIMUM_POSIX_MUTEXES configuration option is obsolete since RTEMS 5.1" +#endif + +#ifdef CONFIGURE_MAXIMUM_POSIX_RWLOCKS + #warning "The CONFIGURE_MAXIMUM_POSIX_RWLOCKS configuration option is obsolete since RTEMS 5.1" +#endif + +#ifdef CONFIGURE_MAXIMUM_POSIX_SPINLOCKS + #warning "The CONFIGURE_MAXIMUM_POSIX_SPINLOCKS configuration option is obsolete since RTEMS 5.1" +#endif + +/* + * POSIX Key pair shouldn't be less than POSIX Key, which is highly + * likely to be error. + */ +#if (CONFIGURE_MAXIMUM_POSIX_KEYS != 0) && \ + (CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS != 0) + #if (CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS < CONFIGURE_MAXIMUM_POSIX_KEYS) + #error "Fewer POSIX Key pairs than POSIX Key!" + #endif +#endif + +/* + * IMFS block size for in memory files (memfiles) must be a power of + * two between 16 and 512 inclusive. + */ +#if ((CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 16) && \ + (CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 32) && \ + (CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 64) && \ + (CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 128) && \ + (CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 256) && \ + (CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 512)) + #error "IMFS Memfile block size must be a power of 2 between 16 and 512" +#endif + + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/config.h b/cpukit/include/rtems/config.h new file mode 100644 index 0000000000..6b97376511 --- /dev/null +++ b/cpukit/include/rtems/config.h @@ -0,0 +1,397 @@ +/** + * @file + * + * @brief Table of User Defined Configuration Parameters + * + * This include file contains the table of user defined configuration + * parameters. + */ + +/* + * COPYRIGHT (c) 1989-2014. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_CONFIG_H +#define _RTEMS_CONFIG_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Unlimited object support. Changes the configuration table entry for POSIX + * or RTEMS APIs to bounded only by the memory of the work-space. + * + * Use the macro to define the resource unlimited before placing in + * the configuration table. + */ + +#include +#define RTEMS_UNLIMITED_OBJECTS OBJECTS_UNLIMITED_OBJECTS + +#define rtems_resource_unlimited(resource) \ + ( resource | RTEMS_UNLIMITED_OBJECTS ) + +#define rtems_resource_is_unlimited(resource) \ + _Objects_Is_unlimited(resource) + +#define rtems_resource_maximum_per_allocation(resource) \ + _Objects_Maximum_per_allocation(resource) + +#include + +/* + * This is kind of kludgy but it allows targets to totally ignore the + * optional APIs like POSIX safely. + */ + +#ifdef RTEMS_POSIX_API +#include +#else +typedef void *posix_api_configuration_table; +#endif + +#include + +#include +#if defined(RTEMS_MULTIPROCESSING) +#include +#endif + +#if defined(RTEMS_MULTIPROCESSING) +/* + * The following records define the Multiprocessor Configuration + * Table. This table defines the multiprocessor system + * characteristics which must be known by RTEMS in a multiprocessor + * system. + */ +typedef struct { + /** This is the local node number. */ + uint32_t node; + /** This is the maximum number of nodes in system. */ + uint32_t maximum_nodes; + /** This is the maximum number of global objects. */ + uint32_t maximum_global_objects; + /** This is the maximum number of proxies. */ + uint32_t maximum_proxies; + + /** + * The MPCI Receive server is assumed to have a stack of at least + * minimum stack size. This field specifies the amount of extra + * stack this task will be given in bytes. + */ + uint32_t extra_mpci_receive_server_stack; + + /** This is a pointer to User/BSP provided MPCI Table. */ + rtems_mpci_table *User_mpci_table; +} rtems_multiprocessing_table; +#endif + +/** + * @brief Task stack allocator initialization hook. + * + * @param[in] stack_space_size is the size of the stack space in bytes. + */ +typedef void (*rtems_stack_allocate_init_hook)( size_t stack_space_size ); + +/** + * @brief Task stack allocator hook. + * + * @param[in] stack_size is the Size of the task stack in bytes. + * + * @retval NULL Not enough memory. + * @retval other Pointer to task stack. + */ +typedef void *(*rtems_stack_allocate_hook)( size_t stack_size ); + +/** + * @brief Task stack deallocator hook. + * + * @param[in] addr is a pointer to previously allocated task stack. + */ +typedef void (*rtems_stack_free_hook)( void *addr ); + +/* + * The following records define the Configuration Table. The + * information contained in this table is required in all + * RTEMS systems, whether single or multiprocessor. This + * table primarily defines the following: + * + * + location and size of the RTEMS Workspace + * + microseconds per clock tick + * + clock ticks per task timeslice + * + required number of each object type for each API configured + */ +typedef struct { + /** + * This field specifies the size in bytes of the RTEMS Workspace. + */ + uintptr_t work_space_size; + + /** + * This field specifies the size in bytes of the RTEMS thread stack space. + */ + uintptr_t stack_space_size; + + /** + * This field specifies the maximum number of dynamically installed + * used extensions. + */ + uint32_t maximum_extensions; + + /** + * This field contains the maximum number of POSIX API + * keys which are configured for this application. + */ + uint32_t maximum_keys; + + /** + * This field contains the maximum number of POSIX API + * key value pairs which are configured for this application. + * + * @note There can be potentially be a key/value pair for + * every thread to use every key. But normally this + * many are not needed in a system. + */ + uint32_t maximum_key_value_pairs; + + /** + * This field specifies the number of microseconds which elapse + * between clock ticks. This is the basis for RTEMS timing. + */ + uint32_t microseconds_per_tick; + + /** + * This field specifies the number of ticks in each task's timeslice. + */ + uint32_t ticks_per_timeslice; + + /** + * This element points to the BSP's optional idle task which may override + * the default one provided with RTEMS. + */ + void *(*idle_task)( uintptr_t ); + + /** + * This field specifies the size of the IDLE task's stack. If less than or + * equal to the minimum stack size, then the IDLE task will have the minimum + * stack size. + */ + uint32_t idle_task_stack_size; + + /** + * This field specifies the size of the interrupt stack. If less than or + * equal to the minimum stack size, then the interrupt stack will be of + * minimum stack size. + */ + uint32_t interrupt_stack_size; + + /** + * @brief Optional task stack allocator initialization hook. + */ + rtems_stack_allocate_init_hook stack_allocate_init_hook; + + /** + * @brief Optional task stack allocator hook. + */ + rtems_stack_allocate_hook stack_allocate_hook; + + /** + * @brief Optional task stack free hook. + */ + rtems_stack_free_hook stack_free_hook; + + /** + * If this element is TRUE, then RTEMS will zero the Executive Workspace. + * When this element is FALSE, it is assumed that the BSP or invoking + * environment has ensured that memory was cleared before RTEMS was + * invoked. + */ + bool do_zero_of_workspace; + + /** + * @brief Specifies if a unified work area is used or not. + * + * If this element is @a true, then the RTEMS Workspace and the C Program + * Heap use the same heap, otherwise they use separate heaps. + */ + bool unified_work_area; + + /** + * @brief Specifies if the stack allocator avoids the work space. + * + * If this element is @a true, then the stack allocator must not allocate the + * thread stacks from the RTEMS Workspace, otherwise it should allocate the + * thread stacks from the RTEMS Workspace. + */ + bool stack_allocator_avoids_work_space; + + #ifdef RTEMS_SMP + bool smp_enabled; + #endif + + uint32_t number_of_initial_extensions; + const rtems_extensions_table *User_extension_table; + #if defined(RTEMS_MULTIPROCESSING) + rtems_multiprocessing_table *User_multiprocessing_table; + #endif + #ifdef RTEMS_SMP + uint32_t maximum_processors; + #endif +} rtems_configuration_table; + +/** + * This is the configuration table generated by confdefs.h. + */ +extern const rtems_configuration_table Configuration; + +#if defined(RTEMS_MULTIPROCESSING) + /** + * This points to the multiprocessing configuration table. + */ + extern rtems_multiprocessing_table *_Configuration_MP_table; +#endif + +#if defined(RTEMS_MULTIPROCESSING) + /** + * @brief RTEMS multiprocessing configuration table. + * + * This is the RTEMS Multiprocessing Configuration Table expected to + * be generated by confdefs.h. + */ + extern rtems_multiprocessing_table Multiprocessing_configuration; + + /* + * This is the default Multiprocessing Configuration Table. + * It is used in single processor configurations. + */ + extern const rtems_multiprocessing_table + _Initialization_Default_multiprocessing_table; +#endif + + +/* + * Some handy macros to avoid dependencies on either the BSP + * or the exact format of the configuration table. + */ + +#define rtems_configuration_get_unified_work_area() \ + (Configuration.unified_work_area) + +#define rtems_configuration_get_stack_allocator_avoids_work_space() \ + (Configuration.stack_allocator_avoids_work_space) + +#define rtems_configuration_get_stack_space_size() \ + (Configuration.stack_space_size) + +#define rtems_configuration_get_work_space_size() \ + (Configuration.work_space_size + \ + (rtems_configuration_get_stack_allocator_avoids_work_space() ? \ + 0 : rtems_configuration_get_stack_space_size())) + +#define rtems_configuration_get_maximum_extensions() \ + (Configuration.maximum_extensions) + +#define rtems_configuration_get_microseconds_per_tick() \ + (Configuration.microseconds_per_tick) +#define rtems_configuration_get_milliseconds_per_tick() \ + (Configuration.microseconds_per_tick / 1000) +#define rtems_configuration_get_nanoseconds_per_tick() \ + (_Watchdog_Nanoseconds_per_tick) + +#define rtems_configuration_get_ticks_per_timeslice() \ + (Configuration.ticks_per_timeslice) + +#define rtems_configuration_get_idle_task() \ + (Configuration.idle_task) + +#define rtems_configuration_get_idle_task_stack_size() \ + (Configuration.idle_task_stack_size) + +#define rtems_configuration_get_interrupt_stack_size() \ + (Configuration.interrupt_stack_size) + +#define rtems_configuration_get_stack_allocate_init_hook() \ + (Configuration.stack_allocate_init_hook) + +#define rtems_configuration_get_stack_allocate_hook() \ + (Configuration.stack_allocate_hook) + +#define rtems_configuration_get_stack_free_hook() \ + (Configuration.stack_free_hook) + + /** + * This macro assists in accessing the field which indicates whether + * RTEMS is responsible for zeroing the Executive Workspace. + */ +#define rtems_configuration_get_do_zero_of_workspace() \ + (Configuration.do_zero_of_workspace) + +#define rtems_configuration_get_number_of_initial_extensions() \ + (Configuration.number_of_initial_extensions) + +#define rtems_configuration_get_user_extension_table() \ + (Configuration.User_extension_table) + +#if defined(RTEMS_MULTIPROCESSING) + #define rtems_configuration_get_user_multiprocessing_table() \ + (Configuration.User_multiprocessing_table) +#else + #define rtems_configuration_get_user_multiprocessing_table() \ + NULL +#endif + +/** + * @brief Returns true if the SMP mode of operation is enabled, and false + * otherwise. + * + * In uni-processor configurations this is a compile-time constant which + * evaluates to false. + * + * @retval true SMP mode of operation is enabled. + * @retval false Otherwise. + */ +#ifdef RTEMS_SMP + #define rtems_configuration_is_smp_enabled() \ + (Configuration.smp_enabled) +#else + #define rtems_configuration_is_smp_enabled() \ + false +#endif + +/** + * @brief Returns the configured maximum count of processors. + * + * The actual number of processors available for the application will be less + * than or equal to the configured maximum count of processors. + * + * On single-processor configurations this is a compile time constant which + * evaluates to one. + * + * @return The configured maximum count of processors. + */ +#ifdef RTEMS_SMP + #define rtems_configuration_get_maximum_processors() \ + (Configuration.maximum_processors) +#else + #define rtems_configuration_get_maximum_processors() \ + 1 +#endif + +#define rtems_configuration_get_rtems_api_configuration() \ + (&Configuration_RTEMS_API) + +#define rtems_configuration_get_posix_api_configuration() \ + (&Configuration_POSIX_API) + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/counter.h b/cpukit/include/rtems/counter.h new file mode 100644 index 0000000000..3b428402a8 --- /dev/null +++ b/cpukit/include/rtems/counter.h @@ -0,0 +1,160 @@ +/** + * @file + * + * @ingroup ClassicCounter + * + * @brief Free-Running Counter and Busy Wait Delay API + */ + +/* + * Copyright (c) 2014 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SAPI_COUNTER_H +#define _RTEMS_SAPI_COUNTER_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup ClassicCounter Free-Running Counter and Busy Wait Delay + * + * @ingroup ClassicRTEMS + * + * @brief Free-running counter and busy wait delay functions. + * + * The RTEMS counter is some free-running counter. It ticks usually with a + * frequency close to the CPU or system bus clock. + * + * The counter can be used in case the overhead of the + * rtems_clock_get_uptime_nanoseconds() is too high. The step from counter + * ticks to/from nanoseconds is explicit in this API unlike to + * rtems_clock_get_uptime_nanoseconds() which performs the conversion on each + * invocation. + * + * This counter works without a clock driver and during system initialization. + * + * The counter can be used to profile low-level operations like SMP locks or + * interrupt disabled critical sections. The counter can act also as an + * entropy source for a random number generator. + * + * The period of the counter depends on the actual hardware. + * + * @{ + */ + +/** + * @brief Unsigned integer type for counter values. + */ +typedef CPU_Counter_ticks rtems_counter_ticks; + +/** + * @brief Reads the current counter values. + * + * @return The current counter values. + */ +static inline rtems_counter_ticks rtems_counter_read( void ) +{ + return _CPU_Counter_read(); +} + +/** + * @brief Returns the difference between the second and first CPU counter + * value. + * + * This operation may be carried out as a modulo operation depending on the + * range of the CPU counter device. + * + * @param[in] second The second CPU counter value. + * @param[in] first The first CPU counter value. + * + * @return Returns second minus first modulo counter period. + */ +static inline rtems_counter_ticks rtems_counter_difference( + rtems_counter_ticks second, + rtems_counter_ticks first +) +{ + return _CPU_Counter_difference( second, first ); +} + +/** + * @brief Converts counter ticks into nanoseconds. + * + * @param[in] ticks Some counter ticks. + * + * @return The nanoseconds corresponding to the counter ticks. The value is + * rounded up. + */ +uint64_t rtems_counter_ticks_to_nanoseconds( + rtems_counter_ticks ticks +); + +/** + * @brief Converts nanoseconds into counter ticks. + * + * @param[in] nanoseconds Some nanoseconds. + * + * @return The counter ticks corresponding to the nanoseconds. The value is + * rounded up. + */ +rtems_counter_ticks rtems_counter_nanoseconds_to_ticks( + uint32_t nanoseconds +); + +/** + * @brief Initializes the counter ticks to/from nanoseconds converter functions. + * + * This function must be used to initialize the + * rtems_counter_ticks_to_nanoseconds() and + * rtems_counter_nanoseconds_to_ticks() functions. It should be called during + * system initialization by the board support package. + * + * @param[in] frequency The current counter frequency in Hz. + */ +void rtems_counter_initialize_converter( uint32_t frequency ); + +/** + * @brief Busy wait for some counter ticks. + * + * This function does not disable interrupts. Thus task switches and + * interrupts can interfere with this busy wait may prolong the delay. This + * function busy waits at least the specified time. Due to some overhead the + * actual delay may be longer. + * + * @param[in] ticks The minimum busy wait time in counter ticks. + */ +void rtems_counter_delay_ticks( rtems_counter_ticks ticks ); + +/** + * @brief Busy wait for some nanoseconds. + * + * This function does not disable interrupts. Thus task switches and + * interrupts can interfere with this busy wait may prolong the delay. This + * function busy waits at least the specified time. Due to some overhead the + * actual delay may be longer. + * + * @param[in] nanoseconds The minimum busy wait time in nanoseconds. + */ +void rtems_counter_delay_nanoseconds( uint32_t nanoseconds ); + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_SAPI_COUNTER_H */ diff --git a/cpukit/include/rtems/cpuuse.h b/cpukit/include/rtems/cpuuse.h new file mode 100644 index 0000000000..23f58faf1b --- /dev/null +++ b/cpukit/include/rtems/cpuuse.h @@ -0,0 +1,88 @@ +/** + * @file rtems/cpuuse.h + * + * @defgroup libmisc_cpuuse CPU Usage + * + * @ingroup libmisc + * @brief CPU Usage Report + * + * This include file contains information necessary to utilize + * and install the cpu usage reporting mechanism. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef __RTEMS_CPUUSE_h +#define __RTEMS_CPUUSE_h + +#include +#include + +/** + * @defgroup libmisc_cpuuse CPU Usage + * + * @ingroup libmisc + */ +/**@{*/ +#ifdef __cplusplus +extern "C" { +#endif + +/* + * rtems_cpu_usage_report_with_handler + */ + +void rtems_cpu_usage_report_with_plugin( const rtems_printer *printer ); + +/** + * @brief Report CPU usage. + * + * CPU Usage Reporter + */ + +void rtems_cpu_usage_report( void ); + +/** + * @brief CPU usage Top plugin + * + * Report CPU Usage in top format to + * to a print plugin. + */ +void rtems_cpu_usage_top_with_plugin( const rtems_printer *printer ); + +/** + * @brief CPU usage top. + * + * CPU Usage top + */ + +void rtems_cpu_usage_top( void ); + +/** + * @brief Reset CPU usage. + * + * CPU Usage Reporter + */ + +void rtems_cpu_usage_reset( void ); + +/** + * @brief Reports per-processor information. + * + * @return The number of characters printed. + */ +int rtems_cpu_info_report( const rtems_printer *printer ); + +#ifdef __cplusplus +} +#endif +/**@}*/ +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/debugger/rtems-debugger-remote.h b/cpukit/include/rtems/debugger/rtems-debugger-remote.h new file mode 100644 index 0000000000..34ad9ee6d2 --- /dev/null +++ b/cpukit/include/rtems/debugger/rtems-debugger-remote.h @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2016 Chris Johns . + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Debugger for RTEMS. + */ + +#ifndef _RTEMS_DEBUGGER_REMOTE_h +#define _RTEMS_DEBUGGER_REMOTE_h + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * Debugger remote. + */ +struct rtems_debugger_remote +{ + const char* name; + int (*begin)(rtems_debugger_remote* remote, const char* device); + int (*end)(rtems_debugger_remote* remote); + int (*connect)(rtems_debugger_remote* remote); + int (*disconnect)(rtems_debugger_remote* remote); + bool (*isconnected)(rtems_debugger_remote* remote); + ssize_t (*read)(rtems_debugger_remote* remote, void* buf, size_t nbytes); + ssize_t (*write)(rtems_debugger_remote* remote, const void* buf, size_t nbytes); + void* data; +}; + +/** + * Register a remote with the server. + */ +int rtems_debugger_remote_register(rtems_debugger_remote* remote); + +/** + * Find a remote by name. + */ +rtems_debugger_remote* rtems_debugger_remote_find(const char* name); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif diff --git a/cpukit/include/rtems/debugger/rtems-debugger-server.h b/cpukit/include/rtems/debugger/rtems-debugger-server.h new file mode 100644 index 0000000000..a345d7649e --- /dev/null +++ b/cpukit/include/rtems/debugger/rtems-debugger-server.h @@ -0,0 +1,217 @@ +/* + * Copyright (c) 2016-2017 Chris Johns . + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Debugger for RTEMS. + */ + +#ifndef _RTEMS_DEBUGGER_SERVER_h +#define _RTEMS_DEBUGGER_SERVER_h + +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * Debugger NUMOF macro. + */ +#define RTEMS_DEBUGGER_NUMOF(_d) (sizeof(_d) / sizeof(_d[0])) + +/** + * Machine specific size. Here for 64bit support. + */ +#define DB_UINT uint32_t + +/* + * Debugger signals. + */ +#define RTEMS_DEBUGGER_SIGNAL_HUP 1 /* Hangup */ +#define RTEMS_DEBUGGER_SIGNAL_INT 2 /* Interrupt */ +#define RTEMS_DEBUGGER_SIGNAL_QUIT 3 /* Quit */ +#define RTEMS_DEBUGGER_SIGNAL_ILL 4 /* Illegal instruction */ +#define RTEMS_DEBUGGER_SIGNAL_TRAP 5 /* Trace/breakpoint trap */ +#define RTEMS_DEBUGGER_SIGNAL_ABRT 6 /* Aborted */ +#define RTEMS_DEBUGGER_SIGNAL_EMT 7 /* Emulation trap */ +#define RTEMS_DEBUGGER_SIGNAL_FPE 8 /* Arithmetic exception */ +#define RTEMS_DEBUGGER_SIGNAL_KILL 9 /* Killed */ +#define RTEMS_DEBUGGER_SIGNAL_BUS 10 /* Bus error */ +#define RTEMS_DEBUGGER_SIGNAL_SEGV 11 /* Segmentation fault */ +#define RTEMS_DEBUGGER_SIGNAL_SYS 12 /* Bad system call */ +#define RTEMS_DEBUGGER_SIGNAL_PIPE 13 /* Broken pipe */ +#define RTEMS_DEBUGGER_SIGNAL_ALRM 14 /* Alarm clock */ +#define RTEMS_DEBUGGER_SIGNAL_TERM 15 /* Terminated */ +#define RTEMS_DEBUGGER_SIGNAL_URG 16 /* Urgent I/O condition */ +#define RTEMS_DEBUGGER_SIGNAL_STOP 17 /* Stopped (signal) */ +#define RTEMS_DEBUGGER_SIGNAL_TSTP 18 /* Stopped (user) */ +#define RTEMS_DEBUGGER_SIGNAL_CONT 19 /* Continued */ + +/** + * Timeout period for the Debugger task to stop in usecs. + */ +#define RTEMS_DEBUGGER_TIMEOUT_STOP (5 * 1000 * 1000) + +/** + * Debugger poll wait timeout in usecs. + */ +#define RTEMS_DEBUGGER_POLL_WAIT (10000) + +/** + * Debugger task stack size. + */ +#define RTEMS_DEBUGGER_STACKSIZE (16 * 1024) + +/** + * Debugger output buffer size. + */ +#define RTEMS_DEBUGGER_BUFFER_SIZE (4 * 1024) + +/** + * Debugger flags. + */ +#define RTEMS_DEBUGGER_FLAG_VERBOSE (1 << 0) +#define RTEMS_DEBUGGER_FLAG_RESET (1 << 1) +#define RTEMS_DEBUGGER_FLAG_NON_STOP (1 << 2) +#define RTEMS_DEBUGGER_FLAG_VCONT (1 << 3) +#define RTEMS_DEBUGGER_FLAG_MULTIPROCESS (1 << 4) +#define RTEMS_DEBUGGER_FLAG_VERBOSE_LOCK (1 << 5) +#define RTEMS_DEBUGGER_FLAG_VERBOSE_CMDS (1 << 6) + +/** + * Forward decl for the threads and targets. + */ +typedef struct rtems_debugger_remote rtems_debugger_remote; +typedef struct rtems_debugger_threads rtems_debugger_threads; +typedef struct rtems_debugger_target rtems_debugger_target; + +/** + * Local types for the RTEMS-X interface. + */ +typedef struct _Condition_Control rtems_rx_cond; +typedef struct _Mutex_recursive_Control rtems_rx_mutex; + +/** + * Debugger data. + */ +typedef struct +{ + int port; + int timeout; + rtems_task_priority priority; + rtems_rx_mutex lock; + rtems_debugger_remote* remote; + rtems_id server_task; + rtems_rx_cond server_cond; + volatile bool server_running; + volatile bool server_finished; + rtems_id events_task; + volatile bool events_running; + volatile bool events_finished; + rtems_printer printer; + uint32_t flags; + pid_t pid; + bool remote_debug; + bool ack_pending; + size_t output_level; + uint8_t input[RTEMS_DEBUGGER_BUFFER_SIZE]; + uint8_t output[RTEMS_DEBUGGER_BUFFER_SIZE]; + rtems_debugger_threads* threads; + rtems_chain_control exception_threads; + int signal; + rtems_debugger_target* target; +} rtems_debugger_server; + +/** + * Debugger global variable. + */ +extern rtems_debugger_server* rtems_debugger; + +/** + * Debug server printer. + */ +extern int rtems_debugger_printf(const char* format, ...) RTEMS_PRINTFLIKE(1, 2); +extern int rtems_debugger_clean_printf(const char* format, ...) RTEMS_PRINTFLIKE(1, 2); +extern void rtems_debugger_printk_lock(rtems_interrupt_lock_context* lock_context); +extern void rtems_debugger_printk_unlock(rtems_interrupt_lock_context* lock_context); + +/** + * Lock the Debugger. + */ +extern void rtems_debugger_lock(void); + +/** + * Unlock the Debugger. + */ +extern void rtems_debugger_unlock(void); + +/** + * Is the server still running? + */ +extern bool rtems_debugger_server_running(void); + +/** + * Get the remote handle from the debugger. + */ +extern rtems_debugger_remote* rtems_debugger_remote_handle(void); + +/** + * Is the debugger connected? + */ +extern bool rtems_debugger_connected(void); + +/** + * Is the debugger events thread runnins? + */ +extern bool rtems_debugger_server_events_running(void); + +/** + * Signal events thread in the debug server to run. + */ +extern void rtems_debugger_server_events_signal(void); + +/** + * Check if verbose is on. + */ +extern bool rtems_debugger_verbose(void); + +/** + * Check a flag. + */ +static inline bool rtems_debugger_server_flag(uint32_t mask) +{ + return (rtems_debugger->flags & mask) != 0; +} + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif diff --git a/cpukit/include/rtems/devfs.h b/cpukit/include/rtems/devfs.h new file mode 100644 index 0000000000..b0a9197eca --- /dev/null +++ b/cpukit/include/rtems/devfs.h @@ -0,0 +1,255 @@ +/** +* @file +* +* @brief Device Only File System +* +* This include file contains all constants and structures associated +* with the 'device-only' filesystem. +*/ + +#ifndef _RTEMS_DEVFS_H +#define _RTEMS_DEVFS_H + +#include + +/** + * @defgroup DevFsDeviceTable Device Only File System + * + * @ingroup FileSystemTypesAndMount + * + * @brief This structure defines the type of device table + */ +/**@{*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Per Device Node Control Structure + * + * This structure is instanced per device node and contains all information + * used by this file system implementation to manage that device node. + */ +typedef struct { + /** This member points to device name which is not a null-terminated string */ + const char *name; + /** This member is the name length of a device */ + size_t namelen; + /** major number of a device */ + rtems_device_major_number major; + /** minor number of a device */ + rtems_device_minor_number minor; + /** device creation mode, only device file can be created */ + mode_t mode; +} devFS_node; + +typedef struct { + devFS_node *nodes; + size_t count; +} devFS_data; + +/** + * The following defines the device-only filesystem operating + * operations. + */ +extern const rtems_filesystem_operations_table devFS_ops; + +/** + * The following defines the device-only filesystem operating + * handlers. + */ +extern const rtems_filesystem_file_handlers_r devFS_file_handlers; + +/** + * @brief Obtain Immutable Pointer to Immutable File System Data + * + * This methods returns the immutable file system specific information + * associated with this file. + */ +static inline const devFS_data *devFS_get_data( + const rtems_filesystem_location_info_t *loc +) +{ + return (const devFS_data *) loc->mt_entry->immutable_fs_info; +} + +/** + * @brief Evaluate Path + */ +extern void devFS_eval_path( + rtems_filesystem_eval_path_context_t *ctx +); + +/** + * @brief Maps Open Operation to rtems_io_open + * + * This handler maps open operation to rtems_io_open. + * + * @param iop This is the RTEMS's internal representation of file. + * @param pathname a null-terminated string that starts with /dev. + * @param oflag access flags + * @param mode access mode + * + * @retval the same as open + */ +extern int devFS_open( + rtems_libio_t *iop, + const char *pathname, + int oflag, + mode_t mode +); + + +/** + * @brief Maps Close Operation to rtems_io_close + * + * This handler maps close operation to rtems_io_close. + * + * @param iop This is the RTEMS's internal representation of file + * + * @retval the same as close + */ +extern int devFS_close( + rtems_libio_t *iop +); + +/** + * @brief Maps Read Operation to rtems_io_read + * + * This handler maps read operation to rtems_io_read. + * + * @param iop This is the RTEMS's internal representation of file + * @param buffer memory location to store read data + * @param count how many bytes to read + * + * @retval On successful, this routine returns total bytes read. On error + * it returns -1 and errno is set to proper value. + */ +extern ssize_t devFS_read( + rtems_libio_t *iop, + void *buffer, + size_t count +); + +/** + * @brief Writes Operation to rtems_io_write + * + * This handler maps write operation to rtems_io_write. + * + * @param iop This is the RTEMS's internal representation of file + * @param buffer data to be written + * @param count how many bytes to write + * + * @retval On successful, this routine returns total bytes written. On error + * it returns -1 and errno is set to proper value. + */ +extern ssize_t devFS_write( + rtems_libio_t *iop, + const void *buffer, + size_t count +); + +/** + * @brief Maps ioctl Operation to rtems_io_ioctl + * + * This handler maps ioctl operation to rtems_io_ioctl. + * + * @param iop This is the RTEMS's internal representation of file + * @param command io control command + * @param buffer io control parameters + * + * @retval On successful, this routine returns total bytes written. On error + * it returns -1 and errno is set to proper value. + */ +extern int devFS_ioctl( + rtems_libio_t *iop, + ioctl_command_t command, + void *buffer +); + +/** + * @brief Gets the Device File Information + * + * This handler gets the device file information. This routine only + * set the following member of struct stat: + * + * - st_dev: device number + * - st_mode: device file creation mode, only two mode are accepted: + * + S_IFCHR: character device file + * + S_IFBLK: block device file + * + * @param loc contains filesystem access information + * @param buf buffer to hold the device file's information + * + * @retval On successful, this routine returns 0. On error + * it returns -1 and errno is set to proper value. + */ +extern int devFS_stat( + const rtems_filesystem_location_info_t *loc, + struct stat *buf +); + +/** + * @brief Creates an item in the main device table. + * + * This routine is invoked upon registration of a new device + * file. It is responsible for creating a item in the main + * device table. This routine searches the device table in + * sequential order, when found a empty slot, it fills the slot + * with proper values. + * + * @see rtems_filesystem_mknod_t. + */ +extern int devFS_mknod( + const rtems_filesystem_location_info_t *parentloc, + const char *name, + size_t namelen, + mode_t mode, + dev_t dev +); + +/** + * @brief Creates the Main Device Table + * + * This routine is invoked upon rtems filesystem initialization. + * It is responsible for creating the main device table, + * initializing it to a known state, and set device file operation + * handlers. After this, the device-only filesytem is ready for use + * + * @param mt_entry The filesystem mount table entry. + * @param data Filesystem specific data. + * + * @retval upon success, this routine returns 0; otherwise it returns + * -1 and errno is set to proper value. The only error is when malloc + * failed, and errno is set to NOMEM. + */ +extern int devFS_initialize( + rtems_filesystem_mount_table_entry_t *mt_entry, + const void *data +); + +/** + * @brief Retrieves and Prints all the Device Registered in System + * + * This routine retrieves all the device registered in system, and + * prints out their detail information. For example, on one system, + * devFS_show will print out following message: + * + * @code + * /dev/console 0 0 + * /dev/clock 1 0 + * /dev/tty0 0 0 + * /flash 2 0 + * @endcode + * + * This routine is intended for debugging, and can be used by shell + * program to provide user with the system information. + */ +extern void devFS_Show(void); + +#ifdef __cplusplus +} +#endif +/**@}*/ +#endif + diff --git a/cpukit/include/rtems/deviceio.h b/cpukit/include/rtems/deviceio.h new file mode 100644 index 0000000000..a448fc7bb4 --- /dev/null +++ b/cpukit/include/rtems/deviceio.h @@ -0,0 +1,88 @@ +/** + * @file + * + * @brief Operations on IMFS Device Nodes + */ + +/* + * COPYRIGHT (c) 1989-2012. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_DEVICEIO_H +#define _RTEMS_DEVICEIO_H + +#include + +/** + * @defgroup IMFSDevices IMFS Device IO Handler + * + * @ingroup IMFS + * + * This contains the interface to device drivers using the RTEMS Classic API. + */ +/**@{*/ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @brief IMFS device node handlers. + * + * IMFS Device Node Handlers + * + * This file contains the set of handlers used to map operations on + * IMFS device nodes onto calls to the RTEMS Classic API IO Manager. + */ +int rtems_deviceio_open( + rtems_libio_t *iop, + const char *path, + int oflag, + mode_t mode, + rtems_device_major_number major, + rtems_device_minor_number minor +); + +int rtems_deviceio_close( + rtems_libio_t *iop, + rtems_device_major_number major, + rtems_device_minor_number minor +); + +ssize_t rtems_deviceio_read( + rtems_libio_t *iop, + void *buf, + size_t nbyte, + rtems_device_major_number major, + rtems_device_minor_number minor +); + +ssize_t rtems_deviceio_write( + rtems_libio_t *iop, + const void *buf, + size_t nbyte, + rtems_device_major_number major, + rtems_device_minor_number minor +); + +int rtems_deviceio_control( + rtems_libio_t *iop, + ioctl_command_t command, + void *buffer, + rtems_device_major_number major, + rtems_device_minor_number minor +); + +#ifdef __cplusplus +} +#endif +/* __cplusplus */ + +/**@}*/ + +#endif /* _RTEMS_DEVICEIO_H */ diff --git a/cpukit/include/rtems/devnull.h b/cpukit/include/rtems/devnull.h new file mode 100644 index 0000000000..39081f478b --- /dev/null +++ b/cpukit/include/rtems/devnull.h @@ -0,0 +1,84 @@ +/** + * @file + * + * @brief RTEMS /dev/null Device Driver + * + * This include file defines the interface to the RTEMS /dev/null + * device driver. + */ + +/* + * Author: Ralf Corsepius (corsepiu@faw.uni-ulm.de) + * + * COPYRIGHT (c) 1989-2000. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_DEVNULL_H +#define _RTEMS_DEVNULL_H + +#include + +/** + * @defgroup libmisc_devnull Null Device Driver + * + * @ingroup libmisc + */ +/**@{*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#define DEVNULL_DRIVER_TABLE_ENTRY \ + { null_initialize, null_open, null_close, null_read, \ + null_write, null_control } + +#define NULL_SUCCESSFUL RTEMS_SUCCESSFUL + +rtems_device_driver null_initialize( + rtems_device_major_number, + rtems_device_minor_number, + void * +); + +rtems_device_driver null_open( + rtems_device_major_number, + rtems_device_minor_number, + void * +); + +rtems_device_driver null_close( + rtems_device_major_number, + rtems_device_minor_number, + void * +); + +rtems_device_driver null_read( + rtems_device_major_number, + rtems_device_minor_number, + void * +); + +rtems_device_driver null_write( + rtems_device_major_number, + rtems_device_minor_number, + void * +); + +rtems_device_driver null_control( + rtems_device_major_number, + rtems_device_minor_number, + void * +); + +#ifdef __cplusplus +} +#endif +/**@}*/ +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/devzero.h b/cpukit/include/rtems/devzero.h new file mode 100644 index 0000000000..bc47d3ea09 --- /dev/null +++ b/cpukit/include/rtems/devzero.h @@ -0,0 +1,92 @@ +/** + * @file rtems/devzero.h + * + * @brief RTEMS /dev/zero Device Driver + * + * This include file defines the interface to the RTEMS /dev/zero + * device driver. + */ + +/* + * Copyright (c) 2011 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Obere Lagerstr. 30 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_DEVZERO_H +#define _RTEMS_DEVZERO_H + +#include + +/** + * @defgroup libmisc_devzero Zero Device Driver + * + * @ingroup libmisc + */ +/**@{*/ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define DEVZERO_DEVICE_NAME "/dev/zero" + +#define DEVZERO_DRIVER_TABLE_ENTRY \ + { \ + dev_zero_initialize, \ + dev_zero_open, \ + dev_zero_close, \ + dev_zero_read, \ + dev_zero_write, \ + dev_zero_control \ + } + +rtems_device_driver dev_zero_initialize( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg +); + +rtems_device_driver dev_zero_open( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg +); + +rtems_device_driver dev_zero_close( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg +); + +rtems_device_driver dev_zero_read( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg +); + +rtems_device_driver dev_zero_write( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg +); + +rtems_device_driver dev_zero_control( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg +); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +/**@}*/ +#endif /* _RTEMS_DEVZERO_H */ diff --git a/cpukit/include/rtems/diskdevs.h b/cpukit/include/rtems/diskdevs.h new file mode 100644 index 0000000000..0be766afa3 --- /dev/null +++ b/cpukit/include/rtems/diskdevs.h @@ -0,0 +1,511 @@ +/** + * @file + * + * @brief Block Device Disk Management API + * + * @ingroup rtems_disk + */ + +/* + * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia + * Author: Victor V. Vengerov + */ + +#ifndef _RTEMS_DISKDEVS_H +#define _RTEMS_DISKDEVS_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct rtems_disk_device rtems_disk_device; + +/** + * @defgroup rtems_disk Block Device Disk Management + * + * @ingroup rtems_libblock + * + * @brief This module provides functions to manage disk devices. + * + * A disk is a set of blocks which are identified by a consecutive set of + * non-negative integers starting at zero. There are also logical disks which + * contain a subset of consecutive disk blocks. The logical disks are used to + * represent the partitions of a disk. The disk devices are accessed via the + * @ref rtems_bdbuf "block device buffer module". + */ +/**@{**/ + +/** + * @brief Block device block index type. + */ +typedef uint32_t rtems_blkdev_bnum; + +/** + * @brief Block device IO control handler type. + */ +typedef int (*rtems_block_device_ioctl)( + rtems_disk_device *dd, + uint32_t req, + void *argp +); + +/** + * @brief Trigger value to disable further read-ahead requests. + */ +#define RTEMS_DISK_READ_AHEAD_NO_TRIGGER ((rtems_blkdev_bnum) -1) + +/** + * @brief Block device read-ahead control. + */ +typedef struct { + /** + * @brief Chain node for the read-ahead request queue of the read-ahead task. + */ + rtems_chain_node node; + + /** + * @brief Block value to trigger the read-ahead request. + * + * A value of @ref RTEMS_DISK_READ_AHEAD_NO_TRIGGER will disable further + * read-ahead requests since no valid block can have this value. + */ + rtems_blkdev_bnum trigger; + + /** + * @brief Start block for the next read-ahead request. + * + * In case the trigger value is out of range of valid blocks, this value my + * be arbitrary. + */ + rtems_blkdev_bnum next; +} rtems_blkdev_read_ahead; + +/** + * @brief Block device statistics. + * + * Integer overflows in the statistic counters may happen. + */ +typedef struct { + /** + * @brief Read hit count. + * + * A read hit occurs in the rtems_bdbuf_read() function in case the block is + * in the cached or modified state. + */ + uint32_t read_hits; + + /** + * @brief Read miss count. + * + * A read miss occurs in the rtems_bdbuf_read() function in case the block is + * in the empty state and a read transfer must be initiated to read the data + * from the device. + */ + uint32_t read_misses; + + /** + * @brief Read-ahead transfer count. + * + * Each read-ahead transfer may read multiple blocks. + */ + uint32_t read_ahead_transfers; + + /** + * @brief Count of blocks transfered from the device. + */ + uint32_t read_blocks; + + /** + * @brief Read error count. + * + * Error count of transfers issued by the read or read-ahead requests. + */ + uint32_t read_errors; + + /** + * @brief Write transfer count. + * + * Each write transfer may write multiple blocks. + */ + uint32_t write_transfers; + + /** + * @brief Count of blocks transfered to the device. + */ + uint32_t write_blocks; + + /** + * @brief Write error count. + * + * Error count of transfers issued by write requests. + */ + uint32_t write_errors; +} rtems_blkdev_stats; + +/** + * @brief Description of a disk device (logical and physical disks). + * + * An array of pointer tables to rtems_disk_device structures is maintained. + * The first table will be indexed by the major number and the second table + * will be indexed by the minor number. This allows quick lookup using a data + * structure of moderated size. + */ +struct rtems_disk_device { + /** + * @brief Device identifier (concatenation of major and minor number). + */ + dev_t dev; + + /** + * @brief Physical device identifier (equals the @c dev entry if it specifies a + * physical device). + */ + rtems_disk_device *phys_dev; + + /** + * @brief Driver capabilities. + */ + uint32_t capabilities; + + /** + * @brief Disk device name. + */ + char *name; + + /** + * @brief Usage counter. + * + * Devices cannot be deleted if they are in use. + */ + unsigned uses; + + /** + * @brief Start media block number. + * + * Equals zero for physical devices. It is a media block offset to the + * related physical device for logical device. + */ + rtems_blkdev_bnum start; + + /** + * @brief Size of the physical or logical disk in media blocks. + */ + rtems_blkdev_bnum size; + + /** + * @brief Media block size in bytes. + * + * This is the media transfer unit the hardware defaults to. + */ + uint32_t media_block_size; + + /** + * @brief Block size in bytes. + * + * This is the minimum transfer unit. It may be a multiple of the media + * block size. It must be positive. + * + * @see rtems_bdbuf_set_block_size(). + */ + uint32_t block_size; + + /** + * @brief Block count. + * + * @see rtems_bdbuf_set_block_size(). + */ + rtems_blkdev_bnum block_count; + + /** + * @brief Media blocks per device blocks. + * + * @see rtems_bdbuf_set_block_size(). + */ + uint32_t media_blocks_per_block; + + /** + * @brief Block to media block shift. + * + * In case this value is non-negative the media block of a block can be + * calculated as media block = block << block_to_media_block_shift, otherwise + * a 64-bit operation will be used. + * + * @see rtems_bdbuf_set_block_size(). + */ + int block_to_media_block_shift; + + /** + * @brief Buffer descriptors per group count. + * + * @see rtems_bdbuf_set_block_size(). + */ + size_t bds_per_group; + + /** + * @brief IO control handler for this disk. + */ + rtems_block_device_ioctl ioctl; + + /** + * @brief Private data for the disk driver. + */ + void *driver_data; + + /** + * @brief Indicates that this disk should be deleted as soon as the last user + * releases this disk. + */ + bool deleted; + + /** + * @brief Device statistics for this disk. + */ + rtems_blkdev_stats stats; + + /** + * @brief Read-ahead control for this disk. + */ + rtems_blkdev_read_ahead read_ahead; +}; + +/** + * @name Disk Device Data + */ +/**@{**/ + +static inline dev_t rtems_disk_get_device_identifier( + const rtems_disk_device *dd +) +{ + return dd->dev; +} + +static inline rtems_device_major_number rtems_disk_get_major_number( + const rtems_disk_device *dd +) +{ + return rtems_filesystem_dev_major_t(dd->dev); +} + +static inline rtems_device_minor_number rtems_disk_get_minor_number( + const rtems_disk_device *dd +) +{ + return rtems_filesystem_dev_minor_t(dd->dev); +} + +static inline void *rtems_disk_get_driver_data( + const rtems_disk_device *dd +) +{ + return dd->driver_data; +} + +static inline uint32_t rtems_disk_get_media_block_size( + const rtems_disk_device *dd +) +{ + return dd->media_block_size; +} + +static inline uint32_t rtems_disk_get_block_size( + const rtems_disk_device *dd +) +{ + return dd->block_size; +} + +static inline rtems_blkdev_bnum rtems_disk_get_block_begin( + const rtems_disk_device *dd +) +{ + return dd->start; +} + +static inline rtems_blkdev_bnum rtems_disk_get_block_count( + const rtems_disk_device *dd +) +{ + return dd->size; +} + +/** @} */ + +/** + * @name Disk Device Maintainance + */ +/**@{**/ + +/** + * @brief Creates a physical disk with device identifier @a dev. + * + * The block size @a block_size must be positive. The disk will have + * @a block_count blocks. The block index starts with zero. The associated disk + * device driver will be invoked via the IO control handler @a handler. A + * device node will be registered in the file system with absolute path @a + * name, if @a name is not @c NULL. This function is usually invoked from a + * block device driver during initialization when a physical device is detected + * in the system. The device driver provides an IO control handler to allow + * block device operations. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_NOT_CONFIGURED Cannot lock disk device operation mutex. + * @retval RTEMS_INVALID_ADDRESS IO control handler is @c NULL. + * @retval RTEMS_INVALID_NUMBER Block size is invalid. + * @retval RTEMS_NO_MEMORY Not enough memory. + * @retval RTEMS_RESOURCE_IN_USE Disk device descriptor is already in use. + * @retval RTEMS_UNSATISFIED Cannot create device node. + */ +rtems_status_code rtems_disk_create_phys( + dev_t dev, + uint32_t block_size, + rtems_blkdev_bnum block_count, + rtems_block_device_ioctl handler, + void *driver_data, + const char *name +); + +/** + * @brief Creates a logical disk with device identifier @a dev. + * + * A logical disk manages a subset of consecutive blocks contained in the + * physical disk with identifier @a phys. The start block index of the logical + * disk device is @a block_begin. The block count of the logcal disk will be + * @a block_count. The blocks must be within the range of blocks managed by + * the associated physical disk device. A device node will be registered in + * the file system with absolute path @a name, if @a name is not @c NULL. The + * block size and IO control handler are inherited by the physical disk. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_NOT_CONFIGURED Cannot lock disk device operation mutex. + * @retval RTEMS_INVALID_ID Specified physical disk identifier does not + * correspond to a physical disk. + * @retval RTEMS_INVALID_NUMBER Begin block or block count are out of range. + * @retval RTEMS_NO_MEMORY Not enough memory. + * @retval RTEMS_RESOURCE_IN_USE Disk device descriptor for logical disk + * identifier is already in use. + * @retval RTEMS_UNSATISFIED Cannot create device node. + */ +rtems_status_code rtems_disk_create_log( + dev_t dev, + dev_t phys, + rtems_blkdev_bnum block_begin, + rtems_blkdev_bnum block_count, + const char *name +); + +/** + * @brief Deletes a physical or logical disk device with identifier @a dev. + * + * Marks the disk device as deleted. When a physical disk device is deleted, + * all corresponding logical disk devices will marked as deleted too. Disks + * that are marked as deleted and have a usage counter of zero will be deleted. + * The corresponding device nodes will be removed from the file system. In + * case of a physical disk deletion the IO control handler will be invoked with + * a RTEMS_BLKIO_DELETED request. Disks that are still in use will be deleted + * upon release. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_NOT_CONFIGURED Cannot lock disk device operation mutex. + * @retval RTEMS_INVALID_ID No disk for specified device identifier. + */ +rtems_status_code rtems_disk_delete(dev_t dev); + +/** + * @brief Returns the disk device descriptor for the device identifier @a dev. + * + * Increments usage counter by one. You should release the disk device + * descriptor with rtems_disk_release(). + * + * @return Pointer to the disk device descriptor or @c NULL if no corresponding + * disk exists. + */ +rtems_disk_device *rtems_disk_obtain(dev_t dev); + +/** + * @brief Releases the disk device descriptor @a dd. + * + * Decrements usage counter by one. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + */ +rtems_status_code rtems_disk_release(rtems_disk_device *dd); + +/** @} */ + +/** + * @name Disk Management + */ +/**@{**/ + +/** + * @brief Initializes the disk device management. + * + * This functions returns successful if the disk device management is already + * initialized. There is no protection against concurrent access. + * + * @retval RTEMS_SUCCESSFUL Successful initialization. + * @retval RTEMS_NO_MEMORY Not enough memory or no semaphore available. + * @retval RTEMS_UNSATISFIED Block device buffer initialization failed. + */ +rtems_status_code rtems_disk_io_initialize(void); + +/** + * @brief Releases all resources allocated for disk device management. + * + * There is no protection against concurrent access. If parts of the system + * are still in use the behaviour is undefined. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + */ +rtems_status_code rtems_disk_io_done(void); + +/** @} */ + +/** @} */ + +/** + * @brief Disk device iterator. + * + * Returns the next disk device descriptor with a device identifier larger than + * @a dev. If there is no such device, @c NULL will be returned. Use minus + * one to start the search. + * + * @code + * rtems_status_code sc = RTEMS_SUCCESSFUL; + * rtems_disk_device *dd = (dev_t) -1; + * + * while (sc == RTEMS_SUCCESSFUL && (dd = rtems_disk_next(dev)) != NULL) { + * dev = rtems_disk_get_device_identifier(dd); + * sc = rtems_disk_release(dd); + * } + * @endcode + */ +rtems_disk_device *rtems_disk_next(dev_t dev); + +/* Internal function, do not use */ +rtems_status_code rtems_disk_init_phys( + rtems_disk_device *dd, + uint32_t block_size, + rtems_blkdev_bnum block_count, + rtems_block_device_ioctl handler, + void *driver_data +); + +/* Internal function, do not use */ +rtems_status_code rtems_disk_init_log( + rtems_disk_device *dd, + rtems_disk_device *phys_dd, + rtems_blkdev_bnum block_begin, + rtems_blkdev_bnum block_count +); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/include/rtems/dosfs.h b/cpukit/include/rtems/dosfs.h new file mode 100644 index 0000000000..7691ed7e43 --- /dev/null +++ b/cpukit/include/rtems/dosfs.h @@ -0,0 +1,433 @@ +/** + * @file + * + * @brief Application Interface to FAT Filesystem + * + * @ingroup DOSFS + */ + +/* + * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia + * Author: Eugeny S. Mints + * + * Modifications to support UTF-8 in the file system are + * Copyright (c) 2013 embedded brains GmbH. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_DOSFS_H +#define _RTEMS_DOSFS_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct rtems_dosfs_convert_control rtems_dosfs_convert_control; + +/** + * @brief Converts from UTF-8 into a specific code page. + * + * @param[in,out] self The convert control. + * @param[in] src A well-formed UTF-8 string to be converted. + * @param[in] src_size The size of the string in bytes (inludes '\\0' if any). + * @param[out] dst The address the converted string will get copied to. + * @param[in,out] dst_size The size of the buffer in bytes respectively the + * number of bytes written to the buffer. + * + * @retval 0 Successful operation. + * @retval EINVAL Conversion was successful, but is not reversible. + * @retval ENOMEM Conversion failed (possibly due to insufficient buffer size). + */ +typedef int (*rtems_dosfs_utf8_to_codepage)( + rtems_dosfs_convert_control *self, + const uint8_t *src, + size_t src_size, + char *dst, + size_t *dst_size +); + +/** + * @brief Converts from a specific code page into UTF-8 + * + * @param[in,out] self The convert control. + * @param[in] src A well-formed string in code page format. + * @param[in] src_size The size of the string in bytes (inludes '\\0' if any). + * @param[out] dst The address the converted string will get copied to. + * @param[in,out] dst_size The size of the buffer in bytes respectively the + * number of bytes written to the buffer. + * + * @retval 0 Successful operation. + * @retval EINVAL Conversion was successful, but is not reversible. + * @retval ENOMEM Conversion failed (possibly due to insufficient buffer size). + */ +typedef int (*rtems_dosfs_codepage_to_utf8)( + rtems_dosfs_convert_control *self, + const char *src, + size_t src_size, + uint8_t *dst, + size_t *dst_size +); + +/** + * @brief Converts from UTF-8 to UTF-16 + * + * @param[in,out] self The convert control. + * @param[in] src A well-formed UTF-8 string to be converted. + * @param[in] src_size The size of the string in bytes (inludes '\\0' if any). + * @param[out] dst The address the converted string will get copied to + * @param[in,out] dst_size The size of the buffer in bytes respectively the + * number of bytes written to the buffer. + * + * @retval 0 Successful operation. + * @retval EINVAL Conversion was successful, but is not reversible. + * @retval ENOMEM Conversion failed (possibly due to insufficient buffer size). + */ +typedef int (*rtems_dosfs_utf8_to_utf16)( + rtems_dosfs_convert_control *self, + const uint8_t *src, + size_t src_size, + uint16_t *dst, + size_t *dst_size +); + +/** + * @brief Converts from UTF-16 to UTF-8. + * + * @param[in,out] self The convert control. + * @param[in] src A well-formed UTF-16 string to be converted. + * @param[in] src_size The size of the string in bytes (inludes '\\0' if any). + * @param[out] dst The address the converted string will get copied to. + * @param[in,out] dst_size The size of the buffer in bytes respectively the + * number of bytes written to the buffer + * + * @retval 0 Successful operation. + * @retval EINVAL Conversion was successful, but is not reversible. + * @retval ENOMEM Conversion failed (possibly due to insufficient buffer size). + */ +typedef int (*rtems_dosfs_utf16_to_utf8)( + rtems_dosfs_convert_control *self, + const uint16_t *src, + size_t src_size, + uint8_t *dst, + size_t *dst_size +); + +/** + * @brief Converts from UTF-8 to Normalized Form Canonical Decomposition. + * + * Does canonical decomposition of the UTF-8 string and in addition + * also converts upper case alphabetic characters to lower case characters + * + * @param[in,out] self The convert control. + * @param[in] src A well-formed UTF-8 string to be normalized and fold. + * @param[in] src_size The size of the string in bytes (inludes '\\0' if any). + * @param[out] dst The address the normalized and fold string will get + * copied to. + * @param[in,out] dst_size The size of the buffer in bytes respectively the + * number of bytes written to the buffer. + * + * @retval 0 Successful operation. + * @retval EINVAL Conversion failed. + * @retval ENOMEM Conversion failed (possibly due to insufficient buffer size). + * @retval EOVERFLOW Conversion failed. + * @retval ENOENT Conversion failed. + */ +typedef int (*rtems_dosfs_utf8_normalize_and_fold)( + rtems_dosfs_convert_control *self, + const uint8_t *src, + size_t src_size, + uint8_t *dst, + size_t *dst_size +); + +/** + * @brief Destroys a convert control structure. + * + * @param[in,out] self The convert control for destruction. + */ +typedef void (*rtems_dosfs_convert_destroy)( + rtems_dosfs_convert_control *self +); + +/** + * @brief FAT filesystem convert handler. + */ +typedef struct { + rtems_dosfs_utf8_to_codepage utf8_to_codepage; + rtems_dosfs_codepage_to_utf8 codepage_to_utf8; + rtems_dosfs_utf8_to_utf16 utf8_to_utf16; + rtems_dosfs_utf16_to_utf8 utf16_to_utf8; + rtems_dosfs_utf8_normalize_and_fold utf8_normalize_and_fold; + rtems_dosfs_convert_destroy destroy; +} rtems_dosfs_convert_handler; + +typedef struct { + void *data; + size_t size; +} rtems_dosfs_buffer; + +/** + * @brief FAT filesystem convert control. + * + * Short file names are stored in the code page format. Long file names are + * stored as little-endian UTF-16. The convert control determines the format + * conversions to and from the POSIX file name strings. + */ +struct rtems_dosfs_convert_control { + const rtems_dosfs_convert_handler *handler; + rtems_dosfs_buffer buffer; +}; + +/** + * @defgroup DOSFS FAT Filesystem Support + * + * @ingroup FileSystemTypesAndMount + * + * @brief FAT file system configuration support, format and mount options. + * + * A block device can be formatted with a FAT file system with the + * msdos_format() function. + * + * The FAT file system mount operation can be controlled with FAT file system + * specific mount options, see @ref rtems_dosfs_mount_options. + * + * @{ + */ + +/** + * @brief Semaphore count per FAT filesystem instance. + * + * This can be used for system configuration via . + */ +#define RTEMS_DOSFS_SEMAPHORES_PER_INSTANCE 1 + +/** + * @brief FAT filesystem mount options. + */ +typedef struct { + /** + * @brief Converter implementation for new file system instance. + * + * Before converters have been added to the RTEMS implementation of the FAT + * file system, the implementation was: + * - Short names were saved in code page format (as is still the case). + * - Long names were not saved in UTF-16 format as mandated by the FAT file + * system specification. Instead the character in the local encoding was + * stored to the low byte directly and the high byte was set to zero. + * + * There are a few compatibility issues due to a non-standard conform + * implementation of the FAT file system before the UTF-8 support was added. + * These following issues affect the default converter and the UTF-8 + * converter: + * - Before UTF-8 support was added, it was possible to create files with the + * the same short name in single case and mixed case in a directory. It + * was for example possible to have files "ABC" and "aBc" in a single + * directory. Now this bug is fixed. + * - Before UTF-8 support was added, it was possible to create files with a + * name length of slightly more than 255 characters. Now the + * implementation adheres exactly to the 255 character limit. + * - Long file names saved before UTF-8 support was added could contain + * non-ASCII characters in the low byte which was saved for a long name + * character. With the default converter this means such files can be read + * only by their short file name. With the UTF-8 converter file names will + * be read correctly as long as the characters written with the old + * implementation were Latin-1 characters. + * + * The following sample code demonstrates how to mount a file + * system with UTF-8 support: + * @code + * #include + * #include + * #include + * #include + * + * static int mount_with_utf8( + * const char *device_file, + * const char *mount_point + * ) + * { + * rtems_dosfs_convert_control *convert_ctrl; + * int rv; + * + * convert_ctrl = rtems_dosfs_create_utf8_converter( "CP850" ); + * + * if ( convert_ctrl != NULL ) { + * rtems_dosfs_mount_options mount_opts; + * + * memset( &mount_opts, 0, sizeof( mount_opts ) ); + * mount_opts.converter = convert_ctrl; + * + * rv = mount_and_make_target_path( + * device_file, + * mount_point, + * RTEMS_FILESYSTEM_TYPE_DOSFS, + * RTEMS_FILESYSTEM_READ_WRITE, + * &mount_opts + * ); + * } else { + * rv = -1; + * errno = ENOMEM; + * } + * + * return rv; + * } + * @endcode + * + * In case you do not want UTF-8 support, you can simply pass a NULL pointer + * to mount_and_make_target_path() respectively to mount() instead of the + * mount_opts address. + * + * @see rtems_dosfs_create_default_converter() and + * rtems_dosfs_create_utf8_converter(). + */ + rtems_dosfs_convert_control *converter; +} rtems_dosfs_mount_options; + +/** + * @brief Allocates and initializes a default converter. + * + * This default converter will accept only POSIX file names with pure ASCII + * characters. This largely corresponds to the file name handling before the + * optional UTF-8 support was added to the RTEMS implementation of the FAT file + * system. This handling is mostly backwards compatible to the previous RTEMS + * implementation of the FAT file system. + * + * For backwards compatibility and the previous RTEMS implementation of the FAT + * file system please see also @ref rtems_dosfs_mount_options and mount(). + * + * @retval NULL Something failed. + * @retval other Pointer to initialized converter. + */ +rtems_dosfs_convert_control *rtems_dosfs_create_default_converter(void); + +/** + * @brief Allocates and initializes a UTF-8 converter. + * + * This converter will assume that all file names passed to POSIX file handling + * methods are UTF-8 strings and will convert them to the selected code page + * for short file names and to UTF-16 for long file names. This conversion + * will be done during reading and writing. These conversions correspond to + * the specification of the FAT file system. This handling is mostly backwards + * compatible to the previous RTEMS implementation of the FAT file system. + * + * For backwards compatibility and the previous RTEMS implementation of the FAT + * file system please see also @ref rtems_dosfs_mount_options and mount(). + * + * One possible issue with this converter is: When reading file names which + * have been created with other implementations of the FAT file system, it can + * happen that during the conversion to UTF-8 a long file name becomes longer + * and exceeds the 255 bytes limit. In such a case only the short file name + * will get read. + * + * @param[in] codepage The iconv() identification string for the used code + * page. + * + * @retval NULL Something failed. + * @retval other Pointer to initialized converter. + */ +rtems_dosfs_convert_control *rtems_dosfs_create_utf8_converter( + const char *codepage +); + +#define MSDOS_FMT_INFO_LEVEL_NONE (0) +#define MSDOS_FMT_INFO_LEVEL_INFO (1) +#define MSDOS_FMT_INFO_LEVEL_DETAIL (2) +#define MSDOS_FMT_INFO_LEVEL_DEBUG (3) + +/** + * @brief FAT file system format request parameters. + */ +typedef struct { + /** + * @brief OEM name string or NULL. + */ + const char *OEMName; + + /** + * @brief Volume label string or NULL. + */ + const char *VolLabel; + + /** + * @brief Sectors per cluster hint. + * + * The format procedure may choose another value. Use 0 as default value. + */ + uint32_t sectors_per_cluster; + + /** + * @brief Number of FATs hint. + * + * Use 0 as default value. + */ + uint32_t fat_num; + + /** + * @brief Minimum files in root directory for FAT12 and FAT16. + * + * The format procedure may choose a greater value. Use 0 as default value. + */ + uint32_t files_per_root_dir; + + /** + * @brief Media code. + * + * Use 0 as default value. The default media code is 0xf8. + */ + uint8_t media; + + /** + * @brief Quick format. + * + * If set to true, then do not clear data sectors to zero. + */ + bool quick_format; + + /** + * @brief Do not align FAT, data cluster, and root directory to a cluster + * boundary. + */ + bool skip_alignment; + + /** + * @brief Synchronize device after write operations. + */ + bool sync_device; + + /** + * @brief The amount of info to output. + */ + int info_level; +} msdos_format_request_param_t; + +/** + * @brief Formats a block device with a FAT file system. + * + * @param[in] devname The block device path. + * @param[in] rqdata The FAT file system format request data. Use NULL for + * default parameters. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The @c errno indicates the error. + */ +int msdos_format ( + const char *devname, + const msdos_format_request_param_t *rqdata +); + +/** @} */ + +int rtems_dosfs_initialize(rtems_filesystem_mount_table_entry_t *mt_entry, + const void *data); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/include/rtems/dumpbuf.h b/cpukit/include/rtems/dumpbuf.h new file mode 100644 index 0000000000..d714879ab4 --- /dev/null +++ b/cpukit/include/rtems/dumpbuf.h @@ -0,0 +1,52 @@ +/** + * @file + * + * @brief Print a Memory Buffer + * + * This file defines the interface to the RTEMS methods to print a + * memory buffer in a style similar to many ROM monitors and debuggers. + */ + +/* + * COPYRIGHT (c) 1997-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may in + * the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef __DUMP_BUFFER_h +#define __DUMP_BUFFER_h + +/** + * @defgroup libmisc_dumpbuf Print Memory Buffer + * + * @ingroup libmisc + */ +/**@{*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Print memory buffer. + * + * This method prints @a length bytes beginning at @a buffer in + * a nice format similar to what one would expect from a debugger + * or ROM monitor. + * + * @param[in] buffer is the address of the buffer + * @param[in] length is the length of the buffer + */ +void rtems_print_buffer( + const unsigned char *buffer, + int length +); + +#ifdef __cplusplus +} +#endif +/**@}*/ +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/error.h b/cpukit/include/rtems/error.h new file mode 100644 index 0000000000..617f59642b --- /dev/null +++ b/cpukit/include/rtems/error.h @@ -0,0 +1,135 @@ +/** + * @file rtems/error.h + * + * @brief RTEMS Error Reporting + * + * Defines and externs for rtems error reporting + * + * These routines provide general purpose error reporting. + * rtems_error reports an error to stderr and allows use of + * printf style formatting. A newline is appended to all messages. + * + * error_flag can be specified as any of the following: + * + * RTEMS_ERROR_ERRNO -- include errno text in output + * RTEMS_ERROR_PANIC -- halts local system after output + * RTEMS_ERROR_ABORT -- abort after output + * + * It can also include a rtems_status value which can be OR'd + * with the above flags. * + * + * Example 1: + * @code + * #include + * #include + * rtems_error(0, "stray interrupt %d", intr); + * @endcode + * + * Example 2: + * @code + * if ((status = rtems_task_create(...)) != RTEMS_SUCCCESSFUL) + * { + * rtems_error(status | RTEMS_ERROR_ABORT, + * "could not create task"); + * } + * @endcode + * + * Example 3: + * @code + * if ((fd = open(pathname, O_RDNLY)) < 0) + * { + * rtems_error(RTEMS_ERROR_ERRNO, "open of '%s' failed", pathname); + * goto failed; + * } + * @endcode + */ + +#ifndef _RTEMS_RTEMS_ERROR_H +#define _RTEMS_RTEMS_ERROR_H + +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ErrorPanicSupport Error And Panic Support + * + * @ingroup libcsupport + * + * @brief Defines and externs for rtems error reporting + * + */ +typedef Internal_errors_t rtems_error_code_t; + +/* + * rtems_error(), rtems_verror() and rtems_panic() support + */ + +#if 0 +/* not 16bit-int host clean */ +#define RTEMS_ERROR_ERRNO (1<<((sizeof(rtems_error_code_t) * CHAR_BIT) - 2)) /* hi bit; use 'errno' */ +#define RTEMS_ERROR_PANIC (RTEMS_ERROR_ERRNO / 2) /* err fatal; no return */ +#define RTEMS_ERROR_ABORT (RTEMS_ERROR_ERRNO / 4) /* err is fatal; panic */ +#else +#define RTEMS_ERROR_ERRNO (0x40000000) /* hi bit; use 'errno' */ +#define RTEMS_ERROR_PANIC (0x20000000) /* err fatal; no return */ +#define RTEMS_ERROR_ABORT (0x10000000) /* err is fatal; panic */ +#endif + +#define RTEMS_ERROR_MASK \ + (RTEMS_ERROR_ERRNO | RTEMS_ERROR_ABORT | RTEMS_ERROR_PANIC) /* all */ + +/** + * @brief Report an Error + * + * @param[in] error_code can be specified as any of the following: + * RTEMS_ERROR_ERRNO -- include errno text in output + * RTEMS_ERROR_PANIC -- halts local system after output + * RTEMS_ERROR_ABORT -- abort after output + * + * @param[in] printf_format is a normal printf(3) format string, + * with its concommitant arguments + * + * @return the number of characters written. + */ +int rtems_error( + rtems_error_code_t error_code, + const char *printf_format, + ... +); + +/** + * @brief Report an Error + * + * @param[in] error_code can be specified as any of the following: + * RTEMS_ERROR_ERRNO -- include errno text in output + * RTEMS_ERROR_PANIC -- halts local system after output + * RTEMS_ERROR_ABORT -- abort after output + * + * @param[in] printf_format is a normal printf(3) format string, + * with its concommitant arguments + * @param[in] arglist is a varargs list corresponding to + * printf_format + * + * @return the number of characters written. + */ +int rtems_verror( + rtems_error_code_t error_code, + const char *printf_format, + va_list arglist +); + +extern int rtems_panic_in_progress; + +#ifdef __cplusplus +} +#endif + + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/extension.h b/cpukit/include/rtems/extension.h new file mode 100644 index 0000000000..f22abf7f18 --- /dev/null +++ b/cpukit/include/rtems/extension.h @@ -0,0 +1,245 @@ +/** + * @file + * + * @brief User Extensions API. + */ + +/* + * COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_EXTENSION_H +#define _RTEMS_EXTENSION_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include + +typedef struct { + Objects_Control Object; + User_extensions_Control Extension; +} Extension_Control; + +typedef User_extensions_routine + rtems_extension RTEMS_DEPRECATED; + +/** + * @defgroup ClassicUserExtensions User Extensions + * + * @ingroup ClassicRTEMS + * + * @brief The User Extensions Manager allows the application developer to + * augment the executive by allowing them to supply extension routines which + * are invoked at critical system events. + * + * @section ClassicUserExtensionsSets Extension Sets + * + * An @ref User_extensions_Table "extension set" is defined as a set of + * routines which are invoked at each of the critical system events at which + * user extension routines are invoked. Together a set of these routines + * typically perform a specific functionality such as performance monitoring or + * debugger support. + * + * RTEMS allows the user to have multiple extension sets active at the same + * time. First, a single static extension set may be defined as the + * application's User Extension Table which is included as part of the + * Configuration Table. This extension set is active for the entire life of the + * system and may not be deleted. This extension set is especially important + * because it is the only way the application can provided a fatal error + * extension which is invoked if RTEMS fails during the + * rtems_initialize_data_structures() directive. The static extension set is + * optional and may be configured as @c NULL if no static extension set is + * required. + * + * Second, the user can install dynamic extensions using the + * rtems_extension_create() directive. These extensions are RTEMS objects in + * that they have a name, an ID, and can be dynamically created and deleted. In + * contrast to the static extension set, these extensions can only be created + * and installed after the rtems_initialize_data_structures() directive + * successfully completes execution. Dynamic extensions are useful for + * encapsulating the functionality of an extension set. For example, the + * application could use extensions to manage a special coprocessor, do + * performance monitoring, and to do stack bounds checking. Each of these + * extension sets could be written and installed independently of the others. + * + * All user extensions are optional and RTEMS places no naming restrictions on + * the user. The user extension entry points are copied into an internal RTEMS + * structure. This means the user does not need to keep the table after + * creating it, and changing the handler entry points dynamically in a table + * once created has no effect. Creating a table local to a function can save + * space in space limited applications. + * + * Extension switches do not effect the context switch overhead if no switch + * handler is installed. + * + * @section ClassicUserExtensionsTCB Task Control Block Area + * + * RTEMS provides for a pointer to a user-defined data area for each extension + * set to be linked to each task's control block (TCB). This area is only + * available for the dynamic extensions. This set of pointers is an extension + * of the TCB and can be used to store additional data required by the user's + * extension functions. + * + * The TCB extension is an array of pointers in the TCB. The index into the + * table can be obtained from the extension identifier returned when the + * extension is created: + * + * @code + * rtems_tcb *task = some_task; + * size_t index = rtems_object_id_get_index(extension_id); + * void *extension_data = task->extensions [index]; + * @endcode + * + * The number of pointers in the area is the same as the number of user + * extension sets configured. This allows an application to augment the TCB + * with user-defined information. For example, an application could implement + * task profiling by storing timing statistics in the TCB's extended memory + * area. When a task context switch is being executed, the task switch + * extension could read a real-time clock to calculate how long the task being + * swapped out has run as well as timestamp the starting time for the task + * being swapped in. + * + * If used, the extended memory area for the TCB should be allocated and the + * TCB extension pointer should be set at the time the task is created or + * started by either the task create or task start extension. The application + * is responsible for managing this extended memory area for the TCBs. The + * memory may be reinitialized by the task restart extension and should be + * deallocated by the task delete extension when the task is deleted. Since the + * TCB extension buffers would most likely be of a fixed size, the RTEMS + * partition manager could be used to manage the application's extended memory + * area. The application could create a partition of fixed size TCB extension + * buffers and use the partition manager's allocation and deallocation + * directives to obtain and release the extension buffers. + * + * @section ClassicUserExtensionsOrder Order of Invokation + * + * When one of the critical system events occur, the user extensions are + * invoked in either @a forward or @a reverse order. Forward order indicates + * that the static extension set is invoked followed by the dynamic extension + * sets in the order in which they were created. Reverse order means that the + * dynamic extension sets are invoked in the opposite of the order in which + * they were created followed by the static extension set. By invoking the + * extension sets in this order, extensions can be built upon one another. At + * the following system events, the extensions are invoked in forward order: + * + * - Task creation + * - Task start + * - Task restart + * - Task context switch + * - Post task context switch + * - Task begins to execute + * + * At the following system events, the extensions are invoked in reverse order: + * + * - Task exit + * - Task deletion + * - Fatal error detection + * + * At these system events, the extensions are invoked in reverse order to + * insure that if an extension set is built upon another, the more complicated + * extension is invoked before the extension set it is built upon. For example, + * by invoking the static extension set last it is known that the "system" + * fatal error extension will be the last fatal error extension executed. + * Another example is use of the task delete extension by the Standard C + * Library. Extension sets which are installed after the Standard C Library + * will operate correctly even if they utilize the C Library because the C + * Library's task delete extension is invoked after that of the other + * extensions. + */ +/**@{**/ + +typedef User_extensions_thread_create_extension rtems_task_create_extension; +typedef User_extensions_thread_delete_extension rtems_task_delete_extension; +typedef User_extensions_thread_start_extension rtems_task_start_extension; +typedef User_extensions_thread_restart_extension rtems_task_restart_extension; +typedef User_extensions_thread_switch_extension rtems_task_switch_extension; +typedef User_extensions_thread_begin_extension rtems_task_begin_extension; +typedef User_extensions_thread_exitted_extension rtems_task_exitted_extension; +typedef User_extensions_fatal_extension rtems_fatal_extension; +typedef User_extensions_thread_terminate_extension rtems_task_terminate_extension; + +typedef User_extensions_Table rtems_extensions_table; + +typedef Internal_errors_Source rtems_fatal_source; + +typedef Internal_errors_t rtems_fatal_code; + +/** + * @brief Creates an extension set object. + * + * This directive creates a extension set object from the extension table + * @a extension_table. The assigned extension set identifier is returned in + * @a id. The identifier is used to access this extension set in other + * extension set related directives. The name @a name will be assigned to the + * extension set object. + * + * Newly created extension sets are immediately installed and are invoked upon + * the next system event supporting an extension. + * + * This directive will not cause the calling task to be preempted. + * + * @retval RTEMS_SUCCESSFUL Extension set created successfully. + * @retval RTEMS_INVALID_ADDRESS Identifier pointer is @c NULL. + * @retval RTEMS_INVALID_NAME Invalid extension set name. + * @retval RTEMS_TOO_MANY Too many extension sets created. + */ +rtems_status_code rtems_extension_create( + rtems_name name, + const rtems_extensions_table *extension_table, + rtems_id *id +); + +/** + * @brief Identifies an extension set object by a name. + * + * This directive obtains an extension set identifier in @a id associated with + * the extension set name @a name. If the extension set name is not unique, + * then the extension set identifier will match one of the extension sets with + * that name. However, this extension set identifier is not guaranteed to + * correspond to the desired extension set. The extension set identifier is + * used to access this extension set in other extension set related directives. + * + * This directive will not cause the calling task to be preempted. + * + * @retval RTEMS_SUCCESSFUL Extension set identified successfully. + * @retval RTEMS_INVALID_ADDRESS Identifier pointer is @c NULL. + * @retval RTEMS_INVALID_NAME Extension set name not found or invalid name. + */ +rtems_status_code rtems_extension_ident( + rtems_name name, + rtems_id *id +); + +/** + * @brief Deletes an extension set object specified by the identifier @a id. + * + * Any subsequent references to the extension's name and identifier are + * invalid. + * + * This directive will not cause the calling task to be preempted. + * + * @retval RTEMS_SUCCESSFUL Extension set deleted successfully. + * @retval RTEMS_INVALID_ID Invalid extension set identifier. + */ +rtems_status_code rtems_extension_delete( + rtems_id id +); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/extensionimpl.h b/cpukit/include/rtems/extensionimpl.h new file mode 100644 index 0000000000..fb4eeaff7c --- /dev/null +++ b/cpukit/include/rtems/extensionimpl.h @@ -0,0 +1,53 @@ +/** + * @file + * + * @ingroup ClassicUserExtensions + * + * @brief User Extensions API + */ + +/* + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_EXTENSIONIMPL_H +#define _RTEMS_EXTENSIONIMPL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern Objects_Information _Extension_Information; + +RTEMS_INLINE_ROUTINE Extension_Control *_Extension_Allocate( void ) +{ + return (Extension_Control *) _Objects_Allocate( &_Extension_Information ); +} + +RTEMS_INLINE_ROUTINE void _Extension_Free ( + Extension_Control *the_extension +) +{ + _Objects_Free( &_Extension_Information, &the_extension->Object ); +} + +RTEMS_INLINE_ROUTINE Extension_Control *_Extension_Get( Objects_Id id ) +{ + return (Extension_Control *) + _Objects_Get_no_protection( id, &_Extension_Information ); +} + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/fatal.h b/cpukit/include/rtems/fatal.h new file mode 100644 index 0000000000..291af42c6e --- /dev/null +++ b/cpukit/include/rtems/fatal.h @@ -0,0 +1,134 @@ +/** + * @file + * + * @brief Fatal API. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_FATAL_H +#define _RTEMS_FATAL_H + +#include /* RTEMS_NO_RETURN */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicFatal Fatal + * + * @ingroup ClassicRTEMS + * + * @brief The Fatal Manager provides functions for fatal system states and or + * irrecoverable errors. + */ +/**@{**/ + +/** + * @brief Assert context. + */ +typedef struct { + const char *file; + int line; + const char *function; + const char *failed_expression; +} rtems_assert_context; + +/** + * @brief Exception frame. + */ +typedef CPU_Exception_frame rtems_exception_frame; + +/** + * @brief Prints the exception frame via printk(). + * + * @see rtems_fatal() and RTEMS_FATAL_SOURCE_EXCEPTION. + */ +static inline void rtems_exception_frame_print( + const rtems_exception_frame *frame +) +{ + _CPU_Exception_frame_print( frame ); +} + +/** + * @brief Invokes the internal error handler with a source of + * INTERNAL_ERROR_RTEMS_API and is internal set to false. + * + * @param[in] the_error is a 32-bit fatal error code. + * + * @see _Terminate(). + */ +void rtems_fatal_error_occurred( + uint32_t the_error +) RTEMS_NO_RETURN; + +/** + * @brief Terminates the system. + * + * @param[in] fatal_source The fatal source. + * @param[in] error_code The error code. + * + * @see _Terminate(). + */ +RTEMS_NO_RETURN RTEMS_INLINE_ROUTINE void rtems_fatal( + rtems_fatal_source fatal_source, + rtems_fatal_code error_code +) +{ + _Terminate( fatal_source, error_code ); +} + +/** + * @brief Prints the specified message via printk() and terminates the system. + * + * @param[in] fmt The message format. + * @param[in] ... The message parameters. + * + * @see _Terminate(). + */ +RTEMS_NO_RETURN void rtems_panic( + const char *fmt, ... +) RTEMS_PRINTFLIKE( 1, 2 ); + +/** + * @brief Returns a text for a fatal source. + * + * The text for each fatal source is the enumerator constant. + * + * @param[in] source is the fatal source. + * + * @retval text The fatal source text. + * @retval "?" The passed fatal source is invalid. + */ +const char *rtems_fatal_source_text( rtems_fatal_source source ); + +/** + * @brief Returns a text for an internal error code. + * + * The text for each internal error code is the enumerator constant. + * + * @param[in] error is the error code. + * + * @retval text The error code text. + * @retval "?" The passed error code is invalid. + */ +const char *rtems_internal_error_text( rtems_fatal_code error ); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/fb.h b/cpukit/include/rtems/fb.h new file mode 100644 index 0000000000..bb5cb23805 --- /dev/null +++ b/cpukit/include/rtems/fb.h @@ -0,0 +1,101 @@ +/** + * @file rtems/fb.h + * + * @brief Frame Buffer Device Driver + * + * This file defines the interface to a frame buffer device driver. + */ + +/* + * Copyright (c) 2000 - Rosimildo da Silva + */ + +#ifndef _MW_FB_H +#define _MW_FB_H + +#include + +/** + * @defgroup libmisc_fb Frame Buffer Device Driver Interface + * + * @ingroup Device Drivers and Frameworks + */ +/**@{*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/* ioctls + 0x46 is 'F' */ +#define FBIOGET_VSCREENINFO 0x4600 +#define FBIOPUT_VSCREENINFO 0x4601 +#define FBIOGET_FSCREENINFO 0x4602 +#define FBIOGETCMAP 0x4604 +#define FBIOPUTCMAP 0x4605 +#define FB_EXEC_FUNCTION 0x4606 +#define FBIOSWAPBUFFERS 0x4607 +#define FBIOSETBUFFERMODE 0x4608 +#define FBIOSETVIDEOMODE 0x4609 + +#define FB_SINGLE_BUFFERED 0 +#define FB_TRIPLE_BUFFERED 1 + +#define FB_TYPE_PACKED_PIXELS 0 /* Packed Pixels */ +#define FB_TYPE_PLANES 1 /* Non interleaved planes */ +#define FB_TYPE_INTERLEAVED_PLANES 2 /* Interleaved planes */ +#define FB_TYPE_TEXT 3 /* Text/attributes */ +#define FB_TYPE_VGA_PLANES 4 /* EGA/VGA planes */ +#define FB_TYPE_VIRTUAL_BUFFER 5 /* Virtual Buffer */ + + +#define FB_VISUAL_MONO01 0 /* Monochr. 1=Black 0=White */ +#define FB_VISUAL_MONO10 1 /* Monochr. 1=White 0=Black */ +#define FB_VISUAL_TRUECOLOR 2 /* True color */ +#define FB_VISUAL_PSEUDOCOLOR 3 /* Pseudo color (like atari) */ +#define FB_VISUAL_DIRECTCOLOR 4 /* Direct color */ +#define FB_VISUAL_STATIC_PSEUDOCOLOR 5 /* Pseudo color readonly */ + +#define FB_ACCEL_NONE 0 /* no hardware accelerator */ + +struct fb_bitfield { + uint32_t offset; /* beginning of bitfield */ + uint32_t length; /* length of bitfield */ + uint32_t msb_right; /* != 0 : Most significant bit is */ + /* right */ +}; + +struct fb_var_screeninfo { + uint32_t xres; /* visible resolution */ + uint32_t yres; + uint32_t bits_per_pixel; /* guess what */ + struct fb_bitfield red; /* bitfield in fb mem if true color, */ + struct fb_bitfield green; /* else only length is significant */ + struct fb_bitfield blue; + struct fb_bitfield transp; /* transparency */ +}; + +struct fb_fix_screeninfo { + volatile char *smem_start; /* Start of frame buffer mem */ + /* (physical address) */ + uint32_t smem_len; /* Length of frame buffer mem */ + uint32_t type; /* see FB_TYPE_* */ + uint32_t visual; /* see FB_VISUAL_* */ + uint32_t line_length; /* number of chars per line */ +}; + +struct fb_cmap { + uint32_t start; /* First entry */ + uint32_t len; /* Number of entries */ + uint16_t *red; /* Red values */ + uint16_t *green; + uint16_t *blue; + uint16_t *transp; /* transparency, can be NULL */ +}; + +#ifdef __cplusplus +} +#endif +/**@}*/ + +#endif /* _MW_FB_H */ diff --git a/cpukit/include/rtems/flashdisk.h b/cpukit/include/rtems/flashdisk.h new file mode 100644 index 0000000000..ec353096ad --- /dev/null +++ b/cpukit/include/rtems/flashdisk.h @@ -0,0 +1,460 @@ +/** + * @file + * + * @ingroup RTEMSFDisk + * + * @brief Interface to a Flash Disk Block Device + * + * This file defines the interface to a flash disk block device. + */ + +/* + * Copyright (C) 2007 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#if !defined (_RTEMS_FLASHDISK_H_) +#define _RTEMS_FLASHDISK_H_ + +#include +#include + +#include + +/** + * @defgroup RTEMSFDisk Flash Disk Device + * + * @ingroup rtems_blkdev + * + * Flash disk driver for RTEMS provides support for block based + * file systems on flash devices. The driver is not a flash file + * system nor does it try to compete with flash file systems. It + * currently does not journal how-ever block sequence numbering + * could be added to allow recovery of a past positions if + * a power down occurred while being updated. + * + * This flash driver provides block device support for most flash + * devices. The driver has been tested on NOR type devices such + * as the AMLV160 or M28W160. Support for NAND type devices may + * require driver changes to allow speedy recover of the block + * mapping data and to also handle the current use of word programming. + * Currently the page descriptors are stored in the first few pages + * of each segment. + * + * The driver supports devices, segments and pages. You provide + * to the driver the device descriptions as a table of device + * descriptors. Each device descriptor contain a table of + * segment descriptions or segment descriptors. The driver uses + * this information to manage the devices. + * + * A device is made up of segments. These are also called + * sectors or blocks. It is the smallest erasable part of a device. + * A device can have differing size segments at different + * offsets in the device. The segment descriptors support repeating + * segments that are continuous in the device. The driver breaks the + * segments up into pages. The first pages of a segment contain + * the page descriptors. A page descriptor hold the page flags, + * a CRC for the page of data and the block number the page + * holds. The block can appear in any order in the devices. A + * page is active if it hold a current block of data. If the + * used bit is set the page is counted as used. A page moves + * from erased to active to used then back to erased. If a block + * is written that is already in a page, the block is written to + * a new page the old page is flagged as used. + * + * At initialization time each segment's page descriptors are + * read into memory and scanned to determine the active pages, + * the used pages and the bad pages. If a segment has any erased + * pages it is queue on the available queue. If the segment has + * no erased pages it is queue on the used queue. + * + * The available queue is sorted from the least number available + * to the most number of available pages. A segment that has just + * been erased will placed at the end of the queue. A segment that + * has only a few available pages will be used sooner and once + * there are no available pages it is queued on the used queue. + * The used queue hold segments that have no available pages and + * is sorted from the least number of active pages to the most + * number of active pages. + * + * The driver is required to compact segments. Compacting takes + * the segment with the most number of available pages from the + * available queue then takes segments with the least number of + * active pages from the used queue until it has enough pages + * to fill the empty segment. As the active pages are moved + * they flagged as used and once the segment has only used pages + * it is erased. + * + * A flash block driver like this never knows if a page is not + * being used by the file-system. A typical file system is not + * design with the idea of erasing a block on a disk once it is + * not being used. The file-system will normally use a flag + * or a location as a marker to say that part of the disk is + * no longer in use. This means a number of blocks could be + * held in active pages but are no in use by the file system. + * The file system may also read blocks that have never been + * written to disk. This complicates the driver and may make + * the wear, usage and erase patterns harsher than a flash + * file system. The driver may also suffer from problems if + * power is lost. + * + * There are some flash disk specific IO control request types. + * To use open the device and issue the ioctl() call. + * + * @code + * int fd = open ("/dev/flashdisk0", O_WRONLY, 0); + * if (fd < 0) + * { + * printf ("driver open failed: %s\n", strerror (errno)); + * exit (1); + * } + * if (ioctl (fd, RTEMS_FDISK_IOCTL_ERASE_DISK) < 0) + * { + * printf ("driver erase failed: %s\n", strerror (errno)); + * exit (1); + * } + * close (fd); + * @endcode + */ +/**@{**/ + +/** + * @brief The base name of the flash disks. + */ +#define RTEMS_FLASHDISK_DEVICE_BASE_NAME "/dev/fdd" + +#define RTEMS_FDISK_IOCTL_ERASE_DISK _IO('B', 128) +#define RTEMS_FDISK_IOCTL_COMPACT _IO('B', 129) +#define RTEMS_FDISK_IOCTL_ERASE_USED _IO('B', 130) +#define RTEMS_FDISK_IOCTL_MONITORING _IO('B', 131) +#define RTEMS_FDISK_IOCTL_INFO_LEVEL _IO('B', 132) +#define RTEMS_FDISK_IOCTL_PRINT_STATUS _IO('B', 133) + +/** + * @brief Flash Disk Monitoring Data allows a user to obtain + * the current status of the disk. + */ +typedef struct rtems_fdisk_monitor_data +{ + uint32_t block_size; + uint32_t block_count; + uint32_t unavail_blocks; + uint32_t device_count; + uint32_t segment_count; + uint32_t page_count; + uint32_t blocks_used; + uint32_t segs_available; + uint32_t segs_used; + uint32_t segs_failed; + uint32_t seg_erases; + uint32_t pages_desc; + uint32_t pages_active; + uint32_t pages_used; + uint32_t pages_bad; + uint32_t info_level; +} rtems_fdisk_monitor_data; + +/** + * @brief Flash Segment Descriptor holds, number of continuous segments in the + * device of this type, the base segment number in the device, the address + * offset of the base segment in the device, and the size of segment. + * + * Typically this structure is part of a table of segments in the + * device which is referenced in the flash disk configuration table. + * The reference is kept in the driver and used all the time to + * manage the flash device, therefore it must always exist. + */ +typedef struct rtems_fdisk_segment_desc +{ + uint16_t count; /**< Number of segments of this type in a row. */ + uint16_t segment; /**< The base segment number. */ + uint32_t offset; /**< Address offset of base segment in device. */ + uint32_t size; /**< Size of the segment in bytes. */ +} rtems_fdisk_segment_desc; + +/** + * @brief Return the number of kilo-bytes. + */ +#define RTEMS_FDISK_KBYTES(_k) (UINT32_C(1024) * (_k)) + +/** + * Forward declaration of the device descriptor. + */ +struct rtems_fdisk_device_desc; + +/** + * @brief Flash Low Level driver handlers. + * + * Typically this structure is part of a table of handlers in the + * device which is referenced in the flash disk configuration table. + * The reference is kept in the driver and used all the time to + * manage the flash device, therefore it must always exist. + */ +typedef struct rtems_fdisk_driver_handlers +{ + /** + * Read data from the device into the buffer. Return an errno + * error number if the device cannot be read. A segment descriptor + * can describe more than one segment in a device if the device has + * repeating segments. The segment number is the device segment to + * access and the segment descriptor must reference the segment + * being requested. For example the segment number must resided in + * the range [base, base + count). + * + * @param sd The segment descriptor. + * @param device The device to read data from. + * @param segment The segment within the device to read. + * @param offset The offset in the segment to read. + * @param buffer The buffer to read the data into. + * @param size The amount of data to read. + * @retval 0 No error. + * @retval EIO The read did not complete. + */ + int (*read) (const rtems_fdisk_segment_desc* sd, + uint32_t device, + uint32_t segment, + uint32_t offset, + void* buffer, + uint32_t size); + + /** + * Write data from the buffer to the device. Return an errno + * error number if the device cannot be written to. A segment + * descriptor can describe more than segment in a device if the + * device has repeating segments. The segment number is the device + * segment to access and the segment descriptor must reference + * the segment being requested. For example the segment number must + * resided in the range [base, base + count). + * + * @param sd The segment descriptor. + * @param device The device to write data from. + * @param segment The segment within the device to write to. + * @param offset The offset in the segment to write. + * @param buffer The buffer to write the data from. + * @param size The amount of data to write. + * @retval 0 No error. + * @retval EIO The write did not complete or verify. + */ + int (*write) (const rtems_fdisk_segment_desc* sd, + uint32_t device, + uint32_t segment, + uint32_t offset, + const void* buffer, + uint32_t size); + + /** + * Blank a segment in the device. Return an errno error number + * if the device cannot be read or is not blank. A segment descriptor + * can describe more than segment in a device if the device has + * repeating segments. The segment number is the device segment to + * access and the segment descriptor must reference the segment + * being requested. For example the segment number must resided in + * the range [base, base + count). + * + * @param sd The segment descriptor. + * @param device The device to read data from. + * @param segment The segment within the device to read. + * @param offset The offset in the segment to checl. + * @param size The amount of data to check. + * @retval 0 No error. + * @retval EIO The segment is not blank. + */ + int (*blank) (const rtems_fdisk_segment_desc* sd, + uint32_t device, + uint32_t segment, + uint32_t offset, + uint32_t size); + + /** + * Verify data in the buffer to the data in the device. Return an + * errno error number if the device cannot be read. A segment + * descriptor can describe more than segment in a device if the + * device has repeating segments. The segment number is the + * segment to access and the segment descriptor must reference + * the device segment being requested. For example the segment number + * must resided in the range [base, base + count). + * + * @param sd The segment descriptor. + * @param device The device to verify data in. + * @param segment The segment within the device to verify. + * @param offset The offset in the segment to verify. + * @param buffer The buffer to verify the data in the device with. + * @param size The amount of data to verify. + * @retval 0 No error. + * @retval EIO The data did not verify. + */ + int (*verify) (const rtems_fdisk_segment_desc* sd, + uint32_t device, + uint32_t segment, + uint32_t offset, + const void* buffer, + uint32_t size); + + /** + * Erase the segment. Return an errno error number if the + * segment cannot be erased. A segment descriptor can describe + * more than segment in a device if the device has repeating + * segments. The segment number is the device segment to access and + * the segment descriptor must reference the segment being requested. + * + * @param sd The segment descriptor. + * @param device The device to erase the segment of. + * @param segment The segment within the device to erase. + * @retval 0 No error. + * @retval EIO The segment was not erased. + */ + int (*erase) (const rtems_fdisk_segment_desc* sd, + uint32_t device, + uint32_t segment); + + /** + * Erase the device. Return an errno error number if the + * segment cannot be erased. A segment descriptor can describe + * more than segment in a device if the device has repeating + * segments. The segment number is the segment to access and + * the segment descriptor must reference the segment being requested. + * + * @param sd The segment descriptor. + * @param device The device to erase. + * @retval 0 No error. + * @retval EIO The device was not erased. + */ + int (*erase_device) (const struct rtems_fdisk_device_desc* dd, + uint32_t device); + +} rtems_fdisk_driver_handlers; + +/** + * @brief Flash Device Descriptor holds the segments in a device. + * + * The placing of the segments in a device decriptor allows the low level + * driver to share the segment descriptors for a number of devices. + * + * Typically this structure is part of a table of segments in the + * device which is referenced in the flash disk configuration table. + * The reference is kept in the driver and used all the time to + * manage the flash device, therefore it must always exist. + */ +typedef struct rtems_fdisk_device_desc +{ + uint32_t segment_count; /**< Number of segments. */ + const rtems_fdisk_segment_desc* segments; /**< Array of segments. */ + const rtems_fdisk_driver_handlers* flash_ops; /**< Device handlers. */ +} rtems_fdisk_device_desc; + +/** + * @brief RTEMS Flash Disk configuration table used to initialise the + * driver. + * + * The unavailable blocks count is the number of blocks less than the + * available number of blocks the file system is given. This means there + * will always be that number of blocks available when the file system + * thinks the disk is full. The compaction code needs blocks to compact + * with so you will never be able to have all the blocks allocated to the + * file system and be able to full the disk. + * + * The compacting segment count is the number of segments that are + * moved into a new segment. A high number will mean more segments with + * low active page counts and high used page counts will be moved into + * avaliable pages how-ever this extends the compaction time due to + * time it takes the erase the pages. There is no pont making this number + * greater than the maximum number of pages in a segment. + * + * The available compacting segment count is the level when compaction occurs + * when writing. If you set this to 0 then compaction will fail because + * there will be no segments to compact into. + * + * The info level can be 0 for off with error, and abort messages allowed. + * Level 1 is warning messages, level 1 is informational messages, and level 3 + * is debugging type prints. The info level can be turned off with a compile + * time directive on the command line to the compiler of: + * + * -DRTEMS_FDISK_TRACE=0 + */ +typedef struct rtems_flashdisk_config +{ + uint32_t block_size; /**< The block size. */ + uint32_t device_count; /**< The number of devices. */ + const rtems_fdisk_device_desc* devices; /**< The device descriptions. */ + uint32_t flags; /**< Set of flags to control + driver. */ + /** + * Number of blocks not available to the file system. This number must be + * greater than or equal to the number of blocks in the largest segment to + * avoid starvation of erased blocks. + */ + uint32_t unavail_blocks; + + uint32_t compact_segs; /**< Max number of segs to + compact in one pass. */ + /** + * The number of segments when compaction occurs when writing. In case the + * number of segments in the available queue is less than or equal to this + * number the compaction process will be triggered. The available queue + * contains all segments with erased blocks. + */ + uint32_t avail_compact_segs; + uint32_t info_level; /**< Default info level. */ +} rtems_flashdisk_config; + +/* + * Driver flags. + */ + +/** + * Leave the erasing of used segment to the background handler. + */ +#define RTEMS_FDISK_BACKGROUND_ERASE (1 << 0) + +/** + * Leave the compacting of of used segment to the background handler. + */ +#define RTEMS_FDISK_BACKGROUND_COMPACT (1 << 1) + +/** + * Check the pages during initialisation to see which pages are + * valid and which are not. This could slow down initialising the + * disk driver. + */ +#define RTEMS_FDISK_CHECK_PAGES (1 << 2) + +/** + * Blank check the flash device before writing to them. This is needed if + * you think you have a driver or device problem. + */ +#define RTEMS_FDISK_BLANK_CHECK_BEFORE_WRITE (1 << 3) + +/** + * Flash disk device driver initialization. Place in a table as the + * initialisation entry and remainder of the entries are the + * RTEMS block device generic handlers. + * + * @param major Flash disk major device number. + * @param minor Minor device number, not applicable. + * @param arg Initialization argument, not applicable. + * @return The rtems_device_driver is actually just + * rtems_status_code. + */ +rtems_device_driver +rtems_fdisk_initialize (rtems_device_major_number major, + rtems_device_minor_number minor, + void* arg); + +/** + * @brief External reference to the configuration. Please supply. + * Support is present in confdefs.h for providing this variable. + */ +extern const rtems_flashdisk_config rtems_flashdisk_configuration[]; + +/** + * @brief External reference to the number of configurations. Please supply. + * Support is present in confdefs.h for providing this variable. + */ +extern uint32_t rtems_flashdisk_configuration_size; + +/** @} */ + +#endif diff --git a/cpukit/include/rtems/fsmount.h b/cpukit/include/rtems/fsmount.h new file mode 100644 index 0000000000..441b0d68ef --- /dev/null +++ b/cpukit/include/rtems/fsmount.h @@ -0,0 +1,211 @@ +/** + * @file rtems/fsmount.h + * + * @defgroup rtems_fstab File System Mount Support + * + * @ingroup FileSystemTypesAndMount + * @brief File System Mount Functions + * + * This file contains the fsmount functions. These functions + * are used to mount a list of filesystems (and create their mount + * points before). + */ + +/* + * Copyright (c) 2003 IMD + * + * Ingenieurbuero fuer Microcomputertechnik Th. Doerfler + * + * all rights reserved + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _FSMOUNT_H +#define _FSMOUNT_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup rtems_fstab File System Mount Support + * + * @ingroup FileSystemTypesAndMount + */ +/**@{**/ + +/** + * File system mount report and abort condition flags. + * + * The flags define, which conditions will cause a report during the mount + * process (via printf()) or abort the mount process. + * + * @see rtems_fstab_entry and rtems_fsmount(). + */ +typedef enum { + /** + * No conditions. + */ + RTEMS_FSTAB_NONE = 0U, + + /** + * Complete mount process was successful. + */ + RTEMS_FSTAB_OK = 0x1U, + + /** + * Mount point creation failed. + */ + RTEMS_FSTAB_ERROR_MOUNT_POINT = 0x2U, + + /** + * File system mount failed. + */ + RTEMS_FSTAB_ERROR_MOUNT = 0x4U, + + /** + * Something failed. + */ + RTEMS_FSTAB_ERROR = RTEMS_FSTAB_ERROR_MOUNT_POINT | RTEMS_FSTAB_ERROR_MOUNT, + + /** + * Any condition. + */ + RTEMS_FSTAB_ANY = RTEMS_FSTAB_OK | RTEMS_FSTAB_ERROR +} rtems_fstab_conditions; + +/** + * File system table entry. + */ +typedef struct { + /** + * Source for the mount. + */ + const char *source; + + /** + * Target for the mount. + */ + const char *target; + + /** + * File system operations. + */ + const char *type; + + /** + * File system mount options. + */ + rtems_filesystem_options_t options; + + /** + * Report @ref rtems_fstab_conditions "condition flags". + */ + uint16_t report_reasons; + + /** + * Abort @ref rtems_fstab_conditions "condition flags". + */ + uint16_t abort_reasons; +} rtems_fstab_entry; + +/** + * @brief Mounts the file systems listed in the file system mount table. + * + * Mounts the file systems listed in the file system mount table @a fstab of + * size @a size. + * + * Each file system will be mounted according to its table entry parameters. + * In case of an abort condition the corresponding table index will be reported + * in @a abort_index. The pointer @a abort_index may be @c NULL. The mount + * point paths will be created with rtems_mkdir() and need not exist + * beforehand. + * + * On success, zero is returned. On error, -1 is returned, and @c errno is set + * appropriately. + * + * @see rtems_bdpart_register_from_disk(). + * + * The following example code tries to mount a FAT file system within a SD + * Card. Some cards do not have a partition table so at first it tries to find + * a file system inside the hole disk. If this is successful the mount process + * will be aborted because the @ref RTEMS_FSTAB_OK condition is true. If this + * did not work it tries to mount the file system inside the first partition. + * If this fails the mount process will not be aborted (this is already the + * last entry), but the last error status will be returned. + * + * @code + * #include + * #include + * #include + * + * #include + * #include + * #include + * #include + * + * static const rtems_fstab_entry fstab [] = { + * { + * .source = "/dev/sd-card-a", + * .target = "/mnt", + * .type = "dosfs", + * .options = RTEMS_FILESYSTEM_READ_WRITE, + * .report_reasons = RTEMS_FSTAB_ANY, + * .abort_reasons = RTEMS_FSTAB_OK + * }, { + * .source = "/dev/sd-card-a1", + * .target = "/mnt", + * .type = "dosfs", + * .options = RTEMS_FILESYSTEM_READ_WRITE, + * .report_reasons = RTEMS_FSTAB_ANY, + * .abort_reasons = RTEMS_FSTAB_NONE + * } + * }; + * + * static void my_mount(void) + * { + * rtems_status_code sc = RTEMS_SUCCESSFUL; + * int rv = 0; + * size_t abort_index = 0; + * + * sc = rtems_bdpart_register_from_disk("/dev/sd-card-a"); + * if (sc != RTEMS_SUCCESSFUL) { + * printf("read partition table failed: %s\n", rtems_status_text(sc)); + * } + * + * rv = rtems_fsmount(fstab, sizeof(fstab) / sizeof(fstab [0]), &abort_index); + * if (rv != 0) { + * printf("mount failed: %s\n", strerror(errno)); + * } + * printf("mount aborted at %zu\n", abort_index); + * } + * @endcode + */ +int rtems_fsmount( + const rtems_fstab_entry *fstab, + size_t size, + size_t *abort_index +); + +/** @} */ + +typedef rtems_fstab_entry fstab_t; + +#define FSMOUNT_MNT_OK RTEMS_FSTAB_OK + +#define FSMOUNT_MNTPNT_CRTERR RTEMS_FSTAB_ERROR_MOUNT_POINT + +#define FSMOUNT_MNT_FAILED RTEMS_FSTAB_ERROR_MOUNT + +#ifdef __cplusplus +} +#endif + +#endif /* _FSMOUNT_H */ diff --git a/cpukit/include/rtems/ftpd.h b/cpukit/include/rtems/ftpd.h new file mode 100644 index 0000000000..f33ca59d3a --- /dev/null +++ b/cpukit/include/rtems/ftpd.h @@ -0,0 +1,74 @@ +/* + * FTP Server Information + */ + +#ifndef _RTEMS_FTPD_H +#define _RTEMS_FTPD_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define FTPD_CONTROL_PORT 21 + +/* Various buffer sizes */ +enum { + FTPD_BUFSIZE = 256, /* Size for temporary buffers */ + FTPD_DATASIZE = 4 * 1024, /* Size for file transfer buffers */ + FTPD_STACKSIZE = RTEMS_MINIMUM_STACK_SIZE + FTPD_DATASIZE /* Tasks stack size */ +}; + +/* FTPD access control flags */ +enum +{ + FTPD_NO_WRITE = 0x1, + FTPD_NO_READ = 0x2, + FTPD_NO_RW = FTPD_NO_WRITE | FTPD_NO_READ +}; + +typedef int (*rtems_ftpd_hookfunction)(char *, size_t); + +#include + +struct rtems_ftpd_hook +{ + char *filename; + rtems_ftpd_hookfunction hook_function; +}; + +struct rtems_ftpd_configuration +{ + rtems_task_priority priority; /* FTPD task priority */ + unsigned long max_hook_filesize; /* Maximum buffersize */ + /* for hooks */ + int port; /* Well-known port */ + struct rtems_ftpd_hook *hooks; /* List of hooks */ + char const *root; /* Root for FTPD or 0 for / */ + int tasks_count; /* Max. connections */ + int idle; /* Idle timeout in seoconds + or 0 for no (inf) timeout */ + int access; /* 0 - r/w, 1 - read-only, + 2 - write-only, + 3 - browse-only */ + rtems_shell_login_check_t login; /* Login check or 0 to ignore + user/passwd. */ +}; + +/* + * Reply codes. + */ +#define PRELIM 1 /* positive preliminary */ +#define COMPLETE 2 /* positive completion */ +#define CONTINUE 3 /* positive intermediate */ +#define TRANSIENT 4 /* transient negative completion */ +#define ERROR 5 /* permanent negative completion */ + +int rtems_initialize_ftpd(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_FTPD_H */ diff --git a/cpukit/include/rtems/gxx_wrappers.h b/cpukit/include/rtems/gxx_wrappers.h new file mode 100644 index 0000000000..94502b937f --- /dev/null +++ b/cpukit/include/rtems/gxx_wrappers.h @@ -0,0 +1,80 @@ +/** + * @file rtems/gxx_wrappers.h + * + * RTEMS threads compatibility routines for libgcc2. + */ + +/* + * by: Rosimildo da Silva (rdasilva@connecttel.com) + * + * Used ideas from: + * W. Eric Norum + * Canadian Light Source + * University of Saskatchewan + * Saskatoon, Saskatchewan, CANADA + * eric@cls.usask.ca + * + * Eric sent some e-mail in the rtems-list as a start point for this + * module implementation. + */ + +#ifndef __GCC_WRAPPERS_h +#define __GCC_WRAPPERS_h + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup GxxWrappersSupport Gxx Wrappers Support + * + * @ingroup libcsupport + * + * @brief RTEMS Threads Compatibility Routines for Libgcc2 + */ + +/* + * These typedefs should match with the ones defined in the file + * gcc/gthr-rtems.h in the gcc distribution. + */ +typedef void *__gthread_key_t; +typedef int __gthread_once_t; +typedef void *__gthread_mutex_t; +typedef void *__gthread_recursive_mutex_t; + +int rtems_gxx_once(__gthread_once_t *once, void (*func) (void)); + +int rtems_gxx_key_create (__gthread_key_t *key, void (*dtor) (void *)); + +int rtems_gxx_key_delete (__gthread_key_t key); + +void *rtems_gxx_getspecific(__gthread_key_t key); + +int rtems_gxx_setspecific(__gthread_key_t key, const void *ptr); + +/* + * MUTEX support + */ +void rtems_gxx_mutex_init (__gthread_mutex_t *mutex); + +int rtems_gxx_mutex_lock (__gthread_mutex_t *mutex); + +int rtems_gxx_mutex_destroy (__gthread_mutex_t *mutex); + +int rtems_gxx_mutex_trylock (__gthread_mutex_t *mutex); + +int rtems_gxx_mutex_unlock (__gthread_mutex_t *mutex); + +void rtems_gxx_recursive_mutex_init(__gthread_recursive_mutex_t *mutex); + +int rtems_gxx_recursive_mutex_lock(__gthread_recursive_mutex_t *mutex); + +int rtems_gxx_recursive_mutex_trylock(__gthread_recursive_mutex_t *mutex); + +int rtems_gxx_recursive_mutex_unlock(__gthread_recursive_mutex_t *mutex); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __GCC_WRAPPERS_h */ diff --git a/cpukit/include/rtems/ide_part_table.h b/cpukit/include/rtems/ide_part_table.h new file mode 100644 index 0000000000..8b683b3ff5 --- /dev/null +++ b/cpukit/include/rtems/ide_part_table.h @@ -0,0 +1,207 @@ +/** + * @file + * + * @brief "MS-DOS-style" Partition Tables Support + */ + +/* + * Copyright (C) 2002 OKTET Ltd., St.-Petersburg, Russia + * + * Author: Konstantin Abramenko + * Alexander Kukuta + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + *****************************************************************************/ + +#ifndef _RTEMS_IDE_PART_TABLE_H +#define _RTEMS_IDE_PART_TABLE_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Minor base number for all logical devices */ +#define RTEMS_IDE_SECTOR_BITS 9 +#define RTEMS_IDE_SECTOR_SIZE 512 +#define RTEMS_IDE_PARTITION_DESCRIPTOR_SIZE 16 +#define RTEMS_IDE_PARTITION_MAX_PARTITION_NUMBER 63 +#define RTEMS_IDE_PARTITION_MAX_SUB_PARTITION_NUMBER 4 +#define RTEMS_IDE_PARTITION_DEV_NAME_LENGTH_MAX 16 + +#define RTEMS_IDE_PARTITION_MSDOS_SIGNATURE_DATA1 0x55 +#define RTEMS_IDE_PARTITION_MSDOS_SIGNATURE_DATA2 0xaa +#define RTEMS_IDE_PARTITION_MSDOS_SIGNATURE_OFFSET 0x1fe +#define RTEMS_IDE_PARTITION_TABLE_OFFSET 0x1be +#define RTEMS_IDE_PARTITION_TABLE_SIZE (4 * 16) +#define RTEMS_IDE_PARTITION_BOOTABLE_OFFSET 0 +#define RTEMS_IDE_PARTITION_SYS_TYPE_OFFSET 4 +#define RTEMS_IDE_PARTITION_START_OFFSET 8 +#define RTEMS_IDE_PARTITION_SIZE_OFFSET 12 + +/* + * Conversion from and to little-endian byte order. (no-op on i386/i486) + */ +#define LE_TO_CPU_U16(v) le16toh(v) +#define LE_TO_CPU_U32(v) le32toh(v) +#define CPU_TO_LE_U16(v) htole16(v) +#define CPU_TO_LE_U32(v) htole32(v) + +/* + * sector_data_t -- + * corresponds to the sector on the device + */ +typedef struct rtems_sector_data_s +{ + uint32_t sector_num; /* sector number on the device */ + uint8_t data[RTEMS_ZERO_LENGTH_ARRAY]; /* raw sector data */ +} rtems_sector_data_t; + + +/* + * Enum partition types + * see list at http://ata-atapi.com/hiwtab.htm + * + * @todo Should these have RTEMS before them. + */ +enum { + EMPTY_PARTITION = 0x00, + DOS_FAT12_PARTITION = 0x01, + DOS_FAT16_PARTITION = 0x04, + EXTENDED_PARTITION = 0x05, + DOS_P32MB_PARTITION = 0x06, + FAT32_PARTITION = 0x0B, + FAT32_LBA_PARTITION = 0x0C, + FAT16_LBA_PARTITION = 0x0E, + DM6_PARTITION = 0x54, + EZD_PARTITION = 0x55, + DM6_AUX1PARTITION = 0x51, + DM6_AUX3PARTITION = 0x53, + LINUX_SWAP = 0x82, + LINUX_NATIVE = 0x83, + LINUX_EXTENDED = 0x85 +}; + + +/* Forward declaration */ +struct rtems_disk_desc_s; + +/* + * part_desc_t -- + * contains all neccessary information about partition + */ +typedef struct rtems_part_desc_s { + uint8_t bootable; /* is the partition active */ + uint8_t sys_type; /* type of partition */ + uint8_t log_id; /* logical number of partition */ + uint32_t start; /* first partition sector, in absolute + * numeration */ + uint32_t size; /* size in sectors */ + uint32_t end; /* last partition sector, end = start + size - 1 */ + struct rtems_disk_desc_s *disk_desc; /* descriptor of disk, partition + * contains in */ + struct rtems_part_desc_s *ext_part; /* extended partition containing this + * one */ + + /* partitions, containing in this one */ + struct rtems_part_desc_s *sub_part[RTEMS_IDE_PARTITION_MAX_SUB_PARTITION_NUMBER]; +} rtems_part_desc_t; + + + +typedef struct rtems_disk_desc_s { + dev_t dev; /* device number */ + + /* device name in /dev filesystem */ + char dev_name[RTEMS_IDE_PARTITION_DEV_NAME_LENGTH_MAX]; + + uint32_t sector_size; /* size of sector */ + uint32_t sector_bits; /* the base-2 logarithm of sector_size */ + uint32_t lba_size; /* total amount of sectors in lba address mode */ + int last_log_id; /* used for logical disks enumerating */ + + /* primary partition descriptors */ + rtems_part_desc_t *partitions[RTEMS_IDE_PARTITION_MAX_PARTITION_NUMBER]; +} rtems_disk_desc_t; + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * rtems_ide_part_table_free -- + * frees disk descriptor structure + * + * PARAMETERS: + * disk_desc - disc descriptor structure to free + * + * RETURNS: + * N/A + */ +/** + * @deprecated Use the @ref rtems_bdpart "block device partition module" instead. + */ +void rtems_ide_part_table_free( + rtems_disk_desc_t *disk_desc +) RTEMS_DEPRECATED; + + +/* + * rtems_ide_part_table_get -- + * reads partition table structure from the device + * and creates disk description structure + * + * PARAMETERS: + * dev_name - path to physical device in /dev filesystem + * disk_desc - returned disc description structure + * + * RETURNS: + * RTEMS_SUCCESSFUL if success, or -1 and corresponding errno else + */ +/** + * @deprecated Use the @ref rtems_bdpart "block device partition module" instead. + */ +rtems_status_code rtems_ide_part_table_get( + const char *dev_name, + rtems_disk_desc_t *disk_desc +) RTEMS_DEPRECATED; + + +/* + * rtems_ide_part_table_initialize -- + * initializes logical devices on the physical IDE drive + * + * PARAMETERS: + * dev_name - path to physical device in /dev filesystem + * + * RETURNS: + * RTEMS_SUCCESSFUL if success, or -1 and corresponding errno else + */ +/** + * @deprecated Use the @ref rtems_bdpart "block device partition module" instead. + */ +rtems_status_code rtems_ide_part_table_initialize( + const char *dev_name +) RTEMS_DEPRECATED; + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_IDE_PART_TABLE_H */ diff --git a/cpukit/include/rtems/imfs.h b/cpukit/include/rtems/imfs.h new file mode 100644 index 0000000000..fe3c5b12a9 --- /dev/null +++ b/cpukit/include/rtems/imfs.h @@ -0,0 +1,946 @@ +/** + * @file + * + * @brief Header File for the In-Memory File System + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_IMFS_H +#define _RTEMS_IMFS_H + +#include + +#include +#include + +/** + * @brief In-Memory File System Support. + * + * @defgroup IMFS In-Memory File System Support + * + * @ingroup FileSystemTypesAndMount + */ +/**@{*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Data types + */ + +struct IMFS_jnode_tt; +typedef struct IMFS_jnode_tt IMFS_jnode_t; + +/** + * IMFS "memfile" information + * + * The data structure for the in-memory "memfiles" is based on classic UNIX. + * + * block_ptr is a pointer to a block of IMFS_MEMFILE_BYTES_PER_BLOCK in + * length which could be data or a table of pointers to blocks. + * + * Setting IMFS_MEMFILE_BYTES_PER_BLOCK to different values has a significant + * impact on the maximum file size supported as well as the amount of + * memory wasted due to internal file fragmentation. The following + * is a list of maximum file sizes based on various settings + * + * @code + * max_filesize with blocks of 16 is 1,328 + * max_filesize with blocks of 32 is 18,656 + * max_filesize with blocks of 64 is 279,488 + * max_filesize with blocks of 128 is 4,329,344 + * max_filesize with blocks of 256 is 68,173,568 + * max_filesize with blocks of 512 is 1,082,195,456 + * @endcode + */ +#define IMFS_MEMFILE_DEFAULT_BYTES_PER_BLOCK 128 + extern int imfs_rq_memfile_bytes_per_block; + extern int imfs_memfile_bytes_per_block; + +#define IMFS_MEMFILE_BYTES_PER_BLOCK imfs_memfile_bytes_per_block +#define IMFS_MEMFILE_BLOCK_SLOTS \ + (IMFS_MEMFILE_BYTES_PER_BLOCK / sizeof(void *)) + +typedef uint8_t *block_p; +typedef block_p *block_ptr; + +/* + * Important block numbers for "memfiles" + */ +#define FIRST_INDIRECT (0) +#define LAST_INDIRECT (IMFS_MEMFILE_BLOCK_SLOTS - 1) + +#define FIRST_DOUBLY_INDIRECT (LAST_INDIRECT + 1) +#define LAST_DOUBLY_INDIRECT \ + (LAST_INDIRECT + \ + (IMFS_MEMFILE_BLOCK_SLOTS * IMFS_MEMFILE_BLOCK_SLOTS)) + +#define FIRST_TRIPLY_INDIRECT (LAST_DOUBLY_INDIRECT + 1) +#define LAST_TRIPLY_INDIRECT \ + (LAST_DOUBLY_INDIRECT +\ + (IMFS_MEMFILE_BLOCK_SLOTS * \ + IMFS_MEMFILE_BLOCK_SLOTS * IMFS_MEMFILE_BLOCK_SLOTS)) + +#define IMFS_MEMFILE_MAXIMUM_SIZE \ + (LAST_TRIPLY_INDIRECT * IMFS_MEMFILE_BYTES_PER_BLOCK) + +/** @} */ + +/** + * @addtogroup IMFSGenericNodes + */ +/**@{*/ + +/** + * @brief Initializes an IMFS node. + * + * @param[in] node The IMFS node. + * @param[in] arg The user provided argument pointer. It may contain node + * specific initialization information. + * + * @retval node Successful operation. + * @retval NULL An error occurred. The @c errno indicates the error. This + * will abort the make operation. + * + * @see IMFS_node_control, IMFS_node_initialize_default(), and + * IMFS_node_initialize_generic(). + */ +typedef IMFS_jnode_t *(*IMFS_node_control_initialize)( + IMFS_jnode_t *node, + void *arg +); + +/** + * @brief Returns the node and does nothing else. + * + * @param[in] node The IMFS node. + * @param[in] arg The user provided argument pointer. It is not used. + * + * @retval node Returns always the node passed as parameter. + * + * @see IMFS_node_control. + */ +IMFS_jnode_t *IMFS_node_initialize_default( + IMFS_jnode_t *node, + void *arg +); + +IMFS_jnode_t *IMFS_node_initialize_directory( + IMFS_jnode_t *node, + void *arg +); + +/** + * @brief Returns the node and sets the generic node context. + * + * @param[in] node The IMFS node. + * @param[in] arg The user provided argument pointer. It must contain the + * generic context. + * + * @retval node Returns always the node passed as parameter. + * + * @see IMFS_node_control. + */ +IMFS_jnode_t *IMFS_node_initialize_generic( + IMFS_jnode_t *node, + void *arg +); + +/** + * @brief Prepares the removal of an IMFS node from its parent directory. + * + * @param[in] node The IMFS node. + * + * @retval node Successful operation. + * @retval NULL An error occurred. The @c errno indicates the error. This + * will abort the removal operation. + * + * @see IMFS_node_control and IMFS_node_remove_default(). + */ +typedef IMFS_jnode_t *(*IMFS_node_control_remove)( + IMFS_jnode_t *node +); + +/** + * @brief Returns the node and does nothing else. + * + * @param[in] node The IMFS node. + * + * @retval node Returns always the node passed as parameter. + * + * @see IMFS_node_control. + */ +IMFS_jnode_t *IMFS_node_remove_default( + IMFS_jnode_t *node +); + +IMFS_jnode_t *IMFS_node_remove_directory( IMFS_jnode_t *node ); + +/** + * @brief Destroys an IMFS node. + * + * @param[in] node The IMFS node. + * + * @see IMFS_node_control and IMFS_node_destroy_default(). + */ +typedef void (*IMFS_node_control_destroy)( IMFS_jnode_t *node ); + +/** + * @brief Frees the node. + * + * @param[in] node The IMFS node. + * + * @see IMFS_node_control. + */ +void IMFS_node_destroy_default( IMFS_jnode_t *node ); + +/** + * @brief IMFS node control. + */ +typedef struct { + const rtems_filesystem_file_handlers_r *handlers; + IMFS_node_control_initialize node_initialize; + IMFS_node_control_remove node_remove; + IMFS_node_control_destroy node_destroy; +} IMFS_node_control; + +typedef struct { + IMFS_node_control node_control; + size_t node_size; +} IMFS_mknod_control; + +/** @} */ + +/** + * @addtogroup IMFS + */ +/**@{*/ + +/* + * Maximum length of a "basename" of an IMFS file/node. + */ + +#define IMFS_NAME_MAX _POSIX_NAME_MAX + +/* + + * The control structure for an IMFS jnode. + */ + +struct IMFS_jnode_tt { + rtems_chain_node Node; /* for chaining them together */ + IMFS_jnode_t *Parent; /* Parent node */ + const char *name; /* "basename" (not \0 terminated) */ + uint16_t namelen; /* Length of "basename" */ + uint16_t flags; /* Node flags */ + mode_t st_mode; /* File mode */ + unsigned short reference_count; + nlink_t st_nlink; /* Link count */ + + uid_t st_uid; /* User ID of owner */ + gid_t st_gid; /* Group ID of owner */ + + time_t stat_atime; /* Time of last access */ + time_t stat_mtime; /* Time of last modification */ + time_t stat_ctime; /* Time of last status change */ + const IMFS_node_control *control; +}; + +#define IMFS_NODE_FLAG_NAME_ALLOCATED 0x1 + +typedef struct { + IMFS_jnode_t Node; + rtems_chain_control Entries; + rtems_filesystem_mount_table_entry_t *mt_fs; +} IMFS_directory_t; + +typedef struct { + IMFS_jnode_t Node; + rtems_device_major_number major; + rtems_device_minor_number minor; +} IMFS_device_t; + +typedef struct { + IMFS_jnode_t Node; + IMFS_jnode_t *link_node; +} IMFS_link_t; + +typedef struct { + IMFS_jnode_t Node; + char *name; +} IMFS_sym_link_t; + +typedef struct { + IMFS_jnode_t Node; + size_t size; /* size of file in bytes */ +} IMFS_filebase_t; + +typedef struct { + IMFS_filebase_t File; + block_ptr indirect; /* array of 128 data blocks pointers */ + block_ptr doubly_indirect; /* 128 indirect blocks */ + block_ptr triply_indirect; /* 128 doubly indirect blocks */ +} IMFS_memfile_t; + +typedef struct { + IMFS_filebase_t File; + block_p direct; /* pointer to file image */ +} IMFS_linearfile_t; + +/* Support copy on write for linear files */ +typedef union { + IMFS_jnode_t Node; + IMFS_filebase_t File; + IMFS_memfile_t Memfile; + IMFS_linearfile_t Linearfile; +} IMFS_file_t; + +typedef struct { + IMFS_jnode_t Node; + pipe_control_t *pipe; +} IMFS_fifo_t; + +typedef struct { + IMFS_jnode_t Node; + void *context; +} IMFS_generic_t; + +static inline IMFS_directory_t *IMFS_iop_to_directory( + const rtems_libio_t *iop +) +{ + return (IMFS_directory_t *) iop->pathinfo.node_access; +} + +static inline IMFS_device_t *IMFS_iop_to_device( const rtems_libio_t *iop ) +{ + return (IMFS_device_t *) iop->pathinfo.node_access; +} + +static inline IMFS_file_t *IMFS_iop_to_file( const rtems_libio_t *iop ) +{ + return (IMFS_file_t *) iop->pathinfo.node_access; +} + +static inline IMFS_memfile_t *IMFS_iop_to_memfile( const rtems_libio_t *iop ) +{ + return (IMFS_memfile_t *) iop->pathinfo.node_access; +} + +static inline void IMFS_update_atime( IMFS_jnode_t *jnode ) +{ + struct timeval now; + + gettimeofday( &now, 0 ); + + jnode->stat_atime = now.tv_sec; +} + +static inline void IMFS_update_mtime( IMFS_jnode_t *jnode ) +{ + struct timeval now; + + gettimeofday( &now, 0 ); + + jnode->stat_mtime = now.tv_sec; +} + +static inline void IMFS_update_ctime( IMFS_jnode_t *jnode ) +{ + struct timeval now; + + gettimeofday( &now, 0 ); + + jnode->stat_ctime = now.tv_sec; +} + +static inline void IMFS_mtime_ctime_update( IMFS_jnode_t *jnode ) +{ + struct timeval now; + + gettimeofday( &now, 0 ); + + jnode->stat_mtime = now.tv_sec; + jnode->stat_ctime = now.tv_sec; +} + +typedef struct { + const IMFS_mknod_control *directory; + const IMFS_mknod_control *device; + const IMFS_mknod_control *file; + const IMFS_mknod_control *fifo; +} IMFS_mknod_controls; + +typedef struct { + IMFS_directory_t Root_directory; + const IMFS_mknod_controls *mknod_controls; +} IMFS_fs_info_t; + +typedef struct { + IMFS_fs_info_t *fs_info; + const rtems_filesystem_operations_table *ops; + const IMFS_mknod_controls *mknod_controls; +} IMFS_mount_data; + +/* + * Shared Data + */ + +extern const IMFS_mknod_control IMFS_mknod_control_dir_default; +extern const IMFS_mknod_control IMFS_mknod_control_dir_minimal; +extern const IMFS_mknod_control IMFS_mknod_control_device; +extern const IMFS_mknod_control IMFS_mknod_control_memfile; +extern const IMFS_node_control IMFS_node_control_linfile; +extern const IMFS_mknod_control IMFS_mknod_control_fifo; +extern const IMFS_mknod_control IMFS_mknod_control_enosys; + +extern const rtems_filesystem_limits_and_options_t IMFS_LIMITS_AND_OPTIONS; + +/* + * Routines + */ + +extern int IMFS_initialize( + rtems_filesystem_mount_table_entry_t *mt_entry, + const void *data +); + +extern int IMFS_initialize_support( + rtems_filesystem_mount_table_entry_t *mt_entry, + const void *data +); + +/** + * @brief Unmount this instance of IMFS. + */ +extern void IMFS_fsunmount( + rtems_filesystem_mount_table_entry_t *mt_entry +); + +/** + * @brief RTEMS load tarfs. + * + * This file implements the "mount" procedure for tar-based IMFS + * extensions. The TAR is not actually mounted under the IMFS. + * Directories from the TAR file are created as usual in the IMFS. + * File entries are created as IMFS_LINEAR_FILE nodes with their nods + * pointing to addresses in the TAR image. + * + * Here we create the mountpoint directory and load the tarfs at + * that node. Once the IMFS has been mounted, we work through the + * tar image and perform as follows: + * - For directories, simply call mkdir(). The IMFS creates nodes as + * needed. + * - For files, we make our own calls to IMFS eval_for_make and + * create_node. + * + * TAR file format: + * + * @code + * Offset Length Contents + * 0 100 bytes File name ('\0' terminated, 99 maxmum length) + * 100 8 bytes File mode (in octal ascii) + * 108 8 bytes User ID (in octal ascii) + * 116 8 bytes Group ID (in octal ascii) + * 124 12 bytes File size (s) (in octal ascii) + * 136 12 bytes Modify time (in octal ascii) + * 148 8 bytes Header checksum (in octal ascii) + * 156 1 bytes Link flag + * 157 100 bytes Linkname ('\0' terminated, 99 maxmum length) + * 257 8 bytes Magic PAX ("ustar\0" + 2 bytes padding) + * 257 8 bytes Magic GNU tar ("ustar \0") + * 265 32 bytes User name ('\0' terminated, 31 maxmum length) + * 297 32 bytes Group name ('\0' terminated, 31 maxmum length) + * 329 8 bytes Major device ID (in octal ascii) + * 337 8 bytes Minor device ID (in octal ascii) + * 345 167 bytes Padding + * 512 (s+p) bytes File contents (s+p) := (((s) + 511) & ~511), + * round up to 512 bytes + * @endcode + * + * Checksum: + * @code + * int i, sum; + * char *header = tar_header_pointer; + * + * sum = 0; + * for (i = 0; i < 512; i++) + * sum += 0xFF & header[i]; + * @endcode + */ +extern int rtems_tarfs_load( + const char *mountpoint, + uint8_t *tar_image, + size_t tar_size +); + +/** + * @brief Destroy an IMFS node. + */ +extern void IMFS_node_destroy( IMFS_jnode_t *node ); + +/** + * @brief Clone an IMFS node. + */ +extern int IMFS_node_clone( rtems_filesystem_location_info_t *loc ); + +/** + * @brief Free an IMFS node. + */ +extern void IMFS_node_free( const rtems_filesystem_location_info_t *loc ); + +/** + * @brief Perform a status processing for the IMFS. + * + * This routine provides a stat for the IMFS file system. + */ +extern int IMFS_stat( + const rtems_filesystem_location_info_t *loc, + struct stat *buf +); + +extern int IMFS_stat_file( + const rtems_filesystem_location_info_t *loc, + struct stat *buf +); + +/** + * @brief IMFS evaluation node support. + */ +extern void IMFS_eval_path( + rtems_filesystem_eval_path_context_t *ctx +); + +/** + * @brief Create a new IMFS link node. + * + * The following rouine creates a new link node under parent with the + * name given in name. The link node is set to point to the node at + * to_loc. + */ +extern int IMFS_link( + const rtems_filesystem_location_info_t *parentloc, + const rtems_filesystem_location_info_t *targetloc, + const char *name, + size_t namelen +); + +/** + * @brief Change the owner of IMFS. + * + * This routine is the implementation of the chown() system + * call for the IMFS. + */ +extern int IMFS_chown( + const rtems_filesystem_location_info_t *loc, + uid_t owner, + gid_t group +); + +/** + * @brief Create an IMFS node. + * + * Routine to create a node in the IMFS file system. + */ +extern int IMFS_mknod( + const rtems_filesystem_location_info_t *parentloc, + const char *name, + size_t namelen, + mode_t mode, + dev_t dev +); + +extern IMFS_jnode_t *IMFS_initialize_node( + IMFS_jnode_t *node, + const IMFS_node_control *node_control, + const char *name, + size_t namelen, + mode_t mode, + void *arg +); + +/** + * @brief Create an IMFS node. + * + * Create an IMFS filesystem node of an arbitrary type that is NOT + * the root directory node. + */ +extern IMFS_jnode_t *IMFS_create_node( + const rtems_filesystem_location_info_t *parentloc, + const IMFS_node_control *node_control, + size_t node_size, + const char *name, + size_t namelen, + mode_t mode, + void *arg +); + +static inline bool IMFS_is_imfs_instance( + const rtems_filesystem_location_info_t *loc +) +{ + return loc->mt_entry->ops->clonenod_h == IMFS_node_clone; +} + +/** @} */ + +/** + * @defgroup IMFSGenericNodes IMFS Generic Nodes + * + * @ingroup LibIO + * + * @brief Generic nodes are an alternative to standard drivers in RTEMS. + * + * The handlers of a generic node are called with less overhead compared to the + * standard driver operations. The usage of file system node handlers enable + * more features like support for fsync() and fdatasync(). The generic nodes + * use the reference counting of the IMFS. This provides automatic node + * destruction when the last reference vanishes. + * + * @{ + */ + +/** + * @brief Initializer for a generic node control. + * + * @param[in] handlers The file system node handlers. + * @param[in] init The node initialization method. + * @param[in] destroy The node destruction method. + */ +#define IMFS_GENERIC_INITIALIZER( handlers, init, destroy ) \ + { \ + ( handlers ), \ + ( init ), \ + IMFS_node_remove_default, \ + ( destroy ) \ + } + +/** + * @brief Makes a generic IMFS node. + * + * @param[in] path The path to the new generic IMFS node. + * @param[in] mode The node mode. + * @param[in] node_control The node control. + * @param[in] context The node control handler context. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The @c errno indicates the error. + * + * @code + * #include + * #include + * #include + * + * #include + * + * static const rtems_filesystem_file_handlers_r some_node_handlers = { + * ... + * }; + * + * static IMFS_jnode_t *some_node_init(IMFS_jnode_t *node, void *arg) + * { + * void *context; + * + * node = IMFS_node_initialize_generic(node, arg); + * context = IMFS_generic_get_context_by_node(node); + * + * return node; + * } + * + * static void some_node_destroy(IMFS_jnode_t *node) + * { + * void *context = IMFS_generic_get_context_by_node(node); + * + * IMFS_node_destroy_default(node); + * } + * + * static const IMFS_node_control some_node_control = IMFS_GENERIC_INITIALIZER( + * &some_node_handlers, + * some_node_init, + * some_node_destroy + * ); + * + * void example(void *some_node_context) + * { + * int rv; + * + * rv = IMFS_make_generic_node( + * "/path/to/some/generic/node", + * S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO, + * &some_node_control, + * some_node_context + * ); + * assert(rv == 0); + * } + * @endcode + */ +extern int IMFS_make_generic_node( + const char *path, + mode_t mode, + const IMFS_node_control *node_control, + void *context +); + +/** @} */ + +/** + * @addtogroup IMFS + */ +/**@{*/ + +/** + * @brief Mount an IMFS. + */ +extern int IMFS_mount( + rtems_filesystem_mount_table_entry_t *mt_entry /* IN */ +); + +/** + * @brief Unmount an IMFS. + */ +extern int IMFS_unmount( + rtems_filesystem_mount_table_entry_t *mt_entry /* IN */ +); + +/** + * @name IMFS Memory File Handlers + * + * This section contains the set of handlers used to process operations on + * IMFS memory file nodes. The memory files are created in memory using + * malloc'ed memory. Thus any data stored in one of these files is lost + * at system shutdown unless special arrangements to copy the data to + * some type of non-volailte storage are made by the application. + */ +/**@{*/ + +extern ssize_t IMFS_memfile_write( + IMFS_memfile_t *memfile, + off_t start, + const unsigned char *source, + unsigned int length +); + +/** @} */ + +/** + * @name IMFS Device Node Handlers + * + * This section contains the set of handlers used to map operations on + * IMFS device nodes onto calls to the RTEMS Classic API IO Manager. + */ +/**@{*/ + +extern int device_open( + rtems_libio_t *iop, /* IN */ + const char *pathname, /* IN */ + int oflag, /* IN */ + mode_t mode /* IN */ +); + +extern int device_close( + rtems_libio_t *iop /* IN */ +); + +extern ssize_t device_read( + rtems_libio_t *iop, /* IN */ + void *buffer, /* IN */ + size_t count /* IN */ +); + +extern ssize_t device_write( + rtems_libio_t *iop, /* IN */ + const void *buffer, /* IN */ + size_t count /* IN */ +); + +extern int device_ioctl( + rtems_libio_t *iop, + ioctl_command_t command, + void *buffer +); + +extern int device_ftruncate( + rtems_libio_t *iop, /* IN */ + off_t length /* IN */ +); + +/** @} */ + +/** + * @brief Set IMFS file access and modification times. + * + * + * This routine is the implementation of the utime() system + * call for the IMFS. + */ +extern int IMFS_utime( + const rtems_filesystem_location_info_t *loc, + time_t actime, + time_t modtime +); + +/** + * @brief Change the IMFS file mode. + */ +extern int IMFS_fchmod( + const rtems_filesystem_location_info_t *loc, + mode_t mode +); + +/** + * @brief Create a new IMFS symbolic link node. + * + * The following rouine creates a new symbolic link node under parent + * with the name given in name. The node is set to point to the node at + * to_loc. + */ +extern int IMFS_symlink( + const rtems_filesystem_location_info_t *parentloc, + const char *name, + size_t namelen, + const char *target +); + +/** + * @brief Put IMFS symbolic link into buffer. + * + * The following rouine puts the symbolic links destination name into + * buff. + * + */ +extern ssize_t IMFS_readlink( + const rtems_filesystem_location_info_t *loc, + char *buf, + size_t bufsize +); + +/** + * @brief Rename the IMFS. + * + * The following rouine creates a new link node under parent with the + * name given in name and removes the old. + */ +extern int IMFS_rename( + const rtems_filesystem_location_info_t *oldparentloc, + const rtems_filesystem_location_info_t *oldloc, + const rtems_filesystem_location_info_t *newparentloc, + const char *name, + size_t namelen +); +/** + * @brief IMFS node removal handler. + * + * This file contains the handler used to remove a node when a file type + * does not require special actions. + */ +extern int IMFS_rmnod( + const rtems_filesystem_location_info_t *parentloc, + const rtems_filesystem_location_info_t *loc +); + +/* + * Turn on IMFS assertions when RTEMS_DEBUG is defined. + */ +#ifdef RTEMS_DEBUG + #include + + #define IMFS_assert(_x) assert(_x) +#else + #define IMFS_assert(_x) +#endif + +static inline void IMFS_Set_handlers( rtems_filesystem_location_info_t *loc ) +{ + IMFS_jnode_t *node = (IMFS_jnode_t *) loc->node_access; + + loc->handlers = node->control->handlers; +} + +static inline void IMFS_add_to_directory( + IMFS_jnode_t *dir_node, + IMFS_jnode_t *entry_node +) +{ + IMFS_directory_t *dir = (IMFS_directory_t *) dir_node; + + entry_node->Parent = dir_node; + rtems_chain_append_unprotected( &dir->Entries, &entry_node->Node ); +} + +static inline void IMFS_remove_from_directory( IMFS_jnode_t *node ) +{ + IMFS_assert( node->Parent != NULL ); + node->Parent = NULL; + rtems_chain_extract_unprotected( &node->Node ); +} + +static inline bool IMFS_is_directory( const IMFS_jnode_t *node ) +{ + return S_ISDIR( node->st_mode ); +} + +#define IMFS_STAT_FMT_HARD_LINK 0 + +static inline bool IMFS_is_hard_link( mode_t mode ) +{ + return ( mode & S_IFMT ) == IMFS_STAT_FMT_HARD_LINK; +} + +static inline ino_t IMFS_node_to_ino( const IMFS_jnode_t *node ) +{ + return (ino_t) ((uintptr_t) node); +} + +/** @} */ + +/** + * @addtogroup IMFSGenericNodes + */ +/**@{*/ + +static inline void *IMFS_generic_get_context_by_node( + const IMFS_jnode_t *node +) +{ + const IMFS_generic_t *generic = (const IMFS_generic_t *) node; + + return generic->context; +} + +static inline void *IMFS_generic_get_context_by_location( + const rtems_filesystem_location_info_t *loc +) +{ + return loc->node_access_2; +} + +static inline void *IMFS_generic_get_context_by_iop( + const rtems_libio_t *iop +) +{ + return IMFS_generic_get_context_by_location( &iop->pathinfo ); +} + +static inline dev_t IMFS_generic_get_device_identifier_by_node( + const IMFS_jnode_t *node +) +{ + return rtems_filesystem_make_dev_t_from_pointer( node ); +} + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/init.h b/cpukit/include/rtems/init.h new file mode 100644 index 0000000000..fa3108ea50 --- /dev/null +++ b/cpukit/include/rtems/init.h @@ -0,0 +1,69 @@ +/** + * @file + * + * @brief Constants and Structures Associated + * with the Initialization Manager + * + * This include file contains all the constants and structures associated + * with the Initialization Manager. This manager is responsible for + * initializing RTEMS, creating and starting all configured initialization + * tasks, invoking the initialization routine for each user-supplied device + * driver, and initializing the optional multiprocessor layer. + * + * This manager provides directives to: + * + * + initialize the RTEMS executive + * + shutdown the RTEMS executive + */ + +/* + * COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_INIT_H +#define _RTEMS_INIT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +/** + * @brief Initializes the system and starts multitasking. + * + * Iterates through the system initialization linker set and invokes the + * registered handlers. The final step is to start multitasking. + * + * This directive should be called by boot_card() only. + * + * This directive does not return. + */ +void rtems_initialize_executive(void) + RTEMS_NO_RETURN; + +/** + * @brief Shutdown the RTEMS environment. + * + * This routine implements the rtems_shutdown_executive directive. The + * invocation of this directive results in the RTEMS environment being + * shutdown and multitasking halted. The system is terminated with a fatal + * source of RTEMS_FATAL_SOURCE_EXIT and the specified result code. + */ +void rtems_shutdown_executive( + uint32_t result +) RTEMS_NO_RETURN; + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/io.h b/cpukit/include/rtems/io.h new file mode 100644 index 0000000000..760d412bb8 --- /dev/null +++ b/cpukit/include/rtems/io.h @@ -0,0 +1,254 @@ +/** + * @file + * + * @brief Classic Input/Output Manager API + * + * This file emulates the old Classic RTEMS IO manager directives + * which register and lookup names using the in-memory filesystem. + */ + +/* + * COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_IO_H +#define _RTEMS_IO_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicIO Input/Output + * + * @ingroup ClassicRTEMS + * + */ +/**@{**/ + +typedef uint32_t rtems_device_major_number; + +typedef uint32_t rtems_device_minor_number; + +typedef rtems_status_code rtems_device_driver; + +typedef rtems_device_driver (*rtems_device_driver_entry)( + rtems_device_major_number, + rtems_device_minor_number, + void * +); + +typedef struct { + rtems_device_driver_entry initialization_entry; + rtems_device_driver_entry open_entry; + rtems_device_driver_entry close_entry; + rtems_device_driver_entry read_entry; + rtems_device_driver_entry write_entry; + rtems_device_driver_entry control_entry; +} rtems_driver_address_table; + +/** + * @name Device Driver Maintainance + */ +/**@{**/ + +/** + * @brief Returns @c RTEMS_IO_ERROR. + * + * @retval RTEMS_IO_ERROR Only this one. + */ +rtems_status_code rtems_io_driver_io_error( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg +); + +/** + * @brief Registers and initializes the device with the device driver table + * @a driver_table and major number @a major. + * + * If the major number equals zero a major number will be obtained. The major + * number of the registered driver will be returned in @a registered_major. + * + * After a successful registration rtems_io_initialize() will be called to + * initialize the device. + * + * @retval RTEMS_SUCCESSFUL Device successfully registered and initialized. + * @retval RTEMS_INVALID_ADDRESS Pointer to driver table or to registered + * major number are invalid. Device driver table is empty. + * @retval RTEMS_INVALID_NUMBER Invalid major number. + * @retval RTEMS_TOO_MANY No major number available. + * @retval RTEMS_RESOURCE_IN_USE Major number in use. + * @retval RTEMS_CALLED_FROM_ISR Called from interrupt context. + * @retval * Status code depends on rtems_io_initialize(). + */ +rtems_status_code rtems_io_register_driver( + rtems_device_major_number major, + const rtems_driver_address_table *driver_table, + rtems_device_major_number *registered_major +); + +/** + * @brief Unregister a driver from the device driver table. + * + * @param[in] major is the device major number. + * + * @retval RTEMS_SUCCESSFUL Device driver successfully unregistered. + * @retval RTEMS_UNSATISFIED Invalid major number. + * @retval RTEMS_CALLED_FROM_ISR Called from interrupt context. + */ +rtems_status_code rtems_io_unregister_driver( + rtems_device_major_number major +); + +/** + * @brief Registers the name @a device_name in the file system for the device + * with number tuple @a major and @a minor. + * + * This assumes that all registered devices are character devices. + * + * @retval RTEMS_SUCCESSFUL Name successfully registered. + * @retval RTEMS_TOO_MANY Name already in use or other errors. + */ +rtems_status_code rtems_io_register_name( + const char *device_name, + rtems_device_major_number major, + rtems_device_minor_number minor +); + +/** @} */ + +/** + * @brief IO driver initialization. + * + * This routine is the initialization directive of the IO manager. + * + * @param[in] major is the device drive number + * @param[in] minor is the device number + * @param[in] argument is the pointer to the argument(s) + * + * @return status code + */ +rtems_status_code rtems_io_initialize( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *argument +); + +/** + * @brief Opening for the IO manager. + * + * Opens a device driver with the number @a major. + * + * @param[in] major is the device driver number. + * @param[in] minor is the device number. + * @param[in] argument is the pointer to the argument(s). + * + * @return Status code. + */ +rtems_status_code rtems_io_open( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *argument +); + +/** + * @brief Closing for the IO manager. + * + * This routine is the close directive of the IO manager. + * + * @param[in] major is the device driver number. + * @param[in] minor is the device number. + * @param[in] argument is the pointer to the argument(s). + * + * @return Status code. + */ +rtems_status_code rtems_io_close( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *argument +); + +/** + * @brief Reading for the IO manager. + * + * This routine is the read directive of the IO manager. + * + * @param[in] major is the device driver number. + * @param[in] minor is the device number. + * @param[in] argument is the pointer to the argument(s). + * + * @return Status code. + */ +rtems_status_code rtems_io_read( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *argument +); + +/** + * @brief Writing for the IO manager. + * + * This routine is the write directive of the IO manager. + * + * @param[in] major is the device driver number. + * @param[in] minor is the device number. + * @param[in] argument is the pointer to the argument(s). + * + * @return Status code. + */ +rtems_status_code rtems_io_write( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *argument +); + +/** + * @brief Control for the IO manager. + * + * This routine is the control directive of the IO manager. + * + * @param[in] major is the device driver number. + * @param[in] minor is the device number. + * @param[in] argument is the pointer to the argument(s). + * + * @return Status code. + */ +rtems_status_code rtems_io_control( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *argument +); + +/** @} */ + +/** @} */ + +typedef struct { + const char *device_name; + size_t device_name_length; + rtems_device_major_number major; + rtems_device_minor_number minor; +} rtems_driver_name_t; + +/** + * @deprecated Use stat() instead. + */ +rtems_status_code rtems_io_lookup_name( + const char *name, + rtems_driver_name_t *device_info +) RTEMS_DEPRECATED; + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/ioimpl.h b/cpukit/include/rtems/ioimpl.h new file mode 100644 index 0000000000..5c4a82eea6 --- /dev/null +++ b/cpukit/include/rtems/ioimpl.h @@ -0,0 +1,65 @@ +/** + * @file + * + * @brief Classic Input/Output Manager Implementation API + */ + +/* + * COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_IOIMPL_H +#define _RTEMS_IOIMPL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +extern const size_t _IO_Number_of_drivers; + +extern rtems_driver_address_table _IO_Driver_address_table[]; + +extern bool _IO_All_drivers_initialized; + +/** + * @brief Initialization of all device drivers. + * + * Initializes all device drivers. + */ +void _IO_Initialize_all_drivers( void ); + +ISR_LOCK_DECLARE( extern, _IO_Driver_registration_lock ) + +RTEMS_INLINE_ROUTINE void _IO_Driver_registration_acquire( + ISR_lock_Context *lock_context +) +{ + _ISR_lock_ISR_disable_and_acquire( + &_IO_Driver_registration_lock, + lock_context + ); +} + +RTEMS_INLINE_ROUTINE void _IO_Driver_registration_release( + ISR_lock_Context *lock_context +) +{ + _ISR_lock_Release_and_ISR_enable( + &_IO_Driver_registration_lock, + lock_context + ); +} + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_IOIMPL_H */ diff --git a/cpukit/include/rtems/iosupp.h b/cpukit/include/rtems/iosupp.h new file mode 100644 index 0000000000..9fe8a6ab1d --- /dev/null +++ b/cpukit/include/rtems/iosupp.h @@ -0,0 +1,46 @@ +/** + * @file rtems/iosupp.h + * + * This include file defines some special characters of interest. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_IOSUPP_H +#define _RTEMS_IOSUPP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* character constants */ + +#define BS 0x08 /* backspace */ +#define LF 0x0a /* line feed */ +#define CR 0x0d /* carriage return */ +#define XON 0x11 /* control-Q */ +#define XOFF 0x13 /* control-S */ + +/* structures */ + +#ifdef IOSUPP_INIT +#define IOSUPP_EXTERN +#else +#undef IOSUPP_EXTERN +#define IOSUPP_EXTERN extern +#endif + +/* functions */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/include/rtems/jffs2.h b/cpukit/include/rtems/jffs2.h new file mode 100644 index 0000000000..a856c46c41 --- /dev/null +++ b/cpukit/include/rtems/jffs2.h @@ -0,0 +1,604 @@ +/* + * Copyright (c) 2013, 2016 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef RTEMS_JFFS2_H +#define RTEMS_JFFS2_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +typedef struct rtems_jffs2_flash_control rtems_jffs2_flash_control; + +/** + * @defgroup JFFS2 Journalling Flash File System Version 2 (JFFS2) Support + * + * @ingroup FileSystemTypesAndMount + * + * @brief Mount options for the Journalling Flash File System, Version 2 + * (JFFS2). + * + * The application must provide flash device geometry information and flash + * device operations in the flash control structure + * @ref rtems_jffs2_flash_control. + * + * The application can optionally provide a compressor control structure to + * enable data compression using the selected compression algorithm. + * + * The application must enable JFFS2 support with rtems_filesystem_register() + * or CONFIGURE_FILESYSTEM_JFFS2 via . + * + * An example mount with a simple memory based flash device simulation follows. + * The zlib is used for as the compressor. + * + * @code + * #include + * + * #include + * #include + * + * #define BLOCK_SIZE (32UL * 1024UL) + * + * #define FLASH_SIZE (32UL * BLOCK_SIZE) + * + * typedef struct { + * rtems_jffs2_flash_control super; + * unsigned char area[FLASH_SIZE]; + * } flash_control; + * + * static flash_control *get_flash_control(rtems_jffs2_flash_control *super) + * { + * return (flash_control *) super; + * } + * + * static int flash_read( + * rtems_jffs2_flash_control *super, + * uint32_t offset, + * unsigned char *buffer, + * size_t size_of_buffer + * ) + * { + * flash_control *self = get_flash_control(super); + * unsigned char *chunk = &self->area[offset]; + * + * memcpy(buffer, chunk, size_of_buffer); + * + * return 0; + * } + * + * static int flash_write( + * rtems_jffs2_flash_control *super, + * uint32_t offset, + * const unsigned char *buffer, + * size_t size_of_buffer + * ) + * { + * flash_control *self = get_flash_control(super); + * unsigned char *chunk = &self->area[offset]; + * size_t i; + * + * for (i = 0; i < size_of_buffer; ++i) { + * chunk[i] &= buffer[i]; + * } + * + * return 0; + * } + * + * static int flash_erase( + * rtems_jffs2_flash_control *super, + * uint32_t offset + * ) + * { + * flash_control *self = get_flash_control(super); + * unsigned char *chunk = &self->area[offset]; + * + * memset(chunk, 0xff, BLOCK_SIZE); + * + * return 0; + * } + * + * static flash_control flash_instance = { + * .super = { + * .block_size = BLOCK_SIZE, + * .flash_size = FLASH_SIZE, + * .read = flash_read, + * .write = flash_write, + * .erase = flash_erase, + * .device_identifier = 0xc01dc0fe + * } + * }; + * + * static rtems_jffs2_compressor_zlib_control compressor_instance = { + * .super = { + * .compress = rtems_jffs2_compressor_zlib_compress, + * .decompress = rtems_jffs2_compressor_zlib_decompress + * } + * }; + * + * static const rtems_jffs2_mount_data mount_data = { + * .flash_control = &flash_instance.super, + * .compressor_control = &compressor_instance.super + * }; + * + * static void erase_all(void) + * { + * memset(&flash_instance.area[0], 0xff, FLASH_SIZE); + * } + * + * void example_jffs2_mount(const char *mount_dir) + * { + * int rv; + * + * erase_all(); + * + * rv = mount_and_make_target_path( + * NULL, + * mount_dir, + * RTEMS_FILESYSTEM_TYPE_JFFS2, + * RTEMS_FILESYSTEM_READ_WRITE, + * &mount_data + * ); + * assert(rv == 0); + * } + * @endcode + * + * @{ + */ + +/** + * @brief Read from flash operation. + * + * @param[in, out] self The flash control. + * @param[in] offset The offset to read from the flash begin in bytes. + * @param[out] buffer The buffer receiving the data. + * @param[in] size_of_buffer The size of the buffer in bytes. + * + * @retval 0 Successful operation. + * @retval -EIO An error occurred. Please note that the value is negative. + * @retval other All other values are reserved and must not be used. + */ +typedef int (*rtems_jffs2_flash_read)( + rtems_jffs2_flash_control *self, + uint32_t offset, + unsigned char *buffer, + size_t size_of_buffer +); + +/** + * @brief Write to flash operation. + * + * @param[in, out] self The flash control. + * @param[in] offset The offset to write from the flash begin in bytes. + * @param[in] buffer The buffer containing the data to write. + * @param[in] size_of_buffer The size of the buffer in bytes. + * + * @retval 0 Successful operation. + * @retval -EIO An error occurred. Please note that the value is negative. + * @retval other All other values are reserved and must not be used. + */ +typedef int (*rtems_jffs2_flash_write)( + rtems_jffs2_flash_control *self, + uint32_t offset, + const unsigned char *buffer, + size_t size_of_buffer +); + +/** + * @brief Flash erase operation. + * + * This operation must erase one block specified by the offset. + * + * @param[in, out] self The flash control. + * @param[in] offset The offset to erase from the flash begin in bytes. + * + * @retval 0 Successful operation. + * @retval -EIO An error occurred. Please note that the value is negative. + * @retval other All other values are reserved and must not be used. + */ +typedef int (*rtems_jffs2_flash_erase)( + rtems_jffs2_flash_control *self, + uint32_t offset +); + +/** + * @brief Flash destroy operation. + * + * The flash destroy operation is called during unmount of the file system + * instance. It can be used to free the resources associated with the now + * unused flash control + * + * @param[in, out] self The flash control. + */ +typedef void (*rtems_jffs2_flash_destroy)( + rtems_jffs2_flash_control *self +); + +/** + * @brief Trigger garbage collection operation. + * + * An optional garbage collection thread may perform now a garbage collection + * using the RTEMS_JFFS2_ON_DEMAND_GARBAGE_COLLECTION IO control. + * + * The garbage collection must not run in the executing context. + * + * @param[in] self The flash control. + */ +typedef void (*rtems_jffs2_trigger_garbage_collection)( + rtems_jffs2_flash_control *self +); + +/** + * @brief JFFS2 flash device control. + */ +struct rtems_jffs2_flash_control { + /** + * @brief The size in bytes of the erasable unit of the flash device. + */ + uint32_t block_size; + + /** + * @brief The size in bytes of the flash device. + * + * It must be an integral multiple of the block size. The flash device must + * have at least five blocks. + */ + uint32_t flash_size; + + /** + * @brief Read from flash operation. + */ + rtems_jffs2_flash_read read; + + /** + * @brief Write to flash operation. + */ + rtems_jffs2_flash_write write; + + /** + * @brief Flash erase operation. + */ + rtems_jffs2_flash_erase erase; + + /** + * @brief Flash destroy operation. + * + * This operation is optional and the pointer may be @c NULL. + */ + rtems_jffs2_flash_destroy destroy; + + /** + * @brief The device identifier of the flash device. + * + * It is used in combination with the inode number to uniquely identify a + * file system node in the system. + */ + dev_t device_identifier; + + /** + * @brief Trigger garbage collection operation. + * + * This operation is optional and may be NULL. This operation should wake up + * a garbage collection thread. The garbage collection thread should use the + * RTEMS_JFFS2_ON_DEMAND_GARBAGE_COLLECTION IO control to carry out the work. + */ + rtems_jffs2_trigger_garbage_collection trigger_garbage_collection; +}; + +typedef struct rtems_jffs2_compressor_control rtems_jffs2_compressor_control; + +/** + * @brief Compress operation. + * + * @param[in, out] self The compressor control. + * @param[in] data_in The uncompressed data. + * @param[out] cdata_out Pointer to buffer with the compressed data. + * @param[in, out] datalen On entry, the size in bytes of the uncompressed + * data. On exit, the size in bytes of uncompressed data which was actually + * compressed. + * @param[in, out] cdatalen On entry, the size in bytes available for + * compressed data. On exit, the size in bytes of the actually compressed + * data. + * + * @return The compressor type. + */ +typedef uint16_t (*rtems_jffs2_compressor_compress)( + rtems_jffs2_compressor_control *self, + unsigned char *data_in, + unsigned char *cdata_out, + uint32_t *datalen, + uint32_t *cdatalen +); + +/** + * @brief Decompress operation. + * + * @param[in, out] self The compressor control. + * @param[in] comprtype The compressor type. + * @param[in] cdata_in The compressed data. + * @param[out] data_out The uncompressed data. + * @param[in] cdatalen The size in bytes of the compressed data. + * @param[in] datalen The size in bytes of the uncompressed data. + * + * @retval 0 Successful operation. + * @retval -EIO An error occurred. Please note that the value is negative. + * @retval other All other values are reserved and must not be used. + */ +typedef int (*rtems_jffs2_compressor_decompress)( + rtems_jffs2_compressor_control *self, + uint16_t comprtype, + unsigned char *cdata_in, + unsigned char *data_out, + uint32_t cdatalen, + uint32_t datalen +); + +/** + * @brief Compressor destroy operation. + * + * The compressor destroy operation is called during unmount of the file system + * instance. It can be used to free the resources associated with the now + * unused compressor operations. + * + * @param[in, out] self The compressor control. + */ +typedef void (*rtems_jffs2_compressor_destroy)( + rtems_jffs2_compressor_control *self +); + +/** + * @brief JFFS2 compressor control. + */ +struct rtems_jffs2_compressor_control { + /** + * @brief Compress operation. + */ + rtems_jffs2_compressor_compress compress; + + /** + * @brief Decompress operation. + */ + rtems_jffs2_compressor_decompress decompress; + + /** + * @brief Compressor destroy operation. + * + * This operation is optional and the pointer may be @c NULL. + */ + rtems_jffs2_compressor_destroy destroy; + + /** + * @brief Compression buffer. + */ + unsigned char buffer[PAGE_SIZE]; +}; + +/** + * @brief RTIME compressor compress operation. + */ +uint16_t rtems_jffs2_compressor_rtime_compress( + rtems_jffs2_compressor_control *self, + unsigned char *data_in, + unsigned char *cdata_out, + uint32_t *datalen, + uint32_t *cdatalen +); + +/** + * @brief RTIME compressor decompress operation. + */ +int rtems_jffs2_compressor_rtime_decompress( + rtems_jffs2_compressor_control *self, + uint16_t comprtype, + unsigned char *cdata_in, + unsigned char *data_out, + uint32_t cdatalen, + uint32_t datalen +); + +/** + * @brief ZLIB compressor control structure. + */ +typedef struct { + rtems_jffs2_compressor_control super; + z_stream stream; +} rtems_jffs2_compressor_zlib_control; + +/** + * @brief ZLIB compressor compress operation. + */ +uint16_t rtems_jffs2_compressor_zlib_compress( + rtems_jffs2_compressor_control *self, + unsigned char *data_in, + unsigned char *cdata_out, + uint32_t *datalen, + uint32_t *cdatalen +); + +/** + * @brief ZLIB compressor decompress operation. + */ +int rtems_jffs2_compressor_zlib_decompress( + rtems_jffs2_compressor_control *self, + uint16_t comprtype, + unsigned char *cdata_in, + unsigned char *data_out, + uint32_t cdatalen, + uint32_t datalen +); + +/** + * @brief JFFS2 mount options. + * + * For JFFS2 the mount options are mandatory. + */ +typedef struct { + /** + * @brief Flash control. + */ + rtems_jffs2_flash_control *flash_control; + + /** + * @brief Compressor control. + * + * The compressor is optional and this pointer may be @c NULL. + */ + rtems_jffs2_compressor_control *compressor_control; +} rtems_jffs2_mount_data; + +/** + * @brief Initialization handler of the JFFS2 file system. + * + * @param[in, out] mt_entry The mount table entry. + * @param[in] data The mount options are mandatory for JFFS2 and data must + * point to a valid @ref rtems_jffs2_mount_data structure used for this file + * system instance. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The @c errno indicates the error. + * + * @see mount(). + */ +int rtems_jffs2_initialize( + rtems_filesystem_mount_table_entry_t *mt_entry, + const void *data +); + +/** + * @brief JFFS2 filesystem instance information. + * + * @see RTEMS_JFFS2_GET_INFO. + */ +typedef struct { + /** + * @brief Flash size in bytes. + */ + uint32_t flash_size; + + /** + * @brief Count of flash blocks (erasable units). + */ + uint32_t flash_blocks; + + /** + * @brief Size of a flash block in bytes. + */ + uint32_t flash_block_size; + + /** + * @brief Used size in bytes. + * + * Used areas contain valid data. + */ + uint32_t used_size; + + /** + * @brief Dirty size in bytes. + * + * Used areas contain no longer used data. + */ + uint32_t dirty_size; + + /** + * @brief Wasted size in bytes. + * + * Wasted areas are unusable. + */ + uint32_t wasted_size; + + /** + * @brief Free size in bytes. + * + * Free areas may be used to store new data. + */ + uint32_t free_size; + + /** + * @brief Bad size in bytes. + * + * Bad areas indicate damaged flash blocks. + */ + uint32_t bad_size; + + /** + * @brief Count of clean blocks. + * + * Clean blocks contain only used areas. + */ + uint32_t clean_blocks; + + /** + * @brief Count of dirty blocks. + * + * Dirty blocks contain dirty and used areas. + */ + uint32_t dirty_blocks; + + /** + * @brief Count of erasable blocks. + * + * Erase blocks contain only dirty or wasted areas. + */ + uint32_t erasable_blocks; + + /** + * @brief Count of free blocks. + * + * Free blocks contain a free area. + */ + uint32_t free_blocks; + + /** + * @brief Count of bad blocks. + * + * Bad blocks are damaged. + */ + uint32_t bad_blocks; +} rtems_jffs2_info; + +/** + * @brief IO control to get the JFFS2 filesystem instance information. + * + * @see rtems_jffs2_info. + */ +#define RTEMS_JFFS2_GET_INFO _IOR('F', 1, rtems_jffs2_info) + +/** + * @brief IO control to perform an on demand garbage collection in a JFFS2 + * filesystem instance. + * + * This operation is intended to be used by an optional garbage collection + * thread. See rtems_jffs2_flash_control::trigger_garbage_collection. + */ +#define RTEMS_JFFS2_ON_DEMAND_GARBAGE_COLLECTION _IO('F', 2) + +/** + * @brief IO control to force a garbage collection in a JFFS2 filesystem + * instance. + * + * Use this operation with care since it may wear out your flash. + */ +#define RTEMS_JFFS2_FORCE_GARBAGE_COLLECTION _IO('F', 3) + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RTEMS_JFFS2_H */ diff --git a/cpukit/include/rtems/libcsupport.h b/cpukit/include/rtems/libcsupport.h new file mode 100644 index 0000000000..51607f9ea1 --- /dev/null +++ b/cpukit/include/rtems/libcsupport.h @@ -0,0 +1,193 @@ +/** + * @file + * + * @brief Standard C Library Support + * + * This include file contains the information regarding the + * RTEMS specific support for the standard C library. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_LIBCSUPPORT_H +#define _RTEMS_RTEMS_LIBCSUPPORT_H + +#include +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup libcsupport Standard C Library Support + * + * @brief RTEMS Specific Support for the Standard C Library + * + */ +/**@{**/ + +extern void malloc_dump(void); + +/** + * @brief Malloc walk. + */ +extern bool malloc_walk(int source, bool printf_enabled); + +/** + * @brief Set malloc heap pointer. + * + * This routine is primarily used for debugging. + */ +void malloc_set_heap_pointer(Heap_Control *new_heap); + +/** + * @brief Get malloc heap pointer. + * + * This routine is primarily used for debugging. + */ +Heap_Control *malloc_get_heap_pointer( void ); + +/** + * @brief Get free malloc information. + * + * Find amount of free heap remaining + */ +extern size_t malloc_free_space(void); + +/** + * @brief Get malloc status information. + * + * Find amount of free heap remaining. + */ +extern int malloc_info(Heap_Information_block *the_info); + +/* + * Prototypes required to install newlib reentrancy user extension + */ +bool newlib_create_hook( + rtems_tcb *current_task, + rtems_tcb *creating_task +); + +void newlib_terminate_hook( + rtems_tcb *current_task +); + +#define RTEMS_NEWLIB_EXTENSION \ +{ \ + newlib_create_hook, /* rtems_task_create */ \ + 0, /* rtems_task_start */ \ + 0, /* rtems_task_restart */ \ + 0, /* rtems_task_delete */ \ + 0, /* task_switch */ \ + 0, /* task_begin */ \ + 0, /* task_exitted */ \ + 0, /* fatal */ \ + newlib_terminate_hook /* thread terminate */ \ +} + +typedef struct { + uint32_t active_barriers; + uint32_t active_extensions; + uint32_t active_message_queues; + uint32_t active_partitions; + uint32_t active_periods; + uint32_t active_ports; + uint32_t active_regions; + uint32_t active_semaphores; + uint32_t active_tasks; + uint32_t active_timers; +} rtems_resource_rtems_api; + +typedef struct { + uint32_t active_message_queues; + uint32_t active_semaphores; + uint32_t active_threads; + uint32_t active_timers; +} rtems_resource_posix_api; + +typedef struct { + Heap_Information_block workspace_info; + Heap_Information_block heap_info; + uint32_t active_posix_key_value_pairs; + uint32_t active_posix_keys; + rtems_resource_rtems_api rtems_api; + rtems_resource_posix_api posix_api; + int open_files; +} rtems_resource_snapshot; + +/** + * @brief Tasks a snapshot of the resource usage of the system. + * + * @param[out] snapshot The snapshot of used resources. + * + * @see rtems_resource_snapshot_equal() and rtems_resource_snapshot_check(). + * + * @code + * #include + * + * #include + * + * void example(void) + * { + * rtems_resource_snapshot before; + * + * test_setup(); + * rtems_resource_snapshot_take(&before); + * test(); + * assert(rtems_resource_snapshot_check(&before)); + * test_cleanup(); + * } + * @endcode + */ +void rtems_resource_snapshot_take(rtems_resource_snapshot *snapshot); + +/** + * @brief Compares two resource snapshots for equality. + * + * @param[in] a One resource snapshot. + * @param[in] b Another resource snapshot. + * + * @retval true The resource snapshots are equal. + * @retval false Otherwise. + * + * @see rtems_resource_snapshot_take(). + */ +bool rtems_resource_snapshot_equal( + const rtems_resource_snapshot *a, + const rtems_resource_snapshot *b +); + +/** + * @brief Takes a new resource snapshot and checks that it is equal to the + * given resource snapshot. + * + * @param[in] snapshot The resource snapshot used for comparison with the new + * resource snapshot. + * + * @retval true The resource snapshots are equal. + * @retval false Otherwise. + * + * @see rtems_resource_snapshot_take(). + */ +bool rtems_resource_snapshot_check(const rtems_resource_snapshot *snapshot); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/libi2c.h b/cpukit/include/rtems/libi2c.h new file mode 100644 index 0000000000..341e390760 --- /dev/null +++ b/cpukit/include/rtems/libi2c.h @@ -0,0 +1,508 @@ +/** + * @file + * + * @ingroup libi2c + * + * @brief I2C Library + */ + +#ifndef _RTEMS_LIBI2C_H +#define _RTEMS_LIBI2C_H + +/* + * Authorship + * ---------- + * This software was created by + * Till Straumann , 2005, + * Stanford Linear Accelerator Center, Stanford University. + * + * Acknowledgement of sponsorship + * ------------------------------ + * This software was produced by + * the Stanford Linear Accelerator Center, Stanford University, + * under Contract DE-AC03-76SFO0515 with the Department of Energy. + * + * Government disclaimer of liability + * ---------------------------------- + * Neither the United States nor the United States Department of Energy, + * nor any of their employees, makes any warranty, express or implied, or + * assumes any legal liability or responsibility for the accuracy, + * completeness, or usefulness of any data, apparatus, product, or process + * disclosed, or represents that its use would not infringe privately owned + * rights. + * + * Stanford disclaimer of liability + * -------------------------------- + * Stanford University makes no representations or warranties, express or + * implied, nor assumes any liability for the use of this software. + * + * Stanford disclaimer of copyright + * -------------------------------- + * Stanford University, owner of the copyright, hereby disclaims its + * copyright and all other rights in this software. Hence, anyone may + * freely use it for any purpose without restriction. + * + * Maintenance of notices + * ---------------------- + * In the interest of clarity regarding the origin and status of this + * SLAC software, this and all the preceding Stanford University notices + * are to remain affixed to any copy or derivative of this software made + * or distributed by the recipient and are to be affixed to any copy of + * software made or distributed by the recipient that contains a copy or + * derivative of this software. + * + * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03 + */ + +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup libi2c I2C Library + * + * @brief I2C library. + * + */ +/**@{**/ + +/* Simple I2C driver API */ + +/* Initialize the libary - may fail if no semaphore or no driver slot is available */ +extern int rtems_libi2c_initialize (void); + +/* Alternatively to rtems_libi2c_initialize() the library can also be + * initialized by means of a traditional driver table entry containing + * the following entry points: + */ +extern rtems_status_code +rtems_i2c_init ( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg); + +extern rtems_status_code +rtems_i2c_open ( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg); + +extern rtems_status_code +rtems_i2c_close ( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg); + +extern rtems_status_code +rtems_i2c_read ( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg); + +extern rtems_status_code +rtems_i2c_write ( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg); + +extern rtems_status_code +rtems_i2c_ioctl ( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg); + +extern const rtems_driver_address_table rtems_libi2c_io_ops; + +/* Unfortunately, if you want to add this driver to + * a RTEMS configuration table then you need all the + * members explicitly :-( (Device_driver_table should + * hold pointers to rtems_driver_address_tables rather + * than full structs). + * + * The difficulty is that adding this driver to the + * configuration table is not enough; you still need + * to populate the framework with low-level bus-driver(s) + * and high-level drivers and/or device-files... + * + * Currently the preferred way is having the BSP + * call 'rtems_libi2c_initialize' followed by + * 'rtems_libi2c_register_bus' and + * 'rtems_libi2c_register_drv' and/or + * 'mknod' (for 'raw' device nodes) + * from the 'bsp_predriver_hook'. + */ +#define RTEMS_LIBI2C_DRIVER_TABLE_ENTRY \ +{ \ + initialization_entry: rtems_i2c_init, \ + open_entry: rtems_i2c_open, \ + close_entry: rtems_i2c_close, \ + read_entry: rtems_i2c_read, \ + write_entry: rtems_i2c_write, \ + control_entry: rtems_i2c_ioctl, \ +} + +/* Bus Driver API + * + * Bus drivers provide access to low-level i2c functions + * such as 'send start', 'send address', 'get bytes' etc. + */ + +/* first field must be a pointer to ops; driver + * may add its own fields after this. + * the struct that is registered with the library + * is not copied; a pointer will we passed + * to the callback functions (ops). + */ +typedef struct rtems_libi2c_bus_t_ +{ + const struct rtems_libi2c_bus_ops_ *ops; + int size; /* size of whole structure */ +} rtems_libi2c_bus_t; + +/* Access functions a low level driver must provide; + * + * All of these, except read_bytes and write_bytes + * return RTEMS_SUCCESSFUL on success and an error status + * otherwise. The read and write ops return the number + * of chars read/written or -(status code) on error. + */ +typedef struct rtems_libi2c_bus_ops_ +{ + /* Initialize the bus; might be called again to reset the bus driver */ + rtems_status_code (*init) (rtems_libi2c_bus_t * bushdl); + /* Send start condition */ + rtems_status_code (*send_start) (rtems_libi2c_bus_t * bushdl); + /* Send stop condition */ + rtems_status_code (*send_stop) (rtems_libi2c_bus_t * bushdl); + /* initiate transfer from (rw!=0) or to a device */ + rtems_status_code (*send_addr) (rtems_libi2c_bus_t * bushdl, + uint32_t addr, int rw); + /* read a number of bytes */ + int (*read_bytes) (rtems_libi2c_bus_t * bushdl, unsigned char *bytes, + int nbytes); + /* write a number of bytes */ + int (*write_bytes) (rtems_libi2c_bus_t * bushdl, unsigned char *bytes, + int nbytes); + /* ioctl misc functions */ + int (*ioctl) (rtems_libi2c_bus_t * bushdl, + int cmd, + void *buffer + ); +} rtems_libi2c_bus_ops_t; + + +/* + * Register a lowlevel driver + * + * TODO: better description + * + * This allocates a major number identifying *this* driver + * (i.e., libi2c) and the minor number encodes a bus# and a i2c address. + * + * The name will be registered in the filesystem (parent + * directories must exist, also IMFS filesystem must exist). It may be NULL in + * which case the library will pick a default. + * + * RETURNS: bus # (>=0) or -1 on error (errno set). + */ + +extern int rtems_libi2c_register_bus (const char *name, rtems_libi2c_bus_t * bus); + +extern rtems_device_major_number rtems_libi2c_major; + +#define RTEMS_LIBI2C_MAKE_MINOR(busno, i2caddr) \ + ((((busno)&((1<<3)-1))<<10) | ((i2caddr)&((1<<10)-1))) + +/* After the library is initialized, a major number is available. + * As soon as a low-level bus driver is registered (above routine + * returns a 'busno'), a device node can be created in the filesystem + * with a major/minor number pair of + * + * rtems_libi2c_major / RTEMS_LIBI2C_MAKE_MINOR(busno, i2caddr) + * + * and a 'raw' hi-level driver is then attached to this device + * node. + * This 'raw' driver has very simple semantics: + * + * 'open' sends a start condition + * 'read'/'write' address the device identified by the i2c bus# and address + * encoded in the minor number and read or write, respectively + * a stream of bytes from or to the device. Every time the + * direction is changed, a 're-start' condition followed by + * an 'address' cycle is generated on the i2c bus. + * 'close' sends a stop condition. + * + * Hence, using the 'raw' driver, e.g., 100 bytes at offset 0x200 can be + * read from an EEPROM by the following pseudo-code: + * + * mknod("/dev/i2c-54", mode, MKDEV(rtems_libi2c_major, RTEMS_LIBI2C_MAKE_MINOR(0,0x54))) + * + * int fd; + * char off[2]={0x02,0x00}; + * + * fd = open("/dev/i2c-54",O_RDWR); + * write(fd,off,2); + * read(fd,buf,100); + * close(fd); + * + */ + +/* Higher Level Driver API + * + * Higher level drivers know how to deal with specific i2c + * devices (independent of the bus interface chip) and provide + * an abstraction, i.e., the usual read/write/ioctl access. + * + * Using the above example, such a high level driver could + * prevent the user from issuing potentially destructive write + * operations (the aforementioned EEPROM interprets any 3rd + * and following byte written to the device as data, i.e., the + * contents could easily be changed!). + * The correct 'read-pointer offset' programming could be + * implemented in 'open' and 'ioctl' of a high-level driver and + * the user would then only have to perform harmless read + * operations, e.g., + * + * fd = open("/dev/i2c.eeprom",O_RDONLY) / * opens and sets EEPROM read pointer * / + * ioctl(fd, IOCTL_SEEK, 0x200) / * repositions the read pointer * / + * read(fd, buf, 100) + * close(fd) + * + */ + +/* struct provided at driver registration. The driver may store + * private data behind the mandatory first fields but the size + * must be set to the size of the entire struct, e.g., + * + * struct driver_pvt { + * rtems_libi2c_drv_t pub; + * struct { ... } pvt; + * } my_driver = { + * { ops: my_ops, + * size: sizeof(my_driver) + * }, + * { ...}; + * }; + * + * A pointer to this struct is passed to the callback ops. + */ + +typedef struct rtems_libi2c_drv_t_ +{ + const rtems_driver_address_table *ops; /* the driver ops */ + int size; /* size of whole structure (including appended private data) */ +} rtems_libi2c_drv_t; + +/* + * The high level driver must be registered with a particular + * bus number and i2c address. + * + * The registration procedure also creates a filesystem node, + * i.e., the returned minor number is not really needed. + * + * If the 'name' argument is NULL, no filesystem node is + * created (but this can be done 'manually' using rtems_libi2c_major + * and the return value of this routine). + * + * RETURNS minor number (FYI) or -1 on failure + */ +extern int +rtems_libi2c_register_drv (const char *name, rtems_libi2c_drv_t * drvtbl, + unsigned bus, unsigned i2caddr); + +/* Operations available to high level drivers */ + +/* NOTES: The bus a device is attached to is LOCKED from the first send_start + * until send_stop is executed! + * + * Bus tenure MUST NOT span multiple system calls - otherwise, a single + * thread could get into the protected sections (or would deadlock if the + * mutex was not nestable). + * E.g., consider what happens if 'open' sends a 'start' and 'close' + * sends a 'stop' (i.e., the bus mutex would be locked in 'open' and + * released in 'close'. A single thread could try to open two devices + * on the same bus and would either deadlock or nest into the bus mutex + * and potentially mess up the i2c messages. + * + * The correct way is to *always* relinquish the i2c bus (i.e., send 'stop' + * from any driver routine prior to returning control to the caller. + * Consult the implementation of the generic driver routines (open, close, ...) + * below or the examples in i2c-2b-eeprom.c and i2c-2b-ds1621.c + * + * Drivers just pass the minor number on to these routines... + */ +extern rtems_status_code rtems_libi2c_send_start (rtems_device_minor_number minor); + +extern rtems_status_code rtems_libi2c_send_stop (rtems_device_minor_number minor); + +extern rtems_status_code +rtems_libi2c_send_addr (rtems_device_minor_number minor, int rw); + +/* the read/write routines return the number of bytes transferred + * or -(status_code) on error. + */ +extern int +rtems_libi2c_read_bytes (rtems_device_minor_number minor, + unsigned char *bytes, int nbytes); + +extern int +rtems_libi2c_write_bytes (rtems_device_minor_number minor, + const unsigned char *bytes, int nbytes); + +/* Send start, send address and read bytes */ +extern int +rtems_libi2c_start_read_bytes (rtems_device_minor_number minor, + unsigned char *bytes, + int nbytes); + +/* Send start, send address and write bytes */ +extern int +rtems_libi2c_start_write_bytes (rtems_device_minor_number minor, + const unsigned char *bytes, + int nbytes); + + +/* call misc iocontrol function */ +extern int +rtems_libi2c_ioctl (rtems_device_minor_number minor, + int cmd, + ...); +/* + * NOTE: any low-level driver ioctl returning a negative + * result for release the bus (perform a STOP condition) + */ +/******************************* + * defined IOCTLs: + *******************************/ +#define RTEMS_LIBI2C_IOCTL_READ_WRITE 1 +/* + * retval = rtems_libi2c_ioctl(rtems_device_minor_number minor, + * RTEMS_LIBI2C_IOCTL_READ_WRITE, + * rtems_libi2c_read_write_t *arg); + * + * This call performs a simultanous read/write transfer, + * which is possible (and sometimes needed) for SPI devices + * + * arg is a pointer to a rd_wr info data structure + * + * This call is only needed for SPI devices + */ +#define RTEMS_LIBI2C_IOCTL_START_TFM_READ_WRITE 2 +/* + * retval = rtems_libi2c_ioctl(rtems_device_minor_number minor, + * RTEMS_LIBI2C_IOCTL_START_READ_WRITE, + * unsigned char *rd_buffer, + * const unsigned char *wr_buffer, + * int byte_cnt, + * const rtems_libi2c_tfr_mode_t *tfr_mode_ptr); + * + * This call addresses a slave and then: + * - sets the proper transfer mode, + * - performs a simultanous read/write transfer, + * (which is possible and sometimes needed for SPI devices) + * NOTE: - if rd_buffer is NULL, receive data will be dropped + * - if wr_buffer is NULL, bytes with content 0 will transmitted + * + * rd_buffer is a pointer to a receive buffer (or NULL) + * wr_buffer is a pointer to the data to be sent (or NULL) + * + * This call is only needed for SPI devices + */ + +#define RTEMS_LIBI2C_IOCTL_SET_TFRMODE 3 +/* + * retval = rtems_libi2c_ioctl(rtems_device_minor_number minor, + * RTEMS_LIBI2C_IOCTL_SET_TFRMODE, + * const rtems_libi2c_tfr_mode_t *tfr_mode_ptr); + * + * This call sets an SPI device to the transfer mode needed (baudrate etc.) + * + * tfr_mode is a pointer to a structure defining the SPI transfer mode needed + * (see below). + * + * This call is only needed for SPI devices + */ + +#define RTEMS_LIBI2C_IOCTL_GET_DRV_T 4 + +/* + * retval = rtems_libi2c_ioctl(rtems_device_minor_number minor, + * RTEMS_LIBI2C_IOCTL_GET_DRV_T, + * const rtems_libi2c_drv_t *drv_t_ptr); + * + * This call allows the a high-level driver to query its driver table entry, + * including its private data appended to it during creation of the entry + * + */ + +/** + * @brief IO control command for asynchronous read and write. + * + * @see rtems_libi2c_read_write_done_t and rtems_libi2c_read_write_async_t. + * + * @warning This is work in progress! + */ +#define RTEMS_LIBI2C_IOCTL_READ_WRITE_ASYNC 5 + +/* + * argument data structures for IOCTLs defined above + */ +typedef struct { + unsigned char *rd_buf; + const unsigned char *wr_buf; + int byte_cnt; +} rtems_libi2c_read_write_t; + +typedef struct { + uint32_t baudrate; /* maximum bits per second */ + /* only valid for SPI drivers: */ + uint8_t bits_per_char; /* how many bits per byte/word/longword? */ + bool lsb_first; /* true: send LSB first */ + bool clock_inv; /* true: inverted clock (high active) */ + bool clock_phs; /* true: clock starts toggling at start of data tfr */ + uint32_t idle_char; /* This character will be continuously transmitted in read only functions */ +} rtems_libi2c_tfr_mode_t; + +typedef struct { + rtems_libi2c_tfr_mode_t tfr_mode; + rtems_libi2c_read_write_t rd_wr; +} rtems_libi2c_tfm_read_write_t; + +/** + * @brief Notification function type for asynchronous read and write. + * + * @see RTEMS_LIBI2C_IOCTL_READ_WRITE_ASYNC and + * rtems_libi2c_read_write_async_t. + * + * @warning This is work in progress! + */ +typedef void (*rtems_libi2c_read_write_done_t) \ + ( int /* return value */, int /* nbytes */, void * /* arg */); + +/** + * @brief IO command data for asynchronous read and write. + * + * @see RTEMS_LIBI2C_IOCTL_READ_WRITE_ASYNC and + * rtems_libi2c_read_write_done_t. + * + * @warning This is work in progress! + */ +typedef struct { + unsigned char *rd_buf; + const unsigned char *wr_buf; + int byte_cnt; + rtems_libi2c_read_write_done_t done; + void *arg; +} rtems_libi2c_read_write_async_t; + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/include/rtems/libio.h b/cpukit/include/rtems/libio.h new file mode 100644 index 0000000000..9d30dafddf --- /dev/null +++ b/cpukit/include/rtems/libio.h @@ -0,0 +1,1967 @@ +/** + * @file + * + * @ingroup LibIO + * + * @brief Basic IO API + * + * This file contains the support infrastructure used to manage the + * table of integer style file descriptors used by the low level + * POSIX system calls like open(), read, fstat(), etc. + */ + +/* + * COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * Modifications to support reference counting in the file system are + * Copyright (c) 2012 embedded brains GmbH. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_LIBIO_H +#define _RTEMS_RTEMS_LIBIO_H + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct knote; + +/** + * @defgroup LibIOFSOps File System Operations + * + * @ingroup LibIO + * + * @brief File system operations. + */ +/**@{**/ + +/** + * @brief Locks a file system instance. + * + * This lock must allow nesting. + * + * @param[in, out] mt_entry The mount table entry of the file system instance. + * + * @see rtems_filesystem_default_lock(). + */ +typedef void (*rtems_filesystem_mt_entry_lock_t)( + const rtems_filesystem_mount_table_entry_t *mt_entry +); + +/** + * @brief Unlocks a file system instance. + * + * @param[in, out] mt_entry The mount table entry of the file system instance. + * + * @see rtems_filesystem_default_unlock(). + */ +typedef void (*rtems_filesystem_mt_entry_unlock_t)( + const rtems_filesystem_mount_table_entry_t *mt_entry +); + +/** + * @brief Path evaluation context. + */ +typedef struct { + /** + * The contents of the remaining path to be evaluated. + */ + const char *path; + + /** + * The length of the remaining path to be evaluated. + */ + size_t pathlen; + + /** + * The contents of the token to be evaluated with respect to the current + * location. + */ + const char *token; + + /** + * The length of the token to be evaluated with respect to the current + * location. + */ + size_t tokenlen; + + /** + * The path evaluation is controlled by the following flags + * - RTEMS_FS_PERMS_READ, + * - RTEMS_FS_PERMS_WRITE, + * - RTEMS_FS_PERMS_EXEC, + * - RTEMS_FS_FOLLOW_HARD_LINK, + * - RTEMS_FS_FOLLOW_SYM_LINK, + * - RTEMS_FS_MAKE, + * - RTEMS_FS_EXCLUSIVE, + * - RTEMS_FS_ACCEPT_RESIDUAL_DELIMITERS, and + * - RTEMS_FS_REJECT_TERMINAL_DOT. + */ + int flags; + + /** + * Symbolic link evaluation is a recursive operation. This field helps to + * limit the recursion level and thus prevents a stack overflow. The + * recursion level is limited by RTEMS_FILESYSTEM_SYMLOOP_MAX. + */ + int recursionlevel; + + /** + * This is the current file system location of the evaluation process. + * Tokens are evaluated with respect to the current location. The token + * interpretation may change the current location. The purpose of the path + * evaluation is to change the start location into a final current location + * according to the path. + */ + rtems_filesystem_location_info_t currentloc; + + /** + * The location of the root directory of the user environment during the + * evaluation start. + */ + rtems_filesystem_global_location_t *rootloc; + + /** + * The start location of the evaluation process. The start location my + * change during symbolic link evaluation. + */ + rtems_filesystem_global_location_t *startloc; +} rtems_filesystem_eval_path_context_t; + +/** + * @brief Path evaluation. + * + * @param[in, out] ctx The path evaluation context. + * + * @see rtems_filesystem_default_eval_path(). + */ +typedef void (*rtems_filesystem_eval_path_t)( + rtems_filesystem_eval_path_context_t *ctx +); + +/** + * @brief Creates a new link for the existing file. + * + * @param[in] parentloc The location of the parent of the new link. + * @param[in] targetloc The location of the target file. + * @param[in] name Name for the new link. + * @param[in] namelen Length of the name for the new link in characters. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The errno is set to indicate the error. + * + * @see rtems_filesystem_default_link(). + */ +typedef int (*rtems_filesystem_link_t)( + const rtems_filesystem_location_info_t *parentloc, + const rtems_filesystem_location_info_t *targetloc, + const char *name, + size_t namelen +); + +/** + * @brief Changes the mode of a node. + * + * @param[in] loc The location of the node. + * @param[in] mode The new mode of the node + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The errno is set to indicate the error. + * + * @see rtems_filesystem_default_fchmod(). + */ +typedef int (*rtems_filesystem_fchmod_t)( + const rtems_filesystem_location_info_t *loc, + mode_t mode +); + +/** + * @brief Changes owner and group of a node. + * + * @param[in] loc The location of the node. + * @param[in] owner User ID for the node. + * @param[in] group Group ID for the node. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The errno is set to indicate the error. + * + * @see rtems_filesystem_default_chown(). + */ +typedef int (*rtems_filesystem_chown_t)( + const rtems_filesystem_location_info_t *loc, + uid_t owner, + gid_t group +); + +/** + * @brief Clones a location. + * + * The location is initialized with a bitwise copy of an existing location. + * The caller must ensure that this location is protected from a release during + * the clone operation. After a successful clone operation the clone will be + * added to the location chain of the corresponding mount table entry. + * + * @param[in, out] loc Location to clone. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The errno is set to indicate the error. + * + * @see rtems_filesystem_default_clonenode(). + */ +typedef int (*rtems_filesystem_clonenode_t)( + rtems_filesystem_location_info_t *loc +); + +/** + * @brief Frees the location of a node. + * + * @param[in] loc The location of the node. + * + * @see rtems_filesystem_default_freenode(). + */ +typedef void (*rtems_filesystem_freenode_t)( + const rtems_filesystem_location_info_t *loc +); + +/** + * @brief Mounts a file system instance in a mount point (directory). + * + * The mount point belongs to the file system instance of the handler and is + * specified by a field of the mount table entry. The handler must check that + * the mount point is capable of mounting a file system instance. This is the + * last step during the mount process. The file system instance is fully + * initialized at this point. + * + * @param[in] mt_entry The mount table entry. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The errno is set to indicate the error. + * + * @see rtems_filesystem_default_mount(). + */ +typedef int (*rtems_filesystem_mount_t) ( + rtems_filesystem_mount_table_entry_t *mt_entry +); + +/** + * @brief Initializes a file system instance. + * + * This function must initialize the file system root node in the mount table + * entry. + * + * @param[in] mt_entry The mount table entry. + * @param[in] data The data provided by the user. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The errno is set to indicate the error. + */ +typedef int (*rtems_filesystem_fsmount_me_t)( + rtems_filesystem_mount_table_entry_t *mt_entry, + const void *data +); + +/** + * @brief Unmounts a file system instance in a mount point (directory). + * + * In case this function is successful the file system instance will be marked + * as unmounted. The file system instance will be destroyed when the last + * reference to it vanishes. + * + * @param[in] mt_entry The mount table entry. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The errno is set to indicate the error. + * + * @see rtems_filesystem_default_unmount(). + */ +typedef int (*rtems_filesystem_unmount_t) ( + rtems_filesystem_mount_table_entry_t *mt_entry +); + +/** + * @brief Destroys a file system instance. + * + * The mount point node location of the mount table entry is invalid. This + * handler must free the file system root location and all remaining resources + * of the file system instance. + * + * @param[in] mt_entry The mount table entry. + * + * @see rtems_filesystem_default_fsunmount(). + */ +typedef void (*rtems_filesystem_fsunmount_me_t)( + rtems_filesystem_mount_table_entry_t *mt_entry +); + +/** + * @brief Tests if the node of one location is equal to the node of the other + * location. + * + * The caller ensures that both nodes are within the same file system instance. + * + * @param[in] a The one location. + * @param[in] b The other location. + * + * @retval true The nodes of the locations are equal. + * @retval false Otherwise. + * + * @see rtems_filesystem_default_are_nodes_equal(). + */ +typedef bool (*rtems_filesystem_are_nodes_equal_t)( + const rtems_filesystem_location_info_t *a, + const rtems_filesystem_location_info_t *b +); + +/** + * @brief Creates a new node. + * + * This handler should create a new node according to the parameters. + * + * @param[in] parentloc The location of the parent of the new node. + * @param[in] name Name for the new node. + * @param[in] namelen Length of the name for the new node in characters. + * @param[in] mode Mode for the new node. + * @param[in] dev Optional device identifier for the new node. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The errno is set to indicate the error. + * + * @see rtems_filesystem_default_mknod(). + */ +typedef int (*rtems_filesystem_mknod_t)( + const rtems_filesystem_location_info_t *parentloc, + const char *name, + size_t namelen, + mode_t mode, + dev_t dev +); + +/** + * @brief Removes a node. + * + * @param[in] parentloc The location of the parent of the node. + * @param[in] loc The location of the node. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The errno is set to indicate the error. + * + * @see rtems_filesystem_default_rmnod(). + */ +typedef int (*rtems_filesystem_rmnod_t)( + const rtems_filesystem_location_info_t *parentloc, + const rtems_filesystem_location_info_t *loc +); + +/** + * @brief Set node access and modification times. + * + * @param[in] loc The location of the node. + * @param[in] actime Access time for the node. + * @param[in] modtime Modification for the node. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The errno is set to indicate the error. + * + * @see rtems_filesystem_default_utime(). + */ +typedef int (*rtems_filesystem_utime_t)( + const rtems_filesystem_location_info_t *loc, + time_t actime, + time_t modtime +); + +/** + * @brief Makes a symbolic link to a node. + * + * @param[in] parentloc The location of the parent of the new symbolic link. + * @param[in] name Name for the new symbolic link. + * @param[in] namelen Length of the name for the new symbolic link in + * characters. + * @param[in] target Contents for the symbolic link. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The errno is set to indicate the error. + * + * @see rtems_filesystem_default_symlink(). + */ +typedef int (*rtems_filesystem_symlink_t)( + const rtems_filesystem_location_info_t *parentloc, + const char *name, + size_t namelen, + const char *target +); + +/** + * @brief Reads the contents of a symbolic link. + * + * @param[in] loc The location of the symbolic link. + * @param[out] buf The buffer for the contents. + * @param[in] bufsize The size of the buffer in characters. + * + * @retval non-negative Size of the actual contents in characters. + * @retval -1 An error occurred. The errno is set to indicate the error. + * + * @see rtems_filesystem_default_readlink(). + */ +typedef ssize_t (*rtems_filesystem_readlink_t)( + const rtems_filesystem_location_info_t *loc, + char *buf, + size_t bufsize +); + +/** + * @brief Renames a node. + * + * @param[in] oldparentloc The location of the parent of the old node. + * @param[in] oldloc The location of the old node. + * @param[in] newparentloc The location of the parent of the new node. + * @param[in] name Name for the new node. + * @param[in] namelen Length of the name for the new node in characters. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The errno is set to indicate the error. + * + * @see rtems_filesystem_default_rename(). + */ +typedef int (*rtems_filesystem_rename_t)( + const rtems_filesystem_location_info_t *oldparentloc, + const rtems_filesystem_location_info_t *oldloc, + const rtems_filesystem_location_info_t *newparentloc, + const char *name, + size_t namelen +); + +/** + * @brief Gets file system information. + * + * @param[in] loc The location of a node. + * @param[out] buf Buffer for file system information. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The errno is set to indicate the error. + * + * @see rtems_filesystem_default_statvfs(). + */ +typedef int (*rtems_filesystem_statvfs_t)( + const rtems_filesystem_location_info_t *loc, + struct statvfs *buf +); + +/** + * @brief File system operations table. + */ +struct _rtems_filesystem_operations_table { + rtems_filesystem_mt_entry_lock_t lock_h; + rtems_filesystem_mt_entry_unlock_t unlock_h; + rtems_filesystem_eval_path_t eval_path_h; + rtems_filesystem_link_t link_h; + rtems_filesystem_are_nodes_equal_t are_nodes_equal_h; + rtems_filesystem_mknod_t mknod_h; + rtems_filesystem_rmnod_t rmnod_h; + rtems_filesystem_fchmod_t fchmod_h; + rtems_filesystem_chown_t chown_h; + rtems_filesystem_clonenode_t clonenod_h; + rtems_filesystem_freenode_t freenod_h; + rtems_filesystem_mount_t mount_h; + rtems_filesystem_unmount_t unmount_h; + rtems_filesystem_fsunmount_me_t fsunmount_me_h; + rtems_filesystem_utime_t utime_h; + rtems_filesystem_symlink_t symlink_h; + rtems_filesystem_readlink_t readlink_h; + rtems_filesystem_rename_t rename_h; + rtems_filesystem_statvfs_t statvfs_h; +}; + +/** + * @brief File system operations table with default operations. + */ +extern const rtems_filesystem_operations_table + rtems_filesystem_operations_default; + +/** + * @brief Obtains the IO library mutex. + * + * @see rtems_filesystem_mt_entry_lock_t. + */ +void rtems_filesystem_default_lock( + const rtems_filesystem_mount_table_entry_t *mt_entry +); + +/** + * @brief Releases the IO library mutex. + * + * @see rtems_filesystem_mt_entry_unlock_t. + */ +void rtems_filesystem_default_unlock( + const rtems_filesystem_mount_table_entry_t *mt_entry +); + +/** + * @brief Terminates the path evaluation and replaces the current location with + * the null location. + * + * @see rtems_filesystem_eval_path_t. + */ +void rtems_filesystem_default_eval_path( + rtems_filesystem_eval_path_context_t *ctx +); + +/** + * @retval -1 Always. The errno is set to ENOTSUP. + * + * @see rtems_filesystem_link_t. + */ +int rtems_filesystem_default_link( + const rtems_filesystem_location_info_t *parentloc, + const rtems_filesystem_location_info_t *targetloc, + const char *name, + size_t namelen +); + +/** + * @brief Tests if the node access pointer of one location is equal to + * the node access pointer of the other location. + * + * @param[in] a The one location. + * @param[in] b The other location. + * + * @retval true The node access pointers of the locations are equal. + * @retval false Otherwise. + * + * @see rtems_filesystem_are_nodes_equal_t. + */ +bool rtems_filesystem_default_are_nodes_equal( + const rtems_filesystem_location_info_t *a, + const rtems_filesystem_location_info_t *b +); + +/** + * @retval -1 Always. The errno is set to ENOTSUP. + * + * @see rtems_filesystem_mknod_t. + */ +int rtems_filesystem_default_mknod( + const rtems_filesystem_location_info_t *parentloc, + const char *name, + size_t namelen, + mode_t mode, + dev_t dev +); + +/** + * @retval -1 Always. The errno is set to ENOTSUP. + * + * @see rtems_filesystem_rmnod_t. + */ +int rtems_filesystem_default_rmnod( + const rtems_filesystem_location_info_t *parentloc, + const rtems_filesystem_location_info_t *loc +); + +/** + * @retval -1 Always. The errno is set to ENOTSUP. + * + * @see rtems_filesystem_fchmod_t. + */ +int rtems_filesystem_default_fchmod( + const rtems_filesystem_location_info_t *loc, + mode_t mode +); + +/** + * @retval -1 Always. The errno is set to ENOTSUP. + * + * @see rtems_filesystem_chown_t. + */ +int rtems_filesystem_default_chown( + const rtems_filesystem_location_info_t *loc, + uid_t owner, + gid_t group +); + +/** + * @retval 0 Always. + * + * @see rtems_filesystem_clonenode_t. + */ +int rtems_filesystem_default_clonenode( + rtems_filesystem_location_info_t *loc +); + +/** + * @see rtems_filesystem_freenode_t. + */ +void rtems_filesystem_default_freenode( + const rtems_filesystem_location_info_t *loc +); + +/** + * @retval -1 Always. The errno is set to ENOTSUP. + * + * @see rtems_filesystem_mount_t. + */ +int rtems_filesystem_default_mount ( + rtems_filesystem_mount_table_entry_t *mt_entry /* IN */ +); + +/** + * @retval -1 Always. The errno is set to ENOTSUP. + * + * @see rtems_filesystem_unmount_t. + */ +int rtems_filesystem_default_unmount( + rtems_filesystem_mount_table_entry_t *mt_entry /* IN */ +); + +/** + * @retval -1 Always. The errno is set to ENOTSUP. + * + * @see rtems_filesystem_fsunmount_me_t. + */ +void rtems_filesystem_default_fsunmount( + rtems_filesystem_mount_table_entry_t *mt_entry /* IN */ +); + +/** + * @retval -1 Always. The errno is set to ENOTSUP. + * + * @see rtems_filesystem_utime_t. + */ +int rtems_filesystem_default_utime( + const rtems_filesystem_location_info_t *loc, + time_t actime, + time_t modtime +); + +/** + * @retval -1 Always. The errno is set to ENOTSUP. + * + * @see rtems_filesystem_symlink_t. + */ +int rtems_filesystem_default_symlink( + const rtems_filesystem_location_info_t *parentloc, + const char *name, + size_t namelen, + const char *target +); + +/** + * @retval -1 Always. The errno is set to ENOTSUP. + * + * @see rtems_filesystem_readlink_t. + */ +ssize_t rtems_filesystem_default_readlink( + const rtems_filesystem_location_info_t *loc, + char *buf, + size_t bufsize +); + +/** + * @retval -1 Always. The errno is set to ENOTSUP. + * + * @see rtems_filesystem_rename_t. + */ +int rtems_filesystem_default_rename( + const rtems_filesystem_location_info_t *oldparentloc, + const rtems_filesystem_location_info_t *oldloc, + const rtems_filesystem_location_info_t *newparentloc, + const char *name, + size_t namelen +); + +/** + * @retval -1 Always. The errno is set to ENOTSUP. + * + * @see rtems_filesystem_statvfs_t. + */ +int rtems_filesystem_default_statvfs( + const rtems_filesystem_location_info_t *loc, + struct statvfs *buf +); + +/** @} */ + +/** + * @defgroup LibIOFSHandler File System Node Handler + * + * @ingroup LibIO + * + * @brief File system node handler. + */ +/**@{**/ + +/** + * @brief Opens a node. + * + * @param[in, out] iop The IO pointer. + * @param[in] path The path. + * @param[in] oflag The open flags. + * @param[in] mode Optional mode for node creation. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The errno is set to indicate the error. + * + * @see rtems_filesystem_default_open(). + */ +typedef int (*rtems_filesystem_open_t)( + rtems_libio_t *iop, + const char *path, + int oflag, + mode_t mode +); + +/** + * @brief Closes a node. + * + * @param[in, out] iop The IO pointer. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The errno is set to indicate the error. + * + * @see rtems_filesystem_default_close(). + */ +typedef int (*rtems_filesystem_close_t)( + rtems_libio_t *iop +); + +/** + * @brief Reads from a node. + * + * This handler is responsible to update the offset field of the IO descriptor. + * + * @param[in, out] iop The IO pointer. + * @param[out] buffer The buffer for read data. + * @param[in] count The size of the buffer in characters. + * + * @retval non-negative Count of read characters. + * @retval -1 An error occurred. The errno is set to indicate the error. + * + * @see rtems_filesystem_default_read(). + */ +typedef ssize_t (*rtems_filesystem_read_t)( + rtems_libio_t *iop, + void *buffer, + size_t count +); + +/** + * @brief Reads an IO vector from a node. + * + * This handler is responsible to update the offset field of the IO descriptor. + * + * @param[in, out] iop The IO pointer. + * @param[in] iov The IO vector with buffer for read data. The caller must + * ensure that the IO vector values are valid. + * @param[in] iovcnt The count of buffers in the IO vector. + * @param[in] total The total count of bytes in the buffers in the IO vector. + * + * @retval non-negative Count of read characters. + * @retval -1 An error occurred. The errno is set to indicate the error. + * + * @see rtems_filesystem_default_readv(). + */ +typedef ssize_t (*rtems_filesystem_readv_t)( + rtems_libio_t *iop, + const struct iovec *iov, + int iovcnt, + ssize_t total +); + +/** + * @brief Writes to a node. + * + * This handler is responsible to update the offset field of the IO descriptor. + * + * @param[in, out] iop The IO pointer. + * @param[out] buffer The buffer for write data. + * @param[in] count The size of the buffer in characters. + * + * @retval non-negative Count of written characters. + * @retval -1 An error occurred. The errno is set to indicate the error. + * + * @see rtems_filesystem_default_write(). + */ +typedef ssize_t (*rtems_filesystem_write_t)( + rtems_libio_t *iop, + const void *buffer, + size_t count +); + +/** + * @brief Writes an IO vector to a node. + * + * This handler is responsible to update the offset field of the IO descriptor. + * + * @param[in, out] iop The IO pointer. + * @param[in] iov The IO vector with buffer for write data. The caller must + * ensure that the IO vector values are valid. + * @param[in] iovcnt The count of buffers in the IO vector. + * @param[in] total The total count of bytes in the buffers in the IO vector. + * + * @retval non-negative Count of written characters. + * @retval -1 An error occurred. The errno is set to indicate the error. + * + * @see rtems_filesystem_default_writev(). + */ +typedef ssize_t (*rtems_filesystem_writev_t)( + rtems_libio_t *iop, + const struct iovec *iov, + int iovcnt, + ssize_t total +); + +/** + * @brief IO control of a node. + * + * @param[in, out] iop The IO pointer. + * @param[in] request The IO control request. + * @param[in, out] buffer The buffer for IO control request data. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The errno is set to indicate the error. + * + * @see rtems_filesystem_default_ioctl(). + */ +typedef int (*rtems_filesystem_ioctl_t)( + rtems_libio_t *iop, + ioctl_command_t request, + void *buffer +); + +/** + * @brief Moves the read/write file offset. + * + * @param[in, out] iop The IO pointer. + * @param[in] offset The offset. + * @param[in] whence The reference position for the offset. + * + * @retval non-negative The new offset from the beginning of the file. + * @retval -1 An error occurred. The errno is set to indicate the error. + * + * @see rtems_filesystem_default_lseek(), + * rtems_filesystem_default_lseek_file(), and + * rtems_filesystem_default_lseek_directory(). + */ +typedef off_t (*rtems_filesystem_lseek_t)( + rtems_libio_t *iop, + off_t offset, + int whence +); + +/** + * @brief Gets a node status. + * + * @param[in, out] iop The IO pointer. + * @param[out] stat The buffer to status information. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The errno is set to indicate the error. + * + * @see rtems_filesystem_default_fstat(). + */ +typedef int (*rtems_filesystem_fstat_t)( + const rtems_filesystem_location_info_t *loc, + struct stat *buf +); + +/** + * @brief Truncates a file to a specified length. + * + * @param[in, out] iop The IO pointer. + * @param[in] length The new length in characters. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The errno is set to indicate the error. + * + * @see rtems_filesystem_default_ftruncate() and + * rtems_filesystem_default_ftruncate_directory(). + */ +typedef int (*rtems_filesystem_ftruncate_t)( + rtems_libio_t *iop, + off_t length +); + +/** + * @brief Synchronizes changes to a file. + * + * @param[in, out] iop The IO pointer. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The errno is set to indicate the error. + * + * @see rtems_filesystem_default_fsync_or_fdatasync() and + * rtems_filesystem_default_fsync_or_fdatasync_success(). + */ +typedef int (*rtems_filesystem_fsync_t)( + rtems_libio_t *iop +); + +/** + * @brief Synchronizes the data of a file. + * + * @param[in, out] iop The IO pointer. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The errno is set to indicate the error. + * + * @see rtems_filesystem_default_fsync_or_fdatasync() and + * rtems_filesystem_default_fsync_or_fdatasync_success(). + */ +typedef int (*rtems_filesystem_fdatasync_t)( + rtems_libio_t *iop +); + +/** + * @brief File control. + * + * @param[in, out] iop The IO pointer. + * @param[in] cmd Control command. + * + * @retval 0 Successful operation. + * @retval errno An error occurred. This value is assigned to errno. + * + * @see rtems_filesystem_default_fcntl(). + */ +typedef int (*rtems_filesystem_fcntl_t)( + rtems_libio_t *iop, + int cmd +); + +/** + * @brief Poll and select support. + * + * @param[in, out] iop The IO pointer. + * @param[in] events The poll events. + * + * @return The poll return events. + * + * @see rtems_filesystem_default_poll(). + */ +typedef int (*rtems_filesystem_poll_t)( + rtems_libio_t *iop, + int events +); + +/** + * @brief Kernel event filter support. + * + * @param[in, out] iop The IO pointer. + * @param[in] kn The kernel event note. + * + * @retval 0 Successful operation. + * @retval error An error occurred. This is usually EINVAL. + * + * @see rtems_filesystem_default_kqfilter(). + */ +typedef int (*rtems_filesystem_kqfilter_t)( + rtems_libio_t *iop, + struct knote *kn +); + +/** + * @brief MMAP support. + * + * @param[in, out] iop The IO pointer. + * @param[in, out] addr The starting address of the mapped memory. + * @param[in] len The maximum number of bytes to map. + * @param[in] prot The desired memory protection. + * @param[in] off The offset within the file descriptor to map. + * + * @retval 0 Successful operation. + * @retval error An error occurred. This is usually EINVAL. + * + * @see rtems_filesystem_default_mmap(). + */ +typedef int (*rtems_filesystem_mmap_t)( + rtems_libio_t *iop, + void **addr, + size_t len, + int prot, + off_t off +); + +/** + * @brief File system node operations table. + */ +struct _rtems_filesystem_file_handlers_r { + rtems_filesystem_open_t open_h; + rtems_filesystem_close_t close_h; + rtems_filesystem_read_t read_h; + rtems_filesystem_write_t write_h; + rtems_filesystem_ioctl_t ioctl_h; + rtems_filesystem_lseek_t lseek_h; + rtems_filesystem_fstat_t fstat_h; + rtems_filesystem_ftruncate_t ftruncate_h; + rtems_filesystem_fsync_t fsync_h; + rtems_filesystem_fdatasync_t fdatasync_h; + rtems_filesystem_fcntl_t fcntl_h; + rtems_filesystem_poll_t poll_h; + rtems_filesystem_kqfilter_t kqfilter_h; + rtems_filesystem_readv_t readv_h; + rtems_filesystem_writev_t writev_h; + rtems_filesystem_mmap_t mmap_h; +}; + +/** + * @brief File system node handler table with default node handlers. + */ +extern const rtems_filesystem_file_handlers_r + rtems_filesystem_handlers_default; + +/** + * @retval 0 Always. + * + * @see rtems_filesystem_open_t. + */ +int rtems_filesystem_default_open( + rtems_libio_t *iop, + const char *path, + int oflag, + mode_t mode +); + +/** + * @retval 0 Always. + * + * @see rtems_filesystem_close_t. + */ +int rtems_filesystem_default_close( + rtems_libio_t *iop +); + +/** + * @retval -1 Always. The errno is set to ENOTSUP. + * + * @see rtems_filesystem_read_t. + */ +ssize_t rtems_filesystem_default_read( + rtems_libio_t *iop, + void *buffer, + size_t count +); + +/** + * @brief Calls the read handler for each IO vector entry. + * + * @see rtems_filesystem_readv_t. + */ +ssize_t rtems_filesystem_default_readv( + rtems_libio_t *iop, + const struct iovec *iov, + int iovcnt, + ssize_t total +); + +/** + * @retval -1 Always. The errno is set to ENOTSUP. + * + * @see rtems_filesystem_write_t. + */ +ssize_t rtems_filesystem_default_write( + rtems_libio_t *iop, + const void *buffer, + size_t count +); + +/** + * @brief Calls the write handler for each IO vector entry. + * + * @see rtems_filesystem_write_t. + */ +ssize_t rtems_filesystem_default_writev( + rtems_libio_t *iop, + const struct iovec *iov, + int iovcnt, + ssize_t total +); + +/** + * @retval -1 Always. The errno is set to ENOTTY. + * + * @see rtems_filesystem_ioctl_t. + */ +int rtems_filesystem_default_ioctl( + rtems_libio_t *iop, + ioctl_command_t request, + void *buffer +); + +/** + * @retval -1 Always. The errno is set to ESPIPE. + * + * @see rtems_filesystem_lseek_t. + */ +off_t rtems_filesystem_default_lseek( + rtems_libio_t *iop, + off_t offset, + int whence +); + +/** + * @brief An offset 0 with a whence of SEEK_SET will perform a directory rewind + * operation. + * + * This function has no protection against concurrent access. + * + * @retval -1 The offset is not zero or the whence is not SEEK_SET. + * @retval 0 Successful rewind operation. + * + * @see rtems_filesystem_lseek_t. + */ +off_t rtems_filesystem_default_lseek_directory( + rtems_libio_t *iop, + off_t offset, + int whence +); + +/** + * @brief Default lseek() handler for files. + * + * The fstat() handler will be used to obtain the file size in case whence is + * SEEK_END. + * + * This function has no protection against concurrent access. + * + * @retval -1 An error occurred. In case an integer overflow occurred, then the + * errno will be set to EOVERFLOW. In case the new offset is negative, then + * the errno will be set to EINVAL. In case the whence is SEEK_END and the + * fstat() handler to obtain the current file size returned an error status, + * then the errno will be set by the fstat() handler. + * @retval offset The new offset. + * + * @see rtems_filesystem_lseek_t. + */ +off_t rtems_filesystem_default_lseek_file( + rtems_libio_t *iop, + off_t offset, + int whence +); + +/** + * @brief Sets the mode to S_IRWXU | S_IRWXG | S_IRWXO. + * + * @retval 0 Always. + * + * @see rtems_filesystem_fstat_t. + */ +int rtems_filesystem_default_fstat( + const rtems_filesystem_location_info_t *loc, + struct stat *buf +); + +/** + * @retval -1 Always. The errno is set to EINVAL. + * + * @see rtems_filesystem_ftruncate_t. + */ +int rtems_filesystem_default_ftruncate( + rtems_libio_t *iop, + off_t length +); + +/** + * @retval -1 Always. The errno is set to EISDIR. + * + * @see rtems_filesystem_ftruncate_t. + */ +int rtems_filesystem_default_ftruncate_directory( + rtems_libio_t *iop, + off_t length +); + +/** + * @retval -1 Always. The errno is set to EINVAL. + * + * @see rtems_filesystem_fsync_t and rtems_filesystem_fdatasync_t. + */ +int rtems_filesystem_default_fsync_or_fdatasync( + rtems_libio_t *iop +); + +/** + * @retval 0 Always. + * + * @see rtems_filesystem_fsync_t and rtems_filesystem_fdatasync_t. + */ +int rtems_filesystem_default_fsync_or_fdatasync_success( + rtems_libio_t *iop +); + +/** + * @retval 0 Always. + * + * @see rtems_filesystem_fcntl_t. + */ +int rtems_filesystem_default_fcntl( + rtems_libio_t *iop, + int cmd +); + +/** + * @brief Default poll handler. + * + * @retval POLLERR Always. + * + * @see rtems_filesystem_poll_t. + */ +int rtems_filesystem_default_poll( + rtems_libio_t *iop, + int events +); + +/** + * @brief Default kernel event filter handler. + * + * @retval EINVAL Always. + * + * @see rtems_filesystem_kqfilter_t. + */ +int rtems_filesystem_default_kqfilter( + rtems_libio_t *iop, + struct knote *kn +); + +/** + * @brief Default MMAP handler. + * + * @retval ENOTSUP Always. + * + * @see rtems_filesystem_mmap_t. + */ +int rtems_filesystem_default_mmap( + rtems_libio_t *iop, + void **addr, + size_t len, + int prot, + off_t off +); + +/** @} */ + +/** + * @defgroup LibIO IO Library + * + * @brief Provides system call and file system interface definitions. + * + * General purpose communication channel for RTEMS to allow UNIX/POSIX + * system call behavior under RTEMS. Initially this supported only + * IO to devices but has since been enhanced to support networking + * and support for mounted file systems. + */ +/**@{**/ + +typedef off_t rtems_off64_t __attribute__((deprecated)); + +/** + * @brief Gets the mount handler for the file system @a type. + * + * @return The file system mount handler associated with the @a type, or + * @c NULL if no such association exists. + */ +rtems_filesystem_fsmount_me_t +rtems_filesystem_get_mount_handler( + const char *type +); + +/** + * @brief Contain file system specific information which is required to support + * fpathconf(). + */ +typedef struct { + int link_max; /* count */ + int max_canon; /* max formatted input line size */ + int max_input; /* max input line size */ + int name_max; /* max name length */ + int path_max; /* max path */ + int pipe_buf; /* pipe buffer size */ + int posix_async_io; /* async IO supported on fs, 0=no, 1=yes */ + int posix_chown_restrictions; /* can chown: 0=no, 1=yes */ + int posix_no_trunc; /* error on names > max name, 0=no, 1=yes */ + int posix_prio_io; /* priority IO, 0=no, 1=yes */ + int posix_sync_io; /* file can be sync'ed, 0=no, 1=yes */ + int posix_vdisable; /* special char processing, 0=no, 1=yes */ +} rtems_filesystem_limits_and_options_t; + +/** + * @brief Default pathconf settings. + * + * Override in a filesystem. + */ +extern const rtems_filesystem_limits_and_options_t + rtems_filesystem_default_pathconf; + +/** + * @brief An open file data structure. + * + * It will be indexed by 'fd'. + * + * @todo Should really have a separate per/file data structure that this points + * to (eg: offset, driver, pathname should be in that) + */ +struct rtems_libio_tt { + off_t offset; /* current offset into file */ + Atomic_Uint flags; + rtems_filesystem_location_info_t pathinfo; + uint32_t data0; /* private to "driver" */ + void *data1; /* ... */ +}; + +/** + * @brief Paramameter block for read/write. + * + * It must include 'offset' instead of using iop's offset since we can have + * multiple outstanding i/o's on a device. + */ +typedef struct { + rtems_libio_t *iop; + off_t offset; + char *buffer; + uint32_t count; + uint32_t flags; + uint32_t bytes_moved; +} rtems_libio_rw_args_t; + +/** + * @brief Parameter block for open/close. + */ +typedef struct { + rtems_libio_t *iop; + uint32_t flags; + uint32_t mode; +} rtems_libio_open_close_args_t; + +/** + * @brief Parameter block for ioctl. + */ +typedef struct { + rtems_libio_t *iop; + ioctl_command_t command; + void *buffer; + int ioctl_return; +} rtems_libio_ioctl_args_t; + +/** + * @name Flag Values + */ +/**@{**/ + +#define LIBIO_FLAGS_NO_DELAY 0x0001U /* return immediately if no data */ +#define LIBIO_FLAGS_READ 0x0002U /* reading */ +#define LIBIO_FLAGS_WRITE 0x0004U /* writing */ +#define LIBIO_FLAGS_OPEN 0x0100U /* device is open */ +#define LIBIO_FLAGS_APPEND 0x0200U /* all writes append */ +#define LIBIO_FLAGS_CLOSE_ON_EXEC 0x0800U /* close on process exec() */ +#define LIBIO_FLAGS_READ_WRITE (LIBIO_FLAGS_READ | LIBIO_FLAGS_WRITE) +#define LIBIO_FLAGS_REFERENCE_INC 0x1000U + +/** @} */ + +static inline unsigned int rtems_libio_iop_flags( const rtems_libio_t *iop ) +{ + return _Atomic_Load_uint( &iop->flags, ATOMIC_ORDER_RELAXED ); +} + +/** + * @brief Returns true if this is a no delay iop, otherwise returns false. + * + * @param[in] iop The iop. + */ +static inline bool rtems_libio_iop_is_no_delay( const rtems_libio_t *iop ) +{ + return ( rtems_libio_iop_flags( iop ) & LIBIO_FLAGS_NO_DELAY ) != 0; +} + +/** + * @brief Returns true if this is a readable iop, otherwise returns false. + * + * @param[in] iop The iop. + */ +static inline bool rtems_libio_iop_is_readable( const rtems_libio_t *iop ) +{ + return ( rtems_libio_iop_flags( iop ) & LIBIO_FLAGS_READ ) != 0; +} + +/** + * @brief Returns true if this is a writeable iop, otherwise returns false. + * + * @param[in] iop The iop. + */ +static inline bool rtems_libio_iop_is_writeable( const rtems_libio_t *iop ) +{ + return ( rtems_libio_iop_flags( iop ) & LIBIO_FLAGS_WRITE ) != 0; +} + +/** + * @brief Returns true if this is an append iop, otherwise returns false. + * + * @param[in] iop The iop. + */ +static inline bool rtems_libio_iop_is_append( const rtems_libio_t *iop ) +{ + return ( rtems_libio_iop_flags( iop ) & LIBIO_FLAGS_APPEND ) != 0; +} + +/** + * @name External I/O Handlers + */ +/**@{**/ + +typedef int (*rtems_libio_open_t)( + const char *pathname, + uint32_t flag, + uint32_t mode +); + +typedef int (*rtems_libio_close_t)( + int fd +); + +typedef ssize_t (*rtems_libio_read_t)( + int fd, + void *buffer, + size_t count +); + +typedef ssize_t (*rtems_libio_write_t)( + int fd, + const void *buffer, + size_t count +); + +typedef int (*rtems_libio_ioctl_t)( + int fd, + uint32_t command, + void *buffer +); + +typedef off_t (*rtems_libio_lseek_t)( + int fd, + off_t offset, + int whence +); + +/** @} */ + +/** + * @name Permission Macros + */ +/**@{**/ + +/* + * The following macros are used to build up the permissions sets + * used to check permissions. These are similar in style to the + * mode_t bits and should stay compatible with them. + */ +#define RTEMS_FS_PERMS_READ 0x4 +#define RTEMS_FS_PERMS_WRITE 0x2 +#define RTEMS_FS_PERMS_EXEC 0x1 +#define RTEMS_FS_PERMS_RWX \ + (RTEMS_FS_PERMS_READ | RTEMS_FS_PERMS_WRITE | RTEMS_FS_PERMS_EXEC) +#define RTEMS_FS_FOLLOW_HARD_LINK 0x8 +#define RTEMS_FS_FOLLOW_SYM_LINK 0x10 +#define RTEMS_FS_FOLLOW_LINK \ + (RTEMS_FS_FOLLOW_HARD_LINK | RTEMS_FS_FOLLOW_SYM_LINK) +#define RTEMS_FS_MAKE 0x20 +#define RTEMS_FS_EXCLUSIVE 0x40 +#define RTEMS_FS_ACCEPT_RESIDUAL_DELIMITERS 0x80 +#define RTEMS_FS_REJECT_TERMINAL_DOT 0x100 + +/** @} */ + +union __rtems_dev_t { + dev_t device; + struct { + rtems_device_major_number major; + rtems_device_minor_number minor; + } __overlay; +}; + +static inline dev_t rtems_filesystem_make_dev_t( + rtems_device_major_number _major, + rtems_device_minor_number _minor +) +{ + union __rtems_dev_t temp; + + temp.__overlay.major = _major; + temp.__overlay.minor = _minor; + return temp.device; +} + +static inline dev_t rtems_filesystem_make_dev_t_from_pointer( + const void *pointer +) +{ + uint64_t temp = (((uint64_t) 1) << 63) | (((uintptr_t) pointer) >> 1); + + return rtems_filesystem_make_dev_t((uint32_t) (temp >> 32), (uint32_t) temp); +} + +static inline rtems_device_major_number rtems_filesystem_dev_major_t( + dev_t device +) +{ + union __rtems_dev_t temp; + + temp.device = device; + return temp.__overlay.major; +} + + +static inline rtems_device_minor_number rtems_filesystem_dev_minor_t( + dev_t device +) +{ + union __rtems_dev_t temp; + + temp.device = device; + return temp.__overlay.minor; +} + +#define rtems_filesystem_split_dev_t( _dev, _major, _minor ) \ + do { \ + (_major) = rtems_filesystem_dev_major_t ( _dev ); \ + (_minor) = rtems_filesystem_dev_minor_t( _dev ); \ + } while(0) + +/* + * Prototypes for filesystem + */ + +/** + * @brief Base File System Initialization + * + * Initialize the foundation of the file system. This is specified + * by the structure rtems_filesystem_mount_table. The usual + * configuration is a single instantiation of the IMFS or miniIMFS with + * a single "/dev" directory in it. + */ +void rtems_filesystem_initialize( void ); + +void rtems_libio_post_driver(void); + +void rtems_libio_exit(void); + +/** + * @brief Creates a directory and all its parent directories according to + * @a path. + * + * The @a mode value selects the access permissions of the directory. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The @c errno indicates the error. + */ +extern int rtems_mkdir(const char *path, mode_t mode); + +/** @} */ + +/** + * @defgroup FileSystemTypesAndMount File System Types and Mount + * + * @ingroup LibIO + * + * @brief File system types and mount. + */ +/**@{**/ + +/** + * @name File System Types + */ +/**@{**/ + +#define RTEMS_FILESYSTEM_TYPE_IMFS "imfs" +#define RTEMS_FILESYSTEM_TYPE_MINIIMFS "mimfs" +#define RTEMS_FILESYSTEM_TYPE_DEVFS "devfs" +#define RTEMS_FILESYSTEM_TYPE_FTPFS "ftpfs" +#define RTEMS_FILESYSTEM_TYPE_TFTPFS "tftpfs" +#define RTEMS_FILESYSTEM_TYPE_NFS "nfs" +#define RTEMS_FILESYSTEM_TYPE_DOSFS "dosfs" +#define RTEMS_FILESYSTEM_TYPE_RFS "rfs" +#define RTEMS_FILESYSTEM_TYPE_JFFS2 "jffs2" + +/** @} */ + +/** + * @brief Mount table entry. + */ +struct rtems_filesystem_mount_table_entry_tt { + rtems_chain_node mt_node; + void *fs_info; + const rtems_filesystem_operations_table *ops; + const void *immutable_fs_info; + rtems_chain_control location_chain; + rtems_filesystem_global_location_t *mt_point_node; + rtems_filesystem_global_location_t *mt_fs_root; + bool mounted; + bool writeable; + const rtems_filesystem_limits_and_options_t *pathconf_limits_and_options; + + /* + * The target or mount point of the file system. + */ + const char *target; + + /* + * The type of filesystem or the name of the filesystem. + */ + const char *type; + + /* + * When someone adds a mounted filesystem on a real device, + * this will need to be used. + * + * The lower layers can manage how this is managed. Leave as a + * string. + */ + char *dev; + + /** + * The task that initiated the unmount process. After unmount process + * completion this task will be notified via the transient event. + * + * @see ClassicEventTransient. + */ + rtems_id unmount_task; +}; + +/** + * @brief File system options. + */ +typedef enum { + RTEMS_FILESYSTEM_READ_ONLY, + RTEMS_FILESYSTEM_READ_WRITE, + RTEMS_FILESYSTEM_BAD_OPTIONS +} rtems_filesystem_options_t; + +/** + * @brief File system table entry. + */ +typedef struct rtems_filesystem_table_t { + const char *type; + rtems_filesystem_fsmount_me_t mount_h; +} rtems_filesystem_table_t; + +/** + * @brief Static table of file systems. + * + * Externally defined by confdefs.h or the user. + */ +extern const rtems_filesystem_table_t rtems_filesystem_table []; + +extern rtems_chain_control rtems_filesystem_mount_table; + +/** + * @brief Registers a file system @a type. + * + * The @a mount_h handler will be used to mount a file system of this @a type. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The @c errno indicates the error. + */ +int rtems_filesystem_register( + const char *type, + rtems_filesystem_fsmount_me_t mount_h +); + +/** + * @brief Unregisters a file system @a type. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The @c errno indicates the error. + */ +int rtems_filesystem_unregister( + const char *type +); + +/** + * @brief Unmounts the file system instance at the specified mount path. + * + * The function waits for the unmount process completion. In case the calling + * thread uses resources of the unmounted file system the function may never + * return. In case the calling thread has its root or current directory in the + * unmounted file system the function returns with an error status and errno is + * set to EBUSY. + * + * The unmount process completion notification uses the transient event. It is + * a fatal error to terminate the calling thread while waiting for this event. + * + * A concurrent unmount request for the same file system instance has + * unpredictable effects. + * + * @param[in] mount_path The path to the file system instance mount point. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The @c errno indicates the error. + * + * @see ClassicEventTransient. + */ +int unmount( + const char *mount_path +); + +/** + * @brief Mounts a file system instance at the specified target path. + * + * To mount a standard file system instance one of the following defines should + * be used to select the file system type + * - RTEMS_FILESYSTEM_TYPE_DEVFS, + * - RTEMS_FILESYSTEM_TYPE_DOSFS, + * - RTEMS_FILESYSTEM_TYPE_FTPFS, + * - RTEMS_FILESYSTEM_TYPE_IMFS, + * - RTEMS_FILESYSTEM_TYPE_JFFS2, + * - RTEMS_FILESYSTEM_TYPE_MINIIMFS, + * - RTEMS_FILESYSTEM_TYPE_NFS, + * - RTEMS_FILESYSTEM_TYPE_RFS, or + * - RTEMS_FILESYSTEM_TYPE_TFTPFS. + * + * Only configured or registered file system types are available. You can add + * file system types to your application configuration with the following + * configuration options + * - CONFIGURE_FILESYSTEM_DEVFS, + * - CONFIGURE_FILESYSTEM_DOSFS, + * - CONFIGURE_FILESYSTEM_FTPFS, + * - CONFIGURE_FILESYSTEM_IMFS, + * - CONFIGURE_FILESYSTEM_JFFS2, + * - CONFIGURE_FILESYSTEM_MINIIMFS, + * - CONFIGURE_FILESYSTEM_NFS, + * - CONFIGURE_FILESYSTEM_RFS, and + * - CONFIGURE_FILESYSTEM_TFTPFS. + * + * In addition to these configuration options file system types can be + * registered with rtems_filesystem_register(). + * + * @param[in] source The source parameter will be forwarded to the file system + * initialization handler. Usually the source is a path to the corresponding + * device file, or @c NULL in case the file system does not use a device file. + * @param[in] target The target path must lead to an existing directory, or + * must be @c NULL. In case the target is @c NULL, the root file system will + * be mounted. + * @param[in] filesystemtype This string selects the file system type. + * @param[in] options The options specify if the file system instance allows + * read-write or read-only access. + * @param[in] data The data parameter will be forwarded to the file system + * initialization handler. It can be used to pass file system specific mount + * options. The data structure for mount options is file system specific. See + * also in the corresponding file system documentation. + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The @c errno indicates the error. + * + * @see rtems_filesystem_register(), mount_and_make_target_path(), @ref DOSFS + * and @ref JFFS2. + */ +int mount( + const char *source, + const char *target, + const char *filesystemtype, + rtems_filesystem_options_t options, + const void *data +); + +/** + * @brief Mounts a file system and makes the @a target path. + * + * The @a target path will be created with rtems_mkdir() and must not be + * @c NULL. + * + * @see mount(). + * + * @retval 0 Successful operation. + * @retval -1 An error occurred. The @c errno indicates the error. + */ +int mount_and_make_target_path( + const char *source, + const char *target, + const char *filesystemtype, + rtems_filesystem_options_t options, + const void *data +); + +/** + * @brief Per file system type routine. + * + * @see rtems_filesystem_iterate(). + * + * @retval true Stop the iteration. + * @retval false Continue the iteration. + */ +typedef bool (*rtems_per_filesystem_routine)( + const rtems_filesystem_table_t *fs_entry, + void *arg +); + +/** + * @brief Iterates over all file system types. + * + * For each file system type the @a routine will be called with the entry and + * the @a routine_arg parameter. + * + * Do not register or unregister file system types in @a routine. + * + * The iteration is protected by the IO library mutex. + * + * @retval true Iteration stopped due to @a routine return status. + * @retval false Iteration through all entries. + */ +bool rtems_filesystem_iterate( + rtems_per_filesystem_routine routine, + void *routine_arg +); + +/** + * @brief Mount table entry visitor. + * + * @retval true Stop the iteration. + * @retval false Continue the iteration. + * + * @see rtems_filesystem_mount_iterate(). + */ +typedef bool (*rtems_filesystem_mt_entry_visitor)( + const rtems_filesystem_mount_table_entry_t *mt_entry, + void *arg +); + +/** + * @brief Iterates over all file system mount entries. + * + * The iteration is protected by the IO library mutex. Do not mount or unmount + * file systems in the visitor function. + * + * @param[in] visitor For each file system mount entry the visitor function + * will be called with the entry and the visitor argument as parameters. + * @param[in] visitor_arg The second parameter for the visitor function. + * + * @retval true Iteration stopped due to visitor function return status. + * @retval false Iteration through all entries. + */ +bool rtems_filesystem_mount_iterate( + rtems_filesystem_mt_entry_visitor visitor, + void *visitor_arg +); + +typedef struct { + const char *source; + const char *target; + const char *filesystemtype; + rtems_filesystem_options_t options; + const void *data; +} rtems_filesystem_mount_configuration; + +extern const rtems_filesystem_mount_configuration + rtems_filesystem_root_configuration; + +/** @} */ + +/** + * @defgroup Termios Termios + * + * @ingroup LibIO + * + * @brief Termios + */ +/**@{**/ + +typedef struct rtems_termios_callbacks { + int (*firstOpen)(int major, int minor, void *arg); + int (*lastClose)(int major, int minor, void *arg); + int (*pollRead)(int minor); + ssize_t (*write)(int minor, const char *buf, size_t len); + int (*setAttributes)(int minor, const struct termios *t); + int (*stopRemoteTx)(int minor); + int (*startRemoteTx)(int minor); + int outputUsesInterrupts; +} rtems_termios_callbacks; + +void rtems_termios_initialize (void); + +/* + * CCJ: Change before opening a tty. Newer code from Eric is coming + * so extra work to handle an open tty is not worth it. If the tty + * is open, close then open it again. + */ +rtems_status_code rtems_termios_bufsize ( + size_t cbufsize, /* cooked buffer size */ + size_t raw_input, /* raw input buffer size */ + size_t raw_output /* raw output buffer size */ +); + +rtems_status_code rtems_termios_open ( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg, + const rtems_termios_callbacks *callbacks +); + +rtems_status_code rtems_termios_close( + void *arg +); + +rtems_status_code rtems_termios_read( + void *arg +); + +rtems_status_code rtems_termios_write( + void *arg +); + +rtems_status_code rtems_termios_ioctl( + void *arg +); + +int rtems_termios_enqueue_raw_characters( + void *ttyp, + const char *buf, + int len +); + +int rtems_termios_dequeue_characters( + void *ttyp, + int len +); + +/** @} */ + +/** + * @brief The pathconf setting for a file system. + */ +#define rtems_filesystem_pathconf(_mte) ((_mte)->pathconf_limits_and_options) + +/** + * @brief The type of file system. Its name. + */ +#define rtems_filesystem_type(_mte) ((_mte)->type) + +/** + * @brief The mount point of a file system. + */ +#define rtems_filesystem_mount_point(_mte) ((_mte)->target) + +/** + * @brief The device entry of a file system. + */ +#define rtems_filesystem_mount_device(_mte) ((_mte)->dev) + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_LIBIO_H */ diff --git a/cpukit/include/rtems/libio_.h b/cpukit/include/rtems/libio_.h new file mode 100644 index 0000000000..414e8a20fc --- /dev/null +++ b/cpukit/include/rtems/libio_.h @@ -0,0 +1,1049 @@ +/** + * @file + * + * @brief LibIO Internal Interface + * + * This file is the libio internal interface. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * Modifications to support reference counting in the file system are + * Copyright (c) 2012 embedded brains GmbH. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_LIBIO__H +#define _RTEMS_RTEMS_LIBIO__H + +#include +#include +#include +#include + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup LibIOInternal IO Internal Library + * + * @brief Internal IO library API and implementation. + * + */ +/**@{**/ + +#define RTEMS_FILESYSTEM_SYMLOOP_MAX 32 + +/* + * Not defined in newlib so provide here. Users should use dup2 and + * not this non-portable fcntl command. Provided here to allow the + * RTEMS implementation to work. + */ +#define F_DUP2FD 20 + +/* + * File descriptor Table Information + */ + +extern const uint32_t rtems_libio_number_iops; +extern rtems_libio_t rtems_libio_iops[]; +extern void *rtems_libio_iop_free_head; +extern void **rtems_libio_iop_free_tail; + +extern const rtems_filesystem_file_handlers_r rtems_filesystem_null_handlers; + +extern rtems_filesystem_mount_table_entry_t rtems_filesystem_null_mt_entry; + +/** + * @brief The global null location. + * + * Every operation and the open and fstat handlers of this location returns an + * error status. The errno is not touched by these operations and handlers. + * The purpose of this location is to deliver the error return status for a + * previous error condition which must set the errno accordingly. + * + * The usage of this null location instead of the NULL pointer eliminates + * a lot of branches. + * + * The user environment root and current directory are statically initialized + * with the null location. Due to that all file system services are in a + * defined state even if no root file system was mounted. + */ +extern rtems_filesystem_global_location_t rtems_filesystem_global_location_null; + +/** + * @brief Sets the iop flags to the specified flags together with + * LIBIO_FLAGS_OPEN. + * + * Use this once a file descriptor allocated via rtems_libio_allocate() is + * fully initialized. + * + * @param[in] iop The iop. + * @param[in] flags The flags. + */ +static inline void rtems_libio_iop_flags_initialize( + rtems_libio_t *iop, + uint32_t flags +) +{ + _Atomic_Store_uint( + &iop->flags, + LIBIO_FLAGS_OPEN | flags, + ATOMIC_ORDER_RELEASE + ); +} + +/** + * @brief Sets the specified flags in the iop. + * + * @param[in] iop The iop. + * @param[in] set The flags to set. + * + * @return The previous flags. + */ +static inline unsigned int rtems_libio_iop_flags_set( + rtems_libio_t *iop, + unsigned int set +) +{ + return _Atomic_Fetch_or_uint( &iop->flags, set, ATOMIC_ORDER_RELAXED ); +} + +/** + * @brief Clears the specified flags in the iop. + * + * @param[in] iop The iop. + * @param[in] clear The flags to clear. + * + * @return The previous flags. + */ +static inline unsigned int rtems_libio_iop_flags_clear( + rtems_libio_t *iop, + unsigned int clear +) +{ + return _Atomic_Fetch_and_uint( &iop->flags, ~clear, ATOMIC_ORDER_RELAXED ); +} + +/** + * @brief Maps a file descriptor to the iop. + * + * The file descriptor must be a valid index into the iop table. + * + * @param[in] fd The file descriptor. + * + * @return The iop corresponding to the specified file descriptor. + */ +static inline rtems_libio_t *rtems_libio_iop( int fd ) +{ + return &rtems_libio_iops[ fd ]; +} + +/** + * @brief Holds a refernece to the iop. + * + * @param[in] iop The iop. + * + * @return The flags corresponding to the specified iop. + */ +static inline unsigned int rtems_libio_iop_hold( rtems_libio_t *iop ) +{ + return _Atomic_Fetch_add_uint( + &iop->flags, + LIBIO_FLAGS_REFERENCE_INC, + ATOMIC_ORDER_ACQUIRE + ); +} + +/** + * @brief Drops a refernece to the iop. + * + * @param[in] iop The iop. + */ +static inline void rtems_libio_iop_drop( rtems_libio_t *iop ) +{ +#if defined(RTEMS_DEBUG) + unsigned int flags; + bool success; + + flags = _Atomic_Load_uint( &iop->flags, ATOMIC_ORDER_RELAXED ); + + do { + unsigned int desired; + + _Assert( flags >= LIBIO_FLAGS_REFERENCE_INC ); + + desired = flags - LIBIO_FLAGS_REFERENCE_INC; + success = _Atomic_Compare_exchange_uint( + &iop->flags, + &flags, + desired, + ATOMIC_ORDER_RELEASE, + ATOMIC_ORDER_RELAXED + ); + } while ( !success ); +#else + _Atomic_Fetch_sub_uint( + &iop->flags, + LIBIO_FLAGS_REFERENCE_INC, + ATOMIC_ORDER_RELEASE + ); +#endif +} + +/* + * rtems_libio_iop_to_descriptor + * + * Macro to convert an internal file descriptor pointer (iop) into + * the integer file descriptor used by the "section 2" system calls. + */ + +#define rtems_libio_iop_to_descriptor(_iop) \ + ((_iop) - &rtems_libio_iops[0]) + +/* + * rtems_libio_check_is_open + * + * Macro to check if a file descriptor is actually open. + */ + +#define rtems_libio_check_is_open(_iop) \ + do { \ + if (((_iop)->flags & LIBIO_FLAGS_OPEN) == 0) { \ + errno = EBADF; \ + return -1; \ + } \ + } while (0) + +/** + * @brief Macro to get the iop for the specified file descriptor. + * + * Checks that the file descriptor is in the valid range and open. + */ +#define LIBIO_GET_IOP( _fd, _iop ) \ + do { \ + unsigned int _flags; \ + if ( (uint32_t) ( _fd ) >= rtems_libio_number_iops ) { \ + rtems_set_errno_and_return_minus_one( EBADF ); \ + } \ + _iop = rtems_libio_iop( _fd ); \ + _flags = rtems_libio_iop_hold( _iop ); \ + if ( ( _flags & LIBIO_FLAGS_OPEN ) == 0 ) { \ + rtems_libio_iop_drop( _iop ); \ + rtems_set_errno_and_return_minus_one( EBADF ); \ + } \ + } while ( 0 ) + +/** + * @brief Macro to get the iop for the specified file descriptor with access + * flags and error. + * + * Checks that the file descriptor is in the valid range and open. + */ +#define LIBIO_GET_IOP_WITH_ACCESS( _fd, _iop, _access_flags, _access_error ) \ + do { \ + unsigned int _flags; \ + unsigned int _mandatory; \ + if ( (uint32_t) ( _fd ) >= rtems_libio_number_iops ) { \ + rtems_set_errno_and_return_minus_one( EBADF ); \ + } \ + _iop = rtems_libio_iop( _fd ); \ + _flags = rtems_libio_iop_hold( _iop ); \ + _mandatory = LIBIO_FLAGS_OPEN | ( _access_flags ); \ + if ( ( _flags & _mandatory ) != _mandatory ) { \ + int _error; \ + rtems_libio_iop_drop( _iop ); \ + if ( ( _flags & LIBIO_FLAGS_OPEN ) == 0 ) { \ + _error = EBADF; \ + } else { \ + _error = _access_error; \ + } \ + rtems_set_errno_and_return_minus_one( _error ); \ + } \ + } while ( 0 ) + +/* + * rtems_libio_check_buffer + * + * Macro to check if a buffer pointer is valid. + */ + +#define rtems_libio_check_buffer(_buffer) \ + do { \ + if ((_buffer) == 0) { \ + errno = EINVAL; \ + return -1; \ + } \ + } while (0) + +/* + * rtems_libio_check_count + * + * Macro to check if a count or length is valid. + */ + +#define rtems_libio_check_count(_count) \ + do { \ + if ((_count) == 0) { \ + return 0; \ + } \ + } while (0) + +/** + * @brief Clones a node. + * + * The caller must hold the file system instance lock. + * + * @param[out] clone The cloned location. + * @param[in] master The master location. + * + * @see rtems_filesystem_instance_lock(). + */ +void rtems_filesystem_location_clone( + rtems_filesystem_location_info_t *clone, + const rtems_filesystem_location_info_t *master +); + +/** + * @brief Releases all resources of a location. + * + * This function may block on a mutex and may complete an unmount process. + * + * @param[in] loc The location to free. + * + * @note The file system root location is released by the file system + * instance destruction handler (see @ref rtems_filesystem_fsunmount_me_t). + * + * @see rtems_filesystem_freenode_t. + */ +void rtems_filesystem_location_free( rtems_filesystem_location_info_t *loc ); + +/* + * External structures + */ +#include + +void rtems_libio_free_user_env( void *env ); + +extern pthread_key_t rtems_current_user_env_key; + +void rtems_libio_lock( void ); + +void rtems_libio_unlock( void ); + +static inline void rtems_filesystem_mt_lock( void ) +{ + rtems_libio_lock(); +} + +static inline void rtems_filesystem_mt_unlock( void ) +{ + rtems_libio_unlock(); +} + +extern rtems_interrupt_lock rtems_filesystem_mt_entry_lock_control; + +#define rtems_filesystem_mt_entry_declare_lock_context( ctx ) \ + rtems_interrupt_lock_context ctx + +#define rtems_filesystem_mt_entry_lock( ctx ) \ + rtems_interrupt_lock_acquire( &rtems_filesystem_mt_entry_lock_control, &ctx ) + +#define rtems_filesystem_mt_entry_unlock( ctx ) \ + rtems_interrupt_lock_release( &rtems_filesystem_mt_entry_lock_control, &ctx ) + +static inline void rtems_filesystem_instance_lock( + const rtems_filesystem_location_info_t *loc +) +{ + const rtems_filesystem_mount_table_entry_t *mt_entry = loc->mt_entry; + + (*mt_entry->ops->lock_h)( mt_entry ); +} + +static inline void rtems_filesystem_instance_unlock( + const rtems_filesystem_location_info_t *loc +) +{ + const rtems_filesystem_mount_table_entry_t *mt_entry = loc->mt_entry; + + (*mt_entry->ops->unlock_h)( mt_entry ); +} + +/* + * File Descriptor Routine Prototypes + */ + +/** + * This routine searches the IOP Table for an unused entry. If it + * finds one, it returns it. Otherwise, it returns NULL. + */ +rtems_libio_t *rtems_libio_allocate(void); + +/** + * Convert UNIX fnctl(2) flags to ones that RTEMS drivers understand + */ +unsigned int rtems_libio_fcntl_flags( int fcntl_flags ); + +/** + * Convert RTEMS internal flags to UNIX fnctl(2) flags + */ +int rtems_libio_to_fcntl_flags( unsigned int flags ); + +/** + * This routine frees the resources associated with an IOP (file descriptor) + * and clears the slot in the IOP Table. + */ +void rtems_libio_free( + rtems_libio_t *iop +); + +/* + * File System Routine Prototypes + */ + +rtems_filesystem_location_info_t * +rtems_filesystem_eval_path_start( + rtems_filesystem_eval_path_context_t *ctx, + const char *path, + int eval_flags +); + +rtems_filesystem_location_info_t * +rtems_filesystem_eval_path_start_with_parent( + rtems_filesystem_eval_path_context_t *ctx, + const char *path, + int eval_flags, + rtems_filesystem_location_info_t *parentloc, + int parent_eval_flags +); + +rtems_filesystem_location_info_t * +rtems_filesystem_eval_path_start_with_root_and_current( + rtems_filesystem_eval_path_context_t *ctx, + const char *path, + size_t pathlen, + int eval_flags, + rtems_filesystem_global_location_t *const *global_root_ptr, + rtems_filesystem_global_location_t *const *global_current_ptr +); + +void rtems_filesystem_eval_path_continue( + rtems_filesystem_eval_path_context_t *ctx +); + +void rtems_filesystem_eval_path_cleanup( + rtems_filesystem_eval_path_context_t *ctx +); + +void rtems_filesystem_eval_path_recursive( + rtems_filesystem_eval_path_context_t *ctx, + const char *path, + size_t pathlen +); + +void rtems_filesystem_eval_path_cleanup_with_parent( + rtems_filesystem_eval_path_context_t *ctx, + rtems_filesystem_location_info_t *parentloc +); + +/** + * @brief Requests a path evaluation restart. + * + * Sets the start and current location to the new start location. The caller + * must terminate its current evaluation process. The path evaluation + * continues in the next loop iteration within + * rtems_filesystem_eval_path_continue(). This avoids recursive invocations. + * The function obtains the new start location and clones it to set the new + * current location. The previous start and current locations are released. + * + * @param[in, out] ctx The path evaluation context. + * @param[in, out] newstartloc_ptr Pointer to the new start location. + */ +void rtems_filesystem_eval_path_restart( + rtems_filesystem_eval_path_context_t *ctx, + rtems_filesystem_global_location_t **newstartloc_ptr +); + +typedef enum { + RTEMS_FILESYSTEM_EVAL_PATH_GENERIC_CONTINUE, + RTEMS_FILESYSTEM_EVAL_PATH_GENERIC_DONE, + RTEMS_FILESYSTEM_EVAL_PATH_GENERIC_NO_ENTRY +} rtems_filesystem_eval_path_generic_status; + +/** + * @brief Tests if the current location is a directory. + * + * @param[in, out] ctx The path evaluation context. + * @param[in, out] arg The handler argument. + * + * @retval true The current location is a directory. + * @retval false Otherwise. + * + * @see rtems_filesystem_eval_path_generic(). + */ +typedef bool (*rtems_filesystem_eval_path_is_directory)( + rtems_filesystem_eval_path_context_t *ctx, + void *arg +); + +/** + * @brief Evaluates a token. + * + * @param[in, out] ctx The path evaluation context. + * @param[in, out] arg The handler argument. + * @param[in] token The token contents. + * @param[in] tokenlen The token length in characters. + * + * @retval status The generic path evaluation status. + * + * @see rtems_filesystem_eval_path_generic(). + */ +typedef rtems_filesystem_eval_path_generic_status +(*rtems_filesystem_eval_path_eval_token)( + rtems_filesystem_eval_path_context_t *ctx, + void *arg, + const char *token, + size_t tokenlen +); + +typedef struct { + rtems_filesystem_eval_path_is_directory is_directory; + rtems_filesystem_eval_path_eval_token eval_token; +} rtems_filesystem_eval_path_generic_config; + +void rtems_filesystem_eval_path_generic( + rtems_filesystem_eval_path_context_t *ctx, + void *arg, + const rtems_filesystem_eval_path_generic_config *config +); + +void rtems_filesystem_initialize(void); + +/** + * @brief Copies a location. + * + * A bitwise copy is performed. The destination location will be added to the + * corresponding mount entry. + * + * @param[out] dst The destination location. + * @param[in] src The source location. + * + * @retval dst The destination location. + * + * @see rtems_filesystem_location_clone(). + */ +rtems_filesystem_location_info_t *rtems_filesystem_location_copy( + rtems_filesystem_location_info_t *dst, + const rtems_filesystem_location_info_t *src +); + +static inline rtems_filesystem_location_info_t * +rtems_filesystem_location_initialize_to_null( + rtems_filesystem_location_info_t *loc +) +{ + return rtems_filesystem_location_copy( + loc, + &rtems_filesystem_global_location_null.location + ); +} + +rtems_filesystem_global_location_t * +rtems_filesystem_location_transform_to_global( + rtems_filesystem_location_info_t *loc +); + +/** + * @brief Assigns a global file system location. + * + * @param[in, out] lhs_global_loc_ptr Pointer to the global left hand side file + * system location. The current left hand side location will be released. + * @param[in] rhs_global_loc The global right hand side file system location. + */ +void rtems_filesystem_global_location_assign( + rtems_filesystem_global_location_t **lhs_global_loc_ptr, + rtems_filesystem_global_location_t *rhs_global_loc +); + +/** + * @brief Obtains a global file system location. + * + * Deferred releases will be processed in this function. + * + * This function must be called from normal thread context and may block on a + * mutex. Thread dispatching is disabled to protect some critical sections. + * + * @param[in] global_loc_ptr Pointer to the global file system location. + * + * @return A global file system location. It returns always a valid object. + * In case of an error, the global null location will be returned. Each + * operation or handler of the null location returns an error status. The + * errno indicates the error. The NULL pointer is never returned. + * + * @see rtems_filesystem_location_transform_to_global(), + * rtems_filesystem_global_location_obtain_null(), and + * rtems_filesystem_global_location_release(). + */ +rtems_filesystem_global_location_t *rtems_filesystem_global_location_obtain( + rtems_filesystem_global_location_t *const *global_loc_ptr +); + +/** + * @brief Releases a global file system location. + * + * In case the reference count reaches zero, all associated resources will be + * released. This may include the complete unmount of the corresponding file + * system instance. + * + * This function may block on a mutex. It may be called within critical + * sections of the operating system. In this case the release will be + * deferred. The next obtain call will do the actual release. + * + * @param[in] global_loc The global file system location. It must not be NULL. + * @param[in] deferred If true, then do a deferred release, otherwise release + * it immediately. + * + * @see rtems_filesystem_global_location_obtain(). + */ +void rtems_filesystem_global_location_release( + rtems_filesystem_global_location_t *global_loc, + bool deferred +); + +void rtems_filesystem_location_detach( + rtems_filesystem_location_info_t *detach +); + +void rtems_filesystem_location_copy_and_detach( + rtems_filesystem_location_info_t *copy, + rtems_filesystem_location_info_t *detach +); + +static inline rtems_filesystem_global_location_t * +rtems_filesystem_global_location_obtain_null(void) +{ + rtems_filesystem_global_location_t *global_loc = NULL; + + return rtems_filesystem_global_location_obtain( &global_loc ); +} + +static inline bool rtems_filesystem_location_is_null( + const rtems_filesystem_location_info_t *loc +) +{ + return loc->handlers == &rtems_filesystem_null_handlers; +} + +static inline bool rtems_filesystem_global_location_is_null( + const rtems_filesystem_global_location_t *global_loc +) +{ + return rtems_filesystem_location_is_null( &global_loc->location ); +} + +static inline void rtems_filesystem_location_error( + const rtems_filesystem_location_info_t *loc, + int eno +) +{ + if ( !rtems_filesystem_location_is_null( loc ) ) { + errno = eno; + } +} + +int rtems_filesystem_mknod( + const rtems_filesystem_location_info_t *parentloc, + const char *name, + size_t namelen, + mode_t mode, + dev_t dev +); + +int rtems_filesystem_chdir( rtems_filesystem_location_info_t *loc ); + +int rtems_filesystem_chmod( + const rtems_filesystem_location_info_t *loc, + mode_t mode +); + +int rtems_filesystem_chown( + const rtems_filesystem_location_info_t *loc, + uid_t owner, + gid_t group +); + +static inline bool rtems_filesystem_is_ready_for_unmount( + rtems_filesystem_mount_table_entry_t *mt_entry +) +{ + bool ready = !mt_entry->mounted + && rtems_chain_has_only_one_node( &mt_entry->location_chain ) + && mt_entry->mt_fs_root->reference_count == 1; + + if ( ready ) { + rtems_chain_initialize_empty( &mt_entry->location_chain ); + } + + return ready; +} + +static inline void rtems_filesystem_location_add_to_mt_entry( + rtems_filesystem_location_info_t *loc +) +{ + rtems_filesystem_mt_entry_declare_lock_context( lock_context ); + + rtems_filesystem_mt_entry_lock( lock_context ); + rtems_chain_append_unprotected( + &loc->mt_entry->location_chain, + &loc->mt_entry_node + ); + rtems_filesystem_mt_entry_unlock( lock_context ); +} + +void rtems_filesystem_location_remove_from_mt_entry( + rtems_filesystem_location_info_t *loc +); + +void rtems_filesystem_do_unmount( + rtems_filesystem_mount_table_entry_t *mt_entry +); + +static inline bool rtems_filesystem_location_is_instance_root( + const rtems_filesystem_location_info_t *loc +) +{ + const rtems_filesystem_mount_table_entry_t *mt_entry = loc->mt_entry; + + return (*mt_entry->ops->are_nodes_equal_h)( + loc, + &mt_entry->mt_fs_root->location + ); +} + +static inline const char *rtems_filesystem_eval_path_get_path( + rtems_filesystem_eval_path_context_t *ctx +) +{ + return ctx->path; +} + +static inline size_t rtems_filesystem_eval_path_get_pathlen( + rtems_filesystem_eval_path_context_t *ctx +) +{ + return ctx->pathlen; +} + +static inline void rtems_filesystem_eval_path_set_path( + rtems_filesystem_eval_path_context_t *ctx, + const char *path, + size_t pathlen +) +{ + ctx->path = path; + ctx->pathlen = pathlen; +} + +static inline void rtems_filesystem_eval_path_clear_path( + rtems_filesystem_eval_path_context_t *ctx +) +{ + ctx->pathlen = 0; +} + +static inline const char *rtems_filesystem_eval_path_get_token( + rtems_filesystem_eval_path_context_t *ctx +) +{ + return ctx->token; +} + +static inline size_t rtems_filesystem_eval_path_get_tokenlen( + rtems_filesystem_eval_path_context_t *ctx +) +{ + return ctx->tokenlen; +} + +static inline void rtems_filesystem_eval_path_set_token( + rtems_filesystem_eval_path_context_t *ctx, + const char *token, + size_t tokenlen +) +{ + ctx->token = token; + ctx->tokenlen = tokenlen; +} + +static inline void rtems_filesystem_eval_path_clear_token( + rtems_filesystem_eval_path_context_t *ctx +) +{ + ctx->tokenlen = 0; +} + +static inline void rtems_filesystem_eval_path_put_back_token( + rtems_filesystem_eval_path_context_t *ctx +) +{ + size_t tokenlen = ctx->tokenlen; + + ctx->path -= tokenlen; + ctx->pathlen += tokenlen; + ctx->tokenlen = 0; +} + +void rtems_filesystem_eval_path_eat_delimiter( + rtems_filesystem_eval_path_context_t *ctx +); + +void rtems_filesystem_eval_path_next_token( + rtems_filesystem_eval_path_context_t *ctx +); + +static inline void rtems_filesystem_eval_path_get_next_token( + rtems_filesystem_eval_path_context_t *ctx, + const char **token, + size_t *tokenlen +) +{ + rtems_filesystem_eval_path_next_token(ctx); + *token = ctx->token; + *tokenlen = ctx->tokenlen; +} + +static inline rtems_filesystem_location_info_t * +rtems_filesystem_eval_path_get_currentloc( + rtems_filesystem_eval_path_context_t *ctx +) +{ + return &ctx->currentloc; +} + +static inline bool rtems_filesystem_eval_path_has_path( + const rtems_filesystem_eval_path_context_t *ctx +) +{ + return ctx->pathlen > 0; +} + +static inline bool rtems_filesystem_eval_path_has_token( + const rtems_filesystem_eval_path_context_t *ctx +) +{ + return ctx->tokenlen > 0; +} + +static inline int rtems_filesystem_eval_path_get_flags( + const rtems_filesystem_eval_path_context_t *ctx +) +{ + return ctx->flags; +} + +static inline void rtems_filesystem_eval_path_set_flags( + rtems_filesystem_eval_path_context_t *ctx, + int flags +) +{ + ctx->flags = flags; +} + +static inline void rtems_filesystem_eval_path_clear_and_set_flags( + rtems_filesystem_eval_path_context_t *ctx, + int clear, + int set +) +{ + int flags = ctx->flags; + + flags &= ~clear; + flags |= set; + + ctx->flags = flags; +} + +static inline void rtems_filesystem_eval_path_extract_currentloc( + rtems_filesystem_eval_path_context_t *ctx, + rtems_filesystem_location_info_t *get +) +{ + rtems_filesystem_location_copy_and_detach( + get, + &ctx->currentloc + ); +} + +void rtems_filesystem_eval_path_error( + rtems_filesystem_eval_path_context_t *ctx, + int eno +); + +/** + * @brief Checks that the locations exist in the same file system instance. + * + * @retval 0 The locations exist and are in the same file system instance. + * @retval -1 An error occurred. The @c errno indicates the error. + */ +int rtems_filesystem_location_exists_in_same_instance_as( + const rtems_filesystem_location_info_t *a, + const rtems_filesystem_location_info_t *b +); + +/** + * @brief Checks if access to an object is allowed for the current user. + * + * If the effective UID is zero or equals the UID of the object, then the user + * permission flags of the object will be used. Otherwise if the effective GID + * is zero or equals the GID of the object or one of the supplementary group + * IDs is equal to the GID of the object, then the group permission flags of + * the object will be used. Otherwise the other permission flags of the object + * will be used. + * + * @param[in] flags The flags determining the access type. It can be + * RTEMS_FS_PERMS_READ, RTEMS_FS_PERMS_WRITE or RTEMS_FS_PERMS_EXEC. + * @param[in] object_mode The mode of the object specifying the permission flags. + * @param[in] object_uid The UID of the object. + * @param[in] object_gid The GID of the object. + * + * @retval true Access is allowed. + * @retval false Otherwise. + */ +bool rtems_filesystem_check_access( + int flags, + mode_t object_mode, + uid_t object_uid, + gid_t object_gid +); + +bool rtems_filesystem_eval_path_check_access( + rtems_filesystem_eval_path_context_t *ctx, + int eval_flags, + mode_t node_mode, + uid_t node_uid, + gid_t node_gid +); + +static inline bool rtems_filesystem_is_delimiter(char c) +{ + return c == '/' || c == '\\'; +} + +static inline bool rtems_filesystem_is_current_directory( + const char *token, + size_t tokenlen +) +{ + return tokenlen == 1 && token [0] == '.'; +} + +static inline bool rtems_filesystem_is_parent_directory( + const char *token, + size_t tokenlen +) +{ + return tokenlen == 2 && token [0] == '.' && token [1] == '.'; +} + +typedef ssize_t ( *rtems_libio_iovec_adapter )( + rtems_libio_t *iop, + const struct iovec *iov, + int iovcnt, + ssize_t total +); + +static inline ssize_t rtems_libio_iovec_eval( + int fd, + const struct iovec *iov, + int iovcnt, + unsigned int flags, + rtems_libio_iovec_adapter adapter +) +{ + ssize_t total; + int v; + rtems_libio_t *iop; + + /* + * Argument validation on IO vector + */ + if ( iov == NULL ) + rtems_set_errno_and_return_minus_one( EINVAL ); + + if ( iovcnt <= 0 ) + rtems_set_errno_and_return_minus_one( EINVAL ); + + if ( iovcnt > IOV_MAX ) + rtems_set_errno_and_return_minus_one( EINVAL ); + + /* + * OpenGroup says that you are supposed to return EINVAL if the + * sum of the iov_len values in the iov array would overflow a + * ssize_t. + */ + total = 0; + for ( v = 0 ; v < iovcnt ; ++v ) { + size_t len = iov[ v ].iov_len; + + if ( len > ( size_t ) ( SSIZE_MAX - total ) ) { + rtems_set_errno_and_return_minus_one( EINVAL ); + } + + total += ( ssize_t ) len; + + if ( iov[ v ].iov_base == NULL && len != 0 ) { + rtems_set_errno_and_return_minus_one( EINVAL ); + } + } + + LIBIO_GET_IOP_WITH_ACCESS( fd, iop, flags, EBADF ); + + if ( total > 0 ) { + total = ( *adapter )( iop, iov, iovcnt, total ); + } + + rtems_libio_iop_drop( iop ); + return total; +} + +/** + * @brief Returns the file type of the file referenced by the filesystem + * location. + * + * @brief[in] loc The filesystem location. + * + * @return The type of the file or an invalid file type in case of an error. + */ +static inline mode_t rtems_filesystem_location_type( + const rtems_filesystem_location_info_t *loc +) +{ + struct stat st; + + st.st_mode = 0; + (void) ( *loc->handlers->fstat_h )( loc, &st ); + + return st.st_mode; +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/linkersets.h b/cpukit/include/rtems/linkersets.h new file mode 100644 index 0000000000..bad046999c --- /dev/null +++ b/cpukit/include/rtems/linkersets.h @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2015, 2016 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_LINKERSET_H +#define _RTEMS_LINKERSET_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define RTEMS_LINKER_SET_BEGIN( set ) \ + _Linker_set_##set##_begin + +#define RTEMS_LINKER_SET_END( set ) \ + _Linker_set_##set##_end + +#define RTEMS_LINKER_ROSET_DECLARE( set, type ) \ + extern type const RTEMS_LINKER_SET_BEGIN( set )[0]; \ + extern type const RTEMS_LINKER_SET_END( set )[0] + +#define RTEMS_LINKER_ROSET( set, type ) \ + type const RTEMS_LINKER_SET_BEGIN( set )[0] \ + RTEMS_SECTION( ".rtemsroset." #set ".begin" ) RTEMS_USED; \ + type const RTEMS_LINKER_SET_END( set )[0] \ + RTEMS_SECTION( ".rtemsroset." #set ".end" ) RTEMS_USED + +#define RTEMS_LINKER_ROSET_ITEM_DECLARE( set, type, item ) \ + extern type const _Linker_set_##set##_##item + +#define RTEMS_LINKER_ROSET_ITEM_REFERENCE( set, type, item ) \ + static type const * const _Set_reference_##set##_##item \ + RTEMS_SECTION( ".rtemsroset.reference" ) RTEMS_USED = \ + &_Linker_set_##set##_##item + +#define RTEMS_LINKER_ROSET_ITEM_ORDERED( set, type, item, order ) \ + type const _Linker_set_##set##_##item \ + RTEMS_SECTION( ".rtemsroset." #set ".content.0." RTEMS_XSTRING( order ) ) \ + RTEMS_USED + +#define RTEMS_LINKER_ROSET_ITEM( set, type, item ) \ + type const _Linker_set_##set##_##item \ + RTEMS_SECTION( ".rtemsroset." #set ".content.1" ) RTEMS_USED + +#define RTEMS_LINKER_ROSET_CONTENT( set, decl ) \ + decl \ + RTEMS_SECTION( ".rtemsroset." #set ".content" ) + +#define RTEMS_LINKER_RWSET_DECLARE( set, type ) \ + extern type RTEMS_LINKER_SET_BEGIN( set )[0]; \ + extern type RTEMS_LINKER_SET_END( set )[0] + +#define RTEMS_LINKER_RWSET( set, type ) \ + type RTEMS_LINKER_SET_BEGIN( set )[0] \ + RTEMS_SECTION( ".rtemsrwset." #set ".begin" ) RTEMS_USED; \ + type RTEMS_LINKER_SET_END( set )[0] \ + RTEMS_SECTION( ".rtemsrwset." #set ".end" ) RTEMS_USED + +#define RTEMS_LINKER_RWSET_ITEM_DECLARE( set, type, item ) \ + extern type _Linker_set_##set##_##item + +/* + * The .rtemsroset is here not a typo. We must ensure that the references are + * not a victim of the garbage collection of the linker. Thus, we place them + * in a dedicated area of the RTEMS read-only linker set section. + */ +#define RTEMS_LINKER_RWSET_ITEM_REFERENCE( set, type, item ) \ + static type * const _Set_reference_##set##_##item \ + RTEMS_SECTION( ".rtemsroset.reference" ) RTEMS_USED = \ + &_Linker_set_##set##_##item + +#define RTEMS_LINKER_RWSET_ITEM_ORDERED( set, type, item, order ) \ + type _Linker_set_##set##_##item \ + RTEMS_SECTION( ".rtemsrwset." #set ".content.0." RTEMS_XSTRING( order ) ) \ + RTEMS_USED + +#define RTEMS_LINKER_RWSET_ITEM( set, type, item ) \ + type _Linker_set_##set##_##item \ + RTEMS_SECTION( ".rtemsrwset." #set ".content.1" ) RTEMS_USED + +#define RTEMS_LINKER_RWSET_CONTENT( set, decl ) \ + decl \ + RTEMS_SECTION( ".rtemsrwset." #set ".content" ) + +RTEMS_INLINE_ROUTINE uintptr_t _Linker_set_Obfuscate( const void *ptr ) +{ + uintptr_t addr; + + addr = (uintptr_t) ptr; + RTEMS_OBFUSCATE_VARIABLE( addr ); + + return addr; +} + +#define RTEMS_LINKER_SET_SIZE( set ) \ + ( _Linker_set_Obfuscate( RTEMS_LINKER_SET_END( set ) ) \ + - _Linker_set_Obfuscate( RTEMS_LINKER_SET_BEGIN( set ) ) ) + +#define RTEMS_LINKER_SET_ITEM_COUNT( set ) \ + ( RTEMS_LINKER_SET_SIZE( set ) \ + / sizeof( RTEMS_LINKER_SET_BEGIN( set )[ 0 ] ) ) + +#define RTEMS_LINKER_SET_IS_EMPTY( set ) \ + ( RTEMS_LINKER_SET_SIZE( set ) == 0 ) + +#define RTEMS_LINKER_SET_FOREACH( set, item ) \ + for ( \ + item = (void *) _Linker_set_Obfuscate( RTEMS_LINKER_SET_BEGIN( set ) ) ; \ + item != RTEMS_LINKER_SET_END( set ) ; \ + ++item \ + ) + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_LINKERSET_H */ diff --git a/cpukit/include/rtems/malloc.h b/cpukit/include/rtems/malloc.h new file mode 100644 index 0000000000..7c00f21e77 --- /dev/null +++ b/cpukit/include/rtems/malloc.h @@ -0,0 +1,201 @@ +/** + * @file rtems/malloc.h + * + * This file defines the interface to RTEMS extensions to the Malloc Family. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may in + * the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_MALLOC_H +#define _RTEMS_MALLOC_H + +#include +#include +#include /* for malloc_walk() */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup MallocSupport Malloc Support + * + * @ingroup libcsupport + * + * @brief RTEMS extensions to the Malloc Family + */ + +/** + * @brief C program heap control. + * + * This is the pointer to the heap control structure used to manage the C + * program heap. + */ +extern Heap_Control *RTEMS_Malloc_Heap; + +void RTEMS_Malloc_Initialize( + const Heap_Area *areas, + size_t area_count, + Heap_Initialization_or_extend_handler extend +); + +extern ptrdiff_t RTEMS_Malloc_Sbrk_amount; + +static inline void rtems_heap_set_sbrk_amount( ptrdiff_t sbrk_amount ) +{ + RTEMS_Malloc_Sbrk_amount = sbrk_amount; +} + +typedef void *(*rtems_heap_extend_handler)( + Heap_Control *heap, + size_t alloc_size +); + +/** + * @brief RTEMS Extend Heap via Sbrk + */ +void *rtems_heap_extend_via_sbrk( + Heap_Control *heap, + size_t alloc_size +); + +void *rtems_heap_null_extend( + Heap_Control *heap, + size_t alloc_size +); + +extern const rtems_heap_extend_handler rtems_malloc_extend_handler; + +/* + * Malloc Plugin to Dirty Memory at Allocation Time + */ +typedef void (*rtems_malloc_dirtier_t)(void *, size_t); +extern rtems_malloc_dirtier_t rtems_malloc_dirty_helper; + +/** + * @brief Dirty Memory Function + * + * This method fills the specified area with a non-zero pattern + * to aid in debugging programs which do not initialize their + * memory allocated from the heap. + */ +void rtems_malloc_dirty_memory( + void *start, + size_t size +); + +/** + * @brief RTEMS Variation on Aligned Memory Allocation + * + * This method is a help memalign implementation which does all + * error checking done by posix_memalign() EXCEPT it does NOT + * place numeric restrictions on the alignment value. + * + * @param[in] pointer points to the user pointer + * @param[in] alignment is the desired alignment + * @param[in] size is the allocation request size in bytes + * + * @return This methods returns zero on success and a POSIX errno + * value to indicate the failure condition. On success + * *pointer will contain the address of the allocated memory. + */ +int rtems_memalign( + void **pointer, + size_t alignment, + size_t size +); + +/** + * @brief Allocates a memory area of size @a size bytes from the heap. + * + * If the alignment parameter @a alignment is not equal to zero, the allocated + * memory area will begin at an address aligned by this value. + * + * If the boundary parameter @a boundary is not equal to zero, the allocated + * memory area will comply with a boundary constraint. The boundary value + * specifies the set of addresses which are aligned by the boundary value. The + * interior of the allocated memory area will not contain an element of this + * set. The begin or end address of the area may be a member of the set. + * + * A size value of zero will return a unique address which may be freed with + * free(). + * + * The memory allocated by this function can be released with a call to free(). + * + * @return A pointer to the begin of the allocated memory area, or @c NULL if + * no memory is available or the parameters are inconsistent. + */ +void *rtems_heap_allocate_aligned_with_boundary( + size_t size, + uintptr_t alignment, + uintptr_t boundary +); + +/** + * @brief Extends the memory available for the heap using the memory area + * starting at @a area_begin of size @a area_size bytes. + * + * There are no alignment requirements. The memory area must be big enough to + * contain some maintenance blocks. It must not overlap parts of the current + * heap areas. Disconnected subordinate heap areas will lead to used blocks + * which cover the gaps. Extending with an inappropriate memory area will + * corrupt the heap. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_ADDRESS Invalid memory area. + */ +rtems_status_code rtems_heap_extend( + void *area_begin, + uintptr_t area_size +); + +/** + * @brief Greedy allocate that empties the heap. + * + * Afterwards the heap has at most @a block_count allocatable blocks of sizes + * specified by @a block_sizes. The @a block_sizes must point to an array with + * @a block_count members. All other blocks are used. + * + * @see rtems_heap_greedy_free(). + */ +void *rtems_heap_greedy_allocate( + const uintptr_t *block_sizes, + size_t block_count +); + +/** + * @brief Greedy allocate all blocks except the largest free block. + * + * Afterwards the heap has at most one allocatable block. This block is the + * largest free block if it exists. The allocatable size of this block is + * stored in @a allocatable_size. All other blocks are used. + * + * @see rtems_heap_greedy_free(). + */ +void *rtems_heap_greedy_allocate_all_except_largest( + uintptr_t *allocatable_size +); + +/** + * @brief Frees space of a greedy allocation. + * + * The @a opaque argument must be the return value of + * rtems_heap_greedy_allocate() or + * rtems_heap_greedy_allocate_all_except_largest(). + */ +void rtems_heap_greedy_free( void *opaque ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/include/rtems/media.h b/cpukit/include/rtems/media.h new file mode 100644 index 0000000000..77a1aa8348 --- /dev/null +++ b/cpukit/include/rtems/media.h @@ -0,0 +1,517 @@ +/** + * @file + * + * @ingroup RTEMSMedia + * + * @brief Media API. + */ + +/* + * Copyright (c) 2009, 2010 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Obere Lagerstr. 30 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef RTEMS_MEDIA_H +#define RTEMS_MEDIA_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup RTEMSMedia Media Manager + * + * @brief Removable media support. + * + * The media manager may be used to maintain the life cycle of a removable + * media. Currently only disk devices are supported. The initiator posts an + * event to the media manager and it will respond with appropriate default + * actions. For example a disk attach will lead to inspection of the partition + * table and mounted file systems. Clients can register listeners to react to + * events. + */ +/**@{**/ + +#define RTEMS_MEDIA_MOUNT_BASE "/media" + +#define RTEMS_MEDIA_DELIMITER '-' + +/** + * Disk life cycle events: + * @dot + * digraph disk_events { + * "DISK ATTACH" -> "PARTITION INQUIRY"; + * "DISK ATTACH" -> "MOUNT"; + * "PARTITION INQUIRY" -> "PARTITION ATTACH"; + * "PARTITION INQUIRY" -> "DISK DETACH"; + * "PARTITION ATTACH" -> "MOUNT"; + * "MOUNT" -> "UNMOUNT"; + * "UNMOUNT" -> "PARTITION DETACH"; + * "UNMOUNT" -> "DISK DETACH"; + * "PARTITION DETACH" -> "DISK DETACH"; + * } + * @enddot + */ +typedef enum { + RTEMS_MEDIA_EVENT_DISK_ATTACH, + RTEMS_MEDIA_EVENT_DISK_DETACH, + RTEMS_MEDIA_EVENT_MOUNT, + RTEMS_MEDIA_EVENT_UNMOUNT, + RTEMS_MEDIA_EVENT_PARTITION_INQUIRY, + RTEMS_MEDIA_EVENT_PARTITION_ATTACH, + RTEMS_MEDIA_EVENT_PARTITION_DETACH, + RTEMS_MEDIA_EVENT_ERROR +} rtems_media_event; + +/** + * Normal state transition: + * @dot + * digraph state { + * INQUIRY -> READY [label="all listeners\nreturned successful"]; + * INQUIRY -> ABORTED [label="otherwise"]; + * READY -> SUCCESS [label="the worker\nreturned successful"]; + * READY -> FAILED [label="otherwise"]; + * } + * @enddot + */ +typedef enum { + RTEMS_MEDIA_STATE_INQUIRY, + RTEMS_MEDIA_STATE_READY, + RTEMS_MEDIA_STATE_ABORTED, + RTEMS_MEDIA_STATE_SUCCESS, + RTEMS_MEDIA_STATE_FAILED, + RTEMS_MEDIA_ERROR_DISK_UNKNOWN, + RTEMS_MEDIA_ERROR_DISK_EXISTS, + RTEMS_MEDIA_ERROR_DISK_OR_PARTITION_UNKNOWN, + RTEMS_MEDIA_ERROR_DISK_OR_PARTITION_EXISTS, + RTEMS_MEDIA_ERROR_PARTITION_UNKNOWN, + RTEMS_MEDIA_ERROR_PARTITION_ORPHAN, + RTEMS_MEDIA_ERROR_PARTITION_DETACH_WITH_MOUNT, + RTEMS_MEDIA_ERROR_PARTITION_WITH_UNKNOWN_DISK, + RTEMS_MEDIA_ERROR_MOUNT_POINT_UNKNOWN, + RTEMS_MEDIA_ERROR_MOUNT_POINT_EXISTS, + RTEMS_MEDIA_ERROR_MOUNT_POINT_ORPHAN +} rtems_media_state; + +/** + * @brief Event listener. + * + * The listener will be called with the @a listener_arg passed to + * rtems_media_listener_add(). + * + * Source and destination values for each event and state: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
EventStateSourceDestination
RTEMS_MEDIA_EVENT_DISK_ATTACHRTEMS_MEDIA_STATE_INQUIRYdriver nameNULL
RTEMS_MEDIA_STATE_READYdriver nameNULL
RTEMS_MEDIA_STATE_ABORTEDdriver nameNULL
RTEMS_MEDIA_STATE_SUCCESSdriver namedisk path
RTEMS_MEDIA_STATE_FAILEDdriver nameNULL
RTEMS_MEDIA_EVENT_DISK_DETACHRTEMS_MEDIA_STATE_INQUIRYdisk pathNULL
RTEMS_MEDIA_STATE_READYdisk pathNULL
RTEMS_MEDIA_STATE_ABORTEDdisk pathNULL
RTEMS_MEDIA_STATE_SUCCESSdisk pathNULL
RTEMS_MEDIA_STATE_FAILEDdisk pathNULL
RTEMS_MEDIA_EVENT_PARTITION_INQUIRYRTEMS_MEDIA_STATE_INQUIRYdisk pathNULL
RTEMS_MEDIA_STATE_READYdisk pathNULL
RTEMS_MEDIA_STATE_ABORTEDdisk pathNULL
RTEMS_MEDIA_STATE_SUCCESSdisk pathNULL
RTEMS_MEDIA_STATE_FAILEDdisk pathNULL
RTEMS_MEDIA_EVENT_PARTITION_ATTACHRTEMS_MEDIA_STATE_INQUIRYdisk pathNULL
RTEMS_MEDIA_STATE_READYdisk pathNULL
RTEMS_MEDIA_STATE_ABORTEDdisk pathNULL
RTEMS_MEDIA_STATE_SUCCESSdisk pathpartition path
RTEMS_MEDIA_STATE_FAILEDdisk pathNULL
RTEMS_MEDIA_EVENT_PARTITION_DETACHRTEMS_MEDIA_STATE_INQUIRYpartition pathNULL
RTEMS_MEDIA_STATE_READYpartition pathNULL
RTEMS_MEDIA_STATE_ABORTEDpartition pathNULL
RTEMS_MEDIA_STATE_SUCCESSpartition pathNULL
RTEMS_MEDIA_STATE_FAILEDpartition pathNULL
RTEMS_MEDIA_EVENT_MOUNTRTEMS_MEDIA_STATE_INQUIRYdisk or partition pathNULL
RTEMS_MEDIA_STATE_READYdisk or partition pathNULL
RTEMS_MEDIA_STATE_ABORTEDdisk or partition pathNULL
RTEMS_MEDIA_STATE_SUCCESSdisk or partition pathmount path
RTEMS_MEDIA_STATE_FAILEDdisk or partition pathNULL
RTEMS_MEDIA_EVENT_UNMOUNTRTEMS_MEDIA_STATE_INQUIRYmount pathNULL
RTEMS_MEDIA_STATE_READYmount pathNULL
RTEMS_MEDIA_STATE_ABORTEDmount pathNULL
RTEMS_MEDIA_STATE_SUCCESSmount pathNULL
RTEMS_MEDIA_STATE_FAILEDmount pathNULL
RTEMS_MEDIA_EVENT_ERRORRTEMS_MEDIA_ERROR_DISK_UNKNOWNdisk pathNULL
RTEMS_MEDIA_ERROR_DISK_EXISTSdisk pathNULL
RTEMS_MEDIA_ERROR_DISK_OR_PARTITION_UNKNOWNdisk or partition pathNULL
RTEMS_MEDIA_ERROR_DISK_OR_PARTITION_EXISTSdisk or partition pathNULL
RTEMS_MEDIA_ERROR_PARTITION_UNKNOWNpartition pathNULL
RTEMS_MEDIA_ERROR_PARTITION_ORPHANpartition pathdisk path
RTEMS_MEDIA_ERROR_PARTITION_DETACH_WITH_MOUNTpartition pathmount path
RTEMS_MEDIA_ERROR_PARTITION_WITH_UNKNOWN_DISKpartition pathdisk path
RTEMS_MEDIA_ERROR_MOUNT_POINT_UNKNOWNmount pathNULL
RTEMS_MEDIA_ERROR_MOUNT_POINT_EXISTSmount pathNULL
RTEMS_MEDIA_ERROR_MOUNT_POINT_ORPHANmount pathdisk path
+ * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_IO_ERROR In the inquiry state this will abort the action. + */ +typedef rtems_status_code (*rtems_media_listener)( + rtems_media_event event, + rtems_media_state state, + const char *src, + const char *dest, + void *listener_arg +); + +/** + * @brief Do the work corresponding to an event. + * + * The @a state will be + * - RTEMS_MEDIA_STATE_READY, or + * - RTEMS_MEDIA_STATE_ABORTED. + * + * It will be called with the @a src and @a worker_arg arguments passed to + * rtems_media_post_event(). + * + * The destination shall be returned in @a dest in case of success. It shall + * be allocated with malloc(). + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_IO_ERROR Failure. + */ +typedef rtems_status_code (*rtems_media_worker)( + rtems_media_state state, + const char *src, + char **dest, + void *worker_arg +); + +/** + * @name Base + */ +/**@{**/ + +/** + * @brief Initializes the media manager. + * + * Calling this function more than once will have no effects. There is no + * protection against concurrent access. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_NO_MEMORY Not enough resources. + */ +rtems_status_code rtems_media_initialize(void); + +/** + * @brief Adds the @a listener with argument @a listener_arg. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_NO_MEMORY Not enough memory. + * @retval RTEMS_TOO_MANY Such a listener is already present. + */ +rtems_status_code rtems_media_listener_add( + rtems_media_listener listener, + void *listener_arg +); + +/** + * @brief Removes the @a listener with argument @a listener_arg. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_ID No such listener is present. + */ +rtems_status_code rtems_media_listener_remove( + rtems_media_listener listener, + void *listener_arg +); + +/** + * @brief Posts the @a event with source @a src. + * + * The @a worker will be called with the @a worker_arg argument. + * + * The destination will be returned in @a dest in case of success. It will be + * allocated with malloc() and should be freed if not needed anymore. + * + * The work will be done by the calling thread. You can avoid this if you use + * the media server via rtems_media_server_post_event(). + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_UNSATISFIED One or more listeners aborted the action. + * @retval RTEMS_IO_ERROR The worker returned with an error status. + */ +rtems_status_code rtems_media_post_event( + rtems_media_event event, + const char *src, + char **dest, + rtems_media_worker worker, + void *worker_arg +); + +/** @} */ + +/** + * @name Server + */ +/**@{**/ + +/** + * @brief Initializes the media manager and media server. + * + * It creates a server task with the @a priority, @a stack_size, @a modes, and + * @a attributes parameters. + * + * Calling this function more than once will have no effects. There is no + * protection against concurrent access. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_NO_MEMORY Not enough resources. + */ +rtems_status_code rtems_media_server_initialize( + rtems_task_priority priority, + size_t stack_size, + rtems_mode modes, + rtems_attribute attributes +); + +/** + * @brief Sends an event message to the media server. + * + * @see See rtems_media_post_event(). + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_NO_MEMORY Not enough resources to notify the media server. + * @retval RTEMS_NOT_CONFIGURED Media server is not initialized. + */ +rtems_status_code rtems_media_server_post_event( + rtems_media_event event, + const char *src, + rtems_media_worker worker, + void *worker_arg +); + +/** + * @brief See rtems_media_server_post_event(). + */ +static inline rtems_status_code rtems_media_server_disk_attach( + const char *driver_name, + rtems_media_worker worker, + void *worker_arg +) +{ + return rtems_media_server_post_event( + RTEMS_MEDIA_EVENT_DISK_ATTACH, + driver_name, + worker, + worker_arg + ); +} + +/** + * @brief See rtems_media_server_post_event(). + */ +static inline rtems_status_code rtems_media_server_disk_detach( + const char *disk_path +) +{ + return rtems_media_server_post_event( + RTEMS_MEDIA_EVENT_DISK_DETACH, + disk_path, + NULL, + NULL + ); +} + +/** @} */ + +/** + * @name Path Construction + */ +/**@{**/ + +/** + * @brief Creates a new path as "prefix/name-major". + * + * @return New string, or @c NULL if no memory is available. + */ +char *rtems_media_create_path( + const char *prefix, + const char *name, + rtems_device_major_number major +); + +/** + * @brief Replaces the prefix of the @a path with @a new_prefix. + * + * The prefix is everything up to the last '/'. + * + * @return New string, or @c NULL if no memory is available. + */ +char *rtems_media_replace_prefix(const char *new_prefix, const char *path); + +/** + * @brief Appends the @a minor number to the @a path resulting in "path-minor". + * + * @return New string, or @c NULL if no memory is available. + */ +char *rtems_media_append_minor( + const char *path, + rtems_device_minor_number minor +); + +/** @} */ + +/** + * @name Support + */ +/**@{**/ + +/** + * @brief Returns the device identifier for the device located at + * @a device_path in @a device_identifier. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_ID No device at this path. + */ +rtems_status_code rtems_media_get_device_identifier( + const char *device_path, + dev_t *device_identifier +); + +const char *rtems_media_event_description(rtems_media_event event); + +const char *rtems_media_state_description(rtems_media_state state); + +/** @} */ + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RTEMS_MEDIA_H */ diff --git a/cpukit/include/rtems/monitor.h b/cpukit/include/rtems/monitor.h new file mode 100644 index 0000000000..6ecd903c63 --- /dev/null +++ b/cpukit/include/rtems/monitor.h @@ -0,0 +1,528 @@ +/** + * @file rtems/monitor.h + * + * @brief The RTEMS Monitor Task + */ + + +#ifndef __MONITOR_H +#define __MONITOR_H + +#include +#include /* rtems_error() */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Forward decls from symbols.h */ +typedef struct _rtems_symbol_t rtems_symbol_t; +typedef struct _rtems_symbol_table_t rtems_symbol_table_t; + +/* + * Monitor types are derived from rtems object classes + */ + +typedef enum { + RTEMS_MONITOR_OBJECT_INVALID = OBJECTS_CLASSIC_NO_CLASS, + RTEMS_MONITOR_OBJECT_TASK = OBJECTS_RTEMS_TASKS, + RTEMS_MONITOR_OBJECT_EXTENSION = OBJECTS_RTEMS_EXTENSIONS, + RTEMS_MONITOR_OBJECT_QUEUE = OBJECTS_RTEMS_MESSAGE_QUEUES, + RTEMS_MONITOR_OBJECT_SEMAPHORE = OBJECTS_RTEMS_SEMAPHORES, + RTEMS_MONITOR_OBJECT_PARTITION = OBJECTS_RTEMS_PARTITIONS, + RTEMS_MONITOR_OBJECT_REGION = OBJECTS_RTEMS_REGIONS, + RTEMS_MONITOR_OBJECT_PORT = OBJECTS_RTEMS_PORTS, + + /* following monitor objects are not known to RTEMS, but + * we like to have "types" for them anyway */ + + RTEMS_MONITOR_OBJECT_DRIVER = OBJECTS_RTEMS_CLASSES_LAST+1, + RTEMS_MONITOR_OBJECT_DNAME, + RTEMS_MONITOR_OBJECT_CONFIG, + RTEMS_MONITOR_OBJECT_INIT_TASK, + RTEMS_MONITOR_OBJECT_MPCI, + RTEMS_MONITOR_OBJECT_SYMBOL, + #if defined(RTEMS_POSIX_API) + RTEMS_MONITOR_OBJECT_PTHREAD, + #endif +} rtems_monitor_object_type_t; + +/* + * rtems_monitor_init() flags + */ + +#define RTEMS_MONITOR_SUSPEND 0x0001 /* suspend monitor on startup */ +#define RTEMS_MONITOR_GLOBAL 0x0002 /* monitor should be global */ +#define RTEMS_MONITOR_NOTASK 0x0004 /* do not start monitor task */ +#define RTEMS_MONITOR_NOSYMLOAD 0x0008 /* do not load symbols */ +#define RTEMS_MONITOR_WAITQUIT 0x0010 /* wait for monitor task to terminate */ + +/* + * Public interfaces for RTEMS data structures monitor is aware of. + * These are only used by the monitor. + * + * NOTE: + * All the canonical objects that correspond to RTEMS managed "objects" + * must have an identical first portion with 'id' and 'name' fields. + * + * Others do not have that restriction, even tho we would like them to. + * This is because some of the canonical structures are almost too big + * for shared memory driver (eg: mpci) and we are nickel and diming it. + */ + +/* + * Type of a pointer that may be a symbol + */ + +#define MONITOR_SYMBOL_LEN 20 +typedef struct { + char name[MONITOR_SYMBOL_LEN]; + uint32_t value; + uint32_t offset; +} rtems_monitor_symbol_t; + +typedef struct { + rtems_id id; + rtems_name name; + /* end of common portion */ +} rtems_monitor_generic_t; + +/* + * Task + */ +typedef struct { + rtems_id id; + rtems_name name; + /* end of common portion */ + char short_name[5]; + char long_name[16]; + Thread_Entry_information entry; + void *stack; + uint32_t stack_size; + char scheduler_name[5]; + rtems_task_priority priority; + States_Control state; + rtems_event_set events; + rtems_mode modes; + rtems_attribute attributes; + char wait[17]; + uint32_t ticks; +} rtems_monitor_task_t; + +/* + * Init task + */ + +typedef struct { + rtems_id id; /* not really an id */ + rtems_name name; + /* end of common portion */ + rtems_monitor_symbol_t entry; + uint32_t argument; + uint32_t stack_size; + rtems_task_priority priority; + rtems_mode modes; + rtems_attribute attributes; +} rtems_monitor_init_task_t; + + +/* + * Message queue + */ +typedef struct { + rtems_id id; + rtems_name name; + /* end of common portion */ + rtems_attribute attributes; + uint32_t number_of_pending_messages; + uint32_t maximum_pending_messages; + size_t maximum_message_size; +} rtems_monitor_queue_t; + +/* + * Semaphore + */ +typedef struct { + rtems_id id; + rtems_name name; + /* end of common portion */ + rtems_attribute attribute; + rtems_task_priority priority_ceiling; + uint32_t max_count; + uint32_t cur_count; + rtems_id holder_id; +} rtems_monitor_sema_t; + +/* + * Extension + */ +typedef struct { + rtems_id id; + rtems_name name; + /* end of common portion */ + rtems_monitor_symbol_t e_create; + rtems_monitor_symbol_t e_start; + rtems_monitor_symbol_t e_restart; + rtems_monitor_symbol_t e_delete; + rtems_monitor_symbol_t e_tswitch; + rtems_monitor_symbol_t e_begin; + rtems_monitor_symbol_t e_exitted; + rtems_monitor_symbol_t e_fatal; +} rtems_monitor_extension_t; + + /* + * Region + */ +typedef struct { + rtems_id id; + rtems_name name; + /* end of common portion */ + rtems_attribute attribute; + void * start_addr; + uint32_t length; + uint32_t page_size; + uint32_t max_seg_size; + uint32_t used_blocks; +} rtems_monitor_region_t; + +/* + * Partition + */ +typedef struct { + rtems_id id; + rtems_name name; + /* end of common portion */ + rtems_attribute attribute; + void * start_addr; + uint32_t length; + uint32_t buf_size; + uint32_t used_blocks; +} rtems_monitor_part_t; + +/* + * Device driver + */ + +typedef struct { + rtems_id id; /* not really an id (should be tho) */ + rtems_name name; /* ditto */ + /* end of common portion */ + rtems_monitor_symbol_t initialization; /* initialization procedure */ + rtems_monitor_symbol_t open; /* open request procedure */ + rtems_monitor_symbol_t close; /* close request procedure */ + rtems_monitor_symbol_t read; /* read request procedure */ + rtems_monitor_symbol_t write; /* write request procedure */ + rtems_monitor_symbol_t control; /* special functions procedure */ +} rtems_monitor_driver_t; + +/* + * System config + */ + +typedef struct { + void *work_space_start; + uint32_t work_space_size; + uint32_t maximum_tasks; + uint32_t maximum_timers; + uint32_t maximum_semaphores; + uint32_t maximum_message_queues; + uint32_t maximum_partitions; + uint32_t maximum_regions; + uint32_t maximum_ports; + uint32_t maximum_periods; + uint32_t maximum_extensions; + uint32_t microseconds_per_tick; + uint32_t ticks_per_timeslice; + uint32_t number_of_initialization_tasks; +} rtems_monitor_config_t; + +/* + * MPCI config + */ + +#if defined(RTEMS_MULTIPROCESSING) +typedef struct { + uint32_t node; /* local node number */ + uint32_t maximum_nodes; /* maximum # nodes in system */ + uint32_t maximum_global_objects; /* maximum # global objects */ + uint32_t maximum_proxies; /* maximum # proxies */ + + uint32_t default_timeout; /* in ticks */ + size_t maximum_packet_size; + rtems_monitor_symbol_t initialization; + rtems_monitor_symbol_t get_packet; + rtems_monitor_symbol_t return_packet; + rtems_monitor_symbol_t send_packet; + rtems_monitor_symbol_t receive_packet; +} rtems_monitor_mpci_t; +#endif + +/* + * The generic canonical information union + */ + +typedef union { + rtems_monitor_generic_t generic; + rtems_monitor_task_t task; + rtems_monitor_queue_t queue; + rtems_monitor_sema_t sema; + rtems_monitor_extension_t extension; + rtems_monitor_driver_t driver; + rtems_monitor_config_t config; + rtems_monitor_region_t region; + rtems_monitor_part_t part; +#if defined(RTEMS_MULTIPROCESSING) + rtems_monitor_mpci_t mpci; +#endif + rtems_monitor_init_task_t itask; +} rtems_monitor_union_t; + +/* + * Support for talking to other monitors + */ + +/* + * Names of other monitors + */ + +#define RTEMS_MONITOR_NAME (rtems_build_name('R', 'M', 'O', 'N')) +#define RTEMS_MONITOR_SERVER_NAME (rtems_build_name('R', 'M', 'S', 'V')) +#define RTEMS_MONITOR_QUEUE_NAME (rtems_build_name('R', 'M', 'S', 'Q')) +#define RTEMS_MONITOR_RESPONSE_QUEUE_NAME (rtems_build_name('R', 'M', 'R', 'Q')) + +#define RTEMS_MONITOR_SERVER_RESPONSE 0x0001 +#define RTEMS_MONITOR_SERVER_CANONICAL 0x0002 + +typedef struct +{ + uint32_t command; + rtems_id return_id; + uint32_t argument0; + uint32_t argument1; + uint32_t argument2; + uint32_t argument3; + uint32_t argument4; + uint32_t argument5; +} rtems_monitor_server_request_t; + +typedef struct +{ + uint32_t command; + uint32_t result0; + uint32_t result1; + rtems_monitor_union_t payload; +} rtems_monitor_server_response_t; + +extern rtems_id rtems_monitor_task_id; + +extern uint32_t rtems_monitor_node; /* our node number */ +extern uint32_t rtems_monitor_default_node; /* current default for commands */ + +/* + * Monitor command function and table entry + */ + +typedef struct rtems_monitor_command_entry_s rtems_monitor_command_entry_t; +typedef union _rtems_monitor_command_arg_t rtems_monitor_command_arg_t; + +typedef void (*rtems_monitor_command_function_t)( + int argc, + char **argv, + const rtems_monitor_command_arg_t *command_arg, + bool verbose +); + +union _rtems_monitor_command_arg_t { + rtems_monitor_object_type_t monitor_object; + rtems_status_code status_code; + rtems_symbol_table_t **symbol_table; + const rtems_monitor_command_entry_t *monitor_command_entry; +}; + +struct rtems_monitor_command_entry_s { + const char *command; /* command name */ + const char *usage; /* usage string for the command */ + uint32_t arguments_required; /* # of required args */ + rtems_monitor_command_function_t command_function; + /* Some argument for the command */ + rtems_monitor_command_arg_t command_arg; + const rtems_monitor_command_entry_t *next; +}; + + +typedef const void *(*rtems_monitor_object_next_fn)(void *, void *, rtems_id *); +typedef void (*rtems_monitor_object_canonical_fn)(void *, const void *); +typedef void (*rtems_monitor_object_dump_header_fn)(bool); +typedef void (*rtems_monitor_object_dump_fn)(void *, bool); + +typedef struct { + rtems_monitor_object_type_t type; + void *object_information; + int size; /* of canonical object */ + rtems_monitor_object_next_fn next; + rtems_monitor_object_canonical_fn canonical; + rtems_monitor_object_dump_header_fn dump_header; + rtems_monitor_object_dump_fn dump; +} rtems_monitor_object_info_t; + +typedef bool (*rtems_monitor_per_command_routine)(const rtems_monitor_command_entry_t *, void *); + +/* monitor.c */ +void rtems_monitor_pause_cmd(int, char **, const rtems_monitor_command_arg_t*, bool); +void rtems_monitor_fatal_cmd(int, char **, const rtems_monitor_command_arg_t*, bool); +void rtems_monitor_continue_cmd(int, char **, const rtems_monitor_command_arg_t*, bool); +void rtems_monitor_debugger_cmd(int, char **, const rtems_monitor_command_arg_t*, bool); +void rtems_monitor_reset_cmd(int, char **, const rtems_monitor_command_arg_t*, bool); +void rtems_monitor_node_cmd(int, char **, const rtems_monitor_command_arg_t*, bool); +void rtems_monitor_symbols_loadup(void); +int rtems_monitor_insert_cmd(rtems_monitor_command_entry_t *); +void rtems_monitor_wakeup(void); +void rtems_monitor_command_iterate(rtems_monitor_per_command_routine routine, void *arg); +rtems_status_code rtems_monitor_suspend(rtems_interval timeout); + +/* editor.c */ +void rtems_monitor_kill(void); +void rtems_monitor_init(uint32_t); +void rtems_monitor_task(rtems_task_argument); + +/* server.c */ +void rtems_monitor_server_kill(void); +rtems_status_code rtems_monitor_server_request(uint32_t , rtems_monitor_server_request_t *, rtems_monitor_server_response_t *); +void rtems_monitor_server_task(rtems_task_argument); +void rtems_monitor_server_init(uint32_t); + +/* command.c */ +int rtems_monitor_make_argv(char *, int *, char **); +int rtems_monitor_command_read(char *, int *, char **); +void rtems_monitor_command_usage(const rtems_monitor_command_entry_t *, const char *); +void rtems_monitor_help_cmd(int, char **, const rtems_monitor_command_arg_t *, bool); +const rtems_monitor_command_entry_t *rtems_monitor_command_lookup(const char *name); + +/* prmisc.c */ +void rtems_monitor_separator(void); +uint32_t rtems_monitor_pad(uint32_t dest_col, uint32_t curr_col); +int rtems_monitor_dump_decimal(uint32_t num); +int rtems_monitor_dump_hex(uint32_t num); +int rtems_monitor_dump_addr(const void *addr); +int rtems_monitor_dump_id(rtems_id id); +int rtems_monitor_dump_name(rtems_id id); +int rtems_monitor_dump_priority(rtems_task_priority priority); +int rtems_monitor_dump_state(States_Control state); +int rtems_monitor_dump_modes(rtems_mode modes); +int rtems_monitor_dump_attributes(rtems_attribute attributes); +int rtems_monitor_dump_events(rtems_event_set events); + +/* object.c */ +rtems_id rtems_monitor_id_fixup(rtems_id, uint32_t , rtems_monitor_object_type_t); +const rtems_monitor_object_info_t *rtems_monitor_object_lookup(rtems_monitor_object_type_t type); +rtems_id rtems_monitor_object_canonical_get(rtems_monitor_object_type_t, rtems_id, void *, size_t *size_p); +rtems_id rtems_monitor_object_canonical_next(const rtems_monitor_object_info_t *, rtems_id, void *); +const void *rtems_monitor_object_next(void *, void *, rtems_id, rtems_id *); +rtems_id rtems_monitor_object_canonical(rtems_id, const void *); +void rtems_monitor_object_cmd(int, char **, const rtems_monitor_command_arg_t*, bool); + +/* manager.c */ +const void *rtems_monitor_manager_next(void *, void *, rtems_id *); + +/* config.c */ +void rtems_monitor_config_canonical(rtems_monitor_config_t *, const void *); +const void *rtems_monitor_config_next(void *, rtems_monitor_config_t *, rtems_id *); +void rtems_monitor_config_dump_header(bool); +int rtems_monitor_config_dump(rtems_monitor_config_t *, bool verbose); + +/* mpci.c */ +#if defined(RTEMS_MULTIPROCESSING) +void rtems_monitor_mpci_canonical(rtems_monitor_mpci_t *, const void *); +const void *rtems_monitor_mpci_next(void *, rtems_monitor_mpci_t *, rtems_id *); +void rtems_monitor_mpci_dump_header(bool); +void rtems_monitor_mpci_dump(rtems_monitor_mpci_t *, bool verbose); +#endif + +/* itask.c */ +void rtems_monitor_init_task_canonical(rtems_monitor_init_task_t *, const void *); +const void *rtems_monitor_init_task_next(void *, rtems_monitor_init_task_t *, rtems_id *); +void rtems_monitor_init_task_dump_header(bool); +void rtems_monitor_init_task_dump(rtems_monitor_init_task_t *, bool verbose); + +/* extension.c */ +void rtems_monitor_extension_canonical(rtems_monitor_extension_t *, const void *); +void rtems_monitor_extension_dump_header(bool verbose); +void rtems_monitor_extension_dump(rtems_monitor_extension_t *, bool); + +/* task.c */ +void rtems_monitor_task_canonical(rtems_monitor_task_t *, const void *); +void rtems_monitor_task_dump_header(bool verbose); +void rtems_monitor_task_dump(rtems_monitor_task_t *, bool); + +/* sema.c */ +void rtems_monitor_sema_canonical(rtems_monitor_sema_t *, const void *); +void rtems_monitor_sema_dump_header(bool verbose); +void rtems_monitor_sema_dump(rtems_monitor_sema_t *, bool); + +/* queue.c */ +void rtems_monitor_queue_canonical(rtems_monitor_queue_t *, const void *); +void rtems_monitor_queue_dump_header(bool verbose); +void rtems_monitor_queue_dump(rtems_monitor_queue_t *, bool); + +/* region.c */ +void rtems_monitor_region_canonical(rtems_monitor_region_t *, const void *); +void rtems_monitor_region_dump_header(bool verbose); +void rtems_monitor_region_dump(rtems_monitor_region_t *, bool); + +/* partition.c */ +void rtems_monitor_part_canonical(rtems_monitor_part_t *, const void *); +void rtems_monitor_part_dump_header(bool verbose); +void rtems_monitor_part_dump(rtems_monitor_part_t *, bool); + +/* driver.c */ +const void *rtems_monitor_driver_next(void *, rtems_monitor_driver_t *, rtems_id *); +void rtems_monitor_driver_canonical(rtems_monitor_driver_t *, const void *); +void rtems_monitor_driver_dump_header(bool); +void rtems_monitor_driver_dump(rtems_monitor_driver_t *, bool); + +/* symbols.c */ +rtems_symbol_table_t *rtems_symbol_table_create(void); +void rtems_symbol_table_destroy(rtems_symbol_table_t *table); + +rtems_symbol_t *rtems_symbol_create(rtems_symbol_table_t *, const char *, uint32_t); +rtems_symbol_t *rtems_symbol_value_lookup(rtems_symbol_table_t *, uint32_t); +const rtems_symbol_t *rtems_symbol_value_lookup_exact(rtems_symbol_table_t *, uint32_t); +rtems_symbol_t *rtems_symbol_name_lookup(rtems_symbol_table_t *, const char *); +const void *rtems_monitor_symbol_next(void *object_info, rtems_monitor_symbol_t *, rtems_id *); +void rtems_monitor_symbol_canonical(rtems_monitor_symbol_t *, rtems_symbol_t *); +void rtems_monitor_symbol_canonical_by_name(rtems_monitor_symbol_t *, const char *); +void rtems_monitor_symbol_canonical_by_value(rtems_monitor_symbol_t *, void *); +uint32_t rtems_monitor_symbol_dump(rtems_monitor_symbol_t *, bool); +void rtems_monitor_symbol_cmd(int, char **, const rtems_monitor_command_arg_t*, bool); + +#if defined(RTEMS_NETWORKING) +void mon_ifconfig( + int argc, + char *argv[], + uint32_t command_arg, + bool verbose +); +void mon_route( + int argc, + char *argv[], + uint32_t command_arg, + bool verbose +); +#endif + +/* mon-object.c */ +const rtems_monitor_object_info_t *rtems_monitor_object_lookup( + rtems_monitor_object_type_t type +); + +/* shared data */ +extern rtems_symbol_table_t *rtems_monitor_symbols; + +#define MONITOR_WAKEUP_EVENT RTEMS_EVENT_0 + +#ifdef __cplusplus +} +#endif + +#endif /* ! __MONITOR_H */ diff --git a/cpukit/include/rtems/mouse_parser.h b/cpukit/include/rtems/mouse_parser.h new file mode 100644 index 0000000000..27bea1bbbc --- /dev/null +++ b/cpukit/include/rtems/mouse_parser.h @@ -0,0 +1,121 @@ +/** + * @file rtems/mouse_parser.h + * + * @brief Initialize Mouse Parser Engine + * + * This file is the header file for the Mouse Parser Engine. + */ + +/* + * This file is derived from a UNIX Serial Port Mouse Driver with the + * following notice: + * + * ================================================================== + * Copyright (c) 1999 Greg Haerr + * Portions Copyright (c) 1991 David I. Bell + * Permission is granted to use, distribute, or modify this source, + * provided that this copyright notice remains intact. + * + * UNIX Serial Port Mouse Driver + * + * This driver opens a serial port directly, and interprets serial data. + * Microsoft, PC, Logitech and PS/2 mice are supported. The PS/2 mouse + * is only supported if the OS runs the mouse byte codes through the + * serial port. + * + * Mouse Types Supported: pc ms, logi, ps2 + * ================================================================== + * + * It has been modified to support the concept of being just a parser + * fed data from an arbitrary source. It is independent of either + * a PS/2 driver or a serial port. + * + * It was moved to cpukit/libmisc/mouse by Joel Sherrill. + */ + +#ifndef __MOUSE_PARSER_h__ +#define __MOUSE_PARSER_h__ + +#include + +/** + * @defgroup libmisc_mouseparser Mouse Parser Engine + * @ingroup libmisc_mouse + */ +/**@{*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * This is the mask for the right button. + * + * @note Use the same definitions as the user interface. + */ +#define RBUTTON MV_BUTTON_RIGHT + +/** + * This is the mask for the center button. + * + * @note Use the same definitions as the user interface. + */ +#define MBUTTON MV_BUTTON_CENTER + +/** + * This is the mask for the left button. + * + * @note Use the same definitions as the user interface. + */ +#define LBUTTON MV_BUTTON_LEFT + +/** + * This type is the device coordinates. + */ +typedef int COORD; + +/** + * This type is the mouse button mask. + */ +typedef unsigned int BUTTON; + +/** + * This type defines a pointer to the enqueue method. It is + * available since some device drivers keep pointers to the method + * to know when to enqueue or not. + */ +typedef void (*mouse_parser_enqueue_handler)(unsigned char *, size_t); + +/** + * @brief Initialize the mouse parser engine. + * + * This method initializes the Mouse Parser Engine for the mouse + * of @a type. The @a type should be one of the following strings: + * pc ms, logi, ps2. + * + * @a param[in] type indicates the type of mouse. + * + * @retval This method returns 0 on success and -1 on error. + */ +int mouse_parser_initialize(const char *type); + +/** + * @brief Enqueue input to the mouse parser engine. + * + * This method is used to pass mouse input to the Mouse Parser Engine. + * + * @a param[in] buffer is the data to enqueue + * @a param[in] size is the amount of data to enqueue + */ +void mouse_parser_enqueue( + unsigned char *buffer, + size_t size +); + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif diff --git a/cpukit/include/rtems/mptables.h b/cpukit/include/rtems/mptables.h new file mode 100644 index 0000000000..01e5b653b4 --- /dev/null +++ b/cpukit/include/rtems/mptables.h @@ -0,0 +1,32 @@ +/** + * @file + * + * @brief Executive's Pre-Initialized Tables used in a + * Multiprocessor Configuration + * + * This include file contains the executive's pre-initialized tables + * used in a multiprocessor configuration. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_MPTABLES_H +#define _RTEMS_MPTABLES_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/mw_uid.h b/cpukit/include/rtems/mw_uid.h new file mode 100644 index 0000000000..aa88392d26 --- /dev/null +++ b/cpukit/include/rtems/mw_uid.h @@ -0,0 +1,194 @@ +/** + * @file rtems/mw_uid.h + * + * @defgroup libmisc_fb_mw Input Devices for MicroWindows + * + * @ingroup libmisc + * @brief Input Devices for MicroWindows + * + * This file defines the interface for input devices used by MicroWindows + * in an embedded system environment. + */ + +/* + * Copyright (c) 2000 - Rosimildo da Silva + */ + +#ifndef _MW_UID_H +#define _MW_UID_H + +#include +#include + +/** + * @defgroup libmisc_fb_mw Input Devices for MicroWindows + * + * @ingroup libmisc + */ +/**@{*/ +#ifdef __cplusplus +extern "C" { +#endif + +/* 0x41XX -- IOCTL functions for the Micro Input Devices commands */ +#define MW_UID_REGISTER_DEVICE 0x4100 +#define MW_UID_UNREGISTER_DEVICE 0x4101 + +/* devices supported by MicroWindows */ +enum MW_INPUT_DEVICE_TYPE { + MV_UID_INVALID = 0, + MV_UID_REL_POS = 1, /* mouse */ + MV_UID_ABS_POS = 2, /* touch-screen */ + MV_UID_KBD = 3, /* keyboard */ + MV_UID_TIMER = 4 /* timer -- not used */ +}; + +/* matching MicroWindows */ +#define MV_BUTTON_RIGHT 0x01 +#define MV_BUTTON_CENTER 0x02 +#define MV_BUTTON_LEFT 0x04 + +/* modifiers of the keyboard type devices */ +#define MV_KEY_MODIFIER_SHIFT_DOWN 0x10 +#define MV_KEY_MODIFIER_ALT_DOWN 0x20 + +/* indication of the LEDS */ +#define MV_KEY_MODIFIER_CAPS_ON 0x04 +#define MV_KEY_MODIFIER_NUN_LOCK_ON 0x02 +#define MV_KEY_SCROLL_LOCK_ON 0x01 + +/* keyboard modes -- default ASCII */ +#define MV_KEY_MODE_ASCII 0x01 +/* + * This mode one event is sent when a key is pressed, + * and another one is send when a key is released. + */ +#define MV_KEY_MODE_SCANCODE 0x00 + +/* these defines match with the linux keyboard range + * for ioctls functions for the keyboard interface. + * 0x4BXX --- keyboard related functions + */ +#define MV_KDGKBMODE 0x4B44 /* gets current keyboard mode */ +#define MV_KDSKBMODE 0x4B45 /* sets current keyboard mode */ + +/* + * Message generated by input devices controlled by MicroWindows. + */ +struct MW_UID_MESSAGE { + enum MW_INPUT_DEVICE_TYPE type; /* device type */ + union { + /* fired when keyboard events are raised */ + struct kbd_t { + unsigned short code; /* keycode or scancode */ + unsigned char modifiers; /* key modifiers */ + unsigned char mode; /* current Kbd mode */ + } kbd; + + /* fired when position events are raised, mouse, touch screen, etc */ + struct pos_t { + unsigned short btns; /* indicates which buttons are pressed */ + short x; /* x location */ + short y; /* y location */ + short z; /* z location, 0 for 2D */ + } pos; + + /* fired by a timer device periodically */ + struct timer_t { + unsigned long frt; /* free running timer */ + unsigned long seq; /* sequence number */ + } tmr; + } m; +}; + + +/* + * API for creating/closing/accessing the message queue used by the micro + * input device interface. All functions in this interface returns a + * zero ( 0 ) on success. One exception for that is the "read" routine + * that returns the number of bytes read. Negaive numbers indicate errors + * + * The implementation of the message queue for RTEMS uses a POSIX message + * queue interface. It should be very portable among systems with a POSIX + * support. + */ + +/** + * This method creates the message queue that holds events from the + * input devices. + * + * @param[in] q_name is the name of the message queue + * @param[in] flags controls the behaviour of the queue + * @param[in] max_msgs specifies the maximum number of pending messages + * + * @note The message queue is from the Classic API. + * + * @retval This method returns 0 on success and -1 on error. + */ +extern int uid_open_queue( const char *q_name, int flags, size_t max_msgs ); + +/** + * This method closes the message queue and deletes it. + * + * @retval This method returns 0 on success and -1 on error. + */ +extern int uid_close_queue( void ); + +/** + * This method reads a message from the queue. It waits up to the specified + * timeout in miliseconds. A @a timeout of 0 is a poll. + * + * @param[in] m will be filled in with the received message + * @param[in] timeout is the maximum number of mulliseconds to wait + * + * @retval This method returns 0 on success and -1 on error. + */ +extern int uid_read_message( struct MW_UID_MESSAGE *m, unsigned long timeout ); + +/** + * This methods writes a message to the queue. + * + * @param[in] m is the message to send + * + * @retval This method returns 0 on success and -1 on error. + */ +extern int uid_send_message( struct MW_UID_MESSAGE *m ); + +/** + * This method registers the device associated with @a fd to + * to insert data to the queue + */ +extern int uid_register_device( int fd, const char *q_name ); + +/* unregister device to stop adding messages to the queue */ +extern int uid_unregister_device( int fd ); + +/* set the keyboard */ +extern int uid_set_kbd_mode( int fd, int mode, int *old_mode ); + +/** + * This methods prints the specified UID message using printk + * + * @param[in] uid points to the message to print + */ +void uid_print_message( + struct MW_UID_MESSAGE *uid +); + +/** + * This methods prints the specified UID message using your fprintf + * style method of choice. + * + * @param[in] RTEMS printer + * @param[in] uid points to the message to print + */ +void uid_print_message_with_plugin( + const rtems_printer *printer, + struct MW_UID_MESSAGE *uid +); + +#ifdef __cplusplus +} +#endif +/**@}*/ +#endif /* _MW_UID_H */ diff --git a/cpukit/include/rtems/nvdisk-sram.h b/cpukit/include/rtems/nvdisk-sram.h new file mode 100644 index 0000000000..3acaf600b6 --- /dev/null +++ b/cpukit/include/rtems/nvdisk-sram.h @@ -0,0 +1,23 @@ +/** + * @file rtems/nvdisk-sram.h + * + * This driver maps an NV disk to static RAM. You can use this + */ + +/* + * RTEMS Project (http://www.rtems.org/) + * + * Copyright 2007 Chris Johns (chrisj@rtems.org) + */ + +#if !defined (_RTEMS_NVDISK_SRAM_H_) +#define _RTEMS_NVDISK_SRAM_H_ + +#include + +/** + * The handlers for the NV Disk SRAM driver. + */ +extern const rtems_nvdisk_driver_handlers rtems_nvdisk_sram_handlers; + +#endif diff --git a/cpukit/include/rtems/nvdisk.h b/cpukit/include/rtems/nvdisk.h new file mode 100644 index 0000000000..5570fb8c6b --- /dev/null +++ b/cpukit/include/rtems/nvdisk.h @@ -0,0 +1,211 @@ +/** + * @file rtems/nvdisk.h + * + * @brief Non-volatile Disk Block Device Implementation + */ + +/* + * Copyright (C) 2007 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +/** + * The Non-volatile disk provides a simple directly mapped disk + * driver with checksums for each. It is designed to provied a + * disk that can survive a restart. Examples are EEPROM devices + * which have byte writeable locations, or a battery backed up + * RAM disk. + * + * The low level driver provides the physical access to the + * hardware. + */ +#if !defined (_RTEMS_NVDISK_H_) +#define _RTEMS_NVDISK_H_ + +#include +#include + +#include + +/** + * The base name of the nv disks. + */ +#define RTEMS_NVDISK_DEVICE_BASE_NAME "/dev/nvd" + +/** + * NV disk specific ioctl request types. To use open the + * device and issue the ioctl call. + * + * @code + * int fd = open ("/dev/nvdisk0", O_WRONLY, 0); + * if (fd < 0) + * { + * printf ("driver open failed: %s\n", strerror (errno)); + * exit (1); + * } + * if (ioctl (fd, RTEMS_NVDISK_IOCTL_ERASE_DISK) < 0) + * { + * printf ("driver erase failed: %s\n", strerror (errno)); + * exit (1); + * } + * close (fd); + * @endcode + */ +#define RTEMS_NVDISK_IOCTL_ERASE_DISK _IO('B', 128) +#define RTEMS_NVDISK_IOCTL_MONITORING _IO('B', 129) +#define RTEMS_NVDISK_IOCTL_INFO_LEVEL _IO('B', 130) +#define RTEMS_NVDISK_IOCTL_PRINT_STATUS _IO('B', 131) + +/** + * NV Disk Monitoring Data allows a user to obtain + * the current status of the disk. + */ +typedef struct rtems_nvdisk_monitor_data +{ + uint32_t block_size; + uint32_t block_count; + uint32_t page_count; + uint32_t pages_available; + uint32_t pages_used; + uint32_t info_level; +} rtems_nvdisk_monitor_data; + +/** + * Return the number of kilo-bytes. + */ +#define RTEMS_NVDISK_KBYTES(_k) ((_k) * 1024) + +/** + * NV Low Level driver handlers. + + * Typically this structure is part of a table of handlers in the + * device which is referenced in the nvdisk configuration table. + * The reference is kept in the driver and used all the time to + * manage the nv device, therefore it must always exist. + */ +typedef struct rtems_nvdisk_driver_handlers +{ + /** + * Read data from the device into the buffer. Return an errno + * error number if the data cannot be read. + * + * @param device The device to read data from. + * @param flags Device specific flags for the driver. + * @param base The base address of the device. + * @param offset The offset in the segment to read. + * @param buffer The buffer to read the data into. + * @param size The amount of data to read. + * @retval 0 No error. + * @retval EIO The read did not complete. + */ + int (*read) (uint32_t device, uint32_t flags, void* base, + uint32_t offset, void* buffer, size_t size); + + /** + * Write data from the buffer to the device. Return an errno + * error number if the device cannot be written to. + * + * @param device The device to write data to. + * @param flags Device specific flags for the driver. + * @param base The base address of the device. + * @param offset The offset in the device to write to. + * @param buffer The buffer to write the data from. + * @param size The amount of data to write. + * @retval 0 No error. + * @retval EIO The write did not complete or verify. + */ + int (*write) (uint32_t device, uint32_t flags, void* base, + uint32_t offset, const void* buffer, size_t size); + + /** + * Verify data in the buffer to the data in the device. Return an + * errno error number if the device cannot be read or the data verified. + * + * @param device The device to verify the data with. + * @param flags Device specific flags for the driver. + * @param base The base address of the device. + * @param offset The offset in the device to verify. + * @param buffer The buffer to verify the data in the device with. + * @param size The amount of data to verify. + * @retval 0 No error. + * @retval EIO The data did not verify. + */ + int (*verify) (uint32_t device, uint32_t flags, void* base, + uint32_t offset, const void* buffer, size_t size); + +} rtems_nvdisk_driver_handlers; + +/** + * NV Device Descriptor holds the description of a device that is + * part of the NV disk. + * + * Typically this structure is part of a table of the device which + * is referenced in the nvdisk configuration table. + * The reference is kept in the driver and used all the time to + * manage the nv device, therefore it must always exist. + */ +typedef struct rtems_nvdisk_device_desc +{ + uint32_t flags; /**< Private user flags. */ + void* base; /**< Base address of the device. */ + uint32_t size; /**< Size of the device. */ + const rtems_nvdisk_driver_handlers* nv_ops; /**< Device handlers. */ +} rtems_nvdisk_device_desc; + +/** + * RTEMS Non-Volatile Disk configuration table used to initialise the + * driver. + */ +typedef struct rtems_nvdisk_config +{ + uint32_t block_size; /**< The block size. */ + uint32_t device_count; /**< The number of devices. */ + const rtems_nvdisk_device_desc* devices; /**< The device descriptions. */ + uint32_t flags; /**< Set of flags to control + driver. */ + uint32_t info_level; /**< Default info level. */ +} rtems_nvdisk_config; + +/* + * Driver flags. + */ + +/** + * Check the pages during initialisation to see which pages are + * valid and which are not. This could slow down initialising the + * disk driver. + */ +#define RTEMS_NVDISK_CHECK_PAGES (1 << 0) + +/** + * Non-volatile disk device driver initialization. Place in a table as the + * initialisation entry and remainder of the entries are the RTEMS block + * device generic handlers. + * + * @param major NV disk major device number. + * @param minor Minor device number, not applicable. + * @param arg Initialization argument, not applicable. + * @return The rtems_device_driver is actually just + * rtems_status_code. + */ +rtems_device_driver +rtems_nvdisk_initialize (rtems_device_major_number major, + rtems_device_minor_number minor, + void* arg); + +/** + * External reference to the configuration. Please supply. + * Support is present in confdefs.h for providing this variable. + */ +extern const rtems_nvdisk_config rtems_nvdisk_configuration[]; + +/** + * External reference to the number of configurations. Please supply. + * Support is present in confdefs.h for providing this variable. + */ +extern uint32_t rtems_nvdisk_configuration_size; + +#endif diff --git a/cpukit/include/rtems/passwd.h b/cpukit/include/rtems/passwd.h new file mode 100644 index 0000000000..8d5c299a5e --- /dev/null +++ b/cpukit/include/rtems/passwd.h @@ -0,0 +1,25 @@ +/* Define a default password for telnetd here. + * NOTES: + * - this can be overridden at run-time by setting + * the "TELNETD_PASSWD" environment variable. + * As soon as that variable is set, the new password + * is effective - no need to restart telnetd. + * - this must be set to an _encrypted_ password, NOT + * the cleartext. Use the 'genpw' utility to generate + * a password string: + * + * 1) Compile 'genpw.c' for the HOST, i.e. + * cc -o genpw genpw.c -lcrypt + * 1) delete an old password definition from this file. + * 2) run './genpw >> passwd.h'. This will append + * a new definition to this file. + * + * - if no password is defined here, no authentication + * is needed, i.e. telnet is open to the world. + * + * T. Straumann + */ + +/* #undef TELNETD_DEFAULT_PASSWD */ +/* Default password: 'rtems' */ +#define TELNETD_DEFAULT_PASSWD "tduDcyLX12owo" diff --git a/cpukit/include/rtems/pipe.h b/cpukit/include/rtems/pipe.h new file mode 100644 index 0000000000..7c6566ad50 --- /dev/null +++ b/cpukit/include/rtems/pipe.h @@ -0,0 +1,133 @@ +/** + * @file + * + * @brief POSIX FIFO/pipe File System Support + * + * This include file defines the interface to the POSIX FIFO/pipe file system + * support. + */ + +/* + * Author: Wei Shen + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_PIPE_H +#define _RTEMS_PIPE_H + +#include + +/** + * @defgroup FIFO_PIPE FIFO/Pipe File System Support + * + * @ingroup FileSystemTypesAndMount + * + * @brief Interface to the POSIX FIFO/Pipe File System + */ +/**@{*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Control block to manage each pipe */ +typedef struct pipe_control { + char *Buffer; + unsigned int Size; + unsigned int Start; + unsigned int Length; + unsigned int Readers; + unsigned int Writers; + unsigned int waitingReaders; + unsigned int waitingWriters; + unsigned int readerCounter; /* incremental counters */ + unsigned int writerCounter; /* for differentiation of successive opens */ + rtems_id Semaphore; + rtems_id readBarrier; /* wait queues */ + rtems_id writeBarrier; +#if 0 + boolean Anonymous; /* anonymous pipe or FIFO */ +#endif +} pipe_control_t; + +/** + * @brief Create an anonymous pipe. + * + * Called by pipe() to create an anonymous pipe. + */ +extern int pipe_create( + int filsdes[2] +); + +/** + * @brief Release a pipe. + * + * Interface to file system close. + * + * *pipep points to pipe control structure. When the last user releases pipe, + * it will be set to NULL. + */ +extern void pipe_release( + pipe_control_t **pipep, + rtems_libio_t *iop +); + +/** + * @brief File system open. + * Interface to file system open. + * + * *pipep points to pipe control structure. If called with *pipep = NULL, + * fifo_open will try allocating and initializing a control structure. If the + * call succeeds, *pipep will be set to address of new control structure. + */ +extern int fifo_open( + pipe_control_t **pipep, + rtems_libio_t *iop +); + +/** + * @brief File system read. + * + * Interface to file system read. + */ +extern ssize_t pipe_read( + pipe_control_t *pipe, + void *buffer, + size_t count, + rtems_libio_t *iop +); + +/** + * @brief File system write. + * + * Interface to file system write. + */ +extern ssize_t pipe_write( + pipe_control_t *pipe, + const void *buffer, + size_t count, + rtems_libio_t *iop +); + +/** + * @brief File system Input/Output control. + * + * Interface to file system ioctl. + */ +extern int pipe_ioctl( + pipe_control_t *pipe, + ioctl_command_t cmd, + void *buffer, + rtems_libio_t *iop +); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/include/rtems/posix/aio_misc.h b/cpukit/include/rtems/posix/aio_misc.h new file mode 100644 index 0000000000..aeccbad98f --- /dev/null +++ b/cpukit/include/rtems/posix/aio_misc.h @@ -0,0 +1,113 @@ +/** + * @file + * + * @brief POSIX Asynchronous Input and Output Private Support + * + * This defines private information for the AIO implementation. + */ + +/* + * Copyright 2010, Alin Rus + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _AIO_MISC_H +#define _AIO_MISC_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + /* Actual request being processed */ + typedef struct + { + rtems_chain_node next_prio; /* chain requests in order of priority */ + int policy; /* If _POSIX_PRIORITIZED_IO and + _POSIX_PRIORITY_SCHEDULING are defined */ + int priority; /* see above */ + pthread_t caller_thread; /* used for notification */ + struct aiocb *aiocbp; /* aio control block */ + } rtems_aio_request; + + typedef struct + { + rtems_chain_node next_fd; /* order fd chains in queue */ + rtems_chain_control perfd; /* chain of requests for this fd */ + int fildes; /* file descriptor to be processed */ + int new_fd; /* if this is a newly created chain */ + pthread_mutex_t mutex; + pthread_cond_t cond; + + } rtems_aio_request_chain; + + typedef struct + { + pthread_mutex_t mutex; + pthread_cond_t new_req; + pthread_attr_t attr; + + rtems_chain_control work_req; /* chains being worked by active threads */ + rtems_chain_control idle_req; /* fd chains waiting to be processed */ + unsigned int initialized; /* specific value if queue is initialized */ + int active_threads; /* the number of active threads */ + int idle_threads; /* number of idle threads */ + + } rtems_aio_queue; + +extern rtems_aio_queue aio_request_queue; + +#define AIO_QUEUE_INITIALIZED 0xB00B + +#ifndef AIO_MAX_THREADS +#define AIO_MAX_THREADS 5 +#endif + +#ifndef AIO_MAX_QUEUE_SIZE +#define AIO_MAX_QUEUE_SIZE 30 +#endif + +int rtems_aio_init (void); +int rtems_aio_enqueue (rtems_aio_request *req); +rtems_aio_request_chain *rtems_aio_search_fd +( + rtems_chain_control *chain, + int fildes, + int create +); +void rtems_aio_remove_fd (rtems_aio_request_chain *r_chain); +int rtems_aio_remove_req (rtems_chain_control *chain, + struct aiocb *aiocbp); + +#ifdef RTEMS_DEBUG +#include + +#define AIO_assert(_x) assert(_x) +#define AIO_printf(_x) printf(_x) +#else +#define AIO_assert(_x) +#define AIO_printf(_x) +#endif + +#define rtems_aio_set_errno_return_minus_one( _error, _aiocbp ) \ + do { (_aiocbp)->error_code = (_error); \ + (_aiocbp)->return_value = -1; \ + rtems_set_errno_and_return_minus_one (_error);} while(0) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/include/rtems/posix/barrierimpl.h b/cpukit/include/rtems/posix/barrierimpl.h new file mode 100644 index 0000000000..a1794b82fd --- /dev/null +++ b/cpukit/include/rtems/posix/barrierimpl.h @@ -0,0 +1,99 @@ +/** + * @file + * + * @brief Inlined Routines from the POSIX Barrier Manager + * + * This file contains the static inlin implementation of the inlined + * routines from the POSIX Barrier Manager. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * Copyright (c) 2017 embedded brains GmbH + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_POSIX_BARRIERIMPL_H +#define _RTEMS_POSIX_BARRIERIMPL_H + +#include +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define POSIX_BARRIER_MAGIC 0x1cf03773UL + +#define POSIX_BARRIER_TQ_OPERATIONS &_Thread_queue_Operations_FIFO + +typedef struct { + unsigned long flags; + Thread_queue_Syslock_queue Queue; + unsigned int count; + unsigned int waiting_threads; +} POSIX_Barrier_Control; + +static inline POSIX_Barrier_Control *_POSIX_Barrier_Get( + pthread_barrier_t *_barrier +) +{ + return (POSIX_Barrier_Control *) _barrier; +} + +static inline Thread_Control *_POSIX_Barrier_Queue_acquire( + POSIX_Barrier_Control *barrier, + Thread_queue_Context *queue_context +) +{ + ISR_Level level; + Thread_Control *executing; + + _Thread_queue_Context_initialize( queue_context ); + _Thread_queue_Context_ISR_disable( queue_context, level ); + _Thread_queue_Context_set_ISR_level( queue_context, level ); + executing = _Thread_Executing; + _Thread_queue_Queue_acquire_critical( + &barrier->Queue.Queue, + &executing->Potpourri_stats, + &queue_context->Lock_context.Lock_context + ); + + return executing; +} + +static inline void _POSIX_Barrier_Queue_release( + POSIX_Barrier_Control *barrier, + Thread_queue_Context *queue_context +) +{ + _Thread_queue_Queue_release( + &barrier->Queue.Queue, + &queue_context->Lock_context.Lock_context + ); +} + +#define POSIX_BARRIER_VALIDATE_OBJECT( bar ) \ + do { \ + if ( \ + ( bar ) == NULL \ + || ( (uintptr_t) ( bar ) ^ POSIX_BARRIER_MAGIC ) != ( bar )->_flags \ + ) { \ + return EINVAL; \ + } \ + } while ( 0 ) + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/posix/condimpl.h b/cpukit/include/rtems/posix/condimpl.h new file mode 100644 index 0000000000..66e09bf6d8 --- /dev/null +++ b/cpukit/include/rtems/posix/condimpl.h @@ -0,0 +1,184 @@ +/** + * @file + * + * This include file contains the static inline implementation of the private + * inlined routines for POSIX condition variables. + */ + +/* + * COPYRIGHT (c) 1989-2013. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_POSIX_CONDIMPL_H +#define _RTEMS_POSIX_CONDIMPL_H + +#include +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + unsigned long flags; + Thread_queue_Syslock_queue Queue; + pthread_mutex_t *mutex; +} POSIX_Condition_variables_Control; + +#define POSIX_CONDITION_VARIABLES_CLOCK_MONOTONIC 0x1UL + +#define POSIX_CONDITION_VARIABLES_FLAGS_MASK 0x1UL + +#define POSIX_CONDITION_VARIABLES_MAGIC 0x18dfb1feUL + +/** + * Constant to indicate condition variable does not currently have + * a mutex assigned to it. + */ +#define POSIX_CONDITION_VARIABLES_NO_MUTEX NULL + +#define POSIX_CONDITION_VARIABLES_TQ_OPERATIONS &_Thread_queue_Operations_FIFO + +#define POSIX_CONDITION_VARIABLE_OF_THREAD_QUEUE_QUEUE( queue ) \ + RTEMS_CONTAINER_OF( \ + queue, POSIX_Condition_variables_Control, Queue.Queue ) + +/** + * The default condition variable attributes structure. + */ +extern const pthread_condattr_t _POSIX_Condition_variables_Default_attributes; + +static inline POSIX_Condition_variables_Control *_POSIX_Condition_variables_Get( + pthread_cond_t *cond +) +{ + return (POSIX_Condition_variables_Control *) cond; +} + +RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Initialize( + POSIX_Condition_variables_Control *the_cond, + const pthread_condattr_t *the_attr +) +{ + unsigned long flags; + + _Thread_queue_Queue_initialize( &the_cond->Queue.Queue, NULL ); + the_cond->mutex = POSIX_CONDITION_VARIABLES_NO_MUTEX; + + flags = (uintptr_t) the_cond ^ POSIX_CONDITION_VARIABLES_MAGIC; + flags &= ~POSIX_CONDITION_VARIABLES_FLAGS_MASK; + + if ( the_attr->clock == CLOCK_MONOTONIC ) { + flags |= POSIX_CONDITION_VARIABLES_CLOCK_MONOTONIC; + } + + the_cond->flags = flags; +} + +RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Destroy( + POSIX_Condition_variables_Control *the_cond +) +{ + the_cond->flags = ~the_cond->flags; +} + +RTEMS_INLINE_ROUTINE clockid_t _POSIX_Condition_variables_Get_clock( + unsigned long flags +) +{ + if ( ( flags & POSIX_CONDITION_VARIABLES_CLOCK_MONOTONIC ) != 0 ) { + return CLOCK_MONOTONIC; + } + + return CLOCK_REALTIME; +} + +RTEMS_INLINE_ROUTINE Thread_Control *_POSIX_Condition_variables_Acquire( + POSIX_Condition_variables_Control *the_cond, + Thread_queue_Context *queue_context +) +{ + ISR_Level level; + Thread_Control *executing; + + _Thread_queue_Context_ISR_disable( queue_context, level ); + _Thread_queue_Context_set_ISR_level( queue_context, level ); + executing = _Thread_Executing; + _Thread_queue_Queue_acquire_critical( + &the_cond->Queue.Queue, + &executing->Potpourri_stats, + &queue_context->Lock_context.Lock_context + ); + + return executing; +} + +RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Release( + POSIX_Condition_variables_Control *the_cond, + Thread_queue_Context *queue_context +) +{ + _Thread_queue_Queue_release( + &the_cond->Queue.Queue, + &queue_context->Lock_context.Lock_context + ); +} + +/** + * @brief Implements wake up version of the "signal" operation. + * + * A support routine which implements guts of the broadcast and single task + * wake up version of the "signal" operation. + */ +int _POSIX_Condition_variables_Signal_support( + pthread_cond_t *cond, + bool is_broadcast +); + +/** + * @brief POSIX condition variables wait support. + * + * A support routine which implements guts of the blocking, non-blocking, and + * timed wait version of condition variable wait routines. + */ +int _POSIX_Condition_variables_Wait_support( + pthread_cond_t *cond, + pthread_mutex_t *mutex, + const struct timespec *abstime +); + +bool _POSIX_Condition_variables_Auto_initialization( + POSIX_Condition_variables_Control *the_cond +); + +#define POSIX_CONDITION_VARIABLES_VALIDATE_OBJECT( the_cond, flags ) \ + do { \ + if ( ( the_cond ) == NULL ) { \ + return EINVAL; \ + } \ + flags = ( the_cond )->flags; \ + if ( \ + ( ( (uintptr_t) ( the_cond ) ^ POSIX_CONDITION_VARIABLES_MAGIC ) \ + & ~POSIX_CONDITION_VARIABLES_FLAGS_MASK ) \ + != ( flags & ~POSIX_CONDITION_VARIABLES_FLAGS_MASK ) \ + ) { \ + if ( !_POSIX_Condition_variables_Auto_initialization( the_cond ) ) { \ + return EINVAL; \ + } \ + } \ + } while ( 0 ) + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/posix/config.h b/cpukit/include/rtems/posix/config.h new file mode 100644 index 0000000000..e90dc27011 --- /dev/null +++ b/cpukit/include/rtems/posix/config.h @@ -0,0 +1,120 @@ +/** + * @file + * + * @brief User Defined Configuration Parameters Specific For The POSIX API + * + * This include file contains the table of user defined configuration + * parameters specific for the POSIX API. + */ + +/* + * COPYRIGHT (c) 1989-2014. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_POSIX_CONFIG_H +#define _RTEMS_POSIX_CONFIG_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicConfig Configuration + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality related to the application's configuration + * of the Classic API including the maximum number of each class of objects. + */ +/**@{*/ + +/** + * For now, we are only allowing the user to specify the entry point + * and stack size for POSIX initialization threads. + */ +typedef struct { + /** This is the entry point for a POSIX initialization thread. */ + void *(*thread_entry)(void *); + /** This is the stack size for a POSIX initialization thread. */ + int stack_size; +} posix_initialization_threads_table; + +/** + * The following records define the POSIX Configuration Table. + * The information contained in this table is required in all + * RTEMS systems which include POSIX threads support, whether + * single or multiprocessor. This table primarily defines the + * following: + * + * + required number of each object type + */ +typedef struct { + /** + * This field contains the maximum number of POSIX API + * threads which are configured for this application. + */ + uint32_t maximum_threads; + + /** + * This field contains the maximum number of POSIX API + * timers which are configured for this application. + */ + uint32_t maximum_timers; + + /** + * This field contains the maximum number of POSIX API + * queued signals which are configured for this application. + */ + uint32_t maximum_queued_signals; + + /** + * This field contains the maximum number of POSIX API + * message queues which are configured for this application. + */ + uint32_t maximum_message_queues; + + /** + * This field contains the maximum number of POSIX API + * semaphores which are configured for this application. + */ + uint32_t maximum_semaphores; + + /** + * Maximum configured number of POSIX Shared memory objects. + */ + uint32_t maximum_shms; + + /** + * This field contains the number of POSIX API Initialization + * threads listed in @a User_initialization_thread_table. + */ + uint32_t number_of_initialization_threads; + + /** + * This field contains the list of POSIX API Initialization threads. + */ + posix_initialization_threads_table *User_initialization_threads_table; +} posix_api_configuration_table; + +/** + * @brief POSIX API configuration table. + * + * This is the POSIX API Configuration Table expected to be generated + * by confdefs.h. + */ +extern posix_api_configuration_table Configuration_POSIX_API; + +/**@}*/ +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/posix/key.h b/cpukit/include/rtems/posix/key.h new file mode 100644 index 0000000000..1f09916f06 --- /dev/null +++ b/cpukit/include/rtems/posix/key.h @@ -0,0 +1,95 @@ +/** + * @file + * + * @brief POSIX Key Private Support + * + * This include file contains all the private support information for + * POSIX key. + */ + +/* + * Copyright (c) 2012 Zhongwei Yao. + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * Copyright (c) 2016 embedded brains GmbH. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_POSIX_KEY_H +#define _RTEMS_POSIX_KEY_H + +#include + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup POSIX_KEY POSIX Key + * + * @ingroup POSIXAPI + * + */ +/**@{**/ + +/** + * @brief Represents POSIX key and value pair. + */ +typedef struct { + /** + * @brief The chain node for the key value pairs chain in POSIX_Keys_Control. + */ + Chain_Node Key_node; + + /** + * @brief The tree node for the lookup tree in Thread_Keys_information. + */ + RBTree_Node Lookup_node; + + /** + * @brief The POSIX key identifier used as the tree key. + */ + pthread_key_t key; + + /** + * @brief The corresponding thread. + */ + Thread_Control *thread; + + /** + * @brief The thread specific POSIX key value. + */ + void *value; +} POSIX_Keys_Key_value_pair; + +/** + * @brief The data structure used to manage a POSIX key. + */ +typedef struct { + /** This field is the Object control structure. */ + Objects_Control Object; + /** This field is the data destructor. */ + void (*destructor) (void *); + + /** + * @brief Key value pairs of this key. + */ + Chain_Control Key_value_pairs; + } POSIX_Keys_Control; + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/posix/keyimpl.h b/cpukit/include/rtems/posix/keyimpl.h new file mode 100644 index 0000000000..1148123638 --- /dev/null +++ b/cpukit/include/rtems/posix/keyimpl.h @@ -0,0 +1,177 @@ +/** + * @file + * + * @brief Private Inlined Routines for POSIX Key's + * + * This include file contains the static inline implementation of the private + * inlined routines for POSIX key's. + */ + +/* + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * Copyright (c) 2016 embedded brains GmbH. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#include +#include +#include +#include +#include + +#ifndef _RTEMS_POSIX_KEYIMPL_H +#define _RTEMS_POSIX_KEYIMPL_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup POSIX_KEY + * + * @{ + */ + +/** + * @brief The information control block used to manage this class of objects. + */ +extern Objects_Information _POSIX_Keys_Information; + +/** + * @brief This freechain is used as a memory pool for POSIX_Keys_Key_value_pair. + */ +extern Freechain_Control _POSIX_Keys_Keypool; + +#define POSIX_KEYS_RBTREE_NODE_TO_KEY_VALUE_PAIR( node ) \ + RTEMS_CONTAINER_OF( node, POSIX_Keys_Key_value_pair, Lookup_node ) + +/** + * @brief Allocate a keys control block. + * + * This function allocates a keys control block from + * the inactive chain of free keys control blocks. + */ + +RTEMS_INLINE_ROUTINE POSIX_Keys_Control *_POSIX_Keys_Allocate( void ) +{ + return (POSIX_Keys_Control *) _Objects_Allocate( &_POSIX_Keys_Information ); +} + +/** + * @brief Free a keys control block. + * + * This routine frees a keys control block to the + * inactive chain of free keys control blocks. + */ +RTEMS_INLINE_ROUTINE void _POSIX_Keys_Free( + POSIX_Keys_Control *the_key +) +{ + _Objects_Free( &_POSIX_Keys_Information, &the_key->Object ); +} + +RTEMS_INLINE_ROUTINE POSIX_Keys_Control *_POSIX_Keys_Get( pthread_key_t key ) +{ + return (POSIX_Keys_Control *) + _Objects_Get_no_protection( (Objects_Id) key, &_POSIX_Keys_Information ); +} + +RTEMS_INLINE_ROUTINE void _POSIX_Keys_Key_value_acquire( + Thread_Control *the_thread, + ISR_lock_Context *lock_context +) +{ + _ISR_lock_ISR_disable_and_acquire( &the_thread->Keys.Lock, lock_context ); +} + +RTEMS_INLINE_ROUTINE void _POSIX_Keys_Key_value_release( + Thread_Control *the_thread, + ISR_lock_Context *lock_context +) +{ + _ISR_lock_Release_and_ISR_enable( &the_thread->Keys.Lock, lock_context ); +} + +POSIX_Keys_Key_value_pair * _POSIX_Keys_Key_value_allocate( void ); + +RTEMS_INLINE_ROUTINE void _POSIX_Keys_Key_value_free( + POSIX_Keys_Key_value_pair *key_value_pair +) +{ + _Chain_Extract_unprotected( &key_value_pair->Key_node ); + _Freechain_Put( &_POSIX_Keys_Keypool, key_value_pair ); +} + +RTEMS_INLINE_ROUTINE bool _POSIX_Keys_Key_value_equal( + const void *left, + const RBTree_Node *right +) +{ + const pthread_key_t *the_left; + const POSIX_Keys_Key_value_pair *the_right; + + the_left = left; + the_right = POSIX_KEYS_RBTREE_NODE_TO_KEY_VALUE_PAIR( right ); + + return *the_left == the_right->key; +} + +RTEMS_INLINE_ROUTINE bool _POSIX_Keys_Key_value_less( + const void *left, + const RBTree_Node *right +) +{ + const pthread_key_t *the_left; + const POSIX_Keys_Key_value_pair *the_right; + + the_left = left; + the_right = POSIX_KEYS_RBTREE_NODE_TO_KEY_VALUE_PAIR( right ); + + return *the_left < the_right->key; +} + +RTEMS_INLINE_ROUTINE void *_POSIX_Keys_Key_value_map( RBTree_Node *node ) +{ + return POSIX_KEYS_RBTREE_NODE_TO_KEY_VALUE_PAIR( node ); +} + +RTEMS_INLINE_ROUTINE POSIX_Keys_Key_value_pair *_POSIX_Keys_Key_value_find( + pthread_key_t key, + const Thread_Control *the_thread +) +{ + return _RBTree_Find_inline( + &the_thread->Keys.Key_value_pairs, + &key, + _POSIX_Keys_Key_value_equal, + _POSIX_Keys_Key_value_less, + _POSIX_Keys_Key_value_map + ); +} + +RTEMS_INLINE_ROUTINE void _POSIX_Keys_Key_value_insert( + pthread_key_t key, + POSIX_Keys_Key_value_pair *key_value_pair, + Thread_Control *the_thread +) +{ + _RBTree_Insert_inline( + &the_thread->Keys.Key_value_pairs, + &key_value_pair->Lookup_node, + &key, + _POSIX_Keys_Key_value_less + ); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/posix/mmanimpl.h b/cpukit/include/rtems/posix/mmanimpl.h new file mode 100644 index 0000000000..e1cc672331 --- /dev/null +++ b/cpukit/include/rtems/posix/mmanimpl.h @@ -0,0 +1,56 @@ +/** + * @file + * + * @brief Internal Support for POSIX 1003.1b 6.3.1 - map pages of memory + * + */ + +/* + * Copyright (c) 2012 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_POSIX_MMANIMPL_H +#define _RTEMS_POSIX_MMANIMPL_H + +#include +#include /* FIXME: use score chains for proper layering? */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* FIXME: add Doxygen */ + +/** + * Every mmap'ed region has a mapping. + */ +typedef struct mmap_mappings_s { + rtems_chain_node node; /**< The mapping chain's node */ + void* addr; /**< The address of the mapped memory */ + size_t len; /**< The length of memory mapped */ + int flags; /**< The mapping flags */ + POSIX_Shm_Control *shm; /**< The shared memory object or NULL */ +} mmap_mapping; + +extern rtems_chain_control mmap_mappings; + +static inline void mmap_mappings_lock_obtain( void ) +{ + rtems_libio_lock(); +} + +static inline void mmap_mappings_lock_release( void ) +{ + rtems_libio_unlock(); +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/include/rtems/posix/mqueue.h b/cpukit/include/rtems/posix/mqueue.h new file mode 100644 index 0000000000..cdf94514af --- /dev/null +++ b/cpukit/include/rtems/posix/mqueue.h @@ -0,0 +1,71 @@ +/** + * @file + * + * @brief POSIX Message Queues Private Private Support + * + * This include file contains all the private support information for + * POSIX Message Queues. + * + * The structure of the routines is identical to that of POSIX + * Message_queues to leave the option of having unnamed message + * queues at a future date. They are currently not part of the + * POSIX standard but unnamed message_queues are. This is also + * the reason for the apparently unnecessary tracking of + * the process_shared attribute. [In addition to the fact that + * it would be trivial to add pshared to the mq_attr structure + * and have process private message queues.] + * + * This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open + * time. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_POSIX_MQUEUE_H +#define _RTEMS_POSIX_MQUEUE_H + +#include +#include /* struct mq_attr */ +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup POSIX_MQUEUE_P Message Queues Private Support + * + * @ingroup POSIXAPI + * + */ +/**@{**/ + +/* + * Data Structure used to manage a POSIX message queue + */ + +typedef struct { + Objects_Control Object; + CORE_message_queue_Control Message_queue; + bool linked; + uint32_t open_count; + struct sigevent notification; + int oflag; +} POSIX_Message_queue_Control; + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/posix/mqueueimpl.h b/cpukit/include/rtems/posix/mqueueimpl.h new file mode 100644 index 0000000000..6813a3ef88 --- /dev/null +++ b/cpukit/include/rtems/posix/mqueueimpl.h @@ -0,0 +1,183 @@ +/** + * @file + * + * @brief Private Inlined Routines for POSIX Message Queue + * + * This include file contains the static inline implementation of the private + * inlined routines for POSIX Message Queue. + */ + +/* + * COPYRIGHT (c) 1989-2013. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_POSIX_MQUEUE_INL +#define _RTEMS_POSIX_MQUEUE_INL + +#include +#include +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * This defines the information control block used to manage + * this class of objects. + */ +extern Objects_Information _POSIX_Message_queue_Information; + +/** + * @brief Delete a POSIX Message Queue + * + * This routine supports the mq_unlink and mq_close routines by + * doing most of the work involved with removing a message queue. + */ +void _POSIX_Message_queue_Delete( + POSIX_Message_queue_Control *the_mq, + Thread_queue_Context *queue_context +); + +/*@ + * @brief POSIX Message Queue Receive Support + * + * This routine supports the various flavors of receiving a message. + * + * @note The structure of the routines is identical to that of POSIX + * Message_queues to leave the option of having unnamed message + * queues at a future date. They are currently not part of the + * POSIX standard but unnamed message_queues are. This is also + * the reason for the apparently unnecessary tracking of + * the process_shared attribute. [In addition to the fact that + * it would be trivial to add pshared to the mq_attr structure + * and have process private message queues.] + * + * @note This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open time. + */ +ssize_t _POSIX_Message_queue_Receive_support( + mqd_t mqdes, + char *msg_ptr, + size_t msg_len, + unsigned int *msg_prio, + const struct timespec *abstime, + Thread_queue_Enqueue_callout enqueue_callout +); + +/** + * @brief POSIX Message Queue Send Support + * + * This routine posts a message to a specified message queue. + */ +int _POSIX_Message_queue_Send_support( + mqd_t mqdes, + const char *msg_ptr, + size_t msg_len, + unsigned int msg_prio, + const struct timespec *abstime, + Thread_queue_Enqueue_callout enqueue_callout +); + +RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control * + _POSIX_Message_queue_Allocate_unprotected( void ) +{ + return (POSIX_Message_queue_Control *) + _Objects_Allocate_unprotected( &_POSIX_Message_queue_Information ); +} + +/** + * @brief POSIX Message Queue Free + * + * This routine frees a message queue control block to the + * inactive chain of free message queue control blocks. + */ +RTEMS_INLINE_ROUTINE void _POSIX_Message_queue_Free( + POSIX_Message_queue_Control *the_mq +) +{ + _Objects_Free( &_POSIX_Message_queue_Information, &the_mq->Object ); +} + + +RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control *_POSIX_Message_queue_Get( + Objects_Id id, + Thread_queue_Context *queue_context +) +{ + _Thread_queue_Context_initialize( queue_context ); + return (POSIX_Message_queue_Control *) _Objects_Get( + id, + &queue_context->Lock_context.Lock_context, + &_POSIX_Message_queue_Information + ); +} + +/* + * @brief POSIX Message Queue Convert Message Priority to Score + * + * This method converts a POSIX message priority to the priorities used + * by the Score. + */ +RTEMS_INLINE_ROUTINE CORE_message_queue_Submit_types + _POSIX_Message_queue_Priority_to_core( + unsigned int priority +) +{ + return (CORE_message_queue_Submit_types) priority * -1; +} + + +/* + * @brief POSIX Message Queue Convert Message Priority from Score + * + * This method converts a POSIX message priority from the priorities used + * by the Score. + */ +RTEMS_INLINE_ROUTINE unsigned int _POSIX_Message_queue_Priority_from_core( + CORE_message_queue_Submit_types priority +) +{ + /* absolute value without a library dependency */ + return (unsigned int) ((priority >= 0) ? priority : -priority); +} + +/** + * @brief POSIX Message Queue Remove from Namespace + */ +RTEMS_INLINE_ROUTINE void _POSIX_Message_queue_Namespace_remove ( + POSIX_Message_queue_Control *the_mq +) +{ + _Objects_Namespace_remove( + &_POSIX_Message_queue_Information, &the_mq->Object ); +} + +RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control * +_POSIX_Message_queue_Get_by_name( + const char *name, + size_t *name_length_p, + Objects_Get_by_name_error *error +) +{ + return (POSIX_Message_queue_Control *) _Objects_Get_by_name( + &_POSIX_Message_queue_Information, + name, + name_length_p, + error + ); +} + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/posix/muteximpl.h b/cpukit/include/rtems/posix/muteximpl.h new file mode 100644 index 0000000000..435b43634d --- /dev/null +++ b/cpukit/include/rtems/posix/muteximpl.h @@ -0,0 +1,487 @@ +/** + * @file + * + * @brief Private Inlined Routines for POSIX Mutex's. + * + * This include file contains the static inline implementation of the private + * inlined routines for POSIX mutex's. + */ + +/* COPYRIGHT (c) 1989-2013. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_POSIX_MUTEXIMPL_H +#define _RTEMS_POSIX_MUTEXIMPL_H + +#include +#include + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + unsigned long flags; + Mutex_recursive_Control Recursive; + Priority_Node Priority_ceiling; + const Scheduler_Control *scheduler; +} POSIX_Mutex_Control; + +#define POSIX_MUTEX_PROTOCOL_MASK 0x3UL + +#define POSIX_MUTEX_RECURSIVE 0x4UL + +#define POSIX_MUTEX_FLAGS_MASK 0x7UL + +#define POSIX_MUTEX_MAGIC 0x961c13b8UL + +#define POSIX_MUTEX_NO_PROTOCOL_TQ_OPERATIONS &_Thread_queue_Operations_FIFO + +#define POSIX_MUTEX_PRIORITY_INHERIT_TQ_OPERATIONS \ + &_Thread_queue_Operations_priority_inherit + +#define POSIX_MUTEX_PRIORITY_CEILING_TQ_OPERATIONS \ + &_Thread_queue_Operations_priority + +/** + * @brief Supported POSIX mutex protocols. + * + * Must be in synchronization with POSIX_Mutex_Control::protocol. + */ +typedef enum { + POSIX_MUTEX_NO_PROTOCOL, + POSIX_MUTEX_PRIORITY_INHERIT, + POSIX_MUTEX_PRIORITY_CEILING +} POSIX_Mutex_Protocol; + +/** + * The default mutex attributes structure. + */ +extern const pthread_mutexattr_t _POSIX_Mutex_Default_attributes; + +RTEMS_INLINE_ROUTINE Thread_Control *_POSIX_Mutex_Acquire( + POSIX_Mutex_Control *the_mutex, + Thread_queue_Context *queue_context +) +{ + ISR_Level level; + Thread_Control *executing; + + _Thread_queue_Context_initialize( queue_context ); + _Thread_queue_Context_ISR_disable( queue_context, level ); + _Thread_queue_Context_set_ISR_level( queue_context, level ); + executing = _Thread_Executing; + _Thread_queue_Queue_acquire_critical( + &the_mutex->Recursive.Mutex.Queue.Queue, + &executing->Potpourri_stats, + &queue_context->Lock_context.Lock_context + ); + + return executing; +} + +RTEMS_INLINE_ROUTINE void _POSIX_Mutex_Release( + POSIX_Mutex_Control *the_mutex, + Thread_queue_Context *queue_context +) +{ + _Thread_queue_Queue_release( + &the_mutex->Recursive.Mutex.Queue.Queue, + &queue_context->Lock_context.Lock_context + ); +} + +RTEMS_INLINE_ROUTINE POSIX_Mutex_Protocol _POSIX_Mutex_Get_protocol( + unsigned long flags +) +{ + return flags & POSIX_MUTEX_PROTOCOL_MASK; +} + +RTEMS_INLINE_ROUTINE bool _POSIX_Mutex_Is_recursive( + unsigned long flags +) +{ + return ( flags & POSIX_MUTEX_RECURSIVE ) != 0; +} + +RTEMS_INLINE_ROUTINE Thread_Control *_POSIX_Mutex_Get_owner( + const POSIX_Mutex_Control *the_mutex +) +{ + return the_mutex->Recursive.Mutex.Queue.Queue.owner; +} + +RTEMS_INLINE_ROUTINE bool _POSIX_Mutex_Is_locked( + const POSIX_Mutex_Control *the_mutex +) +{ + return _POSIX_Mutex_Get_owner( the_mutex ) != NULL; +} + +Status_Control _POSIX_Mutex_Seize_slow( + POSIX_Mutex_Control *the_mutex, + const Thread_queue_Operations *operations, + Thread_Control *executing, + const struct timespec *abstime, + Thread_queue_Context *queue_context +); + +RTEMS_INLINE_ROUTINE void _POSIX_Mutex_Set_owner( + POSIX_Mutex_Control *the_mutex, + Thread_Control *owner +) +{ + the_mutex->Recursive.Mutex.Queue.Queue.owner = owner; +} + +RTEMS_INLINE_ROUTINE bool _POSIX_Mutex_Is_owner( + const POSIX_Mutex_Control *the_mutex, + const Thread_Control *the_thread +) +{ + return _POSIX_Mutex_Get_owner( the_mutex ) == the_thread; +} + +static Status_Control _POSIX_Mutex_Lock_nested( + POSIX_Mutex_Control *the_mutex, + unsigned long flags +) +{ + + if ( _POSIX_Mutex_Is_recursive( flags ) ) { + ++the_mutex->Recursive.nest_level; + return STATUS_SUCCESSFUL; + } else { + return STATUS_NESTING_NOT_ALLOWED; + } +} + +RTEMS_INLINE_ROUTINE Status_Control _POSIX_Mutex_Seize( + POSIX_Mutex_Control *the_mutex, + unsigned long flags, + const Thread_queue_Operations *operations, + Thread_Control *executing, + const struct timespec *abstime, + Thread_queue_Context *queue_context +) +{ + Thread_Control *owner; + + owner = _POSIX_Mutex_Get_owner( the_mutex ); + + if ( owner == NULL ) { + _POSIX_Mutex_Set_owner( the_mutex, executing ); + _Thread_Resource_count_increment( executing ); + _POSIX_Mutex_Release( the_mutex, queue_context ); + return STATUS_SUCCESSFUL; + } + + if ( owner == executing ) { + Status_Control status; + + status = _POSIX_Mutex_Lock_nested( the_mutex, flags ); + _POSIX_Mutex_Release( the_mutex, queue_context ); + return status; + } + + return _POSIX_Mutex_Seize_slow( + the_mutex, + operations, + executing, + abstime, + queue_context + ); +} + +RTEMS_INLINE_ROUTINE Status_Control _POSIX_Mutex_Surrender( + POSIX_Mutex_Control *the_mutex, + const Thread_queue_Operations *operations, + Thread_Control *executing, + Thread_queue_Context *queue_context +) +{ + unsigned int nest_level; + Thread_queue_Heads *heads; + + if ( !_POSIX_Mutex_Is_owner( the_mutex, executing ) ) { + _POSIX_Mutex_Release( the_mutex, queue_context ); + return STATUS_NOT_OWNER; + } + + nest_level = the_mutex->Recursive.nest_level; + + if ( nest_level > 0 ) { + the_mutex->Recursive.nest_level = nest_level - 1; + _POSIX_Mutex_Release( the_mutex, queue_context ); + return STATUS_SUCCESSFUL; + } + + _Thread_Resource_count_decrement( executing ); + _POSIX_Mutex_Set_owner( the_mutex, NULL ); + + heads = the_mutex->Recursive.Mutex.Queue.Queue.heads; + + if ( heads == NULL ) { + _POSIX_Mutex_Release( the_mutex, queue_context ); + return STATUS_SUCCESSFUL; + } + + _Thread_queue_Surrender( + &the_mutex->Recursive.Mutex.Queue.Queue, + heads, + executing, + queue_context, + operations + ); + return STATUS_SUCCESSFUL; +} + +RTEMS_INLINE_ROUTINE const Scheduler_Control *_POSIX_Mutex_Get_scheduler( + const POSIX_Mutex_Control *the_mutex +) +{ +#if defined(RTEMS_SMP) + return the_mutex->scheduler; +#else + return &_Scheduler_Table[ 0 ]; +#endif +} + +RTEMS_INLINE_ROUTINE void _POSIX_Mutex_Set_priority( + POSIX_Mutex_Control *the_mutex, + Priority_Control priority_ceiling, + Thread_queue_Context *queue_context +) +{ + Thread_Control *owner; + + owner = _POSIX_Mutex_Get_owner( the_mutex ); + + if ( owner != NULL ) { + _Thread_Wait_acquire( owner, queue_context ); + _Thread_Priority_change( + owner, + &the_mutex->Priority_ceiling, + priority_ceiling, + false, + queue_context + ); + _Thread_Wait_release( owner, queue_context ); + } else { + the_mutex->Priority_ceiling.priority = priority_ceiling; + } +} + +RTEMS_INLINE_ROUTINE Priority_Control _POSIX_Mutex_Get_priority( + const POSIX_Mutex_Control *the_mutex +) +{ + return the_mutex->Priority_ceiling.priority; +} + +RTEMS_INLINE_ROUTINE Status_Control _POSIX_Mutex_Ceiling_set_owner( + POSIX_Mutex_Control *the_mutex, + Thread_Control *owner, + Thread_queue_Context *queue_context +) +{ + ISR_lock_Context lock_context; + Scheduler_Node *scheduler_node; + Per_CPU_Control *cpu_self; + + _Thread_Wait_acquire_default_critical( owner, &lock_context ); + + scheduler_node = _Thread_Scheduler_get_home_node( owner ); + + if ( + _Priority_Get_priority( &scheduler_node->Wait.Priority ) + < the_mutex->Priority_ceiling.priority + ) { + _Thread_Wait_release_default_critical( owner, &lock_context ); + _POSIX_Mutex_Release( the_mutex, queue_context ); + return STATUS_MUTEX_CEILING_VIOLATED; + } + + _POSIX_Mutex_Set_owner( the_mutex, owner ); + _Thread_Resource_count_increment( owner ); + _Thread_Priority_add( + owner, + &the_mutex->Priority_ceiling, + queue_context + ); + _Thread_Wait_release_default_critical( owner, &lock_context ); + + cpu_self = _Thread_queue_Dispatch_disable( queue_context ); + _POSIX_Mutex_Release( the_mutex, queue_context ); + _Thread_Priority_update( queue_context ); + _Thread_Dispatch_enable( cpu_self ); + return STATUS_SUCCESSFUL; +} + +RTEMS_INLINE_ROUTINE Status_Control _POSIX_Mutex_Ceiling_seize( + POSIX_Mutex_Control *the_mutex, + unsigned long flags, + Thread_Control *executing, + const struct timespec *abstime, + Thread_queue_Context *queue_context +) +{ + Thread_Control *owner; + + owner = _POSIX_Mutex_Get_owner( the_mutex ); + + if ( owner == NULL ) { +#if defined(RTEMS_SMP) + if ( + _Thread_Scheduler_get_home( executing ) + != _POSIX_Mutex_Get_scheduler( the_mutex ) + ) { + _POSIX_Mutex_Release( the_mutex, queue_context ); + return STATUS_NOT_DEFINED; + } +#endif + + _Thread_queue_Context_clear_priority_updates( queue_context ); + return _POSIX_Mutex_Ceiling_set_owner( + the_mutex, + executing, + queue_context + ); + } + + if ( owner == executing ) { + Status_Control status; + + status = _POSIX_Mutex_Lock_nested( the_mutex, flags ); + _POSIX_Mutex_Release( the_mutex, queue_context ); + return status; + } + + return _POSIX_Mutex_Seize_slow( + the_mutex, + POSIX_MUTEX_PRIORITY_CEILING_TQ_OPERATIONS, + executing, + abstime, + queue_context + ); +} + +RTEMS_INLINE_ROUTINE Status_Control _POSIX_Mutex_Ceiling_surrender( + POSIX_Mutex_Control *the_mutex, + Thread_Control *executing, + Thread_queue_Context *queue_context +) +{ + unsigned int nest_level; + ISR_lock_Context lock_context; + Per_CPU_Control *cpu_self; + Thread_queue_Heads *heads; + + if ( !_POSIX_Mutex_Is_owner( the_mutex, executing ) ) { + _POSIX_Mutex_Release( the_mutex, queue_context ); + return STATUS_NOT_OWNER; + } + + nest_level = the_mutex->Recursive.nest_level; + + if ( nest_level > 0 ) { + the_mutex->Recursive.nest_level = nest_level - 1; + _POSIX_Mutex_Release( the_mutex, queue_context ); + return STATUS_SUCCESSFUL; + } + + _Thread_Resource_count_decrement( executing ); + + _Thread_queue_Context_clear_priority_updates( queue_context ); + _Thread_Wait_acquire_default_critical( executing, &lock_context ); + _Thread_Priority_remove( + executing, + &the_mutex->Priority_ceiling, + queue_context + ); + _Thread_Wait_release_default_critical( executing, &lock_context ); + + cpu_self = _Thread_queue_Dispatch_disable( queue_context ); + + heads = the_mutex->Recursive.Mutex.Queue.Queue.heads; + + if ( heads != NULL ) { + const Thread_queue_Operations *operations; + Thread_Control *new_owner; + + operations = POSIX_MUTEX_PRIORITY_CEILING_TQ_OPERATIONS; + new_owner = ( *operations->first )( heads ); + _POSIX_Mutex_Set_owner( the_mutex, new_owner ); + _Thread_Resource_count_increment( new_owner ); + _Thread_Priority_add( + new_owner, + &the_mutex->Priority_ceiling, + queue_context + ); + _Thread_queue_Extract_critical( + &the_mutex->Recursive.Mutex.Queue.Queue, + operations, + new_owner, + queue_context + ); + } else { + _POSIX_Mutex_Set_owner( the_mutex, NULL ); + _POSIX_Mutex_Release( the_mutex, queue_context ); + } + + _Thread_Priority_update( queue_context ); + _Thread_Dispatch_enable( cpu_self ); + return STATUS_SUCCESSFUL; +} + +#define POSIX_MUTEX_ABSTIME_TRY_LOCK ((uintptr_t) 1) + +int _POSIX_Mutex_Lock_support( + pthread_mutex_t *mutex, + const struct timespec *abstime, + Thread_queue_Enqueue_callout enqueue_callout +); + +static inline POSIX_Mutex_Control *_POSIX_Mutex_Get( + pthread_mutex_t *mutex +) +{ + return (POSIX_Mutex_Control *) mutex; +} + +bool _POSIX_Mutex_Auto_initialization( POSIX_Mutex_Control *the_mutex ); + +#define POSIX_MUTEX_VALIDATE_OBJECT( the_mutex, flags ) \ + do { \ + if ( ( the_mutex ) == NULL ) { \ + return EINVAL; \ + } \ + flags = ( the_mutex )->flags; \ + if ( \ + ( ( (uintptr_t) ( the_mutex ) ^ POSIX_MUTEX_MAGIC ) \ + & ~POSIX_MUTEX_FLAGS_MASK ) \ + != ( flags & ~POSIX_MUTEX_FLAGS_MASK ) \ + ) { \ + if ( !_POSIX_Mutex_Auto_initialization( the_mutex ) ) { \ + return EINVAL; \ + } \ + } \ + } while ( 0 ) + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ + diff --git a/cpukit/include/rtems/posix/posixapi.h b/cpukit/include/rtems/posix/posixapi.h new file mode 100644 index 0000000000..29394ab94e --- /dev/null +++ b/cpukit/include/rtems/posix/posixapi.h @@ -0,0 +1,146 @@ +/** + * @file + * + * @brief POSIX API Implementation + * + * This include file defines the top level interface to the POSIX API + * implementation in RTEMS. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_POSIX_POSIXAPI_H +#define _RTEMS_POSIX_POSIXAPI_H + +#include +#include +#include +#include +#include +#include + +#include + +/** + * @defgroup POSIXAPI RTEMS POSIX API + * + * RTEMS POSIX API definitions and modules. + * + */ +/**@{**/ + +/** + * @brief POSIX API Fatal domains. + */ +typedef enum { + POSIX_FD_PTHREAD, /**< A pthread thread error. */ + POSIX_FD_PTHREAD_ONCE /**< A pthread once error. */ +} POSIX_Fatal_domain; + +/** + * @brief POSIX API Fatal error. + * + * A common method of rasing a POSIX API fatal error. + * + * @param[in] domain The POSIX error domain. + * @param[in] eno The error number as defined in errno.h. + */ +void _POSIX_Fatal_error( POSIX_Fatal_domain domain, int eno ); + +extern const int _POSIX_Get_by_name_error_table[ 3 ]; + +RTEMS_INLINE_ROUTINE int _POSIX_Get_by_name_error( + Objects_Get_by_name_error error +) +{ + _Assert( (size_t) error < RTEMS_ARRAY_SIZE( _POSIX_Get_by_name_error_table ) ); + return _POSIX_Get_by_name_error_table[ error ]; +} + +RTEMS_INLINE_ROUTINE int _POSIX_Get_error( Status_Control status ) +{ + return STATUS_GET_POSIX( status ); +} + +RTEMS_INLINE_ROUTINE int _POSIX_Get_error_after_wait( + const Thread_Control *executing +) +{ + return _POSIX_Get_error( _Thread_Wait_get_status( executing ) ); +} + +RTEMS_INLINE_ROUTINE int _POSIX_Zero_or_minus_one_plus_errno( + Status_Control status +) +{ + if ( status == STATUS_SUCCESSFUL ) { + return 0; + } + + rtems_set_errno_and_return_minus_one( _POSIX_Get_error( status ) ); +} + +/** + * @brief Macro to generate a function body to get a POSIX object by + * identifier. + * + * Generates a function body to get the object for the specified identifier. + * Performs automatic initialization if requested and necessary. This is an + * ugly macro, since C lacks support for templates. + */ +#define _POSIX_Get_object_body( \ + type, \ + id, \ + queue_context, \ + info, \ + initializer, \ + init \ +) \ + Objects_Control *the_object; \ + if ( id == NULL ) { \ + return NULL; \ + } \ + _Thread_queue_Context_initialize( queue_context ); \ + the_object = _Objects_Get( \ + (Objects_Id) *id, \ + &queue_context->Lock_context.Lock_context, \ + info \ + ); \ + if ( the_object == NULL ) { \ + _Once_Lock(); \ + if ( *id == initializer ) { \ + init( id, NULL ); \ + } \ + _Once_Unlock(); \ + the_object = _Objects_Get( \ + (Objects_Id) *id, \ + &queue_context->Lock_context.Lock_context, \ + info \ + ); \ + } \ + return (type *) the_object + +/* + * See also The Open Group Base Specifications Issue 7, IEEE Std 1003.1-2008, + * 2016 Edition, subsection 2.9.9, Synchronization Object Copies and + * Alternative Mappings. + * + * http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_09_09 + */ +RTEMS_INLINE_ROUTINE bool _POSIX_Is_valid_pshared( int pshared ) +{ + return pshared == PTHREAD_PROCESS_PRIVATE || + pshared == PTHREAD_PROCESS_SHARED; +} + +/** @} */ + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/posix/priorityimpl.h b/cpukit/include/rtems/posix/priorityimpl.h new file mode 100644 index 0000000000..eb2e3e059f --- /dev/null +++ b/cpukit/include/rtems/posix/priorityimpl.h @@ -0,0 +1,109 @@ +/** + * @file + * + * @brief POSIX Priority Support + * + * This include file defines the interface to the POSIX priority + * implementation. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_POSIX_PRIORITYIMPL_H +#define _RTEMS_POSIX_PRIORITYIMPL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup POSIX_PRIORITY POSIX Priority Support + * + * @ingroup POSIXAPI + * + * @brief Interface to the POSIX Priority Implementation. + * + * @{ + */ + +/** + * This is the numerically least important POSIX priority. + */ +#define POSIX_SCHEDULER_MINIMUM_PRIORITY (1) + +/** + * @brief Gets the maximum POSIX API priority for this scheduler instance. + * + * Such a priority is valid. A scheduler instance may support priority values + * that are not representable as an integer. + * + * @return The maximum POSIX API priority for this scheduler instance. + */ +RTEMS_INLINE_ROUTINE int _POSIX_Priority_Get_maximum( + const Scheduler_Control *scheduler +) +{ + _Assert( (int) scheduler->maximum_priority > 1 ); + return (int) scheduler->maximum_priority - 1; +} + +/** + * @brief Converts the POSIX API priority to the corresponding SuperCore + * priority and validates it. + * + * According to POSIX, numerically higher values represent higher priorities. + * Thus, SuperCore has priorities run in the opposite sense of the POSIX API. + * + * Let N be the maximum priority of this scheduler instance. The SuperCore + * priority zero is system reserved (PRIORITY_PSEUDO_ISR). There are only + * N - 1 POSIX API priority levels since a thread at SuperCore priority N would + * never run because of the idle threads. This is necessary because GNAT maps + * the lowest Ada task priority to the lowest thread priority. The lowest + * priority Ada task should get to run, so there is a fundamental conflict with + * having N priorities. + * + * @param[in] scheduler The scheduler instance. + * @param[in] priority The POSIX API priority to convert and validate. + * @param[out] valid Indicates if the POSIX API priority is valid and a + * corresponding SuperCore priority in the specified scheduler instance + * exists. + * + * @return The corresponding SuperCore priority. + */ +Priority_Control _POSIX_Priority_To_core( + const Scheduler_Control *scheduler, + int priority, + bool *valid +); + +/** + * @brief Converts the SuperCore priority to the corresponding POSIX API + * priority. + * + * @param[in] scheduler The scheduler instance. + * @param[in] priority The SuperCore priority to convert. + * + * @return The corresponding POSIX API priority. + */ +int _POSIX_Priority_From_core( + const Scheduler_Control *scheduler, + Priority_Control priority +); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/include/rtems/posix/psignal.h b/cpukit/include/rtems/posix/psignal.h new file mode 100644 index 0000000000..ed98442e32 --- /dev/null +++ b/cpukit/include/rtems/posix/psignal.h @@ -0,0 +1,35 @@ +/** + * @file + * + * @brief Internal Information about POSIX Signals + * + * This include file defines internal information about POSIX signals. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_POSIX_PSIGNAL_H +#define _RTEMS_POSIX_PSIGNAL_H + +#include + +#include + +/* + * POSIX internal siginfo structure + */ + +typedef struct { + Chain_Node Node; + siginfo_t Info; +} POSIX_signals_Siginfo_node; + +#endif +/* end of file */ diff --git a/cpukit/include/rtems/posix/psignalimpl.h b/cpukit/include/rtems/posix/psignalimpl.h new file mode 100644 index 0000000000..cccc3dafc9 --- /dev/null +++ b/cpukit/include/rtems/posix/psignalimpl.h @@ -0,0 +1,140 @@ +/** + * @file + * + * @brief POSIX Signals Support + * + * This include file defines internal information about POSIX signals. + */ + +/* + * COPYRIGHT (c) 1989-2013. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_POSIX_PSIGNALIMPL_H +#define _RTEMS_POSIX_PSIGNALIMPL_H + +/** + * @defgroup POSIX_SIGNALS POSIX Signals Support + * + * @ingroup POSIXAPI + * + * @brief Internal Information about POSIX Signals + * + */ +/**@{**/ + +#include +#include +#include +#include +#include +#include + +#define POSIX_SIGNALS_TQ_OPERATIONS &_Thread_queue_Operations_FIFO + +#define _States_Is_interruptible_signal( _states ) \ + ( ((_states) & \ + (STATES_WAITING_FOR_SIGNAL|STATES_INTERRUPTIBLE_BY_SIGNAL)) == \ + (STATES_WAITING_FOR_SIGNAL|STATES_INTERRUPTIBLE_BY_SIGNAL)) + +#define SIGACTION_TERMINATE \ + { 0, SIGNAL_ALL_MASK, {_POSIX_signals_Abnormal_termination_handler} } +#define SIGACTION_IGNORE \ + { 0, SIGNAL_ALL_MASK, {SIG_IGN} } +#define SIGACTION_STOP \ + { 0, SIGNAL_ALL_MASK, {_POSIX_signals_Stop_handler} } +#define SIGACTION_CONTINUE \ + { 0, SIGNAL_ALL_MASK, {_POSIX_signals_Continue_handler} } + +#define SIG_ARRAY_MAX (SIGRTMAX + 1) + +/* + * Variables + */ + +extern sigset_t _POSIX_signals_Pending; + +extern const struct sigaction _POSIX_signals_Default_vectors[ SIG_ARRAY_MAX ]; + +extern struct sigaction _POSIX_signals_Vectors[ SIG_ARRAY_MAX ]; + +extern Thread_queue_Control _POSIX_signals_Wait_queue; + +extern Chain_Control _POSIX_signals_Inactive_siginfo; + +extern Chain_Control _POSIX_signals_Siginfo[ SIG_ARRAY_MAX ]; + +/* + * Internal routines + */ + +RTEMS_INLINE_ROUTINE void _POSIX_signals_Acquire( + Thread_queue_Context *queue_context +) +{ + _Thread_queue_Acquire( &_POSIX_signals_Wait_queue, queue_context ); +} + +RTEMS_INLINE_ROUTINE void _POSIX_signals_Release( + Thread_queue_Context *queue_context +) +{ + _Thread_queue_Release( &_POSIX_signals_Wait_queue, queue_context ); +} + +/** + * @brief Unlock POSIX signals thread. + */ +bool _POSIX_signals_Unblock_thread( + Thread_Control *the_thread, + int signo, + siginfo_t *info +); + +/** + * @brief Clear POSIX signals. + */ +bool _POSIX_signals_Clear_signals( + POSIX_API_Control *api, + int signo, + siginfo_t *info, + bool is_global, + bool check_blocked, + bool do_signals_acquire_release +); + +int _POSIX_signals_Send( + pid_t pid, + int sig, + const union sigval *value +); + +/** + * @brief Set POSIX process signals. + */ +void _POSIX_signals_Set_process_signals( + sigset_t mask +); + +void _POSIX_signals_Clear_process_signals( + int signo +); + +/* + * Default signal handlers + */ + +#define _POSIX_signals_Stop_handler NULL +#define _POSIX_signals_Continue_handler NULL + +void _POSIX_signals_Abnormal_termination_handler( int signo ); + +/** @} */ + +#endif +/* end of file */ diff --git a/cpukit/include/rtems/posix/pthread.h b/cpukit/include/rtems/posix/pthread.h new file mode 100644 index 0000000000..05783ff4ad --- /dev/null +++ b/cpukit/include/rtems/posix/pthread.h @@ -0,0 +1,55 @@ +/** + * @file + * + * @brief POSIX Threads Private Support + * + * This include file contains all the private support information for + * POSIX threads. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_POSIX_PTHREAD_H +#define _RTEMS_POSIX_PTHREAD_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup POSIX_PTHREAD POSIX Threads Support + * + * @ingroup POSIXAPI + * + * @brief Private Support Information for POSIX Threads + * + */ +/**@{**/ + +/** + * @brief POSIX threads initialize user threads body. + * + * This routine creates and starts all configured user + * initialization threads. + */ +extern void _POSIX_Threads_Initialize_user_threads_body(void); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/posix/pthreadattrimpl.h b/cpukit/include/rtems/posix/pthreadattrimpl.h new file mode 100644 index 0000000000..12b8559181 --- /dev/null +++ b/cpukit/include/rtems/posix/pthreadattrimpl.h @@ -0,0 +1,95 @@ +/** + * @file + * + * @brief POSIX Threads Private Support + * + * This include file contains all the private support information for + * POSIX threads. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_POSIX_PTHREADATTRIMPL_H +#define _RTEMS_POSIX_PTHREADATTRIMPL_H + +#include +#include + +#include +#include +#include +#if defined(RTEMS_POSIX_API) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup POSIX_PTHREAD + */ +/**@{**/ + +/** + * This variable contains the default POSIX Thread attributes. + */ +extern const pthread_attr_t _POSIX_Threads_Default_attributes; + +RTEMS_INLINE_ROUTINE void _POSIX_Threads_Copy_attributes( + pthread_attr_t *dst_attr, + const pthread_attr_t *src_attr +) +{ + *dst_attr = *src_attr; + _Assert( + dst_attr->affinitysetsize == sizeof(dst_attr->affinitysetpreallocated) + ); + dst_attr->affinityset = &dst_attr->affinitysetpreallocated; +} + +RTEMS_INLINE_ROUTINE void _POSIX_Threads_Initialize_attributes( + pthread_attr_t *attr +) +{ + _POSIX_Threads_Copy_attributes( + attr, + &_POSIX_Threads_Default_attributes + ); +} + +#if defined(RTEMS_POSIX_API) +RTEMS_INLINE_ROUTINE void _POSIX_Threads_Get_sched_param_sporadic( + const Thread_Control *the_thread, + const Scheduler_Control *scheduler, + struct sched_param *param +) +{ + const POSIX_API_Control *api; + + api = the_thread->API_Extensions[ THREAD_API_POSIX ]; + param->sched_ss_low_priority = _POSIX_Priority_From_core( + scheduler, + api->Sporadic.Low_priority.priority + ); + param->sched_ss_repl_period = api->Sporadic.sched_ss_repl_period; + param->sched_ss_init_budget = api->Sporadic.sched_ss_init_budget; + param->sched_ss_max_repl = api->Sporadic.sched_ss_max_repl; +} +#endif + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/posix/pthreadimpl.h b/cpukit/include/rtems/posix/pthreadimpl.h new file mode 100644 index 0000000000..3e2351e57e --- /dev/null +++ b/cpukit/include/rtems/posix/pthreadimpl.h @@ -0,0 +1,129 @@ +/** + * @file + * + * @brief POSIX Threads Private Support + * + * This include file contains all the private support information for + * POSIX threads. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_POSIX_PTHREADIMPL_H +#define _RTEMS_POSIX_PTHREADIMPL_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup POSIX_PTHREAD + */ +/**@{**/ + +/** + * The following sets the minimum stack size for POSIX threads. + */ +#define PTHREAD_MINIMUM_STACK_SIZE (_Stack_Minimum() * 2) + +/** + * The following defines the information control block used to manage + * this class of objects. + */ +extern Thread_Information _POSIX_Threads_Information; + +RTEMS_INLINE_ROUTINE void _POSIX_Threads_Sporadic_timer_insert( + Thread_Control *the_thread, + POSIX_API_Control *api +) +{ + the_thread->cpu_time_budget = + _Timespec_To_ticks( &api->Sporadic.sched_ss_init_budget ); + + _Watchdog_Per_CPU_insert_ticks( + &api->Sporadic.Timer, + _Per_CPU_Get(), + _Timespec_To_ticks( &api->Sporadic.sched_ss_repl_period ) + ); +} + +void _POSIX_Threads_Sporadic_timer( Watchdog_Control *watchdog ); + +/** + * @brief POSIX threads sporadic budget callout. + * + * This routine handles the sporadic scheduling algorithm. + * + * @param[in] the_thread is a pointer to the thread whose budget + * has been exceeded. + */ +void _POSIX_Threads_Sporadic_budget_callout( + Thread_Control *the_thread +); + +int _POSIX_Thread_Translate_to_sched_policy( + Thread_CPU_budget_algorithms budget_algorithm +); + +/** + * @brief Translate sched_param into SuperCore terms. + * + * This method translates the POSIX API sched_param into the corresponding + * SuperCore settings. + * + * @param[in] policy is the POSIX scheduling policy + * @param[in] param points to the scheduling parameter structure + * @param[in] budget_algorithm points to the output CPU Budget algorithm + * @param[in] budget_callout points to the output CPU Callout + * + * @retval 0 Indicates success. + * @retval error_code POSIX error code indicating failure. + */ +int _POSIX_Thread_Translate_sched_param( + int policy, + struct sched_param *param, + Thread_CPU_budget_algorithms *budget_algorithm, + Thread_CPU_budget_algorithm_callout *budget_callout +); + +RTEMS_INLINE_ROUTINE Thread_Control *_POSIX_Threads_Allocate(void) +{ + _Objects_Allocator_lock(); + + _Thread_Kill_zombies(); + + return (Thread_Control *) + _Objects_Allocate_unprotected( &_POSIX_Threads_Information.Objects ); +} + +RTEMS_INLINE_ROUTINE void _POSIX_Threads_Free ( + Thread_Control *the_pthread +) +{ + _Objects_Free( &_POSIX_Threads_Information.Objects, &the_pthread->Object ); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/posix/ptimer.h b/cpukit/include/rtems/posix/ptimer.h new file mode 100644 index 0000000000..f6de4ccb57 --- /dev/null +++ b/cpukit/include/rtems/posix/ptimer.h @@ -0,0 +1,88 @@ +/** + * @file + * + * @brief POSIX Timers Private Support + * + * This include file contains all the private support information for + * POSIX timers. + */ + +/* + * Initial Implementation: + * COPYRIGHT (c) 1998. Alfonso Escalera Piña + * Largely rewritten by Joel Sherrill (1999). + * + * COPYRIGHT (c) 1999-2013. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_POSIX_PTIMER_H +#define _RTEMS_POSIX_PTIMER_H + +/** + * @defgroup POSIX_PRIV_TIMERS POSIX Timers + * + * @ingroup POSIXAPI + */ +/**@{**/ +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/** + * @brief Create a Per-Process Timer + */ +int timer_create( + clockid_t clock_id, + struct sigevent *evp, + timer_t *timerid +); + +/** + * @brief Delete a Per-Process Timer + */ +int timer_delete( + timer_t timerid +); + +/** + * @brief Set a Per-Process Timer + */ +int timer_settime( + timer_t timerid, + int flags, + const struct itimerspec *value, + struct itimerspec *ovalue +); + +/** + * @brief Set a Per-Process Timer + */ +int timer_gettime( + timer_t timerid, + struct itimerspec *value +); + +/** + * @brief Get overrun count for a Per-Process Timer + * + * The expiration of a timer must increase by one a counter. + * After the signal handler associated to the timer finishes + * its execution, _POSIX_Timer_TSR will have to set this counter to 0. + */ +int timer_getoverrun( + timer_t timerid +); + +#ifdef __cplusplus +} +#endif +/** @} */ + +#endif /* _RTEMS_POSIX_PTIMER_H */ diff --git a/cpukit/include/rtems/posix/rwlockimpl.h b/cpukit/include/rtems/posix/rwlockimpl.h new file mode 100644 index 0000000000..b92ca9d04c --- /dev/null +++ b/cpukit/include/rtems/posix/rwlockimpl.h @@ -0,0 +1,64 @@ +/** + * @file + * + * @brief Inlined Routines from the POSIX RWLock Manager + * + * This file contains the static inlin implementation of the inlined + * routines from the POSIX RWLock Manager. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_POSIX_RWLOCKIMPL_H +#define _RTEMS_POSIX_RWLOCKIMPL_H + +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define POSIX_RWLOCK_MAGIC 0x9621dabdUL + +typedef struct { + unsigned long flags; + CORE_RWLock_Control RWLock; +} POSIX_RWLock_Control; + +RTEMS_INLINE_ROUTINE POSIX_RWLock_Control *_POSIX_RWLock_Get( + pthread_rwlock_t *rwlock +) +{ + return (POSIX_RWLock_Control *) rwlock; +} + +bool _POSIX_RWLock_Auto_initialization( POSIX_RWLock_Control *the_rwlock ); + +#define POSIX_RWLOCK_VALIDATE_OBJECT( rw ) \ + do { \ + if ( ( rw ) == NULL ) { \ + return EINVAL; \ + } \ + if ( ( (uintptr_t) ( rw ) ^ POSIX_RWLOCK_MAGIC ) != ( rw )->flags ) { \ + if ( !_POSIX_RWLock_Auto_initialization( rw ) ) { \ + return EINVAL; \ + } \ + } \ + } while ( 0 ) + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/posix/semaphore.h b/cpukit/include/rtems/posix/semaphore.h new file mode 100644 index 0000000000..9133db22be --- /dev/null +++ b/cpukit/include/rtems/posix/semaphore.h @@ -0,0 +1,56 @@ +/** + * @file + * + * @brief Private Support Information for POSIX Semaphores + * + * This include file contains all the private support information for + * POSIX Semaphores. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_POSIX_SEMAPHORE_H +#define _RTEMS_POSIX_SEMAPHORE_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup POSIXSemaphorePrivate POSIX Semaphore Private Support + * + * @ingroup POSIXAPI + * + * This defines the internal implementation support for POSIX semaphores. + */ +/**@{*/ + +/* + * Data Structure used to manage a POSIX semaphore + */ + +typedef struct { + Objects_Control Object; + sem_t Semaphore; + bool linked; + uint32_t open_count; +} POSIX_Semaphore_Control; + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/posix/semaphoreimpl.h b/cpukit/include/rtems/posix/semaphoreimpl.h new file mode 100644 index 0000000000..fd17743699 --- /dev/null +++ b/cpukit/include/rtems/posix/semaphoreimpl.h @@ -0,0 +1,143 @@ +/** + * @file + * + * @brief Private Inlined Routines for POSIX Semaphores + * + * This include file contains the static inline implementation of the private + * inlined routines for POSIX Semaphores. + */ + +/* + * COPYRIGHT (c) 1989-2013. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_POSIX_SEMAPHOREIMPL_H +#define _RTEMS_POSIX_SEMAPHOREIMPL_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief This is a random number used to check if a semaphore object is + * properly initialized. + */ +#define POSIX_SEMAPHORE_MAGIC 0x5d367fe7UL + +/** + * This defines the information control block used to manage + * this class of objects. + */ +extern Objects_Information _POSIX_Semaphore_Information; + +RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control * + _POSIX_Semaphore_Allocate_unprotected( void ) +{ + return (POSIX_Semaphore_Control *) + _Objects_Allocate_unprotected( &_POSIX_Semaphore_Information ); +} + +/** + * @brief POSIX Semaphore Free + * + * This routine frees a semaphore control block to the + * inactive chain of free semaphore control blocks. + */ +RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Free ( + POSIX_Semaphore_Control *the_semaphore +) +{ + _Objects_Free( &_POSIX_Semaphore_Information, &the_semaphore->Object ); +} + +RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *_POSIX_Semaphore_Get( + sem_t *sem +) +{ + return RTEMS_CONTAINER_OF( sem, POSIX_Semaphore_Control, Semaphore ); +} + +RTEMS_INLINE_ROUTINE bool _POSIX_Semaphore_Is_named( const sem_t *sem ) +{ + return sem->_Semaphore._Queue._name != NULL; +} + +RTEMS_INLINE_ROUTINE bool _POSIX_Semaphore_Is_busy( const sem_t *sem ) +{ + return sem->_Semaphore._Queue._heads != NULL; +} + +RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Initialize( + sem_t *sem, + const char *name, + unsigned int value +) +{ + sem->_flags = (uintptr_t) sem ^ POSIX_SEMAPHORE_MAGIC; + _Semaphore_Initialize_named( &sem->_Semaphore, name, value ); +} + +RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Destroy( sem_t *sem ) +{ + sem->_flags = 0; + _Semaphore_Destroy( &sem->_Semaphore ); +} + +/** + * @brief POSIX Semaphore Delete + * + * This routine supports the sem_close and sem_unlink routines. + */ +void _POSIX_Semaphore_Delete( POSIX_Semaphore_Control *the_semaphore ); + +/** + * @brief POSIX Semaphore Namespace Remove + */ +RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Namespace_remove ( + POSIX_Semaphore_Control *the_semaphore +) +{ + _Objects_Namespace_remove( + &_POSIX_Semaphore_Information, &the_semaphore->Object ); +} + +RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *_POSIX_Semaphore_Get_by_name( + const char *name, + size_t *name_length_p, + Objects_Get_by_name_error *error +) +{ + return (POSIX_Semaphore_Control *) _Objects_Get_by_name( + &_POSIX_Semaphore_Information, + name, + name_length_p, + error + ); +} + +#define POSIX_SEMAPHORE_VALIDATE_OBJECT( sem ) \ + do { \ + if ( \ + ( sem ) == NULL \ + || ( (uintptr_t) ( sem ) ^ POSIX_SEMAPHORE_MAGIC ) != ( sem )->_flags \ + ) { \ + rtems_set_errno_and_return_minus_one( EINVAL ); \ + } \ + } while ( 0 ) + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/posix/shm.h b/cpukit/include/rtems/posix/shm.h new file mode 100644 index 0000000000..d2b6036493 --- /dev/null +++ b/cpukit/include/rtems/posix/shm.h @@ -0,0 +1,213 @@ +/** + * @file + * + * @brief Internal Support for POSIX Shared Memory + */ + +/* + * Copyright (c) 2016 Gedare Bloom. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_POSIX_SHM_H +#define _RTEMS_POSIX_SHM_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup POSIXShmPrivate POSIX Shared Memory Private Support + * + * @ingroup POSIXAPI + * + * Internal implementation support for POSIX shared memory. + * @{ + */ +typedef struct POSIX_Shm_Object_operations POSIX_Shm_Object_operations; +extern const POSIX_Shm_Object_operations _POSIX_Shm_Object_operations; + +/** + * @brief Encapsulation for the storage and manipulation of shm objects. + */ +typedef struct { + /** + * @brief The handle is private for finding object storage. + */ + void *handle; + + /** + * @brief The number of bytes allocated to the object. A size of 0 with + * a handle of NULL means no object is allocated. + */ + size_t size; + + /** + * @brief Implementation-specific operations on shm objects. + */ + const POSIX_Shm_Object_operations *ops; +} POSIX_Shm_Object; + +/** + * @brief Operations on POSIX Shared Memory Objects. + */ +struct POSIX_Shm_Object_operations { + /** + * @brief Allocates a new @a shm_obj with initial @a size. + * + * New shared memory is initialized to zeroes. + * + * Returns 0 for success. + */ + int ( *object_create ) ( POSIX_Shm_Object *shm_obj, size_t size ); + + /** + * @brief Changes the @a shm_obj size to @a size. + * + * Zeroes out the portion of the shared memory object that shrinks or grows. + * + * Returns 0 for success. + */ + int ( *object_resize ) ( POSIX_Shm_Object *shm_obj, size_t size ); + + /** + * @brief Deletes the @a shm_obj. + * + * Zeroes out the memory. + * + * Returns 0 for success. + */ + int ( *object_delete ) ( POSIX_Shm_Object *shm_obj ); + + /** + * @brief Copies up to @count bytes of the @a shm_obj data into @a buf. + * + * Returns the number of bytes read (copied) into @a buf. + */ + int ( *object_read ) ( POSIX_Shm_Object *shm_obj, void *buf, size_t count ); + + /** + * @brief Maps a shared memory object. + * + * Establishes a memory mapping between the shared memory object and the + * caller. + * + * Returns the mapped address of the object. + */ + void * ( *object_mmap ) ( POSIX_Shm_Object *shm_obj, size_t len, int prot, off_t off); +}; + +/** + * @brief Control for a POSIX Shared Memory Object + */ +typedef struct { + Objects_Control Object; + Thread_queue_Control Wait_queue; + + int reference_count; + + POSIX_Shm_Object shm_object; + + uid_t uid; + gid_t gid; + mode_t mode; + int oflag; + + time_t atime; + time_t mtime; + time_t ctime; +} POSIX_Shm_Control; + +/** + * @brief object_create operation for shm objects stored in RTEMS Workspace. + */ +extern int _POSIX_Shm_Object_create_from_workspace( + POSIX_Shm_Object *shm_obj, + size_t size +); + +/** + * @brief object_delete operation for shm objects stored in RTEMS Workspace. + */ +extern int _POSIX_Shm_Object_delete_from_workspace( POSIX_Shm_Object *shm_obj ); + +/** + * @brief object_resize operation for shm objects stored in RTEMS Workspace. + */ +extern int _POSIX_Shm_Object_resize_from_workspace( + POSIX_Shm_Object *shm_obj, + size_t size +); + +/** + * @brief object_read operation for shm objects stored in RTEMS Workspace. + */ +extern int _POSIX_Shm_Object_read_from_workspace( + POSIX_Shm_Object *shm_obj, + void *buf, + size_t count +); + +/** + * @brief object_mmap operation for shm objects stored in RTEMS Workspace. + */ +extern void * _POSIX_Shm_Object_mmap_from_workspace( + POSIX_Shm_Object *shm_obj, + size_t len, + int prot, + off_t off +); + +/** + * @brief object_create operation for shm objects stored in C program heap. + */ +extern int _POSIX_Shm_Object_create_from_heap( + POSIX_Shm_Object *shm_obj, + size_t size +); + +/** + * @brief object_delete operation for shm objects stored in C program heap. + */ +extern int _POSIX_Shm_Object_delete_from_heap( POSIX_Shm_Object *shm_obj ); + +/** + * @brief object_resize operation for shm objects stored in C program heap. + */ +extern int _POSIX_Shm_Object_resize_from_heap( + POSIX_Shm_Object *shm_obj, + size_t size +); + +/** + * @brief object_read operation for shm objects stored in C program heap. + */ +extern int _POSIX_Shm_Object_read_from_heap( + POSIX_Shm_Object *shm_obj, + void *buf, + size_t count +); + +/** + * @brief object_mmap operation for shm objects stored in C program heap. + */ +extern void * _POSIX_Shm_Object_mmap_from_heap( + POSIX_Shm_Object *shm_obj, + size_t len, + int prot, + off_t off +); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/include/rtems/posix/shmimpl.h b/cpukit/include/rtems/posix/shmimpl.h new file mode 100644 index 0000000000..f16af8123d --- /dev/null +++ b/cpukit/include/rtems/posix/shmimpl.h @@ -0,0 +1,135 @@ +/** + * @file + * + * @brief Private Support Information for POSIX Shared Memory + * + */ + +/* + * Copyright (c) 2016 Gedare Bloom. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_POSIX_SHMIMPL_H +#define _RTEMS_POSIX_SHMIMPL_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @ingroup POSIXShmPrivate + * @{ + */ + +extern Objects_Information _POSIX_Shm_Information; + +RTEMS_INLINE_ROUTINE POSIX_Shm_Control *_POSIX_Shm_Allocate_unprotected( void ) +{ + return (POSIX_Shm_Control *) + _Objects_Allocate_unprotected( &_POSIX_Shm_Information ); +} + +/** + * @brief POSIX Shared Memory Free + * + * This routine frees a shm control block. + */ +RTEMS_INLINE_ROUTINE void _POSIX_Shm_Free ( + POSIX_Shm_Control *the_shm +) +{ + _Objects_Free( &_POSIX_Shm_Information, &the_shm->Object ); +} + +RTEMS_INLINE_ROUTINE POSIX_Shm_Control *_POSIX_Shm_Get_by_name( + const char *name, + size_t *name_length_p, + Objects_Get_by_name_error *error +) +{ + return (POSIX_Shm_Control *) _Objects_Get_by_name( + &_POSIX_Shm_Information, + name, + name_length_p, + error + ); +} + +RTEMS_INLINE_ROUTINE void _POSIX_Shm_Update_atime( + POSIX_Shm_Control *shm +) +{ + struct timeval now; + gettimeofday( &now, 0 ); + shm->atime = now.tv_sec; +} + +RTEMS_INLINE_ROUTINE void _POSIX_Shm_Update_mtime_ctime( + POSIX_Shm_Control *shm +) +{ + struct timeval now; + gettimeofday( &now, 0 ); + shm->mtime = now.tv_sec; + shm->ctime = now.tv_sec; +} + +static inline POSIX_Shm_Control* iop_to_shm( rtems_libio_t *iop ) +{ + return (POSIX_Shm_Control*) iop->data1; +} + +static inline POSIX_Shm_Control* loc_to_shm( + const rtems_filesystem_location_info_t *loc +) +{ + return (POSIX_Shm_Control*) loc->node_access; +} + +static inline int POSIX_Shm_Attempt_delete( + POSIX_Shm_Control* shm +) +{ + Objects_Control *obj; + ISR_lock_Context lock_ctx; + int err; + + err = 0; + + _Objects_Allocator_lock(); + --shm->reference_count; + if ( shm->reference_count == 0 ) { + if ( (*shm->shm_object.ops->object_delete)( &shm->shm_object ) != 0 ) { + err = EIO; + } + } + /* check if the object has been unlinked yet. */ + obj = _Objects_Get( shm->Object.id, &lock_ctx, &_POSIX_Shm_Information ); + if ( obj == NULL ) { + /* if it was unlinked, then it can be freed. */ + _POSIX_Shm_Free( shm ); + } else { + /* it will be freed when it is unlinked. */ + _ISR_lock_ISR_enable( &lock_ctx ); + } + _Objects_Allocator_unlock(); + return err; +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/include/rtems/posix/sigset.h b/cpukit/include/rtems/posix/sigset.h new file mode 100644 index 0000000000..96bcc086ba --- /dev/null +++ b/cpukit/include/rtems/posix/sigset.h @@ -0,0 +1,45 @@ +/** + * @file + * + * @brief POSIX Signal Sets Management Helper + * + * This file defines the interface to implementation helper for management + * of POSIX Signal Sets. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_POSIX_SIGSET_H +#define _RTEMS_POSIX_SIGSET_H + +#include // sigset_t + +/* + * Currently 32 signals numbered 1-32 are defined + */ + +#define SIGNAL_EMPTY_MASK 0x00000000L +#define SIGNAL_ALL_MASK 0xffffffffL + +static inline sigset_t signo_to_mask( + uint32_t sig +) +{ + return 1u << (sig - 1); +} + +static inline bool is_valid_signo( + int signo +) +{ + return ((signo) >= 1 && (signo) <= 32 ); +} + +#endif diff --git a/cpukit/include/rtems/posix/spinlockimpl.h b/cpukit/include/rtems/posix/spinlockimpl.h new file mode 100644 index 0000000000..d28e0391fc --- /dev/null +++ b/cpukit/include/rtems/posix/spinlockimpl.h @@ -0,0 +1,58 @@ +/** + * @file + * + * @brief Inlined Routines from the POSIX Spinlock Manager + * + * This file contains the static inlin implementation of the inlined + * routines from the POSIX Spinlock Manager. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * Copyright (c) 2016 embedded brains GmbH + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_POSIX_SPINLOCKIMPL_H +#define _RTEMS_POSIX_SPINLOCKIMPL_H + +#include + +#include + +#if defined(RTEMS_SMP) +#include +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { +#if defined(RTEMS_SMP) + SMP_ticket_lock_Control Lock; +#else + unsigned int reserved[ 2 ]; +#endif + ISR_Level interrupt_state; +} POSIX_Spinlock_Control; + +RTEMS_INLINE_ROUTINE POSIX_Spinlock_Control *_POSIX_Spinlock_Get( + pthread_spinlock_t *lock +) +{ + return (POSIX_Spinlock_Control *) lock; +} + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/posix/threadsup.h b/cpukit/include/rtems/posix/threadsup.h new file mode 100644 index 0000000000..d3ee5b28bb --- /dev/null +++ b/cpukit/include/rtems/posix/threadsup.h @@ -0,0 +1,98 @@ +/** + * @file + * + * @brief POSIX Thread API Support + * + * This defines the POSIX thread API extension. + */ + +/* + * COPYRIGHT (c) 1989-2014. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_POSIX_THREADSUP_H +#define _RTEMS_POSIX_THREADSUP_H + +#include +#include + +#include +#include + +/** + * @defgroup POSIX_THREAD POSIX Thread API Extension + * + * @ingroup POSIXAPI + * + */ +/**@{**/ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * This defines the POSIX API support structure associated with + * each thread in a system with POSIX configured. + */ +typedef struct { + /** + * @brief Control block for the sporadic server scheduling policy. + */ + struct { + /** The thread of this sporadic control block */ + Thread_Control *thread; + + /** + * @brief This is the timer which controls when the thread executes at high + * and low priority when using the sporadic server scheduling policy. + */ + Watchdog_Control Timer; + + /** + * @brief The low priority when using the sporadic server scheduling + * policy. + */ + Priority_Node Low_priority; + + /** + * @brief Replenishment period for sporadic server. + */ + struct timespec sched_ss_repl_period; + + /** + * @brief Initial budget for sporadic server. + */ + struct timespec sched_ss_init_budget; + + /** + * @brief Maximum pending replenishments. + * + * Only used by pthread_getschedparam() and pthread_getattr_np(). + */ + int sched_ss_max_repl; + } Sporadic; + + /** This is the set of signals which are currently unblocked. */ + sigset_t signals_unblocked; + /** This is the set of signals which are currently pending. */ + sigset_t signals_pending; + + /** + * @brief Signal post-switch action in case signals are pending. + */ + Thread_Action Signal_action; +} POSIX_API_Control; + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/posix/timer.h b/cpukit/include/rtems/posix/timer.h new file mode 100644 index 0000000000..79fe093219 --- /dev/null +++ b/cpukit/include/rtems/posix/timer.h @@ -0,0 +1,60 @@ +/** + * @file + * + * @brief POSIX Timers Internal Support + * + * This include files defines the internal support for implementation of + * POSIX Timers. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_POSIX_TIMER_H +#define _RTEMS_POSIX_TIMER_H + +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup POSIX_INTERNAL_TIMERS POSIX Timer Private Support + * + * @ingroup POSIXAPI + */ +/**@{*/ + +/* + * Data for a timer + */ +typedef struct { + Objects_Control Object; + Watchdog_Control Timer; /* Internal Timer */ + pthread_t thread_id; /* Thread identifier */ + char state; /* State of the timer */ + struct sigevent inf; /* Information associated to the timer */ + struct itimerspec timer_data; /* Timing data of the timer */ + uint32_t ticks; /* Number of ticks of the initialization */ + uint32_t overrun; /* Number of expirations of the timer */ + struct timespec time; /* Time at which the timer was started */ +} POSIX_Timer_Control; + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/posix/timerimpl.h b/cpukit/include/rtems/posix/timerimpl.h new file mode 100644 index 0000000000..42a814c992 --- /dev/null +++ b/cpukit/include/rtems/posix/timerimpl.h @@ -0,0 +1,134 @@ +/** + * @file + * + * @brief Inlined Routines from the POSIX Timer Manager + * + * This file contains the static inline implementation of the inlined routines + * from the POSIX Timer Manager. + */ + +/* + * COPYRIGHT (c) 1989-2013. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_POSIX_TIMERIMPL_H +#define _RTEMS_POSIX_TIMERIMPL_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** Timer is free */ +#define POSIX_TIMER_STATE_FREE 0x01 + +/** Created timer but not running */ +#define POSIX_TIMER_STATE_CREATE_NEW 0x02 + +/** Created timer and running */ +#define POSIX_TIMER_STATE_CREATE_RUN 0x03 + +/** Created, ran and stopped timer */ +#define POSIX_TIMER_STATE_CREATE_STOP 0x04 + +/** Indicates that the fire time is relative to the current one */ +#define POSIX_TIMER_RELATIVE 0 + +/* + * POSIX defines TIMER_ABSTIME but no constant for relative. So + * we have one internally but we need to be careful it has a different + * value. + */ +#if (POSIX_TIMER_RELATIVE == TIMER_ABSTIME) +#error "POSIX_TIMER_RELATIVE == TIMER_ABSTIME" +#endif + +/** + * The following defines the information control block used to manage + * this class of objects. + */ +extern Objects_Information _POSIX_Timer_Information; + +/** + * @brief POSIX Timer Allocate + * + * This function allocates a timer control block from + * the inactive chain of free timer control blocks. + */ +RTEMS_INLINE_ROUTINE POSIX_Timer_Control *_POSIX_Timer_Allocate( void ) +{ + return (POSIX_Timer_Control *) _Objects_Allocate( &_POSIX_Timer_Information ); +} + +/** + * @brief POSIX Timer Free + * + * This routine frees a timer control block to the + * inactive chain of free timer control blocks. + */ +RTEMS_INLINE_ROUTINE void _POSIX_Timer_Free ( + POSIX_Timer_Control *the_timer +) +{ + _Objects_Free( &_POSIX_Timer_Information, &the_timer->Object ); +} + +void _POSIX_Timer_TSR( Watchdog_Control *the_watchdog ); + +/** + * @brief POSIX Timer Get + * + * This function maps timer IDs to timer control blocks. + * If ID corresponds to a local timer, then it returns + * the timer control pointer which maps to ID and location + * is set to OBJECTS_LOCAL. Otherwise, location is set + * to OBJECTS_ERROR and the returned value is undefined. + */ +RTEMS_INLINE_ROUTINE POSIX_Timer_Control *_POSIX_Timer_Get ( + timer_t id, + ISR_lock_Context *lock_context +) +{ + return (POSIX_Timer_Control *) _Objects_Get( + (Objects_Id) id, + lock_context, + &_POSIX_Timer_Information + ); +} + +RTEMS_INLINE_ROUTINE Per_CPU_Control *_POSIX_Timer_Acquire_critical( + POSIX_Timer_Control *ptimer, + ISR_lock_Context *lock_context +) +{ + Per_CPU_Control *cpu; + + cpu = _Watchdog_Get_CPU( &ptimer->Timer ); + _Watchdog_Per_CPU_acquire_critical( cpu, lock_context ); + + return cpu; +} + +RTEMS_INLINE_ROUTINE void _POSIX_Timer_Release( + Per_CPU_Control *cpu, + ISR_lock_Context *lock_context +) +{ + _Watchdog_Per_CPU_release_critical( cpu, lock_context ); + _ISR_lock_ISR_enable( lock_context ); +} + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/profiling.h b/cpukit/include/rtems/profiling.h new file mode 100644 index 0000000000..9e434b2a3c --- /dev/null +++ b/cpukit/include/rtems/profiling.h @@ -0,0 +1,333 @@ +/** + * @file + * + * @ingroup Profiling + * + * @brief Profiling API + */ + +/* + * Copyright (c) 2014 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_PROFILING_H +#define _RTEMS_PROFILING_H + +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup Profiling Profiling Support + * + * @brief The profiling support offers functions to report profiling + * information available in the system. + * + * Profiling support is by default disabled. It must be enabled via the + * configure command line with the --enable-profiling option. In this + * case the RTEMS_PROFILING pre-processor symbol is defined and profiling + * statistics will be gathered during system run-time. The profiling support + * increases the time of critical sections and has some memory overhead. The + * overhead should be acceptable for most applications. The aim of the + * profiling implementation is to be available even for production systems so + * that verification is simplified. + * + * Profiling information includes critical timing values such as the maximum + * time of disabled thread dispatching which is a measure for the thread + * dispatch latency. On SMP configurations statistics of all SMP locks in the + * system are available. + * + * Profiling information can be retrieved via rtems_profiling_iterate() and + * reported as an XML dump via rtems_profiling_report_xml(). These functions + * are always available, but actual profiling data is only available if enabled + * at build configuration time. + * + * @{ + */ + +/** + * @brief Type of profiling data. + */ +typedef enum { + /** + * @brief Type of per-CPU profiling data. + * + * @see rtems_profiling_per_cpu. + */ + RTEMS_PROFILING_PER_CPU, + + /** + * @brief Type of SMP lock profiling data. + * + * @see rtems_profiling_smp_lock. + */ + RTEMS_PROFILING_SMP_LOCK +} rtems_profiling_type; + +/** + * @brief The profiling data header. + */ +typedef struct { + /** + * @brief The profiling data type. + */ + rtems_profiling_type type; +} rtems_profiling_header; + +/** + * @brief Per-CPU profiling data. + * + * Theoretically all values in this structure can overflow, but the integer + * types are chosen so that they cannot overflow in practice. On systems with + * a 1GHz CPU counter, the 64-bit integers can overflow in about 58 years. + * Since the system should not spend most of the time in critical sections the + * actual system run-time is much longer. Several other counters in the system + * will overflow before we get a problem in the profiling area. + */ +typedef struct { + /** + * @brief The profiling data header. + */ + rtems_profiling_header header; + + /** + * @brief The processor index of this profiling data. + */ + uint32_t processor_index; + + /** + * @brief The maximum time of disabled thread dispatching in nanoseconds. + */ + uint32_t max_thread_dispatch_disabled_time; + + /** + * @brief Count of times when the thread dispatch disable level changes from + * zero to one in thread context. + * + * This value may overflow. + */ + uint64_t thread_dispatch_disabled_count; + + /** + * @brief Total time of disabled thread dispatching in nanoseconds. + * + * The average time of disabled thread dispatching is the total time of + * disabled thread dispatching divided by the thread dispatch disabled + * count. + * + * This value may overflow. + */ + uint64_t total_thread_dispatch_disabled_time; + + /** + * @brief The maximum interrupt delay in nanoseconds if supported by the + * hardware. + * + * The interrupt delay is the time interval from the recognition of an + * interrupt signal by the hardware up to the execution start of the + * corresponding high-level handler. The interrupt delay is the main + * contributor to the interrupt latency. To measure this time hardware + * support is required. A time stamp unit must capture the interrupt signal + * recognition time. If no hardware support is available, then this field + * will have a constant value of zero. + */ + uint32_t max_interrupt_delay; + + /** + * @brief The maximum time spent to process a single sequence of nested + * interrupts in nanoseconds. + * + * This is the time interval between the change of the interrupt nest level + * from zero to one and the change back from one to zero. It is the measured + * worst-case execution time of interrupt service routines. Please note that + * in case of nested interrupts this time includes the combined execution + * time and not the maximum time of an individual interrupt service routine. + */ + uint32_t max_interrupt_time; + + /** + * @brief Count of times when the interrupt nest level changes from zero to + * one. + * + * This value may overflow. + */ + uint64_t interrupt_count; + + /** + * @brief Total time of interrupt processing in nanoseconds. + * + * The average time of interrupt processing is the total time of interrupt + * processing divided by the interrupt count. + * + * This value may overflow. + */ + uint64_t total_interrupt_time; +} rtems_profiling_per_cpu; + +/** + * @brief Count of lock contention counters for SMP lock profiling. + */ +#define RTEMS_PROFILING_SMP_LOCK_CONTENTION_COUNTS 4 + +/** + * @brief SMP lock profiling data. + * + * The lock acquire attempt instant is the point in time right after the + * interrupt disable action in the lock acquire sequence. + * + * The lock acquire instant is the point in time right after the lock + * acquisition. This is the begin of the critical section code execution. + * + * The lock acquire time is the time elapsed between the lock acquire attempt + * instant and the lock acquire instant. + * + * The lock release instant is the point in time right before the interrupt + * enable action in the lock release sequence. + * + * The lock section time is the time elapsed between the lock acquire instant + * and the lock release instant. + */ +typedef struct { + /** + * @brief The profiling data header. + */ + rtems_profiling_header header; + + /** + * @brief The lock name. + */ + const char *name; + + /** + * @brief The maximum lock acquire time in nanoseconds. + */ + uint32_t max_acquire_time; + + /** + * @brief The maximum lock section time in nanoseconds. + */ + uint32_t max_section_time; + + /** + * @brief The count of lock uses. + * + * This value may overflow. + */ + uint64_t usage_count; + + /** + * @brief Total lock acquire time in nanoseconds. + * + * The average lock acquire time is the total acquire time divided by the + * lock usage count. The ration of the total section and total acquire times + * gives a measure for the lock contention. + * + * This value may overflow. + */ + uint64_t total_acquire_time; + + /** + * @brief Total lock section time in nanoseconds. + * + * The average lock section time is the total section time divided by the + * lock usage count. + * + * This value may overflow. + */ + uint64_t total_section_time; + + /** + * @brief The counts of lock acquire operations by contention. + * + * The contention count for index N corresponds to a lock acquire attempt + * with an initial queue length of N. The last index corresponds to all + * lock acquire attempts with an initial queue length greater than or equal + * to RTEMS_PROFILING_SMP_LOCK_CONTENTION_COUNTS minus one. + * + * The values may overflow. + */ + uint64_t contention_counts[RTEMS_PROFILING_SMP_LOCK_CONTENTION_COUNTS]; +} rtems_profiling_smp_lock; + +/** + * @brief Collection of profiling data. + */ +typedef union { + /** + * @brief Header to specify the actual profiling data. + */ + rtems_profiling_header header; + + /** + * @brief Per-CPU profiling data if indicated by the header. + */ + rtems_profiling_per_cpu per_cpu; + + /** + * @brief SMP lock profiling data if indicated by the header. + */ + rtems_profiling_smp_lock smp_lock; +} rtems_profiling_data; + +/** + * @brief Visitor function for the profiling iteration. + * + * @param[in, out] arg The visitor argument. + * @param[in] data The current profiling data. + * + * @see rtems_profiling_iterate(). + */ +typedef void (*rtems_profiling_visitor)( + void *arg, + const rtems_profiling_data *data +); + +/** + * @brief Iterates through all profiling data of the system. + * + * @param[in] visitor The visitor. + * @param[in, out] visitor_arg The visitor argument. + */ +void rtems_profiling_iterate( + rtems_profiling_visitor visitor, + void *visitor_arg +); + +/** + * @brief Reports profiling data as XML. + * + * @param[in] name The name of the profiling report. + * @param[in] printer The RTEMS printer to send the output too. + * @param[in] indentation_level The current indentation level. + * @param[in] indentation The string used for indentation. + * + * @returns As specified by printf(). + */ +int rtems_profiling_report_xml( + const char *name, + const rtems_printer *printer, + uint32_t indentation_level, + const char *indentation +); + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_PROFILING_H */ diff --git a/cpukit/include/rtems/pty.h b/cpukit/include/rtems/pty.h new file mode 100644 index 0000000000..392bfd0969 --- /dev/null +++ b/cpukit/include/rtems/pty.h @@ -0,0 +1,76 @@ +/* + * /dev/ptyXX (A first version for pseudo-terminals) + * + * Author: Fernando RUIZ CASAS (fernando.ruiz@ctv.es) + * May 2001 + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + */ + +#ifndef _RTEMS_PTY_H +#define _RTEMS_PTY_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* Number of ptys to setup */ +extern size_t rtems_pty_maximum_ptys; + +/* Return the devname for a free pty slot. + * If no slot available (socket>=0) + * then the socket argument is closed + */ +char * rtems_pty_get(int socket); + + +/* OBSOLETE */ +#define get_pty rtems_pty_get + +rtems_device_driver pty_initialize( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg); +rtems_device_driver pty_open( + rtems_device_major_number major, + rtems_device_minor_number minor, + void * arg); +rtems_device_driver pty_close( + rtems_device_major_number major, + rtems_device_minor_number minor, + void * arg); +rtems_device_driver pty_read( + rtems_device_major_number major, + rtems_device_minor_number minor, + void * arg); +rtems_device_driver pty_write( + rtems_device_major_number major, + rtems_device_minor_number minor, + void * arg); +rtems_device_driver pty_control( + rtems_device_major_number major, + rtems_device_minor_number minor, + void * arg); + + +#define PTY_DRIVER_TABLE_ENTRY \ + { pty_initialize , pty_open , pty_close , \ + pty_read , pty_write , pty_control } + +/* Internal functions */ + +int telnet_pty_initialize(void); + +int telnet_pty_finalize(void); + +char *telnet_get_pty(int); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/include/rtems/qreslib.h b/cpukit/include/rtems/qreslib.h new file mode 100644 index 0000000000..3de8668fdb --- /dev/null +++ b/cpukit/include/rtems/qreslib.h @@ -0,0 +1,269 @@ +/** + * @file qreslib.h + * + * @brief Constants and Structures Associated + * with the QoS RES library in RTEMS + * + * This include file contains all the constants and structures + * associated with the QoS RES library in RTEMS. + * + * @note The library is available only together with CBS scheduler. + */ + +/* + * Copyright (C) 2011 Petr Benes. + * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef CONFIGURE_SCHEDULER_CBS + #error "qreslib.h available only with CONFIGURE_SCHEDULER_CBS" +#endif + +#ifndef _QRESLIB_H +#define _QRESLIB_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/** Return values. */ +typedef int qos_rv; + +/* Return codes. */ +#define QOS_OK SCHEDULER_CBS_OK +#define QOS_E_GENERIC SCHEDULER_CBS_ERROR_GENERIC +#define QOS_E_NO_MEMORY SCHEDULER_CBS_ERROR_NO_MEMORY +#define QOS_E_INVALID_PARAM SCHEDULER_CBS_ERROR_INVALID_PARAMETER +#define QOS_E_UNAUTHORIZED SCHEDULER_CBS_ERROR_UNAUTHORIZED +#define QOS_E_UNIMPLEMENTED SCHEDULER_CBS_ERROR_UNIMPLEMENTED +#define QOS_E_MISSING_COMPONENT SCHEDULER_CBS_ERROR_MISSING_COMPONENT +#define QOS_E_INCONSISTENT_STATE SCHEDULER_CBS_ERROR_INCONSISTENT_STATE +#define QOS_E_SYSTEM_OVERLOAD SCHEDULER_CBS_ERROR_SYSTEM_OVERLOAD +#define QOS_E_INTERNAL_ERROR SCHEDULER_CBS_ERROR_INTERNAL_ERROR +#define QOS_E_NOT_FOUND SCHEDULER_CBS_ERROR_NOT_FOUND +#define QOS_E_FULL SCHEDULER_CBS_ERROR_FULL +#define QOS_E_EMPTY SCHEDULER_CBS_ERROR_EMPTY +#define QOS_E_NOSERVER SCHEDULER_CBS_ERROR_NOSERVER + +/** Server id. */ +typedef Scheduler_CBS_Server_id qres_sid_t; + +/** Task id. */ +typedef rtems_id tid_t; + +/** Time value. */ +typedef time_t qres_time_t; + +/** Absolute time value */ +typedef time_t qres_atime_t; + +/** Server parameters. */ +typedef struct { + /** Relative deadline of the server. */ + qres_time_t P; + /** Budget (computation time) of the server. */ + qres_time_t Q; +} qres_params_t; + +/** + * @brief qres init + * + * Initializes the QoS RES library. + * + * @return status code. + */ +RTEMS_INLINE_ROUTINE qos_rv qres_init ( void ) +{ + return _Scheduler_CBS_Initialize(); +} + +/** + * @brief qres cleanup + * + * Cleanup resources associated to the QoS RES Library. + * + * @return status code. + */ +RTEMS_INLINE_ROUTINE qos_rv qres_cleanup ( void ) +{ + return _Scheduler_CBS_Cleanup(); +} + +/** + * @brief qres create server + * + * Create a new server with specified parameters. + * + * @return status code. + */ +RTEMS_INLINE_ROUTINE qos_rv qres_create_server ( + qres_params_t *params, + qres_sid_t *server_id +) +{ + return _Scheduler_CBS_Create_server( + (Scheduler_CBS_Parameters *) params, + NULL, + server_id + ); +} + +/** + * @brief qres attach thread + * + * Attach a task to an already existing server. + * + * @return status code. + */ +RTEMS_INLINE_ROUTINE qos_rv qres_attach_thread ( + qres_sid_t server_id, + pid_t pid, + tid_t task_id +) +{ + return _Scheduler_CBS_Attach_thread( server_id, task_id ); +} + +/** + * @brief qres detach thread + * + * Detach from the QoS Server. + * + * @return status code. + */ +RTEMS_INLINE_ROUTINE qos_rv qres_detach_thread ( + qres_sid_t server_id, + pid_t pid, + tid_t task_id +) +{ + return _Scheduler_CBS_Detach_thread( server_id, task_id ); +} + +/** + * @brief qres destroy server + * + * Detach all tasks from a server and destroy it. + * + * @return status code. + */ +RTEMS_INLINE_ROUTINE qos_rv qres_destroy_server ( + qres_sid_t server_id +) +{ + return _Scheduler_CBS_Destroy_server( server_id ); +} + +/** + * @brief qres get server id + * + * Get a thread server id, or QOS_E_NOT_FOUND if it is not + * attached to any server. + * + * @return status code. + */ +RTEMS_INLINE_ROUTINE qos_rv qres_get_sid ( + pid_t pid, + tid_t task_id, + qres_sid_t *server_id +) +{ + return _Scheduler_CBS_Get_server_id( task_id, server_id ); +} + +/** + * @brief qres get params + * + * Retrieve QoS scheduling parameters. + * + * @return status code. + */ +RTEMS_INLINE_ROUTINE qos_rv qres_get_params ( + qres_sid_t server_id, + qres_params_t *params +) +{ + return _Scheduler_CBS_Get_parameters( + server_id, + (Scheduler_CBS_Parameters *) params + ); +} + +/** + * @brief qres set params + * + * Change QoS scheduling parameters. + * + * @return status code. + */ +RTEMS_INLINE_ROUTINE qos_rv qres_set_params ( + qres_sid_t server_id, + qres_params_t *params +) +{ + return _Scheduler_CBS_Set_parameters( + server_id, + (Scheduler_CBS_Parameters *) params + ); +} + +/** + * @brief qres get execution time + * + * Retrieve time info relative to the current server. + * + * @return status code. + */ +RTEMS_INLINE_ROUTINE qos_rv qres_get_exec_time ( + qres_sid_t server_id, + qres_time_t *exec_time, + qres_atime_t *abs_time +) +{ + return _Scheduler_CBS_Get_execution_time( server_id, exec_time, abs_time ); +} + +/** + * @brief qres get current budget + * + * Retrieve remaining budget for the current server instance. + * + * @return status code. + */ +RTEMS_INLINE_ROUTINE qos_rv qres_get_curr_budget ( + qres_sid_t server_id, + qres_time_t *current_budget +) +{ + return _Scheduler_CBS_Get_remaining_budget( server_id, current_budget ); +} + +/** + * @brief qres get approved budget + * + * Retrieve the budget that has been approved for the subsequent + * server instances. + * + * @return status code. + */ +RTEMS_INLINE_ROUTINE qos_rv qres_get_appr_budget ( + qres_sid_t server_id, + qres_time_t *appr_budget +) +{ + return _Scheduler_CBS_Get_approved_budget( server_id, appr_budget ); +} + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/ramdisk.h b/cpukit/include/rtems/ramdisk.h new file mode 100644 index 0000000000..727efddbe8 --- /dev/null +++ b/cpukit/include/rtems/ramdisk.h @@ -0,0 +1,227 @@ +/** + * @file + * + * @brief RAM Disk Block Device API + */ + +/* + * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia + * Author: Victor V. Vengerov + */ + +#ifndef _RTEMS_RAMDISK_H +#define _RTEMS_RAMDISK_H + + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup rtems_ramdisk RAM Disk Device + * + * @ingroup rtems_blkdev + * + */ +/**@{**/ + +/** + * @name Static Configuration + */ +/**@{**/ + +/** + * @brief RAM disk configuration table entry. + */ +typedef struct rtems_ramdisk_config { + /** + * @brief RAM disk block size. + */ + uint32_t block_size; + + /** + * @brief Number of blocks on this RAM disk. + */ + rtems_blkdev_bnum block_num; + + /** + * @brief RAM disk location or @c NULL if RAM disk memory should be allocated + * dynamically. + */ + void *location; +} rtems_ramdisk_config; + +/** + * @brief External reference to the RAM disk configuration table describing + * each RAM disk in the system. + * + * The configuration table is provided by the application. + */ +extern rtems_ramdisk_config rtems_ramdisk_configuration []; + +/** + * @brief External reference the size of the RAM disk configuration table + * @ref rtems_ramdisk_configuration. + * + * The configuration table size is provided by the application. + */ +extern size_t rtems_ramdisk_configuration_size; + +/** + * @brief RAM disk driver initialization entry point. + */ +rtems_device_driver ramdisk_initialize( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg +); + +/** + * RAM disk driver table entry. + */ +#define RAMDISK_DRIVER_TABLE_ENTRY \ + { \ + .initialization_entry = ramdisk_initialize, \ + RTEMS_GENERIC_BLOCK_DEVICE_DRIVER_ENTRIES \ + } + +#define RAMDISK_DEVICE_BASE_NAME "/dev/rd" + +/** @} */ + +/** + * @name Runtime Configuration + */ +/**@{**/ + +/** + * @brief RAM disk descriptor. + */ +typedef struct ramdisk { + /** + * @brief RAM disk block size, the media size. + */ + uint32_t block_size; + + /** + * @brief Number of blocks on this RAM disk. + */ + rtems_blkdev_bnum block_num; + + /** + * @brief RAM disk memory area. + */ + void *area; + + /** + * @brief RAM disk is initialized. + */ + bool initialized; + + /** + * @brief Indicates if memory is allocated by malloc() for this RAM disk. + */ + bool malloced; + + /** + * @brief Trace enable. + */ + bool trace; + + /** + * @brief Free the RAM disk at the block device delete request. + */ + bool free_at_delete_request; +} ramdisk; + +extern const rtems_driver_address_table ramdisk_ops; + +int ramdisk_ioctl(rtems_disk_device *dd, uint32_t req, void *argp); + +/** + * @brief Allocates and initializes a RAM disk descriptor. + * + * The block size will be @a media_block_size. The block count will be + * @a media_block_count. The disk storage area begins at @a area_begin. If + * @a area_begin is @c NULL, the memory will be allocated and zeroed. Sets the + * trace enable to @a trace. + * + * @return Pointer to allocated and initialized ramdisk structure, or @c NULL + * if no memory is available. + * + * @note + * Runtime configuration example: + * @code + * #include + * + * rtems_status_code create_ramdisk( + * const char *device, + * uint32_t media_block_size, + * rtems_blkdev_bnum media_block_count + * ) + * { + * rtems_status_code sc; + * ramdisk *rd; + * + * rd = ramdisk_allocate(NULL, media_block_size, media_block_count, false); + * if (rd != NULL) { + * sc = rtems_blkdev_create( + * device, + * media_block_size, + * media_block_count, + * ramdisk_ioctl, + * rd + * ); + * } else { + * sc = RTEMS_UNSATISFIED; + * } + * + * return sc; + * } + * @endcode + */ +ramdisk *ramdisk_allocate( + void *area_begin, + uint32_t media_block_size, + rtems_blkdev_bnum media_block_count, + bool trace +); + +void ramdisk_free(ramdisk *rd); + +static inline void ramdisk_enable_free_at_delete_request(ramdisk *rd) +{ + rd->free_at_delete_request = true; +} + +/** + * @brief Allocates, initializes and registers a RAM disk. + * + * The block size will be @a media_block_size. The block count will be + * @a media_block_count. The disk storage will be allocated. Sets the trace + * enable to @a trace. Registers a device node with disk name path @a disk. + * The registered device number will be returned in @a dev. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_UNSATISFIED Something is wrong. + */ +rtems_status_code ramdisk_register( + uint32_t media_block_size, + rtems_blkdev_bnum media_block_count, + bool trace, + const char *disk, + dev_t *dev +); + +/** @} */ + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/include/rtems/rbheap.h b/cpukit/include/rtems/rbheap.h new file mode 100644 index 0000000000..735aa6c8fd --- /dev/null +++ b/cpukit/include/rtems/rbheap.h @@ -0,0 +1,268 @@ +/** + * @file + * + * @brief Red-Black Tree Heap API + */ + +/* + * Copyright (c) 2012 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Obere Lagerstr. 30 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RBHEAP_H +#define _RTEMS_RBHEAP_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup RBHeap Red-Black Tree Heap + * + * @ingroup ClassicRTEMS + * + * @brief Red-Black Tree Heap API. + * + * The red-black tree heap provides a memory allocator suitable to implement + * the malloc() and free() interface. It uses a first-fit allocation strategy. + * In the red-black tree heap the administration data structures are not + * contained in the managed memory area. Thus writing beyond the boundaries of + * a chunk does not damage the data to maintain the heap. This can be used for + * example in a task stack allocator which protects the task stacks from access + * by other tasks. The allocated and free memory parts of the managed area are + * called chunks. Each chunk needs a descriptor which is stored outside of the + * managed area. + */ +/**@{*/ + +/** + * @brief Red-black heap chunk descriptor. + */ +typedef struct { + /** + * This chain node can be used in two chains + * - the chain of spare chunk descriptors and + * - the chain of free chunks in the managed memory area. + * + * In case this chain node is not part of a chain, the chunk represents a + * used chunk in the managed memory area. + */ + rtems_chain_node chain_node; + + /** + * Tree node for chunks that represent a part of the managed memory area. + * These chunks are either free or used. + */ + rtems_rbtree_node tree_node; + + /** + * Begin address of the chunk. The address alignment it specified in the + * @ref rtems_rbheap_control. + */ + uintptr_t begin; + + /** + * Size of the chunk in bytes. + */ + uintptr_t size; +} rtems_rbheap_chunk; + +typedef struct rtems_rbheap_control rtems_rbheap_control; + +/** + * @brief Handler to extend the available chunk descriptors. + * + * This handler is called when no more chunk descriptors are available. An + * example implementation is this: + * + * @code + * void extend_descriptors_with_malloc(rtems_rbheap_control *control) + * { + * rtems_rbheap_chunk *chunk = malloc(sizeof(*chunk)); + * + * if (chunk != NULL) { + * rtems_rbheap_add_to_spare_descriptor_chain(control, chunk); + * } + * } + * @endcode + * + * @see rtems_rbheap_extend_descriptors_never() and + * rtems_rbheap_extend_descriptors_with_malloc(). + */ +typedef void (*rtems_rbheap_extend_descriptors)(rtems_rbheap_control *control); + +/** + * @brief Red-black heap control. + */ +struct rtems_rbheap_control { + /** + * Chain of free chunks in the managed memory area. + */ + rtems_chain_control free_chunk_chain; + + /** + * Chain of free chunk descriptors. Descriptors are consumed during + * allocation and may be produced during free if contiguous chunks can be + * coalesced. In case of descriptor starvation the @ref extend_descriptors + * handler will be called. + */ + rtems_chain_control spare_descriptor_chain; + + /** + * Tree of chunks representing the state of the managed memory area. + */ + rtems_rbtree_control chunk_tree; + + /** + * Minimum chunk begin alignment in bytes. + */ + uintptr_t alignment; + + /** + * Handler to extend the available chunk descriptors. + */ + rtems_rbheap_extend_descriptors extend_descriptors; + + /** + * User specified argument handler for private handler data. + */ + void *handler_arg; +}; + +/** + * @brief Initializes the red-black tree heap @a control. + * + * @param[in, out] control The red-black tree heap. + * @param[in] area_begin The managed memory area begin. + * @param[in] area_size The managed memory area size. + * @param[in] alignment The minimum chunk alignment. + * @param[in] extend_descriptors The handler to extend the available chunk + * descriptors. + * @param[in] handler_arg The handler argument. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_ADDRESS The memory area is invalid. + * @retval RTEMS_NO_MEMORY Not enough chunk descriptors. + */ +rtems_status_code rtems_rbheap_initialize( + rtems_rbheap_control *control, + void *area_begin, + uintptr_t area_size, + uintptr_t alignment, + rtems_rbheap_extend_descriptors extend_descriptors, + void *handler_arg +); + +/** + * @brief Allocates a chunk of memory of at least @a size bytes from the + * red-black tree heap @a control. + * + * The chunk begin is aligned by the value specified in + * rtems_rbheap_initialize(). + * + * @param[in, out] control The red-black tree heap. + * @param[in] size The requested chunk size in bytes. + * + * @retval NULL Not enough free space in the heap. + * @retval otherwise Pointer to allocated chunk of memory. + */ +void *rtems_rbheap_allocate(rtems_rbheap_control *control, size_t size); + +/** + * @brief Frees a chunk of memory @a ptr allocated from the red-black tree heap + * @a control. + * + * @param[in, out] control The red-black tree heap. + * @param[in] ptr The pointer to the chunk of memory. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_ID The chunk of memory is not a valid chunk in the + * red-black tree heap. + * @retval RTEMS_INCORRECT_STATE The chunk of memory is not in the right state. + */ +rtems_status_code rtems_rbheap_free(rtems_rbheap_control *control, void *ptr); + +static inline rtems_chain_control *rtems_rbheap_get_spare_descriptor_chain( + rtems_rbheap_control *control +) +{ + return &control->spare_descriptor_chain; +} + +static inline void rtems_rbheap_add_to_spare_descriptor_chain( + rtems_rbheap_control *control, + rtems_rbheap_chunk *chunk +) +{ + rtems_chain_control *chain = + rtems_rbheap_get_spare_descriptor_chain(control); + + rtems_chain_initialize_node(&chunk->chain_node); + rtems_chain_prepend_unprotected(chain, &chunk->chain_node); +} + +static inline void rtems_rbheap_set_extend_descriptors( + rtems_rbheap_control *control, + rtems_rbheap_extend_descriptors extend_descriptors +) +{ + control->extend_descriptors = extend_descriptors; +} + +static inline void *rtems_rbheap_get_handler_arg( + const rtems_rbheap_control *control +) +{ + return control->handler_arg; +} + +static inline void rtems_rbheap_set_handler_arg( + rtems_rbheap_control *control, + void *handler_arg +) +{ + control->handler_arg = handler_arg; +} + +/** + * @brief Chunk descriptor extend handler that does nothing. + */ +void rtems_rbheap_extend_descriptors_never(rtems_rbheap_control *control); + +/** + * @brief Chunk descriptor extend handler that uses malloc(). + */ +void rtems_rbheap_extend_descriptors_with_malloc( + rtems_rbheap_control *control +); + +/** @} */ + +/* Private API */ + +#define rtems_rbheap_chunk_of_node(node) \ + RTEMS_CONTAINER_OF(node, rtems_rbheap_chunk, tree_node) + +static inline bool rtems_rbheap_is_chunk_free(const rtems_rbheap_chunk *chunk) +{ + return !rtems_chain_is_node_off_chain(&chunk->chain_node); +} + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_RBHEAP_H */ diff --git a/cpukit/include/rtems/rbtree.h b/cpukit/include/rtems/rbtree.h new file mode 100644 index 0000000000..57821cf31d --- /dev/null +++ b/cpukit/include/rtems/rbtree.h @@ -0,0 +1,456 @@ +/** + * @file + * + * @brief Constants and Structures Associated with the RBTree API in RTEMS + * + * This include file contains all the constants and structures associated + * with the RBTree API in RTEMS. The rbtree is a Red Black Tree that + * is part of the Super Core. This is the published interface to that + * code. + */ + +/* + * Copyright (c) 2010 Gedare Bloom. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RBTREE_H +#define _RTEMS_RBTREE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicRBTrees Red-Black Trees + * + * @ingroup ClassicRTEMS + * + * @brief A Red-Black Tree container. + * + * The red-black tree container offers no internal protection against + * concurrent access. The user must ensure that at most one thread at once can + * access a red-black tree instance. + * + * @{ + */ + +/** + * @typedef rtems_rbtree_node + * + * A node that can be manipulated in the rbtree. + */ +typedef RBTree_Node rtems_rbtree_node; + +/** + * @typedef rtems_rbtree_control + * + * The rbtree's control anchors the rbtree. + */ +typedef RBTree_Control rtems_rbtree_control; + +/** + * @brief Integer type for compare results. + * + * The type is large enough to represent pointers and 32-bit signed integers. + * + * @see rtems_rbtree_compare. + */ +typedef long rtems_rbtree_compare_result; + +/** + * @brief Compares two red-black tree nodes. + * + * @param[in] first The first node. + * @param[in] second The second node. + * + * @retval positive The key value of the first node is greater than the one of + * the second node. + * @retval 0 The key value of the first node is equal to the one of the second + * node. + * @retval negative The key value of the first node is less than the one of the + * second node. + */ +typedef rtems_rbtree_compare_result ( *rtems_rbtree_compare )( + const RBTree_Node *first, + const RBTree_Node *second +); + +/** + * @brief RBTree initializer for an empty rbtree with designator @a name. + */ +#define RTEMS_RBTREE_INITIALIZER_EMPTY(name) \ + RBTREE_INITIALIZER_EMPTY(name) + +/** + * @brief RBTree definition for an empty rbtree with designator @a name. + */ +#define RTEMS_RBTREE_DEFINE_EMPTY(name) \ + RBTREE_DEFINE_EMPTY(name) + +/** + * @brief Initialize a RBTree header. + * + * This routine initializes @a the_rbtree structure to manage the + * contiguous array of @a number_nodes nodes which starts at + * @a starting_address. Each node is of @a node_size bytes. + * + * @param[in] the_rbtree is the pointer to rbtree header + * @param[in] compare The node compare function. + * @param[in] starting_address is the starting address of first node + * @param[in] number_nodes is the number of nodes in rbtree + * @param[in] node_size is the size of node in bytes + * @param[in] is_unique If true, then reject nodes with a duplicate key, else + * otherwise. + */ +void rtems_rbtree_initialize( + rtems_rbtree_control *the_rbtree, + rtems_rbtree_compare compare, + void *starting_address, + size_t number_nodes, + size_t node_size, + bool is_unique +); + +/** + * @brief Initialize this RBTree as Empty + * + * This routine initializes @a the_rbtree to contain zero nodes. + */ +RTEMS_INLINE_ROUTINE void rtems_rbtree_initialize_empty( + rtems_rbtree_control *the_rbtree +) +{ + _RBTree_Initialize_empty( the_rbtree ); +} + +/** + * @brief Set off RBtree. + * + * This function sets the next and previous fields of the @a node to NULL + * indicating the @a node is not part of any rbtree. + */ +RTEMS_INLINE_ROUTINE void rtems_rbtree_set_off_tree( + rtems_rbtree_node *node +) +{ + _RBTree_Set_off_tree( node ); +} + +/** + * @brief Is the Node off RBTree. + * + * This function returns true if the @a node is not on a rbtree. A @a node is + * off rbtree if the next and previous fields are set to NULL. + */ +RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_node_off_tree( + const rtems_rbtree_node *node +) +{ + return _RBTree_Is_node_off_tree( node ); +} + +/** + * @brief Return pointer to RBTree root. + * + * This function returns a pointer to the root node of @a the_rbtree. + */ +RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_root( + const rtems_rbtree_control *the_rbtree +) +{ + return _RBTree_Root( the_rbtree ); +} + +/** + * @copydoc _RBTree_Minimum() + */ +RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_min( + const rtems_rbtree_control *the_rbtree +) +{ + return _RBTree_Minimum( the_rbtree ); +} + +/** + * @copydoc _RBTree_Maximum() + */ +RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_max( + const rtems_rbtree_control *the_rbtree +) +{ + return _RBTree_Maximum( the_rbtree ); +} + +/** + * @brief Return pointer to the left child node from this node. + * + * This function returns a pointer to the left child node of @a the_node. + */ +RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_left( + const rtems_rbtree_node *the_node +) +{ + return _RBTree_Left( the_node ); +} + +/** + * @brief Return pointer to the right child node from this node. + * + * This function returns a pointer to the right child node of @a the_node. + */ +RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_right( + const rtems_rbtree_node *the_node +) +{ + return _RBTree_Right( the_node ); +} + +/** + * @copydoc _RBTree_Parent() + */ +RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_parent( + const rtems_rbtree_node *the_node +) +{ + return _RBTree_Parent( the_node ); +} + +/** + * @brief Is the RBTree empty. + * + * This function returns true if there a no nodes on @a the_rbtree and + * false otherwise. + */ +RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_empty( + const rtems_rbtree_control *the_rbtree +) +{ + return _RBTree_Is_empty( the_rbtree ); +} + +/** + * @brief Is this the minimum node on the RBTree. + * + * This function returns true if @a the_node is the min node on @a the_rbtree + * and false otherwise. + */ +RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_min( + const rtems_rbtree_control *the_rbtree, + const rtems_rbtree_node *the_node +) +{ + return rtems_rbtree_min( the_rbtree ) == the_node; +} + +/** + * @brief Is this the maximum node on the RBTree. + * + * This function returns true if @a the_node is the max node on @a the_rbtree + * and false otherwise. + */ +RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_max( + const rtems_rbtree_control *the_rbtree, + const rtems_rbtree_node *the_node +) +{ + return rtems_rbtree_max( the_rbtree ) == the_node; +} + +/** + * @copydoc _RBTree_Is_root() + */ +RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_root( + const rtems_rbtree_node *the_node +) +{ + return _RBTree_Is_root( the_node ); +} + +RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_equal( + rtems_rbtree_compare_result compare_result +) +{ + return compare_result == 0; +} + +RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_greater( + rtems_rbtree_compare_result compare_result +) +{ + return compare_result > 0; +} + +RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_lesser( + rtems_rbtree_compare_result compare_result +) +{ + return compare_result < 0; +} + +/** + * @brief Tries to find a node for the specified key in the tree. + * + * @param[in] the_rbtree The red-black tree control. + * @param[in] the_node A node specifying the key. + * @param[in] compare The node compare function. + * @param[in] is_unique If true, then return the first node with a key equal to + * the one of the node specified if it exits, else return the last node if it + * exists. + * + * @retval node A node corresponding to the key. If the tree is not unique + * and contains duplicate keys, the set of duplicate keys acts as FIFO. + * @retval NULL No node exists in the tree for the key. + */ +rtems_rbtree_node* rtems_rbtree_find( + const rtems_rbtree_control *the_rbtree, + const rtems_rbtree_node *the_node, + rtems_rbtree_compare compare, + bool is_unique +); + +/** + * @copydoc _RBTree_Predecessor() + */ +RTEMS_INLINE_ROUTINE rtems_rbtree_node* rtems_rbtree_predecessor( + const rtems_rbtree_node *node +) +{ + return _RBTree_Predecessor( node ); +} + +/** + * @copydoc _RBTree_Successor() + */ +RTEMS_INLINE_ROUTINE rtems_rbtree_node* rtems_rbtree_successor( + const rtems_rbtree_node *node +) +{ + return _RBTree_Successor( node ); +} + +/** + * @copydoc _RBTree_Extract() + */ +RTEMS_INLINE_ROUTINE void rtems_rbtree_extract( + rtems_rbtree_control *the_rbtree, + rtems_rbtree_node *the_node +) +{ + _RBTree_Extract( the_rbtree, the_node ); +} + +/** + * @brief Gets a node with the minimum key value from the red-black tree. + * + * This function extracts a node with the minimum key value from + * tree and returns a pointer to that node if it exists. In case multiple + * nodes with a minimum key value exist, then they are extracted in FIFO order. + * + * @param[in] the_rbtree The red-black tree control. + * + * @retval NULL The tree is empty. + * @retval node A node with the minimal key value on the tree. + */ +RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_get_min( + rtems_rbtree_control *the_rbtree +) +{ + rtems_rbtree_node *the_node = rtems_rbtree_min( the_rbtree ); + + if ( the_node != NULL ) { + rtems_rbtree_extract( the_rbtree, the_node ); + } + + return the_node; +} + +/** + * @brief Gets a node with the maximal key value from the red-black tree. + * + * This function extracts a node with the maximum key value from tree and + * returns a pointer to that node if it exists. In case multiple nodes with a + * maximum key value exist, then they are extracted in LIFO order. + * + * @param[in] the_rbtree The red-black tree control. + * + * @retval NULL The tree is empty. + * @retval node A node with the maximal key value on the tree. + */ +RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_get_max( + rtems_rbtree_control *the_rbtree +) +{ + rtems_rbtree_node *the_node = rtems_rbtree_max( the_rbtree ); + + if ( the_node != NULL ) { + rtems_rbtree_extract( the_rbtree, the_node ); + } + + return the_node; +} + +/** + * @brief Peek at the min node on a rbtree. + * + * This function returns a pointer to the min node from @a the_rbtree + * without changing the tree. If @a the_rbtree is empty, + * then NULL is returned. + */ +RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_peek_min( + const rtems_rbtree_control *the_rbtree +) +{ + return rtems_rbtree_min( the_rbtree ); +} + +/** + * @brief Peek at the max node on a rbtree. + * + * This function returns a pointer to the max node from @a the_rbtree + * without changing the tree. If @a the_rbtree is empty, + * then NULL is returned. + */ +RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_peek_max( + const rtems_rbtree_control *the_rbtree +) +{ + return rtems_rbtree_max( the_rbtree ); +} + +/** + * @brief Inserts the node into the red-black tree. + * + * In case the node is already a node of a tree, then this function yields + * unpredictable results. + * + * @param[in] the_rbtree The red-black tree control. + * @param[in] the_node The node to insert. + * @param[in] compare The node compare function. + * @param[in] is_unique If true, then reject nodes with a duplicate key, else + * insert nodes in FIFO order in case the key value is equal to existing nodes. + * + * @retval NULL Successfully inserted. + * @retval existing_node This is a unique insert and there exists a node with + * an equal key in the tree already. + */ +rtems_rbtree_node *rtems_rbtree_insert( + RBTree_Control *the_rbtree, + RBTree_Node *the_node, + rtems_rbtree_compare compare, + bool is_unique +); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rfs/rtems-rfs-bitmaps.h b/cpukit/include/rtems/rfs/rtems-rfs-bitmaps.h new file mode 100644 index 0000000000..5574339421 --- /dev/null +++ b/cpukit/include/rtems/rfs/rtems-rfs-bitmaps.h @@ -0,0 +1,326 @@ +/** + * @file + * + * @brief RTEMS File Systems Bitmap Routines + * + * @ingroup rtems_rfs + * + * RTEMS File Systems Bitmap Routines. + * + * These functions manage bit maps. A bit map consists of the map of bit + * allocated in a block and a search map where a bit represents 32 actual + * bits. The search map allows for a faster search for an available bit as 32 + * search bits can checked in a test. + */ + +/* + * COPYRIGHT (c) 2010 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + + +#if !defined (_RTEMS_RFS_BITMAPS_H_) +#define _RTEMS_RFS_BITMAPS_H_ + +#include +#include +#include + +/** + * Define the way the bits are configured. We can have them configured as clear + * being 0 or clear being 1. This does not effect how masks are defined. A mask + * always has a 1 for set and 0 for clear. + */ +#define RTEMS_RFS_BITMAP_CLEAR_ZERO 0 + +#if RTEMS_RFS_BITMAP_CLEAR_ZERO +/* + * Bit set is a 1 and clear is 0. + */ +#define RTEMS_RFS_BITMAP_BIT_CLEAR 0 +#define RTEMS_RFS_BITMAP_BIT_SET 1 +#define RTEMS_RFS_BITMAP_ELEMENT_SET (RTEMS_RFS_BITMAP_ELEMENT_FULL_MASK) +#define RTEMS_RFS_BITMAP_ELEMENT_CLEAR (0) +#define RTEMS_RFS_BITMAP_SET_BITS(_t, _b) ((_t) | (_b)) +#define RTEMS_RFS_BITMAP_CLEAR_BITS(_t, _b) ((_t) & ~(_b)) +#define RTEMS_RFS_BITMAP_TEST_BIT(_t, _b) (((_t) & (1 << (_b))) != 0 ? true : false) +#else +/* + * Bit set is a 0 and clear is 1. + */ +#define RTEMS_RFS_BITMAP_BIT_CLEAR 1 +#define RTEMS_RFS_BITMAP_BIT_SET 0 +#define RTEMS_RFS_BITMAP_ELEMENT_SET (0) +#define RTEMS_RFS_BITMAP_ELEMENT_CLEAR (RTEMS_RFS_BITMAP_ELEMENT_FULL_MASK) +#define RTEMS_RFS_BITMAP_SET_BITS(_t, _b) ((_t) & ~(_b)) +#define RTEMS_RFS_BITMAP_CLEAR_BITS(_t, _b) ((_t) | (_b)) +#define RTEMS_RFS_BITMAP_TEST_BIT(_t, _b) (((_t) & (1 << (_b))) == 0 ? true : false) +#endif + +/** + * Invert a mask. Masks are always 1 for set and 0 for clear. + */ +#define RTEMS_RFS_BITMAP_INVERT_MASK(_mask) (~(_mask)) + +/** + * This is the full mask of the length of the element. A mask is always a 1 for + * set and 0 for clear. It is not effected by the state of + * RTEMS_RFS_BITMAP_CLEAR_ZERO. + */ +#define RTEMS_RFS_BITMAP_ELEMENT_FULL_MASK (0xffffffffUL) + +/** + * The bitmap search window. Searches occur around a seed in either direction + * for half the window. + */ +#define RTEMS_RFS_BITMAP_SEARCH_WINDOW (rtems_rfs_bitmap_element_bits () * 64) + +/** + * A bit in a map. + */ +typedef int32_t rtems_rfs_bitmap_bit; + +/** + * The basic element of a bitmap. A bitmap is manipulated by elements. + */ +typedef uint32_t rtems_rfs_bitmap_element; + +/** + * The power of 2 number of bits in the element. + */ +#define RTEMS_RFS_ELEMENT_BITS_POWER_2 (5) + +/** + * A bitmap or map is an array of bitmap elements. + */ +typedef rtems_rfs_bitmap_element* rtems_rfs_bitmap_map; + +/** + * The bitmap control is a simple way to manage the various parts of a bitmap. + */ +typedef struct rtems_rfs_bitmap_control_s +{ + rtems_rfs_buffer_handle* buffer; //< Handle the to buffer with the bit + //map. + rtems_rfs_file_system* fs; //< The map's file system. + rtems_rfs_buffer_block block; //< The map's block number on disk. + size_t size; //< Number of bits in the map. Passed + //to create. + size_t free; //< Number of bits in the map that are + //free (clear). + rtems_rfs_bitmap_map search_bits; //< The search bit map memory. +} rtems_rfs_bitmap_control; + +/** + * Return the number of bits for the number of bytes provided. + */ +#define rtems_rfs_bitmap_numof_bits(_bytes) (8 * (_bytes)) + +/** + * Return the number of bits for the number of bytes provided. The search + * element and the element must have the same number of bits. + */ +#define rtems_rfs_bitmap_element_bits() \ + rtems_rfs_bitmap_numof_bits (sizeof (rtems_rfs_bitmap_element)) + +/** + * Return the number of bits a search element covers. + */ +#define rtems_rfs_bitmap_search_element_bits() \ + (rtems_rfs_bitmap_element_bits() * rtems_rfs_bitmap_element_bits()) + +/** + * Return the number of elements for a given number of bits. + */ +#define rtems_rfs_bitmap_elements(_bits) \ + ((((_bits) - 1) / rtems_rfs_bitmap_element_bits()) + 1) + +/** + * Release the bitmap buffer back to the buffer pool or cache. + */ +#define rtems_rfs_bitmap_release_buffer(_fs, _bm) \ + rtems_rfs_buffer_handle_release (_fs, (_bm)->buffer) + +/** + * Return the element index for a given bit. We use a macro to hide any + * implementation assuptions. Typically this would be calculated by dividing + * the bit index by the number of bits in an element. Given we have a power of + * 2 as the number of bits we can avoid the division by using a shift. A good + * compiler should figure this out but I would rather enforce this than rely on + * the specific backend of a compiler to do the right thing. + */ +#define rtems_rfs_bitmap_map_index(_b) \ + ((_b) >> RTEMS_RFS_ELEMENT_BITS_POWER_2) + +/** + * Return the bit offset for a given bit in an element in a map. See @ref + * rtems_rfs_bitmap_map_index for a detailed reason why. + */ +#define rtems_rfs_bitmap_map_offset(_b) \ + ((_b) & ((1 << RTEMS_RFS_ELEMENT_BITS_POWER_2) - 1)) + +/** + * Return the size of the bitmap. + */ +#define rtems_rfs_bitmap_map_size(_c) ((_c)->size) + +/** + * Return the number of free bits in the bitmap. + */ +#define rtems_rfs_bitmap_map_free(_c) ((_c)->free) + +/** + * Return the buffer handle. + */ +#define rtems_rfs_bitmap_map_handle(_c) ((_c)->buffer) + +/** + * Return the bitmap map block. + */ +#define rtems_rfs_bitmap_map_block(_c) ((_c)->block) + +/** + * Create a bit mask with the specified number of bits up to an element's + * size. The mask is aligned to bit 0 of the element. + * + * @param[in] size is the number of bits in the mask. + * + * @return The mask of the argument size number of bits. + */ +rtems_rfs_bitmap_element rtems_rfs_bitmap_mask (unsigned int size); + +/** + * Create a bit mask section. A mask section is a mask that is not aligned to + * an end of the element. + * + * @param[in] start is the first bit of the mask numbered from 0. + * @param[in] end is the end bit of the mask numbered from 0. + * + * @return Mask section as defined by the start and end arguments. + */ +rtems_rfs_bitmap_element rtems_rfs_bitmap_mask_section (unsigned int start, + unsigned int end); + +/** + * Set a bit in a map and if all the bits are set, set the search map bit as + * well. + * + * @param[in] control is the control for the map. + * @param[in] bit is the bit in the map to set. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_bitmap_map_set (rtems_rfs_bitmap_control* control, + rtems_rfs_bitmap_bit bit); + +/** + * Clear a bit in a map and make sure the search map bit is clear so a search + * will find this bit available. + * + * @param[in] control is the control for the map. + * @param[in] bit is the bit in the map to clear. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_bitmap_map_clear (rtems_rfs_bitmap_control* control, + rtems_rfs_bitmap_bit bit); + +/** + * Test a bit in the map. + * + * @param[in] control is the bitmap control. + * @param[in] bit is the bit to test. + * @param[in] state is the state of the bit if no error is returned. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int +rtems_rfs_bitmap_map_test (rtems_rfs_bitmap_control* control, + rtems_rfs_bitmap_bit bit, + bool* state); + +/** + * Set all bits in the bitmap and set the dirty bit. + * + * @param[in] control is the bitmap control. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_bitmap_map_set_all (rtems_rfs_bitmap_control* control); + +/** + * Clear all bits in the bitmap and set the dirty bit. + * + * @param[in] control is the bitmap control. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_bitmap_map_clear_all (rtems_rfs_bitmap_control* control); + +/** + * Find a free bit searching from the seed up and down until found. The search + * is performing by moving up from the seed for the window distance then to + * search down from the seed for the window distance. This is repeated out + * from the seed for each window until a free bit is found. The search is + * performed by checking the search map to see if the map has a free bit. + * + * @param[in] control is the map control. + * @param[in] seed is the bit to search out from. + * @param[out] allocate A bit was allocated. + * @param[out] bit will contain the bit found free if true is returned. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_bitmap_map_alloc (rtems_rfs_bitmap_control* control, + rtems_rfs_bitmap_bit seed, + bool* allocate, + rtems_rfs_bitmap_bit* bit); + +/** + * Create a search bit map from the actual bit map. + * + * @param[in] control is the map control. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_bitmap_create_search (rtems_rfs_bitmap_control* control); + +/** + * Open a bitmap control with a map and search map. + * + * @param[in] control is the map control. + * @param[in] fs is the file system data. + * @param[in] buffer is a pointer to the buffer handle the map is + * stored in. + * @param[in] size is the number of bits in the map. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_bitmap_open (rtems_rfs_bitmap_control* control, + rtems_rfs_file_system* fs, + rtems_rfs_buffer_handle* buffer, + size_t size, + rtems_rfs_buffer_block block); + +/** + * Close a bitmap. + * + * @param[in] control is the bit map control. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_bitmap_close (rtems_rfs_bitmap_control* control); + +#endif diff --git a/cpukit/include/rtems/rfs/rtems-rfs-block-pos.h b/cpukit/include/rtems/rfs/rtems-rfs-block-pos.h new file mode 100644 index 0000000000..7d0f0693be --- /dev/null +++ b/cpukit/include/rtems/rfs/rtems-rfs-block-pos.h @@ -0,0 +1,242 @@ +/** + * @file + * + * @brief RTEMS File Systems Block Position and Size Management + * + * @ingroup rtems_rfs + * + * RTEMS File Systems Block Position and Size Management. + * + * These functions manage the position in a block map as well as a size of data + * held in a block map. The position is the block count plus the offset into + * the last block where a block position of 0 and an offset of 0 is the start + * of a map. The size has a block count plus an offset, but the offset into the + * last block gives the actual size of the data in the map. This means a size + * will always have a block count greater than 0 when the file is not empty. A + * size offset of 0 and a non-zero block count means the length if aligned to + * the end of the block. For this reason there are 2 similar types so we know + * which set of rules are in use and the reason for this file. + */ + +/* + * COPYRIGHT (c) 2010 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#if !defined (_RTEMS_RFS_BLOCK_POS_H_) +#define _RTEMS_RFS_BLOCK_POS_H_ + +#include +#include + +/** + * The block number is the same type as the inode block number. This makes sure + * the sizes of the types match. + */ +typedef rtems_rfs_inode_block rtems_rfs_block_no; + +/** + * The offset into a block. + */ +typedef uint32_t rtems_rfs_block_off; + +/** + * A block position is a block number times the block size plus the offset. The + * block field can be used hold a block number for the position as a look up + * cache. + */ +typedef struct rtems_rfs_block_pos_s +{ + /** + * The block index in the map. Range is from 0 to the maps block count minus + * 1. + */ + rtems_rfs_block_no bno; + + /** + * The offset into the block. Must be less than the block size. + */ + rtems_rfs_block_off boff; + + /** + * The block number that the bpos + boff map to. The 0 value is invalid and + * means no block number has been set. + */ + rtems_rfs_block_no block; + +} rtems_rfs_block_pos; + +/** + * Copy a block position. + * + * @param[in] _lhs is the left hand side. + * @param[in] _rhs is the right hand side. + */ +#define rtems_rfs_block_copy_bpos(_lhs, _rhs) \ + do { (_lhs)->bno = (_rhs)->bno; \ + (_lhs)->boff = (_rhs)->boff; \ + (_lhs)->block = (_rhs)->block; } while (0) + +/** + * Zero a block position. + * + * @param[in] bpos is a pointer to the block position. + */ +static inline void +rtems_rfs_block_set_bpos_zero (rtems_rfs_block_pos* bpos) +{ + bpos->bno = 0; + bpos->boff = 0; + bpos->block = 0; +} + +/** + * Given a position compute the block number and block offset. + * + * @param[in] fs is the file system data. + * @param[in] pos is the position as an absolute offset from the start. + * @param[out] bpos is a pointer to the block position to fill in. + */ +void rtems_rfs_block_get_bpos (rtems_rfs_file_system* fs, + rtems_rfs_pos pos, + rtems_rfs_block_pos* bpos); + +/** + * Given a block position compute the absolute offset. + * + * @param[in] fs is the file system data. + * @param[out] bpos is a pointer to the block position to fill in. + * + * @retval offset The absolute offset. + */ +rtems_rfs_pos rtems_rfs_block_get_pos (rtems_rfs_file_system* fs, + rtems_rfs_block_pos* bpos); + +/** + * Add the relative position to the block position. The relative position is + * signed. + * + * @param[in] fs is the file system data. + * @param[in] offset is the relative offset add to the block position. + * @param[out] bpos is a pointer to the block position to fill in. + */ +static inline void +rtems_rfs_block_add_pos (rtems_rfs_file_system* fs, + rtems_rfs_pos_rel offset, + rtems_rfs_block_pos* bpos) +{ + rtems_rfs_block_get_bpos (fs, + rtems_rfs_block_get_pos (fs, bpos) + offset, + bpos); + bpos->block = 0; +} + +/** + * A block size is the number of blocks less one plus the offset where the + * offset must be less than the block size. + */ +typedef struct rtems_rfs_block_size_s +{ + /** + * The count of blocks in a map. A 0 means no blocks and a zero length and + * the offset should also be 0. + */ + rtems_rfs_block_no count; + + /** + * The offset into the block. An offset of 0 means block size, ie the first + * byte of the next block which is not allocated. + */ + rtems_rfs_block_off offset; + +} rtems_rfs_block_size; + +/** + * Copy a block size. + * + * @param[in] _lhs is the left hand side. + * @param[in] _rhs is the right hand side. + */ +#define rtems_rfs_block_copy_size(_lhs, _rhs) \ + do { (_lhs)->count = (_rhs)->count; \ + (_lhs)->offset = (_rhs)->offset; } while (0) + +/** + * Last block ? + */ +#define rtems_rfs_block_pos_last_block(_p, _s) \ + ((((_p)->bno == 0) && ((_s)->count == 0)) || ((_p)->bno == ((_s)->count - 1))) + +/** + * Last block ? + */ +#define rtems_rfs_block_pos_past_end(_p, _s) \ + (((_p)->bno && ((_s)->count == 0)) || \ + ((_p)->bno >= (_s)->count) || \ + (((_p)->bno == ((_s)->count - 1)) && ((_p)->boff > (_s)->offset))) + +/** + * Is the block position past the end. + */ +#define rtems_rfs_block_pos_block_past_end(_p, _s) \ + (((_p)->bno && ((_s)->count == 0)) || ((_p)->bno >= (_s)->count)) + +/** + * Copy the size to the block position. Note the block position and the size + * have different block counts. + */ +#define rtems_rfs_block_size_get_bpos(_s, _b) \ + do { (_b)->bno = (_s)->count; \ + (_b)->boff = (_s)->offset; \ + (_b)->block = 0; \ + if ((_b)->boff) --(_b)->bno; } while (0) + +/** + * Do the sizes match ? + */ +#define rtems_rfs_block_size_equal(_lhs, _rhs) \ + (((_lhs)->count == (_rhs)->count) && ((_lhs)->offset == (_rhs)->offset)) + +/** + * Zero a block size. + * + * @param[in] size is a pointer to the block size. + */ +static inline void +rtems_rfs_block_set_size_zero (rtems_rfs_block_size* size) +{ + size->count = 0; + size->offset = 0; +} + +/** + * Set the size given a position. + * + * @param[in] fs is the file system data. + * @param[in] pos is the position as an absolute offset from the start. + * @param[out] size is a pointer to the block size to fill in. + */ +void rtems_rfs_block_get_block_size (rtems_rfs_file_system* fs, + rtems_rfs_pos pos, + rtems_rfs_block_size* size); + +/** + * Calculate the position given the number of blocks and the offset. If the + * block count is 0 the size is 0. If the block is greater than 0 and the + * offset is 0 the size is number of blocks multipled by the block size and if + * the offset is not 0 it is the offset into the last block. For example if + * blocks is 1 and offset is 0 the size is the block size. If the block count + * is 1 and size is 100 the size is 100. + * + * @param[in] fs is the file system data. + * @param[in] size The size in blocks and offset. + * + * @retval size The size in bytes. + */ +rtems_rfs_pos rtems_rfs_block_get_size (rtems_rfs_file_system* fs, + rtems_rfs_block_size* size); + +#endif diff --git a/cpukit/include/rtems/rfs/rtems-rfs-block.h b/cpukit/include/rtems/rfs/rtems-rfs-block.h new file mode 100644 index 0000000000..394853b7ad --- /dev/null +++ b/cpukit/include/rtems/rfs/rtems-rfs-block.h @@ -0,0 +1,344 @@ +/** + * @file + * + * @brief RTEMS File Systems Block Management + * + * @ingroup rtems_rfs + * + * RTEMS File Systems Block Management. + * + * These functions manage the blocks used in the file system. + */ + +/* + * COPYRIGHT (c) 2010 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + + +#if !defined (_RTEMS_RFS_BLOCK_H_) +#define _RTEMS_RFS_BLOCK_H_ + +#include +#include +#include +#include + +/** + * Get a block number in the media format and return it in the host format. + * + * @param[in] _h is the buffer handle of the block. + * @param[in] _b is the block number index. + * + * @retval block The block number. + */ +#define rtems_rfs_block_get_number(_h, _b) \ + ((rtems_rfs_block_no) \ + (rtems_rfs_read_u32 (rtems_rfs_buffer_data (_h) + \ + ((_b) * sizeof (rtems_rfs_block_no))))) + +/** + * Set a block number in the media format given a number in the host format. + * + * @param[in] _h is the buffer handle of the block. + * @param[in] _b is the block number index, ie the number of block number not the + * buffer offset. + * @param[in] _n is the block number. + */ +#define rtems_rfs_block_set_number(_h, _b, _n) \ + do { \ + rtems_rfs_write_u32 (rtems_rfs_buffer_data (_h) + \ + ((_b) * sizeof (rtems_rfs_block_no)), (_n)); \ + rtems_rfs_buffer_mark_dirty (_h); \ + } while (0) + +/** + * A block map manges the block lists that originate from an inode. The inode + * contains a number of block numbers. A block map takes those block numbers + * and manages them. + * + * The blocks cannot have all ones as a block number nor block 0. The block map + * is series of block numbers in a blocks. The size of the map determines the + * way the block numbers are stored. The map uses the following: + * + * @li @e Direct Access, + * @li @e Single Indirect Access, and + * @li @e Double Indirect Access. + * + * Direct access has the blocks numbers in the inode slots. The Single Indirect + * Access has block numbers in the inode slots that pointer to a table of block + * numbers that point to data blocks. The Double Indirect Access has block + * numbers in the inode that point to Single Indirect block tables. + * + * The inode can hold a number of Direct, Single Indirect, and Double Indirect + * block tables. The move from Direct to Single occurs then the block count in + * the map is above the number of slots in the inode. The move from Single to + * Double occurs when the map block count is greated than the block numbers per + * block multipled by the slots in the inode. The move from Single to Double + * occurs when the map block count is over the block numbers per block squared + * multipled by the number of slots in the inode. + * + * The block map can managed files of the follow size verses block size with 5 + * inode slots: + * + * @li 41,943,040 bytes for a 512 byte block size, + * @li 335,544,320 bytes for a 1024 byte block size, + * @li 2,684,354,560 bytes for a 2048 byte block size, and + * @li 21,474,836,480 bytes for a 4096 byte block size. + */ +typedef struct rtems_rfs_block_map_s +{ + /** + * Is the map dirty ? + */ + bool dirty; + + /** + * The inode this map is attached to. + */ + rtems_rfs_inode_handle* inode; + + /** + * The size of the map. + */ + rtems_rfs_block_size size; + + /** + * The block map position. Used to navigate the map when seeking. The find + * call is to a position in the file/directory and is a block number plus + * offset. The block find only needs to locate a block and not worry about + * the offset while a seek can be less than a block size yet move across a + * block boundary. Therefore the position a block map has to maintain must + * include the offset so seeks work. + */ + rtems_rfs_block_pos bpos; + + /** + * The last map block allocated. This is used as the goal when allocating a + * new map block. + */ + rtems_rfs_block_no last_map_block; + + /** + * The last data block allocated. This is used as the goal when allocating a + * new data block. + */ + rtems_rfs_block_no last_data_block; + + /** + * The block map. + */ + uint32_t blocks[RTEMS_RFS_INODE_BLOCKS]; + + /** + * Singly Buffer handle. + */ + rtems_rfs_buffer_handle singly_buffer; + + /** + * Doubly Buffer handle. + */ + rtems_rfs_buffer_handle doubly_buffer; + +} rtems_rfs_block_map; + +/** + * Is the map dirty ? + */ +#define rtems_rfs_block_map_is_dirty(_m) ((_m)->dirty) + +/** + * Return the block count in the map. + */ +#define rtems_rfs_block_map_count(_m) ((_m)->size.count) + +/** + * Return the map's size element. + */ +#define rtems_rfs_block_map_size(_m) (&((_m)->size)) + +/** + * Return the size offset for the map. + */ +#define rtems_rfs_block_map_size_offset(_m) ((_m)->size.offset) + +/** + * Are we at the last block in the map ? + */ +#define rtems_rfs_block_map_last(_m) \ + rtems_rfs_block_pos_last_block (&(_m)->bpos, &(_m)->size) + +/** + * Is the position past the end of the block ? + */ +#define rtems_rfs_block_map_past_end(_m, _p) \ + rtems_rfs_block_pos_past_end (_p, &(_m)->size) + +/** + * Return the current position in the map. + */ +#define rtems_rfs_block_map_pos(_f, _m) \ + rtems_rfs_block_get_pos (_f, &(_m)->bpos) + +/** + * Return the map's current block number. + */ +#define rtems_rfs_block_map_block(_m) ((_m)->bpos.bno) + +/** + * Return the map's current block offset. + */ +#define rtems_rfs_block_map_block_offset(_m) ((_m)->bpos.boff) + +/** + * Set the size offset for the map. The map is tagged as dirty. + * + * @param[in] map is a pointer to the open map to set the offset in. + * @param[in] offset is the offset to set in the map's size. + */ +static inline void +rtems_rfs_block_map_set_size_offset (rtems_rfs_block_map* map, + rtems_rfs_block_off offset) +{ + map->size.offset = offset; + map->dirty = true; +} + +/** + * Set the map's size. The map is tagged as dirty. + * + * @param[in] map is a pointer to the open map to set the offset in. + * @param[in] size is the size to set in the map's size. + */ +static inline void +rtems_rfs_block_map_set_size (rtems_rfs_block_map* map, + rtems_rfs_block_size* size) +{ + rtems_rfs_block_copy_size (&map->size, size); + map->dirty = true; +} +/** + * Open a block map. The block map data in the inode is copied into the + * map. The buffer handles are opened. The block position is set to the start + * so a seek of offset 0 will return the first block. + * + * @param[in] fs is the file system data. + * @param[in] inode is a pointer to the inode the map belongs to. + * @param[in] map is a pointer to the map that is opened. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_block_map_open (rtems_rfs_file_system* fs, + rtems_rfs_inode_handle* inode, + rtems_rfs_block_map* map); + +/** + * Close the map. The buffer handles are closed and any help buffers are + * released. + * + * @param[in] fs is the file system data. + * @param[in] map is a pointer to the map that is opened. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_block_map_close (rtems_rfs_file_system* fs, + rtems_rfs_block_map* map); + +/** + * Find a block number in the map from the position provided. + * + * @param[in] fs is the file system data. + * @param[in] map is a pointer to the map to search. + * @param[in] bpos is a pointer to the block position to find. + * @param[out] block will contain the block in when found. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_block_map_find (rtems_rfs_file_system* fs, + rtems_rfs_block_map* map, + rtems_rfs_block_pos* bpos, + rtems_rfs_buffer_block* block); + +/** + * Seek around the map. + * + * @param[in] fs is the file system data. + * @param[in] map is a pointer to the map to search. + * @param[in] offset is the distance to seek. It is signed. + * @param[out] block will contain the block in when found. + * + * @retval 0 Successful operation. + * @retval ENXIO Failed to seek because it is outside the block map. + * @retval error_code An error occurred. + */ +int rtems_rfs_block_map_seek (rtems_rfs_file_system* fs, + rtems_rfs_block_map* map, + rtems_rfs_pos_rel offset, + rtems_rfs_buffer_block* block); + +/** + * Seek to the next block. + * + * @param[in] fs is the file system data. + * @param[in] map is a pointer to the map to search. + * @param[out] block will contain the block in when found. + * + * @retval 0 Successful operation. + * @retval ENXIO Failed to seek because it is outside the block map. + * @retval error_code An error occurred. + */ +int rtems_rfs_block_map_next_block (rtems_rfs_file_system* fs, + rtems_rfs_block_map* map, + rtems_rfs_buffer_block* block); + +/** + * Grow the block map by the specified number of blocks. + * + * @param[in] fs is the file system data. + * @param[in] map is a pointer to the open map to grow. + * @param[in] blocks is the number of blocks to grow the map by. + * @param[out] new_block will contain first of the blocks allocated + * to the map. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_block_map_grow (rtems_rfs_file_system* fs, + rtems_rfs_block_map* map, + size_t blocks, + rtems_rfs_block_no* new_block); + +/** + * Grow the block map by the specified number of blocks. + * + * @param[in] fs is the file system data. + * @param[in] map is a pointer to the open map to shrink. + * @param[in] blocks is the number of blocks to shrink the map by. If more + * than the number of blocks the map is emptied. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_block_map_shrink (rtems_rfs_file_system* fs, + rtems_rfs_block_map* map, + size_t blocks); + +/** + * Free all blocks in the map. + * + * @param[in] fs is the file system data. + * @param[in] map is a pointer to the open map to free all blocks from. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_block_map_free_all (rtems_rfs_file_system* fs, + rtems_rfs_block_map* map); + +#endif diff --git a/cpukit/include/rtems/rfs/rtems-rfs-buffer.h b/cpukit/include/rtems/rfs/rtems-rfs-buffer.h new file mode 100644 index 0000000000..1c603e1827 --- /dev/null +++ b/cpukit/include/rtems/rfs/rtems-rfs-buffer.h @@ -0,0 +1,283 @@ +/** + * @file + * + * @ingroup rtems_rfs + * + * @brief Maps Blocks to the Media Interface Layers + * + * These functions map blocks to the media interface layers. + */ + +/* + * COPYRIGHT (c) 2010 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + + +#if !defined (_RTEMS_RFS_BUFFER_H_) +#define _RTEMS_RFS_BUFFER_H_ + +#include + +#include +#include + +/** + * Define the method used to interface to the buffers. It can be libblock or + * device I/O. The libblock interface is to the RTEMS cache and block devices + * and device I/O accesses the media via a device file handle. + */ +#if defined (__rtems__) +#define RTEMS_RFS_USE_LIBBLOCK 1 +#endif + +/** + * The RTEMS RFS I/O Layering. + */ +#if RTEMS_RFS_USE_LIBBLOCK +#include +#include + +typedef rtems_blkdev_bnum rtems_rfs_buffer_block; +typedef rtems_bdbuf_buffer rtems_rfs_buffer; +#define rtems_rfs_buffer_io_request rtems_rfs_buffer_bdbuf_request +#define rtems_rfs_buffer_io_release rtems_rfs_buffer_bdbuf_release + +/** + * Request a buffer from the RTEMS libblock BD buffer cache. + */ +int rtems_rfs_buffer_bdbuf_request (rtems_rfs_file_system* fs, + rtems_rfs_buffer_block block, + bool read, + rtems_rfs_buffer** buffer); +/** + * Release a buffer to the RTEMS libblock BD buffer cache. + */ +int rtems_rfs_buffer_bdbuf_release (rtems_rfs_buffer* handle, + bool modified); +#else /* Device I/O */ +typedef uint32_t rtems_rfs_buffer_block; +typedef struct _rtems_rfs_buffer +{ + rtems_chain_node link; + rtems_rfs_buffer_block user; + void* buffer; + size_t size; + uint32_t references; +} rtems_rfs_buffer; +#define rtems_rfs_buffer_io_request rtems_rfs_buffer_deviceio_request +#define rtems_rfs_buffer_io_release rtems_rfs_buffer_deviceio_release + +/** + * Request a buffer from the device I/O. + */ +int rtems_rfs_buffer_deviceio_request (rtems_rfs_file_system* fs, + rtems_rfs_buffer_block block, + bool read, + rtems_rfs_buffer* buffer); +/** + * Release a buffer to the RTEMS libblock BD buffer cache. + */ +int rtems_rfs_buffer_deviceio_release (rtems_rfs_buffer* handle, + bool modified); +#endif + +/** + * RFS Buffer handle. + */ +typedef struct rtems_rfs_buffer_handle_t +{ + /** + * Has the buffer been modifed? + */ + bool dirty; + + /** + * Block number. The lower layer block number may be absolute and we maybe + * relative to an offset in the disk so hold locally. + */ + rtems_rfs_buffer_block bnum; + + /** + * Reference the buffer descriptor. + */ + rtems_rfs_buffer* buffer; + +} rtems_rfs_buffer_handle; + +/** + * The buffer linkage. + */ +#define rtems_rfs_buffer_link(_h) (&(_h)->buffer->link) + +/** + * Return the start of the data area of the buffer given a handle. + */ +#define rtems_rfs_buffer_data(_h) ((void*)((_h)->buffer->buffer)) + +/** + * Return the size of the buffer given a handle. + */ +#define rtems_rfs_buffer_size(_h) ((_h)->buffer->size) + +/** + * Return the block number. + */ +#define rtems_rfs_buffer_bnum(_h) ((_h)->bnum) + +/** + * Return the buffer dirty status. + */ +#define rtems_rfs_buffer_dirty(_h) ((_h)->dirty) + +/** + * Does the handle have a valid block attached ? + */ +#define rtems_rfs_buffer_handle_has_block(_h) ((_h)->buffer ? true : false) + +/** + * Mark the buffer as dirty. + */ +#define rtems_rfs_buffer_mark_dirty(_h) ((_h)->dirty = true) + +/** + * Return the reference count. + */ +#define rtems_rfs_buffer_refs(_h) ((_h)->buffer->references) + +/** + * Increment the reference count. + */ +#define rtems_rfs_buffer_refs_up(_h) ((_h)->buffer->references += 1) + +/** + * Decrement the reference count. + */ +#define rtems_rfs_buffer_refs_down(_h) ((_h)->buffer->references -= 1) + +/** + * Request a buffer. The buffer can be filled with data from the media + * (read == true) or you can request a buffer to fill with data. + * + * @param[in] fs is the file system data. + * @param[in] handle is the handle the requested buffer is attached to. + * @param[in] block is the block number. + * @param[in] read Read the data from the disk. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_buffer_handle_request (rtems_rfs_file_system* fs, + rtems_rfs_buffer_handle* handle, + rtems_rfs_buffer_block block, + bool read); + +/** + * Release a buffer. If the buffer is dirty the buffer is written to disk. The + * result does not indicate if the data was successfully written to the disk as + * this operation may be performed in asynchronously to this release. + * + * @param[in] fs is the file system data. + * @param[in] handle is the handle the requested buffer is attached to. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_buffer_handle_release (rtems_rfs_file_system* fs, + rtems_rfs_buffer_handle* handle); + +/** + * Open a handle. + * + * @param[in] fs i the file system data. + * @param[in] handle i the buffer handle to open. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +static inline int +rtems_rfs_buffer_handle_open (rtems_rfs_file_system* fs, + rtems_rfs_buffer_handle* handle) +{ + handle->dirty = false; + handle->bnum = 0; + handle->buffer = NULL; + return 0; +} + +/** + * Close a handle. + * + * @param[in] fs is the file system data. + * @param[in] handle is the buffer handle to close. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +static inline int +rtems_rfs_buffer_handle_close (rtems_rfs_file_system* fs, + rtems_rfs_buffer_handle* handle) +{ + rtems_rfs_buffer_handle_release (fs, handle); + handle->dirty = false; + handle->bnum = 0; + handle->buffer = NULL; + return 0; +} + +/** + * Open the buffer interface. + * + * @param[in] name is a pointer to the device name to the media. + * @param[in] fs is the file system data. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_buffer_open (const char* name, rtems_rfs_file_system* fs); + +/** + * Close the buffer interface. + * + * @param[in] fs is the file system data. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_buffer_close (rtems_rfs_file_system* fs); + +/** + * Sync all buffers to the media. + * + * @param[in] fs is the file system data. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_buffer_sync (rtems_rfs_file_system* fs); + +/** + * Set the block size of the device. + * + * @param[in] fs is the file system data. + * @param[in] size is the new block size. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_buffer_setblksize (rtems_rfs_file_system* fs, uint32_t size); + +/** + * Release any chained buffers. + * + * @param[in] fs is the file system data. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_buffers_release (rtems_rfs_file_system* fs); + +#endif diff --git a/cpukit/include/rtems/rfs/rtems-rfs-data.h b/cpukit/include/rtems/rfs/rtems-rfs-data.h new file mode 100644 index 0000000000..6217e74587 --- /dev/null +++ b/cpukit/include/rtems/rfs/rtems-rfs-data.h @@ -0,0 +1,89 @@ +/** + * @file + * + * @brief RTEMS File System Data + * + * @ingroup rtems_rfs + * + * RTEMS File System Data. + * + * Access data in the correct byte order for the specific target we are running + * on. + * + * @todo Make direct access on matching byte ordered targets. + */ + +/* + * COPYRIGHT (c) 2010 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + + +#if !defined (_RTEMS_RFS_DATA_H_) +#define _RTEMS_RFS_DATA_H_ + +#include + +/** + * Helper function to make sure we have a byte pointer. + */ +#define rtems_rfs_data_ptr(_d) ((uint8_t*)(_d)) + +/** + * Helper function to get the data shifted in the correctly sized type. + */ +#define rtems_rfs_data_get(_d, _t, _o, _s) \ + (((_t)(rtems_rfs_data_ptr (_d)[_o])) << (_s)) + +/** + * RFS Read Unsigned 8bit Integer + */ +#define rtems_rfs_read_u8(_d) \ + (*rtems_rfs_data_ptr (_d)) + +/** + * RFS Read Unsigned 16bit Integer + */ +#define rtems_rfs_read_u16(_d) \ + (rtems_rfs_data_get (_d, uint16_t, 0, 8) | \ + rtems_rfs_data_get (_d, uint16_t, 1, 0)) + +/** + * RFS Read Unsigned 32bit Integer + */ +#define rtems_rfs_read_u32(_d) \ + (rtems_rfs_data_get (_d, uint32_t, 0, 24) | \ + rtems_rfs_data_get (_d, uint32_t, 1, 16) | \ + rtems_rfs_data_get (_d, uint32_t, 2, 8) | \ + rtems_rfs_data_get (_d, uint32_t, 3, 0)) + +/** + * RFS Write Unsigned 8bit Integer + */ +#define rtems_rfs_write_u8(_d, _v) \ + (*rtems_rfs_data_ptr (_d) = (uint8_t)(_v)) + +/** + * RFS Write Unsigned 16bit Integer + */ +#define rtems_rfs_write_u16(_d, _v) \ + do { \ + rtems_rfs_data_ptr (_d)[0] = (uint8_t)(((uint16_t)(_v)) >> 8); \ + rtems_rfs_data_ptr (_d)[1] = (uint8_t)((_v)); \ + } while (0) + +/** + * RFS Write Unsigned 32bit Integer + */ +#define rtems_rfs_write_u32(_d, _v) \ + do { \ + rtems_rfs_data_ptr (_d)[0] = (uint8_t)(((uint32_t)(_v)) >> 24); \ + rtems_rfs_data_ptr (_d)[1] = (uint8_t)(((uint32_t)(_v)) >> 16); \ + rtems_rfs_data_ptr (_d)[2] = (uint8_t)(((uint32_t)(_v)) >> 8); \ + rtems_rfs_data_ptr (_d)[3] = (uint8_t)((uint32_t)(_v)); \ + } while (0) + +#endif diff --git a/cpukit/include/rtems/rfs/rtems-rfs-dir-hash.h b/cpukit/include/rtems/rfs/rtems-rfs-dir-hash.h new file mode 100644 index 0000000000..d9a8a2004f --- /dev/null +++ b/cpukit/include/rtems/rfs/rtems-rfs-dir-hash.h @@ -0,0 +1,36 @@ +/** + * @file + * + * @brief Provides a 32bit Hash of a String used to Search a Directory + * + * @ingroup rtems_rfs + * + * RTEMS File Systems Directory Hash provides a 32bit hash of a string. This is + * used to search a directory. + */ + +/* + * COPYRIGHT (c) 2010 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#if !defined (_RTEMS_RFS_DIR_HASH_H_) +#define _RTEMS_RFS_DIR_HAS_H_ + +#include +#include + +/** + * Compute a hash of the key over the length of string. + * + * @param[in] key is a pointer to the key to calculate the hash of. + * @param[in] length is the length of the key in bytes. + * + * @retval hash The computed uint32_t hash. + */ +uint32_t rtems_rfs_dir_hash (const void *key, size_t length); + +#endif diff --git a/cpukit/include/rtems/rfs/rtems-rfs-dir.h b/cpukit/include/rtems/rfs/rtems-rfs-dir.h new file mode 100644 index 0000000000..ae3647d03c --- /dev/null +++ b/cpukit/include/rtems/rfs/rtems-rfs-dir.h @@ -0,0 +1,209 @@ +/** + * @file + * + * @brief RTEMS File System Directory Support + * + * @ingroup rtems_rfs + * + * RTEMS File System Directory Support + * + * This file provides the directory support functions. + */ + +/* + * COPYRIGHT (c) 2010 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#if !defined (_RTEMS_RFS_DIR_H_) +#define _RTEMS_RFS_DIR_H_ + +#include + +#include + +#include +#include +#include + +/** + * Define the offsets of the fields of a directory entry. + */ +#define RTEMS_RFS_DIR_ENTRY_INO (0) /**< The ino offset in a directory + * entry. */ +#define RTEMS_RFS_DIR_ENTRY_HASH (4) /**< The hash offset in a directory + * entry. The hash is 32bits. We need at + * least 16bits and given the length and + * ino field are 4 the extra 2 bytes is + * not a big overhead.*/ +#define RTEMS_RFS_DIR_ENTRY_LEN (8) /**< The length offset in a directory + * entry. */ + +/** + * The length of the directory entry header. + */ +#define RTEMS_RFS_DIR_ENTRY_SIZE (4 + 4 + 2) + +/** + * The length when the remainder of the directory block is empty. + */ +#define RTEMS_RFS_DIR_ENTRY_EMPTY (0xffff) + +/** + * Return the hash of the entry. + * + * @param[in] _e is a pointer to the directory entry. + * + * @retval hash The uint32_t hash of the entry. + */ +#define rtems_rfs_dir_entry_hash(_e) \ + rtems_rfs_read_u32 (_e + RTEMS_RFS_DIR_ENTRY_HASH) + +/** + * Set the hash of the entry. + * + * @param[in] _e is a pointer to the directory entry. + * + * @param[in] _h is the hash of the entry. + */ +#define rtems_rfs_dir_set_entry_hash(_e, _h) \ + rtems_rfs_write_u32 (_e + RTEMS_RFS_DIR_ENTRY_HASH, _h) + +/** + * Return the ino of the entry. + * + * @param[in] _e is a pointer to the directory entry. + * + * @retval ino The ino of the entry. + */ +#define rtems_rfs_dir_entry_ino(_e) \ + rtems_rfs_read_u32 (_e + RTEMS_RFS_DIR_ENTRY_INO) + +/** + * Set the ino of the entry. + * + * @param[in] _e is a pointer to the directory entry. + * + * @param[in] _i is the ino of the entry. + */ +#define rtems_rfs_dir_set_entry_ino(_e, _i) \ + rtems_rfs_write_u32 (_e + RTEMS_RFS_DIR_ENTRY_INO, _i) + +/** + * Return the length of the entry. + * + * @param[in] _e Pointer to the directory entry. + * + * @retval length The length of the entry. + */ +#define rtems_rfs_dir_entry_length(_e) \ + rtems_rfs_read_u16 (_e + RTEMS_RFS_DIR_ENTRY_LEN) + +/** + * Set the length of the entry. + * + * @param[in] _e is a pointer to the directory entry. + * @param[in] _l is the length. + */ +#define rtems_rfs_dir_set_entry_length(_e, _l) \ + rtems_rfs_write_u16 (_e + RTEMS_RFS_DIR_ENTRY_LEN, _l) + +/** + * Look up a directory entry in the directory pointed to by the inode. The look + * up is local to this directory. No need to decend. + * + * @param[in] fs is the file system. + * @param[in] inode is a pointer to the inode of the directory to search. + * @param[in] name is a pointer to the name to look up. The name may not be + * nul terminated. + * @param[in] length is the length of the name. + * @param[out] ino will be filled in with the inode number + * if there is no error. + * @param[in] offset is the offset in the directory for the entry. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_dir_lookup_ino (rtems_rfs_file_system* fs, + rtems_rfs_inode_handle* inode, + const char* name, + int length, + rtems_rfs_ino* ino, + uint32_t* offset); + +/** + * Add an entry to the directory returing the inode number allocated to the + * entry. + * + * @param[in] fs is the file system data. + * @param[in] dir is a pointer to the directory inode the + * entry is to be added too. + * @param[in] name is a pointer to the name of the entry to be added. + * @param[in] length is the length of the name excluding a terminating 0. + * @param[in] ino is the ino of the entry. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_dir_add_entry (rtems_rfs_file_system* fs, + rtems_rfs_inode_handle* dir, + const char* name, + size_t length, + rtems_rfs_ino ino); + +/** + * Del an entry from the directory using an inode number as a key. + * + * @param[in] fs is the file system data. + * @param[in] dir is a pointer to the directory inode the + * entry is to be deleted from. + * @param[in] ino is the ino of the entry. + * @param[in] offset is the offset in the directory of the entry + * to delete. If 0 search from the start for the ino. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_dir_del_entry (rtems_rfs_file_system* fs, + rtems_rfs_inode_handle* dir, + rtems_rfs_ino ino, + uint32_t offset); + +/** + * Read the directory entry from offset into the directory entry buffer and + * return the length of space this entry uses in the directory table. + * + * @param[in] fs is the file system data. + * @param[in] dir is a pointer to the direct inode handler. + * @param[in] offset is the offset in the directory to read from. + * @param[in] dirent is a ointer to the dirent structure the entry + * is written into. + * @param[out] length will contain the length this entry + * takes in the directory. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_dir_read (rtems_rfs_file_system* fs, + rtems_rfs_inode_handle* dir, + rtems_rfs_pos_rel offset, + struct dirent* dirent, + size_t* length); + +/** + * Check if the directory is empty. The current and parent directory entries + * are ignored. + * + * @param[in] fs is the file system data + * @param[in] dir is a pointer to the directory inode to check. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_dir_empty (rtems_rfs_file_system* fs, + rtems_rfs_inode_handle* dir); + +#endif diff --git a/cpukit/include/rtems/rfs/rtems-rfs-file-system-fwd.h b/cpukit/include/rtems/rfs/rtems-rfs-file-system-fwd.h new file mode 100644 index 0000000000..e239c25d6f --- /dev/null +++ b/cpukit/include/rtems/rfs/rtems-rfs-file-system-fwd.h @@ -0,0 +1,29 @@ +/** + * @file + * + * @brief RTEMS File Systems Data Forward Declaration + * + * @ingroup rtems_rfs + * + * RTEMS File Systems Data forward decl. + */ + +/* + * COPYRIGHT (c) 2010 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + + +#if !defined (_RTEMS_RFS_FILE_SYSTEM_FWD_H_) +#define _RTEMS_RFS_FILE_SYSTEM_FWD_H_ + +/** + * Forward reference to the file system data. + */ +struct _rtems_rfs_file_system; +typedef struct _rtems_rfs_file_system rtems_rfs_file_system; + +#endif diff --git a/cpukit/include/rtems/rfs/rtems-rfs-file-system.h b/cpukit/include/rtems/rfs/rtems-rfs-file-system.h new file mode 100644 index 0000000000..e00b142532 --- /dev/null +++ b/cpukit/include/rtems/rfs/rtems-rfs-file-system.h @@ -0,0 +1,410 @@ +/** + * @file + * + * @brief RTEMS File System Data + * + * @ingroup rtems_rfs + * + * RTEMS File System Data + * + * This file defines the file system data. + */ + +/* + * COPYRIGHT (c) 2010 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#if !defined (_RTEMS_RFS_FILE_SYSTEM_H_) +#define _RTEMS_RFS_FILE_SYSTEM_H_ + +#include + +/** + * Superblock offsets and values. + */ +#define RTEMS_RFS_SB_OFFSET_MAGIC (0) +#define RTEMS_RFS_SB_MAGIC (0x28092001) +#define RTEMS_RFS_SB_OFFSET_VERSION (RTEMS_RFS_SB_OFFSET_MAGIC + 4) +#define RTEMS_RFS_SB_OFFSET_BLOCK_SIZE (RTEMS_RFS_SB_OFFSET_VERSION + 4) +#define RTEMS_RFS_SB_OFFSET_BLOCKS (RTEMS_RFS_SB_OFFSET_BLOCK_SIZE + 4) +#define RTEMS_RFS_SB_OFFSET_BAD_BLOCKS (RTEMS_RFS_SB_OFFSET_BLOCKS + 4) +#define RTEMS_RFS_SB_OFFSET_MAX_NAME_LENGTH (RTEMS_RFS_SB_OFFSET_BAD_BLOCKS + 4) +#define RTEMS_RFS_SB_OFFSET_GROUPS (RTEMS_RFS_SB_OFFSET_MAX_NAME_LENGTH + 4) +#define RTEMS_RFS_SB_OFFSET_GROUP_BLOCKS (RTEMS_RFS_SB_OFFSET_GROUPS + 4) +#define RTEMS_RFS_SB_OFFSET_GROUP_INODES (RTEMS_RFS_SB_OFFSET_GROUP_BLOCKS + 4) +#define RTEMS_RFS_SB_OFFSET_INODE_SIZE (RTEMS_RFS_SB_OFFSET_GROUP_INODES + 4) + +/** + * RFS Version Number. + */ +#define RTEMS_RFS_VERSION (0x00000000) + +/** + * RFS Version Number Mask. The mask determines which bits of the version + * number indicate compatility issues. + */ +#define RTEMS_RFS_VERSION_MASK INT32_C(0x00000000) + +/** + * The root inode number. Do not use 0 as this has special meaning in some + * Unix operating systems. + */ +#define RTEMS_RFS_ROOT_INO (1) + +/** + * Empty inode number. + */ +#define RTEMS_RFS_EMPTY_INO (0) + +/** + * The number of blocks in the inode. This number effects the size of the + * inode and that effects the overhead of the inode tables in a group. + */ +#define RTEMS_RFS_INODE_BLOCKS (5) + +/** + * The inode overhead is the percentage of space reserved for inodes. It is + * calculated as the percentage number of blocks in a group. The number of + * blocks in a group is the number of bits a block can hold. + */ +#define RTEMS_RFS_INODE_OVERHEAD_PERCENTAGE (1) + +/** + * Number of blocks in the superblock. Yes I know it is a superblock and not + * superblocks but if for any reason this needs to change it is handled. + */ +#define RTEMS_RFS_SUPERBLOCK_SIZE (1) + +/** + * The maximum number of buffers held by the file system at any one time. + */ +#define RTEMS_RFS_FS_MAX_HELD_BUFFERS (5) + +/** + * Absolute position. Make a 64bit value. + */ +typedef uint64_t rtems_rfs_pos; + +/** + * Relative position. Make a 64bit value. + */ +typedef int64_t rtems_rfs_pos_rel; + +/** + * Flags to control the file system. + */ +#define RTEMS_RFS_FS_BITMAPS_HOLD (1 << 0) /**< Do not release bitmaps + * when finished. Default is + * off so they are released. */ +#define RTEMS_RFS_FS_NO_LOCAL_CACHE (1 << 1) /**< Do not cache the buffers + * and release directly to the + * buffer support layer. The + * default is to hold buffers. */ +#define RTEMS_RFS_FS_FORCE_OPEN (1 << 2) /**< Force open and ignore any + * errors. */ +#define RTEMS_RFS_FS_READ_ONLY (1 << 3) /**< Make the mount + * read-only. Currently not + * supported. */ +/** + * RFS File System data. + */ +struct _rtems_rfs_file_system +{ + /** + * Flags to control the file system. Some can be controlled via the ioctl. + */ + uint32_t flags; + + /** + * The number of blocks in the disk. The size of the disk is the number of + * blocks by the block size. This should be within a block size of the size + * returned by the media driver. + */ + size_t blocks; + + /** + * The size of a block. This must be a multiple of the disk's media block + * size. + */ + size_t block_size; + + /** + * The file descriptor for device I/O. + */ + int device; + +#if RTEMS_RFS_USE_LIBBLOCK + /** + * The disk device. This is the data about the block device this file system + * is mounted on. We access the data held in this structure rather than + * making an extra copy in this structure. + */ + rtems_disk_device* disk; +#else + /** + * The number of blocks in the file system. + */ + size_t size; +#endif + + /** + * Inode count. + */ + uint32_t inodes; + + /** + * Bad block blocks. This is a table of blocks that have been found to be + * bad. + */ + uint32_t bad_blocks; + + /** + * Maximum length of names supported by this file system. + */ + uint32_t max_name_length; + + /** + * A disk is broken down into a series of groups. + */ + rtems_rfs_group* groups; + + /** + * Number of groups. + */ + int group_count; + + /** + * Number of blocks in a group. + */ + size_t group_blocks; + + /** + * Number of inodes in a group. + */ + size_t group_inodes; + + /** + * Number of inodes in each block. + */ + size_t inodes_per_block; + + /** + * Number of block numbers in a block. + */ + size_t blocks_per_block; + + /** + * Block map single indirect count. This is the block number per block + * multiplied but the slots in the inode. + */ + size_t block_map_singly_blocks; + + /** + * Block map double indirect count. This is the block number per block + * squared and multiplied by the slots in the inode. It is the maximum + * number of blocks a map (file/directory) can have. + */ + size_t block_map_doubly_blocks; + + /** + * Number of buffers held before releasing back to the cache. + */ + uint32_t max_held_buffers; + + /** + * List of buffers attached to buffer handles. Allows sharing. + */ + rtems_chain_control buffers; + + /** + * Number of buffers held on the buffers list. + */ + uint32_t buffers_count; + + /** + * List of buffers that need to be released when the processing of a file + * system request has completed. + */ + rtems_chain_control release; + + /** + * Number of buffers held on the release list. + */ + uint32_t release_count; + + /** + * List of buffers that need to be released modified when the processing of a + * file system request has completed. + */ + rtems_chain_control release_modified; + + /** + * Number of buffers held on the release modified list. + */ + uint32_t release_modified_count; + + /** + * List of open shared file node data. The shared node data such as the inode + * and block map allows a single file to be open more than once. + */ + rtems_chain_control file_shares; + + /** + * Pointer to user data supplied when opening. + */ + void* user; +}; + +/** + * Return the flags. + * + * @param[in] _fs is a pointer to the file system. + */ +#define rtems_rfs_fs_flags(_f) ((_f)->flags) +/** + * Should bitmap buffers be released when finished ? + * + * @param[in] _fs is a pointer to the file system. + */ +#define rtems_rfs_fs_release_bitmaps(_f) (!((_f)->flags & RTEMS_RFS_FS_BITMAPS_HOLD)) + +/** + * Are the buffers locally cache or released back to the buffering layer ? + * + * @param[in] _fs is a pointer to the file system. + */ +#define rtems_rfs_fs_no_local_cache(_f) ((_f)->flags & RTEMS_RFS_FS_NO_LOCAL_CACHE) + +/** + * The disk device number. + * + * @param[in] _fs is a pointer to the file system. + */ +#if RTEMS_RFS_USE_LIBBLOCK +#define rtems_rfs_fs_device(_fs) ((_fs)->disk) +#else +#define rtems_rfs_fs_device(_fs) ((_fs)->device) +#endif + +/** + * The size of the disk in blocks. + * + * @param[in] _fs is a pointer to the file system. + */ +#define rtems_rfs_fs_blocks(_fs) ((_fs)->blocks) + +/** + * The block size. + * + * @param[in] _fs is a pointer to the file system. + */ +#define rtems_rfs_fs_block_size(_fs) ((_fs)->block_size) + +/** + * The number of inodes. + * + * @param[in] _fs is a pointer to the file system. + */ +#define rtems_rfs_fs_inodes(_fs) ((_fs)->inodes) + +/** + * Calculate a block in the file system given the group and the block within + * the group. + * + * @param[in] _fs is a pointer to the file system. + * @param[in] _grp is the group. + * @param[in] _blk is the block within the group. + * @return The absolute block number. + */ +#define rtems_rfs_fs_block(_fs, _grp, _blk) \ + ((((_fs)->group_blocks) * (_grp)) + (_blk) + 1) + +/** + * The media size of the disk in media size blocks. + * + * @param[in] _fs is a pointer to the file system. + */ +#if RTEMS_RFS_USE_LIBBLOCK +#define rtems_rfs_fs_media_blocks(_fs) ((_fs)->disk->size) +#else +#define rtems_rfs_fs_media_blocks(_fs) ((_fs)->media_size) +#endif + +/** + * The media block size. This is the size of a block on disk. For a device I/O + * this value is 1. + * + * @param[in] _fs is a pointer to the file system. + */ +#if RTEMS_RFS_USE_LIBBLOCK +#define rtems_rfs_fs_media_block_size(_fs) ((_fs)->disk->media_block_size) +#else +#define rtems_rfs_fs_media_block_size(_fs) (1) +#endif + +/** + * The maximum length of a name supported by the file system. + */ +#define rtems_rfs_fs_max_name(_fs) ((_fs)->max_name_length) + +/** + * Return the maximum number of blocks in a block map. + * + * @return uint32_t The maximum number of blocks possible. + */ +#define rtems_rfs_fs_max_block_map_blocks(_fs) ((_fs)->block_map_doubly_blocks) + +/** + * Return the user pointer. + */ +#define rtems_rfs_fs_user(_fs) ((_fs)->user) + +/** + * Return the size of the disk in bytes. + * + * @param[in] fs is a pointer to the file system. + * @return uint64_t The size of the disk in bytes. + */ +uint64_t rtems_rfs_fs_size(rtems_rfs_file_system* fs); + +/** + * The size of the disk in bytes calculated from the media parameters.. + * + * @param[in] fs is a pointer to the file system. + * @return uint64_t The size of the disk in bytes. + */ +uint64_t rtems_rfs_fs_media_size (rtems_rfs_file_system* fs); + +/** + * Open the file system given a file path. + * + * @param[in] name is a pointer to the device to open. + * @param[in] fs is the file system data filled in by this call. + * @param[in] user is a pointer to the user data. + * @param[in] flags is a initial set of user flags for the file system. + * @param[in] max_held_buffers is the maximum number of buffers the RFS holds. + * + * @retval 0 Successful operation. + * @retval -1 Error. See errno + */ +int rtems_rfs_fs_open (const char* name, + void* user, + uint32_t flags, + uint32_t max_held_buffers, + rtems_rfs_file_system** fs); + +/** + * Close the file system. + * + * @param[in] fs is the file system data. + * + * @retval 0 Successful operation. + * @retval -1 Error. See errno + */ +int rtems_rfs_fs_close (rtems_rfs_file_system* fs); + +#endif diff --git a/cpukit/include/rtems/rfs/rtems-rfs-file.h b/cpukit/include/rtems/rfs/rtems-rfs-file.h new file mode 100644 index 0000000000..772e846143 --- /dev/null +++ b/cpukit/include/rtems/rfs/rtems-rfs-file.h @@ -0,0 +1,416 @@ +/** + * @file + * + * @brief RTEMS File System File Support + * + * @ingroup rtems_rfs + * + * RTEMS File System File Support + * + * This file provides the support functions. + */ + +/* + * COPYRIGHT (c) 2010 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#if !defined (_RTEMS_RFS_FILE_H_) +#define _RTEMS_RFS_FILE_H_ + +#include + +#include +#include +#include +#include + +/** + * File data that is shared by various file handles accessing the same file. We + * hold various inode values common to the file that can change frequently so + * the inode is not thrashed yet we meet the requirements of the POSIX + * standard. The stat call needs to check the shared file data. + */ +typedef struct _rtems_rfs_file_shared +{ + /** + * The shared parts are maintained as a list. + */ + rtems_chain_node link; + + /** + * Reference count the users of this data. + */ + int references; + + /** + * The inode for the file. + */ + rtems_rfs_inode_handle inode; + + /** + * The block map for the file. The handle holds the file's position not the + * map. + */ + rtems_rfs_block_map map; + + /** + * The size of the file as taken from the inode. The map's size and + * this size should be the same. + */ + rtems_rfs_block_size size; + + /** + * The access time. The last time the file was read. + */ + rtems_rfs_time atime; + + /** + * The modified time. The last time the file was written too. + */ + rtems_rfs_time mtime; + + /** + * The change time. The last time the inode was written too. + */ + rtems_rfs_time ctime; + + /** + * Hold a pointer to the file system data so users can take the handle and + * use it without the needing to hold the file system data pointer. + */ + rtems_rfs_file_system* fs; + +} rtems_rfs_file_shared; + +/** + * Get the atime. + * + * @param[in] shared is a pointer to the shared file data. + * + * @retval atime The atime. + */ +static inline rtems_rfs_time +rtems_rfs_file_shared_get_atime (rtems_rfs_file_shared* shared) +{ + return shared->atime; +} + +/** + * Get the mtime. + * + * @param[in] shared is a pointer to the shared file data. + * + * @retval mtime The mtime. + */ +static inline rtems_rfs_time +rtems_rfs_file_shared_get_mtime (rtems_rfs_file_shared* shared) +{ + return shared->mtime; +} + +/** + * Get the ctime. + * + * @param[in] shared is a pointer to the shared file data. + * + * @retval ctime The ctime. + */ +static inline rtems_rfs_time +rtems_rfs_file_shared_get_ctime (rtems_rfs_file_shared* shared) +{ + return shared->ctime; +} + +/** + * Get the block count. + * + * @param[in] shared is a pointer to the shared file data. + * + * @retval count The block count. + */ +static inline uint32_t +rtems_rfs_file_shared_get_block_count (rtems_rfs_file_shared* shared) +{ + return shared->size.count; +} + +/** + * Get the block offset. + * + * @param shared is a pointer to the shared file data. + * + * @retval offset The block offset. + */ +static inline uint16_t +rtems_rfs_file_shared_get_block_offset (rtems_rfs_file_shared* shared) +{ + return shared->size.offset; +} + +/** + * Calculate the size of data. + * + * @param[in] fs is the file system data. + * @param[in] shared is a pointer to the shared file data. + * + * @retval data The data size in bytes. + */ +static inline rtems_rfs_pos +rtems_rfs_file_shared_get_size (rtems_rfs_file_system* fs, + rtems_rfs_file_shared* shared) +{ + return rtems_rfs_block_get_size (fs, &shared->size); +} + +/** + * File flags. + */ +#define RTEMS_RFS_FILE_NO_ATIME_UPDATE (1 << 0) /**< Do not update the atime + * field in the inode if + * set. */ +#define RTEMS_RFS_FILE_NO_MTIME_UPDATE (1 << 1) /**< Do not update the mtime + * field in the inode if + * set. */ +#define RTEMS_RFS_FILE_NO_LENGTH_UPDATE (1 << 2) /**< Do not update the position + * field in the inode if + * set. */ + +/** + * File data used to managed an open file. + */ +typedef struct _rtems_rfs_file_handle +{ + /** + * Special flags that can be controlled by the fctrl call. + */ + int flags; + + /** + * The buffer of data at the file's position. + */ + rtems_rfs_buffer_handle buffer; + + /** + * The block position of this file handle. + */ + rtems_rfs_block_pos bpos; + + /** + * Pointer to the shared file data. + */ + rtems_rfs_file_shared* shared; + +} rtems_rfs_file_handle; + +/** + * Access the data in the buffer. + */ +#define rtems_rfs_file_data(_f) \ + (rtems_rfs_buffer_data (&(_f)->buffer) + (_f)->bpos.boff) + +/** + * Return the file system data pointer given a file handle. + */ +#define rtems_rfs_file_fs(_f) ((_f)->shared->fs) + +/** + * Return the file's inode handle pointer given a file handle. + */ +#define rtems_rfs_file_inode(_f) (&(_f)->shared->inode) + +/** + * Return the file's block map pointer given a file handle. + */ +#define rtems_rfs_file_map(_f) (&(_f)->shared->map) + +/** + * Return the file's block position pointer given a file handle. + */ +#define rtems_rfs_file_bpos(_f) (&(_f)->bpos) + +/** + * Return the file's block number given a file handle. + */ +#define rtems_rfs_file_block(_f) ((_f)->bpos.bno) + +/** + * Return the file's block offset given a file handle. + */ +#define rtems_rfs_file_block_offset(_f) ((_f)->bpos.boff) + +/** + * Set the file's block position given a file position (absolute). + */ +#define rtems_rfs_file_set_bpos(_f, _p) \ + rtems_rfs_block_get_bpos (rtems_rfs_file_fs (_f), _p, (&(_f)->bpos)) + +/** + * Return the file's buffer handle pointer given a file handle. + */ +#define rtems_rfs_file_buffer(_f) (&(_f)->buffer) + +/** + * Update the access time field of the inode when reading if flagged to do so. + */ +#define rtems_rfs_file_update_atime(_f) \ + (((_f)->flags & RTEMS_RFS_FILE_NO_ATIME_UPDATE) == 0) + +/** + * Update the modified time field of the inode when writing if flagged to do so. + */ +#define rtems_rfs_file_update_mtime(_f) \ + (((_f)->flags & RTEMS_RFS_FILE_NO_MTIME_UPDATE) == 0) + +/** + * Update the length field of the inode. + */ +#define rtems_rfs_file_update_length(_f) \ + (((_f)->flags & RTEMS_RFS_FILE_NO_LENGTH_UPDATE) == 0) + +/** + * Return the shared size varable. + */ +#define rtems_rfs_file_get_size(_f) \ + (&(_f)->shared->size) + +/** + * Return the size of file. + */ +#define rtems_rfs_file_size(_f) \ + rtems_rfs_file_shared_get_size (rtems_rfs_file_fs (_f), (_f)->shared) + +/** + * Return the file block count. + */ +#define rtems_rfs_file_size_count(_f) \ + rtems_rfs_file_shared_get_block_count ((_f)->shared) + +/** + * Return the file block offset. + */ +#define rtems_rfs_file_size_offset(_f) \ + rtems_rfs_file_shared_get_block_offset ((_f)->shared) + +/** + * Open a file handle. + * + * @param[in] fs is the file system. + * @param[in] ino is the inode number of the file to be opened. + * @param[out] handle will be filled in with the handle pointer. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_file_open (rtems_rfs_file_system* fs, + rtems_rfs_ino ino, + int oflag, + rtems_rfs_file_handle** handle); + +/** + * Close an open file handle. + * + * @param[in] fs is the file system. + * @param[in] handle is the open file handle. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_file_close (rtems_rfs_file_system* fs, + rtems_rfs_file_handle* handle); + +/** + * Start I/O on a block of a file. This call only requests the block from the + * media if reading and makes the buffer available to you the via the + * rtems_rfs_file_data interface after the call. The available amount data is + * taken from the current file position until the end of the block. The file + * position is not adujsted until the I/O ends. An I/O request cannot perform + * I/O past the end of a block so the call returns the amount of data + * available. + * + * @param[in] handle is the file handle. + * @param[in] available is the amount of data available for I/O. + * @param[in] read is the I/O operation is a read so the block is read from the media. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_file_io_start (rtems_rfs_file_handle* handle, + size_t* available, + bool read); + +/** + * End the I/O. Any buffers held in the file handle and returned to the + * cache. If inode updating is not disable and the I/O is a read the atime + * field is updated and if a write I/O the mtime is updated. + * + * If the file's position is updated by the size amount. + * + * @param[in] handle is the file handle. + * @param[in] size is the amount of data read or written. + * @param[in] read is the I/O was a read if true else it was a write. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_file_io_end (rtems_rfs_file_handle* handle, + size_t size, + bool read); + +/** + * Release the I/O resources without any changes. If data has changed in the + * buffer and the buffer was not already released as modified the data will be + * lost. + * + * @param[in] handle is the file handle. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_file_io_release (rtems_rfs_file_handle* handle); + +/** + * The file to the position returning the old position. The position is + * abolute. + * + * @param[in] handle The file handle. + * @param[in] pos is the position to seek to. + * @param[out] new_pos will contain the actual position. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_file_seek (rtems_rfs_file_handle* handle, + rtems_rfs_pos pos, + rtems_rfs_pos* new_pos); + +/** + * Set the size of the file to the new size. This can extend the file to a new + * size. + * + * @param[in] handle is the file handle. + * @param[in] size is the new size of the file. + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_file_set_size (rtems_rfs_file_handle* handle, + rtems_rfs_pos size); + +/** + * Return the shared file data for an ino. + * + * @param[in] fs is the file system data. + * @param[in] ino is the inode number to locate the data for. + * @return rtems_rfs_file_shared* The shared data or NULL is not located. + * + * @retval shared The shared data. + * @retval NULL No shared file data is located. + */ +rtems_rfs_file_shared* rtems_rfs_file_get_shared (rtems_rfs_file_system* fs, + rtems_rfs_ino ino); + + +#endif diff --git a/cpukit/include/rtems/rfs/rtems-rfs-group.h b/cpukit/include/rtems/rfs/rtems-rfs-group.h new file mode 100644 index 0000000000..23e6434b2c --- /dev/null +++ b/cpukit/include/rtems/rfs/rtems-rfs-group.h @@ -0,0 +1,181 @@ +/** + * @file + * + * @brief RTEMS File Systems Group Management + * + * @ingroup rtems_rfs + * + * RTEMS File Systems Group Management. + * + * These functions manage the groups used in the file system. + */ + +/* + * COPYRIGHT (c) 2010 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + + +#if !defined (_RTEMS_RFS_GROUP_H_) +#define _RTEMS_RFS_GROUP_H_ + +/** + * @ingroup rtems_rfs + * + * RTEMS File System Group Management + */ +/**@{*/ + +#include +#include +#include + +/** + * Block allocations for a group on disk. + */ +#define RTEMS_RFS_GROUP_BLOCK_BITMAP_BLOCK (0) +#define RTEMS_RFS_GROUP_INODE_BITMAP_BLOCK (1) +#define RTEMS_RFS_GROUP_INODE_BLOCK (2) + +/** + * @brief Creates bit allocator for blocks in the group simpler. + * + * A group is a selection of blocks on the disk. Typically the number of blocks + * in a group is determined by the number of bits a block holds. This makes the + * bit allocator for blocks in the group simpler plus is allows a simple way to + * localise access to files and directories. + */ +typedef struct _rtems_rfs_group +{ + /** + * Base block number. + */ + rtems_rfs_buffer_block base; + + /** + * The number of blocks in the group. Groups may be different sizes. + */ + size_t size; + + /** + * The block bitmap control. + */ + rtems_rfs_bitmap_control block_bitmap; + + /** + * The handle to the block bitmap buffer. + */ + rtems_rfs_buffer_handle block_bitmap_buffer; + + /** + * The inode bitmap control. + */ + rtems_rfs_bitmap_control inode_bitmap; + + /** + * The handle to the inode bitmap buffer. + */ + rtems_rfs_buffer_handle inode_bitmap_buffer; + +} rtems_rfs_group; + +/** + * Return the disk's block for a block in a group. + */ +#define rtems_rfs_group_block(_g, _b) (((_g)->base) + (_b)) + +/** + * Return the file system inode for a inode in a group. + */ +#define rtems_rfs_group_inode(_f, _g, _i) \ + (((_f)->group_inodes * (_g)) + (_i) + RTEMS_RFS_ROOT_INO) + +/** + * @brief Open a group. + * + * Allocate all the resources including the bitmaps. + * + * @param fs The file system. + * @param base The base block number. + * @param size The number of blocks in the group. + * @param group Reference to the group to open. + * @retval int The error number (errno). No error if 0. + */ +int rtems_rfs_group_open (rtems_rfs_file_system* fs, + rtems_rfs_buffer_block base, + size_t size, + size_t inodes, + rtems_rfs_group* group); + +/** + * @brief Close a group. + * + * Release all resources the group holds. + * + * @param fs The file system. + * @param group The group to close. + * @retval int The error number (errno). No error if 0. + */ +int rtems_rfs_group_close (rtems_rfs_file_system* fs, + rtems_rfs_group* group); + +/** + * @brief Allocate an inode or block. + * + * The groups are searched to find the next + * available inode or block. + * + * @param fs The file system data. + * @param goal The goal to seed the bitmap search. + * @param inode If true allocate an inode else allocate a block. + * @param result The allocated bit in the bitmap. + * @retval int The error number (errno). No error if 0. + */ +int rtems_rfs_group_bitmap_alloc (rtems_rfs_file_system* fs, + rtems_rfs_bitmap_bit goal, + bool inode, + rtems_rfs_bitmap_bit* result); + +/** + * @brief Free the group allocated bit. + * + * @param fs The file system data. + * @param inode If true the number to free is an inode else it is a block. + * @param block The inode or block number to free. + * @retval int The error number (errno). No error if 0. + */ +int rtems_rfs_group_bitmap_free (rtems_rfs_file_system* fs, + bool inode, + rtems_rfs_bitmap_bit no); + +/** + * @brief Test the group allocated bit. + * + * @param fs The file system data. + * @param inode If true the number to free is an inode else it is a block. + * @param block The inode or block number to free. + * @param state Return the state of the bit. + * @retval int The error number (errno). No error if 0. + */ +int rtems_rfs_group_bitmap_test (rtems_rfs_file_system* fs, + bool inode, + rtems_rfs_bitmap_bit no, + bool* state); + +/** + * @brief Determine the number of blocks and inodes used. + * + * @param fs The file system data. + * @param blocks The number of blocks used. + * @param inodes The number of inodes used. + * @retval int The error number (errno). No error if 0. + */ +int rtems_rfs_group_usage (rtems_rfs_file_system* fs, + size_t* blocks, + size_t* inodes); + +/** @} */ +#endif diff --git a/cpukit/include/rtems/rfs/rtems-rfs-inode.h b/cpukit/include/rtems/rfs/rtems-rfs-inode.h new file mode 100644 index 0000000000..95861ea8a7 --- /dev/null +++ b/cpukit/include/rtems/rfs/rtems-rfs-inode.h @@ -0,0 +1,728 @@ +/** + * @file + * + * @brief RTEMS File System Information Node + * + * @ingroup rtems_rfs + * + * RTEMS File System Information Node. + * + * The information nodes hold the data about all nodes in the file system. + */ + +/* + * COPYRIGHT (c) 2010 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + + +#if !defined (_RTEMS_RFS_INODE_H_) +#define _RTEMS_RFS_INODE_H_ + +#include + +#include +#include + +/** + * The RFS mode definitions. Currently map to the C library ones. + */ +#define RTEMS_RFS_S_ISUID S_ISUID /**< Set user id on execution */ +#define RTEMS_RFS_S_ISGID S_ISGID /**< Set group id on execution */ +#define RTEMS_RFS_S_ISVTX S_ISVTX /**< Save swapped text even after use */ +#define RTEMS_RFS_S_IREAD S_IREAD /**< Read permission, owner */ +#define RTEMS_RFS_S_IWRITE S_IWRITE /**< Write permission, owner */ +#define RTEMS_RFS_S_IEXEC S_IEXEC /**< Execute/search permission, owner */ +#define RTEMS_RFS_S_ENFMT S_ENFMT /**< Enforcement-mode locking */ +#define RTEMS_RFS_S_IFMT S_IFMT /**< Type of file */ +#define RTEMS_RFS_S_IFDIR S_IFDIR /**< Directory */ +#define RTEMS_RFS_S_IFCHR S_IFCHR /**< Character special */ +#define RTEMS_RFS_S_IFBLK S_IFBLK /**< Block special */ +#define RTEMS_RFS_S_IFREG S_IFREG /**< Regular */ +#define RTEMS_RFS_S_IFLNK S_IFLNK /**< Symbolic link */ +#define RTEMS_RFS_S_IFSOCK S_IFSOCK /**< Socket */ +#define RTEMS_RFS_S_IFIFO S_IFIFO /**< Fifo */ +#define RTEMS_RFS_S_IRWXU S_IRWXU +#define RTEMS_RFS_S_IRUSR S_IRUSR /**< Read permission, owner */ +#define RTEMS_RFS_S_IWUSR S_IWUSR /**< Write permission, owner */ +#define RTEMS_RFS_S_IXUSR S_IXUSR /**< Execute/search permission, owner */ +#define RTEMS_RFS_S_IRWXG S_IRWXG +#define RTEMS_RFS_S_IRGRP S_IRGRP /**< Read permission, group */ +#define RTEMS_RFS_S_IWGRP S_IWGRP /**< Write permission, grougroup */ +#define RTEMS_RFS_S_IXGRP S_IXGRP /**< Execute/search permission, group */ +#define RTEMS_RFS_S_IRWXO S_IRWXO +#define RTEMS_RFS_S_IROTH S_IROTH /**< Read permission, other */ +#define RTEMS_RFS_S_IWOTH S_IWOTH /**< Write permission, other */ +#define RTEMS_RFS_S_IXOTH S_IXOTH /**< Execute/search permission, other */ + +#define RTEMS_RFS_S_ISBLK(m) S_ISBLK(m) +#define RTEMS_RFS_S_ISCHR(m) S_ISCHR(m) +#define RTEMS_RFS_S_ISDIR(m) S_ISDIR(m) +#define RTEMS_RFS_S_ISFIFO(m) S_ISFIFO(m) +#define RTEMS_RFS_S_ISREG(m) S_ISREG(m) +#define RTEMS_RFS_S_ISLNK(m) S_ISLNK(m) +#define RTEMS_RFS_S_ISSOCK(m) S_ISSOCK(m) + +/** + * Permissions of a symlink. + */ +#define RTEMS_RFS_S_SYMLINK \ + RTEMS_RFS_S_IFLNK | RTEMS_RFS_S_IRWXU | RTEMS_RFS_S_IRWXG | RTEMS_RFS_S_IRWXO + +/** + * The inode number or ino. + */ +typedef uint32_t rtems_rfs_ino; + +/** + * The time in the file system. + */ +typedef uint32_t rtems_rfs_time; + +/** + * The size of a block value on disk. This include the inodes and indirect + * tables. + */ +typedef uint32_t rtems_rfs_inode_block; + +/** + * The size of the data name field in the inode. + */ +#define RTEMS_RFS_INODE_DATA_NAME_SIZE \ + (RTEMS_RFS_INODE_BLOCKS * sizeof (rtems_rfs_inode_block)) + +/** + * The inode. + */ +typedef struct _rtems_rfs_inode +{ + /** + * The number of links to the inode. + */ + uint16_t links; + + /** + * The mode of the node. + */ + uint16_t mode; + + /** + * The owner of the node. + */ + uint32_t owner; + + /** + * Reserved. + */ + uint16_t flags; + + /** + * Amount of data held in the last block data. + */ + uint16_t block_offset; + + /** + * Number of blocks held by this file. + */ + uint32_t block_count; + + /** + * The access time. The last time the file was read. + */ + rtems_rfs_time atime; + + /** + * The modified time. The last time the file was written too. + */ + rtems_rfs_time mtime; + + /** + * The change time. The last time the inode was written too. + */ + rtems_rfs_time ctime; + + /** + * Blocks. These are the block numbers used by the node or table of + * nodes. The flags indicate the mode the blocks are being held in. In the + * direct table mode the blocks are entries in this table. In the indirect + * mode the blocks point to blocks that hold the block numbers. The data can + * also be a name if it fits. For example a symbolic link. + */ + union + { + rtems_rfs_inode_block blocks[RTEMS_RFS_INODE_BLOCKS]; + uint8_t name[RTEMS_RFS_INODE_DATA_NAME_SIZE]; + } data; + + /** + * The last block map block. Used as the goal when allocating a new block for + * use in the map. + */ + rtems_rfs_inode_block last_map_block; + + /** + * The last data block. Used as the goal when allocating a new block. + */ + rtems_rfs_inode_block last_data_block; + +} rtems_rfs_inode; + +/** + * The size of an inode. + */ +#define RTEMS_RFS_INODE_SIZE (sizeof (rtems_rfs_inode)) + +/** + * RFS Inode Handle. + */ +typedef struct _rtems_rfs_inode_handle +{ + /** + * Handles can be linked as a list for easy processing. + */ + rtems_chain_node link; + + /** + * The ino for this handle. + */ + rtems_rfs_ino ino; + + /** + * The pointer to the inode. + */ + rtems_rfs_inode* node; + + /** + * The buffer that contains this inode. + */ + rtems_rfs_buffer_handle buffer; + + /** + * The block number that holds the inode. + */ + rtems_rfs_buffer_block block; + + /** + * The offset into the block for the inode. + */ + int offset; + + /** + * Number of load requests. + */ + int loads; + +} rtems_rfs_inode_handle; + +/** + * Is the inode loaded ? + */ +#define rtems_rfs_inode_is_loaded(_h) ((_h)->node) + +/** + * Get the inode ino for a handle. + */ +#define rtems_rfs_inode_ino(_h) ((_h)->ino) + +/** + * Get the link count. + * + * @param[in] handle is the inode handle. + * + * @retval links The link count. + */ +static inline uint16_t +rtems_rfs_inode_get_links (rtems_rfs_inode_handle* handle) +{ + uint16_t links; + links = rtems_rfs_read_u16 (&handle->node->links); + if (links == 0xffff) + links = 0; + return links; +} + +/** + * Set the link count. + * + * @param[in] handle is the inode handle. + * @param[in] links are the links. + */ +static inline void +rtems_rfs_inode_set_links (rtems_rfs_inode_handle* handle, uint16_t links) +{ + rtems_rfs_write_u16 (&handle->node->links, links); + rtems_rfs_buffer_mark_dirty (&handle->buffer); +} + +/** + * Get the flags. + * + * @param[in] handle is the inode handle. + * + * @retval flags The flags. + */ +static inline uint16_t +rtems_rfs_inode_get_flags (rtems_rfs_inode_handle* handle) +{ + return rtems_rfs_read_u16 (&handle->node->flags); +} + +/** + * Set the flags. + * + * @param[in] handle is the inode handle. + * @param[in] flags are the flags. + */ +static inline void +rtems_rfs_inode_set_flags (rtems_rfs_inode_handle* handle, uint16_t flags) +{ + rtems_rfs_write_u16 (&handle->node->flags, flags); + rtems_rfs_buffer_mark_dirty (&handle->buffer); +} + +/** + * Get the mode. + * + * @param[in] handle is the inode handle. + * + * @retval mode The mode. + */ +static inline uint16_t +rtems_rfs_inode_get_mode (rtems_rfs_inode_handle* handle) +{ + return rtems_rfs_read_u16 (&handle->node->mode); +} + +/** + * Set the mode. + * + * @param[in] handle is the inode handle. + * @param[in] mode is the mode. + */ +static inline void +rtems_rfs_inode_set_mode (rtems_rfs_inode_handle* handle, uint16_t mode) +{ + rtems_rfs_write_u16 (&handle->node->mode, mode); + rtems_rfs_buffer_mark_dirty (&handle->buffer); +} + +/** + * Get the user id. + * + * @param[in] handle is the inode handle. + * + * @retval uid The used id. + */ +static inline uint16_t +rtems_rfs_inode_get_uid (rtems_rfs_inode_handle* handle) +{ + return rtems_rfs_read_u32 (&handle->node->owner) & 0xffff; +} + +/** + * Get the group id. + * + * @param[in] handle is the inode handle. + * + * @retval gid The grpup id. + */ +static inline uint16_t +rtems_rfs_inode_get_gid (rtems_rfs_inode_handle* handle) +{ + return (rtems_rfs_read_u32 (&handle->node->owner) >> 16) & 0xffff; +} + +/** + * Set the user id and group id. + * + * @param[in] handle is the inode handle. + * @param[in] uid is the user id (uid). + * @param[in] gid is the group id (gid). + */ +static inline void +rtems_rfs_inode_set_uid_gid (rtems_rfs_inode_handle* handle, + uint16_t uid, uint16_t gid) +{ + rtems_rfs_write_u32 (&handle->node->owner, (((uint32_t) gid) << 16) | uid); + rtems_rfs_buffer_mark_dirty (&handle->buffer); +} + +/** + * Get the block offset. + * + * @param[in] handle is the inode handle. + * + * @retval offset The block offset. + */ +static inline uint16_t +rtems_rfs_inode_get_block_offset (rtems_rfs_inode_handle* handle) +{ + return rtems_rfs_read_u16 (&handle->node->block_offset); +} + +/** + * Set the block offset. + * + * @param[in] handle is the inode handle. + * @param[in] block_count is the block offset. + */ +static inline void +rtems_rfs_inode_set_block_offset (rtems_rfs_inode_handle* handle, + uint16_t block_offset) +{ + rtems_rfs_write_u16 (&handle->node->block_offset, block_offset); + rtems_rfs_buffer_mark_dirty (&handle->buffer); +} + +/** + * Get the block count. + * + * @param[in] handle is the inode handle. + * + * @retval count The block count. + */ +static inline uint32_t +rtems_rfs_inode_get_block_count (rtems_rfs_inode_handle* handle) +{ + return rtems_rfs_read_u32 (&handle->node->block_count); +} + +/** + * Set the block count. + * + * @param[in] handle is the inode handle. + * @param[in] block_count is the block count. + */ +static inline void +rtems_rfs_inode_set_block_count (rtems_rfs_inode_handle* handle, uint32_t block_count) +{ + rtems_rfs_write_u32 (&handle->node->block_count, block_count); + rtems_rfs_buffer_mark_dirty (&handle->buffer); +} + +/** + * Get the atime. + * + * @param[in] handle is the inode handle. + * + * @retval atime The atime. + */ +static inline rtems_rfs_time +rtems_rfs_inode_get_atime (rtems_rfs_inode_handle* handle) +{ + return rtems_rfs_read_u32 (&handle->node->atime); +} + +/** + * Set the atime. + * + * @param[in] handle is the inode handle. + * @param[in] atime The atime. + */ +static inline void +rtems_rfs_inode_set_atime (rtems_rfs_inode_handle* handle, + rtems_rfs_time atime) +{ + rtems_rfs_write_u32 (&handle->node->atime, atime); + rtems_rfs_buffer_mark_dirty (&handle->buffer); +} + +/** + * Get the mtime. + * + * @param[in] handle is the inode handle. + * + * @retval mtime The mtime. + */ +static inline rtems_rfs_time +rtems_rfs_inode_get_mtime (rtems_rfs_inode_handle* handle) +{ + return rtems_rfs_read_u32 (&handle->node->mtime); +} + +/** + * Set the mtime. + * + * @param[in] handle is the inode handle. + * @param[in] mtime The mtime. + */ +static inline void +rtems_rfs_inode_set_mtime (rtems_rfs_inode_handle* handle, + rtems_rfs_time mtime) +{ + rtems_rfs_write_u32 (&handle->node->mtime, mtime); + rtems_rfs_buffer_mark_dirty (&handle->buffer); +} + +/** + * Get the ctime. + * + * @param[in] handle is the inode handle. + * + * @retval ctime The ctime. + */ +static inline rtems_rfs_time +rtems_rfs_inode_get_ctime (rtems_rfs_inode_handle* handle) +{ + return rtems_rfs_read_u32 (&handle->node->ctime); +} + +/** + * Set the ctime. + * + * @param[in] handle is the inode handle. + * @param[in] ctime The ctime. + */ +static inline void +rtems_rfs_inode_set_ctime (rtems_rfs_inode_handle* handle, + rtems_rfs_time ctime) +{ + rtems_rfs_write_u32 (&handle->node->ctime, ctime); + rtems_rfs_buffer_mark_dirty (&handle->buffer); +} + +/** + * Get the block number. + * + * @param[in] handle is the inode handle. + * @param[in] block is the block number to return. + * + * @retval block The block number. + */ +static inline uint32_t +rtems_rfs_inode_get_block (rtems_rfs_inode_handle* handle, int block) +{ + return rtems_rfs_read_u32 (&handle->node->data.blocks[block]); +} + +/** + * Set the block number for a given block index. + * + * @param[in] handle is the inode handle. + * @param[in] block is the block index. + * @param[in] bno is the block number. + */ +static inline void +rtems_rfs_inode_set_block (rtems_rfs_inode_handle* handle, int block, uint32_t bno) +{ + rtems_rfs_write_u32 (&handle->node->data.blocks[block], bno); + rtems_rfs_buffer_mark_dirty (&handle->buffer); +} + +/** + * Get the last map block from the inode. + * + * @param[in] handle is the inode handle. + * + * @retval block The last map block number. + */ +static inline uint32_t +rtems_rfs_inode_get_last_map_block (rtems_rfs_inode_handle* handle) +{ + return rtems_rfs_read_u32 (&handle->node->last_map_block); +} + +/** + * Set the last map block. + * + * @param[in] handle is the inode handle. + * @param[in] block_count is last map block number. + */ +static inline void +rtems_rfs_inode_set_last_map_block (rtems_rfs_inode_handle* handle, uint32_t last_map_block) +{ + rtems_rfs_write_u32 (&handle->node->last_map_block, last_map_block); + rtems_rfs_buffer_mark_dirty (&handle->buffer); +} + +/** + * Get the last data block from the inode. + * + * @param[in] handle is the inode handle. + * + * @retval block The last data block number. + * + */ +static inline uint32_t +rtems_rfs_inode_get_last_data_block (rtems_rfs_inode_handle* handle) +{ + return rtems_rfs_read_u32 (&handle->node->last_data_block); +} + +/** + * Set the last data block. + * + * @param[in] handle is the inode handle. + * @param[in] block_count is the last data block number. + */ +static inline void +rtems_rfs_inode_set_last_data_block (rtems_rfs_inode_handle* handle, uint32_t last_data_block) +{ + rtems_rfs_write_u32 (&handle->node->last_data_block, last_data_block); + rtems_rfs_buffer_mark_dirty (&handle->buffer); +} + +/** + * Allocate an inode number and return it. + * + * @param[in] fs is the file system data. + * @param[out] ino will contain the ino. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_inode_alloc (rtems_rfs_file_system* fs, + rtems_rfs_bitmap_bit goal, + rtems_rfs_ino* ino); + +/** + * Free an inode. + * + * @param[in] fs is the file system data. + * @param[in] ino is the ino too free. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_inode_free (rtems_rfs_file_system* fs, + rtems_rfs_ino ino); + +/** + * Open the inode handle. This reads the inode into the buffer and sets the + * data pointer. All data is in media byte order and needs to be accessed via + * the supporting calls. + * + * @param[in] fs is the file system. + * @param[in] ino is the inode number. + * @param[in] handle is the handle to the inode we are opening. + * @param[in] load If true load the inode into memory from the media. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_inode_open (rtems_rfs_file_system* fs, + rtems_rfs_ino ino, + rtems_rfs_inode_handle* handle, + bool load); + +/** + * The close inode handle. All opened inodes need to be closed. + * + * @param[in] fs is the file system. + * @param[in] handle is the handle to close. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_inode_close (rtems_rfs_file_system* fs, + rtems_rfs_inode_handle* handle); + +/** + * Load the inode into memory. + * + * @param[in] fs is the file system. + * @param[in] handle is the inode handle to load. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_inode_load (rtems_rfs_file_system* fs, + rtems_rfs_inode_handle* handle); + +/** + * Unload the inode from memory. + * + * @param[in] fs is the file system. + * @param[in] handle is the inode handle to unload. + * @param[in] update_ctime Update the ctime field of the inode. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_inode_unload (rtems_rfs_file_system* fs, + rtems_rfs_inode_handle* handle, + bool update_ctime); + +/** + * Create an inode allocating, initialising and adding an entry to the parent + * directory. + * + * @param[in] fs is the file system data. + * @param[in] parent is the parent inode number to add the directory entry to. + * @param[in] name is a pointer to the name of the directory entryinode + * to create. + * + */ +int rtems_rfs_inode_create (rtems_rfs_file_system* fs, + rtems_rfs_ino parent, + const char* name, + size_t length, + uint16_t mode, + uint16_t links, + uid_t uid, + gid_t gid, + rtems_rfs_ino* ino); + +/** + * Delete the inode eraseing it and release the buffer to commit the write. You + * need to load the inode again if you wish to use it again. + * + * @param[in] fs is the file system. + * @param[in] handle is the inode handle to erase. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_inode_delete (rtems_rfs_file_system* fs, + rtems_rfs_inode_handle* handle); + +/** + * Initialise a new inode. + * + * @param[in] handle is the inode handle to initialise. + * @param[in] links are the number of links to the inode. + * @param[in] mode is the inode mode. + * @param[in] uid is the user id. + * @param[in] gid is the group id. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_inode_initialise (rtems_rfs_inode_handle* handle, + uint16_t links, + uint16_t mode, + uid_t uid, + gid_t gid); + +/** + * Time stamp the inode with the current time. The ctime field is hanlded + * automatically. + * + * @param[in] handle is the inode handle. + * @param[in] atime Update the atime field. + * @param[in] mtime UPdate the mtime field. + * + * @retval 0 Successful operation. + * @retval ENXIO No inode is loaded. + * @retval error_code An error occurred. + */ +int rtems_rfs_inode_time_stamp_now (rtems_rfs_inode_handle* handle, + bool atime, + bool mtime); + +/** + * Calculate the size of data attached to the inode. + * + * @param[in] fs is the file system data. + * @param[in] handle is the inode handle. + * + * @retval size The data size in bytes in the block map attched to the inode. + */ +rtems_rfs_pos rtems_rfs_inode_get_size (rtems_rfs_file_system* fs, + rtems_rfs_inode_handle* handle); + +#endif + diff --git a/cpukit/include/rtems/rfs/rtems-rfs-link.h b/cpukit/include/rtems/rfs/rtems-rfs-link.h new file mode 100644 index 0000000000..d30814aaff --- /dev/null +++ b/cpukit/include/rtems/rfs/rtems-rfs-link.h @@ -0,0 +1,124 @@ +/** + * @file + * + * @brief RTEMS File System Link Support + * + * @ingroup rtems_rfs + * + * RTEMS File System Link Support + * + * This file provides the link support functions. + */ + +/* + * COPYRIGHT (c) 2010 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + + +#if !defined (_RTEMS_RFS_LINK_H_) +#define _RTEMS_RFS_LINK_H_ + +#include + +#include +#include + +/** + * Directory unlink modes. + */ +typedef enum rtems_rfs_unlink_dir_e +{ + rtems_rfs_unlink_dir_denied, /**< Not allowed to unlink a directory. */ + rtems_rfs_unlink_dir_if_empty, /**< Unlink if the directory is empty. */ + rtems_rfs_unlink_dir_allowed /**< Unlinking of directories is allowed. */ +} rtems_rfs_unlink_dir; + +/** + * Create a link. Do not link directories unless renaming or you will create + * loops in the file system. + * + * @param[in] fs is the file system. + * @param[in] name is a pointer to the name of the link. + * @param[in] length is the length of the name. + * @param[in] parent is the inode number of the parent directory. + * @param[in] target is the inode of the target. + * @param[in] link_dir If true directories can be linked. Useful when + * renaming. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_link (rtems_rfs_file_system* fs, + const char* name, + int length, + rtems_rfs_ino parent, + rtems_rfs_ino target, + bool link_dir); + +/** + * Unlink the node from the parent directory. A directory offset for the + * target entry is required because links cause a number of inode numbers to + * appear in a single directory so scanning does not work. + * + * @param[in] fs is the file system. + * @param[in] parent is the inode number of the parent directory. + * @param[in] target is the inode of the target. + * @param[in] doff is the parent directory entry offset for the target entry. + * @param[in] dir_mode is the directory unlink mode. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_unlink (rtems_rfs_file_system* fs, + rtems_rfs_ino parent, + rtems_rfs_ino target, + uint32_t doff, + rtems_rfs_unlink_dir dir_mode); + +/** + * Symbolic link is an inode that has a path attached. + * + * @param[in] fs is the file system data. + * @param[in] name is a pointer to the name of the node. + * @param[in] length is the length of the name of the node. + * @param[in] link is a pointer to the link path attached to the + * symlink inode. + * @param[in] link_length is the length of the link path. + * @param[in] parent is the parent inode number. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_symlink (rtems_rfs_file_system* fs, + const char* name, + int length, + const char* link, + int link_length, + uid_t uid, + gid_t gid, + rtems_rfs_ino parent); + +/** + * Read a symbolic link into the provided buffer returning the link of link + * name. + * + * @param[in] fs is the file system data. + * @param[in] link is the link inode number to read. + * @param[in] path is a pointer to the buffer to write the link path into. + * @param[in] size is the size of the buffer. + * @param[out] length will contain the length of the link path. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_rfs_symlink_read (rtems_rfs_file_system* fs, + rtems_rfs_ino link, + char* path, + size_t size, + size_t* length); + +#endif diff --git a/cpukit/include/rtems/rfs/rtems-rfs-mutex.h b/cpukit/include/rtems/rfs/rtems-rfs-mutex.h new file mode 100644 index 0000000000..606fd53233 --- /dev/null +++ b/cpukit/include/rtems/rfs/rtems-rfs-mutex.h @@ -0,0 +1,116 @@ +/** + * @file + * + * @brief RTEMS File System Mutex + * + * @ingroup rtems_rfs + * + * RTEMS File System Mutex. + * + * It may be suprising we abstract this for the RTEMS file system but this code + * is designed to be run on host operating systems. + */ + +/* + * COPYRIGHT (c) 2010 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#if !defined (_RTEMS_RFS_MUTEX_H_) +#define _RTEMS_RFS_MUTEX_H_ + +#include + +#include + +#if __rtems__ +#include +#include +#endif + +/** + * RFS Mutex type. + */ +#if __rtems__ +typedef rtems_id rtems_rfs_mutex; +#else +typedef uint32_t rtems_rfs_mutex; /* place holder */ +#endif + +/** + * @brief Create the mutex. + * + * @param [in] mutex is pointer to the mutex handle returned to the caller. + * + * @retval 0 Successful operation. + * @retval EIO An error occurred. + * + */ +int rtems_rfs_mutex_create (rtems_rfs_mutex* mutex); + +/** + * @brief Destroy the mutex. + * + * @param[in] mutex Reference to the mutex handle returned to the caller. + * + * @retval 0 Successful operation. + * @retval EIO An error occurred. + */ +int rtems_rfs_mutex_destroy (rtems_rfs_mutex* mutex); + +/** + * @brief Lock the mutex. + * + * @param[in] mutex is a pointer to the mutex to lock. + * + * @retval 0 Successful operation. + * @retval EIO An error occurred. + */ +static inline int +rtems_rfs_mutex_lock (rtems_rfs_mutex* mutex) +{ +#if __rtems__ + rtems_status_code sc = rtems_semaphore_obtain (*mutex, RTEMS_WAIT, 0); + if (sc != RTEMS_SUCCESSFUL) + { +#if RTEMS_RFS_TRACE + if (rtems_rfs_trace (RTEMS_RFS_TRACE_MUTEX)) + printf ("rtems-rfs: mutex: obtain failed: %s\n", + rtems_status_text (sc)); +#endif + return EIO; + } +#endif + return 0; +} + +/** + * @brief Unlock the mutex. + * + * @param[in] mutex is a pointer to the mutex to unlock. + * + * @retval 0 Successful operation. + * @retval EIO An error occurred. + */ +static inline int +rtems_rfs_mutex_unlock (rtems_rfs_mutex* mutex) +{ +#if __rtems__ + rtems_status_code sc = rtems_semaphore_release (*mutex); + if (sc != RTEMS_SUCCESSFUL) + { +#if RTEMS_RFS_TRACE + if (rtems_rfs_trace (RTEMS_RFS_TRACE_MUTEX)) + printf ("rtems-rfs: mutex: release failed: %s\n", + rtems_status_text (sc)); +#endif + return EIO; + } +#endif + return 0; +} + +#endif diff --git a/cpukit/include/rtems/rfs/rtems-rfs-trace.h b/cpukit/include/rtems/rfs/rtems-rfs-trace.h new file mode 100644 index 0000000000..4d6d0c9ddb --- /dev/null +++ b/cpukit/include/rtems/rfs/rtems-rfs-trace.h @@ -0,0 +1,135 @@ +/** + * @file + * + * @brief Manages the Trace and Debugging Features of the + * RTEMS RFS File System + * + * @ingroup rtems_rfs + * + * RTEMS File Systems Trace manages the trace and debugging features of the + * RTEMS RFS file system. The design allows all tracing code and strings to be + * removed from the target code for small footprint systems. + */ + +/* + * COPYRIGHT (c) 2010 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + + +#if !defined (_RTEMS_RFS_TRACE_H_) +#define _RTEMS_RFS_TRACE_H_ + +#include +#include +#include +#include + +/** + * Is tracing enabled ? + */ +#if !defined (RTEMS_RFS_TRACE) +#define RTEMS_RFS_TRACE 1 +#endif + +/** + * The type of the mask. + */ +typedef uint64_t rtems_rfs_trace_mask; + +/** + * List of tracing bits for the various parts of the file system. + */ +#define RTEMS_RFS_TRACE_ALL (0xffffffffffffffffULL) +#define RTEMS_RFS_TRACE_OPEN (1ULL << 0) +#define RTEMS_RFS_TRACE_CLOSE (1ULL << 1) +#define RTEMS_RFS_TRACE_MUTEX (1ULL << 2) +#define RTEMS_RFS_TRACE_BUFFER_OPEN (1ULL << 3) +#define RTEMS_RFS_TRACE_BUFFER_CLOSE (1ULL << 4) +#define RTEMS_RFS_TRACE_BUFFER_SYNC (1ULL << 5) +#define RTEMS_RFS_TRACE_BUFFER_RELEASE (1ULL << 6) +#define RTEMS_RFS_TRACE_BUFFER_CHAINS (1ULL << 7) +#define RTEMS_RFS_TRACE_BUFFER_HANDLE_REQUEST (1ULL << 8) +#define RTEMS_RFS_TRACE_BUFFER_HANDLE_RELEASE (1ULL << 9) +#define RTEMS_RFS_TRACE_BUFFER_SETBLKSIZE (1ULL << 10) +#define RTEMS_RFS_TRACE_BUFFERS_RELEASE (1ULL << 11) +#define RTEMS_RFS_TRACE_BLOCK_FIND (1ULL << 12) +#define RTEMS_RFS_TRACE_BLOCK_MAP_GROW (1ULL << 13) +#define RTEMS_RFS_TRACE_BLOCK_MAP_SHRINK (1ULL << 14) +#define RTEMS_RFS_TRACE_GROUP_OPEN (1ULL << 15) +#define RTEMS_RFS_TRACE_GROUP_CLOSE (1ULL << 16) +#define RTEMS_RFS_TRACE_GROUP_BITMAPS (1ULL << 17) +#define RTEMS_RFS_TRACE_INODE_OPEN (1ULL << 18) +#define RTEMS_RFS_TRACE_INODE_CLOSE (1ULL << 19) +#define RTEMS_RFS_TRACE_INODE_LOAD (1ULL << 20) +#define RTEMS_RFS_TRACE_INODE_UNLOAD (1ULL << 21) +#define RTEMS_RFS_TRACE_INODE_CREATE (1ULL << 22) +#define RTEMS_RFS_TRACE_INODE_DELETE (1ULL << 23) +#define RTEMS_RFS_TRACE_LINK (1ULL << 24) +#define RTEMS_RFS_TRACE_UNLINK (1ULL << 25) +#define RTEMS_RFS_TRACE_DIR_LOOKUP_INO (1ULL << 26) +#define RTEMS_RFS_TRACE_DIR_LOOKUP_INO_CHECK (1ULL << 27) +#define RTEMS_RFS_TRACE_DIR_LOOKUP_INO_FOUND (1ULL << 28) +#define RTEMS_RFS_TRACE_DIR_ADD_ENTRY (1ULL << 29) +#define RTEMS_RFS_TRACE_DIR_DEL_ENTRY (1ULL << 30) +#define RTEMS_RFS_TRACE_DIR_READ (1ULL << 31) +#define RTEMS_RFS_TRACE_DIR_EMPTY (1ULL << 32) +#define RTEMS_RFS_TRACE_SYMLINK (1ULL << 33) +#define RTEMS_RFS_TRACE_SYMLINK_READ (1ULL << 34) +#define RTEMS_RFS_TRACE_FILE_OPEN (1ULL << 35) +#define RTEMS_RFS_TRACE_FILE_CLOSE (1ULL << 36) +#define RTEMS_RFS_TRACE_FILE_IO (1ULL << 37) +#define RTEMS_RFS_TRACE_FILE_SET (1ULL << 38) + +/** + * Call to check if this part is bring traced. If RTEMS_RFS_TRACE is defined to + * 0 the code is dead code elminiated when built with -Os, -O2, or higher. + * + * @param[in] mask is the part of the API to trace. + * + * @retval true Tracing is active for the mask. + * @retval false Do not trace. + */ +#if RTEMS_RFS_TRACE +bool rtems_rfs_trace (rtems_rfs_trace_mask mask); +#else +#define rtems_rfs_trace(_m) (0) +#endif + +/** + * Set the mask. + * + * @param[in] mask are the mask bits to set. + * + * @retval mask The previous mask. + */ +#if RTEMS_RFS_TRACE +rtems_rfs_trace_mask rtems_rfs_trace_set_mask (rtems_rfs_trace_mask mask); +#else +#define rtems_rfs_trace_set_mask(_m) +#endif + +/** + * Clear the mask. + * + * @param[in] mask are the mask bits to clear. + * + * @retval mask The previous mask. + */ +#if RTEMS_RFS_TRACE +rtems_rfs_trace_mask rtems_rfs_trace_clear_mask (rtems_rfs_trace_mask mask); +#else +#define rtems_rfs_trace_clear_mask(_m) +#endif + +/** + * Add shell trace shell command. + */ +#if RTEMS_RFS_TRACE +int rtems_rfs_trace_shell_command (int argc, char *argv[]); +#endif + +#endif diff --git a/cpukit/include/rtems/ringbuf.h b/cpukit/include/rtems/ringbuf.h new file mode 100644 index 0000000000..c16a79d1ae --- /dev/null +++ b/cpukit/include/rtems/ringbuf.h @@ -0,0 +1,63 @@ +/** + * @file + * + * @brief Simple Ring Buffer Functionality + * + * This file provides simple ring buffer functionality. + */ + + +#ifndef _RTEMS_RINGBUF_H +#define _RTEMS_RINGBUF_H + +#include + +#ifndef RINGBUF_QUEUE_LENGTH +#define RINGBUF_QUEUE_LENGTH 128 +#endif + +typedef struct { + uint8_t buffer[RINGBUF_QUEUE_LENGTH]; + volatile int head; + volatile int tail; + rtems_interrupt_lock lock; +} Ring_buffer_t; + +#define Ring_buffer_Initialize( _buffer ) \ + do { \ + (_buffer)->head = (_buffer)->tail = 0; \ + rtems_interrupt_lock_initialize(&(_buffer)->lock, "ring buffer"); \ + } while ( 0 ) + +#define Ring_buffer_Destory( _buffer ) \ + do { \ + rtems_interrupt_lock_destroy(&(_buffer)->lock); \ + } while ( 0 ) + +#define Ring_buffer_Is_empty( _buffer ) \ + ( (_buffer)->head == (_buffer)->tail ) + +#define Ring_buffer_Is_full( _buffer ) \ + ( (_buffer)->head == ((_buffer)->tail + 1) % RINGBUF_QUEUE_LENGTH ) + +#define Ring_buffer_Add_character( _buffer, _ch ) \ + do { \ + rtems_interrupt_lock_context lock_context; \ + \ + rtems_interrupt_lock_acquire( &(_buffer)->lock, &lock_context ); \ + (_buffer)->tail = ((_buffer)->tail+1) % RINGBUF_QUEUE_LENGTH; \ + (_buffer)->buffer[ (_buffer)->tail ] = (_ch); \ + rtems_interrupt_lock_release( &(_buffer)->lock, &lock_context ); \ + } while ( 0 ) + +#define Ring_buffer_Remove_character( _buffer, _ch ) \ + do { \ + rtems_interrupt_lock_context lock_context; \ + \ + rtems_interrupt_lock_acquire( &(_buffer)->lock, &lock_context ); \ + (_buffer)->head = ((_buffer)->head+1) % RINGBUF_QUEUE_LENGTH; \ + (_ch) = (_buffer)->buffer[ (_buffer)->head ]; \ + rtems_interrupt_lock_release( &(_buffer)->lock, &lock_context ); \ + } while ( 0 ) + +#endif diff --git a/cpukit/include/rtems/rtems-debugger.h b/cpukit/include/rtems/rtems-debugger.h new file mode 100644 index 0000000000..1fc8b3d522 --- /dev/null +++ b/cpukit/include/rtems/rtems-debugger.h @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2016 Chris Johns . All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Debugger for RTEMS. + */ + +#ifndef _RTEMS_DEBUGGER_h +#define _RTEMS_DEBUGGER_h + +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * Timeout period for an ack + */ +#define RTEMS_DEBUGGER_TIMEOUT (3) + +/** + * Start the Debugger. + */ +extern int rtems_debugger_start(const char* remote, + const char* device, + int timeout, + rtems_task_priority priority, + const rtems_printer* printer); + +/** + * Stop the Debugger. + */ +extern int rtems_debugger_stop(void); + +/** + * Is the Debugger running?. + */ +extern bool rtems_debugger_running(void); + +/** + * Verbose control. + */ +extern void rtems_debugger_set_verbose(bool on); + +/** + * Control remote debug printing. + */ +extern int rtems_debugger_remote_debug(bool state); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif diff --git a/cpukit/include/rtems/rtems-fdt-shell.h b/cpukit/include/rtems/rtems-fdt-shell.h new file mode 100644 index 0000000000..74e9a44aaf --- /dev/null +++ b/cpukit/include/rtems/rtems-fdt-shell.h @@ -0,0 +1,42 @@ +/* + * COPYRIGHT (c) 2013-2017 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ +/** + * @file + * + * @ingroup rtems_fdt + * + * @brief RTEMS Flattened Device Tree Shell Command + * + * Support for loading, managing and accessing FDT blobs in RTEMS. + */ + +#if !defined (_RTEMS_FDT_SHELL_H_) +#define _RTEMS_FDT_SHELL_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * Add a shell command to access memory and registers associated with the DTF. + */ +void rtems_fdt_add_shell_command (void); + +/** + * Get a pointer to the handle. You can use this to load files or register + * blobs and have the shell command access them. + */ +rtems_fdt_handle* rtems_fdt_get_shell_handle (void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/cpukit/include/rtems/rtems-fdt.h b/cpukit/include/rtems/rtems-fdt.h new file mode 100644 index 0000000000..ebc222e4c9 --- /dev/null +++ b/cpukit/include/rtems/rtems-fdt.h @@ -0,0 +1,621 @@ +/* + * COPYRIGHT (c) 2013-2017 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + * Interface based on the libdft: + * libfdt - Flat Device Tree manipulation + * Copyright (C) 2006 David Gibson, IBM Corporation. + */ +/** + * @file + * + * @ingroup rtems_fdt + * + * @brief RTEMS Flattened Device Tree + * + * Support for loading, managing and accessing FDT blobs in RTEMS. + */ + +#if !defined (_RTEMS_FDT_H_) +#define _RTEMS_FDT_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * A blob. + */ +struct rtems_fdt_blob; +typedef struct rtems_fdt_blob rtems_fdt_blob; + +/** + * A blob handle is a way to manage access to the FDT blobs. The blob is + * referenced via the handle to allow searches across loaded DTB's to return + * the referenced DTB. + */ +typedef struct +{ + rtems_fdt_blob* blob; /**< The blob the handle references. */ +} rtems_fdt_handle; + +/* + * The following are mappings to the standard FDT calls. + */ + +/** + * RTEMS_FDT_ERR_NOTFOUND: The requested node or property does not exist + */ +#define RTEMS_FDT_ERR_NOTFOUND 1 +/** + * RTEMS_FDT_ERR_EXISTS: Attemped to create a node or property which already + * exists */ +#define RTEMS_FDT_ERR_EXISTS 2 +/** + * RTEMS_FDT_ERR_NOSPACE: Operation needed to expand the device tree, but its + * buffer did not have sufficient space to contain the expanded tree. Use + * rtems_fdt_open_into() to move the device tree to a buffer with more space. + */ +#define RTEMS_FDT_ERR_NOSPACE 3 + +/* Error codes: codes for bad parameters */ +/** + * RTEMS_FDT_ERR_BADOFFSET: Function was passed a structure block offset which + * is out-of-bounds, or which points to an unsuitable part of the structure for + * the operation. + */ +#define RTEMS_FDT_ERR_BADOFFSET 4 +/** + * RTEMS_FDT_ERR_BADPATH: Function was passed a badly formatted path + * (e.g. missing a leading / for a function which requires an absolute path) +*/ +#define RTEMS_FDT_ERR_BADPATH 5 +/** + * RTEMS_FDT_ERR_BADPHANDLE: Function was passed an invalid phandle value. + * phandle values of 0 and -1 are not permitted. + */ +#define RTEMS_FDT_ERR_BADPHANDLE 6 +/** + * RTEMS_FDT_ERR_BADSTATE: Function was passed an incomplete device tree + * created by the sequential-write functions, which is not sufficiently + * complete for the requested operation. + */ +#define RTEMS_FDT_ERR_BADSTATE 7 + +/* Error codes: codes for bad device tree blobs */ + +/** + * RTEMS_FDT_ERR_TRUNCATED: Structure block of the given device tree ends + * without an RTEMS_FDT_END tag. + */ +#define RTEMS_FDT_ERR_TRUNCATED 8 +/** + * RTEMS_FDT_ERR_BADMAGIC: Given "device tree" appears not to be a device tree + * at all - it is missing the flattened device tree magic number. + */ +#define RTEMS_FDT_ERR_BADMAGIC 9 +/** RTEMS_FDT_ERR_BADVERSION: Given device tree has a version which can't be + * handled by the requested operation. For read-write functions, this may mean + * that rtems_fdt_open_into() is required to convert the tree to the expected + * version. + */ +#define RTEMS_FDT_ERR_BADVERSION 10 +/** + * RTEMS_FDT_ERR_BADSTRUCTURE: Given device tree has a corrupt structure block + * or other serious error (e.g. misnested nodes, or subnodes preceding + * properties). + */ +#define RTEMS_FDT_ERR_BADSTRUCTURE 11 +/** + * RTEMS_FDT_ERR_BADLAYOUT: For read-write functions, the given device tree has + * it's sub-blocks in an order that the function can't handle (memory reserve + * map, then structure, then strings). Use rtems_fdt_open_into() to reorganize + * the tree into a form suitable for the read-write operations. + */ +#define RTEMS_FDT_ERR_BADLAYOUT 12 +/** + * "Can't happen" error indicating a bug in libfdt + */ +#define RTEMS_FDT_ERR_INTERNAL 13 + +/* RTEMS error codes. */ + +/** + * Invalid handle. + */ +#define RTEMS_FDT_ERR_INVALID_HANDLE 100 +/** + * No memory. + */ +#define RTEMS_FDT_ERR_NO_MEMORY 101 +/** + * File not found. + */ +#define RTEMS_FDT_ERR_NOT_FOUND 102 +/** + * Cannot read the DTB into memory. + */ +#define RTEMS_FDT_ERR_READ_FAIL 103 +/** + * The blob cannot be unloaded as it is referenced. + */ +#define RTEMS_FDT_ERR_REFERENCED 104 + +#define RTEMS_FDT_ERR_RTEMS_MIN 100 +#define RTEMS_FDT_ERR_MAX 104 + +/** + * Initialise a handle to a default state. + * + * @param handle The handle to initialise. + */ +void rtems_fdt_init_handle (rtems_fdt_handle* handle); + +/** + * Duplicate a handle. The copy must be released. + * + * @param from Duplicate from this handle. + * @param to Duplicate to this handle. + */ +void rtems_fdt_dup_handle (rtems_fdt_handle* from, rtems_fdt_handle* to); + +/** + * Release a blob from a handle and clear it. + * + * @param handle The handle to check. + */ +void rtems_fdt_release_handle (rtems_fdt_handle* handle); + +/** + * Check if a handle had a valid blob assigned. + * + * @param handle The handle to check. + * @retval true The handle has a valid blob. + * @retval false The handle does not have a valid blob. + */ +bool rtems_fdt_valid_handle (const rtems_fdt_handle* handle); + +/** + * Find a tree node by its full path looking across of loaded blobs.. Each path + * component may omit the unit address portion, but the results of this are + * undefined if any such path component is ambiguous (that is if there are + * multiple nodes at the relevant level matching the given component, + * differentiated only by unit address). + * + * If the handle points to a valid blob it is release and the search starts + * from the first blob. + * + * @param handle The FDT handle assigned to the blob if found else left invalid. + * @param path Full path of the node to locate. + * @param int If less than 0 an error code else the node offset is returned. + */ +int rtems_fdt_find_path_offset (rtems_fdt_handle* handle, const char* path); + +/** + * Load a device tree blob or DTB file into memory and register it on the chain + * of blobs. + * + * @param filename The name of the blob file to load. + * @param handle The handle returns the reference to the blob once load. + * @return int If less than 0 it is an error code else it is the blob descriptor. + */ +int rtems_fdt_load (const char* const filename, rtems_fdt_handle* handle); + +/** + * Register a device tree blob or DTB on to the chain of blobs. + * + * @param blob_desc A pointer to the blob. + * @param handle The handle returns the reference to the blob once load. + * @return int If less than 0 it is an error code else it is the blob descriptor. + */ +int rtems_fdt_register (const void* blob, rtems_fdt_handle* handle); + +/** + * Unload a device tree blob or DTB file and release any memory allocated when + * loading. The blob is removed from the list of registered. + * + * @param blob_desc A valid blob descriptor. + * @return int If less than 0 it is an error code else 0 is return on success. + */ +int rtems_fdt_unload (rtems_fdt_handle* handle); + +/** + * Returns the number of entries in the device tree blob's memory + * reservation map. This does not include the terminating 0,0 entry + * or any other (0,0) entries reserved for expansion. + * + * @param blob_desc A valid blob descriptor. + * @return int The number of entries. + */ +int rtems_fdt_num_mem_rsv (rtems_fdt_handle* handle); + +/** + * Retrieve one memory reserve map entry. On success, *address and *size will + * contain the address and size of the n-th reserve map entry from the device + * tree blob, in native-endian format. + * + * @param blob_desc A valid blob descriptor. + * @param address Pointer to 64-bit variables to hold the addresses. + * @param size Pointer to 64-bit variables to hold the size. + * @return int If less than 0 it is an error code else 0 is returned on + * success. + */ +int rtems_fdt_get_mem_rsv (rtems_fdt_handle* handle, + int n, + uint64_t* address, + uint64_t* size); + +/** + * Find a subnode based on substring. Identical to rtems_fdt_subnode_offset(), + * but only examine the first namelen characters of name for matching the + * subnode name. This is useful for finding subnodes based on a portion of a + * larger string, such as a full path. + * + * @param blob_desc A valid blob descriptor. + * @param arentoffset Structure block offset of a node + * @param name Name of the subnode to locate. + * @param namelen Number of characters of name to consider. + * @return int If less than 0 it is an error code else the node offset is + * returned. + */ +int rtems_fdt_subnode_offset_namelen (rtems_fdt_handle* handle, + int parentoffset, + const char* const name, + int namelen); + +/** + * Find a subnode of a given node at structure block offset parentoffset with + * the given name. The name may include a unit address, in which case + * rtems_fdt_subnode_offset() will find the subnode with that unit address, or + * the unit address may be omitted, in which case rtems_fdt_subnode_offset() + * will find an arbitrary subnode whose name excluding unit address matches the + * given name. + * + * @param blob_desc A valid blob descriptor. + * @param parentoffset Structure block offset of a node. + * @param name The name of the subnode to locate. + * @return int If less than 0 it is an error code else the subnode offset is + * returned. + */ +int rtems_fdt_subnode_offset (rtems_fdt_handle* handle, + int parentoffset, + const char* const name); + +/** + * Find a tree node by its full path. Each path component may omit the unit + * address portion, but the results of this are undefined if any such path + * component is ambiguous (that is if there are multiple nodes at the relevant + * level matching the given component, differentiated only by unit address). + * + * @param handle The FDT handle to the current blob. + * @param path Full path of the node to locate. + * @param int If less than 0 an error code else the node offset is returned. + */ +int rtems_fdt_path_offset (rtems_fdt_handle* handle, const char* path); + +/** + * Retrieve the name of a given node (including unit address) of the device + * tree node at structure block offset @nodeoffset. If @length is non-NULL, + * the length of this name is also returned, in the integer pointed to by + * @length. + * + * @param handle The FDT handle to the current blob. + * @param nodeoffset Structure block offset of the starting node. + * @param length Pointer to an integer variable (will be overwritten) or NULL. + * @return const char* The node's name on success or NULL on error. The length + * if non-NULL will hold the error code. + */ +const char* rtems_fdt_get_name (rtems_fdt_handle* handle, + int nodeoffset, + int* length); + +/** + * Get property value based on substring. Identical to rtems_fdt_getprop(), but + * only examine the first namelen characters of name for matching the property + * name. + * + * @param handle The FDT handle to the current blob. + * @param nodeoffset Offset of the node whose property to find + * @param name The name of the property to find + * @param namelen The number of characters of name to consider + * @param length A pointer to an integer variable (will be overwritten) or + * NULL. + * @return const void* The node's property on success or NULL on error. The + * length if non-NULL will hold the error code. + */ +const void *rtems_fdt_getprop_namelen (rtems_fdt_handle* handle, + int nodeoffset, + const char* const name, + int namelen, + int* length); + +/** + * Retrieve the value of a given property. Retrieves a pointer to the value of + * the property named 'name' of the node at offset nodeoffset (this will be a + * pointer to within the device blob itself, not a copy of the value). If lenp + * is non-NULL, the length of the property value is also returned, in the + * integer pointed to by @length. + * + * @param handle The FDT handle to the current blob. + * @param nodeoffset The offset of the node whose property to find. + * @param name The name of the property to find. + * @param length A pointer to an integer variable (will be overwritten) or + * NULL. + * @return const void* The node's property on success or NULL on error. The + * length if non-NULL will hold the error code. + */ +const void *rtems_fdt_getprop (rtems_fdt_handle* handle, + int nodeoffset, + const char* const name, + int* length); + +/** + * Retrieve the phandle of a given of the device tree node at structure block + * offset nodeoffset. + * + * @param handle The FDT handle to the current blob. + * @oaram nodeoffset The structure block offset of the node. + * return uint32_t The phandle of the node at nodeoffset, on success (!= 0, != + * -1) 0, if the node has no phandle, or another error occurs. + */ +uint32_t rtems_fdt_get_phandle (rtems_fdt_handle* handle, int nodeoffset); + +/** + * Get alias based on substring. Identical to rtems_fdt_get_alias(), but only + * examine the first namelen characters of name for matching the alias name. + * + * @param handle The FDT handle to the current blob. + * @param name The name of the alias th look up. + * @param namelen The number of characters of name to consider. + * @return const char* The alias or NULL. + */ +const char *rtems_fdt_get_alias_namelen (rtems_fdt_handle* handle, + const char* const name, + int namelen); + +/** + * Retreive the path referenced by a given alias. That is, the value of the + * property named 'name' in the node /aliases. + * + * @param handle The FDT handle to the current blob. + * @param name The name of the alias to look up. + * @return const char* A pointer to the expansion of the alias named 'name', of + * it exists NULL, if the given alias or the /aliases node + * does not exist + */ +const char* rtems_fdt_get_alias (rtems_fdt_handle* handle, const char* name); + +/** + * Determine the full path of a node. This function is expensive, as it must + * scan the device tree structure from the start to nodeoffset. It computes the + * full path of the node at offset nodeoffset, and records that path in the + * buffer at buf. + * + * @param handle The FDT handle to the current blob. + * @param nodeoffset The offset of the node whose path to find. + * @param buf A character buffer to contain the returned path (will be + * overwritten) + * @param buflen The size of the character buffer at buf. + * @return int 0 on success of an error code. + */ +int rtems_fdt_get_path (rtems_fdt_handle* handle, + int nodeoffset, + char* buf, + int buflen); + +/** + * Find a specific ancestor of a node at a specific depth from the root (where + * the root itself has depth 0, its immediate subnodes depth 1 and so forth). + * So rtems_fdt_supernode_atdepth_offset(blob, nodeoffset, 0, NULL); will + * always return 0, the offset of the root node. If the node at nodeoffset has + * depth D, then: + * rtems_fdt_supernode_atdepth_offset(blob, nodeoffset, D, NULL); + * will return nodeoffset itself. + * + * @param handle The FDT handle to the current blob. + * @param nodeoffset The offset of the node whose parent to find. + * @param supernodedepth The depth of the ancestor to find. + * @oaram nodedepth The pointer to an integer variable (will be overwritten) or + * NULL + * @return int If less than 0 an error else the node offset. + */ +int rtems_fdt_supernode_atdepth_offset (rtems_fdt_handle* handle, + int nodeoffset, + int supernodedepth, + int* nodedepth); + +/** + * Find the depth of a given node. The root node has depth 0, its immediate + * subnodes depth 1 and so forth. + * + * @note This function is expensive, as it must scan the device tree structure + * from the start to nodeoffset. + * + * @param handle The FDT handle to the current blob. + * @param nodeoffset The offset of the node whose parent to find. + * @return int If less than 0 an error else the node offset. + */ +int rtems_fdt_node_depth (rtems_fdt_handle* handle, int nodeoffset); + +/** + * Find the parent of a given node. This funciton locates the parent node of a + * given node (that is, it finds the offset of the node which contains the node + * at nodeoffset as a subnode). + * + * @note This function is expensive, as it must scan the device tree structure + * from the start to nodeoffset, *twice*. + * + * @param handle The FDT handle to the current blob. + * @param nodeoffset The offset of the node whose parent to find. + * @return int If less than 0 an error else the node offset. + */ +int rtems_fdt_parent_offset (rtems_fdt_handle* handle, int nodeoffset); + +/** + * Find nodes with a given property value. This funtion returns the offset of + * the first node after startoffset, which has a property named propname whose + * value is of length proplen and has value equal to propval; or if startoffset + * is -1, the very first such node in the tree. + * + * To iterate through all nodes matching the criterion, the following idiom can + * be used: + * offset = rtemsfdt_node_offset_by_prop_value(blob, -1, propname, + * propval, proplen); + * while (offset != -RTEMS_FDT_ERR_NOTFOUND) { + * // other code here + * offset = rtems_fdt_node_offset_by_prop_value(fdt, offset, propname, + * propval, proplen); + * } + * + * @note The -1 in the first call to the function, if 0 is used here + * instead, the function will never locate the root node, even if it + * matches the criterion. + * + * @param handle The FDT handle to the current blob. + * @param startoffset Only find nodes after this offset. + * @param propname The property name to check. + * @param propval The property value to search for. + * @param proplen The length of the value in propval. + * @return int The structure block offset of the located node (>= 0, + * >startoffset), on success and an error code is less + * than 0. + */ +int rtems_fdt_node_offset_by_prop_value (rtems_fdt_handle* handle, + int startoffset, + const char* const propname, + const void* propval, + int proplen); + +/** + * Find the node with a given phandle returning the offset of the node which + * has the given phandle value. If there is more than one node in the tree + * with the given phandle (an invalid tree), results are undefined. + * + * @param handle The FDT handle to the current blob. + * @param phandle The phandle value. + * @return int If less than 0 an error else the node offset. + */ +int rtems_fdt_node_offset_by_phandle (rtems_fdt_handle* handle, + uint32_t phandle); + +/** + * Check a node's compatible property returning 0 if the given node contains a + * 'compatible' property with the given string as one of its elements, it + * returns non-zero otherwise, or on error. + * + * @param handle The FDT handle to the current blob. + * @param nodeoffset The offset of a tree node. + * @param compatible The string to match against. + * @retval 0, if the node has a 'compatible' property listing the given string. + * @retval 1, if the node has a 'compatible' property, but it does not list the + * given string + */ +int rtems_fdt_node_check_compatible (rtems_fdt_handle* handle, + int nodeoffset, + const char* const compatible); + +/** + * Find nodes with a given 'compatible' value returning the offset of the first + * node after startoffset, which has a 'compatible' property which lists the + * given compatible string; or if startoffset is -1, the very first such node + * in the tree. + * + * To iterate through all nodes matching the criterion, the following idiom can + * be used: + * + * offset = rtems_fdt_node_offset_by_compatible(blob, -1, compatible); + * while (offset != -RTEMS_FDT_ERR_NOTFOUND) { + * // other code here + * offset = rtems_fdt_node_offset_by_compatible(blob, offset, compatible); + * } + * + * @note The -1 in the first call to the function, if 0 is used here instead, + * the function will never locate the root node, even if it matches the + * criterion. + * + * @param handle The FDT handle to the current blob. + * @param startoffset Only find nodes after this offset. + * @param compatible The 'compatible' string to match against. + * @return int If less than 0 an error else the node offset. + */ +int rtems_fdt_node_offset_by_compatible(rtems_fdt_handle* handle, + int startoffset, + const char* compatible); + +/** + * Traverse to the next node. + * + * @param handle The FDT handle to the current blob. + * @param offset The offset in the blob to start looking for the next node. + * @param depth Pointer to return the depth the node is. + * @return int If less than 0 an error else the node offset. + */ +int rtems_fdt_next_node (rtems_fdt_handle* handle, int offset, int* depth); + +/** + * Return an error string given an error value. + * + * @param errval The error value. + * @return const char* The error string. + */ +const char* rtems_fdt_strerror (int errval); + +/** + * Return a property given a path. + */ +int rtems_fdt_prop_value(const char* const path, + const char* const propname, + void* value, + size_t* size); + +/** + * Create a map given a path the property name and the names of the subnodes of + * the path. + */ +int rtems_fdt_prop_map (const char* const path, + const char* const propname, + const char* const names[], + uint32_t* values, + size_t count); + +/* + * Get a value given a path and a property. + */ +int rtems_fdt_get_value (const char* const path, + const char* const property, + size_t size, + uint32_t* value); + +/** + * Get the number of entries in an FDT handle. + */ +int rtems_fdt_num_entries(rtems_fdt_handle* handle); + +/** + * Get the numbered entry name. Note that the id isn't the same as + * the offset - it's numbered 0, 1, 2 ... num_entries-1 + */ +const char *rtems_fdt_entry_name(rtems_fdt_handle* handle, int id); + +/** + * Get the numbered entry offset. Note that the id isn't the same as + * the offset - it's numbered 0, 1, 2 ... num_entries-1 + */ +int rtems_fdt_entry_offset(rtems_fdt_handle* handle, int id); + +/* + * Helper function to convert the void* property result to a 32bit unsigned int. + */ +uint32_t rtems_fdt_get_uint32 (const void* prop); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/cpukit/include/rtems/rtems-rfs-format.h b/cpukit/include/rtems/rtems-rfs-format.h new file mode 100644 index 0000000000..f65cce1789 --- /dev/null +++ b/cpukit/include/rtems/rtems-rfs-format.h @@ -0,0 +1,90 @@ +/** + * @file + * + * @ingroup rtems_rfs + * + * @brief RTEMS File System Format + * + * This function lets you format a disk in the RFS format. + */ + +/* + * COPYRIGHT (c) 2010 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#if !defined (_RTEMS_RFS_FORMAT_H_) +#define _RTEMS_RFS_FORMAT_H_ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/** + * RFS File System Configuration data used to format the file system. For + * default values leave the field set to 0. + */ +typedef struct _rtems_rfs_format_config +{ + /** + * The size of a block. + */ + size_t block_size; + + /** + * The number of blocks in a group. + */ + size_t group_blocks; + + /** + * The number of inodes in a group. + */ + size_t group_inodes; + + /** + * The percentage overhead allocated to inodes. + */ + int inode_overhead; + + /** + * The maximum length of a name. + */ + size_t max_name_length; + + /** + * Initialise the inode tables to all ones. + */ + bool initialise_inodes; + + /** + * Is the format verbose. + */ + bool verbose; + +} rtems_rfs_format_config; + +/** + * RFS Format command. + * + * @param[in] name is the device name to format. + * @param[in] config is a pointer to the configuration table. + * + * @retval -1 Error. See errno. + * @retval 0 No error. Format successful. + */ +int rtems_rfs_format (const char* name, const rtems_rfs_format_config* config); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/include/rtems/rtems-rfs-shell.h b/cpukit/include/rtems/rtems-rfs-shell.h new file mode 100644 index 0000000000..c2e1108a47 --- /dev/null +++ b/cpukit/include/rtems/rtems-rfs-shell.h @@ -0,0 +1,48 @@ +/** + * @file + * + * @ingroup rtems_rfs + * @brief RTEMS File Systems Shell Commands + * + * RTEMS File Systems Shell commands provide a CLI interface to support and + * development of the RFS file system. + */ + +/* + * COPYRIGHT (c) 2010 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#if !defined (_RTEMS_RFS_SHELL_H_) +#define _RTEMS_RFS_SHELL_H_ + +#include +#include +#include + +/** + * The shell command for the RFS debugger. + * + * @param[in] argc is the argument count. + * @param[in] argv is a pointer to the argument variables. + * + * @retval 0 Successful operation. + * @retval error_code An error occurred. + */ +int rtems_shell_debugrfs (int argc, char *argv[]); + +/** + * The shell command for formatting an RFS file system. + * + * @param[in] argc is the argument count. + * @param[in] argv is a pointer to the argument variables. + * + * @retval 0 Successful operation. + * @retval 1 An error occurred. + */ +int rtems_shell_rfs_format (int argc, char* argv[]); + +#endif diff --git a/cpukit/include/rtems/rtems-rfs.h b/cpukit/include/rtems/rtems-rfs.h new file mode 100644 index 0000000000..958f9a636b --- /dev/null +++ b/cpukit/include/rtems/rtems-rfs.h @@ -0,0 +1,38 @@ +/** + * @file + * + * @brief RFS File system Initialization + * @ingroup rtems_rfs + * + * RTEMS File System + * + */ + +/* + * COPYRIGHT (c) 2010 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#if !defined(RTEMS_RFS_DEFINED) +#define RTEMS_RFS_DEFINED + +#include +#include + +/** + * @defgroup rtems_rfs RTEMS File System Group Management + * + * @ingroup FileSystemTypesAndMount + */ +/**@{*/ + +/** + * Initialise the RFS File system. + */ +int rtems_rfs_rtems_initialise (rtems_filesystem_mount_table_entry_t *mt_entry, const void *data); + +/**@}*/ +#endif diff --git a/cpukit/include/rtems/rtems/asr.h b/cpukit/include/rtems/rtems/asr.h new file mode 100644 index 0000000000..edd5e2fe62 --- /dev/null +++ b/cpukit/include/rtems/rtems/asr.h @@ -0,0 +1,156 @@ +/** + * @file rtems/rtems/asr.h + * + * @defgroup ClassicASR ASR Support + * + * @ingroup ClassicRTEMS + * @brief Asynchronous Signal Handler + * + * This include file contains all the constants and structures associated + * with the Asynchronous Signal Handler. This Handler provides the low-level + * support required by the Signal Manager. + */ + +/* COPYRIGHT (c) 1989-2013. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_ASR_H +#define _RTEMS_RTEMS_ASR_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicASR ASR Support + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality related to the Classic API Signal + * Manager. + */ +/**@{*/ + +/** + * The following type defines the control block used to manage + * each signal set. + */ +typedef uint32_t rtems_signal_set; + +/** + * Return type for ASR Handler + */ +typedef void rtems_asr; + +/** + * The following type corresponds to the applications asynchronous + * signal processing routine. + */ +typedef rtems_asr ( *rtems_asr_entry )( + rtems_signal_set + ); + +/** + * The following defines the control structure used to manage + * signals. Each thread has a copy of this record. + */ +typedef struct { + /** This field indicates if are ASRs enabled currently. */ + bool is_enabled; + /** This field indicates if address of the signal handler function. */ + rtems_asr_entry handler; + /** This field indicates if the task mode the signal will run with. */ + Modes_Control mode_set; + /** This field indicates the signal set that is posted. */ + rtems_signal_set signals_posted; + /** This field indicates the signal set that is pending. */ + rtems_signal_set signals_pending; + /** This field indicates if nest level of signals being processed */ + uint32_t nest_level; +} ASR_Information; + +/* + * The following constants define the individual signals which may + * be used to compose a signal set. + */ + +/** This defines the bit in the signal set associated with signal 0. */ +#define RTEMS_SIGNAL_0 0x00000001 +/** This defines the bit in the signal set associated with signal 1. */ +#define RTEMS_SIGNAL_1 0x00000002 +/** This defines the bit in the signal set associated with signal 2. */ +#define RTEMS_SIGNAL_2 0x00000004 +/** This defines the bit in the signal set associated with signal 3. */ +#define RTEMS_SIGNAL_3 0x00000008 +/** This defines the bit in the signal set associated with signal 4. */ +#define RTEMS_SIGNAL_4 0x00000010 +/** This defines the bit in the signal set associated with signal 5. */ +#define RTEMS_SIGNAL_5 0x00000020 +/** This defines the bit in the signal set associated with signal 6. */ +#define RTEMS_SIGNAL_6 0x00000040 +/** This defines the bit in the signal set associated with signal 7. */ +#define RTEMS_SIGNAL_7 0x00000080 +/** This defines the bit in the signal set associated with signal 8. */ +#define RTEMS_SIGNAL_8 0x00000100 +/** This defines the bit in the signal set associated with signal 9. */ +#define RTEMS_SIGNAL_9 0x00000200 +/** This defines the bit in the signal set associated with signal 10. */ +#define RTEMS_SIGNAL_10 0x00000400 +/** This defines the bit in the signal set associated with signal 11. */ +#define RTEMS_SIGNAL_11 0x00000800 +/** This defines the bit in the signal set associated with signal 12. */ +#define RTEMS_SIGNAL_12 0x00001000 +/** This defines the bit in the signal set associated with signal 13. */ +#define RTEMS_SIGNAL_13 0x00002000 +/** This defines the bit in the signal set associated with signal 14. */ +#define RTEMS_SIGNAL_14 0x00004000 +/** This defines the bit in the signal set associated with signal 15. */ +#define RTEMS_SIGNAL_15 0x00008000 +/** This defines the bit in the signal set associated with signal 16. */ +#define RTEMS_SIGNAL_16 0x00010000 +/** This defines the bit in the signal set associated with signal 17. */ +#define RTEMS_SIGNAL_17 0x00020000 +/** This defines the bit in the signal set associated with signal 18. */ +#define RTEMS_SIGNAL_18 0x00040000 +/** This defines the bit in the signal set associated with signal 19. */ +#define RTEMS_SIGNAL_19 0x00080000 +/** This defines the bit in the signal set associated with signal 20. */ +#define RTEMS_SIGNAL_20 0x00100000 +/** This defines the bit in the signal set associated with signal 21. */ +#define RTEMS_SIGNAL_21 0x00200000 +/** This defines the bit in the signal set associated with signal 22. */ +#define RTEMS_SIGNAL_22 0x00400000 +/** This defines the bit in the signal set associated with signal 23. */ +#define RTEMS_SIGNAL_23 0x00800000 +/** This defines the bit in the signal set associated with signal 24. */ +#define RTEMS_SIGNAL_24 0x01000000 +/** This defines the bit in the signal set associated with signal 25. */ +#define RTEMS_SIGNAL_25 0x02000000 +/** This defines the bit in the signal set associated with signal 26. */ +#define RTEMS_SIGNAL_26 0x04000000 +/** This defines the bit in the signal set associated with signal 27. */ +#define RTEMS_SIGNAL_27 0x08000000 +/** This defines the bit in the signal set associated with signal 28. */ +#define RTEMS_SIGNAL_28 0x10000000 +/** This defines the bit in the signal set associated with signal 29. */ +#define RTEMS_SIGNAL_29 0x20000000 +/** This defines the bit in the signal set associated with signal 30. */ +#define RTEMS_SIGNAL_30 0x40000000 +/** This defines the bit in the signal set associated with signal 31. */ +#define RTEMS_SIGNAL_31 0x80000000 + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/asrimpl.h b/cpukit/include/rtems/rtems/asrimpl.h new file mode 100644 index 0000000000..141c34d4bb --- /dev/null +++ b/cpukit/include/rtems/rtems/asrimpl.h @@ -0,0 +1,99 @@ +/** + * @file + * + * @ingroup ClassicASRImpl + * + * @brief Classic ASR Implementation + */ + +/* COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_ASRIMPL_H +#define _RTEMS_RTEMS_ASRIMPL_H + +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicASRImpl Classic ASR Implementation + * + * @ingroup ClassicASR + * + * @{ + */ + +/** + * @brief ASR_Initialize + * + * This routine initializes the given RTEMS_ASR information record. + */ +RTEMS_INLINE_ROUTINE void _ASR_Initialize ( + ASR_Information *asr +) +{ + memset(asr, 0, sizeof(*asr)); +} + +/** + * @brief ASR_Is_null_handler + * + * This function returns TRUE if the given asr_handler is NULL and + * FALSE otherwise. + */ +RTEMS_INLINE_ROUTINE bool _ASR_Is_null_handler ( + rtems_asr_entry asr_handler +) +{ + return asr_handler == NULL; +} + +RTEMS_INLINE_ROUTINE rtems_signal_set _ASR_Swap_signals( ASR_Information *asr ) +{ + rtems_signal_set new_signals_posted; + + new_signals_posted = asr->signals_pending; + asr->signals_pending = asr->signals_posted; + asr->signals_posted = new_signals_posted; + + return new_signals_posted; +} + +RTEMS_INLINE_ROUTINE void _ASR_Post_signals( + rtems_signal_set signals, + rtems_signal_set *signal_set +) +{ + *signal_set |= signals; +} + +RTEMS_INLINE_ROUTINE rtems_signal_set _ASR_Get_posted_signals( + ASR_Information *asr +) +{ + rtems_signal_set signal_set; + + signal_set = asr->signals_posted; + asr->signals_posted = 0; + + return signal_set; +} + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/attr.h b/cpukit/include/rtems/rtems/attr.h new file mode 100644 index 0000000000..7e8fa4818a --- /dev/null +++ b/cpukit/include/rtems/rtems/attr.h @@ -0,0 +1,191 @@ +/** + * @file rtems/rtems/attr.h + * + * @defgroup ClassicAttributes Attributes + * + * @ingroup ClassicRTEMS + * @brief Object Attributes Handler + * + * This include file contains all information about the Object Attributes + * Handler. + */ + +/* COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_ATTR_H +#define _RTEMS_RTEMS_ATTR_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicAttributes Attributes + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality which defines and manages the + * set of Classic API object attributes. + */ +/**@{*/ + +/** + * This defines the type used to contain Classic API attributes. These + * are primarily used when creating objects. + */ +typedef uint32_t rtems_attribute; + +/** This is the default value for an attribute set. */ + +#define RTEMS_DEFAULT_ATTRIBUTES 0x00000000 + +/** + * This is the attribute constant to indicate local resource. + */ +#define RTEMS_LOCAL 0x00000000 + +/** + * This is the attribute constant to indicate global resource. + */ +#define RTEMS_GLOBAL 0x00000002 + +/** + * This is the attribute constant which reflects that blocking + * tasks will be managed using FIFO discipline. + */ +#define RTEMS_FIFO 0x00000000 + +/** + * This is the attribute constant which reflects that blocking + * tasks will be managed using task priority discipline. + */ +#define RTEMS_PRIORITY 0x00000004 + +/******************** RTEMS Task Specific Attributes *********************/ + +/** + * This attribute constant indicates that the task will not use the + * floating point hardware. If the architecture permits it, then + * the FPU will be disabled when the task is executing. + */ +#define RTEMS_NO_FLOATING_POINT 0x00000000 + +/** + * This attribute constant indicates that the task will use the + * floating point hardware. There will be a floating point + * context associated with this task. + */ +#define RTEMS_FLOATING_POINT 0x00000001 + +/***************** RTEMS Semaphore Specific Attributes ********************/ + +/** + * This is the mask for the attribute bits associated with the + * Classic API Semaphore Manager. + */ +#define RTEMS_SEMAPHORE_CLASS 0x00000030 + +/** + * This attribute constant indicates that the Classic API Semaphore + * instance created will be a counting semaphore. + */ +#define RTEMS_COUNTING_SEMAPHORE 0x00000000 + +/** + * This attribute constant indicates that the Classic API Semaphore + * instance created will be a proper binary semaphore or mutex. + */ +#define RTEMS_BINARY_SEMAPHORE 0x00000010 + +/** + * This attribute constant indicates that the Classic API Semaphore + * instance created will be a simple binary semaphore. + */ +#define RTEMS_SIMPLE_BINARY_SEMAPHORE 0x00000020 + +/** + * This attribute constant indicates that the Classic API Semaphore + * instance created will NOT use the Priority Inheritance Protocol. + */ +#define RTEMS_NO_INHERIT_PRIORITY 0x00000000 + +/** + * This attribute constant indicates that the Classic API Semaphore + * instance created will use the Priority Inheritance Protocol. + * + * @note The semaphore instance must be a binary semaphore. + */ +#define RTEMS_INHERIT_PRIORITY 0x00000040 + +/** + * This attribute constant indicates that the Classic API Semaphore + * instance created will NOT use the Priority Ceiling Protocol. + */ +#define RTEMS_NO_PRIORITY_CEILING 0x00000000 + +/** + * This attribute constant indicates that the Classic API Semaphore + * instance created will use the Priority Ceiling Protocol. + * + * @note The semaphore instance must be a binary semaphore. + */ +#define RTEMS_PRIORITY_CEILING 0x00000080 + +/** + * This attribute constant indicates that the Classic API Semaphore instance + * created will NOT use the Multiprocessor Resource Sharing Protocol. + */ +#define RTEMS_NO_MULTIPROCESSOR_RESOURCE_SHARING 0x00000000 + +/** + * This attribute constant indicates that the Classic API Semaphore instance + * created will use the Multiprocessor Resource Sharing Protocol. + * + * @note The semaphore instance must be a binary semaphore. + */ +#define RTEMS_MULTIPROCESSOR_RESOURCE_SHARING 0x00000100 + +/******************** RTEMS Barrier Specific Attributes ********************/ + +/** + * This attribute constant indicates that the Classic API Barrier + * instance created will use an automatic release protocol. + */ +#define RTEMS_BARRIER_AUTOMATIC_RELEASE 0x00000010 + +/** + * This attribute constant indicates that the Classic API Barrier + * instance created will use the manual release protocol. + */ +#define RTEMS_BARRIER_MANUAL_RELEASE 0x00000000 + +/**************** RTEMS Internal Task Specific Attributes ****************/ + +/** + * This attribute constant indicates that the task was created + * by the application using normal Classic API methods. + */ +#define RTEMS_APPLICATION_TASK 0x00000000 + +/** + * This attribute constant indicates that the task was created + * by RTEMS as a support task. + */ +#define RTEMS_SYSTEM_TASK 0x00008000 + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/attrimpl.h b/cpukit/include/rtems/rtems/attrimpl.h new file mode 100644 index 0000000000..bb8e5f8f58 --- /dev/null +++ b/cpukit/include/rtems/rtems/attrimpl.h @@ -0,0 +1,263 @@ +/** + * @file + * + * @ingroup ClassicAttributesImpl + * + * @brief Classic Attributes Implementation + */ + +/* + * COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_ATTR_INL +#define _RTEMS_RTEMS_ATTR_INL + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicAttributesImpl Classic Attributes Implementation + * + * @ingroup ClassicAttributes + * + * @{ + */ + +/****************** Forced Attributes in Configuration ****************/ + +/** + * This attribute constant indicates the attributes that are not + * supportable given the hardware configuration. + */ +#define ATTRIBUTES_NOT_SUPPORTED 0 + +/** + * This attribute constant indicates the attributes that are + * required given the hardware configuration. + */ +#if ( CPU_ALL_TASKS_ARE_FP == TRUE ) +#define ATTRIBUTES_REQUIRED RTEMS_FLOATING_POINT +#else +#define ATTRIBUTES_REQUIRED 0 +#endif + +/** + * @brief Sets the requested new_attributes in the attribute_set passed in. + * + * This function sets the requested new_attributes in the attribute_set + * passed in. The result is returned to the user. + */ +RTEMS_INLINE_ROUTINE rtems_attribute _Attributes_Set ( + rtems_attribute new_attributes, + rtems_attribute attribute_set +) +{ + return attribute_set | new_attributes; +} + +/** + * @brief Clears the requested new_attributes in the attribute_set + * passed in. + * + * This function clears the requested new_attributes in the attribute_set + * passed in. The result is returned to the user. + */ +RTEMS_INLINE_ROUTINE rtems_attribute _Attributes_Clear ( + rtems_attribute attribute_set, + rtems_attribute mask +) +{ + return attribute_set & ~mask; +} + +/** + * @brief Checks if the floating point attribute is + * enabled in the attribute_set. + * + * This function returns TRUE if the floating point attribute is + * enabled in the attribute_set and FALSE otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Attributes_Is_floating_point( + rtems_attribute attribute_set +) +{ + return ( attribute_set & RTEMS_FLOATING_POINT ) ? true : false; +} + +#if defined(RTEMS_MULTIPROCESSING) +/** + * @brief Checks if the global object attribute is enabled in + * the attribute_set. + * + * This function returns TRUE if the global object attribute is + * enabled in the attribute_set and FALSE otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Attributes_Is_global( + rtems_attribute attribute_set +) +{ + return ( attribute_set & RTEMS_GLOBAL ) ? true : false; +} +#endif + +/** + * @brief Checks if the priority attribute is enabled in the attribute_set. + * + * This function returns TRUE if the priority attribute is + * enabled in the attribute_set and FALSE otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Attributes_Is_priority( + rtems_attribute attribute_set +) +{ + return ( attribute_set & RTEMS_PRIORITY ) ? true : false; +} + +/** + * @brief Checks if the binary semaphore attribute is + * enabled in the attribute_set. + * + * This function returns TRUE if the binary semaphore attribute is + * enabled in the attribute_set and FALSE otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Attributes_Is_binary_semaphore( + rtems_attribute attribute_set +) +{ + return ((attribute_set & RTEMS_SEMAPHORE_CLASS) == RTEMS_BINARY_SEMAPHORE); +} + +/** + * @brief Checks if the simple binary semaphore attribute is + * enabled in the attribute_set + * + * This function returns TRUE if the simple binary semaphore attribute is + * enabled in the attribute_set and FALSE otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Attributes_Is_simple_binary_semaphore( + rtems_attribute attribute_set +) +{ + return + ((attribute_set & RTEMS_SEMAPHORE_CLASS) == RTEMS_SIMPLE_BINARY_SEMAPHORE); +} + +/** + * @brief Checks if the counting semaphore attribute is + * enabled in the attribute_set + * + * This function returns TRUE if the counting semaphore attribute is + * enabled in the attribute_set and FALSE otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Attributes_Is_counting_semaphore( + rtems_attribute attribute_set +) +{ + return ((attribute_set & RTEMS_SEMAPHORE_CLASS) == RTEMS_COUNTING_SEMAPHORE); +} + +/** + * @brief Checks if the priority inheritance attribute + * is enabled in the attribute_set + * + * This function returns TRUE if the priority inheritance attribute + * is enabled in the attribute_set and FALSE otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Attributes_Is_inherit_priority( + rtems_attribute attribute_set +) +{ + return ( attribute_set & RTEMS_INHERIT_PRIORITY ) ? true : false; +} + +/** + * @brief Returns true if the attribute set has at most one protocol, and false + * otherwise. + * + * The protocols are RTEMS_INHERIT_PRIORITY, RTEMS_PRIORITY_CEILING and + * RTEMS_MULTIPROCESSOR_RESOURCE_SHARING. + */ +RTEMS_INLINE_ROUTINE bool _Attributes_Has_at_most_one_protocol( + rtems_attribute attribute_set +) +{ + attribute_set &= RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY_CEILING + | RTEMS_MULTIPROCESSOR_RESOURCE_SHARING; + + return ( attribute_set & ( attribute_set - 1 ) ) == 0; +} + +/** + * @brief Checks if the priority ceiling attribute + * is enabled in the attribute_set + * + * This function returns TRUE if the priority ceiling attribute + * is enabled in the attribute_set and FALSE otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Attributes_Is_priority_ceiling( + rtems_attribute attribute_set +) +{ + return ( attribute_set & RTEMS_PRIORITY_CEILING ) ? true : false; +} + +/** + * @brief Checks if the Multiprocessor Resource Sharing Protocol attribute + * is enabled in the attribute_set + * + * This function returns TRUE if the Multiprocessor Resource Sharing Protocol + * attribute is enabled in the attribute_set and FALSE otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Attributes_Is_multiprocessor_resource_sharing( + rtems_attribute attribute_set +) +{ + return ( attribute_set & RTEMS_MULTIPROCESSOR_RESOURCE_SHARING ) != 0; +} + +/** + * @brief Checks if the barrier automatic release + * attribute is enabled in the attribute_set + * + * This function returns TRUE if the barrier automatic release + * attribute is enabled in the attribute_set and FALSE otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Attributes_Is_barrier_automatic( + rtems_attribute attribute_set +) +{ + return ( attribute_set & RTEMS_BARRIER_AUTOMATIC_RELEASE ) ? true : false; +} + +/** + * @brief Checks if the system task attribute + * is enabled in the attribute_set. + * + * This function returns TRUE if the system task attribute + * is enabled in the attribute_set and FALSE otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Attributes_Is_system_task( + rtems_attribute attribute_set +) +{ + return ( attribute_set & RTEMS_SYSTEM_TASK ) ? true : false; +} + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/barrier.h b/cpukit/include/rtems/rtems/barrier.h new file mode 100644 index 0000000000..2eea90fa41 --- /dev/null +++ b/cpukit/include/rtems/rtems/barrier.h @@ -0,0 +1,173 @@ +/** + * @file rtems/rtems/barrier.h + * + * @defgroup ClassicBarrier Barriers + * + * @ingroup ClassicRTEMS + * @brief Classic API Barrier Manager + * + * This include file contains all the constants and structures associated + * with the Barrier Manager. + * + * Directives provided are: + * + * - create a barrier + * - get an ID of a barrier + * - delete a barrier + * - wait for a barrier + * - signal a barrier + */ + +/* COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_BARRIER_H +#define _RTEMS_RTEMS_BARRIER_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicBarrier Barriers + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality which implements the Classic API + * Barrier Manager. + */ +/**@{*/ + +/** + * This type defines the control block used to manage each barrier. + */ +typedef struct { + /** This is used to manage a barrier as an object. */ + Objects_Control Object; + /** This is used to implement the barrier. */ + CORE_barrier_Control Barrier; + /** This is used to specify the attributes of a barrier. */ + rtems_attribute attribute_set; +} Barrier_Control; + +/** + * @brief RTEMS Create Barrier + * + * Barrier Manager -- Create a Barrier Instance + * + * This routine implements the rtems_barrier_create directive. The + * barrier will have the name name. The starting count for + * the barrier is count. The attribute_set determines if + * the barrier is global or local and the thread queue + * discipline. It returns the id of the created barrier in ID. + * + * @param[in] name is the name of this barrier instance. + * @param[in] attribute_set specifies the attributes of this barrier instance. + * @param[in] maximum_waiters is the maximum number of threads which will + * be allowed to concurrently wait at the barrier. + * @param[out] id will contain the id of this barrier. + * + * @retval a status code indicating success or the reason for failure. + */ +rtems_status_code rtems_barrier_create( + rtems_name name, + rtems_attribute attribute_set, + uint32_t maximum_waiters, + rtems_id *id +); + +/** + * @brief RTEMS Barrier name to Id + * + * This routine implements the rtems_barrier_ident directive. + * This directive returns the barrier ID associated with name. + * If more than one barrier is named name, then the barrier + * to which the ID belongs is arbitrary. node indicates the + * extent of the search for the ID of the barrier named name. + * The search can be limited to a particular node or allowed to + * encompass all nodes. + * + * @param[in] name is the name of this barrier instance. + * @param[out] id will contain the id of this barrier. + * + * @retval a status code indicating success or the reason for failure. + */ +rtems_status_code rtems_barrier_ident( + rtems_name name, + rtems_id *id +); + +/** + * @brief RTEMS Delete Barrier + * + * This routine implements the rtems_barrier_delete directive. The + * barrier indicated by @a id is deleted. The barrier is freed back to the + * inactive barrier chain. + * + * + * @param[in] id indicates the barrier to delete + * + * @retval a status code indicating success or the reason for failure. + */ +rtems_status_code rtems_barrier_delete( + rtems_id id +); + +/** + * @brief RTEMS Barrier Wait + * + * This routine implements the rtems_barrier_wait directive. It + * attempts to wait at the barrier associated with @a id. The calling task + * may block waiting for the barrier with an optional timeout of @a timeout + * clock ticks. + * + * @param[in] id indicates the barrier to wait at. + * @param[in] timeout is the maximum length of time in ticks the calling + * thread is willing to block. + * + * @retval a status code indicating success or the reason for failure. + */ +rtems_status_code rtems_barrier_wait( + rtems_id id, + rtems_interval timeout +); + +/** + * @brief RTEMS Barrier Release + * + * Barrier Manager -- Release Tasks Waitng at a Barrier + * + * This routine implements the rtems_barrier_release directive. It + * unblocks all of the threads waiting on the barrier associated with + * @a id. The number of threads unblocked is returned in @a released. + * + * + * @param[in] id indicates the barrier to wait at. + * @param[out] released will contain the number of threads unblocked. + * + * @retval a status code indicating success or the reason for failure. + */ +rtems_status_code rtems_barrier_release( + rtems_id id, + uint32_t *released +); + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/barrierimpl.h b/cpukit/include/rtems/rtems/barrierimpl.h new file mode 100644 index 0000000000..f0b53e0cab --- /dev/null +++ b/cpukit/include/rtems/rtems/barrierimpl.h @@ -0,0 +1,92 @@ +/** + * @file rtems/rtems/barrier.inl + * + * @defgroup ClassicBarrier Barriers + * + * @ingroup ClassicRTEMS + * @brief Inline Implementation from Barrier Manager + * + * This file contains the static inlin implementation of the inlined + * routines from the Barrier Manager. + */ + +/* + * COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_BARRIERIMPL_H +#define _RTEMS_RTEMS_BARRIERIMPL_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicBarrierImpl Classic Barrier Implementation + * + * @ingroup ClassicBarrier + * + * @{ + */ + +/** + * The following defines the information control block used to manage + * this class of objects. + */ +extern Objects_Information _Barrier_Information; + +/** + * @brief _Barrier_Allocate + * + * This function allocates a barrier control block from + * the inactive chain of free barrier control blocks. + */ +RTEMS_INLINE_ROUTINE Barrier_Control *_Barrier_Allocate( void ) +{ + return (Barrier_Control *) _Objects_Allocate( &_Barrier_Information ); +} + +/** + * @brief _Barrier_Free + * + * This routine frees a barrier control block to the + * inactive chain of free barrier control blocks. + */ +RTEMS_INLINE_ROUTINE void _Barrier_Free ( + Barrier_Control *the_barrier +) +{ + _CORE_barrier_Destroy( &the_barrier->Barrier ); + _Objects_Free( &_Barrier_Information, &the_barrier->Object ); +} + +RTEMS_INLINE_ROUTINE Barrier_Control *_Barrier_Get( + Objects_Id id, + Thread_queue_Context *queue_context +) +{ + _Thread_queue_Context_initialize( queue_context ); + return (Barrier_Control *) _Objects_Get( + id, + &queue_context->Lock_context.Lock_context, + &_Barrier_Information + ); +} + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/cache.h b/cpukit/include/rtems/rtems/cache.h new file mode 100644 index 0000000000..f1dc9bf03d --- /dev/null +++ b/cpukit/include/rtems/rtems/cache.h @@ -0,0 +1,370 @@ +/** + * @file + * + * @ingroup ClassicCache + */ + +/* COPYRIGHT (c) 1989-2013. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_CACHE_H +#define _RTEMS_RTEMS_CACHE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/** + * @defgroup ClassicCache Cache + * + * @ingroup ClassicRTEMS + * + * @brief The Cache Manager provides functions to perform maintenance + * operations for data and instruction caches. + * + * The actual actions of the Cache Manager operations depend on the hardware + * and the implementation provided by the CPU architecture port or a board + * support package. Cache implementations tend to be highly hardware + * dependent. + * + * @{ + */ + +/** + * @brief Returns the data cache line size in bytes. + * + * For multi-level caches this is the maximum of the cache line sizes of all + * levels. + * + * @retval 0 No data cache is present. + * @retval positive The data cache line size in bytes. + */ +size_t rtems_cache_get_data_line_size( void ); + +/** + * @brief Returns the instruction cache line size in bytes. + * + * For multi-level caches this is the maximum of the cache line sizes of all + * levels. + * + * @retval 0 No instruction cache is present. + * @retval positive The instruction cache line size in bytes. + */ +size_t rtems_cache_get_instruction_line_size( void ); + +/** + * @brief Returns the maximal cache line size of all cache kinds in bytes. + * + * Returns computed or obtained maximal cache line size of all + * all caches in the system. + * + * @retval 0 No cache is present + * @retval positive The maximal cache line size in bytes. + */ +size_t rtems_cache_get_maximal_line_size( void ); + +/** + * @brief Returns the data cache size in bytes. + * + * @param[in] level The cache level of interest. The cache level zero + * specifies the entire data cache. + * + * @returns The data cache size in bytes of the specified level. + */ +size_t rtems_cache_get_data_cache_size( uint32_t level ); + +/** + * @brief Returns the instruction cache size in bytes. + * + * @param[in] level The cache level of interest. The cache level zero + * specifies the entire instruction cache. + * + * @returns The instruction cache size in bytes of the specified level. + */ +size_t rtems_cache_get_instruction_cache_size( uint32_t level ); + +/** + * @brief Flushes multiple data cache lines. + * + * Dirty cache lines covering the area are transfered to memory. Depending on + * the cache implementation this may mark the lines as invalid. + * + * @param[in] addr The start address of the area to flush. + * @param[in] size The size in bytes of the area to flush. + */ +void rtems_cache_flush_multiple_data_lines( const void *addr, size_t size ); + +/** + * @brief Invalidates multiple data cache lines. + * + * The cache lines covering the area are marked as invalid. A later read + * access in the area will load the data from memory. + * + * In case the area is not aligned on cache line boundaries, then this + * operation may destroy unrelated data. + * + * @param[in] addr The start address of the area to invalidate. + * @param[in] size The size in bytes of the area to invalidate. + */ +void rtems_cache_invalidate_multiple_data_lines( + const void *addr, + size_t size +); + +/** + * @brief Invalidates multiple instruction cache lines. + * + * The cache lines covering the area are marked as invalid. A later + * instruction fetch from the area will result in a load from memory. + * In SMP mode, on processors without instruction cache snooping, this + * operation will invalidate the instruction cache lines on all processors. + * It should not be called from interrupt context in such case. + * + * @param[in] addr The start address of the area to invalidate. + * @param[in] size The size in bytes of the area to invalidate. + */ +void rtems_cache_invalidate_multiple_instruction_lines( + const void *addr, + size_t size +); + + +/** + * @brief Ensure necessary synchronization required after code changes + * + * When code is loaded or modified then many Harvard cache equipped + * systems require synchronization of main memory and or updated + * code in data cache to ensure visibility of change in all + * connected CPUs instruction memory view. This operation + * should be used by run time loader for example. + * + * @param[in] addr The start address of the area to invalidate. + * @param[in] size The size in bytes of the area to invalidate. + */ +void rtems_cache_instruction_sync_after_code_change( + const void * code_addr, + size_t n_bytes +); + +/** + * @brief Flushes the entire data cache. + * + * @see rtems_cache_flush_multiple_data_lines(). + */ +void rtems_cache_flush_entire_data( void ); + +/** + * @brief Invalidates the entire instruction cache. + * + * @see rtems_cache_invalidate_multiple_instruction_lines(). + */ +void rtems_cache_invalidate_entire_instruction( void ); + +/** + * This function is responsible for performing a data cache + * invalidate. It invalidates the entire cache. + */ +void rtems_cache_invalidate_entire_data( void ); + +/** + * This function freezes the data cache. + */ +void rtems_cache_freeze_data( void ); + +/** + * This function unfreezes the data cache. + */ +void rtems_cache_unfreeze_data( void ); + +/** + * This function enables the data cache. + */ +void rtems_cache_enable_data( void ); + +/** + * This function disables the data cache. + */ +void rtems_cache_disable_data( void ); + +/** + * This function freezes the instruction cache. + */ +void rtems_cache_freeze_instruction( void ); + +/** + * This function unfreezes the instruction cache. + */ +void rtems_cache_unfreeze_instruction( void ); + +/** + * This function enables the instruction cache. + */ +void rtems_cache_enable_instruction( void ); + +/** + * This function disables the instruction cache. + */ +void rtems_cache_disable_instruction( void ); + +/** + * This function is used to allocate storage that spans an + * integral number of cache blocks. + */ +void *rtems_cache_aligned_malloc ( size_t nbytes ); + +/** + * @brief Allocates a memory area of size @a size bytes from cache coherent + * memory. + * + * A size value of zero will return a unique address which may be freed with + * rtems_cache_coherent_free(). + * + * The memory allocated by this function can be released with a call to + * rtems_cache_coherent_free(). + * + * By default the C program heap allocator is used. In case special memory + * areas must be used, then the BSP or the application must add cache coherent + * memory areas for the allocator via rtems_cache_coherent_add_area(). + * + * This function must be called from driver initialization or task context + * only. + * + * @param[in] alignment If the alignment parameter is not equal to zero, the + * allocated memory area will begin at an address aligned by this value. + * @param[in] boundary If the boundary parameter is not equal to zero, the + * allocated memory area will comply with a boundary constraint. The + * boundary value specifies the set of addresses which are aligned by the + * boundary value. The interior of the allocated memory area will not + * contain an element of this set. The begin or end address of the area may + * be a member of the set. + * + * @retval NULL If no memory is available or the parameters are inconsistent. + * @retval other A pointer to the begin of the allocated memory area. + */ +void *rtems_cache_coherent_allocate( + size_t size, + uintptr_t alignment, + uintptr_t boundary +); + +/** + * @brief Frees memory allocated by rtems_cache_coherent_allocate(). + * + * This function must be called from driver initialization or task context + * only. + * + * @param[in] ptr A pointer returned by rtems_cache_coherent_allocate(). + */ +void rtems_cache_coherent_free( void *ptr ); + +/** + * @brief Adds a cache coherent memory area to the cache coherent allocator. + * + * This function must be called from BSP initialization, driver initialization + * or task context only. + * + * @param[in] area_begin The area begin address. + * @param[in] area_size The area size in bytes. + * + * @see rtems_cache_coherent_allocate(). + */ +void rtems_cache_coherent_add_area( + void *area_begin, + uintptr_t area_size +); + +#if defined( RTEMS_SMP ) + +/** + * @brief Flushes multiple data cache lines for a set of processors + * + * Dirty cache lines covering the area are transferred to memory. + * Depending on the cache implementation this may mark the lines as invalid. + * + * This operation should not be called from interrupt context. + * + * @param[in] addr The start address of the area to flush. + * @param[in] size The size in bytes of the area to flush. + * @param[in] setsize The size of the processor set. + * @param[in] set The target processor set. + */ +void rtems_cache_flush_multiple_data_lines_processor_set( + const void *addr, + size_t size, + const size_t setsize, + const cpu_set_t *set +); + +/** + * @brief Invalidates multiple data cache lines for a set of processors + * + * The cache lines covering the area are marked as invalid. A later read + * access in the area will load the data from memory. + * + * In case the area is not aligned on cache line boundaries, then this + * operation may destroy unrelated data. + * + * This operation should not be called from interrupt context. + * + * @param[in] addr The start address of the area to invalidate. + * @param[in] size The size in bytes of the area to invalidate. + * @param[in] setsize The size of the processor set. + * @param[in] set The target processor set. + */ +void rtems_cache_invalidate_multiple_data_lines_processor_set( + const void *addr, + size_t size, + const size_t setsize, + const cpu_set_t *set +); + +/** + * @brief Flushes the entire data cache for a set of processors + * + * This operation should not be called from interrupt context. + * + * @see rtems_cache_flush_multiple_data_lines(). + * + * @param[in] setsize The size of the processor set. + * @param[in] set The target processor set. + */ +void rtems_cache_flush_entire_data_processor_set( + const size_t setsize, + const cpu_set_t *set +); + +/** + * @brief Invalidates the entire cache for a set of processors + * + * This function is responsible for performing a data cache + * invalidate. It invalidates the entire cache for a set of + * processors. + * + * This operation should not be called from interrupt context. + * + * @param[in] setsize The size of the processor set. + * @param[in] set The target processor set. + */ +void rtems_cache_invalidate_entire_data_processor_set( + const size_t setsize, + const cpu_set_t *set +); + +#endif + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/clock.h b/cpukit/include/rtems/rtems/clock.h new file mode 100644 index 0000000000..a837b88700 --- /dev/null +++ b/cpukit/include/rtems/rtems/clock.h @@ -0,0 +1,318 @@ +/** + * @file rtems/rtems/clock.h + * + * @defgroup ClassicClock Clocks + * + * @ingroup ClassicRTEMS + * @brief Clock Manager API + * + * This include file contains all the constants and structures associated + * with the Clock Manager. This manager provides facilities to set, obtain, + * and continually update the current date and time. + * + * This manager provides directives to: + * + * - set the current date and time + * - obtain the current date and time + * - announce a clock tick + * - obtain the system uptime + */ + +/* COPYRIGHT (c) 1989-2013. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_CLOCK_H +#define _RTEMS_RTEMS_CLOCK_H + +#include +#include +#include +#include +#include +#include + +#include /* struct timeval */ + +/** + * @defgroup ClassicClock Clocks + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality related to the Classic API Clock + * Manager. + */ +/**@{*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Obtain Current Time of Day (Classic TOD) + * + * This routine implements the rtems_clock_get_tod directive. It returns + * the current time of day in the format defined by RTEID. + * + * Clock Manager - rtems_clock_get_tod + * + * @param[in] time_buffer points to the time of day structure + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. If successful, the time_buffer will + * be filled in with the current time of day. + */ +rtems_status_code rtems_clock_get_tod( + rtems_time_of_day *time_buffer +); + +/** + * @brief Obtain TOD in struct timeval Format + * + * This routine implements the rtems_clock_get_tod_timeval + * directive. + * + * @param[in] time points to the struct timeval variable to fill in + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. If successful, the time will + * be filled in with the current time of day. + */ +rtems_status_code rtems_clock_get_tod_timeval( + struct timeval *time +); + +/** + * @brief Obtain Seconds Since Epoch + * + * This routine implements the rtems_clock_get_seconds_since_epoch + * directive. + * + * @param[in] the_interval points to the interval variable to fill in + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. If successful, the time_buffer will + * be filled in with the current time of day. + */ +rtems_status_code rtems_clock_get_seconds_since_epoch( + rtems_interval *the_interval +); + +/** + * @brief Gets the current ticks counter value. + * + * @return The current tick counter value. With a 1ms clock tick, this counter + * overflows after 50 days since boot. + */ +RTEMS_INLINE_ROUTINE rtems_interval rtems_clock_get_ticks_since_boot(void) +{ + return _Watchdog_Ticks_since_boot; +} + +/** + * @brief Returns the ticks counter value delta ticks in the future. + * + * @param[in] delta The ticks delta value. + * + * @return The tick counter value delta ticks in the future. + */ +RTEMS_INLINE_ROUTINE rtems_interval rtems_clock_tick_later( + rtems_interval delta +) +{ + return _Watchdog_Ticks_since_boot + delta; +} + +/** + * @brief Returns the ticks counter value at least delta microseconds in the + * future. + * + * @param[in] delta_in_usec The delta value in microseconds. + * + * @return The tick counter value at least delta microseconds in the future. + */ +RTEMS_INLINE_ROUTINE rtems_interval rtems_clock_tick_later_usec( + rtems_interval delta_in_usec +) +{ + rtems_interval us_per_tick = rtems_configuration_get_microseconds_per_tick(); + + /* + * Add one additional tick, since we don't know the time to the clock next + * tick. + */ + return _Watchdog_Ticks_since_boot + + (delta_in_usec + us_per_tick - 1) / us_per_tick + 1; +} + +/** + * @brief Returns true if the current ticks counter value indicates a time + * before the time specified by the tick value and false otherwise. + * + * @param[in] tick The tick value. + * + * This can be used to write busy loops with a timeout. + * + * @code + * status busy( void ) + * { + * rtems_interval timeout = rtems_clock_tick_later_usec( 10000 ); + * + * do { + * if ( ok() ) { + * return success; + * } + * } while ( rtems_clock_tick_before( timeout ) ); + * + * return timeout; + * } + * @endcode + * + * @retval true The current ticks counter value indicates a time before the + * time specified by the tick value. + * @retval false Otherwise. + */ +RTEMS_INLINE_ROUTINE bool rtems_clock_tick_before( + rtems_interval tick +) +{ + return (int32_t) ( tick - _Watchdog_Ticks_since_boot ) > 0; +} + +/** + * @brief Obtain Ticks Per Seconds + * + * This routine implements the rtems_clock_get_ticks_per_second + * directive. + * + * @retval This method returns the number of ticks per second. It cannot + * fail since RTEMS is always configured to know the number of + * ticks per second. + */ +rtems_interval rtems_clock_get_ticks_per_second(void); + +/* Optimized variant for C/C++ without function call overhead */ +#define rtems_clock_get_ticks_per_second() ( _Watchdog_Ticks_per_second ) + +/** + * @brief Set the Current TOD + * + * This routine implements the rtems_clock_set directive. It sets + * the current time of day to that in the time_buffer record. + * + * @param[in] time_buffer points to the new TOD + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + * + * @note Activities scheduled based upon the current time of day + * may be executed immediately if the time is moved forward. + */ +rtems_status_code rtems_clock_set( + const rtems_time_of_day *time_buffer +); + +/** + * @brief Announce a Clock Tick + * + * This routine implements the rtems_clock_tick directive. It is invoked + * to inform RTEMS of the occurrence of a clock tick. + * + * @retval This directive always returns RTEMS_SUCCESSFUL. + * + * @note This method is typically called from an ISR and is the basis + * for all timeouts and delays. This routine only works for leap-years + * through 2099. + */ +rtems_status_code rtems_clock_tick( void ); + +/** + * @brief Obtain the System Uptime + * + * This directive returns the system uptime. + * + * @param[in] uptime is a pointer to the time structure + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. If successful, the @a uptime will be + * filled in. + */ +rtems_status_code rtems_clock_get_uptime( + struct timespec *uptime +); + +/** + * @brief Gets the System Uptime in the Struct Timeval Format + * + * @param[out] uptime is a pointer to a struct timeval structure. + * + * @retval This methods returns the system uptime. + * + * @note Pointer must not be NULL. + */ +void rtems_clock_get_uptime_timeval( struct timeval *uptime ); + +/** + * @brief Returns the system uptime in seconds. + * + * @retval The system uptime in seconds. + */ +RTEMS_INLINE_ROUTINE time_t rtems_clock_get_uptime_seconds( void ) +{ + return _Timecounter_Time_uptime - 1; +} + +/** + * @brief Returns the system uptime in nanoseconds. + * + * @retval The system uptime in nanoseconds. + */ +uint64_t rtems_clock_get_uptime_nanoseconds( void ); + +/** + * @brief TOD Validate + * + * This support function returns true if @a the_tod contains + * a valid time of day, and false otherwise. + * + * @param[in] the_tod is the TOD structure to validate + * + * @retval This method returns true if the TOD is valid and false otherwise. + * + * @note This routine only works for leap-years through 2099. + */ +bool _TOD_Validate( + const rtems_time_of_day *the_tod +); + +/** + * @brief TOD to Seconds + * + * This function returns the number seconds between the epoch and @a the_tod. + * + * @param[in] the_tod is the TOD structure to convert to seconds + * + * @retval This method returns the number of seconds since epoch represented + * by @a the_tod + */ +Watchdog_Interval _TOD_To_seconds( + const rtems_time_of_day *the_tod +); + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/config.h b/cpukit/include/rtems/rtems/config.h new file mode 100644 index 0000000000..77ee798d74 --- /dev/null +++ b/cpukit/include/rtems/rtems/config.h @@ -0,0 +1,142 @@ +/** + * @file rtems/rtems/config.h + * + * @defgroup ClassicConfig Configuration + * + * @ingroup ClassicRTEMS + * @brief Configuration Table + * + * This include file contains the table of user defined configuration + * parameters specific for the RTEMS API. + */ + +/* COPYRIGHT (c) 1989-2013. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_CONFIG_H +#define _RTEMS_RTEMS_CONFIG_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicConfig Configuration + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality related to the application's configuration + * of the Classic API including the maximum number of each class of objects. + */ +/**@{*/ + +/** + * The following records define the Configuration Table. The + * information contained in this table is required in all + * RTEMS systems, whether single or multiprocessor. This + * table primarily defines the following: + * + * + required number of each object type + */ +typedef struct { + /** + * This field contains the maximum number of Classic API + * Tasks which are configured for this application. + */ + uint32_t maximum_tasks; + + /** + * This field contains the maximum number of Classic API + * Timers which are configured for this application. + */ + uint32_t maximum_timers; + + /** + * This field contains the maximum number of Classic API + * Semaphores which are configured for this application. + */ + uint32_t maximum_semaphores; + + /** + * This field contains the maximum number of Classic API + * Message Queues which are configured for this application. + */ + uint32_t maximum_message_queues; + + /** + * This field contains the maximum number of Classic API + * Partitions which are configured for this application. + */ + uint32_t maximum_partitions; + + /** + * This field contains the maximum number of Classic API + * Regions which are configured for this application. + */ + uint32_t maximum_regions; + + /** + * This field contains the maximum number of Classic API + * Dual Ported Memory Areas which are configured for this + * application. + */ + uint32_t maximum_ports; + + /** + * This field contains the maximum number of Classic API + * Rate Monotonic Periods which are configured for this + * application. + */ + uint32_t maximum_periods; + + /** + * This field contains the maximum number of Classic API + * Barriers which are configured for this application. + */ + uint32_t maximum_barriers; + + /** + * This field contains the number of Classic API Initialization + * Tasks which are configured for this application. + */ + uint32_t number_of_initialization_tasks; + + /** + * This field is the set of Classic API Initialization + * Tasks which are configured for this application. + */ + rtems_initialization_tasks_table *User_initialization_tasks_table; +} rtems_api_configuration_table; + +/** + * @brief RTEMS API Configuration Table + * + * This is the RTEMS API Configuration Table expected to be generated + * by confdefs.h. + */ +extern rtems_api_configuration_table Configuration_RTEMS_API; + +/**@}*/ + +/** + * This macro returns the number of Classic API semaphores configured. + */ +#define rtems_configuration_get_maximum_semaphores() \ + rtems_configuration_get_rtems_api_configuration()->maximum_semaphores + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/dpmem.h b/cpukit/include/rtems/rtems/dpmem.h new file mode 100644 index 0000000000..e582d2d359 --- /dev/null +++ b/cpukit/include/rtems/rtems/dpmem.h @@ -0,0 +1,179 @@ +/** + * @file rtems/rtems/dpmem.h + * + * @defgroup ClassicDPMEM Dual Ported Memory + * + * @ingroup ClassicRTEMS + * @brief Dual Ported Memory Manager + * + * This include file contains all the constants and structures associated + * with the Dual Ported Memory Manager. This manager provides a mechanism + * for converting addresses between internal and external representations + * for multiple dual-ported memory areas. + * + * Directives provided are: + * + * - create a port + * - get ID of a port + * - delete a port + * - convert external to internal address + * - convert internal to external address + * + */ + +/* COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_DPMEM_H +#define _RTEMS_RTEMS_DPMEM_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicDPMEM Dual Ported Memory + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality related to the + * Classic API Dual Ported Memory Manager. + */ +/**@{*/ + +/** + * The following structure defines the port control block. Each port + * has a control block associated with it. This control block contains + * all information required to support the port related operations. + */ +typedef struct { + /** This field is the object management portion of a Port instance. */ + Objects_Control Object; + /** This field is the base internal address of the port. */ + void *internal_base; + /** This field is the base external address of the port. */ + void *external_base; + /** This field is the length of dual-ported area of the port. */ + uint32_t length; +} Dual_ported_memory_Control; + +/** + * @brief Creates a port into a dual-ported memory area. + * + * This routine implements the rtems_port_create directive. The port + * will have the name @a name. The port maps onto an area of dual ported + * memory of length bytes which has internal_start and external_start + * as the internal and external starting addresses, respectively. + * It returns the id of the created port in ID. + * + * @param[in] name is the user defined port name + * @param[in] internal_start is the internal start address of port + * @param[in] external_start is the external start address of port + * @param[in] length is the physical length in bytes + * @param[out] id is the address of port id to set + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. If successful, the id will + * be filled in with the port id. + */ +rtems_status_code rtems_port_create( + rtems_name name, + void *internal_start, + void *external_start, + uint32_t length, + rtems_id *id +); + +/** + * @brief RTEMS Port Name to Id + * + * This routine implements the rtems_port_ident directive. This directive + * returns the port ID associated with name. If more than one port is + * named name, then the port to which the ID belongs is arbitrary. + * + * @param[in] name is the user defined port name + * @param[out] id is the pointer to port id + * + * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful + */ +rtems_status_code rtems_port_ident( + rtems_name name, + rtems_id *id +); + +/** + * @brief RTEMS Delete Port + * + * This routine implements the rtems_port_delete directive. It deletes + * the port associated with ID. + * + * @param[in] id is the dual-ported memory area id + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + */ +rtems_status_code rtems_port_delete( + rtems_id id +); + +/** + * @brief RTEMS Port External to Internal + * + * This routine implements the rtems_port_external_to_internal directive. + * It returns the internal port address which maps to the provided + * external port address for the specified port ID. If the given external + * address is an invalid dual-ported address, then the internal address is + * set to the given external address. + * + * @param[in] id is the id of dp memory object + * @param[in] external is the external address + * @param[out] internal is the pointer of internal address to set + * + * @retval RTEMS_SUCCESSFUL + */ +rtems_status_code rtems_port_external_to_internal( + rtems_id id, + void *external, + void **internal +); + +/** + * @brief RTEMS Port Internal to External + * + * This routine implements the Port_internal_to_external directive. + * It returns the external port address which maps to the provided + * internal port address for the specified port ID. If the given + * internal address is an invalid dual-ported address, then the + * external address is set to the given internal address. + * + * @param[in] id is the id of dual-ported memory object + * @param[in] internal is the internal address to set + * @param[in] external is the pointer to external address + * + * @retval RTEMS_SUCCESSFUL and the external will be filled in + * with the external addresses + */ +rtems_status_code rtems_port_internal_to_external( + rtems_id id, + void *internal, + void **external +); + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/dpmemimpl.h b/cpukit/include/rtems/rtems/dpmemimpl.h new file mode 100644 index 0000000000..52ac48c8dc --- /dev/null +++ b/cpukit/include/rtems/rtems/dpmemimpl.h @@ -0,0 +1,85 @@ +/** + * @file + * + * @ingroup ClassicDPMEMImpl + * + * @brief Dual Ported Memory Manager Implementation + */ + +/* COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_DPMEM_INL +#define _RTEMS_RTEMS_DPMEM_INL + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicDPMEMImpl Dual Ported Memory Manager Implementation + * + * @ingroup ClassicDPMEM + * + * @{ + */ + +/** + * @brief Define the internal Dual Ported Memory information + * The following define the internal Dual Ported Memory information. + */ +extern Objects_Information _Dual_ported_memory_Information; + +/** + * @brief Allocates a port control block from the inactive chain + * of free port control blocks. + * + * This routine allocates a port control block from the inactive chain + * of free port control blocks. + */ +RTEMS_INLINE_ROUTINE Dual_ported_memory_Control + *_Dual_ported_memory_Allocate ( void ) +{ + return (Dual_ported_memory_Control *) + _Objects_Allocate( &_Dual_ported_memory_Information ); +} + +/** + * @brief Frees a port control block to the inactive chain + * of free port control blocks. + * + * This routine frees a port control block to the inactive chain + * of free port control blocks. + */ +RTEMS_INLINE_ROUTINE void _Dual_ported_memory_Free ( + Dual_ported_memory_Control *the_port +) +{ + _Objects_Free( &_Dual_ported_memory_Information, &the_port->Object ); +} + +RTEMS_INLINE_ROUTINE Dual_ported_memory_Control *_Dual_ported_memory_Get( + Objects_Id id, + ISR_lock_Context *lock_context +) +{ + return (Dual_ported_memory_Control *) + _Objects_Get( id, lock_context, &_Dual_ported_memory_Information ); +} + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_RTEMS_DPMEM_INL */ +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/event.h b/cpukit/include/rtems/rtems/event.h new file mode 100644 index 0000000000..1cd64c0cfa --- /dev/null +++ b/cpukit/include/rtems/rtems/event.h @@ -0,0 +1,526 @@ +/** + * @file rtems/rtems/event.h + * + * @defgroup ClassicEvent Events + * + * @ingroup ClassicRTEMS + * @brief Information Related to Event Manager + * + * This include file contains the information pertaining to the Event + * Manager. This manager provides a high performance method of communication + * and synchronization. + * + * Directives provided are: + * + * - send an event set to a task + * - receive event condition + * + */ + +/* COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_EVENT_H +#define _RTEMS_RTEMS_EVENT_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicEventSet Event Set + * + * @ingroup ClassicEvent + * + * @{ + */ + +/** + * @brief Integer type to hold an event set of up to 32 events represented as + * a bit field. + */ +typedef uint32_t rtems_event_set; + +/** + * @brief Constant used to send or receive all events. + */ +#define RTEMS_ALL_EVENTS 0xFFFFFFFF + +/** @brief Defines the bit in the event set associated with event 0. */ +#define RTEMS_EVENT_0 0x00000001 +/** @brief Defines the bit in the event set associated with event 1. */ +#define RTEMS_EVENT_1 0x00000002 +/** @brief Defines the bit in the event set associated with event 2. */ +#define RTEMS_EVENT_2 0x00000004 +/** @brief Defines the bit in the event set associated with event 3. */ +#define RTEMS_EVENT_3 0x00000008 +/** @brief Defines the bit in the event set associated with event 4. */ +#define RTEMS_EVENT_4 0x00000010 +/** @brief Defines the bit in the event set associated with event 5. */ +#define RTEMS_EVENT_5 0x00000020 +/** @brief Defines the bit in the event set associated with event 6. */ +#define RTEMS_EVENT_6 0x00000040 +/** @brief Defines the bit in the event set associated with event 7. */ +#define RTEMS_EVENT_7 0x00000080 +/** @brief Defines the bit in the event set associated with event 8. */ +#define RTEMS_EVENT_8 0x00000100 +/** @brief Defines the bit in the event set associated with event 9. */ +#define RTEMS_EVENT_9 0x00000200 +/** @brief Defines the bit in the event set associated with event 10. */ +#define RTEMS_EVENT_10 0x00000400 +/** @brief Defines the bit in the event set associated with event 11. */ +#define RTEMS_EVENT_11 0x00000800 +/** @brief Defines the bit in the event set associated with event 12. */ +#define RTEMS_EVENT_12 0x00001000 +/** @brief Defines the bit in the event set associated with event 13. */ +#define RTEMS_EVENT_13 0x00002000 +/** @brief Defines the bit in the event set associated with event 14. */ +#define RTEMS_EVENT_14 0x00004000 +/** @brief Defines the bit in the event set associated with event 15. */ +#define RTEMS_EVENT_15 0x00008000 +/** @brief Defines the bit in the event set associated with event 16. */ +#define RTEMS_EVENT_16 0x00010000 +/** @brief Defines the bit in the event set associated with event 17. */ +#define RTEMS_EVENT_17 0x00020000 +/** @brief Defines the bit in the event set associated with event 18. */ +#define RTEMS_EVENT_18 0x00040000 +/** @brief Defines the bit in the event set associated with event 19. */ +#define RTEMS_EVENT_19 0x00080000 +/** @brief Defines the bit in the event set associated with event 20. */ +#define RTEMS_EVENT_20 0x00100000 +/** @brief Defines the bit in the event set associated with event 21. */ +#define RTEMS_EVENT_21 0x00200000 +/** @brief Defines the bit in the event set associated with event 22. */ +#define RTEMS_EVENT_22 0x00400000 +/** @brief Defines the bit in the event set associated with event 23. */ +#define RTEMS_EVENT_23 0x00800000 +/** @brief Defines the bit in the event set associated with event 24. */ +#define RTEMS_EVENT_24 0x01000000 +/** @brief Defines the bit in the event set associated with event 25. */ +#define RTEMS_EVENT_25 0x02000000 +/** @brief Defines the bit in the event set associated with event 26. */ +#define RTEMS_EVENT_26 0x04000000 +/** @brief Defines the bit in the event set associated with event 27. */ +#define RTEMS_EVENT_27 0x08000000 +/** @brief Defines the bit in the event set associated with event 29. */ +#define RTEMS_EVENT_28 0x10000000 +/** @brief Defines the bit in the event set associated with event 29. */ +#define RTEMS_EVENT_29 0x20000000 +/** @brief Defines the bit in the event set associated with event 30. */ +#define RTEMS_EVENT_30 0x40000000 +/** @brief Defines the bit in the event set associated with event 31. */ +#define RTEMS_EVENT_31 0x80000000 + +/** @} */ + +/** + * @defgroup ClassicEvent Events + * + * @ingroup ClassicRTEMS + * + * @brief The event manager provides a high performance method of intertask + * communication and synchronization. + * + * An event flag is used by a task (or ISR) to inform another task of the + * occurrence of a significant situation. Thirty-two event flags are + * associated with each task. A collection of one or more event flags is + * referred to as an event set. The data type rtems_event_set is used to + * manage event sets. + * + * The application developer should remember the following key characteristics + * of event operations when utilizing the event manager: + * + * - Events provide a simple synchronization facility. + * - Events are aimed at tasks. + * - Tasks can wait on more than one event simultaneously. + * - Events are independent of one another. + * - Events do not hold or transport data. + * - Events are not queued. In other words, if an event is sent more than once + * to a task before being received, the second and subsequent send + * operations to that same task have no effect. + * + * An event set is posted when it is directed (or sent) to a task. A pending + * event is an event that has been posted but not received. An event condition + * is used to specify the event set which the task desires to receive and the + * algorithm which will be used to determine when the request is satisfied. An + * event condition is satisfied based upon one of two algorithms which are + * selected by the user. The @ref RTEMS_EVENT_ANY algorithm states that an + * event condition is satisfied when at least a single requested event is + * posted. The @ref RTEMS_EVENT_ALL algorithm states that an event condition + * is satisfied when every requested event is posted. + * + * An event set or condition is built by a bitwise or of the desired events. + * The set of valid events is @ref RTEMS_EVENT_0 through @ref RTEMS_EVENT_31. + * If an event is not explicitly specified in the set or condition, then it is + * not present. Events are specifically designed to be mutually exclusive, + * therefore bitwise or and addition operations are equivalent as long as each + * event appears exactly once in the event set list. + * + * For example, when sending the event set consisting of @ref RTEMS_EVENT_6, + * @ref RTEMS_EVENT_15, and @ref RTEMS_EVENT_31, the event parameter to the + * rtems_event_send() directive should be @ref RTEMS_EVENT_6 | + * @ref RTEMS_EVENT_15 | @ref RTEMS_EVENT_31. + * + * @{ + */ + +/** + * @brief Constant used to receive the set of currently pending events in + * rtems_event_receive(). + */ +#define RTEMS_PENDING_EVENTS 0 + +/** + * @brief Sends an Event Set to the Target Task + * + * This directive sends an event set @a event_in to the task specified by + * @a id. + * + * Based upon the state of the target task, one of the following situations + * applies. The target task is + * - blocked waiting for events. + * If the waiting task's input event condition is + * - satisfied, then the task is made ready for execution. + * - not satisfied, then the event set is posted but left pending and the + * task remains blocked. + * - not waiting for events. + * - The event set is posted and left pending. + * + * Identical events sent to a task are not queued. In other words, the second, + * and subsequent, posting of an event to a task before it can perform an + * rtems_event_receive() has no effect. + * + * The calling task will be preempted if it has preemption enabled and a + * higher priority task is unblocked as the result of this directive. + * + * Sending an event set to a global task which does not reside on the local + * node will generate a request telling the remote node to send the event set + * to the appropriate task. + * + * @param[in] id Identifier of the target task. Specifying @ref RTEMS_SELF + * results in the event set being sent to the calling task. + * @param[in] event_in Event set sent to the target task. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_ID Invalid task identifier. + */ +rtems_status_code rtems_event_send ( + rtems_id id, + rtems_event_set event_in +); + +/** + * @brief Receives pending events. + * + * This directive attempts to receive the event condition specified in + * @a event_in. If @a event_in is set to @ref RTEMS_PENDING_EVENTS, then the + * current pending events are returned in @a event_out and left pending. The + * @ref RTEMS_WAIT and @ref RTEMS_NO_WAIT options in the @a option_set + * parameter are used to specify whether or not the task is willing to wait + * for the event condition to be satisfied. The @ref RTEMS_EVENT_ANY and @ref + * RTEMS_EVENT_ALL are used in the @a option_set parameter to specify whether + * at least a single event or the complete event set is necessary to satisfy + * the event condition. The @a event_out parameter is returned to the calling + * task with the value that corresponds to the events in @a event_in that were + * satisfied. + * + * A task can determine the pending event set by using a value of + * @ref RTEMS_PENDING_EVENTS for the input event set @a event_in. The pending + * events are returned to the calling task but the event set is left + * unaltered. + * + * A task can receive all of the currently pending events by using the a value + * of @ref RTEMS_ALL_EVENTS for the input event set @a event_in and + * @ref RTEMS_NO_WAIT | @ref RTEMS_EVENT_ANY for the option set @a option_set. + * The pending events are returned to the calling task and the event set is + * cleared. If no events are pending then the @ref RTEMS_UNSATISFIED status + * code will be returned. + * + * If pending events satisfy the event condition, then @a event_out is set to + * the satisfied events and the pending events in the event condition are + * cleared. If the event condition is not satisfied and @ref RTEMS_NO_WAIT is + * specified, then @a event_out is set to the currently satisfied events. If + * the calling task chooses to wait, then it will block waiting for the event + * condition. + * + * If the calling task must wait for the event condition to be satisfied, then + * the timeout parameter is used to specify the maximum interval to wait. If + * it is set to @ref RTEMS_NO_TIMEOUT, then the calling task will wait forever. + * + * This directive only affects the events specified in @a event_in. Any + * pending events that do not correspond to any of the events specified in + * @a event_in will be left pending. + * + * A clock tick is required to support the wait with time out functionality of + * this directive. + * + * @param[in] event_in Set of requested events (input events). + * @param[in] option_set Use a bitwise or of the following options + * - @ref RTEMS_WAIT - task will wait for event (default), + * - @ref RTEMS_NO_WAIT - task should not wait, + * - @ref RTEMS_EVENT_ALL - return after all events (default), and + * - @ref RTEMS_EVENT_ANY - return after any events. + * @param[in] ticks Time out in ticks. Use @ref RTEMS_NO_TIMEOUT to wait + * without a time out (potentially forever). + * @param[out] event_out Set of received events (output events). + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_UNSATISFIED Input events not satisfied (only with the + * @ref RTEMS_NO_WAIT option). + * @retval RTEMS_INVALID_ADDRESS The @a event_out pointer is @c NULL. + * @retval RTEMS_TIMEOUT Timed out waiting for events. + */ +rtems_status_code rtems_event_receive ( + rtems_event_set event_in, + rtems_option option_set, + rtems_interval ticks, + rtems_event_set *event_out +); + +/** @} */ + +/** + * @defgroup ClassicEventSystem System Events + * + * @ingroup ClassicEvent + * + * System events are similar to normal events. They offer a second set of + * events. These events are intended for internal RTEMS use and should not be + * used by applications (with the exception of the transient system event). + * + * The event @ref RTEMS_EVENT_SYSTEM_TRANSIENT is used for transient usage. + * See also @ref ClassicEventTransient. This event may be used by every entity + * that fulfils its usage pattern. + */ +/**@{**/ + +/** + * @brief Reserved system event for network SBWAIT usage. + */ +#define RTEMS_EVENT_SYSTEM_NETWORK_SBWAIT RTEMS_EVENT_24 + +/** + * @brief Reserved system event for network SOSLEEP usage. + */ +#define RTEMS_EVENT_SYSTEM_NETWORK_SOSLEEP RTEMS_EVENT_25 + +/** + * @brief Reserved system event for network socket close. + */ +#define RTEMS_EVENT_SYSTEM_NETWORK_CLOSE RTEMS_EVENT_26 + +/** + * @brief Reserved system event to resume server threads, e.g timer or + * interrupt server. + */ +#define RTEMS_EVENT_SYSTEM_SERVER_RESUME RTEMS_EVENT_29 + +/** + * @brief Reserved system event for the server threads, e.g timer or interrupt + * server. + */ +#define RTEMS_EVENT_SYSTEM_SERVER RTEMS_EVENT_30 + +/** + * @brief Reserved system event for transient usage. + */ +#define RTEMS_EVENT_SYSTEM_TRANSIENT RTEMS_EVENT_31 + +/** + * @brief See rtems_event_send(). + */ +rtems_status_code rtems_event_system_send( + rtems_id id, + rtems_event_set event_in +); + +/** + * @brief See rtems_event_receive(). + */ +rtems_status_code rtems_event_system_receive( + rtems_event_set event_in, + rtems_option option_set, + rtems_interval ticks, + rtems_event_set *event_out +); + +/** @} */ + +/** + * @defgroup ClassicEventTransient Transient Event + * + * @ingroup ClassicEvent + * + * The transient event can be used by a client task to issue a request to + * another task or interrupt service (server). The server can send the + * transient event to the client task to notify about a request completion, see + * rtems_event_transient_send(). The client task can wait for the transient + * event reception with rtems_event_transient_receive(). + * + * The user of the transient event must ensure that this event is not pending + * once the request is finished or cancelled. A successful reception of the + * transient event with rtems_event_transient_receive() will clear the + * transient event. If a reception with timeout is used the transient event + * state is undefined after a timeout return status. The transient event can + * be cleared unconditionally with the non-blocking + * rtems_event_transient_clear(). + * + * @msc + * hscale="1.6"; + * M [label="Main Task"], IDLE [label="Idle Task"], S [label="Server"], TIME [label="System Tick Handler"]; + * |||; + * --- [label="sequence with request completion"]; + * M box M [label="prepare request\nissue request\nrtems_event_transient_receive()"]; + * M=>>IDLE [label="blocking operation"]; + * IDLE=>>S [label="request completion"]; + * S box S [label="rtems_event_transient_send()"]; + * S=>>M [label="task is ready again"]; + * M box M [label="finish request"]; + * |||; + * --- [label="sequence with early request completion"]; + * M box M [label="prepare request\nissue request"]; + * M=>>S [label="request completion"]; + * S box S [label="rtems_event_transient_send()"]; + * S=>>M [label="transient event is now pending"]; + * M box M [label="rtems_event_transient_receive()\nfinish request"]; + * |||; + * --- [label="sequence with timeout event"]; + * M box M [label="prepare request\nissue request\nrtems_event_transient_receive()"]; + * M=>>IDLE [label="blocking operation"]; + * IDLE=>>TIME [label="timeout expired"]; + * TIME box TIME [label="cancel blocking operation"]; + * TIME=>>M [label="task is ready again"]; + * M box M [label="cancel request\nrtems_event_transient_clear()"]; + * @endmsc + * + * Suppose you have a task that wants to issue a certain request and then waits + * for request completion. It can create a request structure and store its + * task identifier there. Now it can place the request on a work queue of + * another task (or interrupt handler). Afterwards the task waits for the + * reception of the transient event. Once the server task is finished with the + * request it can send the transient event to the waiting task and wake it up. + * + * @code + * #include + * #include + * + * typedef struct { + * rtems_id task_id; + * bool work_done; + * } request; + * + * void server(rtems_task_argument arg) + * { + * rtems_status_code sc; + * request *req = (request *) arg; + * + * req->work_done = true; + * + * sc = rtems_event_transient_send(req->task_id); + * assert(sc == RTEMS_SUCCESSFUL); + * + * sc = rtems_task_delete(RTEMS_SELF); + * assert(sc == RTEMS_SUCCESSFUL); + * } + * + * void issue_request_and_wait_for_completion(void) + * { + * rtems_status_code sc; + * rtems_id id; + * request req; + * + * req.task_id = rtems_task_self(); + * req.work_done = false; + * + * sc = rtems_task_create( + * rtems_build_name('S', 'E', 'R', 'V'), + * 1, + * RTEMS_MINIMUM_STACK_SIZE, + * RTEMS_DEFAULT_MODES, + * RTEMS_DEFAULT_ATTRIBUTES, + * &id + * ); + * assert(sc == RTEMS_SUCCESSFUL); + * + * sc = rtems_task_start(id, server, (rtems_task_argument) &req); + * assert(sc == RTEMS_SUCCESSFUL); + * + * sc = rtems_event_transient_receive(RTEMS_WAIT, RTEMS_NO_TIMEOUT); + * assert(sc == RTEMS_SUCCESSFUL); + * + * assert(req.work_done); + * } + * @endcode + */ +/**@{**/ + +/** + * @brief See rtems_event_system_send(). + * + * The system event @ref RTEMS_EVENT_SYSTEM_TRANSIENT will be sent. + */ +RTEMS_INLINE_ROUTINE rtems_status_code rtems_event_transient_send( + rtems_id id +) +{ + return rtems_event_system_send( id, RTEMS_EVENT_SYSTEM_TRANSIENT ); +} + +/** + * @brief See rtems_event_system_receive(). + * + * The system event @ref RTEMS_EVENT_SYSTEM_TRANSIENT will be received. + */ +RTEMS_INLINE_ROUTINE rtems_status_code rtems_event_transient_receive( + rtems_option option_set, + rtems_interval ticks +) +{ + rtems_event_set event_out; + + return rtems_event_system_receive( + RTEMS_EVENT_SYSTEM_TRANSIENT, + RTEMS_EVENT_ALL | option_set, + ticks, + &event_out + ); +} + +/** + * @brief See rtems_event_system_receive(). + * + * The system event @ref RTEMS_EVENT_SYSTEM_TRANSIENT will be cleared. + */ +RTEMS_INLINE_ROUTINE void rtems_event_transient_clear( void ) +{ + rtems_event_set event_out; + + rtems_event_system_receive( + RTEMS_EVENT_SYSTEM_TRANSIENT, + RTEMS_EVENT_ALL | RTEMS_NO_WAIT, + 0, + &event_out + ); +} + +/** @} */ + +typedef struct { + rtems_event_set pending_events; +} Event_Control; + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/eventimpl.h b/cpukit/include/rtems/rtems/eventimpl.h new file mode 100644 index 0000000000..933ea0fe2b --- /dev/null +++ b/cpukit/include/rtems/rtems/eventimpl.h @@ -0,0 +1,146 @@ +/** + * @file + * + * @ingroup ClassicEventImpl + * + * @brief Classic Event Implementation + */ + +/* COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_EVENTIMPL_H +#define _RTEMS_RTEMS_EVENTIMPL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicEventImpl Classic Event Implementation + * + * @ingroup ClassicEvent + * + * @{ + */ + +/** + * This constant is passed as the event_in to the + * rtems_event_receive directive to determine which events are pending. + */ +#define EVENT_CURRENT 0 + +/** + * The following constant is the value of an event set which + * has no events pending. + */ +#define EVENT_SETS_NONE_PENDING 0 + +rtems_status_code _Event_Seize( + rtems_event_set event_in, + rtems_option option_set, + rtems_interval ticks, + rtems_event_set *event_out, + Thread_Control *executing, + Event_Control *event, + Thread_Wait_flags wait_class, + States_Control block_state, + ISR_lock_Context *lock_context +); + +rtems_status_code _Event_Surrender( + Thread_Control *the_thread, + rtems_event_set event_in, + Event_Control *event, + Thread_Wait_flags wait_class, + ISR_lock_Context *lock_context +); + +/** + * @brief Timeout Event + */ +void _Event_Timeout( + Objects_Id id, + void *arg +); + +RTEMS_INLINE_ROUTINE void _Event_Initialize( Event_Control *event ) +{ + event->pending_events = EVENT_SETS_NONE_PENDING; +} + +/** + * @brief Checks if on events are posted in the event_set. + * + * This function returns TRUE if on events are posted in the event_set, + * and FALSE otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Event_sets_Is_empty( + rtems_event_set the_event_set +) +{ + return ( the_event_set == 0 ); +} + +/** + * @brief Posts the given new_events into the event_set passed in. + * + * This routine posts the given new_events into the event_set + * passed in. The result is returned to the user in event_set. + */ +RTEMS_INLINE_ROUTINE void _Event_sets_Post( + rtems_event_set the_new_events, + rtems_event_set *the_event_set +) +{ + *the_event_set |= the_new_events; +} + +/** + * @brief Returns the events in event_condition that are set in event_set. + * + * This function returns the events in event_condition which are + * set in event_set. + */ +RTEMS_INLINE_ROUTINE rtems_event_set _Event_sets_Get( + rtems_event_set the_event_set, + rtems_event_set the_event_condition +) +{ + return ( the_event_set & the_event_condition ); +} + +/** + * @brief Removes the events in mask from the event_set passed in. + * + * This function removes the events in mask from the event_set + * passed in. The result is returned to the user in event_set. + */ +RTEMS_INLINE_ROUTINE rtems_event_set _Event_sets_Clear( + rtems_event_set the_event_set, + rtems_event_set the_mask +) +{ + return ( the_event_set & ~(the_mask) ); +} + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#if defined(RTEMS_MULTIPROCESSING) +#include +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/eventmp.h b/cpukit/include/rtems/rtems/eventmp.h new file mode 100644 index 0000000000..a80e60c4e0 --- /dev/null +++ b/cpukit/include/rtems/rtems/eventmp.h @@ -0,0 +1,101 @@ +/** + * @file rtems/rtems/eventmp.h + * + * @defgroup ClassicEventMP Event MP Support + * + * @ingroup ClassicRTEMS + * @brief Event Manager MP Support + * + * This include file contains all the constants and structures associated + * with the Multiprocessing Support in the Event Manager. + */ + +/* COPYRIGHT (c) 1989-2013. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_EVENTMP_H +#define _RTEMS_RTEMS_EVENTMP_H + +#ifndef _RTEMS_RTEMS_EVENTIMPL_H +# error "Never use directly; include instead." +#endif + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicEventMP Event MP Support + * + * @ingroup ClassicMP + * + * This encapsulates functionality related to the transparent multiprocessing + * support within the Classic API Event Manager. + */ +/**@{*/ + +/* + * @brief Event_MP_Send_process_packet + * + * This routine performs a remote procedure call so that a + * process operation can be performed on another node. + * + * @note This routine is not needed since there are no process + * packets to be sent by this manager. + */ + +/** + * @brief Issues a remote rtems_event_send() request. + */ +rtems_status_code _Event_MP_Send( + rtems_id id, + rtems_event_set event_in +); + +/** + * @brief Event MP Packet Process + * + * This routine performs the actions specific to this package for + * the request from another node. + */ +void _Event_MP_Process_packet ( + rtems_packet_prefix *the_packet_prefix +); + +/* + * @brief Event_MP_Send_object_was_deleted + * + * This routine is invoked indirectly by the thread queue + * when a proxy has been removed from the thread queue and + * the remote node must be informed of this. + * + * This routine is not needed since there are no objects + * deleted by this manager. + */ + +/* + * @brief Event_MP_Send_extract_proxy + * + * This routine is invoked when a task is deleted and it + * has a proxy which must be removed from a thread queue and + * the remote node must be informed of this. + * + * This routine is not needed since there are no objects + * deleted by this manager. + */ + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of file */ diff --git a/cpukit/include/rtems/rtems/intr.h b/cpukit/include/rtems/rtems/intr.h new file mode 100644 index 0000000000..7f99d93883 --- /dev/null +++ b/cpukit/include/rtems/rtems/intr.h @@ -0,0 +1,373 @@ +/** + * @file rtems/rtems/intr.h + * + * @defgroup ClassicINTR Interrupts + * + * @ingroup ClassicRTEMS + * @brief Header file for Interrupt Manager + * + * This include file contains all the constants and structures associated with + * the Interrupt Manager. + */ + +/* COPYRIGHT (c) 1989-2013. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_INTR_H +#define _RTEMS_RTEMS_INTR_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +/** + * @defgroup ClassicINTR Interrupts + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality related to the Classic API Interrupt + * Manager. + */ +/**@{*/ + +/** + * @brief Interrupt level type. + */ +typedef ISR_Level rtems_interrupt_level; + +/** + * @brief Control block type used to manage the vectors. + */ +typedef ISR_Vector_number rtems_vector_number; + +/** + * @brief Return type for interrupt handler. + */ +typedef ISR_Handler rtems_isr; + +#if (CPU_SIMPLE_VECTORED_INTERRUPTS == FALSE) + +typedef ISR_Handler_entry rtems_isr_entry; + +#else +/** + * @brief Interrupt handler type. + * + * @see rtems_interrupt_catch() + */ +typedef rtems_isr ( *rtems_isr_entry )( + rtems_vector_number + ); + +/** + * @brief RTEMS Interrupt Catch + * + * This directive installs @a new_isr_handler as the RTEMS interrupt service + * routine for the interrupt vector with number @a vector. The previous RTEMS + * interrupt service routine is returned in @a old_isr_handler. + * + * @param[in] new_isr_handler is the address of interrupt service routine + * @param[in] vector is the interrupt vector number + * @param[in] old_isr_handler address at which to store previous ISR address + * + * @retval RTEMS_SUCCESSFUL and *old_isr_handler filled with previous ISR + * address + */ +rtems_status_code rtems_interrupt_catch( + rtems_isr_entry new_isr_handler, + rtems_vector_number vector, + rtems_isr_entry *old_isr_handler +); +#endif + +#if !defined(RTEMS_SMP) + +/** + * @brief Disable RTEMS Interrupt + * + * @note The interrupt level shall be of type @ref rtems_interrupt_level. + * + * This macro is only available on uni-processor configurations. The macro + * rtems_interrupt_local_disable() is available on all configurations. + */ +#define rtems_interrupt_disable( _isr_cookie ) \ + _ISR_Local_disable(_isr_cookie) + +/** + * @brief Enable RTEMS Interrupt + * + * @note The interrupt level shall be of type @ref rtems_interrupt_level. + * + * This macro is only available on uni-processor configurations. The macro + * rtems_interrupt_local_enable() is available on all configurations. + */ +#define rtems_interrupt_enable( _isr_cookie ) \ + _ISR_Local_enable(_isr_cookie) + +/** + * @brief Flash RTEMS Interrupt + * + * @note The interrupt level shall be of type @ref rtems_interrupt_level. + * + * This macro is only available on uni-processor configurations. The macro + * rtems_interrupt_local_disable() and rtems_interrupt_local_enable() is + * available on all configurations. + */ +#define rtems_interrupt_flash( _isr_cookie ) \ + _ISR_Local_flash(_isr_cookie) + +#endif /* RTEMS_SMP */ + +/** + * @brief This macro disables the interrupts on the current processor. + * + * On SMP configurations this will not ensure system wide mutual exclusion. + * Use interrupt locks instead. + * + * @param[in] _isr_cookie The previous interrupt level is returned. The type + * of this variable must be rtems_interrupt_level. + * + * @see rtems_interrupt_local_enable(). + */ +#define rtems_interrupt_local_disable( _isr_cookie ) \ + _ISR_Local_disable( _isr_cookie ) + +/** + * @brief This macro restores the previous interrupt level on the current + * processor. + * + * @param[in] _isr_cookie The previous interrupt level returned by + * rtems_interrupt_local_disable(). + */ +#define rtems_interrupt_local_enable( _isr_cookie ) \ + _ISR_Local_enable( _isr_cookie ) + +/** + * @brief RTEMS Interrupt Is in Progress + * + * A return value of true indicates that the caller is an interrupt service + * routine and @b not a thread. The directives available to an interrupt + * service routine are restricted. + */ +#define rtems_interrupt_is_in_progress() \ + _ISR_Is_in_progress() + +/** + * @brief This routine generates an interrupt. + * + * @note No implementation. + */ +#define rtems_interrupt_cause( _interrupt_to_cause ) + +/** + * @brief This routine clears the specified interrupt. + * + * @note No implementation. + */ +#define rtems_interrupt_clear( _interrupt_to_clear ) + +/** + * @defgroup ClassicINTRLocks Interrupt Locks + * + * @ingroup ClassicINTR + * + * @brief Low-level lock to protect critical sections accessed by threads and + * interrupt service routines. + * + * On single processor configurations the interrupt locks degrade to simple + * interrupt disable/enable sequences. No additional storage or objects are + * required. + * + * This synchronization primitive is supported on SMP configurations. Here SMP + * locks are used. + * @{ + */ + +/** + * @brief Interrupt lock control. + */ +typedef ISR_lock_Control rtems_interrupt_lock; + +/** + * @brief Local interrupt lock context for acquire and release pairs. + */ +typedef ISR_lock_Context rtems_interrupt_lock_context; + +/** + * @brief Defines an interrupt lock member. + * + * Do not add a ';' after this macro. + * + * @param _designator The designator for the interrupt lock. + */ +#define RTEMS_INTERRUPT_LOCK_MEMBER( _designator ) \ + ISR_LOCK_MEMBER( _designator ) + +/** + * @brief Declares an interrupt lock variable. + * + * Do not add a ';' after this macro. + * + * @param _qualifier The qualifier for the interrupt lock, e.g. extern. + * @param _designator The designator for the interrupt lock. + */ +#define RTEMS_INTERRUPT_LOCK_DECLARE( _qualifier, _designator ) \ + ISR_LOCK_DECLARE( _qualifier, _designator ) + +/** + * @brief Defines an interrupt lock variable. + * + * Do not add a ';' after this macro. + * + * @param _qualifier The qualifier for the interrupt lock, e.g. static. + * @param _designator The designator for the interrupt lock. + * @param _name The name for the interrupt lock. It must be a string. The + * name is only used if profiling is enabled. + */ +#define RTEMS_INTERRUPT_LOCK_DEFINE( _qualifier, _designator, _name ) \ + ISR_LOCK_DEFINE( _qualifier, _designator, _name ) + +/** + * @brief Defines an interrupt lock variable reference. + * + * Do not add a ';' after this macro. + * + * @param _designator The designator for the interrupt lock reference. + * @param _target The target for the interrupt lock reference. + */ +#define RTEMS_INTERRUPT_LOCK_REFERENCE( _designator, _target ) \ + ISR_LOCK_REFERENCE( _designator, _target ) + +/** + * @brief Initializer for static initialization of interrupt locks. + * + * @param _name The name for the interrupt lock. It must be a string. The + * name is only used if profiling is enabled. + */ +#define RTEMS_INTERRUPT_LOCK_INITIALIZER( _name ) ISR_LOCK_INITIALIZER( _name ) + +/** + * @brief Initializes an interrupt lock. + * + * Concurrent initialization leads to unpredictable results. + * + * @param[in,out] _lock The interrupt lock. + * @param[in] _name The name for the interrupt lock. This name must be a + * string persistent throughout the life time of this lock. The name is only + * used if profiling is enabled. + */ +#define rtems_interrupt_lock_initialize( _lock, _name ) \ + _ISR_lock_Initialize( _lock, _name ) + +/** + * @brief Destroys an interrupt lock. + * + * Concurrent destruction leads to unpredictable results. + * + * @param[in,out] _lock The interrupt lock control. + */ +#define rtems_interrupt_lock_destroy( _lock ) \ + _ISR_lock_Destroy( _lock ) + +/** + * @brief Disables interrupts on the current processor. + * + * This function can be used in thread and interrupt context. + * + * @param[in,out] _lock_context The local interrupt lock context for an acquire + * and release pair. + * + * @see rtems_interrupt_lock_acquire_isr(). + */ +#define rtems_interrupt_lock_interrupt_disable( _lock_context ) \ + _ISR_lock_ISR_disable( _lock_context ) + +/** + * @brief Acquires an interrupt lock. + * + * Interrupts will be disabled. On SMP configurations this function acquires + * an SMP lock. + * + * This function can be used in thread and interrupt context. + * + * @param[in,out] _lock The interrupt lock. + * @param[in,out] _lock_context The local interrupt lock context for an acquire + * and release pair. + * + * @see rtems_interrupt_lock_release(). + */ +#define rtems_interrupt_lock_acquire( _lock, _lock_context ) \ + _ISR_lock_ISR_disable_and_acquire( _lock, _lock_context ) + +/** + * @brief Releases an interrupt lock. + * + * The interrupt status will be restored. On SMP configurations this function + * releases an SMP lock. + * + * This function can be used in thread and interrupt context. + * + * @param[in,out] _lock The interrupt lock. + * @param[in,out] _lock_context The local interrupt lock context for an acquire + * and release pair. + * + * @see rtems_interrupt_lock_acquire(). + */ +#define rtems_interrupt_lock_release( _lock, _lock_context ) \ + _ISR_lock_Release_and_ISR_enable( _lock, _lock_context ) + +/** + * @brief Acquires an interrupt lock in the corresponding interrupt service + * routine. + * + * The interrupt status will remain unchanged. On SMP configurations this + * function acquires an SMP lock. + * + * In case the corresponding interrupt service routine can be interrupted by + * higher priority interrupts and these interrupts enter the critical section + * protected by this lock, then the result is unpredictable. + * + * @param[in,out] _lock The interrupt lock. + * @param[in,out] _lock_context The local interrupt lock context for an acquire + * and release pair. + * + * @see rtems_interrupt_lock_release_isr(). + */ +#define rtems_interrupt_lock_acquire_isr( _lock, _lock_context ) \ + _ISR_lock_Acquire( _lock, _lock_context ) + +/** + * @brief Releases an interrupt lock in the corresponding interrupt service + * routine. + * + * The interrupt status will remain unchanged. On SMP configurations this + * function releases an SMP lock. + * + * @param[in,out] _lock The interrupt lock. + * @param[in,out] _lock_context The local interrupt lock context for an acquire + * and release pair. + * + * @see rtems_interrupt_lock_acquire_isr(). + */ +#define rtems_interrupt_lock_release_isr( _lock, _lock_context ) \ + _ISR_lock_Release( _lock, _lock_context ) + +/** @} */ + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/mainpage.h b/cpukit/include/rtems/rtems/mainpage.h new file mode 100644 index 0000000000..e2d51328cf --- /dev/null +++ b/cpukit/include/rtems/rtems/mainpage.h @@ -0,0 +1,927 @@ +/** + * @file rtems/rtems/mainpage.h + * + * This file exists to provide a top level description of RTEMS for Doxygen. + */ + +/* + * COPYRIGHT (c) 1989-2014. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +/** + * @mainpage + * + * The RTEMS real-time operating systems is a layered system with each of the + * public APIs implemented in terms of a common foundation layer called the + * SuperCore. This is the Doxygen generated documentation for the RTEMS CPU + * Kit including the Classic API, POSIX API and SuperCore. + */ + +/** + * @page RTEMSPreface RTEMS History and Introduction + * + * In recent years, the cost required to develop a software product has + * increased significantly while the target hardware costs have decreased. Now + * a larger portion of money is expended in developing, using, and maintaining + * software. The trend in computing costs is the complete dominance of software + * over hardware costs. Because of this, it is necessary that formal + * disciplines be established to increase the probability that software is + * characterized by a high degree of correctness, maintainability, and + * portability. In addition, these disciplines must promote practices that aid + * in the consistent and orderly development of a software system within + * schedule and budgetary constraints. To be effective, these disciplines must + * adopt standards which channel individual software efforts toward a common + * goal. + * + * The push for standards in the software development field has been met with + * various degrees of success. The Microprocessor Operating Systems Interfaces + * (MOSI) effort has experienced only limited success. As popular as the UNIX + * operating system has grown, the attempt to develop a standard interface + * definition to allow portable application development has only recently begun + * to produce the results needed in this area. Unfortunately, very little + * effort has been expended to provide standards addressing the needs of the + * real-time community. Several organizations have addressed this need during + * recent years. + * + * The Real Time Executive Interface Definition (RTEID) was developed by + * Motorola with technical input from Software Components Group. RTEID was + * adopted by the VMEbus International Trade Association (VITA) as a baseline + * draft for their proposed standard multiprocessor, real-time executive + * interface, Open Real-Time Kernel Interface Definition (ORKID). These two + * groups are currently working together with the IEEE P1003.4 committee to + * insure that the functionality of their proposed standards is adopted as the + * real-time extensions to POSIX. + * + * This emerging standard defines an interface for the development of real-time + * software to ease the writing of real-time application programs that are + * directly portable across multiple real-time executive implementations. This + * interface includes both the source code interfaces and run-time behavior as + * seen by a real-time application. It does not include the details of how a + * kernel implements these functions. The standard's goal is to serve as a + * complete definition of external interfaces so that application code that + * conforms to these interfaces will execute properly in all real-time + * executive environments. With the use of a standards compliant executive, + * routines that acquire memory blocks, create and manage message queues, + * establish and use semaphores, and send and receive signals need not be + * redeveloped for a different real-time environment as long as the new + * environment is compliant with the standard. Software developers need only + * concentrate on the hardware dependencies of the real-time system. + * Furthermore, most hardware dependencies for real-time applications can be + * localized to the device drivers. + * + * A compliant executive provides simple and flexible real-time + * multiprocessing. It easily lends itself to both tightly-coupled and + * loosely-coupled configurations (depending on the system hardware + * configuration). Objects such as tasks, queues, events, signals, semaphores, + * and memory blocks can be designated as global objects and accessed by any + * task regardless of which processor the object and the accessing task reside. + * + * The acceptance of a standard for real-time executives will produce the same + * advantages enjoyed from the push for UNIX standardization by AT&T's System V + * Interface Definition and IEEE's POSIX efforts. A compliant multiprocessing + * executive will allow close coupling between UNIX systems and real-time + * executives to provide the many benefits of the UNIX development environment + * to be applied to real-time software development. Together they provide the + * necessary laboratory environment to implement real-time, distributed, + * embedded systems using a wide variety of computer architectures. + * + * A study was completed in 1988, within the Research, Development, and + * Engineering Center, U.S. Army Missile Command, which compared the various + * aspects of the Ada programming language as they related to the application + * of Ada code in distributed and/or multiple processing systems. Several + * critical conclusions were derived from the study. These conclusions have a + * major impact on the way the Army develops application software for embedded + * applications. These impacts apply to both in-house software development and + * contractor developed software. + * + * A conclusion of the analysis, which has been previously recognized by other + * agencies attempting to utilize Ada in a distributed or multiprocessing + * environment, is that the Ada programming language does not adequately + * support multiprocessing. Ada does provide a mechanism for multi-tasking, + * however, this capability exists only for a single processor system. The + * language also does not have inherent capabilities to access global named + * variables, flags or program code. These critical features are essential in + * order for data to be shared between processors. However, these drawbacks do + * have workarounds which are sometimes awkward and defeat the intent of + * software maintainability and portability goals. + * + * Another conclusion drawn from the analysis, was that the run time executives + * being delivered with the Ada compilers were too slow and inefficient to be + * used in modern missile systems. A run time executive is the core part of the + * run time system code, or operating system code, that controls task + * scheduling, input/output management and memory management. Traditionally, + * whenever efficient executive (also known as kernel) code was required by the + * application, the user developed in-house software. This software was usually + * written in assembly language for optimization. + * + * Because of this shortcoming in the Ada programming language, software + * developers in research and development and contractors for project managed + * systems, are mandated by technology to purchase and utilize off-the-shelf + * third party kernel code. The contractor, and eventually the Government, must + * pay a licensing fee for every copy of the kernel code used in an embedded + * system. + * + * The main drawback to this development environment is that the Government + * does not own, nor has the right to modify code contained within the kernel. + * V&V techniques in this situation are more difficult than if the complete + * source code were available. Responsibility for system failures due to faulty + * software is yet another area to be resolved under this environment. + * + * The Guidance and Control Directorate began a software development effort to + * address these problems. A project to develop an experimental run time kernel + * was begun that will eliminate the major drawbacks of the Ada programming + * language mentioned above. The Real Time Executive for Multiprocessor Systems + * (RTEMS) provides full capabilities for management of tasks, interrupts, + * time, and multiple processors in addition to those features typical of + * generic operating systems. The code is Government owned, so no licensing + * fees are necessary. RTEMS has been implemented in both the Ada and C + * programming languages. It has been ported to the following processor + * families: + * + * - Altera NIOS II + * - Analog Devices Blackfin + * - ARM + * - Freescale (formerly Motorola) MC68xxx + * - Freescale (formerly Motorola) MC683xx + * - Freescale (formerly Motorola) ColdFire + * - Intel i386 and above + * - Lattice Semiconductor LM32 + * - MIPS + * - PowerPC + * - Renesas (formerly Hitachi) SuperH + * - Renesas (formerly Hitachi) H8/300 + * - SPARC + * - Texas Instruments C3x/C4x + * - UNIX + * + * Support for other processor families, including RISC, CISC, and DSP, is + * planned. Since almost all of RTEMS is written in a high level language, + * ports to additional processor families require minimal effort. + * + * RTEMS multiprocessor support is capable of handling either homogeneous or + * heterogeneous systems. The kernel automatically compensates for + * architectural differences (byte swapping, etc.) between processors. This + * allows a much easier transition from one processor family to another without + * a major system redesign. + * + * Since the proposed standards are still in draft form, RTEMS cannot and does + * not claim compliance. However, the status of the standard is being carefully + * monitored to guarantee that RTEMS provides the functionality specified in + * the standard. Once approved, RTEMS will be made compliant. + */ + +/** + * @page RTEMSOverview RTEMS Overview + * + * @section RTEMSOverviewSecIntroduction Introduction + * + * RTEMS, Real-Time Executive for Multiprocessor Systems, is a real-time + * executive (kernel) which provides a high performance environment for + * embedded military applications including the following features: + * + * - multitasking capabilities + * - homogeneous and heterogeneous multiprocessor systems + * - event-driven, priority-based, preemptive scheduling + * - optional rate monotonic scheduling + * - intertask communication and synchronization + * - priority inheritance + * - responsive interrupt management + * - dynamic memory allocation + * - high level of user configurability + * + * This manual describes the usage of RTEMS for applications written in the C + * programming language. Those implementation details that are processor + * dependent are provided in the Applications Supplement documents. A + * supplement document which addresses specific architectural issues that + * affect RTEMS is provided for each processor type that is supported. + * + * @section RTEMSOverviewSecRealtimeApplicationSystems Real-time Application Systems + * + * Real-time application systems are a special class of computer applications. + * They have a complex set of characteristics that distinguish them from other + * software problems. Generally, they must adhere to more rigorous + * requirements. The correctness of the system depends not only on the results + * of computations, but also on the time at which the results are produced. The + * most important and complex characteristic of real-time application systems + * is that they must receive and respond to a set of external stimuli within + * rigid and critical time constraints referred to as deadlines. Systems can be + * buried by an avalanche of interdependent, asynchronous or cyclical event + * streams. + * + * Deadlines can be further characterized as either hard or soft based upon the + * value of the results when produced after the deadline has passed. A deadline + * is hard if the results have no value or if their use will result in a + * catastrophic event. In contrast, results which are produced after a soft + * deadline may have some value. + * + * Another distinguishing requirement of real-time application systems is the + * ability to coordinate or manage a large number of concurrent activities. + * Since software is a synchronous entity, this presents special problems. One + * instruction follows another in a repeating synchronous cycle. Even though + * mechanisms have been developed to allow for the processing of external + * asynchronous events, the software design efforts required to process and + * manage these events and tasks are growing more complicated. + * + * The design process is complicated further by spreading this activity over a + * set of processors instead of a single processor. The challenges associated + * with designing and building real-time application systems become very + * complex when multiple processors are involved. New requirements such as + * interprocessor communication channels and global resources that must be + * shared between competing processors are introduced. The ramifications of + * multiple processors complicate each and every characteristic of a real-time + * system. + * + * @section RTEMSOverviewSecRealtimeExecutive Real-time Executive + * + * Fortunately, real-time operating systems or real-time executives serve as a + * cornerstone on which to build the application system. A real-time + * multitasking executive allows an application to be cast into a set of + * logical, autonomous processes or tasks which become quite manageable. Each + * task is internally synchronous, but different tasks execute independently, + * resulting in an asynchronous processing stream. Tasks can be dynamically + * paused for many reasons resulting in a different task being allowed to + * execute for a period of time. The executive also provides an interface to + * other system components such as interrupt handlers and device drivers. + * System components may request the executive to allocate and coordinate + * resources, and to wait for and trigger synchronizing conditions. The + * executive system calls effectively extend the CPU instruction set to support + * efficient multitasking. By causing tasks to travel through well-defined + * state transitions, system calls permit an application to demand-switch + * between tasks in response to real-time events. + * + * By proper grouping of responses to stimuli into separate tasks, a system can + * now asynchronously switch between independent streams of execution, directly + * responding to external stimuli as they occur. This allows the system design + * to meet critical performance specifications which are typically measured by + * guaranteed response time and transaction throughput. The multiprocessor + * extensions of RTEMS provide the features necessary to manage the extra + * requirements introduced by a system distributed across several processors. + * It removes the physical barriers of processor boundaries from the world of + * the system designer, enabling more critical aspects of the system to receive + * the required attention. Such a system, based on an efficient real-time, + * multiprocessor executive, is a more realistic model of the outside world or + * environment for which it is designed. As a result, the system will always be + * more logical, efficient, and reliable. + * + * By using the directives provided by RTEMS, the real-time applications + * developer is freed from the problem of controlling and synchronizing + * multiple tasks and processors. In addition, one need not develop, test, + * debug, and document routines to manage memory, pass messages, or provide + * mutual exclusion. The developer is then able to concentrate solely on the + * application. By using standard software components, the time and cost + * required to develop sophisticated real-time applications is significantly + * reduced. + * + * @section RTEMSOverviewSecApplicationArchitecture RTEMS Application Architecture + * + * One important design goal of RTEMS was to provide a bridge between two + * critical layers of typical real-time systems. As shown in the following + * figure, RTEMS serves as a buffer between the project dependent application + * code and the target hardware. Most hardware dependencies for real-time + * applications can be localized to the low level device drivers. + * + * @todo Image RTEMS Application Architecture + * + * The RTEMS I/O interface manager provides an efficient tool for incorporating + * these hardware dependencies into the system while simultaneously providing a + * general mechanism to the application code that accesses them. A well + * designed real-time system can benefit from this architecture by building a + * rich library of standard application components which can be used repeatedly + * in other real-time projects. + * + * @section RTEMSOverviewSecInternalArchitecture RTEMS Internal Architecture + * + * RTEMS can be viewed as a set of layered components that work in harmony to + * provide a set of services to a real-time application system. The executive + * interface presented to the application is formed by grouping directives into + * logical sets called resource managers. Functions utilized by multiple + * managers such as scheduling, dispatching, and object management are provided + * in the executive core. The executive core depends on a small set of CPU + * dependent routines. Together these components provide a powerful run time + * environment that promotes the development of efficient real-time application + * systems. The following figure illustrates this organization: + * + * @todo Image RTEMS Architecture + * + * Subsequent chapters present a detailed description of the capabilities + * provided by each of the following RTEMS managers: + * + * - initialization + * - task + * - interrupt + * - clock + * - timer + * - semaphore + * - message + * - event + * - signal + * - partition + * - region + * - dual ported memory + * - I/O + * - fatal error + * - rate monotonic + * - user extensions + * - multiprocessing + * + * @section RTEMSOverviewSecUserCustomization User Customization and Extensibility + * + * As 32-bit microprocessors have decreased in cost, they have become + * increasingly common in a variety of embedded systems. A wide range of custom + * and general-purpose processor boards are based on various 32-bit + * processors. RTEMS was designed to make no assumptions concerning the + * characteristics of individual microprocessor families or of specific support + * hardware. In addition, RTEMS allows the system developer a high degree of + * freedom in customizing and extending its features. + * + * RTEMS assumes the existence of a supported microprocessor and sufficient + * memory for both RTEMS and the real-time application. Board dependent + * components such as clocks, interrupt controllers, or I/O devices can be + * easily integrated with RTEMS. The customization and extensibility features + * allow RTEMS to efficiently support as many environments as possible. + * + * @section RTEMSOverviewSecPortability Portability + * + * The issue of portability was the major factor in the creation of RTEMS. + * Since RTEMS is designed to isolate the hardware dependencies in the specific + * board support packages, the real-time application should be easily ported to + * any other processor. The use of RTEMS allows the development of real-time + * applications which can be completely independent of a particular + * microprocessor architecture. + * + * @section RTEMSOverviewSecMemoryRequirements Memory Requirements + * + * Since memory is a critical resource in many real-time embedded systems, + * RTEMS was specifically designed to automatically leave out all services that + * are not required from the run-time environment. Features such as networking, + * various fileystems, and many other features are completely optional. This + * allows the application designer the flexibility to tailor RTEMS to most + * efficiently meet system requirements while still satisfying even the most + * stringent memory constraints. As a result, the size of the RTEMS executive + * is application dependent. + * + * RTEMS requires RAM to manage each instance of an RTEMS object that is + * created. Thus the more RTEMS objects an application needs, the more memory + * that must be reserved. See Configuring a System Determining Memory + * Requirements for more details. + * + * @todo Link to Configuring a SystemDetermining Memory Requirements + * + * RTEMS utilizes memory for both code and data space. Although RTEMS' data + * space must be in RAM, its code space can be located in either ROM or RAM. + * + * @section RTEMSOverviewSecAudience Audience + * + * This manual was written for experienced real-time software developers. + * Although some background is provided, it is assumed that the reader is + * familiar with the concepts of task management as well as intertask + * communication and synchronization. Since directives, user related data + * structures, and examples are presented in C, a basic understanding of the C + * programming language is required to fully understand the material presented. + * However, because of the similarity of the Ada and C RTEMS implementations, + * users will find that the use and behavior of the two implementations is very + * similar. A working knowledge of the target processor is helpful in + * understanding some of RTEMS' features. A thorough understanding of the + * executive cannot be obtained without studying the entire manual because many + * of RTEMS' concepts and features are interrelated. Experienced RTEMS users + * will find that the manual organization facilitates its use as a reference + * document. + */ + +/** + * @addtogroup ClassicAPI + * + * The facilities provided by RTEMS are built upon a foundation of very + * powerful concepts. These concepts must be understood before the application + * developer can efficiently utilize RTEMS. The purpose of this chapter is to + * familiarize one with these concepts. + * + * @section ClassicRTEMSSecObjects Objects + * + * RTEMS provides directives which can be used to dynamically create, delete, + * and manipulate a set of predefined object types. These types include tasks, + * message queues, semaphores, memory regions, memory partitions, timers, + * ports, and rate monotonic periods. The object-oriented nature of RTEMS + * encourages the creation of modular applications built upon re-usable + * "building block" routines. + * + * All objects are created on the local node as required by the application and + * have an RTEMS assigned ID. All objects have a user-assigned name. Although a + * relationship exists between an object's name and its RTEMS assigned ID, the + * name and ID are not identical. Object names are completely arbitrary and + * selected by the user as a meaningful "tag" which may commonly reflect the + * object's use in the application. Conversely, object IDs are designed to + * facilitate efficient object manipulation by the executive. + * + * @subsection ClassicRTEMSSubSecObjectNames Object Names + * + * An object name is an unsigned 32-bit entity associated with the + * object by the user. The data type @ref rtems_name is used to store object names. + * + * Although not required by RTEMS, object names are often composed of four + * ASCII characters which help identify that object. For example, a task which + * causes a light to blink might be called "LITE". The rtems_build_name() + * routine is provided to build an object name from four ASCII characters. The + * following example illustrates this: + * + * @code + * rtems_name my_name = rtems_build_name('L', 'I', 'T', 'E'); + * @endcode + * + * However, it is not required that the application use ASCII characters to + * build object names. For example, if an application requires one-hundred + * tasks, it would be difficult to assign meaningful ASCII names to each task. + * A more convenient approach would be to name them the binary values one + * through one-hundred, respectively. + * + * RTEMS provides a helper routine, rtems_object_get_name(), which can be used to + * obtain the name of any RTEMS object using just its ID. This routine attempts + * to convert the name into a printable string. + * + * @subsection ClassicRTEMSSubSecObjectIdentifiers Object Identifiers + * + * An object ID is a unique unsigned integer value which uniquely identifies an + * object instance. Object IDs are passed as arguments to many directives in + * RTEMS and RTEMS translates the ID to an internal object pointer. The + * efficient manipulation of object IDs is critical to the performance of RTEMS + * services. Because of this, there are two object ID formats defined. Each + * target architecture specifies which format it will use. There is a 32-bit + * format which is used for most of the supported architectures and supports + * multiprocessor configurations. There is also a simpler 16-bit format which + * is appropriate for smaller target architectures and does not support + * multiprocessor configurations. + * + * @subsubsection ClassicRTEMSSubSec32BitObjectIdentifierFormat 32-Bit Object Identifier Format + * + * The 32-bit format for an object ID is composed of four parts: API, + * object class, node, and index. The data type @ref rtems_id is used to store + * object IDs. + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Bits3130292827262524232221201918171615141312111009080706050403020100
ContentsClassAPINodeObject Index
+ * + * The most significant five bits are the object class. The next three bits + * indicate the API to which the object class belongs. The next eight bits + * (16 .. 23) are the number of the node on which this object was created. The + * node number is always one (1) in a single processor system. The least + * significant 16-bits form an identifier within a particular object type. + * This identifier, called the object index, ranges in value from one to the + * maximum number of objects configured for this object type. + * + * @subsubsection ClassicRTEMSSubSec16BitObjectIdentifierFormat 16-Bit Object Identifier Format + * + * The 16-bit format for an object ID is composed of three parts: API, object + * class, and index. The data type @ref rtems_id is used to store object IDs. + * + * + * + * + * + * + * + * + * + * + * + *
Bits15141312111009080706050403020100
ContentsClassAPIObject Index
+ * + * The 16-bit format is designed to be as similar as possible to the 32-bit + * format. The differences are limited to the eliminatation of the node field + * and reduction of the index field from 16-bits to 8-bits. Thus the 16-bit + * format only supports up to 255 object instances per API/Class combination + * and single processor systems. As this format is typically utilized by 16-bit + * processors with limited address space, this is more than enough object + * instances. + * + * @subsection ClassicRTEMSSubSecObjectIdentiferDescription Object Identifer Description + * + * The components of an object ID make it possible to quickly locate any object + * in even the most complicated multiprocessor system. Object ID's are + * associated with an object by RTEMS when the object is created and the + * corresponding ID is returned by the appropriate object create directive. The + * object ID is required as input to all directives involving objects, except + * those which create an object or obtain the ID of an object. + * + * The object identification directives can be used to dynamically obtain a + * particular object's ID given its name. This mapping is accomplished by + * searching the name table associated with this object type. If the name is + * non-unique, then the ID associated with the first occurrence of the name + * will be returned to the application. Since object IDs are returned when the + * object is created, the object identification directives are not necessary in + * a properly designed single processor application. + * + * In addition, services are provided to portably examine the subcomponents of + * an RTEMS ID. These services are described in detail later in this manual but + * are prototyped as follows: + * + * - rtems_object_id_get_api() + * - rtems_object_id_get_class() + * - rtems_object_id_get_node() + * - rtems_object_id_get_index() + * + * An object control block is a data structure defined by RTEMS which contains + * the information necessary to manage a particular object type. For efficiency + * reasons, the format of each object type's control block is different. + * However, many of the fields are similar in function. The number of each type + * of control block is application dependent and determined by the values + * specified in the user's Configuration Table. An object control block is + * allocated at object create time and freed when the object is deleted. With + * the exception of user extension routines, object control blocks are not + * directly manipulated by user applications. + * + * @section ClassicRTEMSSecComSync Communication and Synchronization + * + * In real-time multitasking applications, the ability for cooperating + * execution threads to communicate and synchronize with each other is + * imperative. A real-time executive should provide an application with the + * following capabilities + * + * - data transfer between cooperating tasks, + * - data transfer between tasks and ISRs, + * - synchronization of cooperating tasks, and + * - synchronization of tasks and ISRs. + * + * Most RTEMS managers can be used to provide some form of communication and/or + * synchronization. However, managers dedicated specifically to communication + * and synchronization provide well established mechanisms which directly map + * to the application's varying needs. This level of flexibility allows the + * application designer to match the features of a particular manager with the + * complexity of communication and synchronization required. The following + * managers were specifically designed for communication and synchronization: + * + * - @ref ClassicSem + * - @ref ClassicMessageQueue + * - @ref ClassicEvent + * - @ref ClassicSignal + * + * The semaphore manager supports mutual exclusion involving the + * synchronization of access to one or more shared user resources. Binary + * semaphores may utilize the optional priority inheritance algorithm to avoid + * the problem of priority inversion. The message manager supports both + * communication and synchronization, while the event manager primarily + * provides a high performance synchronization mechanism. The signal manager + * supports only asynchronous communication and is typically used for exception + * handling. + * + * @section ClassicRTEMSSecTime Time + * + * The development of responsive real-time applications requires an + * understanding of how RTEMS maintains and supports time-related operations. + * The basic unit of time in RTEMS is known as a tick. The frequency of clock + * ticks is completely application dependent and determines the granularity and + * accuracy of all interval and calendar time operations. + * + * By tracking time in units of ticks, RTEMS is capable of supporting interval + * timing functions such as task delays, timeouts, timeslicing, the delayed + * execution of timer service routines, and the rate monotonic scheduling of + * tasks. An interval is defined as a number of ticks relative to the current + * time. For example, when a task delays for an interval of ten ticks, it is + * implied that the task will not execute until ten clock ticks have occurred. + * All intervals are specified using data type @ref rtems_interval. + * + * A characteristic of interval timing is that the actual interval period may + * be a fraction of a tick less than the interval requested. This occurs + * because the time at which the delay timer is set up occurs at some time + * between two clock ticks. Therefore, the first countdown tick occurs in less + * than the complete time interval for a tick. This can be a problem if the + * clock granularity is large. + * + * The rate monotonic scheduling algorithm is a hard real-time scheduling + * methodology. This methodology provides rules which allows one to guarantee + * that a set of independent periodic tasks will always meet their deadlines -- + * even under transient overload conditions. The rate monotonic manager + * provides directives built upon the Clock Manager's interval timer support + * routines. + * + * Interval timing is not sufficient for the many applications which require + * that time be kept in wall time or true calendar form. Consequently, RTEMS + * maintains the current date and time. This allows selected time operations to + * be scheduled at an actual calendar date and time. For example, a task could + * request to delay until midnight on New Year's Eve before lowering the ball + * at Times Square. The data type @ref rtems_time_of_day is used to specify + * calendar time in RTEMS services. See Clock Manager Time and Date Data + * Structures. + * + * @todo Link to Clock Manager Time and Date Data Structures + * + * Obviously, the directives which use intervals or wall time cannot operate + * without some external mechanism which provides a periodic clock tick. This + * clock tick is typically provided by a real time clock or counter/timer + * device. + * + * @section ClassicRTEMSSecMemoryManagement Memory Management + * + * RTEMS memory management facilities can be grouped into two classes: dynamic + * memory allocation and address translation. Dynamic memory allocation is + * required by applications whose memory requirements vary through the + * application's course of execution. Address translation is needed by + * applications which share memory with another CPU or an intelligent + * Input/Output processor. The following RTEMS managers provide facilities to + * manage memory: + * + * - @ref ClassicRegion + * - @ref ClassicPart + * - @ref ClassicDPMEM + * + * RTEMS memory management features allow an application to create simple + * memory pools of fixed size buffers and/or more complex memory pools of + * variable size segments. The partition manager provides directives to manage + * and maintain pools of fixed size entities such as resource control blocks. + * Alternatively, the region manager provides a more general purpose memory + * allocation scheme that supports variable size blocks of memory which are + * dynamically obtained and freed by the application. The dual-ported memory + * manager provides executive support for address translation between internal + * and external dual-ported RAM address space. + */ + +/** + * @addtogroup ClassicTasks + * + * @section ClassicTasksSecTaskDefinition Task Definition + * + * Many definitions of a task have been proposed in computer literature. + * Unfortunately, none of these definitions encompasses all facets of the + * concept in a manner which is operating system independent. Several of the + * more common definitions are provided to enable each user to select a + * definition which best matches their own experience and understanding of the + * task concept: + * + * - a "dispatchable" unit. + * - an entity to which the processor is allocated. + * - an atomic unit of a real-time, multiprocessor system. + * - single threads of execution which concurrently compete for resources. + * - a sequence of closely related computations which can execute concurrently + * with other computational sequences. + * + * From RTEMS' perspective, a task is the smallest thread of execution which + * can compete on its own for system resources. A task is manifested by the + * existence of a task control block (TCB). + * + * @section ClassicTasksSecTaskControlBlock Task Control Block + * + * The Task Control Block (TCB) is an RTEMS defined data structure which + * contains all the information that is pertinent to the execution of a task. + * During system initialization, RTEMS reserves a TCB for each task configured. + * A TCB is allocated upon creation of the task and is returned to the TCB free + * list upon deletion of the task. + * + * The TCB's elements are modified as a result of system calls made by the + * application in response to external and internal stimuli. TCBs are the only + * RTEMS internal data structure that can be accessed by an application via + * user extension routines. The TCB contains a task's name, ID, current + * priority, current and starting states, execution mode, TCB user extension + * pointer, scheduling control structures, as well as data required by a + * blocked task. + * + * A task's context is stored in the TCB when a task switch occurs. When the + * task regains control of the processor, its context is restored from the TCB. + * When a task is restarted, the initial state of the task is restored from the + * starting context area in the task's TCB. + * + * @section ClassicTasksSecTaskStates Task States + * + * A task may exist in one of the following five states: + * + * - executing - Currently scheduled to the CPU + * - ready - May be scheduled to the CPU + * - blocked - Unable to be scheduled to the CPU + * - dormant - Created task that is not started + * - non-existent - Uncreated or deleted task + * + * An active task may occupy the executing, ready, blocked or dormant state, + * otherwise the task is considered non-existent. One or more tasks may be + * active in the system simultaneously. Multiple tasks communicate, + * synchronize, and compete for system resources with each other via system + * calls. The multiple tasks appear to execute in parallel, but actually each + * is dispatched to the CPU for periods of time determined by the RTEMS + * scheduling algorithm. The scheduling of a task is based on its current state + * and priority. + * + * @section ClassicTasksSecTaskPriority Task Priority + * + * A task's priority determines its importance in relation to the other tasks + * executing on the same processor. RTEMS supports 255 levels of priority + * ranging from 1 to 255. The data type rtems_task_priority() is used to store + * task priorities. + * + * Tasks of numerically smaller priority values are more important tasks than + * tasks of numerically larger priority values. For example, a task at priority + * level 5 is of higher privilege than a task at priority level 10. There is no + * limit to the number of tasks assigned to the same priority. + * + * Each task has a priority associated with it at all times. The initial value + * of this priority is assigned at task creation time. The priority of a task + * may be changed at any subsequent time. + * + * Priorities are used by the scheduler to determine which ready task will be + * allowed to execute. In general, the higher the logical priority of a task, + * the more likely it is to receive processor execution time. + * + * @section ClassicTasksSecTaskMode Task Mode + * + * A task's execution mode is a combination of the following four components: + * + * - preemption + * - ASR processing + * - timeslicing + * - interrupt level + * + * It is used to modify RTEMS' scheduling process and to alter the execution + * environment of the task. The data type rtems_task_mode() is used to manage + * the task execution mode. + * + * The preemption component allows a task to determine when control of the + * processor is relinquished. If preemption is disabled (@c + * RTEMS_NO_PREEMPT), the task will retain control of the + * processor as long as it is in the executing state -- even if a higher + * priority task is made ready. If preemption is enabled (@c RTEMS_PREEMPT) + * and a higher priority task is made ready, then the processor will be + * taken away from the current task immediately and given to the higher + * priority task. + * + * The timeslicing component is used by the RTEMS scheduler to determine how + * the processor is allocated to tasks of equal priority. If timeslicing is + * enabled (@c RTEMS_TIMESLICE), then RTEMS will limit the amount of time the + * task can execute before the processor is allocated to another ready task of + * equal priority. The length of the timeslice is application dependent and + * specified in the Configuration Table. If timeslicing is disabled (@c + * RTEMS_NO_TIMESLICE), then the task will be allowed to + * execute until a task of higher priority is made ready. If @c + * RTEMS_NO_PREEMPT is selected, then the timeslicing component is ignored by + * the scheduler. + * + * The asynchronous signal processing component is used to determine when + * received signals are to be processed by the task. If signal processing is + * enabled (@c RTEMS_ASR), then signals sent to the task will be processed + * the next time the task executes. If signal processing is disabled (@c + * RTEMS_NO_ASR), then all signals received by the task will + * remain posted until signal processing is enabled. This component affects + * only tasks which have established a routine to process asynchronous signals. + * + * The interrupt level component is used to determine which interrupts will be + * enabled when the task is executing. @c RTEMS_INTERRUPT_LEVEL(n) specifies + * that the task will execute at interrupt level n. + * + * - @ref RTEMS_PREEMPT - enable preemption (default) + * - @ref RTEMS_NO_PREEMPT - disable preemption + * - @ref RTEMS_NO_TIMESLICE - disable timeslicing (default) + * - @ref RTEMS_TIMESLICE - enable timeslicing + * - @ref RTEMS_ASR - enable ASR processing (default) + * - @ref RTEMS_NO_ASR - disable ASR processing + * - @ref RTEMS_INTERRUPT_LEVEL(0) - enable all interrupts (default) + * - @ref RTEMS_INTERRUPT_LEVEL(n) - execute at interrupt level n + * + * The set of default modes may be selected by specifying the @ref + * RTEMS_DEFAULT_MODES constant. + * + * @section ClassicTasksSecAccessingTaskArguments Accessing Task Arguments + * + * All RTEMS tasks are invoked with a single argument which is specified when + * they are started or restarted. The argument is commonly used to communicate + * startup information to the task. The simplest manner in which to define a + * task which accesses it argument is: + * + * @code + * rtems_task user_task( + * rtems_task_argument argument + * ); + * @endcode + * + * Application tasks requiring more information may view this single argument + * as an index into an array of parameter blocks. + * + * @section ClassicTasksSecFloatingPointConsiderations Floating Point Considerations + * + * Creating a task with the @ref RTEMS_FLOATING_POINT attribute flag results in + * additional memory being allocated for the TCB to store the state of the + * numeric coprocessor during task switches. This additional memory is NOT + * allocated for @ref RTEMS_NO_FLOATING_POINT tasks. Saving and restoring the + * context of a @c RTEMS_FLOATING_POINT task takes longer than that of a @c + * RTEMS_NO_FLOATING_POINT task because of the relatively large amount of time + * required for the numeric coprocessor to save or restore its computational + * state. + * + * Since RTEMS was designed specifically for embedded military applications + * which are floating point intensive, the executive is optimized to avoid + * unnecessarily saving and restoring the state of the numeric coprocessor. The + * state of the numeric coprocessor is only saved when a @c + * RTEMS_FLOATING_POINT task is dispatched and that task was not the last task + * to utilize the coprocessor. In a system with only one @c + * RTEMS_FLOATING_POINT task, the state of the numeric coprocessor will never + * be saved or restored. + * + * Although the overhead imposed by @c RTEMS_FLOATING_POINT tasks is minimal, + * some applications may wish to completely avoid the overhead associated with + * @c RTEMS_FLOATING_POINT tasks and still utilize a numeric coprocessor. By + * preventing a task from being preempted while performing a sequence of + * floating point operations, a @c RTEMS_NO_FLOATING_POINT task can utilize + * the numeric coprocessor without incurring the overhead of a @c + * RTEMS_FLOATING_POINT context switch. This approach also avoids the + * allocation of a floating point context area. However, if this approach is + * taken by the application designer, NO tasks should be created as @c + * RTEMS_FLOATING_POINT tasks. Otherwise, the floating point context will not + * be correctly maintained because RTEMS assumes that the state of the numeric + * coprocessor will not be altered by @c RTEMS_NO_FLOATING_POINT tasks. + * + * If the supported processor type does not have hardware floating capabilities + * or a standard numeric coprocessor, RTEMS will not provide built-in support + * for hardware floating point on that processor. In this case, all tasks are + * considered @c RTEMS_NO_FLOATING_POINT whether created as @c + * RTEMS_FLOATING_POINT or @c RTEMS_NO_FLOATING_POINT tasks. A floating point + * emulation software library must be utilized for floating point operations. + * + * On some processors, it is possible to disable the floating point unit + * dynamically. If this capability is supported by the target processor, then + * RTEMS will utilize this capability to enable the floating point unit only + * for tasks which are created with the @c RTEMS_FLOATING_POINT attribute. + * The consequence of a @c RTEMS_NO_FLOATING_POINT task attempting to access + * the floating point unit is CPU dependent but will generally result in an + * exception condition. + * + * @section ClassicTasksSecPerTaskVariables Per Task Variables + * + * Per task variables are no longer available. In particular the + * rtems_task_variable_add(), rtems_task_variable_get() and + * rtems_task_variable_delete() functions are neither declared nor defined + * anymore. Use thread local storage or POSIX Keys instead. + * + * @section ClassicTasksSecBuildingTaskAttributeSet Building a Task Attribute Set + * + * In general, an attribute set is built by a bitwise OR of the desired + * components. The set of valid task attribute components is listed below: + * + * - @ref RTEMS_NO_FLOATING_POINT - does not use coprocessor (default) + * - @ref RTEMS_FLOATING_POINT - uses numeric coprocessor + * - @ref RTEMS_LOCAL - local task (default) + * - @ref RTEMS_GLOBAL - global task + * + * Attribute values are specifically designed to be mutually exclusive, + * therefore bitwise OR and addition operations are equivalent as long as each + * attribute appears exactly once in the component list. A component listed as + * a default is not required to appear in the component list, although it is a + * good programming practice to specify default components. If all defaults are + * desired, then @ref RTEMS_DEFAULT_ATTRIBUTES should be used. This example + * demonstrates the attribute_set parameter needed to create a local task which + * utilizes the numeric coprocessor. The attribute_set parameter could be @c + * RTEMS_FLOATING_POINT or @c RTEMS_LOCAL | @c RTEMS_FLOATING_POINT. The + * attribute_set parameter can be set to @c RTEMS_FLOATING_POINT because @c + * RTEMS_LOCAL is the default for all created tasks. If the task were global + * and used the numeric coprocessor, then the attribute_set parameter would be + * @c RTEMS_GLOBAL | @c RTEMS_FLOATING_POINT. + * + * @section ClassicTasksSecBuildingModeAndMask Building a Mode and Mask + * + * In general, a mode and its corresponding mask is built by a bitwise OR of + * the desired components. The set of valid mode constants and each mode's + * corresponding mask constant is listed below: + * + * + * + * + * + * + * + * + * + * + * + *
Mode ConstantMask ConstantDescription
@ref RTEMS_PREEMPT@ref RTEMS_PREEMPT_MASKenables preemption
@ref RTEMS_NO_PREEMPT@ref RTEMS_PREEMPT_MASKdisables preemption
@ref RTEMS_NO_TIMESLICE@ref RTEMS_TIMESLICE_MASKdisables timeslicing
@ref RTEMS_TIMESLICE@ref RTEMS_TIMESLICE_MASKenables timeslicing
@ref RTEMS_ASR@ref RTEMS_ASR_MASKenables ASR processing
@ref RTEMS_NO_ASR@ref RTEMS_ASR_MASKdisables ASR processing
@ref RTEMS_INTERRUPT_LEVEL(0)@ref RTEMS_INTERRUPT_MASKenables all interrupts
@ref RTEMS_INTERRUPT_LEVEL(n)@ref RTEMS_INTERRUPT_MASKsets interrupts level n
+ * + * Mode values are specifically designed to be mutually exclusive, therefore + * bitwise OR and addition operations are equivalent as long as each mode + * appears exactly once in the component list. A mode component listed as a + * default is not required to appear in the mode component list, although it is + * a good programming practice to specify default components. If all defaults + * are desired, the mode @ref RTEMS_DEFAULT_MODES and the mask @ref + * RTEMS_ALL_MODE_MASKS should be used. + * + * The following example demonstrates the mode and mask parameters used with + * the rtems_task_mode() directive to place a task at interrupt level 3 and + * make it non-preemptible. The mode should be set to @c + * RTEMS_INTERRUPT_LEVEL(3) | @c RTEMS_NO_PREEMPT to indicate the desired + * preemption mode and interrupt level, while the mask parameter should be set + * to @c RTEMS_INTERRUPT_MASK | @c RTEMS_PREEMPT_MASK to indicate that + * the calling task's interrupt level and preemption mode are being altered. + */ + + /** + * @defgroup LocalPackages Local Packages + * + * @brief Local packages. + */ diff --git a/cpukit/include/rtems/rtems/message.h b/cpukit/include/rtems/rtems/message.h new file mode 100644 index 0000000000..8ae9e156a1 --- /dev/null +++ b/cpukit/include/rtems/rtems/message.h @@ -0,0 +1,270 @@ +/** + * @file rtems/rtems/message.h + * + * @defgroup ClassicMessageQueue Message Queues + * + * @ingroup ClassicRTEMS + * @brief Message Queue Manager + * + * This include file contains all the constants and structures associated + * with the Message Queue Manager. This manager provides a mechanism for + * communication and synchronization between tasks using messages. + * + * Directives provided are: + * + * - create a queue + * - get ID of a queue + * - delete a queue + * - put a message at the rear of a queue + * - put a message at the front of a queue + * - broadcast N messages to a queue + * - receive message from a queue + * - flush all messages on a queue + */ + +/* COPYRIGHT (c) 1989-2013. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_MESSAGE_H +#define _RTEMS_RTEMS_MESSAGE_H + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @ingroup ClassicMessageQueueImpl + * + * The following records define the control block used to manage + * each message queue. + */ +typedef struct { + /** This field is the inherited object characteristics. */ + Objects_Control Object; + /** This field is the instance of the SuperCore Message Queue. */ + CORE_message_queue_Control message_queue; + /** This field is the attribute set as defined by the API. */ + rtems_attribute attribute_set; +} Message_queue_Control; + +/** + * @defgroup ClassicMessageQueue Message Queues + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality related to the Classic API Message Queue + * Manager. + */ +/**@{*/ + +/** + * @brief RTEMS Create Message Queue + * + * This routine implements the rtems_message_queue_create directive. The + * message queue will have the @a name. If the @a attribute_set indicates + * that the message queue is to be limited in the number of messages + * that can be outstanding, then @a count indicates the maximum number of + * messages that will be held. It returns the id of the created + * message queue in @a id. + * + * @param[in] name is the user defined queue name + * @param[in] count is the maximum message and reserved buffer count + * @param[in] max_message_size is the maximum size of each message + * @param[in] attribute_set is the process method + * @param[in] id is the pointer to queue + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. If successful, the @a id will + * be filled in with the queue id. + */ +rtems_status_code rtems_message_queue_create( + rtems_name name, + uint32_t count, + size_t max_message_size, + rtems_attribute attribute_set, + rtems_id *id +); + +/** + * @brief RTEMS Message Queue Name to Id + * + * This routine implements the rtems_message_queue_ident directive. + * This directive returns the message queue ID associated with NAME. + * If more than one message queue is named name, then the message + * queue to which the ID belongs is arbitrary. node indicates the + * extent of the search for the ID of the message queue named name. + * The search can be limited to a particular node or allowed to + * encompass all nodes. + * + * @param[in] name is the user defined message queue name + * @param[in] node is the node(s) to be searched + * @param[in] id is the pointer to message queue id + * + * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful and + * *id filled with the message queue id + */ +rtems_status_code rtems_message_queue_ident( + rtems_name name, + uint32_t node, + rtems_id *id +); + +/** + * @brief RTEMS Delete Message Queue + * + * This routine implements the rtems_message_queue_delete directive. The + * message queue indicated by ID is deleted. + * + * @param[in] id is the queue id + * + * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful + */ +rtems_status_code rtems_message_queue_delete( + rtems_id id +); + +/** + * @brief rtems_message_queue_send + * + * Message Queue Manager - rtems_message_queue_send + * + * This routine implements the rtems_message_queue_send directive. + * This directive sends the message buffer to the message queue + * indicated by ID. If one or more tasks is blocked waiting + * to receive a message from this message queue, then one will + * receive the message. The task selected to receive the + * message is based on the task queue discipline algorithm in + * use by this particular message queue. If no tasks are waiting, + * then the message buffer will be placed at the REAR of the + * chain of pending messages for this message queue. + */ +rtems_status_code rtems_message_queue_send( + rtems_id id, + const void *buffer, + size_t size +); + +/** + * @brief RTEMS Urgent Message Queue + * + * This routine implements the rtems_message_queue_urgent directive. + * This directive has the same behavior as rtems_message_queue_send + * except that if no tasks are waiting, the message buffer will + * be placed at the FRONT of the chain of pending messages rather + * than at the REAR. + * + * @param[in] id is the pointer to message queue + * @param[in] buffer is the pointer to message buffer + * @param[in] size is the size of message to send urgently + * + * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful + */ +rtems_status_code rtems_message_queue_urgent( + rtems_id id, + const void *buffer, + size_t size +); + +/** + * @brief RTEMS Broadcast Message Queue + * + * This routine implements the rtems_message_queue_broadcast directive. + * This directive sends the message buffer to all of the tasks blocked + * waiting for a message on the message queue indicated by ID. + * If no tasks are waiting, then the message buffer will not be queued. + * + * @param[in] id is the pointer to message queue + * @param[in] buffer is the pointer to message buffer + * @param[in] size is the size of message to broadcast + * @param[in] count pointer to area to store number of threads made ready + * + * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful and + * *count filled in with number of threads made ready + */ +rtems_status_code rtems_message_queue_broadcast( + rtems_id id, + const void *buffer, + size_t size, + uint32_t *count +); + +/** + * @brief RTEMS Message Queue Receive + * + * This routine implements the rtems_message_queue_receive directive. + * This directive is invoked when the calling task wishes to receive + * a message from the message queue indicated by ID. The received + * message is to be placed in buffer. If no messages are outstanding + * and the option_set indicates that the task is willing to block, + * then the task will be blocked until a message arrives or until, + * optionally, timeout clock ticks have passed. + * + * @param[in] id is the queue id + * @param[in] buffer is the pointer to message buffer + * @param[in] size is the size of message receive + * @param[in] option_set is the options on receive + * @param[in] timeout is the number of ticks to wait + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + */ +rtems_status_code rtems_message_queue_receive( + rtems_id id, + void *buffer, + size_t *size, + rtems_option option_set, + rtems_interval timeout +); + +/** + * @brief rtems_message_queue_flush + * + * This routine implements the rtems_message_queue_flush directive. + * This directive takes all outstanding messages for the message + * queue indicated by ID and returns them to the inactive message + * chain. The number of messages flushed is returned in COUNT. + * + * Message Queue Manager + */ +rtems_status_code rtems_message_queue_flush( + rtems_id id, + uint32_t *count +); + +/** + * @brief RTEMS Message Queue Get Number Pending + * + * Message Queue Manager + * + * This routine implements the rtems_message_queue_get_number_pending + * directive. This directive returns the number of pending + * messages for the message queue indicated by ID + * chain. The number of messages pending is returned in COUNT. + */ +rtems_status_code rtems_message_queue_get_number_pending( + rtems_id id, + uint32_t *count +); + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/messageimpl.h b/cpukit/include/rtems/rtems/messageimpl.h new file mode 100644 index 0000000000..df7cea6829 --- /dev/null +++ b/cpukit/include/rtems/rtems/messageimpl.h @@ -0,0 +1,120 @@ +/** + * @file rtems/rtems/message.inl + * + * This include file contains the static inline implementation of all + * inlined routines in the Message Manager. + */ + +/* COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_MESSAGEIMPL_H +#define _RTEMS_RTEMS_MESSAGEIMPL_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicMessageQueueImpl Classic Message Queue Implementation + * + * @ingroup ClassicMessageQueue + * + * @{ + */ + +/** + * The following enumerated type details the modes in which a message + * may be submitted to a message queue. The message may be posted + * in a send or urgent fashion. + */ +typedef enum { + /** + * This value indicates the user wants to send the message using the + * normal message insertion protocol (FIFO or priority). + */ + MESSAGE_QUEUE_SEND_REQUEST = 0, + /** + * This value indicates the user considers the message to be urgent + * and wants it inserted at the head of the pending message queue. + */ + MESSAGE_QUEUE_URGENT_REQUEST = 1 +} Message_queue_Submit_types; + +/** + * The following defines the information control block used to + * manage this class of objects. + */ +extern Objects_Information _Message_queue_Information; + +/** + * @brief Message_queue_Submit + * + * This routine implements the directives rtems_message_queue_send + * and rtems_message_queue_urgent. It processes a message that is + * to be submitted to the designated message queue. The message will + * either be processed as a send send message which it will be inserted + * at the rear of the queue or it will be processed as an urgent message + * which will be inserted at the front of the queue. + */ +rtems_status_code _Message_queue_Submit( + rtems_id id, + const void *buffer, + size_t size, + Message_queue_Submit_types submit_type +); + +/** + * @brief Deallocates a message queue control block into + * the inactive chain of free message queue control blocks. + * + * This routine deallocates a message queue control block into + * the inactive chain of free message queue control blocks. + */ +RTEMS_INLINE_ROUTINE void _Message_queue_Free ( + Message_queue_Control *the_message_queue +) +{ + _Objects_Free( &_Message_queue_Information, &the_message_queue->Object ); +} + +RTEMS_INLINE_ROUTINE Message_queue_Control *_Message_queue_Get( + Objects_Id id, + Thread_queue_Context *queue_context +) +{ + _Thread_queue_Context_initialize( queue_context ); + return (Message_queue_Control *) _Objects_Get( + id, + &queue_context->Lock_context.Lock_context, + &_Message_queue_Information + ); +} + +RTEMS_INLINE_ROUTINE Message_queue_Control *_Message_queue_Allocate( void ) +{ + return (Message_queue_Control *) + _Objects_Allocate( &_Message_queue_Information ); +} + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#if defined(RTEMS_MULTIPROCESSING) +#include +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/modes.h b/cpukit/include/rtems/rtems/modes.h new file mode 100644 index 0000000000..547ae13e05 --- /dev/null +++ b/cpukit/include/rtems/rtems/modes.h @@ -0,0 +1,132 @@ +/** + * @file rtems/rtems/modes.h + * + * @defgroup ClassicModes Modes + * + * @ingroup ClassicRTEMS + * @brief RTEMS thread and RTEMS_ASR modes + * + * This include file contains all constants and structures associated + * with the RTEMS thread and RTEMS_ASR modes. + */ + +/* COPYRIGHT (c) 1989-2013. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_MODES_H +#define _RTEMS_RTEMS_MODES_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicModes Modes + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality related to the task modes supported + * by the Classic API Task Manager. + */ +/**@{*/ + +/** + * The following type defines the control block used to manage + * each a mode set. + */ +typedef uint32_t Modes_Control; + +/** + * The following constants define the individual modes and masks + * which may be used to compose a mode set and to alter modes. + */ +#define RTEMS_ALL_MODE_MASKS 0x0000ffff + +/** + * This mode constant is the default mode set. + */ +#define RTEMS_DEFAULT_MODES 0x00000000 + +/** + * This mode constant is used when the user wishes to obtain their + * current execution mode. + */ +#define RTEMS_CURRENT_MODE 0 + +/** This mode constant corresponds to the timeslice enable/disable bit. */ +#define RTEMS_TIMESLICE_MASK 0x00000200 + +/** This mode constant corresponds to the preemption enable/disable bit. */ +#define RTEMS_PREEMPT_MASK 0x00000100 + +/** This mode constant corresponds to the signal enable/disable bit. */ +#define RTEMS_ASR_MASK 0x00000400 + +/** This mode constant corresponds to the interrupt enable/disable bits. */ +#define RTEMS_INTERRUPT_MASK CPU_MODES_INTERRUPT_MASK + +/** This mode constant is used to indicate preemption is enabled. */ +#define RTEMS_PREEMPT 0x00000000 +/** This mode constant is used to indicate preemption is disabled. */ +#define RTEMS_NO_PREEMPT 0x00000100 + +/** This mode constant is used to indicate timeslicing is disabled. */ +#define RTEMS_NO_TIMESLICE 0x00000000 +/** This mode constant is used to indicate timeslicing is enabled. */ +#define RTEMS_TIMESLICE 0x00000200 + +/** This mode constant is used to indicate signal processing is enabled. */ +#define RTEMS_ASR 0x00000000 +/** This mode constant is used to indicate signal processing is disabled. */ +#define RTEMS_NO_ASR 0x00000400 + +/** + * @brief RTEMS_INTERRUPT_LEVEL + * + * This function returns the processor dependent interrupt + * level which corresponds to the requested interrupt level. + * + * @note RTEMS supports 256 interrupt levels using the least + * significant eight bits of MODES.CONTROL. On any + * particular CPU, fewer than 256 levels may be supported. + */ +#define RTEMS_INTERRUPT_LEVEL( _mode_set ) \ + ( (_mode_set) & RTEMS_INTERRUPT_MASK ) + +/** + * @brief Interrupt Mask Variable + * + * This variable is used by bindings from languages other than C and C++. + */ +extern const uint32_t rtems_interrupt_mask; + +/** + * @brief Body for RTEMS_INTERRUPT_LEVEL Macro + * + * @param[in] level is the desired interrupt level + * + * @retval This methods returns a mode with the desired interrupt + * @a level in the proper bitfield location. + * + * @note This variable is used by bindings from languages other than + * C and C++. + */ +Modes_Control rtems_interrupt_level_body( + uint32_t level +); + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/modesimpl.h b/cpukit/include/rtems/rtems/modesimpl.h new file mode 100644 index 0000000000..8c1acc7cb9 --- /dev/null +++ b/cpukit/include/rtems/rtems/modesimpl.h @@ -0,0 +1,146 @@ +/** + * @file + * + * @ingroup ClassicModesImpl + * + * @brief Classic Modes Implementation + */ + +/* COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_MODESIMPL_H +#define _RTEMS_RTEMS_MODESIMPL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicModesImpl Classic Modes Implementation + * + * @ingroup ClassicModes + * + * @{ + */ + +/** + * @brief Checks if any of the mode flags in mask are set in mode_set. + * + * This function returns TRUE if any of the mode flags in mask + * are set in mode_set, and FALSE otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Modes_Mask_changed ( + Modes_Control mode_set, + Modes_Control masks +) +{ + return ( mode_set & masks ) ? true : false; +} + +/** + * @brief Checks if mode_set says that Asynchronous Signal Processing is disabled. + * + * This function returns TRUE if mode_set indicates that Asynchronous + * Signal Processing is disabled, and FALSE otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Modes_Is_asr_disabled ( + Modes_Control mode_set +) +{ + return (mode_set & RTEMS_ASR_MASK) == RTEMS_NO_ASR; +} + +/** + * @brief Checks if mode_set indicates that preemption is enabled. + * + * This function returns TRUE if mode_set indicates that preemption + * is enabled, and FALSE otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Modes_Is_preempt ( + Modes_Control mode_set +) +{ + return (mode_set & RTEMS_PREEMPT_MASK) == RTEMS_PREEMPT; +} + +/** + * @brief Checks if mode_set indicates that timeslicing is enabled. + * + * This function returns TRUE if mode_set indicates that timeslicing + * is enabled, and FALSE otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Modes_Is_timeslice ( + Modes_Control mode_set +) +{ + return (mode_set & RTEMS_TIMESLICE_MASK) == RTEMS_TIMESLICE; +} + +/** + * @brief Gets the interrupt level portion of the mode_set. + * + * This function returns the interrupt level portion of the mode_set. + */ +RTEMS_INLINE_ROUTINE ISR_Level _Modes_Get_interrupt_level ( + Modes_Control mode_set +) +{ + return ( mode_set & RTEMS_INTERRUPT_MASK ); +} + +/** + * @brief Sets the current interrupt level to that specified in the mode_set. + * + * This routine sets the current interrupt level to that specified + * in the mode_set. + */ +RTEMS_INLINE_ROUTINE void _Modes_Set_interrupt_level ( + Modes_Control mode_set +) +{ + _ISR_Set_level( _Modes_Get_interrupt_level( mode_set ) ); +} + +/** + * @brief Changes the modes in old_mode_set indicated by + * mask to the requested values in new_mode_set. + * + * This routine changes the modes in old_mode_set indicated by + * mask to the requested values in new_mode_set. The resulting + * mode set is returned in out_mode_set and the modes that changed + * is returned in changed. + */ +RTEMS_INLINE_ROUTINE void _Modes_Change ( + Modes_Control old_mode_set, + Modes_Control new_mode_set, + Modes_Control mask, + Modes_Control *out_mode_set, + Modes_Control *changed +) +{ + Modes_Control _out_mode; + + _out_mode = old_mode_set; + _out_mode &= ~mask; + _out_mode |= new_mode_set & mask; + *changed = _out_mode ^ old_mode_set; + *out_mode_set = _out_mode; +} + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/mp.h b/cpukit/include/rtems/rtems/mp.h new file mode 100644 index 0000000000..f1b93b6751 --- /dev/null +++ b/cpukit/include/rtems/rtems/mp.h @@ -0,0 +1,54 @@ +/** + * @file rtems/rtems/mp.h + * + * @defgroup ClassicMP Multiprocessing + * + * @ingroup ClassicRTEMS + * @brief Multiprocessing Manager + * + * This include file contains all the constants and structures associated + * with the Multiprocessing Manager. + */ + +/* COPYRIGHT (c) 1989-2013. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_MP_H +#define _RTEMS_RTEMS_MP_H + +/** + * @defgroup ClassicMP Multiprocessing + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality related to the distributed + * Multiprocessing support in the Classic API. + */ +/**@{*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief RTEMS Multiprocessing Announce + * + * This routine implements the MULTIPROCESSING_ANNOUNCE directive. + * It is invoked by the MPCI layer to indicate that an MPCI packet + * has been received. + */ +void rtems_multiprocessing_announce ( void ); + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/msgmp.h b/cpukit/include/rtems/rtems/msgmp.h new file mode 100644 index 0000000000..3dabd8d46b --- /dev/null +++ b/cpukit/include/rtems/rtems/msgmp.h @@ -0,0 +1,211 @@ +/** + * @file rtems/rtems/msgmp.h + * + * @brief Message Manager MP Support + * + * This include file contains all the constants and structures associated + * with the Multiprocessing Support in the Message Manager. + */ + +/* COPYRIGHT (c) 1989-2013. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_MSGMP_H +#define _RTEMS_RTEMS_MSGMP_H + +#ifndef _RTEMS_RTEMS_MESSAGEIMPL_H +# error "Never use directly; include instead." +#endif + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicMsgMP Message Queue MP Support + * + * @ingroup ClassicMP + * + * This encapsulates functionality related to the transparent multiprocessing + * support within the Classic API Message Queue Manager. + */ +/*{*/ + +/** + * The following enumerated type defines the list of + * remote message queue operations. + */ +typedef enum { + MESSAGE_QUEUE_MP_ANNOUNCE_CREATE = 0, + MESSAGE_QUEUE_MP_ANNOUNCE_DELETE = 1, + MESSAGE_QUEUE_MP_EXTRACT_PROXY = 2, + MESSAGE_QUEUE_MP_RECEIVE_REQUEST = 3, + MESSAGE_QUEUE_MP_RECEIVE_RESPONSE = 4, + MESSAGE_QUEUE_MP_SEND_REQUEST = 5, + MESSAGE_QUEUE_MP_SEND_RESPONSE = 6, + MESSAGE_QUEUE_MP_URGENT_REQUEST = 7, + MESSAGE_QUEUE_MP_URGENT_RESPONSE = 8, + MESSAGE_QUEUE_MP_BROADCAST_REQUEST = 9, + MESSAGE_QUEUE_MP_BROADCAST_RESPONSE = 10, + MESSAGE_QUEUE_MP_FLUSH_REQUEST = 11, + MESSAGE_QUEUE_MP_FLUSH_RESPONSE = 12, + MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_REQUEST = 13, + MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_RESPONSE = 14 +} Message_queue_MP_Remote_operations; + +/** + * The following data structure defines the packet used to perform + * remote message queue operations. + */ +typedef struct { + rtems_packet_prefix Prefix; + Message_queue_MP_Remote_operations operation; + rtems_name name; + rtems_option option_set; + Objects_Id proxy_id; + uint32_t count; + size_t size; + uint32_t pad0; + CORE_message_queue_Buffer Buffer; +} Message_queue_MP_Packet; + +#define MESSAGE_QUEUE_MP_PACKET_SIZE \ + offsetof(Message_queue_MP_Packet, Buffer.buffer) + +RTEMS_INLINE_ROUTINE bool _Message_queue_MP_Is_remote( Objects_Id id ) +{ + return _Objects_MP_Is_remote( id, &_Message_queue_Information ); +} + +/** + * @brief Message_queue_Core_message_queue_mp_support + * + * Input parameters: + * the_thread - the remote thread the message was submitted to + * id - id of the message queue + * + * Output parameters: NONE + */ +void _Message_queue_Core_message_queue_mp_support ( + Thread_Control *the_thread, + rtems_id id +); + +/** + * @brief _Message_queue_MP_Send_process_packet + * + * This routine performs a remote procedure call so that a + * process operation can be performed on another node. + */ +void _Message_queue_MP_Send_process_packet ( + Message_queue_MP_Remote_operations operation, + Objects_Id message_queue_id, + rtems_name name, + Objects_Id proxy_id +); + +/** + * @brief Issues a remote rtems_message_queue_broadcast() request. + */ +rtems_status_code _Message_queue_MP_Broadcast( + rtems_id id, + const void *buffer, + size_t size, + uint32_t *count +); + +/** + * @brief Issues a remote rtems_message_queue_flush() request. + */ +rtems_status_code _Message_queue_MP_Flush( + rtems_id id, + uint32_t *count +); + +/** + * @brief Issues a remote rtems_message_queue_get_number_pending() request. + */ +rtems_status_code _Message_queue_MP_Get_number_pending( + rtems_id id, + uint32_t *count +); + +/** + * @brief Issues a remote rtems_message_queue_receive() request. + */ +rtems_status_code _Message_queue_MP_Receive( + rtems_id id, + void *buffer, + size_t *size, + rtems_option option_set, + rtems_interval timeout +); + +/** + * @brief Issues a remote rtems_message_queue_send() request. + */ +rtems_status_code _Message_queue_MP_Send( + rtems_id id, + const void *buffer, + size_t size +); + +/** + * @brief Issues a remote rtems_message_queue_urgent() request. + */ +rtems_status_code _Message_queue_MP_Urgent( + rtems_id id, + const void *buffer, + size_t size +); + +/** + * + * @brief _Message_queue_MP_Process_packet + * + * This routine performs the actions specific to this package for + * the request from another node. + */ +void _Message_queue_MP_Process_packet ( + rtems_packet_prefix *the_packet_prefix +); + +/** + * @brief _Message_queue_MP_Send_object_was_deleted + * + * This routine is invoked indirectly by the thread queue + * when a proxy has been removed from the thread queue and + * the remote node must be informed of this. + */ +void _Message_queue_MP_Send_object_was_deleted ( + Thread_Control *the_proxy, + Objects_Id mp_id +); + +/** + * @brief _Message_queue_MP_Send_extract_proxy + * + * This routine is invoked when a task is deleted and it + * has a proxy which must be removed from a thread queue and + * the remote node must be informed of this. + */ +void _Message_queue_MP_Send_extract_proxy ( + Thread_Control *the_thread, + Objects_Id id +); + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of file */ diff --git a/cpukit/include/rtems/rtems/object.h b/cpukit/include/rtems/rtems/object.h new file mode 100644 index 0000000000..2652915462 --- /dev/null +++ b/cpukit/include/rtems/rtems/object.h @@ -0,0 +1,370 @@ +/** + * @file rtems/rtems/object.h + * + * @defgroup ClassicClassInfo Object Class Information + * + * @ingroup ClassicRTEMS + * @brief Classic API interfaces to Object Services + * + * This include file defines Classic API interfaces to Object Services. + */ + +/* COPYRIGHT (c) 1989-2013. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_OBJECT_H +#define _RTEMS_RTEMS_OBJECT_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicClassInfo Object Class Information + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality related to the Classic API Object + * Class Services. + */ +/**@{*/ + +/** + * This structure is used to return information to the application + * about the objects configured for a specific API/Class combination. + */ +typedef struct { + /** This field is the minimum valid object Id for this class. */ + rtems_id minimum_id; + /** This field is the maximum valid object Id for this class. */ + rtems_id maximum_id; + /** This field is the number of object instances configured for this class. */ + uint32_t maximum; + /** This field indicates if the class is configured for auto-extend. */ + bool auto_extend; + /** This field is the number of currently unallocated objects. */ + uint32_t unallocated; +} rtems_object_api_class_information; + +/** + * @brief Build Object Id + * + * This function returns an object id composed of the + * specified @a api, @a class, @a node, + * and @a index. + * + * @param[in] _api indicates the api to use for the Id + * @param[in] _class indicates the class to use for the Id + * @param[in] _node indicates the node to use for the Id + * @param[in] _index indicates the index to use for the Id + * + * @retval This method returns an object Id built from the + * specified values. + * + * @note A body is also provided. + */ +#define rtems_build_id( _api, _class, _node, _index ) \ + _Objects_Build_id( _api, _class, _node, _index ) + +/** + * @brief Build Thirty-Two Bit Object Name + * + * RTEMS Object Helper -- Build an Object Id + * + * This function returns an object name composed of the four characters + * C1, C2, C3, and C4. + * + * @param[in] _C1 is the first character of the name + * @param[in] _C2 is the second character of the name + * @param[in] _C3 is the third character of the name + * @param[in] _C4 is the fourth character of the name + * + * @note This must be implemented as a macro for use in + * Configuration Tables. A body is also provided. + * + */ +#define rtems_build_name( _C1, _C2, _C3, _C4 ) \ + _Objects_Build_name( _C1, _C2, _C3, _C4 ) + +/** + * @brief Obtain Name of Object + * + * This directive returns the name associated with the specified + * object ID. + * + * @param[in] id is the Id of the object to obtain the name of. + * @param[out] name will be set to the name of the object + * + * @note The object must be have a name of the 32-bit form. + * + * @retval @a *name will contain user defined object name + * @retval @a RTEMS_SUCCESSFUL - if successful + * @retval error code - if unsuccessful + */ +rtems_status_code rtems_object_get_classic_name( + rtems_id id, + rtems_name *name +); + +/** + * @brief Obtain Object Name as String + * + * This directive returns the name associated with the specified + * object ID. + * + * @param[in] id is the Id of the object to obtain the name of + * @param[in] length is the length of the output name buffer + * @param[out] name will be set to the name of the object + * + * @retval @a *name will contain user defined object name + * @retval @a name - if successful + * @retval @a NULL - if unsuccessful + */ +char *rtems_object_get_name( + rtems_id id, + size_t length, + char *name +); + +/** + * @brief Set Name of Object + * + * This method allows the caller to set the name of an + * object. This can be used to set the name of objects + * which do not have a naming scheme per their API. + * + * RTEMS Object Helper -- Set Name of Object as String + * + * @param[in] id is the Id of the object to obtain the name of + * @param[out] name will be set to the name of the object + * + * @retval @a *name will contain user defined object name + * @retval @a RTEMS_SUCCESSFUL - if successful + * @retval error code - if unsuccessful + */ +rtems_status_code rtems_object_set_name( + rtems_id id, + const char *name +); + +/** + * @brief Get API Portion of Object Id + * + * RTEMS Object Helper -- Extract API From Id + * + * This function returns the API portion of the Id. + * + * @param[in] _id is the Id of the object to obtain the API from + * + * @retval This method returns the API portion of the provided + * @a _id. + * + * @note This method does NOT validate the @a _id provided. + * + * @note A body is also provided. + */ +#define rtems_object_id_get_api( _id ) \ + _Objects_Get_API( _id ) + +/** + * @brief Get Class Portion of Object Id + * + * This function returns the class portion of the @a _id ID. + * + * @param[in] _id is the Id of the object to obtain the class from + * + * @retval This method returns the class portion of the provided + * @a _id. + * + * @note This method does NOT validate the @a _id provided. + * + * @note A body is also provided. + */ +#define rtems_object_id_get_class( _id ) \ + _Objects_Get_class( _id ) + +/** + * @brief Get Node Portion of Object Id + * + * This function returns the node portion of the ID. + * + * @param[in] _id is the Id of the object to obtain the node from + * + * @retval This method returns the node portion of the provided + * @a _id. + * + * @note This method does NOT validate the @a _id provided. + * + * @note A body is also provided. + */ +#define rtems_object_id_get_node( _id ) \ + _Objects_Get_node( _id ) + +/** + * @brief Get Index Portion of Object Id + * + * This function returns the index portion of the ID. + * + * @param[in] _id is the Id of the object to obtain the index from + * + * @retval This method returns the index portion of the provided + * @a _id. + * + * @note This method does NOT validate the @a _id provided. + * + * @note A body is also provided. + */ +#define rtems_object_id_get_index( _id ) \ + _Objects_Get_index( _id ) + +/** + * @brief Get Lowest Valid API Index + * + * This method returns the lowest valid value for the API + * portion of an RTEMS object Id. + * + * @retval This method returns the least valid value for + * the API portion of an RTEMS object Id. + * + * @note A body is also provided. + */ +#define rtems_object_id_api_minimum() \ + OBJECTS_INTERNAL_API + +/** + * @brief Get Highest Valid API Index + * + * This method returns the highest valid value for the API + * portion of an RTEMS object Id. + * + * @retval This method returns the greatest valid value for + * the API portion of an RTEMS object Id. + * + * @note A body is also provided. + */ +#define rtems_object_id_api_maximum() \ + OBJECTS_APIS_LAST + +/** + * @brief Get Lowest Valid Class Value + * + * This method returns the lowest valid value Class for the + * specified @a api. Each API supports a different number + * of object classes. + * + * @param[in] api is the API to obtain the minimum class of + * + * @retval This method returns the least valid value for + * class number for the specified @a api. + * RTEMS Object Helper -- Get Least Valid Class for an API + */ +int rtems_object_api_minimum_class( + int api +); + +/** + * @brief Get Highest Valid Class Value + * + * This method returns the highest valid value Class for the + * specified @a api. Each API supports a different number + * of object classes. + * + * @param[in] api is the API to obtain the maximum class of + * + * @retval This method returns the greatet valid value for + * class number for the specified @a api. + */ +int rtems_object_api_maximum_class( + int api +); + + +/** + * @brief Get Highest Valid Class Value + * + * This method returns the lowest valid value Class for the + * specified @a api. Each API supports a different number + * of object classes. + * + * @param[in] api is the API to obtain the maximum class of + * + * @retval This method returns the least valid value for + * class number for the specified @a api. + */ +int rtems_object_id_api_maximum_class( + int api +); + +/** + * @brief Get API Name + * + * This method returns a string containing the name of the + * specified @a api. + * + * @param[in] api is the API to obtain the name of + * + * @retval If successful, this method returns the name of + * the specified @a api. Otherwise, it returns + * the string "BAD API" + */ +const char *rtems_object_get_api_name( + int api +); + +/** + * @brief Get Class Name + * + * This method returns a string containing the name of the + * @a class from the specified @a api. + * + * @param[in] the_api is the API for the class + * @param[in] the_class is the class to obtain the name of + * + * @retval If successful, this method returns the name of + * the specified @a class. Otherwise, it returns + * the string "BAD CLASS" + */ +const char *rtems_object_get_api_class_name( + int the_api, + int the_class +); + +/** + * @brief Get Class Information + * + * This method returns a string containing the name of the + * @a the_class from the specified @a api. + * + * @param[in] the_api is the API for the class + * @param[in] the_class is the class to obtain information about + * @param[in] info points to the information structure to fill in + * + * @retval If successful, this method returns the name of + * RTEMS_SUCCESSFUL with @a *info filled in. Otherwise, + * a status is returned to indicate the error. + * + */ +rtems_status_code rtems_object_get_class_information( + int the_api, + int the_class, + rtems_object_api_class_information *info +); + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/options.h b/cpukit/include/rtems/rtems/options.h new file mode 100644 index 0000000000..752aefda2e --- /dev/null +++ b/cpukit/include/rtems/rtems/options.h @@ -0,0 +1,83 @@ +/** + * @file rtems/rtems/options.h + * + * @defgroup ClassicOptions Classic API Options + * + * @ingroup ClassicRTEMS + * @brief Options Available on Many Directives + * + * This include file contains information which defines the + * options available on many directives. + */ + +/* COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_OPTIONS_H +#define _RTEMS_RTEMS_OPTIONS_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicOptions Classic API Options + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality related to the options argument + * to Classic API blocking operations. The primary option is whether + * or not a task is willing to wait for the operation to complete. + */ +/**@{*/ + +/** + * The following type defines the control block used to manage + * option sets. + */ +typedef uint32_t rtems_option; + +/** + * The following constants define the individual options which may + * be used to compose an option set. + */ +#define RTEMS_DEFAULT_OPTIONS 0x00000000 + +/** + * This option constants indicates that the task is to wait on resource. + */ +#define RTEMS_WAIT 0x00000000 +/** + * This option constants indicates that the task is to not wait on + * the resource. If it is not available, return immediately with + * a status to indicate unsatisfied. + */ +#define RTEMS_NO_WAIT 0x00000001 + +/** + * This option constants indicates that the task wishes to wait until + * all events of interest are available. + */ +#define RTEMS_EVENT_ALL 0x00000000 + +/** + * This option constants indicates that the task wishes to wait until + * ANY events of interest are available. + */ +#define RTEMS_EVENT_ANY 0x00000002 + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/optionsimpl.h b/cpukit/include/rtems/rtems/optionsimpl.h new file mode 100644 index 0000000000..0263fcf78d --- /dev/null +++ b/cpukit/include/rtems/rtems/optionsimpl.h @@ -0,0 +1,67 @@ +/** + * @file + * + * @ingroup ClassicOptionsImpl + * + * @brief Classic Options Implementation + */ + +/* COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_OPTIONSIMPL_H +#define _RTEMS_RTEMS_OPTIONSIMPL_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicOptionsImpl Classic Options Implementation + * + * @ingroup ClassicOptions + * + * @{ + */ + +/** + * @brief Checks if the RTEMS_NO_WAIT option is enabled in option_set. + * + * This function returns TRUE if the RTEMS_NO_WAIT option is enabled in + * option_set, and FALSE otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Options_Is_no_wait ( + rtems_option option_set +) +{ + return (option_set & RTEMS_NO_WAIT) ? true : false; +} + +/** + * @brief Checks if the RTEMS_EVENT_ANY option is enabled in OPTION_SET. + * + * This function returns TRUE if the RTEMS_EVENT_ANY option is enabled in + * OPTION_SET, and FALSE otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Options_Is_any ( + rtems_option option_set +) +{ + return (option_set & RTEMS_EVENT_ANY) ? true : false; +} + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/part.h b/cpukit/include/rtems/rtems/part.h new file mode 100644 index 0000000000..5b840cc96c --- /dev/null +++ b/cpukit/include/rtems/rtems/part.h @@ -0,0 +1,174 @@ +/** + * @file rtems/rtems/part.h + * + * @defgroup ClassicPart Partitions + * + * @ingroup ClassicRTEMS + * @brief Partition Manager + * + * This include file contains all the constants and structures associated + * with the Partition Manager. This manager provides facilities to + * dynamically allocate memory in fixed-sized units which are returned + * as buffers. + * + * Directives provided are: + * + * - create a partition + * - get an ID of a partition + * - delete a partition + * - get a buffer from a partition + * - return a buffer to a partition + */ + +/* COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_PART_H +#define _RTEMS_RTEMS_PART_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicPart Partitions + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality related to the + * Classic API Partition Manager. + */ +/**@{*/ + +/** + * The following defines the control block used to manage each partition. + */ +typedef struct { + /** This field is the object management portion of a Partition instance. */ + Objects_Control Object; + /** This field is the lock of the Partition. */ + ISR_LOCK_MEMBER( Lock ) + /** This field is the physical starting address of the Partition. */ + void *starting_address; + /** This field is the size of the Partition in bytes. */ + intptr_t length; + /** This field is the size of each buffer in bytes */ + uint32_t buffer_size; + /** This field is the attribute set provided at create time. */ + rtems_attribute attribute_set; + /** This field is the of allocated buffers. */ + uint32_t number_of_used_blocks; + /** This field is the chain used to manage unallocated buffers. */ + Chain_Control Memory; +} Partition_Control; + +/** + * @brief RTEMS Partition Create + * + * Partition Manager + * + * This routine implements the rtems_partition_create directive. The + * partition will have the name name. The memory area managed by + * the partition is of length bytes and starts at starting_address. + * The memory area will be divided into as many buffers of + * buffer_size bytes as possible. The attribute_set determines if + * the partition is global or local. It returns the id of the + * created partition in ID. + */ +rtems_status_code rtems_partition_create( + rtems_name name, + void *starting_address, + uint32_t length, + uint32_t buffer_size, + rtems_attribute attribute_set, + rtems_id *id +); + +/** + * @brief RTEMS Partition Ident + * + * This routine implements the rtems_partition_ident directive. + * This directive returns the partition ID associated with name. + * If more than one partition is named name, then the partition + * to which the ID belongs is arbitrary. node indicates the + * extent of the search for the ID of the partition named name. + * The search can be limited to a particular node or allowed to + * encompass all nodes. + * + * @param[in] name is the user defined partition name + * @param[in] node is(are) the node(s) to be searched + * @param[in] id is the pointer to partition id + * + * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful and + * *id filled in with the partition id + */ +rtems_status_code rtems_partition_ident( + rtems_name name, + uint32_t node, + rtems_id *id +); + +/** + * @brief RTEMS Delete Partition + * + * This routine implements the rtems_partition_delete directive. The + * partition indicated by ID is deleted, provided that none of its buffers + * are still allocated. + * + * @param[in] id is the partition id + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + */ +rtems_status_code rtems_partition_delete( + rtems_id id +); + +/** + * @brief RTEMS Get Partition Buffer + * + * This routine implements the rtems_partition_get_buffer directive. It + * attempts to allocate a buffer from the partition associated with ID. + * If a buffer is allocated, its address is returned in buffer. + * + * @param[in] id is the partition id + * @param[out] buffer is the pointer to buffer address + * + * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful + */ +rtems_status_code rtems_partition_get_buffer( + rtems_id id, + void **buffer +); + +/** + * @brief rtems_partition_return_buffer + * + * This routine implements the rtems_partition_return_buffer directive. It + * frees the buffer to the partition associated with ID. The buffer must + * have been previously allocated from the same partition. + */ +rtems_status_code rtems_partition_return_buffer( + rtems_id id, + void *buffer +); + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/partimpl.h b/cpukit/include/rtems/rtems/partimpl.h new file mode 100644 index 0000000000..13ee86b4c2 --- /dev/null +++ b/cpukit/include/rtems/rtems/partimpl.h @@ -0,0 +1,223 @@ +/** + * @file + * + * @ingroup ClassicPartImpl + * + * @brief Classic Partition Manager Implementation + */ + +/* COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_PARTIMPL_H +#define _RTEMS_RTEMS_PARTIMPL_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicPartImpl Classic Partition Manager Implementation + * + * @ingroup ClassicPart + * + * @{ + */ + +/** + * The following defines the information control block used to + * manage this class of objects. + */ +extern Objects_Information _Partition_Information; + +/** + * @brief Allocate a buffer from the_partition. + * + * This function attempts to allocate a buffer from the_partition. + * If successful, it returns the address of the allocated buffer. + * Otherwise, it returns NULL. + */ +RTEMS_INLINE_ROUTINE void *_Partition_Allocate_buffer ( + Partition_Control *the_partition +) +{ + return _Chain_Get_unprotected( &the_partition->Memory ); +} + +/** + * @brief Frees the_buffer to the_partition. + * + * This routine frees the_buffer to the_partition. + */ +RTEMS_INLINE_ROUTINE void _Partition_Free_buffer ( + Partition_Control *the_partition, + Chain_Node *the_buffer +) +{ + _Chain_Append_unprotected( &the_partition->Memory, the_buffer ); +} + +/** + * @brief Checks whether is on a valid buffer boundary for the_partition. + * + * This function returns TRUE if the_buffer is on a valid buffer + * boundary for the_partition, and FALSE otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Partition_Is_buffer_on_boundary ( + void *the_buffer, + Partition_Control *the_partition +) +{ + uint32_t offset; + + offset = (uint32_t) _Addresses_Subtract( + the_buffer, + the_partition->starting_address + ); + + return ((offset % the_partition->buffer_size) == 0); +} + +/** + * @brief Checks whether the_buffer is a valid buffer from the_partition. + * + * This function returns TRUE if the_buffer is a valid buffer from + * the_partition, otherwise FALSE is returned. + */ +RTEMS_INLINE_ROUTINE bool _Partition_Is_buffer_valid ( + Chain_Node *the_buffer, + Partition_Control *the_partition +) +{ + void *starting; + void *ending; + + starting = the_partition->starting_address; + ending = _Addresses_Add_offset( starting, the_partition->length ); + + return ( + _Addresses_Is_in_range( the_buffer, starting, ending ) && + _Partition_Is_buffer_on_boundary( the_buffer, the_partition ) + ); +} + +/** + * @brief Checks if partition is buffer size aligned. + * + * This function returns TRUE if the use of the specified buffer_size + * will result in the allocation of buffers whose first byte is + * properly aligned, and FALSE otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Partition_Is_buffer_size_aligned ( + uint32_t buffer_size +) +{ + return ((buffer_size % CPU_PARTITION_ALIGNMENT) == 0); +} + +/** + * @brief Allocates a partition control block from the + * inactive chain of free partition control blocks. + * + * This function allocates a partition control block from + * the inactive chain of free partition control blocks. + */ +RTEMS_INLINE_ROUTINE Partition_Control *_Partition_Allocate ( void ) +{ + return (Partition_Control *) _Objects_Allocate( &_Partition_Information ); +} + +RTEMS_INLINE_ROUTINE void _Partition_Initialize( + Partition_Control *the_partition, + void *starting_address, + uint32_t length, + uint32_t buffer_size, + rtems_attribute attribute_set +) +{ + the_partition->starting_address = starting_address; + the_partition->length = length; + the_partition->buffer_size = buffer_size; + the_partition->attribute_set = attribute_set; + the_partition->number_of_used_blocks = 0; + + _Chain_Initialize( + &the_partition->Memory, + starting_address, + length / buffer_size, + buffer_size + ); + + _ISR_lock_Initialize( &the_partition->Lock, "Partition" ); +} + +RTEMS_INLINE_ROUTINE void _Partition_Destroy( + Partition_Control *the_partition +) +{ + _ISR_lock_Destroy( &the_partition->Lock ); +} + +/** + * @brief Frees a partition control block to the + * inactive chain of free partition control blocks. + * + * This routine frees a partition control block to the + * inactive chain of free partition control blocks. + */ +RTEMS_INLINE_ROUTINE void _Partition_Free ( + Partition_Control *the_partition +) +{ + _Objects_Free( &_Partition_Information, &the_partition->Object ); +} + +RTEMS_INLINE_ROUTINE Partition_Control *_Partition_Get( + Objects_Id id, + ISR_lock_Context *lock_context +) +{ + return (Partition_Control *) _Objects_Get( + id, + lock_context, + &_Partition_Information + ); +} + +RTEMS_INLINE_ROUTINE void _Partition_Acquire_critical( + Partition_Control *the_partition, + ISR_lock_Context *lock_context +) +{ + _ISR_lock_Acquire( &the_partition->Lock, lock_context ); +} + +RTEMS_INLINE_ROUTINE void _Partition_Release( + Partition_Control *the_partition, + ISR_lock_Context *lock_context +) +{ + _ISR_lock_Release_and_ISR_enable( &the_partition->Lock, lock_context ); +} + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#if defined(RTEMS_MULTIPROCESSING) +#include +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/partmp.h b/cpukit/include/rtems/rtems/partmp.h new file mode 100644 index 0000000000..b9eaa08b8c --- /dev/null +++ b/cpukit/include/rtems/rtems/partmp.h @@ -0,0 +1,144 @@ +/** + * @file rtems/rtems/partmp.h + * + * @brief MP Support in Partition Manager + * + * This include file contains all the constants and structures associated + * with the Multiprocessing Support in the Partition Manager. + */ + +/* COPYRIGHT (c) 1989-2013. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_PARTMP_H +#define _RTEMS_RTEMS_PARTMP_H + +#ifndef _RTEMS_RTEMS_PARTIMPL_H +# error "Never use directly; include instead." +#endif + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicPartMP Partition MP Support + * + * @ingroup ClassicMP + * + * This encapsulates functionality related to the transparent multiprocessing + * support within the Classic API Partition Manager. + */ +/*{*/ + +/** + * The following enumerated type defines the list of + * remote partition operations. + */ +typedef enum { + PARTITION_MP_ANNOUNCE_CREATE = 0, + PARTITION_MP_ANNOUNCE_DELETE = 1, + PARTITION_MP_EXTRACT_PROXY = 2, + PARTITION_MP_GET_BUFFER_REQUEST = 3, + PARTITION_MP_GET_BUFFER_RESPONSE = 4, + PARTITION_MP_RETURN_BUFFER_REQUEST = 5, + PARTITION_MP_RETURN_BUFFER_RESPONSE = 6 +} Partition_MP_Remote_operations; + +/** + * The following data structure defines the packet used to perform + * remote partition operations. + */ +typedef struct { + rtems_packet_prefix Prefix; + Partition_MP_Remote_operations operation; + rtems_name name; + void *buffer; + Objects_Id proxy_id; +} Partition_MP_Packet; + +RTEMS_INLINE_ROUTINE bool _Partition_MP_Is_remote( Objects_Id id ) +{ + return _Objects_MP_Is_remote( id, &_Partition_Information ); +} + +/** + * @brief Partition_MP_Send_process_packet + * + * Multiprocessing Support for the Partition Manager + * + * This routine performs a remote procedure call so that a + * process operation can be performed on another node. + */ +void _Partition_MP_Send_process_packet ( + Partition_MP_Remote_operations operation, + Objects_Id partition_id, + rtems_name name, + Objects_Id proxy_id +); + +/** + * @brief Issues a remote rtems_partition_get_buffer() request. + */ +rtems_status_code _Partition_MP_Get_buffer( + rtems_id id, + void **buffer +); + +/** + * @brief Issues a remote rtems_partition_return_buffer() request. + */ +rtems_status_code _Partition_MP_Return_buffer( + rtems_id id, + void *buffer +); + +/** + * + * @brief Partition_MP_Process_packet + * + * This routine performs the actions specific to this package for + * the request from another node. + */ +void _Partition_MP_Process_packet ( + rtems_packet_prefix *the_packet_prefix +); + +/* + * @brief Partition_MP_Send_object_was_deleted + * + * This routine is invoked indirectly by the thread queue + * when a proxy has been removed from the thread queue and + * the remote node must be informed of this. + * + * This routine is not needed by the Partition since a partition + * cannot be deleted when buffers are in use. + */ + +/** + * @brief Partition_MP_Send_extract_proxy + * + * This routine is invoked when a task is deleted and it + * has a proxy which must be removed from a thread queue and + * the remote node must be informed of this. + */ +void _Partition_MP_Send_extract_proxy ( + Thread_Control *the_thread, + Objects_Id id +); + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of file */ diff --git a/cpukit/include/rtems/rtems/ratemon.h b/cpukit/include/rtems/rtems/ratemon.h new file mode 100644 index 0000000000..ca48a92983 --- /dev/null +++ b/cpukit/include/rtems/rtems/ratemon.h @@ -0,0 +1,430 @@ +/** + * @file rtems/rtems/ratemon.h + * + * @defgroup ClassicRateMon Rate Monotonic Scheduler + * + * @ingroup ClassicRTEMS + * @brief Classic API Rate Monotonic Manager. + * + * This include file contains all the constants, structures, and + * prototypes associated with the Rate Monotonic Manager. This manager + * provides facilities to implement threads which execute in a periodic + * fashion. + * + * Directives provided are: + * + * - create a rate monotonic timer + * - cancel a period + * - delete a rate monotonic timer + * - conclude current and start the next period + * - obtain status information on a period + * - obtain the number of postponed jobs + */ + +/* COPYRIGHT (c) 1989-2009, 2016. + * On-Line Applications Research Corporation (OAR). + * COPYRIGHT (c) 2016-2017 Kuan-Hsun Chen. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_RATEMON_H +#define _RTEMS_RTEMS_RATEMON_H + +#include +#include +#include +#include + +struct rtems_printer; + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicRateMon Rate Monotonic Scheduler + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality related to the Classic API Rate + * Monotonic Manager. + * + * Statistics are kept for each period and can be obtained or printed via + * API calls. The statistics kept include minimum, maximum and average times + * for both cpu usage and wall time. The statistics indicate the execution + * and wall time used by the owning thread between successive calls to + * rtems_rate_monotonic_period. + */ +/**@{*/ + +/** + * This is the public type used for the rate monotonic timing + * statistics. + */ +#include + +typedef struct timespec rtems_rate_monotonic_period_time_t; + +/** + * This is the internal type used for the rate monotonic timing + * statistics. + */ +#include + +/** + * The following enumerated type defines the states in which a + * period may be. + */ +typedef enum { + /** + * This value indicates the period is off the watchdog chain, + * and has never been initialized. + */ + RATE_MONOTONIC_INACTIVE, + + /** + * This value indicates the period is on the watchdog chain, and + * running. The owner should be executed or blocked waiting on + * another object. + */ + RATE_MONOTONIC_ACTIVE, + + /** + * This value indicates the period is off the watchdog chain, and + * has expired. The owner is still executing and has taken too much + * all time to complete this iteration of the period. + */ + RATE_MONOTONIC_EXPIRED +} rtems_rate_monotonic_period_states; + +/** + * The following constant is the interval passed to the rate_monontonic_period + * directive to obtain status information. + */ +#define RTEMS_PERIOD_STATUS WATCHDOG_NO_TIMEOUT + +/** + * The following defines the PUBLIC data structure that has the + * statistics kept on each period instance. + * + * @note The public structure uses struct timespec while the + * internal one uses Timestamp_Control. + */ +typedef struct { + /** This field contains the number of periods executed. */ + uint32_t count; + /** This field contains the number of periods missed. */ + uint32_t missed_count; + + /** This field contains the least amount of CPU time used in a period. */ + rtems_thread_cpu_usage_t min_cpu_time; + /** This field contains the highest amount of CPU time used in a period. */ + rtems_thread_cpu_usage_t max_cpu_time; + /** This field contains the total amount of wall time used in a period. */ + rtems_thread_cpu_usage_t total_cpu_time; + + /** This field contains the least amount of wall time used in a period. */ + rtems_rate_monotonic_period_time_t min_wall_time; + /** This field contains the highest amount of wall time used in a period. */ + rtems_rate_monotonic_period_time_t max_wall_time; + /** This field contains the total amount of CPU time used in a period. */ + rtems_rate_monotonic_period_time_t total_wall_time; +} rtems_rate_monotonic_period_statistics; + +/** + * The following defines the INTERNAL data structure that has the + * statistics kept on each period instance. + */ +typedef struct { + /** This field contains the number of periods executed. */ + uint32_t count; + /** This field contains the number of periods missed. */ + uint32_t missed_count; + + /** This field contains the least amount of CPU time used in a period. */ + Timestamp_Control min_cpu_time; + /** This field contains the highest amount of CPU time used in a period. */ + Timestamp_Control max_cpu_time; + /** This field contains the total amount of wall time used in a period. */ + Timestamp_Control total_cpu_time; + + /** This field contains the least amount of wall time used in a period. */ + Timestamp_Control min_wall_time; + /** This field contains the highest amount of wall time used in a period. */ + Timestamp_Control max_wall_time; + /** This field contains the total amount of CPU time used in a period. */ + Timestamp_Control total_wall_time; +} Rate_monotonic_Statistics; + +/** + * The following defines the period status structure. + */ +typedef struct { + /** This is the Id of the thread using this period. */ + rtems_id owner; + + /** This is the current state of this period. */ + rtems_rate_monotonic_period_states state; + + /** + * This is the length of wall time that has passed since this period + * was last initiated. If the period is expired or has not been initiated, + * then this field has no meaning. + */ + rtems_rate_monotonic_period_time_t since_last_period; + + /** + * This is the amount of CPU time that has been used since this period + * was last initiated. If the period is expired or has not been initiated, + * then this field has no meaning. + */ + rtems_thread_cpu_usage_t executed_since_last_period; + + /** This is the count of postponed jobs of this period. */ + uint32_t postponed_jobs_count; +} rtems_rate_monotonic_period_status; + +/** + * @brief The following structure defines the control block used to manage each + * period. + * + * State changes are protected by the default thread lock of the owner thread. + * The owner thread is the thread that created the period object. The owner + * thread field is immutable after object creation. + */ +typedef struct { + /** This field is the object management portion of a Period instance. */ + Objects_Control Object; + + /** + * @brief Protects the rate monotonic period state. + */ + ISR_LOCK_MEMBER( Lock ) + + /** This is the timer used to provide the unblocking mechanism. */ + Watchdog_Control Timer; + + /** This field indicates the current state of the period. */ + rtems_rate_monotonic_period_states state; + + /** + * @brief A priority node for use by the scheduler job release and cancel + * operations. + */ + Priority_Node Priority; + + /** + * This field contains the length of the next period to be + * executed. + */ + uint32_t next_length; + + /** + * This field contains a pointer to the TCB for the thread + * which owns and uses this period instance. + */ + Thread_Control *owner; + + /** + * This field contains the cpu usage value of the owning thread when + * the period was initiated. It is used to compute the period's + * statistics. + */ + Timestamp_Control cpu_usage_period_initiated; + + /** + * This field contains the wall time value when the period + * was initiated. It is used to compute the period's statistics. + */ + Timestamp_Control time_period_initiated; + + /** + * This field contains the statistics maintained for the period. + */ + Rate_monotonic_Statistics Statistics; + + /** + * This field contains the number of postponed jobs. + * When the watchdog timeout, this variable will be increased immediately. + */ + uint32_t postponed_jobs; + + /** + * This field contains the tick of the latest deadline decided by the period + * watchdog. + */ + uint64_t latest_deadline; +} Rate_monotonic_Control; + +/** + * @brief Create a Period + * + * Rate Monotonic Manager + * + * This routine implements the rate_monotonic_create directive. The + * period will have the name name. It returns the id of the + * created period in ID. + */ +rtems_status_code rtems_rate_monotonic_create( + rtems_name name, + rtems_id *id +); + +/** + * @brief RTEMS Rate Monotonic Name to Id + * + * This routine implements the rtems_rate_monotonic_ident directive. + * It returns the period ID associated with name. If more than one period + * is named name, then the period to which the ID belongs is arbitrary. + * + * @param[in] name is the user defined period name + * @param[in] id is the pointer to period id + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. If successful, the id will + * be filled in with the region id. + */ +rtems_status_code rtems_rate_monotonic_ident( + rtems_name name, + rtems_id *id +); + +/** + * @brief RTEMS Rate Monotonic Cancel + * + * This routine implements the rtems_rate_monotonic_cancel directive. This + * directive stops the period associated with ID from continuing to + * run. + * + * @param[in] id is the rate monotonic id + * + * @retval RTEMS_SUCCESSFUL if successful and caller is not the owning thread + * or error code if unsuccessful + * + */ +rtems_status_code rtems_rate_monotonic_cancel( + rtems_id id +); + +/** + * @brief RTEMS Delete Rate Monotonic + * + * This routine implements the rtems_rate_monotonic_delete directive. The + * period indicated by ID is deleted. + * + * @param[in] id is the rate monotonic id + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + */ +rtems_status_code rtems_rate_monotonic_delete( + rtems_id id +); + +/** + * @brief RTEMS Rate Monotonic Get Status + * + * This routine implements the rtems_rate_monotonic_get_status directive. + * Information about the period indicated by ID is returned. + * + * @param[in] id is the rate monotonic id + * @param[in] status is the pointer to status control block + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + * + */ +rtems_status_code rtems_rate_monotonic_get_status( + rtems_id id, + rtems_rate_monotonic_period_status *status +); + +/** + * @brief RTEMS Rate Monotonic Get Statistics + * + * This routine implements the rtems_rate_monotonic_get_statistics directive. + * Statistics gathered from the use of this period are returned. + * + * @param[in] id is the rate monotonic id + * @param[in] statistics is the pointer to statistics control block + * + * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful + */ +rtems_status_code rtems_rate_monotonic_get_statistics( + rtems_id id, + rtems_rate_monotonic_period_statistics *statistics +); + +/** + * @brief RTEMS Rate Monotonic Reset Statistics + * + * Rate Monotonic Manager -- Reset Statistics + * + * This routine allows a thread to reset the statistics information + * on a specific period instance. + */ +rtems_status_code rtems_rate_monotonic_reset_statistics( + rtems_id id +); + +/** + * @brief rtems_rate_monotonic_reset_all_statistics + * + * This routine allows a thread to reset the statistics information + * on ALL period instances. + */ +void rtems_rate_monotonic_reset_all_statistics( void ); + +/** + * @brief RTEMS Report Rate Monotonic Statistics + * + * This routine allows a thread to print the statistics information + * on ALL period instances which have non-zero counts using the RTEMS + * printer. The implementation of this directive straddles the fence + * between inside and outside of RTEMS. It is presented as part of + * the Manager but actually uses other services of the Manager. + */ +void rtems_rate_monotonic_report_statistics_with_plugin( + const struct rtems_printer *printer +); + +/** + * @brief RTEMS Report Rate Monotonic Statistics + * + * This routine allows a thread to print the statistics information + * on ALL period instances which have non-zero counts using printk. + */ +void rtems_rate_monotonic_report_statistics( void ); + +/** + * @brief RTEMS Rate Monotonic Period + * + * This routine implements the rtems_rate_monotonic_period directive. When + * length is non-zero, this directive initiates the period associated with + * ID from continuing for a period of length. If length is zero, then + * result is set to indicate the current state of the period. + * + * @param[in] id is the rate monotonic id + * @param[in] length is the length of period (in ticks) + * + * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful + */ +rtems_status_code rtems_rate_monotonic_period( + rtems_id id, + rtems_interval length +); + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/ratemonimpl.h b/cpukit/include/rtems/rtems/ratemonimpl.h new file mode 100644 index 0000000000..ba38a3e61a --- /dev/null +++ b/cpukit/include/rtems/rtems/ratemonimpl.h @@ -0,0 +1,158 @@ +/** + * @file + * + * @ingroup ClassicRateMonImpl + * + * @brief Classic Rate Monotonic Scheduler Implementation + */ + +/* COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * Copyright (c) 2016 embedded brains GmbH. + * COPYRIGHT (c) 2016 Kuan-Hsun Chen. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_RATEMONIMPL_H +#define _RTEMS_RTEMS_RATEMONIMPL_H + +#include +#include +#include +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicRateMonImpl Classic Rate Monotonic Scheduler Implementation + * + * @ingroup ClassicRateMon + * + * @{ + */ + +#define RATE_MONOTONIC_INTEND_TO_BLOCK \ + ( THREAD_WAIT_CLASS_PERIOD | THREAD_WAIT_STATE_INTEND_TO_BLOCK ) + +#define RATE_MONOTONIC_BLOCKED \ + ( THREAD_WAIT_CLASS_PERIOD | THREAD_WAIT_STATE_BLOCKED ) + +#define RATE_MONOTONIC_READY_AGAIN \ + ( THREAD_WAIT_CLASS_PERIOD | THREAD_WAIT_STATE_READY_AGAIN ) + +/** + * @brief Rate Monotonic Period Class Management Structure + * + * This instance of Objects_Information is used to manage the + * set of rate monotonic period instances. + */ +extern Objects_Information _Rate_monotonic_Information; + +/** + * @brief Allocates a period control block from + * the inactive chain of free period control blocks. + * + * This function allocates a period control block from + * the inactive chain of free period control blocks. + */ +RTEMS_INLINE_ROUTINE Rate_monotonic_Control *_Rate_monotonic_Allocate( void ) +{ + return (Rate_monotonic_Control *) + _Objects_Allocate( &_Rate_monotonic_Information ); +} + +RTEMS_INLINE_ROUTINE void _Rate_monotonic_Acquire_critical( + Rate_monotonic_Control *the_period, + ISR_lock_Context *lock_context +) +{ + _ISR_lock_Acquire( &the_period->Lock, lock_context ); +} + +RTEMS_INLINE_ROUTINE void _Rate_monotonic_Release( + Rate_monotonic_Control *the_period, + ISR_lock_Context *lock_context +) +{ + _ISR_lock_Release_and_ISR_enable( &the_period->Lock, lock_context ); +} + +RTEMS_INLINE_ROUTINE Rate_monotonic_Control *_Rate_monotonic_Get( + Objects_Id id, + ISR_lock_Context *lock_context +) +{ + return (Rate_monotonic_Control *) + _Objects_Get( id, lock_context, &_Rate_monotonic_Information ); +} + +void _Rate_monotonic_Timeout( Watchdog_Control *watchdog ); + +/** + * @brief _Rate_monotonic_Get_status( + * + * This routine is invoked to compute the elapsed wall time and cpu + * time for a period. + * + * @param[in] the_period points to the period being operated upon. + * @param[out] wall_since_last_period is set to the wall time elapsed + * since the period was initiated. + * @param[out] cpu_since_last_period is set to the cpu time used by the + * owning thread since the period was initiated. + * + * @retval This routine returns true if the status can be determined + * and false otherwise. + */ +bool _Rate_monotonic_Get_status( + const Rate_monotonic_Control *the_period, + Timestamp_Control *wall_since_last_period, + Timestamp_Control *cpu_since_last_period +); + +void _Rate_monotonic_Restart( + Rate_monotonic_Control *the_period, + Thread_Control *owner, + ISR_lock_Context *lock_context +); + +void _Rate_monotonic_Cancel( + Rate_monotonic_Control *the_period, + Thread_Control *owner, + ISR_lock_Context *lock_context +); + +RTEMS_INLINE_ROUTINE void _Rate_monotonic_Reset_min_time( + Timestamp_Control *min_time +) +{ + _Timestamp_Set( min_time, 0x7fffffff, 0x7fffffff ); +} + +RTEMS_INLINE_ROUTINE void _Rate_monotonic_Reset_statistics( + Rate_monotonic_Control *the_period +) +{ + Rate_monotonic_Statistics *statistics; + + statistics = &the_period->Statistics; + memset( statistics, 0, sizeof( *statistics ) ); + _Rate_monotonic_Reset_min_time( &statistics->min_wall_time ); + _Rate_monotonic_Reset_min_time( &statistics->min_cpu_time ); +} + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/region.h b/cpukit/include/rtems/rtems/region.h new file mode 100644 index 0000000000..4772e2835b --- /dev/null +++ b/cpukit/include/rtems/rtems/region.h @@ -0,0 +1,298 @@ +/** + * @file rtems/rtems/region.h + * + * @defgroup ClassicRegion Regions + * + * @ingroup ClassicRTEMS + * @brief Region Manager + * + * This include file contains all the constants and structures associated + * with the Region Manager. This manager provides facilities to dynamically + * allocate memory in variable sized units which are returned as segments. + * + * Directives provided are: + * + * - create a region + * - get an ID of a region + * - delete a region + * - get a segment from a region + * - return a segment to a region + */ + +/* COPYRIGHT (c) 1989-2013. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_REGION_H +#define _RTEMS_RTEMS_REGION_H + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicRegion Regions + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality related to the Classic API Region + * Manager. + */ +/**@{*/ + +/** + * The following records define the control block used to manage + * each region. + */ + +typedef struct { + Objects_Control Object; + Thread_queue_Control Wait_queue; /* waiting threads */ + const Thread_queue_Operations *wait_operations; + uintptr_t maximum_segment_size; /* in bytes */ + rtems_attribute attribute_set; + Heap_Control Memory; +} Region_Control; + +/** + * @brief rtems_region_create + * + * Region Manager + * + * This routine implements the rtems_region_create directive. The + * region will have the name name. The memory area managed by + * the region is of length bytes and starts at starting_address. + * The memory area will be divided into as many allocatable units of + * page_size bytes as possible. The attribute_set determines which + * thread queue discipline is used by the region. It returns the + * id of the created region in ID. + */ +rtems_status_code rtems_region_create( + rtems_name name, + void *starting_address, + uintptr_t length, + uintptr_t page_size, + rtems_attribute attribute_set, + rtems_id *id +); + +/** + * @brief RTEMS Extend Region + * + * This routine implements the rtems_region_extend directive. The + * region will have the name name. The memory area managed by + * the region will be attempted to be grown by length bytes using + * the memory starting at starting_address. + * + * @param[in] id is the id of region to grow + * @param[in] starting_address starting address of memory area for extension + * @param[in] length is the physical length in bytes to grow the region + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + */ +rtems_status_code rtems_region_extend( + rtems_id id, + void *starting_address, + uintptr_t length +); + +/** + * @brief RTEMS Region Name to Id + * + * This routine implements the rtems_region_ident directive. + * This directive returns the region ID associated with name. + * If more than one region is named name, then the region + * to which the ID belongs is arbitrary. + * + * @param[in] name is the user defined region name + * @param[in] id is the pointer to region id + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. If successful, the id will + * be filled in with the region id. + */ +rtems_status_code rtems_region_ident( + rtems_name name, + rtems_id *id +); + +/** + * @brief RTEMS Get Region Information + * + * This routine implements the rtems_region_get_information directive. + * This directive returns information about the heap associated with + * this region. + * + * @param[in] id is the region id + * @param[in] the_info is the pointer to region information block + * + * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful and + * *id filled with the region information block + */ +rtems_status_code rtems_region_get_information( + rtems_id id, + Heap_Information_block *the_info +); + +/** + * @brief RTEMS Get Region Free Information + * + * This routine implements the rtems_region_get_free_information directive. + * This directive returns information about the free blocks in the + * heap associated with this region. Information about the used blocks + * will be returned as zero. + * + * @param[in] id is the region id + * @param[in] the_info is the pointer to region information block + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. If successful, the the_info will + * be filled in with the region information block. + */ +rtems_status_code rtems_region_get_free_information( + rtems_id id, + Heap_Information_block *the_info +); + +/** + * @brief RTEMS Delete Region + * + * This routine implements the rtems_region_delete directive. The + * region indicated by ID is deleted, provided that none of its segments are + * still allocated. + * + * @param[in] id is the region id + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + */ +rtems_status_code rtems_region_delete( + rtems_id id +); + +/** + * @brief RTEMS Get Region Segment + * + * This routine implements the rtems_region_get_segment directive. It + * attempts to allocate a segment from the region associated with @a id. + * If a segment of the requested @a size size can be allocated, its address + * is returned in @a segment. If no segment is available, then the task + * may return immediately or block waiting for a segment with an optional + * timeout of @a timeout clock ticks. Whether the task blocks or returns + * immediately is based on the no_wait option in the @a option_set. + * + * @param[in] id is the region id + * @param[in] size is the segment size in bytes + * @param[in] option_set is the wait option + * @param[in] timeout is the number of ticks to wait (0 means wait forever) + * @param[in] segment is the pointer to segment address + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. If successful, the segment will + * be filled in with the segment address. + */ +rtems_status_code rtems_region_get_segment( + rtems_id id, + uintptr_t size, + rtems_option option_set, + rtems_interval timeout, + void **segment +); + +/** + * @brief RTEMS Get Region Segment Size + * + * This routine implements the rtems_region_get_segment_size directive. It + * returns the size in bytes of the specified user memory area. + * + * @param[in] id is the region id + * @param[in] segment is the segment address + * @param[in] size is the pointer to segment size in bytes + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. If successful, the size will + * be filled in with the segment size in bytes. + */ +rtems_status_code rtems_region_get_segment_size( + rtems_id id, + void *segment, + uintptr_t *size +); + +/** + * @brief RTEMS Return Region Segment + * + * This routine implements the rtems_region_return_segment directive. It + * frees the segment to the region associated with ID. The segment must + * have been previously allocated from the same region. If freeing the + * segment results in enough memory being available to satisfy the + * rtems_region_get_segment of the first blocked task, then that task and as + * many subsequent tasks as possible will be unblocked with their requests + * satisfied. + * + * @param[in] id is the region id + * @param[in] segment is the pointer to segment address + * + * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful + */ +rtems_status_code rtems_region_return_segment( + rtems_id id, + void *segment +); + +/** + * @brief Resize RTEMS Region Segment + * + * This routine implements the rtems_region_resize_segment directive. It + * tries to resize segment in the region associated with 'id' to the new size + * 'size' in place. The first 'size' or old size bytes of the segment + * (whatever is less) are guaranteed to remain unmodified. The segment must + * have been previously allocated from the same region. If resizing the + * segment results in enough memory being available to satisfy the + * rtems_region_get_segment of the first blocked task, then that task and as + * many subsequent tasks as possible will be unblocked with their requests + * satisfied. + * + * @param[in] id is the region id + * @param[in] segment is the pointer to segment address + * @param[in] size is the new required size + * @retval RTEMS_SUCCESSFUL if operation successful, RTEMS_UNSATISFIED if the + * the segment can't be resized in place or any other code at failure + * + * @note On RTEMS_SUCCESSFUL or RTEMS_UNSATISFIED exit it returns into the + * 'old_size' the old size in bytes of the user memory area of the + * specified segment. + */ +rtems_status_code rtems_region_resize_segment( + rtems_id id, + void *segment, + uintptr_t size, + uintptr_t *old_size +); + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/regionimpl.h b/cpukit/include/rtems/rtems/regionimpl.h new file mode 100644 index 0000000000..178b7ea32b --- /dev/null +++ b/cpukit/include/rtems/rtems/regionimpl.h @@ -0,0 +1,142 @@ +/** + * @file + * + * @ingroup ClassicRegionImpl + * + * @brief Classic Region Manager Implementation + */ + +/* COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_REGIONIMPL_H +#define _RTEMS_RTEMS_REGIONIMPL_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicRegionImpl Classic Region Manager Implementation + * + * @ingroup ClassicRegion + * + * @{ + */ + +#define REGION_OF_THREAD_QUEUE_QUEUE( queue ) \ + RTEMS_CONTAINER_OF( queue, Region_Control, Wait_queue.Queue ) + +/** + * The following defines the information control block used to + * manage this class of objects. + */ +extern Objects_Information _Region_Information; + +/** + * @brief Region_Allocate + * + * This function allocates a region control block from + * the inactive chain of free region control blocks. + */ +RTEMS_INLINE_ROUTINE Region_Control *_Region_Allocate( void ) +{ + return (Region_Control *) _Objects_Allocate( &_Region_Information ); +} + +/** + * @brief Region_Free + * + * This routine frees a region control block to the + * inactive chain of free region control blocks. + */ +RTEMS_INLINE_ROUTINE void _Region_Free ( + Region_Control *the_region +) +{ + _Thread_queue_Destroy( &the_region->Wait_queue ); + _Objects_Free( &_Region_Information, &the_region->Object ); +} + +RTEMS_INLINE_ROUTINE Region_Control *_Region_Get_and_lock( Objects_Id id ) +{ + Region_Control *the_region; + + _RTEMS_Lock_allocator(); + + the_region = (Region_Control *) + _Objects_Get_no_protection( id, &_Region_Information ); + + if ( the_region != NULL ) { + /* Keep allocator lock */ + return the_region; + } + + _RTEMS_Unlock_allocator(); + return NULL; +} + +RTEMS_INLINE_ROUTINE void _Region_Unlock( Region_Control *the_region ) +{ + (void) the_region; + _RTEMS_Unlock_allocator(); +} + +/** + * @brief Region_Allocate_segment + * + * This function attempts to allocate a segment from the_region. + * If successful, it returns the address of the allocated segment. + * Otherwise, it returns NULL. + */ +RTEMS_INLINE_ROUTINE void *_Region_Allocate_segment ( + Region_Control *the_region, + uintptr_t size +) +{ + return _Heap_Allocate( &the_region->Memory, size ); +} + +/** + * @brief Region_Free_segment + * + * This function frees the_segment to the_region. + */ +RTEMS_INLINE_ROUTINE bool _Region_Free_segment ( + Region_Control *the_region, + void *the_segment +) +{ + return _Heap_Free( &the_region->Memory, the_segment ); +} + +/** + * @brief Process Region Queue + * + * This is a helper routine which is invoked any time memory is + * freed. It looks at the set of waiting tasks and attempts to + * satisfy all outstanding requests. + * + * @param[in] the_region is the the region + */ +extern void _Region_Process_queue(Region_Control *the_region); + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/sem.h b/cpukit/include/rtems/rtems/sem.h new file mode 100644 index 0000000000..41b0061979 --- /dev/null +++ b/cpukit/include/rtems/rtems/sem.h @@ -0,0 +1,278 @@ +/** + * @file + * + * @ingroup ClassicSem + * + * @brief Classic Semaphores API + * + * This include file contains all the constants and structures associated + * with the Semaphore Manager. This manager utilizes standard Dijkstra + * counting semaphores to provide synchronization and mutual exclusion + * capabilities. + * + * Directives provided are: + * + * - create a semaphore + * - get an ID of a semaphore + * - delete a semaphore + * - acquire a semaphore + * - release a semaphore + * - flush a semaphore + * - set ceiling priority for a semaphore + */ + +/* + * COPYRIGHT (c) 1989-2008, 2016. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_SEM_H +#define _RTEMS_RTEMS_SEM_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicSem Semaphores + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality related to the Classic API + * Semaphore Manager. + */ +/**@{*/ + +/** + * The following defines the control block used to manage each semaphore. + */ +typedef struct { + /** This field is the object management portion of a Semaphore instance. */ + Objects_Control Object; + + /** + * This contains the memory associated with the SuperCore Semaphore or + * Mutex instance that provides the primary functionality of each + * Classic API Semaphore instance. The structure used is dependent + * on the attributes specified by the user on the create directive. + * + * @note Only one of these has meaning in a particular Classic API + * Semaphore instance. + */ + union { + /** + * @brief The thread queue present in all other variants. + */ + Thread_queue_Control Wait_queue; + + /** + * This is the SuperCore Mutex instance associated with this Classic + * API Semaphore instance. + */ + CORE_ceiling_mutex_Control Mutex; + + /** + * This is the SuperCore Semaphore instance associated with this Classic + * API Semaphore instance. + */ + CORE_semaphore_Control Semaphore; + +#if defined(RTEMS_SMP) + MRSP_Control MRSP; +#endif + } Core_control; + + /** + * @brief The semaphore variant. + * + * @see Semaphore_Variant. + */ + unsigned int variant : 3; + + /** + * @brief The semaphore thread queue discipline. + * + * @see Semaphore_Discipline. + */ + unsigned int discipline : 1; + +#if defined(RTEMS_MULTIPROCESSING) + unsigned int is_global : 1; +#endif +} Semaphore_Control; + +/** + * @brief rtems_semaphore_create + * + * This routine implements the rtems_semaphore_create directive. The + * semaphore will have the name name. The starting count for + * the semaphore is count. The attribute_set determines if + * the semaphore is global or local and the thread queue + * discipline. It returns the id of the created semaphore in ID. + */ +rtems_status_code rtems_semaphore_create( + rtems_name name, + uint32_t count, + rtems_attribute attribute_set, + rtems_task_priority priority_ceiling, + rtems_id *id +); + +/** + * @brief RTEMS Semaphore Name to Id + * + * This routine implements the rtems_semaphore_ident directive. + * This directive returns the semaphore ID associated with name. + * If more than one semaphore is named name, then the semaphore + * to which the ID belongs is arbitrary. node indicates the + * extent of the search for the ID of the semaphore named name. + * The search can be limited to a particular node or allowed to + * encompass all nodes. + * + * @param[in] name is the user defined semaphore name + * @param[in] node is(are) the node(s) to be searched + * @param[in] id is the pointer to semaphore id + * + * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful and + * *id filled in with the semaphore id + */ +rtems_status_code rtems_semaphore_ident( + rtems_name name, + uint32_t node, + rtems_id *id +); + +/** + * @brief RTEMS Delete Semaphore + * + * This routine implements the rtems_semaphore_delete directive. The + * semaphore indicated by ID is deleted. + * + * @param[in] id is the semaphore id + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + */ +rtems_status_code rtems_semaphore_delete( + rtems_id id +); + +/** + * @brief RTEMS Obtain Semaphore + * + * This routine implements the rtems_semaphore_obtain directive. It + * attempts to obtain a unit from the semaphore associated with ID. + * If a unit can be allocated, the calling task will return immediately. + * If no unit is available, then the task may return immediately or + * block waiting for a unit with an optional timeout of timeout + * clock ticks. Whether the task blocks or returns immediately + * is based on the RTEMS_NO_WAIT option in the option_set. + * + * @param[in] id is the semaphore id + * @param[in] option_set is the wait option + * @param[in] timeout is the number of ticks to wait (0 means wait forever) + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + */ +rtems_status_code rtems_semaphore_obtain( + rtems_id id, + rtems_option option_set, + rtems_interval timeout +); + +/** + * @brief RTEMS Semaphore Release + * + * This routine implements the rtems_semaphore_release directive. It + * frees a unit to the semaphore associated with ID. If a task was + * blocked waiting for a unit from this semaphore, then that task will + * be readied and the unit given to that task. Otherwise, the unit + * will be returned to the semaphore. + */ +rtems_status_code rtems_semaphore_release( + rtems_id id +); + +/** + * @brief RTEMS Semaphore Flush + * + * This method is the implementation of the flush directive + * of the Semaphore Manager. + * + * This directive allows a thread to flush the threads + * pending on the semaphore. + * + * @param[in] id is the semaphore id + * + * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful + */ +rtems_status_code rtems_semaphore_flush( + rtems_id id +); + +/** + * @brief Sets the priority value with respect to the specified scheduler of a + * semaphore. + * + * The special priority value @ref RTEMS_CURRENT_PRIORITY can be used to get + * the current priority value without changing it. + * + * The interpretation of the priority value depends on the protocol of the + * semaphore object. + * + * - The Multiprocessor Resource Sharing Protocol needs a ceiling priority per + * scheduler instance. This operation can be used to specify these priority + * values. + * - For the Priority Ceiling Protocol the ceiling priority is used with this + * operation. + * - For other protocols this operation is not defined. + * + * @param[in] semaphore_id Identifier of the semaphore. + * @param[in] scheduler_id Identifier of the scheduler. + * @param[in] new_priority The new priority value. Use + * @ref RTEMS_CURRENT_PRIORITY to not set a new priority and only get the + * current priority. + * @param[out] old_priority Reference to store the old priority value. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_ID Invalid semaphore or scheduler identifier. + * @retval RTEMS_INVALID_ADDRESS The old priority reference is @c NULL. + * @retval RTEMS_INVALID_PRIORITY The new priority value is invalid. + * @retval RTEMS_NOT_DEFINED The set priority operation is not defined for the + * protocol of this semaphore object. + * @retval RTEMS_ILLEGAL_ON_REMOTE_OBJECT Not supported for remote semaphores. + * + * @see rtems_scheduler_ident() and rtems_task_set_priority(). + */ +rtems_status_code rtems_semaphore_set_priority( + rtems_id semaphore_id, + rtems_id scheduler_id, + rtems_task_priority new_priority, + rtems_task_priority *old_priority +); + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/semimpl.h b/cpukit/include/rtems/rtems/semimpl.h new file mode 100644 index 0000000000..6d0f156e5c --- /dev/null +++ b/cpukit/include/rtems/rtems/semimpl.h @@ -0,0 +1,120 @@ +/** + * @file + * + * @ingroup ClassicSem + * + * @brief Classic Semaphores Implementation + */ + +/* COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_SEMIMPL_H +#define _RTEMS_RTEMS_SEMIMPL_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Classic semaphore variants. + * + * Must be in synchronization with Semaphore_Control::variant. + */ +typedef enum { + SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY, + SEMAPHORE_VARIANT_MUTEX_PRIORITY_CEILING, + SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL, + SEMAPHORE_VARIANT_SIMPLE_BINARY, + SEMAPHORE_VARIANT_COUNTING +#if defined(RTEMS_SMP) + , + SEMAPHORE_VARIANT_MRSP +#endif +} Semaphore_Variant; + +typedef enum { + SEMAPHORE_DISCIPLINE_PRIORITY, + SEMAPHORE_DISCIPLINE_FIFO +} Semaphore_Discipline; + +/** + * The following defines the information control block used to manage + * this class of objects. + */ +extern Objects_Information _Semaphore_Information; + +RTEMS_INLINE_ROUTINE const Thread_queue_Operations *_Semaphore_Get_operations( + const Semaphore_Control *the_semaphore +) +{ + if ( the_semaphore->variant == SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY ) { + return &_Thread_queue_Operations_priority_inherit; + } + + if ( the_semaphore->discipline == SEMAPHORE_DISCIPLINE_PRIORITY ) { + return &_Thread_queue_Operations_priority; + } + + return &_Thread_queue_Operations_FIFO; +} + +/** + * @brief Allocates a semaphore control block from + * the inactive chain of free semaphore control blocks. + * + * This function allocates a semaphore control block from + * the inactive chain of free semaphore control blocks. + */ +RTEMS_INLINE_ROUTINE Semaphore_Control *_Semaphore_Allocate( void ) +{ + return (Semaphore_Control *) _Objects_Allocate( &_Semaphore_Information ); +} + +/** + * @brief Frees a semaphore control block to the + * inactive chain of free semaphore control blocks. + * + * This routine frees a semaphore control block to the + * inactive chain of free semaphore control blocks. + */ +RTEMS_INLINE_ROUTINE void _Semaphore_Free ( + Semaphore_Control *the_semaphore +) +{ + _Objects_Free( &_Semaphore_Information, &the_semaphore->Object ); +} + +RTEMS_INLINE_ROUTINE Semaphore_Control *_Semaphore_Get( + Objects_Id id, + Thread_queue_Context *queue_context +) +{ + _Thread_queue_Context_initialize( queue_context ); + return (Semaphore_Control *) _Objects_Get( + id, + &queue_context->Lock_context.Lock_context, + &_Semaphore_Information + ); +} + +#ifdef __cplusplus +} +#endif + +#ifdef RTEMS_MULTIPROCESSING +#include +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/semmp.h b/cpukit/include/rtems/rtems/semmp.h new file mode 100644 index 0000000000..9d7669f43e --- /dev/null +++ b/cpukit/include/rtems/rtems/semmp.h @@ -0,0 +1,171 @@ +/** + * @file rtems/rtems/semmp.h + * + * @defgroup ClassicSEM Semaphore MP Support + * + * @ingroup ClassicRTEMS + * @brief Semaphore Manager MP Support + * + * This include file contains all the constants and structures associated + * with the Multiprocessing Support in the Semaphore Manager. + */ + +/* COPYRIGHT (c) 1989-2013. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_SEMMP_H +#define _RTEMS_RTEMS_SEMMP_H + +#ifndef _RTEMS_RTEMS_SEMIMPL_H +# error "Never use directly; include instead." +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicSEM Semaphore MP Support + * + * @ingroup ClassicMP + * + * This encapsulates functionality related to the transparent multiprocessing + * support within the Classic API Semaphore Manager. + */ +/**@{*/ + +/** + * The following enumerated type defines the list of + * remote semaphore operations. + */ +typedef enum { + SEMAPHORE_MP_ANNOUNCE_CREATE = 0, + SEMAPHORE_MP_ANNOUNCE_DELETE = 1, + SEMAPHORE_MP_EXTRACT_PROXY = 2, + SEMAPHORE_MP_OBTAIN_REQUEST = 3, + SEMAPHORE_MP_OBTAIN_RESPONSE = 4, + SEMAPHORE_MP_RELEASE_REQUEST = 5, + SEMAPHORE_MP_RELEASE_RESPONSE = 6 +} Semaphore_MP_Remote_operations; + +/** + * The following data structure defines the packet used to perform + * remote semaphore operations. + */ +typedef struct { + rtems_packet_prefix Prefix; + Semaphore_MP_Remote_operations operation; + rtems_name name; + rtems_option option_set; + Objects_Id proxy_id; +} Semaphore_MP_Packet; + +RTEMS_INLINE_ROUTINE bool _Semaphore_MP_Is_remote( Objects_Id id ) +{ + return _Objects_MP_Is_remote( id, &_Semaphore_Information ); +} + +/** + * @brief Semaphore MP Send Process Packet + * + * This routine performs a remote procedure call so that a + * process operation can be performed on another node. + */ +void _Semaphore_MP_Send_process_packet ( + Semaphore_MP_Remote_operations operation, + Objects_Id semaphore_id, + rtems_name name, + Objects_Id proxy_id +); + +/** + * @brief Issues a remote rtems_semaphore_obtain() request. + */ +rtems_status_code _Semaphore_MP_Obtain( + rtems_id id, + rtems_option option_set, + rtems_interval timeout +); + +/** + * @brief Issues a remote rtems_semaphore_release() request. + */ +rtems_status_code _Semaphore_MP_Release( rtems_id id ); + +/** + * @brief Semaphore MP Process Packet + * + * This routine performs the actions specific to this package for + * the request from another node. + */ +void _Semaphore_MP_Process_packet ( + rtems_packet_prefix *the_packet_prefix +); + +/** + * @brief Semaphore MP Send Object was Deleted + * + * This routine is invoked indirectly by the thread queue + * when a proxy has been removed from the thread queue and + * the remote node must be informed of this. + */ +void _Semaphore_MP_Send_object_was_deleted ( + Thread_Control *the_proxy, + Objects_Id mp_id +); + +/** + * @brief Semaphore MP Send Extract Proxy + * + * This routine is invoked when a task is deleted and it + * has a proxy which must be removed from a thread queue and + * the remote node must be informed of this. + */ +void _Semaphore_MP_Send_extract_proxy ( + Thread_Control *the_thread, + Objects_Id id +); + +/** + * @brief Semaphore Core Mutex MP Support + * + * This function processes the global actions necessary for remote + * accesses to a global semaphore based on a core mutex. This function + * is called by the core. + * + * @param[in] the_thread the remote thread the semaphore was surrendered to + * @param[in] id is the id of the surrendered semaphore + */ +void _Semaphore_Core_mutex_mp_support ( + Thread_Control *the_thread, + Objects_Id id +); + +/** + * @brief Semaphore Core MP Support + * + * This function processes the global actions necessary for remote + * accesses to a global semaphore based on a core semaphore. This function + * is called by the core. + * + * @param[in] the_thread the remote thread the semaphore was surrendered to + * @param[in] id is the id of the surrendered semaphore + */ +void _Semaphore_Core_semaphore_mp_support ( + Thread_Control *the_thread, + Objects_Id id +); + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of file */ diff --git a/cpukit/include/rtems/rtems/signal.h b/cpukit/include/rtems/rtems/signal.h new file mode 100644 index 0000000000..f7b7000d9a --- /dev/null +++ b/cpukit/include/rtems/rtems/signal.h @@ -0,0 +1,83 @@ +/** + * @file + * + * @ingroup ClassicSignal + * + * @brief Signals API + */ + +/* COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_SIGNAL_H +#define _RTEMS_RTEMS_SIGNAL_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicSignal Signals + * + * @ingroup ClassicRTEMS + * + * Directives provided are: + * + * + establish an asynchronous signal routine + * + send a signal set to a task + */ +/**@{*/ + +/** + * @brief RTEMS Catch Signal + * + * This routine implements the rtems_signal_catch directive. This directive + * is used to establish asr_handler as the Asynchronous Signal Routine + * (RTEMS_ASR) for the calling task. The asr_handler will execute with a + * mode of mode_set. + * + * @param[in] asr_handler is the address of asynchronous signal routine (asr) + * ( NULL indicates asr is invalid ) + * @param[in] mode_set is the mode value for asr + * + * @retval RTEMS_SUCCESSFUL + */ +rtems_status_code rtems_signal_catch( + rtems_asr_entry asr_handler, + rtems_mode mode_set +); + +/** + * @brief RTEMS Send Signal + * + * This routine implements the rtems_signal_send directive. This directive + * sends the signal_set to the task specified by ID. + * + * @param[in] id is the thread thread id + * @param[in] signal_set is the signal set + * + * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful + */ +rtems_status_code rtems_signal_send( + rtems_id id, + rtems_signal_set signal_set +); + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/signalimpl.h b/cpukit/include/rtems/rtems/signalimpl.h new file mode 100644 index 0000000000..61848ae95c --- /dev/null +++ b/cpukit/include/rtems/rtems/signalimpl.h @@ -0,0 +1,51 @@ +/** + * @file + * + * @ingroup ClassicSignalImpl + * + * @brief Signals Implementation + */ + +/* COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_SIGNALIMPL_H +#define _RTEMS_RTEMS_SIGNALIMPL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicSignalImpl Signals Implementation + * + * @ingroup ClassicSignal + */ +/**@{*/ + +void _Signal_Action_handler( + Thread_Control *executing, + Thread_Action *action, + ISR_lock_Context *lock_context +); + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#if defined(RTEMS_MULTIPROCESSING) +#include +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/signalmp.h b/cpukit/include/rtems/rtems/signalmp.h new file mode 100644 index 0000000000..57b8682c58 --- /dev/null +++ b/cpukit/include/rtems/rtems/signalmp.h @@ -0,0 +1,98 @@ +/** + * @file rtems/rtems/signalmp.h + * + * @brief Signal MP Support + * + * This include file contains all the constants and structures associated + * with the Multiprocessing Support in the Signal Manager. + */ + +/* COPYRIGHT (c) 1989-2013. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_SIGNALMP_H +#define _RTEMS_RTEMS_SIGNALMP_H + +#ifndef _RTEMS_RTEMS_SIGNALIMPL_H +# error "Never use directly; include instead." +#endif + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicSignalMP Signal MP Support + * + * @ingroup ClassicMP + * + * This encapsulates functionality related to the transparent multiprocessing + * support within the Classic API Signal Manager. + */ +/*{*/ + +/* + * @brief Signal_MP_Send_process_packet + * + * This routine performs a remote procedure call so that a + * process operation can be performed on another node. + * + * This routine is not needed since there are no process + * packets to be sent by this manager. + */ + +/** + * @brief Issues a remote rtems_signal_send() request. + */ +rtems_status_code _Signal_MP_Send( + rtems_id id, + rtems_signal_set signal_set +); + +/** + * @brief Signal MP Process Packet + * + * This routine performs the actions specific to this package for + * the request from another node. + */ +void _Signal_MP_Process_packet ( + rtems_packet_prefix *the_packet_prefix +); + +/* + * @brief Signal_MP_Send_object_was_deleted + * + * This routine is invoked indirectly by the thread queue + * when a proxy has been removed from the thread queue and + * the remote node must be informed of this. + * + * This routine is not needed since there are no objects + * deleted by this manager. + */ + +/* + * @brief Signal_MP_Send_extract_proxy + * + * This routine is invoked when a task is deleted and it + * has a proxy which must be removed from a thread queue and + * the remote node must be informed of this. + * + * This routine is not needed since there are no objects + * deleted by this manager. + */ + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of file */ diff --git a/cpukit/include/rtems/rtems/smp.h b/cpukit/include/rtems/rtems/smp.h new file mode 100644 index 0000000000..aeb0df6f46 --- /dev/null +++ b/cpukit/include/rtems/rtems/smp.h @@ -0,0 +1,78 @@ +/** + * @file + * + * @ingroup ClassicSMP + * + * @brief SMP Services API + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_SMP_H +#define _RTEMS_RTEMS_SMP_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicSMP SMP Services + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality which is useful for SMP applications. + * + * @{ + */ + +/** + * @brief Returns the count of processors in the system. + * + * On uni-processor configurations a value of one will be returned. + * + * On SMP configurations this returns the value of a global variable set during + * system initialization to indicate the count of utilized processors. The + * processor count depends on the physically or virtually available processors + * and application configuration. The value will always be less than or equal + * to the maximum count of application configured processors. + * + * @return The count of processors being utilized. + */ +uint32_t rtems_get_processor_count(void); + +/** + * @brief Returns the index of the current processor. + * + * On uni-processor configurations a value of zero will be returned. + * + * On SMP configurations an architecture specific method is used to obtain the + * index of the current processor in the system. The set of processor indices + * is the range of integers starting with zero up to the processor count minus + * one. + * + * Outside of sections with disabled thread dispatching the current processor + * index may change after every instruction since the thread may migrate from + * one processor to another. Sections with disabled interrupts are sections + * with thread dispatching disabled. + * + * @return The index of the current processor. + */ +uint32_t rtems_get_current_processor(void); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/status.h b/cpukit/include/rtems/rtems/status.h new file mode 100644 index 0000000000..c54404ba14 --- /dev/null +++ b/cpukit/include/rtems/rtems/status.h @@ -0,0 +1,263 @@ +/** + * @file rtems/rtems/status.h + * + * @defgroup ClassicStatus Status Codes + * + * @ingroup ClassicRTEMS + * @brief Status Codes Returned from Executive Directives + * + * This include file contains the status codes returned from the + * executive directives. + */ + +/* COPYRIGHT (c) 1989-2013. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_STATUS_H +#define _RTEMS_RTEMS_STATUS_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicStatus Status Codes + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality related to the status codes returned + * by Classic API directives. + */ +/**@{*/ + +/** + * @brief Classic API Status + * + * This enumerates the possible status values returned b + * Classic API directives. + */ +typedef enum { + /** + * This is the status to indicate successful completion. + */ + RTEMS_SUCCESSFUL = 0, + /** + * This is the status to indicate that a thread exited. + */ + RTEMS_TASK_EXITTED = 1, + /** + * This is the status to indicate multiprocessing is not configured. + */ + RTEMS_MP_NOT_CONFIGURED = 2, + /** + * This is the status to indicate that the object name was invalid. + */ + RTEMS_INVALID_NAME = 3, + /** + * This is the status to indicate that the object Id was invalid. + */ + RTEMS_INVALID_ID = 4, + /** + * This is the status to indicate you have attempted to create too many + * instances of a particular object class. + */ + RTEMS_TOO_MANY = 5, + /** + * This is the status to indicate that a blocking directive timed out. + */ + RTEMS_TIMEOUT = 6, + /** + * This is the status to indicate the the object was deleted + * while the task was blocked waiting. + */ + RTEMS_OBJECT_WAS_DELETED = 7, + /** + * This is the status to indicate that the specified size was invalid. + */ + RTEMS_INVALID_SIZE = 8, + /** + * This is the status to indicate that the specified address is invalid. + */ + RTEMS_INVALID_ADDRESS = 9, + /** + * This is the status to indicate that the specified number was invalid. + */ + RTEMS_INVALID_NUMBER = 10, + /** + * This is the status to indicate that the item has not been initialized. + */ + RTEMS_NOT_DEFINED = 11, + /** + * This is the status to indicate that the object still has + * resources in use. + */ + RTEMS_RESOURCE_IN_USE = 12, + /** + * This is the status to indicate that the request was not satisfied. + */ + RTEMS_UNSATISFIED = 13, + /** + * This is the status to indicate that a thread is in wrong state + * was in the wrong execution state for the requested operation. + */ + RTEMS_INCORRECT_STATE = 14, + /** + * This is the status to indicate thread was already suspended. + */ + RTEMS_ALREADY_SUSPENDED = 15, + /** + * This is the status to indicate that the operation is illegal + * on calling thread. + */ + RTEMS_ILLEGAL_ON_SELF = 16, + /** + * This is the status to indicate illegal for remote object. + */ + RTEMS_ILLEGAL_ON_REMOTE_OBJECT = 17, + /** + * This is the status to indicate that the operation should not be + * called from from this excecution environment. + */ + RTEMS_CALLED_FROM_ISR = 18, + /** + * This is the status to indicate that an invalid thread priority + * was provided. + */ + RTEMS_INVALID_PRIORITY = 19, + /** + * This is the status to indicate that the specified date/time was invalid. + */ + RTEMS_INVALID_CLOCK = 20, + /** + * This is the status to indicate that the specified node Id was invalid. + */ + RTEMS_INVALID_NODE = 21, + /** + * This is the status to indicate that the directive was not configured. + */ + RTEMS_NOT_CONFIGURED = 22, + /** + * This is the status to indicate that the caller is not the + * owner of the resource. + */ + RTEMS_NOT_OWNER_OF_RESOURCE = 23, + /** + * This is the status to indicate the the directive or requested + * portion of the directive is not implemented. This is a hint + * that you have stumbled across an opportunity to submit code + * to the RTEMS Project. + */ + RTEMS_NOT_IMPLEMENTED = 24, + /** + * This is the status to indicate that an internal RTEMS inconsistency + * was detected. + */ + RTEMS_INTERNAL_ERROR = 25, + /** + * This is the status to indicate that the directive attempted to allocate + * memory but was unable to do so. + */ + RTEMS_NO_MEMORY = 26, + /** + * This is the status to indicate an driver IO error. + */ + RTEMS_IO_ERROR = 27, + /** + * This is the status is used internally to RTEMS when performing + * operations on behalf of remote tasks. This is referred to as + * proxying operations and this status indicates that the operation + * could not be completed immediately and the "proxy is blocking." + * + * @note This status will @b NOT be returned to the user. + */ + RTEMS_PROXY_BLOCKING = 28 +} rtems_status_code; + +/** + * This is the lowest valid value for a Classic API status code. + */ +#define RTEMS_STATUS_CODES_FIRST RTEMS_SUCCESSFUL + +/** + * This is the highest valid value for a Classic API status code. + */ +#define RTEMS_STATUS_CODES_LAST RTEMS_PROXY_BLOCKING + +/** + * @brief Checks if the status code is equal to RTEMS_SUCCESSFUL. + * + * This function returns TRUE if the status code is equal to RTEMS_SUCCESSFUL, + * and FALSE otherwise. + */ +RTEMS_INLINE_ROUTINE bool rtems_is_status_successful( + rtems_status_code code +) +{ + return (code == RTEMS_SUCCESSFUL); +} + +/** + * @brief Checks if the status code1 is equal to code2. + * + * This function returns TRUE if the status code1 is equal to code2, + * and FALSE otherwise. + */ +RTEMS_INLINE_ROUTINE bool rtems_are_statuses_equal( + rtems_status_code code1, + rtems_status_code code2 +) +{ + return (code1 == code2); +} + +/** + * @brief RTEMS Status Code to Errno Mapping Function + * + * This function recieves an RTEMS status code and returns an + * errno error code. The retval values show the mappings between + * rtems_status_codes and errno error codes. + * + * @retval 0 RTEMS_SUCCESSFUL + * @retval EIO RTEMS_TASK_EXITED, RTEMS_MP_NOT_CONFIGURED, RTEMS_INVALID_ID, + * RTEMS_TOO_MANY, RTEMS_OBJECT_WAS_DELETED, RTEMS_INVALID_SIZE, + * RTEMS_INVALID_ADDRESS, RTEMS_NOT_DEFINED, RTEMS_INCORRECT_STATE, + * RTEMS_ILLEGAL_ON_SELF, RTEMS_ILLEGAL_ON_REMOTE_OBJECT, + * RTEMS_CALLED_FROM_ISR, RTEMS_INVALID_PRIORITY, RTEMS_INTERNAL_ERROR, + * RTEMS_IO_ERROR, RTEMS_PROXY_BLOCKING + * @retval EINVAL RTEMS_INVALID_NAME, RTEMS_INVALID_CLOCK, RTEMS_INVALID_NODE + * @retval ETIMEDOUT RTEMS_TIMEOUT + * @retval EBADF RTEMS_INVALID_NUMBER + * @retval EBUSY RTEMS_RESOURCE_IN_USE + * @retval ENODEV RTEMS_UNSATISFIED + * @retval ENOSYS RTEMS_NOT_IMPLEMENTED, RTEMS_NOT_CONFIGURED + * @retval ENOMEM RTEMS_NO_MEMORY + */ +int rtems_status_code_to_errno(rtems_status_code sc); + +/** + * @brief Returns a text for a status code. + * + * The text for each status code is the enumerator constant. + * + * @param[in] code The status code. + * + * @retval text The status code text. + * @retval "?" The passed status code is invalid. + */ +const char *rtems_status_text( rtems_status_code code ); + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/statusimpl.h b/cpukit/include/rtems/rtems/statusimpl.h new file mode 100644 index 0000000000..8a51bb8b19 --- /dev/null +++ b/cpukit/include/rtems/rtems/statusimpl.h @@ -0,0 +1,64 @@ +/** + * @file + * + * @ingroup ClassicStatusImpl + * + * @brief Classic Status Implementation + */ + +/* COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_STATUSIMPL_H +#define _RTEMS_RTEMS_STATUSIMPL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicStatusImpl Classic Status Implementation + * + * @ingroup ClassicStatus + * + * @{ + */ + +/** + * @brief Status Object Name Errors to Status Array + * + * This array is used to map SuperCore Object Handler return + * codes to Classic API status codes. + */ +extern const rtems_status_code _Status_Object_name_errors_to_status[]; + +RTEMS_INLINE_ROUTINE rtems_status_code _Status_Get( + Status_Control status +) +{ + return (rtems_status_code) STATUS_GET_CLASSIC( status ); +} + +RTEMS_INLINE_ROUTINE rtems_status_code _Status_Get_after_wait( + const Thread_Control *executing +) +{ + return _Status_Get( _Thread_Wait_get_status( executing ) ); +} + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/support.h b/cpukit/include/rtems/rtems/support.h new file mode 100644 index 0000000000..4ebb50cbdf --- /dev/null +++ b/cpukit/include/rtems/rtems/support.h @@ -0,0 +1,170 @@ +/** + * @file + * + * @defgroup ClassicRTEMSWorkspace Workspace + * + * @ingroup ClassicRTEMS + * @brief Classic API support. + */ + +/* COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_SUPPORT_H +#define _RTEMS_RTEMS_SUPPORT_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup ClassicRTEMS + */ +/**@{**/ + +/** + * @brief Returns the number of micro seconds for the milli seconds value @a _ms. + */ +#define RTEMS_MILLISECONDS_TO_MICROSECONDS(_ms) ((_ms) * 1000UL) + +/** + * @brief Returns the number of ticks for the milli seconds value @a _ms. + */ +#define RTEMS_MILLISECONDS_TO_TICKS(_ms) \ + (RTEMS_MILLISECONDS_TO_MICROSECONDS(_ms) / \ + rtems_configuration_get_microseconds_per_tick()) + +/** + * @brief Returns the number of ticks for the micro seconds value @a _us. + */ +#define RTEMS_MICROSECONDS_TO_TICKS(_us) \ + ((_us) / rtems_configuration_get_microseconds_per_tick()) + +/** + * @brief Returns @c true if the name is valid, and @c false otherwise. + */ +RTEMS_INLINE_ROUTINE bool rtems_is_name_valid ( + rtems_name name +) +{ + return ( name != 0 ); +} + +/** + * @brief Breaks the object name into the four component characters @a c1, + * @a c2, @a c3, and @a c4. + */ +RTEMS_INLINE_ROUTINE void rtems_name_to_characters( + rtems_name name, + char *c1, + char *c2, + char *c3, + char *c4 +) +{ + *c1 = (char) ((name >> 24) & 0xff); + *c2 = (char) ((name >> 16) & 0xff); + *c3 = (char) ((name >> 8) & 0xff); + *c4 = (char) ( name & 0xff); +} + +/** @} */ + +/** + * @defgroup ClassicRTEMSWorkspace Workspace + * + * @ingroup ClassicRTEMS + * + * Workspace definitions. + */ +/**@{**/ + +/** + * @brief Gets Workspace Information + * + * Returns information about the heap that is used as the RTEMS Executive + * Workspace in @a the_info. + * + * Returns @c true if successful, and @a false otherwise. + */ +bool rtems_workspace_get_information( + Heap_Information_block *the_info +); + +/** + * @brief Allocates Memory from the Workspace + * + * A number of @a bytes bytes will be allocated from the RTEMS Executive + * Workspace and returned in @a pointer. + * + * Returns @c true if successful, and @a false otherwise. + */ +bool rtems_workspace_allocate( + size_t bytes, + void **pointer +); + +/** + * @brief Frees Memory Allocated from the Workspace + * + * This frees the memory indicated by @a pointer that was allocated from the + * RTEMS Executive Workspace. + * + * Returns @c true if successful, and @a false otherwise. + */ +bool rtems_workspace_free( + void *pointer +); + +/** + * @brief Greedy allocate that empties the workspace. + * + * Afterwards the heap has at most @a block_count allocatable blocks of sizes + * specified by @a block_sizes. The @a block_sizes must point to an array with + * @a block_count members. All other blocks are used. + * + * @see rtems_workspace_greedy_free(). + */ +void *rtems_workspace_greedy_allocate( + const uintptr_t *block_sizes, + size_t block_count +); + +/** + * @brief Greedy allocate all blocks except the largest free block. + * + * Afterwards the heap has at most one allocatable block. This block is the + * largest free block if it exists. The allocatable size of this block is + * stored in @a allocatable_size. All other blocks are used. + * + * @see rtems_workspace_greedy_free(). + */ +void *rtems_workspace_greedy_allocate_all_except_largest( + uintptr_t *allocatable_size +); + +/** + * @brief Frees space of a greedy allocation. + * + * The @a opaque argument must be the return value of + * rtems_workspace_greedy_allocate() or + * rtems_workspace_greedy_allocate_all_except_largest(). + */ +void rtems_workspace_greedy_free( void *opaque ); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/taskmp.h b/cpukit/include/rtems/rtems/taskmp.h new file mode 100644 index 0000000000..e2d70a924e --- /dev/null +++ b/cpukit/include/rtems/rtems/taskmp.h @@ -0,0 +1,132 @@ +/** + * @file rtems/rtems/taskmp.h + * + * @defgroup ClassicTaskMP Task MP Support + * + * @ingroup ClassicRTEMS + * @brief Task Manager MP Support + * + * This include file contains all the constants and structures associated + * with the multiprocessing support in the task manager. + */ + +/* COPYRIGHT (c) 1989-2013. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_TASKMP_H +#define _RTEMS_RTEMS_TASKMP_H + +#ifndef _RTEMS_RTEMS_TASKSIMPL_H +# error "Never use directly; include instead." +#endif + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicTaskMP Task MP Support + * + * @ingroup ClassicMP + * + * This encapsulates functionality related to the transparent multiprocessing + * support within the Classic API Task Manager. + */ +/**@{*/ + +/** + * The following enumerated type defines the list of + * remote task operations. + */ +typedef enum { + RTEMS_TASKS_MP_ANNOUNCE_CREATE = 0, + RTEMS_TASKS_MP_ANNOUNCE_DELETE = 1, + RTEMS_TASKS_MP_SUSPEND_REQUEST = 2, + RTEMS_TASKS_MP_SUSPEND_RESPONSE = 3, + RTEMS_TASKS_MP_RESUME_REQUEST = 4, + RTEMS_TASKS_MP_RESUME_RESPONSE = 5, + RTEMS_TASKS_MP_SET_PRIORITY_REQUEST = 6, + RTEMS_TASKS_MP_SET_PRIORITY_RESPONSE = 7, +} RTEMS_tasks_MP_Remote_operations; + +/** + * @brief RTEMS Tasks MP Send Process Packet + * + * Multiprocessing Support for the RTEMS Task Manager + * + * This routine performs a remote procedure call so that a + * process operation can be performed on another node. + */ +void _RTEMS_tasks_MP_Send_process_packet ( + RTEMS_tasks_MP_Remote_operations operation, + Objects_Id task_id, + rtems_name name +); + +/** + * @brief Issues a remote rtems_task_set_priority() request. + */ +rtems_status_code _RTEMS_tasks_MP_Set_priority( + rtems_id id, + rtems_task_priority new_priority, + rtems_task_priority *old_priority +); + +/** + * @brief Issues a remote rtems_task_suspend() request. + */ +rtems_status_code _RTEMS_tasks_MP_Suspend( rtems_id id ); + +/** + * @brief Issues a remote rtems_task_resume() request. + */ +rtems_status_code _RTEMS_tasks_MP_Resume( rtems_id id ); + +/** + * @brief _RTEMS_tasks_MP_Process_packet + * + * This routine performs the actions specific to this package for + * the request from another node. + */ +void _RTEMS_tasks_MP_Process_packet ( + rtems_packet_prefix *the_packet_prefix +); + +/** + * @brief _RTEMS_tasks_MP_Send_object_was_deleted + * + * This routine is invoked indirectly by the thread queue + * when a proxy has been removed from the thread queue and + * the remote node must be informed of this. + * + * This routine is not needed by RTEMS_tasks since a task + * cannot be deleted when segments are in use. + */ + +/* + * _RTEMS_tasks_MP_Send_extract_proxy + * + * This routine is invoked when a task is deleted and it + * has a proxy which must be removed from a thread queue and + * the remote node must be informed of this. + * + * This routine is not needed since there are no objects + * deleted by this manager. + * + */ + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of file */ diff --git a/cpukit/include/rtems/rtems/tasks.h b/cpukit/include/rtems/rtems/tasks.h new file mode 100644 index 0000000000..585f4c449c --- /dev/null +++ b/cpukit/include/rtems/rtems/tasks.h @@ -0,0 +1,716 @@ +/** + * @file rtems/rtems/tasks.h + * + * @defgroup ClassicTasks Tasks + * + * @ingroup ClassicRTEMS + * @brief RTEMS Tasks + * + * This include file contains all constants and structures associated + * with RTEMS tasks. This manager provides a comprehensive set of directives + * to create, delete, and administer tasks. + * + * Directives provided are: + * + * - create a task + * - get an ID of a task + * - start a task + * - restart a task + * - delete a task + * - suspend a task + * - resume a task + * - set a task's priority + * - change the current task's mode + * - wake up after interval + * - wake up when specified + */ + +/* + * COPYRIGHT (c) 1989-2014. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_TASKS_H +#define _RTEMS_RTEMS_TASKS_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicTasks Tasks + * + * @ingroup ClassicRTEMS + * + * This encapsulates the functionality of the Classic API Task Manager. + * This functionality includes task services such as creation, deletion, + * delays, suspend/resume, and manipulation of execution mode and priority. + */ +/**@{*/ + +/** + * Constant to be used as the ID of current task + */ +#define RTEMS_SELF OBJECTS_ID_OF_SELF + +/** + * This constant is passed to the rtems_task_wake_after directive as the + * interval when a task wishes to yield the CPU. + */ +#define RTEMS_YIELD_PROCESSOR WATCHDOG_NO_TIMEOUT + +/** + * Define the type for an RTEMS API task priority. + */ +typedef uint32_t rtems_task_priority; + +/** + * This is the constant used with the rtems_task_set_priority + * directive to indicate that the caller wants to obtain its + * current priority rather than set it as the name of the + * directive indicates. + */ +#define RTEMS_NO_PRIORITY RTEMS_CURRENT_PRIORITY + +/** + * This constant is the least valid value for a Classic API + * task priority. + */ +#define RTEMS_MINIMUM_PRIORITY (PRIORITY_MINIMUM + 1) + +/** + * This constant is the maximum valid value for a Classic API + * task priority. + * + * @note This is actually the priority of the IDLE thread so + * using this priority will result in having a task + * which never executes. This could be useful if you + * want to ensure that a task does not executes during + * certain operations such as a system mode change. + */ +#define RTEMS_MAXIMUM_PRIORITY ((rtems_task_priority) PRIORITY_MAXIMUM) + +/** + * The following constant is passed to rtems_task_set_priority when the + * caller wants to obtain the current priority. + */ +#define RTEMS_CURRENT_PRIORITY PRIORITY_MINIMUM + +/** + * External API name for Thread_Control + */ +typedef Thread_Control rtems_tcb; + +/** + * The following defines the "return type" of an RTEMS task. + */ +typedef void rtems_task; + +/** + * The following defines the argument to an RTEMS task. + */ +typedef Thread_Entry_numeric_type rtems_task_argument; + +/** + * The following defines the type for the entry point of an RTEMS task. + */ +typedef rtems_task ( *rtems_task_entry )( + rtems_task_argument + ); + +/** + * The following records define the Initialization Tasks Table. + * Each entry contains the information required by RTEMS to + * create and start a user task automatically at executive + * initialization time. + */ +typedef struct { + /** This is the Initialization Task's name. */ + rtems_name name; + /** This is the Initialization Task's stack size. */ + size_t stack_size; + /** This is the Initialization Task's priority. */ + rtems_task_priority initial_priority; + /** This is the Initialization Task's attributes. */ + rtems_attribute attribute_set; + /** This is the Initialization Task's entry point. */ + rtems_task_entry entry_point; + /** This is the Initialization Task's initial mode. */ + rtems_mode mode_set; + /** This is the Initialization Task's argument. */ + rtems_task_argument argument; +} rtems_initialization_tasks_table; + +/** + * @brief RTEMS Task Create + * + * This routine implements the rtems_task_create directive. The task + * will have the name name. The attribute_set can be used to indicate + * that the task will be globally accessible or utilize floating point. + * The task's stack will be stack_size bytes. The task will begin + * execution with initial_priority and initial_modes. It returns the + * id of the created task in ID. + * + * @param[in] name is the user defined thread name + * @param[in] initial_priority is the thread priority + * @param[in] stack_size is the stack size in bytes + * @param[in] initial_modes is the initial thread mode + * @param[in] attribute_set is the thread attributes + * @param[in] id is the pointer to thread id + * + * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful + * and *id thread id filled in + */ +rtems_status_code rtems_task_create( + rtems_name name, + rtems_task_priority initial_priority, + size_t stack_size, + rtems_mode initial_modes, + rtems_attribute attribute_set, + rtems_id *id +); + +/** + * @brief RTEMS Task Name to Id + * + * This routine implements the rtems_task_ident directive. + * This directive returns the task ID associated with name. + * If more than one task is named name, then the task to + * which the ID belongs is arbitrary. node indicates the + * extent of the search for the ID of the task named name. + * The search can be limited to a particular node or allowed to + * encompass all nodes. + * + * @param[in] name is the user defined thread name + * @param[in] node is(are) the node(s) to be searched + * @param[in] id is the pointer to thread id + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. If successful, the id will + * be filled in with the thread id. + */ +rtems_status_code rtems_task_ident( + rtems_name name, + uint32_t node, + rtems_id *id +); + +/** + * @brief RTEMS Delete Task + * + * This routine implements the rtems_task_delete directive. The + * task indicated by ID is deleted. The executive halts execution + * of the thread and frees the thread control block. + * + * @param[in] id is the thread id + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error and id is not the requesting thread. Status code is + * returned indicating the source of the error. Nothing + * is returned if id is the requesting thread (always succeeds). + */ +rtems_status_code rtems_task_delete( + rtems_id id +); + +/** + * @brief RTEMS Task Mode + * + * This routine implements the rtems_task_mode directive. The current + * values of the modes indicated by mask of the calling task are changed + * to that indicated in mode_set. The former mode of the task is + * returned in mode_set. + * + * @param[in] mode_set is the new mode + * @param[in] mask is the mask + * @param[in] previous_mode_set is the address of previous mode set + * + * @retval RTEMS_SUCCESSFUL and previous_mode_set filled in with the + * previous mode set + */ +rtems_status_code rtems_task_mode( + rtems_mode mode_set, + rtems_mode mask, + rtems_mode *previous_mode_set +); + +/** + * @brief RTEMS Task Restart + * + * This routine implements the rtems_task_restart directive. The + * task associated with ID is restarted at its initial entry + * point with the new argument. + * + * @param[in] id is the thread id + * @param[in] arg is the thread argument + * + * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful + */ +rtems_status_code rtems_task_restart( + rtems_id id, + uint32_t arg +); + +/** + * @brief RTEMS Suspend Task + * + * This routine implements the rtems_task_suspend directive. The + * SUSPENDED state is set for task associated with ID. Note that the + * suspended state can be in addition to other waiting states. + * + * @param[in] id is the thread id + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + */ +rtems_status_code rtems_task_suspend( + rtems_id id +); + +/** + * @brief RTEMS Resume Task + * + * This routine implements the rtems_task_resume Directive. The + * SUSPENDED state is cleared for task associated with ID. + * + * @param[in] id is the thread id + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + */ +rtems_status_code rtems_task_resume( + rtems_id id +); + +/** + * @brief RTEMS Set Task Priority + * + * This routine implements the rtems_task_set_priority directive. The + * current priority of the task associated with ID is set to + * new_priority. The former priority of that task is returned + * in old_priority. + * + * @param[in] id is the thread to extract + * @param[in] new_priority is the thread to extract + * @param[in] old_priority is the thread to extract + * + * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful and + * and *old_priority filled in with the previous previous priority + */ +rtems_status_code rtems_task_set_priority( + rtems_id id, + rtems_task_priority new_priority, + rtems_task_priority *old_priority +); + +/** + * @brief Gets the current priority of the specified task with respect to the + * specified scheduler instance. + * + * The current priority reflects temporary priority adjustments due to locking + * protocols, the rate-monotonic period objects on some schedulers and other + * mechanisms. + * + * @param[in] task_id Identifier of the task. Use @ref RTEMS_SELF to select + * the executing task. + * @param[in] scheduler_id Identifier of the scheduler instance. + * @param[out] priority Returns the current priority of the specified task with + * respect to the specified scheduler instance. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_ILLEGAL_ON_REMOTE_OBJECT Directive is illegal on remote tasks. + * @retval RTEMS_INVALID_ADDRESS The priority parameter is @c NULL. + * @retval RTEMS_INVALID_ID Invalid task or scheduler identifier. + * @retval RTEMS_NOT_DEFINED The task has no priority within the specified + * scheduler instance. This error is only possible on SMP configurations. + * + * @see rtems_scheduler_ident(). + */ +rtems_status_code rtems_task_get_priority( + rtems_id task_id, + rtems_id scheduler_id, + rtems_task_priority *priority +); + +/** + * @brief RTEMS Start Task + * + * RTEMS Task Manager + * + * This routine implements the rtems_task_start directive. The + * starting execution point of the task associated with ID is + * set to entry_point with the initial argument. + */ +rtems_status_code rtems_task_start( + rtems_id id, + rtems_task_entry entry_point, + rtems_task_argument argument +); + +/** + * @brief RTEMS Task Wake When + * + * This routine implements the rtems_task_wake_when directive. The + * calling task is blocked until the current time of day is + * equal to that indicated by time_buffer. + * + * @param[in] time_buffer is the pointer to the time and date structure + * + * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful + */ +rtems_status_code rtems_task_wake_when( + rtems_time_of_day *time_buffer +); + +/** + * @brief RTEMS Task Wake After + * + * This routine implements the rtems_task_wake_after directive. The + * calling task is blocked until the indicated number of clock + * ticks have occurred. + * + * @param[in] ticks is the number of ticks to wait + * @retval RTEMS_SUCCESSFUL + */ +rtems_status_code rtems_task_wake_after( + rtems_interval ticks +); + +/** + * @brief rtems_task_is_suspended + * + * This directive returns a status indicating whether or not + * the specified task is suspended. + */ +rtems_status_code rtems_task_is_suspended( + rtems_id id +); + +/** + * @brief Gets the processor affinity set of a task. + * + * @param[in] id Identifier of the task. Use @ref RTEMS_SELF to select the + * executing task. + * @param[in] cpusetsize Size of the specified affinity set buffer in + * bytes. This value must be positive. + * @param[out] cpuset The current processor affinity set of the task. A set + * bit in the affinity set means that the task can execute on this processor + * and a cleared bit means the opposite. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_ADDRESS The @a cpuset parameter is @c NULL. + * @retval RTEMS_INVALID_ID Invalid task identifier. + * @retval RTEMS_INVALID_NUMBER The affinity set buffer is too small for the + * current processor affinity set of the task. + */ +rtems_status_code rtems_task_get_affinity( + rtems_id id, + size_t cpusetsize, + cpu_set_t *cpuset +); + +/** + * @brief Sets the processor affinity set of a task. + * + * This function will not change the scheduler of the task. The intersection + * of the processor affinity set and the set of processors owned by the + * scheduler of the task must be non-empty. It is not an error if the + * processor affinity set contains processors that are not part of the set of + * processors owned by the scheduler instance of the task. A task will simply + * not run under normal circumstances on these processors since the scheduler + * ignores them. Some locking protocols may temporarily use processors that + * are not included in the processor affinity set of the task. It is also not + * an error if the processor affinity set contains processors that are not part + * of the system. + * + * @param[in] id Identifier of the task. Use @ref RTEMS_SELF to select the + * executing task. + * @param[in] cpusetsize Size of the specified affinity set buffer in + * bytes. This value must be positive. + * @param[in] cpuset The new processor affinity set for the task. A set bit in + * the affinity set means that the task can execute on this processor and a + * cleared bit means the opposite. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_ADDRESS The @a cpuset parameter is @c NULL. + * @retval RTEMS_INVALID_ID Invalid task identifier. + * @retval RTEMS_INVALID_NUMBER Invalid processor affinity set. + */ +rtems_status_code rtems_task_set_affinity( + rtems_id id, + size_t cpusetsize, + const cpu_set_t *cpuset +); + +/** + * @brief Gets the scheduler of a task. + * + * @param[in] task_id Identifier of the task. Use @ref RTEMS_SELF to select + * the executing task. + * @param[out] scheduler_id Identifier of the scheduler instance. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_ADDRESS The @a scheduler_id parameter is @c NULL. + * @retval RTEMS_INVALID_ID Invalid task identifier. + */ +rtems_status_code rtems_task_get_scheduler( + rtems_id task_id, + rtems_id *scheduler_id +); + +/** + * @brief Sets the scheduler instance of a task. + * + * Initially, the scheduler instance of a task is set to the scheduler instance + * of the task that created it. This directive allows to move a task from its + * current scheduler instance to another specified by the scheduler identifier. + * + * @param[in] task_id Identifier of the task. Use @ref RTEMS_SELF to select + * the executing task. + * @param[in] scheduler_id Identifier of the scheduler instance. + * @param[in] priority The task priority with respect to the new scheduler + * instance. The real and initial priority of the task is set to this value. + * The initial priority is used by rtems_task_restart() for example. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_ILLEGAL_ON_REMOTE_OBJECT Directive is illegal on remote tasks. + * @retval RTEMS_INVALID_ID Invalid task or scheduler identifier. + * @retval RTEMS_INVALID_PRIORITY Invalid priority. + * @retval RTEMS_RESOURCE_IN_USE The task owns resources which deny a scheduler + * change. + * + * @see rtems_scheduler_ident(). + */ +rtems_status_code rtems_task_set_scheduler( + rtems_id task_id, + rtems_id scheduler_id, + rtems_task_priority priority +); + +/** + * @brief RTEMS Get Self Task Id + * + * This directive returns the ID of the currently executing task. + */ +rtems_id rtems_task_self(void); + +/** + * @brief Task visitor. + * + * @param[in] tcb The task control block. + * @param[in] arg The visitor argument. + * + * @retval true Stop the iteration. + * @retval false Otherwise. + * + * @see rtems_task_iterate(). + */ +typedef bool ( *rtems_task_visitor )( rtems_tcb *tcb, void *arg ); + +/** + * @brief Iterates over all tasks in the system. + * + * This operation covers all tasks of all APIs. + * + * Must be called from task context. This operation obtains and releases the + * objects allocator lock. The task visitor is called while owning the objects + * allocator lock. It is possible to perform blocking operations in the task + * visitor, however, take care that no deadlocks via the object allocator lock + * can occur. + * + * @param[in] visitor The task visitor. + * @param[in] arg The visitor argument. + */ +void rtems_task_iterate( + rtems_task_visitor visitor, + void *arg +); + +/** + * @brief Identifies a scheduler by its name. + * + * The scheduler name is determined by the scheduler configuration. + * + * @param[in] name The scheduler name. + * @param[out] id The scheduler identifier associated with the name. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_ADDRESS The @a id parameter is @c NULL. + * @retval RTEMS_INVALID_NAME Invalid scheduler name. + */ +rtems_status_code rtems_scheduler_ident( + rtems_name name, + rtems_id *id +); + +/** + * @brief Identifies a scheduler by a processor index. + * + * @param[in] cpu_index The processor index. + * @param[out] id The scheduler identifier associated with the processor index. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_ADDRESS The @a id parameter is @c NULL. + * @retval RTEMS_INVALID_NAME Invalid processor index. + * @retval RTEMS_INCORRECT_STATE The processor index is valid, however, this + * processor is not owned by a scheduler. + */ +rtems_status_code rtems_scheduler_ident_by_processor( + uint32_t cpu_index, + rtems_id *id +); + +/** + * @brief Identifies a scheduler by a processor set. + * + * The scheduler is selected according to the highest numbered online processor + * in the specified processor set. + * + * @param[in] cpusetsize Size of the specified processor set buffer in + * bytes. This value must be positive. + * @param[out] cpuset The processor set to identify the scheduler. + * @param[out] id The scheduler identifier associated with the processor set. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_ADDRESS The @a id parameter is @c NULL. + * @retval RTEMS_INVALID_SIZE Invalid processor set size. + * @retval RTEMS_INVALID_NAME The processor set contains no online processor. + * @retval RTEMS_INCORRECT_STATE The processor set is valid, however, the + * highest numbered online processor in the specified processor set is not + * owned by a scheduler. + */ +rtems_status_code rtems_scheduler_ident_by_processor_set( + size_t cpusetsize, + const cpu_set_t *cpuset, + rtems_id *id +); + +/** + * @brief Gets the set of processors owned by the specified scheduler instance. + * + * @param[in] scheduler_id Identifier of the scheduler instance. + * @param[in] cpusetsize Size of the specified processor set buffer in + * bytes. This value must be positive. + * @param[out] cpuset The processor set owned by the scheduler. A set bit in + * the processor set means that this processor is owned by the scheduler and a + * cleared bit means the opposite. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_ADDRESS The @a cpuset parameter is @c NULL. + * @retval RTEMS_INVALID_ID Invalid scheduler instance identifier. + * @retval RTEMS_INVALID_NUMBER The processor set buffer is too small for the + * set of processors owned by the scheduler. + */ +rtems_status_code rtems_scheduler_get_processor_set( + rtems_id scheduler_id, + size_t cpusetsize, + cpu_set_t *cpuset +); + +/** + * @brief Adds a processor to the set of processors owned by the specified + * scheduler instance. + * + * Must be called from task context. This operation obtains and releases the + * objects allocator lock. + * + * @param[in] scheduler_id Identifier of the scheduler instance. + * @param[in] cpu_index Index of the processor to add. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_ID Invalid scheduler instance identifier. + * @retval RTEMS_NOT_CONFIGURED The processor is not configured to be used by + * the application. + * @retval RTEMS_INCORRECT_STATE The processor is configured to be used by + * the application, however, it is not online. + * @retval RTEMS_RESOURCE_IN_USE The processor is already assigned to a + * scheduler instance. + */ +rtems_status_code rtems_scheduler_add_processor( + rtems_id scheduler_id, + uint32_t cpu_index +); + +/** + * @brief Removes a processor from set of processors owned by the specified + * scheduler instance. + * + * Must be called from task context. This operation obtains and releases the + * objects allocator lock. Removing a processor from a scheduler is a complex + * operation that involves all tasks of the system. + * + * @param[in] scheduler_id Identifier of the scheduler instance. + * @param[in] cpu_index Index of the processor to add. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_ID Invalid scheduler instance identifier. + * @retval RTEMS_INVALID_NUMBER The processor is not owned by the specified + * scheduler instance. + * @retval RTEMS_RESOURCE_IN_USE The set of processors owned by the specified + * scheduler instance would be empty after the processor removal and there + * exists a non-idle task that uses this scheduler instance as its home + * scheduler instance. + */ +rtems_status_code rtems_scheduler_remove_processor( + rtems_id scheduler_id, + uint32_t cpu_index +); + +/**@}*/ + +/** + * This is the API specific information required by each thread for + * the RTEMS API to function correctly. + * + */ +typedef struct { + /** This field contains the event control for this task. */ + Event_Control Event; + /** This field contains the system event control for this task. */ + Event_Control System_event; + /** This field contains the Classic API Signal information for this task. */ + ASR_Information Signal; + + /** + * @brief Signal post-switch action in case signals are pending. + */ + Thread_Action Signal_action; +} RTEMS_API_Control; + +/** + * @brief _RTEMS_tasks_Initialize_user_tasks_body + * + * This routine creates and starts all configured user + * initialization threads. + * + * Input parameters: NONE + * + * Output parameters: NONE + * + * RTEMS Task Manager + */ + +extern void _RTEMS_tasks_Initialize_user_tasks_body( void ); + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/tasksimpl.h b/cpukit/include/rtems/rtems/tasksimpl.h new file mode 100644 index 0000000000..b0432351f3 --- /dev/null +++ b/cpukit/include/rtems/rtems/tasksimpl.h @@ -0,0 +1,131 @@ +/** + * @file + * + * @ingroup ClassicTasksImpl + * + * @brief Classic Tasks Manager Implementation + */ + +/* COPYRIGHT (c) 1989-2014. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_TASKSIMPL_H +#define _RTEMS_RTEMS_TASKSIMPL_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicTasksImpl Classic Tasks Manager Implementation + * + * @ingroup ClassicTasks + * + * @{ + */ + +/** + * The following instantiates the information control block used to + * manage this class of objects. + */ +extern Thread_Information _RTEMS_tasks_Information; + +/** + * @brief RTEMS User Task Initialization + * + * This routine creates and starts all configured user + * initialization threads. + */ +void _RTEMS_tasks_Initialize_user_tasks( void ); + +RTEMS_INLINE_ROUTINE Thread_Control *_RTEMS_tasks_Allocate(void) +{ + _Objects_Allocator_lock(); + + _Thread_Kill_zombies(); + + return (Thread_Control *) + _Objects_Allocate_unprotected( &_RTEMS_tasks_Information.Objects ); +} + +/** + * @brief Frees a task control block. + * + * This routine frees a task control block to the + * inactive chain of free task control blocks. + */ +RTEMS_INLINE_ROUTINE void _RTEMS_tasks_Free ( + Thread_Control *the_task +) +{ + _Objects_Free( + _Objects_Get_information_id( the_task->Object.id ), + &the_task->Object + ); +} + +/** + * @brief Converts the RTEMS API priority to the corresponding SuperCore + * priority and validates it. + * + * The RTEMS API system priority is accepted as valid. + * + * @param[in] scheduler The scheduler instance. + * @param[in] priority The RTEMS API priority to convert and validate. + * @param[out] valid Indicates if the RTEMS API priority is valid and a + * corresponding SuperCore priority in the specified scheduler instance + * exists. + * + * @return The corresponding SuperCore priority. + */ +RTEMS_INLINE_ROUTINE Priority_Control _RTEMS_Priority_To_core( + const Scheduler_Control *scheduler, + rtems_task_priority priority, + bool *valid +) +{ + *valid = ( priority <= scheduler->maximum_priority ); + + return _Scheduler_Map_priority( scheduler, (Priority_Control) priority ); +} + +/** + * @brief Converts the SuperCore priority to the corresponding RTEMS API + * priority. + * + * @param[in] scheduler The scheduler instance. + * @param[in] priority The SuperCore priority to convert. + * + * @return The corresponding RTEMS API priority. + */ +RTEMS_INLINE_ROUTINE rtems_task_priority _RTEMS_Priority_From_core( + const Scheduler_Control *scheduler, + Priority_Control priority +) +{ + return (rtems_task_priority) + _Scheduler_Unmap_priority( scheduler, priority ); +} + +/**@}*/ + +#if defined(RTEMS_MULTIPROCESSING) +#include +#endif + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/timer.h b/cpukit/include/rtems/rtems/timer.h new file mode 100644 index 0000000000..032c49525a --- /dev/null +++ b/cpukit/include/rtems/rtems/timer.h @@ -0,0 +1,384 @@ +/** + * @file rtems/rtems/timer.h + * + * @defgroup ClassicTimer Timers + * + * @ingroup ClassicRTEMS + * @brief Instantiate RTEMS Timer Data + * + * This include file contains all the constants, structures, and + * prototypes associated with the Timer Manager. This manager provides + * facilities to configure, initiate, cancel, and delete timers which will + * fire at specified intervals of time. + * + * Directives provided are: + * + * - create a timer + * - get an ID of a timer + * - delete a timer + * - set timer to fire in context of clock tick + * - after a number of ticks have passed + * - when a specified date and time has been reached + * - initiate the timer server task + * - set timer to fire in context of the timer server task + * - after a number of ticks have passed + * - when a specified date and time has been reached + * - reset a timer + * - cancel a time + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * Copyright (c) 2009, 2016 embedded brains GmbH. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_TIMER_H +#define _RTEMS_RTEMS_TIMER_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicTimer Timers + * + * @ingroup ClassicRTEMS + * + * This encapsulates functionality related to the Classic API Timer + * Manager. This manager provides functionality which allows the + * application to schedule the execution of methods at a specified + * time in the future. These methods may be scheduled based upon + * interval or wall time and may be executed in either the clock tick + * ISR or in a special dedicated timer server task. + */ +/**@{*/ + +#define TIMER_CLASS_BIT_TIME_OF_DAY 0x1 + +#define TIMER_CLASS_BIT_ON_TASK 0x2 + +#define TIMER_CLASS_BIT_NOT_DORMANT 0x4 + +/** + * The following enumerated type details the classes to which a timer + * may belong. + */ +typedef enum { + /** + * This value indicates the timer is currently not in use. + */ + TIMER_DORMANT, + + /** + * This value indicates the timer is currently in use as an interval + * timer which will fire in the clock tick ISR. + */ + TIMER_INTERVAL = TIMER_CLASS_BIT_NOT_DORMANT, + + /** + * This value indicates the timer is currently in use as an interval + * timer which will fire in the timer server task. + */ + TIMER_INTERVAL_ON_TASK = + TIMER_CLASS_BIT_NOT_DORMANT | TIMER_CLASS_BIT_ON_TASK, + + /** + * This value indicates the timer is currently in use as an time of day + * timer which will fire in the clock tick ISR. + */ + TIMER_TIME_OF_DAY = + TIMER_CLASS_BIT_NOT_DORMANT | TIMER_CLASS_BIT_TIME_OF_DAY, + + /** + * This value indicates the timer is currently in use as an time of day + * timer which will fire in the timer server task. + */ + TIMER_TIME_OF_DAY_ON_TASK = + TIMER_CLASS_BIT_NOT_DORMANT | TIMER_CLASS_BIT_TIME_OF_DAY | + TIMER_CLASS_BIT_ON_TASK +} Timer_Classes; + +/** + * The following types define a pointer to a timer service routine. + */ +typedef void rtems_timer_service_routine; + +/** + * This type defines the type used to manage and indirectly invoke + * Timer Service Routines (TSRs). This defines the prototype and interface + * for a function which is to be used as a TSR. + */ +typedef rtems_timer_service_routine ( *rtems_timer_service_routine_entry )( + rtems_id, + void * + ); + +/** + * The following records define the control block used to manage + * each timer. + */ +typedef struct { + /** This field is the object management portion of a Timer instance. */ + Objects_Control Object; + /** This field is the Watchdog instance which will be the scheduled. */ + Watchdog_Control Ticker; + /** This field indicates what type of timer this currently is. */ + Timer_Classes the_class; + /** This field is the timer service routine. */ + rtems_timer_service_routine_entry routine; + /** This field is the timer service routine user data. */ + void *user_data; + /** This field is the timer interval in ticks or seconds. */ + Watchdog_Interval initial; + /** This field is the timer start time point in ticks. */ + Watchdog_Interval start_time; + /** This field is the timer stop time point in ticks. */ + Watchdog_Interval stop_time; +} Timer_Control; + +/** + * @brief RTEMS Create Timer + * + * This routine implements the rtems_timer_create directive. The + * timer will have the name name. It returns the id of the + * created timer in ID. + * + * @param[in] name is the timer name + * @param[out] id is the pointer to timer id + * + * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful + */ +rtems_status_code rtems_timer_create( + rtems_name name, + rtems_id *id +); + +/** + * @brief RTEMS Timer Name to Id + * + * This routine implements the rtems_timer_ident directive. + * This directive returns the timer ID associated with name. + * If more than one timer is named name, then the timer + * to which the ID belongs is arbitrary. + * + * @param[in] name is the user defined message queue name + * @param[in] id is the pointer to timer id + * + * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful and + * id filled with the message queue id + */ +rtems_status_code rtems_timer_ident( + rtems_name name, + rtems_id *id +); + +/** + * @brief rtems_timer_cancel + * + * This routine implements the rtems_timer_cancel directive. It is used + * to stop the timer associated with ID from firing. + */ +rtems_status_code rtems_timer_cancel( + rtems_id id +); + +/** + * @brief RTEMS Delete Timer + * + * This routine implements the rtems_timer_delete directive. The + * timer indicated by ID is deleted. + * + * @param[in] id is the timer id + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + */ +rtems_status_code rtems_timer_delete( + rtems_id id +); + +/** + * @brief RTEMS Timer Fire After + * + * This routine implements the rtems_timer_fire_after directive. It + * initiates the timer associated with ID to fire in ticks clock ticks. + * When the timer fires, the routine will be invoked in the context + * of the rtems_clock_tick directive which is normally invoked as + * part of servicing a periodic interupt. + * + * @param[in] id is the timer id + * @param[in] ticks is the interval until routine is fired + * @param[in] routine is the routine to schedule + * @param[in] user_data is the passed as argument to routine when it is fired + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + */ +rtems_status_code rtems_timer_fire_after( + rtems_id id, + rtems_interval ticks, + rtems_timer_service_routine_entry routine, + void *user_data +); + +/** + * @brief RTEMS Timer Server Fire After + * + * This routine implements the rtems_timer_server_fire_after directive. It + * initiates the timer associated with ID to fire in ticks clock + * ticks. When the timer fires, the routine will be invoked by the + * Timer Server in the context of a task NOT IN THE CONTEXT of the + * clock tick interrupt. + * + * @param[in] id is the timer id + * @param[in] ticks is the interval until routine is fired + * @param[in] routine is the routine to schedule + * @param[in] user_data is the passed as argument to routine when it is fired + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + */ +rtems_status_code rtems_timer_server_fire_after( + rtems_id id, + rtems_interval ticks, + rtems_timer_service_routine_entry routine, + void *user_data +); + +/** + * @brief RTEMS Timer Fire When + * + * This routine implements the rtems_timer_fire_when directive. It + * initiates the timer associated with ID to fire at wall_time + * When the timer fires, the routine will be invoked in the context + * of the rtems_clock_tick directive which is normally invoked as + * part of servicing a periodic interupt. + * + * @param[in] id is the timer id + * @param[in] wall_time is the time of day to fire timer + * @param[in] routine is the routine to schedule + * @param[in] user_data is the passed as argument to routine when it is fired + * + * @retval This method returns RTEMS_SUCCESSFUL if there was not an + * error. Otherwise, a status code is returned indicating the + * source of the error. + */ +rtems_status_code rtems_timer_fire_when( + rtems_id id, + rtems_time_of_day *wall_time, + rtems_timer_service_routine_entry routine, + void *user_data +); + +/** + * @brief RTEMS Timer Server Fire When Directive + * + * Timer Manager - RTEMS Timer Server Fire When Directive + * + * This routine implements the rtems_timer_server_fire_when directive. It + * initiates the timer associated with ID to fire at wall_time + * When the timer fires, the routine will be invoked by the + * Timer Server in the context of a task NOT IN THE CONTEXT of the + * clock tick interrupt. + */ +rtems_status_code rtems_timer_server_fire_when( + rtems_id id, + rtems_time_of_day *wall_time, + rtems_timer_service_routine_entry routine, + void *user_data +); + +/** + * @brief RTEMS Timer Reset + * + * Timer Manager - RTEMS Timer Reset + * + * This routine implements the rtems_timer_reset directive. It is used + * to reinitialize the interval timer associated with ID just as if + * rtems_timer_fire_after were re-invoked with the same arguments that + * were used to initiate this timer. + */ +rtems_status_code rtems_timer_reset( + rtems_id id +); + +/** + * @brief Initiates the timer server. + * + * This directive creates and starts the server for task-based timers. + * It must be invoked before any task-based timers can be initiated. + * + * @param priority The timer server task priority. + * @param stack_size The stack size in bytes for the timer server task. + * @param attribute_set The timer server task attributes. + * + * @return This method returns RTEMS_SUCCESSFUL if successful and an + * error code otherwise. + */ +rtems_status_code rtems_timer_initiate_server( + rtems_task_priority priority, + size_t stack_size, + rtems_attribute attribute_set +); + +/** + * This is the default value for the priority of the Timer Server. + * When given this priority, a special high priority not accessible + * via the Classic API is used. + */ +#define RTEMS_TIMER_SERVER_DEFAULT_PRIORITY (uint32_t) -1 + +/** + * This is the structure filled in by the timer get information + * service. + */ +typedef struct { + /** This indicates the current type of the timer. */ + Timer_Classes the_class; + /** This indicates the initial requested interval. */ + Watchdog_Interval initial; + /** This indicates the time the timer was initially scheduled. */ + Watchdog_Interval start_time; + /** This indicates the time the timer is scheduled to fire. */ + Watchdog_Interval stop_time; +} rtems_timer_information; + +/** + * @brief RTEMS Get Timer Information + * + * This routine implements the rtems_timer_get_information directive. + * This directive returns information about the timer. + * + * @param[in] id is the timer id + * @param[in] the_info is the pointer to timer information block + * + * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful and + * *the_info region information block filled in + */ +rtems_status_code rtems_timer_get_information( + rtems_id id, + rtems_timer_information *the_info +); + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/timerimpl.h b/cpukit/include/rtems/rtems/timerimpl.h new file mode 100644 index 0000000000..d8581bfcd8 --- /dev/null +++ b/cpukit/include/rtems/rtems/timerimpl.h @@ -0,0 +1,209 @@ +/** + * @file + * + * @ingroup ClassicTimerImpl + * + * @brief Classic Timer Implementation + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * Copyright (c) 2016 embedded brains GmbH. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_TIMER_INL +#define _RTEMS_RTEMS_TIMER_INL + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicTimerImpl Classic Timer Implementation + * + * @ingroup ClassicTimer + * + * @{ + */ + +typedef struct Timer_server_Control { + ISR_LOCK_MEMBER( Lock ) + + Chain_Control Pending; + + Objects_Id server_id; +} Timer_server_Control; + +/** + * @brief Pointer to default timer server control block. + * + * This value is @c NULL when the default timer server is not initialized. + */ +extern Timer_server_Control *volatile _Timer_server; + +/** + * The following defines the information control block used to manage + * this class of objects. + */ +extern Objects_Information _Timer_Information; + +/** + * @brief Timer_Allocate + * + * This function allocates a timer control block from + * the inactive chain of free timer control blocks. + */ +RTEMS_INLINE_ROUTINE Timer_Control *_Timer_Allocate( void ) +{ + return (Timer_Control *) _Objects_Allocate( &_Timer_Information ); +} + +/** + * @brief Timer_Free + * + * This routine frees a timer control block to the + * inactive chain of free timer control blocks. + */ +RTEMS_INLINE_ROUTINE void _Timer_Free ( + Timer_Control *the_timer +) +{ + _Objects_Free( &_Timer_Information, &the_timer->Object ); +} + +RTEMS_INLINE_ROUTINE Timer_Control *_Timer_Get( + Objects_Id id, + ISR_lock_Context *lock_context +) +{ + return (Timer_Control *) _Objects_Get( + id, + lock_context, + &_Timer_Information + ); +} + +RTEMS_INLINE_ROUTINE Per_CPU_Control *_Timer_Acquire_critical( + Timer_Control *the_timer, + ISR_lock_Context *lock_context +) +{ + Per_CPU_Control *cpu; + + cpu = _Watchdog_Get_CPU( &the_timer->Ticker ); + _Watchdog_Per_CPU_acquire_critical( cpu, lock_context ); + + return cpu; +} + +RTEMS_INLINE_ROUTINE void _Timer_Release( + Per_CPU_Control *cpu, + ISR_lock_Context *lock_context +) +{ + _Watchdog_Per_CPU_release_critical( cpu, lock_context ); + _ISR_lock_ISR_enable( lock_context ); +} + +RTEMS_INLINE_ROUTINE bool _Timer_Is_interval_class( + Timer_Classes the_class +) +{ + Timer_Classes mask = + TIMER_CLASS_BIT_NOT_DORMANT | TIMER_CLASS_BIT_TIME_OF_DAY; + + return ( the_class & mask ) == TIMER_CLASS_BIT_NOT_DORMANT; +} + +RTEMS_INLINE_ROUTINE bool _Timer_Is_on_task_class( + Timer_Classes the_class +) +{ + Timer_Classes mask = + TIMER_CLASS_BIT_NOT_DORMANT | TIMER_CLASS_BIT_ON_TASK; + + return ( the_class & mask ) == mask; +} + +RTEMS_INLINE_ROUTINE Per_CPU_Watchdog_index _Timer_Watchdog_header_index( + Timer_Classes the_class +) +{ + return ( the_class & TIMER_CLASS_BIT_TIME_OF_DAY ); +} + +RTEMS_INLINE_ROUTINE Watchdog_Interval _Timer_Get_CPU_ticks( + const Per_CPU_Control *cpu +) +{ + return (Watchdog_Interval) cpu->Watchdog.ticks; +} + +rtems_status_code _Timer_Fire( + rtems_id id, + rtems_interval interval, + rtems_timer_service_routine_entry routine, + void *user_data, + Timer_Classes the_class, + Watchdog_Service_routine_entry adaptor +); + +rtems_status_code _Timer_Fire_after( + rtems_id id, + rtems_interval ticks, + rtems_timer_service_routine_entry routine, + void *user_data, + Timer_Classes the_class, + Watchdog_Service_routine_entry adaptor +); + +rtems_status_code _Timer_Fire_when( + rtems_id id, + const rtems_time_of_day *wall_time, + rtems_timer_service_routine_entry routine, + void *user_data, + Timer_Classes the_class, + Watchdog_Service_routine_entry adaptor +); + +void _Timer_Cancel( Per_CPU_Control *cpu, Timer_Control *the_timer ); + +void _Timer_Routine_adaptor( Watchdog_Control *the_watchdog ); + +void _Timer_server_Routine_adaptor( Watchdog_Control *the_watchdog ); + +RTEMS_INLINE_ROUTINE void _Timer_server_Acquire_critical( + Timer_server_Control *timer_server, + ISR_lock_Context *lock_context +) +{ + _ISR_lock_Acquire( &timer_server->Lock, lock_context ); +} + +RTEMS_INLINE_ROUTINE void _Timer_server_Release_critical( + Timer_server_Control *timer_server, + ISR_lock_Context *lock_context +) +{ + _ISR_lock_Release( &timer_server->Lock, lock_context ); +} + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtems/types.h b/cpukit/include/rtems/rtems/types.h new file mode 100644 index 0000000000..82c0edd3c3 --- /dev/null +++ b/cpukit/include/rtems/rtems/types.h @@ -0,0 +1,235 @@ +/** + * @file + * + * @defgroup ClassicTypes Types + * + * @ingroup ClassicRTEMS + * @brief Types used by Classic API. + */ + +/* COPYRIGHT (c) 1989-2009. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_RTEMS_TYPES_H +#define _RTEMS_RTEMS_TYPES_H + +/* + * RTEMS basic type definitions + */ + +#include +#include +#include +#include +#include +#include +#if defined(RTEMS_MULTIPROCESSING) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup ClassicRTEMS + */ +/**@{**/ + +#ifdef RTEMS_DEPRECATED_TYPES +/** + * @brief Single precision float type. + * + * @deprecated Use @c float instead. + */ +typedef single_precision rtems_single; + +/** + * @brief Double precision float type. + * + * @deprecated Use @c double instead. + */ +typedef double_precision rtems_double; + +/** + * @brief RTEMS boolean type. + * + * @deprecated Use @c bool instead + */ +typedef boolean rtems_boolean; +#endif + +/** + * @brief Classic API @ref ClassicRTEMSSubSecObjectNames "object name" type. + * + * Contains the name of a Classic API object. It is an unsigned 32-bit integer + * which can be treated as a numeric value or initialized using + * rtems_build_name() to contain four ASCII characters. + */ +typedef uint32_t rtems_name; + +/** + * @brief Used to manage and manipulate + * @ref ClassicRTEMSSubSecObjectIdentifiers "RTEMS object identifiers". + */ +typedef Objects_Id rtems_id; + +/** + * @brief Invalid object identifier value. + * + * No object can have this identifier value. + */ +#define RTEMS_ID_NONE OBJECTS_ID_NONE + +/** + * @brief Public name for task context area. + */ +typedef Context_Control rtems_context; + +#if (CPU_HARDWARE_FP == TRUE) || (CPU_SOFTWARE_FP == TRUE) +/** + * @brief Public name for task floating point context area. + */ +typedef Context_Control_fp rtems_context_fp; +#endif + +#if (CPU_ISR_PASSES_FRAME_POINTER == TRUE) +/** + * @brief Defines the format of the interrupt stack frame as it appears to a + * user ISR. + * + * This data structure is only provided if the interrupt stack frame is passed + * to the ISR handler. + * + * @see rtems_interrupt_catch(). + */ +typedef CPU_Interrupt_frame rtems_interrupt_frame; +#endif + +/** + * @brief Information structure returned by the Heap Handler via the Region + * Manager. + */ +typedef Heap_Information_block region_information_block; + +/** + * @brief Used to manage and manipulate intervals specified by + * @ref ClassicRTEMSSecTime "clock ticks". + */ +typedef Watchdog_Interval rtems_interval; + +/** + * @brief Represents the CPU usage per thread. + * + * When using nanoseconds granularity timing, RTEMS may internally use a + * variety of representations. + */ +typedef struct timespec rtems_thread_cpu_usage_t; + +/** + * @brief Data structure to manage and manipulate calendar + * @ref ClassicRTEMSSecTime "time". + */ +typedef struct { + /** + * @brief Year, A.D. + */ + uint32_t year; + /** + * @brief Month, 1 .. 12. + */ + uint32_t month; + /** + * @brief Day, 1 .. 31. + */ + uint32_t day; + /** + * @brief Hour, 0 .. 23. + */ + uint32_t hour; + /** + * @brief Minute, 0 .. 59. + */ + uint32_t minute; + /** + * @brief Second, 0 .. 59. + */ + uint32_t second; + /** + * @brief Elapsed ticks between seconds. + */ + uint32_t ticks; +} rtems_time_of_day; + +/** + * @brief Task mode type. + */ +typedef Modes_Control rtems_mode; + +/* + * MPCI related entries + */ +#if defined(RTEMS_MULTIPROCESSING) +/** + * @brief Set of MPCI packet classes which are internally dispatched to the + * managers. + */ +typedef MP_packet_Classes rtems_mp_packet_classes; + +/** + * @brief Prefix found at the beginning of each MPCI packet sent between nodes. + */ +typedef MP_packet_Prefix rtems_packet_prefix; + +/** + * @brief Indirect pointer to the initialization entry point for an MPCI + * handler. + */ +typedef MPCI_initialization_entry rtems_mpci_initialization_entry; + +/** + * @brief Indirect pointer to the get_packet entry point for an MPCI handler. + */ +typedef MPCI_get_packet_entry rtems_mpci_get_packet_entry; + +/** + * @brief Indirect pointer to the return_packet entry point for an MPCI + * handler. + */ +typedef MPCI_return_packet_entry rtems_mpci_return_packet_entry; + +/** + * @brief Indirect pointer to the send_packet entry point for an MPCI handler. + */ +typedef MPCI_send_entry rtems_mpci_send_packet_entry; + +/** + * @brief Indirect pointer to the receive entry point for an MPCI handler. + */ +typedef MPCI_receive_entry rtems_mpci_receive_packet_entry; + +/** + * @brief Return type from every MPCI handler routine. + */ +typedef MPCI_Entry rtems_mpci_entry; + +/** + * @brief Structure which is used to configure an MPCI handler. + */ +typedef MPCI_Control rtems_mpci_table; + +#endif + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/rtemsdialer.h b/cpukit/include/rtems/rtemsdialer.h new file mode 100644 index 0000000000..611986b802 --- /dev/null +++ b/cpukit/include/rtems/rtemsdialer.h @@ -0,0 +1,24 @@ + +#ifndef DIALER_H +#define DIALER_H + +/* define constant mode values */ +#define DIALER_INIT 0 +#define DIALER_CONNECT 1 +#define DIALER_WELCOME 2 +#define DIALER_DISCONNECT 3 + +/* define constant return values */ +#define DIALER_SUCCESS 0 +#define DIALER_INVALIDARG 1 +#define DIALER_UNEXPECTED 2 +#define DIALER_TIMEOUT 3 +#define DIALER_CMDFAILED 4 + +/* define typedef for dialer function prototype */ +typedef int (*dialerfp)(int tty, int mode, char *pScript); + +/* declare default chat program dialer */ +extern int chatmain(int tty, int mode, char *pScript); + +#endif diff --git a/cpukit/include/rtems/rtemspppd.h b/cpukit/include/rtems/rtemspppd.h new file mode 100644 index 0000000000..a6c8d0b398 --- /dev/null +++ b/cpukit/include/rtems/rtemspppd.h @@ -0,0 +1,49 @@ +/* + * COPYRIGHT (c) 2001, Michael Siers . + * Poliac Research, Burnsville, Minnesota USA. + * COPYRIGHT (c) 2001, On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef RTEMSPPPD_H +#define RTEMSPPPD_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* define hook function identifiers */ +#define RTEMS_PPPD_LINKUP_HOOK 1 +#define RTEMS_PPPD_LINKDOWN_HOOK 2 +#define RTEMS_PPPD_IPUP_HOOK 3 +#define RTEMS_PPPD_IPDOWN_HOOK 4 +#define RTEMS_PPPD_ERROR_HOOK 5 +#define RTEMS_PPPD_EXIT_HOOK 6 + +/* define hook function pointer prototype */ +typedef void (*rtems_pppd_hookfunction)(void); +typedef int (*rtems_pppd_dialerfunction)(int tty, int mode, char *pScript); + + +/* define pppd function prototyes */ +int rtems_pppd_initialize(void); +int rtems_pppd_terminate(void); +int rtems_pppd_reset_options(void); +int rtems_pppd_set_hook(int id, rtems_pppd_hookfunction hookfp); +int rtems_pppd_set_dialer(rtems_pppd_dialerfunction dialerfp); +int rtems_pppd_set_option(const char *pOption, const char *pValue); +int rtems_pppd_connect(void); +int rtems_pppd_disconnect(void); + +struct rtems_bsdnet_ifconfig; + +int rtems_ppp_driver_attach(struct rtems_bsdnet_ifconfig *config, int attaching); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/cpukit/include/rtems/rtl/dlfcn-shell.h b/cpukit/include/rtems/rtl/dlfcn-shell.h new file mode 100644 index 0000000000..9383577d25 --- /dev/null +++ b/cpukit/include/rtems/rtl/dlfcn-shell.h @@ -0,0 +1,17 @@ +/* + * COPYRIGHT (c) 2012 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#if !defined(_DLFCN_SHELL_H_) +#define _DLFCN_SHELL_H_ + +int shell_dlopen (int argc, char* argv[]); +int shell_dlclose (int argc, char* argv[]); +int shell_dlsym (int argc, char* argv[]); +int shell_dlcall (int argc, char* argv[]); + +#endif diff --git a/cpukit/include/rtems/rtl/rap-shell.h b/cpukit/include/rtems/rtl/rap-shell.h new file mode 100644 index 0000000000..c2d9112c0f --- /dev/null +++ b/cpukit/include/rtems/rtl/rap-shell.h @@ -0,0 +1,14 @@ +/* + * COPYRIGHT (c) 2013 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#if !defined(_RAP_SHELL_H_) +#define _RAP_SHELL_H_ + +int shell_rap (int argc, char* argv[]); + +#endif diff --git a/cpukit/include/rtems/rtl/rap.h b/cpukit/include/rtems/rtl/rap.h new file mode 100644 index 0000000000..0b86553e2b --- /dev/null +++ b/cpukit/include/rtems/rtl/rap.h @@ -0,0 +1,115 @@ +/* + * COPYRIGHT (c) 2013 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ +/** + * @file + * + * @ingroup rtems_rap + * + * @brief RTEMS Application Loader + * + * This is the RTEMS Application loader for files in the RAP format. + */ + +#if !defined (_RAP_H_) +#define _RAP_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup rtems_rap RTEMS Application Loader + * + * The module implements an application loader for files in the RAP format. The + * RAP format is: + * + *
+ * + * + * The compressed container is a stream of ELF relocatable object files. + * + * TBD. + */ + +/** + * The module iterator handle. + */ +typedef bool (*rtems_rap_iterator_t) (void* handle); + +/** + * Load an application. + * + * @param name The name of the application file. + * @return bool True if the module loads else an error. + */ +bool rtems_rap_load (const char* name, int mode, int argc, const char* argv[]); + +/** + * Unload an application. + * + * @param obj The application descriptor. + * @retval true The application file has been unloaded. + * @retval false The application could not be unloaded. + */ +bool rtems_rap_unload (const char* name); + +/** + * Find the application handle given a file name. + * + * @param name The name of the application file. It can be absolute or + * relative. Relative names can the basename with an extension. + * @retval NULL No application file with that name found. + * @return void* The application descriptor. + */ +void* rtems_rap_find (const char* name); + +/** + * Run an iterator over the modules calling the iterator function. + * + * @param iterator The iterator function. + * @retval true The iterator function returned did not return false. + * @retval false The iterator function returned false.. + */ +bool rtems_rap_iterate (rtems_rap_iterator_t iterator); + +/** + * Return the name of the module given a handle. + * + * @param handle The module handle. + * @return const char* The name of the module if the handle is valid else it + * is NULL. + */ +const char* rtems_rap_name (void* handle); + +/** + * Return the DL handle used to load the module given the RAP handle. + * + * @param handle The module handle. + * @return void* The DL handle returned by the dlopen call. + */ +void* rtems_rap_dl_handle (void* handle); + +/** + * Get the last error message clearing it. This call is not thread safe is + * multiple threads are loading object files at the same time. This call + * follows the model provided by the dlopen family of calls. + * + * @param message Pointer to a buffer to copy the message into. + * @param max_message The maximum message that can be copied. + * @return int The last error number. + */ +int rtems_rap_get_error (char* message, size_t max_message); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/cpukit/include/rtems/rtl/rtl-allocator.h b/cpukit/include/rtems/rtl/rtl-allocator.h new file mode 100644 index 0000000000..e8044ee1e8 --- /dev/null +++ b/cpukit/include/rtems/rtl/rtl-allocator.h @@ -0,0 +1,181 @@ +/* + * COPYRIGHT (c) 2012 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ +/** + * @file + * + * @ingroup rtems_rtl + * + * @brief RTEMS Run-Time Linker Allocator + */ + +#if !defined (_RTEMS_RTL_ALLOCATOR_H_) +#define _RTEMS_RTL_ALLOCATOR_H_ + +#include + +#include "rtl-indirect-ptr.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * Define the types of allocation the loader requires. + * + * @note It is best to use the object tag for general memory allocation and to + * leave the tags with specific access properties to the module data + */ +enum rtems_rtl_alloc_tags_e { + RTEMS_RTL_ALLOC_OBJECT, /**< A generic memory object. */ + RTEMS_RTL_ALLOC_SYMBOL, /**< Memory used for symbols. */ + RTEMS_RTL_ALLOC_EXTERNAL, /**< Memory used for external symbols. */ + RTEMS_RTL_ALLOC_READ, /**< The memory is read only. */ + RTEMS_RTL_ALLOC_READ_WRITE, /**< The memory is read and write. */ + RTEMS_RTL_ALLOC_READ_EXEC /**< The memory is read and executable. */ +}; + +/** + * The allocator tag type. + */ +typedef enum rtems_rtl_alloc_tags_e rtems_rtl_alloc_tag_t; + +/** + * The number of tags. + */ +#define RTEMS_RTL_ALLOC_TAGS ((size_t) (RTEMS_RTL_ALLOC_READ_EXEC + 1)) + +/** + * Allocator handler handles all RTL allocations. It can be hooked and + * overridded for customised allocation schemes or memory maps. + * + * @param allocation If true the request is to allocate memory else free. + * @param tag The type of allocation request. + * @param address Pointer to the memory address. If an allocation the value is + * unspecific on entry and the allocated address or NULL on + * exit. The NULL value means the allocation failed. If a delete + * or free request the memory address is the block to free. A + * free request of NULL is silently ignored. + * @param size The size of the allocation if an allocation request and + * not used if deleting or freeing a previous allocation. + */ +typedef void (*rtems_rtl_allocator_t)(bool allocate, + rtems_rtl_alloc_tag_t tag, + void** address, + size_t size); + +/** + * The allocator data. + */ +struct rtems_rtl_alloc_data_s { + /**< The memory allocator handler. */ + rtems_rtl_allocator_t allocator; + /**< The indirect pointer chains. */ + rtems_chain_control indirects[RTEMS_RTL_ALLOC_TAGS]; +}; + +typedef struct rtems_rtl_alloc_data_s rtems_rtl_alloc_data_t; + +/** + * Initialise the allocate data. + * + * @param data The data to initialise. + */ +void rtems_rtl_alloc_initialise (rtems_rtl_alloc_data_t* data); + +/** + * The Runtime Loader allocator new allocates new memory and optionally clear + * the memory if requested. + * + * @param tag The type of allocation request. + * @param size The size of the allocation. + * @param zero If true the memory is cleared. + * @return void* The memory address or NULL is not memory available. + */ +void* rtems_rtl_alloc_new (rtems_rtl_alloc_tag_t tag, size_t size, bool zero); + +/** + * The Runtime Loader allocator delete deletes allocated memory. + * + * @param tag The type of allocation request. + * @param address The memory address to delete. A NULL is ignored. + */ +void rtems_rtl_alloc_del (rtems_rtl_alloc_tag_t tag, void* address); + +/** + * Hook the Runtime Loader allocatior. A handler can call the previous handler + * in the chain to use it for specific tags. The default handler uses the + * system heap. Do not unhook your handler if memory it allocates has not been + * returned. + * + * @param handler The handler to use as the allocator. + * @return rtems_rtl_alloc_handler_t The previous handler. + */ +rtems_rtl_allocator_t rtems_rtl_alloc_hook (rtems_rtl_allocator_t handler); + +/** + * Allocate memory to an indirect handle. + * + * @param tag The type of allocation request. + * @param handle The handle to allocate the memory to. + * @param size The size of the allocation. + */ +void rtems_rtl_alloc_indirect_new (rtems_rtl_alloc_tag_t tag, + rtems_rtl_ptr_t* handle, + size_t size); + +/** + * Free memory from an indirect handle. + * + * @param tag The type of allocation request. + * @param handle The handle to free the memory from. + */ +void rtems_rtl_alloc_indirect_del (rtems_rtl_alloc_tag_t tag, + rtems_rtl_ptr_t* handle); + +/** + * Allocate the memory for a module given the size of the text, const, data and + * bss sections. If any part of the allocation fails the no memory is + * allocated. + * + * @param text_base Pointer to the text base pointer. + * @param text_size The size of the read/exec section. + * @param const_base Pointer to the const base pointer. + * @param const_size The size of the read only section. + * @param eh_base Pointer to the eh base pointer. + * @param eh_size The size of the eh section. + * @param data_base Pointer to the data base pointer. + * @param data_size The size of the read/write secton. + * @param bss_base Pointer to the bss base pointer. + * @param bss_size The size of the read/write. + * @retval true The memory has been allocated. + * @retval false The allocation of memory has failed. + */ +bool rtems_rtl_alloc_module_new (void** text_base, size_t text_size, + void** const_base, size_t const_size, + void** eh_base, size_t eh_size, + void** data_base, size_t data_size, + void** bss_base, size_t bss_size); + +/** + * Free the memory allocated to a module. + * + * @param text_base Pointer to the text base pointer. + * @param const_base Pointer to the const base pointer. + * @param eh_base Pointer to the eh base pointer. + * @param data_base Pointer to the data base pointer. + * @param bss_base Pointer to the bss base pointer. + */ +void rtems_rtl_alloc_module_del (void** text_base, void** const_base, + void** eh_base, void** data_base, + void** bss_base); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/cpukit/include/rtems/rtl/rtl-fwd.h b/cpukit/include/rtems/rtl/rtl-fwd.h new file mode 100644 index 0000000000..4641ad5d5e --- /dev/null +++ b/cpukit/include/rtems/rtl/rtl-fwd.h @@ -0,0 +1,33 @@ +/* + * COPYRIGHT (c) 2012 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ +/** + * @file + * + * @ingroup rtems_rtl + * + * @brief RTEMS Run-Time Linker ELF Headers + */ + +#if !defined (_RTEMS_RTL_FWD_H_) +#define _RTEMS_RTL_FWD_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * The forward declaration of the obj structure. + */ +struct rtems_rtl_data_s; +typedef struct rtems_rtl_data_s rtems_rtl_data_t; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/cpukit/include/rtems/rtl/rtl-indirect-ptr.h b/cpukit/include/rtems/rtl/rtl-indirect-ptr.h new file mode 100644 index 0000000000..81503a3b45 --- /dev/null +++ b/cpukit/include/rtems/rtl/rtl-indirect-ptr.h @@ -0,0 +1,235 @@ +/* + * COPYRIGHT (c) 2012 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ +/** + * @file + * + * @ingroup rtems_rtl + * + * @brief RTEMS Run-Time Linker Indirect Pointer Management allows memory + * compaction in the allocator. + */ + +#if !defined (_RTEMS_RTL_INDIRECT_PTR_H_) +#define _RTEMS_RTL_INDIRECT_PTR_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include + +/** + * The RTL Indirect pointer. + */ +struct rtems_rtl_ptr_s { + rtems_chain_node node; /**< Indirect pointers are held on lists. */ + void* pointer; /**< The actual pointer. */ +}; + +typedef struct rtems_rtl_ptr_s rtems_rtl_ptr_t; + +/** + * The RTL Indirect size and pointer. + */ +struct rtems_rtl_sptr_s { + rtems_rtl_ptr_t ptr; /**< The indirect pointer. */ + size_t size; /**< The size of the memory block. */ +}; + +typedef struct rtems_rtl_sptr_s rtems_rtl_sptr_t; + +/** + * A chain of indirect pointers for users to chain in applications. + * + * @note The chain the pointer is on is internal to the allocator and cannot be + * used by applications. + */ +struct rtems_rtl_ptr_chain_s { + rtems_chain_node node; /**< Chain of indirect pointers. */ + rtems_rtl_ptr_t ptr; /**< The indirect pointer. */ +}; + +typedef struct rtems_rtl_ptr_chain_s rtems_rtl_ptr_chain_t; + +/** + * A chain of indirect sized pointers for users to chain in applications. + * + * @note The chain the pointer is on is internal to the allocator and cannot be + * used by applications. + */ +struct rtems_rtl_sptr_chain_s { + rtems_chain_node node; /**< Chain of indirect pointers. */ + rtems_rtl_sptr_t ptr; /**< The indirect pointer. */ +}; + +typedef struct rtems_rtl_sptr_chain_s rtems_rtl_sptr_chain_t; + +/** + * Get the pointer given an indirect handle. + * + * @param handle The handle the pointer is returned from. + * @return void* The pointer held in the handle. + */ +static inline void* rtems_rtl_ptr_get (rtems_rtl_ptr_t* handle) +{ + return handle->pointer; +} + +/** + * Set the pointer given an indirect handle and the pointer. + * + * @param handle The handle the pointer is returned from. + * @param pointer The pointer to set in the handle. + */ +static inline void rtems_rtl_ptr_set (rtems_rtl_ptr_t* handle, void* pointer) +{ + handle->pointer = pointer; +} + +/** + * Initialise the indirect handle. + * + * @param handle The handle to initialise. + */ +static inline void rtems_rtl_ptr_init (rtems_rtl_ptr_t* handle) +{ + rtems_chain_set_off_chain (&handle->node); + handle->pointer = NULL; +} + +/** + * Is the indirect handle NULL ? + * + * @param handle The handle to test. + * @return bool True if the pointer is NULL. + */ +static inline bool rtems_rtl_ptr_null (rtems_rtl_ptr_t* handle) +{ + return handle->pointer == NULL; +} + +/** + * Move the allocated pointer from one handle to another. The source handle is + * cleared and removed from the list of handles. + * + * @param src The source handle to move the pointer from. + * @param dst The destination handle to receive the pointer. + */ +static inline void rtems_rtl_ptr_move (rtems_rtl_ptr_t* dst, rtems_rtl_ptr_t* src) +{ + /* + * We do not know which chain the src handle resides on so insert the dst + * handle after the src handle then extract the src handle. + */ + rtems_chain_insert_unprotected (&src->node, &dst->node); + rtems_chain_extract_unprotected (&src->node); + dst->pointer = src->pointer; + rtems_rtl_ptr_init (src); +} + +/** + * Return the pointer as the type provided. + * + * @param _h The handle. + * @param _t The type. + */ +#define rtems_rtl_ptr_type_get(_h, _t) ((_t*) rtems_rtl_ptr_get (_h)) + +/** + * Get the pointer given an indirect handle. + * + * @param handle The handle the pointer is returned from. + * @return void* The pointer held in the handle. + */ +static inline void* rtems_rtl_sptr_get (rtems_rtl_sptr_t* handle) +{ + return rtems_rtl_ptr_get (&handle->ptr); +} + +/** + * Set the pointer given an indirect handle and the pointer. + * + * @param handle The handle the pointer is returned from. + * @param pointer The pointer to set in the handle. + */ +static inline void rtems_rtl_sptr_set (rtems_rtl_sptr_t* handle, void* pointer) +{ + rtems_rtl_ptr_set (&handle->ptr, pointer); +} + +/** + * Initialise the indirect handle. + * + * @param handle The handle to initialise. + */ +static inline void rtems_rtl_sptr_init (rtems_rtl_sptr_t* handle) +{ + rtems_rtl_ptr_init (&handle->ptr); + handle->size = 0; +} + +/** + * Is the indirect handle NULL ? + * + * @param handle The handle to test. + * @return bool True if the pointer is NULL. + */ +static inline bool rtems_rtl_sptr_null (rtems_rtl_sptr_t* handle) +{ + return rtems_rtl_ptr_null (&handle->ptr); +} + +/** + * Move the allocated pointer from one handle to another. The source handle is + * cleared and removed from the list of handles. + * + * @param src The source handle to move the pointer from. + * @param dst The destination handle to receive the pointer. + */ +static inline void rtems_rtl_sptr_move (rtems_rtl_sptr_t* dst, rtems_rtl_sptr_t* src) +{ + rtems_rtl_ptr_move (&dst->ptr, &src->ptr); + dst->size = src->size; + src->size = 0; +} + +/** + * Get the size. + * + * @param handle The handle to get the size from. + * @return size_t The size_t. + */ +static inline size_t rtems_rtl_sptr_get_size (rtems_rtl_sptr_t* handle) +{ + return handle->size; +} + +/** + * Set the size. + * + * @param handle The handle to set the size. + * @param size The size to set.. + */ +static inline void rtems_rtl_sptr_set_size (rtems_rtl_sptr_t* handle, size_t size) +{ + handle->size = size; +} + +/** + * Return the pointer as the type provided. + * + * @param _h The handle. + * @param _t The type. + */ +#define rtems_rtl_sptr_type_get(_h, _t) ((_t*) rtems_rtl_sptr_get (_h)) + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/cpukit/include/rtems/rtl/rtl-obj-cache.h b/cpukit/include/rtems/rtl/rtl-obj-cache.h new file mode 100644 index 0000000000..8eacdd316b --- /dev/null +++ b/cpukit/include/rtems/rtl/rtl-obj-cache.h @@ -0,0 +1,132 @@ +/* + * COPYRIGHT (c) 2012 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ +/** + * @file + * + * @ingroup rtems_rtl + * + * @brief RTEMS Run-Time Linker Object File cache buffers a section of the + * object file in a buffer to localise read performance. + * + * This is a simple object file cache that holds a buffer of data from the + * offset in the file the read is requested from. Writes are not supported. + * + * The cache holds the file descriptor, the offset into the file and the amount + * of valid data in the cache. If the file is ever modified the user of the + * cache to responsible for flushing the cache. For example the cache should be + * flused if the file is closed. + * + * The cache can return by reference or by value. By reference allow access to + * the cache buffer. Do not modify the cache's data. By value will copy the + * requested data into the user supplied buffer. + * + * The read by reference call allows you to probe the file's data. For example + * a string in an object file can be an unknown length. You can request a read + * up to the cache's size by reference. The code will attempt to have this data + * in the buffer. If there is not enough data in the file the length will be + * modifed to reflect this. + * + * You can have more than one cache for a single file all looking at different + * parts of the file. + */ + +#if !defined (_RTEMS_RTL_OBJ_CACHE_H_) +#define _RTEMS_RTL_OBJ_CACHE_H_ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * The buffer cache. + */ +typedef struct rtems_rtl_obj_cache_s +{ + int fd; /**< The file descriptor of the data in the cache. */ + size_t file_size; /**< The size of the file. */ + off_t offset; /**< The base offset of the buffer. */ + size_t size; /**< The size of the cache. */ + size_t level; /**< The amount of data in the cache. A file can be + * smaller than the cache file. */ + uint8_t* buffer; /**< The buffer */ +} rtems_rtl_obj_cache_t; + +/** + * Open a cache allocating a single buffer of the size passed. The default + * state of the cache is flushed. No already open checks are made. + * + * @param cache The cache to initialise. + * @param size The size of the cache. + * @retval true The cache is open. + * @retval false The cache is not open. The RTL error is set. + */ +bool rtems_rtl_obj_cache_open (rtems_rtl_obj_cache_t* cache, size_t size); + +/** + * Close a cache. + * + * @param cache The cache to close. + */ +void rtems_rtl_obj_cache_close (rtems_rtl_obj_cache_t* cache); + +/** + * Flush the cache. Any further read will read the data from the file. + * + * @param cache The cache to flush. + */ +void rtems_rtl_obj_cache_flush (rtems_rtl_obj_cache_t* cache); + +/** + * Read data by reference. The length contains the amount of data that should + * be available in the cache and referenced by the buffer handle. It must be + * less than or equal to the size of the cache. This call will return the + * amount of data that is available. It can be less than you ask if the offset + * and size is past the end of the file. + * + * @param cache The cache to reference data from. + * @param fd The file descriptor. Must be an open file. + * @param offset The offset in the file to reference the data to. + * @param buffer The location to reference the data from. + * @param length The length of data to reference. Can be modified to a + * lesser value and true is still returned so check it. + * @retval true The data referenced is in the cache. + * @retval false The read failed and the RTL error has been set. + */ +bool rtems_rtl_obj_cache_read (rtems_rtl_obj_cache_t* cache, + int fd, + off_t offset, + void** buffer, + size_t* length); + +/** + * Read data by value. The data is copied to the user supplied buffer. + * + * @param cache The cache to read the data from. + * @param fd The file descriptor. Must be an open file. + * @param offset The offset in the file to read the data from. + * @param buffer The location the data is written into. + * @param length The length of data to read. + * @retval true The data has been read from the cache. + * @retval false The read failed and the RTL error has been set. + */ +bool rtems_rtl_obj_cache_read_byval (rtems_rtl_obj_cache_t* cache, + int fd, + off_t offset, + void* buffer, + size_t length); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/cpukit/include/rtems/rtl/rtl-obj-comp.h b/cpukit/include/rtems/rtl/rtl-obj-comp.h new file mode 100644 index 0000000000..34bfa6ffa1 --- /dev/null +++ b/cpukit/include/rtems/rtl/rtl-obj-comp.h @@ -0,0 +1,122 @@ +/* + * COPYRIGHT (c) 2012 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ +/** + * @file + * + * @ingroup rtems_rtl + * + * @brief RTEMS Run-Time Linker Object File Compression manages a + * compressed stream of data. + * + * This is a simple interface to the object file cache to stream data from + * from a compressed object file. There is no ability to seek with the + * data from a compressed file. The module exists to allocate the output + * buffer when the loader starts and use the cache buffers will have been + * allocated. + */ + +#if !defined (_RTEMS_RTL_OBJ_COMP_H_) +#define _RTEMS_RTL_OBJ_COMP_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * The amount of input data read at a time from the file. + */ +#define RTEMS_RTL_DECOMP_INPUT_SIZE (256) + +/** + * The types of supported compression. + */ +#define RTEMS_RTL_COMP_NONE (0) +#define RTEMS_RTL_COMP_LZ77 (1) + +/** + * The compressed file. + */ +typedef struct rtems_rtl_obj_cpmp_s +{ + rtems_rtl_obj_cache_t* cache; /**< The cache provides the input + * buffer. */ + int fd; /**< The file descriptor. */ + int compression; /**< The type of compression. */ + off_t offset; /**< The base offset of the buffer. */ + size_t size; /**< The size of the output buffer. */ + size_t level; /**< The amount of data in the buffer. */ + uint8_t* buffer; /**< The buffer */ + uint32_t read; /**< The amount of data read. */ +} rtems_rtl_obj_comp_t; + +/** + * Return the input level. + */ +static inline uint32_t rtems_rtl_obj_comp_input (rtems_rtl_obj_comp_t* comp) +{ + return comp->read; +} + +/** + * Open a compressor allocating the output buffer. + * + * @param comp The compressor to initialise. + * @param size The size of the compressor's output buffer. + * @retval true The compressor is open. + * @retval false The compressor is not open. The RTL error is set. + */ +bool rtems_rtl_obj_comp_open (rtems_rtl_obj_comp_t* comp, + size_t size); + +/** + * Close a compressor. + * + * @param comp The compressor to close. + */ +void rtems_rtl_obj_comp_close (rtems_rtl_obj_comp_t* comp); + +/** + * Set the cache and offset in the file the compressed stream starts. + * + * @param comp The compressor to set the offset in. + * @param cache The cache to read the file in by. + * @param fd The file descriptor. Must be an open file. + * @param compression The type of compression being streamed. + * @param offset The offset in the file the compressed stream starts. + */ +void rtems_rtl_obj_comp_set (rtems_rtl_obj_comp_t* comp, + rtems_rtl_obj_cache_t* cache, + int fd, + int compression, + off_t offset); + +/** + * Read decompressed data. The length contains the amount of data that should + * be available in the cache and referenced by the buffer handle. It must be + * less than or equal to the size of the cache. This call will return the + * amount of data that is available. It can be less than you ask if the offset + * and size is past the end of the file. + * + * @param comp The compressor to read data from. + * @param buffer The buffer the output is written too. + * @param length The length of data to read. Can be modified to a + * lesser value and true is still returned so check it. + * @retval true The data referenced is in the cache. + * @retval false The read failed and the RTL error has been set. + */ +bool rtems_rtl_obj_comp_read (rtems_rtl_obj_comp_t* comp, + void* buffer, + size_t length); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/cpukit/include/rtems/rtl/rtl-obj-fwd.h b/cpukit/include/rtems/rtl/rtl-obj-fwd.h new file mode 100644 index 0000000000..2c53244316 --- /dev/null +++ b/cpukit/include/rtems/rtl/rtl-obj-fwd.h @@ -0,0 +1,39 @@ +/* + * COPYRIGHT (c) 2012 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ +/** + * @file + * + * @ingroup rtems_rtl + * + * @brief RTEMS Run-Time Linker ELF Headers + */ + +#if !defined (_RTEMS_RTL_OBJ_FWD_H_) +#define _RTEMS_RTL_OBJ_FWD_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * The forward declaration of the obj section structure. + */ +struct rtems_rtl_obj_sect_s; +typedef struct rtems_rtl_obj_sect_s rtems_rtl_obj_sect_t; + +/** + * The forward declaration of the obj structure. + */ +struct rtems_rtl_obj_s; +typedef struct rtems_rtl_obj_s rtems_rtl_obj_t; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/cpukit/include/rtems/rtl/rtl-obj.h b/cpukit/include/rtems/rtl/rtl-obj.h new file mode 100644 index 0000000000..6a35a72822 --- /dev/null +++ b/cpukit/include/rtems/rtl/rtl-obj.h @@ -0,0 +1,635 @@ +/* + * COPYRIGHT (c) 2012 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ +/** + * @file + * + * @ingroup rtems_rtl + * + * @brief RTEMS Run-Time Linker Object Support. + */ + +#if !defined (_RTEMS_RTL_OBJ_H_) +#define _RTEMS_RTL_OBJ_H_ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * Loader format flags. + */ +#define RTEMS_RTL_FMT_ELF (1 << 0) +#define RTEMS_RTL_FMT_COMP (1 << 1) +#define RTEMS_RTL_FMT_PRIVATE (1 << 16) + +/** + * Loader format definition. + */ +typedef struct rtems_rtl_loader_format_s +{ + /** + * The format label. This can be used to determine and manage + * specific formats. + */ + const char* label; + + /** + * The format flags. + */ + uint32_t flags; +} rtems_rtl_loader_format_t; + +/** + * The type of the format loader check handler. This handler checks the format + * and if it is detected as suitable it returns true. + */ +typedef bool (*rtems_rtl_loader_check) (rtems_rtl_obj_t* obj, int fd); + +/** + * The type of the format loader load handler. This handler loads the specific + * format. + */ +typedef bool (*rtems_rtl_loader_load) (rtems_rtl_obj_t* obj, int fd); + +/** + * The type of the format loader unload handler. This handler unloads the + * specific format. + */ +typedef bool (*rtems_rtl_loader_unload) (rtems_rtl_obj_t* obj); + +/** + * The type of the format loader signature handler. This handler checks the + * format signature. + */ +typedef rtems_rtl_loader_format_t* (*rtems_rtl_loader_sig) (void); + +/** + * Table for supported loadable formats. + */ +typedef struct rtems_rtl_loader_table_s +{ + rtems_rtl_loader_check check; /**< The check handler. */ + rtems_rtl_loader_load load; /**< The loader. */ + rtems_rtl_loader_unload unload; /**< The unloader. */ + rtems_rtl_loader_sig signature; /**< The loader's signature. */ +} rtems_rtl_loader_table_t; + +/** + * Flags for the various section types. + */ +#define RTEMS_RTL_OBJ_SECT_TEXT (1 << 0) /**< Section holds program text. */ +#define RTEMS_RTL_OBJ_SECT_CONST (1 << 1) /**< Section holds program text. */ +#define RTEMS_RTL_OBJ_SECT_DATA (1 << 2) /**< Section holds program data. */ +#define RTEMS_RTL_OBJ_SECT_BSS (1 << 3) /**< Section holds program bss. */ +#define RTEMS_RTL_OBJ_SECT_EH (1 << 4) /**< Section holds exception data. */ +#define RTEMS_RTL_OBJ_SECT_REL (1 << 5) /**< Section holds relocation records. */ +#define RTEMS_RTL_OBJ_SECT_RELA (1 << 6) /**< Section holds relocation addend + * records. */ +#define RTEMS_RTL_OBJ_SECT_SYM (1 << 7) /**< Section holds symbols. */ +#define RTEMS_RTL_OBJ_SECT_STR (1 << 8) /**< Section holds strings. */ +#define RTEMS_RTL_OBJ_SECT_ALLOC (1 << 9) /**< Section allocates runtime memory. */ +#define RTEMS_RTL_OBJ_SECT_LOAD (1 << 10) /**< Section is loaded from object file. */ +#define RTEMS_RTL_OBJ_SECT_WRITE (1 << 11) /**< Section is writable, ie data. */ +#define RTEMS_RTL_OBJ_SECT_EXEC (1 << 12) /**< Section is executable. */ +#define RTEMS_RTL_OBJ_SECT_ZERO (1 << 13) /**< Section is preset to zero. */ +#define RTEMS_RTL_OBJ_SECT_LINK (1 << 14) /**< Section is link-ordered. */ +#define RTEMS_RTL_OBJ_SECT_CTOR (1 << 15) /**< Section contains constructors. */ +#define RTEMS_RTL_OBJ_SECT_DTOR (1 << 16) /**< Section contains destructors. */ +#define RTEMS_RTL_OBJ_SECT_LOCD (1 << 17) /**< Section has been located. */ + +/** + * Section types mask. + */ +#define RTEMS_RTL_OBJ_SECT_TYPES (RTEMS_RTL_OBJ_SECT_TEXT | \ + RTEMS_RTL_OBJ_SECT_CONST | \ + RTEMS_RTL_OBJ_SECT_DATA | \ + RTEMS_RTL_OBJ_SECT_BSS | \ + RTEMS_RTL_OBJ_SECT_EH) + +/** + * An object file is made up of sections and the can be more than + * one of a specific type of sections. All sections and grouped + * together in memory. + */ +struct rtems_rtl_obj_sect_s +{ + rtems_chain_node node; /**< The node's link in the chain. */ + int section; /**< The section number. */ + const char* name; /**< The section's name. */ + size_t size; /**< The size of the section in memory. */ + off_t offset; /**< Offset into the object file. Relative to + * the start of the object file. */ + uint32_t alignment; /**< Alignment of this section. */ + int link; /**< Section link field. */ + int info; /**< Secfion info field. */ + uint32_t flags; /**< The section's flags. */ + void* base; /**< The base address of the section in + * memory. */ + int load_order; /**< Order we load sections. */ +}; + +/** + * Object file descriptor flags. + */ +#define RTEMS_RTL_OBJ_LOCKED (1 << 0) /**< Lock the object file so it cannot + * be unloaded. */ +#define RTEMS_RTL_OBJ_UNRESOLVED (1 << 1) /**< The object file has unresolved + * external symbols. */ + +/** + * RTL Object. There is one for each object module loaded plus one for the base + * kernel image. + */ +struct rtems_rtl_obj_s +{ + rtems_chain_node link; /**< The node's link in the chain. */ + uint32_t flags; /**< The status of the object file. */ + uint32_t users; /**< References to the object file. */ + int format; /**< The format of the object file. */ + const char* fname; /**< The file name for the object. */ + const char* oname; /**< The object file name. Can be + * relative. */ + const char* aname; /**< The archive name containing the + * object. NULL means the object is not + * in a lib */ + off_t ooffset; /**< The object offset in the archive. */ + size_t fsize; /**< Size of the object file. */ + rtems_chain_control sections; /**< The sections of interest in the + * object file. */ + rtems_rtl_obj_sym_t* local_table; /**< Local symbol table. */ + size_t local_syms; /**< Local symbol count. */ + size_t local_size; /**< Local symbol memory usage. */ + rtems_rtl_obj_sym_t* global_table; /**< Global symbol table. */ + size_t global_syms; /**< Global symbol count. */ + size_t global_size; /**< Global symbol memory usage. */ + uint32_t unresolved; /**< The number of unresolved relocations. */ + void* text_base; /**< The base address of the text section + * in memory. */ + size_t text_size; /**< The size of the text section. */ + void* const_base; /**< The base address of the const section + * in memory. */ + void* eh_base; /**< The base address of the eh section + * in memory. */ + size_t eh_size; /**< The size of the eh section. */ + void* data_base; /**< The base address of the data section + * in memory. */ + void* bss_base; /**< The base address of the bss section + * in memory. */ + size_t bss_size; /**< The size of the bss section. */ + size_t exec_size; /**< The amount of executable memory + * allocated */ + void* entry; /**< The entry point of the module. */ + uint32_t checksum; /**< The checksum of the text sections. A + * zero means do not checksum. */ + uint32_t* sec_num; /**< The sec nums of each obj. */ + uint32_t obj_num; /**< The count of elf files in an rtl obj. */ + struct link_map* linkmap; /**< For GDB. */ + void* loader; /**< The file details specific to a loader. */ +}; + +/** + * A section handler is called once for each section that needs to be + * processed by this handler. + * + * @param obj The object file's descriptor the section belongs too. + * @param fd The file descriptor of the object file beling loaded. + * @param sect The section the handler is being invoked to handle. + * @param data A user supplied data variable. + * @retval true The operation was successful. + * @retval false The operation failed and the RTL has been set. + */ +typedef bool (*rtems_rtl_obj_sect_handler_t)(rtems_rtl_obj_t* obj, + int fd, + rtems_rtl_obj_sect_t* sect, + void* data); + +/** + * Get the file name. + * + * @param obj The object file. + * @return const char* The string. + */ +static inline const char* rtems_rtl_obj_fname (const rtems_rtl_obj_t* obj) +{ + return obj->fname; +} + +/** + * Is the file name valid ? + * + * @param obj The object file. + * @return bool There is a file name + */ +static inline bool rtems_rtl_obj_fname_valid (const rtems_rtl_obj_t* obj) +{ + return obj->fname; +} + +/** + * Get the object name. + * + * @param obj The object file. + * @return const char* The string. + */ +static inline const char* rtems_rtl_obj_oname (const rtems_rtl_obj_t* obj) +{ + return obj->oname; +} + +/** + * Is the object name valid ? + * + * @param obj The object file. + * @return bool There is an object name + */ +static inline bool rtems_rtl_obj_oname_valid (const rtems_rtl_obj_t* obj) +{ + return obj->oname; +} + +/** + * Get the archive name. + * + * @param obj The object file. + * @return const char* The string. + */ +static inline const char* rtems_rtl_obj_aname (const rtems_rtl_obj_t* obj) +{ + return obj->aname; +} + +/** + * Is the archive name valid ? + * + * @param obj The object file. + * @return bool There is an archive name + */ +static inline bool rtems_rtl_obj_aname_valid (const rtems_rtl_obj_t* obj) +{ + return obj->aname; +} + +/** + * Is the address inside the text section? + * + * @param obj The object file. + * @return bool There is an archive name + */ +static inline bool rtems_rtl_obj_text_inside (const rtems_rtl_obj_t* obj, + const void* address) +{ + return + (address >= obj->text_base) && + (address < (obj->text_base + obj->text_size)); +} + +/** + * Allocate an object structure on the heap. + * + * @retval NULL No memory for the object. + */ +rtems_rtl_obj_t* rtems_rtl_obj_alloc (void); + +/** + * Free the object structure and related resources. + * + * @param obj The object file's descriptor to free. + * @retval false The object has dependences. + * @retval true The object has been freed. + */ +bool rtems_rtl_obj_free (rtems_rtl_obj_t* obj); + +/** + * Does the object file have unresolved external references ? If it does the + * results of executing code is unpredictable. + * + * @param obj The object file's descriptor. + * @retval true The object file has unresolved externals. + * @retval false The object file has all external references resolved. + */ +bool rtems_rtl_obj_unresolved (rtems_rtl_obj_t* obj); + +/** + * Parses a filename and returns newly allocated strings with the archive name, + * object name, and the object's offset + * + * @param name The filename of the object + * @param aname Address of a string pointer that holds the archive name + * @param oname Address of a string pointer that holds the object name + * @param ooffset Address of an int that holds the object offset + * @retval true The parsing was successful + * @retval false The parsing was unsuccessful + */ +bool rtems_rtl_parse_name (const char* name, + const char** aname, + const char** oname, + off_t* ooffset); + +/** + * Check of the name matches the object file's object name. + * + * @param obj The object file's descriptor. + * @param name The name to match. + */ +bool rtems_rtl_match_name (rtems_rtl_obj_t* obj, const char* name); + +/** + * Find an object file on disk that matches the name. The object descriptor is + * fill in with the various parts of a name. A name can have archive, object + * file and offset components. The search path in the RTL is searched. + * + * @param obj The object file's descriptor. + * @param name The name to locate on disk. + * @retval true The file has been found. + * @retval false The file could not be located. The RTL error has been set. + */ +bool rtems_rtl_obj_find_file (rtems_rtl_obj_t* obj, const char* name); + +/** + * Add a section to the object descriptor. + * + * @param obj The object file's descriptor. + * @param section The section's index number. + * @param name The name of the section. + * @param size The size of the section in memory. + * @param offset The offset of the section in the object file. + * @param alignment The alignment of the section in memory. + * @param link The section's link field (from the ELF format). + * @param info The section's info field (from the ELF format). + * @param flags The section's flags. + * @retval true The section has been added. + * @retval false The section has not been added. See the RTL error. + */ +bool rtems_rtl_obj_add_section (rtems_rtl_obj_t* obj, + int section, + const char* name, + size_t size, + off_t offset, + uint32_t alignment, + int link, + int info, + uint32_t flags); + +/** + * Erase the object file descriptor's sections. + * + * @param obj The object file's descriptor. + */ +void rtems_rtl_obj_erase_sections (rtems_rtl_obj_t* obj); + +/** + * Find the section given a name. + * + * @param obj The object file's descriptor. + * @param name The name of the section to find. + * @retval NULL The section was not found. + * @return rtems_rtl_obj_sect_t* The named section. + */ +rtems_rtl_obj_sect_t* rtems_rtl_obj_find_section (const rtems_rtl_obj_t* obj, + const char* name); + +/** + * Find a section given a section's index number. + * + * @param obj The object file's descriptor. + * @param index The section's index to find. + * @retval NULL The section was not found. + * @return rtems_rtl_obj_sect_t* The found section. + */ +rtems_rtl_obj_sect_t* rtems_rtl_obj_find_section_by_index (const rtems_rtl_obj_t* obj, + int index); + +/** + * The text section size. Only use once all the sections has been added. It + * includes alignments between sections that are part of the object's text + * area. The consts sections are included in this section. + * + * @param obj The object file's descriptor. + * @return size_t The size of the text area of the object file. + */ +size_t rtems_rtl_obj_text_size (const rtems_rtl_obj_t* obj); + +/** + * The text section alignment for the object file. Only use once all the + * sections has been added. The section alignment is the alignment of the first + * text type section loaded the text section. + * + * You can assume the alignment is a positive integral power of 2 if not 0 or + * 1. If 0 or 1 then there is no alignment. + * + * @param obj The object file's descriptor. + * @return uint32_t The alignment. Can be 0 or 1 for not aligned or the alignment. + */ +uint32_t rtems_rtl_obj_text_alignment (const rtems_rtl_obj_t* obj); + +/** + * The const section size. Only use once all the sections has been added. It + * includes alignments between sections that are part of the object's const + * area. The consts sections are included in this section. + * + * @param obj The object file's descriptor. + * @return size_t The size of the const area of the object file. + */ +size_t rtems_rtl_obj_const_size (const rtems_rtl_obj_t* obj); + +/** + * The const section alignment for the object file. Only use once all the + * sections has been added. The section alignment is the alignment of the first + * const type section loaded the const section. + * + * You can assume the alignment is a positive integral power of 2 if not 0 or + * 1. If 0 or 1 then there is no alignment. + * + * @param obj The object file's descriptor. + * @return uint32_t The alignment. Can be 0 or 1 for not aligned or the alignment. + */ +uint32_t rtems_rtl_obj_const_alignment (const rtems_rtl_obj_t* obj); + +/** + * The eh section size. Only use once all the sections has been added. It + * includes alignments between sections that are part of the object's bss area. + * + * @param obj The object file's descriptor. + * @return size_t The size of the bss area of the object file. + */ +size_t rtems_rtl_obj_eh_size (const rtems_rtl_obj_t* obj); + +/** + * The eh section alignment for the object file. Only use once all the sections + * has been added. The section alignment is the alignment of the first bss type + * section loaded the bss section. + * + * You can assume the alignment is a positive integral power of 2 if not 0 or + * 1. If 0 or 1 then there is no alignment. + * + * @param obj The object file's descriptor. + * @return uint32_t The alignment. Can be 0 or 1 for not aligned or the alignment. + */ +uint32_t rtems_rtl_obj_eh_alignment (const rtems_rtl_obj_t* obj); + +/** + * The data section size. Only use once all the sections has been added. It + * includes alignments between sections that are part of the object's data + * area. + * + * @param obj The object file's descriptor. + * @return size_t The size of the data area of the object file. + */ +size_t rtems_rtl_obj_data_size (const rtems_rtl_obj_t* obj); + +/** + * The data section alignment for the object file. Only use once all the + * sections has been added. The section alignment is the alignment of the first + * data type section loaded the data section. + * + * You can assume the alignment is a positive integral power of 2 if not 0 or + * 1. If 0 or 1 then there is no alignment. + * + * @param obj The object file's descriptor. + * @return uint32_t The alignment. Can be 0 or 1 for not aligned or the alignment. + */ +uint32_t rtems_rtl_obj_data_alignment (const rtems_rtl_obj_t* obj); + +/** + * The bss section size. Only use once all the sections has been added. It + * includes alignments between sections that are part of the object's bss area. + * + * @param obj The object file's descriptor. + * @return size_t The size of the bss area of the object file. + */ +size_t rtems_rtl_obj_bss_size (const rtems_rtl_obj_t* obj); + +/** + * The bss section alignment for the object file. Only use once all the + * sections has been added. The section alignment is the alignment of the first + * bss type section loaded the bss section. + * + * You can assume the alignment is a positive integral power of 2 if not 0 or + * 1. If 0 or 1 then there is no alignment. + * + * @param obj The object file's descriptor. + * @return uint32_t The alignment. Can be 0 or 1 for not aligned or the alignment. + */ +uint32_t rtems_rtl_obj_bss_alignment (const rtems_rtl_obj_t* obj); + +/** + * Relocate the object file. The object file's section are parsed for any + * relocation type sections. + * + * @param obj The object file's descriptor. + * @param fd The object file's file descriptor. + * @param handler The object file's format specific relocation handler. + * @param data User specific data handle. + * @retval true The object file was relocated. + * @retval false The relocation failed. The RTL error is set. + */ +bool rtems_rtl_obj_relocate (rtems_rtl_obj_t* obj, + int fd, + rtems_rtl_obj_sect_handler_t handler, + void* data); + +/** + * Synchronize caches to make code visible to CPU(s) + * + * @param obj The object file's descriptor. + */ +void rtems_rtl_obj_synchronize_cache (rtems_rtl_obj_t* obj); + +/** + * Relocate an object file's unresolved reference. + * + * @param rec The unresolved relocation record. + * @param sym The unresolved relocation's referenced symbol. + * @retval true The object file record was relocated. + * @retval false The relocation failed. The RTL error is set. + */ +bool rtems_rtl_obj_relocate_unresolved (rtems_rtl_unresolv_reloc_t* reloc, + rtems_rtl_obj_sym_t* sym); + +/** + * Load the symbols from the object file. Only the exported or public symbols + * are read into memory and held in the global symbol table. + * + * @param obj The object file's descriptor. + * @param fd The object file's file descriptor. + * @param handler The object file's format specific symbol handler. + * @param data User specific data handle. + * @retval true The object file's symbol where loaded. + * @retval false The symbol loading failed. The RTL error is set. + */ +bool rtems_rtl_obj_load_symbols (rtems_rtl_obj_t* obj, + int fd, + rtems_rtl_obj_sect_handler_t handler, + void* data); + +/** + * Load the sections that have been allocated memory in the target. The bss + * type section does not load any data, it is set to 0. The text and data + * sections read the detault data from the object file into the target memory. + * + * @param obj The object file's descriptor. + * @param fd The object file's file descriptor. + * @param handler The object file's format specific load handler. + * @param data User specific data handle. + * @retval true The object has been sucessfully loaded. + * @retval false The load failed. The RTL error has been set. + */ +bool rtems_rtl_obj_load_sections (rtems_rtl_obj_t* obj, + int fd, + rtems_rtl_obj_sect_handler_t handler, + void* data); + +/** + * Invoke the constructors the object has. Constructors are a table of pointers + * to "void (*)(void);" where NULL pointers are skipped. The table's size is + * taken from the section's size. The objet ELF specific code is responisble + * for flagging which sections contain constructors. + * + * @param obj The object file's descriptor. + */ +void rtems_rtl_obj_run_ctors (rtems_rtl_obj_t* obj); + +/** + * Invoke the destructors the object has. Destructors are a table of pointers + * to "void (*)(void);" where NULL pointers are skipped. The table's size is + * taken from the section's size. The objet ELF specific code is responisble + * for flagging which sections contain destructors. + * + * @param obj The object file's descriptor. + */ +void rtems_rtl_obj_run_dtors (rtems_rtl_obj_t* obj); + +/** + * Load the object file, reading all sections into memory, symbols and + * performing any relocation fixups. + * + * @param obj The object file's descriptor. + * @retval true The object file has been loaded. + * @retval false The load failed. The RTL error has been set. + */ +bool rtems_rtl_obj_load (rtems_rtl_obj_t* obj); + +/** + * Unload the object file, erasing all symbols and releasing all memory. + * + * @param obj The object file's descriptor. + * @retval true The object file has been unloaded. + * @retval false The unload failed. The RTL error has been set. + */ +bool rtems_rtl_obj_unload (rtems_rtl_obj_t* obj); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/cpukit/include/rtems/rtl/rtl-sym.h b/cpukit/include/rtems/rtl/rtl-sym.h new file mode 100644 index 0000000000..fe00da89d7 --- /dev/null +++ b/cpukit/include/rtems/rtl/rtl-sym.h @@ -0,0 +1,135 @@ +/* + * COPYRIGHT (c) 2012-2014 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ +/** + * @file + * + * @ingroup rtems_rtl + * + * @brief RTEMS Run-Time Linker Object File Symbol Table. + */ + +#if !defined (_RTEMS_RTL_SYM_H_) +#define _RTEMS_RTL_SYM_H_ + +#include +#include "rtl-obj-fwd.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * An object file symbol. + */ +typedef struct rtems_rtl_obj_sym_s +{ + rtems_chain_node node; /**< The node's link in the chain. */ + const char* name; /**< The symbol's name. */ + void* value; /**< The value of the symbol. */ + uint32_t data; /**< Format specific data. */ +} rtems_rtl_obj_sym_t; + +/** + * Table of symbols stored in a hash table. + */ +typedef struct rtems_rtl_symbols_s +{ + rtems_chain_control* buckets; + size_t nbuckets; +} rtems_rtl_symbols_t; + +/** + * Open a symbol table with the specified number of buckets. + * + * @param symbols The symbol table to open. + * @param buckets The number of buckets in the hash table. + * @retval true The symbol is open. + * @retval false The symbol table could not created. The RTL + * error has the error. + */ +bool rtems_rtl_symbol_table_open (rtems_rtl_symbols_t* symbols, + size_t buckets); + +/** + * Close the table and erase the hash table. + * + * @param symbols Close the symbol table. + */ +void rtems_rtl_symbol_table_close (rtems_rtl_symbols_t* symbols); + +/** + * Add a table of exported symbols to the symbol table. + * + * The export table is a series of symbol records and each record has two + * fields: + * + * 1. label + * 2. address + * + * The 'label' is an ASCIIZ string of variable length. The address is of size + * of an unsigned long for the target running the link editor. The byte order + * is defined by the machine type because the table should be built by the + * target compiler. + * + * The table is terminated with a nul string followed by the bytes 0xDE, 0xAD, + * 0xBE, and 0xEF. This avoids alignments issues. + * + * @param obj The object table the symbols are for. + * @param esyms The exported symbol table. + * @param size The size of the table in bytes. + */ +bool rtems_rtl_symbol_global_add (rtems_rtl_obj_t* obj, + const unsigned char* esyms, + unsigned int size); + +/** + * Find a symbol given the symbol label in the global symbol table. + * + * @param name The name as an ASCIIZ string. + * @retval NULL No symbol found. + * @return rtems_rtl_obj_sym_t* Reference to the symbol. + */ +rtems_rtl_obj_sym_t* rtems_rtl_symbol_global_find (const char* name); + +/** + * Find a symbol given the symbol label in the local object file. + * + * @param obj The object file to search. + * @param name The name as an ASCIIZ string. + * @retval NULL No symbol found. + * @return rtems_rtl_obj_sym_t* Reference to the symbol. + */ +rtems_rtl_obj_sym_t* rtems_rtl_symbol_obj_find (rtems_rtl_obj_t* obj, + const char* name); + +/** + * Add the object file's symbols to the global table. + * + * @param obj The object file the symbols are to be added. + */ +void rtems_rtl_symbol_obj_add (rtems_rtl_obj_t* obj); + +/** + * Erase the object file's local symbols. + * + * @param obj The object file the local symbols are to be erased from. + */ +void rtems_rtl_symbol_obj_erase_local (rtems_rtl_obj_t* obj); + +/** + * Erase the object file's symbols. + * + * @param obj The object file the symbols are to be erased from. + */ +void rtems_rtl_symbol_obj_erase (rtems_rtl_obj_t* obj); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/cpukit/include/rtems/rtl/rtl-trace.h b/cpukit/include/rtems/rtl/rtl-trace.h new file mode 100644 index 0000000000..4b93c8c91c --- /dev/null +++ b/cpukit/include/rtems/rtl/rtl-trace.h @@ -0,0 +1,102 @@ +/* + * COPYRIGHT (c) 2012-2014 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ +/** + * @file + * + * @ingroup rtems_rtl + * + * @brief RTEMS Run-Time Linker ELF Trace Support. + */ + +#if !defined (_RTEMS_RTL_TRACE_H_) +#define _RTEMS_RTL_TRACE_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include +#include + +/** + * Set to 1 to build trace support in to the RTL code. + */ +#define RTEMS_RTL_TRACE 1 + +/** + * The type of the mask. + */ +typedef uint32_t rtems_rtl_trace_mask; + +/** + * List of tracing bits for the various parts of the link editor. + */ +#define RTEMS_RTL_TRACE_DETAIL (1UL << 0) +#define RTEMS_RTL_TRACE_WARNING (1UL << 1) +#define RTEMS_RTL_TRACE_LOAD (1UL << 2) +#define RTEMS_RTL_TRACE_UNLOAD (1UL << 3) +#define RTEMS_RTL_TRACE_SECTION (1UL << 4) +#define RTEMS_RTL_TRACE_SYMBOL (1UL << 5) +#define RTEMS_RTL_TRACE_RELOC (1UL << 6) +#define RTEMS_RTL_TRACE_GLOBAL_SYM (1UL << 7) +#define RTEMS_RTL_TRACE_LOAD_SECT (1UL << 8) +#define RTEMS_RTL_TRACE_ALLOCATOR (1UL << 9) +#define RTEMS_RTL_TRACE_UNRESOLVED (1UL << 10) +#define RTEMS_RTL_TRACE_CACHE (1UL << 11) +#define RTEMS_RTL_TRACE_ALL (0xffffffffUL & ~(RTEMS_RTL_TRACE_CACHE)) + +/** + * Call to check if this part is bring traced. If RTEMS_RTL_TRACE is defined to + * 0 the code is dead code elminiated when built with -Os, -O2, or higher. + * + * @param mask The part of the API to trace. + * @retval true Tracing is active for the mask. + * @retval false Do not trace. + */ +#if RTEMS_RTL_TRACE +bool rtems_rtl_trace (rtems_rtl_trace_mask mask); +#else +#define rtems_rtl_trace(_m) (0) +#endif + +/** + * Set the mask. + * + * @param mask The mask bits to set. + * @return The previous mask. + */ +#if RTEMS_RTL_TRACE +rtems_rtl_trace_mask rtems_rtl_trace_set_mask (rtems_rtl_trace_mask mask); +#else +#define rtems_rtl_trace_set_mask(_m) +#endif + +/** + * Clear the mask. + * + * @param mask The mask bits to clear. + * @return The previous mask. + */ +#if RTEMS_RTL_TRACE +rtems_rtl_trace_mask rtems_rtl_trace_clear_mask (rtems_rtl_trace_mask mask); +#else +#define rtems_rtl_trace_clear_mask(_m) +#endif + +/** + * Add shell trace shell command. + */ +#if RTEMS_RTL_TRACE +int rtems_rtl_trace_shell_command (int argc, char *argv[]); +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/cpukit/include/rtems/rtl/rtl-unresolved.h b/cpukit/include/rtems/rtl/rtl-unresolved.h new file mode 100644 index 0000000000..bd4ce2a215 --- /dev/null +++ b/cpukit/include/rtems/rtl/rtl-unresolved.h @@ -0,0 +1,212 @@ +/* + * COPYRIGHT (c) 2012 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ +/** + * @file + * + * @ingroup rtems_rtl + * + * @brief RTEMS Run-Time Linker Object File Unresolved Relocations Table. + * + * The unresolved relocation table holds relocations in a loaded object file + * which reference unresolved external symbols. The support is needed to allow + * dependent object files to load. In the case of dependent object files one + * will have unresolved externals until the dependent object file is also + * loaded. There is no load order that resolves this. + * + * The unresolved relocation table is a single table used by all object files + * with unresolved symbols. It made of blocks linked together where blocks are + * allocated as requiered. The table is always maintained compacted. That is as + * relocations are resolved and removed the table is compacted. The only + * pointer in the table is the object file poniter. This is used to identify + * which object the relocation belongs to. There are no linking or back + * pointers in the unresolved relocations table. The table is scanned for each + * object file's relocations. This is not fast but the table should be small + * and if it happens to grow large you have other more pressing issues to + * resolve in your application. + * + * The table holds two (2) types of records: + * + * # Symbol name strings. + * # Relocations. + * + * The symbol name a relocation references is held in a specific symbol name + * string record in the table the relocation record references. The record + * counts the number of references and the string is removed from the table + * when the reference count reaches 0. There can be many relocations + * referencing the symbol. The strings are referenced by a single 16bit + * unsigned integer which is the count of the string in the table. + * + * The section the relocation is for in the object is the section number. The + * relocation data is series of machine word sized fields: + * + * # Offset in the section. + * # Relocation info (format specific) + * # Additional format specific data. + */ + +#if !defined (_RTEMS_RTL_UNRESOLVED_H_) +#define _RTEMS_RTL_UNRESOLVED_H_ + +#include +#include "rtl-obj-fwd.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * Hack to work around machine size. This needs to be cleaned up + * to better support 64bit targets. + */ +typedef uint32_t rtems_rtl_word_t; + +/** + * The types of records in the blocks. + */ +typedef enum rtems_rtl_unresolved_rtype_e +{ + rtems_rtl_unresolved_empty = 0, /**< The records is empty. Must always be 0 */ + rtems_rtl_unresolved_name = 1, /**< The record is a name. */ + rtems_rtl_unresolved_reloc = 2 /**< The record is a relocation record. */ +} rtems_rtl_unresolved_rtype_t; + +/** + * Unresolved externals symbol names. The names are reference counted and + * separate from the relocation records because a number of records could + * reference the same symbol name. + */ +typedef struct rtems_rtl_unresolv_name_s +{ + uint16_t refs; /**< The number of references to this name. */ + uint16_t length; /**< The length of this name. */ + const char name[12]; /**< The symbol name. */ +} rtems_rtl_unresolv_name_t; + +/** + * Unresolved externals symbols require the relocation records to be held + * and references. + */ +typedef struct rtems_rtl_unresolv_reloc_s +{ + rtems_rtl_obj_t* obj; /**< The relocation's object file. */ + uint16_t flags; /**< Format specific flags. */ + uint16_t name; /**< The symbol's name. */ + uint16_t sect; /**< The target section. */ + rtems_rtl_word_t rel[3]; /**< Relocation record. */ +} rtems_rtl_unresolv_reloc_t; + +/** + * Unresolved externals records. + */ +typedef struct rtems_rtl_unresolv_rec_s +{ + rtems_rtl_unresolved_rtype_t type; + union + { + rtems_rtl_unresolv_name_t name; /**< The name, or */ + rtems_rtl_unresolv_reloc_t reloc; /**< the relocation record. */ + } rec; +} rtems_rtl_unresolv_rec_t; + +/** + * Unresolved blocks. + */ +typedef struct rtems_rtl_unresolv_block_s +{ + rtems_chain_node link; /**< Blocks are chained. */ + uint32_t recs; /**< The number of records in the block. */ + rtems_rtl_unresolv_rec_t rec; /**< The records. More follow. */ +} rtems_rtl_unresolv_block_t; + +/** + * Unresolved table holds the names and relocations. + */ +typedef struct rtems_rtl_unresolved_s +{ + uint32_t marker; + size_t block_recs; /**< The records per blocks allocated. */ + rtems_chain_control blocks; /**< List of blocks. */ +} rtems_rtl_unresolved_t; + +/** + * The iterator function used to iterate over the unresolved table. + * + * @param rec The current iterator. + * @param data The user data. + * @retval true The iterator has finished. + * @retval false The iterator has not finished. Keep iterating. + */ +typedef bool rtems_rtl_unresolved_iterator_t (rtems_rtl_unresolv_rec_t* rec, + void* data); + +/** + * Open an unresolved relocation table. + * + * @param unresolv The unresolved table to open. + * @param block_records The number of records per block allocated. + * @retval true The table is open. + * @retval false The unresolved relocation table could not created. The RTL + * error has the error. + */ +bool rtems_rtl_unresolved_table_open (rtems_rtl_unresolved_t* unresolved, + size_t block_records); + +/** + * Close the table and erase the blocks. + * + * @param unreolved Close the unresolved table. + */ +void rtems_rtl_unresolved_table_close (rtems_rtl_unresolved_t* unresolved); + +/** + * Iterate over the table of unresolved entries. + */ +bool rtems_rtl_unresolved_interate (rtems_rtl_unresolved_iterator_t iterator, + void* data); + +/** + * Add a relocation to the list of unresolved relocations. + * + * @param unresolved The unresolved symbol table. + * @param obj The object table the symbols are for. + * @param flags Format specific flags. + * @param name The symbol name the relocation references. + * @param sect The target section number the relocation references. + * @param rel The format specific relocation data. + * @retval true The relocation has been added. + * @retval false The relocation could not be added. + */ +bool rtems_rtl_unresolved_add (rtems_rtl_obj_t* obj, + const uint16_t flags, + const char* name, + const uint16_t sect, + const rtems_rtl_word_t* rel); + +/** + * Resolve the unresolved symbols. + */ +void rtems_rtl_unresolved_resolve (void); + +/** + * Remove a relocation from the list of unresolved relocations. + * + * @param unresolved The unresolved symbol table. + * @param obj The object table the symbols are for. + * @param esyms The exported symbol table. + * @param size The size of the table in bytes. + */ +bool rtems_rtl_unresolved_remove (rtems_rtl_obj_t* obj, + const char* name, + const uint16_t sect, + const rtems_rtl_word_t* rel); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/cpukit/include/rtems/rtl/rtl.h b/cpukit/include/rtems/rtl/rtl.h new file mode 100644 index 0000000000..fe9a7df081 --- /dev/null +++ b/cpukit/include/rtems/rtl/rtl.h @@ -0,0 +1,321 @@ +/* + * COPYRIGHT (c) 2012 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +/** + * @file + * + * @ingroup rtems_rtl + * + * @brief RTEMS Run-Time Linker + * + * This is the POSIX interface to run-time loading of code into RTEMS. + */ + +#if !defined (_RTEMS_RTL_H_) +#define _RTEMS_RTL_H_ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup rtems_rtl RTEMS Runtime Link Editor + * + * The module implements a runtime link editor with the standard dlopen, and + * dlclose family of functions. + * + * The runtime link editor is different to that found on Unix type systems. The + * object modules are compiled for PIC or position indepentent code and + * therefore require relocating when loaded. + * + * The object file format is currently ELF and object files can be separate + * files or in an archive. Object files in an archive are referenced by + * specifing 'archive:object' format. For example 'libfoo.a:bar.o'. + */ + +/** + * Macros to glue two tokens. + */ +#ifdef __STDC__ +#define RTL_XGLUE(a,b) a##b +#else +#define RTL_XGLUE(a,b) a/**/b +#endif + +#define RTL_GLUE(a,b) RTL_XGLUE(a,b) + +/** + * The number of buckets in the global symbol table. + */ +#define RTEMS_RTL_SYMS_GLOBAL_BUCKETS (32) + +/** + * The number of relocation record per block in the unresolved table. + */ +#define RTEMS_RTL_UNRESOLVED_BLOCK_SIZE (64) + +/** + * The global debugger interface variable. + */ +extern struct r_debug _rtld_debug; + +/** + * Debugger break function. Call when debugging to have it read the _rtld_debug + * variable. + */ +extern void _rtld_debug_state (void); + +/** + * The type of constructor/destructor function. + */ +typedef void (*rtems_rtl_cdtor_t)(void); + +/** + * The global RTL data. This structure is allocated on the heap when the first + * call to the RTL is made and never released. + * + * The global symbol table is a hash table held in this structure and the + * actual symbols are part of the object's structure. If this is a problem we + * could look at a hash table per object file. + */ +struct rtems_rtl_data_s +{ + rtems_id lock; /**< The RTL lock id */ + rtems_rtl_alloc_data_t allocator; /**< The allocator data. */ + rtems_chain_control objects; /**< List if loaded object files. */ + const char* paths; /**< Search paths for archives. */ + rtems_rtl_symbols_t globals; /**< Global symbol table. */ + rtems_rtl_unresolved_t unresolved; /**< Unresolved symbols. */ + rtems_rtl_obj_t* base; /**< Base object file. */ + rtems_rtl_obj_cache_t symbols; /**< Symbols object file cache. */ + rtems_rtl_obj_cache_t strings; /**< Strings object file cache. */ + rtems_rtl_obj_cache_t relocs; /**< Relocations object file cache. */ + rtems_rtl_obj_comp_t decomp; /**< The decompression compressor. */ + int last_errno; /**< Last error number. */ + char last_error[64]; /**< Last error string. */ +}; + +/** + * Get the RTL data with out locking. This call assumes the RTL is locked. + * + * @return rtems_rtl_data_t* The RTL data after being locked. + * @retval NULL The RTL data is not initialised. + */ +rtems_rtl_data_t* rtems_rtl_data (void); + +/** + * Get the RTL global symbol table with out locking. This call assmes the RTL + * is locked. + * + * @return rtems_rtl_symbols_t* The RTL global symbols after being locked. + * @retval NULL The RTL data is not initialised. + */ +rtems_rtl_symbols_t* rtems_rtl_global_symbols (void); + +/** + * Get the RTL resolved table with out locking. This call assmes the RTL + * is locked. + * + * @return rtems_rtl_unresolv_t* The RTL unresolved symbols and reloc records. + * @retval NULL The RTL data is not initialised. + */ +rtems_rtl_unresolved_t* rtems_rtl_unresolved (void); + +/** + * Get the RTL symbols, strings, or relocations object file caches. This call + * assmes the RTL is locked. + * + * @param symbols Pointer to the location to set the cache into. Returns NULL + * is rtl is not initialised. If NULL is passed in no value set. + * @param strings Pointer to the location to set the cache into. Returns NULL + * is rtl is not initialised. If NULL is passed in no value set. + * @param relocs Pointer to the location to set the cache into. Returns NULL + * is rtl is not initialised. If NULL is passed in no value set. + */ +void rtems_rtl_obj_caches (rtems_rtl_obj_cache_t** symbols, + rtems_rtl_obj_cache_t** strings, + rtems_rtl_obj_cache_t** relocs); + +/** + * Flush all the object file caches. + */ +void rtems_rtl_obj_caches_flush (void); + +/** + * Get the RTL decompressor setting the cache and the offset in the file the + * compressed stream starts. This call assmes the RTL is locked. + * + * @param decomp Pointer to the location to set the compressor into. Returns + * NULL is rtl is not initialised. + * @param cache The cache to read the file with. Saves needing an extrs buffer. + * @param offset The offset in the file the compressed stream starts. + */ +void rtems_rtl_obj_comp (rtems_rtl_obj_comp_t** decomp, + rtems_rtl_obj_cache_t* cache, + int fd, + int compression, + off_t offset); + +/** + * Lock the Run-time Linker. + * + * @return rtems_rtl_data_t* The RTL data after being locked. + * @retval NULL The RTL data could not be initialised or locked. Typically this + * means the lock could not be created. + */ +rtems_rtl_data_t* rtems_rtl_lock (void); + +/** + * Unlock the Run-time Linker. + * + * @return True The RTL is unlocked. + * @return False The RTL could not be unlocked. Not much you can do. + */ +bool rtems_rtl_unlock (void); + +/** + * Check a pointer is a valid object file descriptor returning the pointer as + * that type. + * + * Assumes the RTL has been locked. + * + * @param handle Pointer to the object file to be validated. + * @return rtl_obj* The object file descriptor. NULL is returned if invalid. + */ +rtems_rtl_obj_t* rtems_rtl_check_handle (void* handle); + +/** + * Find the object given a file name. + * + * @param name The name of the object file. + * @retval NULL No object file with that name found. + * @return rtems_rtl_obj_t* The object file descriptor. + */ +rtems_rtl_obj_t* rtems_rtl_find_obj (const char* name); + +/** + * Load an object file into memory relocating it. It will not be resolved + * against other symbols in other object files or the base image. + * + * The name can be a file name for an object file or it can be encoded to + * reference an archive of object modules (static library). This encoding is + * specific to RTEMS and allows dependences to specify an archive without the + * searching overhead normally incurred by linkers locating object files in an + * archive. The file name format rules are: + * + * 1. Absolute file references a specific object file in the architecture + * specific location on the file system. + * + * 2. Relative file references an object format file in the search path. + * + * 3. Absolute archive and file reference to a specific location in the file + * system. The archive and file are encoded as 'archive:file [@@offset]' + * where 'archive' is a valid file at the absolute path in the file system, + * and 'file' is a contained in the archive, and optionally an offset to + * the 'file' in the 'archive'. If no offset is provided the archive is + * searched. + * + * 4. Relative archive and file in the search path. The encoding is the same + * as described in item 3 of this list. + * + * Assumes the RTL has been locked. + * + * @param name The name of the object file. + * @param mode The mode of the load as defined by the dlopen call. + * @return rtl_obj* The object file descriptor. NULL is returned if the load fails. + */ +rtems_rtl_obj_t* rtems_rtl_load_object (const char* name, int mode); + +/** + * Unload an object file. This only happens when the user count is 0. + * + * Assumes the RTL has been locked. + * + * @param obj The object file descriptor. + * @retval true The object file has been unloaded. + * @retval false The object file could not be unloaded. + */ +bool rtems_rtl_unload_object (rtems_rtl_obj_t* obj); + +/** + * Run any constructor functions the object file may contain. This call + * assumes the linker is unlocked. + * + * @param obj The object file. + */ +void rtems_rtl_run_ctors (rtems_rtl_obj_t* obj); + +/** + * Get the last error message clearing it. This operation locks the run time + * linker and therefore keeps the RTL thread safe but this call is not thread + * safe is multiple threads are loading object files at the same time. This + * call is provided to map to the dlopen family of calls. + * + * @param message Pointer to a buffer to copy the message into. + * @param max_message The maximum message that can be copied. + * @return int The last error number. + */ +int rtems_rtl_get_error (char* message, size_t max_message); + +/** + * Append the path to the search path. + * + * @param path The path to append. + * @retval false The path could not be appended. + * @retval true The path was appended. + */ +bool rtems_rtl_path_append (const char* path); + +/** + * Prepend the path to the search path. + * + * @param path The path to prepend. + * @retval false The path could not be prepended. + * @retval true The path was prepended. + */ + +bool rtems_rtl_path_prepend (const char* path); + +/** + * Add an exported symbol table to the global symbol table. This call is + * normally used by an object file when loaded that contains a global symbol + * table. + * + * @param esyms The exported symbol table. + * @param count The size of the exported symbol table. + */ +void rtems_rtl_base_sym_global_add (const unsigned char* esyms, + unsigned int count); + +/** + * Return the object file descriptor for the base image. The object file + * descriptor returned is created when the run time linker is initialised. + * + * Assumes the RTL has been locked. + * + * @return rtl_obj* The object file descriptor for the base image. NULL is + * returned if the load fails. + */ +rtems_rtl_obj_t* rtems_rtl_baseimage (void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/cpukit/include/rtems/scheduler.h b/cpukit/include/rtems/scheduler.h new file mode 100644 index 0000000000..8684b798f7 --- /dev/null +++ b/cpukit/include/rtems/scheduler.h @@ -0,0 +1,247 @@ +/** + * @file + * + * @brief Scheduler Configuration API + */ + +/* + * Copyright (c) 2014, 2017 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SAPI_SCHEDULER_H +#define _RTEMS_SAPI_SCHEDULER_H + +#include + +#define RTEMS_SCHEDULER_CONTEXT_NAME( name ) \ + _Configuration_Scheduler_ ## name + +#if defined(RTEMS_SMP) + /* This object doesn't exist and indicates a configuration error */ + extern const Scheduler_Control RTEMS_SCHEDULER_INVALID_INDEX; + + #define RTEMS_SCHEDULER_ASSIGN_DEFAULT \ + SCHEDULER_ASSIGN_DEFAULT + + #define RTEMS_SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL \ + SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL + + #define RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY \ + SCHEDULER_ASSIGN_PROCESSOR_MANDATORY + + #define RTEMS_SCHEDULER_ASSIGN( index, attr ) \ + { \ + ( index ) < RTEMS_ARRAY_SIZE( _Scheduler_Table ) ? \ + &_Scheduler_Table[ ( index ) ] : &RTEMS_SCHEDULER_INVALID_INDEX, \ + ( attr ) \ + } + + #define RTEMS_SCHEDULER_ASSIGN_NO_SCHEDULER { NULL, 0 } +#endif + +/* + * This file should be only included in the context of . + * Define the scheduler configuration macros only in case the corresponding + * configure symbol is defined. This is necessary to prevent invalid workspace + * size estimates since we have to account for the per-thread scheduler + * information. + */ + +#ifdef CONFIGURE_SCHEDULER_CBS + #include + + #define RTEMS_SCHEDULER_CONTEXT_CBS_NAME( name ) \ + RTEMS_SCHEDULER_CONTEXT_NAME( CBS_ ## name ) + + #define RTEMS_SCHEDULER_CONTEXT_CBS( name ) \ + static Scheduler_EDF_Context RTEMS_SCHEDULER_CONTEXT_CBS_NAME( name ) + + #define RTEMS_SCHEDULER_CONTROL_CBS( name, obj_name ) \ + { \ + &RTEMS_SCHEDULER_CONTEXT_CBS_NAME( name ).Base, \ + SCHEDULER_CBS_ENTRY_POINTS, \ + SCHEDULER_CBS_MAXIMUM_PRIORITY, \ + ( obj_name ) \ + } +#endif + +#ifdef CONFIGURE_SCHEDULER_EDF + #include + + #define RTEMS_SCHEDULER_CONTEXT_EDF_NAME( name ) \ + RTEMS_SCHEDULER_CONTEXT_NAME( EDF_ ## name ) + + #define RTEMS_SCHEDULER_CONTEXT_EDF( name ) \ + static Scheduler_EDF_Context RTEMS_SCHEDULER_CONTEXT_EDF_NAME( name ) + + #define RTEMS_SCHEDULER_CONTROL_EDF( name, obj_name ) \ + { \ + &RTEMS_SCHEDULER_CONTEXT_EDF_NAME( name ).Base, \ + SCHEDULER_EDF_ENTRY_POINTS, \ + SCHEDULER_EDF_MAXIMUM_PRIORITY, \ + ( obj_name ) \ + } +#endif + +#ifdef CONFIGURE_SCHEDULER_EDF_SMP + #include + + #define RTEMS_SCHEDULER_CONTEXT_EDF_SMP_NAME( name ) \ + RTEMS_SCHEDULER_CONTEXT_NAME( EDF_SMP_ ## name ) + + #define RTEMS_SCHEDULER_CONTEXT_EDF_SMP( name, max_cpu_count ) \ + static struct { \ + Scheduler_EDF_SMP_Context Base; \ + Scheduler_EDF_SMP_Ready_queue Ready[ ( max_cpu_count ) + 1 ]; \ + } RTEMS_SCHEDULER_CONTEXT_EDF_SMP_NAME( name ) + + #define RTEMS_SCHEDULER_CONTROL_EDF_SMP( name, obj_name ) \ + { \ + &RTEMS_SCHEDULER_CONTEXT_EDF_SMP_NAME( name ).Base.Base.Base, \ + SCHEDULER_EDF_SMP_ENTRY_POINTS, \ + SCHEDULER_EDF_MAXIMUM_PRIORITY, \ + ( obj_name ) \ + } +#endif + +#ifdef CONFIGURE_SCHEDULER_PRIORITY + #include + + #define RTEMS_SCHEDULER_CONTEXT_PRIORITY_NAME( name ) \ + RTEMS_SCHEDULER_CONTEXT_NAME( priority_ ## name ) + + #define RTEMS_SCHEDULER_CONTEXT_PRIORITY( name, prio_count ) \ + static struct { \ + Scheduler_priority_Context Base; \ + Chain_Control Ready[ ( prio_count ) ]; \ + } RTEMS_SCHEDULER_CONTEXT_PRIORITY_NAME( name ) + + #define RTEMS_SCHEDULER_CONTROL_PRIORITY( name, obj_name ) \ + { \ + &RTEMS_SCHEDULER_CONTEXT_PRIORITY_NAME( name ).Base.Base, \ + SCHEDULER_PRIORITY_ENTRY_POINTS, \ + RTEMS_ARRAY_SIZE( \ + RTEMS_SCHEDULER_CONTEXT_PRIORITY_NAME( name ).Ready \ + ) - 1, \ + ( obj_name ) \ + } +#endif + +#ifdef CONFIGURE_SCHEDULER_PRIORITY_AFFINITY_SMP + #include + + #define RTEMS_SCHEDULER_CONTEXT_PRIORITY_AFFINITY_SMP_NAME( name ) \ + RTEMS_SCHEDULER_CONTEXT_NAME( priority_affinity_SMP_ ## name ) + + #define RTEMS_SCHEDULER_CONTEXT_PRIORITY_AFFINITY_SMP( name, prio_count ) \ + static struct { \ + Scheduler_priority_SMP_Context Base; \ + Chain_Control Ready[ ( prio_count ) ]; \ + } RTEMS_SCHEDULER_CONTEXT_PRIORITY_AFFINITY_SMP_NAME( name ) + + #define RTEMS_SCHEDULER_CONTROL_PRIORITY_AFFINITY_SMP( name, obj_name ) \ + { \ + &RTEMS_SCHEDULER_CONTEXT_PRIORITY_AFFINITY_SMP_NAME( name ).Base.Base.Base, \ + SCHEDULER_PRIORITY_AFFINITY_SMP_ENTRY_POINTS, \ + RTEMS_ARRAY_SIZE( \ + RTEMS_SCHEDULER_CONTEXT_PRIORITY_AFFINITY_SMP_NAME( name ).Ready \ + ) - 1, \ + ( obj_name ) \ + } +#endif + +#ifdef CONFIGURE_SCHEDULER_PRIORITY_SMP + #include + + #define RTEMS_SCHEDULER_CONTEXT_PRIORITY_SMP_NAME( name ) \ + RTEMS_SCHEDULER_CONTEXT_NAME( priority_SMP_ ## name ) + + #define RTEMS_SCHEDULER_CONTEXT_PRIORITY_SMP( name, prio_count ) \ + static struct { \ + Scheduler_priority_SMP_Context Base; \ + Chain_Control Ready[ ( prio_count ) ]; \ + } RTEMS_SCHEDULER_CONTEXT_PRIORITY_SMP_NAME( name ) + + #define RTEMS_SCHEDULER_CONTROL_PRIORITY_SMP( name, obj_name ) \ + { \ + &RTEMS_SCHEDULER_CONTEXT_PRIORITY_SMP_NAME( name ).Base.Base.Base, \ + SCHEDULER_PRIORITY_SMP_ENTRY_POINTS, \ + RTEMS_ARRAY_SIZE( \ + RTEMS_SCHEDULER_CONTEXT_PRIORITY_SMP_NAME( name ).Ready \ + ) - 1, \ + ( obj_name ) \ + } +#endif + +#ifdef CONFIGURE_SCHEDULER_STRONG_APA + #include + + #define RTEMS_SCHEDULER_CONTEXT_STRONG_APA_NAME( name ) \ + RTEMS_SCHEDULER_CONTEXT_NAME( strong_APA_ ## name ) + + #define RTEMS_SCHEDULER_CONTEXT_STRONG_APA( name, prio_count ) \ + static struct { \ + Scheduler_strong_APA_Context Base; \ + Chain_Control Ready[ ( prio_count ) ]; \ + } RTEMS_SCHEDULER_CONTEXT_STRONG_APA_NAME( name ) + + #define RTEMS_SCHEDULER_CONTROL_STRONG_APA( name, obj_name ) \ + { \ + &RTEMS_SCHEDULER_CONTEXT_STRONG_APA_NAME( name ).Base.Base.Base, \ + SCHEDULER_STRONG_APA_ENTRY_POINTS, \ + RTEMS_ARRAY_SIZE( \ + RTEMS_SCHEDULER_CONTEXT_STRONG_APA_NAME( name ).Ready \ + ) - 1, \ + ( obj_name ) \ + } +#endif + +#ifdef CONFIGURE_SCHEDULER_SIMPLE + #include + + #define RTEMS_SCHEDULER_CONTEXT_SIMPLE_NAME( name ) \ + RTEMS_SCHEDULER_CONTEXT_NAME( simple_ ## name ) + + #define RTEMS_SCHEDULER_CONTEXT_SIMPLE( name ) \ + static Scheduler_simple_Context \ + RTEMS_SCHEDULER_CONTEXT_SIMPLE_NAME( name ) + + #define RTEMS_SCHEDULER_CONTROL_SIMPLE( name, obj_name ) \ + { \ + &RTEMS_SCHEDULER_CONTEXT_SIMPLE_NAME( name ).Base, \ + SCHEDULER_SIMPLE_ENTRY_POINTS, \ + SCHEDULER_SIMPLE_MAXIMUM_PRIORITY, \ + ( obj_name ) \ + } +#endif + +#ifdef CONFIGURE_SCHEDULER_SIMPLE_SMP + #include + + #define RTEMS_SCHEDULER_CONTEXT_SIMPLE_SMP_NAME( name ) \ + RTEMS_SCHEDULER_CONTEXT_NAME( simple_SMP_ ## name ) + + #define RTEMS_SCHEDULER_CONTEXT_SIMPLE_SMP( name ) \ + static Scheduler_simple_SMP_Context \ + RTEMS_SCHEDULER_CONTEXT_SIMPLE_SMP_NAME( name ) + + #define RTEMS_SCHEDULER_CONTROL_SIMPLE_SMP( name, obj_name ) \ + { \ + &RTEMS_SCHEDULER_CONTEXT_SIMPLE_SMP_NAME( name ).Base.Base, \ + SCHEDULER_SIMPLE_SMP_ENTRY_POINTS, \ + SCHEDULER_SIMPLE_SMP_MAXIMUM_PRIORITY, \ + ( obj_name ) \ + } +#endif + +#endif /* _RTEMS_SAPI_SCHEDULER_H */ diff --git a/cpukit/include/rtems/score/address.h b/cpukit/include/rtems/score/address.h new file mode 100644 index 0000000000..8f38f7c2dc --- /dev/null +++ b/cpukit/include/rtems/score/address.h @@ -0,0 +1,200 @@ +/** + * @file rtems/score/address.h + * + * @brief Information Required to Manipulate Physical Addresses + * + * This include file contains the information required to manipulate + * physical addresses. + */ + +/* + * COPYRIGHT (c) 1989-2006. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_ADDRESS_H +#define _RTEMS_SCORE_ADDRESS_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ScoreAddress Address Handler + * + * @ingroup Score + * + * This handler encapsulates functionality which abstracts address + * manipulation in a portable manner. + */ +/**@{*/ + +/** + * @brief Add offset to an address. + * + * This function is used to add an @a offset to a @a base address. + * It returns the resulting address. This address is typically + * converted to an access type before being used further. + * + * @param[in] base is the base address. + * @param[in] offset is the offset to add to @a base. + * + * @return This method returns the resulting address. + */ +RTEMS_INLINE_ROUTINE void *_Addresses_Add_offset ( + const void *base, + uintptr_t offset +) +{ + return (void *)((uintptr_t)base + offset); +} + +/** + * @brief Subtract offset from offset. + * + * This function is used to subtract an @a offset from a @a base + * address. It returns the resulting address. This address is + * typically converted to an access type before being used further. + * + * @param[in] base is the base address. + * @param[in] offset is the offset to subtract to @a base. + * + * @return This method returns the resulting address. + */ + +RTEMS_INLINE_ROUTINE void *_Addresses_Subtract_offset ( + const void *base, + uintptr_t offset +) +{ + return (void *)((uintptr_t)base - offset); +} + +/** + * @brief Subtract two offsets. + * + * This function is used to subtract two addresses. It returns the + * resulting offset. + * + * @param[in] left is the address on the left hand side of the subtraction. + * @param[in] right is the address on the right hand side of the subtraction. + * + * @return This method returns the resulting address. + * + * @note The cast of an address to an uint32_t makes this code + * dependent on an addresses being thirty two bits. + */ +RTEMS_INLINE_ROUTINE int32_t _Addresses_Subtract ( + const void *left, + const void *right +) +{ + return (int32_t) ((const char *) left - (const char *) right); +} + +/** + * @brief Is address aligned. + * + * This function returns true if the given address is correctly + * aligned for this processor and false otherwise. Proper alignment + * is based on correctness and efficiency. + * + * @param[in] address is the address being checked for alignment. + * + * @retval true The @a address is aligned. + * @retval false The @a address is not aligned. + */ +RTEMS_INLINE_ROUTINE bool _Addresses_Is_aligned ( + const void *address +) +{ +#if (CPU_ALIGNMENT == 0) + return true; +#else + return (((uintptr_t)address % CPU_ALIGNMENT) == 0); +#endif +} + +/** + * @brief Is address in range. + * + * This function returns true if the given address is within the + * memory range specified and false otherwise. base is the address + * of the first byte in the memory range and limit is the address + * of the last byte in the memory range. The base address is + * assumed to be lower than the limit address. + * + * @param[in] address is the address to check. + * @param[in] base is the lowest address of the range to check against. + * @param[in] limit is the highest address of the range to check against. + * + * @retval true The @a address is within the memory range specified + * @retval false The @a address is not within the memory range specified. + */ +RTEMS_INLINE_ROUTINE bool _Addresses_Is_in_range ( + const void *address, + const void *base, + const void *limit +) +{ + return (address >= base && address <= limit); +} + +/** + * @brief Align address to nearest multiple of alignment, rounding up. + * + * This function returns the given address aligned to the given alignment. + * If the address already is aligned, or if alignment is 0, the address is + * returned as is. The returned address is greater than or equal to the + * given address. + * + * @param[in] address is the address to align. + * @param[in] alignment is the boundary for alignment and must be a power of 2 + * + * @return Returns the aligned address. + */ +RTEMS_INLINE_ROUTINE void *_Addresses_Align_up( + void *address, + size_t alignment +) +{ + uintptr_t mask = alignment - (uintptr_t)1; + return (void*)(((uintptr_t)address + mask) & ~mask); +} + +/** + * @brief Align address to nearest multiple of alignment, truncating. + * + * This function returns the given address aligned to the given alignment. + * If the address already is aligned, or if alignment is 0, the address is + * returned as is. The returned address is less than or equal to the + * given address. + * + * @param[in] address is the address to align. + * @param[in] alignment is the boundary for alignment and must be a power of 2. + * + * @return Returns the aligned address. + */ +RTEMS_INLINE_ROUTINE void *_Addresses_Align_down( + void *address, + size_t alignment +) +{ + uintptr_t mask = alignment - (uintptr_t)1; + return (void*)((uintptr_t)address & ~mask); +} + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/apimutex.h b/cpukit/include/rtems/score/apimutex.h new file mode 100644 index 0000000000..f43edf23f4 --- /dev/null +++ b/cpukit/include/rtems/score/apimutex.h @@ -0,0 +1,109 @@ +/** + * @file + * + * @ingroup ScoreAPIMutex + * + * @brief API Mutex Handler API + */ + +/* + * COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_APIMUTEX_H +#define _RTEMS_SCORE_APIMUTEX_H + +#include + +#include + +/** + * @defgroup ScoreAPIMutex API Mutex Handler + * + * @ingroup Score + * + * @brief Provides routines to ensure mutual exclusion on API level. + */ +/**@{**/ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Control block used to manage each API mutex. + */ +typedef struct { + /** + * A recursive mutex. + */ + struct _Mutex_recursive_Control Mutex; + + /** + * @brief The thread life protection state before the outer-most mutex + * obtain. + */ + Thread_Life_state previous_thread_life_state; +} API_Mutex_Control; + +/** + * @brief Statically initialize an API mutex. + */ +#define API_MUTEX_INITIALIZER( name ) \ + { _MUTEX_RECURSIVE_NAMED_INITIALIZER( name ), 0 } + +/** + * @brief Acquires the specified API mutex. + * + * @param[in] mutex The API mutex. + */ +void _API_Mutex_Lock( API_Mutex_Control *mutex ); + +/** + * @brief Releases the specified API mutex. + * + * @param[in] mutex The API mutex. + */ +void _API_Mutex_Unlock( API_Mutex_Control *mutex ); + +/** + * @brief Checks if the specified API mutex is owned by the executing thread. + * + * @param[in] mutex The API mutex. + */ +bool _API_Mutex_Is_owner( const API_Mutex_Control *mutex ); + +/** @} */ + +/** + * @defgroup ScoreAllocatorMutex RTEMS Allocator Mutex + * + * @ingroup ScoreAPIMutex + * + * @brief Protection for all memory allocations and deallocations in RTEMS. + * + * When the APIs all use this for allocation and deallocation protection, then + * this possibly should be renamed and moved to a higher level in the + * hierarchy. + */ +/**@{**/ + +void _RTEMS_Lock_allocator( void ); + +void _RTEMS_Unlock_allocator( void ); + +bool _RTEMS_Allocator_is_owner( void ); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/assert.h b/cpukit/include/rtems/score/assert.h new file mode 100644 index 0000000000..d4432838ce --- /dev/null +++ b/cpukit/include/rtems/score/assert.h @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2013-2014 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_ASSERT_H +#define _RTEMS_SCORE_ASSERT_H + +#include + +#if defined( RTEMS_DEBUG ) + #include +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @brief Assertion similar to assert() controlled via RTEMS_DEBUG instead of + * NDEBUG. + */ +#if defined( RTEMS_DEBUG ) + + /** + * @brief Macro with method name used in assert output + * + * Given the variations in compilers and standards, we have to poke a bit. + * + * @note This is based on the code in newlib's assert.h. + */ + #ifndef __RTEMS_ASSERT_FUNCTION + /* Use g++'s demangled names in C++. */ + #if defined __cplusplus && defined __GNUC__ + #define __RTEMS_ASSERT_FUNCTION __PRETTY_FUNCTION__ + + /* C99 requires the use of __func__. */ + #elif __STDC_VERSION__ >= 199901L + #define __RTEMS_ASSERT_FUNCTION __func__ + + /* Older versions of gcc don't have __func__ but can use __FUNCTION__. */ + #elif __GNUC__ >= 2 + #define __RTEMS_ASSERT_FUNCTION __FUNCTION__ + + /* failed to detect __func__ support. */ + #else + #define __RTEMS_ASSERT_FUNCTION ((char *) 0) + #endif + #endif /* !__RTEMS_ASSERT_FUNCTION */ + + #if !defined( RTEMS_SCHEDSIM ) + /* normal build is newlib. */ + + void __assert_func(const char *, int, const char *, const char *) + RTEMS_NO_RETURN; + + #define _Assert( _e ) \ + ( ( _e ) ? \ + ( void ) 0 : \ + __assert_func( __FILE__, __LINE__, __RTEMS_ASSERT_FUNCTION, #_e ) ) + + #elif defined(__linux__) + /* Scheduler simulator has only beed tested on glibc. */ + #define _Assert( _e ) \ + ( ( _e ) ? \ + ( void ) 0 : \ + __assert_fail( #_e, __FILE__, __LINE__, __RTEMS_ASSERT_FUNCTION ) ) + #else + #error "Implement RTEMS assert support for this C Library" + #endif + +#else + #define _Assert( _e ) ( ( void ) 0 ) +#endif + +/** + * @brief Like _Assert(), but only armed if RTEMS_SMP is defined. + */ +#if defined( RTEMS_SMP ) + #define _SMP_Assert( _e ) _Assert( _e ) +#else + #define _SMP_Assert( _e ) ( ( void ) 0 ) +#endif + +/** + * @brief Returns true if thread dispatching is allowed. + * + * Thread dispatching can be repressed via _Thread_Disable_dispatch() or + * _ISR_Local_disable(). + */ +#if defined( RTEMS_DEBUG ) + bool _Debug_Is_thread_dispatching_allowed( void ); +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_SCORE_ASSERT_H */ diff --git a/cpukit/include/rtems/score/atomic.h b/cpukit/include/rtems/score/atomic.h new file mode 100644 index 0000000000..526926926f --- /dev/null +++ b/cpukit/include/rtems/score/atomic.h @@ -0,0 +1,156 @@ +/** + * @file + * + * @ingroup ScoreAtomic + * + * @brief Atomic Operations API + */ + +/* + * COPYRIGHT (c) 2012-2013 Deng Hengyi. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_ATOMIC_H +#define _RTEMS_SCORE_ATOMIC_H + +#include + +/** + * @defgroup ScoreAtomic Atomic Operations + * + * @ingroup Score + * + * @brief Support for atomic operations. + * + * Atomic operations can be used to implement low-level synchronization + * primitives on SMP systems, like spin locks. All atomic operations are + * defined in terms of C11 (ISO/IEC 9899:2011) or C++11 (ISO/IEC 14882:2011). + * For documentation use the standard documents. + * + * @{ + */ + +typedef CPU_atomic_Uint Atomic_Uint; + +typedef CPU_atomic_Ulong Atomic_Ulong; + +typedef CPU_atomic_Uintptr Atomic_Uintptr; + +typedef CPU_atomic_Flag Atomic_Flag; + +typedef CPU_atomic_Order Atomic_Order; + +#define ATOMIC_ORDER_RELAXED CPU_ATOMIC_ORDER_RELAXED + +#define ATOMIC_ORDER_ACQUIRE CPU_ATOMIC_ORDER_ACQUIRE + +#define ATOMIC_ORDER_RELEASE CPU_ATOMIC_ORDER_RELEASE + +#define ATOMIC_ORDER_ACQ_REL CPU_ATOMIC_ORDER_ACQ_REL + +#define ATOMIC_ORDER_SEQ_CST CPU_ATOMIC_ORDER_SEQ_CST + +#define ATOMIC_INITIALIZER_UINT( value ) CPU_ATOMIC_INITIALIZER_UINT( value ) + +#define ATOMIC_INITIALIZER_ULONG( value ) CPU_ATOMIC_INITIALIZER_ULONG( value ) + +#define ATOMIC_INITIALIZER_UINTPTR( value ) CPU_ATOMIC_INITIALIZER_UINTPTR( value ) + +#define ATOMIC_INITIALIZER_FLAG CPU_ATOMIC_INITIALIZER_FLAG + +#define _Atomic_Fence( order ) _CPU_atomic_Fence( order ) + +#define _Atomic_Init_uint( obj, desired ) \ + _CPU_atomic_Init_uint( obj, desired ) + +#define _Atomic_Init_ulong( obj, desired ) \ + _CPU_atomic_Init_ulong( obj, desired ) + +#define _Atomic_Init_uintptr( obj, desired ) \ + _CPU_atomic_Init_uintptr( obj, desired ) + +#define _Atomic_Load_uint( obj, order ) \ + _CPU_atomic_Load_uint( obj, order ) + +#define _Atomic_Load_ulong( obj, order ) \ + _CPU_atomic_Load_ulong( obj, order ) + +#define _Atomic_Load_uintptr( obj, order ) \ + _CPU_atomic_Load_uintptr( obj, order ) + +#define _Atomic_Store_uint( obj, desr, order ) \ + _CPU_atomic_Store_uint( obj, desr, order ) + +#define _Atomic_Store_ulong( obj, desr, order ) \ + _CPU_atomic_Store_ulong( obj, desr, order ) + +#define _Atomic_Store_uintptr( obj, desr, order ) \ + _CPU_atomic_Store_uintptr( obj, desr, order ) + +#define _Atomic_Fetch_add_uint( obj, arg, order ) \ + _CPU_atomic_Fetch_add_uint( obj, arg, order ) + +#define _Atomic_Fetch_add_ulong( obj, arg, order ) \ + _CPU_atomic_Fetch_add_ulong( obj, arg, order ) + +#define _Atomic_Fetch_add_uintptr( obj, arg, order ) \ + _CPU_atomic_Fetch_add_uintptr( obj, arg, order ) + +#define _Atomic_Fetch_sub_uint( obj, arg, order ) \ + _CPU_atomic_Fetch_sub_uint( obj, arg, order ) + +#define _Atomic_Fetch_sub_ulong( obj, arg, order ) \ + _CPU_atomic_Fetch_sub_ulong( obj, arg, order ) + +#define _Atomic_Fetch_sub_uintptr( obj, arg, order ) \ + _CPU_atomic_Fetch_sub_uintptr( obj, arg, order ) + +#define _Atomic_Fetch_or_uint( obj, arg, order ) \ + _CPU_atomic_Fetch_or_uint( obj, arg, order ) + +#define _Atomic_Fetch_or_ulong( obj, arg, order ) \ + _CPU_atomic_Fetch_or_ulong( obj, arg, order ) + +#define _Atomic_Fetch_or_uintptr( obj, arg, order ) \ + _CPU_atomic_Fetch_or_uintptr( obj, arg, order ) + +#define _Atomic_Fetch_and_uint( obj, arg, order ) \ + _CPU_atomic_Fetch_and_uint( obj, arg, order ) + +#define _Atomic_Fetch_and_ulong( obj, arg, order ) \ + _CPU_atomic_Fetch_and_ulong( obj, arg, order ) + +#define _Atomic_Fetch_and_uintptr( obj, arg, order ) \ + _CPU_atomic_Fetch_and_uintptr( obj, arg, order ) + +#define _Atomic_Exchange_uint( obj, desr, order ) \ + _CPU_atomic_Exchange_uint( obj, desr, order ) + +#define _Atomic_Exchange_ulong( obj, desr, order ) \ + _CPU_atomic_Exchange_ulong( obj, desr, order ) + +#define _Atomic_Exchange_uintptr( obj, desr, order ) \ + _CPU_atomic_Exchange_uintptr( obj, desr, order ) + +#define _Atomic_Compare_exchange_uint( obj, expected, desired, succ, fail ) \ + _CPU_atomic_Compare_exchange_uint( obj, expected, desired, succ, fail ) + +#define _Atomic_Compare_exchange_ulong( obj, expected, desired, succ, fail ) \ + _CPU_atomic_Compare_exchange_ulong( obj, expected, desired, succ, fail ) + +#define _Atomic_Compare_exchange_uintptr( obj, expected, desired, succ, fail ) \ + _CPU_atomic_Compare_exchange_uintptr( obj, expected, desired, succ, fail ) + +#define _Atomic_Flag_clear( obj, order ) \ + _CPU_atomic_Flag_clear( obj, order ) + +#define _Atomic_Flag_test_and_set( obj, order ) \ + _CPU_atomic_Flag_test_and_set( obj, order ) + +/** @} */ + +#endif /* _RTEMS_SCORE_ATOMIC_H */ diff --git a/cpukit/include/rtems/score/basedefs.h b/cpukit/include/rtems/score/basedefs.h new file mode 100644 index 0000000000..4e48d226e8 --- /dev/null +++ b/cpukit/include/rtems/score/basedefs.h @@ -0,0 +1,415 @@ +/** + * @file + * + * @ingroup Score + * + * @brief Basic Definitions + */ + +/* + * COPYRIGHT (c) 1989-2007. + * On-Line Applications Research Corporation (OAR). + * + * Copyright (c) 2010, 2017 embedded brains GmbH. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_BASEDEFS_H +#define _RTEMS_BASEDEFS_H + +/** + * @defgroup ScoreBaseDefs Basic Definitions + * + * @ingroup Score + */ +/**@{*/ + +#include + +#ifndef ASM + #include + #include + #include +#endif + +#ifndef TRUE + /** + * This ensures that RTEMS has TRUE defined in all situations. + */ + #define TRUE 1 +#endif + +#ifndef FALSE + /** + * This ensures that RTEMS has FALSE defined in all situations. + */ + #define FALSE 0 +#endif + +#if TRUE == FALSE + #error "TRUE equals FALSE" +#endif + +/** + * The following (in conjunction with compiler arguments) are used + * to choose between the use of static inline functions and macro + * functions. The static inline implementation allows better + * type checking with no cost in code size or execution speed. + */ +#ifdef __GNUC__ + #define RTEMS_INLINE_ROUTINE static __inline__ +#else + #define RTEMS_INLINE_ROUTINE static inline +#endif + +/** + * The following macro is a compiler specific way to ensure that memory + * writes are not reordered around certian points. This specifically can + * impact interrupt disable and thread dispatching critical sections. + */ +#ifdef __GNUC__ + #define RTEMS_COMPILER_MEMORY_BARRIER() __asm__ volatile("" ::: "memory") +#else + #define RTEMS_COMPILER_MEMORY_BARRIER() +#endif + +/** + * The following defines a compiler specific attribute which informs + * the compiler that the method must not be inlined. + */ +#ifdef __GNUC__ + #define RTEMS_NO_INLINE __attribute__((__noinline__)) +#else + #define RTEMS_NO_INLINE +#endif + +/** + * The following macro is a compiler specific way to indicate that + * the method will NOT return to the caller. This can assist the + * compiler in code generation and avoid unreachable paths. This + * can impact the code generated following calls to + * rtems_fatal_error_occurred and _Terminate. + */ +#if defined(RTEMS_SCHEDSIM) + #define RTEMS_NO_RETURN +#elif defined(__GNUC__) && !defined(RTEMS_DEBUG) + #define RTEMS_NO_RETURN __attribute__((__noreturn__)) +#else + #define RTEMS_NO_RETURN +#endif + +/* Provided for backward compatibility */ +#define RTEMS_COMPILER_NO_RETURN_ATTRIBUTE RTEMS_NO_RETURN + +/** + * The following defines a compiler specific attribute which informs + * the compiler that the method has no effect except the return value + * and that the return value depends only on parameters and/or global + * variables. + */ +#ifdef __GNUC__ + #define RTEMS_PURE __attribute__((__pure__)) +#else + #define RTEMS_PURE +#endif + +/* Provided for backward compatibility */ +#define RTEMS_COMPILER_PURE_ATTRIBUTE RTEMS_PURE + +/** + * Instructs the compiler to issue a warning whenever a variable or function + * with this attribute will be used. + */ +#ifdef __GNUC__ + #define RTEMS_DEPRECATED __attribute__((__deprecated__)) +#else + #define RTEMS_DEPRECATED +#endif + +/* Provided for backward compatibility */ +#define RTEMS_COMPILER_DEPRECATED_ATTRIBUTE RTEMS_DEPRECATED + +/** + * @brief Instructs the compiler to place a specific variable or function in + * the specified section. + */ +#if defined(__GNUC__) + #define RTEMS_SECTION( _section ) __attribute__((__section__(_section))) +#else + #define RTEMS_SECTION( _section ) +#endif + +/** + * @brief Instructs the compiler that a specific variable or function is used. + */ +#if defined(__GNUC__) + #define RTEMS_USED __attribute__((__used__)) +#else + #define RTEMS_USED +#endif + +/** + * Instructs the compiler that a specific variable is deliberately unused. + * This can occur when reading volatile device memory or skipping arguments + * in a variable argument method. + */ +#if defined(__GNUC__) + #define RTEMS_UNUSED __attribute__((__unused__)) +#else + #define RTEMS_UNUSED +#endif + +/* Provided for backward compatibility */ +#define RTEMS_COMPILER_UNUSED_ATTRIBUTE RTEMS_UNUSED + +/** + * Instructs the compiler that a specific structure or union members will be + * placed so that the least memory is used. + */ +#if defined(__GNUC__) + #define RTEMS_PACKED __attribute__((__packed__)) +#else + #define RTEMS_PACKED +#endif + +/** + * @brief Instructs the compiler to generate an alias to the specified target + * function. + */ +#if defined(__GNUC__) + #define RTEMS_ALIAS( _target ) __attribute__((__alias__(#_target))) +#else + #define RTEMS_ALIAS( _target ) +#endif + +/** + * @brief Instructs the compiler to generate a weak alias to the specified + * target function. + */ +#if defined(__GNUC__) + #define RTEMS_WEAK_ALIAS( _target ) __attribute__((__weak__, __alias__(#_target))) +#else + #define RTEMS_WEAK_ALIAS( _target ) +#endif + +/** + * @brief Instructs the compiler to enforce the specified alignment. + */ +#if defined(__GNUC__) + #define RTEMS_ALIGNED( _alignment ) __attribute__((__aligned__(_alignment))) +#else + #define RTEMS_ALIGNED( _alignment ) +#endif + +/* Provided for backward compatibility */ +#define RTEMS_COMPILER_PACKED_ATTRIBUTE RTEMS_PACKED + +#if defined(RTEMS_DEBUG) && !defined(RTEMS_SCHEDSIM) + #define _Assert_Unreachable() _Assert( 0 ) +#else + #define _Assert_Unreachable() do { } while ( 0 ) +#endif + +/** + * @brief Tells the compiler that this program point is unreachable. + */ +#if defined(__GNUC__) && !defined(RTEMS_SCHEDSIM) + #define RTEMS_UNREACHABLE() \ + do { \ + __builtin_unreachable(); \ + _Assert_Unreachable(); \ + } while ( 0 ) +#else + #define RTEMS_UNREACHABLE() _Assert_Unreachable() +#endif + +/** + * @brief Tells the compiler that this function expects printf()-like + * arguments. + */ +#if defined(__GNUC__) + #define RTEMS_PRINTFLIKE( _format_pos, _ap_pos ) \ + __attribute__((__format__(__printf__, _format_pos, _ap_pos))) +#else + #define RTEMS_PRINTFLIKE( _format_pos, _ap_pos ) +#endif + +/** + * @brief Obfuscates the variable so that the compiler cannot perform + * optimizations based on the variable value. + * + * The variable must be simple enough to fit into a register. + */ +#if defined(__GNUC__) + #define RTEMS_OBFUSCATE_VARIABLE( _var ) __asm__("" : "+r" (_var)) +#else + #define RTEMS_OBFUSCATE_VARIABLE( _var ) (void) (_var) +#endif + +#if __cplusplus >= 201103L + #define RTEMS_STATIC_ASSERT(cond, msg) \ + static_assert(cond, # msg) +#elif __STDC_VERSION__ >= 201112L + #define RTEMS_STATIC_ASSERT(cond, msg) \ + _Static_assert(cond, # msg) +#else + #define RTEMS_STATIC_ASSERT(cond, msg) \ + typedef int rtems_static_assert_ ## msg [(cond) ? 1 : -1] +#endif + +#define RTEMS_ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) + +/* + * Zero-length arrays are valid in C99 as flexible array members. C++11 + * doesn't allow flexible array members. Use the GNU extension which is also + * supported by other compilers. + */ +#define RTEMS_ZERO_LENGTH_ARRAY 0 + +/** + * @brief Returns a pointer to the container of a specified member pointer. + * + * @param[in] _m The pointer to a member of the container. + * @param[in] _type The type of the container. + * @param[in] _member_name The designator name of the container member. + */ +#define RTEMS_CONTAINER_OF( _m, _type, _member_name ) \ + ( (_type *) ( (uintptr_t) ( _m ) - offsetof( _type, _member_name ) ) ) + +#ifdef __cplusplus +#define RTEMS_DEQUALIFY_DEPTHX( _ptr_level, _type, _var ) \ + (const_cast<_type>( _var )) +#else /* Standard C code */ + +/* The reference type idea based on libHX by Jan Engelhardt */ +#define RTEMS_TYPEOF_REFX(_ptr_level, _ptr_type) \ + typeof(_ptr_level(union { int z; typeof(_ptr_type) x; }){0}.x) + +#if defined(__GNUC__) && !defined(ASM) +#if ((__GNUC__ * 1000 + __GNUC_MINOR__) >= 4004) +extern void* RTEMS_DEQUALIFY_types_not_compatible(void) + __attribute__((error ("RTEMS_DEQUALIFY types differ not only by volatile and const"))); +#else +extern void RTEMS_DEQUALIFY_types_not_compatible(void); +#endif +#define RTEMS_DEQUALIFY_DEPTHX( _ptr_level, _type, _var ) ( \ + __builtin_choose_expr( __builtin_types_compatible_p ( \ + RTEMS_TYPEOF_REFX( _ptr_level, _var ), \ + RTEMS_TYPEOF_REFX( _ptr_level, _type ) \ + ) || __builtin_types_compatible_p ( _type, void * ), \ + (_type)(_var), \ + RTEMS_DEQUALIFY_types_not_compatible() \ + ) \ +) +#endif /*__GNUC__*/ +#endif /*__cplusplus*/ + +#ifndef RTEMS_DECONST +#ifdef RTEMS_DEQUALIFY_DEPTHX +#define RTEMS_DECONST( _type, _var ) \ + RTEMS_DEQUALIFY_DEPTHX( *, _type, _var ) +#else /*RTEMS_DEQUALIFY_DEPTHX*/ +/** + * @brief Removes the const qualifier from a type of a variable. + * + * @param[in] _type The target type for the variable. + * @param[in] _var The variable. + */ +#define RTEMS_DECONST( _type, _var ) \ + ((_type)(uintptr_t)(const void *) ( _var )) + +#endif /*RTEMS_DEQUALIFY_DEPTHX*/ +#endif /*RTEMS_DECONST*/ + +#ifndef RTEMS_DEVOLATILE +#ifdef RTEMS_DEQUALIFY_DEPTHX +#define RTEMS_DEVOLATILE( _type, _var ) \ + RTEMS_DEQUALIFY_DEPTHX( *, _type, _var ) +#else /*RTEMS_DEQUALIFY_DEPTHX*/ +/** + * @brief Removes the volatile qualifier from a type of a variable. + * + * @param[in] _type The target type for the variable. + * @param[in] _var The variable. + */ +#define RTEMS_DEVOLATILE( _type, _var ) \ + ((_type)(uintptr_t)(volatile void *) ( _var )) + +#endif /*RTEMS_DEQUALIFY_DEPTHX*/ +#endif /*RTEMS_DEVOLATILE*/ + +#ifndef RTEMS_DEQUALIFY +#ifdef RTEMS_DEQUALIFY_DEPTHX +#define RTEMS_DEQUALIFY( _type, _var ) \ + RTEMS_DEQUALIFY_DEPTHX( *, _type, _var ) +#else /*RTEMS_DEQUALIFY_DEPTHX*/ +/** + * @brief Removes the all qualifiers from a type of a variable. + * + * @param[in] _type The target type for the variable. + * @param[in] _var The variable. + */ +#define RTEMS_DEQUALIFY( _type, _var ) \ + ((_type)(uintptr_t)(const volatile void *) ( _var )) + +#endif /*RTEMS_DEQUALIFY_DEPTHX*/ +#endif /*RTEMS_DEQUALIFY*/ + +/** + * @brief Evaluates to true if the members of two types have the same type. + * + * @param[in] _t_lhs Left hand side type. + * @param[in] _m_lhs Left hand side member. + * @param[in] _t_rhs Right hand side type. + * @param[in] _m_rhs Right hand side member. + */ +#ifdef __GNUC__ + #define RTEMS_HAVE_MEMBER_SAME_TYPE( _t_lhs, _m_lhs, _t_rhs, _m_rhs ) \ + __builtin_types_compatible_p( \ + __typeof( ( (_t_lhs *) 0 )->_m_lhs ), \ + __typeof( ( (_t_rhs *) 0 )->_m_rhs ) \ + ) +#else + #define RTEMS_HAVE_MEMBER_SAME_TYPE( _t_lhs, _m_lhs, _t_rhs, _m_rhs ) \ + true +#endif + +/** + * @brief Concatenates _x and _y without expanding. + */ +#define RTEMS_CONCAT( _x, _y ) _x##_y + +/** + * @brief Concatenates expansion of _x and expansion of _y. + */ +#define RTEMS_XCONCAT( _x, _y ) RTEMS_CONCAT( _x, _y ) + +/** + * @brief Stringifies _x without expanding. + */ +#define RTEMS_STRING( _x ) #_x + +/** + * @brief Stringifies expansion of _x. + */ +#define RTEMS_XSTRING( _x ) RTEMS_STRING( _x ) + +#ifndef ASM + #ifdef RTEMS_DEPRECATED_TYPES + typedef bool boolean; + typedef float single_precision; + typedef double double_precision; + #endif + + /** + * XXX: Eventually proc_ptr needs to disappear!!! + */ + typedef void * proc_ptr; +#endif + +/**@}*/ + +#endif /* _RTEMS_BASEDEFS_H */ diff --git a/cpukit/include/rtems/score/chain.h b/cpukit/include/rtems/score/chain.h new file mode 100644 index 0000000000..e358262e6e --- /dev/null +++ b/cpukit/include/rtems/score/chain.h @@ -0,0 +1,102 @@ +/** + * @file + * + * @ingroup ScoreChain + * + * @brief Chain Handler API + */ + +/* + * Copyright (c) 2010 embedded brains GmbH. + * + * COPYRIGHT (c) 1989-2006. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CHAIN_H +#define _RTEMS_SCORE_CHAIN_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ScoreChain Chain Handler + * + * @ingroup Score + * + * The Chain Handler is used to manage sets of entities. This handler + * provides two data structures. The Chain Node data structure is included + * as the first part of every data structure that will be placed on + * a chain. The second data structure is Chain Control which is used + * to manage a set of Chain Nodes. + */ +/**@{*/ + +/** + * @typedef Chain_Node + * + * This type definition promotes the name for the Chain Node used by + * all RTEMS code. It is a separate type definition because a forward + * reference is required to define it. See @ref Chain_Node_struct for + * detailed information. + */ +typedef struct Chain_Node_struct Chain_Node; + +/** + * @struct Chain_Node_struct + * + * This is used to manage each element (node) which is placed + * on a chain. + * + * @note Typically, a more complicated structure will use the + * chain package. The more complicated structure will + * include a chain node as the first element in its + * control structure. It will then call the chain package + * with a pointer to that node element. The node pointer + * and the higher level structure start at the same address + * so the user can cast the pointers back and forth. + * + */ +struct Chain_Node_struct { + /** This points to the node after this one on this chain. */ + Chain_Node *next; + /** This points to the node immediate prior to this one on this chain. */ + Chain_Node *previous; +}; + +/** + * @struct Chain_Control + * + * This is used to manage a chain. A chain consists of a doubly + * linked list of zero or more nodes. + * + * @note This implementation does not require special checks for + * manipulating the first and last elements on the chain. + * To accomplish this the @a Chain_Control structure is + * treated as two overlapping @ref Chain_Node structures. + */ +typedef union { + struct { + Chain_Node Node; + Chain_Node *fill; + } Head; + + struct { + Chain_Node *fill; + Chain_Node Node; + } Tail; +} Chain_Control; + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/chainimpl.h b/cpukit/include/rtems/score/chainimpl.h new file mode 100644 index 0000000000..c94c051198 --- /dev/null +++ b/cpukit/include/rtems/score/chainimpl.h @@ -0,0 +1,1123 @@ +/** + * @file + * + * @brief Chain Handler API + */ + +/* + * Copyright (c) 2010 embedded brains GmbH. + * + * COPYRIGHT (c) 1989-2014. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CHAINIMPL_H +#define _RTEMS_SCORE_CHAINIMPL_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup ScoreChain + */ +/**@{**/ + +/** + * @brief Chain initializer for an empty chain with designator @a name. + */ +#define CHAIN_INITIALIZER_EMPTY(name) \ + { { { &(name).Tail.Node, NULL }, &(name).Head.Node } } + +/** + * @brief Chain initializer for a chain with one @a node. + * + * @see CHAIN_NODE_INITIALIZER_ONE_NODE_CHAIN(). + */ +#define CHAIN_INITIALIZER_ONE_NODE( node ) \ + { { { (node), NULL }, (node) } } + +/** + * @brief Chain node initializer for a @a chain containing exactly this node. + * + * @see CHAIN_INITIALIZER_ONE_NODE(). + */ +#define CHAIN_NODE_INITIALIZER_ONE_NODE_CHAIN( chain ) \ + { &(chain)->Tail.Node, &(chain)->Head.Node } + +/** + * @brief Chain definition for an empty chain with designator @a name. + */ +#define CHAIN_DEFINE_EMPTY(name) \ + Chain_Control name = CHAIN_INITIALIZER_EMPTY(name) + +/** + * @brief Initialize a chain header. + * + * This routine initializes @a the_chain structure to manage the + * contiguous array of @a number_nodes nodes which starts at + * @a starting_address. Each node is of @a node_size bytes. + * + * @param[in] the_chain specifies the chain to initialize + * @param[in] starting_address is the starting address of the array + * of elements + * @param[in] number_nodes is the numebr of nodes that will be in the chain + * @param[in] node_size is the size of each node + */ +void _Chain_Initialize( + Chain_Control *the_chain, + void *starting_address, + size_t number_nodes, + size_t node_size +); + +/** + * @brief Returns the node count of the chain. + * + * @param[in] chain The chain. + * + * @note It does NOT disable interrupts to ensure the atomicity of the + * operation. + * + * @retval The node count of the chain. + */ +size_t _Chain_Node_count_unprotected( const Chain_Control *chain ); + +/** + * @brief Set off chain. + * + * This function sets the next field of the @a node to NULL indicating the @a + * node is not part of a chain. + * + * @param[in] node the node set to off chain. + */ +RTEMS_INLINE_ROUTINE void _Chain_Set_off_chain( + Chain_Node *node +) +{ + node->next = NULL; +#if defined(RTEMS_DEBUG) + node->previous = NULL; +#endif +} + +/** + * @brief Initializes a chain node. + * + * In debug configurations, the node is set off chain. In all other + * configurations, this function does nothing. + * + * @param[in] the_node The chain node to initialize. + */ +RTEMS_INLINE_ROUTINE void _Chain_Initialize_node( Chain_Node *the_node ) +{ +#if defined(RTEMS_DEBUG) + _Chain_Set_off_chain( the_node ); +#else + (void) the_node; +#endif +} + +/** + * @brief Is the node off chain. + * + * This function returns true if the @a node is not on a chain. A @a node is + * off chain if the next field is set to NULL. + * + * @param[in] node is the node off chain. + * + * @retval true The @a node is off chain. + * @retval false The @a node is not off chain. + */ +RTEMS_INLINE_ROUTINE bool _Chain_Is_node_off_chain( + const Chain_Node *node +) +{ + return node->next == NULL; +} + +/** + * @brief Are two nodes equal. + * + * This function returns true if @a left and @a right are equal, + * and false otherwise. + * + * @param[in] left is the node on the left hand side of the comparison. + * @param[in] right is the node on the left hand side of the comparison. + * + * @retval true @a left and @a right are equal. + * @retval false @a left and @a right are not equal. + */ +RTEMS_INLINE_ROUTINE bool _Chain_Are_nodes_equal( + const Chain_Node *left, + const Chain_Node *right +) +{ + return left == right; +} + +/** + * @brief Is the chain node pointer NULL. + * + * This function returns true if the_node is NULL and false otherwise. + * + * @param[in] the_node is the node pointer to check. + * + * @retval true @a the_node is @c NULL. + * @retval false @a the_node is not @c NULL. + */ +RTEMS_INLINE_ROUTINE bool _Chain_Is_null_node( + const Chain_Node *the_node +) +{ + return (the_node == NULL); +} + +/** + * @brief Return pointer to chain head. + * + * This function returns a pointer to the head node on the chain. + * + * @param[in] the_chain is the chain to be operated upon. + * + * @return This method returns the permanent head node of the chain. + */ +RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Head( + Chain_Control *the_chain +) +{ + return &the_chain->Head.Node; +} + +/** + * @brief Return pointer to immutable chain head. + * + * This function returns a pointer to the head node on the chain. + * + * @param[in] the_chain is the chain to be operated upon. + * + * @return This method returns the permanent head node of the chain. + */ +RTEMS_INLINE_ROUTINE const Chain_Node *_Chain_Immutable_head( + const Chain_Control *the_chain +) +{ + return &the_chain->Head.Node; +} + +/** + * @brief Return pointer to chain tail. + * + * This function returns a pointer to the tail node on the chain. + * + * @param[in] the_chain is the chain to be operated upon. + * + * @return This method returns the permanent tail node of the chain. + */ +RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Tail( + Chain_Control *the_chain +) +{ + return &the_chain->Tail.Node; +} + +/** + * @brief Return pointer to immutable chain tail. + * + * This function returns a pointer to the tail node on the chain. + * + * @param[in] the_chain is the chain to be operated upon. + * + * @return This method returns the permanent tail node of the chain. + */ +RTEMS_INLINE_ROUTINE const Chain_Node *_Chain_Immutable_tail( + const Chain_Control *the_chain +) +{ + return &the_chain->Tail.Node; +} + +/** + * @brief Return pointer to chain's first node. + * + * This function returns a pointer to the first node on the chain after the + * head. + * + * @param[in] the_chain is the chain to be operated upon. + * + * @return This method returns the first node of the chain. + */ +RTEMS_INLINE_ROUTINE Chain_Node *_Chain_First( + const Chain_Control *the_chain +) +{ + return _Chain_Immutable_head( the_chain )->next; +} + +/** + * @brief Return pointer to immutable chain's first node. + * + * This function returns a pointer to the first node on the chain after the + * head. + * + * @param[in] the_chain is the chain to be operated upon. + * + * @return This method returns the first node of the chain. + */ +RTEMS_INLINE_ROUTINE const Chain_Node *_Chain_Immutable_first( + const Chain_Control *the_chain +) +{ + return _Chain_Immutable_head( the_chain )->next; +} + +/** + * @brief Return pointer to chain's last node. + * + * This function returns a pointer to the last node on the chain just before + * the tail. + * + * @param[in] the_chain is the chain to be operated upon. + * + * @return This method returns the last node of the chain. + */ +RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Last( + const Chain_Control *the_chain +) +{ + return _Chain_Immutable_tail( the_chain )->previous; +} + +/** + * @brief Return pointer to immutable chain's last node. + * + * This function returns a pointer to the last node on the chain just before + * the tail. + * + * @param[in] the_chain is the chain to be operated upon. + * + * @return This method returns the last node of the chain. + */ +RTEMS_INLINE_ROUTINE const Chain_Node *_Chain_Immutable_last( + const Chain_Control *the_chain +) +{ + return _Chain_Immutable_tail( the_chain )->previous; +} + +/** + * @brief Return pointer the next node from this node. + * + * This function returns a pointer to the next node after this node. + * + * @param[in] the_node is the node to be operated upon. + * + * @return This method returns the next node on the chain. + */ +RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Next( + const Chain_Node *the_node +) +{ + return the_node->next; +} + +/** + * @brief Return pointer the immutable next node from this node. + * + * This function returns a pointer to the next node after this node. + * + * @param[in] the_node is the node to be operated upon. + * + * @return This method returns the next node on the chain. + */ +RTEMS_INLINE_ROUTINE const Chain_Node *_Chain_Immutable_next( + const Chain_Node *the_node +) +{ + return the_node->next; +} + +/** + * @brief Return pointer the previous node from this node. + * + * This function returns a pointer to the previous node on this chain. + * + * @param[in] the_node is the node to be operated upon. + * + * @return This method returns the previous node on the chain. + */ +RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Previous( + const Chain_Node *the_node +) +{ + return the_node->previous; +} + +/** + * @brief Return pointer the immutable previous node from this node. + * + * This function returns a pointer to the previous node on this chain. + * + * @param[in] the_node is the node to be operated upon. + * + * @return This method returns the previous node on the chain. + */ +RTEMS_INLINE_ROUTINE const Chain_Node *_Chain_Immutable_previous( + const Chain_Node *the_node +) +{ + return the_node->previous; +} + +/** + * @brief Is the chain empty. + * + * This function returns true if there a no nodes on @a the_chain and + * false otherwise. + * + * @param[in] the_chain is the chain to be operated upon. + * + * @retval true There are no nodes on @a the_chain. + * @retval false There are nodes on @a the_chain. + */ +RTEMS_INLINE_ROUTINE bool _Chain_Is_empty( + const Chain_Control *the_chain +) +{ + return _Chain_Immutable_first( the_chain ) + == _Chain_Immutable_tail( the_chain ); +} + +/** + * @brief Is this the first node on the chain. + * + * This function returns true if the_node is the first node on a chain and + * false otherwise. + * + * @param[in] the_node is the node the caller wants to know if it is + * the first node on a chain. + * + * @retval true @a the_node is the first node on a chain. + * @retval false @a the_node is not the first node on a chain. + */ +RTEMS_INLINE_ROUTINE bool _Chain_Is_first( + const Chain_Node *the_node +) +{ + return (the_node->previous->previous == NULL); +} + +/** + * @brief Is this the last node on the chain. + * + * This function returns true if @a the_node is the last node on a chain and + * false otherwise. + * + * @param[in] the_node is the node to check as the last node. + * + * @retval true @a the_node is the last node on a chain. + * @retval false @a the_node is not the last node on a chain. + */ +RTEMS_INLINE_ROUTINE bool _Chain_Is_last( + const Chain_Node *the_node +) +{ + return (the_node->next->next == NULL); +} + +/** + * @brief Does this chain have only one node. + * + * This function returns true if there is only one node on @a the_chain and + * false otherwise. + * + * @param[in] the_chain is the chain to be operated upon. + * + * @return This function returns true if there is only one node on + * @a the_chain and false otherwise. + * + * @retval true There is only one node on @a the_chain. + * @retval false There is more than one node on @a the_chain. + */ +RTEMS_INLINE_ROUTINE bool _Chain_Has_only_one_node( + const Chain_Control *the_chain +) +{ + return _Chain_Immutable_first( the_chain ) + == _Chain_Immutable_last( the_chain ); +} + +/** + * @brief Is this node the chain head. + * + * This function returns true if @a the_node is the head of @a the_chain and + * false otherwise. + * + * @param[in] the_chain is the chain to be operated upon. + * @param[in] the_node is the node to check for being the Chain Head. + * + * @retval true @a the_node is the head of @a the_chain. + * @retval false @a the_node is not the head of @a the_chain. + */ +RTEMS_INLINE_ROUTINE bool _Chain_Is_head( + const Chain_Control *the_chain, + const Chain_Node *the_node +) +{ + return (the_node == _Chain_Immutable_head( the_chain )); +} + +/** + * @brief Is this node the chail tail. + * + * This function returns true if @a the_node is the tail of @a the_chain and + * false otherwise. + * + * @param[in] the_chain is the chain to be operated upon. + * @param[in] the_node is the node to check for being the Chain Tail. + * + * @retval true @a the_node is the tail of @a the_chain. + * @retval false @a the_node is not the tail of @a the_chain. + */ +RTEMS_INLINE_ROUTINE bool _Chain_Is_tail( + const Chain_Control *the_chain, + const Chain_Node *the_node +) +{ + return (the_node == _Chain_Immutable_tail( the_chain )); +} + +/** + * @brief Initialize this chain as empty. + * + * This routine initializes the specified chain to contain zero nodes. + * + * @param[in] the_chain is the chain to be initialized. + */ +RTEMS_INLINE_ROUTINE void _Chain_Initialize_empty( + Chain_Control *the_chain +) +{ + Chain_Node *head; + Chain_Node *tail; + + _Assert( the_chain != NULL ); + + head = _Chain_Head( the_chain ); + tail = _Chain_Tail( the_chain ); + + head->next = tail; + head->previous = NULL; + tail->previous = head; +} + +/** + * @brief Initializes this chain to contain exactly the specified node. + * + * @param[in] the_chain The chain control. + * @param[in] the_node The one and only node. + */ +RTEMS_INLINE_ROUTINE void _Chain_Initialize_one( + Chain_Control *the_chain, + Chain_Node *the_node +) +{ + Chain_Node *head; + Chain_Node *tail; + + _Assert( _Chain_Is_node_off_chain( the_node ) ); + + head = _Chain_Head( the_chain ); + tail = _Chain_Tail( the_chain ); + + the_node->next = tail; + the_node->previous = head; + + head->next = the_node; + head->previous = NULL; + tail->previous = the_node; +} + +/** + * @brief Extract this node (unprotected). + * + * This routine extracts the_node from the chain on which it resides. + * It does NOT disable interrupts to ensure the atomicity of the + * extract operation. + * + * @param[in] the_node is the node to be extracted. + */ +RTEMS_INLINE_ROUTINE void _Chain_Extract_unprotected( + Chain_Node *the_node +) +{ + Chain_Node *next; + Chain_Node *previous; + + next = the_node->next; + previous = the_node->previous; + next->previous = previous; + previous->next = next; + +#if defined(RTEMS_DEBUG) + _Chain_Set_off_chain( the_node ); +#endif +} + +/** + * @brief Get the first node (unprotected). + * + * This function removes the first node from the_chain and returns + * a pointer to that node. It does NOT disable interrupts to ensure + * the atomicity of the get operation. + * + * @param[in] the_chain is the chain to attempt to get the first node from. + * + * @return This method returns the first node on the chain even if it is + * the Chain Tail. + * + * @note This routine assumes that there is at least one node on the chain + * and always returns a node even if it is the Chain Tail. + */ +RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Get_first_unprotected( + Chain_Control *the_chain +) +{ + Chain_Node *head; + Chain_Node *old_first; + Chain_Node *new_first; + + _Assert( !_Chain_Is_empty( the_chain ) ); + + head = _Chain_Head( the_chain ); + old_first = head->next; + new_first = old_first->next; + + head->next = new_first; + new_first->previous = head; + +#if defined(RTEMS_DEBUG) + _Chain_Set_off_chain( old_first ); +#endif + + return old_first; +} + +/** + * @brief Get the first node (unprotected). + * + * This function removes the first node from the_chain and returns + * a pointer to that node. If the_chain is empty, then NULL is returned. + * + * @param[in] the_chain is the chain to attempt to get the first node from. + * + * @return This method returns the first node on the chain or NULL if the + * chain is empty. + * + * @note It does NOT disable interrupts to ensure the atomicity of the + * get operation. + */ +RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Get_unprotected( + Chain_Control *the_chain +) +{ + if ( !_Chain_Is_empty(the_chain)) + return _Chain_Get_first_unprotected(the_chain); + else + return NULL; +} + +/** + * @brief Insert a node (unprotected). + * + * This routine inserts the_node on a chain immediately following + * after_node. + * + * @param[in] after_node is the node which will precede @a the_node on the + * chain. + * @param[in] the_node is the node to be inserted. + * + * @note It does NOT disable interrupts to ensure the atomicity + * of the extract operation. + */ +RTEMS_INLINE_ROUTINE void _Chain_Insert_unprotected( + Chain_Node *after_node, + Chain_Node *the_node +) +{ + Chain_Node *before_node; + + _Assert( _Chain_Is_node_off_chain( the_node ) ); + + the_node->previous = after_node; + before_node = after_node->next; + after_node->next = the_node; + the_node->next = before_node; + before_node->previous = the_node; +} + +/** + * @brief Append a node (unprotected). + * + * This routine appends the_node onto the end of the_chain. + * + * @param[in] the_chain is the chain to be operated upon. + * @param[in] the_node is the node to be appended. + * + * @note It does NOT disable interrupts to ensure the atomicity of the + * append operation. + */ +RTEMS_INLINE_ROUTINE void _Chain_Append_unprotected( + Chain_Control *the_chain, + Chain_Node *the_node +) +{ + Chain_Node *tail; + Chain_Node *old_last; + + _Assert( _Chain_Is_node_off_chain( the_node ) ); + + tail = _Chain_Tail( the_chain ); + old_last = tail->previous; + + the_node->next = tail; + tail->previous = the_node; + old_last->next = the_node; + the_node->previous = old_last; +} + +/** + * @brief Append a node on the end of a chain if the node is in the off chain + * state (unprotected). + * + * @note It does NOT disable interrupts to ensure the atomicity of the + * append operation. + * + * @see _Chain_Append_unprotected() and _Chain_Is_node_off_chain(). + */ +RTEMS_INLINE_ROUTINE void _Chain_Append_if_is_off_chain_unprotected( + Chain_Control *the_chain, + Chain_Node *the_node +) +{ + if ( _Chain_Is_node_off_chain( the_node ) ) { + _Chain_Append_unprotected( the_chain, the_node ); + } +} + +/** + * @brief Prepend a node (unprotected). + * + * This routine prepends the_node onto the front of the_chain. + * + * @param[in] the_chain is the chain to be operated upon. + * @param[in] the_node is the node to be prepended. + * + * @note It does NOT disable interrupts to ensure the atomicity of the + * prepend operation. + */ +RTEMS_INLINE_ROUTINE void _Chain_Prepend_unprotected( + Chain_Control *the_chain, + Chain_Node *the_node +) +{ + _Chain_Insert_unprotected(_Chain_Head(the_chain), the_node); +} + +/** + * @brief Append a node and check if the chain was empty before (unprotected). + * + * This routine appends the_node onto the end of the_chain. + * + * @param[in] the_chain is the chain to be operated upon. + * @param[in] the_node is the node to be appended. + * + * @note It does NOT disable interrupts to ensure the atomicity of the + * append operation. + * + * @retval true The chain was empty before. + * @retval false The chain contained at least one node before. + */ +RTEMS_INLINE_ROUTINE bool _Chain_Append_with_empty_check_unprotected( + Chain_Control *the_chain, + Chain_Node *the_node +) +{ + bool was_empty = _Chain_Is_empty( the_chain ); + + _Chain_Append_unprotected( the_chain, the_node ); + + return was_empty; +} + +/** + * @brief Prepend a node and check if the chain was empty before (unprotected). + * + * This routine prepends the_node onto the front of the_chain. + * + * @param[in] the_chain is the chain to be operated upon. + * @param[in] the_node is the node to be prepended. + * + * @note It does NOT disable interrupts to ensure the atomicity of the + * prepend operation. + * + * @retval true The chain was empty before. + * @retval false The chain contained at least one node before. + */ +RTEMS_INLINE_ROUTINE bool _Chain_Prepend_with_empty_check_unprotected( + Chain_Control *the_chain, + Chain_Node *the_node +) +{ + bool was_empty = _Chain_Is_empty( the_chain ); + + _Chain_Prepend_unprotected( the_chain, the_node ); + + return was_empty; +} + +/** + * @brief Get the first node and check if the chain is empty afterwards + * (unprotected). + * + * This function removes the first node from the_chain and returns + * a pointer to that node in @a the_node. If the_chain is empty, then NULL is + * returned. + * + * @param[in] the_chain is the chain to attempt to get the first node from. + * @param[out] the_node is the first node on the chain or NULL if the chain is + * empty. + * + * @note It does NOT disable interrupts to ensure the atomicity of the + * get operation. + * + * @retval true The chain is empty now. + * @retval false The chain contains at least one node now. + */ +RTEMS_INLINE_ROUTINE bool _Chain_Get_with_empty_check_unprotected( + Chain_Control *the_chain, + Chain_Node **the_node +) +{ + bool is_empty_now = true; + Chain_Node *head = _Chain_Head( the_chain ); + Chain_Node *tail = _Chain_Tail( the_chain ); + Chain_Node *old_first = head->next; + + if ( old_first != tail ) { + Chain_Node *new_first = old_first->next; + + head->next = new_first; + new_first->previous = head; + + *the_node = old_first; + + is_empty_now = new_first == tail; + } else + *the_node = NULL; + + return is_empty_now; +} + +/** + * @brief Chain node order. + * + * @param[in] left The left hand side. + * @param[in] right The right hand side. + * + * @retval true According to the order the left node precedes the right node. + * @retval false Otherwise. + */ +typedef bool ( *Chain_Node_order )( + const void *left, + const Chain_Node *right +); + +/** + * @brief Inserts a node into the chain according to the order relation. + * + * After the operation the chain contains the node to insert and the order + * relation holds for all nodes from the head up to the inserted node. Nodes + * after the inserted node are not moved. + * + * @param[in] the_chain The chain. + * @param[in] to_insert The node to insert. + * @param[in] left The left hand side passed to the order relation. It must + * correspond to the node to insert. The separate left hand side parameter + * may help the compiler to generate better code if it is stored in a local + * variable. + * @param[in] order The order relation. + */ +RTEMS_INLINE_ROUTINE void _Chain_Insert_ordered_unprotected( + Chain_Control *the_chain, + Chain_Node *to_insert, + const void *left, + Chain_Node_order order +) +{ + const Chain_Node *tail = _Chain_Immutable_tail( the_chain ); + Chain_Node *next = _Chain_First( the_chain ); + + while ( next != tail && !( *order )( left, next ) ) { + next = _Chain_Next( next ); + } + + _Chain_Insert_unprotected( _Chain_Previous( next ), to_insert ); +} + +/** + * @brief The chain iterator direction. + */ +typedef enum { + /** + * @brief Iteration from head to tail. + */ + CHAIN_ITERATOR_FORWARD, + + /** + * @brief Iteration from tail to head. + */ + CHAIN_ITERATOR_BACKWARD +} Chain_Iterator_direction; + +/** + * @brief A chain iterator which is updated during node extraction if it is + * properly registered. + * + * @see _Chain_Iterator_initialize(). + */ +typedef struct { + /** + * @brief Node for registration. + * + * Used during _Chain_Iterator_initialize() and _Chain_Iterator_destroy(). + */ + Chain_Node Registry_node; + + /** + * @brief The direction of this iterator. + * + * Immutable after initialization via _Chain_Iterator_initialize(). + */ + Chain_Iterator_direction direction; + + /** + * @brief The current position of this iterator. + * + * The position is initialized via _Chain_Iterator_initialize(). It must be + * explicitly set after one valid iteration step, e.g. in case a next node in + * the iterator direction existed. It is updated through the registration in + * case a node is extracted via _Chain_Iterator_registry_update(). + */ + Chain_Node *position; +} Chain_Iterator; + +/** + * @brief A registry for chain iterators. + * + * Should be attached to a chain control to enable safe iteration through a + * chain in case of concurrent node extractions. + */ +typedef struct { + Chain_Control Iterators; +} Chain_Iterator_registry; + +/** + * @brief Chain iterator registry initializer for static initialization. + * + * @param name The designator of the chain iterator registry. + */ +#define CHAIN_ITERATOR_REGISTRY_INITIALIZER( name ) \ + { CHAIN_INITIALIZER_EMPTY( name.Iterators ) } + +/** + * @brief Initializes a chain iterator registry. + */ +RTEMS_INLINE_ROUTINE void _Chain_Iterator_registry_initialize( + Chain_Iterator_registry *the_registry +) +{ + _Chain_Initialize_empty( &the_registry->Iterators ); +} + +/** + * @brief Updates all iterators present in the chain iterator registry in case + * of a node extraction. + * + * Must be called before _Chain_Extract_unprotected(). + * + * @warning This function will look at all registered chain iterators to + * determine if an update is necessary. + */ +RTEMS_INLINE_ROUTINE void _Chain_Iterator_registry_update( + Chain_Iterator_registry *the_registry, + Chain_Node *the_node_to_extract +) +{ + Chain_Node *iter_node; + Chain_Node *iter_tail; + + iter_node = _Chain_Head( &the_registry->Iterators ); + iter_tail = _Chain_Tail( &the_registry->Iterators ); + + while ( ( iter_node = _Chain_Next( iter_node ) ) != iter_tail ) { + Chain_Iterator *iter; + + iter = (Chain_Iterator *) iter_node; + + if ( iter->position == the_node_to_extract ) { + if ( iter->direction == CHAIN_ITERATOR_FORWARD ) { + iter->position = _Chain_Previous( the_node_to_extract ); + } else { + iter->position = _Chain_Next( the_node_to_extract ); + } + } + } +} + +/** + * @brief Initializes the chain iterator. + * + * In the following example nodes inserted during the iteration are visited in + * case they are inserted after the current position in iteration order. + * + * @code + * #include + * #include + * + * typedef struct { + * Chain_Control Chain; + * Chain_Iterator_registry Iterators; + * ISR_LOCK_MEMBER( Lock ) + * } Some_Control; + * + * void iterate( + * Some_Control *the_some, + * void ( *visitor )( Chain_Node * ) + * ) + * { + * ISR_lock_Context lock_context; + * Chain_Iterator iter; + * Chain_Node *node; + * const Chain_Node *end; + * + * end = _Chain_Immutable_tail( &the_some->Chain ); + * + * _ISR_lock_ISR_disable_and_acquire( &the_some->Lock, &lock_context ); + * + * _Chain_Iterator_initialize( + * &the_some->Chain, + * &the_some->Iterators, + * &iter, + * CHAIN_ITERATOR_FORWARD + * ); + * + * while ( ( node = _Chain_Iterator_next( &iter ) ) != end ) { + * _Chain_Iterator_set_position( &iter, node ); + * _ISR_lock_Release_and_ISR_enable( &the_some->Lock, &lock_context ); + * ( *visitor )( node ); + * _ISR_lock_ISR_disable_and_acquire( &the_some->Lock, &lock_context ); + * } + * + * _Chain_Iterator_destroy( &iter ); + * _ISR_lock_Release_and_ISR_enable( &the_some->Lock, &lock_context ); + * } + * @endcode + * + * @param the_chain The chain to iterate. + * @param the_registry The registry for the chain iterator. + * @param the_iterator The chain iterator to initialize. + * @param direction The iteration direction. + * + * @see _Chain_Iterator_next(), _Chain_Iterator_set_position() and + * Chain_Iterator_destroy(). + * + * @warning Think twice before you use a chain iterator. Its current + * implementation is unfit for use in performance relevant components, due to + * the linear time complexity in _Chain_Iterator_registry_update(). + */ +RTEMS_INLINE_ROUTINE void _Chain_Iterator_initialize( + Chain_Control *the_chain, + Chain_Iterator_registry *the_registry, + Chain_Iterator *the_iterator, + Chain_Iterator_direction direction +) +{ + _Chain_Initialize_node( &the_iterator->Registry_node ); + _Chain_Append_unprotected( + &the_registry->Iterators, + &the_iterator->Registry_node + ); + + the_iterator->direction = direction; + + if ( direction == CHAIN_ITERATOR_FORWARD ) { + the_iterator->position = _Chain_Head( the_chain ); + } else { + the_iterator->position = _Chain_Tail( the_chain ); + } +} + +/** + * @brief Returns the next node in the iterator direction. + * + * In case a next node exists, then the iterator should be updated via + * _Chain_Iterator_set_position() to continue with the next iteration step. + * + * @param the_iterator The chain iterator. + */ +RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Iterator_next( + const Chain_Iterator *the_iterator +) +{ + if ( the_iterator->direction == CHAIN_ITERATOR_FORWARD ) { + return _Chain_Next( the_iterator->position ); + } else { + return _Chain_Previous( the_iterator->position ); + } +} + +/** + * @brief Sets the iterator position. + * + * @param the_iterator The chain iterator. + * @param the_node The new iterator position. + */ +RTEMS_INLINE_ROUTINE void _Chain_Iterator_set_position( + Chain_Iterator *the_iterator, + Chain_Node *the_node +) +{ + the_iterator->position = the_node; +} + +/** + * @brief Destroys the iterator. + * + * Removes the iterator from its registry. + * + * @param the_iterator The chain iterator. + */ +RTEMS_INLINE_ROUTINE void _Chain_Iterator_destroy( + Chain_Iterator *the_iterator +) +{ + _Chain_Extract_unprotected( &the_iterator->Registry_node ); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/context.h b/cpukit/include/rtems/score/context.h new file mode 100644 index 0000000000..990a602396 --- /dev/null +++ b/cpukit/include/rtems/score/context.h @@ -0,0 +1,163 @@ +/** + * @file rtems/score/context.h + * + * @brief Information About Each Thread's Context + * + * This include file contains all information about each thread's context. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CONTEXT_H +#define _RTEMS_SCORE_CONTEXT_H + +/** + * @defgroup ScoreContext Context Handler + * + * @ingroup Score + * + * This handler encapsulates functionality which abstracts thread context + * management in a portable manner. + * + * The context switch needed variable is contained in the per cpu + * data structure. + */ +/**@{*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/** + * @brief Size of floating point context area. + * + * This constant defines the number of bytes required + * to store a full floating point context. + */ +#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) + #define CONTEXT_FP_SIZE CPU_CONTEXT_FP_SIZE +#else + #define CONTEXT_FP_SIZE 0 +#endif + +/** + * @brief Initialize context area. + * + * This routine initializes @a _the_context such that the stack + * pointer, interrupt level, and entry point are correct for the + * thread's initial state. + * + * @param[in] _the_context will be initialized + * @param[in] _stack is the lowest physical address of the thread's + * context + * @param[in] _size is the size in octets of the thread's context + * @param[in] _isr is the ISR enable level for this thread + * @param[in] _entry is this thread's entry point + * @param[in] _is_fp is set to true if this thread has floating point + * enabled + * @param[in] _tls_area The thread-local storage (TLS) area begin. + */ +#define _Context_Initialize( _the_context, _stack, _size, _isr, _entry, \ + _is_fp, _tls_area ) \ + _CPU_Context_Initialize( _the_context, _stack, _size, _isr, _entry, \ + _is_fp, _tls_area ) + +/** + * This macro is invoked from _Thread_Handler to do whatever CPU + * specific magic is required that must be done in the context of + * the thread when it starts. + * + * If the CPU architecture does not require any magic, then this + * macro is empty. + */ + +#if defined(_CPU_Context_Initialization_at_thread_begin) + #define _Context_Initialization_at_thread_begin() \ + _CPU_Context_Initialization_at_thread_begin() +#else + #define _Context_Initialization_at_thread_begin() +#endif + +/** + * @brief Perform context switch. + * + * This routine saves the current context into the @a _executing + * context record and restores the context specified by @a _heir. + * + * @param[in] _executing is the currently executing thread's context + * @param[in] _heir is the context of the thread to be switched to + */ +#define _Context_Switch( _executing, _heir ) \ + _CPU_Context_switch( _executing, _heir ) + +/** + * @brief Restart currently executing thread. + * + * This routine restarts the calling thread by restoring its initial + * stack pointer and returning to the thread's entry point. + * + * @param[in] _the_context is the context of the thread to restart + */ +#define _Context_Restart_self( _the_context ) \ + _CPU_Context_Restart_self( _the_context ) + +/** + * @brief Initialize floating point context area. + * + * This routine initializes the floating point context save + * area to contain an initial known state. + * + * @param[in] _fp_area is the base address of the floating point + * context save area to initialize. + */ +#define _Context_Initialize_fp( _fp_area ) \ + _CPU_Context_Initialize_fp( _fp_area ) + +/** + * @brief Restore floating point context area. + * + * This routine restores the floating point context contained + * in the @a _fp area. It is assumed that the current + * floating point context has been saved by a previous invocation + * of @a _Context_Save_fp. + * + * @param[in] _fp points to the floating point context area to restore. + */ +#define _Context_Restore_fp( _fp ) \ + _CPU_Context_restore_fp( _fp ) + +/** + * @brief Save floating point context area. + * + * This routine saves the current floating point context + * in the @a _fp area. + * + * @param[in] _fp points to the floating point context area to restore. + */ +#define _Context_Save_fp( _fp ) \ + _CPU_Context_save_fp( _fp ) + +#if defined(_CPU_Context_Destroy) + #define _Context_Destroy( _the_thread, _the_context ) \ + _CPU_Context_Destroy( _the_thread, _the_context ) +#else + #define _Context_Destroy( _the_thread, _the_context ) +#endif + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/copyrt.h b/cpukit/include/rtems/score/copyrt.h new file mode 100644 index 0000000000..17c925a008 --- /dev/null +++ b/cpukit/include/rtems/score/copyrt.h @@ -0,0 +1,44 @@ +/** + * @file rtems/score/copyrt.h + * + * @brief Copyright Notice for RTEMS + * + * This include file contains the copyright notice for RTEMS + * which is included in every binary copy of the executive. + */ + +/* + * COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_COPYRT_H +#define _RTEMS_SCORE_COPYRT_H + +/** + * @defgroup SuperCoreCopyright RTEMS Copyright Notice + * + * @ingroup Score + */ +/**@{*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * This is the copyright string for RTEMS. + */ +extern const char _Copyright_Notice[]; + +#ifdef __cplusplus +} +#endif + +/**@}*/ +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/corebarrier.h b/cpukit/include/rtems/score/corebarrier.h new file mode 100644 index 0000000000..ba706be3e3 --- /dev/null +++ b/cpukit/include/rtems/score/corebarrier.h @@ -0,0 +1,91 @@ +/** + * @file rtems/score/corebarrier.h + * + * @brief Constants and Structures Associated with the Barrier Handler + * + * This include file contains all the constants and structures associated + * with the Barrier Handler. + */ + +/* + * COPYRIGHT (c) 1989-2007. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_COREBARRIER_H +#define _RTEMS_SCORE_COREBARRIER_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ScoreBarrier Barrier Handler + * + * @ingroup Score + * + * This handler encapsulates functionality which provides the foundation + * Barrier services used in all of the APIs supported by RTEMS. + */ +/**@{*/ + +/** + * Flavors of barriers. + */ +typedef enum { + /** This specifies that the barrier will automatically release when + * the user specified number of threads have arrived at the barrier. + */ + CORE_BARRIER_AUTOMATIC_RELEASE, + /** This specifies that the user will have to manually release the barrier + * in order to release the waiting threads. + */ + CORE_BARRIER_MANUAL_RELEASE +} CORE_barrier_Disciplines; + +/** + * The following defines the control block used to manage the + * attributes of each barrier. + */ +typedef struct { + /** This field indicates whether the barrier is automatic or manual. + */ + CORE_barrier_Disciplines discipline; + /** This element indicates the number of threads which must arrive at the + * barrier to trip the automatic release. + */ + uint32_t maximum_count; +} CORE_barrier_Attributes; + +/** + * The following defines the control block used to manage each + * barrier. + */ +typedef struct { + /** This field is the Waiting Queue used to manage the set of tasks + * which are blocked waiting for the barrier to be released. + */ + Thread_queue_Control Wait_queue; + /** This element is the set of attributes which define this instance's + * behavior. + */ + CORE_barrier_Attributes Attributes; + /** This element contains the current number of thread waiting for this + * barrier to be released. */ + uint32_t number_of_waiting_threads; +} CORE_barrier_Control; + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/corebarrierimpl.h b/cpukit/include/rtems/score/corebarrierimpl.h new file mode 100644 index 0000000000..d5d63659d0 --- /dev/null +++ b/cpukit/include/rtems/score/corebarrierimpl.h @@ -0,0 +1,173 @@ +/** + * @file + * + * @brief Inlined Routines Associated with the SuperCore Barrier + * + * This include file contains all of the inlined routines associated + * with the SuperCore barrier. + */ + +/* + * COPYRIGHT (c) 1989-2006. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_COREBARRIERIMPL_H +#define _RTEMS_SCORE_COREBARRIERIMPL_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup ScoreBarrier + */ +/**@{**/ + +#define CORE_BARRIER_TQ_OPERATIONS &_Thread_queue_Operations_FIFO + +/** + * @brief Initialize core barrier. + * + * This routine initializes the barrier based on the parameters passed. + * + * @param[in] the_barrier is the barrier to initialize + * @param[in] the_barrier_attributes define the behavior of this instance + */ +void _CORE_barrier_Initialize( + CORE_barrier_Control *the_barrier, + CORE_barrier_Attributes *the_barrier_attributes +); + +RTEMS_INLINE_ROUTINE void _CORE_barrier_Destroy( + CORE_barrier_Control *the_barrier +) +{ + _Thread_queue_Destroy( &the_barrier->Wait_queue ); +} + +RTEMS_INLINE_ROUTINE void _CORE_barrier_Acquire_critical( + CORE_barrier_Control *the_barrier, + Thread_queue_Context *queue_context +) +{ + _Thread_queue_Acquire_critical( &the_barrier->Wait_queue, queue_context ); +} + +RTEMS_INLINE_ROUTINE void _CORE_barrier_Release( + CORE_barrier_Control *the_barrier, + Thread_queue_Context *queue_context +) +{ + _Thread_queue_Release( &the_barrier->Wait_queue, queue_context ); +} + +/** + * @brief Wait for the barrier. + * + * This routine wait for the barrier to be released. If the barrier + * is set to automatic and this is the appropriate thread, then it returns + * immediately. Otherwise, the calling thread is blocked until the barrier + * is released. + * + * @param[in] the_barrier is the barrier to wait for + * @param[in,out] executing The currently executing thread. + * @param[in] wait is true if the calling thread is willing to wait + * + * @return The method status. + */ +Status_Control _CORE_barrier_Seize( + CORE_barrier_Control *the_barrier, + Thread_Control *executing, + bool wait, + Thread_queue_Context *queue_context +); + +uint32_t _CORE_barrier_Do_flush( + CORE_barrier_Control *the_barrier, + Thread_queue_Flush_filter filter, + Thread_queue_Context *queue_context +); + +/** + * @brief Manually release the barrier. + * + * This routine manually releases the barrier. All of the threads waiting + * for the barrier will be readied. + * + * @param[in] the_barrier is the barrier to surrender + * @param[in] mp_callout is the routine to invoke if the + * thread unblocked is remote + * + * @retval the number of unblocked threads + */ +RTEMS_INLINE_ROUTINE uint32_t _CORE_barrier_Surrender( + CORE_barrier_Control *the_barrier, + Thread_queue_Context *queue_context +) +{ + return _CORE_barrier_Do_flush( + the_barrier, + _Thread_queue_Flush_default_filter, + queue_context + ); +} + +RTEMS_INLINE_ROUTINE void _CORE_barrier_Flush( + CORE_barrier_Control *the_barrier, + Thread_queue_Context *queue_context +) +{ + _CORE_barrier_Do_flush( + the_barrier, + _Thread_queue_Flush_status_object_was_deleted, + queue_context + ); +} + +/** + * This function returns true if the automatic release attribute is + * enabled in the @a attribute_set and false otherwise. + * + * @param[in] the_attribute is the attribute set to test + * + * @return true if the priority attribute is enabled + */ +RTEMS_INLINE_ROUTINE bool _CORE_barrier_Is_automatic( + CORE_barrier_Attributes *the_attribute +) +{ + return + (the_attribute->discipline == CORE_BARRIER_AUTOMATIC_RELEASE); +} + +/** + * This routine returns the number of threads currently waiting at the barrier. + * + * @param[in] the_barrier is the barrier to obtain the number of blocked + * threads for + * @return the current count of this barrier + */ +RTEMS_INLINE_ROUTINE uint32_t _CORE_barrier_Get_number_of_waiting_threads( + CORE_barrier_Control *the_barrier +) +{ + return the_barrier->number_of_waiting_threads; +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/coremsg.h b/cpukit/include/rtems/score/coremsg.h new file mode 100644 index 0000000000..8d25529fdc --- /dev/null +++ b/cpukit/include/rtems/score/coremsg.h @@ -0,0 +1,185 @@ +/** + * @file rtems/score/coremsg.h + * + * @brief Constants and Structures Associated with the Message Queue Handler. + * + * This include file contains all the constants and structures associated + * with the Message queue Handler. + */ + +/* + * COPYRIGHT (c) 1989-2009. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_COREMSG_H +#define _RTEMS_SCORE_COREMSG_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ScoreMessageQueue Message Queue Handler + * + * @ingroup Score + * + * This handler encapsulates functionality which provides the foundation + * Message Queue services used in all of the APIs supported by RTEMS. + */ +/**@{*/ + +#if defined(RTEMS_POSIX_API) + /** + * This macro is defined when an API is enabled that requires that the + * Message Queue Handler include support for priority based enqueuing + * of messages. + */ + #define RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY +#endif + +#if defined(RTEMS_POSIX_API) + /** + * This macro is defined when an API is enabled that requires that the + * Message Queue Handler include support for notification of enqueuing + * a message. + */ + #define RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION +#endif + +#if defined(RTEMS_POSIX_API) + /** + * This macro is defined when an API is enabled that requires the + * Message Queue Handler include support for blocking send operations. + */ + #define RTEMS_SCORE_COREMSG_ENABLE_BLOCKING_SEND +#endif + +typedef struct CORE_message_queue_Control CORE_message_queue_Control; + +/** + * @brief Data types needed to manipulate the contents of message buffers. + * + * The following defines the data types needed to manipulate + * the contents of message buffers. + * + * @note The buffer field is normally longer than a single uint32_t + * but since messages are variable length we just make a ptr to 1. + */ +typedef struct { + /** This field is the size of this message. */ + size_t size; + /** This field contains the actual message. */ + uint32_t buffer[1]; +} CORE_message_queue_Buffer; + +/** + * @brief The organization of a message buffer. + * + * The following records define the organization of a message + * buffer. + */ +typedef struct { + /** This element allows this structure to be placed on chains. */ + Chain_Node Node; + #if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY) + /** This field is the priority of this message. */ + int priority; + #endif + /** This field points to the contents of the message. */ + CORE_message_queue_Buffer Contents; +} CORE_message_queue_Buffer_control; + +/** + * @brief The possible blocking disciplines for a message queue. + * + * This enumerated types defines the possible blocking disciplines + * for a message queue. + */ +typedef enum { + /** This value indicates that blocking tasks are in FIFO order. */ + CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO, + /** This value indicates that blocking tasks are in priority order. */ + CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY +} CORE_message_queue_Disciplines; + +#if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION) + /** + * @brief Type for a notification handler. + * + * The following defines the type for a Notification handler. A + * notification handler is invoked when the message queue makes a + * 0->1 transition on pending messages. + */ + typedef void (*CORE_message_queue_Notify_Handler)( + CORE_message_queue_Control *, + Thread_queue_Context * + ); +#endif + +/** + * @brief Control block used to manage each message queue. + * + * The following defines the control block used to manage each + * Message Queue. + */ +struct CORE_message_queue_Control { + /** This field is the Waiting Queue used to manage the set of tasks + * which are blocked waiting to receive a message from this queue. + */ + Thread_queue_Control Wait_queue; + + /** + * @brief The thread queue operations according to the blocking discipline. + */ + const Thread_queue_Operations *operations; + + /** This element is maximum number of messages which may be pending + * at any given time. + */ + uint32_t maximum_pending_messages; + /** This element is the number of messages which are currently pending. + */ + uint32_t number_of_pending_messages; + /** This is the size in bytes of the largest message which may be + * sent via this queue. + */ + size_t maximum_message_size; + /** This chain is the set of pending messages. It may be ordered by + * message priority or in FIFO order. + */ + Chain_Control Pending_messages; + /** This is the address of the memory allocated for message buffers. + * It is allocated are part of message queue initialization and freed + * as part of destroying it. + */ + CORE_message_queue_Buffer *message_buffers; + #if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION) + /** This is the routine invoked when the message queue transitions + * from zero (0) messages pending to one (1) message pending. + */ + CORE_message_queue_Notify_Handler notify_handler; + #endif + /** This chain is the set of inactive messages. A message is inactive + * when it does not contain a pending message. + */ + Chain_Control Inactive_messages; +}; + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/coremsgimpl.h b/cpukit/include/rtems/score/coremsgimpl.h new file mode 100644 index 0000000000..e33e3308b2 --- /dev/null +++ b/cpukit/include/rtems/score/coremsgimpl.h @@ -0,0 +1,494 @@ +/** + * @file + * + * @brief Inlined Routines in the Core Message Handler + * + * This include file contains the static inline implementation of all + * inlined routines in the Core Message Handler. + */ + +/* + * COPYRIGHT (c) 1989-2009. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_COREMSGIMPL_H +#define _RTEMS_SCORE_COREMSGIMPL_H + +#include +#include +#include +#include +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup ScoreMessageQueue + */ +/**@{**/ + +/** + * @brief Used when appending messages onto a message queue. + * + * This is the priority constant used when appending messages onto + * a message queue. + */ +#define CORE_MESSAGE_QUEUE_SEND_REQUEST INT_MAX + +/** + * @brief Used when prepending messages onto a message queue. + * + * This is the priority constant used when prepending messages onto + * a message queue. + */ +#define CORE_MESSAGE_QUEUE_URGENT_REQUEST INT_MIN + +/** + * @brief The modes in which a message may be submitted to a message queue. + * + * The following type details the modes in which a message + * may be submitted to a message queue. The message may be posted + * in a send or urgent fashion. + * + * @note All other values are message priorities. Numerically smaller + * priorities indicate higher priority messages. + */ +typedef int CORE_message_queue_Submit_types; + +/** + * @brief Initialize a message queue. + * + * This package is the implementation of the CORE Message Queue Handler. + * This core object provides task synchronization and communication functions + * via messages passed to queue objects. + * + * This routine initializes @a the_message_queue + * based on the parameters passed. + * + * @param[in] the_message_queue points to the message queue to initialize + * @param[in] discipline the blocking discipline + * @param[in] maximum_pending_messages is the maximum number of messages + * that will be allowed to pend at any given time + * @param[in] maximum_message_size is the size of largest message that + * may be sent to this message queue instance + * + * @retval true if the message queue can be initialized. In general, + * false will only be returned if memory for the pending + * messages cannot be allocated. + */ +bool _CORE_message_queue_Initialize( + CORE_message_queue_Control *the_message_queue, + CORE_message_queue_Disciplines discipline, + uint32_t maximum_pending_messages, + size_t maximum_message_size +); + +/** + * @brief Close a message queue. + * + * This package is the implementation of the CORE Message Queue Handler. + * This core object provides task synchronization and communication functions + * via messages passed to queue objects + * + * This function closes a message by returning all allocated space and + * flushing @a the_message_queue's task wait queue. + * + * @param[in] the_message_queue points to the message queue to close + * @param[in] queue_context The thread queue context used for + * _CORE_message_queue_Acquire() or _CORE_message_queue_Acquire_critical(). + */ +void _CORE_message_queue_Close( + CORE_message_queue_Control *the_message_queue, + Thread_queue_Context *queue_context +); + +/** + * @brief Flush pending messages. + * + * This package is the implementation of the CORE Message Queue Handler. + * This core object provides task synchronization and communication functions + * via messages passed to queue objects. + * + * This function flushes @a the_message_queue's pending message queue. The + * number of messages flushed from the queue is returned. + * + * @param[in] the_message_queue points to the message queue to flush + * @param[in] queue_context The thread queue context with interrupts disabled. + * + * @retval This method returns the number of message pending messages flushed. + */ +uint32_t _CORE_message_queue_Flush( + CORE_message_queue_Control *the_message_queue, + Thread_queue_Context *queue_context +); + +#if defined(FUNCTIONALITY_NOT_CURRENTLY_USED_BY_ANY_API) +/** + * @brief Flush waiting threads. + * + * This function flushes the threads which are blocked on + * @a the_message_queue's pending message queue. They are + * unblocked whether blocked sending or receiving. It returns + * the number of messages flushed from the queue. + * + * @param[in] the_message_queue points to the message queue to flush + * @retval number of messages flushed from the queue + */ + void _CORE_message_queue_Flush_waiting_threads( + CORE_message_queue_Control *the_message_queue + ); +#endif + +/** + * @brief Broadcast a message to the message queue. + * + * This package is the implementation of the CORE Message Queue Handler. + * This core object provides task synchronization and communication functions + * via messages passed to queue objects. + * + * This function sends a message for every thread waiting on the queue and + * returns the number of threads made ready by the message. + * + * @param[in] the_message_queue points to the message queue + * @param[in] buffer is the starting address of the message to broadcast + * @param[in] size is the size of the message being broadcast + * @param[out] count points to the variable that will contain the + * number of tasks that are sent this message + * @param[in] queue_context The thread queue context used for + * _CORE_message_queue_Acquire() or _CORE_message_queue_Acquire_critical(). + * @retval @a *count will contain the number of messages sent + * @retval indication of the successful completion or reason for failure + */ +Status_Control _CORE_message_queue_Broadcast( + CORE_message_queue_Control *the_message_queue, + const void *buffer, + size_t size, + uint32_t *count, + Thread_queue_Context *queue_context +); + +/** + * @brief Submit a message to the message queue. + * + * This routine implements the send and urgent message functions. It + * processes a message that is to be submitted to the designated + * message queue. The message will either be processed as a + * send message which it will be inserted at the rear of the queue + * or it will be processed as an urgent message which will be inserted + * at the front of the queue. + * + * @param[in] the_message_queue points to the message queue + * @param[in] buffer is the starting address of the message to send + * @param[in] size is the size of the message being send + * @param[in] submit_type determines whether the message is prepended, + * appended, or enqueued in priority order. + * @param[in] wait indicates whether the calling thread is willing to block + * if the message queue is full. + * @param[in] queue_context The thread queue context used for + * _CORE_message_queue_Acquire() or _CORE_message_queue_Acquire_critical(). + * @retval indication of the successful completion or reason for failure + */ +Status_Control _CORE_message_queue_Submit( + CORE_message_queue_Control *the_message_queue, + Thread_Control *executing, + const void *buffer, + size_t size, + CORE_message_queue_Submit_types submit_type, + bool wait, + Thread_queue_Context *queue_context +); + +/** + * @brief Size a message from the message queue. + * + * This package is the implementation of the CORE Message Queue Handler. + * This core object provides task synchronization and communication functions + * via messages passed to queue objects. + * + * This kernel routine dequeues a message, copies the message buffer to + * a given destination buffer, and frees the message buffer to the + * inactive message pool. The thread will be blocked if wait is true, + * otherwise an error will be given to the thread if no messages are available. + * + * @param[in] the_message_queue points to the message queue + * @param[in] buffer is the starting address of the message buffer to + * to be filled in with a message + * @param[in] size_p is a pointer to the size of the @a buffer and + * indicates the maximum size message that the caller can receive. + * @param[in] wait indicates whether the calling thread is willing to block + * if the message queue is empty. + * @param[in] queue_context The thread queue context used for + * _CORE_message_queue_Acquire() or _CORE_message_queue_Acquire_critical(). + * + * @retval indication of the successful completion or reason for failure. + * On success, the location pointed to @a size_p will contain the + * size of the received message. + * + * @note Returns message priority via return area in TCB. + * + * - INTERRUPT LATENCY: + * + available + * + wait + */ +Status_Control _CORE_message_queue_Seize( + CORE_message_queue_Control *the_message_queue, + Thread_Control *executing, + void *buffer, + size_t *size_p, + bool wait, + Thread_queue_Context *queue_context +); + +/** + * @brief Insert a message into the message queue. + * + * Copies the specified content into the message storage space and then + * inserts the message into the message queue according to the submit type. + * + * @param[in] the_message_queue points to the message queue + * @param[in] the_message is the message to enqueue + * @param[in] content_source the message content source + * @param[in] content_size the message content size in bytes + * @param[in] submit_type determines whether the message is prepended, + * appended, or enqueued in priority order. + */ +void _CORE_message_queue_Insert_message( + CORE_message_queue_Control *the_message_queue, + CORE_message_queue_Buffer_control *the_message, + const void *content_source, + size_t content_size, + CORE_message_queue_Submit_types submit_type +); + +RTEMS_INLINE_ROUTINE Status_Control _CORE_message_queue_Send( + CORE_message_queue_Control *the_message_queue, + const void *buffer, + size_t size, + bool wait, + Thread_queue_Context *queue_context +) +{ + return _CORE_message_queue_Submit( + the_message_queue, + _Thread_Executing, + buffer, + size, + CORE_MESSAGE_QUEUE_SEND_REQUEST, + wait, + queue_context + ); +} + +RTEMS_INLINE_ROUTINE Status_Control _CORE_message_queue_Urgent( + CORE_message_queue_Control *the_message_queue, + const void *buffer, + size_t size, + bool wait, + Thread_queue_Context *queue_context +) +{ + return _CORE_message_queue_Submit( + the_message_queue, + _Thread_Executing, + buffer, + size, + CORE_MESSAGE_QUEUE_URGENT_REQUEST, + wait, + queue_context + ); +} + +RTEMS_INLINE_ROUTINE void _CORE_message_queue_Acquire( + CORE_message_queue_Control *the_message_queue, + Thread_queue_Context *queue_context +) +{ + _Thread_queue_Acquire( &the_message_queue->Wait_queue, queue_context ); +} + +RTEMS_INLINE_ROUTINE void _CORE_message_queue_Acquire_critical( + CORE_message_queue_Control *the_message_queue, + Thread_queue_Context *queue_context +) +{ + _Thread_queue_Acquire_critical( &the_message_queue->Wait_queue, queue_context ); +} + +RTEMS_INLINE_ROUTINE void _CORE_message_queue_Release( + CORE_message_queue_Control *the_message_queue, + Thread_queue_Context *queue_context +) +{ + _Thread_queue_Release( &the_message_queue->Wait_queue, queue_context ); +} + +/** + * This routine copies the contents of the source message buffer + * to the destination message buffer. + */ +RTEMS_INLINE_ROUTINE void _CORE_message_queue_Copy_buffer ( + const void *source, + void *destination, + size_t size +) +{ + memcpy(destination, source, size); +} + +/** + * This function allocates a message buffer from the inactive + * message buffer chain. + */ +RTEMS_INLINE_ROUTINE CORE_message_queue_Buffer_control * +_CORE_message_queue_Allocate_message_buffer ( + CORE_message_queue_Control *the_message_queue +) +{ + return (CORE_message_queue_Buffer_control *) + _Chain_Get_unprotected( &the_message_queue->Inactive_messages ); +} + +/** + * This routine frees a message buffer to the inactive + * message buffer chain. + */ +RTEMS_INLINE_ROUTINE void _CORE_message_queue_Free_message_buffer ( + CORE_message_queue_Control *the_message_queue, + CORE_message_queue_Buffer_control *the_message +) +{ + _Chain_Append_unprotected( &the_message_queue->Inactive_messages, &the_message->Node ); +} + +/** + * This function returns the priority of @a the_message. + * + * @note It encapsulates the optional behavior that message priority is + * disabled if no API requires it. + */ +RTEMS_INLINE_ROUTINE int _CORE_message_queue_Get_message_priority ( + const CORE_message_queue_Buffer_control *the_message +) +{ + #if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY) + return the_message->priority; + #else + return 0; + #endif +} + +/** + * This function removes the first message from the_message_queue + * and returns a pointer to it. + */ +RTEMS_INLINE_ROUTINE + CORE_message_queue_Buffer_control *_CORE_message_queue_Get_pending_message ( + CORE_message_queue_Control *the_message_queue +) +{ + return (CORE_message_queue_Buffer_control *) + _Chain_Get_unprotected( &the_message_queue->Pending_messages ); +} + +#if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION) + /** + * This function returns true if notification is enabled on this message + * queue and false otherwise. + */ + RTEMS_INLINE_ROUTINE bool _CORE_message_queue_Is_notify_enabled ( + CORE_message_queue_Control *the_message_queue + ) + { + return (the_message_queue->notify_handler != NULL); + } +#endif + +/** + * This routine initializes the notification information for + * @a the_message_queue. + */ +#if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION) + RTEMS_INLINE_ROUTINE void _CORE_message_queue_Set_notify ( + CORE_message_queue_Control *the_message_queue, + CORE_message_queue_Notify_Handler the_handler + ) + { + the_message_queue->notify_handler = the_handler; + } +#else + /* turn it into nothing if not enabled */ + #define _CORE_message_queue_Set_notify( the_message_queue, the_handler ) \ + do { } while ( 0 ) +#endif + +RTEMS_INLINE_ROUTINE Thread_Control *_CORE_message_queue_Dequeue_receiver( + CORE_message_queue_Control *the_message_queue, + const void *buffer, + size_t size, + CORE_message_queue_Submit_types submit_type, + Thread_queue_Context *queue_context +) +{ + Thread_Control *the_thread; + + /* + * If there are pending messages, then there can't be threads + * waiting for us to send them a message. + * + * NOTE: This check is critical because threads can block on + * send and receive and this ensures that we are broadcasting + * the message to threads waiting to receive -- not to send. + */ + if ( the_message_queue->number_of_pending_messages != 0 ) { + return NULL; + } + + /* + * There must be no pending messages if there is a thread waiting to + * receive a message. + */ + the_thread = _Thread_queue_First_locked( + &the_message_queue->Wait_queue, + the_message_queue->operations + ); + if ( the_thread == NULL ) { + return NULL; + } + + *(size_t *) the_thread->Wait.return_argument = size; + the_thread->Wait.count = (uint32_t) submit_type; + + _CORE_message_queue_Copy_buffer( + buffer, + the_thread->Wait.return_argument_second.mutable_object, + size + ); + + _Thread_queue_Extract_critical( + &the_message_queue->Wait_queue.Queue, + the_message_queue->operations, + the_thread, + queue_context + ); + + return the_thread; +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/coremutex.h b/cpukit/include/rtems/score/coremutex.h new file mode 100644 index 0000000000..fd1f27c697 --- /dev/null +++ b/cpukit/include/rtems/score/coremutex.h @@ -0,0 +1,104 @@ +/** + * @file + * + * @brief CORE Mutex API + * + * This include file contains all the constants and structures associated with + * the Mutex Handler. A mutex is an enhanced version of the standard Dijkstra + * binary semaphore used to provide synchronization and mutual exclusion + * capabilities. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_COREMUTEX_H +#define _RTEMS_SCORE_COREMUTEX_H + +#include +#include +#include +#include +#include + +struct _Scheduler_Control; + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ScoreMutex Mutex Handler + * + * @ingroup Score + * + * This handler encapsulates functionality which provides the foundation + * Mutex services used in all of the APIs supported by RTEMS. + */ +/**@{*/ + +/** + * @brief Control block used to manage each mutex. + * + * The following defines the control block used to manage each mutex. + */ +typedef struct { + /** + * @brief The thread queue of this mutex. + * + * The owner of the thread queue indicates the mutex owner. + */ + Thread_queue_Control Wait_queue; +} CORE_mutex_Control; + +/** + * @brief The recursive mutex control. + */ +typedef struct { + /** + * @brief The plain non-recursive mutex. + */ + CORE_mutex_Control Mutex; + + /** + * @brief The nest level in case of a recursive seize. + */ + unsigned int nest_level; +} CORE_recursive_mutex_Control; + +/** + * @brief The recursive mutex control with priority ceiling protocol support. + */ +typedef struct { + /** + * @brief The plain recursive mutex. + */ + CORE_recursive_mutex_Control Recursive; + + /** + * @brief The priority ceiling node for the mutex owner. + */ + Priority_Node Priority_ceiling; + +#if defined(RTEMS_SMP) + /** + * @brief The scheduler instance for this priority ceiling mutex. + */ + const struct _Scheduler_Control *scheduler; +#endif +} CORE_ceiling_mutex_Control; + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/coremuteximpl.h b/cpukit/include/rtems/score/coremuteximpl.h new file mode 100644 index 0000000000..78fafca6e1 --- /dev/null +++ b/cpukit/include/rtems/score/coremuteximpl.h @@ -0,0 +1,447 @@ +/** + * @file + * + * @ingroup ScoreMutex + * + * @brief CORE Mutex Implementation + */ + +/* + * COPYRIGHT (c) 1989-2009. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_COREMUTEXIMPL_H +#define _RTEMS_SCORE_COREMUTEXIMPL_H + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup ScoreMutex + */ +/**@{**/ + +#define CORE_MUTEX_TQ_OPERATIONS &_Thread_queue_Operations_priority + +#define CORE_MUTEX_TQ_PRIORITY_INHERIT_OPERATIONS \ + &_Thread_queue_Operations_priority_inherit + +RTEMS_INLINE_ROUTINE void _CORE_mutex_Initialize( + CORE_mutex_Control *the_mutex +) +{ + _Thread_queue_Object_initialize( &the_mutex->Wait_queue ); +} + +RTEMS_INLINE_ROUTINE void _CORE_mutex_Destroy( CORE_mutex_Control *the_mutex ) +{ + _Thread_queue_Destroy( &the_mutex->Wait_queue ); +} + +RTEMS_INLINE_ROUTINE void _CORE_mutex_Acquire_critical( + CORE_mutex_Control *the_mutex, + Thread_queue_Context *queue_context +) +{ + _Thread_queue_Acquire_critical( &the_mutex->Wait_queue, queue_context ); +} + +RTEMS_INLINE_ROUTINE void _CORE_mutex_Release( + CORE_mutex_Control *the_mutex, + Thread_queue_Context *queue_context +) +{ + _Thread_queue_Release( &the_mutex->Wait_queue, queue_context ); +} + +RTEMS_INLINE_ROUTINE Thread_Control *_CORE_mutex_Get_owner( + const CORE_mutex_Control *the_mutex +) +{ + return the_mutex->Wait_queue.Queue.owner; +} + +/** + * @brief Is mutex locked. + * + * This routine returns true if the mutex specified is locked and false + * otherwise. + * + * @param[in] the_mutex is the mutex to check. + * + * @retval true The mutex is locked. + * @retval false The mutex is not locked. + */ +RTEMS_INLINE_ROUTINE bool _CORE_mutex_Is_locked( + const CORE_mutex_Control *the_mutex +) +{ + return _CORE_mutex_Get_owner( the_mutex ) != NULL; +} + +Status_Control _CORE_mutex_Seize_slow( + CORE_mutex_Control *the_mutex, + const Thread_queue_Operations *operations, + Thread_Control *executing, + bool wait, + Thread_queue_Context *queue_context +); + +RTEMS_INLINE_ROUTINE void _CORE_mutex_Set_owner( + CORE_mutex_Control *the_mutex, + Thread_Control *owner +) +{ + the_mutex->Wait_queue.Queue.owner = owner; +} + +RTEMS_INLINE_ROUTINE bool _CORE_mutex_Is_owner( + const CORE_mutex_Control *the_mutex, + const Thread_Control *the_thread +) +{ + return _CORE_mutex_Get_owner( the_mutex ) == the_thread; +} + +RTEMS_INLINE_ROUTINE void _CORE_recursive_mutex_Initialize( + CORE_recursive_mutex_Control *the_mutex +) +{ + _CORE_mutex_Initialize( &the_mutex->Mutex ); + the_mutex->nest_level = 0; +} + +RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Seize_nested( + CORE_recursive_mutex_Control *the_mutex +) +{ + ++the_mutex->nest_level; + return STATUS_SUCCESSFUL; +} + +RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Seize( + CORE_recursive_mutex_Control *the_mutex, + const Thread_queue_Operations *operations, + Thread_Control *executing, + bool wait, + Status_Control ( *nested )( CORE_recursive_mutex_Control * ), + Thread_queue_Context *queue_context +) +{ + Thread_Control *owner; + + _CORE_mutex_Acquire_critical( &the_mutex->Mutex, queue_context ); + + owner = _CORE_mutex_Get_owner( &the_mutex->Mutex ); + + if ( owner == NULL ) { + _CORE_mutex_Set_owner( &the_mutex->Mutex, executing ); + _Thread_Resource_count_increment( executing ); + _CORE_mutex_Release( &the_mutex->Mutex, queue_context ); + return STATUS_SUCCESSFUL; + } + + if ( owner == executing ) { + Status_Control status; + + status = ( *nested )( the_mutex ); + _CORE_mutex_Release( &the_mutex->Mutex, queue_context ); + return status; + } + + return _CORE_mutex_Seize_slow( + &the_mutex->Mutex, + operations, + executing, + wait, + queue_context + ); +} + +RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Surrender( + CORE_recursive_mutex_Control *the_mutex, + const Thread_queue_Operations *operations, + Thread_Control *executing, + Thread_queue_Context *queue_context +) +{ + unsigned int nest_level; + Thread_queue_Heads *heads; + + _CORE_mutex_Acquire_critical( &the_mutex->Mutex, queue_context ); + + if ( !_CORE_mutex_Is_owner( &the_mutex->Mutex, executing ) ) { + _CORE_mutex_Release( &the_mutex->Mutex, queue_context ); + return STATUS_NOT_OWNER; + } + + nest_level = the_mutex->nest_level; + + if ( nest_level > 0 ) { + the_mutex->nest_level = nest_level - 1; + _CORE_mutex_Release( &the_mutex->Mutex, queue_context ); + return STATUS_SUCCESSFUL; + } + + _Thread_Resource_count_decrement( executing ); + _CORE_mutex_Set_owner( &the_mutex->Mutex, NULL ); + + heads = the_mutex->Mutex.Wait_queue.Queue.heads; + + if ( heads == NULL ) { + _CORE_mutex_Release( &the_mutex->Mutex, queue_context ); + return STATUS_SUCCESSFUL; + } + + _Thread_queue_Surrender( + &the_mutex->Mutex.Wait_queue.Queue, + heads, + executing, + queue_context, + operations + ); + return STATUS_SUCCESSFUL; +} + +RTEMS_INLINE_ROUTINE void _CORE_ceiling_mutex_Initialize( + CORE_ceiling_mutex_Control *the_mutex, + const Scheduler_Control *scheduler, + Priority_Control priority_ceiling +) +{ + _CORE_recursive_mutex_Initialize( &the_mutex->Recursive ); + _Priority_Node_initialize( &the_mutex->Priority_ceiling, priority_ceiling ); +#if defined(RTEMS_SMP) + the_mutex->scheduler = scheduler; +#endif +} + +RTEMS_INLINE_ROUTINE const Scheduler_Control * +_CORE_ceiling_mutex_Get_scheduler( + const CORE_ceiling_mutex_Control *the_mutex +) +{ +#if defined(RTEMS_SMP) + return the_mutex->scheduler; +#else + return &_Scheduler_Table[ 0 ]; +#endif +} + +RTEMS_INLINE_ROUTINE void _CORE_ceiling_mutex_Set_priority( + CORE_ceiling_mutex_Control *the_mutex, + Priority_Control priority_ceiling, + Thread_queue_Context *queue_context +) +{ + Thread_Control *owner; + + owner = _CORE_mutex_Get_owner( &the_mutex->Recursive.Mutex ); + + if ( owner != NULL ) { + _Thread_Wait_acquire( owner, queue_context ); + _Thread_Priority_change( + owner, + &the_mutex->Priority_ceiling, + priority_ceiling, + false, + queue_context + ); + _Thread_Wait_release( owner, queue_context ); + } else { + the_mutex->Priority_ceiling.priority = priority_ceiling; + } +} + +RTEMS_INLINE_ROUTINE Priority_Control _CORE_ceiling_mutex_Get_priority( + const CORE_ceiling_mutex_Control *the_mutex +) +{ + return the_mutex->Priority_ceiling.priority; +} + +RTEMS_INLINE_ROUTINE Status_Control _CORE_ceiling_mutex_Set_owner( + CORE_ceiling_mutex_Control *the_mutex, + Thread_Control *owner, + Thread_queue_Context *queue_context +) +{ + ISR_lock_Context lock_context; + Scheduler_Node *scheduler_node; + Per_CPU_Control *cpu_self; + + _Thread_Wait_acquire_default_critical( owner, &lock_context ); + + scheduler_node = _Thread_Scheduler_get_home_node( owner ); + + if ( + _Priority_Get_priority( &scheduler_node->Wait.Priority ) + < the_mutex->Priority_ceiling.priority + ) { + _Thread_Wait_release_default_critical( owner, &lock_context ); + _CORE_mutex_Release( &the_mutex->Recursive.Mutex, queue_context ); + return STATUS_MUTEX_CEILING_VIOLATED; + } + + _CORE_mutex_Set_owner( &the_mutex->Recursive.Mutex, owner ); + _Thread_Resource_count_increment( owner ); + _Thread_Priority_add( + owner, + &the_mutex->Priority_ceiling, + queue_context + ); + _Thread_Wait_release_default_critical( owner, &lock_context ); + + cpu_self = _Thread_queue_Dispatch_disable( queue_context ); + _CORE_mutex_Release( &the_mutex->Recursive.Mutex, queue_context ); + _Thread_Priority_update( queue_context ); + _Thread_Dispatch_enable( cpu_self ); + return STATUS_SUCCESSFUL; +} + +RTEMS_INLINE_ROUTINE Status_Control _CORE_ceiling_mutex_Seize( + CORE_ceiling_mutex_Control *the_mutex, + Thread_Control *executing, + bool wait, + Status_Control ( *nested )( CORE_recursive_mutex_Control * ), + Thread_queue_Context *queue_context +) +{ + Thread_Control *owner; + + _CORE_mutex_Acquire_critical( &the_mutex->Recursive.Mutex, queue_context ); + + owner = _CORE_mutex_Get_owner( &the_mutex->Recursive.Mutex ); + + if ( owner == NULL ) { +#if defined(RTEMS_SMP) + if ( + _Thread_Scheduler_get_home( executing ) + != _CORE_ceiling_mutex_Get_scheduler( the_mutex ) + ) { + _CORE_mutex_Release( &the_mutex->Recursive.Mutex, queue_context ); + return STATUS_NOT_DEFINED; + } +#endif + + _Thread_queue_Context_clear_priority_updates( queue_context ); + return _CORE_ceiling_mutex_Set_owner( + the_mutex, + executing, + queue_context + ); + } + + if ( owner == executing ) { + Status_Control status; + + status = ( *nested )( &the_mutex->Recursive ); + _CORE_mutex_Release( &the_mutex->Recursive.Mutex, queue_context ); + return status; + } + + return _CORE_mutex_Seize_slow( + &the_mutex->Recursive.Mutex, + CORE_MUTEX_TQ_OPERATIONS, + executing, + wait, + queue_context + ); +} + +RTEMS_INLINE_ROUTINE Status_Control _CORE_ceiling_mutex_Surrender( + CORE_ceiling_mutex_Control *the_mutex, + Thread_Control *executing, + Thread_queue_Context *queue_context +) +{ + unsigned int nest_level; + ISR_lock_Context lock_context; + Per_CPU_Control *cpu_self; + Thread_Control *new_owner; + + _CORE_mutex_Acquire_critical( &the_mutex->Recursive.Mutex, queue_context ); + + if ( !_CORE_mutex_Is_owner( &the_mutex->Recursive.Mutex, executing ) ) { + _CORE_mutex_Release( &the_mutex->Recursive.Mutex, queue_context ); + return STATUS_NOT_OWNER; + } + + nest_level = the_mutex->Recursive.nest_level; + + if ( nest_level > 0 ) { + the_mutex->Recursive.nest_level = nest_level - 1; + _CORE_mutex_Release( &the_mutex->Recursive.Mutex, queue_context ); + return STATUS_SUCCESSFUL; + } + + _Thread_Resource_count_decrement( executing ); + + _Thread_queue_Context_clear_priority_updates( queue_context ); + _Thread_Wait_acquire_default_critical( executing, &lock_context ); + _Thread_Priority_remove( + executing, + &the_mutex->Priority_ceiling, + queue_context + ); + _Thread_Wait_release_default_critical( executing, &lock_context ); + + new_owner = _Thread_queue_First_locked( + &the_mutex->Recursive.Mutex.Wait_queue, + CORE_MUTEX_TQ_OPERATIONS + ); + _CORE_mutex_Set_owner( &the_mutex->Recursive.Mutex, new_owner ); + + cpu_self = _Thread_Dispatch_disable_critical( + &queue_context->Lock_context.Lock_context + ); + + if ( new_owner != NULL ) { +#if defined(RTEMS_MULTIPROCESSING) + if ( _Objects_Is_local_id( new_owner->Object.id ) ) +#endif + { + _Thread_Resource_count_increment( new_owner ); + _Thread_Priority_add( + new_owner, + &the_mutex->Priority_ceiling, + queue_context + ); + } + + _Thread_queue_Extract_critical( + &the_mutex->Recursive.Mutex.Wait_queue.Queue, + CORE_MUTEX_TQ_OPERATIONS, + new_owner, + queue_context + ); + } else { + _CORE_mutex_Release( &the_mutex->Recursive.Mutex, queue_context ); + } + + _Thread_Priority_update( queue_context ); + _Thread_Dispatch_enable( cpu_self ); + return STATUS_SUCCESSFUL; +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/corerwlockimpl.h b/cpukit/include/rtems/score/corerwlockimpl.h new file mode 100644 index 0000000000..942e8c8d75 --- /dev/null +++ b/cpukit/include/rtems/score/corerwlockimpl.h @@ -0,0 +1,182 @@ +/** + * @file + * + * @brief Inlined Routines Associated with the SuperCore RWLock + * + * This include file contains all of the inlined routines associated + * with the SuperCore RWLock. + */ + +/* + * COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CORERWLOCKIMPL_H +#define _RTEMS_SCORE_CORERWLOCKIMPL_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup ScoreRWLock + */ +/**@{**/ + +#define CORE_RWLOCK_TQ_OPERATIONS &_Thread_queue_Operations_FIFO + +/** + * This is used to denote that a thread is blocking waiting for + * read-only access to the RWLock. + */ +#define CORE_RWLOCK_THREAD_WAITING_FOR_READ 0 + +/** + * This is used to denote that a thread is blocking waiting for + * write-exclusive access to the RWLock. + */ +#define CORE_RWLOCK_THREAD_WAITING_FOR_WRITE 1 + +/** + * RWLock State. + */ +typedef enum { + /** This indicates the the RWLock is not currently locked. + */ + CORE_RWLOCK_UNLOCKED, + /** This indicates the the RWLock is currently locked for reading. + */ + CORE_RWLOCK_LOCKED_FOR_READING, + /** This indicates the the RWLock is currently locked for reading. + */ + CORE_RWLOCK_LOCKED_FOR_WRITING +} CORE_RWLock_States; + +/** + * The following defines the control block used to manage each + * RWLock. + */ +typedef struct { + /** This field is the Waiting Queue used to manage the set of tasks + * which are blocked waiting for the RWLock to be released. + */ + Thread_queue_Syslock_queue Queue; + + /** This element is the current state of the RWLock. + */ + CORE_RWLock_States current_state; + + /** This element contains the current number of thread waiting for this + * RWLock to be released. */ + unsigned int number_of_readers; +} CORE_RWLock_Control; + +/** + * @brief Initialize a RWlock. + * + * This routine initializes the RWLock based on the parameters passed. + * + * @param[in] the_rwlock is the RWLock to initialize + */ +void _CORE_RWLock_Initialize( + CORE_RWLock_Control *the_rwlock +); + +RTEMS_INLINE_ROUTINE void _CORE_RWLock_Destroy( + CORE_RWLock_Control *the_rwlock +) +{ + (void) the_rwlock; +} + +RTEMS_INLINE_ROUTINE Thread_Control *_CORE_RWLock_Acquire( + CORE_RWLock_Control *the_rwlock, + Thread_queue_Context *queue_context +) +{ + ISR_Level level; + Thread_Control *executing; + + _Thread_queue_Context_ISR_disable( queue_context, level ); + _Thread_queue_Context_set_ISR_level( queue_context, level ); + executing = _Thread_Executing; + _Thread_queue_Queue_acquire_critical( + &the_rwlock->Queue.Queue, + &executing->Potpourri_stats, + &queue_context->Lock_context.Lock_context + ); + + return executing; +} + +RTEMS_INLINE_ROUTINE void _CORE_RWLock_Release( + CORE_RWLock_Control *the_rwlock, + Thread_queue_Context *queue_context +) +{ + _Thread_queue_Queue_release( + &the_rwlock->Queue.Queue, + &queue_context->Lock_context.Lock_context + ); +} + +/** + * @brief Obtain RWLock for reading. + * + * This routine attempts to obtain the RWLock for read access. + * + * @param[in] the_rwlock is the RWLock to wait for + * @param[in] wait is true if the calling thread is willing to wait + */ + +Status_Control _CORE_RWLock_Seize_for_reading( + CORE_RWLock_Control *the_rwlock, + bool wait, + Thread_queue_Context *queue_context +); + +/** + * @brief Obtain RWLock for writing. + * + * This routine attempts to obtain the RWLock for write exclusive access. + * + * @param[in] the_rwlock is the RWLock to wait for + * @param[in] wait is true if the calling thread is willing to wait + */ +Status_Control _CORE_RWLock_Seize_for_writing( + CORE_RWLock_Control *the_rwlock, + bool wait, + Thread_queue_Context *queue_context +); + +/** + * @brief Release the RWLock. + * + * This routine manually releases @a the_rwlock. All of the threads waiting + * for the RWLock will be readied. + * + * @param[in] the_rwlock is the RWLock to surrender + * + * @retval Status is returned to indicate successful or failure. + */ +Status_Control _CORE_RWLock_Surrender( CORE_RWLock_Control *the_rwlock ); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/coresem.h b/cpukit/include/rtems/score/coresem.h new file mode 100644 index 0000000000..f9d3ac8fd5 --- /dev/null +++ b/cpukit/include/rtems/score/coresem.h @@ -0,0 +1,61 @@ +/** + * @file rtems/score/coresem.h + * + * @brief Data Associated with the Counting Semaphore Handler + * + * This include file contains all the constants and structures associated + * with the Counting Semaphore Handler. A counting semaphore is the + * standard Dijkstra binary semaphore used to provide synchronization + * and mutual exclusion capabilities. + */ + +/* + * COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CORESEM_H +#define _RTEMS_SCORE_CORESEM_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ScoreSemaphore Semaphore Handler + * + * @ingroup Score + * + * This handler encapsulates functionality which provides the foundation + * Semaphore services used in all of the APIs supported by RTEMS. + */ +/**@{*/ + +/** + * The following defines the control block used to manage each + * counting semaphore. + */ +typedef struct { + /** This field is the Waiting Queue used to manage the set of tasks + * which are blocked waiting to obtain the semaphore. + */ + Thread_queue_Control Wait_queue; + + /** This element contains the current count of this semaphore. */ + uint32_t count; +} CORE_semaphore_Control; + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/coresemimpl.h b/cpukit/include/rtems/score/coresemimpl.h new file mode 100644 index 0000000000..00f77e61dd --- /dev/null +++ b/cpukit/include/rtems/score/coresemimpl.h @@ -0,0 +1,207 @@ +/** + * @file + * + * @brief Inlined Routines Associated with the SuperCore Semaphore + * + * This include file contains all of the inlined routines associated + * with the SuperCore semaphore. + */ + +/* + * COPYRIGHT (c) 1989-2006. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CORESEMIMPL_H +#define _RTEMS_SCORE_CORESEMIMPL_H + +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup ScoreSemaphore + */ +/**@{**/ + +/** + * @brief Initialize the semaphore based on the parameters passed. + * + * This package is the implementation of the CORE Semaphore Handler. + * This core object utilizes standard Dijkstra counting semaphores to provide + * synchronization and mutual exclusion capabilities. + * + * This routine initializes the semaphore based on the parameters passed. + * + * @param[in] the_semaphore is the semaphore to initialize + * @param[in] initial_value is the initial count of the semaphore + */ +void _CORE_semaphore_Initialize( + CORE_semaphore_Control *the_semaphore, + uint32_t initial_value +); + +RTEMS_INLINE_ROUTINE void _CORE_semaphore_Acquire_critical( + CORE_semaphore_Control *the_semaphore, + Thread_queue_Context *queue_context +) +{ + _Thread_queue_Acquire_critical( &the_semaphore->Wait_queue, queue_context ); +} + +RTEMS_INLINE_ROUTINE void _CORE_semaphore_Release( + CORE_semaphore_Control *the_semaphore, + Thread_queue_Context *queue_context +) +{ + _Thread_queue_Release( &the_semaphore->Wait_queue, queue_context ); +} + +RTEMS_INLINE_ROUTINE void _CORE_semaphore_Destroy( + CORE_semaphore_Control *the_semaphore, + const Thread_queue_Operations *operations, + Thread_queue_Context *queue_context +) +{ + _Thread_queue_Flush_critical( + &the_semaphore->Wait_queue.Queue, + operations, + _Thread_queue_Flush_status_object_was_deleted, + queue_context + ); + _Thread_queue_Destroy( &the_semaphore->Wait_queue ); +} + +/** + * @brief Surrender a unit to a semaphore. + * + * This routine frees a unit to the semaphore. If a task was blocked waiting + * for a unit from this semaphore, then that task will be readied and the unit + * given to that task. Otherwise, the unit will be returned to the semaphore. + * + * @param[in] the_semaphore is the semaphore to surrender + * @param[in] operations The thread queue operations. + * @param[in] queue_context is a temporary variable used to contain the ISR + * disable level cookie + * + * @retval an indication of whether the routine succeeded or failed + */ +RTEMS_INLINE_ROUTINE Status_Control _CORE_semaphore_Surrender( + CORE_semaphore_Control *the_semaphore, + const Thread_queue_Operations *operations, + uint32_t maximum_count, + Thread_queue_Context *queue_context +) +{ + Thread_Control *the_thread; + Status_Control status; + + status = STATUS_SUCCESSFUL; + + _CORE_semaphore_Acquire_critical( the_semaphore, queue_context ); + + the_thread = _Thread_queue_First_locked( + &the_semaphore->Wait_queue, + operations + ); + if ( the_thread != NULL ) { + _Thread_queue_Extract_critical( + &the_semaphore->Wait_queue.Queue, + operations, + the_thread, + queue_context + ); + } else { + if ( the_semaphore->count < maximum_count ) + the_semaphore->count += 1; + else + status = STATUS_MAXIMUM_COUNT_EXCEEDED; + + _CORE_semaphore_Release( the_semaphore, queue_context ); + } + + return status; +} + +/** + * This routine returns the current count associated with the semaphore. + * + * @param[in] the_semaphore is the semaphore to obtain the count of + * + * @return the current count of this semaphore + */ +RTEMS_INLINE_ROUTINE uint32_t _CORE_semaphore_Get_count( + const CORE_semaphore_Control *the_semaphore +) +{ + return the_semaphore->count; +} + +/** + * This routine attempts to receive a unit from the_semaphore. + * If a unit is available or if the wait flag is false, then the routine + * returns. Otherwise, the calling task is blocked until a unit becomes + * available. + * + * @param[in] the_semaphore is the semaphore to obtain + * @param[in] operations The thread queue operations. + * @param[in] executing The currently executing thread. + * @param[in] wait is true if the thread is willing to wait + * @param[in] queue_context is a temporary variable used to contain the ISR + * disable level cookie + */ +RTEMS_INLINE_ROUTINE Status_Control _CORE_semaphore_Seize( + CORE_semaphore_Control *the_semaphore, + const Thread_queue_Operations *operations, + Thread_Control *executing, + bool wait, + Thread_queue_Context *queue_context +) +{ + _Assert( _ISR_Get_level() != 0 ); + + _CORE_semaphore_Acquire_critical( the_semaphore, queue_context ); + if ( the_semaphore->count != 0 ) { + the_semaphore->count -= 1; + _CORE_semaphore_Release( the_semaphore, queue_context ); + return STATUS_SUCCESSFUL; + } + + if ( !wait ) { + _CORE_semaphore_Release( the_semaphore, queue_context ); + return STATUS_UNSATISFIED; + } + + _Thread_queue_Context_set_thread_state( + queue_context, + STATES_WAITING_FOR_SEMAPHORE + ); + _Thread_queue_Enqueue( + &the_semaphore->Wait_queue.Queue, + operations, + executing, + queue_context + ); + return _Thread_Wait_get_status( executing ); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/cpustdatomic.h b/cpukit/include/rtems/score/cpustdatomic.h new file mode 100644 index 0000000000..6c6db8d279 --- /dev/null +++ b/cpukit/include/rtems/score/cpustdatomic.h @@ -0,0 +1,682 @@ +/** + * @file + * + * @brief Atomic Operations CPU API + */ + +/* + * COPYRIGHT (c) 2013 Deng Hengyi. + * Copyright (c) 2015 embedded brains GmbH. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPUSTDATOMIC_H +#define _RTEMS_SCORE_CPUSTDATOMIC_H + +#include + +#ifdef RTEMS_SMP + #if defined(__cplusplus) \ + && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)) + /* + * The GCC 4.9 ships its own which is not C++ compatible. The + * suggested solution was to include in case C++ is used. This works + * at least with GCC 4.9. See also: + * + * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60932 + * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60940 + */ + #include + #define _RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC + #else + #include + #define _RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC + #endif +#else + #include +#endif + +#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) + +typedef std::atomic_uint CPU_atomic_Uint; + +typedef std::atomic_ulong CPU_atomic_Ulong; + +typedef std::atomic_uintptr_t CPU_atomic_Uintptr; + +typedef std::atomic_flag CPU_atomic_Flag; + +typedef std::memory_order CPU_atomic_Order; + +#define CPU_ATOMIC_ORDER_RELAXED std::memory_order_relaxed + +#define CPU_ATOMIC_ORDER_ACQUIRE std::memory_order_acquire + +#define CPU_ATOMIC_ORDER_RELEASE std::memory_order_release + +#define CPU_ATOMIC_ORDER_ACQ_REL std::memory_order_acq_rel + +#define CPU_ATOMIC_ORDER_SEQ_CST std::memory_order_seq_cst + +#define CPU_ATOMIC_INITIALIZER_UINT( value ) ATOMIC_VAR_INIT( value ) + +#define CPU_ATOMIC_INITIALIZER_ULONG( value ) ATOMIC_VAR_INIT( value ) + +#define CPU_ATOMIC_INITIALIZER_UINTPTR( value ) ATOMIC_VAR_INIT( value ) + +#define CPU_ATOMIC_INITIALIZER_FLAG ATOMIC_FLAG_INIT + +#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) + +typedef atomic_uint CPU_atomic_Uint; + +typedef atomic_ulong CPU_atomic_Ulong; + +typedef atomic_uintptr_t CPU_atomic_Uintptr; + +typedef atomic_flag CPU_atomic_Flag; + +typedef memory_order CPU_atomic_Order; + +#define CPU_ATOMIC_ORDER_RELAXED memory_order_relaxed + +#define CPU_ATOMIC_ORDER_ACQUIRE memory_order_acquire + +#define CPU_ATOMIC_ORDER_RELEASE memory_order_release + +#define CPU_ATOMIC_ORDER_ACQ_REL memory_order_acq_rel + +#define CPU_ATOMIC_ORDER_SEQ_CST memory_order_seq_cst + +#define CPU_ATOMIC_INITIALIZER_UINT( value ) ATOMIC_VAR_INIT( value ) + +#define CPU_ATOMIC_INITIALIZER_ULONG( value ) ATOMIC_VAR_INIT( value ) + +#define CPU_ATOMIC_INITIALIZER_UINTPTR( value ) ATOMIC_VAR_INIT( value ) + +#define CPU_ATOMIC_INITIALIZER_FLAG ATOMIC_FLAG_INIT + +#else + +typedef unsigned int CPU_atomic_Uint; + +typedef unsigned long CPU_atomic_Ulong; + +typedef uintptr_t CPU_atomic_Uintptr; + +typedef bool CPU_atomic_Flag; + +typedef int CPU_atomic_Order; + +#define CPU_ATOMIC_ORDER_RELAXED 0 + +#define CPU_ATOMIC_ORDER_ACQUIRE 2 + +#define CPU_ATOMIC_ORDER_RELEASE 3 + +#define CPU_ATOMIC_ORDER_ACQ_REL 4 + +#define CPU_ATOMIC_ORDER_SEQ_CST 5 + +#define CPU_ATOMIC_INITIALIZER_UINT( value ) ( value ) + +#define CPU_ATOMIC_INITIALIZER_ULONG( value ) ( value ) + +#define CPU_ATOMIC_INITIALIZER_UINTPTR( value ) ( value ) + +#define CPU_ATOMIC_INITIALIZER_FLAG false + +#endif + +static inline void _CPU_atomic_Fence( CPU_atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) + std::atomic_thread_fence( order ); +#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) + atomic_thread_fence( order ); +#else + (void) order; + RTEMS_COMPILER_MEMORY_BARRIER(); +#endif +} + +static inline void _CPU_atomic_Init_uint( CPU_atomic_Uint *obj, unsigned int desired ) +{ +#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) + obj->store( desired ); +#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) + atomic_init( obj, desired ); +#else + *obj = desired; +#endif +} + +static inline void _CPU_atomic_Init_ulong( CPU_atomic_Ulong *obj, unsigned long desired ) +{ +#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) + obj->store( desired ); +#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) + atomic_init( obj, desired ); +#else + *obj = desired; +#endif +} + +static inline void _CPU_atomic_Init_uintptr( CPU_atomic_Uintptr *obj, uintptr_t desired ) +{ +#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) + obj->store( desired ); +#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) + atomic_init( obj, desired ); +#else + *obj = desired; +#endif +} + +static inline unsigned int _CPU_atomic_Load_uint( const CPU_atomic_Uint *obj, CPU_atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) + return obj->load( order ); +#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) + return atomic_load_explicit( obj, order ); +#else + unsigned int val; + + (void) order; + val = *obj; + RTEMS_COMPILER_MEMORY_BARRIER(); + + return val; +#endif +} + +static inline unsigned long _CPU_atomic_Load_ulong( const CPU_atomic_Ulong *obj, CPU_atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) + return obj->load( order ); +#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) + return atomic_load_explicit( obj, order ); +#else + unsigned long val; + + (void) order; + val = *obj; + RTEMS_COMPILER_MEMORY_BARRIER(); + + return val; +#endif +} + +static inline uintptr_t _CPU_atomic_Load_uintptr( const CPU_atomic_Uintptr *obj, CPU_atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) + return obj->load( order ); +#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) + return atomic_load_explicit( obj, order ); +#else + uintptr_t val; + + (void) order; + val = *obj; + RTEMS_COMPILER_MEMORY_BARRIER(); + + return val; +#endif +} + +static inline void _CPU_atomic_Store_uint( CPU_atomic_Uint *obj, unsigned int desired, CPU_atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) + obj->store( desired ); +#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) + atomic_store_explicit( obj, desired, order ); +#else + (void) order; + RTEMS_COMPILER_MEMORY_BARRIER(); + *obj = desired; +#endif +} + +static inline void _CPU_atomic_Store_ulong( CPU_atomic_Ulong *obj, unsigned long desired, CPU_atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) + obj->store( desired ); +#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) + atomic_store_explicit( obj, desired, order ); +#else + (void) order; + RTEMS_COMPILER_MEMORY_BARRIER(); + *obj = desired; +#endif +} + +static inline void _CPU_atomic_Store_uintptr( CPU_atomic_Uintptr *obj, uintptr_t desired, CPU_atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) + obj->store( desired ); +#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) + atomic_store_explicit( obj, desired, order ); +#else + (void) order; + RTEMS_COMPILER_MEMORY_BARRIER(); + *obj = desired; +#endif +} + +static inline unsigned int _CPU_atomic_Fetch_add_uint( CPU_atomic_Uint *obj, unsigned int arg, CPU_atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) + return obj->fetch_add( arg, order ); +#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) + return atomic_fetch_add_explicit( obj, arg, order ); +#else + unsigned int val; + ISR_Level level; + + (void) order; + _ISR_Local_disable( level ); + val = *obj; + *obj = val + arg; + _ISR_Local_enable( level ); + + return val; +#endif +} + +static inline unsigned long _CPU_atomic_Fetch_add_ulong( CPU_atomic_Ulong *obj, unsigned long arg, CPU_atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) + return obj->fetch_add( arg, order ); +#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) + return atomic_fetch_add_explicit( obj, arg, order ); +#else + unsigned long val; + ISR_Level level; + + (void) order; + _ISR_Local_disable( level ); + val = *obj; + *obj = val + arg; + _ISR_Local_enable( level ); + + return val; +#endif +} + +static inline uintptr_t _CPU_atomic_Fetch_add_uintptr( CPU_atomic_Uintptr *obj, uintptr_t arg, CPU_atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) + return obj->fetch_add( arg, order ); +#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) + return atomic_fetch_add_explicit( obj, arg, order ); +#else + uintptr_t val; + ISR_Level level; + + (void) order; + _ISR_Local_disable( level ); + val = *obj; + *obj = val + arg; + _ISR_Local_enable( level ); + + return val; +#endif +} + +static inline unsigned int _CPU_atomic_Fetch_sub_uint( CPU_atomic_Uint *obj, unsigned int arg, CPU_atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) + return obj->fetch_sub( arg, order ); +#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) + return atomic_fetch_sub_explicit( obj, arg, order ); +#else + unsigned int val; + ISR_Level level; + + (void) order; + _ISR_Local_disable( level ); + val = *obj; + *obj = val - arg; + _ISR_Local_enable( level ); + + return val; +#endif +} + +static inline unsigned long _CPU_atomic_Fetch_sub_ulong( CPU_atomic_Ulong *obj, unsigned long arg, CPU_atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) + return obj->fetch_sub( arg, order ); +#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) + return atomic_fetch_sub_explicit( obj, arg, order ); +#else + unsigned long val; + ISR_Level level; + + (void) order; + _ISR_Local_disable( level ); + val = *obj; + *obj = val - arg; + _ISR_Local_enable( level ); + + return val; +#endif +} + +static inline uintptr_t _CPU_atomic_Fetch_sub_uintptr( CPU_atomic_Uintptr *obj, uintptr_t arg, CPU_atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) + return obj->fetch_sub( arg, order ); +#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) + return atomic_fetch_sub_explicit( obj, arg, order ); +#else + uintptr_t val; + ISR_Level level; + + (void) order; + _ISR_Local_disable( level ); + val = *obj; + *obj = val - arg; + _ISR_Local_enable( level ); + + return val; +#endif +} + +static inline unsigned int _CPU_atomic_Fetch_or_uint( CPU_atomic_Uint *obj, unsigned int arg, CPU_atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) + return obj->fetch_or( arg, order ); +#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) + return atomic_fetch_or_explicit( obj, arg, order ); +#else + unsigned int val; + ISR_Level level; + + (void) order; + _ISR_Local_disable( level ); + val = *obj; + *obj = val | arg; + _ISR_Local_enable( level ); + + return val; +#endif +} + +static inline unsigned long _CPU_atomic_Fetch_or_ulong( CPU_atomic_Ulong *obj, unsigned long arg, CPU_atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) + return obj->fetch_or( arg, order ); +#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) + return atomic_fetch_or_explicit( obj, arg, order ); +#else + unsigned long val; + ISR_Level level; + + (void) order; + _ISR_Local_disable( level ); + val = *obj; + *obj = val | arg; + _ISR_Local_enable( level ); + + return val; +#endif +} + +static inline uintptr_t _CPU_atomic_Fetch_or_uintptr( CPU_atomic_Uintptr *obj, uintptr_t arg, CPU_atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) + return obj->fetch_or( arg, order ); +#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) + return atomic_fetch_or_explicit( obj, arg, order ); +#else + uintptr_t val; + ISR_Level level; + + (void) order; + _ISR_Local_disable( level ); + val = *obj; + *obj = val | arg; + _ISR_Local_enable( level ); + + return val; +#endif +} + +static inline unsigned int _CPU_atomic_Fetch_and_uint( CPU_atomic_Uint *obj, unsigned int arg, CPU_atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) + return obj->fetch_and( arg, order ); +#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) + return atomic_fetch_and_explicit( obj, arg, order ); +#else + unsigned int val; + ISR_Level level; + + (void) order; + _ISR_Local_disable( level ); + val = *obj; + *obj = val & arg; + _ISR_Local_enable( level ); + + return val; +#endif +} + +static inline unsigned long _CPU_atomic_Fetch_and_ulong( CPU_atomic_Ulong *obj, unsigned long arg, CPU_atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) + return obj->fetch_and( arg, order ); +#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) + return atomic_fetch_and_explicit( obj, arg, order ); +#else + unsigned long val; + ISR_Level level; + + (void) order; + _ISR_Local_disable( level ); + val = *obj; + *obj = val & arg; + _ISR_Local_enable( level ); + + return val; +#endif +} + +static inline uintptr_t _CPU_atomic_Fetch_and_uintptr( CPU_atomic_Uintptr *obj, uintptr_t arg, CPU_atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) + return obj->fetch_and( arg, order ); +#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) + return atomic_fetch_and_explicit( obj, arg, order ); +#else + uintptr_t val; + ISR_Level level; + + (void) order; + _ISR_Local_disable( level ); + val = *obj; + *obj = val & arg; + _ISR_Local_enable( level ); + + return val; +#endif +} + +static inline unsigned int _CPU_atomic_Exchange_uint( CPU_atomic_Uint *obj, unsigned int desired, CPU_atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) + return obj->exchange( desired, order ); +#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) + return atomic_exchange_explicit( obj, desired, order ); +#else + unsigned int val; + ISR_Level level; + + (void) order; + _ISR_Local_disable( level ); + val = *obj; + *obj = desired; + _ISR_Local_enable( level ); + + return val; +#endif +} + +static inline unsigned long _CPU_atomic_Exchange_ulong( CPU_atomic_Ulong *obj, unsigned long desired, CPU_atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) + return obj->exchange( desired, order ); +#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) + return atomic_exchange_explicit( obj, desired, order ); +#else + unsigned long val; + ISR_Level level; + + (void) order; + _ISR_Local_disable( level ); + val = *obj; + *obj = desired; + _ISR_Local_enable( level ); + + return val; +#endif +} + +static inline uintptr_t _CPU_atomic_Exchange_uintptr( CPU_atomic_Uintptr *obj, uintptr_t desired, CPU_atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) + return obj->exchange( desired, order ); +#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) + return atomic_exchange_explicit( obj, desired, order ); +#else + uintptr_t val; + ISR_Level level; + + (void) order; + _ISR_Local_disable( level ); + val = *obj; + *obj = desired; + _ISR_Local_enable( level ); + + return val; +#endif +} + +static inline bool _CPU_atomic_Compare_exchange_uint( CPU_atomic_Uint *obj, unsigned int *expected, unsigned int desired, CPU_atomic_Order succ, CPU_atomic_Order fail ) +{ +#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) + return obj->compare_exchange_strong( *expected, desired, succ, fail ); +#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) + return atomic_compare_exchange_strong_explicit( obj, expected, desired, succ, fail ); +#else + bool success; + ISR_Level level; + unsigned int actual; + + (void) succ; + (void) fail; + _ISR_Local_disable( level ); + actual = *obj; + success = ( actual == *expected ); + if ( success ) { + *obj = desired; + } else { + *expected = actual; + } + _ISR_Local_enable( level ); + + return success; +#endif +} + +static inline bool _CPU_atomic_Compare_exchange_ulong( CPU_atomic_Ulong *obj, unsigned long *expected, unsigned long desired, CPU_atomic_Order succ, CPU_atomic_Order fail ) +{ +#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) + return obj->compare_exchange_strong( *expected, desired, succ, fail ); +#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) + return atomic_compare_exchange_strong_explicit( obj, expected, desired, succ, fail ); +#else + bool success; + ISR_Level level; + unsigned long actual; + + (void) succ; + (void) fail; + _ISR_Local_disable( level ); + actual = *obj; + success = ( actual == *expected ); + if ( success ) { + *obj = desired; + } else { + *expected = actual; + } + _ISR_Local_enable( level ); + + return success; +#endif +} + +static inline bool _CPU_atomic_Compare_exchange_uintptr( CPU_atomic_Uintptr *obj, uintptr_t *expected, uintptr_t desired, CPU_atomic_Order succ, CPU_atomic_Order fail ) +{ +#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) + return obj->compare_exchange_strong( *expected, desired, succ, fail ); +#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) + return atomic_compare_exchange_strong_explicit( obj, expected, desired, succ, fail ); +#else + bool success; + ISR_Level level; + uintptr_t actual; + + (void) succ; + (void) fail; + _ISR_Local_disable( level ); + actual = *obj; + success = ( actual == *expected ); + if ( success ) { + *obj = desired; + } else { + *expected = actual; + } + _ISR_Local_enable( level ); + + return success; +#endif +} + +static inline void _CPU_atomic_Flag_clear( CPU_atomic_Flag *obj, CPU_atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) + obj->clear( order ); +#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) + atomic_flag_clear_explicit( obj, order ); +#else + (void) order; + *obj = false; +#endif +} + +static inline bool _CPU_atomic_Flag_test_and_set( CPU_atomic_Flag *obj, CPU_atomic_Order order ) +{ +#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) + return obj->test_and_set( order ); +#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) + return atomic_flag_test_and_set_explicit( obj, order ); +#else + bool flag; + ISR_Level level; + + (void) order; + _ISR_Local_disable( level ); + flag = *obj; + *obj = true; + _ISR_Local_enable( level ); + + return flag; +#endif +} + +#endif /* _RTEMS_SCORE_CPUSTDATOMIC_H */ diff --git a/cpukit/include/rtems/score/freechain.h b/cpukit/include/rtems/score/freechain.h new file mode 100644 index 0000000000..1540c0e2a1 --- /dev/null +++ b/cpukit/include/rtems/score/freechain.h @@ -0,0 +1,111 @@ +/** + * @file + * + * @ingroup ScoreFreechain + * + * @brief Freechain Handler API + */ +/* + * Copyright (c) 2013 Gedare Bloom. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_FREECHAIN_H +#define _RTEMS_SCORE_FREECHAIN_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ScoreFreechain Freechain Handler + * + * @ingroup Score + * + * The Freechain Handler is used to manage a chain of nodes, of which size can + * automatically increase when there is no free node left. This handler + * provides one data structure: Freechain_Control. + * + * @{ + */ + +/** + * @brief Allocator function. + */ +typedef void *( *Freechain_Allocator )( size_t size ); + +/** + * @brief The freechain control. + */ +typedef struct { + /** + * @brief Chain of free nodes. + */ + Chain_Control Free; +} Freechain_Control; + +/** + * @brief Initializes a freechain. + * + * This routine initializes the freechain control structure to manage a chain + * of nodes. In case the freechain is empty the extend handler is called to + * get more nodes. + * + * @param[in] freechain The freechain control to initialize. + * @param[in] allocator The allocator function. + * @param[in] number_nodes The initial number of nodes. + * @param[in] node_size The node size. + */ +void _Freechain_Initialize( + Freechain_Control *freechain, + Freechain_Allocator allocator, + size_t number_nodes, + size_t node_size +); + +/** + * @brief Gets a node from the freechain. + * + * @param[in] freechain The freechain control. + * @param[in] allocator The allocator function. + * @param[in] number_nodes_to_extend The number of nodes in case an extend is + * necessary due to an empty freechain. + * @param[in] node_size The node size. + * + * @retval NULL The freechain is empty and the extend operation failed. + * @retval otherwise Pointer to a node. The node ownership passes to the + * caller. + */ +void *_Freechain_Get( + Freechain_Control *freechain, + Freechain_Allocator allocator, + size_t number_nodes_to_extend, + size_t node_size +); + +/** + * @brief Puts a node back onto the freechain. + * + * @param[in] freechain The freechain control. + * @param[in] node The node to put back. The node may be @c NULL, in this case + * the function does nothing. + */ +void _Freechain_Put( + Freechain_Control *freechain, + void *node +); + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/heap.h b/cpukit/include/rtems/score/heap.h new file mode 100644 index 0000000000..60cb3be99d --- /dev/null +++ b/cpukit/include/rtems/score/heap.h @@ -0,0 +1,518 @@ +/** + * @file + * + * @ingroup ScoreHeap + * + * @brief Heap Handler API + */ + +/* + * COPYRIGHT (c) 1989-2006. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_HEAP_H +#define _RTEMS_SCORE_HEAP_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef RTEMS_DEBUG + #define HEAP_PROTECTION +#endif + +/** + * @defgroup ScoreHeap Heap Handler + * + * @ingroup Score + * + * @brief The Heap Handler provides a heap. + * + * A heap is a doubly linked list of variable size blocks which are allocated + * using the first fit method. Garbage collection is performed each time a + * block is returned to the heap by coalescing neighbor blocks. Control + * information for both allocated and free blocks is contained in the heap + * area. A heap control structure contains control information for the heap. + * + * The alignment routines could be made faster should we require only powers of + * two to be supported for page size, alignment and boundary arguments. The + * minimum alignment requirement for pages is currently CPU_ALIGNMENT and this + * value is only required to be multiple of two and explicitly not required to + * be a power of two. + * + * There are two kinds of blocks. One sort describes a free block from which + * we can allocate memory. The other blocks are used and provide an allocated + * memory area. The free blocks are accessible via a list of free blocks. + * + * Blocks or areas cover a continuous set of memory addresses. They have a + * begin and end address. The end address is not part of the set. The size of + * a block or area equals the distance between the begin and end address in + * units of bytes. + * + * Free blocks look like: + * + * + * + * + * + * + * + * + * + * + *
@ref Heap_Blockprevious block size in case the + * previous block is free,
otherwise it may contain data used by + * the previous block
block size and a flag which indicates if the previous block is free + * or used,
this field contains always valid data regardless of the + * block usage
pointer to next block (this field is page size aligned)
pointer to previous block
free space
+ * + * Used blocks look like: + * + * + * + * + * + * + * + * + * + * + *
@ref Heap_Blockprevious block size in case the + * previous block is free,
otherwise it may contain data used by + * the previous block
block size and a flag which indicates if the previous block is free + * or used,
this field contains always valid data regardless of the + * block usage
begin of allocated area (this field is page size aligned)
allocated space
allocated space
+ * + * The heap area after initialization contains two blocks and looks like: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
LabelContent
heap->area_beginheap area begin address
first_block->prev_size + * subordinate heap area end address (this will be used to maintain a + * linked list of scattered heap areas) + *
first_block->sizesize available for allocation + * | @c HEAP_PREV_BLOCK_USED
first_block->next_Heap_Free_list_tail(heap)memory area available for allocation
first_block->prev_Heap_Free_list_head(heap)
...
last_block->prev_sizesize of first block
last_block->sizefirst block begin address - last block begin address
heap->area_endheap area end address
+ * The next block of the last block is the first block. Since the first + * block indicates that the previous block is used, this ensures that the + * last block appears as used for the _Heap_Is_used() and _Heap_Is_free() + * functions. + */ +/**@{**/ + +typedef struct Heap_Control Heap_Control; + +typedef struct Heap_Block Heap_Block; + +#ifndef HEAP_PROTECTION + #define HEAP_PROTECTION_HEADER_SIZE 0 +#else + #define HEAP_PROTECTOR_COUNT 2 + + #define HEAP_BEGIN_PROTECTOR_0 ((uintptr_t) 0xfd75a98f) + #define HEAP_BEGIN_PROTECTOR_1 ((uintptr_t) 0xbfa1f177) + #define HEAP_END_PROTECTOR_0 ((uintptr_t) 0xd6b8855e) + #define HEAP_END_PROTECTOR_1 ((uintptr_t) 0x13a44a5b) + + #define HEAP_FREE_PATTERN ((uintptr_t) 0xe7093cdf) + + #define HEAP_PROTECTION_OBOLUS ((Heap_Block *) 1) + + typedef void (*_Heap_Protection_handler)( + Heap_Control *heap, + Heap_Block *block + ); + + typedef struct { + _Heap_Protection_handler block_initialize; + _Heap_Protection_handler block_check; + _Heap_Protection_handler block_error; + void *handler_data; + Heap_Block *first_delayed_free_block; + Heap_Block *last_delayed_free_block; + uintptr_t delayed_free_block_count; + uintptr_t delayed_free_fraction; + } Heap_Protection; + + typedef struct { + uintptr_t protector [HEAP_PROTECTOR_COUNT]; + Heap_Block *next_delayed_free_block; + Thread_Control *task; + void *tag; + } Heap_Protection_block_begin; + + typedef struct { + uintptr_t protector [HEAP_PROTECTOR_COUNT]; + } Heap_Protection_block_end; + + #define HEAP_PROTECTION_HEADER_SIZE \ + (sizeof(Heap_Protection_block_begin) + sizeof(Heap_Protection_block_end)) +#endif + +/** + * @brief The block header consists of the two size fields + * (@ref Heap_Block.prev_size and @ref Heap_Block.size_and_flag). + */ +#define HEAP_BLOCK_HEADER_SIZE \ + (2 * sizeof(uintptr_t) + HEAP_PROTECTION_HEADER_SIZE) + +/** + * @brief Description for free or used blocks. + */ +struct Heap_Block { + /** + * @brief Size of the previous block or part of the allocated area of the + * previous block. + * + * This field is only valid if the previous block is free. This case is + * indicated by a cleared @c HEAP_PREV_BLOCK_USED flag in the + * @a size_and_flag field of the current block. + * + * In a used block only the @a size_and_flag field needs to be valid. The + * @a prev_size field of the current block is maintained by the previous + * block. The current block can use the @a prev_size field in the next block + * for allocation. + */ + uintptr_t prev_size; + + #ifdef HEAP_PROTECTION + Heap_Protection_block_begin Protection_begin; + #endif + + /** + * @brief Contains the size of the current block and a flag which indicates + * if the previous block is free or used. + * + * If the flag @c HEAP_PREV_BLOCK_USED is set, then the previous block is + * used, otherwise the previous block is free. A used previous block may + * claim the @a prev_size field for allocation. This trick allows to + * decrease the overhead in the used blocks by the size of the @a prev_size + * field. As sizes are required to be multiples of two, the least + * significant bits would be always zero. We use this bit to store the flag. + * + * This field is always valid. + */ + uintptr_t size_and_flag; + + #ifdef HEAP_PROTECTION + Heap_Protection_block_end Protection_end; + #endif + + /** + * @brief Pointer to the next free block or part of the allocated area. + * + * This field is page size aligned and begins of the allocated area in case + * the block is used. + * + * This field is only valid if the block is free and thus part of the free + * block list. + */ + Heap_Block *next; + + /** + * @brief Pointer to the previous free block or part of the allocated area. + * + * This field is only valid if the block is free and thus part of the free + * block list. + */ + Heap_Block *prev; +}; + +/** + * @brief Run-time heap statistics. + * + * The value @a searches / @a allocs gives the mean number of searches per + * allocation, while @a max_search gives maximum number of searches ever + * performed on a single allocation call. + */ +typedef struct { + /** + * @brief Lifetime number of bytes allocated from this heap. + * + * This value is an integral multiple of the page size. + */ + uint64_t lifetime_allocated; + + /** + * @brief Lifetime number of bytes freed to this heap. + * + * This value is an integral multiple of the page size. + */ + uint64_t lifetime_freed; + + /** + * @brief Size of the allocatable area in bytes. + * + * This value is an integral multiple of the page size. + */ + uintptr_t size; + + /** + * @brief Current free size in bytes. + * + * This value is an integral multiple of the page size. + */ + uintptr_t free_size; + + /** + * @brief Minimum free size ever in bytes. + * + * This value is an integral multiple of the page size. + */ + uintptr_t min_free_size; + + /** + * @brief Current number of free blocks. + */ + uint32_t free_blocks; + + /** + * @brief Maximum number of free blocks ever. + */ + uint32_t max_free_blocks; + + /** + * @brief Current number of used blocks. + */ + uint32_t used_blocks; + + /** + * @brief Maximum number of blocks searched ever. + */ + uint32_t max_search; + + /** + * @brief Total number of searches. + */ + uint32_t searches; + + /** + * @brief Total number of successful allocations. + */ + uint32_t allocs; + + /** + * @brief Total number of failed allocations. + */ + uint32_t failed_allocs; + + /** + * @brief Total number of successful frees. + */ + uint32_t frees; + + /** + * @brief Total number of successful resizes. + */ + uint32_t resizes; +} Heap_Statistics; + +/** + * @brief Control block used to manage a heap. + */ +struct Heap_Control { + Heap_Block free_list; + uintptr_t page_size; + uintptr_t min_block_size; + uintptr_t area_begin; + uintptr_t area_end; + Heap_Block *first_block; + Heap_Block *last_block; + Heap_Statistics stats; + #ifdef HEAP_PROTECTION + Heap_Protection Protection; + #endif +}; + +/** + * @brief Information about blocks. + */ +typedef struct { + /** + * @brief Number of blocks of this type. + */ + uintptr_t number; + + /** + * @brief Largest block of this type. + */ + uintptr_t largest; + + /** + * @brief Total size of the blocks of this type. + */ + uintptr_t total; +} Heap_Information; + +/** + * @brief Information block returned by _Heap_Get_information(). + */ +typedef struct { + Heap_Information Free; + Heap_Information Used; + Heap_Statistics Stats; +} Heap_Information_block; + +/** + * @brief Heap area structure for table based heap initialization and + * extension. + * + * @see Heap_Initialization_or_extend_handler. + */ +typedef struct { + void *begin; + uintptr_t size; +} Heap_Area; + +/** + * @brief Heap initialization and extend handler type. + * + * This helps to do a table based heap initialization and extension. Create a + * table of Heap_Area elements and iterate through it. Set the handler to + * _Heap_Initialize() in the first iteration and then to _Heap_Extend(). + * + * @see Heap_Area, _Heap_Initialize(), _Heap_Extend(), or _Heap_No_extend(). + */ +typedef uintptr_t (*Heap_Initialization_or_extend_handler)( + Heap_Control *heap, + void *area_begin, + uintptr_t area_size, + uintptr_t page_size_or_unused +); + +/** + * @brief Extends the memory available for the heap @a heap using the memory + * area starting at @a area_begin of size @a area_size bytes. + * + * There are no alignment requirements for the memory area. The memory area + * must be big enough to contain some maintenance blocks. It must not overlap + * parts of the current heap memory areas. Disconnected memory areas added to + * the heap will lead to used blocks which cover the gaps. Extending with an + * inappropriate memory area will corrupt the heap resulting in undefined + * behaviour. + * + * The unused fourth parameter is provided to have the same signature as + * _Heap_Initialize(). + * + * Returns the extended space available for allocation, or zero in case of failure. + * + * @see Heap_Initialization_or_extend_handler. + */ +uintptr_t _Heap_Extend( + Heap_Control *heap, + void *area_begin, + uintptr_t area_size, + uintptr_t unused +); + +/** + * @brief This function returns always zero. + * + * This function only returns zero and does nothing else. + * + * Returns always zero. + * + * @see Heap_Initialization_or_extend_handler. + */ +uintptr_t _Heap_No_extend( + Heap_Control *unused_0, + void *unused_1, + uintptr_t unused_2, + uintptr_t unused_3 +); + +RTEMS_INLINE_ROUTINE uintptr_t _Heap_Align_up( + uintptr_t value, + uintptr_t alignment +) +{ + uintptr_t remainder = value % alignment; + + if ( remainder != 0 ) { + return value - remainder + alignment; + } else { + return value; + } +} + +RTEMS_INLINE_ROUTINE uintptr_t _Heap_Min_block_size( uintptr_t page_size ) +{ + return _Heap_Align_up( sizeof( Heap_Block ), page_size ); +} + +/** + * @brief Returns the worst case overhead to manage a memory area. + */ +RTEMS_INLINE_ROUTINE uintptr_t _Heap_Area_overhead( + uintptr_t page_size +) +{ + if ( page_size != 0 ) { + page_size = _Heap_Align_up( page_size, CPU_ALIGNMENT ); + } else { + page_size = CPU_ALIGNMENT; + } + + return 2 * (page_size - 1) + HEAP_BLOCK_HEADER_SIZE; +} + +/** + * @brief Returns the size with administration and alignment overhead for one + * allocation. + */ +RTEMS_INLINE_ROUTINE uintptr_t _Heap_Size_with_overhead( + uintptr_t page_size, + uintptr_t size, + uintptr_t alignment +) +{ + if ( page_size != 0 ) { + page_size = _Heap_Align_up( page_size, CPU_ALIGNMENT ); + } else { + page_size = CPU_ALIGNMENT; + } + + if ( page_size < alignment ) { + page_size = alignment; + } + + return HEAP_BLOCK_HEADER_SIZE + page_size - 1 + size; +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/heapimpl.h b/cpukit/include/rtems/score/heapimpl.h new file mode 100644 index 0000000000..a8948edd6f --- /dev/null +++ b/cpukit/include/rtems/score/heapimpl.h @@ -0,0 +1,601 @@ +/** + * @file + * + * @ingroup ScoreHeap + * + * @brief Heap Handler Implementation + */ + +/* + * COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_HEAPIMPL_H +#define _RTEMS_SCORE_HEAPIMPL_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup ScoreHeap + */ +/**@{**/ + +/** + * @brief See also @ref Heap_Block.size_and_flag. + */ +#define HEAP_PREV_BLOCK_USED ((uintptr_t) 1) + +/** + * @brief Size of the part at the block begin which may be used for allocation + * in charge of the previous block. + */ +#define HEAP_ALLOC_BONUS sizeof(uintptr_t) + +/** + * @brief See _Heap_Resize_block(). + */ +typedef enum { + HEAP_RESIZE_SUCCESSFUL, + HEAP_RESIZE_UNSATISFIED, + HEAP_RESIZE_FATAL_ERROR +} Heap_Resize_status; + +/** + * @brief Gets the first and last block for the heap area with begin + * @a heap_area_begin and size @a heap_area_size. + * + * A page size of @a page_size and minimal block size of @a min_block_size will + * be used for calculation. + * + * Nothing will be written to this area. + * + * In case of success the pointers to the first and last block will be returned + * via @a first_block_ptr and @a last_block_ptr. + * + * Returns @c true if the area is big enough, and @c false otherwise. + */ +bool _Heap_Get_first_and_last_block( + uintptr_t heap_area_begin, + uintptr_t heap_area_size, + uintptr_t page_size, + uintptr_t min_block_size, + Heap_Block **first_block_ptr, + Heap_Block **last_block_ptr +); + +/** + * @brief Initializes the heap control block @a heap to manage the area + * starting at @a area_begin of size @a area_size bytes. + * + * Blocks of memory are allocated from the heap in multiples of @a page_size + * byte units. If the @a page_size is equal to zero or is not multiple of + * @c CPU_ALIGNMENT, it is aligned up to the nearest @c CPU_ALIGNMENT boundary. + * + * Returns the maximum memory available, or zero in case of failure. + * + * @see Heap_Initialization_or_extend_handler. + */ +uintptr_t _Heap_Initialize( + Heap_Control *heap, + void *area_begin, + uintptr_t area_size, + uintptr_t page_size +); + +/** + * @brief Allocates a memory area of size @a size bytes from the heap @a heap. + * + * If the alignment parameter @a alignment is not equal to zero, the allocated + * memory area will begin at an address aligned by this value. + * + * If the boundary parameter @a boundary is not equal to zero, the allocated + * memory area will fulfill a boundary constraint. The boundary value + * specifies the set of addresses which are aligned by the boundary value. The + * interior of the allocated memory area will not contain an element of this + * set. The begin or end address of the area may be a member of the set. + * + * A size value of zero will return a unique address which may be freed with + * _Heap_Free(). + * + * Returns a pointer to the begin of the allocated memory area, or @c NULL if + * no memory is available or the parameters are inconsistent. + */ +void *_Heap_Allocate_aligned_with_boundary( + Heap_Control *heap, + uintptr_t size, + uintptr_t alignment, + uintptr_t boundary +); + +/** + * @brief See _Heap_Allocate_aligned_with_boundary() with boundary equals zero. + */ +RTEMS_INLINE_ROUTINE void *_Heap_Allocate_aligned( + Heap_Control *heap, + uintptr_t size, + uintptr_t alignment +) +{ + return _Heap_Allocate_aligned_with_boundary( heap, size, alignment, 0 ); +} + +/** + * @brief See _Heap_Allocate_aligned_with_boundary() with alignment and + * boundary equals zero. + */ +RTEMS_INLINE_ROUTINE void *_Heap_Allocate( Heap_Control *heap, uintptr_t size ) +{ + return _Heap_Allocate_aligned_with_boundary( heap, size, 0, 0 ); +} + +/** + * @brief Frees the allocated memory area starting at @a addr in the heap + * @a heap. + * + * Inappropriate values for @a addr may corrupt the heap. + * + * Returns @c true in case of success, and @c false otherwise. + */ +bool _Heap_Free( Heap_Control *heap, void *addr ); + +/** + * @brief Walks the heap @a heap to verify its integrity. + * + * If @a dump is @c true, then diagnostic messages will be printed to standard + * output. In this case @a source is used to mark the output lines. + * + * Returns @c true if no errors occurred, and @c false if the heap is corrupt. + */ +bool _Heap_Walk( + Heap_Control *heap, + int source, + bool dump +); + +/** + * @brief Heap block visitor. + * + * @see _Heap_Iterate(). + * + * @retval true Stop the iteration. + * @retval false Continue the iteration. + */ +typedef bool (*Heap_Block_visitor)( + const Heap_Block *block, + uintptr_t block_size, + bool block_is_used, + void *visitor_arg +); + +/** + * @brief Iterates over all blocks of the heap. + * + * For each block the @a visitor with the argument @a visitor_arg will be + * called. + */ +void _Heap_Iterate( + Heap_Control *heap, + Heap_Block_visitor visitor, + void *visitor_arg +); + +/** + * @brief Greedy allocate that empties the heap. + * + * Afterwards the heap has at most @a block_count allocatable blocks of sizes + * specified by @a block_sizes. The @a block_sizes must point to an array with + * @a block_count members. All other blocks are used. + * + * @see _Heap_Greedy_free(). + */ +Heap_Block *_Heap_Greedy_allocate( + Heap_Control *heap, + const uintptr_t *block_sizes, + size_t block_count +); + +/** + * @brief Greedy allocate all blocks except the largest free block. + * + * Afterwards the heap has at most one allocatable block. This block is the + * largest free block if it exists. The allocatable size of this block is + * stored in @a allocatable_size. All other blocks are used. + * + * @see _Heap_Greedy_free(). + */ +Heap_Block *_Heap_Greedy_allocate_all_except_largest( + Heap_Control *heap, + uintptr_t *allocatable_size +); + +/** + * @brief Frees blocks of a greedy allocation. + * + * The @a blocks must be the return value of _Heap_Greedy_allocate(). + */ +void _Heap_Greedy_free( + Heap_Control *heap, + Heap_Block *blocks +); + +/** + * @brief Returns information about used and free blocks for the heap @a heap + * in @a info. + */ +void _Heap_Get_information( + Heap_Control *heap, + Heap_Information_block *info +); + +/** + * @brief Returns information about free blocks for the heap @a heap in + * @a info. + */ +void _Heap_Get_free_information( + Heap_Control *heap, + Heap_Information *info +); + +/** + * @brief Returns the size of the allocatable memory area starting at @a addr + * in @a size. + * + * The size value may be greater than the initially requested size in + * _Heap_Allocate_aligned_with_boundary(). + * + * Inappropriate values for @a addr will not corrupt the heap, but may yield + * invalid size values. + * + * Returns @a true if successful, and @c false otherwise. + */ +bool _Heap_Size_of_alloc_area( + Heap_Control *heap, + void *addr, + uintptr_t *size +); + +/** + * @brief Resizes the block of the allocated memory area starting at @a addr. + * + * The new memory area will have a size of at least @a size bytes. A resize + * may be impossible and depends on the current heap usage. + * + * The size available for allocation in the current block before the resize + * will be returned in @a old_size. The size available for allocation in + * the resized block will be returned in @a new_size. If the resize was not + * successful, then a value of zero will be returned in @a new_size. + * + * Inappropriate values for @a addr may corrupt the heap. + */ +Heap_Resize_status _Heap_Resize_block( + Heap_Control *heap, + void *addr, + uintptr_t size, + uintptr_t *old_size, + uintptr_t *new_size +); + +/** + * @brief Allocates the memory area starting at @a alloc_begin of size + * @a alloc_size bytes in the block @a block. + * + * The block may be split up into multiple blocks. The previous and next block + * may be used or free. Free block parts which form a vaild new block will be + * inserted into the free list or merged with an adjacent free block. If the + * block is used, they will be inserted after the free list head. If the block + * is free, they will be inserted after the previous block in the free list. + * + * Inappropriate values for @a alloc_begin or @a alloc_size may corrupt the + * heap. + * + * Returns the block containing the allocated memory area. + */ +Heap_Block *_Heap_Block_allocate( + Heap_Control *heap, + Heap_Block *block, + uintptr_t alloc_begin, + uintptr_t alloc_size +); + +#ifndef HEAP_PROTECTION + #define _Heap_Protection_block_initialize( heap, block ) ((void) 0) + #define _Heap_Protection_block_check( heap, block ) ((void) 0) + #define _Heap_Protection_block_error( heap, block ) ((void) 0) + #define _Heap_Protection_free_all_delayed_blocks( heap ) ((void) 0) +#else + static inline void _Heap_Protection_block_initialize( + Heap_Control *heap, + Heap_Block *block + ) + { + (*heap->Protection.block_initialize)( heap, block ); + } + + static inline void _Heap_Protection_block_check( + Heap_Control *heap, + Heap_Block *block + ) + { + (*heap->Protection.block_check)( heap, block ); + } + + static inline void _Heap_Protection_block_error( + Heap_Control *heap, + Heap_Block *block + ) + { + (*heap->Protection.block_error)( heap, block ); + } + + static inline void _Heap_Protection_free_all_delayed_blocks( Heap_Control *heap ) + { + uintptr_t large = 0 + - (uintptr_t) HEAP_BLOCK_HEADER_SIZE + - (uintptr_t) HEAP_ALLOC_BONUS + - (uintptr_t) 1; + void *p = _Heap_Allocate( heap, large ); + _Heap_Free( heap, p ); + } +#endif + +/** + * @brief Sets the fraction of delayed free blocks that is actually freed + * during memory shortage. + * + * The default is to free half the delayed free blocks. This is equal to a + * fraction value of two. + * + * @param[in] heap The heap control. + * @param[in] fraction The fraction is one divided by this fraction value. + */ +RTEMS_INLINE_ROUTINE void _Heap_Protection_set_delayed_free_fraction( + Heap_Control *heap, + uintptr_t fraction +) +{ +#ifdef HEAP_PROTECTION + heap->Protection.delayed_free_fraction = fraction; +#else + (void) heap; + (void) fraction; +#endif +} + +RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Free_list_head( Heap_Control *heap ) +{ + return &heap->free_list; +} + +RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Free_list_tail( Heap_Control *heap ) +{ + return &heap->free_list; +} + +RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Free_list_first( Heap_Control *heap ) +{ + return _Heap_Free_list_head(heap)->next; +} + +RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Free_list_last( Heap_Control *heap ) +{ + return _Heap_Free_list_tail(heap)->prev; +} + +RTEMS_INLINE_ROUTINE void _Heap_Free_list_remove( Heap_Block *block ) +{ + Heap_Block *next = block->next; + Heap_Block *prev = block->prev; + + prev->next = next; + next->prev = prev; +} + +RTEMS_INLINE_ROUTINE void _Heap_Free_list_replace( + Heap_Block *old_block, + Heap_Block *new_block +) +{ + Heap_Block *next = old_block->next; + Heap_Block *prev = old_block->prev; + + new_block->next = next; + new_block->prev = prev; + + next->prev = new_block; + prev->next = new_block; +} + +RTEMS_INLINE_ROUTINE void _Heap_Free_list_insert_after( + Heap_Block *block_before, + Heap_Block *new_block +) +{ + Heap_Block *next = block_before->next; + + new_block->next = next; + new_block->prev = block_before; + block_before->next = new_block; + next->prev = new_block; +} + +RTEMS_INLINE_ROUTINE void _Heap_Free_list_insert_before( + Heap_Block *block_next, + Heap_Block *new_block +) +{ + Heap_Block *prev = block_next->prev; + + new_block->next = block_next; + new_block->prev = prev; + prev->next = new_block; + block_next->prev = new_block; +} + +RTEMS_INLINE_ROUTINE bool _Heap_Is_aligned( + uintptr_t value, + uintptr_t alignment +) +{ + return (value % alignment) == 0; +} + +RTEMS_INLINE_ROUTINE uintptr_t _Heap_Align_down( + uintptr_t value, + uintptr_t alignment +) +{ + return value - (value % alignment); +} + +/** + * @brief Returns the block which is @a offset away from @a block. + */ +RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Block_at( + const Heap_Block *block, + uintptr_t offset +) +{ + return (Heap_Block *) ((uintptr_t) block + offset); +} + +RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Prev_block( + const Heap_Block *block +) +{ + return (Heap_Block *) ((uintptr_t) block - block->prev_size); +} + +RTEMS_INLINE_ROUTINE uintptr_t _Heap_Alloc_area_of_block( + const Heap_Block *block +) +{ + return (uintptr_t) block + HEAP_BLOCK_HEADER_SIZE; +} + +RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Block_of_alloc_area( + uintptr_t alloc_begin, + uintptr_t page_size +) +{ + return (Heap_Block *) (_Heap_Align_down( alloc_begin, page_size ) + - HEAP_BLOCK_HEADER_SIZE); +} + +RTEMS_INLINE_ROUTINE uintptr_t _Heap_Block_size( const Heap_Block *block ) +{ + return block->size_and_flag & ~HEAP_PREV_BLOCK_USED; +} + +RTEMS_INLINE_ROUTINE void _Heap_Block_set_size( + Heap_Block *block, + uintptr_t size +) +{ + uintptr_t flag = block->size_and_flag & HEAP_PREV_BLOCK_USED; + + block->size_and_flag = size | flag; +} + +RTEMS_INLINE_ROUTINE bool _Heap_Is_prev_used( const Heap_Block *block ) +{ + return block->size_and_flag & HEAP_PREV_BLOCK_USED; +} + +RTEMS_INLINE_ROUTINE bool _Heap_Is_used( + const Heap_Block *block +) +{ + const Heap_Block *const next_block = + _Heap_Block_at( block, _Heap_Block_size( block ) ); + + return _Heap_Is_prev_used( next_block ); +} + +RTEMS_INLINE_ROUTINE bool _Heap_Is_free( + const Heap_Block *block +) +{ + return !_Heap_Is_used( block ); +} + +RTEMS_INLINE_ROUTINE bool _Heap_Is_block_in_heap( + const Heap_Control *heap, + const Heap_Block *block +) +{ + return (uintptr_t) block >= (uintptr_t) heap->first_block + && (uintptr_t) block <= (uintptr_t) heap->last_block; +} + +/** + * @brief Sets the size of the last block for heap @a heap. + * + * The next block of the last block will be the first block. Since the first + * block indicates that the previous block is used, this ensures that the last + * block appears as used for the _Heap_Is_used() and _Heap_Is_free() + * functions. + * + * This feature will be used to terminate the scattered heap area list. See + * also _Heap_Extend(). + */ +RTEMS_INLINE_ROUTINE void _Heap_Set_last_block_size( Heap_Control *heap ) +{ + _Heap_Block_set_size( + heap->last_block, + (uintptr_t) heap->first_block - (uintptr_t) heap->last_block + ); +} + +/** + * @brief Returns the size of the allocatable area in bytes. + * + * This value is an integral multiple of the page size. + */ +RTEMS_INLINE_ROUTINE uintptr_t _Heap_Get_size( const Heap_Control *heap ) +{ + return heap->stats.size; +} + +RTEMS_INLINE_ROUTINE uintptr_t _Heap_Max( uintptr_t a, uintptr_t b ) +{ + return a > b ? a : b; +} + +RTEMS_INLINE_ROUTINE uintptr_t _Heap_Min( uintptr_t a, uintptr_t b ) +{ + return a < b ? a : b; +} + +#ifdef RTEMS_DEBUG + #define RTEMS_HEAP_DEBUG +#endif + +#ifdef RTEMS_HEAP_DEBUG + #include + #define _HAssert( cond ) \ + do { \ + if ( !(cond) ) { \ + __assert( __FILE__, __LINE__, #cond ); \ + } \ + } while (0) +#else + #define _HAssert( cond ) ((void) 0) +#endif + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/interr.h b/cpukit/include/rtems/score/interr.h new file mode 100644 index 0000000000..3144952716 --- /dev/null +++ b/cpukit/include/rtems/score/interr.h @@ -0,0 +1,268 @@ +/** + * @file rtems/score/interr.h + * + * @brief Constants and Prototypes Related to the Internal Error Handler + * + * This include file contains constants and prototypes related + * to the Internal Error Handler. + */ + +/* + * COPYRIGHT (c) 1989-2009. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_INTERR_H +#define _RTEMS_SCORE_INTERR_H + +#include +#include + +#include + +/** + * @defgroup ScoreIntErr Internal Error Handler + * + * @ingroup Score + * + * This handler encapsulates functionality which provides the foundation + * Semaphore services used in all of the APIs supported by RTEMS. + */ +/**@{*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief This type lists the possible sources from which an error + * can be reported. + */ +typedef enum { + /** + * @brief Errors of the core system. + * + * @see Internal_errors_Core_list. + */ + INTERNAL_ERROR_CORE = 0, + + /** + * @brief Errors of the RTEMS API. + */ + INTERNAL_ERROR_RTEMS_API = 1, + + /** + * @brief Errors of the POSIX API. + */ + INTERNAL_ERROR_POSIX_API = 2, + + /** + * @brief Fatal source for the block device cache. + * + * @see rtems_bdbuf_fatal_code. + */ + RTEMS_FATAL_SOURCE_BDBUF = 3, + + /** + * @brief Fatal source for application specific errors. + * + * The fatal code is application specific. + */ + RTEMS_FATAL_SOURCE_APPLICATION = 4, + + /** + * @brief Fatal source of exit(). + * + * The fatal code is the exit() status code. + */ + RTEMS_FATAL_SOURCE_EXIT = 5, + + /** + * @brief Fatal source for BSP errors. + * + * The fatal codes are defined in . Examples are interrupt and + * exception initialization. + * + * @see bsp_fatal_code and bsp_fatal(). + */ + RTEMS_FATAL_SOURCE_BSP = 6, + + /** + * @brief Fatal source of assert(). + * + * The fatal code is the pointer value of the assert context. + * + * @see rtems_assert_context. + */ + RTEMS_FATAL_SOURCE_ASSERT = 7, + + /** + * @brief Fatal source of the stack checker. + * + * The fatal code is the object name of the executing task. + */ + RTEMS_FATAL_SOURCE_STACK_CHECKER = 8, + + /** + * @brief Fatal source of the exceptions. + * + * The fatal code is the pointer value of the exception frame pointer. + * + * @see rtems_exception_frame and rtems_exception_frame_print(). + */ + RTEMS_FATAL_SOURCE_EXCEPTION = 9, + + /** + * @brief Fatal source of SMP domain. + * + * @see SMP_Fatal_code. + */ + RTEMS_FATAL_SOURCE_SMP = 10, + + /** + * @brief Fatal source of rtems_panic(). + * + * @see rtem + */ + RTEMS_FATAL_SOURCE_PANIC = 11, + + /** + * @brief The last available fatal source. + * + * This enum value ensures that the enum type needs at least 32-bits for + * architectures with short enums. + */ + RTEMS_FATAL_SOURCE_LAST = 0xffffffff +} Internal_errors_Source; + +/** + * @brief A list of errors which are generated internally by the executive + * core. + * + * Do not re-use numbers of obsolete error codes. Uncomment no longer used + * error codes. + */ +typedef enum { + /* INTERNAL_ERROR_NO_CONFIGURATION_TABLE = 0, */ + /* INTERNAL_ERROR_NO_CPU_TABLE = 1, */ + INTERNAL_ERROR_TOO_LITTLE_WORKSPACE = 2, + INTERNAL_ERROR_WORKSPACE_ALLOCATION = 3, + INTERNAL_ERROR_INTERRUPT_STACK_TOO_SMALL = 4, + INTERNAL_ERROR_THREAD_EXITTED = 5, + INTERNAL_ERROR_INCONSISTENT_MP_INFORMATION = 6, + INTERNAL_ERROR_INVALID_NODE = 7, + INTERNAL_ERROR_NO_MPCI = 8, + INTERNAL_ERROR_BAD_PACKET = 9, + INTERNAL_ERROR_OUT_OF_PACKETS = 10, + INTERNAL_ERROR_OUT_OF_GLOBAL_OBJECTS = 11, + INTERNAL_ERROR_OUT_OF_PROXIES = 12, + INTERNAL_ERROR_INVALID_GLOBAL_ID = 13, + INTERNAL_ERROR_BAD_STACK_HOOK = 14, + /* INTERNAL_ERROR_BAD_ATTRIBUTES = 15, */ + /* INTERNAL_ERROR_IMPLEMENTATION_KEY_CREATE_INCONSISTENCY = 16, */ + /* INTERNAL_ERROR_IMPLEMENTATION_BLOCKING_OPERATION_CANCEL = 17, */ + /* INTERNAL_ERROR_THREAD_QUEUE_ENQUEUE_FROM_BAD_STATE = 18, */ + INTERNAL_ERROR_UNLIMITED_AND_MAXIMUM_IS_0 = 19, + /* INTERNAL_ERROR_SHUTDOWN_WHEN_NOT_UP = 20, */ + INTERNAL_ERROR_GXX_KEY_ADD_FAILED = 21, + INTERNAL_ERROR_GXX_MUTEX_INIT_FAILED = 22, + INTERNAL_ERROR_NO_MEMORY_FOR_HEAP = 23, + INTERNAL_ERROR_CPU_ISR_INSTALL_VECTOR = 24, + INTERNAL_ERROR_RESOURCE_IN_USE = 25, + INTERNAL_ERROR_RTEMS_INIT_TASK_ENTRY_IS_NULL = 26, + /* INTERNAL_ERROR_POSIX_INIT_THREAD_ENTRY_IS_NULL = 27, */ + INTERNAL_ERROR_THREAD_QUEUE_DEADLOCK = 28, + INTERNAL_ERROR_THREAD_QUEUE_ENQUEUE_STICKY_FROM_BAD_STATE = 29, + INTERNAL_ERROR_BAD_THREAD_DISPATCH_DISABLE_LEVEL = 30, + INTERNAL_ERROR_BAD_THREAD_DISPATCH_ENVIRONMENT = 31, + INTERNAL_ERROR_RTEMS_INIT_TASK_CREATE_FAILED = 32, + INTERNAL_ERROR_POSIX_INIT_THREAD_CREATE_FAILED = 33, + INTERNAL_ERROR_LIBIO_USER_ENV_KEY_CREATE_FAILED = 34, + /* INTERNAL_ERROR_LIBIO_SEM_CREATE_FAILED = 35, */ + INTERNAL_ERROR_LIBIO_STDOUT_FD_OPEN_FAILED = 36, + INTERNAL_ERROR_LIBIO_STDERR_FD_OPEN_FAILED = 37, + INTERNAL_ERROR_ILLEGAL_USE_OF_FLOATING_POINT_UNIT = 38, + INTERNAL_ERROR_ARC4RANDOM_GETENTROPY_FAIL = 39 +} Internal_errors_Core_list; + +typedef CPU_Uint32ptr Internal_errors_t; + +/** + * This type holds the fatal error information. + */ +typedef struct { + /** This is the source of the error. */ + Internal_errors_Source the_source; + /** This is the error code. */ + Internal_errors_t the_error; +} Internal_errors_Information; + +/** + * When a fatal error occurs, the error information is stored here. + */ +extern Internal_errors_Information _Internal_errors_What_happened; + +/** + * @brief Initiates system termination. + * + * This routine is invoked when the application or the executive itself + * determines that a fatal error has occurred or a final system state is + * reached (for example after exit()). + * + * The first action of this function is to call the fatal handler of the user + * extensions. For the initial extensions the following conditions are + * required + * - a valid stack pointer and enough stack space, + * - a valid code memory, and + * - valid read-only data. + * + * For the initial extensions the read-write data (including BSS segment) is + * not required on single processor configurations. On SMP configurations + * however the read-write data must be initialized since this function must + * determine the state of the other processors and request them to shut-down if + * necessary. + * + * Non-initial extensions require in addition valid read-write data. The BSP + * may install an initial extension that performs a system reset. In this case + * the non-initial extensions will be not called. + * + * Once all fatal handler executed the error information will be stored to + * _Internal_errors_What_happened and the system state is set to + * SYSTEM_STATE_TERMINATED. + * + * The final step is to call the CPU specific _CPU_Fatal_halt(). + * + * @param[in] the_source The fatal source indicating the subsystem the fatal + * condition originated in. + * @param[in] the_error The fatal error code. This value must be interpreted + * with respect to the source. + * + * @see rtems_fatal() and _Internal_error(). + */ +void _Terminate( + Internal_errors_Source the_source, + Internal_errors_t the_error +) RTEMS_NO_RETURN; + +/** + * @brief Terminates the system with an INTERNAL_ERROR_CORE fatal source and + * the specified core error code. + * + * @param[in] core_error The core error code. + * + * @see _Terminate(). + */ +void _Internal_error( Internal_errors_Core_list core_error ) RTEMS_NO_RETURN; + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/io.h b/cpukit/include/rtems/score/io.h new file mode 100644 index 0000000000..ae3c57f031 --- /dev/null +++ b/cpukit/include/rtems/score/io.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2017 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_IO_H +#define _RTEMS_SCORE_IO_H + +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +typedef void ( *IO_Put_char )(int c, void *arg); + +int _IO_Printf( + IO_Put_char put_char, + void *arg, + char const *fmt, + ... +) RTEMS_PRINTFLIKE( 3, 4 ); + +int _IO_Vprintf( + IO_Put_char put_char, + void *arg, + char const *fmt, + va_list ap +); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_SCORE_IO_H */ diff --git a/cpukit/include/rtems/score/isr.h b/cpukit/include/rtems/score/isr.h new file mode 100644 index 0000000000..d9c03b807f --- /dev/null +++ b/cpukit/include/rtems/score/isr.h @@ -0,0 +1,155 @@ +/** + * @file rtems/score/isr.h + * + * @brief Data Related to the Management of Processor Interrupt Levels + * + * This include file contains all the constants and structures associated + * with the management of processor interrupt levels. This handler + * supports interrupt critical sections, vectoring of user interrupt + * handlers, nesting of interrupts, and manipulating interrupt levels. + */ + +/* + * COPYRIGHT (c) 1989-2012. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_ISR_H +#define _RTEMS_SCORE_ISR_H + +#include + +/** + * @defgroup ScoreISR ISR Handler + * + * @ingroup Score + * + * This handler encapsulates functionality which provides the foundation + * ISR services used in all of the APIs supported by RTEMS. + * + * The ISR Nest level counter variable is maintained as part of the + * per cpu data structure. + */ +/**@{*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The following type defines the type used to manage the vectors. + */ +typedef uint32_t ISR_Vector_number; + +/** + * Return type for ISR Handler + */ +typedef void ISR_Handler; + +#if (CPU_SIMPLE_VECTORED_INTERRUPTS == FALSE) + +typedef void * ISR_Handler_entry; + +#else +/** + * Pointer to an ISR Handler + */ +#if (CPU_ISR_PASSES_FRAME_POINTER == TRUE) +typedef ISR_Handler ( *ISR_Handler_entry )( + ISR_Vector_number, + CPU_Interrupt_frame * + ); +#else +typedef ISR_Handler ( *ISR_Handler_entry )( + ISR_Vector_number + ); +#endif + +/** + * The following declares the Vector Table. Application + * interrupt service routines are vectored by the ISR Handler via this table. + */ +extern ISR_Handler_entry _ISR_Vector_table[ CPU_INTERRUPT_NUMBER_OF_VECTORS ]; +#endif + +/** + * @brief Initialize the ISR handler. + * + * This routine performs the initialization necessary for the ISR handler. + */ +void _ISR_Handler_initialization ( void ); + +/** + * @brief Install interrupt handler vector. + * + * This routine installs new_handler as the interrupt service routine + * for the specified vector. The previous interrupt service routine is + * returned as old_handler. + * + * LM32 Specific Information: + * XXX document implementation including references if appropriate + * + * @param[in] _vector is the vector number + * @param[in] _new_handler is ISR handler to install + * @param[in] _old_handler is a pointer to a variable which will be set + * to the old handler + * + * @retval *_old_handler will be set to the old ISR handler + */ +#define _ISR_Install_vector( _vector, _new_handler, _old_handler ) \ + _CPU_ISR_install_vector( _vector, _new_handler, _old_handler ) + +/** + * @brief ISR interrupt dispatcher. + * + * This routine is the interrupt dispatcher. ALL interrupts + * are vectored to this routine so that minimal context can be saved + * and setup performed before the application's high-level language + * interrupt service routine is invoked. After the application's + * interrupt service routine returns control to this routine, it + * will determine if a thread dispatch is necessary. If so, it will + * ensure that the necessary thread scheduling operations are + * performed when the outermost interrupt service routine exits. + * + * @note Typically implemented in assembly language. + */ +void _ISR_Handler( void ); + +/** + * @brief ISR wrapper for thread dispatcher. + * + * This routine provides a wrapper so that the routine + * @ref _Thread_Dispatch can be invoked when a reschedule is necessary + * at the end of the outermost interrupt service routine. This + * wrapper is necessary to establish the processor context needed + * by _Thread_Dispatch and to save the processor context which is + * corrupted by _Thread_Dispatch. This context typically consists + * of registers which are not preserved across routine invocations. + * + * @note Typically mplemented in assembly language. + */ +void _ISR_Dispatch( void ); + +/** + * @brief Checks if an ISR in progress. + * + * This function returns true if the processor is currently servicing + * and interrupt and false otherwise. A return value of true indicates + * that the caller is an interrupt service routine, NOT a thread. + * + * @retval This methods returns true when called from an ISR. + */ +bool _ISR_Is_in_progress( void ); + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/isrlevel.h b/cpukit/include/rtems/score/isrlevel.h new file mode 100644 index 0000000000..abfb1b67fc --- /dev/null +++ b/cpukit/include/rtems/score/isrlevel.h @@ -0,0 +1,153 @@ +/** + * @file rtems/score/isrlevel.h + * + * @brief ISR Level Type + * + * This include file defines the ISR Level type. It exists to + * simplify include dependencies. It is part of the ISR Handler. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_ISR_LEVEL_h +#define _RTEMS_SCORE_ISR_LEVEL_h + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ScoreISR ISR Handler + * + * @ingroup Score + * + * @addtogroup ScoreISR ISR Handler + */ +/**@{*/ + +/** + * The following type defines the control block used to manage + * the interrupt level portion of the status register. + */ +typedef uint32_t ISR_Level; + +/** + * @brief Disables interrupts on this processor. + * + * This macro disables all interrupts on this processor so that a critical + * section of code is protected from concurrent access by interrupts of this + * processor. Disabling of interrupts disables thread dispatching on the + * processor as well. + * + * On SMP configurations other processors can enter such sections if not + * protected by other means. + * + * @param[out] _level The argument @a _level will contain the previous + * interrupt mask level. + */ +#define _ISR_Local_disable( _level ) \ + do { \ + _CPU_ISR_Disable( _level ); \ + RTEMS_COMPILER_MEMORY_BARRIER(); \ + } while (0) + +/** + * @brief Enables interrupts on this processor. + * + * This macro restores the interrupt status on the processor with the + * interrupt level value obtained by _ISR_Local_disable(). It is used at the end of + * a critical section of code to enable interrupts so they can be processed + * again. + * + * @param[in] _level The interrupt level previously obtained by + * _ISR_Local_disable(). + */ +#define _ISR_Local_enable( _level ) \ + do { \ + RTEMS_COMPILER_MEMORY_BARRIER(); \ + _CPU_ISR_Enable( _level ); \ + } while (0) + +/** + * @brief Temporarily enables interrupts on this processor. + * + * This macro temporarily enables interrupts to the previous + * interrupt mask level and then disables all interrupts so that + * the caller can continue into the second part of a critical + * section. + * + * This routine is used to temporarily enable interrupts + * during a long critical section. It is used in long sections of + * critical code when a point is reached at which interrupts can + * be temporarily enabled. Deciding where to flash interrupts + * in a long critical section is often difficult and the point + * must be selected with care to ensure that the critical section + * properly protects itself. + * + * @param[in] _level The interrupt level previously obtained by + * _ISR_Local_disable(). + */ +#define _ISR_Local_flash( _level ) \ + do { \ + RTEMS_COMPILER_MEMORY_BARRIER(); \ + _CPU_ISR_Flash( _level ); \ + RTEMS_COMPILER_MEMORY_BARRIER(); \ + } while (0) + +/** + * @brief Returns true if interrupts are enabled in the specified interrupt + * level, otherwise returns false. + * + * @param[in] _level The ISR level. + * + * @retval true Interrupts are enabled in the interrupt level. + * @retval false Otherwise. + */ +#define _ISR_Is_enabled( _level ) \ + _CPU_ISR_Is_enabled( _level ) + +/** + * @brief Return current interrupt level. + * + * This routine returns the current interrupt level. + * + * LM32 Specific Information: + * XXX document implementation including references if appropriate + * + * @retval This method returns the current level. + */ +#define _ISR_Get_level() \ + _CPU_ISR_Get_level() + +/** + * @brief Set current interrupt level. + * + * This routine sets the current interrupt level to that specified + * by @a _new_level. The new interrupt level is effective when the + * routine exits. + * + * @param[in] _new_level contains the desired interrupt level. + */ +#define _ISR_Set_level( _new_level ) \ + do { \ + RTEMS_COMPILER_MEMORY_BARRIER(); \ + _CPU_ISR_Set_level( _new_level ); \ + RTEMS_COMPILER_MEMORY_BARRIER(); \ + } while (0) + +/**@}*/ + +#ifdef __cplusplus +} +#endif +#endif diff --git a/cpukit/include/rtems/score/isrlock.h b/cpukit/include/rtems/score/isrlock.h new file mode 100644 index 0000000000..7dd2f29000 --- /dev/null +++ b/cpukit/include/rtems/score/isrlock.h @@ -0,0 +1,439 @@ +/** + * @file + * + * @ingroup ScoreISRLocks + * + * @brief ISR Locks + */ + +/* + * Copyright (c) 2013-2015 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_ISR_LOCK_H +#define _RTEMS_SCORE_ISR_LOCK_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ScoreISRLocks ISR Locks + * + * @ingroup ScoreISR + * + * @brief Low-level lock to protect critical sections accessed by threads and + * interrupt service routines. + * + * On single processor configurations the ISR locks degrade to simple ISR + * disable/enable sequences. No additional storage or objects are required. + * + * This synchronization primitive is supported on SMP configurations. Here SMP + * locks are used. + * + * @{ + */ + +/** + * @brief ISR lock control. + * + * @warning Empty structures are implementation-defined in C. GCC gives them a + * size of zero. In C++ empty structures have a non-zero size. + */ +typedef struct { +#if defined( RTEMS_SMP ) + SMP_lock_Control Lock; +#endif +} ISR_lock_Control; + +/** + * @brief Local ISR lock context for acquire and release pairs. + */ +typedef struct { +#if defined( RTEMS_SMP ) + SMP_lock_Context Lock_context; +#else + ISR_Level isr_level; +#endif +#if defined( RTEMS_PROFILING ) + /** + * @brief The last interrupt disable instant in CPU counter ticks. + */ + CPU_Counter_ticks ISR_disable_instant; +#endif +} ISR_lock_Context; + +/** + * @brief Defines an ISR lock member. + * + * Do not add a ';' after this macro. + * + * @param _designator The designator for the interrupt lock. + */ +#if defined( RTEMS_SMP ) + #define ISR_LOCK_MEMBER( _designator ) ISR_lock_Control _designator; +#else + #define ISR_LOCK_MEMBER( _designator ) +#endif + +/** + * @brief Declares an ISR lock variable. + * + * Do not add a ';' after this macro. + * + * @param _qualifier The qualifier for the interrupt lock, e.g. extern. + * @param _designator The designator for the interrupt lock. + */ +#if defined( RTEMS_SMP ) + #define ISR_LOCK_DECLARE( _qualifier, _designator ) \ + _qualifier ISR_lock_Control _designator; +#else + #define ISR_LOCK_DECLARE( _qualifier, _designator ) +#endif + +/** + * @brief Defines an ISR lock variable. + * + * Do not add a ';' after this macro. + * + * @param _qualifier The qualifier for the interrupt lock, e.g. static. + * @param _designator The designator for the interrupt lock. + * @param _name The name for the interrupt lock. It must be a string. The + * name is only used if profiling is enabled. + */ +#if defined( RTEMS_SMP ) + #define ISR_LOCK_DEFINE( _qualifier, _designator, _name ) \ + _qualifier ISR_lock_Control _designator = { SMP_LOCK_INITIALIZER( _name ) }; +#else + #define ISR_LOCK_DEFINE( _qualifier, _designator, _name ) +#endif + +/** + * @brief Defines an ISR lock variable reference. + * + * Do not add a ';' after this macro. + * + * @param _designator The designator for the interrupt lock reference. + * @param _target The target for the interrupt lock reference. + */ +#if defined( RTEMS_SMP ) + #define ISR_LOCK_REFERENCE( _designator, _target ) \ + ISR_lock_Control *_designator = _target; +#else + #define ISR_LOCK_REFERENCE( _designator, _target ) +#endif + +/** + * @brief Initializer for static initialization of ISR locks. + * + * @param _name The name for the interrupt lock. It must be a string. The + * name is only used if profiling is enabled. + */ +#if defined( RTEMS_SMP ) + #define ISR_LOCK_INITIALIZER( _name ) \ + { SMP_LOCK_INITIALIZER( _name ) } +#else + #define ISR_LOCK_INITIALIZER( _name ) \ + { } +#endif + +/** + * @brief Sets the ISR level in the ISR lock context. + * + * @param[in] context The ISR lock context. + * @param[in] level The ISR level. + */ +RTEMS_INLINE_ROUTINE void _ISR_lock_Context_set_level( + ISR_lock_Context *context, + ISR_Level level +) +{ +#if defined( RTEMS_SMP ) + context->Lock_context.isr_level = level; +#else + context->isr_level = level; +#endif +} + +/** + * @brief Initializes an ISR lock. + * + * Concurrent initialization leads to unpredictable results. + * + * @param[in] _lock The ISR lock control. + * @param[in] _name The name for the ISR lock. This name must be a + * string persistent throughout the life time of this lock. The name is only + * used if profiling is enabled. + */ +#if defined( RTEMS_SMP ) + #define _ISR_lock_Initialize( _lock, _name ) \ + _SMP_lock_Initialize( &( _lock )->Lock, _name ) +#else + #define _ISR_lock_Initialize( _lock, _name ) +#endif + +/** + * @brief Destroys an ISR lock. + * + * Concurrent destruction leads to unpredictable results. + * + * @param[in] _lock The ISR lock control. + */ +#if defined( RTEMS_SMP ) + #define _ISR_lock_Destroy( _lock ) \ + _SMP_lock_Destroy( &( _lock )->Lock ) +#else + #define _ISR_lock_Destroy( _lock ) +#endif + +/** + * @brief Acquires an ISR lock. + * + * Interrupts will be disabled. On SMP configurations this function acquires + * an SMP lock. + * + * This function can be used in thread and interrupt context. + * + * @param[in] _lock The ISR lock control. + * @param[in] _context The local ISR lock context for an acquire and release + * pair. + * + * @see _ISR_lock_Release_and_ISR_enable(). + */ +#if defined( RTEMS_SMP ) + #define _ISR_lock_ISR_disable_and_acquire( _lock, _context ) \ + _SMP_lock_ISR_disable_and_acquire( \ + &( _lock )->Lock, \ + &( _context )->Lock_context \ + ) +#else + #define _ISR_lock_ISR_disable_and_acquire( _lock, _context ) \ + _ISR_Local_disable( ( _context )->isr_level ) +#endif + +/** + * @brief Releases an ISR lock. + * + * The interrupt status will be restored. On SMP configurations this function + * releases an SMP lock. + * + * This function can be used in thread and interrupt context. + * + * @param[in] _lock The ISR lock control. + * @param[in] _context The local ISR lock context for an acquire and release + * pair. + * + * @see _ISR_lock_ISR_disable_and_acquire(). + */ +#if defined( RTEMS_SMP ) + #define _ISR_lock_Release_and_ISR_enable( _lock, _context ) \ + _SMP_lock_Release_and_ISR_enable( \ + &( _lock )->Lock, \ + &( _context )->Lock_context \ + ) +#else + #define _ISR_lock_Release_and_ISR_enable( _lock, _context ) \ + _ISR_Local_enable( ( _context )->isr_level ) +#endif + +/** + * @brief Acquires an ISR lock inside an ISR disabled section. + * + * The interrupt status will remain unchanged. On SMP configurations this + * function acquires an SMP lock. + * + * In case the executing context can be interrupted by higher priority + * interrupts and these interrupts enter the critical section protected by this + * lock, then the result is unpredictable. + * + * @param[in] _lock The ISR lock control. + * @param[in] _context The local ISR lock context for an acquire and release + * pair. + * + * @see _ISR_lock_Release(). + */ +#if defined( RTEMS_SMP ) + #define _ISR_lock_Acquire( _lock, _context ) \ + _SMP_lock_Acquire( \ + &( _lock )->Lock, \ + &( _context )->Lock_context \ + ) +#else + #define _ISR_lock_Acquire( _lock, _context ) \ + (void) _context; +#endif + +/** + * @brief Releases an ISR lock inside an ISR disabled section. + * + * The interrupt status will remain unchanged. On SMP configurations this + * function releases an SMP lock. + * + * @param[in] _lock The ISR lock control. + * @param[in] _context The local ISR lock context for an acquire and release + * pair. + * + * @see _ISR_lock_Acquire(). + */ +#if defined( RTEMS_SMP ) + #define _ISR_lock_Release( _lock, _context ) \ + _SMP_lock_Release( \ + &( _lock )->Lock, \ + &( _context )->Lock_context \ + ) +#else + #define _ISR_lock_Release( _lock, _context ) \ + (void) _context; +#endif + +/** + * @brief Acquires an ISR lock inside an ISR disabled section (inline). + * + * @see _ISR_lock_Acquire(). + */ +#if defined( RTEMS_SMP ) + #define _ISR_lock_Acquire_inline( _lock, _context ) \ + _SMP_lock_Acquire_inline( \ + &( _lock )->Lock, \ + &( _context )->Lock_context \ + ) +#else + #define _ISR_lock_Acquire_inline( _lock, _context ) \ + (void) _context; +#endif + +/** + * @brief Releases an ISR lock inside an ISR disabled section (inline). + * + * @see _ISR_lock_Release(). + */ +#if defined( RTEMS_SMP ) + #define _ISR_lock_Release_inline( _lock, _context ) \ + _SMP_lock_Release_inline( \ + &( _lock )->Lock, \ + &( _context )->Lock_context \ + ) +#else + #define _ISR_lock_Release_inline( _lock, _context ) \ + (void) _context; +#endif + +#if defined( RTEMS_DEBUG ) + /** + * @brief Returns true, if the ISR lock is owned by the current processor, + * otherwise false. + * + * On uni-processor configurations, this function returns true, if interrupts + * are disabled, otherwise false. + * + * @param[in] _lock The ISR lock control. + */ + #if defined( RTEMS_SMP ) + #define _ISR_lock_Is_owner( _lock ) \ + _SMP_lock_Is_owner( &( _lock )->Lock ) + #else + #define _ISR_lock_Is_owner( _lock ) \ + ( _ISR_Get_level() != 0 ) + #endif +#endif + +/** + * @brief Flashes an ISR lock. + * + * On uni-processor configurations this a simple _ISR_Local_flash(). On SMP + * configurations this function releases an SMP lock, restores the interrupt + * status, then disables interrupts and acquires the SMP lock again. + * + * This function can be used in thread and interrupt context. + * + * @param[in] _lock The ISR lock control. + * @param[in] _context The local ISR lock context for an acquire and release + * pair. + * + * @see _ISR_lock_ISR_disable_and_acquire() and + * _ISR_lock_Release_and_ISR_enable(). + */ +#if defined( RTEMS_SMP ) + #define _ISR_lock_Flash( _lock, _context ) \ + _SMP_lock_Release_and_ISR_enable( \ + &( _lock )->Lock, \ + &( _context )->Lock_context \ + ); \ + _SMP_lock_ISR_disable_and_acquire( \ + &( _lock )->Lock, \ + &( _context )->Lock_context \ + ) +#else + #define _ISR_lock_Flash( _lock, _context ) \ + _ISR_Local_flash( ( _context )->isr_level ) +#endif + +#if defined( RTEMS_PROFILING ) + #define _ISR_lock_ISR_disable_profile( _context ) \ + ( _context )->ISR_disable_instant = _CPU_Counter_read(); +#else + #define _ISR_lock_ISR_disable_profile( _context ) +#endif + +/** + * @brief Disables interrupts and saves the previous interrupt state in the ISR + * lock context. + * + * This function can be used in thread and interrupt context. + * + * @param[in] _context The local ISR lock context to store the interrupt state. + * + * @see _ISR_lock_ISR_enable(). + */ +#if defined( RTEMS_SMP ) + #define _ISR_lock_ISR_disable( _context ) \ + do { \ + _ISR_Local_disable( ( _context )->Lock_context.isr_level ); \ + _ISR_lock_ISR_disable_profile( _context ) \ + } while ( 0 ) +#else + #define _ISR_lock_ISR_disable( _context ) \ + do { \ + _ISR_Local_disable( ( _context )->isr_level ); \ + _ISR_lock_ISR_disable_profile( _context ) \ + } while ( 0 ) +#endif + +/** + * @brief Restores the saved interrupt state of the ISR lock context. + * + * This function can be used in thread and interrupt context. + * + * @param[in] _context The local ISR lock context containing the saved + * interrupt state. + * + * @see _ISR_lock_ISR_disable(). + */ +#if defined( RTEMS_SMP ) + #define _ISR_lock_ISR_enable( _context ) \ + _ISR_Local_enable( ( _context )->Lock_context.isr_level ) +#else + #define _ISR_lock_ISR_enable( _context ) \ + _ISR_Local_enable( ( _context )->isr_level ) +#endif + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_SCORE_ISR_LOCK_H */ diff --git a/cpukit/include/rtems/score/mpci.h b/cpukit/include/rtems/score/mpci.h new file mode 100644 index 0000000000..c20b45c3e1 --- /dev/null +++ b/cpukit/include/rtems/score/mpci.h @@ -0,0 +1,135 @@ +/** + * @file + * + * @ingroup ScoreMPCI + * + * @brief MPCI Layer API + */ + +/* + * COPYRIGHT (c) 1989-2009. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_MPCI_H +#define _RTEMS_SCORE_MPCI_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ScoreMPCI MPCI Handler + * + * @ingroup Score + * + * The MPCI Handler encapsulates functionality which is related to the + * generation, receipt, and processing of remote operations in a + * multiprocessor system. This handler contains the message passing + * support for making remote service calls as well as the server thread + * which processes requests from remote nodes. +*/ +/**@{*/ + +/** + * The following defines the node number used when a broadcast is desired. + */ +#define MPCI_ALL_NODES 0 + +/** + * This type is returned by all user provided MPCI routines. + */ +typedef void MPCI_Entry; + +/** + * This type defines the prototype for the initization entry point + * in an Multiprocessor Communications Interface. + */ +typedef MPCI_Entry ( *MPCI_initialization_entry )( void ); + +/** + * This type defines the prototype for the get packet entry point + * in an Multiprocessor Communications Interface. The single + * parameter will point to the packet allocated. + */ +typedef MPCI_Entry ( *MPCI_get_packet_entry )( + MP_packet_Prefix ** + ); + +/** + * This type defines the prototype for the return packet entry point + * in an Multiprocessor Communications Interface. The single + * parameter will point to a packet previously allocated by the + * get packet MPCI entry. + */ +typedef MPCI_Entry ( *MPCI_return_packet_entry )( + MP_packet_Prefix * + ); + +/** + * This type defines the prototype for send get packet entry point + * in an Multiprocessor Communications Interface. The single + * parameter will point to a packet previously allocated by the + * get packet entry point that has been filled in by the caller. + */ +typedef MPCI_Entry ( *MPCI_send_entry )( + uint32_t, + MP_packet_Prefix * + ); + +/** + * This type defines the prototype for the receive packet entry point + * in an Multiprocessor Communications Interface. The single + * parameter will point to a packet allocated and filled in by the + * receive packet handler. The caller will block until a packet is + * received. + */ +typedef MPCI_Entry ( *MPCI_receive_entry )( + MP_packet_Prefix ** + ); + +/** + * This type defines the Multiprocessor Communications + * Interface (MPCI) Table. This table defines the user-provided + * MPCI which is a required part of a multiprocessor system. + * + * For non-blocking local operations that become remote operations, + * we need a timeout. This is a per-driver timeout: default_timeout + */ +typedef struct { + /** This fields contains the timeout for MPCI operations in ticks. */ + uint32_t default_timeout; + /** This field contains the maximum size of a packet supported by this + * MPCI layer. This size places a limit on the size of a message + * which can be transmitted over this interface. + **/ + size_t maximum_packet_size; + /** This field points to the MPCI initialization entry point. */ + MPCI_initialization_entry initialization; + /** This field points to the MPCI get packet entry point. */ + MPCI_get_packet_entry get_packet; + /** This field points to the MPCI return packet entry point. */ + MPCI_return_packet_entry return_packet; + /** This field points to the MPCI send packet entry point. */ + MPCI_send_entry send_packet; + /** This field points to the MPCI receive packet entry point. */ + MPCI_receive_entry receive_packet; +} MPCI_Control; + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/mpciimpl.h b/cpukit/include/rtems/score/mpciimpl.h new file mode 100644 index 0000000000..eb03a1d7b3 --- /dev/null +++ b/cpukit/include/rtems/score/mpciimpl.h @@ -0,0 +1,326 @@ +/** + * @file + * + * @ingroup ScoreMPCI + * + * @brief MPCI Layer Implementation + */ + +/* + * COPYRIGHT (c) 1989-2009. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_MPCIIMPL_H +#define _RTEMS_SCORE_MPCIIMPL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup ScoreMPCI + * + * @{ + */ + +/** + * For packets associated with requests that don't already have a timeout, + * use the one specified by this MPCI driver. The value specified by + * the MPCI driver sets an upper limit on how long a remote request + * should take to complete. + */ +#define MPCI_DEFAULT_TIMEOUT 0xFFFFFFFF + +/** + * The following defines the type for packet processing routines + * invoked by the MPCI Receive server. + */ +typedef void (*MPCI_Packet_processor)( MP_packet_Prefix * ); + +/** + * The following enumerated type defines the list of + * internal MP operations. + */ +typedef enum { + MPCI_PACKETS_SYSTEM_VERIFY = 0 +} MPCI_Internal_Remote_operations; + +/** + * The following data structure defines the packet used to perform + * remote event operations. + */ +typedef struct { + /** This field is the general header for all packets. */ + MP_packet_Prefix Prefix; + /** This value specifies the operation. */ + MPCI_Internal_Remote_operations operation; + /** This is the maximum number of nodes in the system. It must agree + * on all nodes. + */ + uint32_t maximum_nodes; + /** This field is the maximum number of concurrently existent + * globally offered objects. + */ + uint32_t maximum_global_objects; +} MPCI_Internal_packet; + +/** + * The following thread queue is used to maintain a list of tasks + * which currently have outstanding remote requests. + */ +extern Thread_queue_Control _MPCI_Remote_blocked_threads; + +/** + * The following define the internal pointers to the user's + * configuration information. + */ +extern MPCI_Control *_MPCI_table; + +/** + * @brief Pointer to MP thread control block. + * + * The following is used to determine when the multiprocessing receive + * thread is executing so that a proxy can be allocated instead of + * blocking the multiprocessing receive thread. + */ +extern Thread_Control *_MPCI_Receive_server_tcb; + +/** + * The following table contains the process packet routines provided + * by each object that supports MP operations. + */ +extern MPCI_Packet_processor +_MPCI_Packet_processors[ MP_PACKET_CLASSES_LAST + 1 ]; + +/** + * This routine registers the MPCI packet processor for the + * designated object class. + * + * @param[in] the_class is the class indicator for packets which will + * be processed by @a the_packet_processor method. + * @param[in] the_packet_processor is a pointer to a method which is + * invoked when packets with @a the_class are received. + */ +void _MPCI_Register_packet_processor( + MP_packet_Classes the_class, + MPCI_Packet_processor the_packet_processor + +); + +/** + * This function obtains a packet by invoking the user provided + * MPCI get packet callout. + * + * @retval This method returns a pointer to a MPCI packet which can be + * filled in by the caller and used to perform a subsequent + * remote operation. + */ +MP_packet_Prefix *_MPCI_Get_packet ( void ); + +/** + * @brief Deallocate a packet. + * + * This routine deallocates a packet by invoking the user provided + * MPCI return packet callout. + * + * @param[in] the_packet is the MP packet to deallocate. + */ +void _MPCI_Return_packet ( + MP_packet_Prefix *the_packet +); + +/** + * @brief Send a process packet. + * + * This routine sends a process packet by invoking the user provided + * MPCI send callout. + * + * @param[in] destination is the node which should receive this packet. + * @param[in] the_packet is the packet to be sent. + */ +void _MPCI_Send_process_packet ( + uint32_t destination, + MP_packet_Prefix *the_packet +); + +/** + * @brief Send a request packet. + * + * This routine sends a request packet by invoking the user provided + * MPCI send callout. + * + * @param[in] destination is the node which should receive this packet. + * @param[in] the_packet is the packet to be sent. + * @param[in] extra_state is the extra thread state bits which should be + * set in addition to the remote operation pending state. It + * may indicate the caller is blocking on a message queue + * operation. + * + * @retval This method returns the operation status from the remote node. + */ +Status_Control _MPCI_Send_request_packet( + uint32_t destination, + MP_packet_Prefix *the_packet, + States_Control extra_state +); + +/** + * @brief Send a response packet. + * + * This routine sends a response packet by invoking the user provided + * MPCI send callout. + * + * @param[in] destination is the node which should receive this packet. + * @param[in] the_packet is the packet to be sent. + */ +void _MPCI_Send_response_packet ( + uint32_t destination, + MP_packet_Prefix *the_packet +); + +/** + * @brief Receive a packet. + * + * This routine receives a packet by invoking the user provided + * MPCI receive callout. + * + * @retval This method returns the packet received. + */ +MP_packet_Prefix *_MPCI_Receive_packet ( void ); + +/** + * @brief Pass a packet to the thread. + * + * This routine is responsible for passing @a the_packet to the thread + * waiting on the remote operation to complete. The unblocked thread is + * responsible for eventually freeing @a the_packet. + * + * @param[in] the_packet is the response packet to be processed. + * + * @retval This method returns a pointer to the thread which was if unblocked + * or NULL if the waiting thread no longer exists. + */ +Thread_Control *_MPCI_Process_response ( + MP_packet_Prefix *the_packet +); + +/** + * @brief Receive and process all packets. + * + * This is the server thread which receives and processes all MCPI packets. + * + * @param[in] ignored is the thread argument. It is not used. + */ +void _MPCI_Receive_server( + Thread_Entry_numeric_type ignored +); + +/** + * @brief Announce the availability of a packet. + * + * This routine informs RTEMS of the availability of an MPCI packet. + */ +void _MPCI_Announce ( void ); + +/** + * @brief Perform a process on another node. + * + * This routine performs a remote procedure call so that a + * process operation can be performed on another node. + * + * @param[in] operation is the remote operation to perform. + */ +void _MPCI_Internal_packets_Send_process_packet ( + MPCI_Internal_Remote_operations operation +); + +/** + * _MPCI_Internal_packets_Send_request_packet + * + * This routine performs a remote procedure call so that a + * directive operation can be initiated on another node. + * + * This routine is not needed since there are no request + * packets to be sent by this manager. + */ + +/** + * _MPCI_Internal_packets_Send_response_packet + * + * This routine performs a remote procedure call so that a + * directive can be performed on another node. + * + * This routine is not needed since there are no response + * packets to be sent by this manager. + */ + +/** + * @brief Perform requested action from another node. + * + * This routine performs the actions specific to this package for + * the request from another node. + */ +void _MPCI_Internal_packets_Process_packet ( + MP_packet_Prefix *the_packet_prefix +); + +/** + * _MPCI_Internal_packets_Send_object_was_deleted + * + * This routine is invoked indirectly by the thread queue + * when a proxy has been removed from the thread queue and + * the remote node must be informed of this. + * + * This routine is not needed since there are no objects + * deleted by this manager. + */ + +/** + * _MPCI_Internal_packets_Send_extract_proxy + * + * This routine is invoked when a task is deleted and it + * has a proxy which must be removed from a thread queue and + * the remote node must be informed of this. + * + * This routine is not needed since there are no objects + * deleted by this manager. + */ + +/** + * @brief Obtain an internal thread. + * + * This routine is used to obtain an internal threads MP packet. + */ +MPCI_Internal_packet *_MPCI_Internal_packets_Get_packet ( void ); + +/** + * This function returns true if the the_packet_class is valid, + * and false otherwise. + * + * @note Check for lower bounds (MP_PACKET_CLASSES_FIRST ) is unnecessary + * because this enum starts at lower bound of zero. + */ + +RTEMS_INLINE_ROUTINE bool _Mp_packet_Is_valid_packet_class ( + MP_packet_Classes the_packet_class +) +{ + return ( the_packet_class <= MP_PACKET_CLASSES_LAST ); +} + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/mppkt.h b/cpukit/include/rtems/score/mppkt.h new file mode 100644 index 0000000000..573abf574b --- /dev/null +++ b/cpukit/include/rtems/score/mppkt.h @@ -0,0 +1,121 @@ +/** + * @file rtems/score/mppkt.h + * + * @brief Specification for the Packet Handler + * + * This package is the specification for the Packet Handler. + * This handler defines the basic packet and provides + * mechanisms to utilize packets based on this prefix. + * Packets are the fundamental basis for messages passed between + * nodes in an MP system. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_MPPKT_H +#define _RTEMS_SCORE_MPPKT_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ScoreMPPacket MP Packet Handler + * + * @ingroup Score + * + * This handler encapsulates the primary definition of MPCI packets. This + * handler defines the part of the packet that is common to all remote + * operations. + */ +/**@{*/ + +/** + * The following enumerated type defines the packet classes. + * + * @note In general, each class corresponds to a manager + * which supports global operations. Each manager + * defines the set of supported operations. + */ +typedef enum { + MP_PACKET_MPCI_INTERNAL = 0, + MP_PACKET_TASKS = 1, + MP_PACKET_MESSAGE_QUEUE = 2, + MP_PACKET_SEMAPHORE = 3, + MP_PACKET_PARTITION = 4, + MP_PACKET_REGION = 5, + MP_PACKET_EVENT = 6, + MP_PACKET_SIGNAL = 7 +} MP_packet_Classes; + +/** + * This constant defines the first entry in the MP_packet_Classes enumeration. + */ +#define MP_PACKET_CLASSES_FIRST MP_PACKET_MPCI_INTERNAL + +/** + * This constant defines the last entry in the MP_packet_Classes enumeration. + */ +#define MP_PACKET_CLASSES_LAST MP_PACKET_SIGNAL + +/** + * The following record contains the prefix for every packet + * passed between nodes in an MP system. + * + * @note This structure is padded to ensure that anything following it + * is on a 16 byte boundary. This is the most stringent structure + * alignment rule encountered yet. + */ +typedef struct { + /** This field indicates the API class of the operation being performed. */ + MP_packet_Classes the_class; + /** This field is the id of the object to be acted upon. */ + Objects_Id id; + /** This field is the ID of the originating thread. */ + Objects_Id source_tid; + /** This field is the priority of the originating thread. */ + uint32_t source_priority; + /** This field is where the status of the operation will be returned. */ + uint32_t return_code; + /** This field is the length of the data following the prefix. */ + uint32_t length; + /** This field is the length of the data which required network conversion. */ + uint32_t to_convert; + /** This field is the requested timeout for this operation. */ + Watchdog_Interval timeout; +} MP_packet_Prefix; + +/** + * An MPCI must support packets of at least this size. + */ +#define MP_PACKET_MINIMUM_PACKET_SIZE 64 + +/** + * The following constant defines the number of uint32_t's + * in a packet which must be converted to native format in a + * heterogeneous system. In packets longer than + * MP_PACKET_MINIMUN_HETERO_CONVERSION uint32_t's, some of the "extra" data + * may a user message buffer which is not automatically endian swapped. + */ +#define MP_PACKET_MINIMUN_HETERO_CONVERSION \ + ( sizeof( MP_packet_Prefix ) / sizeof( uint32_t ) ) + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/mrsp.h b/cpukit/include/rtems/score/mrsp.h new file mode 100644 index 0000000000..85cbff784f --- /dev/null +++ b/cpukit/include/rtems/score/mrsp.h @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2014, 2016 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_MRSP_H +#define _RTEMS_SCORE_MRSP_H + +#include + +#if defined(RTEMS_SMP) + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup ScoreMRSP Multiprocessor Resource Sharing Protocol Handler + * + * @ingroup Score + * + * @brief Multiprocessor Resource Sharing Protocol (MrsP). + * + * The Multiprocessor Resource Sharing Protocol (MrsP) is defined in A. Burns + * and A.J. Wellings, A Schedulability Compatible Multiprocessor Resource + * Sharing Protocol - MrsP, Proceedings of the 25th Euromicro Conference on + * Real-Time Systems (ECRTS 2013), July 2013. It is a generalization of the + * Priority Ceiling Protocol to SMP systems. Each MrsP semaphore uses a + * ceiling priority per scheduler instance. A task obtaining or owning a MrsP + * semaphore will execute with the ceiling priority for its scheduler instance + * as specified by the MrsP semaphore object. Tasks waiting to get ownership + * of a MrsP semaphore will not relinquish the processor voluntarily. In case + * the owner of a MrsP semaphore gets preempted it can ask all tasks waiting + * for this semaphore to help out and temporarily borrow the right to execute + * on one of their assigned processors. + * + * @{ + */ + +/** + * @brief MrsP control block. + */ +typedef struct { + /** + * @brief The thread queue to manage ownership and waiting threads. + */ + Thread_queue_Control Wait_queue; + + /** + * @brief The ceiling priority used by the owner thread. + */ + Priority_Node Ceiling_priority; + + /** + * @brief One ceiling priority per scheduler instance. + */ + Priority_Control *ceiling_priorities; +} MRSP_Control; + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RTEMS_SMP */ + +#endif /* _RTEMS_SCORE_MRSP_H */ diff --git a/cpukit/include/rtems/score/mrspimpl.h b/cpukit/include/rtems/score/mrspimpl.h new file mode 100644 index 0000000000..b9c7441401 --- /dev/null +++ b/cpukit/include/rtems/score/mrspimpl.h @@ -0,0 +1,384 @@ +/* + * Copyright (c) 2014, 2016 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_MRSPIMPL_H +#define _RTEMS_SCORE_MRSPIMPL_H + +#include + +#if defined(RTEMS_SMP) + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @addtogroup ScoreMRSP + * + * @{ + */ + +#define MRSP_TQ_OPERATIONS &_Thread_queue_Operations_priority_inherit + +RTEMS_INLINE_ROUTINE void _MRSP_Acquire_critical( + MRSP_Control *mrsp, + Thread_queue_Context *queue_context +) +{ + _Thread_queue_Acquire_critical( &mrsp->Wait_queue, queue_context ); +} + +RTEMS_INLINE_ROUTINE void _MRSP_Release( + MRSP_Control *mrsp, + Thread_queue_Context *queue_context +) +{ + _Thread_queue_Release( &mrsp->Wait_queue, queue_context ); +} + +RTEMS_INLINE_ROUTINE Thread_Control *_MRSP_Get_owner( + const MRSP_Control *mrsp +) +{ + return mrsp->Wait_queue.Queue.owner; +} + +RTEMS_INLINE_ROUTINE void _MRSP_Set_owner( + MRSP_Control *mrsp, + Thread_Control *owner +) +{ + mrsp->Wait_queue.Queue.owner = owner; +} + +RTEMS_INLINE_ROUTINE Priority_Control _MRSP_Get_priority( + const MRSP_Control *mrsp, + const Scheduler_Control *scheduler +) +{ + uint32_t scheduler_index; + + scheduler_index = _Scheduler_Get_index( scheduler ); + return mrsp->ceiling_priorities[ scheduler_index ]; +} + +RTEMS_INLINE_ROUTINE void _MRSP_Set_priority( + MRSP_Control *mrsp, + const Scheduler_Control *scheduler, + Priority_Control new_priority +) +{ + uint32_t scheduler_index; + + scheduler_index = _Scheduler_Get_index( scheduler ); + mrsp->ceiling_priorities[ scheduler_index ] = new_priority; +} + +RTEMS_INLINE_ROUTINE Status_Control _MRSP_Raise_priority( + MRSP_Control *mrsp, + Thread_Control *thread, + Priority_Node *priority_node, + Thread_queue_Context *queue_context +) +{ + Status_Control status; + ISR_lock_Context lock_context; + const Scheduler_Control *scheduler; + Priority_Control ceiling_priority; + Scheduler_Node *scheduler_node; + + _Thread_queue_Context_clear_priority_updates( queue_context ); + _Thread_Wait_acquire_default_critical( thread, &lock_context ); + + scheduler = _Thread_Scheduler_get_home( thread ); + scheduler_node = _Thread_Scheduler_get_home_node( thread ); + ceiling_priority = _MRSP_Get_priority( mrsp, scheduler ); + + if ( + ceiling_priority + <= _Priority_Get_priority( &scheduler_node->Wait.Priority ) + ) { + _Priority_Node_initialize( priority_node, ceiling_priority ); + _Thread_Priority_add( thread, priority_node, queue_context ); + status = STATUS_SUCCESSFUL; + } else { + status = STATUS_MUTEX_CEILING_VIOLATED; + } + + _Thread_Wait_release_default_critical( thread, &lock_context ); + return status; +} + +RTEMS_INLINE_ROUTINE void _MRSP_Remove_priority( + Thread_Control *thread, + Priority_Node *priority_node, + Thread_queue_Context *queue_context +) +{ + ISR_lock_Context lock_context; + + _Thread_queue_Context_clear_priority_updates( queue_context ); + _Thread_Wait_acquire_default_critical( thread, &lock_context ); + _Thread_Priority_remove( thread, priority_node, queue_context ); + _Thread_Wait_release_default_critical( thread, &lock_context ); +} + +RTEMS_INLINE_ROUTINE void _MRSP_Replace_priority( + MRSP_Control *mrsp, + Thread_Control *thread, + Priority_Node *ceiling_priority +) +{ + ISR_lock_Context lock_context; + + _Thread_Wait_acquire_default( thread, &lock_context ); + _Thread_Priority_replace( + thread, + ceiling_priority, + &mrsp->Ceiling_priority + ); + _Thread_Wait_release_default( thread, &lock_context ); +} + +RTEMS_INLINE_ROUTINE Status_Control _MRSP_Claim_ownership( + MRSP_Control *mrsp, + Thread_Control *executing, + Thread_queue_Context *queue_context +) +{ + Status_Control status; + Per_CPU_Control *cpu_self; + + status = _MRSP_Raise_priority( + mrsp, + executing, + &mrsp->Ceiling_priority, + queue_context + ); + + if ( status != STATUS_SUCCESSFUL ) { + _MRSP_Release( mrsp, queue_context ); + return status; + } + + _MRSP_Set_owner( mrsp, executing ); + cpu_self = _Thread_queue_Dispatch_disable( queue_context ); + _MRSP_Release( mrsp, queue_context ); + _Thread_Priority_and_sticky_update( executing, 1 ); + _Thread_Dispatch_enable( cpu_self ); + return STATUS_SUCCESSFUL; +} + +RTEMS_INLINE_ROUTINE Status_Control _MRSP_Initialize( + MRSP_Control *mrsp, + const Scheduler_Control *scheduler, + Priority_Control ceiling_priority, + Thread_Control *executing, + bool initially_locked +) +{ + uint32_t scheduler_count = _Scheduler_Count; + uint32_t i; + + if ( initially_locked ) { + return STATUS_INVALID_NUMBER; + } + + mrsp->ceiling_priorities = _Workspace_Allocate( + sizeof( *mrsp->ceiling_priorities ) * scheduler_count + ); + if ( mrsp->ceiling_priorities == NULL ) { + return STATUS_NO_MEMORY; + } + + for ( i = 0 ; i < scheduler_count ; ++i ) { + const Scheduler_Control *scheduler_of_index; + + scheduler_of_index = &_Scheduler_Table[ i ]; + + if ( scheduler != scheduler_of_index ) { + mrsp->ceiling_priorities[ i ] = + _Scheduler_Map_priority( scheduler_of_index, 0 ); + } else { + mrsp->ceiling_priorities[ i ] = ceiling_priority; + } + } + + _Thread_queue_Object_initialize( &mrsp->Wait_queue ); + return STATUS_SUCCESSFUL; +} + +RTEMS_INLINE_ROUTINE Status_Control _MRSP_Wait_for_ownership( + MRSP_Control *mrsp, + Thread_Control *executing, + Thread_queue_Context *queue_context +) +{ + Status_Control status; + Priority_Node ceiling_priority; + + status = _MRSP_Raise_priority( + mrsp, + executing, + &ceiling_priority, + queue_context + ); + + if ( status != STATUS_SUCCESSFUL ) { + _MRSP_Release( mrsp, queue_context ); + return status; + } + + _Thread_queue_Context_set_deadlock_callout( + queue_context, + _Thread_queue_Deadlock_status + ); + status = _Thread_queue_Enqueue_sticky( + &mrsp->Wait_queue.Queue, + MRSP_TQ_OPERATIONS, + executing, + queue_context + ); + + if ( status == STATUS_SUCCESSFUL ) { + _MRSP_Replace_priority( mrsp, executing, &ceiling_priority ); + } else { + Thread_queue_Context queue_context; + Per_CPU_Control *cpu_self; + int sticky_level_change; + + if ( status != STATUS_DEADLOCK ) { + sticky_level_change = -1; + } else { + sticky_level_change = 0; + } + + _ISR_lock_ISR_disable( &queue_context.Lock_context.Lock_context ); + _MRSP_Remove_priority( executing, &ceiling_priority, &queue_context ); + cpu_self = _Thread_Dispatch_disable_critical( + &queue_context.Lock_context.Lock_context + ); + _ISR_lock_ISR_enable( &queue_context.Lock_context.Lock_context ); + _Thread_Priority_and_sticky_update( executing, sticky_level_change ); + _Thread_Dispatch_enable( cpu_self ); + } + + return status; +} + +RTEMS_INLINE_ROUTINE Status_Control _MRSP_Seize( + MRSP_Control *mrsp, + Thread_Control *executing, + bool wait, + Thread_queue_Context *queue_context +) +{ + Status_Control status; + Thread_Control *owner; + + _MRSP_Acquire_critical( mrsp, queue_context ); + + owner = _MRSP_Get_owner( mrsp ); + + if ( owner == NULL ) { + status = _MRSP_Claim_ownership( mrsp, executing, queue_context ); + } else if ( owner == executing ) { + _MRSP_Release( mrsp, queue_context ); + status = STATUS_UNAVAILABLE; + } else if ( wait ) { + status = _MRSP_Wait_for_ownership( mrsp, executing, queue_context ); + } else { + _MRSP_Release( mrsp, queue_context ); + status = STATUS_UNAVAILABLE; + } + + return status; +} + +RTEMS_INLINE_ROUTINE Status_Control _MRSP_Surrender( + MRSP_Control *mrsp, + Thread_Control *executing, + Thread_queue_Context *queue_context +) +{ + Thread_queue_Heads *heads; + + if ( _MRSP_Get_owner( mrsp ) != executing ) { + _ISR_lock_ISR_enable( &queue_context->Lock_context.Lock_context ); + return STATUS_NOT_OWNER; + } + + _MRSP_Acquire_critical( mrsp, queue_context ); + + _MRSP_Set_owner( mrsp, NULL ); + _MRSP_Remove_priority( executing, &mrsp->Ceiling_priority, queue_context ); + + heads = mrsp->Wait_queue.Queue.heads; + + if ( heads == NULL ) { + Per_CPU_Control *cpu_self; + + cpu_self = _Thread_Dispatch_disable_critical( + &queue_context->Lock_context.Lock_context + ); + _MRSP_Release( mrsp, queue_context ); + _Thread_Priority_and_sticky_update( executing, -1 ); + _Thread_Dispatch_enable( cpu_self ); + return STATUS_SUCCESSFUL; + } + + _Thread_queue_Surrender_sticky( + &mrsp->Wait_queue.Queue, + heads, + executing, + queue_context, + MRSP_TQ_OPERATIONS + ); + return STATUS_SUCCESSFUL; +} + +RTEMS_INLINE_ROUTINE Status_Control _MRSP_Can_destroy( MRSP_Control *mrsp ) +{ + if ( _MRSP_Get_owner( mrsp ) != NULL ) { + return STATUS_RESOURCE_IN_USE; + } + + return STATUS_SUCCESSFUL; +} + +RTEMS_INLINE_ROUTINE void _MRSP_Destroy( + MRSP_Control *mrsp, + Thread_queue_Context *queue_context +) +{ + _MRSP_Release( mrsp, queue_context ); + _Thread_queue_Destroy( &mrsp->Wait_queue ); + _Workspace_Free( mrsp->ceiling_priorities ); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RTEMS_SMP */ + +#endif /* _RTEMS_SCORE_MRSPIMPL_H */ diff --git a/cpukit/include/rtems/score/muteximpl.h b/cpukit/include/rtems/score/muteximpl.h new file mode 100644 index 0000000000..5fd4f5e8be --- /dev/null +++ b/cpukit/include/rtems/score/muteximpl.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2015, 2017 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_MUTEXIMPL_H +#define _RTEMS_SCORE_MUTEXIMPL_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +typedef struct { + Thread_queue_Syslock_queue Queue; +} Mutex_Control; + +typedef struct { + Mutex_Control Mutex; + unsigned int nest_level; +} Mutex_recursive_Control; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_SCORE_MUTEXIMPL_H */ diff --git a/cpukit/include/rtems/score/object.h b/cpukit/include/rtems/score/object.h new file mode 100644 index 0000000000..6789c61fea --- /dev/null +++ b/cpukit/include/rtems/score/object.h @@ -0,0 +1,469 @@ +/** + * @file rtems/score/object.h + * + * @brief Constants and Structures Associated with the Object Handler + * + * This include file contains all the constants and structures associated + * with the Object Handler. This Handler provides mechanisms which + * can be used to initialize and manipulate all objects which have ids. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_OBJECT_H +#define _RTEMS_SCORE_OBJECT_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup Score SuperCore + * + * @brief Provides services for all APIs. + */ +/**@{*/ + +#if defined(RTEMS_POSIX_API) + /** + * This macro is defined when an API is enabled that requires the + * use of strings for object names. Since the Classic API uses + * 32-bit unsigned integers and not strings, this allows us to + * disable this in the smallest RTEMS configuratinos. + */ + #define RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES +#endif + +/** + * @defgroup ScoreCPU CPU Architecture Support + * + * @ingroup Score + * + * @brief Provides CPU architecture dependent services. + */ +/**@{*/ + +/** + * @defgroup ScoreObject Object Handler + * + * @ingroup Score + */ +/**@{*/ + +/** + * The following type defines the control block used to manage + * object names. + */ +typedef union { + #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES) + /** This is a pointer to a string name. */ + const char *name_p; + #endif + /** This is the actual 32-bit "raw" integer name. */ + uint32_t name_u32; +} Objects_Name; + +#if defined(RTEMS_USE_16_BIT_OBJECT) +/** + * The following type defines the control block used to manage + * object IDs. The format is as follows (0=LSB): + * + * Bits 0 .. 7 = index (up to 254 objects of a type) + * Bits 8 .. 10 = API (up to 7 API classes) + * Bits 11 .. 15 = class (up to 31 object types per API) + */ +typedef uint16_t Objects_Id; + +/** + * This type is used to store the maximum number of allowed objects + * of each type. + */ +typedef uint8_t Objects_Maximum; + +#define OBJECTS_INDEX_START_BIT 0U +#define OBJECTS_API_START_BIT 8U +#define OBJECTS_CLASS_START_BIT 11U + +#define OBJECTS_INDEX_MASK (Objects_Id)0x00ffU +#define OBJECTS_API_MASK (Objects_Id)0x0700U +#define OBJECTS_CLASS_MASK (Objects_Id)0xF800U + +#define OBJECTS_INDEX_VALID_BITS (Objects_Id)0x00ffU +#define OBJECTS_API_VALID_BITS (Objects_Id)0x0007U +/* OBJECTS_NODE_VALID_BITS should not be used with 16 bit Ids */ +#define OBJECTS_CLASS_VALID_BITS (Objects_Id)0x001fU + +#define OBJECTS_UNLIMITED_OBJECTS 0x8000U + +#define OBJECTS_ID_INITIAL_INDEX (0) +#define OBJECTS_ID_FINAL_INDEX (0xff) + +#else +/** + * The following type defines the control block used to manage + * object IDs. The format is as follows (0=LSB): + * + * Bits 0 .. 15 = index (up to 65535 objects of a type) + * Bits 16 .. 23 = node (up to 255 nodes) + * Bits 24 .. 26 = API (up to 7 API classes) + * Bits 27 .. 31 = class (up to 31 object types per API) + */ +typedef uint32_t Objects_Id; + +/** + * This type is used to store the maximum number of allowed objects + * of each type. + */ +typedef uint16_t Objects_Maximum; + +/** + * This is the bit position of the starting bit of the index portion of + * the object Id. + */ +#define OBJECTS_INDEX_START_BIT 0U +/** + * This is the bit position of the starting bit of the node portion of + * the object Id. + */ +#define OBJECTS_NODE_START_BIT 16U + +/** + * This is the bit position of the starting bit of the API portion of + * the object Id. + */ +#define OBJECTS_API_START_BIT 24U + +/** + * This is the bit position of the starting bit of the class portion of + * the object Id. + */ +#define OBJECTS_CLASS_START_BIT 27U + +/** + * This mask is used to extract the index portion of an object Id. + */ +#define OBJECTS_INDEX_MASK (Objects_Id)0x0000ffffU + +/** + * This mask is used to extract the node portion of an object Id. + */ +#define OBJECTS_NODE_MASK (Objects_Id)0x00ff0000U + +/** + * This mask is used to extract the API portion of an object Id. + */ +#define OBJECTS_API_MASK (Objects_Id)0x07000000U + +/** + * This mask is used to extract the class portion of an object Id. + */ +#define OBJECTS_CLASS_MASK (Objects_Id)0xf8000000U + +/** + * This mask represents the bits that is used to ensure no extra bits + * are set after shifting to extract the index portion of an object Id. + */ +#define OBJECTS_INDEX_VALID_BITS (Objects_Id)0x0000ffffU + +/** + * This mask represents the bits that is used to ensure no extra bits + * are set after shifting to extract the node portion of an object Id. + */ +#define OBJECTS_NODE_VALID_BITS (Objects_Id)0x000000ffU + +/** + * This mask represents the bits that is used to ensure no extra bits + * are set after shifting to extract the API portion of an object Id. + */ +#define OBJECTS_API_VALID_BITS (Objects_Id)0x00000007U + +/** + * This mask represents the bits that is used to ensure no extra bits + * are set after shifting to extract the class portion of an object Id. + */ +#define OBJECTS_CLASS_VALID_BITS (Objects_Id)0x0000001fU + +/** + * Mask to enable unlimited objects. This is used in the configuration + * table when specifying the number of configured objects. + */ +#define OBJECTS_UNLIMITED_OBJECTS 0x80000000U + +/** + * This is the lowest value for the index portion of an object Id. + */ +#define OBJECTS_ID_INITIAL_INDEX (0) + +/** + * This is the highest value for the index portion of an object Id. + */ +#define OBJECTS_ID_FINAL_INDEX (0xffffU) +#endif + +/** + * This enumerated type is used in the class field of the object ID. + */ +typedef enum { + OBJECTS_NO_API = 0, + OBJECTS_INTERNAL_API = 1, + OBJECTS_CLASSIC_API = 2, + OBJECTS_POSIX_API = 3, + OBJECTS_FAKE_OBJECTS_API = 7 +} Objects_APIs; + +/** This macro is used to generically specify the last API index. */ +#define OBJECTS_APIS_LAST OBJECTS_POSIX_API + +/** + * The following defines the Object Control Block used to manage + * each object local to this node. + */ +typedef struct { + /** This is the chain node portion of an object. */ + Chain_Node Node; + /** This is the object's ID. */ + Objects_Id id; + /** This is the object's name. */ + Objects_Name name; +} Objects_Control; + +#if defined( RTEMS_MULTIPROCESSING ) +/** + * @brief This defines the Global Object Control Block used to manage objects + * resident on other nodes. + */ +typedef struct { + /** + * @brief Nodes to manage active and inactive global objects. + */ + union { + /** + * @brief Inactive global objects reside on a chain. + */ + Chain_Node Inactive; + + struct { + /** + * @brief Node to lookup an active global object by identifier. + */ + RBTree_Node Id_lookup; + + /** + * @brief Node to lookup an active global object by name. + */ + RBTree_Node Name_lookup; + } Active; + } Nodes; + + /** + * @brief The global object identifier. + */ + Objects_Id id; + + /** + * @brief The global object name. + * + * Using an unsigned thirty two bit value is broken but works. If any API is + * MP with variable length names .. BOOM!!!! + */ + uint32_t name; +} Objects_MP_Control; +#endif + +/** + * No object can have this ID. + */ +#define OBJECTS_ID_NONE 0 + +/** + * The following defines the constant which may be used + * to manipulate the calling task. + */ +#define OBJECTS_ID_OF_SELF ((Objects_Id) 0) + +/** + * The following constant is used to specify that a name to ID search + * should search through all nodes. + */ +#define OBJECTS_SEARCH_ALL_NODES 0 + +/** + * The following constant is used to specify that a name to ID search + * should search through all nodes except the current node. + */ +#define OBJECTS_SEARCH_OTHER_NODES 0x7FFFFFFE + +/** + * The following constant is used to specify that a name to ID search + * should search only on this node. + */ +#define OBJECTS_SEARCH_LOCAL_NODE 0x7FFFFFFF + +/** + * The following constant is used to specify that a name to ID search + * is being asked for the ID of the currently executing task. + */ +#define OBJECTS_WHO_AM_I 0 + +/** + * This macros calculates the lowest ID for the specified api, class, + * and node. + */ +#define OBJECTS_ID_INITIAL(_api, _class, _node) \ + _Objects_Build_id( (_api), (_class), (_node), OBJECTS_ID_INITIAL_INDEX ) + +/** + * This macro specifies the highest object ID value + */ +#define OBJECTS_ID_FINAL ((Objects_Id)~0) + +/** + * This macro is used to build a thirty-two bit style name from + * four characters. The most significant byte will be the + * character @a _C1. + * + * @param[in] _C1 is the first character of the name + * @param[in] _C2 is the second character of the name + * @param[in] _C3 is the third character of the name + * @param[in] _C4 is the fourth character of the name + */ +#define _Objects_Build_name( _C1, _C2, _C3, _C4 ) \ + ( (uint32_t)(_C1) << 24 | \ + (uint32_t)(_C2) << 16 | \ + (uint32_t)(_C3) << 8 | \ + (uint32_t)(_C4) ) + +/** + * This function returns the API portion of the ID. + * + * @param[in] id is the object Id to be processed. + * + * @return This method returns an object Id constructed from the arguments. + */ +RTEMS_INLINE_ROUTINE Objects_APIs _Objects_Get_API( + Objects_Id id +) +{ + return (Objects_APIs) ((id >> OBJECTS_API_START_BIT) & OBJECTS_API_VALID_BITS); +} + +/** + * This function returns the class portion of the ID. + * + * @param[in] id is the object Id to be processed + */ +RTEMS_INLINE_ROUTINE uint32_t _Objects_Get_class( + Objects_Id id +) +{ + return (uint32_t) + ((id >> OBJECTS_CLASS_START_BIT) & OBJECTS_CLASS_VALID_BITS); +} + +/** + * This function returns the node portion of the ID. + * + * @param[in] id is the object Id to be processed + * + * @return This method returns the node portion of an object ID. + */ +RTEMS_INLINE_ROUTINE uint32_t _Objects_Get_node( + Objects_Id id +) +{ + /* + * If using 16-bit Ids, then there is no node field and it MUST + * be a single processor system. + */ + #if defined(RTEMS_USE_16_BIT_OBJECT) + return 1; + #else + return (id >> OBJECTS_NODE_START_BIT) & OBJECTS_NODE_VALID_BITS; + #endif +} + +/** + * This function returns the index portion of the ID. + * + * @param[in] id is the Id to be processed + * + * @return This method returns the class portion of the specified object ID. + */ +RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Get_index( + Objects_Id id +) +{ + return + (Objects_Maximum)((id >> OBJECTS_INDEX_START_BIT) & + OBJECTS_INDEX_VALID_BITS); +} + +/** + * This function builds an object's id from the processor node and index + * values specified. + * + * @param[in] the_api indicates the API associated with this Id. + * @param[in] the_class indicates the class of object. + * It is specific to @a the_api. + * @param[in] node is the node where this object resides. + * @param[in] index is the instance number of this object. + * + * @return This method returns an object Id constructed from the arguments. + */ +RTEMS_INLINE_ROUTINE Objects_Id _Objects_Build_id( + Objects_APIs the_api, + uint16_t the_class, + uint8_t node, + uint16_t index +) +{ + return (( (Objects_Id) the_api ) << OBJECTS_API_START_BIT) | + (( (Objects_Id) the_class ) << OBJECTS_CLASS_START_BIT) | + #if !defined(RTEMS_USE_16_BIT_OBJECT) + (( (Objects_Id) node ) << OBJECTS_NODE_START_BIT) | + #endif + (( (Objects_Id) index ) << OBJECTS_INDEX_START_BIT); +} + +/** + * Returns if the object maximum specifies unlimited objects. + * + * @param[in] maximum The object maximum specification. + * + * @retval true Unlimited objects are available. + * @retval false The object count is fixed. + */ +RTEMS_INLINE_ROUTINE bool _Objects_Is_unlimited( uint32_t maximum ) +{ + return (maximum & OBJECTS_UNLIMITED_OBJECTS) != 0; +} + +/* + * We cannot use an inline function for this since it may be evaluated at + * compile time. + */ +#define _Objects_Maximum_per_allocation( maximum ) \ + ((Objects_Maximum) ((maximum) & ~OBJECTS_UNLIMITED_OBJECTS)) + +/**@}*/ +/**@}*/ +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/objectimpl.h b/cpukit/include/rtems/score/objectimpl.h new file mode 100644 index 0000000000..cc5820785c --- /dev/null +++ b/cpukit/include/rtems/score/objectimpl.h @@ -0,0 +1,1002 @@ +/** + * @file + * + * @brief Inlined Routines in the Object Handler + * + * This include file contains the static inline implementation of all + * of the inlined routines in the Object Handler. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_OBJECTIMPL_H +#define _RTEMS_SCORE_OBJECTIMPL_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup ScoreObject + * + * @{ + */ + +/** + * Functions which compare names are prototyped like this. + */ +typedef bool (*Objects_Name_comparators)( + void * /* name_1 */, + void * /* name_2 */, + uint16_t /* length */ +); + +/** + * This enumerated type is used in the class field of the object ID + * for RTEMS internal object classes. + */ +typedef enum { + OBJECTS_INTERNAL_NO_CLASS = 0, + OBJECTS_INTERNAL_THREADS = 1 +} Objects_Internal_API; + +/** This macro is used to generically specify the last API index. */ +#define OBJECTS_INTERNAL_CLASSES_LAST OBJECTS_INTERNAL_THREADS + +/** + * This enumerated type is used in the class field of the object ID + * for the RTEMS Classic API. + */ +typedef enum { + OBJECTS_CLASSIC_NO_CLASS = 0, + OBJECTS_RTEMS_TASKS = 1, + OBJECTS_RTEMS_TIMERS = 2, + OBJECTS_RTEMS_SEMAPHORES = 3, + OBJECTS_RTEMS_MESSAGE_QUEUES = 4, + OBJECTS_RTEMS_PARTITIONS = 5, + OBJECTS_RTEMS_REGIONS = 6, + OBJECTS_RTEMS_PORTS = 7, + OBJECTS_RTEMS_PERIODS = 8, + OBJECTS_RTEMS_EXTENSIONS = 9, + OBJECTS_RTEMS_BARRIERS = 10 +} Objects_Classic_API; + +/** This macro is used to generically specify the last API index. */ +#define OBJECTS_RTEMS_CLASSES_LAST OBJECTS_RTEMS_BARRIERS + +/** + * This enumerated type is used in the class field of the object ID + * for the POSIX API. + */ +typedef enum { + OBJECTS_POSIX_NO_CLASS = 0, + OBJECTS_POSIX_THREADS = 1, + OBJECTS_POSIX_KEYS = 2, + OBJECTS_POSIX_INTERRUPTS = 3, + OBJECTS_POSIX_MESSAGE_QUEUES = 5, + OBJECTS_POSIX_SEMAPHORES = 7, + OBJECTS_POSIX_TIMERS = 9, + OBJECTS_POSIX_SHMS = 12 +} Objects_POSIX_API; + +/** This macro is used to generically specify the last API index. */ +#define OBJECTS_POSIX_CLASSES_LAST OBJECTS_POSIX_SHMS + +/* + * For fake objects, which have an object identifier, but no objects + * information block. + */ +typedef enum { + OBJECTS_FAKE_OBJECTS_NO_CLASS = 0, + OBJECTS_FAKE_OBJECTS_SCHEDULERS = 1 +} Objects_Fake_objects_API; + +#if defined(RTEMS_MULTIPROCESSING) +/** + * The following type defines the callout used when a local task + * is extracted from a remote thread queue (i.e. it's proxy must + * extracted from the remote queue). + */ +typedef void ( *Objects_Thread_queue_Extract_callout )( + Thread_Control *, + Objects_Id +); +#endif + +/** + * The following defines the structure for the information used to + * manage each class of objects. + */ +typedef struct { + /** This field indicates the API of this object class. */ + Objects_APIs the_api; + /** This is the class of this object set. */ + uint16_t the_class; + /** This is the minimum valid id of this object class. */ + Objects_Id minimum_id; + /** This is the maximum valid id of this object class. */ + Objects_Id maximum_id; + /** This is the maximum number of objects in this class. */ + Objects_Maximum maximum; + /** This is the true if unlimited objects in this class. */ + bool auto_extend; + /** This is the number of objects in a block. */ + Objects_Maximum allocation_size; + /** This is the size in bytes of each object instance. */ + size_t size; + /** This points to the table of local objects. */ + Objects_Control **local_table; + /** This is the chain of inactive control blocks. */ + Chain_Control Inactive; + /** This is the number of objects on the Inactive list. */ + Objects_Maximum inactive; + /** This is the number of inactive objects per block. */ + uint32_t *inactive_per_block; + /** This is a table to the chain of inactive object memory blocks. */ + void **object_blocks; + #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES) + /** This is true if names are strings. */ + bool is_string; + #endif + /** This is the maximum length of names. */ + uint16_t name_length; + #if defined(RTEMS_MULTIPROCESSING) + /** This is this object class' method called when extracting a thread. */ + Objects_Thread_queue_Extract_callout extract; + + /** + * @brief The global objects of this object information sorted by object + * identifier. + */ + RBTree_Control Global_by_id; + + /** + * @brief The global objects of this object information sorted by object + * name. + * + * Objects with the same name are sorted according to their identifier. + */ + RBTree_Control Global_by_name; + #endif +} Objects_Information; + +/** + * The following is referenced to the node number of the local node. + */ +#if defined(RTEMS_MULTIPROCESSING) +extern uint16_t _Objects_Local_node; +#else +#define _Objects_Local_node ((uint16_t)1) +#endif + +/** + * The following is referenced to the number of nodes in the system. + */ +#if defined(RTEMS_MULTIPROCESSING) +extern uint16_t _Objects_Maximum_nodes; +#else +#define _Objects_Maximum_nodes 1 +#endif + +/** + * The following is the list of information blocks per API for each object + * class. From the ID, we can go to one of these information blocks, + * and obtain a pointer to the appropriate object control block. + */ +extern Objects_Information ** const +_Objects_Information_table[ OBJECTS_APIS_LAST + 1 ]; + +/** + * This function extends an object class information record. + * + * @param[in] information points to an object class information block. + */ +void _Objects_Extend_information( + Objects_Information *information +); + +/** + * @brief Shrink an object class information record + * + * This function shrink an object class information record. + * The object's name and object space are released. The local_table + * etc block does not shrink. The InActive list needs to be scanned + * to find the objects are remove them. + * + * @param[in] information points to an object class information block. + */ +void _Objects_Shrink_information( + Objects_Information *information +); + +void _Objects_Do_initialize_information( + Objects_Information *information, + Objects_APIs the_api, + uint16_t the_class, + uint32_t maximum, + uint16_t size, + bool is_string, + uint32_t maximum_name_length +#if defined(RTEMS_MULTIPROCESSING) + , + Objects_Thread_queue_Extract_callout extract +#endif +); + +/** + * @brief Initialize object Information + * + * This function initializes an object class information record. + * SUPPORTS_GLOBAL is true if the object class supports global + * objects, and false otherwise. Maximum indicates the number + * of objects required in this class and size indicates the size + * in bytes of each control block for this object class. The + * name length and string designator are also set. In addition, + * the class may be a task, therefore this information is also included. + * + * @param[in] information points to an object class information block. + * @param[in] the_api indicates the API associated with this information block. + * @param[in] the_class indicates the class of object being managed + * by this information block. It is specific to @a the_api. + * @param[in] maximum is the maximum number of instances of this object + * class which may be concurrently active. + * @param[in] size is the size of the data structure for this class. + * @param[in] is_string is true if this object uses string style names. + * @param[in] maximum_name_length is the maximum length of object names. + */ +#if defined(RTEMS_MULTIPROCESSING) + #define _Objects_Initialize_information( \ + information, \ + the_api, \ + the_class, \ + maximum, \ + size, \ + is_string, \ + maximum_name_length, \ + extract \ + ) \ + _Objects_Do_initialize_information( \ + information, \ + the_api, \ + the_class, \ + maximum, \ + size, \ + is_string, \ + maximum_name_length, \ + extract \ + ) +#else + #define _Objects_Initialize_information( \ + information, \ + the_api, \ + the_class, \ + maximum, \ + size, \ + is_string, \ + maximum_name_length, \ + extract \ + ) \ + _Objects_Do_initialize_information( \ + information, \ + the_api, \ + the_class, \ + maximum, \ + size, \ + is_string, \ + maximum_name_length \ + ) +#endif + +/** + * @brief Object API Maximum Class + * + * This function returns the highest numeric value of a valid + * API for the specified @a api. + * + * @param[in] api is the API of interest + * + * @retval A positive integer on success and 0 otherwise. + */ +unsigned int _Objects_API_maximum_class( + uint32_t api +); + +/** + * @brief Allocates an object without locking the allocator mutex. + * + * This function can be called in two contexts + * - the executing thread is the owner of the object allocator mutex, or + * - in case the system state is not up, e.g. during sequential system + * initialization. + * + * @param[in] information The object information block. + * + * @retval NULL No object available. + * @retval object The allocated object. + * + * @see _Objects_Allocate() and _Objects_Free(). + */ +Objects_Control *_Objects_Allocate_unprotected( + Objects_Information *information +); + +/** + * @brief Allocates an object. + * + * This function locks the object allocator mutex via + * _Objects_Allocator_lock(). The caller must later unlock the object + * allocator mutex via _Objects_Allocator_unlock(). The caller must unlock the + * mutex in any case, even if the allocation failed due to resource shortage. + * + * A typical object allocation code looks like this: + * @code + * rtems_status_code some_create( rtems_id *id ) + * { + * rtems_status_code sc; + * Some_Control *some; + * + * // The object allocator mutex protects the executing thread from + * // asynchronous thread restart and deletion. + * some = (Some_Control *) _Objects_Allocate( &_Some_Information ); + * + * if ( some != NULL ) { + * _Some_Initialize( some ); + * sc = RTEMS_SUCCESSFUL; + * } else { + * sc = RTEMS_TOO_MANY; + * } + * + * _Objects_Allocator_unlock(); + * + * return sc; + * } + * @endcode + * + * @param[in] information The object information block. + * + * @retval NULL No object available. + * @retval object The allocated object. + * + * @see _Objects_Free(). + */ +Objects_Control *_Objects_Allocate( Objects_Information *information ); + +/** + * @brief Frees an object. + * + * Appends the object to the chain of inactive objects. + * + * @param[in] information The object information block. + * @param[in] the_object The object to free. + * + * @see _Objects_Allocate(). + * + * A typical object deletion code looks like this: + * @code + * rtems_status_code some_delete( rtems_id id ) + * { + * Some_Control *some; + * + * // The object allocator mutex protects the executing thread from + * // asynchronous thread restart and deletion. + * _Objects_Allocator_lock(); + * + * // Get the object under protection of the object allocator mutex. + * some = (Semaphore_Control *) + * _Objects_Get_no_protection( id, &_Some_Information ); + * + * if ( some == NULL ) { + * _Objects_Allocator_unlock(); + * return RTEMS_INVALID_ID; + * } + * + * // After the object close an object get with this identifier will + * // fail. + * _Objects_Close( &_Some_Information, &some->Object ); + * + * _Some_Delete( some ); + * + * // Thread dispatching is enabled. The object free is only protected + * // by the object allocator mutex. + * _Objects_Free( &_Some_Information, &some->Object ); + * + * _Objects_Allocator_unlock(); + * return RTEMS_SUCCESSFUL; + * } + * @endcode + */ +void _Objects_Free( + Objects_Information *information, + Objects_Control *the_object +); + +/** + * This function implements the common portion of the object + * identification directives. This directive returns the object + * id associated with name. If more than one object of this class + * is named name, then the object to which the id belongs is + * arbitrary. Node indicates the extent of the search for the + * id of the object named name. If the object class supports global + * objects, then the search can be limited to a particular node + * or allowed to encompass all nodes. + */ +typedef enum { + OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL, + OBJECTS_INVALID_NAME, + OBJECTS_INVALID_ADDRESS, + OBJECTS_INVALID_ID, + OBJECTS_INVALID_NODE +} Objects_Name_or_id_lookup_errors; + +/** + * This macro defines the first entry in the + * @ref Objects_Name_or_id_lookup_errors enumerated list. + */ +#define OBJECTS_NAME_ERRORS_FIRST OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL + +/** + * This macro defines the last entry in the + * @ref Objects_Name_or_id_lookup_errors enumerated list. + */ +#define OBJECTS_NAME_ERRORS_LAST OBJECTS_INVALID_NODE + +/** + * @brief Converts an object name to an Id. + * + * This method converts an object name to an Id. It performs a look up + * using the object information block for this object class. + * + * @param[in] information points to an object class information block. + * @param[in] name is the name of the object to find. + * @param[in] node is the set of nodes to search. + * @param[in] id will contain the Id if the search is successful. + * + * @retval This method returns one of the values from the + * @ref Objects_Name_or_id_lookup_errors enumeration to indicate + * successful or failure. On success @a id will contain the Id of + * the requested object. + */ +Objects_Name_or_id_lookup_errors _Objects_Name_to_id_u32( + Objects_Information *information, + uint32_t name, + uint32_t node, + Objects_Id *id +); + +typedef enum { + OBJECTS_GET_BY_NAME_INVALID_NAME, + OBJECTS_GET_BY_NAME_NAME_TOO_LONG, + OBJECTS_GET_BY_NAME_NO_OBJECT +} Objects_Get_by_name_error; + +/** + * @brief Gets an object control block identified by its name. + * + * The object information must use string names. + * + * @param information The object information. Must not be NULL. + * @param name The object name. + * @param name_length_p Optional parameter to return the name length. + * @param error The error indication in case of failure. Must not be NULL. + * + * @retval NULL No object exists for this name or invalid parameters. + * @retval other The first object according to object index associated with + * this name. + */ +Objects_Control *_Objects_Get_by_name( + const Objects_Information *information, + const char *name, + size_t *name_length_p, + Objects_Get_by_name_error *error +); + +/** + * @brief Implements the common portion of the object Id to name directives. + * + * This function implements the common portion of the object Id + * to name directives. This function returns the name + * associated with object id. + * + * @param[in] id is the Id of the object whose name we are locating. + * @param[in] name will contain the name of the object, if found. + * + * @retval This method returns one of the values from the + * @ref Objects_Name_or_id_lookup_errors enumeration to indicate + * successful or failure. On success @a name will contain the name of + * the requested object. + * + * @note This function currently does not support string names. + */ +Objects_Name_or_id_lookup_errors _Objects_Id_to_name ( + Objects_Id id, + Objects_Name *name +); + +/** + * @brief Maps the specified object identifier to the associated local object + * control block. + * + * In this function interrupts are disabled during the object lookup. In case + * an associated object exists, then interrupts remain disabled, otherwise the + * previous interrupt state is restored. + * + * @param id The object identifier. This is the first parameter since usual + * callers get the object identifier as the first parameter themself. + * @param lock_context The interrupt lock context. This is the second + * parameter since usual callers get the interrupt lock context as the second + * parameter themself. + * @param information The object class information block. + * + * @retval NULL No associated object exists. + * @retval other The pointer to the associated object control block. + * Interrupts are now disabled and must be restored using the specified lock + * context via _ISR_lock_ISR_enable() or _ISR_lock_Release_and_ISR_enable(). + */ +Objects_Control *_Objects_Get( + Objects_Id id, + ISR_lock_Context *lock_context, + const Objects_Information *information +); + +/** + * @brief Maps object ids to object control blocks. + * + * This function maps object ids to object control blocks. + * If id corresponds to a local object, then it returns + * the_object control pointer which maps to id and location + * is set to OBJECTS_LOCAL. If the object class supports global + * objects and the object id is global and resides on a remote + * node, then location is set to OBJECTS_REMOTE, and the_object + * is undefined. Otherwise, location is set to OBJECTS_ERROR + * and the_object is undefined. + * + * @param[in] id is the Id of the object whose name we are locating. + * This is the first parameter since usual callers get the object identifier + * as the first parameter themself. + * @param[in] information points to an object class information block. + * + * @retval This method returns one of the values from the + * @ref Objects_Name_or_id_lookup_errors enumeration to indicate + * successful or failure. On success @a id will contain the Id of + * the requested object. + */ +Objects_Control *_Objects_Get_no_protection( + Objects_Id id, + const Objects_Information *information +); + +/** + * Gets the next open object after the specified object identifier. + * + * Locks the object allocator mutex in case a next object exists. + * + * @param[in] id is the Id of the object whose name we are locating. + * This is the first parameter since usual callers get the object identifier + * as the first parameter themself. + * @param[in] information points to an object class information block. + * @param[in] next_id_p is the Id of the next object we will look at. + * + * @retval This method returns the pointer to the object located or + * NULL on error. + */ +Objects_Control *_Objects_Get_next( + Objects_Id id, + const Objects_Information *information, + Objects_Id *next_id_p +); + +/** + * @brief Get object information. + * + * This function return the information structure given + * an the API and Class. This can be done independent of + * the existence of any objects created by the API. + * + * @param[in] the_api indicates the API for the information we want + * @param[in] the_class indicates the Class for the information we want + * + * @retval This method returns a pointer to the Object Information Table + * for the class of objects which corresponds to this object ID. + */ +Objects_Information *_Objects_Get_information( + Objects_APIs the_api, + uint16_t the_class +); + +/** + * @brief Get information of an object from an ID. + * + * This function return the information structure given + * an @a id of an object. + * + * @param[in] id is the object ID to get the information from + * + * @retval This method returns a pointer to the Object Information Table + * for the class of objects which corresponds to this object ID. + */ +Objects_Information *_Objects_Get_information_id( + Objects_Id id +); + +/** + * @brief Gets object name in the form of a C string. + * + * This method objects the name of an object and returns its name + * in the form of a C string. It attempts to be careful about + * overflowing the user's string and about returning unprintable characters. + * + * @param[in] id is the object to obtain the name of + * @param[in] length indicates the length of the caller's buffer + * @param[in] name points a string which will be filled in. + * + * @retval This method returns @a name or NULL on error. @a *name will + * contain the name if successful. + */ +char *_Objects_Get_name_as_string( + Objects_Id id, + size_t length, + char *name +); + +/** + * @brief Converts the specified object name to a text representation. + * + * Non-printable characters according to isprint() are converted to '*'. + * + * @param[in] name The object name. + * @param[in] is_string Indicates if the object name is a string or a four + * character array (32-bit unsigned integer). + * @param[in] buffer The string buffer for the text representation. + * @param[in] buffer_size The buffer size in characters. + * + * @retval The length of the text representation. May be greater than or equal + * to the buffer size if truncation occurred. + */ +size_t _Objects_Name_to_string( + Objects_Name name, + bool is_string, + char *buffer, + size_t buffer_size +); + +/** + * @brief Set objects name. + * + * This method sets the object name to either a copy of a string + * or up to the first four characters of the string based upon + * whether this object class uses strings for names. + * + * @param[in] information points to the object information structure + * @param[in] the_object is the object to operate upon + * @param[in] name is a pointer to the name to use + * + * @retval If successful, true is returned. Otherwise false is returned. + */ +bool _Objects_Set_name( + Objects_Information *information, + Objects_Control *the_object, + const char *name +); + +/** + * @brief Removes object from namespace. + * + * This function removes @a the_object from the namespace. + * + * @param[in] information points to an Object Information Table. + * @param[in] the_object is a pointer to an object. + */ +void _Objects_Namespace_remove( + Objects_Information *information, + Objects_Control *the_object +); + +/** + * @brief Close object. + * + * This function removes the_object control pointer and object name + * in the Local Pointer and Local Name Tables. + * + * @param[in] information points to an Object Information Table + * @param[in] the_object is a pointer to an object + */ +void _Objects_Close( + Objects_Information *information, + Objects_Control *the_object +); + +/** + * @brief Returns the count of active objects. + * + * @param[in] information The object information table. + * + * @retval The count of active objects. + */ +Objects_Maximum _Objects_Active_count( + const Objects_Information *information +); + +RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Extend_size( + const Objects_Information *information +) +{ + return information->auto_extend ? information->allocation_size : 0; +} + +/** + * This function returns true if the api is valid. + * + * @param[in] the_api is the api portion of an object ID. + * + * @return This method returns true if the specified api value is valid + * and false otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Objects_Is_api_valid( + uint32_t the_api +) +{ + if ( !the_api || the_api > OBJECTS_APIS_LAST ) + return false; + return true; +} + +/** + * This function returns true if the node is of the local object, and + * false otherwise. + * + * @param[in] node is the node number and corresponds to the node number + * portion of an object ID. + * + * @return This method returns true if the specified node is the local node + * and false otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Objects_Is_local_node( + uint32_t node +) +{ + return ( node == _Objects_Local_node ); +} + +/** + * This function returns true if the id is of a local object, and + * false otherwise. + * + * @param[in] id is an object ID + * + * @return This method returns true if the specified object Id is local + * and false otherwise. + * + * @note On a single processor configuration, this always returns true. + */ +RTEMS_INLINE_ROUTINE bool _Objects_Is_local_id( +#if defined(RTEMS_MULTIPROCESSING) + Objects_Id id +#else + Objects_Id id RTEMS_UNUSED +#endif +) +{ +#if defined(RTEMS_MULTIPROCESSING) + return _Objects_Is_local_node( _Objects_Get_node(id) ); +#else + return true; +#endif +} + +/** + * This function returns true if left and right are equal, + * and false otherwise. + * + * @param[in] left is the Id on the left hand side of the comparison + * @param[in] right is the Id on the right hand side of the comparison + * + * @return This method returns true if the specified object IDs are equal + * and false otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Objects_Are_ids_equal( + Objects_Id left, + Objects_Id right +) +{ + return ( left == right ); +} + +/** + * This function sets the pointer to the local_table object + * referenced by the index. + * + * @param[in] information points to an Object Information Table + * @param[in] index is the index of the object the caller wants to access + * @param[in] the_object is the local object pointer + * + * @note This routine is ONLY to be called in places where the + * index portion of the Id is known to be good. This is + * OK since it is normally called from object create/init + * or delete/destroy operations. + */ + +RTEMS_INLINE_ROUTINE void _Objects_Set_local_object( + Objects_Information *information, + uint32_t index, + Objects_Control *the_object +) +{ + /* + * This routine is ONLY to be called from places in the code + * where the Id is known to be good. Therefore, this should NOT + * occur in normal situations. + */ + #if defined(RTEMS_DEBUG) + if ( index > information->maximum ) + return; + #endif + + information->local_table[ index ] = the_object; +} + +/** + * This function sets the pointer to the local_table object + * referenced by the index to a NULL so the object Id is invalid + * after this call. + * + * @param[in] information points to an Object Information Table + * @param[in] the_object is the local object pointer + * + * @note This routine is ONLY to be called in places where the + * index portion of the Id is known to be good. This is + * OK since it is normally called from object create/init + * or delete/destroy operations. + */ + +RTEMS_INLINE_ROUTINE void _Objects_Invalidate_Id( + Objects_Information *information, + Objects_Control *the_object +) +{ + _Assert( information != NULL ); + _Assert( the_object != NULL ); + + _Objects_Set_local_object( + information, + _Objects_Get_index( the_object->id ), + NULL + ); +} + +/** + * This function places the_object control pointer and object name + * in the Local Pointer and Local Name Tables, respectively. + * + * @param[in] information points to an Object Information Table + * @param[in] the_object is a pointer to an object + * @param[in] name is the name of the object to make accessible + */ +RTEMS_INLINE_ROUTINE void _Objects_Open( + Objects_Information *information, + Objects_Control *the_object, + Objects_Name name +) +{ + _Assert( information != NULL ); + _Assert( the_object != NULL ); + + the_object->name = name; + + _Objects_Set_local_object( + information, + _Objects_Get_index( the_object->id ), + the_object + ); +} + +/** + * This function places the_object control pointer and object name + * in the Local Pointer and Local Name Tables, respectively. + * + * @param[in] information points to an Object Information Table + * @param[in] the_object is a pointer to an object + * @param[in] name is the name of the object to make accessible + */ +RTEMS_INLINE_ROUTINE void _Objects_Open_u32( + Objects_Information *information, + Objects_Control *the_object, + uint32_t name +) +{ + /* ASSERT: information->is_string == false */ + the_object->name.name_u32 = name; + + _Objects_Set_local_object( + information, + _Objects_Get_index( the_object->id ), + the_object + ); +} + +/** + * This function places the_object control pointer and object name + * in the Local Pointer and Local Name Tables, respectively. + * + * @param[in] information points to an Object Information Table + * @param[in] the_object is a pointer to an object + * @param[in] name is the name of the object to make accessible + */ +RTEMS_INLINE_ROUTINE void _Objects_Open_string( + Objects_Information *information, + Objects_Control *the_object, + const char *name +) +{ + #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES) + /* ASSERT: information->is_string */ + the_object->name.name_p = name; + #endif + + _Objects_Set_local_object( + information, + _Objects_Get_index( the_object->id ), + the_object + ); +} + +/** + * @brief Locks the object allocator mutex. + * + * While holding the allocator mutex the executing thread is protected from + * asynchronous thread restart and deletion. + * + * The usage of the object allocator mutex with the thread life protection + * makes it possible to allocate and free objects without thread dispatching + * disabled. The usage of a unified workspace and unlimited objects may lead + * to heap fragmentation. Thus the execution time of the _Objects_Allocate() + * function may increase during system run-time. + * + * @see _Objects_Allocator_unlock() and _Objects_Allocate(). + */ +RTEMS_INLINE_ROUTINE void _Objects_Allocator_lock( void ) +{ + _RTEMS_Lock_allocator(); +} + +/** + * @brief Unlocks the object allocator mutex. + * + * In case the mutex is fully unlocked, then this function restores the + * previous thread life protection state and thus may not return if the + * executing thread was restarted or deleted in the mean-time. + */ +RTEMS_INLINE_ROUTINE void _Objects_Allocator_unlock( void ) +{ + _RTEMS_Unlock_allocator(); +} + +RTEMS_INLINE_ROUTINE bool _Objects_Allocator_is_owner( void ) +{ + return _RTEMS_Allocator_is_owner(); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#if defined(RTEMS_MULTIPROCESSING) +#include +#endif + + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/objectmp.h b/cpukit/include/rtems/score/objectmp.h new file mode 100644 index 0000000000..5c9f4f74e3 --- /dev/null +++ b/cpukit/include/rtems/score/objectmp.h @@ -0,0 +1,197 @@ +/** + * @file rtems/score/objectmp.h + * + * @brief Data Associated with the Manipulation of Global RTEMS Objects + * + * This include file contains all the constants and structures associated + * with the manipulation of Global RTEMS Objects. + */ + +/* + * COPYRIGHT (c) 1989-2009. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_OBJECTMP_H +#define _RTEMS_SCORE_OBJECTMP_H + +#ifndef _RTEMS_SCORE_OBJECTIMPL_H +# error "Never use directly; include instead." +#endif + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ScoreObjectMP Object Handler Multiprocessing Support + * + * @ingroup Score + * + * This handler encapsulates functionality which is used to manage + * objects which have been declared to be globally visible. This handler + * knows objects from all of the nodes in the system. + */ +/**@{*/ + +/** + * @brief Intializes the inactive global object chain + * based on the maximum number of global objects configured. + * + * This routine intializes the inactive global object chain + * based on the maximum number of global objects configured. + */ +void _Objects_MP_Handler_initialization(void); + +/** + * @brief Intializes the global object node number + * used in the ID field of all objects. + * + * This routine intializes the global object node number + * used in the ID field of all objects. + */ +void _Objects_MP_Handler_early_initialization(void); + +/** + * @brief Place the specified global object in the + * specified information table. + * + * This routine place the specified global object in the + * specified information table. + * + * @param[in] information points to the object information table for this + * object class. + * @param[in] the_global_object points to the object being opened. + * @param[in] the_name is the name of the object being opened. + * @param[in] the_id is the Id of the object being opened. + * + * @todo This method only works for object types with 4 byte object names. + * It does not support variable length object names. + */ +void _Objects_MP_Open ( + Objects_Information *information, + Objects_MP_Control *the_global_object, + uint32_t the_name, + Objects_Id the_id +); + +/** + * @brief Allocates a global object control block + * and places it in the specified information table. + * + * This routine allocates a global object control block + * and places it in the specified information table. If the + * allocation fails, then is_fatal_error determines the + * error processing actions taken. + * + * @param[in] information points to the object information table for this + * object class. + * @param[in] the_name is the name of the object being opened. + * @param[in] the_id is the Id of the object being opened. + * @param[in] is_fatal_error is true if not being able to allocate the + * object is considered a fatal error. + * + * @todo This method only works for object types with 4 byte object names. + * It does not support variable length object names. + */ +bool _Objects_MP_Allocate_and_open ( + Objects_Information *information, + uint32_t the_name, + Objects_Id the_id, + bool is_fatal_error +); + +/** + * @brief Removes a global object from the specified information table. + * + * This routine removes a global object from the specified + * information table and deallocates the global object control block. + */ +void _Objects_MP_Close ( + Objects_Information *information, + Objects_Id the_id +); + +/** + * @brief Look for the object with the_name in the global + * object tables indicated by information. + * + * This routine looks for the object with the_name in the global + * object tables indicated by information. It returns the ID of the + * object with that name if one is found. + * + * @param[in] information points to the object information table for this + * object class. + * @param[in] the_name is the name of the object being searched for. + * @param[in] nodes_to_search indicates the set of nodes to search. + * @param[in] the_id will contain the Id of the object if found. + * + * @retval This method returns one of the + * @ref Objects_Name_or_id_lookup_errors. If successful, @a the_id + * will contain the Id of the object. + */ +Objects_Name_or_id_lookup_errors _Objects_MP_Global_name_search ( + Objects_Information *information, + Objects_Name the_name, + uint32_t nodes_to_search, + Objects_Id *the_id +); + +/** + * @brief Returns true, if the object identifier is in the global object + * identifier cache of the specified object information, otherwise false. + * + * @param id The object identifier. + * @param information The object information. + * + * @retval true A remote objects with this object identifier exits in the + * global object identifier cache of the specified information. + * @retval false Otherwise. + */ +bool _Objects_MP_Is_remote( + Objects_Id id, + const Objects_Information *information +); + +/** + * This is the maximum number of global objects configured. + */ +extern uint32_t _Objects_MP_Maximum_global_objects; + +/** + * This function allocates a Global Object control block. + */ + +Objects_MP_Control *_Objects_MP_Allocate_global_object( void ); + +/** + * This routine deallocates a Global Object control block. + */ + +void _Objects_MP_Free_global_object( Objects_MP_Control *the_object ); + +/** + * This function returns whether the global object is NULL or not. + */ + +RTEMS_INLINE_ROUTINE bool _Objects_MP_Is_null_global_object ( + Objects_MP_Control *the_object +) +{ + return( the_object == NULL ); +} + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/onceimpl.h b/cpukit/include/rtems/score/onceimpl.h new file mode 100644 index 0000000000..60f1378506 --- /dev/null +++ b/cpukit/include/rtems/score/onceimpl.h @@ -0,0 +1,52 @@ +/** + * @file + * + * @ingroup ScoreOnce + * + * @brief Once API + */ + +/* + * Copyright (c) 2014 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_ONCE_H +#define _RTEMS_ONCE_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup ScoreOnce Once Functions. + * + * @ingroup Score + * + * @brief The _Once() function for pthread_once() and rtems_gxx_once(). + * + * @{ + */ + +int _Once( unsigned char *once_state, void (*init_routine)(void) ); + +void _Once_Lock( void ); + +void _Once_Unlock( void ); + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_ONCE_H */ diff --git a/cpukit/include/rtems/score/percpu.h b/cpukit/include/rtems/score/percpu.h new file mode 100644 index 0000000000..00528b5ce3 --- /dev/null +++ b/cpukit/include/rtems/score/percpu.h @@ -0,0 +1,851 @@ +/** + * @file rtems/score/percpu.h + * + * This include file defines the per CPU information required + * by RTEMS. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * Copyright (c) 2012, 2016 embedded brains GmbH + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_PERCPU_H +#define _RTEMS_PERCPU_H + +#include + +#if defined( ASM ) + #include +#else + #include + #include + #include + #include + #include + #include + #include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(RTEMS_SMP) + #if defined(RTEMS_PROFILING) + #define PER_CPU_CONTROL_SIZE_APPROX ( 512 + CPU_INTERRUPT_FRAME_SIZE ) + #elif defined(RTEMS_DEBUG) + #define PER_CPU_CONTROL_SIZE_APPROX ( 256 + CPU_INTERRUPT_FRAME_SIZE ) + #else + #define PER_CPU_CONTROL_SIZE_APPROX ( 128 + CPU_INTERRUPT_FRAME_SIZE ) + #endif + + /* + * This ensures that on SMP configurations the individual per-CPU controls + * are on different cache lines to prevent false sharing. This define can be + * used in assembler code to easily get the per-CPU control for a particular + * processor. + */ + #if PER_CPU_CONTROL_SIZE_APPROX > 1024 + #define PER_CPU_CONTROL_SIZE_LOG2 11 + #elif PER_CPU_CONTROL_SIZE_APPROX > 512 + #define PER_CPU_CONTROL_SIZE_LOG2 10 + #elif PER_CPU_CONTROL_SIZE_APPROX > 256 + #define PER_CPU_CONTROL_SIZE_LOG2 9 + #elif PER_CPU_CONTROL_SIZE_APPROX > 128 + #define PER_CPU_CONTROL_SIZE_LOG2 8 + #else + #define PER_CPU_CONTROL_SIZE_LOG2 7 + #endif + + #define PER_CPU_CONTROL_SIZE ( 1 << PER_CPU_CONTROL_SIZE_LOG2 ) +#endif + +#if !defined( ASM ) + +struct _Thread_Control; + +struct Scheduler_Context; + +/** + * @defgroup PerCPU RTEMS Per CPU Information + * + * @ingroup Score + * + * This defines the per CPU state information required by RTEMS + * and the BSP. In an SMP configuration, there will be multiple + * instances of this data structure -- one per CPU -- and the + * current CPU number will be used as the index. + */ + +/**@{*/ + +#if defined( RTEMS_SMP ) + +/** + * @brief State of a processor. + * + * The processor state controls the life cycle of processors at the lowest + * level. No multi-threading or other high-level concepts matter here. + * + * State changes must be initiated via _Per_CPU_State_change(). This function + * may not return in case someone requested a shutdown. The + * _SMP_Send_message() function will be used to notify other processors about + * state changes if the other processor is in the up state. + * + * Due to the sequential nature of the basic system initialization one + * processor has a special role. It is the processor executing the boot_card() + * function. This processor is called the boot processor. All other + * processors are called secondary. + * + * @dot + * digraph states { + * i [label="PER_CPU_STATE_INITIAL"]; + * rdy [label="PER_CPU_STATE_READY_TO_START_MULTITASKING"]; + * reqsm [label="PER_CPU_STATE_REQUEST_START_MULTITASKING"]; + * u [label="PER_CPU_STATE_UP"]; + * s [label="PER_CPU_STATE_SHUTDOWN"]; + * i -> rdy [label="processor\ncompleted initialization"]; + * rdy -> reqsm [label="boot processor\ncompleted initialization"]; + * reqsm -> u [label="processor\nstarts multitasking"]; + * i -> s; + * rdy -> s; + * reqsm -> s; + * u -> s; + * } + * @enddot + */ +typedef enum { + /** + * @brief The per CPU controls are initialized to zero. + * + * The boot processor executes the sequential boot code in this state. The + * secondary processors should perform their basic initialization now and + * change into the PER_CPU_STATE_READY_TO_START_MULTITASKING state once this + * is complete. + */ + PER_CPU_STATE_INITIAL, + + /** + * @brief Processor is ready to start multitasking. + * + * The secondary processor performed its basic initialization and is ready to + * receive inter-processor interrupts. Interrupt delivery must be disabled + * in this state, but requested inter-processor interrupts must be recorded + * and must be delivered once the secondary processor enables interrupts for + * the first time. The boot processor will wait for all secondary processors + * to change into this state. In case a secondary processor does not reach + * this state the system will not start. The secondary processors wait now + * for a change into the PER_CPU_STATE_REQUEST_START_MULTITASKING state set + * by the boot processor once all secondary processors reached the + * PER_CPU_STATE_READY_TO_START_MULTITASKING state. + */ + PER_CPU_STATE_READY_TO_START_MULTITASKING, + + /** + * @brief Multitasking start of processor is requested. + * + * The boot processor completed system initialization and is about to perform + * a context switch to its heir thread. Secondary processors should now + * issue a context switch to the heir thread. This normally enables + * interrupts on the processor for the first time. + */ + PER_CPU_STATE_REQUEST_START_MULTITASKING, + + /** + * @brief Normal multitasking state. + */ + PER_CPU_STATE_UP, + + /** + * @brief This is the terminal state. + */ + PER_CPU_STATE_SHUTDOWN +} Per_CPU_State; + +#endif /* defined( RTEMS_SMP ) */ + +/** + * @brief Per-CPU statistics. + */ +typedef struct { +#if defined( RTEMS_PROFILING ) + /** + * @brief The thread dispatch disabled begin instant in CPU counter ticks. + * + * This value is used to measure the time of disabled thread dispatching. + */ + CPU_Counter_ticks thread_dispatch_disabled_instant; + + /** + * @brief The maximum time of disabled thread dispatching in CPU counter + * ticks. + */ + CPU_Counter_ticks max_thread_dispatch_disabled_time; + + /** + * @brief The maximum time spent to process a single sequence of nested + * interrupts in CPU counter ticks. + * + * This is the time interval between the change of the interrupt nest level + * from zero to one and the change back from one to zero. + */ + CPU_Counter_ticks max_interrupt_time; + + /** + * @brief The maximum interrupt delay in CPU counter ticks if supported by + * the hardware. + */ + CPU_Counter_ticks max_interrupt_delay; + + /** + * @brief Count of times when the thread dispatch disable level changes from + * zero to one in thread context. + * + * This value may overflow. + */ + uint64_t thread_dispatch_disabled_count; + + /** + * @brief Total time of disabled thread dispatching in CPU counter ticks. + * + * The average time of disabled thread dispatching is the total time of + * disabled thread dispatching divided by the thread dispatch disabled + * count. + * + * This value may overflow. + */ + uint64_t total_thread_dispatch_disabled_time; + + /** + * @brief Count of times when the interrupt nest level changes from zero to + * one. + * + * This value may overflow. + */ + uint64_t interrupt_count; + + /** + * @brief Total time of interrupt processing in CPU counter ticks. + * + * The average time of interrupt processing is the total time of interrupt + * processing divided by the interrupt count. + * + * This value may overflow. + */ + uint64_t total_interrupt_time; +#endif /* defined( RTEMS_PROFILING ) */ +} Per_CPU_Stats; + +/** + * @brief Per-CPU watchdog header index. + */ +typedef enum { + /** + * @brief Index for monotonic clock per-CPU watchdog header. + * + * The reference time point for the monotonic clock is the system start. The + * clock resolution is one system clock tick. It is used for the system + * clock tick based time services and the POSIX services using + * CLOCK_MONOTONIC. + */ + PER_CPU_WATCHDOG_MONOTONIC, + + /** + * @brief Index for realtime clock per-CPU watchdog header. + * + * The reference time point for the realtime clock is the POSIX Epoch. The + * clock resolution is one nanosecond. It is used for the time of day + * services and the POSIX services using CLOCK_REALTIME. + */ + PER_CPU_WATCHDOG_REALTIME, + + /** + * @brief Count of per-CPU watchdog headers. + */ + PER_CPU_WATCHDOG_COUNT +} Per_CPU_Watchdog_index; + +/** + * @brief Per CPU Core Structure + * + * This structure is used to hold per core state information. + */ +typedef struct Per_CPU_Control { + #if CPU_PER_CPU_CONTROL_SIZE > 0 + /** + * @brief CPU port specific control. + */ + CPU_Per_CPU_control cpu_per_cpu; + #endif + + #if (CPU_ALLOCATE_INTERRUPT_STACK == TRUE) || \ + (CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE) + /** + * This contains a pointer to the lower range of the interrupt stack for + * this CPU. This is the address allocated and freed. + */ + void *interrupt_stack_low; + + /** + * This contains a pointer to the interrupt stack pointer for this CPU. + * It will be loaded at the beginning on an ISR. + */ + void *interrupt_stack_high; + #endif + + /** + * This contains the current interrupt nesting level on this + * CPU. + */ + uint32_t isr_nest_level; + + /** + * @brief Indicetes if an ISR thread dispatch is disabled. + * + * This flag is context switched with each thread. It indicates that this + * thread has an interrupt stack frame on its stack. By using this flag, we + * can avoid nesting more interrupt dispatching attempts on a previously + * interrupted thread's stack. + */ + uint32_t isr_dispatch_disable; + + /** + * @brief The thread dispatch critical section nesting counter which is used + * to prevent context switches at inopportune moments. + */ + volatile uint32_t thread_dispatch_disable_level; + + /** + * @brief This is set to true when this processor needs to run the thread + * dispatcher. + * + * It is volatile since interrupts may alter this flag. + * + * This field is not protected by a lock and must be accessed only by this + * processor. Code (e.g. scheduler and post-switch action requests) running + * on another processors must use an inter-processor interrupt to set the + * thread dispatch necessary indicator to true. + * + * @see _Thread_Get_heir_and_make_it_executing(). + */ + volatile bool dispatch_necessary; + + /* + * Ensure that the executing member is at least 4-byte aligned, see + * PER_CPU_OFFSET_EXECUTING. This is necessary on CPU ports with relaxed + * alignment restrictions, e.g. type alignment is less than the type size. + */ + bool reserved_for_executing_alignment[ 3 ]; + + /** + * @brief This is the thread executing on this processor. + * + * This field is not protected by a lock. The only writer is this processor. + * + * On SMP configurations a thread may be registered as executing on more than + * one processor in case a thread migration is in progress. On SMP + * configurations use _Thread_Is_executing_on_a_processor() to figure out if + * a thread context is executing on a processor. + */ + struct _Thread_Control *executing; + + /** + * @brief This is the heir thread for this processor. + * + * This field is not protected by a lock. The only writer after multitasking + * start is the scheduler owning this processor. It is assumed that stores + * to pointers are atomic on all supported SMP architectures. The CPU port + * specific code (inter-processor interrupt handling and + * _CPU_SMP_Send_interrupt()) must guarantee that this processor observes the + * last value written. + * + * A thread can be a heir on at most one processor in the system. + * + * @see _Thread_Get_heir_and_make_it_executing(). + */ + struct _Thread_Control *heir; + +#if defined(RTEMS_SMP) + CPU_Interrupt_frame Interrupt_frame; +#endif + + /** + * @brief The CPU usage timestamp contains the time point of the last heir + * thread change or last CPU usage update of the executing thread of this + * processor. + * + * Protected by the scheduler lock. + * + * @see _Scheduler_Update_heir(), _Thread_Dispatch_update_heir() and + * _Thread_Get_CPU_time_used(). + */ + Timestamp_Control cpu_usage_timestamp; + + /** + * @brief Watchdog state for this processor. + */ + struct { + /** + * @brief Protects all watchdog operations on this processor. + */ + ISR_LOCK_MEMBER( Lock ) + + /** + * @brief Watchdog ticks on this processor used for monotonic clock + * watchdogs. + */ + uint64_t ticks; + + /** + * @brief Header for watchdogs. + * + * @see Per_CPU_Watchdog_index. + */ + Watchdog_Header Header[ PER_CPU_WATCHDOG_COUNT ]; + } Watchdog; + + #if defined( RTEMS_SMP ) + /** + * @brief This lock protects some parts of the low-level thread dispatching. + * + * We must use a ticket lock here since we cannot transport a local context + * through the context switch. + * + * @see _Thread_Dispatch(). + */ + SMP_ticket_lock_Control Lock; + + #if defined( RTEMS_PROFILING ) + /** + * @brief Lock statistics for the per-CPU lock. + */ + SMP_lock_Stats Lock_stats; + + /** + * @brief Lock statistics context for the per-CPU lock. + */ + SMP_lock_Stats_context Lock_stats_context; + #endif + + /** + * @brief Chain of threads in need for help. + * + * This field is protected by the Per_CPU_Control::Lock lock. + */ + Chain_Control Threads_in_need_for_help; + + /** + * @brief Bit field for SMP messages. + * + * This bit field is not protected locks. Atomic operations are used to + * set and get the message bits. + */ + Atomic_Ulong message; + + struct { + /** + * @brief The scheduler control of the scheduler owning this processor. + * + * This pointer is NULL in case this processor is currently not used by a + * scheduler instance. + */ + const struct _Scheduler_Control *control; + + /** + * @brief The scheduler context of the scheduler owning this processor. + * + * This pointer is NULL in case this processor is currently not used by a + * scheduler instance. + */ + const struct Scheduler_Context *context; + + /** + * @brief The idle thread for this processor in case it is online and + * currently not used by a scheduler instance. + */ + struct _Thread_Control *idle_if_online_and_unused; + } Scheduler; + + /** + * @brief Indicates the current state of the CPU. + * + * This field is protected by the _Per_CPU_State_lock lock. + * + * @see _Per_CPU_State_change(). + */ + Per_CPU_State state; + + /** + * @brief Action to be executed by this processor in the + * SYSTEM_STATE_BEFORE_MULTITASKING state on behalf of the boot processor. + * + * @see _SMP_Before_multitasking_action(). + */ + Atomic_Uintptr before_multitasking_action; + + /** + * @brief Indicates if the processor has been successfully started via + * _CPU_SMP_Start_processor(). + */ + bool online; + + /** + * @brief Indicates if the processor is the one that performed the initial + * system initialization. + */ + bool boot; + #endif + + Per_CPU_Stats Stats; +} Per_CPU_Control; + +#if defined( RTEMS_SMP ) +typedef struct { + Per_CPU_Control per_cpu; + char unused_space_for_cache_line_alignment + [ PER_CPU_CONTROL_SIZE - sizeof( Per_CPU_Control ) ]; +} Per_CPU_Control_envelope; +#else +typedef struct { + Per_CPU_Control per_cpu; +} Per_CPU_Control_envelope; +#endif + +/** + * @brief Set of Per CPU Core Information + * + * This is an array of per CPU core information. + */ +extern Per_CPU_Control_envelope _Per_CPU_Information[] CPU_STRUCTURE_ALIGNMENT; + +#if defined( RTEMS_SMP ) +#define _Per_CPU_Acquire( cpu ) \ + _SMP_ticket_lock_Acquire( \ + &( cpu )->Lock, \ + &( cpu )->Lock_stats, \ + &( cpu )->Lock_stats_context \ + ) +#else +#define _Per_CPU_Acquire( cpu ) \ + do { \ + (void) ( cpu ); \ + } while ( 0 ) +#endif + +#if defined( RTEMS_SMP ) +#define _Per_CPU_Release( cpu ) \ + _SMP_ticket_lock_Release( \ + &( cpu )->Lock, \ + &( cpu )->Lock_stats_context \ + ) +#else +#define _Per_CPU_Release( cpu ) \ + do { \ + (void) ( cpu ); \ + } while ( 0 ) +#endif + +#if defined( RTEMS_SMP ) +#define _Per_CPU_ISR_disable_and_acquire( cpu, isr_cookie ) \ + do { \ + _ISR_Local_disable( isr_cookie ); \ + _Per_CPU_Acquire( cpu ); \ + } while ( 0 ) +#else +#define _Per_CPU_ISR_disable_and_acquire( cpu, isr_cookie ) \ + do { \ + _ISR_Local_disable( isr_cookie ); \ + (void) ( cpu ); \ + } while ( 0 ) +#endif + +#if defined( RTEMS_SMP ) +#define _Per_CPU_Release_and_ISR_enable( cpu, isr_cookie ) \ + do { \ + _Per_CPU_Release( cpu ); \ + _ISR_Local_enable( isr_cookie ); \ + } while ( 0 ) +#else +#define _Per_CPU_Release_and_ISR_enable( cpu, isr_cookie ) \ + do { \ + (void) ( cpu ); \ + _ISR_Local_enable( isr_cookie ); \ + } while ( 0 ) +#endif + +#if defined( RTEMS_SMP ) +#define _Per_CPU_Acquire_all( isr_cookie ) \ + do { \ + uint32_t ncpus = _SMP_Get_processor_count(); \ + uint32_t cpu; \ + _ISR_Local_disable( isr_cookie ); \ + for ( cpu = 0 ; cpu < ncpus ; ++cpu ) { \ + _Per_CPU_Acquire( _Per_CPU_Get_by_index( cpu ) ); \ + } \ + } while ( 0 ) +#else +#define _Per_CPU_Acquire_all( isr_cookie ) \ + _ISR_Local_disable( isr_cookie ) +#endif + +#if defined( RTEMS_SMP ) +#define _Per_CPU_Release_all( isr_cookie ) \ + do { \ + uint32_t ncpus = _SMP_Get_processor_count(); \ + uint32_t cpu; \ + for ( cpu = 0 ; cpu < ncpus ; ++cpu ) { \ + _Per_CPU_Release( _Per_CPU_Get_by_index( cpu ) ); \ + } \ + _ISR_Local_enable( isr_cookie ); \ + } while ( 0 ) +#else +#define _Per_CPU_Release_all( isr_cookie ) \ + _ISR_Local_enable( isr_cookie ) +#endif + +/* + * If we get the current processor index in a context which allows thread + * dispatching, then we may already run on another processor right after the + * read instruction. There are very few cases in which this makes sense (here + * we can use _Per_CPU_Get_snapshot()). All other places must use + * _Per_CPU_Get() so that we can add checks for RTEMS_DEBUG. + */ +#if defined( _CPU_Get_current_per_CPU_control ) + #define _Per_CPU_Get_snapshot() _CPU_Get_current_per_CPU_control() +#else + #define _Per_CPU_Get_snapshot() \ + ( &_Per_CPU_Information[ _SMP_Get_current_processor() ].per_cpu ) +#endif + +#if defined( RTEMS_SMP ) +static inline Per_CPU_Control *_Per_CPU_Get( void ) +{ + Per_CPU_Control *cpu_self = _Per_CPU_Get_snapshot(); + + _Assert( + cpu_self->thread_dispatch_disable_level != 0 || _ISR_Get_level() != 0 + ); + + return cpu_self; +} +#else +#define _Per_CPU_Get() _Per_CPU_Get_snapshot() +#endif + +static inline Per_CPU_Control *_Per_CPU_Get_by_index( uint32_t index ) +{ + return &_Per_CPU_Information[ index ].per_cpu; +} + +static inline uint32_t _Per_CPU_Get_index( const Per_CPU_Control *cpu ) +{ + const Per_CPU_Control_envelope *per_cpu_envelope = + ( const Per_CPU_Control_envelope * ) cpu; + + return ( uint32_t ) ( per_cpu_envelope - &_Per_CPU_Information[ 0 ] ); +} + +static inline struct _Thread_Control *_Per_CPU_Get_executing( + const Per_CPU_Control *cpu +) +{ + return cpu->executing; +} + +static inline bool _Per_CPU_Is_processor_online( + const Per_CPU_Control *cpu +) +{ +#if defined( RTEMS_SMP ) + return cpu->online; +#else + (void) cpu; + + return true; +#endif +} + +static inline bool _Per_CPU_Is_boot_processor( + const Per_CPU_Control *cpu +) +{ +#if defined( RTEMS_SMP ) + return cpu->boot; +#else + (void) cpu; + + return true; +#endif +} + +#if defined( RTEMS_SMP ) + +/** + * @brief Allocate and Initialize Per CPU Structures + * + * This method allocates and initialize the per CPU structure. + */ +void _Per_CPU_Initialize(void); + +void _Per_CPU_State_change( + Per_CPU_Control *cpu, + Per_CPU_State new_state +); + +/** + * @brief Waits for a processor to change into a non-initial state. + * + * This function should be called only in _CPU_SMP_Start_processor() if + * required by the CPU port or BSP. + * + * @code + * bool _CPU_SMP_Start_processor(uint32_t cpu_index) + * { + * uint32_t timeout = 123456; + * + * start_the_processor(cpu_index); + * + * return _Per_CPU_State_wait_for_non_initial_state(cpu_index, timeout); + * } + * @endcode + * + * @param[in] cpu_index The processor index. + * @param[in] timeout_in_ns The timeout in nanoseconds. Use a value of zero to + * wait forever if necessary. + * + * @retval true The processor is in a non-initial state. + * @retval false The timeout expired before the processor reached a non-initial + * state. + */ +bool _Per_CPU_State_wait_for_non_initial_state( + uint32_t cpu_index, + uint32_t timeout_in_ns +); + +#endif /* defined( RTEMS_SMP ) */ + +/* + * On a non SMP system, the _SMP_Get_current_processor() is defined to 0. + * Thus when built for non-SMP, there should be no performance penalty. + */ +#define _Thread_Dispatch_disable_level \ + _Per_CPU_Get()->thread_dispatch_disable_level +#define _Thread_Heir \ + _Per_CPU_Get()->heir + +#if defined(_CPU_Get_thread_executing) +#define _Thread_Executing \ + _CPU_Get_thread_executing() +#else +#define _Thread_Executing \ + _Per_CPU_Get_executing( _Per_CPU_Get() ) +#endif + +#define _ISR_Nest_level \ + _Per_CPU_Get()->isr_nest_level +#define _CPU_Interrupt_stack_low \ + _Per_CPU_Get()->interrupt_stack_low +#define _CPU_Interrupt_stack_high \ + _Per_CPU_Get()->interrupt_stack_high +#define _Thread_Dispatch_necessary \ + _Per_CPU_Get()->dispatch_necessary + +/** + * @brief Returns the thread control block of the executing thread. + * + * This function can be called in any thread context. On SMP configurations, + * interrupts are disabled to ensure that the processor index is used + * consistently if no CPU port specific method is available to get the + * executing thread. + * + * @return The thread control block of the executing thread. + */ +RTEMS_INLINE_ROUTINE struct _Thread_Control *_Thread_Get_executing( void ) +{ + struct _Thread_Control *executing; + + #if defined(RTEMS_SMP) && !defined(_CPU_Get_thread_executing) + ISR_Level level; + + _ISR_Local_disable( level ); + #endif + + executing = _Thread_Executing; + + #if defined(RTEMS_SMP) && !defined(_CPU_Get_thread_executing) + _ISR_Local_enable( level ); + #endif + + return executing; +} + +/**@}*/ + +#endif /* !defined( ASM ) */ + +#if defined( ASM ) || defined( _RTEMS_PERCPU_DEFINE_OFFSETS ) + +#if (CPU_ALLOCATE_INTERRUPT_STACK == TRUE) || \ + (CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE) + /* + * If this CPU target lets RTEMS allocates the interrupt stack, then + * we need to have places in the per CPU table to hold them. + */ + #define PER_CPU_INTERRUPT_STACK_LOW \ + CPU_PER_CPU_CONTROL_SIZE + #define PER_CPU_INTERRUPT_STACK_HIGH \ + PER_CPU_INTERRUPT_STACK_LOW + CPU_SIZEOF_POINTER + #define PER_CPU_END_STACK \ + PER_CPU_INTERRUPT_STACK_HIGH + CPU_SIZEOF_POINTER + + #define INTERRUPT_STACK_LOW \ + (SYM(_Per_CPU_Information) + PER_CPU_INTERRUPT_STACK_LOW) + #define INTERRUPT_STACK_HIGH \ + (SYM(_Per_CPU_Information) + PER_CPU_INTERRUPT_STACK_HIGH) +#else + #define PER_CPU_END_STACK \ + CPU_PER_CPU_CONTROL_SIZE +#endif + +/* + * These are the offsets of the required elements in the per CPU table. + */ +#define PER_CPU_ISR_NEST_LEVEL \ + PER_CPU_END_STACK +#define PER_CPU_ISR_DISPATCH_DISABLE \ + PER_CPU_ISR_NEST_LEVEL + 4 +#define PER_CPU_THREAD_DISPATCH_DISABLE_LEVEL \ + PER_CPU_ISR_DISPATCH_DISABLE + 4 +#define PER_CPU_DISPATCH_NEEDED \ + PER_CPU_THREAD_DISPATCH_DISABLE_LEVEL + 4 +#define PER_CPU_OFFSET_EXECUTING \ + PER_CPU_DISPATCH_NEEDED + 4 +#define PER_CPU_OFFSET_HEIR \ + PER_CPU_OFFSET_EXECUTING + CPU_SIZEOF_POINTER +#if defined(RTEMS_SMP) +#define PER_CPU_INTERRUPT_FRAME_AREA \ + PER_CPU_OFFSET_HEIR + CPU_SIZEOF_POINTER +#endif + +#define THREAD_DISPATCH_DISABLE_LEVEL \ + (SYM(_Per_CPU_Information) + PER_CPU_THREAD_DISPATCH_DISABLE_LEVEL) +#define ISR_NEST_LEVEL \ + (SYM(_Per_CPU_Information) + PER_CPU_ISR_NEST_LEVEL) +#define DISPATCH_NEEDED \ + (SYM(_Per_CPU_Information) + PER_CPU_DISPATCH_NEEDED) + +#endif /* defined( ASM ) || defined( _RTEMS_PERCPU_DEFINE_OFFSETS ) */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/priority.h b/cpukit/include/rtems/score/priority.h new file mode 100644 index 0000000000..7a8ddba763 --- /dev/null +++ b/cpukit/include/rtems/score/priority.h @@ -0,0 +1,203 @@ +/** + * @file + * + * @brief Priority Handler API + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * Copyright (c) 2016, 2017 embedded brains GmbH. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_PRIORITY_H +#define _RTEMS_SCORE_PRIORITY_H + +#include +#include +#include + +struct _Scheduler_Control; + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ScorePriority Priority Handler + * + * @ingroup Score + * + * This handler encapsulates functionality which is used to manage thread + * priorities. The actual priority of a thread is an aggregation of priority + * nodes. The thread priority aggregation for the home scheduler instance of a + * thread consists of at least one priority node, which is normally the real + * priority of the thread. The locking protocols (e.g. priority ceiling and + * priority inheritance), rate-monotonic period objects and the POSIX sporadic + * server add, change and remove priority nodes. + * + * @{ + */ + +/** + * @brief The thread priority control. + * + * Lower values represent higher priorities. So, a priority value of zero + * represents the highest priority thread. This value is reserved for internal + * threads and the priority ceiling protocol. + * + * The format of the thread priority control depends on the context. A thread + * priority control may contain a user visible priority for API import/export. + * It may also contain a scheduler internal priority value. Values are + * translated via the scheduler map/unmap priority operations. The format of + * scheduler interal values depend on the particular scheduler implementation. + * It may for example encode a deadline in case of the EDF scheduler. + * + * The thread priority control value contained in the scheduler node + * (Scheduler_Node::Priority::value) uses the least-significant bit to indicate + * if the thread should be appended or prepended to its priority group, see + * SCHEDULER_PRIORITY_APPEND(). + */ +typedef uint64_t Priority_Control; + +/** + * @brief The highest (most important) thread priority value. + */ +#define PRIORITY_MINIMUM 0 + +/** + * @brief The priority value of pseudo-ISR threads. + * + * Examples are the MPCI and timer server threads. + */ +#define PRIORITY_PSEUDO_ISR PRIORITY_MINIMUM + +/** + * @brief The default lowest (least important) thread priority value. + * + * This value is CPU port dependent. + */ +#if defined (CPU_PRIORITY_MAXIMUM) + #define PRIORITY_DEFAULT_MAXIMUM CPU_PRIORITY_MAXIMUM +#else + #define PRIORITY_DEFAULT_MAXIMUM 255 +#endif + +/** + * @brief The priority node to build up a priority aggregation. + */ +typedef struct { + /** + * @brief Node component for a chain or red-black tree. + */ + union { + Chain_Node Chain; + RBTree_Node RBTree; + } Node; + + /** + * @brief The priority value of this node. + */ + Priority_Control priority; +} Priority_Node; + +/** + * @brief The priority action type. + */ +typedef enum { + PRIORITY_ACTION_ADD, + PRIORITY_ACTION_CHANGE, + PRIORITY_ACTION_REMOVE, + PRIORITY_ACTION_INVALID +} Priority_Action_type; + +typedef struct Priority_Aggregation Priority_Aggregation; + +/** + * @brief The priority aggregation. + * + * This structure serves two purposes. Firstly, it provides a place to + * register priority nodes and reflects the overall priority of its + * contributors. Secondly, it provides an action block to signal addition, + * change and removal of a priority node. + */ +struct Priority_Aggregation { + /** + * @brief This priority node reflects the overall priority of the aggregation. + * + * The overall priority of the aggregation is the minimum priority of the + * priority nodes in the contributors tree. + * + * This priority node may be used to add this aggregation to another + * aggregation to build up a recursive priority scheme. + * + * In case priority nodes of the contributors tree are added, changed or + * removed the priority of this node may change. To signal such changes to a + * priority aggregation the action block may be used. + */ + Priority_Node Node; + + /** + * @brief A red-black tree to contain priority nodes contributing to the + * overall priority of this priority aggregation. + */ + RBTree_Control Contributors; + +#if defined(RTEMS_SMP) + /** + * @brief The scheduler instance of this priority aggregation. + */ + const struct _Scheduler_Control *scheduler; +#endif + + /** + * @brief A priority action block to manage priority node additions, changes + * and removals. + */ + struct { +#if defined(RTEMS_SMP) + /** + * @brief The next priority aggregation in the action list. + */ + Priority_Aggregation *next; +#endif + + /** + * @brief The priority node of the action. + */ + Priority_Node *node; + + /** + * @brief The type of the action. + */ + Priority_Action_type type; + } Action; +}; + +/** + * @brief A list of priority actions. + * + * Actions are only added to the list. The action lists reside on the stack + * and have a short life-time. They are moved, processed or destroyed as a + * whole. + */ +typedef struct { + /** + * @brief The first action of a priority action list. + */ + Priority_Aggregation *actions; +} Priority_Actions; + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/prioritybitmap.h b/cpukit/include/rtems/score/prioritybitmap.h new file mode 100644 index 0000000000..40638dd628 --- /dev/null +++ b/cpukit/include/rtems/score/prioritybitmap.h @@ -0,0 +1,79 @@ +/** + * @file rtems/score/prioritybitmap.h + * + * @brief Manipulation Routines for the Bitmap Priority Queue Implementation + * + * This include file contains all thread priority manipulation routines for + * the bit map priority queue implementation. + */ + +/* + * COPYRIGHT (c) 1989-2010. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_PRIORITYBITMAP_H +#define _RTEMS_SCORE_PRIORITYBITMAP_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ScorePriorityBitmap Bitmap Priority Thread Routines + * + * @ingroup Score + */ +/**@{*/ + +typedef uint16_t Priority_bit_map_Word; + +typedef struct { + /** + * @brief Each sixteen bit entry in this word is associated with one of the + * sixteen entries in the bit map. + */ + Priority_bit_map_Word major_bit_map; + + /** + * @brief Each bit in the bit map indicates whether or not there are threads + * ready at a particular priority. + * + * The mapping of individual priority levels to particular bits is processor + * dependent as is the value of each bit used to indicate that threads are + * ready at that priority. + */ + Priority_bit_map_Word bit_map[ 16 ]; +} Priority_bit_map_Control; + +/** + * The following record defines the information associated with + * each thread to manage its interaction with the priority bit maps. + */ +typedef struct { + /** This is the address of minor bit map slot. */ + Priority_bit_map_Word *minor; + /** This is the priority bit map ready mask. */ + Priority_bit_map_Word ready_major; + /** This is the priority bit map ready mask. */ + Priority_bit_map_Word ready_minor; + /** This is the priority bit map block mask. */ + Priority_bit_map_Word block_major; + /** This is the priority bit map block mask. */ + Priority_bit_map_Word block_minor; +} Priority_bit_map_Information; + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/prioritybitmapimpl.h b/cpukit/include/rtems/score/prioritybitmapimpl.h new file mode 100644 index 0000000000..82c92eb5d6 --- /dev/null +++ b/cpukit/include/rtems/score/prioritybitmapimpl.h @@ -0,0 +1,215 @@ +/** + * @file + * + * @brief Inlined Routines in the Priority Handler Bit Map Implementation + * + * This file contains the static inline implementation of all inlined + * routines in the Priority Handler bit map implementation + */ + +/* + * COPYRIGHT (c) 1989-2010. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_PRIORITYBITMAPIMPL_H +#define _RTEMS_SCORE_PRIORITYBITMAPIMPL_H + +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup ScorePriority + */ +/**@{**/ + +/** + * This table is used by the generic bitfield routines to perform + * a highly optimized bit scan without the use of special CPU + * instructions. + */ +extern const unsigned char _Bitfield_Leading_zeros[256]; + +/** + * @brief Returns the bit number of the first bit set in the specified value. + * + * The correspondence between the bit number and actual bit position is CPU + * architecture dependent. The search for the first bit set may run from most + * to least significant bit or vice-versa. + * + * @param value The value to bit scan. + * + * @return The bit number of the first bit set. + * + * @see _Priority_Bits_index() and _Priority_Mask(). + */ +RTEMS_INLINE_ROUTINE unsigned int _Bitfield_Find_first_bit( + unsigned int value +) +{ + unsigned int bit_number; + +#if ( CPU_USE_GENERIC_BITFIELD_CODE == FALSE ) + _CPU_Bitfield_Find_first_bit( value, bit_number ); +#elif defined(__GNUC__) + bit_number = (unsigned int) __builtin_clz( value ) + - __SIZEOF_INT__ * __CHAR_BIT__ + 16; +#else + if ( value < 0x100 ) { + bit_number = _Bitfield_Leading_zeros[ value ] + 8; + } else { \ + bit_number = _Bitfield_Leading_zeros[ value >> 8 ]; + } +#endif + + return bit_number; +} + +/** + * @brief Returns the priority bit mask for the specified major or minor bit + * number. + * + * @param bit_number The bit number for which we need a mask. + * + * @return The priority bit mask. + */ +RTEMS_INLINE_ROUTINE Priority_bit_map_Word _Priority_Mask( + unsigned int bit_number +) +{ +#if ( CPU_USE_GENERIC_BITFIELD_CODE == FALSE ) + return _CPU_Priority_Mask( bit_number ); +#else + return (Priority_bit_map_Word) ( 0x8000u >> bit_number ); +#endif +} + +/** + * @brief Returns the bit index position for the specified major or minor bit + * number. + * + * @param bit_number The bit number for which we need an index. + * + * @return The corresponding array index into the priority bit map. + */ +RTEMS_INLINE_ROUTINE unsigned int _Priority_Bits_index( + unsigned int bit_number +) +{ +#if ( CPU_USE_GENERIC_BITFIELD_CODE == FALSE ) + return _CPU_Priority_bits_index( bit_number ); +#else + return bit_number; +#endif +} + +/** + * This function returns the major portion of the_priority. + */ + +RTEMS_INLINE_ROUTINE unsigned int _Priority_Major( unsigned int the_priority ) +{ + return the_priority / 16; +} + +/** + * This function returns the minor portion of the_priority. + */ + +RTEMS_INLINE_ROUTINE unsigned int _Priority_Minor( unsigned int the_priority ) +{ + return the_priority % 16; +} + +RTEMS_INLINE_ROUTINE void _Priority_bit_map_Initialize( + Priority_bit_map_Control *bit_map +) +{ + memset( bit_map, 0, sizeof( *bit_map ) ); +} + +/** + * Priority Queue implemented by bit map + */ + +RTEMS_INLINE_ROUTINE void _Priority_bit_map_Add ( + Priority_bit_map_Control *bit_map, + Priority_bit_map_Information *bit_map_info +) +{ + *bit_map_info->minor |= bit_map_info->ready_minor; + bit_map->major_bit_map |= bit_map_info->ready_major; +} + +RTEMS_INLINE_ROUTINE void _Priority_bit_map_Remove ( + Priority_bit_map_Control *bit_map, + Priority_bit_map_Information *bit_map_info +) +{ + *bit_map_info->minor &= bit_map_info->block_minor; + if ( *bit_map_info->minor == 0 ) + bit_map->major_bit_map &= bit_map_info->block_major; +} + +RTEMS_INLINE_ROUTINE unsigned int _Priority_bit_map_Get_highest( + const Priority_bit_map_Control *bit_map +) +{ + unsigned int minor; + unsigned int major; + + major = _Bitfield_Find_first_bit( bit_map->major_bit_map ); + minor = _Bitfield_Find_first_bit( bit_map->bit_map[ major ] ); + + return (_Priority_Bits_index( major ) << 4) + + _Priority_Bits_index( minor ); +} + +RTEMS_INLINE_ROUTINE bool _Priority_bit_map_Is_empty( + const Priority_bit_map_Control *bit_map +) +{ + return bit_map->major_bit_map == 0; +} + +RTEMS_INLINE_ROUTINE void _Priority_bit_map_Initialize_information( + Priority_bit_map_Control *bit_map, + Priority_bit_map_Information *bit_map_info, + unsigned int new_priority +) +{ + unsigned int major; + unsigned int minor; + Priority_bit_map_Word mask; + + major = _Priority_Major( new_priority ); + minor = _Priority_Minor( new_priority ); + + bit_map_info->minor = &bit_map->bit_map[ _Priority_Bits_index( major ) ]; + + mask = _Priority_Mask( major ); + bit_map_info->ready_major = mask; + bit_map_info->block_major = (Priority_bit_map_Word) ~mask; + + mask = _Priority_Mask( minor ); + bit_map_info->ready_minor = mask; + bit_map_info->block_minor = (Priority_bit_map_Word) ~mask; +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/priorityimpl.h b/cpukit/include/rtems/score/priorityimpl.h new file mode 100644 index 0000000000..3380983cb7 --- /dev/null +++ b/cpukit/include/rtems/score/priorityimpl.h @@ -0,0 +1,435 @@ +/* + * Copyright (c) 2016 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_PRIORITYIMPL_H +#define _RTEMS_SCORE_PRIORITYIMPL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +RTEMS_INLINE_ROUTINE void _Priority_Actions_initialize_empty( + Priority_Actions *actions +) +{ + actions->actions = NULL; +} + +RTEMS_INLINE_ROUTINE void _Priority_Actions_initialize_one( + Priority_Actions *actions, + Priority_Aggregation *aggregation, + Priority_Node *node, + Priority_Action_type type +) +{ +#if defined(RTEMS_SMP) + aggregation->Action.next = NULL; +#endif + aggregation->Action.node = node; + aggregation->Action.type = type; + + actions->actions = aggregation; +} + +RTEMS_INLINE_ROUTINE bool _Priority_Actions_is_empty( + const Priority_Actions *actions +) +{ + return actions->actions == NULL; +} + +RTEMS_INLINE_ROUTINE bool _Priority_Actions_is_valid( + const Priority_Aggregation *aggregation +) +{ +#if defined(RTEMS_SMP) + return aggregation != NULL; +#else + (void) aggregation; + return false; +#endif +} + +RTEMS_INLINE_ROUTINE Priority_Aggregation *_Priority_Actions_move( + Priority_Actions *actions +) +{ + Priority_Aggregation *aggregation; + + aggregation = actions->actions; + actions->actions = NULL; + + return aggregation; +} + +RTEMS_INLINE_ROUTINE void _Priority_Actions_add( + Priority_Actions *actions, + Priority_Aggregation *aggregation +) +{ +#if defined(RTEMS_SMP) + /* + * Priority aggregations are only added to action lists, so do not care about + * the current next pointer value. + */ + aggregation->Action.next = actions->actions; +#endif + actions->actions = aggregation; +} + +RTEMS_INLINE_ROUTINE void _Priority_Node_initialize( + Priority_Node *node, + Priority_Control priority +) +{ + node->priority = priority; + _RBTree_Initialize_node( &node->Node.RBTree ); +} + +RTEMS_INLINE_ROUTINE void _Priority_Node_set_priority( + Priority_Node *node, + Priority_Control priority +) +{ + node->priority = priority; +} + +RTEMS_INLINE_ROUTINE void _Priority_Node_set_inactive( + Priority_Node *node +) +{ + _RBTree_Set_off_tree( &node->Node.RBTree ); +} + +RTEMS_INLINE_ROUTINE bool _Priority_Node_is_active( + const Priority_Node *node +) +{ + return !_RBTree_Is_node_off_tree( &node->Node.RBTree ); +} + +RTEMS_INLINE_ROUTINE void _Priority_Initialize_empty( + Priority_Aggregation *aggregation +) +{ +#if defined(RTEMS_DEBUG) +#if defined(RTEMS_SMP) + aggregation->Action.next = NULL; +#endif + aggregation->Action.node = NULL; + aggregation->Action.type = PRIORITY_ACTION_INVALID; +#endif + _RBTree_Initialize_node( &aggregation->Node.Node.RBTree ); + _RBTree_Initialize_empty( &aggregation->Contributors ); +} + +RTEMS_INLINE_ROUTINE void _Priority_Initialize_one( + Priority_Aggregation *aggregation, + Priority_Node *node +) +{ +#if defined(RTEMS_DEBUG) +#if defined(RTEMS_SMP) + aggregation->Action.next = NULL; +#endif + aggregation->Action.node = NULL; + aggregation->Action.type = PRIORITY_ACTION_INVALID; +#endif + _Priority_Node_initialize( &aggregation->Node, node->priority ); + _RBTree_Initialize_one( &aggregation->Contributors, &node->Node.RBTree ); +} + +RTEMS_INLINE_ROUTINE bool _Priority_Is_empty( + const Priority_Aggregation *aggregation +) +{ + return _RBTree_Is_empty( &aggregation->Contributors ); +} + +RTEMS_INLINE_ROUTINE Priority_Control _Priority_Get_priority( + const Priority_Aggregation *aggregation +) +{ + return aggregation->Node.priority; +} + +RTEMS_INLINE_ROUTINE const Scheduler_Control *_Priority_Get_scheduler( + const Priority_Aggregation *aggregation +) +{ +#if defined(RTEMS_SMP) + return aggregation->scheduler; +#else + return &_Scheduler_Table[ 0 ]; +#endif +} + +RTEMS_INLINE_ROUTINE Priority_Node *_Priority_Get_minimum_node( + const Priority_Aggregation *aggregation +) +{ + return (Priority_Node *) _RBTree_Minimum( &aggregation->Contributors ); +} + +RTEMS_INLINE_ROUTINE void _Priority_Set_action_node( + Priority_Aggregation *aggregation, + Priority_Node *node +) +{ + aggregation->Action.node = node; +} + +RTEMS_INLINE_ROUTINE void _Priority_Set_action_type( + Priority_Aggregation *aggregation, + Priority_Action_type type +) +{ + aggregation->Action.type = type; +} + +RTEMS_INLINE_ROUTINE void _Priority_Set_action( + Priority_Aggregation *aggregation, + Priority_Node *node, + Priority_Action_type type +) +{ + aggregation->Action.node = node; + aggregation->Action.type = type; +} + +RTEMS_INLINE_ROUTINE Priority_Aggregation *_Priority_Get_next_action( + const Priority_Aggregation *aggregation +) +{ +#if defined(RTEMS_SMP) + return aggregation->Action.next; +#else + (void) aggregation; + return NULL; +#endif +} + +RTEMS_INLINE_ROUTINE bool _Priority_Less( + const void *left, + const RBTree_Node *right +) +{ + const Priority_Control *the_left; + const Priority_Node *the_right; + + the_left = left; + the_right = RTEMS_CONTAINER_OF( right, Priority_Node, Node.RBTree ); + + return *the_left < the_right->priority; +} + +RTEMS_INLINE_ROUTINE bool _Priority_Plain_insert( + Priority_Aggregation *aggregation, + Priority_Node *node, + Priority_Control priority +) +{ + return _RBTree_Insert_inline( + &aggregation->Contributors, + &node->Node.RBTree, + &priority, + _Priority_Less + ); +} + +RTEMS_INLINE_ROUTINE void _Priority_Plain_extract( + Priority_Aggregation *aggregation, + Priority_Node *node +) +{ + _RBTree_Extract( &aggregation->Contributors, &node->Node.RBTree ); +} + +RTEMS_INLINE_ROUTINE void _Priority_Plain_changed( + Priority_Aggregation *aggregation, + Priority_Node *node +) +{ + _Priority_Plain_extract( aggregation, node ); + _Priority_Plain_insert( aggregation, node, node->priority ); +} + +typedef void ( *Priority_Add_handler )( + Priority_Aggregation *aggregation, + Priority_Actions *actions, + void *arg +); + +typedef void ( *Priority_Change_handler )( + Priority_Aggregation *aggregation, + bool prepend_it, + Priority_Actions *actions, + void *arg +); + +typedef void ( *Priority_Remove_handler )( + Priority_Aggregation *aggregation, + Priority_Actions *actions, + void *arg +); + +RTEMS_INLINE_ROUTINE void _Priority_Change_nothing( + Priority_Aggregation *aggregation, + bool prepend_it, + Priority_Actions *actions, + void *arg +) +{ + (void) aggregation; + (void) prepend_it; + (void) actions; + (void) arg; +} + +RTEMS_INLINE_ROUTINE void _Priority_Remove_nothing( + Priority_Aggregation *aggregation, + Priority_Actions *actions, + void *arg +) +{ + (void) aggregation; + (void) actions; + (void) arg; +} + +RTEMS_INLINE_ROUTINE void _Priority_Non_empty_insert( + Priority_Aggregation *aggregation, + Priority_Node *node, + Priority_Actions *actions, + Priority_Change_handler change, + void *arg +) +{ + bool is_new_minimum; + + _Assert( !_Priority_Is_empty( aggregation ) ); + is_new_minimum = _Priority_Plain_insert( aggregation, node, node->priority ); + + if ( is_new_minimum ) { + aggregation->Node.priority = node->priority; + ( *change )( aggregation, false, actions, arg ); + } +} + +RTEMS_INLINE_ROUTINE void _Priority_Insert( + Priority_Aggregation *aggregation, + Priority_Node *node, + Priority_Actions *actions, + Priority_Add_handler add, + Priority_Change_handler change, + void *arg +) +{ + if ( _Priority_Is_empty( aggregation ) ) { + _Priority_Initialize_one( aggregation, node ); + ( *add )( aggregation, actions, arg ); + } else { + _Priority_Non_empty_insert( aggregation, node, actions, change, arg ); + } +} + +RTEMS_INLINE_ROUTINE void _Priority_Extract( + Priority_Aggregation *aggregation, + Priority_Node *node, + Priority_Actions *actions, + Priority_Remove_handler remove, + Priority_Change_handler change, + void *arg +) +{ + _Priority_Plain_extract( aggregation, node ); + + if ( _Priority_Is_empty( aggregation ) ) { + ( *remove )( aggregation, actions, arg ); + } else { + Priority_Node *min; + + min = _Priority_Get_minimum_node( aggregation ); + + if ( node->priority < min->priority ) { + aggregation->Node.priority = min->priority; + ( *change )( aggregation, true, actions, arg ); + } + } +} + +RTEMS_INLINE_ROUTINE void _Priority_Extract_non_empty( + Priority_Aggregation *aggregation, + Priority_Node *node, + Priority_Actions *actions, + Priority_Change_handler change, + void *arg +) +{ + Priority_Node *min; + + _Priority_Plain_extract( aggregation, node ); + _Assert( !_Priority_Is_empty( aggregation ) ); + + min = _Priority_Get_minimum_node( aggregation ); + + if ( node->priority < min->priority ) { + aggregation->Node.priority = min->priority; + ( *change )( aggregation, true, actions, arg ); + } +} + +RTEMS_INLINE_ROUTINE void _Priority_Changed( + Priority_Aggregation *aggregation, + Priority_Node *node, + bool prepend_it, + Priority_Actions *actions, + Priority_Change_handler change, + void *arg +) +{ + Priority_Node *min; + + _Priority_Plain_changed( aggregation, node ); + + min = _Priority_Get_minimum_node( aggregation ); + + if ( min->priority != aggregation->Node.priority ) { + aggregation->Node.priority = min->priority; + ( *change )( aggregation, prepend_it, actions, arg ); + } +} + +RTEMS_INLINE_ROUTINE void _Priority_Replace( + Priority_Aggregation *aggregation, + Priority_Node *victim, + Priority_Node *replacement +) +{ + replacement->priority = victim->priority; + _RBTree_Replace_node( + &aggregation->Contributors, + &victim->Node.RBTree, + &replacement->Node.RBTree + ); +} + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_SCORE_PRIORITYIMPL_H */ diff --git a/cpukit/include/rtems/score/processormask.h b/cpukit/include/rtems/score/processormask.h new file mode 100644 index 0000000000..a06aa2a56b --- /dev/null +++ b/cpukit/include/rtems/score/processormask.h @@ -0,0 +1,290 @@ +/** + * @file + * + * @brief Processor Mask API + * + * @ingroup ScoreProcessorMask + */ + +/* + * Copyright (c) 2016, 2017 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_PROCESSORMASK_H +#define _RTEMS_SCORE_PROCESSORMASK_H + +#include + +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup ScoreProcessorMask Processor Mask + * + * @ingroup Score + * + * The processor mask provides a bit map large enough to provide one bit for + * each processor in the system. It is a fixed size internal data type + * provided for efficiency in addition to the API level cpu_set_t. + * + * @{ + */ + +/** + * @brief A bit map which is large enough to provide one bit for each processor + * in the system. + */ +typedef BITSET_DEFINE( Processor_mask, CPU_MAXIMUM_PROCESSORS ) Processor_mask; + +RTEMS_INLINE_ROUTINE void _Processor_mask_Zero( Processor_mask *mask ) +{ + BIT_ZERO( CPU_MAXIMUM_PROCESSORS, mask ); +} + +RTEMS_INLINE_ROUTINE bool _Processor_mask_Is_zero( const Processor_mask *mask ) +{ + return BIT_EMPTY( CPU_MAXIMUM_PROCESSORS, mask ); +} + +RTEMS_INLINE_ROUTINE void _Processor_mask_Fill( Processor_mask *mask ) +{ + BIT_FILL( CPU_MAXIMUM_PROCESSORS, mask ); +} + +RTEMS_INLINE_ROUTINE void _Processor_mask_Assign( + Processor_mask *dst, const Processor_mask *src +) +{ + BIT_COPY( CPU_MAXIMUM_PROCESSORS, src, dst ); +} + +RTEMS_INLINE_ROUTINE void _Processor_mask_Set( + Processor_mask *mask, + uint32_t index +) +{ + BIT_SET( CPU_MAXIMUM_PROCESSORS, index, mask ); +} + +RTEMS_INLINE_ROUTINE void _Processor_mask_Clear( + Processor_mask *mask, + uint32_t index +) +{ + BIT_CLR( CPU_MAXIMUM_PROCESSORS, index, mask ); +} + +RTEMS_INLINE_ROUTINE bool _Processor_mask_Is_set( + const Processor_mask *mask, + uint32_t index +) +{ + return BIT_ISSET( CPU_MAXIMUM_PROCESSORS, index, mask ); +} + +/** + * @brief Returns true if the processor sets a and b are equal, and false + * otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Processor_mask_Is_equal( + const Processor_mask *a, + const Processor_mask *b +) +{ + return !BIT_CMP( CPU_MAXIMUM_PROCESSORS, a, b ); +} + +/** + * @brief Returns true if the intersection of the processor sets a and b is + * non-empty, and false otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Processor_mask_Has_overlap( + const Processor_mask *a, + const Processor_mask *b +) +{ + return BIT_OVERLAP( CPU_MAXIMUM_PROCESSORS, a, b ); +} + +/** + * @brief Returns true if the processor set small is a subset of processor set + * big, and false otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Processor_mask_Is_subset( + const Processor_mask *big, + const Processor_mask *small +) +{ + return BIT_SUBSET( CPU_MAXIMUM_PROCESSORS, big, small ); +} + +/** + * @brief Performs a bitwise a = b & c. + */ +RTEMS_INLINE_ROUTINE void _Processor_mask_And( + Processor_mask *a, + const Processor_mask *b, + const Processor_mask *c +) +{ + BIT_AND2( CPU_MAXIMUM_PROCESSORS, a, b, c ); +} + +/** + * @brief Performs a bitwise a = b & ~c. + */ +RTEMS_INLINE_ROUTINE void _Processor_mask_Nand( + Processor_mask *a, + const Processor_mask *b, + const Processor_mask *c +) +{ + BIT_NAND2( CPU_MAXIMUM_PROCESSORS, a, b, c ); +} + +/** + * @brief Performs a bitwise a = b | c. + */ +RTEMS_INLINE_ROUTINE void _Processor_mask_Or( + Processor_mask *a, + const Processor_mask *b, + const Processor_mask *c +) +{ + BIT_OR2( CPU_MAXIMUM_PROCESSORS, a, b, c ); +} + +/** + * @brief Performs a bitwise a = b ^ c. + */ +RTEMS_INLINE_ROUTINE void _Processor_mask_Xor( + Processor_mask *a, + const Processor_mask *b, + const Processor_mask *c +) +{ + BIT_XOR2( CPU_MAXIMUM_PROCESSORS, a, b, c ); +} + +RTEMS_INLINE_ROUTINE uint32_t _Processor_mask_Count( const Processor_mask *a ) +{ + return (uint32_t) BIT_COUNT( CPU_MAXIMUM_PROCESSORS, a ); +} + +RTEMS_INLINE_ROUTINE uint32_t _Processor_mask_Find_last_set( const Processor_mask *a ) +{ + return (uint32_t) BIT_FLS( CPU_MAXIMUM_PROCESSORS, a ); +} + +/** + * @brief Returns the subset of 32 processors containing the specified index as + * an unsigned 32-bit integer. + */ +RTEMS_INLINE_ROUTINE uint32_t _Processor_mask_To_uint32_t( + const Processor_mask *mask, + uint32_t index +) +{ + long bits = mask->__bits[ __bitset_words( index ) ]; + + return (uint32_t) (bits >> (32 * (index % _BITSET_BITS) / 32)); +} + +/** + * @brief Creates a processor set from an unsigned 32-bit integer relative to + * the specified index. + */ +RTEMS_INLINE_ROUTINE void _Processor_mask_From_uint32_t( + Processor_mask *mask, + uint32_t bits, + uint32_t index +) +{ + _Processor_mask_Zero( mask ); + mask->__bits[ __bitset_words( index ) ] = ((long) bits) << (32 * (index % _BITSET_BITS) / 32); +} + +/** + * @brief Creates a processor set from the specified index. + */ +RTEMS_INLINE_ROUTINE void _Processor_mask_From_index( + Processor_mask *mask, + uint32_t index +) +{ + BIT_SETOF( CPU_MAXIMUM_PROCESSORS, (int) index, mask ); +} + +typedef enum { + PROCESSOR_MASK_COPY_LOSSLESS, + PROCESSOR_MASK_COPY_PARTIAL_LOSS, + PROCESSOR_MASK_COPY_COMPLETE_LOSS, + PROCESSOR_MASK_COPY_INVALID_SIZE +} Processor_mask_Copy_status; + +RTEMS_INLINE_ROUTINE bool _Processor_mask_Is_at_most_partial_loss( + Processor_mask_Copy_status status +) +{ + return (unsigned int) status <= PROCESSOR_MASK_COPY_PARTIAL_LOSS; +} + +Processor_mask_Copy_status _Processor_mask_Copy( + long *dst, + size_t dst_size, + const long *src, + size_t src_size +); + +RTEMS_INLINE_ROUTINE Processor_mask_Copy_status _Processor_mask_To_cpu_set_t( + const Processor_mask *src, + size_t dst_size, + cpu_set_t *dst +) +{ + return _Processor_mask_Copy( + &dst->__bits[ 0 ], + dst_size, + &src->__bits[ 0 ], + sizeof( *src ) + ); +} + +RTEMS_INLINE_ROUTINE Processor_mask_Copy_status _Processor_mask_From_cpu_set_t( + Processor_mask *dst, + size_t src_size, + const cpu_set_t *src +) +{ + return _Processor_mask_Copy( + &dst->__bits[ 0 ], + sizeof( *dst ), + &src->__bits[ 0 ], + src_size + ); +} + +extern const Processor_mask _Processor_mask_The_one_and_only; + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_SCORE_PROCESSORMASK_H */ diff --git a/cpukit/include/rtems/score/profiling.h b/cpukit/include/rtems/score/profiling.h new file mode 100644 index 0000000000..6ba5d2987f --- /dev/null +++ b/cpukit/include/rtems/score/profiling.h @@ -0,0 +1,140 @@ +/** + * @file + * + * @ingroup ScoreProfiling + * + * @brief Profiling Support API + */ + +/* + * Copyright (c) 2014 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_PROFILING +#define _RTEMS_SCORE_PROFILING + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup ScoreProfiling Profiling Support + * + * @brief Profiling support. + * + * @{ + */ + +static inline void _Profiling_Thread_dispatch_disable( + Per_CPU_Control *cpu, + uint32_t previous_thread_dispatch_disable_level +) +{ +#if defined( RTEMS_PROFILING ) + if ( previous_thread_dispatch_disable_level == 0 ) { + Per_CPU_Stats *stats = &cpu->Stats; + + stats->thread_dispatch_disabled_instant = _CPU_Counter_read(); + ++stats->thread_dispatch_disabled_count; + } +#else + (void) cpu; + (void) previous_thread_dispatch_disable_level; +#endif +} + +static inline void _Profiling_Thread_dispatch_disable_critical( + Per_CPU_Control *cpu, + uint32_t previous_thread_dispatch_disable_level, + const ISR_lock_Context *lock_context +) +{ +#if defined( RTEMS_PROFILING ) + if ( previous_thread_dispatch_disable_level == 0 ) { + Per_CPU_Stats *stats = &cpu->Stats; + + stats->thread_dispatch_disabled_instant = lock_context->ISR_disable_instant; + ++stats->thread_dispatch_disabled_count; + } +#else + (void) cpu; + (void) previous_thread_dispatch_disable_level; + (void) lock_context; +#endif +} + +static inline void _Profiling_Thread_dispatch_enable( + Per_CPU_Control *cpu, + uint32_t new_thread_dispatch_disable_level +) +{ +#if defined( RTEMS_PROFILING ) + if ( new_thread_dispatch_disable_level == 0 ) { + Per_CPU_Stats *stats = &cpu->Stats; + CPU_Counter_ticks now = _CPU_Counter_read(); + CPU_Counter_ticks delta = _CPU_Counter_difference( + now, + stats->thread_dispatch_disabled_instant + ); + + stats->total_thread_dispatch_disabled_time += delta; + + if ( stats->max_thread_dispatch_disabled_time < delta ) { + stats->max_thread_dispatch_disabled_time = delta; + } + } +#else + (void) cpu; + (void) new_thread_dispatch_disable_level; +#endif +} + +static inline void _Profiling_Update_max_interrupt_delay( + Per_CPU_Control *cpu, + CPU_Counter_ticks interrupt_delay +) +{ +#if defined( RTEMS_PROFILING ) + Per_CPU_Stats *stats = &cpu->Stats; + + if ( stats->max_interrupt_delay < interrupt_delay ) { + stats->max_interrupt_delay = interrupt_delay; + } +#else + (void) cpu; + (void) interrupt_delay; +#endif +} + +/** + * @brief Updates the interrupt profiling statistics. + * + * Must be called with the interrupt stack and before the thread dispatch + * disable level is decremented. + */ +void _Profiling_Outer_most_interrupt_entry_and_exit( + Per_CPU_Control *cpu, + CPU_Counter_ticks interrupt_entry_instant, + CPU_Counter_ticks interrupt_exit_instant +); + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_SCORE_PROFILING */ diff --git a/cpukit/include/rtems/score/protectedheap.h b/cpukit/include/rtems/score/protectedheap.h new file mode 100644 index 0000000000..a08fa36cf3 --- /dev/null +++ b/cpukit/include/rtems/score/protectedheap.h @@ -0,0 +1,172 @@ +/** + * @file + * + * @ingroup ScoreProtHeap + * + * @brief Protected Heap Handler API + */ + +/* + * COPYRIGHT (c) 1989-2007. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_PROTECTED_HEAP_H +#define _RTEMS_SCORE_PROTECTED_HEAP_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ScoreProtHeap Protected Heap Handler + * + * @ingroup ScoreHeap + * + * @brief Provides protected heap services. + * + * The @ref ScoreAllocatorMutex is used to protect the heap accesses. + * + */ +/**@{**/ + +/** + * @brief See _Heap_Initialize(). + */ +RTEMS_INLINE_ROUTINE uintptr_t _Protected_heap_Initialize( + Heap_Control *heap, + void *area_begin, + uintptr_t area_size, + uintptr_t page_size +) +{ + return _Heap_Initialize( heap, area_begin, area_size, page_size ); +} + +/** + * @brief See _Heap_Extend(). + * + * Returns @a true in case of success, and @a false otherwise. + */ +bool _Protected_heap_Extend( + Heap_Control *heap, + void *area_begin, + uintptr_t area_size +); + +/** + * @brief See _Heap_Allocate_aligned_with_boundary(). + */ +void *_Protected_heap_Allocate_aligned_with_boundary( + Heap_Control *heap, + uintptr_t size, + uintptr_t alignment, + uintptr_t boundary +); + +/** + * @brief See _Heap_Allocate_aligned_with_boundary() with boundary equals zero. + */ +RTEMS_INLINE_ROUTINE void *_Protected_heap_Allocate_aligned( + Heap_Control *heap, + uintptr_t size, + uintptr_t alignment +) +{ + return + _Protected_heap_Allocate_aligned_with_boundary( heap, size, alignment, 0 ); +} + +/** + * @brief See _Heap_Allocate_aligned_with_boundary() with alignment and + * boundary equals zero. + */ +RTEMS_INLINE_ROUTINE void *_Protected_heap_Allocate( + Heap_Control *heap, + uintptr_t size +) +{ + return _Protected_heap_Allocate_aligned_with_boundary( heap, size, 0, 0 ); +} + +/** + * @brief See _Heap_Size_of_alloc_area(). + */ +bool _Protected_heap_Get_block_size( + Heap_Control *heap, + void *addr, + uintptr_t *size +); + +/** + * @brief See _Heap_Resize_block(). + * + * Returns @a true in case of success, and @a false otherwise. + */ +bool _Protected_heap_Resize_block( + Heap_Control *heap, + void *addr, + uintptr_t size +); + +/** + * @brief See _Heap_Free(). + * + * Returns @a true in case of success, and @a false otherwise. + */ +bool _Protected_heap_Free( Heap_Control *heap, void *addr ); + +/** + * @brief See _Heap_Walk(). + */ +bool _Protected_heap_Walk( Heap_Control *heap, int source, bool dump ); + +/** + * @brief See _Heap_Iterate(). + */ +void _Protected_heap_Iterate( + Heap_Control *heap, + Heap_Block_visitor visitor, + void *visitor_arg +); + +/** + * @brief See _Heap_Get_information(). + * + * Returns @a true in case of success, and @a false otherwise. + */ +bool _Protected_heap_Get_information( + Heap_Control *heap, + Heap_Information_block *info +); + +/** + * @brief See _Heap_Get_free_information(). + * + * Returns @a true in case of success, and @a false otherwise. + */ +bool _Protected_heap_Get_free_information( + Heap_Control *heap, + Heap_Information *info +); + +/** + * @brief See _Heap_Get_size(). + */ +uintptr_t _Protected_heap_Get_size( Heap_Control *heap ); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/rbtree.h b/cpukit/include/rtems/score/rbtree.h new file mode 100644 index 0000000000..15a3bc8913 --- /dev/null +++ b/cpukit/include/rtems/score/rbtree.h @@ -0,0 +1,568 @@ +/** + * @file rtems/score/rbtree.h + * + * @brief Constants and Structures Associated with the Red-Black Tree Handler + * + * This include file contains all the constants and structures associated + * with the Red-Black Tree Handler. + */ + +/* + * Copyright (c) 2010 Gedare Bloom. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_RBTREE_H +#define _RTEMS_SCORE_RBTREE_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ScoreRBTree Red-Black Tree Handler + * + * @ingroup Score + * + * The Red-Black Tree Handler is used to manage sets of entities. This handler + * provides two data structures. The rbtree Node data structure is included + * as the first part of every data structure that will be placed on + * a RBTree. The second data structure is rbtree Control which is used + * to manage a set of rbtree Nodes. + */ +/**@{*/ + +struct RBTree_Control; + +/** + * @brief Red-black tree node. + * + * This is used to manage each node (element) which is placed on a red-black + * tree. + */ +typedef struct RBTree_Node { + RB_ENTRY(RBTree_Node) Node; +} RBTree_Node; + +/** + * @brief Red-black tree control. + * + * This is used to manage a red-black tree. A red-black tree consists of a + * tree of zero or more nodes. + */ +typedef RB_HEAD(RBTree_Control, RBTree_Node) RBTree_Control; + +/** + * @brief Initializer for an empty red-black tree with designator @a name. + */ +#define RBTREE_INITIALIZER_EMPTY( name ) \ + RB_INITIALIZER( name ) + +/** + * @brief Definition for an empty red-black tree with designator @a name. + */ +#define RBTREE_DEFINE_EMPTY( name ) \ + RBTree_Control name = RBTREE_INITIALIZER_EMPTY( name ) + +/** + * @brief Sets a red-black tree node as off-tree. + * + * Do not use this function on nodes which are a part of a tree. + * + * @param[in] the_node The node to set off-tree. + * + * @see _RBTree_Is_node_off_tree(). + */ +RTEMS_INLINE_ROUTINE void _RBTree_Set_off_tree( RBTree_Node *the_node ) +{ + RB_COLOR( the_node, Node ) = -1; +} + +/** + * @brief Returns true, if this red-black tree node is off-tree, and false + * otherwise. + * + * @param[in] the_node The node to test. + * + * @retval true The node is not a part of a tree (off-tree). + * @retval false Otherwise. + * + * @see _RBTree_Set_off_tree(). + */ +RTEMS_INLINE_ROUTINE bool _RBTree_Is_node_off_tree( + const RBTree_Node *the_node +) +{ + return RB_COLOR( the_node, Node ) == -1; +} + +/** + * @brief Rebalances the red-black tree after insertion of the node. + * + * @param[in] the_rbtree The red-black tree control. + * @param[in] the_node The most recently inserted node. + */ +void _RBTree_Insert_color( + RBTree_Control *the_rbtree, + RBTree_Node *the_node +); + +/** + * @brief Initializes a red-black tree node. + * + * In debug configurations, the node is set off tree. In all other + * configurations, this function does nothing. + * + * @param[in] the_node The red-black tree node to initialize. + */ +RTEMS_INLINE_ROUTINE void _RBTree_Initialize_node( RBTree_Node *the_node ) +{ +#if defined(RTEMS_DEBUG) + _RBTree_Set_off_tree( the_node ); +#else + (void) the_node; +#endif +} + +/** + * @brief Adds a child node to a parent node. + * + * @param[in] child The child node. + * @param[in] parent The parent node. + * @param[in] link The child node link of the parent node. + */ +RTEMS_INLINE_ROUTINE void _RBTree_Add_child( + RBTree_Node *child, + RBTree_Node *parent, + RBTree_Node **link +) +{ + _Assert( _RBTree_Is_node_off_tree( child ) ); + RB_SET( child, parent, Node ); + *link = child; +} + +/** + * @brief Inserts the node into the red-black tree using the specified parent + * node and link. + * + * @param[in] the_rbtree The red-black tree control. + * @param[in] the_node The node to insert. + * @param[in] parent The parent node. + * @param[in] link The child node link of the parent node. + * + * @code + * #include + * + * typedef struct { + * int value; + * RBTree_Node Node; + * } Some_Node; + * + * bool _Some_Less( + * const RBTree_Node *a, + * const RBTree_Node *b + * ) + * { + * const Some_Node *aa = RTEMS_CONTAINER_OF( a, Some_Node, Node ); + * const Some_Node *bb = RTEMS_CONTAINER_OF( b, Some_Node, Node ); + * + * return aa->value < bb->value; + * } + * + * void _Some_Insert( + * RBTree_Control *the_rbtree, + * Some_Node *the_node + * ) + * { + * RBTree_Node **link = _RBTree_Root_reference( the_rbtree ); + * RBTree_Node *parent = NULL; + * + * while ( *link != NULL ) { + * parent = *link; + * + * if ( _Some_Less( &the_node->Node, parent ) ) { + * link = _RBTree_Left_reference( parent ); + * } else { + * link = _RBTree_Right_reference( parent ); + * } + * } + * + * _RBTree_Insert_with_parent( the_rbtree, &the_node->Node, parent, link ); + * } + * @endcode + */ +RTEMS_INLINE_ROUTINE void _RBTree_Insert_with_parent( + RBTree_Control *the_rbtree, + RBTree_Node *the_node, + RBTree_Node *parent, + RBTree_Node **link +) +{ + _RBTree_Add_child( the_node, parent, link ); + _RBTree_Insert_color( the_rbtree, the_node ); +} + +/** + * @brief Extracts (removes) the node from the red-black tree. + * + * This function does not set the node off-tree. In case this is desired, then + * call _RBTree_Set_off_tree() after the extraction. + * + * In case the node to extract is not a node of the tree, then this function + * yields unpredictable results. + * + * @param[in] the_rbtree The red-black tree control. + * @param[in] the_node The node to extract. + */ +void _RBTree_Extract( + RBTree_Control *the_rbtree, + RBTree_Node *the_node +); + +/** + * @brief Returns a pointer to root node of the red-black tree. + * + * The root node may change after insert or extract operations. + * + * @param[in] the_rbtree The red-black tree control. + * + * @retval NULL The tree is empty. + * @retval root The root node. + * + * @see _RBTree_Is_root(). + */ +RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Root( + const RBTree_Control *the_rbtree +) +{ + return RB_ROOT( the_rbtree ); +} + +/** + * @brief Returns a reference to the root pointer of the red-black tree. + */ +RTEMS_INLINE_ROUTINE RBTree_Node **_RBTree_Root_reference( + RBTree_Control *the_rbtree +) +{ + return &RB_ROOT( the_rbtree ); +} + +/** + * @brief Returns a constant reference to the root pointer of the red-black tree. + */ +RTEMS_INLINE_ROUTINE RBTree_Node * const *_RBTree_Root_const_reference( + const RBTree_Control *the_rbtree +) +{ + return &RB_ROOT( the_rbtree ); +} + +/** + * @brief Returns a pointer to the parent of this node. + * + * The node must have a parent, thus it is invalid to use this function for the + * root node or a node that is not part of a tree. To test for the root node + * compare with _RBTree_Root() or use _RBTree_Is_root(). + * + * @param[in] the_node The node of interest. + * + * @retval parent The parent of this node. + * @retval undefined The node is the root node or not part of a tree. + */ +RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Parent( + const RBTree_Node *the_node +) +{ + return RB_PARENT( the_node, Node ); +} + +/** + * @brief Return pointer to the left of this node. + * + * This function returns a pointer to the left node of this node. + * + * @param[in] the_node is the node to be operated upon. + * + * @return This method returns the left node on the rbtree. + */ +RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Left( + const RBTree_Node *the_node +) +{ + return RB_LEFT( the_node, Node ); +} + +/** + * @brief Returns a reference to the left child pointer of the red-black tree + * node. + */ +RTEMS_INLINE_ROUTINE RBTree_Node **_RBTree_Left_reference( + RBTree_Node *the_node +) +{ + return &RB_LEFT( the_node, Node ); +} + +/** + * @brief Return pointer to the right of this node. + * + * This function returns a pointer to the right node of this node. + * + * @param[in] the_node is the node to be operated upon. + * + * @return This method returns the right node on the rbtree. + */ +RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Right( + const RBTree_Node *the_node +) +{ + return RB_RIGHT( the_node, Node ); +} + +/** + * @brief Returns a reference to the right child pointer of the red-black tree + * node. + */ +RTEMS_INLINE_ROUTINE RBTree_Node **_RBTree_Right_reference( + RBTree_Node *the_node +) +{ + return &RB_RIGHT( the_node, Node ); +} + +/** + * @brief Is the RBTree empty. + * + * This function returns true if there are no nodes on @a the_rbtree and + * false otherwise. + * + * @param[in] the_rbtree is the rbtree to be operated upon. + * + * @retval true There are no nodes on @a the_rbtree. + * @retval false There are nodes on @a the_rbtree. + */ +RTEMS_INLINE_ROUTINE bool _RBTree_Is_empty( + const RBTree_Control *the_rbtree +) +{ + return RB_EMPTY( the_rbtree ); +} + +/** + * @brief Returns true if this node is the root node of a red-black tree, and + * false otherwise. + * + * The root node may change after insert or extract operations. In case the + * node is not a node of a tree, then this function yields unpredictable + * results. + * + * @param[in] the_node The node of interest. + * + * @retval true The node is the root node. + * @retval false Otherwise. + * + * @see _RBTree_Root(). + */ +RTEMS_INLINE_ROUTINE bool _RBTree_Is_root( + const RBTree_Node *the_node +) +{ + return _RBTree_Parent( the_node ) == NULL; +} + +/** + * @brief Initialize this RBTree as empty. + * + * This routine initializes @a the_rbtree to contain zero nodes. + */ +RTEMS_INLINE_ROUTINE void _RBTree_Initialize_empty( + RBTree_Control *the_rbtree +) +{ + RB_INIT( the_rbtree ); +} + +/** + * @brief Initializes this red-black tree to contain exactly the specified + * node. + * + * @param[in] the_rbtree The red-black tree control. + * @param[in] the_node The one and only node. + */ +RTEMS_INLINE_ROUTINE void _RBTree_Initialize_one( + RBTree_Control *the_rbtree, + RBTree_Node *the_node +) +{ + _Assert( _RBTree_Is_node_off_tree( the_node ) ); + RB_ROOT( the_rbtree ) = the_node; + RB_PARENT( the_node, Node ) = NULL; + RB_LEFT( the_node, Node ) = NULL; + RB_RIGHT( the_node, Node ) = NULL; + RB_COLOR( the_node, Node ) = RB_BLACK; +} + +/** + * @brief Returns the minimum node of the red-black tree. + * + * @param[in] the_rbtree The red-black tree control. + * + * @retval NULL The red-black tree is empty. + * @retval node The minimum node. + */ +RBTree_Node *_RBTree_Minimum( const RBTree_Control *the_rbtree ); + +/** + * @brief Returns the maximum node of the red-black tree. + * + * @param[in] the_rbtree The red-black tree control. + * + * @retval NULL The red-black tree is empty. + * @retval node The maximum node. + */ +RBTree_Node *_RBTree_Maximum( const RBTree_Control *the_rbtree ); + +/** + * @brief Returns the predecessor of a node. + * + * @param[in] node is the node. + * + * @retval NULL The predecessor does not exist. Otherwise it returns + * the predecessor node. + */ +RBTree_Node *_RBTree_Predecessor( const RBTree_Node *node ); + +/** + * @brief Returns the successor of a node. + * + * @param[in] node is the node. + * + * @retval NULL The successor does not exist. Otherwise the successor node. + */ +RBTree_Node *_RBTree_Successor( const RBTree_Node *node ); + +/** + * @brief Replaces a node in the red-black tree without a rebalance. + * + * @param[in] the_rbtree The red-black tree control. + * @param[in] victim The victim node. + * @param[in] replacement The replacement node. + */ +void _RBTree_Replace_node( + RBTree_Control *the_rbtree, + RBTree_Node *victim, + RBTree_Node *replacement +); + +/** + * @brief Inserts the node into the red-black tree. + * + * @param the_rbtree The red-black tree control. + * @param the_node The node to insert. + * @param key The key of the node to insert. This key must be equal to the key + * stored in the node to insert. The separate key parameter is provided for + * two reasons. Firstly, it allows to share the less operator with + * _RBTree_Find_inline(). Secondly, the compiler may generate better code if + * the key is stored in a local variable. + * @param less Must return true if the specified key is less than the key of + * the node, otherwise false. + * + * @retval true The inserted node is the new minimum node according to the + * specified less order function. + * @retval false Otherwise. + */ +RTEMS_INLINE_ROUTINE bool _RBTree_Insert_inline( + RBTree_Control *the_rbtree, + RBTree_Node *the_node, + const void *key, + bool ( *less )( const void *, const RBTree_Node * ) +) +{ + RBTree_Node **link; + RBTree_Node *parent; + bool is_new_minimum; + + link = _RBTree_Root_reference( the_rbtree ); + parent = NULL; + is_new_minimum = true; + + while ( *link != NULL ) { + parent = *link; + + if ( ( *less )( key, parent ) ) { + link = _RBTree_Left_reference( parent ); + } else { + link = _RBTree_Right_reference( parent ); + is_new_minimum = false; + } + } + + _RBTree_Add_child( the_node, parent, link ); + _RBTree_Insert_color( the_rbtree, the_node ); + return is_new_minimum; +} + +/** + * @brief Finds an object in the red-black tree with the specified key. + * + * @param the_rbtree The red-black tree control. + * @param key The key to look after. + * @param equal Must return true if the specified key equals the key of the + * node, otherwise false. + * @param less Must return true if the specified key is less than the key of + * the node, otherwise false. + * @param map In case a node with the specified key is found, then this + * function is called to map the node to the object returned. Usually it + * performs some offset operation via RTEMS_CONTAINER_OF() to map the node to + * its containing object. Thus, the return type is a void pointer and not a + * red-black tree node. + * + * @retval object An object with the specified key. + * @retval NULL No object with the specified key exists in the red-black tree. + */ +RTEMS_INLINE_ROUTINE void *_RBTree_Find_inline( + const RBTree_Control *the_rbtree, + const void *key, + bool ( *equal )( const void *, const RBTree_Node * ), + bool ( *less )( const void *, const RBTree_Node * ), + void *( *map )( RBTree_Node * ) +) +{ + RBTree_Node * const *link; + RBTree_Node *parent; + + link = _RBTree_Root_const_reference( the_rbtree ); + parent = NULL; + + while ( *link != NULL ) { + parent = *link; + + if ( ( *equal )( key, parent ) ) { + return ( *map )( parent ); + } else if ( ( *less )( key, parent ) ) { + link = _RBTree_Left_reference( parent ); + } else { + link = _RBTree_Right_reference( parent ); + } + } + + return NULL; +} + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/rbtreeimpl.h b/cpukit/include/rtems/score/rbtreeimpl.h new file mode 100644 index 0000000000..bf92e29228 --- /dev/null +++ b/cpukit/include/rtems/score/rbtreeimpl.h @@ -0,0 +1,72 @@ +/** + * @file + * + * @brief Inlined Routines Associated with Red-Black Trees + * + * This include file contains the bodies of the routines which are + * associated with Red-Black Trees and inlined. + * + * @note The routines in this file are ordered from simple + * to complex. No other RBTree Handler routine is referenced + * unless it has already been defined. + */ + +/* + * Copyright (c) 2010-2012 Gedare Bloom. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_RBTREEIMPL_H +#define _RTEMS_SCORE_RBTREEIMPL_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup ScoreRBTree + */ +/**@{**/ + +/** + * @brief Red-black tree visitor. + * + * @param[in] node The node. + * @param[in] visitor_arg The visitor argument. + * + * @retval true Stop the iteration. + * @retval false Continue the iteration. + * + * @see _RBTree_Iterate(). + */ +typedef bool (*RBTree_Visitor)( + const RBTree_Node *node, + void *visitor_arg +); + +/** + * @brief Red-black tree iteration. + * + * @param[in] rbtree The red-black tree. + * @param[in] visitor The visitor. + * @param[in] visitor_arg The visitor argument. + */ +void _RBTree_Iterate( + const RBTree_Control *rbtree, + RBTree_Visitor visitor, + void *visitor_arg +); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/scheduler.h b/cpukit/include/rtems/score/scheduler.h new file mode 100644 index 0000000000..a6066c8e4a --- /dev/null +++ b/cpukit/include/rtems/score/scheduler.h @@ -0,0 +1,556 @@ +/** + * @file rtems/score/scheduler.h + * + * @brief Constants and Structures Associated with the Scheduler + * + * This include file contains all the constants and structures associated + * with the scheduler. + */ + +/* + * Copyright (C) 2010 Gedare Bloom. + * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SCHEDULER_H +#define _RTEMS_SCORE_SCHEDULER_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct Per_CPU_Control; + +/** + * @defgroup ScoreScheduler Scheduler Handler + * + * @ingroup Score + * + * This handler encapsulates functionality related to managing sets of threads + * that are ready for execution. + */ +/**@{*/ + +typedef struct _Scheduler_Control Scheduler_Control; + +/** + * @brief The scheduler operations. + */ +typedef struct { + /** @see _Scheduler_Handler_initialization() */ + void ( *initialize )( const Scheduler_Control * ); + + /** @see _Scheduler_Schedule() */ + void ( *schedule )( const Scheduler_Control *, Thread_Control *); + + /** @see _Scheduler_Yield() */ + void ( *yield )( + const Scheduler_Control *, + Thread_Control *, + Scheduler_Node * + ); + + /** @see _Scheduler_Block() */ + void ( *block )( + const Scheduler_Control *, + Thread_Control *, + Scheduler_Node * + ); + + /** @see _Scheduler_Unblock() */ + void ( *unblock )( + const Scheduler_Control *, + Thread_Control *, + Scheduler_Node * + ); + + /** @see _Scheduler_Update_priority() */ + void ( *update_priority )( + const Scheduler_Control *, + Thread_Control *, + Scheduler_Node * + ); + + /** @see _Scheduler_Map_priority() */ + Priority_Control ( *map_priority )( + const Scheduler_Control *, + Priority_Control + ); + + /** @see _Scheduler_Unmap_priority() */ + Priority_Control ( *unmap_priority )( + const Scheduler_Control *, + Priority_Control + ); + +#if defined(RTEMS_SMP) + /** + * @brief Ask for help operation. + * + * @param[in] scheduler The scheduler instance to ask for help. + * @param[in] the_thread The thread needing help. + * @param[in] node The scheduler node. + * + * @retval true Ask for help was successful. + * @retval false Otherwise. + */ + bool ( *ask_for_help )( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node + ); + + /** + * @brief Reconsider help operation. + * + * @param[in] scheduler The scheduler instance to reconsider the help + * request. + * @param[in] the_thread The thread reconsidering a help request. + * @param[in] node The scheduler node. + */ + void ( *reconsider_help_request )( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node + ); + + /** + * @brief Withdraw node operation. + * + * @param[in] scheduler The scheduler instance to withdraw the node. + * @param[in] the_thread The thread using the node. + * @param[in] node The scheduler node to withdraw. + * @param[in] next_state The next thread scheduler state in case the node is + * scheduled. + */ + void ( *withdraw_node )( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node, + Thread_Scheduler_state next_state + ); + + /** + * @brief Add processor operation. + * + * @param[in] scheduler The scheduler instance to add the processor. + * @param[in] idle The idle thread of the processor to add. + */ + void ( *add_processor )( + const Scheduler_Control *scheduler, + Thread_Control *idle + ); + + /** + * @brief Remove processor operation. + * + * @param[in] scheduler The scheduler instance to remove the processor. + * @param[in] cpu The processor to remove. + * + * @return The idle thread of the removed processor. + */ + Thread_Control *( *remove_processor )( + const Scheduler_Control *scheduler, + struct Per_CPU_Control *cpu + ); +#endif + + /** @see _Scheduler_Node_initialize() */ + void ( *node_initialize )( + const Scheduler_Control *, + Scheduler_Node *, + Thread_Control *, + Priority_Control + ); + + /** @see _Scheduler_Node_destroy() */ + void ( *node_destroy )( const Scheduler_Control *, Scheduler_Node * ); + + /** @see _Scheduler_Release_job() */ + void ( *release_job ) ( + const Scheduler_Control *, + Thread_Control *, + Priority_Node *, + uint64_t, + Thread_queue_Context * + ); + + /** @see _Scheduler_Cancel_job() */ + void ( *cancel_job ) ( + const Scheduler_Control *, + Thread_Control *, + Priority_Node *, + Thread_queue_Context * + ); + + /** @see _Scheduler_Tick() */ + void ( *tick )( const Scheduler_Control *, Thread_Control * ); + + /** @see _Scheduler_Start_idle() */ + void ( *start_idle )( + const Scheduler_Control *, + Thread_Control *, + struct Per_CPU_Control * + ); + +#if defined(RTEMS_SMP) + /** @see _Scheduler_Set_affinity() */ + bool ( *set_affinity )( + const Scheduler_Control *, + Thread_Control *, + Scheduler_Node *, + const Processor_mask * + ); +#endif +} Scheduler_Operations; + +/** + * @brief Scheduler context. + * + * The scheduler context of a particular scheduler implementation must place + * this structure at the begin of its context structure. + */ +typedef struct Scheduler_Context { + /** + * @brief Lock to protect this scheduler instance. + */ + ISR_LOCK_MEMBER( Lock ) + +#if defined(RTEMS_SMP) + /** + * @brief The set of processors owned by this scheduler instance. + */ + Processor_mask Processors; +#endif +} Scheduler_Context; + +/** + * @brief Scheduler control. + */ +struct _Scheduler_Control { + /** + * @brief Reference to a statically allocated scheduler context. + */ + Scheduler_Context *context; + + /** + * @brief The scheduler operations. + */ + Scheduler_Operations Operations; + + /** + * @brief The maximum priority value of this scheduler. + * + * It defines the lowest (least important) thread priority for this + * scheduler. For example the idle threads have this priority. + */ + Priority_Control maximum_priority; + + /** + * @brief The scheduler name. + */ + uint32_t name; +}; + +/** + * @brief Registered schedulers. + * + * Application provided via . + * + * @see _Scheduler_Count. + */ +extern const Scheduler_Control _Scheduler_Table[]; + +/** + * @brief Count of registered schedulers. + * + * Application provided via on SMP configurations. + * + * It is very important that this is a compile-time constant on uni-processor + * configurations (in this case RTEMS_SMP is not defined) so that the compiler + * can optimize the some loops away + * + * @see _Scheduler_Table. + */ +#if defined(RTEMS_SMP) + extern const size_t _Scheduler_Count; +#else + #define _Scheduler_Count ( (size_t) 1 ) +#endif + +#if defined(RTEMS_SMP) + /** + * @brief The scheduler assignment default attributes. + */ + #define SCHEDULER_ASSIGN_DEFAULT UINT32_C(0x0) + + /** + * @brief The presence of this processor is optional. + */ + #define SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL SCHEDULER_ASSIGN_DEFAULT + + /** + * @brief The presence of this processor is mandatory. + */ + #define SCHEDULER_ASSIGN_PROCESSOR_MANDATORY UINT32_C(0x1) + + /** + * @brief Scheduler assignment. + */ + typedef struct { + /** + * @brief The scheduler for this processor. + */ + const Scheduler_Control *scheduler; + + /** + * @brief The scheduler assignment attributes. + * + * Use @ref SCHEDULER_ASSIGN_DEFAULT to select default attributes. + * + * The presence of a processor can be + * - @ref SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL, or + * - @ref SCHEDULER_ASSIGN_PROCESSOR_MANDATORY. + */ + uint32_t attributes; + } Scheduler_Assignment; + + /** + * @brief The scheduler assignments. + * + * The length of this array must be equal to the maximum processors. + * + * Application provided via . + * + * @see _Scheduler_Table and rtems_configuration_get_maximum_processors(). + */ + extern const Scheduler_Assignment _Scheduler_Initial_assignments[]; +#endif + +/** + * @brief Returns the scheduler internal thread priority mapped by + * SCHEDULER_PRIORITY_MAP(). + * + * @param[in] scheduler Unused. + * @param[in] priority The user visible thread priority. + * + * @return priority The scheduler internal thread priority. + */ +Priority_Control _Scheduler_default_Map_priority( + const Scheduler_Control *scheduler, + Priority_Control priority +); + +/** + * @brief Returns the user visible thread priority unmapped by + * SCHEDULER_PRIORITY_UNMAP(). + * + * @param[in] scheduler Unused. + * @param[in] priority The scheduler internal thread priority. + * + * @return priority The user visible thread priority. + */ +Priority_Control _Scheduler_default_Unmap_priority( + const Scheduler_Control *scheduler, + Priority_Control priority +); + +#if defined(RTEMS_SMP) + /** + * @brief Does nothing. + * + * @param[in] scheduler Unused. + * @param[in] the_thread Unused. + * @param[in] node Unused. + * + * @retval false Always. + */ + bool _Scheduler_default_Ask_for_help( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node + ); + + /** + * @brief Does nothing. + * + * @param[in] scheduler Unused. + * @param[in] the_thread Unused. + * @param[in] node Unused. + */ + void _Scheduler_default_Reconsider_help_request( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node + ); + + /** + * @brief Does nothing. + * + * @param[in] scheduler Unused. + * @param[in] the_thread Unused. + * @param[in] node Unused. + * @param[in] next_state Unused. + */ + void _Scheduler_default_Withdraw_node( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node, + Thread_Scheduler_state next_state + ); + + #define SCHEDULER_OPERATION_DEFAULT_ASK_FOR_HELP \ + _Scheduler_default_Ask_for_help, \ + _Scheduler_default_Reconsider_help_request, \ + _Scheduler_default_Withdraw_node, \ + NULL, \ + NULL, +#else + #define SCHEDULER_OPERATION_DEFAULT_ASK_FOR_HELP +#endif + +/** + * @brief Does nothing. + * + * @param[in] scheduler Unused. + * @param[in] the_thread Unused. + */ +void _Scheduler_default_Schedule( + const Scheduler_Control *scheduler, + Thread_Control *the_thread +); + +/** + * @brief Performs the scheduler base node initialization. + * + * @param[in] scheduler Unused. + * @param[in] node The node to initialize. + * @param[in] the_thread Unused. + * @param[in] priority The thread priority. + */ +void _Scheduler_default_Node_initialize( + const Scheduler_Control *scheduler, + Scheduler_Node *node, + Thread_Control *the_thread, + Priority_Control priority +); + +/** + * @brief Does nothing. + * + * @param[in] scheduler Unused. + * @param[in] node Unused. + */ +void _Scheduler_default_Node_destroy( + const Scheduler_Control *scheduler, + Scheduler_Node *node +); + +/** + * @brief Does nothing. + * + * @param[in] scheduler Unused. + * @param[in] the_thread Unused. + * @param[in] priority_node Unused. + * @param[in] deadline Unused. + * @param[in] queue_context Unused. + * + * @retval NULL Always. + */ +void _Scheduler_default_Release_job( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Priority_Node *priority_node, + uint64_t deadline, + Thread_queue_Context *queue_context +); + +/** + * @brief Does nothing. + * + * @param[in] scheduler Unused. + * @param[in] the_thread Unused. + * @param[in] priority_node Unused. + * @param[in] queue_context Unused. + * + * @retval NULL Always. + */ +void _Scheduler_default_Cancel_job( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Priority_Node *priority_node, + Thread_queue_Context *queue_context +); + +/** + * @brief Performs tick operations depending on the CPU budget algorithm for + * each executing thread. + * + * This routine is invoked as part of processing each clock tick. + * + * @param[in] scheduler The scheduler. + * @param[in] executing An executing thread. + */ +void _Scheduler_default_Tick( + const Scheduler_Control *scheduler, + Thread_Control *executing +); + +/** + * @brief Starts an idle thread. + * + * @param[in] scheduler The scheduler. + * @param[in] the_thread An idle thread. + * @param[in] cpu This parameter is unused. + */ +void _Scheduler_default_Start_idle( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + struct Per_CPU_Control *cpu +); + +#if defined(RTEMS_SMP) + /** + * @brief Default implementation of the set affinity scheduler operation. + * + * @param[in] scheduler The scheduler instance. + * @param[in] thread The associated thread. + * @param[in] node The home scheduler node of the associated thread. + * @param[in] affinity The new processor affinity set for the thread. + * + * @retval true The processor set of the scheduler is a subset of the affinity set. + * @retval false Otherwise. + */ + bool _Scheduler_default_Set_affinity( + const Scheduler_Control *scheduler, + Thread_Control *thread, + Scheduler_Node *node, + const Processor_mask *affinity + ); + + #define SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY \ + , _Scheduler_default_Set_affinity +#else + #define SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY +#endif + +/** + * @brief This defines the lowest (least important) thread priority of the + * first scheduler instance. + */ +#define PRIORITY_MAXIMUM ( _Scheduler_Table[ 0 ].maximum_priority ) + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/schedulercbs.h b/cpukit/include/rtems/score/schedulercbs.h new file mode 100644 index 0000000000..635abce125 --- /dev/null +++ b/cpukit/include/rtems/score/schedulercbs.h @@ -0,0 +1,346 @@ +/** + * @file rtems/score/schedulercbs.h + * + * @brief Thread manipulation for the CBS scheduler + * + * This include file contains all the constants and structures associated + * with the manipulation of threads for the CBS scheduler. + */ + +/* + * Copryight (c) 2011 Petr Benes. + * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SCHEDULERCBS_H +#define _RTEMS_SCORE_SCHEDULERCBS_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ScoreSchedulerCBS CBS Scheduler + * + * @ingroup ScoreScheduler + */ +/**@{*/ + +#define SCHEDULER_CBS_MAXIMUM_PRIORITY SCHEDULER_EDF_MAXIMUM_PRIORITY + +/** + * Entry points for the Constant Bandwidth Server Scheduler. + * + * @note: The CBS scheduler is an enhancement of EDF scheduler, + * therefor some routines are similar. + */ +#define SCHEDULER_CBS_ENTRY_POINTS \ + { \ + _Scheduler_EDF_Initialize, /* initialize entry point */ \ + _Scheduler_EDF_Schedule, /* schedule entry point */ \ + _Scheduler_EDF_Yield, /* yield entry point */ \ + _Scheduler_EDF_Block, /* block entry point */ \ + _Scheduler_CBS_Unblock, /* unblock entry point */ \ + _Scheduler_EDF_Update_priority, /* update priority entry point */ \ + _Scheduler_EDF_Map_priority, /* map priority entry point */ \ + _Scheduler_EDF_Unmap_priority, /* unmap priority entry point */ \ + SCHEDULER_OPERATION_DEFAULT_ASK_FOR_HELP \ + _Scheduler_CBS_Node_initialize, /* node initialize entry point */ \ + _Scheduler_default_Node_destroy, /* node destroy entry point */ \ + _Scheduler_CBS_Release_job, /* new period of task */ \ + _Scheduler_CBS_Cancel_job, /* cancel period of task */ \ + _Scheduler_default_Tick, /* tick entry point */ \ + _Scheduler_default_Start_idle /* start idle entry point */ \ + SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY \ + } + +/* Return values for CBS server. */ +#define SCHEDULER_CBS_OK 0 +#define SCHEDULER_CBS_ERROR_GENERIC -16 +#define SCHEDULER_CBS_ERROR_NO_MEMORY -17 +#define SCHEDULER_CBS_ERROR_INVALID_PARAMETER -18 +#define SCHEDULER_CBS_ERROR_UNAUTHORIZED -19 +#define SCHEDULER_CBS_ERROR_UNIMPLEMENTED -20 +#define SCHEDULER_CBS_ERROR_MISSING_COMPONENT -21 +#define SCHEDULER_CBS_ERROR_INCONSISTENT_STATE -22 +#define SCHEDULER_CBS_ERROR_SYSTEM_OVERLOAD -23 +#define SCHEDULER_CBS_ERROR_INTERNAL_ERROR -24 +#define SCHEDULER_CBS_ERROR_NOT_FOUND -25 +#define SCHEDULER_CBS_ERROR_FULL -26 +#define SCHEDULER_CBS_ERROR_EMPTY -27 +#define SCHEDULER_CBS_ERROR_NOSERVER SCHEDULER_CBS_ERROR_NOT_FOUND + +/** Maximum number of simultaneous servers. */ +extern const uint32_t _Scheduler_CBS_Maximum_servers; + +/** Server id. */ +typedef uint32_t Scheduler_CBS_Server_id; + +/** Callback function invoked when a budget overrun of a task occurs. */ +typedef void (*Scheduler_CBS_Budget_overrun)( + Scheduler_CBS_Server_id server_id +); + +/** + * This structure handles server parameters. + */ +typedef struct { + /** Relative deadline of the server. */ + time_t deadline; + /** Budget (computation time) of the server. */ + time_t budget; +} Scheduler_CBS_Parameters; + +/** + * This structure represents a time server. + */ +typedef struct { + /** + * Task id. + * + * @note: The current implementation of CBS handles only one task per server. + */ + rtems_id task_id; + /** Server paramenters. */ + Scheduler_CBS_Parameters parameters; + /** Callback function invoked when a budget overrun occurs. */ + Scheduler_CBS_Budget_overrun cbs_budget_overrun; + + /** + * @brief Indicates if this CBS server is initialized. + * + * @see _Scheduler_CBS_Create_server() and _Scheduler_CBS_Destroy_server(). + */ + bool initialized; +} Scheduler_CBS_Server; + +/** + * This structure handles CBS specific data of a thread. + */ +typedef struct { + /** EDF scheduler specific data of a task. */ + Scheduler_EDF_Node Base; + /** CBS server specific data of a task. */ + Scheduler_CBS_Server *cbs_server; + + Priority_Node *deadline_node; +} Scheduler_CBS_Node; + + +/** + * List of servers. The @a Scheduler_CBS_Server is the index to the array + * of pointers to @a _Scheduler_CBS_Server_list. + */ +extern Scheduler_CBS_Server _Scheduler_CBS_Server_list[]; + +void _Scheduler_CBS_Unblock( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +void _Scheduler_CBS_Release_job( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Priority_Node *priority_node, + uint64_t deadline, + Thread_queue_Context *queue_context +); + +void _Scheduler_CBS_Cancel_job( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Priority_Node *priority_node, + Thread_queue_Context *queue_context +); + +/** + * @brief _Scheduler_CBS_Initialize + * + * Initializes the CBS library. + * + * @retval status code. + */ +int _Scheduler_CBS_Initialize(void); + +/** + * @brief Attach a task to an already existing server. + * + * Attach a task to an already existing server. + * + * @retval status code. + */ +int _Scheduler_CBS_Attach_thread ( + Scheduler_CBS_Server_id server_id, + rtems_id task_id +); + +/** + * @brief Detach from the CBS Server. + * + * Detach from the CBS Server. + * + * @retval status code. + */ +int _Scheduler_CBS_Detach_thread ( + Scheduler_CBS_Server_id server_id, + rtems_id task_id +); + +/** + * @brief Cleanup resources associated to the CBS Library. + * + * Cleanup resources associated to the CBS Library. + * + * @retval status code. + */ +int _Scheduler_CBS_Cleanup (void); + +/** + * @brief Create a new server with specified parameters. + * + * Create a new server with specified parameters. + * + * @retval status code. + */ +int _Scheduler_CBS_Create_server ( + Scheduler_CBS_Parameters *params, + Scheduler_CBS_Budget_overrun budget_overrun_callback, + rtems_id *server_id +); + +/** + * @brief Detach all tasks from a server and destroy it. + * + * Detach all tasks from a server and destroy it. + * + * @param[in] server_id is the ID of the server + * + * @retval status code. + */ +int _Scheduler_CBS_Destroy_server ( + Scheduler_CBS_Server_id server_id +); + +/** + * @brief Retrieve the approved budget. + * + * Retrieve the budget that has been approved for the subsequent + * server instances. + * + * @retval status code. + */ +int _Scheduler_CBS_Get_approved_budget ( + Scheduler_CBS_Server_id server_id, + time_t *approved_budget +); + +/** + * @brief Retrieve remaining budget for the current server instance. + * + * Retrieve remaining budget for the current server instance. + * + * @retval status code. + */ +int _Scheduler_CBS_Get_remaining_budget ( + Scheduler_CBS_Server_id server_id, + time_t *remaining_budget +); + +/** + * @brief Get relative time info. + * + * Retrieve time info relative to @a server_id. The server status code is returned. + * + * @param[in] server_id is the server to get the status code from. + * @param[in] exec_time is the execution time. + * @param[in] abs_time is not apparently used. + * + * @retval status code. + */ +int _Scheduler_CBS_Get_execution_time ( + Scheduler_CBS_Server_id server_id, + time_t *exec_time, + time_t *abs_time +); + +/** + * @brief Retrieve CBS scheduling parameters. + * + * Retrieve CBS scheduling parameters. + * + * @retval status code. + */ +int _Scheduler_CBS_Get_parameters ( + Scheduler_CBS_Server_id server_id, + Scheduler_CBS_Parameters *params +); + +/** + * @brief Get a thread server id. + * + * Get a thread server id, or SCHEDULER_CBS_ERROR_NOT_FOUND if it is not + * attached to any server. + * + * @retval status code. + */ +int _Scheduler_CBS_Get_server_id ( + rtems_id task_id, + Scheduler_CBS_Server_id *server_id +); + +/** + * @brief Set parameters for CBS scheduling. + * + * Change CBS scheduling parameters. + * + * @param[in] server_id is the ID of the server. + * @param[in] parameters are the parameters to set. + * + * @retval status code. + */ +int _Scheduler_CBS_Set_parameters ( + Scheduler_CBS_Server_id server_id, + Scheduler_CBS_Parameters *parameters +); + +/** + * @brief Invoked when a limited time quantum is exceeded. + * + * This routine is invoked when a limited time quantum is exceeded. + */ +void _Scheduler_CBS_Budget_callout( + Thread_Control *the_thread +); + +/** + * @brief Initializes a CBS specific scheduler node of @a the_thread. + */ +void _Scheduler_CBS_Node_initialize( + const Scheduler_Control *scheduler, + Scheduler_Node *node, + Thread_Control *the_thread, + Priority_Control priority +); + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/schedulercbsimpl.h b/cpukit/include/rtems/score/schedulercbsimpl.h new file mode 100644 index 0000000000..ed75979f75 --- /dev/null +++ b/cpukit/include/rtems/score/schedulercbsimpl.h @@ -0,0 +1,59 @@ +/** + * @file + * + * @brief CBS Scheduler Implementation + * + * @ingroup ScoreSchedulerCBS + */ + +/* + * Copyright (c) 2014 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SCHEDULERCBSIMPL_H +#define _RTEMS_SCORE_SCHEDULERCBSIMPL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @addtogroup ScoreSchedulerCBS + * + * @{ + */ + +RTEMS_INLINE_ROUTINE Scheduler_CBS_Node *_Scheduler_CBS_Thread_get_node( + Thread_Control *the_thread +) +{ + return (Scheduler_CBS_Node *) _Thread_Scheduler_get_home_node( the_thread ); +} + +RTEMS_INLINE_ROUTINE Scheduler_CBS_Node *_Scheduler_CBS_Node_downcast( + Scheduler_Node *node +) +{ + return (Scheduler_CBS_Node *) node; +} + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_SCORE_SCHEDULERCBSIMPL_H */ diff --git a/cpukit/include/rtems/score/scheduleredf.h b/cpukit/include/rtems/score/scheduleredf.h new file mode 100644 index 0000000000..91c303ca56 --- /dev/null +++ b/cpukit/include/rtems/score/scheduleredf.h @@ -0,0 +1,197 @@ +/** + * @file rtems/score/scheduleredf.h + * + * @brief Data Related to the Manipulation of Threads for the EDF Scheduler + * + * This include file contains all the constants and structures associated + * with the manipulation of threads for the EDF scheduler. + */ + +/* + * Copryight (c) 2011 Petr Benes. + * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SCHEDULEREDF_H +#define _RTEMS_SCORE_SCHEDULEREDF_H + +#include +#include +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ScoreSchedulerEDF EDF Scheduler + * + * @ingroup ScoreScheduler + */ +/**@{*/ + +/* + * Actually the EDF scheduler supports a maximum priority of + * 0x7fffffffffffffff, but the user API is limited to uint32_t or int for + * thread priorities. Ignore ILP64 targets for now. + */ +#define SCHEDULER_EDF_MAXIMUM_PRIORITY INT_MAX + +/** + * Entry points for the Earliest Deadline First Scheduler. + */ +#define SCHEDULER_EDF_ENTRY_POINTS \ + { \ + _Scheduler_EDF_Initialize, /* initialize entry point */ \ + _Scheduler_EDF_Schedule, /* schedule entry point */ \ + _Scheduler_EDF_Yield, /* yield entry point */ \ + _Scheduler_EDF_Block, /* block entry point */ \ + _Scheduler_EDF_Unblock, /* unblock entry point */ \ + _Scheduler_EDF_Update_priority, /* update priority entry point */ \ + _Scheduler_EDF_Map_priority, /* map priority entry point */ \ + _Scheduler_EDF_Unmap_priority, /* unmap priority entry point */ \ + SCHEDULER_OPERATION_DEFAULT_ASK_FOR_HELP \ + _Scheduler_EDF_Node_initialize, /* node initialize entry point */ \ + _Scheduler_default_Node_destroy, /* node destroy entry point */ \ + _Scheduler_EDF_Release_job, /* new period of task */ \ + _Scheduler_EDF_Cancel_job, /* cancel period of task */ \ + _Scheduler_default_Tick, /* tick entry point */ \ + _Scheduler_default_Start_idle /* start idle entry point */ \ + SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY \ + } + +typedef struct { + /** + * @brief Basic scheduler context. + */ + Scheduler_Context Base; + + /** + * Top of the ready queue. + */ + RBTree_Control Ready; +} Scheduler_EDF_Context; + +/** + * @brief Scheduler node specialization for EDF schedulers. + */ +typedef struct { + /** + * @brief Basic scheduler node. + */ + Scheduler_Node Base; + + /** + * Rbtree node related to this thread. + */ + RBTree_Node Node; + + /** + * @brief The thread priority currently used for this scheduler instance. + */ + Priority_Control priority; +} Scheduler_EDF_Node; + +/** + * @brief Initialize EDF scheduler. + * + * This routine initializes the EDF scheduler. + * + * @param[in] scheduler The scheduler instance. + */ +void _Scheduler_EDF_Initialize( const Scheduler_Control *scheduler ); + +void _Scheduler_EDF_Block( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +/** + * @brief Sets the heir thread to be the next ready thread + * in the rbtree ready queue. + * + * This kernel routine sets the heir thread to be the next ready thread + * in the rbtree ready queue. + * + * @param[in] scheduler The scheduler instance. + * @param[in] the_thread being scheduled. + */ +void _Scheduler_EDF_Schedule( + const Scheduler_Control *scheduler, + Thread_Control *the_thread +); + +/** + * @brief Initializes an EDF specific scheduler node of @a the_thread. + * + * @param[in] scheduler The scheduler instance. + * @param[in] node being initialized. + * @param[in] the_thread the thread of the node. + * @param[in] priority The thread priority. + */ +void _Scheduler_EDF_Node_initialize( + const Scheduler_Control *scheduler, + Scheduler_Node *node, + Thread_Control *the_thread, + Priority_Control priority +); + +void _Scheduler_EDF_Unblock( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +void _Scheduler_EDF_Update_priority( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +Priority_Control _Scheduler_EDF_Map_priority( + const Scheduler_Control *scheduler, + Priority_Control priority +); + +Priority_Control _Scheduler_EDF_Unmap_priority( + const Scheduler_Control *scheduler, + Priority_Control priority +); + +void _Scheduler_EDF_Yield( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +void _Scheduler_EDF_Release_job( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Priority_Node *priority_node, + uint64_t deadline, + Thread_queue_Context *queue_context +); + +void _Scheduler_EDF_Cancel_job( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Priority_Node *priority_node, + Thread_queue_Context *queue_context +); + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/scheduleredfimpl.h b/cpukit/include/rtems/score/scheduleredfimpl.h new file mode 100644 index 0000000000..f6bd7d8384 --- /dev/null +++ b/cpukit/include/rtems/score/scheduleredfimpl.h @@ -0,0 +1,164 @@ +/** + * @file + * + * @ingroup ScoreSchedulerEDF + * + * @brief EDF Scheduler Implementation + */ + +/* + * Copryight (c) 2011 Petr Benes. + * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SCHEDULEREDFIMPL_H +#define _RTEMS_SCORE_SCHEDULEREDFIMPL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup ScoreSchedulerEDF + * + * @{ + */ + +/** + * This is just a most significant bit of Priority_Control type. It + * distinguishes threads which are deadline driven (priority + * represented by a lower number than @a SCHEDULER_EDF_PRIO_MSB) from those + * ones who do not have any deadlines and thus are considered background + * tasks. + */ +#define SCHEDULER_EDF_PRIO_MSB 0x8000000000000000 + +RTEMS_INLINE_ROUTINE Scheduler_EDF_Context * + _Scheduler_EDF_Get_context( const Scheduler_Control *scheduler ) +{ + return (Scheduler_EDF_Context *) _Scheduler_Get_context( scheduler ); +} + +RTEMS_INLINE_ROUTINE Scheduler_EDF_Node *_Scheduler_EDF_Thread_get_node( + Thread_Control *the_thread +) +{ + return (Scheduler_EDF_Node *) _Thread_Scheduler_get_home_node( the_thread ); +} + +RTEMS_INLINE_ROUTINE Scheduler_EDF_Node * _Scheduler_EDF_Node_downcast( + Scheduler_Node *node +) +{ + return (Scheduler_EDF_Node *) node; +} + +RTEMS_INLINE_ROUTINE bool _Scheduler_EDF_Less( + const void *left, + const RBTree_Node *right +) +{ + const Priority_Control *the_left; + const Scheduler_EDF_Node *the_right; + Priority_Control prio_left; + Priority_Control prio_right; + + the_left = left; + the_right = RTEMS_CONTAINER_OF( right, Scheduler_EDF_Node, Node ); + + prio_left = *the_left; + prio_right = the_right->priority; + + return prio_left < prio_right; +} + +RTEMS_INLINE_ROUTINE bool _Scheduler_EDF_Priority_less_equal( + const void *left, + const RBTree_Node *right +) +{ + const Priority_Control *the_left; + const Scheduler_EDF_Node *the_right; + Priority_Control prio_left; + Priority_Control prio_right; + + the_left = left; + the_right = RTEMS_CONTAINER_OF( right, Scheduler_EDF_Node, Node ); + + prio_left = *the_left; + prio_right = the_right->priority; + + return prio_left <= prio_right; +} + +RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Enqueue( + Scheduler_EDF_Context *context, + Scheduler_EDF_Node *node, + Priority_Control insert_priority +) +{ + _RBTree_Insert_inline( + &context->Ready, + &node->Node, + &insert_priority, + _Scheduler_EDF_Priority_less_equal + ); +} + +RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Extract( + Scheduler_EDF_Context *context, + Scheduler_EDF_Node *node +) +{ + _RBTree_Extract( &context->Ready, &node->Node ); +} + +RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Extract_body( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +) +{ + Scheduler_EDF_Context *context; + Scheduler_EDF_Node *the_node; + + context = _Scheduler_EDF_Get_context( scheduler ); + the_node = _Scheduler_EDF_Node_downcast( node ); + + _Scheduler_EDF_Extract( context, the_node ); +} + +RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Schedule_body( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + bool force_dispatch +) +{ + Scheduler_EDF_Context *context; + RBTree_Node *first; + Scheduler_EDF_Node *node; + + (void) the_thread; + + context = _Scheduler_EDF_Get_context( scheduler ); + first = _RBTree_Minimum( &context->Ready ); + node = RTEMS_CONTAINER_OF( first, Scheduler_EDF_Node, Node ); + + _Scheduler_Update_heir( node->Base.owner, force_dispatch ); +} + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/scheduleredfsmp.h b/cpukit/include/rtems/score/scheduleredfsmp.h new file mode 100644 index 0000000000..018568190e --- /dev/null +++ b/cpukit/include/rtems/score/scheduleredfsmp.h @@ -0,0 +1,200 @@ +/** + * @file + * + * @brief EDF SMP Scheduler API + * + * @ingroup ScoreSchedulerSMPEDF + */ + +/* + * Copyright (c) 2017 embedded brains GmbH. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SCHEDULEREDFSMP_H +#define _RTEMS_SCORE_SCHEDULEREDFSMP_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ScoreSchedulerSMPEDF EDF Priority SMP Scheduler + * + * @ingroup ScoreSchedulerSMP + * + * @{ + */ + +typedef struct { + Scheduler_SMP_Node Base; + + /** + * @brief Generation number to ensure FIFO/LIFO order for threads of the same + * priority across different ready queues. + */ + int64_t generation; + + /** + * @brief The ready queue index depending on the processor affinity of the thread. + * + * The ready queue index zero is used for threads with a one-to-all thread + * processor affinity. Threads with a one-to-one processor affinity use the + * processor index plus one as the ready queue index. + */ + uint32_t ready_queue_index; +} Scheduler_EDF_SMP_Node; + +typedef struct { + /** + * @brief Chain node for Scheduler_SMP_Context::Affine_queues. + */ + Chain_Node Node; + + /** + * @brief The ready threads of the corresponding affinity. + */ + RBTree_Control Queue; + + /** + * @brief The scheduled thread of the corresponding processor. + */ + Scheduler_EDF_SMP_Node *scheduled; +} Scheduler_EDF_SMP_Ready_queue; + +typedef struct { + Scheduler_SMP_Context Base; + + /** + * @brief Current generation for LIFO (index 0) and FIFO (index 1) ordering. + */ + int64_t generations[ 2 ]; + + /** + * @brief Chain of ready queues with affine threads to determine the highest + * priority ready thread. + */ + Chain_Control Affine_queues; + + /** + * @brief A table with ready queues. + * + * The index zero queue is used for threads with a one-to-all processor + * affinity. Index one corresponds to processor index zero, and so on. + */ + Scheduler_EDF_SMP_Ready_queue Ready[ RTEMS_ZERO_LENGTH_ARRAY ]; +} Scheduler_EDF_SMP_Context; + +#define SCHEDULER_EDF_SMP_ENTRY_POINTS \ + { \ + _Scheduler_EDF_SMP_Initialize, \ + _Scheduler_default_Schedule, \ + _Scheduler_EDF_SMP_Yield, \ + _Scheduler_EDF_SMP_Block, \ + _Scheduler_EDF_SMP_Unblock, \ + _Scheduler_EDF_SMP_Update_priority, \ + _Scheduler_EDF_Map_priority, \ + _Scheduler_EDF_Unmap_priority, \ + _Scheduler_EDF_SMP_Ask_for_help, \ + _Scheduler_EDF_SMP_Reconsider_help_request, \ + _Scheduler_EDF_SMP_Withdraw_node, \ + _Scheduler_EDF_SMP_Add_processor, \ + _Scheduler_EDF_SMP_Remove_processor, \ + _Scheduler_EDF_SMP_Node_initialize, \ + _Scheduler_default_Node_destroy, \ + _Scheduler_EDF_Release_job, \ + _Scheduler_EDF_Cancel_job, \ + _Scheduler_default_Tick, \ + _Scheduler_EDF_SMP_Start_idle, \ + _Scheduler_EDF_SMP_Set_affinity \ + } + +void _Scheduler_EDF_SMP_Initialize( const Scheduler_Control *scheduler ); + +void _Scheduler_EDF_SMP_Node_initialize( + const Scheduler_Control *scheduler, + Scheduler_Node *node, + Thread_Control *the_thread, + Priority_Control priority +); + +void _Scheduler_EDF_SMP_Block( + const Scheduler_Control *scheduler, + Thread_Control *thread, + Scheduler_Node *node +); + +void _Scheduler_EDF_SMP_Unblock( + const Scheduler_Control *scheduler, + Thread_Control *thread, + Scheduler_Node *node +); + +void _Scheduler_EDF_SMP_Update_priority( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +bool _Scheduler_EDF_SMP_Ask_for_help( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +void _Scheduler_EDF_SMP_Reconsider_help_request( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +void _Scheduler_EDF_SMP_Withdraw_node( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node, + Thread_Scheduler_state next_state +); + +void _Scheduler_EDF_SMP_Add_processor( + const Scheduler_Control *scheduler, + Thread_Control *idle +); + +Thread_Control *_Scheduler_EDF_SMP_Remove_processor( + const Scheduler_Control *scheduler, + struct Per_CPU_Control *cpu +); + +void _Scheduler_EDF_SMP_Yield( + const Scheduler_Control *scheduler, + Thread_Control *thread, + Scheduler_Node *node +); + +void _Scheduler_EDF_SMP_Start_idle( + const Scheduler_Control *scheduler, + Thread_Control *idle, + struct Per_CPU_Control *cpu +); + +bool _Scheduler_EDF_SMP_Set_affinity( + const Scheduler_Control *scheduler, + Thread_Control *thread, + Scheduler_Node *node, + const Processor_mask *affinity +); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_SCORE_SCHEDULEREDFSMP_H */ diff --git a/cpukit/include/rtems/score/schedulerimpl.h b/cpukit/include/rtems/score/schedulerimpl.h new file mode 100644 index 0000000000..10c12242a9 --- /dev/null +++ b/cpukit/include/rtems/score/schedulerimpl.h @@ -0,0 +1,1203 @@ +/** + * @file + * + * @brief Inlined Routines Associated with the Manipulation of the Scheduler + * + * This inline file contains all of the inlined routines associated with + * the manipulation of the scheduler. + */ + +/* + * Copyright (C) 2010 Gedare Bloom. + * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). + * Copyright (c) 2014, 2017 embedded brains GmbH + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SCHEDULERIMPL_H +#define _RTEMS_SCORE_SCHEDULERIMPL_H + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup ScoreScheduler + */ +/**@{**/ + +/** + * @brief Maps a priority value to support the append indicator. + */ +#define SCHEDULER_PRIORITY_MAP( priority ) ( ( priority ) << 1 ) + +/** + * @brief Returns the plain priority value. + */ +#define SCHEDULER_PRIORITY_UNMAP( priority ) ( ( priority ) >> 1 ) + +/** + * @brief Clears the priority append indicator bit. + */ +#define SCHEDULER_PRIORITY_PURIFY( priority ) \ + ( ( priority ) & ~( (Priority_Control) SCHEDULER_PRIORITY_APPEND_FLAG ) ) + +/** + * @brief Returns the priority control with the append indicator bit set. + */ +#define SCHEDULER_PRIORITY_APPEND( priority ) \ + ( ( priority ) | SCHEDULER_PRIORITY_APPEND_FLAG ) + +/** + * @brief Returns true, if the item should be appended to its priority group, + * otherwise returns false and the item should be prepended to its priority + * group. + */ +#define SCHEDULER_PRIORITY_IS_APPEND( priority ) \ + ( ( ( priority ) & SCHEDULER_PRIORITY_APPEND_FLAG ) != 0 ) + +/** + * @brief Initializes the scheduler to the policy chosen by the user. + * + * This routine initializes the scheduler to the policy chosen by the user + * through confdefs, or to the priority scheduler with ready chains by + * default. + */ +void _Scheduler_Handler_initialization( void ); + +RTEMS_INLINE_ROUTINE Scheduler_Context *_Scheduler_Get_context( + const Scheduler_Control *scheduler +) +{ + return scheduler->context; +} + +RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Get_by_CPU( + const Per_CPU_Control *cpu +) +{ +#if defined(RTEMS_SMP) + return cpu->Scheduler.control; +#else + (void) cpu; + return &_Scheduler_Table[ 0 ]; +#endif +} + +/** + * @brief Acquires the scheduler instance inside a critical section (interrupts + * disabled). + * + * @param[in] scheduler The scheduler instance. + * @param[in] lock_context The lock context to use for + * _Scheduler_Release_critical(). + */ +RTEMS_INLINE_ROUTINE void _Scheduler_Acquire_critical( + const Scheduler_Control *scheduler, + ISR_lock_Context *lock_context +) +{ +#if defined(RTEMS_SMP) + Scheduler_Context *context; + + context = _Scheduler_Get_context( scheduler ); + _ISR_lock_Acquire( &context->Lock, lock_context ); +#else + (void) scheduler; + (void) lock_context; +#endif +} + +/** + * @brief Releases the scheduler instance inside a critical section (interrupts + * disabled). + * + * @param[in] scheduler The scheduler instance. + * @param[in] lock_context The lock context used for + * _Scheduler_Acquire_critical(). + */ +RTEMS_INLINE_ROUTINE void _Scheduler_Release_critical( + const Scheduler_Control *scheduler, + ISR_lock_Context *lock_context +) +{ +#if defined(RTEMS_SMP) + Scheduler_Context *context; + + context = _Scheduler_Get_context( scheduler ); + _ISR_lock_Release( &context->Lock, lock_context ); +#else + (void) scheduler; + (void) lock_context; +#endif +} + +#if defined(RTEMS_SMP) +void _Scheduler_Request_ask_for_help( Thread_Control *the_thread ); + +/** + * @brief Registers an ask for help request if necessary. + * + * The actual ask for help operation is carried out during + * _Thread_Do_dispatch() on a processor related to the thread. This yields a + * better separation of scheduler instances. A thread of one scheduler + * instance should not be forced to carry out too much work for threads on + * other scheduler instances. + * + * @param[in] the_thread The thread in need for help. + */ +RTEMS_INLINE_ROUTINE void _Scheduler_Ask_for_help( Thread_Control *the_thread ) +{ + _Assert( _Thread_State_is_owner( the_thread ) ); + + if ( the_thread->Scheduler.helping_nodes > 0 ) { + _Scheduler_Request_ask_for_help( the_thread ); + } +} +#endif + +/** + * The preferred method to add a new scheduler is to define the jump table + * entries and add a case to the _Scheduler_Initialize routine. + * + * Generic scheduling implementations that rely on the ready queue only can + * be found in the _Scheduler_queue_XXX functions. + */ + +/* + * Passing the Scheduler_Control* to these functions allows for multiple + * scheduler's to exist simultaneously, which could be useful on an SMP + * system. Then remote Schedulers may be accessible. How to protect such + * accesses remains an open problem. + */ + +/** + * @brief General scheduling decision. + * + * This kernel routine implements the scheduling decision logic for + * the scheduler. It does NOT dispatch. + * + * @param[in] the_thread The thread which state changed previously. + */ +RTEMS_INLINE_ROUTINE void _Scheduler_Schedule( Thread_Control *the_thread ) +{ + const Scheduler_Control *scheduler; + ISR_lock_Context lock_context; + + scheduler = _Thread_Scheduler_get_home( the_thread ); + _Scheduler_Acquire_critical( scheduler, &lock_context ); + + ( *scheduler->Operations.schedule )( scheduler, the_thread ); + + _Scheduler_Release_critical( scheduler, &lock_context ); +} + +/** + * @brief Scheduler yield with a particular thread. + * + * This routine is invoked when a thread wishes to voluntarily transfer control + * of the processor to another thread. + * + * @param[in] the_thread The yielding thread. + */ +RTEMS_INLINE_ROUTINE void _Scheduler_Yield( Thread_Control *the_thread ) +{ + const Scheduler_Control *scheduler; + ISR_lock_Context lock_context; + + scheduler = _Thread_Scheduler_get_home( the_thread ); + _Scheduler_Acquire_critical( scheduler, &lock_context ); + ( *scheduler->Operations.yield )( + scheduler, + the_thread, + _Thread_Scheduler_get_home_node( the_thread ) + ); + _Scheduler_Release_critical( scheduler, &lock_context ); +} + +/** + * @brief Blocks a thread with respect to the scheduler. + * + * This routine removes @a the_thread from the scheduling decision for + * the scheduler. The primary task is to remove the thread from the + * ready queue. It performs any necessary schedulering operations + * including the selection of a new heir thread. + * + * @param[in] the_thread The thread. + */ +RTEMS_INLINE_ROUTINE void _Scheduler_Block( Thread_Control *the_thread ) +{ +#if defined(RTEMS_SMP) + Chain_Node *node; + const Chain_Node *tail; + Scheduler_Node *scheduler_node; + const Scheduler_Control *scheduler; + ISR_lock_Context lock_context; + + node = _Chain_First( &the_thread->Scheduler.Scheduler_nodes ); + tail = _Chain_Immutable_tail( &the_thread->Scheduler.Scheduler_nodes ); + + scheduler_node = SCHEDULER_NODE_OF_THREAD_SCHEDULER_NODE( node ); + scheduler = _Scheduler_Node_get_scheduler( scheduler_node ); + + _Scheduler_Acquire_critical( scheduler, &lock_context ); + ( *scheduler->Operations.block )( + scheduler, + the_thread, + scheduler_node + ); + _Scheduler_Release_critical( scheduler, &lock_context ); + + node = _Chain_Next( node ); + + while ( node != tail ) { + scheduler_node = SCHEDULER_NODE_OF_THREAD_SCHEDULER_NODE( node ); + scheduler = _Scheduler_Node_get_scheduler( scheduler_node ); + + _Scheduler_Acquire_critical( scheduler, &lock_context ); + ( *scheduler->Operations.withdraw_node )( + scheduler, + the_thread, + scheduler_node, + THREAD_SCHEDULER_BLOCKED + ); + _Scheduler_Release_critical( scheduler, &lock_context ); + + node = _Chain_Next( node ); + } +#else + const Scheduler_Control *scheduler; + + scheduler = _Thread_Scheduler_get_home( the_thread ); + ( *scheduler->Operations.block )( + scheduler, + the_thread, + _Thread_Scheduler_get_home_node( the_thread ) + ); +#endif +} + +/** + * @brief Unblocks a thread with respect to the scheduler. + * + * This operation must fetch the latest thread priority value for this + * scheduler instance and update its internal state if necessary. + * + * @param[in] the_thread The thread. + * + * @see _Scheduler_Node_get_priority(). + */ +RTEMS_INLINE_ROUTINE void _Scheduler_Unblock( Thread_Control *the_thread ) +{ + const Scheduler_Control *scheduler; + ISR_lock_Context lock_context; + + scheduler = _Thread_Scheduler_get_home( the_thread ); + _Scheduler_Acquire_critical( scheduler, &lock_context ); + ( *scheduler->Operations.unblock )( + scheduler, + the_thread, + _Thread_Scheduler_get_home_node( the_thread ) + ); + _Scheduler_Release_critical( scheduler, &lock_context ); +} + +/** + * @brief Propagates a priority change of a thread to the scheduler. + * + * On uni-processor configurations, this operation must evaluate the thread + * state. In case the thread is not ready, then the priority update should be + * deferred to the next scheduler unblock operation. + * + * The operation must update the heir and thread dispatch necessary variables + * in case the set of scheduled threads changes. + * + * @param[in] the_thread The thread changing its priority. + * + * @see _Scheduler_Node_get_priority(). + */ +RTEMS_INLINE_ROUTINE void _Scheduler_Update_priority( Thread_Control *the_thread ) +{ +#if defined(RTEMS_SMP) + Chain_Node *node; + const Chain_Node *tail; + + _Thread_Scheduler_process_requests( the_thread ); + + node = _Chain_First( &the_thread->Scheduler.Scheduler_nodes ); + tail = _Chain_Immutable_tail( &the_thread->Scheduler.Scheduler_nodes ); + + do { + Scheduler_Node *scheduler_node; + const Scheduler_Control *scheduler; + ISR_lock_Context lock_context; + + scheduler_node = SCHEDULER_NODE_OF_THREAD_SCHEDULER_NODE( node ); + scheduler = _Scheduler_Node_get_scheduler( scheduler_node ); + + _Scheduler_Acquire_critical( scheduler, &lock_context ); + ( *scheduler->Operations.update_priority )( + scheduler, + the_thread, + scheduler_node + ); + _Scheduler_Release_critical( scheduler, &lock_context ); + + node = _Chain_Next( node ); + } while ( node != tail ); +#else + const Scheduler_Control *scheduler; + + scheduler = _Thread_Scheduler_get_home( the_thread ); + ( *scheduler->Operations.update_priority )( + scheduler, + the_thread, + _Thread_Scheduler_get_home_node( the_thread ) + ); +#endif +} + +#if defined(RTEMS_SMP) +/** + * @brief Changes the sticky level of the home scheduler node and propagates a + * priority change of a thread to the scheduler. + * + * @param[in] the_thread The thread changing its priority or sticky level. + * + * @see _Scheduler_Update_priority(). + */ +RTEMS_INLINE_ROUTINE void _Scheduler_Priority_and_sticky_update( + Thread_Control *the_thread, + int sticky_level_change +) +{ + Chain_Node *node; + const Chain_Node *tail; + Scheduler_Node *scheduler_node; + const Scheduler_Control *scheduler; + ISR_lock_Context lock_context; + + _Thread_Scheduler_process_requests( the_thread ); + + node = _Chain_First( &the_thread->Scheduler.Scheduler_nodes ); + scheduler_node = SCHEDULER_NODE_OF_THREAD_SCHEDULER_NODE( node ); + scheduler = _Scheduler_Node_get_scheduler( scheduler_node ); + + _Scheduler_Acquire_critical( scheduler, &lock_context ); + + scheduler_node->sticky_level += sticky_level_change; + _Assert( scheduler_node->sticky_level >= 0 ); + + ( *scheduler->Operations.update_priority )( + scheduler, + the_thread, + scheduler_node + ); + + _Scheduler_Release_critical( scheduler, &lock_context ); + + tail = _Chain_Immutable_tail( &the_thread->Scheduler.Scheduler_nodes ); + node = _Chain_Next( node ); + + while ( node != tail ) { + scheduler_node = SCHEDULER_NODE_OF_THREAD_SCHEDULER_NODE( node ); + scheduler = _Scheduler_Node_get_scheduler( scheduler_node ); + + _Scheduler_Acquire_critical( scheduler, &lock_context ); + ( *scheduler->Operations.update_priority )( + scheduler, + the_thread, + scheduler_node + ); + _Scheduler_Release_critical( scheduler, &lock_context ); + + node = _Chain_Next( node ); + } +} +#endif + +/** + * @brief Maps a thread priority from the user domain to the scheduler domain. + * + * Let M be the maximum scheduler priority. The mapping must be bijective in + * the closed interval [0, M], e.g. _Scheduler_Unmap_priority( scheduler, + * _Scheduler_Map_priority( scheduler, p ) ) == p for all p in [0, M]. For + * other values the mapping is undefined. + * + * @param[in] scheduler The scheduler instance. + * @param[in] priority The user domain thread priority. + * + * @return The corresponding thread priority of the scheduler domain is returned. + */ +RTEMS_INLINE_ROUTINE Priority_Control _Scheduler_Map_priority( + const Scheduler_Control *scheduler, + Priority_Control priority +) +{ + return ( *scheduler->Operations.map_priority )( scheduler, priority ); +} + +/** + * @brief Unmaps a thread priority from the scheduler domain to the user domain. + * + * @param[in] scheduler The scheduler instance. + * @param[in] priority The scheduler domain thread priority. + * + * @return The corresponding thread priority of the user domain is returned. + */ +RTEMS_INLINE_ROUTINE Priority_Control _Scheduler_Unmap_priority( + const Scheduler_Control *scheduler, + Priority_Control priority +) +{ + return ( *scheduler->Operations.unmap_priority )( scheduler, priority ); +} + +/** + * @brief Initializes a scheduler node. + * + * The scheduler node contains arbitrary data on function entry. The caller + * must ensure that _Scheduler_Node_destroy() will be called after a + * _Scheduler_Node_initialize() before the memory of the scheduler node is + * destroyed. + * + * @param[in] scheduler The scheduler instance. + * @param[in] node The scheduler node to initialize. + * @param[in] the_thread The thread of the scheduler node to initialize. + * @param[in] priority The thread priority. + */ +RTEMS_INLINE_ROUTINE void _Scheduler_Node_initialize( + const Scheduler_Control *scheduler, + Scheduler_Node *node, + Thread_Control *the_thread, + Priority_Control priority +) +{ + ( *scheduler->Operations.node_initialize )( + scheduler, + node, + the_thread, + priority + ); +} + +/** + * @brief Destroys a scheduler node. + * + * The caller must ensure that _Scheduler_Node_destroy() will be called only + * after a corresponding _Scheduler_Node_initialize(). + * + * @param[in] scheduler The scheduler instance. + * @param[in] node The scheduler node to destroy. + */ +RTEMS_INLINE_ROUTINE void _Scheduler_Node_destroy( + const Scheduler_Control *scheduler, + Scheduler_Node *node +) +{ + ( *scheduler->Operations.node_destroy )( scheduler, node ); +} + +/** + * @brief Releases a job of a thread with respect to the scheduler. + * + * @param[in] the_thread The thread. + * @param[in] priority_node The priority node of the job. + * @param[in] deadline The deadline in watchdog ticks since boot. + * @param[in] queue_context The thread queue context to provide the set of + * threads for _Thread_Priority_update(). + */ +RTEMS_INLINE_ROUTINE void _Scheduler_Release_job( + Thread_Control *the_thread, + Priority_Node *priority_node, + uint64_t deadline, + Thread_queue_Context *queue_context +) +{ + const Scheduler_Control *scheduler = _Thread_Scheduler_get_home( the_thread ); + + _Thread_queue_Context_clear_priority_updates( queue_context ); + ( *scheduler->Operations.release_job )( + scheduler, + the_thread, + priority_node, + deadline, + queue_context + ); +} + +/** + * @brief Cancels a job of a thread with respect to the scheduler. + * + * @param[in] the_thread The thread. + * @param[in] priority_node The priority node of the job. + * @param[in] queue_context The thread queue context to provide the set of + * threads for _Thread_Priority_update(). + */ +RTEMS_INLINE_ROUTINE void _Scheduler_Cancel_job( + Thread_Control *the_thread, + Priority_Node *priority_node, + Thread_queue_Context *queue_context +) +{ + const Scheduler_Control *scheduler = _Thread_Scheduler_get_home( the_thread ); + + _Thread_queue_Context_clear_priority_updates( queue_context ); + ( *scheduler->Operations.cancel_job )( + scheduler, + the_thread, + priority_node, + queue_context + ); +} + +/** + * @brief Scheduler method invoked at each clock tick. + * + * This method is invoked at each clock tick to allow the scheduler + * implementation to perform any activities required. For the + * scheduler which support standard RTEMS features, this includes + * time-slicing management. + */ +RTEMS_INLINE_ROUTINE void _Scheduler_Tick( const Per_CPU_Control *cpu ) +{ + const Scheduler_Control *scheduler = _Scheduler_Get_by_CPU( cpu ); + Thread_Control *executing = cpu->executing; + + if ( scheduler != NULL && executing != NULL ) { + ( *scheduler->Operations.tick )( scheduler, executing ); + } +} + +/** + * @brief Starts the idle thread for a particular processor. + * + * @param[in] scheduler The scheduler instance. + * @param[in,out] the_thread The idle thread for the processor. + * @param[in,out] cpu The processor for the idle thread. + * + * @see _Thread_Create_idle(). + */ +RTEMS_INLINE_ROUTINE void _Scheduler_Start_idle( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Per_CPU_Control *cpu +) +{ + ( *scheduler->Operations.start_idle )( scheduler, the_thread, cpu ); +} + +RTEMS_INLINE_ROUTINE bool _Scheduler_Has_processor_ownership( + const Scheduler_Control *scheduler, + uint32_t cpu_index +) +{ +#if defined(RTEMS_SMP) + const Per_CPU_Control *cpu; + const Scheduler_Control *scheduler_of_cpu; + + cpu = _Per_CPU_Get_by_index( cpu_index ); + scheduler_of_cpu = _Scheduler_Get_by_CPU( cpu ); + + return scheduler_of_cpu == scheduler; +#else + (void) scheduler; + (void) cpu_index; + + return true; +#endif +} + +RTEMS_INLINE_ROUTINE const Processor_mask *_Scheduler_Get_processors( + const Scheduler_Control *scheduler +) +{ +#if defined(RTEMS_SMP) + return &_Scheduler_Get_context( scheduler )->Processors; +#else + return &_Processor_mask_The_one_and_only; +#endif +} + +bool _Scheduler_Get_affinity( + Thread_Control *the_thread, + size_t cpusetsize, + cpu_set_t *cpuset +); + +RTEMS_INLINE_ROUTINE bool _Scheduler_default_Set_affinity_body( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node, + const Processor_mask *affinity +) +{ + (void) scheduler; + (void) the_thread; + (void) node; + return _Processor_mask_Is_subset( affinity, _SMP_Get_online_processors() ); +} + +bool _Scheduler_Set_affinity( + Thread_Control *the_thread, + size_t cpusetsize, + const cpu_set_t *cpuset +); + +RTEMS_INLINE_ROUTINE void _Scheduler_Generic_block( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node, + void ( *extract )( + const Scheduler_Control *, + Thread_Control *, + Scheduler_Node * + ), + void ( *schedule )( + const Scheduler_Control *, + Thread_Control *, + bool + ) +) +{ + ( *extract )( scheduler, the_thread, node ); + + /* TODO: flash critical section? */ + + if ( _Thread_Is_executing( the_thread ) || _Thread_Is_heir( the_thread ) ) { + ( *schedule )( scheduler, the_thread, true ); + } +} + +RTEMS_INLINE_ROUTINE uint32_t _Scheduler_Get_processor_count( + const Scheduler_Control *scheduler +) +{ +#if defined(RTEMS_SMP) + const Scheduler_Context *context = _Scheduler_Get_context( scheduler ); + + return _Processor_mask_Count( &context->Processors ); +#else + (void) scheduler; + + return 1; +#endif +} + +RTEMS_INLINE_ROUTINE Objects_Id _Scheduler_Build_id( uint32_t scheduler_index ) +{ + return _Objects_Build_id( + OBJECTS_FAKE_OBJECTS_API, + OBJECTS_FAKE_OBJECTS_SCHEDULERS, + _Objects_Local_node, + (uint16_t) ( scheduler_index + 1 ) + ); +} + +RTEMS_INLINE_ROUTINE uint32_t _Scheduler_Get_index_by_id( Objects_Id id ) +{ + uint32_t minimum_id = _Scheduler_Build_id( 0 ); + + return id - minimum_id; +} + +RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Get_by_id( + Objects_Id id +) +{ + uint32_t index; + + index = _Scheduler_Get_index_by_id( id ); + + if ( index >= _Scheduler_Count ) { + return NULL; + } + + return &_Scheduler_Table[ index ]; +} + +RTEMS_INLINE_ROUTINE uint32_t _Scheduler_Get_index( + const Scheduler_Control *scheduler +) +{ + return (uint32_t) (scheduler - &_Scheduler_Table[ 0 ]); +} + +#if defined(RTEMS_SMP) +/** + * @brief Gets an idle thread from the scheduler instance. + * + * @param[in] context The scheduler instance context. + * + * @retval idle An idle thread for use. This function must always return an + * idle thread. If none is available, then this is a fatal error. + */ +typedef Thread_Control *( *Scheduler_Get_idle_thread )( + Scheduler_Context *context +); + +/** + * @brief Releases an idle thread to the scheduler instance for reuse. + * + * @param[in] context The scheduler instance context. + * @param[in] idle The idle thread to release + */ +typedef void ( *Scheduler_Release_idle_thread )( + Scheduler_Context *context, + Thread_Control *idle +); + +RTEMS_INLINE_ROUTINE void _Scheduler_Thread_change_state( + Thread_Control *the_thread, + Thread_Scheduler_state new_state +) +{ + _Assert( + _ISR_lock_Is_owner( &the_thread->Scheduler.Lock ) + || the_thread->Scheduler.state == THREAD_SCHEDULER_BLOCKED + || !_System_state_Is_up( _System_state_Get() ) + ); + + the_thread->Scheduler.state = new_state; +} + +RTEMS_INLINE_ROUTINE void _Scheduler_Set_idle_thread( + Scheduler_Node *node, + Thread_Control *idle +) +{ + _Assert( _Scheduler_Node_get_idle( node ) == NULL ); + _Assert( + _Scheduler_Node_get_owner( node ) == _Scheduler_Node_get_user( node ) + ); + + _Scheduler_Node_set_user( node, idle ); + node->idle = idle; +} + +/** + * @brief Use an idle thread for this scheduler node. + * + * A thread those home scheduler node has a sticky level greater than zero may + * use an idle thread in the home scheduler instance in case it executes + * currently in another scheduler instance or in case it is in a blocking + * state. + * + * @param[in] context The scheduler instance context. + * @param[in] node The node which wants to use the idle thread. + * @param[in] cpu The processor for the idle thread. + * @param[in] get_idle_thread Function to get an idle thread. + */ +RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Use_idle_thread( + Scheduler_Context *context, + Scheduler_Node *node, + Per_CPU_Control *cpu, + Scheduler_Get_idle_thread get_idle_thread +) +{ + Thread_Control *idle = ( *get_idle_thread )( context ); + + _Scheduler_Set_idle_thread( node, idle ); + _Thread_Set_CPU( idle, cpu ); + return idle; +} + +typedef enum { + SCHEDULER_TRY_TO_SCHEDULE_DO_SCHEDULE, + SCHEDULER_TRY_TO_SCHEDULE_DO_IDLE_EXCHANGE, + SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK +} Scheduler_Try_to_schedule_action; + +/** + * @brief Try to schedule this scheduler node. + * + * @param[in] context The scheduler instance context. + * @param[in] node The node which wants to get scheduled. + * @param[in] idle A potential idle thread used by a potential victim node. + * @param[in] get_idle_thread Function to get an idle thread. + * + * @retval true This node can be scheduled. + * @retval false Otherwise. + */ +RTEMS_INLINE_ROUTINE Scheduler_Try_to_schedule_action +_Scheduler_Try_to_schedule_node( + Scheduler_Context *context, + Scheduler_Node *node, + Thread_Control *idle, + Scheduler_Get_idle_thread get_idle_thread +) +{ + ISR_lock_Context lock_context; + Scheduler_Try_to_schedule_action action; + Thread_Control *owner; + + action = SCHEDULER_TRY_TO_SCHEDULE_DO_SCHEDULE; + owner = _Scheduler_Node_get_owner( node ); + _Assert( _Scheduler_Node_get_user( node ) == owner ); + _Assert( _Scheduler_Node_get_idle( node ) == NULL ); + + _Thread_Scheduler_acquire_critical( owner, &lock_context ); + + if ( owner->Scheduler.state == THREAD_SCHEDULER_READY ) { + _Thread_Scheduler_cancel_need_for_help( owner, _Thread_Get_CPU( owner ) ); + _Scheduler_Thread_change_state( owner, THREAD_SCHEDULER_SCHEDULED ); + } else if ( + owner->Scheduler.state == THREAD_SCHEDULER_SCHEDULED + && node->sticky_level <= 1 + ) { + action = SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK; + } else if ( node->sticky_level == 0 ) { + action = SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK; + } else if ( idle != NULL ) { + action = SCHEDULER_TRY_TO_SCHEDULE_DO_IDLE_EXCHANGE; + } else { + _Scheduler_Use_idle_thread( + context, + node, + _Thread_Get_CPU( owner ), + get_idle_thread + ); + } + + _Thread_Scheduler_release_critical( owner, &lock_context ); + return action; +} + +/** + * @brief Release an idle thread using this scheduler node. + * + * @param[in] context The scheduler instance context. + * @param[in] node The node which may have an idle thread as user. + * @param[in] release_idle_thread Function to release an idle thread. + * + * @retval idle The idle thread which used this node. + * @retval NULL This node had no idle thread as an user. + */ +RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Release_idle_thread( + Scheduler_Context *context, + Scheduler_Node *node, + Scheduler_Release_idle_thread release_idle_thread +) +{ + Thread_Control *idle = _Scheduler_Node_get_idle( node ); + + if ( idle != NULL ) { + Thread_Control *owner = _Scheduler_Node_get_owner( node ); + + node->idle = NULL; + _Scheduler_Node_set_user( node, owner ); + ( *release_idle_thread )( context, idle ); + } + + return idle; +} + +RTEMS_INLINE_ROUTINE void _Scheduler_Exchange_idle_thread( + Scheduler_Node *needs_idle, + Scheduler_Node *uses_idle, + Thread_Control *idle +) +{ + uses_idle->idle = NULL; + _Scheduler_Node_set_user( + uses_idle, + _Scheduler_Node_get_owner( uses_idle ) + ); + _Scheduler_Set_idle_thread( needs_idle, idle ); +} + +/** + * @brief Block this scheduler node. + * + * @param[in] context The scheduler instance context. + * @param[in] thread The thread which wants to get blocked referencing this + * node. This is not necessarily the user of this node in case the node + * participates in the scheduler helping protocol. + * @param[in] node The node which wants to get blocked. + * @param[in] is_scheduled This node is scheduled. + * @param[in] get_idle_thread Function to get an idle thread. + * + * @retval thread_cpu The processor of the thread. Indicates to continue with + * the blocking operation. + * @retval NULL Otherwise. + */ +RTEMS_INLINE_ROUTINE Per_CPU_Control *_Scheduler_Block_node( + Scheduler_Context *context, + Thread_Control *thread, + Scheduler_Node *node, + bool is_scheduled, + Scheduler_Get_idle_thread get_idle_thread +) +{ + int sticky_level; + ISR_lock_Context lock_context; + Per_CPU_Control *thread_cpu; + + sticky_level = node->sticky_level; + --sticky_level; + node->sticky_level = sticky_level; + _Assert( sticky_level >= 0 ); + + _Thread_Scheduler_acquire_critical( thread, &lock_context ); + thread_cpu = _Thread_Get_CPU( thread ); + _Thread_Scheduler_cancel_need_for_help( thread, thread_cpu ); + _Scheduler_Thread_change_state( thread, THREAD_SCHEDULER_BLOCKED ); + _Thread_Scheduler_release_critical( thread, &lock_context ); + + if ( sticky_level > 0 ) { + if ( is_scheduled && _Scheduler_Node_get_idle( node ) == NULL ) { + Thread_Control *idle; + + idle = _Scheduler_Use_idle_thread( + context, + node, + thread_cpu, + get_idle_thread + ); + _Thread_Dispatch_update_heir( _Per_CPU_Get(), thread_cpu, idle ); + } + + return NULL; + } + + _Assert( thread == _Scheduler_Node_get_user( node ) ); + return thread_cpu; +} + +RTEMS_INLINE_ROUTINE void _Scheduler_Discard_idle_thread( + Scheduler_Context *context, + Thread_Control *the_thread, + Scheduler_Node *node, + Scheduler_Release_idle_thread release_idle_thread +) +{ + Thread_Control *idle; + Thread_Control *owner; + Per_CPU_Control *cpu; + + idle = _Scheduler_Node_get_idle( node ); + owner = _Scheduler_Node_get_owner( node ); + + node->idle = NULL; + _Assert( _Scheduler_Node_get_user( node ) == idle ); + _Scheduler_Node_set_user( node, owner ); + ( *release_idle_thread )( context, idle ); + + cpu = _Thread_Get_CPU( idle ); + _Thread_Set_CPU( the_thread, cpu ); + _Thread_Dispatch_update_heir( _Per_CPU_Get(), cpu, the_thread ); +} + +/** + * @brief Unblock this scheduler node. + * + * @param[in] context The scheduler instance context. + * @param[in] the_thread The thread which wants to get unblocked. + * @param[in] node The node which wants to get unblocked. + * @param[in] is_scheduled This node is scheduled. + * @param[in] release_idle_thread Function to release an idle thread. + * + * @retval true Continue with the unblocking operation. + * @retval false Otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Scheduler_Unblock_node( + Scheduler_Context *context, + Thread_Control *the_thread, + Scheduler_Node *node, + bool is_scheduled, + Scheduler_Release_idle_thread release_idle_thread +) +{ + bool unblock; + + ++node->sticky_level; + _Assert( node->sticky_level > 0 ); + + if ( is_scheduled ) { + _Scheduler_Discard_idle_thread( + context, + the_thread, + node, + release_idle_thread + ); + _Scheduler_Thread_change_state( the_thread, THREAD_SCHEDULER_SCHEDULED ); + unblock = false; + } else { + _Scheduler_Thread_change_state( the_thread, THREAD_SCHEDULER_READY ); + unblock = true; + } + + return unblock; +} +#endif + +RTEMS_INLINE_ROUTINE void _Scheduler_Update_heir( + Thread_Control *new_heir, + bool force_dispatch +) +{ + Thread_Control *heir = _Thread_Heir; + + if ( heir != new_heir && ( heir->is_preemptible || force_dispatch ) ) { +#if defined(RTEMS_SMP) + /* + * We need this state only for _Thread_Get_CPU_time_used(). Cannot use + * _Scheduler_Thread_change_state() since THREAD_SCHEDULER_BLOCKED to + * THREAD_SCHEDULER_BLOCKED state changes are illegal for the real SMP + * schedulers. + */ + heir->Scheduler.state = THREAD_SCHEDULER_BLOCKED; + new_heir->Scheduler.state = THREAD_SCHEDULER_SCHEDULED; +#endif + _Thread_Update_CPU_time_used( heir, _Thread_Get_CPU( heir ) ); + _Thread_Heir = new_heir; + _Thread_Dispatch_necessary = true; + } +} + +RTEMS_INLINE_ROUTINE Status_Control _Scheduler_Set( + const Scheduler_Control *new_scheduler, + Thread_Control *the_thread, + Priority_Control priority +) +{ + Scheduler_Node *new_scheduler_node; + Scheduler_Node *old_scheduler_node; +#if defined(RTEMS_SMP) + ISR_lock_Context lock_context; + const Scheduler_Control *old_scheduler; + +#endif + + if ( the_thread->Wait.queue != NULL ) { + return STATUS_RESOURCE_IN_USE; + } + + old_scheduler_node = _Thread_Scheduler_get_home_node( the_thread ); + _Priority_Plain_extract( + &old_scheduler_node->Wait.Priority, + &the_thread->Real_priority + ); + + if ( !_Priority_Is_empty( &old_scheduler_node->Wait.Priority ) ) { + _Priority_Plain_insert( + &old_scheduler_node->Wait.Priority, + &the_thread->Real_priority, + the_thread->Real_priority.priority + ); + return STATUS_RESOURCE_IN_USE; + } + +#if defined(RTEMS_SMP) + if ( !_Chain_Has_only_one_node( &the_thread->Scheduler.Wait_nodes ) ) { + _Priority_Plain_insert( + &old_scheduler_node->Wait.Priority, + &the_thread->Real_priority, + the_thread->Real_priority.priority + ); + return STATUS_RESOURCE_IN_USE; + } + + old_scheduler = _Thread_Scheduler_get_home( the_thread ); + new_scheduler_node = _Thread_Scheduler_get_node_by_index( + the_thread, + _Scheduler_Get_index( new_scheduler ) + ); + + _Scheduler_Acquire_critical( new_scheduler, &lock_context ); + + if ( + _Scheduler_Get_processor_count( new_scheduler ) == 0 + || !( *new_scheduler->Operations.set_affinity )( + new_scheduler, + the_thread, + new_scheduler_node, + &the_thread->Scheduler.Affinity + ) + ) { + _Scheduler_Release_critical( new_scheduler, &lock_context ); + _Priority_Plain_insert( + &old_scheduler_node->Wait.Priority, + &the_thread->Real_priority, + the_thread->Real_priority.priority + ); + return STATUS_UNSATISFIED; + } + + the_thread->Scheduler.home = new_scheduler; + + _Scheduler_Release_critical( new_scheduler, &lock_context ); + + _Thread_Scheduler_process_requests( the_thread ); +#else + new_scheduler_node = old_scheduler_node; +#endif + + the_thread->Start.initial_priority = priority; + _Priority_Node_set_priority( &the_thread->Real_priority, priority ); + _Priority_Initialize_one( + &new_scheduler_node->Wait.Priority, + &the_thread->Real_priority + ); + +#if defined(RTEMS_SMP) + if ( old_scheduler != new_scheduler ) { + States_Control current_state; + + current_state = the_thread->current_state; + + if ( _States_Is_ready( current_state ) ) { + _Scheduler_Block( the_thread ); + } + + _Assert( old_scheduler_node->sticky_level == 0 ); + _Assert( new_scheduler_node->sticky_level == 0 ); + + _Chain_Extract_unprotected( &old_scheduler_node->Thread.Wait_node ); + _Assert( _Chain_Is_empty( &the_thread->Scheduler.Wait_nodes ) ); + _Chain_Initialize_one( + &the_thread->Scheduler.Wait_nodes, + &new_scheduler_node->Thread.Wait_node + ); + _Chain_Extract_unprotected( + &old_scheduler_node->Thread.Scheduler_node.Chain + ); + _Assert( _Chain_Is_empty( &the_thread->Scheduler.Scheduler_nodes ) ); + _Chain_Initialize_one( + &the_thread->Scheduler.Scheduler_nodes, + &new_scheduler_node->Thread.Scheduler_node.Chain + ); + + _Scheduler_Node_set_priority( new_scheduler_node, priority, false ); + + if ( _States_Is_ready( current_state ) ) { + _Scheduler_Unblock( the_thread ); + } + + return STATUS_SUCCESSFUL; + } +#endif + + _Scheduler_Node_set_priority( new_scheduler_node, priority, false ); + _Scheduler_Update_priority( the_thread ); + return STATUS_SUCCESSFUL; +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/schedulernode.h b/cpukit/include/rtems/score/schedulernode.h new file mode 100644 index 0000000000..d62e983853 --- /dev/null +++ b/cpukit/include/rtems/score/schedulernode.h @@ -0,0 +1,217 @@ +/* + * Copyright (c) 2014, 2016 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SCHEDULERNODE_H +#define _RTEMS_SCORE_SCHEDULERNODE_H + +#include +#include +#include +#include + +struct _Thread_Control; + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#if defined(RTEMS_SMP) +/** + * @brief The scheduler node requests. + */ +typedef enum { + /** + * @brief The scheduler node is not on the list of pending requests. + */ + SCHEDULER_NODE_REQUEST_NOT_PENDING, + + /** + * @brief There is a pending scheduler node request to add this scheduler + * node to the Thread_Control::Scheduler::Scheduler_nodes chain. + */ + SCHEDULER_NODE_REQUEST_ADD, + + /** + * @brief There is a pending scheduler node request to remove this scheduler + * node from the Thread_Control::Scheduler::Scheduler_nodes chain. + */ + SCHEDULER_NODE_REQUEST_REMOVE, + + /** + * @brief The scheduler node is on the list of pending requests, but nothing + * should change. + */ + SCHEDULER_NODE_REQUEST_NOTHING, + +} Scheduler_Node_request; +#endif + +typedef struct Scheduler_Node Scheduler_Node; + +/** + * @brief Scheduler node for per-thread data. + */ +struct Scheduler_Node { +#if defined(RTEMS_SMP) + /** + * @brief Chain node for usage in various scheduler data structures. + * + * Strictly, this is the wrong place for this field since the data structures + * to manage scheduler nodes belong to the particular scheduler + * implementation. Currently, all SMP scheduler implementations use chains + * or red-black trees. The node is here to simplify things, just like the + * object node in the thread control block. + */ + union { + Chain_Node Chain; + RBTree_Node RBTree; + } Node; + + /** + * @brief The sticky level determines if this scheduler node should use an + * idle thread in case this node is scheduled and the owner thread is + * blocked. + */ + int sticky_level; + + /** + * @brief The thread using this node. + * + * This is either the owner or an idle thread. + */ + struct _Thread_Control *user; + + /** + * @brief The idle thread claimed by this node in case the sticky level is + * greater than zero and the thread is block or is scheduled on another + * scheduler instance. + * + * This is necessary to ensure the priority ceiling protocols work across + * scheduler boundaries. + */ + struct _Thread_Control *idle; +#endif + + /** + * @brief The thread owning this node. + */ + struct _Thread_Control *owner; + +#if defined(RTEMS_SMP) + /** + * @brief Block to register and manage this scheduler node in the thread + * control block of the owner of this scheduler node. + */ + struct { + /** + * @brief Node to add this scheduler node to + * Thread_Control::Scheduler::Wait_nodes. + */ + Chain_Node Wait_node; + + /** + * @brief Node to add this scheduler node to + * Thread_Control::Scheduler::Scheduler_nodes or a temporary remove list. + */ + union { + /** + * @brief The node for Thread_Control::Scheduler::Scheduler_nodes. + */ + Chain_Node Chain; + + /** + * @brief The next pointer for a temporary remove list. + * + * @see _Thread_Scheduler_process_requests(). + */ + Scheduler_Node *next; + } Scheduler_node; + + /** + * @brief Link to the next scheduler node in the + * Thread_Control::Scheduler::requests list. + */ + Scheduler_Node *next_request; + + /** + * @brief The current scheduler node request. + */ + Scheduler_Node_request request; + } Thread; +#endif + + /** + * @brief Thread wait support block. + */ + struct { + Priority_Aggregation Priority; + } Wait; + + /** + * @brief The thread priority information used by the scheduler. + * + * The thread priority is manifest in two independent areas. One area is the + * user visible thread priority along with a potential thread queue. The + * other is the scheduler. During a thread priority change, the user visible + * thread priority and the thread queue are first updated and the thread + * priority value here is changed. Once this is done the scheduler is + * notified via the update priority operation, so that it can update its + * internal state and honour a new thread priority value. + */ + struct { + /** + * @brief The thread priority value of this scheduler node. + * + * The producer of this value is _Thread_Change_priority(). The consumer + * is the scheduler via the unblock and update priority operations. + * + * This priority control consists of two parts. One part is the plain + * priority value (most-significant 63 bits). The other part is the + * least-significant bit which indicates if the thread should be appended + * (bit set) or prepended (bit cleared) to its priority group, see + * SCHEDULER_PRIORITY_APPEND(). + */ + Priority_Control value; + +#if defined(RTEMS_SMP) + /** + * @brief Sequence lock to synchronize priority value updates. + */ + SMP_sequence_lock_Control Lock; +#endif + } Priority; +}; + +#if defined(RTEMS_SMP) +/** + * @brief The size of a scheduler node. + * + * This value is provided via . + */ +extern const size_t _Scheduler_Node_size; +#endif + +#if defined(RTEMS_SMP) +#define SCHEDULER_NODE_OF_THREAD_WAIT_NODE( node ) \ + RTEMS_CONTAINER_OF( node, Scheduler_Node, Thread.Wait_node ) + +#define SCHEDULER_NODE_OF_THREAD_SCHEDULER_NODE( node ) \ + RTEMS_CONTAINER_OF( node, Scheduler_Node, Thread.Scheduler_node.Chain ) +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_SCORE_SCHEDULERNODE_H */ diff --git a/cpukit/include/rtems/score/schedulernodeimpl.h b/cpukit/include/rtems/score/schedulernodeimpl.h new file mode 100644 index 0000000000..8997b3f218 --- /dev/null +++ b/cpukit/include/rtems/score/schedulernodeimpl.h @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2014, 2017 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SCHEDULERNODEIMPL_H +#define _RTEMS_SCORE_SCHEDULERNODEIMPL_H + +#include +#include + +struct _Scheduler_Control; + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define SCHEDULER_NODE_OF_WAIT_PRIORITY_NODE( node ) \ + RTEMS_CONTAINER_OF( node, Scheduler_Node, Wait.Priority.Node.Node.Chain ) + +#define SCHEDULER_NODE_OF_WAIT_PRIORITY( node ) \ + RTEMS_CONTAINER_OF( node, Scheduler_Node, Wait.Priority ) + +/** + * @brief Priority append indicator for the priority control used for the + * scheduler node priority. + */ +#define SCHEDULER_PRIORITY_APPEND_FLAG 1 + +RTEMS_INLINE_ROUTINE void _Scheduler_Node_do_initialize( + const struct _Scheduler_Control *scheduler, + Scheduler_Node *node, + Thread_Control *the_thread, + Priority_Control priority +) +{ + node->owner = the_thread; + + node->Priority.value = priority; + +#if defined(RTEMS_SMP) + _Chain_Initialize_node( &node->Thread.Wait_node ); + node->Wait.Priority.scheduler = scheduler; + node->user = the_thread; + node->idle = NULL; + _SMP_sequence_lock_Initialize( &node->Priority.Lock ); +#else + (void) scheduler; + (void) the_thread; +#endif +} + +RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Node_get_scheduler( + const Scheduler_Node *node +) +{ + return _Priority_Get_scheduler( &node->Wait.Priority ); +} + +RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_owner( + const Scheduler_Node *node +) +{ + return node->owner; +} + +RTEMS_INLINE_ROUTINE Priority_Control _Scheduler_Node_get_priority( + Scheduler_Node *node +) +{ + Priority_Control priority; + +#if defined(RTEMS_SMP) + unsigned int seq; + + do { + seq = _SMP_sequence_lock_Read_begin( &node->Priority.Lock ); +#endif + + priority = node->Priority.value; + +#if defined(RTEMS_SMP) + } while ( _SMP_sequence_lock_Read_retry( &node->Priority.Lock, seq ) ); +#endif + + return priority; +} + +RTEMS_INLINE_ROUTINE void _Scheduler_Node_set_priority( + Scheduler_Node *node, + Priority_Control new_priority, + bool prepend_it +) +{ +#if defined(RTEMS_SMP) + unsigned int seq; + + seq = _SMP_sequence_lock_Write_begin( &node->Priority.Lock ); +#endif + + new_priority |= ( prepend_it ? 0 : SCHEDULER_PRIORITY_APPEND_FLAG ); + node->Priority.value = new_priority; + +#if defined(RTEMS_SMP) + _SMP_sequence_lock_Write_end( &node->Priority.Lock, seq ); +#endif +} + +#if defined(RTEMS_SMP) +RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_user( + const Scheduler_Node *node +) +{ + return node->user; +} + +RTEMS_INLINE_ROUTINE void _Scheduler_Node_set_user( + Scheduler_Node *node, + Thread_Control *user +) +{ + node->user = user; +} + +RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_idle( + const Scheduler_Node *node +) +{ + return node->idle; +} +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_SCORE_SCHEDULERNODEIMPL_H */ diff --git a/cpukit/include/rtems/score/schedulerpriority.h b/cpukit/include/rtems/score/schedulerpriority.h new file mode 100644 index 0000000000..f5ae66102d --- /dev/null +++ b/cpukit/include/rtems/score/schedulerpriority.h @@ -0,0 +1,163 @@ +/** + * @file rtems/score/schedulerpriority.h + * + * @brief Thread Manipulation with the Priority-Based Scheduler + * + * This include file contains all the constants and structures associated + * with the manipulation of threads for the priority-based scheduler. + */ + +/* + * Copryight (c) 2010 Gedare Bloom. + * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SCHEDULERPRIORITY_H +#define _RTEMS_SCORE_SCHEDULERPRIORITY_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ScoreSchedulerDPS Deterministic Priority Scheduler + * + * @ingroup ScoreScheduler + */ +/**@{*/ + +/** + * Entry points for the Deterministic Priority Based Scheduler. + */ +#define SCHEDULER_PRIORITY_ENTRY_POINTS \ + { \ + _Scheduler_priority_Initialize, /* initialize entry point */ \ + _Scheduler_priority_Schedule, /* schedule entry point */ \ + _Scheduler_priority_Yield, /* yield entry point */ \ + _Scheduler_priority_Block, /* block entry point */ \ + _Scheduler_priority_Unblock, /* unblock entry point */ \ + _Scheduler_priority_Update_priority, /* update priority entry point */ \ + _Scheduler_default_Map_priority, /* map priority entry point */ \ + _Scheduler_default_Unmap_priority, /* unmap priority entry point */ \ + SCHEDULER_OPERATION_DEFAULT_ASK_FOR_HELP \ + _Scheduler_priority_Node_initialize, /* node initialize entry point */ \ + _Scheduler_default_Node_destroy, /* node destroy entry point */ \ + _Scheduler_default_Release_job, /* new period of task */ \ + _Scheduler_default_Cancel_job, /* cancel period of task */ \ + _Scheduler_default_Tick, /* tick entry point */ \ + _Scheduler_default_Start_idle /* start idle entry point */ \ + SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY \ + } + +typedef struct { + /** + * @brief Basic scheduler context. + */ + Scheduler_Context Base; + + /** + * @brief Bit map to indicate non-empty ready queues. + */ + Priority_bit_map_Control Bit_map; + + /** + * @brief One ready queue per priority level. + */ + Chain_Control Ready[ 0 ]; +} Scheduler_priority_Context; + +/** + * @brief Data for ready queue operations. + */ +typedef struct { + /** + * @brief The thread priority currently used by the scheduler. + */ + unsigned int current_priority; + + /** This field points to the Ready FIFO for this thread's priority. */ + Chain_Control *ready_chain; + + /** This field contains precalculated priority map indices. */ + Priority_bit_map_Information Priority_map; +} Scheduler_priority_Ready_queue; + +/** + * @brief Scheduler node specialization for Deterministic Priority schedulers. + */ +typedef struct { + /** + * @brief Basic scheduler node. + */ + Scheduler_Node Base; + + /** + * @brief The associated ready queue of this node. + */ + Scheduler_priority_Ready_queue Ready_queue; +} Scheduler_priority_Node; + +/** + * @brief Initializes the priority scheduler. + * This routine initializes the priority scheduler. + */ +void _Scheduler_priority_Initialize( const Scheduler_Control *scheduler ); + +void _Scheduler_priority_Block( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +/** + * @brief Sets the heir thread to be the next ready thread. + * + * This kernel routine sets the heir thread to be the next ready thread + * by invoking the_scheduler->ready_queue->operations->first(). + */ +void _Scheduler_priority_Schedule( + const Scheduler_Control *scheduler, + Thread_Control *the_thread +); + +void _Scheduler_priority_Unblock( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +void _Scheduler_priority_Update_priority( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *base_node +); + +void _Scheduler_priority_Node_initialize( + const Scheduler_Control *scheduler, + Scheduler_Node *node, + Thread_Control *the_thread, + Priority_Control priority +); + +void _Scheduler_priority_Yield( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/schedulerpriorityaffinitysmp.h b/cpukit/include/rtems/score/schedulerpriorityaffinitysmp.h new file mode 100644 index 0000000000..d988d5752a --- /dev/null +++ b/cpukit/include/rtems/score/schedulerpriorityaffinitysmp.h @@ -0,0 +1,181 @@ +/** + * @file + * + * @ingroup ScoreSchedulerPriorityAffinitySMP + * + * @brief Deterministic Priority Affinity SMP Scheduler API + */ + +/* + * COPYRIGHT (c) 2014. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SCHEDULERPRIORITYAFFINITYSMP_H +#define _RTEMS_SCORE_SCHEDULERPRIORITYAFFINITYSMP_H + +#include +#include +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup ScoreSchedulerPriorityAffinitySMP Deterministic Priority Affinity SMP Scheduler + * + * @ingroup ScoreSchedulerPrioritySMP + * + * This is an extension of the Deterministic Priority SMP Scheduler. which + * is an implementation of the global fixed priority scheduler (G-FP). + * It adds thread to core affinity support. + * + * @note This is the first iteration of this scheduler. It currently tracks + * the requested affinity to exercise the Scheduler Framework but it + * does not honor that affinity in assigning threads to cores. This + * will be added in a subsequent revision. + * @{ + */ + +/** + * @brief Entry points for the Deterministic Priority Affinity SMP Scheduler. + */ +#define SCHEDULER_PRIORITY_AFFINITY_SMP_ENTRY_POINTS \ + { \ + _Scheduler_priority_SMP_Initialize, \ + _Scheduler_default_Schedule, \ + _Scheduler_priority_SMP_Yield, \ + _Scheduler_priority_affinity_SMP_Block, \ + _Scheduler_priority_affinity_SMP_Unblock, \ + _Scheduler_priority_affinity_SMP_Update_priority, \ + _Scheduler_default_Map_priority, \ + _Scheduler_default_Unmap_priority, \ + _Scheduler_priority_affinity_SMP_Ask_for_help, \ + _Scheduler_priority_affinity_SMP_Reconsider_help_request, \ + _Scheduler_priority_affinity_SMP_Withdraw_node, \ + _Scheduler_priority_affinity_SMP_Add_processor, \ + _Scheduler_priority_affinity_SMP_Remove_processor, \ + _Scheduler_priority_affinity_SMP_Node_initialize, \ + _Scheduler_default_Node_destroy, \ + _Scheduler_default_Release_job, \ + _Scheduler_default_Cancel_job, \ + _Scheduler_default_Tick, \ + _Scheduler_SMP_Start_idle, \ + _Scheduler_priority_affinity_SMP_Set_affinity \ + } + +/** + * @brief Initializes per thread scheduler information + * + * This routine allocates @a thread->scheduler. + * + * @param[in] scheduler points to the scheduler specific information. + * @param[in] node is the node the scheduler is allocating + * management memory for. + * @param[in] the_thread the thread of the node. + * @param[in] priority is the thread priority. + */ +void _Scheduler_priority_affinity_SMP_Node_initialize( + const Scheduler_Control *scheduler, + Scheduler_Node *node, + Thread_Control *the_thread, + Priority_Control priority +); + +void _Scheduler_priority_affinity_SMP_Block( + const Scheduler_Control *scheduler, + Thread_Control *thread, + Scheduler_Node *node +); + +void _Scheduler_priority_affinity_SMP_Unblock( + const Scheduler_Control *scheduler, + Thread_Control *thread, + Scheduler_Node *node +); + +void _Scheduler_priority_affinity_SMP_Update_priority( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +bool _Scheduler_priority_affinity_SMP_Ask_for_help( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +void _Scheduler_priority_affinity_SMP_Reconsider_help_request( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +void _Scheduler_priority_affinity_SMP_Withdraw_node( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node, + Thread_Scheduler_state next_state +); + +void _Scheduler_priority_affinity_SMP_Add_processor( + const Scheduler_Control *scheduler, + Thread_Control *idle +); + +Thread_Control *_Scheduler_priority_affinity_SMP_Remove_processor( + const Scheduler_Control *scheduler, + struct Per_CPU_Control *cpu +); + +/** + * @brief Set affinity for the priority affinity SMP scheduler. + * + * @param[in] scheduler The scheduler of the thread. + * @param[in] thread The associated thread. + * @param[in] affinity The new affinity set. + * + * @retval true if successful + * @retval false if unsuccessful + */ +bool _Scheduler_priority_affinity_SMP_Set_affinity( + const Scheduler_Control *scheduler, + Thread_Control *thread, + Scheduler_Node *node, + const Processor_mask *affinity +); + +/** + * @brief Scheduler node specialization for Deterministic Priority Affinity SMP + * schedulers. + * + * This is a per thread structure. + */ +typedef struct { + /** + * @brief SMP priority scheduler node. + */ + Scheduler_priority_SMP_Node Base; + + /** + * @brief The thread processor affinity set. + */ + Processor_mask Affinity; +} Scheduler_priority_affinity_SMP_Node; + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_SCORE_SCHEDULERPRIORITYAFFINITYSMP_H */ diff --git a/cpukit/include/rtems/score/schedulerpriorityimpl.h b/cpukit/include/rtems/score/schedulerpriorityimpl.h new file mode 100644 index 0000000000..354065fac4 --- /dev/null +++ b/cpukit/include/rtems/score/schedulerpriorityimpl.h @@ -0,0 +1,241 @@ +/** + * @file + * + * @brief Inlined Routines Associated with the Manipulation of the + * Priority-Based Scheduling Structures + * + * This inline file contains all of the inlined routines associated with + * the manipulation of the priority-based scheduling structures. + */ + +/* + * Copyright (C) 2010 Gedare Bloom. + * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SCHEDULERPRIORITYIMPL_H +#define _RTEMS_SCORE_SCHEDULERPRIORITYIMPL_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup ScoreSchedulerDPS + */ +/**@{**/ + +RTEMS_INLINE_ROUTINE Scheduler_priority_Context * + _Scheduler_priority_Get_context( const Scheduler_Control *scheduler ) +{ + return (Scheduler_priority_Context *) _Scheduler_Get_context( scheduler ); +} + +RTEMS_INLINE_ROUTINE Scheduler_priority_Node *_Scheduler_priority_Thread_get_node( + Thread_Control *the_thread +) +{ + return (Scheduler_priority_Node *) _Thread_Scheduler_get_home_node( the_thread ); +} + +RTEMS_INLINE_ROUTINE Scheduler_priority_Node *_Scheduler_priority_Node_downcast( + Scheduler_Node *node +) +{ + return (Scheduler_priority_Node *) node; +} + +/** + * @brief Ready queue initialization. + * + * This routine initializes @a ready_queues for priority-based scheduling. + */ +RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_initialize( + Chain_Control *ready_queues, + Priority_Control maximum_priority +) +{ + size_t index; + + for ( index = 0 ; index <= (size_t) maximum_priority ; ++index ) { + _Chain_Initialize_empty( &ready_queues[ index ] ); + } +} + +/** + * @brief Enqueues a node on the specified ready queue. + * + * The node is placed as the last element of its priority group. + * + * @param[in] node The node to enqueue. + * @param[in] ready_queue The ready queue. + * @param[in] bit_map The priority bit map of the scheduler instance. + */ +RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_enqueue( + Chain_Node *node, + Scheduler_priority_Ready_queue *ready_queue, + Priority_bit_map_Control *bit_map +) +{ + Chain_Control *ready_chain = ready_queue->ready_chain; + + _Chain_Append_unprotected( ready_chain, node ); + _Priority_bit_map_Add( bit_map, &ready_queue->Priority_map ); +} + +/** + * @brief Enqueues a node on the specified ready queue as first. + * + * The node is placed as the first element of its priority group. + * + * @param[in] node The node to enqueue as first. + * @param[in] ready_queue The ready queue. + * @param[in] bit_map The priority bit map of the scheduler instance. + */ +RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_enqueue_first( + Chain_Node *node, + Scheduler_priority_Ready_queue *ready_queue, + Priority_bit_map_Control *bit_map +) +{ + Chain_Control *ready_chain = ready_queue->ready_chain; + + _Chain_Prepend_unprotected( ready_chain, node ); + _Priority_bit_map_Add( bit_map, &ready_queue->Priority_map ); +} + +/** + * @brief Extracts a node from the specified ready queue. + * + * @param[in] node The node to extract. + * @param[in] ready_queue The ready queue. + * @param[in] bit_map The priority bit map of the scheduler instance. + */ +RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_extract( + Chain_Node *node, + Scheduler_priority_Ready_queue *ready_queue, + Priority_bit_map_Control *bit_map +) +{ + Chain_Control *ready_chain = ready_queue->ready_chain; + + if ( _Chain_Has_only_one_node( ready_chain ) ) { + _Chain_Initialize_empty( ready_chain ); + _Chain_Initialize_node( node ); + _Priority_bit_map_Remove( bit_map, &ready_queue->Priority_map ); + } else { + _Chain_Extract_unprotected( node ); + } +} + +RTEMS_INLINE_ROUTINE void _Scheduler_priority_Extract_body( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +) +{ + Scheduler_priority_Context *context; + Scheduler_priority_Node *the_node; + + context = _Scheduler_priority_Get_context( scheduler ); + the_node = _Scheduler_priority_Node_downcast( node ); + + _Scheduler_priority_Ready_queue_extract( + &the_thread->Object.Node, + &the_node->Ready_queue, + &context->Bit_map + ); +} + +/** + * @brief Return a pointer to the first node. + * + * This routines returns a pointer to the first node on @a ready_queues. + * + * @param[in] bit_map The priority bit map of the scheduler instance. + * @param[in] ready_queues The ready queues of the scheduler instance. + * + * @return This method returns the first node. + */ +RTEMS_INLINE_ROUTINE Chain_Node *_Scheduler_priority_Ready_queue_first( + Priority_bit_map_Control *bit_map, + Chain_Control *ready_queues +) +{ + Priority_Control index = _Priority_bit_map_Get_highest( bit_map ); + Chain_Node *first = _Chain_First( &ready_queues[ index ] ); + + _Assert( first != _Chain_Tail( &ready_queues[ index ] ) ); + + return first; +} + +/** + * @brief Scheduling decision logic. + * + * This kernel routine implements scheduling decision logic + * for priority-based scheduling. + */ +RTEMS_INLINE_ROUTINE void _Scheduler_priority_Schedule_body( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + bool force_dispatch +) +{ + Scheduler_priority_Context *context = + _Scheduler_priority_Get_context( scheduler ); + Thread_Control *heir = (Thread_Control *) + _Scheduler_priority_Ready_queue_first( + &context->Bit_map, + &context->Ready[ 0 ] + ); + + ( void ) the_thread; + + _Scheduler_Update_heir( heir, force_dispatch ); +} + +/** + * @brief Updates the specified ready queue data according to the new priority + * value. + * + * @param[in] ready_queue The ready queue. + * @param[in] new_priority The new priority. + * @param[in] bit_map The priority bit map of the scheduler instance. + * @param[in] ready_queues The ready queues of the scheduler instance. + */ +RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_update( + Scheduler_priority_Ready_queue *ready_queue, + unsigned int new_priority, + Priority_bit_map_Control *bit_map, + Chain_Control *ready_queues +) +{ + ready_queue->current_priority = new_priority; + ready_queue->ready_chain = &ready_queues[ new_priority ]; + + _Priority_bit_map_Initialize_information( + bit_map, + &ready_queue->Priority_map, + new_priority + ); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/schedulerprioritysmp.h b/cpukit/include/rtems/score/schedulerprioritysmp.h new file mode 100644 index 0000000000..6671da5b7a --- /dev/null +++ b/cpukit/include/rtems/score/schedulerprioritysmp.h @@ -0,0 +1,171 @@ +/** + * @file + * + * @ingroup ScoreSchedulerPrioritySMP + * + * @brief Deterministic Priority SMP Scheduler API + */ + +/* + * Copyright (c) 2013, 2016 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SCHEDULERPRIORITYSMP_H +#define _RTEMS_SCORE_SCHEDULERPRIORITYSMP_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup ScoreSchedulerPrioritySMP Deterministic Priority SMP Scheduler + * + * @ingroup ScoreSchedulerSMP + * + * This is an implementation of the global fixed priority scheduler (G-FP). It + * uses one ready chain per priority to ensure constant time insert operations. + * The scheduled chain uses linear insert operations and has at most processor + * count entries. Since the processor and priority count are constants all + * scheduler operations complete in a bounded execution time. + * + * The thread preempt mode will be ignored. + * + * @{ + */ + +/** + * @brief Scheduler context specialization for Deterministic Priority SMP + * schedulers. + */ +typedef struct { + Scheduler_SMP_Context Base; + Priority_bit_map_Control Bit_map; + Chain_Control Ready[ RTEMS_ZERO_LENGTH_ARRAY ]; +} Scheduler_priority_SMP_Context; + +/** + * @brief Scheduler node specialization for Deterministic Priority SMP + * schedulers. + */ +typedef struct { + /** + * @brief SMP scheduler node. + */ + Scheduler_SMP_Node Base; + + /** + * @brief The associated ready queue of this node. + */ + Scheduler_priority_Ready_queue Ready_queue; +} Scheduler_priority_SMP_Node; + +/** + * @brief Entry points for the Priority SMP Scheduler. + */ +#define SCHEDULER_PRIORITY_SMP_ENTRY_POINTS \ + { \ + _Scheduler_priority_SMP_Initialize, \ + _Scheduler_default_Schedule, \ + _Scheduler_priority_SMP_Yield, \ + _Scheduler_priority_SMP_Block, \ + _Scheduler_priority_SMP_Unblock, \ + _Scheduler_priority_SMP_Update_priority, \ + _Scheduler_default_Map_priority, \ + _Scheduler_default_Unmap_priority, \ + _Scheduler_priority_SMP_Ask_for_help, \ + _Scheduler_priority_SMP_Reconsider_help_request, \ + _Scheduler_priority_SMP_Withdraw_node, \ + _Scheduler_priority_SMP_Add_processor, \ + _Scheduler_priority_SMP_Remove_processor, \ + _Scheduler_priority_SMP_Node_initialize, \ + _Scheduler_default_Node_destroy, \ + _Scheduler_default_Release_job, \ + _Scheduler_default_Cancel_job, \ + _Scheduler_default_Tick, \ + _Scheduler_SMP_Start_idle \ + SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY \ + } + +void _Scheduler_priority_SMP_Initialize( const Scheduler_Control *scheduler ); + +void _Scheduler_priority_SMP_Node_initialize( + const Scheduler_Control *scheduler, + Scheduler_Node *node, + Thread_Control *the_thread, + Priority_Control priority +); + +void _Scheduler_priority_SMP_Block( + const Scheduler_Control *scheduler, + Thread_Control *thread, + Scheduler_Node *node +); + +void _Scheduler_priority_SMP_Unblock( + const Scheduler_Control *scheduler, + Thread_Control *thread, + Scheduler_Node *node +); + +void _Scheduler_priority_SMP_Update_priority( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +bool _Scheduler_priority_SMP_Ask_for_help( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +void _Scheduler_priority_SMP_Reconsider_help_request( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +void _Scheduler_priority_SMP_Withdraw_node( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node, + Thread_Scheduler_state next_state +); + +void _Scheduler_priority_SMP_Add_processor( + const Scheduler_Control *scheduler, + Thread_Control *idle +); + +Thread_Control *_Scheduler_priority_SMP_Remove_processor( + const Scheduler_Control *scheduler, + struct Per_CPU_Control *cpu +); + +void _Scheduler_priority_SMP_Yield( + const Scheduler_Control *scheduler, + Thread_Control *thread, + Scheduler_Node *node +); + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_SCORE_SCHEDULERPRIORITYSMP_H */ diff --git a/cpukit/include/rtems/score/schedulerprioritysmpimpl.h b/cpukit/include/rtems/score/schedulerprioritysmpimpl.h new file mode 100644 index 0000000000..17d6e552f3 --- /dev/null +++ b/cpukit/include/rtems/score/schedulerprioritysmpimpl.h @@ -0,0 +1,184 @@ +/** + * @file + * + * @ingroup ScoreSchedulerPrioritySMP + * + * @brief Deterministic Priority SMP Scheduler API + */ + +/* + * Copyright (c) 2013, 2017 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SCHEDULERPRIORITYSMPIMPL_H +#define _RTEMS_SCORE_SCHEDULERPRIORITYSMPIMPL_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @ingroup ScoreSchedulerPrioritySMP + * @{ + */ + +static inline Scheduler_priority_SMP_Context *_Scheduler_priority_SMP_Get_self( + Scheduler_Context *context +) +{ + return (Scheduler_priority_SMP_Context *) context; +} + +static inline Scheduler_priority_SMP_Node *_Scheduler_priority_SMP_Thread_get_node( + Thread_Control *thread +) +{ + return (Scheduler_priority_SMP_Node *) _Thread_Scheduler_get_home_node( thread ); +} + +static inline Scheduler_priority_SMP_Node * +_Scheduler_priority_SMP_Node_downcast( Scheduler_Node *node ) +{ + return (Scheduler_priority_SMP_Node *) node; +} + +static inline bool _Scheduler_priority_SMP_Has_ready( Scheduler_Context *context ) +{ + Scheduler_priority_SMP_Context *self = + _Scheduler_priority_SMP_Get_self( context ); + + return !_Priority_bit_map_Is_empty( &self->Bit_map ); +} + +static inline void _Scheduler_priority_SMP_Move_from_scheduled_to_ready( + Scheduler_Context *context, + Scheduler_Node *scheduled_to_ready +) +{ + Scheduler_priority_SMP_Context *self = + _Scheduler_priority_SMP_Get_self( context ); + Scheduler_priority_SMP_Node *node = + _Scheduler_priority_SMP_Node_downcast( scheduled_to_ready ); + + _Chain_Extract_unprotected( &node->Base.Base.Node.Chain ); + _Scheduler_priority_Ready_queue_enqueue_first( + &node->Base.Base.Node.Chain, + &node->Ready_queue, + &self->Bit_map + ); +} + +static inline void _Scheduler_priority_SMP_Move_from_ready_to_scheduled( + Scheduler_Context *context, + Scheduler_Node *ready_to_scheduled +) +{ + Scheduler_priority_SMP_Context *self; + Scheduler_priority_SMP_Node *node; + Priority_Control insert_priority; + + self = _Scheduler_priority_SMP_Get_self( context ); + node = _Scheduler_priority_SMP_Node_downcast( ready_to_scheduled ); + + _Scheduler_priority_Ready_queue_extract( + &node->Base.Base.Node.Chain, + &node->Ready_queue, + &self->Bit_map + ); + insert_priority = _Scheduler_SMP_Node_priority( &node->Base.Base ); + insert_priority = SCHEDULER_PRIORITY_APPEND( insert_priority ); + _Chain_Insert_ordered_unprotected( + &self->Base.Scheduled, + &node->Base.Base.Node.Chain, + &insert_priority, + _Scheduler_SMP_Priority_less_equal + ); +} + +static inline void _Scheduler_priority_SMP_Insert_ready( + Scheduler_Context *context, + Scheduler_Node *node_base, + Priority_Control insert_priority +) +{ + Scheduler_priority_SMP_Context *self; + Scheduler_priority_SMP_Node *node; + + self = _Scheduler_priority_SMP_Get_self( context ); + node = _Scheduler_priority_SMP_Node_downcast( node_base ); + + if ( SCHEDULER_PRIORITY_IS_APPEND( insert_priority ) ) { + _Scheduler_priority_Ready_queue_enqueue( + &node->Base.Base.Node.Chain, + &node->Ready_queue, + &self->Bit_map + ); + } else { + _Scheduler_priority_Ready_queue_enqueue_first( + &node->Base.Base.Node.Chain, + &node->Ready_queue, + &self->Bit_map + ); + } +} + +static inline void _Scheduler_priority_SMP_Extract_from_ready( + Scheduler_Context *context, + Scheduler_Node *thread +) +{ + Scheduler_priority_SMP_Context *self = + _Scheduler_priority_SMP_Get_self( context ); + Scheduler_priority_SMP_Node *node = + _Scheduler_priority_SMP_Node_downcast( thread ); + + _Scheduler_priority_Ready_queue_extract( + &node->Base.Base.Node.Chain, + &node->Ready_queue, + &self->Bit_map + ); +} + +static inline void _Scheduler_priority_SMP_Do_update( + Scheduler_Context *context, + Scheduler_Node *node_to_update, + Priority_Control new_priority +) +{ + Scheduler_priority_SMP_Context *self; + Scheduler_priority_SMP_Node *node; + + self = _Scheduler_priority_SMP_Get_self( context ); + node = _Scheduler_priority_SMP_Node_downcast( node_to_update ); + + _Scheduler_SMP_Node_update_priority( &node->Base, new_priority ); + _Scheduler_priority_Ready_queue_update( + &node->Ready_queue, + SCHEDULER_PRIORITY_UNMAP( new_priority ), + &self->Bit_map, + &self->Ready[ 0 ] + ); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_SCORE_SCHEDULERPRIORITYSMPIMPL_H */ diff --git a/cpukit/include/rtems/score/schedulersimple.h b/cpukit/include/rtems/score/schedulersimple.h new file mode 100644 index 0000000000..0d410d5676 --- /dev/null +++ b/cpukit/include/rtems/score/schedulersimple.h @@ -0,0 +1,126 @@ +/** + * @file rtems/score/schedulersimple.h + * + * @brief Manipulation of Threads Simple-Priority-Based Ready Queue + * + * This include file contains all the constants and structures associated + * with the manipulation of threads on a simple-priority-based ready queue. + */ + +/* + * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SCHEDULERSIMPLE_H +#define _RTEMS_SCORE_SCHEDULERSIMPLE_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ScoreSchedulerSimple Simple Priority Scheduler + * + * @ingroup ScoreScheduler + */ +/**@{*/ + +#define SCHEDULER_SIMPLE_MAXIMUM_PRIORITY 255 + +/** + * Entry points for Scheduler Simple + */ +#define SCHEDULER_SIMPLE_ENTRY_POINTS \ + { \ + _Scheduler_simple_Initialize, /* initialize entry point */ \ + _Scheduler_simple_Schedule, /* schedule entry point */ \ + _Scheduler_simple_Yield, /* yield entry point */ \ + _Scheduler_simple_Block, /* block entry point */ \ + _Scheduler_simple_Unblock, /* unblock entry point */ \ + _Scheduler_simple_Update_priority, /* update priority entry point */ \ + _Scheduler_default_Map_priority, /* map priority entry point */ \ + _Scheduler_default_Unmap_priority, /* unmap priority entry point */ \ + SCHEDULER_OPERATION_DEFAULT_ASK_FOR_HELP \ + _Scheduler_default_Node_initialize, /* node initialize entry point */ \ + _Scheduler_default_Node_destroy, /* node destroy entry point */ \ + _Scheduler_default_Release_job, /* new period of task */ \ + _Scheduler_default_Cancel_job, /* cancel period of task */ \ + _Scheduler_default_Tick, /* tick entry point */ \ + _Scheduler_default_Start_idle /* start idle entry point */ \ + SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY \ + } + +/** + * @brief Simple scheduler context. + */ +typedef struct { + /** + * @brief Basic scheduler context. + */ + Scheduler_Context Base; + + /** + * @brief One ready queue for all ready threads. + */ + Chain_Control Ready; +} Scheduler_simple_Context; + +/** + * @brief Initialize simple scheduler. + * + * This routine initializes the simple scheduler. + */ +void _Scheduler_simple_Initialize( const Scheduler_Control *scheduler ); + +/** + * This routine sets the heir thread to be the next ready thread + * on the ready queue by getting the first node in the scheduler + * information. + * + * @param[in] scheduler The scheduler instance. + * @param[in] the_thread causing the scheduling operation. + */ +void _Scheduler_simple_Schedule( + const Scheduler_Control *scheduler, + Thread_Control *the_thread +); + +void _Scheduler_simple_Yield( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +void _Scheduler_simple_Block( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +void _Scheduler_simple_Unblock( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +void _Scheduler_simple_Update_priority( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/schedulersimpleimpl.h b/cpukit/include/rtems/score/schedulersimpleimpl.h new file mode 100644 index 0000000000..3891839281 --- /dev/null +++ b/cpukit/include/rtems/score/schedulersimpleimpl.h @@ -0,0 +1,103 @@ +/** + * @file + * + * @brief Inlined Routines Associated with the Manipulation of the + * Priority-Based Scheduling Structures + * + * This inline file contains all of the inlined routines associated with + * the manipulation of the priority-based scheduling structures. + */ + +/* + * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SCHEDULERSIMPLEIMPL_H +#define _RTEMS_SCORE_SCHEDULERSIMPLEIMPL_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup ScoreSchedulerSimple + */ +/**@{**/ + +RTEMS_INLINE_ROUTINE Scheduler_simple_Context * + _Scheduler_simple_Get_context( const Scheduler_Control *scheduler ) +{ + return (Scheduler_simple_Context *) _Scheduler_Get_context( scheduler ); +} + +RTEMS_INLINE_ROUTINE bool _Scheduler_simple_Priority_less_equal( + const void *to_insert, + const Chain_Node *next +) +{ + const unsigned int *priority_to_insert; + const Thread_Control *thread_next; + + priority_to_insert = (const unsigned int *) to_insert; + thread_next = (const Thread_Control *) next; + + return *priority_to_insert <= _Thread_Get_priority( thread_next ); +} + +RTEMS_INLINE_ROUTINE void _Scheduler_simple_Insert( + Chain_Control *chain, + Thread_Control *to_insert, + unsigned int insert_priority +) +{ + _Chain_Insert_ordered_unprotected( + chain, + &to_insert->Object.Node, + &insert_priority, + _Scheduler_simple_Priority_less_equal + ); +} + +RTEMS_INLINE_ROUTINE void _Scheduler_simple_Extract( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +) +{ + (void) scheduler; + (void) node; + + _Chain_Extract_unprotected( &the_thread->Object.Node ); +} + +RTEMS_INLINE_ROUTINE void _Scheduler_simple_Schedule_body( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + bool force_dispatch +) +{ + Scheduler_simple_Context *context = + _Scheduler_simple_Get_context( scheduler ); + Thread_Control *heir = (Thread_Control *) _Chain_First( &context->Ready ); + + ( void ) the_thread; + + _Scheduler_Update_heir( heir, force_dispatch ); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/schedulersimplesmp.h b/cpukit/include/rtems/score/schedulersimplesmp.h new file mode 100644 index 0000000000..bc75b205d5 --- /dev/null +++ b/cpukit/include/rtems/score/schedulersimplesmp.h @@ -0,0 +1,155 @@ +/** + * @file + * + * @brief Simple SMP Scheduler API + * + * @ingroup ScoreSchedulerSMPSimple + */ + +/* + * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). + * + * Copyright (c) 2013, 2016 embedded brains GmbH. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SCHEDULERSIMPLE_SMP_H +#define _RTEMS_SCORE_SCHEDULERSIMPLE_SMP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +/** + * @defgroup ScoreSchedulerSMPSimple Simple Priority SMP Scheduler + * + * @ingroup ScoreSchedulerSMP + * + * The Simple Priority SMP Scheduler allocates a processor for the processor + * count highest priority ready threads. The thread priority and position in + * the ready chain are the only information to determine the scheduling + * decision. Threads with an allocated processor are in the scheduled chain. + * After initialization the scheduled chain has exactly processor count nodes. + * Each processor has exactly one allocated thread after initialization. All + * enqueue and extract operations may exchange threads with the scheduled + * chain. One thread will be added and another will be removed. The scheduled + * and ready chain is ordered according to the thread priority order. The + * chain insert operations are O(count of ready threads), thus this scheduler + * is unsuitable for most real-time applications. + * + * The thread preempt mode will be ignored. + * + * @{ + */ + +typedef struct { + Scheduler_SMP_Context Base; + Chain_Control Ready; +} Scheduler_simple_SMP_Context; + +#define SCHEDULER_SIMPLE_SMP_MAXIMUM_PRIORITY 255 + +/** + * @brief Entry points for the Simple SMP Scheduler. + */ +#define SCHEDULER_SIMPLE_SMP_ENTRY_POINTS \ + { \ + _Scheduler_simple_SMP_Initialize, \ + _Scheduler_default_Schedule, \ + _Scheduler_simple_SMP_Yield, \ + _Scheduler_simple_SMP_Block, \ + _Scheduler_simple_SMP_Unblock, \ + _Scheduler_simple_SMP_Update_priority, \ + _Scheduler_default_Map_priority, \ + _Scheduler_default_Unmap_priority, \ + _Scheduler_simple_SMP_Ask_for_help, \ + _Scheduler_simple_SMP_Reconsider_help_request, \ + _Scheduler_simple_SMP_Withdraw_node, \ + _Scheduler_simple_SMP_Add_processor, \ + _Scheduler_simple_SMP_Remove_processor, \ + _Scheduler_simple_SMP_Node_initialize, \ + _Scheduler_default_Node_destroy, \ + _Scheduler_default_Release_job, \ + _Scheduler_default_Cancel_job, \ + _Scheduler_default_Tick, \ + _Scheduler_SMP_Start_idle \ + SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY \ + } + +void _Scheduler_simple_SMP_Initialize( const Scheduler_Control *scheduler ); + +void _Scheduler_simple_SMP_Node_initialize( + const Scheduler_Control *scheduler, + Scheduler_Node *node, + Thread_Control *the_thread, + Priority_Control priority +); + +void _Scheduler_simple_SMP_Block( + const Scheduler_Control *scheduler, + Thread_Control *thread, + Scheduler_Node *node +); + +void _Scheduler_simple_SMP_Unblock( + const Scheduler_Control *scheduler, + Thread_Control *thread, + Scheduler_Node *node +); + +void _Scheduler_simple_SMP_Update_priority( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +bool _Scheduler_simple_SMP_Ask_for_help( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +void _Scheduler_simple_SMP_Reconsider_help_request( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +void _Scheduler_simple_SMP_Withdraw_node( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node, + Thread_Scheduler_state next_state +); + +void _Scheduler_simple_SMP_Add_processor( + const Scheduler_Control *scheduler, + Thread_Control *idle +); + +Thread_Control *_Scheduler_simple_SMP_Remove_processor( + const Scheduler_Control *scheduler, + struct Per_CPU_Control *cpu +); + +void _Scheduler_simple_SMP_Yield( + const Scheduler_Control *scheduler, + Thread_Control *thread, + Scheduler_Node *node +); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/schedulersmp.h b/cpukit/include/rtems/score/schedulersmp.h new file mode 100644 index 0000000000..0bd899a6a6 --- /dev/null +++ b/cpukit/include/rtems/score/schedulersmp.h @@ -0,0 +1,127 @@ +/** + * @file + * + * @brief SMP Scheduler API + * + * @ingroup ScoreSchedulerSMP + */ + +/* + * Copyright (c) 2013-2014 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SCHEDULERSMP_H +#define _RTEMS_SCORE_SCHEDULERSMP_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup ScoreSchedulerSMP SMP Scheduler + * + * @ingroup ScoreScheduler + * + * @{ + */ + +/** + * @brief Scheduler context specialization for SMP schedulers. + */ +typedef struct { + /** + * @brief Basic scheduler context. + */ + Scheduler_Context Base; + + /** + * @brief The chain of scheduled nodes. + */ + Chain_Control Scheduled; + + /** + * @brief Chain of the available idle threads. + * + * Idle threads are used for the scheduler helping protocol. It is crucial + * that the idle threads preserve their relative order. This is the case for + * this priority based scheduler. + */ + Chain_Control Idle_threads; +} Scheduler_SMP_Context; + +/** + * @brief SMP scheduler node states. + */ +typedef enum { + /** + * @brief This scheduler node is blocked. + * + * A scheduler node is blocked if the corresponding thread is not ready. + */ + SCHEDULER_SMP_NODE_BLOCKED, + + /** + * @brief The scheduler node is scheduled. + * + * A scheduler node is scheduled if the corresponding thread is ready and the + * scheduler allocated a processor for it. A scheduled node is assigned to + * exactly one processor. The count of scheduled nodes in this scheduler + * instance equals the processor count owned by the scheduler instance. + */ + SCHEDULER_SMP_NODE_SCHEDULED, + + /** + * @brief This scheduler node is ready. + * + * A scheduler node is ready if the corresponding thread is ready and the + * scheduler did not allocate a processor for it. + */ + SCHEDULER_SMP_NODE_READY +} Scheduler_SMP_Node_state; + +/** + * @brief Scheduler node specialization for SMP schedulers. + */ +typedef struct { + /** + * @brief Basic scheduler node. + */ + Scheduler_Node Base; + + /** + * @brief The state of this node. + */ + Scheduler_SMP_Node_state state; + + /** + * @brief The current priority of thread owning this node. + */ + Priority_Control priority; +} Scheduler_SMP_Node; + +void _Scheduler_SMP_Start_idle( + const Scheduler_Control *scheduler, + Thread_Control *idle, + struct Per_CPU_Control *cpu +); + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_SCORE_SCHEDULERSMP_H */ diff --git a/cpukit/include/rtems/score/schedulersmpimpl.h b/cpukit/include/rtems/score/schedulersmpimpl.h new file mode 100644 index 0000000000..e152eb0878 --- /dev/null +++ b/cpukit/include/rtems/score/schedulersmpimpl.h @@ -0,0 +1,1482 @@ +/** + * @file + * + * @brief SMP Scheduler Implementation + * + * @ingroup ScoreSchedulerSMP + */ + +/* + * Copyright (c) 2013, 2017 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SCHEDULERSMPIMPL_H +#define _RTEMS_SCORE_SCHEDULERSMPIMPL_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @addtogroup ScoreSchedulerSMP + * + * The scheduler nodes can be in four states + * - @ref SCHEDULER_SMP_NODE_BLOCKED, + * - @ref SCHEDULER_SMP_NODE_SCHEDULED, and + * - @ref SCHEDULER_SMP_NODE_READY. + * + * State transitions are triggered via basic operations + * - _Scheduler_SMP_Enqueue(), + * - _Scheduler_SMP_Enqueue_scheduled(), and + * - _Scheduler_SMP_Block(). + * + * @dot + * digraph { + * node [style="filled"]; + * + * bs [label="BLOCKED"]; + * ss [label="SCHEDULED", fillcolor="green"]; + * rs [label="READY", fillcolor="red"]; + * + * edge [label="enqueue"]; + * edge [fontcolor="darkgreen", color="darkgreen"]; + * + * bs -> ss; + * + * edge [fontcolor="red", color="red"]; + * + * bs -> rs; + * + * edge [label="enqueue other"]; + * + * ss -> rs; + * + * edge [label="block"]; + * edge [fontcolor="black", color="black"]; + * + * ss -> bs; + * rs -> bs; + * + * edge [label="block other"]; + * edge [fontcolor="darkgreen", color="darkgreen"]; + * + * rs -> ss; + * } + * @enddot + * + * During system initialization each processor of the scheduler instance starts + * with an idle thread assigned to it. Lets have a look at an example with two + * idle threads I and J with priority 5. We also have blocked threads A, B and + * C with priorities 1, 2 and 3 respectively. The scheduler nodes are ordered + * with respect to the thread priority from left to right in the below + * diagrams. The highest priority node (lowest priority number) is the + * leftmost node. Since the processor assignment is independent of the thread + * priority the processor indices may move from one state to the other. + * + * @dot + * digraph { + * node [style="filled"]; + * edge [dir="none"]; + * subgraph { + * rank = same; + * + * i [label="I (5)", fillcolor="green"]; + * j [label="J (5)", fillcolor="green"]; + * a [label="A (1)"]; + * b [label="B (2)"]; + * c [label="C (3)"]; + * i -> j; + * } + * + * subgraph { + * rank = same; + * + * p0 [label="PROCESSOR 0", shape="box"]; + * p1 [label="PROCESSOR 1", shape="box"]; + * } + * + * i -> p0; + * j -> p1; + * } + * @enddot + * + * Lets start A. For this an enqueue operation is performed. + * + * @dot + * digraph { + * node [style="filled"]; + * edge [dir="none"]; + * + * subgraph { + * rank = same; + * + * i [label="I (5)", fillcolor="green"]; + * j [label="J (5)", fillcolor="red"]; + * a [label="A (1)", fillcolor="green"]; + * b [label="B (2)"]; + * c [label="C (3)"]; + * a -> i; + * } + * + * subgraph { + * rank = same; + * + * p0 [label="PROCESSOR 0", shape="box"]; + * p1 [label="PROCESSOR 1", shape="box"]; + * } + * + * i -> p0; + * a -> p1; + * } + * @enddot + * + * Lets start C. + * + * @dot + * digraph { + * node [style="filled"]; + * edge [dir="none"]; + * + * subgraph { + * rank = same; + * + * a [label="A (1)", fillcolor="green"]; + * c [label="C (3)", fillcolor="green"]; + * i [label="I (5)", fillcolor="red"]; + * j [label="J (5)", fillcolor="red"]; + * b [label="B (2)"]; + * a -> c; + * i -> j; + * } + * + * subgraph { + * rank = same; + * + * p0 [label="PROCESSOR 0", shape="box"]; + * p1 [label="PROCESSOR 1", shape="box"]; + * } + * + * c -> p0; + * a -> p1; + * } + * @enddot + * + * Lets start B. + * + * @dot + * digraph { + * node [style="filled"]; + * edge [dir="none"]; + * + * subgraph { + * rank = same; + * + * a [label="A (1)", fillcolor="green"]; + * b [label="B (2)", fillcolor="green"]; + * c [label="C (3)", fillcolor="red"]; + * i [label="I (5)", fillcolor="red"]; + * j [label="J (5)", fillcolor="red"]; + * a -> b; + * c -> i -> j; + * } + * + * subgraph { + * rank = same; + * + * p0 [label="PROCESSOR 0", shape="box"]; + * p1 [label="PROCESSOR 1", shape="box"]; + * } + * + * b -> p0; + * a -> p1; + * } + * @enddot + * + * Lets change the priority of thread A to 4. + * + * @dot + * digraph { + * node [style="filled"]; + * edge [dir="none"]; + * + * subgraph { + * rank = same; + * + * b [label="B (2)", fillcolor="green"]; + * c [label="C (3)", fillcolor="green"]; + * a [label="A (4)", fillcolor="red"]; + * i [label="I (5)", fillcolor="red"]; + * j [label="J (5)", fillcolor="red"]; + * b -> c; + * a -> i -> j; + * } + * + * subgraph { + * rank = same; + * + * p0 [label="PROCESSOR 0", shape="box"]; + * p1 [label="PROCESSOR 1", shape="box"]; + * } + * + * b -> p0; + * c -> p1; + * } + * @enddot + * + * Now perform a blocking operation with thread B. Please note that thread A + * migrated now from processor 0 to processor 1 and thread C still executes on + * processor 1. + * + * @dot + * digraph { + * node [style="filled"]; + * edge [dir="none"]; + * + * subgraph { + * rank = same; + * + * c [label="C (3)", fillcolor="green"]; + * a [label="A (4)", fillcolor="green"]; + * i [label="I (5)", fillcolor="red"]; + * j [label="J (5)", fillcolor="red"]; + * b [label="B (2)"]; + * c -> a; + * i -> j; + * } + * + * subgraph { + * rank = same; + * + * p0 [label="PROCESSOR 0", shape="box"]; + * p1 [label="PROCESSOR 1", shape="box"]; + * } + * + * a -> p0; + * c -> p1; + * } + * @enddot + * + * @{ + */ + +typedef bool ( *Scheduler_SMP_Has_ready )( + Scheduler_Context *context +); + +typedef Scheduler_Node *( *Scheduler_SMP_Get_highest_ready )( + Scheduler_Context *context, + Scheduler_Node *node +); + +typedef Scheduler_Node *( *Scheduler_SMP_Get_lowest_scheduled )( + Scheduler_Context *context, + Scheduler_Node *filter +); + +typedef void ( *Scheduler_SMP_Extract )( + Scheduler_Context *context, + Scheduler_Node *node_to_extract +); + +typedef void ( *Scheduler_SMP_Insert )( + Scheduler_Context *context, + Scheduler_Node *node_to_insert, + Priority_Control insert_priority +); + +typedef void ( *Scheduler_SMP_Move )( + Scheduler_Context *context, + Scheduler_Node *node_to_move +); + +typedef bool ( *Scheduler_SMP_Ask_for_help )( + Scheduler_Context *context, + Thread_Control *thread, + Scheduler_Node *node +); + +typedef void ( *Scheduler_SMP_Update )( + Scheduler_Context *context, + Scheduler_Node *node_to_update, + Priority_Control new_priority +); + +typedef void ( *Scheduler_SMP_Set_affinity )( + Scheduler_Context *context, + Scheduler_Node *node, + void *arg +); + +typedef bool ( *Scheduler_SMP_Enqueue )( + Scheduler_Context *context, + Scheduler_Node *node_to_enqueue, + Priority_Control priority +); + +typedef void ( *Scheduler_SMP_Allocate_processor )( + Scheduler_Context *context, + Scheduler_Node *scheduled, + Scheduler_Node *victim, + Per_CPU_Control *victim_cpu +); + +typedef void ( *Scheduler_SMP_Register_idle )( + Scheduler_Context *context, + Scheduler_Node *idle, + Per_CPU_Control *cpu +); + +static inline void _Scheduler_SMP_Do_nothing_register_idle( + Scheduler_Context *context, + Scheduler_Node *idle, + Per_CPU_Control *cpu +) +{ + (void) context; + (void) idle; + (void) cpu; +} + +static inline bool _Scheduler_SMP_Priority_less_equal( + const void *to_insert, + const Chain_Node *next +) +{ + const Priority_Control *priority_to_insert; + const Scheduler_SMP_Node *node_next; + + priority_to_insert = (const Priority_Control *) to_insert; + node_next = (const Scheduler_SMP_Node *) next; + + return *priority_to_insert <= node_next->priority; +} + +static inline Scheduler_SMP_Context *_Scheduler_SMP_Get_self( + Scheduler_Context *context +) +{ + return (Scheduler_SMP_Context *) context; +} + +static inline void _Scheduler_SMP_Initialize( + Scheduler_SMP_Context *self +) +{ + _Chain_Initialize_empty( &self->Scheduled ); + _Chain_Initialize_empty( &self->Idle_threads ); +} + +static inline Scheduler_SMP_Node *_Scheduler_SMP_Thread_get_node( + Thread_Control *thread +) +{ + return (Scheduler_SMP_Node *) _Thread_Scheduler_get_home_node( thread ); +} + +static inline Scheduler_SMP_Node *_Scheduler_SMP_Thread_get_own_node( + Thread_Control *thread +) +{ + return (Scheduler_SMP_Node *) _Thread_Scheduler_get_home_node( thread ); +} + +static inline Scheduler_SMP_Node *_Scheduler_SMP_Node_downcast( + Scheduler_Node *node +) +{ + return (Scheduler_SMP_Node *) node; +} + +static inline Scheduler_SMP_Node_state _Scheduler_SMP_Node_state( + const Scheduler_Node *node +) +{ + return ( (const Scheduler_SMP_Node *) node )->state; +} + +static inline Priority_Control _Scheduler_SMP_Node_priority( + const Scheduler_Node *node +) +{ + return ( (const Scheduler_SMP_Node *) node )->priority; +} + +static inline void _Scheduler_SMP_Node_initialize( + const Scheduler_Control *scheduler, + Scheduler_SMP_Node *node, + Thread_Control *thread, + Priority_Control priority +) +{ + _Scheduler_Node_do_initialize( scheduler, &node->Base, thread, priority ); + node->state = SCHEDULER_SMP_NODE_BLOCKED; + node->priority = priority; +} + +static inline void _Scheduler_SMP_Node_update_priority( + Scheduler_SMP_Node *node, + Priority_Control new_priority +) +{ + node->priority = new_priority; +} + +static inline void _Scheduler_SMP_Node_change_state( + Scheduler_Node *node, + Scheduler_SMP_Node_state new_state +) +{ + Scheduler_SMP_Node *the_node; + + the_node = _Scheduler_SMP_Node_downcast( node ); + the_node->state = new_state; +} + +static inline bool _Scheduler_SMP_Is_processor_owned_by_us( + const Scheduler_Context *context, + const Per_CPU_Control *cpu +) +{ + return cpu->Scheduler.context == context; +} + +static inline Thread_Control *_Scheduler_SMP_Get_idle_thread( + Scheduler_Context *context +) +{ + Scheduler_SMP_Context *self = _Scheduler_SMP_Get_self( context ); + Thread_Control *idle = (Thread_Control *) + _Chain_Get_first_unprotected( &self->Idle_threads ); + + _Assert( &idle->Object.Node != _Chain_Tail( &self->Idle_threads ) ); + + return idle; +} + +static inline void _Scheduler_SMP_Release_idle_thread( + Scheduler_Context *context, + Thread_Control *idle +) +{ + Scheduler_SMP_Context *self = _Scheduler_SMP_Get_self( context ); + + _Chain_Prepend_unprotected( &self->Idle_threads, &idle->Object.Node ); +} + +static inline void _Scheduler_SMP_Exctract_idle_thread( + Thread_Control *idle +) +{ + _Chain_Extract_unprotected( &idle->Object.Node ); +} + +static inline void _Scheduler_SMP_Allocate_processor_lazy( + Scheduler_Context *context, + Scheduler_Node *scheduled, + Scheduler_Node *victim, + Per_CPU_Control *victim_cpu +) +{ + Thread_Control *scheduled_thread = _Scheduler_Node_get_user( scheduled ); + Thread_Control *victim_thread = _Scheduler_Node_get_user( victim ); + Per_CPU_Control *scheduled_cpu = _Thread_Get_CPU( scheduled_thread ); + Per_CPU_Control *cpu_self = _Per_CPU_Get(); + Thread_Control *heir; + + _Assert( _ISR_Get_level() != 0 ); + + if ( _Thread_Is_executing_on_a_processor( scheduled_thread ) ) { + if ( _Scheduler_SMP_Is_processor_owned_by_us( context, scheduled_cpu ) ) { + heir = scheduled_cpu->heir; + _Thread_Dispatch_update_heir( + cpu_self, + scheduled_cpu, + scheduled_thread + ); + } else { + /* We have to force a migration to our processor set */ + heir = scheduled_thread; + } + } else { + heir = scheduled_thread; + } + + if ( heir != victim_thread ) { + _Thread_Set_CPU( heir, victim_cpu ); + _Thread_Dispatch_update_heir( cpu_self, victim_cpu, heir ); + } +} + +/* + * This method is slightly different from + * _Scheduler_SMP_Allocate_processor_lazy() in that it does what it is asked to + * do. _Scheduler_SMP_Allocate_processor_lazy() attempts to prevent migrations + * but does not take into account affinity. + */ +static inline void _Scheduler_SMP_Allocate_processor_exact( + Scheduler_Context *context, + Scheduler_Node *scheduled, + Scheduler_Node *victim, + Per_CPU_Control *victim_cpu +) +{ + Thread_Control *scheduled_thread = _Scheduler_Node_get_user( scheduled ); + Per_CPU_Control *cpu_self = _Per_CPU_Get(); + + (void) context; + (void) victim; + + _Thread_Set_CPU( scheduled_thread, victim_cpu ); + _Thread_Dispatch_update_heir( cpu_self, victim_cpu, scheduled_thread ); +} + +static inline void _Scheduler_SMP_Allocate_processor( + Scheduler_Context *context, + Scheduler_Node *scheduled, + Scheduler_Node *victim, + Per_CPU_Control *victim_cpu, + Scheduler_SMP_Allocate_processor allocate_processor +) +{ + _Scheduler_SMP_Node_change_state( scheduled, SCHEDULER_SMP_NODE_SCHEDULED ); + ( *allocate_processor )( context, scheduled, victim, victim_cpu ); +} + +static inline Thread_Control *_Scheduler_SMP_Preempt( + Scheduler_Context *context, + Scheduler_Node *scheduled, + Scheduler_Node *victim, + Scheduler_SMP_Allocate_processor allocate_processor +) +{ + Thread_Control *victim_thread; + ISR_lock_Context lock_context; + Per_CPU_Control *victim_cpu; + + victim_thread = _Scheduler_Node_get_user( victim ); + _Scheduler_SMP_Node_change_state( victim, SCHEDULER_SMP_NODE_READY ); + + _Thread_Scheduler_acquire_critical( victim_thread, &lock_context ); + + victim_cpu = _Thread_Get_CPU( victim_thread ); + + if ( victim_thread->Scheduler.state == THREAD_SCHEDULER_SCHEDULED ) { + _Scheduler_Thread_change_state( victim_thread, THREAD_SCHEDULER_READY ); + + if ( victim_thread->Scheduler.helping_nodes > 0 ) { + _Per_CPU_Acquire( victim_cpu ); + _Chain_Append_unprotected( + &victim_cpu->Threads_in_need_for_help, + &victim_thread->Scheduler.Help_node + ); + _Per_CPU_Release( victim_cpu ); + } + } + + _Thread_Scheduler_release_critical( victim_thread, &lock_context ); + + _Scheduler_SMP_Allocate_processor( + context, + scheduled, + victim, + victim_cpu, + allocate_processor + ); + + return victim_thread; +} + +static inline Scheduler_Node *_Scheduler_SMP_Get_lowest_scheduled( + Scheduler_Context *context, + Scheduler_Node *filter +) +{ + Scheduler_SMP_Context *self = _Scheduler_SMP_Get_self( context ); + Chain_Control *scheduled = &self->Scheduled; + Scheduler_Node *lowest_scheduled = + (Scheduler_Node *) _Chain_Last( scheduled ); + + (void) filter; + + _Assert( &lowest_scheduled->Node.Chain != _Chain_Tail( scheduled ) ); + _Assert( + _Chain_Next( &lowest_scheduled->Node.Chain ) == _Chain_Tail( scheduled ) + ); + + return lowest_scheduled; +} + +static inline void _Scheduler_SMP_Enqueue_to_scheduled( + Scheduler_Context *context, + Scheduler_Node *node, + Priority_Control priority, + Scheduler_Node *lowest_scheduled, + Scheduler_SMP_Insert insert_scheduled, + Scheduler_SMP_Move move_from_scheduled_to_ready, + Scheduler_SMP_Allocate_processor allocate_processor +) +{ + Scheduler_Try_to_schedule_action action; + + action = _Scheduler_Try_to_schedule_node( + context, + node, + _Scheduler_Node_get_idle( lowest_scheduled ), + _Scheduler_SMP_Get_idle_thread + ); + + if ( action == SCHEDULER_TRY_TO_SCHEDULE_DO_SCHEDULE ) { + _Scheduler_SMP_Preempt( + context, + node, + lowest_scheduled, + allocate_processor + ); + + ( *insert_scheduled )( context, node, priority ); + ( *move_from_scheduled_to_ready )( context, lowest_scheduled ); + + _Scheduler_Release_idle_thread( + context, + lowest_scheduled, + _Scheduler_SMP_Release_idle_thread + ); + } else if ( action == SCHEDULER_TRY_TO_SCHEDULE_DO_IDLE_EXCHANGE ) { + _Scheduler_SMP_Node_change_state( + lowest_scheduled, + SCHEDULER_SMP_NODE_READY + ); + _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_SCHEDULED ); + + ( *insert_scheduled )( context, node, priority ); + ( *move_from_scheduled_to_ready )( context, lowest_scheduled ); + + _Scheduler_Exchange_idle_thread( + node, + lowest_scheduled, + _Scheduler_Node_get_idle( lowest_scheduled ) + ); + } else { + _Assert( action == SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK ); + _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_BLOCKED ); + } +} + +/** + * @brief Enqueues a node according to the specified order function. + * + * The node must not be in the scheduled state. + * + * @param[in] context The scheduler instance context. + * @param[in] node The node to enqueue. + * @param[in] priority The node insert priority. + * @param[in] order The order function. + * @param[in] insert_ready Function to insert a node into the set of ready + * nodes. + * @param[in] insert_scheduled Function to insert a node into the set of + * scheduled nodes. + * @param[in] move_from_scheduled_to_ready Function to move a node from the set + * of scheduled nodes to the set of ready nodes. + * @param[in] get_lowest_scheduled Function to select the node from the + * scheduled nodes to replace. It may not be possible to find one, in this + * case a pointer must be returned so that the order functions returns false + * if this pointer is passed as the second argument to the order function. + * @param[in] allocate_processor Function to allocate a processor to a node + * based on the rules of the scheduler. + */ +static inline bool _Scheduler_SMP_Enqueue( + Scheduler_Context *context, + Scheduler_Node *node, + Priority_Control insert_priority, + Chain_Node_order order, + Scheduler_SMP_Insert insert_ready, + Scheduler_SMP_Insert insert_scheduled, + Scheduler_SMP_Move move_from_scheduled_to_ready, + Scheduler_SMP_Get_lowest_scheduled get_lowest_scheduled, + Scheduler_SMP_Allocate_processor allocate_processor +) +{ + bool needs_help; + Scheduler_Node *lowest_scheduled; + + lowest_scheduled = ( *get_lowest_scheduled )( context, node ); + + if ( ( *order )( &insert_priority, &lowest_scheduled->Node.Chain ) ) { + _Scheduler_SMP_Enqueue_to_scheduled( + context, + node, + insert_priority, + lowest_scheduled, + insert_scheduled, + move_from_scheduled_to_ready, + allocate_processor + ); + needs_help = false; + } else { + ( *insert_ready )( context, node, insert_priority ); + needs_help = true; + } + + return needs_help; +} + +/** + * @brief Enqueues a scheduled node according to the specified order + * function. + * + * @param[in] context The scheduler instance context. + * @param[in] node The node to enqueue. + * @param[in] order The order function. + * @param[in] extract_from_ready Function to extract a node from the set of + * ready nodes. + * @param[in] get_highest_ready Function to get the highest ready node. + * @param[in] insert_ready Function to insert a node into the set of ready + * nodes. + * @param[in] insert_scheduled Function to insert a node into the set of + * scheduled nodes. + * @param[in] move_from_ready_to_scheduled Function to move a node from the set + * of ready nodes to the set of scheduled nodes. + * @param[in] allocate_processor Function to allocate a processor to a node + * based on the rules of the scheduler. + */ +static inline bool _Scheduler_SMP_Enqueue_scheduled( + Scheduler_Context *context, + Scheduler_Node *const node, + Priority_Control insert_priority, + Chain_Node_order order, + Scheduler_SMP_Extract extract_from_ready, + Scheduler_SMP_Get_highest_ready get_highest_ready, + Scheduler_SMP_Insert insert_ready, + Scheduler_SMP_Insert insert_scheduled, + Scheduler_SMP_Move move_from_ready_to_scheduled, + Scheduler_SMP_Allocate_processor allocate_processor +) +{ + while ( true ) { + Scheduler_Node *highest_ready; + Scheduler_Try_to_schedule_action action; + + highest_ready = ( *get_highest_ready )( context, node ); + + /* + * The node has been extracted from the scheduled chain. We have to place + * it now on the scheduled or ready set. + */ + if ( + node->sticky_level > 0 + && ( *order )( &insert_priority, &highest_ready->Node.Chain ) + ) { + ( *insert_scheduled )( context, node, insert_priority ); + + if ( _Scheduler_Node_get_idle( node ) != NULL ) { + Thread_Control *owner; + ISR_lock_Context lock_context; + + owner = _Scheduler_Node_get_owner( node ); + _Thread_Scheduler_acquire_critical( owner, &lock_context ); + + if ( owner->Scheduler.state == THREAD_SCHEDULER_READY ) { + _Thread_Scheduler_cancel_need_for_help( + owner, + _Thread_Get_CPU( owner ) + ); + _Scheduler_Discard_idle_thread( + context, + owner, + node, + _Scheduler_SMP_Release_idle_thread + ); + _Scheduler_Thread_change_state( owner, THREAD_SCHEDULER_SCHEDULED ); + } + + _Thread_Scheduler_release_critical( owner, &lock_context ); + } + + return false; + } + + action = _Scheduler_Try_to_schedule_node( + context, + highest_ready, + _Scheduler_Node_get_idle( node ), + _Scheduler_SMP_Get_idle_thread + ); + + if ( action == SCHEDULER_TRY_TO_SCHEDULE_DO_SCHEDULE ) { + Thread_Control *idle; + + _Scheduler_SMP_Preempt( + context, + highest_ready, + node, + allocate_processor + ); + + ( *insert_ready )( context, node, insert_priority ); + ( *move_from_ready_to_scheduled )( context, highest_ready ); + + idle = _Scheduler_Release_idle_thread( + context, + node, + _Scheduler_SMP_Release_idle_thread + ); + return ( idle == NULL ); + } else if ( action == SCHEDULER_TRY_TO_SCHEDULE_DO_IDLE_EXCHANGE ) { + _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_READY ); + _Scheduler_SMP_Node_change_state( + highest_ready, + SCHEDULER_SMP_NODE_SCHEDULED + ); + + ( *insert_ready )( context, node, insert_priority ); + ( *move_from_ready_to_scheduled )( context, highest_ready ); + + _Scheduler_Exchange_idle_thread( + highest_ready, + node, + _Scheduler_Node_get_idle( node ) + ); + return false; + } else { + _Assert( action == SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK ); + + _Scheduler_SMP_Node_change_state( + highest_ready, + SCHEDULER_SMP_NODE_BLOCKED + ); + + ( *extract_from_ready )( context, highest_ready ); + } + } +} + +static inline void _Scheduler_SMP_Extract_from_scheduled( + Scheduler_Node *node +) +{ + _Chain_Extract_unprotected( &node->Node.Chain ); +} + +static inline void _Scheduler_SMP_Schedule_highest_ready( + Scheduler_Context *context, + Scheduler_Node *victim, + Per_CPU_Control *victim_cpu, + Scheduler_SMP_Extract extract_from_ready, + Scheduler_SMP_Get_highest_ready get_highest_ready, + Scheduler_SMP_Move move_from_ready_to_scheduled, + Scheduler_SMP_Allocate_processor allocate_processor +) +{ + Scheduler_Try_to_schedule_action action; + + do { + Scheduler_Node *highest_ready = ( *get_highest_ready )( context, victim ); + + action = _Scheduler_Try_to_schedule_node( + context, + highest_ready, + NULL, + _Scheduler_SMP_Get_idle_thread + ); + + if ( action == SCHEDULER_TRY_TO_SCHEDULE_DO_SCHEDULE ) { + _Scheduler_SMP_Allocate_processor( + context, + highest_ready, + victim, + victim_cpu, + allocate_processor + ); + + ( *move_from_ready_to_scheduled )( context, highest_ready ); + } else { + _Assert( action == SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK ); + + _Scheduler_SMP_Node_change_state( + highest_ready, + SCHEDULER_SMP_NODE_BLOCKED + ); + + ( *extract_from_ready )( context, highest_ready ); + } + } while ( action == SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK ); +} + +static inline void _Scheduler_SMP_Preempt_and_schedule_highest_ready( + Scheduler_Context *context, + Scheduler_Node *victim, + Per_CPU_Control *victim_cpu, + Scheduler_SMP_Extract extract_from_ready, + Scheduler_SMP_Get_highest_ready get_highest_ready, + Scheduler_SMP_Move move_from_ready_to_scheduled, + Scheduler_SMP_Allocate_processor allocate_processor +) +{ + Scheduler_Try_to_schedule_action action; + + do { + Scheduler_Node *highest_ready = ( *get_highest_ready )( context, victim ); + + action = _Scheduler_Try_to_schedule_node( + context, + highest_ready, + NULL, + _Scheduler_SMP_Get_idle_thread + ); + + if ( action == SCHEDULER_TRY_TO_SCHEDULE_DO_SCHEDULE ) { + _Scheduler_SMP_Preempt( + context, + highest_ready, + victim, + allocate_processor + ); + + ( *move_from_ready_to_scheduled )( context, highest_ready ); + } else { + _Assert( action == SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK ); + + _Scheduler_SMP_Node_change_state( + highest_ready, + SCHEDULER_SMP_NODE_BLOCKED + ); + + ( *extract_from_ready )( context, highest_ready ); + } + } while ( action == SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK ); +} + +/** + * @brief Blocks a thread. + * + * @param[in] context The scheduler instance context. + * @param[in] thread The thread of the scheduling operation. + * @param[in] node The scheduler node of the thread to block. + * @param[in] extract_from_ready Function to extract a node from the set of + * ready nodes. + * @param[in] get_highest_ready Function to get the highest ready node. + * @param[in] move_from_ready_to_scheduled Function to move a node from the set + * of ready nodes to the set of scheduled nodes. + */ +static inline void _Scheduler_SMP_Block( + Scheduler_Context *context, + Thread_Control *thread, + Scheduler_Node *node, + Scheduler_SMP_Extract extract_from_ready, + Scheduler_SMP_Get_highest_ready get_highest_ready, + Scheduler_SMP_Move move_from_ready_to_scheduled, + Scheduler_SMP_Allocate_processor allocate_processor +) +{ + Scheduler_SMP_Node_state node_state; + Per_CPU_Control *thread_cpu; + + node_state = _Scheduler_SMP_Node_state( node ); + + thread_cpu = _Scheduler_Block_node( + context, + thread, + node, + node_state == SCHEDULER_SMP_NODE_SCHEDULED, + _Scheduler_SMP_Get_idle_thread + ); + + if ( thread_cpu != NULL ) { + _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_BLOCKED ); + + if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) { + _Scheduler_SMP_Extract_from_scheduled( node ); + _Scheduler_SMP_Schedule_highest_ready( + context, + node, + thread_cpu, + extract_from_ready, + get_highest_ready, + move_from_ready_to_scheduled, + allocate_processor + ); + } else if ( node_state == SCHEDULER_SMP_NODE_READY ) { + ( *extract_from_ready )( context, node ); + } + } +} + +static inline void _Scheduler_SMP_Unblock( + Scheduler_Context *context, + Thread_Control *thread, + Scheduler_Node *node, + Scheduler_SMP_Update update, + Scheduler_SMP_Enqueue enqueue +) +{ + Scheduler_SMP_Node_state node_state; + bool unblock; + + node_state = _Scheduler_SMP_Node_state( node ); + unblock = _Scheduler_Unblock_node( + context, + thread, + node, + node_state == SCHEDULER_SMP_NODE_SCHEDULED, + _Scheduler_SMP_Release_idle_thread + ); + + if ( unblock ) { + Priority_Control priority; + bool needs_help; + + priority = _Scheduler_Node_get_priority( node ); + priority = SCHEDULER_PRIORITY_PURIFY( priority ); + + if ( priority != _Scheduler_SMP_Node_priority( node ) ) { + ( *update )( context, node, priority ); + } + + if ( node_state == SCHEDULER_SMP_NODE_BLOCKED ) { + Priority_Control insert_priority; + + _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_READY ); + insert_priority = SCHEDULER_PRIORITY_APPEND( priority ); + needs_help = ( *enqueue )( context, node, insert_priority ); + } else { + _Assert( node_state == SCHEDULER_SMP_NODE_READY ); + _Assert( node->sticky_level > 0 ); + _Assert( node->idle == NULL ); + needs_help = true; + } + + if ( needs_help ) { + _Scheduler_Ask_for_help( thread ); + } + } +} + +static inline void _Scheduler_SMP_Update_priority( + Scheduler_Context *context, + Thread_Control *thread, + Scheduler_Node *node, + Scheduler_SMP_Extract extract_from_ready, + Scheduler_SMP_Update update, + Scheduler_SMP_Enqueue enqueue, + Scheduler_SMP_Enqueue enqueue_scheduled, + Scheduler_SMP_Ask_for_help ask_for_help +) +{ + Priority_Control priority; + Priority_Control insert_priority; + Scheduler_SMP_Node_state node_state; + + insert_priority = _Scheduler_Node_get_priority( node ); + priority = SCHEDULER_PRIORITY_PURIFY( insert_priority ); + + if ( priority == _Scheduler_SMP_Node_priority( node ) ) { + if ( _Thread_Is_ready( thread ) ) { + ( *ask_for_help )( context, thread, node ); + } + + return; + } + + node_state = _Scheduler_SMP_Node_state( node ); + + if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) { + _Scheduler_SMP_Extract_from_scheduled( node ); + ( *update )( context, node, priority ); + ( *enqueue_scheduled )( context, node, insert_priority ); + } else if ( node_state == SCHEDULER_SMP_NODE_READY ) { + ( *extract_from_ready )( context, node ); + ( *update )( context, node, priority ); + ( *enqueue )( context, node, insert_priority ); + } else { + ( *update )( context, node, priority ); + + if ( _Thread_Is_ready( thread ) ) { + ( *ask_for_help )( context, thread, node ); + } + } +} + +static inline void _Scheduler_SMP_Yield( + Scheduler_Context *context, + Thread_Control *thread, + Scheduler_Node *node, + Scheduler_SMP_Extract extract_from_ready, + Scheduler_SMP_Enqueue enqueue, + Scheduler_SMP_Enqueue enqueue_scheduled +) +{ + bool needs_help; + Scheduler_SMP_Node_state node_state; + Priority_Control insert_priority; + + node_state = _Scheduler_SMP_Node_state( node ); + insert_priority = _Scheduler_SMP_Node_priority( node ); + insert_priority = SCHEDULER_PRIORITY_APPEND( insert_priority ); + + if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) { + _Scheduler_SMP_Extract_from_scheduled( node ); + ( *enqueue_scheduled )( context, node, insert_priority ); + needs_help = false; + } else if ( node_state == SCHEDULER_SMP_NODE_READY ) { + ( *extract_from_ready )( context, node ); + + needs_help = ( *enqueue )( context, node, insert_priority ); + } else { + needs_help = true; + } + + if ( needs_help ) { + _Scheduler_Ask_for_help( thread ); + } +} + +static inline void _Scheduler_SMP_Insert_scheduled( + Scheduler_Context *context, + Scheduler_Node *node_to_insert, + Priority_Control priority_to_insert +) +{ + Scheduler_SMP_Context *self; + + self = _Scheduler_SMP_Get_self( context ); + + _Chain_Insert_ordered_unprotected( + &self->Scheduled, + &node_to_insert->Node.Chain, + &priority_to_insert, + _Scheduler_SMP_Priority_less_equal + ); +} + +static inline bool _Scheduler_SMP_Ask_for_help( + Scheduler_Context *context, + Thread_Control *thread, + Scheduler_Node *node, + Chain_Node_order order, + Scheduler_SMP_Insert insert_ready, + Scheduler_SMP_Insert insert_scheduled, + Scheduler_SMP_Move move_from_scheduled_to_ready, + Scheduler_SMP_Get_lowest_scheduled get_lowest_scheduled, + Scheduler_SMP_Allocate_processor allocate_processor +) +{ + Scheduler_Node *lowest_scheduled; + ISR_lock_Context lock_context; + bool success; + + lowest_scheduled = ( *get_lowest_scheduled )( context, node ); + + _Thread_Scheduler_acquire_critical( thread, &lock_context ); + + if ( thread->Scheduler.state == THREAD_SCHEDULER_READY ) { + Scheduler_SMP_Node_state node_state; + + node_state = _Scheduler_SMP_Node_state( node ); + + if ( node_state == SCHEDULER_SMP_NODE_BLOCKED ) { + Priority_Control insert_priority; + + insert_priority = _Scheduler_SMP_Node_priority( node ); + + if ( ( *order )( &insert_priority, &lowest_scheduled->Node.Chain ) ) { + _Thread_Scheduler_cancel_need_for_help( + thread, + _Thread_Get_CPU( thread ) + ); + _Scheduler_Thread_change_state( thread, THREAD_SCHEDULER_SCHEDULED ); + _Thread_Scheduler_release_critical( thread, &lock_context ); + + _Scheduler_SMP_Preempt( + context, + node, + lowest_scheduled, + allocate_processor + ); + + ( *insert_scheduled )( context, node, insert_priority ); + ( *move_from_scheduled_to_ready )( context, lowest_scheduled ); + + _Scheduler_Release_idle_thread( + context, + lowest_scheduled, + _Scheduler_SMP_Release_idle_thread + ); + success = true; + } else { + _Thread_Scheduler_release_critical( thread, &lock_context ); + _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_READY ); + ( *insert_ready )( context, node, insert_priority ); + success = false; + } + } else if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) { + _Thread_Scheduler_cancel_need_for_help( + thread, + _Thread_Get_CPU( thread ) + ); + _Scheduler_Discard_idle_thread( + context, + thread, + node, + _Scheduler_SMP_Release_idle_thread + ); + _Scheduler_Thread_change_state( thread, THREAD_SCHEDULER_SCHEDULED ); + _Thread_Scheduler_release_critical( thread, &lock_context ); + success = true; + } else { + _Thread_Scheduler_release_critical( thread, &lock_context ); + success = false; + } + } else { + _Thread_Scheduler_release_critical( thread, &lock_context ); + success = false; + } + + return success; +} + +static inline void _Scheduler_SMP_Reconsider_help_request( + Scheduler_Context *context, + Thread_Control *thread, + Scheduler_Node *node, + Scheduler_SMP_Extract extract_from_ready +) +{ + ISR_lock_Context lock_context; + + _Thread_Scheduler_acquire_critical( thread, &lock_context ); + + if ( + thread->Scheduler.state == THREAD_SCHEDULER_SCHEDULED + && _Scheduler_SMP_Node_state( node ) == SCHEDULER_SMP_NODE_READY + && node->sticky_level == 1 + ) { + _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_BLOCKED ); + ( *extract_from_ready )( context, node ); + } + + _Thread_Scheduler_release_critical( thread, &lock_context ); +} + +static inline void _Scheduler_SMP_Withdraw_node( + Scheduler_Context *context, + Thread_Control *thread, + Scheduler_Node *node, + Thread_Scheduler_state next_state, + Scheduler_SMP_Extract extract_from_ready, + Scheduler_SMP_Get_highest_ready get_highest_ready, + Scheduler_SMP_Move move_from_ready_to_scheduled, + Scheduler_SMP_Allocate_processor allocate_processor +) +{ + ISR_lock_Context lock_context; + Scheduler_SMP_Node_state node_state; + + _Thread_Scheduler_acquire_critical( thread, &lock_context ); + + node_state = _Scheduler_SMP_Node_state( node ); + _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_BLOCKED ); + + if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) { + Per_CPU_Control *thread_cpu; + + thread_cpu = _Thread_Get_CPU( thread ); + _Scheduler_Thread_change_state( thread, next_state ); + _Thread_Scheduler_release_critical( thread, &lock_context ); + + _Scheduler_SMP_Extract_from_scheduled( node ); + _Scheduler_SMP_Schedule_highest_ready( + context, + node, + thread_cpu, + extract_from_ready, + get_highest_ready, + move_from_ready_to_scheduled, + allocate_processor + ); + } else if ( node_state == SCHEDULER_SMP_NODE_READY ) { + _Thread_Scheduler_release_critical( thread, &lock_context ); + ( *extract_from_ready )( context, node ); + } else { + _Assert( node_state == SCHEDULER_SMP_NODE_BLOCKED ); + _Thread_Scheduler_release_critical( thread, &lock_context ); + } +} + +static inline void _Scheduler_SMP_Do_start_idle( + Scheduler_Context *context, + Thread_Control *idle, + Per_CPU_Control *cpu, + Scheduler_SMP_Register_idle register_idle +) +{ + Scheduler_SMP_Context *self; + Scheduler_SMP_Node *node; + + self = _Scheduler_SMP_Get_self( context ); + node = _Scheduler_SMP_Thread_get_node( idle ); + + _Scheduler_Thread_change_state( idle, THREAD_SCHEDULER_SCHEDULED ); + node->state = SCHEDULER_SMP_NODE_SCHEDULED; + + _Thread_Set_CPU( idle, cpu ); + ( *register_idle )( context, &node->Base, cpu ); + _Chain_Append_unprotected( &self->Scheduled, &node->Base.Node.Chain ); + _Scheduler_SMP_Release_idle_thread( &self->Base, idle ); +} + +static inline void _Scheduler_SMP_Add_processor( + Scheduler_Context *context, + Thread_Control *idle, + Scheduler_SMP_Has_ready has_ready, + Scheduler_SMP_Enqueue enqueue_scheduled, + Scheduler_SMP_Register_idle register_idle +) +{ + Scheduler_SMP_Context *self; + Scheduler_Node *node; + + self = _Scheduler_SMP_Get_self( context ); + idle->Scheduler.state = THREAD_SCHEDULER_SCHEDULED; + _Scheduler_SMP_Release_idle_thread( &self->Base, idle ); + node = _Thread_Scheduler_get_home_node( idle ); + _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_SCHEDULED ); + ( *register_idle )( context, node, _Thread_Get_CPU( idle ) ); + + if ( ( *has_ready )( &self->Base ) ) { + Priority_Control insert_priority; + + insert_priority = _Scheduler_SMP_Node_priority( node ); + insert_priority = SCHEDULER_PRIORITY_APPEND( insert_priority ); + ( *enqueue_scheduled )( &self->Base, node, insert_priority ); + } else { + _Chain_Append_unprotected( &self->Scheduled, &node->Node.Chain ); + } +} + +static inline Thread_Control *_Scheduler_SMP_Remove_processor( + Scheduler_Context *context, + Per_CPU_Control *cpu, + Scheduler_SMP_Extract extract_from_ready, + Scheduler_SMP_Enqueue enqueue +) +{ + Scheduler_SMP_Context *self; + Chain_Node *chain_node; + Scheduler_Node *victim_node; + Thread_Control *victim_user; + Thread_Control *victim_owner; + Thread_Control *idle; + + self = _Scheduler_SMP_Get_self( context ); + chain_node = _Chain_First( &self->Scheduled ); + + do { + _Assert( chain_node != _Chain_Immutable_tail( &self->Scheduled ) ); + victim_node = (Scheduler_Node *) chain_node; + victim_user = _Scheduler_Node_get_user( victim_node ); + chain_node = _Chain_Next( chain_node ); + } while ( _Thread_Get_CPU( victim_user ) != cpu ); + + _Scheduler_SMP_Extract_from_scheduled( victim_node ); + victim_owner = _Scheduler_Node_get_owner( victim_node ); + + if ( !victim_owner->is_idle ) { + Scheduler_Node *idle_node; + + _Scheduler_Release_idle_thread( + &self->Base, + victim_node, + _Scheduler_SMP_Release_idle_thread + ); + idle = _Scheduler_SMP_Get_idle_thread( &self->Base ); + idle_node = _Thread_Scheduler_get_home_node( idle ); + ( *extract_from_ready )( &self->Base, idle_node ); + _Scheduler_SMP_Preempt( + &self->Base, + idle_node, + victim_node, + _Scheduler_SMP_Allocate_processor_exact + ); + + if ( !_Chain_Is_empty( &self->Scheduled ) ) { + Priority_Control insert_priority; + + insert_priority = _Scheduler_SMP_Node_priority( victim_node ); + insert_priority = SCHEDULER_PRIORITY_APPEND( insert_priority ); + ( *enqueue )( context, victim_node, insert_priority ); + } + } else { + _Assert( victim_owner == victim_user ); + _Assert( _Scheduler_Node_get_idle( victim_node ) == NULL ); + idle = victim_owner; + _Scheduler_SMP_Exctract_idle_thread( idle ); + } + + return idle; +} + +static inline void _Scheduler_SMP_Set_affinity( + Scheduler_Context *context, + Thread_Control *thread, + Scheduler_Node *node, + void *arg, + Scheduler_SMP_Set_affinity set_affinity, + Scheduler_SMP_Extract extract_from_ready, + Scheduler_SMP_Get_highest_ready get_highest_ready, + Scheduler_SMP_Move move_from_ready_to_scheduled, + Scheduler_SMP_Enqueue enqueue, + Scheduler_SMP_Allocate_processor allocate_processor +) +{ + Scheduler_SMP_Node_state node_state; + Priority_Control insert_priority; + + node_state = _Scheduler_SMP_Node_state( node ); + insert_priority = _Scheduler_SMP_Node_priority( node ); + insert_priority = SCHEDULER_PRIORITY_APPEND( insert_priority ); + + if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) { + _Scheduler_SMP_Extract_from_scheduled( node ); + _Scheduler_SMP_Preempt_and_schedule_highest_ready( + context, + node, + _Thread_Get_CPU( thread ), + extract_from_ready, + get_highest_ready, + move_from_ready_to_scheduled, + allocate_processor + ); + ( *set_affinity )( context, node, arg ); + ( *enqueue )( context, node, insert_priority ); + } else if ( node_state == SCHEDULER_SMP_NODE_READY ) { + ( *extract_from_ready )( context, node ); + ( *set_affinity )( context, node, arg ); + ( *enqueue )( context, node, insert_priority ); + } else { + ( *set_affinity )( context, node, arg ); + } +} + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_SCORE_SCHEDULERSMPIMPL_H */ diff --git a/cpukit/include/rtems/score/schedulerstrongapa.h b/cpukit/include/rtems/score/schedulerstrongapa.h new file mode 100644 index 0000000000..d961f20c68 --- /dev/null +++ b/cpukit/include/rtems/score/schedulerstrongapa.h @@ -0,0 +1,171 @@ +/** + * @file + * + * @ingroup ScoreSchedulerStrongAPA + * + * @brief Strong APA Scheduler API + */ + +/* + * Copyright (c) 2013, 2016 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SCHEDULERSTRONGAPA_H +#define _RTEMS_SCORE_SCHEDULERSTRONGAPA_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup ScoreSchedulerStrongAPA Strong APA Scheduler + * + * @ingroup ScoreSchedulerSMP + * + * This is an implementation of the global fixed priority scheduler (G-FP). It + * uses one ready chain per priority to ensure constant time insert operations. + * The scheduled chain uses linear insert operations and has at most processor + * count entries. Since the processor and priority count are constants all + * scheduler operations complete in a bounded execution time. + * + * The the_thread preempt mode will be ignored. + * + * @{ + */ + +/** + * @brief Scheduler context specialization for Strong APA + * schedulers. + */ +typedef struct { + Scheduler_SMP_Context Base; + Priority_bit_map_Control Bit_map; + Chain_Control Ready[ RTEMS_ZERO_LENGTH_ARRAY ]; +} Scheduler_strong_APA_Context; + +/** + * @brief Scheduler node specialization for Strong APA + * schedulers. + */ +typedef struct { + /** + * @brief SMP scheduler node. + */ + Scheduler_SMP_Node Base; + + /** + * @brief The associated ready queue of this node. + */ + Scheduler_priority_Ready_queue Ready_queue; +} Scheduler_strong_APA_Node; + +/** + * @brief Entry points for the Strong APA Scheduler. + */ +#define SCHEDULER_STRONG_APA_ENTRY_POINTS \ + { \ + _Scheduler_strong_APA_Initialize, \ + _Scheduler_default_Schedule, \ + _Scheduler_strong_APA_Yield, \ + _Scheduler_strong_APA_Block, \ + _Scheduler_strong_APA_Unblock, \ + _Scheduler_strong_APA_Update_priority, \ + _Scheduler_default_Map_priority, \ + _Scheduler_default_Unmap_priority, \ + _Scheduler_strong_APA_Ask_for_help, \ + _Scheduler_strong_APA_Reconsider_help_request, \ + _Scheduler_strong_APA_Withdraw_node, \ + _Scheduler_strong_APA_Add_processor, \ + _Scheduler_strong_APA_Remove_processor, \ + _Scheduler_strong_APA_Node_initialize, \ + _Scheduler_default_Node_destroy, \ + _Scheduler_default_Release_job, \ + _Scheduler_default_Cancel_job, \ + _Scheduler_default_Tick, \ + _Scheduler_SMP_Start_idle \ + SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY \ + } + +void _Scheduler_strong_APA_Initialize( const Scheduler_Control *scheduler ); + +void _Scheduler_strong_APA_Node_initialize( + const Scheduler_Control *scheduler, + Scheduler_Node *node, + Thread_Control *the_thread, + Priority_Control priority +); + +void _Scheduler_strong_APA_Block( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +void _Scheduler_strong_APA_Unblock( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +void _Scheduler_strong_APA_Update_priority( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +bool _Scheduler_strong_APA_Ask_for_help( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +void _Scheduler_strong_APA_Reconsider_help_request( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +void _Scheduler_strong_APA_Withdraw_node( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node, + Thread_Scheduler_state next_state +); + +void _Scheduler_strong_APA_Add_processor( + const Scheduler_Control *scheduler, + Thread_Control *idle +); + +Thread_Control *_Scheduler_strong_APA_Remove_processor( + const Scheduler_Control *scheduler, + struct Per_CPU_Control *cpu +); + +void _Scheduler_strong_APA_Yield( + const Scheduler_Control *scheduler, + Thread_Control *the_thread, + Scheduler_Node *node +); + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_SCORE_SCHEDULERSTRONGAPA_H */ diff --git a/cpukit/include/rtems/score/semaphoreimpl.h b/cpukit/include/rtems/score/semaphoreimpl.h new file mode 100644 index 0000000000..a7857db93e --- /dev/null +++ b/cpukit/include/rtems/score/semaphoreimpl.h @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2015, 2017 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SEMAPHOREIMPL_H +#define _RTEMS_SCORE_SEMAPHOREIMPL_H + +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +typedef struct { + Thread_queue_Syslock_queue Queue; + unsigned int count; +} Sem_Control; + +#define SEMAPHORE_TQ_OPERATIONS &_Thread_queue_Operations_priority + +static inline Sem_Control *_Sem_Get( struct _Semaphore_Control *_sem ) +{ + return (Sem_Control *) _sem; +} + +static inline Thread_Control *_Sem_Queue_acquire_critical( + Sem_Control *sem, + Thread_queue_Context *queue_context +) +{ + Thread_Control *executing; + + executing = _Thread_Executing; + _Thread_queue_Queue_acquire_critical( + &sem->Queue.Queue, + &executing->Potpourri_stats, + &queue_context->Lock_context.Lock_context + ); + + return executing; +} + +static inline void _Sem_Queue_release( + Sem_Control *sem, + ISR_Level level, + Thread_queue_Context *queue_context +) +{ + _Thread_queue_Queue_release_critical( + &sem->Queue.Queue, + &queue_context->Lock_context.Lock_context + ); + _ISR_Local_enable( level ); +} + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_SCORE_SEMAPHOREIMPL_H */ diff --git a/cpukit/include/rtems/score/smp.h b/cpukit/include/rtems/score/smp.h new file mode 100644 index 0000000000..469025e5dc --- /dev/null +++ b/cpukit/include/rtems/score/smp.h @@ -0,0 +1,64 @@ +/** + * @file + * + * @ingroup ScoreSMP + * + * @brief SuperCore SMP Support API + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SMP_H +#define _RTEMS_SCORE_SMP_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ScoreSMP SMP Support + * + * @ingroup Score + * + * This defines the interface of the SuperCore SMP support. + * + * @{ + */ + +#if defined( RTEMS_SMP ) + extern uint32_t _SMP_Processor_count; + + static inline uint32_t _SMP_Get_processor_count( void ) + { + return _SMP_Processor_count; + } +#else + #define _SMP_Get_processor_count() UINT32_C(1) +#endif + +#if defined( RTEMS_SMP ) + static inline uint32_t _SMP_Get_current_processor( void ) + { + return _CPU_SMP_Get_current_processor(); + } +#else + #define _SMP_Get_current_processor() UINT32_C(0) +#endif + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/smpbarrier.h b/cpukit/include/rtems/score/smpbarrier.h new file mode 100644 index 0000000000..fddf7bb1cd --- /dev/null +++ b/cpukit/include/rtems/score/smpbarrier.h @@ -0,0 +1,125 @@ +/** + * @file + * + * @ingroup ScoreSMPBarrier + * + * @brief SMP Barrier API + */ + +/* + * Copyright (c) 2013-2014 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SMPBARRIER_H +#define _RTEMS_SCORE_SMPBARRIER_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup ScoreSMPBarrier SMP Barriers + * + * @ingroup Score + * + * @brief The SMP barrier provides barrier synchronization for SMP systems at + * the lowest level. + * + * The SMP barrier is implemented as a sense barrier, see also Herlihy and + * Shavit, "The Art of Multiprocessor Programming", 17.3 Sense-Reversing + * Barrier. + * + * @{ + */ + +/** + * @brief SMP barrier control. + */ +typedef struct { + Atomic_Uint value; + Atomic_Uint sense; +} SMP_barrier_Control; + +/** + * @brief SMP barrier per-thread state. + * + * Each user of the barrier must provide this per-thread state. + */ +typedef struct { + unsigned int sense; +} SMP_barrier_State; + +/** + * @brief SMP barrier control initializer for static initialization. + */ +#define SMP_BARRIER_CONTROL_INITIALIZER \ + { ATOMIC_INITIALIZER_UINT( 0U ), ATOMIC_INITIALIZER_UINT( 0U ) } + +/** + * @brief SMP barrier per-thread state initializer for static initialization. + */ +#define SMP_BARRIER_STATE_INITIALIZER { 0U } + +/** + * @brief Initializes a SMP barrier control. + * + * Concurrent initialization leads to unpredictable results. + * + * @param[out] control The SMP barrier control. + */ +static inline void _SMP_barrier_Control_initialize( + SMP_barrier_Control *control +) +{ + _Atomic_Init_uint( &control->value, 0U ); + _Atomic_Init_uint( &control->sense, 0U ); +} + +/** + * @brief Initializes a SMP barrier per-thread state. + * + * @param[out] state The SMP barrier control. + */ +static inline void _SMP_barrier_State_initialize( + SMP_barrier_State *state +) +{ + state->sense = 0U; +} + +/** + * @brief Waits on the SMP barrier until count threads rendezvoused. + * + * @param[in, out] control The SMP barrier control. + * @param[in, out] state The SMP barrier per-thread state. + * @param[in] count The thread count bound to rendezvous. + * + * @retval true This processor performed the barrier release. + * @retval false Otherwise. + */ +bool _SMP_barrier_Wait( + SMP_barrier_Control *control, + SMP_barrier_State *state, + unsigned int count +); + +/**@}*/ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_SCORE_SMPBARRIER_H */ diff --git a/cpukit/include/rtems/score/smpimpl.h b/cpukit/include/rtems/score/smpimpl.h new file mode 100644 index 0000000000..48e6a12498 --- /dev/null +++ b/cpukit/include/rtems/score/smpimpl.h @@ -0,0 +1,354 @@ +/** + * @file + * + * @ingroup ScoreSMPImpl + * + * @brief SuperCore SMP Implementation + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SMPIMPL_H +#define _RTEMS_SCORE_SMPIMPL_H + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ScoreSMP SMP Support + * + * @ingroup Score + * + * This defines the interface of the SuperCore SMP support. + * + * @{ + */ + +/** + * @brief SMP message to request a processor shutdown. + * + * @see _SMP_Send_message(). + */ +#define SMP_MESSAGE_SHUTDOWN 0x1UL + +/** + * @brief SMP message to request a test handler invocation. + * + * @see _SMP_Send_message(). + */ +#define SMP_MESSAGE_TEST 0x2UL + +/** + * @brief SMP message to request a multicast action. + * + * @see _SMP_Send_message(). + */ +#define SMP_MESSAGE_MULTICAST_ACTION 0x4UL + +/** + * @brief SMP message to request a clock tick. + * + * This message is provided for systems without a proper interrupt affinity + * support and may be used by the clock driver. + * + * @see _SMP_Send_message(). + */ +#define SMP_MESSAGE_CLOCK_TICK 0x8UL + +/** + * @brief SMP fatal codes. + */ +typedef enum { + SMP_FATAL_BOOT_PROCESSOR_NOT_ASSIGNED_TO_SCHEDULER, + SMP_FATAL_MANDATORY_PROCESSOR_NOT_PRESENT, + SMP_FATAL_MULTITASKING_START_ON_INVALID_PROCESSOR, + SMP_FATAL_MULTITASKING_START_ON_UNASSIGNED_PROCESSOR, + SMP_FATAL_SHUTDOWN, + SMP_FATAL_SHUTDOWN_RESPONSE, + SMP_FATAL_START_OF_MANDATORY_PROCESSOR_FAILED +} SMP_Fatal_code; + +static inline void _SMP_Fatal( SMP_Fatal_code code ) +{ + _Terminate( RTEMS_FATAL_SOURCE_SMP, code ); +} + +/** + * @brief Initialize SMP Handler + * + * This method initialize the SMP Handler. + */ +#if defined( RTEMS_SMP ) + void _SMP_Handler_initialize( void ); +#else + #define _SMP_Handler_initialize() \ + do { } while ( 0 ) +#endif + +#if defined( RTEMS_SMP ) + +/** + * @brief Set of online processors. + * + * A processor is online if was started during system initialization. In this + * case its corresponding bit in the mask is set. + * + * @see _SMP_Handler_initialize(). + */ +extern Processor_mask _SMP_Online_processors; + +/** + * @brief Performs high-level initialization of a secondary processor and runs + * the application threads. + * + * The low-level initialization code must call this function to hand over the + * control of this processor to RTEMS. Interrupts must be disabled. It must + * be possible to send inter-processor interrupts to this processor. Since + * interrupts are disabled the inter-processor interrupt delivery is postponed + * until interrupts are enabled the first time. Interrupts are enabled during + * the execution begin of threads in case they have interrupt level zero (this + * is the default). + * + * The pre-requisites for the call to this function are + * - disabled interrupts, + * - delivery of inter-processor interrupts is possible, + * - a valid stack pointer and enough stack space, + * - a valid code memory, and + * - a valid BSS section. + * + * This function must not be called by the main processor. The main processor + * uses _Thread_Start_multitasking() instead. + * + * This function does not return to the caller. + */ +void _SMP_Start_multitasking_on_secondary_processor( void ) + RTEMS_NO_RETURN; + +typedef void ( *SMP_Test_message_handler )( Per_CPU_Control *cpu_self ); + +extern SMP_Test_message_handler _SMP_Test_message_handler; + +/** + * @brief Sets the handler for test messages. + * + * This handler can be used to test the inter-processor interrupt + * implementation. + */ +static inline void _SMP_Set_test_message_handler( + SMP_Test_message_handler handler +) +{ + _SMP_Test_message_handler = handler; +} + +/** + * @brief Processes all pending multicast actions. + */ +void _SMP_Multicast_actions_process( void ); + +/** + * @brief Interrupt handler for inter-processor interrupts. + * + * @return The received message. + */ +static inline long unsigned _SMP_Inter_processor_interrupt_handler( void ) +{ + Per_CPU_Control *cpu_self; + unsigned long message; + + cpu_self = _Per_CPU_Get(); + + /* + * In the common case the inter-processor interrupt is issued to carry out a + * thread dispatch. + */ + cpu_self->dispatch_necessary = true; + + message = _Atomic_Exchange_ulong( + &cpu_self->message, + 0, + ATOMIC_ORDER_ACQUIRE + ); + + if ( message != 0 ) { + if ( ( message & SMP_MESSAGE_SHUTDOWN ) != 0 ) { + _SMP_Fatal( SMP_FATAL_SHUTDOWN_RESPONSE ); + /* does not continue past here */ + } + + if ( ( message & SMP_MESSAGE_TEST ) != 0 ) { + ( *_SMP_Test_message_handler )( cpu_self ); + } + + if ( ( message & SMP_MESSAGE_MULTICAST_ACTION ) != 0 ) { + _SMP_Multicast_actions_process(); + } + } + + return message; +} + +/** + * @brief Returns true, if the processor with the specified index should be + * started. + * + * @param[in] cpu_index The processor index. + * + * @retval true The processor should be started. + * @retval false Otherwise. + */ +bool _SMP_Should_start_processor( uint32_t cpu_index ); + +/** + * @brief Sends an SMP message to a processor. + * + * The target processor may be the sending processor. + * + * @param[in] cpu_index The target processor of the message. + * @param[in] message The message. + */ +void _SMP_Send_message( uint32_t cpu_index, unsigned long message ); + +/** + * @brief Sends an SMP message to all other online processors. + * + * @param[in] message The message. + */ +void _SMP_Send_message_broadcast( + unsigned long message +); + +/** + * @brief Sends an SMP message to a set of processors. + * + * The sending processor may be part of the set. + * + * @param[in] targets The set of processors to send the message. + * @param[in] message The message. + */ +void _SMP_Send_message_multicast( + const Processor_mask *targets, + unsigned long message +); + +typedef void ( *SMP_Action_handler )( void *arg ); + +/** + * @brief Initiates an SMP multicast action to a set of processors. + * + * The current processor may be part of the set. + * + * @param[in] setsize The size of the set of target processors of the message. + * @param[in] cpus The set of target processors of the message. + * @param[in] handler The multicast action handler. + * @param[in] arg The multicast action argument. + */ +void _SMP_Multicast_action( + const size_t setsize, + const cpu_set_t *cpus, + SMP_Action_handler handler, + void *arg +); + +/** + * @brief Executes a handler with argument on the specified processor on behalf + * of the boot processor. + * + * The calling processor must be the boot processor. In case the specified + * processor is not online or not in the + * PER_CPU_STATE_READY_TO_START_MULTITASKING state, then no action is + * performed. + * + * @param cpu The processor to execute the action. + * @param handler The handler of the action. + * @param arg The argument of the action. + * + * @retval true The handler executed on the specified processor. + * @retval false Otherwise. + * + * @see _SMP_Before_multitasking_action_broadcast(). + */ +bool _SMP_Before_multitasking_action( + Per_CPU_Control *cpu, + SMP_Action_handler handler, + void *arg +); + +/** + * @brief Executes a handler with argument on all online processors except the + * boot processor on behalf of the boot processor. + * + * The calling processor must be the boot processor. + * + * @param handler The handler of the action. + * @param arg The argument of the action. + * + * @retval true The handler executed on all online processors except the boot + * processor. + * @retval false Otherwise. + * + * @see _SMP_Before_multitasking_action(). + */ +bool _SMP_Before_multitasking_action_broadcast( + SMP_Action_handler handler, + void *arg +); + +#endif /* defined( RTEMS_SMP ) */ + +/** + * @brief Requests a multitasking start on all configured and available + * processors. + */ +#if defined( RTEMS_SMP ) + void _SMP_Request_start_multitasking( void ); +#else + #define _SMP_Request_start_multitasking() \ + do { } while ( 0 ) +#endif + +/** + * @brief Requests a shutdown of all processors. + * + * This function is a part of the system termination procedure. + * + * @see _Terminate(). + */ +#if defined( RTEMS_SMP ) + void _SMP_Request_shutdown( void ); +#else + #define _SMP_Request_shutdown() \ + do { } while ( 0 ) +#endif + +RTEMS_INLINE_ROUTINE const Processor_mask *_SMP_Get_online_processors( void ) +{ +#if defined(RTEMS_SMP) + return &_SMP_Online_processors; +#else + return &_Processor_mask_The_one_and_only; +#endif +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/smplock.h b/cpukit/include/rtems/score/smplock.h new file mode 100644 index 0000000000..a156edfd92 --- /dev/null +++ b/cpukit/include/rtems/score/smplock.h @@ -0,0 +1,327 @@ +/** + * @file + * + * @ingroup ScoreSMPLock + * + * @brief SMP Lock API + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * Copyright (c) 2013, 2016 embedded brains GmbH + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SMPLOCK_H +#define _RTEMS_SCORE_SMPLOCK_H + +#include + +#if defined(RTEMS_SMP) + +#include +#include +#include + +#if defined(RTEMS_DEBUG) +#include +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup ScoreSMPLock SMP Locks + * + * @ingroup Score + * + * @brief The SMP lock provides mutual exclusion for SMP systems at the lowest + * level. + * + * The SMP lock is implemented as a ticket lock. This provides fairness in + * case of concurrent lock attempts. + * + * This SMP lock API uses a local context for acquire and release pairs. Such + * a context may be used to implement for example the Mellor-Crummey and Scott + * (MCS) locks in the future. + * + * @{ + */ + +#if defined(RTEMS_DEBUG) || defined(RTEMS_PROFILING) +#define RTEMS_SMP_LOCK_DO_NOT_INLINE +#endif + +/** + * @brief SMP lock control. + */ +typedef struct { + SMP_ticket_lock_Control Ticket_lock; +#if defined(RTEMS_DEBUG) + /** + * @brief The index of the owning processor of this lock. + * + * The processor index is used instead of the executing thread, so that this + * works in interrupt and system initialization context. It is assumed that + * thread dispatching is disabled in SMP lock critical sections. + * + * In case the lock is free, then the value of this field is + * SMP_LOCK_NO_OWNER. + * + * @see _SMP_lock_Is_owner(). + */ + uint32_t owner; +#endif +#if defined(RTEMS_PROFILING) + SMP_lock_Stats Stats; +#endif +} SMP_lock_Control; + +/** + * @brief Local SMP lock context for acquire and release pairs. + */ +typedef struct { + ISR_Level isr_level; +#if defined(RTEMS_DEBUG) + SMP_lock_Control *lock_used_for_acquire; +#endif +#if defined(RTEMS_PROFILING) + SMP_lock_Stats_context Stats_context; +#endif +} SMP_lock_Context; + +#if defined(RTEMS_DEBUG) +#define SMP_LOCK_NO_OWNER 0 +#endif + +/** + * @brief SMP lock control initializer for static initialization. + */ +#if defined(RTEMS_DEBUG) && defined(RTEMS_PROFILING) + #define SMP_LOCK_INITIALIZER( name ) \ + { \ + SMP_TICKET_LOCK_INITIALIZER, \ + SMP_LOCK_NO_OWNER, \ + SMP_LOCK_STATS_INITIALIZER( name ) \ + } +#elif defined(RTEMS_DEBUG) + #define SMP_LOCK_INITIALIZER( name ) \ + { SMP_TICKET_LOCK_INITIALIZER, SMP_LOCK_NO_OWNER } +#elif defined(RTEMS_PROFILING) + #define SMP_LOCK_INITIALIZER( name ) \ + { SMP_TICKET_LOCK_INITIALIZER, SMP_LOCK_STATS_INITIALIZER( name ) } +#else + #define SMP_LOCK_INITIALIZER( name ) { SMP_TICKET_LOCK_INITIALIZER } +#endif + +static inline void _SMP_lock_Initialize_inline( + SMP_lock_Control *lock, + const char *name +) +{ + _SMP_ticket_lock_Initialize( &lock->Ticket_lock ); +#if defined(RTEMS_DEBUG) + lock->owner = SMP_LOCK_NO_OWNER; +#endif +#if defined(RTEMS_PROFILING) + _SMP_lock_Stats_initialize( &lock->Stats, name ); +#else + (void) name; +#endif +} + +/** + * @brief Initializes an SMP lock. + * + * Concurrent initialization leads to unpredictable results. + * + * @param[in] lock The SMP lock control. + * @param[in] name The name for the SMP lock statistics. This name must be + * persistent throughout the life time of this statistics block. + */ +#if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE) +void _SMP_lock_Initialize( + SMP_lock_Control *lock, + const char * name +); +#else +#define _SMP_lock_Initialize( lock, name ) \ + _SMP_lock_Initialize_inline( lock, name ) +#endif + +static inline void _SMP_lock_Destroy_inline( SMP_lock_Control *lock ) +{ + _SMP_ticket_lock_Destroy( &lock->Ticket_lock ); + _SMP_lock_Stats_destroy( &lock->Stats ); +} + +/** + * @brief Destroys an SMP lock. + * + * Concurrent destruction leads to unpredictable results. + * + * @param[in] lock The SMP lock control. + */ +#if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE) +void _SMP_lock_Destroy( SMP_lock_Control *lock ); +#else +#define _SMP_lock_Destroy( lock ) \ + _SMP_lock_Destroy_inline( lock ) +#endif + +#if defined(RTEMS_DEBUG) +static inline uint32_t _SMP_lock_Who_am_I( void ) +{ + /* + * The CPU index starts with zero. Increment it by one, to allow global SMP + * locks to reside in the BSS section. + */ + return _SMP_Get_current_processor() + 1; +} +#endif + +static inline void _SMP_lock_Acquire_inline( + SMP_lock_Control *lock, + SMP_lock_Context *context +) +{ +#if defined(RTEMS_DEBUG) + context->lock_used_for_acquire = lock; +#else + (void) context; +#endif + _SMP_ticket_lock_Acquire( + &lock->Ticket_lock, + &lock->Stats, + &context->Stats_context + ); +#if defined(RTEMS_DEBUG) + lock->owner = _SMP_lock_Who_am_I(); +#endif +} + +/** + * @brief Acquires an SMP lock. + * + * This function will not disable interrupts. The caller must ensure that the + * current thread of execution is not interrupted indefinite once it obtained + * the SMP lock. + * + * @param[in] lock The SMP lock control. + * @param[in] context The local SMP lock context for an acquire and release + * pair. + */ +void _SMP_lock_Acquire( + SMP_lock_Control *lock, + SMP_lock_Context *context +); + +static inline void _SMP_lock_Release_inline( + SMP_lock_Control *lock, + SMP_lock_Context *context +) +{ +#if defined(RTEMS_DEBUG) + _Assert( context->lock_used_for_acquire == lock ); + context->lock_used_for_acquire = NULL; + _Assert( lock->owner == _SMP_lock_Who_am_I() ); + lock->owner = SMP_LOCK_NO_OWNER; +#else + (void) context; +#endif + _SMP_ticket_lock_Release( + &lock->Ticket_lock, + &context->Stats_context + ); +} + +/** + * @brief Releases an SMP lock. + * + * @param[in] lock The SMP lock control. + * @param[in] context The local SMP lock context for an acquire and release + * pair. + */ +#if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE) +void _SMP_lock_Release( + SMP_lock_Control *lock, + SMP_lock_Context *context +); +#else +#define _SMP_lock_Release( lock, context ) \ + _SMP_lock_Release_inline( lock, context ) +#endif + +static inline void _SMP_lock_ISR_disable_and_acquire_inline( + SMP_lock_Control *lock, + SMP_lock_Context *context +) +{ + _ISR_Local_disable( context->isr_level ); + _SMP_lock_Acquire_inline( lock, context ); +} + +/** + * @brief Disables interrupts and acquires the SMP lock. + * + * @param[in] lock The SMP lock control. + * @param[in] context The local SMP lock context for an acquire and release + * pair. + */ +void _SMP_lock_ISR_disable_and_acquire( + SMP_lock_Control *lock, + SMP_lock_Context *context +); + +static inline void _SMP_lock_Release_and_ISR_enable_inline( + SMP_lock_Control *lock, + SMP_lock_Context *context +) +{ + _SMP_lock_Release_inline( lock, context ); + _ISR_Local_enable( context->isr_level ); +} + +/** + * @brief Releases the SMP lock and enables interrupts. + * + * @param[in] lock The SMP lock control. + * @param[in] context The local SMP lock context for an acquire and release + * pair. + */ +#if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE) +void _SMP_lock_Release_and_ISR_enable( + SMP_lock_Control *lock, + SMP_lock_Context *context +); +#else +#define _SMP_lock_Release_and_ISR_enable( lock, context ) \ + _SMP_lock_Release_and_ISR_enable_inline( lock, context ) +#endif + +#if defined(RTEMS_DEBUG) +/** + * @brief Returns true, if the SMP lock is owned by the current processor, + * otherwise false. + * + * @param[in] lock The SMP lock control. + */ +bool _SMP_lock_Is_owner( const SMP_lock_Control *lock ); +#endif + +/**@}*/ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RTEMS_SMP */ + +#endif /* _RTEMS_SCORE_SMPLOCK_H */ diff --git a/cpukit/include/rtems/score/smplockmcs.h b/cpukit/include/rtems/score/smplockmcs.h new file mode 100644 index 0000000000..5a1ad23dc9 --- /dev/null +++ b/cpukit/include/rtems/score/smplockmcs.h @@ -0,0 +1,262 @@ +/** + * @file + * + * @ingroup ScoreSMPLock + * + * @brief SMP Lock API + */ + +/* + * Copyright (c) 2016 embedded brains GmbH + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SMPLOCKMCS_H +#define _RTEMS_SCORE_SMPLOCKMCS_H + +#include + +#if defined(RTEMS_SMP) + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @addtogroup ScoreSMPLock + * + * @{ + */ + +/** + * @brief SMP Mellor-Crummey and Scott (MCS) lock context. + */ +typedef struct SMP_MCS_lock_Context { + /** + * @brief The next context on the queue if it exists. + */ + union { + /** + * @brief The next context as an atomic unsigned integer pointer value. + */ + Atomic_Uintptr atomic; + + /** + * @brief The next context as a normal pointer. + * + * Only provided for debugging purposes. + */ + struct SMP_MCS_lock_Context *normal; + } next; + + /** + * @brief Indicates if the lock is owned or free in case a previous context + * exits on the queue. + * + * This field is initialized to a non-zero value. The previous lock owner + * (which is the owner of the previous context) will set it to zero during + * its lock release. + */ + Atomic_Uint locked; + +#if defined(RTEMS_PROFILING) + SMP_lock_Stats_context Stats_context; + + unsigned int queue_length; +#endif +} SMP_MCS_lock_Context; + +/** + * @brief SMP Mellor-Crummey and Scott (MCS) lock control. + */ +typedef struct { + /** + * @brief The queue tail context. + * + * The lock is free, in case this field is zero, otherwise it is locked by + * the owner of the queue head. + */ + union { + /** + * @brief The queue tail context as an atomic unsigned integer pointer + * value. + */ + Atomic_Uintptr atomic; + + /** + * @brief The queue tail context as a normal pointer. + * + * Only provided for debugging purposes. + */ + struct SMP_MCS_lock_Context *normal; + } queue; +} SMP_MCS_lock_Control; + +/** + * @brief SMP MCS lock control initializer for static initialization. + */ +#define SMP_MCS_LOCK_INITIALIZER { { ATOMIC_INITIALIZER_UINTPTR( 0 ) } } + +/** + * @brief Initializes an SMP MCS lock. + * + * Concurrent initialization leads to unpredictable results. + * + * @param lock The SMP MCS lock control. + */ +static inline void _SMP_MCS_lock_Initialize( SMP_MCS_lock_Control *lock ) +{ + _Atomic_Init_uintptr( &lock->queue.atomic, 0 ); +} + +/** + * @brief Destroys an SMP MCS lock. + * + * Concurrent destruction leads to unpredictable results. + * + * @param lock The SMP MCS lock control. + */ +static inline void _SMP_MCS_lock_Destroy( SMP_MCS_lock_Control *lock ) +{ + (void) lock; +} + +static inline void _SMP_MCS_lock_Do_acquire( + SMP_MCS_lock_Control *lock, + SMP_MCS_lock_Context *context +#if defined(RTEMS_PROFILING) + , + SMP_lock_Stats *stats +#endif +) +{ + SMP_MCS_lock_Context *previous; +#if defined(RTEMS_PROFILING) + SMP_lock_Stats_acquire_context acquire_context; + + _SMP_lock_Stats_acquire_begin( &acquire_context ); + context->queue_length = 0; +#endif + + _Atomic_Store_uintptr( &context->next.atomic, 0, ATOMIC_ORDER_RELAXED ); + _Atomic_Store_uint( &context->locked, 1, ATOMIC_ORDER_RELAXED ); + + previous = (SMP_MCS_lock_Context *) _Atomic_Exchange_uintptr( + &lock->queue.atomic, + (uintptr_t) context, + ATOMIC_ORDER_ACQ_REL + ); + + if ( previous != NULL ) { + unsigned int locked; + + _Atomic_Store_uintptr( + &previous->next.atomic, + (uintptr_t) context, + ATOMIC_ORDER_RELAXED + ); + + do { + locked = _Atomic_Load_uint( &context->locked, ATOMIC_ORDER_ACQUIRE ); + } while ( locked != 0 ); + } + +#if defined(RTEMS_PROFILING) + _SMP_lock_Stats_acquire_end( + &acquire_context, + stats, + &context->Stats_context, + context->queue_length + ); +#endif +} + +/** + * @brief Acquires an SMP MCS lock. + * + * This function will not disable interrupts. The caller must ensure that the + * current thread of execution is not interrupted indefinite once it obtained + * the SMP MCS lock. + * + * @param lock The SMP MCS lock control. + * @param context The SMP MCS lock context. + * @param stats The SMP lock statistics. + */ +#if defined(RTEMS_PROFILING) + #define _SMP_MCS_lock_Acquire( lock, context, stats ) \ + _SMP_MCS_lock_Do_acquire( lock, context, stats ) +#else + #define _SMP_MCS_lock_Acquire( lock, context, stats ) \ + _SMP_MCS_lock_Do_acquire( lock, context ) +#endif + +/** + * @brief Releases an SMP MCS lock. + * + * @param lock The SMP MCS lock control. + * @param context The SMP MCS lock context. + */ +static inline void _SMP_MCS_lock_Release( + SMP_MCS_lock_Control *lock, + SMP_MCS_lock_Context *context +) +{ + SMP_MCS_lock_Context *next; + + next = (SMP_MCS_lock_Context *) _Atomic_Load_uintptr( + &context->next.atomic, + ATOMIC_ORDER_RELAXED + ); + + if ( next == NULL ) { + uintptr_t expected; + bool success; + + expected = (uintptr_t) context; + success = _Atomic_Compare_exchange_uintptr( + &lock->queue.atomic, + &expected, + 0, + ATOMIC_ORDER_RELEASE, + ATOMIC_ORDER_RELAXED + ); + + if ( success ) { +#if defined(RTEMS_PROFILING) + _SMP_lock_Stats_release_update( &context->Stats_context ); +#endif + /* Nobody waits. So, we are done */ + return; + } + + do { + next = (SMP_MCS_lock_Context *) _Atomic_Load_uintptr( + &context->next.atomic, + ATOMIC_ORDER_RELAXED + ); + } while ( next == NULL ); + } + +#if defined(RTEMS_PROFILING) + next->queue_length = context->queue_length + 1; + _SMP_lock_Stats_release_update( &context->Stats_context ); +#endif + + _Atomic_Store_uint( &next->locked, 0, ATOMIC_ORDER_RELEASE ); +} + +/**@}*/ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RTEMS_SMP */ + +#endif /* _RTEMS_SCORE_SMPLOCKMCS_H */ diff --git a/cpukit/include/rtems/score/smplockseq.h b/cpukit/include/rtems/score/smplockseq.h new file mode 100644 index 0000000000..5daaee9c6e --- /dev/null +++ b/cpukit/include/rtems/score/smplockseq.h @@ -0,0 +1,176 @@ +/** + * @file + * + * @ingroup ScoreSMPLock + * + * @brief SMP Lock API + */ + +/* + * Copyright (c) 2016 embedded brains GmbH + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SMPLOCKSEQ_H +#define _RTEMS_SCORE_SMPLOCKSEQ_H + +#include + +#if defined(RTEMS_SMP) + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @addtogroup ScoreSMPLock + * + * @{ + */ + +/** + * @brief SMP sequence lock control. + * + * The sequence lock offers a consistent data set for readers in the presence + * of at most one concurrent writer. Due to the read-modify-write operation in + * _SMP_sequence_lock_Read_retry() the data corresponding to the last written + * sequence number is observed. To allow multiple writers an additional SMP + * lock is necessary to serialize writes. + * + * See also Hans-J. Boehm, HP Laboratories, + * "Can Seqlocks Get Along With Programming Language Memory Models?", + * http://www.hpl.hp.com/techreports/2012/HPL-2012-68.pdf + */ +typedef struct { + /** + * @brief The sequence number. + * + * An odd value indicates that a write is in progress. + */ + Atomic_Uint sequence; +} SMP_sequence_lock_Control; + +/** + * @brief SMP sequence lock control initializer for static initialization. + */ +#define SMP_SEQUENCE_LOCK_INITIALIZER { ATOMIC_INITIALIZER_UINT( 0 ) } + +/** + * @brief Initializes an SMP sequence lock. + * + * Concurrent initialization leads to unpredictable results. + * + * @param lock The SMP sequence lock control. + */ +static inline void _SMP_sequence_lock_Initialize( SMP_sequence_lock_Control *lock ) +{ + _Atomic_Init_uint( &lock->sequence, 0 ); +} + +/** + * @brief Destroys an SMP sequence lock. + * + * Concurrent destruction leads to unpredictable results. + * + * @param lock The SMP sequence lock control. + */ +static inline void _SMP_sequence_lock_Destroy( SMP_sequence_lock_Control *lock ) +{ + (void) lock; +} + +/** + * @brief Begins an SMP sequence lock write operation. + * + * This function will not disable interrupts. The caller must ensure that the + * current thread of execution is not interrupted indefinite since this would + * starve readers. + * + * @param lock The SMP sequence lock control. + * + * @return The current sequence number. + */ +static inline unsigned int _SMP_sequence_lock_Write_begin( + SMP_sequence_lock_Control *lock +) +{ + unsigned int seq; + + seq = _Atomic_Load_uint( &lock->sequence, ATOMIC_ORDER_RELAXED ); + _Assert( seq % 2 == 0 ); + + _Atomic_Store_uint( &lock->sequence, seq + 1, ATOMIC_ORDER_RELAXED ); + + /* There is no atomic store with acquire/release semantics */ + _Atomic_Fence( ATOMIC_ORDER_ACQ_REL ); + + return seq; +} + +/** + * @brief Ends an SMP sequence lock write operation. + * + * @param lock The SMP sequence lock control. + * @param seq The sequence number returned by _SMP_sequence_lock_Write_begin(). + */ +static inline void _SMP_sequence_lock_Write_end( + SMP_sequence_lock_Control *lock, + unsigned int seq +) +{ + _Atomic_Store_uint( &lock->sequence, seq + 2, ATOMIC_ORDER_RELEASE ); +} + +/** + * @brief Begins an SMP sequence lock read operation. + * + * This function will not disable interrupts. + * + * @param lock The SMP sequence lock control. + * + * @return The current sequence number. + */ +static inline unsigned int _SMP_sequence_lock_Read_begin( + const SMP_sequence_lock_Control *lock +) +{ + return _Atomic_Load_uint( &lock->sequence, ATOMIC_ORDER_ACQUIRE ); +} + +/** + * @brief Ends an SMP sequence lock read operation and indicates if a retry is + * necessary. + * + * @param lock The SMP sequence lock control. + * @param seq The sequence number returned by _SMP_sequence_lock_Read_begin(). + * + * @retval true The read operation must be retried with a call to + * _SMP_sequence_lock_Read_begin(). + * @retval false Otherwise. + */ +static inline bool _SMP_sequence_lock_Read_retry( + SMP_sequence_lock_Control *lock, + unsigned int seq +) +{ + unsigned int seq2; + + seq2 = _Atomic_Fetch_add_uint( &lock->sequence, 0, ATOMIC_ORDER_RELEASE ); + return seq != seq2 || seq % 2 != 0; +} + +/**@}*/ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RTEMS_SMP */ + +#endif /* _RTEMS_SCORE_SMPLOCKSEQ_H */ diff --git a/cpukit/include/rtems/score/smplockstats.h b/cpukit/include/rtems/score/smplockstats.h new file mode 100644 index 0000000000..dd8e06c81d --- /dev/null +++ b/cpukit/include/rtems/score/smplockstats.h @@ -0,0 +1,277 @@ +/** + * @file + * + * @ingroup ScoreSMPLock + * + * @brief SMP Lock API + */ + +/* + * Copyright (c) 2013, 2016 embedded brains GmbH + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SMPLOCKSTATS_H +#define _RTEMS_SCORE_SMPLOCKSTATS_H + +#include + +#if defined(RTEMS_SMP) + +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @addtogroup ScoreSMPLock + * + * @{ + */ + +#if defined(RTEMS_PROFILING) + +/** + * @brief Count of lock contention counters for lock statistics. + */ +#define SMP_LOCK_STATS_CONTENTION_COUNTS 4 + +/** + * @brief SMP lock statistics. + * + * The lock acquire attempt instant is the point in time right after the + * interrupt disable action in the lock acquire sequence. + * + * The lock acquire instant is the point in time right after the lock + * acquisition. This is the begin of the critical section code execution. + * + * The lock release instant is the point in time right before the interrupt + * enable action in the lock release sequence. + * + * The lock section time is the time elapsed between the lock acquire instant + * and the lock release instant. + * + * The lock acquire time is the time elapsed between the lock acquire attempt + * instant and the lock acquire instant. + */ +typedef struct { + /** + * @brief Node for SMP lock statistics chain. + */ + Chain_Node Node; + + /** + * @brief The maximum lock acquire time in CPU counter ticks. + */ + CPU_Counter_ticks max_acquire_time; + + /** + * @brief The maximum lock section time in CPU counter ticks. + */ + CPU_Counter_ticks max_section_time; + + /** + * @brief The count of lock uses. + * + * This value may overflow. + */ + uint64_t usage_count; + + /** + * @brief Total lock acquire time in nanoseconds. + * + * The average lock acquire time is the total acquire time divided by the + * lock usage count. The ration of the total section and total acquire times + * gives a measure for the lock contention. + * + * This value may overflow. + */ + uint64_t total_acquire_time; + + /** + * @brief The counts of lock acquire operations by contention. + * + * The contention count for index N corresponds to a lock acquire attempt + * with an initial queue length of N. The last index corresponds to all + * lock acquire attempts with an initial queue length greater than or equal + * to SMP_LOCK_STATS_CONTENTION_COUNTS minus one. + * + * The values may overflow. + */ + uint64_t contention_counts[SMP_LOCK_STATS_CONTENTION_COUNTS]; + + /** + * @brief Total lock section time in CPU counter ticks. + * + * The average lock section time is the total section time divided by the + * lock usage count. + * + * This value may overflow. + */ + uint64_t total_section_time; + + /** + * @brief The lock name. + */ + const char *name; +} SMP_lock_Stats; + +/** + * @brief Local context for SMP lock statistics. + */ +typedef struct { + /** + * @brief The last lock acquire instant in CPU counter ticks. + * + * This value is used to measure the lock section time. + */ + CPU_Counter_ticks acquire_instant; + + /** + * @brief The lock stats used for the last lock acquire. + */ + SMP_lock_Stats *stats; +} SMP_lock_Stats_context; + +/** + * @brief SMP lock statistics initializer for static initialization. + */ +#define SMP_LOCK_STATS_INITIALIZER( name ) \ + { { NULL, NULL }, 0, 0, 0, 0, { 0, 0, 0, 0 }, 0, name } + +/** + * @brief Initializes an SMP lock statistics block. + * + * @param[in, out] stats The SMP lock statistics block. + * @param[in] name The name for the SMP lock statistics. This name must be + * persistent throughout the life time of this statistics block. + */ +static inline void _SMP_lock_Stats_initialize( + SMP_lock_Stats *stats, + const char *name +) +{ + SMP_lock_Stats init = SMP_LOCK_STATS_INITIALIZER( name ); + + *stats = init; +} + +/** + * @brief Destroys an SMP lock statistics block. + * + * @param[in] stats The SMP lock statistics block. + */ +void _SMP_lock_Stats_destroy( SMP_lock_Stats *stats ); + +void _SMP_lock_Stats_register( SMP_lock_Stats *stats ); + +typedef struct { + CPU_Counter_ticks first; +} SMP_lock_Stats_acquire_context; + +static inline void _SMP_lock_Stats_acquire_begin( + SMP_lock_Stats_acquire_context *acquire_context +) +{ + acquire_context->first = _CPU_Counter_read(); +} + +static inline void _SMP_lock_Stats_acquire_end( + const SMP_lock_Stats_acquire_context *acquire_context, + SMP_lock_Stats *stats, + SMP_lock_Stats_context *stats_context, + unsigned int queue_length +) +{ + CPU_Counter_ticks second; + CPU_Counter_ticks delta; + + second = _CPU_Counter_read(); + stats_context->acquire_instant = second; + delta = _CPU_Counter_difference( second, acquire_context->first ); + + ++stats->usage_count; + + stats->total_acquire_time += delta; + + if ( stats->max_acquire_time < delta ) { + stats->max_acquire_time = delta; + } + + if ( queue_length >= SMP_LOCK_STATS_CONTENTION_COUNTS ) { + queue_length = SMP_LOCK_STATS_CONTENTION_COUNTS - 1; + } + ++stats->contention_counts[ queue_length ]; + + stats_context->stats = stats; +} + +/** + * @brief Updates an SMP lock statistics block during a lock release. + * + * @param[in] stats_context The SMP lock statistics context. + */ +static inline void _SMP_lock_Stats_release_update( + const SMP_lock_Stats_context *stats_context +) +{ + SMP_lock_Stats *stats = stats_context->stats; + CPU_Counter_ticks first = stats_context->acquire_instant; + CPU_Counter_ticks second = _CPU_Counter_read(); + CPU_Counter_ticks delta = _CPU_Counter_difference( second, first ); + + stats->total_section_time += delta; + + if ( stats->max_section_time < delta ) { + stats->max_section_time = delta; + + if ( _Chain_Is_node_off_chain( &stats->Node ) ) { + _SMP_lock_Stats_register( stats ); + } + } +} + +typedef struct { + Chain_Node Node; + SMP_lock_Stats *current; +} SMP_lock_Stats_iteration_context; + +void _SMP_lock_Stats_iteration_start( + SMP_lock_Stats_iteration_context *iteration_context +); + + +bool _SMP_lock_Stats_iteration_next( + SMP_lock_Stats_iteration_context *iteration_context, + SMP_lock_Stats *snapshot, + char *name, + size_t name_size +); + +void _SMP_lock_Stats_iteration_stop( + SMP_lock_Stats_iteration_context *iteration_context +); + +#else /* RTEMS_PROFILING */ + +#define _SMP_lock_Stats_initialize( stats, name ) do { } while ( 0 ) + +#define _SMP_lock_Stats_destroy( stats ) do { } while ( 0 ) + +#endif /* !RTEMS_PROFILING */ + +/**@}*/ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RTEMS_SMP */ + +#endif /* _RTEMS_SCORE_SMPLOCKSTATS_H */ diff --git a/cpukit/include/rtems/score/smplockticket.h b/cpukit/include/rtems/score/smplockticket.h new file mode 100644 index 0000000000..e04c4056a5 --- /dev/null +++ b/cpukit/include/rtems/score/smplockticket.h @@ -0,0 +1,187 @@ +/** + * @file + * + * @ingroup ScoreSMPLock + * + * @brief SMP Lock API + */ + +/* + * Copyright (c) 2013, 2016 embedded brains GmbH + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SMPLOCKTICKET_H +#define _RTEMS_SCORE_SMPLOCKTICKET_H + +#include + +#if defined(RTEMS_SMP) + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @addtogroup ScoreSMPLock + * + * @{ + */ + +/** + * @brief SMP ticket lock control. + */ +typedef struct { + Atomic_Uint next_ticket; + Atomic_Uint now_serving; +} SMP_ticket_lock_Control; + +/** + * @brief SMP ticket lock control initializer for static initialization. + */ +#define SMP_TICKET_LOCK_INITIALIZER \ + { \ + ATOMIC_INITIALIZER_UINT( 0U ), \ + ATOMIC_INITIALIZER_UINT( 0U ) \ + } + +/** + * @brief Initializes an SMP ticket lock. + * + * Concurrent initialization leads to unpredictable results. + * + * @param[in] lock The SMP ticket lock control. + */ +static inline void _SMP_ticket_lock_Initialize( + SMP_ticket_lock_Control *lock +) +{ + _Atomic_Init_uint( &lock->next_ticket, 0U ); + _Atomic_Init_uint( &lock->now_serving, 0U ); +} + +/** + * @brief Destroys an SMP ticket lock. + * + * Concurrent destruction leads to unpredictable results. + * + * @param[in] lock The SMP ticket lock control. + */ +static inline void _SMP_ticket_lock_Destroy( SMP_ticket_lock_Control *lock ) +{ + (void) lock; +} + +static inline void _SMP_ticket_lock_Do_acquire( + SMP_ticket_lock_Control *lock +#if defined(RTEMS_PROFILING) + , + SMP_lock_Stats *stats, + SMP_lock_Stats_context *stats_context +#endif +) +{ + unsigned int my_ticket; + unsigned int now_serving; +#if defined(RTEMS_PROFILING) + unsigned int initial_queue_length; + SMP_lock_Stats_acquire_context acquire_context; + + _SMP_lock_Stats_acquire_begin( &acquire_context ); +#endif + + my_ticket = + _Atomic_Fetch_add_uint( &lock->next_ticket, 1U, ATOMIC_ORDER_RELAXED ); + +#if defined(RTEMS_PROFILING) + now_serving = + _Atomic_Load_uint( &lock->now_serving, ATOMIC_ORDER_ACQUIRE ); + initial_queue_length = my_ticket - now_serving; + + if ( initial_queue_length > 0 ) { +#endif + + do { + now_serving = + _Atomic_Load_uint( &lock->now_serving, ATOMIC_ORDER_ACQUIRE ); + } while ( now_serving != my_ticket ); + +#if defined(RTEMS_PROFILING) + } + + _SMP_lock_Stats_acquire_end( + &acquire_context, + stats, + stats_context, + initial_queue_length + ); +#endif +} + +/** + * @brief Acquires an SMP ticket lock. + * + * This function will not disable interrupts. The caller must ensure that the + * current thread of execution is not interrupted indefinite once it obtained + * the SMP ticket lock. + * + * @param[in] lock The SMP ticket lock control. + * @param[in] stats The SMP lock statistics. + * @param[out] stats_context The SMP lock statistics context. + */ +#if defined(RTEMS_PROFILING) + #define _SMP_ticket_lock_Acquire( lock, stats, stats_context ) \ + _SMP_ticket_lock_Do_acquire( lock, stats, stats_context ) +#else + #define _SMP_ticket_lock_Acquire( lock, stats, stats_context ) \ + _SMP_ticket_lock_Do_acquire( lock ) +#endif + +static inline void _SMP_ticket_lock_Do_release( + SMP_ticket_lock_Control *lock +#if defined(RTEMS_PROFILING) + , + const SMP_lock_Stats_context *stats_context +#endif +) +{ + unsigned int current_ticket = + _Atomic_Load_uint( &lock->now_serving, ATOMIC_ORDER_RELAXED ); + unsigned int next_ticket = current_ticket + 1U; + +#if defined(RTEMS_PROFILING) + _SMP_lock_Stats_release_update( stats_context ); +#endif + + _Atomic_Store_uint( &lock->now_serving, next_ticket, ATOMIC_ORDER_RELEASE ); +} + +/** + * @brief Releases an SMP ticket lock. + * + * @param[in] lock The SMP ticket lock control. + * @param[in] stats_context The SMP lock statistics context. + */ +#if defined(RTEMS_PROFILING) + #define _SMP_ticket_lock_Release( lock, stats_context ) \ + _SMP_ticket_lock_Do_release( lock, stats_context ) +#else + #define _SMP_ticket_lock_Release( lock, stats_context ) \ + _SMP_ticket_lock_Do_release( lock ) +#endif + +/**@}*/ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RTEMS_SMP */ + +#endif /* _RTEMS_SCORE_SMPLOCKTICKET_H */ diff --git a/cpukit/include/rtems/score/stack.h b/cpukit/include/rtems/score/stack.h new file mode 100644 index 0000000000..9622495092 --- /dev/null +++ b/cpukit/include/rtems/score/stack.h @@ -0,0 +1,69 @@ +/** + * @file rtems/score/stack.h + * + * @brief Information About the Thread Stack Handler + * + * This include file contains all information about the thread + * Stack Handler. This Handler provides mechanisms which can be used to + * initialize and utilize stacks. + */ + +/* + * COPYRIGHT (c) 1989-2006. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_STACK_H +#define _RTEMS_SCORE_STACK_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ScoreStack Stack Handler + * + * @ingroup Score + * + * This handler encapsulates functionality which is used in the management + * of thread stacks. + */ +/**@{*/ + +/** + * The following constant defines the minimum stack size which every + * thread must exceed. + */ +#define STACK_MINIMUM_SIZE CPU_STACK_MINIMUM_SIZE + +/** + * The following defines the control block used to manage each stack. + */ +typedef struct { + /** This is the stack size. */ + size_t size; + /** This is the low memory address of stack. */ + void *area; +} Stack_Control; + +/** + * This variable contains the the minimum stack size; + * + * @note It is instantiated and set by User Configuration via confdefs.h. + */ +extern uint32_t rtems_minimum_stack_size; + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/stackimpl.h b/cpukit/include/rtems/score/stackimpl.h new file mode 100644 index 0000000000..4c622345ff --- /dev/null +++ b/cpukit/include/rtems/score/stackimpl.h @@ -0,0 +1,99 @@ +/** + * @file + * + * @brief Inlined Routines from the Stack Handler + * + * This file contains the static inline implementation of the inlined + * routines from the Stack Handler. + */ + +/* + * COPYRIGHT (c) 1989-2006. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_STACKIMPL_H +#define _RTEMS_SCORE_STACKIMPL_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup ScoreStack + */ +/**@{**/ + +/** + * This routine initializes the_stack record to indicate that + * size bytes of memory starting at starting_address have been + * reserved for a stack. + */ +RTEMS_INLINE_ROUTINE void _Stack_Initialize ( + Stack_Control *the_stack, + void *starting_address, + size_t size +) +{ + the_stack->area = starting_address; + the_stack->size = size; +} + +/** + * This function returns the minimum stack size configured + * for this application. + * + * @return This method returns the minimum stack size; + */ +RTEMS_INLINE_ROUTINE uint32_t _Stack_Minimum (void) +{ + return rtems_minimum_stack_size; +} + +/** + * This function returns true if size bytes is enough memory for + * a valid stack area on this processor, and false otherwise. + * + * @param[in] size is the stack size to check + * + * @return This method returns true if the stack is large enough. + */ +RTEMS_INLINE_ROUTINE bool _Stack_Is_enough ( + size_t size +) +{ + return ( size >= _Stack_Minimum() ); +} + +/** + * This function returns the appropriate stack size given the requested + * size. If the requested size is below the minimum, then the minimum + * configured stack size is returned. + * + * @param[in] size is the stack size to check + * + * @return This method returns the appropriate stack size. + */ +RTEMS_INLINE_ROUTINE size_t _Stack_Ensure_minimum ( + size_t size +) +{ + if ( size >= _Stack_Minimum() ) + return size; + return _Stack_Minimum(); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/states.h b/cpukit/include/rtems/score/states.h new file mode 100644 index 0000000000..ba59af6907 --- /dev/null +++ b/cpukit/include/rtems/score/states.h @@ -0,0 +1,50 @@ +/** + * @file rtems/score/states.h + * + * @brief Thread Execution State Information + * + * This include file defines thread execution state information. + */ + +/* + * COPYRIGHT (c) 1989-2006. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_STATES_H +#define _RTEMS_SCORE_STATES_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ScoreStates SuperCore Thread States + * + * @ingroup Score + * + * This handler encapsulates functionality which relates to the management of + * the state bitmap associated with each thread. + */ +/**@{*/ + +/** + * The following type defines the control block used to manage a + * thread's state. + */ +typedef uint32_t States_Control; + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/statesimpl.h b/cpukit/include/rtems/score/statesimpl.h new file mode 100644 index 0000000000..db462fbb9a --- /dev/null +++ b/cpukit/include/rtems/score/statesimpl.h @@ -0,0 +1,283 @@ +/** + * @file + * + * @brief Inlined Routines Associated with Thread State Information + * + * This file contains the static inline implementation of the inlined + * routines associated with thread state information. + */ + +/* + * COPYRIGHT (c) 1989-2012. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_STATESIMPL_H +#define _RTEMS_SCORE_STATESIMPL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup ScoreStates + */ +/**@{**/ + +/* + * The following constants define the individual states which may be + * be used to compose and manipulate a thread's state. More frequently used + * states should use lower value bits to ease the use of immediate values on + * RISC architectures. + */ + +/** This macro corresponds to a task being ready. */ +#define STATES_READY 0x00000000 + +/** This macro corresponds to a task waiting for a mutex. */ +#define STATES_WAITING_FOR_MUTEX 0x00000001 + +/** This macro corresponds to a task waiting for a semaphore. */ +#define STATES_WAITING_FOR_SEMAPHORE 0x00000002 + +/** This macro corresponds to a task waiting for an event. */ +#define STATES_WAITING_FOR_EVENT 0x00000004 + +/** This macro corresponds to a task waiting for a system event. */ +#define STATES_WAITING_FOR_SYSTEM_EVENT 0x00000008 + +/** This macro corresponds to a task waiting for a message. */ +#define STATES_WAITING_FOR_MESSAGE 0x00000010 + +/** This macro corresponds to a task waiting for a condition variable. */ +#define STATES_WAITING_FOR_CONDITION_VARIABLE 0x00000020 + +/** This macro corresponds to a task waiting for a futex. */ +#define STATES_WAITING_FOR_FUTEX 0x00000040 + +/** This macro corresponds to a task waiting for BSD wakeup. */ +#define STATES_WAITING_FOR_BSD_WAKEUP 0x00000080 + +/** + * @brief This macro corresponds to a task which is waiting for a relative or + * absolute timeout. + */ +#define STATES_WAITING_FOR_TIME 0x00000100 + +/** This macro corresponds to a task waiting for a period. */ +#define STATES_WAITING_FOR_PERIOD 0x00000200 + +/** This macro corresponds to a task waiting for a signal. */ +#define STATES_WAITING_FOR_SIGNAL 0x00000400 + +/** This macro corresponds to a task waiting for a barrier. */ +#define STATES_WAITING_FOR_BARRIER 0x00000800 + +/** This macro corresponds to a task waiting for a RWLock. */ +#define STATES_WAITING_FOR_RWLOCK 0x00001000 + +/** This macro corresponds to a task waiting for a join while exiting. */ +#define STATES_WAITING_FOR_JOIN_AT_EXIT 0x00002000 + +/** This macro corresponds to a task waiting for a join. */ +#define STATES_WAITING_FOR_JOIN 0x00004000 + +/** This macro corresponds to a task being suspended. */ +#define STATES_SUSPENDED 0x00008000 + +/** This macro corresponds to a task waiting for a fixed size segment. */ +#define STATES_WAITING_FOR_SEGMENT 0x00010000 + +/** This macro corresponds to a task those life is changing. */ +#define STATES_LIFE_IS_CHANGING 0x00020000 + +/** This macro corresponds to a task being held by the debugger. */ +#define STATES_DEBUGGER 0x08000000 + +/** This macro corresponds to a task which is in an interruptible + * blocking state. + */ +#define STATES_INTERRUPTIBLE_BY_SIGNAL 0x10000000 + +/** This macro corresponds to a task waiting for a reply to an MPCI request. */ +#define STATES_WAITING_FOR_RPC_REPLY 0x20000000 + +/** This macro corresponds to a task being a zombie. */ +#define STATES_ZOMBIE 0x40000000 + +/** This macro corresponds to a task being created but not yet started. */ +#define STATES_DORMANT 0x80000000 + +/** This macro corresponds to a task waiting for a local object operation. */ +#define STATES_LOCALLY_BLOCKED ( STATES_WAITING_FOR_SEGMENT | \ + STATES_WAITING_FOR_MESSAGE | \ + STATES_WAITING_FOR_SEMAPHORE | \ + STATES_WAITING_FOR_MUTEX | \ + STATES_WAITING_FOR_CONDITION_VARIABLE | \ + STATES_WAITING_FOR_JOIN | \ + STATES_WAITING_FOR_SIGNAL | \ + STATES_WAITING_FOR_BARRIER | \ + STATES_WAITING_FOR_BSD_WAKEUP | \ + STATES_WAITING_FOR_FUTEX | \ + STATES_WAITING_FOR_RWLOCK ) + +/** This macro corresponds to a task waiting which is blocked. */ +#define STATES_BLOCKED ( STATES_LOCALLY_BLOCKED | \ + STATES_WAITING_FOR_TIME | \ + STATES_WAITING_FOR_PERIOD | \ + STATES_WAITING_FOR_EVENT | \ + STATES_WAITING_FOR_RPC_REPLY | \ + STATES_WAITING_FOR_SYSTEM_EVENT | \ + STATES_INTERRUPTIBLE_BY_SIGNAL ) + +/** All state bits set to one (provided for _Thread_Start()) */ +#define STATES_ALL_SET 0xffffffff + +/** + * This function sets the given states_to_set into the current_state + * passed in. The result is returned to the user in current_state. + * + * @param[in] states_to_set is the state bits to set + * @param[in] current_state is the state set to add them to + * + * @return This method returns the updated states value. + */ +RTEMS_INLINE_ROUTINE States_Control _States_Set ( + States_Control states_to_set, + States_Control current_state +) +{ + return (current_state | states_to_set); +} + +/** + * This function clears the given states_to_clear into the current_state + * passed in. The result is returned to the user in current_state. + * + * @param[in] states_to_clear is the state bits to clean + * @param[in] current_state is the state set to remove them from + * + * @return This method returns the updated states value. + */ +RTEMS_INLINE_ROUTINE States_Control _States_Clear ( + States_Control states_to_clear, + States_Control current_state +) +{ + return (current_state & ~states_to_clear); +} + +/** + * This function returns true if the_states indicates that the + * state is READY, and false otherwise. + * + * @param[in] the_states is the task state set to test + * + * @return This method returns true if the desired state condition is set. + */ +RTEMS_INLINE_ROUTINE bool _States_Is_ready ( + States_Control the_states +) +{ + return (the_states == STATES_READY); +} + +/** + * This function returns true if the DORMANT state is set in + * the_states, and false otherwise. + * + * @param[in] the_states is the task state set to test + * + * @return This method returns true if the desired state condition is set. + */ +RTEMS_INLINE_ROUTINE bool _States_Is_dormant ( + States_Control the_states +) +{ + return (the_states & STATES_DORMANT); +} + +/** + * This function returns true if the SUSPENDED state is set in + * the_states, and false otherwise. + * + * @param[in] the_states is the task state set to test + * + * @return This method returns true if the desired state condition is set. + */ +RTEMS_INLINE_ROUTINE bool _States_Is_suspended ( + States_Control the_states +) +{ + return (the_states & STATES_SUSPENDED); +} + +/** + * This function returns true if the WAITING_FOR_TIME state is set in + * the_states, and false otherwise. + * + * @param[in] the_states is the task state set to test + * + * @return This method returns true if the desired state condition is set. + */ +RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_rpc_reply ( + States_Control the_states +) +{ + return (the_states & STATES_WAITING_FOR_RPC_REPLY); +} + +RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_join_at_exit( + States_Control the_states +) +{ + return ( the_states & STATES_WAITING_FOR_JOIN_AT_EXIT ) != 0; +} + +/** + * This function returns true if the task's state is set in + * way that allows it to be interrupted by a signal. + * + * @param[in] the_states is the task state set to test + * + * @return This method returns true if the desired state condition is set. + */ +RTEMS_INLINE_ROUTINE bool _States_Is_interruptible_by_signal ( + States_Control the_states +) +{ + return (the_states & STATES_INTERRUPTIBLE_BY_SIGNAL); + +} +/** + * This function returns true if one of the states which indicates + * that a task is blocked waiting for a local resource is set in + * the_states, and false otherwise. + * + * @param[in] the_states is the task state set to test + * + * @return This method returns true if the desired state condition is set. + */ + +RTEMS_INLINE_ROUTINE bool _States_Is_locally_blocked ( + States_Control the_states +) +{ + return (the_states & STATES_LOCALLY_BLOCKED); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/status.h b/cpukit/include/rtems/score/status.h new file mode 100644 index 0000000000..5b154bb207 --- /dev/null +++ b/cpukit/include/rtems/score/status.h @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2016 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_STATUS_H +#define _RTEMS_SCORE_STATUS_H + +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @brief Status code parts for the Classic API. + * + * Must be in synchronization with rtems_status_code. + */ +typedef enum { + STATUS_CLASSIC_INCORRECT_STATE = 14, + STATUS_CLASSIC_INTERNAL_ERROR = 13, + STATUS_CLASSIC_INVALID_NUMBER = 10, + STATUS_CLASSIC_INVALID_PRIORITY = 19, + STATUS_CLASSIC_INVALID_SIZE = 8, + STATUS_CLASSIC_NO_MEMORY = 26, + STATUS_CLASSIC_NOT_DEFINED = 11, + STATUS_CLASSIC_NOT_OWNER_OF_RESOURCE = 23, + STATUS_CLASSIC_OBJECT_WAS_DELETED = 7, + STATUS_CLASSIC_RESOURCE_IN_USE = 12, + STATUS_CLASSIC_SUCCESSFUL = 0, + STATUS_CLASSIC_TIMEOUT = 6, + STATUS_CLASSIC_TOO_MANY = 5, + STATUS_CLASSIC_UNSATISFIED = 13 +} Status_Classic; + +/** + * @brief Macro to build a status code from Classic and POSIX API parts. + */ +#define STATUS_BUILD( classic_status, posix_status ) \ + ( ( ( (unsigned int) ( posix_status ) ) << 8 ) | ( classic_status ) ) + +/** + * @brief Macro to get the Classic API status code. + */ +#define STATUS_GET_CLASSIC( status ) \ + ( ( status ) & 0xff ) + +/** + * @brief Macro to get the POSIX API status code. + * + * Performs an arithmetic shift to reconstruct a negative POSIX status. + */ +#define STATUS_GET_POSIX( status ) \ + ( ( ( (int) ( status ) ) | 0xff ) >> 8 ) + +/** + * @brief Status codes. + */ +typedef enum { + STATUS_BARRIER_AUTOMATICALLY_RELEASED = + STATUS_BUILD( STATUS_CLASSIC_SUCCESSFUL, PTHREAD_BARRIER_SERIAL_THREAD ), + STATUS_DEADLOCK = + STATUS_BUILD( STATUS_CLASSIC_INCORRECT_STATE, EDEADLK ), + STATUS_FLUSHED = + STATUS_BUILD( STATUS_CLASSIC_UNSATISFIED, EAGAIN ), + STATUS_INCORRECT_STATE = + STATUS_BUILD( STATUS_CLASSIC_INCORRECT_STATE, EINVAL ), + STATUS_INTERRUPTED = + STATUS_BUILD( STATUS_CLASSIC_INTERNAL_ERROR, EINTR ), + STATUS_INVALID_NUMBER = + STATUS_BUILD( STATUS_CLASSIC_INVALID_NUMBER, EINVAL ), + STATUS_INVALID_PRIORITY = + STATUS_BUILD( STATUS_CLASSIC_INVALID_PRIORITY, EINVAL ), + STATUS_MAXIMUM_COUNT_EXCEEDED = + STATUS_BUILD( STATUS_CLASSIC_INTERNAL_ERROR, EOVERFLOW ), + STATUS_MESSAGE_INVALID_SIZE = + STATUS_BUILD( STATUS_CLASSIC_INVALID_SIZE, EMSGSIZE ), + STATUS_MESSAGE_QUEUE_WAIT_IN_ISR = + STATUS_BUILD( STATUS_CLASSIC_INTERNAL_ERROR, ENOMEM ), + STATUS_MESSAGE_QUEUE_WAS_DELETED = + STATUS_BUILD( STATUS_CLASSIC_OBJECT_WAS_DELETED, EBADF ), + STATUS_MINUS_ONE = + -1, + STATUS_MUTEX_CEILING_VIOLATED = + STATUS_BUILD( STATUS_CLASSIC_INVALID_PRIORITY, EINVAL ), + STATUS_NESTING_NOT_ALLOWED = + STATUS_BUILD( STATUS_CLASSIC_UNSATISFIED, EDEADLK ), + STATUS_NO_MEMORY = + STATUS_BUILD( STATUS_CLASSIC_NO_MEMORY, EINVAL ), + STATUS_NOT_DEFINED = + STATUS_BUILD( STATUS_CLASSIC_NOT_DEFINED, EINVAL ), + STATUS_NOT_OWNER = + STATUS_BUILD( STATUS_CLASSIC_NOT_OWNER_OF_RESOURCE, EPERM ), + STATUS_OBJECT_WAS_DELETED = + STATUS_BUILD( STATUS_CLASSIC_OBJECT_WAS_DELETED, EINVAL ), + STATUS_RESOURCE_IN_USE = + STATUS_BUILD( STATUS_CLASSIC_RESOURCE_IN_USE, EBUSY ), + STATUS_RESULT_TOO_LARGE = + STATUS_BUILD( STATUS_CLASSIC_UNSATISFIED, ERANGE ), + STATUS_SUCCESSFUL = + STATUS_BUILD( STATUS_CLASSIC_SUCCESSFUL, 0 ), + STATUS_TIMEOUT = + STATUS_BUILD( STATUS_CLASSIC_TIMEOUT, ETIMEDOUT ), + STATUS_TOO_MANY = + STATUS_BUILD( STATUS_CLASSIC_TOO_MANY, EAGAIN ), + STATUS_UNAVAILABLE = + STATUS_BUILD( STATUS_CLASSIC_UNSATISFIED, EBUSY ), + STATUS_UNSATISFIED = + STATUS_BUILD( STATUS_CLASSIC_UNSATISFIED, EAGAIN ) +} Status_Control; + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_SCORE_STATUS_H */ diff --git a/cpukit/include/rtems/score/sysstate.h b/cpukit/include/rtems/score/sysstate.h new file mode 100644 index 0000000000..0e01927d9a --- /dev/null +++ b/cpukit/include/rtems/score/sysstate.h @@ -0,0 +1,119 @@ +/** + * @file + * + * @ingroup ScoreSysState + * + * @brief System State Handler API + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SYSSTATE_H +#define _RTEMS_SCORE_SYSSTATE_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ScoreSysState System State Handler + * + * @ingroup Score + * + * @brief Management of the internal system state of RTEMS. + */ +/**@{**/ + +/** + * @brief System states. + */ +typedef enum { + /** + * @brief The system is before the end of the first phase of initialization. + */ + SYSTEM_STATE_BEFORE_INITIALIZATION, + + /** + * @brief The system is between end of the first phase of initialization but + * before multitasking is started. + */ + SYSTEM_STATE_BEFORE_MULTITASKING, + + /** + * @brief The system is up and operating normally. + */ + SYSTEM_STATE_UP, + + /** + * @brief The system reached its terminal state. + */ + SYSTEM_STATE_TERMINATED +} System_state_Codes; + +#define SYSTEM_STATE_CODES_FIRST SYSTEM_STATE_BEFORE_INITIALIZATION + +#define SYSTEM_STATE_CODES_LAST SYSTEM_STATE_TERMINATED + +#if defined(RTEMS_MULTIPROCESSING) +extern bool _System_state_Is_multiprocessing; +#endif + +extern System_state_Codes _System_state_Current; + +RTEMS_INLINE_ROUTINE void _System_state_Set ( + System_state_Codes state +) +{ + _System_state_Current = state; +} + +RTEMS_INLINE_ROUTINE System_state_Codes _System_state_Get ( void ) +{ + return _System_state_Current; +} + +RTEMS_INLINE_ROUTINE bool _System_state_Is_before_initialization ( + System_state_Codes state +) +{ + return (state == SYSTEM_STATE_BEFORE_INITIALIZATION); +} + +RTEMS_INLINE_ROUTINE bool _System_state_Is_before_multitasking ( + System_state_Codes state +) +{ + return (state == SYSTEM_STATE_BEFORE_MULTITASKING); +} + +RTEMS_INLINE_ROUTINE bool _System_state_Is_up ( + System_state_Codes state +) +{ + return (state == SYSTEM_STATE_UP); +} + +RTEMS_INLINE_ROUTINE bool _System_state_Is_terminated ( + System_state_Codes state +) +{ + return (state == SYSTEM_STATE_TERMINATED); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/thread.h b/cpukit/include/rtems/score/thread.h new file mode 100644 index 0000000000..7e0e2722dd --- /dev/null +++ b/cpukit/include/rtems/score/thread.h @@ -0,0 +1,935 @@ +/** + * @file rtems/score/thread.h + * + * @brief Constants and Structures Related with the Thread Control Block + * + * This include file contains all constants and structures associated + * with the thread control block. + */ + +/* + * COPYRIGHT (c) 1989-2014. + * On-Line Applications Research Corporation (OAR). + * + * Copyright (c) 2014, 2016 embedded brains GmbH. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_THREAD_H +#define _RTEMS_SCORE_THREAD_H + +#include +#include +#if defined(RTEMS_MULTIPROCESSING) +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(RTEMS_SMP) +#include +#endif + +struct _pthread_cleanup_context; + +struct Per_CPU_Control; + +struct _Scheduler_Control; + +struct User_extensions_Iterator; + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ScoreThread Thread Handler + * + * @ingroup Score + * + * This handler encapsulates functionality related to the management of + * threads. This includes the creation, deletion, and scheduling of threads. + * + * The following variables are maintained as part of the per cpu data + * structure. + * + * + Idle thread pointer + * + Executing thread pointer + * + Heir thread pointer + */ +/**@{*/ + +#if defined(RTEMS_POSIX_API) + #define RTEMS_SCORE_THREAD_ENABLE_EXHAUST_TIMESLICE +#endif + +/* + * With the addition of the Constant Block Scheduler (CBS), + * this feature is needed even when POSIX is disabled. + */ +#define RTEMS_SCORE_THREAD_ENABLE_SCHEDULER_CALLOUT + +#if defined(RTEMS_POSIX_API) + #define RTEMS_SCORE_THREAD_ENABLE_USER_PROVIDED_STACK_VIA_API +#endif + +#if defined(RTEMS_DEBUG) +#define RTEMS_SCORE_THREAD_ENABLE_RESOURCE_COUNT +#endif + +/* + * Only provided for backward compatiblity to not break application + * configurations. + */ +typedef void *Thread RTEMS_DEPRECATED; + +/** + * @brief Type of the numeric argument of a thread entry function with at + * least one numeric argument. + * + * This numeric argument type designates an unsigned integer type with the + * property that any valid pointer to void can be converted to this type and + * then converted back to a pointer to void. The result will compare equal to + * the original pointer. + */ +typedef CPU_Uint32ptr Thread_Entry_numeric_type; + +/** + * @brief Data for idle thread entry. + */ +typedef struct { + void *( *entry )( uintptr_t argument ); +} Thread_Entry_idle; + +/** + * @brief Data for thread entry with one numeric argument and no return value. + */ +typedef struct { + void ( *entry )( Thread_Entry_numeric_type argument ); + Thread_Entry_numeric_type argument; +} Thread_Entry_numeric; + +/** + * @brief Data for thread entry with one pointer argument and a pointer return + * value. + */ +typedef struct { + void *( *entry )( void *argument ); + void *argument; +} Thread_Entry_pointer; + +/** + * @brief Thread entry information. + */ +typedef struct { + /** + * @brief Thread entry adaptor. + * + * Calls the corresponding thread entry with the right parameters. + * + * @param executing The executing thread. + */ + void ( *adaptor )( Thread_Control *executing ); + + /** + * @brief Thread entry data used by the adaptor to call the thread entry + * function with the right parameters. + */ + union { + Thread_Entry_idle Idle; + Thread_Entry_numeric Numeric; + Thread_Entry_pointer Pointer; + } Kinds; +} Thread_Entry_information; + +/** + * The following lists the algorithms used to manage the thread cpu budget. + * + * Reset Timeslice: At each context switch, reset the time quantum. + * Exhaust Timeslice: Only reset the quantum once it is consumed. + * Callout: Execute routine when budget is consumed. + */ +typedef enum { + THREAD_CPU_BUDGET_ALGORITHM_NONE, + THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE, + #if defined(RTEMS_SCORE_THREAD_ENABLE_EXHAUST_TIMESLICE) + THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE, + #endif + #if defined(RTEMS_SCORE_THREAD_ENABLE_SCHEDULER_CALLOUT) + THREAD_CPU_BUDGET_ALGORITHM_CALLOUT + #endif +} Thread_CPU_budget_algorithms; + +/** This defines thes the entry point for the thread specific timeslice + * budget management algorithm. + */ +typedef void (*Thread_CPU_budget_algorithm_callout )( Thread_Control * ); + +/** + * The following structure contains the information which defines + * the starting state of a thread. + */ +typedef struct { + /** This field contains the thread entry information. */ + Thread_Entry_information Entry; + /*-------------- initial execution modes ----------------- */ + /** This field indicates whether the thread was preemptible when + * it started. + */ + bool is_preemptible; + /** This field indicates the CPU budget algorith. */ + Thread_CPU_budget_algorithms budget_algorithm; + /** This field is the routine to invoke when the CPU allotment is + * consumed. + */ + Thread_CPU_budget_algorithm_callout budget_callout; + /** This field is the initial ISR disable level of this thread. */ + uint32_t isr_level; + /** This field is the initial priority. */ + Priority_Control initial_priority; + #if defined(RTEMS_SCORE_THREAD_ENABLE_USER_PROVIDED_STACK_VIA_API) + /** This field indicates whether the SuperCore allocated the stack. */ + bool core_allocated_stack; + #endif + /** This field is the stack information. */ + Stack_Control Initial_stack; + #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) + /** This field is the initial FP context area address. */ + Context_Control_fp *fp_context; + #endif + /** This field is the initial stack area address. */ + void *stack; + /** The thread-local storage (TLS) area */ + void *tls_area; +} Thread_Start_information; + +#if defined(RTEMS_SMP) +/** + * @brief The thread state with respect to the scheduler. + */ +typedef enum { + /** + * @brief This thread is blocked with respect to the scheduler. + * + * This thread uses no scheduler nodes. + */ + THREAD_SCHEDULER_BLOCKED, + + /** + * @brief This thread is scheduled with respect to the scheduler. + * + * This thread executes using one of its scheduler nodes. This could be its + * own scheduler node or in case it owns resources taking part in the + * scheduler helping protocol a scheduler node of another thread. + */ + THREAD_SCHEDULER_SCHEDULED, + + /** + * @brief This thread is ready with respect to the scheduler. + * + * None of the scheduler nodes of this thread is scheduled. + */ + THREAD_SCHEDULER_READY +} Thread_Scheduler_state; +#endif + +/** + * @brief Thread scheduler control. + */ +typedef struct { +#if defined(RTEMS_SMP) + /** + * @brief Lock to protect the scheduler node change requests. + */ + ISR_lock_Control Lock; + + /** + * @brief The current scheduler state of this thread. + */ + Thread_Scheduler_state state; + + /** + * @brief The home scheduler control of this thread. + */ + const struct _Scheduler_Control *home; + + /** + * @brief The processor assigned by the current scheduler. + */ + struct Per_CPU_Control *cpu; + + /** + * @brief Scheduler nodes immediately available to the thread by its home + * scheduler instance and due to thread queue ownerships. + * + * This chain is protected by the thread wait lock. + * + * This chain is never empty. The first scheduler node on the chain is the + * scheduler node of the home scheduler instance. + */ + Chain_Control Wait_nodes; + + /** + * @brief Scheduler nodes immediately available to the schedulers for this + * thread. + * + * This chain is protected by the thread state lock. + * + * This chain is never empty. The first scheduler node on the chain is the + * scheduler node of the home scheduler instance. + */ + Chain_Control Scheduler_nodes; + + /** + * @brief Node for the Per_CPU_Control::Threads_in_need_for_help chain. + * + * This chain is protected by the Per_CPU_Control::Lock lock of the assigned + * processor. + */ + Chain_Node Help_node; + + /** + * @brief Count of nodes scheduler nodes minus one. + * + * This chain is protected by the thread state lock. + */ + size_t helping_nodes; + + /** + * @brief List of pending scheduler node requests. + * + * This list is protected by the thread scheduler lock. + */ + Scheduler_Node *requests; + + /** + * @brief The thread processor affinity set. + */ + Processor_mask Affinity; +#endif + + /** + * @brief The scheduler nodes of this thread. + * + * Each thread has a scheduler node for each scheduler instance. + */ + Scheduler_Node *nodes; +} Thread_Scheduler_control; + +/** + * @brief Union type to hold a pointer to an immutable or a mutable object. + * + * The main purpose is to enable passing of pointers to read-only send buffers + * in the message passing subsystem. This approach is somewhat fragile since + * it prevents the compiler to check if the operations on objects are valid + * with respect to the constant qualifier. An alternative would be to add a + * third pointer argument for immutable objects, but this would increase the + * structure size. + */ +typedef union { + void *mutable_object; + const void *immutable_object; +} Thread_Wait_information_Object_argument_type; + +/** + * @brief This type is able to contain several flags used to control the wait + * class and state of a thread. + * + * The mutually exclusive wait class flags are + * - @ref THREAD_WAIT_CLASS_EVENT, + * - @ref THREAD_WAIT_CLASS_SYSTEM_EVENT, and + * - @ref THREAD_WAIT_CLASS_OBJECT. + * + * The mutually exclusive wait state flags are + * - @ref THREAD_WAIT_STATE_INTEND_TO_BLOCK, + * - @ref THREAD_WAIT_STATE_BLOCKED, and + * - @ref THREAD_WAIT_STATE_READY_AGAIN. + */ +typedef unsigned int Thread_Wait_flags; + +/** + * @brief Information required to manage a thread while it is blocked. + * + * This contains the information required to manage a thread while it is + * blocked and to return information to it. + */ +typedef struct { +#if defined(RTEMS_MULTIPROCESSING) + /* + * @brief This field is the identifier of the remote object this thread is + * waiting upon. + */ + Objects_Id remote_id; +#endif + /** This field is used to return an integer while when blocked. */ + uint32_t count; + /** This field is for a pointer to a user return argument. */ + void *return_argument; + /** This field is for a pointer to a second user return argument. */ + Thread_Wait_information_Object_argument_type + return_argument_second; + /** This field contains any options in effect on this blocking operation. */ + uint32_t option; + /** This field will contain the return status from a blocking operation. + * + * @note The following assumes that all API return codes can be + * treated as an uint32_t. + */ + uint32_t return_code; + + /** + * @brief This field contains several flags used to control the wait class + * and state of a thread in case fine-grained locking is used. + */ +#if defined(RTEMS_SMP) + Atomic_Uint flags; +#else + Thread_Wait_flags flags; +#endif + +#if defined(RTEMS_SMP) + /** + * @brief Thread wait lock control block. + * + * Parts of the thread wait information are protected by the thread wait + * default lock and additionally a thread queue lock in case the thread + * is enqueued on a thread queue. + * + * The thread wait lock mechanism protects the following thread variables + * - POSIX_API_Control::Attributes, + * - Scheduler_Node::Wait, + * - Thread_Control::Wait::Lock::Pending_requests, + * - Thread_Control::Wait::queue, and + * - Thread_Control::Wait::operations. + * + * @see _Thread_Wait_acquire(), _Thread_Wait_release(), _Thread_Wait_claim(), + * _Thread_Wait_restore_default() and _Thread_Wait_tranquilize(). + */ + struct { + /** + * @brief Thread wait default lock. + */ + ISR_lock_Control Default; + + /** + * @brief The pending thread wait lock acquire or tranquilize requests in + * case the thread is enqueued on a thread queue. + */ + Chain_Control Pending_requests; + + /** + * @brief Tranquilizer gate used by _Thread_Wait_tranquilize(). + * + * This gate is closed by _Thread_Wait_claim(). In case there are no + * pending requests during a _Thread_Wait_restore_default(), then this gate + * is opened immediately, otherwise it is placed on the pending request + * chain and opened by _Thread_Wait_remove_request_locked() as the last + * gate on the chain to signal overall request completion. + */ + Thread_queue_Gate Tranquilizer; + } Lock; + + /** + * @brief Thread queue link provided for use by the thread wait lock owner to + * build a thread queue path. + */ + Thread_queue_Link Link; +#endif + + /** + * @brief The current thread queue. + * + * If this field is NULL the thread is not enqueued on a thread queue. This + * field is protected by the thread wait default lock. + * + * @see _Thread_Wait_claim(). + */ + Thread_queue_Queue *queue; + + /** + * @brief The current thread queue operations. + * + * This field is protected by the thread lock wait default lock. + * + * @see _Thread_Wait_claim(). + */ + const Thread_queue_Operations *operations; + + Thread_queue_Heads *spare_heads; +} Thread_Wait_information; + +/** + * @brief Information required to manage a thread timer. + */ +typedef struct { + ISR_LOCK_MEMBER( Lock ) + Watchdog_Header *header; + Watchdog_Control Watchdog; +} Thread_Timer_information; + +/** + * The following defines the control block used to manage + * each thread proxy. + * + * @note It is critical that proxies and threads have identical + * memory images for the shared part. + */ +typedef struct { + /** This field is the object management structure for each proxy. */ + Objects_Control Object; + + /** + * @see Thread_Control::Join_queue + */ + Thread_queue_Control Join_queue; + + /** This field is the current execution state of this proxy. */ + States_Control current_state; + + /** + * @brief The base priority of this thread in its home scheduler instance. + */ + Priority_Node Real_priority; + +#if defined(RTEMS_SCORE_THREAD_ENABLE_RESOURCE_COUNT) + /** This field is the number of mutexes currently held by this proxy. */ + uint32_t resource_count; +#endif + + /** + * @brief Scheduler related control. + */ + Thread_Scheduler_control Scheduler; + + /** This field is the blocking information for this proxy. */ + Thread_Wait_information Wait; + /** This field is the Watchdog used to manage proxy delays and timeouts. */ + Thread_Timer_information Timer; +#if defined(RTEMS_MULTIPROCESSING) + /** This field is the received response packet in an MP system. */ + MP_packet_Prefix *receive_packet; + /****************** end of common block ********************/ + + /** + * @brief Thread queue callout for _Thread_queue_Enqueue(). + */ + Thread_queue_MP_callout thread_queue_callout; + + /** + * @brief This field is used to manage the set of active proxies in the system. + */ + RBTree_Node Active; + + /** + * @brief The scheduler node providing the thread wait nodes used to enqueue + * this thread proxy on a thread queue. + */ + Scheduler_Node Scheduler_node; + + /** + * @brief Provide thread queue heads for this thread proxy. + * + * The actual size of the thread queue heads depends on the application + * configuration. Since thread proxies are never destroyed we can use the + * same storage place for the thread queue heads. + */ + Thread_queue_Heads Thread_queue_heads[ RTEMS_ZERO_LENGTH_ARRAY ]; +#endif +} Thread_Proxy_control; + +/** + * The following record defines the control block used + * to manage each thread. + * + * @note It is critical that proxies and threads have identical + * memory images for the shared part. + */ +typedef enum { + /** This value is for the Classic RTEMS API. */ + THREAD_API_RTEMS, + /** This value is for the POSIX API. */ + THREAD_API_POSIX +} Thread_APIs; + +/** This macro defines the first API which has threads. */ +#define THREAD_API_FIRST THREAD_API_RTEMS + +/** This macro defines the last API which has threads. */ +#define THREAD_API_LAST THREAD_API_POSIX + +typedef struct Thread_Action Thread_Action; + +/** + * @brief Thread action handler. + * + * The thread action handler will be called with interrupts disabled and a + * corresponding lock acquired, e.g. _Thread_State_acquire(). The handler must + * release the corresponding lock, e.g. _Thread_State_release(). So, the + * corresponding lock may be used to protect private data used by the + * particular action. + * + * Since the action is passed to the handler additional data may be accessed + * via RTEMS_CONTAINER_OF(). + * + * @param[in] the_thread The thread performing the action. + * @param[in] action The thread action. + * @param[in] lock_context The lock context to use for the lock release. + */ +typedef void ( *Thread_Action_handler )( + Thread_Control *the_thread, + Thread_Action *action, + ISR_lock_Context *lock_context +); + +/** + * @brief Thread action. + * + * Thread actions can be chained together to trigger a set of actions on + * particular events like for example a thread post-switch. Use + * _Thread_Action_initialize() to initialize this structure. + * + * Thread actions are the building block for efficient implementation of + * - Classic signals delivery, + * - POSIX signals delivery, and + * - thread life-cycle changes. + * + * @see _Thread_Add_post_switch_action() and _Thread_Run_post_switch_actions(). + */ +struct Thread_Action { + Chain_Node Node; + Thread_Action_handler handler; +}; + +/** + * @brief Per-thread information for POSIX Keys. + */ +typedef struct { + /** + * @brief Key value pairs registered for this thread. + */ + RBTree_Control Key_value_pairs; + + /** + * @brief Lock to protect the tree operations. + */ + ISR_LOCK_MEMBER( Lock ) +} Thread_Keys_information; + +/** + * @brief Control block to manage thread actions. + * + * Use _Thread_Action_control_initialize() to initialize this structure. + */ +typedef struct { + Chain_Control Chain; +} Thread_Action_control; + +/** + * @brief Thread life states. + * + * The thread life states are orthogonal to the thread states used for + * synchronization primitives and blocking operations. They reflect the state + * changes triggered with thread restart and delete requests. + * + * The individual state values must be a power of two to allow use of bit + * operations to manipulate and evaluate the thread life state. + */ +typedef enum { + THREAD_LIFE_PROTECTED = 0x1, + THREAD_LIFE_RESTARTING = 0x2, + THREAD_LIFE_TERMINATING = 0x4, + THREAD_LIFE_CHANGE_DEFERRED = 0x8, + THREAD_LIFE_DETACHED = 0x10 +} Thread_Life_state; + +/** + * @brief Thread life control. + */ +typedef struct { + /** + * @brief Thread life action used to react upon thread restart and delete + * requests. + */ + Thread_Action Action; + + /** + * @brief The current thread life state. + */ + Thread_Life_state state; + + /** + * @brief The count of pending life change requests. + */ + uint32_t pending_life_change_requests; + +#if defined(RTEMS_POSIX_API) + /** + * @brief The thread exit value. + * + * It is, + * - the value passed to pthread_exit(), or + * - PTHREAD_CANCELED in case it is cancelled via pthread_cancel(), or + * - NULL. + */ + void *exit_value; +#endif +} Thread_Life_control; + +typedef struct { + uint32_t flags; + void * control; +}Thread_Capture_control; + +/** + * This structure defines the Thread Control Block (TCB). + * + * Uses a leading underscore in the structure name to allow forward + * declarations in standard header files provided by Newlib and GCC. + * + * In case the second member changes (currently Join_queue), then the memset() + * in _Thread_Initialize() must be adjusted. + */ +struct _Thread_Control { + /** This field is the object management structure for each thread. */ + Objects_Control Object; + + /** + * @brief Thread queue for thread join operations and multi-purpose lock. + * + * The lock of this thread queue is used for various purposes. It protects + * the following fields + * + * - RTEMS_API_Control::Signal, + * - Thread_Control::budget_algorithm, + * - Thread_Control::budget_callout, + * - Thread_Control::cpu_time_budget, + * - Thread_Control::current_state, + * - Thread_Control::Post_switch_actions, + * - Thread_Control::Scheduler::control, and + * - Thread_Control::Scheduler::own_control. + * + * @see _Thread_State_acquire(). + */ + Thread_queue_Control Join_queue; + + /** This field is the current execution state of this thread. */ + States_Control current_state; + + /** + * @brief The base priority of this thread in its home scheduler instance. + */ + Priority_Node Real_priority; + +#if defined(RTEMS_SCORE_THREAD_ENABLE_RESOURCE_COUNT) + /** This field is the number of mutexes currently held by this thread. */ + uint32_t resource_count; +#endif + + /** + * @brief Scheduler related control. + */ + Thread_Scheduler_control Scheduler; + + /** This field is the blocking information for this thread. */ + Thread_Wait_information Wait; + /** This field is the Watchdog used to manage thread delays and timeouts. */ + Thread_Timer_information Timer; +#if defined(RTEMS_MULTIPROCESSING) + /** This field is the received response packet in an MP system. */ + MP_packet_Prefix *receive_packet; +#endif + /*================= end of common block =================*/ + +#if defined(RTEMS_SMP) && defined(RTEMS_PROFILING) + /** + * @brief Potpourri lock statistics. + * + * These SMP lock statistics are used for all lock objects that lack a + * storage space for the statistics. Examples are lock objects used in + * external libraries which are independent of the actual RTEMS build + * configuration. + */ + SMP_lock_Stats Potpourri_stats; +#endif + + /** This field is true if the thread is an idle thread. */ + bool is_idle; +#if defined(RTEMS_MULTIPROCESSING) + /** This field is true if the thread is offered globally */ + bool is_global; +#endif + /** This field is true if the thread is preemptible. */ + bool is_preemptible; + /** This field is true if the thread uses the floating point unit. */ + bool is_fp; + + /** + * @brief True, if the thread was created with an inherited scheduler + * (PTHREAD_INHERIT_SCHED), and false otherwise. + */ + bool was_created_with_inherited_scheduler; + + /** This field is the length of the time quantum that this thread is + * allowed to consume. The algorithm used to manage limits on CPU usage + * is specified by budget_algorithm. + */ + uint32_t cpu_time_budget; + /** This field is the algorithm used to manage this thread's time + * quantum. The algorithm may be specified as none which case, + * no limit is in place. + */ + Thread_CPU_budget_algorithms budget_algorithm; + /** This field is the method invoked with the budgeted time is consumed. */ + Thread_CPU_budget_algorithm_callout budget_callout; + /** This field is the amount of CPU time consumed by this thread + * since it was created. + */ + Timestamp_Control cpu_time_used; + + /** This field contains information about the starting state of + * this thread. + */ + Thread_Start_information Start; + + Thread_Action_control Post_switch_actions; + + /** This field contains the context of this thread. */ + Context_Control Registers; +#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) + /** This field points to the floating point context for this thread. + * If NULL, the thread is integer only. + */ + Context_Control_fp *fp_context; +#endif + /** This field points to the newlib reentrancy structure for this thread. */ + struct _reent *libc_reent; + /** This array contains the API extension area pointers. */ + void *API_Extensions[ THREAD_API_LAST + 1 ]; + + /** + * @brief The POSIX Keys information. + */ + Thread_Keys_information Keys; + + /** + * @brief Thread life-cycle control. + * + * Control state changes triggered by thread restart and delete requests. + */ + Thread_Life_control Life; + + Thread_Capture_control Capture; + + /** + * @brief LIFO list of POSIX cleanup contexts. + */ + struct _pthread_cleanup_context *last_cleanup_context; + + /** + * @brief LIFO list of user extensions iterators. + */ + struct User_extensions_Iterator *last_user_extensions_iterator; + + /** + * @brief Variable length array of user extension pointers. + * + * The length is defined by the application via . + */ + void *extensions[ RTEMS_ZERO_LENGTH_ARRAY ]; +}; + +#if (CPU_PROVIDES_IDLE_THREAD_BODY == FALSE) +/** + * This routine is the body of the system idle thread. + * + * NOTE: This routine is actually instantiated by confdefs.h when needed. + */ +void *_Thread_Idle_body( + uintptr_t ignored +); +#endif + +typedef void (*rtems_per_thread_routine)( Thread_Control * ); + +/* Use rtems_task_iterate() instead */ +void rtems_iterate_over_all_threads( + rtems_per_thread_routine routine +) RTEMS_DEPRECATED; + +/** + * @brief Thread control add-on. + */ +typedef struct { + /** + * @brief Offset of the pointer field in Thread_Control referencing an + * application configuration dependent memory area in the thread control + * block. + */ + size_t destination_offset; + + /** + * @brief Offset relative to the thread control block begin to an application + * configuration dependent memory area. + */ + size_t source_offset; +} Thread_Control_add_on; + +/** + * @brief Thread control add-ons. + * + * The thread control block contains fields that point to application + * configuration dependent memory areas, like the scheduler information, the + * API control blocks, the user extension context table, and the Newlib + * re-entrancy support. Account for these areas in the configuration and + * avoid extra workspace allocations for these areas. + * + * This array is provided via . + * + * @see _Thread_Control_add_on_count and _Thread_Control_size. + */ +extern const Thread_Control_add_on _Thread_Control_add_ons[]; + +/** + * @brief Thread control add-on count. + * + * Count of entries in _Thread_Control_add_ons. + * + * This value is provided via . + */ +extern const size_t _Thread_Control_add_on_count; + +/** + * @brief Size of the thread control block of a particular application. + * + * This value is provided via . + * + * @see _Thread_Control_add_ons. + */ +extern const size_t _Thread_Control_size; + +/** + * @brief Maximum size of a thread name in characters (including the + * terminating '\0' character). + * + * This value is provided via . + */ +extern const size_t _Thread_Maximum_name_size; + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/threaddispatch.h b/cpukit/include/rtems/score/threaddispatch.h new file mode 100644 index 0000000000..63eb4c6fb4 --- /dev/null +++ b/cpukit/include/rtems/score/threaddispatch.h @@ -0,0 +1,281 @@ +/** + * @brief Constants and Structures Related with Thread Dispatch + */ + +/* + * COPYRIGHT (c) 1989-2009. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_THREADDISPATCH_H +#define _RTEMS_SCORE_THREADDISPATCH_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @addtogroup ScoreThread + * + * @{ + */ + +#if defined(RTEMS_SMP) || ( CPU_ENABLE_ROBUST_THREAD_DISPATCH == TRUE ) +/** + * @brief Enables a robust thread dispatch. + * + * On each change of the thread dispatch disable level from one to zero the + * interrupt status is checked. In case interrupts are disabled and SMP is + * enabled or the CPU port needs it, then the system terminates with the fatal + * internal error INTERNAL_ERROR_BAD_THREAD_DISPATCH_ENVIRONMENT. + */ +#define RTEMS_SCORE_ROBUST_THREAD_DISPATCH +#endif + +/** + * @brief Indicates if the executing thread is inside a thread dispatch + * critical section. + * + * @retval true Thread dispatching is enabled. + * @retval false The executing thread is inside a thread dispatch critical + * section and dispatching is not allowed. + */ +RTEMS_INLINE_ROUTINE bool _Thread_Dispatch_is_enabled(void) +{ + bool enabled; + +#if defined(RTEMS_SMP) + ISR_Level level; + + _ISR_Local_disable( level ); +#endif + + enabled = _Thread_Dispatch_disable_level == 0; + +#if defined(RTEMS_SMP) + _ISR_Local_enable( level ); +#endif + + return enabled; +} + +/** + * @brief Gets thread dispatch disable level. + * + * @return The value of the thread dispatch level. + */ +RTEMS_INLINE_ROUTINE uint32_t _Thread_Dispatch_get_disable_level(void) +{ + return _Thread_Dispatch_disable_level; +} + +/** + * @brief Thread dispatch initialization. + * + * This routine initializes the thread dispatching subsystem. + */ +RTEMS_INLINE_ROUTINE void _Thread_Dispatch_initialization( void ) +{ + _Thread_Dispatch_disable_level = 1; +} + +/** + * @brief Performs a thread dispatch if necessary. + * + * This routine is responsible for transferring control of the processor from + * the executing thread to the heir thread. Once the heir is running an + * attempt is made to run the pending post-switch thread actions. + * + * As part of this process, it is responsible for the following actions + * - update timing information of the executing thread, + * - save the context of the executing thread, + * - invokation of the thread switch user extensions, + * - restore the context of the heir thread, and + * - run of pending post-switch thread actions of the resulting executing + * thread. + * + * On entry the thread dispatch level must be equal to zero. + */ +void _Thread_Dispatch( void ); + +/** + * @brief Directly do a thread dispatch. + * + * Must be called with a thread dispatch disable level of one, otherwise the + * INTERNAL_ERROR_BAD_THREAD_DISPATCH_DISABLE_LEVEL will occur. This function + * is useful for operations which synchronously block, e.g. self restart, self + * deletion, yield, sleep. + * + * @param[in] cpu_self The current processor. + * + * @see _Thread_Dispatch(). + */ +void _Thread_Dispatch_direct( Per_CPU_Control *cpu_self ); + +/** + * @brief Performs a thread dispatch on the current processor. + * + * On entry the thread dispatch disable level must be equal to one and + * interrupts must be disabled. + * + * This function assumes that a thread dispatch is necessary. + * + * @param[in] cpu_self The current processor. + * @param[in] level The previous interrupt level. + * + * @see _Thread_Dispatch(). + */ +void _Thread_Do_dispatch( Per_CPU_Control *cpu_self, ISR_Level level ); + +/** + * @brief Disables thread dispatching inside a critical section (interrupts + * disabled) with the current processor. + * + * @param[in] cpu_self The current processor. + * @param[in] lock_context The lock context of the corresponding + * _ISR_lock_ISR_disable() that started the critical section. + * + * @return The current processor. + */ +RTEMS_INLINE_ROUTINE Per_CPU_Control *_Thread_Dispatch_disable_with_CPU( + Per_CPU_Control *cpu_self, + const ISR_lock_Context *lock_context +) +{ + uint32_t disable_level; + + disable_level = cpu_self->thread_dispatch_disable_level; + _Profiling_Thread_dispatch_disable_critical( + cpu_self, + disable_level, + lock_context + ); + cpu_self->thread_dispatch_disable_level = disable_level + 1; + + return cpu_self; +} + +/** + * @brief Disables thread dispatching inside a critical section (interrupts + * disabled). + * + * @param[in] lock_context The lock context of the corresponding + * _ISR_lock_ISR_disable() that started the critical section. + * + * @return The current processor. + */ +RTEMS_INLINE_ROUTINE Per_CPU_Control *_Thread_Dispatch_disable_critical( + const ISR_lock_Context *lock_context +) +{ + return _Thread_Dispatch_disable_with_CPU( _Per_CPU_Get(), lock_context ); +} + +/** + * @brief Disables thread dispatching. + * + * @return The current processor. + */ +RTEMS_INLINE_ROUTINE Per_CPU_Control *_Thread_Dispatch_disable( void ) +{ + Per_CPU_Control *cpu_self; + ISR_lock_Context lock_context; + +#if defined( RTEMS_SMP ) || defined( RTEMS_PROFILING ) + _ISR_lock_ISR_disable( &lock_context ); +#endif + + cpu_self = _Thread_Dispatch_disable_critical( &lock_context ); + +#if defined( RTEMS_SMP ) || defined( RTEMS_PROFILING ) + _ISR_lock_ISR_enable( &lock_context ); +#endif + + return cpu_self; +} + +/** + * @brief Enables thread dispatching. + * + * May perfrom a thread dispatch if necessary as a side-effect. + * + * @param[in] cpu_self The current processor. + */ +RTEMS_INLINE_ROUTINE void _Thread_Dispatch_enable( Per_CPU_Control *cpu_self ) +{ + uint32_t disable_level = cpu_self->thread_dispatch_disable_level; + + if ( disable_level == 1 ) { + ISR_Level level; + + _ISR_Local_disable( level ); + + if ( + cpu_self->dispatch_necessary +#if defined(RTEMS_SCORE_ROBUST_THREAD_DISPATCH) + || !_ISR_Is_enabled( level ) +#endif + ) { + _Thread_Do_dispatch( cpu_self, level ); + } else { + cpu_self->thread_dispatch_disable_level = 0; + _Profiling_Thread_dispatch_enable( cpu_self, 0 ); + } + + _ISR_Local_enable( level ); + } else { + _Assert( disable_level > 0 ); + cpu_self->thread_dispatch_disable_level = disable_level - 1; + } +} + +/** + * @brief Unnests thread dispatching. + * + * @param[in] cpu_self The current processor. + */ +RTEMS_INLINE_ROUTINE void _Thread_Dispatch_unnest( Per_CPU_Control *cpu_self ) +{ + _Assert( cpu_self->thread_dispatch_disable_level > 0 ); + --cpu_self->thread_dispatch_disable_level; +} + +/** + * @brief Requests a thread dispatch on the target processor. + * + * @param[in] cpu_self The current processor. + * @param[in] cpu_target The target processor to request a thread dispatch. + */ +RTEMS_INLINE_ROUTINE void _Thread_Dispatch_request( + Per_CPU_Control *cpu_self, + Per_CPU_Control *cpu_target +) +{ +#if defined( RTEMS_SMP ) + if ( cpu_self == cpu_target ) { + cpu_self->dispatch_necessary = true; + } else { + _Atomic_Fetch_or_ulong( &cpu_target->message, 0, ATOMIC_ORDER_RELEASE ); + _CPU_SMP_Send_interrupt( _Per_CPU_Get_index( cpu_target ) ); + } +#else + cpu_self->dispatch_necessary = true; + (void) cpu_target; +#endif +} + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_SCORE_THREADDISPATCH_H */ diff --git a/cpukit/include/rtems/score/threadimpl.h b/cpukit/include/rtems/score/threadimpl.h new file mode 100644 index 0000000000..b6722fae19 --- /dev/null +++ b/cpukit/include/rtems/score/threadimpl.h @@ -0,0 +1,1969 @@ +/** + * @file + * + * @brief Inlined Routines from the Thread Handler + * + * This file contains the macro implementation of the inlined + * routines from the Thread handler. + */ + +/* + * COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * Copyright (c) 2014, 2017 embedded brains GmbH. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_THREADIMPL_H +#define _RTEMS_SCORE_THREADIMPL_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup ScoreThread + */ +/**@{**/ + +/** + * The following structure contains the information necessary to manage + * a thread which it is waiting for a resource. + */ +#define THREAD_STATUS_PROXY_BLOCKING 0x1111111 + +/** + * Self for the GNU Ada Run-Time + */ +extern void *rtems_ada_self; + +typedef struct { + Objects_Information Objects; + + Freechain_Control Free_thread_queue_heads; +} Thread_Information; + +/** + * The following defines the information control block used to + * manage this class of objects. + */ +extern Thread_Information _Thread_Internal_information; + +/** + * @brief Object identifier of the global constructor thread. + * + * This variable is set by _RTEMS_tasks_Initialize_user_tasks_body() or + * _POSIX_Threads_Initialize_user_threads_body(). + * + * It is consumed by _Thread_Handler(). + */ +extern Objects_Id _Thread_Global_constructor; + +/** + * The following points to the thread whose floating point + * context is currently loaded. + */ +#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) +extern Thread_Control *_Thread_Allocated_fp; +#endif + +#if defined(RTEMS_SMP) +#define THREAD_OF_SCHEDULER_HELP_NODE( node ) \ + RTEMS_CONTAINER_OF( node, Thread_Control, Scheduler.Help_node ) +#endif + +typedef bool ( *Thread_Visitor )( Thread_Control *the_thread, void *arg ); + +void _Thread_Iterate( + Thread_Visitor visitor, + void *arg +); + +void _Thread_Initialize_information( + Thread_Information *information, + Objects_APIs the_api, + uint16_t the_class, + uint32_t maximum, + bool is_string, + uint32_t maximum_name_length +); + +/** + * @brief Initialize thread handler. + * + * This routine performs the initialization necessary for this handler. + */ +void _Thread_Handler_initialization(void); + +/** + * @brief Create idle thread. + * + * This routine creates the idle thread. + * + * @warning No thread should be created before this one. + */ +void _Thread_Create_idle(void); + +/** + * @brief Start thread multitasking. + * + * This routine initiates multitasking. It is invoked only as + * part of initialization and its invocation is the last act of + * the non-multitasking part of the system initialization. + */ +void _Thread_Start_multitasking( void ) RTEMS_NO_RETURN; + +/** + * @brief Allocate the requested stack space for the thread. + * + * Allocate the requested stack space for the thread. + * Set the Start.stack field to the address of the stack. + * + * @param[in] the_thread is the thread where the stack space is requested + * @param[in] stack_size is the stack space is requested + * + * @retval actual size allocated after any adjustment + * @retval zero if the allocation failed + */ +size_t _Thread_Stack_Allocate( + Thread_Control *the_thread, + size_t stack_size +); + +/** + * @brief Deallocate thread stack. + * + * Deallocate the Thread's stack. + */ +void _Thread_Stack_Free( + Thread_Control *the_thread +); + +/** + * @brief Initialize thread. + * + * This routine initializes the specified the thread. It allocates + * all memory associated with this thread. It completes by adding + * the thread to the local object table so operations on this + * thread id are allowed. + * + * @note If stack_area is NULL, it is allocated from the workspace. + * + * @note If the stack is allocated from the workspace, then it is + * guaranteed to be of at least minimum size. + */ +bool _Thread_Initialize( + Thread_Information *information, + Thread_Control *the_thread, + const struct _Scheduler_Control *scheduler, + void *stack_area, + size_t stack_size, + bool is_fp, + Priority_Control priority, + bool is_preemptible, + Thread_CPU_budget_algorithms budget_algorithm, + Thread_CPU_budget_algorithm_callout budget_callout, + uint32_t isr_level, + Objects_Name name +); + +/** + * @brief Initializes thread and executes it. + * + * This routine initializes the executable information for a thread + * and makes it ready to execute. After this routine executes, the + * thread competes with all other threads for CPU time. + * + * @param the_thread The thread to be started. + * @param entry The thread entry information. + */ +bool _Thread_Start( + Thread_Control *the_thread, + const Thread_Entry_information *entry, + ISR_lock_Context *lock_context +); + +void _Thread_Restart_self( + Thread_Control *executing, + const Thread_Entry_information *entry, + ISR_lock_Context *lock_context +) RTEMS_NO_RETURN; + +bool _Thread_Restart_other( + Thread_Control *the_thread, + const Thread_Entry_information *entry, + ISR_lock_Context *lock_context +); + +void _Thread_Yield( Thread_Control *executing ); + +Thread_Life_state _Thread_Change_life( + Thread_Life_state clear, + Thread_Life_state set, + Thread_Life_state ignore +); + +Thread_Life_state _Thread_Set_life_protection( Thread_Life_state state ); + +/** + * @brief Kills all zombie threads in the system. + * + * Threads change into the zombie state as the last step in the thread + * termination sequence right before a context switch to the heir thread is + * initiated. Since the thread stack is still in use during this phase we have + * to postpone the thread stack reclamation until this point. On SMP + * configurations we may have to busy wait for context switch completion here. + */ +void _Thread_Kill_zombies( void ); + +void _Thread_Exit( + Thread_Control *executing, + Thread_Life_state set, + void *exit_value +); + +void _Thread_Join( + Thread_Control *the_thread, + States_Control waiting_for_join, + Thread_Control *executing, + Thread_queue_Context *queue_context +); + +void _Thread_Cancel( + Thread_Control *the_thread, + Thread_Control *executing, + void *exit_value +); + +typedef struct { + Thread_queue_Context Base; + Thread_Control *cancel; +} Thread_Close_context; + +/** + * @brief Closes the thread. + * + * Closes the thread object and starts the thread termination sequence. In + * case the executing thread is not terminated, then this function waits until + * the terminating thread reached the zombie state. + */ +void _Thread_Close( + Thread_Control *the_thread, + Thread_Control *executing, + Thread_Close_context *context +); + +RTEMS_INLINE_ROUTINE bool _Thread_Is_ready( const Thread_Control *the_thread ) +{ + return _States_Is_ready( the_thread->current_state ); +} + +States_Control _Thread_Clear_state_locked( + Thread_Control *the_thread, + States_Control state +); + +/** + * @brief Clears the specified thread state. + * + * In case the previous state is a non-ready state and the next state is the + * ready state, then the thread is unblocked by the scheduler. + * + * @param[in] the_thread The thread. + * @param[in] state The state to clear. It must not be zero. + * + * @return The previous state. + */ +States_Control _Thread_Clear_state( + Thread_Control *the_thread, + States_Control state +); + +States_Control _Thread_Set_state_locked( + Thread_Control *the_thread, + States_Control state +); + +/** + * @brief Sets the specified thread state. + * + * In case the previous state is the ready state, then the thread is blocked by + * the scheduler. + * + * @param[in] the_thread The thread. + * @param[in] state The state to set. It must not be zero. + * + * @return The previous state. + */ +States_Control _Thread_Set_state( + Thread_Control *the_thread, + States_Control state +); + +/** + * @brief Initializes enviroment for a thread. + * + * This routine initializes the context of @a the_thread to its + * appropriate starting state. + * + * @param[in] the_thread is the pointer to the thread control block. + */ +void _Thread_Load_environment( + Thread_Control *the_thread +); + +void _Thread_Entry_adaptor_idle( Thread_Control *executing ); + +void _Thread_Entry_adaptor_numeric( Thread_Control *executing ); + +void _Thread_Entry_adaptor_pointer( Thread_Control *executing ); + +/** + * @brief Wrapper function for all threads. + * + * This routine is the wrapper function for all threads. It is + * the starting point for all threads. The user provided thread + * entry point is invoked by this routine. Operations + * which must be performed immediately before and after the user's + * thread executes are found here. + * + * @note On entry, it is assumed all interrupts are blocked and that this + * routine needs to set the initial isr level. This may or may not + * actually be needed by the context switch routine and as a result + * interrupts may already be at there proper level. Either way, + * setting the initial isr level properly here is safe. + */ +void _Thread_Handler( void ); + +RTEMS_INLINE_ROUTINE void _Thread_State_acquire_critical( + Thread_Control *the_thread, + ISR_lock_Context *lock_context +) +{ + _Thread_queue_Do_acquire_critical( &the_thread->Join_queue, lock_context ); +} + +RTEMS_INLINE_ROUTINE void _Thread_State_acquire( + Thread_Control *the_thread, + ISR_lock_Context *lock_context +) +{ + _ISR_lock_ISR_disable( lock_context ); + _Thread_State_acquire_critical( the_thread, lock_context ); +} + +RTEMS_INLINE_ROUTINE Thread_Control *_Thread_State_acquire_for_executing( + ISR_lock_Context *lock_context +) +{ + Thread_Control *executing; + + _ISR_lock_ISR_disable( lock_context ); + executing = _Thread_Executing; + _Thread_State_acquire_critical( executing, lock_context ); + + return executing; +} + +RTEMS_INLINE_ROUTINE void _Thread_State_release_critical( + Thread_Control *the_thread, + ISR_lock_Context *lock_context +) +{ + _Thread_queue_Do_release_critical( &the_thread->Join_queue, lock_context ); +} + +RTEMS_INLINE_ROUTINE void _Thread_State_release( + Thread_Control *the_thread, + ISR_lock_Context *lock_context +) +{ + _Thread_State_release_critical( the_thread, lock_context ); + _ISR_lock_ISR_enable( lock_context ); +} + +#if defined(RTEMS_DEBUG) +RTEMS_INLINE_ROUTINE bool _Thread_State_is_owner( + const Thread_Control *the_thread +) +{ + return _Thread_queue_Is_lock_owner( &the_thread->Join_queue ); +} +#endif + +/** + * @brief Performs the priority actions specified by the thread queue context + * along the thread queue path. + * + * The caller must be the owner of the thread wait lock. + * + * @param start_of_path The start thread of the thread queue path. + * @param queue_context The thread queue context specifying the thread queue + * path and initial thread priority actions. + * + * @see _Thread_queue_Path_acquire_critical(). + */ +void _Thread_Priority_perform_actions( + Thread_Control *start_of_path, + Thread_queue_Context *queue_context +); + +/** + * @brief Adds the specified thread priority node to the corresponding thread + * priority aggregation. + * + * The caller must be the owner of the thread wait lock. + * + * @param the_thread The thread. + * @param priority_node The thread priority node to add. + * @param queue_context The thread queue context to return an updated set of + * threads for _Thread_Priority_update(). The thread queue context must be + * initialized via _Thread_queue_Context_clear_priority_updates() before a + * call of this function. + * + * @see _Thread_Wait_acquire(). + */ +void _Thread_Priority_add( + Thread_Control *the_thread, + Priority_Node *priority_node, + Thread_queue_Context *queue_context +); + +/** + * @brief Removes the specified thread priority node from the corresponding + * thread priority aggregation. + * + * The caller must be the owner of the thread wait lock. + * + * @param the_thread The thread. + * @param priority_node The thread priority node to remove. + * @param queue_context The thread queue context to return an updated set of + * threads for _Thread_Priority_update(). The thread queue context must be + * initialized via _Thread_queue_Context_clear_priority_updates() before a + * call of this function. + * + * @see _Thread_Wait_acquire(). + */ +void _Thread_Priority_remove( + Thread_Control *the_thread, + Priority_Node *priority_node, + Thread_queue_Context *queue_context +); + +/** + * @brief Propagates a thread priority value change in the specified thread + * priority node to the corresponding thread priority aggregation. + * + * The caller must be the owner of the thread wait lock. + * + * @param the_thread The thread. + * @param priority_node The thread priority node to change. + * @param prepend_it In case this is true, then the thread is prepended to + * its priority group in its home scheduler instance, otherwise it is + * appended. + * @param queue_context The thread queue context to return an updated set of + * threads for _Thread_Priority_update(). The thread queue context must be + * initialized via _Thread_queue_Context_clear_priority_updates() before a + * call of this function. + * + * @see _Thread_Wait_acquire(). + */ +void _Thread_Priority_changed( + Thread_Control *the_thread, + Priority_Node *priority_node, + bool prepend_it, + Thread_queue_Context *queue_context +); + +/** + * @brief Changes the thread priority value of the specified thread priority + * node in the corresponding thread priority aggregation. + * + * The caller must be the owner of the thread wait lock. + * + * @param the_thread The thread. + * @param priority_node The thread priority node to change. + * @param new_priority The new thread priority value of the thread priority + * node to change. + * @param prepend_it In case this is true, then the thread is prepended to + * its priority group in its home scheduler instance, otherwise it is + * appended. + * @param queue_context The thread queue context to return an updated set of + * threads for _Thread_Priority_update(). The thread queue context must be + * initialized via _Thread_queue_Context_clear_priority_updates() before a + * call of this function. + * + * @see _Thread_Wait_acquire(). + */ +RTEMS_INLINE_ROUTINE void _Thread_Priority_change( + Thread_Control *the_thread, + Priority_Node *priority_node, + Priority_Control new_priority, + bool prepend_it, + Thread_queue_Context *queue_context +) +{ + _Priority_Node_set_priority( priority_node, new_priority ); + _Thread_Priority_changed( + the_thread, + priority_node, + prepend_it, + queue_context + ); +} + +/** + * @brief Replaces the victim priority node with the replacement priority node + * in the corresponding thread priority aggregation. + * + * The caller must be the owner of the thread wait lock. + * + * @param the_thread The thread. + * @param victim_node The victim thread priority node. + * @param replacement_node The replacement thread priority node. + * + * @see _Thread_Wait_acquire(). + */ +void _Thread_Priority_replace( + Thread_Control *the_thread, + Priority_Node *victim_node, + Priority_Node *replacement_node +); + +/** + * @brief Adds a priority node to the corresponding thread priority + * aggregation. + * + * The caller must be the owner of the thread wait lock. + * + * @param the_thread The thread. + * @param priority_node The thread priority node to add. + * @param queue_context The thread queue context to return an updated set of + * threads for _Thread_Priority_update(). The thread queue context must be + * initialized via _Thread_queue_Context_clear_priority_updates() before a + * call of this function. + * + * @see _Thread_Priority_add(), _Thread_Priority_change(), + * _Thread_Priority_changed() and _Thread_Priority_remove(). + */ +void _Thread_Priority_update( Thread_queue_Context *queue_context ); + +#if defined(RTEMS_SMP) +void _Thread_Priority_and_sticky_update( + Thread_Control *the_thread, + int sticky_level_change +); +#endif + +/** + * @brief Returns true if the left thread priority is less than the right + * thread priority in the intuitive sense of priority and false otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Thread_Priority_less_than( + Priority_Control left, + Priority_Control right +) +{ + return left > right; +} + +/** + * @brief Returns the highest priority of the left and right thread priorities + * in the intuitive sense of priority. + */ +RTEMS_INLINE_ROUTINE Priority_Control _Thread_Priority_highest( + Priority_Control left, + Priority_Control right +) +{ + return _Thread_Priority_less_than( left, right ) ? right : left; +} + +RTEMS_INLINE_ROUTINE Objects_Information *_Thread_Get_objects_information( + Objects_Id id +) +{ + uint32_t the_api; + + the_api = _Objects_Get_API( id ); + + if ( !_Objects_Is_api_valid( the_api ) ) { + return NULL; + } + + /* + * Threads are always first class :) + * + * There is no need to validate the object class of the object identifier, + * since this will be done by the object get methods. + */ + return _Objects_Information_table[ the_api ][ 1 ]; +} + +/** + * @brief Gets a thread by its identifier. + * + * @see _Objects_Get(). + */ +Thread_Control *_Thread_Get( + Objects_Id id, + ISR_lock_Context *lock_context +); + +RTEMS_INLINE_ROUTINE Per_CPU_Control *_Thread_Get_CPU( + const Thread_Control *thread +) +{ +#if defined(RTEMS_SMP) + return thread->Scheduler.cpu; +#else + (void) thread; + + return _Per_CPU_Get(); +#endif +} + +RTEMS_INLINE_ROUTINE void _Thread_Set_CPU( + Thread_Control *thread, + Per_CPU_Control *cpu +) +{ +#if defined(RTEMS_SMP) + thread->Scheduler.cpu = cpu; +#else + (void) thread; + (void) cpu; +#endif +} + +/** + * This function returns true if the_thread is the currently executing + * thread, and false otherwise. + */ + +RTEMS_INLINE_ROUTINE bool _Thread_Is_executing ( + const Thread_Control *the_thread +) +{ + return ( the_thread == _Thread_Executing ); +} + +#if defined(RTEMS_SMP) +/** + * @brief Returns @a true in case the thread executes currently on some + * processor in the system, otherwise @a false. + * + * Do not confuse this with _Thread_Is_executing() which checks only the + * current processor. + */ +RTEMS_INLINE_ROUTINE bool _Thread_Is_executing_on_a_processor( + const Thread_Control *the_thread +) +{ + return _CPU_Context_Get_is_executing( &the_thread->Registers ); +} +#endif + +/** + * This function returns true if the_thread is the heir + * thread, and false otherwise. + */ + +RTEMS_INLINE_ROUTINE bool _Thread_Is_heir ( + const Thread_Control *the_thread +) +{ + return ( the_thread == _Thread_Heir ); +} + +/** + * This routine clears any blocking state for the_thread. It performs + * any necessary scheduling operations including the selection of + * a new heir thread. + */ + +RTEMS_INLINE_ROUTINE void _Thread_Unblock ( + Thread_Control *the_thread +) +{ + _Thread_Clear_state( the_thread, STATES_BLOCKED ); +} + +/** + * This function returns true if the floating point context of + * the_thread is currently loaded in the floating point unit, and + * false otherwise. + */ + +#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) +RTEMS_INLINE_ROUTINE bool _Thread_Is_allocated_fp ( + const Thread_Control *the_thread +) +{ + return ( the_thread == _Thread_Allocated_fp ); +} +#endif + +/* + * If the CPU has hardware floating point, then we must address saving + * and restoring it as part of the context switch. + * + * The second conditional compilation section selects the algorithm used + * to context switch between floating point tasks. The deferred algorithm + * can be significantly better in a system with few floating point tasks + * because it reduces the total number of save and restore FP context + * operations. However, this algorithm can not be used on all CPUs due + * to unpredictable use of FP registers by some compilers for integer + * operations. + */ + +RTEMS_INLINE_ROUTINE void _Thread_Save_fp( Thread_Control *executing ) +{ +#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) +#if ( CPU_USE_DEFERRED_FP_SWITCH != TRUE ) + if ( executing->fp_context != NULL ) + _Context_Save_fp( &executing->fp_context ); +#endif +#endif +} + +RTEMS_INLINE_ROUTINE void _Thread_Restore_fp( Thread_Control *executing ) +{ +#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) +#if ( CPU_USE_DEFERRED_FP_SWITCH == TRUE ) + if ( (executing->fp_context != NULL) && + !_Thread_Is_allocated_fp( executing ) ) { + if ( _Thread_Allocated_fp != NULL ) + _Context_Save_fp( &_Thread_Allocated_fp->fp_context ); + _Context_Restore_fp( &executing->fp_context ); + _Thread_Allocated_fp = executing; + } +#else + if ( executing->fp_context != NULL ) + _Context_Restore_fp( &executing->fp_context ); +#endif +#endif +} + +/** + * This routine is invoked when the currently loaded floating + * point context is now longer associated with an active thread. + */ + +#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) +RTEMS_INLINE_ROUTINE void _Thread_Deallocate_fp( void ) +{ + _Thread_Allocated_fp = NULL; +} +#endif + +/** + * This function returns true if dispatching is disabled, and false + * otherwise. + */ + +RTEMS_INLINE_ROUTINE bool _Thread_Is_context_switch_necessary( void ) +{ + return ( _Thread_Dispatch_necessary ); +} + +/** + * This function returns true if the_thread is NULL and false otherwise. + */ + +RTEMS_INLINE_ROUTINE bool _Thread_Is_null ( + const Thread_Control *the_thread +) +{ + return ( the_thread == NULL ); +} + +/** + * @brief Is proxy blocking. + * + * status which indicates that a proxy is blocking, and false otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Thread_Is_proxy_blocking ( + uint32_t code +) +{ + return (code == THREAD_STATUS_PROXY_BLOCKING); +} + +RTEMS_INLINE_ROUTINE uint32_t _Thread_Get_maximum_internal_threads(void) +{ + /* Idle threads */ + uint32_t maximum_internal_threads = + rtems_configuration_get_maximum_processors(); + + /* MPCI thread */ +#if defined(RTEMS_MULTIPROCESSING) + if ( _System_state_Is_multiprocessing ) { + ++maximum_internal_threads; + } +#endif + + return maximum_internal_threads; +} + +RTEMS_INLINE_ROUTINE Thread_Control *_Thread_Internal_allocate( void ) +{ + return (Thread_Control *) + _Objects_Allocate_unprotected( &_Thread_Internal_information.Objects ); +} + +/** + * @brief Gets the heir of the processor and makes it executing. + * + * Must be called with interrupts disabled. The thread dispatch necessary + * indicator is cleared as a side-effect. + * + * @return The heir thread. + * + * @see _Thread_Dispatch(), _Thread_Start_multitasking() and + * _Thread_Dispatch_update_heir(). + */ +RTEMS_INLINE_ROUTINE Thread_Control *_Thread_Get_heir_and_make_it_executing( + Per_CPU_Control *cpu_self +) +{ + Thread_Control *heir; + + heir = cpu_self->heir; + cpu_self->dispatch_necessary = false; + cpu_self->executing = heir; + + return heir; +} + +RTEMS_INLINE_ROUTINE void _Thread_Update_CPU_time_used( + Thread_Control *the_thread, + Per_CPU_Control *cpu +) +{ + Timestamp_Control last; + Timestamp_Control ran; + + last = cpu->cpu_usage_timestamp; + _TOD_Get_uptime( &cpu->cpu_usage_timestamp ); + _Timestamp_Subtract( &last, &cpu->cpu_usage_timestamp, &ran ); + _Timestamp_Add_to( &the_thread->cpu_time_used, &ran ); +} + +#if defined( RTEMS_SMP ) +RTEMS_INLINE_ROUTINE void _Thread_Dispatch_update_heir( + Per_CPU_Control *cpu_self, + Per_CPU_Control *cpu_for_heir, + Thread_Control *heir +) +{ + _Thread_Update_CPU_time_used( cpu_for_heir->heir, cpu_for_heir ); + + cpu_for_heir->heir = heir; + + _Thread_Dispatch_request( cpu_self, cpu_for_heir ); +} +#endif + +void _Thread_Get_CPU_time_used( + Thread_Control *the_thread, + Timestamp_Control *cpu_time_used +); + +RTEMS_INLINE_ROUTINE void _Thread_Action_control_initialize( + Thread_Action_control *action_control +) +{ + _Chain_Initialize_empty( &action_control->Chain ); +} + +RTEMS_INLINE_ROUTINE void _Thread_Action_initialize( + Thread_Action *action +) +{ + _Chain_Set_off_chain( &action->Node ); +} + +RTEMS_INLINE_ROUTINE void _Thread_Add_post_switch_action( + Thread_Control *the_thread, + Thread_Action *action, + Thread_Action_handler handler +) +{ + Per_CPU_Control *cpu_of_thread; + + _Assert( _Thread_State_is_owner( the_thread ) ); + + cpu_of_thread = _Thread_Get_CPU( the_thread ); + + action->handler = handler; + + _Thread_Dispatch_request( _Per_CPU_Get(), cpu_of_thread ); + + _Chain_Append_if_is_off_chain_unprotected( + &the_thread->Post_switch_actions.Chain, + &action->Node + ); +} + +RTEMS_INLINE_ROUTINE bool _Thread_Is_life_restarting( + Thread_Life_state life_state +) +{ + return ( life_state & THREAD_LIFE_RESTARTING ) != 0; +} + +RTEMS_INLINE_ROUTINE bool _Thread_Is_life_terminating( + Thread_Life_state life_state +) +{ + return ( life_state & THREAD_LIFE_TERMINATING ) != 0; +} + +RTEMS_INLINE_ROUTINE bool _Thread_Is_life_change_allowed( + Thread_Life_state life_state +) +{ + return ( life_state + & ( THREAD_LIFE_PROTECTED | THREAD_LIFE_CHANGE_DEFERRED ) ) == 0; +} + +RTEMS_INLINE_ROUTINE bool _Thread_Is_life_changing( + Thread_Life_state life_state +) +{ + return ( life_state + & ( THREAD_LIFE_RESTARTING | THREAD_LIFE_TERMINATING ) ) != 0; +} + +RTEMS_INLINE_ROUTINE bool _Thread_Is_joinable( + const Thread_Control *the_thread +) +{ + _Assert( _Thread_State_is_owner( the_thread ) ); + return ( the_thread->Life.state & THREAD_LIFE_DETACHED ) == 0; +} + +RTEMS_INLINE_ROUTINE void _Thread_Resource_count_increment( + Thread_Control *the_thread +) +{ +#if defined(RTEMS_SCORE_THREAD_ENABLE_RESOURCE_COUNT) + ++the_thread->resource_count; +#else + (void) the_thread; +#endif +} + +RTEMS_INLINE_ROUTINE void _Thread_Resource_count_decrement( + Thread_Control *the_thread +) +{ +#if defined(RTEMS_SCORE_THREAD_ENABLE_RESOURCE_COUNT) + --the_thread->resource_count; +#else + (void) the_thread; +#endif +} + +#if defined(RTEMS_SCORE_THREAD_ENABLE_RESOURCE_COUNT) +/** + * @brief Returns true if the thread owns resources, and false otherwise. + * + * Resources are accounted with the Thread_Control::resource_count resource + * counter. This counter is used by mutex objects for example. + * + * @param[in] the_thread The thread. + */ +RTEMS_INLINE_ROUTINE bool _Thread_Owns_resources( + const Thread_Control *the_thread +) +{ + return the_thread->resource_count != 0; +} +#endif + +#if defined(RTEMS_SMP) +RTEMS_INLINE_ROUTINE void _Thread_Scheduler_cancel_need_for_help( + Thread_Control *the_thread, + Per_CPU_Control *cpu +) +{ + _Per_CPU_Acquire( cpu ); + + if ( !_Chain_Is_node_off_chain( &the_thread->Scheduler.Help_node ) ) { + _Chain_Extract_unprotected( &the_thread->Scheduler.Help_node ); + _Chain_Set_off_chain( &the_thread->Scheduler.Help_node ); + } + + _Per_CPU_Release( cpu ); +} +#endif + +RTEMS_INLINE_ROUTINE const Scheduler_Control *_Thread_Scheduler_get_home( + const Thread_Control *the_thread +) +{ +#if defined(RTEMS_SMP) + return the_thread->Scheduler.home; +#else + (void) the_thread; + return &_Scheduler_Table[ 0 ]; +#endif +} + +RTEMS_INLINE_ROUTINE Scheduler_Node *_Thread_Scheduler_get_home_node( + const Thread_Control *the_thread +) +{ +#if defined(RTEMS_SMP) + _Assert( !_Chain_Is_empty( &the_thread->Scheduler.Wait_nodes ) ); + return SCHEDULER_NODE_OF_THREAD_WAIT_NODE( + _Chain_First( &the_thread->Scheduler.Wait_nodes ) + ); +#else + return the_thread->Scheduler.nodes; +#endif +} + +RTEMS_INLINE_ROUTINE Scheduler_Node *_Thread_Scheduler_get_node_by_index( + const Thread_Control *the_thread, + size_t scheduler_index +) +{ +#if defined(RTEMS_SMP) + return (Scheduler_Node *) + ( (uintptr_t) the_thread->Scheduler.nodes + + scheduler_index * _Scheduler_Node_size ); +#else + _Assert( scheduler_index == 0 ); + (void) scheduler_index; + return the_thread->Scheduler.nodes; +#endif +} + +#if defined(RTEMS_SMP) +RTEMS_INLINE_ROUTINE void _Thread_Scheduler_acquire_critical( + Thread_Control *the_thread, + ISR_lock_Context *lock_context +) +{ + _ISR_lock_Acquire( &the_thread->Scheduler.Lock, lock_context ); +} + +RTEMS_INLINE_ROUTINE void _Thread_Scheduler_release_critical( + Thread_Control *the_thread, + ISR_lock_Context *lock_context +) +{ + _ISR_lock_Release( &the_thread->Scheduler.Lock, lock_context ); +} + +#if defined(RTEMS_SMP) +void _Thread_Scheduler_process_requests( Thread_Control *the_thread ); +#endif + +RTEMS_INLINE_ROUTINE void _Thread_Scheduler_add_request( + Thread_Control *the_thread, + Scheduler_Node *scheduler_node, + Scheduler_Node_request request +) +{ + ISR_lock_Context lock_context; + Scheduler_Node_request current_request; + + _Thread_Scheduler_acquire_critical( the_thread, &lock_context ); + + current_request = scheduler_node->Thread.request; + + if ( current_request == SCHEDULER_NODE_REQUEST_NOT_PENDING ) { + _Assert( + request == SCHEDULER_NODE_REQUEST_ADD + || request == SCHEDULER_NODE_REQUEST_REMOVE + ); + _Assert( scheduler_node->Thread.next_request == NULL ); + scheduler_node->Thread.next_request = the_thread->Scheduler.requests; + the_thread->Scheduler.requests = scheduler_node; + } else if ( current_request != SCHEDULER_NODE_REQUEST_NOTHING ) { + _Assert( + ( current_request == SCHEDULER_NODE_REQUEST_ADD + && request == SCHEDULER_NODE_REQUEST_REMOVE ) + || ( current_request == SCHEDULER_NODE_REQUEST_REMOVE + && request == SCHEDULER_NODE_REQUEST_ADD ) + ); + request = SCHEDULER_NODE_REQUEST_NOTHING; + } + + scheduler_node->Thread.request = request; + + _Thread_Scheduler_release_critical( the_thread, &lock_context ); +} + +RTEMS_INLINE_ROUTINE void _Thread_Scheduler_add_wait_node( + Thread_Control *the_thread, + Scheduler_Node *scheduler_node +) +{ + _Chain_Append_unprotected( + &the_thread->Scheduler.Wait_nodes, + &scheduler_node->Thread.Wait_node + ); + _Thread_Scheduler_add_request( + the_thread, + scheduler_node, + SCHEDULER_NODE_REQUEST_ADD + ); +} + +RTEMS_INLINE_ROUTINE void _Thread_Scheduler_remove_wait_node( + Thread_Control *the_thread, + Scheduler_Node *scheduler_node +) +{ + _Chain_Extract_unprotected( &scheduler_node->Thread.Wait_node ); + _Thread_Scheduler_add_request( + the_thread, + scheduler_node, + SCHEDULER_NODE_REQUEST_REMOVE + ); +} +#endif + +/** + * @brief Returns the priority of the thread. + * + * Returns the user API and thread wait information relevant thread priority. + * This includes temporary thread priority adjustments due to locking + * protocols, a job release or the POSIX sporadic server for example. + * + * @return The priority of the thread. + */ +RTEMS_INLINE_ROUTINE Priority_Control _Thread_Get_priority( + const Thread_Control *the_thread +) +{ + Scheduler_Node *scheduler_node; + + scheduler_node = _Thread_Scheduler_get_home_node( the_thread ); + return _Priority_Get_priority( &scheduler_node->Wait.Priority ); +} + +/** + * @brief Acquires the thread wait default lock inside a critical section + * (interrupts disabled). + * + * @param[in] the_thread The thread. + * @param[in] lock_context The lock context used for the corresponding lock + * release. + * + * @see _Thread_Wait_release_default_critical(). + */ +RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire_default_critical( + Thread_Control *the_thread, + ISR_lock_Context *lock_context +) +{ + _ISR_lock_Acquire( &the_thread->Wait.Lock.Default, lock_context ); +} + +/** + * @brief Acquires the thread wait default lock and returns the executing + * thread. + * + * @param[in] lock_context The lock context used for the corresponding lock + * release. + * + * @return The executing thread. + * + * @see _Thread_Wait_release_default(). + */ +RTEMS_INLINE_ROUTINE Thread_Control *_Thread_Wait_acquire_default_for_executing( + ISR_lock_Context *lock_context +) +{ + Thread_Control *executing; + + _ISR_lock_ISR_disable( lock_context ); + executing = _Thread_Executing; + _Thread_Wait_acquire_default_critical( executing, lock_context ); + + return executing; +} + +/** + * @brief Acquires the thread wait default lock and disables interrupts. + * + * @param[in] the_thread The thread. + * @param[in] lock_context The lock context used for the corresponding lock + * release. + * + * @see _Thread_Wait_release_default(). + */ +RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire_default( + Thread_Control *the_thread, + ISR_lock_Context *lock_context +) +{ + _ISR_lock_ISR_disable( lock_context ); + _Thread_Wait_acquire_default_critical( the_thread, lock_context ); +} + +/** + * @brief Releases the thread wait default lock inside a critical section + * (interrupts disabled). + * + * The previous interrupt status is not restored. + * + * @param[in] the_thread The thread. + * @param[in] lock_context The lock context used for the corresponding lock + * acquire. + */ +RTEMS_INLINE_ROUTINE void _Thread_Wait_release_default_critical( + Thread_Control *the_thread, + ISR_lock_Context *lock_context +) +{ + _ISR_lock_Release( &the_thread->Wait.Lock.Default, lock_context ); +} + +/** + * @brief Releases the thread wait default lock and restores the previous + * interrupt status. + * + * @param[in] the_thread The thread. + * @param[in] lock_context The lock context used for the corresponding lock + * acquire. + */ +RTEMS_INLINE_ROUTINE void _Thread_Wait_release_default( + Thread_Control *the_thread, + ISR_lock_Context *lock_context +) +{ + _Thread_Wait_release_default_critical( the_thread, lock_context ); + _ISR_lock_ISR_enable( lock_context ); +} + +#if defined(RTEMS_SMP) +#define THREAD_QUEUE_CONTEXT_OF_REQUEST( node ) \ + RTEMS_CONTAINER_OF( node, Thread_queue_Context, Lock_context.Wait.Gate.Node ) + +RTEMS_INLINE_ROUTINE void _Thread_Wait_remove_request_locked( + Thread_Control *the_thread, + Thread_queue_Lock_context *queue_lock_context +) +{ + Chain_Node *first; + + _Chain_Extract_unprotected( &queue_lock_context->Wait.Gate.Node ); + first = _Chain_First( &the_thread->Wait.Lock.Pending_requests ); + + if ( first != _Chain_Tail( &the_thread->Wait.Lock.Pending_requests ) ) { + _Thread_queue_Gate_open( (Thread_queue_Gate *) first ); + } +} + +RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire_queue_critical( + Thread_queue_Queue *queue, + Thread_queue_Lock_context *queue_lock_context +) +{ + _Thread_queue_Queue_acquire_critical( + queue, + &_Thread_Executing->Potpourri_stats, + &queue_lock_context->Lock_context + ); +} + +RTEMS_INLINE_ROUTINE void _Thread_Wait_release_queue_critical( + Thread_queue_Queue *queue, + Thread_queue_Lock_context *queue_lock_context +) +{ + _Thread_queue_Queue_release_critical( + queue, + &queue_lock_context->Lock_context + ); +} +#endif + +/** + * @brief Acquires the thread wait lock inside a critical section (interrupts + * disabled). + * + * @param[in] the_thread The thread. + * @param[in] queue_context The thread queue context for the corresponding + * _Thread_Wait_release_critical(). + */ +RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire_critical( + Thread_Control *the_thread, + Thread_queue_Context *queue_context +) +{ +#if defined(RTEMS_SMP) + Thread_queue_Queue *queue; + + _Thread_Wait_acquire_default_critical( + the_thread, + &queue_context->Lock_context.Lock_context + ); + + queue = the_thread->Wait.queue; + queue_context->Lock_context.Wait.queue = queue; + + if ( queue != NULL ) { + _Thread_queue_Gate_add( + &the_thread->Wait.Lock.Pending_requests, + &queue_context->Lock_context.Wait.Gate + ); + _Thread_Wait_release_default_critical( + the_thread, + &queue_context->Lock_context.Lock_context + ); + _Thread_Wait_acquire_queue_critical( queue, &queue_context->Lock_context ); + + if ( queue_context->Lock_context.Wait.queue == NULL ) { + _Thread_Wait_release_queue_critical( + queue, + &queue_context->Lock_context + ); + _Thread_Wait_acquire_default_critical( + the_thread, + &queue_context->Lock_context.Lock_context + ); + _Thread_Wait_remove_request_locked( + the_thread, + &queue_context->Lock_context + ); + _Assert( the_thread->Wait.queue == NULL ); + } + } +#else + (void) the_thread; + (void) queue_context; +#endif +} + +/** + * @brief Acquires the thread wait default lock and disables interrupts. + * + * @param[in] the_thread The thread. + * @param[in] queue_context The thread queue context for the corresponding + * _Thread_Wait_release(). + */ +RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire( + Thread_Control *the_thread, + Thread_queue_Context *queue_context +) +{ + _ISR_lock_ISR_disable( &queue_context->Lock_context.Lock_context ); + _Thread_Wait_acquire_critical( the_thread, queue_context ); +} + +/** + * @brief Releases the thread wait lock inside a critical section (interrupts + * disabled). + * + * The previous interrupt status is not restored. + * + * @param[in] the_thread The thread. + * @param[in] queue_context The thread queue context used for corresponding + * _Thread_Wait_acquire_critical(). + */ +RTEMS_INLINE_ROUTINE void _Thread_Wait_release_critical( + Thread_Control *the_thread, + Thread_queue_Context *queue_context +) +{ +#if defined(RTEMS_SMP) + Thread_queue_Queue *queue; + + queue = queue_context->Lock_context.Wait.queue; + + if ( queue != NULL ) { + _Thread_Wait_release_queue_critical( + queue, &queue_context->Lock_context + ); + _Thread_Wait_acquire_default_critical( + the_thread, + &queue_context->Lock_context.Lock_context + ); + _Thread_Wait_remove_request_locked( + the_thread, + &queue_context->Lock_context + ); + } + + _Thread_Wait_release_default_critical( + the_thread, + &queue_context->Lock_context.Lock_context + ); +#else + (void) the_thread; + (void) queue_context; +#endif +} + +/** + * @brief Releases the thread wait lock and restores the previous interrupt + * status. + * + * @param[in] the_thread The thread. + * @param[in] queue_context The thread queue context used for corresponding + * _Thread_Wait_acquire(). + */ +RTEMS_INLINE_ROUTINE void _Thread_Wait_release( + Thread_Control *the_thread, + Thread_queue_Context *queue_context +) +{ + _Thread_Wait_release_critical( the_thread, queue_context ); + _ISR_lock_ISR_enable( &queue_context->Lock_context.Lock_context ); +} + +/** + * @brief Claims the thread wait queue. + * + * The caller must not be the owner of the default thread wait lock. The + * caller must be the owner of the corresponding thread queue lock. The + * registration of the corresponding thread queue operations is deferred and + * done after the deadlock detection. This is crucial to support timeouts on + * SMP configurations. + * + * @param[in] the_thread The thread. + * @param[in] queue The new thread queue. + * + * @see _Thread_Wait_claim_finalize() and _Thread_Wait_restore_default(). + */ +RTEMS_INLINE_ROUTINE void _Thread_Wait_claim( + Thread_Control *the_thread, + Thread_queue_Queue *queue +) +{ + ISR_lock_Context lock_context; + + _Thread_Wait_acquire_default_critical( the_thread, &lock_context ); + + _Assert( the_thread->Wait.queue == NULL ); + +#if defined(RTEMS_SMP) + _Chain_Initialize_empty( &the_thread->Wait.Lock.Pending_requests ); + _Chain_Initialize_node( &the_thread->Wait.Lock.Tranquilizer.Node ); + _Thread_queue_Gate_close( &the_thread->Wait.Lock.Tranquilizer ); +#endif + + the_thread->Wait.queue = queue; + + _Thread_Wait_release_default_critical( the_thread, &lock_context ); +} + +/** + * @brief Finalizes the thread wait queue claim via registration of the + * corresponding thread queue operations. + * + * @param[in] the_thread The thread. + * @param[in] operations The corresponding thread queue operations. + */ +RTEMS_INLINE_ROUTINE void _Thread_Wait_claim_finalize( + Thread_Control *the_thread, + const Thread_queue_Operations *operations +) +{ + the_thread->Wait.operations = operations; +} + +/** + * @brief Removes a thread wait lock request. + * + * On SMP configurations, removes a thread wait lock request. + * + * On other configurations, this function does nothing. + * + * @param[in] the_thread The thread. + * @param[in] queue_lock_context The thread queue lock context used for + * corresponding _Thread_Wait_acquire(). + */ +RTEMS_INLINE_ROUTINE void _Thread_Wait_remove_request( + Thread_Control *the_thread, + Thread_queue_Lock_context *queue_lock_context +) +{ +#if defined(RTEMS_SMP) + ISR_lock_Context lock_context; + + _Thread_Wait_acquire_default( the_thread, &lock_context ); + _Thread_Wait_remove_request_locked( the_thread, queue_lock_context ); + _Thread_Wait_release_default( the_thread, &lock_context ); +#else + (void) the_thread; + (void) queue_lock_context; +#endif +} + +/** + * @brief Restores the default thread wait queue and operations. + * + * The caller must be the owner of the current thread wait queue lock. + * + * On SMP configurations, the pending requests are updated to use the stale + * thread queue operations. + * + * @param[in] the_thread The thread. + * + * @see _Thread_Wait_claim(). + */ +RTEMS_INLINE_ROUTINE void _Thread_Wait_restore_default( + Thread_Control *the_thread +) +{ +#if defined(RTEMS_SMP) + ISR_lock_Context lock_context; + Chain_Node *node; + const Chain_Node *tail; + + _Thread_Wait_acquire_default_critical( the_thread, &lock_context ); + + node = _Chain_First( &the_thread->Wait.Lock.Pending_requests ); + tail = _Chain_Immutable_tail( &the_thread->Wait.Lock.Pending_requests ); + + if ( node != tail ) { + do { + Thread_queue_Context *queue_context; + + queue_context = THREAD_QUEUE_CONTEXT_OF_REQUEST( node ); + queue_context->Lock_context.Wait.queue = NULL; + + node = _Chain_Next( node ); + } while ( node != tail ); + + _Thread_queue_Gate_add( + &the_thread->Wait.Lock.Pending_requests, + &the_thread->Wait.Lock.Tranquilizer + ); + } else { + _Thread_queue_Gate_open( &the_thread->Wait.Lock.Tranquilizer ); + } +#endif + + the_thread->Wait.queue = NULL; + the_thread->Wait.operations = &_Thread_queue_Operations_default; + +#if defined(RTEMS_SMP) + _Thread_Wait_release_default_critical( the_thread, &lock_context ); +#endif +} + +/** + * @brief Tranquilizes the thread after a wait on a thread queue. + * + * After the violent blocking procedure this function makes the thread calm and + * peaceful again so that it can carry out its normal work. + * + * On SMP configurations, ensures that all pending thread wait lock requests + * completed before the thread is able to begin a new thread wait procedure. + * + * On other configurations, this function does nothing. + * + * It must be called after a _Thread_Wait_claim() exactly once + * - after the corresponding thread queue lock was released, and + * - the default wait state is restored or some other processor is about to do + * this. + * + * @param[in] the_thread The thread. + */ +RTEMS_INLINE_ROUTINE void _Thread_Wait_tranquilize( + Thread_Control *the_thread +) +{ +#if defined(RTEMS_SMP) + _Thread_queue_Gate_wait( &the_thread->Wait.Lock.Tranquilizer ); +#else + (void) the_thread; +#endif +} + +/** + * @brief Cancels a thread wait on a thread queue. + * + * @param[in] the_thread The thread. + * @param[in] queue_context The thread queue context used for corresponding + * _Thread_Wait_acquire(). + */ +RTEMS_INLINE_ROUTINE void _Thread_Wait_cancel( + Thread_Control *the_thread, + Thread_queue_Context *queue_context +) +{ + Thread_queue_Queue *queue; + + queue = the_thread->Wait.queue; + +#if defined(RTEMS_SMP) + if ( queue != NULL ) { + _Assert( queue_context->Lock_context.Wait.queue == queue ); +#endif + + ( *the_thread->Wait.operations->extract )( + queue, + the_thread, + queue_context + ); + _Thread_Wait_restore_default( the_thread ); + +#if defined(RTEMS_SMP) + _Assert( queue_context->Lock_context.Wait.queue == NULL ); + queue_context->Lock_context.Wait.queue = queue; + } +#endif +} + +/** + * @brief The initial thread wait flags value set by _Thread_Initialize(). + */ +#define THREAD_WAIT_FLAGS_INITIAL 0x0U + +/** + * @brief Mask to get the thread wait state flags. + */ +#define THREAD_WAIT_STATE_MASK 0xffU + +/** + * @brief Indicates that the thread begins with the blocking operation. + * + * A blocking operation consists of an optional watchdog initialization and the + * setting of the appropriate thread blocking state with the corresponding + * scheduler block operation. + */ +#define THREAD_WAIT_STATE_INTEND_TO_BLOCK 0x1U + +/** + * @brief Indicates that the thread completed the blocking operation. + */ +#define THREAD_WAIT_STATE_BLOCKED 0x2U + +/** + * @brief Indicates that a condition to end the thread wait occurred. + * + * This could be a timeout, a signal, an event or a resource availability. + */ +#define THREAD_WAIT_STATE_READY_AGAIN 0x4U + +/** + * @brief Mask to get the thread wait class flags. + */ +#define THREAD_WAIT_CLASS_MASK 0xff00U + +/** + * @brief Indicates that the thread waits for an event. + */ +#define THREAD_WAIT_CLASS_EVENT 0x100U + +/** + * @brief Indicates that the thread waits for a system event. + */ +#define THREAD_WAIT_CLASS_SYSTEM_EVENT 0x200U + +/** + * @brief Indicates that the thread waits for an object. + */ +#define THREAD_WAIT_CLASS_OBJECT 0x400U + +/** + * @brief Indicates that the thread waits for a period. + */ +#define THREAD_WAIT_CLASS_PERIOD 0x800U + +RTEMS_INLINE_ROUTINE void _Thread_Wait_flags_set( + Thread_Control *the_thread, + Thread_Wait_flags flags +) +{ +#if defined(RTEMS_SMP) + _Atomic_Store_uint( &the_thread->Wait.flags, flags, ATOMIC_ORDER_RELAXED ); +#else + the_thread->Wait.flags = flags; +#endif +} + +RTEMS_INLINE_ROUTINE Thread_Wait_flags _Thread_Wait_flags_get( + const Thread_Control *the_thread +) +{ +#if defined(RTEMS_SMP) + return _Atomic_Load_uint( &the_thread->Wait.flags, ATOMIC_ORDER_RELAXED ); +#else + return the_thread->Wait.flags; +#endif +} + +RTEMS_INLINE_ROUTINE Thread_Wait_flags _Thread_Wait_flags_get_acquire( + const Thread_Control *the_thread +) +{ +#if defined(RTEMS_SMP) + return _Atomic_Load_uint( &the_thread->Wait.flags, ATOMIC_ORDER_ACQUIRE ); +#else + return the_thread->Wait.flags; +#endif +} + +/** + * @brief Tries to change the thread wait flags with release semantics in case + * of success. + * + * Must be called inside a critical section (interrupts disabled). + * + * In case the wait flags are equal to the expected wait flags, then the wait + * flags are set to the desired wait flags. + * + * @param[in] the_thread The thread. + * @param[in] expected_flags The expected wait flags. + * @param[in] desired_flags The desired wait flags. + * + * @retval true The wait flags were equal to the expected wait flags. + * @retval false Otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Thread_Wait_flags_try_change_release( + Thread_Control *the_thread, + Thread_Wait_flags expected_flags, + Thread_Wait_flags desired_flags +) +{ + _Assert( _ISR_Get_level() != 0 ); + +#if defined(RTEMS_SMP) + return _Atomic_Compare_exchange_uint( + &the_thread->Wait.flags, + &expected_flags, + desired_flags, + ATOMIC_ORDER_RELEASE, + ATOMIC_ORDER_RELAXED + ); +#else + bool success = ( the_thread->Wait.flags == expected_flags ); + + if ( success ) { + the_thread->Wait.flags = desired_flags; + } + + return success; +#endif +} + +/** + * @brief Tries to change the thread wait flags with acquire semantics. + * + * In case the wait flags are equal to the expected wait flags, then the wait + * flags are set to the desired wait flags. + * + * @param[in] the_thread The thread. + * @param[in] expected_flags The expected wait flags. + * @param[in] desired_flags The desired wait flags. + * + * @retval true The wait flags were equal to the expected wait flags. + * @retval false Otherwise. + */ +RTEMS_INLINE_ROUTINE bool _Thread_Wait_flags_try_change_acquire( + Thread_Control *the_thread, + Thread_Wait_flags expected_flags, + Thread_Wait_flags desired_flags +) +{ + bool success; +#if defined(RTEMS_SMP) + return _Atomic_Compare_exchange_uint( + &the_thread->Wait.flags, + &expected_flags, + desired_flags, + ATOMIC_ORDER_ACQUIRE, + ATOMIC_ORDER_ACQUIRE + ); +#else + ISR_Level level; + + _ISR_Local_disable( level ); + + success = _Thread_Wait_flags_try_change_release( + the_thread, + expected_flags, + desired_flags + ); + + _ISR_Local_enable( level ); +#endif + + return success; +} + +/** + * @brief Returns the object identifier of the object containing the current + * thread wait queue. + * + * This function may be used for debug and system information purposes. The + * caller must be the owner of the thread lock. + * + * @retval 0 The thread waits on no thread queue currently, the thread wait + * queue is not contained in an object, or the current thread state provides + * insufficient information, e.g. the thread is in the middle of a blocking + * operation. + * @retval other The object identifier of the object containing the thread wait + * queue. + */ +Objects_Id _Thread_Wait_get_id( const Thread_Control *the_thread ); + +RTEMS_INLINE_ROUTINE Status_Control _Thread_Wait_get_status( + const Thread_Control *the_thread +) +{ + return (Status_Control) the_thread->Wait.return_code; +} + +/** + * @brief Cancels a blocking operation so that the thread can continue its + * execution. + * + * In case this function actually cancelled the blocking operation, then the + * thread wait return code is set to the specified status. + * + * A specialization of this function is _Thread_Timeout(). + * + * @param[in] the_thread The thread. + * @param[in] status The thread wait status. + */ +void _Thread_Continue( Thread_Control *the_thread, Status_Control status ); + +/** + * @brief General purpose thread wait timeout. + * + * @param[in] the_watchdog The thread timer watchdog. + */ +void _Thread_Timeout( Watchdog_Control *the_watchdog ); + +RTEMS_INLINE_ROUTINE void _Thread_Timer_initialize( + Thread_Timer_information *timer, + Per_CPU_Control *cpu +) +{ + _ISR_lock_Initialize( &timer->Lock, "Thread Timer" ); + timer->header = &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_MONOTONIC ]; + _Watchdog_Preinitialize( &timer->Watchdog, cpu ); +} + +RTEMS_INLINE_ROUTINE void _Thread_Add_timeout_ticks( + Thread_Control *the_thread, + Per_CPU_Control *cpu, + Watchdog_Interval ticks +) +{ + ISR_lock_Context lock_context; + + _ISR_lock_ISR_disable_and_acquire( &the_thread->Timer.Lock, &lock_context ); + + the_thread->Timer.header = + &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_MONOTONIC ]; + the_thread->Timer.Watchdog.routine = _Thread_Timeout; + _Watchdog_Per_CPU_insert_ticks( &the_thread->Timer.Watchdog, cpu, ticks ); + + _ISR_lock_Release_and_ISR_enable( &the_thread->Timer.Lock, &lock_context ); +} + +RTEMS_INLINE_ROUTINE void _Thread_Timer_insert_realtime( + Thread_Control *the_thread, + Per_CPU_Control *cpu, + Watchdog_Service_routine_entry routine, + uint64_t expire +) +{ + ISR_lock_Context lock_context; + + _ISR_lock_ISR_disable_and_acquire( &the_thread->Timer.Lock, &lock_context ); + + the_thread->Timer.header = + &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_REALTIME ]; + the_thread->Timer.Watchdog.routine = routine; + _Watchdog_Per_CPU_insert_realtime( &the_thread->Timer.Watchdog, cpu, expire ); + + _ISR_lock_Release_and_ISR_enable( &the_thread->Timer.Lock, &lock_context ); +} + +RTEMS_INLINE_ROUTINE void _Thread_Timer_remove( Thread_Control *the_thread ) +{ + ISR_lock_Context lock_context; + + _ISR_lock_ISR_disable_and_acquire( &the_thread->Timer.Lock, &lock_context ); + + _Watchdog_Per_CPU_remove( + &the_thread->Timer.Watchdog, +#if defined(RTEMS_SMP) + the_thread->Timer.Watchdog.cpu, +#else + _Per_CPU_Get(), +#endif + the_thread->Timer.header + ); + + _ISR_lock_Release_and_ISR_enable( &the_thread->Timer.Lock, &lock_context ); +} + +RTEMS_INLINE_ROUTINE void _Thread_Remove_timer_and_unblock( + Thread_Control *the_thread, + Thread_queue_Queue *queue +) +{ + _Thread_Wait_tranquilize( the_thread ); + _Thread_Timer_remove( the_thread ); + +#if defined(RTEMS_MULTIPROCESSING) + if ( _Objects_Is_local_id( the_thread->Object.id ) ) { + _Thread_Unblock( the_thread ); + } else { + _Thread_queue_Unblock_proxy( queue, the_thread ); + } +#else + (void) queue; + _Thread_Unblock( the_thread ); +#endif +} + +Status_Control _Thread_Set_name( + Thread_Control *the_thread, + const char *name +); + +size_t _Thread_Get_name( + const Thread_Control *the_thread, + char *buffer, + size_t buffer_size +); + +/** @}*/ + +#ifdef __cplusplus +} +#endif + +#if defined(RTEMS_MULTIPROCESSING) +#include +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/threadmp.h b/cpukit/include/rtems/score/threadmp.h new file mode 100644 index 0000000000..9cde35b649 --- /dev/null +++ b/cpukit/include/rtems/score/threadmp.h @@ -0,0 +1,113 @@ +/** + * @file rtems/score/threadmp.h + * + * @brief Multiprocessing Portion of the Thread Package + * + * This include file contains the specification for all routines + * and data specific to the multiprocessing portion of the thread package. + */ + +/* + * COPYRIGHT (c) 1989-2009. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_THREADMP_H +#define _RTEMS_SCORE_THREADMP_H + +#ifndef _RTEMS_SCORE_THREADIMPL_H +# error "Never use directly; include instead." +#endif + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ScoreThreadMP Thread Handler Multiprocessing Support + * + * @ingroup Score + * + * This handler encapsulates functionality which is related to managing + * threads in a multiprocessor system configuration. This handler must + * manage proxies which represent remote threads blocking on local + * operations. + */ +/**@{*/ + +/** + * @brief Initialize MP thread handler. + * + * This routine initializes the multiprocessing portion of the Thread Handler. + */ +void _Thread_MP_Handler_initialization ( + uint32_t maximum_proxies +); + +/** + * @brief Allocate a MP proxy control block from + * the inactive chain of free proxy control blocks. + * + * This allocates a proxy control block from + * the inactive chain of free proxy control blocks. + * + * @note This function returns a thread control pointer + * because proxies are substitutes for remote threads. + */ +Thread_Control *_Thread_MP_Allocate_proxy ( + States_Control the_state +); + +/** + * @brief Removes the MP proxy control block for the specified + * id from the active chain of proxy control blocks. + * + * This function removes the proxy control block for the specified + * id from the active red-black tree of proxy control blocks. + */ +Thread_Control *_Thread_MP_Find_proxy ( + Objects_Id the_id +); + +/** + * This function returns true if the thread in question is the + * multiprocessing receive thread. + * + * @note This is a macro to avoid needing a prototype for + * _MPCI_Receive_server_tcb until it is used. + */ +#define _Thread_MP_Is_receive(_the_thread) \ + ((_the_thread) == _MPCI_Receive_server_tcb) + +/** + * This routine frees a proxy control block to the + * inactive chain of free proxy control blocks. + */ +void _Thread_MP_Free_proxy( Thread_Control *the_thread ); + +RTEMS_INLINE_ROUTINE bool _Thread_MP_Is_remote( Objects_Id id ) +{ + Objects_Information *information; + + information = _Thread_Get_objects_information( id ); + if ( information == NULL ) { + return false; + } + + return _Objects_MP_Is_remote( id, information ); +} + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/threadq.h b/cpukit/include/rtems/score/threadq.h new file mode 100644 index 0000000000..3e618bf5af --- /dev/null +++ b/cpukit/include/rtems/score/threadq.h @@ -0,0 +1,595 @@ +/** + * @file + * + * @brief Constants and Structures Needed to Declare a Thread Queue + * + * This include file contains all the constants and structures + * needed to declare a thread queue. + */ + +/* + * COPYRIGHT (c) 1989-2014. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_THREADQ_H +#define _RTEMS_SCORE_THREADQ_H + +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct Scheduler_Node; + +/** + * @defgroup ScoreThreadQueue Thread Queue Handler + * + * @ingroup Score + * + * This handler provides the capability to have threads block in + * ordered sets. The sets may be ordered using the FIFO or priority + * discipline. + */ +/**@{*/ + +typedef struct _Thread_Control Thread_Control; + +typedef struct Thread_queue_Context Thread_queue_Context; + +typedef struct Thread_queue_Queue Thread_queue_Queue; + +typedef struct Thread_queue_Operations Thread_queue_Operations; + +/** + * @brief Thread queue enqueue callout. + * + * @param[in] queue The actual thread queue. + * @param[in] the_thread The thread to enqueue. + * @param[in] cpu_self The current processor. + * @param[in] queue_context The thread queue context of the lock acquire. + * + * @see _Thread_queue_Context_set_enqueue_callout(). + */ +typedef void ( *Thread_queue_Enqueue_callout )( + Thread_queue_Queue *queue, + Thread_Control *the_thread, + struct Per_CPU_Control *cpu_self, + Thread_queue_Context *queue_context +); + +/** + * @brief Thread queue deadlock callout. + * + * @param the_thread The thread that detected the deadlock. + * + * @see _Thread_queue_Context_set_deadlock_callout(). + */ +typedef void ( *Thread_queue_Deadlock_callout )( + Thread_Control *the_thread +); + +#if defined(RTEMS_MULTIPROCESSING) +/** + * @brief Multiprocessing (MP) support callout for thread queue operations. + * + * @param the_proxy The thread proxy of the thread queue operation. A thread + * control is actually a thread proxy if and only if + * _Objects_Is_local_id( the_proxy->Object.id ) is false. + * @param mp_id Object identifier of the object containing the thread queue. + * + * @see _Thread_queue_Context_set_MP_callout(). + */ +typedef void ( *Thread_queue_MP_callout )( + Thread_Control *the_proxy, + Objects_Id mp_id +); +#endif + +#if defined(RTEMS_SMP) +/** + * @brief The thread queue gate is an SMP synchronization means. + * + * The gates are added to a list of requests. A busy wait is performed to make + * sure that preceding requests are carried out. Each predecessor notifies its + * successor about on request completion. + * + * @see _Thread_queue_Gate_add(), _Thread_queue_Gate_wait(), and + * _Thread_queue_Gate_open(). + */ +typedef struct { + Chain_Node Node; + + Atomic_Uint go_ahead; +} Thread_queue_Gate; +#endif + +typedef struct { + /** + * @brief The lock context for the thread queue acquire and release + * operations. + */ + ISR_lock_Context Lock_context; + +#if defined(RTEMS_SMP) + /** + * @brief Data to support thread queue enqueue operations. + */ + struct { + /** + * @brief Gate to synchronize thread wait lock requests. + * + * @see _Thread_Wait_acquire_critical() and _Thread_Wait_tranquilize(). + */ + Thread_queue_Gate Gate; + + /** + * @brief The thread queue in case the thread is blocked on a thread queue. + */ + Thread_queue_Queue *queue; + } Wait; +#endif +} Thread_queue_Lock_context; + +#if defined(RTEMS_SMP) +/** + * @brief A thread queue link from one thread to another specified by the + * thread queue owner and thread wait queue relationships. + */ +typedef struct { + /** + * @brief Node to register this link in the global thread queue links lookup + * tree. + */ + RBTree_Node Registry_node; + + /** + * @brief The source thread queue determined by the thread queue owner. + */ + Thread_queue_Queue *source; + + /** + * @brief The target thread queue determined by the thread wait queue of the + * source owner. + */ + Thread_queue_Queue *target; + + /** + * @brief Node to add this link to a thread queue path. + */ + Chain_Node Path_node; + + /** + * @brief The owner of this thread queue link. + */ + Thread_Control *owner; + + /** + * @brief The queue lock context used to acquire the thread wait lock of the + * owner. + */ + Thread_queue_Lock_context Lock_context; +} Thread_queue_Link; +#endif + +/** + * @brief Thread queue context for the thread queue methods. + * + * @see _Thread_queue_Context_initialize(). + */ +struct Thread_queue_Context { + /** + * @brief The lock context for the thread queue acquire and release + * operations. + */ + Thread_queue_Lock_context Lock_context; + + /** + * @brief The thread state for _Thread_queue_Enqueue(). + */ + States_Control thread_state; + + /** + * @brief The enqueue callout for _Thread_queue_Enqueue(). + * + * The callout is invoked after the release of the thread queue lock with + * thread dispatching disabled. Afterwards the thread is blocked. This + * callout must be used to install the thread watchdog for timeout handling. + * + * @see _Thread_queue_Enqueue_do_nothing_extra(). + * _Thread_queue_Add_timeout_ticks(), and + * _Thread_queue_Add_timeout_realtime_timespec(). + */ + Thread_queue_Enqueue_callout enqueue_callout; + + /** + * @brief Interval to wait. + * + * May be used by the enqueue callout to register a timeout handler. + */ + union { + /** + * @brief The timeout in ticks. + */ + Watchdog_Interval ticks; + + /** + * @brief The timeout argument, e.g. pointer to struct timespec. + */ + const void *arg; + } Timeout; + +#if defined(RTEMS_SMP) + /** + * @brief Representation of a thread queue path from a start thread queue to + * the terminal thread queue. + * + * The start thread queue is determined by the object on which a thread intends + * to block. The terminal thread queue is the thread queue reachable via + * thread queue links whose owner is not blocked on a thread queue. The thread + * queue links are determined by the thread queue owner and thread wait queue + * relationships. + */ + struct { + /** + * @brief The chain of thread queue links defining the thread queue path. + */ + Chain_Control Links; + + /** + * @brief The start of a thread queue path. + */ + Thread_queue_Link Start; + + /** + * @brief In case of a deadlock, a link for the first thread on the path + * that tries to enqueue on a thread queue. + */ + Thread_queue_Link Deadlock; + } Path; +#endif + + /** + * @brief Block to manage thread priority changes due to a thread queue + * operation. + */ + struct { + /** + * @brief A priority action list. + */ + Priority_Actions Actions; + + /** + * @brief Count of threads to update the priority via + * _Thread_Priority_update(). + */ + size_t update_count; + + /** + * @brief Threads to update the priority via _Thread_Priority_update(). + * + * Currently, a maximum of two threads need an update in one rush, for + * example the thread of the thread queue operation and the owner of the + * thread queue. + */ + Thread_Control *update[ 2 ]; + } Priority; + + /** + * @brief Invoked in case of a detected deadlock. + * + * Must be initialized for _Thread_queue_Enqueue() in case the + * thread queue may have an owner, e.g. for mutex objects. + * + * @see _Thread_queue_Context_set_deadlock_callout(). + */ + Thread_queue_Deadlock_callout deadlock_callout; + +#if defined(RTEMS_MULTIPROCESSING) + /** + * @brief Callout to unblock the thread in case it is actually a thread + * proxy. + * + * This field is only used on multiprocessing configurations. Used by + * thread queue extract and unblock methods for objects with multiprocessing + * (MP) support. + * + * @see _Thread_queue_Context_set_MP_callout(). + */ + Thread_queue_MP_callout mp_callout; +#endif +}; + +/** + * @brief Thread priority queue. + */ +typedef struct { +#if defined(RTEMS_SMP) + /** + * @brief Node to enqueue this queue in the FIFO chain of the corresponding + * heads structure. + * + * @see Thread_queue_Heads::Heads::Fifo. + */ + Chain_Node Node; +#endif + + /** + * @brief The actual thread priority queue. + */ + Priority_Aggregation Queue; + + /** + * @brief This priority queue is added to a scheduler node of the owner in + * case of priority inheritance. + */ + struct Scheduler_Node *scheduler_node; +} Thread_queue_Priority_queue; + +/** + * @brief Thread queue heads. + * + * Each thread is equipped with spare thread queue heads in case it is not + * enqueued on a thread queue. The first thread enqueued on a thread queue + * will give its spare thread queue heads to that thread queue. The threads + * arriving at the queue will add their thread queue heads to the free chain of + * the queue heads provided by the first thread enqueued. Once a thread is + * dequeued it use the free chain to get new spare thread queue heads. + * + * Uses a leading underscore in the structure name to allow forward + * declarations in standard header files provided by Newlib and GCC. + */ +typedef struct _Thread_queue_Heads { + /** This union contains the data structures used to manage the blocked + * set of tasks which varies based upon the discipline. + */ + union { + /** + * @brief This is the FIFO discipline list. + * + * On SMP configurations this FIFO is used to enqueue the per scheduler + * instance priority queues of this structure. This ensures FIFO fairness + * among the highest priority thread of each scheduler instance. + */ + Chain_Control Fifo; + +#if !defined(RTEMS_SMP) + /** + * @brief This is the set of threads for priority discipline waiting. + */ + Thread_queue_Priority_queue Priority; +#endif + } Heads; + + /** + * @brief A chain with free thread queue heads providing the spare thread + * queue heads for a thread once it is dequeued. + */ + Chain_Control Free_chain; + + /** + * @brief A chain node to add these thread queue heads to the free chain of + * the thread queue heads dedicated to the thread queue of an object. + */ + Chain_Node Free_node; + +#if defined(RTEMS_SMP) + /** + * @brief One priority queue per scheduler instance. + */ + Thread_queue_Priority_queue Priority[ RTEMS_ZERO_LENGTH_ARRAY ]; +#endif +} Thread_queue_Heads; + +#if defined(RTEMS_SMP) + #define THREAD_QUEUE_HEADS_SIZE( scheduler_count ) \ + ( sizeof( Thread_queue_Heads ) \ + + ( scheduler_count ) * sizeof( Thread_queue_Priority_queue ) ) +#else + #define THREAD_QUEUE_HEADS_SIZE( scheduler_count ) \ + sizeof( Thread_queue_Heads ) +#endif + +struct Thread_queue_Queue { + /** + * @brief Lock to protect this thread queue. + * + * It may be used to protect additional state of the object embedding this + * thread queue. + * + * Must be the first component of this structure to be able to re-use + * implementation parts for structures defined by Newlib . + * + * @see _Thread_queue_Acquire(), _Thread_queue_Acquire_critical() and + * _Thread_queue_Release(). + */ +#if defined(RTEMS_SMP) + SMP_ticket_lock_Control Lock; +#endif + + /** + * @brief The thread queue heads. + * + * This pointer is NULL, if and only if no threads are enqueued. The first + * thread to enqueue will give its spare thread queue heads to this thread + * queue. + */ + Thread_queue_Heads *heads; + + /** + * @brief The thread queue owner. + */ + Thread_Control *owner; + + /** + * @brief The thread queue name. + */ + const char *name; +}; + +/** + * @brief Thread queue action operation. + * + * @param[in] queue The actual thread queue. + * @param[in] the_thread The thread. + * @param[in] queue_context The thread queue context providing the thread queue + * action set to perform. Returns the thread queue action set to perform on + * the thread queue owner or the empty set in case there is nothing to do. + */ +typedef void ( *Thread_queue_Priority_actions_operation )( + Thread_queue_Queue *queue, + Priority_Actions *priority_actions +); + +/** + * @brief Thread queue enqueue operation. + * + * A potential thread to update the priority due to priority inheritance is + * returned via the thread queue context. This thread is handed over to + * _Thread_Priority_update(). + * + * @param[in] queue The actual thread queue. + * @param[in] the_thread The thread to enqueue on the queue. + */ +typedef void ( *Thread_queue_Enqueue_operation )( + Thread_queue_Queue *queue, + Thread_Control *the_thread, + Thread_queue_Context *queue_context +); + +/** + * @brief Thread queue extract operation. + * + * @param[in] queue The actual thread queue. + * @param[in] the_thread The thread to extract from the thread queue. + */ +typedef void ( *Thread_queue_Extract_operation )( + Thread_queue_Queue *queue, + Thread_Control *the_thread, + Thread_queue_Context *queue_context +); + +/** + * @brief Thread queue surrender operation. + * + * This operation must dequeue and return the first thread on the queue. + * + * @param[in] queue The actual thread queue. + * @param[in] heads The thread queue heads. It must not be NULL. + * @param[in] previous_owner The previous owner of the thread queue. + * + * @return The previous first thread on the queue. + */ +typedef Thread_Control *( *Thread_queue_Surrender_operation )( + Thread_queue_Queue *queue, + Thread_queue_Heads *heads, + Thread_Control *previous_owner, + Thread_queue_Context *queue_context +); + +/** + * @brief Thread queue first operation. + * + * @param[in] heads The thread queue heads. + * + * @retval NULL No thread is present on the thread queue. + * @retval first The first thread of the thread queue according to the insert + * order. This thread remains on the thread queue. + */ +typedef Thread_Control *( *Thread_queue_First_operation )( + Thread_queue_Heads *heads +); + +/** + * @brief Thread queue operations. + * + * @see _Thread_wait_Set_operations(). + */ +struct Thread_queue_Operations { + /** + * @brief Thread queue priority actions operation. + */ + Thread_queue_Priority_actions_operation priority_actions; + + /** + * @brief Thread queue enqueue operation. + * + * Called by object routines to enqueue the thread. + */ + Thread_queue_Enqueue_operation enqueue; + + /** + * @brief Thread queue extract operation. + * + * Called by object routines to extract a thread from a thread queue. + */ + Thread_queue_Extract_operation extract; + + /** + * @brief Thread queue surrender operation. + */ + Thread_queue_Surrender_operation surrender; + + /** + * @brief Thread queue first operation. + */ + Thread_queue_First_operation first; +}; + +/** + * This is the structure used to manage sets of tasks which are blocked + * waiting to acquire a resource. + */ +typedef struct { +#if defined(RTEMS_SMP) +#if defined(RTEMS_DEBUG) + /** + * @brief The index of the owning processor of the thread queue lock. + * + * The thread queue lock may be acquired via the thread lock also. This path + * is not covered by this field. In case the lock is not owned directly via + * _Thread_queue_Acquire(), then the value of this field is + * SMP_LOCK_NO_OWNER. + * + * Must be before the queue component of this structure to be able to re-use + * implementation parts for structures defined by Newlib . + */ + uint32_t owner; +#endif + +#if defined(RTEMS_PROFILING) + /** + * @brief SMP lock statistics in case SMP and profiling are enabled. + * + * Must be before the queue component of this structure to be able to re-use + * implementation parts for structures defined by Newlib . + */ + SMP_lock_Stats Lock_stats; +#endif +#endif + + /** + * @brief The actual thread queue. + */ + Thread_queue_Queue Queue; +} Thread_queue_Control; + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/threadqimpl.h b/cpukit/include/rtems/score/threadqimpl.h new file mode 100644 index 0000000000..ecbd8fd42f --- /dev/null +++ b/cpukit/include/rtems/score/threadqimpl.h @@ -0,0 +1,1265 @@ +/** + * @file rtems/score/threadq.h + * + * Constants and Structures Associated with the Manipulation of Objects + * + * This include file contains all the constants and structures associated + * with the manipulation of objects. + */ + +/* + * COPYRIGHT (c) 1989-2014. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_THREADQIMPL_H +#define _RTEMS_SCORE_THREADQIMPL_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(RTEMS_DEBUG) +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup ScoreThreadQueue + */ +/**@{*/ + +#define THREAD_QUEUE_LINK_OF_PATH_NODE( node ) \ + RTEMS_CONTAINER_OF( node, Thread_queue_Link, Path_node ); + +/** + * @brief Thread queue with a layout compatible to struct _Thread_queue_Queue + * defined in Newlib . + */ +typedef struct { +#if !defined(RTEMS_SMP) + /* + * The struct _Thread_queue_Queue definition is independent of the RTEMS + * build configuration. Thus, the storage space for the SMP lock is always + * present. In SMP configurations, the SMP lock is contained in the + * Thread_queue_Queue. + */ + unsigned int reserved[2]; +#endif + + Thread_queue_Queue Queue; +} Thread_queue_Syslock_queue; + +void _Thread_queue_Enqueue_do_nothing_extra( + Thread_queue_Queue *queue, + Thread_Control *the_thread, + Per_CPU_Control *cpu_self, + Thread_queue_Context *queue_context +); + +void _Thread_queue_Add_timeout_ticks( + Thread_queue_Queue *queue, + Thread_Control *the_thread, + Per_CPU_Control *cpu_self, + Thread_queue_Context *queue_context +); + +void _Thread_queue_Add_timeout_monotonic_timespec( + Thread_queue_Queue *queue, + Thread_Control *the_thread, + Per_CPU_Control *cpu_self, + Thread_queue_Context *queue_context +); + +void _Thread_queue_Add_timeout_realtime_timespec( + Thread_queue_Queue *queue, + Thread_Control *the_thread, + Per_CPU_Control *cpu_self, + Thread_queue_Context *queue_context +); + +/** + * @brief Sets the thread wait return code to STATUS_DEADLOCK. + */ +void _Thread_queue_Deadlock_status( Thread_Control *the_thread ); + +/** + * @brief Results in an INTERNAL_ERROR_THREAD_QUEUE_DEADLOCK fatal error. + */ +void _Thread_queue_Deadlock_fatal( Thread_Control *the_thread ); + +/** + * @brief Initializes a thread queue context. + * + * @param queue_context The thread queue context to initialize. + */ +RTEMS_INLINE_ROUTINE void _Thread_queue_Context_initialize( + Thread_queue_Context *queue_context +) +{ +#if defined(RTEMS_DEBUG) + memset( queue_context, 0x7f, sizeof( *queue_context ) ); +#if defined(RTEMS_SMP) + _Chain_Initialize_node( &queue_context->Lock_context.Wait.Gate.Node ); +#endif + queue_context->enqueue_callout = NULL; + queue_context->deadlock_callout = NULL; +#else + (void) queue_context; +#endif +} + +/** + * @brief Sets the thread state for the thread to enqueue in the thread queue + * context. + * + * @param queue_context The thread queue context. + * @param state The thread state. + * + * @see _Thread_queue_Enqueue(). + */ +RTEMS_INLINE_ROUTINE void +_Thread_queue_Context_set_thread_state( + Thread_queue_Context *queue_context, + States_Control thread_state +) +{ + queue_context->thread_state = thread_state; +} + +/** + * @brief Sets the timeout ticks in the thread queue context. + * + * @param queue_context The thread queue context. + * @param ticks The timeout in ticks. + * + * @see _Thread_queue_Enqueue(). + */ +RTEMS_INLINE_ROUTINE void +_Thread_queue_Context_set_timeout_ticks( + Thread_queue_Context *queue_context, + Watchdog_Interval ticks +) +{ + queue_context->Timeout.ticks = ticks; +} + +/** + * @brief Sets the timeout argument in the thread queue context. + * + * @param queue_context The thread queue context. + * @param arg The timeout argument. + * + * @see _Thread_queue_Enqueue(). + */ +RTEMS_INLINE_ROUTINE void +_Thread_queue_Context_set_timeout_argument( + Thread_queue_Context *queue_context, + const void *arg +) +{ + queue_context->Timeout.arg = arg; +} + +/** + * @brief Sets the enqueue callout in the thread queue context. + * + * @param queue_context The thread queue context. + * @param enqueue_callout The enqueue callout. + * + * @see _Thread_queue_Enqueue(). + */ +RTEMS_INLINE_ROUTINE void +_Thread_queue_Context_set_enqueue_callout( + Thread_queue_Context *queue_context, + Thread_queue_Enqueue_callout enqueue_callout +) +{ + queue_context->enqueue_callout = enqueue_callout; +} + +/** + * @brief Sets the do nothing enqueue callout in the thread queue context. + * + * @param queue_context The thread queue context. + * + * @see _Thread_queue_Enqueue(). + */ +RTEMS_INLINE_ROUTINE void +_Thread_queue_Context_set_enqueue_do_nothing_extra( + Thread_queue_Context *queue_context +) +{ + queue_context->enqueue_callout = _Thread_queue_Enqueue_do_nothing_extra; +} + +/** + * @brief Sets the enqueue callout to add a relative monotonic timeout in + * ticks. + * + * @param queue_context The thread queue context. + * @param ticks The timeout in ticks. + * + * @see _Thread_queue_Enqueue(). + */ +RTEMS_INLINE_ROUTINE void +_Thread_queue_Context_set_enqueue_timeout_ticks( + Thread_queue_Context *queue_context, + Watchdog_Interval ticks +) +{ + queue_context->Timeout.ticks = ticks; + queue_context->enqueue_callout = _Thread_queue_Add_timeout_ticks; +} + +/** + * @brief Sets the enqueue callout to add an absolute monotonic timeout in + * timespec format. + * + * @param queue_context The thread queue context. + * @param abstime The absolute monotonic timeout. + * + * @see _Thread_queue_Enqueue(). + */ +RTEMS_INLINE_ROUTINE void +_Thread_queue_Context_set_enqueue_timeout_monotonic_timespec( + Thread_queue_Context *queue_context, + const struct timespec *abstime +) +{ + queue_context->Timeout.arg = abstime; + queue_context->enqueue_callout = + _Thread_queue_Add_timeout_monotonic_timespec; +} + +/** + * @brief Sets the enqueue callout to add an absolute realtime timeout in + * timespec format. + * + * @param queue_context The thread queue context. + * @param abstime The absolute realtime timeout. + * + * @see _Thread_queue_Enqueue(). + */ +RTEMS_INLINE_ROUTINE void +_Thread_queue_Context_set_enqueue_timeout_realtime_timespec( + Thread_queue_Context *queue_context, + const struct timespec *abstime +) +{ + queue_context->Timeout.arg = abstime; + queue_context->enqueue_callout = _Thread_queue_Add_timeout_realtime_timespec; +} + +/** + * @brief Sets the deadlock callout in the thread queue + * context. + * + * A deadlock callout must be provided for _Thread_queue_Enqueue() + * operations that operate on thread queues which may have an owner, e.g. mutex + * objects. Available deadlock callouts are _Thread_queue_Deadlock_status() + * and _Thread_queue_Deadlock_fatal(). + * + * @param queue_context The thread queue context. + * @param deadlock_callout The deadlock callout. + * + * @see _Thread_queue_Enqueue(). + */ +RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_deadlock_callout( + Thread_queue_Context *queue_context, + Thread_queue_Deadlock_callout deadlock_callout +) +{ + queue_context->deadlock_callout = deadlock_callout; +} + +RTEMS_INLINE_ROUTINE void _Thread_queue_Context_clear_priority_updates( + Thread_queue_Context *queue_context +) +{ + queue_context->Priority.update_count = 0; +} + +RTEMS_INLINE_ROUTINE size_t _Thread_queue_Context_save_priority_updates( + Thread_queue_Context *queue_context +) +{ + return queue_context->Priority.update_count; +} + +RTEMS_INLINE_ROUTINE void _Thread_queue_Context_restore_priority_updates( + Thread_queue_Context *queue_context, + size_t update_count +) +{ + queue_context->Priority.update_count = update_count; +} + +RTEMS_INLINE_ROUTINE void _Thread_queue_Context_add_priority_update( + Thread_queue_Context *queue_context, + Thread_Control *the_thread +) +{ + size_t n; + + n = queue_context->Priority.update_count; + _Assert( n < RTEMS_ARRAY_SIZE( queue_context->Priority.update ) ); + + queue_context->Priority.update_count = n + 1; + queue_context->Priority.update[ n ] = the_thread; +} + +#define _Thread_queue_Context_ISR_disable( queue_context, level ) \ + do { \ + _ISR_Local_disable( level ); \ + _ISR_lock_ISR_disable_profile( \ + &( queue_context )->Lock_context.Lock_context \ + ) \ + } while ( 0 ) + +RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_ISR_level( + Thread_queue_Context *queue_context, + ISR_Level level +) +{ + _ISR_lock_Context_set_level( + &queue_context->Lock_context.Lock_context, + level + ); +} + +RTEMS_INLINE_ROUTINE Per_CPU_Control *_Thread_queue_Dispatch_disable( + Thread_queue_Context *queue_context +) +{ + return _Thread_Dispatch_disable_critical( + &queue_context->Lock_context.Lock_context + ); +} + +/** + * @brief Sets the MP callout in the thread queue context. + * + * @param queue_context The thread queue context. + * @param mp_callout Callout to unblock the thread in case it is actually a + * thread proxy. This parameter is only used on multiprocessing + * configurations. Used by thread queue extract and unblock methods for + * objects with multiprocessing (MP) support. + */ +#if defined(RTEMS_MULTIPROCESSING) +RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_MP_callout( + Thread_queue_Context *queue_context, + Thread_queue_MP_callout mp_callout +) +{ + queue_context->mp_callout = mp_callout; +} +#else +#define _Thread_queue_Context_set_MP_callout( queue_context, mp_callout ) \ + do { \ + (void) queue_context; \ + } while ( 0 ) +#endif + +#if defined(RTEMS_SMP) +RTEMS_INLINE_ROUTINE void _Thread_queue_Gate_close( + Thread_queue_Gate *gate +) +{ + _Atomic_Store_uint( &gate->go_ahead, 0, ATOMIC_ORDER_RELAXED ); +} + +RTEMS_INLINE_ROUTINE void _Thread_queue_Gate_add( + Chain_Control *chain, + Thread_queue_Gate *gate +) +{ + _Chain_Append_unprotected( chain, &gate->Node ); +} + +RTEMS_INLINE_ROUTINE void _Thread_queue_Gate_open( + Thread_queue_Gate *gate +) +{ + _Atomic_Store_uint( &gate->go_ahead, 1, ATOMIC_ORDER_RELAXED ); +} + +RTEMS_INLINE_ROUTINE void _Thread_queue_Gate_wait( + Thread_queue_Gate *gate +) +{ + while ( _Atomic_Load_uint( &gate->go_ahead, ATOMIC_ORDER_RELAXED ) == 0 ) { + /* Wait */ + } +} +#endif + +RTEMS_INLINE_ROUTINE void _Thread_queue_Heads_initialize( + Thread_queue_Heads *heads +) +{ +#if defined(RTEMS_SMP) + size_t i; + + for ( i = 0; i < _Scheduler_Count; ++i ) { + _Chain_Initialize_node( &heads->Priority[ i ].Node ); + _Priority_Initialize_empty( &heads->Priority[ i ].Queue ); + heads->Priority[ i ].Queue.scheduler = &_Scheduler_Table[ i ]; + } +#endif + + _Chain_Initialize_empty( &heads->Free_chain ); + _Chain_Initialize_node( &heads->Free_node ); +} + +RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_initialize( + Thread_queue_Queue *queue, + const char *name +) +{ +#if defined(RTEMS_SMP) + _SMP_ticket_lock_Initialize( &queue->Lock ); +#endif + queue->heads = NULL; + queue->owner = NULL; + queue->name = name; +} + +RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_do_acquire_critical( + Thread_queue_Queue *queue, +#if defined(RTEMS_SMP) && defined(RTEMS_PROFILING) + SMP_lock_Stats *lock_stats, +#endif + ISR_lock_Context *lock_context +) +{ +#if defined(RTEMS_SMP) + _SMP_ticket_lock_Acquire( + &queue->Lock, + lock_stats, + &lock_context->Lock_context.Stats_context + ); +#else + (void) queue; + (void) lock_context; +#endif +} + +#if defined(RTEMS_SMP) && defined( RTEMS_PROFILING ) + #define \ + _Thread_queue_Queue_acquire_critical( queue, lock_stats, lock_context ) \ + _Thread_queue_Queue_do_acquire_critical( queue, lock_stats, lock_context ) +#else + #define \ + _Thread_queue_Queue_acquire_critical( queue, lock_stats, lock_context ) \ + _Thread_queue_Queue_do_acquire_critical( queue, lock_context ) +#endif + +RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_release_critical( + Thread_queue_Queue *queue, + ISR_lock_Context *lock_context +) +{ +#if defined(RTEMS_SMP) + _SMP_ticket_lock_Release( + &queue->Lock, + &lock_context->Lock_context.Stats_context + ); +#else + (void) queue; + (void) lock_context; +#endif +} + +RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_release( + Thread_queue_Queue *queue, + ISR_lock_Context *lock_context +) +{ + _Thread_queue_Queue_release_critical( queue, lock_context ); + _ISR_lock_ISR_enable( lock_context ); +} + +/** + * @brief Copies the thread queue name to the specified buffer. + * + * @param[in] queue The actual thread queue. + * @param[in] buffer The buffer for the thread queue name copy. + * @param[in] buffer_size The buffer size in characters. + * @param[in] id The object identifier in case the thread queue is embedded in + * an object with identifier, otherwise it is set to 0. + * + * @retval The length of the thread queue name. May be greater than or equal + * to the buffer size if truncation occurred. + */ +size_t _Thread_queue_Queue_get_name_and_id( + const Thread_queue_Queue *queue, + char *buffer, + size_t buffer_size, + Objects_Id *id +); + +#if defined(RTEMS_SMP) +void _Thread_queue_Do_acquire_critical( + Thread_queue_Control *the_thread_queue, + ISR_lock_Context *lock_context +); +#else +RTEMS_INLINE_ROUTINE void _Thread_queue_Do_acquire_critical( + Thread_queue_Control *the_thread_queue, + ISR_lock_Context *lock_context +) +{ + (void) the_thread_queue; + (void) lock_context; +} +#endif + +RTEMS_INLINE_ROUTINE void _Thread_queue_Acquire_critical( + Thread_queue_Control *the_thread_queue, + Thread_queue_Context *queue_context +) +{ + _Thread_queue_Do_acquire_critical( + the_thread_queue, + &queue_context->Lock_context.Lock_context + ); +} + +#if defined(RTEMS_SMP) +void _Thread_queue_Acquire( + Thread_queue_Control *the_thread_queue, + Thread_queue_Context *queue_context +); +#else +RTEMS_INLINE_ROUTINE void _Thread_queue_Acquire( + Thread_queue_Control *the_thread_queue, + Thread_queue_Context *queue_context +) +{ + (void) the_thread_queue; + _ISR_lock_ISR_disable( &queue_context->Lock_context.Lock_context ); +} +#endif + +#if defined(RTEMS_DEBUG) +RTEMS_INLINE_ROUTINE bool _Thread_queue_Is_lock_owner( + const Thread_queue_Control *the_thread_queue +) +{ +#if defined(RTEMS_SMP) + return the_thread_queue->owner == _SMP_lock_Who_am_I(); +#else + return _ISR_Get_level() != 0; +#endif +} +#endif + +#if defined(RTEMS_SMP) +void _Thread_queue_Do_release_critical( + Thread_queue_Control *the_thread_queue, + ISR_lock_Context *lock_context +); +#else +RTEMS_INLINE_ROUTINE void _Thread_queue_Do_release_critical( + Thread_queue_Control *the_thread_queue, + ISR_lock_Context *lock_context +) +{ + (void) the_thread_queue; + (void) lock_context; + _Assert( _Thread_queue_Is_lock_owner( the_thread_queue ) ); +} +#endif + +RTEMS_INLINE_ROUTINE void _Thread_queue_Release_critical( + Thread_queue_Control *the_thread_queue, + Thread_queue_Context *queue_context +) +{ + _Thread_queue_Do_release_critical( + the_thread_queue, + &queue_context->Lock_context.Lock_context + ); +} + +#if defined(RTEMS_SMP) +void _Thread_queue_Release( + Thread_queue_Control *the_thread_queue, + Thread_queue_Context *queue_context +); +#else +RTEMS_INLINE_ROUTINE void _Thread_queue_Release( + Thread_queue_Control *the_thread_queue, + Thread_queue_Context *queue_context +) +{ + (void) the_thread_queue; + _Assert( _Thread_queue_Is_lock_owner( the_thread_queue ) ); + _ISR_lock_ISR_enable( &queue_context->Lock_context.Lock_context ); +} +#endif + +Thread_Control *_Thread_queue_Do_dequeue( + Thread_queue_Control *the_thread_queue, + const Thread_queue_Operations *operations +#if defined(RTEMS_MULTIPROCESSING) + , + Thread_queue_MP_callout mp_callout +#endif +); + +/** + * @brief Gets a pointer to a thread waiting on the_thread_queue. + * + * This function returns a pointer to a thread waiting on + * the_thread_queue. The selection of this thread is based on + * the discipline of the_thread_queue. If no threads are waiting + * on the_thread_queue, then NULL is returned. + * + * - INTERRUPT LATENCY: + * + single case + */ +#if defined(RTEMS_MULTIPROCESSING) + #define _Thread_queue_Dequeue( \ + the_thread_queue, \ + operations, \ + mp_callout \ + ) \ + _Thread_queue_Do_dequeue( \ + the_thread_queue, \ + operations, \ + mp_callout \ + ) +#else + #define _Thread_queue_Dequeue( \ + the_thread_queue, \ + operations, \ + mp_callout \ + ) \ + _Thread_queue_Do_dequeue( \ + the_thread_queue, \ + operations \ + ) +#endif + +/** + * @brief Blocks the thread and places it on the thread queue. + * + * This enqueues the thread on the thread queue, blocks the thread, and + * optionally starts the thread timer in case the timeout discipline is not + * WATCHDOG_NO_TIMEOUT. Timeout discipline and value are in the queue_context. + * + * The caller must be the owner of the thread queue lock. This function will + * release the thread queue lock and register it as the new thread lock. + * Thread dispatching is disabled before the thread queue lock is released. + * Thread dispatching is enabled once the sequence to block the thread is + * complete. The operation to enqueue the thread on the queue is protected by + * the thread queue lock. This makes it possible to use the thread queue lock + * to protect the state of objects embedding the thread queue and directly + * enter _Thread_queue_Enqueue() in case the thread must block. + * + * The thread queue context must be set up with the following functions, + * otherwise the behaviour is unpredictable + * + * - _Thread_queue_Context_set_thread_state(), + * + * - _Thread_queue_Context_set_enqueue_callout() or + * _Thread_queue_Context_set_enqueue_do_nothing_extra() or + * _Thread_queue_Context_set_enqueue_timeout_ticks() or + * _Thread_queue_Context_set_enqueue_timeout_monotonic_timespec() or + * _Thread_queue_Context_set_enqueue_timeout_realtime_timespec(), + * + * - _Thread_queue_Context_set_deadlock_callout(). + * + * @code + * #include + * #include + * + * #define MUTEX_TQ_OPERATIONS &_Thread_queue_Operations_priority + * + * typedef struct { + * Thread_queue_Control Queue; + * } Mutex; + * + * void _Mutex_Obtain( Mutex *mutex ) + * { + * Thread_queue_Context queue_context; + * Thread_Control *executing; + * + * _Thread_queue_Context_initialize( &queue_context ); + * _Thread_queue_Acquire( &mutex->Queue, queue_context ); + * + * executing = _Thread_Executing; + * + * if ( mutex->Queue.owner == NULL ) { + * mutex->Queue.owner = executing; + * _Thread_queue_Release( &mutex->Queue, queue_context ); + * } else { + * _Thread_queue_Context_set_thread_state( + * &queue_context, + * STATES_WAITING_FOR_MUTEX + * ); + * _Thread_queue_Context_set_enqueue_do_nothing_extra( &queue_context ); + * _Thread_queue_Context_set_deadlock_callout( + * queue_context, + * _Thread_queue_Deadlock_fatal + * ); + * _Thread_queue_Enqueue( + * &mutex->Queue.Queue, + * MUTEX_TQ_OPERATIONS, + * executing, + * &queue_context + * ); + * } + * } + * @endcode + * + * @param[in] queue The actual thread queue. + * @param[in] operations The thread queue operations. + * @param[in] the_thread The thread to enqueue. + * @param[in] queue_context The thread queue context of the lock acquire. + */ +void _Thread_queue_Enqueue( + Thread_queue_Queue *queue, + const Thread_queue_Operations *operations, + Thread_Control *the_thread, + Thread_queue_Context *queue_context +); + +#if defined(RTEMS_SMP) +/** + * @brief Enqueues the thread on the thread queue and busy waits for dequeue. + * + * Optionally starts the thread timer in case the timeout discipline is not + * WATCHDOG_NO_TIMEOUT. Timeout discipline and value are in the queue_context. + * + * The caller must be the owner of the thread queue lock. This function will + * release the thread queue lock and register it as the new thread lock. + * + * The thread priorities of the owner and the are updated with respect to the + * scheduler. The sticky level of the thread is incremented. A thread + * dispatch is performed if necessary. + * + * Afterwards, the thread busy waits on the thread wait flags until a timeout + * occurs or the thread queue is surrendered to this thread. So, it sticks to + * the processor instead of blocking with respect to the scheduler. + * + * @param[in] queue The actual thread queue. + * @param[in] operations The thread queue operations. + * @param[in] the_thread The thread to enqueue. + * @param[in] queue_context The thread queue context of the lock acquire. + */ +Status_Control _Thread_queue_Enqueue_sticky( + Thread_queue_Queue *queue, + const Thread_queue_Operations *operations, + Thread_Control *the_thread, + Thread_queue_Context *queue_context +); +#endif + +/** + * @brief Extracts the thread from the thread queue, restores the default wait + * operations and restores the default thread lock. + * + * The caller must be the owner of the thread queue lock. The thread queue + * lock is not released. + * + * @param[in] queue The actual thread queue. + * @param[in] operations The thread queue operations. + * @param[in] the_thread The thread to extract. + * @param[in] queue_context The thread queue context. + * + * @return Returns the unblock indicator for _Thread_queue_Unblock_critical(). + * True indicates, that this thread must be unblocked by the scheduler later in + * _Thread_queue_Unblock_critical(), and false otherwise. In case false is + * returned, then the thread queue enqueue procedure was interrupted. Thus it + * will unblock itself and the thread wait information is no longer accessible, + * since this thread may already block on another resource in an SMP + * configuration. + */ +bool _Thread_queue_Extract_locked( + Thread_queue_Queue *queue, + const Thread_queue_Operations *operations, + Thread_Control *the_thread, + Thread_queue_Context *queue_context +); + +/** + * @brief Unblocks the thread which was on the thread queue before. + * + * The caller must be the owner of the thread queue lock. This function will + * release the thread queue lock. Thread dispatching is disabled before the + * thread queue lock is released and an unblock is necessary. Thread + * dispatching is enabled once the sequence to unblock the thread is complete. + * + * @param[in] unblock The unblock indicator returned by + * _Thread_queue_Extract_locked(). + * @param[in] queue The actual thread queue. + * @param[in] the_thread The thread to extract. + * @param[in] lock_context The lock context of the lock acquire. + */ +void _Thread_queue_Unblock_critical( + bool unblock, + Thread_queue_Queue *queue, + Thread_Control *the_thread, + ISR_lock_Context *lock_context +); + +/** + * @brief Extracts the thread from the thread queue and unblocks it. + * + * The caller must be the owner of the thread queue lock. This function will + * release the thread queue lock and restore the default thread lock. Thread + * dispatching is disabled before the thread queue lock is released and an + * unblock is necessary. Thread dispatching is enabled once the sequence to + * unblock the thread is complete. This makes it possible to use the thread + * queue lock to protect the state of objects embedding the thread queue and + * directly enter _Thread_queue_Extract_critical() to finalize an operation in + * case a waiting thread exists. + * + * @code + * #include + * + * typedef struct { + * Thread_queue_Control Queue; + * Thread_Control *owner; + * } Mutex; + * + * void _Mutex_Release( Mutex *mutex ) + * { + * Thread_queue_Context queue_context; + * Thread_Control *first; + * + * _Thread_queue_Context_initialize( &queue_context, NULL ); + * _Thread_queue_Acquire( &mutex->Queue, queue_context ); + * + * first = _Thread_queue_First_locked( &mutex->Queue ); + * mutex->owner = first; + * + * if ( first != NULL ) { + * _Thread_queue_Extract_critical( + * &mutex->Queue.Queue, + * mutex->Queue.operations, + * first, + * &queue_context + * ); + * } + * @endcode + * + * @param[in] queue The actual thread queue. + * @param[in] operations The thread queue operations. + * @param[in] the_thread The thread to extract. + * @param[in] queue_context The thread queue context of the lock acquire. + */ +void _Thread_queue_Extract_critical( + Thread_queue_Queue *queue, + const Thread_queue_Operations *operations, + Thread_Control *the_thread, + Thread_queue_Context *queue_context +); + +/** + * @brief Extracts thread from thread queue. + * + * This routine removes @a the_thread its thread queue + * and cancels any timeouts associated with this blocking. + * + * @param[in] the_thread is the pointer to a thread control block that + * is to be removed + */ +void _Thread_queue_Extract( Thread_Control *the_thread ); + +/** + * @brief Extracts the_thread from the_thread_queue. + * + * This routine extracts the_thread from the_thread_queue + * and ensures that if there is a proxy for this task on + * another node, it is also dealt with. + */ +void _Thread_queue_Extract_with_proxy( + Thread_Control *the_thread +); + +/** + * @brief Surrenders the thread queue previously owned by the thread to the + * first enqueued thread. + * + * The owner of the thread queue must be set to NULL by the caller. + * + * This function releases the thread queue lock. In addition it performs a + * thread dispatch if necessary. + * + * @param[in] queue The actual thread queue. + * @param[in] heads The thread queue heads. It must not be NULL. + * @param[in] previous_owner The previous owner thread surrendering the thread + * queue. + * @param[in] queue_context The thread queue context of the lock acquire. + * @param[in] operations The thread queue operations. + */ +void _Thread_queue_Surrender( + Thread_queue_Queue *queue, + Thread_queue_Heads *heads, + Thread_Control *previous_owner, + Thread_queue_Context *queue_context, + const Thread_queue_Operations *operations +); + +#if defined(RTEMS_SMP) +/** + * @brief Surrenders the thread queue previously owned by the thread to the + * first enqueued thread. + * + * The owner of the thread queue must be set to NULL by the caller. + * + * The caller must be the owner of the thread queue lock. This function will + * release the thread queue. + * + * The thread priorities of the previous owner and the new owner are updated. The + * sticky level of the previous owner is decremented. A thread dispatch is + * performed if necessary. + * + * @param[in] queue The actual thread queue. + * @param[in] heads The thread queue heads. It must not be NULL. + * @param[in] previous_owner The previous owner thread surrendering the thread + * queue. + * @param[in] queue_context The thread queue context of the lock acquire. + * @param[in] operations The thread queue operations. + */ +void _Thread_queue_Surrender_sticky( + Thread_queue_Queue *queue, + Thread_queue_Heads *heads, + Thread_Control *previous_owner, + Thread_queue_Context *queue_context, + const Thread_queue_Operations *operations +); +#endif + +RTEMS_INLINE_ROUTINE bool _Thread_queue_Is_empty( + const Thread_queue_Queue *queue +) +{ + return queue->heads == NULL; +} + +/** + * @brief Returns the first thread on the thread queue if it exists, otherwise + * @c NULL. + * + * The caller must be the owner of the thread queue lock. The thread queue + * lock is not released. + * + * @param[in] the_thread_queue The thread queue. + * @param[in] operations The thread queue operations. + * + * @retval NULL No thread is present on the thread queue. + * @retval first The first thread on the thread queue according to the enqueue + * order. + */ +RTEMS_INLINE_ROUTINE Thread_Control *_Thread_queue_First_locked( + Thread_queue_Control *the_thread_queue, + const Thread_queue_Operations *operations +) +{ + Thread_queue_Heads *heads = the_thread_queue->Queue.heads; + + if ( heads != NULL ) { + return ( *operations->first )( heads ); + } else { + return NULL; + } +} + +/** + * @brief Returns the first thread on the thread queue if it exists, otherwise + * @c NULL. + * + * @param[in] the_thread_queue The thread queue. + * + * @retval NULL No thread is present on the thread queue. + * @retval first The first thread on the thread queue according to the enqueue + * order. + */ +Thread_Control *_Thread_queue_First( + Thread_queue_Control *the_thread_queue, + const Thread_queue_Operations *operations +); + +/** + * @brief Thread queue flush filter function. + * + * Called under protection of the thread queue lock by + * _Thread_queue_Flush_critical() to optionally alter the thread wait + * information and control the iteration. + * + * @param the_thread The thread to extract. This is the first parameter to + * optimize for architectures that use the same register for the first + * parameter and the return value. + * @param queue The actual thread queue. + * @param queue_context The thread queue context of the lock acquire. May be + * used to pass additional data to the filter function via an overlay + * structure. The filter function should not release or acquire the thread + * queue lock. + * + * @retval the_thread Extract this thread. + * @retval NULL Do not extract this thread and stop the thread queue flush + * operation. Threads that are already extracted will complete the flush + * operation. + */ +typedef Thread_Control *( *Thread_queue_Flush_filter )( + Thread_Control *the_thread, + Thread_queue_Queue *queue, + Thread_queue_Context *queue_context +); + +/** + * @brief Default thread queue flush filter function. + * + * @param the_thread The thread to extract. + * @param queue Unused. + * @param queue_context Unused. + * + * @retval the_thread Extract this thread. + */ +Thread_Control *_Thread_queue_Flush_default_filter( + Thread_Control *the_thread, + Thread_queue_Queue *queue, + Thread_queue_Context *queue_context +); + +/** + * @brief Status unavailable thread queue flush filter function. + * + * Sets the thread wait return code of the thread to STATUS_UNAVAILABLE. + * + * @param the_thread The thread to extract. + * @param queue Unused. + * @param queue_context Unused. + * + * @retval the_thread Extract this thread. + */ +Thread_Control *_Thread_queue_Flush_status_unavailable( + Thread_Control *the_thread, + Thread_queue_Queue *queue, + Thread_queue_Context *queue_context +); + +/** + * @brief Status object was deleted thread queue flush filter function. + * + * Sets the thread wait return code of the thread to STATUS_OBJECT_WAS_DELETED + * + * @param the_thread The thread to extract. + * @param queue Unused. + * @param queue_context Unused. + * + * @retval the_thread Extract this thread. + */ +Thread_Control *_Thread_queue_Flush_status_object_was_deleted( + Thread_Control *the_thread, + Thread_queue_Queue *queue, + Thread_queue_Context *queue_context +); + +/** + * @brief Unblocks all threads enqueued on the thread queue. + * + * This function iteratively extracts the first enqueued thread of the thread + * queue until the thread queue is empty or the filter function indicates a + * stop. The thread timers of the extracted threads are cancelled. The + * extracted threads are unblocked. + * + * @param queue The actual thread queue. + * @param operations The thread queue operations. + * @param filter The filter functions is called for each thread to extract from + * the thread queue. It may be used to alter the thread under protection of + * the thread queue lock, for example to set the thread wait return code. + * The return value of the filter function controls if the thread queue flush + * operation should stop or continue. + * @param queue_context The thread queue context of the lock acquire. May be + * used to pass additional data to the filter function via an overlay + * structure. The filter function should not release or acquire the thread + * queue lock. + * + * @return The count of extracted threads. + */ +size_t _Thread_queue_Flush_critical( + Thread_queue_Queue *queue, + const Thread_queue_Operations *operations, + Thread_queue_Flush_filter filter, + Thread_queue_Context *queue_context +); + +void _Thread_queue_Initialize( + Thread_queue_Control *the_thread_queue, + const char *name +); + +#if defined(RTEMS_SMP) && defined(RTEMS_DEBUG) && defined(RTEMS_PROFILING) + #define THREAD_QUEUE_INITIALIZER( _name ) \ + { \ + .Lock_stats = SMP_LOCK_STATS_INITIALIZER( _name ), \ + .owner = SMP_LOCK_NO_OWNER, \ + .Queue = { \ + .Lock = SMP_TICKET_LOCK_INITIALIZER, \ + .heads = NULL, \ + .owner = NULL, \ + .name = _name \ + } \ + } +#elif defined(RTEMS_SMP) && defined(RTEMS_DEBUG) + #define THREAD_QUEUE_INITIALIZER( _name ) \ + { \ + .owner = SMP_LOCK_NO_OWNER, \ + .Queue = { \ + .Lock = SMP_TICKET_LOCK_INITIALIZER, \ + .heads = NULL, \ + .owner = NULL, \ + .name = _name \ + } \ + } +#elif defined(RTEMS_SMP) && defined(RTEMS_PROFILING) + #define THREAD_QUEUE_INITIALIZER( _name ) \ + { \ + .Lock_stats = SMP_LOCK_STATS_INITIALIZER( _name ), \ + .Queue = { \ + .Lock = SMP_TICKET_LOCK_INITIALIZER, \ + .heads = NULL, \ + .owner = NULL, \ + .name = _name \ + } \ + } +#elif defined(RTEMS_SMP) + #define THREAD_QUEUE_INITIALIZER( _name ) \ + { \ + .Queue = { \ + .Lock = SMP_TICKET_LOCK_INITIALIZER, \ + .heads = NULL, \ + .owner = NULL, \ + .name = _name \ + } \ + } +#else + #define THREAD_QUEUE_INITIALIZER( _name ) \ + { \ + .Queue = { \ + .heads = NULL, \ + .owner = NULL, \ + .name = _name \ + } \ + } +#endif + +RTEMS_INLINE_ROUTINE void _Thread_queue_Destroy( + Thread_queue_Control *the_thread_queue +) +{ +#if defined(RTEMS_SMP) + _SMP_ticket_lock_Destroy( &the_thread_queue->Queue.Lock ); + _SMP_lock_Stats_destroy( &the_thread_queue->Lock_stats ); +#endif +} + +#if defined(RTEMS_MULTIPROCESSING) +void _Thread_queue_MP_callout_do_nothing( + Thread_Control *the_proxy, + Objects_Id mp_id +); + +void _Thread_queue_Unblock_proxy( + Thread_queue_Queue *queue, + Thread_Control *the_thread +); +#endif + +#if defined(RTEMS_SMP) +bool _Thread_queue_Path_acquire_critical( + Thread_queue_Queue *queue, + Thread_Control *the_thread, + Thread_queue_Context *queue_context +); + +void _Thread_queue_Path_release_critical( + Thread_queue_Context *queue_context +); +#endif + +/** + * @brief Helper structure to ensure that all objects containing a thread queue + * have the right layout. + * + * @see _Thread_Wait_get_id() and THREAD_QUEUE_OBJECT_ASSERT(). + */ +typedef struct { + Objects_Control Object; + Thread_queue_Control Wait_queue; +} Thread_queue_Object; + +#define THREAD_QUEUE_OBJECT_ASSERT( object_type, wait_queue_member ) \ + RTEMS_STATIC_ASSERT( \ + offsetof( object_type, wait_queue_member ) \ + == offsetof( Thread_queue_Object, Wait_queue ) \ + && RTEMS_HAVE_MEMBER_SAME_TYPE( \ + object_type, \ + wait_queue_member, \ + Thread_queue_Object, \ + Wait_queue \ + ), \ + object_type \ + ) + +#define THREAD_QUEUE_QUEUE_TO_OBJECT( queue ) \ + RTEMS_CONTAINER_OF( \ + queue, \ + Thread_queue_Object, \ + Wait_queue.Queue \ + ) + +extern const Thread_queue_Operations _Thread_queue_Operations_default; + +extern const Thread_queue_Operations _Thread_queue_Operations_FIFO; + +extern const Thread_queue_Operations _Thread_queue_Operations_priority; + +extern const Thread_queue_Operations _Thread_queue_Operations_priority_inherit; + +/** + * @brief The special thread queue name to indicated that the thread queue is + * embedded in an object with identifier. + * + * @see _Thread_queue_Object_initialize(). + */ +extern const char _Thread_queue_Object_name[]; + +/** + * @brief Initializes a thread queue embedded in an object with identifier. + * + * The object must have the layout specified by Thread_queue_Object. It should + * be ensured with the THREAD_QUEUE_OBJECT_ASSERT() static assertion. + * + * @param[in] the_thread_queue The thread queue. + */ +void _Thread_queue_Object_initialize( + Thread_queue_Control *the_thread_queue +); + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/timecounter.h b/cpukit/include/rtems/score/timecounter.h new file mode 100644 index 0000000000..79444de482 --- /dev/null +++ b/cpukit/include/rtems/score/timecounter.h @@ -0,0 +1,244 @@ +/** + * @file + * + * @ingroup ScoreTimecounter + * + * @brief Timecounter API + */ + +/* + * Copyright (c) 2015 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_TIMECOUNTER_H +#define _RTEMS_SCORE_TIMECOUNTER_H + +#include +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup ScoreTimecounter Timecounter Handler + * + * @ingroup Score + * + * @{ + */ + +/** + * @brief Returns the wall clock time in the bintime format. + * + * @param[out] bt Returns the wall clock time. + */ +void _Timecounter_Bintime( struct bintime *bt ); + +/** + * @brief Returns the wall clock time in the timespec format. + * + * @param[out] ts Returns the wall clock time. + */ +void _Timecounter_Nanotime( struct timespec *ts ); + +/** + * @brief Returns the wall clock time in the timeval format. + * + * @param[out] tv Returns the wall clock time. + */ +void _Timecounter_Microtime( struct timeval *tv ); + +/** + * @brief Returns the uptime in the bintime format. + * + * @param[out] bt Returns the uptime. + */ +void _Timecounter_Binuptime( struct bintime *bt ); + +/** + * @brief Returns the uptime in the sbintime_t format. + * + * @return Returns the uptime. + */ +sbintime_t _Timecounter_Sbinuptime( void ); + +/** + * @brief Returns the uptime in the timespec format. + * + * @param[out] ts Returns the uptime. + */ +void _Timecounter_Nanouptime( struct timespec *ts ); + +/** + * @brief Returns the uptime in the timeval format. + * + * @param[out] tv Returns the uptime. + */ +void _Timecounter_Microuptime( struct timeval *tv ); + +/** + * @brief Returns the wall clock time in the bintime format. + * + * This function obtains the time with a lower overhead and lower accuracy + * compared to the _Timecounter_Bintime() variant. + * + * @param[out] ts Returns the wall clock time. + */ +void _Timecounter_Getbintime( struct bintime *bt ); + +/** + * @brief Returns the wall clock time in the timespec format. + * + * This function obtains the time with a lower overhead and lower accuracy + * compared to the _Timecounter_Nanotime() variant. + * + * @param[out] ts Returns the wall clock time. + * + * @see _Timecounter_Getbintime(). + */ +void _Timecounter_Getnanotime( struct timespec *ts ); + +/** + * @brief Returns the wall clock time in the timeval format. + * + * This function obtains the time with a lower overhead and lower accuracy + * compared to the _Timecounter_Microtime() variant. + * + * @param[out] tv Returns the wall clock time. + * + * @see _Timecounter_Getbintime(). + */ +void _Timecounter_Getmicrotime( struct timeval *tv ); + +/** + * @brief Returns the uptime in the bintime format. + * + * This function obtains the time with a lower overhead and lower accuracy + * compared to the _Timecounter_Binuptime() variant. + * + * @param[out] ts Returns the uptime. + */ +void _Timecounter_Getbinuptime( struct bintime *bt ); + +/** + * @brief Returns the uptime in the timespec format. + * + * This function obtains the time with a lower overhead and lower accuracy + * compared to the _Timecounter_Nanouptime() variant. + * + * @param[out] ts Returns the uptime. + */ +void _Timecounter_Getnanouptime( struct timespec *ts ); + +/** + * @brief Returns the uptime in the timeval format. + * + * This function obtains the time with a lower overhead and lower accuracy + * compared to the _Timecounter_Microuptime() variant. + * + * @param[out] tv Returns the uptime. + */ +void _Timecounter_Getmicrouptime( struct timeval *tv ); + +/** + * @brief Returns the boot time in the timeval format. + * + * @param[out] tv Returns the boot time. + */ +void _Timecounter_Getboottime( struct timeval *tv ); + +/** + * @brief Returns the boot time in the bintime format. + * + * @param[out] tv Returns the boot time. + */ +void _Timecounter_Getboottimebin( struct bintime *bt ); + +/** + * @brief Installs the timecounter. + * + * The timecounter structure must contain valid values in the fields + * tc_get_timecount, tc_counter_mask, tc_frequency and tc_quality. All other + * fields must be zero initialized. + * + * @param[in] tc The timecounter. + */ +void _Timecounter_Install( struct timecounter *tc ); + +/** + * @brief Performs a timecounter tick. + */ +void _Timecounter_Tick( void ); + +/** + * @brief Lock to protect the timecounter mechanic. + */ +ISR_LOCK_DECLARE( extern, _Timecounter_Lock ) + +/** + * @brief Acquires the timecounter lock. + * + * @param[in] lock_context The lock context. + * + * See _Timecounter_Tick_simple(). + */ +#define _Timecounter_Acquire( lock_context ) \ + _ISR_lock_ISR_disable_and_acquire( &_Timecounter_Lock, lock_context ) + +/** + * @brief Performs a simple timecounter tick. + * + * This is a special purpose tick function for simple timecounter to support + * legacy clock drivers. + * + * @param[in] delta The time in timecounter ticks elapsed since the last call + * to _Timecounter_Tick_simple(). + * @param[in] offset The current value of the timecounter. + * @param[in] lock_context The lock context of the corresponding + * _Timecounter_Acquire(). + */ +void _Timecounter_Tick_simple( + uint32_t delta, + uint32_t offset, + ISR_lock_Context *lock_context +); + +/** + * @brief The wall clock time in seconds. + */ +extern volatile time_t _Timecounter_Time_second; + +/** + * @brief The uptime in seconds. + * + * For compatibility with the FreeBSD network stack the initial value is one + * second. + */ +extern volatile int32_t _Timecounter_Time_uptime; + +/** + * @brief The current timecounter. + */ +extern struct timecounter *_Timecounter; + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_SCORE_TIMECOUNTER_H */ diff --git a/cpukit/include/rtems/score/timecounterimpl.h b/cpukit/include/rtems/score/timecounterimpl.h new file mode 100644 index 0000000000..a48ac70683 --- /dev/null +++ b/cpukit/include/rtems/score/timecounterimpl.h @@ -0,0 +1,50 @@ +/** + * @file + * + * @ingroup ScoreTimecounter + * + * @brief Timecounter Implementation + */ + +/* + * Copyright (c) 2015 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_TIMECOUNTERIMPL_H +#define _RTEMS_SCORE_TIMECOUNTERIMPL_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @addtogroup ScoreTimecounter + * + * @{ + */ + +void _Timecounter_Set_clock( + const struct bintime *bt, + ISR_lock_Context *lock_context +); + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_SCORE_TIMECOUNTERIMPL_H */ diff --git a/cpukit/include/rtems/score/timespec.h b/cpukit/include/rtems/score/timespec.h new file mode 100644 index 0000000000..72a000177f --- /dev/null +++ b/cpukit/include/rtems/score/timespec.h @@ -0,0 +1,272 @@ +/** + * @file rtems/score/timespec.h + * + * This include file contains helpers for manipulating timespecs. + */ + +/* + * COPYRIGHT (c) 1989-2009. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_TIMESPEC_H +#define _RTEMS_SCORE_TIMESPEC_H + +/** + * @defgroup Timespec Helpers + * + * @ingroup Score + * + * This handler encapsulates functionality related to manipulating + * POSIX struct timespecs. + */ +/**@{*/ + +#include /* bool */ +#include /* uint32_t */ +#include /* struct timespec */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Set timespec to seconds nanosecond. + * + * This method sets the timespec to the specified seconds and nanoseconds + * value. + * + * @param[in] _time points to the timespec instance to validate. + * @param[in] _seconds is the seconds portion of the timespec + * @param[in] _nanoseconds is the nanoseconds portion of the timespec + */ +#define _Timespec_Set( _time, _seconds, _nanoseconds ) \ + do { \ + (_time)->tv_sec = (_seconds); \ + (_time)->tv_nsec = (_nanoseconds); \ + } while (0) + +/** + * @brief Sets the Timespec to Zero + * + * This method sets the timespec to zero. + * value. + * + * @param[in] _time points to the timespec instance to zero. + */ +#define _Timespec_Set_to_zero( _time ) \ + do { \ + (_time)->tv_sec = 0; \ + (_time)->tv_nsec = 0; \ + } while (0) + +/** + * @brief Get seconds portion of timespec. + * + * This method returns the seconds portion of the specified timespec + * + * @param[in] _time points to the timespec + * + * @retval The seconds portion of @a _time. + */ +#define _Timespec_Get_seconds( _time ) \ + ((_time)->tv_sec) + +/** + * @brief Get nanoseconds portion of timespec. + * + * This method returns the nanoseconds portion of the specified timespec + * + * @param[in] _time points to the timespec + * + * @retval The nanoseconds portion of @a _time. + */ +#define _Timespec_Get_nanoseconds( _time ) \ + ((_time)->tv_nsec) + +/** + * @brief Get the timestamp as nanoseconds. + * + * This method returns the timestamp as nanoseconds. + * + * @param[in] time points to the timestamp. + * + * @retval The time in nanoseconds. + */ +uint64_t _Timespec_Get_as_nanoseconds( + const struct timespec *time +); + +/** + * @brief Check if timespec is valid. + * + * This method determines the validity of a timespec. + * + * @param[in] time is the timespec instance to validate. + * + * @retval This method returns true if @a time is valid and + * false otherwise. + */ +bool _Timespec_Is_valid( + const struct timespec *time +); + +/** + * @brief The Timespec "less than" operator. + * + * This method is the less than operator for timespecs. + * + * @param[in] lhs is the left hand side timespec + * @param[in] rhs is the right hand side timespec + * + * @retval This method returns true if @a lhs is less than the @a rhs and + * false otherwise. + */ +bool _Timespec_Less_than( + const struct timespec *lhs, + const struct timespec *rhs +); + +/** + * @brief The Timespec "greater than" operator. + * + * This method is the greater than operator for timespecs. + * + * @param[in] _lhs is the left hand side timespec + * @param[in] _rhs is the right hand side timespec + * + * @retval This method returns true if @a lhs is greater than the @a rhs and + * false otherwise. + */ +#define _Timespec_Greater_than( _lhs, _rhs ) \ + _Timespec_Less_than( _rhs, _lhs ) + +/** + * @brief The Timespec "equal to" operator. + * + * This method is the is equal to than operator for timespecs. + * + * @param[in] lhs is the left hand side timespec + * @param[in] rhs is the right hand side timespec + * + * @retval This method returns true if @a lhs is equal to @a rhs and + * false otherwise. + */ +#define _Timespec_Equal_to( lhs, rhs ) \ + ( ((lhs)->tv_sec == (rhs)->tv_sec) && \ + ((lhs)->tv_nsec == (rhs)->tv_nsec) \ + ) + +/** + * @brief Add two timespecs. + * + * This routine adds two timespecs. The second argument is added + * to the first. + * + * @param[in] time is the base time to be added to + * @param[in] add is the timespec to add to the first argument + * + * @retval This method returns the number of seconds @a time increased by. + */ +uint32_t _Timespec_Add_to( + struct timespec *time, + const struct timespec *add +); + +/** + * @brief Convert timespec to number of ticks. + * + * This routine convert the @a time timespec to the corresponding number + * of clock ticks. + * + * @param[in] time is the time to be converted + * + * @retval This method returns the number of ticks computed. + */ +uint32_t _Timespec_To_ticks( + const struct timespec *time +); + +/** + * @brief Convert ticks to timespec. + * + * This routine converts the @a ticks value to the corresponding + * timespec format @a time. + * + * @param[in] time is the timespec format time result + * @param[in] ticks is the number of ticks to convert + */ +void _Timespec_From_ticks( + uint32_t ticks, + struct timespec *time +); + +/** + * @brief Subtract two timespec. + * + * This routine subtracts two timespecs. @a result is set to + * @a end - @a start. + * + * @param[in] start is the starting time + * @param[in] end is the ending time + * @param[in] result is the difference between starting and ending time. + * + * @retval This method fills in @a result. + */ +void _Timespec_Subtract( + const struct timespec *start, + const struct timespec *end, + struct timespec *result +); + +/** + * @brief Divide timespec by an integer. + * + * This routine divides a timespec by an integer value. The expected + * use is to assist in benchmark calculations where you typically + * divide a duration by a number of iterations. + * + * @param[in] time is the total + * @param[in] iterations is the number of iterations + * @param[in] result is the average time. + * + * @retval This method fills in @a result. + */ +void _Timespec_Divide_by_integer( + const struct timespec *time, + uint32_t iterations, + struct timespec *result +); + +/** + * @brief Divide a timespec by anonther timespec. + * + * This routine divides a timespec by another timespec. The + * intended use is for calculating percentages to three decimal points. + * + * @param[in] lhs is the left hand number + * @param[in] rhs is the right hand number + * @param[in] ival_percentage is the integer portion of the average + * @param[in] fval_percentage is the thousandths of percentage + * + * @retval This method fills in @a result. + */ +void _Timespec_Divide( + const struct timespec *lhs, + const struct timespec *rhs, + uint32_t *ival_percentage, + uint32_t *fval_percentage +); + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/timestamp.h b/cpukit/include/rtems/score/timestamp.h new file mode 100644 index 0000000000..6fc17ced9c --- /dev/null +++ b/cpukit/include/rtems/score/timestamp.h @@ -0,0 +1,323 @@ +/** + * @file rtems/score/timestamp.h + * + * @brief Helpers for Manipulating Timestamps + * + * This include file contains helpers for manipulating timestamps. + */ + +/* + * COPYRIGHT (c) 1989-2009. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_TIMESTAMP_H +#define _RTEMS_SCORE_TIMESTAMP_H + +/** + * @defgroup SuperCoreTimeStamp Score Timestamp + * + * @ingroup Score + * + * This handler encapsulates functionality related to manipulating + * SuperCore Timestamps. SuperCore Timestamps may be used to + * represent time of day, uptime, or intervals. + * + * The key attribute of the SuperCore Timestamp handler is that it + * is a completely opaque handler. There can be multiple implementations + * of the required functionality and with a recompile, RTEMS can use + * any implementation. It is intended to be a simple wrapper. + * + * This handler can be implemented as either struct timespec or + * unsigned64 bit numbers. The use of a wrapper class allows the + * the implementation of timestamps to change on a per architecture + * basis. This is an important option as the performance of this + * handler is critical. + */ +/**@{*/ + +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Define the Timestamp control type. + */ +typedef sbintime_t Timestamp_Control; + +/** + * @brief Set timestamp to specified seconds and nanoseconds. + * + * This method sets the timestamp to the specified @a _seconds and @a _nanoseconds + * value. + * + * @param[in] _time points to the timestamp instance to validate. + * @param[in] _seconds is the seconds portion of the timestamp + * @param[in] _nanoseconds is the nanoseconds portion of the timestamp + */ +RTEMS_INLINE_ROUTINE void _Timestamp_Set( + Timestamp_Control *_time, + time_t _seconds, + long _nanoseconds +) +{ + struct timespec _ts; + + _ts.tv_sec = _seconds; + _ts.tv_nsec = _nanoseconds; + + *_time = tstosbt(_ts); +} + +/** + * @brief Sets the timestamp to zero. + * + * This method sets the timestamp to zero. + * value. + * + * @param[in] _time points to the timestamp instance to zero. + */ + +RTEMS_INLINE_ROUTINE void _Timestamp_Set_to_zero( + Timestamp_Control *_time +) +{ + *_time = 0; +} + +/** + * @brief Less than operator for timestamps. + * + * This method is the less than operator for timestamps. + * + * @param[in] _lhs points to the left hand side timestamp + * @param[in] _rhs points to the right hand side timestamp + * + * @retval This method returns true if @a _lhs is less than the @a _rhs and + * false otherwise. + */ + +RTEMS_INLINE_ROUTINE bool _Timestamp_Less_than( + const Timestamp_Control *_lhs, + const Timestamp_Control *_rhs +) +{ + return *_lhs < *_rhs; +} + +/** + * @brief Greater than operator for timestamps. + * + * This method is the greater than operator for timestamps. + * + * @param[in] _lhs points to the left hand side timestamp + * @param[in] _rhs points to the right hand side timestamp + * + * @retval This method returns true if @a _lhs is greater than the @a _rhs and + * false otherwise. + */ + +RTEMS_INLINE_ROUTINE bool _Timestamp_Greater_than( + const Timestamp_Control *_lhs, + const Timestamp_Control *_rhs +) +{ + return *_lhs > *_rhs; +} + +/** + * @brief Equal to than operator for timestamps. + * + * This method is the is equal to than operator for timestamps. + * + * @param[in] _lhs points to the left hand side timestamp + * @param[in] _rhs points to the right hand side timestamp + * + * @retval This method returns true if @a _lhs is equal to @a _rhs and + * false otherwise. + */ + +RTEMS_INLINE_ROUTINE bool _Timestamp_Equal_to( + const Timestamp_Control *_lhs, + const Timestamp_Control *_rhs +) +{ + return *_lhs == *_rhs; +} + +/** + * @brief Adds two timestamps. + * + * This routine adds two timestamps. The second argument is added + * to the first. + * + * @param[in] _time points to the base time to be added to + * @param[in] _add points to the timestamp to add to the first argument + */ +RTEMS_INLINE_ROUTINE void _Timestamp_Add_to( + Timestamp_Control *_time, + const Timestamp_Control *_add +) +{ + *_time += *_add; +} + +/** + * @brief Subtracts two timestamps. + * + * This routine subtracts two timestamps. @a result is set to + * @a end - @a start. + * + * @param[in] _start points to the starting time + * @param[in] _end points to the ending time + * @param[in] _result points to the difference between + * starting and ending time. + * + * @retval This method fills in @a _result. + */ +RTEMS_INLINE_ROUTINE void _Timestamp_Subtract( + const Timestamp_Control *_start, + const Timestamp_Control *_end, + Timestamp_Control *_result +) +{ + *_result = *_end - *_start; +} + +/** + * @brief Divides a timestamp by another timestamp. + * + * This routine divides a timestamp by another timestamp. The + * intended use is for calculating percentages to three decimal points. + * + * @param[in] _lhs points to the left hand number + * @param[in] _rhs points to the right hand number + * @param[in] _ival_percentage points to the integer portion of the average + * @param[in] _fval_percentage points to the thousandths of percentage + * + * @retval This method fills in @a result. + */ +RTEMS_INLINE_ROUTINE void _Timestamp_Divide( + const Timestamp_Control *_lhs, + const Timestamp_Control *_rhs, + uint32_t *_ival_percentage, + uint32_t *_fval_percentage +) +{ + struct timespec _ts_left; + struct timespec _ts_right; + + _ts_left = sbttots( *_lhs ); + _ts_right = sbttots( *_rhs ); + + _Timespec_Divide( + &_ts_left, + &_ts_right, + _ival_percentage, + _fval_percentage + ); +} + +/** + * @brief Get seconds portion of timestamp. + * + * This method returns the seconds portion of the specified timestamp + * + * @param[in] _time points to the timestamp + * + * @retval The seconds portion of @a _time. + */ +RTEMS_INLINE_ROUTINE time_t _Timestamp_Get_seconds( + const Timestamp_Control *_time +) +{ + return (*_time >> 32); +} + +/** + * @brief Get nanoseconds portion of timestamp. + * + * This method returns the nanoseconds portion of the specified timestamp + * + * @param[in] _time points to the timestamp + * + * @retval The nanoseconds portion of @a _time. + */ +RTEMS_INLINE_ROUTINE uint32_t _Timestamp_Get_nanoseconds( + const Timestamp_Control *_time +) +{ + struct timespec _ts; + + _ts = sbttots( *_time ); + + return (uint32_t) _ts.tv_nsec; +} + +/** + * @brief Get the timestamp as nanoseconds. + * + * This method returns the timestamp as nanoseconds. + * + * @param[in] _time points to the timestamp + * + * @retval The time in nanoseconds. + */ +RTEMS_INLINE_ROUTINE uint64_t _Timestamp_Get_as_nanoseconds( + const Timestamp_Control *_time +) +{ + struct timespec _ts; + + _ts = sbttots( *_time ); + + return _Timespec_Get_as_nanoseconds( &_ts ); +} + +/** + * @brief Convert timestamp to struct timespec. + * + * This method returns the seconds portion of the specified @a _timestamp. + * + * @param[in] _timestamp points to the timestamp + * @param[in] _timespec points to the timespec + */ +RTEMS_INLINE_ROUTINE void _Timestamp_To_timespec( + const Timestamp_Control *_timestamp, + struct timespec *_timespec +) +{ + *_timespec = sbttots( *_timestamp ); +} + +/** + * @brief Convert timestamp to struct timeval. + * + * @param[in] _timestamp points to the timestamp + * @param[in] _timeval points to the timeval + */ +RTEMS_INLINE_ROUTINE void _Timestamp_To_timeval( + const Timestamp_Control *_timestamp, + struct timeval *_timeval +) +{ + *_timeval = sbttotv( *_timestamp ); +} + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/tls.h b/cpukit/include/rtems/score/tls.h new file mode 100644 index 0000000000..644e54e6f7 --- /dev/null +++ b/cpukit/include/rtems/score/tls.h @@ -0,0 +1,217 @@ +/** + * @file + * + * @ingroup ScoreTLS + * + * @brief Thread-Local Storage (TLS) + */ + +/* + * Copyright (c) 2014 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_TLS_H +#define _RTEMS_SCORE_TLS_H + +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup ScoreTLS Thread-Local Storage (TLS) + * + * @ingroup Score + * + * @brief Thread-local storage (TLS) support. + * + * Variants I and II are according to Ulrich Drepper, "ELF Handling For + * Thread-Local Storage". + * + * @{ + */ + +extern char _TLS_Data_begin[]; + +extern char _TLS_Data_end[]; + +extern char _TLS_Data_size[]; + +extern char _TLS_BSS_begin[]; + +extern char _TLS_BSS_end[]; + +extern char _TLS_BSS_size[]; + +extern char _TLS_Size[]; + +extern char _TLS_Alignment[]; + +typedef struct { + /* + * FIXME: Not sure if the generation number type is correct for all + * architectures. + */ + uint32_t generation_number; + + void *tls_blocks[1]; +} TLS_Dynamic_thread_vector; + +typedef struct TLS_Thread_control_block { +#ifdef __i386__ + struct TLS_Thread_control_block *tcb; +#else + TLS_Dynamic_thread_vector *dtv; + uintptr_t reserved; +#endif +} TLS_Thread_control_block; + +typedef struct { + uintptr_t module; + uintptr_t offset; +} TLS_Index; + +static inline uintptr_t _TLS_Get_size( void ) +{ + /* + * Do not use _TLS_Size here since this will lead GCC to assume that this + * symbol is not 0 and the tests for 0 will be optimized away. + */ + return (uintptr_t) _TLS_BSS_end - (uintptr_t) _TLS_Data_begin; +} + +static inline uintptr_t _TLS_Heap_align_up( uintptr_t val ) +{ + uintptr_t msk = CPU_HEAP_ALIGNMENT - 1; + + return (val + msk) & ~msk; +} + +static inline uintptr_t _TLS_Get_thread_control_block_area_size( + uintptr_t alignment +) +{ + return alignment <= sizeof(TLS_Thread_control_block) ? + sizeof(TLS_Thread_control_block) : alignment; +} + +static inline uintptr_t _TLS_Get_allocation_size( + uintptr_t size, + uintptr_t alignment +) +{ + uintptr_t allocation_size = 0; + + allocation_size += _TLS_Heap_align_up( size ); + allocation_size += _TLS_Get_thread_control_block_area_size( alignment ); + +#ifndef __i386__ + allocation_size += sizeof(TLS_Dynamic_thread_vector); +#endif + + return allocation_size; +} + +static inline void *_TLS_Copy_and_clear( void *tls_area ) +{ + tls_area = memcpy( + tls_area, + _TLS_Data_begin, + (size_t) ((uintptr_t)_TLS_Data_size) + ); + + + memset( + (char *) tls_area + (size_t)((intptr_t) _TLS_BSS_begin) - + (size_t)((intptr_t) _TLS_Data_begin), + 0, + ((size_t) (intptr_t)_TLS_BSS_size) + ); + + return tls_area; +} + +static inline void *_TLS_Initialize( + void *tls_block, + TLS_Thread_control_block *tcb, + TLS_Dynamic_thread_vector *dtv +) +{ +#ifdef __i386__ + (void) dtv; + tcb->tcb = tcb; +#else + tcb->dtv = dtv; + dtv->generation_number = 1; + dtv->tls_blocks[0] = tls_block; +#endif + + return _TLS_Copy_and_clear( tls_block ); +} + +/* Use Variant I, TLS offsets emitted by linker takes the TCB into account */ +static inline void *_TLS_TCB_at_area_begin_initialize( void *tls_area ) +{ + void *tls_block = (char *) tls_area + + _TLS_Get_thread_control_block_area_size( (uintptr_t) _TLS_Alignment ); + TLS_Thread_control_block *tcb = tls_area; + uintptr_t aligned_size = _TLS_Heap_align_up( (uintptr_t) _TLS_Size ); + TLS_Dynamic_thread_vector *dtv = (TLS_Dynamic_thread_vector *) + ((char *) tls_block + aligned_size); + + return _TLS_Initialize( tls_block, tcb, dtv ); +} + +/* Use Variant I, TLS offsets emitted by linker neglects the TCB */ +static inline void *_TLS_TCB_before_TLS_block_initialize( void *tls_area ) +{ + void *tls_block = (char *) tls_area + + _TLS_Get_thread_control_block_area_size( (uintptr_t) _TLS_Alignment ); + TLS_Thread_control_block *tcb = (TLS_Thread_control_block *) + ((char *) tls_block - sizeof(*tcb)); + uintptr_t aligned_size = _TLS_Heap_align_up( (uintptr_t) _TLS_Size ); + TLS_Dynamic_thread_vector *dtv = (TLS_Dynamic_thread_vector *) + ((char *) tls_block + aligned_size); + + return _TLS_Initialize( tls_block, tcb, dtv ); +} + +/* Use Variant II */ +static inline void *_TLS_TCB_after_TLS_block_initialize( void *tls_area ) +{ + uintptr_t size = (uintptr_t) _TLS_Size; + uintptr_t tls_align = (uintptr_t) _TLS_Alignment; + uintptr_t tls_mask = tls_align - 1; + uintptr_t heap_align = _TLS_Heap_align_up( tls_align ); + uintptr_t heap_mask = heap_align - 1; + TLS_Thread_control_block *tcb = (TLS_Thread_control_block *) + ((char *) tls_area + ((size + heap_mask) & ~heap_mask)); + void *tls_block = (char *) tcb - ((size + tls_mask) & ~tls_mask); + TLS_Dynamic_thread_vector *dtv = (TLS_Dynamic_thread_vector *) + ((char *) tcb + sizeof(*tcb)); + + _TLS_Initialize( tls_block, tcb, dtv ); + + return tcb; +} + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_SCORE_TLS_H */ diff --git a/cpukit/include/rtems/score/tod.h b/cpukit/include/rtems/score/tod.h new file mode 100644 index 0000000000..c0ab5e795d --- /dev/null +++ b/cpukit/include/rtems/score/tod.h @@ -0,0 +1,32 @@ +/** + * @file + * + * @ingroup ScoreTOD + * + * @brief Time of Day Handler API + */ + +/* + * COPYRIGHT (c) 1989-2009. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_TOD_H +#define _RTEMS_SCORE_TOD_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/todimpl.h b/cpukit/include/rtems/score/todimpl.h new file mode 100644 index 0000000000..b00ab6cca2 --- /dev/null +++ b/cpukit/include/rtems/score/todimpl.h @@ -0,0 +1,304 @@ +/** + * @file + * + * @ingroup ScoreTOD + * + * @brief Time of Day Handler API + */ + +/* + * COPYRIGHT (c) 1989-2009. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_TODIMPL_H +#define _RTEMS_SCORE_TODIMPL_H + +#include +#include +#include +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ScoreTOD Time of Day Handler + * + * @ingroup Score + * + * The following constants are related to the time of day and are + * independent of RTEMS. + */ +/**@{*/ + +/** + * This constant represents the number of seconds in a minute. + */ +#define TOD_SECONDS_PER_MINUTE (uint32_t)60 + +/** + * This constant represents the number of minutes per hour. + */ +#define TOD_MINUTES_PER_HOUR (uint32_t)60 + +/** + * This constant represents the number of months in a year. + */ +#define TOD_MONTHS_PER_YEAR (uint32_t)12 + +/** + * This constant represents the number of days in a non-leap year. + */ +#define TOD_DAYS_PER_YEAR (uint32_t)365 + +/** + * This constant represents the number of hours per day. + */ +#define TOD_HOURS_PER_DAY (uint32_t)24 + +/** + * This constant represents the number of seconds in a day which does + * not include a leap second. + */ +#define TOD_SECONDS_PER_DAY (uint32_t) (TOD_SECONDS_PER_MINUTE * \ + TOD_MINUTES_PER_HOUR * \ + TOD_HOURS_PER_DAY) + +/** + * This constant represents the number of seconds in a non-leap year. + */ +#define TOD_SECONDS_PER_NON_LEAP_YEAR (365 * TOD_SECONDS_PER_DAY) + +/** + * This constant represents the number of millisecond in a second. + */ +#define TOD_MILLISECONDS_PER_SECOND (uint32_t)1000 + +/** + * This constant represents the number of microseconds in a second. + */ +#define TOD_MICROSECONDS_PER_SECOND (uint32_t)1000000 + +/** + * This constant represents the number of nanoseconds in a second. + */ +#define TOD_NANOSECONDS_PER_SECOND (uint32_t)1000000000 + +/** + * This constant represents the number of nanoseconds in a mircosecond. + */ +#define TOD_NANOSECONDS_PER_MICROSECOND (uint32_t)1000 + +/**@}*/ + +/** + * Seconds from January 1, 1970 to January 1, 1988. Used to account for + * differences between POSIX API and RTEMS core. The timespec format time + * is kept in POSIX compliant form. + */ +#define TOD_SECONDS_1970_THROUGH_1988 \ + (((1987 - 1970 + 1) * TOD_SECONDS_PER_NON_LEAP_YEAR) + \ + (4 * TOD_SECONDS_PER_DAY)) + +/** + * @brief Earliest year to which an time of day can be initialized. + * + * The following constant define the earliest year to which an + * time of day can be initialized. This is considered the + * epoch. + */ +#define TOD_BASE_YEAR 1988 + +/** + * @defgroup ScoreTOD Time Of Day (TOD) Handler + * + * @ingroup Score + * + * This handler encapsulates functionality used to manage time of day. + */ +/**@{*/ + +/** + * @brief TOD control. + */ +typedef struct { + /** + * @brief Indicates if the time of day is set. + * + * This is true if the application has set the current + * time of day, and false otherwise. + */ + bool is_set; +} TOD_Control; + +extern TOD_Control _TOD; + +void _TOD_Lock( void ); + +void _TOD_Unlock( void ); + +#if defined(RTEMS_DEBUG) +bool _TOD_Is_owner( void ); +#endif + +static inline void _TOD_Acquire( ISR_lock_Context *lock_context ) +{ + _Timecounter_Acquire( lock_context ); +} + +/** + * @brief Sets the time of day. + * + * The caller must be the owner of the TOD lock. + * + * @param tod The new time of day in timespec format representing + * the time since UNIX Epoch. + * @param lock_context The ISR lock context used for the corresponding + * _TOD_Acquire(). The caller must be the owner of the TOD lock. This + * function will release the TOD lock. + */ +void _TOD_Set( + const struct timespec *tod, + ISR_lock_Context *lock_context +); + +/** + * @brief Gets the current time in the timespec format. + * + * @param[out] time is the value gathered by the request + */ +static inline void _TOD_Get( + struct timespec *tod +) +{ + _Timecounter_Nanotime( tod ); +} + +/** + * @brief Gets the system uptime with potential accuracy to the nanosecond. + * + * This routine returns the system uptime with potential accuracy + * to the nanosecond. + * + * The initial uptime value is undefined. + * + * @param[in] time is a pointer to the uptime to be returned + */ +static inline void _TOD_Get_uptime( + Timestamp_Control *time +) +{ + *time = _Timecounter_Sbinuptime(); +} + +/** + * @brief Gets the system uptime with potential accuracy to the nanosecond. + * to the nanosecond. + * + * The initial uptime value is zero. + * + * @param[in] time is a pointer to the uptime to be returned + */ +static inline void _TOD_Get_zero_based_uptime( + Timestamp_Control *time +) +{ + *time = _Timecounter_Sbinuptime() - SBT_1S; +} + +/** + * @brief Gets the system uptime with potential accuracy to the nanosecond. + * + * The initial uptime value is zero. + * + * @param[in] time is a pointer to the uptime to be returned + */ +static inline void _TOD_Get_zero_based_uptime_as_timespec( + struct timespec *time +) +{ + _Timecounter_Nanouptime( time ); + --time->tv_sec; +} + +/** + * @brief Number of seconds Since RTEMS epoch. + * + * The following contains the number of seconds from 00:00:00 + * January 1, TOD_BASE_YEAR until the current time of day. + */ +static inline uint32_t _TOD_Seconds_since_epoch( void ) +{ + return (uint32_t) _Timecounter_Time_second; +} + +/** + * @brief Gets number of ticks in a second. + * + * This method returns the number of ticks in a second. + * + * @note If the clock tick value does not multiply evenly into a second + * then this number of ticks will be slightly shorter than a second. + */ +uint32_t TOD_TICKS_PER_SECOND_method(void); + +/** + * @brief Gets number of ticks in a second. + * + * This method exists to hide the fact that TOD_TICKS_PER_SECOND can not + * be implemented as a macro in a .h file due to visibility issues. + * The Configuration Table is not available to SuperCore .h files but + * is available to their .c files. + */ +#define TOD_TICKS_PER_SECOND TOD_TICKS_PER_SECOND_method() + +/** + * This routine returns a timeval based upon the internal timespec format TOD. + */ + +RTEMS_INLINE_ROUTINE void _TOD_Get_timeval( + struct timeval *time +) +{ + _Timecounter_Microtime( time ); +} + +/** + * @brief Adjust the Time of Time + * + * This method is used to adjust the current time of day by the + * specified amount. + * + * @param[in] delta is the amount to adjust + */ +void _TOD_Adjust( + const struct timespec *delta +); + +/** + * @brief Check if the TOD is Set + * + * @return TRUE is the time is set. FALSE otherwise. + */ +RTEMS_INLINE_ROUTINE bool _TOD_Is_set( void ) +{ + return _TOD.is_set; +} + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/userext.h b/cpukit/include/rtems/score/userext.h new file mode 100644 index 0000000000..5af5824808 --- /dev/null +++ b/cpukit/include/rtems/score/userext.h @@ -0,0 +1,273 @@ +/** + * @file + * + * @ingroup ScoreUserExt + * + * @brief User Extension Handler API + */ + +/* + * COPYRIGHT (c) 1989-2009. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_USEREXT_H +#define _RTEMS_SCORE_USEREXT_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void User_extensions_routine RTEMS_DEPRECATED; + +/** + * @defgroup ScoreUserExt User Extension Handler + * + * @ingroup Score + * + * @brief The User Extension Handler provides invocation of application + * dependent routines at critical points in the life of each thread and the + * system as a whole. + */ +/**@{**/ + +/** + * @brief Task create extension. + * + * It corresponds to _Thread_Initialize() (used by the rtems_task_create() + * directive and pthread_create()). + * + * It is invoked after the new thread has been completely initialized, but + * before it is placed on a ready chain. + * + * Thread dispatching may be disabled. This depends on the context of the + * _Thread_Initialize() call. Thread dispatch is disabled during the creation + * of the idle thread and the initialization threads. It can be considered as + * an invalid API usage, if the application calls _Thread_Initialize() with + * disabled thread dispatching. Disabled thread dispatching is different from + * disabled preemption. + * + * It can be assumed that the executing thread locked the allocator mutex. + * The only exception is the creation of the idle thread. In this case the + * allocator mutex is not locked. Since the allocator mutex allows nesting the + * normal memory allocation routines can be used. + * + * @param[in] executing The executing thread. + * @param[in] created The created thread. + * + * @retval true Successful operation. + * @retval false A thread create user extension will frequently attempt to + * allocate resources. If this allocation fails, then the extension should + * return @a false and the entire thread create operation will fail. + */ +typedef bool ( *User_extensions_thread_create_extension )( + Thread_Control *executing, + Thread_Control *created +); + +/** + * @brief Task delete extension. + * + * It corresponds to _Thread_Close() (used by the rtems_task_delete() + * directive, pthread_exit() and pthread_cancel()). + * + * It is invoked before all resources of the thread are deleted. The executing + * and deleted arguments are never equal. + * + * Thread dispatching is enabled. The executing thread locked the allocator + * mutex. + * + * @param[in] executing The executing thread. + * @param[in] deleted The deleted thread. + */ +typedef void( *User_extensions_thread_delete_extension )( + Thread_Control *executing, + Thread_Control *deleted +); + +/** + * @brief Task start extension. + * + * It corresponds to _Thread_Start() (used by the rtems_task_start() + * directive). + * + * It is invoked after the environment of the thread has been loaded and the + * thread has been made ready. + * + * Thread dispatching is disabled. The executing thread is not the holder of + * the allocator mutex. + * + * @param[in] executing The executing thread. + * @param[in] started The started thread. + */ +typedef void( *User_extensions_thread_start_extension )( + Thread_Control *executing, + Thread_Control *started +); + +/** + * @brief Task restart extension. + * + * It corresponds to _Thread_Restart() (used by the rtems_task_restart() + * directive). + * + * It is invoked in the context of the restarted thread right before the + * execution context is reloaded. The executing and restarted arguments are + * always equal. The thread stack reflects the previous execution context. + * + * Thread dispatching is enabled. The thread is not the holder of the + * allocator mutex. The thread life is protected. Thread restart and delete + * requests issued by restart extensions lead to recursion. + * + * @param[in] executing The executing thread. + * @param[in] restarted The executing thread. Yes, the executing thread. + */ +typedef void( *User_extensions_thread_restart_extension )( + Thread_Control *executing, + Thread_Control *restarted +); + +/** + * @brief Task switch extension. + * + * It corresponds to _Thread_Dispatch(). + * + * It is invoked before the context switch from the executing to the heir + * thread. + * + * Thread dispatching is disabled. The state of the allocator mutex is + * arbitrary. Interrupts are disabled and the per-CPU lock is acquired on SMP + * configurations. + * + * The context switches initiated through _Thread_Start_multitasking() are not + * covered by this extension. + * + * @param[in] executing The executing thread. + * @param[in] heir The heir thread. + */ +typedef void( *User_extensions_thread_switch_extension )( + Thread_Control *executing, + Thread_Control *heir +); + +/** + * @brief Task begin extension. + * + * It corresponds to _Thread_Handler(). + * + * Thread dispatching is disabled. The executing thread is not the holder of + * the allocator mutex. + * + * @param[in] executing The executing thread. + */ +typedef void( *User_extensions_thread_begin_extension )( + Thread_Control *executing +); + +/** + * @brief Task exitted extension. + * + * It corresponds to _Thread_Handler() after a return of the entry function. + * + * Thread dispatching is disabled. The state of the allocator mutex is + * arbitrary. + * + * @param[in] executing The executing thread. + */ +typedef void( *User_extensions_thread_exitted_extension )( + Thread_Control *executing +); + +/** + * @brief Fatal error extension. + * + * It corresponds to _Terminate() (used by the rtems_fatal() directive). + * + * This extension should not call any RTEMS directives. + * + * @param[in] source The fatal source indicating the subsystem the fatal + * condition originated in. + * @param[in] always_set_to_false This parameter is always set to false and + * provided only for backward compatibility reasons. + * @param[in] code The fatal error code. This value must be interpreted with + * respect to the source. + */ +typedef void( *User_extensions_fatal_extension )( + Internal_errors_Source source, + bool always_set_to_false, + Internal_errors_t code +); + +/** + * @brief Task termination extension. + * + * This extension is invoked by _Thread_Life_action_handler() in case a + * termination request is recognized. + * + * It is invoked in the context of the terminated thread right before the + * thread dispatch to the heir thread. The POSIX cleanup and key destructors + * execute in this context. + * + * Thread dispatching is enabled. The thread is not the holder of the + * allocator mutex. The thread life is protected. Thread restart and delete + * requests issued by terminate extensions lead to recursion. + * + * @param[in] terminated The terminated thread. + */ +typedef void( *User_extensions_thread_terminate_extension )( + Thread_Control *terminated +); + +/** + * @brief User extension table. + */ +typedef struct { + User_extensions_thread_create_extension thread_create; + User_extensions_thread_start_extension thread_start; + User_extensions_thread_restart_extension thread_restart; + User_extensions_thread_delete_extension thread_delete; + User_extensions_thread_switch_extension thread_switch; + User_extensions_thread_begin_extension thread_begin; + User_extensions_thread_exitted_extension thread_exitted; + User_extensions_fatal_extension fatal; + User_extensions_thread_terminate_extension thread_terminate; +} User_extensions_Table; + +/** + * @brief Manages the switch callouts. + * + * They are managed separately from other extensions for performance reasons. + */ +typedef struct { + Chain_Node Node; + User_extensions_thread_switch_extension thread_switch; +} User_extensions_Switch_control; + +/** + * @brief Manages each user extension set. + * + * The switch control is part of the extensions control even if not used due to + * the extension not having a switch handler. + */ +typedef struct { + Chain_Node Node; + User_extensions_Switch_control Switch; + User_extensions_Table Callouts; +} User_extensions_Control; + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/userextimpl.h b/cpukit/include/rtems/score/userextimpl.h new file mode 100644 index 0000000000..5ad2c63765 --- /dev/null +++ b/cpukit/include/rtems/score/userextimpl.h @@ -0,0 +1,369 @@ +/** + * @file + * + * @ingroup ScoreUserExt + * + * @brief User Extension Handler API + */ + +/* + * COPYRIGHT (c) 1989-2009. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_USEREXTIMPL_H +#define _RTEMS_SCORE_USEREXTIMPL_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ScoreUserExt User Extension Handler + * + * @ingroup Score + * + * @addtogroup ScoreUserExt + */ +/**@{**/ + +/** + * @brief Chain iterator for dynamic user extensions. + * + * Since user extensions may delete or restart the executing thread, we must + * clean up registered iterators. + * + * @see _User_extensions_Iterate(), _User_extensions_Destroy_iterators() and + * Thread_Control::last_user_extensions_iterator. + */ +typedef struct User_extensions_Iterator { + Chain_Iterator Iterator; + struct User_extensions_Iterator *previous; +} User_extensions_Iterator; + +typedef struct { + /** + * @brief Active dynamically added user extensions. + */ + Chain_Control Active; + + /** + * @brief Chain iterator registration. + */ + Chain_Iterator_registry Iterators; + + /** + * @brief Lock to protect User_extensions_List::Active and + * User_extensions_List::Iterators. + */ + ISR_LOCK_MEMBER( Lock ) +} User_extensions_List; + +/** + * @brief List of active extensions. + */ +extern User_extensions_List _User_extensions_List; + +/** + * @brief List of active task switch extensions. + */ +extern Chain_Control _User_extensions_Switches_list; + +/** + * @name Extension Maintainance + */ +/**@{**/ + +void _User_extensions_Handler_initialization( void ); + +void _User_extensions_Add_set( + User_extensions_Control *extension +); + +RTEMS_INLINE_ROUTINE void _User_extensions_Add_API_set( + User_extensions_Control *extension +) +{ + _User_extensions_Add_set( extension ); +} + +RTEMS_INLINE_ROUTINE void _User_extensions_Add_set_with_table( + User_extensions_Control *extension, + const User_extensions_Table *extension_table +) +{ + extension->Callouts = *extension_table; + + _User_extensions_Add_set( extension ); +} + +void _User_extensions_Remove_set( + User_extensions_Control *extension +); + +/** + * @brief User extension visitor. + * + * @param[in, out] executing The currently executing thread. + * @param[in, out] arg The argument passed to _User_extensions_Iterate(). + * @param[in] callouts The current callouts. + */ +typedef void (*User_extensions_Visitor)( + Thread_Control *executing, + void *arg, + const User_extensions_Table *callouts +); + +typedef struct { + Thread_Control *created; + bool ok; +} User_extensions_Thread_create_context; + +void _User_extensions_Thread_create_visitor( + Thread_Control *executing, + void *arg, + const User_extensions_Table *callouts +); + +void _User_extensions_Thread_delete_visitor( + Thread_Control *executing, + void *arg, + const User_extensions_Table *callouts +); + +void _User_extensions_Thread_start_visitor( + Thread_Control *executing, + void *arg, + const User_extensions_Table *callouts +); + +void _User_extensions_Thread_restart_visitor( + Thread_Control *executing, + void *arg, + const User_extensions_Table *callouts +); + +void _User_extensions_Thread_begin_visitor( + Thread_Control *executing, + void *arg, + const User_extensions_Table *callouts +); + +void _User_extensions_Thread_exitted_visitor( + Thread_Control *executing, + void *arg, + const User_extensions_Table *callouts +); + +typedef struct { + Internal_errors_Source source; + Internal_errors_t error; +} User_extensions_Fatal_context; + +void _User_extensions_Fatal_visitor( + Thread_Control *executing, + void *arg, + const User_extensions_Table *callouts +); + +void _User_extensions_Thread_terminate_visitor( + Thread_Control *executing, + void *arg, + const User_extensions_Table *callouts +); + +/** + * @brief Iterates through all user extensions and calls the visitor for each. + * + * @param[in, out] arg The argument passed to the visitor. + * @param[in] visitor The visitor for each extension. + * @param[in] direction The iteration direction for dynamic extensions. + */ +void _User_extensions_Iterate( + void *arg, + User_extensions_Visitor visitor, + Chain_Iterator_direction direction +); + +/** @} */ + +/** + * @name Extension Callout Dispatcher + */ +/**@{**/ + +static inline bool _User_extensions_Thread_create( Thread_Control *created ) +{ + User_extensions_Thread_create_context ctx = { created, true }; + + _User_extensions_Iterate( + &ctx, + _User_extensions_Thread_create_visitor, + CHAIN_ITERATOR_FORWARD + ); + + return ctx.ok; +} + +static inline void _User_extensions_Thread_delete( Thread_Control *deleted ) +{ + _User_extensions_Iterate( + deleted, + _User_extensions_Thread_delete_visitor, + CHAIN_ITERATOR_BACKWARD + ); +} + +static inline void _User_extensions_Thread_start( Thread_Control *started ) +{ + _User_extensions_Iterate( + started, + _User_extensions_Thread_start_visitor, + CHAIN_ITERATOR_FORWARD + ); +} + +static inline void _User_extensions_Thread_restart( Thread_Control *restarted ) +{ + _User_extensions_Iterate( + restarted, + _User_extensions_Thread_restart_visitor, + CHAIN_ITERATOR_FORWARD + ); +} + +static inline void _User_extensions_Thread_begin( Thread_Control *executing ) +{ + _User_extensions_Iterate( + executing, + _User_extensions_Thread_begin_visitor, + CHAIN_ITERATOR_FORWARD + ); +} + +static inline void _User_extensions_Thread_switch( + Thread_Control *executing, + Thread_Control *heir +) +{ + const Chain_Control *chain = &_User_extensions_Switches_list; + const Chain_Node *tail = _Chain_Immutable_tail( chain ); + const Chain_Node *node = _Chain_Immutable_first( chain ); + + if ( node != tail ) { + Per_CPU_Control *cpu_self; +#if defined(RTEMS_SMP) + ISR_Level level; +#endif + + cpu_self = _Per_CPU_Get(); + +#if defined(RTEMS_SMP) + _ISR_Local_disable( level ); +#endif + _Per_CPU_Acquire( cpu_self ); + + while ( node != tail ) { + const User_extensions_Switch_control *extension = + (const User_extensions_Switch_control *) node; + + (*extension->thread_switch)( executing, heir ); + + node = _Chain_Immutable_next( node ); + } + + _Per_CPU_Release( cpu_self ); +#if defined(RTEMS_SMP) + _ISR_Local_enable( level ); +#endif + } +} + +static inline void _User_extensions_Thread_exitted( Thread_Control *executing ) +{ + _User_extensions_Iterate( + executing, + _User_extensions_Thread_exitted_visitor, + CHAIN_ITERATOR_FORWARD + ); +} + +static inline void _User_extensions_Fatal( + Internal_errors_Source source, + Internal_errors_t error +) +{ + User_extensions_Fatal_context ctx = { source, error }; + + _User_extensions_Iterate( + &ctx, + _User_extensions_Fatal_visitor, + CHAIN_ITERATOR_FORWARD + ); +} + +static inline void _User_extensions_Thread_terminate( + Thread_Control *executing +) +{ + _User_extensions_Iterate( + executing, + _User_extensions_Thread_terminate_visitor, + CHAIN_ITERATOR_BACKWARD + ); +} + +static inline void _User_extensions_Acquire( ISR_lock_Context *lock_context ) +{ + _ISR_lock_ISR_disable_and_acquire( + &_User_extensions_List.Lock, + lock_context + ); +} + +static inline void _User_extensions_Release( ISR_lock_Context *lock_context ) +{ + _ISR_lock_Release_and_ISR_enable( + &_User_extensions_List.Lock, + lock_context + ); +} + +static inline void _User_extensions_Destroy_iterators( + Thread_Control *the_thread +) +{ + ISR_lock_Context lock_context; + User_extensions_Iterator *iter; + + _User_extensions_Acquire( &lock_context ); + + iter = the_thread->last_user_extensions_iterator; + + while ( iter != NULL ) { + _Chain_Iterator_destroy( &iter->Iterator ); + iter = iter->previous; + } + + _User_extensions_Release( &lock_context ); +} + +/** @} */ + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/watchdog.h b/cpukit/include/rtems/score/watchdog.h new file mode 100644 index 0000000000..dbb092bbef --- /dev/null +++ b/cpukit/include/rtems/score/watchdog.h @@ -0,0 +1,166 @@ +/** + * @file rtems/score/watchdog.h + * + * @brief Constants and Structures Associated with Watchdog Timers + * + * This include file contains all the constants and structures associated + * with watchdog timers. This Handler provides mechanisms which can be + * used to initialize and manipulate watchdog timers. + */ + +/* + * COPYRIGHT (c) 1989-2009. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_WATCHDOG_H +#define _RTEMS_SCORE_WATCHDOG_H + +#include +#include +#include + +struct Per_CPU_Control; + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ScoreWatchdog Watchdog Handler + * + * @ingroup Score + * + * This handler encapsulates functionality related to the scheduling of + * watchdog functions to be called at specific times in the future. + * + * @note This handler does not have anything to do with hardware watchdog + * timers. + */ +/**@{*/ + +typedef struct Watchdog_Control Watchdog_Control; + +/** + * @brief Type is used to specify the length of intervals. + * + * This type is used to specify the length of intervals. + */ +typedef uint32_t Watchdog_Interval; + +/** + * @brief Special watchdog ticks value to indicate an infinite wait. + */ +#define WATCHDOG_NO_TIMEOUT 0 + +/** + * @brief Return type from a Watchdog Service Routine. + * + * This type defines the return type from a Watchdog Service Routine. + */ +typedef void Watchdog_Service_routine; + +/** + * @brief Pointer to a watchdog service routine. + * + * This type define a pointer to a watchdog service routine. + */ +typedef Watchdog_Service_routine + ( *Watchdog_Service_routine_entry )( Watchdog_Control * ); + +/** + * @brief The watchdog header to manage scheduled watchdogs. + */ +typedef struct { + /** + * @brief Red-black tree of scheduled watchdogs sorted by expiration time. + */ + RBTree_Control Watchdogs; + + /** + * @brief The scheduled watchdog with the earliest expiration time or NULL in + * case no watchdog is scheduled. + */ + RBTree_Node *first; +} Watchdog_Header; + +/** + * @brief The control block used to manage each watchdog timer. + * + * The following record defines the control block used + * to manage each watchdog timer. + */ +struct Watchdog_Control { + /** + * @brief Nodes for the watchdog. + */ + union { + /** + * @brief this field is a red-black tree node structure and allows this to + * be placed on a red-black tree used to manage the scheduled watchdogs. + */ + RBTree_Node RBTree; + + /** + * @brief this field is a chain node structure and allows this to be placed + * on a chain used to manage pending watchdogs by the timer server. + */ + Chain_Node Chain; + } Node; + +#if defined(RTEMS_SMP) + /** @brief This field references the processor of this watchdog control. */ + struct Per_CPU_Control *cpu; +#endif + + /** @brief This field is the function to invoke. */ + Watchdog_Service_routine_entry routine; + + /** @brief This field is the expiration time point. */ + uint64_t expire; +}; + +/** + * @brief The watchdog ticks counter. + * + * With a 1ms watchdog tick, this counter overflows after 50 days since boot. + */ +extern volatile Watchdog_Interval _Watchdog_Ticks_since_boot; + +/** + * @brief The watchdog nanoseconds per tick. + * + * This constant is defined by the application configuration via + * . + */ +extern const uint32_t _Watchdog_Nanoseconds_per_tick; + +/** + * @brief The watchdog ticks per second. + * + * This constant is defined by the application configuration via + * . + */ +extern const uint32_t _Watchdog_Ticks_per_second; + +/** + * @brief The maximum number of seconds representable in the monotonic watchdog + * format. + * + * This constant is defined by the application configuration via + * . + */ +extern const uint64_t _Watchdog_Monotonic_max_seconds; + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/watchdogimpl.h b/cpukit/include/rtems/score/watchdogimpl.h new file mode 100644 index 0000000000..f219a70768 --- /dev/null +++ b/cpukit/include/rtems/score/watchdogimpl.h @@ -0,0 +1,574 @@ +/** + * @file + * + * @brief Inlined Routines in the Watchdog Handler + * + * This file contains the static inline implementation of all inlined + * routines in the Watchdog Handler. + */ + +/* + * COPYRIGHT (c) 1989-2004. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_WATCHDOGIMPL_H +#define _RTEMS_SCORE_WATCHDOGIMPL_H + +#include +#include +#include +#include +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup ScoreWatchdog + * @{ + */ + +/** + * @brief Watchdog states. + */ +typedef enum { + /** + * @brief The watchdog is scheduled and a black node in the red-black tree. + */ + WATCHDOG_SCHEDULED_BLACK, + + /** + * @brief The watchdog is scheduled and a red node in the red-black tree. + */ + WATCHDOG_SCHEDULED_RED, + + /** + * @brief The watchdog is inactive. + */ + WATCHDOG_INACTIVE, + + /** + * @brief The watchdog is on a chain of pending watchdogs. + * + * This state is used by the timer server for example. + */ + WATCHDOG_PENDING +} Watchdog_State; + +/** + * @brief Watchdog initializer for static initialization. + * + * The processor of this watchdog is set to processor with index zero. + * + * @see _Watchdog_Preinitialize(). + */ +#if defined(RTEMS_SMP) + #define WATCHDOG_INITIALIZER( routine ) \ + { \ + { { { NULL, NULL, NULL, WATCHDOG_INACTIVE } } }, \ + &_Per_CPU_Information[ 0 ].per_cpu, \ + ( routine ), \ + 0 \ + } +#else + #define WATCHDOG_INITIALIZER( routine ) \ + { \ + { { { NULL, NULL, NULL, WATCHDOG_INACTIVE } } }, \ + ( routine ), \ + 0 \ + } +#endif + +RTEMS_INLINE_ROUTINE void _Watchdog_Header_initialize( + Watchdog_Header *header +) +{ + _RBTree_Initialize_empty( &header->Watchdogs ); + header->first = NULL; +} + +RTEMS_INLINE_ROUTINE void _Watchdog_Header_destroy( + Watchdog_Header *header +) +{ + /* Do nothing */ + (void) header; +} + +/** + * @brief Performs a watchdog tick. + * + * @param cpu The processor for this watchdog tick. + */ +void _Watchdog_Tick( struct Per_CPU_Control *cpu ); + +RTEMS_INLINE_ROUTINE Watchdog_State _Watchdog_Get_state( + const Watchdog_Control *the_watchdog +) +{ + return RB_COLOR( &the_watchdog->Node.RBTree, Node ); +} + +RTEMS_INLINE_ROUTINE void _Watchdog_Set_state( + Watchdog_Control *the_watchdog, + Watchdog_State state +) +{ + RB_COLOR( &the_watchdog->Node.RBTree, Node ) = state; +} + +RTEMS_INLINE_ROUTINE Per_CPU_Control *_Watchdog_Get_CPU( + const Watchdog_Control *the_watchdog +) +{ +#if defined(RTEMS_SMP) + return the_watchdog->cpu; +#else + return _Per_CPU_Get_by_index( 0 ); +#endif +} + +RTEMS_INLINE_ROUTINE void _Watchdog_Set_CPU( + Watchdog_Control *the_watchdog, + Per_CPU_Control *cpu +) +{ +#if defined(RTEMS_SMP) + the_watchdog->cpu = cpu; +#else + (void) cpu; +#endif +} + +/** + * @brief Pre-initializes a watchdog. + * + * This routine must be called before a watchdog is used in any way. The + * exception are statically initialized watchdogs via WATCHDOG_INITIALIZER(). + * + * @param[in] the_watchdog The uninitialized watchdog. + */ +RTEMS_INLINE_ROUTINE void _Watchdog_Preinitialize( + Watchdog_Control *the_watchdog, + Per_CPU_Control *cpu +) +{ + _Watchdog_Set_CPU( the_watchdog, cpu ); + _Watchdog_Set_state( the_watchdog, WATCHDOG_INACTIVE ); + +#if defined(RTEMS_DEBUG) + the_watchdog->routine = NULL; + the_watchdog->expire = 0; +#endif +} + +/** + * @brief Initializes a watchdog with a new service routine. + * + * The watchdog must be inactive. + */ +RTEMS_INLINE_ROUTINE void _Watchdog_Initialize( + Watchdog_Control *the_watchdog, + Watchdog_Service_routine_entry routine +) +{ + _Assert( _Watchdog_Get_state( the_watchdog ) == WATCHDOG_INACTIVE ); + the_watchdog->routine = routine; +} + +void _Watchdog_Do_tickle( + Watchdog_Header *header, + uint64_t now, +#if defined(RTEMS_SMP) + ISR_lock_Control *lock, +#endif + ISR_lock_Context *lock_context +); + +#if defined(RTEMS_SMP) + #define _Watchdog_Tickle( header, now, lock, lock_context ) \ + _Watchdog_Do_tickle( header, now, lock, lock_context ) +#else + #define _Watchdog_Tickle( header, now, lock, lock_context ) \ + _Watchdog_Do_tickle( header, now, lock_context ) +#endif + +/** + * @brief Inserts a watchdog into the set of scheduled watchdogs according to + * the specified expiration time. + * + * The watchdog must be inactive. + */ +void _Watchdog_Insert( + Watchdog_Header *header, + Watchdog_Control *the_watchdog, + uint64_t expire +); + +/** + * @brief In case the watchdog is scheduled, then it is removed from the set of + * scheduled watchdogs. + * + * The watchdog must be initialized before this call. + */ +void _Watchdog_Remove( + Watchdog_Header *header, + Watchdog_Control *the_watchdog +); + +/** + * @brief In case the watchdog is scheduled, then it is removed from the set of + * scheduled watchdogs. + * + * The watchdog must be initialized before this call. + * + * @retval 0 The now time is greater than or equal to the expiration time of + * the watchdog. + * @retval other The difference of the now and expiration time. + */ +RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Cancel( + Watchdog_Header *header, + Watchdog_Control *the_watchdog, + uint64_t now +) +{ + uint64_t expire; + uint64_t remaining; + + expire = the_watchdog->expire; + + if ( now < expire ) { + remaining = expire - now; + } else { + remaining = 0; + } + + _Watchdog_Remove( header, the_watchdog ); + + return remaining; +} + +RTEMS_INLINE_ROUTINE bool _Watchdog_Is_scheduled( + const Watchdog_Control *the_watchdog +) +{ + return _Watchdog_Get_state( the_watchdog ) < WATCHDOG_INACTIVE; +} + +RTEMS_INLINE_ROUTINE void _Watchdog_Next_first( + Watchdog_Header *header, + Watchdog_Control *the_watchdog +) +{ + RBTree_Node *node = _RBTree_Right( &the_watchdog->Node.RBTree ); + + if ( node != NULL ) { + RBTree_Node *left; + + while ( ( left = _RBTree_Left( node ) ) != NULL ) { + node = left; + } + + header->first = node; + } else { + header->first = _RBTree_Parent( &the_watchdog->Node.RBTree ); + } +} + +/** + * @brief The maximum watchdog ticks value for the far future. + */ +#define WATCHDOG_MAXIMUM_TICKS UINT64_MAX + +#define WATCHDOG_NANOSECONDS_PER_SECOND 1000000000 + +/** + * @brief The bits necessary to store 1000000000 + * (= WATCHDOG_NANOSECONDS_PER_SECOND) nanoseconds. + * + * The expiration time is an unsigned 64-bit integer. To store absolute + * timeouts we use 30 bits (2**30 == 1073741824) for the nanoseconds and 34 + * bits for the seconds since UNIX Epoch. This leads to a year 2514 problem. + */ +#define WATCHDOG_BITS_FOR_1E9_NANOSECONDS 30 + +/** + * @brief The maximum number of seconds representable in the realtime watchdog + * format. + * + * We have 2**34 bits for the seconds part. + */ +#define WATCHDOG_REALTIME_MAX_SECONDS 0x3ffffffff + +RTEMS_INLINE_ROUTINE bool _Watchdog_Is_valid_timespec( + const struct timespec *ts +) +{ + return ts != NULL + && (unsigned long) ts->tv_nsec < WATCHDOG_NANOSECONDS_PER_SECOND; +} + +RTEMS_INLINE_ROUTINE bool _Watchdog_Is_valid_interval_timespec( + const struct timespec *ts +) +{ + return _Watchdog_Is_valid_timespec( ts ) && ts->tv_sec >= 0; +} + +RTEMS_INLINE_ROUTINE const struct timespec * _Watchdog_Future_timespec( + struct timespec *now, + const struct timespec *delta +) +{ + uint64_t sec; + + if ( !_Watchdog_Is_valid_interval_timespec( delta ) ) { + return NULL; + } + + sec = (uint64_t) now->tv_sec; + sec += (uint64_t) delta->tv_sec; + now->tv_nsec += delta->tv_nsec; + + /* We have 2 * (2**63 - 1) + 1 == UINT64_MAX */ + if ( now->tv_nsec >= WATCHDOG_NANOSECONDS_PER_SECOND ) { + now->tv_nsec -= WATCHDOG_NANOSECONDS_PER_SECOND; + ++sec; + } + + if ( sec <= INT64_MAX ) { + now->tv_sec = sec; + } else { + now->tv_sec = INT64_MAX; + } + + return now; +} + +RTEMS_INLINE_ROUTINE bool _Watchdog_Is_far_future_monotonic_timespec( + const struct timespec *ts +) +{ + return ts->tv_sec >= _Watchdog_Monotonic_max_seconds; +} + +RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Monotonic_from_timespec( + const struct timespec *ts +) +{ + uint64_t ticks; + + _Assert( _Watchdog_Is_valid_timespec( ts ) ); + _Assert( ts->tv_sec >= 0 ); + _Assert( !_Watchdog_Is_far_future_monotonic_timespec( ts ) ); + + ticks = (uint64_t) ts->tv_sec * _Watchdog_Ticks_per_second; + ticks += (unsigned long) ts->tv_nsec / _Watchdog_Nanoseconds_per_tick; + + return ticks; +} + +RTEMS_INLINE_ROUTINE bool _Watchdog_Is_far_future_realtime_timespec( + const struct timespec *ts +) +{ + return ts->tv_sec > WATCHDOG_REALTIME_MAX_SECONDS; +} + +RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Realtime_from_seconds( + uint32_t seconds +) +{ + uint64_t ticks = seconds; + + ticks <<= WATCHDOG_BITS_FOR_1E9_NANOSECONDS; + + return ticks; +} + +RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Realtime_from_timespec( + const struct timespec *ts +) +{ + uint64_t ticks; + + _Assert( _Watchdog_Is_valid_timespec( ts ) ); + _Assert( ts->tv_sec >= 0 ); + _Assert( !_Watchdog_Is_far_future_realtime_timespec( ts ) ); + + ticks = (uint64_t) ts->tv_sec; + ticks <<= WATCHDOG_BITS_FOR_1E9_NANOSECONDS; + ticks |= (uint32_t) ts->tv_nsec; + + return ticks; +} + +RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Realtime_from_sbintime( + sbintime_t sbt +) +{ + uint64_t ticks = ( sbt >> 32 ) << WATCHDOG_BITS_FOR_1E9_NANOSECONDS; + + ticks |= ( (uint64_t) 1000000000 * (uint32_t) sbt ) >> 32; + + return ticks; +} + +RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_acquire_critical( + Per_CPU_Control *cpu, + ISR_lock_Context *lock_context +) +{ + _ISR_lock_Acquire( &cpu->Watchdog.Lock, lock_context ); +} + +RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_release_critical( + Per_CPU_Control *cpu, + ISR_lock_Context *lock_context +) +{ + _ISR_lock_Release( &cpu->Watchdog.Lock, lock_context ); +} + +RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Per_CPU_insert_ticks( + Watchdog_Control *the_watchdog, + Per_CPU_Control *cpu, + Watchdog_Interval ticks +) +{ + ISR_lock_Context lock_context; + Watchdog_Header *header; + uint64_t expire; + + header = &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_MONOTONIC ]; + + _Watchdog_Set_CPU( the_watchdog, cpu ); + + _Watchdog_Per_CPU_acquire_critical( cpu, &lock_context ); + expire = ticks + cpu->Watchdog.ticks; + _Watchdog_Insert(header, the_watchdog, expire); + _Watchdog_Per_CPU_release_critical( cpu, &lock_context ); + return expire; +} + +RTEMS_INLINE_ROUTINE bool _Watchdog_Per_CPU_lazy_insert_monotonic( + Watchdog_Control *the_watchdog, + Per_CPU_Control *cpu, + uint64_t expire +) +{ + ISR_lock_Context lock_context; + Watchdog_Header *header; + bool insert; + + header = &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_MONOTONIC ]; + + _Watchdog_Set_CPU( the_watchdog, cpu ); + + _Watchdog_Per_CPU_acquire_critical( cpu, &lock_context ); + insert = ( expire > cpu->Watchdog.ticks ); + + if ( insert ) { + _Watchdog_Insert(header, the_watchdog, expire); + } + + _Watchdog_Per_CPU_release_critical( cpu, &lock_context ); + return insert; +} + +RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Per_CPU_insert_realtime( + Watchdog_Control *the_watchdog, + Per_CPU_Control *cpu, + uint64_t expire +) +{ + ISR_lock_Context lock_context; + Watchdog_Header *header; + + header = &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_REALTIME ]; + + _Watchdog_Set_CPU( the_watchdog, cpu ); + + _Watchdog_Per_CPU_acquire_critical( cpu, &lock_context ); + _Watchdog_Insert(header, the_watchdog, expire); + _Watchdog_Per_CPU_release_critical( cpu, &lock_context ); + return expire; +} + +RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_remove( + Watchdog_Control *the_watchdog, + Per_CPU_Control *cpu, + Watchdog_Header *header +) +{ + ISR_lock_Context lock_context; + + _Watchdog_Per_CPU_acquire_critical( cpu, &lock_context ); + _Watchdog_Remove( + header, + the_watchdog + ); + _Watchdog_Per_CPU_release_critical( cpu, &lock_context ); +} + +RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_remove_monotonic( + Watchdog_Control *the_watchdog +) +{ + Per_CPU_Control *cpu; + + cpu = _Watchdog_Get_CPU( the_watchdog ); + _Watchdog_Per_CPU_remove( + the_watchdog, + cpu, + &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_MONOTONIC ] + ); +} + +RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_remove_realtime( + Watchdog_Control *the_watchdog +) +{ + Per_CPU_Control *cpu; + + cpu = _Watchdog_Get_CPU( the_watchdog ); + _Watchdog_Per_CPU_remove( + the_watchdog, + cpu, + &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_REALTIME ] + ); +} + +RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_tickle_realtime( + Per_CPU_Control *cpu, + uint64_t now +) +{ + ISR_lock_Context lock_context; + + _ISR_lock_ISR_disable_and_acquire( &cpu->Watchdog.Lock, &lock_context ); + _Watchdog_Tickle( + &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_REALTIME ], + now, + &cpu->Watchdog.Lock, + &lock_context + ); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/score/wkspace.h b/cpukit/include/rtems/score/wkspace.h new file mode 100644 index 0000000000..3676ff28c4 --- /dev/null +++ b/cpukit/include/rtems/score/wkspace.h @@ -0,0 +1,138 @@ +/** + * @file rtems/score/wkspace.h + * + * @brief Information Related to the RAM Workspace + * + * This include file contains information related to the + * RAM Workspace. This Handler provides mechanisms which can be used to + * define, initialize and manipulate the workspace. + */ + +/* + * COPYRIGHT (c) 1989-2009. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_WKSPACE_H +#define _RTEMS_SCORE_WKSPACE_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ScoreWorkspace Workspace Handler + * + * @ingroup Score + * + * This handler encapsulates functionality related to the management of + * the RTEMS Executive Workspace. + */ +/**@{*/ + +/** + * @brief Executive workspace control. + * + * This is the heap control structure used to manage the RTEMS Executive + * Workspace. + */ +extern Heap_Control _Workspace_Area; + +/** + * @brief Initilize workspace handler. + * + * This routine performs the initialization necessary for this handler. + */ +void _Workspace_Handler_initialization( + Heap_Area *areas, + size_t area_count, + Heap_Initialization_or_extend_handler extend +); + +/** + * @brief Allocate memory from workspace. + * + * This routine returns the address of a block of memory of size + * bytes. If a block of the appropriate size cannot be allocated + * from the workspace, then NULL is returned. + * + * @param size is the requested size + * + * @retval a pointer to the requested memory or NULL. + */ +void *_Workspace_Allocate( + size_t size +); + +/** + * @brief Allocate aligned memory from workspace. + * + * @param[in] size The size of the requested memory. + * @param[in] alignment The alignment of the requested memory. + * + * @retval NULL Not enough resources. + * @retval other The memory area begin. + */ +void *_Workspace_Allocate_aligned( size_t size, size_t alignment ); + +/** + * @brief Free memory to the workspace. + * + * This function frees the specified block of memory. If the block + * belongs to the Workspace and can be successfully freed, then + * true is returned. Otherwise false is returned. + * + * @param block is the memory to free + * + * @note If @a block is equal to NULL, then the request is ignored. + * This allows the caller to not worry about whether or not + * a pointer is NULL. + */ + +void _Workspace_Free( + void *block +); + +/** + * @brief Workspace allocate or fail with fatal error. + * + * This routine returns the address of a block of memory of @a size + * bytes. If a block of the appropriate size cannot be allocated + * from the workspace, then the internal error handler is invoked. + * + * @param[in] size is the desired number of bytes to allocate + * @retval If successful, the starting address of the allocated memory + */ +void *_Workspace_Allocate_or_fatal_error( + size_t size +); + +/** + * @brief Duplicates string with memory from the workspace. + * + * @param[in] string is the pointer to a zero terminated string. + * @param[in] len is the length of the string (equal to strlen(string)). + * + * @retval NULL Not enough memory. + * @retval other Duplicated string. + */ +char *_Workspace_String_duplicate( + const char *string, + size_t len +); + +/**@}*/ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/serdbg.h b/cpukit/include/rtems/serdbg.h new file mode 100644 index 0000000000..fe106bce44 --- /dev/null +++ b/cpukit/include/rtems/serdbg.h @@ -0,0 +1,151 @@ +/*===============================================================*\ +| Project: RTEMS remote gdb over serial line | ++-----------------------------------------------------------------+ +| File: serdbg.h | ++-----------------------------------------------------------------+ +| Copyright (c) 2002 IMD | +| Ingenieurbuero fuer Microcomputertechnik Th. Doerfler | +| | +| all rights reserved | ++-----------------------------------------------------------------+ +| this file declares intialization functions to add | +| a gdb remote debug stub to an RTEMS system | +| | ++-----------------------------------------------------------------+ +| date history ID | +| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | +| 04.04.02 creation doe | +\*===============================================================*/ +#ifndef _SERDBG_H +#define _SERDBG_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + uint32_t baudrate; /* debug baud rate, e.g. 57600 */ + void (*callout)(void); /* callout pointer during polling */ + int (*open_io)(const char *dev_name, uint32_t baudrate); /* I/O open fnc */ + const char *devname; /* debug device, e.g. "/dev/tty01" */ + bool skip_init_bkpt; /* if TRUE, do not stop when initializing */ +} serdbg_conf_t; + +/* + * must be defined in init module... + */ +extern serdbg_conf_t serdbg_conf; + + +/*=========================================================================*\ +| Function: | +\*-------------------------------------------------------------------------*/ +void putDebugChar +( +/*-------------------------------------------------------------------------*\ +| Purpose: | +| send character to remote debugger | ++---------------------------------------------------------------------------+ +| Input Parameters: | +\*-------------------------------------------------------------------------*/ + char c /* char to send */ + ); +/*-------------------------------------------------------------------------*\ +| Return Value: | +| | +\*=========================================================================*/ + +/*=========================================================================*\ +| Function: | +\*-------------------------------------------------------------------------*/ +int getDebugChar +( +/*-------------------------------------------------------------------------*\ +| Purpose: | +| get character from remote debugger | ++---------------------------------------------------------------------------+ +| Input Parameters: | +\*-------------------------------------------------------------------------*/ + void /* */ + ); +/*-------------------------------------------------------------------------*\ +| Return Value: | +| | +\*=========================================================================*/ + +/*=========================================================================*\ +| Function: | +\*-------------------------------------------------------------------------*/ +void serdbg_exceptionHandler +( +/*-------------------------------------------------------------------------*\ +| Purpose: | +| hook directly to an exception vector | ++---------------------------------------------------------------------------+ +| Input Parameters: | +\*-------------------------------------------------------------------------*/ + int vecnum, /* vector index to hook at */ + void *vector /* address of handler function */ + ); +/*-------------------------------------------------------------------------*\ +| Return Value: | +| | +\*=========================================================================*/ + +/*=========================================================================*\ +| Function: | +\*-------------------------------------------------------------------------*/ +int serdbg_init +( +/*-------------------------------------------------------------------------*\ +| Purpose: | +| initialize remote gdb session over serial line | ++---------------------------------------------------------------------------+ +| Input Parameters: | +\*-------------------------------------------------------------------------*/ + void + ); +/*-------------------------------------------------------------------------*\ +| Return Value: | +| rtems_status_code | +\*=========================================================================*/ + +/* + * stuff from serdbgio.c + */ +/*=========================================================================*\ +| Function: | +\*-------------------------------------------------------------------------*/ +int serdbg_open + +/*-------------------------------------------------------------------------*\ +| Purpose: | +| try to open given serial debug port | ++---------------------------------------------------------------------------+ +| Input Parameters: | +\*-------------------------------------------------------------------------*/ +( + const char *dev_name, /* name of device to open */ + uint32_t baudrate /* baud rate to use */ + ); +/*-------------------------------------------------------------------------*\ +| Return Value: | +| 0 on success, -1 and errno otherwise | +\*=========================================================================*/ + + +extern int serdbg_init_dbg(void); + +/* + * Assumed to be provided by the BSP + */ +extern void set_debug_traps(void); +extern void breakpoint(void); +#ifdef __cplusplus +} +#endif + +#endif /* _SERDBG_H */ diff --git a/cpukit/include/rtems/serdbgcnf.h b/cpukit/include/rtems/serdbgcnf.h new file mode 100644 index 0000000000..9d4087ae69 --- /dev/null +++ b/cpukit/include/rtems/serdbgcnf.h @@ -0,0 +1,91 @@ +/** + * @file + * + * @brief Adds a GDB remote Debug Stub to an RTEMS System + */ + +/*===============================================================*\ +| Project: RTEMS configure remote gdb over serial line | ++-----------------------------------------------------------------+ +| File: serdbgcnf.h | ++-----------------------------------------------------------------+ +| Copyright (c) 2002 IMD | +| Ingenieurbuero fuer Microcomputertechnik Th. Doerfler | +| | +| all rights reserved | ++-----------------------------------------------------------------+ +| this file declares intialization functions to add | +| a gdb remote debug stub to an RTEMS system | +| | ++-----------------------------------------------------------------+ +| date history ID | +| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | +| 13.05.02 creation doe | +\*===============================================================*/ +#ifndef _SERDBGCNF_H +#define _SERDBGCNF_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef CONFIGURE_INIT + +/* + * fallback for baud rate to use + */ +#ifndef CONFIGURE_SERDBG_BAUDRATE +#define CONFIGURE_SERDBG_BAUDRATE 9600 +#endif + +/* + * fallback for device name to use + */ +#ifndef CONFIGURE_SERDBG_DEVNAME +#define CONFIGURE_SERDBG_DEVNAME "/dev/tty01" +#endif + +/* + * fill in serdbg_conf structure + */ +serdbg_conf_t serdbg_conf = { + CONFIGURE_SERDBG_BAUDRATE, + +#ifdef CONFIGURE_SERDBG_CALLOUT + CONFIGURE_SERDBG_CALLOUT, +#else + NULL, +#endif + +#ifdef CONFIGURE_SERDBG_USE_POLLED_TERMIOS + serdbg_open, +#else + NULL, +#endif + + CONFIGURE_SERDBG_DEVNAME, + +#ifdef CONFIGURE_SERDBG_SKIP_INIT_BKPT + true, +#else + false, +#endif +}; + +int serdbg_init(void) { +#ifdef CONFIGURE_USE_SERDBG + return serdbg_init_dbg(); +#else + return 0; +#endif +} + +#endif /* CONFIGURE_INIT */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SERDBGCNF_H */ diff --git a/cpukit/include/rtems/serial_mouse.h b/cpukit/include/rtems/serial_mouse.h new file mode 100644 index 0000000000..174fcfb909 --- /dev/null +++ b/cpukit/include/rtems/serial_mouse.h @@ -0,0 +1,169 @@ +/** + * @file + * + * @brief Serial Mouse Driver + * + * This file describes the Serial Mouse Driver for all boards. + * This driver assumes that the BSP or application will provide + * an implementation of the method bsp_get_serial_mouse_device() + * which tells the driver what serial port device to open() and + * what type of mouse is connected. + * + * This driver relies on the Mouse Parser Engine. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef __SERIAL_MOUSE_h__ +#define __SERIAL_MOUSE_h__ + +#include + +/* functions */ + +/** + * @defgroup libmisc_serialmouse Serial Mouse Driver + * @ingroup libmisc_mouse + */ +/**@{*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Standard device file path for a PS2 mouse device. + */ +#define SERIAL_MOUSE_DEVICE_PS2 "/dev/psaux" + +/** + * This macro defines the serial mouse device driver entry points. + */ +#define SERIAL_MOUSE_DRIVER_TABLE_ENTRY \ + { serial_mouse_initialize, serial_mouse_open, serial_mouse_close, \ + serial_mouse_read, serial_mouse_write, serial_mouse_control } + +/** + * @brief The initialization of the serial mouse driver. + * + * This method initializes the serial mouse driver. + * + * @param[in] major is the mouse device major number + * @param[in] minor is the mouse device minor number + * @param[in] arg points to device driver arguments + */ +rtems_device_driver serial_mouse_initialize( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg +); + +/** + * @brief Open device driver entry point for the serial mouse driver. + * + * This method implements the Open device driver entry + * point for the serial mouse driver. + * + * @param[in] major is the mouse device major number + * @param[in] minor is the mouse device minor number + * @param[in] arg points to device driver arguments + */ +rtems_device_driver serial_mouse_open( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg +); + +/** + * @brief Close device driver entry point for the serial mouse driver. + * + * This method implements the Close device driver entry + * point for the serial mouse driver. + * + * @param[in] major is the mouse device major number + * @param[in] minor is the mouse device minor number + * @param[in] arg points to device driver arguments + */ +rtems_device_driver serial_mouse_close( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg +); + +/** + * @brief Read device driver entry point for the serial mouse driver. + * + * This method implements the Read device driver entry + * point for the serial mouse driver. + * + * @param[in] major is the mouse device major number + * @param[in] minor is the mouse device minor number + * @param[in] arg points to device driver arguments + */ +rtems_device_driver serial_mouse_read( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg +); + +/** + * @brief Write device driver entry point for the serial mouse driver. + * + * This method implements the Write device driver entry + * point for the serial mouse driver. + * + * @param[in] major is the mouse device major number + * @param[in] minor is the mouse device minor number + * @param[in] arg points to device driver arguments + */ +rtems_device_driver serial_mouse_write( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg +); + +/** + * @brief IO Control device driver entry point for the serial mouse driver. + * + * This method implements the IO Control device driver entry + * point for the serial mouse driver. + * + * @param[in] major is the mouse device major number + * @param[in] minor is the mouse device minor number + * @param[in] arg points to device driver arguments + */ +rtems_device_driver serial_mouse_control( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *arg +); + +/** + * @brief Obtain serial mouse configuration information. + * + * This method is implemented by the BSP or application and + * tells the driver what device to open() and what type of + * mouse is connected. + * + * @param[in] name will point to a string with the device name + * of the serial port with the mouse connected. + * @param[in] type will point to a string with the type of mouse connected. + * + * @retval This method returns true on success and false on error. + */ +bool bsp_get_serial_mouse_device( + const char **name, + const char **type +); + +#ifdef __cplusplus +} +#endif +/**@}*/ +#endif /* __tty_drv__ */ diff --git a/cpukit/include/rtems/seterr.h b/cpukit/include/rtems/seterr.h new file mode 100644 index 0000000000..22fddc824e --- /dev/null +++ b/cpukit/include/rtems/seterr.h @@ -0,0 +1,53 @@ +/** + * @file rtems/seterr.h + * + * @brief Data which Ease the Burden of Consistently Setting Errno + * + * This file contains macros and definitions which ease the burden + * of consistently setting errno and returning -1. + */ + +/* + * COPYRIGHT (c) 1989-2006. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SETERR_H +#define _RTEMS_SETERR_H + +/** + * @defgroup ScoreSetErr Set Errno + * + * @ingroup Score + * + */ +/**@{*/ + +#include + +/** + * This is a helper macro which will set the variable errno and return + * the specified value to the caller. + * + * @param[in] _error is the error code + * @param[in] _value is the value to return + */ +#define rtems_set_errno_and_return_value( _error, _value ) \ + do { errno = ( _error ); return ( _value ); } while ( 0 ) + +/** + * This is a helper macro which will set the variable errno and return + * -1 to the caller. This pattern is common to many POSIX methods. + * + * @param[in] _error is the error code + */ +#define rtems_set_errno_and_return_minus_one( _error ) \ + rtems_set_errno_and_return_value( _error, -1 ) + +/**@}*/ +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/shell.h b/cpukit/include/rtems/shell.h new file mode 100644 index 0000000000..98ddf0a958 --- /dev/null +++ b/cpukit/include/rtems/shell.h @@ -0,0 +1,385 @@ +/** + * @file rtems/shell.h + * + * @brief Instantatiate a New Terminal Shell + */ + +/* + * Author: + * + * WORK: fernando.ruiz@ctv.es + * HOME: correo@fernando-ruiz.com + * + * Thanks at: + * Chris Johns + */ + +#ifndef __RTEMS_SHELL_H__ +#define __RTEMS_SHELL_H__ + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Some key labels to define special keys. + */ + +#define RTEMS_SHELL_KEYS_EXTENDED (0x8000) +#define RTEMS_SHELL_KEYS_NORMAL_MASK (0x00ff) +#define RTEMS_SHELL_KEYS_INS (0) +#define RTEMS_SHELL_KEYS_DEL (1) +#define RTEMS_SHELL_KEYS_UARROW (2) +#define RTEMS_SHELL_KEYS_DARROW (3) +#define RTEMS_SHELL_KEYS_LARROW (4) +#define RTEMS_SHELL_KEYS_RARROW (5) +#define RTEMS_SHELL_KEYS_HOME (6) +#define RTEMS_SHELL_KEYS_END (7) +#define RTEMS_SHELL_KEYS_F1 (8) +#define RTEMS_SHELL_KEYS_F2 (9) +#define RTEMS_SHELL_KEYS_F3 (10) +#define RTEMS_SHELL_KEYS_F4 (11) +#define RTEMS_SHELL_KEYS_F5 (12) +#define RTEMS_SHELL_KEYS_F6 (13) +#define RTEMS_SHELL_KEYS_F7 (14) +#define RTEMS_SHELL_KEYS_F8 (15) +#define RTEMS_SHELL_KEYS_F9 (16) +#define RTEMS_SHELL_KEYS_F10 (17) + +typedef bool (*rtems_shell_login_check_t)( + const char * /* user */, + const char * /* passphrase */ +); + +extern bool rtems_shell_login_prompt( + FILE *in, + FILE *out, + const char *device, + rtems_shell_login_check_t check +); + +extern bool rtems_shell_login_check( + const char *user, + const char *passphrase +); + +typedef int (*rtems_shell_command_t)(int argc, char **argv); + +struct rtems_shell_cmd_tt; +typedef struct rtems_shell_cmd_tt rtems_shell_cmd_t; + +struct rtems_shell_cmd_tt { + const char *name; + const char *usage; + const char *topic; + rtems_shell_command_t command; + rtems_shell_cmd_t *alias; + rtems_shell_cmd_t *next; + mode_t mode; + uid_t uid; + gid_t gid; +}; + +typedef struct { + const char *name; + const char *alias; +} rtems_shell_alias_t; + +struct rtems_shell_topic_tt; +typedef struct rtems_shell_topic_tt rtems_shell_topic_t; + +struct rtems_shell_topic_tt { + const char *topic; + rtems_shell_topic_t *next; +}; + +/* + * The return value has RTEMS_SHELL_KEYS_EXTENDED set if the key + * is extended, ie a special key. + */ +extern unsigned int rtems_shell_getchar(FILE *in); + +extern rtems_shell_cmd_t * rtems_shell_lookup_cmd(const char *cmd); + +extern rtems_shell_cmd_t *rtems_shell_add_cmd_struct( + rtems_shell_cmd_t *shell_cmd +); + +rtems_shell_cmd_t * rtems_shell_add_cmd( + const char *cmd, + const char *topic, + const char *usage, + rtems_shell_command_t command +); + +extern rtems_shell_cmd_t * rtems_shell_alias_cmd( + const char *cmd, + const char *alias +); + +extern int rtems_shell_make_args( + char *commandLine, + int *argc_p, + char **argv_p, + int max_args +); + +extern rtems_shell_topic_t * rtems_shell_lookup_topic( + const char *topic +); + +extern bool rtems_shell_can_see_cmd( + const rtems_shell_cmd_t *shell_cmd +); + +extern int rtems_shell_execute_cmd( + const char *cmd, int argc, char *argv[] +); + +/* + * Call to set up the shell environment if you need to execute commands before + * running a shell. + */ +extern void rtems_shell_init_environment( + void +); + +extern int rtems_shell_cat_file( + FILE *out, + const char *name +); + +extern void rtems_shell_write_file( + const char *name, + const char *content +); + +extern int rtems_shell_script_file( + int argc, + char **argv +); + +/** + * Initialise the shell creating tasks to login and run the shell + * sessions. + * + * @param task_name Name of the shell task. + * @param task_stacksize The size of the stack. If 0 the default size is used. + * @param task_priority The priority the shell runs at. + * @param forever Repeat logins. + * @param wait Caller should block until shell exits. + * @param login_check User login check function, NULL disables login checks. + * + */ +extern rtems_status_code rtems_shell_init( + const char *task_name, + size_t task_stacksize, + rtems_task_priority task_priority, + const char *devname, + bool forever, + bool wait, + rtems_shell_login_check_t login_check +); + +/** + * Run a shell script creating a shell tasks to execute the command under. + * + * @param task_name Name of the shell task. + * @param task_stacksize The size of the stack. If 0 the default size is used. + * @param task_priority The priority the shell runs at. + * @param input The file of commands. Can be 'stdin' to use stdin. + * @param output The output file to write commands to. Can be 'stdout', + * 'stderr' or '/dev/null'. + * @param output_append Append the output to the file or truncate the file. + * Create if it does not exist. + * @param wait Wait for the script to finish. + */ +extern rtems_status_code rtems_shell_script( + const char *task_name, + size_t task_stacksize, /* 0 default*/ + rtems_task_priority task_priority, + const char *input, + const char *output, + bool output_append, + bool wait, + bool echo +); + +/** + * Private environment associated with each shell instance. + */ +typedef struct { + /** 'S','E','N','V': Shell Environment */ + rtems_name magic; + const char *devname; + const char *taskname; + bool exit_shell; /* logout */ + bool forever; /* repeat login */ + int errorlevel; + bool echo; + char cwd[256]; + const char *input; + const char *output; + bool output_append; + rtems_id wake_on_end; + rtems_shell_login_check_t login_check; + + /** + * @brief The real and effective UID of the shell task in case no login check + * is present. + */ + uid_t uid; + + /** + * @brief The real and effective GID of the shell task in case no login check + * is present. + */ + gid_t gid; +} rtems_shell_env_t; + +bool rtems_shell_main_loop( + rtems_shell_env_t *rtems_shell_env +); + +extern const rtems_shell_env_t rtems_global_shell_env; + +rtems_shell_env_t *rtems_shell_get_current_env(void); +void rtems_shell_dup_current_env(rtems_shell_env_t *); + +/* + * The types of file systems we can mount. We have them broken out + * out like this so they can be configured by shellconfig.h. The + * mount command needs special treatment due to some file systems + * being dependent on the network stack and some not. If we had + * all possible file systems being included it would force the + * networking stack into the applcation and this may not be + * required. + */ +struct rtems_shell_filesystems_tt; +typedef struct rtems_shell_filesystems_tt rtems_shell_filesystems_t; + +typedef int (*rtems_shell_filesystems_mounter_t)( + const char* driver, + const char* path, + rtems_shell_filesystems_t* fs, + rtems_filesystem_options_t options +); + +struct rtems_shell_filesystems_tt { + rtems_chain_node link; + const char *name; + int driver_needed; + const rtems_filesystem_operations_table *fs_ops; + rtems_shell_filesystems_mounter_t mounter; +}; + +/** + * This method dynamically builds the command line prompt string + * and places it in @a prompt. + * + * @param[in] shell_env is the shell execution environment + * @param[in] prompt is a pointer to a string buffer area + * @param[in] size is length of the prompt buffer area + * + * @return This method fills in the memory pointed to by @a prompt. + * + * @note An application specific implementation can be provided + * by the user. + */ +extern void rtems_shell_get_prompt( + rtems_shell_env_t *shell_env, + char *prompt, + size_t size +); + +/** + * Helper for the mount command. + * + * @param[in] driver The path to the driver. + * @param[in] path The path to mount on. + * @param[in] fs The file system definition. + * @param[in] options Special file system options. + */ +extern int rtems_shell_libc_mounter( + const char* driver, + const char* path, + rtems_shell_filesystems_t* fs, + rtems_filesystem_options_t options +); + +/** + * Add a new file system mount configuration to the mount command. + * + * @param[in] fs The file system mount data. + */ +extern void rtems_shell_mount_add_fsys(rtems_shell_filesystems_t* fs); + +/** + * Delete file system mount configuration from the mount command. + * + * @param[in] fs The file system mount data to remove. + */ +extern void rtems_shell_mount_del_fsys(rtems_shell_filesystems_t* fs); + +typedef void (*rtems_shell_wait_for_input_notification)( + int fd, + int seconds_remaining, + void *arg +); + +/** + * @brief Waits for input. + * + * @retval RTEMS_SUCCESSFUL Input detected. + * @retval RTEMS_TIMEOUT Timeout expired. + * @retval RTEMS_UNSATISFIED Cannot change or restore termios attributes. + */ +extern rtems_status_code rtems_shell_wait_for_input( + int fd, + int timeout_in_seconds, + rtems_shell_wait_for_input_notification notification, + void *notification_arg +); + +/** + * @brief Waits for explicit input. + * + * @param desired_input An explicit unsigned character to wait for or -1 to + * accept any input. + * + * @retval RTEMS_SUCCESSFUL Input detected. + * @retval RTEMS_TIMEOUT Timeout expired. + * @retval RTEMS_UNSATISFIED Cannot change or restore termios attributes. + */ +extern rtems_status_code rtems_shell_wait_for_explicit_input( + int fd, + int timeout_in_seconds, + rtems_shell_wait_for_input_notification notification, + void *notification_arg, + int desired_input +); + +extern int rtems_shell_main_monitor(int argc, char **argv); + +/* + * Provide these commands for application use, as their implementation + * is tedious. + */ +int rtems_shell_main_mv(int argc, char *argv[]); +int rtems_shell_main_cp(int argc, char *argv[]); +int rtems_shell_main_rm(int argc, char *argv[]); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/include/rtems/shellconfig.h b/cpukit/include/rtems/shellconfig.h new file mode 100644 index 0000000000..9f68b313fb --- /dev/null +++ b/cpukit/include/rtems/shellconfig.h @@ -0,0 +1,554 @@ +/** + * @file rtems/shellconfig.h + * + * RTEMS Shell Command Set Configuration + */ + +/* + * COPYRIGHT (c) 1989-2012. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SHELL_CONFIG_h +#define _RTEMS_SHELL_CONFIG_h + +#include + +/* + * Externs for all command definition structures + */ +extern rtems_shell_cmd_t rtems_shell_HELP_Command; +extern rtems_shell_cmd_t rtems_shell_ALIAS_Command; +extern rtems_shell_cmd_t rtems_shell_TIME_Command; +extern rtems_shell_cmd_t rtems_shell_CMDLS_Command; +extern rtems_shell_cmd_t rtems_shell_CMDCHOWN_Command; +extern rtems_shell_cmd_t rtems_shell_CMDCHMOD_Command; +extern rtems_shell_cmd_t rtems_shell_LOGOFF_Command; +extern rtems_shell_cmd_t rtems_shell_SETENV_Command; +extern rtems_shell_cmd_t rtems_shell_GETENV_Command; +extern rtems_shell_cmd_t rtems_shell_UNSETENV_Command; + +extern rtems_shell_cmd_t rtems_shell_MDUMP_Command; +extern rtems_shell_cmd_t rtems_shell_WDUMP_Command; +extern rtems_shell_cmd_t rtems_shell_LDUMP_Command; +extern rtems_shell_cmd_t rtems_shell_MEDIT_Command; +extern rtems_shell_cmd_t rtems_shell_MFILL_Command; +extern rtems_shell_cmd_t rtems_shell_MMOVE_Command; + +extern rtems_shell_cmd_t rtems_shell_JOEL_Command; +extern rtems_shell_cmd_t rtems_shell_DATE_Command; +extern rtems_shell_cmd_t rtems_shell_ECHO_Command; +extern rtems_shell_cmd_t rtems_shell_EDIT_Command; +extern rtems_shell_cmd_t rtems_shell_SLEEP_Command; +extern rtems_shell_cmd_t rtems_shell_ID_Command; +extern rtems_shell_cmd_t rtems_shell_TTY_Command; +extern rtems_shell_cmd_t rtems_shell_WHOAMI_Command; + +extern rtems_shell_cmd_t rtems_shell_CP_Command; +extern rtems_shell_cmd_t rtems_shell_PWD_Command; +extern rtems_shell_cmd_t rtems_shell_LS_Command; +extern rtems_shell_cmd_t rtems_shell_CHDIR_Command; +extern rtems_shell_cmd_t rtems_shell_MKDIR_Command; +extern rtems_shell_cmd_t rtems_shell_RMDIR_Command; +extern rtems_shell_cmd_t rtems_shell_CHROOT_Command; +extern rtems_shell_cmd_t rtems_shell_CHMOD_Command; +extern rtems_shell_cmd_t rtems_shell_CAT_Command; +extern rtems_shell_cmd_t rtems_shell_MKRFS_Command; +extern rtems_shell_cmd_t rtems_shell_MSDOSFMT_Command; +extern rtems_shell_cmd_t rtems_shell_MSDOSFMT_Alias; +extern rtems_shell_cmd_t rtems_shell_MV_Command; +extern rtems_shell_cmd_t rtems_shell_RM_Command; +extern rtems_shell_cmd_t rtems_shell_LN_Command; +extern rtems_shell_cmd_t rtems_shell_MKNOD_Command; +extern rtems_shell_cmd_t rtems_shell_UMASK_Command; +extern rtems_shell_cmd_t rtems_shell_LSOF_Command; +extern rtems_shell_cmd_t rtems_shell_MOUNT_Command; +extern rtems_shell_cmd_t rtems_shell_UNMOUNT_Command; +extern rtems_shell_cmd_t rtems_shell_BLKSYNC_Command; +extern rtems_shell_cmd_t rtems_shell_BLKSTATS_Command; +extern rtems_shell_cmd_t rtems_shell_FDISK_Command; +extern rtems_shell_cmd_t rtems_shell_DD_Command; +extern rtems_shell_cmd_t rtems_shell_HEXDUMP_Command; +extern rtems_shell_cmd_t rtems_shell_DEBUGRFS_Command; +extern rtems_shell_cmd_t rtems_shell_DF_Command; +extern rtems_shell_cmd_t rtems_shell_MD5_Command; + +extern rtems_shell_cmd_t rtems_shell_RTC_Command; + +extern rtems_shell_cmd_t rtems_shell_SHUTDOWN_Command; +extern rtems_shell_cmd_t rtems_shell_CPUINFO_Command; +extern rtems_shell_cmd_t rtems_shell_CPUUSE_Command; +extern rtems_shell_cmd_t rtems_shell_TOP_Command; +extern rtems_shell_cmd_t rtems_shell_STACKUSE_Command; +extern rtems_shell_cmd_t rtems_shell_PERIODUSE_Command; +extern rtems_shell_cmd_t rtems_shell_PROFREPORT_Command; +extern rtems_shell_cmd_t rtems_shell_WKSPACE_INFO_Command; +extern rtems_shell_cmd_t rtems_shell_MALLOC_INFO_Command; +extern rtems_shell_cmd_t rtems_shell_RTRACE_Command; +#if RTEMS_NETWORKING + extern rtems_shell_cmd_t rtems_shell_IFCONFIG_Command; + extern rtems_shell_cmd_t rtems_shell_ROUTE_Command; + extern rtems_shell_cmd_t rtems_shell_NETSTATS_Command; + extern rtems_shell_cmd_t rtems_shell_PING_Command; +#endif + +/* + * Extern for System commands + */ +extern rtems_shell_cmd_t rtems_shell_DRVMGR_Command; +extern rtems_shell_cmd_t rtems_shell_PCI_Command; + +extern rtems_shell_cmd_t * const rtems_shell_Initial_commands[]; + +/* + * Extern for alias commands + */ +extern rtems_shell_alias_t rtems_shell_DIR_Alias; +extern rtems_shell_alias_t rtems_shell_CD_Alias; +extern rtems_shell_alias_t rtems_shell_EXIT_Alias; + +extern rtems_shell_alias_t * const rtems_shell_Initial_aliases[]; + +/* + * If we are configured to alias a command, then make sure the underlying + * command is configured. + */ + +#if !defined(CONFIGURE_SHELL_COMMANDS_ALL) + #if defined(CONFIGURE_SHELL_COMMANDS_DIR) && \ + !defined(CONFIGURE_SHELL_COMMANDS_LS) + #define CONFIGURE_SHELL_COMMAND_LS + #endif + + #if defined(CONFIGURE_SHELL_COMMANDS_CD) && \ + !defined(CONFIGURE_SHELL_COMMANDS_CHDIR) + #define CONFIGURE_SHELL_COMMAND_CHDIR + #endif + + #if defined(CONFIGURE_SHELL_COMMANDS_EXIT) && \ + !defined(CONFIGURE_SHELL_COMMANDS_LOGOFF) + #define CONFIGURE_SHELL_COMMAND_LOGOFF + #endif +#endif + +#if defined(CONFIGURE_SHELL_COMMANDS_INIT) + rtems_shell_alias_t * const rtems_shell_Initial_aliases[] = { + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_DIR)) || \ + defined(CONFIGURE_SHELL_COMMAND_DIR) + &rtems_shell_DIR_Alias, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_CD)) || \ + defined(CONFIGURE_SHELL_COMMAND_CD) + &rtems_shell_CD_Alias, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_EXIT)) || \ + defined(CONFIGURE_SHELL_COMMAND_EXIT) + &rtems_shell_EXIT_Alias, + #endif + + /* + * User defined shell aliases + */ + #if defined(CONFIGURE_SHELL_USER_ALIASES) + CONFIGURE_SHELL_USER_ALIASES, + #endif + NULL + }; + + rtems_shell_cmd_t * const rtems_shell_Initial_commands[] = { + /* + * General comamnds that should be present + */ + &rtems_shell_HELP_Command, + &rtems_shell_ALIAS_Command, + &rtems_shell_TIME_Command, + + /* + * Common commands that can be optional + */ + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_CMDLS)) || \ + defined(CONFIGURE_SHELL_COMMAND_CMDLS) + &rtems_shell_CMDLS_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_CMDCHOWN)) || \ + defined(CONFIGURE_SHELL_COMMAND_CMDCHOWN) + &rtems_shell_CMDCHOWN_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_CMDCHMOD)) || \ + defined(CONFIGURE_SHELL_COMMAND_CMDCHMOD) + &rtems_shell_CMDCHMOD_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_JOEL)) || \ + defined(CONFIGURE_SHELL_COMMAND_JOEL) + &rtems_shell_JOEL_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_DATE)) || \ + defined(CONFIGURE_SHELL_COMMAND_DATE) + &rtems_shell_DATE_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_ECHO)) || \ + defined(CONFIGURE_SHELL_COMMAND_ECHO) + &rtems_shell_ECHO_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_EDIT)) || \ + defined(CONFIGURE_SHELL_COMMAND_EDIT) + &rtems_shell_EDIT_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_SLEEP)) || \ + defined(CONFIGURE_SHELL_COMMAND_SLEEP) + &rtems_shell_SLEEP_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_ID)) || \ + defined(CONFIGURE_SHELL_COMMAND_ID) + &rtems_shell_ID_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_TTY)) || \ + defined(CONFIGURE_SHELL_COMMAND_TTY) + &rtems_shell_TTY_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_WHOAMI)) || \ + defined(CONFIGURE_SHELL_COMMAND_WHOAMI) + &rtems_shell_WHOAMI_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_LOGOFF)) || \ + defined(CONFIGURE_SHELL_COMMAND_LOGOFF) + &rtems_shell_LOGOFF_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_SETENV)) || \ + defined(CONFIGURE_SHELL_COMMAND_SETENV) + &rtems_shell_SETENV_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_GETENV)) || \ + defined(CONFIGURE_SHELL_COMMAND_GETENV) + &rtems_shell_GETENV_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_CRLENV)) || \ + defined(CONFIGURE_SHELL_COMMAND_UNSETENV) + &rtems_shell_UNSETENV_Command, + #endif + + /* + * Memory printing/modification family commands + */ + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_MDUMP)) || \ + defined(CONFIGURE_SHELL_COMMAND_MDUMP) + &rtems_shell_MDUMP_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_WDUMP)) || \ + defined(CONFIGURE_SHELL_COMMAND_WDUMP) + &rtems_shell_WDUMP_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_LDUMP)) || \ + defined(CONFIGURE_SHELL_COMMAND_LDUMP) + &rtems_shell_LDUMP_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_MEDIT)) || \ + defined(CONFIGURE_SHELL_COMMAND_MEDIT) + &rtems_shell_MEDIT_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_MFILL)) || \ + defined(CONFIGURE_SHELL_COMMAND_MFILL) + &rtems_shell_MFILL_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_MMOVE)) || \ + defined(CONFIGURE_SHELL_COMMAND_MMOVE) + &rtems_shell_MMOVE_Command, + #endif + + /* + * File and directory commands + */ + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_CP)) || \ + defined(CONFIGURE_SHELL_COMMAND_CP) + &rtems_shell_CP_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_PWD)) || \ + defined(CONFIGURE_SHELL_COMMAND_PWD) + &rtems_shell_PWD_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_LS)) || \ + defined(CONFIGURE_SHELL_COMMAND_LS) + &rtems_shell_LS_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_CHDIR)) || \ + defined(CONFIGURE_SHELL_COMMAND_CHDIR) + &rtems_shell_CHDIR_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_MKDIR)) || \ + defined(CONFIGURE_SHELL_COMMAND_MKDIR) + &rtems_shell_MKDIR_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_RMDIR)) || \ + defined(CONFIGURE_SHELL_COMMAND_RMDIR) + &rtems_shell_RMDIR_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_CHROOT)) || \ + defined(CONFIGURE_SHELL_COMMAND_CHROOT) + &rtems_shell_CHROOT_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_CHMOD)) || \ + defined(CONFIGURE_SHELL_COMMAND_CHMOD) + &rtems_shell_CHMOD_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_CAT)) || \ + defined(CONFIGURE_SHELL_COMMAND_CAT) + &rtems_shell_CAT_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_MKRFS)) || \ + defined(CONFIGURE_SHELL_COMMAND_MKRFS) + &rtems_shell_MKRFS_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_MSDOSFMT)) || \ + defined(CONFIGURE_SHELL_COMMAND_MSDOSFMT) + &rtems_shell_MSDOSFMT_Command, + &rtems_shell_MSDOSFMT_Alias, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_MV)) || \ + defined(CONFIGURE_SHELL_COMMAND_MV) + &rtems_shell_MV_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_RM)) || \ + defined(CONFIGURE_SHELL_COMMAND_RM) + &rtems_shell_RM_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_LN)) || \ + defined(CONFIGURE_SHELL_COMMAND_LN) + &rtems_shell_LN_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_MKNOD)) || \ + defined(CONFIGURE_SHELL_COMMAND_MKNOD) + &rtems_shell_MKNOD_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_UMASK)) || \ + defined(CONFIGURE_SHELL_COMMAND_UMASK) + &rtems_shell_UMASK_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_LSOF)) || \ + defined(CONFIGURE_SHELL_COMMAND_LSOF) + &rtems_shell_LSOF_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_MOUNT)) || \ + defined(CONFIGURE_SHELL_COMMAND_MOUNT) + &rtems_shell_MOUNT_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_UNMOUNT)) || \ + defined(CONFIGURE_SHELL_COMMAND_UNMOUNT) + &rtems_shell_UNMOUNT_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_BLKSYNC)) || \ + defined(CONFIGURE_SHELL_COMMAND_BLKSYNC) + &rtems_shell_BLKSYNC_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_BLKSTATS)) || \ + defined(CONFIGURE_SHELL_COMMAND_BLKSTATS) + &rtems_shell_BLKSTATS_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_FDISK)) || \ + defined(CONFIGURE_SHELL_COMMAND_FDISK) + &rtems_shell_FDISK_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_DD)) || \ + defined(CONFIGURE_SHELL_COMMAND_DD) + &rtems_shell_DD_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_HEXDUMP)) || \ + defined(CONFIGURE_SHELL_COMMAND_HEXDUMP) + &rtems_shell_HEXDUMP_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_DEBUGRFS)) || \ + defined(CONFIGURE_SHELL_COMMAND_DEBUGRFS) + &rtems_shell_DEBUGRFS_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_DF)) || \ + defined(CONFIGURE_SHELL_COMMAND_DF) + &rtems_shell_DF_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_MD5)) || \ + defined(CONFIGURE_SHELL_COMMAND_MD5) + &rtems_shell_MD5_Command, + #endif + + /* + * RTEMS Related commands + */ + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_SHUTDOWN)) || \ + defined(CONFIGURE_SHELL_COMMAND_SHUTDOWN) + &rtems_shell_SHUTDOWN_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_CPUINFO)) || \ + defined(CONFIGURE_SHELL_COMMAND_CPUINFO) + &rtems_shell_CPUINFO_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_CPUUSE)) || \ + defined(CONFIGURE_SHELL_COMMAND_CPUUSE) + &rtems_shell_CPUUSE_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_TOP)) || \ + defined(CONFIGURE_SHELL_COMMAND_TOP) + &rtems_shell_TOP_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_STACKUSE)) || \ + defined(CONFIGURE_SHELL_COMMAND_STACKUSE) + &rtems_shell_STACKUSE_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_PERIODUSE)) || \ + defined(CONFIGURE_SHELL_COMMAND_PERIODUSE) + &rtems_shell_PERIODUSE_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_PROFREPORT)) || \ + defined(CONFIGURE_SHELL_COMMAND_PROFREPORT) + &rtems_shell_PROFREPORT_Command, + #endif + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_WKSPACE_INFO)) || \ + defined(CONFIGURE_SHELL_COMMAND_WKSPACE_INFO) + &rtems_shell_WKSPACE_INFO_Command, + #endif + + /* + * Malloc family commands + */ + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_MALLOC_INFO)) || \ + defined(CONFIGURE_SHELL_COMMAND_MALLOC_INFO) + &rtems_shell_MALLOC_INFO_Command, + #endif + + /* + * Tracing family commands + */ + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_RTRACE)) || \ + defined(CONFIGURE_SHELL_COMMAND_RTRACE) + &rtems_shell_RTRACE_Command, + #endif + + /* + * Network related commands + */ + #if RTEMS_NETWORKING + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL_NETWORKING) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_IFCONFIG)) || \ + defined(CONFIGURE_SHELL_COMMAND_IFCONFIG) + &rtems_shell_IFCONFIG_Command, + #endif + + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL_NETWORKING) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_ROUTE)) || \ + defined(CONFIGURE_SHELL_COMMAND_ROUTE) + &rtems_shell_ROUTE_Command, + #endif + + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL_NETWORKING) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_NETSTATS)) || \ + defined(CONFIGURE_SHELL_COMMAND_NETSTATS) + &rtems_shell_NETSTATS_Command, + #endif + + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL_NETWORKING) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_PING)) || \ + defined(CONFIGURE_SHELL_COMMAND_PING) + &rtems_shell_PING_Command, + #endif + #endif + + /* Miscanellous shell commands */ + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) \ + && !defined(CONFIGURE_SHELL_NO_COMMAND_RTC)) \ + || defined(CONFIGURE_SHELL_COMMAND_RTC) + &rtems_shell_RTC_Command, + #endif + + /* + * System related commands + */ + #if defined(RTEMS_DRVMGR_STARTUP) || defined(CONFIGURE_SHELL_COMMAND_DRVMGR) + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_DRVMGR)) || \ + defined(CONFIGURE_SHELL_COMMAND_DRVMGR) + &rtems_shell_DRVMGR_Command, + #endif + #endif + + #if defined(RTEMS_PCI_CONFIG_LIB) + #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ + !defined(CONFIGURE_SHELL_NO_COMMAND_PCI)) || \ + defined(CONFIGURE_SHELL_COMMAND_PCI) + &rtems_shell_PCI_Command, + #endif + #endif + + /* + * User defined shell commands + */ + #if defined(CONFIGURE_SHELL_USER_COMMANDS) + CONFIGURE_SHELL_USER_COMMANDS, + #endif + NULL + }; + +#endif + +#endif diff --git a/cpukit/include/rtems/sparse-disk.h b/cpukit/include/rtems/sparse-disk.h new file mode 100644 index 0000000000..e558e08925 --- /dev/null +++ b/cpukit/include/rtems/sparse-disk.h @@ -0,0 +1,137 @@ +/** + * @file + * + * @ingroup rtems_sparse_disk + * + * @brief Sparse disk block device API. + */ + +/* + * Copyright (c) 2012 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Obere Lagerstr. 30 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef SPARSE_DISK_H +#define SPARSE_DISK_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup rtems_sparse_disk Sparse Disk Device + * + * @ingroup rtems_blkdev + * + */ +/**@{**/ + +typedef struct { + rtems_blkdev_bnum block; + void *data; +} rtems_sparse_disk_key; + +typedef struct rtems_sparse_disk rtems_sparse_disk; + +typedef void (*rtems_sparse_disk_delete_handler)(rtems_sparse_disk *sparse_disk); + +struct rtems_sparse_disk { + rtems_id mutex; + rtems_blkdev_bnum blocks_with_buffer; + size_t used_count; + uint32_t media_block_size; + rtems_sparse_disk_delete_handler delete_handler; + uint8_t fill_pattern; + rtems_sparse_disk_key *key_table; +}; + +/** + * @brief Creates and registers a sparse disk. + * + * @param[in] device_file_name The device file name path. + * @param[in] media_block_size The media block size in bytes. + * @param[in] blocks_with_buffer Blocks of the device with a buffer. Other + * blocks can store only fill pattern value bytes. + * @param[in] block_count The media block count of the device. It is the sum + * of blocks with buffer and blocks that contain only fill pattern value bytes. + * @param[in] fill_pattern The fill pattern specifies the byte value of blocks + * without a buffer. It is also the initial value for blocks with a buffer. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_NUMBER Media block size or media block count is not + * positive. The blocks with buffer count is greater than the media block count. + * @retval RTEMS_NO_MEMORY Not enough memory. + * @retval RTEMS_TOO_MANY Cannot create semaphore. + * @retval RTEMS_UNSATISFIED Cannot create generic device node. + * + * @see rtems_sparse_disk_register(). + */ +rtems_status_code rtems_sparse_disk_create_and_register( + const char *device_file_name, + uint32_t media_block_size, + rtems_blkdev_bnum blocks_with_buffer, + rtems_blkdev_bnum media_block_count, + uint8_t fill_pattern +); + +/** + * @brief Frees a sparse disk. + * + * Calls free() on the sparse disk pointer. + */ +void rtems_sparse_disk_free( rtems_sparse_disk *sparse_disk ); + +/** + * @brief Initializes and registers a sparse disk. + * + * This will create one semaphore for mutual exclusion. + * + * @param[in] device_file_name The device file name path. + * @param[in, out] sparse_disk The sparse disk. + * @param[in] media_block_size The media block size in bytes. + * @param[in] blocks_with_buffer Blocks of the device with a buffer. Other + * blocks can store only fill pattern value bytes. + * @param[in] block_count The media block count of the device. It is the sum + * of blocks with buffer and blocks that contain only fill pattern value bytes. + * @param[in] fill_pattern The fill pattern specifies the byte value of blocks + * without a buffer. It is also the initial value for blocks with a buffer. + * @param[in] sparse_disk_delete The sparse disk delete handler. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_NUMBER Media block size or media block count is not + * positive. The blocks with buffer count is greater than the media block count. + * @retval RTEMS_INVALID_ADDRESS Invalid sparse disk address. + * @retval RTEMS_TOO_MANY Cannot create semaphore. + * @retval RTEMS_UNSATISFIED Cannot create generic device node. + */ +rtems_status_code rtems_sparse_disk_register( + const char *device_file_name, + rtems_sparse_disk *sparse_disk, + uint32_t media_block_size, + rtems_blkdev_bnum blocks_with_buffer, + rtems_blkdev_bnum media_block_count, + uint8_t fill_pattern, + rtems_sparse_disk_delete_handler sparse_disk_delete +); + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* SPARSE_DISK_H */ diff --git a/cpukit/include/rtems/spurious.h b/cpukit/include/rtems/spurious.h new file mode 100644 index 0000000000..049f3bf3a0 --- /dev/null +++ b/cpukit/include/rtems/spurious.h @@ -0,0 +1,42 @@ +/** + * @file rtems/spurious.h + * + * This file describes the Spurious Interrupt Driver for all boards. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SPURIOUS_H +#define _RTEMS_SPURIOUS_H + +#include /* rtems_id */ +#include /* rtems_device_driver */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define SPURIOUS_DRIVER_TABLE_ENTRY \ + { Spurious_Initialize, NULL, NULL, NULL, NULL, NULL } + +rtems_device_driver Spurious_Initialize( + rtems_device_major_number, + rtems_device_minor_number, + void *, + rtems_id, + uint32_t * +); + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/stackchk.h b/cpukit/include/rtems/stackchk.h new file mode 100644 index 0000000000..16fc4f9b9d --- /dev/null +++ b/cpukit/include/rtems/stackchk.h @@ -0,0 +1,139 @@ +/** + * @file rtems/stackchk.h + * + * @defgroup libmisc_stackchk Stack Checker Mechanism + * + * @ingroup libmisc + * @brief Stack Checker Information + * + * This include file contains information necessary to utilize + * and install the stack checker mechanism. + */ + +/* + * COPYRIGHT (c) 1989-2009. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_STACKCHK_H +#define _RTEMS_STACKCHK_H + +#include /* bool */ + +#include /* Thread_Control */ +#include + +/** + * @defgroup libmisc_stackchk Stack Checker Mechanism + * + * @ingroup libmisc + */ +/**@{*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Checks if current task is blown its stack. + * + * This method is used to determine if the current stack pointer + * of the currently executing task is within bounds. + * + * @retval This method returns true if the currently executing task + * has blown its stack. + * + */ +bool rtems_stack_checker_is_blown( void ); + +/** + * @brief Print the stack usage report using printk. + * + * This method prints a stack usage report for the curently executing + * task. + * + * @note It uses printk to print the report. + */ +void rtems_stack_checker_report_usage( void ); + +/** + * @brief Print the stack usage report using caller's routine. + * + * This method prints a stack usage report for the curently executing + * task. + * + * @param[in] context is the context to pass to the print handler + * @param[in] print is the print handler + * + * @note It uses the caller's routine to print the report. + */ +void rtems_stack_checker_report_usage_with_plugin( + const rtems_printer *printer +); + +/************************************************************* + ************************************************************* + ** Prototyped only so the user extension can be installed ** + ************************************************************* + *************************************************************/ + +/** + * @brief Stack Checker Task Create Extension + * + * This method is the task create extension for the stack checker. + * + * @param[in] running points to the currently executing task + * @param[in] the_thread points to the newly created task + * + * @note If this this the first task created, the stack checker + * will automatically intialize itself. + */ +bool rtems_stack_checker_create_extension( + Thread_Control *running, + Thread_Control *the_thread +); + +/** + * @brief Stack Checker Task Context Switch Extension + * + * This method is the task context switch extension for the stack checker. + * + * @param[in] running points to the currently executing task which + * is being context switched out + * @param[in] running points to the heir task which we are switching to + * + * @note This is called from the internal method _Thread_Dispatch. + */ +void rtems_stack_checker_switch_extension( + Thread_Control *running, + Thread_Control *heir +); + +/** + * @brief Stack Checker Extension Set Definition + * + * This macro defines the user extension handler set for the stack + * checker. This macro is normally only used by confdefs.h. + */ +#define RTEMS_STACK_CHECKER_EXTENSION \ +{ \ + rtems_stack_checker_create_extension, /* rtems_task_create */ \ + 0, /* rtems_task_start */ \ + 0, /* rtems_task_restart */ \ + 0, /* rtems_task_delete */ \ + rtems_stack_checker_switch_extension, /* task_switch */ \ + 0, /* task_begin */ \ + 0, /* task_exitted */ \ + 0 /* rtems_stack_checker_fatal_extension */, /* fatal */ \ + 0, /* terminate */ \ +} + +#ifdef __cplusplus +} +#endif +/**@}*/ +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/stdio-redirect.h b/cpukit/include/rtems/stdio-redirect.h new file mode 100644 index 0000000000..6f1d4cdd98 --- /dev/null +++ b/cpukit/include/rtems/stdio-redirect.h @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2014 Chris Johns (chrisj@rtems.org) + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution. + * + * This software with is provided ``as is'' and with NO WARRANTY. + */ + +/* + * @brief Redirect an stdio file decriptor. + * + * The is a helper module of code design to redirect an stdio file + * descriptor. You can optionally have the data buffered and/or you can provide + * a handler function that is called when data arrives. + * + * The module uses standard POSIX calls to implement the redirection and if the + * threading was POSIX based the code would be portable. Currently the code + * uses RTEMS threads. + * + * Redirecting stderr and stdout is useful in embedded system because you can + * transport the output off your device or create a web interface that can + * display the output. This can be a very powerful diagnostic and support tool. + * + * The implementation does: + * + * 1. Duplicate the file descriptor (fd) to redirect using the dup call. The + * duplicated desciptor is used to echo the output out the existing path. + * + * 2. Create a pipe using the pipe call. + * + * 3. Duplicate the pipe's writer file descriptor to user's file + * descriptor. This results in any writes to the user's fd being written to + * the pipe. + * + * 4. Create a reader task that blocks on the pipe. It optionally calls a + * handler and if configured buffers the data. + */ + +#if !defined(RTEMS_STDIO_REDIRECT_H) +#define RTEMS_STDIO_REDIRECT_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * Handler called whenever redirected data arrives. + * + * @param buffer The data. + * @param length The amount of data in the buffer. + */ +typedef void (*rtems_stdio_redirect_handler)(const char* buffer, + ssize_t length); + +/* + * Redirector data. + */ +typedef struct +{ + volatile uint32_t state; /**< The state. */ + rtems_id reader; /**< The reader thread. */ + rtems_id lock; /**< Lock for this struct. */ + int fd; /**< The file descriptor to redirect. */ + int fd_dup; /**< Duplicated fd to write to. */ + int pipe[2]; /**< The pipe to the reader thread. */ + char* input; /**< The input buffer the reader uses. */ + ssize_t input_size; /**< The input buffer size. */ + char* buffer; /**< Captured redirected data. */ + ssize_t buffer_size; /**< Capture buffer size. */ + ssize_t in; /**< Buffer in index. */ + bool full; /**< The buffer is full. */ + bool echo; /**< Echo the data out the existing path. */ + rtems_stdio_redirect_handler handler; /**< Redirected data handler. */ +} rtems_stdio_redirect; + +/* + * Open a redirector returning the handle to it. + * + * @param fd The file descriptor to redirect. + * @param priority The priority of the reader thread. + */ +rtems_stdio_redirect* rtems_stdio_redirect_open(int fd, + rtems_task_priority priority, + size_t stack_size, + ssize_t input_size, + ssize_t buffer_size, + bool echo, + rtems_stdio_redirect_handler handler); + +/* + * Close the redirector. + */ +void rtems_stdio_redirect_close(rtems_stdio_redirect* sr); + +/* + * Get data from the capture buffer. Data read is removed from the buffer. + * + * @param sr The stdio redirection handle. + * @param buffer The buffer data is written into. + * @param length The size of the buffer. + * @return ssize_t The amount of data written and -1 or an error. + */ +ssize_t rtems_stdio_redirect_read(rtems_stdio_redirect* sr, + char* buffer, + ssize_t length); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/cpukit/include/rtems/stringto.h b/cpukit/include/rtems/stringto.h new file mode 100644 index 0000000000..878814da54 --- /dev/null +++ b/cpukit/include/rtems/stringto.h @@ -0,0 +1,262 @@ +/** + * @file rtems/stringto.h + * + * @defgroup libmisc_conv_help Conversion Helpers + * + * @ingroup libmisc + * @brief Convert String to Pointer (with validation) + * + * This file defines the interface to a set of string conversion helpers. + */ + +/* + * COPYRIGHT (c) 2009-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_STRINGTO_H +#define _RTEMS_STRINGTO_H +/** + * @defgroup libmisc_conv_help Conversion Helpers + * + * @ingroup libmisc + */ +/**@{*/ + +#include + +/** + * @brief Convert String to Pointer (with validation). + * + * This method converts a string to a pointer (void *) with + * basic numeric validation. + * + * @param[in] s is the string to convert + * @param[in] n points to the variable to place the converted output in + * @param[in] endptr is used to keep track of the position in the string + * + * @retval This method returns RTEMS_SUCCESSFUL on successful conversion + * and *n is filled in. Otherwise, the status indicates the + * source of the error. + */ +rtems_status_code rtems_string_to_pointer( + const char *s, + void **n, + char **endptr +); + +/** + * @brief Convert String to Unsigned Character (with validation). + * + * This method converts a string to an unsigned character with + * range validation. + * + * @param[in] s is the string to convert + * @param[in] n points to the variable to place the converted output in + * @param[in] endptr is used to keep track of the position in the string + * @param[in] base is the expected base of the number + * + * @retval This method returns RTEMS_SUCCESSFUL on successful conversion + * and *n is filled in. Otherwise, the status indicates the + * source of the error. + */ +rtems_status_code rtems_string_to_unsigned_char( + const char *s, + unsigned char *n, + char **endptr, + int base +); + +/** + * @brief Convert String to Int (with validation). + * + * This method converts a string to an int with range validation. + * + * @param[in] s is the string to convert + * @param[in] n points to the variable to place the converted output in + * @param[in] endptr is used to keep track of the position in the string + * @param[in] base is the expected base of the number + * + * @retval This method returns RTEMS_SUCCESSFUL on successful conversion + * and *n is filled in. Otherwise, the status indicates the + * source of the error. + */ +rtems_status_code rtems_string_to_int( + const char *s, + int *n, + char **endptr, + int base +); + +/** + * @brief Convert String to Unsigned Int (with validation). + * + * This method converts a string to an unsigned int with range validation. + * + * @param[in] s is the string to convert + * @param[in] n points to the variable to place the converted output in + * @param[in] endptr is used to keep track of the position in the string + * @param[in] base is the expected base of the number + * + * @retval This method returns RTEMS_SUCCESSFUL on successful conversion + * and *n is filled in. Otherwise, the status indicates the + * source of the error. + */ +rtems_status_code rtems_string_to_unsigned_int( + const char *s, + unsigned int *n, + char **endptr, + int base +); + +/** + * @brief Convert String to Long (with validation). + * + * This method converts a string to a long with + * range validation. + * + * @param[in] s is the string to convert + * @param[in] n points to the variable to place the converted output in + * @param[in] endptr is used to keep track of the position in the string + * @param[in] base is the expected base of the number + * + * @retval This method returns RTEMS_SUCCESSFUL on successful conversion + * and *n is filled in. Otherwise, the status indicates the + * source of the error. + */ +rtems_status_code rtems_string_to_long( + const char *s, + long *n, + char **endptr, + int base +); + +/** + * @brief Convert String to Unsigned Long (with validation). + * + * This method converts a string to an unsigned long with + * range validation. + * + * @param[in] s is the string to convert + * @param[in] n points to the variable to place the converted output in + * @param[in] endptr is used to keep track of the position in the string + * @param[in] base is the expected base of the number + * + * @retval This method returns RTEMS_SUCCESSFUL on successful conversion + * and *n is filled in. Otherwise, the status indicates the + * source of the error. + */ +rtems_status_code rtems_string_to_unsigned_long( + const char *s, + unsigned long *n, + char **endptr, + int base +); + +/** + * @brief Convert String to Long Long (with validation). + * + * This method converts a string to a long long with + * range validation. + * + * @param[in] s is the string to convert + * @param[in] n points to the variable to place the converted output in + * @param[in] endptr is used to keep track of the position in the string + * @param[in] base is the expected base of the number + * + * @retval This method returns RTEMS_SUCCESSFUL on successful conversion + * and *n is filled in. Otherwise, the status indicates the + * source of the error. + */ +rtems_status_code rtems_string_to_long_long( + const char *s, + long long *n, + char **endptr, + int base +); + +/** + * @brief Convert String to Unsigned Long Long (with validation). + * + * This method converts a string to an unsigned character with + * range validation. + * + * @param[in] s is the string to convert + * @param[in] n points to the variable to place the converted output in + * @param[in] endptr is used to keep track of the position in the string + * @param[in] base is the expected base of the number + * + * @retval This method returns RTEMS_SUCCESSFUL on successful conversion + * and *n is filled in. Otherwise, the status indicates the + * source of the error. + */ +rtems_status_code rtems_string_to_unsigned_long_long( + const char *s, + unsigned long long *n, + char **endptr, + int base +); + +/** + * @brief Convert String to Float (with validation). + * + * This method converts a string to a float with range validation. + * + * @param[in] s is the string to convert + * @param[in] n points to the variable to place the converted output in + * @param[in] endptr is used to keep track of the position in the string + * + * @retval This method returns RTEMS_SUCCESSFUL on successful conversion + * and *n is filled in. Otherwise, the status indicates the + * source of the error. + */ +rtems_status_code rtems_string_to_float( + const char *s, + float *n, + char **endptr +); + +/** + * @brief Convert String to Double (with validation). + * + * This method converts a string to a double with range validation. + * + * @param[in] s is the string to convert + * @param[in] n points to the variable to place the converted output in + * @param[in] endptr is used to keep track of the position in the string + * + * @retval This method returns RTEMS_SUCCESSFUL on successful conversion + * and *n is filled in. Otherwise, the status indicates the + * source of the error. + */ +rtems_status_code rtems_string_to_double( + const char *s, + double *n, + char **endptr +); + +/** + * @brief Convert String to long double (with validation). + * + * This method converts a string to a long double with range validation. + * + * @param[in] s is the string to convert + * @param[in] n points to the variable to place the converted output in + * @param[in] endptr is used to keep track of the position in the string + * + * @retval This method returns RTEMS_SUCCESSFUL on successful conversion + * and *n is filled in. Otherwise, the status indicates the + * source of the error. + */ +rtems_status_code rtems_string_to_long_double( + const char *s, + long double *n, + char **endptr +); + +#endif +/**@}*/ diff --git a/cpukit/include/rtems/sysinit.h b/cpukit/include/rtems/sysinit.h new file mode 100644 index 0000000000..535fb98e2c --- /dev/null +++ b/cpukit/include/rtems/sysinit.h @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2015 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SYSINIT_H +#define _RTEMS_SYSINIT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * The value of each module define must consist of exactly six hexadecimal + * digits without a 0x-prefix. A 0x-prefix is concatenated with the module and + * order values to form a proper integer literal. + */ +#define RTEMS_SYSINIT_BSP_WORK_AREAS 000100 +#define RTEMS_SYSINIT_BSP_START 000200 +#define RTEMS_SYSINIT_INITIAL_EXTENSIONS 000300 +#define RTEMS_SYSINIT_MP_EARLY 000301 +#define RTEMS_SYSINIT_DATA_STRUCTURES 000302 +#define RTEMS_SYSINIT_MP 00030e +#define RTEMS_SYSINIT_USER_EXTENSIONS 000320 +#define RTEMS_SYSINIT_CLASSIC_TASKS 000340 +#define RTEMS_SYSINIT_CLASSIC_TIMER 000341 +#define RTEMS_SYSINIT_CLASSIC_SIGNAL 000342 +#define RTEMS_SYSINIT_CLASSIC_EVENT 000343 +#define RTEMS_SYSINIT_CLASSIC_MESSAGE_QUEUE 000344 +#define RTEMS_SYSINIT_CLASSIC_SEMAPHORE 000345 +#define RTEMS_SYSINIT_CLASSIC_PARTITION 000346 +#define RTEMS_SYSINIT_CLASSIC_REGION 000347 +#define RTEMS_SYSINIT_CLASSIC_DUAL_PORTED_MEMORY 000348 +#define RTEMS_SYSINIT_CLASSIC_RATE_MONOTONIC 000349 +#define RTEMS_SYSINIT_CLASSIC_BARRIER 00034a +#define RTEMS_SYSINIT_POSIX_SIGNALS 000360 +#define RTEMS_SYSINIT_POSIX_THREADS 000361 +#define RTEMS_SYSINIT_POSIX_MESSAGE_QUEUE 000364 +#define RTEMS_SYSINIT_POSIX_SEMAPHORE 000365 +#define RTEMS_SYSINIT_POSIX_TIMER 000366 +#define RTEMS_SYSINIT_POSIX_SHM 000369 +#define RTEMS_SYSINIT_POSIX_KEYS 00036a +#define RTEMS_SYSINIT_POSIX_CLEANUP 00036b +#define RTEMS_SYSINIT_IDLE_THREADS 000380 +#define RTEMS_SYSINIT_LIBIO 000400 +#define RTEMS_SYSINIT_ROOT_FILESYSTEM 000401 +#define RTEMS_SYSINIT_DRVMGR 000500 +#define RTEMS_SYSINIT_MP_SERVER 000501 +#define RTEMS_SYSINIT_BSP_PRE_DRIVERS 000600 +#define RTEMS_SYSINIT_DRVMGR_LEVEL_1 000700 +#define RTEMS_SYSINIT_DEVICE_DRIVERS 000701 +#define RTEMS_SYSINIT_DRVMGR_LEVEL_2 000702 +#define RTEMS_SYSINIT_DRVMGR_LEVEL_3 000703 +#define RTEMS_SYSINIT_DRVMGR_LEVEL_4 000704 +#define RTEMS_SYSINIT_MP_FINALIZE 000705 +#define RTEMS_SYSINIT_CLASSIC_USER_TASKS 000706 +#define RTEMS_SYSINIT_POSIX_USER_THREADS 000707 +#define RTEMS_SYSINIT_STD_FILE_DESCRIPTORS 000800 +#define RTEMS_SYSINIT_LAST ffffff + +/* + * The value of each order define must consist of exactly two hexadecimal + * digits without a 0x-prefix. A 0x-prefix is concatenated with the module and + * order values to form a proper integer literal. + */ +#define RTEMS_SYSINIT_ORDER_FIRST 00 +#define RTEMS_SYSINIT_ORDER_SECOND 01 +#define RTEMS_SYSINIT_ORDER_THIRD 02 +#define RTEMS_SYSINIT_ORDER_FOURTH 03 +#define RTEMS_SYSINIT_ORDER_FIFTH 04 +#define RTEMS_SYSINIT_ORDER_SIXTH 05 +#define RTEMS_SYSINIT_ORDER_SEVENTH 06 +#define RTEMS_SYSINIT_ORDER_EIGHTH 07 +#define RTEMS_SYSINIT_ORDER_NINETH 08 +#define RTEMS_SYSINIT_ORDER_TENTH 09 +#define RTEMS_SYSINIT_ORDER_MIDDLE 80 +#define RTEMS_SYSINIT_ORDER_LAST ff + +typedef void ( *rtems_sysinit_handler )( void ); + +typedef struct { + rtems_sysinit_handler handler; +} rtems_sysinit_item; + +/* The enum helps to detect typos in the module and order parameters */ +#define _RTEMS_SYSINIT_INDEX_ITEM( handler, index ) \ + enum { _Sysinit_##handler = index }; \ + RTEMS_LINKER_ROSET_ITEM_ORDERED( \ + _Sysinit, \ + rtems_sysinit_item, \ + handler, \ + index \ + ) = { handler } + +/* Create index from module and order */ +#define _RTEMS_SYSINIT_ITEM( handler, module, order ) \ + _RTEMS_SYSINIT_INDEX_ITEM( handler, 0x##module##order ) + +/* Perform parameter expansion */ +#define RTEMS_SYSINIT_ITEM( handler, module, order ) \ + _RTEMS_SYSINIT_ITEM( handler, module, order ) + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_SYSINIT_H */ diff --git a/cpukit/include/rtems/system.h b/cpukit/include/rtems/system.h new file mode 100644 index 0000000000..26156c64f7 --- /dev/null +++ b/cpukit/include/rtems/system.h @@ -0,0 +1,66 @@ +/** + * @file + * + * @brief Information Included in Every Function in the Executive + * + * This include file contains information that is included in every + * function in the executive. This must be the first include file + * included in all internal RTEMS files. + */ + +/* + * COPYRIGHT (c) 1989-2007. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SYSTEM_H +#define _RTEMS_SYSTEM_H + +#include + +/** + * @defgroup ScoreSystem System Information + * + * @ingroup Score + */ +/**@{*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef ASM + +#ifdef RTEMS_POSIX_API +/** The following is used by the POSIX implementation to catch bad paths. */ +int POSIX_NOT_IMPLEMENTED( void ); +#endif + +/** + * The following is the extern for the RTEMS version string. + * + * @note The contents of this string are CPU specific. + */ +extern const char _RTEMS_version[]; + +/** + * The following is the extern for the RTEMS copyright string. + */ +extern const char _Copyright_Notice[]; + +/** This macro defines the maximum length of a Classic API name. */ +#define RTEMS_MAXIMUM_NAME_LENGTH sizeof(rtems_name) + +#endif /* ASM */ + +#ifdef __cplusplus +} +#endif + +/**@}*/ +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/telnetd.h b/cpukit/include/rtems/telnetd.h new file mode 100644 index 0000000000..a5c8a187e3 --- /dev/null +++ b/cpukit/include/rtems/telnetd.h @@ -0,0 +1,110 @@ +/* + * Original Author: Fernando RUIZ CASAS (fernando.ruiz@ctv.es) + * May 2001 + * Reworked by Till Straumann and .h overhauled by Joel Sherrill. + * + * Copyright (c) 2009 embedded brains GmbH and others. + * + * embedded brains GmbH + * Obere Lagerstr. 30 + * D-82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_TELNETD_H +#define _RTEMS_TELNETD_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +bool rtems_telnetd_login_check( + const char *user, + const char *passphrase +); + +/** + * @brief Telnet command type. + */ +typedef void (*rtems_telnetd_command)( + char * /* device name */, + void * /* arg */ +); + +/** + * @brief Telnet configuration structure. + */ +typedef struct { + /** + * @brief Function invoked for each Telnet connection. + * + * The first parameter contains the device name. The second parameter + * contains the argument pointer of this configuration table. + */ + rtems_telnetd_command command; + + /** + * @brief Argument for command function. + */ + void *arg; + + /** + * @brief Task priority. + * + * If this parameter is equal to zero, then the priority of network task is + * used or 100 if this priority is less than two. + */ + rtems_task_priority priority; + + /** + * @brief Task stack size. + */ + size_t stack_size; + + /** + * @brief Login check function. + * + * Method used for login checks. Use @c NULL to disable a login check. + */ + rtems_shell_login_check_t login_check; + + /** + * @brief Keep standard IO of the caller. + * + * Telnet takes over the standard input, output and error associated with + * task, if this parameter is set to @c true. In this case, it will @b not + * listen on any sockets. When this parameter is @c false, Telnet will + * create other tasks for the shell which listen on sockets. + */ + bool keep_stdio; +} rtems_telnetd_config_table; + +/** + * @brief Telnet configuration. + * + * The application must provide this configuration table. It is used by + * rtems_telnetd_initialize() to configure the Telnet subsystem. Do not modify + * the entries after the intialization since it is used internally. + */ +extern rtems_telnetd_config_table rtems_telnetd_config; + +/** + * @brief Initializes the Telnet subsystem. + * + * Uses the application provided @ref rtems_telnetd_config configuration table. + */ +rtems_status_code rtems_telnetd_initialize(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/include/rtems/termios_printk.h b/cpukit/include/rtems/termios_printk.h new file mode 100644 index 0000000000..dcb183533a --- /dev/null +++ b/cpukit/include/rtems/termios_printk.h @@ -0,0 +1,101 @@ +/*===============================================================*\ +| Project: RTEMS remote gdb over serial line | ++-----------------------------------------------------------------+ +| File: termios_printk.h | ++-----------------------------------------------------------------+ +| Copyright (c) 2002 IMD | +| Ingenieurbuero fuer Microcomputertechnik Th. Doerfler | +| | +| all rights reserved | ++-----------------------------------------------------------------+ +| this file declares intialization functions to add | +| printk polled output via termios polled drivers | +| | ++-----------------------------------------------------------------+ +| date history ID | +| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | +| 13.04.02 creation doe | +\*===============================================================*/ +#ifndef _TERMIOS_PRINTK_H +#define _TERMIOS_PRINTK_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + uint32_t baudrate; /* debug baud rate, e.g. 57600 */ + void (*callout)(void); /* callout pointer during polling */ + const char *devname; /* debug device, e.g. "/dev/tty01" */ +} termios_printk_conf_t; + +/* + * must be defined in init module... + */ +extern termios_printk_conf_t termios_printk_conf; + +/*=========================================================================*\ +| Function: | +\*-------------------------------------------------------------------------*/ +void termios_printk_outputchar +/*-------------------------------------------------------------------------*\ +| Purpose: | +| send one character to serial port | ++---------------------------------------------------------------------------+ +| Input Parameters: | +\*-------------------------------------------------------------------------*/ +( + char c /* character to print */ + ); +/*-------------------------------------------------------------------------*\ +| Return Value: | +| | +\*=========================================================================*/ + +/*=========================================================================*\ +| Function: | +\*-------------------------------------------------------------------------*/ +int termios_printk_inputchar +/*-------------------------------------------------------------------------*\ +| Purpose: | +| wait for one character from serial port | ++---------------------------------------------------------------------------+ +| Input Parameters: | +\*-------------------------------------------------------------------------*/ +( + void /* none */ + ); +/*-------------------------------------------------------------------------*\ +| Return Value: | +| received character | +\*=========================================================================*/ + + +/*=========================================================================*\ +| Function: | +\*-------------------------------------------------------------------------*/ +int termios_printk_open + +/*-------------------------------------------------------------------------*\ +| Purpose: | +| try to open given serial debug port | ++---------------------------------------------------------------------------+ +| Input Parameters: | +\*-------------------------------------------------------------------------*/ +( + const char *dev_name, /* name of device to open */ + uint32_t baudrate /* baud rate to use */ + ); +/*-------------------------------------------------------------------------*\ +| Return Value: | +| 0 on success, -1 and errno otherwise | +\*=========================================================================*/ + +#ifdef __cplusplus +} +#endif + +#endif /* _TERMIOS_PRINTK_H */ diff --git a/cpukit/include/rtems/termios_printk_cnf.h b/cpukit/include/rtems/termios_printk_cnf.h new file mode 100644 index 0000000000..03c3090c38 --- /dev/null +++ b/cpukit/include/rtems/termios_printk_cnf.h @@ -0,0 +1,81 @@ +/** + * @file + * + * @brief Adds printk Support via Polled termios + */ + +/*===============================================================*\ +| Project: RTEMS configure remote gdb over serial line | ++-----------------------------------------------------------------+ +| File: termios_printk_cnf.h | ++-----------------------------------------------------------------+ +| Copyright (c) 2002 IMD | +| Ingenieurbuero fuer Microcomputertechnik Th. Doerfler | +| | +| all rights reserved | ++-----------------------------------------------------------------+ +| this file declares intialization functions to add | +| printk support via polled termios | +| | ++-----------------------------------------------------------------+ +| date history ID | +| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | +| 13.05.02 creation doe | +\*===============================================================*/ +#ifndef _TERMIOS_PRINTK_CNF_H +#define _TERMIOS_PRINTK_CNF_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef CONFIGURE_INIT + +/* + * fallback for baud rate to use + */ +#ifndef CONFIGURE_TERMIOS_PRINTK_BAUDRATE +#define CONFIGURE_TERMIOS_PRINTK_BAUDRATE 9600 +#endif + +/* + * fallback for device name to use + */ +#ifndef CONFIGURE_TERMIOS_PRINTK_DEVNAME +#define CONFIGURE_TERMIOS_PRINTK_DEVNAME "/dev/console" +#endif + +#ifdef CONFIGURE_USE_TERMIOS_PRINTK +/* + * fill in termios_printk_conf structure + */ +termios_printk_conf_t termios_printk_conf = { + CONFIGURE_TERMIOS_PRINTK_BAUDRATE, + +#ifdef CONFIGURE_TERMIOS_PRINTK_CALLOUT + CONFIGURE_TERMIOS_PRINTK_CALLOUT, +#else + NULL, +#endif + CONFIGURE_TERMIOS_PRINTK_DEVNAME, +}; +#endif + +int termios_printk_init(void) { +#ifdef CONFIGURE_USE_TERMIOS_PRINTK + return termios_printk_open(termios_printk_conf.devname, + termios_printk_conf.baudrate); +#else + return 0; +#endif +} + +#endif /* CONFIGURE_INIT */ + +#ifdef __cplusplus +} +#endif + +#endif /* _TERMIOS_PRINTK_CNF_H */ diff --git a/cpukit/include/rtems/termiostypes.h b/cpukit/include/rtems/termiostypes.h new file mode 100644 index 0000000000..b3cac66e92 --- /dev/null +++ b/cpukit/include/rtems/termiostypes.h @@ -0,0 +1,602 @@ +/** + * @file rtems/termiostypes.h + * + * RTEMS termios device support internal data structures + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef __TERMIOSTYPES_H +#define __TERMIOSTYPES_H + +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup TermiostypesSupport RTEMS Termios Device Support + * + * @ingroup libcsupport + * + * @brief RTEMS Termios Device Support Internal Data Structures + */ + +/* + * Wakeup callback data structure + */ +struct ttywakeup { + void (*sw_pfn)(struct termios *tty, void *arg); + void *sw_arg; +}; + +/* + * Variables associated with the character buffer + */ +struct rtems_termios_rawbuf { + char *theBuf; + volatile unsigned int Head; + volatile unsigned int Tail; + volatile unsigned int Size; + rtems_id Semaphore; +}; + +typedef enum { + TERMIOS_POLLED, + TERMIOS_IRQ_DRIVEN, + TERMIOS_TASK_DRIVEN, + TERMIOS_IRQ_SERVER_DRIVEN +} rtems_termios_device_mode; + +struct rtems_termios_tty; + +/** + * @brief Termios device context. + * + * @see RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER(), + * rtems_termios_device_context_initialize() and + * rtems_termios_device_install(). + */ +typedef struct rtems_termios_device_context { + union { + /* Used for TERMIOS_POLLED and TERMIOS_IRQ_DRIVEN */ + rtems_interrupt_lock interrupt; + + /* Used for TERMIOS_IRQ_SERVER_DRIVEN or TERMIOS_TASK_DRIVEN */ + rtems_id mutex; + } lock; + + void ( *lock_acquire )( + struct rtems_termios_device_context *, + rtems_interrupt_lock_context * + ); + + void ( *lock_release )( + struct rtems_termios_device_context *, + rtems_interrupt_lock_context * + ); +} rtems_termios_device_context; + +void rtems_termios_device_lock_acquire_default( + rtems_termios_device_context *ctx, + rtems_interrupt_lock_context *lock_context +); + +void rtems_termios_device_lock_release_default( + rtems_termios_device_context *ctx, + rtems_interrupt_lock_context *lock_context +); + +/** + * @brief Initializes a device context. + * + * @param[in] context The Termios device context. + * @param[in] name The name for the interrupt lock. This name must be a + * string persistent throughout the life time of this lock. The name is only + * used if profiling is enabled. + */ +RTEMS_INLINE_ROUTINE void rtems_termios_device_context_initialize( + rtems_termios_device_context *context, + const char *name +) +{ + rtems_interrupt_lock_initialize( &context->lock.interrupt, name ); + context->lock_acquire = rtems_termios_device_lock_acquire_default; + context->lock_release = rtems_termios_device_lock_release_default; +} + +/** + * @brief Initializer for static initialization of Termios device contexts. + * + * @param name The name for the interrupt lock. It must be a string. The name + * is only used if profiling is enabled. + */ +#define RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER( name ) \ + { \ + { RTEMS_INTERRUPT_LOCK_INITIALIZER( name ) }, \ + rtems_termios_device_lock_acquire_default, \ + rtems_termios_device_lock_release_default \ + } + +/** + * @brief Termios device handler. + * + * @see rtems_termios_device_install(). + */ +typedef struct { + /** + * @brief First open of this device. + * + * @param[in] tty The Termios control. This parameter may be passed to + * interrupt service routines since it must be provided for the + * rtems_termios_enqueue_raw_characters() and + * rtems_termios_dequeue_characters() functions. + * @param[in] context The Termios device context. + * @param[in] term The current Termios attributes. + * @param[in] args The open/close arguments. This is parameter provided to + * support legacy drivers. It must not be used by new drivers. + * + * @retval true Successful operation. + * @retval false Cannot open device. + * + * @see rtems_termios_get_device_context() and rtems_termios_set_best_baud(). + */ + bool (*first_open)( + struct rtems_termios_tty *tty, + rtems_termios_device_context *context, + struct termios *term, + rtems_libio_open_close_args_t *args + ); + + /** + * @brief Last close of this device. + * + * @param[in] tty The Termios control. + * @param[in] context The Termios device context. + * @param[in] args The open/close arguments. This is parameter provided to + * support legacy drivers. It must not be used by new drivers. + */ + void (*last_close)( + struct rtems_termios_tty *tty, + rtems_termios_device_context *context, + rtems_libio_open_close_args_t *args + ); + + /** + * @brief Polled read. + * + * In case mode is TERMIOS_IRQ_DRIVEN, TERMIOS_IRQ_SERVER_DRIVEN or + * TERMIOS_TASK_DRIVEN, then data is received via + * rtems_termios_enqueue_raw_characters(). + * + * @param[in] context The Termios device context. + * + * @retval char The received data encoded as unsigned char. + * @retval -1 No data currently available. + */ + int (*poll_read)(rtems_termios_device_context *context); + + /** + * @brief Polled write in case mode is TERMIOS_POLLED or write support + * otherwise. + * + * @param[in] context The Termios device context. + * @param[in] buf The output buffer. + * @param[in] len The output buffer length in characters. + */ + void (*write)( + rtems_termios_device_context *context, + const char *buf, + size_t len + ); + + /** + * @brief Set attributes after a Termios settings change. + * + * @param[in] context The Termios device context. + * @param[in] term The new Termios attributes. + * + * @retval true Successful operation. + * @retval false Invalid attributes. + */ + bool (*set_attributes)( + rtems_termios_device_context *context, + const struct termios *term + ); + + /** + * @brief IO control handler. + * + * Invoked in case the Termios layer cannot deal with the IO request. + * + * @param[in] context The Termios device context. + * @param[in] request The IO control request. + * @param[in] buffer The IO control buffer. + */ + int (*ioctl)( + rtems_termios_device_context *context, + ioctl_command_t request, + void *buffer + ); + + /** + * @brief Termios device mode. + */ + rtems_termios_device_mode mode; +} rtems_termios_device_handler; + +/** + * @brief Termios device flow control handler. + * + * @see rtems_termios_device_install(). + */ +typedef struct { + /** + * @brief Indicate to stop remote transmitter. + * + * @param[in] context The Termios device context. + */ + void (*stop_remote_tx)(rtems_termios_device_context *context); + + /** + * @brief Indicate to start remote transmitter. + * + * @param[in] context The Termios device context. + */ + void (*start_remote_tx)(rtems_termios_device_context *context); +} rtems_termios_device_flow; + +/** + * @brief Termios device node for installed devices. + * + * @see rtems_termios_device_install(). + */ +typedef struct rtems_termios_device_node { + rtems_chain_node node; + rtems_device_major_number major; + rtems_device_minor_number minor; + const rtems_termios_device_handler *handler; + const rtems_termios_device_flow *flow; + rtems_termios_device_context *context; + struct rtems_termios_tty *tty; +} rtems_termios_device_node; + +/* + * Variables associated with each termios instance. + * One structure for each hardware I/O device. + */ +typedef struct rtems_termios_tty { + /* + * Linked-list of active TERMIOS devices + */ + struct rtems_termios_tty *forw; + struct rtems_termios_tty *back; + + /* + * How many times has this device been opened + */ + int refcount; + + /* + * This device + */ + rtems_device_major_number major; + rtems_device_minor_number minor; + + /* + * Mutual-exclusion semaphores + */ + rtems_id isem; + rtems_id osem; + + /* + * The canonical (cooked) character buffer + */ + char *cbuf; + int ccount; + int cindex; + + /* + * Keep track of cursor (printhead) position + */ + int column; + int read_start_column; + + /* + * The ioctl settings + */ + struct termios termios; + rtems_interval vtimeTicks; + + /* + * Raw input character buffer + */ + struct rtems_termios_rawbuf rawInBuf; + uint32_t rawInBufSemaphoreOptions; + rtems_interval rawInBufSemaphoreTimeout; + rtems_interval rawInBufSemaphoreFirstTimeout; + unsigned int rawInBufDropped; /* Statistics */ + + /* + * Raw output character buffer + */ + struct rtems_termios_rawbuf rawOutBuf; + int t_dqlen; /* count of characters dequeued from device */ + enum {rob_idle, rob_busy, rob_wait } rawOutBufState; + + /* + * Callbacks to device-specific routines + */ + rtems_termios_callbacks device; + + /** + * @brief Context for legacy devices using the callbacks. + */ + rtems_termios_device_context legacy_device_context; + + /** + * @brief The device handler. + */ + rtems_termios_device_handler handler; + + /** + * @brief The device flow control handler. + */ + rtems_termios_device_flow flow; + + volatile unsigned int flow_ctrl; + unsigned int lowwater,highwater; + + /* + * I/O task IDs (for task-driven drivers) + */ + rtems_id rxTaskId; + rtems_id txTaskId; + + /* + * line discipline related stuff + */ + int t_line; /* id of line discipline */ + void *t_sc; /* hook for discipline-specific data structure */ + + /* + * Wakeup callback variables + */ + struct ttywakeup tty_snd; + struct ttywakeup tty_rcv; + bool tty_rcvwakeup; + + /** + * @brief Corresponding device node. + */ + rtems_termios_device_node *device_node; + + /** + * @brief Context for device driver. + */ + rtems_termios_device_context *device_context; +} rtems_termios_tty; + +/** + * @brief Installs a Termios device. + * + * The installed Termios device may be removed via unlink(). + * + * @param[in] device_file The device file path. + * @param[in] handler The device handler. It must be persistent throughout the + * installed time of the device. + * @param[in] flow The device flow control handler. The device flow control + * handler are optional and may be @c NULL. If present must be persistent + * throughout the installed time of the device. + * @param[in] context The device context. It must be persistent throughout the + * installed time of the device. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_NO_MEMORY Not enough memory to create a device node. + * @retval RTEMS_UNSATISFIED Creation of the device file failed. + * @retval RTEMS_INCORRECT_STATE Termios is not initialized. + * + * @see rtems_termios_get_device_context(). + */ +rtems_status_code rtems_termios_device_install( + const char *device_file, + const rtems_termios_device_handler *handler, + const rtems_termios_device_flow *flow, + rtems_termios_device_context *context +); + +/** + * @brief Returns the device context of an installed Termios device. + * + * @param[in] tty The Termios control. + */ +RTEMS_INLINE_ROUTINE void *rtems_termios_get_device_context( + const rtems_termios_tty *tty +) +{ + return tty->device_context; +} + +/** + * @brief Acquires the device lock. + * + * @param[in] context The device context. + * @param[in] lock_context The local interrupt lock context for an acquire and + * release pair. + */ +RTEMS_INLINE_ROUTINE void rtems_termios_device_lock_acquire( + rtems_termios_device_context *context, + rtems_interrupt_lock_context *lock_context +) +{ + ( *context->lock_acquire )( context, lock_context ); +} + +/** + * @brief Releases the device lock. + * + * @param[in] context The device context. + * @param[in] lock_context The local interrupt lock context for an acquire and + * release pair. + */ +RTEMS_INLINE_ROUTINE void rtems_termios_device_lock_release( + rtems_termios_device_context *context, + rtems_interrupt_lock_context *lock_context +) +{ + ( *context->lock_release )( context, lock_context ); +} + +/** + * @brief Sets the best baud value in the Termios control. + * + * The valid Termios baud values are between 0 and 460800. The Termios baud + * value is chosen which minimizes the difference to the value specified. + * + * @param[in] term The Termios attributes. + * @param[in] baud The current baud setting of the device. + */ +void rtems_termios_set_best_baud( + struct termios *term, + uint32_t baud +); + +struct rtems_termios_linesw { + int (*l_open) (struct rtems_termios_tty *tp); + int (*l_close)(struct rtems_termios_tty *tp); + int (*l_read )(struct rtems_termios_tty *tp,rtems_libio_rw_args_t *args); + int (*l_write)(struct rtems_termios_tty *tp,rtems_libio_rw_args_t *args); + int (*l_rint )(int c,struct rtems_termios_tty *tp); + int (*l_start)(struct rtems_termios_tty *tp); + int (*l_ioctl)(struct rtems_termios_tty *tp,rtems_libio_ioctl_args_t *args); + int (*l_modem)(struct rtems_termios_tty *tp,int flags); +}; + +/* + * FIXME: this should move to termios.h! + */ +void rtems_termios_rxirq_occured(struct rtems_termios_tty *tty); + +/* + * FIXME: this should move to termios.h! + * put a string to output ring buffer + */ +void rtems_termios_puts ( + const void *buf, + size_t len, + struct rtems_termios_tty *tty +); + +/* + * global hooks for line disciplines + */ +extern struct rtems_termios_linesw rtems_termios_linesw[]; +extern int rtems_termios_nlinesw; + +#define TTYDISC 0 /* termios tty line discipline */ +#define TABLDISC 3 /* tablet discipline */ +#define SLIPDISC 4 /* serial IP discipline */ +#define PPPDISC 5 /* PPP discipline */ +#define MAXLDISC 8 + +/* baudrate xxx integer type */ +typedef uint32_t rtems_termios_baud_t; + +/** + * @brief RTEMS Termios Baud Table + */ +extern const rtems_assoc_t rtems_termios_baud_table []; + +/** + * @brief Converts the Integral Baud value @a baud to the Termios Control Flag + * Representation + * + * @retval B0 Invalid baud value or a baud value of 0. + * @retval other Baud constant according to @a baud. + */ +speed_t rtems_termios_number_to_baud(rtems_termios_baud_t baud); + +/** + * @brief Converts the baud flags to an integral baud value. + * + * @retval 0 Invalid baud value or a baud value of @c B0. + * @retval other Integral baud value. + */ +rtems_termios_baud_t rtems_termios_baud_to_number(speed_t baud); + +/** + * @brief Convert Bxxx Constant to Index + */ +int rtems_termios_baud_to_index(rtems_termios_baud_t termios_baud); + +/** + * @brief Sets the initial @a baud in the Termios context @a tty. + * + * @retval 0 Successful operation. + * @retval -1 Invalid baud value. + */ +int rtems_termios_set_initial_baud( + struct rtems_termios_tty *tty, + rtems_termios_baud_t baud +); + +/** + * @brief Termios kqueue() filter filesystem node handler + * + * Real implementation is provided by libbsd. + */ +int rtems_termios_kqfilter( + rtems_libio_t *iop, + struct knote *kn +); + +/** + * @brief Termios mmap() filter filesystem node handler + * + * Real implementation is provided by libbsd. + */ +int rtems_termios_mmap( + rtems_libio_t *iop, + void **addr, + size_t len, + int prot, + off_t off +); + +/** + * @brief Termios poll() filesystem node handler. + * + * Real implementation is provided by libbsd. + */ +int rtems_termios_poll( + rtems_libio_t *iop, + int events +); + +#define RTEMS_IO_SNDWAKEUP _IOW('t', 11, struct ttywakeup ) /* send tty wakeup */ +#define RTEMS_IO_RCVWAKEUP _IOW('t', 12, struct ttywakeup ) /* recv tty wakeup */ + +#define OLCUC 0x00000100 /* map lower case to upper case on output */ +#define IUCLC 0x00004000 /* map upper case to lower case on input */ + +#define RTEMS_TERMIOS_NUMBER_BAUD_RATES 25 + +#ifdef __cplusplus +} +#endif + +#endif /* TERMIOSTYPES_H */ diff --git a/cpukit/include/rtems/test.h b/cpukit/include/rtems/test.h new file mode 100644 index 0000000000..3dbdb9e32e --- /dev/null +++ b/cpukit/include/rtems/test.h @@ -0,0 +1,314 @@ +/* + * Copyright (c) 2014, 2017 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_TEST_H +#define _RTEMS_TEST_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup RTEMSTest Test Support + * + * @brief Test support functions. + * + * @{ + */ + +/** + * @brief Each test must define a test name string. + */ +extern const char rtems_test_name[]; + +/** + * @brief Each test must define a printer. + */ +extern rtems_printer rtems_test_printer; + +/** + * @brief Fatal extension for tests. + */ +void rtems_test_fatal_extension( + rtems_fatal_source source, + bool always_set_to_false, + rtems_fatal_code code +); + +/** + * @brief Initial extension for tests. + */ +#define RTEMS_TEST_INITIAL_EXTENSION \ + { NULL, NULL, NULL, NULL, NULL, NULL, NULL, rtems_test_fatal_extension } + +/** + * @brief Test states. + */ +typedef enum +{ + RTEMS_TEST_STATE_PASS, + RTEMS_TEST_STATE_FAIL, + RTEMS_TEST_STATE_USER_INPUT, + RTEMS_TEST_STATE_INDETERMINATE, + RTEMS_TEST_STATE_BENCHMARK +} RTEMS_TEST_STATE; + +#if (TEST_STATE_EXPECTED_FAIL && TEST_STATE_USER_INPUT) || \ + (TEST_STATE_EXPECTED_FAIL && TEST_STATE_INDETERMINATE) || \ + (TEST_STATE_EXPECTED_FAIL && TEST_STATE_BENCHMARK) || \ + (TEST_STATE_USER_INPUT && TEST_STATE_INDETERMINATE) || \ + (TEST_STATE_USER_INPUT && TEST_STATE_BENCHMARK) || \ + (TEST_STATE_INDETERMINATE && TEST_STATE_BENCHMARK) + #error Test states must be unique +#endif + +#if TEST_STATE_EXPECTED_FAIL + #define TEST_STATE RTEMS_TEST_STATE_FAIL +#elif TEST_STATE_USER_INPUT + #define TEST_STATE RTEMS_TEST_STATE_USER_INPUT +#elif TEST_STATE_INDETERMINATE + #define TEST_STATE RTEMS_TEST_STATE_INDETERMINATE +#elif TEST_STATE_BENCHMARK + #define TEST_STATE RTEMS_TEST_STATE_BENCHMARK +#else + #define TEST_STATE RTEMS_TEST_STATE_PASS +#endif + +/** + * @brief Prints a begin of test message using printf(). + * + * @returns As specified by printf(). + */ +int rtems_test_begin(const char* name, const RTEMS_TEST_STATE state); + +/** + * @brief Prints an end of test message using printf(). + * + * @returns As specified by printf(). + */ +int rtems_test_end(const char* name); + +/** + * @brief Exit the test without calling exit() since it closes stdin, etc and + * pulls in stdio code + */ +void rtems_test_exit(int status) RTEMS_NO_RETURN; + +/** + * @brief Prints via the RTEMS printer. + * + * @returns As specified by printf(). + */ +int rtems_test_printf(const char* format, ...) RTEMS_PRINTFLIKE(1, 2); + +#define RTEMS_TEST_PARALLEL_PROCESSOR_MAX 32 + +typedef struct rtems_test_parallel_job rtems_test_parallel_job; + +/** + * @brief Internal context for parallel job execution. + */ +typedef struct { + Atomic_Ulong stop; + SMP_barrier_Control barrier; + size_t worker_count; + rtems_id worker_ids[RTEMS_TEST_PARALLEL_PROCESSOR_MAX]; + rtems_id stop_worker_timer_id; + const struct rtems_test_parallel_job *jobs; + size_t job_count; +} rtems_test_parallel_context; + +/** + * @brief Worker task setup handler. + * + * Called during rtems_test_parallel() to optionally setup a worker task before + * it is started. + * + * @param[in] ctx The parallel context. + * @param[in] worker_index The worker index. + * @param[in] worker_id The worker task identifier. + */ +typedef void (*rtems_test_parallel_worker_setup)( + rtems_test_parallel_context *ctx, + size_t worker_index, + rtems_id worker_id +); + +/** + * @brief Basic parallel job description. + */ +struct rtems_test_parallel_job { + /** + * @brief Job initialization handler. + * + * This handler executes only in the context of the master worker before the + * job body handler. + * + * @param[in] ctx The parallel context. + * @param[in] arg The user specified argument. + * @param[in] active_workers Count of active workers. Depends on the cascade + * option. + * + * @return The desired job body execution time in clock ticks. See + * rtems_test_parallel_stop_job(). + */ + rtems_interval (*init)( + rtems_test_parallel_context *ctx, + void *arg, + size_t active_workers + ); + + /** + * @brief Job body handler. + * + * @param[in] ctx The parallel context. + * @param[in] arg The user specified argument. + * @param[in] active_workers Count of active workers. Depends on the cascade + * option. + * @param[in] worker_index The worker index. It ranges from 0 to the + * processor count minus one. + */ + void (*body)( + rtems_test_parallel_context *ctx, + void *arg, + size_t active_workers, + size_t worker_index + ); + + /** + * @brief Job finalization handler. + * + * This handler executes only in the context of the master worker after the + * job body handler. + * + * @param[in] ctx The parallel context. + * @param[in] arg The user specified argument. + * @param[in] active_workers Count of active workers. Depends on the cascade + * option. + */ + void (*fini)( + rtems_test_parallel_context *ctx, + void *arg, + size_t active_workers + ); + + /** + * @brief Job specific argument. + */ + void *arg; + + /** + * @brief Job cascading flag. + * + * This flag indicates whether the job should be executed in a cascaded + * manner (the job is executed on one processor first, two processors + * afterwards and incremented step by step until all processors are used). + */ + bool cascade; +}; + +/** + * @brief Indicates if a job body should stop its work loop. + * + * @param[in] ctx The parallel context. + * + * @retval true The job body should stop its work loop and return to the caller. + * @retval false Otherwise. + */ +static inline bool rtems_test_parallel_stop_job( + const rtems_test_parallel_context *ctx +) +{ + return _Atomic_Load_ulong(&ctx->stop, ATOMIC_ORDER_RELAXED) != 0; +} + +/** + * @brief Indicates if a worker is the master worker. + * + * The master worker is the thread that called rtems_test_parallel(). + * + * @param[in] worker_index The worker index. + * + * @retval true This is the master worker. + * @retval false Otherwise. + */ +static inline bool rtems_test_parallel_is_master_worker(size_t worker_index) +{ + return worker_index == 0; +} + +/** + * @brief Returns the task identifier for a worker. + * + * @param[in] ctx The parallel context. + * @param[in] worker_index The worker index. + * + * @return The task identifier of the worker. + */ +static inline rtems_id rtems_test_parallel_get_task_id( + const rtems_test_parallel_context *ctx, + size_t worker_index +) +{ + return ctx->worker_ids[worker_index]; +} + +/** + * @brief Runs a bunch of jobs in parallel on all processors of the system. + * + * The worker tasks inherit the priority of the executing task. + * + * There are SMP barriers before and after the job body. + * + * @param[in] ctx The parallel context. + * @param[in] worker_setup Optional handler to setup a worker task before it is + * started. + * @param[in] jobs The table of jobs. + * @param[in] job_count The count of jobs in the job table. + */ +void rtems_test_parallel( + rtems_test_parallel_context *ctx, + rtems_test_parallel_worker_setup worker_setup, + const rtems_test_parallel_job *jobs, + size_t job_count +); + +/** + * @brief Performs a busy loop with the specified iteration count. + * + * This function is optimized to not perform memory accesses and should have a + * small jitter. + * + * @param[in] count The iteration count. + */ +void rtems_test_busy(uint_fast32_t count); + +/** + * @brief Returns a count value for rtems_test_busy() which yields roughly a + * duration of one clock tick. + */ +uint_fast32_t rtems_test_get_one_tick_busy_count(void); + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_TEST_H */ diff --git a/cpukit/include/rtems/timecounter.h b/cpukit/include/rtems/timecounter.h new file mode 100644 index 0000000000..8d1bd78618 --- /dev/null +++ b/cpukit/include/rtems/timecounter.h @@ -0,0 +1,335 @@ +/** + * @file + * + * @ingroup SAPITimecounter + * + * @brief Timecounter API + */ + +/* + * Copyright (c) 2015 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_TIMECOUNTER_H +#define _RTEMS_TIMECOUNTER_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @defgroup SAPITimecounter Timecounter Support + * + * @{ + */ + +/** + * @brief Timecounter quality for the clock drivers. + * + * Timecounter with higher quality value are used in favour of those with lower + * quality value. + */ +#define RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER 100 + +/** + * @copydoc _Timecounter_Install() + * + * Below is an exemplary code snippet that shows the adjustable parameters and + * the following call of the install routine. + * + * @code + * struct timecounter tc; + * + * uint32_t get_timecount( struct timecounter *tc ) + * { + * return some_free_running_counter; + * } + * + * void install( void ) + * { + * tc.tc_get_timecount = get_timecount; + * tc.tc_counter_mask = 0xffffffff; + * tc.tc_frequency = 123456; + * tc.tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER; + * rtems_timecounter_install( &tc ); + * } + * @endcode + */ +RTEMS_INLINE_ROUTINE void rtems_timecounter_install( + struct timecounter *tc +) +{ + _Timecounter_Install( tc ); +} + +/** + * @copydoc _Timecounter_Tick() + */ +RTEMS_INLINE_ROUTINE void rtems_timecounter_tick(void) +{ + _Timecounter_Tick(); +} + +/** + * @brief Simple timecounter to support legacy clock drivers. + */ +typedef struct { + struct timecounter tc; + uint64_t scaler; + uint32_t real_interval; + uint32_t binary_interval; +} rtems_timecounter_simple; + +/** + * @brief At tick handling done under protection of the timecounter lock. + */ +typedef void rtems_timecounter_simple_at_tick( + rtems_timecounter_simple *tc +); + +/** + * @brief Returns the current value of a simple timecounter. + */ +typedef uint32_t rtems_timecounter_simple_get( + rtems_timecounter_simple *tc +); + +/** + * @brief Returns true if the interrupt of a simple timecounter is pending, and + * false otherwise. + */ +typedef bool rtems_timecounter_simple_is_pending( + rtems_timecounter_simple *tc +); + +/** + * @brief Initializes and installs a simple timecounter. + * + * A simple timecounter can be used if the hardware provides no free running + * counter. A periodic hardware counter must be provided. The counter period + * must be synchronous to the clock tick. The counter ticks per clock tick is + * scaled up to the next power of two. + * + * @param[in] tc Zero initialized simple timecounter. + * @param[in] counter_frequency_in_hz The hardware counter frequency in Hz. + * @param[in] counter_ticks_per_clock_tick The hardware counter ticks per clock + * tick. + * @param[in] get_timecount The method to get the current time count. + * + * @code + * #include + * + * static rtems_timecounter_simple some_tc; + * + * static uint32_t some_tc_get( rtems_timecounter_simple *tc ) + * { + * return some.value; + * } + * + * static bool some_tc_is_pending( rtems_timecounter_simple *tc ) + * { + * return some.is_pending; + * } + * + * static uint32_t some_tc_get_timecount( struct timecounter *tc ) + * { + * return rtems_timecounter_simple_downcounter_get( + * tc, + * some_tc_get, + * some_tc_is_pending + * ); + * } + * + * static void some_tc_tick( void ) + * { + * rtems_timecounter_simple_downcounter_tick( &some_tc, some_tc_get ); + * } + * + * void some_tc_init( void ) + * { + * uint64_t us_per_tick; + * uint32_t counter_frequency_in_hz; + * uint32_t counter_ticks_per_clock_tick; + * + * us_per_tick = rtems_configuration_get_microseconds_per_tick(); + * counter_frequency_in_hz = some_tc_get_frequency(); + * counter_ticks_per_clock_tick = + * (uint32_t) ( counter_frequency_in_hz * us_per_tick ) / 1000000; + * + * some_tc_init_hardware( counter_ticks_per_clock_tick ); + * some_tc_init_clock_tick_interrupt( some_tc_tick ); + * + * rtems_timecounter_simple_install( + * &some_tc, + * counter_frequency_in_hz, + * counter_ticks_per_clock_tick, + * some_tc_get_timecount + * ); + * } + * @endcode + * + * @see rtems_timecounter_simple_downcounter_get(), + * rtems_timecounter_simple_downcounter_tick(), + * rtems_timecounter_simple_upcounter_get() and + * rtems_timecounter_simple_upcounter_tick(). + */ +void rtems_timecounter_simple_install( + rtems_timecounter_simple *tc, + uint32_t counter_frequency_in_hz, + uint32_t counter_ticks_per_clock_tick, + timecounter_get_t *get_timecount +); + +/** + * @brief Maps a simple timecounter value into its binary frequency domain. + * + * @param[in] tc The simple timecounter. + * @param[in] value The value of the simple timecounter. + * + * @return The scaled value. + */ +RTEMS_INLINE_ROUTINE uint32_t rtems_timecounter_simple_scale( + const rtems_timecounter_simple *tc, + uint32_t value +) +{ + return (uint32_t) ( ( value * tc->scaler ) >> 32 ); +} + +/** + * @brief Performs a simple timecounter tick for downcounters. + * + * @param[in] tc The simple timecounter. + * @param[in] get The method to get the value of the simple timecounter. + * @param[in] at_tick The method to perform work under timecounter lock + * protection at this tick, e.g. clear a pending flag. + */ +RTEMS_INLINE_ROUTINE void rtems_timecounter_simple_downcounter_tick( + rtems_timecounter_simple *tc, + rtems_timecounter_simple_get get, + rtems_timecounter_simple_at_tick at_tick +) +{ + ISR_lock_Context lock_context; + uint32_t current; + + _Timecounter_Acquire( &lock_context ); + + ( *at_tick )( tc ); + + current = rtems_timecounter_simple_scale( + tc, + tc->real_interval - ( *get )( tc ) + ); + + _Timecounter_Tick_simple( tc->binary_interval, current, &lock_context ); +} + +/** + * @brief Performs a simple timecounter tick for upcounters. + * + * @param[in] tc The simple timecounter. + * @param[in] get The method to get the value of the simple timecounter. + * @param[in] at_tick The method to perform work under timecounter lock + * protection at this tick, e.g. clear a pending flag. + */ +RTEMS_INLINE_ROUTINE void rtems_timecounter_simple_upcounter_tick( + rtems_timecounter_simple *tc, + rtems_timecounter_simple_get get, + rtems_timecounter_simple_at_tick at_tick +) +{ + ISR_lock_Context lock_context; + uint32_t current; + + _Timecounter_Acquire( &lock_context ); + + ( *at_tick )( tc ); + + current = rtems_timecounter_simple_scale( tc, ( *get )( tc ) ); + + _Timecounter_Tick_simple( tc->binary_interval, current, &lock_context ); +} + +/** + * @brief Gets the simple timecounter value mapped to its binary frequency + * domain for downcounters. + * + * @param[in] tc The simple timecounter. + * @param[in] get The method to get the value of the simple timecounter. + * @param[in] is_pending The method which indicates if the interrupt of the + * simple timecounter is pending. + */ +RTEMS_INLINE_ROUTINE uint32_t rtems_timecounter_simple_downcounter_get( + struct timecounter *tc_base, + rtems_timecounter_simple_get get, + rtems_timecounter_simple_is_pending is_pending +) +{ + rtems_timecounter_simple *tc; + uint32_t counter; + uint32_t interval; + + tc = (rtems_timecounter_simple *) tc_base; + counter = ( *get )( tc ); + interval = tc->real_interval; + + if ( ( *is_pending )( tc ) ) { + counter = ( *get )( tc ); + interval *= 2; + } + + return rtems_timecounter_simple_scale( tc, interval - counter ); +} + +/** + * @brief Gets the simple timecounter value mapped to its binary frequency + * domain for upcounters. + * + * @param[in] tc The simple timecounter. + * @param[in] get The method to get the value of the simple timecounter. + * @param[in] is_pending The method which indicates if the interrupt of the + * simple timecounter is pending. + */ +RTEMS_INLINE_ROUTINE uint32_t rtems_timecounter_simple_upcounter_get( + struct timecounter *tc_base, + rtems_timecounter_simple_get get, + rtems_timecounter_simple_is_pending is_pending +) +{ + rtems_timecounter_simple *tc; + uint32_t counter; + uint32_t interval; + + tc = (rtems_timecounter_simple *) tc_base; + counter = ( *get )( tc ); + interval = 0; + + if ( ( *is_pending )( tc ) ) { + counter = ( *get )( tc ); + interval = tc->real_interval; + } + + return rtems_timecounter_simple_scale( tc, interval + counter ); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_TIMECOUNTER_H */ diff --git a/cpukit/include/rtems/timespec.h b/cpukit/include/rtems/timespec.h new file mode 100644 index 0000000000..e82d271492 --- /dev/null +++ b/cpukit/include/rtems/timespec.h @@ -0,0 +1,305 @@ +/** + * @file + * + * @brief Timespec API + * + * This include file contains API for manipulating timespecs. + */ + +/* + * Copyright (c) 2012. + * Krzysztof Miesowicz + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_TIMESPEC_H +#define _RTEMS_TIMESPEC_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup TimespecAPI Timespec + * + * @ingroup ClassicRTEMS + * + * @brief Timespec API + * + * @{ + * + */ + +/** + * @brief Is timespec valid + * + * This method determines the validity of a timespec. + * + * @param[in] time is the timespec instance to validate. + * + * @retval true The timespec is valid. + * @retval false The timespec is not valid. + */ +RTEMS_INLINE_ROUTINE bool rtems_timespec_is_valid( + const struct timespec *time +) +{ + return _Timespec_Is_valid(time); +} + +/** + * @brief Timespec less than operator. + * + * This method is the less than operator for timespecs. + * + * @param[in] lhs is the left hand side timespec + * @param[in] rhs is the right hand side timespec + * + * @retval true @a lhs is less than @a rhs. + * @retval false @a lhs is not less than @a rhs. + * + */ +RTEMS_INLINE_ROUTINE bool rtems_timespec_less_than( + const struct timespec *lhs, + const struct timespec *rhs +) +{ + return _Timespec_Less_than(lhs,rhs); +} + +/** + * @brief Add to a timespec. + * + * This routine adds two timespecs. The second argument is added + * to the first. + * + * @param[in] time is the base time to be added to + * @param[in] add is the timespec to add to the first argument + * + * @return This method returns the number of seconds @a time increased by. + */ +RTEMS_INLINE_ROUTINE uint32_t rtems_timespec_add_to( + struct timespec *time, + const struct timespec *add +) +{ + return _Timespec_Add_to(time,add); +} + +/** + * @brief Convert timespec to number of ticks. + * + * This routine convert the @a time timespec to the corresponding number + * of clock ticks. + * + * @param[in] time is the time to be converted + * + * @return This method returns the number of ticks computed. + */ +RTEMS_INLINE_ROUTINE uint32_t rtems_timespec_to_ticks( + const struct timespec *time +) +{ + return _Timespec_To_ticks(time); +} + +/** + * @brief Convert ticks to timespec. + * + * This routine converts the @a ticks value to the corresponding + * timespec format @a time. + * + * @param[in] time is the timespec format time result + * @param[in] ticks is the number of ticks to convert + */ + +RTEMS_INLINE_ROUTINE void rtems_timespec_from_ticks( + uint32_t ticks, + struct timespec *time +) +{ + _Timespec_From_ticks(ticks,time); +} + +/** + * @brief Subtract two timespec. + * + * This routine subtracts two timespecs. @a result is set to + * @a end - @a start. + * + * @param[in] start is the starting time + * @param[in] end is the ending time + * @param[in] result is the difference between starting and ending time. + * + * @return This method fills in @a result. + */ +RTEMS_INLINE_ROUTINE void rtems_timespec_subtract( + const struct timespec *start, + const struct timespec *end, + struct timespec *result +) +{ + _Timespec_Subtract(start,end,result); +} + +/** + * @brief Divide timespec by integer. + * + * This routine divides a timespec by an integer value. The expected + * use is to assist in benchmark calculations where you typically + * divide a duration by a number of iterations. + * + * @param[in] time is the total + * @param[in] iterations is the number of iterations + * @param[in] result is the average time. + * + * @return This method fills in @a result. + */ +RTEMS_INLINE_ROUTINE void rtems_timespec_divide_by_integer( + const struct timespec *time, + uint32_t iterations, + struct timespec *result +) +{ + _Timespec_Divide_by_integer(time,iterations,result); +} + +/** + * @brief Divide timespec. + * + * This routine divides a timespec by another timespec. The + * intended use is for calculating percentages to three decimal points. + * + * @param[in] lhs is the left hand number + * @param[in] rhs is the right hand number + * @param[in] ival_percentage is the integer portion of the average + * @param[in] fval_percentage is the thousandths of percentage + * + * @return This method fills in @a result. + */ +RTEMS_INLINE_ROUTINE void rtems_timespec_divide( + const struct timespec *lhs, + const struct timespec *rhs, + uint32_t *ival_percentage, + uint32_t *fval_percentage +) +{ + _Timespec_Divide(lhs,rhs,ival_percentage,fval_percentage); +} + +/** + * @brief Set timespec to seconds nanosecond. + * + * This method sets the timespec to the specified seconds and nanoseconds + * value. + * + * @param[in] _time points to the timespec instance to validate. + * @param[in] _seconds is the seconds portion of the timespec + * @param[in] _nanoseconds is the nanoseconds portion of the timespec + */ +RTEMS_INLINE_ROUTINE void rtems_timespec_set( + struct timespec *_time, + time_t _seconds, + uint32_t _nanoseconds +) +{ + _Timespec_Set( _time, _seconds, _nanoseconds ); +} + +/** + * @brief Zero timespec. + * + * This method sets the timespec to zero. + * value. + * + * @param[in] _time points to the timespec instance to zero. + */ +RTEMS_INLINE_ROUTINE void rtems_timespec_zero( + struct timespec *_time +) +{ + _Timespec_Set_to_zero( _time ); +} + +/** + * @brief Get seconds portion of timespec. + * + * This method returns the seconds portion of the specified timespec + * + * @param[in] _time points to the timespec + * + * @return The seconds portion of @a _time. + */ +RTEMS_INLINE_ROUTINE time_t rtems_timespec_get_seconds( + struct timespec *_time +) +{ + return _Timespec_Get_seconds( _time ); +} + +/** + * @brief Get nanoseconds portion of timespec. + * + * This method returns the nanoseconds portion of the specified timespec + * + * @param[in] _time points to the timespec + * + * @return The nanoseconds portion of @a _time. + */ +RTEMS_INLINE_ROUTINE uint32_t rtems_timespec_get_nanoseconds( + struct timespec *_time +) +{ + return _Timespec_Get_nanoseconds( _time ); +} + +/** + * @brief Timespec greater than operator. + * + * This method is the greater than operator for timespecs. + * + * @param[in] _lhs is the left hand side timespec + * @param[in] _rhs is the right hand side timespec + * + * @retval true @a _lhs is greater than @a _rhs. + * @retval false @a _lhs is not greater than @a _rhs. + */ +RTEMS_INLINE_ROUTINE bool rtems_timespec_greater_than( + const struct timespec *_lhs, + const struct timespec *_rhs +) +{ + return _Timespec_Greater_than( _lhs, _rhs ); +} +/** + * @brief Timespec equal to Operator + * + * This method is the is equal to than operator for timespecs. + * + * @param[in] lhs is the left hand side timespec + * @param[in] rhs is the right hand side timespec + * + * @retval true @a lhs is equal to @a rhs. + * @retval false @a lhs is not equal to @a rhs. + */ +RTEMS_INLINE_ROUTINE bool rtems_timespec_equal_to( + const struct timespec *lhs, + const struct timespec *rhs +) +{ + return _Timespec_Equal_to( lhs, rhs); +} + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/tod.h b/cpukit/include/rtems/tod.h new file mode 100644 index 0000000000..971e8548e8 --- /dev/null +++ b/cpukit/include/rtems/tod.h @@ -0,0 +1,70 @@ +/** + * @file + * + * @ingroup shared_tod + * + * @brief Real Time Clock Time of Day API Definition + */ + +/* + * + * Based on MVME162 TOD by: + * COPYRIGHT (C) 1997 + * by Katsutoshi Shibuya - BU Denken Co.,Ltd. - Sapporo - JAPAN + * ALL RIGHTS RESERVED + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef TOD_H +#define TOD_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup shared_tod RTC + * + * @ingroup bsp_shared + * + * @brief Set the RTC + */ +int setRealTime( + const rtems_time_of_day *tod +); + +/* + * Get the time from the RTC. + */ + +void getRealTime( + rtems_time_of_day *tod +); + +/* + * Read real time from RTC and set it to RTEMS' clock manager + */ + +void setRealTimeToRTEMS(void); + +/* + * Read time from RTEMS' clock manager and set it to RTC + */ + +void setRealTimeFromRTEMS(void); + +/* + * Return the difference between RTC and RTEMS' clock manager time in minutes. + * If the difference is greater than 1 day, this returns 9999. + */ + +int checkRealTime(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/include/rtems/trace/rtems-trace-buffer-vars.h b/cpukit/include/rtems/trace/rtems-trace-buffer-vars.h new file mode 100644 index 0000000000..8f0ff08587 --- /dev/null +++ b/cpukit/include/rtems/trace/rtems-trace-buffer-vars.h @@ -0,0 +1,148 @@ +/** + * @file + * + * @ingroup Shell + * + * @brief Access to the RTEMS Trace Buffer Generator (TBG). + */ +/* + * Copyright (c) 2015 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#if !defined (_RTEMS_TRACE_BUFFER_VARS_H_) +#define _RTEMS_TRACE_BUFFER_VARS_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * These functions are provided as a separated interface to the Trace Buffer + * Generatror (TBG) data are not really designed for any real-time performance + * type interface. + * + * Separating the data from the codes stops the compiler incorrectly loop + * optimising. + */ + +typedef struct +{ + uint32_t size; + const char* const type; +} __rtld_trace_sig_arg; + + typedef struct { + uint32_t argc; + const __rtld_trace_sig_arg* args; +} __rtld_trace_sig; + +typedef __rtld_trace_sig_arg rtems_trace_sig_arg; +typedef __rtld_trace_sig rtems_trace_sig; + +/** + * Returns the number of trace functions. + */ +uint32_t rtems_trace_names_size (void); + +/** + * Return the name given an index. No range checking. + */ +const char* rtems_trace_names (const uint32_t index); + +/** + * Returns the number of words in the enables array. + */ +uint32_t rtems_trace_enables_size (void); + +/** + * Return the enable 32bit bitmap indexed into the enables array. No range + * checking. + */ +uint32_t rtems_trace_enables (const uint32_t index); + +/** + * Returns the number of words in the triggers array. + */ +uint32_t rtems_trace_triggers_size (void); + +/** + * Return the trigger 32bit bitmap indexed into the triggers array. No range + * checking. + */ +uint32_t rtems_trace_triggers (const uint32_t index); + +/** + * Return the trace function signature. + */ +const rtems_trace_sig* rtems_trace_signatures (const uint32_t index); + +/** + * Return true is the enable bit is set for the trace function index. + */ +bool rtems_trace_enable_set(const uint32_t index); + +/** + * Return true is the trigger bit is set for the trace function index. + */ +bool rtems_trace_trigger_set(const uint32_t index); + +/** + * The application has been linked with Trace Buffering generated code. + */ +bool rtems_trace_buffering_present (void); + +/** + * Return the trace buffering mode flags. + */ +uint32_t rtems_trace_buffering_mode (void); + +/** + * Return the size of the trace buffering buffer in words. + */ +uint32_t rtems_trace_buffering_buffer_size (void); + +/** + * Return the base of the trace buffering buffer. + */ +uint32_t* rtems_trace_buffering_buffer (void); + +/** + * Return the buffer level. This is only stable if tracing has finished. + */ +uint32_t rtems_trace_buffering_buffer_in (void); + +/** + * The tracing has finished. + */ +bool rtems_trace_buffering_finished (void); + +/** + * Trace has been triggered and enable trace functions are being recorded. + */ +bool rtems_trace_buffering_triggered (void); + +/** + * Start tracing by clearing the triggered flag, setting to 0 and clearing the + * finished flag. + */ +void rtems_trace_buffering_start (void); + +/** + * Stop tracing by setting the finished flag. + */ +void rtems_trace_buffering_stop (void); + +/** + * Resume tracing by setting the finished flag. + */ +void rtems_trace_buffering_resume (void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/cpukit/include/rtems/untar.h b/cpukit/include/rtems/untar.h new file mode 100644 index 0000000000..bc0a97c103 --- /dev/null +++ b/cpukit/include/rtems/untar.h @@ -0,0 +1,260 @@ +/** + * @file + * + * @brief Untar an Image + * + * This file defines the interface to methods which can untar an image. + */ + +/* + * Written by: Jake Janovetz + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_UNTAR_H +#define _RTEMS_UNTAR_H + +#include +#include +#include +#include +#include + +#include + +/** + * @defgroup libmisc_untar_img Untar Image + * + * @ingroup libmisc + */ +/**@{*/ +#ifdef __cplusplus +extern "C" { +#endif + +#define UNTAR_SUCCESSFUL 0 +#define UNTAR_FAIL 1 +#define UNTAR_INVALID_CHECKSUM 2 +#define UNTAR_INVALID_HEADER 3 + +#define UNTAR_GZ_INFLATE_FAILED 4 +#define UNTAR_GZ_INFLATE_END_FAILED 5 + +int Untar_FromMemory(void *tar_buf, size_t size); +int Untar_FromMemory_Print(void *tar_buf, size_t size, const rtems_printer* printer); +int Untar_FromFile(const char *tar_name); +int Untar_FromFile_Print(const char *tar_name, const rtems_printer* printer); + +typedef struct { + /** + * @brief Current context state. + */ + enum { + UNTAR_CHUNK_HEADER, + UNTAR_CHUNK_SKIP, + UNTAR_CHUNK_WRITE, + UNTAR_CHUNK_ERROR + } state; + + /** + * @brief Header buffer. + */ + char header[512]; + + /** + * @brief Name buffer. + */ + char fname[100]; + + /** + * @brief Number of bytes of overall length are already processed. + */ + size_t done_bytes; + + /** + * @brief Mode of the file. + */ + unsigned long mode; + + /** + * @brief Overall amount of bytes to be processed. + */ + unsigned long todo_bytes; + + /** + * @brief Overall amount of blocks to be processed. + */ + unsigned long todo_blocks; + + /** + * @brief File descriptor of output file. + */ + int out_fd; +} Untar_ChunkContext; + +typedef struct { + /** + * @brief Instance of Chunk Context needed for tar decompression. + */ + Untar_ChunkContext base; + + /** + * @brief Current zlib context. + */ + z_stream strm; + + /** + * @brief Buffer that contains the inflated data. + */ + void *inflateBuffer; + + /** + * @brief Size of buffer that contains the inflated data. + */ + size_t inflateBufferSize; + +} Untar_GzChunkContext; + +typedef struct { + /** + * @brief Instance of Chunk Context needed for tar decompression. + */ + Untar_ChunkContext base; + + /** + * @brief Xz context. + */ + struct xz_dec* strm; + + /** + * @brief Xz buffer. + */ + struct xz_buf buf; + + /** + * @brief Buffer that contains the inflated data. + */ + void *inflateBuffer; + + /** + * @brief Size of buffer that contains the inflated data. + */ + size_t inflateBufferSize; + +} Untar_XzChunkContext; + +/** + * @brief Initializes the Untar_ChunkContext files out of a part of a block of + * memory. + * + * @param Untar_ChunkContext *context [in] Pointer to a context structure. + */ +void Untar_ChunkContext_Init(Untar_ChunkContext *context); + +/* + * @brief Rips links, directories and files out of a part of a block of memory. + * + * @param Untar_ChunkContext *context [in] Pointer to a context structure. + * @param void *chunk [in] Pointer to a chunk of a TAR buffer. + * @param size_t chunk_size [in] Length of the chunk of a TAR buffer. + * + * @retval UNTAR_SUCCESSFUL (0) on successful completion. + * @retval UNTAR_FAIL for a faulty step within the process. + * @retval UNTAR_INVALID_CHECKSUM for an invalid header checksum. + * @retval UNTAR_INVALID_HEADER for an invalid header. + */ + +int Untar_FromChunk_Print( + Untar_ChunkContext *context, + void *chunk, + size_t chunk_size, + const rtems_printer* printer +); + +/** + * @brief Initializes the Untar_ChunkGzContext. + * + * @param Untar_ChunkGzContext *context [in] Pointer to a context structure. + * @param void *inflateBuffer [in] Pointer to a context structure. + * @param size_t inflateBufferSize [in] Size of inflateBuffer. + */ +int Untar_GzChunkContext_Init( + Untar_GzChunkContext *ctx, + void *inflateBuffer, + size_t inflateBufferSize +); + +/* + * @brief Untars a GZ compressed POSIX TAR file. + * + * This is a subroutine used to rip links, directories, and + * files out of a tar.gz/tgz file. + * + * @param Untar_ChunkContext *context [in] Pointer to a context structure. + * @param ssize buflen [in] Size of valid bytes in input buffer. + * @param z_stream *strm [in] Pointer to the current zlib context. + */ +int Untar_FromGzChunk_Print( + Untar_GzChunkContext *ctx, + void *chunk, + size_t chunk_size, + const rtems_printer* printer +); + +/** + * @brief Initializes the Untar_ChunkXzContext. + * + * @param Untar_ChunkXzContext *context [in] Pointer to a context structure. + * @param enum xz_mode mode [in] Dictionary mode. + * @param uint32_t dict_max [in] Maximum size of dictionary. + * @param void *inflateBuffer [in] Pointer to a context structure. + * @param size_t inflateBufferSize [in] Size of inflateBuffer. + */ +int Untar_XzChunkContext_Init( + Untar_XzChunkContext *ctx, + enum xz_mode mode, + uint32_t dict_max, + void *inflateBuffer, + size_t inflateBufferSize +); + +/* + * @brief Untars a XZ compressed POSIX TAR file. + * + * This is a subroutine used to rip links, directories, and + * files out of a tar.gz/tgz file. + * + * @param Untar_ChunkContext *context [in] Pointer to a context structure. + * @param ssize buflen [in] Size of valid bytes in input buffer. + * @param z_stream *strm [in] Pointer to the current zlib context. + */ +int Untar_FromXzChunk_Print( + Untar_XzChunkContext *ctx, + const void *chunk, + size_t chunk_size, + const rtems_printer* printer +); + +/************************************************************************** + * This converts octal ASCII number representations into an + * unsigned long. Only support 32-bit numbers for now. + *************************************************************************/ +extern unsigned long +_rtems_octal2ulong(const char *octascii, size_t len); + +/************************************************************************ + * Compute the TAR checksum and check with the value in + * the archive. The checksum is computed over the entire + * header, but the checksum field is substituted with blanks. + ************************************************************************/ +extern int +_rtems_tar_header_checksum(const char *bufr); + +#ifdef __cplusplus +} +#endif +/**@}*/ +#endif /* _RTEMS_UNTAR_H */ diff --git a/cpukit/include/rtems/version.h b/cpukit/include/rtems/version.h new file mode 100644 index 0000000000..b806cb8c2f --- /dev/null +++ b/cpukit/include/rtems/version.h @@ -0,0 +1,77 @@ +/** + * @file + * + * @brief Version API. + */ + +/* + * Copyright (C) 2017. + * Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_VERSION_H +#define _RTEMS_VERSION_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup ClassicVersion Version + * + * @ingroup ClassicVersion + * + * @brief The Version API provides functions to return the version or parts of + * the version of RTEMS you are using. + */ +/**@{**/ + +/** + * @brief Returns the version string. + * + * @retval text The version as a string. + */ +const char *rtems_version( void ); + +/** + * @brief Returns the version's major number. + * + * @retval int The version's major number. + */ +int rtems_version_major( void ); + +/** + * @brief Returns the version's minor number. + * + * @retval int The version's minor number. + */ +int rtems_version_minor( void ); + +/** + * @brief Returns the version's revision number. + * + * @retval int The version's revision number. + */ +int rtems_version_revision( void ); + +/** + * @brief Returns the version control key for the current version of code that + * has been built. The key is specific to the version control system being used + * and allows the built version to be identified. + * + * @retval int The version's version control key. + */ +const char *rtems_version_control_key( void ); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/rtems/vmeintr.h b/cpukit/include/rtems/vmeintr.h new file mode 100644 index 0000000000..74bda9bf08 --- /dev/null +++ b/cpukit/include/rtems/vmeintr.h @@ -0,0 +1,59 @@ +/** + * @file + * + * @brief VMEbus Interface Library + * + * This file is the specification for the VMEbus interface library + * which should be provided by all BSPs for VMEbus Single Board + * Computers but currently only a few do so. + */ + +/* + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_VMEINTR_H +#define _RTEMS_VMEINTR_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This defines the mask which is used to determine which + * interrupt levels are affected by a call to this package. + * The LSB corresponds to VME interrupt 0 and the MSB + * to VME interrupt 7. + * + */ + +typedef uint8_t VME_interrupt_Mask; + +/* + * VME_interrupt_Disable + * + */ + +void VME_interrupt_Disable ( + VME_interrupt_Mask mask /* IN */ +); + +/* + * VME_interrupt_Disable + * + */ + +void VME_interrupt_Enable ( + VME_interrupt_Mask mask /* IN */ +); + +#ifdef __cplusplus +} +#endif + +#endif /* end of include file */ diff --git a/cpukit/include/sha256.h b/cpukit/include/sha256.h new file mode 100644 index 0000000000..1b6a4f4c57 --- /dev/null +++ b/cpukit/include/sha256.h @@ -0,0 +1,50 @@ +/*- + * Copyright 2005 Colin Percival + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _SHA256_H_ +#define _SHA256_H_ + +#include + +typedef struct SHA256Context { + uint32_t state[8]; + uint64_t count; + unsigned char buf[64]; +} SHA256_CTX; + +__BEGIN_DECLS +void SHA256_Init(SHA256_CTX *); +void SHA256_Update(SHA256_CTX *, const void *, size_t); +void SHA256_Final(unsigned char [32], SHA256_CTX *); +char *SHA256_End(SHA256_CTX *, char *); +char *SHA256_File(const char *, char *); +char *SHA256_FileChunk(const char *, char *, off_t, off_t); +char *SHA256_Data(const void *, unsigned int, char *); +__END_DECLS + +#endif /* !_SHA256_H_ */ diff --git a/cpukit/include/sha512.h b/cpukit/include/sha512.h new file mode 100644 index 0000000000..8998f4c5bf --- /dev/null +++ b/cpukit/include/sha512.h @@ -0,0 +1,50 @@ +/*- + * Copyright 2005 Colin Percival + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _SHA512_H_ +#define _SHA512_H_ + +#include + +typedef struct SHA512Context { + uint64_t state[8]; + uint64_t count[2]; + unsigned char buf[128]; +} SHA512_CTX; + +__BEGIN_DECLS +void SHA512_Init(SHA512_CTX *); +void SHA512_Update(SHA512_CTX *, const void *, size_t); +void SHA512_Final(unsigned char [64], SHA512_CTX *); +char *SHA512_End(SHA512_CTX *, char *); +char *SHA512_File(const char *, char *); +char *SHA512_FileChunk(const char *, char *, off_t, off_t); +char *SHA512_Data(const void *, unsigned int, char *); +__END_DECLS + +#endif /* !_SHA512_H_ */ diff --git a/cpukit/include/sys/_ffcounter.h b/cpukit/include/sys/_ffcounter.h new file mode 100644 index 0000000000..d83c48cd44 --- /dev/null +++ b/cpukit/include/sys/_ffcounter.h @@ -0,0 +1,42 @@ +/*- + * Copyright (c) 2011 The University of Melbourne + * All rights reserved. + * + * This software was developed by Julien Ridoux at the University of Melbourne + * under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD r277406 2015-01-20T03:54:30Z$ + */ + +#ifndef _SYS__FFCOUNTER_H_ +#define _SYS__FFCOUNTER_H_ + +/* + * The feed-forward clock counter. The fundamental element of a feed-forward + * clock is a wide monotonically increasing counter that accumulates at the same + * rate as the selected timecounter. + */ +typedef uint64_t ffcounter; + +#endif /* _SYS__FFCOUNTER_H_ */ diff --git a/cpukit/include/sys/cdefs_elf.h b/cpukit/include/sys/cdefs_elf.h new file mode 100644 index 0000000000..91903d6017 --- /dev/null +++ b/cpukit/include/sys/cdefs_elf.h @@ -0,0 +1,152 @@ +/* $NetBSD: cdefs_elf.h,v 1.24 2005/07/16 17:53:36 christos Exp $ */ + +/* + * Copyright (c) 1995, 1996 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Chris G. Demetriou + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +#ifndef _SYS_CDEFS_ELF_H_ +#define _SYS_CDEFS_ELF_H_ + +#ifdef __LEADING_UNDERSCORE +#define _C_LABEL(x) __CONCAT(_,x) +#define _C_LABEL_STRING(x) "_"x +#else +#define _C_LABEL(x) x +#define _C_LABEL_STRING(x) x +#endif + +#if __STDC__ +#define ___RENAME(x) __asm__(___STRING(_C_LABEL(x))) +#else +#ifdef __LEADING_UNDERSCORE +#define ___RENAME(x) ____RENAME(_/**/x) +#define ____RENAME(x) __asm__(___STRING(x)) +#else +#define ___RENAME(x) __asm__(___STRING(x)) +#endif +#endif + +#define __indr_reference(sym,alias) /* nada, since we do weak refs */ + +#if __STDC__ +#define __strong_alias(alias,sym) \ + __asm__(".global " _C_LABEL_STRING(#alias) "\n" \ + _C_LABEL_STRING(#alias) " = " _C_LABEL_STRING(#sym)); + +#define __weak_alias(alias,sym) \ + __asm__(".weak " _C_LABEL_STRING(#alias) "\n" \ + _C_LABEL_STRING(#alias) " = " _C_LABEL_STRING(#sym)); +#define __weak_extern(sym) \ + __asm__(".weak " _C_LABEL_STRING(#sym)); +#define __warn_references(sym,msg) \ + __asm__(".section .gnu.warning." #sym "\n\t.ascii \"" msg "\"\n\t.text"); + +#else /* !__STDC__ */ + +#ifdef __LEADING_UNDERSCORE +#define __weak_alias(alias,sym) ___weak_alias(_/**/alias,_/**/sym) +#define ___weak_alias(alias,sym) \ + __asm__(".weak alias\nalias = sym"); +#else +#define __weak_alias(alias,sym) \ + __asm__(".weak alias\nalias = sym"); +#endif +#ifdef __LEADING_UNDERSCORE +#define __weak_extern(sym) ___weak_extern(_/**/sym) +#define ___weak_extern(sym) \ + __asm__(".weak sym"); +#else +#define __weak_extern(sym) \ + __asm__(".weak sym"); +#endif +#define __warn_references(sym,msg) \ + __asm__(".section .gnu.warning.sym\n\t.ascii msg ; .text"); + +#endif /* !__STDC__ */ + +#if __STDC__ +#define __SECTIONSTRING(_sec, _str) \ + __asm__(".section " #_sec "\n\t.asciz \"" _str "\"\n\t.previous") +#else +#define __SECTIONSTRING(_sec, _str) \ + __asm__(".section _sec\n\t.asciz _str\n\t.previous") +#endif + +#define __IDSTRING(_n,_s) __SECTIONSTRING(.ident,_s) + +#define __RCSID(_s) __IDSTRING(rcsid,_s) +#define __SCCSID(_s) +#define __SCCSID2(_s) +#if 0 /* XXX userland __COPYRIGHTs have \ns in them */ +#define __COPYRIGHT(_s) __SECTIONSTRING(.copyright,_s) +#else +#define __COPYRIGHT(_s) \ + static const char copyright[] \ + __attribute__((__unused__,__section__(".copyright"))) = _s +#endif + +#define __KERNEL_RCSID(_n, _s) __RCSID(_s) +#define __KERNEL_SCCSID(_n, _s) +#if 0 /* XXX see above */ +#define __KERNEL_COPYRIGHT(_n, _s) __COPYRIGHT(_s) +#else +#define __KERNEL_COPYRIGHT(_n, _s) __SECTIONSTRING(.copyright, _s) +#endif + +#ifndef __lint__ +#define __link_set_make_entry(set, sym) \ + static void const * const __link_set_##set##_sym_##sym \ + __section("link_set_" #set) __used = &sym +#define __link_set_make_entry2(set, sym, n) \ + static void const * const __link_set_##set##_sym_##sym##_##n \ + __section("link_set_" #set) __used = &sym[n] +#else +#define __link_set_make_entry(set, sym) \ + extern void const * const __link_set_##set##_sym_##sym +#define __link_set_make_entry2(set, sym, n) \ + extern void const * const __link_set_##set##_sym_##sym##_##n +#endif /* __lint__ */ + +#define __link_set_add_text(set, sym) __link_set_make_entry(set, sym) +#define __link_set_add_rodata(set, sym) __link_set_make_entry(set, sym) +#define __link_set_add_data(set, sym) __link_set_make_entry(set, sym) +#define __link_set_add_bss(set, sym) __link_set_make_entry(set, sym) +#define __link_set_add_text2(set, sym, n) __link_set_make_entry2(set, sym, n) +#define __link_set_add_rodata2(set, sym, n) __link_set_make_entry2(set, sym, n) +#define __link_set_add_data2(set, sym, n) __link_set_make_entry2(set, sym, n) +#define __link_set_add_bss2(set, sym, n) __link_set_make_entry2(set, sym, n) + +#define __link_set_decl(set, ptype) \ + extern ptype * const __start_link_set_##set[]; \ + extern ptype * const __stop_link_set_##set[] \ + +#define __link_set_start(set) (__start_link_set_##set) +#define __link_set_end(set) (__stop_link_set_##set) + +#define __link_set_count(set) \ + (__link_set_end(set) - __link_set_start(set)) + +#endif /* !_SYS_CDEFS_ELF_H_ */ diff --git a/cpukit/include/sys/event.h b/cpukit/include/sys/event.h new file mode 100644 index 0000000000..bc18aa90ea --- /dev/null +++ b/cpukit/include/sys/event.h @@ -0,0 +1,303 @@ +/*- + * Copyright (c) 1999,2000,2001 Jonathan Lemon + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: head/sys/sys/event.h 313704 2017-02-13 19:00:09Z ed $ + */ + +#ifndef _SYS_EVENT_H_ +#define _SYS_EVENT_H_ + +#include +#include + +#define EVFILT_READ (-1) +#define EVFILT_WRITE (-2) +#define EVFILT_AIO (-3) /* attached to aio requests */ +#define EVFILT_VNODE (-4) /* attached to vnodes */ +#define EVFILT_PROC (-5) /* attached to struct proc */ +#define EVFILT_SIGNAL (-6) /* attached to struct proc */ +#define EVFILT_TIMER (-7) /* timers */ +#define EVFILT_PROCDESC (-8) /* attached to process descriptors */ +#define EVFILT_FS (-9) /* filesystem events */ +#define EVFILT_LIO (-10) /* attached to lio requests */ +#define EVFILT_USER (-11) /* User events */ +#define EVFILT_SENDFILE (-12) /* attached to sendfile requests */ +#define EVFILT_EMPTY (-13) /* empty send socket buf */ +#define EVFILT_SYSCOUNT 13 + +#define EV_SET(kevp_, a, b, c, d, e, f) do { \ + struct kevent *kevp = (kevp_); \ + (kevp)->ident = (a); \ + (kevp)->filter = (b); \ + (kevp)->flags = (c); \ + (kevp)->fflags = (d); \ + (kevp)->data = (e); \ + (kevp)->udata = (f); \ +} while(0) + +struct kevent { + __uintptr_t ident; /* identifier for this event */ + short filter; /* filter for event */ + unsigned short flags; + unsigned int fflags; + __intptr_t data; + void *udata; /* opaque user data identifier */ +}; + +/* actions */ +#define EV_ADD 0x0001 /* add event to kq (implies enable) */ +#define EV_DELETE 0x0002 /* delete event from kq */ +#define EV_ENABLE 0x0004 /* enable event */ +#define EV_DISABLE 0x0008 /* disable event (not reported) */ +#define EV_FORCEONESHOT 0x0100 /* enable _ONESHOT and force trigger */ + +/* flags */ +#define EV_ONESHOT 0x0010 /* only report one occurrence */ +#define EV_CLEAR 0x0020 /* clear event state after reporting */ +#define EV_RECEIPT 0x0040 /* force EV_ERROR on success, data=0 */ +#define EV_DISPATCH 0x0080 /* disable event after reporting */ + +#define EV_SYSFLAGS 0xF000 /* reserved by system */ +#define EV_DROP 0x1000 /* note should be dropped */ +#define EV_FLAG1 0x2000 /* filter-specific flag */ +#define EV_FLAG2 0x4000 /* filter-specific flag */ + +/* returned values */ +#define EV_EOF 0x8000 /* EOF detected */ +#define EV_ERROR 0x4000 /* error, data contains errno */ + + /* + * data/hint flags/masks for EVFILT_USER, shared with userspace + * + * On input, the top two bits of fflags specifies how the lower twenty four + * bits should be applied to the stored value of fflags. + * + * On output, the top two bits will always be set to NOTE_FFNOP and the + * remaining twenty four bits will contain the stored fflags value. + */ +#define NOTE_FFNOP 0x00000000 /* ignore input fflags */ +#define NOTE_FFAND 0x40000000 /* AND fflags */ +#define NOTE_FFOR 0x80000000 /* OR fflags */ +#define NOTE_FFCOPY 0xc0000000 /* copy fflags */ +#define NOTE_FFCTRLMASK 0xc0000000 /* masks for operations */ +#define NOTE_FFLAGSMASK 0x00ffffff + +#define NOTE_TRIGGER 0x01000000 /* Cause the event to be + triggered for output. */ + +/* + * data/hint flags for EVFILT_{READ|WRITE}, shared with userspace + */ +#define NOTE_LOWAT 0x0001 /* low water mark */ +#define NOTE_FILE_POLL 0x0002 /* behave like poll() */ + +/* + * data/hint flags for EVFILT_VNODE, shared with userspace + */ +#define NOTE_DELETE 0x0001 /* vnode was removed */ +#define NOTE_WRITE 0x0002 /* data contents changed */ +#define NOTE_EXTEND 0x0004 /* size increased */ +#define NOTE_ATTRIB 0x0008 /* attributes changed */ +#define NOTE_LINK 0x0010 /* link count changed */ +#define NOTE_RENAME 0x0020 /* vnode was renamed */ +#define NOTE_REVOKE 0x0040 /* vnode access was revoked */ +#define NOTE_OPEN 0x0080 /* vnode was opened */ +#define NOTE_CLOSE 0x0100 /* file closed, fd did not + allowed write */ +#define NOTE_CLOSE_WRITE 0x0200 /* file closed, fd did allowed + write */ +#define NOTE_READ 0x0400 /* file was read */ + +/* + * data/hint flags for EVFILT_PROC and EVFILT_PROCDESC, shared with userspace + */ +#define NOTE_EXIT 0x80000000 /* process exited */ +#define NOTE_FORK 0x40000000 /* process forked */ +#define NOTE_EXEC 0x20000000 /* process exec'd */ +#define NOTE_PCTRLMASK 0xf0000000 /* mask for hint bits */ +#define NOTE_PDATAMASK 0x000fffff /* mask for pid */ + +/* additional flags for EVFILT_PROC */ +#define NOTE_TRACK 0x00000001 /* follow across forks */ +#define NOTE_TRACKERR 0x00000002 /* could not track child */ +#define NOTE_CHILD 0x00000004 /* am a child process */ + +/* additional flags for EVFILT_TIMER */ +#define NOTE_SECONDS 0x00000001 /* data is seconds */ +#define NOTE_MSECONDS 0x00000002 /* data is milliseconds */ +#define NOTE_USECONDS 0x00000004 /* data is microseconds */ +#define NOTE_NSECONDS 0x00000008 /* data is nanoseconds */ + +struct knote; +SLIST_HEAD(klist, knote); +struct kqueue; +TAILQ_HEAD(kqlist, kqueue); +struct knlist { + struct klist kl_list; + void (*kl_lock)(void *); /* lock function */ + void (*kl_unlock)(void *); + void (*kl_assert_locked)(void *); + void (*kl_assert_unlocked)(void *); + void *kl_lockarg; /* argument passed to lock functions */ + int kl_autodestroy; +}; + + +#ifdef _KERNEL + +/* + * Flags for knote call + */ +#define KNF_LISTLOCKED 0x0001 /* knlist is locked */ +#define KNF_NOKQLOCK 0x0002 /* do not keep KQ_LOCK */ + +#define KNOTE(list, hist, flags) knote(list, hist, flags) +#define KNOTE_LOCKED(list, hint) knote(list, hint, KNF_LISTLOCKED) +#define KNOTE_UNLOCKED(list, hint) knote(list, hint, 0) + +#define KNLIST_EMPTY(list) SLIST_EMPTY(&(list)->kl_list) + +/* + * Flag indicating hint is a signal. Used by EVFILT_SIGNAL, and also + * shared by EVFILT_PROC (all knotes attached to p->p_klist) + */ +#define NOTE_SIGNAL 0x08000000 + +/* + * Hint values for the optional f_touch event filter. If f_touch is not set + * to NULL and f_isfd is zero the f_touch filter will be called with the type + * argument set to EVENT_REGISTER during a kevent() system call. It is also + * called under the same conditions with the type argument set to EVENT_PROCESS + * when the event has been triggered. + */ +#define EVENT_REGISTER 1 +#define EVENT_PROCESS 2 + +struct filterops { + int f_isfd; /* true if ident == filedescriptor */ + int (*f_attach)(struct knote *kn); + void (*f_detach)(struct knote *kn); + int (*f_event)(struct knote *kn, long hint); + void (*f_touch)(struct knote *kn, struct kevent *kev, u_long type); +}; + +/* + * An in-flux knote cannot be dropped from its kq while the kq is + * unlocked. If the KN_SCAN flag is not set, a thread can only set + * kn_influx when it is exclusive owner of the knote state, and can + * modify kn_status as if it had the KQ lock. KN_SCAN must not be set + * on a knote which is already in flux. + * + * kn_sfflags, kn_sdata, and kn_kevent are protected by the knlist lock. + */ +struct knote { + SLIST_ENTRY(knote) kn_link; /* for kq */ + SLIST_ENTRY(knote) kn_selnext; /* for struct selinfo */ + struct knlist *kn_knlist; /* f_attach populated */ + TAILQ_ENTRY(knote) kn_tqe; + struct kqueue *kn_kq; /* which queue we are on */ + struct kevent kn_kevent; + void *kn_hook; + int kn_hookid; + int kn_status; /* protected by kq lock */ +#define KN_ACTIVE 0x01 /* event has been triggered */ +#define KN_QUEUED 0x02 /* event is on queue */ +#define KN_DISABLED 0x04 /* event is disabled */ +#define KN_DETACHED 0x08 /* knote is detached */ +#define KN_MARKER 0x20 /* ignore this knote */ +#define KN_KQUEUE 0x40 /* this knote belongs to a kq */ +#define KN_HASKQLOCK 0x80 /* for _inevent */ +#define KN_SCAN 0x100 /* flux set in kqueue_scan() */ + int kn_influx; + int kn_sfflags; /* saved filter flags */ + intptr_t kn_sdata; /* saved data field */ + union { + struct file *p_fp; /* file data pointer */ + struct proc *p_proc; /* proc pointer */ + struct kaiocb *p_aio; /* AIO job pointer */ + struct aioliojob *p_lio; /* LIO job pointer */ + void *p_v; /* generic other pointer */ + } kn_ptr; + struct filterops *kn_fop; + +#define kn_id kn_kevent.ident +#define kn_filter kn_kevent.filter +#define kn_flags kn_kevent.flags +#define kn_fflags kn_kevent.fflags +#define kn_data kn_kevent.data +#define kn_fp kn_ptr.p_fp +}; +struct kevent_copyops { + void *arg; + int (*k_copyout)(void *arg, struct kevent *kevp, int count); + int (*k_copyin)(void *arg, struct kevent *kevp, int count); +}; + +struct thread; +struct proc; +struct knlist; +struct mtx; +struct rwlock; + +void knote(struct knlist *list, long hint, int lockflags); +void knote_fork(struct knlist *list, int pid); +struct knlist *knlist_alloc(struct mtx *lock); +void knlist_detach(struct knlist *knl); +void knlist_add(struct knlist *knl, struct knote *kn, int islocked); +void knlist_remove(struct knlist *knl, struct knote *kn, int islocked); +int knlist_empty(struct knlist *knl); +void knlist_init(struct knlist *knl, void *lock, void (*kl_lock)(void *), + void (*kl_unlock)(void *), void (*kl_assert_locked)(void *), + void (*kl_assert_unlocked)(void *)); +void knlist_init_mtx(struct knlist *knl, struct mtx *lock); +void knlist_init_rw_reader(struct knlist *knl, struct rwlock *lock); +void knlist_destroy(struct knlist *knl); +void knlist_cleardel(struct knlist *knl, struct thread *td, + int islocked, int killkn); +#define knlist_clear(knl, islocked) \ + knlist_cleardel((knl), NULL, (islocked), 0) +#define knlist_delete(knl, td, islocked) \ + knlist_cleardel((knl), (td), (islocked), 1) +void knote_fdclose(struct thread *p, int fd); +int kqfd_register(int fd, struct kevent *kev, struct thread *p, + int waitok); +int kqueue_add_filteropts(int filt, struct filterops *filtops); +int kqueue_del_filteropts(int filt); + +#else /* !_KERNEL */ + +#include +struct timespec; + +__BEGIN_DECLS +int kqueue(void); +int kevent(int kq, const struct kevent *changelist, int nchanges, + struct kevent *eventlist, int nevents, + const struct timespec *timeout); +__END_DECLS + +#endif /* !_KERNEL */ + +#endif /* !_SYS_EVENT_H_ */ diff --git a/cpukit/include/sys/exec_elf.h b/cpukit/include/sys/exec_elf.h new file mode 100644 index 0000000000..4242415f54 --- /dev/null +++ b/cpukit/include/sys/exec_elf.h @@ -0,0 +1,1101 @@ +/* $NetBSD: exec_elf.h,v 1.102 2010/03/01 11:27:29 skrll Exp $ */ + +/*- + * Copyright (c) 1994 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SYS_EXEC_ELF_H_ +#define _SYS_EXEC_ELF_H_ + +/* + * The current ELF ABI specification is available at: + * http://www.sco.com/developers/gabi/ + * + * Current header definitions are in: + * http://www.sco.com/developers/gabi/latest/ch4.eheader.html + */ + +#if defined(_KERNEL) || defined(_STANDALONE) +#include +#else +#include +#endif /* _KERNEL || _STANDALONE */ + +#if defined(ELFSIZE) +#define CONCAT(x,y) __CONCAT(x,y) +#define ELFNAME(x) CONCAT(elf,CONCAT(ELFSIZE,CONCAT(_,x))) +#define ELFNAME2(x,y) CONCAT(x,CONCAT(_elf,CONCAT(ELFSIZE,CONCAT(_,y)))) +#define ELFNAMEEND(x) CONCAT(x,CONCAT(_elf,ELFSIZE)) +#define ELFDEFNNAME(x) CONCAT(ELF,CONCAT(ELFSIZE,CONCAT(_,x))) +#endif + +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif + +typedef uint8_t Elf_Byte; + +typedef uint32_t Elf32_Addr; +#define ELF32_FSZ_ADDR 4 +typedef uint32_t Elf32_Off; +typedef int32_t Elf32_SOff; +#define ELF32_FSZ_OFF 4 +typedef int32_t Elf32_Sword; +#define ELF32_FSZ_SWORD 4 +typedef uint32_t Elf32_Word; +#define ELF32_FSZ_WORD 4 +typedef uint16_t Elf32_Half; +#define ELF32_FSZ_HALF 2 +typedef uint64_t Elf32_Lword; +#define ELF32_FSZ_LWORD 8 + +typedef uint64_t Elf64_Addr; +#define ELF64_FSZ_ADDR 8 +typedef uint64_t Elf64_Off; +typedef int64_t Elf64_SOff; +#define ELF64_FSZ_OFF 8 +typedef int32_t Elf64_Shalf; +#define ELF64_FSZ_SHALF 4 + +#ifndef ELF64_FSZ_SWORD +typedef int32_t Elf64_Sword; +#define ELF64_FSZ_SWORD 4 +#endif /* ELF64_FSZ_SWORD */ +#ifndef ELF64_FSZ_WORD +typedef uint32_t Elf64_Word; +#define ELF64_FSZ_WORD 4 +#endif /* ELF64_FSZ_WORD */ + +typedef int64_t Elf64_Sxword; +#define ELF64_FSZ_SXWORD 8 +typedef uint64_t Elf64_Xword; +#define ELF64_FSZ_XWORD 8 +typedef uint64_t Elf64_Lword; +#define ELF64_FSZ_LWORD 8 +typedef uint32_t Elf64_Half; +#define ELF64_FSZ_HALF 4 +typedef uint16_t Elf64_Quarter; +#define ELF64_FSZ_QUARTER 2 + +/* + * ELF Header + */ +#define ELF_NIDENT 16 + +typedef struct { + unsigned char e_ident[ELF_NIDENT]; /* Id bytes */ + Elf32_Half e_type; /* file type */ + Elf32_Half e_machine; /* machine type */ + Elf32_Word e_version; /* version number */ + Elf32_Addr e_entry; /* entry point */ + Elf32_Off e_phoff; /* Program hdr offset */ + Elf32_Off e_shoff; /* Section hdr offset */ + Elf32_Word e_flags; /* Processor flags */ + Elf32_Half e_ehsize; /* sizeof ehdr */ + Elf32_Half e_phentsize; /* Program header entry size */ + Elf32_Half e_phnum; /* Number of program headers */ + Elf32_Half e_shentsize; /* Section header entry size */ + Elf32_Half e_shnum; /* Number of section headers */ + Elf32_Half e_shstrndx; /* String table index */ +} Elf32_Ehdr; + +typedef struct { + unsigned char e_ident[ELF_NIDENT]; /* Id bytes */ + Elf64_Quarter e_type; /* file type */ + Elf64_Quarter e_machine; /* machine type */ + Elf64_Half e_version; /* version number */ + Elf64_Addr e_entry; /* entry point */ + Elf64_Off e_phoff; /* Program hdr offset */ + Elf64_Off e_shoff; /* Section hdr offset */ + Elf64_Half e_flags; /* Processor flags */ + Elf64_Quarter e_ehsize; /* sizeof ehdr */ + Elf64_Quarter e_phentsize; /* Program header entry size */ + Elf64_Quarter e_phnum; /* Number of program headers */ + Elf64_Quarter e_shentsize; /* Section header entry size */ + Elf64_Quarter e_shnum; /* Number of section headers */ + Elf64_Quarter e_shstrndx; /* String table index */ +} Elf64_Ehdr; + +/* e_ident offsets */ +#define EI_MAG0 0 /* '\177' */ +#define EI_MAG1 1 /* 'E' */ +#define EI_MAG2 2 /* 'L' */ +#define EI_MAG3 3 /* 'F' */ +#define EI_CLASS 4 /* File class */ +#define EI_DATA 5 /* Data encoding */ +#define EI_VERSION 6 /* File version */ +#define EI_OSABI 7 /* Operating system/ABI identification */ +#define EI_ABIVERSION 8 /* ABI version */ +#define EI_PAD 9 /* Start of padding bytes up to EI_NIDENT*/ +#define EI_NIDENT 16 /* First non-ident header byte */ + +/* e_ident[EI_MAG0,EI_MAG3] */ +#define ELFMAG0 0x7f +#define ELFMAG1 'E' +#define ELFMAG2 'L' +#define ELFMAG3 'F' +#define ELFMAG "\177ELF" +#define SELFMAG 4 + +/* e_ident[EI_CLASS] */ +#define ELFCLASSNONE 0 /* Invalid class */ +#define ELFCLASS32 1 /* 32-bit objects */ +#define ELFCLASS64 2 /* 64-bit objects */ +#define ELFCLASSNUM 3 + +/* e_ident[EI_DATA] */ +#define ELFDATANONE 0 /* Invalid data encoding */ +#define ELFDATA2LSB 1 /* 2's complement values, LSB first */ +#define ELFDATA2MSB 2 /* 2's complement values, MSB first */ + +/* e_ident[EI_VERSION] */ +#define EV_NONE 0 /* Invalid version */ +#define EV_CURRENT 1 /* Current version */ +#define EV_NUM 2 + +/* e_ident[EI_OSABI] */ +#define ELFOSABI_SYSV 0 /* UNIX System V ABI */ +#define ELFOSABI_HPUX 1 /* HP-UX operating system */ +#define ELFOSABI_NETBSD 2 /* NetBSD */ +#define ELFOSABI_LINUX 3 /* GNU/Linux */ +#define ELFOSABI_HURD 4 /* GNU/Hurd */ +#define ELFOSABI_86OPEN 5 /* 86Open */ +#define ELFOSABI_SOLARIS 6 /* Solaris */ +#define ELFOSABI_MONTEREY 7 /* Monterey */ +#define ELFOSABI_IRIX 8 /* IRIX */ +#define ELFOSABI_FREEBSD 9 /* FreeBSD */ +#define ELFOSABI_TRU64 10 /* TRU64 UNIX */ +#define ELFOSABI_MODESTO 11 /* Novell Modesto */ +#define ELFOSABI_OPENBSD 12 /* OpenBSD */ +#define ELFOSABI_OPENVMS 13 /* OpenVMS */ +#define ELFOSABI_NSK 14 /* HP Non-Stop Kernel */ +#define ELFOSABI_AROS 15 /* Amiga Research OS */ +/* Unofficial OSABIs follow */ +#define ELFOSABI_ARM 97 /* ARM */ +#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ + +#define ELFOSABI_NONE ELFOSABI_SYSV +#define ELFOSABI_AIX ELFOSABI_MONTEREY + +/* e_type */ +#define ET_NONE 0 /* No file type */ +#define ET_REL 1 /* Relocatable file */ +#define ET_EXEC 2 /* Executable file */ +#define ET_DYN 3 /* Shared object file */ +#define ET_CORE 4 /* Core file */ +#define ET_NUM 5 + +#define ET_LOOS 0xfe00 /* Operating system specific range */ +#define ET_HIOS 0xfeff +#define ET_LOPROC 0xff00 /* Processor-specific range */ +#define ET_HIPROC 0xffff + +/* e_machine */ +#define EM_NONE 0 /* No machine */ +#define EM_M32 1 /* AT&T WE 32100 */ +#define EM_SPARC 2 /* SPARC */ +#define EM_386 3 /* Intel 80386 */ +#define EM_68K 4 /* Motorola 68000 */ +#define EM_88K 5 /* Motorola 88000 */ +#define EM_486 6 /* Intel 80486 */ +#define EM_860 7 /* Intel 80860 */ +#define EM_MIPS 8 /* MIPS I Architecture */ +#define EM_S370 9 /* Amdahl UTS on System/370 */ +#define EM_MIPS_RS3_LE 10 /* MIPS RS3000 Little-endian */ + /* 11-14 - Reserved */ +#define EM_RS6000 11 /* IBM RS/6000 XXX reserved */ +#define EM_PARISC 15 /* Hewlett-Packard PA-RISC */ +#define EM_NCUBE 16 /* NCube XXX reserved */ +#define EM_VPP500 17 /* Fujitsu VPP500 */ +#define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */ +#define EM_960 19 /* Intel 80960 */ +#define EM_PPC 20 /* PowerPC */ +#define EM_PPC64 21 /* 64-bit PowerPC */ + /* 22-35 - Reserved */ +#define EM_S390 22 /* System/390 XXX reserved */ +#define EM_V800 36 /* NEC V800 */ +#define EM_FR20 37 /* Fujitsu FR20 */ +#define EM_RH32 38 /* TRW RH-32 */ +#define EM_RCE 39 /* Motorola RCE */ +#define EM_ARM 40 /* Advanced RISC Machines ARM */ +#define EM_ALPHA 41 /* DIGITAL Alpha */ +#define EM_SH 42 /* Hitachi Super-H */ +#define EM_SPARCV9 43 /* SPARC Version 9 */ +#define EM_TRICORE 44 /* Siemens Tricore */ +#define EM_ARC 45 /* Argonaut RISC Core */ +#define EM_H8_300 46 /* Hitachi H8/300 */ +#define EM_H8_300H 47 /* Hitachi H8/300H */ +#define EM_H8S 48 /* Hitachi H8S */ +#define EM_H8_500 49 /* Hitachi H8/500 */ +#define EM_IA_64 50 /* Intel Merced Processor */ +#define EM_MIPS_X 51 /* Stanford MIPS-X */ +#define EM_COLDFIRE 52 /* Motorola Coldfire */ +#define EM_68HC12 53 /* Motorola MC68HC12 */ +#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator */ +#define EM_PCP 55 /* Siemens PCP */ +#define EM_NCPU 56 /* Sony nCPU embedded RISC processor */ +#define EM_NDR1 57 /* Denso NDR1 microprocessor */ +#define EM_STARCORE 58 /* Motorola Star*Core processor */ +#define EM_ME16 59 /* Toyota ME16 processor */ +#define EM_ST100 60 /* STMicroelectronics ST100 processor */ +#define EM_TINYJ 61 /* Advanced Logic Corp. TinyJ embedded family processor */ +#define EM_X86_64 62 /* AMD x86-64 architecture */ +#define EM_PDSP 63 /* Sony DSP Processor */ +#define EM_PDP10 64 /* Digital Equipment Corp. PDP-10 */ +#define EM_PDP11 65 /* Digital Equipment Corp. PDP-11 */ +#define EM_FX66 66 /* Siemens FX66 microcontroller */ +#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 bit microcontroller */ +#define EM_ST7 68 /* STMicroelectronics ST7 8-bit microcontroller */ +#define EM_68HC16 69 /* Motorola MC68HC16 Microcontroller */ +#define EM_68HC11 70 /* Motorola MC68HC11 Microcontroller */ +#define EM_68HC08 71 /* Motorola MC68HC08 Microcontroller */ +#define EM_68HC05 72 /* Motorola MC68HC05 Microcontroller */ +#define EM_SVX 73 /* Silicon Graphics SVx */ +#define EM_ST19 74 /* STMicroelectronics ST19 8-bit CPU */ +#define EM_VAX 75 /* Digital VAX */ +#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */ +#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded CPU */ +#define EM_FIREPATH 78 /* Element 14 64-bit DSP processor */ +#define EM_ZSP 79 /* LSI Logic's 16-bit DSP processor */ +#define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */ +#define EM_HUANY 81 /* Harvard's machine-independent format */ +#define EM_PRISM 82 /* SiTera Prism */ +#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */ +#define EM_FR30 84 /* Fujitsu FR30 */ +#define EM_D10V 85 /* Mitsubishi D10V */ +#define EM_D30V 86 /* Mitsubishi D30V */ +#define EM_V850 87 /* NEC v850 */ +#define EM_M32R 88 /* Mitsubishi M32R */ +#define EM_MN10300 89 /* Matsushita MN10300 */ +#define EM_MN10200 90 /* Matsushita MN10200 */ +#define EM_PJ 91 /* picoJava */ +#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */ +#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */ +#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */ +#define EM_VIDEOCORE 95 /* Alphamosaic VideoCore processor */ +#define EM_TMM_GPP 96 /* Thompson Multimedia General Purpose Processor */ +#define EM_NS32K 97 /* National Semiconductor 32000 series */ +#define EM_TPC 98 /* Tenor Network TPC processor */ +#define EM_SNP1K 99 /* Trebia SNP 1000 processor */ +#define EM_ST200 100 /* STMicroelectronics ST200 microcontroller */ +#define EM_IP2K 101 /* Ubicom IP2xxx microcontroller family */ +#define EM_MAX 102 /* MAX processor */ +#define EM_CR 103 /* National Semiconductor CompactRISC micorprocessor */ +#define EM_F2MC16 104 /* Fujitsu F2MC16 */ +#define EM_MSP430 105 /* Texas Instruments MSP430 */ +#define EM_BLACKFIN 106 /* Analog Devices Blackfin DSP */ +#define EM_SE_C33 107 /* Seiko Epson S1C33 family */ +#define EM_SEP 108 /* Sharp embedded microprocessor */ +#define EM_ARCA 109 /* Arca RISC microprocessor */ +#define EM_UNICORE 110 /* UNICORE from PKU-Unity Ltd. and MPRC Peking University */ +#define EM_EXCESS 111 /* eXcess: 16/32/64-bit configurable embedded CPU */ +#define EM_DXP 112 /* Icera Semiconductor Inc. Deep Execution Processor */ +#define EM_ALTERA_NIOS2 113 /* Altera Nios II soft-core processor */ +#define EM_CRX 114 /* National Semiconductor CRX */ +#define EM_XGATE 115 /* Motorola XGATE embedded processor */ +#define EM_C166 116 /* Infineon C16x/XC16x processor */ +#define EM_M16C 117 /* Renesas M16C series microprocessors */ +#define EM_DSPIC30F 118 /* Microchip Technology dsPIC30F Digital Signal Controller */ +#define EM_CE 119 /* Freescale Communication Engine RISC core */ +#define EM_M32C 120 /* Renesas M32C series microprocessors */ + +#define EM_LATTICEMICO32 138 /* RICS processor for Lattice FPGA architecture */ + +#define EM_MICROBLAZE 189 /* Xilinx MicroBlaze 32-bit RISC soft processor core */ + +#define EM_MOXIE 0xFEED + +/* Unofficial machine types follow */ +#define EM_AVR32 6317 /* used by NetBSD/avr32 */ +#define EM_ALPHA_EXP 36902 /* used by NetBSD/alpha; obsolete */ +#define EM_NUM 36903 + +/* + * Program Header + */ +typedef struct { + Elf32_Word p_type; /* entry type */ + Elf32_Off p_offset; /* offset */ + Elf32_Addr p_vaddr; /* virtual address */ + Elf32_Addr p_paddr; /* physical address */ + Elf32_Word p_filesz; /* file size */ + Elf32_Word p_memsz; /* memory size */ + Elf32_Word p_flags; /* flags */ + Elf32_Word p_align; /* memory & file alignment */ +} Elf32_Phdr; + +typedef struct { + Elf64_Half p_type; /* entry type */ + Elf64_Half p_flags; /* flags */ + Elf64_Off p_offset; /* offset */ + Elf64_Addr p_vaddr; /* virtual address */ + Elf64_Addr p_paddr; /* physical address */ + Elf64_Xword p_filesz; /* file size */ + Elf64_Xword p_memsz; /* memory size */ + Elf64_Xword p_align; /* memory & file alignment */ +} Elf64_Phdr; + +/* p_type */ +#define PT_NULL 0 /* Program header table entry unused */ +#define PT_LOAD 1 /* Loadable program segment */ +#define PT_DYNAMIC 2 /* Dynamic linking information */ +#define PT_INTERP 3 /* Program interpreter */ +#define PT_NOTE 4 /* Auxiliary information */ +#define PT_SHLIB 5 /* Reserved, unspecified semantics */ +#define PT_PHDR 6 /* Entry for header table itself */ +#define PT_NUM 7 + +#define PT_LOOS 0x60000000 /* OS-specific range */ +#define PT_HIOS 0x6fffffff +#define PT_LOPROC 0x70000000 /* Processor-specific range */ +#define PT_HIPROC 0x7fffffff + +#define PT_MIPS_REGINFO 0x70000000 + +/* p_flags */ +#define PF_R 0x4 /* Segment is readable */ +#define PF_W 0x2 /* Segment is writable */ +#define PF_X 0x1 /* Segment is executable */ + +#define PF_MASKOS 0x0ff00000 /* Operating system specific values */ +#define PF_MASKPROC 0xf0000000 /* Processor-specific values */ + +/* Extended program header index. */ +#define PN_XNUM 0xffff + +/* + * Section Headers + */ +typedef struct { + Elf32_Word sh_name; /* section name (.shstrtab index) */ + Elf32_Word sh_type; /* section type */ + Elf32_Word sh_flags; /* section flags */ + Elf32_Addr sh_addr; /* virtual address */ + Elf32_Off sh_offset; /* file offset */ + Elf32_Word sh_size; /* section size */ + Elf32_Word sh_link; /* link to another */ + Elf32_Word sh_info; /* misc info */ + Elf32_Word sh_addralign; /* memory alignment */ + Elf32_Word sh_entsize; /* table entry size */ +} Elf32_Shdr; + +typedef struct { + Elf64_Half sh_name; /* section name (.shstrtab index) */ + Elf64_Half sh_type; /* section type */ + Elf64_Xword sh_flags; /* section flags */ + Elf64_Addr sh_addr; /* virtual address */ + Elf64_Off sh_offset; /* file offset */ + Elf64_Xword sh_size; /* section size */ + Elf64_Half sh_link; /* link to another */ + Elf64_Half sh_info; /* misc info */ + Elf64_Xword sh_addralign; /* memory alignment */ + Elf64_Xword sh_entsize; /* table entry size */ +} Elf64_Shdr; + +/* sh_type */ +#define SHT_NULL 0 /* Section header table entry unused */ +#define SHT_PROGBITS 1 /* Program information */ +#define SHT_SYMTAB 2 /* Symbol table */ +#define SHT_STRTAB 3 /* String table */ +#define SHT_RELA 4 /* Relocation information w/ addend */ +#define SHT_HASH 5 /* Symbol hash table */ +#define SHT_DYNAMIC 6 /* Dynamic linking information */ +#define SHT_NOTE 7 /* Auxiliary information */ +#define SHT_NOBITS 8 /* No space allocated in file image */ +#define SHT_REL 9 /* Relocation information w/o addend */ +#define SHT_SHLIB 10 /* Reserved, unspecified semantics */ +#define SHT_DYNSYM 11 /* Symbol table for dynamic linker */ +#define SHT_INIT_ARRAY 14 /* Initialization function pointers */ +#define SHT_FINI_ARRAY 15 /* Termination function pointers */ +#define SHT_PREINIT_ARRAY 16 /* Pre-initialization function ptrs */ +#define SHT_GROUP 17 /* Section group */ +#define SHT_SYMTAB_SHNDX 18 /* Section indexes (see SHN_XINDEX) */ +#define SHT_NUM 19 + +#define SHT_LOOS 0x60000000 /* Operating system specific range */ +#define SHT_SUNW_move 0x6ffffffa +#define SHT_SUNW_syminfo 0x6ffffffc +#define SHT_SUNW_verdef 0x6ffffffd /* Versions defined by file */ +#define SHT_GNU_verdef SHT_SUNW_verdef +#define SHT_SUNW_verneed 0x6ffffffe /* Versions needed by file */ +#define SHT_GNU_verneed SHT_SUNW_verneed +#define SHT_SUNW_versym 0x6fffffff /* Symbol versions */ +#define SHT_GNU_versym SHT_SUNW_versym +#define SHT_HIOS 0x6fffffff +#define SHT_LOPROC 0x70000000 /* Processor-specific range */ +#define SHT_AMD64_UNWIND 0x70000001 /* unwind information */ +#define SHT_HIPROC 0x7fffffff +#define SHT_LOUSER 0x80000000 /* Application-specific range */ +#define SHT_HIUSER 0xffffffff + +/* sh_flags */ +#define SHF_WRITE 0x1 /* Section contains writable data */ +#define SHF_ALLOC 0x2 /* Section occupies memory */ +#define SHF_EXECINSTR 0x4 /* Section contains executable insns */ +#define SHF_MERGE 0x10 /* Section contains data that can be merged */ +#define SHF_STRINGS 0x20 /* Section contains null-terminated strings */ +#define SHF_INFO_LINK 0x40 /* Section header's sh_info holds table index */ +#define SHF_LINK_ORDER 0x80 /* Section has special ordering requirements */ + +#define SHF_MASKOS 0x0f000000 /* Operating system specific values */ +#define SHF_MASKPROC 0xf0000000 /* Processor-specific values */ + +/* + * Symbol Table + */ +typedef struct { + Elf32_Word st_name; /* Symbol name (.strtab index) */ + Elf32_Word st_value; /* value of symbol */ + Elf32_Word st_size; /* size of symbol */ + Elf_Byte st_info; /* type / binding attrs */ + Elf_Byte st_other; /* unused */ + Elf32_Half st_shndx; /* section index of symbol */ +} Elf32_Sym; + +typedef struct { + Elf64_Half st_name; /* Symbol name (.strtab index) */ + Elf_Byte st_info; /* type / binding attrs */ + Elf_Byte st_other; /* unused */ + Elf64_Quarter st_shndx; /* section index of symbol */ + Elf64_Addr st_value; /* value of symbol */ + Elf64_Xword st_size; /* size of symbol */ +} Elf64_Sym; + +/* Symbol Table index of the undefined symbol */ +#define ELF_SYM_UNDEFINED 0 + +#define STN_UNDEF 0 /* undefined index */ + +/* st_info: Symbol Bindings */ +#define STB_LOCAL 0 /* local symbol */ +#define STB_GLOBAL 1 /* global symbol */ +#define STB_WEAK 2 /* weakly defined global symbol */ +#define STB_NUM 3 + +#define STB_LOOS 10 /* Operating system specific range */ +#define STB_HIOS 12 +#define STB_LOPROC 13 /* Processor-specific range */ +#define STB_HIPROC 15 + +/* st_info: Symbol Types */ +#define STT_NOTYPE 0 /* Type not specified */ +#define STT_OBJECT 1 /* Associated with a data object */ +#define STT_FUNC 2 /* Associated with a function */ +#define STT_SECTION 3 /* Associated with a section */ +#define STT_FILE 4 /* Associated with a file name */ +#define STT_COMMON 5 /* Uninitialised common block */ +#define STT_TLS 6 /* Thread local data object */ +#define STT_NUM 7 + +#define STT_LOOS 10 /* Operating system specific range */ +#define STT_HIOS 12 +#define STT_LOPROC 13 /* Processor-specific range */ +#define STT_HIPROC 15 + +/* st_other: Visibility Types */ +#define STV_DEFAULT 0 /* use binding type */ +#define STV_INTERNAL 1 /* not referenced from outside */ +#define STV_HIDDEN 2 /* not visible, may be used via ptr */ +#define STV_PROTECTED 3 /* visible, not preemptible */ +#define STV_EXPORTED 4 +#define STV_SINGLETON 5 +#define STV_ELIMINATE 6 + +/* st_info/st_other utility macros */ +#define ELF_ST_BIND(info) ((uint32_t)(info) >> 4) +#define ELF_ST_TYPE(info) ((uint32_t)(info) & 0xf) +#define ELF_ST_INFO(bind,type) ((Elf_Byte)(((bind) << 4) | \ + ((type) & 0xf))) +#define ELF_ST_VISIBILITY(other) ((uint32_t)(other) & 3) + +/* + * Special section indexes + */ +#define SHN_UNDEF 0 /* Undefined section */ + +#define SHN_LORESERVE 0xff00 /* Reserved range */ +#define SHN_ABS 0xfff1 /* Absolute symbols */ +#define SHN_COMMON 0xfff2 /* Common symbols */ +#define SHN_XINDEX 0xffff /* Escape -- index stored elsewhere */ +#define SHN_HIRESERVE 0xffff + +#define SHN_LOPROC 0xff00 /* Processor-specific range */ +#define SHN_HIPROC 0xff1f +#define SHN_LOOS 0xff20 /* Operating system specific range */ +#define SHN_HIOS 0xff3f + +#define SHN_MIPS_ACOMMON 0xff00 +#define SHN_MIPS_TEXT 0xff01 +#define SHN_MIPS_DATA 0xff02 +#define SHN_MIPS_SCOMMON 0xff03 + +/* + * Relocation Entries + */ +typedef struct { + Elf32_Word r_offset; /* where to do it */ + Elf32_Word r_info; /* index & type of relocation */ +} Elf32_Rel; + +typedef struct { + Elf32_Word r_offset; /* where to do it */ + Elf32_Word r_info; /* index & type of relocation */ + Elf32_Sword r_addend; /* adjustment value */ +} Elf32_Rela; + +/* r_info utility macros */ +#define ELF32_R_SYM(info) ((info) >> 8) +#define ELF32_R_TYPE(info) ((info) & 0xff) +#define ELF32_R_INFO(sym, type) (((sym) << 8) + (unsigned char)(type)) + +typedef struct { + Elf64_Addr r_offset; /* where to do it */ + Elf64_Xword r_info; /* index & type of relocation */ +} Elf64_Rel; + +typedef struct { + Elf64_Addr r_offset; /* where to do it */ + Elf64_Xword r_info; /* index & type of relocation */ + Elf64_Sxword r_addend; /* adjustment value */ +} Elf64_Rela; + +/* r_info utility macros */ +#define ELF64_R_SYM(info) ((info) >> 32) +#define ELF64_R_TYPE(info) ((info) & 0xffffffff) +#define ELF64_R_INFO(sym,type) (((sym) << 32) + (type)) + +/* + * Move entries + */ +typedef struct { + Elf32_Lword m_value; /* symbol value */ + Elf32_Word m_info; /* size + index */ + Elf32_Word m_poffset; /* symbol offset */ + Elf32_Half m_repeat; /* repeat count */ + Elf32_Half m_stride; /* stride info */ +} Elf32_Move; + +#define ELF32_M_SYM(info) ((info) >> 8) +#define ELF32_M_SIZE(info) (info) & 0xff) +#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char)(size)) + +typedef struct { + Elf64_Lword m_value; /* symbol value */ + Elf64_Xword m_info; /* size + index */ + Elf64_Xword m_poffset; /* symbol offset */ + Elf64_Half m_repeat; /* repeat count */ + Elf64_Half m_stride; /* stride info */ +} Elf64_Move; + +#define ELF64_M_SYM(info) ((info) >> 8) +#define ELF64_M_SIZE(info) (info) & 0xff) +#define ELF64_M_INFO(sym, size) (((sym) << 8) + (unsigned char)(size)) + +/* + * Hardware/software capabilities entry + */ +typedef struct { + Elf32_Word c_tag; /* entry tag value */ + union { + Elf32_Addr c_ptr; + Elf32_Word c_val; + } c_un; +} Elf32_Cap; + +typedef struct { + Elf64_Xword c_tag; /* entry tag value */ + union { + Elf64_Addr c_ptr; + Elf64_Xword c_val; + } c_un; +} Elf64_Cap; + +/* + * Dynamic Section structure array + */ +typedef struct { + Elf32_Word d_tag; /* entry tag value */ + union { + Elf32_Addr d_ptr; + Elf32_Word d_val; + } d_un; +} Elf32_Dyn; + +typedef struct { + Elf64_Xword d_tag; /* entry tag value */ + union { + Elf64_Addr d_ptr; + Elf64_Xword d_val; + } d_un; +} Elf64_Dyn; + +/* d_tag */ +#define DT_NULL 0 /* Marks end of dynamic array */ +#define DT_NEEDED 1 /* Name of needed library (DT_STRTAB offset) */ +#define DT_PLTRELSZ 2 /* Size, in bytes, of relocations in PLT */ +#define DT_PLTGOT 3 /* Address of PLT and/or GOT */ +#define DT_HASH 4 /* Address of symbol hash table */ +#define DT_STRTAB 5 /* Address of string table */ +#define DT_SYMTAB 6 /* Address of symbol table */ +#define DT_RELA 7 /* Address of Rela relocation table */ +#define DT_RELASZ 8 /* Size, in bytes, of DT_RELA table */ +#define DT_RELAENT 9 /* Size, in bytes, of one DT_RELA entry */ +#define DT_STRSZ 10 /* Size, in bytes, of DT_STRTAB table */ +#define DT_SYMENT 11 /* Size, in bytes, of one DT_SYMTAB entry */ +#define DT_INIT 12 /* Address of initialization function */ +#define DT_FINI 13 /* Address of termination function */ +#define DT_SONAME 14 /* Shared object name (DT_STRTAB offset) */ +#define DT_RPATH 15 /* Library search path (DT_STRTAB offset) */ +#define DT_SYMBOLIC 16 /* Start symbol search within local object */ +#define DT_REL 17 /* Address of Rel relocation table */ +#define DT_RELSZ 18 /* Size, in bytes, of DT_REL table */ +#define DT_RELENT 19 /* Size, in bytes, of one DT_REL entry */ +#define DT_PLTREL 20 /* Type of PLT relocation entries */ +#define DT_DEBUG 21 /* Used for debugging; unspecified */ +#define DT_TEXTREL 22 /* Relocations might modify non-writable seg */ +#define DT_JMPREL 23 /* Address of relocations associated with PLT */ +#define DT_BIND_NOW 24 /* Process all relocations at load-time */ +#define DT_INIT_ARRAY 25 /* Address of initialization function array */ +#define DT_FINI_ARRAY 26 /* Size, in bytes, of DT_INIT_ARRAY array */ +#define DT_INIT_ARRAYSZ 27 /* Address of termination function array */ +#define DT_FINI_ARRAYSZ 28 /* Size, in bytes, of DT_FINI_ARRAY array*/ +#define DT_NUM 29 + +#define DT_LOOS 0x60000000 /* Operating system specific range */ +#define DT_VERSYM 0x6ffffff0 /* Symbol versions */ +#define DT_FLAGS_1 0x6ffffffb /* ELF dynamic flags */ +#define DT_VERDEF 0x6ffffffc /* Versions defined by file */ +#define DT_VERDEFNUM 0x6ffffffd /* Number of versions defined by file */ +#define DT_VERNEED 0x6ffffffe /* Versions needed by file */ +#define DT_VERNEEDNUM 0x6fffffff /* Number of versions needed by file */ +#define DT_HIOS 0x6fffffff +#define DT_LOPROC 0x70000000 /* Processor-specific range */ +#define DT_HIPROC 0x7fffffff + +/* Flag values for DT_FLAGS_1 (incomplete) */ +#define DF_1_INITFIRST 0x00000020 /* Object's init/fini take priority */ + +/* + * Auxiliary Vectors + */ +typedef struct { + Elf32_Word a_type; /* 32-bit id */ + Elf32_Word a_v; /* 32-bit id */ +} Aux32Info; + +typedef struct { + Elf64_Half a_type; /* 32-bit id */ + Elf64_Xword a_v; /* 64-bit id */ +} Aux64Info; + +/* a_type */ +#define AT_NULL 0 /* Marks end of array */ +#define AT_IGNORE 1 /* No meaning, a_un is undefined */ +#define AT_EXECFD 2 /* Open file descriptor of object file */ +#define AT_PHDR 3 /* &phdr[0] */ +#define AT_PHENT 4 /* sizeof(phdr[0]) */ +#define AT_PHNUM 5 /* # phdr entries */ +#define AT_PAGESZ 6 /* PAGESIZE */ +#define AT_BASE 7 /* Interpreter base addr */ +#define AT_FLAGS 8 /* Processor flags */ +#define AT_ENTRY 9 /* Entry address of executable */ +#define AT_DCACHEBSIZE 10 /* Data cache block size */ +#define AT_ICACHEBSIZE 11 /* Instruction cache block size */ +#define AT_UCACHEBSIZE 12 /* Unified cache block size */ + + /* Vendor specific */ +#define AT_MIPS_NOTELF 10 /* XXX a_val != 0 -> MIPS XCOFF executable */ + +#define AT_EUID 2000 /* euid (solaris compatible numbers) */ +#define AT_RUID 2001 /* ruid (solaris compatible numbers) */ +#define AT_EGID 2002 /* egid (solaris compatible numbers) */ +#define AT_RGID 2003 /* rgid (solaris compatible numbers) */ + + /* Solaris kernel specific */ +#define AT_SUN_LDELF 2004 /* dynamic linker's ELF header */ +#define AT_SUN_LDSHDR 2005 /* dynamic linker's section header */ +#define AT_SUN_LDNAME 2006 /* dynamic linker's name */ +#define AT_SUN_LPGSIZE 2007 /* large pagesize */ + + /* Other information */ +#define AT_SUN_PLATFORM 2008 /* sysinfo(SI_PLATFORM) */ +#define AT_SUN_HWCAP 2009 /* process hardware capabilities */ +#define AT_SUN_IFLUSH 2010 /* do we need to flush the instruction cache? */ +#define AT_SUN_CPU 2011 /* CPU name */ + /* ibcs2 emulation band aid */ +#define AT_SUN_EMUL_ENTRY 2012 /* coff entry point */ +#define AT_SUN_EMUL_EXECFD 2013 /* coff file descriptor */ + /* Executable's fully resolved name */ +#define AT_SUN_EXECNAME 2014 + +/* + * Note Headers + */ +typedef struct { + Elf32_Word n_namesz; + Elf32_Word n_descsz; + Elf32_Word n_type; +} Elf32_Nhdr; + +typedef struct { + Elf64_Half n_namesz; + Elf64_Half n_descsz; + Elf64_Half n_type; +} Elf64_Nhdr; + +#define ELF_NOTE_TYPE_ABI_TAG 1 + +/* GNU-specific note name and description sizes */ +#define ELF_NOTE_ABI_NAMESZ 4 +#define ELF_NOTE_ABI_DESCSZ 16 +/* GNU-specific note name */ +#define ELF_NOTE_ABI_NAME "GNU\0" + +/* GNU-specific OS/version value stuff */ +#define ELF_NOTE_ABI_OS_LINUX 0 +#define ELF_NOTE_ABI_OS_HURD 1 +#define ELF_NOTE_ABI_OS_SOLARIS 2 + +/* NetBSD-specific note type: Emulation name. desc is emul name string. */ +#define ELF_NOTE_TYPE_NETBSD_TAG 1 +/* NetBSD-specific note name and description sizes */ +#define ELF_NOTE_NETBSD_NAMESZ 7 +#define ELF_NOTE_NETBSD_DESCSZ 4 +/* NetBSD-specific note name */ +#define ELF_NOTE_NETBSD_NAME "NetBSD\0\0" + +/* NetBSD-specific note type: Checksum. There should be 1 NOTE per PT_LOAD + section. desc is a tuple of (16),(16),. */ +#define ELF_NOTE_TYPE_CHECKSUM_TAG 2 +#define ELF_NOTE_CHECKSUM_CRC32 1 +#define ELF_NOTE_CHECKSUM_MD5 2 +#define ELF_NOTE_CHECKSUM_SHA1 3 +#define ELF_NOTE_CHECKSUM_SHA256 4 + +/* NetBSD-specific note type: PaX. There should be 1 NOTE per executable. + section. desc is a 32 bit bitmask */ +#define ELF_NOTE_TYPE_PAX_TAG 3 +#define ELF_NOTE_PAX_MPROTECT 0x01 /* Force enable Mprotect */ +#define ELF_NOTE_PAX_NOMPROTECT 0x02 /* Force disable Mprotect */ +#define ELF_NOTE_PAX_GUARD 0x04 /* Force enable Segvguard */ +#define ELF_NOTE_PAX_NOGUARD 0x08 /* Force disable Servguard */ +#define ELF_NOTE_PAX_ASLR 0x10 /* Force enable ASLR */ +#define ELF_NOTE_PAX_NOASLR 0x20 /* Force disable ASLR */ +#define ELF_NOTE_PAX_NAMESZ 4 +#define ELF_NOTE_PAX_NAME "PaX\0" +#define ELF_NOTE_PAX_DESCSZ 4 + +/* + * NetBSD-specific core file information. + * + * NetBSD ELF core files use notes to provide information about + * the process's state. The note name is "NetBSD-CORE" for + * information that is global to the process, and "NetBSD-CORE@nn", + * where "nn" is the lwpid of the LWP that the information belongs + * to (such as register state). + * + * We use the following note identifiers: + * + * ELF_NOTE_NETBSD_CORE_PROCINFO + * Note is a "netbsd_elfcore_procinfo" structure. + * + * We also use ptrace(2) request numbers (the ones that exist in + * machine-dependent space) to identify register info notes. The + * info in such notes is in the same format that ptrace(2) would + * export that information. + * + * Please try to keep the members of this structure nicely aligned, + * and if you add elements, add them to the end and bump the version. + */ + +#define ELF_NOTE_NETBSD_CORE_NAME "NetBSD-CORE" + +#define ELF_NOTE_NETBSD_CORE_PROCINFO 1 + +#define NETBSD_ELFCORE_PROCINFO_VERSION 1 + +struct netbsd_elfcore_procinfo { + /* Version 1 fields start here. */ + uint32_t cpi_version; /* netbsd_elfcore_procinfo version */ + uint32_t cpi_cpisize; /* sizeof(netbsd_elfcore_procinfo) */ + uint32_t cpi_signo; /* killing signal */ + uint32_t cpi_sigcode; /* signal code */ + uint32_t cpi_sigpend[4]; /* pending signals */ + uint32_t cpi_sigmask[4]; /* blocked signals */ + uint32_t cpi_sigignore[4];/* blocked signals */ + uint32_t cpi_sigcatch[4];/* blocked signals */ + int32_t cpi_pid; /* process ID */ + int32_t cpi_ppid; /* parent process ID */ + int32_t cpi_pgrp; /* process group ID */ + int32_t cpi_sid; /* session ID */ + uint32_t cpi_ruid; /* real user ID */ + uint32_t cpi_euid; /* effective user ID */ + uint32_t cpi_svuid; /* saved user ID */ + uint32_t cpi_rgid; /* real group ID */ + uint32_t cpi_egid; /* effective group ID */ + uint32_t cpi_svgid; /* saved group ID */ + uint32_t cpi_nlwps; /* number of LWPs */ + int8_t cpi_name[32]; /* copy of p->p_comm */ + /* Add version 2 fields below here. */ + int32_t cpi_siglwp; /* LWP target of killing signal */ +}; + +#if defined(ELFSIZE) && (ELFSIZE == 32) +#define Elf_Ehdr Elf32_Ehdr +#define Elf_Phdr Elf32_Phdr +#define Elf_Shdr Elf32_Shdr +#define Elf_Sym Elf32_Sym +#define Elf_Rel Elf32_Rel +#define Elf_Rela Elf32_Rela +#define Elf_Dyn Elf32_Dyn +#define Elf_Word Elf32_Word +#define Elf_Sword Elf32_Sword +#define Elf_Addr Elf32_Addr +#define Elf_Off Elf32_Off +#define Elf_SOff Elf32_SOff +#define Elf_Nhdr Elf32_Nhdr + +#define ELF_R_SYM ELF32_R_SYM +#define ELF_R_TYPE ELF32_R_TYPE +#define ELFCLASS ELFCLASS32 + +#define AuxInfo Aux32Info +#elif defined(ELFSIZE) && (ELFSIZE == 64) +#define Elf_Ehdr Elf64_Ehdr +#define Elf_Phdr Elf64_Phdr +#define Elf_Shdr Elf64_Shdr +#define Elf_Sym Elf64_Sym +#define Elf_Rel Elf64_Rel +#define Elf_Rela Elf64_Rela +#define Elf_Dyn Elf64_Dyn +#define Elf_Word Elf64_Word +#define Elf_Sword Elf64_Sword +#define Elf_Addr Elf64_Addr +#define Elf_Off Elf64_Off +#define Elf_SOff Elf64_SOff +#define Elf_Nhdr Elf64_Nhdr + +#define ELF_R_SYM ELF64_R_SYM +#define ELF_R_TYPE ELF64_R_TYPE +#define ELFCLASS ELFCLASS64 + +#define AuxInfo Aux64Info +#endif + +#define ELF32_ST_BIND(info) ELF_ST_BIND(info) +#define ELF32_ST_TYPE(info) ELF_ST_TYPE(info) +#define ELF32_ST_INFO(bind,type) ELF_ST_INFO(bind,type) +#define ELF32_ST_VISIBILITY(other) ELF_ST_VISIBILITY(other) + +#define ELF64_ST_BIND(info) ELF_ST_BIND(info) +#define ELF64_ST_TYPE(info) ELF_ST_TYPE(info) +#define ELF64_ST_INFO(bind,type) ELF_ST_INFO(bind,type) +#define ELF64_ST_VISIBILITY(other) ELF_ST_VISIBILITY(other) + +typedef struct { + Elf32_Half si_boundto; /* direct bindings - symbol bound to */ + Elf32_Half si_flags; /* per symbol flags */ +} Elf32_Syminfo; + +typedef struct { + Elf64_Half si_boundto; /* direct bindings - symbol bound to */ + Elf64_Half si_flags; /* per symbol flags */ +} Elf64_Syminfo; + +#define SYMINFO_FLG_DIRECT 0x0001 /* symbol ref has direct association + to object containing definition */ +#define SYMINFO_FLG_PASSTHRU 0x0002 /* ignored - see SYMINFO_FLG_FILTER */ +#define SYMINFO_FLG_COPY 0x0004 /* symbol is a copy-reloc */ +#define SYMINFO_FLG_LAZYLOAD 0x0008 /* object containing defn should be + lazily-loaded */ +#define SYMINFO_FLG_DIRECTBIND 0x0010 /* ref should be bound directly to + object containing definition */ +#define SYMINFO_FLG_NOEXTDIRECT 0x0020 /* don't let an external reference + directly bind to this symbol */ +#define SYMINFO_FLG_FILTER 0x0002 /* symbol ref is associated to a */ +#define SYMINFO_FLG_AUXILIARY 0x0040 /* standard or auxiliary filter */ + +#define SYMINFO_BT_SELF 0xffff /* symbol bound to self */ +#define SYMINFO_BT_PARENT 0xfffe /* symbol bound to parent */ +#define SYMINFO_BT_NONE 0xfffd /* no special symbol binding */ +#define SYMINFO_BT_EXTERN 0xfffc /* symbol defined as external */ +#define SYMINFO_BT_LOWRESERVE 0xff00 /* beginning of reserved entries */ + +#define SYMINFO_NONE 0 /* Syminfo version */ +#define SYMINFO_CURRENT 1 +#define SYMINFO_NUM 2 + +/* + * These constants are used for Elf32_Verdef struct's version number. + */ +#define VER_DEF_NONE 0 +#define VER_DEF_CURRENT 1 + +/* + * These constants are used for Elf32_Verdef struct's vd_flags. + */ +#define VER_FLG_BASE 0x1 +#define VER_FLG_WEAK 0x2 + +/* + * These are used in an Elf32_Versym field. + */ +#define VER_NDX_LOCAL 0 +#define VER_NDX_GLOBAL 1 + +/* + * These constants are used for Elf32_Verneed struct's version number. + */ +#define VER_NEED_NONE 0 +#define VER_NEED_CURRENT 1 + +/* + * GNU Extension hidding symb + */ +#define VERSYM_HIDDEN 0x8000 +#define VERSYM_VERSION 0x7fff + +#define ELF_VER_CHR '@' + +/* + * These are current size independent. + */ + +typedef struct { + Elf32_Half vd_version; /* version number of structure */ + Elf32_Half vd_flags; /* flags (VER_FLG_*) */ + Elf32_Half vd_ndx; /* version index */ + Elf32_Half vd_cnt; /* number of verdaux entries */ + Elf32_Word vd_hash; /* hash of name */ + Elf32_Word vd_aux; /* offset to verdaux entries */ + Elf32_Word vd_next; /* offset to next verdef */ +} Elf32_Verdef; +typedef Elf32_Verdef Elf64_Verdef; + +typedef struct { + Elf32_Word vda_name; /* string table offset of name */ + Elf32_Word vda_next; /* offset to verdaux */ +} Elf32_Verdaux; +typedef Elf32_Verdaux Elf64_Verdaux; + +typedef struct { + Elf32_Half vn_version; /* version number of structure */ + Elf32_Half vn_cnt; /* number of vernaux entries */ + Elf32_Word vn_file; /* string table offset of library name*/ + Elf32_Word vn_aux; /* offset to vernaux entries */ + Elf32_Word vn_next; /* offset to next verneed */ +} Elf32_Verneed; +typedef Elf32_Verneed Elf64_Verneed; + +typedef struct { + Elf32_Word vna_hash; /* Hash of dependency name */ + Elf32_Half vna_flags; /* flags (VER_FLG_*) */ + Elf32_Half vna_other; /* unused */ + Elf32_Word vna_name; /* string table offset to version name*/ + Elf32_Word vna_next; /* offset to next vernaux */ +} Elf32_Vernaux; +typedef Elf32_Vernaux Elf64_Vernaux; + +typedef struct { + Elf32_Half vs_vers; +} Elf32_Versym; +typedef Elf32_Versym Elf64_Versym; + +#ifdef _KERNEL + +#define ELF_AUX_ENTRIES 14 /* Max size of aux array passed to loader */ +#define ELF32_NO_ADDR (~(Elf32_Addr)0) /* Indicates addr. not yet filled in */ +#define ELF32_LINK_ADDR ((Elf32_Addr)-2) /* advises to use link address */ +#define ELF64_NO_ADDR (~(Elf64_Addr)0) /* Indicates addr. not yet filled in */ +#define ELF64_LINK_ADDR ((Elf64_Addr)-2) /* advises to use link address */ + +#if defined(ELFSIZE) && (ELFSIZE == 64) +#define ELF_NO_ADDR ELF64_NO_ADDR +#define ELF_LINK_ADDR ELF64_LINK_ADDR +#elif defined(ELFSIZE) && (ELFSIZE == 32) +#define ELF_NO_ADDR ELF32_NO_ADDR +#define ELF_LINK_ADDR ELF32_LINK_ADDR +#endif + +#ifndef ELF32_EHDR_FLAGS_OK +#define ELF32_EHDR_FLAGS_OK(eh) 1 +#endif + +#ifndef ELF64_EHDR_FLAGS_OK +#define ELF64_EHDR_FLAGS_OK(eh) 1 +#endif + +#if defined(ELFSIZE) && (ELFSIZE == 64) +#define ELF_EHDR_FLAGS_OK(eh) ELF64_EHDR_FLAGS_OK(eh) +#else +#define ELF_EHDR_FLAGS_OK(eh) ELF32_EHDR_FLAGS_OK(eh) +#endif + +#if defined(ELFSIZE) +struct elf_args { + Elf_Addr arg_entry; /* program entry point */ + Elf_Addr arg_interp; /* Interpreter load address */ + Elf_Addr arg_phaddr; /* program header address */ + Elf_Addr arg_phentsize; /* Size of program header */ + Elf_Addr arg_phnum; /* Number of program headers */ +}; +#endif + +#ifdef _KERNEL_OPT +#include "opt_execfmt.h" +#endif + +#ifdef EXEC_ELF32 +int exec_elf32_makecmds(struct lwp *, struct exec_package *); +int elf32_copyargs(struct lwp *, struct exec_package *, + struct ps_strings *, char **, void *); + +int coredump_elf32(struct lwp *, void *); +int coredump_writenote_elf32(struct proc *, void *, Elf32_Nhdr *, + const char *, void *); + +int elf32_check_header(Elf32_Ehdr *, int); +#endif + +#ifdef EXEC_ELF64 +int exec_elf64_makecmds(struct lwp *, struct exec_package *); +int elf64_copyargs(struct lwp *, struct exec_package *, + struct ps_strings *, char **, void *); + +int coredump_elf64(struct lwp *, void *); +int coredump_writenote_elf64(struct proc *, void *, Elf64_Nhdr *, + const char *, void *); + +int elf64_check_header(Elf64_Ehdr *, int); +#endif + +#endif /* _KERNEL */ + +#endif /* !_SYS_EXEC_ELF_H_ */ diff --git a/cpukit/include/sys/poll.h b/cpukit/include/sys/poll.h new file mode 100644 index 0000000000..c955f321c7 --- /dev/null +++ b/cpukit/include/sys/poll.h @@ -0,0 +1,104 @@ +/*- + * Copyright (c) 1997 Peter Wemm + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _SYS_POLL_H_ +#define _SYS_POLL_H_ + +#include + +/* + * This file is intended to be compatible with the traditional poll.h. + */ + +typedef unsigned int nfds_t; + +/* + * This structure is passed as an array to poll(2). + */ +struct pollfd { + int fd; /* which file descriptor to poll */ + short events; /* events we are interested in */ + short revents; /* events found on return */ +}; + +/* + * Requestable events. If poll(2) finds any of these set, they are + * copied to revents on return. + * XXX Note that FreeBSD doesn't make much distinction between POLLPRI + * and POLLRDBAND since none of the file types have distinct priority + * bands - and only some have an urgent "mode". + * XXX Note POLLIN isn't really supported in true SVSV terms. Under SYSV + * POLLIN includes all of normal, band and urgent data. Most poll handlers + * on FreeBSD only treat it as "normal" data. + */ +#define POLLIN 0x0001 /* any readable data available */ +#define POLLPRI 0x0002 /* OOB/Urgent readable data */ +#define POLLOUT 0x0004 /* file descriptor is writeable */ +#define POLLRDNORM 0x0040 /* non-OOB/URG data available */ +#define POLLWRNORM POLLOUT /* no write type differentiation */ +#define POLLRDBAND 0x0080 /* OOB/Urgent readable data */ +#define POLLWRBAND 0x0100 /* OOB/Urgent data can be written */ + +#if __BSD_VISIBLE +/* General FreeBSD extension (currently only supported for sockets): */ +#define POLLINIGNEOF 0x2000 /* like POLLIN, except ignore EOF */ +#endif + +/* + * These events are set if they occur regardless of whether they were + * requested. + */ +#define POLLERR 0x0008 /* some poll error occurred */ +#define POLLHUP 0x0010 /* file descriptor was "hung up" */ +#define POLLNVAL 0x0020 /* requested events "invalid" */ + +#if __BSD_VISIBLE + +#define POLLSTANDARD (POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|\ + POLLWRBAND|POLLERR|POLLHUP|POLLNVAL) + +/* + * Request that poll() wait forever. + * XXX in SYSV, this is defined in stropts.h, which is not included + * by poll.h. + */ +#define INFTIM (-1) + +#endif + +#ifndef _KERNEL + +__BEGIN_DECLS +int poll(struct pollfd _pfd[], nfds_t _nfds, int _timeout); +__END_DECLS + +#endif /* !_KERNEL */ + +#endif /* !_SYS_POLL_H_ */ diff --git a/cpukit/include/sys/statvfs.h b/cpukit/include/sys/statvfs.h new file mode 100644 index 0000000000..cf80478aae --- /dev/null +++ b/cpukit/include/sys/statvfs.h @@ -0,0 +1,60 @@ +/** + * @file + * + * @brief Interface to the statvfs() Set of API Methods + * + * This include file defines the interface to the statvfs() set of + * API methods. The statvfs as defined by the SUS: + * + * - http://www.opengroup.org/onlinepubs/009695399/basedefs/sys/statvfs.h.html + */ + +/* + * COPYRIGHT (c) 2009 Chris Johns + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +/* + */ + +#ifndef _SYS_STATVFS_H_ +#define _SYS_STATVFS_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef uint64_t fsblkcnt_t; +typedef uint32_t fsfilcnt_t; + +struct statvfs +{ + unsigned long f_bsize; /**< File system block size. */ + unsigned long f_frsize; /**< Fundamental file system block size. */ + fsblkcnt_t f_blocks; /**< Total number of blocks on file system in units + * of f_frsize. */ + fsblkcnt_t f_bfree; /**< Total number of free blocks. */ + fsblkcnt_t f_bavail; /**< Number of free blocks available to + * non-privileged process. */ + fsfilcnt_t f_files; /**< Total number of file serial numbers. */ + fsfilcnt_t f_ffree; /**< Total number of free file serial numbers. */ + fsfilcnt_t f_favail; /**< Number of file serial numbers available to + * non-privileged process. */ + unsigned long f_fsid; /**< File system ID. */ + unsigned long f_flag; /**< Bit mask of f_flag values. */ + unsigned long f_namemax; /**< Maximum filename length. */ +}; + +extern int statvfs(const char *__restrict , struct statvfs *__restrict); +extern int fstatvfs(int, struct statvfs *); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/include/sys/timeffc.h b/cpukit/include/sys/timeffc.h new file mode 100644 index 0000000000..c04de97f1d --- /dev/null +++ b/cpukit/include/sys/timeffc.h @@ -0,0 +1,391 @@ +/*- + * Copyright (c) 2011 The University of Melbourne + * All rights reserved. + * + * This software was developed by Julien Ridoux at the University of Melbourne + * under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: head/sys/sys/timeffc.h 228856 2011-12-24 01:32:01Z lstewart $ + */ + +#ifndef _SYS_TIMEFF_H_ +#define _SYS_TIMEFF_H_ + +#include + +/* + * Feed-forward clock estimate + * Holds time mark as a ffcounter and conversion to bintime based on current + * timecounter period and offset estimate passed by the synchronization daemon. + * Provides time of last daemon update, clock status and bound on error. + */ +struct ffclock_estimate { + struct bintime update_time; /* Time of last estimates update. */ + ffcounter update_ffcount; /* Counter value at last update. */ + ffcounter leapsec_next; /* Counter value of next leap second. */ + uint64_t period; /* Estimate of counter period. */ + uint32_t errb_abs; /* Bound on absolute clock error [ns]. */ + uint32_t errb_rate; /* Bound on counter rate error [ps/s]. */ + uint32_t status; /* Clock status. */ + int16_t leapsec_total; /* All leap seconds seen so far. */ + int8_t leapsec; /* Next leap second (in {-1,0,1}). */ +}; + +#if __BSD_VISIBLE +#ifdef _KERNEL + +#ifndef __rtems__ +/* Define the kern.sysclock sysctl tree. */ +SYSCTL_DECL(_kern_sysclock); + +/* Define the kern.sysclock.ffclock sysctl tree. */ +SYSCTL_DECL(_kern_sysclock_ffclock); +#endif /* __rtems__ */ + +/* + * Index into the sysclocks array for obtaining the ASCII name of a particular + * sysclock. + */ +#define SYSCLOCK_FBCK 0 +#define SYSCLOCK_FFWD 1 +extern int sysclock_active; + +/* + * Parameters of counter characterisation required by feed-forward algorithms. + */ +#define FFCLOCK_SKM_SCALE 1024 + +/* + * Feed-forward clock status + */ +#define FFCLOCK_STA_UNSYNC 1 +#define FFCLOCK_STA_WARMUP 2 + +/* + * Flags for use by sysclock_snap2bintime() and various ffclock_ functions to + * control how the timecounter hardware is read and how the hardware snapshot is + * converted into absolute time. + * {FB|FF}CLOCK_FAST: Do not read the hardware counter, instead using the + * value at last tick. The time returned has a resolution + * of the kernel tick timer (1/hz [s]). + * FFCLOCK_LERP: Linear interpolation of ffclock time to guarantee + * monotonic time. + * FFCLOCK_LEAPSEC: Include leap seconds. + * {FB|FF}CLOCK_UPTIME: Time stamp should be relative to system boot, not epoch. + */ +#define FFCLOCK_FAST 0x00000001 +#define FFCLOCK_LERP 0x00000002 +#define FFCLOCK_LEAPSEC 0x00000004 +#define FFCLOCK_UPTIME 0x00000008 +#define FFCLOCK_MASK 0x0000ffff + +#define FBCLOCK_FAST 0x00010000 /* Currently unused. */ +#define FBCLOCK_UPTIME 0x00020000 +#define FBCLOCK_MASK 0xffff0000 + +/* + * Feedback clock specific info structure. The feedback clock's estimation of + * clock error is an absolute figure determined by the NTP algorithm. The status + * is determined by the userland daemon. + */ +struct fbclock_info { + struct bintime error; + struct bintime tick_time; + uint64_t th_scale; + int status; +}; + +/* + * Feed-forward clock specific info structure. The feed-forward clock's + * estimation of clock error is an upper bound, which although potentially + * looser than the feedback clock equivalent, is much more reliable. The status + * is determined by the userland daemon. + */ +struct ffclock_info { + struct bintime error; + struct bintime tick_time; + struct bintime tick_time_lerp; + uint64_t period; + uint64_t period_lerp; + int leapsec_adjustment; + int status; +}; + +/* + * Snapshot of system clocks and related information. Holds time read from each + * clock based on a single read of the active hardware timecounter, as well as + * respective clock information such as error estimates and the ffcounter value + * at the time of the read. + */ +struct sysclock_snap { + struct fbclock_info fb_info; + struct ffclock_info ff_info; + ffcounter ffcount; + unsigned int delta; + int sysclock_active; +}; + +/* Take a snapshot of the system clocks and related information. */ +void sysclock_getsnapshot(struct sysclock_snap *clock_snap, int fast); + +/* Convert a timestamp from the selected system clock into bintime. */ +int sysclock_snap2bintime(struct sysclock_snap *cs, struct bintime *bt, + int whichclock, uint32_t flags); + +/* Resets feed-forward clock from RTC */ +void ffclock_reset_clock(struct timespec *ts); + +/* + * Return the current value of the feed-forward clock counter. Essential to + * measure time interval in counter units. If a fast timecounter is used by the + * system, may also allow fast but accurate timestamping. + */ +void ffclock_read_counter(ffcounter *ffcount); + +/* + * Retrieve feed-forward counter value and time of last kernel tick. This + * accepts the FFCLOCK_LERP flag. + */ +void ffclock_last_tick(ffcounter *ffcount, struct bintime *bt, uint32_t flags); + +/* + * Low level routines to convert a counter timestamp into absolute time and a + * counter timestamp interval into an interval in seconds. The absolute time + * conversion accepts the FFCLOCK_LERP flag. + */ +void ffclock_convert_abs(ffcounter ffcount, struct bintime *bt, uint32_t flags); +void ffclock_convert_diff(ffcounter ffdelta, struct bintime *bt); + +/* + * Feed-forward clock routines. + * + * These functions rely on the timecounters and ffclock_estimates stored in + * fftimehands. Note that the error_bound parameter is not the error of the + * clock but an upper bound on the error of the absolute time or time interval + * returned. + * + * ffclock_abstime(): retrieves current time as counter value and convert this + * timestamp in seconds. The value (in seconds) of the converted timestamp + * depends on the flags passed: for a given counter value, different + * conversions are possible. Different clock models can be selected by + * combining flags (for example (FFCLOCK_LERP|FFCLOCK_UPTIME) produces + * linearly interpolated uptime). + * ffclock_difftime(): computes a time interval in seconds based on an interval + * measured in ffcounter units. This should be the preferred way to measure + * small time intervals very accurately. + */ +void ffclock_abstime(ffcounter *ffcount, struct bintime *bt, + struct bintime *error_bound, uint32_t flags); +void ffclock_difftime(ffcounter ffdelta, struct bintime *bt, + struct bintime *error_bound); + +/* + * Wrapper routines to return current absolute time using the feed-forward + * clock. These functions are named after those defined in , which + * contains a description of the original ones. + */ +void ffclock_bintime(struct bintime *bt); +void ffclock_nanotime(struct timespec *tsp); +void ffclock_microtime(struct timeval *tvp); + +void ffclock_getbintime(struct bintime *bt); +void ffclock_getnanotime(struct timespec *tsp); +void ffclock_getmicrotime(struct timeval *tvp); + +void ffclock_binuptime(struct bintime *bt); +void ffclock_nanouptime(struct timespec *tsp); +void ffclock_microuptime(struct timeval *tvp); + +void ffclock_getbinuptime(struct bintime *bt); +void ffclock_getnanouptime(struct timespec *tsp); +void ffclock_getmicrouptime(struct timeval *tvp); + +/* + * Wrapper routines to convert a time interval specified in ffcounter units into + * seconds using the current feed-forward clock estimates. + */ +void ffclock_bindifftime(ffcounter ffdelta, struct bintime *bt); +void ffclock_nanodifftime(ffcounter ffdelta, struct timespec *tsp); +void ffclock_microdifftime(ffcounter ffdelta, struct timeval *tvp); + +/* + * When FFCLOCK is enabled in the kernel, [get]{bin,nano,micro}[up]time() become + * wrappers around equivalent feedback or feed-forward functions. Provide access + * outside of kern_tc.c to the feedback clock equivalent functions for + * specialised use i.e. these are not for general consumption. + */ +void fbclock_bintime(struct bintime *bt); +void fbclock_nanotime(struct timespec *tsp); +void fbclock_microtime(struct timeval *tvp); + +void fbclock_getbintime(struct bintime *bt); +void fbclock_getnanotime(struct timespec *tsp); +void fbclock_getmicrotime(struct timeval *tvp); + +void fbclock_binuptime(struct bintime *bt); +void fbclock_nanouptime(struct timespec *tsp); +void fbclock_microuptime(struct timeval *tvp); + +void fbclock_getbinuptime(struct bintime *bt); +void fbclock_getnanouptime(struct timespec *tsp); +void fbclock_getmicrouptime(struct timeval *tvp); + +/* + * Public system clock wrapper API which allows consumers to select which clock + * to obtain time from, independent of the current default system clock. These + * wrappers should be used instead of directly calling the underlying fbclock_ + * or ffclock_ functions. + */ +static inline void +bintime_fromclock(struct bintime *bt, int whichclock) +{ + + if (whichclock == SYSCLOCK_FFWD) + ffclock_bintime(bt); + else + fbclock_bintime(bt); +} + +static inline void +nanotime_fromclock(struct timespec *tsp, int whichclock) +{ + + if (whichclock == SYSCLOCK_FFWD) + ffclock_nanotime(tsp); + else + fbclock_nanotime(tsp); +} + +static inline void +microtime_fromclock(struct timeval *tvp, int whichclock) +{ + + if (whichclock == SYSCLOCK_FFWD) + ffclock_microtime(tvp); + else + fbclock_microtime(tvp); +} + +static inline void +getbintime_fromclock(struct bintime *bt, int whichclock) +{ + + if (whichclock == SYSCLOCK_FFWD) + ffclock_getbintime(bt); + else + fbclock_getbintime(bt); +} + +static inline void +getnanotime_fromclock(struct timespec *tsp, int whichclock) +{ + + if (whichclock == SYSCLOCK_FFWD) + ffclock_getnanotime(tsp); + else + fbclock_getnanotime(tsp); +} + +static inline void +getmicrotime_fromclock(struct timeval *tvp, int whichclock) +{ + + if (whichclock == SYSCLOCK_FFWD) + ffclock_getmicrotime(tvp); + else + fbclock_getmicrotime(tvp); +} + +static inline void +binuptime_fromclock(struct bintime *bt, int whichclock) +{ + + if (whichclock == SYSCLOCK_FFWD) + ffclock_binuptime(bt); + else + fbclock_binuptime(bt); +} + +static inline void +nanouptime_fromclock(struct timespec *tsp, int whichclock) +{ + + if (whichclock == SYSCLOCK_FFWD) + ffclock_nanouptime(tsp); + else + fbclock_nanouptime(tsp); +} + +static inline void +microuptime_fromclock(struct timeval *tvp, int whichclock) +{ + + if (whichclock == SYSCLOCK_FFWD) + ffclock_microuptime(tvp); + else + fbclock_microuptime(tvp); +} + +static inline void +getbinuptime_fromclock(struct bintime *bt, int whichclock) +{ + + if (whichclock == SYSCLOCK_FFWD) + ffclock_getbinuptime(bt); + else + fbclock_getbinuptime(bt); +} + +static inline void +getnanouptime_fromclock(struct timespec *tsp, int whichclock) +{ + + if (whichclock == SYSCLOCK_FFWD) + ffclock_getnanouptime(tsp); + else + fbclock_getnanouptime(tsp); +} + +static inline void +getmicrouptime_fromclock(struct timeval *tvp, int whichclock) +{ + + if (whichclock == SYSCLOCK_FFWD) + ffclock_getmicrouptime(tvp); + else + fbclock_getmicrouptime(tvp); +} + +#else /* !_KERNEL */ + +/* Feed-Forward Clock system calls. */ +__BEGIN_DECLS +int ffclock_getcounter(ffcounter *ffcount); +int ffclock_getestimate(struct ffclock_estimate *cest); +int ffclock_setestimate(struct ffclock_estimate *cest); +__END_DECLS + +#endif /* _KERNEL */ +#endif /* __BSD_VISIBLE */ +#endif /* _SYS_TIMEFF_H_ */ diff --git a/cpukit/include/sys/timepps.h b/cpukit/include/sys/timepps.h new file mode 100644 index 0000000000..01212f0b43 --- /dev/null +++ b/cpukit/include/sys/timepps.h @@ -0,0 +1,266 @@ +/*- + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * wrote this file. As long as you retain this notice you + * can do whatever you want with this stuff. If we meet some day, and you think + * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp + * ---------------------------------------------------------------------------- + * + * Copyright (c) 2011 The FreeBSD Foundation + * All rights reserved. + * + * Portions of this software were developed by Julien Ridoux at the University + * of Melbourne under sponsorship from the FreeBSD Foundation. + * + * $FreeBSD: head/sys/sys/timepps.h 282424 2015-05-04 17:59:39Z ian $ + * + * The is a FreeBSD version of the RFC 2783 API for Pulse Per Second + * timing interfaces. + */ + +#ifndef _SYS_TIMEPPS_H_ +#define _SYS_TIMEPPS_H_ + +#include +#include +#include + +#define PPS_API_VERS_1 1 + +typedef int pps_handle_t; + +typedef unsigned pps_seq_t; + +typedef struct ntp_fp { + unsigned int integral; + unsigned int fractional; +} ntp_fp_t; + +typedef union pps_timeu { + struct timespec tspec; + ntp_fp_t ntpfp; + unsigned long longpad[3]; +} pps_timeu_t; + +typedef struct { + pps_seq_t assert_sequence; /* assert event seq # */ + pps_seq_t clear_sequence; /* clear event seq # */ + pps_timeu_t assert_tu; + pps_timeu_t clear_tu; + int current_mode; /* current mode bits */ +} pps_info_t; + +typedef struct { + pps_seq_t assert_sequence; /* assert event seq # */ + pps_seq_t clear_sequence; /* clear event seq # */ + pps_timeu_t assert_tu; + pps_timeu_t clear_tu; + ffcounter assert_ffcount; /* ffcounter on assert event */ + ffcounter clear_ffcount; /* ffcounter on clear event */ + int current_mode; /* current mode bits */ +} pps_info_ffc_t; + +#define assert_timestamp assert_tu.tspec +#define clear_timestamp clear_tu.tspec + +#define assert_timestamp_ntpfp assert_tu.ntpfp +#define clear_timestamp_ntpfp clear_tu.ntpfp + +typedef struct { + int api_version; /* API version # */ + int mode; /* mode bits */ + pps_timeu_t assert_off_tu; + pps_timeu_t clear_off_tu; +} pps_params_t; + +#define assert_offset assert_off_tu.tspec +#define clear_offset clear_off_tu.tspec + +#define assert_offset_ntpfp assert_off_tu.ntpfp +#define clear_offset_ntpfp clear_off_tu.ntpfp + + +#define PPS_CAPTUREASSERT 0x01 +#define PPS_CAPTURECLEAR 0x02 +#define PPS_CAPTUREBOTH 0x03 + +#define PPS_OFFSETASSERT 0x10 +#define PPS_OFFSETCLEAR 0x20 + +#define PPS_ECHOASSERT 0x40 +#define PPS_ECHOCLEAR 0x80 + +#define PPS_CANWAIT 0x100 +#define PPS_CANPOLL 0x200 + +#define PPS_TSFMT_TSPEC 0x1000 +#define PPS_TSFMT_NTPFP 0x2000 + +#define PPS_TSCLK_FBCK 0x10000 +#define PPS_TSCLK_FFWD 0x20000 +#define PPS_TSCLK_MASK 0x30000 + +#define PPS_KC_HARDPPS 0 +#define PPS_KC_HARDPPS_PLL 1 +#define PPS_KC_HARDPPS_FLL 2 + +struct pps_fetch_args { + int tsformat; + pps_info_t pps_info_buf; + struct timespec timeout; +}; + +struct pps_fetch_ffc_args { + int tsformat; + pps_info_ffc_t pps_info_buf_ffc; + struct timespec timeout; +}; + +struct pps_kcbind_args { + int kernel_consumer; + int edge; + int tsformat; +}; + +#define PPS_IOC_CREATE _IO('1', 1) +#define PPS_IOC_DESTROY _IO('1', 2) +#define PPS_IOC_SETPARAMS _IOW('1', 3, pps_params_t) +#define PPS_IOC_GETPARAMS _IOR('1', 4, pps_params_t) +#define PPS_IOC_GETCAP _IOR('1', 5, int) +#define PPS_IOC_FETCH _IOWR('1', 6, struct pps_fetch_args) +#define PPS_IOC_KCBIND _IOW('1', 7, struct pps_kcbind_args) +#define PPS_IOC_FETCH_FFCOUNTER _IOWR('1', 8, struct pps_fetch_ffc_args) + +#ifdef _KERNEL + +struct mtx; + +#define KCMODE_EDGEMASK 0x03 +#define KCMODE_ABIFLAG 0x80000000 /* Internal use: abi-aware driver. */ + +#define PPS_ABI_VERSION 1 + +#define PPSFLAG_MTX_SPIN 0x01 /* Driver mtx is MTX_SPIN type. */ + +struct pps_state { + /* Capture information. */ + struct timehands *capth; + struct fftimehands *capffth; + unsigned capgen; + unsigned capcount; + + /* State information. */ + pps_params_t ppsparam; + pps_info_t ppsinfo; + pps_info_ffc_t ppsinfo_ffc; + int kcmode; + int ppscap; + struct timecounter *ppstc; + unsigned ppscount[3]; + /* + * The following fields are valid if the driver calls pps_init_abi(). + */ + uint16_t driver_abi; /* Driver sets before pps_init_abi(). */ + uint16_t kernel_abi; /* Kernel sets during pps_init_abi(). */ + struct mtx *driver_mtx; /* Optional, valid if non-NULL. */ + uint32_t flags; +}; + +void pps_capture(struct pps_state *pps); +void pps_event(struct pps_state *pps, int event); +void pps_init(struct pps_state *pps); +void pps_init_abi(struct pps_state *pps); +int pps_ioctl(unsigned long cmd, caddr_t data, struct pps_state *pps); +void hardpps(struct timespec *tsp, long nsec); + +#else /* !_KERNEL */ + +static __inline int +time_pps_create(int filedes, pps_handle_t *handle) +{ + int error; + + *handle = -1; + error = ioctl(filedes, PPS_IOC_CREATE, 0); + if (error < 0) + return (-1); + *handle = filedes; + return (0); +} + +static __inline int +time_pps_destroy(pps_handle_t handle) +{ + return (ioctl(handle, PPS_IOC_DESTROY, 0)); +} + +static __inline int +time_pps_setparams(pps_handle_t handle, const pps_params_t *ppsparams) +{ + return (ioctl(handle, PPS_IOC_SETPARAMS, ppsparams)); +} + +static __inline int +time_pps_getparams(pps_handle_t handle, pps_params_t *ppsparams) +{ + return (ioctl(handle, PPS_IOC_GETPARAMS, ppsparams)); +} + +static __inline int +time_pps_getcap(pps_handle_t handle, int *mode) +{ + return (ioctl(handle, PPS_IOC_GETCAP, mode)); +} + +static __inline int +time_pps_fetch(pps_handle_t handle, const int tsformat, + pps_info_t *ppsinfobuf, const struct timespec *timeout) +{ + int error; + struct pps_fetch_args arg; + + arg.tsformat = tsformat; + if (timeout == NULL) { + arg.timeout.tv_sec = -1; + arg.timeout.tv_nsec = -1; + } else + arg.timeout = *timeout; + error = ioctl(handle, PPS_IOC_FETCH, &arg); + *ppsinfobuf = arg.pps_info_buf; + return (error); +} + +static __inline int +time_pps_fetch_ffc(pps_handle_t handle, const int tsformat, + pps_info_ffc_t *ppsinfobuf, const struct timespec *timeout) +{ + struct pps_fetch_ffc_args arg; + int error; + + arg.tsformat = tsformat; + if (timeout == NULL) { + arg.timeout.tv_sec = -1; + arg.timeout.tv_nsec = -1; + } else { + arg.timeout = *timeout; + } + error = ioctl(handle, PPS_IOC_FETCH_FFCOUNTER, &arg); + *ppsinfobuf = arg.pps_info_buf_ffc; + return (error); +} + +static __inline int +time_pps_kcbind(pps_handle_t handle, const int kernel_consumer, + const int edge, const int tsformat) +{ + struct pps_kcbind_args arg; + + arg.kernel_consumer = kernel_consumer; + arg.edge = edge; + arg.tsformat = tsformat; + return (ioctl(handle, PPS_IOC_KCBIND, &arg)); +} + +#endif /* KERNEL */ + +#endif /* !_SYS_TIMEPPS_H_ */ diff --git a/cpukit/include/sys/timetc.h b/cpukit/include/sys/timetc.h new file mode 100644 index 0000000000..347a140ed9 --- /dev/null +++ b/cpukit/include/sys/timetc.h @@ -0,0 +1,105 @@ +/*- + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42): + * wrote this file. As long as you retain this notice you + * can do whatever you want with this stuff. If we meet some day, and you think + * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp + * ---------------------------------------------------------------------------- + * + * $FreeBSD: head/sys/sys/timetc.h 304285 2016-08-17 09:52:09Z kib $ + */ + +#ifndef _SYS_TIMETC_H_ +#define _SYS_TIMETC_H_ + +#ifndef __rtems__ +#ifndef _KERNEL +#error "no user-serviceable parts inside" +#endif +#endif /* __rtems__ */ + +/*- + * `struct timecounter' is the interface between the hardware which implements + * a timecounter and the MI code which uses this to keep track of time. + * + * A timecounter is a binary counter which has two properties: + * * it runs at a fixed, known frequency. + * * it has sufficient bits to not roll over in less than approximately + * max(2 msec, 2/HZ seconds). (The value 2 here is really 1 + delta, + * for some indeterminate value of delta.) + */ + +struct timecounter; +struct vdso_timehands; +struct vdso_timehands32; +#ifndef __rtems__ +typedef u_int timecounter_get_t(struct timecounter *); +#else /* __rtems__ */ +typedef uint32_t timecounter_get_t(struct timecounter *); +#endif /* __rtems__ */ +typedef void timecounter_pps_t(struct timecounter *); +typedef uint32_t timecounter_fill_vdso_timehands_t(struct vdso_timehands *, + struct timecounter *); +typedef uint32_t timecounter_fill_vdso_timehands32_t(struct vdso_timehands32 *, + struct timecounter *); + +struct timecounter { + timecounter_get_t *tc_get_timecount; + /* + * This function reads the counter. It is not required to + * mask any unimplemented bits out, as long as they are + * constant. + */ + timecounter_pps_t *tc_poll_pps; + /* + * This function is optional. It will be called whenever the + * timecounter is rewound, and is intended to check for PPS + * events. Normal hardware does not need it but timecounters + * which latch PPS in hardware (like sys/pci/xrpu.c) do. + */ + uint32_t tc_counter_mask; + /* This mask should mask off any unimplemented bits. */ + uint64_t tc_frequency; + /* Frequency of the counter in Hz. */ + const char *tc_name; + /* Name of the timecounter. */ + int tc_quality; + /* + * Used to determine if this timecounter is better than + * another timecounter higher means better. Negative + * means "only use at explicit request". + */ + u_int tc_flags; +#define TC_FLAGS_C2STOP 1 /* Timer dies in C2+. */ +#define TC_FLAGS_SUSPEND_SAFE 2 /* + * Timer functional across + * suspend/resume. + */ + + void *tc_priv; + /* Pointer to the timecounter's private parts. */ + struct timecounter *tc_next; + /* Pointer to the next timecounter. */ +#ifndef __rtems__ + timecounter_fill_vdso_timehands_t *tc_fill_vdso_timehands; + timecounter_fill_vdso_timehands32_t *tc_fill_vdso_timehands32; +#endif /* __rtems__ */ +}; + +extern struct timecounter *timecounter; +extern int tc_min_ticktock_freq; /* + * Minimal tc_ticktock() call frequency, + * required to handle counter wraps. + */ + +u_int64_t tc_getfrequency(void); +void tc_init(struct timecounter *tc); +void tc_setclock(struct timespec *ts); +void tc_ticktock(int cnt); +void cpu_tick_calibration(void); + +#ifdef SYSCTL_DECL +SYSCTL_DECL(_kern_timecounter); +#endif + +#endif /* !_SYS_TIMETC_H_ */ diff --git a/cpukit/include/sys/timex.h b/cpukit/include/sys/timex.h new file mode 100644 index 0000000000..d2d2012ff5 --- /dev/null +++ b/cpukit/include/sys/timex.h @@ -0,0 +1,171 @@ +/*- + *********************************************************************** + * * + * Copyright (c) David L. Mills 1993-2001 * + * Copyright (c) Poul-Henning Kamp 2000-2001 * + * * + * Permission to use, copy, modify, and distribute this software and * + * its documentation for any purpose and without fee is hereby * + * granted, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission * + * notice appear in supporting documentation, and that the name * + * University of Delaware not be used in advertising or publicity * + * pertaining to distribution of the software without specific, * + * written prior permission. The University of Delaware makes no * + * representations about the suitability this software for any * + * purpose. It is provided "as is" without express or implied * + * warranty. * + * * + *********************************************************************** + * + * $FreeBSD: head/sys/sys/timex.h 298981 2016-05-03 15:14:17Z pfg $ + * + * This header file defines the Network Time Protocol (NTP) interfaces + * for user and daemon application programs. + * + * This file was originally created 17 Sep 93 by David L. Mills, Professor + * of University of Delaware, building on work which had already been ongoing + * for a decade and a half at that point in time. + * + * In 2000 the APIs got a upgrade from microseconds to nanoseconds, + * a joint work between Poul-Henning Kamp and David L. Mills. + * + */ + +#ifndef _SYS_TIMEX_H_ +#define _SYS_TIMEX_H_ 1 + +#define NTP_API 4 /* NTP API version */ + +#ifdef __FreeBSD__ +#include +#endif /* __FreeBSD__ */ + +/* + * The following defines establish the performance envelope of the + * kernel discipline loop. Phase or frequency errors greater than + * NAXPHASE or MAXFREQ are clamped to these maxima. For update intervals + * less than MINSEC, the loop always operates in PLL mode; while, for + * update intervals greater than MAXSEC, the loop always operates in FLL + * mode. Between these two limits the operating mode is selected by the + * STA_FLL bit in the status word. + */ + +#define MAXPHASE 500000000L /* max phase error (ns) */ +#define MAXFREQ 500000L /* max freq error (ns/s) */ +#define MINSEC 256 /* min FLL update interval (s) */ +#define MAXSEC 2048 /* max PLL update interval (s) */ +#define NANOSECOND 1000000000L /* nanoseconds in one second */ +#define SCALE_PPM (65536 / 1000) /* crude ns/s to scaled PPM */ +#define MAXTC 10 /* max time constant */ + +/* + * Control mode codes (timex.modes) + */ +#define MOD_OFFSET 0x0001 /* set time offset */ +#define MOD_FREQUENCY 0x0002 /* set frequency offset */ +#define MOD_MAXERROR 0x0004 /* set maximum time error */ +#define MOD_ESTERROR 0x0008 /* set estimated time error */ +#define MOD_STATUS 0x0010 /* set clock status bits */ +#define MOD_TIMECONST 0x0020 /* set PLL time constant */ +#define MOD_PPSMAX 0x0040 /* set PPS maximum averaging time */ +#define MOD_TAI 0x0080 /* set TAI offset */ +#define MOD_MICRO 0x1000 /* select microsecond resolution */ +#define MOD_NANO 0x2000 /* select nanosecond resolution */ +#define MOD_CLKB 0x4000 /* select clock B */ +#define MOD_CLKA 0x8000 /* select clock A */ + +/* + * Status codes (timex.status) + */ +#define STA_PLL 0x0001 /* enable PLL updates (rw) */ +#define STA_PPSFREQ 0x0002 /* enable PPS freq discipline (rw) */ +#define STA_PPSTIME 0x0004 /* enable PPS time discipline (rw) */ +#define STA_FLL 0x0008 /* enable FLL mode (rw) */ +#define STA_INS 0x0010 /* insert leap (rw) */ +#define STA_DEL 0x0020 /* delete leap (rw) */ +#define STA_UNSYNC 0x0040 /* clock unsynchronized (rw) */ +#define STA_FREQHOLD 0x0080 /* hold frequency (rw) */ +#define STA_PPSSIGNAL 0x0100 /* PPS signal present (ro) */ +#define STA_PPSJITTER 0x0200 /* PPS signal jitter exceeded (ro) */ +#define STA_PPSWANDER 0x0400 /* PPS signal wander exceeded (ro) */ +#define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */ +#define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */ +#define STA_NANO 0x2000 /* resolution (0 = us, 1 = ns) (ro) */ +#define STA_MODE 0x4000 /* mode (0 = PLL, 1 = FLL) (ro) */ +#define STA_CLK 0x8000 /* clock source (0 = A, 1 = B) (ro) */ + +#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \ + STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | STA_CLK) + +/* + * Clock states (ntptimeval.time_state) + */ +#define TIME_OK 0 /* no leap second warning */ +#define TIME_INS 1 /* insert leap second warning */ +#define TIME_DEL 2 /* delete leap second warning */ +#define TIME_OOP 3 /* leap second in progress */ +#define TIME_WAIT 4 /* leap second has occurred */ +#define TIME_ERROR 5 /* error (see status word) */ + +/* + * NTP user interface -- ntp_gettime(2) - used to read kernel clock values + */ +struct ntptimeval { + struct timespec time; /* current time (ns) (ro) */ + long maxerror; /* maximum error (us) (ro) */ + long esterror; /* estimated error (us) (ro) */ + long tai; /* TAI offset */ + int time_state; /* time status */ +}; + +/* + * NTP daemon interface -- ntp_adjtime(2) -- used to discipline CPU clock + * oscillator and control/determine status. + * + * Note: The offset, precision and jitter members are in microseconds if + * STA_NANO is zero and nanoseconds if not. + */ +struct timex { + unsigned int modes; /* clock mode bits (wo) */ + long offset; /* time offset (ns/us) (rw) */ + long freq; /* frequency offset (scaled PPM) (rw) */ + long maxerror; /* maximum error (us) (rw) */ + long esterror; /* estimated error (us) (rw) */ + int status; /* clock status bits (rw) */ + long constant; /* poll interval (log2 s) (rw) */ + long precision; /* clock precision (ns/us) (ro) */ + long tolerance; /* clock frequency tolerance (scaled + * PPM) (ro) */ + /* + * The following read-only structure members are implemented + * only if the PPS signal discipline is configured in the + * kernel. They are included in all configurations to insure + * portability. + */ + long ppsfreq; /* PPS frequency (scaled PPM) (ro) */ + long jitter; /* PPS jitter (ns/us) (ro) */ + int shift; /* interval duration (s) (shift) (ro) */ + long stabil; /* PPS stability (scaled PPM) (ro) */ + long jitcnt; /* jitter limit exceeded (ro) */ + long calcnt; /* calibration intervals (ro) */ + long errcnt; /* calibration errors (ro) */ + long stbcnt; /* stability limit exceeded (ro) */ +}; + +#ifdef __FreeBSD__ + +#ifdef _KERNEL +void ntp_update_second(int64_t *adjustment, time_t *newsec); +#else /* !_KERNEL */ +#include + +__BEGIN_DECLS +int ntp_adjtime(struct timex *); +int ntp_gettime(struct ntptimeval *); +__END_DECLS +#endif /* _KERNEL */ + +#endif /* __FreeBSD__ */ + +#endif /* !_SYS_TIMEX_H_ */ diff --git a/cpukit/include/sys/utsname.h b/cpukit/include/sys/utsname.h new file mode 100644 index 0000000000..ddeb0e90c2 --- /dev/null +++ b/cpukit/include/sys/utsname.h @@ -0,0 +1,76 @@ +/** + * @file + * + * @brief Interface to the POSIX utsname() Service + * + * This include file defines the interface to the POSIX utsname() service. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef __POSIX_SYS_UTSNAME_h +#define __POSIX_SYS_UTSNAME_h + +/** + * @defgroup UTSNAME utsname Service + * + * @ingroup POSIXAPI + */ +/**@{*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * 4.4.1 Get System Name (Table 4-1), P1003.1b-1993, p. 90 + * + * NOTE: The lengths of the strings in this structure are + * just long enough to reliably contain the RTEMS information. + * For example, the fields are not long enough to support + * Internet hostnames. + */ + +#ifdef _KERNEL +#define SYS_NMLN 48 /* uname(2) for the FreeBSD 1.1 ABI. */ +#endif + +#ifndef SYS_NMLN +#define SYS_NMLN 48 /* User can override. */ +#endif + +struct utsname { + char sysname[SYS_NMLN]; /* Name of this implementation of the */ + /* operating system */ + char nodename[SYS_NMLN]; /* Name of this node within an implementation */ + /* specified communication network */ + char release[SYS_NMLN]; /* Current release level of this implementation */ + char version[SYS_NMLN]; /* Current version level of this release */ + char machine[SYS_NMLN]; /* Name of the hardware type on which the system */ + /* is running */ +}; + +/** + * @brief Get system name. + * + * 4.4.1 Get System Name, P1003.1b-1993, p. 90 + */ +int uname( + struct utsname *name +); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif +/* end of include file */ diff --git a/cpukit/include/utf8proc/utf8proc.h b/cpukit/include/utf8proc/utf8proc.h new file mode 100644 index 0000000000..24a891b6c6 --- /dev/null +++ b/cpukit/include/utf8proc/utf8proc.h @@ -0,0 +1,385 @@ +/* + * Copyright (c) 2009 Public Software Group e. V., Berlin, Germany + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + + +/* + * File name: utf8proc.h + * + * Description: + * Header files for libutf8proc, which is a mapping tool for UTF-8 strings + * with following features: + * - decomposing and composing of strings + * - replacing compatibility characters with their equivalents + * - stripping of "default ignorable characters" + * like SOFT-HYPHEN or ZERO-WIDTH-SPACE + * - folding of certain characters for string comparison + * (e.g. HYPHEN U+2010 and MINUS U+2212 to ASCII "-") + * (see "LUMP" option) + * - optional rejection of strings containing non-assigned code points + * - stripping of control characters + * - stripping of character marks (accents, etc.) + * - transformation of LF, CRLF, CR and NEL to line-feed (LF) + * or to the unicode chararacters for paragraph separation (PS) + * or line separation (LS). + * - unicode case folding (for case insensitive string comparisons) + * - rejection of illegal UTF-8 data + * (i.e. UTF-8 encoded UTF-16 surrogates) + * - support for korean hangul characters + * Unicode Version 5.0.0 is supported. + */ + + +#ifndef UTF8PROC_H +#define UTF8PROC_H + + +#include +#include +#ifdef _MSC_VER +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef short int16_t; +typedef unsigned short uint16_t; +typedef int int32_t; +#ifdef _WIN64 +#define ssize_t __int64 +#else +#define ssize_t int +#endif +typedef unsigned char bool; +enum {false, true}; +#else +#include +#include +#endif +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef SSIZE_MAX +#define SSIZE_MAX ((size_t)SIZE_MAX/2) +#endif + +#define UTF8PROC_NULLTERM (1<<0) +#define UTF8PROC_STABLE (1<<1) +#define UTF8PROC_COMPAT (1<<2) +#define UTF8PROC_COMPOSE (1<<3) +#define UTF8PROC_DECOMPOSE (1<<4) +#define UTF8PROC_IGNORE (1<<5) +#define UTF8PROC_REJECTNA (1<<6) +#define UTF8PROC_NLF2LS (1<<7) +#define UTF8PROC_NLF2PS (1<<8) +#define UTF8PROC_NLF2LF (UTF8PROC_NLF2LS | UTF8PROC_NLF2PS) +#define UTF8PROC_STRIPCC (1<<9) +#define UTF8PROC_CASEFOLD (1<<10) +#define UTF8PROC_CHARBOUND (1<<11) +#define UTF8PROC_LUMP (1<<12) +#define UTF8PROC_STRIPMARK (1<<13) +/* + * Flags being regarded by several functions in the library: + * NULLTERM: The given UTF-8 input is NULL terminated. + * STABLE: Unicode Versioning Stability has to be respected. + * COMPAT: Compatiblity decomposition + * (i.e. formatting information is lost) + * COMPOSE: Return a result with composed characters. + * DECOMPOSE: Return a result with decomposed characters. + * IGNORE: Strip "default ignorable characters" + * REJECTNA: Return an error, if the input contains unassigned + * code points. + * NLF2LS: Indicating that NLF-sequences (LF, CRLF, CR, NEL) are + * representing a line break, and should be converted to the + * unicode character for line separation (LS). + * NLF2PS: Indicating that NLF-sequences are representing a paragraph + * break, and should be converted to the unicode character for + * paragraph separation (PS). + * NLF2LF: Indicating that the meaning of NLF-sequences is unknown. + * STRIPCC: Strips and/or convers control characters. + * NLF-sequences are transformed into space, except if one of + * the NLF2LS/PS/LF options is given. + * HorizontalTab (HT) and FormFeed (FF) are treated as a + * NLF-sequence in this case. + * All other control characters are simply removed. + * CASEFOLD: Performs unicode case folding, to be able to do a + * case-insensitive string comparison. + * CHARBOUND: Inserts 0xFF bytes at the beginning of each sequence which + * is representing a single grapheme cluster (see UAX#29). + * LUMP: Lumps certain characters together + * (e.g. HYPHEN U+2010 and MINUS U+2212 to ASCII "-"). + * (See lump.txt for details.) + * If NLF2LF is set, this includes a transformation of + * paragraph and line separators to ASCII line-feed (LF). + * STRIPMARK: Strips all character markings + * (non-spacing, spacing and enclosing) (i.e. accents) + * NOTE: this option works only with COMPOSE or DECOMPOSE + */ + +#define UTF8PROC_ERROR_NOMEM -1 +#define UTF8PROC_ERROR_OVERFLOW -2 +#define UTF8PROC_ERROR_INVALIDUTF8 -3 +#define UTF8PROC_ERROR_NOTASSIGNED -4 +#define UTF8PROC_ERROR_INVALIDOPTS -5 +/* + * Error codes being returned by almost all functions: + * ERROR_NOMEM: Memory could not be allocated. + * ERROR_OVERFLOW: The given string is too long to be processed. + * ERROR_INVALIDUTF8: The given string is not a legal UTF-8 string. + * ERROR_NOTASSIGNED: The REJECTNA flag was set, + * and an unassigned code point was found. + * ERROR_INVALIDOPTS: Invalid options have been used. + */ + +typedef int16_t utf8proc_propval_t; +typedef struct utf8proc_property_struct { + utf8proc_propval_t category; + utf8proc_propval_t combining_class; + utf8proc_propval_t bidi_class; + utf8proc_propval_t decomp_type; + const int32_t *decomp_mapping; + unsigned bidi_mirrored:1; + int32_t uppercase_mapping; + int32_t lowercase_mapping; + int32_t titlecase_mapping; + int32_t comb1st_index; + int32_t comb2nd_index; + unsigned comp_exclusion:1; + unsigned ignorable:1; + unsigned control_boundary:1; + unsigned extend:1; + const int32_t *casefold_mapping; +} utf8proc_property_t; + +#define UTF8PROC_CATEGORY_LU 1 +#define UTF8PROC_CATEGORY_LL 2 +#define UTF8PROC_CATEGORY_LT 3 +#define UTF8PROC_CATEGORY_LM 4 +#define UTF8PROC_CATEGORY_LO 5 +#define UTF8PROC_CATEGORY_MN 6 +#define UTF8PROC_CATEGORY_MC 7 +#define UTF8PROC_CATEGORY_ME 8 +#define UTF8PROC_CATEGORY_ND 9 +#define UTF8PROC_CATEGORY_NL 10 +#define UTF8PROC_CATEGORY_NO 11 +#define UTF8PROC_CATEGORY_PC 12 +#define UTF8PROC_CATEGORY_PD 13 +#define UTF8PROC_CATEGORY_PS 14 +#define UTF8PROC_CATEGORY_PE 15 +#define UTF8PROC_CATEGORY_PI 16 +#define UTF8PROC_CATEGORY_PF 17 +#define UTF8PROC_CATEGORY_PO 18 +#define UTF8PROC_CATEGORY_SM 19 +#define UTF8PROC_CATEGORY_SC 20 +#define UTF8PROC_CATEGORY_SK 21 +#define UTF8PROC_CATEGORY_SO 22 +#define UTF8PROC_CATEGORY_ZS 23 +#define UTF8PROC_CATEGORY_ZL 24 +#define UTF8PROC_CATEGORY_ZP 25 +#define UTF8PROC_CATEGORY_CC 26 +#define UTF8PROC_CATEGORY_CF 27 +#define UTF8PROC_CATEGORY_CS 28 +#define UTF8PROC_CATEGORY_CO 29 +#define UTF8PROC_CATEGORY_CN 30 +#define UTF8PROC_BIDI_CLASS_L 1 +#define UTF8PROC_BIDI_CLASS_LRE 2 +#define UTF8PROC_BIDI_CLASS_LRO 3 +#define UTF8PROC_BIDI_CLASS_R 4 +#define UTF8PROC_BIDI_CLASS_AL 5 +#define UTF8PROC_BIDI_CLASS_RLE 6 +#define UTF8PROC_BIDI_CLASS_RLO 7 +#define UTF8PROC_BIDI_CLASS_PDF 8 +#define UTF8PROC_BIDI_CLASS_EN 9 +#define UTF8PROC_BIDI_CLASS_ES 10 +#define UTF8PROC_BIDI_CLASS_ET 11 +#define UTF8PROC_BIDI_CLASS_AN 12 +#define UTF8PROC_BIDI_CLASS_CS 13 +#define UTF8PROC_BIDI_CLASS_NSM 14 +#define UTF8PROC_BIDI_CLASS_BN 15 +#define UTF8PROC_BIDI_CLASS_B 16 +#define UTF8PROC_BIDI_CLASS_S 17 +#define UTF8PROC_BIDI_CLASS_WS 18 +#define UTF8PROC_BIDI_CLASS_ON 19 +#define UTF8PROC_DECOMP_TYPE_FONT 1 +#define UTF8PROC_DECOMP_TYPE_NOBREAK 2 +#define UTF8PROC_DECOMP_TYPE_INITIAL 3 +#define UTF8PROC_DECOMP_TYPE_MEDIAL 4 +#define UTF8PROC_DECOMP_TYPE_FINAL 5 +#define UTF8PROC_DECOMP_TYPE_ISOLATED 6 +#define UTF8PROC_DECOMP_TYPE_CIRCLE 7 +#define UTF8PROC_DECOMP_TYPE_SUPER 8 +#define UTF8PROC_DECOMP_TYPE_SUB 9 +#define UTF8PROC_DECOMP_TYPE_VERTICAL 10 +#define UTF8PROC_DECOMP_TYPE_WIDE 11 +#define UTF8PROC_DECOMP_TYPE_NARROW 12 +#define UTF8PROC_DECOMP_TYPE_SMALL 13 +#define UTF8PROC_DECOMP_TYPE_SQUARE 14 +#define UTF8PROC_DECOMP_TYPE_FRACTION 15 +#define UTF8PROC_DECOMP_TYPE_COMPAT 16 + +extern const int8_t utf8proc_utf8class[256]; + +const char *utf8proc_version(void); + +const char *utf8proc_errmsg(ssize_t errcode); +/* + * Returns a static error string for the given error code. + */ + +ssize_t utf8proc_iterate(const uint8_t *str, ssize_t strlen, int32_t *dst); +/* + * Reads a single char from the UTF-8 sequence being pointed to by 'str'. + * The maximum number of bytes read is 'strlen', unless 'strlen' is + * negative. + * If a valid unicode char could be read, it is stored in the variable + * being pointed to by 'dst', otherwise that variable will be set to -1. + * In case of success the number of bytes read is returned, otherwise a + * negative error code is returned. + */ + +bool utf8proc_codepoint_valid(int32_t uc); +/* + * Returns 1, if the given unicode code-point is valid, otherwise 0. + */ + +ssize_t utf8proc_encode_char(int32_t uc, uint8_t *dst); +/* + * Encodes the unicode char with the code point 'uc' as an UTF-8 string in + * the byte array being pointed to by 'dst'. This array has to be at least + * 4 bytes long. + * In case of success the number of bytes written is returned, + * otherwise 0. + * This function does not check if 'uc' is a valid unicode code point. + */ + +const utf8proc_property_t *utf8proc_get_property(int32_t uc); +/* + * Returns a pointer to a (constant) struct containing information about + * the unicode char with the given code point 'uc'. + * If the character is not existent a pointer to a special struct is + * returned, where 'category' is a NULL pointer. + * WARNING: The parameter 'uc' has to be in the range of 0x0000 to + * 0x10FFFF, otherwise the program might crash! + */ + +ssize_t utf8proc_decompose_char( + int32_t uc, int32_t *dst, ssize_t bufsize, + int options, int *last_boundclass +); +/* + * Writes a decomposition of the unicode char 'uc' into the array being + * pointed to by 'dst'. + * Following flags in the 'options' field are regarded: + * REJECTNA: an unassigned unicode code point leads to an error + * IGNORE: "default ignorable" chars are stripped + * CASEFOLD: unicode casefolding is applied + * COMPAT: replace certain characters with their + * compatibility decomposition + * CHARBOUND: Inserts 0xFF bytes before each grapheme cluster + * LUMP: lumps certain different characters together + * STRIPMARK: removes all character marks + * The pointer 'last_boundclass' has to point to an integer variable which + * is storing the last character boundary class, if the CHARBOUND option + * is used. + * In case of success the number of chars written is returned, + * in case of an error, a negative error code is returned. + * If the number of written chars would be bigger than 'bufsize', + * the buffer (up to 'bufsize') has inpredictable data, and the needed + * buffer size is returned. + * WARNING: The parameter 'uc' has to be in the range of 0x0000 to + * 0x10FFFF, otherwise the program might crash! + */ + +ssize_t utf8proc_decompose( + const uint8_t *str, ssize_t strlen, + int32_t *buffer, ssize_t bufsize, int options +); +/* + * Does the same as 'utf8proc_decompose_char', but acts on a whole UTF-8 + * string, and orders the decomposed sequences correctly. + * If the NULLTERM flag in 'options' is set, processing will be stopped, + * when a NULL byte is encounted, otherwise 'strlen' bytes are processed. + * The result in form of unicode code points is written into the buffer + * being pointed to by 'buffer', having the length of 'bufsize' entries. + * In case of success the number of chars written is returned, + * in case of an error, a negative error code is returned. + * If the number of written chars would be bigger than 'bufsize', + * the buffer (up to 'bufsize') has inpredictable data, and the needed + * buffer size is returned. + */ + +ssize_t utf8proc_reencode(int32_t *buffer, ssize_t length, int options); +/* + * Reencodes the sequence of unicode characters given by the pointer + * 'buffer' and 'length' as UTF-8. + * The result is stored in the same memory area where the data is read. + * Following flags in the 'options' field are regarded: + * NLF2LS: converts LF, CRLF, CR and NEL into LS + * NLF2PS: converts LF, CRLF, CR and NEL into PS + * NLF2LF: converts LF, CRLF, CR and NEL into LF + * STRIPCC: strips or converts all non-affected control characters + * COMPOSE: tries to combine decomposed characters into composite + * characters + * STABLE: prohibits combining characters which would violate + * the unicode versioning stability + * In case of success the length of the resulting UTF-8 string is + * returned, otherwise a negative error code is returned. + * WARNING: The amount of free space being pointed to by 'buffer', has to + * exceed the amount of the input data by one byte, and the + * entries of the array pointed to by 'str' have to be in the + * range of 0x0000 to 0x10FFFF, otherwise the program might + * crash! + */ + +ssize_t utf8proc_map( + const uint8_t *str, ssize_t strlen, uint8_t **dstptr, int options +); +/* + * Maps the given UTF-8 string being pointed to by 'str' to a new UTF-8 + * string, which is allocated dynamically, and afterwards pointed to by + * the pointer being pointed to by 'dstptr'. + * If the NULLTERM flag in the 'options' field is set, the length is + * determined by a NULL terminator, otherwise the parameter 'strlen' is + * evaluated to determine the string length, but in any case the result + * will be NULL terminated (though it might contain NULL characters + * before). Other flags in the 'options' field are passed to the functions + * defined above, and regarded as described. + * In case of success the length of the new string is returned, + * otherwise a negative error code is returned. + * NOTICE: The memory of the new UTF-8 string will have been allocated with + * 'malloc', and has theirfore to be freed with 'free'. + */ + +uint8_t *utf8proc_NFD(const uint8_t *str); +uint8_t *utf8proc_NFC(const uint8_t *str); +uint8_t *utf8proc_NFKD(const uint8_t *str); +uint8_t *utf8proc_NFKC(const uint8_t *str); +/* + * Returns a pointer to newly allocated memory of a NFD, NFC, NFKD or NFKC + * normalized version of the null-terminated string 'str'. + */ + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/cpukit/include/uuid/uuid.h b/cpukit/include/uuid/uuid.h new file mode 100644 index 0000000000..ca846da0f0 --- /dev/null +++ b/cpukit/include/uuid/uuid.h @@ -0,0 +1,103 @@ +/* + * Public include file for the UUID library + * + * Copyright (C) 1996, 1997, 1998 Theodore Ts'o. + * + * %Begin-Header% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, and the entire permission notice in its entirety, + * including the disclaimer of warranties. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF + * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * %End-Header% + */ + +#ifndef _UUID_UUID_H +#define _UUID_UUID_H + +#include +#ifndef _WIN32 +#include +#endif +#include + +typedef unsigned char uuid_t[16]; + +/* UUID Variant definitions */ +#define UUID_VARIANT_NCS 0 +#define UUID_VARIANT_DCE 1 +#define UUID_VARIANT_MICROSOFT 2 +#define UUID_VARIANT_OTHER 3 + +/* UUID Type definitions */ +#define UUID_TYPE_DCE_TIME 1 +#define UUID_TYPE_DCE_RANDOM 4 + +/* Allow UUID constants to be defined */ +#ifdef __GNUC__ +#define UUID_DEFINE(name,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15) \ + static const uuid_t name __attribute__ ((unused)) = {u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15} +#else +#define UUID_DEFINE(name,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15) \ + static const uuid_t name = {u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15} +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* clear.c */ +void uuid_clear(uuid_t uu); + +/* compare.c */ +int uuid_compare(const uuid_t uu1, const uuid_t uu2); + +/* copy.c */ +void uuid_copy(uuid_t dst, const uuid_t src); + +/* gen_uuid.c */ +void uuid_generate(uuid_t out); +void uuid_generate_random(uuid_t out); +void uuid_generate_time(uuid_t out); + +/* isnull.c */ +int uuid_is_null(const uuid_t uu); + +/* parse.c */ +int uuid_parse(const char *in, uuid_t uu); + +/* unparse.c */ +void uuid_unparse(const uuid_t uu, char *out); +void uuid_unparse_lower(const uuid_t uu, char *out); +void uuid_unparse_upper(const uuid_t uu, char *out); + +/* uuid_time.c */ +time_t uuid_time(const uuid_t uu, struct timeval *ret_tv); +int uuid_type(const uuid_t uu); +int uuid_variant(const uuid_t uu); + +#ifdef __cplusplus +} +#endif + +#endif /* _UUID_UUID_H */ diff --git a/cpukit/include/xz.h b/cpukit/include/xz.h new file mode 100644 index 0000000000..0a4b38d33c --- /dev/null +++ b/cpukit/include/xz.h @@ -0,0 +1,304 @@ +/* + * XZ decompressor + * + * Authors: Lasse Collin + * Igor Pavlov + * + * This file has been put into the public domain. + * You can do whatever you want with this file. + */ + +#ifndef XZ_H +#define XZ_H + +#ifdef __KERNEL__ +# include +# include +#else +# include +# include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* In Linux, this is used to make extern functions static when needed. */ +#ifndef XZ_EXTERN +# define XZ_EXTERN extern +#endif + +/** + * enum xz_mode - Operation mode + * + * @XZ_SINGLE: Single-call mode. This uses less RAM than + * than multi-call modes, because the LZMA2 + * dictionary doesn't need to be allocated as + * part of the decoder state. All required data + * structures are allocated at initialization, + * so xz_dec_run() cannot return XZ_MEM_ERROR. + * @XZ_PREALLOC: Multi-call mode with preallocated LZMA2 + * dictionary buffer. All data structures are + * allocated at initialization, so xz_dec_run() + * cannot return XZ_MEM_ERROR. + * @XZ_DYNALLOC: Multi-call mode. The LZMA2 dictionary is + * allocated once the required size has been + * parsed from the stream headers. If the + * allocation fails, xz_dec_run() will return + * XZ_MEM_ERROR. + * + * It is possible to enable support only for a subset of the above + * modes at compile time by defining XZ_DEC_SINGLE, XZ_DEC_PREALLOC, + * or XZ_DEC_DYNALLOC. The xz_dec kernel module is always compiled + * with support for all operation modes, but the preboot code may + * be built with fewer features to minimize code size. + */ +enum xz_mode { + XZ_SINGLE, + XZ_PREALLOC, + XZ_DYNALLOC +}; + +/** + * enum xz_ret - Return codes + * @XZ_OK: Everything is OK so far. More input or more + * output space is required to continue. This + * return code is possible only in multi-call mode + * (XZ_PREALLOC or XZ_DYNALLOC). + * @XZ_STREAM_END: Operation finished successfully. + * @XZ_UNSUPPORTED_CHECK: Integrity check type is not supported. Decoding + * is still possible in multi-call mode by simply + * calling xz_dec_run() again. + * Note that this return value is used only if + * XZ_DEC_ANY_CHECK was defined at build time, + * which is not used in the kernel. Unsupported + * check types return XZ_OPTIONS_ERROR if + * XZ_DEC_ANY_CHECK was not defined at build time. + * @XZ_MEM_ERROR: Allocating memory failed. This return code is + * possible only if the decoder was initialized + * with XZ_DYNALLOC. The amount of memory that was + * tried to be allocated was no more than the + * dict_max argument given to xz_dec_init(). + * @XZ_MEMLIMIT_ERROR: A bigger LZMA2 dictionary would be needed than + * allowed by the dict_max argument given to + * xz_dec_init(). This return value is possible + * only in multi-call mode (XZ_PREALLOC or + * XZ_DYNALLOC); the single-call mode (XZ_SINGLE) + * ignores the dict_max argument. + * @XZ_FORMAT_ERROR: File format was not recognized (wrong magic + * bytes). + * @XZ_OPTIONS_ERROR: This implementation doesn't support the requested + * compression options. In the decoder this means + * that the header CRC32 matches, but the header + * itself specifies something that we don't support. + * @XZ_DATA_ERROR: Compressed data is corrupt. + * @XZ_BUF_ERROR: Cannot make any progress. Details are slightly + * different between multi-call and single-call + * mode; more information below. + * + * In multi-call mode, XZ_BUF_ERROR is returned when two consecutive calls + * to XZ code cannot consume any input and cannot produce any new output. + * This happens when there is no new input available, or the output buffer + * is full while at least one output byte is still pending. Assuming your + * code is not buggy, you can get this error only when decoding a compressed + * stream that is truncated or otherwise corrupt. + * + * In single-call mode, XZ_BUF_ERROR is returned only when the output buffer + * is too small or the compressed input is corrupt in a way that makes the + * decoder produce more output than the caller expected. When it is + * (relatively) clear that the compressed input is truncated, XZ_DATA_ERROR + * is used instead of XZ_BUF_ERROR. + */ +enum xz_ret { + XZ_OK, + XZ_STREAM_END, + XZ_UNSUPPORTED_CHECK, + XZ_MEM_ERROR, + XZ_MEMLIMIT_ERROR, + XZ_FORMAT_ERROR, + XZ_OPTIONS_ERROR, + XZ_DATA_ERROR, + XZ_BUF_ERROR +}; + +/** + * struct xz_buf - Passing input and output buffers to XZ code + * @in: Beginning of the input buffer. This may be NULL if and only + * if in_pos is equal to in_size. + * @in_pos: Current position in the input buffer. This must not exceed + * in_size. + * @in_size: Size of the input buffer + * @out: Beginning of the output buffer. This may be NULL if and only + * if out_pos is equal to out_size. + * @out_pos: Current position in the output buffer. This must not exceed + * out_size. + * @out_size: Size of the output buffer + * + * Only the contents of the output buffer from out[out_pos] onward, and + * the variables in_pos and out_pos are modified by the XZ code. + */ +struct xz_buf { + const uint8_t *in; + size_t in_pos; + size_t in_size; + + uint8_t *out; + size_t out_pos; + size_t out_size; +}; + +/** + * struct xz_dec - Opaque type to hold the XZ decoder state + */ +struct xz_dec; + +/** + * xz_dec_init() - Allocate and initialize a XZ decoder state + * @mode: Operation mode + * @dict_max: Maximum size of the LZMA2 dictionary (history buffer) for + * multi-call decoding. This is ignored in single-call mode + * (mode == XZ_SINGLE). LZMA2 dictionary is always 2^n bytes + * or 2^n + 2^(n-1) bytes (the latter sizes are less common + * in practice), so other values for dict_max don't make sense. + * In the kernel, dictionary sizes of 64 KiB, 128 KiB, 256 KiB, + * 512 KiB, and 1 MiB are probably the only reasonable values, + * except for kernel and initramfs images where a bigger + * dictionary can be fine and useful. + * + * Single-call mode (XZ_SINGLE): xz_dec_run() decodes the whole stream at + * once. The caller must provide enough output space or the decoding will + * fail. The output space is used as the dictionary buffer, which is why + * there is no need to allocate the dictionary as part of the decoder's + * internal state. + * + * Because the output buffer is used as the workspace, streams encoded using + * a big dictionary are not a problem in single-call mode. It is enough that + * the output buffer is big enough to hold the actual uncompressed data; it + * can be smaller than the dictionary size stored in the stream headers. + * + * Multi-call mode with preallocated dictionary (XZ_PREALLOC): dict_max bytes + * of memory is preallocated for the LZMA2 dictionary. This way there is no + * risk that xz_dec_run() could run out of memory, since xz_dec_run() will + * never allocate any memory. Instead, if the preallocated dictionary is too + * small for decoding the given input stream, xz_dec_run() will return + * XZ_MEMLIMIT_ERROR. Thus, it is important to know what kind of data will be + * decoded to avoid allocating excessive amount of memory for the dictionary. + * + * Multi-call mode with dynamically allocated dictionary (XZ_DYNALLOC): + * dict_max specifies the maximum allowed dictionary size that xz_dec_run() + * may allocate once it has parsed the dictionary size from the stream + * headers. This way excessive allocations can be avoided while still + * limiting the maximum memory usage to a sane value to prevent running the + * system out of memory when decompressing streams from untrusted sources. + * + * On success, xz_dec_init() returns a pointer to struct xz_dec, which is + * ready to be used with xz_dec_run(). If memory allocation fails, + * xz_dec_init() returns NULL. + */ +XZ_EXTERN struct xz_dec *xz_dec_init(enum xz_mode mode, uint32_t dict_max); + +/** + * xz_dec_run() - Run the XZ decoder + * @s: Decoder state allocated using xz_dec_init() + * @b: Input and output buffers + * + * The possible return values depend on build options and operation mode. + * See enum xz_ret for details. + * + * Note that if an error occurs in single-call mode (return value is not + * XZ_STREAM_END), b->in_pos and b->out_pos are not modified and the + * contents of the output buffer from b->out[b->out_pos] onward are + * undefined. This is true even after XZ_BUF_ERROR, because with some filter + * chains, there may be a second pass over the output buffer, and this pass + * cannot be properly done if the output buffer is truncated. Thus, you + * cannot give the single-call decoder a too small buffer and then expect to + * get that amount valid data from the beginning of the stream. You must use + * the multi-call decoder if you don't want to uncompress the whole stream. + */ +XZ_EXTERN enum xz_ret xz_dec_run(struct xz_dec *s, struct xz_buf *b); + +/** + * xz_dec_reset() - Reset an already allocated decoder state + * @s: Decoder state allocated using xz_dec_init() + * + * This function can be used to reset the multi-call decoder state without + * freeing and reallocating memory with xz_dec_end() and xz_dec_init(). + * + * In single-call mode, xz_dec_reset() is always called in the beginning of + * xz_dec_run(). Thus, explicit call to xz_dec_reset() is useful only in + * multi-call mode. + */ +XZ_EXTERN void xz_dec_reset(struct xz_dec *s); + +/** + * xz_dec_end() - Free the memory allocated for the decoder state + * @s: Decoder state allocated using xz_dec_init(). If s is NULL, + * this function does nothing. + */ +XZ_EXTERN void xz_dec_end(struct xz_dec *s); + +/* + * Standalone build (userspace build or in-kernel build for boot time use) + * needs a CRC32 implementation. For normal in-kernel use, kernel's own + * CRC32 module is used instead, and users of this module don't need to + * care about the functions below. + */ +#ifndef XZ_INTERNAL_CRC32 +# ifdef __KERNEL__ +# define XZ_INTERNAL_CRC32 0 +# else +# define XZ_INTERNAL_CRC32 1 +# endif +#endif + +/* + * If CRC64 support has been enabled with XZ_USE_CRC64, a CRC64 + * implementation is needed too. + */ +#ifndef XZ_USE_CRC64 +# undef XZ_INTERNAL_CRC64 +# define XZ_INTERNAL_CRC64 0 +#endif +#ifndef XZ_INTERNAL_CRC64 +# ifdef __KERNEL__ +# error Using CRC64 in the kernel has not been implemented. +# else +# define XZ_INTERNAL_CRC64 1 +# endif +#endif + +#if XZ_INTERNAL_CRC32 +/* + * This must be called before any other xz_* function to initialize + * the CRC32 lookup table. + */ +XZ_EXTERN void xz_crc32_init(void); + +/* + * Update CRC32 value using the polynomial from IEEE-802.3. To start a new + * calculation, the third argument must be zero. To continue the calculation, + * the previously returned value is passed as the third argument. + */ +XZ_EXTERN uint32_t xz_crc32(const uint8_t *buf, size_t size, uint32_t crc); +#endif + +#if XZ_INTERNAL_CRC64 +/* + * This must be called before any other xz_* function (except xz_crc32_init()) + * to initialize the CRC64 lookup table. + */ +XZ_EXTERN void xz_crc64_init(void); + +/* + * Update CRC64 value using the polynomial from ECMA-182. To start a new + * calculation, the third argument must be zero. To continue the calculation, + * the previously returned value is passed as the third argument. + */ +XZ_EXTERN uint64_t xz_crc64(const uint8_t *buf, size_t size, uint64_t crc); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/include/zlib.h b/cpukit/include/zlib.h new file mode 100644 index 0000000000..bfbba83e8e --- /dev/null +++ b/cpukit/include/zlib.h @@ -0,0 +1,1613 @@ +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.2.5, April 19th, 2010 + + Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + + + The data format used by the zlib library is described by RFCs (Request for + Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt + (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). +*/ + +#ifndef ZLIB_H +#define ZLIB_H + +#include "zconf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ZLIB_VERSION "1.2.5" +#define ZLIB_VERNUM 0x1250 +#define ZLIB_VER_MAJOR 1 +#define ZLIB_VER_MINOR 2 +#define ZLIB_VER_REVISION 5 +#define ZLIB_VER_SUBREVISION 0 + +/* + The 'zlib' compression library provides in-memory compression and + decompression functions, including integrity checks of the uncompressed data. + This version of the library supports only one compression method (deflation) + but other algorithms will be added later and will have the same stream + interface. + + Compression can be done in a single step if the buffers are large enough, + or can be done by repeated calls of the compression function. In the latter + case, the application must provide more input and/or consume the output + (providing more output space) before each call. + + The compressed data format used by default by the in-memory functions is + the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped + around a deflate stream, which is itself documented in RFC 1951. + + The library also supports reading and writing files in gzip (.gz) format + with an interface similar to that of stdio using the functions that start + with "gz". The gzip format is different from the zlib format. gzip is a + gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. + + This library can optionally read and write gzip streams in memory as well. + + The zlib format was designed to be compact and fast for use in memory + and on communications channels. The gzip format was designed for single- + file compression on file systems, has a larger header than zlib to maintain + directory information, and uses a different, slower check method than zlib. + + The library does not install any signal handler. The decoder checks + the consistency of the compressed data, so the library should never crash + even in case of corrupted input. +*/ + +typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); +typedef void (*free_func) OF((voidpf opaque, voidpf address)); + +struct internal_state; + +typedef struct z_stream_s { + Bytef *next_in; /* next input byte */ + uInt avail_in; /* number of bytes available at next_in */ + uLong total_in; /* total nb of input bytes read so far */ + + Bytef *next_out; /* next output byte should be put there */ + uInt avail_out; /* remaining free space at next_out */ + uLong total_out; /* total nb of bytes output so far */ + + char *msg; /* last error message, NULL if no error */ + struct internal_state FAR *state; /* not visible by applications */ + + alloc_func zalloc; /* used to allocate the internal state */ + free_func zfree; /* used to free the internal state */ + voidpf opaque; /* private data object passed to zalloc and zfree */ + + int data_type; /* best guess about the data type: binary or text */ + uLong adler; /* adler32 value of the uncompressed data */ + uLong reserved; /* reserved for future use */ +} z_stream; + +typedef z_stream FAR *z_streamp; + +/* + gzip header information passed to and from zlib routines. See RFC 1952 + for more details on the meanings of these fields. +*/ +typedef struct gz_header_s { + int text; /* true if compressed data believed to be text */ + uLong time; /* modification time */ + int xflags; /* extra flags (not used when writing a gzip file) */ + int os; /* operating system */ + Bytef *extra; /* pointer to extra field or Z_NULL if none */ + uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ + uInt extra_max; /* space at extra (only when reading header) */ + Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ + uInt name_max; /* space at name (only when reading header) */ + Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ + uInt comm_max; /* space at comment (only when reading header) */ + int hcrc; /* true if there was or will be a header crc */ + int done; /* true when done reading gzip header (not used + when writing a gzip file) */ +} gz_header; + +typedef gz_header FAR *gz_headerp; + +/* + The application must update next_in and avail_in when avail_in has dropped + to zero. It must update next_out and avail_out when avail_out has dropped + to zero. The application must initialize zalloc, zfree and opaque before + calling the init function. All other fields are set by the compression + library and must not be updated by the application. + + The opaque value provided by the application will be passed as the first + parameter for calls of zalloc and zfree. This can be useful for custom + memory management. The compression library attaches no meaning to the + opaque value. + + zalloc must return Z_NULL if there is not enough memory for the object. + If zlib is used in a multi-threaded application, zalloc and zfree must be + thread safe. + + On 16-bit systems, the functions zalloc and zfree must be able to allocate + exactly 65536 bytes, but will not be required to allocate more than this if + the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers + returned by zalloc for objects of exactly 65536 bytes *must* have their + offset normalized to zero. The default allocation function provided by this + library ensures this (see zutil.c). To reduce memory requirements and avoid + any allocation of 64K objects, at the expense of compression ratio, compile + the library with -DMAX_WBITS=14 (see zconf.h). + + The fields total_in and total_out can be used for statistics or progress + reports. After compression, total_in holds the total size of the + uncompressed data and may be saved for use in the decompressor (particularly + if the decompressor wants to decompress everything in a single step). +*/ + + /* constants */ + +#define Z_NO_FLUSH 0 +#define Z_PARTIAL_FLUSH 1 +#define Z_SYNC_FLUSH 2 +#define Z_FULL_FLUSH 3 +#define Z_FINISH 4 +#define Z_BLOCK 5 +#define Z_TREES 6 +/* Allowed flush values; see deflate() and inflate() below for details */ + +#define Z_OK 0 +#define Z_STREAM_END 1 +#define Z_NEED_DICT 2 +#define Z_ERRNO (-1) +#define Z_STREAM_ERROR (-2) +#define Z_DATA_ERROR (-3) +#define Z_MEM_ERROR (-4) +#define Z_BUF_ERROR (-5) +#define Z_VERSION_ERROR (-6) +/* Return codes for the compression/decompression functions. Negative values + * are errors, positive values are used for special but normal events. + */ + +#define Z_NO_COMPRESSION 0 +#define Z_BEST_SPEED 1 +#define Z_BEST_COMPRESSION 9 +#define Z_DEFAULT_COMPRESSION (-1) +/* compression levels */ + +#define Z_FILTERED 1 +#define Z_HUFFMAN_ONLY 2 +#define Z_RLE 3 +#define Z_FIXED 4 +#define Z_DEFAULT_STRATEGY 0 +/* compression strategy; see deflateInit2() below for details */ + +#define Z_BINARY 0 +#define Z_TEXT 1 +#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ +#define Z_UNKNOWN 2 +/* Possible values of the data_type field (though see inflate()) */ + +#define Z_DEFLATED 8 +/* The deflate compression method (the only one supported in this version) */ + +#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ + +#define zlib_version zlibVersion() +/* for compatibility with versions < 1.0.2 */ + + + /* basic functions */ + +ZEXTERN const char * ZEXPORT zlibVersion OF((void)); +/* The application can compare zlibVersion and ZLIB_VERSION for consistency. + If the first character differs, the library code actually used is not + compatible with the zlib.h header file used by the application. This check + is automatically made by deflateInit and inflateInit. + */ + +/* +ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); + + Initializes the internal stream state for compression. The fields + zalloc, zfree and opaque must be initialized before by the caller. If + zalloc and zfree are set to Z_NULL, deflateInit updates them to use default + allocation functions. + + The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: + 1 gives best speed, 9 gives best compression, 0 gives no compression at all + (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION + requests a default compromise between speed and compression (currently + equivalent to level 6). + + deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if level is not a valid compression level, or + Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible + with the version assumed by the caller (ZLIB_VERSION). msg is set to null + if there is no error message. deflateInit does not perform any compression: + this will be done by deflate(). +*/ + + +ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); +/* + deflate compresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce + some output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. deflate performs one or both of the + following actions: + + - Compress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in and avail_in are updated and + processing will resume at this point for the next call of deflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. This action is forced if the parameter flush is non zero. + Forcing flush frequently degrades the compression ratio, so this parameter + should be set only when necessary (in interactive applications). Some + output may be provided even if flush is not set. + + Before the call of deflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming more + output, and updating avail_in or avail_out accordingly; avail_out should + never be zero before the call. The application can consume the compressed + output when it wants, for example when the output buffer is full (avail_out + == 0), or after each call of deflate(). If deflate returns Z_OK and with + zero avail_out, it must be called again after making room in the output + buffer because there might be more output pending. + + Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to + decide how much data to accumulate before producing output, in order to + maximize compression. + + If the parameter flush is set to Z_SYNC_FLUSH, all pending output is + flushed to the output buffer and the output is aligned on a byte boundary, so + that the decompressor can get all input data available so far. (In + particular avail_in is zero after the call if enough output space has been + provided before the call.) Flushing may degrade compression for some + compression algorithms and so it should be used only when necessary. This + completes the current deflate block and follows it with an empty stored block + that is three bits plus filler bits to the next byte, followed by four bytes + (00 00 ff ff). + + If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the + output buffer, but the output is not aligned to a byte boundary. All of the + input data so far will be available to the decompressor, as for Z_SYNC_FLUSH. + This completes the current deflate block and follows it with an empty fixed + codes block that is 10 bits long. This assures that enough bytes are output + in order for the decompressor to finish the block before the empty fixed code + block. + + If flush is set to Z_BLOCK, a deflate block is completed and emitted, as + for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to + seven bits of the current block are held to be written as the next byte after + the next deflate block is completed. In this case, the decompressor may not + be provided enough bits at this point in order to complete decompression of + the data provided so far to the compressor. It may need to wait for the next + block to be emitted. This is for advanced applications that need to control + the emission of deflate blocks. + + If flush is set to Z_FULL_FLUSH, all output is flushed as with + Z_SYNC_FLUSH, and the compression state is reset so that decompression can + restart from this point if previous compressed data has been damaged or if + random access is desired. Using Z_FULL_FLUSH too often can seriously degrade + compression. + + If deflate returns with avail_out == 0, this function must be called again + with the same value of the flush parameter and more output space (updated + avail_out), until the flush is complete (deflate returns with non-zero + avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that + avail_out is greater than six to avoid repeated flush markers due to + avail_out == 0 on return. + + If the parameter flush is set to Z_FINISH, pending input is processed, + pending output is flushed and deflate returns with Z_STREAM_END if there was + enough output space; if deflate returns with Z_OK, this function must be + called again with Z_FINISH and more output space (updated avail_out) but no + more input data, until it returns with Z_STREAM_END or an error. After + deflate has returned Z_STREAM_END, the only possible operations on the stream + are deflateReset or deflateEnd. + + Z_FINISH can be used immediately after deflateInit if all the compression + is to be done in a single step. In this case, avail_out must be at least the + value returned by deflateBound (see below). If deflate does not return + Z_STREAM_END, then it must be called again as described above. + + deflate() sets strm->adler to the adler32 checksum of all input read + so far (that is, total_in bytes). + + deflate() may update strm->data_type if it can make a good guess about + the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered + binary. This field is only for information purposes and does not affect the + compression algorithm in any manner. + + deflate() returns Z_OK if some progress has been made (more input + processed or more output produced), Z_STREAM_END if all input has been + consumed and all output has been produced (only when flush is set to + Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example + if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible + (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not + fatal, and deflate() can be called again with more input and more output + space to continue compressing. +*/ + + +ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any pending + output. + + deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the + stream state was inconsistent, Z_DATA_ERROR if the stream was freed + prematurely (some input or output was discarded). In the error case, msg + may be set but then points to a static string (which must not be + deallocated). +*/ + + +/* +ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); + + Initializes the internal stream state for decompression. The fields + next_in, avail_in, zalloc, zfree and opaque must be initialized before by + the caller. If next_in is not Z_NULL and avail_in is large enough (the + exact value depends on the compression method), inflateInit determines the + compression method from the zlib header and allocates all data structures + accordingly; otherwise the allocation will be deferred to the first call of + inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to + use default allocation functions. + + inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller, or Z_STREAM_ERROR if the parameters are + invalid, such as a null pointer to the structure. msg is set to null if + there is no error message. inflateInit does not perform any decompression + apart from possibly reading the zlib header if present: actual decompression + will be done by inflate(). (So next_in and avail_in may be modified, but + next_out and avail_out are unused and unchanged.) The current implementation + of inflateInit() does not process any header information -- that is deferred + until inflate() is called. +*/ + + +ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); +/* + inflate decompresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce + some output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. inflate performs one or both of the + following actions: + + - Decompress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in is updated and processing will + resume at this point for the next call of inflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. inflate() provides as much output as possible, until there is + no more input data or no more space in the output buffer (see below about + the flush parameter). + + Before the call of inflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming more + output, and updating the next_* and avail_* values accordingly. The + application can consume the uncompressed output when it wants, for example + when the output buffer is full (avail_out == 0), or after each call of + inflate(). If inflate returns Z_OK and with zero avail_out, it must be + called again after making room in the output buffer because there might be + more output pending. + + The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH, + Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much + output as possible to the output buffer. Z_BLOCK requests that inflate() + stop if and when it gets to the next deflate block boundary. When decoding + the zlib or gzip format, this will cause inflate() to return immediately + after the header and before the first block. When doing a raw inflate, + inflate() will go ahead and process the first block, and will return when it + gets to the end of that block, or when it runs out of data. + + The Z_BLOCK option assists in appending to or combining deflate streams. + Also to assist in this, on return inflate() will set strm->data_type to the + number of unused bits in the last byte taken from strm->next_in, plus 64 if + inflate() is currently decoding the last block in the deflate stream, plus + 128 if inflate() returned immediately after decoding an end-of-block code or + decoding the complete header up to just before the first byte of the deflate + stream. The end-of-block will not be indicated until all of the uncompressed + data from that block has been written to strm->next_out. The number of + unused bits may in general be greater than seven, except when bit 7 of + data_type is set, in which case the number of unused bits will be less than + eight. data_type is set as noted here every time inflate() returns for all + flush options, and so can be used to determine the amount of currently + consumed input in bits. + + The Z_TREES option behaves as Z_BLOCK does, but it also returns when the + end of each deflate block header is reached, before any actual data in that + block is decoded. This allows the caller to determine the length of the + deflate block header for later use in random access within a deflate block. + 256 is added to the value of strm->data_type when inflate() returns + immediately after reaching the end of the deflate block header. + + inflate() should normally be called until it returns Z_STREAM_END or an + error. However if all decompression is to be performed in a single step (a + single call of inflate), the parameter flush should be set to Z_FINISH. In + this case all pending input is processed and all pending output is flushed; + avail_out must be large enough to hold all the uncompressed data. (The size + of the uncompressed data may have been saved by the compressor for this + purpose.) The next operation on this stream must be inflateEnd to deallocate + the decompression state. The use of Z_FINISH is never required, but can be + used to inform inflate that a faster approach may be used for the single + inflate() call. + + In this implementation, inflate() always flushes as much output as + possible to the output buffer, and always uses the faster approach on the + first call. So the only effect of the flush parameter in this implementation + is on the return value of inflate(), as noted below, or when it returns early + because Z_BLOCK or Z_TREES is used. + + If a preset dictionary is needed after this call (see inflateSetDictionary + below), inflate sets strm->adler to the adler32 checksum of the dictionary + chosen by the compressor and returns Z_NEED_DICT; otherwise it sets + strm->adler to the adler32 checksum of all output produced so far (that is, + total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described + below. At the end of the stream, inflate() checks that its computed adler32 + checksum is equal to that saved by the compressor and returns Z_STREAM_END + only if the checksum is correct. + + inflate() can decompress and check either zlib-wrapped or gzip-wrapped + deflate data. The header type is detected automatically, if requested when + initializing with inflateInit2(). Any information contained in the gzip + header is not retained, so applications that need that information should + instead use raw inflate, see inflateInit2() below, or inflateBack() and + perform their own processing of the gzip header and trailer. + + inflate() returns Z_OK if some progress has been made (more input processed + or more output produced), Z_STREAM_END if the end of the compressed data has + been reached and all uncompressed output has been produced, Z_NEED_DICT if a + preset dictionary is needed at this point, Z_DATA_ERROR if the input data was + corrupted (input stream not conforming to the zlib format or incorrect check + value), Z_STREAM_ERROR if the stream structure was inconsistent (for example + next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory, + Z_BUF_ERROR if no progress is possible or if there was not enough room in the + output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and + inflate() can be called again with more input and more output space to + continue decompressing. If Z_DATA_ERROR is returned, the application may + then call inflateSync() to look for a good compression block if a partial + recovery of the data is desired. +*/ + + +ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any pending + output. + + inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state + was inconsistent. In the error case, msg may be set but then points to a + static string (which must not be deallocated). +*/ + + + /* Advanced functions */ + +/* + The following functions are needed only in some special applications. +*/ + +/* +ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy)); + + This is another version of deflateInit with more compression options. The + fields next_in, zalloc, zfree and opaque must be initialized before by the + caller. + + The method parameter is the compression method. It must be Z_DEFLATED in + this version of the library. + + The windowBits parameter is the base two logarithm of the window size + (the size of the history buffer). It should be in the range 8..15 for this + version of the library. Larger values of this parameter result in better + compression at the expense of memory usage. The default value is 15 if + deflateInit is used instead. + + windowBits can also be -8..-15 for raw deflate. In this case, -windowBits + determines the window size. deflate() will then generate raw deflate data + with no zlib header or trailer, and will not compute an adler32 check value. + + windowBits can also be greater than 15 for optional gzip encoding. Add + 16 to windowBits to write a simple gzip header and trailer around the + compressed data instead of a zlib wrapper. The gzip header will have no + file name, no extra data, no comment, no modification time (set to zero), no + header crc, and the operating system will be set to 255 (unknown). If a + gzip stream is being written, strm->adler is a crc32 instead of an adler32. + + The memLevel parameter specifies how much memory should be allocated + for the internal compression state. memLevel=1 uses minimum memory but is + slow and reduces compression ratio; memLevel=9 uses maximum memory for + optimal speed. The default value is 8. See zconf.h for total memory usage + as a function of windowBits and memLevel. + + The strategy parameter is used to tune the compression algorithm. Use the + value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a + filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no + string match), or Z_RLE to limit match distances to one (run-length + encoding). Filtered data consists mostly of small values with a somewhat + random distribution. In this case, the compression algorithm is tuned to + compress them better. The effect of Z_FILTERED is to force more Huffman + coding and less string matching; it is somewhat intermediate between + Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as + fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The + strategy parameter only affects the compression ratio but not the + correctness of the compressed output even if it is not set appropriately. + Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler + decoder for special applications. + + deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid + method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is + incompatible with the version assumed by the caller (ZLIB_VERSION). msg is + set to null if there is no error message. deflateInit2 does not perform any + compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the compression dictionary from the given byte sequence + without producing any compressed output. This function must be called + immediately after deflateInit, deflateInit2 or deflateReset, before any call + of deflate. The compressor and decompressor must use exactly the same + dictionary (see inflateSetDictionary). + + The dictionary should consist of strings (byte sequences) that are likely + to be encountered later in the data to be compressed, with the most commonly + used strings preferably put towards the end of the dictionary. Using a + dictionary is most useful when the data to be compressed is short and can be + predicted with good accuracy; the data can then be compressed better than + with the default empty dictionary. + + Depending on the size of the compression data structures selected by + deflateInit or deflateInit2, a part of the dictionary may in effect be + discarded, for example if the dictionary is larger than the window size + provided in deflateInit or deflateInit2. Thus the strings most likely to be + useful should be put at the end of the dictionary, not at the front. In + addition, the current implementation of deflate will use at most the window + size minus 262 bytes of the provided dictionary. + + Upon return of this function, strm->adler is set to the adler32 value + of the dictionary; the decompressor may later use this value to determine + which dictionary has been used by the compressor. (The adler32 value + applies to the whole dictionary even if only a subset of the dictionary is + actually used by the compressor.) If a raw deflate was requested, then the + adler32 value is not computed and strm->adler is not set. + + deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a + parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is + inconsistent (for example if deflate has already been called for this stream + or if the compression method is bsort). deflateSetDictionary does not + perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when several compression strategies will be + tried, for example when there are several ways of pre-processing the input + data with a filter. The streams that will be discarded should then be freed + by calling deflateEnd. Note that deflateCopy duplicates the internal + compression state which can be quite large, so this strategy is slow and can + consume lots of memory. + + deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being Z_NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); +/* + This function is equivalent to deflateEnd followed by deflateInit, + but does not free and reallocate all the internal compression state. The + stream will keep the same compression level and any other attributes that + may have been set by deflateInit2. + + deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL). +*/ + +ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, + int level, + int strategy)); +/* + Dynamically update the compression level and compression strategy. The + interpretation of level and strategy is as in deflateInit2. This can be + used to switch between compression and straight copy of the input data, or + to switch to a different kind of input data requiring a different strategy. + If the compression level is changed, the input available so far is + compressed with the old level (and may be flushed); the new level will take + effect only at the next call of deflate(). + + Before the call of deflateParams, the stream state must be set as for + a call of deflate(), since the currently available input may have to be + compressed and flushed. In particular, strm->avail_out must be non-zero. + + deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source + stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if + strm->avail_out was zero. +*/ + +ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, + int good_length, + int max_lazy, + int nice_length, + int max_chain)); +/* + Fine tune deflate's internal compression parameters. This should only be + used by someone who understands the algorithm used by zlib's deflate for + searching for the best matching string, and even then only by the most + fanatic optimizer trying to squeeze out the last compressed bit for their + specific input data. Read the deflate.c source code for the meaning of the + max_lazy, good_length, nice_length, and max_chain parameters. + + deflateTune() can be called after deflateInit() or deflateInit2(), and + returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. + */ + +ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, + uLong sourceLen)); +/* + deflateBound() returns an upper bound on the compressed size after + deflation of sourceLen bytes. It must be called after deflateInit() or + deflateInit2(), and after deflateSetHeader(), if used. This would be used + to allocate an output buffer for deflation in a single pass, and so would be + called before deflate(). +*/ + +ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + deflatePrime() inserts bits in the deflate output stream. The intent + is that this function is used to start off the deflate output with the bits + leftover from a previous deflate stream when appending to it. As such, this + function can only be used for raw deflate, and must be used before the first + deflate() call after a deflateInit2() or deflateReset(). bits must be less + than or equal to 16, and that many of the least significant bits of value + will be inserted in the output. + + deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, + gz_headerp head)); +/* + deflateSetHeader() provides gzip header information for when a gzip + stream is requested by deflateInit2(). deflateSetHeader() may be called + after deflateInit2() or deflateReset() and before the first call of + deflate(). The text, time, os, extra field, name, and comment information + in the provided gz_header structure are written to the gzip header (xflag is + ignored -- the extra flags are set according to the compression level). The + caller must assure that, if not Z_NULL, name and comment are terminated with + a zero byte, and that if extra is not Z_NULL, that extra_len bytes are + available there. If hcrc is true, a gzip header crc is included. Note that + the current versions of the command-line version of gzip (up through version + 1.3.x) do not support header crc's, and will report that it is a "multi-part + gzip file" and give up. + + If deflateSetHeader is not used, the default gzip header has text false, + the time set to zero, and os set to 255, with no extra, name, or comment + fields. The gzip header is returned to the default state by deflateReset(). + + deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, + int windowBits)); + + This is another version of inflateInit with an extra parameter. The + fields next_in, avail_in, zalloc, zfree and opaque must be initialized + before by the caller. + + The windowBits parameter is the base two logarithm of the maximum window + size (the size of the history buffer). It should be in the range 8..15 for + this version of the library. The default value is 15 if inflateInit is used + instead. windowBits must be greater than or equal to the windowBits value + provided to deflateInit2() while compressing, or it must be equal to 15 if + deflateInit2() was not used. If a compressed stream with a larger window + size is given as input, inflate() will return with the error code + Z_DATA_ERROR instead of trying to allocate a larger window. + + windowBits can also be zero to request that inflate use the window size in + the zlib header of the compressed stream. + + windowBits can also be -8..-15 for raw inflate. In this case, -windowBits + determines the window size. inflate() will then process raw deflate data, + not looking for a zlib or gzip header, not generating a check value, and not + looking for any check values for comparison at the end of the stream. This + is for use with other formats that use the deflate compressed data format + such as zip. Those formats provide their own check values. If a custom + format is developed using the raw deflate format for compressed data, it is + recommended that a check value such as an adler32 or a crc32 be applied to + the uncompressed data as is done in the zlib, gzip, and zip formats. For + most applications, the zlib format should be used as is. Note that comments + above on the use in deflateInit2() applies to the magnitude of windowBits. + + windowBits can also be greater than 15 for optional gzip decoding. Add + 32 to windowBits to enable zlib and gzip decoding with automatic header + detection, or add 16 to decode only the gzip format (the zlib format will + return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a + crc32 instead of an adler32. + + inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller, or Z_STREAM_ERROR if the parameters are + invalid, such as a null pointer to the structure. msg is set to null if + there is no error message. inflateInit2 does not perform any decompression + apart from possibly reading the zlib header if present: actual decompression + will be done by inflate(). (So next_in and avail_in may be modified, but + next_out and avail_out are unused and unchanged.) The current implementation + of inflateInit2() does not process any header information -- that is + deferred until inflate() is called. +*/ + +ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the decompression dictionary from the given uncompressed byte + sequence. This function must be called immediately after a call of inflate, + if that call returned Z_NEED_DICT. The dictionary chosen by the compressor + can be determined from the adler32 value returned by that call of inflate. + The compressor and decompressor must use exactly the same dictionary (see + deflateSetDictionary). For raw inflate, this function can be called + immediately after inflateInit2() or inflateReset() and before any call of + inflate() to set the dictionary. The application must insure that the + dictionary that was used for compression is provided. + + inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a + parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is + inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the + expected one (incorrect adler32 value). inflateSetDictionary does not + perform any decompression: this will be done by subsequent calls of + inflate(). +*/ + +ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); +/* + Skips invalid compressed data until a full flush point (see above the + description of deflate with Z_FULL_FLUSH) can be found, or until all + available input is skipped. No output is provided. + + inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR + if no more input was provided, Z_DATA_ERROR if no flush point has been + found, or Z_STREAM_ERROR if the stream structure was inconsistent. In the + success case, the application may save the current current value of total_in + which indicates where valid compressed data was found. In the error case, + the application may repeatedly call inflateSync, providing more input each + time, until success or end of the input data. +*/ + +ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when randomly accessing a large stream. The + first pass through the stream can periodically record the inflate state, + allowing restarting inflate at those points when randomly accessing the + stream. + + inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being Z_NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); +/* + This function is equivalent to inflateEnd followed by inflateInit, + but does not free and reallocate all the internal decompression state. The + stream will keep attributes that may have been set by inflateInit2. + + inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL). +*/ + +ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, + int windowBits)); +/* + This function is the same as inflateReset, but it also permits changing + the wrap and window size requests. The windowBits parameter is interpreted + the same as it is for inflateInit2. + + inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL), or if + the windowBits parameter is invalid. +*/ + +ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + This function inserts bits in the inflate input stream. The intent is + that this function is used to start inflating at a bit position in the + middle of a byte. The provided bits will be used before any bytes are used + from next_in. This function should only be used with raw inflate, and + should be used before the first inflate() call after inflateInit2() or + inflateReset(). bits must be less than or equal to 16, and that many of the + least significant bits of value will be inserted in the input. + + If bits is negative, then the input stream bit buffer is emptied. Then + inflatePrime() can be called again to put bits in the buffer. This is used + to clear out bits leftover after feeding inflate a block description prior + to feeding inflate codes. + + inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); +/* + This function returns two values, one in the lower 16 bits of the return + value, and the other in the remaining upper bits, obtained by shifting the + return value down 16 bits. If the upper value is -1 and the lower value is + zero, then inflate() is currently decoding information outside of a block. + If the upper value is -1 and the lower value is non-zero, then inflate is in + the middle of a stored block, with the lower value equaling the number of + bytes from the input remaining to copy. If the upper value is not -1, then + it is the number of bits back from the current bit position in the input of + the code (literal or length/distance pair) currently being processed. In + that case the lower value is the number of bytes already emitted for that + code. + + A code is being processed if inflate is waiting for more input to complete + decoding of the code, or if it has completed decoding but is waiting for + more output space to write the literal or match data. + + inflateMark() is used to mark locations in the input data for random + access, which may be at bit positions, and to note those cases where the + output of a code may span boundaries of random access blocks. The current + location in the input stream can be determined from avail_in and data_type + as noted in the description for the Z_BLOCK flush parameter for inflate. + + inflateMark returns the value noted above or -1 << 16 if the provided + source stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, + gz_headerp head)); +/* + inflateGetHeader() requests that gzip header information be stored in the + provided gz_header structure. inflateGetHeader() may be called after + inflateInit2() or inflateReset(), and before the first call of inflate(). + As inflate() processes the gzip stream, head->done is zero until the header + is completed, at which time head->done is set to one. If a zlib stream is + being decoded, then head->done is set to -1 to indicate that there will be + no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be + used to force inflate() to return immediately after header processing is + complete and before any actual data is decompressed. + + The text, time, xflags, and os fields are filled in with the gzip header + contents. hcrc is set to true if there is a header CRC. (The header CRC + was valid if done is set to one.) If extra is not Z_NULL, then extra_max + contains the maximum number of bytes to write to extra. Once done is true, + extra_len contains the actual extra field length, and extra contains the + extra field, or that field truncated if extra_max is less than extra_len. + If name is not Z_NULL, then up to name_max characters are written there, + terminated with a zero unless the length is greater than name_max. If + comment is not Z_NULL, then up to comm_max characters are written there, + terminated with a zero unless the length is greater than comm_max. When any + of extra, name, or comment are not Z_NULL and the respective field is not + present in the header, then that field is set to Z_NULL to signal its + absence. This allows the use of deflateSetHeader() with the returned + structure to duplicate the header. However if those fields are set to + allocated memory, then the application will need to save those pointers + elsewhere so that they can be eventually freed. + + If inflateGetHeader is not used, then the header information is simply + discarded. The header is always checked for validity, including the header + CRC if present. inflateReset() will reset the process to discard the header + information. The application would need to call inflateGetHeader() again to + retrieve the header from the next gzip stream. + + inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, + unsigned char FAR *window)); + + Initialize the internal stream state for decompression using inflateBack() + calls. The fields zalloc, zfree and opaque in strm must be initialized + before the call. If zalloc and zfree are Z_NULL, then the default library- + derived memory allocation routines are used. windowBits is the base two + logarithm of the window size, in the range 8..15. window is a caller + supplied buffer of that size. Except for special applications where it is + assured that deflate was used with small window sizes, windowBits must be 15 + and a 32K byte window must be supplied to be able to decompress general + deflate streams. + + See inflateBack() for the usage of these routines. + + inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of + the paramaters are invalid, Z_MEM_ERROR if the internal state could not be + allocated, or Z_VERSION_ERROR if the version of the library does not match + the version of the header file. +*/ + +typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); +typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); + +ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, + in_func in, void FAR *in_desc, + out_func out, void FAR *out_desc)); +/* + inflateBack() does a raw inflate with a single call using a call-back + interface for input and output. This is more efficient than inflate() for + file i/o applications in that it avoids copying between the output and the + sliding window by simply making the window itself the output buffer. This + function trusts the application to not change the output buffer passed by + the output function, at least until inflateBack() returns. + + inflateBackInit() must be called first to allocate the internal state + and to initialize the state with the user-provided window buffer. + inflateBack() may then be used multiple times to inflate a complete, raw + deflate stream with each call. inflateBackEnd() is then called to free the + allocated state. + + A raw deflate stream is one with no zlib or gzip header or trailer. + This routine would normally be used in a utility that reads zip or gzip + files and writes out uncompressed files. The utility would decode the + header and process the trailer on its own, hence this routine expects only + the raw deflate stream to decompress. This is different from the normal + behavior of inflate(), which expects either a zlib or gzip header and + trailer around the deflate stream. + + inflateBack() uses two subroutines supplied by the caller that are then + called by inflateBack() for input and output. inflateBack() calls those + routines until it reads a complete deflate stream and writes out all of the + uncompressed data, or until it encounters an error. The function's + parameters and return types are defined above in the in_func and out_func + typedefs. inflateBack() will call in(in_desc, &buf) which should return the + number of bytes of provided input, and a pointer to that input in buf. If + there is no input available, in() must return zero--buf is ignored in that + case--and inflateBack() will return a buffer error. inflateBack() will call + out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() + should return zero on success, or non-zero on failure. If out() returns + non-zero, inflateBack() will return with an error. Neither in() nor out() + are permitted to change the contents of the window provided to + inflateBackInit(), which is also the buffer that out() uses to write from. + The length written by out() will be at most the window size. Any non-zero + amount of input may be provided by in(). + + For convenience, inflateBack() can be provided input on the first call by + setting strm->next_in and strm->avail_in. If that input is exhausted, then + in() will be called. Therefore strm->next_in must be initialized before + calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called + immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in + must also be initialized, and then if strm->avail_in is not zero, input will + initially be taken from strm->next_in[0 .. strm->avail_in - 1]. + + The in_desc and out_desc parameters of inflateBack() is passed as the + first parameter of in() and out() respectively when they are called. These + descriptors can be optionally used to pass any information that the caller- + supplied in() and out() functions need to do their job. + + On return, inflateBack() will set strm->next_in and strm->avail_in to + pass back any unused input that was provided by the last in() call. The + return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR + if in() or out() returned an error, Z_DATA_ERROR if there was a format error + in the deflate stream (in which case strm->msg is set to indicate the nature + of the error), or Z_STREAM_ERROR if the stream was not properly initialized. + In the case of Z_BUF_ERROR, an input or output error can be distinguished + using strm->next_in which will be Z_NULL only if in() returned an error. If + strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning + non-zero. (in() will always be called before out(), so strm->next_in is + assured to be defined if out() returns non-zero.) Note that inflateBack() + cannot return Z_OK. +*/ + +ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); +/* + All memory allocated by inflateBackInit() is freed. + + inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream + state was inconsistent. +*/ + +ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); +/* Return flags indicating compile-time options. + + Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: + 1.0: size of uInt + 3.2: size of uLong + 5.4: size of voidpf (pointer) + 7.6: size of z_off_t + + Compiler, assembler, and debug options: + 8: DEBUG + 9: ASMV or ASMINF -- use ASM code + 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention + 11: 0 (reserved) + + One-time table building (smaller code, but not thread-safe if true): + 12: BUILDFIXED -- build static block decoding tables when needed + 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed + 14,15: 0 (reserved) + + Library content (indicates missing functionality): + 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking + deflate code when not needed) + 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect + and decode gzip streams (to avoid linking crc code) + 18-19: 0 (reserved) + + Operation variations (changes in library functionality): + 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate + 21: FASTEST -- deflate algorithm with only one, lowest compression level + 22,23: 0 (reserved) + + The sprintf variant used by gzprintf (zero is best): + 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format + 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! + 26: 0 = returns value, 1 = void -- 1 means inferred string length returned + + Remainder: + 27-31: 0 (reserved) + */ + + + /* utility functions */ + +/* + The following utility functions are implemented on top of the basic + stream-oriented functions. To simplify the interface, some default options + are assumed (compression level and memory usage, standard memory allocation + functions). The source code of these utility functions can be modified if + you need special options. +*/ + +ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Compresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total size + of the destination buffer, which must be at least the value returned by + compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed buffer. + + compress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer. +*/ + +ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level)); +/* + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least the value returned by + compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ + +ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); +/* + compressBound() returns an upper bound on the compressed size after + compress() or compress2() on sourceLen bytes. It would be used before a + compress() or compress2() call to allocate the destination buffer. +*/ + +ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total size + of the destination buffer, which must be large enough to hold the entire + uncompressed data. (The size of the uncompressed data must have been saved + previously by the compressor and transmitted to the decompressor by some + mechanism outside the scope of this compression library.) Upon exit, destLen + is the actual size of the uncompressed buffer. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. +*/ + + + /* gzip file access functions */ + +/* + This library supports reading and writing files in gzip (.gz) format with + an interface similar to that of stdio, using the functions that start with + "gz". The gzip format is different from the zlib format. gzip is a gzip + wrapper, documented in RFC 1952, wrapped around a deflate stream. +*/ + +typedef voidp gzFile; /* opaque gzip file descriptor */ + +/* +ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); + + Opens a gzip (.gz) file for reading or writing. The mode parameter is as + in fopen ("rb" or "wb") but can also include a compression level ("wb9") or + a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only + compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F' + for fixed code compression as in "wb9F". (See the description of + deflateInit2 for more information about the strategy parameter.) Also "a" + can be used instead of "w" to request that the gzip stream that will be + written be appended to the file. "+" will result in an error, since reading + and writing to the same gzip file is not supported. + + gzopen can be used to read a file which is not in gzip format; in this + case gzread will directly read from the file without decompression. + + gzopen returns NULL if the file could not be opened, if there was + insufficient memory to allocate the gzFile state, or if an invalid mode was + specified (an 'r', 'w', or 'a' was not provided, or '+' was provided). + errno can be checked to determine if the reason gzopen failed was that the + file could not be opened. +*/ + +ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); +/* + gzdopen associates a gzFile with the file descriptor fd. File descriptors + are obtained from calls like open, dup, creat, pipe or fileno (if the file + has been previously opened with fopen). The mode parameter is as in gzopen. + + The next call of gzclose on the returned gzFile will also close the file + descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor + fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd, + mode);. The duplicated descriptor should be saved to avoid a leak, since + gzdopen does not close fd if it fails. + + gzdopen returns NULL if there was insufficient memory to allocate the + gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not + provided, or '+' was provided), or if fd is -1. The file descriptor is not + used until the next gz* read, write, seek, or close operation, so gzdopen + will not detect if fd is invalid (unless fd is -1). +*/ + +ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); +/* + Set the internal buffer size used by this library's functions. The + default buffer size is 8192 bytes. This function must be called after + gzopen() or gzdopen(), and before any other calls that read or write the + file. The buffer memory allocation is always deferred to the first read or + write. Two buffers are allocated, either both of the specified size when + writing, or one of the specified size and the other twice that size when + reading. A larger buffer size of, for example, 64K or 128K bytes will + noticeably increase the speed of decompression (reading). + + The new buffer size also affects the maximum length for gzprintf(). + + gzbuffer() returns 0 on success, or -1 on failure, such as being called + too late. +*/ + +ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); +/* + Dynamically update the compression level or strategy. See the description + of deflateInit2 for the meaning of these parameters. + + gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not + opened for writing. +*/ + +ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +/* + Reads the given number of uncompressed bytes from the compressed file. If + the input file was not in gzip format, gzread copies the given number of + bytes into the buffer. + + After reaching the end of a gzip stream in the input, gzread will continue + to read, looking for another gzip stream, or failing that, reading the rest + of the input file directly without decompression. The entire input file + will be read if gzread is called until it returns less than the requested + len. + + gzread returns the number of uncompressed bytes actually read, less than + len for end of file, or -1 for error. +*/ + +ZEXTERN int ZEXPORT gzwrite OF((gzFile file, + voidpc buf, unsigned len)); +/* + Writes the given number of uncompressed bytes into the compressed file. + gzwrite returns the number of uncompressed bytes written or 0 in case of + error. +*/ + +ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); +/* + Converts, formats, and writes the arguments to the compressed file under + control of the format string, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written, or 0 in case of error. The number of + uncompressed bytes written is limited to 8191, or one less than the buffer + size given to gzbuffer(). The caller should assure that this limit is not + exceeded. If it is exceeded, then gzprintf() will return an error (0) with + nothing written. In this case, there may also be a buffer overflow with + unpredictable consequences, which is possible only if zlib was compiled with + the insecure functions sprintf() or vsprintf() because the secure snprintf() + or vsnprintf() functions were not available. This can be determined using + zlibCompileFlags(). +*/ + +ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); +/* + Writes the given null-terminated string to the compressed file, excluding + the terminating null character. + + gzputs returns the number of characters written, or -1 in case of error. +*/ + +ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); +/* + Reads bytes from the compressed file until len-1 characters are read, or a + newline character is read and transferred to buf, or an end-of-file + condition is encountered. If any characters are read or if len == 1, the + string is terminated with a null character. If no characters are read due + to an end-of-file or len < 1, then the buffer is left untouched. + + gzgets returns buf which is a null-terminated string, or it returns NULL + for end-of-file or in case of error. If there was an error, the contents at + buf are indeterminate. +*/ + +ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); +/* + Writes c, converted to an unsigned char, into the compressed file. gzputc + returns the value that was written, or -1 in case of error. +*/ + +ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); +/* + Reads one byte from the compressed file. gzgetc returns this byte or -1 + in case of end of file or error. +*/ + +ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); +/* + Push one character back onto the stream to be read as the first character + on the next read. At least one character of push-back is allowed. + gzungetc() returns the character pushed, or -1 on failure. gzungetc() will + fail if c is -1, and may fail if a character has been pushed but not read + yet. If gzungetc is used immediately after gzopen or gzdopen, at least the + output buffer size of pushed characters is allowed. (See gzbuffer above.) + The pushed character will be discarded if the stream is repositioned with + gzseek() or gzrewind(). +*/ + +ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); +/* + Flushes all pending output into the compressed file. The parameter flush + is as in the deflate() function. The return value is the zlib error number + (see function gzerror below). gzflush is only permitted when writing. + + If the flush parameter is Z_FINISH, the remaining data is written and the + gzip stream is completed in the output. If gzwrite() is called again, a new + gzip stream will be started in the output. gzread() is able to read such + concatented gzip streams. + + gzflush should be called only when strictly necessary because it will + degrade compression if called too often. +*/ + +/* +ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, + z_off_t offset, int whence)); + + Sets the starting position for the next gzread or gzwrite on the given + compressed file. The offset represents a number of bytes in the + uncompressed data stream. The whence parameter is defined as in lseek(2); + the value SEEK_END is not supported. + + If the file is opened for reading, this function is emulated but can be + extremely slow. If the file is opened for writing, only forward seeks are + supported; gzseek then compresses a sequence of zeroes up to the new + starting position. + + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error, in + particular if the file is opened for writing and the new starting position + would be before the current position. +*/ + +ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); +/* + Rewinds the given file. This function is supported only for reading. + + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) +*/ + +/* +ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); + + Returns the starting position for the next gzread or gzwrite on the given + compressed file. This position represents a number of bytes in the + uncompressed data stream, and is zero when starting, even if appending or + reading a gzip stream from the middle of a file using gzdopen(). + + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) +*/ + +/* +ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file)); + + Returns the current offset in the file being read or written. This offset + includes the count of bytes that precede the gzip stream, for example when + appending or when using gzdopen() for reading. When reading, the offset + does not include as yet unused buffered input. This information can be used + for a progress indicator. On error, gzoffset() returns -1. +*/ + +ZEXTERN int ZEXPORT gzeof OF((gzFile file)); +/* + Returns true (1) if the end-of-file indicator has been set while reading, + false (0) otherwise. Note that the end-of-file indicator is set only if the + read tried to go past the end of the input, but came up short. Therefore, + just like feof(), gzeof() may return false even if there is no more data to + read, in the event that the last read request was for the exact number of + bytes remaining in the input file. This will happen if the input file size + is an exact multiple of the buffer size. + + If gzeof() returns true, then the read functions will return no more data, + unless the end-of-file indicator is reset by gzclearerr() and the input file + has grown since the previous end of file was detected. +*/ + +ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); +/* + Returns true (1) if file is being copied directly while reading, or false + (0) if file is a gzip stream being decompressed. This state can change from + false to true while reading the input file if the end of a gzip stream is + reached, but is followed by data that is not another gzip stream. + + If the input file is empty, gzdirect() will return true, since the input + does not contain a gzip stream. + + If gzdirect() is used immediately after gzopen() or gzdopen() it will + cause buffers to be allocated to allow reading the file to determine if it + is a gzip file. Therefore if gzbuffer() is used, it should be called before + gzdirect(). +*/ + +ZEXTERN int ZEXPORT gzclose OF((gzFile file)); +/* + Flushes all pending output if necessary, closes the compressed file and + deallocates the (de)compression state. Note that once file is closed, you + cannot call gzerror with file, since its structures have been deallocated. + gzclose must not be called more than once on the same file, just as free + must not be called more than once on the same allocation. + + gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a + file operation error, or Z_OK on success. +*/ + +ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); +ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); +/* + Same as gzclose(), but gzclose_r() is only for use when reading, and + gzclose_w() is only for use when writing or appending. The advantage to + using these instead of gzclose() is that they avoid linking in zlib + compression or decompression code that is not used when only reading or only + writing respectively. If gzclose() is used, then both compression and + decompression code will be included the application when linking to a static + zlib library. +*/ + +ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); +/* + Returns the error message for the last error which occurred on the given + compressed file. errnum is set to zlib error number. If an error occurred + in the file system and not in the compression library, errnum is set to + Z_ERRNO and the application may consult errno to get the exact error code. + + The application must not modify the returned string. Future calls to + this function may invalidate the previously returned string. If file is + closed, then the string previously returned by gzerror will no longer be + available. + + gzerror() should be used to distinguish errors from end-of-file for those + functions above that do not distinguish those cases in their return values. +*/ + +ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); +/* + Clears the error and end-of-file flags for file. This is analogous to the + clearerr() function in stdio. This is useful for continuing to read a gzip + file that is being written concurrently. +*/ + + + /* checksum functions */ + +/* + These functions are not related to compression but are exported + anyway because they might be useful in applications using the compression + library. +*/ + +ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); +/* + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. If buf is Z_NULL, this function returns the + required initial value for the checksum. + + An Adler-32 checksum is almost as reliable as a CRC32 but can be computed + much faster. + + Usage example: + + uLong adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); +*/ + +/* +ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, + z_off_t len2)); + + Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 + and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for + each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of + seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. +*/ + +ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); +/* + Update a running CRC-32 with the bytes buf[0..len-1] and return the + updated CRC-32. If buf is Z_NULL, this function returns the required + initial value for the for the crc. Pre- and post-conditioning (one's + complement) is performed within this function so it shouldn't be done by the + application. + + Usage example: + + uLong crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); +*/ + +/* +ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); + + Combine two CRC-32 check values into one. For two sequences of bytes, + seq1 and seq2 with lengths len1 and len2, CRC-32 check values were + calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 + check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and + len2. +*/ + + + /* various hacks, don't look :) */ + +/* deflateInit and inflateInit are macros to allow checking the zlib version + * and the compiler's view of z_stream: + */ +ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size)); +ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, + unsigned char FAR *window, + const char *version, + int stream_size)); +#define deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) +#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) +#define inflateBackInit(strm, windowBits, window) \ + inflateBackInit_((strm), (windowBits), (window), \ + ZLIB_VERSION, sizeof(z_stream)) + +/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or + * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if + * both are true, the application gets the *64 functions, and the regular + * functions are changed to 64 bits) -- in case these are set on systems + * without large file support, _LFS64_LARGEFILE must also be true + */ +#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 + ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); + ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); + ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); + ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); + ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t)); + ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); +#endif + +#if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS-0 == 64 && _LFS64_LARGEFILE-0 +# define gzopen gzopen64 +# define gzseek gzseek64 +# define gztell gztell64 +# define gzoffset gzoffset64 +# define adler32_combine adler32_combine64 +# define crc32_combine crc32_combine64 +# ifdef _LARGEFILE64_SOURCE + ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); + ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); + ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); + ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile)); + ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); + ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); +# endif +#else + ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); + ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int)); + ZEXTERN z_off_t ZEXPORT gztell OF((gzFile)); + ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile)); + ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); + ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); +#endif + +/* hack for buggy compilers */ +#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) + struct internal_state {int dummy;}; +#endif + +/* undocumented functions */ +ZEXTERN const char * ZEXPORT zError OF((int)); +ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); +ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); +ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); + +#ifdef __cplusplus +} +#endif + +#endif /* ZLIB_H */ diff --git a/cpukit/libblock/include/rtems/bdbuf.h b/cpukit/libblock/include/rtems/bdbuf.h deleted file mode 100644 index edec05e099..0000000000 --- a/cpukit/libblock/include/rtems/bdbuf.h +++ /dev/null @@ -1,699 +0,0 @@ -/** - * @file - * - * @ingroup rtems_bdbuf - * @brief Block Device Buffer Management - */ - -/* - * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia - * Author: Victor V. Vengerov - * - * Copyright (C) 2008,2009 Chris Johns - * Rewritten to remove score mutex access. Fixes many performance - * issues. - * Change to support demand driven variable buffer sizes. - * - * Copyright (c) 2009-2012 embedded brains GmbH. - */ - -#ifndef _RTEMS_BDBUF_H -#define _RTEMS_BDBUF_H - -#include -#include -#include - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup rtems_libblock Block Device Library - * - * Block device modules. - */ - -/** - * @defgroup rtems_bdbuf Block Device Buffer Management - * - * @ingroup rtems_libblock - * - * The Block Device Buffer Management implements a cache between the disk - * devices and file systems. The code provides read-ahead and write queuing to - * the drivers and fast cache look-up using an AVL tree. - * - * The block size used by a file system can be set at runtime and must be a - * multiple of the disk device block size. The disk device's physical block - * size is called the media block size. The file system can set the block size - * it uses to a larger multiple of the media block size. The driver must be - * able to handle buffers sizes larger than one media block. - * - * The user configures the amount of memory to be used as buffers in the cache, - * and the minimum and maximum buffer size. The cache will allocate additional - * memory for the buffer descriptors and groups. There are enough buffer - * descriptors allocated so all the buffer memory can be used as minimum sized - * buffers. - * - * The cache is a single pool of buffers. The buffer memory is divided into - * groups where the size of buffer memory allocated to a group is the maximum - * buffer size. A group's memory can be divided down into small buffer sizes - * that are a multiple of 2 of the minimum buffer size. A group is the minimum - * allocation unit for buffers of a specific size. If a buffer of maximum size - * is request the group will have a single buffer. If a buffer of minimum size - * is requested the group is divided into minimum sized buffers and the - * remaining buffers are held ready for use. A group keeps track of which - * buffers are with a file system or driver and groups who have buffer in use - * cannot be realloced. Groups with no buffers in use can be taken and - * realloced to a new size. This is how buffers of different sizes move around - * the cache. - - * The buffers are held in various lists in the cache. All buffers follow this - * state machine: - * - * @dot - * digraph state { - * size="16,8"; - * f [label="FREE",style="filled",fillcolor="aquamarine"]; - * e [label="EMPTY",style="filled",fillcolor="seagreen"]; - * c [label="CACHED",style="filled",fillcolor="chartreuse"]; - * ac [label="ACCESS CACHED",style="filled",fillcolor="royalblue"]; - * am [label="ACCESS MODIFIED",style="filled",fillcolor="royalblue"]; - * ae [label="ACCESS EMPTY",style="filled",fillcolor="royalblue"]; - * ap [label="ACCESS PURGED",style="filled",fillcolor="royalblue"]; - * t [label="TRANSFER",style="filled",fillcolor="red"]; - * tp [label="TRANSFER PURGED",style="filled",fillcolor="red"]; - * s [label="SYNC",style="filled",fillcolor="red"]; - * m [label="MODIFIED",style="filled",fillcolor="gold"]; - * i [label="INITIAL"]; - * - * legend_transfer [label="Transfer Wake-Up",fontcolor="red",shape="none"]; - * legend_access [label="Access Wake-Up",fontcolor="royalblue",shape="none"]; - * - * i -> f [label="Init"]; - * f -> e [label="Buffer Recycle"]; - * e -> ae [label="Get"]; - * e -> t [label="Read"]; - * e -> f [label="Nobody Waits"]; - * c -> ac [label="Get\nRead"]; - * c -> e [label="Buffer Recycle\nPurge"]; - * c -> f [label="Reallocate\nBlock Size Changed"]; - * t -> c [label="Transfer Done",color="red",fontcolor="red"]; - * t -> e [label="Transfer Error",color="red",fontcolor="red"]; - * t -> tp [label="Purge"]; - * tp -> e [label="Transfer Done\nTransfer Error",color="red",fontcolor="red"]; - * m -> t [label="Swapout"]; - * m -> s [label="Block Size Changed"]; - * m -> am [label="Get\nRead"]; - * m -> e [label="Purge"]; - * ac -> m [label="Release Modified",color="royalblue",fontcolor="royalblue"]; - * ac -> s [label="Sync",color="royalblue",fontcolor="royalblue"]; - * ac -> c [label="Release",color="royalblue",fontcolor="royalblue"]; - * ac -> ap [label="Purge"]; - * am -> m [label="Release\nRelease Modified",color="royalblue",fontcolor="royalblue"]; - * am -> s [label="Sync",color="royalblue",fontcolor="royalblue"]; - * am -> ap [label="Purge"]; - * ae -> m [label="Release Modified",color="royalblue",fontcolor="royalblue"]; - * ae -> s [label="Sync",color="royalblue",fontcolor="royalblue"]; - * ae -> e [label="Release",color="royalblue",fontcolor="royalblue"]; - * ae -> ap [label="Purge"]; - * ap -> e [label="Release\nRelease Modified\nSync",color="royalblue",fontcolor="royalblue"]; - * s -> t [label="Swapout"]; - * s -> e [label="Purge",color="red",fontcolor="red"]; - * } - * @enddot - * - * Empty or cached buffers are added to the LRU list and removed from this - * queue when a caller requests a buffer. This is referred to as getting a - * buffer in the code and the event get in the state diagram. The buffer is - * assigned to a block and inserted to the AVL based on the block/device key. - * If the block is to be read by the user and not in the cache it is transfered - * from the disk into memory. If no buffers are on the LRU list the modified - * list is checked. If buffers are on the modified the swap out task will be - * woken. The request blocks until a buffer is available for recycle. - * - * A block being accessed is given to the file system layer and not accessible - * to another requester until released back to the cache. The same goes to a - * buffer in the transfer state. The transfer state means being read or - * written. If the file system has modified the block and releases it as - * modified it placed on the cache's modified list and a hold timer - * initialised. The buffer is held for the hold time before being written to - * disk. Buffers are held for a configurable period of time on the modified - * list as a write sets the state to transfer and this locks the buffer out - * from the file system until the write completes. Buffers are often accessed - * and modified in a series of small updates so if sent to the disk when - * released as modified the user would have to block waiting until it had been - * written. This would be a performance problem. - * - * The code performs multiple block reads and writes. Multiple block reads or - * read-ahead increases performance with hardware that supports it. It also - * helps with a large cache as the disk head movement is reduced. It however - * is a speculative operation so excessive use can remove valuable and needed - * blocks from the cache. The read-ahead is triggered after two misses of - * ascending consecutive blocks or a read hit of a block read by the - * most-resent read-ahead transfer. The read-ahead works per disk, but all - * transfers are issued by the read-ahead task. - * - * The cache has the following lists of buffers: - * - LRU: Accessed or transfered buffers released in least recently used - * order. Empty buffers will be placed to the front. - * - Modified: Buffers waiting to be written to disk. - * - Sync: Buffers to be synchronized with the disk. - * - * A cache look-up will be performed to find a suitable buffer. A suitable - * buffer is one that matches the same allocation size as the device the buffer - * is for. The a buffer's group has no buffers in use with the file system or - * driver the group is reallocated. This means the buffers in the group are - * invalidated, resized and placed on the LRU queue. There is a performance - * issue with this design. The reallocation of a group may forced recently - * accessed buffers out of the cache when they should not. The design should be - * change to have groups on a LRU list if they have no buffers in use. - */ -/**@{**/ - -#if defined(RTEMS_POSIX_API) - /* - * Use the PTHREAD mutexes and condition variables if available. This helps - * on SMP configurations to avoid the home grown condition variables via - * disabled preemption. - */ - #define RTEMS_BDBUF_USE_PTHREAD -#endif - -/** - * @brief State of a buffer of the cache. - * - * The state has several implications. Depending on the state a buffer can be - * in the AVL tree, in a list, in use by an entity and a group user or not. - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
StateValid DataAVL TreeLRU ListModified ListSynchronization ListGroup UserExternal User
FREEX
EMPTYX
CACHEDXXX
ACCESS CACHEDXXXX
ACCESS MODIFIEDXXXX
ACCESS EMPTYXXX
ACCESS PURGEDXXX
MODIFIEDXXXX
SYNCXXXX
TRANSFERXXXX
TRANSFER PURGEDXXX
- */ -typedef enum -{ - /** - * @brief Free. - */ - RTEMS_BDBUF_STATE_FREE = 0, - - /** - * @brief Empty. - */ - RTEMS_BDBUF_STATE_EMPTY, - - /** - * @brief Cached. - */ - RTEMS_BDBUF_STATE_CACHED, - - /** - * @brief Accessed by upper layer with cached data. - */ - RTEMS_BDBUF_STATE_ACCESS_CACHED, - - /** - * @brief Accessed by upper layer with modified data. - */ - RTEMS_BDBUF_STATE_ACCESS_MODIFIED, - - /** - * @brief Accessed by upper layer with invalid data. - */ - RTEMS_BDBUF_STATE_ACCESS_EMPTY, - - /** - * @brief Accessed by upper layer with purged data. - */ - RTEMS_BDBUF_STATE_ACCESS_PURGED, - - /** - * @brief Modified by upper layer. - */ - RTEMS_BDBUF_STATE_MODIFIED, - - /** - * @brief Scheduled for synchronization. - */ - RTEMS_BDBUF_STATE_SYNC, - - /** - * @brief In transfer by block device driver. - */ - RTEMS_BDBUF_STATE_TRANSFER, - - /** - * @brief In transfer by block device driver and purged. - */ - RTEMS_BDBUF_STATE_TRANSFER_PURGED -} rtems_bdbuf_buf_state; - -/** - * Forward reference to the block. - */ -struct rtems_bdbuf_group; -typedef struct rtems_bdbuf_group rtems_bdbuf_group; - -/** - * To manage buffers we using buffer descriptors (BD). A BD holds a buffer plus - * a range of other information related to managing the buffer in the cache. To - * speed-up buffer lookup descriptors are organized in AVL-Tree. The fields - * 'dd' and 'block' are search keys. - */ -typedef struct rtems_bdbuf_buffer -{ - rtems_chain_node link; /**< Link the BD onto a number of lists. */ - - struct rtems_bdbuf_avl_node - { - struct rtems_bdbuf_buffer* left; /**< Left Child */ - struct rtems_bdbuf_buffer* right; /**< Right Child */ - signed char cache; /**< Cache */ - signed char bal; /**< The balance of the sub-tree */ - } avl; - - rtems_disk_device *dd; /**< disk device */ - - rtems_blkdev_bnum block; /**< block number on the device */ - - unsigned char* buffer; /**< Pointer to the buffer memory area */ - - rtems_bdbuf_buf_state state; /**< State of the buffer. */ - - uint32_t waiters; /**< The number of threads waiting on this - * buffer. */ - rtems_bdbuf_group* group; /**< Pointer to the group of BDs this BD is - * part of. */ - uint32_t hold_timer; /**< Timer to indicate how long a buffer - * has been held in the cache modified. */ - - int references; /**< Allow reference counting by owner. */ - void* user; /**< User data. */ -} rtems_bdbuf_buffer; - -/** - * A group is a continuous block of buffer descriptors. A group covers the - * maximum configured buffer size and is the allocation size for the buffers to - * a specific buffer size. If you allocate a buffer to be a specific size, all - * buffers in the group, if there are more than 1 will also be that size. The - * number of buffers in a group is a multiple of 2, ie 1, 2, 4, 8, etc. - */ -struct rtems_bdbuf_group -{ - rtems_chain_node link; /**< Link the groups on a LRU list if they - * have no buffers in use. */ - size_t bds_per_group; /**< The number of BD allocated to this - * group. This value must be a multiple of - * 2. */ - uint32_t users; /**< How many users the block has. */ - rtems_bdbuf_buffer* bdbuf; /**< First BD this block covers. */ -}; - -/** - * Buffering configuration definition. See confdefs.h for support on using this - * structure. - */ -typedef struct rtems_bdbuf_config { - uint32_t max_read_ahead_blocks; /**< Number of blocks to read - * ahead. */ - uint32_t max_write_blocks; /**< Number of blocks to write - * at once. */ - rtems_task_priority swapout_priority; /**< Priority of the swap out - * task. */ - uint32_t swapout_period; /**< Period swap-out checks buf - * timers. */ - uint32_t swap_block_hold; /**< Period a buffer is held. */ - size_t swapout_workers; /**< The number of worker - * threads for the swap-out - * task. */ - rtems_task_priority swapout_worker_priority; /**< Priority of the swap out - * task. */ - size_t task_stack_size; /**< Task stack size for swap-out - * task and worker threads. */ - size_t size; /**< Size of memory in the - * cache */ - uint32_t buffer_min; /**< Minimum buffer size. */ - uint32_t buffer_max; /**< Maximum buffer size - * supported. It is also the - * allocation size. */ - rtems_task_priority read_ahead_priority; /**< Priority of the read-ahead - * task. */ -} rtems_bdbuf_config; - -/** - * External reference to the configuration. - * - * The configuration is provided by the application. - */ -extern const rtems_bdbuf_config rtems_bdbuf_configuration; - -/** - * The default value for the maximum read-ahead blocks disables the read-ahead - * feature. - */ -#define RTEMS_BDBUF_MAX_READ_AHEAD_BLOCKS_DEFAULT 0 - -/** - * Default maximum number of blocks to write at once. - */ -#define RTEMS_BDBUF_MAX_WRITE_BLOCKS_DEFAULT 16 - -/** - * Default swap-out task priority. - */ -#define RTEMS_BDBUF_SWAPOUT_TASK_PRIORITY_DEFAULT 15 - -/** - * Default swap-out task swap period in milli seconds. - */ -#define RTEMS_BDBUF_SWAPOUT_TASK_SWAP_PERIOD_DEFAULT 250 - -/** - * Default swap-out task block hold time in milli seconds. - */ -#define RTEMS_BDBUF_SWAPOUT_TASK_BLOCK_HOLD_DEFAULT 1000 - -/** - * Default swap-out worker tasks. Currently disabled. - */ -#define RTEMS_BDBUF_SWAPOUT_WORKER_TASKS_DEFAULT 0 - -/** - * Default swap-out worker task priority. The same as the swap-out task. - */ -#define RTEMS_BDBUF_SWAPOUT_WORKER_TASK_PRIORITY_DEFAULT \ - RTEMS_BDBUF_SWAPOUT_TASK_PRIORITY_DEFAULT - -/** - * Default read-ahead task priority. The same as the swap-out task. - */ -#define RTEMS_BDBUF_READ_AHEAD_TASK_PRIORITY_DEFAULT \ - RTEMS_BDBUF_SWAPOUT_TASK_PRIORITY_DEFAULT - -/** - * Default task stack size for swap-out and worker tasks. - */ -#define RTEMS_BDBUF_TASK_STACK_SIZE_DEFAULT RTEMS_MINIMUM_STACK_SIZE - -/** - * Default size of memory allocated to the cache. - */ -#define RTEMS_BDBUF_CACHE_MEMORY_SIZE_DEFAULT (64 * 512) - -/** - * Default minimum size of buffers. - */ -#define RTEMS_BDBUF_BUFFER_MIN_SIZE_DEFAULT (512) - -/** - * Default maximum size of buffers. - */ -#define RTEMS_BDBUF_BUFFER_MAX_SIZE_DEFAULT (4096) - -/** - * Prepare buffering layer to work - initialize buffer descritors and (if it is - * neccessary) buffers. After initialization all blocks is placed into the - * ready state. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_CALLED_FROM_ISR Called from an interrupt context. - * @retval RTEMS_INVALID_NUMBER The buffer maximum is not an integral multiple - * of the buffer minimum. The maximum read-ahead blocks count is too large. - * @retval RTEMS_RESOURCE_IN_USE Already initialized. - * @retval RTEMS_UNSATISFIED Not enough resources. - */ -rtems_status_code -rtems_bdbuf_init (void); - -/** - * Get block buffer for data to be written into. The buffers is set to the - * access or modified access state. If the buffer is in the cache and modified - * the state is access modified else the state is access. This buffer contents - * are not initialised if the buffer is not already in the cache. If the block - * is already resident in memory it is returned how-ever if not in memory the - * buffer is not read from disk. This call is used when writing the whole block - * on a disk rather than just changing a part of it. If there is no buffers - * available this call will block. A buffer obtained with this call will not be - * involved in a transfer request and will not be returned to another user - * until released. If the buffer is already with a user when this call is made - * the call is blocked until the buffer is returned. The highest priority - * waiter will obtain the buffer first. - * - * The block number is the linear block number. This is relative to the start - * of the partition on the media. - * - * Before you can use this function, the rtems_bdbuf_init() routine must be - * called at least once to initialize the cache, otherwise a fatal error will - * occur. - * - * @param dd [in] The disk device. - * @param block [in] Linear media block number. - * @param bd [out] Reference to the buffer descriptor pointer. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_INVALID_ID Invalid block number. - */ -rtems_status_code -rtems_bdbuf_get ( - rtems_disk_device *dd, - rtems_blkdev_bnum block, - rtems_bdbuf_buffer** bd -); - -/** - * Get the block buffer and if not already in the cache read from the disk. If - * specified block already cached return. The buffer is set to the access or - * modified access state. If the buffer is in the cache and modified the state - * is access modified else the state is access. If block is already being read - * from disk for being written to disk this call blocks. If the buffer is - * waiting to be written it is removed from modified queue and returned to the - * user. If the buffer is not in the cache a new buffer is obtained and the - * data read from disk. The call may block until these operations complete. A - * buffer obtained with this call will not be involved in a transfer request - * and will not be returned to another user until released. If the buffer is - * already with a user when this call is made the call is blocked until the - * buffer is returned. The highest priority waiter will obtain the buffer - * first. - * - * Before you can use this function, the rtems_bdbuf_init() routine must be - * called at least once to initialize the cache, otherwise a fatal error will - * occur. - * - * @param dd [in] The disk device. - * @param block [in] Linear media block number. - * @param bd [out] Reference to the buffer descriptor pointer. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_INVALID_ID Invalid block number. - * @retval RTEMS_IO_ERROR IO error. - */ -rtems_status_code -rtems_bdbuf_read ( - rtems_disk_device *dd, - rtems_blkdev_bnum block, - rtems_bdbuf_buffer** bd -); - -/** - * Release the buffer obtained by a read call back to the cache. If the buffer - * was obtained by a get call and was not already in the cache the release - * modified call should be used. A buffer released with this call obtained by a - * get call may not be in sync with the contents on disk. If the buffer was in - * the cache and modified before this call it will be returned to the modified - * queue. The buffers is returned to the end of the LRU list. - * - * Before you can use this function, the rtems_bdbuf_init() routine must be - * called at least once to initialize the cache, otherwise a fatal error will - * occur. - * - * @param bd [in] Reference to the buffer descriptor. The buffer descriptor - * reference must not be @c NULL and must be obtained via rtems_bdbuf_get() or - * rtems_bdbuf_read(). - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_INVALID_ADDRESS The reference is NULL. - */ -rtems_status_code -rtems_bdbuf_release (rtems_bdbuf_buffer* bd); - -/** - * Release the buffer allocated with a get or read call placing it on the - * modified list. If the buffer was not released modified before the hold - * timer is set to the configuration value. If the buffer had been released - * modified before but not written to disk the hold timer is not updated. The - * buffer will be written to disk when the hold timer has expired, there are - * not more buffers available in the cache and a get or read buffer needs one - * or a sync call has been made. If the buffer is obtained with a get or read - * before the hold timer has expired the buffer will be returned to the user. - * - * Before you can use this function, the rtems_bdbuf_init() routine must be - * called at least once to initialize the cache, otherwise a fatal error will - * occur. - * - * @param bd [in] Reference to the buffer descriptor. The buffer descriptor - * reference must not be @c NULL and must be obtained via rtems_bdbuf_get() or - * rtems_bdbuf_read(). - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_INVALID_ADDRESS The reference is NULL. - */ -rtems_status_code -rtems_bdbuf_release_modified (rtems_bdbuf_buffer* bd); - -/** - * Release the buffer as modified and wait until it has been synchronized with - * the disk by writing it. This buffer will be the first to be transfer to disk - * and other buffers may also be written if the maximum number of blocks in a - * requests allows it. - * - * @note This code does not lock the sync mutex and stop additions to the - * modified queue. - * - * Before you can use this function, the rtems_bdbuf_init() routine must be - * called at least once to initialize the cache, otherwise a fatal error will - * occur. - * - * @param bd [in] Reference to the buffer descriptor. The buffer descriptor - * reference must not be @c NULL and must be obtained via rtems_bdbuf_get() or - * rtems_bdbuf_read(). - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_INVALID_ADDRESS The reference is NULL. - */ -rtems_status_code -rtems_bdbuf_sync (rtems_bdbuf_buffer* bd); - -/** - * Synchronize all modified buffers for this device with the disk and wait - * until the transfers have completed. The sync mutex for the cache is locked - * stopping the addition of any further modified buffers. It is only the - * currently modified buffers that are written. - * - * @note Nesting calls to sync multiple devices will be handled sequentially. A - * nested call will be blocked until the first sync request has complete. - * - * Before you can use this function, the rtems_bdbuf_init() routine must be - * called at least once to initialize the cache, otherwise a fatal error will - * occur. - * - * @param dd [in] The disk device. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - */ -rtems_status_code -rtems_bdbuf_syncdev (rtems_disk_device *dd); - -/** - * @brief Purges all buffers corresponding to the disk device @a dd. - * - * This may result in loss of data. The read-ahead state of this device is reset. - * - * Before you can use this function, the rtems_bdbuf_init() routine must be - * called at least once to initialize the cache, otherwise a fatal error will - * occur. - * - * @param dd [in] The disk device. - */ -void -rtems_bdbuf_purge_dev (rtems_disk_device *dd); - -/** - * @brief Sets the block size of a disk device. - * - * This will set the block size derived fields of the disk device. If - * requested the disk device is synchronized before the block size change - * occurs. Since the cache is unlocked during the synchronization operation - * some tasks may access the disk device in the meantime. This may result in - * loss of data. After the synchronization the disk device is purged to ensure - * a consistent cache state and the block size change occurs. This also resets - * the read-ahead state of this disk device. Due to the purge operation this - * may result in loss of data. - * - * Before you can use this function, the rtems_bdbuf_init() routine must be - * called at least once to initialize the cache, otherwise a fatal error will - * occur. - * - * @param dd [in, out] The disk device. - * @param block_size [in] The new block size in bytes. - * @param sync [in] If @c true, then synchronize the disk device before the - * block size change. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_INVALID_NUMBER Invalid block size. - */ -rtems_status_code -rtems_bdbuf_set_block_size (rtems_disk_device *dd, - uint32_t block_size, - bool sync); - -/** - * @brief Returns the block device statistics. - */ -void -rtems_bdbuf_get_device_stats (const rtems_disk_device *dd, - rtems_blkdev_stats *stats); - -/** - * @brief Resets the block device statistics. - */ -void -rtems_bdbuf_reset_device_stats (rtems_disk_device *dd); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/libblock/include/rtems/bdpart.h b/cpukit/libblock/include/rtems/bdpart.h deleted file mode 100644 index 8886c3614d..0000000000 --- a/cpukit/libblock/include/rtems/bdpart.h +++ /dev/null @@ -1,411 +0,0 @@ -/** - * @file - * - * @ingroup rtems_bdpart - * - * @brief Block Device Partition Management - */ - -/* - * Copyright (c) 2009-2012 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Obere Lagerstr. 30 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef RTEMS_BDPART_H -#define RTEMS_BDPART_H - -#include - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup rtems_bdpart Block Device Partition Management - * - * @ingroup rtems_libblock - * - * @brief This module provides functions to manage partitions of a disk device. - * - * A @ref rtems_disk "disk" is a set of blocks which are identified by a - * consecutive set of non-negative integers starting at zero. There are also - * logical disks which contain a subset of consecutive disk blocks. The - * logical disks are used to represent the partitions of a disk. The disk - * devices are accessed via the @ref rtems_disk "block device buffer module". - * - * The partition format on the physical disk will be converted to an internal - * representation. It is possible to convert the internal representation into - * a specific output format and write it to the physical disk. One of the - * constrains for the internal representation was to support the GPT format - * easily. - * - * Currently two physical partition formats are supported. These are the MBR - * and the GPT format. Please note that the GPT support is not implemented. - * With MBR format we mean the partition format of the wide spread IBM - * PC-compatible systems. The GPT format is defined in the Extensible Firmware - * Interface (EFI). - * - * The most common task will be to read the partition information of a disk and - * register logical disks for each partition. This can be done with the - * rtems_bdpart_register_from_disk() function. Afterwards you can - * @ref rtems_fsmount "mount" the file systems within the partitions. - * - * You can read the partition information from a disk with rtems_bdpart_read() - * and write it to the disk with rtems_bdpart_write(). - * - * To create a partition table from scratch for a disk use - * rtems_bdpart_create(). - * - * You can access some disk functions with the shell command @c fdisk. - * - * References used to create this module: - * - Universally Unique Identifier - * - Globally Unique Identifier - * - Disk Paritioning - * - GUID Partition Table - * - Master Boot Record - * - Extended Boot Record - * - Cylinder Head Sector - * - Partition Types - */ -/**@{**/ - -/** - * @name MBR Partition Types and Flags - */ -/**@{**/ - -#define RTEMS_BDPART_MBR_EMPTY 0x0U - -#define RTEMS_BDPART_MBR_FAT_12 0x1U - -#define RTEMS_BDPART_MBR_FAT_16 0x4U - -#define RTEMS_BDPART_MBR_FAT_16_LBA 0xeU - -#define RTEMS_BDPART_MBR_FAT_32 0xbU - -#define RTEMS_BDPART_MBR_FAT_32_LBA 0xcU - -#define RTEMS_BDPART_MBR_EXTENDED 0x5U - -#define RTEMS_BDPART_MBR_DATA 0xdaU - -#define RTEMS_BDPART_MBR_GPT 0xeeU - -#define RTEMS_BDPART_MBR_FLAG_ACTIVE 0x80U - -/** @} */ - -/** - * Recommended maximum partition table size. - */ -#define RTEMS_BDPART_PARTITION_NUMBER_HINT 16 - -/** - * Partition description. - */ -typedef struct rtems_bdpart_partition { - /** - * Block index for partition begin. - */ - rtems_blkdev_bnum begin; - - /** - * Block index for partition end (this block is not a part of the partition). - */ - rtems_blkdev_bnum end; - - /** - * Partition type. - */ - uuid_t type; - - /** - * Partition ID. - */ - uuid_t id; - - /** - * Partition flags. - */ - uint64_t flags; -} rtems_bdpart_partition; - -/** - * Disk format for the partition tables. - */ -typedef enum { - /** - * Type value for MBR format. - */ - RTEMS_BDPART_FORMAT_MBR, - - /** - * Type value for GPT format. - */ - RTEMS_BDPART_FORMAT_GPT -} rtems_bdpart_format_type; - -/** - * Disk format description. - */ -typedef union { - /** - * Format type. - */ - rtems_bdpart_format_type type; - - /** - * MBR format fields. - */ - struct { - rtems_bdpart_format_type type; - - /** - * Disk ID in MBR at offset 440. - */ - uint32_t disk_id; - - /** - * This option is used for partition table creation and validation checks - * before a write to the disk. It ensures that the first primary - * partition and the logical partitions start at head one and sector one - * under the virtual one head and 63 sectors geometry. Each begin and - * end of a partition will be aligned to the virtual cylinder boundary. - */ - bool dos_compatibility; - } mbr; - - /** - * GPT format fields. - */ - struct { - rtems_bdpart_format_type type; - - /** - * Disk ID in GPT header. - */ - uuid_t disk_id; - } gpt; -} rtems_bdpart_format; - -/** - * @brief Reads the partition information from the physical disk device with - * name @a disk_name. - * - * The partition information will be stored in the partition table - * @a partitions with a maximum of @a count partitions. The number of actual - * partitions will be stored in @a count. If there are more partitions than - * space for storage an error status will be returned. The partition table - * format recognized on the disk will be stored in @a format. - */ -rtems_status_code rtems_bdpart_read( - const char *disk_name, - rtems_bdpart_format *format, - rtems_bdpart_partition *partitions, - size_t *count -); - -/** - * @brief Sorts the partition table @a partitions with @a count partitions to - * have ascending begin blocks - */ -void rtems_bdpart_sort( rtems_bdpart_partition *partitions, size_t count); - -/** - * @brief Writes the partition table to the physical disk device with name - * @a disk_name. - * - * The partition table @a partitions with @a count partitions will be written - * to the disk. The output format for the partition table on the disk is - * specified by @a format. There are some consistency checks applied to the - * partition table. The partition table must be sorted such that the begin - * blocks are in ascending order. This can be done with the - * rtems_bdpart_sort() function. The partitions must not overlap. The - * partitions must have a positive size. The partitions must be within the - * disk. Depending on the output format there are additional constrains. - */ -rtems_status_code rtems_bdpart_write( - const char *disk_name, - const rtems_bdpart_format *format, - const rtems_bdpart_partition *partitions, - size_t count -); - -/** - * @brief Creates a partition table in @a partitions with @a count partitions - * for the physical disk device with name @a disk_name. - * - * The array of positive integer weights in @a distribution must have exactly - * @a count elements. The weights in the distribution array are summed up. - * Each weight is then divided by the sum to obtain the disk fraction which - * forms the corresponding partition. The partition boundaries are generated - * with respect to the output format in @a format. - */ -rtems_status_code rtems_bdpart_create( - const char *disk_name, - const rtems_bdpart_format *format, - rtems_bdpart_partition *partitions, - const unsigned *distribution, - size_t count -); - -/** - * @brief Registers the partitions as logical disks for the physical disk - * device with name @a disk_name. - * - * For each partition of the partition table @a partitions with @a count - * partitions a logical disk is registered. The partition number equals the - * partition table index plus one. The name of the logical disk device is the - * concatenation of the physical disk device name and the partition number. - * - * @see rtems_blkdev_create_partition(). - */ -rtems_status_code rtems_bdpart_register( - const char *disk_name, - const rtems_bdpart_partition *partitions, - size_t count -); - -/** - * @a brief Reads the partition table from the disk device with name @a - * disk_name and registers the partitions as logical disks. - * - * @see rtems_bdpart_register() and rtems_fsmount(). - */ -rtems_status_code rtems_bdpart_register_from_disk( const char *disk_name); - -/** - * @brief Deletes the logical disks associated with the partitions of the disk - * device with name @a disk_name. - * - * The partition table @a partitions with @a count partitions will be used to - * determine which disks need to be deleted. It may be obtained from - * rtems_bdpart_read(). - */ -rtems_status_code rtems_bdpart_unregister( - const char *disk_name, - const rtems_bdpart_partition *partitions, - size_t count -); - -/** - * @brief Mounts all supported file systems inside the logical disks derived - * from the partitions of the physical disk device with name @a disk_name. - * - * For each partition in the partition table @a partitions with @a count - * partitions it will be checked if it contains a supported file system. In - * this case a mount point derived from the disk name will be created in the - * mount base path @a mount_base. The file system will be mounted there. The - * partition number equals the partition table index plus one. The mount point - * name for each partition will be the concatenation of the mount base path, - * the disk device file name and the parition number. - * - * @see rtems_bdpart_read(). - */ -rtems_status_code rtems_bdpart_mount( - const char *disk_name, - const rtems_bdpart_partition *partitions, - size_t count, - const char *mount_base -); - -/** - * @brief Unmounts all file systems mounted with rtems_bdpart_mount(). - */ -rtems_status_code rtems_bdpart_unmount( - const char *disk_name, - const rtems_bdpart_partition *partitions, - size_t count, - const char *mount_base -); - -/** - * @brief Prints the partition table @a partitions with @a count partitions to - * standard output. - */ -void rtems_bdpart_dump( const rtems_bdpart_partition *partitions, size_t count); - -/** - * @brief Returns the partition type for the MBR partition type value - * @a mbr_type in @a type. - */ -void rtems_bdpart_to_partition_type( uint8_t mbr_type, uuid_t type); - -/** - * @brief Converts the partition type in @a type to the MBR partition type. - * - * The result will be stored in @a mbr_type. Returns @c true in case of a - * successful convertion and otherwise @c false. Both arguments must not be - * @c NULL. - */ -bool rtems_bdpart_to_mbr_partition_type( - const uuid_t type, - uint8_t *mbr_type -); - -/** @} */ - -#define RTEMS_BDPART_MBR_CYLINDER_SIZE 63 - -#define RTEMS_BDPART_NUMBER_SIZE 4 - -#define RTEMS_BDPART_BLOCK_SIZE 512 - -#define RTEMS_BDPART_MBR_TABLE_ENTRY_SIZE 16 - -#define RTEMS_BDPART_MBR_OFFSET_TABLE_0 446 - -#define RTEMS_BDPART_MBR_OFFSET_TABLE_1 \ - (RTEMS_BDPART_MBR_OFFSET_TABLE_0 + RTEMS_BDPART_MBR_TABLE_ENTRY_SIZE) - -#define RTEMS_BDPART_MBR_OFFSET_DISK_ID 440 - -#define RTEMS_BDPART_MBR_OFFSET_SIGNATURE_0 510 - -#define RTEMS_BDPART_MBR_OFFSET_SIGNATURE_1 511 - -#define RTEMS_BDPART_MBR_SIGNATURE_0 0x55U - -#define RTEMS_BDPART_MBR_SIGNATURE_1 0xaaU - -#define RTEMS_BDPART_MBR_OFFSET_BEGIN 8 - -#define RTEMS_BDPART_MBR_OFFSET_SIZE 12 - -#define RTEMS_BDPART_MBR_OFFSET_TYPE 4 - -#define RTEMS_BDPART_MBR_OFFSET_FLAGS 0 - -static inline uint8_t rtems_bdpart_mbr_partition_type( - const uuid_t type -) -{ - return type [0]; -} - -rtems_status_code rtems_bdpart_get_disk_data( - const char *disk_name, - int *fd_ptr, - rtems_disk_device **dd_ptr, - rtems_blkdev_bnum *disk_end -); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* RTEMS_BDPART_H */ diff --git a/cpukit/libblock/include/rtems/blkdev.h b/cpukit/libblock/include/rtems/blkdev.h deleted file mode 100644 index 3f829e6068..0000000000 --- a/cpukit/libblock/include/rtems/blkdev.h +++ /dev/null @@ -1,460 +0,0 @@ -/** - * @file - * - * @ingroup rtems_blkdev - * - * @brief Block Device Management - */ - -/* - * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia - * Author: Victor V. Vengerov - */ - -#ifndef _RTEMS_BLKDEV_H -#define _RTEMS_BLKDEV_H - -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup rtems_blkdev Block Device Management - * - * @ingroup rtems_libblock - * - * Interface between device drivers and the - * @ref rtems_bdbuf "block device buffer module". - * - * The heart of the block device driver is the @ref RTEMS_BLKIO_REQUEST IO - * control. This call puts IO @ref rtems_blkdev_request "requests" to the block - * device for asynchronous processing. When a driver executes a request, it - * invokes the request done callback function to finish the request. - */ -/**@{**/ - -/** - * @brief Block device request type. - * - * @warning The sync request is an IO one and only used from the cache. Use the - * Block IO when operating at the device level. We need a sync request - * to avoid requests looping for ever. - */ -typedef enum rtems_blkdev_request_op { - RTEMS_BLKDEV_REQ_READ, /**< Read the requested blocks of data. */ - RTEMS_BLKDEV_REQ_WRITE, /**< Write the requested blocks of data. */ - RTEMS_BLKDEV_REQ_SYNC /**< Sync any data with the media. */ -} rtems_blkdev_request_op; - -struct rtems_blkdev_request; - -/** - * @brief Block device request done callback function type. - */ -typedef void (*rtems_blkdev_request_cb)( - struct rtems_blkdev_request *req, - rtems_status_code status -); - -/** - * @brief Block device scatter or gather buffer structure. - */ -typedef struct rtems_blkdev_sg_buffer { - /** - * Block index. - */ - rtems_blkdev_bnum block; - - /** - * Buffer length. - */ - uint32_t length; - - /** - * Buffer pointer. - */ - void *buffer; - - /** - * User pointer. - */ - void *user; -} rtems_blkdev_sg_buffer; - -/** - * @brief The block device transfer request is used to read or write a number - * of blocks from or to the device. - * - * Transfer requests are issued to the disk device driver with the - * @ref RTEMS_BLKIO_REQUEST IO control. The transfer request completion status - * must be signalled with rtems_blkdev_request_done(). This function must be - * called exactly once per request. The return value of the IO control will be - * ignored for transfer requests. - * - * @see rtems_blkdev_create(). - */ -typedef struct rtems_blkdev_request { - /** - * Block device operation (read or write). - */ - rtems_blkdev_request_op req; - - /** - * Request done callback function. - */ - rtems_blkdev_request_cb done; - - /** - * Argument to be passed to callback function. - */ - void *done_arg; - - /** - * Last IO operation completion status. - */ - rtems_status_code status; - - /** - * Number of blocks for this request. - */ - uint32_t bufnum; - - /** - * The task requesting the IO operation. - */ - rtems_id io_task; - - /* - * TODO: The use of these req blocks is not a great design. The req is a - * struct with a single 'bufs' declared in the req struct and the - * others are added in the outer level struct. This relies on the - * structs joining as a single array and that assumes the compiler - * packs the structs. Why not just place on a list ? The BD has a - * node that can be used. - */ - - /** - * List of scatter or gather buffers. - */ - rtems_blkdev_sg_buffer bufs[RTEMS_ZERO_LENGTH_ARRAY]; -} rtems_blkdev_request; - -/** - * @brief Signals transfer request completion status. - * - * This function must be called exactly once per request. - * - * @param[in,out] req The transfer request. - * @param[in] status The status of the operation should be - * - @c RTEMS_SUCCESSFUL, if the operation was successful, - * - @c RTEMS_IO_ERROR, if some sort of input or output error occurred, or - * - @c RTEMS_UNSATISFIED, if media is no more present. - */ -static inline void rtems_blkdev_request_done( - rtems_blkdev_request *req, - rtems_status_code status -) -{ - (*req->done)(req, status); -} - -/** - * @brief The start block in a request. - * - * Only valid if the driver has returned the - * @ref RTEMS_BLKDEV_CAP_MULTISECTOR_CONT capability. - */ -#define RTEMS_BLKDEV_START_BLOCK(req) (req->bufs[0].block) - -/** - * @name IO Control Request Codes - */ -/**@{**/ - -#define RTEMS_BLKIO_REQUEST _IOWR('B', 1, rtems_blkdev_request) -#define RTEMS_BLKIO_GETMEDIABLKSIZE _IOR('B', 2, uint32_t) -#define RTEMS_BLKIO_GETBLKSIZE _IOR('B', 3, uint32_t) -#define RTEMS_BLKIO_SETBLKSIZE _IOW('B', 4, uint32_t) -#define RTEMS_BLKIO_GETSIZE _IOR('B', 5, rtems_blkdev_bnum) -#define RTEMS_BLKIO_SYNCDEV _IO('B', 6) -#define RTEMS_BLKIO_DELETED _IO('B', 7) -#define RTEMS_BLKIO_CAPABILITIES _IO('B', 8) -#define RTEMS_BLKIO_GETDISKDEV _IOR('B', 9, rtems_disk_device *) -#define RTEMS_BLKIO_PURGEDEV _IO('B', 10) -#define RTEMS_BLKIO_GETDEVSTATS _IOR('B', 11, rtems_blkdev_stats *) -#define RTEMS_BLKIO_RESETDEVSTATS _IO('B', 12) - -/** @} */ - -static inline int rtems_disk_fd_get_media_block_size( - int fd, - uint32_t *media_block_size -) -{ - return ioctl(fd, RTEMS_BLKIO_GETMEDIABLKSIZE, media_block_size); -} - -static inline int rtems_disk_fd_get_block_size(int fd, uint32_t *block_size) -{ - return ioctl(fd, RTEMS_BLKIO_GETBLKSIZE, block_size); -} - -static inline int rtems_disk_fd_set_block_size(int fd, uint32_t block_size) -{ - return ioctl(fd, RTEMS_BLKIO_SETBLKSIZE, &block_size); -} - -static inline int rtems_disk_fd_get_block_count( - int fd, - rtems_blkdev_bnum *block_count -) -{ - return ioctl(fd, RTEMS_BLKIO_GETSIZE, block_count); -} - -static inline int rtems_disk_fd_get_disk_device( - int fd, - rtems_disk_device **dd_ptr -) -{ - return ioctl(fd, RTEMS_BLKIO_GETDISKDEV, dd_ptr); -} - -static inline int rtems_disk_fd_sync(int fd) -{ - return ioctl(fd, RTEMS_BLKIO_SYNCDEV); -} - -static inline int rtems_disk_fd_purge(int fd) -{ - return ioctl(fd, RTEMS_BLKIO_PURGEDEV); -} - -static inline int rtems_disk_fd_get_device_stats( - int fd, - rtems_blkdev_stats *stats -) -{ - return ioctl(fd, RTEMS_BLKIO_GETDEVSTATS, stats); -} - -static inline int rtems_disk_fd_reset_device_stats(int fd) -{ - return ioctl(fd, RTEMS_BLKIO_RESETDEVSTATS); -} - -/** - * @name Block Device Driver Capabilities - */ -/**@{**/ - -/** - * @brief Only consecutive multi-sector buffer requests are supported. - * - * This option means the cache will only supply multiple buffers that are - * inorder so the ATA multi-sector command for example can be used. This is a - * hack to work around the current ATA driver. - */ -#define RTEMS_BLKDEV_CAP_MULTISECTOR_CONT (1 << 0) - -/** - * @brief The driver will accept a sync call. - * - * A sync call is made to a driver after a bdbuf cache sync has finished. - */ -#define RTEMS_BLKDEV_CAP_SYNC (1 << 1) - -/** @} */ - -/** - * @brief Common IO control primitive. - * - * Use this in all block devices to handle the common set of IO control - * requests. - */ -int -rtems_blkdev_ioctl(rtems_disk_device *dd, uint32_t req, void *argp); - -/** - * @brief Creates a block device. - * - * The block size is set to the media block size. - * - * @param[in] device The path for the new block device. - * @param[in] media_block_size The media block size in bytes. Must be positive. - * @param[in] media_block_count The media block count. Must be positive. - * @param[in] handler The block device IO control handler. Must not be @c NULL. - * @param[in] driver_data The block device driver data. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_INVALID_NUMBER Media block size or count is not positive. - * @retval RTEMS_NO_MEMORY Not enough memory. - * @retval RTEMS_UNSATISFIED Cannot create generic device node. - * - * @see rtems_blkdev_create_partition(), rtems_bdbuf_set_block_size(), and - * rtems_blkdev_request. - */ -rtems_status_code rtems_blkdev_create( - const char *device, - uint32_t media_block_size, - rtems_blkdev_bnum media_block_count, - rtems_block_device_ioctl handler, - void *driver_data -); - -/** - * @brief Creates a partition within a parent block device. - * - * A partition manages a subset of consecutive blocks contained in a parent block - * device. The blocks must be within the range of blocks managed by the - * associated parent block device. The media block size and IO control - * handler are inherited by the parent block device. The block size is set to - * the media block size. - * - * @param[in] partition The path for the new partition device. - * @param[in] parent_block_device The parent block device path. - * @param[in] media_block_begin The media block begin of the partition within - * the parent block device. - * @param[in] media_block_count The media block count of the partition. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_INVALID_ID Block device node does not exist. - * @retval RTEMS_INVALID_NODE File system node is not a block device. - * @retval RTEMS_NOT_IMPLEMENTED Block device implementation is incomplete. - * @retval RTEMS_INVALID_NUMBER Block begin or block count is invalid. - * @retval RTEMS_NO_MEMORY Not enough memory. - * @retval RTEMS_UNSATISFIED Cannot create generic device node. - * - * @see rtems_blkdev_create() and rtems_bdbuf_set_block_size(). - */ -rtems_status_code rtems_blkdev_create_partition( - const char *partition, - const char *parent_block_device, - rtems_blkdev_bnum media_block_begin, - rtems_blkdev_bnum media_block_count -); - -/** - * @brief Prints the block device statistics. - */ -void rtems_blkdev_print_stats( - const rtems_blkdev_stats *stats, - uint32_t media_block_size, - uint32_t media_block_count, - uint32_t block_size, - const rtems_printer* printer -); - -/** - * @brief Block device statistics command. - */ -void rtems_blkstats( - const rtems_printer *printer, - const char *device, - bool reset -); - -/** @} */ - -/** - * @defgroup rtems_blkdev_generic Generic Disk Device - * - * @ingroup rtems_blkdev - * - * Generic disk device operations for standard RTEMS IO drivers. - */ -/**@{**/ - -/** - * The device driver interface conventions suppose that a driver may contain an - * initialize, open, close, read, write and IO control entry points. These - * primitives (except initialize) can be implemented in a generic fashion based - * upon the supplied block device driver IO control handler. Every block device - * driver should provide an initialize entry point, which registers the - * appropriate IO control handler. - */ -#define RTEMS_GENERIC_BLOCK_DEVICE_DRIVER_ENTRIES \ - rtems_blkdev_generic_open, \ - rtems_blkdev_generic_close, \ - rtems_blkdev_generic_read, \ - rtems_blkdev_generic_write, \ - rtems_blkdev_generic_ioctl - -/** - * Generic block device read primitive. - * - * Implemented using block device buffer management primitives. - */ -rtems_device_driver -rtems_blkdev_generic_read( - rtems_device_major_number major, - rtems_device_minor_number minor, - void * arg -); - -/** - * Generic block device write primitive. - * - * Implemented using block device buffer management primitives. - */ -rtems_device_driver -rtems_blkdev_generic_write( - rtems_device_major_number major, - rtems_device_minor_number minor, - void * arg -); - -/** - * Generic block device open primitive. - * - * Implemented using block device buffer management primitives. - */ -rtems_device_driver -rtems_blkdev_generic_open( - rtems_device_major_number major, - rtems_device_minor_number minor, - void * arg -); - -/** - * Generic block device close primitive. - * - * Implemented using block device buffer management primitives. - */ -rtems_device_driver -rtems_blkdev_generic_close( - rtems_device_major_number major, - rtems_device_minor_number minor, - void * arg -); - -/** - * Generic block device IO control primitive. - * - * Implemented using block device buffer management primitives. - */ -rtems_device_driver -rtems_blkdev_generic_ioctl( - rtems_device_major_number major, - rtems_device_minor_number minor, - void * arg -); - -/** - * @brief Generic block operations driver address table. - */ -extern const rtems_driver_address_table rtems_blkdev_generic_ops; - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/libblock/include/rtems/diskdevs.h b/cpukit/libblock/include/rtems/diskdevs.h deleted file mode 100644 index 0be766afa3..0000000000 --- a/cpukit/libblock/include/rtems/diskdevs.h +++ /dev/null @@ -1,511 +0,0 @@ -/** - * @file - * - * @brief Block Device Disk Management API - * - * @ingroup rtems_disk - */ - -/* - * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia - * Author: Victor V. Vengerov - */ - -#ifndef _RTEMS_DISKDEVS_H -#define _RTEMS_DISKDEVS_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct rtems_disk_device rtems_disk_device; - -/** - * @defgroup rtems_disk Block Device Disk Management - * - * @ingroup rtems_libblock - * - * @brief This module provides functions to manage disk devices. - * - * A disk is a set of blocks which are identified by a consecutive set of - * non-negative integers starting at zero. There are also logical disks which - * contain a subset of consecutive disk blocks. The logical disks are used to - * represent the partitions of a disk. The disk devices are accessed via the - * @ref rtems_bdbuf "block device buffer module". - */ -/**@{**/ - -/** - * @brief Block device block index type. - */ -typedef uint32_t rtems_blkdev_bnum; - -/** - * @brief Block device IO control handler type. - */ -typedef int (*rtems_block_device_ioctl)( - rtems_disk_device *dd, - uint32_t req, - void *argp -); - -/** - * @brief Trigger value to disable further read-ahead requests. - */ -#define RTEMS_DISK_READ_AHEAD_NO_TRIGGER ((rtems_blkdev_bnum) -1) - -/** - * @brief Block device read-ahead control. - */ -typedef struct { - /** - * @brief Chain node for the read-ahead request queue of the read-ahead task. - */ - rtems_chain_node node; - - /** - * @brief Block value to trigger the read-ahead request. - * - * A value of @ref RTEMS_DISK_READ_AHEAD_NO_TRIGGER will disable further - * read-ahead requests since no valid block can have this value. - */ - rtems_blkdev_bnum trigger; - - /** - * @brief Start block for the next read-ahead request. - * - * In case the trigger value is out of range of valid blocks, this value my - * be arbitrary. - */ - rtems_blkdev_bnum next; -} rtems_blkdev_read_ahead; - -/** - * @brief Block device statistics. - * - * Integer overflows in the statistic counters may happen. - */ -typedef struct { - /** - * @brief Read hit count. - * - * A read hit occurs in the rtems_bdbuf_read() function in case the block is - * in the cached or modified state. - */ - uint32_t read_hits; - - /** - * @brief Read miss count. - * - * A read miss occurs in the rtems_bdbuf_read() function in case the block is - * in the empty state and a read transfer must be initiated to read the data - * from the device. - */ - uint32_t read_misses; - - /** - * @brief Read-ahead transfer count. - * - * Each read-ahead transfer may read multiple blocks. - */ - uint32_t read_ahead_transfers; - - /** - * @brief Count of blocks transfered from the device. - */ - uint32_t read_blocks; - - /** - * @brief Read error count. - * - * Error count of transfers issued by the read or read-ahead requests. - */ - uint32_t read_errors; - - /** - * @brief Write transfer count. - * - * Each write transfer may write multiple blocks. - */ - uint32_t write_transfers; - - /** - * @brief Count of blocks transfered to the device. - */ - uint32_t write_blocks; - - /** - * @brief Write error count. - * - * Error count of transfers issued by write requests. - */ - uint32_t write_errors; -} rtems_blkdev_stats; - -/** - * @brief Description of a disk device (logical and physical disks). - * - * An array of pointer tables to rtems_disk_device structures is maintained. - * The first table will be indexed by the major number and the second table - * will be indexed by the minor number. This allows quick lookup using a data - * structure of moderated size. - */ -struct rtems_disk_device { - /** - * @brief Device identifier (concatenation of major and minor number). - */ - dev_t dev; - - /** - * @brief Physical device identifier (equals the @c dev entry if it specifies a - * physical device). - */ - rtems_disk_device *phys_dev; - - /** - * @brief Driver capabilities. - */ - uint32_t capabilities; - - /** - * @brief Disk device name. - */ - char *name; - - /** - * @brief Usage counter. - * - * Devices cannot be deleted if they are in use. - */ - unsigned uses; - - /** - * @brief Start media block number. - * - * Equals zero for physical devices. It is a media block offset to the - * related physical device for logical device. - */ - rtems_blkdev_bnum start; - - /** - * @brief Size of the physical or logical disk in media blocks. - */ - rtems_blkdev_bnum size; - - /** - * @brief Media block size in bytes. - * - * This is the media transfer unit the hardware defaults to. - */ - uint32_t media_block_size; - - /** - * @brief Block size in bytes. - * - * This is the minimum transfer unit. It may be a multiple of the media - * block size. It must be positive. - * - * @see rtems_bdbuf_set_block_size(). - */ - uint32_t block_size; - - /** - * @brief Block count. - * - * @see rtems_bdbuf_set_block_size(). - */ - rtems_blkdev_bnum block_count; - - /** - * @brief Media blocks per device blocks. - * - * @see rtems_bdbuf_set_block_size(). - */ - uint32_t media_blocks_per_block; - - /** - * @brief Block to media block shift. - * - * In case this value is non-negative the media block of a block can be - * calculated as media block = block << block_to_media_block_shift, otherwise - * a 64-bit operation will be used. - * - * @see rtems_bdbuf_set_block_size(). - */ - int block_to_media_block_shift; - - /** - * @brief Buffer descriptors per group count. - * - * @see rtems_bdbuf_set_block_size(). - */ - size_t bds_per_group; - - /** - * @brief IO control handler for this disk. - */ - rtems_block_device_ioctl ioctl; - - /** - * @brief Private data for the disk driver. - */ - void *driver_data; - - /** - * @brief Indicates that this disk should be deleted as soon as the last user - * releases this disk. - */ - bool deleted; - - /** - * @brief Device statistics for this disk. - */ - rtems_blkdev_stats stats; - - /** - * @brief Read-ahead control for this disk. - */ - rtems_blkdev_read_ahead read_ahead; -}; - -/** - * @name Disk Device Data - */ -/**@{**/ - -static inline dev_t rtems_disk_get_device_identifier( - const rtems_disk_device *dd -) -{ - return dd->dev; -} - -static inline rtems_device_major_number rtems_disk_get_major_number( - const rtems_disk_device *dd -) -{ - return rtems_filesystem_dev_major_t(dd->dev); -} - -static inline rtems_device_minor_number rtems_disk_get_minor_number( - const rtems_disk_device *dd -) -{ - return rtems_filesystem_dev_minor_t(dd->dev); -} - -static inline void *rtems_disk_get_driver_data( - const rtems_disk_device *dd -) -{ - return dd->driver_data; -} - -static inline uint32_t rtems_disk_get_media_block_size( - const rtems_disk_device *dd -) -{ - return dd->media_block_size; -} - -static inline uint32_t rtems_disk_get_block_size( - const rtems_disk_device *dd -) -{ - return dd->block_size; -} - -static inline rtems_blkdev_bnum rtems_disk_get_block_begin( - const rtems_disk_device *dd -) -{ - return dd->start; -} - -static inline rtems_blkdev_bnum rtems_disk_get_block_count( - const rtems_disk_device *dd -) -{ - return dd->size; -} - -/** @} */ - -/** - * @name Disk Device Maintainance - */ -/**@{**/ - -/** - * @brief Creates a physical disk with device identifier @a dev. - * - * The block size @a block_size must be positive. The disk will have - * @a block_count blocks. The block index starts with zero. The associated disk - * device driver will be invoked via the IO control handler @a handler. A - * device node will be registered in the file system with absolute path @a - * name, if @a name is not @c NULL. This function is usually invoked from a - * block device driver during initialization when a physical device is detected - * in the system. The device driver provides an IO control handler to allow - * block device operations. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_NOT_CONFIGURED Cannot lock disk device operation mutex. - * @retval RTEMS_INVALID_ADDRESS IO control handler is @c NULL. - * @retval RTEMS_INVALID_NUMBER Block size is invalid. - * @retval RTEMS_NO_MEMORY Not enough memory. - * @retval RTEMS_RESOURCE_IN_USE Disk device descriptor is already in use. - * @retval RTEMS_UNSATISFIED Cannot create device node. - */ -rtems_status_code rtems_disk_create_phys( - dev_t dev, - uint32_t block_size, - rtems_blkdev_bnum block_count, - rtems_block_device_ioctl handler, - void *driver_data, - const char *name -); - -/** - * @brief Creates a logical disk with device identifier @a dev. - * - * A logical disk manages a subset of consecutive blocks contained in the - * physical disk with identifier @a phys. The start block index of the logical - * disk device is @a block_begin. The block count of the logcal disk will be - * @a block_count. The blocks must be within the range of blocks managed by - * the associated physical disk device. A device node will be registered in - * the file system with absolute path @a name, if @a name is not @c NULL. The - * block size and IO control handler are inherited by the physical disk. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_NOT_CONFIGURED Cannot lock disk device operation mutex. - * @retval RTEMS_INVALID_ID Specified physical disk identifier does not - * correspond to a physical disk. - * @retval RTEMS_INVALID_NUMBER Begin block or block count are out of range. - * @retval RTEMS_NO_MEMORY Not enough memory. - * @retval RTEMS_RESOURCE_IN_USE Disk device descriptor for logical disk - * identifier is already in use. - * @retval RTEMS_UNSATISFIED Cannot create device node. - */ -rtems_status_code rtems_disk_create_log( - dev_t dev, - dev_t phys, - rtems_blkdev_bnum block_begin, - rtems_blkdev_bnum block_count, - const char *name -); - -/** - * @brief Deletes a physical or logical disk device with identifier @a dev. - * - * Marks the disk device as deleted. When a physical disk device is deleted, - * all corresponding logical disk devices will marked as deleted too. Disks - * that are marked as deleted and have a usage counter of zero will be deleted. - * The corresponding device nodes will be removed from the file system. In - * case of a physical disk deletion the IO control handler will be invoked with - * a RTEMS_BLKIO_DELETED request. Disks that are still in use will be deleted - * upon release. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_NOT_CONFIGURED Cannot lock disk device operation mutex. - * @retval RTEMS_INVALID_ID No disk for specified device identifier. - */ -rtems_status_code rtems_disk_delete(dev_t dev); - -/** - * @brief Returns the disk device descriptor for the device identifier @a dev. - * - * Increments usage counter by one. You should release the disk device - * descriptor with rtems_disk_release(). - * - * @return Pointer to the disk device descriptor or @c NULL if no corresponding - * disk exists. - */ -rtems_disk_device *rtems_disk_obtain(dev_t dev); - -/** - * @brief Releases the disk device descriptor @a dd. - * - * Decrements usage counter by one. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - */ -rtems_status_code rtems_disk_release(rtems_disk_device *dd); - -/** @} */ - -/** - * @name Disk Management - */ -/**@{**/ - -/** - * @brief Initializes the disk device management. - * - * This functions returns successful if the disk device management is already - * initialized. There is no protection against concurrent access. - * - * @retval RTEMS_SUCCESSFUL Successful initialization. - * @retval RTEMS_NO_MEMORY Not enough memory or no semaphore available. - * @retval RTEMS_UNSATISFIED Block device buffer initialization failed. - */ -rtems_status_code rtems_disk_io_initialize(void); - -/** - * @brief Releases all resources allocated for disk device management. - * - * There is no protection against concurrent access. If parts of the system - * are still in use the behaviour is undefined. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - */ -rtems_status_code rtems_disk_io_done(void); - -/** @} */ - -/** @} */ - -/** - * @brief Disk device iterator. - * - * Returns the next disk device descriptor with a device identifier larger than - * @a dev. If there is no such device, @c NULL will be returned. Use minus - * one to start the search. - * - * @code - * rtems_status_code sc = RTEMS_SUCCESSFUL; - * rtems_disk_device *dd = (dev_t) -1; - * - * while (sc == RTEMS_SUCCESSFUL && (dd = rtems_disk_next(dev)) != NULL) { - * dev = rtems_disk_get_device_identifier(dd); - * sc = rtems_disk_release(dd); - * } - * @endcode - */ -rtems_disk_device *rtems_disk_next(dev_t dev); - -/* Internal function, do not use */ -rtems_status_code rtems_disk_init_phys( - rtems_disk_device *dd, - uint32_t block_size, - rtems_blkdev_bnum block_count, - rtems_block_device_ioctl handler, - void *driver_data -); - -/* Internal function, do not use */ -rtems_status_code rtems_disk_init_log( - rtems_disk_device *dd, - rtems_disk_device *phys_dd, - rtems_blkdev_bnum block_begin, - rtems_blkdev_bnum block_count -); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/libblock/include/rtems/flashdisk.h b/cpukit/libblock/include/rtems/flashdisk.h deleted file mode 100644 index ec353096ad..0000000000 --- a/cpukit/libblock/include/rtems/flashdisk.h +++ /dev/null @@ -1,460 +0,0 @@ -/** - * @file - * - * @ingroup RTEMSFDisk - * - * @brief Interface to a Flash Disk Block Device - * - * This file defines the interface to a flash disk block device. - */ - -/* - * Copyright (C) 2007 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if !defined (_RTEMS_FLASHDISK_H_) -#define _RTEMS_FLASHDISK_H_ - -#include -#include - -#include - -/** - * @defgroup RTEMSFDisk Flash Disk Device - * - * @ingroup rtems_blkdev - * - * Flash disk driver for RTEMS provides support for block based - * file systems on flash devices. The driver is not a flash file - * system nor does it try to compete with flash file systems. It - * currently does not journal how-ever block sequence numbering - * could be added to allow recovery of a past positions if - * a power down occurred while being updated. - * - * This flash driver provides block device support for most flash - * devices. The driver has been tested on NOR type devices such - * as the AMLV160 or M28W160. Support for NAND type devices may - * require driver changes to allow speedy recover of the block - * mapping data and to also handle the current use of word programming. - * Currently the page descriptors are stored in the first few pages - * of each segment. - * - * The driver supports devices, segments and pages. You provide - * to the driver the device descriptions as a table of device - * descriptors. Each device descriptor contain a table of - * segment descriptions or segment descriptors. The driver uses - * this information to manage the devices. - * - * A device is made up of segments. These are also called - * sectors or blocks. It is the smallest erasable part of a device. - * A device can have differing size segments at different - * offsets in the device. The segment descriptors support repeating - * segments that are continuous in the device. The driver breaks the - * segments up into pages. The first pages of a segment contain - * the page descriptors. A page descriptor hold the page flags, - * a CRC for the page of data and the block number the page - * holds. The block can appear in any order in the devices. A - * page is active if it hold a current block of data. If the - * used bit is set the page is counted as used. A page moves - * from erased to active to used then back to erased. If a block - * is written that is already in a page, the block is written to - * a new page the old page is flagged as used. - * - * At initialization time each segment's page descriptors are - * read into memory and scanned to determine the active pages, - * the used pages and the bad pages. If a segment has any erased - * pages it is queue on the available queue. If the segment has - * no erased pages it is queue on the used queue. - * - * The available queue is sorted from the least number available - * to the most number of available pages. A segment that has just - * been erased will placed at the end of the queue. A segment that - * has only a few available pages will be used sooner and once - * there are no available pages it is queued on the used queue. - * The used queue hold segments that have no available pages and - * is sorted from the least number of active pages to the most - * number of active pages. - * - * The driver is required to compact segments. Compacting takes - * the segment with the most number of available pages from the - * available queue then takes segments with the least number of - * active pages from the used queue until it has enough pages - * to fill the empty segment. As the active pages are moved - * they flagged as used and once the segment has only used pages - * it is erased. - * - * A flash block driver like this never knows if a page is not - * being used by the file-system. A typical file system is not - * design with the idea of erasing a block on a disk once it is - * not being used. The file-system will normally use a flag - * or a location as a marker to say that part of the disk is - * no longer in use. This means a number of blocks could be - * held in active pages but are no in use by the file system. - * The file system may also read blocks that have never been - * written to disk. This complicates the driver and may make - * the wear, usage and erase patterns harsher than a flash - * file system. The driver may also suffer from problems if - * power is lost. - * - * There are some flash disk specific IO control request types. - * To use open the device and issue the ioctl() call. - * - * @code - * int fd = open ("/dev/flashdisk0", O_WRONLY, 0); - * if (fd < 0) - * { - * printf ("driver open failed: %s\n", strerror (errno)); - * exit (1); - * } - * if (ioctl (fd, RTEMS_FDISK_IOCTL_ERASE_DISK) < 0) - * { - * printf ("driver erase failed: %s\n", strerror (errno)); - * exit (1); - * } - * close (fd); - * @endcode - */ -/**@{**/ - -/** - * @brief The base name of the flash disks. - */ -#define RTEMS_FLASHDISK_DEVICE_BASE_NAME "/dev/fdd" - -#define RTEMS_FDISK_IOCTL_ERASE_DISK _IO('B', 128) -#define RTEMS_FDISK_IOCTL_COMPACT _IO('B', 129) -#define RTEMS_FDISK_IOCTL_ERASE_USED _IO('B', 130) -#define RTEMS_FDISK_IOCTL_MONITORING _IO('B', 131) -#define RTEMS_FDISK_IOCTL_INFO_LEVEL _IO('B', 132) -#define RTEMS_FDISK_IOCTL_PRINT_STATUS _IO('B', 133) - -/** - * @brief Flash Disk Monitoring Data allows a user to obtain - * the current status of the disk. - */ -typedef struct rtems_fdisk_monitor_data -{ - uint32_t block_size; - uint32_t block_count; - uint32_t unavail_blocks; - uint32_t device_count; - uint32_t segment_count; - uint32_t page_count; - uint32_t blocks_used; - uint32_t segs_available; - uint32_t segs_used; - uint32_t segs_failed; - uint32_t seg_erases; - uint32_t pages_desc; - uint32_t pages_active; - uint32_t pages_used; - uint32_t pages_bad; - uint32_t info_level; -} rtems_fdisk_monitor_data; - -/** - * @brief Flash Segment Descriptor holds, number of continuous segments in the - * device of this type, the base segment number in the device, the address - * offset of the base segment in the device, and the size of segment. - * - * Typically this structure is part of a table of segments in the - * device which is referenced in the flash disk configuration table. - * The reference is kept in the driver and used all the time to - * manage the flash device, therefore it must always exist. - */ -typedef struct rtems_fdisk_segment_desc -{ - uint16_t count; /**< Number of segments of this type in a row. */ - uint16_t segment; /**< The base segment number. */ - uint32_t offset; /**< Address offset of base segment in device. */ - uint32_t size; /**< Size of the segment in bytes. */ -} rtems_fdisk_segment_desc; - -/** - * @brief Return the number of kilo-bytes. - */ -#define RTEMS_FDISK_KBYTES(_k) (UINT32_C(1024) * (_k)) - -/** - * Forward declaration of the device descriptor. - */ -struct rtems_fdisk_device_desc; - -/** - * @brief Flash Low Level driver handlers. - * - * Typically this structure is part of a table of handlers in the - * device which is referenced in the flash disk configuration table. - * The reference is kept in the driver and used all the time to - * manage the flash device, therefore it must always exist. - */ -typedef struct rtems_fdisk_driver_handlers -{ - /** - * Read data from the device into the buffer. Return an errno - * error number if the device cannot be read. A segment descriptor - * can describe more than one segment in a device if the device has - * repeating segments. The segment number is the device segment to - * access and the segment descriptor must reference the segment - * being requested. For example the segment number must resided in - * the range [base, base + count). - * - * @param sd The segment descriptor. - * @param device The device to read data from. - * @param segment The segment within the device to read. - * @param offset The offset in the segment to read. - * @param buffer The buffer to read the data into. - * @param size The amount of data to read. - * @retval 0 No error. - * @retval EIO The read did not complete. - */ - int (*read) (const rtems_fdisk_segment_desc* sd, - uint32_t device, - uint32_t segment, - uint32_t offset, - void* buffer, - uint32_t size); - - /** - * Write data from the buffer to the device. Return an errno - * error number if the device cannot be written to. A segment - * descriptor can describe more than segment in a device if the - * device has repeating segments. The segment number is the device - * segment to access and the segment descriptor must reference - * the segment being requested. For example the segment number must - * resided in the range [base, base + count). - * - * @param sd The segment descriptor. - * @param device The device to write data from. - * @param segment The segment within the device to write to. - * @param offset The offset in the segment to write. - * @param buffer The buffer to write the data from. - * @param size The amount of data to write. - * @retval 0 No error. - * @retval EIO The write did not complete or verify. - */ - int (*write) (const rtems_fdisk_segment_desc* sd, - uint32_t device, - uint32_t segment, - uint32_t offset, - const void* buffer, - uint32_t size); - - /** - * Blank a segment in the device. Return an errno error number - * if the device cannot be read or is not blank. A segment descriptor - * can describe more than segment in a device if the device has - * repeating segments. The segment number is the device segment to - * access and the segment descriptor must reference the segment - * being requested. For example the segment number must resided in - * the range [base, base + count). - * - * @param sd The segment descriptor. - * @param device The device to read data from. - * @param segment The segment within the device to read. - * @param offset The offset in the segment to checl. - * @param size The amount of data to check. - * @retval 0 No error. - * @retval EIO The segment is not blank. - */ - int (*blank) (const rtems_fdisk_segment_desc* sd, - uint32_t device, - uint32_t segment, - uint32_t offset, - uint32_t size); - - /** - * Verify data in the buffer to the data in the device. Return an - * errno error number if the device cannot be read. A segment - * descriptor can describe more than segment in a device if the - * device has repeating segments. The segment number is the - * segment to access and the segment descriptor must reference - * the device segment being requested. For example the segment number - * must resided in the range [base, base + count). - * - * @param sd The segment descriptor. - * @param device The device to verify data in. - * @param segment The segment within the device to verify. - * @param offset The offset in the segment to verify. - * @param buffer The buffer to verify the data in the device with. - * @param size The amount of data to verify. - * @retval 0 No error. - * @retval EIO The data did not verify. - */ - int (*verify) (const rtems_fdisk_segment_desc* sd, - uint32_t device, - uint32_t segment, - uint32_t offset, - const void* buffer, - uint32_t size); - - /** - * Erase the segment. Return an errno error number if the - * segment cannot be erased. A segment descriptor can describe - * more than segment in a device if the device has repeating - * segments. The segment number is the device segment to access and - * the segment descriptor must reference the segment being requested. - * - * @param sd The segment descriptor. - * @param device The device to erase the segment of. - * @param segment The segment within the device to erase. - * @retval 0 No error. - * @retval EIO The segment was not erased. - */ - int (*erase) (const rtems_fdisk_segment_desc* sd, - uint32_t device, - uint32_t segment); - - /** - * Erase the device. Return an errno error number if the - * segment cannot be erased. A segment descriptor can describe - * more than segment in a device if the device has repeating - * segments. The segment number is the segment to access and - * the segment descriptor must reference the segment being requested. - * - * @param sd The segment descriptor. - * @param device The device to erase. - * @retval 0 No error. - * @retval EIO The device was not erased. - */ - int (*erase_device) (const struct rtems_fdisk_device_desc* dd, - uint32_t device); - -} rtems_fdisk_driver_handlers; - -/** - * @brief Flash Device Descriptor holds the segments in a device. - * - * The placing of the segments in a device decriptor allows the low level - * driver to share the segment descriptors for a number of devices. - * - * Typically this structure is part of a table of segments in the - * device which is referenced in the flash disk configuration table. - * The reference is kept in the driver and used all the time to - * manage the flash device, therefore it must always exist. - */ -typedef struct rtems_fdisk_device_desc -{ - uint32_t segment_count; /**< Number of segments. */ - const rtems_fdisk_segment_desc* segments; /**< Array of segments. */ - const rtems_fdisk_driver_handlers* flash_ops; /**< Device handlers. */ -} rtems_fdisk_device_desc; - -/** - * @brief RTEMS Flash Disk configuration table used to initialise the - * driver. - * - * The unavailable blocks count is the number of blocks less than the - * available number of blocks the file system is given. This means there - * will always be that number of blocks available when the file system - * thinks the disk is full. The compaction code needs blocks to compact - * with so you will never be able to have all the blocks allocated to the - * file system and be able to full the disk. - * - * The compacting segment count is the number of segments that are - * moved into a new segment. A high number will mean more segments with - * low active page counts and high used page counts will be moved into - * avaliable pages how-ever this extends the compaction time due to - * time it takes the erase the pages. There is no pont making this number - * greater than the maximum number of pages in a segment. - * - * The available compacting segment count is the level when compaction occurs - * when writing. If you set this to 0 then compaction will fail because - * there will be no segments to compact into. - * - * The info level can be 0 for off with error, and abort messages allowed. - * Level 1 is warning messages, level 1 is informational messages, and level 3 - * is debugging type prints. The info level can be turned off with a compile - * time directive on the command line to the compiler of: - * - * -DRTEMS_FDISK_TRACE=0 - */ -typedef struct rtems_flashdisk_config -{ - uint32_t block_size; /**< The block size. */ - uint32_t device_count; /**< The number of devices. */ - const rtems_fdisk_device_desc* devices; /**< The device descriptions. */ - uint32_t flags; /**< Set of flags to control - driver. */ - /** - * Number of blocks not available to the file system. This number must be - * greater than or equal to the number of blocks in the largest segment to - * avoid starvation of erased blocks. - */ - uint32_t unavail_blocks; - - uint32_t compact_segs; /**< Max number of segs to - compact in one pass. */ - /** - * The number of segments when compaction occurs when writing. In case the - * number of segments in the available queue is less than or equal to this - * number the compaction process will be triggered. The available queue - * contains all segments with erased blocks. - */ - uint32_t avail_compact_segs; - uint32_t info_level; /**< Default info level. */ -} rtems_flashdisk_config; - -/* - * Driver flags. - */ - -/** - * Leave the erasing of used segment to the background handler. - */ -#define RTEMS_FDISK_BACKGROUND_ERASE (1 << 0) - -/** - * Leave the compacting of of used segment to the background handler. - */ -#define RTEMS_FDISK_BACKGROUND_COMPACT (1 << 1) - -/** - * Check the pages during initialisation to see which pages are - * valid and which are not. This could slow down initialising the - * disk driver. - */ -#define RTEMS_FDISK_CHECK_PAGES (1 << 2) - -/** - * Blank check the flash device before writing to them. This is needed if - * you think you have a driver or device problem. - */ -#define RTEMS_FDISK_BLANK_CHECK_BEFORE_WRITE (1 << 3) - -/** - * Flash disk device driver initialization. Place in a table as the - * initialisation entry and remainder of the entries are the - * RTEMS block device generic handlers. - * - * @param major Flash disk major device number. - * @param minor Minor device number, not applicable. - * @param arg Initialization argument, not applicable. - * @return The rtems_device_driver is actually just - * rtems_status_code. - */ -rtems_device_driver -rtems_fdisk_initialize (rtems_device_major_number major, - rtems_device_minor_number minor, - void* arg); - -/** - * @brief External reference to the configuration. Please supply. - * Support is present in confdefs.h for providing this variable. - */ -extern const rtems_flashdisk_config rtems_flashdisk_configuration[]; - -/** - * @brief External reference to the number of configurations. Please supply. - * Support is present in confdefs.h for providing this variable. - */ -extern uint32_t rtems_flashdisk_configuration_size; - -/** @} */ - -#endif diff --git a/cpukit/libblock/include/rtems/ide_part_table.h b/cpukit/libblock/include/rtems/ide_part_table.h deleted file mode 100644 index 8b683b3ff5..0000000000 --- a/cpukit/libblock/include/rtems/ide_part_table.h +++ /dev/null @@ -1,207 +0,0 @@ -/** - * @file - * - * @brief "MS-DOS-style" Partition Tables Support - */ - -/* - * Copyright (C) 2002 OKTET Ltd., St.-Petersburg, Russia - * - * Author: Konstantin Abramenko - * Alexander Kukuta - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - * - *****************************************************************************/ - -#ifndef _RTEMS_IDE_PART_TABLE_H -#define _RTEMS_IDE_PART_TABLE_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* Minor base number for all logical devices */ -#define RTEMS_IDE_SECTOR_BITS 9 -#define RTEMS_IDE_SECTOR_SIZE 512 -#define RTEMS_IDE_PARTITION_DESCRIPTOR_SIZE 16 -#define RTEMS_IDE_PARTITION_MAX_PARTITION_NUMBER 63 -#define RTEMS_IDE_PARTITION_MAX_SUB_PARTITION_NUMBER 4 -#define RTEMS_IDE_PARTITION_DEV_NAME_LENGTH_MAX 16 - -#define RTEMS_IDE_PARTITION_MSDOS_SIGNATURE_DATA1 0x55 -#define RTEMS_IDE_PARTITION_MSDOS_SIGNATURE_DATA2 0xaa -#define RTEMS_IDE_PARTITION_MSDOS_SIGNATURE_OFFSET 0x1fe -#define RTEMS_IDE_PARTITION_TABLE_OFFSET 0x1be -#define RTEMS_IDE_PARTITION_TABLE_SIZE (4 * 16) -#define RTEMS_IDE_PARTITION_BOOTABLE_OFFSET 0 -#define RTEMS_IDE_PARTITION_SYS_TYPE_OFFSET 4 -#define RTEMS_IDE_PARTITION_START_OFFSET 8 -#define RTEMS_IDE_PARTITION_SIZE_OFFSET 12 - -/* - * Conversion from and to little-endian byte order. (no-op on i386/i486) - */ -#define LE_TO_CPU_U16(v) le16toh(v) -#define LE_TO_CPU_U32(v) le32toh(v) -#define CPU_TO_LE_U16(v) htole16(v) -#define CPU_TO_LE_U32(v) htole32(v) - -/* - * sector_data_t -- - * corresponds to the sector on the device - */ -typedef struct rtems_sector_data_s -{ - uint32_t sector_num; /* sector number on the device */ - uint8_t data[RTEMS_ZERO_LENGTH_ARRAY]; /* raw sector data */ -} rtems_sector_data_t; - - -/* - * Enum partition types - * see list at http://ata-atapi.com/hiwtab.htm - * - * @todo Should these have RTEMS before them. - */ -enum { - EMPTY_PARTITION = 0x00, - DOS_FAT12_PARTITION = 0x01, - DOS_FAT16_PARTITION = 0x04, - EXTENDED_PARTITION = 0x05, - DOS_P32MB_PARTITION = 0x06, - FAT32_PARTITION = 0x0B, - FAT32_LBA_PARTITION = 0x0C, - FAT16_LBA_PARTITION = 0x0E, - DM6_PARTITION = 0x54, - EZD_PARTITION = 0x55, - DM6_AUX1PARTITION = 0x51, - DM6_AUX3PARTITION = 0x53, - LINUX_SWAP = 0x82, - LINUX_NATIVE = 0x83, - LINUX_EXTENDED = 0x85 -}; - - -/* Forward declaration */ -struct rtems_disk_desc_s; - -/* - * part_desc_t -- - * contains all neccessary information about partition - */ -typedef struct rtems_part_desc_s { - uint8_t bootable; /* is the partition active */ - uint8_t sys_type; /* type of partition */ - uint8_t log_id; /* logical number of partition */ - uint32_t start; /* first partition sector, in absolute - * numeration */ - uint32_t size; /* size in sectors */ - uint32_t end; /* last partition sector, end = start + size - 1 */ - struct rtems_disk_desc_s *disk_desc; /* descriptor of disk, partition - * contains in */ - struct rtems_part_desc_s *ext_part; /* extended partition containing this - * one */ - - /* partitions, containing in this one */ - struct rtems_part_desc_s *sub_part[RTEMS_IDE_PARTITION_MAX_SUB_PARTITION_NUMBER]; -} rtems_part_desc_t; - - - -typedef struct rtems_disk_desc_s { - dev_t dev; /* device number */ - - /* device name in /dev filesystem */ - char dev_name[RTEMS_IDE_PARTITION_DEV_NAME_LENGTH_MAX]; - - uint32_t sector_size; /* size of sector */ - uint32_t sector_bits; /* the base-2 logarithm of sector_size */ - uint32_t lba_size; /* total amount of sectors in lba address mode */ - int last_log_id; /* used for logical disks enumerating */ - - /* primary partition descriptors */ - rtems_part_desc_t *partitions[RTEMS_IDE_PARTITION_MAX_PARTITION_NUMBER]; -} rtems_disk_desc_t; - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * rtems_ide_part_table_free -- - * frees disk descriptor structure - * - * PARAMETERS: - * disk_desc - disc descriptor structure to free - * - * RETURNS: - * N/A - */ -/** - * @deprecated Use the @ref rtems_bdpart "block device partition module" instead. - */ -void rtems_ide_part_table_free( - rtems_disk_desc_t *disk_desc -) RTEMS_DEPRECATED; - - -/* - * rtems_ide_part_table_get -- - * reads partition table structure from the device - * and creates disk description structure - * - * PARAMETERS: - * dev_name - path to physical device in /dev filesystem - * disk_desc - returned disc description structure - * - * RETURNS: - * RTEMS_SUCCESSFUL if success, or -1 and corresponding errno else - */ -/** - * @deprecated Use the @ref rtems_bdpart "block device partition module" instead. - */ -rtems_status_code rtems_ide_part_table_get( - const char *dev_name, - rtems_disk_desc_t *disk_desc -) RTEMS_DEPRECATED; - - -/* - * rtems_ide_part_table_initialize -- - * initializes logical devices on the physical IDE drive - * - * PARAMETERS: - * dev_name - path to physical device in /dev filesystem - * - * RETURNS: - * RTEMS_SUCCESSFUL if success, or -1 and corresponding errno else - */ -/** - * @deprecated Use the @ref rtems_bdpart "block device partition module" instead. - */ -rtems_status_code rtems_ide_part_table_initialize( - const char *dev_name -) RTEMS_DEPRECATED; - -#ifdef __cplusplus -} -#endif - -#endif /* _RTEMS_IDE_PART_TABLE_H */ diff --git a/cpukit/libblock/include/rtems/media.h b/cpukit/libblock/include/rtems/media.h deleted file mode 100644 index 77a1aa8348..0000000000 --- a/cpukit/libblock/include/rtems/media.h +++ /dev/null @@ -1,517 +0,0 @@ -/** - * @file - * - * @ingroup RTEMSMedia - * - * @brief Media API. - */ - -/* - * Copyright (c) 2009, 2010 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Obere Lagerstr. 30 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef RTEMS_MEDIA_H -#define RTEMS_MEDIA_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup RTEMSMedia Media Manager - * - * @brief Removable media support. - * - * The media manager may be used to maintain the life cycle of a removable - * media. Currently only disk devices are supported. The initiator posts an - * event to the media manager and it will respond with appropriate default - * actions. For example a disk attach will lead to inspection of the partition - * table and mounted file systems. Clients can register listeners to react to - * events. - */ -/**@{**/ - -#define RTEMS_MEDIA_MOUNT_BASE "/media" - -#define RTEMS_MEDIA_DELIMITER '-' - -/** - * Disk life cycle events: - * @dot - * digraph disk_events { - * "DISK ATTACH" -> "PARTITION INQUIRY"; - * "DISK ATTACH" -> "MOUNT"; - * "PARTITION INQUIRY" -> "PARTITION ATTACH"; - * "PARTITION INQUIRY" -> "DISK DETACH"; - * "PARTITION ATTACH" -> "MOUNT"; - * "MOUNT" -> "UNMOUNT"; - * "UNMOUNT" -> "PARTITION DETACH"; - * "UNMOUNT" -> "DISK DETACH"; - * "PARTITION DETACH" -> "DISK DETACH"; - * } - * @enddot - */ -typedef enum { - RTEMS_MEDIA_EVENT_DISK_ATTACH, - RTEMS_MEDIA_EVENT_DISK_DETACH, - RTEMS_MEDIA_EVENT_MOUNT, - RTEMS_MEDIA_EVENT_UNMOUNT, - RTEMS_MEDIA_EVENT_PARTITION_INQUIRY, - RTEMS_MEDIA_EVENT_PARTITION_ATTACH, - RTEMS_MEDIA_EVENT_PARTITION_DETACH, - RTEMS_MEDIA_EVENT_ERROR -} rtems_media_event; - -/** - * Normal state transition: - * @dot - * digraph state { - * INQUIRY -> READY [label="all listeners\nreturned successful"]; - * INQUIRY -> ABORTED [label="otherwise"]; - * READY -> SUCCESS [label="the worker\nreturned successful"]; - * READY -> FAILED [label="otherwise"]; - * } - * @enddot - */ -typedef enum { - RTEMS_MEDIA_STATE_INQUIRY, - RTEMS_MEDIA_STATE_READY, - RTEMS_MEDIA_STATE_ABORTED, - RTEMS_MEDIA_STATE_SUCCESS, - RTEMS_MEDIA_STATE_FAILED, - RTEMS_MEDIA_ERROR_DISK_UNKNOWN, - RTEMS_MEDIA_ERROR_DISK_EXISTS, - RTEMS_MEDIA_ERROR_DISK_OR_PARTITION_UNKNOWN, - RTEMS_MEDIA_ERROR_DISK_OR_PARTITION_EXISTS, - RTEMS_MEDIA_ERROR_PARTITION_UNKNOWN, - RTEMS_MEDIA_ERROR_PARTITION_ORPHAN, - RTEMS_MEDIA_ERROR_PARTITION_DETACH_WITH_MOUNT, - RTEMS_MEDIA_ERROR_PARTITION_WITH_UNKNOWN_DISK, - RTEMS_MEDIA_ERROR_MOUNT_POINT_UNKNOWN, - RTEMS_MEDIA_ERROR_MOUNT_POINT_EXISTS, - RTEMS_MEDIA_ERROR_MOUNT_POINT_ORPHAN -} rtems_media_state; - -/** - * @brief Event listener. - * - * The listener will be called with the @a listener_arg passed to - * rtems_media_listener_add(). - * - * Source and destination values for each event and state: - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
EventStateSourceDestination
RTEMS_MEDIA_EVENT_DISK_ATTACHRTEMS_MEDIA_STATE_INQUIRYdriver nameNULL
RTEMS_MEDIA_STATE_READYdriver nameNULL
RTEMS_MEDIA_STATE_ABORTEDdriver nameNULL
RTEMS_MEDIA_STATE_SUCCESSdriver namedisk path
RTEMS_MEDIA_STATE_FAILEDdriver nameNULL
RTEMS_MEDIA_EVENT_DISK_DETACHRTEMS_MEDIA_STATE_INQUIRYdisk pathNULL
RTEMS_MEDIA_STATE_READYdisk pathNULL
RTEMS_MEDIA_STATE_ABORTEDdisk pathNULL
RTEMS_MEDIA_STATE_SUCCESSdisk pathNULL
RTEMS_MEDIA_STATE_FAILEDdisk pathNULL
RTEMS_MEDIA_EVENT_PARTITION_INQUIRYRTEMS_MEDIA_STATE_INQUIRYdisk pathNULL
RTEMS_MEDIA_STATE_READYdisk pathNULL
RTEMS_MEDIA_STATE_ABORTEDdisk pathNULL
RTEMS_MEDIA_STATE_SUCCESSdisk pathNULL
RTEMS_MEDIA_STATE_FAILEDdisk pathNULL
RTEMS_MEDIA_EVENT_PARTITION_ATTACHRTEMS_MEDIA_STATE_INQUIRYdisk pathNULL
RTEMS_MEDIA_STATE_READYdisk pathNULL
RTEMS_MEDIA_STATE_ABORTEDdisk pathNULL
RTEMS_MEDIA_STATE_SUCCESSdisk pathpartition path
RTEMS_MEDIA_STATE_FAILEDdisk pathNULL
RTEMS_MEDIA_EVENT_PARTITION_DETACHRTEMS_MEDIA_STATE_INQUIRYpartition pathNULL
RTEMS_MEDIA_STATE_READYpartition pathNULL
RTEMS_MEDIA_STATE_ABORTEDpartition pathNULL
RTEMS_MEDIA_STATE_SUCCESSpartition pathNULL
RTEMS_MEDIA_STATE_FAILEDpartition pathNULL
RTEMS_MEDIA_EVENT_MOUNTRTEMS_MEDIA_STATE_INQUIRYdisk or partition pathNULL
RTEMS_MEDIA_STATE_READYdisk or partition pathNULL
RTEMS_MEDIA_STATE_ABORTEDdisk or partition pathNULL
RTEMS_MEDIA_STATE_SUCCESSdisk or partition pathmount path
RTEMS_MEDIA_STATE_FAILEDdisk or partition pathNULL
RTEMS_MEDIA_EVENT_UNMOUNTRTEMS_MEDIA_STATE_INQUIRYmount pathNULL
RTEMS_MEDIA_STATE_READYmount pathNULL
RTEMS_MEDIA_STATE_ABORTEDmount pathNULL
RTEMS_MEDIA_STATE_SUCCESSmount pathNULL
RTEMS_MEDIA_STATE_FAILEDmount pathNULL
RTEMS_MEDIA_EVENT_ERRORRTEMS_MEDIA_ERROR_DISK_UNKNOWNdisk pathNULL
RTEMS_MEDIA_ERROR_DISK_EXISTSdisk pathNULL
RTEMS_MEDIA_ERROR_DISK_OR_PARTITION_UNKNOWNdisk or partition pathNULL
RTEMS_MEDIA_ERROR_DISK_OR_PARTITION_EXISTSdisk or partition pathNULL
RTEMS_MEDIA_ERROR_PARTITION_UNKNOWNpartition pathNULL
RTEMS_MEDIA_ERROR_PARTITION_ORPHANpartition pathdisk path
RTEMS_MEDIA_ERROR_PARTITION_DETACH_WITH_MOUNTpartition pathmount path
RTEMS_MEDIA_ERROR_PARTITION_WITH_UNKNOWN_DISKpartition pathdisk path
RTEMS_MEDIA_ERROR_MOUNT_POINT_UNKNOWNmount pathNULL
RTEMS_MEDIA_ERROR_MOUNT_POINT_EXISTSmount pathNULL
RTEMS_MEDIA_ERROR_MOUNT_POINT_ORPHANmount pathdisk path
- * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_IO_ERROR In the inquiry state this will abort the action. - */ -typedef rtems_status_code (*rtems_media_listener)( - rtems_media_event event, - rtems_media_state state, - const char *src, - const char *dest, - void *listener_arg -); - -/** - * @brief Do the work corresponding to an event. - * - * The @a state will be - * - RTEMS_MEDIA_STATE_READY, or - * - RTEMS_MEDIA_STATE_ABORTED. - * - * It will be called with the @a src and @a worker_arg arguments passed to - * rtems_media_post_event(). - * - * The destination shall be returned in @a dest in case of success. It shall - * be allocated with malloc(). - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_IO_ERROR Failure. - */ -typedef rtems_status_code (*rtems_media_worker)( - rtems_media_state state, - const char *src, - char **dest, - void *worker_arg -); - -/** - * @name Base - */ -/**@{**/ - -/** - * @brief Initializes the media manager. - * - * Calling this function more than once will have no effects. There is no - * protection against concurrent access. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_NO_MEMORY Not enough resources. - */ -rtems_status_code rtems_media_initialize(void); - -/** - * @brief Adds the @a listener with argument @a listener_arg. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_NO_MEMORY Not enough memory. - * @retval RTEMS_TOO_MANY Such a listener is already present. - */ -rtems_status_code rtems_media_listener_add( - rtems_media_listener listener, - void *listener_arg -); - -/** - * @brief Removes the @a listener with argument @a listener_arg. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_INVALID_ID No such listener is present. - */ -rtems_status_code rtems_media_listener_remove( - rtems_media_listener listener, - void *listener_arg -); - -/** - * @brief Posts the @a event with source @a src. - * - * The @a worker will be called with the @a worker_arg argument. - * - * The destination will be returned in @a dest in case of success. It will be - * allocated with malloc() and should be freed if not needed anymore. - * - * The work will be done by the calling thread. You can avoid this if you use - * the media server via rtems_media_server_post_event(). - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_UNSATISFIED One or more listeners aborted the action. - * @retval RTEMS_IO_ERROR The worker returned with an error status. - */ -rtems_status_code rtems_media_post_event( - rtems_media_event event, - const char *src, - char **dest, - rtems_media_worker worker, - void *worker_arg -); - -/** @} */ - -/** - * @name Server - */ -/**@{**/ - -/** - * @brief Initializes the media manager and media server. - * - * It creates a server task with the @a priority, @a stack_size, @a modes, and - * @a attributes parameters. - * - * Calling this function more than once will have no effects. There is no - * protection against concurrent access. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_NO_MEMORY Not enough resources. - */ -rtems_status_code rtems_media_server_initialize( - rtems_task_priority priority, - size_t stack_size, - rtems_mode modes, - rtems_attribute attributes -); - -/** - * @brief Sends an event message to the media server. - * - * @see See rtems_media_post_event(). - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_NO_MEMORY Not enough resources to notify the media server. - * @retval RTEMS_NOT_CONFIGURED Media server is not initialized. - */ -rtems_status_code rtems_media_server_post_event( - rtems_media_event event, - const char *src, - rtems_media_worker worker, - void *worker_arg -); - -/** - * @brief See rtems_media_server_post_event(). - */ -static inline rtems_status_code rtems_media_server_disk_attach( - const char *driver_name, - rtems_media_worker worker, - void *worker_arg -) -{ - return rtems_media_server_post_event( - RTEMS_MEDIA_EVENT_DISK_ATTACH, - driver_name, - worker, - worker_arg - ); -} - -/** - * @brief See rtems_media_server_post_event(). - */ -static inline rtems_status_code rtems_media_server_disk_detach( - const char *disk_path -) -{ - return rtems_media_server_post_event( - RTEMS_MEDIA_EVENT_DISK_DETACH, - disk_path, - NULL, - NULL - ); -} - -/** @} */ - -/** - * @name Path Construction - */ -/**@{**/ - -/** - * @brief Creates a new path as "prefix/name-major". - * - * @return New string, or @c NULL if no memory is available. - */ -char *rtems_media_create_path( - const char *prefix, - const char *name, - rtems_device_major_number major -); - -/** - * @brief Replaces the prefix of the @a path with @a new_prefix. - * - * The prefix is everything up to the last '/'. - * - * @return New string, or @c NULL if no memory is available. - */ -char *rtems_media_replace_prefix(const char *new_prefix, const char *path); - -/** - * @brief Appends the @a minor number to the @a path resulting in "path-minor". - * - * @return New string, or @c NULL if no memory is available. - */ -char *rtems_media_append_minor( - const char *path, - rtems_device_minor_number minor -); - -/** @} */ - -/** - * @name Support - */ -/**@{**/ - -/** - * @brief Returns the device identifier for the device located at - * @a device_path in @a device_identifier. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_INVALID_ID No device at this path. - */ -rtems_status_code rtems_media_get_device_identifier( - const char *device_path, - dev_t *device_identifier -); - -const char *rtems_media_event_description(rtems_media_event event); - -const char *rtems_media_state_description(rtems_media_state state); - -/** @} */ - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* RTEMS_MEDIA_H */ diff --git a/cpukit/libblock/include/rtems/nvdisk-sram.h b/cpukit/libblock/include/rtems/nvdisk-sram.h deleted file mode 100644 index 3acaf600b6..0000000000 --- a/cpukit/libblock/include/rtems/nvdisk-sram.h +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @file rtems/nvdisk-sram.h - * - * This driver maps an NV disk to static RAM. You can use this - */ - -/* - * RTEMS Project (http://www.rtems.org/) - * - * Copyright 2007 Chris Johns (chrisj@rtems.org) - */ - -#if !defined (_RTEMS_NVDISK_SRAM_H_) -#define _RTEMS_NVDISK_SRAM_H_ - -#include - -/** - * The handlers for the NV Disk SRAM driver. - */ -extern const rtems_nvdisk_driver_handlers rtems_nvdisk_sram_handlers; - -#endif diff --git a/cpukit/libblock/include/rtems/nvdisk.h b/cpukit/libblock/include/rtems/nvdisk.h deleted file mode 100644 index 5570fb8c6b..0000000000 --- a/cpukit/libblock/include/rtems/nvdisk.h +++ /dev/null @@ -1,211 +0,0 @@ -/** - * @file rtems/nvdisk.h - * - * @brief Non-volatile Disk Block Device Implementation - */ - -/* - * Copyright (C) 2007 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -/** - * The Non-volatile disk provides a simple directly mapped disk - * driver with checksums for each. It is designed to provied a - * disk that can survive a restart. Examples are EEPROM devices - * which have byte writeable locations, or a battery backed up - * RAM disk. - * - * The low level driver provides the physical access to the - * hardware. - */ -#if !defined (_RTEMS_NVDISK_H_) -#define _RTEMS_NVDISK_H_ - -#include -#include - -#include - -/** - * The base name of the nv disks. - */ -#define RTEMS_NVDISK_DEVICE_BASE_NAME "/dev/nvd" - -/** - * NV disk specific ioctl request types. To use open the - * device and issue the ioctl call. - * - * @code - * int fd = open ("/dev/nvdisk0", O_WRONLY, 0); - * if (fd < 0) - * { - * printf ("driver open failed: %s\n", strerror (errno)); - * exit (1); - * } - * if (ioctl (fd, RTEMS_NVDISK_IOCTL_ERASE_DISK) < 0) - * { - * printf ("driver erase failed: %s\n", strerror (errno)); - * exit (1); - * } - * close (fd); - * @endcode - */ -#define RTEMS_NVDISK_IOCTL_ERASE_DISK _IO('B', 128) -#define RTEMS_NVDISK_IOCTL_MONITORING _IO('B', 129) -#define RTEMS_NVDISK_IOCTL_INFO_LEVEL _IO('B', 130) -#define RTEMS_NVDISK_IOCTL_PRINT_STATUS _IO('B', 131) - -/** - * NV Disk Monitoring Data allows a user to obtain - * the current status of the disk. - */ -typedef struct rtems_nvdisk_monitor_data -{ - uint32_t block_size; - uint32_t block_count; - uint32_t page_count; - uint32_t pages_available; - uint32_t pages_used; - uint32_t info_level; -} rtems_nvdisk_monitor_data; - -/** - * Return the number of kilo-bytes. - */ -#define RTEMS_NVDISK_KBYTES(_k) ((_k) * 1024) - -/** - * NV Low Level driver handlers. - - * Typically this structure is part of a table of handlers in the - * device which is referenced in the nvdisk configuration table. - * The reference is kept in the driver and used all the time to - * manage the nv device, therefore it must always exist. - */ -typedef struct rtems_nvdisk_driver_handlers -{ - /** - * Read data from the device into the buffer. Return an errno - * error number if the data cannot be read. - * - * @param device The device to read data from. - * @param flags Device specific flags for the driver. - * @param base The base address of the device. - * @param offset The offset in the segment to read. - * @param buffer The buffer to read the data into. - * @param size The amount of data to read. - * @retval 0 No error. - * @retval EIO The read did not complete. - */ - int (*read) (uint32_t device, uint32_t flags, void* base, - uint32_t offset, void* buffer, size_t size); - - /** - * Write data from the buffer to the device. Return an errno - * error number if the device cannot be written to. - * - * @param device The device to write data to. - * @param flags Device specific flags for the driver. - * @param base The base address of the device. - * @param offset The offset in the device to write to. - * @param buffer The buffer to write the data from. - * @param size The amount of data to write. - * @retval 0 No error. - * @retval EIO The write did not complete or verify. - */ - int (*write) (uint32_t device, uint32_t flags, void* base, - uint32_t offset, const void* buffer, size_t size); - - /** - * Verify data in the buffer to the data in the device. Return an - * errno error number if the device cannot be read or the data verified. - * - * @param device The device to verify the data with. - * @param flags Device specific flags for the driver. - * @param base The base address of the device. - * @param offset The offset in the device to verify. - * @param buffer The buffer to verify the data in the device with. - * @param size The amount of data to verify. - * @retval 0 No error. - * @retval EIO The data did not verify. - */ - int (*verify) (uint32_t device, uint32_t flags, void* base, - uint32_t offset, const void* buffer, size_t size); - -} rtems_nvdisk_driver_handlers; - -/** - * NV Device Descriptor holds the description of a device that is - * part of the NV disk. - * - * Typically this structure is part of a table of the device which - * is referenced in the nvdisk configuration table. - * The reference is kept in the driver and used all the time to - * manage the nv device, therefore it must always exist. - */ -typedef struct rtems_nvdisk_device_desc -{ - uint32_t flags; /**< Private user flags. */ - void* base; /**< Base address of the device. */ - uint32_t size; /**< Size of the device. */ - const rtems_nvdisk_driver_handlers* nv_ops; /**< Device handlers. */ -} rtems_nvdisk_device_desc; - -/** - * RTEMS Non-Volatile Disk configuration table used to initialise the - * driver. - */ -typedef struct rtems_nvdisk_config -{ - uint32_t block_size; /**< The block size. */ - uint32_t device_count; /**< The number of devices. */ - const rtems_nvdisk_device_desc* devices; /**< The device descriptions. */ - uint32_t flags; /**< Set of flags to control - driver. */ - uint32_t info_level; /**< Default info level. */ -} rtems_nvdisk_config; - -/* - * Driver flags. - */ - -/** - * Check the pages during initialisation to see which pages are - * valid and which are not. This could slow down initialising the - * disk driver. - */ -#define RTEMS_NVDISK_CHECK_PAGES (1 << 0) - -/** - * Non-volatile disk device driver initialization. Place in a table as the - * initialisation entry and remainder of the entries are the RTEMS block - * device generic handlers. - * - * @param major NV disk major device number. - * @param minor Minor device number, not applicable. - * @param arg Initialization argument, not applicable. - * @return The rtems_device_driver is actually just - * rtems_status_code. - */ -rtems_device_driver -rtems_nvdisk_initialize (rtems_device_major_number major, - rtems_device_minor_number minor, - void* arg); - -/** - * External reference to the configuration. Please supply. - * Support is present in confdefs.h for providing this variable. - */ -extern const rtems_nvdisk_config rtems_nvdisk_configuration[]; - -/** - * External reference to the number of configurations. Please supply. - * Support is present in confdefs.h for providing this variable. - */ -extern uint32_t rtems_nvdisk_configuration_size; - -#endif diff --git a/cpukit/libblock/include/rtems/ramdisk.h b/cpukit/libblock/include/rtems/ramdisk.h deleted file mode 100644 index 727efddbe8..0000000000 --- a/cpukit/libblock/include/rtems/ramdisk.h +++ /dev/null @@ -1,227 +0,0 @@ -/** - * @file - * - * @brief RAM Disk Block Device API - */ - -/* - * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia - * Author: Victor V. Vengerov - */ - -#ifndef _RTEMS_RAMDISK_H -#define _RTEMS_RAMDISK_H - - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup rtems_ramdisk RAM Disk Device - * - * @ingroup rtems_blkdev - * - */ -/**@{**/ - -/** - * @name Static Configuration - */ -/**@{**/ - -/** - * @brief RAM disk configuration table entry. - */ -typedef struct rtems_ramdisk_config { - /** - * @brief RAM disk block size. - */ - uint32_t block_size; - - /** - * @brief Number of blocks on this RAM disk. - */ - rtems_blkdev_bnum block_num; - - /** - * @brief RAM disk location or @c NULL if RAM disk memory should be allocated - * dynamically. - */ - void *location; -} rtems_ramdisk_config; - -/** - * @brief External reference to the RAM disk configuration table describing - * each RAM disk in the system. - * - * The configuration table is provided by the application. - */ -extern rtems_ramdisk_config rtems_ramdisk_configuration []; - -/** - * @brief External reference the size of the RAM disk configuration table - * @ref rtems_ramdisk_configuration. - * - * The configuration table size is provided by the application. - */ -extern size_t rtems_ramdisk_configuration_size; - -/** - * @brief RAM disk driver initialization entry point. - */ -rtems_device_driver ramdisk_initialize( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *arg -); - -/** - * RAM disk driver table entry. - */ -#define RAMDISK_DRIVER_TABLE_ENTRY \ - { \ - .initialization_entry = ramdisk_initialize, \ - RTEMS_GENERIC_BLOCK_DEVICE_DRIVER_ENTRIES \ - } - -#define RAMDISK_DEVICE_BASE_NAME "/dev/rd" - -/** @} */ - -/** - * @name Runtime Configuration - */ -/**@{**/ - -/** - * @brief RAM disk descriptor. - */ -typedef struct ramdisk { - /** - * @brief RAM disk block size, the media size. - */ - uint32_t block_size; - - /** - * @brief Number of blocks on this RAM disk. - */ - rtems_blkdev_bnum block_num; - - /** - * @brief RAM disk memory area. - */ - void *area; - - /** - * @brief RAM disk is initialized. - */ - bool initialized; - - /** - * @brief Indicates if memory is allocated by malloc() for this RAM disk. - */ - bool malloced; - - /** - * @brief Trace enable. - */ - bool trace; - - /** - * @brief Free the RAM disk at the block device delete request. - */ - bool free_at_delete_request; -} ramdisk; - -extern const rtems_driver_address_table ramdisk_ops; - -int ramdisk_ioctl(rtems_disk_device *dd, uint32_t req, void *argp); - -/** - * @brief Allocates and initializes a RAM disk descriptor. - * - * The block size will be @a media_block_size. The block count will be - * @a media_block_count. The disk storage area begins at @a area_begin. If - * @a area_begin is @c NULL, the memory will be allocated and zeroed. Sets the - * trace enable to @a trace. - * - * @return Pointer to allocated and initialized ramdisk structure, or @c NULL - * if no memory is available. - * - * @note - * Runtime configuration example: - * @code - * #include - * - * rtems_status_code create_ramdisk( - * const char *device, - * uint32_t media_block_size, - * rtems_blkdev_bnum media_block_count - * ) - * { - * rtems_status_code sc; - * ramdisk *rd; - * - * rd = ramdisk_allocate(NULL, media_block_size, media_block_count, false); - * if (rd != NULL) { - * sc = rtems_blkdev_create( - * device, - * media_block_size, - * media_block_count, - * ramdisk_ioctl, - * rd - * ); - * } else { - * sc = RTEMS_UNSATISFIED; - * } - * - * return sc; - * } - * @endcode - */ -ramdisk *ramdisk_allocate( - void *area_begin, - uint32_t media_block_size, - rtems_blkdev_bnum media_block_count, - bool trace -); - -void ramdisk_free(ramdisk *rd); - -static inline void ramdisk_enable_free_at_delete_request(ramdisk *rd) -{ - rd->free_at_delete_request = true; -} - -/** - * @brief Allocates, initializes and registers a RAM disk. - * - * The block size will be @a media_block_size. The block count will be - * @a media_block_count. The disk storage will be allocated. Sets the trace - * enable to @a trace. Registers a device node with disk name path @a disk. - * The registered device number will be returned in @a dev. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_UNSATISFIED Something is wrong. - */ -rtems_status_code ramdisk_register( - uint32_t media_block_size, - rtems_blkdev_bnum media_block_count, - bool trace, - const char *disk, - dev_t *dev -); - -/** @} */ - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/libblock/include/rtems/sparse-disk.h b/cpukit/libblock/include/rtems/sparse-disk.h deleted file mode 100644 index e558e08925..0000000000 --- a/cpukit/libblock/include/rtems/sparse-disk.h +++ /dev/null @@ -1,137 +0,0 @@ -/** - * @file - * - * @ingroup rtems_sparse_disk - * - * @brief Sparse disk block device API. - */ - -/* - * Copyright (c) 2012 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Obere Lagerstr. 30 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef SPARSE_DISK_H -#define SPARSE_DISK_H - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup rtems_sparse_disk Sparse Disk Device - * - * @ingroup rtems_blkdev - * - */ -/**@{**/ - -typedef struct { - rtems_blkdev_bnum block; - void *data; -} rtems_sparse_disk_key; - -typedef struct rtems_sparse_disk rtems_sparse_disk; - -typedef void (*rtems_sparse_disk_delete_handler)(rtems_sparse_disk *sparse_disk); - -struct rtems_sparse_disk { - rtems_id mutex; - rtems_blkdev_bnum blocks_with_buffer; - size_t used_count; - uint32_t media_block_size; - rtems_sparse_disk_delete_handler delete_handler; - uint8_t fill_pattern; - rtems_sparse_disk_key *key_table; -}; - -/** - * @brief Creates and registers a sparse disk. - * - * @param[in] device_file_name The device file name path. - * @param[in] media_block_size The media block size in bytes. - * @param[in] blocks_with_buffer Blocks of the device with a buffer. Other - * blocks can store only fill pattern value bytes. - * @param[in] block_count The media block count of the device. It is the sum - * of blocks with buffer and blocks that contain only fill pattern value bytes. - * @param[in] fill_pattern The fill pattern specifies the byte value of blocks - * without a buffer. It is also the initial value for blocks with a buffer. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_INVALID_NUMBER Media block size or media block count is not - * positive. The blocks with buffer count is greater than the media block count. - * @retval RTEMS_NO_MEMORY Not enough memory. - * @retval RTEMS_TOO_MANY Cannot create semaphore. - * @retval RTEMS_UNSATISFIED Cannot create generic device node. - * - * @see rtems_sparse_disk_register(). - */ -rtems_status_code rtems_sparse_disk_create_and_register( - const char *device_file_name, - uint32_t media_block_size, - rtems_blkdev_bnum blocks_with_buffer, - rtems_blkdev_bnum media_block_count, - uint8_t fill_pattern -); - -/** - * @brief Frees a sparse disk. - * - * Calls free() on the sparse disk pointer. - */ -void rtems_sparse_disk_free( rtems_sparse_disk *sparse_disk ); - -/** - * @brief Initializes and registers a sparse disk. - * - * This will create one semaphore for mutual exclusion. - * - * @param[in] device_file_name The device file name path. - * @param[in, out] sparse_disk The sparse disk. - * @param[in] media_block_size The media block size in bytes. - * @param[in] blocks_with_buffer Blocks of the device with a buffer. Other - * blocks can store only fill pattern value bytes. - * @param[in] block_count The media block count of the device. It is the sum - * of blocks with buffer and blocks that contain only fill pattern value bytes. - * @param[in] fill_pattern The fill pattern specifies the byte value of blocks - * without a buffer. It is also the initial value for blocks with a buffer. - * @param[in] sparse_disk_delete The sparse disk delete handler. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_INVALID_NUMBER Media block size or media block count is not - * positive. The blocks with buffer count is greater than the media block count. - * @retval RTEMS_INVALID_ADDRESS Invalid sparse disk address. - * @retval RTEMS_TOO_MANY Cannot create semaphore. - * @retval RTEMS_UNSATISFIED Cannot create generic device node. - */ -rtems_status_code rtems_sparse_disk_register( - const char *device_file_name, - rtems_sparse_disk *sparse_disk, - uint32_t media_block_size, - rtems_blkdev_bnum blocks_with_buffer, - rtems_blkdev_bnum media_block_count, - uint8_t fill_pattern, - rtems_sparse_disk_delete_handler sparse_disk_delete -); - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* SPARSE_DISK_H */ diff --git a/cpukit/libcrypt/Makefile.am b/cpukit/libcrypt/Makefile.am index fe174d4e9d..cb8dbe129a 100644 --- a/cpukit/libcrypt/Makefile.am +++ b/cpukit/libcrypt/Makefile.am @@ -1,7 +1,5 @@ include $(top_srcdir)/automake/compile.am -include_HEADERS = - noinst_LIBRARIES = libcrypt.a libcrypt_a_CPPFLAGS = $(AM_CPPFLAGS) @@ -13,5 +11,4 @@ libcrypt_a_SOURCES += crypt-sha256.c libcrypt_a_SOURCES += crypt-sha512.c libcrypt_a_SOURCES += misc.c -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am diff --git a/cpukit/libcrypt/preinstall.am b/cpukit/libcrypt/preinstall.am deleted file mode 100644 index feb5d1d4e3..0000000000 --- a/cpukit/libcrypt/preinstall.am +++ /dev/null @@ -1,15 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -$(PROJECT_INCLUDE)/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE) - @: > $(PROJECT_INCLUDE)/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/$(dirstamp) - diff --git a/cpukit/libcsupport/Makefile.am b/cpukit/libcsupport/Makefile.am index 038ac93548..253c2c9924 100644 --- a/cpukit/libcsupport/Makefile.am +++ b/cpukit/libcsupport/Makefile.am @@ -5,32 +5,7 @@ noinst_LIBRARIES = libcsupport.a libcalloc.a libcsupport_a_CPPFLAGS = $(AM_CPPFLAGS) libcalloc_a_CPPFLAGS = $(AM_CPPFLAGS) -include_rtemsdir = $(includedir)/rtems -include_rtems_HEADERS = include/iosupp.h -include_rtems_HEADERS += include/ringbuf.h -include_rtems_HEADERS += include/rtems/tod.h -include_rtems_HEADERS += include/spurious.h -include_rtems_HEADERS += include/vmeintr.h - ## rtems -include_rtems_HEADERS += include/rtems/assoc.h -include_rtems_HEADERS += include/rtems/deviceio.h -include_rtems_HEADERS += include/rtems/error.h -include_rtems_HEADERS += include/rtems/libcsupport.h -include_rtems_HEADERS += include/rtems/libio.h -include_rtems_HEADERS += include/rtems/libio_.h -include_rtems_HEADERS += include/rtems/malloc.h -include_rtems_HEADERS += include/rtems/termiostypes.h -include_rtems_HEADERS += include/rtems/gxx_wrappers.h - -include_machinedir = $(includedir)/machine -include_machine_HEADERS = -include_machine_HEADERS += include/machine/_kernel_cpuset.h -include_machine_HEADERS += include/machine/_kernel_param.h -include_machine_HEADERS += include/machine/_kernel_time.h -include_machine_HEADERS += include/machine/_kernel_types.h -include_machine_HEADERS += include/machine/_timecounter.h - ## General stuff ERROR_C_FILES = src/error.c src/__assert.c @@ -157,5 +132,4 @@ libcalloc_a_CFLAGS = -fno-builtin EXTRA_DIST = src/TODO src/CASES src/README -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am diff --git a/cpukit/libcsupport/include/iosupp.h b/cpukit/libcsupport/include/iosupp.h deleted file mode 100644 index 9fe8a6ab1d..0000000000 --- a/cpukit/libcsupport/include/iosupp.h +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @file rtems/iosupp.h - * - * This include file defines some special characters of interest. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_IOSUPP_H -#define _RTEMS_IOSUPP_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* character constants */ - -#define BS 0x08 /* backspace */ -#define LF 0x0a /* line feed */ -#define CR 0x0d /* carriage return */ -#define XON 0x11 /* control-Q */ -#define XOFF 0x13 /* control-S */ - -/* structures */ - -#ifdef IOSUPP_INIT -#define IOSUPP_EXTERN -#else -#undef IOSUPP_EXTERN -#define IOSUPP_EXTERN extern -#endif - -/* functions */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/libcsupport/include/machine/_kernel_cpuset.h b/cpukit/libcsupport/include/machine/_kernel_cpuset.h deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/cpukit/libcsupport/include/machine/_kernel_param.h b/cpukit/libcsupport/include/machine/_kernel_param.h deleted file mode 100644 index 183bb895a2..0000000000 --- a/cpukit/libcsupport/include/machine/_kernel_param.h +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include -#include -#include - -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef TRUE -#define TRUE 1 -#endif - -#ifndef _BYTEORDER_PROTOTYPED -#define _BYTEORDER_PROTOTYPED -__BEGIN_DECLS -__uint32_t htonl(__uint32_t); -__uint16_t htons(__uint16_t); -__uint32_t ntohl(__uint32_t); -__uint16_t ntohs(__uint16_t); -__END_DECLS -#endif - -#ifndef _BYTEORDER_FUNC_DEFINED -#define _BYTEORDER_FUNC_DEFINED -#define htonl(x) __htonl(x) -#define htons(x) __htons(x) -#define ntohl(x) __ntohl(x) -#define ntohs(x) __ntohs(x) -#endif /* !_BYTEORDER_FUNC_DEFINED */ diff --git a/cpukit/libcsupport/include/machine/_kernel_time.h b/cpukit/libcsupport/include/machine/_kernel_time.h deleted file mode 100644 index 8200b6a73e..0000000000 --- a/cpukit/libcsupport/include/machine/_kernel_time.h +++ /dev/null @@ -1,173 +0,0 @@ -/*- - * Copyright (c) 2016 embedded brains GmbH - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if !defined(_SYS_TIME_H_) || !defined(_KERNEL) -#error "must be included via in kernel space" -#endif - -#include - -/* Operations on timespecs */ -#define timespecclear(tvp) ((tvp)->tv_sec = (tvp)->tv_nsec = 0) -#define timespecisset(tvp) ((tvp)->tv_sec || (tvp)->tv_nsec) -#define timespeccmp(tvp, uvp, cmp) \ - (((tvp)->tv_sec == (uvp)->tv_sec) ? \ - ((tvp)->tv_nsec cmp (uvp)->tv_nsec) : \ - ((tvp)->tv_sec cmp (uvp)->tv_sec)) -#define timespecadd(vvp, uvp) \ - do { \ - (vvp)->tv_sec += (uvp)->tv_sec; \ - (vvp)->tv_nsec += (uvp)->tv_nsec; \ - if ((vvp)->tv_nsec >= 1000000000) { \ - (vvp)->tv_sec++; \ - (vvp)->tv_nsec -= 1000000000; \ - } \ - } while (0) -#define timespecsub(vvp, uvp) \ - do { \ - (vvp)->tv_sec -= (uvp)->tv_sec; \ - (vvp)->tv_nsec -= (uvp)->tv_nsec; \ - if ((vvp)->tv_nsec < 0) { \ - (vvp)->tv_sec--; \ - (vvp)->tv_nsec += 1000000000; \ - } \ - } while (0) - -/* Operations on timevals. */ - -#define timevalclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0) -#define timevalisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) -#define timevalcmp(tvp, uvp, cmp) \ - (((tvp)->tv_sec == (uvp)->tv_sec) ? \ - ((tvp)->tv_usec cmp (uvp)->tv_usec) : \ - ((tvp)->tv_sec cmp (uvp)->tv_sec)) - -/* timevaladd and timevalsub are not inlined */ - -/* - * Kernel to clock driver interface. - */ -void inittodr(time_t base); -void resettodr(void); - -#define time_second _Timecounter_Time_second -#define time_uptime _Timecounter_Time_uptime -extern struct timeval boottime; -extern struct bintime tc_tick_bt; -extern sbintime_t tc_tick_sbt; -extern struct bintime tick_bt; -extern sbintime_t tick_sbt; -extern int tc_precexp; -extern int tc_timepercentage; -extern struct bintime bt_timethreshold; -extern struct bintime bt_tickthreshold; -extern sbintime_t sbt_timethreshold; -extern sbintime_t sbt_tickthreshold; - -/* - * Functions for looking at our clock: [get]{bin,nano,micro}[up]time() - * - * Functions without the "get" prefix returns the best timestamp - * we can produce in the given format. - * - * "bin" == struct bintime == seconds + 64 bit fraction of seconds. - * "nano" == struct timespec == seconds + nanoseconds. - * "micro" == struct timeval == seconds + microseconds. - * - * Functions containing "up" returns time relative to boot and - * should be used for calculating time intervals. - * - * Functions without "up" returns UTC time. - * - * Functions with the "get" prefix returns a less precise result - * much faster than the functions without "get" prefix and should - * be used where a precision of 1/hz seconds is acceptable or where - * performance is priority. (NB: "precision", _not_ "resolution" !) - */ - -#define binuptime(_bt) _Timecounter_Binuptime(_bt) -#define nanouptime(_tsp) _Timecounter_Nanouptime(_tsp) -#define microuptime(_tvp) _Timecounter_Microuptime(_tvp) - -static __inline sbintime_t -sbinuptime(void) -{ - struct bintime _bt; - - binuptime(&_bt); - return (bttosbt(_bt)); -} - -#define bintime(_bt) _Timecounter_Bintime(_bt) -#define nanotime(_tsp) _Timecounter_Nanotime(_tsp) -#define microtime(_tvp) _Timecounter_Microtime(_tvp) - -#define getbinuptime(_bt) _Timecounter_Getbinuptime(_bt) -#define getnanouptime(_tsp) _Timecounter_Getnanouptime(_tsp) -#define getmicrouptime(_tvp) _Timecounter_Getmicrouptime(_tvp) - -static __inline sbintime_t -getsbinuptime(void) -{ - struct bintime _bt; - - getbinuptime(&_bt); - return (bttosbt(_bt)); -} - -#define getbintime(_bt) _Timecounter_Getbintime(_bt) -#define getnanotime(_tsp) _Timecounter_Getnanotime(_tsp) -#define getmicrotime(_tvp) _Timecounter_Getmicrotime(_tvp) - -#define getboottime(_tvp) _Timecounter_Getboottime(_tvp) -#define getboottimebin(_bt) _Timecounter_Getboottimebin(_bt) - -/* Other functions */ -int itimerdecr(struct itimerval *itp, int usec); -int itimerfix(struct timeval *tv); -int ppsratecheck(struct timeval *, int *, int); -int ratecheck(struct timeval *, const struct timeval *); -void timevaladd(struct timeval *t1, const struct timeval *t2); -void timevalsub(struct timeval *t1, const struct timeval *t2); -int tvtohz(struct timeval *tv); - -#define TC_DEFAULTPERC 5 - -#define BT2FREQ(bt) \ - (((uint64_t)0x8000000000000000 + ((bt)->frac >> 2)) / \ - ((bt)->frac >> 1)) - -#define SBT2FREQ(sbt) ((SBT_1S + ((sbt) >> 1)) / (sbt)) - -#define FREQ2BT(freq, bt) \ -{ \ - (bt)->sec = 0; \ - (bt)->frac = ((uint64_t)0x8000000000000000 / (freq)) << 1; \ -} - -#define TIMESEL(sbt, sbt2) \ - (((sbt2) >= sbt_timethreshold) ? \ - ((*(sbt) = getsbinuptime()), 1) : ((*(sbt) = sbinuptime()), 0)) diff --git a/cpukit/libcsupport/include/machine/_kernel_types.h b/cpukit/libcsupport/include/machine/_kernel_types.h deleted file mode 100644 index 892ec413d5..0000000000 --- a/cpukit/libcsupport/include/machine/_kernel_types.h +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * Copyright (c) 2016 embedded brains GmbH - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if !defined(_SYS_TYPES_H) || !defined(_KERNEL) -#error "must be included via in kernel space" -#endif - -typedef int boolean_t; -typedef struct device *device_t; -typedef char vm_memattr_t; /* memory attribute codes */ -typedef struct vm_page *vm_page_t; diff --git a/cpukit/libcsupport/include/machine/_timecounter.h b/cpukit/libcsupport/include/machine/_timecounter.h deleted file mode 100644 index fb974f13c1..0000000000 --- a/cpukit/libcsupport/include/machine/_timecounter.h +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 2016 embedded brains GmbH - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _SYS_TIME_H_ -#error " must be included first" -#endif /* !_SYS_TIME_H_ */ - -#ifndef _MACHINE__TIMECOUNTER_H_ -#define _MACHINE__TIMECOUNTER_H_ - -__BEGIN_DECLS -extern volatile time_t _Timecounter_Time_second; -extern volatile int32_t _Timecounter_Time_uptime; -extern struct bintime _Timecounter_Boottimebin; - -void _Timecounter_Binuptime(struct bintime *); -void _Timecounter_Nanouptime(struct timespec *); -void _Timecounter_Microuptime(struct timeval *); -void _Timecounter_Bintime(struct bintime *); -void _Timecounter_Nanotime(struct timespec *); -void _Timecounter_Microtime(struct timeval *); -void _Timecounter_Getbinuptime(struct bintime *); -void _Timecounter_Getnanouptime(struct timespec *); -void _Timecounter_Getmicrouptime(struct timeval *); -void _Timecounter_Getbintime(struct bintime *); -void _Timecounter_Getnanotime(struct timespec *); -void _Timecounter_Getmicrotime(struct timeval *); -__END_DECLS - -#endif /* _MACHINE__TIMECOUNTER_H_ */ diff --git a/cpukit/libcsupport/include/ringbuf.h b/cpukit/libcsupport/include/ringbuf.h deleted file mode 100644 index c16a79d1ae..0000000000 --- a/cpukit/libcsupport/include/ringbuf.h +++ /dev/null @@ -1,63 +0,0 @@ -/** - * @file - * - * @brief Simple Ring Buffer Functionality - * - * This file provides simple ring buffer functionality. - */ - - -#ifndef _RTEMS_RINGBUF_H -#define _RTEMS_RINGBUF_H - -#include - -#ifndef RINGBUF_QUEUE_LENGTH -#define RINGBUF_QUEUE_LENGTH 128 -#endif - -typedef struct { - uint8_t buffer[RINGBUF_QUEUE_LENGTH]; - volatile int head; - volatile int tail; - rtems_interrupt_lock lock; -} Ring_buffer_t; - -#define Ring_buffer_Initialize( _buffer ) \ - do { \ - (_buffer)->head = (_buffer)->tail = 0; \ - rtems_interrupt_lock_initialize(&(_buffer)->lock, "ring buffer"); \ - } while ( 0 ) - -#define Ring_buffer_Destory( _buffer ) \ - do { \ - rtems_interrupt_lock_destroy(&(_buffer)->lock); \ - } while ( 0 ) - -#define Ring_buffer_Is_empty( _buffer ) \ - ( (_buffer)->head == (_buffer)->tail ) - -#define Ring_buffer_Is_full( _buffer ) \ - ( (_buffer)->head == ((_buffer)->tail + 1) % RINGBUF_QUEUE_LENGTH ) - -#define Ring_buffer_Add_character( _buffer, _ch ) \ - do { \ - rtems_interrupt_lock_context lock_context; \ - \ - rtems_interrupt_lock_acquire( &(_buffer)->lock, &lock_context ); \ - (_buffer)->tail = ((_buffer)->tail+1) % RINGBUF_QUEUE_LENGTH; \ - (_buffer)->buffer[ (_buffer)->tail ] = (_ch); \ - rtems_interrupt_lock_release( &(_buffer)->lock, &lock_context ); \ - } while ( 0 ) - -#define Ring_buffer_Remove_character( _buffer, _ch ) \ - do { \ - rtems_interrupt_lock_context lock_context; \ - \ - rtems_interrupt_lock_acquire( &(_buffer)->lock, &lock_context ); \ - (_buffer)->head = ((_buffer)->head+1) % RINGBUF_QUEUE_LENGTH; \ - (_ch) = (_buffer)->buffer[ (_buffer)->head ]; \ - rtems_interrupt_lock_release( &(_buffer)->lock, &lock_context ); \ - } while ( 0 ) - -#endif diff --git a/cpukit/libcsupport/include/rtems/assoc.h b/cpukit/libcsupport/include/rtems/assoc.h deleted file mode 100644 index 345761758a..0000000000 --- a/cpukit/libcsupport/include/rtems/assoc.h +++ /dev/null @@ -1,204 +0,0 @@ -/** - * @file rtems/assoc.h - * - * @brief RTEMS Associativity Routines - * - * RTEMS associativity routines. Mainly used to convert a value from - * one space to another (eg: our errno's to host errno's and vice-versa) - */ - - -#ifndef _RTEMS_RTEMS_ASSOC_H -#define _RTEMS_RTEMS_ASSOC_H - -/** - * @defgroup Associativity Associativity Routines - */ -/**@{*/ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - const char *name; - uint32_t local_value; - uint32_t remote_value; -} rtems_assoc_t; - -/* - * Flag/marker for optional default value in each table - */ - -#define RTEMS_ASSOC_DEFAULT_NAME "(default)" - -/** - * @brief RTEMS Associate Pointer by Name - */ -const rtems_assoc_t *rtems_assoc_ptr_by_name( - const rtems_assoc_t *, - const char * -); - -/** - * @brief RTEMS Associate Pointer by Remote - */ -const rtems_assoc_t *rtems_assoc_ptr_by_remote( - const rtems_assoc_t *, - uint32_t -); - -uint32_t rtems_assoc_remote_by_local( - const rtems_assoc_t *, - uint32_t -); - -/** - * @brief RTEMS Associate Local by Remote - */ -uint32_t rtems_assoc_local_by_remote( - const rtems_assoc_t *, - uint32_t -); - -/** - * @brief RTEMS Associate Remote by Name - */ -uint32_t rtems_assoc_remote_by_name( - const rtems_assoc_t *, - const char * -); - -/** - * @brief RTEMS Associate Local by Name - */ -uint32_t rtems_assoc_local_by_name( - const rtems_assoc_t *, - const char * -); - -/** - * @brief RTEMS Associate Name by Local - */ -const char *rtems_assoc_name_by_local( - const rtems_assoc_t *, - uint32_t -); - -/** - * @brief RTEMS Associate Name by Remote - */ -const char *rtems_assoc_name_by_remote( - const rtems_assoc_t *, - uint32_t -); - -/** - * @brief RTEMS Assoc Routines - */ -uint32_t rtems_assoc_remote_by_local_bitfield( - const rtems_assoc_t *, - uint32_t -); - -/** - * @brief RTEMS Associate Name by Local Bitfield - */ -char *rtems_assoc_name_by_local_bitfield( - const rtems_assoc_t *, - uint32_t , - char * -); - -/** - * @brief RTEMS Associate Name by Remote Bitfield - */ -char *rtems_assoc_name_by_remote_bitfield( - const rtems_assoc_t *, - uint32_t , - char * -); - -uint32_t rtems_assoc_local_by_remote_bitfield( - const rtems_assoc_t *, - uint32_t -); - -/** - * @brief RTEMS Associate Pointer by Local - */ -const rtems_assoc_t *rtems_assoc_ptr_by_local( - const rtems_assoc_t *ap, - uint32_t local_value -); - -#if defined(INSIDE_ASSOC) - -#define rtems_assoc_is_default(_ap) \ - ((_ap)->name && !strcmp((_ap)->name, RTEMS_ASSOC_DEFAULT_NAME)) - -/** - * @brief RTEMS Associate Bad Name - * - * what to return if a value is not found - * this is not reentrant, but it really shouldn't be invoked anyway - */ -const char *rtems_assoc_name_bad( - uint32_t bad_value -); -#endif - -typedef struct { - uint32_t bits; - const char *name; -} rtems_assoc_32_pair; - -/** - * @brief Converts the specified value into a text representation. - * - * @param[in] value The value to convert. - * @param[in] buffer The buffer for the text representation. - * @param[in] buffer_size The buffer size in characters. - * @param[in] pairs Names for particular bits. - * @param[in] pair_count Count of pairs. - * @param[in] separator Separator between individual names. - * @param[in] fallback Fallback value in case no bits contained in the pairs - * are set in the value. - * - * @retval The length of the text representation. May be greater than or equal - * to the buffer size if truncation occurred. - */ -size_t rtems_assoc_32_to_string( - uint32_t value, - char *buffer, - size_t buffer_size, - const rtems_assoc_32_pair *pairs, - size_t pair_count, - const char *separator, - const char *fallback -); - -/** - * @brief Converts the specified thread states into a text representation. - * - * @param[in] states The thread states to convert. - * @param[in] buffer The buffer for the text representation. - * @param[in] buffer_size The buffer size in characters. - * - * @retval The length of the text representation. May be greater than or equal - * to the buffer size if truncation occurred. - */ -size_t rtems_assoc_thread_states_to_string( - uint32_t states, - char *buffer, - size_t buffer_size -); - -#ifdef __cplusplus -} -#endif -/**@}*/ -#endif /* ! _RTEMS_RTEMS_ASSOC_H */ diff --git a/cpukit/libcsupport/include/rtems/deviceio.h b/cpukit/libcsupport/include/rtems/deviceio.h deleted file mode 100644 index a448fc7bb4..0000000000 --- a/cpukit/libcsupport/include/rtems/deviceio.h +++ /dev/null @@ -1,88 +0,0 @@ -/** - * @file - * - * @brief Operations on IMFS Device Nodes - */ - -/* - * COPYRIGHT (c) 1989-2012. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_DEVICEIO_H -#define _RTEMS_DEVICEIO_H - -#include - -/** - * @defgroup IMFSDevices IMFS Device IO Handler - * - * @ingroup IMFS - * - * This contains the interface to device drivers using the RTEMS Classic API. - */ -/**@{*/ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @brief IMFS device node handlers. - * - * IMFS Device Node Handlers - * - * This file contains the set of handlers used to map operations on - * IMFS device nodes onto calls to the RTEMS Classic API IO Manager. - */ -int rtems_deviceio_open( - rtems_libio_t *iop, - const char *path, - int oflag, - mode_t mode, - rtems_device_major_number major, - rtems_device_minor_number minor -); - -int rtems_deviceio_close( - rtems_libio_t *iop, - rtems_device_major_number major, - rtems_device_minor_number minor -); - -ssize_t rtems_deviceio_read( - rtems_libio_t *iop, - void *buf, - size_t nbyte, - rtems_device_major_number major, - rtems_device_minor_number minor -); - -ssize_t rtems_deviceio_write( - rtems_libio_t *iop, - const void *buf, - size_t nbyte, - rtems_device_major_number major, - rtems_device_minor_number minor -); - -int rtems_deviceio_control( - rtems_libio_t *iop, - ioctl_command_t command, - void *buffer, - rtems_device_major_number major, - rtems_device_minor_number minor -); - -#ifdef __cplusplus -} -#endif -/* __cplusplus */ - -/**@}*/ - -#endif /* _RTEMS_DEVICEIO_H */ diff --git a/cpukit/libcsupport/include/rtems/error.h b/cpukit/libcsupport/include/rtems/error.h deleted file mode 100644 index 617f59642b..0000000000 --- a/cpukit/libcsupport/include/rtems/error.h +++ /dev/null @@ -1,135 +0,0 @@ -/** - * @file rtems/error.h - * - * @brief RTEMS Error Reporting - * - * Defines and externs for rtems error reporting - * - * These routines provide general purpose error reporting. - * rtems_error reports an error to stderr and allows use of - * printf style formatting. A newline is appended to all messages. - * - * error_flag can be specified as any of the following: - * - * RTEMS_ERROR_ERRNO -- include errno text in output - * RTEMS_ERROR_PANIC -- halts local system after output - * RTEMS_ERROR_ABORT -- abort after output - * - * It can also include a rtems_status value which can be OR'd - * with the above flags. * - * - * Example 1: - * @code - * #include - * #include - * rtems_error(0, "stray interrupt %d", intr); - * @endcode - * - * Example 2: - * @code - * if ((status = rtems_task_create(...)) != RTEMS_SUCCCESSFUL) - * { - * rtems_error(status | RTEMS_ERROR_ABORT, - * "could not create task"); - * } - * @endcode - * - * Example 3: - * @code - * if ((fd = open(pathname, O_RDNLY)) < 0) - * { - * rtems_error(RTEMS_ERROR_ERRNO, "open of '%s' failed", pathname); - * goto failed; - * } - * @endcode - */ - -#ifndef _RTEMS_RTEMS_ERROR_H -#define _RTEMS_RTEMS_ERROR_H - -#include -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ErrorPanicSupport Error And Panic Support - * - * @ingroup libcsupport - * - * @brief Defines and externs for rtems error reporting - * - */ -typedef Internal_errors_t rtems_error_code_t; - -/* - * rtems_error(), rtems_verror() and rtems_panic() support - */ - -#if 0 -/* not 16bit-int host clean */ -#define RTEMS_ERROR_ERRNO (1<<((sizeof(rtems_error_code_t) * CHAR_BIT) - 2)) /* hi bit; use 'errno' */ -#define RTEMS_ERROR_PANIC (RTEMS_ERROR_ERRNO / 2) /* err fatal; no return */ -#define RTEMS_ERROR_ABORT (RTEMS_ERROR_ERRNO / 4) /* err is fatal; panic */ -#else -#define RTEMS_ERROR_ERRNO (0x40000000) /* hi bit; use 'errno' */ -#define RTEMS_ERROR_PANIC (0x20000000) /* err fatal; no return */ -#define RTEMS_ERROR_ABORT (0x10000000) /* err is fatal; panic */ -#endif - -#define RTEMS_ERROR_MASK \ - (RTEMS_ERROR_ERRNO | RTEMS_ERROR_ABORT | RTEMS_ERROR_PANIC) /* all */ - -/** - * @brief Report an Error - * - * @param[in] error_code can be specified as any of the following: - * RTEMS_ERROR_ERRNO -- include errno text in output - * RTEMS_ERROR_PANIC -- halts local system after output - * RTEMS_ERROR_ABORT -- abort after output - * - * @param[in] printf_format is a normal printf(3) format string, - * with its concommitant arguments - * - * @return the number of characters written. - */ -int rtems_error( - rtems_error_code_t error_code, - const char *printf_format, - ... -); - -/** - * @brief Report an Error - * - * @param[in] error_code can be specified as any of the following: - * RTEMS_ERROR_ERRNO -- include errno text in output - * RTEMS_ERROR_PANIC -- halts local system after output - * RTEMS_ERROR_ABORT -- abort after output - * - * @param[in] printf_format is a normal printf(3) format string, - * with its concommitant arguments - * @param[in] arglist is a varargs list corresponding to - * printf_format - * - * @return the number of characters written. - */ -int rtems_verror( - rtems_error_code_t error_code, - const char *printf_format, - va_list arglist -); - -extern int rtems_panic_in_progress; - -#ifdef __cplusplus -} -#endif - - -#endif -/* end of include file */ diff --git a/cpukit/libcsupport/include/rtems/gxx_wrappers.h b/cpukit/libcsupport/include/rtems/gxx_wrappers.h deleted file mode 100644 index 94502b937f..0000000000 --- a/cpukit/libcsupport/include/rtems/gxx_wrappers.h +++ /dev/null @@ -1,80 +0,0 @@ -/** - * @file rtems/gxx_wrappers.h - * - * RTEMS threads compatibility routines for libgcc2. - */ - -/* - * by: Rosimildo da Silva (rdasilva@connecttel.com) - * - * Used ideas from: - * W. Eric Norum - * Canadian Light Source - * University of Saskatchewan - * Saskatoon, Saskatchewan, CANADA - * eric@cls.usask.ca - * - * Eric sent some e-mail in the rtems-list as a start point for this - * module implementation. - */ - -#ifndef __GCC_WRAPPERS_h -#define __GCC_WRAPPERS_h - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup GxxWrappersSupport Gxx Wrappers Support - * - * @ingroup libcsupport - * - * @brief RTEMS Threads Compatibility Routines for Libgcc2 - */ - -/* - * These typedefs should match with the ones defined in the file - * gcc/gthr-rtems.h in the gcc distribution. - */ -typedef void *__gthread_key_t; -typedef int __gthread_once_t; -typedef void *__gthread_mutex_t; -typedef void *__gthread_recursive_mutex_t; - -int rtems_gxx_once(__gthread_once_t *once, void (*func) (void)); - -int rtems_gxx_key_create (__gthread_key_t *key, void (*dtor) (void *)); - -int rtems_gxx_key_delete (__gthread_key_t key); - -void *rtems_gxx_getspecific(__gthread_key_t key); - -int rtems_gxx_setspecific(__gthread_key_t key, const void *ptr); - -/* - * MUTEX support - */ -void rtems_gxx_mutex_init (__gthread_mutex_t *mutex); - -int rtems_gxx_mutex_lock (__gthread_mutex_t *mutex); - -int rtems_gxx_mutex_destroy (__gthread_mutex_t *mutex); - -int rtems_gxx_mutex_trylock (__gthread_mutex_t *mutex); - -int rtems_gxx_mutex_unlock (__gthread_mutex_t *mutex); - -void rtems_gxx_recursive_mutex_init(__gthread_recursive_mutex_t *mutex); - -int rtems_gxx_recursive_mutex_lock(__gthread_recursive_mutex_t *mutex); - -int rtems_gxx_recursive_mutex_trylock(__gthread_recursive_mutex_t *mutex); - -int rtems_gxx_recursive_mutex_unlock(__gthread_recursive_mutex_t *mutex); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __GCC_WRAPPERS_h */ diff --git a/cpukit/libcsupport/include/rtems/libcsupport.h b/cpukit/libcsupport/include/rtems/libcsupport.h deleted file mode 100644 index 51607f9ea1..0000000000 --- a/cpukit/libcsupport/include/rtems/libcsupport.h +++ /dev/null @@ -1,193 +0,0 @@ -/** - * @file - * - * @brief Standard C Library Support - * - * This include file contains the information regarding the - * RTEMS specific support for the standard C library. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_LIBCSUPPORT_H -#define _RTEMS_RTEMS_LIBCSUPPORT_H - -#include -#include - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup libcsupport Standard C Library Support - * - * @brief RTEMS Specific Support for the Standard C Library - * - */ -/**@{**/ - -extern void malloc_dump(void); - -/** - * @brief Malloc walk. - */ -extern bool malloc_walk(int source, bool printf_enabled); - -/** - * @brief Set malloc heap pointer. - * - * This routine is primarily used for debugging. - */ -void malloc_set_heap_pointer(Heap_Control *new_heap); - -/** - * @brief Get malloc heap pointer. - * - * This routine is primarily used for debugging. - */ -Heap_Control *malloc_get_heap_pointer( void ); - -/** - * @brief Get free malloc information. - * - * Find amount of free heap remaining - */ -extern size_t malloc_free_space(void); - -/** - * @brief Get malloc status information. - * - * Find amount of free heap remaining. - */ -extern int malloc_info(Heap_Information_block *the_info); - -/* - * Prototypes required to install newlib reentrancy user extension - */ -bool newlib_create_hook( - rtems_tcb *current_task, - rtems_tcb *creating_task -); - -void newlib_terminate_hook( - rtems_tcb *current_task -); - -#define RTEMS_NEWLIB_EXTENSION \ -{ \ - newlib_create_hook, /* rtems_task_create */ \ - 0, /* rtems_task_start */ \ - 0, /* rtems_task_restart */ \ - 0, /* rtems_task_delete */ \ - 0, /* task_switch */ \ - 0, /* task_begin */ \ - 0, /* task_exitted */ \ - 0, /* fatal */ \ - newlib_terminate_hook /* thread terminate */ \ -} - -typedef struct { - uint32_t active_barriers; - uint32_t active_extensions; - uint32_t active_message_queues; - uint32_t active_partitions; - uint32_t active_periods; - uint32_t active_ports; - uint32_t active_regions; - uint32_t active_semaphores; - uint32_t active_tasks; - uint32_t active_timers; -} rtems_resource_rtems_api; - -typedef struct { - uint32_t active_message_queues; - uint32_t active_semaphores; - uint32_t active_threads; - uint32_t active_timers; -} rtems_resource_posix_api; - -typedef struct { - Heap_Information_block workspace_info; - Heap_Information_block heap_info; - uint32_t active_posix_key_value_pairs; - uint32_t active_posix_keys; - rtems_resource_rtems_api rtems_api; - rtems_resource_posix_api posix_api; - int open_files; -} rtems_resource_snapshot; - -/** - * @brief Tasks a snapshot of the resource usage of the system. - * - * @param[out] snapshot The snapshot of used resources. - * - * @see rtems_resource_snapshot_equal() and rtems_resource_snapshot_check(). - * - * @code - * #include - * - * #include - * - * void example(void) - * { - * rtems_resource_snapshot before; - * - * test_setup(); - * rtems_resource_snapshot_take(&before); - * test(); - * assert(rtems_resource_snapshot_check(&before)); - * test_cleanup(); - * } - * @endcode - */ -void rtems_resource_snapshot_take(rtems_resource_snapshot *snapshot); - -/** - * @brief Compares two resource snapshots for equality. - * - * @param[in] a One resource snapshot. - * @param[in] b Another resource snapshot. - * - * @retval true The resource snapshots are equal. - * @retval false Otherwise. - * - * @see rtems_resource_snapshot_take(). - */ -bool rtems_resource_snapshot_equal( - const rtems_resource_snapshot *a, - const rtems_resource_snapshot *b -); - -/** - * @brief Takes a new resource snapshot and checks that it is equal to the - * given resource snapshot. - * - * @param[in] snapshot The resource snapshot used for comparison with the new - * resource snapshot. - * - * @retval true The resource snapshots are equal. - * @retval false Otherwise. - * - * @see rtems_resource_snapshot_take(). - */ -bool rtems_resource_snapshot_check(const rtems_resource_snapshot *snapshot); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/libcsupport/include/rtems/libio.h b/cpukit/libcsupport/include/rtems/libio.h deleted file mode 100644 index 9d30dafddf..0000000000 --- a/cpukit/libcsupport/include/rtems/libio.h +++ /dev/null @@ -1,1967 +0,0 @@ -/** - * @file - * - * @ingroup LibIO - * - * @brief Basic IO API - * - * This file contains the support infrastructure used to manage the - * table of integer style file descriptors used by the low level - * POSIX system calls like open(), read, fstat(), etc. - */ - -/* - * COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * Modifications to support reference counting in the file system are - * Copyright (c) 2012 embedded brains GmbH. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_LIBIO_H -#define _RTEMS_RTEMS_LIBIO_H - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -struct knote; - -/** - * @defgroup LibIOFSOps File System Operations - * - * @ingroup LibIO - * - * @brief File system operations. - */ -/**@{**/ - -/** - * @brief Locks a file system instance. - * - * This lock must allow nesting. - * - * @param[in, out] mt_entry The mount table entry of the file system instance. - * - * @see rtems_filesystem_default_lock(). - */ -typedef void (*rtems_filesystem_mt_entry_lock_t)( - const rtems_filesystem_mount_table_entry_t *mt_entry -); - -/** - * @brief Unlocks a file system instance. - * - * @param[in, out] mt_entry The mount table entry of the file system instance. - * - * @see rtems_filesystem_default_unlock(). - */ -typedef void (*rtems_filesystem_mt_entry_unlock_t)( - const rtems_filesystem_mount_table_entry_t *mt_entry -); - -/** - * @brief Path evaluation context. - */ -typedef struct { - /** - * The contents of the remaining path to be evaluated. - */ - const char *path; - - /** - * The length of the remaining path to be evaluated. - */ - size_t pathlen; - - /** - * The contents of the token to be evaluated with respect to the current - * location. - */ - const char *token; - - /** - * The length of the token to be evaluated with respect to the current - * location. - */ - size_t tokenlen; - - /** - * The path evaluation is controlled by the following flags - * - RTEMS_FS_PERMS_READ, - * - RTEMS_FS_PERMS_WRITE, - * - RTEMS_FS_PERMS_EXEC, - * - RTEMS_FS_FOLLOW_HARD_LINK, - * - RTEMS_FS_FOLLOW_SYM_LINK, - * - RTEMS_FS_MAKE, - * - RTEMS_FS_EXCLUSIVE, - * - RTEMS_FS_ACCEPT_RESIDUAL_DELIMITERS, and - * - RTEMS_FS_REJECT_TERMINAL_DOT. - */ - int flags; - - /** - * Symbolic link evaluation is a recursive operation. This field helps to - * limit the recursion level and thus prevents a stack overflow. The - * recursion level is limited by RTEMS_FILESYSTEM_SYMLOOP_MAX. - */ - int recursionlevel; - - /** - * This is the current file system location of the evaluation process. - * Tokens are evaluated with respect to the current location. The token - * interpretation may change the current location. The purpose of the path - * evaluation is to change the start location into a final current location - * according to the path. - */ - rtems_filesystem_location_info_t currentloc; - - /** - * The location of the root directory of the user environment during the - * evaluation start. - */ - rtems_filesystem_global_location_t *rootloc; - - /** - * The start location of the evaluation process. The start location my - * change during symbolic link evaluation. - */ - rtems_filesystem_global_location_t *startloc; -} rtems_filesystem_eval_path_context_t; - -/** - * @brief Path evaluation. - * - * @param[in, out] ctx The path evaluation context. - * - * @see rtems_filesystem_default_eval_path(). - */ -typedef void (*rtems_filesystem_eval_path_t)( - rtems_filesystem_eval_path_context_t *ctx -); - -/** - * @brief Creates a new link for the existing file. - * - * @param[in] parentloc The location of the parent of the new link. - * @param[in] targetloc The location of the target file. - * @param[in] name Name for the new link. - * @param[in] namelen Length of the name for the new link in characters. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The errno is set to indicate the error. - * - * @see rtems_filesystem_default_link(). - */ -typedef int (*rtems_filesystem_link_t)( - const rtems_filesystem_location_info_t *parentloc, - const rtems_filesystem_location_info_t *targetloc, - const char *name, - size_t namelen -); - -/** - * @brief Changes the mode of a node. - * - * @param[in] loc The location of the node. - * @param[in] mode The new mode of the node - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The errno is set to indicate the error. - * - * @see rtems_filesystem_default_fchmod(). - */ -typedef int (*rtems_filesystem_fchmod_t)( - const rtems_filesystem_location_info_t *loc, - mode_t mode -); - -/** - * @brief Changes owner and group of a node. - * - * @param[in] loc The location of the node. - * @param[in] owner User ID for the node. - * @param[in] group Group ID for the node. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The errno is set to indicate the error. - * - * @see rtems_filesystem_default_chown(). - */ -typedef int (*rtems_filesystem_chown_t)( - const rtems_filesystem_location_info_t *loc, - uid_t owner, - gid_t group -); - -/** - * @brief Clones a location. - * - * The location is initialized with a bitwise copy of an existing location. - * The caller must ensure that this location is protected from a release during - * the clone operation. After a successful clone operation the clone will be - * added to the location chain of the corresponding mount table entry. - * - * @param[in, out] loc Location to clone. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The errno is set to indicate the error. - * - * @see rtems_filesystem_default_clonenode(). - */ -typedef int (*rtems_filesystem_clonenode_t)( - rtems_filesystem_location_info_t *loc -); - -/** - * @brief Frees the location of a node. - * - * @param[in] loc The location of the node. - * - * @see rtems_filesystem_default_freenode(). - */ -typedef void (*rtems_filesystem_freenode_t)( - const rtems_filesystem_location_info_t *loc -); - -/** - * @brief Mounts a file system instance in a mount point (directory). - * - * The mount point belongs to the file system instance of the handler and is - * specified by a field of the mount table entry. The handler must check that - * the mount point is capable of mounting a file system instance. This is the - * last step during the mount process. The file system instance is fully - * initialized at this point. - * - * @param[in] mt_entry The mount table entry. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The errno is set to indicate the error. - * - * @see rtems_filesystem_default_mount(). - */ -typedef int (*rtems_filesystem_mount_t) ( - rtems_filesystem_mount_table_entry_t *mt_entry -); - -/** - * @brief Initializes a file system instance. - * - * This function must initialize the file system root node in the mount table - * entry. - * - * @param[in] mt_entry The mount table entry. - * @param[in] data The data provided by the user. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The errno is set to indicate the error. - */ -typedef int (*rtems_filesystem_fsmount_me_t)( - rtems_filesystem_mount_table_entry_t *mt_entry, - const void *data -); - -/** - * @brief Unmounts a file system instance in a mount point (directory). - * - * In case this function is successful the file system instance will be marked - * as unmounted. The file system instance will be destroyed when the last - * reference to it vanishes. - * - * @param[in] mt_entry The mount table entry. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The errno is set to indicate the error. - * - * @see rtems_filesystem_default_unmount(). - */ -typedef int (*rtems_filesystem_unmount_t) ( - rtems_filesystem_mount_table_entry_t *mt_entry -); - -/** - * @brief Destroys a file system instance. - * - * The mount point node location of the mount table entry is invalid. This - * handler must free the file system root location and all remaining resources - * of the file system instance. - * - * @param[in] mt_entry The mount table entry. - * - * @see rtems_filesystem_default_fsunmount(). - */ -typedef void (*rtems_filesystem_fsunmount_me_t)( - rtems_filesystem_mount_table_entry_t *mt_entry -); - -/** - * @brief Tests if the node of one location is equal to the node of the other - * location. - * - * The caller ensures that both nodes are within the same file system instance. - * - * @param[in] a The one location. - * @param[in] b The other location. - * - * @retval true The nodes of the locations are equal. - * @retval false Otherwise. - * - * @see rtems_filesystem_default_are_nodes_equal(). - */ -typedef bool (*rtems_filesystem_are_nodes_equal_t)( - const rtems_filesystem_location_info_t *a, - const rtems_filesystem_location_info_t *b -); - -/** - * @brief Creates a new node. - * - * This handler should create a new node according to the parameters. - * - * @param[in] parentloc The location of the parent of the new node. - * @param[in] name Name for the new node. - * @param[in] namelen Length of the name for the new node in characters. - * @param[in] mode Mode for the new node. - * @param[in] dev Optional device identifier for the new node. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The errno is set to indicate the error. - * - * @see rtems_filesystem_default_mknod(). - */ -typedef int (*rtems_filesystem_mknod_t)( - const rtems_filesystem_location_info_t *parentloc, - const char *name, - size_t namelen, - mode_t mode, - dev_t dev -); - -/** - * @brief Removes a node. - * - * @param[in] parentloc The location of the parent of the node. - * @param[in] loc The location of the node. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The errno is set to indicate the error. - * - * @see rtems_filesystem_default_rmnod(). - */ -typedef int (*rtems_filesystem_rmnod_t)( - const rtems_filesystem_location_info_t *parentloc, - const rtems_filesystem_location_info_t *loc -); - -/** - * @brief Set node access and modification times. - * - * @param[in] loc The location of the node. - * @param[in] actime Access time for the node. - * @param[in] modtime Modification for the node. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The errno is set to indicate the error. - * - * @see rtems_filesystem_default_utime(). - */ -typedef int (*rtems_filesystem_utime_t)( - const rtems_filesystem_location_info_t *loc, - time_t actime, - time_t modtime -); - -/** - * @brief Makes a symbolic link to a node. - * - * @param[in] parentloc The location of the parent of the new symbolic link. - * @param[in] name Name for the new symbolic link. - * @param[in] namelen Length of the name for the new symbolic link in - * characters. - * @param[in] target Contents for the symbolic link. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The errno is set to indicate the error. - * - * @see rtems_filesystem_default_symlink(). - */ -typedef int (*rtems_filesystem_symlink_t)( - const rtems_filesystem_location_info_t *parentloc, - const char *name, - size_t namelen, - const char *target -); - -/** - * @brief Reads the contents of a symbolic link. - * - * @param[in] loc The location of the symbolic link. - * @param[out] buf The buffer for the contents. - * @param[in] bufsize The size of the buffer in characters. - * - * @retval non-negative Size of the actual contents in characters. - * @retval -1 An error occurred. The errno is set to indicate the error. - * - * @see rtems_filesystem_default_readlink(). - */ -typedef ssize_t (*rtems_filesystem_readlink_t)( - const rtems_filesystem_location_info_t *loc, - char *buf, - size_t bufsize -); - -/** - * @brief Renames a node. - * - * @param[in] oldparentloc The location of the parent of the old node. - * @param[in] oldloc The location of the old node. - * @param[in] newparentloc The location of the parent of the new node. - * @param[in] name Name for the new node. - * @param[in] namelen Length of the name for the new node in characters. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The errno is set to indicate the error. - * - * @see rtems_filesystem_default_rename(). - */ -typedef int (*rtems_filesystem_rename_t)( - const rtems_filesystem_location_info_t *oldparentloc, - const rtems_filesystem_location_info_t *oldloc, - const rtems_filesystem_location_info_t *newparentloc, - const char *name, - size_t namelen -); - -/** - * @brief Gets file system information. - * - * @param[in] loc The location of a node. - * @param[out] buf Buffer for file system information. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The errno is set to indicate the error. - * - * @see rtems_filesystem_default_statvfs(). - */ -typedef int (*rtems_filesystem_statvfs_t)( - const rtems_filesystem_location_info_t *loc, - struct statvfs *buf -); - -/** - * @brief File system operations table. - */ -struct _rtems_filesystem_operations_table { - rtems_filesystem_mt_entry_lock_t lock_h; - rtems_filesystem_mt_entry_unlock_t unlock_h; - rtems_filesystem_eval_path_t eval_path_h; - rtems_filesystem_link_t link_h; - rtems_filesystem_are_nodes_equal_t are_nodes_equal_h; - rtems_filesystem_mknod_t mknod_h; - rtems_filesystem_rmnod_t rmnod_h; - rtems_filesystem_fchmod_t fchmod_h; - rtems_filesystem_chown_t chown_h; - rtems_filesystem_clonenode_t clonenod_h; - rtems_filesystem_freenode_t freenod_h; - rtems_filesystem_mount_t mount_h; - rtems_filesystem_unmount_t unmount_h; - rtems_filesystem_fsunmount_me_t fsunmount_me_h; - rtems_filesystem_utime_t utime_h; - rtems_filesystem_symlink_t symlink_h; - rtems_filesystem_readlink_t readlink_h; - rtems_filesystem_rename_t rename_h; - rtems_filesystem_statvfs_t statvfs_h; -}; - -/** - * @brief File system operations table with default operations. - */ -extern const rtems_filesystem_operations_table - rtems_filesystem_operations_default; - -/** - * @brief Obtains the IO library mutex. - * - * @see rtems_filesystem_mt_entry_lock_t. - */ -void rtems_filesystem_default_lock( - const rtems_filesystem_mount_table_entry_t *mt_entry -); - -/** - * @brief Releases the IO library mutex. - * - * @see rtems_filesystem_mt_entry_unlock_t. - */ -void rtems_filesystem_default_unlock( - const rtems_filesystem_mount_table_entry_t *mt_entry -); - -/** - * @brief Terminates the path evaluation and replaces the current location with - * the null location. - * - * @see rtems_filesystem_eval_path_t. - */ -void rtems_filesystem_default_eval_path( - rtems_filesystem_eval_path_context_t *ctx -); - -/** - * @retval -1 Always. The errno is set to ENOTSUP. - * - * @see rtems_filesystem_link_t. - */ -int rtems_filesystem_default_link( - const rtems_filesystem_location_info_t *parentloc, - const rtems_filesystem_location_info_t *targetloc, - const char *name, - size_t namelen -); - -/** - * @brief Tests if the node access pointer of one location is equal to - * the node access pointer of the other location. - * - * @param[in] a The one location. - * @param[in] b The other location. - * - * @retval true The node access pointers of the locations are equal. - * @retval false Otherwise. - * - * @see rtems_filesystem_are_nodes_equal_t. - */ -bool rtems_filesystem_default_are_nodes_equal( - const rtems_filesystem_location_info_t *a, - const rtems_filesystem_location_info_t *b -); - -/** - * @retval -1 Always. The errno is set to ENOTSUP. - * - * @see rtems_filesystem_mknod_t. - */ -int rtems_filesystem_default_mknod( - const rtems_filesystem_location_info_t *parentloc, - const char *name, - size_t namelen, - mode_t mode, - dev_t dev -); - -/** - * @retval -1 Always. The errno is set to ENOTSUP. - * - * @see rtems_filesystem_rmnod_t. - */ -int rtems_filesystem_default_rmnod( - const rtems_filesystem_location_info_t *parentloc, - const rtems_filesystem_location_info_t *loc -); - -/** - * @retval -1 Always. The errno is set to ENOTSUP. - * - * @see rtems_filesystem_fchmod_t. - */ -int rtems_filesystem_default_fchmod( - const rtems_filesystem_location_info_t *loc, - mode_t mode -); - -/** - * @retval -1 Always. The errno is set to ENOTSUP. - * - * @see rtems_filesystem_chown_t. - */ -int rtems_filesystem_default_chown( - const rtems_filesystem_location_info_t *loc, - uid_t owner, - gid_t group -); - -/** - * @retval 0 Always. - * - * @see rtems_filesystem_clonenode_t. - */ -int rtems_filesystem_default_clonenode( - rtems_filesystem_location_info_t *loc -); - -/** - * @see rtems_filesystem_freenode_t. - */ -void rtems_filesystem_default_freenode( - const rtems_filesystem_location_info_t *loc -); - -/** - * @retval -1 Always. The errno is set to ENOTSUP. - * - * @see rtems_filesystem_mount_t. - */ -int rtems_filesystem_default_mount ( - rtems_filesystem_mount_table_entry_t *mt_entry /* IN */ -); - -/** - * @retval -1 Always. The errno is set to ENOTSUP. - * - * @see rtems_filesystem_unmount_t. - */ -int rtems_filesystem_default_unmount( - rtems_filesystem_mount_table_entry_t *mt_entry /* IN */ -); - -/** - * @retval -1 Always. The errno is set to ENOTSUP. - * - * @see rtems_filesystem_fsunmount_me_t. - */ -void rtems_filesystem_default_fsunmount( - rtems_filesystem_mount_table_entry_t *mt_entry /* IN */ -); - -/** - * @retval -1 Always. The errno is set to ENOTSUP. - * - * @see rtems_filesystem_utime_t. - */ -int rtems_filesystem_default_utime( - const rtems_filesystem_location_info_t *loc, - time_t actime, - time_t modtime -); - -/** - * @retval -1 Always. The errno is set to ENOTSUP. - * - * @see rtems_filesystem_symlink_t. - */ -int rtems_filesystem_default_symlink( - const rtems_filesystem_location_info_t *parentloc, - const char *name, - size_t namelen, - const char *target -); - -/** - * @retval -1 Always. The errno is set to ENOTSUP. - * - * @see rtems_filesystem_readlink_t. - */ -ssize_t rtems_filesystem_default_readlink( - const rtems_filesystem_location_info_t *loc, - char *buf, - size_t bufsize -); - -/** - * @retval -1 Always. The errno is set to ENOTSUP. - * - * @see rtems_filesystem_rename_t. - */ -int rtems_filesystem_default_rename( - const rtems_filesystem_location_info_t *oldparentloc, - const rtems_filesystem_location_info_t *oldloc, - const rtems_filesystem_location_info_t *newparentloc, - const char *name, - size_t namelen -); - -/** - * @retval -1 Always. The errno is set to ENOTSUP. - * - * @see rtems_filesystem_statvfs_t. - */ -int rtems_filesystem_default_statvfs( - const rtems_filesystem_location_info_t *loc, - struct statvfs *buf -); - -/** @} */ - -/** - * @defgroup LibIOFSHandler File System Node Handler - * - * @ingroup LibIO - * - * @brief File system node handler. - */ -/**@{**/ - -/** - * @brief Opens a node. - * - * @param[in, out] iop The IO pointer. - * @param[in] path The path. - * @param[in] oflag The open flags. - * @param[in] mode Optional mode for node creation. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The errno is set to indicate the error. - * - * @see rtems_filesystem_default_open(). - */ -typedef int (*rtems_filesystem_open_t)( - rtems_libio_t *iop, - const char *path, - int oflag, - mode_t mode -); - -/** - * @brief Closes a node. - * - * @param[in, out] iop The IO pointer. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The errno is set to indicate the error. - * - * @see rtems_filesystem_default_close(). - */ -typedef int (*rtems_filesystem_close_t)( - rtems_libio_t *iop -); - -/** - * @brief Reads from a node. - * - * This handler is responsible to update the offset field of the IO descriptor. - * - * @param[in, out] iop The IO pointer. - * @param[out] buffer The buffer for read data. - * @param[in] count The size of the buffer in characters. - * - * @retval non-negative Count of read characters. - * @retval -1 An error occurred. The errno is set to indicate the error. - * - * @see rtems_filesystem_default_read(). - */ -typedef ssize_t (*rtems_filesystem_read_t)( - rtems_libio_t *iop, - void *buffer, - size_t count -); - -/** - * @brief Reads an IO vector from a node. - * - * This handler is responsible to update the offset field of the IO descriptor. - * - * @param[in, out] iop The IO pointer. - * @param[in] iov The IO vector with buffer for read data. The caller must - * ensure that the IO vector values are valid. - * @param[in] iovcnt The count of buffers in the IO vector. - * @param[in] total The total count of bytes in the buffers in the IO vector. - * - * @retval non-negative Count of read characters. - * @retval -1 An error occurred. The errno is set to indicate the error. - * - * @see rtems_filesystem_default_readv(). - */ -typedef ssize_t (*rtems_filesystem_readv_t)( - rtems_libio_t *iop, - const struct iovec *iov, - int iovcnt, - ssize_t total -); - -/** - * @brief Writes to a node. - * - * This handler is responsible to update the offset field of the IO descriptor. - * - * @param[in, out] iop The IO pointer. - * @param[out] buffer The buffer for write data. - * @param[in] count The size of the buffer in characters. - * - * @retval non-negative Count of written characters. - * @retval -1 An error occurred. The errno is set to indicate the error. - * - * @see rtems_filesystem_default_write(). - */ -typedef ssize_t (*rtems_filesystem_write_t)( - rtems_libio_t *iop, - const void *buffer, - size_t count -); - -/** - * @brief Writes an IO vector to a node. - * - * This handler is responsible to update the offset field of the IO descriptor. - * - * @param[in, out] iop The IO pointer. - * @param[in] iov The IO vector with buffer for write data. The caller must - * ensure that the IO vector values are valid. - * @param[in] iovcnt The count of buffers in the IO vector. - * @param[in] total The total count of bytes in the buffers in the IO vector. - * - * @retval non-negative Count of written characters. - * @retval -1 An error occurred. The errno is set to indicate the error. - * - * @see rtems_filesystem_default_writev(). - */ -typedef ssize_t (*rtems_filesystem_writev_t)( - rtems_libio_t *iop, - const struct iovec *iov, - int iovcnt, - ssize_t total -); - -/** - * @brief IO control of a node. - * - * @param[in, out] iop The IO pointer. - * @param[in] request The IO control request. - * @param[in, out] buffer The buffer for IO control request data. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The errno is set to indicate the error. - * - * @see rtems_filesystem_default_ioctl(). - */ -typedef int (*rtems_filesystem_ioctl_t)( - rtems_libio_t *iop, - ioctl_command_t request, - void *buffer -); - -/** - * @brief Moves the read/write file offset. - * - * @param[in, out] iop The IO pointer. - * @param[in] offset The offset. - * @param[in] whence The reference position for the offset. - * - * @retval non-negative The new offset from the beginning of the file. - * @retval -1 An error occurred. The errno is set to indicate the error. - * - * @see rtems_filesystem_default_lseek(), - * rtems_filesystem_default_lseek_file(), and - * rtems_filesystem_default_lseek_directory(). - */ -typedef off_t (*rtems_filesystem_lseek_t)( - rtems_libio_t *iop, - off_t offset, - int whence -); - -/** - * @brief Gets a node status. - * - * @param[in, out] iop The IO pointer. - * @param[out] stat The buffer to status information. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The errno is set to indicate the error. - * - * @see rtems_filesystem_default_fstat(). - */ -typedef int (*rtems_filesystem_fstat_t)( - const rtems_filesystem_location_info_t *loc, - struct stat *buf -); - -/** - * @brief Truncates a file to a specified length. - * - * @param[in, out] iop The IO pointer. - * @param[in] length The new length in characters. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The errno is set to indicate the error. - * - * @see rtems_filesystem_default_ftruncate() and - * rtems_filesystem_default_ftruncate_directory(). - */ -typedef int (*rtems_filesystem_ftruncate_t)( - rtems_libio_t *iop, - off_t length -); - -/** - * @brief Synchronizes changes to a file. - * - * @param[in, out] iop The IO pointer. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The errno is set to indicate the error. - * - * @see rtems_filesystem_default_fsync_or_fdatasync() and - * rtems_filesystem_default_fsync_or_fdatasync_success(). - */ -typedef int (*rtems_filesystem_fsync_t)( - rtems_libio_t *iop -); - -/** - * @brief Synchronizes the data of a file. - * - * @param[in, out] iop The IO pointer. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The errno is set to indicate the error. - * - * @see rtems_filesystem_default_fsync_or_fdatasync() and - * rtems_filesystem_default_fsync_or_fdatasync_success(). - */ -typedef int (*rtems_filesystem_fdatasync_t)( - rtems_libio_t *iop -); - -/** - * @brief File control. - * - * @param[in, out] iop The IO pointer. - * @param[in] cmd Control command. - * - * @retval 0 Successful operation. - * @retval errno An error occurred. This value is assigned to errno. - * - * @see rtems_filesystem_default_fcntl(). - */ -typedef int (*rtems_filesystem_fcntl_t)( - rtems_libio_t *iop, - int cmd -); - -/** - * @brief Poll and select support. - * - * @param[in, out] iop The IO pointer. - * @param[in] events The poll events. - * - * @return The poll return events. - * - * @see rtems_filesystem_default_poll(). - */ -typedef int (*rtems_filesystem_poll_t)( - rtems_libio_t *iop, - int events -); - -/** - * @brief Kernel event filter support. - * - * @param[in, out] iop The IO pointer. - * @param[in] kn The kernel event note. - * - * @retval 0 Successful operation. - * @retval error An error occurred. This is usually EINVAL. - * - * @see rtems_filesystem_default_kqfilter(). - */ -typedef int (*rtems_filesystem_kqfilter_t)( - rtems_libio_t *iop, - struct knote *kn -); - -/** - * @brief MMAP support. - * - * @param[in, out] iop The IO pointer. - * @param[in, out] addr The starting address of the mapped memory. - * @param[in] len The maximum number of bytes to map. - * @param[in] prot The desired memory protection. - * @param[in] off The offset within the file descriptor to map. - * - * @retval 0 Successful operation. - * @retval error An error occurred. This is usually EINVAL. - * - * @see rtems_filesystem_default_mmap(). - */ -typedef int (*rtems_filesystem_mmap_t)( - rtems_libio_t *iop, - void **addr, - size_t len, - int prot, - off_t off -); - -/** - * @brief File system node operations table. - */ -struct _rtems_filesystem_file_handlers_r { - rtems_filesystem_open_t open_h; - rtems_filesystem_close_t close_h; - rtems_filesystem_read_t read_h; - rtems_filesystem_write_t write_h; - rtems_filesystem_ioctl_t ioctl_h; - rtems_filesystem_lseek_t lseek_h; - rtems_filesystem_fstat_t fstat_h; - rtems_filesystem_ftruncate_t ftruncate_h; - rtems_filesystem_fsync_t fsync_h; - rtems_filesystem_fdatasync_t fdatasync_h; - rtems_filesystem_fcntl_t fcntl_h; - rtems_filesystem_poll_t poll_h; - rtems_filesystem_kqfilter_t kqfilter_h; - rtems_filesystem_readv_t readv_h; - rtems_filesystem_writev_t writev_h; - rtems_filesystem_mmap_t mmap_h; -}; - -/** - * @brief File system node handler table with default node handlers. - */ -extern const rtems_filesystem_file_handlers_r - rtems_filesystem_handlers_default; - -/** - * @retval 0 Always. - * - * @see rtems_filesystem_open_t. - */ -int rtems_filesystem_default_open( - rtems_libio_t *iop, - const char *path, - int oflag, - mode_t mode -); - -/** - * @retval 0 Always. - * - * @see rtems_filesystem_close_t. - */ -int rtems_filesystem_default_close( - rtems_libio_t *iop -); - -/** - * @retval -1 Always. The errno is set to ENOTSUP. - * - * @see rtems_filesystem_read_t. - */ -ssize_t rtems_filesystem_default_read( - rtems_libio_t *iop, - void *buffer, - size_t count -); - -/** - * @brief Calls the read handler for each IO vector entry. - * - * @see rtems_filesystem_readv_t. - */ -ssize_t rtems_filesystem_default_readv( - rtems_libio_t *iop, - const struct iovec *iov, - int iovcnt, - ssize_t total -); - -/** - * @retval -1 Always. The errno is set to ENOTSUP. - * - * @see rtems_filesystem_write_t. - */ -ssize_t rtems_filesystem_default_write( - rtems_libio_t *iop, - const void *buffer, - size_t count -); - -/** - * @brief Calls the write handler for each IO vector entry. - * - * @see rtems_filesystem_write_t. - */ -ssize_t rtems_filesystem_default_writev( - rtems_libio_t *iop, - const struct iovec *iov, - int iovcnt, - ssize_t total -); - -/** - * @retval -1 Always. The errno is set to ENOTTY. - * - * @see rtems_filesystem_ioctl_t. - */ -int rtems_filesystem_default_ioctl( - rtems_libio_t *iop, - ioctl_command_t request, - void *buffer -); - -/** - * @retval -1 Always. The errno is set to ESPIPE. - * - * @see rtems_filesystem_lseek_t. - */ -off_t rtems_filesystem_default_lseek( - rtems_libio_t *iop, - off_t offset, - int whence -); - -/** - * @brief An offset 0 with a whence of SEEK_SET will perform a directory rewind - * operation. - * - * This function has no protection against concurrent access. - * - * @retval -1 The offset is not zero or the whence is not SEEK_SET. - * @retval 0 Successful rewind operation. - * - * @see rtems_filesystem_lseek_t. - */ -off_t rtems_filesystem_default_lseek_directory( - rtems_libio_t *iop, - off_t offset, - int whence -); - -/** - * @brief Default lseek() handler for files. - * - * The fstat() handler will be used to obtain the file size in case whence is - * SEEK_END. - * - * This function has no protection against concurrent access. - * - * @retval -1 An error occurred. In case an integer overflow occurred, then the - * errno will be set to EOVERFLOW. In case the new offset is negative, then - * the errno will be set to EINVAL. In case the whence is SEEK_END and the - * fstat() handler to obtain the current file size returned an error status, - * then the errno will be set by the fstat() handler. - * @retval offset The new offset. - * - * @see rtems_filesystem_lseek_t. - */ -off_t rtems_filesystem_default_lseek_file( - rtems_libio_t *iop, - off_t offset, - int whence -); - -/** - * @brief Sets the mode to S_IRWXU | S_IRWXG | S_IRWXO. - * - * @retval 0 Always. - * - * @see rtems_filesystem_fstat_t. - */ -int rtems_filesystem_default_fstat( - const rtems_filesystem_location_info_t *loc, - struct stat *buf -); - -/** - * @retval -1 Always. The errno is set to EINVAL. - * - * @see rtems_filesystem_ftruncate_t. - */ -int rtems_filesystem_default_ftruncate( - rtems_libio_t *iop, - off_t length -); - -/** - * @retval -1 Always. The errno is set to EISDIR. - * - * @see rtems_filesystem_ftruncate_t. - */ -int rtems_filesystem_default_ftruncate_directory( - rtems_libio_t *iop, - off_t length -); - -/** - * @retval -1 Always. The errno is set to EINVAL. - * - * @see rtems_filesystem_fsync_t and rtems_filesystem_fdatasync_t. - */ -int rtems_filesystem_default_fsync_or_fdatasync( - rtems_libio_t *iop -); - -/** - * @retval 0 Always. - * - * @see rtems_filesystem_fsync_t and rtems_filesystem_fdatasync_t. - */ -int rtems_filesystem_default_fsync_or_fdatasync_success( - rtems_libio_t *iop -); - -/** - * @retval 0 Always. - * - * @see rtems_filesystem_fcntl_t. - */ -int rtems_filesystem_default_fcntl( - rtems_libio_t *iop, - int cmd -); - -/** - * @brief Default poll handler. - * - * @retval POLLERR Always. - * - * @see rtems_filesystem_poll_t. - */ -int rtems_filesystem_default_poll( - rtems_libio_t *iop, - int events -); - -/** - * @brief Default kernel event filter handler. - * - * @retval EINVAL Always. - * - * @see rtems_filesystem_kqfilter_t. - */ -int rtems_filesystem_default_kqfilter( - rtems_libio_t *iop, - struct knote *kn -); - -/** - * @brief Default MMAP handler. - * - * @retval ENOTSUP Always. - * - * @see rtems_filesystem_mmap_t. - */ -int rtems_filesystem_default_mmap( - rtems_libio_t *iop, - void **addr, - size_t len, - int prot, - off_t off -); - -/** @} */ - -/** - * @defgroup LibIO IO Library - * - * @brief Provides system call and file system interface definitions. - * - * General purpose communication channel for RTEMS to allow UNIX/POSIX - * system call behavior under RTEMS. Initially this supported only - * IO to devices but has since been enhanced to support networking - * and support for mounted file systems. - */ -/**@{**/ - -typedef off_t rtems_off64_t __attribute__((deprecated)); - -/** - * @brief Gets the mount handler for the file system @a type. - * - * @return The file system mount handler associated with the @a type, or - * @c NULL if no such association exists. - */ -rtems_filesystem_fsmount_me_t -rtems_filesystem_get_mount_handler( - const char *type -); - -/** - * @brief Contain file system specific information which is required to support - * fpathconf(). - */ -typedef struct { - int link_max; /* count */ - int max_canon; /* max formatted input line size */ - int max_input; /* max input line size */ - int name_max; /* max name length */ - int path_max; /* max path */ - int pipe_buf; /* pipe buffer size */ - int posix_async_io; /* async IO supported on fs, 0=no, 1=yes */ - int posix_chown_restrictions; /* can chown: 0=no, 1=yes */ - int posix_no_trunc; /* error on names > max name, 0=no, 1=yes */ - int posix_prio_io; /* priority IO, 0=no, 1=yes */ - int posix_sync_io; /* file can be sync'ed, 0=no, 1=yes */ - int posix_vdisable; /* special char processing, 0=no, 1=yes */ -} rtems_filesystem_limits_and_options_t; - -/** - * @brief Default pathconf settings. - * - * Override in a filesystem. - */ -extern const rtems_filesystem_limits_and_options_t - rtems_filesystem_default_pathconf; - -/** - * @brief An open file data structure. - * - * It will be indexed by 'fd'. - * - * @todo Should really have a separate per/file data structure that this points - * to (eg: offset, driver, pathname should be in that) - */ -struct rtems_libio_tt { - off_t offset; /* current offset into file */ - Atomic_Uint flags; - rtems_filesystem_location_info_t pathinfo; - uint32_t data0; /* private to "driver" */ - void *data1; /* ... */ -}; - -/** - * @brief Paramameter block for read/write. - * - * It must include 'offset' instead of using iop's offset since we can have - * multiple outstanding i/o's on a device. - */ -typedef struct { - rtems_libio_t *iop; - off_t offset; - char *buffer; - uint32_t count; - uint32_t flags; - uint32_t bytes_moved; -} rtems_libio_rw_args_t; - -/** - * @brief Parameter block for open/close. - */ -typedef struct { - rtems_libio_t *iop; - uint32_t flags; - uint32_t mode; -} rtems_libio_open_close_args_t; - -/** - * @brief Parameter block for ioctl. - */ -typedef struct { - rtems_libio_t *iop; - ioctl_command_t command; - void *buffer; - int ioctl_return; -} rtems_libio_ioctl_args_t; - -/** - * @name Flag Values - */ -/**@{**/ - -#define LIBIO_FLAGS_NO_DELAY 0x0001U /* return immediately if no data */ -#define LIBIO_FLAGS_READ 0x0002U /* reading */ -#define LIBIO_FLAGS_WRITE 0x0004U /* writing */ -#define LIBIO_FLAGS_OPEN 0x0100U /* device is open */ -#define LIBIO_FLAGS_APPEND 0x0200U /* all writes append */ -#define LIBIO_FLAGS_CLOSE_ON_EXEC 0x0800U /* close on process exec() */ -#define LIBIO_FLAGS_READ_WRITE (LIBIO_FLAGS_READ | LIBIO_FLAGS_WRITE) -#define LIBIO_FLAGS_REFERENCE_INC 0x1000U - -/** @} */ - -static inline unsigned int rtems_libio_iop_flags( const rtems_libio_t *iop ) -{ - return _Atomic_Load_uint( &iop->flags, ATOMIC_ORDER_RELAXED ); -} - -/** - * @brief Returns true if this is a no delay iop, otherwise returns false. - * - * @param[in] iop The iop. - */ -static inline bool rtems_libio_iop_is_no_delay( const rtems_libio_t *iop ) -{ - return ( rtems_libio_iop_flags( iop ) & LIBIO_FLAGS_NO_DELAY ) != 0; -} - -/** - * @brief Returns true if this is a readable iop, otherwise returns false. - * - * @param[in] iop The iop. - */ -static inline bool rtems_libio_iop_is_readable( const rtems_libio_t *iop ) -{ - return ( rtems_libio_iop_flags( iop ) & LIBIO_FLAGS_READ ) != 0; -} - -/** - * @brief Returns true if this is a writeable iop, otherwise returns false. - * - * @param[in] iop The iop. - */ -static inline bool rtems_libio_iop_is_writeable( const rtems_libio_t *iop ) -{ - return ( rtems_libio_iop_flags( iop ) & LIBIO_FLAGS_WRITE ) != 0; -} - -/** - * @brief Returns true if this is an append iop, otherwise returns false. - * - * @param[in] iop The iop. - */ -static inline bool rtems_libio_iop_is_append( const rtems_libio_t *iop ) -{ - return ( rtems_libio_iop_flags( iop ) & LIBIO_FLAGS_APPEND ) != 0; -} - -/** - * @name External I/O Handlers - */ -/**@{**/ - -typedef int (*rtems_libio_open_t)( - const char *pathname, - uint32_t flag, - uint32_t mode -); - -typedef int (*rtems_libio_close_t)( - int fd -); - -typedef ssize_t (*rtems_libio_read_t)( - int fd, - void *buffer, - size_t count -); - -typedef ssize_t (*rtems_libio_write_t)( - int fd, - const void *buffer, - size_t count -); - -typedef int (*rtems_libio_ioctl_t)( - int fd, - uint32_t command, - void *buffer -); - -typedef off_t (*rtems_libio_lseek_t)( - int fd, - off_t offset, - int whence -); - -/** @} */ - -/** - * @name Permission Macros - */ -/**@{**/ - -/* - * The following macros are used to build up the permissions sets - * used to check permissions. These are similar in style to the - * mode_t bits and should stay compatible with them. - */ -#define RTEMS_FS_PERMS_READ 0x4 -#define RTEMS_FS_PERMS_WRITE 0x2 -#define RTEMS_FS_PERMS_EXEC 0x1 -#define RTEMS_FS_PERMS_RWX \ - (RTEMS_FS_PERMS_READ | RTEMS_FS_PERMS_WRITE | RTEMS_FS_PERMS_EXEC) -#define RTEMS_FS_FOLLOW_HARD_LINK 0x8 -#define RTEMS_FS_FOLLOW_SYM_LINK 0x10 -#define RTEMS_FS_FOLLOW_LINK \ - (RTEMS_FS_FOLLOW_HARD_LINK | RTEMS_FS_FOLLOW_SYM_LINK) -#define RTEMS_FS_MAKE 0x20 -#define RTEMS_FS_EXCLUSIVE 0x40 -#define RTEMS_FS_ACCEPT_RESIDUAL_DELIMITERS 0x80 -#define RTEMS_FS_REJECT_TERMINAL_DOT 0x100 - -/** @} */ - -union __rtems_dev_t { - dev_t device; - struct { - rtems_device_major_number major; - rtems_device_minor_number minor; - } __overlay; -}; - -static inline dev_t rtems_filesystem_make_dev_t( - rtems_device_major_number _major, - rtems_device_minor_number _minor -) -{ - union __rtems_dev_t temp; - - temp.__overlay.major = _major; - temp.__overlay.minor = _minor; - return temp.device; -} - -static inline dev_t rtems_filesystem_make_dev_t_from_pointer( - const void *pointer -) -{ - uint64_t temp = (((uint64_t) 1) << 63) | (((uintptr_t) pointer) >> 1); - - return rtems_filesystem_make_dev_t((uint32_t) (temp >> 32), (uint32_t) temp); -} - -static inline rtems_device_major_number rtems_filesystem_dev_major_t( - dev_t device -) -{ - union __rtems_dev_t temp; - - temp.device = device; - return temp.__overlay.major; -} - - -static inline rtems_device_minor_number rtems_filesystem_dev_minor_t( - dev_t device -) -{ - union __rtems_dev_t temp; - - temp.device = device; - return temp.__overlay.minor; -} - -#define rtems_filesystem_split_dev_t( _dev, _major, _minor ) \ - do { \ - (_major) = rtems_filesystem_dev_major_t ( _dev ); \ - (_minor) = rtems_filesystem_dev_minor_t( _dev ); \ - } while(0) - -/* - * Prototypes for filesystem - */ - -/** - * @brief Base File System Initialization - * - * Initialize the foundation of the file system. This is specified - * by the structure rtems_filesystem_mount_table. The usual - * configuration is a single instantiation of the IMFS or miniIMFS with - * a single "/dev" directory in it. - */ -void rtems_filesystem_initialize( void ); - -void rtems_libio_post_driver(void); - -void rtems_libio_exit(void); - -/** - * @brief Creates a directory and all its parent directories according to - * @a path. - * - * The @a mode value selects the access permissions of the directory. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The @c errno indicates the error. - */ -extern int rtems_mkdir(const char *path, mode_t mode); - -/** @} */ - -/** - * @defgroup FileSystemTypesAndMount File System Types and Mount - * - * @ingroup LibIO - * - * @brief File system types and mount. - */ -/**@{**/ - -/** - * @name File System Types - */ -/**@{**/ - -#define RTEMS_FILESYSTEM_TYPE_IMFS "imfs" -#define RTEMS_FILESYSTEM_TYPE_MINIIMFS "mimfs" -#define RTEMS_FILESYSTEM_TYPE_DEVFS "devfs" -#define RTEMS_FILESYSTEM_TYPE_FTPFS "ftpfs" -#define RTEMS_FILESYSTEM_TYPE_TFTPFS "tftpfs" -#define RTEMS_FILESYSTEM_TYPE_NFS "nfs" -#define RTEMS_FILESYSTEM_TYPE_DOSFS "dosfs" -#define RTEMS_FILESYSTEM_TYPE_RFS "rfs" -#define RTEMS_FILESYSTEM_TYPE_JFFS2 "jffs2" - -/** @} */ - -/** - * @brief Mount table entry. - */ -struct rtems_filesystem_mount_table_entry_tt { - rtems_chain_node mt_node; - void *fs_info; - const rtems_filesystem_operations_table *ops; - const void *immutable_fs_info; - rtems_chain_control location_chain; - rtems_filesystem_global_location_t *mt_point_node; - rtems_filesystem_global_location_t *mt_fs_root; - bool mounted; - bool writeable; - const rtems_filesystem_limits_and_options_t *pathconf_limits_and_options; - - /* - * The target or mount point of the file system. - */ - const char *target; - - /* - * The type of filesystem or the name of the filesystem. - */ - const char *type; - - /* - * When someone adds a mounted filesystem on a real device, - * this will need to be used. - * - * The lower layers can manage how this is managed. Leave as a - * string. - */ - char *dev; - - /** - * The task that initiated the unmount process. After unmount process - * completion this task will be notified via the transient event. - * - * @see ClassicEventTransient. - */ - rtems_id unmount_task; -}; - -/** - * @brief File system options. - */ -typedef enum { - RTEMS_FILESYSTEM_READ_ONLY, - RTEMS_FILESYSTEM_READ_WRITE, - RTEMS_FILESYSTEM_BAD_OPTIONS -} rtems_filesystem_options_t; - -/** - * @brief File system table entry. - */ -typedef struct rtems_filesystem_table_t { - const char *type; - rtems_filesystem_fsmount_me_t mount_h; -} rtems_filesystem_table_t; - -/** - * @brief Static table of file systems. - * - * Externally defined by confdefs.h or the user. - */ -extern const rtems_filesystem_table_t rtems_filesystem_table []; - -extern rtems_chain_control rtems_filesystem_mount_table; - -/** - * @brief Registers a file system @a type. - * - * The @a mount_h handler will be used to mount a file system of this @a type. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The @c errno indicates the error. - */ -int rtems_filesystem_register( - const char *type, - rtems_filesystem_fsmount_me_t mount_h -); - -/** - * @brief Unregisters a file system @a type. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The @c errno indicates the error. - */ -int rtems_filesystem_unregister( - const char *type -); - -/** - * @brief Unmounts the file system instance at the specified mount path. - * - * The function waits for the unmount process completion. In case the calling - * thread uses resources of the unmounted file system the function may never - * return. In case the calling thread has its root or current directory in the - * unmounted file system the function returns with an error status and errno is - * set to EBUSY. - * - * The unmount process completion notification uses the transient event. It is - * a fatal error to terminate the calling thread while waiting for this event. - * - * A concurrent unmount request for the same file system instance has - * unpredictable effects. - * - * @param[in] mount_path The path to the file system instance mount point. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The @c errno indicates the error. - * - * @see ClassicEventTransient. - */ -int unmount( - const char *mount_path -); - -/** - * @brief Mounts a file system instance at the specified target path. - * - * To mount a standard file system instance one of the following defines should - * be used to select the file system type - * - RTEMS_FILESYSTEM_TYPE_DEVFS, - * - RTEMS_FILESYSTEM_TYPE_DOSFS, - * - RTEMS_FILESYSTEM_TYPE_FTPFS, - * - RTEMS_FILESYSTEM_TYPE_IMFS, - * - RTEMS_FILESYSTEM_TYPE_JFFS2, - * - RTEMS_FILESYSTEM_TYPE_MINIIMFS, - * - RTEMS_FILESYSTEM_TYPE_NFS, - * - RTEMS_FILESYSTEM_TYPE_RFS, or - * - RTEMS_FILESYSTEM_TYPE_TFTPFS. - * - * Only configured or registered file system types are available. You can add - * file system types to your application configuration with the following - * configuration options - * - CONFIGURE_FILESYSTEM_DEVFS, - * - CONFIGURE_FILESYSTEM_DOSFS, - * - CONFIGURE_FILESYSTEM_FTPFS, - * - CONFIGURE_FILESYSTEM_IMFS, - * - CONFIGURE_FILESYSTEM_JFFS2, - * - CONFIGURE_FILESYSTEM_MINIIMFS, - * - CONFIGURE_FILESYSTEM_NFS, - * - CONFIGURE_FILESYSTEM_RFS, and - * - CONFIGURE_FILESYSTEM_TFTPFS. - * - * In addition to these configuration options file system types can be - * registered with rtems_filesystem_register(). - * - * @param[in] source The source parameter will be forwarded to the file system - * initialization handler. Usually the source is a path to the corresponding - * device file, or @c NULL in case the file system does not use a device file. - * @param[in] target The target path must lead to an existing directory, or - * must be @c NULL. In case the target is @c NULL, the root file system will - * be mounted. - * @param[in] filesystemtype This string selects the file system type. - * @param[in] options The options specify if the file system instance allows - * read-write or read-only access. - * @param[in] data The data parameter will be forwarded to the file system - * initialization handler. It can be used to pass file system specific mount - * options. The data structure for mount options is file system specific. See - * also in the corresponding file system documentation. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The @c errno indicates the error. - * - * @see rtems_filesystem_register(), mount_and_make_target_path(), @ref DOSFS - * and @ref JFFS2. - */ -int mount( - const char *source, - const char *target, - const char *filesystemtype, - rtems_filesystem_options_t options, - const void *data -); - -/** - * @brief Mounts a file system and makes the @a target path. - * - * The @a target path will be created with rtems_mkdir() and must not be - * @c NULL. - * - * @see mount(). - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The @c errno indicates the error. - */ -int mount_and_make_target_path( - const char *source, - const char *target, - const char *filesystemtype, - rtems_filesystem_options_t options, - const void *data -); - -/** - * @brief Per file system type routine. - * - * @see rtems_filesystem_iterate(). - * - * @retval true Stop the iteration. - * @retval false Continue the iteration. - */ -typedef bool (*rtems_per_filesystem_routine)( - const rtems_filesystem_table_t *fs_entry, - void *arg -); - -/** - * @brief Iterates over all file system types. - * - * For each file system type the @a routine will be called with the entry and - * the @a routine_arg parameter. - * - * Do not register or unregister file system types in @a routine. - * - * The iteration is protected by the IO library mutex. - * - * @retval true Iteration stopped due to @a routine return status. - * @retval false Iteration through all entries. - */ -bool rtems_filesystem_iterate( - rtems_per_filesystem_routine routine, - void *routine_arg -); - -/** - * @brief Mount table entry visitor. - * - * @retval true Stop the iteration. - * @retval false Continue the iteration. - * - * @see rtems_filesystem_mount_iterate(). - */ -typedef bool (*rtems_filesystem_mt_entry_visitor)( - const rtems_filesystem_mount_table_entry_t *mt_entry, - void *arg -); - -/** - * @brief Iterates over all file system mount entries. - * - * The iteration is protected by the IO library mutex. Do not mount or unmount - * file systems in the visitor function. - * - * @param[in] visitor For each file system mount entry the visitor function - * will be called with the entry and the visitor argument as parameters. - * @param[in] visitor_arg The second parameter for the visitor function. - * - * @retval true Iteration stopped due to visitor function return status. - * @retval false Iteration through all entries. - */ -bool rtems_filesystem_mount_iterate( - rtems_filesystem_mt_entry_visitor visitor, - void *visitor_arg -); - -typedef struct { - const char *source; - const char *target; - const char *filesystemtype; - rtems_filesystem_options_t options; - const void *data; -} rtems_filesystem_mount_configuration; - -extern const rtems_filesystem_mount_configuration - rtems_filesystem_root_configuration; - -/** @} */ - -/** - * @defgroup Termios Termios - * - * @ingroup LibIO - * - * @brief Termios - */ -/**@{**/ - -typedef struct rtems_termios_callbacks { - int (*firstOpen)(int major, int minor, void *arg); - int (*lastClose)(int major, int minor, void *arg); - int (*pollRead)(int minor); - ssize_t (*write)(int minor, const char *buf, size_t len); - int (*setAttributes)(int minor, const struct termios *t); - int (*stopRemoteTx)(int minor); - int (*startRemoteTx)(int minor); - int outputUsesInterrupts; -} rtems_termios_callbacks; - -void rtems_termios_initialize (void); - -/* - * CCJ: Change before opening a tty. Newer code from Eric is coming - * so extra work to handle an open tty is not worth it. If the tty - * is open, close then open it again. - */ -rtems_status_code rtems_termios_bufsize ( - size_t cbufsize, /* cooked buffer size */ - size_t raw_input, /* raw input buffer size */ - size_t raw_output /* raw output buffer size */ -); - -rtems_status_code rtems_termios_open ( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *arg, - const rtems_termios_callbacks *callbacks -); - -rtems_status_code rtems_termios_close( - void *arg -); - -rtems_status_code rtems_termios_read( - void *arg -); - -rtems_status_code rtems_termios_write( - void *arg -); - -rtems_status_code rtems_termios_ioctl( - void *arg -); - -int rtems_termios_enqueue_raw_characters( - void *ttyp, - const char *buf, - int len -); - -int rtems_termios_dequeue_characters( - void *ttyp, - int len -); - -/** @} */ - -/** - * @brief The pathconf setting for a file system. - */ -#define rtems_filesystem_pathconf(_mte) ((_mte)->pathconf_limits_and_options) - -/** - * @brief The type of file system. Its name. - */ -#define rtems_filesystem_type(_mte) ((_mte)->type) - -/** - * @brief The mount point of a file system. - */ -#define rtems_filesystem_mount_point(_mte) ((_mte)->target) - -/** - * @brief The device entry of a file system. - */ -#define rtems_filesystem_mount_device(_mte) ((_mte)->dev) - -#ifdef __cplusplus -} -#endif - -#endif /* _RTEMS_LIBIO_H */ diff --git a/cpukit/libcsupport/include/rtems/libio_.h b/cpukit/libcsupport/include/rtems/libio_.h deleted file mode 100644 index 414e8a20fc..0000000000 --- a/cpukit/libcsupport/include/rtems/libio_.h +++ /dev/null @@ -1,1049 +0,0 @@ -/** - * @file - * - * @brief LibIO Internal Interface - * - * This file is the libio internal interface. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * Modifications to support reference counting in the file system are - * Copyright (c) 2012 embedded brains GmbH. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_LIBIO__H -#define _RTEMS_RTEMS_LIBIO__H - -#include -#include -#include -#include - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup LibIOInternal IO Internal Library - * - * @brief Internal IO library API and implementation. - * - */ -/**@{**/ - -#define RTEMS_FILESYSTEM_SYMLOOP_MAX 32 - -/* - * Not defined in newlib so provide here. Users should use dup2 and - * not this non-portable fcntl command. Provided here to allow the - * RTEMS implementation to work. - */ -#define F_DUP2FD 20 - -/* - * File descriptor Table Information - */ - -extern const uint32_t rtems_libio_number_iops; -extern rtems_libio_t rtems_libio_iops[]; -extern void *rtems_libio_iop_free_head; -extern void **rtems_libio_iop_free_tail; - -extern const rtems_filesystem_file_handlers_r rtems_filesystem_null_handlers; - -extern rtems_filesystem_mount_table_entry_t rtems_filesystem_null_mt_entry; - -/** - * @brief The global null location. - * - * Every operation and the open and fstat handlers of this location returns an - * error status. The errno is not touched by these operations and handlers. - * The purpose of this location is to deliver the error return status for a - * previous error condition which must set the errno accordingly. - * - * The usage of this null location instead of the NULL pointer eliminates - * a lot of branches. - * - * The user environment root and current directory are statically initialized - * with the null location. Due to that all file system services are in a - * defined state even if no root file system was mounted. - */ -extern rtems_filesystem_global_location_t rtems_filesystem_global_location_null; - -/** - * @brief Sets the iop flags to the specified flags together with - * LIBIO_FLAGS_OPEN. - * - * Use this once a file descriptor allocated via rtems_libio_allocate() is - * fully initialized. - * - * @param[in] iop The iop. - * @param[in] flags The flags. - */ -static inline void rtems_libio_iop_flags_initialize( - rtems_libio_t *iop, - uint32_t flags -) -{ - _Atomic_Store_uint( - &iop->flags, - LIBIO_FLAGS_OPEN | flags, - ATOMIC_ORDER_RELEASE - ); -} - -/** - * @brief Sets the specified flags in the iop. - * - * @param[in] iop The iop. - * @param[in] set The flags to set. - * - * @return The previous flags. - */ -static inline unsigned int rtems_libio_iop_flags_set( - rtems_libio_t *iop, - unsigned int set -) -{ - return _Atomic_Fetch_or_uint( &iop->flags, set, ATOMIC_ORDER_RELAXED ); -} - -/** - * @brief Clears the specified flags in the iop. - * - * @param[in] iop The iop. - * @param[in] clear The flags to clear. - * - * @return The previous flags. - */ -static inline unsigned int rtems_libio_iop_flags_clear( - rtems_libio_t *iop, - unsigned int clear -) -{ - return _Atomic_Fetch_and_uint( &iop->flags, ~clear, ATOMIC_ORDER_RELAXED ); -} - -/** - * @brief Maps a file descriptor to the iop. - * - * The file descriptor must be a valid index into the iop table. - * - * @param[in] fd The file descriptor. - * - * @return The iop corresponding to the specified file descriptor. - */ -static inline rtems_libio_t *rtems_libio_iop( int fd ) -{ - return &rtems_libio_iops[ fd ]; -} - -/** - * @brief Holds a refernece to the iop. - * - * @param[in] iop The iop. - * - * @return The flags corresponding to the specified iop. - */ -static inline unsigned int rtems_libio_iop_hold( rtems_libio_t *iop ) -{ - return _Atomic_Fetch_add_uint( - &iop->flags, - LIBIO_FLAGS_REFERENCE_INC, - ATOMIC_ORDER_ACQUIRE - ); -} - -/** - * @brief Drops a refernece to the iop. - * - * @param[in] iop The iop. - */ -static inline void rtems_libio_iop_drop( rtems_libio_t *iop ) -{ -#if defined(RTEMS_DEBUG) - unsigned int flags; - bool success; - - flags = _Atomic_Load_uint( &iop->flags, ATOMIC_ORDER_RELAXED ); - - do { - unsigned int desired; - - _Assert( flags >= LIBIO_FLAGS_REFERENCE_INC ); - - desired = flags - LIBIO_FLAGS_REFERENCE_INC; - success = _Atomic_Compare_exchange_uint( - &iop->flags, - &flags, - desired, - ATOMIC_ORDER_RELEASE, - ATOMIC_ORDER_RELAXED - ); - } while ( !success ); -#else - _Atomic_Fetch_sub_uint( - &iop->flags, - LIBIO_FLAGS_REFERENCE_INC, - ATOMIC_ORDER_RELEASE - ); -#endif -} - -/* - * rtems_libio_iop_to_descriptor - * - * Macro to convert an internal file descriptor pointer (iop) into - * the integer file descriptor used by the "section 2" system calls. - */ - -#define rtems_libio_iop_to_descriptor(_iop) \ - ((_iop) - &rtems_libio_iops[0]) - -/* - * rtems_libio_check_is_open - * - * Macro to check if a file descriptor is actually open. - */ - -#define rtems_libio_check_is_open(_iop) \ - do { \ - if (((_iop)->flags & LIBIO_FLAGS_OPEN) == 0) { \ - errno = EBADF; \ - return -1; \ - } \ - } while (0) - -/** - * @brief Macro to get the iop for the specified file descriptor. - * - * Checks that the file descriptor is in the valid range and open. - */ -#define LIBIO_GET_IOP( _fd, _iop ) \ - do { \ - unsigned int _flags; \ - if ( (uint32_t) ( _fd ) >= rtems_libio_number_iops ) { \ - rtems_set_errno_and_return_minus_one( EBADF ); \ - } \ - _iop = rtems_libio_iop( _fd ); \ - _flags = rtems_libio_iop_hold( _iop ); \ - if ( ( _flags & LIBIO_FLAGS_OPEN ) == 0 ) { \ - rtems_libio_iop_drop( _iop ); \ - rtems_set_errno_and_return_minus_one( EBADF ); \ - } \ - } while ( 0 ) - -/** - * @brief Macro to get the iop for the specified file descriptor with access - * flags and error. - * - * Checks that the file descriptor is in the valid range and open. - */ -#define LIBIO_GET_IOP_WITH_ACCESS( _fd, _iop, _access_flags, _access_error ) \ - do { \ - unsigned int _flags; \ - unsigned int _mandatory; \ - if ( (uint32_t) ( _fd ) >= rtems_libio_number_iops ) { \ - rtems_set_errno_and_return_minus_one( EBADF ); \ - } \ - _iop = rtems_libio_iop( _fd ); \ - _flags = rtems_libio_iop_hold( _iop ); \ - _mandatory = LIBIO_FLAGS_OPEN | ( _access_flags ); \ - if ( ( _flags & _mandatory ) != _mandatory ) { \ - int _error; \ - rtems_libio_iop_drop( _iop ); \ - if ( ( _flags & LIBIO_FLAGS_OPEN ) == 0 ) { \ - _error = EBADF; \ - } else { \ - _error = _access_error; \ - } \ - rtems_set_errno_and_return_minus_one( _error ); \ - } \ - } while ( 0 ) - -/* - * rtems_libio_check_buffer - * - * Macro to check if a buffer pointer is valid. - */ - -#define rtems_libio_check_buffer(_buffer) \ - do { \ - if ((_buffer) == 0) { \ - errno = EINVAL; \ - return -1; \ - } \ - } while (0) - -/* - * rtems_libio_check_count - * - * Macro to check if a count or length is valid. - */ - -#define rtems_libio_check_count(_count) \ - do { \ - if ((_count) == 0) { \ - return 0; \ - } \ - } while (0) - -/** - * @brief Clones a node. - * - * The caller must hold the file system instance lock. - * - * @param[out] clone The cloned location. - * @param[in] master The master location. - * - * @see rtems_filesystem_instance_lock(). - */ -void rtems_filesystem_location_clone( - rtems_filesystem_location_info_t *clone, - const rtems_filesystem_location_info_t *master -); - -/** - * @brief Releases all resources of a location. - * - * This function may block on a mutex and may complete an unmount process. - * - * @param[in] loc The location to free. - * - * @note The file system root location is released by the file system - * instance destruction handler (see @ref rtems_filesystem_fsunmount_me_t). - * - * @see rtems_filesystem_freenode_t. - */ -void rtems_filesystem_location_free( rtems_filesystem_location_info_t *loc ); - -/* - * External structures - */ -#include - -void rtems_libio_free_user_env( void *env ); - -extern pthread_key_t rtems_current_user_env_key; - -void rtems_libio_lock( void ); - -void rtems_libio_unlock( void ); - -static inline void rtems_filesystem_mt_lock( void ) -{ - rtems_libio_lock(); -} - -static inline void rtems_filesystem_mt_unlock( void ) -{ - rtems_libio_unlock(); -} - -extern rtems_interrupt_lock rtems_filesystem_mt_entry_lock_control; - -#define rtems_filesystem_mt_entry_declare_lock_context( ctx ) \ - rtems_interrupt_lock_context ctx - -#define rtems_filesystem_mt_entry_lock( ctx ) \ - rtems_interrupt_lock_acquire( &rtems_filesystem_mt_entry_lock_control, &ctx ) - -#define rtems_filesystem_mt_entry_unlock( ctx ) \ - rtems_interrupt_lock_release( &rtems_filesystem_mt_entry_lock_control, &ctx ) - -static inline void rtems_filesystem_instance_lock( - const rtems_filesystem_location_info_t *loc -) -{ - const rtems_filesystem_mount_table_entry_t *mt_entry = loc->mt_entry; - - (*mt_entry->ops->lock_h)( mt_entry ); -} - -static inline void rtems_filesystem_instance_unlock( - const rtems_filesystem_location_info_t *loc -) -{ - const rtems_filesystem_mount_table_entry_t *mt_entry = loc->mt_entry; - - (*mt_entry->ops->unlock_h)( mt_entry ); -} - -/* - * File Descriptor Routine Prototypes - */ - -/** - * This routine searches the IOP Table for an unused entry. If it - * finds one, it returns it. Otherwise, it returns NULL. - */ -rtems_libio_t *rtems_libio_allocate(void); - -/** - * Convert UNIX fnctl(2) flags to ones that RTEMS drivers understand - */ -unsigned int rtems_libio_fcntl_flags( int fcntl_flags ); - -/** - * Convert RTEMS internal flags to UNIX fnctl(2) flags - */ -int rtems_libio_to_fcntl_flags( unsigned int flags ); - -/** - * This routine frees the resources associated with an IOP (file descriptor) - * and clears the slot in the IOP Table. - */ -void rtems_libio_free( - rtems_libio_t *iop -); - -/* - * File System Routine Prototypes - */ - -rtems_filesystem_location_info_t * -rtems_filesystem_eval_path_start( - rtems_filesystem_eval_path_context_t *ctx, - const char *path, - int eval_flags -); - -rtems_filesystem_location_info_t * -rtems_filesystem_eval_path_start_with_parent( - rtems_filesystem_eval_path_context_t *ctx, - const char *path, - int eval_flags, - rtems_filesystem_location_info_t *parentloc, - int parent_eval_flags -); - -rtems_filesystem_location_info_t * -rtems_filesystem_eval_path_start_with_root_and_current( - rtems_filesystem_eval_path_context_t *ctx, - const char *path, - size_t pathlen, - int eval_flags, - rtems_filesystem_global_location_t *const *global_root_ptr, - rtems_filesystem_global_location_t *const *global_current_ptr -); - -void rtems_filesystem_eval_path_continue( - rtems_filesystem_eval_path_context_t *ctx -); - -void rtems_filesystem_eval_path_cleanup( - rtems_filesystem_eval_path_context_t *ctx -); - -void rtems_filesystem_eval_path_recursive( - rtems_filesystem_eval_path_context_t *ctx, - const char *path, - size_t pathlen -); - -void rtems_filesystem_eval_path_cleanup_with_parent( - rtems_filesystem_eval_path_context_t *ctx, - rtems_filesystem_location_info_t *parentloc -); - -/** - * @brief Requests a path evaluation restart. - * - * Sets the start and current location to the new start location. The caller - * must terminate its current evaluation process. The path evaluation - * continues in the next loop iteration within - * rtems_filesystem_eval_path_continue(). This avoids recursive invocations. - * The function obtains the new start location and clones it to set the new - * current location. The previous start and current locations are released. - * - * @param[in, out] ctx The path evaluation context. - * @param[in, out] newstartloc_ptr Pointer to the new start location. - */ -void rtems_filesystem_eval_path_restart( - rtems_filesystem_eval_path_context_t *ctx, - rtems_filesystem_global_location_t **newstartloc_ptr -); - -typedef enum { - RTEMS_FILESYSTEM_EVAL_PATH_GENERIC_CONTINUE, - RTEMS_FILESYSTEM_EVAL_PATH_GENERIC_DONE, - RTEMS_FILESYSTEM_EVAL_PATH_GENERIC_NO_ENTRY -} rtems_filesystem_eval_path_generic_status; - -/** - * @brief Tests if the current location is a directory. - * - * @param[in, out] ctx The path evaluation context. - * @param[in, out] arg The handler argument. - * - * @retval true The current location is a directory. - * @retval false Otherwise. - * - * @see rtems_filesystem_eval_path_generic(). - */ -typedef bool (*rtems_filesystem_eval_path_is_directory)( - rtems_filesystem_eval_path_context_t *ctx, - void *arg -); - -/** - * @brief Evaluates a token. - * - * @param[in, out] ctx The path evaluation context. - * @param[in, out] arg The handler argument. - * @param[in] token The token contents. - * @param[in] tokenlen The token length in characters. - * - * @retval status The generic path evaluation status. - * - * @see rtems_filesystem_eval_path_generic(). - */ -typedef rtems_filesystem_eval_path_generic_status -(*rtems_filesystem_eval_path_eval_token)( - rtems_filesystem_eval_path_context_t *ctx, - void *arg, - const char *token, - size_t tokenlen -); - -typedef struct { - rtems_filesystem_eval_path_is_directory is_directory; - rtems_filesystem_eval_path_eval_token eval_token; -} rtems_filesystem_eval_path_generic_config; - -void rtems_filesystem_eval_path_generic( - rtems_filesystem_eval_path_context_t *ctx, - void *arg, - const rtems_filesystem_eval_path_generic_config *config -); - -void rtems_filesystem_initialize(void); - -/** - * @brief Copies a location. - * - * A bitwise copy is performed. The destination location will be added to the - * corresponding mount entry. - * - * @param[out] dst The destination location. - * @param[in] src The source location. - * - * @retval dst The destination location. - * - * @see rtems_filesystem_location_clone(). - */ -rtems_filesystem_location_info_t *rtems_filesystem_location_copy( - rtems_filesystem_location_info_t *dst, - const rtems_filesystem_location_info_t *src -); - -static inline rtems_filesystem_location_info_t * -rtems_filesystem_location_initialize_to_null( - rtems_filesystem_location_info_t *loc -) -{ - return rtems_filesystem_location_copy( - loc, - &rtems_filesystem_global_location_null.location - ); -} - -rtems_filesystem_global_location_t * -rtems_filesystem_location_transform_to_global( - rtems_filesystem_location_info_t *loc -); - -/** - * @brief Assigns a global file system location. - * - * @param[in, out] lhs_global_loc_ptr Pointer to the global left hand side file - * system location. The current left hand side location will be released. - * @param[in] rhs_global_loc The global right hand side file system location. - */ -void rtems_filesystem_global_location_assign( - rtems_filesystem_global_location_t **lhs_global_loc_ptr, - rtems_filesystem_global_location_t *rhs_global_loc -); - -/** - * @brief Obtains a global file system location. - * - * Deferred releases will be processed in this function. - * - * This function must be called from normal thread context and may block on a - * mutex. Thread dispatching is disabled to protect some critical sections. - * - * @param[in] global_loc_ptr Pointer to the global file system location. - * - * @return A global file system location. It returns always a valid object. - * In case of an error, the global null location will be returned. Each - * operation or handler of the null location returns an error status. The - * errno indicates the error. The NULL pointer is never returned. - * - * @see rtems_filesystem_location_transform_to_global(), - * rtems_filesystem_global_location_obtain_null(), and - * rtems_filesystem_global_location_release(). - */ -rtems_filesystem_global_location_t *rtems_filesystem_global_location_obtain( - rtems_filesystem_global_location_t *const *global_loc_ptr -); - -/** - * @brief Releases a global file system location. - * - * In case the reference count reaches zero, all associated resources will be - * released. This may include the complete unmount of the corresponding file - * system instance. - * - * This function may block on a mutex. It may be called within critical - * sections of the operating system. In this case the release will be - * deferred. The next obtain call will do the actual release. - * - * @param[in] global_loc The global file system location. It must not be NULL. - * @param[in] deferred If true, then do a deferred release, otherwise release - * it immediately. - * - * @see rtems_filesystem_global_location_obtain(). - */ -void rtems_filesystem_global_location_release( - rtems_filesystem_global_location_t *global_loc, - bool deferred -); - -void rtems_filesystem_location_detach( - rtems_filesystem_location_info_t *detach -); - -void rtems_filesystem_location_copy_and_detach( - rtems_filesystem_location_info_t *copy, - rtems_filesystem_location_info_t *detach -); - -static inline rtems_filesystem_global_location_t * -rtems_filesystem_global_location_obtain_null(void) -{ - rtems_filesystem_global_location_t *global_loc = NULL; - - return rtems_filesystem_global_location_obtain( &global_loc ); -} - -static inline bool rtems_filesystem_location_is_null( - const rtems_filesystem_location_info_t *loc -) -{ - return loc->handlers == &rtems_filesystem_null_handlers; -} - -static inline bool rtems_filesystem_global_location_is_null( - const rtems_filesystem_global_location_t *global_loc -) -{ - return rtems_filesystem_location_is_null( &global_loc->location ); -} - -static inline void rtems_filesystem_location_error( - const rtems_filesystem_location_info_t *loc, - int eno -) -{ - if ( !rtems_filesystem_location_is_null( loc ) ) { - errno = eno; - } -} - -int rtems_filesystem_mknod( - const rtems_filesystem_location_info_t *parentloc, - const char *name, - size_t namelen, - mode_t mode, - dev_t dev -); - -int rtems_filesystem_chdir( rtems_filesystem_location_info_t *loc ); - -int rtems_filesystem_chmod( - const rtems_filesystem_location_info_t *loc, - mode_t mode -); - -int rtems_filesystem_chown( - const rtems_filesystem_location_info_t *loc, - uid_t owner, - gid_t group -); - -static inline bool rtems_filesystem_is_ready_for_unmount( - rtems_filesystem_mount_table_entry_t *mt_entry -) -{ - bool ready = !mt_entry->mounted - && rtems_chain_has_only_one_node( &mt_entry->location_chain ) - && mt_entry->mt_fs_root->reference_count == 1; - - if ( ready ) { - rtems_chain_initialize_empty( &mt_entry->location_chain ); - } - - return ready; -} - -static inline void rtems_filesystem_location_add_to_mt_entry( - rtems_filesystem_location_info_t *loc -) -{ - rtems_filesystem_mt_entry_declare_lock_context( lock_context ); - - rtems_filesystem_mt_entry_lock( lock_context ); - rtems_chain_append_unprotected( - &loc->mt_entry->location_chain, - &loc->mt_entry_node - ); - rtems_filesystem_mt_entry_unlock( lock_context ); -} - -void rtems_filesystem_location_remove_from_mt_entry( - rtems_filesystem_location_info_t *loc -); - -void rtems_filesystem_do_unmount( - rtems_filesystem_mount_table_entry_t *mt_entry -); - -static inline bool rtems_filesystem_location_is_instance_root( - const rtems_filesystem_location_info_t *loc -) -{ - const rtems_filesystem_mount_table_entry_t *mt_entry = loc->mt_entry; - - return (*mt_entry->ops->are_nodes_equal_h)( - loc, - &mt_entry->mt_fs_root->location - ); -} - -static inline const char *rtems_filesystem_eval_path_get_path( - rtems_filesystem_eval_path_context_t *ctx -) -{ - return ctx->path; -} - -static inline size_t rtems_filesystem_eval_path_get_pathlen( - rtems_filesystem_eval_path_context_t *ctx -) -{ - return ctx->pathlen; -} - -static inline void rtems_filesystem_eval_path_set_path( - rtems_filesystem_eval_path_context_t *ctx, - const char *path, - size_t pathlen -) -{ - ctx->path = path; - ctx->pathlen = pathlen; -} - -static inline void rtems_filesystem_eval_path_clear_path( - rtems_filesystem_eval_path_context_t *ctx -) -{ - ctx->pathlen = 0; -} - -static inline const char *rtems_filesystem_eval_path_get_token( - rtems_filesystem_eval_path_context_t *ctx -) -{ - return ctx->token; -} - -static inline size_t rtems_filesystem_eval_path_get_tokenlen( - rtems_filesystem_eval_path_context_t *ctx -) -{ - return ctx->tokenlen; -} - -static inline void rtems_filesystem_eval_path_set_token( - rtems_filesystem_eval_path_context_t *ctx, - const char *token, - size_t tokenlen -) -{ - ctx->token = token; - ctx->tokenlen = tokenlen; -} - -static inline void rtems_filesystem_eval_path_clear_token( - rtems_filesystem_eval_path_context_t *ctx -) -{ - ctx->tokenlen = 0; -} - -static inline void rtems_filesystem_eval_path_put_back_token( - rtems_filesystem_eval_path_context_t *ctx -) -{ - size_t tokenlen = ctx->tokenlen; - - ctx->path -= tokenlen; - ctx->pathlen += tokenlen; - ctx->tokenlen = 0; -} - -void rtems_filesystem_eval_path_eat_delimiter( - rtems_filesystem_eval_path_context_t *ctx -); - -void rtems_filesystem_eval_path_next_token( - rtems_filesystem_eval_path_context_t *ctx -); - -static inline void rtems_filesystem_eval_path_get_next_token( - rtems_filesystem_eval_path_context_t *ctx, - const char **token, - size_t *tokenlen -) -{ - rtems_filesystem_eval_path_next_token(ctx); - *token = ctx->token; - *tokenlen = ctx->tokenlen; -} - -static inline rtems_filesystem_location_info_t * -rtems_filesystem_eval_path_get_currentloc( - rtems_filesystem_eval_path_context_t *ctx -) -{ - return &ctx->currentloc; -} - -static inline bool rtems_filesystem_eval_path_has_path( - const rtems_filesystem_eval_path_context_t *ctx -) -{ - return ctx->pathlen > 0; -} - -static inline bool rtems_filesystem_eval_path_has_token( - const rtems_filesystem_eval_path_context_t *ctx -) -{ - return ctx->tokenlen > 0; -} - -static inline int rtems_filesystem_eval_path_get_flags( - const rtems_filesystem_eval_path_context_t *ctx -) -{ - return ctx->flags; -} - -static inline void rtems_filesystem_eval_path_set_flags( - rtems_filesystem_eval_path_context_t *ctx, - int flags -) -{ - ctx->flags = flags; -} - -static inline void rtems_filesystem_eval_path_clear_and_set_flags( - rtems_filesystem_eval_path_context_t *ctx, - int clear, - int set -) -{ - int flags = ctx->flags; - - flags &= ~clear; - flags |= set; - - ctx->flags = flags; -} - -static inline void rtems_filesystem_eval_path_extract_currentloc( - rtems_filesystem_eval_path_context_t *ctx, - rtems_filesystem_location_info_t *get -) -{ - rtems_filesystem_location_copy_and_detach( - get, - &ctx->currentloc - ); -} - -void rtems_filesystem_eval_path_error( - rtems_filesystem_eval_path_context_t *ctx, - int eno -); - -/** - * @brief Checks that the locations exist in the same file system instance. - * - * @retval 0 The locations exist and are in the same file system instance. - * @retval -1 An error occurred. The @c errno indicates the error. - */ -int rtems_filesystem_location_exists_in_same_instance_as( - const rtems_filesystem_location_info_t *a, - const rtems_filesystem_location_info_t *b -); - -/** - * @brief Checks if access to an object is allowed for the current user. - * - * If the effective UID is zero or equals the UID of the object, then the user - * permission flags of the object will be used. Otherwise if the effective GID - * is zero or equals the GID of the object or one of the supplementary group - * IDs is equal to the GID of the object, then the group permission flags of - * the object will be used. Otherwise the other permission flags of the object - * will be used. - * - * @param[in] flags The flags determining the access type. It can be - * RTEMS_FS_PERMS_READ, RTEMS_FS_PERMS_WRITE or RTEMS_FS_PERMS_EXEC. - * @param[in] object_mode The mode of the object specifying the permission flags. - * @param[in] object_uid The UID of the object. - * @param[in] object_gid The GID of the object. - * - * @retval true Access is allowed. - * @retval false Otherwise. - */ -bool rtems_filesystem_check_access( - int flags, - mode_t object_mode, - uid_t object_uid, - gid_t object_gid -); - -bool rtems_filesystem_eval_path_check_access( - rtems_filesystem_eval_path_context_t *ctx, - int eval_flags, - mode_t node_mode, - uid_t node_uid, - gid_t node_gid -); - -static inline bool rtems_filesystem_is_delimiter(char c) -{ - return c == '/' || c == '\\'; -} - -static inline bool rtems_filesystem_is_current_directory( - const char *token, - size_t tokenlen -) -{ - return tokenlen == 1 && token [0] == '.'; -} - -static inline bool rtems_filesystem_is_parent_directory( - const char *token, - size_t tokenlen -) -{ - return tokenlen == 2 && token [0] == '.' && token [1] == '.'; -} - -typedef ssize_t ( *rtems_libio_iovec_adapter )( - rtems_libio_t *iop, - const struct iovec *iov, - int iovcnt, - ssize_t total -); - -static inline ssize_t rtems_libio_iovec_eval( - int fd, - const struct iovec *iov, - int iovcnt, - unsigned int flags, - rtems_libio_iovec_adapter adapter -) -{ - ssize_t total; - int v; - rtems_libio_t *iop; - - /* - * Argument validation on IO vector - */ - if ( iov == NULL ) - rtems_set_errno_and_return_minus_one( EINVAL ); - - if ( iovcnt <= 0 ) - rtems_set_errno_and_return_minus_one( EINVAL ); - - if ( iovcnt > IOV_MAX ) - rtems_set_errno_and_return_minus_one( EINVAL ); - - /* - * OpenGroup says that you are supposed to return EINVAL if the - * sum of the iov_len values in the iov array would overflow a - * ssize_t. - */ - total = 0; - for ( v = 0 ; v < iovcnt ; ++v ) { - size_t len = iov[ v ].iov_len; - - if ( len > ( size_t ) ( SSIZE_MAX - total ) ) { - rtems_set_errno_and_return_minus_one( EINVAL ); - } - - total += ( ssize_t ) len; - - if ( iov[ v ].iov_base == NULL && len != 0 ) { - rtems_set_errno_and_return_minus_one( EINVAL ); - } - } - - LIBIO_GET_IOP_WITH_ACCESS( fd, iop, flags, EBADF ); - - if ( total > 0 ) { - total = ( *adapter )( iop, iov, iovcnt, total ); - } - - rtems_libio_iop_drop( iop ); - return total; -} - -/** - * @brief Returns the file type of the file referenced by the filesystem - * location. - * - * @brief[in] loc The filesystem location. - * - * @return The type of the file or an invalid file type in case of an error. - */ -static inline mode_t rtems_filesystem_location_type( - const rtems_filesystem_location_info_t *loc -) -{ - struct stat st; - - st.st_mode = 0; - (void) ( *loc->handlers->fstat_h )( loc, &st ); - - return st.st_mode; -} - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/libcsupport/include/rtems/malloc.h b/cpukit/libcsupport/include/rtems/malloc.h deleted file mode 100644 index 7c00f21e77..0000000000 --- a/cpukit/libcsupport/include/rtems/malloc.h +++ /dev/null @@ -1,201 +0,0 @@ -/** - * @file rtems/malloc.h - * - * This file defines the interface to RTEMS extensions to the Malloc Family. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may in - * the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_MALLOC_H -#define _RTEMS_MALLOC_H - -#include -#include -#include /* for malloc_walk() */ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup MallocSupport Malloc Support - * - * @ingroup libcsupport - * - * @brief RTEMS extensions to the Malloc Family - */ - -/** - * @brief C program heap control. - * - * This is the pointer to the heap control structure used to manage the C - * program heap. - */ -extern Heap_Control *RTEMS_Malloc_Heap; - -void RTEMS_Malloc_Initialize( - const Heap_Area *areas, - size_t area_count, - Heap_Initialization_or_extend_handler extend -); - -extern ptrdiff_t RTEMS_Malloc_Sbrk_amount; - -static inline void rtems_heap_set_sbrk_amount( ptrdiff_t sbrk_amount ) -{ - RTEMS_Malloc_Sbrk_amount = sbrk_amount; -} - -typedef void *(*rtems_heap_extend_handler)( - Heap_Control *heap, - size_t alloc_size -); - -/** - * @brief RTEMS Extend Heap via Sbrk - */ -void *rtems_heap_extend_via_sbrk( - Heap_Control *heap, - size_t alloc_size -); - -void *rtems_heap_null_extend( - Heap_Control *heap, - size_t alloc_size -); - -extern const rtems_heap_extend_handler rtems_malloc_extend_handler; - -/* - * Malloc Plugin to Dirty Memory at Allocation Time - */ -typedef void (*rtems_malloc_dirtier_t)(void *, size_t); -extern rtems_malloc_dirtier_t rtems_malloc_dirty_helper; - -/** - * @brief Dirty Memory Function - * - * This method fills the specified area with a non-zero pattern - * to aid in debugging programs which do not initialize their - * memory allocated from the heap. - */ -void rtems_malloc_dirty_memory( - void *start, - size_t size -); - -/** - * @brief RTEMS Variation on Aligned Memory Allocation - * - * This method is a help memalign implementation which does all - * error checking done by posix_memalign() EXCEPT it does NOT - * place numeric restrictions on the alignment value. - * - * @param[in] pointer points to the user pointer - * @param[in] alignment is the desired alignment - * @param[in] size is the allocation request size in bytes - * - * @return This methods returns zero on success and a POSIX errno - * value to indicate the failure condition. On success - * *pointer will contain the address of the allocated memory. - */ -int rtems_memalign( - void **pointer, - size_t alignment, - size_t size -); - -/** - * @brief Allocates a memory area of size @a size bytes from the heap. - * - * If the alignment parameter @a alignment is not equal to zero, the allocated - * memory area will begin at an address aligned by this value. - * - * If the boundary parameter @a boundary is not equal to zero, the allocated - * memory area will comply with a boundary constraint. The boundary value - * specifies the set of addresses which are aligned by the boundary value. The - * interior of the allocated memory area will not contain an element of this - * set. The begin or end address of the area may be a member of the set. - * - * A size value of zero will return a unique address which may be freed with - * free(). - * - * The memory allocated by this function can be released with a call to free(). - * - * @return A pointer to the begin of the allocated memory area, or @c NULL if - * no memory is available or the parameters are inconsistent. - */ -void *rtems_heap_allocate_aligned_with_boundary( - size_t size, - uintptr_t alignment, - uintptr_t boundary -); - -/** - * @brief Extends the memory available for the heap using the memory area - * starting at @a area_begin of size @a area_size bytes. - * - * There are no alignment requirements. The memory area must be big enough to - * contain some maintenance blocks. It must not overlap parts of the current - * heap areas. Disconnected subordinate heap areas will lead to used blocks - * which cover the gaps. Extending with an inappropriate memory area will - * corrupt the heap. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_INVALID_ADDRESS Invalid memory area. - */ -rtems_status_code rtems_heap_extend( - void *area_begin, - uintptr_t area_size -); - -/** - * @brief Greedy allocate that empties the heap. - * - * Afterwards the heap has at most @a block_count allocatable blocks of sizes - * specified by @a block_sizes. The @a block_sizes must point to an array with - * @a block_count members. All other blocks are used. - * - * @see rtems_heap_greedy_free(). - */ -void *rtems_heap_greedy_allocate( - const uintptr_t *block_sizes, - size_t block_count -); - -/** - * @brief Greedy allocate all blocks except the largest free block. - * - * Afterwards the heap has at most one allocatable block. This block is the - * largest free block if it exists. The allocatable size of this block is - * stored in @a allocatable_size. All other blocks are used. - * - * @see rtems_heap_greedy_free(). - */ -void *rtems_heap_greedy_allocate_all_except_largest( - uintptr_t *allocatable_size -); - -/** - * @brief Frees space of a greedy allocation. - * - * The @a opaque argument must be the return value of - * rtems_heap_greedy_allocate() or - * rtems_heap_greedy_allocate_all_except_largest(). - */ -void rtems_heap_greedy_free( void *opaque ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/libcsupport/include/rtems/termiostypes.h b/cpukit/libcsupport/include/rtems/termiostypes.h deleted file mode 100644 index b3cac66e92..0000000000 --- a/cpukit/libcsupport/include/rtems/termiostypes.h +++ /dev/null @@ -1,602 +0,0 @@ -/** - * @file rtems/termiostypes.h - * - * RTEMS termios device support internal data structures - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef __TERMIOSTYPES_H -#define __TERMIOSTYPES_H - -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup TermiostypesSupport RTEMS Termios Device Support - * - * @ingroup libcsupport - * - * @brief RTEMS Termios Device Support Internal Data Structures - */ - -/* - * Wakeup callback data structure - */ -struct ttywakeup { - void (*sw_pfn)(struct termios *tty, void *arg); - void *sw_arg; -}; - -/* - * Variables associated with the character buffer - */ -struct rtems_termios_rawbuf { - char *theBuf; - volatile unsigned int Head; - volatile unsigned int Tail; - volatile unsigned int Size; - rtems_id Semaphore; -}; - -typedef enum { - TERMIOS_POLLED, - TERMIOS_IRQ_DRIVEN, - TERMIOS_TASK_DRIVEN, - TERMIOS_IRQ_SERVER_DRIVEN -} rtems_termios_device_mode; - -struct rtems_termios_tty; - -/** - * @brief Termios device context. - * - * @see RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER(), - * rtems_termios_device_context_initialize() and - * rtems_termios_device_install(). - */ -typedef struct rtems_termios_device_context { - union { - /* Used for TERMIOS_POLLED and TERMIOS_IRQ_DRIVEN */ - rtems_interrupt_lock interrupt; - - /* Used for TERMIOS_IRQ_SERVER_DRIVEN or TERMIOS_TASK_DRIVEN */ - rtems_id mutex; - } lock; - - void ( *lock_acquire )( - struct rtems_termios_device_context *, - rtems_interrupt_lock_context * - ); - - void ( *lock_release )( - struct rtems_termios_device_context *, - rtems_interrupt_lock_context * - ); -} rtems_termios_device_context; - -void rtems_termios_device_lock_acquire_default( - rtems_termios_device_context *ctx, - rtems_interrupt_lock_context *lock_context -); - -void rtems_termios_device_lock_release_default( - rtems_termios_device_context *ctx, - rtems_interrupt_lock_context *lock_context -); - -/** - * @brief Initializes a device context. - * - * @param[in] context The Termios device context. - * @param[in] name The name for the interrupt lock. This name must be a - * string persistent throughout the life time of this lock. The name is only - * used if profiling is enabled. - */ -RTEMS_INLINE_ROUTINE void rtems_termios_device_context_initialize( - rtems_termios_device_context *context, - const char *name -) -{ - rtems_interrupt_lock_initialize( &context->lock.interrupt, name ); - context->lock_acquire = rtems_termios_device_lock_acquire_default; - context->lock_release = rtems_termios_device_lock_release_default; -} - -/** - * @brief Initializer for static initialization of Termios device contexts. - * - * @param name The name for the interrupt lock. It must be a string. The name - * is only used if profiling is enabled. - */ -#define RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER( name ) \ - { \ - { RTEMS_INTERRUPT_LOCK_INITIALIZER( name ) }, \ - rtems_termios_device_lock_acquire_default, \ - rtems_termios_device_lock_release_default \ - } - -/** - * @brief Termios device handler. - * - * @see rtems_termios_device_install(). - */ -typedef struct { - /** - * @brief First open of this device. - * - * @param[in] tty The Termios control. This parameter may be passed to - * interrupt service routines since it must be provided for the - * rtems_termios_enqueue_raw_characters() and - * rtems_termios_dequeue_characters() functions. - * @param[in] context The Termios device context. - * @param[in] term The current Termios attributes. - * @param[in] args The open/close arguments. This is parameter provided to - * support legacy drivers. It must not be used by new drivers. - * - * @retval true Successful operation. - * @retval false Cannot open device. - * - * @see rtems_termios_get_device_context() and rtems_termios_set_best_baud(). - */ - bool (*first_open)( - struct rtems_termios_tty *tty, - rtems_termios_device_context *context, - struct termios *term, - rtems_libio_open_close_args_t *args - ); - - /** - * @brief Last close of this device. - * - * @param[in] tty The Termios control. - * @param[in] context The Termios device context. - * @param[in] args The open/close arguments. This is parameter provided to - * support legacy drivers. It must not be used by new drivers. - */ - void (*last_close)( - struct rtems_termios_tty *tty, - rtems_termios_device_context *context, - rtems_libio_open_close_args_t *args - ); - - /** - * @brief Polled read. - * - * In case mode is TERMIOS_IRQ_DRIVEN, TERMIOS_IRQ_SERVER_DRIVEN or - * TERMIOS_TASK_DRIVEN, then data is received via - * rtems_termios_enqueue_raw_characters(). - * - * @param[in] context The Termios device context. - * - * @retval char The received data encoded as unsigned char. - * @retval -1 No data currently available. - */ - int (*poll_read)(rtems_termios_device_context *context); - - /** - * @brief Polled write in case mode is TERMIOS_POLLED or write support - * otherwise. - * - * @param[in] context The Termios device context. - * @param[in] buf The output buffer. - * @param[in] len The output buffer length in characters. - */ - void (*write)( - rtems_termios_device_context *context, - const char *buf, - size_t len - ); - - /** - * @brief Set attributes after a Termios settings change. - * - * @param[in] context The Termios device context. - * @param[in] term The new Termios attributes. - * - * @retval true Successful operation. - * @retval false Invalid attributes. - */ - bool (*set_attributes)( - rtems_termios_device_context *context, - const struct termios *term - ); - - /** - * @brief IO control handler. - * - * Invoked in case the Termios layer cannot deal with the IO request. - * - * @param[in] context The Termios device context. - * @param[in] request The IO control request. - * @param[in] buffer The IO control buffer. - */ - int (*ioctl)( - rtems_termios_device_context *context, - ioctl_command_t request, - void *buffer - ); - - /** - * @brief Termios device mode. - */ - rtems_termios_device_mode mode; -} rtems_termios_device_handler; - -/** - * @brief Termios device flow control handler. - * - * @see rtems_termios_device_install(). - */ -typedef struct { - /** - * @brief Indicate to stop remote transmitter. - * - * @param[in] context The Termios device context. - */ - void (*stop_remote_tx)(rtems_termios_device_context *context); - - /** - * @brief Indicate to start remote transmitter. - * - * @param[in] context The Termios device context. - */ - void (*start_remote_tx)(rtems_termios_device_context *context); -} rtems_termios_device_flow; - -/** - * @brief Termios device node for installed devices. - * - * @see rtems_termios_device_install(). - */ -typedef struct rtems_termios_device_node { - rtems_chain_node node; - rtems_device_major_number major; - rtems_device_minor_number minor; - const rtems_termios_device_handler *handler; - const rtems_termios_device_flow *flow; - rtems_termios_device_context *context; - struct rtems_termios_tty *tty; -} rtems_termios_device_node; - -/* - * Variables associated with each termios instance. - * One structure for each hardware I/O device. - */ -typedef struct rtems_termios_tty { - /* - * Linked-list of active TERMIOS devices - */ - struct rtems_termios_tty *forw; - struct rtems_termios_tty *back; - - /* - * How many times has this device been opened - */ - int refcount; - - /* - * This device - */ - rtems_device_major_number major; - rtems_device_minor_number minor; - - /* - * Mutual-exclusion semaphores - */ - rtems_id isem; - rtems_id osem; - - /* - * The canonical (cooked) character buffer - */ - char *cbuf; - int ccount; - int cindex; - - /* - * Keep track of cursor (printhead) position - */ - int column; - int read_start_column; - - /* - * The ioctl settings - */ - struct termios termios; - rtems_interval vtimeTicks; - - /* - * Raw input character buffer - */ - struct rtems_termios_rawbuf rawInBuf; - uint32_t rawInBufSemaphoreOptions; - rtems_interval rawInBufSemaphoreTimeout; - rtems_interval rawInBufSemaphoreFirstTimeout; - unsigned int rawInBufDropped; /* Statistics */ - - /* - * Raw output character buffer - */ - struct rtems_termios_rawbuf rawOutBuf; - int t_dqlen; /* count of characters dequeued from device */ - enum {rob_idle, rob_busy, rob_wait } rawOutBufState; - - /* - * Callbacks to device-specific routines - */ - rtems_termios_callbacks device; - - /** - * @brief Context for legacy devices using the callbacks. - */ - rtems_termios_device_context legacy_device_context; - - /** - * @brief The device handler. - */ - rtems_termios_device_handler handler; - - /** - * @brief The device flow control handler. - */ - rtems_termios_device_flow flow; - - volatile unsigned int flow_ctrl; - unsigned int lowwater,highwater; - - /* - * I/O task IDs (for task-driven drivers) - */ - rtems_id rxTaskId; - rtems_id txTaskId; - - /* - * line discipline related stuff - */ - int t_line; /* id of line discipline */ - void *t_sc; /* hook for discipline-specific data structure */ - - /* - * Wakeup callback variables - */ - struct ttywakeup tty_snd; - struct ttywakeup tty_rcv; - bool tty_rcvwakeup; - - /** - * @brief Corresponding device node. - */ - rtems_termios_device_node *device_node; - - /** - * @brief Context for device driver. - */ - rtems_termios_device_context *device_context; -} rtems_termios_tty; - -/** - * @brief Installs a Termios device. - * - * The installed Termios device may be removed via unlink(). - * - * @param[in] device_file The device file path. - * @param[in] handler The device handler. It must be persistent throughout the - * installed time of the device. - * @param[in] flow The device flow control handler. The device flow control - * handler are optional and may be @c NULL. If present must be persistent - * throughout the installed time of the device. - * @param[in] context The device context. It must be persistent throughout the - * installed time of the device. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_NO_MEMORY Not enough memory to create a device node. - * @retval RTEMS_UNSATISFIED Creation of the device file failed. - * @retval RTEMS_INCORRECT_STATE Termios is not initialized. - * - * @see rtems_termios_get_device_context(). - */ -rtems_status_code rtems_termios_device_install( - const char *device_file, - const rtems_termios_device_handler *handler, - const rtems_termios_device_flow *flow, - rtems_termios_device_context *context -); - -/** - * @brief Returns the device context of an installed Termios device. - * - * @param[in] tty The Termios control. - */ -RTEMS_INLINE_ROUTINE void *rtems_termios_get_device_context( - const rtems_termios_tty *tty -) -{ - return tty->device_context; -} - -/** - * @brief Acquires the device lock. - * - * @param[in] context The device context. - * @param[in] lock_context The local interrupt lock context for an acquire and - * release pair. - */ -RTEMS_INLINE_ROUTINE void rtems_termios_device_lock_acquire( - rtems_termios_device_context *context, - rtems_interrupt_lock_context *lock_context -) -{ - ( *context->lock_acquire )( context, lock_context ); -} - -/** - * @brief Releases the device lock. - * - * @param[in] context The device context. - * @param[in] lock_context The local interrupt lock context for an acquire and - * release pair. - */ -RTEMS_INLINE_ROUTINE void rtems_termios_device_lock_release( - rtems_termios_device_context *context, - rtems_interrupt_lock_context *lock_context -) -{ - ( *context->lock_release )( context, lock_context ); -} - -/** - * @brief Sets the best baud value in the Termios control. - * - * The valid Termios baud values are between 0 and 460800. The Termios baud - * value is chosen which minimizes the difference to the value specified. - * - * @param[in] term The Termios attributes. - * @param[in] baud The current baud setting of the device. - */ -void rtems_termios_set_best_baud( - struct termios *term, - uint32_t baud -); - -struct rtems_termios_linesw { - int (*l_open) (struct rtems_termios_tty *tp); - int (*l_close)(struct rtems_termios_tty *tp); - int (*l_read )(struct rtems_termios_tty *tp,rtems_libio_rw_args_t *args); - int (*l_write)(struct rtems_termios_tty *tp,rtems_libio_rw_args_t *args); - int (*l_rint )(int c,struct rtems_termios_tty *tp); - int (*l_start)(struct rtems_termios_tty *tp); - int (*l_ioctl)(struct rtems_termios_tty *tp,rtems_libio_ioctl_args_t *args); - int (*l_modem)(struct rtems_termios_tty *tp,int flags); -}; - -/* - * FIXME: this should move to termios.h! - */ -void rtems_termios_rxirq_occured(struct rtems_termios_tty *tty); - -/* - * FIXME: this should move to termios.h! - * put a string to output ring buffer - */ -void rtems_termios_puts ( - const void *buf, - size_t len, - struct rtems_termios_tty *tty -); - -/* - * global hooks for line disciplines - */ -extern struct rtems_termios_linesw rtems_termios_linesw[]; -extern int rtems_termios_nlinesw; - -#define TTYDISC 0 /* termios tty line discipline */ -#define TABLDISC 3 /* tablet discipline */ -#define SLIPDISC 4 /* serial IP discipline */ -#define PPPDISC 5 /* PPP discipline */ -#define MAXLDISC 8 - -/* baudrate xxx integer type */ -typedef uint32_t rtems_termios_baud_t; - -/** - * @brief RTEMS Termios Baud Table - */ -extern const rtems_assoc_t rtems_termios_baud_table []; - -/** - * @brief Converts the Integral Baud value @a baud to the Termios Control Flag - * Representation - * - * @retval B0 Invalid baud value or a baud value of 0. - * @retval other Baud constant according to @a baud. - */ -speed_t rtems_termios_number_to_baud(rtems_termios_baud_t baud); - -/** - * @brief Converts the baud flags to an integral baud value. - * - * @retval 0 Invalid baud value or a baud value of @c B0. - * @retval other Integral baud value. - */ -rtems_termios_baud_t rtems_termios_baud_to_number(speed_t baud); - -/** - * @brief Convert Bxxx Constant to Index - */ -int rtems_termios_baud_to_index(rtems_termios_baud_t termios_baud); - -/** - * @brief Sets the initial @a baud in the Termios context @a tty. - * - * @retval 0 Successful operation. - * @retval -1 Invalid baud value. - */ -int rtems_termios_set_initial_baud( - struct rtems_termios_tty *tty, - rtems_termios_baud_t baud -); - -/** - * @brief Termios kqueue() filter filesystem node handler - * - * Real implementation is provided by libbsd. - */ -int rtems_termios_kqfilter( - rtems_libio_t *iop, - struct knote *kn -); - -/** - * @brief Termios mmap() filter filesystem node handler - * - * Real implementation is provided by libbsd. - */ -int rtems_termios_mmap( - rtems_libio_t *iop, - void **addr, - size_t len, - int prot, - off_t off -); - -/** - * @brief Termios poll() filesystem node handler. - * - * Real implementation is provided by libbsd. - */ -int rtems_termios_poll( - rtems_libio_t *iop, - int events -); - -#define RTEMS_IO_SNDWAKEUP _IOW('t', 11, struct ttywakeup ) /* send tty wakeup */ -#define RTEMS_IO_RCVWAKEUP _IOW('t', 12, struct ttywakeup ) /* recv tty wakeup */ - -#define OLCUC 0x00000100 /* map lower case to upper case on output */ -#define IUCLC 0x00004000 /* map upper case to lower case on input */ - -#define RTEMS_TERMIOS_NUMBER_BAUD_RATES 25 - -#ifdef __cplusplus -} -#endif - -#endif /* TERMIOSTYPES_H */ diff --git a/cpukit/libcsupport/include/rtems/tod.h b/cpukit/libcsupport/include/rtems/tod.h deleted file mode 100644 index 971e8548e8..0000000000 --- a/cpukit/libcsupport/include/rtems/tod.h +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @file - * - * @ingroup shared_tod - * - * @brief Real Time Clock Time of Day API Definition - */ - -/* - * - * Based on MVME162 TOD by: - * COPYRIGHT (C) 1997 - * by Katsutoshi Shibuya - BU Denken Co.,Ltd. - Sapporo - JAPAN - * ALL RIGHTS RESERVED - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef TOD_H -#define TOD_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup shared_tod RTC - * - * @ingroup bsp_shared - * - * @brief Set the RTC - */ -int setRealTime( - const rtems_time_of_day *tod -); - -/* - * Get the time from the RTC. - */ - -void getRealTime( - rtems_time_of_day *tod -); - -/* - * Read real time from RTC and set it to RTEMS' clock manager - */ - -void setRealTimeToRTEMS(void); - -/* - * Read time from RTEMS' clock manager and set it to RTC - */ - -void setRealTimeFromRTEMS(void); - -/* - * Return the difference between RTC and RTEMS' clock manager time in minutes. - * If the difference is greater than 1 day, this returns 9999. - */ - -int checkRealTime(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/libcsupport/include/spurious.h b/cpukit/libcsupport/include/spurious.h deleted file mode 100644 index 049f3bf3a0..0000000000 --- a/cpukit/libcsupport/include/spurious.h +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @file rtems/spurious.h - * - * This file describes the Spurious Interrupt Driver for all boards. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SPURIOUS_H -#define _RTEMS_SPURIOUS_H - -#include /* rtems_id */ -#include /* rtems_device_driver */ - -#ifdef __cplusplus -extern "C" { -#endif - -#define SPURIOUS_DRIVER_TABLE_ENTRY \ - { Spurious_Initialize, NULL, NULL, NULL, NULL, NULL } - -rtems_device_driver Spurious_Initialize( - rtems_device_major_number, - rtems_device_minor_number, - void *, - rtems_id, - uint32_t * -); - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/libcsupport/include/sys/event.h b/cpukit/libcsupport/include/sys/event.h deleted file mode 100644 index bc18aa90ea..0000000000 --- a/cpukit/libcsupport/include/sys/event.h +++ /dev/null @@ -1,303 +0,0 @@ -/*- - * Copyright (c) 1999,2000,2001 Jonathan Lemon - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: head/sys/sys/event.h 313704 2017-02-13 19:00:09Z ed $ - */ - -#ifndef _SYS_EVENT_H_ -#define _SYS_EVENT_H_ - -#include -#include - -#define EVFILT_READ (-1) -#define EVFILT_WRITE (-2) -#define EVFILT_AIO (-3) /* attached to aio requests */ -#define EVFILT_VNODE (-4) /* attached to vnodes */ -#define EVFILT_PROC (-5) /* attached to struct proc */ -#define EVFILT_SIGNAL (-6) /* attached to struct proc */ -#define EVFILT_TIMER (-7) /* timers */ -#define EVFILT_PROCDESC (-8) /* attached to process descriptors */ -#define EVFILT_FS (-9) /* filesystem events */ -#define EVFILT_LIO (-10) /* attached to lio requests */ -#define EVFILT_USER (-11) /* User events */ -#define EVFILT_SENDFILE (-12) /* attached to sendfile requests */ -#define EVFILT_EMPTY (-13) /* empty send socket buf */ -#define EVFILT_SYSCOUNT 13 - -#define EV_SET(kevp_, a, b, c, d, e, f) do { \ - struct kevent *kevp = (kevp_); \ - (kevp)->ident = (a); \ - (kevp)->filter = (b); \ - (kevp)->flags = (c); \ - (kevp)->fflags = (d); \ - (kevp)->data = (e); \ - (kevp)->udata = (f); \ -} while(0) - -struct kevent { - __uintptr_t ident; /* identifier for this event */ - short filter; /* filter for event */ - unsigned short flags; - unsigned int fflags; - __intptr_t data; - void *udata; /* opaque user data identifier */ -}; - -/* actions */ -#define EV_ADD 0x0001 /* add event to kq (implies enable) */ -#define EV_DELETE 0x0002 /* delete event from kq */ -#define EV_ENABLE 0x0004 /* enable event */ -#define EV_DISABLE 0x0008 /* disable event (not reported) */ -#define EV_FORCEONESHOT 0x0100 /* enable _ONESHOT and force trigger */ - -/* flags */ -#define EV_ONESHOT 0x0010 /* only report one occurrence */ -#define EV_CLEAR 0x0020 /* clear event state after reporting */ -#define EV_RECEIPT 0x0040 /* force EV_ERROR on success, data=0 */ -#define EV_DISPATCH 0x0080 /* disable event after reporting */ - -#define EV_SYSFLAGS 0xF000 /* reserved by system */ -#define EV_DROP 0x1000 /* note should be dropped */ -#define EV_FLAG1 0x2000 /* filter-specific flag */ -#define EV_FLAG2 0x4000 /* filter-specific flag */ - -/* returned values */ -#define EV_EOF 0x8000 /* EOF detected */ -#define EV_ERROR 0x4000 /* error, data contains errno */ - - /* - * data/hint flags/masks for EVFILT_USER, shared with userspace - * - * On input, the top two bits of fflags specifies how the lower twenty four - * bits should be applied to the stored value of fflags. - * - * On output, the top two bits will always be set to NOTE_FFNOP and the - * remaining twenty four bits will contain the stored fflags value. - */ -#define NOTE_FFNOP 0x00000000 /* ignore input fflags */ -#define NOTE_FFAND 0x40000000 /* AND fflags */ -#define NOTE_FFOR 0x80000000 /* OR fflags */ -#define NOTE_FFCOPY 0xc0000000 /* copy fflags */ -#define NOTE_FFCTRLMASK 0xc0000000 /* masks for operations */ -#define NOTE_FFLAGSMASK 0x00ffffff - -#define NOTE_TRIGGER 0x01000000 /* Cause the event to be - triggered for output. */ - -/* - * data/hint flags for EVFILT_{READ|WRITE}, shared with userspace - */ -#define NOTE_LOWAT 0x0001 /* low water mark */ -#define NOTE_FILE_POLL 0x0002 /* behave like poll() */ - -/* - * data/hint flags for EVFILT_VNODE, shared with userspace - */ -#define NOTE_DELETE 0x0001 /* vnode was removed */ -#define NOTE_WRITE 0x0002 /* data contents changed */ -#define NOTE_EXTEND 0x0004 /* size increased */ -#define NOTE_ATTRIB 0x0008 /* attributes changed */ -#define NOTE_LINK 0x0010 /* link count changed */ -#define NOTE_RENAME 0x0020 /* vnode was renamed */ -#define NOTE_REVOKE 0x0040 /* vnode access was revoked */ -#define NOTE_OPEN 0x0080 /* vnode was opened */ -#define NOTE_CLOSE 0x0100 /* file closed, fd did not - allowed write */ -#define NOTE_CLOSE_WRITE 0x0200 /* file closed, fd did allowed - write */ -#define NOTE_READ 0x0400 /* file was read */ - -/* - * data/hint flags for EVFILT_PROC and EVFILT_PROCDESC, shared with userspace - */ -#define NOTE_EXIT 0x80000000 /* process exited */ -#define NOTE_FORK 0x40000000 /* process forked */ -#define NOTE_EXEC 0x20000000 /* process exec'd */ -#define NOTE_PCTRLMASK 0xf0000000 /* mask for hint bits */ -#define NOTE_PDATAMASK 0x000fffff /* mask for pid */ - -/* additional flags for EVFILT_PROC */ -#define NOTE_TRACK 0x00000001 /* follow across forks */ -#define NOTE_TRACKERR 0x00000002 /* could not track child */ -#define NOTE_CHILD 0x00000004 /* am a child process */ - -/* additional flags for EVFILT_TIMER */ -#define NOTE_SECONDS 0x00000001 /* data is seconds */ -#define NOTE_MSECONDS 0x00000002 /* data is milliseconds */ -#define NOTE_USECONDS 0x00000004 /* data is microseconds */ -#define NOTE_NSECONDS 0x00000008 /* data is nanoseconds */ - -struct knote; -SLIST_HEAD(klist, knote); -struct kqueue; -TAILQ_HEAD(kqlist, kqueue); -struct knlist { - struct klist kl_list; - void (*kl_lock)(void *); /* lock function */ - void (*kl_unlock)(void *); - void (*kl_assert_locked)(void *); - void (*kl_assert_unlocked)(void *); - void *kl_lockarg; /* argument passed to lock functions */ - int kl_autodestroy; -}; - - -#ifdef _KERNEL - -/* - * Flags for knote call - */ -#define KNF_LISTLOCKED 0x0001 /* knlist is locked */ -#define KNF_NOKQLOCK 0x0002 /* do not keep KQ_LOCK */ - -#define KNOTE(list, hist, flags) knote(list, hist, flags) -#define KNOTE_LOCKED(list, hint) knote(list, hint, KNF_LISTLOCKED) -#define KNOTE_UNLOCKED(list, hint) knote(list, hint, 0) - -#define KNLIST_EMPTY(list) SLIST_EMPTY(&(list)->kl_list) - -/* - * Flag indicating hint is a signal. Used by EVFILT_SIGNAL, and also - * shared by EVFILT_PROC (all knotes attached to p->p_klist) - */ -#define NOTE_SIGNAL 0x08000000 - -/* - * Hint values for the optional f_touch event filter. If f_touch is not set - * to NULL and f_isfd is zero the f_touch filter will be called with the type - * argument set to EVENT_REGISTER during a kevent() system call. It is also - * called under the same conditions with the type argument set to EVENT_PROCESS - * when the event has been triggered. - */ -#define EVENT_REGISTER 1 -#define EVENT_PROCESS 2 - -struct filterops { - int f_isfd; /* true if ident == filedescriptor */ - int (*f_attach)(struct knote *kn); - void (*f_detach)(struct knote *kn); - int (*f_event)(struct knote *kn, long hint); - void (*f_touch)(struct knote *kn, struct kevent *kev, u_long type); -}; - -/* - * An in-flux knote cannot be dropped from its kq while the kq is - * unlocked. If the KN_SCAN flag is not set, a thread can only set - * kn_influx when it is exclusive owner of the knote state, and can - * modify kn_status as if it had the KQ lock. KN_SCAN must not be set - * on a knote which is already in flux. - * - * kn_sfflags, kn_sdata, and kn_kevent are protected by the knlist lock. - */ -struct knote { - SLIST_ENTRY(knote) kn_link; /* for kq */ - SLIST_ENTRY(knote) kn_selnext; /* for struct selinfo */ - struct knlist *kn_knlist; /* f_attach populated */ - TAILQ_ENTRY(knote) kn_tqe; - struct kqueue *kn_kq; /* which queue we are on */ - struct kevent kn_kevent; - void *kn_hook; - int kn_hookid; - int kn_status; /* protected by kq lock */ -#define KN_ACTIVE 0x01 /* event has been triggered */ -#define KN_QUEUED 0x02 /* event is on queue */ -#define KN_DISABLED 0x04 /* event is disabled */ -#define KN_DETACHED 0x08 /* knote is detached */ -#define KN_MARKER 0x20 /* ignore this knote */ -#define KN_KQUEUE 0x40 /* this knote belongs to a kq */ -#define KN_HASKQLOCK 0x80 /* for _inevent */ -#define KN_SCAN 0x100 /* flux set in kqueue_scan() */ - int kn_influx; - int kn_sfflags; /* saved filter flags */ - intptr_t kn_sdata; /* saved data field */ - union { - struct file *p_fp; /* file data pointer */ - struct proc *p_proc; /* proc pointer */ - struct kaiocb *p_aio; /* AIO job pointer */ - struct aioliojob *p_lio; /* LIO job pointer */ - void *p_v; /* generic other pointer */ - } kn_ptr; - struct filterops *kn_fop; - -#define kn_id kn_kevent.ident -#define kn_filter kn_kevent.filter -#define kn_flags kn_kevent.flags -#define kn_fflags kn_kevent.fflags -#define kn_data kn_kevent.data -#define kn_fp kn_ptr.p_fp -}; -struct kevent_copyops { - void *arg; - int (*k_copyout)(void *arg, struct kevent *kevp, int count); - int (*k_copyin)(void *arg, struct kevent *kevp, int count); -}; - -struct thread; -struct proc; -struct knlist; -struct mtx; -struct rwlock; - -void knote(struct knlist *list, long hint, int lockflags); -void knote_fork(struct knlist *list, int pid); -struct knlist *knlist_alloc(struct mtx *lock); -void knlist_detach(struct knlist *knl); -void knlist_add(struct knlist *knl, struct knote *kn, int islocked); -void knlist_remove(struct knlist *knl, struct knote *kn, int islocked); -int knlist_empty(struct knlist *knl); -void knlist_init(struct knlist *knl, void *lock, void (*kl_lock)(void *), - void (*kl_unlock)(void *), void (*kl_assert_locked)(void *), - void (*kl_assert_unlocked)(void *)); -void knlist_init_mtx(struct knlist *knl, struct mtx *lock); -void knlist_init_rw_reader(struct knlist *knl, struct rwlock *lock); -void knlist_destroy(struct knlist *knl); -void knlist_cleardel(struct knlist *knl, struct thread *td, - int islocked, int killkn); -#define knlist_clear(knl, islocked) \ - knlist_cleardel((knl), NULL, (islocked), 0) -#define knlist_delete(knl, td, islocked) \ - knlist_cleardel((knl), (td), (islocked), 1) -void knote_fdclose(struct thread *p, int fd); -int kqfd_register(int fd, struct kevent *kev, struct thread *p, - int waitok); -int kqueue_add_filteropts(int filt, struct filterops *filtops); -int kqueue_del_filteropts(int filt); - -#else /* !_KERNEL */ - -#include -struct timespec; - -__BEGIN_DECLS -int kqueue(void); -int kevent(int kq, const struct kevent *changelist, int nchanges, - struct kevent *eventlist, int nevents, - const struct timespec *timeout); -__END_DECLS - -#endif /* !_KERNEL */ - -#endif /* !_SYS_EVENT_H_ */ diff --git a/cpukit/libcsupport/include/sys/poll.h b/cpukit/libcsupport/include/sys/poll.h deleted file mode 100644 index c955f321c7..0000000000 --- a/cpukit/libcsupport/include/sys/poll.h +++ /dev/null @@ -1,104 +0,0 @@ -/*- - * Copyright (c) 1997 Peter Wemm - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _SYS_POLL_H_ -#define _SYS_POLL_H_ - -#include - -/* - * This file is intended to be compatible with the traditional poll.h. - */ - -typedef unsigned int nfds_t; - -/* - * This structure is passed as an array to poll(2). - */ -struct pollfd { - int fd; /* which file descriptor to poll */ - short events; /* events we are interested in */ - short revents; /* events found on return */ -}; - -/* - * Requestable events. If poll(2) finds any of these set, they are - * copied to revents on return. - * XXX Note that FreeBSD doesn't make much distinction between POLLPRI - * and POLLRDBAND since none of the file types have distinct priority - * bands - and only some have an urgent "mode". - * XXX Note POLLIN isn't really supported in true SVSV terms. Under SYSV - * POLLIN includes all of normal, band and urgent data. Most poll handlers - * on FreeBSD only treat it as "normal" data. - */ -#define POLLIN 0x0001 /* any readable data available */ -#define POLLPRI 0x0002 /* OOB/Urgent readable data */ -#define POLLOUT 0x0004 /* file descriptor is writeable */ -#define POLLRDNORM 0x0040 /* non-OOB/URG data available */ -#define POLLWRNORM POLLOUT /* no write type differentiation */ -#define POLLRDBAND 0x0080 /* OOB/Urgent readable data */ -#define POLLWRBAND 0x0100 /* OOB/Urgent data can be written */ - -#if __BSD_VISIBLE -/* General FreeBSD extension (currently only supported for sockets): */ -#define POLLINIGNEOF 0x2000 /* like POLLIN, except ignore EOF */ -#endif - -/* - * These events are set if they occur regardless of whether they were - * requested. - */ -#define POLLERR 0x0008 /* some poll error occurred */ -#define POLLHUP 0x0010 /* file descriptor was "hung up" */ -#define POLLNVAL 0x0020 /* requested events "invalid" */ - -#if __BSD_VISIBLE - -#define POLLSTANDARD (POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|\ - POLLWRBAND|POLLERR|POLLHUP|POLLNVAL) - -/* - * Request that poll() wait forever. - * XXX in SYSV, this is defined in stropts.h, which is not included - * by poll.h. - */ -#define INFTIM (-1) - -#endif - -#ifndef _KERNEL - -__BEGIN_DECLS -int poll(struct pollfd _pfd[], nfds_t _nfds, int _timeout); -__END_DECLS - -#endif /* !_KERNEL */ - -#endif /* !_SYS_POLL_H_ */ diff --git a/cpukit/libcsupport/include/sys/statvfs.h b/cpukit/libcsupport/include/sys/statvfs.h deleted file mode 100644 index cf80478aae..0000000000 --- a/cpukit/libcsupport/include/sys/statvfs.h +++ /dev/null @@ -1,60 +0,0 @@ -/** - * @file - * - * @brief Interface to the statvfs() Set of API Methods - * - * This include file defines the interface to the statvfs() set of - * API methods. The statvfs as defined by the SUS: - * - * - http://www.opengroup.org/onlinepubs/009695399/basedefs/sys/statvfs.h.html - */ - -/* - * COPYRIGHT (c) 2009 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -/* - */ - -#ifndef _SYS_STATVFS_H_ -#define _SYS_STATVFS_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef uint64_t fsblkcnt_t; -typedef uint32_t fsfilcnt_t; - -struct statvfs -{ - unsigned long f_bsize; /**< File system block size. */ - unsigned long f_frsize; /**< Fundamental file system block size. */ - fsblkcnt_t f_blocks; /**< Total number of blocks on file system in units - * of f_frsize. */ - fsblkcnt_t f_bfree; /**< Total number of free blocks. */ - fsblkcnt_t f_bavail; /**< Number of free blocks available to - * non-privileged process. */ - fsfilcnt_t f_files; /**< Total number of file serial numbers. */ - fsfilcnt_t f_ffree; /**< Total number of free file serial numbers. */ - fsfilcnt_t f_favail; /**< Number of file serial numbers available to - * non-privileged process. */ - unsigned long f_fsid; /**< File system ID. */ - unsigned long f_flag; /**< Bit mask of f_flag values. */ - unsigned long f_namemax; /**< Maximum filename length. */ -}; - -extern int statvfs(const char *__restrict , struct statvfs *__restrict); -extern int fstatvfs(int, struct statvfs *); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/libcsupport/include/sys/utsname.h b/cpukit/libcsupport/include/sys/utsname.h deleted file mode 100644 index ddeb0e90c2..0000000000 --- a/cpukit/libcsupport/include/sys/utsname.h +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @file - * - * @brief Interface to the POSIX utsname() Service - * - * This include file defines the interface to the POSIX utsname() service. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef __POSIX_SYS_UTSNAME_h -#define __POSIX_SYS_UTSNAME_h - -/** - * @defgroup UTSNAME utsname Service - * - * @ingroup POSIXAPI - */ -/**@{*/ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * 4.4.1 Get System Name (Table 4-1), P1003.1b-1993, p. 90 - * - * NOTE: The lengths of the strings in this structure are - * just long enough to reliably contain the RTEMS information. - * For example, the fields are not long enough to support - * Internet hostnames. - */ - -#ifdef _KERNEL -#define SYS_NMLN 48 /* uname(2) for the FreeBSD 1.1 ABI. */ -#endif - -#ifndef SYS_NMLN -#define SYS_NMLN 48 /* User can override. */ -#endif - -struct utsname { - char sysname[SYS_NMLN]; /* Name of this implementation of the */ - /* operating system */ - char nodename[SYS_NMLN]; /* Name of this node within an implementation */ - /* specified communication network */ - char release[SYS_NMLN]; /* Current release level of this implementation */ - char version[SYS_NMLN]; /* Current version level of this release */ - char machine[SYS_NMLN]; /* Name of the hardware type on which the system */ - /* is running */ -}; - -/** - * @brief Get system name. - * - * 4.4.1 Get System Name, P1003.1b-1993, p. 90 - */ -int uname( - struct utsname *name -); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/libcsupport/include/vmeintr.h b/cpukit/libcsupport/include/vmeintr.h deleted file mode 100644 index 74bda9bf08..0000000000 --- a/cpukit/libcsupport/include/vmeintr.h +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @file - * - * @brief VMEbus Interface Library - * - * This file is the specification for the VMEbus interface library - * which should be provided by all BSPs for VMEbus Single Board - * Computers but currently only a few do so. - */ - -/* - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_VMEINTR_H -#define _RTEMS_VMEINTR_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This defines the mask which is used to determine which - * interrupt levels are affected by a call to this package. - * The LSB corresponds to VME interrupt 0 and the MSB - * to VME interrupt 7. - * - */ - -typedef uint8_t VME_interrupt_Mask; - -/* - * VME_interrupt_Disable - * - */ - -void VME_interrupt_Disable ( - VME_interrupt_Mask mask /* IN */ -); - -/* - * VME_interrupt_Disable - * - */ - -void VME_interrupt_Enable ( - VME_interrupt_Mask mask /* IN */ -); - -#ifdef __cplusplus -} -#endif - -#endif /* end of include file */ diff --git a/cpukit/libcsupport/preinstall.am b/cpukit/libcsupport/preinstall.am deleted file mode 100644 index 01a128e2ff..0000000000 --- a/cpukit/libcsupport/preinstall.am +++ /dev/null @@ -1,101 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -$(PROJECT_INCLUDE)/rtems/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems - @: > $(PROJECT_INCLUDE)/rtems/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/iosupp.h: include/iosupp.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/iosupp.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/iosupp.h - -$(PROJECT_INCLUDE)/rtems/ringbuf.h: include/ringbuf.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/ringbuf.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/ringbuf.h - -$(PROJECT_INCLUDE)/rtems/tod.h: include/rtems/tod.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/tod.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/tod.h - -$(PROJECT_INCLUDE)/rtems/spurious.h: include/spurious.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/spurious.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/spurious.h - -$(PROJECT_INCLUDE)/rtems/vmeintr.h: include/vmeintr.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/vmeintr.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/vmeintr.h - -$(PROJECT_INCLUDE)/rtems/assoc.h: include/rtems/assoc.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/assoc.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/assoc.h - -$(PROJECT_INCLUDE)/rtems/deviceio.h: include/rtems/deviceio.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/deviceio.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/deviceio.h - -$(PROJECT_INCLUDE)/rtems/error.h: include/rtems/error.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/error.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/error.h - -$(PROJECT_INCLUDE)/rtems/libcsupport.h: include/rtems/libcsupport.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/libcsupport.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/libcsupport.h - -$(PROJECT_INCLUDE)/rtems/libio.h: include/rtems/libio.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/libio.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/libio.h - -$(PROJECT_INCLUDE)/rtems/libio_.h: include/rtems/libio_.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/libio_.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/libio_.h - -$(PROJECT_INCLUDE)/rtems/malloc.h: include/rtems/malloc.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/malloc.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/malloc.h - -$(PROJECT_INCLUDE)/rtems/termiostypes.h: include/rtems/termiostypes.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/termiostypes.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/termiostypes.h - -$(PROJECT_INCLUDE)/rtems/gxx_wrappers.h: include/rtems/gxx_wrappers.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/gxx_wrappers.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/gxx_wrappers.h - -$(PROJECT_INCLUDE)/machine/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/machine - @: > $(PROJECT_INCLUDE)/machine/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/machine/$(dirstamp) - -$(PROJECT_INCLUDE)/machine/_kernel_cpuset.h: include/machine/_kernel_cpuset.h $(PROJECT_INCLUDE)/machine/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/machine/_kernel_cpuset.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/machine/_kernel_cpuset.h - -$(PROJECT_INCLUDE)/machine/_kernel_param.h: include/machine/_kernel_param.h $(PROJECT_INCLUDE)/machine/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/machine/_kernel_param.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/machine/_kernel_param.h - -$(PROJECT_INCLUDE)/machine/_kernel_time.h: include/machine/_kernel_time.h $(PROJECT_INCLUDE)/machine/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/machine/_kernel_time.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/machine/_kernel_time.h - -$(PROJECT_INCLUDE)/machine/_kernel_types.h: include/machine/_kernel_types.h $(PROJECT_INCLUDE)/machine/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/machine/_kernel_types.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/machine/_kernel_types.h - -$(PROJECT_INCLUDE)/machine/_timecounter.h: include/machine/_timecounter.h $(PROJECT_INCLUDE)/machine/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/machine/_timecounter.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/machine/_timecounter.h - diff --git a/cpukit/libdebugger/Makefile.am b/cpukit/libdebugger/Makefile.am index 72a89447d7..b202003e41 100644 --- a/cpukit/libdebugger/Makefile.am +++ b/cpukit/libdebugger/Makefile.am @@ -1,7 +1,7 @@ -if LIBDEBUGGER - include $(top_srcdir)/automake/compile.am +if LIBDEBUGGER + noinst_LIBRARIES = libdebugger.a libdebugger_a_SOURCES = \ rtems-debugger-block.c \ @@ -19,5 +19,4 @@ endif endif -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am diff --git a/cpukit/libdebugger/preinstall.am b/cpukit/libdebugger/preinstall.am deleted file mode 100644 index 695eb30912..0000000000 --- a/cpukit/libdebugger/preinstall.am +++ /dev/null @@ -1,9 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -if LIBDEBUGGER -endif diff --git a/cpukit/libdebugger/rtems-debugger-remote.h b/cpukit/libdebugger/rtems-debugger-remote.h deleted file mode 100644 index 34ad9ee6d2..0000000000 --- a/cpukit/libdebugger/rtems-debugger-remote.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2016 Chris Johns . - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * Debugger for RTEMS. - */ - -#ifndef _RTEMS_DEBUGGER_REMOTE_h -#define _RTEMS_DEBUGGER_REMOTE_h - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * Debugger remote. - */ -struct rtems_debugger_remote -{ - const char* name; - int (*begin)(rtems_debugger_remote* remote, const char* device); - int (*end)(rtems_debugger_remote* remote); - int (*connect)(rtems_debugger_remote* remote); - int (*disconnect)(rtems_debugger_remote* remote); - bool (*isconnected)(rtems_debugger_remote* remote); - ssize_t (*read)(rtems_debugger_remote* remote, void* buf, size_t nbytes); - ssize_t (*write)(rtems_debugger_remote* remote, const void* buf, size_t nbytes); - void* data; -}; - -/** - * Register a remote with the server. - */ -int rtems_debugger_remote_register(rtems_debugger_remote* remote); - -/** - * Find a remote by name. - */ -rtems_debugger_remote* rtems_debugger_remote_find(const char* name); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif diff --git a/cpukit/libdebugger/rtems-debugger-server.h b/cpukit/libdebugger/rtems-debugger-server.h deleted file mode 100644 index a345d7649e..0000000000 --- a/cpukit/libdebugger/rtems-debugger-server.h +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (c) 2016-2017 Chris Johns . - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * Debugger for RTEMS. - */ - -#ifndef _RTEMS_DEBUGGER_SERVER_h -#define _RTEMS_DEBUGGER_SERVER_h - -#include -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * Debugger NUMOF macro. - */ -#define RTEMS_DEBUGGER_NUMOF(_d) (sizeof(_d) / sizeof(_d[0])) - -/** - * Machine specific size. Here for 64bit support. - */ -#define DB_UINT uint32_t - -/* - * Debugger signals. - */ -#define RTEMS_DEBUGGER_SIGNAL_HUP 1 /* Hangup */ -#define RTEMS_DEBUGGER_SIGNAL_INT 2 /* Interrupt */ -#define RTEMS_DEBUGGER_SIGNAL_QUIT 3 /* Quit */ -#define RTEMS_DEBUGGER_SIGNAL_ILL 4 /* Illegal instruction */ -#define RTEMS_DEBUGGER_SIGNAL_TRAP 5 /* Trace/breakpoint trap */ -#define RTEMS_DEBUGGER_SIGNAL_ABRT 6 /* Aborted */ -#define RTEMS_DEBUGGER_SIGNAL_EMT 7 /* Emulation trap */ -#define RTEMS_DEBUGGER_SIGNAL_FPE 8 /* Arithmetic exception */ -#define RTEMS_DEBUGGER_SIGNAL_KILL 9 /* Killed */ -#define RTEMS_DEBUGGER_SIGNAL_BUS 10 /* Bus error */ -#define RTEMS_DEBUGGER_SIGNAL_SEGV 11 /* Segmentation fault */ -#define RTEMS_DEBUGGER_SIGNAL_SYS 12 /* Bad system call */ -#define RTEMS_DEBUGGER_SIGNAL_PIPE 13 /* Broken pipe */ -#define RTEMS_DEBUGGER_SIGNAL_ALRM 14 /* Alarm clock */ -#define RTEMS_DEBUGGER_SIGNAL_TERM 15 /* Terminated */ -#define RTEMS_DEBUGGER_SIGNAL_URG 16 /* Urgent I/O condition */ -#define RTEMS_DEBUGGER_SIGNAL_STOP 17 /* Stopped (signal) */ -#define RTEMS_DEBUGGER_SIGNAL_TSTP 18 /* Stopped (user) */ -#define RTEMS_DEBUGGER_SIGNAL_CONT 19 /* Continued */ - -/** - * Timeout period for the Debugger task to stop in usecs. - */ -#define RTEMS_DEBUGGER_TIMEOUT_STOP (5 * 1000 * 1000) - -/** - * Debugger poll wait timeout in usecs. - */ -#define RTEMS_DEBUGGER_POLL_WAIT (10000) - -/** - * Debugger task stack size. - */ -#define RTEMS_DEBUGGER_STACKSIZE (16 * 1024) - -/** - * Debugger output buffer size. - */ -#define RTEMS_DEBUGGER_BUFFER_SIZE (4 * 1024) - -/** - * Debugger flags. - */ -#define RTEMS_DEBUGGER_FLAG_VERBOSE (1 << 0) -#define RTEMS_DEBUGGER_FLAG_RESET (1 << 1) -#define RTEMS_DEBUGGER_FLAG_NON_STOP (1 << 2) -#define RTEMS_DEBUGGER_FLAG_VCONT (1 << 3) -#define RTEMS_DEBUGGER_FLAG_MULTIPROCESS (1 << 4) -#define RTEMS_DEBUGGER_FLAG_VERBOSE_LOCK (1 << 5) -#define RTEMS_DEBUGGER_FLAG_VERBOSE_CMDS (1 << 6) - -/** - * Forward decl for the threads and targets. - */ -typedef struct rtems_debugger_remote rtems_debugger_remote; -typedef struct rtems_debugger_threads rtems_debugger_threads; -typedef struct rtems_debugger_target rtems_debugger_target; - -/** - * Local types for the RTEMS-X interface. - */ -typedef struct _Condition_Control rtems_rx_cond; -typedef struct _Mutex_recursive_Control rtems_rx_mutex; - -/** - * Debugger data. - */ -typedef struct -{ - int port; - int timeout; - rtems_task_priority priority; - rtems_rx_mutex lock; - rtems_debugger_remote* remote; - rtems_id server_task; - rtems_rx_cond server_cond; - volatile bool server_running; - volatile bool server_finished; - rtems_id events_task; - volatile bool events_running; - volatile bool events_finished; - rtems_printer printer; - uint32_t flags; - pid_t pid; - bool remote_debug; - bool ack_pending; - size_t output_level; - uint8_t input[RTEMS_DEBUGGER_BUFFER_SIZE]; - uint8_t output[RTEMS_DEBUGGER_BUFFER_SIZE]; - rtems_debugger_threads* threads; - rtems_chain_control exception_threads; - int signal; - rtems_debugger_target* target; -} rtems_debugger_server; - -/** - * Debugger global variable. - */ -extern rtems_debugger_server* rtems_debugger; - -/** - * Debug server printer. - */ -extern int rtems_debugger_printf(const char* format, ...) RTEMS_PRINTFLIKE(1, 2); -extern int rtems_debugger_clean_printf(const char* format, ...) RTEMS_PRINTFLIKE(1, 2); -extern void rtems_debugger_printk_lock(rtems_interrupt_lock_context* lock_context); -extern void rtems_debugger_printk_unlock(rtems_interrupt_lock_context* lock_context); - -/** - * Lock the Debugger. - */ -extern void rtems_debugger_lock(void); - -/** - * Unlock the Debugger. - */ -extern void rtems_debugger_unlock(void); - -/** - * Is the server still running? - */ -extern bool rtems_debugger_server_running(void); - -/** - * Get the remote handle from the debugger. - */ -extern rtems_debugger_remote* rtems_debugger_remote_handle(void); - -/** - * Is the debugger connected? - */ -extern bool rtems_debugger_connected(void); - -/** - * Is the debugger events thread runnins? - */ -extern bool rtems_debugger_server_events_running(void); - -/** - * Signal events thread in the debug server to run. - */ -extern void rtems_debugger_server_events_signal(void); - -/** - * Check if verbose is on. - */ -extern bool rtems_debugger_verbose(void); - -/** - * Check a flag. - */ -static inline bool rtems_debugger_server_flag(uint32_t mask) -{ - return (rtems_debugger->flags & mask) != 0; -} - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif diff --git a/cpukit/libdebugger/rtems-debugger.h b/cpukit/libdebugger/rtems-debugger.h deleted file mode 100644 index 1fc8b3d522..0000000000 --- a/cpukit/libdebugger/rtems-debugger.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2016 Chris Johns . All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * Debugger for RTEMS. - */ - -#ifndef _RTEMS_DEBUGGER_h -#define _RTEMS_DEBUGGER_h - -#include - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * Timeout period for an ack - */ -#define RTEMS_DEBUGGER_TIMEOUT (3) - -/** - * Start the Debugger. - */ -extern int rtems_debugger_start(const char* remote, - const char* device, - int timeout, - rtems_task_priority priority, - const rtems_printer* printer); - -/** - * Stop the Debugger. - */ -extern int rtems_debugger_stop(void); - -/** - * Is the Debugger running?. - */ -extern bool rtems_debugger_running(void); - -/** - * Verbose control. - */ -extern void rtems_debugger_set_verbose(bool on); - -/** - * Control remote debug printing. - */ -extern int rtems_debugger_remote_debug(bool state); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif diff --git a/cpukit/libdl/Makefile.am b/cpukit/libdl/Makefile.am index b21c16750a..8b95a7d91c 100644 --- a/cpukit/libdl/Makefile.am +++ b/cpukit/libdl/Makefile.am @@ -1,7 +1,7 @@ -if LIBDL - include $(top_srcdir)/automake/compile.am +if LIBDL + noinst_LIBRARIES = libdl.a libdl_a_SOURCES = \ dlfcn-shell.c \ @@ -33,5 +33,4 @@ libdl_a_CPPFLAGS = $(AM_CPPFLAGS) -DRTEMS_RTL_RAP_LOADER=1 -DRTEMS_RTL_ELF_LOADE endif -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am diff --git a/cpukit/libdl/dlfcn-shell.h b/cpukit/libdl/dlfcn-shell.h deleted file mode 100644 index 9383577d25..0000000000 --- a/cpukit/libdl/dlfcn-shell.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * COPYRIGHT (c) 2012 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if !defined(_DLFCN_SHELL_H_) -#define _DLFCN_SHELL_H_ - -int shell_dlopen (int argc, char* argv[]); -int shell_dlclose (int argc, char* argv[]); -int shell_dlsym (int argc, char* argv[]); -int shell_dlcall (int argc, char* argv[]); - -#endif diff --git a/cpukit/libdl/dlfcn.h b/cpukit/libdl/dlfcn.h deleted file mode 100644 index 1ac3ba1330..0000000000 --- a/cpukit/libdl/dlfcn.h +++ /dev/null @@ -1,112 +0,0 @@ -/* $NetBSD: dlfcn.h,v 1.21 2010/01/07 07:35:35 skrll Exp $ */ - -/*- - * Copyright (c) 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Paul Kranenburg. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _DLFCN_H_ -#define _DLFCN_H_ - -//#include -#include - -#if defined(_NETBSD_SOURCE) -typedef struct _dl_info { - const char *dli_fname; /* File defining the symbol */ - void *dli_fbase; /* Base address */ - const char *dli_sname; /* Symbol name */ - const void *dli_saddr; /* Symbol address */ -} Dl_info; -#endif /* defined(_NETBSD_SOURCE) */ - -/* - * User interface to the run-time linker. - */ -__BEGIN_DECLS -void *dlopen(const char *, int); -int dlclose(void *); -void *dlsym(void * __restrict, const char * __restrict); -#if defined(_NETBSD_SOURCE) -int dladdr(void * __restrict, Dl_info * __restrict); -int dlctl(void *, int, void *); -#endif -int dlinfo(void *, int, void *); -const char *dlerror(void); -__END_DECLS - -/* Values for dlopen `mode'. */ -#define RTLD_LAZY 1 -#define RTLD_NOW 2 -#define RTLD_GLOBAL 0x100 /* Allow global searches in object */ -#define RTLD_LOCAL 0x200 -#if defined(_NETBSD_SOURCE) -#define DL_LAZY RTLD_LAZY /* Compat */ -#endif - -/* - * Special handle arguments for dlsym(). - */ -#define RTLD_NEXT ((void *) -1) /* Search subsequent objects. */ -#define RTLD_DEFAULT ((void *) -2) /* Use default search algorithm. */ -#define RTLD_SELF ((void *) -3) /* Search the caller itself. */ - -/* - * dlctl() commands - */ -#if defined(_NETBSD_SOURCE) -#define DL_GETERRNO 1 -#define DL_GETSYMBOL 2 -#if 0 -#define DL_SETSRCHPATH x -#define DL_GETLIST x -#define DL_GETREFCNT x -#define DL_GETLOADADDR x -#endif /* 0 */ -#endif /* defined(_NETBSD_SOURCE) */ - -/* - * dlinfo() commands - * - * From Solaris: http://docs.sun.com/app/docs/doc/816-5168/dlinfo-3c?a=view - */ -#define RTLD_DI_UNRESOLVED 10 -#if defined(_NETBSD_SOURCE) -#define RTLD_DI_LINKMAP 3 -#if 0 -#define RTLD_DI_ARGSINFO 1 -#define RTLD_DI_CONFIGADDR 2 -#define RTLD_DI_LMID 4 -#define RTLD_DI_SERINFO 5 -#define RTLD_DI_SERINFOSIZE 6 -#define RTLD_DI_ORIGIN 7 -#define RTLD_DI_GETSIGNAL 8 -#define RTLD_DI_SETSIGNAL 9 -#endif -#endif /* _NETBSD_SOURCE */ - -#endif /* !defined(_DLFCN_H_) */ diff --git a/cpukit/libdl/include/arch/arm/machine/elf_machdep.h b/cpukit/libdl/include/arch/arm/machine/elf_machdep.h deleted file mode 100644 index 8f01d05212..0000000000 --- a/cpukit/libdl/include/arch/arm/machine/elf_machdep.h +++ /dev/null @@ -1,132 +0,0 @@ -/* $NetBSD: elf_machdep.h,v 1.8 2009/05/30 05:56:52 skrll Exp $ */ - -#if defined(__ARMEB__) -#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB -#else -#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB -#endif - -#define ELF64_MACHDEP_ENDIANNESS XXX /* break compilation */ -#define ELF64_MACHDEP_ID_CASES \ - /* no 64-bit ELF machine types supported */ - -/* Processor specific flags for the ELF header e_flags field. */ -#define EF_ARM_RELEXEC 0x00000001 -#define EF_ARM_HASENTRY 0x00000002 -#define EF_ARM_INTERWORK 0x00000004 /* GNU binutils 000413 */ -#define EF_ARM_SYMSARESORTED 0x00000004 /* ARM ELF A08 */ -#define EF_ARM_APCS_26 0x00000008 /* GNU binutils 000413 */ -#define EF_ARM_DYNSYMSUSESEGIDX 0x00000008 /* ARM ELF B01 */ -#define EF_ARM_APCS_FLOAT 0x00000010 /* GNU binutils 000413 */ -#define EF_ARM_MAPSYMSFIRST 0x00000010 /* ARM ELF B01 */ -#define EF_ARM_PIC 0x00000020 -#define EF_ARM_ALIGN8 0x00000040 /* 8-bit structure alignment. */ -#define EF_ARM_NEW_ABI 0x00000080 -#define EF_ARM_OLD_ABI 0x00000100 -#define EF_ARM_SOFT_FLOAT 0x00000200 -#define EF_ARM_EABIMASK 0xff000000 - -#define ELF32_MACHDEP_ID_CASES \ - case EM_ARM: \ - break; - -#define ELF32_MACHDEP_ID EM_ARM - -#define ARCH_ELFSIZE 32 /* MD native binary size */ - -/* Processor specific relocation types */ - -#define R_ARM_NONE 0 -#define R_ARM_PC24 1 -#define R_ARM_ABS32 2 -#define R_ARM_REL32 3 -#define R_ARM_PC13 4 -#define R_ARM_ABS16 5 -#define R_ARM_ABS12 6 -#define R_ARM_THM_ABS5 7 -#define R_ARM_ABS8 8 -#define R_ARM_SBREL32 9 -#define R_ARM_THM_CALL 10 -#define R_ARM_THM_PC8 11 -#define R_ARM_AMP_VCALL9 12 -#define R_ARM_SWI24 13 -#define R_ARM_THM_SWI8 14 -#define R_ARM_XPC25 15 -#define R_ARM_THM_XPC22 16 - -/* TLS relocations */ -#define R_ARM_TLS_DTPMOD32 17 /* ID of module containing symbol */ -#define R_ARM_TLS_DTPOFF32 18 /* Offset in TLS block */ -#define R_ARM_TLS_TPOFF32 19 /* Offset in static TLS block */ - -/* 20-31 are reserved for ARM Linux. */ -#define R_ARM_COPY 20 -#define R_ARM_GLOB_DAT 21 -#define R_ARM_JUMP_SLOT 22 -#define R_ARM_RELATIVE 23 -#define R_ARM_GOTOFF 24 -#define R_ARM_GOTPC 25 -#define R_ARM_GOT32 26 -#define R_ARM_PLT32 27 -#define R_ARM_CALL 28 -#define R_ARM_JUMP24 29 -#define R_ARM_THM_JUMP24 30 -#define R_ARM_BASE_ABS 31 - -#define R_ARM_ALU_PCREL_7_0 32 -#define R_ARM_ALU_PCREL_15_8 33 -#define R_ARM_ALU_PCREL_23_15 34 -#define R_ARM_ALU_SBREL_11_0 35 -#define R_ARM_ALU_SBREL_19_12 36 -#define R_ARM_ALU_SBREL_27_20 37 -#define R_ARM_V4BX 40 -#define R_ARM_TARGET2 41 -#define R_ARM_PREL31 42 - -#define R_ARM_MOVW_ABS_NC 43 -#define R_ARM_MOVT_ABS 44 - -#define R_ARM_THM_MOVW_ABS_NC 47 -#define R_ARM_THM_MOVT_ABS 48 - -#define R_ARM_THM_JUMP19 51 - -/* 96-111 are reserved to G++. */ -#define R_ARM_GNU_VTENTRY 100 -#define R_ARM_GNU_VTINHERIT 101 -#define R_ARM_THM_JUMP11 102 -#define R_ARM_THM_JUMP8 103 - -/* More TLS relocations */ -#define R_ARM_TLS_GD32 104 /* PC-rel 32 bit for global dynamic */ -#define R_ARM_TLS_LDM32 105 /* PC-rel 32 bit for local dynamic */ -#define R_ARM_TLS_LDO32 106 /* 32 bit offset relative to TLS */ -#define R_ARM_TLS_IE32 107 /* PC-rel 32 bit for GOT entry of */ -#define R_ARM_TLS_LE32 108 -#define R_ARM_TLS_LDO12 109 -#define R_ARM_TLS_LE12 110 -#define R_ARM_TLS_IE12GP 111 - -/* 112-127 are reserved for private experiments. */ - -#define R_ARM_RXPC25 249 -#define R_ARM_RSBREL32 250 -#define R_ARM_THM_RPC22 251 -#define R_ARM_RREL32 252 -#define R_ARM_RABS32 253 -#define R_ARM_RPC24 254 -#define R_ARM_RBASE 255 - -#define R_TYPE(name) __CONCAT(R_ARM_,name) - -/* Processor specific program header flags */ -#define PF_ARM_SB 0x10000000 -#define PF_ARM_PI 0x20000000 -#define PF_ARM_ENTRY 0x80000000 - -/* Processor specific section header flags */ -#define SHF_ENTRYSECT 0x10000000 -#define SHF_COMDEF 0x80000000 - -/* Processor specific symbol types */ -#define STT_ARM_TFUNC STT_LOPROC diff --git a/cpukit/libdl/include/arch/bfin/machine/elf_machdep.h b/cpukit/libdl/include/arch/bfin/machine/elf_machdep.h deleted file mode 100644 index cf0dc19221..0000000000 --- a/cpukit/libdl/include/arch/bfin/machine/elf_machdep.h +++ /dev/null @@ -1,28 +0,0 @@ -#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB - -#define ELF32_MACHDEP_ID_CASES \ - case EM_BLACKFIN: \ - break; - -#define ELF32_MACHDEP_ID EM_BLACKFIN - -#define ARCH_ELFSIZE 32 - -#define R_BFIN_UNUSED0 0 - -#define R_BFIN_RIMM16 5 -#define R_BFIN_LUIMM16 6 -#define R_BFIN_HUIMM16 7 -#define R_BFIN_PCREL12_JUMP_S 8 -#define R_BFIN_PCREL24_JUMP_X 9 -#define R_BFIN_PCREL24 10 -#define R_BFIN_PCREL24_JU 13 -#define R_BFIN_PCREL24_CALL_X 14 - -#define R_BFIN_BYTE_DATA 16 -#define R_BFIN_BYTE2_DATA 17 -#define R_BFIN_BYTE4_DATA 18 - - - -#define R_TYPE(name) __CONCAT(R_BFIN_,name) diff --git a/cpukit/libdl/include/arch/h8300/machine/elf_machdep.h b/cpukit/libdl/include/arch/h8300/machine/elf_machdep.h deleted file mode 100644 index 3d049157eb..0000000000 --- a/cpukit/libdl/include/arch/h8300/machine/elf_machdep.h +++ /dev/null @@ -1,59 +0,0 @@ - -#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB - -#define ELF32_MACHDEP_ID_CASES \ - case EM_H8_300: \ - case EM_H8_300H: \ - case EM_H8S: \ - case EM_H8_500: \ - break; - -#define ELF32_MACHDEP_ID EM_H8_300 -#define ARCH_ELFSIZE 32 - -#define R_H8_NONE 0 -#define R_H8_DIR32 1 -#define R_H8_DIR32_28 2 -#define R_H8_DIR32_24 3 -#define R_H8_DIR32_16 4 -#define R_H8_DIR32U 6 -#define R_H8_DIR32U_28 7 -#define R_H8_DIR32U_24 8 -#define R_H8_DIR32U_20 9 -#define R_H8_DIR32U_16 10 -#define R_H8_DIR24 11 -#define R_H8_DIR24_20 12 -#define R_H8_DIR24_16 13 -#define R_H8_DIR24U 14 -#define R_H8_DIR24U_20 15 -#define R_H8_DIR24U_16 16 -#define R_H8_DIR16 17 -#define R_H8_DIR16U 18 -#define R_H8_DIR16S_32 19 -#define R_H8_DIR16S_28 20 -#define R_H8_DIR16S_24 21 -#define R_H8_DIR16S_20 22 -#define R_H8_DIR16S 23 -#define R_H8_DIR8 24 -#define R_H8_DIR8U 25 -#define R_H8_DIR8Z_32 26 -#define R_H8_DIR8Z_28 27 -#define R_H8_DIR8Z_24 28 -#define R_H8_DIR8Z_20 29 -#define R_H8_DIR8Z_16 30 -#define R_H8_PCREL16 31 -#define R_H8_PCREL8 32 -#define R_H8_BPOS 33 -#define R_H8_PCREL32 34 -#define R_H8_GOT32O 35 -#define R_H8_GOT16O 36 -#define R_H8_DIR16A8 59 -#define R_H8_DIR16R8 60 -#define R_H8_DIR24A8 61 -#define R_H8_DIR24R8 62 -#define R_H8_DIR32A16 63 -#define R_H8_ABS32 65 -#define R_H8_ABS32A16 127 - - -#define R_TYPE(name) __CONCAT(R_H8_,name) diff --git a/cpukit/libdl/include/arch/i386/machine/elf_machdep.h b/cpukit/libdl/include/arch/i386/machine/elf_machdep.h deleted file mode 100644 index 442c561a9c..0000000000 --- a/cpukit/libdl/include/arch/i386/machine/elf_machdep.h +++ /dev/null @@ -1,63 +0,0 @@ -/* $NetBSD: elf_machdep.h,v 1.10 2009/05/30 05:56:52 skrll Exp $ */ - -#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB -#define ELF32_MACHDEP_ID_CASES \ - case EM_386: \ - case EM_486: \ - break; - -#define ELF64_MACHDEP_ENDIANNESS XXX /* break compilation */ -#define ELF64_MACHDEP_ID_CASES \ - /* no 64-bit ELF machine types supported */ - -#define ELF32_MACHDEP_ID EM_386 - -#define ARCH_ELFSIZE 32 /* MD native binary size */ - -/* i386 relocations */ -#define R_386_NONE 0 -#define R_386_32 1 -#define R_386_PC32 2 -#define R_386_GOT32 3 -#define R_386_PLT32 4 -#define R_386_COPY 5 -#define R_386_GLOB_DAT 6 -#define R_386_JMP_SLOT 7 -#define R_386_RELATIVE 8 -#define R_386_GOTOFF 9 -#define R_386_GOTPC 10 - -/* TLS relocations */ -#define R_386_TLS_TPOFF 14 -#define R_386_TLS_IE 15 -#define R_386_TLS_GOTIE 16 -#define R_386_TLS_LE 17 -#define R_386_TLS_GD 18 -#define R_386_TLS_LDM 19 - -/* The following relocations are GNU extensions. */ -#define R_386_16 20 -#define R_386_PC16 21 -#define R_386_8 22 -#define R_386_PC8 23 - -/* More TLS relocations */ -#define R_386_TLS_GD_32 24 -#define R_386_TLS_GD_PUSH 25 -#define R_386_TLS_GD_CALL 26 -#define R_386_TLS_GD_POP 27 -#define R_386_TLS_LDM_32 28 -#define R_386_TLS_LDM_PUSH 29 -#define R_386_TLS_LDM_CALL 30 -#define R_386_TLS_LDM_POP 31 -#define R_386_TLS_LDO_32 32 -#define R_386_TLS_IE_32 33 -#define R_386_TLS_LE_32 34 -#define R_386_TLS_DTPMOD32 35 -#define R_386_TLS_DTPOFF32 36 -#define R_386_TLS_TPOFF32 37 -#define R_386_TLS_GOTDESC 39 -#define R_386_TLS_DESC_CALL 40 -#define R_386_TLS_DESC 41 - -#define R_TYPE(name) __CONCAT(R_386_,name) diff --git a/cpukit/libdl/include/arch/lm32/machine/elf_machdep.h b/cpukit/libdl/include/arch/lm32/machine/elf_machdep.h deleted file mode 100644 index 29c75b89db..0000000000 --- a/cpukit/libdl/include/arch/lm32/machine/elf_machdep.h +++ /dev/null @@ -1,34 +0,0 @@ -#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB - -#define ELF32_MACHDEP_ID_CASES \ - case EM_LATTICEMICO32: \ - break; - -#define ELF32_MACHDEP_ID EM_LATTICEMICO32 - -#define EF_MACH32_MACH 0x00000001 - -//#define EF_BLACKFIN - -#define ARCH_ELFSIZE 32 - -#define R_LM32_NONE 0 -#define R_LM32_8 1 -#define R_LM32_16 2 -#define R_LM32_32 3 -#define R_LM32_HI16 4 -#define R_LM32_LO16 5 -#define R_LM32_GPREL16 6 -#define R_LM32_CALL 7 -#define R_LM32_BRANCH 8 -#define R_LM32_GNU_VTINHERIT 9 -#define R_LM32_GNU_VTENTRY 10 -#define R_LM32_16_GOT 11 -#define R_LM32_GOTOFF_HI16 12 -#define R_LM32_GOTOFF_LO16 13 -#define R_LM32_COPY 14 -#define R_LM32_GLOT_DAT 15 -#define R_LM32_JMP_SLOT 16 -#define R_LM32_RELATIVE 17 - -#define R_TYPE(name) __CONCAT(R_LM32_,name) diff --git a/cpukit/libdl/include/arch/m68k/machine/elf_machdep.h b/cpukit/libdl/include/arch/m68k/machine/elf_machdep.h deleted file mode 100644 index 9a987c69b5..0000000000 --- a/cpukit/libdl/include/arch/m68k/machine/elf_machdep.h +++ /dev/null @@ -1,47 +0,0 @@ -/* $NetBSD: elf_machdep.h,v 1.7 2002/01/28 21:34:48 thorpej Exp $ */ - -#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB -#define ELF32_MACHDEP_ID_CASES \ - case EM_68K: \ - break; - -#define ELF64_MACHDEP_ENDIANNESS XXX /* break compilation */ -#define ELF64_MACHDEP_ID_CASES \ - /* no 64-bit ELF machine types supported */ - -#define ELF32_MACHDEP_ID EM_68K - -/* - * Machine-dependent ELF flags. These are defined by the GNU tools. - */ -#define EF_CPU32 0x00810000 -#define EF_M68000 0x01000000 - -#define ARCH_ELFSIZE 32 /* MD native binary size */ - -/* m68k relocation types */ -#define R_68K_NONE 0 -#define R_68K_32 1 -#define R_68K_16 2 -#define R_68K_8 3 -#define R_68K_PC32 4 -#define R_68K_PC16 5 -#define R_68K_PC8 6 -#define R_68K_GOT32 7 -#define R_68K_GOT16 8 -#define R_68K_GOT8 9 -#define R_68K_GOT32O 10 -#define R_68K_GOT16O 11 -#define R_68K_GOT8O 12 -#define R_68K_PLT32 13 -#define R_68K_PLT16 14 -#define R_68K_PLT8 15 -#define R_68K_PLT32O 16 -#define R_68K_PLT16O 17 -#define R_68K_PLT8O 18 -#define R_68K_COPY 19 -#define R_68K_GLOB_DAT 20 -#define R_68K_JMP_SLOT 21 -#define R_68K_RELATIVE 22 - -#define R_TYPE(name) __CONCAT(R_68K_,name) diff --git a/cpukit/libdl/include/arch/mips/machine/elf_machdep.h b/cpukit/libdl/include/arch/mips/machine/elf_machdep.h deleted file mode 100644 index 26700ce4ce..0000000000 --- a/cpukit/libdl/include/arch/mips/machine/elf_machdep.h +++ /dev/null @@ -1,199 +0,0 @@ -/* $NetBSD: elf_machdep.h,v 1.15 2011/03/15 07:39:22 matt Exp $ */ - -#ifndef _MIPS_ELF_MACHDEP_H_ -#define _MIPS_ELF_MACHDEP_H_ - -#ifdef _LP64 -#define ARCH_ELFSIZE 64 /* MD native binary size */ -#else -#define ARCH_ELFSIZE 32 /* MD native binary size */ -#endif - -#if ARCH_ELFSIZE == 32 -#define ELF32_MACHDEP_ID_CASES \ - case EM_MIPS: \ - break; - -#define ELF32_MACHDEP_ID EM_MIPS - -#elif ARCH_ELFSIZE == 64 -#define ELF64_MACHDEP_ID_CASES \ - case EM_MIPS: \ - break; - -#define ELF64_MACHDEP_ID EM_MIPS - -#endif - - -/* mips relocs. */ - -#define R_MIPS_NONE 0 -#define R_MIPS_16 1 -#define R_MIPS_32 2 -#define R_MIPS_REL32 3 -#define R_MIPS_REL R_MIPS_REL32 -#define R_MIPS_26 4 -#define R_MIPS_HI16 5 /* high 16 bits of symbol value */ -#define R_MIPS_LO16 6 /* low 16 bits of symbol value */ -#define R_MIPS_GPREL16 7 /* GP-relative reference */ -#define R_MIPS_LITERAL 8 /* Reference to literal section */ -#define R_MIPS_GOT16 9 /* Reference to global offset table */ -#define R_MIPS_GOT R_MIPS_GOT16 -#define R_MIPS_PC16 10 /* 16 bit PC relative reference */ -#define R_MIPS_CALL16 11 /* 16 bit call thru glbl offset tbl */ -#define R_MIPS_CALL R_MIPS_CALL16 -#define R_MIPS_GPREL32 12 - -/* 13, 14, 15 are not defined at this point. */ -#define R_MIPS_UNUSED1 13 -#define R_MIPS_UNUSED2 14 -#define R_MIPS_UNUSED3 15 - -/* - * The remaining relocs are apparently part of the 64-bit Irix ELF ABI. - */ -#define R_MIPS_SHIFT5 16 -#define R_MIPS_SHIFT6 17 - -#define R_MIPS_64 18 -#define R_MIPS_GOT_DISP 19 -#define R_MIPS_GOT_PAGE 20 -#define R_MIPS_GOT_OFST 21 -#define R_MIPS_GOT_HI16 22 -#define R_MIPS_GOT_LO16 23 -#define R_MIPS_SUB 24 -#define R_MIPS_INSERT_A 25 -#define R_MIPS_INSERT_B 26 -#define R_MIPS_DELETE 27 -#define R_MIPS_HIGHER 28 -#define R_MIPS_HIGHEST 29 -#define R_MIPS_CALL_HI16 30 -#define R_MIPS_CALL_LO16 31 -#define R_MIPS_SCN_DISP 32 -#define R_MIPS_REL16 33 -#define R_MIPS_ADD_IMMEDIATE 34 -#define R_MIPS_PJUMP 35 -#define R_MIPS_RELGOT 36 -#define R_MIPS_JALR 37 -/* TLS relocations */ - -#define R_MIPS_TLS_DTPMOD32 38 /* Module number 32 bit */ -#define R_MIPS_TLS_DTPREL32 39 /* Module-relative offset 32 bit */ -#define R_MIPS_TLS_DTPMOD64 40 /* Module number 64 bit */ -#define R_MIPS_TLS_DTPREL64 41 /* Module-relative offset 64 bit */ -#define R_MIPS_TLS_GD 42 /* 16 bit GOT offset for GD */ -#define R_MIPS_TLS_LDM 43 /* 16 bit GOT offset for LDM */ -#define R_MIPS_TLS_DTPREL_HI16 44 /* Module-relative offset, high 16 bits */ -#define R_MIPS_TLS_DTPREL_LO16 45 /* Module-relative offset, low 16 bits */ -#define R_MIPS_TLS_GOTTPREL 46 /* 16 bit GOT offset for IE */ -#define R_MIPS_TLS_TPREL32 47 /* TP-relative offset, 32 bit */ -#define R_MIPS_TLS_TPREL64 48 /* TP-relative offset, 64 bit */ -#define R_MIPS_TLS_TPREL_HI16 49 /* TP-relative offset, high 16 bits */ -#define R_MIPS_TLS_TPREL_LO16 50 /* TP-relative offset, low 16 bits */ - -#define R_MIPS_max 51 - -#define R_TYPE(name) __CONCAT(R_MIPS_,name) - -#define R_MIPS16_min 100 -#define R_MIPS16_26 100 -#define R_MIPS16_GPREL 101 -#define R_MIPS16_GOT16 102 -#define R_MIPS16_CALL16 103 -#define R_MIPS16_HI16 104 -#define R_MIPS16_LO16 105 -#define R_MIPS16_max 106 - - -/* mips dynamic tags */ - -#define DT_MIPS_RLD_VERSION 0x70000001 -#define DT_MIPS_TIME_STAMP 0x70000002 -#define DT_MIPS_ICHECKSUM 0x70000003 -#define DT_MIPS_IVERSION 0x70000004 -#define DT_MIPS_FLAGS 0x70000005 -#define DT_MIPS_BASE_ADDRESS 0x70000006 -#define DT_MIPS_CONFLICT 0x70000008 -#define DT_MIPS_LIBLIST 0x70000009 -#define DT_MIPS_CONFLICTNO 0x7000000b -#define DT_MIPS_LOCAL_GOTNO 0x7000000a /* number of local got ents */ -#define DT_MIPS_LIBLISTNO 0x70000010 -#define DT_MIPS_SYMTABNO 0x70000011 /* number of .dynsym entries */ -#define DT_MIPS_UNREFEXTNO 0x70000012 -#define DT_MIPS_GOTSYM 0x70000013 /* first dynamic sym in got */ -#define DT_MIPS_HIPAGENO 0x70000014 -#define DT_MIPS_RLD_MAP 0x70000016 /* address of loader map */ - -/* - * ELF Flags - */ -#define EF_MIPS_PIC 0x00000002 /* Contains PIC code */ -#define EF_MIPS_CPIC 0x00000004 /* STD PIC calling sequence */ -#define EF_MIPS_ABI2 0x00000020 /* N32 */ - -#define EF_MIPS_ARCH_ASE 0x0f000000 /* Architectural extensions */ -#define EF_MIPS_ARCH_MDMX 0x08000000 /* MDMX multimedia extension */ -#define EF_MIPS_ARCH_M16 0x04000000 /* MIPS-16 ISA extensions */ - -#define EF_MIPS_ARCH 0xf0000000 /* Architecture field */ -#define EF_MIPS_ARCH_1 0x00000000 /* -mips1 code */ -#define EF_MIPS_ARCH_2 0x10000000 /* -mips2 code */ -#define EF_MIPS_ARCH_3 0x20000000 /* -mips3 code */ -#define EF_MIPS_ARCH_4 0x30000000 /* -mips4 code */ -#define EF_MIPS_ARCH_5 0x40000000 /* -mips5 code */ -#define EF_MIPS_ARCH_32 0x50000000 /* -mips32 code */ -#define EF_MIPS_ARCH_64 0x60000000 /* -mips64 code */ -#define EF_MIPS_ARCH_32R2 0x70000000 /* -mips32r2 code */ -#define EF_MIPS_ARCH_64R2 0x80000000 /* -mips64r2 code */ - -#define EF_MIPS_ABI 0x0000f000 -#define EF_MIPS_ABI_O32 0x00001000 -#define EF_MIPS_ABI_O64 0x00002000 -#define EF_MIPS_ABI_EABI32 0x00003000 -#define EF_MIPS_ABI_EABI64 0x00004000 - -#if defined(__MIPSEB__) -#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB -#define ELF64_MACHDEP_ENDIANNESS ELFDATA2MSB -#elif defined(__MIPSEL__) -#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB -#define ELF64_MACHDEP_ENDIANNESS ELFDATA2LSB -#elif !defined(HAVE_NBTOOL_CONFIG_H) -#error neither __MIPSEL__ nor __MIPSEB__ are defined. -#endif - -#ifdef _KERNEL -#ifdef _KERNEL_OPT -#include "opt_compat_netbsd.h" -#endif -#ifdef COMPAT_16 -/* - * Up to 1.6, the ELF dynamic loader (ld.elf_so) was not relocatable. - * Tell the kernel ELF exec code not to try relocating the interpreter - * for dynamically-linked ELF binaries. - */ -#define ELF_INTERP_NON_RELOCATABLE -#endif /* COMPAT_16 */ - -/* - * We need to be able to include the ELF header so we can pick out the - * ABI being used. - */ -#ifdef ELFSIZE -#define ELF_MD_PROBE_FUNC ELFNAME2(mips_netbsd,probe) -#define ELF_MD_COREDUMP_SETUP ELFNAME2(coredump,setup) -#endif - -struct exec_package; - -int mips_netbsd_elf32_probe(struct lwp *, struct exec_package *, void *, char *, - vaddr_t *); -void coredump_elf32_setup(struct lwp *, void *); - -int mips_netbsd_elf64_probe(struct lwp *, struct exec_package *, void *, char *, - vaddr_t *); -void coredump_elf64_setup(struct lwp *, void *); -#endif /* _KERNEL */ - -#endif /* _MIPS_ELF_MACHDEP_H_ */ diff --git a/cpukit/libdl/include/arch/moxie/machine/elf_machdep.h b/cpukit/libdl/include/arch/moxie/machine/elf_machdep.h deleted file mode 100644 index 3f0df23cdc..0000000000 --- a/cpukit/libdl/include/arch/moxie/machine/elf_machdep.h +++ /dev/null @@ -1,15 +0,0 @@ -#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB - -#define ELF32_MACHDEP_ID_CASES \ - case EM_MOXIE: \ - break; - -#define ELF32_MACHDEP_ID EM_MOXIE - -#define ARCH_ELFSIZE 32 - -#define R_MOXIE_NONE 0 -#define R_MOXIE_32 1 -#define R_MOXIE_PCREL10 2 - -#define R_TYPE(name) __CONCAT(R_MOXIE_,name) diff --git a/cpukit/libdl/include/arch/nios2/machine/elf_machdep.h b/cpukit/libdl/include/arch/nios2/machine/elf_machdep.h deleted file mode 100644 index 3f3c108bf5..0000000000 --- a/cpukit/libdl/include/arch/nios2/machine/elf_machdep.h +++ /dev/null @@ -1,46 +0,0 @@ -/* $NetBSD: elf_machdep.h,v 1.7 2002/01/28 21:34:48 thorpej Exp $ */ - -#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB -#define ELF32_MACHDEP_ID_CASES \ - case EM_ALTERA_NIOS2: \ - break; - -#define ELF64_MACHDEP_ENDIANNESS XXX /* break compilation */ -#define ELF64_MACHDEP_ID_CASES \ - /* no 64-bit ELF machine types supported */ - -#define ELF32_MACHDEP_ID EM_ALTERA_NIOS2 - -/* - * Machine-dependent ELF flags. These are defined by the GNU tools. - */ -#define EF_NIOS2 0x00810000 - -#define ARCH_ELFSIZE 32 /* MD native binary size */ - -/* NIOS2 relocation types */ -#define R_NIOS2_NONE 0 -#define R_NIOS2_32 1 -#define R_NIOS2_16 2 -#define R_NIOS2_8 3 -#define R_NIOS2_PC32 4 -#define R_NIOS2_PC16 5 -#define R_NIOS2_PC8 6 -#define R_NIOS2_GOT32 7 -#define R_NIOS2_GOT16 8 -#define R_NIOS2_GOT8 9 -#define R_NIOS2_GOT32O 10 -#define R_NIOS2_GOT16O 11 -#define R_NIOS2_GOT8O 12 -#define R_NIOS2_PLT32 13 -#define R_NIOS2_PLT16 14 -#define R_NIOS2_PLT8 15 -#define R_NIOS2_PLT32O 16 -#define R_NIOS2_PLT16O 17 -#define R_NIOS2_PLT8O 18 -#define R_NIOS2_COPY 19 -#define R_NIOS2_GLOB_DAT 20 -#define R_NIOS2_JMP_SLOT 21 -#define R_NIOS2_RELATIVE 22 - -#define R_TYPE(name) __CONCAT(R_NIOS2_,name) diff --git a/cpukit/libdl/include/arch/powerpc/machine/elf_machdep.h b/cpukit/libdl/include/arch/powerpc/machine/elf_machdep.h deleted file mode 100644 index f0fdb3f33b..0000000000 --- a/cpukit/libdl/include/arch/powerpc/machine/elf_machdep.h +++ /dev/null @@ -1,105 +0,0 @@ -/* $NetBSD: elf_machdep.h,v 1.9 2011/01/15 10:00:07 matt Exp $ */ - -#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB -#define ELF32_MACHDEP_ID_CASES \ - case EM_PPC: \ - break; - -#define ELF64_MACHDEP_ENDIANNESS ELFDATA2MSB -#define ELF64_MACHDEP_ID_CASES \ - case EM_PPC64: \ - break; - -#define ELF32_MACHDEP_ID EM_PPC -#define ELF64_MACHDEP_ID EM_PPC64 - -#ifdef _LP64 -#define ARCH_ELFSIZE 64 /* MD native binary size */ -#else -#define ARCH_ELFSIZE 32 /* MD native binary size */ -#endif - -/* Specify the value of _GLOBAL_OFFSET_TABLE_ */ -#define DT_PPC_GOT DT_LOPROC - -#define R_PPC_NONE 0 -#define R_PPC_32 1 -#define R_PPC_24 2 -#define R_PPC_16 3 -#define R_PPC_16_LO 4 -#define R_PPC_16_HI 5 /* R_PPC_ADDIS */ -#define R_PPC_16_HA 6 -#define R_PPC_14 7 -#define R_PPC_14_TAKEN 8 -#define R_PPC_14_NTAKEN 9 -#define R_PPC_REL24 10 /* R_PPC_BRANCH */ -#define R_PPC_REL14 11 -#define R_PPC_REL14_TAKEN 12 -#define R_PPC_REL14_NTAKEN 13 -#define R_PPC_GOT16 14 -#define R_PPC_GOT16_LO 15 -#define R_PPC_GOT16_HI 16 -#define R_PPC_GOT16_HA 17 -#define R_PPC_PLT24 18 -#define R_PPC_COPY 19 -#define R_PPC_GLOB_DAT 20 -#define R_PPC_JMP_SLOT 21 -#define R_PPC_RELATIVE 22 -#define R_PPC_LOCAL24PC 23 -#define R_PPC_U32 24 -#define R_PPC_U16 25 -#define R_PPC_REL32 26 -#define R_PPC_PLT32 27 -#define R_PPC_PLTREL32 28 -#define R_PPC_PLT16_LO 29 -#define R_PPC_PLT16_HI 30 -#define R_PPC_PLT16_HA 31 -#define R_PPC_SDAREL16 32 -#define R_PPC_SECTOFF 33 -#define R_PPC_SECTOFF_LO 34 -#define R_PPC_SECTOFF_HI 35 -#define R_PPC_SECTOFF_HA 36 -#define R_PPC_ADDR30 37 - -/* TLS relocations */ -#define R_PPC_TLS 67 - -#define R_PPC_DTPMOD32 68 -#define R_PPC_TPREL16 69 -#define R_PPC_TPREL16_LO 70 -#define R_PPC_TPREL16_HI 71 -#define R_PPC_TPREL16_HA 72 -#define R_PPC_TPREL32 73 -#define R_PPC_DTPREL16 74 -#define R_PPC_DTPREL16_LO 75 -#define R_PPC_DTPREL16_HI 76 -#define R_PPC_DTPREL16_HA 77 -#define R_PPC_DTPREL32 78 - -#define R_PPC_GOT_TLSGD16 79 -#define R_PPC_GOT_TLSGD16_LO 80 -#define R_PPC_GOT_TLSGD16_HI 81 -#define R_PPC_GOT_TLSGD16_HA 82 -#define R_PPC_GOT_TLSLD16 83 -#define R_PPC_GOT_TLSLD16_LO 84 -#define R_PPC_GOT_TLSLD16_HI 85 -#define R_PPC_GOT_TLSLD16_HA 86 - -#define R_PPC_GOT_TPREL16 87 -#define R_PPC_GOT_TPREL16_LO 88 -#define R_PPC_GOT_TPREL16_HI 89 -#define R_PPC_GOT_TPREL16_HA 90 -#define R_PPC_GOT_DTPREL16 91 -#define R_PPC_GOT_DTPREL16_LO 92 -#define R_PPC_GOT_DTPREL16_HI 93 -#define R_PPC_GOT_DTPREL16_HA 94 -#define R_PPC_TLSGD 95 -#define R_PPC_TLSLD 96 - -/* Used for the secure-plt PIC code sequences */ -#define R_PPC_REL16 249 -#define R_PPC_REL16_LO 250 -#define R_PPC_REL16_HI 251 -#define R_PPC_REL16_HA 252 - -#define R_TYPE(name) __CONCAT(R_PPC_,name) diff --git a/cpukit/libdl/include/arch/sparc/machine/elf_machdep.h b/cpukit/libdl/include/arch/sparc/machine/elf_machdep.h deleted file mode 100644 index e8f2b630c2..0000000000 --- a/cpukit/libdl/include/arch/sparc/machine/elf_machdep.h +++ /dev/null @@ -1,92 +0,0 @@ -/* $NetBSD: elf_machdep.h,v 1.7 2009/05/30 05:56:53 skrll Exp $ */ - -#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB -#define ELF32_MACHDEP_ID_CASES \ - case EM_SPARC: \ - case EM_SPARC32PLUS: \ - break; - -#define ELF64_MACHDEP_ENDIANNESS ELFDATA2MSB -#define ELF64_MACHDEP_ID_CASES \ - case EM_SPARC32PLUS: \ - case EM_SPARCV9: \ - /* no 64-bit ELF machine types supported */ - -#define ELF32_MACHDEP_ID EM_SPARC /* XXX right? */ - -#define ARCH_ELFSIZE 32 /* MD native binary size */ - -#define R_SPARC_NONE 0 -#define R_SPARC_8 1 -#define R_SPARC_16 2 -#define R_SPARC_32 3 -#define R_SPARC_DISP8 4 -#define R_SPARC_DISP16 5 -#define R_SPARC_DISP32 6 -#define R_SPARC_WDISP30 7 -#define R_SPARC_WDISP22 8 -#define R_SPARC_HI22 9 -#define R_SPARC_22 10 -#define R_SPARC_13 11 -#define R_SPARC_LO10 12 -#define R_SPARC_GOT10 13 -#define R_SPARC_GOT13 14 -#define R_SPARC_GOT22 15 -#define R_SPARC_PC10 16 -#define R_SPARC_PC22 17 -#define R_SPARC_WPLT30 18 -#define R_SPARC_COPY 19 -#define R_SPARC_GLOB_DAT 20 -#define R_SPARC_JMP_SLOT 21 -#define R_SPARC_RELATIVE 22 -#define R_SPARC_UA32 23 -#define R_SPARC_PLT32 24 -#define R_SPARC_HIPLT22 25 -#define R_SPARC_LOPLT10 26 -#define R_SPARC_PCPLT32 27 -#define R_SPARC_PCPLT22 28 -#define R_SPARC_PCPLT10 29 -#define R_SPARC_10 30 -#define R_SPARC_11 31 -#define R_SPARC_64 32 -#define R_SPARC_OLO10 33 -#define R_SPARC_HH22 34 -#define R_SPARC_HM10 35 -#define R_SPARC_LM22 36 -#define R_SPARC_PC_HH22 37 -#define R_SPARC_PC_HM10 38 -#define R_SPARC_PC_LM22 39 -#define R_SPARC_WDISP16 40 -#define R_SPARC_WDISP19 41 -#define R_SPARC_GLOB_JMP 42 -#define R_SPARC_7 43 -#define R_SPARC_5 44 -#define R_SPARC_6 45 - -/* TLS relocations */ -#define R_SPARC_TLS_GD_HI22 56 -#define R_SPARC_TLS_GD_LO10 57 -#define R_SPARC_TLS_GD_ADD 58 -#define R_SPARC_TLS_GD_CALL 59 -#define R_SPARC_TLS_LDM_HI22 60 -#define R_SPARC_TLS_LDM_LO10 61 -#define R_SPARC_TLS_LDM_ADD 62 -#define R_SPARC_TLS_LDM_CALL 63 -#define R_SPARC_TLS_LDO_HIX22 64 -#define R_SPARC_TLS_LDO_LOX10 65 -#define R_SPARC_TLS_LDO_ADD 66 -#define R_SPARC_TLS_IE_HI22 67 -#define R_SPARC_TLS_IE_LO10 68 -#define R_SPARC_TLS_IE_LD 69 -#define R_SPARC_TLS_IE_LDX 70 -#define R_SPARC_TLS_IE_ADD 71 -#define R_SPARC_TLS_LE_HIX22 72 -#define R_SPARC_TLS_LE_LOX10 73 -#define R_SPARC_TLS_DTPMOD32 74 -#define R_SPARC_TLS_DTPMOD64 75 -#define R_SPARC_TLS_DTPOFF32 76 -#define R_SPARC_TLS_DTPOFF64 77 -#define R_SPARC_TLS_TPOFF32 78 -#define R_SPARC_TLS_TPOFF64 79 - -#define R_TYPE(name) __CONCAT(R_SPARC_,name) diff --git a/cpukit/libdl/include/arch/v850/machine/elf_machdep.h b/cpukit/libdl/include/arch/v850/machine/elf_machdep.h deleted file mode 100644 index b76d1491d6..0000000000 --- a/cpukit/libdl/include/arch/v850/machine/elf_machdep.h +++ /dev/null @@ -1,74 +0,0 @@ -#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB - -#define ELF32_MACHDEP_ID_CASES \ - case EM_V850: \ - break; - -#define ELF32_MACHDEP_ID EM_V850 - - - -#define EF_V850_ARCH 0xf0000000 -#define E_V850_ARCH 0x00000000 -#define E_V850E_ARCH 0x10000000 -#define E_V850E1_ARCH 0x20000000 -#define E_V850E2_ARCH 0x30000000 -#define E_V850E2V3_ARCH 0x40000000 - -#define ARCH_ELFSIZE 32 - - -#define R_V850_NONE 0 -#define R_V850_9_PCREL 1 -#define R_V850_22_PCREL 2 -#define R_V850_HI16_S 3 -#define R_V850_HI16 4 -#define R_V850_LO16 5 -#define R_V850_ABS32 6 -#define R_V850_16 7 -#define R_V850_8 8 -#define R_V850_SDA_16_16_OFFSET 9 -#define R_V850_SDA_15_16_OFFSET 10 -#define R_V850_ZDA_16_16_OFFSET 11 -#define R_V850_ZDA_15_16_OFFSET 12 -#define R_V850_TDA_6_8_OFFSET 13 -#define R_V850_TDA_7_8_OFFSET 14 -#define R_V850_TDA_7_7_OFFSET 15 -#define R_V850_TDA_16_16_OFFSET 16 -#define R_V850_TDA_4_5_OFFSET 17 -#define R_V850_TDA_4_4_OFFSET 18 -#define R_V850_SDA_16_16_SPLIT_OFFSET 19 -#define R_V850_ZDA_16_16_SPLIT_OFFSET 20 -#define R_V850_CALLT_6_7_OFFSET 21 -#define R_V850_CALLT_16_16_OFFSET 22 -#define R_V850_GNU_VTINHERIT 23 -#define R_V850_GNU_VTENTRY 24 -#define R_V850_LONGCALL 25 -#define R_V850_LONGJUMP 26 -#define R_V850_ALIGN 27 -#define R_V850_REL32 28 -#define R_V850_LO16_SPLIT_OFFSET 29 -#define R_V850_16_PCREL 30 -#define R_V850_17_PCREL 31 -#define R_V850_23 32 -#define R_V850_32_PCREL 33 -#define R_V850_32_ABS 34 -#define R_V850_16_SPLIT_OFFSET 35 -#define R_V850_16_S1 36 -#define R_V850_LO16_S1 37 -#define R_V850_CALLT_15_16_OFFSET 38 -#define R_V850_32_GOTPCREL 39 -#define R_V850_16_GOT 40 -#define R_V850_32_GOT 41 -#define R_V850_22_PLT 42 -#define R_V850_32_PLT 43 -#define R_V850_COPY 44 -#define R_V850_GLOB_DAT 45 -#define R_V850_JMP_SLOT 46 -#define R_V850_RELATIVE 47 -#define R_V850_16_GOTOFF 48 -#define R_V850_32_GOTOFF 49 -#define R_V850_CODE 50 -#define R_V850_DATA 51 - -#define R_TYPE(name) __CONCAT(R_V850_,name) diff --git a/cpukit/libdl/include/link.h b/cpukit/libdl/include/link.h deleted file mode 100644 index c93efd9e78..0000000000 --- a/cpukit/libdl/include/link.h +++ /dev/null @@ -1,45 +0,0 @@ -/* $NetBSD: link.h,v 1.13 2008/04/28 20:22:54 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _LINK_H_ -#define _LINK_H_ - -/* - * Pull in the correct definitions for our toolchain target. - */ -#ifdef __ELF__ -#include -#else -#include -#endif - -#endif /* _LINK_H_ */ diff --git a/cpukit/libdl/include/link_elf.h b/cpukit/libdl/include/link_elf.h deleted file mode 100644 index d2691b68b0..0000000000 --- a/cpukit/libdl/include/link_elf.h +++ /dev/null @@ -1,79 +0,0 @@ -/* $NetBSD: link_elf.h,v 1.8 2009/11/04 19:28:03 pooka Exp $ */ - -/* - * This only exists for GDB. - */ - -#ifndef _LINK_ELF_H_ -#define _LINK_ELF_H_ - -#include - -#include -#include -#include - -enum sections -{ - rap_text = 0, - rap_const = 1, - rap_ctor = 2, - rap_dtor = 3, - rap_data = 4, - rap_bss = 5, - rap_secs = 6 -}; - -/** - * Object details. - */ -typedef struct -{ - const char* name; /**< Section name. */ - uint32_t offset; /**< The offset in the elf file. */ - uint32_t size; /**< The size of the section. */ - uint32_t rap_id; /**< Which obj does this section belongs to. */ -}section_detail; - -/** - * link map structure will be used for GDB support. - */ -struct link_map { - const char* name; /**< Name of the obj. */ - uint32_t sec_num; /**< The count of section. */ - section_detail* sec_detail; /**< The section details. */ - uint32_t* sec_addr[rap_secs]; /**< The RAP section addr. */ - uint32_t rpathlen; /**< The length of the path. */ - char* rpath; /**< The path of object files. */ - struct link_map* l_next; /**< Linked list of mapped libs. */ - struct link_map* l_prev; -}; - -/** - * r_debug is used to manage the debug related structures. - */ -struct r_debug { - int r_version; /* not used */ - struct link_map *r_map; /* list of loaded images */ - enum { - RT_CONSISTENT, /* things are stable */ - RT_ADD, /* adding a shared library */ - RT_DELETE /* removing a shared library */ - } r_state; -}; - -/* - * stub function. It is empty. - */ -void _rtld_debug_state (void); - -/* - * add link map to the list. - */ -int _rtld_linkmap_add (rtems_rtl_obj_t* obj); - -/* - * Remove link map from the list. - */ -void _rtld_linkmap_delete (rtems_rtl_obj_t* obj); -#endif /* _LINK_ELF_H_ */ diff --git a/cpukit/libdl/include/sys/cdefs_elf.h b/cpukit/libdl/include/sys/cdefs_elf.h deleted file mode 100644 index 91903d6017..0000000000 --- a/cpukit/libdl/include/sys/cdefs_elf.h +++ /dev/null @@ -1,152 +0,0 @@ -/* $NetBSD: cdefs_elf.h,v 1.24 2005/07/16 17:53:36 christos Exp $ */ - -/* - * Copyright (c) 1995, 1996 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#ifndef _SYS_CDEFS_ELF_H_ -#define _SYS_CDEFS_ELF_H_ - -#ifdef __LEADING_UNDERSCORE -#define _C_LABEL(x) __CONCAT(_,x) -#define _C_LABEL_STRING(x) "_"x -#else -#define _C_LABEL(x) x -#define _C_LABEL_STRING(x) x -#endif - -#if __STDC__ -#define ___RENAME(x) __asm__(___STRING(_C_LABEL(x))) -#else -#ifdef __LEADING_UNDERSCORE -#define ___RENAME(x) ____RENAME(_/**/x) -#define ____RENAME(x) __asm__(___STRING(x)) -#else -#define ___RENAME(x) __asm__(___STRING(x)) -#endif -#endif - -#define __indr_reference(sym,alias) /* nada, since we do weak refs */ - -#if __STDC__ -#define __strong_alias(alias,sym) \ - __asm__(".global " _C_LABEL_STRING(#alias) "\n" \ - _C_LABEL_STRING(#alias) " = " _C_LABEL_STRING(#sym)); - -#define __weak_alias(alias,sym) \ - __asm__(".weak " _C_LABEL_STRING(#alias) "\n" \ - _C_LABEL_STRING(#alias) " = " _C_LABEL_STRING(#sym)); -#define __weak_extern(sym) \ - __asm__(".weak " _C_LABEL_STRING(#sym)); -#define __warn_references(sym,msg) \ - __asm__(".section .gnu.warning." #sym "\n\t.ascii \"" msg "\"\n\t.text"); - -#else /* !__STDC__ */ - -#ifdef __LEADING_UNDERSCORE -#define __weak_alias(alias,sym) ___weak_alias(_/**/alias,_/**/sym) -#define ___weak_alias(alias,sym) \ - __asm__(".weak alias\nalias = sym"); -#else -#define __weak_alias(alias,sym) \ - __asm__(".weak alias\nalias = sym"); -#endif -#ifdef __LEADING_UNDERSCORE -#define __weak_extern(sym) ___weak_extern(_/**/sym) -#define ___weak_extern(sym) \ - __asm__(".weak sym"); -#else -#define __weak_extern(sym) \ - __asm__(".weak sym"); -#endif -#define __warn_references(sym,msg) \ - __asm__(".section .gnu.warning.sym\n\t.ascii msg ; .text"); - -#endif /* !__STDC__ */ - -#if __STDC__ -#define __SECTIONSTRING(_sec, _str) \ - __asm__(".section " #_sec "\n\t.asciz \"" _str "\"\n\t.previous") -#else -#define __SECTIONSTRING(_sec, _str) \ - __asm__(".section _sec\n\t.asciz _str\n\t.previous") -#endif - -#define __IDSTRING(_n,_s) __SECTIONSTRING(.ident,_s) - -#define __RCSID(_s) __IDSTRING(rcsid,_s) -#define __SCCSID(_s) -#define __SCCSID2(_s) -#if 0 /* XXX userland __COPYRIGHTs have \ns in them */ -#define __COPYRIGHT(_s) __SECTIONSTRING(.copyright,_s) -#else -#define __COPYRIGHT(_s) \ - static const char copyright[] \ - __attribute__((__unused__,__section__(".copyright"))) = _s -#endif - -#define __KERNEL_RCSID(_n, _s) __RCSID(_s) -#define __KERNEL_SCCSID(_n, _s) -#if 0 /* XXX see above */ -#define __KERNEL_COPYRIGHT(_n, _s) __COPYRIGHT(_s) -#else -#define __KERNEL_COPYRIGHT(_n, _s) __SECTIONSTRING(.copyright, _s) -#endif - -#ifndef __lint__ -#define __link_set_make_entry(set, sym) \ - static void const * const __link_set_##set##_sym_##sym \ - __section("link_set_" #set) __used = &sym -#define __link_set_make_entry2(set, sym, n) \ - static void const * const __link_set_##set##_sym_##sym##_##n \ - __section("link_set_" #set) __used = &sym[n] -#else -#define __link_set_make_entry(set, sym) \ - extern void const * const __link_set_##set##_sym_##sym -#define __link_set_make_entry2(set, sym, n) \ - extern void const * const __link_set_##set##_sym_##sym##_##n -#endif /* __lint__ */ - -#define __link_set_add_text(set, sym) __link_set_make_entry(set, sym) -#define __link_set_add_rodata(set, sym) __link_set_make_entry(set, sym) -#define __link_set_add_data(set, sym) __link_set_make_entry(set, sym) -#define __link_set_add_bss(set, sym) __link_set_make_entry(set, sym) -#define __link_set_add_text2(set, sym, n) __link_set_make_entry2(set, sym, n) -#define __link_set_add_rodata2(set, sym, n) __link_set_make_entry2(set, sym, n) -#define __link_set_add_data2(set, sym, n) __link_set_make_entry2(set, sym, n) -#define __link_set_add_bss2(set, sym, n) __link_set_make_entry2(set, sym, n) - -#define __link_set_decl(set, ptype) \ - extern ptype * const __start_link_set_##set[]; \ - extern ptype * const __stop_link_set_##set[] \ - -#define __link_set_start(set) (__start_link_set_##set) -#define __link_set_end(set) (__stop_link_set_##set) - -#define __link_set_count(set) \ - (__link_set_end(set) - __link_set_start(set)) - -#endif /* !_SYS_CDEFS_ELF_H_ */ diff --git a/cpukit/libdl/include/sys/exec_elf.h b/cpukit/libdl/include/sys/exec_elf.h deleted file mode 100644 index 4242415f54..0000000000 --- a/cpukit/libdl/include/sys/exec_elf.h +++ /dev/null @@ -1,1101 +0,0 @@ -/* $NetBSD: exec_elf.h,v 1.102 2010/03/01 11:27:29 skrll Exp $ */ - -/*- - * Copyright (c) 1994 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_EXEC_ELF_H_ -#define _SYS_EXEC_ELF_H_ - -/* - * The current ELF ABI specification is available at: - * http://www.sco.com/developers/gabi/ - * - * Current header definitions are in: - * http://www.sco.com/developers/gabi/latest/ch4.eheader.html - */ - -#if defined(_KERNEL) || defined(_STANDALONE) -#include -#else -#include -#endif /* _KERNEL || _STANDALONE */ - -#if defined(ELFSIZE) -#define CONCAT(x,y) __CONCAT(x,y) -#define ELFNAME(x) CONCAT(elf,CONCAT(ELFSIZE,CONCAT(_,x))) -#define ELFNAME2(x,y) CONCAT(x,CONCAT(_elf,CONCAT(ELFSIZE,CONCAT(_,y)))) -#define ELFNAMEEND(x) CONCAT(x,CONCAT(_elf,ELFSIZE)) -#define ELFDEFNNAME(x) CONCAT(ELF,CONCAT(ELFSIZE,CONCAT(_,x))) -#endif - -#if HAVE_NBTOOL_CONFIG_H -#include -#else -#include -#endif - -typedef uint8_t Elf_Byte; - -typedef uint32_t Elf32_Addr; -#define ELF32_FSZ_ADDR 4 -typedef uint32_t Elf32_Off; -typedef int32_t Elf32_SOff; -#define ELF32_FSZ_OFF 4 -typedef int32_t Elf32_Sword; -#define ELF32_FSZ_SWORD 4 -typedef uint32_t Elf32_Word; -#define ELF32_FSZ_WORD 4 -typedef uint16_t Elf32_Half; -#define ELF32_FSZ_HALF 2 -typedef uint64_t Elf32_Lword; -#define ELF32_FSZ_LWORD 8 - -typedef uint64_t Elf64_Addr; -#define ELF64_FSZ_ADDR 8 -typedef uint64_t Elf64_Off; -typedef int64_t Elf64_SOff; -#define ELF64_FSZ_OFF 8 -typedef int32_t Elf64_Shalf; -#define ELF64_FSZ_SHALF 4 - -#ifndef ELF64_FSZ_SWORD -typedef int32_t Elf64_Sword; -#define ELF64_FSZ_SWORD 4 -#endif /* ELF64_FSZ_SWORD */ -#ifndef ELF64_FSZ_WORD -typedef uint32_t Elf64_Word; -#define ELF64_FSZ_WORD 4 -#endif /* ELF64_FSZ_WORD */ - -typedef int64_t Elf64_Sxword; -#define ELF64_FSZ_SXWORD 8 -typedef uint64_t Elf64_Xword; -#define ELF64_FSZ_XWORD 8 -typedef uint64_t Elf64_Lword; -#define ELF64_FSZ_LWORD 8 -typedef uint32_t Elf64_Half; -#define ELF64_FSZ_HALF 4 -typedef uint16_t Elf64_Quarter; -#define ELF64_FSZ_QUARTER 2 - -/* - * ELF Header - */ -#define ELF_NIDENT 16 - -typedef struct { - unsigned char e_ident[ELF_NIDENT]; /* Id bytes */ - Elf32_Half e_type; /* file type */ - Elf32_Half e_machine; /* machine type */ - Elf32_Word e_version; /* version number */ - Elf32_Addr e_entry; /* entry point */ - Elf32_Off e_phoff; /* Program hdr offset */ - Elf32_Off e_shoff; /* Section hdr offset */ - Elf32_Word e_flags; /* Processor flags */ - Elf32_Half e_ehsize; /* sizeof ehdr */ - Elf32_Half e_phentsize; /* Program header entry size */ - Elf32_Half e_phnum; /* Number of program headers */ - Elf32_Half e_shentsize; /* Section header entry size */ - Elf32_Half e_shnum; /* Number of section headers */ - Elf32_Half e_shstrndx; /* String table index */ -} Elf32_Ehdr; - -typedef struct { - unsigned char e_ident[ELF_NIDENT]; /* Id bytes */ - Elf64_Quarter e_type; /* file type */ - Elf64_Quarter e_machine; /* machine type */ - Elf64_Half e_version; /* version number */ - Elf64_Addr e_entry; /* entry point */ - Elf64_Off e_phoff; /* Program hdr offset */ - Elf64_Off e_shoff; /* Section hdr offset */ - Elf64_Half e_flags; /* Processor flags */ - Elf64_Quarter e_ehsize; /* sizeof ehdr */ - Elf64_Quarter e_phentsize; /* Program header entry size */ - Elf64_Quarter e_phnum; /* Number of program headers */ - Elf64_Quarter e_shentsize; /* Section header entry size */ - Elf64_Quarter e_shnum; /* Number of section headers */ - Elf64_Quarter e_shstrndx; /* String table index */ -} Elf64_Ehdr; - -/* e_ident offsets */ -#define EI_MAG0 0 /* '\177' */ -#define EI_MAG1 1 /* 'E' */ -#define EI_MAG2 2 /* 'L' */ -#define EI_MAG3 3 /* 'F' */ -#define EI_CLASS 4 /* File class */ -#define EI_DATA 5 /* Data encoding */ -#define EI_VERSION 6 /* File version */ -#define EI_OSABI 7 /* Operating system/ABI identification */ -#define EI_ABIVERSION 8 /* ABI version */ -#define EI_PAD 9 /* Start of padding bytes up to EI_NIDENT*/ -#define EI_NIDENT 16 /* First non-ident header byte */ - -/* e_ident[EI_MAG0,EI_MAG3] */ -#define ELFMAG0 0x7f -#define ELFMAG1 'E' -#define ELFMAG2 'L' -#define ELFMAG3 'F' -#define ELFMAG "\177ELF" -#define SELFMAG 4 - -/* e_ident[EI_CLASS] */ -#define ELFCLASSNONE 0 /* Invalid class */ -#define ELFCLASS32 1 /* 32-bit objects */ -#define ELFCLASS64 2 /* 64-bit objects */ -#define ELFCLASSNUM 3 - -/* e_ident[EI_DATA] */ -#define ELFDATANONE 0 /* Invalid data encoding */ -#define ELFDATA2LSB 1 /* 2's complement values, LSB first */ -#define ELFDATA2MSB 2 /* 2's complement values, MSB first */ - -/* e_ident[EI_VERSION] */ -#define EV_NONE 0 /* Invalid version */ -#define EV_CURRENT 1 /* Current version */ -#define EV_NUM 2 - -/* e_ident[EI_OSABI] */ -#define ELFOSABI_SYSV 0 /* UNIX System V ABI */ -#define ELFOSABI_HPUX 1 /* HP-UX operating system */ -#define ELFOSABI_NETBSD 2 /* NetBSD */ -#define ELFOSABI_LINUX 3 /* GNU/Linux */ -#define ELFOSABI_HURD 4 /* GNU/Hurd */ -#define ELFOSABI_86OPEN 5 /* 86Open */ -#define ELFOSABI_SOLARIS 6 /* Solaris */ -#define ELFOSABI_MONTEREY 7 /* Monterey */ -#define ELFOSABI_IRIX 8 /* IRIX */ -#define ELFOSABI_FREEBSD 9 /* FreeBSD */ -#define ELFOSABI_TRU64 10 /* TRU64 UNIX */ -#define ELFOSABI_MODESTO 11 /* Novell Modesto */ -#define ELFOSABI_OPENBSD 12 /* OpenBSD */ -#define ELFOSABI_OPENVMS 13 /* OpenVMS */ -#define ELFOSABI_NSK 14 /* HP Non-Stop Kernel */ -#define ELFOSABI_AROS 15 /* Amiga Research OS */ -/* Unofficial OSABIs follow */ -#define ELFOSABI_ARM 97 /* ARM */ -#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ - -#define ELFOSABI_NONE ELFOSABI_SYSV -#define ELFOSABI_AIX ELFOSABI_MONTEREY - -/* e_type */ -#define ET_NONE 0 /* No file type */ -#define ET_REL 1 /* Relocatable file */ -#define ET_EXEC 2 /* Executable file */ -#define ET_DYN 3 /* Shared object file */ -#define ET_CORE 4 /* Core file */ -#define ET_NUM 5 - -#define ET_LOOS 0xfe00 /* Operating system specific range */ -#define ET_HIOS 0xfeff -#define ET_LOPROC 0xff00 /* Processor-specific range */ -#define ET_HIPROC 0xffff - -/* e_machine */ -#define EM_NONE 0 /* No machine */ -#define EM_M32 1 /* AT&T WE 32100 */ -#define EM_SPARC 2 /* SPARC */ -#define EM_386 3 /* Intel 80386 */ -#define EM_68K 4 /* Motorola 68000 */ -#define EM_88K 5 /* Motorola 88000 */ -#define EM_486 6 /* Intel 80486 */ -#define EM_860 7 /* Intel 80860 */ -#define EM_MIPS 8 /* MIPS I Architecture */ -#define EM_S370 9 /* Amdahl UTS on System/370 */ -#define EM_MIPS_RS3_LE 10 /* MIPS RS3000 Little-endian */ - /* 11-14 - Reserved */ -#define EM_RS6000 11 /* IBM RS/6000 XXX reserved */ -#define EM_PARISC 15 /* Hewlett-Packard PA-RISC */ -#define EM_NCUBE 16 /* NCube XXX reserved */ -#define EM_VPP500 17 /* Fujitsu VPP500 */ -#define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */ -#define EM_960 19 /* Intel 80960 */ -#define EM_PPC 20 /* PowerPC */ -#define EM_PPC64 21 /* 64-bit PowerPC */ - /* 22-35 - Reserved */ -#define EM_S390 22 /* System/390 XXX reserved */ -#define EM_V800 36 /* NEC V800 */ -#define EM_FR20 37 /* Fujitsu FR20 */ -#define EM_RH32 38 /* TRW RH-32 */ -#define EM_RCE 39 /* Motorola RCE */ -#define EM_ARM 40 /* Advanced RISC Machines ARM */ -#define EM_ALPHA 41 /* DIGITAL Alpha */ -#define EM_SH 42 /* Hitachi Super-H */ -#define EM_SPARCV9 43 /* SPARC Version 9 */ -#define EM_TRICORE 44 /* Siemens Tricore */ -#define EM_ARC 45 /* Argonaut RISC Core */ -#define EM_H8_300 46 /* Hitachi H8/300 */ -#define EM_H8_300H 47 /* Hitachi H8/300H */ -#define EM_H8S 48 /* Hitachi H8S */ -#define EM_H8_500 49 /* Hitachi H8/500 */ -#define EM_IA_64 50 /* Intel Merced Processor */ -#define EM_MIPS_X 51 /* Stanford MIPS-X */ -#define EM_COLDFIRE 52 /* Motorola Coldfire */ -#define EM_68HC12 53 /* Motorola MC68HC12 */ -#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator */ -#define EM_PCP 55 /* Siemens PCP */ -#define EM_NCPU 56 /* Sony nCPU embedded RISC processor */ -#define EM_NDR1 57 /* Denso NDR1 microprocessor */ -#define EM_STARCORE 58 /* Motorola Star*Core processor */ -#define EM_ME16 59 /* Toyota ME16 processor */ -#define EM_ST100 60 /* STMicroelectronics ST100 processor */ -#define EM_TINYJ 61 /* Advanced Logic Corp. TinyJ embedded family processor */ -#define EM_X86_64 62 /* AMD x86-64 architecture */ -#define EM_PDSP 63 /* Sony DSP Processor */ -#define EM_PDP10 64 /* Digital Equipment Corp. PDP-10 */ -#define EM_PDP11 65 /* Digital Equipment Corp. PDP-11 */ -#define EM_FX66 66 /* Siemens FX66 microcontroller */ -#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 bit microcontroller */ -#define EM_ST7 68 /* STMicroelectronics ST7 8-bit microcontroller */ -#define EM_68HC16 69 /* Motorola MC68HC16 Microcontroller */ -#define EM_68HC11 70 /* Motorola MC68HC11 Microcontroller */ -#define EM_68HC08 71 /* Motorola MC68HC08 Microcontroller */ -#define EM_68HC05 72 /* Motorola MC68HC05 Microcontroller */ -#define EM_SVX 73 /* Silicon Graphics SVx */ -#define EM_ST19 74 /* STMicroelectronics ST19 8-bit CPU */ -#define EM_VAX 75 /* Digital VAX */ -#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */ -#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded CPU */ -#define EM_FIREPATH 78 /* Element 14 64-bit DSP processor */ -#define EM_ZSP 79 /* LSI Logic's 16-bit DSP processor */ -#define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */ -#define EM_HUANY 81 /* Harvard's machine-independent format */ -#define EM_PRISM 82 /* SiTera Prism */ -#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */ -#define EM_FR30 84 /* Fujitsu FR30 */ -#define EM_D10V 85 /* Mitsubishi D10V */ -#define EM_D30V 86 /* Mitsubishi D30V */ -#define EM_V850 87 /* NEC v850 */ -#define EM_M32R 88 /* Mitsubishi M32R */ -#define EM_MN10300 89 /* Matsushita MN10300 */ -#define EM_MN10200 90 /* Matsushita MN10200 */ -#define EM_PJ 91 /* picoJava */ -#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */ -#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */ -#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */ -#define EM_VIDEOCORE 95 /* Alphamosaic VideoCore processor */ -#define EM_TMM_GPP 96 /* Thompson Multimedia General Purpose Processor */ -#define EM_NS32K 97 /* National Semiconductor 32000 series */ -#define EM_TPC 98 /* Tenor Network TPC processor */ -#define EM_SNP1K 99 /* Trebia SNP 1000 processor */ -#define EM_ST200 100 /* STMicroelectronics ST200 microcontroller */ -#define EM_IP2K 101 /* Ubicom IP2xxx microcontroller family */ -#define EM_MAX 102 /* MAX processor */ -#define EM_CR 103 /* National Semiconductor CompactRISC micorprocessor */ -#define EM_F2MC16 104 /* Fujitsu F2MC16 */ -#define EM_MSP430 105 /* Texas Instruments MSP430 */ -#define EM_BLACKFIN 106 /* Analog Devices Blackfin DSP */ -#define EM_SE_C33 107 /* Seiko Epson S1C33 family */ -#define EM_SEP 108 /* Sharp embedded microprocessor */ -#define EM_ARCA 109 /* Arca RISC microprocessor */ -#define EM_UNICORE 110 /* UNICORE from PKU-Unity Ltd. and MPRC Peking University */ -#define EM_EXCESS 111 /* eXcess: 16/32/64-bit configurable embedded CPU */ -#define EM_DXP 112 /* Icera Semiconductor Inc. Deep Execution Processor */ -#define EM_ALTERA_NIOS2 113 /* Altera Nios II soft-core processor */ -#define EM_CRX 114 /* National Semiconductor CRX */ -#define EM_XGATE 115 /* Motorola XGATE embedded processor */ -#define EM_C166 116 /* Infineon C16x/XC16x processor */ -#define EM_M16C 117 /* Renesas M16C series microprocessors */ -#define EM_DSPIC30F 118 /* Microchip Technology dsPIC30F Digital Signal Controller */ -#define EM_CE 119 /* Freescale Communication Engine RISC core */ -#define EM_M32C 120 /* Renesas M32C series microprocessors */ - -#define EM_LATTICEMICO32 138 /* RICS processor for Lattice FPGA architecture */ - -#define EM_MICROBLAZE 189 /* Xilinx MicroBlaze 32-bit RISC soft processor core */ - -#define EM_MOXIE 0xFEED - -/* Unofficial machine types follow */ -#define EM_AVR32 6317 /* used by NetBSD/avr32 */ -#define EM_ALPHA_EXP 36902 /* used by NetBSD/alpha; obsolete */ -#define EM_NUM 36903 - -/* - * Program Header - */ -typedef struct { - Elf32_Word p_type; /* entry type */ - Elf32_Off p_offset; /* offset */ - Elf32_Addr p_vaddr; /* virtual address */ - Elf32_Addr p_paddr; /* physical address */ - Elf32_Word p_filesz; /* file size */ - Elf32_Word p_memsz; /* memory size */ - Elf32_Word p_flags; /* flags */ - Elf32_Word p_align; /* memory & file alignment */ -} Elf32_Phdr; - -typedef struct { - Elf64_Half p_type; /* entry type */ - Elf64_Half p_flags; /* flags */ - Elf64_Off p_offset; /* offset */ - Elf64_Addr p_vaddr; /* virtual address */ - Elf64_Addr p_paddr; /* physical address */ - Elf64_Xword p_filesz; /* file size */ - Elf64_Xword p_memsz; /* memory size */ - Elf64_Xword p_align; /* memory & file alignment */ -} Elf64_Phdr; - -/* p_type */ -#define PT_NULL 0 /* Program header table entry unused */ -#define PT_LOAD 1 /* Loadable program segment */ -#define PT_DYNAMIC 2 /* Dynamic linking information */ -#define PT_INTERP 3 /* Program interpreter */ -#define PT_NOTE 4 /* Auxiliary information */ -#define PT_SHLIB 5 /* Reserved, unspecified semantics */ -#define PT_PHDR 6 /* Entry for header table itself */ -#define PT_NUM 7 - -#define PT_LOOS 0x60000000 /* OS-specific range */ -#define PT_HIOS 0x6fffffff -#define PT_LOPROC 0x70000000 /* Processor-specific range */ -#define PT_HIPROC 0x7fffffff - -#define PT_MIPS_REGINFO 0x70000000 - -/* p_flags */ -#define PF_R 0x4 /* Segment is readable */ -#define PF_W 0x2 /* Segment is writable */ -#define PF_X 0x1 /* Segment is executable */ - -#define PF_MASKOS 0x0ff00000 /* Operating system specific values */ -#define PF_MASKPROC 0xf0000000 /* Processor-specific values */ - -/* Extended program header index. */ -#define PN_XNUM 0xffff - -/* - * Section Headers - */ -typedef struct { - Elf32_Word sh_name; /* section name (.shstrtab index) */ - Elf32_Word sh_type; /* section type */ - Elf32_Word sh_flags; /* section flags */ - Elf32_Addr sh_addr; /* virtual address */ - Elf32_Off sh_offset; /* file offset */ - Elf32_Word sh_size; /* section size */ - Elf32_Word sh_link; /* link to another */ - Elf32_Word sh_info; /* misc info */ - Elf32_Word sh_addralign; /* memory alignment */ - Elf32_Word sh_entsize; /* table entry size */ -} Elf32_Shdr; - -typedef struct { - Elf64_Half sh_name; /* section name (.shstrtab index) */ - Elf64_Half sh_type; /* section type */ - Elf64_Xword sh_flags; /* section flags */ - Elf64_Addr sh_addr; /* virtual address */ - Elf64_Off sh_offset; /* file offset */ - Elf64_Xword sh_size; /* section size */ - Elf64_Half sh_link; /* link to another */ - Elf64_Half sh_info; /* misc info */ - Elf64_Xword sh_addralign; /* memory alignment */ - Elf64_Xword sh_entsize; /* table entry size */ -} Elf64_Shdr; - -/* sh_type */ -#define SHT_NULL 0 /* Section header table entry unused */ -#define SHT_PROGBITS 1 /* Program information */ -#define SHT_SYMTAB 2 /* Symbol table */ -#define SHT_STRTAB 3 /* String table */ -#define SHT_RELA 4 /* Relocation information w/ addend */ -#define SHT_HASH 5 /* Symbol hash table */ -#define SHT_DYNAMIC 6 /* Dynamic linking information */ -#define SHT_NOTE 7 /* Auxiliary information */ -#define SHT_NOBITS 8 /* No space allocated in file image */ -#define SHT_REL 9 /* Relocation information w/o addend */ -#define SHT_SHLIB 10 /* Reserved, unspecified semantics */ -#define SHT_DYNSYM 11 /* Symbol table for dynamic linker */ -#define SHT_INIT_ARRAY 14 /* Initialization function pointers */ -#define SHT_FINI_ARRAY 15 /* Termination function pointers */ -#define SHT_PREINIT_ARRAY 16 /* Pre-initialization function ptrs */ -#define SHT_GROUP 17 /* Section group */ -#define SHT_SYMTAB_SHNDX 18 /* Section indexes (see SHN_XINDEX) */ -#define SHT_NUM 19 - -#define SHT_LOOS 0x60000000 /* Operating system specific range */ -#define SHT_SUNW_move 0x6ffffffa -#define SHT_SUNW_syminfo 0x6ffffffc -#define SHT_SUNW_verdef 0x6ffffffd /* Versions defined by file */ -#define SHT_GNU_verdef SHT_SUNW_verdef -#define SHT_SUNW_verneed 0x6ffffffe /* Versions needed by file */ -#define SHT_GNU_verneed SHT_SUNW_verneed -#define SHT_SUNW_versym 0x6fffffff /* Symbol versions */ -#define SHT_GNU_versym SHT_SUNW_versym -#define SHT_HIOS 0x6fffffff -#define SHT_LOPROC 0x70000000 /* Processor-specific range */ -#define SHT_AMD64_UNWIND 0x70000001 /* unwind information */ -#define SHT_HIPROC 0x7fffffff -#define SHT_LOUSER 0x80000000 /* Application-specific range */ -#define SHT_HIUSER 0xffffffff - -/* sh_flags */ -#define SHF_WRITE 0x1 /* Section contains writable data */ -#define SHF_ALLOC 0x2 /* Section occupies memory */ -#define SHF_EXECINSTR 0x4 /* Section contains executable insns */ -#define SHF_MERGE 0x10 /* Section contains data that can be merged */ -#define SHF_STRINGS 0x20 /* Section contains null-terminated strings */ -#define SHF_INFO_LINK 0x40 /* Section header's sh_info holds table index */ -#define SHF_LINK_ORDER 0x80 /* Section has special ordering requirements */ - -#define SHF_MASKOS 0x0f000000 /* Operating system specific values */ -#define SHF_MASKPROC 0xf0000000 /* Processor-specific values */ - -/* - * Symbol Table - */ -typedef struct { - Elf32_Word st_name; /* Symbol name (.strtab index) */ - Elf32_Word st_value; /* value of symbol */ - Elf32_Word st_size; /* size of symbol */ - Elf_Byte st_info; /* type / binding attrs */ - Elf_Byte st_other; /* unused */ - Elf32_Half st_shndx; /* section index of symbol */ -} Elf32_Sym; - -typedef struct { - Elf64_Half st_name; /* Symbol name (.strtab index) */ - Elf_Byte st_info; /* type / binding attrs */ - Elf_Byte st_other; /* unused */ - Elf64_Quarter st_shndx; /* section index of symbol */ - Elf64_Addr st_value; /* value of symbol */ - Elf64_Xword st_size; /* size of symbol */ -} Elf64_Sym; - -/* Symbol Table index of the undefined symbol */ -#define ELF_SYM_UNDEFINED 0 - -#define STN_UNDEF 0 /* undefined index */ - -/* st_info: Symbol Bindings */ -#define STB_LOCAL 0 /* local symbol */ -#define STB_GLOBAL 1 /* global symbol */ -#define STB_WEAK 2 /* weakly defined global symbol */ -#define STB_NUM 3 - -#define STB_LOOS 10 /* Operating system specific range */ -#define STB_HIOS 12 -#define STB_LOPROC 13 /* Processor-specific range */ -#define STB_HIPROC 15 - -/* st_info: Symbol Types */ -#define STT_NOTYPE 0 /* Type not specified */ -#define STT_OBJECT 1 /* Associated with a data object */ -#define STT_FUNC 2 /* Associated with a function */ -#define STT_SECTION 3 /* Associated with a section */ -#define STT_FILE 4 /* Associated with a file name */ -#define STT_COMMON 5 /* Uninitialised common block */ -#define STT_TLS 6 /* Thread local data object */ -#define STT_NUM 7 - -#define STT_LOOS 10 /* Operating system specific range */ -#define STT_HIOS 12 -#define STT_LOPROC 13 /* Processor-specific range */ -#define STT_HIPROC 15 - -/* st_other: Visibility Types */ -#define STV_DEFAULT 0 /* use binding type */ -#define STV_INTERNAL 1 /* not referenced from outside */ -#define STV_HIDDEN 2 /* not visible, may be used via ptr */ -#define STV_PROTECTED 3 /* visible, not preemptible */ -#define STV_EXPORTED 4 -#define STV_SINGLETON 5 -#define STV_ELIMINATE 6 - -/* st_info/st_other utility macros */ -#define ELF_ST_BIND(info) ((uint32_t)(info) >> 4) -#define ELF_ST_TYPE(info) ((uint32_t)(info) & 0xf) -#define ELF_ST_INFO(bind,type) ((Elf_Byte)(((bind) << 4) | \ - ((type) & 0xf))) -#define ELF_ST_VISIBILITY(other) ((uint32_t)(other) & 3) - -/* - * Special section indexes - */ -#define SHN_UNDEF 0 /* Undefined section */ - -#define SHN_LORESERVE 0xff00 /* Reserved range */ -#define SHN_ABS 0xfff1 /* Absolute symbols */ -#define SHN_COMMON 0xfff2 /* Common symbols */ -#define SHN_XINDEX 0xffff /* Escape -- index stored elsewhere */ -#define SHN_HIRESERVE 0xffff - -#define SHN_LOPROC 0xff00 /* Processor-specific range */ -#define SHN_HIPROC 0xff1f -#define SHN_LOOS 0xff20 /* Operating system specific range */ -#define SHN_HIOS 0xff3f - -#define SHN_MIPS_ACOMMON 0xff00 -#define SHN_MIPS_TEXT 0xff01 -#define SHN_MIPS_DATA 0xff02 -#define SHN_MIPS_SCOMMON 0xff03 - -/* - * Relocation Entries - */ -typedef struct { - Elf32_Word r_offset; /* where to do it */ - Elf32_Word r_info; /* index & type of relocation */ -} Elf32_Rel; - -typedef struct { - Elf32_Word r_offset; /* where to do it */ - Elf32_Word r_info; /* index & type of relocation */ - Elf32_Sword r_addend; /* adjustment value */ -} Elf32_Rela; - -/* r_info utility macros */ -#define ELF32_R_SYM(info) ((info) >> 8) -#define ELF32_R_TYPE(info) ((info) & 0xff) -#define ELF32_R_INFO(sym, type) (((sym) << 8) + (unsigned char)(type)) - -typedef struct { - Elf64_Addr r_offset; /* where to do it */ - Elf64_Xword r_info; /* index & type of relocation */ -} Elf64_Rel; - -typedef struct { - Elf64_Addr r_offset; /* where to do it */ - Elf64_Xword r_info; /* index & type of relocation */ - Elf64_Sxword r_addend; /* adjustment value */ -} Elf64_Rela; - -/* r_info utility macros */ -#define ELF64_R_SYM(info) ((info) >> 32) -#define ELF64_R_TYPE(info) ((info) & 0xffffffff) -#define ELF64_R_INFO(sym,type) (((sym) << 32) + (type)) - -/* - * Move entries - */ -typedef struct { - Elf32_Lword m_value; /* symbol value */ - Elf32_Word m_info; /* size + index */ - Elf32_Word m_poffset; /* symbol offset */ - Elf32_Half m_repeat; /* repeat count */ - Elf32_Half m_stride; /* stride info */ -} Elf32_Move; - -#define ELF32_M_SYM(info) ((info) >> 8) -#define ELF32_M_SIZE(info) (info) & 0xff) -#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char)(size)) - -typedef struct { - Elf64_Lword m_value; /* symbol value */ - Elf64_Xword m_info; /* size + index */ - Elf64_Xword m_poffset; /* symbol offset */ - Elf64_Half m_repeat; /* repeat count */ - Elf64_Half m_stride; /* stride info */ -} Elf64_Move; - -#define ELF64_M_SYM(info) ((info) >> 8) -#define ELF64_M_SIZE(info) (info) & 0xff) -#define ELF64_M_INFO(sym, size) (((sym) << 8) + (unsigned char)(size)) - -/* - * Hardware/software capabilities entry - */ -typedef struct { - Elf32_Word c_tag; /* entry tag value */ - union { - Elf32_Addr c_ptr; - Elf32_Word c_val; - } c_un; -} Elf32_Cap; - -typedef struct { - Elf64_Xword c_tag; /* entry tag value */ - union { - Elf64_Addr c_ptr; - Elf64_Xword c_val; - } c_un; -} Elf64_Cap; - -/* - * Dynamic Section structure array - */ -typedef struct { - Elf32_Word d_tag; /* entry tag value */ - union { - Elf32_Addr d_ptr; - Elf32_Word d_val; - } d_un; -} Elf32_Dyn; - -typedef struct { - Elf64_Xword d_tag; /* entry tag value */ - union { - Elf64_Addr d_ptr; - Elf64_Xword d_val; - } d_un; -} Elf64_Dyn; - -/* d_tag */ -#define DT_NULL 0 /* Marks end of dynamic array */ -#define DT_NEEDED 1 /* Name of needed library (DT_STRTAB offset) */ -#define DT_PLTRELSZ 2 /* Size, in bytes, of relocations in PLT */ -#define DT_PLTGOT 3 /* Address of PLT and/or GOT */ -#define DT_HASH 4 /* Address of symbol hash table */ -#define DT_STRTAB 5 /* Address of string table */ -#define DT_SYMTAB 6 /* Address of symbol table */ -#define DT_RELA 7 /* Address of Rela relocation table */ -#define DT_RELASZ 8 /* Size, in bytes, of DT_RELA table */ -#define DT_RELAENT 9 /* Size, in bytes, of one DT_RELA entry */ -#define DT_STRSZ 10 /* Size, in bytes, of DT_STRTAB table */ -#define DT_SYMENT 11 /* Size, in bytes, of one DT_SYMTAB entry */ -#define DT_INIT 12 /* Address of initialization function */ -#define DT_FINI 13 /* Address of termination function */ -#define DT_SONAME 14 /* Shared object name (DT_STRTAB offset) */ -#define DT_RPATH 15 /* Library search path (DT_STRTAB offset) */ -#define DT_SYMBOLIC 16 /* Start symbol search within local object */ -#define DT_REL 17 /* Address of Rel relocation table */ -#define DT_RELSZ 18 /* Size, in bytes, of DT_REL table */ -#define DT_RELENT 19 /* Size, in bytes, of one DT_REL entry */ -#define DT_PLTREL 20 /* Type of PLT relocation entries */ -#define DT_DEBUG 21 /* Used for debugging; unspecified */ -#define DT_TEXTREL 22 /* Relocations might modify non-writable seg */ -#define DT_JMPREL 23 /* Address of relocations associated with PLT */ -#define DT_BIND_NOW 24 /* Process all relocations at load-time */ -#define DT_INIT_ARRAY 25 /* Address of initialization function array */ -#define DT_FINI_ARRAY 26 /* Size, in bytes, of DT_INIT_ARRAY array */ -#define DT_INIT_ARRAYSZ 27 /* Address of termination function array */ -#define DT_FINI_ARRAYSZ 28 /* Size, in bytes, of DT_FINI_ARRAY array*/ -#define DT_NUM 29 - -#define DT_LOOS 0x60000000 /* Operating system specific range */ -#define DT_VERSYM 0x6ffffff0 /* Symbol versions */ -#define DT_FLAGS_1 0x6ffffffb /* ELF dynamic flags */ -#define DT_VERDEF 0x6ffffffc /* Versions defined by file */ -#define DT_VERDEFNUM 0x6ffffffd /* Number of versions defined by file */ -#define DT_VERNEED 0x6ffffffe /* Versions needed by file */ -#define DT_VERNEEDNUM 0x6fffffff /* Number of versions needed by file */ -#define DT_HIOS 0x6fffffff -#define DT_LOPROC 0x70000000 /* Processor-specific range */ -#define DT_HIPROC 0x7fffffff - -/* Flag values for DT_FLAGS_1 (incomplete) */ -#define DF_1_INITFIRST 0x00000020 /* Object's init/fini take priority */ - -/* - * Auxiliary Vectors - */ -typedef struct { - Elf32_Word a_type; /* 32-bit id */ - Elf32_Word a_v; /* 32-bit id */ -} Aux32Info; - -typedef struct { - Elf64_Half a_type; /* 32-bit id */ - Elf64_Xword a_v; /* 64-bit id */ -} Aux64Info; - -/* a_type */ -#define AT_NULL 0 /* Marks end of array */ -#define AT_IGNORE 1 /* No meaning, a_un is undefined */ -#define AT_EXECFD 2 /* Open file descriptor of object file */ -#define AT_PHDR 3 /* &phdr[0] */ -#define AT_PHENT 4 /* sizeof(phdr[0]) */ -#define AT_PHNUM 5 /* # phdr entries */ -#define AT_PAGESZ 6 /* PAGESIZE */ -#define AT_BASE 7 /* Interpreter base addr */ -#define AT_FLAGS 8 /* Processor flags */ -#define AT_ENTRY 9 /* Entry address of executable */ -#define AT_DCACHEBSIZE 10 /* Data cache block size */ -#define AT_ICACHEBSIZE 11 /* Instruction cache block size */ -#define AT_UCACHEBSIZE 12 /* Unified cache block size */ - - /* Vendor specific */ -#define AT_MIPS_NOTELF 10 /* XXX a_val != 0 -> MIPS XCOFF executable */ - -#define AT_EUID 2000 /* euid (solaris compatible numbers) */ -#define AT_RUID 2001 /* ruid (solaris compatible numbers) */ -#define AT_EGID 2002 /* egid (solaris compatible numbers) */ -#define AT_RGID 2003 /* rgid (solaris compatible numbers) */ - - /* Solaris kernel specific */ -#define AT_SUN_LDELF 2004 /* dynamic linker's ELF header */ -#define AT_SUN_LDSHDR 2005 /* dynamic linker's section header */ -#define AT_SUN_LDNAME 2006 /* dynamic linker's name */ -#define AT_SUN_LPGSIZE 2007 /* large pagesize */ - - /* Other information */ -#define AT_SUN_PLATFORM 2008 /* sysinfo(SI_PLATFORM) */ -#define AT_SUN_HWCAP 2009 /* process hardware capabilities */ -#define AT_SUN_IFLUSH 2010 /* do we need to flush the instruction cache? */ -#define AT_SUN_CPU 2011 /* CPU name */ - /* ibcs2 emulation band aid */ -#define AT_SUN_EMUL_ENTRY 2012 /* coff entry point */ -#define AT_SUN_EMUL_EXECFD 2013 /* coff file descriptor */ - /* Executable's fully resolved name */ -#define AT_SUN_EXECNAME 2014 - -/* - * Note Headers - */ -typedef struct { - Elf32_Word n_namesz; - Elf32_Word n_descsz; - Elf32_Word n_type; -} Elf32_Nhdr; - -typedef struct { - Elf64_Half n_namesz; - Elf64_Half n_descsz; - Elf64_Half n_type; -} Elf64_Nhdr; - -#define ELF_NOTE_TYPE_ABI_TAG 1 - -/* GNU-specific note name and description sizes */ -#define ELF_NOTE_ABI_NAMESZ 4 -#define ELF_NOTE_ABI_DESCSZ 16 -/* GNU-specific note name */ -#define ELF_NOTE_ABI_NAME "GNU\0" - -/* GNU-specific OS/version value stuff */ -#define ELF_NOTE_ABI_OS_LINUX 0 -#define ELF_NOTE_ABI_OS_HURD 1 -#define ELF_NOTE_ABI_OS_SOLARIS 2 - -/* NetBSD-specific note type: Emulation name. desc is emul name string. */ -#define ELF_NOTE_TYPE_NETBSD_TAG 1 -/* NetBSD-specific note name and description sizes */ -#define ELF_NOTE_NETBSD_NAMESZ 7 -#define ELF_NOTE_NETBSD_DESCSZ 4 -/* NetBSD-specific note name */ -#define ELF_NOTE_NETBSD_NAME "NetBSD\0\0" - -/* NetBSD-specific note type: Checksum. There should be 1 NOTE per PT_LOAD - section. desc is a tuple of (16),(16),. */ -#define ELF_NOTE_TYPE_CHECKSUM_TAG 2 -#define ELF_NOTE_CHECKSUM_CRC32 1 -#define ELF_NOTE_CHECKSUM_MD5 2 -#define ELF_NOTE_CHECKSUM_SHA1 3 -#define ELF_NOTE_CHECKSUM_SHA256 4 - -/* NetBSD-specific note type: PaX. There should be 1 NOTE per executable. - section. desc is a 32 bit bitmask */ -#define ELF_NOTE_TYPE_PAX_TAG 3 -#define ELF_NOTE_PAX_MPROTECT 0x01 /* Force enable Mprotect */ -#define ELF_NOTE_PAX_NOMPROTECT 0x02 /* Force disable Mprotect */ -#define ELF_NOTE_PAX_GUARD 0x04 /* Force enable Segvguard */ -#define ELF_NOTE_PAX_NOGUARD 0x08 /* Force disable Servguard */ -#define ELF_NOTE_PAX_ASLR 0x10 /* Force enable ASLR */ -#define ELF_NOTE_PAX_NOASLR 0x20 /* Force disable ASLR */ -#define ELF_NOTE_PAX_NAMESZ 4 -#define ELF_NOTE_PAX_NAME "PaX\0" -#define ELF_NOTE_PAX_DESCSZ 4 - -/* - * NetBSD-specific core file information. - * - * NetBSD ELF core files use notes to provide information about - * the process's state. The note name is "NetBSD-CORE" for - * information that is global to the process, and "NetBSD-CORE@nn", - * where "nn" is the lwpid of the LWP that the information belongs - * to (such as register state). - * - * We use the following note identifiers: - * - * ELF_NOTE_NETBSD_CORE_PROCINFO - * Note is a "netbsd_elfcore_procinfo" structure. - * - * We also use ptrace(2) request numbers (the ones that exist in - * machine-dependent space) to identify register info notes. The - * info in such notes is in the same format that ptrace(2) would - * export that information. - * - * Please try to keep the members of this structure nicely aligned, - * and if you add elements, add them to the end and bump the version. - */ - -#define ELF_NOTE_NETBSD_CORE_NAME "NetBSD-CORE" - -#define ELF_NOTE_NETBSD_CORE_PROCINFO 1 - -#define NETBSD_ELFCORE_PROCINFO_VERSION 1 - -struct netbsd_elfcore_procinfo { - /* Version 1 fields start here. */ - uint32_t cpi_version; /* netbsd_elfcore_procinfo version */ - uint32_t cpi_cpisize; /* sizeof(netbsd_elfcore_procinfo) */ - uint32_t cpi_signo; /* killing signal */ - uint32_t cpi_sigcode; /* signal code */ - uint32_t cpi_sigpend[4]; /* pending signals */ - uint32_t cpi_sigmask[4]; /* blocked signals */ - uint32_t cpi_sigignore[4];/* blocked signals */ - uint32_t cpi_sigcatch[4];/* blocked signals */ - int32_t cpi_pid; /* process ID */ - int32_t cpi_ppid; /* parent process ID */ - int32_t cpi_pgrp; /* process group ID */ - int32_t cpi_sid; /* session ID */ - uint32_t cpi_ruid; /* real user ID */ - uint32_t cpi_euid; /* effective user ID */ - uint32_t cpi_svuid; /* saved user ID */ - uint32_t cpi_rgid; /* real group ID */ - uint32_t cpi_egid; /* effective group ID */ - uint32_t cpi_svgid; /* saved group ID */ - uint32_t cpi_nlwps; /* number of LWPs */ - int8_t cpi_name[32]; /* copy of p->p_comm */ - /* Add version 2 fields below here. */ - int32_t cpi_siglwp; /* LWP target of killing signal */ -}; - -#if defined(ELFSIZE) && (ELFSIZE == 32) -#define Elf_Ehdr Elf32_Ehdr -#define Elf_Phdr Elf32_Phdr -#define Elf_Shdr Elf32_Shdr -#define Elf_Sym Elf32_Sym -#define Elf_Rel Elf32_Rel -#define Elf_Rela Elf32_Rela -#define Elf_Dyn Elf32_Dyn -#define Elf_Word Elf32_Word -#define Elf_Sword Elf32_Sword -#define Elf_Addr Elf32_Addr -#define Elf_Off Elf32_Off -#define Elf_SOff Elf32_SOff -#define Elf_Nhdr Elf32_Nhdr - -#define ELF_R_SYM ELF32_R_SYM -#define ELF_R_TYPE ELF32_R_TYPE -#define ELFCLASS ELFCLASS32 - -#define AuxInfo Aux32Info -#elif defined(ELFSIZE) && (ELFSIZE == 64) -#define Elf_Ehdr Elf64_Ehdr -#define Elf_Phdr Elf64_Phdr -#define Elf_Shdr Elf64_Shdr -#define Elf_Sym Elf64_Sym -#define Elf_Rel Elf64_Rel -#define Elf_Rela Elf64_Rela -#define Elf_Dyn Elf64_Dyn -#define Elf_Word Elf64_Word -#define Elf_Sword Elf64_Sword -#define Elf_Addr Elf64_Addr -#define Elf_Off Elf64_Off -#define Elf_SOff Elf64_SOff -#define Elf_Nhdr Elf64_Nhdr - -#define ELF_R_SYM ELF64_R_SYM -#define ELF_R_TYPE ELF64_R_TYPE -#define ELFCLASS ELFCLASS64 - -#define AuxInfo Aux64Info -#endif - -#define ELF32_ST_BIND(info) ELF_ST_BIND(info) -#define ELF32_ST_TYPE(info) ELF_ST_TYPE(info) -#define ELF32_ST_INFO(bind,type) ELF_ST_INFO(bind,type) -#define ELF32_ST_VISIBILITY(other) ELF_ST_VISIBILITY(other) - -#define ELF64_ST_BIND(info) ELF_ST_BIND(info) -#define ELF64_ST_TYPE(info) ELF_ST_TYPE(info) -#define ELF64_ST_INFO(bind,type) ELF_ST_INFO(bind,type) -#define ELF64_ST_VISIBILITY(other) ELF_ST_VISIBILITY(other) - -typedef struct { - Elf32_Half si_boundto; /* direct bindings - symbol bound to */ - Elf32_Half si_flags; /* per symbol flags */ -} Elf32_Syminfo; - -typedef struct { - Elf64_Half si_boundto; /* direct bindings - symbol bound to */ - Elf64_Half si_flags; /* per symbol flags */ -} Elf64_Syminfo; - -#define SYMINFO_FLG_DIRECT 0x0001 /* symbol ref has direct association - to object containing definition */ -#define SYMINFO_FLG_PASSTHRU 0x0002 /* ignored - see SYMINFO_FLG_FILTER */ -#define SYMINFO_FLG_COPY 0x0004 /* symbol is a copy-reloc */ -#define SYMINFO_FLG_LAZYLOAD 0x0008 /* object containing defn should be - lazily-loaded */ -#define SYMINFO_FLG_DIRECTBIND 0x0010 /* ref should be bound directly to - object containing definition */ -#define SYMINFO_FLG_NOEXTDIRECT 0x0020 /* don't let an external reference - directly bind to this symbol */ -#define SYMINFO_FLG_FILTER 0x0002 /* symbol ref is associated to a */ -#define SYMINFO_FLG_AUXILIARY 0x0040 /* standard or auxiliary filter */ - -#define SYMINFO_BT_SELF 0xffff /* symbol bound to self */ -#define SYMINFO_BT_PARENT 0xfffe /* symbol bound to parent */ -#define SYMINFO_BT_NONE 0xfffd /* no special symbol binding */ -#define SYMINFO_BT_EXTERN 0xfffc /* symbol defined as external */ -#define SYMINFO_BT_LOWRESERVE 0xff00 /* beginning of reserved entries */ - -#define SYMINFO_NONE 0 /* Syminfo version */ -#define SYMINFO_CURRENT 1 -#define SYMINFO_NUM 2 - -/* - * These constants are used for Elf32_Verdef struct's version number. - */ -#define VER_DEF_NONE 0 -#define VER_DEF_CURRENT 1 - -/* - * These constants are used for Elf32_Verdef struct's vd_flags. - */ -#define VER_FLG_BASE 0x1 -#define VER_FLG_WEAK 0x2 - -/* - * These are used in an Elf32_Versym field. - */ -#define VER_NDX_LOCAL 0 -#define VER_NDX_GLOBAL 1 - -/* - * These constants are used for Elf32_Verneed struct's version number. - */ -#define VER_NEED_NONE 0 -#define VER_NEED_CURRENT 1 - -/* - * GNU Extension hidding symb - */ -#define VERSYM_HIDDEN 0x8000 -#define VERSYM_VERSION 0x7fff - -#define ELF_VER_CHR '@' - -/* - * These are current size independent. - */ - -typedef struct { - Elf32_Half vd_version; /* version number of structure */ - Elf32_Half vd_flags; /* flags (VER_FLG_*) */ - Elf32_Half vd_ndx; /* version index */ - Elf32_Half vd_cnt; /* number of verdaux entries */ - Elf32_Word vd_hash; /* hash of name */ - Elf32_Word vd_aux; /* offset to verdaux entries */ - Elf32_Word vd_next; /* offset to next verdef */ -} Elf32_Verdef; -typedef Elf32_Verdef Elf64_Verdef; - -typedef struct { - Elf32_Word vda_name; /* string table offset of name */ - Elf32_Word vda_next; /* offset to verdaux */ -} Elf32_Verdaux; -typedef Elf32_Verdaux Elf64_Verdaux; - -typedef struct { - Elf32_Half vn_version; /* version number of structure */ - Elf32_Half vn_cnt; /* number of vernaux entries */ - Elf32_Word vn_file; /* string table offset of library name*/ - Elf32_Word vn_aux; /* offset to vernaux entries */ - Elf32_Word vn_next; /* offset to next verneed */ -} Elf32_Verneed; -typedef Elf32_Verneed Elf64_Verneed; - -typedef struct { - Elf32_Word vna_hash; /* Hash of dependency name */ - Elf32_Half vna_flags; /* flags (VER_FLG_*) */ - Elf32_Half vna_other; /* unused */ - Elf32_Word vna_name; /* string table offset to version name*/ - Elf32_Word vna_next; /* offset to next vernaux */ -} Elf32_Vernaux; -typedef Elf32_Vernaux Elf64_Vernaux; - -typedef struct { - Elf32_Half vs_vers; -} Elf32_Versym; -typedef Elf32_Versym Elf64_Versym; - -#ifdef _KERNEL - -#define ELF_AUX_ENTRIES 14 /* Max size of aux array passed to loader */ -#define ELF32_NO_ADDR (~(Elf32_Addr)0) /* Indicates addr. not yet filled in */ -#define ELF32_LINK_ADDR ((Elf32_Addr)-2) /* advises to use link address */ -#define ELF64_NO_ADDR (~(Elf64_Addr)0) /* Indicates addr. not yet filled in */ -#define ELF64_LINK_ADDR ((Elf64_Addr)-2) /* advises to use link address */ - -#if defined(ELFSIZE) && (ELFSIZE == 64) -#define ELF_NO_ADDR ELF64_NO_ADDR -#define ELF_LINK_ADDR ELF64_LINK_ADDR -#elif defined(ELFSIZE) && (ELFSIZE == 32) -#define ELF_NO_ADDR ELF32_NO_ADDR -#define ELF_LINK_ADDR ELF32_LINK_ADDR -#endif - -#ifndef ELF32_EHDR_FLAGS_OK -#define ELF32_EHDR_FLAGS_OK(eh) 1 -#endif - -#ifndef ELF64_EHDR_FLAGS_OK -#define ELF64_EHDR_FLAGS_OK(eh) 1 -#endif - -#if defined(ELFSIZE) && (ELFSIZE == 64) -#define ELF_EHDR_FLAGS_OK(eh) ELF64_EHDR_FLAGS_OK(eh) -#else -#define ELF_EHDR_FLAGS_OK(eh) ELF32_EHDR_FLAGS_OK(eh) -#endif - -#if defined(ELFSIZE) -struct elf_args { - Elf_Addr arg_entry; /* program entry point */ - Elf_Addr arg_interp; /* Interpreter load address */ - Elf_Addr arg_phaddr; /* program header address */ - Elf_Addr arg_phentsize; /* Size of program header */ - Elf_Addr arg_phnum; /* Number of program headers */ -}; -#endif - -#ifdef _KERNEL_OPT -#include "opt_execfmt.h" -#endif - -#ifdef EXEC_ELF32 -int exec_elf32_makecmds(struct lwp *, struct exec_package *); -int elf32_copyargs(struct lwp *, struct exec_package *, - struct ps_strings *, char **, void *); - -int coredump_elf32(struct lwp *, void *); -int coredump_writenote_elf32(struct proc *, void *, Elf32_Nhdr *, - const char *, void *); - -int elf32_check_header(Elf32_Ehdr *, int); -#endif - -#ifdef EXEC_ELF64 -int exec_elf64_makecmds(struct lwp *, struct exec_package *); -int elf64_copyargs(struct lwp *, struct exec_package *, - struct ps_strings *, char **, void *); - -int coredump_elf64(struct lwp *, void *); -int coredump_writenote_elf64(struct proc *, void *, Elf64_Nhdr *, - const char *, void *); - -int elf64_check_header(Elf64_Ehdr *, int); -#endif - -#endif /* _KERNEL */ - -#endif /* !_SYS_EXEC_ELF_H_ */ diff --git a/cpukit/libdl/preinstall.am b/cpukit/libdl/preinstall.am deleted file mode 100644 index dba6cc4d81..0000000000 --- a/cpukit/libdl/preinstall.am +++ /dev/null @@ -1,7 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - diff --git a/cpukit/libdl/rap-shell.h b/cpukit/libdl/rap-shell.h deleted file mode 100644 index c2d9112c0f..0000000000 --- a/cpukit/libdl/rap-shell.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * COPYRIGHT (c) 2013 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if !defined(_RAP_SHELL_H_) -#define _RAP_SHELL_H_ - -int shell_rap (int argc, char* argv[]); - -#endif diff --git a/cpukit/libdl/rap.h b/cpukit/libdl/rap.h deleted file mode 100644 index 0b86553e2b..0000000000 --- a/cpukit/libdl/rap.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * COPYRIGHT (c) 2013 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ -/** - * @file - * - * @ingroup rtems_rap - * - * @brief RTEMS Application Loader - * - * This is the RTEMS Application loader for files in the RAP format. - */ - -#if !defined (_RAP_H_) -#define _RAP_H_ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup rtems_rap RTEMS Application Loader - * - * The module implements an application loader for files in the RAP format. The - * RAP format is: - * - *
- * - * - * The compressed container is a stream of ELF relocatable object files. - * - * TBD. - */ - -/** - * The module iterator handle. - */ -typedef bool (*rtems_rap_iterator_t) (void* handle); - -/** - * Load an application. - * - * @param name The name of the application file. - * @return bool True if the module loads else an error. - */ -bool rtems_rap_load (const char* name, int mode, int argc, const char* argv[]); - -/** - * Unload an application. - * - * @param obj The application descriptor. - * @retval true The application file has been unloaded. - * @retval false The application could not be unloaded. - */ -bool rtems_rap_unload (const char* name); - -/** - * Find the application handle given a file name. - * - * @param name The name of the application file. It can be absolute or - * relative. Relative names can the basename with an extension. - * @retval NULL No application file with that name found. - * @return void* The application descriptor. - */ -void* rtems_rap_find (const char* name); - -/** - * Run an iterator over the modules calling the iterator function. - * - * @param iterator The iterator function. - * @retval true The iterator function returned did not return false. - * @retval false The iterator function returned false.. - */ -bool rtems_rap_iterate (rtems_rap_iterator_t iterator); - -/** - * Return the name of the module given a handle. - * - * @param handle The module handle. - * @return const char* The name of the module if the handle is valid else it - * is NULL. - */ -const char* rtems_rap_name (void* handle); - -/** - * Return the DL handle used to load the module given the RAP handle. - * - * @param handle The module handle. - * @return void* The DL handle returned by the dlopen call. - */ -void* rtems_rap_dl_handle (void* handle); - -/** - * Get the last error message clearing it. This call is not thread safe is - * multiple threads are loading object files at the same time. This call - * follows the model provided by the dlopen family of calls. - * - * @param message Pointer to a buffer to copy the message into. - * @param max_message The maximum message that can be copied. - * @return int The last error number. - */ -int rtems_rap_get_error (char* message, size_t max_message); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/cpukit/libdl/rtl-allocator.h b/cpukit/libdl/rtl-allocator.h deleted file mode 100644 index e8044ee1e8..0000000000 --- a/cpukit/libdl/rtl-allocator.h +++ /dev/null @@ -1,181 +0,0 @@ -/* - * COPYRIGHT (c) 2012 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ -/** - * @file - * - * @ingroup rtems_rtl - * - * @brief RTEMS Run-Time Linker Allocator - */ - -#if !defined (_RTEMS_RTL_ALLOCATOR_H_) -#define _RTEMS_RTL_ALLOCATOR_H_ - -#include - -#include "rtl-indirect-ptr.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * Define the types of allocation the loader requires. - * - * @note It is best to use the object tag for general memory allocation and to - * leave the tags with specific access properties to the module data - */ -enum rtems_rtl_alloc_tags_e { - RTEMS_RTL_ALLOC_OBJECT, /**< A generic memory object. */ - RTEMS_RTL_ALLOC_SYMBOL, /**< Memory used for symbols. */ - RTEMS_RTL_ALLOC_EXTERNAL, /**< Memory used for external symbols. */ - RTEMS_RTL_ALLOC_READ, /**< The memory is read only. */ - RTEMS_RTL_ALLOC_READ_WRITE, /**< The memory is read and write. */ - RTEMS_RTL_ALLOC_READ_EXEC /**< The memory is read and executable. */ -}; - -/** - * The allocator tag type. - */ -typedef enum rtems_rtl_alloc_tags_e rtems_rtl_alloc_tag_t; - -/** - * The number of tags. - */ -#define RTEMS_RTL_ALLOC_TAGS ((size_t) (RTEMS_RTL_ALLOC_READ_EXEC + 1)) - -/** - * Allocator handler handles all RTL allocations. It can be hooked and - * overridded for customised allocation schemes or memory maps. - * - * @param allocation If true the request is to allocate memory else free. - * @param tag The type of allocation request. - * @param address Pointer to the memory address. If an allocation the value is - * unspecific on entry and the allocated address or NULL on - * exit. The NULL value means the allocation failed. If a delete - * or free request the memory address is the block to free. A - * free request of NULL is silently ignored. - * @param size The size of the allocation if an allocation request and - * not used if deleting or freeing a previous allocation. - */ -typedef void (*rtems_rtl_allocator_t)(bool allocate, - rtems_rtl_alloc_tag_t tag, - void** address, - size_t size); - -/** - * The allocator data. - */ -struct rtems_rtl_alloc_data_s { - /**< The memory allocator handler. */ - rtems_rtl_allocator_t allocator; - /**< The indirect pointer chains. */ - rtems_chain_control indirects[RTEMS_RTL_ALLOC_TAGS]; -}; - -typedef struct rtems_rtl_alloc_data_s rtems_rtl_alloc_data_t; - -/** - * Initialise the allocate data. - * - * @param data The data to initialise. - */ -void rtems_rtl_alloc_initialise (rtems_rtl_alloc_data_t* data); - -/** - * The Runtime Loader allocator new allocates new memory and optionally clear - * the memory if requested. - * - * @param tag The type of allocation request. - * @param size The size of the allocation. - * @param zero If true the memory is cleared. - * @return void* The memory address or NULL is not memory available. - */ -void* rtems_rtl_alloc_new (rtems_rtl_alloc_tag_t tag, size_t size, bool zero); - -/** - * The Runtime Loader allocator delete deletes allocated memory. - * - * @param tag The type of allocation request. - * @param address The memory address to delete. A NULL is ignored. - */ -void rtems_rtl_alloc_del (rtems_rtl_alloc_tag_t tag, void* address); - -/** - * Hook the Runtime Loader allocatior. A handler can call the previous handler - * in the chain to use it for specific tags. The default handler uses the - * system heap. Do not unhook your handler if memory it allocates has not been - * returned. - * - * @param handler The handler to use as the allocator. - * @return rtems_rtl_alloc_handler_t The previous handler. - */ -rtems_rtl_allocator_t rtems_rtl_alloc_hook (rtems_rtl_allocator_t handler); - -/** - * Allocate memory to an indirect handle. - * - * @param tag The type of allocation request. - * @param handle The handle to allocate the memory to. - * @param size The size of the allocation. - */ -void rtems_rtl_alloc_indirect_new (rtems_rtl_alloc_tag_t tag, - rtems_rtl_ptr_t* handle, - size_t size); - -/** - * Free memory from an indirect handle. - * - * @param tag The type of allocation request. - * @param handle The handle to free the memory from. - */ -void rtems_rtl_alloc_indirect_del (rtems_rtl_alloc_tag_t tag, - rtems_rtl_ptr_t* handle); - -/** - * Allocate the memory for a module given the size of the text, const, data and - * bss sections. If any part of the allocation fails the no memory is - * allocated. - * - * @param text_base Pointer to the text base pointer. - * @param text_size The size of the read/exec section. - * @param const_base Pointer to the const base pointer. - * @param const_size The size of the read only section. - * @param eh_base Pointer to the eh base pointer. - * @param eh_size The size of the eh section. - * @param data_base Pointer to the data base pointer. - * @param data_size The size of the read/write secton. - * @param bss_base Pointer to the bss base pointer. - * @param bss_size The size of the read/write. - * @retval true The memory has been allocated. - * @retval false The allocation of memory has failed. - */ -bool rtems_rtl_alloc_module_new (void** text_base, size_t text_size, - void** const_base, size_t const_size, - void** eh_base, size_t eh_size, - void** data_base, size_t data_size, - void** bss_base, size_t bss_size); - -/** - * Free the memory allocated to a module. - * - * @param text_base Pointer to the text base pointer. - * @param const_base Pointer to the const base pointer. - * @param eh_base Pointer to the eh base pointer. - * @param data_base Pointer to the data base pointer. - * @param bss_base Pointer to the bss base pointer. - */ -void rtems_rtl_alloc_module_del (void** text_base, void** const_base, - void** eh_base, void** data_base, - void** bss_base); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/cpukit/libdl/rtl-fwd.h b/cpukit/libdl/rtl-fwd.h deleted file mode 100644 index 4641ad5d5e..0000000000 --- a/cpukit/libdl/rtl-fwd.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * COPYRIGHT (c) 2012 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ -/** - * @file - * - * @ingroup rtems_rtl - * - * @brief RTEMS Run-Time Linker ELF Headers - */ - -#if !defined (_RTEMS_RTL_FWD_H_) -#define _RTEMS_RTL_FWD_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * The forward declaration of the obj structure. - */ -struct rtems_rtl_data_s; -typedef struct rtems_rtl_data_s rtems_rtl_data_t; - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/cpukit/libdl/rtl-indirect-ptr.h b/cpukit/libdl/rtl-indirect-ptr.h deleted file mode 100644 index 81503a3b45..0000000000 --- a/cpukit/libdl/rtl-indirect-ptr.h +++ /dev/null @@ -1,235 +0,0 @@ -/* - * COPYRIGHT (c) 2012 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ -/** - * @file - * - * @ingroup rtems_rtl - * - * @brief RTEMS Run-Time Linker Indirect Pointer Management allows memory - * compaction in the allocator. - */ - -#if !defined (_RTEMS_RTL_INDIRECT_PTR_H_) -#define _RTEMS_RTL_INDIRECT_PTR_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include - -/** - * The RTL Indirect pointer. - */ -struct rtems_rtl_ptr_s { - rtems_chain_node node; /**< Indirect pointers are held on lists. */ - void* pointer; /**< The actual pointer. */ -}; - -typedef struct rtems_rtl_ptr_s rtems_rtl_ptr_t; - -/** - * The RTL Indirect size and pointer. - */ -struct rtems_rtl_sptr_s { - rtems_rtl_ptr_t ptr; /**< The indirect pointer. */ - size_t size; /**< The size of the memory block. */ -}; - -typedef struct rtems_rtl_sptr_s rtems_rtl_sptr_t; - -/** - * A chain of indirect pointers for users to chain in applications. - * - * @note The chain the pointer is on is internal to the allocator and cannot be - * used by applications. - */ -struct rtems_rtl_ptr_chain_s { - rtems_chain_node node; /**< Chain of indirect pointers. */ - rtems_rtl_ptr_t ptr; /**< The indirect pointer. */ -}; - -typedef struct rtems_rtl_ptr_chain_s rtems_rtl_ptr_chain_t; - -/** - * A chain of indirect sized pointers for users to chain in applications. - * - * @note The chain the pointer is on is internal to the allocator and cannot be - * used by applications. - */ -struct rtems_rtl_sptr_chain_s { - rtems_chain_node node; /**< Chain of indirect pointers. */ - rtems_rtl_sptr_t ptr; /**< The indirect pointer. */ -}; - -typedef struct rtems_rtl_sptr_chain_s rtems_rtl_sptr_chain_t; - -/** - * Get the pointer given an indirect handle. - * - * @param handle The handle the pointer is returned from. - * @return void* The pointer held in the handle. - */ -static inline void* rtems_rtl_ptr_get (rtems_rtl_ptr_t* handle) -{ - return handle->pointer; -} - -/** - * Set the pointer given an indirect handle and the pointer. - * - * @param handle The handle the pointer is returned from. - * @param pointer The pointer to set in the handle. - */ -static inline void rtems_rtl_ptr_set (rtems_rtl_ptr_t* handle, void* pointer) -{ - handle->pointer = pointer; -} - -/** - * Initialise the indirect handle. - * - * @param handle The handle to initialise. - */ -static inline void rtems_rtl_ptr_init (rtems_rtl_ptr_t* handle) -{ - rtems_chain_set_off_chain (&handle->node); - handle->pointer = NULL; -} - -/** - * Is the indirect handle NULL ? - * - * @param handle The handle to test. - * @return bool True if the pointer is NULL. - */ -static inline bool rtems_rtl_ptr_null (rtems_rtl_ptr_t* handle) -{ - return handle->pointer == NULL; -} - -/** - * Move the allocated pointer from one handle to another. The source handle is - * cleared and removed from the list of handles. - * - * @param src The source handle to move the pointer from. - * @param dst The destination handle to receive the pointer. - */ -static inline void rtems_rtl_ptr_move (rtems_rtl_ptr_t* dst, rtems_rtl_ptr_t* src) -{ - /* - * We do not know which chain the src handle resides on so insert the dst - * handle after the src handle then extract the src handle. - */ - rtems_chain_insert_unprotected (&src->node, &dst->node); - rtems_chain_extract_unprotected (&src->node); - dst->pointer = src->pointer; - rtems_rtl_ptr_init (src); -} - -/** - * Return the pointer as the type provided. - * - * @param _h The handle. - * @param _t The type. - */ -#define rtems_rtl_ptr_type_get(_h, _t) ((_t*) rtems_rtl_ptr_get (_h)) - -/** - * Get the pointer given an indirect handle. - * - * @param handle The handle the pointer is returned from. - * @return void* The pointer held in the handle. - */ -static inline void* rtems_rtl_sptr_get (rtems_rtl_sptr_t* handle) -{ - return rtems_rtl_ptr_get (&handle->ptr); -} - -/** - * Set the pointer given an indirect handle and the pointer. - * - * @param handle The handle the pointer is returned from. - * @param pointer The pointer to set in the handle. - */ -static inline void rtems_rtl_sptr_set (rtems_rtl_sptr_t* handle, void* pointer) -{ - rtems_rtl_ptr_set (&handle->ptr, pointer); -} - -/** - * Initialise the indirect handle. - * - * @param handle The handle to initialise. - */ -static inline void rtems_rtl_sptr_init (rtems_rtl_sptr_t* handle) -{ - rtems_rtl_ptr_init (&handle->ptr); - handle->size = 0; -} - -/** - * Is the indirect handle NULL ? - * - * @param handle The handle to test. - * @return bool True if the pointer is NULL. - */ -static inline bool rtems_rtl_sptr_null (rtems_rtl_sptr_t* handle) -{ - return rtems_rtl_ptr_null (&handle->ptr); -} - -/** - * Move the allocated pointer from one handle to another. The source handle is - * cleared and removed from the list of handles. - * - * @param src The source handle to move the pointer from. - * @param dst The destination handle to receive the pointer. - */ -static inline void rtems_rtl_sptr_move (rtems_rtl_sptr_t* dst, rtems_rtl_sptr_t* src) -{ - rtems_rtl_ptr_move (&dst->ptr, &src->ptr); - dst->size = src->size; - src->size = 0; -} - -/** - * Get the size. - * - * @param handle The handle to get the size from. - * @return size_t The size_t. - */ -static inline size_t rtems_rtl_sptr_get_size (rtems_rtl_sptr_t* handle) -{ - return handle->size; -} - -/** - * Set the size. - * - * @param handle The handle to set the size. - * @param size The size to set.. - */ -static inline void rtems_rtl_sptr_set_size (rtems_rtl_sptr_t* handle, size_t size) -{ - handle->size = size; -} - -/** - * Return the pointer as the type provided. - * - * @param _h The handle. - * @param _t The type. - */ -#define rtems_rtl_sptr_type_get(_h, _t) ((_t*) rtems_rtl_sptr_get (_h)) - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/cpukit/libdl/rtl-obj-cache.h b/cpukit/libdl/rtl-obj-cache.h deleted file mode 100644 index 8eacdd316b..0000000000 --- a/cpukit/libdl/rtl-obj-cache.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * COPYRIGHT (c) 2012 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ -/** - * @file - * - * @ingroup rtems_rtl - * - * @brief RTEMS Run-Time Linker Object File cache buffers a section of the - * object file in a buffer to localise read performance. - * - * This is a simple object file cache that holds a buffer of data from the - * offset in the file the read is requested from. Writes are not supported. - * - * The cache holds the file descriptor, the offset into the file and the amount - * of valid data in the cache. If the file is ever modified the user of the - * cache to responsible for flushing the cache. For example the cache should be - * flused if the file is closed. - * - * The cache can return by reference or by value. By reference allow access to - * the cache buffer. Do not modify the cache's data. By value will copy the - * requested data into the user supplied buffer. - * - * The read by reference call allows you to probe the file's data. For example - * a string in an object file can be an unknown length. You can request a read - * up to the cache's size by reference. The code will attempt to have this data - * in the buffer. If there is not enough data in the file the length will be - * modifed to reflect this. - * - * You can have more than one cache for a single file all looking at different - * parts of the file. - */ - -#if !defined (_RTEMS_RTL_OBJ_CACHE_H_) -#define _RTEMS_RTL_OBJ_CACHE_H_ - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * The buffer cache. - */ -typedef struct rtems_rtl_obj_cache_s -{ - int fd; /**< The file descriptor of the data in the cache. */ - size_t file_size; /**< The size of the file. */ - off_t offset; /**< The base offset of the buffer. */ - size_t size; /**< The size of the cache. */ - size_t level; /**< The amount of data in the cache. A file can be - * smaller than the cache file. */ - uint8_t* buffer; /**< The buffer */ -} rtems_rtl_obj_cache_t; - -/** - * Open a cache allocating a single buffer of the size passed. The default - * state of the cache is flushed. No already open checks are made. - * - * @param cache The cache to initialise. - * @param size The size of the cache. - * @retval true The cache is open. - * @retval false The cache is not open. The RTL error is set. - */ -bool rtems_rtl_obj_cache_open (rtems_rtl_obj_cache_t* cache, size_t size); - -/** - * Close a cache. - * - * @param cache The cache to close. - */ -void rtems_rtl_obj_cache_close (rtems_rtl_obj_cache_t* cache); - -/** - * Flush the cache. Any further read will read the data from the file. - * - * @param cache The cache to flush. - */ -void rtems_rtl_obj_cache_flush (rtems_rtl_obj_cache_t* cache); - -/** - * Read data by reference. The length contains the amount of data that should - * be available in the cache and referenced by the buffer handle. It must be - * less than or equal to the size of the cache. This call will return the - * amount of data that is available. It can be less than you ask if the offset - * and size is past the end of the file. - * - * @param cache The cache to reference data from. - * @param fd The file descriptor. Must be an open file. - * @param offset The offset in the file to reference the data to. - * @param buffer The location to reference the data from. - * @param length The length of data to reference. Can be modified to a - * lesser value and true is still returned so check it. - * @retval true The data referenced is in the cache. - * @retval false The read failed and the RTL error has been set. - */ -bool rtems_rtl_obj_cache_read (rtems_rtl_obj_cache_t* cache, - int fd, - off_t offset, - void** buffer, - size_t* length); - -/** - * Read data by value. The data is copied to the user supplied buffer. - * - * @param cache The cache to read the data from. - * @param fd The file descriptor. Must be an open file. - * @param offset The offset in the file to read the data from. - * @param buffer The location the data is written into. - * @param length The length of data to read. - * @retval true The data has been read from the cache. - * @retval false The read failed and the RTL error has been set. - */ -bool rtems_rtl_obj_cache_read_byval (rtems_rtl_obj_cache_t* cache, - int fd, - off_t offset, - void* buffer, - size_t length); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/cpukit/libdl/rtl-obj-comp.h b/cpukit/libdl/rtl-obj-comp.h deleted file mode 100644 index 34bfa6ffa1..0000000000 --- a/cpukit/libdl/rtl-obj-comp.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * COPYRIGHT (c) 2012 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ -/** - * @file - * - * @ingroup rtems_rtl - * - * @brief RTEMS Run-Time Linker Object File Compression manages a - * compressed stream of data. - * - * This is a simple interface to the object file cache to stream data from - * from a compressed object file. There is no ability to seek with the - * data from a compressed file. The module exists to allocate the output - * buffer when the loader starts and use the cache buffers will have been - * allocated. - */ - -#if !defined (_RTEMS_RTL_OBJ_COMP_H_) -#define _RTEMS_RTL_OBJ_COMP_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * The amount of input data read at a time from the file. - */ -#define RTEMS_RTL_DECOMP_INPUT_SIZE (256) - -/** - * The types of supported compression. - */ -#define RTEMS_RTL_COMP_NONE (0) -#define RTEMS_RTL_COMP_LZ77 (1) - -/** - * The compressed file. - */ -typedef struct rtems_rtl_obj_cpmp_s -{ - rtems_rtl_obj_cache_t* cache; /**< The cache provides the input - * buffer. */ - int fd; /**< The file descriptor. */ - int compression; /**< The type of compression. */ - off_t offset; /**< The base offset of the buffer. */ - size_t size; /**< The size of the output buffer. */ - size_t level; /**< The amount of data in the buffer. */ - uint8_t* buffer; /**< The buffer */ - uint32_t read; /**< The amount of data read. */ -} rtems_rtl_obj_comp_t; - -/** - * Return the input level. - */ -static inline uint32_t rtems_rtl_obj_comp_input (rtems_rtl_obj_comp_t* comp) -{ - return comp->read; -} - -/** - * Open a compressor allocating the output buffer. - * - * @param comp The compressor to initialise. - * @param size The size of the compressor's output buffer. - * @retval true The compressor is open. - * @retval false The compressor is not open. The RTL error is set. - */ -bool rtems_rtl_obj_comp_open (rtems_rtl_obj_comp_t* comp, - size_t size); - -/** - * Close a compressor. - * - * @param comp The compressor to close. - */ -void rtems_rtl_obj_comp_close (rtems_rtl_obj_comp_t* comp); - -/** - * Set the cache and offset in the file the compressed stream starts. - * - * @param comp The compressor to set the offset in. - * @param cache The cache to read the file in by. - * @param fd The file descriptor. Must be an open file. - * @param compression The type of compression being streamed. - * @param offset The offset in the file the compressed stream starts. - */ -void rtems_rtl_obj_comp_set (rtems_rtl_obj_comp_t* comp, - rtems_rtl_obj_cache_t* cache, - int fd, - int compression, - off_t offset); - -/** - * Read decompressed data. The length contains the amount of data that should - * be available in the cache and referenced by the buffer handle. It must be - * less than or equal to the size of the cache. This call will return the - * amount of data that is available. It can be less than you ask if the offset - * and size is past the end of the file. - * - * @param comp The compressor to read data from. - * @param buffer The buffer the output is written too. - * @param length The length of data to read. Can be modified to a - * lesser value and true is still returned so check it. - * @retval true The data referenced is in the cache. - * @retval false The read failed and the RTL error has been set. - */ -bool rtems_rtl_obj_comp_read (rtems_rtl_obj_comp_t* comp, - void* buffer, - size_t length); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/cpukit/libdl/rtl-obj-fwd.h b/cpukit/libdl/rtl-obj-fwd.h deleted file mode 100644 index 2c53244316..0000000000 --- a/cpukit/libdl/rtl-obj-fwd.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * COPYRIGHT (c) 2012 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ -/** - * @file - * - * @ingroup rtems_rtl - * - * @brief RTEMS Run-Time Linker ELF Headers - */ - -#if !defined (_RTEMS_RTL_OBJ_FWD_H_) -#define _RTEMS_RTL_OBJ_FWD_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * The forward declaration of the obj section structure. - */ -struct rtems_rtl_obj_sect_s; -typedef struct rtems_rtl_obj_sect_s rtems_rtl_obj_sect_t; - -/** - * The forward declaration of the obj structure. - */ -struct rtems_rtl_obj_s; -typedef struct rtems_rtl_obj_s rtems_rtl_obj_t; - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/cpukit/libdl/rtl-obj.h b/cpukit/libdl/rtl-obj.h deleted file mode 100644 index 6a35a72822..0000000000 --- a/cpukit/libdl/rtl-obj.h +++ /dev/null @@ -1,635 +0,0 @@ -/* - * COPYRIGHT (c) 2012 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ -/** - * @file - * - * @ingroup rtems_rtl - * - * @brief RTEMS Run-Time Linker Object Support. - */ - -#if !defined (_RTEMS_RTL_OBJ_H_) -#define _RTEMS_RTL_OBJ_H_ - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * Loader format flags. - */ -#define RTEMS_RTL_FMT_ELF (1 << 0) -#define RTEMS_RTL_FMT_COMP (1 << 1) -#define RTEMS_RTL_FMT_PRIVATE (1 << 16) - -/** - * Loader format definition. - */ -typedef struct rtems_rtl_loader_format_s -{ - /** - * The format label. This can be used to determine and manage - * specific formats. - */ - const char* label; - - /** - * The format flags. - */ - uint32_t flags; -} rtems_rtl_loader_format_t; - -/** - * The type of the format loader check handler. This handler checks the format - * and if it is detected as suitable it returns true. - */ -typedef bool (*rtems_rtl_loader_check) (rtems_rtl_obj_t* obj, int fd); - -/** - * The type of the format loader load handler. This handler loads the specific - * format. - */ -typedef bool (*rtems_rtl_loader_load) (rtems_rtl_obj_t* obj, int fd); - -/** - * The type of the format loader unload handler. This handler unloads the - * specific format. - */ -typedef bool (*rtems_rtl_loader_unload) (rtems_rtl_obj_t* obj); - -/** - * The type of the format loader signature handler. This handler checks the - * format signature. - */ -typedef rtems_rtl_loader_format_t* (*rtems_rtl_loader_sig) (void); - -/** - * Table for supported loadable formats. - */ -typedef struct rtems_rtl_loader_table_s -{ - rtems_rtl_loader_check check; /**< The check handler. */ - rtems_rtl_loader_load load; /**< The loader. */ - rtems_rtl_loader_unload unload; /**< The unloader. */ - rtems_rtl_loader_sig signature; /**< The loader's signature. */ -} rtems_rtl_loader_table_t; - -/** - * Flags for the various section types. - */ -#define RTEMS_RTL_OBJ_SECT_TEXT (1 << 0) /**< Section holds program text. */ -#define RTEMS_RTL_OBJ_SECT_CONST (1 << 1) /**< Section holds program text. */ -#define RTEMS_RTL_OBJ_SECT_DATA (1 << 2) /**< Section holds program data. */ -#define RTEMS_RTL_OBJ_SECT_BSS (1 << 3) /**< Section holds program bss. */ -#define RTEMS_RTL_OBJ_SECT_EH (1 << 4) /**< Section holds exception data. */ -#define RTEMS_RTL_OBJ_SECT_REL (1 << 5) /**< Section holds relocation records. */ -#define RTEMS_RTL_OBJ_SECT_RELA (1 << 6) /**< Section holds relocation addend - * records. */ -#define RTEMS_RTL_OBJ_SECT_SYM (1 << 7) /**< Section holds symbols. */ -#define RTEMS_RTL_OBJ_SECT_STR (1 << 8) /**< Section holds strings. */ -#define RTEMS_RTL_OBJ_SECT_ALLOC (1 << 9) /**< Section allocates runtime memory. */ -#define RTEMS_RTL_OBJ_SECT_LOAD (1 << 10) /**< Section is loaded from object file. */ -#define RTEMS_RTL_OBJ_SECT_WRITE (1 << 11) /**< Section is writable, ie data. */ -#define RTEMS_RTL_OBJ_SECT_EXEC (1 << 12) /**< Section is executable. */ -#define RTEMS_RTL_OBJ_SECT_ZERO (1 << 13) /**< Section is preset to zero. */ -#define RTEMS_RTL_OBJ_SECT_LINK (1 << 14) /**< Section is link-ordered. */ -#define RTEMS_RTL_OBJ_SECT_CTOR (1 << 15) /**< Section contains constructors. */ -#define RTEMS_RTL_OBJ_SECT_DTOR (1 << 16) /**< Section contains destructors. */ -#define RTEMS_RTL_OBJ_SECT_LOCD (1 << 17) /**< Section has been located. */ - -/** - * Section types mask. - */ -#define RTEMS_RTL_OBJ_SECT_TYPES (RTEMS_RTL_OBJ_SECT_TEXT | \ - RTEMS_RTL_OBJ_SECT_CONST | \ - RTEMS_RTL_OBJ_SECT_DATA | \ - RTEMS_RTL_OBJ_SECT_BSS | \ - RTEMS_RTL_OBJ_SECT_EH) - -/** - * An object file is made up of sections and the can be more than - * one of a specific type of sections. All sections and grouped - * together in memory. - */ -struct rtems_rtl_obj_sect_s -{ - rtems_chain_node node; /**< The node's link in the chain. */ - int section; /**< The section number. */ - const char* name; /**< The section's name. */ - size_t size; /**< The size of the section in memory. */ - off_t offset; /**< Offset into the object file. Relative to - * the start of the object file. */ - uint32_t alignment; /**< Alignment of this section. */ - int link; /**< Section link field. */ - int info; /**< Secfion info field. */ - uint32_t flags; /**< The section's flags. */ - void* base; /**< The base address of the section in - * memory. */ - int load_order; /**< Order we load sections. */ -}; - -/** - * Object file descriptor flags. - */ -#define RTEMS_RTL_OBJ_LOCKED (1 << 0) /**< Lock the object file so it cannot - * be unloaded. */ -#define RTEMS_RTL_OBJ_UNRESOLVED (1 << 1) /**< The object file has unresolved - * external symbols. */ - -/** - * RTL Object. There is one for each object module loaded plus one for the base - * kernel image. - */ -struct rtems_rtl_obj_s -{ - rtems_chain_node link; /**< The node's link in the chain. */ - uint32_t flags; /**< The status of the object file. */ - uint32_t users; /**< References to the object file. */ - int format; /**< The format of the object file. */ - const char* fname; /**< The file name for the object. */ - const char* oname; /**< The object file name. Can be - * relative. */ - const char* aname; /**< The archive name containing the - * object. NULL means the object is not - * in a lib */ - off_t ooffset; /**< The object offset in the archive. */ - size_t fsize; /**< Size of the object file. */ - rtems_chain_control sections; /**< The sections of interest in the - * object file. */ - rtems_rtl_obj_sym_t* local_table; /**< Local symbol table. */ - size_t local_syms; /**< Local symbol count. */ - size_t local_size; /**< Local symbol memory usage. */ - rtems_rtl_obj_sym_t* global_table; /**< Global symbol table. */ - size_t global_syms; /**< Global symbol count. */ - size_t global_size; /**< Global symbol memory usage. */ - uint32_t unresolved; /**< The number of unresolved relocations. */ - void* text_base; /**< The base address of the text section - * in memory. */ - size_t text_size; /**< The size of the text section. */ - void* const_base; /**< The base address of the const section - * in memory. */ - void* eh_base; /**< The base address of the eh section - * in memory. */ - size_t eh_size; /**< The size of the eh section. */ - void* data_base; /**< The base address of the data section - * in memory. */ - void* bss_base; /**< The base address of the bss section - * in memory. */ - size_t bss_size; /**< The size of the bss section. */ - size_t exec_size; /**< The amount of executable memory - * allocated */ - void* entry; /**< The entry point of the module. */ - uint32_t checksum; /**< The checksum of the text sections. A - * zero means do not checksum. */ - uint32_t* sec_num; /**< The sec nums of each obj. */ - uint32_t obj_num; /**< The count of elf files in an rtl obj. */ - struct link_map* linkmap; /**< For GDB. */ - void* loader; /**< The file details specific to a loader. */ -}; - -/** - * A section handler is called once for each section that needs to be - * processed by this handler. - * - * @param obj The object file's descriptor the section belongs too. - * @param fd The file descriptor of the object file beling loaded. - * @param sect The section the handler is being invoked to handle. - * @param data A user supplied data variable. - * @retval true The operation was successful. - * @retval false The operation failed and the RTL has been set. - */ -typedef bool (*rtems_rtl_obj_sect_handler_t)(rtems_rtl_obj_t* obj, - int fd, - rtems_rtl_obj_sect_t* sect, - void* data); - -/** - * Get the file name. - * - * @param obj The object file. - * @return const char* The string. - */ -static inline const char* rtems_rtl_obj_fname (const rtems_rtl_obj_t* obj) -{ - return obj->fname; -} - -/** - * Is the file name valid ? - * - * @param obj The object file. - * @return bool There is a file name - */ -static inline bool rtems_rtl_obj_fname_valid (const rtems_rtl_obj_t* obj) -{ - return obj->fname; -} - -/** - * Get the object name. - * - * @param obj The object file. - * @return const char* The string. - */ -static inline const char* rtems_rtl_obj_oname (const rtems_rtl_obj_t* obj) -{ - return obj->oname; -} - -/** - * Is the object name valid ? - * - * @param obj The object file. - * @return bool There is an object name - */ -static inline bool rtems_rtl_obj_oname_valid (const rtems_rtl_obj_t* obj) -{ - return obj->oname; -} - -/** - * Get the archive name. - * - * @param obj The object file. - * @return const char* The string. - */ -static inline const char* rtems_rtl_obj_aname (const rtems_rtl_obj_t* obj) -{ - return obj->aname; -} - -/** - * Is the archive name valid ? - * - * @param obj The object file. - * @return bool There is an archive name - */ -static inline bool rtems_rtl_obj_aname_valid (const rtems_rtl_obj_t* obj) -{ - return obj->aname; -} - -/** - * Is the address inside the text section? - * - * @param obj The object file. - * @return bool There is an archive name - */ -static inline bool rtems_rtl_obj_text_inside (const rtems_rtl_obj_t* obj, - const void* address) -{ - return - (address >= obj->text_base) && - (address < (obj->text_base + obj->text_size)); -} - -/** - * Allocate an object structure on the heap. - * - * @retval NULL No memory for the object. - */ -rtems_rtl_obj_t* rtems_rtl_obj_alloc (void); - -/** - * Free the object structure and related resources. - * - * @param obj The object file's descriptor to free. - * @retval false The object has dependences. - * @retval true The object has been freed. - */ -bool rtems_rtl_obj_free (rtems_rtl_obj_t* obj); - -/** - * Does the object file have unresolved external references ? If it does the - * results of executing code is unpredictable. - * - * @param obj The object file's descriptor. - * @retval true The object file has unresolved externals. - * @retval false The object file has all external references resolved. - */ -bool rtems_rtl_obj_unresolved (rtems_rtl_obj_t* obj); - -/** - * Parses a filename and returns newly allocated strings with the archive name, - * object name, and the object's offset - * - * @param name The filename of the object - * @param aname Address of a string pointer that holds the archive name - * @param oname Address of a string pointer that holds the object name - * @param ooffset Address of an int that holds the object offset - * @retval true The parsing was successful - * @retval false The parsing was unsuccessful - */ -bool rtems_rtl_parse_name (const char* name, - const char** aname, - const char** oname, - off_t* ooffset); - -/** - * Check of the name matches the object file's object name. - * - * @param obj The object file's descriptor. - * @param name The name to match. - */ -bool rtems_rtl_match_name (rtems_rtl_obj_t* obj, const char* name); - -/** - * Find an object file on disk that matches the name. The object descriptor is - * fill in with the various parts of a name. A name can have archive, object - * file and offset components. The search path in the RTL is searched. - * - * @param obj The object file's descriptor. - * @param name The name to locate on disk. - * @retval true The file has been found. - * @retval false The file could not be located. The RTL error has been set. - */ -bool rtems_rtl_obj_find_file (rtems_rtl_obj_t* obj, const char* name); - -/** - * Add a section to the object descriptor. - * - * @param obj The object file's descriptor. - * @param section The section's index number. - * @param name The name of the section. - * @param size The size of the section in memory. - * @param offset The offset of the section in the object file. - * @param alignment The alignment of the section in memory. - * @param link The section's link field (from the ELF format). - * @param info The section's info field (from the ELF format). - * @param flags The section's flags. - * @retval true The section has been added. - * @retval false The section has not been added. See the RTL error. - */ -bool rtems_rtl_obj_add_section (rtems_rtl_obj_t* obj, - int section, - const char* name, - size_t size, - off_t offset, - uint32_t alignment, - int link, - int info, - uint32_t flags); - -/** - * Erase the object file descriptor's sections. - * - * @param obj The object file's descriptor. - */ -void rtems_rtl_obj_erase_sections (rtems_rtl_obj_t* obj); - -/** - * Find the section given a name. - * - * @param obj The object file's descriptor. - * @param name The name of the section to find. - * @retval NULL The section was not found. - * @return rtems_rtl_obj_sect_t* The named section. - */ -rtems_rtl_obj_sect_t* rtems_rtl_obj_find_section (const rtems_rtl_obj_t* obj, - const char* name); - -/** - * Find a section given a section's index number. - * - * @param obj The object file's descriptor. - * @param index The section's index to find. - * @retval NULL The section was not found. - * @return rtems_rtl_obj_sect_t* The found section. - */ -rtems_rtl_obj_sect_t* rtems_rtl_obj_find_section_by_index (const rtems_rtl_obj_t* obj, - int index); - -/** - * The text section size. Only use once all the sections has been added. It - * includes alignments between sections that are part of the object's text - * area. The consts sections are included in this section. - * - * @param obj The object file's descriptor. - * @return size_t The size of the text area of the object file. - */ -size_t rtems_rtl_obj_text_size (const rtems_rtl_obj_t* obj); - -/** - * The text section alignment for the object file. Only use once all the - * sections has been added. The section alignment is the alignment of the first - * text type section loaded the text section. - * - * You can assume the alignment is a positive integral power of 2 if not 0 or - * 1. If 0 or 1 then there is no alignment. - * - * @param obj The object file's descriptor. - * @return uint32_t The alignment. Can be 0 or 1 for not aligned or the alignment. - */ -uint32_t rtems_rtl_obj_text_alignment (const rtems_rtl_obj_t* obj); - -/** - * The const section size. Only use once all the sections has been added. It - * includes alignments between sections that are part of the object's const - * area. The consts sections are included in this section. - * - * @param obj The object file's descriptor. - * @return size_t The size of the const area of the object file. - */ -size_t rtems_rtl_obj_const_size (const rtems_rtl_obj_t* obj); - -/** - * The const section alignment for the object file. Only use once all the - * sections has been added. The section alignment is the alignment of the first - * const type section loaded the const section. - * - * You can assume the alignment is a positive integral power of 2 if not 0 or - * 1. If 0 or 1 then there is no alignment. - * - * @param obj The object file's descriptor. - * @return uint32_t The alignment. Can be 0 or 1 for not aligned or the alignment. - */ -uint32_t rtems_rtl_obj_const_alignment (const rtems_rtl_obj_t* obj); - -/** - * The eh section size. Only use once all the sections has been added. It - * includes alignments between sections that are part of the object's bss area. - * - * @param obj The object file's descriptor. - * @return size_t The size of the bss area of the object file. - */ -size_t rtems_rtl_obj_eh_size (const rtems_rtl_obj_t* obj); - -/** - * The eh section alignment for the object file. Only use once all the sections - * has been added. The section alignment is the alignment of the first bss type - * section loaded the bss section. - * - * You can assume the alignment is a positive integral power of 2 if not 0 or - * 1. If 0 or 1 then there is no alignment. - * - * @param obj The object file's descriptor. - * @return uint32_t The alignment. Can be 0 or 1 for not aligned or the alignment. - */ -uint32_t rtems_rtl_obj_eh_alignment (const rtems_rtl_obj_t* obj); - -/** - * The data section size. Only use once all the sections has been added. It - * includes alignments between sections that are part of the object's data - * area. - * - * @param obj The object file's descriptor. - * @return size_t The size of the data area of the object file. - */ -size_t rtems_rtl_obj_data_size (const rtems_rtl_obj_t* obj); - -/** - * The data section alignment for the object file. Only use once all the - * sections has been added. The section alignment is the alignment of the first - * data type section loaded the data section. - * - * You can assume the alignment is a positive integral power of 2 if not 0 or - * 1. If 0 or 1 then there is no alignment. - * - * @param obj The object file's descriptor. - * @return uint32_t The alignment. Can be 0 or 1 for not aligned or the alignment. - */ -uint32_t rtems_rtl_obj_data_alignment (const rtems_rtl_obj_t* obj); - -/** - * The bss section size. Only use once all the sections has been added. It - * includes alignments between sections that are part of the object's bss area. - * - * @param obj The object file's descriptor. - * @return size_t The size of the bss area of the object file. - */ -size_t rtems_rtl_obj_bss_size (const rtems_rtl_obj_t* obj); - -/** - * The bss section alignment for the object file. Only use once all the - * sections has been added. The section alignment is the alignment of the first - * bss type section loaded the bss section. - * - * You can assume the alignment is a positive integral power of 2 if not 0 or - * 1. If 0 or 1 then there is no alignment. - * - * @param obj The object file's descriptor. - * @return uint32_t The alignment. Can be 0 or 1 for not aligned or the alignment. - */ -uint32_t rtems_rtl_obj_bss_alignment (const rtems_rtl_obj_t* obj); - -/** - * Relocate the object file. The object file's section are parsed for any - * relocation type sections. - * - * @param obj The object file's descriptor. - * @param fd The object file's file descriptor. - * @param handler The object file's format specific relocation handler. - * @param data User specific data handle. - * @retval true The object file was relocated. - * @retval false The relocation failed. The RTL error is set. - */ -bool rtems_rtl_obj_relocate (rtems_rtl_obj_t* obj, - int fd, - rtems_rtl_obj_sect_handler_t handler, - void* data); - -/** - * Synchronize caches to make code visible to CPU(s) - * - * @param obj The object file's descriptor. - */ -void rtems_rtl_obj_synchronize_cache (rtems_rtl_obj_t* obj); - -/** - * Relocate an object file's unresolved reference. - * - * @param rec The unresolved relocation record. - * @param sym The unresolved relocation's referenced symbol. - * @retval true The object file record was relocated. - * @retval false The relocation failed. The RTL error is set. - */ -bool rtems_rtl_obj_relocate_unresolved (rtems_rtl_unresolv_reloc_t* reloc, - rtems_rtl_obj_sym_t* sym); - -/** - * Load the symbols from the object file. Only the exported or public symbols - * are read into memory and held in the global symbol table. - * - * @param obj The object file's descriptor. - * @param fd The object file's file descriptor. - * @param handler The object file's format specific symbol handler. - * @param data User specific data handle. - * @retval true The object file's symbol where loaded. - * @retval false The symbol loading failed. The RTL error is set. - */ -bool rtems_rtl_obj_load_symbols (rtems_rtl_obj_t* obj, - int fd, - rtems_rtl_obj_sect_handler_t handler, - void* data); - -/** - * Load the sections that have been allocated memory in the target. The bss - * type section does not load any data, it is set to 0. The text and data - * sections read the detault data from the object file into the target memory. - * - * @param obj The object file's descriptor. - * @param fd The object file's file descriptor. - * @param handler The object file's format specific load handler. - * @param data User specific data handle. - * @retval true The object has been sucessfully loaded. - * @retval false The load failed. The RTL error has been set. - */ -bool rtems_rtl_obj_load_sections (rtems_rtl_obj_t* obj, - int fd, - rtems_rtl_obj_sect_handler_t handler, - void* data); - -/** - * Invoke the constructors the object has. Constructors are a table of pointers - * to "void (*)(void);" where NULL pointers are skipped. The table's size is - * taken from the section's size. The objet ELF specific code is responisble - * for flagging which sections contain constructors. - * - * @param obj The object file's descriptor. - */ -void rtems_rtl_obj_run_ctors (rtems_rtl_obj_t* obj); - -/** - * Invoke the destructors the object has. Destructors are a table of pointers - * to "void (*)(void);" where NULL pointers are skipped. The table's size is - * taken from the section's size. The objet ELF specific code is responisble - * for flagging which sections contain destructors. - * - * @param obj The object file's descriptor. - */ -void rtems_rtl_obj_run_dtors (rtems_rtl_obj_t* obj); - -/** - * Load the object file, reading all sections into memory, symbols and - * performing any relocation fixups. - * - * @param obj The object file's descriptor. - * @retval true The object file has been loaded. - * @retval false The load failed. The RTL error has been set. - */ -bool rtems_rtl_obj_load (rtems_rtl_obj_t* obj); - -/** - * Unload the object file, erasing all symbols and releasing all memory. - * - * @param obj The object file's descriptor. - * @retval true The object file has been unloaded. - * @retval false The unload failed. The RTL error has been set. - */ -bool rtems_rtl_obj_unload (rtems_rtl_obj_t* obj); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/cpukit/libdl/rtl-sym.h b/cpukit/libdl/rtl-sym.h deleted file mode 100644 index fe00da89d7..0000000000 --- a/cpukit/libdl/rtl-sym.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * COPYRIGHT (c) 2012-2014 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ -/** - * @file - * - * @ingroup rtems_rtl - * - * @brief RTEMS Run-Time Linker Object File Symbol Table. - */ - -#if !defined (_RTEMS_RTL_SYM_H_) -#define _RTEMS_RTL_SYM_H_ - -#include -#include "rtl-obj-fwd.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * An object file symbol. - */ -typedef struct rtems_rtl_obj_sym_s -{ - rtems_chain_node node; /**< The node's link in the chain. */ - const char* name; /**< The symbol's name. */ - void* value; /**< The value of the symbol. */ - uint32_t data; /**< Format specific data. */ -} rtems_rtl_obj_sym_t; - -/** - * Table of symbols stored in a hash table. - */ -typedef struct rtems_rtl_symbols_s -{ - rtems_chain_control* buckets; - size_t nbuckets; -} rtems_rtl_symbols_t; - -/** - * Open a symbol table with the specified number of buckets. - * - * @param symbols The symbol table to open. - * @param buckets The number of buckets in the hash table. - * @retval true The symbol is open. - * @retval false The symbol table could not created. The RTL - * error has the error. - */ -bool rtems_rtl_symbol_table_open (rtems_rtl_symbols_t* symbols, - size_t buckets); - -/** - * Close the table and erase the hash table. - * - * @param symbols Close the symbol table. - */ -void rtems_rtl_symbol_table_close (rtems_rtl_symbols_t* symbols); - -/** - * Add a table of exported symbols to the symbol table. - * - * The export table is a series of symbol records and each record has two - * fields: - * - * 1. label - * 2. address - * - * The 'label' is an ASCIIZ string of variable length. The address is of size - * of an unsigned long for the target running the link editor. The byte order - * is defined by the machine type because the table should be built by the - * target compiler. - * - * The table is terminated with a nul string followed by the bytes 0xDE, 0xAD, - * 0xBE, and 0xEF. This avoids alignments issues. - * - * @param obj The object table the symbols are for. - * @param esyms The exported symbol table. - * @param size The size of the table in bytes. - */ -bool rtems_rtl_symbol_global_add (rtems_rtl_obj_t* obj, - const unsigned char* esyms, - unsigned int size); - -/** - * Find a symbol given the symbol label in the global symbol table. - * - * @param name The name as an ASCIIZ string. - * @retval NULL No symbol found. - * @return rtems_rtl_obj_sym_t* Reference to the symbol. - */ -rtems_rtl_obj_sym_t* rtems_rtl_symbol_global_find (const char* name); - -/** - * Find a symbol given the symbol label in the local object file. - * - * @param obj The object file to search. - * @param name The name as an ASCIIZ string. - * @retval NULL No symbol found. - * @return rtems_rtl_obj_sym_t* Reference to the symbol. - */ -rtems_rtl_obj_sym_t* rtems_rtl_symbol_obj_find (rtems_rtl_obj_t* obj, - const char* name); - -/** - * Add the object file's symbols to the global table. - * - * @param obj The object file the symbols are to be added. - */ -void rtems_rtl_symbol_obj_add (rtems_rtl_obj_t* obj); - -/** - * Erase the object file's local symbols. - * - * @param obj The object file the local symbols are to be erased from. - */ -void rtems_rtl_symbol_obj_erase_local (rtems_rtl_obj_t* obj); - -/** - * Erase the object file's symbols. - * - * @param obj The object file the symbols are to be erased from. - */ -void rtems_rtl_symbol_obj_erase (rtems_rtl_obj_t* obj); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/cpukit/libdl/rtl-trace.h b/cpukit/libdl/rtl-trace.h deleted file mode 100644 index 4b93c8c91c..0000000000 --- a/cpukit/libdl/rtl-trace.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * COPYRIGHT (c) 2012-2014 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ -/** - * @file - * - * @ingroup rtems_rtl - * - * @brief RTEMS Run-Time Linker ELF Trace Support. - */ - -#if !defined (_RTEMS_RTL_TRACE_H_) -#define _RTEMS_RTL_TRACE_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include -#include - -/** - * Set to 1 to build trace support in to the RTL code. - */ -#define RTEMS_RTL_TRACE 1 - -/** - * The type of the mask. - */ -typedef uint32_t rtems_rtl_trace_mask; - -/** - * List of tracing bits for the various parts of the link editor. - */ -#define RTEMS_RTL_TRACE_DETAIL (1UL << 0) -#define RTEMS_RTL_TRACE_WARNING (1UL << 1) -#define RTEMS_RTL_TRACE_LOAD (1UL << 2) -#define RTEMS_RTL_TRACE_UNLOAD (1UL << 3) -#define RTEMS_RTL_TRACE_SECTION (1UL << 4) -#define RTEMS_RTL_TRACE_SYMBOL (1UL << 5) -#define RTEMS_RTL_TRACE_RELOC (1UL << 6) -#define RTEMS_RTL_TRACE_GLOBAL_SYM (1UL << 7) -#define RTEMS_RTL_TRACE_LOAD_SECT (1UL << 8) -#define RTEMS_RTL_TRACE_ALLOCATOR (1UL << 9) -#define RTEMS_RTL_TRACE_UNRESOLVED (1UL << 10) -#define RTEMS_RTL_TRACE_CACHE (1UL << 11) -#define RTEMS_RTL_TRACE_ALL (0xffffffffUL & ~(RTEMS_RTL_TRACE_CACHE)) - -/** - * Call to check if this part is bring traced. If RTEMS_RTL_TRACE is defined to - * 0 the code is dead code elminiated when built with -Os, -O2, or higher. - * - * @param mask The part of the API to trace. - * @retval true Tracing is active for the mask. - * @retval false Do not trace. - */ -#if RTEMS_RTL_TRACE -bool rtems_rtl_trace (rtems_rtl_trace_mask mask); -#else -#define rtems_rtl_trace(_m) (0) -#endif - -/** - * Set the mask. - * - * @param mask The mask bits to set. - * @return The previous mask. - */ -#if RTEMS_RTL_TRACE -rtems_rtl_trace_mask rtems_rtl_trace_set_mask (rtems_rtl_trace_mask mask); -#else -#define rtems_rtl_trace_set_mask(_m) -#endif - -/** - * Clear the mask. - * - * @param mask The mask bits to clear. - * @return The previous mask. - */ -#if RTEMS_RTL_TRACE -rtems_rtl_trace_mask rtems_rtl_trace_clear_mask (rtems_rtl_trace_mask mask); -#else -#define rtems_rtl_trace_clear_mask(_m) -#endif - -/** - * Add shell trace shell command. - */ -#if RTEMS_RTL_TRACE -int rtems_rtl_trace_shell_command (int argc, char *argv[]); -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/cpukit/libdl/rtl-unresolved.h b/cpukit/libdl/rtl-unresolved.h deleted file mode 100644 index bd4ce2a215..0000000000 --- a/cpukit/libdl/rtl-unresolved.h +++ /dev/null @@ -1,212 +0,0 @@ -/* - * COPYRIGHT (c) 2012 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ -/** - * @file - * - * @ingroup rtems_rtl - * - * @brief RTEMS Run-Time Linker Object File Unresolved Relocations Table. - * - * The unresolved relocation table holds relocations in a loaded object file - * which reference unresolved external symbols. The support is needed to allow - * dependent object files to load. In the case of dependent object files one - * will have unresolved externals until the dependent object file is also - * loaded. There is no load order that resolves this. - * - * The unresolved relocation table is a single table used by all object files - * with unresolved symbols. It made of blocks linked together where blocks are - * allocated as requiered. The table is always maintained compacted. That is as - * relocations are resolved and removed the table is compacted. The only - * pointer in the table is the object file poniter. This is used to identify - * which object the relocation belongs to. There are no linking or back - * pointers in the unresolved relocations table. The table is scanned for each - * object file's relocations. This is not fast but the table should be small - * and if it happens to grow large you have other more pressing issues to - * resolve in your application. - * - * The table holds two (2) types of records: - * - * # Symbol name strings. - * # Relocations. - * - * The symbol name a relocation references is held in a specific symbol name - * string record in the table the relocation record references. The record - * counts the number of references and the string is removed from the table - * when the reference count reaches 0. There can be many relocations - * referencing the symbol. The strings are referenced by a single 16bit - * unsigned integer which is the count of the string in the table. - * - * The section the relocation is for in the object is the section number. The - * relocation data is series of machine word sized fields: - * - * # Offset in the section. - * # Relocation info (format specific) - * # Additional format specific data. - */ - -#if !defined (_RTEMS_RTL_UNRESOLVED_H_) -#define _RTEMS_RTL_UNRESOLVED_H_ - -#include -#include "rtl-obj-fwd.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * Hack to work around machine size. This needs to be cleaned up - * to better support 64bit targets. - */ -typedef uint32_t rtems_rtl_word_t; - -/** - * The types of records in the blocks. - */ -typedef enum rtems_rtl_unresolved_rtype_e -{ - rtems_rtl_unresolved_empty = 0, /**< The records is empty. Must always be 0 */ - rtems_rtl_unresolved_name = 1, /**< The record is a name. */ - rtems_rtl_unresolved_reloc = 2 /**< The record is a relocation record. */ -} rtems_rtl_unresolved_rtype_t; - -/** - * Unresolved externals symbol names. The names are reference counted and - * separate from the relocation records because a number of records could - * reference the same symbol name. - */ -typedef struct rtems_rtl_unresolv_name_s -{ - uint16_t refs; /**< The number of references to this name. */ - uint16_t length; /**< The length of this name. */ - const char name[12]; /**< The symbol name. */ -} rtems_rtl_unresolv_name_t; - -/** - * Unresolved externals symbols require the relocation records to be held - * and references. - */ -typedef struct rtems_rtl_unresolv_reloc_s -{ - rtems_rtl_obj_t* obj; /**< The relocation's object file. */ - uint16_t flags; /**< Format specific flags. */ - uint16_t name; /**< The symbol's name. */ - uint16_t sect; /**< The target section. */ - rtems_rtl_word_t rel[3]; /**< Relocation record. */ -} rtems_rtl_unresolv_reloc_t; - -/** - * Unresolved externals records. - */ -typedef struct rtems_rtl_unresolv_rec_s -{ - rtems_rtl_unresolved_rtype_t type; - union - { - rtems_rtl_unresolv_name_t name; /**< The name, or */ - rtems_rtl_unresolv_reloc_t reloc; /**< the relocation record. */ - } rec; -} rtems_rtl_unresolv_rec_t; - -/** - * Unresolved blocks. - */ -typedef struct rtems_rtl_unresolv_block_s -{ - rtems_chain_node link; /**< Blocks are chained. */ - uint32_t recs; /**< The number of records in the block. */ - rtems_rtl_unresolv_rec_t rec; /**< The records. More follow. */ -} rtems_rtl_unresolv_block_t; - -/** - * Unresolved table holds the names and relocations. - */ -typedef struct rtems_rtl_unresolved_s -{ - uint32_t marker; - size_t block_recs; /**< The records per blocks allocated. */ - rtems_chain_control blocks; /**< List of blocks. */ -} rtems_rtl_unresolved_t; - -/** - * The iterator function used to iterate over the unresolved table. - * - * @param rec The current iterator. - * @param data The user data. - * @retval true The iterator has finished. - * @retval false The iterator has not finished. Keep iterating. - */ -typedef bool rtems_rtl_unresolved_iterator_t (rtems_rtl_unresolv_rec_t* rec, - void* data); - -/** - * Open an unresolved relocation table. - * - * @param unresolv The unresolved table to open. - * @param block_records The number of records per block allocated. - * @retval true The table is open. - * @retval false The unresolved relocation table could not created. The RTL - * error has the error. - */ -bool rtems_rtl_unresolved_table_open (rtems_rtl_unresolved_t* unresolved, - size_t block_records); - -/** - * Close the table and erase the blocks. - * - * @param unreolved Close the unresolved table. - */ -void rtems_rtl_unresolved_table_close (rtems_rtl_unresolved_t* unresolved); - -/** - * Iterate over the table of unresolved entries. - */ -bool rtems_rtl_unresolved_interate (rtems_rtl_unresolved_iterator_t iterator, - void* data); - -/** - * Add a relocation to the list of unresolved relocations. - * - * @param unresolved The unresolved symbol table. - * @param obj The object table the symbols are for. - * @param flags Format specific flags. - * @param name The symbol name the relocation references. - * @param sect The target section number the relocation references. - * @param rel The format specific relocation data. - * @retval true The relocation has been added. - * @retval false The relocation could not be added. - */ -bool rtems_rtl_unresolved_add (rtems_rtl_obj_t* obj, - const uint16_t flags, - const char* name, - const uint16_t sect, - const rtems_rtl_word_t* rel); - -/** - * Resolve the unresolved symbols. - */ -void rtems_rtl_unresolved_resolve (void); - -/** - * Remove a relocation from the list of unresolved relocations. - * - * @param unresolved The unresolved symbol table. - * @param obj The object table the symbols are for. - * @param esyms The exported symbol table. - * @param size The size of the table in bytes. - */ -bool rtems_rtl_unresolved_remove (rtems_rtl_obj_t* obj, - const char* name, - const uint16_t sect, - const rtems_rtl_word_t* rel); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/cpukit/libdl/rtl.h b/cpukit/libdl/rtl.h deleted file mode 100644 index fe9a7df081..0000000000 --- a/cpukit/libdl/rtl.h +++ /dev/null @@ -1,321 +0,0 @@ -/* - * COPYRIGHT (c) 2012 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -/** - * @file - * - * @ingroup rtems_rtl - * - * @brief RTEMS Run-Time Linker - * - * This is the POSIX interface to run-time loading of code into RTEMS. - */ - -#if !defined (_RTEMS_RTL_H_) -#define _RTEMS_RTL_H_ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup rtems_rtl RTEMS Runtime Link Editor - * - * The module implements a runtime link editor with the standard dlopen, and - * dlclose family of functions. - * - * The runtime link editor is different to that found on Unix type systems. The - * object modules are compiled for PIC or position indepentent code and - * therefore require relocating when loaded. - * - * The object file format is currently ELF and object files can be separate - * files or in an archive. Object files in an archive are referenced by - * specifing 'archive:object' format. For example 'libfoo.a:bar.o'. - */ - -/** - * Macros to glue two tokens. - */ -#ifdef __STDC__ -#define RTL_XGLUE(a,b) a##b -#else -#define RTL_XGLUE(a,b) a/**/b -#endif - -#define RTL_GLUE(a,b) RTL_XGLUE(a,b) - -/** - * The number of buckets in the global symbol table. - */ -#define RTEMS_RTL_SYMS_GLOBAL_BUCKETS (32) - -/** - * The number of relocation record per block in the unresolved table. - */ -#define RTEMS_RTL_UNRESOLVED_BLOCK_SIZE (64) - -/** - * The global debugger interface variable. - */ -extern struct r_debug _rtld_debug; - -/** - * Debugger break function. Call when debugging to have it read the _rtld_debug - * variable. - */ -extern void _rtld_debug_state (void); - -/** - * The type of constructor/destructor function. - */ -typedef void (*rtems_rtl_cdtor_t)(void); - -/** - * The global RTL data. This structure is allocated on the heap when the first - * call to the RTL is made and never released. - * - * The global symbol table is a hash table held in this structure and the - * actual symbols are part of the object's structure. If this is a problem we - * could look at a hash table per object file. - */ -struct rtems_rtl_data_s -{ - rtems_id lock; /**< The RTL lock id */ - rtems_rtl_alloc_data_t allocator; /**< The allocator data. */ - rtems_chain_control objects; /**< List if loaded object files. */ - const char* paths; /**< Search paths for archives. */ - rtems_rtl_symbols_t globals; /**< Global symbol table. */ - rtems_rtl_unresolved_t unresolved; /**< Unresolved symbols. */ - rtems_rtl_obj_t* base; /**< Base object file. */ - rtems_rtl_obj_cache_t symbols; /**< Symbols object file cache. */ - rtems_rtl_obj_cache_t strings; /**< Strings object file cache. */ - rtems_rtl_obj_cache_t relocs; /**< Relocations object file cache. */ - rtems_rtl_obj_comp_t decomp; /**< The decompression compressor. */ - int last_errno; /**< Last error number. */ - char last_error[64]; /**< Last error string. */ -}; - -/** - * Get the RTL data with out locking. This call assumes the RTL is locked. - * - * @return rtems_rtl_data_t* The RTL data after being locked. - * @retval NULL The RTL data is not initialised. - */ -rtems_rtl_data_t* rtems_rtl_data (void); - -/** - * Get the RTL global symbol table with out locking. This call assmes the RTL - * is locked. - * - * @return rtems_rtl_symbols_t* The RTL global symbols after being locked. - * @retval NULL The RTL data is not initialised. - */ -rtems_rtl_symbols_t* rtems_rtl_global_symbols (void); - -/** - * Get the RTL resolved table with out locking. This call assmes the RTL - * is locked. - * - * @return rtems_rtl_unresolv_t* The RTL unresolved symbols and reloc records. - * @retval NULL The RTL data is not initialised. - */ -rtems_rtl_unresolved_t* rtems_rtl_unresolved (void); - -/** - * Get the RTL symbols, strings, or relocations object file caches. This call - * assmes the RTL is locked. - * - * @param symbols Pointer to the location to set the cache into. Returns NULL - * is rtl is not initialised. If NULL is passed in no value set. - * @param strings Pointer to the location to set the cache into. Returns NULL - * is rtl is not initialised. If NULL is passed in no value set. - * @param relocs Pointer to the location to set the cache into. Returns NULL - * is rtl is not initialised. If NULL is passed in no value set. - */ -void rtems_rtl_obj_caches (rtems_rtl_obj_cache_t** symbols, - rtems_rtl_obj_cache_t** strings, - rtems_rtl_obj_cache_t** relocs); - -/** - * Flush all the object file caches. - */ -void rtems_rtl_obj_caches_flush (void); - -/** - * Get the RTL decompressor setting the cache and the offset in the file the - * compressed stream starts. This call assmes the RTL is locked. - * - * @param decomp Pointer to the location to set the compressor into. Returns - * NULL is rtl is not initialised. - * @param cache The cache to read the file with. Saves needing an extrs buffer. - * @param offset The offset in the file the compressed stream starts. - */ -void rtems_rtl_obj_comp (rtems_rtl_obj_comp_t** decomp, - rtems_rtl_obj_cache_t* cache, - int fd, - int compression, - off_t offset); - -/** - * Lock the Run-time Linker. - * - * @return rtems_rtl_data_t* The RTL data after being locked. - * @retval NULL The RTL data could not be initialised or locked. Typically this - * means the lock could not be created. - */ -rtems_rtl_data_t* rtems_rtl_lock (void); - -/** - * Unlock the Run-time Linker. - * - * @return True The RTL is unlocked. - * @return False The RTL could not be unlocked. Not much you can do. - */ -bool rtems_rtl_unlock (void); - -/** - * Check a pointer is a valid object file descriptor returning the pointer as - * that type. - * - * Assumes the RTL has been locked. - * - * @param handle Pointer to the object file to be validated. - * @return rtl_obj* The object file descriptor. NULL is returned if invalid. - */ -rtems_rtl_obj_t* rtems_rtl_check_handle (void* handle); - -/** - * Find the object given a file name. - * - * @param name The name of the object file. - * @retval NULL No object file with that name found. - * @return rtems_rtl_obj_t* The object file descriptor. - */ -rtems_rtl_obj_t* rtems_rtl_find_obj (const char* name); - -/** - * Load an object file into memory relocating it. It will not be resolved - * against other symbols in other object files or the base image. - * - * The name can be a file name for an object file or it can be encoded to - * reference an archive of object modules (static library). This encoding is - * specific to RTEMS and allows dependences to specify an archive without the - * searching overhead normally incurred by linkers locating object files in an - * archive. The file name format rules are: - * - * 1. Absolute file references a specific object file in the architecture - * specific location on the file system. - * - * 2. Relative file references an object format file in the search path. - * - * 3. Absolute archive and file reference to a specific location in the file - * system. The archive and file are encoded as 'archive:file [@@offset]' - * where 'archive' is a valid file at the absolute path in the file system, - * and 'file' is a contained in the archive, and optionally an offset to - * the 'file' in the 'archive'. If no offset is provided the archive is - * searched. - * - * 4. Relative archive and file in the search path. The encoding is the same - * as described in item 3 of this list. - * - * Assumes the RTL has been locked. - * - * @param name The name of the object file. - * @param mode The mode of the load as defined by the dlopen call. - * @return rtl_obj* The object file descriptor. NULL is returned if the load fails. - */ -rtems_rtl_obj_t* rtems_rtl_load_object (const char* name, int mode); - -/** - * Unload an object file. This only happens when the user count is 0. - * - * Assumes the RTL has been locked. - * - * @param obj The object file descriptor. - * @retval true The object file has been unloaded. - * @retval false The object file could not be unloaded. - */ -bool rtems_rtl_unload_object (rtems_rtl_obj_t* obj); - -/** - * Run any constructor functions the object file may contain. This call - * assumes the linker is unlocked. - * - * @param obj The object file. - */ -void rtems_rtl_run_ctors (rtems_rtl_obj_t* obj); - -/** - * Get the last error message clearing it. This operation locks the run time - * linker and therefore keeps the RTL thread safe but this call is not thread - * safe is multiple threads are loading object files at the same time. This - * call is provided to map to the dlopen family of calls. - * - * @param message Pointer to a buffer to copy the message into. - * @param max_message The maximum message that can be copied. - * @return int The last error number. - */ -int rtems_rtl_get_error (char* message, size_t max_message); - -/** - * Append the path to the search path. - * - * @param path The path to append. - * @retval false The path could not be appended. - * @retval true The path was appended. - */ -bool rtems_rtl_path_append (const char* path); - -/** - * Prepend the path to the search path. - * - * @param path The path to prepend. - * @retval false The path could not be prepended. - * @retval true The path was prepended. - */ - -bool rtems_rtl_path_prepend (const char* path); - -/** - * Add an exported symbol table to the global symbol table. This call is - * normally used by an object file when loaded that contains a global symbol - * table. - * - * @param esyms The exported symbol table. - * @param count The size of the exported symbol table. - */ -void rtems_rtl_base_sym_global_add (const unsigned char* esyms, - unsigned int count); - -/** - * Return the object file descriptor for the base image. The object file - * descriptor returned is created when the run time linker is initialised. - * - * Assumes the RTL has been locked. - * - * @return rtl_obj* The object file descriptor for the base image. NULL is - * returned if the load fails. - */ -rtems_rtl_obj_t* rtems_rtl_baseimage (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/cpukit/libdrvmgr/drvmgr.h b/cpukit/libdrvmgr/drvmgr.h deleted file mode 100644 index cb8f4a5f5a..0000000000 --- a/cpukit/libdrvmgr/drvmgr.h +++ /dev/null @@ -1,988 +0,0 @@ -/* Driver Manager Interface. - * - * COPYRIGHT (c) 2009 Cobham Gaisler AB. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _DRIVER_MANAGER_H_ -#define _DRIVER_MANAGER_H_ - -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/*** Configure Driver manager ***/ - -/* Define the number of initialization levels of device drivers */ -#define DRVMGR_LEVEL_MAX 4 - -/* Default to use semahpores for protection. Initialization works without - * locks and after initialization too if devices are not removed. - */ -#ifndef DRVMGR_USE_LOCKS -#define DRVMGR_USE_LOCKS 1 -#endif - -struct drvmgr_dev; /* Device */ -struct drvmgr_bus; /* Bus */ -struct drvmgr_drv; /* Driver */ - -/*** List Interface shortcuts ***/ -#define BUS_LIST_HEAD(list) LIST_HEAD(list, struct drvmgr_bus) -#define BUS_LIST_TAIL(list) LIST_TAIL(list, struct drvmgr_bus) -#define DEV_LIST_HEAD(list) LIST_HEAD(list, struct drvmgr_dev) -#define DEV_LIST_TAIL(list) LIST_TAIL(list, struct drvmgr_dev) -#define DRV_LIST_HEAD(list) LIST_HEAD(list, struct drvmgr_drv) -#define DRV_LIST_TAIL(list) LIST_TAIL(list, struct drvmgr_drv) - -/*** Bus indentification ***/ -#define DRVMGR_BUS_TYPE_NONE 0 /* Not a valid bus */ -#define DRVMGR_BUS_TYPE_ROOT 1 /* Hard coded bus */ -#define DRVMGR_BUS_TYPE_PCI 2 /* PCI bus */ -#define DRVMGR_BUS_TYPE_AMBAPP 3 /* AMBA Plug & Play bus */ -#define DRVMGR_BUS_TYPE_LEON2_AMBA 4 /* LEON2 hardcoded bus */ -#define DRVMGR_BUS_TYPE_AMBAPP_DIST 5 /* Distibuted AMBA Plug & Play bus accessed using a communication interface */ -#define DRVMGR_BUS_TYPE_SPW_RMAP 6 /* SpaceWire Network bus */ -#define DRVMGR_BUS_TYPE_AMBAPP_RMAP 7 /* SpaceWire RMAP accessed AMBA Plug & Play bus */ - -enum { - DRVMGR_OBJ_NONE = 0, - DRVMGR_OBJ_DRV = 1, - DRVMGR_OBJ_BUS = 2, - DRVMGR_OBJ_DEV = 3, -}; - -/*** Driver indentification *** - * - * 64-bit identification integer definition - * * Bus ID 8-bit [7..0] - * * Reserved 8-bit field [63..56] - * * Device ID specific for bus type 48-bit [55..8] (Different buses have - * different unique identifications for hardware/driver.) - * - * ID Rules - * * A root bus driver must always have device ID set to 0. There can only by - * one root bus driver for a certain bus type. - * * A Driver ID must identify a unique hardware core - * - */ - -/* Bus ID Mask */ -#define DRIVER_ID_BUS_MASK 0x00000000000000FFULL - -/* Reserved Mask for future use */ -#define DRIVER_ID_RSV_MASK 0xFF00000000000000ULL - -/* Reserved Mask for future use */ -#define DRIVER_ID_DEV_MASK 0x00FFFFFFFFFFFF00ULL - -/* Set Bus ID Mask. */ -#define DRIVER_ID(busid, devid) ((unsigned long long) \ - ((((unsigned long long)(devid) << 8) & DRIVER_ID_DEV_MASK) | \ - ((unsigned long long)(busid) & DRIVER_ID_BUS_MASK))) - -/* Get IDs */ -#define DRIVER_BUSID_GET(id) ((unsigned long long)(id) & DRIVER_ID_BUS_MASK) -#define DRIVER_DEVID_GET(id) (((unsigned long long)(id) & DRIVER_ID_DEV_MASK) >> 8) - -#define DRIVER_ROOTBUS_ID(bus_type) DRIVER_ID(bus_type, 0) - -/*** Root Bus drivers ***/ - -/* Generic Hard coded Root bus: Driver ID */ -#define DRIVER_ROOT_ID DRIVER_ROOTBUS_ID(DRVMGR_BUS_TYPE_ROOT) - -/* PCI Plug & Play bus: Driver ID */ -#define DRIVER_PCIBUS_ID DRIVER_ROOTBUS_ID(DRVMGR_BUS_TYPE_PCI) - -/* AMBA Plug & Play bus: Driver ID */ -#define DRIVER_GRLIB_AMBAPP_ID DRIVER_ROOTBUS_ID(DRVMGR_BUS_TYPE_AMBAPP) - -/* AMBA Hard coded bus: Driver ID */ -#define DRIVER_LEON2_AMBA_ID DRIVER_ROOTBUS_ID(DRVMGR_BUS_TYPE_LEON2_AMBA) - -/* Distributed AMBA Plug & Play bus: Driver ID */ -#define DRIVER_AMBAPP_DIST_ID DRIVER_ROOTBUS_ID(DRVMGR_BUS_TYPE_AMBAPP_DIST) - -/*! Bus parameters used by driver interface functions to aquire information - * about bus. All Bus drivers should implement the operation 'get_params' so - * that the driver interface routines can access bus dependent information in - * an non-dependent way. - */ -struct drvmgr_bus_params { - char *dev_prefix; /*!< Optional name prefix */ -}; - -/* Interrupt Service Routine (ISR) */ -typedef void (*drvmgr_isr)(void *arg); - -/*! Bus operations */ -struct drvmgr_bus_ops { - /* Functions used internally within driver manager */ - int (*init[DRVMGR_LEVEL_MAX])(struct drvmgr_bus *); - int (*remove)(struct drvmgr_bus *); - int (*unite)(struct drvmgr_drv *, struct drvmgr_dev *); /*!< Unite Hardware Device with Driver */ - - /* Functions called indirectly from drivers */ - int (*int_register)(struct drvmgr_dev *, int index, const char *info, drvmgr_isr isr, void *arg); - int (*int_unregister)(struct drvmgr_dev *, int index, drvmgr_isr isr, void *arg); - int (*int_clear)(struct drvmgr_dev *, int index); - int (*int_mask)(struct drvmgr_dev *, int index); - int (*int_unmask)(struct drvmgr_dev *, int index); -#ifdef RTEMS_SMP - int (*int_set_affinity)(struct drvmgr_dev *, int index, - const Processor_mask *cpus); -#endif - - /* Get Parameters */ - int (*get_params)(struct drvmgr_dev *, struct drvmgr_bus_params *); - /* Get Frequency of Bus */ - int (*get_freq)(struct drvmgr_dev*, int, unsigned int*); - /*! Function called to request information about a device. The bus - * driver interpret the bus-specific information about the device. - */ - void (*get_info_dev)(struct drvmgr_dev *, - void (*print)(void *p, char *str), void *p); -}; -#define BUS_OPS_NUM (sizeof(struct drvmgr_bus_ops)/sizeof(void (*)(void))) - -struct drvmgr_func { - int funcid; - void *func; -}; -#define DRVMGR_FUNC(_ID_, _FUNC_) {(int)(_ID_), (void *)(_FUNC_)} -#define DRVMGR_FUNC_END {0, NULL} - -/*** Resource definitions *** - * - * Overview of structures: - * All bus resources entries (_bus_res) are linked together per bus - * (bus_info->reslist). One bus resource entry has a pointer to an array of - * driver resources (_drv_res). One driver resouces is made out of an array - * of keys (drvmgr_key). All keys belongs to the same driver and harwdare - * device. Each key has a Name, Type ID and Data interpreted differently - * depending on the Type ID (union drvmgr_key_value). - * - */ - -/* Key Data Types */ -enum drvmgr_kt { - DRVMGR_KT_ANY = -1, - DRVMGR_KT_NONE = 0, - DRVMGR_KT_INT = 1, - DRVMGR_KT_STRING = 2, - DRVMGR_KT_POINTER = 3, -}; - -#define DRVMGR_KEY_EMPTY {NULL, DRVMGR_KT_NONE, {0}} -#define DRVMGR_RES_EMPTY {0, 0, NULL} -#define MMAP_EMPTY {0, 0, 0} - -/*! Union of different values */ -union drvmgr_key_value { - unsigned int i; /*!< Key data type UNSIGNED INTEGER */ - char *str; /*!< Key data type STRING */ - void *ptr; /*!< Key data type ADDRESS/POINTER */ -}; - -/* One key. One Value. Holding information relevant to the driver. */ -struct drvmgr_key { - char *key_name; /* Name of key */ - enum drvmgr_kt key_type; /* How to interpret key_value */ - union drvmgr_key_value key_value; /* The value or pointer to value */ -}; - -/*! Driver resource entry, Driver resources for a certain device instance, - * containing a number of keys where each key hold the data of interest. - */ -struct drvmgr_drv_res { - uint64_t drv_id; /*!< Identifies the driver this resource is aiming */ - int minor_bus; /*!< Indentifies a specfic device */ - struct drvmgr_key *keys; /*!< First key in key array, ended with KEY_EMPTY */ -}; - -/*! Bus resource list node */ -struct drvmgr_bus_res { - struct drvmgr_bus_res *next; /*!< Next resource node in list */ - struct drvmgr_drv_res resource[]; /*!< Array of resources, one per device instance */ -}; - -/*! MAP entry. Describes an linear address space translation. Untranslated - * Start, Translated Start and length. - * - * Used by bus drivers to describe the address translation needed for - * the translation driver interface. - */ -struct drvmgr_map_entry { - char *name; /*!< Map Name */ - unsigned int size; /*!< Size of map window */ - char *from_adr; /*!< Start address of access window used - * to reach into remote bus */ - char *to_adr; /*!< Start address of remote system - * address range */ -}; -#define DRVMGR_TRANSLATE_ONE2ONE NULL -#define DRVMGR_TRANSLATE_NO_BRIDGE ((void *)1) /* No bridge, error */ - -/*! Bus information. Describes a bus. */ -struct drvmgr_bus { - int obj_type; /*!< DRVMGR_OBJ_BUS */ - unsigned char bus_type; /*!< Type of bus */ - unsigned char depth; /*!< Bus level distance from root bus */ - struct drvmgr_bus *next; /*!< Next Bus */ - struct drvmgr_dev *dev; /*!< Bus device, the hardware... */ - void *priv; /*!< Private data structure used by BUS driver */ - struct drvmgr_dev *children; /*!< Hardware devices on this bus */ - struct drvmgr_bus_ops *ops; /*!< Bus operations supported by this bus driver */ - struct drvmgr_func *funcs; /*!< Extra operations */ - int dev_cnt; /*!< Number of devices this bus has */ - struct drvmgr_bus_res *reslist; /*!< Bus resources, head of a linked list of resources. */ - struct drvmgr_map_entry *maps_up; /*!< Map Translation, array of address spaces upstreams to CPU */ - struct drvmgr_map_entry *maps_down; /*!< Map Translation, array of address spaces downstreams to Hardware */ - - /* Bus status */ - int level; /*!< Initialization Level of Bus */ - int state; /*!< Init State of Bus, BUS_STATE_* */ - int error; /*!< Return code from bus->ops->initN() */ -}; - -/* States of a bus */ -#define BUS_STATE_INIT_FAILED 0x00000001 /* Initialization Failed */ -#define BUS_STATE_LIST_INACTIVE 0x00001000 /* In inactive bus list */ -#define BUS_STATE_DEPEND_FAILED 0x00000004 /* Device init failed */ - -/* States of a device */ -#define DEV_STATE_INIT_FAILED 0x00000001 /* Initialization Failed */ -#define DEV_STATE_INIT_DONE 0x00000002 /* All init levels completed */ -#define DEV_STATE_DEPEND_FAILED 0x00000004 /* Parent Bus init failed */ -#define DEV_STATE_UNITED 0x00000100 /* Device United with Device Driver */ -#define DEV_STATE_REMOVED 0x00000200 /* Device has been removed (unregistered) */ -#define DEV_STATE_IGNORED 0x00000400 /* Device was ignored according to user's request, the device - * was never reported to it's driver (as expected). - */ -#define DEV_STATE_LIST_INACTIVE 0x00001000 /* In inactive device list */ - -/*! Device information */ -struct drvmgr_dev { - int obj_type; /*!< DRVMGR_OBJ_DEV */ - struct drvmgr_dev *next; /*!< Next device */ - struct drvmgr_dev *next_in_bus; /*!< Next device on the same bus */ - struct drvmgr_dev *next_in_drv; /*!< Next device using the same driver */ - - struct drvmgr_drv *drv; /*!< The driver owning this device */ - struct drvmgr_bus *parent; /*!< Bus that this device resides on */ - short minor_drv; /*!< Device number within driver */ - short minor_bus; /*!< Device number on bus (for device separation) */ - char *name; /*!< Name of Device Hardware */ - void *priv; /*!< Pointer to driver private device structure */ - void *businfo; /*!< Host bus specific information */ - struct drvmgr_bus *bus; /*!< Pointer to bus, set only if this is a bridge */ - - /* Device Status */ - unsigned int state; /*!< State of device, see DEV_STATE_* */ - int level; /*!< Init Level */ - int error; /*!< Error state returned by driver */ -}; - -/*! Driver operations, function pointers. */ -struct drvmgr_drv_ops { - int (*init[DRVMGR_LEVEL_MAX])(struct drvmgr_dev *); /*! Function doing Init Stage 1 of a hardware device */ - int (*remove)(struct drvmgr_dev *); /*! Function called when device instance is to be removed */ - int (*info)(struct drvmgr_dev *, void (*print)(void *p, char *str), void *p, int, char *argv[]);/*! Function called to request information about a device or driver */ -}; -#define DRVMGR_OPS_NUM(x) (sizeof(x)/sizeof(void (*)(void))) - -/*! Device driver description */ -struct drvmgr_drv { - int obj_type; /*!< DRVMGR_OBJ_DRV */ - struct drvmgr_drv *next; /*!< Next Driver */ - struct drvmgr_dev *dev; /*!< Devices using this driver */ - - uint64_t drv_id; /*!< Unique Driver ID */ - char *name; /*!< Name of Driver */ - int bus_type; /*!< Type of Bus this driver supports */ - struct drvmgr_drv_ops *ops; /*!< Driver operations */ - struct drvmgr_func *funcs; /*!< Extra Operations */ - unsigned int dev_cnt; /*!< Number of devices in dev */ - unsigned int dev_priv_size; /*!< If non-zero DRVMGR will allocate memory for dev->priv */ -}; - -/*! Structure defines a function pointer called when driver manager is ready - * for drivers to register themselfs. Used to select drivers available to the - * driver manager. - */ -typedef void (*drvmgr_drv_reg_func)(void); - -/*** DRIVER | DEVICE | BUS FUNCTIONS ***/ - -/* Return Codes */ -enum { - DRVMGR_OK = 0, /* Sucess */ - DRVMGR_NOMEM = 1, /* Memory allocation error */ - DRVMGR_EIO = 2, /* I/O error */ - DRVMGR_EINVAL = 3, /* Invalid parameter */ - DRVMGR_ENOSYS = 4, - DRVMGR_TIMEDOUT = 5, /* Operation timeout error */ - DRVMGR_EBUSY = 6, - DRVMGR_ENORES = 7, /* Not enough resources */ - DRVMGR_FAIL = -1 /* Unspecified failure */ -}; - -/*! Initialize data structures of the driver management system. - * Calls predefined register driver functions so that drivers can - * register themselves. - */ -extern void _DRV_Manager_initialization(void); - -/*! Take all devices into init level 'level', all devices registered later - * will directly be taken into this level as well, ensuring that all - * registerd devices has been taken into the level. - * - */ -extern void _DRV_Manager_init_level(int level); - -/*! This function must be defined by the BSP when the driver manager is enabled - * and initialized during BSP initialization. The function is called after a - * init level is reached the first time by the driver manager. - */ -extern void bsp_driver_level_hook(int level); - -/*! Init driver manager all in one go, will call _DRV_Manager_initialization(), - * then _DRV_Manager_init_level([1..DRVMGR_LEVEL_MAX]). - * Typically called from Init task when user wants to initilize driver - * manager after startup, otherwise not used. - */ -extern int drvmgr_init(void); - -/* Take registered buses and devices into the correct init level, - * this function is called from _init_level() so normally - * we don't need to call it directly. - */ -extern void drvmgr_init_update(void); - -/*! Register Root Bus device driver */ -extern int drvmgr_root_drv_register(struct drvmgr_drv *drv); - -/*! Register a driver */ -extern int drvmgr_drv_register(struct drvmgr_drv *drv); - -/*! Register a device */ -extern int drvmgr_dev_register(struct drvmgr_dev *dev); - -/*! Remove a device, and all its children devices if device is a bus device. The - * device driver will be requested to remove the device and once gone from bus, - * device and driver list the device is put into a inactive list for debugging - * (this is optional by using remove argument). - * - * Removing the Root Bus Device is not supported. - * - * \param remove If non-zero the device will be deallocated, and not put into - * the inacitve list. - */ -extern int drvmgr_dev_unregister(struct drvmgr_dev *dev); - -/*! Register a bus */ -extern int drvmgr_bus_register(struct drvmgr_bus *bus); - -/*! Unregister a bus */ -extern int drvmgr_bus_unregister(struct drvmgr_bus *bus); - -/*! Unregister all child devices of a bus. - * - * This function is called from the bus driver, from a "safe" state where - * devices will not be added or removed on this particular bus at this time - */ -extern int drvmgr_children_unregister(struct drvmgr_bus *bus); - -/* Separate a device from the driver it has been united with */ -extern int drvmgr_dev_drv_separate(struct drvmgr_dev *dev); - -/*! Allocate a device structure, if no memory available - * rtems_error_fatal_occurred is called. - * The 'extra' argment tells how many bytes extra space is to be allocated after - * the device structure, this is typically used for "businfo" structures. The extra - * space is always aligned to a 4-byte boundary. - */ -extern int drvmgr_alloc_dev(struct drvmgr_dev **pdev, int extra); - -/*! Allocate a bus structure, if no memory available rtems_error_fatal_occurred - * is called. - * The 'extra' argment tells how many bytes extra space is to be allocated after - * the device structure, this is typically used for "businfo" structures. The - * extra space is always aligned to a 4-byte boundary. - */ -extern int drvmgr_alloc_bus(struct drvmgr_bus **pbus, int extra); - -/*** DRIVER RESOURCE FUNCTIONS ***/ - -/*! Add resources to a bus, typically used by a bus driver. - * - * \param bus The Bus to add the resources to. - * \param res An array with Driver resources, all together are called bus - * resources. - */ -extern void drvmgr_bus_res_add(struct drvmgr_bus *bus, - struct drvmgr_bus_res *bres); - -/*! Find all the resource keys for a device among all driver resources on a - * bus. Typically used by a device driver to get configuration options. - * - * \param dev Device to find resources for - * \param key Location where the pointer to the driver resource array (drvmgr_drv_res->keys) is stored. - */ -extern int drvmgr_keys_get(struct drvmgr_dev *dev, struct drvmgr_key **keys); - -/*! Return the one key that matches key name from a driver keys array. The keys - * can be obtained using drvmgr_keys_get(). - * - * \param keys An array of keys ended with DRVMGR_KEY_EMPTY to search among. - * \param key_name Name of key to search for among the keys. - */ -extern struct drvmgr_key *drvmgr_key_get(struct drvmgr_key *keys, char *key_name); - -/*! Extract key value from the key in the keys array matching name and type. - * - * This function calls drvmgr_keys_get to get the key requested (from key - * name), then determines if the type is correct. A pointer to the key value - * is returned. - * - * \param keys An array of keys ended with DRVMGR_KEY_EMPTY to search among. - * \param key_name Name of key to search for among the keys. - * \param key_type Data Type of value. INTEGER, ADDRESS, STRING. - * \return Returns NULL if no value found matching Key Name and Key - * Type. - */ -extern union drvmgr_key_value *drvmgr_key_val_get( - struct drvmgr_key *keys, - char *key_name, - enum drvmgr_kt key_type); - -/*! Get key value from the bus resources matching [device, key name, key type] - * if no matching key is found NULL is returned. - * - * This is typically used by device drivers to find a particular device - * resource. - * - * \param dev The device to search resource for. - * \param key_name The key name to search for - * \param key_type The key type expected. - * \return Returns NULL if no value found matching Key Name and - * Key Type was found for device. - */ -extern union drvmgr_key_value *drvmgr_dev_key_get( - struct drvmgr_dev *dev, - char *key_name, - enum drvmgr_kt key_type); - -/*** DRIVER INTERACE USED TO REQUEST INFORMATION/SERVICES FROM BUS DRIVER ***/ - -/*! Get parent bus */ -RTEMS_INLINE_ROUTINE struct drvmgr_bus *drvmgr_get_parent( - struct drvmgr_dev *dev) -{ - if (dev) - return dev->parent; - else - return NULL; -} - -/*! Get Driver of device */ -RTEMS_INLINE_ROUTINE struct drvmgr_drv *drvmgr_get_drv(struct drvmgr_dev *dev) -{ - if (dev) - return dev->drv; - else - return NULL; -} - -/*! Calls func() for every device found in the device tree, regardless of - * device state or if a driver is assigned. With the options argument the user - * can decide to do either a depth-first or a breadth-first search. - * - * If the function func() returns a non-zero value then for_each_dev will - * return imediatly with the same return value as func() returned. - * - * \param func Function called on each device - * \param arg Custom function argument - * \param options Search Options, see DRVMGR_FED_* - * - */ -#define DRVMGR_FED_BF 1 /* Breadth-first search */ -#define DRVMGR_FED_DF 0 /* Depth first search */ -extern int drvmgr_for_each_dev( - int (*func)(struct drvmgr_dev *dev, void *arg), - void *arg, - int options); - -/*! Get Device pointer from Driver and Driver minor number - * - * \param drv Driver the device is united with. - * \param minor Driver minor number assigned to device. - * \param pdev Location where the Device point will be stored. - * \return Zero on success. -1 on failure, when device was not - * found in driver device list. - */ -extern int drvmgr_get_dev( - struct drvmgr_drv *drv, - int minor, - struct drvmgr_dev **pdev); - -/*! Get Bus frequency in Hertz. Frequency is stored into address of freq_hz. - * - * \param dev The Device to get Bus frequency for. - * \param options Bus-type specific options - * \param freq_hz Location where Bus Frequency will be stored. - */ -extern int drvmgr_freq_get( - struct drvmgr_dev *dev, - int options, - unsigned int *freq_hz); - -/*! Return 0 if dev is not located on the root bus, 1 if on root bus */ -extern int drvmgr_on_rootbus(struct drvmgr_dev *dev); - -/*! Get device name prefix, this name can be used to register a unique name in - * the bus->error filesystem or to get an idea where the device is located. - * - * \param dev The Device to get the device Prefix for. - * \param dev_prefix Location where the prefix will be stored. - */ -extern int drvmgr_get_dev_prefix(struct drvmgr_dev *dev, char *dev_prefix); - -/*! Register a shared interrupt handler. Since this service is shared among - * interrupt drivers/handlers the handler[arg] must be installed before the - * interrupt can be cleared or disabled. The handler is by default disabled - * after registration. - * - * \param index Index is used to identify the IRQ number if hardware has - * multiple IRQ sources. Normally Index is set to 0 to - * indicated the first and only IRQ source. - * A negative index is interpreted as a absolute bus IRQ - * number. - * \param isr Interrupt Service Routine. - * \param arg Optional ISR argument. - */ -extern int drvmgr_interrupt_register( - struct drvmgr_dev *dev, - int index, - const char *info, - drvmgr_isr isr, - void *arg); - -/*! Unregister an interrupt handler. This also disables the interrupt before - * unregistering the interrupt handler. - * \param index Index is used to identify the IRQ number if hardware has - * multiple IRQ sources. Normally Index is set to 0 to - * indicated the first and only IRQ source. - * A negative index is interpreted as a absolute bus IRQ - * number. - * \param isr Interrupt Service Routine, previously registered. - * \param arg Optional ISR argument, previously registered. - */ -extern int drvmgr_interrupt_unregister( - struct drvmgr_dev *dev, - int index, - drvmgr_isr isr, - void *arg); - -/*! Clear (ACK) pending interrupt - * - * \param dev Device to clear interrupt for. - * \param index Index is used to identify the IRQ number if hardware has multiple IRQ sources. - * Normally Index is set to 0 to indicated the first and only IRQ source. - * A negative index is interpreted as a absolute bus IRQ number. - * \param isr Interrupt Service Routine, previously registered. - * \param arg Optional ISR argument, previously registered. - */ -extern int drvmgr_interrupt_clear( - struct drvmgr_dev *dev, - int index); - -/*! Force unmasking/enableing an interrupt on the interrupt controller, this is not normally used, - * if used the caller has masked/disabled the interrupt just before. - * - * \param dev Device to clear interrupt for. - * \param index Index is used to identify the IRQ number if hardware has multiple IRQ sources. - * Normally Index is set to 0 to indicated the first and only IRQ source. - * A negative index is interpreted as a absolute bus IRQ number. - * \param isr Interrupt Service Routine, previously registered. - * \param arg Optional ISR argument, previously registered. - */ -extern int drvmgr_interrupt_unmask( - struct drvmgr_dev *dev, - int index); - -/*! Force masking/disable an interrupt on the interrupt controller, this is not normally performed - * since this will stop all other (shared) ISRs to be disabled until _unmask() is called. - * - * \param dev Device to mask interrupt for. - * \param index Index is used to identify the IRQ number if hardware has multiple IRQ sources. - * Normally Index is set to 0 to indicated the first and only IRQ source. - * A negative index is interpreted as a absolute bus IRQ number. - */ -extern int drvmgr_interrupt_mask( - struct drvmgr_dev *dev, - int index); - -/*! Force masking/disable an interrupt on the interrupt controller, this is not normally performed - * since this will stop all other (shared) ISRs to be disabled until _unmask() is called. - * - * \param dev Device to mask interrupt for. - * \param index Index is used to identify the IRQ number if hardware has multiple IRQ sources. - * Normally Index is set to 0 to indicated the first and only IRQ source. - * A negative index is interpreted as a absolute bus IRQ number. - */ -#ifdef RTEMS_SMP -extern int drvmgr_interrupt_set_affinity( - struct drvmgr_dev *dev, - int index, - const Processor_mask *cpus); -#endif - -/*! drvmgr_translate() translation options */ -enum drvmgr_tr_opts { - /* Translate CPU RAM Address (input) to DMA unit accessible address - * (output), this is an upstreams translation in reverse order. - * - * Typical Usage: - * It is common to translate a CPU accessible RAM address to an - * address that DMA units can access over bridges. - */ - CPUMEM_TO_DMA = 0x0, - - /* Translate DMA Unit Accessible address mapped to CPU RAM (input) to - * CPU accessible address (output). This is an upstreams translation. - * - * Typical Usage (not often used): - * The DMA unit descriptors contain pointers to DMA buffers located at - * CPU RAM addresses that the DMA unit can access, the CPU processes - * the descriptors and want to access the data but a translation back - * to CPU address is required. - */ - CPUMEM_FROM_DMA = 0x1, - - /* Translate DMA Memory Address (input) to CPU accessible address - * (output), this is a downstreams translation in reverse order. - * - * Typical Usage: - * A PCI network card puts packets into its memory not doing DMA over - * PCI, in order for the CPU to access them the PCI address must be - * translated. - */ - DMAMEM_TO_CPU = 0x2, - - /* Translate CPU accessible address (input) mapped to DMA Memory Address - * to DMA Unit accessible address (output). This is a downstreams - * translation. - */ - DMAMEM_FROM_CPU = 0x3, -}; -#define DRVMGR_TR_REVERSE 0x1 /* do reverse translation direction order */ -#define DRVMGR_TR_PATH 0x2 /* 0x0=down-stream 0x2=up-stream address path */ - -/*! Translate an address on one bus to an address on another bus. - * - * The device determines source or destination bus, the root bus is always - * the other bus. It is assumed that the CPU is located on the root bus or - * that it can access it without address translation (mapped 1:1). The CPU - * is thus assumed to be located on level 0 top most in the bus hierarchy. - * - * If no map is present in the bus driver src_address is translated 1:1 - * (just copied). - * - * Addresses are typically converted up-streams from the DMA unit towards the - * CPU (DMAMEM_TO_CPU) or down-streams towards DMA hardware from the CPU - * (CPUMEM_TO_DMA) over one or multiple bridges depending on bus architecture. - * See 'enum drvmgr_tr_opts' for other translation direction options. - * For example: - * Two common operations is to translate a CPU accessible RAM address to an - * address that DMA units can access (dev=DMA-unit, CPUMEM_TO_DMA, - * src_address=CPU-RAM-ADR) and to translate an address of a PCI resource for - * example RAM mapped into a PCI BAR to an CPU accessible address - * (dev=PCI-device, DMAMEM_TO_CPU, src_address=PCI-BAR-ADR). - * - * Source address is translated and the result is put into *dst_address, if - * the address is not accessible on the other bus -1 is returned. - * - * \param dev Device to translate addresses for - * \param options Tanslation direction options, see enum drvmgr_tr_opts - * \param src_address Address to translate - * \param dst_address Location where translated address is stored - * - * Returns 0 if unable to translate. The remaining length from the given - * address of the map is returned on success, for example if a map starts - * at 0x40000000 of size 0x100000 the result will be 0x40000 if the address - * was translated into 0x400C0000. - * If dev is on root-bus no translation is performed 0xffffffff is returned - * and src_address is stored in *dst_address. - */ -extern unsigned int drvmgr_translate( - struct drvmgr_dev *dev, - unsigned int options, - void *src_address, - void **dst_address); - -/* Translate addresses between buses, used internally to implement - * drvmgr_translate. Function is not limited to translate from/to root bus - * where CPU is resident, however buses must be on a straight path relative - * to each other (parent of parent of parent and so on). - * - * \param from src_address is given for this bus - * \param to src_address is translated to this bus - * \param reverse Selects translation method, if map entries are used in - * the reverse order (map_up->to is used as map_up->from) - * \param src_address Address to be translated - * \param dst_address Translated address is stored here on success (return=0) - * - * Returns 0 if unable to translate. The remaining length from the given - * address of the map is returned on success and the result is stored into - * *dst_address. For example if a map starts at 0x40000000 of size 0x100000 - * the result will be 0x40000 if the address was translated into 0x400C0000. - * If dev is on root-bus no translation is performed 0xffffffff is returned. - * and src_address is stored in *dst_address. - */ -extern unsigned int drvmgr_translate_bus( - struct drvmgr_bus *from, - struct drvmgr_bus *to, - int reverse, - void *src_address, - void **dst_address); - -/* Calls drvmgr_translate() to translate an address range and checks the result, - * a printout is generated if the check fails. All parameters are passed on to - * drvmgr_translate() except for size, see paramters of drvmgr_translate(). - * - * If size=0 only the starting address is not checked. - * - * If mapping failes a non-zero result is returned. - */ -extern int drvmgr_translate_check( - struct drvmgr_dev *dev, - unsigned int options, - void *src_address, - void **dst_address, - unsigned int size); - -/*! Get function pointer from Device Driver or Bus Driver. - * - * Returns 0 if function is available - */ -extern int drvmgr_func_get(void *obj, int funcid, void **func); - -/*! Lookup function and call it directly with the four optional arguments */ -extern int drvmgr_func_call(void *obj, int funcid, void *a, void *b, void *c, void *d); - -/* Builds a Function ID. - * - * Used to request optional functions by a bus or device driver - */ -#define DRVMGR_FUNCID(major, minor) ((((major) & 0xfff) << 20) | ((minor) & 0xfffff)) -#define DRVMGR_FUNCID_NONE 0 -#define DRVMGR_FUNCID_END DRVMGR_FUNCID(DRVMGR_FUNCID_NONE, 0) - -/* Major Function ID. Most significant 12-bits. */ -enum { - FUNCID_NONE = 0x000, - FUNCID_RW = 0x001, /* Read/Write functions */ -}; - -/* Select Sub-Function Read/Write function by ID */ -#define RW_SIZE_1 0x00001 /* Access Size */ -#define RW_SIZE_2 0x00002 -#define RW_SIZE_4 0x00004 -#define RW_SIZE_8 0x00008 -#define RW_SIZE_ANY 0x00000 -#define RW_SIZE(id) ((unsigned int)(id) & 0xf) - -#define RW_DIR_ANY 0x00000 /* Access Direction */ -#define RW_READ 0x00000 /* Read */ -#define RW_WRITE 0x00010 /* Write */ -#define RW_SET 0x00020 /* Write with same value (memset) */ -#define RW_DIR(id) (((unsigned int)(id) >> 4) & 0x3) - -#define RW_RAW 0x00000 /* Raw access - no swapping (machine default) */ -#define RW_LITTLE 0x00040 /* Little Endian */ -#define RW_BIG 0x00080 /* Big Endian */ -#define RW_ENDIAN(id) (((unsigned int)(id) >> 6) & 0x3) - -#define RW_TYPE_ANY 0x00000 /* Access type */ -#define RW_REG 0x00100 -#define RW_MEM 0x00200 -#define RW_MEMREG 0x00300 -#define RW_CFG 0x00400 -#define RW_TYPE(id) (((unsigned int)(id) >> 8) & 0xf) - -#define RW_ARG 0x01000 /* Optional Argument */ -#define RW_ERR 0x02000 /* Optional Error Handler */ - -/* Build a Read/Write function ID */ -#define DRVMGR_RWFUNC(minor) DRVMGR_FUNCID(FUNCID_RW, minor) - -/* Argument to Read/Write functions, the "void *arg" pointer is returned by - * RW_ARG. If NULL is returned no argument is needed. - */ -struct drvmgr_rw_arg { - void *arg; - struct drvmgr_dev *dev; -}; - -/* Standard Read/Write function types */ -typedef uint8_t (*drvmgr_r8)(uint8_t *srcadr); -typedef uint16_t (*drvmgr_r16)(uint16_t *srcadr); -typedef uint32_t (*drvmgr_r32)(uint32_t *srcadr); -typedef uint64_t (*drvmgr_r64)(uint64_t *srcadr); -typedef void (*drvmgr_w8)(uint8_t *dstadr, uint8_t data); -typedef void (*drvmgr_w16)(uint16_t *dstadr, uint16_t data); -typedef void (*drvmgr_w32)(uint32_t *dstadr, uint32_t data); -typedef void (*drvmgr_w64)(uint64_t *dstadr, uint64_t data); -/* READ/COPY a memory area located on bus into CPU memory. - * From 'src' (remote) to the destination 'dest' (local), n=number of bytes - */ -typedef int (*drvmgr_rmem)(void *dest, const void *src, int n); -/* WRITE/COPY a user buffer located in CPU memory to a location on the bus. - * From 'src' (local) to the destination 'dest' (remote), n=number of bytes - */ -typedef int (*drvmgr_wmem)(void *dest, const void *src, int n); -/* Set a memory area to the byte value given in c, see LIBC memset(). Memset is - * implemented by calling wmem() multiple times with a "large" buffer. - */ -typedef int (*drvmgr_memset)(void *dstadr, int c, size_t n); - -/* Read/Write function types with additional argument */ -typedef uint8_t (*drvmgr_r8_arg)(uint8_t *srcadr, void *a); -typedef uint16_t (*drvmgr_r16_arg)(uint16_t *srcadr, void *a); -typedef uint32_t (*drvmgr_r32_arg)(uint32_t *srcadr, void *a); -typedef uint64_t (*drvmgr_r64_arg)(uint64_t *srcadr, void *a); -typedef void (*drvmgr_w8_arg)(uint8_t *dstadr, uint8_t data, void *a); -typedef void (*drvmgr_w16_arg)(uint16_t *dstadr, uint16_t data, void *a); -typedef void (*drvmgr_w32_arg)(uint32_t *dstadr, uint32_t data, void *a); -typedef void (*drvmgr_w64_arg)(uint64_t *dstadr, uint64_t data, void *a); -typedef int (*drvmgr_rmem_arg)(void *dest, const void *src, int n, void *a); -typedef int (*drvmgr_wmem_arg)(void *dest, const void *src, int n, void *a); -typedef int (*drvmgr_memset_arg)(void *dstadr, int c, size_t n, void *a); - -/* Report an error to the parent bus of the device */ -typedef void (*drvmgr_rw_err)(struct drvmgr_rw_arg *a, struct drvmgr_bus *bus, - int funcid, void *adr); - -/* Helper function for buses that implement the memset() over wmem() */ -extern void drvmgr_rw_memset( - void *dstadr, - int c, - size_t n, - void *a, - drvmgr_wmem_arg wmem - ); - -/*** PRINT INFORMATION ABOUT DRIVER MANAGER ***/ - -/*! Calls func() for every device found matching the search requirements of - * set_mask and clr_mask. Each bit set in set_mask must be set in the - * device state bit mask (dev->state), and Each bit in the clr_mask must - * be cleared in the device state bit mask (dev->state). There are three - * special cases: - * - * 1. If state_set_mask and state_clr_mask are zero the state bits are - * ignored and all cores are treated as a match. - * - * 2. If state_set_mask is zero the function func will not be called due to - * a bit being set in the state mask. - * - * 3. If state_clr_mask is zero the function func will not be called due to - * a bit being cleared in the state mask. - * - * If the function func() returns a non-zero value then for_each_dev will - * return imediatly with the same return value as func() returned. - * - * \param devlist The list to iterate though searching for devices. - * \param state_set_mask Defines the bits that must be set in dev->state - * \param state_clr_mask Defines the bits that must be cleared in dev->state - * \param func Function called on each - * - */ -extern int drvmgr_for_each_listdev( - struct drvmgr_list *devlist, - unsigned int state_set_mask, - unsigned int state_clr_mask, - int (*func)(struct drvmgr_dev *dev, void *arg), - void *arg); - -/* Print all devices */ -#define PRINT_DEVS_FAILED 0x01 /* Failed during initialization */ -#define PRINT_DEVS_ASSIGNED 0x02 /* Driver assigned */ -#define PRINT_DEVS_UNASSIGNED 0x04 /* Driver not assigned */ -#define PRINT_DEVS_IGNORED 0x08 /* Device ignored on user's request */ -#define PRINT_DEVS_ALL (PRINT_DEVS_FAILED | \ - PRINT_DEVS_ASSIGNED | \ - PRINT_DEVS_UNASSIGNED |\ - PRINT_DEVS_IGNORED) - -/*! Print number of devices, buses and drivers */ -extern void drvmgr_summary(void); - -/*! Print devices with certain condictions met according to 'options' */ -extern void drvmgr_print_devs(unsigned int options); - -/*! Print device/bus topology */ -extern void drvmgr_print_topo(void); - -/*! Print the memory usage - * Only accounts for data structures. Not for the text size. - */ -extern void drvmgr_print_mem(void); - -#define OPTION_DEV_GENINFO 0x00000001 -#define OPTION_DEV_BUSINFO 0x00000002 -#define OPTION_DEV_DRVINFO 0x00000004 -#define OPTION_DRV_DEVS 0x00000100 -#define OPTION_BUS_DEVS 0x00010000 -#define OPTION_RECURSIVE 0x01000000 -#define OPTION_INFO_ALL 0xffffffff - -/*! Print information about a driver manager object (device, driver, bus) */ -extern void drvmgr_info(void *id, unsigned int options); - -/*! Get information about a device */ -extern void drvmgr_info_dev(struct drvmgr_dev *dev, unsigned int options); - -/*! Get information about a bus */ -extern void drvmgr_info_bus(struct drvmgr_bus *bus, unsigned int options); - -/*! Get information about a driver */ -extern void drvmgr_info_drv(struct drvmgr_drv *drv, unsigned int options); - -/*! Get information about all devices on a bus */ -extern void drvmgr_info_devs_on_bus(struct drvmgr_bus *bus, unsigned int options); - -/*! Get information about all devices in the system (on all buses) */ -extern void drvmgr_info_devs(unsigned int options); - -/*! Get information about all drivers in the system */ -extern void drvmgr_info_drvs(unsigned int options); - -/*! Get information about all buses in the system */ -extern void drvmgr_info_buses(unsigned int options); - -/*! Get Driver by Driver ID */ -extern struct drvmgr_drv *drvmgr_drv_by_id(uint64_t id); - -/*! Get Driver by Driver Name */ -extern struct drvmgr_drv *drvmgr_drv_by_name(const char *name); - -/*! Get Device by Device Name */ -extern struct drvmgr_dev *drvmgr_dev_by_name(const char *name); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/libdrvmgr/drvmgr_confdefs.h b/cpukit/libdrvmgr/drvmgr_confdefs.h deleted file mode 100644 index 82829bd8aa..0000000000 --- a/cpukit/libdrvmgr/drvmgr_confdefs.h +++ /dev/null @@ -1,258 +0,0 @@ -/* Driver Manager Configuration file. - * - * COPYRIGHT (c) 2009 Cobham Gaisler AB. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -/* - * The configuration consist of an array with function pointers that - * register one or more drivers that will be used by the Driver Manger. - * - * The Functions are called in the order they are declared. - * - */ - -#ifndef _DRIVER_MANAGER_CONFDEFS_H_ -#define _DRIVER_MANAGER_CONFDEFS_H_ - -#include "drvmgr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -extern drvmgr_drv_reg_func drvmgr_drivers[]; - -#ifdef CONFIGURE_INIT - -/*** AMBA Plug & Play Drivers ***/ -extern void gptimer_register_drv(void); -extern void apbuart_cons_register_drv(void); -extern void greth_register_drv(void); -extern void grspw_register_drv(void); -extern void grspw2_register_drv(void); -extern void grcan_register_drv(void); -extern void occan_register_drv(void); -extern void gr1553_register(void); -extern void gr1553bc_register(void); -extern void gr1553bm_register(void); -extern void gr1553rt_register(void); -extern void b1553brm_register_drv(void); -extern void b1553rt_register_drv(void); -extern void grtm_register_drv(void); -extern void grtc_register_drv(void); -extern void pcif_register_drv(void); -extern void grpci_register_drv(void); -extern void mctrl_register_drv(void); -extern void l2cache_register_drv(void); -extern void griommu_register_drv(void); -extern void grpci2_register_drv(void); -extern void spictrl_register_drv(void); -extern void i2cmst_register_drv(void); -extern void grgpio_register_drv(void); -extern void grpwm_register_drv(void); -extern void gradcdac_register_drv(void); -extern void spwcuc_register(void); -extern void grctm_register(void); -extern void router_register_drv(void); -extern void ahbstat_register_drv(void); -extern void memscrub_register_drv(void); -extern void l4stat_register_drv(void); - - -/*** LEON2 AMBA Hard coded bus Drivers ***/ -extern void at697pci_register_drv(void); -extern void ambapp_leon2_register(void); - - -/*** PCI Bus Drivers (PCI Target drivers) ***/ -extern void gr_rasta_adcdac_register_drv(void); -extern void gr_rasta_io_register_drv(void); -extern void gr_rasta_tmtc_register_drv(void); -extern void gr701_register_drv(void); -extern void gr_tmtc_1553_register_drv(void); -extern void gr_rasta_spw_router_register_drv(void); -extern void gr_cpci_leon4_n2x_register_drv(void); -extern void gr_cpci_gr740_register_drv(void); - - -/* CONFIGURE DRIVER MANAGER */ -drvmgr_drv_reg_func drvmgr_drivers[] = { - /*** AMBA Plug & Play Drivers ***/ -#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER - gptimer_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART - apbuart_cons_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRETH - greth_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW - grspw_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW2 - grspw2_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRCAN - grcan_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_OCCAN - occan_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GR1553B - gr1553_register, -#endif -#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GR1553BC - gr1553bc_register, -#endif -#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GR1553BM - gr1553bm_register, -#endif -#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GR1553RT - gr1553rt_register, -#endif -#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_B1553BRM - b1553brm_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_B1553RT - b1553rt_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRTM - grtm_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRTC - grtc_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_PCIF - pcif_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRPCI - grpci_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRPCI2 - grpci2_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_AMBAPP_MCTRL - mctrl_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_L2CACHE - l2cache_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRIOMMU - griommu_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_SPICTRL - spictrl_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_I2CMST - i2cmst_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRGPIO - grgpio_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRPWM - grpwm_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRADCDAC - gradcdac_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_SPWCUC - spwcuc_register, -#endif -#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_GRCTM - grctm_register, -#endif -#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_SPW_ROUTER - router_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_AHBSTAT - ahbstat_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_MEMSCRUB - memscrub_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_AMBAPP_GAISLER_L4STAT - l4stat_register_drv, -#endif - - /*** LEON2 AMBA Drivers ***/ -#ifdef CONFIGURE_DRIVER_LEON2_AT697PCI - at697pci_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_LEON2_AMBAPP - ambapp_leon2_register, -#endif - - /*** PCI Target Drivers ***/ -#ifdef CONFIGURE_DRIVER_PCI_GR_RASTA_ADCDAC - gr_rasta_adcdac_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_PCI_GR_RASTA_IO - gr_rasta_io_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_PCI_GR_RASTA_TMTC - gr_rasta_tmtc_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_PCI_GR_701 - gr701_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_PCI_GR_TMTC_1553 - gr_tmtc_1553_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_PCI_GR_RASTA_SPW_ROUTER - gr_rasta_spw_router_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_PCI_GR_LEON4_N2X - gr_cpci_leon4_n2x_register_drv, -#endif -#ifdef CONFIGURE_DRIVER_PCI_GR_CPCI_GR740 - gr_cpci_gr740_register_drv, -#endif - - -/* Macros for adding custom drivers without needing to recompile - * kernel. - */ -#ifdef CONFIGURE_DRIVER_CUSTOM1 - DRIVER_CUSTOM1_REG, -#endif -#ifdef CONFIGURE_DRIVER_CUSTOM2 - DRIVER_CUSTOM2_REG, -#endif -#ifdef CONFIGURE_DRIVER_CUSTOM3 - DRIVER_CUSTOM3_REG, -#endif -#ifdef CONFIGURE_DRIVER_CUSTOM4 - DRIVER_CUSTOM4_REG, -#endif -#ifdef CONFIGURE_DRIVER_CUSTOM5 - DRIVER_CUSTOM5_REG, -#endif -#ifdef CONFIGURE_DRIVER_CUSTOM6 - DRIVER_CUSTOM6_REG, -#endif -#ifdef CONFIGURE_DRIVER_CUSTOM7 - DRIVER_CUSTOM7_REG, -#endif -#ifdef CONFIGURE_DRIVER_CUSTOM8 - DRIVER_CUSTOM8_REG, -#endif -#ifdef CONFIGURE_DRIVER_CUSTOM9 - DRIVER_CUSTOM9_REG, -#endif - - /* End array with NULL */ - NULL -}; - -#endif /* CONFIGURE_INIT */ - -#ifdef __cplusplus -} -#endif - -#endif /* _DRIVER_MANAGER_CONFDEFS_H_ */ diff --git a/cpukit/libdrvmgr/drvmgr_list.h b/cpukit/libdrvmgr/drvmgr_list.h deleted file mode 100644 index 76028fb5bd..0000000000 --- a/cpukit/libdrvmgr/drvmgr_list.h +++ /dev/null @@ -1,78 +0,0 @@ -/* Linked list help functions used by driver manager. - * - * COPYRIGHT (c) 2009 Cobham Gaisler AB. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -/* - * Help functions for the Driver Manager. Implements a singly linked list - * with head and tail pointers for fast insertions/deletions to head and - * tail in list. - */ - -#ifndef _DRVIVER_MANAGER_LIST_H_ -#define _DRVIVER_MANAGER_LIST_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/*! List description, Singly link list with head and tail pointers. */ -struct drvmgr_list { - void *head; /*!< First entry in queue */ - void *tail; /*!< Last entry in queue */ - int ofs; /*!< Offset into head and tail to find next field */ -}; - -/* Static initialization of list */ -#define LIST_INITIALIZER(type, field) {NULL, NULL, offsetof(type, field)} - -/* Return the first element in list */ -#define LIST_HEAD(list, type) ((type *)(list)->head) - -/* Return the last element in list */ -#define LIST_TAIL(list, type) ((type *)(list)->tail) - -/* Get the next pointer of an entry */ -#define LIST_FIELD(list, entry) (*(void **)((char *)(entry) + (list)->ofs)) - -/* Return the next emlement in list */ -#define LIST_NEXT(list, entry, type) ((type *)(LIST_FIELD(list, entry))) - -/* Iterate through all entries in list */ -#define LIST_FOR_EACH(list, entry, type) \ - for (entry = LIST_HEAD(list, type); \ - entry; \ - entry = LIST_NEXT(list, entry, type)) - -/*! Initialize a list during runtime - * - * \param list The list to initialize - * \param offset The number of bytes into the entry structure the next pointer - * is found - */ -extern void drvmgr_list_init(struct drvmgr_list *list, int offset); - -/*! Clear list */ -extern void drvmgr_list_empty(struct drvmgr_list *list); - -/*! Add entry to front of list */ -extern void drvmgr_list_add_head(struct drvmgr_list *list, void *entry); - -/*! Add entry to end of list */ -extern void drvmgr_list_add_tail(struct drvmgr_list *list, void *entry); - -/*! Remove entry from front of list */ -extern void drvmgr_list_remove_head(struct drvmgr_list *list); - -/*! Remove entry from anywhere in list */ -extern void drvmgr_list_remove(struct drvmgr_list *list, void *entry); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/libfs/Makefile.am b/cpukit/libfs/Makefile.am index 0985b2ffb4..a76fa8ae2d 100644 --- a/cpukit/libfs/Makefile.am +++ b/cpukit/libfs/Makefile.am @@ -112,6 +112,11 @@ librfs_a_SOURCES = \ # JFFS2 project_lib_LIBRARIES = libjffs2.a + +$(PROJECT_LIB)/libjffs2.a: libjffs2.a + $(INSTALL_DATA) $< $(PROJECT_LIB)/libjffs2.a +TMPINSTALL_FILES = $(PROJECT_LIB)/libjffs2.a + libjffs2_a_SOURCES = libjffs2_a_SOURCES += src/jffs2/src/build.c libjffs2_a_SOURCES += src/jffs2/src/compat-crc32.c @@ -139,6 +144,5 @@ libjffs2_a_CPPFLAGS += -D__ECOS libjffs2_a_CPPFLAGS += '-DKBUILD_MODNAME="JFFS2"' # --- -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/subdirs.am include $(top_srcdir)/automake/local.am diff --git a/cpukit/libfs/preinstall.am b/cpukit/libfs/preinstall.am deleted file mode 100644 index 2aca1ef32f..0000000000 --- a/cpukit/libfs/preinstall.am +++ /dev/null @@ -1,24 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-local: $(TMPINSTALL_FILES) - -TMPINSTALL_FILES = -CLEANFILES = $(TMPINSTALL_FILES) - -$(PROJECT_LIB)/$(dirstamp): - @$(MKDIR_P) $(PROJECT_LIB) - @: > $(PROJECT_LIB)/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_LIB)/$(dirstamp) - -$(PROJECT_LIB)/libjffs2.a: libjffs2.a $(PROJECT_LIB)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_LIB)/libjffs2.a -TMPINSTALL_FILES += $(PROJECT_LIB)/libjffs2.a - diff --git a/cpukit/libfs/src/devfs/devfs.h b/cpukit/libfs/src/devfs/devfs.h deleted file mode 100644 index b0a9197eca..0000000000 --- a/cpukit/libfs/src/devfs/devfs.h +++ /dev/null @@ -1,255 +0,0 @@ -/** -* @file -* -* @brief Device Only File System -* -* This include file contains all constants and structures associated -* with the 'device-only' filesystem. -*/ - -#ifndef _RTEMS_DEVFS_H -#define _RTEMS_DEVFS_H - -#include - -/** - * @defgroup DevFsDeviceTable Device Only File System - * - * @ingroup FileSystemTypesAndMount - * - * @brief This structure defines the type of device table - */ -/**@{*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Per Device Node Control Structure - * - * This structure is instanced per device node and contains all information - * used by this file system implementation to manage that device node. - */ -typedef struct { - /** This member points to device name which is not a null-terminated string */ - const char *name; - /** This member is the name length of a device */ - size_t namelen; - /** major number of a device */ - rtems_device_major_number major; - /** minor number of a device */ - rtems_device_minor_number minor; - /** device creation mode, only device file can be created */ - mode_t mode; -} devFS_node; - -typedef struct { - devFS_node *nodes; - size_t count; -} devFS_data; - -/** - * The following defines the device-only filesystem operating - * operations. - */ -extern const rtems_filesystem_operations_table devFS_ops; - -/** - * The following defines the device-only filesystem operating - * handlers. - */ -extern const rtems_filesystem_file_handlers_r devFS_file_handlers; - -/** - * @brief Obtain Immutable Pointer to Immutable File System Data - * - * This methods returns the immutable file system specific information - * associated with this file. - */ -static inline const devFS_data *devFS_get_data( - const rtems_filesystem_location_info_t *loc -) -{ - return (const devFS_data *) loc->mt_entry->immutable_fs_info; -} - -/** - * @brief Evaluate Path - */ -extern void devFS_eval_path( - rtems_filesystem_eval_path_context_t *ctx -); - -/** - * @brief Maps Open Operation to rtems_io_open - * - * This handler maps open operation to rtems_io_open. - * - * @param iop This is the RTEMS's internal representation of file. - * @param pathname a null-terminated string that starts with /dev. - * @param oflag access flags - * @param mode access mode - * - * @retval the same as open - */ -extern int devFS_open( - rtems_libio_t *iop, - const char *pathname, - int oflag, - mode_t mode -); - - -/** - * @brief Maps Close Operation to rtems_io_close - * - * This handler maps close operation to rtems_io_close. - * - * @param iop This is the RTEMS's internal representation of file - * - * @retval the same as close - */ -extern int devFS_close( - rtems_libio_t *iop -); - -/** - * @brief Maps Read Operation to rtems_io_read - * - * This handler maps read operation to rtems_io_read. - * - * @param iop This is the RTEMS's internal representation of file - * @param buffer memory location to store read data - * @param count how many bytes to read - * - * @retval On successful, this routine returns total bytes read. On error - * it returns -1 and errno is set to proper value. - */ -extern ssize_t devFS_read( - rtems_libio_t *iop, - void *buffer, - size_t count -); - -/** - * @brief Writes Operation to rtems_io_write - * - * This handler maps write operation to rtems_io_write. - * - * @param iop This is the RTEMS's internal representation of file - * @param buffer data to be written - * @param count how many bytes to write - * - * @retval On successful, this routine returns total bytes written. On error - * it returns -1 and errno is set to proper value. - */ -extern ssize_t devFS_write( - rtems_libio_t *iop, - const void *buffer, - size_t count -); - -/** - * @brief Maps ioctl Operation to rtems_io_ioctl - * - * This handler maps ioctl operation to rtems_io_ioctl. - * - * @param iop This is the RTEMS's internal representation of file - * @param command io control command - * @param buffer io control parameters - * - * @retval On successful, this routine returns total bytes written. On error - * it returns -1 and errno is set to proper value. - */ -extern int devFS_ioctl( - rtems_libio_t *iop, - ioctl_command_t command, - void *buffer -); - -/** - * @brief Gets the Device File Information - * - * This handler gets the device file information. This routine only - * set the following member of struct stat: - * - * - st_dev: device number - * - st_mode: device file creation mode, only two mode are accepted: - * + S_IFCHR: character device file - * + S_IFBLK: block device file - * - * @param loc contains filesystem access information - * @param buf buffer to hold the device file's information - * - * @retval On successful, this routine returns 0. On error - * it returns -1 and errno is set to proper value. - */ -extern int devFS_stat( - const rtems_filesystem_location_info_t *loc, - struct stat *buf -); - -/** - * @brief Creates an item in the main device table. - * - * This routine is invoked upon registration of a new device - * file. It is responsible for creating a item in the main - * device table. This routine searches the device table in - * sequential order, when found a empty slot, it fills the slot - * with proper values. - * - * @see rtems_filesystem_mknod_t. - */ -extern int devFS_mknod( - const rtems_filesystem_location_info_t *parentloc, - const char *name, - size_t namelen, - mode_t mode, - dev_t dev -); - -/** - * @brief Creates the Main Device Table - * - * This routine is invoked upon rtems filesystem initialization. - * It is responsible for creating the main device table, - * initializing it to a known state, and set device file operation - * handlers. After this, the device-only filesytem is ready for use - * - * @param mt_entry The filesystem mount table entry. - * @param data Filesystem specific data. - * - * @retval upon success, this routine returns 0; otherwise it returns - * -1 and errno is set to proper value. The only error is when malloc - * failed, and errno is set to NOMEM. - */ -extern int devFS_initialize( - rtems_filesystem_mount_table_entry_t *mt_entry, - const void *data -); - -/** - * @brief Retrieves and Prints all the Device Registered in System - * - * This routine retrieves all the device registered in system, and - * prints out their detail information. For example, on one system, - * devFS_show will print out following message: - * - * @code - * /dev/console 0 0 - * /dev/clock 1 0 - * /dev/tty0 0 0 - * /flash 2 0 - * @endcode - * - * This routine is intended for debugging, and can be used by shell - * program to provide user with the system information. - */ -extern void devFS_Show(void); - -#ifdef __cplusplus -} -#endif -/**@}*/ -#endif - diff --git a/cpukit/libfs/src/dosfs/dosfs.h b/cpukit/libfs/src/dosfs/dosfs.h deleted file mode 100644 index 7691ed7e43..0000000000 --- a/cpukit/libfs/src/dosfs/dosfs.h +++ /dev/null @@ -1,433 +0,0 @@ -/** - * @file - * - * @brief Application Interface to FAT Filesystem - * - * @ingroup DOSFS - */ - -/* - * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia - * Author: Eugeny S. Mints - * - * Modifications to support UTF-8 in the file system are - * Copyright (c) 2013 embedded brains GmbH. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_DOSFS_H -#define _RTEMS_DOSFS_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct rtems_dosfs_convert_control rtems_dosfs_convert_control; - -/** - * @brief Converts from UTF-8 into a specific code page. - * - * @param[in,out] self The convert control. - * @param[in] src A well-formed UTF-8 string to be converted. - * @param[in] src_size The size of the string in bytes (inludes '\\0' if any). - * @param[out] dst The address the converted string will get copied to. - * @param[in,out] dst_size The size of the buffer in bytes respectively the - * number of bytes written to the buffer. - * - * @retval 0 Successful operation. - * @retval EINVAL Conversion was successful, but is not reversible. - * @retval ENOMEM Conversion failed (possibly due to insufficient buffer size). - */ -typedef int (*rtems_dosfs_utf8_to_codepage)( - rtems_dosfs_convert_control *self, - const uint8_t *src, - size_t src_size, - char *dst, - size_t *dst_size -); - -/** - * @brief Converts from a specific code page into UTF-8 - * - * @param[in,out] self The convert control. - * @param[in] src A well-formed string in code page format. - * @param[in] src_size The size of the string in bytes (inludes '\\0' if any). - * @param[out] dst The address the converted string will get copied to. - * @param[in,out] dst_size The size of the buffer in bytes respectively the - * number of bytes written to the buffer. - * - * @retval 0 Successful operation. - * @retval EINVAL Conversion was successful, but is not reversible. - * @retval ENOMEM Conversion failed (possibly due to insufficient buffer size). - */ -typedef int (*rtems_dosfs_codepage_to_utf8)( - rtems_dosfs_convert_control *self, - const char *src, - size_t src_size, - uint8_t *dst, - size_t *dst_size -); - -/** - * @brief Converts from UTF-8 to UTF-16 - * - * @param[in,out] self The convert control. - * @param[in] src A well-formed UTF-8 string to be converted. - * @param[in] src_size The size of the string in bytes (inludes '\\0' if any). - * @param[out] dst The address the converted string will get copied to - * @param[in,out] dst_size The size of the buffer in bytes respectively the - * number of bytes written to the buffer. - * - * @retval 0 Successful operation. - * @retval EINVAL Conversion was successful, but is not reversible. - * @retval ENOMEM Conversion failed (possibly due to insufficient buffer size). - */ -typedef int (*rtems_dosfs_utf8_to_utf16)( - rtems_dosfs_convert_control *self, - const uint8_t *src, - size_t src_size, - uint16_t *dst, - size_t *dst_size -); - -/** - * @brief Converts from UTF-16 to UTF-8. - * - * @param[in,out] self The convert control. - * @param[in] src A well-formed UTF-16 string to be converted. - * @param[in] src_size The size of the string in bytes (inludes '\\0' if any). - * @param[out] dst The address the converted string will get copied to. - * @param[in,out] dst_size The size of the buffer in bytes respectively the - * number of bytes written to the buffer - * - * @retval 0 Successful operation. - * @retval EINVAL Conversion was successful, but is not reversible. - * @retval ENOMEM Conversion failed (possibly due to insufficient buffer size). - */ -typedef int (*rtems_dosfs_utf16_to_utf8)( - rtems_dosfs_convert_control *self, - const uint16_t *src, - size_t src_size, - uint8_t *dst, - size_t *dst_size -); - -/** - * @brief Converts from UTF-8 to Normalized Form Canonical Decomposition. - * - * Does canonical decomposition of the UTF-8 string and in addition - * also converts upper case alphabetic characters to lower case characters - * - * @param[in,out] self The convert control. - * @param[in] src A well-formed UTF-8 string to be normalized and fold. - * @param[in] src_size The size of the string in bytes (inludes '\\0' if any). - * @param[out] dst The address the normalized and fold string will get - * copied to. - * @param[in,out] dst_size The size of the buffer in bytes respectively the - * number of bytes written to the buffer. - * - * @retval 0 Successful operation. - * @retval EINVAL Conversion failed. - * @retval ENOMEM Conversion failed (possibly due to insufficient buffer size). - * @retval EOVERFLOW Conversion failed. - * @retval ENOENT Conversion failed. - */ -typedef int (*rtems_dosfs_utf8_normalize_and_fold)( - rtems_dosfs_convert_control *self, - const uint8_t *src, - size_t src_size, - uint8_t *dst, - size_t *dst_size -); - -/** - * @brief Destroys a convert control structure. - * - * @param[in,out] self The convert control for destruction. - */ -typedef void (*rtems_dosfs_convert_destroy)( - rtems_dosfs_convert_control *self -); - -/** - * @brief FAT filesystem convert handler. - */ -typedef struct { - rtems_dosfs_utf8_to_codepage utf8_to_codepage; - rtems_dosfs_codepage_to_utf8 codepage_to_utf8; - rtems_dosfs_utf8_to_utf16 utf8_to_utf16; - rtems_dosfs_utf16_to_utf8 utf16_to_utf8; - rtems_dosfs_utf8_normalize_and_fold utf8_normalize_and_fold; - rtems_dosfs_convert_destroy destroy; -} rtems_dosfs_convert_handler; - -typedef struct { - void *data; - size_t size; -} rtems_dosfs_buffer; - -/** - * @brief FAT filesystem convert control. - * - * Short file names are stored in the code page format. Long file names are - * stored as little-endian UTF-16. The convert control determines the format - * conversions to and from the POSIX file name strings. - */ -struct rtems_dosfs_convert_control { - const rtems_dosfs_convert_handler *handler; - rtems_dosfs_buffer buffer; -}; - -/** - * @defgroup DOSFS FAT Filesystem Support - * - * @ingroup FileSystemTypesAndMount - * - * @brief FAT file system configuration support, format and mount options. - * - * A block device can be formatted with a FAT file system with the - * msdos_format() function. - * - * The FAT file system mount operation can be controlled with FAT file system - * specific mount options, see @ref rtems_dosfs_mount_options. - * - * @{ - */ - -/** - * @brief Semaphore count per FAT filesystem instance. - * - * This can be used for system configuration via . - */ -#define RTEMS_DOSFS_SEMAPHORES_PER_INSTANCE 1 - -/** - * @brief FAT filesystem mount options. - */ -typedef struct { - /** - * @brief Converter implementation for new file system instance. - * - * Before converters have been added to the RTEMS implementation of the FAT - * file system, the implementation was: - * - Short names were saved in code page format (as is still the case). - * - Long names were not saved in UTF-16 format as mandated by the FAT file - * system specification. Instead the character in the local encoding was - * stored to the low byte directly and the high byte was set to zero. - * - * There are a few compatibility issues due to a non-standard conform - * implementation of the FAT file system before the UTF-8 support was added. - * These following issues affect the default converter and the UTF-8 - * converter: - * - Before UTF-8 support was added, it was possible to create files with the - * the same short name in single case and mixed case in a directory. It - * was for example possible to have files "ABC" and "aBc" in a single - * directory. Now this bug is fixed. - * - Before UTF-8 support was added, it was possible to create files with a - * name length of slightly more than 255 characters. Now the - * implementation adheres exactly to the 255 character limit. - * - Long file names saved before UTF-8 support was added could contain - * non-ASCII characters in the low byte which was saved for a long name - * character. With the default converter this means such files can be read - * only by their short file name. With the UTF-8 converter file names will - * be read correctly as long as the characters written with the old - * implementation were Latin-1 characters. - * - * The following sample code demonstrates how to mount a file - * system with UTF-8 support: - * @code - * #include - * #include - * #include - * #include - * - * static int mount_with_utf8( - * const char *device_file, - * const char *mount_point - * ) - * { - * rtems_dosfs_convert_control *convert_ctrl; - * int rv; - * - * convert_ctrl = rtems_dosfs_create_utf8_converter( "CP850" ); - * - * if ( convert_ctrl != NULL ) { - * rtems_dosfs_mount_options mount_opts; - * - * memset( &mount_opts, 0, sizeof( mount_opts ) ); - * mount_opts.converter = convert_ctrl; - * - * rv = mount_and_make_target_path( - * device_file, - * mount_point, - * RTEMS_FILESYSTEM_TYPE_DOSFS, - * RTEMS_FILESYSTEM_READ_WRITE, - * &mount_opts - * ); - * } else { - * rv = -1; - * errno = ENOMEM; - * } - * - * return rv; - * } - * @endcode - * - * In case you do not want UTF-8 support, you can simply pass a NULL pointer - * to mount_and_make_target_path() respectively to mount() instead of the - * mount_opts address. - * - * @see rtems_dosfs_create_default_converter() and - * rtems_dosfs_create_utf8_converter(). - */ - rtems_dosfs_convert_control *converter; -} rtems_dosfs_mount_options; - -/** - * @brief Allocates and initializes a default converter. - * - * This default converter will accept only POSIX file names with pure ASCII - * characters. This largely corresponds to the file name handling before the - * optional UTF-8 support was added to the RTEMS implementation of the FAT file - * system. This handling is mostly backwards compatible to the previous RTEMS - * implementation of the FAT file system. - * - * For backwards compatibility and the previous RTEMS implementation of the FAT - * file system please see also @ref rtems_dosfs_mount_options and mount(). - * - * @retval NULL Something failed. - * @retval other Pointer to initialized converter. - */ -rtems_dosfs_convert_control *rtems_dosfs_create_default_converter(void); - -/** - * @brief Allocates and initializes a UTF-8 converter. - * - * This converter will assume that all file names passed to POSIX file handling - * methods are UTF-8 strings and will convert them to the selected code page - * for short file names and to UTF-16 for long file names. This conversion - * will be done during reading and writing. These conversions correspond to - * the specification of the FAT file system. This handling is mostly backwards - * compatible to the previous RTEMS implementation of the FAT file system. - * - * For backwards compatibility and the previous RTEMS implementation of the FAT - * file system please see also @ref rtems_dosfs_mount_options and mount(). - * - * One possible issue with this converter is: When reading file names which - * have been created with other implementations of the FAT file system, it can - * happen that during the conversion to UTF-8 a long file name becomes longer - * and exceeds the 255 bytes limit. In such a case only the short file name - * will get read. - * - * @param[in] codepage The iconv() identification string for the used code - * page. - * - * @retval NULL Something failed. - * @retval other Pointer to initialized converter. - */ -rtems_dosfs_convert_control *rtems_dosfs_create_utf8_converter( - const char *codepage -); - -#define MSDOS_FMT_INFO_LEVEL_NONE (0) -#define MSDOS_FMT_INFO_LEVEL_INFO (1) -#define MSDOS_FMT_INFO_LEVEL_DETAIL (2) -#define MSDOS_FMT_INFO_LEVEL_DEBUG (3) - -/** - * @brief FAT file system format request parameters. - */ -typedef struct { - /** - * @brief OEM name string or NULL. - */ - const char *OEMName; - - /** - * @brief Volume label string or NULL. - */ - const char *VolLabel; - - /** - * @brief Sectors per cluster hint. - * - * The format procedure may choose another value. Use 0 as default value. - */ - uint32_t sectors_per_cluster; - - /** - * @brief Number of FATs hint. - * - * Use 0 as default value. - */ - uint32_t fat_num; - - /** - * @brief Minimum files in root directory for FAT12 and FAT16. - * - * The format procedure may choose a greater value. Use 0 as default value. - */ - uint32_t files_per_root_dir; - - /** - * @brief Media code. - * - * Use 0 as default value. The default media code is 0xf8. - */ - uint8_t media; - - /** - * @brief Quick format. - * - * If set to true, then do not clear data sectors to zero. - */ - bool quick_format; - - /** - * @brief Do not align FAT, data cluster, and root directory to a cluster - * boundary. - */ - bool skip_alignment; - - /** - * @brief Synchronize device after write operations. - */ - bool sync_device; - - /** - * @brief The amount of info to output. - */ - int info_level; -} msdos_format_request_param_t; - -/** - * @brief Formats a block device with a FAT file system. - * - * @param[in] devname The block device path. - * @param[in] rqdata The FAT file system format request data. Use NULL for - * default parameters. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The @c errno indicates the error. - */ -int msdos_format ( - const char *devname, - const msdos_format_request_param_t *rqdata -); - -/** @} */ - -int rtems_dosfs_initialize(rtems_filesystem_mount_table_entry_t *mt_entry, - const void *data); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/libfs/src/imfs/imfs.h b/cpukit/libfs/src/imfs/imfs.h deleted file mode 100644 index fe3c5b12a9..0000000000 --- a/cpukit/libfs/src/imfs/imfs.h +++ /dev/null @@ -1,946 +0,0 @@ -/** - * @file - * - * @brief Header File for the In-Memory File System - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_IMFS_H -#define _RTEMS_IMFS_H - -#include - -#include -#include - -/** - * @brief In-Memory File System Support. - * - * @defgroup IMFS In-Memory File System Support - * - * @ingroup FileSystemTypesAndMount - */ -/**@{*/ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Data types - */ - -struct IMFS_jnode_tt; -typedef struct IMFS_jnode_tt IMFS_jnode_t; - -/** - * IMFS "memfile" information - * - * The data structure for the in-memory "memfiles" is based on classic UNIX. - * - * block_ptr is a pointer to a block of IMFS_MEMFILE_BYTES_PER_BLOCK in - * length which could be data or a table of pointers to blocks. - * - * Setting IMFS_MEMFILE_BYTES_PER_BLOCK to different values has a significant - * impact on the maximum file size supported as well as the amount of - * memory wasted due to internal file fragmentation. The following - * is a list of maximum file sizes based on various settings - * - * @code - * max_filesize with blocks of 16 is 1,328 - * max_filesize with blocks of 32 is 18,656 - * max_filesize with blocks of 64 is 279,488 - * max_filesize with blocks of 128 is 4,329,344 - * max_filesize with blocks of 256 is 68,173,568 - * max_filesize with blocks of 512 is 1,082,195,456 - * @endcode - */ -#define IMFS_MEMFILE_DEFAULT_BYTES_PER_BLOCK 128 - extern int imfs_rq_memfile_bytes_per_block; - extern int imfs_memfile_bytes_per_block; - -#define IMFS_MEMFILE_BYTES_PER_BLOCK imfs_memfile_bytes_per_block -#define IMFS_MEMFILE_BLOCK_SLOTS \ - (IMFS_MEMFILE_BYTES_PER_BLOCK / sizeof(void *)) - -typedef uint8_t *block_p; -typedef block_p *block_ptr; - -/* - * Important block numbers for "memfiles" - */ -#define FIRST_INDIRECT (0) -#define LAST_INDIRECT (IMFS_MEMFILE_BLOCK_SLOTS - 1) - -#define FIRST_DOUBLY_INDIRECT (LAST_INDIRECT + 1) -#define LAST_DOUBLY_INDIRECT \ - (LAST_INDIRECT + \ - (IMFS_MEMFILE_BLOCK_SLOTS * IMFS_MEMFILE_BLOCK_SLOTS)) - -#define FIRST_TRIPLY_INDIRECT (LAST_DOUBLY_INDIRECT + 1) -#define LAST_TRIPLY_INDIRECT \ - (LAST_DOUBLY_INDIRECT +\ - (IMFS_MEMFILE_BLOCK_SLOTS * \ - IMFS_MEMFILE_BLOCK_SLOTS * IMFS_MEMFILE_BLOCK_SLOTS)) - -#define IMFS_MEMFILE_MAXIMUM_SIZE \ - (LAST_TRIPLY_INDIRECT * IMFS_MEMFILE_BYTES_PER_BLOCK) - -/** @} */ - -/** - * @addtogroup IMFSGenericNodes - */ -/**@{*/ - -/** - * @brief Initializes an IMFS node. - * - * @param[in] node The IMFS node. - * @param[in] arg The user provided argument pointer. It may contain node - * specific initialization information. - * - * @retval node Successful operation. - * @retval NULL An error occurred. The @c errno indicates the error. This - * will abort the make operation. - * - * @see IMFS_node_control, IMFS_node_initialize_default(), and - * IMFS_node_initialize_generic(). - */ -typedef IMFS_jnode_t *(*IMFS_node_control_initialize)( - IMFS_jnode_t *node, - void *arg -); - -/** - * @brief Returns the node and does nothing else. - * - * @param[in] node The IMFS node. - * @param[in] arg The user provided argument pointer. It is not used. - * - * @retval node Returns always the node passed as parameter. - * - * @see IMFS_node_control. - */ -IMFS_jnode_t *IMFS_node_initialize_default( - IMFS_jnode_t *node, - void *arg -); - -IMFS_jnode_t *IMFS_node_initialize_directory( - IMFS_jnode_t *node, - void *arg -); - -/** - * @brief Returns the node and sets the generic node context. - * - * @param[in] node The IMFS node. - * @param[in] arg The user provided argument pointer. It must contain the - * generic context. - * - * @retval node Returns always the node passed as parameter. - * - * @see IMFS_node_control. - */ -IMFS_jnode_t *IMFS_node_initialize_generic( - IMFS_jnode_t *node, - void *arg -); - -/** - * @brief Prepares the removal of an IMFS node from its parent directory. - * - * @param[in] node The IMFS node. - * - * @retval node Successful operation. - * @retval NULL An error occurred. The @c errno indicates the error. This - * will abort the removal operation. - * - * @see IMFS_node_control and IMFS_node_remove_default(). - */ -typedef IMFS_jnode_t *(*IMFS_node_control_remove)( - IMFS_jnode_t *node -); - -/** - * @brief Returns the node and does nothing else. - * - * @param[in] node The IMFS node. - * - * @retval node Returns always the node passed as parameter. - * - * @see IMFS_node_control. - */ -IMFS_jnode_t *IMFS_node_remove_default( - IMFS_jnode_t *node -); - -IMFS_jnode_t *IMFS_node_remove_directory( IMFS_jnode_t *node ); - -/** - * @brief Destroys an IMFS node. - * - * @param[in] node The IMFS node. - * - * @see IMFS_node_control and IMFS_node_destroy_default(). - */ -typedef void (*IMFS_node_control_destroy)( IMFS_jnode_t *node ); - -/** - * @brief Frees the node. - * - * @param[in] node The IMFS node. - * - * @see IMFS_node_control. - */ -void IMFS_node_destroy_default( IMFS_jnode_t *node ); - -/** - * @brief IMFS node control. - */ -typedef struct { - const rtems_filesystem_file_handlers_r *handlers; - IMFS_node_control_initialize node_initialize; - IMFS_node_control_remove node_remove; - IMFS_node_control_destroy node_destroy; -} IMFS_node_control; - -typedef struct { - IMFS_node_control node_control; - size_t node_size; -} IMFS_mknod_control; - -/** @} */ - -/** - * @addtogroup IMFS - */ -/**@{*/ - -/* - * Maximum length of a "basename" of an IMFS file/node. - */ - -#define IMFS_NAME_MAX _POSIX_NAME_MAX - -/* - - * The control structure for an IMFS jnode. - */ - -struct IMFS_jnode_tt { - rtems_chain_node Node; /* for chaining them together */ - IMFS_jnode_t *Parent; /* Parent node */ - const char *name; /* "basename" (not \0 terminated) */ - uint16_t namelen; /* Length of "basename" */ - uint16_t flags; /* Node flags */ - mode_t st_mode; /* File mode */ - unsigned short reference_count; - nlink_t st_nlink; /* Link count */ - - uid_t st_uid; /* User ID of owner */ - gid_t st_gid; /* Group ID of owner */ - - time_t stat_atime; /* Time of last access */ - time_t stat_mtime; /* Time of last modification */ - time_t stat_ctime; /* Time of last status change */ - const IMFS_node_control *control; -}; - -#define IMFS_NODE_FLAG_NAME_ALLOCATED 0x1 - -typedef struct { - IMFS_jnode_t Node; - rtems_chain_control Entries; - rtems_filesystem_mount_table_entry_t *mt_fs; -} IMFS_directory_t; - -typedef struct { - IMFS_jnode_t Node; - rtems_device_major_number major; - rtems_device_minor_number minor; -} IMFS_device_t; - -typedef struct { - IMFS_jnode_t Node; - IMFS_jnode_t *link_node; -} IMFS_link_t; - -typedef struct { - IMFS_jnode_t Node; - char *name; -} IMFS_sym_link_t; - -typedef struct { - IMFS_jnode_t Node; - size_t size; /* size of file in bytes */ -} IMFS_filebase_t; - -typedef struct { - IMFS_filebase_t File; - block_ptr indirect; /* array of 128 data blocks pointers */ - block_ptr doubly_indirect; /* 128 indirect blocks */ - block_ptr triply_indirect; /* 128 doubly indirect blocks */ -} IMFS_memfile_t; - -typedef struct { - IMFS_filebase_t File; - block_p direct; /* pointer to file image */ -} IMFS_linearfile_t; - -/* Support copy on write for linear files */ -typedef union { - IMFS_jnode_t Node; - IMFS_filebase_t File; - IMFS_memfile_t Memfile; - IMFS_linearfile_t Linearfile; -} IMFS_file_t; - -typedef struct { - IMFS_jnode_t Node; - pipe_control_t *pipe; -} IMFS_fifo_t; - -typedef struct { - IMFS_jnode_t Node; - void *context; -} IMFS_generic_t; - -static inline IMFS_directory_t *IMFS_iop_to_directory( - const rtems_libio_t *iop -) -{ - return (IMFS_directory_t *) iop->pathinfo.node_access; -} - -static inline IMFS_device_t *IMFS_iop_to_device( const rtems_libio_t *iop ) -{ - return (IMFS_device_t *) iop->pathinfo.node_access; -} - -static inline IMFS_file_t *IMFS_iop_to_file( const rtems_libio_t *iop ) -{ - return (IMFS_file_t *) iop->pathinfo.node_access; -} - -static inline IMFS_memfile_t *IMFS_iop_to_memfile( const rtems_libio_t *iop ) -{ - return (IMFS_memfile_t *) iop->pathinfo.node_access; -} - -static inline void IMFS_update_atime( IMFS_jnode_t *jnode ) -{ - struct timeval now; - - gettimeofday( &now, 0 ); - - jnode->stat_atime = now.tv_sec; -} - -static inline void IMFS_update_mtime( IMFS_jnode_t *jnode ) -{ - struct timeval now; - - gettimeofday( &now, 0 ); - - jnode->stat_mtime = now.tv_sec; -} - -static inline void IMFS_update_ctime( IMFS_jnode_t *jnode ) -{ - struct timeval now; - - gettimeofday( &now, 0 ); - - jnode->stat_ctime = now.tv_sec; -} - -static inline void IMFS_mtime_ctime_update( IMFS_jnode_t *jnode ) -{ - struct timeval now; - - gettimeofday( &now, 0 ); - - jnode->stat_mtime = now.tv_sec; - jnode->stat_ctime = now.tv_sec; -} - -typedef struct { - const IMFS_mknod_control *directory; - const IMFS_mknod_control *device; - const IMFS_mknod_control *file; - const IMFS_mknod_control *fifo; -} IMFS_mknod_controls; - -typedef struct { - IMFS_directory_t Root_directory; - const IMFS_mknod_controls *mknod_controls; -} IMFS_fs_info_t; - -typedef struct { - IMFS_fs_info_t *fs_info; - const rtems_filesystem_operations_table *ops; - const IMFS_mknod_controls *mknod_controls; -} IMFS_mount_data; - -/* - * Shared Data - */ - -extern const IMFS_mknod_control IMFS_mknod_control_dir_default; -extern const IMFS_mknod_control IMFS_mknod_control_dir_minimal; -extern const IMFS_mknod_control IMFS_mknod_control_device; -extern const IMFS_mknod_control IMFS_mknod_control_memfile; -extern const IMFS_node_control IMFS_node_control_linfile; -extern const IMFS_mknod_control IMFS_mknod_control_fifo; -extern const IMFS_mknod_control IMFS_mknod_control_enosys; - -extern const rtems_filesystem_limits_and_options_t IMFS_LIMITS_AND_OPTIONS; - -/* - * Routines - */ - -extern int IMFS_initialize( - rtems_filesystem_mount_table_entry_t *mt_entry, - const void *data -); - -extern int IMFS_initialize_support( - rtems_filesystem_mount_table_entry_t *mt_entry, - const void *data -); - -/** - * @brief Unmount this instance of IMFS. - */ -extern void IMFS_fsunmount( - rtems_filesystem_mount_table_entry_t *mt_entry -); - -/** - * @brief RTEMS load tarfs. - * - * This file implements the "mount" procedure for tar-based IMFS - * extensions. The TAR is not actually mounted under the IMFS. - * Directories from the TAR file are created as usual in the IMFS. - * File entries are created as IMFS_LINEAR_FILE nodes with their nods - * pointing to addresses in the TAR image. - * - * Here we create the mountpoint directory and load the tarfs at - * that node. Once the IMFS has been mounted, we work through the - * tar image and perform as follows: - * - For directories, simply call mkdir(). The IMFS creates nodes as - * needed. - * - For files, we make our own calls to IMFS eval_for_make and - * create_node. - * - * TAR file format: - * - * @code - * Offset Length Contents - * 0 100 bytes File name ('\0' terminated, 99 maxmum length) - * 100 8 bytes File mode (in octal ascii) - * 108 8 bytes User ID (in octal ascii) - * 116 8 bytes Group ID (in octal ascii) - * 124 12 bytes File size (s) (in octal ascii) - * 136 12 bytes Modify time (in octal ascii) - * 148 8 bytes Header checksum (in octal ascii) - * 156 1 bytes Link flag - * 157 100 bytes Linkname ('\0' terminated, 99 maxmum length) - * 257 8 bytes Magic PAX ("ustar\0" + 2 bytes padding) - * 257 8 bytes Magic GNU tar ("ustar \0") - * 265 32 bytes User name ('\0' terminated, 31 maxmum length) - * 297 32 bytes Group name ('\0' terminated, 31 maxmum length) - * 329 8 bytes Major device ID (in octal ascii) - * 337 8 bytes Minor device ID (in octal ascii) - * 345 167 bytes Padding - * 512 (s+p) bytes File contents (s+p) := (((s) + 511) & ~511), - * round up to 512 bytes - * @endcode - * - * Checksum: - * @code - * int i, sum; - * char *header = tar_header_pointer; - * - * sum = 0; - * for (i = 0; i < 512; i++) - * sum += 0xFF & header[i]; - * @endcode - */ -extern int rtems_tarfs_load( - const char *mountpoint, - uint8_t *tar_image, - size_t tar_size -); - -/** - * @brief Destroy an IMFS node. - */ -extern void IMFS_node_destroy( IMFS_jnode_t *node ); - -/** - * @brief Clone an IMFS node. - */ -extern int IMFS_node_clone( rtems_filesystem_location_info_t *loc ); - -/** - * @brief Free an IMFS node. - */ -extern void IMFS_node_free( const rtems_filesystem_location_info_t *loc ); - -/** - * @brief Perform a status processing for the IMFS. - * - * This routine provides a stat for the IMFS file system. - */ -extern int IMFS_stat( - const rtems_filesystem_location_info_t *loc, - struct stat *buf -); - -extern int IMFS_stat_file( - const rtems_filesystem_location_info_t *loc, - struct stat *buf -); - -/** - * @brief IMFS evaluation node support. - */ -extern void IMFS_eval_path( - rtems_filesystem_eval_path_context_t *ctx -); - -/** - * @brief Create a new IMFS link node. - * - * The following rouine creates a new link node under parent with the - * name given in name. The link node is set to point to the node at - * to_loc. - */ -extern int IMFS_link( - const rtems_filesystem_location_info_t *parentloc, - const rtems_filesystem_location_info_t *targetloc, - const char *name, - size_t namelen -); - -/** - * @brief Change the owner of IMFS. - * - * This routine is the implementation of the chown() system - * call for the IMFS. - */ -extern int IMFS_chown( - const rtems_filesystem_location_info_t *loc, - uid_t owner, - gid_t group -); - -/** - * @brief Create an IMFS node. - * - * Routine to create a node in the IMFS file system. - */ -extern int IMFS_mknod( - const rtems_filesystem_location_info_t *parentloc, - const char *name, - size_t namelen, - mode_t mode, - dev_t dev -); - -extern IMFS_jnode_t *IMFS_initialize_node( - IMFS_jnode_t *node, - const IMFS_node_control *node_control, - const char *name, - size_t namelen, - mode_t mode, - void *arg -); - -/** - * @brief Create an IMFS node. - * - * Create an IMFS filesystem node of an arbitrary type that is NOT - * the root directory node. - */ -extern IMFS_jnode_t *IMFS_create_node( - const rtems_filesystem_location_info_t *parentloc, - const IMFS_node_control *node_control, - size_t node_size, - const char *name, - size_t namelen, - mode_t mode, - void *arg -); - -static inline bool IMFS_is_imfs_instance( - const rtems_filesystem_location_info_t *loc -) -{ - return loc->mt_entry->ops->clonenod_h == IMFS_node_clone; -} - -/** @} */ - -/** - * @defgroup IMFSGenericNodes IMFS Generic Nodes - * - * @ingroup LibIO - * - * @brief Generic nodes are an alternative to standard drivers in RTEMS. - * - * The handlers of a generic node are called with less overhead compared to the - * standard driver operations. The usage of file system node handlers enable - * more features like support for fsync() and fdatasync(). The generic nodes - * use the reference counting of the IMFS. This provides automatic node - * destruction when the last reference vanishes. - * - * @{ - */ - -/** - * @brief Initializer for a generic node control. - * - * @param[in] handlers The file system node handlers. - * @param[in] init The node initialization method. - * @param[in] destroy The node destruction method. - */ -#define IMFS_GENERIC_INITIALIZER( handlers, init, destroy ) \ - { \ - ( handlers ), \ - ( init ), \ - IMFS_node_remove_default, \ - ( destroy ) \ - } - -/** - * @brief Makes a generic IMFS node. - * - * @param[in] path The path to the new generic IMFS node. - * @param[in] mode The node mode. - * @param[in] node_control The node control. - * @param[in] context The node control handler context. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The @c errno indicates the error. - * - * @code - * #include - * #include - * #include - * - * #include - * - * static const rtems_filesystem_file_handlers_r some_node_handlers = { - * ... - * }; - * - * static IMFS_jnode_t *some_node_init(IMFS_jnode_t *node, void *arg) - * { - * void *context; - * - * node = IMFS_node_initialize_generic(node, arg); - * context = IMFS_generic_get_context_by_node(node); - * - * return node; - * } - * - * static void some_node_destroy(IMFS_jnode_t *node) - * { - * void *context = IMFS_generic_get_context_by_node(node); - * - * IMFS_node_destroy_default(node); - * } - * - * static const IMFS_node_control some_node_control = IMFS_GENERIC_INITIALIZER( - * &some_node_handlers, - * some_node_init, - * some_node_destroy - * ); - * - * void example(void *some_node_context) - * { - * int rv; - * - * rv = IMFS_make_generic_node( - * "/path/to/some/generic/node", - * S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO, - * &some_node_control, - * some_node_context - * ); - * assert(rv == 0); - * } - * @endcode - */ -extern int IMFS_make_generic_node( - const char *path, - mode_t mode, - const IMFS_node_control *node_control, - void *context -); - -/** @} */ - -/** - * @addtogroup IMFS - */ -/**@{*/ - -/** - * @brief Mount an IMFS. - */ -extern int IMFS_mount( - rtems_filesystem_mount_table_entry_t *mt_entry /* IN */ -); - -/** - * @brief Unmount an IMFS. - */ -extern int IMFS_unmount( - rtems_filesystem_mount_table_entry_t *mt_entry /* IN */ -); - -/** - * @name IMFS Memory File Handlers - * - * This section contains the set of handlers used to process operations on - * IMFS memory file nodes. The memory files are created in memory using - * malloc'ed memory. Thus any data stored in one of these files is lost - * at system shutdown unless special arrangements to copy the data to - * some type of non-volailte storage are made by the application. - */ -/**@{*/ - -extern ssize_t IMFS_memfile_write( - IMFS_memfile_t *memfile, - off_t start, - const unsigned char *source, - unsigned int length -); - -/** @} */ - -/** - * @name IMFS Device Node Handlers - * - * This section contains the set of handlers used to map operations on - * IMFS device nodes onto calls to the RTEMS Classic API IO Manager. - */ -/**@{*/ - -extern int device_open( - rtems_libio_t *iop, /* IN */ - const char *pathname, /* IN */ - int oflag, /* IN */ - mode_t mode /* IN */ -); - -extern int device_close( - rtems_libio_t *iop /* IN */ -); - -extern ssize_t device_read( - rtems_libio_t *iop, /* IN */ - void *buffer, /* IN */ - size_t count /* IN */ -); - -extern ssize_t device_write( - rtems_libio_t *iop, /* IN */ - const void *buffer, /* IN */ - size_t count /* IN */ -); - -extern int device_ioctl( - rtems_libio_t *iop, - ioctl_command_t command, - void *buffer -); - -extern int device_ftruncate( - rtems_libio_t *iop, /* IN */ - off_t length /* IN */ -); - -/** @} */ - -/** - * @brief Set IMFS file access and modification times. - * - * - * This routine is the implementation of the utime() system - * call for the IMFS. - */ -extern int IMFS_utime( - const rtems_filesystem_location_info_t *loc, - time_t actime, - time_t modtime -); - -/** - * @brief Change the IMFS file mode. - */ -extern int IMFS_fchmod( - const rtems_filesystem_location_info_t *loc, - mode_t mode -); - -/** - * @brief Create a new IMFS symbolic link node. - * - * The following rouine creates a new symbolic link node under parent - * with the name given in name. The node is set to point to the node at - * to_loc. - */ -extern int IMFS_symlink( - const rtems_filesystem_location_info_t *parentloc, - const char *name, - size_t namelen, - const char *target -); - -/** - * @brief Put IMFS symbolic link into buffer. - * - * The following rouine puts the symbolic links destination name into - * buff. - * - */ -extern ssize_t IMFS_readlink( - const rtems_filesystem_location_info_t *loc, - char *buf, - size_t bufsize -); - -/** - * @brief Rename the IMFS. - * - * The following rouine creates a new link node under parent with the - * name given in name and removes the old. - */ -extern int IMFS_rename( - const rtems_filesystem_location_info_t *oldparentloc, - const rtems_filesystem_location_info_t *oldloc, - const rtems_filesystem_location_info_t *newparentloc, - const char *name, - size_t namelen -); -/** - * @brief IMFS node removal handler. - * - * This file contains the handler used to remove a node when a file type - * does not require special actions. - */ -extern int IMFS_rmnod( - const rtems_filesystem_location_info_t *parentloc, - const rtems_filesystem_location_info_t *loc -); - -/* - * Turn on IMFS assertions when RTEMS_DEBUG is defined. - */ -#ifdef RTEMS_DEBUG - #include - - #define IMFS_assert(_x) assert(_x) -#else - #define IMFS_assert(_x) -#endif - -static inline void IMFS_Set_handlers( rtems_filesystem_location_info_t *loc ) -{ - IMFS_jnode_t *node = (IMFS_jnode_t *) loc->node_access; - - loc->handlers = node->control->handlers; -} - -static inline void IMFS_add_to_directory( - IMFS_jnode_t *dir_node, - IMFS_jnode_t *entry_node -) -{ - IMFS_directory_t *dir = (IMFS_directory_t *) dir_node; - - entry_node->Parent = dir_node; - rtems_chain_append_unprotected( &dir->Entries, &entry_node->Node ); -} - -static inline void IMFS_remove_from_directory( IMFS_jnode_t *node ) -{ - IMFS_assert( node->Parent != NULL ); - node->Parent = NULL; - rtems_chain_extract_unprotected( &node->Node ); -} - -static inline bool IMFS_is_directory( const IMFS_jnode_t *node ) -{ - return S_ISDIR( node->st_mode ); -} - -#define IMFS_STAT_FMT_HARD_LINK 0 - -static inline bool IMFS_is_hard_link( mode_t mode ) -{ - return ( mode & S_IFMT ) == IMFS_STAT_FMT_HARD_LINK; -} - -static inline ino_t IMFS_node_to_ino( const IMFS_jnode_t *node ) -{ - return (ino_t) ((uintptr_t) node); -} - -/** @} */ - -/** - * @addtogroup IMFSGenericNodes - */ -/**@{*/ - -static inline void *IMFS_generic_get_context_by_node( - const IMFS_jnode_t *node -) -{ - const IMFS_generic_t *generic = (const IMFS_generic_t *) node; - - return generic->context; -} - -static inline void *IMFS_generic_get_context_by_location( - const rtems_filesystem_location_info_t *loc -) -{ - return loc->node_access_2; -} - -static inline void *IMFS_generic_get_context_by_iop( - const rtems_libio_t *iop -) -{ - return IMFS_generic_get_context_by_location( &iop->pathinfo ); -} - -static inline dev_t IMFS_generic_get_device_identifier_by_node( - const IMFS_jnode_t *node -) -{ - return rtems_filesystem_make_dev_t_from_pointer( node ); -} - -#ifdef __cplusplus -} -#endif -/** @} */ -#endif -/* end of include file */ diff --git a/cpukit/libfs/src/jffs2/include/rtems/jffs2.h b/cpukit/libfs/src/jffs2/include/rtems/jffs2.h deleted file mode 100644 index a856c46c41..0000000000 --- a/cpukit/libfs/src/jffs2/include/rtems/jffs2.h +++ /dev/null @@ -1,604 +0,0 @@ -/* - * Copyright (c) 2013, 2016 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef RTEMS_JFFS2_H -#define RTEMS_JFFS2_H - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -typedef struct rtems_jffs2_flash_control rtems_jffs2_flash_control; - -/** - * @defgroup JFFS2 Journalling Flash File System Version 2 (JFFS2) Support - * - * @ingroup FileSystemTypesAndMount - * - * @brief Mount options for the Journalling Flash File System, Version 2 - * (JFFS2). - * - * The application must provide flash device geometry information and flash - * device operations in the flash control structure - * @ref rtems_jffs2_flash_control. - * - * The application can optionally provide a compressor control structure to - * enable data compression using the selected compression algorithm. - * - * The application must enable JFFS2 support with rtems_filesystem_register() - * or CONFIGURE_FILESYSTEM_JFFS2 via . - * - * An example mount with a simple memory based flash device simulation follows. - * The zlib is used for as the compressor. - * - * @code - * #include - * - * #include - * #include - * - * #define BLOCK_SIZE (32UL * 1024UL) - * - * #define FLASH_SIZE (32UL * BLOCK_SIZE) - * - * typedef struct { - * rtems_jffs2_flash_control super; - * unsigned char area[FLASH_SIZE]; - * } flash_control; - * - * static flash_control *get_flash_control(rtems_jffs2_flash_control *super) - * { - * return (flash_control *) super; - * } - * - * static int flash_read( - * rtems_jffs2_flash_control *super, - * uint32_t offset, - * unsigned char *buffer, - * size_t size_of_buffer - * ) - * { - * flash_control *self = get_flash_control(super); - * unsigned char *chunk = &self->area[offset]; - * - * memcpy(buffer, chunk, size_of_buffer); - * - * return 0; - * } - * - * static int flash_write( - * rtems_jffs2_flash_control *super, - * uint32_t offset, - * const unsigned char *buffer, - * size_t size_of_buffer - * ) - * { - * flash_control *self = get_flash_control(super); - * unsigned char *chunk = &self->area[offset]; - * size_t i; - * - * for (i = 0; i < size_of_buffer; ++i) { - * chunk[i] &= buffer[i]; - * } - * - * return 0; - * } - * - * static int flash_erase( - * rtems_jffs2_flash_control *super, - * uint32_t offset - * ) - * { - * flash_control *self = get_flash_control(super); - * unsigned char *chunk = &self->area[offset]; - * - * memset(chunk, 0xff, BLOCK_SIZE); - * - * return 0; - * } - * - * static flash_control flash_instance = { - * .super = { - * .block_size = BLOCK_SIZE, - * .flash_size = FLASH_SIZE, - * .read = flash_read, - * .write = flash_write, - * .erase = flash_erase, - * .device_identifier = 0xc01dc0fe - * } - * }; - * - * static rtems_jffs2_compressor_zlib_control compressor_instance = { - * .super = { - * .compress = rtems_jffs2_compressor_zlib_compress, - * .decompress = rtems_jffs2_compressor_zlib_decompress - * } - * }; - * - * static const rtems_jffs2_mount_data mount_data = { - * .flash_control = &flash_instance.super, - * .compressor_control = &compressor_instance.super - * }; - * - * static void erase_all(void) - * { - * memset(&flash_instance.area[0], 0xff, FLASH_SIZE); - * } - * - * void example_jffs2_mount(const char *mount_dir) - * { - * int rv; - * - * erase_all(); - * - * rv = mount_and_make_target_path( - * NULL, - * mount_dir, - * RTEMS_FILESYSTEM_TYPE_JFFS2, - * RTEMS_FILESYSTEM_READ_WRITE, - * &mount_data - * ); - * assert(rv == 0); - * } - * @endcode - * - * @{ - */ - -/** - * @brief Read from flash operation. - * - * @param[in, out] self The flash control. - * @param[in] offset The offset to read from the flash begin in bytes. - * @param[out] buffer The buffer receiving the data. - * @param[in] size_of_buffer The size of the buffer in bytes. - * - * @retval 0 Successful operation. - * @retval -EIO An error occurred. Please note that the value is negative. - * @retval other All other values are reserved and must not be used. - */ -typedef int (*rtems_jffs2_flash_read)( - rtems_jffs2_flash_control *self, - uint32_t offset, - unsigned char *buffer, - size_t size_of_buffer -); - -/** - * @brief Write to flash operation. - * - * @param[in, out] self The flash control. - * @param[in] offset The offset to write from the flash begin in bytes. - * @param[in] buffer The buffer containing the data to write. - * @param[in] size_of_buffer The size of the buffer in bytes. - * - * @retval 0 Successful operation. - * @retval -EIO An error occurred. Please note that the value is negative. - * @retval other All other values are reserved and must not be used. - */ -typedef int (*rtems_jffs2_flash_write)( - rtems_jffs2_flash_control *self, - uint32_t offset, - const unsigned char *buffer, - size_t size_of_buffer -); - -/** - * @brief Flash erase operation. - * - * This operation must erase one block specified by the offset. - * - * @param[in, out] self The flash control. - * @param[in] offset The offset to erase from the flash begin in bytes. - * - * @retval 0 Successful operation. - * @retval -EIO An error occurred. Please note that the value is negative. - * @retval other All other values are reserved and must not be used. - */ -typedef int (*rtems_jffs2_flash_erase)( - rtems_jffs2_flash_control *self, - uint32_t offset -); - -/** - * @brief Flash destroy operation. - * - * The flash destroy operation is called during unmount of the file system - * instance. It can be used to free the resources associated with the now - * unused flash control - * - * @param[in, out] self The flash control. - */ -typedef void (*rtems_jffs2_flash_destroy)( - rtems_jffs2_flash_control *self -); - -/** - * @brief Trigger garbage collection operation. - * - * An optional garbage collection thread may perform now a garbage collection - * using the RTEMS_JFFS2_ON_DEMAND_GARBAGE_COLLECTION IO control. - * - * The garbage collection must not run in the executing context. - * - * @param[in] self The flash control. - */ -typedef void (*rtems_jffs2_trigger_garbage_collection)( - rtems_jffs2_flash_control *self -); - -/** - * @brief JFFS2 flash device control. - */ -struct rtems_jffs2_flash_control { - /** - * @brief The size in bytes of the erasable unit of the flash device. - */ - uint32_t block_size; - - /** - * @brief The size in bytes of the flash device. - * - * It must be an integral multiple of the block size. The flash device must - * have at least five blocks. - */ - uint32_t flash_size; - - /** - * @brief Read from flash operation. - */ - rtems_jffs2_flash_read read; - - /** - * @brief Write to flash operation. - */ - rtems_jffs2_flash_write write; - - /** - * @brief Flash erase operation. - */ - rtems_jffs2_flash_erase erase; - - /** - * @brief Flash destroy operation. - * - * This operation is optional and the pointer may be @c NULL. - */ - rtems_jffs2_flash_destroy destroy; - - /** - * @brief The device identifier of the flash device. - * - * It is used in combination with the inode number to uniquely identify a - * file system node in the system. - */ - dev_t device_identifier; - - /** - * @brief Trigger garbage collection operation. - * - * This operation is optional and may be NULL. This operation should wake up - * a garbage collection thread. The garbage collection thread should use the - * RTEMS_JFFS2_ON_DEMAND_GARBAGE_COLLECTION IO control to carry out the work. - */ - rtems_jffs2_trigger_garbage_collection trigger_garbage_collection; -}; - -typedef struct rtems_jffs2_compressor_control rtems_jffs2_compressor_control; - -/** - * @brief Compress operation. - * - * @param[in, out] self The compressor control. - * @param[in] data_in The uncompressed data. - * @param[out] cdata_out Pointer to buffer with the compressed data. - * @param[in, out] datalen On entry, the size in bytes of the uncompressed - * data. On exit, the size in bytes of uncompressed data which was actually - * compressed. - * @param[in, out] cdatalen On entry, the size in bytes available for - * compressed data. On exit, the size in bytes of the actually compressed - * data. - * - * @return The compressor type. - */ -typedef uint16_t (*rtems_jffs2_compressor_compress)( - rtems_jffs2_compressor_control *self, - unsigned char *data_in, - unsigned char *cdata_out, - uint32_t *datalen, - uint32_t *cdatalen -); - -/** - * @brief Decompress operation. - * - * @param[in, out] self The compressor control. - * @param[in] comprtype The compressor type. - * @param[in] cdata_in The compressed data. - * @param[out] data_out The uncompressed data. - * @param[in] cdatalen The size in bytes of the compressed data. - * @param[in] datalen The size in bytes of the uncompressed data. - * - * @retval 0 Successful operation. - * @retval -EIO An error occurred. Please note that the value is negative. - * @retval other All other values are reserved and must not be used. - */ -typedef int (*rtems_jffs2_compressor_decompress)( - rtems_jffs2_compressor_control *self, - uint16_t comprtype, - unsigned char *cdata_in, - unsigned char *data_out, - uint32_t cdatalen, - uint32_t datalen -); - -/** - * @brief Compressor destroy operation. - * - * The compressor destroy operation is called during unmount of the file system - * instance. It can be used to free the resources associated with the now - * unused compressor operations. - * - * @param[in, out] self The compressor control. - */ -typedef void (*rtems_jffs2_compressor_destroy)( - rtems_jffs2_compressor_control *self -); - -/** - * @brief JFFS2 compressor control. - */ -struct rtems_jffs2_compressor_control { - /** - * @brief Compress operation. - */ - rtems_jffs2_compressor_compress compress; - - /** - * @brief Decompress operation. - */ - rtems_jffs2_compressor_decompress decompress; - - /** - * @brief Compressor destroy operation. - * - * This operation is optional and the pointer may be @c NULL. - */ - rtems_jffs2_compressor_destroy destroy; - - /** - * @brief Compression buffer. - */ - unsigned char buffer[PAGE_SIZE]; -}; - -/** - * @brief RTIME compressor compress operation. - */ -uint16_t rtems_jffs2_compressor_rtime_compress( - rtems_jffs2_compressor_control *self, - unsigned char *data_in, - unsigned char *cdata_out, - uint32_t *datalen, - uint32_t *cdatalen -); - -/** - * @brief RTIME compressor decompress operation. - */ -int rtems_jffs2_compressor_rtime_decompress( - rtems_jffs2_compressor_control *self, - uint16_t comprtype, - unsigned char *cdata_in, - unsigned char *data_out, - uint32_t cdatalen, - uint32_t datalen -); - -/** - * @brief ZLIB compressor control structure. - */ -typedef struct { - rtems_jffs2_compressor_control super; - z_stream stream; -} rtems_jffs2_compressor_zlib_control; - -/** - * @brief ZLIB compressor compress operation. - */ -uint16_t rtems_jffs2_compressor_zlib_compress( - rtems_jffs2_compressor_control *self, - unsigned char *data_in, - unsigned char *cdata_out, - uint32_t *datalen, - uint32_t *cdatalen -); - -/** - * @brief ZLIB compressor decompress operation. - */ -int rtems_jffs2_compressor_zlib_decompress( - rtems_jffs2_compressor_control *self, - uint16_t comprtype, - unsigned char *cdata_in, - unsigned char *data_out, - uint32_t cdatalen, - uint32_t datalen -); - -/** - * @brief JFFS2 mount options. - * - * For JFFS2 the mount options are mandatory. - */ -typedef struct { - /** - * @brief Flash control. - */ - rtems_jffs2_flash_control *flash_control; - - /** - * @brief Compressor control. - * - * The compressor is optional and this pointer may be @c NULL. - */ - rtems_jffs2_compressor_control *compressor_control; -} rtems_jffs2_mount_data; - -/** - * @brief Initialization handler of the JFFS2 file system. - * - * @param[in, out] mt_entry The mount table entry. - * @param[in] data The mount options are mandatory for JFFS2 and data must - * point to a valid @ref rtems_jffs2_mount_data structure used for this file - * system instance. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The @c errno indicates the error. - * - * @see mount(). - */ -int rtems_jffs2_initialize( - rtems_filesystem_mount_table_entry_t *mt_entry, - const void *data -); - -/** - * @brief JFFS2 filesystem instance information. - * - * @see RTEMS_JFFS2_GET_INFO. - */ -typedef struct { - /** - * @brief Flash size in bytes. - */ - uint32_t flash_size; - - /** - * @brief Count of flash blocks (erasable units). - */ - uint32_t flash_blocks; - - /** - * @brief Size of a flash block in bytes. - */ - uint32_t flash_block_size; - - /** - * @brief Used size in bytes. - * - * Used areas contain valid data. - */ - uint32_t used_size; - - /** - * @brief Dirty size in bytes. - * - * Used areas contain no longer used data. - */ - uint32_t dirty_size; - - /** - * @brief Wasted size in bytes. - * - * Wasted areas are unusable. - */ - uint32_t wasted_size; - - /** - * @brief Free size in bytes. - * - * Free areas may be used to store new data. - */ - uint32_t free_size; - - /** - * @brief Bad size in bytes. - * - * Bad areas indicate damaged flash blocks. - */ - uint32_t bad_size; - - /** - * @brief Count of clean blocks. - * - * Clean blocks contain only used areas. - */ - uint32_t clean_blocks; - - /** - * @brief Count of dirty blocks. - * - * Dirty blocks contain dirty and used areas. - */ - uint32_t dirty_blocks; - - /** - * @brief Count of erasable blocks. - * - * Erase blocks contain only dirty or wasted areas. - */ - uint32_t erasable_blocks; - - /** - * @brief Count of free blocks. - * - * Free blocks contain a free area. - */ - uint32_t free_blocks; - - /** - * @brief Count of bad blocks. - * - * Bad blocks are damaged. - */ - uint32_t bad_blocks; -} rtems_jffs2_info; - -/** - * @brief IO control to get the JFFS2 filesystem instance information. - * - * @see rtems_jffs2_info. - */ -#define RTEMS_JFFS2_GET_INFO _IOR('F', 1, rtems_jffs2_info) - -/** - * @brief IO control to perform an on demand garbage collection in a JFFS2 - * filesystem instance. - * - * This operation is intended to be used by an optional garbage collection - * thread. See rtems_jffs2_flash_control::trigger_garbage_collection. - */ -#define RTEMS_JFFS2_ON_DEMAND_GARBAGE_COLLECTION _IO('F', 2) - -/** - * @brief IO control to force a garbage collection in a JFFS2 filesystem - * instance. - * - * Use this operation with care since it may wear out your flash. - */ -#define RTEMS_JFFS2_FORCE_GARBAGE_COLLECTION _IO('F', 3) - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* RTEMS_JFFS2_H */ diff --git a/cpukit/libfs/src/nfsclient/Makefile.am b/cpukit/libfs/src/nfsclient/Makefile.am index 85f4a71756..04d840f507 100644 --- a/cpukit/libfs/src/nfsclient/Makefile.am +++ b/cpukit/libfs/src/nfsclient/Makefile.am @@ -10,6 +10,11 @@ dirutils_rel_LDFLAGS = $(RTEMS_RELLDFLAGS) if LIBNETWORKING project_lib_LIBRARIES = libnfs.a +$(PROJECT_LIB)/libnfs.a: libnfs.a + $(INSTALL_DATA) $< $(PROJECT_LIB)/libnfs.a +TMPINSTALL_FILES = $(PROJECT_LIB)/libnfs.a + + # if you have CEXP set this variable to 'YES' # and some "help" info will be compiled in. libnfs_a_SOURCES = src/rpcio.c src/rpcio.h @@ -19,8 +24,6 @@ libnfs_a_SOURCES += proto/mount_prot.h proto/nfs_prot.h # With CEXP # libnfs_a_SOURCES += dirutils.c rpcio.modini.c nfs.modini.c cexphelp.c -include_HEADERS = src/librtemsNfs.h - # PGMS=${ARCH}/nfs.obj ${ARCH}/rpcio.obj ${ARCH}/dirutils.obj libnfs_a_CPPFLAGS = $(AM_CPPFLAGS) @@ -66,5 +69,4 @@ $(srcdir)/proto/nfs_prot_xdr.c: proto/nfs_prot.x proto/nfs_prot.h > nfs_prot_xdr.c) endif -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am diff --git a/cpukit/libfs/src/nfsclient/preinstall.am b/cpukit/libfs/src/nfsclient/preinstall.am deleted file mode 100644 index 593fc0367d..0000000000 --- a/cpukit/libfs/src/nfsclient/preinstall.am +++ /dev/null @@ -1,51 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -all-local: $(TMPINSTALL_FILES) - -TMPINSTALL_FILES = -CLEANFILES += $(TMPINSTALL_FILES) - -$(PROJECT_LIB)/$(dirstamp): - @$(MKDIR_P) $(PROJECT_LIB) - @: > $(PROJECT_LIB)/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_LIB)/$(dirstamp) - -$(PROJECT_INCLUDE)/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE) - @: > $(PROJECT_INCLUDE)/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/$(dirstamp) - -$(PROJECT_LIB)/dirutils.rel: dirutils.rel $(PROJECT_LIB)/$(dirstamp) - $(INSTALL_PROGRAM) $< $(PROJECT_LIB)/dirutils.rel -TMPINSTALL_FILES += $(PROJECT_LIB)/dirutils.rel - -if LIBNETWORKING -$(PROJECT_LIB)/libnfs.a: libnfs.a $(PROJECT_LIB)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_LIB)/libnfs.a -TMPINSTALL_FILES += $(PROJECT_LIB)/libnfs.a - -$(PROJECT_INCLUDE)/librtemsNfs.h: src/librtemsNfs.h $(PROJECT_INCLUDE)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/librtemsNfs.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/librtemsNfs.h - -$(PROJECT_LIB)/nfs.rel: nfs.rel $(PROJECT_LIB)/$(dirstamp) - $(INSTALL_PROGRAM) $< $(PROJECT_LIB)/nfs.rel -TMPINSTALL_FILES += $(PROJECT_LIB)/nfs.rel - -$(PROJECT_LIB)/rpcio.rel: rpcio.rel $(PROJECT_LIB)/$(dirstamp) - $(INSTALL_PROGRAM) $< $(PROJECT_LIB)/rpcio.rel -TMPINSTALL_FILES += $(PROJECT_LIB)/rpcio.rel -endif diff --git a/cpukit/libfs/src/nfsclient/src/librtemsNfs.h b/cpukit/libfs/src/nfsclient/src/librtemsNfs.h deleted file mode 100644 index 530eee2144..0000000000 --- a/cpukit/libfs/src/nfsclient/src/librtemsNfs.h +++ /dev/null @@ -1,234 +0,0 @@ -/** - * @file - * - * @brief Public Interface to the NFS Client Library for RTEMS - * - * @ingroup rtems-nfsclient - */ - -/* - * Author: Till Straumann 2002-2003 - * - * Authorship - * ---------- - * This software (NFS-2 client implementation for RTEMS) was created by - * Till Straumann , 2002-2007, - * Stanford Linear Accelerator Center, Stanford University. - * - * Acknowledgement of sponsorship - * ------------------------------ - * The NFS-2 client implementation for RTEMS was produced by - * the Stanford Linear Accelerator Center, Stanford University, - * under Contract DE-AC03-76SFO0515 with the Department of Energy. - * - * Government disclaimer of liability - * ---------------------------------- - * Neither the United States nor the United States Department of Energy, - * nor any of their employees, makes any warranty, express or implied, or - * assumes any legal liability or responsibility for the accuracy, - * completeness, or usefulness of any data, apparatus, product, or process - * disclosed, or represents that its use would not infringe privately owned - * rights. - * - * Stanford disclaimer of liability - * -------------------------------- - * Stanford University makes no representations or warranties, express or - * implied, nor assumes any liability for the use of this software. - * - * Stanford disclaimer of copyright - * -------------------------------- - * Stanford University, owner of the copyright, hereby disclaims its - * copyright and all other rights in this software. Hence, anyone may - * freely use it for any purpose without restriction. - * - * Maintenance of notices - * ---------------------- - * In the interest of clarity regarding the origin and status of this - * SLAC software, this and all the preceding Stanford University notices - * are to remain affixed to any copy or derivative of this software made - * or distributed by the recipient and are to be affixed to any copy of - * software made or distributed by the recipient that contains a copy or - * derivative of this software. - * - * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03 - */ - -#ifndef LIB_RTEMS_NFS_CLIENT_H -#define LIB_RTEMS_NFS_CLIENT_H - -/** - * @defgroup rtems-nfsclient NFS Client Library - * - * @ingroup nfsclient - * @{ - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** RPCIO driver interface. - * If you need RPCIO for other purposes than NFS - * you may want to include -#include "rpcio.h" - */ - -/** Priority of daemon; may be setup prior to calling rpcUdpInit(); - * otherwise the network task priority from the rtems_bsdnet_config - * is used... - */ -extern rtems_task_priority rpciodPriority; - -#ifdef RTEMS_SMP -/** CPU affinity of daemon; may be setup prior to calling rpcUdpInit(); - * otherwise the network task CPU affinity from the rtems_bsdnet_config - * is used... - */ -extern const cpu_set_t *rpciodCpuset; -extern size_t rpciodCpusetSize; -#endif - -/** - * @brief Sets the XIDs of the RPC transaction hash table. - * - * The active RPC transactions are stored in a hash table. Each table entry - * contains the XID of its corresponding transaction. The XID consists of two - * parts. The lower part is determined by the hash table index. The upper - * part is incremented in each send operation. - * - * This function sets the upper part of the XID in all hash table entries. - * This can be used to ensure that the XIDs are not reused in a short interval - * for example during a boot process or after resets. - * - * @param[in] xid The upper part is used to set the upper XID part of the hash - * table entries. - */ -void -rpcSetXIDs(uint32_t xid); - -/** Initialize the driver. - * - * Note, called in nfsfs initialise when mount is called. - * - * @retval 0 on success, -1 on failure - */ -int -rpcUdpInit(void); - -/** - * @brief RPC cleanup and stop. - * - * @retval 0 on success, nonzero if still in use - */ -int -rpcUdpCleanup(void); - -/** NFS driver interface */ - -/** - * @brief Initialize the NFS driver. - * - * The RPCIO driver must have been initialized prior to calling this. - * - * Note, called in nfsfs initialise when mount is called with defaults. - * - * ARGS: depth of the small and big - * transaction pools, i.e. how - * many transactions (buffers) - * should always be kept around. - * - * (If more transactions are needed, - * they are created and destroyed - * on the fly). - * - * Supply zero values to have the - * driver chose reasonable defaults. - * - * @retval 0 Successful operation. - * @retval -1 An error occurred. The errno is set to indicate the error. - */ -int -nfsInit(int smallPoolDepth, int bigPoolDepth); - -/** - * @brief Driver cleanup code. - * - * @retval 0 on success, nonzero if still in use - */ -int -nfsCleanup(void); - -/** - * @brief Dump a list of the currently mounted NFS to a file. - * - * Dump a list of the currently mounted NFS to a file - * (stdout is used in case f==NULL) - */ -int -nfsMountsShow(FILE *f); - -/** - * @brief Filesystem mount table mount handler. - * - * Filesystem mount table mount handler. Do not call, use the mount call. - */ -int -rtems_nfs_initialize(rtems_filesystem_mount_table_entry_t *mt_entry, - const void *data); - -/** - * @brief A utility routine to find the path leading to a - * rtems_filesystem_location_info_t node. - * - * This should really be present in libcsupport... - * - * @param[in] 'loc' and a buffer 'buf' (length 'len') to hold the path. - * - * @param[out] path copied into 'buf' - * - * @retval 0 on success, RTEMS error code on error. - */ -rtems_status_code -rtems_filesystem_resolve_location(char *buf, int len, rtems_filesystem_location_info_t *loc); - -/** - * @brief Set the timeout (initial default: 10s) for NFS and mount calls. - * - * Set the timeout (initial default: 10s) for NFS and mount calls. - * - * @retval 0 on success, nonzero if the requested timeout is less than - * a clock tick or if the system clock rate cannot be determined. - */ - -int -nfsSetTimeout(uint32_t timeout_ms); - -/** Read current timeout (in milliseconds) */ -uint32_t -nfsGetTimeout(void); - -#ifdef __cplusplus -} -#endif - -/** @} */ -#endif diff --git a/cpukit/libfs/src/pipe/pipe.h b/cpukit/libfs/src/pipe/pipe.h deleted file mode 100644 index 7c6566ad50..0000000000 --- a/cpukit/libfs/src/pipe/pipe.h +++ /dev/null @@ -1,133 +0,0 @@ -/** - * @file - * - * @brief POSIX FIFO/pipe File System Support - * - * This include file defines the interface to the POSIX FIFO/pipe file system - * support. - */ - -/* - * Author: Wei Shen - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_PIPE_H -#define _RTEMS_PIPE_H - -#include - -/** - * @defgroup FIFO_PIPE FIFO/Pipe File System Support - * - * @ingroup FileSystemTypesAndMount - * - * @brief Interface to the POSIX FIFO/Pipe File System - */ -/**@{*/ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Control block to manage each pipe */ -typedef struct pipe_control { - char *Buffer; - unsigned int Size; - unsigned int Start; - unsigned int Length; - unsigned int Readers; - unsigned int Writers; - unsigned int waitingReaders; - unsigned int waitingWriters; - unsigned int readerCounter; /* incremental counters */ - unsigned int writerCounter; /* for differentiation of successive opens */ - rtems_id Semaphore; - rtems_id readBarrier; /* wait queues */ - rtems_id writeBarrier; -#if 0 - boolean Anonymous; /* anonymous pipe or FIFO */ -#endif -} pipe_control_t; - -/** - * @brief Create an anonymous pipe. - * - * Called by pipe() to create an anonymous pipe. - */ -extern int pipe_create( - int filsdes[2] -); - -/** - * @brief Release a pipe. - * - * Interface to file system close. - * - * *pipep points to pipe control structure. When the last user releases pipe, - * it will be set to NULL. - */ -extern void pipe_release( - pipe_control_t **pipep, - rtems_libio_t *iop -); - -/** - * @brief File system open. - * Interface to file system open. - * - * *pipep points to pipe control structure. If called with *pipep = NULL, - * fifo_open will try allocating and initializing a control structure. If the - * call succeeds, *pipep will be set to address of new control structure. - */ -extern int fifo_open( - pipe_control_t **pipep, - rtems_libio_t *iop -); - -/** - * @brief File system read. - * - * Interface to file system read. - */ -extern ssize_t pipe_read( - pipe_control_t *pipe, - void *buffer, - size_t count, - rtems_libio_t *iop -); - -/** - * @brief File system write. - * - * Interface to file system write. - */ -extern ssize_t pipe_write( - pipe_control_t *pipe, - const void *buffer, - size_t count, - rtems_libio_t *iop -); - -/** - * @brief File system Input/Output control. - * - * Interface to file system ioctl. - */ -extern int pipe_ioctl( - pipe_control_t *pipe, - ioctl_command_t cmd, - void *buffer, - rtems_libio_t *iop -); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs-bitmaps.h b/cpukit/libfs/src/rfs/rtems-rfs-bitmaps.h deleted file mode 100644 index 5574339421..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-bitmaps.h +++ /dev/null @@ -1,326 +0,0 @@ -/** - * @file - * - * @brief RTEMS File Systems Bitmap Routines - * - * @ingroup rtems_rfs - * - * RTEMS File Systems Bitmap Routines. - * - * These functions manage bit maps. A bit map consists of the map of bit - * allocated in a block and a search map where a bit represents 32 actual - * bits. The search map allows for a faster search for an available bit as 32 - * search bits can checked in a test. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - - -#if !defined (_RTEMS_RFS_BITMAPS_H_) -#define _RTEMS_RFS_BITMAPS_H_ - -#include -#include -#include - -/** - * Define the way the bits are configured. We can have them configured as clear - * being 0 or clear being 1. This does not effect how masks are defined. A mask - * always has a 1 for set and 0 for clear. - */ -#define RTEMS_RFS_BITMAP_CLEAR_ZERO 0 - -#if RTEMS_RFS_BITMAP_CLEAR_ZERO -/* - * Bit set is a 1 and clear is 0. - */ -#define RTEMS_RFS_BITMAP_BIT_CLEAR 0 -#define RTEMS_RFS_BITMAP_BIT_SET 1 -#define RTEMS_RFS_BITMAP_ELEMENT_SET (RTEMS_RFS_BITMAP_ELEMENT_FULL_MASK) -#define RTEMS_RFS_BITMAP_ELEMENT_CLEAR (0) -#define RTEMS_RFS_BITMAP_SET_BITS(_t, _b) ((_t) | (_b)) -#define RTEMS_RFS_BITMAP_CLEAR_BITS(_t, _b) ((_t) & ~(_b)) -#define RTEMS_RFS_BITMAP_TEST_BIT(_t, _b) (((_t) & (1 << (_b))) != 0 ? true : false) -#else -/* - * Bit set is a 0 and clear is 1. - */ -#define RTEMS_RFS_BITMAP_BIT_CLEAR 1 -#define RTEMS_RFS_BITMAP_BIT_SET 0 -#define RTEMS_RFS_BITMAP_ELEMENT_SET (0) -#define RTEMS_RFS_BITMAP_ELEMENT_CLEAR (RTEMS_RFS_BITMAP_ELEMENT_FULL_MASK) -#define RTEMS_RFS_BITMAP_SET_BITS(_t, _b) ((_t) & ~(_b)) -#define RTEMS_RFS_BITMAP_CLEAR_BITS(_t, _b) ((_t) | (_b)) -#define RTEMS_RFS_BITMAP_TEST_BIT(_t, _b) (((_t) & (1 << (_b))) == 0 ? true : false) -#endif - -/** - * Invert a mask. Masks are always 1 for set and 0 for clear. - */ -#define RTEMS_RFS_BITMAP_INVERT_MASK(_mask) (~(_mask)) - -/** - * This is the full mask of the length of the element. A mask is always a 1 for - * set and 0 for clear. It is not effected by the state of - * RTEMS_RFS_BITMAP_CLEAR_ZERO. - */ -#define RTEMS_RFS_BITMAP_ELEMENT_FULL_MASK (0xffffffffUL) - -/** - * The bitmap search window. Searches occur around a seed in either direction - * for half the window. - */ -#define RTEMS_RFS_BITMAP_SEARCH_WINDOW (rtems_rfs_bitmap_element_bits () * 64) - -/** - * A bit in a map. - */ -typedef int32_t rtems_rfs_bitmap_bit; - -/** - * The basic element of a bitmap. A bitmap is manipulated by elements. - */ -typedef uint32_t rtems_rfs_bitmap_element; - -/** - * The power of 2 number of bits in the element. - */ -#define RTEMS_RFS_ELEMENT_BITS_POWER_2 (5) - -/** - * A bitmap or map is an array of bitmap elements. - */ -typedef rtems_rfs_bitmap_element* rtems_rfs_bitmap_map; - -/** - * The bitmap control is a simple way to manage the various parts of a bitmap. - */ -typedef struct rtems_rfs_bitmap_control_s -{ - rtems_rfs_buffer_handle* buffer; //< Handle the to buffer with the bit - //map. - rtems_rfs_file_system* fs; //< The map's file system. - rtems_rfs_buffer_block block; //< The map's block number on disk. - size_t size; //< Number of bits in the map. Passed - //to create. - size_t free; //< Number of bits in the map that are - //free (clear). - rtems_rfs_bitmap_map search_bits; //< The search bit map memory. -} rtems_rfs_bitmap_control; - -/** - * Return the number of bits for the number of bytes provided. - */ -#define rtems_rfs_bitmap_numof_bits(_bytes) (8 * (_bytes)) - -/** - * Return the number of bits for the number of bytes provided. The search - * element and the element must have the same number of bits. - */ -#define rtems_rfs_bitmap_element_bits() \ - rtems_rfs_bitmap_numof_bits (sizeof (rtems_rfs_bitmap_element)) - -/** - * Return the number of bits a search element covers. - */ -#define rtems_rfs_bitmap_search_element_bits() \ - (rtems_rfs_bitmap_element_bits() * rtems_rfs_bitmap_element_bits()) - -/** - * Return the number of elements for a given number of bits. - */ -#define rtems_rfs_bitmap_elements(_bits) \ - ((((_bits) - 1) / rtems_rfs_bitmap_element_bits()) + 1) - -/** - * Release the bitmap buffer back to the buffer pool or cache. - */ -#define rtems_rfs_bitmap_release_buffer(_fs, _bm) \ - rtems_rfs_buffer_handle_release (_fs, (_bm)->buffer) - -/** - * Return the element index for a given bit. We use a macro to hide any - * implementation assuptions. Typically this would be calculated by dividing - * the bit index by the number of bits in an element. Given we have a power of - * 2 as the number of bits we can avoid the division by using a shift. A good - * compiler should figure this out but I would rather enforce this than rely on - * the specific backend of a compiler to do the right thing. - */ -#define rtems_rfs_bitmap_map_index(_b) \ - ((_b) >> RTEMS_RFS_ELEMENT_BITS_POWER_2) - -/** - * Return the bit offset for a given bit in an element in a map. See @ref - * rtems_rfs_bitmap_map_index for a detailed reason why. - */ -#define rtems_rfs_bitmap_map_offset(_b) \ - ((_b) & ((1 << RTEMS_RFS_ELEMENT_BITS_POWER_2) - 1)) - -/** - * Return the size of the bitmap. - */ -#define rtems_rfs_bitmap_map_size(_c) ((_c)->size) - -/** - * Return the number of free bits in the bitmap. - */ -#define rtems_rfs_bitmap_map_free(_c) ((_c)->free) - -/** - * Return the buffer handle. - */ -#define rtems_rfs_bitmap_map_handle(_c) ((_c)->buffer) - -/** - * Return the bitmap map block. - */ -#define rtems_rfs_bitmap_map_block(_c) ((_c)->block) - -/** - * Create a bit mask with the specified number of bits up to an element's - * size. The mask is aligned to bit 0 of the element. - * - * @param[in] size is the number of bits in the mask. - * - * @return The mask of the argument size number of bits. - */ -rtems_rfs_bitmap_element rtems_rfs_bitmap_mask (unsigned int size); - -/** - * Create a bit mask section. A mask section is a mask that is not aligned to - * an end of the element. - * - * @param[in] start is the first bit of the mask numbered from 0. - * @param[in] end is the end bit of the mask numbered from 0. - * - * @return Mask section as defined by the start and end arguments. - */ -rtems_rfs_bitmap_element rtems_rfs_bitmap_mask_section (unsigned int start, - unsigned int end); - -/** - * Set a bit in a map and if all the bits are set, set the search map bit as - * well. - * - * @param[in] control is the control for the map. - * @param[in] bit is the bit in the map to set. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_bitmap_map_set (rtems_rfs_bitmap_control* control, - rtems_rfs_bitmap_bit bit); - -/** - * Clear a bit in a map and make sure the search map bit is clear so a search - * will find this bit available. - * - * @param[in] control is the control for the map. - * @param[in] bit is the bit in the map to clear. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_bitmap_map_clear (rtems_rfs_bitmap_control* control, - rtems_rfs_bitmap_bit bit); - -/** - * Test a bit in the map. - * - * @param[in] control is the bitmap control. - * @param[in] bit is the bit to test. - * @param[in] state is the state of the bit if no error is returned. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int -rtems_rfs_bitmap_map_test (rtems_rfs_bitmap_control* control, - rtems_rfs_bitmap_bit bit, - bool* state); - -/** - * Set all bits in the bitmap and set the dirty bit. - * - * @param[in] control is the bitmap control. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_bitmap_map_set_all (rtems_rfs_bitmap_control* control); - -/** - * Clear all bits in the bitmap and set the dirty bit. - * - * @param[in] control is the bitmap control. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_bitmap_map_clear_all (rtems_rfs_bitmap_control* control); - -/** - * Find a free bit searching from the seed up and down until found. The search - * is performing by moving up from the seed for the window distance then to - * search down from the seed for the window distance. This is repeated out - * from the seed for each window until a free bit is found. The search is - * performed by checking the search map to see if the map has a free bit. - * - * @param[in] control is the map control. - * @param[in] seed is the bit to search out from. - * @param[out] allocate A bit was allocated. - * @param[out] bit will contain the bit found free if true is returned. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_bitmap_map_alloc (rtems_rfs_bitmap_control* control, - rtems_rfs_bitmap_bit seed, - bool* allocate, - rtems_rfs_bitmap_bit* bit); - -/** - * Create a search bit map from the actual bit map. - * - * @param[in] control is the map control. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_bitmap_create_search (rtems_rfs_bitmap_control* control); - -/** - * Open a bitmap control with a map and search map. - * - * @param[in] control is the map control. - * @param[in] fs is the file system data. - * @param[in] buffer is a pointer to the buffer handle the map is - * stored in. - * @param[in] size is the number of bits in the map. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_bitmap_open (rtems_rfs_bitmap_control* control, - rtems_rfs_file_system* fs, - rtems_rfs_buffer_handle* buffer, - size_t size, - rtems_rfs_buffer_block block); - -/** - * Close a bitmap. - * - * @param[in] control is the bit map control. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_bitmap_close (rtems_rfs_bitmap_control* control); - -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs-block-pos.h b/cpukit/libfs/src/rfs/rtems-rfs-block-pos.h deleted file mode 100644 index 7d0f0693be..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-block-pos.h +++ /dev/null @@ -1,242 +0,0 @@ -/** - * @file - * - * @brief RTEMS File Systems Block Position and Size Management - * - * @ingroup rtems_rfs - * - * RTEMS File Systems Block Position and Size Management. - * - * These functions manage the position in a block map as well as a size of data - * held in a block map. The position is the block count plus the offset into - * the last block where a block position of 0 and an offset of 0 is the start - * of a map. The size has a block count plus an offset, but the offset into the - * last block gives the actual size of the data in the map. This means a size - * will always have a block count greater than 0 when the file is not empty. A - * size offset of 0 and a non-zero block count means the length if aligned to - * the end of the block. For this reason there are 2 similar types so we know - * which set of rules are in use and the reason for this file. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if !defined (_RTEMS_RFS_BLOCK_POS_H_) -#define _RTEMS_RFS_BLOCK_POS_H_ - -#include -#include - -/** - * The block number is the same type as the inode block number. This makes sure - * the sizes of the types match. - */ -typedef rtems_rfs_inode_block rtems_rfs_block_no; - -/** - * The offset into a block. - */ -typedef uint32_t rtems_rfs_block_off; - -/** - * A block position is a block number times the block size plus the offset. The - * block field can be used hold a block number for the position as a look up - * cache. - */ -typedef struct rtems_rfs_block_pos_s -{ - /** - * The block index in the map. Range is from 0 to the maps block count minus - * 1. - */ - rtems_rfs_block_no bno; - - /** - * The offset into the block. Must be less than the block size. - */ - rtems_rfs_block_off boff; - - /** - * The block number that the bpos + boff map to. The 0 value is invalid and - * means no block number has been set. - */ - rtems_rfs_block_no block; - -} rtems_rfs_block_pos; - -/** - * Copy a block position. - * - * @param[in] _lhs is the left hand side. - * @param[in] _rhs is the right hand side. - */ -#define rtems_rfs_block_copy_bpos(_lhs, _rhs) \ - do { (_lhs)->bno = (_rhs)->bno; \ - (_lhs)->boff = (_rhs)->boff; \ - (_lhs)->block = (_rhs)->block; } while (0) - -/** - * Zero a block position. - * - * @param[in] bpos is a pointer to the block position. - */ -static inline void -rtems_rfs_block_set_bpos_zero (rtems_rfs_block_pos* bpos) -{ - bpos->bno = 0; - bpos->boff = 0; - bpos->block = 0; -} - -/** - * Given a position compute the block number and block offset. - * - * @param[in] fs is the file system data. - * @param[in] pos is the position as an absolute offset from the start. - * @param[out] bpos is a pointer to the block position to fill in. - */ -void rtems_rfs_block_get_bpos (rtems_rfs_file_system* fs, - rtems_rfs_pos pos, - rtems_rfs_block_pos* bpos); - -/** - * Given a block position compute the absolute offset. - * - * @param[in] fs is the file system data. - * @param[out] bpos is a pointer to the block position to fill in. - * - * @retval offset The absolute offset. - */ -rtems_rfs_pos rtems_rfs_block_get_pos (rtems_rfs_file_system* fs, - rtems_rfs_block_pos* bpos); - -/** - * Add the relative position to the block position. The relative position is - * signed. - * - * @param[in] fs is the file system data. - * @param[in] offset is the relative offset add to the block position. - * @param[out] bpos is a pointer to the block position to fill in. - */ -static inline void -rtems_rfs_block_add_pos (rtems_rfs_file_system* fs, - rtems_rfs_pos_rel offset, - rtems_rfs_block_pos* bpos) -{ - rtems_rfs_block_get_bpos (fs, - rtems_rfs_block_get_pos (fs, bpos) + offset, - bpos); - bpos->block = 0; -} - -/** - * A block size is the number of blocks less one plus the offset where the - * offset must be less than the block size. - */ -typedef struct rtems_rfs_block_size_s -{ - /** - * The count of blocks in a map. A 0 means no blocks and a zero length and - * the offset should also be 0. - */ - rtems_rfs_block_no count; - - /** - * The offset into the block. An offset of 0 means block size, ie the first - * byte of the next block which is not allocated. - */ - rtems_rfs_block_off offset; - -} rtems_rfs_block_size; - -/** - * Copy a block size. - * - * @param[in] _lhs is the left hand side. - * @param[in] _rhs is the right hand side. - */ -#define rtems_rfs_block_copy_size(_lhs, _rhs) \ - do { (_lhs)->count = (_rhs)->count; \ - (_lhs)->offset = (_rhs)->offset; } while (0) - -/** - * Last block ? - */ -#define rtems_rfs_block_pos_last_block(_p, _s) \ - ((((_p)->bno == 0) && ((_s)->count == 0)) || ((_p)->bno == ((_s)->count - 1))) - -/** - * Last block ? - */ -#define rtems_rfs_block_pos_past_end(_p, _s) \ - (((_p)->bno && ((_s)->count == 0)) || \ - ((_p)->bno >= (_s)->count) || \ - (((_p)->bno == ((_s)->count - 1)) && ((_p)->boff > (_s)->offset))) - -/** - * Is the block position past the end. - */ -#define rtems_rfs_block_pos_block_past_end(_p, _s) \ - (((_p)->bno && ((_s)->count == 0)) || ((_p)->bno >= (_s)->count)) - -/** - * Copy the size to the block position. Note the block position and the size - * have different block counts. - */ -#define rtems_rfs_block_size_get_bpos(_s, _b) \ - do { (_b)->bno = (_s)->count; \ - (_b)->boff = (_s)->offset; \ - (_b)->block = 0; \ - if ((_b)->boff) --(_b)->bno; } while (0) - -/** - * Do the sizes match ? - */ -#define rtems_rfs_block_size_equal(_lhs, _rhs) \ - (((_lhs)->count == (_rhs)->count) && ((_lhs)->offset == (_rhs)->offset)) - -/** - * Zero a block size. - * - * @param[in] size is a pointer to the block size. - */ -static inline void -rtems_rfs_block_set_size_zero (rtems_rfs_block_size* size) -{ - size->count = 0; - size->offset = 0; -} - -/** - * Set the size given a position. - * - * @param[in] fs is the file system data. - * @param[in] pos is the position as an absolute offset from the start. - * @param[out] size is a pointer to the block size to fill in. - */ -void rtems_rfs_block_get_block_size (rtems_rfs_file_system* fs, - rtems_rfs_pos pos, - rtems_rfs_block_size* size); - -/** - * Calculate the position given the number of blocks and the offset. If the - * block count is 0 the size is 0. If the block is greater than 0 and the - * offset is 0 the size is number of blocks multipled by the block size and if - * the offset is not 0 it is the offset into the last block. For example if - * blocks is 1 and offset is 0 the size is the block size. If the block count - * is 1 and size is 100 the size is 100. - * - * @param[in] fs is the file system data. - * @param[in] size The size in blocks and offset. - * - * @retval size The size in bytes. - */ -rtems_rfs_pos rtems_rfs_block_get_size (rtems_rfs_file_system* fs, - rtems_rfs_block_size* size); - -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs-block.h b/cpukit/libfs/src/rfs/rtems-rfs-block.h deleted file mode 100644 index 394853b7ad..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-block.h +++ /dev/null @@ -1,344 +0,0 @@ -/** - * @file - * - * @brief RTEMS File Systems Block Management - * - * @ingroup rtems_rfs - * - * RTEMS File Systems Block Management. - * - * These functions manage the blocks used in the file system. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - - -#if !defined (_RTEMS_RFS_BLOCK_H_) -#define _RTEMS_RFS_BLOCK_H_ - -#include -#include -#include -#include - -/** - * Get a block number in the media format and return it in the host format. - * - * @param[in] _h is the buffer handle of the block. - * @param[in] _b is the block number index. - * - * @retval block The block number. - */ -#define rtems_rfs_block_get_number(_h, _b) \ - ((rtems_rfs_block_no) \ - (rtems_rfs_read_u32 (rtems_rfs_buffer_data (_h) + \ - ((_b) * sizeof (rtems_rfs_block_no))))) - -/** - * Set a block number in the media format given a number in the host format. - * - * @param[in] _h is the buffer handle of the block. - * @param[in] _b is the block number index, ie the number of block number not the - * buffer offset. - * @param[in] _n is the block number. - */ -#define rtems_rfs_block_set_number(_h, _b, _n) \ - do { \ - rtems_rfs_write_u32 (rtems_rfs_buffer_data (_h) + \ - ((_b) * sizeof (rtems_rfs_block_no)), (_n)); \ - rtems_rfs_buffer_mark_dirty (_h); \ - } while (0) - -/** - * A block map manges the block lists that originate from an inode. The inode - * contains a number of block numbers. A block map takes those block numbers - * and manages them. - * - * The blocks cannot have all ones as a block number nor block 0. The block map - * is series of block numbers in a blocks. The size of the map determines the - * way the block numbers are stored. The map uses the following: - * - * @li @e Direct Access, - * @li @e Single Indirect Access, and - * @li @e Double Indirect Access. - * - * Direct access has the blocks numbers in the inode slots. The Single Indirect - * Access has block numbers in the inode slots that pointer to a table of block - * numbers that point to data blocks. The Double Indirect Access has block - * numbers in the inode that point to Single Indirect block tables. - * - * The inode can hold a number of Direct, Single Indirect, and Double Indirect - * block tables. The move from Direct to Single occurs then the block count in - * the map is above the number of slots in the inode. The move from Single to - * Double occurs when the map block count is greated than the block numbers per - * block multipled by the slots in the inode. The move from Single to Double - * occurs when the map block count is over the block numbers per block squared - * multipled by the number of slots in the inode. - * - * The block map can managed files of the follow size verses block size with 5 - * inode slots: - * - * @li 41,943,040 bytes for a 512 byte block size, - * @li 335,544,320 bytes for a 1024 byte block size, - * @li 2,684,354,560 bytes for a 2048 byte block size, and - * @li 21,474,836,480 bytes for a 4096 byte block size. - */ -typedef struct rtems_rfs_block_map_s -{ - /** - * Is the map dirty ? - */ - bool dirty; - - /** - * The inode this map is attached to. - */ - rtems_rfs_inode_handle* inode; - - /** - * The size of the map. - */ - rtems_rfs_block_size size; - - /** - * The block map position. Used to navigate the map when seeking. The find - * call is to a position in the file/directory and is a block number plus - * offset. The block find only needs to locate a block and not worry about - * the offset while a seek can be less than a block size yet move across a - * block boundary. Therefore the position a block map has to maintain must - * include the offset so seeks work. - */ - rtems_rfs_block_pos bpos; - - /** - * The last map block allocated. This is used as the goal when allocating a - * new map block. - */ - rtems_rfs_block_no last_map_block; - - /** - * The last data block allocated. This is used as the goal when allocating a - * new data block. - */ - rtems_rfs_block_no last_data_block; - - /** - * The block map. - */ - uint32_t blocks[RTEMS_RFS_INODE_BLOCKS]; - - /** - * Singly Buffer handle. - */ - rtems_rfs_buffer_handle singly_buffer; - - /** - * Doubly Buffer handle. - */ - rtems_rfs_buffer_handle doubly_buffer; - -} rtems_rfs_block_map; - -/** - * Is the map dirty ? - */ -#define rtems_rfs_block_map_is_dirty(_m) ((_m)->dirty) - -/** - * Return the block count in the map. - */ -#define rtems_rfs_block_map_count(_m) ((_m)->size.count) - -/** - * Return the map's size element. - */ -#define rtems_rfs_block_map_size(_m) (&((_m)->size)) - -/** - * Return the size offset for the map. - */ -#define rtems_rfs_block_map_size_offset(_m) ((_m)->size.offset) - -/** - * Are we at the last block in the map ? - */ -#define rtems_rfs_block_map_last(_m) \ - rtems_rfs_block_pos_last_block (&(_m)->bpos, &(_m)->size) - -/** - * Is the position past the end of the block ? - */ -#define rtems_rfs_block_map_past_end(_m, _p) \ - rtems_rfs_block_pos_past_end (_p, &(_m)->size) - -/** - * Return the current position in the map. - */ -#define rtems_rfs_block_map_pos(_f, _m) \ - rtems_rfs_block_get_pos (_f, &(_m)->bpos) - -/** - * Return the map's current block number. - */ -#define rtems_rfs_block_map_block(_m) ((_m)->bpos.bno) - -/** - * Return the map's current block offset. - */ -#define rtems_rfs_block_map_block_offset(_m) ((_m)->bpos.boff) - -/** - * Set the size offset for the map. The map is tagged as dirty. - * - * @param[in] map is a pointer to the open map to set the offset in. - * @param[in] offset is the offset to set in the map's size. - */ -static inline void -rtems_rfs_block_map_set_size_offset (rtems_rfs_block_map* map, - rtems_rfs_block_off offset) -{ - map->size.offset = offset; - map->dirty = true; -} - -/** - * Set the map's size. The map is tagged as dirty. - * - * @param[in] map is a pointer to the open map to set the offset in. - * @param[in] size is the size to set in the map's size. - */ -static inline void -rtems_rfs_block_map_set_size (rtems_rfs_block_map* map, - rtems_rfs_block_size* size) -{ - rtems_rfs_block_copy_size (&map->size, size); - map->dirty = true; -} -/** - * Open a block map. The block map data in the inode is copied into the - * map. The buffer handles are opened. The block position is set to the start - * so a seek of offset 0 will return the first block. - * - * @param[in] fs is the file system data. - * @param[in] inode is a pointer to the inode the map belongs to. - * @param[in] map is a pointer to the map that is opened. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_block_map_open (rtems_rfs_file_system* fs, - rtems_rfs_inode_handle* inode, - rtems_rfs_block_map* map); - -/** - * Close the map. The buffer handles are closed and any help buffers are - * released. - * - * @param[in] fs is the file system data. - * @param[in] map is a pointer to the map that is opened. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_block_map_close (rtems_rfs_file_system* fs, - rtems_rfs_block_map* map); - -/** - * Find a block number in the map from the position provided. - * - * @param[in] fs is the file system data. - * @param[in] map is a pointer to the map to search. - * @param[in] bpos is a pointer to the block position to find. - * @param[out] block will contain the block in when found. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_block_map_find (rtems_rfs_file_system* fs, - rtems_rfs_block_map* map, - rtems_rfs_block_pos* bpos, - rtems_rfs_buffer_block* block); - -/** - * Seek around the map. - * - * @param[in] fs is the file system data. - * @param[in] map is a pointer to the map to search. - * @param[in] offset is the distance to seek. It is signed. - * @param[out] block will contain the block in when found. - * - * @retval 0 Successful operation. - * @retval ENXIO Failed to seek because it is outside the block map. - * @retval error_code An error occurred. - */ -int rtems_rfs_block_map_seek (rtems_rfs_file_system* fs, - rtems_rfs_block_map* map, - rtems_rfs_pos_rel offset, - rtems_rfs_buffer_block* block); - -/** - * Seek to the next block. - * - * @param[in] fs is the file system data. - * @param[in] map is a pointer to the map to search. - * @param[out] block will contain the block in when found. - * - * @retval 0 Successful operation. - * @retval ENXIO Failed to seek because it is outside the block map. - * @retval error_code An error occurred. - */ -int rtems_rfs_block_map_next_block (rtems_rfs_file_system* fs, - rtems_rfs_block_map* map, - rtems_rfs_buffer_block* block); - -/** - * Grow the block map by the specified number of blocks. - * - * @param[in] fs is the file system data. - * @param[in] map is a pointer to the open map to grow. - * @param[in] blocks is the number of blocks to grow the map by. - * @param[out] new_block will contain first of the blocks allocated - * to the map. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_block_map_grow (rtems_rfs_file_system* fs, - rtems_rfs_block_map* map, - size_t blocks, - rtems_rfs_block_no* new_block); - -/** - * Grow the block map by the specified number of blocks. - * - * @param[in] fs is the file system data. - * @param[in] map is a pointer to the open map to shrink. - * @param[in] blocks is the number of blocks to shrink the map by. If more - * than the number of blocks the map is emptied. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_block_map_shrink (rtems_rfs_file_system* fs, - rtems_rfs_block_map* map, - size_t blocks); - -/** - * Free all blocks in the map. - * - * @param[in] fs is the file system data. - * @param[in] map is a pointer to the open map to free all blocks from. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_block_map_free_all (rtems_rfs_file_system* fs, - rtems_rfs_block_map* map); - -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs-buffer.h b/cpukit/libfs/src/rfs/rtems-rfs-buffer.h deleted file mode 100644 index 1c603e1827..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-buffer.h +++ /dev/null @@ -1,283 +0,0 @@ -/** - * @file - * - * @ingroup rtems_rfs - * - * @brief Maps Blocks to the Media Interface Layers - * - * These functions map blocks to the media interface layers. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - - -#if !defined (_RTEMS_RFS_BUFFER_H_) -#define _RTEMS_RFS_BUFFER_H_ - -#include - -#include -#include - -/** - * Define the method used to interface to the buffers. It can be libblock or - * device I/O. The libblock interface is to the RTEMS cache and block devices - * and device I/O accesses the media via a device file handle. - */ -#if defined (__rtems__) -#define RTEMS_RFS_USE_LIBBLOCK 1 -#endif - -/** - * The RTEMS RFS I/O Layering. - */ -#if RTEMS_RFS_USE_LIBBLOCK -#include -#include - -typedef rtems_blkdev_bnum rtems_rfs_buffer_block; -typedef rtems_bdbuf_buffer rtems_rfs_buffer; -#define rtems_rfs_buffer_io_request rtems_rfs_buffer_bdbuf_request -#define rtems_rfs_buffer_io_release rtems_rfs_buffer_bdbuf_release - -/** - * Request a buffer from the RTEMS libblock BD buffer cache. - */ -int rtems_rfs_buffer_bdbuf_request (rtems_rfs_file_system* fs, - rtems_rfs_buffer_block block, - bool read, - rtems_rfs_buffer** buffer); -/** - * Release a buffer to the RTEMS libblock BD buffer cache. - */ -int rtems_rfs_buffer_bdbuf_release (rtems_rfs_buffer* handle, - bool modified); -#else /* Device I/O */ -typedef uint32_t rtems_rfs_buffer_block; -typedef struct _rtems_rfs_buffer -{ - rtems_chain_node link; - rtems_rfs_buffer_block user; - void* buffer; - size_t size; - uint32_t references; -} rtems_rfs_buffer; -#define rtems_rfs_buffer_io_request rtems_rfs_buffer_deviceio_request -#define rtems_rfs_buffer_io_release rtems_rfs_buffer_deviceio_release - -/** - * Request a buffer from the device I/O. - */ -int rtems_rfs_buffer_deviceio_request (rtems_rfs_file_system* fs, - rtems_rfs_buffer_block block, - bool read, - rtems_rfs_buffer* buffer); -/** - * Release a buffer to the RTEMS libblock BD buffer cache. - */ -int rtems_rfs_buffer_deviceio_release (rtems_rfs_buffer* handle, - bool modified); -#endif - -/** - * RFS Buffer handle. - */ -typedef struct rtems_rfs_buffer_handle_t -{ - /** - * Has the buffer been modifed? - */ - bool dirty; - - /** - * Block number. The lower layer block number may be absolute and we maybe - * relative to an offset in the disk so hold locally. - */ - rtems_rfs_buffer_block bnum; - - /** - * Reference the buffer descriptor. - */ - rtems_rfs_buffer* buffer; - -} rtems_rfs_buffer_handle; - -/** - * The buffer linkage. - */ -#define rtems_rfs_buffer_link(_h) (&(_h)->buffer->link) - -/** - * Return the start of the data area of the buffer given a handle. - */ -#define rtems_rfs_buffer_data(_h) ((void*)((_h)->buffer->buffer)) - -/** - * Return the size of the buffer given a handle. - */ -#define rtems_rfs_buffer_size(_h) ((_h)->buffer->size) - -/** - * Return the block number. - */ -#define rtems_rfs_buffer_bnum(_h) ((_h)->bnum) - -/** - * Return the buffer dirty status. - */ -#define rtems_rfs_buffer_dirty(_h) ((_h)->dirty) - -/** - * Does the handle have a valid block attached ? - */ -#define rtems_rfs_buffer_handle_has_block(_h) ((_h)->buffer ? true : false) - -/** - * Mark the buffer as dirty. - */ -#define rtems_rfs_buffer_mark_dirty(_h) ((_h)->dirty = true) - -/** - * Return the reference count. - */ -#define rtems_rfs_buffer_refs(_h) ((_h)->buffer->references) - -/** - * Increment the reference count. - */ -#define rtems_rfs_buffer_refs_up(_h) ((_h)->buffer->references += 1) - -/** - * Decrement the reference count. - */ -#define rtems_rfs_buffer_refs_down(_h) ((_h)->buffer->references -= 1) - -/** - * Request a buffer. The buffer can be filled with data from the media - * (read == true) or you can request a buffer to fill with data. - * - * @param[in] fs is the file system data. - * @param[in] handle is the handle the requested buffer is attached to. - * @param[in] block is the block number. - * @param[in] read Read the data from the disk. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_buffer_handle_request (rtems_rfs_file_system* fs, - rtems_rfs_buffer_handle* handle, - rtems_rfs_buffer_block block, - bool read); - -/** - * Release a buffer. If the buffer is dirty the buffer is written to disk. The - * result does not indicate if the data was successfully written to the disk as - * this operation may be performed in asynchronously to this release. - * - * @param[in] fs is the file system data. - * @param[in] handle is the handle the requested buffer is attached to. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_buffer_handle_release (rtems_rfs_file_system* fs, - rtems_rfs_buffer_handle* handle); - -/** - * Open a handle. - * - * @param[in] fs i the file system data. - * @param[in] handle i the buffer handle to open. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -static inline int -rtems_rfs_buffer_handle_open (rtems_rfs_file_system* fs, - rtems_rfs_buffer_handle* handle) -{ - handle->dirty = false; - handle->bnum = 0; - handle->buffer = NULL; - return 0; -} - -/** - * Close a handle. - * - * @param[in] fs is the file system data. - * @param[in] handle is the buffer handle to close. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -static inline int -rtems_rfs_buffer_handle_close (rtems_rfs_file_system* fs, - rtems_rfs_buffer_handle* handle) -{ - rtems_rfs_buffer_handle_release (fs, handle); - handle->dirty = false; - handle->bnum = 0; - handle->buffer = NULL; - return 0; -} - -/** - * Open the buffer interface. - * - * @param[in] name is a pointer to the device name to the media. - * @param[in] fs is the file system data. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_buffer_open (const char* name, rtems_rfs_file_system* fs); - -/** - * Close the buffer interface. - * - * @param[in] fs is the file system data. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_buffer_close (rtems_rfs_file_system* fs); - -/** - * Sync all buffers to the media. - * - * @param[in] fs is the file system data. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_buffer_sync (rtems_rfs_file_system* fs); - -/** - * Set the block size of the device. - * - * @param[in] fs is the file system data. - * @param[in] size is the new block size. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_buffer_setblksize (rtems_rfs_file_system* fs, uint32_t size); - -/** - * Release any chained buffers. - * - * @param[in] fs is the file system data. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_buffers_release (rtems_rfs_file_system* fs); - -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs-data.h b/cpukit/libfs/src/rfs/rtems-rfs-data.h deleted file mode 100644 index 6217e74587..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-data.h +++ /dev/null @@ -1,89 +0,0 @@ -/** - * @file - * - * @brief RTEMS File System Data - * - * @ingroup rtems_rfs - * - * RTEMS File System Data. - * - * Access data in the correct byte order for the specific target we are running - * on. - * - * @todo Make direct access on matching byte ordered targets. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - - -#if !defined (_RTEMS_RFS_DATA_H_) -#define _RTEMS_RFS_DATA_H_ - -#include - -/** - * Helper function to make sure we have a byte pointer. - */ -#define rtems_rfs_data_ptr(_d) ((uint8_t*)(_d)) - -/** - * Helper function to get the data shifted in the correctly sized type. - */ -#define rtems_rfs_data_get(_d, _t, _o, _s) \ - (((_t)(rtems_rfs_data_ptr (_d)[_o])) << (_s)) - -/** - * RFS Read Unsigned 8bit Integer - */ -#define rtems_rfs_read_u8(_d) \ - (*rtems_rfs_data_ptr (_d)) - -/** - * RFS Read Unsigned 16bit Integer - */ -#define rtems_rfs_read_u16(_d) \ - (rtems_rfs_data_get (_d, uint16_t, 0, 8) | \ - rtems_rfs_data_get (_d, uint16_t, 1, 0)) - -/** - * RFS Read Unsigned 32bit Integer - */ -#define rtems_rfs_read_u32(_d) \ - (rtems_rfs_data_get (_d, uint32_t, 0, 24) | \ - rtems_rfs_data_get (_d, uint32_t, 1, 16) | \ - rtems_rfs_data_get (_d, uint32_t, 2, 8) | \ - rtems_rfs_data_get (_d, uint32_t, 3, 0)) - -/** - * RFS Write Unsigned 8bit Integer - */ -#define rtems_rfs_write_u8(_d, _v) \ - (*rtems_rfs_data_ptr (_d) = (uint8_t)(_v)) - -/** - * RFS Write Unsigned 16bit Integer - */ -#define rtems_rfs_write_u16(_d, _v) \ - do { \ - rtems_rfs_data_ptr (_d)[0] = (uint8_t)(((uint16_t)(_v)) >> 8); \ - rtems_rfs_data_ptr (_d)[1] = (uint8_t)((_v)); \ - } while (0) - -/** - * RFS Write Unsigned 32bit Integer - */ -#define rtems_rfs_write_u32(_d, _v) \ - do { \ - rtems_rfs_data_ptr (_d)[0] = (uint8_t)(((uint32_t)(_v)) >> 24); \ - rtems_rfs_data_ptr (_d)[1] = (uint8_t)(((uint32_t)(_v)) >> 16); \ - rtems_rfs_data_ptr (_d)[2] = (uint8_t)(((uint32_t)(_v)) >> 8); \ - rtems_rfs_data_ptr (_d)[3] = (uint8_t)((uint32_t)(_v)); \ - } while (0) - -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs-dir-hash.h b/cpukit/libfs/src/rfs/rtems-rfs-dir-hash.h deleted file mode 100644 index d9a8a2004f..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-dir-hash.h +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @file - * - * @brief Provides a 32bit Hash of a String used to Search a Directory - * - * @ingroup rtems_rfs - * - * RTEMS File Systems Directory Hash provides a 32bit hash of a string. This is - * used to search a directory. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if !defined (_RTEMS_RFS_DIR_HASH_H_) -#define _RTEMS_RFS_DIR_HAS_H_ - -#include -#include - -/** - * Compute a hash of the key over the length of string. - * - * @param[in] key is a pointer to the key to calculate the hash of. - * @param[in] length is the length of the key in bytes. - * - * @retval hash The computed uint32_t hash. - */ -uint32_t rtems_rfs_dir_hash (const void *key, size_t length); - -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs-dir.h b/cpukit/libfs/src/rfs/rtems-rfs-dir.h deleted file mode 100644 index ae3647d03c..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-dir.h +++ /dev/null @@ -1,209 +0,0 @@ -/** - * @file - * - * @brief RTEMS File System Directory Support - * - * @ingroup rtems_rfs - * - * RTEMS File System Directory Support - * - * This file provides the directory support functions. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if !defined (_RTEMS_RFS_DIR_H_) -#define _RTEMS_RFS_DIR_H_ - -#include - -#include - -#include -#include -#include - -/** - * Define the offsets of the fields of a directory entry. - */ -#define RTEMS_RFS_DIR_ENTRY_INO (0) /**< The ino offset in a directory - * entry. */ -#define RTEMS_RFS_DIR_ENTRY_HASH (4) /**< The hash offset in a directory - * entry. The hash is 32bits. We need at - * least 16bits and given the length and - * ino field are 4 the extra 2 bytes is - * not a big overhead.*/ -#define RTEMS_RFS_DIR_ENTRY_LEN (8) /**< The length offset in a directory - * entry. */ - -/** - * The length of the directory entry header. - */ -#define RTEMS_RFS_DIR_ENTRY_SIZE (4 + 4 + 2) - -/** - * The length when the remainder of the directory block is empty. - */ -#define RTEMS_RFS_DIR_ENTRY_EMPTY (0xffff) - -/** - * Return the hash of the entry. - * - * @param[in] _e is a pointer to the directory entry. - * - * @retval hash The uint32_t hash of the entry. - */ -#define rtems_rfs_dir_entry_hash(_e) \ - rtems_rfs_read_u32 (_e + RTEMS_RFS_DIR_ENTRY_HASH) - -/** - * Set the hash of the entry. - * - * @param[in] _e is a pointer to the directory entry. - * - * @param[in] _h is the hash of the entry. - */ -#define rtems_rfs_dir_set_entry_hash(_e, _h) \ - rtems_rfs_write_u32 (_e + RTEMS_RFS_DIR_ENTRY_HASH, _h) - -/** - * Return the ino of the entry. - * - * @param[in] _e is a pointer to the directory entry. - * - * @retval ino The ino of the entry. - */ -#define rtems_rfs_dir_entry_ino(_e) \ - rtems_rfs_read_u32 (_e + RTEMS_RFS_DIR_ENTRY_INO) - -/** - * Set the ino of the entry. - * - * @param[in] _e is a pointer to the directory entry. - * - * @param[in] _i is the ino of the entry. - */ -#define rtems_rfs_dir_set_entry_ino(_e, _i) \ - rtems_rfs_write_u32 (_e + RTEMS_RFS_DIR_ENTRY_INO, _i) - -/** - * Return the length of the entry. - * - * @param[in] _e Pointer to the directory entry. - * - * @retval length The length of the entry. - */ -#define rtems_rfs_dir_entry_length(_e) \ - rtems_rfs_read_u16 (_e + RTEMS_RFS_DIR_ENTRY_LEN) - -/** - * Set the length of the entry. - * - * @param[in] _e is a pointer to the directory entry. - * @param[in] _l is the length. - */ -#define rtems_rfs_dir_set_entry_length(_e, _l) \ - rtems_rfs_write_u16 (_e + RTEMS_RFS_DIR_ENTRY_LEN, _l) - -/** - * Look up a directory entry in the directory pointed to by the inode. The look - * up is local to this directory. No need to decend. - * - * @param[in] fs is the file system. - * @param[in] inode is a pointer to the inode of the directory to search. - * @param[in] name is a pointer to the name to look up. The name may not be - * nul terminated. - * @param[in] length is the length of the name. - * @param[out] ino will be filled in with the inode number - * if there is no error. - * @param[in] offset is the offset in the directory for the entry. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_dir_lookup_ino (rtems_rfs_file_system* fs, - rtems_rfs_inode_handle* inode, - const char* name, - int length, - rtems_rfs_ino* ino, - uint32_t* offset); - -/** - * Add an entry to the directory returing the inode number allocated to the - * entry. - * - * @param[in] fs is the file system data. - * @param[in] dir is a pointer to the directory inode the - * entry is to be added too. - * @param[in] name is a pointer to the name of the entry to be added. - * @param[in] length is the length of the name excluding a terminating 0. - * @param[in] ino is the ino of the entry. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_dir_add_entry (rtems_rfs_file_system* fs, - rtems_rfs_inode_handle* dir, - const char* name, - size_t length, - rtems_rfs_ino ino); - -/** - * Del an entry from the directory using an inode number as a key. - * - * @param[in] fs is the file system data. - * @param[in] dir is a pointer to the directory inode the - * entry is to be deleted from. - * @param[in] ino is the ino of the entry. - * @param[in] offset is the offset in the directory of the entry - * to delete. If 0 search from the start for the ino. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_dir_del_entry (rtems_rfs_file_system* fs, - rtems_rfs_inode_handle* dir, - rtems_rfs_ino ino, - uint32_t offset); - -/** - * Read the directory entry from offset into the directory entry buffer and - * return the length of space this entry uses in the directory table. - * - * @param[in] fs is the file system data. - * @param[in] dir is a pointer to the direct inode handler. - * @param[in] offset is the offset in the directory to read from. - * @param[in] dirent is a ointer to the dirent structure the entry - * is written into. - * @param[out] length will contain the length this entry - * takes in the directory. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_dir_read (rtems_rfs_file_system* fs, - rtems_rfs_inode_handle* dir, - rtems_rfs_pos_rel offset, - struct dirent* dirent, - size_t* length); - -/** - * Check if the directory is empty. The current and parent directory entries - * are ignored. - * - * @param[in] fs is the file system data - * @param[in] dir is a pointer to the directory inode to check. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_dir_empty (rtems_rfs_file_system* fs, - rtems_rfs_inode_handle* dir); - -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs-file-system-fwd.h b/cpukit/libfs/src/rfs/rtems-rfs-file-system-fwd.h deleted file mode 100644 index e239c25d6f..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-file-system-fwd.h +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @file - * - * @brief RTEMS File Systems Data Forward Declaration - * - * @ingroup rtems_rfs - * - * RTEMS File Systems Data forward decl. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - - -#if !defined (_RTEMS_RFS_FILE_SYSTEM_FWD_H_) -#define _RTEMS_RFS_FILE_SYSTEM_FWD_H_ - -/** - * Forward reference to the file system data. - */ -struct _rtems_rfs_file_system; -typedef struct _rtems_rfs_file_system rtems_rfs_file_system; - -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs-file-system.h b/cpukit/libfs/src/rfs/rtems-rfs-file-system.h deleted file mode 100644 index e00b142532..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-file-system.h +++ /dev/null @@ -1,410 +0,0 @@ -/** - * @file - * - * @brief RTEMS File System Data - * - * @ingroup rtems_rfs - * - * RTEMS File System Data - * - * This file defines the file system data. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if !defined (_RTEMS_RFS_FILE_SYSTEM_H_) -#define _RTEMS_RFS_FILE_SYSTEM_H_ - -#include - -/** - * Superblock offsets and values. - */ -#define RTEMS_RFS_SB_OFFSET_MAGIC (0) -#define RTEMS_RFS_SB_MAGIC (0x28092001) -#define RTEMS_RFS_SB_OFFSET_VERSION (RTEMS_RFS_SB_OFFSET_MAGIC + 4) -#define RTEMS_RFS_SB_OFFSET_BLOCK_SIZE (RTEMS_RFS_SB_OFFSET_VERSION + 4) -#define RTEMS_RFS_SB_OFFSET_BLOCKS (RTEMS_RFS_SB_OFFSET_BLOCK_SIZE + 4) -#define RTEMS_RFS_SB_OFFSET_BAD_BLOCKS (RTEMS_RFS_SB_OFFSET_BLOCKS + 4) -#define RTEMS_RFS_SB_OFFSET_MAX_NAME_LENGTH (RTEMS_RFS_SB_OFFSET_BAD_BLOCKS + 4) -#define RTEMS_RFS_SB_OFFSET_GROUPS (RTEMS_RFS_SB_OFFSET_MAX_NAME_LENGTH + 4) -#define RTEMS_RFS_SB_OFFSET_GROUP_BLOCKS (RTEMS_RFS_SB_OFFSET_GROUPS + 4) -#define RTEMS_RFS_SB_OFFSET_GROUP_INODES (RTEMS_RFS_SB_OFFSET_GROUP_BLOCKS + 4) -#define RTEMS_RFS_SB_OFFSET_INODE_SIZE (RTEMS_RFS_SB_OFFSET_GROUP_INODES + 4) - -/** - * RFS Version Number. - */ -#define RTEMS_RFS_VERSION (0x00000000) - -/** - * RFS Version Number Mask. The mask determines which bits of the version - * number indicate compatility issues. - */ -#define RTEMS_RFS_VERSION_MASK INT32_C(0x00000000) - -/** - * The root inode number. Do not use 0 as this has special meaning in some - * Unix operating systems. - */ -#define RTEMS_RFS_ROOT_INO (1) - -/** - * Empty inode number. - */ -#define RTEMS_RFS_EMPTY_INO (0) - -/** - * The number of blocks in the inode. This number effects the size of the - * inode and that effects the overhead of the inode tables in a group. - */ -#define RTEMS_RFS_INODE_BLOCKS (5) - -/** - * The inode overhead is the percentage of space reserved for inodes. It is - * calculated as the percentage number of blocks in a group. The number of - * blocks in a group is the number of bits a block can hold. - */ -#define RTEMS_RFS_INODE_OVERHEAD_PERCENTAGE (1) - -/** - * Number of blocks in the superblock. Yes I know it is a superblock and not - * superblocks but if for any reason this needs to change it is handled. - */ -#define RTEMS_RFS_SUPERBLOCK_SIZE (1) - -/** - * The maximum number of buffers held by the file system at any one time. - */ -#define RTEMS_RFS_FS_MAX_HELD_BUFFERS (5) - -/** - * Absolute position. Make a 64bit value. - */ -typedef uint64_t rtems_rfs_pos; - -/** - * Relative position. Make a 64bit value. - */ -typedef int64_t rtems_rfs_pos_rel; - -/** - * Flags to control the file system. - */ -#define RTEMS_RFS_FS_BITMAPS_HOLD (1 << 0) /**< Do not release bitmaps - * when finished. Default is - * off so they are released. */ -#define RTEMS_RFS_FS_NO_LOCAL_CACHE (1 << 1) /**< Do not cache the buffers - * and release directly to the - * buffer support layer. The - * default is to hold buffers. */ -#define RTEMS_RFS_FS_FORCE_OPEN (1 << 2) /**< Force open and ignore any - * errors. */ -#define RTEMS_RFS_FS_READ_ONLY (1 << 3) /**< Make the mount - * read-only. Currently not - * supported. */ -/** - * RFS File System data. - */ -struct _rtems_rfs_file_system -{ - /** - * Flags to control the file system. Some can be controlled via the ioctl. - */ - uint32_t flags; - - /** - * The number of blocks in the disk. The size of the disk is the number of - * blocks by the block size. This should be within a block size of the size - * returned by the media driver. - */ - size_t blocks; - - /** - * The size of a block. This must be a multiple of the disk's media block - * size. - */ - size_t block_size; - - /** - * The file descriptor for device I/O. - */ - int device; - -#if RTEMS_RFS_USE_LIBBLOCK - /** - * The disk device. This is the data about the block device this file system - * is mounted on. We access the data held in this structure rather than - * making an extra copy in this structure. - */ - rtems_disk_device* disk; -#else - /** - * The number of blocks in the file system. - */ - size_t size; -#endif - - /** - * Inode count. - */ - uint32_t inodes; - - /** - * Bad block blocks. This is a table of blocks that have been found to be - * bad. - */ - uint32_t bad_blocks; - - /** - * Maximum length of names supported by this file system. - */ - uint32_t max_name_length; - - /** - * A disk is broken down into a series of groups. - */ - rtems_rfs_group* groups; - - /** - * Number of groups. - */ - int group_count; - - /** - * Number of blocks in a group. - */ - size_t group_blocks; - - /** - * Number of inodes in a group. - */ - size_t group_inodes; - - /** - * Number of inodes in each block. - */ - size_t inodes_per_block; - - /** - * Number of block numbers in a block. - */ - size_t blocks_per_block; - - /** - * Block map single indirect count. This is the block number per block - * multiplied but the slots in the inode. - */ - size_t block_map_singly_blocks; - - /** - * Block map double indirect count. This is the block number per block - * squared and multiplied by the slots in the inode. It is the maximum - * number of blocks a map (file/directory) can have. - */ - size_t block_map_doubly_blocks; - - /** - * Number of buffers held before releasing back to the cache. - */ - uint32_t max_held_buffers; - - /** - * List of buffers attached to buffer handles. Allows sharing. - */ - rtems_chain_control buffers; - - /** - * Number of buffers held on the buffers list. - */ - uint32_t buffers_count; - - /** - * List of buffers that need to be released when the processing of a file - * system request has completed. - */ - rtems_chain_control release; - - /** - * Number of buffers held on the release list. - */ - uint32_t release_count; - - /** - * List of buffers that need to be released modified when the processing of a - * file system request has completed. - */ - rtems_chain_control release_modified; - - /** - * Number of buffers held on the release modified list. - */ - uint32_t release_modified_count; - - /** - * List of open shared file node data. The shared node data such as the inode - * and block map allows a single file to be open more than once. - */ - rtems_chain_control file_shares; - - /** - * Pointer to user data supplied when opening. - */ - void* user; -}; - -/** - * Return the flags. - * - * @param[in] _fs is a pointer to the file system. - */ -#define rtems_rfs_fs_flags(_f) ((_f)->flags) -/** - * Should bitmap buffers be released when finished ? - * - * @param[in] _fs is a pointer to the file system. - */ -#define rtems_rfs_fs_release_bitmaps(_f) (!((_f)->flags & RTEMS_RFS_FS_BITMAPS_HOLD)) - -/** - * Are the buffers locally cache or released back to the buffering layer ? - * - * @param[in] _fs is a pointer to the file system. - */ -#define rtems_rfs_fs_no_local_cache(_f) ((_f)->flags & RTEMS_RFS_FS_NO_LOCAL_CACHE) - -/** - * The disk device number. - * - * @param[in] _fs is a pointer to the file system. - */ -#if RTEMS_RFS_USE_LIBBLOCK -#define rtems_rfs_fs_device(_fs) ((_fs)->disk) -#else -#define rtems_rfs_fs_device(_fs) ((_fs)->device) -#endif - -/** - * The size of the disk in blocks. - * - * @param[in] _fs is a pointer to the file system. - */ -#define rtems_rfs_fs_blocks(_fs) ((_fs)->blocks) - -/** - * The block size. - * - * @param[in] _fs is a pointer to the file system. - */ -#define rtems_rfs_fs_block_size(_fs) ((_fs)->block_size) - -/** - * The number of inodes. - * - * @param[in] _fs is a pointer to the file system. - */ -#define rtems_rfs_fs_inodes(_fs) ((_fs)->inodes) - -/** - * Calculate a block in the file system given the group and the block within - * the group. - * - * @param[in] _fs is a pointer to the file system. - * @param[in] _grp is the group. - * @param[in] _blk is the block within the group. - * @return The absolute block number. - */ -#define rtems_rfs_fs_block(_fs, _grp, _blk) \ - ((((_fs)->group_blocks) * (_grp)) + (_blk) + 1) - -/** - * The media size of the disk in media size blocks. - * - * @param[in] _fs is a pointer to the file system. - */ -#if RTEMS_RFS_USE_LIBBLOCK -#define rtems_rfs_fs_media_blocks(_fs) ((_fs)->disk->size) -#else -#define rtems_rfs_fs_media_blocks(_fs) ((_fs)->media_size) -#endif - -/** - * The media block size. This is the size of a block on disk. For a device I/O - * this value is 1. - * - * @param[in] _fs is a pointer to the file system. - */ -#if RTEMS_RFS_USE_LIBBLOCK -#define rtems_rfs_fs_media_block_size(_fs) ((_fs)->disk->media_block_size) -#else -#define rtems_rfs_fs_media_block_size(_fs) (1) -#endif - -/** - * The maximum length of a name supported by the file system. - */ -#define rtems_rfs_fs_max_name(_fs) ((_fs)->max_name_length) - -/** - * Return the maximum number of blocks in a block map. - * - * @return uint32_t The maximum number of blocks possible. - */ -#define rtems_rfs_fs_max_block_map_blocks(_fs) ((_fs)->block_map_doubly_blocks) - -/** - * Return the user pointer. - */ -#define rtems_rfs_fs_user(_fs) ((_fs)->user) - -/** - * Return the size of the disk in bytes. - * - * @param[in] fs is a pointer to the file system. - * @return uint64_t The size of the disk in bytes. - */ -uint64_t rtems_rfs_fs_size(rtems_rfs_file_system* fs); - -/** - * The size of the disk in bytes calculated from the media parameters.. - * - * @param[in] fs is a pointer to the file system. - * @return uint64_t The size of the disk in bytes. - */ -uint64_t rtems_rfs_fs_media_size (rtems_rfs_file_system* fs); - -/** - * Open the file system given a file path. - * - * @param[in] name is a pointer to the device to open. - * @param[in] fs is the file system data filled in by this call. - * @param[in] user is a pointer to the user data. - * @param[in] flags is a initial set of user flags for the file system. - * @param[in] max_held_buffers is the maximum number of buffers the RFS holds. - * - * @retval 0 Successful operation. - * @retval -1 Error. See errno - */ -int rtems_rfs_fs_open (const char* name, - void* user, - uint32_t flags, - uint32_t max_held_buffers, - rtems_rfs_file_system** fs); - -/** - * Close the file system. - * - * @param[in] fs is the file system data. - * - * @retval 0 Successful operation. - * @retval -1 Error. See errno - */ -int rtems_rfs_fs_close (rtems_rfs_file_system* fs); - -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs-file.h b/cpukit/libfs/src/rfs/rtems-rfs-file.h deleted file mode 100644 index 772e846143..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-file.h +++ /dev/null @@ -1,416 +0,0 @@ -/** - * @file - * - * @brief RTEMS File System File Support - * - * @ingroup rtems_rfs - * - * RTEMS File System File Support - * - * This file provides the support functions. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if !defined (_RTEMS_RFS_FILE_H_) -#define _RTEMS_RFS_FILE_H_ - -#include - -#include -#include -#include -#include - -/** - * File data that is shared by various file handles accessing the same file. We - * hold various inode values common to the file that can change frequently so - * the inode is not thrashed yet we meet the requirements of the POSIX - * standard. The stat call needs to check the shared file data. - */ -typedef struct _rtems_rfs_file_shared -{ - /** - * The shared parts are maintained as a list. - */ - rtems_chain_node link; - - /** - * Reference count the users of this data. - */ - int references; - - /** - * The inode for the file. - */ - rtems_rfs_inode_handle inode; - - /** - * The block map for the file. The handle holds the file's position not the - * map. - */ - rtems_rfs_block_map map; - - /** - * The size of the file as taken from the inode. The map's size and - * this size should be the same. - */ - rtems_rfs_block_size size; - - /** - * The access time. The last time the file was read. - */ - rtems_rfs_time atime; - - /** - * The modified time. The last time the file was written too. - */ - rtems_rfs_time mtime; - - /** - * The change time. The last time the inode was written too. - */ - rtems_rfs_time ctime; - - /** - * Hold a pointer to the file system data so users can take the handle and - * use it without the needing to hold the file system data pointer. - */ - rtems_rfs_file_system* fs; - -} rtems_rfs_file_shared; - -/** - * Get the atime. - * - * @param[in] shared is a pointer to the shared file data. - * - * @retval atime The atime. - */ -static inline rtems_rfs_time -rtems_rfs_file_shared_get_atime (rtems_rfs_file_shared* shared) -{ - return shared->atime; -} - -/** - * Get the mtime. - * - * @param[in] shared is a pointer to the shared file data. - * - * @retval mtime The mtime. - */ -static inline rtems_rfs_time -rtems_rfs_file_shared_get_mtime (rtems_rfs_file_shared* shared) -{ - return shared->mtime; -} - -/** - * Get the ctime. - * - * @param[in] shared is a pointer to the shared file data. - * - * @retval ctime The ctime. - */ -static inline rtems_rfs_time -rtems_rfs_file_shared_get_ctime (rtems_rfs_file_shared* shared) -{ - return shared->ctime; -} - -/** - * Get the block count. - * - * @param[in] shared is a pointer to the shared file data. - * - * @retval count The block count. - */ -static inline uint32_t -rtems_rfs_file_shared_get_block_count (rtems_rfs_file_shared* shared) -{ - return shared->size.count; -} - -/** - * Get the block offset. - * - * @param shared is a pointer to the shared file data. - * - * @retval offset The block offset. - */ -static inline uint16_t -rtems_rfs_file_shared_get_block_offset (rtems_rfs_file_shared* shared) -{ - return shared->size.offset; -} - -/** - * Calculate the size of data. - * - * @param[in] fs is the file system data. - * @param[in] shared is a pointer to the shared file data. - * - * @retval data The data size in bytes. - */ -static inline rtems_rfs_pos -rtems_rfs_file_shared_get_size (rtems_rfs_file_system* fs, - rtems_rfs_file_shared* shared) -{ - return rtems_rfs_block_get_size (fs, &shared->size); -} - -/** - * File flags. - */ -#define RTEMS_RFS_FILE_NO_ATIME_UPDATE (1 << 0) /**< Do not update the atime - * field in the inode if - * set. */ -#define RTEMS_RFS_FILE_NO_MTIME_UPDATE (1 << 1) /**< Do not update the mtime - * field in the inode if - * set. */ -#define RTEMS_RFS_FILE_NO_LENGTH_UPDATE (1 << 2) /**< Do not update the position - * field in the inode if - * set. */ - -/** - * File data used to managed an open file. - */ -typedef struct _rtems_rfs_file_handle -{ - /** - * Special flags that can be controlled by the fctrl call. - */ - int flags; - - /** - * The buffer of data at the file's position. - */ - rtems_rfs_buffer_handle buffer; - - /** - * The block position of this file handle. - */ - rtems_rfs_block_pos bpos; - - /** - * Pointer to the shared file data. - */ - rtems_rfs_file_shared* shared; - -} rtems_rfs_file_handle; - -/** - * Access the data in the buffer. - */ -#define rtems_rfs_file_data(_f) \ - (rtems_rfs_buffer_data (&(_f)->buffer) + (_f)->bpos.boff) - -/** - * Return the file system data pointer given a file handle. - */ -#define rtems_rfs_file_fs(_f) ((_f)->shared->fs) - -/** - * Return the file's inode handle pointer given a file handle. - */ -#define rtems_rfs_file_inode(_f) (&(_f)->shared->inode) - -/** - * Return the file's block map pointer given a file handle. - */ -#define rtems_rfs_file_map(_f) (&(_f)->shared->map) - -/** - * Return the file's block position pointer given a file handle. - */ -#define rtems_rfs_file_bpos(_f) (&(_f)->bpos) - -/** - * Return the file's block number given a file handle. - */ -#define rtems_rfs_file_block(_f) ((_f)->bpos.bno) - -/** - * Return the file's block offset given a file handle. - */ -#define rtems_rfs_file_block_offset(_f) ((_f)->bpos.boff) - -/** - * Set the file's block position given a file position (absolute). - */ -#define rtems_rfs_file_set_bpos(_f, _p) \ - rtems_rfs_block_get_bpos (rtems_rfs_file_fs (_f), _p, (&(_f)->bpos)) - -/** - * Return the file's buffer handle pointer given a file handle. - */ -#define rtems_rfs_file_buffer(_f) (&(_f)->buffer) - -/** - * Update the access time field of the inode when reading if flagged to do so. - */ -#define rtems_rfs_file_update_atime(_f) \ - (((_f)->flags & RTEMS_RFS_FILE_NO_ATIME_UPDATE) == 0) - -/** - * Update the modified time field of the inode when writing if flagged to do so. - */ -#define rtems_rfs_file_update_mtime(_f) \ - (((_f)->flags & RTEMS_RFS_FILE_NO_MTIME_UPDATE) == 0) - -/** - * Update the length field of the inode. - */ -#define rtems_rfs_file_update_length(_f) \ - (((_f)->flags & RTEMS_RFS_FILE_NO_LENGTH_UPDATE) == 0) - -/** - * Return the shared size varable. - */ -#define rtems_rfs_file_get_size(_f) \ - (&(_f)->shared->size) - -/** - * Return the size of file. - */ -#define rtems_rfs_file_size(_f) \ - rtems_rfs_file_shared_get_size (rtems_rfs_file_fs (_f), (_f)->shared) - -/** - * Return the file block count. - */ -#define rtems_rfs_file_size_count(_f) \ - rtems_rfs_file_shared_get_block_count ((_f)->shared) - -/** - * Return the file block offset. - */ -#define rtems_rfs_file_size_offset(_f) \ - rtems_rfs_file_shared_get_block_offset ((_f)->shared) - -/** - * Open a file handle. - * - * @param[in] fs is the file system. - * @param[in] ino is the inode number of the file to be opened. - * @param[out] handle will be filled in with the handle pointer. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_file_open (rtems_rfs_file_system* fs, - rtems_rfs_ino ino, - int oflag, - rtems_rfs_file_handle** handle); - -/** - * Close an open file handle. - * - * @param[in] fs is the file system. - * @param[in] handle is the open file handle. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_file_close (rtems_rfs_file_system* fs, - rtems_rfs_file_handle* handle); - -/** - * Start I/O on a block of a file. This call only requests the block from the - * media if reading and makes the buffer available to you the via the - * rtems_rfs_file_data interface after the call. The available amount data is - * taken from the current file position until the end of the block. The file - * position is not adujsted until the I/O ends. An I/O request cannot perform - * I/O past the end of a block so the call returns the amount of data - * available. - * - * @param[in] handle is the file handle. - * @param[in] available is the amount of data available for I/O. - * @param[in] read is the I/O operation is a read so the block is read from the media. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_file_io_start (rtems_rfs_file_handle* handle, - size_t* available, - bool read); - -/** - * End the I/O. Any buffers held in the file handle and returned to the - * cache. If inode updating is not disable and the I/O is a read the atime - * field is updated and if a write I/O the mtime is updated. - * - * If the file's position is updated by the size amount. - * - * @param[in] handle is the file handle. - * @param[in] size is the amount of data read or written. - * @param[in] read is the I/O was a read if true else it was a write. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_file_io_end (rtems_rfs_file_handle* handle, - size_t size, - bool read); - -/** - * Release the I/O resources without any changes. If data has changed in the - * buffer and the buffer was not already released as modified the data will be - * lost. - * - * @param[in] handle is the file handle. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_file_io_release (rtems_rfs_file_handle* handle); - -/** - * The file to the position returning the old position. The position is - * abolute. - * - * @param[in] handle The file handle. - * @param[in] pos is the position to seek to. - * @param[out] new_pos will contain the actual position. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_file_seek (rtems_rfs_file_handle* handle, - rtems_rfs_pos pos, - rtems_rfs_pos* new_pos); - -/** - * Set the size of the file to the new size. This can extend the file to a new - * size. - * - * @param[in] handle is the file handle. - * @param[in] size is the new size of the file. - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_file_set_size (rtems_rfs_file_handle* handle, - rtems_rfs_pos size); - -/** - * Return the shared file data for an ino. - * - * @param[in] fs is the file system data. - * @param[in] ino is the inode number to locate the data for. - * @return rtems_rfs_file_shared* The shared data or NULL is not located. - * - * @retval shared The shared data. - * @retval NULL No shared file data is located. - */ -rtems_rfs_file_shared* rtems_rfs_file_get_shared (rtems_rfs_file_system* fs, - rtems_rfs_ino ino); - - -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs-format.h b/cpukit/libfs/src/rfs/rtems-rfs-format.h deleted file mode 100644 index f65cce1789..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-format.h +++ /dev/null @@ -1,90 +0,0 @@ -/** - * @file - * - * @ingroup rtems_rfs - * - * @brief RTEMS File System Format - * - * This function lets you format a disk in the RFS format. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if !defined (_RTEMS_RFS_FORMAT_H_) -#define _RTEMS_RFS_FORMAT_H_ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/** - * RFS File System Configuration data used to format the file system. For - * default values leave the field set to 0. - */ -typedef struct _rtems_rfs_format_config -{ - /** - * The size of a block. - */ - size_t block_size; - - /** - * The number of blocks in a group. - */ - size_t group_blocks; - - /** - * The number of inodes in a group. - */ - size_t group_inodes; - - /** - * The percentage overhead allocated to inodes. - */ - int inode_overhead; - - /** - * The maximum length of a name. - */ - size_t max_name_length; - - /** - * Initialise the inode tables to all ones. - */ - bool initialise_inodes; - - /** - * Is the format verbose. - */ - bool verbose; - -} rtems_rfs_format_config; - -/** - * RFS Format command. - * - * @param[in] name is the device name to format. - * @param[in] config is a pointer to the configuration table. - * - * @retval -1 Error. See errno. - * @retval 0 No error. Format successful. - */ -int rtems_rfs_format (const char* name, const rtems_rfs_format_config* config); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs-group.h b/cpukit/libfs/src/rfs/rtems-rfs-group.h deleted file mode 100644 index 23e6434b2c..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-group.h +++ /dev/null @@ -1,181 +0,0 @@ -/** - * @file - * - * @brief RTEMS File Systems Group Management - * - * @ingroup rtems_rfs - * - * RTEMS File Systems Group Management. - * - * These functions manage the groups used in the file system. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - - -#if !defined (_RTEMS_RFS_GROUP_H_) -#define _RTEMS_RFS_GROUP_H_ - -/** - * @ingroup rtems_rfs - * - * RTEMS File System Group Management - */ -/**@{*/ - -#include -#include -#include - -/** - * Block allocations for a group on disk. - */ -#define RTEMS_RFS_GROUP_BLOCK_BITMAP_BLOCK (0) -#define RTEMS_RFS_GROUP_INODE_BITMAP_BLOCK (1) -#define RTEMS_RFS_GROUP_INODE_BLOCK (2) - -/** - * @brief Creates bit allocator for blocks in the group simpler. - * - * A group is a selection of blocks on the disk. Typically the number of blocks - * in a group is determined by the number of bits a block holds. This makes the - * bit allocator for blocks in the group simpler plus is allows a simple way to - * localise access to files and directories. - */ -typedef struct _rtems_rfs_group -{ - /** - * Base block number. - */ - rtems_rfs_buffer_block base; - - /** - * The number of blocks in the group. Groups may be different sizes. - */ - size_t size; - - /** - * The block bitmap control. - */ - rtems_rfs_bitmap_control block_bitmap; - - /** - * The handle to the block bitmap buffer. - */ - rtems_rfs_buffer_handle block_bitmap_buffer; - - /** - * The inode bitmap control. - */ - rtems_rfs_bitmap_control inode_bitmap; - - /** - * The handle to the inode bitmap buffer. - */ - rtems_rfs_buffer_handle inode_bitmap_buffer; - -} rtems_rfs_group; - -/** - * Return the disk's block for a block in a group. - */ -#define rtems_rfs_group_block(_g, _b) (((_g)->base) + (_b)) - -/** - * Return the file system inode for a inode in a group. - */ -#define rtems_rfs_group_inode(_f, _g, _i) \ - (((_f)->group_inodes * (_g)) + (_i) + RTEMS_RFS_ROOT_INO) - -/** - * @brief Open a group. - * - * Allocate all the resources including the bitmaps. - * - * @param fs The file system. - * @param base The base block number. - * @param size The number of blocks in the group. - * @param group Reference to the group to open. - * @retval int The error number (errno). No error if 0. - */ -int rtems_rfs_group_open (rtems_rfs_file_system* fs, - rtems_rfs_buffer_block base, - size_t size, - size_t inodes, - rtems_rfs_group* group); - -/** - * @brief Close a group. - * - * Release all resources the group holds. - * - * @param fs The file system. - * @param group The group to close. - * @retval int The error number (errno). No error if 0. - */ -int rtems_rfs_group_close (rtems_rfs_file_system* fs, - rtems_rfs_group* group); - -/** - * @brief Allocate an inode or block. - * - * The groups are searched to find the next - * available inode or block. - * - * @param fs The file system data. - * @param goal The goal to seed the bitmap search. - * @param inode If true allocate an inode else allocate a block. - * @param result The allocated bit in the bitmap. - * @retval int The error number (errno). No error if 0. - */ -int rtems_rfs_group_bitmap_alloc (rtems_rfs_file_system* fs, - rtems_rfs_bitmap_bit goal, - bool inode, - rtems_rfs_bitmap_bit* result); - -/** - * @brief Free the group allocated bit. - * - * @param fs The file system data. - * @param inode If true the number to free is an inode else it is a block. - * @param block The inode or block number to free. - * @retval int The error number (errno). No error if 0. - */ -int rtems_rfs_group_bitmap_free (rtems_rfs_file_system* fs, - bool inode, - rtems_rfs_bitmap_bit no); - -/** - * @brief Test the group allocated bit. - * - * @param fs The file system data. - * @param inode If true the number to free is an inode else it is a block. - * @param block The inode or block number to free. - * @param state Return the state of the bit. - * @retval int The error number (errno). No error if 0. - */ -int rtems_rfs_group_bitmap_test (rtems_rfs_file_system* fs, - bool inode, - rtems_rfs_bitmap_bit no, - bool* state); - -/** - * @brief Determine the number of blocks and inodes used. - * - * @param fs The file system data. - * @param blocks The number of blocks used. - * @param inodes The number of inodes used. - * @retval int The error number (errno). No error if 0. - */ -int rtems_rfs_group_usage (rtems_rfs_file_system* fs, - size_t* blocks, - size_t* inodes); - -/** @} */ -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs-inode.h b/cpukit/libfs/src/rfs/rtems-rfs-inode.h deleted file mode 100644 index 95861ea8a7..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-inode.h +++ /dev/null @@ -1,728 +0,0 @@ -/** - * @file - * - * @brief RTEMS File System Information Node - * - * @ingroup rtems_rfs - * - * RTEMS File System Information Node. - * - * The information nodes hold the data about all nodes in the file system. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - - -#if !defined (_RTEMS_RFS_INODE_H_) -#define _RTEMS_RFS_INODE_H_ - -#include - -#include -#include - -/** - * The RFS mode definitions. Currently map to the C library ones. - */ -#define RTEMS_RFS_S_ISUID S_ISUID /**< Set user id on execution */ -#define RTEMS_RFS_S_ISGID S_ISGID /**< Set group id on execution */ -#define RTEMS_RFS_S_ISVTX S_ISVTX /**< Save swapped text even after use */ -#define RTEMS_RFS_S_IREAD S_IREAD /**< Read permission, owner */ -#define RTEMS_RFS_S_IWRITE S_IWRITE /**< Write permission, owner */ -#define RTEMS_RFS_S_IEXEC S_IEXEC /**< Execute/search permission, owner */ -#define RTEMS_RFS_S_ENFMT S_ENFMT /**< Enforcement-mode locking */ -#define RTEMS_RFS_S_IFMT S_IFMT /**< Type of file */ -#define RTEMS_RFS_S_IFDIR S_IFDIR /**< Directory */ -#define RTEMS_RFS_S_IFCHR S_IFCHR /**< Character special */ -#define RTEMS_RFS_S_IFBLK S_IFBLK /**< Block special */ -#define RTEMS_RFS_S_IFREG S_IFREG /**< Regular */ -#define RTEMS_RFS_S_IFLNK S_IFLNK /**< Symbolic link */ -#define RTEMS_RFS_S_IFSOCK S_IFSOCK /**< Socket */ -#define RTEMS_RFS_S_IFIFO S_IFIFO /**< Fifo */ -#define RTEMS_RFS_S_IRWXU S_IRWXU -#define RTEMS_RFS_S_IRUSR S_IRUSR /**< Read permission, owner */ -#define RTEMS_RFS_S_IWUSR S_IWUSR /**< Write permission, owner */ -#define RTEMS_RFS_S_IXUSR S_IXUSR /**< Execute/search permission, owner */ -#define RTEMS_RFS_S_IRWXG S_IRWXG -#define RTEMS_RFS_S_IRGRP S_IRGRP /**< Read permission, group */ -#define RTEMS_RFS_S_IWGRP S_IWGRP /**< Write permission, grougroup */ -#define RTEMS_RFS_S_IXGRP S_IXGRP /**< Execute/search permission, group */ -#define RTEMS_RFS_S_IRWXO S_IRWXO -#define RTEMS_RFS_S_IROTH S_IROTH /**< Read permission, other */ -#define RTEMS_RFS_S_IWOTH S_IWOTH /**< Write permission, other */ -#define RTEMS_RFS_S_IXOTH S_IXOTH /**< Execute/search permission, other */ - -#define RTEMS_RFS_S_ISBLK(m) S_ISBLK(m) -#define RTEMS_RFS_S_ISCHR(m) S_ISCHR(m) -#define RTEMS_RFS_S_ISDIR(m) S_ISDIR(m) -#define RTEMS_RFS_S_ISFIFO(m) S_ISFIFO(m) -#define RTEMS_RFS_S_ISREG(m) S_ISREG(m) -#define RTEMS_RFS_S_ISLNK(m) S_ISLNK(m) -#define RTEMS_RFS_S_ISSOCK(m) S_ISSOCK(m) - -/** - * Permissions of a symlink. - */ -#define RTEMS_RFS_S_SYMLINK \ - RTEMS_RFS_S_IFLNK | RTEMS_RFS_S_IRWXU | RTEMS_RFS_S_IRWXG | RTEMS_RFS_S_IRWXO - -/** - * The inode number or ino. - */ -typedef uint32_t rtems_rfs_ino; - -/** - * The time in the file system. - */ -typedef uint32_t rtems_rfs_time; - -/** - * The size of a block value on disk. This include the inodes and indirect - * tables. - */ -typedef uint32_t rtems_rfs_inode_block; - -/** - * The size of the data name field in the inode. - */ -#define RTEMS_RFS_INODE_DATA_NAME_SIZE \ - (RTEMS_RFS_INODE_BLOCKS * sizeof (rtems_rfs_inode_block)) - -/** - * The inode. - */ -typedef struct _rtems_rfs_inode -{ - /** - * The number of links to the inode. - */ - uint16_t links; - - /** - * The mode of the node. - */ - uint16_t mode; - - /** - * The owner of the node. - */ - uint32_t owner; - - /** - * Reserved. - */ - uint16_t flags; - - /** - * Amount of data held in the last block data. - */ - uint16_t block_offset; - - /** - * Number of blocks held by this file. - */ - uint32_t block_count; - - /** - * The access time. The last time the file was read. - */ - rtems_rfs_time atime; - - /** - * The modified time. The last time the file was written too. - */ - rtems_rfs_time mtime; - - /** - * The change time. The last time the inode was written too. - */ - rtems_rfs_time ctime; - - /** - * Blocks. These are the block numbers used by the node or table of - * nodes. The flags indicate the mode the blocks are being held in. In the - * direct table mode the blocks are entries in this table. In the indirect - * mode the blocks point to blocks that hold the block numbers. The data can - * also be a name if it fits. For example a symbolic link. - */ - union - { - rtems_rfs_inode_block blocks[RTEMS_RFS_INODE_BLOCKS]; - uint8_t name[RTEMS_RFS_INODE_DATA_NAME_SIZE]; - } data; - - /** - * The last block map block. Used as the goal when allocating a new block for - * use in the map. - */ - rtems_rfs_inode_block last_map_block; - - /** - * The last data block. Used as the goal when allocating a new block. - */ - rtems_rfs_inode_block last_data_block; - -} rtems_rfs_inode; - -/** - * The size of an inode. - */ -#define RTEMS_RFS_INODE_SIZE (sizeof (rtems_rfs_inode)) - -/** - * RFS Inode Handle. - */ -typedef struct _rtems_rfs_inode_handle -{ - /** - * Handles can be linked as a list for easy processing. - */ - rtems_chain_node link; - - /** - * The ino for this handle. - */ - rtems_rfs_ino ino; - - /** - * The pointer to the inode. - */ - rtems_rfs_inode* node; - - /** - * The buffer that contains this inode. - */ - rtems_rfs_buffer_handle buffer; - - /** - * The block number that holds the inode. - */ - rtems_rfs_buffer_block block; - - /** - * The offset into the block for the inode. - */ - int offset; - - /** - * Number of load requests. - */ - int loads; - -} rtems_rfs_inode_handle; - -/** - * Is the inode loaded ? - */ -#define rtems_rfs_inode_is_loaded(_h) ((_h)->node) - -/** - * Get the inode ino for a handle. - */ -#define rtems_rfs_inode_ino(_h) ((_h)->ino) - -/** - * Get the link count. - * - * @param[in] handle is the inode handle. - * - * @retval links The link count. - */ -static inline uint16_t -rtems_rfs_inode_get_links (rtems_rfs_inode_handle* handle) -{ - uint16_t links; - links = rtems_rfs_read_u16 (&handle->node->links); - if (links == 0xffff) - links = 0; - return links; -} - -/** - * Set the link count. - * - * @param[in] handle is the inode handle. - * @param[in] links are the links. - */ -static inline void -rtems_rfs_inode_set_links (rtems_rfs_inode_handle* handle, uint16_t links) -{ - rtems_rfs_write_u16 (&handle->node->links, links); - rtems_rfs_buffer_mark_dirty (&handle->buffer); -} - -/** - * Get the flags. - * - * @param[in] handle is the inode handle. - * - * @retval flags The flags. - */ -static inline uint16_t -rtems_rfs_inode_get_flags (rtems_rfs_inode_handle* handle) -{ - return rtems_rfs_read_u16 (&handle->node->flags); -} - -/** - * Set the flags. - * - * @param[in] handle is the inode handle. - * @param[in] flags are the flags. - */ -static inline void -rtems_rfs_inode_set_flags (rtems_rfs_inode_handle* handle, uint16_t flags) -{ - rtems_rfs_write_u16 (&handle->node->flags, flags); - rtems_rfs_buffer_mark_dirty (&handle->buffer); -} - -/** - * Get the mode. - * - * @param[in] handle is the inode handle. - * - * @retval mode The mode. - */ -static inline uint16_t -rtems_rfs_inode_get_mode (rtems_rfs_inode_handle* handle) -{ - return rtems_rfs_read_u16 (&handle->node->mode); -} - -/** - * Set the mode. - * - * @param[in] handle is the inode handle. - * @param[in] mode is the mode. - */ -static inline void -rtems_rfs_inode_set_mode (rtems_rfs_inode_handle* handle, uint16_t mode) -{ - rtems_rfs_write_u16 (&handle->node->mode, mode); - rtems_rfs_buffer_mark_dirty (&handle->buffer); -} - -/** - * Get the user id. - * - * @param[in] handle is the inode handle. - * - * @retval uid The used id. - */ -static inline uint16_t -rtems_rfs_inode_get_uid (rtems_rfs_inode_handle* handle) -{ - return rtems_rfs_read_u32 (&handle->node->owner) & 0xffff; -} - -/** - * Get the group id. - * - * @param[in] handle is the inode handle. - * - * @retval gid The grpup id. - */ -static inline uint16_t -rtems_rfs_inode_get_gid (rtems_rfs_inode_handle* handle) -{ - return (rtems_rfs_read_u32 (&handle->node->owner) >> 16) & 0xffff; -} - -/** - * Set the user id and group id. - * - * @param[in] handle is the inode handle. - * @param[in] uid is the user id (uid). - * @param[in] gid is the group id (gid). - */ -static inline void -rtems_rfs_inode_set_uid_gid (rtems_rfs_inode_handle* handle, - uint16_t uid, uint16_t gid) -{ - rtems_rfs_write_u32 (&handle->node->owner, (((uint32_t) gid) << 16) | uid); - rtems_rfs_buffer_mark_dirty (&handle->buffer); -} - -/** - * Get the block offset. - * - * @param[in] handle is the inode handle. - * - * @retval offset The block offset. - */ -static inline uint16_t -rtems_rfs_inode_get_block_offset (rtems_rfs_inode_handle* handle) -{ - return rtems_rfs_read_u16 (&handle->node->block_offset); -} - -/** - * Set the block offset. - * - * @param[in] handle is the inode handle. - * @param[in] block_count is the block offset. - */ -static inline void -rtems_rfs_inode_set_block_offset (rtems_rfs_inode_handle* handle, - uint16_t block_offset) -{ - rtems_rfs_write_u16 (&handle->node->block_offset, block_offset); - rtems_rfs_buffer_mark_dirty (&handle->buffer); -} - -/** - * Get the block count. - * - * @param[in] handle is the inode handle. - * - * @retval count The block count. - */ -static inline uint32_t -rtems_rfs_inode_get_block_count (rtems_rfs_inode_handle* handle) -{ - return rtems_rfs_read_u32 (&handle->node->block_count); -} - -/** - * Set the block count. - * - * @param[in] handle is the inode handle. - * @param[in] block_count is the block count. - */ -static inline void -rtems_rfs_inode_set_block_count (rtems_rfs_inode_handle* handle, uint32_t block_count) -{ - rtems_rfs_write_u32 (&handle->node->block_count, block_count); - rtems_rfs_buffer_mark_dirty (&handle->buffer); -} - -/** - * Get the atime. - * - * @param[in] handle is the inode handle. - * - * @retval atime The atime. - */ -static inline rtems_rfs_time -rtems_rfs_inode_get_atime (rtems_rfs_inode_handle* handle) -{ - return rtems_rfs_read_u32 (&handle->node->atime); -} - -/** - * Set the atime. - * - * @param[in] handle is the inode handle. - * @param[in] atime The atime. - */ -static inline void -rtems_rfs_inode_set_atime (rtems_rfs_inode_handle* handle, - rtems_rfs_time atime) -{ - rtems_rfs_write_u32 (&handle->node->atime, atime); - rtems_rfs_buffer_mark_dirty (&handle->buffer); -} - -/** - * Get the mtime. - * - * @param[in] handle is the inode handle. - * - * @retval mtime The mtime. - */ -static inline rtems_rfs_time -rtems_rfs_inode_get_mtime (rtems_rfs_inode_handle* handle) -{ - return rtems_rfs_read_u32 (&handle->node->mtime); -} - -/** - * Set the mtime. - * - * @param[in] handle is the inode handle. - * @param[in] mtime The mtime. - */ -static inline void -rtems_rfs_inode_set_mtime (rtems_rfs_inode_handle* handle, - rtems_rfs_time mtime) -{ - rtems_rfs_write_u32 (&handle->node->mtime, mtime); - rtems_rfs_buffer_mark_dirty (&handle->buffer); -} - -/** - * Get the ctime. - * - * @param[in] handle is the inode handle. - * - * @retval ctime The ctime. - */ -static inline rtems_rfs_time -rtems_rfs_inode_get_ctime (rtems_rfs_inode_handle* handle) -{ - return rtems_rfs_read_u32 (&handle->node->ctime); -} - -/** - * Set the ctime. - * - * @param[in] handle is the inode handle. - * @param[in] ctime The ctime. - */ -static inline void -rtems_rfs_inode_set_ctime (rtems_rfs_inode_handle* handle, - rtems_rfs_time ctime) -{ - rtems_rfs_write_u32 (&handle->node->ctime, ctime); - rtems_rfs_buffer_mark_dirty (&handle->buffer); -} - -/** - * Get the block number. - * - * @param[in] handle is the inode handle. - * @param[in] block is the block number to return. - * - * @retval block The block number. - */ -static inline uint32_t -rtems_rfs_inode_get_block (rtems_rfs_inode_handle* handle, int block) -{ - return rtems_rfs_read_u32 (&handle->node->data.blocks[block]); -} - -/** - * Set the block number for a given block index. - * - * @param[in] handle is the inode handle. - * @param[in] block is the block index. - * @param[in] bno is the block number. - */ -static inline void -rtems_rfs_inode_set_block (rtems_rfs_inode_handle* handle, int block, uint32_t bno) -{ - rtems_rfs_write_u32 (&handle->node->data.blocks[block], bno); - rtems_rfs_buffer_mark_dirty (&handle->buffer); -} - -/** - * Get the last map block from the inode. - * - * @param[in] handle is the inode handle. - * - * @retval block The last map block number. - */ -static inline uint32_t -rtems_rfs_inode_get_last_map_block (rtems_rfs_inode_handle* handle) -{ - return rtems_rfs_read_u32 (&handle->node->last_map_block); -} - -/** - * Set the last map block. - * - * @param[in] handle is the inode handle. - * @param[in] block_count is last map block number. - */ -static inline void -rtems_rfs_inode_set_last_map_block (rtems_rfs_inode_handle* handle, uint32_t last_map_block) -{ - rtems_rfs_write_u32 (&handle->node->last_map_block, last_map_block); - rtems_rfs_buffer_mark_dirty (&handle->buffer); -} - -/** - * Get the last data block from the inode. - * - * @param[in] handle is the inode handle. - * - * @retval block The last data block number. - * - */ -static inline uint32_t -rtems_rfs_inode_get_last_data_block (rtems_rfs_inode_handle* handle) -{ - return rtems_rfs_read_u32 (&handle->node->last_data_block); -} - -/** - * Set the last data block. - * - * @param[in] handle is the inode handle. - * @param[in] block_count is the last data block number. - */ -static inline void -rtems_rfs_inode_set_last_data_block (rtems_rfs_inode_handle* handle, uint32_t last_data_block) -{ - rtems_rfs_write_u32 (&handle->node->last_data_block, last_data_block); - rtems_rfs_buffer_mark_dirty (&handle->buffer); -} - -/** - * Allocate an inode number and return it. - * - * @param[in] fs is the file system data. - * @param[out] ino will contain the ino. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_inode_alloc (rtems_rfs_file_system* fs, - rtems_rfs_bitmap_bit goal, - rtems_rfs_ino* ino); - -/** - * Free an inode. - * - * @param[in] fs is the file system data. - * @param[in] ino is the ino too free. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_inode_free (rtems_rfs_file_system* fs, - rtems_rfs_ino ino); - -/** - * Open the inode handle. This reads the inode into the buffer and sets the - * data pointer. All data is in media byte order and needs to be accessed via - * the supporting calls. - * - * @param[in] fs is the file system. - * @param[in] ino is the inode number. - * @param[in] handle is the handle to the inode we are opening. - * @param[in] load If true load the inode into memory from the media. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_inode_open (rtems_rfs_file_system* fs, - rtems_rfs_ino ino, - rtems_rfs_inode_handle* handle, - bool load); - -/** - * The close inode handle. All opened inodes need to be closed. - * - * @param[in] fs is the file system. - * @param[in] handle is the handle to close. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_inode_close (rtems_rfs_file_system* fs, - rtems_rfs_inode_handle* handle); - -/** - * Load the inode into memory. - * - * @param[in] fs is the file system. - * @param[in] handle is the inode handle to load. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_inode_load (rtems_rfs_file_system* fs, - rtems_rfs_inode_handle* handle); - -/** - * Unload the inode from memory. - * - * @param[in] fs is the file system. - * @param[in] handle is the inode handle to unload. - * @param[in] update_ctime Update the ctime field of the inode. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_inode_unload (rtems_rfs_file_system* fs, - rtems_rfs_inode_handle* handle, - bool update_ctime); - -/** - * Create an inode allocating, initialising and adding an entry to the parent - * directory. - * - * @param[in] fs is the file system data. - * @param[in] parent is the parent inode number to add the directory entry to. - * @param[in] name is a pointer to the name of the directory entryinode - * to create. - * - */ -int rtems_rfs_inode_create (rtems_rfs_file_system* fs, - rtems_rfs_ino parent, - const char* name, - size_t length, - uint16_t mode, - uint16_t links, - uid_t uid, - gid_t gid, - rtems_rfs_ino* ino); - -/** - * Delete the inode eraseing it and release the buffer to commit the write. You - * need to load the inode again if you wish to use it again. - * - * @param[in] fs is the file system. - * @param[in] handle is the inode handle to erase. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_inode_delete (rtems_rfs_file_system* fs, - rtems_rfs_inode_handle* handle); - -/** - * Initialise a new inode. - * - * @param[in] handle is the inode handle to initialise. - * @param[in] links are the number of links to the inode. - * @param[in] mode is the inode mode. - * @param[in] uid is the user id. - * @param[in] gid is the group id. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_inode_initialise (rtems_rfs_inode_handle* handle, - uint16_t links, - uint16_t mode, - uid_t uid, - gid_t gid); - -/** - * Time stamp the inode with the current time. The ctime field is hanlded - * automatically. - * - * @param[in] handle is the inode handle. - * @param[in] atime Update the atime field. - * @param[in] mtime UPdate the mtime field. - * - * @retval 0 Successful operation. - * @retval ENXIO No inode is loaded. - * @retval error_code An error occurred. - */ -int rtems_rfs_inode_time_stamp_now (rtems_rfs_inode_handle* handle, - bool atime, - bool mtime); - -/** - * Calculate the size of data attached to the inode. - * - * @param[in] fs is the file system data. - * @param[in] handle is the inode handle. - * - * @retval size The data size in bytes in the block map attched to the inode. - */ -rtems_rfs_pos rtems_rfs_inode_get_size (rtems_rfs_file_system* fs, - rtems_rfs_inode_handle* handle); - -#endif - diff --git a/cpukit/libfs/src/rfs/rtems-rfs-link.h b/cpukit/libfs/src/rfs/rtems-rfs-link.h deleted file mode 100644 index d30814aaff..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-link.h +++ /dev/null @@ -1,124 +0,0 @@ -/** - * @file - * - * @brief RTEMS File System Link Support - * - * @ingroup rtems_rfs - * - * RTEMS File System Link Support - * - * This file provides the link support functions. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - - -#if !defined (_RTEMS_RFS_LINK_H_) -#define _RTEMS_RFS_LINK_H_ - -#include - -#include -#include - -/** - * Directory unlink modes. - */ -typedef enum rtems_rfs_unlink_dir_e -{ - rtems_rfs_unlink_dir_denied, /**< Not allowed to unlink a directory. */ - rtems_rfs_unlink_dir_if_empty, /**< Unlink if the directory is empty. */ - rtems_rfs_unlink_dir_allowed /**< Unlinking of directories is allowed. */ -} rtems_rfs_unlink_dir; - -/** - * Create a link. Do not link directories unless renaming or you will create - * loops in the file system. - * - * @param[in] fs is the file system. - * @param[in] name is a pointer to the name of the link. - * @param[in] length is the length of the name. - * @param[in] parent is the inode number of the parent directory. - * @param[in] target is the inode of the target. - * @param[in] link_dir If true directories can be linked. Useful when - * renaming. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_link (rtems_rfs_file_system* fs, - const char* name, - int length, - rtems_rfs_ino parent, - rtems_rfs_ino target, - bool link_dir); - -/** - * Unlink the node from the parent directory. A directory offset for the - * target entry is required because links cause a number of inode numbers to - * appear in a single directory so scanning does not work. - * - * @param[in] fs is the file system. - * @param[in] parent is the inode number of the parent directory. - * @param[in] target is the inode of the target. - * @param[in] doff is the parent directory entry offset for the target entry. - * @param[in] dir_mode is the directory unlink mode. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_unlink (rtems_rfs_file_system* fs, - rtems_rfs_ino parent, - rtems_rfs_ino target, - uint32_t doff, - rtems_rfs_unlink_dir dir_mode); - -/** - * Symbolic link is an inode that has a path attached. - * - * @param[in] fs is the file system data. - * @param[in] name is a pointer to the name of the node. - * @param[in] length is the length of the name of the node. - * @param[in] link is a pointer to the link path attached to the - * symlink inode. - * @param[in] link_length is the length of the link path. - * @param[in] parent is the parent inode number. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_symlink (rtems_rfs_file_system* fs, - const char* name, - int length, - const char* link, - int link_length, - uid_t uid, - gid_t gid, - rtems_rfs_ino parent); - -/** - * Read a symbolic link into the provided buffer returning the link of link - * name. - * - * @param[in] fs is the file system data. - * @param[in] link is the link inode number to read. - * @param[in] path is a pointer to the buffer to write the link path into. - * @param[in] size is the size of the buffer. - * @param[out] length will contain the length of the link path. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_rfs_symlink_read (rtems_rfs_file_system* fs, - rtems_rfs_ino link, - char* path, - size_t size, - size_t* length); - -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs-mutex.h b/cpukit/libfs/src/rfs/rtems-rfs-mutex.h deleted file mode 100644 index 606fd53233..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-mutex.h +++ /dev/null @@ -1,116 +0,0 @@ -/** - * @file - * - * @brief RTEMS File System Mutex - * - * @ingroup rtems_rfs - * - * RTEMS File System Mutex. - * - * It may be suprising we abstract this for the RTEMS file system but this code - * is designed to be run on host operating systems. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if !defined (_RTEMS_RFS_MUTEX_H_) -#define _RTEMS_RFS_MUTEX_H_ - -#include - -#include - -#if __rtems__ -#include -#include -#endif - -/** - * RFS Mutex type. - */ -#if __rtems__ -typedef rtems_id rtems_rfs_mutex; -#else -typedef uint32_t rtems_rfs_mutex; /* place holder */ -#endif - -/** - * @brief Create the mutex. - * - * @param [in] mutex is pointer to the mutex handle returned to the caller. - * - * @retval 0 Successful operation. - * @retval EIO An error occurred. - * - */ -int rtems_rfs_mutex_create (rtems_rfs_mutex* mutex); - -/** - * @brief Destroy the mutex. - * - * @param[in] mutex Reference to the mutex handle returned to the caller. - * - * @retval 0 Successful operation. - * @retval EIO An error occurred. - */ -int rtems_rfs_mutex_destroy (rtems_rfs_mutex* mutex); - -/** - * @brief Lock the mutex. - * - * @param[in] mutex is a pointer to the mutex to lock. - * - * @retval 0 Successful operation. - * @retval EIO An error occurred. - */ -static inline int -rtems_rfs_mutex_lock (rtems_rfs_mutex* mutex) -{ -#if __rtems__ - rtems_status_code sc = rtems_semaphore_obtain (*mutex, RTEMS_WAIT, 0); - if (sc != RTEMS_SUCCESSFUL) - { -#if RTEMS_RFS_TRACE - if (rtems_rfs_trace (RTEMS_RFS_TRACE_MUTEX)) - printf ("rtems-rfs: mutex: obtain failed: %s\n", - rtems_status_text (sc)); -#endif - return EIO; - } -#endif - return 0; -} - -/** - * @brief Unlock the mutex. - * - * @param[in] mutex is a pointer to the mutex to unlock. - * - * @retval 0 Successful operation. - * @retval EIO An error occurred. - */ -static inline int -rtems_rfs_mutex_unlock (rtems_rfs_mutex* mutex) -{ -#if __rtems__ - rtems_status_code sc = rtems_semaphore_release (*mutex); - if (sc != RTEMS_SUCCESSFUL) - { -#if RTEMS_RFS_TRACE - if (rtems_rfs_trace (RTEMS_RFS_TRACE_MUTEX)) - printf ("rtems-rfs: mutex: release failed: %s\n", - rtems_status_text (sc)); -#endif - return EIO; - } -#endif - return 0; -} - -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs-shell.h b/cpukit/libfs/src/rfs/rtems-rfs-shell.h deleted file mode 100644 index c2e1108a47..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-shell.h +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @file - * - * @ingroup rtems_rfs - * @brief RTEMS File Systems Shell Commands - * - * RTEMS File Systems Shell commands provide a CLI interface to support and - * development of the RFS file system. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if !defined (_RTEMS_RFS_SHELL_H_) -#define _RTEMS_RFS_SHELL_H_ - -#include -#include -#include - -/** - * The shell command for the RFS debugger. - * - * @param[in] argc is the argument count. - * @param[in] argv is a pointer to the argument variables. - * - * @retval 0 Successful operation. - * @retval error_code An error occurred. - */ -int rtems_shell_debugrfs (int argc, char *argv[]); - -/** - * The shell command for formatting an RFS file system. - * - * @param[in] argc is the argument count. - * @param[in] argv is a pointer to the argument variables. - * - * @retval 0 Successful operation. - * @retval 1 An error occurred. - */ -int rtems_shell_rfs_format (int argc, char* argv[]); - -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs-trace.h b/cpukit/libfs/src/rfs/rtems-rfs-trace.h deleted file mode 100644 index 4d6d0c9ddb..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs-trace.h +++ /dev/null @@ -1,135 +0,0 @@ -/** - * @file - * - * @brief Manages the Trace and Debugging Features of the - * RTEMS RFS File System - * - * @ingroup rtems_rfs - * - * RTEMS File Systems Trace manages the trace and debugging features of the - * RTEMS RFS file system. The design allows all tracing code and strings to be - * removed from the target code for small footprint systems. - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - - -#if !defined (_RTEMS_RFS_TRACE_H_) -#define _RTEMS_RFS_TRACE_H_ - -#include -#include -#include -#include - -/** - * Is tracing enabled ? - */ -#if !defined (RTEMS_RFS_TRACE) -#define RTEMS_RFS_TRACE 1 -#endif - -/** - * The type of the mask. - */ -typedef uint64_t rtems_rfs_trace_mask; - -/** - * List of tracing bits for the various parts of the file system. - */ -#define RTEMS_RFS_TRACE_ALL (0xffffffffffffffffULL) -#define RTEMS_RFS_TRACE_OPEN (1ULL << 0) -#define RTEMS_RFS_TRACE_CLOSE (1ULL << 1) -#define RTEMS_RFS_TRACE_MUTEX (1ULL << 2) -#define RTEMS_RFS_TRACE_BUFFER_OPEN (1ULL << 3) -#define RTEMS_RFS_TRACE_BUFFER_CLOSE (1ULL << 4) -#define RTEMS_RFS_TRACE_BUFFER_SYNC (1ULL << 5) -#define RTEMS_RFS_TRACE_BUFFER_RELEASE (1ULL << 6) -#define RTEMS_RFS_TRACE_BUFFER_CHAINS (1ULL << 7) -#define RTEMS_RFS_TRACE_BUFFER_HANDLE_REQUEST (1ULL << 8) -#define RTEMS_RFS_TRACE_BUFFER_HANDLE_RELEASE (1ULL << 9) -#define RTEMS_RFS_TRACE_BUFFER_SETBLKSIZE (1ULL << 10) -#define RTEMS_RFS_TRACE_BUFFERS_RELEASE (1ULL << 11) -#define RTEMS_RFS_TRACE_BLOCK_FIND (1ULL << 12) -#define RTEMS_RFS_TRACE_BLOCK_MAP_GROW (1ULL << 13) -#define RTEMS_RFS_TRACE_BLOCK_MAP_SHRINK (1ULL << 14) -#define RTEMS_RFS_TRACE_GROUP_OPEN (1ULL << 15) -#define RTEMS_RFS_TRACE_GROUP_CLOSE (1ULL << 16) -#define RTEMS_RFS_TRACE_GROUP_BITMAPS (1ULL << 17) -#define RTEMS_RFS_TRACE_INODE_OPEN (1ULL << 18) -#define RTEMS_RFS_TRACE_INODE_CLOSE (1ULL << 19) -#define RTEMS_RFS_TRACE_INODE_LOAD (1ULL << 20) -#define RTEMS_RFS_TRACE_INODE_UNLOAD (1ULL << 21) -#define RTEMS_RFS_TRACE_INODE_CREATE (1ULL << 22) -#define RTEMS_RFS_TRACE_INODE_DELETE (1ULL << 23) -#define RTEMS_RFS_TRACE_LINK (1ULL << 24) -#define RTEMS_RFS_TRACE_UNLINK (1ULL << 25) -#define RTEMS_RFS_TRACE_DIR_LOOKUP_INO (1ULL << 26) -#define RTEMS_RFS_TRACE_DIR_LOOKUP_INO_CHECK (1ULL << 27) -#define RTEMS_RFS_TRACE_DIR_LOOKUP_INO_FOUND (1ULL << 28) -#define RTEMS_RFS_TRACE_DIR_ADD_ENTRY (1ULL << 29) -#define RTEMS_RFS_TRACE_DIR_DEL_ENTRY (1ULL << 30) -#define RTEMS_RFS_TRACE_DIR_READ (1ULL << 31) -#define RTEMS_RFS_TRACE_DIR_EMPTY (1ULL << 32) -#define RTEMS_RFS_TRACE_SYMLINK (1ULL << 33) -#define RTEMS_RFS_TRACE_SYMLINK_READ (1ULL << 34) -#define RTEMS_RFS_TRACE_FILE_OPEN (1ULL << 35) -#define RTEMS_RFS_TRACE_FILE_CLOSE (1ULL << 36) -#define RTEMS_RFS_TRACE_FILE_IO (1ULL << 37) -#define RTEMS_RFS_TRACE_FILE_SET (1ULL << 38) - -/** - * Call to check if this part is bring traced. If RTEMS_RFS_TRACE is defined to - * 0 the code is dead code elminiated when built with -Os, -O2, or higher. - * - * @param[in] mask is the part of the API to trace. - * - * @retval true Tracing is active for the mask. - * @retval false Do not trace. - */ -#if RTEMS_RFS_TRACE -bool rtems_rfs_trace (rtems_rfs_trace_mask mask); -#else -#define rtems_rfs_trace(_m) (0) -#endif - -/** - * Set the mask. - * - * @param[in] mask are the mask bits to set. - * - * @retval mask The previous mask. - */ -#if RTEMS_RFS_TRACE -rtems_rfs_trace_mask rtems_rfs_trace_set_mask (rtems_rfs_trace_mask mask); -#else -#define rtems_rfs_trace_set_mask(_m) -#endif - -/** - * Clear the mask. - * - * @param[in] mask are the mask bits to clear. - * - * @retval mask The previous mask. - */ -#if RTEMS_RFS_TRACE -rtems_rfs_trace_mask rtems_rfs_trace_clear_mask (rtems_rfs_trace_mask mask); -#else -#define rtems_rfs_trace_clear_mask(_m) -#endif - -/** - * Add shell trace shell command. - */ -#if RTEMS_RFS_TRACE -int rtems_rfs_trace_shell_command (int argc, char *argv[]); -#endif - -#endif diff --git a/cpukit/libfs/src/rfs/rtems-rfs.h b/cpukit/libfs/src/rfs/rtems-rfs.h deleted file mode 100644 index 958f9a636b..0000000000 --- a/cpukit/libfs/src/rfs/rtems-rfs.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @file - * - * @brief RFS File system Initialization - * @ingroup rtems_rfs - * - * RTEMS File System - * - */ - -/* - * COPYRIGHT (c) 2010 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if !defined(RTEMS_RFS_DEFINED) -#define RTEMS_RFS_DEFINED - -#include -#include - -/** - * @defgroup rtems_rfs RTEMS File System Group Management - * - * @ingroup FileSystemTypesAndMount - */ -/**@{*/ - -/** - * Initialise the RFS File system. - */ -int rtems_rfs_rtems_initialise (rtems_filesystem_mount_table_entry_t *mt_entry, const void *data); - -/**@}*/ -#endif diff --git a/cpukit/libi2c/libi2c.h b/cpukit/libi2c/libi2c.h deleted file mode 100644 index 341e390760..0000000000 --- a/cpukit/libi2c/libi2c.h +++ /dev/null @@ -1,508 +0,0 @@ -/** - * @file - * - * @ingroup libi2c - * - * @brief I2C Library - */ - -#ifndef _RTEMS_LIBI2C_H -#define _RTEMS_LIBI2C_H - -/* - * Authorship - * ---------- - * This software was created by - * Till Straumann , 2005, - * Stanford Linear Accelerator Center, Stanford University. - * - * Acknowledgement of sponsorship - * ------------------------------ - * This software was produced by - * the Stanford Linear Accelerator Center, Stanford University, - * under Contract DE-AC03-76SFO0515 with the Department of Energy. - * - * Government disclaimer of liability - * ---------------------------------- - * Neither the United States nor the United States Department of Energy, - * nor any of their employees, makes any warranty, express or implied, or - * assumes any legal liability or responsibility for the accuracy, - * completeness, or usefulness of any data, apparatus, product, or process - * disclosed, or represents that its use would not infringe privately owned - * rights. - * - * Stanford disclaimer of liability - * -------------------------------- - * Stanford University makes no representations or warranties, express or - * implied, nor assumes any liability for the use of this software. - * - * Stanford disclaimer of copyright - * -------------------------------- - * Stanford University, owner of the copyright, hereby disclaims its - * copyright and all other rights in this software. Hence, anyone may - * freely use it for any purpose without restriction. - * - * Maintenance of notices - * ---------------------- - * In the interest of clarity regarding the origin and status of this - * SLAC software, this and all the preceding Stanford University notices - * are to remain affixed to any copy or derivative of this software made - * or distributed by the recipient and are to be affixed to any copy of - * software made or distributed by the recipient that contains a copy or - * derivative of this software. - * - * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03 - */ - -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup libi2c I2C Library - * - * @brief I2C library. - * - */ -/**@{**/ - -/* Simple I2C driver API */ - -/* Initialize the libary - may fail if no semaphore or no driver slot is available */ -extern int rtems_libi2c_initialize (void); - -/* Alternatively to rtems_libi2c_initialize() the library can also be - * initialized by means of a traditional driver table entry containing - * the following entry points: - */ -extern rtems_status_code -rtems_i2c_init ( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *arg); - -extern rtems_status_code -rtems_i2c_open ( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *arg); - -extern rtems_status_code -rtems_i2c_close ( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *arg); - -extern rtems_status_code -rtems_i2c_read ( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *arg); - -extern rtems_status_code -rtems_i2c_write ( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *arg); - -extern rtems_status_code -rtems_i2c_ioctl ( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *arg); - -extern const rtems_driver_address_table rtems_libi2c_io_ops; - -/* Unfortunately, if you want to add this driver to - * a RTEMS configuration table then you need all the - * members explicitly :-( (Device_driver_table should - * hold pointers to rtems_driver_address_tables rather - * than full structs). - * - * The difficulty is that adding this driver to the - * configuration table is not enough; you still need - * to populate the framework with low-level bus-driver(s) - * and high-level drivers and/or device-files... - * - * Currently the preferred way is having the BSP - * call 'rtems_libi2c_initialize' followed by - * 'rtems_libi2c_register_bus' and - * 'rtems_libi2c_register_drv' and/or - * 'mknod' (for 'raw' device nodes) - * from the 'bsp_predriver_hook'. - */ -#define RTEMS_LIBI2C_DRIVER_TABLE_ENTRY \ -{ \ - initialization_entry: rtems_i2c_init, \ - open_entry: rtems_i2c_open, \ - close_entry: rtems_i2c_close, \ - read_entry: rtems_i2c_read, \ - write_entry: rtems_i2c_write, \ - control_entry: rtems_i2c_ioctl, \ -} - -/* Bus Driver API - * - * Bus drivers provide access to low-level i2c functions - * such as 'send start', 'send address', 'get bytes' etc. - */ - -/* first field must be a pointer to ops; driver - * may add its own fields after this. - * the struct that is registered with the library - * is not copied; a pointer will we passed - * to the callback functions (ops). - */ -typedef struct rtems_libi2c_bus_t_ -{ - const struct rtems_libi2c_bus_ops_ *ops; - int size; /* size of whole structure */ -} rtems_libi2c_bus_t; - -/* Access functions a low level driver must provide; - * - * All of these, except read_bytes and write_bytes - * return RTEMS_SUCCESSFUL on success and an error status - * otherwise. The read and write ops return the number - * of chars read/written or -(status code) on error. - */ -typedef struct rtems_libi2c_bus_ops_ -{ - /* Initialize the bus; might be called again to reset the bus driver */ - rtems_status_code (*init) (rtems_libi2c_bus_t * bushdl); - /* Send start condition */ - rtems_status_code (*send_start) (rtems_libi2c_bus_t * bushdl); - /* Send stop condition */ - rtems_status_code (*send_stop) (rtems_libi2c_bus_t * bushdl); - /* initiate transfer from (rw!=0) or to a device */ - rtems_status_code (*send_addr) (rtems_libi2c_bus_t * bushdl, - uint32_t addr, int rw); - /* read a number of bytes */ - int (*read_bytes) (rtems_libi2c_bus_t * bushdl, unsigned char *bytes, - int nbytes); - /* write a number of bytes */ - int (*write_bytes) (rtems_libi2c_bus_t * bushdl, unsigned char *bytes, - int nbytes); - /* ioctl misc functions */ - int (*ioctl) (rtems_libi2c_bus_t * bushdl, - int cmd, - void *buffer - ); -} rtems_libi2c_bus_ops_t; - - -/* - * Register a lowlevel driver - * - * TODO: better description - * - * This allocates a major number identifying *this* driver - * (i.e., libi2c) and the minor number encodes a bus# and a i2c address. - * - * The name will be registered in the filesystem (parent - * directories must exist, also IMFS filesystem must exist). It may be NULL in - * which case the library will pick a default. - * - * RETURNS: bus # (>=0) or -1 on error (errno set). - */ - -extern int rtems_libi2c_register_bus (const char *name, rtems_libi2c_bus_t * bus); - -extern rtems_device_major_number rtems_libi2c_major; - -#define RTEMS_LIBI2C_MAKE_MINOR(busno, i2caddr) \ - ((((busno)&((1<<3)-1))<<10) | ((i2caddr)&((1<<10)-1))) - -/* After the library is initialized, a major number is available. - * As soon as a low-level bus driver is registered (above routine - * returns a 'busno'), a device node can be created in the filesystem - * with a major/minor number pair of - * - * rtems_libi2c_major / RTEMS_LIBI2C_MAKE_MINOR(busno, i2caddr) - * - * and a 'raw' hi-level driver is then attached to this device - * node. - * This 'raw' driver has very simple semantics: - * - * 'open' sends a start condition - * 'read'/'write' address the device identified by the i2c bus# and address - * encoded in the minor number and read or write, respectively - * a stream of bytes from or to the device. Every time the - * direction is changed, a 're-start' condition followed by - * an 'address' cycle is generated on the i2c bus. - * 'close' sends a stop condition. - * - * Hence, using the 'raw' driver, e.g., 100 bytes at offset 0x200 can be - * read from an EEPROM by the following pseudo-code: - * - * mknod("/dev/i2c-54", mode, MKDEV(rtems_libi2c_major, RTEMS_LIBI2C_MAKE_MINOR(0,0x54))) - * - * int fd; - * char off[2]={0x02,0x00}; - * - * fd = open("/dev/i2c-54",O_RDWR); - * write(fd,off,2); - * read(fd,buf,100); - * close(fd); - * - */ - -/* Higher Level Driver API - * - * Higher level drivers know how to deal with specific i2c - * devices (independent of the bus interface chip) and provide - * an abstraction, i.e., the usual read/write/ioctl access. - * - * Using the above example, such a high level driver could - * prevent the user from issuing potentially destructive write - * operations (the aforementioned EEPROM interprets any 3rd - * and following byte written to the device as data, i.e., the - * contents could easily be changed!). - * The correct 'read-pointer offset' programming could be - * implemented in 'open' and 'ioctl' of a high-level driver and - * the user would then only have to perform harmless read - * operations, e.g., - * - * fd = open("/dev/i2c.eeprom",O_RDONLY) / * opens and sets EEPROM read pointer * / - * ioctl(fd, IOCTL_SEEK, 0x200) / * repositions the read pointer * / - * read(fd, buf, 100) - * close(fd) - * - */ - -/* struct provided at driver registration. The driver may store - * private data behind the mandatory first fields but the size - * must be set to the size of the entire struct, e.g., - * - * struct driver_pvt { - * rtems_libi2c_drv_t pub; - * struct { ... } pvt; - * } my_driver = { - * { ops: my_ops, - * size: sizeof(my_driver) - * }, - * { ...}; - * }; - * - * A pointer to this struct is passed to the callback ops. - */ - -typedef struct rtems_libi2c_drv_t_ -{ - const rtems_driver_address_table *ops; /* the driver ops */ - int size; /* size of whole structure (including appended private data) */ -} rtems_libi2c_drv_t; - -/* - * The high level driver must be registered with a particular - * bus number and i2c address. - * - * The registration procedure also creates a filesystem node, - * i.e., the returned minor number is not really needed. - * - * If the 'name' argument is NULL, no filesystem node is - * created (but this can be done 'manually' using rtems_libi2c_major - * and the return value of this routine). - * - * RETURNS minor number (FYI) or -1 on failure - */ -extern int -rtems_libi2c_register_drv (const char *name, rtems_libi2c_drv_t * drvtbl, - unsigned bus, unsigned i2caddr); - -/* Operations available to high level drivers */ - -/* NOTES: The bus a device is attached to is LOCKED from the first send_start - * until send_stop is executed! - * - * Bus tenure MUST NOT span multiple system calls - otherwise, a single - * thread could get into the protected sections (or would deadlock if the - * mutex was not nestable). - * E.g., consider what happens if 'open' sends a 'start' and 'close' - * sends a 'stop' (i.e., the bus mutex would be locked in 'open' and - * released in 'close'. A single thread could try to open two devices - * on the same bus and would either deadlock or nest into the bus mutex - * and potentially mess up the i2c messages. - * - * The correct way is to *always* relinquish the i2c bus (i.e., send 'stop' - * from any driver routine prior to returning control to the caller. - * Consult the implementation of the generic driver routines (open, close, ...) - * below or the examples in i2c-2b-eeprom.c and i2c-2b-ds1621.c - * - * Drivers just pass the minor number on to these routines... - */ -extern rtems_status_code rtems_libi2c_send_start (rtems_device_minor_number minor); - -extern rtems_status_code rtems_libi2c_send_stop (rtems_device_minor_number minor); - -extern rtems_status_code -rtems_libi2c_send_addr (rtems_device_minor_number minor, int rw); - -/* the read/write routines return the number of bytes transferred - * or -(status_code) on error. - */ -extern int -rtems_libi2c_read_bytes (rtems_device_minor_number minor, - unsigned char *bytes, int nbytes); - -extern int -rtems_libi2c_write_bytes (rtems_device_minor_number minor, - const unsigned char *bytes, int nbytes); - -/* Send start, send address and read bytes */ -extern int -rtems_libi2c_start_read_bytes (rtems_device_minor_number minor, - unsigned char *bytes, - int nbytes); - -/* Send start, send address and write bytes */ -extern int -rtems_libi2c_start_write_bytes (rtems_device_minor_number minor, - const unsigned char *bytes, - int nbytes); - - -/* call misc iocontrol function */ -extern int -rtems_libi2c_ioctl (rtems_device_minor_number minor, - int cmd, - ...); -/* - * NOTE: any low-level driver ioctl returning a negative - * result for release the bus (perform a STOP condition) - */ -/******************************* - * defined IOCTLs: - *******************************/ -#define RTEMS_LIBI2C_IOCTL_READ_WRITE 1 -/* - * retval = rtems_libi2c_ioctl(rtems_device_minor_number minor, - * RTEMS_LIBI2C_IOCTL_READ_WRITE, - * rtems_libi2c_read_write_t *arg); - * - * This call performs a simultanous read/write transfer, - * which is possible (and sometimes needed) for SPI devices - * - * arg is a pointer to a rd_wr info data structure - * - * This call is only needed for SPI devices - */ -#define RTEMS_LIBI2C_IOCTL_START_TFM_READ_WRITE 2 -/* - * retval = rtems_libi2c_ioctl(rtems_device_minor_number minor, - * RTEMS_LIBI2C_IOCTL_START_READ_WRITE, - * unsigned char *rd_buffer, - * const unsigned char *wr_buffer, - * int byte_cnt, - * const rtems_libi2c_tfr_mode_t *tfr_mode_ptr); - * - * This call addresses a slave and then: - * - sets the proper transfer mode, - * - performs a simultanous read/write transfer, - * (which is possible and sometimes needed for SPI devices) - * NOTE: - if rd_buffer is NULL, receive data will be dropped - * - if wr_buffer is NULL, bytes with content 0 will transmitted - * - * rd_buffer is a pointer to a receive buffer (or NULL) - * wr_buffer is a pointer to the data to be sent (or NULL) - * - * This call is only needed for SPI devices - */ - -#define RTEMS_LIBI2C_IOCTL_SET_TFRMODE 3 -/* - * retval = rtems_libi2c_ioctl(rtems_device_minor_number minor, - * RTEMS_LIBI2C_IOCTL_SET_TFRMODE, - * const rtems_libi2c_tfr_mode_t *tfr_mode_ptr); - * - * This call sets an SPI device to the transfer mode needed (baudrate etc.) - * - * tfr_mode is a pointer to a structure defining the SPI transfer mode needed - * (see below). - * - * This call is only needed for SPI devices - */ - -#define RTEMS_LIBI2C_IOCTL_GET_DRV_T 4 - -/* - * retval = rtems_libi2c_ioctl(rtems_device_minor_number minor, - * RTEMS_LIBI2C_IOCTL_GET_DRV_T, - * const rtems_libi2c_drv_t *drv_t_ptr); - * - * This call allows the a high-level driver to query its driver table entry, - * including its private data appended to it during creation of the entry - * - */ - -/** - * @brief IO control command for asynchronous read and write. - * - * @see rtems_libi2c_read_write_done_t and rtems_libi2c_read_write_async_t. - * - * @warning This is work in progress! - */ -#define RTEMS_LIBI2C_IOCTL_READ_WRITE_ASYNC 5 - -/* - * argument data structures for IOCTLs defined above - */ -typedef struct { - unsigned char *rd_buf; - const unsigned char *wr_buf; - int byte_cnt; -} rtems_libi2c_read_write_t; - -typedef struct { - uint32_t baudrate; /* maximum bits per second */ - /* only valid for SPI drivers: */ - uint8_t bits_per_char; /* how many bits per byte/word/longword? */ - bool lsb_first; /* true: send LSB first */ - bool clock_inv; /* true: inverted clock (high active) */ - bool clock_phs; /* true: clock starts toggling at start of data tfr */ - uint32_t idle_char; /* This character will be continuously transmitted in read only functions */ -} rtems_libi2c_tfr_mode_t; - -typedef struct { - rtems_libi2c_tfr_mode_t tfr_mode; - rtems_libi2c_read_write_t rd_wr; -} rtems_libi2c_tfm_read_write_t; - -/** - * @brief Notification function type for asynchronous read and write. - * - * @see RTEMS_LIBI2C_IOCTL_READ_WRITE_ASYNC and - * rtems_libi2c_read_write_async_t. - * - * @warning This is work in progress! - */ -typedef void (*rtems_libi2c_read_write_done_t) \ - ( int /* return value */, int /* nbytes */, void * /* arg */); - -/** - * @brief IO command data for asynchronous read and write. - * - * @see RTEMS_LIBI2C_IOCTL_READ_WRITE_ASYNC and - * rtems_libi2c_read_write_done_t. - * - * @warning This is work in progress! - */ -typedef struct { - unsigned char *rd_buf; - const unsigned char *wr_buf; - int byte_cnt; - rtems_libi2c_read_write_done_t done; - void *arg; -} rtems_libi2c_read_write_async_t; - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/libmd/Makefile.am b/cpukit/libmd/Makefile.am index 2d3f2e1ad2..b56aff7ca5 100644 --- a/cpukit/libmd/Makefile.am +++ b/cpukit/libmd/Makefile.am @@ -1,12 +1,6 @@ include $(top_srcdir)/automake/compile.am if NEWLIB -include_HEADERS = -include_HEADERS += md4.h -include_HEADERS += md5.h -include_HEADERS += sha256.h -include_HEADERS += sha512.h - noinst_LIBRARIES = libmd.a libmd_a_SOURCES = libmd_a_SOURCES += md4.c @@ -18,5 +12,4 @@ endif libmd_a_CPPFLAGS = $(AM_CPPFLAGS) endif -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am diff --git a/cpukit/libmd/md4.h b/cpukit/libmd/md4.h deleted file mode 100644 index c5ae2f13ef..0000000000 --- a/cpukit/libmd/md4.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -** ******************************************************************** -** md4.h -- Header file for implementation of ** -** MD4 Message Digest Algorithm ** -** Updated: 2/13/90 by Ronald L. Rivest ** -** (C) 1990 RSA Data Security, Inc. ** -** ******************************************************************** -*/ - -#include - -/* MDstruct is the data structure for a message digest computation. -*/ -typedef struct { - uint32_t buffer[4]; /* Holds 4-word result of MD computation */ - uint8_t count[8]; /* Number of bits processed so far */ - uint32_t done; /* Nonzero means MD computation finished */ -} MD4_CTX; - -/* MD4Init(MD4_CTX *) -** Initialize the MD4_CTX prepatory to doing a message digest -** computation. -*/ -extern void MD4Init(MD4_CTX *MD); - -/* MD4Update(MD,X,count) -** Input: X -- a pointer to an array of unsigned characters. -** count -- the number of bits of X to use (an unsigned int). -** Updates MD using the first "count" bits of X. -** The array pointed to by X is not modified. -** If count is not a multiple of 8, MD4Update uses high bits of -** last byte. -** This is the basic input routine for a user. -** The routine terminates the MD computation when count < 512, so -** every MD computation should end with one call to MD4Update with a -** count less than 512. Zero is OK for a count. -*/ -extern void MD4Update(MD4_CTX *MD, unsigned char *X, unsigned int count); - -/* MD4Print(MD) -** Prints message digest buffer MD as 32 hexadecimal digits. -** Order is from low-order byte of buffer[0] to high-order byte -** of buffer[3]. -** Each byte is printed with high-order hexadecimal digit first. -*/ -extern void MD4Print(MD4_CTX *); - -/* MD4Final(buf, MD) -** Returns message digest from MD and terminates the message -** digest computation. -*/ -extern void MD4Final(unsigned char *, MD4_CTX *); - -/* -** End of md4.h -****************************(cut)***********************************/ diff --git a/cpukit/libmd/md5.h b/cpukit/libmd/md5.h deleted file mode 100644 index ca48d61d7b..0000000000 --- a/cpukit/libmd/md5.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - *********************************************************************** - ** md5.h -- header file for implementation of MD5 ** - ** RSA Data Security, Inc. MD5 Message-Digest Algorithm ** - ** Created: 2/17/90 RLR ** - ** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version ** - ** Revised (for MD5): RLR 4/27/91 ** - ** -- G modified to have y&~z instead of y&z ** - ** -- FF, GG, HH modified to add in last register done ** - ** -- Access pattern: round 2 works mod 5, round 3 works mod 3 ** - ** -- distinct additive constant for each step ** - ** -- round 4 added, working mod 7 ** - *********************************************************************** - */ - -/* - *********************************************************************** - ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. ** - ** ** - ** License to copy and use this software is granted provided that ** - ** it is identified as the "RSA Data Security, Inc. MD5 Message- ** - ** Digest Algorithm" in all material mentioning or referencing this ** - ** software or this function. ** - ** ** - ** License is also granted to make and use derivative works ** - ** provided that such works are identified as "derived from the RSA ** - ** Data Security, Inc. MD5 Message-Digest Algorithm" in all ** - ** material mentioning or referencing the derived work. ** - ** ** - ** RSA Data Security, Inc. makes no representations concerning ** - ** either the merchantability of this software or the suitability ** - ** of this software for any particular purpose. It is provided "as ** - ** is" without express or implied warranty of any kind. ** - ** ** - ** These notices must be retained in any copies of any part of this ** - ** documentation and/or software. ** - *********************************************************************** - */ - -#ifndef __MD5_INCLUDE__ - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* typedef a 32-bit type */ -typedef uint32_t UINT4; - -#define MD5_BLOCK_LENGTH 64 -#define MD5_DIGEST_LENGTH 16 - -/* Data structure for MD5 (Message-Digest) computation */ -typedef struct { - UINT4 i[2]; /* number of _bits_ handled mod 2^64 */ - UINT4 buf[4]; /* scratch buffer */ - unsigned char in[64]; /* input buffer */ - unsigned char digest[16]; /* actual digest after MD5Final call */ -} MD5_CTX; - -void MD5Init (MD5_CTX *); -void MD5Update (MD5_CTX *, const void *, unsigned int); -void MD5Final (unsigned char [16], MD5_CTX *); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#define __MD5_INCLUDE__ -#endif /* __MD5_INCLUDE__ */ diff --git a/cpukit/libmd/preinstall.am b/cpukit/libmd/preinstall.am deleted file mode 100644 index f4462f4193..0000000000 --- a/cpukit/libmd/preinstall.am +++ /dev/null @@ -1,38 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -$(PROJECT_INCLUDE)/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE) - @: > $(PROJECT_INCLUDE)/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/$(dirstamp) - -if NEWLIB -$(PROJECT_INCLUDE)/md4.h: md4.h $(PROJECT_INCLUDE)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/md4.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/md4.h - -$(PROJECT_INCLUDE)/md5.h: md5.h $(PROJECT_INCLUDE)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/md5.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/md5.h - -$(PROJECT_INCLUDE)/sha256.h: sha256.h $(PROJECT_INCLUDE)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sha256.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sha256.h - -$(PROJECT_INCLUDE)/sha512.h: sha512.h $(PROJECT_INCLUDE)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sha512.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sha512.h - -endif diff --git a/cpukit/libmd/sha256.h b/cpukit/libmd/sha256.h deleted file mode 100644 index 1b6a4f4c57..0000000000 --- a/cpukit/libmd/sha256.h +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright 2005 Colin Percival - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _SHA256_H_ -#define _SHA256_H_ - -#include - -typedef struct SHA256Context { - uint32_t state[8]; - uint64_t count; - unsigned char buf[64]; -} SHA256_CTX; - -__BEGIN_DECLS -void SHA256_Init(SHA256_CTX *); -void SHA256_Update(SHA256_CTX *, const void *, size_t); -void SHA256_Final(unsigned char [32], SHA256_CTX *); -char *SHA256_End(SHA256_CTX *, char *); -char *SHA256_File(const char *, char *); -char *SHA256_FileChunk(const char *, char *, off_t, off_t); -char *SHA256_Data(const void *, unsigned int, char *); -__END_DECLS - -#endif /* !_SHA256_H_ */ diff --git a/cpukit/libmd/sha512.h b/cpukit/libmd/sha512.h deleted file mode 100644 index 8998f4c5bf..0000000000 --- a/cpukit/libmd/sha512.h +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright 2005 Colin Percival - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _SHA512_H_ -#define _SHA512_H_ - -#include - -typedef struct SHA512Context { - uint64_t state[8]; - uint64_t count[2]; - unsigned char buf[128]; -} SHA512_CTX; - -__BEGIN_DECLS -void SHA512_Init(SHA512_CTX *); -void SHA512_Update(SHA512_CTX *, const void *, size_t); -void SHA512_Final(unsigned char [64], SHA512_CTX *); -char *SHA512_End(SHA512_CTX *, char *); -char *SHA512_File(const char *, char *); -char *SHA512_FileChunk(const char *, char *, off_t, off_t); -char *SHA512_Data(const void *, unsigned int, char *); -__END_DECLS - -#endif /* !_SHA512_H_ */ diff --git a/cpukit/libmisc/Makefile.am b/cpukit/libmisc/Makefile.am index e1343ddf11..ca4686a954 100644 --- a/cpukit/libmisc/Makefile.am +++ b/cpukit/libmisc/Makefile.am @@ -208,5 +208,4 @@ libxz_a_SOURCES = xz/xz/h xz/xz_crc32.c \ EXTRA_DIST += xz/README xz/COPING ## --- -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am diff --git a/cpukit/libmisc/bspcmdline/bspcmdline.h b/cpukit/libmisc/bspcmdline/bspcmdline.h deleted file mode 100644 index 51916ff26a..0000000000 --- a/cpukit/libmisc/bspcmdline/bspcmdline.h +++ /dev/null @@ -1,131 +0,0 @@ -/** - * @file rtems/bspcmdline.h - * - * @defgroup BSPCommandLine BSP Command Line Helpers - * - * @ingroup libmisc - * @brief BSP Command Line Handler - * - * This include file contains all prototypes and specifications - * related to the BSP Command Line String and associated helper - * routines. The helpers are useful for locating command line - * type arguments (e.g. --mode) and their associated right - * hand side (e.g. FAST in --mode=FAST). - */ - -/* - * COPYRIGHT (c) 1989-2009. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef __BSP_COMMAND_LINE_h -#define __BSP_COMMAND_LINE_h - -/** - * @defgroup BSPCommandLine BSP Command Line Helpers - * - * The BSP Command Line Handler provides a set of routines which assist - * in examining and decoding the Command Line String passed to the BSP - * at boot time. - */ -/**@{*/ - -#include /* for size_t */ - -#ifdef __cplusplus -extern "C" { -#endif - - -/** - * @brief Obtain Pointer to BSP Boot Command String - * - * This method returns a pointer to the BSP Boot Command String. It - * is as likely to be NULL as point to a string as most BSPs do not - * have a start environment that provides a boot string. - * - * @retval This method returns the pointer to the BSP Boot Command String. - */ -const char *rtems_bsp_cmdline_get(void); - -/** - * @brief Obtain COPY of the Entire Matching Argument - * - * This method searches for the argument @a name in the BSP Boot Command - * String and returns a copy of the entire string associated with it in - * @a value up to a string of @a length. This will include the argument - * and any right hand side portion of the string. For example, one might - * be returned --mode=FAST if - * searching for --mode. - * - * @param[in] name is the arugment to search for - * @param[in] value points to where the contents will - * be placed if located. - * @param[in] length is the maximum length to copy - * - * @return This method returns NULL if not found and - * @a value if found. - */ -const char *rtems_bsp_cmdline_get_param( - const char *name, - char *value, - size_t length -); - - -/** - * @brief Obtain COPY of the Right Hand Side of the Matching Argument - * - * This method searches for the argument @a name in - * the BSP Boot Command String and returns the right hand side - * associated with it in @a value up to a maximum string @a length. - * This will NOT include the argument but only any right hand side - * portion of the string. * For example, one might be returned FAST if - * searching for --mode. - * - * @param[in] name is the arugment to search for - * @param[in] value points to where the contents will - * be placed if located. - * @param[in] length is the maximum length to copy - * - * @retval This method returns NULL if not found and - * @a value if found. - */ -const char *rtems_bsp_cmdline_get_param_rhs( - const char *name, - char *value, - size_t length -); - -/** - * @brief Obtain Pointer to the Entire Matching Argument - * - * This method searches for the argument @a name in - * the BSP Boot Command String and returns a pointer to the - * entire string associated with it. This will include the - * argument and any right hand side portion of the string. - * For example, one might be returned --mode=FAST if - * searching for --mode. - * - * @param[in] name is the arugment to search for - * - * @retval This method returns NULL if not found and a pointer - * into the BSP Boot Command String if found. - * - * @note The pointer will be to the original BSP Command - * Line string. Exercise caution when using this. - */ -const char *rtems_bsp_cmdline_get_param_raw( - const char *name -); - -#ifdef __cplusplus -} -#endif - -/**@}*/ -#endif diff --git a/cpukit/libmisc/capture/capture-cli.h b/cpukit/libmisc/capture/capture-cli.h deleted file mode 100644 index 55749b7cb1..0000000000 --- a/cpukit/libmisc/capture/capture-cli.h +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @file rtems/capture-cli.h - * - * This is the Target Interface Command Line Interface. You need - * start the RTEMS monitor. - */ - -/* - ------------------------------------------------------------------------ - - Copyright 2002, 2016 Chris Johns . - All rights reserved. - - COPYRIGHT (c) 1989-2014. - On-Line Applications Research Corporation (OAR). - - The license and distribution terms for this file may be - found in the file LICENSE in this distribution. - - This software with is provided ``as is'' and with NO WARRANTY. - - ------------------------------------------------------------------------ - - RTEMS Performance Monitoring and Measurement Framework. - - This is the Target Interface Command Line Interface. You need - start the RTEMS monitor. - -*/ - -#ifndef __CAPTURE_CLI_H_ -#define __CAPTURE_CLI_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/** - * rtems_capture_cli_init - * - * This function initialises the command line interface to the capture - * engine. - */ -rtems_status_code -rtems_capture_cli_init (rtems_capture_timestamp timestamp); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/libmisc/capture/capture.h b/cpukit/libmisc/capture/capture.h deleted file mode 100644 index f847ee0424..0000000000 --- a/cpukit/libmisc/capture/capture.h +++ /dev/null @@ -1,1122 +0,0 @@ -/** - * @file rtems/capture.h - * - * @brief Capture Engine Component of the RTEMS Measurement and - * Monitoring System - * - * This is the Capture Engine component of the RTEMS Measurement and - * Monitoring system. - */ - -/* - ------------------------------------------------------------------------ - - Copyright 2002, 2016 Chris Johns . - All rights reserved. - - COPYRIGHT (c) 1989-2014 - On-Line Applications Research Corporation (OAR). - - The license and distribution terms for this file may be - found in the file LICENSE in this distribution. - - This software with is provided ``as is'' and with NO WARRANTY. - - ------------------------------------------------------------------------ - - RTEMS Performance Monitoring and Measurement Framework. - This is the Capture Engine component. - -*/ - -#ifndef __CAPTURE_H_ -#define __CAPTURE_H_ - -#include -#include -#include - -/** - * @defgroup libmisc_capture RTEMS Capture Engine - * - * @ingroup libmisc - * - * Capture Engine Component of the RTEMS Measurement and Monitoring System - */ -/**@{*/ -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Global capture flags. - */ -#define RTEMS_CAPTURE_INIT (1u << 0) -#define RTEMS_CAPTURE_ON (1U << 1) -#define RTEMS_CAPTURE_NO_MEMORY (1U << 2) -#define RTEMS_CAPTURE_TRIGGERED (1U << 3) -#define RTEMS_CAPTURE_GLOBAL_WATCH (1U << 4) -#define RTEMS_CAPTURE_ONLY_MONITOR (1U << 5) - -/* - * Per-CPU capture flags. - */ -#define RTEMS_CAPTURE_OVERFLOW (1U << 0) -#define RTEMS_CAPTURE_READER_ACTIVE (1U << 1) -#define RTEMS_CAPTURE_READER_WAITING (1U << 2) - -/** - * The number of tasks in a trigger group. - */ -#define RTEMS_CAPTURE_TRIGGER_TASKS (32) - -/** - * @brief A capture timestamp. - * - * This is a nanosecond capture timestamp - */ -typedef uint64_t rtems_capture_time; - -/** - * @brief Task id and mask for the from trigger. - * - * A from capture is a task id and a mask for the type of - * from trigger we are interested in. The mask uses the same - * bit maps as the flags field in the control structure. There - * will only be a from type trigger if the flags in the control - * structure has the specific *_BY bit set. - */ -typedef struct rtems_capture_from -{ - rtems_name name; - rtems_id id; - uint32_t trigger; -} rtems_capture_from; - -/** - * @brief Capture control structure for a group of tasks. - * - * RTEMS control holds the trigger and watch configuration for a group of - * tasks with the same name. The flags hold global control flags. - * - * The to_triggers fields holds triggers TO this task. The from_triggers holds - * triggers from this task. The by_triggers is an OR or triggers which are - * caused BY the task listed TO this task. The by_valid flag which entries - * in by are valid. - */ -typedef struct rtems_capture_control -{ - rtems_name name; - rtems_id id; - uint32_t flags; - uint32_t to_triggers; - uint32_t from_triggers; - uint32_t by_triggers; - uint32_t by_valid; - rtems_capture_from by[RTEMS_CAPTURE_TRIGGER_TASKS]; - struct rtems_capture_control* next; -} rtems_capture_control; - -/** - * The from_valid mask. - */ -#define RTEMS_CAPTURE_CONTROL_FROM_MASK(_s) \ - (UINT32_C(1) << (RTEMS_CAPTURE_TRIGGER_TASKS - ((_s) + 1))) - -/** - * Control flags. - */ -#define RTEMS_CAPTURE_WATCH (1U << 0) - -/** - * Control triggers. - */ -#define RTEMS_CAPTURE_SWITCH (1 << 0) -#define RTEMS_CAPTURE_CREATE (1 << 1) -#define RTEMS_CAPTURE_START (1 << 2) -#define RTEMS_CAPTURE_RESTART (1 << 3) -#define RTEMS_CAPTURE_DELETE (1 << 4) -#define RTEMS_CAPTURE_BEGIN (1 << 5) -#define RTEMS_CAPTURE_EXITTED (1 << 6) -#define RTEMS_CAPTURE_TERMINATED (1 << 7) - -#define RTEMS_CAPTURE_FROM_TRIGS (RTEMS_CAPTURE_SWITCH | \ - RTEMS_CAPTURE_CREATE | \ - RTEMS_CAPTURE_START | \ - RTEMS_CAPTURE_RESTART | \ - RTEMS_CAPTURE_DELETE) - -#define RTEMS_CAPTURE_TO_TRIGS (RTEMS_CAPTURE_SWITCH | \ - RTEMS_CAPTURE_CREATE | \ - RTEMS_CAPTURE_START | \ - RTEMS_CAPTURE_RESTART | \ - RTEMS_CAPTURE_DELETE | \ - RTEMS_CAPTURE_BEGIN | \ - RTEMS_CAPTURE_EXITTED) - -/** - * Task flags. - */ -#define RTEMS_CAPTURE_TRACED (1U << 0) -#define RTEMS_CAPTURE_INIT_TASK (1U << 1) -#define RTEMS_CAPTURE_RECORD_TASK (1U << 2) - -/* - * @brief Capture record. - * - * This is a record that is written into - * the buffer. The events includes the priority of the task - * at the time of the context switch. - */ -typedef struct rtems_capture_record -{ - size_t size; - uint32_t events; - rtems_id task_id; - rtems_capture_time time; -} RTEMS_PACKED rtems_capture_record; - -/* - * @brief Capture task record. - * - * This is a record that is written into - * the buffer. The events includes the priority of the task - * at the time of the context switch. - */ -typedef struct rtems_capture_task_record -{ - rtems_name name; - rtems_task_priority start_priority; - uint32_t stack_size; -} RTEMS_PACKED rtems_capture_task_record; - -/** - * The capture record event flags. - */ -#define RTEMS_CAPTURE_REAL_PRI_EVENT_MASK UINT32_C (0x000000ff) -#define RTEMS_CAPTURE_CURR_PRI_EVENT_MASK UINT32_C (0x0000ff00) -#define RTEMS_CAPTURE_REAL_PRIORITY_EVENT (0) -#define RTEMS_CAPTURE_CURR_PRIORITY_EVENT (8) -#define RTEMS_CAPTURE_EVENT_START (16) -#define RTEMS_CAPTURE_CREATED_BY_EVENT UINT32_C (0x00010000) -#define RTEMS_CAPTURE_CREATED_EVENT UINT32_C (0x00020000) -#define RTEMS_CAPTURE_STARTED_BY_EVENT UINT32_C (0x00040000) -#define RTEMS_CAPTURE_STARTED_EVENT UINT32_C (0x00080000) -#define RTEMS_CAPTURE_RESTARTED_BY_EVENT UINT32_C (0x00100000) -#define RTEMS_CAPTURE_RESTARTED_EVENT UINT32_C (0x00200000) -#define RTEMS_CAPTURE_DELETED_BY_EVENT UINT32_C (0x00400000) -#define RTEMS_CAPTURE_DELETED_EVENT UINT32_C (0x00800000) -#define RTEMS_CAPTURE_TERMINATED_EVENT UINT32_C (0x01000000) -#define RTEMS_CAPTURE_BEGIN_EVENT UINT32_C (0x02000000) -#define RTEMS_CAPTURE_EXITTED_EVENT UINT32_C (0x04000000) -#define RTEMS_CAPTURE_SWITCHED_OUT_EVENT UINT32_C (0x08000000) -#define RTEMS_CAPTURE_SWITCHED_IN_EVENT UINT32_C (0x10000000) -#define RTEMS_CAPTURE_TIMESTAMP UINT32_C (0x20000000) -#define RTEMS_CAPTURE_EVENT_END (29) - -/** - * @brief Capture trigger modes - * - * The types of trigger modes that exist. - */ -typedef enum rtems_capture_trigger_mode -{ - rtems_capture_to_any, - rtems_capture_from_any, - rtems_capture_from_to -} rtems_capture_trigger_mode; - -/** - * @brief Capture trigger. - * - * The types of triggers that exist. - */ -typedef enum rtems_capture_trigger -{ - rtems_capture_switch, - rtems_capture_create, - rtems_capture_start, - rtems_capture_restart, - rtems_capture_delete, - rtems_capture_begin, - rtems_capture_exitted, - rtems_capture_terminated -} rtems_capture_trigger; - -/** - * @brief Capture timestamp callout handler. - * - * This defines the callout handler to obtain a time stamp. The - * value returned is time count since the last read. - * - */ - -typedef void (*rtems_capture_timestamp)(rtems_capture_time* time); - -/** - * @brief Capture record lock context. - * - * This structure is used to lock a per CPU buffer when opeining recording. The - * per CPU buffer is held locked until the record close is called. Locking - * masks interrupts so use this lock only when needed and do not hold it for - * long. - * - * The lock first masks the CPU interrupt before taking the interrupt - * lock. This stops a thread context taking the lock and then an interrupt on - * the same CPU attempting to take the lock so creating a deadlock. - * - */ -typedef struct { - rtems_interrupt_lock_context lock_context; - rtems_interrupt_lock* lock; -} rtems_capture_record_lock_context; - -/** - * @brief Capture open - * - * This function initialises the realtime trace manager allocating the - * capture buffer. It is assumed we have a working heap at stage of - * initialisation. - * - * @param[in] size The number of capture records to define. - * @param[in] timestamp The timestamp callout handler to use. If the - * the handler is NULL a default nano-second timestamp - * will be used. - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - */ -rtems_status_code rtems_capture_open (uint32_t size, - rtems_capture_timestamp timestamp); - -/** - * @brief Capture close - * - * This function shutdowns the tracer and release any claimed - * resources. - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - */ -rtems_status_code rtems_capture_close (void); - -/** - * @brief Capture control trace enable/disable. - * - * This function allows control of tracing at a global level. - * - * @param[in] enable The trace enable/disable flag. - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - */ -rtems_status_code rtems_capture_set_control (bool enable); - -/** - * @brief Capture monitor enable/disable. - * - * This function enable the monitor mode. When in the monitor mode - * the tasks are monitored but no data is saved. This can be used - * to profile the load on a system. - * - * @param[in] enable The monitor enable/disable flag. - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - */ -rtems_status_code rtems_capture_set_monitor (bool enable); - -/* - * @brief Capture flush trace buffer. - * - * This function flushes the trace buffer. The prime parameter allows the - * capture engine to also be primed again. - * - * @param[in] prime The prime after flush flag. - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - */ -rtems_status_code rtems_capture_flush (bool prime); - -/** - * @brief Capture add watch - * - * This function defines a watch for a specific task given a name. A watch - * causes it to be traced either in or out of context. The watch can be - * optionally enabled or disabled with the set routine. It is disabled by - * default. - * - * @param[in] name The name of the @a capture_controls entry - * @param[in] id The id of the @a capture_controls entry. - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - */ -rtems_status_code rtems_capture_watch_add (rtems_name name, rtems_id id); - -/** - * @brief Capture delete watch. - * - * This function removes a watch for a specific task given a name. The task - * description will still exist if referenced by a trace record in the trace - * buffer or a global watch is defined. - * - * @param[in] name The name of the @a capture_controls entry - * @param[in] id The id of the @a capture_controls entry. - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - */ -rtems_status_code rtems_capture_watch_del (rtems_name name, rtems_id id); - -/** - * @brief Capture enable/disable watch. - * - * This function allows control of a watch. The watch can be enabled or - * disabled. - * - * @param[in] name The name of the @a capture_controls entry - * @param[in] id The id of the @a capture_controls entry. - * @param[in] enable The enable/disable flag for the watch. - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - */ -rtems_status_code rtems_capture_watch_ctrl (rtems_name name, - rtems_id id, - bool enable); - -/** - * @brief Capture enable/disable global watch. - * - * This function allows control of a global watch. The watch can - * be enabled or disabled. A global watch configures all tasks below - * the ceiling and above the floor to be traced. - * - * @param[in] enable The enable/disable flag for the watch. - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - */ -rtems_status_code rtems_capture_watch_global (bool enable); - -/** - * @brief Get global watch state - * - * This function returns the global watch state. - * - * @retval This method returns true if the global watch - * is on. Otherwise, it returns false. - */ -bool rtems_capture_watch_global_on (void); - -/** - * @brief Set watch ceiling. - * - * This function sets a watch ceiling. Events from tasks at or greater - * than the ceiling priority are ignored. This is a simple way to - * monitor an application and exclude system tasks running at a higher - * priority level. - * - * @param[in] ceiling specifies the priority level immediately above - * that at which events from tasks are not captured. - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - */ -rtems_status_code rtems_capture_watch_ceiling (rtems_task_priority ceiling); - -/** - * @brief Get watch ceiling. - * - * This function gets the watch ceiling. - * - * @retval The priority level immediately above that at which events - * from tasks are not captured. - */ -rtems_task_priority rtems_capture_watch_get_ceiling (void); - -/** - * @brief Capture set watch floor. - * - * This function sets a watch floor. Tasks at or less than the - * floor priority are not watched. This is a simple way to monitor - * an application and exclude system tasks running at a lower - * priority level. - * - * @param[in] floor specifies the priority level immediately below - * that at which events from tasks are not captured. - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - */ -rtems_status_code rtems_capture_watch_floor (rtems_task_priority floor); - -/** - * @brief Capture set watch floor - * - * This function gets the watch floor. - * - * @retval The priority level immediately below - * that at which events from tasks are not captured. - */ -rtems_task_priority rtems_capture_watch_get_floor (void); - -/** - * @brief Capture set trigger - * - * This function sets a trigger. - * - * This set trigger routine will create a trace control for the - * target task. The task list is searched and any existing tasks - * are linked to the new control. - * - * We can have a number of tasks that have the same name so we - * search using names. This means a number of tasks can be - * linked to single control. - * - * Some events captured such as context switch include two - * tasks. These are referred to as being "from" and "to" - * Some events may only have one task specified. - * - * @param[in] from_name specifies the name of the from task. - * @param[in] from_id specifies the id of the from task. - * @param[in] to_name specifies the name of the to task. - * @param[in] to_id specifies the id of the to task. - * @param[in] mode specifies the trigger mode. - * @param[in] trigger specifies the type of trigger. - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - */ -rtems_status_code -rtems_capture_set_trigger (rtems_name from_name, - rtems_id from_id, - rtems_name to_name, - rtems_id to_id, - rtems_capture_trigger_mode mode, - rtems_capture_trigger trigger); - -/** - * @brief Capture clear trigger. - * - * This function clears a trigger. - * - * This clear trigger routine will not clear a watch. - * - * @param[in] from_name specifies the name of the from task. - * @param[in] from_id specifies the id of the from task. - * @param[in] to_name specifies the name of the to task. - * @param[in] to_id specifies the id of the to task. - * @param[in] mode specifies the trigger mode. - * @param[in] trigger specifies the type of trigger. - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - */ -rtems_status_code -rtems_capture_clear_trigger (rtems_name from_name, - rtems_id from_id, - rtems_name to_name, - rtems_id to_id, - rtems_capture_trigger_mode mode, - rtems_capture_trigger trigger); - -/** - * @brief Capture read records from capture buffer - * - * This function reads a number of records from the capture buffer. - * - * The function returns the number of record that is has that are - * in a continous block of memory. If the number of available records - * wrap then only those records are provided. This removes the need for - * caller to be concerned about buffer wrappings. If the number of - * requested records cannot be met due to the wrapping of the records - * less than the specified number will be returned. - * - * The user must release the records. This is achieved with a call to - * rtems_capture_release. Calls this function without a release will - * result in at least the same number of records being released. - * - * @param[in] cpu The cpu number that the records were recorded on - * @param[out] read will contain the number of records read - * @param[out] recs The capture records that are read. - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - */ -rtems_status_code rtems_capture_read (uint32_t cpu, - size_t* read, - const void** recs); - -/** - * @brief Capture release records. - * - * This function releases the requested number of record slots back - * to the capture engine. The count must match the number read. - * - * @param[in] count The number of record slots to release - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - */ -rtems_status_code rtems_capture_release (uint32_t cpu, uint32_t count); - -/** - * @brief Capture filter - * - * This function this function specifies if the given task and events should be - * logged. - * - * @param[in] task specifies the capture task control block - * @param[in] events specifies the events - * - * @retval This method returns true if this data should be filtered from the - * log. It returns false if this data should be logged. - */ -bool rtems_capture_filter (rtems_tcb* task, uint32_t events); - -/** - * @brief Capture returns the current time. - * - * This function returns the current time. If a handler is provided - * by the user the time is gotten from that. - * - * @param[in] time specifies the capture time - * - * @retval This method returns a nano-second time if no user handler - * is provided. Otherwise, it returns a resolution defined by the handler. - */ -void rtems_capture_get_time (rtems_capture_time* time); - -/** - * @brief Capture get event text. - * - * This function returns a string for an event based on the bit in the - * event. The functions takes the bit offset as a number not the bit - * set in a bit map. - * - * @param[in] event specifies the event to describe - * - * @retval This method returns a string description of the given event. - */ -const char* rtems_capture_event_text (int event); - -/** - * @brief Capture initialize task - * - * This function initializes capture control in the tcb. - * - * @param[in] tcb is the task control block for the task - */ -void rtems_capture_initialize_task (rtems_tcb* tcb); - -/** - * @brief Capture record task. - * - * This function records a new capture task record. - * - * @param[in] tcb is the task control block for the task - */ -void rtems_capture_record_task (rtems_tcb* tcb); - -/** - * @brief Capture record lock. - * - * This does a lock acquire which will remain in effect until - * rtems_capture_record_unlock is called. - * - * @param[out] context specifies the record context - */ -void rtems_capture_record_lock (rtems_capture_record_lock_context* context); - -/** - * @brief Capture record unlock. - * - * This unlocks the record lock. - * - * @param[in] context specifies the record context - */ -void rtems_capture_record_unlock (rtems_capture_record_lock_context* context); - -/** - * @brief Capture record open. - * - * This function allocates a record and fills in the header information. It - * does a lock acquire which will remain in effect until - * rtems_capture_record_close is called. The size is the amount of user data - * being recorded. The record header is internally managed. - * - * @param[in] task specifies the caputre task block - * @param[in] events specifies the events - * @param[in] size specifies the user's capture data size - * @param[out] context specifies the record context - * - * @retval This method returns a pointer to the next location in - * the capture record to store data. - */ -void* rtems_capture_record_open (rtems_tcb* task, - uint32_t events, - size_t size, - rtems_capture_record_lock_context* context); - -/** - * @brief Capture record close. - * - * This function closes writing to capure record and releases the lock that was - * held on the per CPU buffer. - * - * @param[out] context specifies the record context - */ -void rtems_capture_record_close (rtems_capture_record_lock_context* context); - -/** - * @brief Capture append to record to the per CPU buffer. - * - * This function appends data of a specifed size into a capture buffer. - * - * @param[in] rec specifies the next write point in the capture record - * @param[in] data specifies the data to write - * @param[in] size specifies the size of the data - * - * @retval This method returns the next write point in the capture record. - */ -static inline void* -rtems_capture_record_append (void* rec, const void* data, size_t size) -{ - memcpy (rec, data, size); - return ((uint8_t*) rec) + size; -} - -/** - * @brief Capture read a record from the per CPU buffer. - * - * This function reads data of a specifed size from a capture buffer. - * - * @param[in] rec specifies the next read point in the capture record - * @param[in] data specifies where to write the data - * @param[in] size specifies the size of the data - * - * @retval This method returns the next write point in the capture record. - */ -static inline void* -rtems_capture_record_extract (const void* rec, void* data, size_t size) -{ - memcpy (data, rec, size); - return ((uint8_t*) rec) + size; -} - -/** - * @brief Capture task recorded - * - * This function returns true if this task information has been - * recorded. - * - * @param[in] tcb is the task control block for the task - */ -static inline bool rtems_capture_task_recorded (rtems_tcb* tcb) { - return ((tcb->Capture.flags & RTEMS_CAPTURE_RECORD_TASK) != 0); -} - -/** - * @brief Capture task initialized - * - * This function returns true if this task information has been - * initialized. - * - * @param[in] tcb is the task control block for the task - */ -static inline bool rtems_capture_task_initialized (rtems_tcb* tcb) { - return ((tcb->Capture.flags & RTEMS_CAPTURE_INIT_TASK) != 0); -} - -/** - * @brief Capture get task id. - * - * This function returns the task id. - * - * @param[in] task The capture task. - * - * @retval This function returns the task id. - */ -static inline rtems_id -rtems_capture_task_id (rtems_tcb* tcb) -{ - return tcb->Object.id; -} - -/** - * @brief Capture get task API. - * - * This function returns the task API as an int. - * - * @param[in] task The capture task. - * - * @retval This function returns the task API as an int. - */ -static inline int -rtems_capture_task_api (rtems_id id) -{ - return _Objects_Get_API (id); -} - -/** - * @brief Capture get task state. - * - * This function returns the task state. - * - * @param[in] task The capture task. - * - * @retval This function returns the task state. - */ -static inline States_Control -rtems_capture_task_state (rtems_tcb* tcb) -{ - if (tcb) - return tcb->current_state; - return 0; -} - -/** - * @brief Capture get task name. - * - * This function returns the task name. - * - * @param[in] task The capture task. - * - * @retval This function returns the task name. - */ -static inline rtems_name -rtems_capture_task_name (rtems_tcb* tcb) -{ - rtems_name name; - rtems_object_get_classic_name( tcb->Object.id, &name ); - return name; -} - -/** - * @brief Capture get task flags. - * - * This function returns the task flags. - * - * @param[in] task The capture task. - * - * @retval This function returns the task flags. - */ -static inline uint32_t -rtems_capture_task_flags (rtems_tcb* tcb) -{ - return tcb->Capture.flags; -} - -/** - * @brief Capture get task control - * - * This function returns the task control if present. - * - * @param[in] task The capture task. - * - * @retval This function returns the task control if present. - */ -static inline rtems_capture_control* -rtems_capture_task_control (rtems_tcb* tcb) -{ - return tcb->Capture.control; -} - -/** - * @brief Capture get task control flags. - * - * This function returns the task control flags if a control is present. - * - * @param[in] task The capture task. - * - * @retval This function returns the task control flags if a control is present. - */ -static inline uint32_t -rtems_capture_task_control_flags (rtems_tcb* tcb) -{ - rtems_capture_control* control = tcb->Capture.control; - if (!control) - return 0; - return control->flags; -} - -/** - * @brief Capture get task start priority. - * - * This function returns the tasks start priority. The tracer needs this - * to track where the task's priority goes. - * - * @param[in] task The capture task. - * - * @retval This function returns the tasks start priority. The tracer needs this - * to track where the task's priority goes. - */ -static inline rtems_task_priority -rtems_capture_task_start_priority (rtems_tcb* tcb) -{ - return _RTEMS_Priority_From_core (_Thread_Scheduler_get_home( tcb ), - tcb->Start.initial_priority); -} - -/** - * @brief Capture get task real priority. - * - * This function returns the tasks real priority. - * - * @param[in] task The capture task. - * - * @retval This function returns the tasks real priority. - */ -static inline rtems_task_priority -rtems_capture_task_real_priority (rtems_tcb* tcb) -{ - return tcb->Real_priority.priority; -} - -/** - * @brief Capture get task current priority. - * - * This function returns the tasks current priority. - * - * @param[in] task The capture task. - * - * @retval This function returns the tasks current priority. - */ -static inline rtems_task_priority -rtems_capture_task_curr_priority (rtems_tcb* tcb) -{ - return _Thread_Get_priority (tcb); -} - -/** - * @brief Capture get control list. - * - * This function returns the head of the list of controls in the - * capture engine. - * - * @retval This function returns the head of the list of controls in the - * capture engine. - */ -rtems_capture_control* -rtems_capture_get_control_list (void); - -/** - * @brief Capture get next capture control. - * - * This function returns the pointer to the next control in the list. The - * pointer NULL terminates the list. - * - * @param[in] control the current capture control. - * - * @retval This function returns the pointer to the next control in the list. The - * pointer NULL terminates the list. - */ -static inline rtems_capture_control* -rtems_capture_next_control (rtems_capture_control* control) -{ - return control->next; -} - -/** - * @brief Capture get capture control id. - * - * This function returns the control id. - * - * @param[in] control the capture control. - * - * @retval This function returns the control id. - */ -static inline rtems_id -rtems_capture_control_id (rtems_capture_control* control) -{ - return control->id; -} - -/** - * @brief Capture get capture control name. - * - * This function returns the control name. - * - * @param[in] control the capture control. - * - * @retval This function returns the control name. - */ -static inline rtems_name -rtems_capture_control_name (rtems_capture_control* control) -{ - return control->name; -} - -/** - * @brief Capture get capture control flags. - * - * This function returns the control flags. - * - * @param[in] control the capture control. - * - * @retval This function returns the control flags. - */ -static inline uint32_t -rtems_capture_control_flags (rtems_capture_control* control) -{ - return control->flags; -} - -/** - * @brief Capture get capture control to triggers. - * - * This function returns the task control to triggers. - * - * @param[in] control the capture control. - * - * @retval This function returns the task control to triggers. - */ -static inline uint32_t -rtems_capture_control_to_triggers (rtems_capture_control* control) -{ - return control->to_triggers; -} - -/** - * @brief Capture get capture control from triggers. - * - * This function returns the task control from triggers. - * - * @param[in] control the capture control. - * - * @retval This function returns the task control from triggers. - */ -static inline uint32_t -rtems_capture_control_from_triggers (rtems_capture_control* control) -{ - return control->from_triggers; -} - -/** - * @brief Capture get capture control by triggers. - * - * This function returns the task control by triggers. - * - * @param[in] control the capture control. - * - * @retval This function returns the task control by triggers. - */ -static inline uint32_t -rtems_capture_control_all_by_triggers (rtems_capture_control* control) -{ - return control->by_triggers; -} - -/** - * @brief Capture get capture control valid by flags. - * - * This function returns the control valid BY flags. - * - * @param[in] control The capture control. - * @param[in] slot The slot. - * - * @retval This function returns the control valid BY flags. - */ -static inline int -rtems_capture_control_by_valid (rtems_capture_control* control, int slot) -{ - return control->by_valid & RTEMS_CAPTURE_CONTROL_FROM_MASK (slot); -} - -/** - * @brief Capture get capture control by task name. - * - * This function returns the control @a by task name. - * - * @param[in] control The capture control. - * @param[in] by The by index. - * - * @retval This function returns the control @a by task name. - */ -static inline rtems_name -rtems_capture_control_by_name (rtems_capture_control* control, int by) -{ - if (by < RTEMS_CAPTURE_TRIGGER_TASKS) - return control->by[by].name; - return control->by[0].name; -} - -/** - * @brief Capture get capture control by task id. - * - * This function returns the control @a by task id - * - * @retval This function returns the control @a by task id. - */ -static inline rtems_id -rtems_capture_control_by_id (rtems_capture_control* control, int by) -{ - if (by < RTEMS_CAPTURE_TRIGGER_TASKS) - return control->by[by].id; - return control->by[0].id; -} - -/** - * @brief Capture get capture control by task triggers. - * - * This function returns the control @a by task triggers. - * - * @retval This function returns the control @a by task triggers. - */ -static inline uint32_t -rtems_capture_control_by_triggers (rtems_capture_control* control, - int by) -{ - if (by < RTEMS_CAPTURE_TRIGGER_TASKS) - return control->by[by].trigger; - return control->by[0].trigger; -} - -/** - * @brief Capture get capture control count. - * - * This function returns the number of controls the capture - * engine has. - * - * @retval This function returns the number of controls the capture - * engine has. - */ -static inline uint32_t -rtems_capture_control_count (void) -{ - rtems_capture_control* control = rtems_capture_get_control_list (); - uint32_t count = 0; - - while (control) - { - count++; - control = rtems_capture_next_control (control); - } - - return count; -} - -#ifdef __cplusplus -} -#endif -/**@}*/ - -#endif diff --git a/cpukit/libmisc/capture/captureimpl.h b/cpukit/libmisc/capture/captureimpl.h deleted file mode 100644 index 4c4cbe66c3..0000000000 --- a/cpukit/libmisc/capture/captureimpl.h +++ /dev/null @@ -1,185 +0,0 @@ -/** - * @file rtems/captureimpl.h - * - * @brief Capture Implementation file - * - * This file contains an interface between the capture engine and - * capture user extension methods. - */ - -/* - ------------------------------------------------------------------------ - - Copyright 2002, 2016 Chris Johns . - All rights reserved. - - COPYRIGHT (c) 1989-2014. - On-Line Applications Research Corporation (OAR). - - The license and distribution terms for this file may be - found in the file LICENSE in this distribution. - - This software with is provided ``as is'' and with NO WARRANTY. - - ------------------------------------------------------------------------ - - RTEMS Performance Monitoring and Measurement Framework. - This is the Capture Engine component. - -*/ - -#ifndef __CAPTUREIMPL_H_ -#define __CAPTUREIMPL_H_ - -#include "capture.h" - -/**@{*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Capture set extension index. - * - * This function is used to set the extension index - * for the capture engine. - * - * @param[in] index specifies the extension index to be - * used for capture engine data. - */ -void rtems_capture_set_extension_index(int index); - -/** - * @brief Capture get extension index. - * - * This function rturns the extension index for the - * capture engine. - * - * @retval This method returns the extension index. - */ -int rtems_capture_get_extension_index(void); - -/** - * @brief Capture get flags. - * - * This function gets the current flag settings - * for the capture engine. - * - * @retval This method returns the global capture - * flags. - * - */ -uint32_t rtems_capture_get_flags(void); - -/** - * @brief Capture set flags. - * - * This function sets a flag in the capture engine - * - * @param[in] mask specifies the flag to set - */ -void rtems_capture_set_flags(uint32_t mask); - -/** - * @brief Capture user extension open. - * - * This function creates the capture user extensions. - * - * - * @retval This method returns RTEMS_SUCCESSFUL upon successful - * creation of the user extensions. - */ -rtems_status_code rtems_capture_user_extension_open(void); - -/** - * @brief Capture user extension close. - * - * This function closes the capture user extensions. - * - * @retval This method returns RTEMS_SUCCESSFUL upon a successful - * delete of the user extensions. - */ -rtems_status_code rtems_capture_user_extension_close(void); - -/** - * @brief Capture check trigger. - * - * This function checks if we have triggered or if this event is a - * cause of a trigger. - * - * @param[in] ft specifies specifices the capture from task - * @param[in] tt specifies specifices the capture to task - * @param[in] events specifies the events - * - * @retval This method returns true if we have triggered or - * if the event is a cause of a trigger. - */ -bool rtems_capture_trigger_fired (rtems_tcb* ft, - rtems_tcb* tt, - uint32_t events); - -/** - * @brief Capture print trace records. - * - * This function reads, prints and releases up to - * total trace records in either a csv format or an - * ascii table format. - * - * @param[in] total specifies the number of records to print - * @param[in] csv specifies a comma seperated value format - */ -void rtems_capture_print_trace_records ( int total, bool csv ); - -/** - * @brief Capture print timestamp. - * - * This function prints uptime in a timestamp format. - * - * @param[in] uptime specifies the timestamp to print - */ -void rtems_capture_print_timestamp (uint64_t uptime); - -/** - * @brief Capture print record task. - * - * This function prints a capture record task. This - * record contains information to identify a task. It - * is refrenced in other records by the task id. - * - * @param[in] cpu specifies the cpu the cpu the record was logged on. - * @param[in] rec specifies the task record. - */ -void rtems_capture_print_record_task(int cpu, - const rtems_capture_record* rec, - const rtems_capture_task_record* task_rec); - -/** - * @brief Capture print capture record. - * - * This function prints a user extension - * capture record. - * - * @param[in] cpu specifies the cpu the cpu the record was logged on. - * @param[in] rec specifies the record. - * @param[in] diff specifies the time between this and the last capture record. - * @param[in] name specifies the name of the task, NULL if none. - * @param[in] task_count number of tasks to search for. - */ -void rtems_capture_print_record_capture(int cpu, - const rtems_capture_record* rec, - uint64_t diff, - const rtems_name* name); - -/** - * @brief Capture print watch list - * - * This function prints a capture watch list - */ -void rtems_capture_print_watch_list (void); - -#ifdef __cplusplus -} -#endif -/**@}*/ - -#endif diff --git a/cpukit/libmisc/capture/rtems-trace-buffer-vars.h b/cpukit/libmisc/capture/rtems-trace-buffer-vars.h deleted file mode 100644 index 8f0ff08587..0000000000 --- a/cpukit/libmisc/capture/rtems-trace-buffer-vars.h +++ /dev/null @@ -1,148 +0,0 @@ -/** - * @file - * - * @ingroup Shell - * - * @brief Access to the RTEMS Trace Buffer Generator (TBG). - */ -/* - * Copyright (c) 2015 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if !defined (_RTEMS_TRACE_BUFFER_VARS_H_) -#define _RTEMS_TRACE_BUFFER_VARS_H_ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * These functions are provided as a separated interface to the Trace Buffer - * Generatror (TBG) data are not really designed for any real-time performance - * type interface. - * - * Separating the data from the codes stops the compiler incorrectly loop - * optimising. - */ - -typedef struct -{ - uint32_t size; - const char* const type; -} __rtld_trace_sig_arg; - - typedef struct { - uint32_t argc; - const __rtld_trace_sig_arg* args; -} __rtld_trace_sig; - -typedef __rtld_trace_sig_arg rtems_trace_sig_arg; -typedef __rtld_trace_sig rtems_trace_sig; - -/** - * Returns the number of trace functions. - */ -uint32_t rtems_trace_names_size (void); - -/** - * Return the name given an index. No range checking. - */ -const char* rtems_trace_names (const uint32_t index); - -/** - * Returns the number of words in the enables array. - */ -uint32_t rtems_trace_enables_size (void); - -/** - * Return the enable 32bit bitmap indexed into the enables array. No range - * checking. - */ -uint32_t rtems_trace_enables (const uint32_t index); - -/** - * Returns the number of words in the triggers array. - */ -uint32_t rtems_trace_triggers_size (void); - -/** - * Return the trigger 32bit bitmap indexed into the triggers array. No range - * checking. - */ -uint32_t rtems_trace_triggers (const uint32_t index); - -/** - * Return the trace function signature. - */ -const rtems_trace_sig* rtems_trace_signatures (const uint32_t index); - -/** - * Return true is the enable bit is set for the trace function index. - */ -bool rtems_trace_enable_set(const uint32_t index); - -/** - * Return true is the trigger bit is set for the trace function index. - */ -bool rtems_trace_trigger_set(const uint32_t index); - -/** - * The application has been linked with Trace Buffering generated code. - */ -bool rtems_trace_buffering_present (void); - -/** - * Return the trace buffering mode flags. - */ -uint32_t rtems_trace_buffering_mode (void); - -/** - * Return the size of the trace buffering buffer in words. - */ -uint32_t rtems_trace_buffering_buffer_size (void); - -/** - * Return the base of the trace buffering buffer. - */ -uint32_t* rtems_trace_buffering_buffer (void); - -/** - * Return the buffer level. This is only stable if tracing has finished. - */ -uint32_t rtems_trace_buffering_buffer_in (void); - -/** - * The tracing has finished. - */ -bool rtems_trace_buffering_finished (void); - -/** - * Trace has been triggered and enable trace functions are being recorded. - */ -bool rtems_trace_buffering_triggered (void); - -/** - * Start tracing by clearing the triggered flag, setting to 0 and clearing the - * finished flag. - */ -void rtems_trace_buffering_start (void); - -/** - * Stop tracing by setting the finished flag. - */ -void rtems_trace_buffering_stop (void); - -/** - * Resume tracing by setting the finished flag. - */ -void rtems_trace_buffering_resume (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/cpukit/libmisc/cpuuse/cpuuse.h b/cpukit/libmisc/cpuuse/cpuuse.h deleted file mode 100644 index 23f58faf1b..0000000000 --- a/cpukit/libmisc/cpuuse/cpuuse.h +++ /dev/null @@ -1,88 +0,0 @@ -/** - * @file rtems/cpuuse.h - * - * @defgroup libmisc_cpuuse CPU Usage - * - * @ingroup libmisc - * @brief CPU Usage Report - * - * This include file contains information necessary to utilize - * and install the cpu usage reporting mechanism. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef __RTEMS_CPUUSE_h -#define __RTEMS_CPUUSE_h - -#include -#include - -/** - * @defgroup libmisc_cpuuse CPU Usage - * - * @ingroup libmisc - */ -/**@{*/ -#ifdef __cplusplus -extern "C" { -#endif - -/* - * rtems_cpu_usage_report_with_handler - */ - -void rtems_cpu_usage_report_with_plugin( const rtems_printer *printer ); - -/** - * @brief Report CPU usage. - * - * CPU Usage Reporter - */ - -void rtems_cpu_usage_report( void ); - -/** - * @brief CPU usage Top plugin - * - * Report CPU Usage in top format to - * to a print plugin. - */ -void rtems_cpu_usage_top_with_plugin( const rtems_printer *printer ); - -/** - * @brief CPU usage top. - * - * CPU Usage top - */ - -void rtems_cpu_usage_top( void ); - -/** - * @brief Reset CPU usage. - * - * CPU Usage Reporter - */ - -void rtems_cpu_usage_reset( void ); - -/** - * @brief Reports per-processor information. - * - * @return The number of characters printed. - */ -int rtems_cpu_info_report( const rtems_printer *printer ); - -#ifdef __cplusplus -} -#endif -/**@}*/ -#endif -/* end of include file */ diff --git a/cpukit/libmisc/devnull/devnull.h b/cpukit/libmisc/devnull/devnull.h deleted file mode 100644 index 39081f478b..0000000000 --- a/cpukit/libmisc/devnull/devnull.h +++ /dev/null @@ -1,84 +0,0 @@ -/** - * @file - * - * @brief RTEMS /dev/null Device Driver - * - * This include file defines the interface to the RTEMS /dev/null - * device driver. - */ - -/* - * Author: Ralf Corsepius (corsepiu@faw.uni-ulm.de) - * - * COPYRIGHT (c) 1989-2000. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_DEVNULL_H -#define _RTEMS_DEVNULL_H - -#include - -/** - * @defgroup libmisc_devnull Null Device Driver - * - * @ingroup libmisc - */ -/**@{*/ - -#ifdef __cplusplus -extern "C" { -#endif - -#define DEVNULL_DRIVER_TABLE_ENTRY \ - { null_initialize, null_open, null_close, null_read, \ - null_write, null_control } - -#define NULL_SUCCESSFUL RTEMS_SUCCESSFUL - -rtems_device_driver null_initialize( - rtems_device_major_number, - rtems_device_minor_number, - void * -); - -rtems_device_driver null_open( - rtems_device_major_number, - rtems_device_minor_number, - void * -); - -rtems_device_driver null_close( - rtems_device_major_number, - rtems_device_minor_number, - void * -); - -rtems_device_driver null_read( - rtems_device_major_number, - rtems_device_minor_number, - void * -); - -rtems_device_driver null_write( - rtems_device_major_number, - rtems_device_minor_number, - void * -); - -rtems_device_driver null_control( - rtems_device_major_number, - rtems_device_minor_number, - void * -); - -#ifdef __cplusplus -} -#endif -/**@}*/ -#endif -/* end of include file */ diff --git a/cpukit/libmisc/devnull/devzero.h b/cpukit/libmisc/devnull/devzero.h deleted file mode 100644 index bc47d3ea09..0000000000 --- a/cpukit/libmisc/devnull/devzero.h +++ /dev/null @@ -1,92 +0,0 @@ -/** - * @file rtems/devzero.h - * - * @brief RTEMS /dev/zero Device Driver - * - * This include file defines the interface to the RTEMS /dev/zero - * device driver. - */ - -/* - * Copyright (c) 2011 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Obere Lagerstr. 30 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_DEVZERO_H -#define _RTEMS_DEVZERO_H - -#include - -/** - * @defgroup libmisc_devzero Zero Device Driver - * - * @ingroup libmisc - */ -/**@{*/ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define DEVZERO_DEVICE_NAME "/dev/zero" - -#define DEVZERO_DRIVER_TABLE_ENTRY \ - { \ - dev_zero_initialize, \ - dev_zero_open, \ - dev_zero_close, \ - dev_zero_read, \ - dev_zero_write, \ - dev_zero_control \ - } - -rtems_device_driver dev_zero_initialize( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *arg -); - -rtems_device_driver dev_zero_open( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *arg -); - -rtems_device_driver dev_zero_close( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *arg -); - -rtems_device_driver dev_zero_read( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *arg -); - -rtems_device_driver dev_zero_write( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *arg -); - -rtems_device_driver dev_zero_control( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *arg -); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ -/**@}*/ -#endif /* _RTEMS_DEVZERO_H */ diff --git a/cpukit/libmisc/dumpbuf/dumpbuf.h b/cpukit/libmisc/dumpbuf/dumpbuf.h deleted file mode 100644 index d714879ab4..0000000000 --- a/cpukit/libmisc/dumpbuf/dumpbuf.h +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @file - * - * @brief Print a Memory Buffer - * - * This file defines the interface to the RTEMS methods to print a - * memory buffer in a style similar to many ROM monitors and debuggers. - */ - -/* - * COPYRIGHT (c) 1997-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may in - * the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef __DUMP_BUFFER_h -#define __DUMP_BUFFER_h - -/** - * @defgroup libmisc_dumpbuf Print Memory Buffer - * - * @ingroup libmisc - */ -/**@{*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Print memory buffer. - * - * This method prints @a length bytes beginning at @a buffer in - * a nice format similar to what one would expect from a debugger - * or ROM monitor. - * - * @param[in] buffer is the address of the buffer - * @param[in] length is the length of the buffer - */ -void rtems_print_buffer( - const unsigned char *buffer, - int length -); - -#ifdef __cplusplus -} -#endif -/**@}*/ -#endif -/* end of include file */ diff --git a/cpukit/libmisc/fb/fb.h b/cpukit/libmisc/fb/fb.h deleted file mode 100644 index bb5cb23805..0000000000 --- a/cpukit/libmisc/fb/fb.h +++ /dev/null @@ -1,101 +0,0 @@ -/** - * @file rtems/fb.h - * - * @brief Frame Buffer Device Driver - * - * This file defines the interface to a frame buffer device driver. - */ - -/* - * Copyright (c) 2000 - Rosimildo da Silva - */ - -#ifndef _MW_FB_H -#define _MW_FB_H - -#include - -/** - * @defgroup libmisc_fb Frame Buffer Device Driver Interface - * - * @ingroup Device Drivers and Frameworks - */ -/**@{*/ - -#ifdef __cplusplus -extern "C" { -#endif - -/* ioctls - 0x46 is 'F' */ -#define FBIOGET_VSCREENINFO 0x4600 -#define FBIOPUT_VSCREENINFO 0x4601 -#define FBIOGET_FSCREENINFO 0x4602 -#define FBIOGETCMAP 0x4604 -#define FBIOPUTCMAP 0x4605 -#define FB_EXEC_FUNCTION 0x4606 -#define FBIOSWAPBUFFERS 0x4607 -#define FBIOSETBUFFERMODE 0x4608 -#define FBIOSETVIDEOMODE 0x4609 - -#define FB_SINGLE_BUFFERED 0 -#define FB_TRIPLE_BUFFERED 1 - -#define FB_TYPE_PACKED_PIXELS 0 /* Packed Pixels */ -#define FB_TYPE_PLANES 1 /* Non interleaved planes */ -#define FB_TYPE_INTERLEAVED_PLANES 2 /* Interleaved planes */ -#define FB_TYPE_TEXT 3 /* Text/attributes */ -#define FB_TYPE_VGA_PLANES 4 /* EGA/VGA planes */ -#define FB_TYPE_VIRTUAL_BUFFER 5 /* Virtual Buffer */ - - -#define FB_VISUAL_MONO01 0 /* Monochr. 1=Black 0=White */ -#define FB_VISUAL_MONO10 1 /* Monochr. 1=White 0=Black */ -#define FB_VISUAL_TRUECOLOR 2 /* True color */ -#define FB_VISUAL_PSEUDOCOLOR 3 /* Pseudo color (like atari) */ -#define FB_VISUAL_DIRECTCOLOR 4 /* Direct color */ -#define FB_VISUAL_STATIC_PSEUDOCOLOR 5 /* Pseudo color readonly */ - -#define FB_ACCEL_NONE 0 /* no hardware accelerator */ - -struct fb_bitfield { - uint32_t offset; /* beginning of bitfield */ - uint32_t length; /* length of bitfield */ - uint32_t msb_right; /* != 0 : Most significant bit is */ - /* right */ -}; - -struct fb_var_screeninfo { - uint32_t xres; /* visible resolution */ - uint32_t yres; - uint32_t bits_per_pixel; /* guess what */ - struct fb_bitfield red; /* bitfield in fb mem if true color, */ - struct fb_bitfield green; /* else only length is significant */ - struct fb_bitfield blue; - struct fb_bitfield transp; /* transparency */ -}; - -struct fb_fix_screeninfo { - volatile char *smem_start; /* Start of frame buffer mem */ - /* (physical address) */ - uint32_t smem_len; /* Length of frame buffer mem */ - uint32_t type; /* see FB_TYPE_* */ - uint32_t visual; /* see FB_VISUAL_* */ - uint32_t line_length; /* number of chars per line */ -}; - -struct fb_cmap { - uint32_t start; /* First entry */ - uint32_t len; /* Number of entries */ - uint16_t *red; /* Red values */ - uint16_t *green; - uint16_t *blue; - uint16_t *transp; /* transparency, can be NULL */ -}; - -#ifdef __cplusplus -} -#endif -/**@}*/ - -#endif /* _MW_FB_H */ diff --git a/cpukit/libmisc/fb/mw_uid.h b/cpukit/libmisc/fb/mw_uid.h deleted file mode 100644 index aa88392d26..0000000000 --- a/cpukit/libmisc/fb/mw_uid.h +++ /dev/null @@ -1,194 +0,0 @@ -/** - * @file rtems/mw_uid.h - * - * @defgroup libmisc_fb_mw Input Devices for MicroWindows - * - * @ingroup libmisc - * @brief Input Devices for MicroWindows - * - * This file defines the interface for input devices used by MicroWindows - * in an embedded system environment. - */ - -/* - * Copyright (c) 2000 - Rosimildo da Silva - */ - -#ifndef _MW_UID_H -#define _MW_UID_H - -#include -#include - -/** - * @defgroup libmisc_fb_mw Input Devices for MicroWindows - * - * @ingroup libmisc - */ -/**@{*/ -#ifdef __cplusplus -extern "C" { -#endif - -/* 0x41XX -- IOCTL functions for the Micro Input Devices commands */ -#define MW_UID_REGISTER_DEVICE 0x4100 -#define MW_UID_UNREGISTER_DEVICE 0x4101 - -/* devices supported by MicroWindows */ -enum MW_INPUT_DEVICE_TYPE { - MV_UID_INVALID = 0, - MV_UID_REL_POS = 1, /* mouse */ - MV_UID_ABS_POS = 2, /* touch-screen */ - MV_UID_KBD = 3, /* keyboard */ - MV_UID_TIMER = 4 /* timer -- not used */ -}; - -/* matching MicroWindows */ -#define MV_BUTTON_RIGHT 0x01 -#define MV_BUTTON_CENTER 0x02 -#define MV_BUTTON_LEFT 0x04 - -/* modifiers of the keyboard type devices */ -#define MV_KEY_MODIFIER_SHIFT_DOWN 0x10 -#define MV_KEY_MODIFIER_ALT_DOWN 0x20 - -/* indication of the LEDS */ -#define MV_KEY_MODIFIER_CAPS_ON 0x04 -#define MV_KEY_MODIFIER_NUN_LOCK_ON 0x02 -#define MV_KEY_SCROLL_LOCK_ON 0x01 - -/* keyboard modes -- default ASCII */ -#define MV_KEY_MODE_ASCII 0x01 -/* - * This mode one event is sent when a key is pressed, - * and another one is send when a key is released. - */ -#define MV_KEY_MODE_SCANCODE 0x00 - -/* these defines match with the linux keyboard range - * for ioctls functions for the keyboard interface. - * 0x4BXX --- keyboard related functions - */ -#define MV_KDGKBMODE 0x4B44 /* gets current keyboard mode */ -#define MV_KDSKBMODE 0x4B45 /* sets current keyboard mode */ - -/* - * Message generated by input devices controlled by MicroWindows. - */ -struct MW_UID_MESSAGE { - enum MW_INPUT_DEVICE_TYPE type; /* device type */ - union { - /* fired when keyboard events are raised */ - struct kbd_t { - unsigned short code; /* keycode or scancode */ - unsigned char modifiers; /* key modifiers */ - unsigned char mode; /* current Kbd mode */ - } kbd; - - /* fired when position events are raised, mouse, touch screen, etc */ - struct pos_t { - unsigned short btns; /* indicates which buttons are pressed */ - short x; /* x location */ - short y; /* y location */ - short z; /* z location, 0 for 2D */ - } pos; - - /* fired by a timer device periodically */ - struct timer_t { - unsigned long frt; /* free running timer */ - unsigned long seq; /* sequence number */ - } tmr; - } m; -}; - - -/* - * API for creating/closing/accessing the message queue used by the micro - * input device interface. All functions in this interface returns a - * zero ( 0 ) on success. One exception for that is the "read" routine - * that returns the number of bytes read. Negaive numbers indicate errors - * - * The implementation of the message queue for RTEMS uses a POSIX message - * queue interface. It should be very portable among systems with a POSIX - * support. - */ - -/** - * This method creates the message queue that holds events from the - * input devices. - * - * @param[in] q_name is the name of the message queue - * @param[in] flags controls the behaviour of the queue - * @param[in] max_msgs specifies the maximum number of pending messages - * - * @note The message queue is from the Classic API. - * - * @retval This method returns 0 on success and -1 on error. - */ -extern int uid_open_queue( const char *q_name, int flags, size_t max_msgs ); - -/** - * This method closes the message queue and deletes it. - * - * @retval This method returns 0 on success and -1 on error. - */ -extern int uid_close_queue( void ); - -/** - * This method reads a message from the queue. It waits up to the specified - * timeout in miliseconds. A @a timeout of 0 is a poll. - * - * @param[in] m will be filled in with the received message - * @param[in] timeout is the maximum number of mulliseconds to wait - * - * @retval This method returns 0 on success and -1 on error. - */ -extern int uid_read_message( struct MW_UID_MESSAGE *m, unsigned long timeout ); - -/** - * This methods writes a message to the queue. - * - * @param[in] m is the message to send - * - * @retval This method returns 0 on success and -1 on error. - */ -extern int uid_send_message( struct MW_UID_MESSAGE *m ); - -/** - * This method registers the device associated with @a fd to - * to insert data to the queue - */ -extern int uid_register_device( int fd, const char *q_name ); - -/* unregister device to stop adding messages to the queue */ -extern int uid_unregister_device( int fd ); - -/* set the keyboard */ -extern int uid_set_kbd_mode( int fd, int mode, int *old_mode ); - -/** - * This methods prints the specified UID message using printk - * - * @param[in] uid points to the message to print - */ -void uid_print_message( - struct MW_UID_MESSAGE *uid -); - -/** - * This methods prints the specified UID message using your fprintf - * style method of choice. - * - * @param[in] RTEMS printer - * @param[in] uid points to the message to print - */ -void uid_print_message_with_plugin( - const rtems_printer *printer, - struct MW_UID_MESSAGE *uid -); - -#ifdef __cplusplus -} -#endif -/**@}*/ -#endif /* _MW_UID_H */ diff --git a/cpukit/libmisc/fsmount/fsmount.h b/cpukit/libmisc/fsmount/fsmount.h deleted file mode 100644 index 441b0d68ef..0000000000 --- a/cpukit/libmisc/fsmount/fsmount.h +++ /dev/null @@ -1,211 +0,0 @@ -/** - * @file rtems/fsmount.h - * - * @defgroup rtems_fstab File System Mount Support - * - * @ingroup FileSystemTypesAndMount - * @brief File System Mount Functions - * - * This file contains the fsmount functions. These functions - * are used to mount a list of filesystems (and create their mount - * points before). - */ - -/* - * Copyright (c) 2003 IMD - * - * Ingenieurbuero fuer Microcomputertechnik Th. Doerfler - * - * all rights reserved - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _FSMOUNT_H -#define _FSMOUNT_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup rtems_fstab File System Mount Support - * - * @ingroup FileSystemTypesAndMount - */ -/**@{**/ - -/** - * File system mount report and abort condition flags. - * - * The flags define, which conditions will cause a report during the mount - * process (via printf()) or abort the mount process. - * - * @see rtems_fstab_entry and rtems_fsmount(). - */ -typedef enum { - /** - * No conditions. - */ - RTEMS_FSTAB_NONE = 0U, - - /** - * Complete mount process was successful. - */ - RTEMS_FSTAB_OK = 0x1U, - - /** - * Mount point creation failed. - */ - RTEMS_FSTAB_ERROR_MOUNT_POINT = 0x2U, - - /** - * File system mount failed. - */ - RTEMS_FSTAB_ERROR_MOUNT = 0x4U, - - /** - * Something failed. - */ - RTEMS_FSTAB_ERROR = RTEMS_FSTAB_ERROR_MOUNT_POINT | RTEMS_FSTAB_ERROR_MOUNT, - - /** - * Any condition. - */ - RTEMS_FSTAB_ANY = RTEMS_FSTAB_OK | RTEMS_FSTAB_ERROR -} rtems_fstab_conditions; - -/** - * File system table entry. - */ -typedef struct { - /** - * Source for the mount. - */ - const char *source; - - /** - * Target for the mount. - */ - const char *target; - - /** - * File system operations. - */ - const char *type; - - /** - * File system mount options. - */ - rtems_filesystem_options_t options; - - /** - * Report @ref rtems_fstab_conditions "condition flags". - */ - uint16_t report_reasons; - - /** - * Abort @ref rtems_fstab_conditions "condition flags". - */ - uint16_t abort_reasons; -} rtems_fstab_entry; - -/** - * @brief Mounts the file systems listed in the file system mount table. - * - * Mounts the file systems listed in the file system mount table @a fstab of - * size @a size. - * - * Each file system will be mounted according to its table entry parameters. - * In case of an abort condition the corresponding table index will be reported - * in @a abort_index. The pointer @a abort_index may be @c NULL. The mount - * point paths will be created with rtems_mkdir() and need not exist - * beforehand. - * - * On success, zero is returned. On error, -1 is returned, and @c errno is set - * appropriately. - * - * @see rtems_bdpart_register_from_disk(). - * - * The following example code tries to mount a FAT file system within a SD - * Card. Some cards do not have a partition table so at first it tries to find - * a file system inside the hole disk. If this is successful the mount process - * will be aborted because the @ref RTEMS_FSTAB_OK condition is true. If this - * did not work it tries to mount the file system inside the first partition. - * If this fails the mount process will not be aborted (this is already the - * last entry), but the last error status will be returned. - * - * @code - * #include - * #include - * #include - * - * #include - * #include - * #include - * #include - * - * static const rtems_fstab_entry fstab [] = { - * { - * .source = "/dev/sd-card-a", - * .target = "/mnt", - * .type = "dosfs", - * .options = RTEMS_FILESYSTEM_READ_WRITE, - * .report_reasons = RTEMS_FSTAB_ANY, - * .abort_reasons = RTEMS_FSTAB_OK - * }, { - * .source = "/dev/sd-card-a1", - * .target = "/mnt", - * .type = "dosfs", - * .options = RTEMS_FILESYSTEM_READ_WRITE, - * .report_reasons = RTEMS_FSTAB_ANY, - * .abort_reasons = RTEMS_FSTAB_NONE - * } - * }; - * - * static void my_mount(void) - * { - * rtems_status_code sc = RTEMS_SUCCESSFUL; - * int rv = 0; - * size_t abort_index = 0; - * - * sc = rtems_bdpart_register_from_disk("/dev/sd-card-a"); - * if (sc != RTEMS_SUCCESSFUL) { - * printf("read partition table failed: %s\n", rtems_status_text(sc)); - * } - * - * rv = rtems_fsmount(fstab, sizeof(fstab) / sizeof(fstab [0]), &abort_index); - * if (rv != 0) { - * printf("mount failed: %s\n", strerror(errno)); - * } - * printf("mount aborted at %zu\n", abort_index); - * } - * @endcode - */ -int rtems_fsmount( - const rtems_fstab_entry *fstab, - size_t size, - size_t *abort_index -); - -/** @} */ - -typedef rtems_fstab_entry fstab_t; - -#define FSMOUNT_MNT_OK RTEMS_FSTAB_OK - -#define FSMOUNT_MNTPNT_CRTERR RTEMS_FSTAB_ERROR_MOUNT_POINT - -#define FSMOUNT_MNT_FAILED RTEMS_FSTAB_ERROR_MOUNT - -#ifdef __cplusplus -} -#endif - -#endif /* _FSMOUNT_H */ diff --git a/cpukit/libmisc/monitor/monitor.h b/cpukit/libmisc/monitor/monitor.h deleted file mode 100644 index 6ecd903c63..0000000000 --- a/cpukit/libmisc/monitor/monitor.h +++ /dev/null @@ -1,528 +0,0 @@ -/** - * @file rtems/monitor.h - * - * @brief The RTEMS Monitor Task - */ - - -#ifndef __MONITOR_H -#define __MONITOR_H - -#include -#include /* rtems_error() */ -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* Forward decls from symbols.h */ -typedef struct _rtems_symbol_t rtems_symbol_t; -typedef struct _rtems_symbol_table_t rtems_symbol_table_t; - -/* - * Monitor types are derived from rtems object classes - */ - -typedef enum { - RTEMS_MONITOR_OBJECT_INVALID = OBJECTS_CLASSIC_NO_CLASS, - RTEMS_MONITOR_OBJECT_TASK = OBJECTS_RTEMS_TASKS, - RTEMS_MONITOR_OBJECT_EXTENSION = OBJECTS_RTEMS_EXTENSIONS, - RTEMS_MONITOR_OBJECT_QUEUE = OBJECTS_RTEMS_MESSAGE_QUEUES, - RTEMS_MONITOR_OBJECT_SEMAPHORE = OBJECTS_RTEMS_SEMAPHORES, - RTEMS_MONITOR_OBJECT_PARTITION = OBJECTS_RTEMS_PARTITIONS, - RTEMS_MONITOR_OBJECT_REGION = OBJECTS_RTEMS_REGIONS, - RTEMS_MONITOR_OBJECT_PORT = OBJECTS_RTEMS_PORTS, - - /* following monitor objects are not known to RTEMS, but - * we like to have "types" for them anyway */ - - RTEMS_MONITOR_OBJECT_DRIVER = OBJECTS_RTEMS_CLASSES_LAST+1, - RTEMS_MONITOR_OBJECT_DNAME, - RTEMS_MONITOR_OBJECT_CONFIG, - RTEMS_MONITOR_OBJECT_INIT_TASK, - RTEMS_MONITOR_OBJECT_MPCI, - RTEMS_MONITOR_OBJECT_SYMBOL, - #if defined(RTEMS_POSIX_API) - RTEMS_MONITOR_OBJECT_PTHREAD, - #endif -} rtems_monitor_object_type_t; - -/* - * rtems_monitor_init() flags - */ - -#define RTEMS_MONITOR_SUSPEND 0x0001 /* suspend monitor on startup */ -#define RTEMS_MONITOR_GLOBAL 0x0002 /* monitor should be global */ -#define RTEMS_MONITOR_NOTASK 0x0004 /* do not start monitor task */ -#define RTEMS_MONITOR_NOSYMLOAD 0x0008 /* do not load symbols */ -#define RTEMS_MONITOR_WAITQUIT 0x0010 /* wait for monitor task to terminate */ - -/* - * Public interfaces for RTEMS data structures monitor is aware of. - * These are only used by the monitor. - * - * NOTE: - * All the canonical objects that correspond to RTEMS managed "objects" - * must have an identical first portion with 'id' and 'name' fields. - * - * Others do not have that restriction, even tho we would like them to. - * This is because some of the canonical structures are almost too big - * for shared memory driver (eg: mpci) and we are nickel and diming it. - */ - -/* - * Type of a pointer that may be a symbol - */ - -#define MONITOR_SYMBOL_LEN 20 -typedef struct { - char name[MONITOR_SYMBOL_LEN]; - uint32_t value; - uint32_t offset; -} rtems_monitor_symbol_t; - -typedef struct { - rtems_id id; - rtems_name name; - /* end of common portion */ -} rtems_monitor_generic_t; - -/* - * Task - */ -typedef struct { - rtems_id id; - rtems_name name; - /* end of common portion */ - char short_name[5]; - char long_name[16]; - Thread_Entry_information entry; - void *stack; - uint32_t stack_size; - char scheduler_name[5]; - rtems_task_priority priority; - States_Control state; - rtems_event_set events; - rtems_mode modes; - rtems_attribute attributes; - char wait[17]; - uint32_t ticks; -} rtems_monitor_task_t; - -/* - * Init task - */ - -typedef struct { - rtems_id id; /* not really an id */ - rtems_name name; - /* end of common portion */ - rtems_monitor_symbol_t entry; - uint32_t argument; - uint32_t stack_size; - rtems_task_priority priority; - rtems_mode modes; - rtems_attribute attributes; -} rtems_monitor_init_task_t; - - -/* - * Message queue - */ -typedef struct { - rtems_id id; - rtems_name name; - /* end of common portion */ - rtems_attribute attributes; - uint32_t number_of_pending_messages; - uint32_t maximum_pending_messages; - size_t maximum_message_size; -} rtems_monitor_queue_t; - -/* - * Semaphore - */ -typedef struct { - rtems_id id; - rtems_name name; - /* end of common portion */ - rtems_attribute attribute; - rtems_task_priority priority_ceiling; - uint32_t max_count; - uint32_t cur_count; - rtems_id holder_id; -} rtems_monitor_sema_t; - -/* - * Extension - */ -typedef struct { - rtems_id id; - rtems_name name; - /* end of common portion */ - rtems_monitor_symbol_t e_create; - rtems_monitor_symbol_t e_start; - rtems_monitor_symbol_t e_restart; - rtems_monitor_symbol_t e_delete; - rtems_monitor_symbol_t e_tswitch; - rtems_monitor_symbol_t e_begin; - rtems_monitor_symbol_t e_exitted; - rtems_monitor_symbol_t e_fatal; -} rtems_monitor_extension_t; - - /* - * Region - */ -typedef struct { - rtems_id id; - rtems_name name; - /* end of common portion */ - rtems_attribute attribute; - void * start_addr; - uint32_t length; - uint32_t page_size; - uint32_t max_seg_size; - uint32_t used_blocks; -} rtems_monitor_region_t; - -/* - * Partition - */ -typedef struct { - rtems_id id; - rtems_name name; - /* end of common portion */ - rtems_attribute attribute; - void * start_addr; - uint32_t length; - uint32_t buf_size; - uint32_t used_blocks; -} rtems_monitor_part_t; - -/* - * Device driver - */ - -typedef struct { - rtems_id id; /* not really an id (should be tho) */ - rtems_name name; /* ditto */ - /* end of common portion */ - rtems_monitor_symbol_t initialization; /* initialization procedure */ - rtems_monitor_symbol_t open; /* open request procedure */ - rtems_monitor_symbol_t close; /* close request procedure */ - rtems_monitor_symbol_t read; /* read request procedure */ - rtems_monitor_symbol_t write; /* write request procedure */ - rtems_monitor_symbol_t control; /* special functions procedure */ -} rtems_monitor_driver_t; - -/* - * System config - */ - -typedef struct { - void *work_space_start; - uint32_t work_space_size; - uint32_t maximum_tasks; - uint32_t maximum_timers; - uint32_t maximum_semaphores; - uint32_t maximum_message_queues; - uint32_t maximum_partitions; - uint32_t maximum_regions; - uint32_t maximum_ports; - uint32_t maximum_periods; - uint32_t maximum_extensions; - uint32_t microseconds_per_tick; - uint32_t ticks_per_timeslice; - uint32_t number_of_initialization_tasks; -} rtems_monitor_config_t; - -/* - * MPCI config - */ - -#if defined(RTEMS_MULTIPROCESSING) -typedef struct { - uint32_t node; /* local node number */ - uint32_t maximum_nodes; /* maximum # nodes in system */ - uint32_t maximum_global_objects; /* maximum # global objects */ - uint32_t maximum_proxies; /* maximum # proxies */ - - uint32_t default_timeout; /* in ticks */ - size_t maximum_packet_size; - rtems_monitor_symbol_t initialization; - rtems_monitor_symbol_t get_packet; - rtems_monitor_symbol_t return_packet; - rtems_monitor_symbol_t send_packet; - rtems_monitor_symbol_t receive_packet; -} rtems_monitor_mpci_t; -#endif - -/* - * The generic canonical information union - */ - -typedef union { - rtems_monitor_generic_t generic; - rtems_monitor_task_t task; - rtems_monitor_queue_t queue; - rtems_monitor_sema_t sema; - rtems_monitor_extension_t extension; - rtems_monitor_driver_t driver; - rtems_monitor_config_t config; - rtems_monitor_region_t region; - rtems_monitor_part_t part; -#if defined(RTEMS_MULTIPROCESSING) - rtems_monitor_mpci_t mpci; -#endif - rtems_monitor_init_task_t itask; -} rtems_monitor_union_t; - -/* - * Support for talking to other monitors - */ - -/* - * Names of other monitors - */ - -#define RTEMS_MONITOR_NAME (rtems_build_name('R', 'M', 'O', 'N')) -#define RTEMS_MONITOR_SERVER_NAME (rtems_build_name('R', 'M', 'S', 'V')) -#define RTEMS_MONITOR_QUEUE_NAME (rtems_build_name('R', 'M', 'S', 'Q')) -#define RTEMS_MONITOR_RESPONSE_QUEUE_NAME (rtems_build_name('R', 'M', 'R', 'Q')) - -#define RTEMS_MONITOR_SERVER_RESPONSE 0x0001 -#define RTEMS_MONITOR_SERVER_CANONICAL 0x0002 - -typedef struct -{ - uint32_t command; - rtems_id return_id; - uint32_t argument0; - uint32_t argument1; - uint32_t argument2; - uint32_t argument3; - uint32_t argument4; - uint32_t argument5; -} rtems_monitor_server_request_t; - -typedef struct -{ - uint32_t command; - uint32_t result0; - uint32_t result1; - rtems_monitor_union_t payload; -} rtems_monitor_server_response_t; - -extern rtems_id rtems_monitor_task_id; - -extern uint32_t rtems_monitor_node; /* our node number */ -extern uint32_t rtems_monitor_default_node; /* current default for commands */ - -/* - * Monitor command function and table entry - */ - -typedef struct rtems_monitor_command_entry_s rtems_monitor_command_entry_t; -typedef union _rtems_monitor_command_arg_t rtems_monitor_command_arg_t; - -typedef void (*rtems_monitor_command_function_t)( - int argc, - char **argv, - const rtems_monitor_command_arg_t *command_arg, - bool verbose -); - -union _rtems_monitor_command_arg_t { - rtems_monitor_object_type_t monitor_object; - rtems_status_code status_code; - rtems_symbol_table_t **symbol_table; - const rtems_monitor_command_entry_t *monitor_command_entry; -}; - -struct rtems_monitor_command_entry_s { - const char *command; /* command name */ - const char *usage; /* usage string for the command */ - uint32_t arguments_required; /* # of required args */ - rtems_monitor_command_function_t command_function; - /* Some argument for the command */ - rtems_monitor_command_arg_t command_arg; - const rtems_monitor_command_entry_t *next; -}; - - -typedef const void *(*rtems_monitor_object_next_fn)(void *, void *, rtems_id *); -typedef void (*rtems_monitor_object_canonical_fn)(void *, const void *); -typedef void (*rtems_monitor_object_dump_header_fn)(bool); -typedef void (*rtems_monitor_object_dump_fn)(void *, bool); - -typedef struct { - rtems_monitor_object_type_t type; - void *object_information; - int size; /* of canonical object */ - rtems_monitor_object_next_fn next; - rtems_monitor_object_canonical_fn canonical; - rtems_monitor_object_dump_header_fn dump_header; - rtems_monitor_object_dump_fn dump; -} rtems_monitor_object_info_t; - -typedef bool (*rtems_monitor_per_command_routine)(const rtems_monitor_command_entry_t *, void *); - -/* monitor.c */ -void rtems_monitor_pause_cmd(int, char **, const rtems_monitor_command_arg_t*, bool); -void rtems_monitor_fatal_cmd(int, char **, const rtems_monitor_command_arg_t*, bool); -void rtems_monitor_continue_cmd(int, char **, const rtems_monitor_command_arg_t*, bool); -void rtems_monitor_debugger_cmd(int, char **, const rtems_monitor_command_arg_t*, bool); -void rtems_monitor_reset_cmd(int, char **, const rtems_monitor_command_arg_t*, bool); -void rtems_monitor_node_cmd(int, char **, const rtems_monitor_command_arg_t*, bool); -void rtems_monitor_symbols_loadup(void); -int rtems_monitor_insert_cmd(rtems_monitor_command_entry_t *); -void rtems_monitor_wakeup(void); -void rtems_monitor_command_iterate(rtems_monitor_per_command_routine routine, void *arg); -rtems_status_code rtems_monitor_suspend(rtems_interval timeout); - -/* editor.c */ -void rtems_monitor_kill(void); -void rtems_monitor_init(uint32_t); -void rtems_monitor_task(rtems_task_argument); - -/* server.c */ -void rtems_monitor_server_kill(void); -rtems_status_code rtems_monitor_server_request(uint32_t , rtems_monitor_server_request_t *, rtems_monitor_server_response_t *); -void rtems_monitor_server_task(rtems_task_argument); -void rtems_monitor_server_init(uint32_t); - -/* command.c */ -int rtems_monitor_make_argv(char *, int *, char **); -int rtems_monitor_command_read(char *, int *, char **); -void rtems_monitor_command_usage(const rtems_monitor_command_entry_t *, const char *); -void rtems_monitor_help_cmd(int, char **, const rtems_monitor_command_arg_t *, bool); -const rtems_monitor_command_entry_t *rtems_monitor_command_lookup(const char *name); - -/* prmisc.c */ -void rtems_monitor_separator(void); -uint32_t rtems_monitor_pad(uint32_t dest_col, uint32_t curr_col); -int rtems_monitor_dump_decimal(uint32_t num); -int rtems_monitor_dump_hex(uint32_t num); -int rtems_monitor_dump_addr(const void *addr); -int rtems_monitor_dump_id(rtems_id id); -int rtems_monitor_dump_name(rtems_id id); -int rtems_monitor_dump_priority(rtems_task_priority priority); -int rtems_monitor_dump_state(States_Control state); -int rtems_monitor_dump_modes(rtems_mode modes); -int rtems_monitor_dump_attributes(rtems_attribute attributes); -int rtems_monitor_dump_events(rtems_event_set events); - -/* object.c */ -rtems_id rtems_monitor_id_fixup(rtems_id, uint32_t , rtems_monitor_object_type_t); -const rtems_monitor_object_info_t *rtems_monitor_object_lookup(rtems_monitor_object_type_t type); -rtems_id rtems_monitor_object_canonical_get(rtems_monitor_object_type_t, rtems_id, void *, size_t *size_p); -rtems_id rtems_monitor_object_canonical_next(const rtems_monitor_object_info_t *, rtems_id, void *); -const void *rtems_monitor_object_next(void *, void *, rtems_id, rtems_id *); -rtems_id rtems_monitor_object_canonical(rtems_id, const void *); -void rtems_monitor_object_cmd(int, char **, const rtems_monitor_command_arg_t*, bool); - -/* manager.c */ -const void *rtems_monitor_manager_next(void *, void *, rtems_id *); - -/* config.c */ -void rtems_monitor_config_canonical(rtems_monitor_config_t *, const void *); -const void *rtems_monitor_config_next(void *, rtems_monitor_config_t *, rtems_id *); -void rtems_monitor_config_dump_header(bool); -int rtems_monitor_config_dump(rtems_monitor_config_t *, bool verbose); - -/* mpci.c */ -#if defined(RTEMS_MULTIPROCESSING) -void rtems_monitor_mpci_canonical(rtems_monitor_mpci_t *, const void *); -const void *rtems_monitor_mpci_next(void *, rtems_monitor_mpci_t *, rtems_id *); -void rtems_monitor_mpci_dump_header(bool); -void rtems_monitor_mpci_dump(rtems_monitor_mpci_t *, bool verbose); -#endif - -/* itask.c */ -void rtems_monitor_init_task_canonical(rtems_monitor_init_task_t *, const void *); -const void *rtems_monitor_init_task_next(void *, rtems_monitor_init_task_t *, rtems_id *); -void rtems_monitor_init_task_dump_header(bool); -void rtems_monitor_init_task_dump(rtems_monitor_init_task_t *, bool verbose); - -/* extension.c */ -void rtems_monitor_extension_canonical(rtems_monitor_extension_t *, const void *); -void rtems_monitor_extension_dump_header(bool verbose); -void rtems_monitor_extension_dump(rtems_monitor_extension_t *, bool); - -/* task.c */ -void rtems_monitor_task_canonical(rtems_monitor_task_t *, const void *); -void rtems_monitor_task_dump_header(bool verbose); -void rtems_monitor_task_dump(rtems_monitor_task_t *, bool); - -/* sema.c */ -void rtems_monitor_sema_canonical(rtems_monitor_sema_t *, const void *); -void rtems_monitor_sema_dump_header(bool verbose); -void rtems_monitor_sema_dump(rtems_monitor_sema_t *, bool); - -/* queue.c */ -void rtems_monitor_queue_canonical(rtems_monitor_queue_t *, const void *); -void rtems_monitor_queue_dump_header(bool verbose); -void rtems_monitor_queue_dump(rtems_monitor_queue_t *, bool); - -/* region.c */ -void rtems_monitor_region_canonical(rtems_monitor_region_t *, const void *); -void rtems_monitor_region_dump_header(bool verbose); -void rtems_monitor_region_dump(rtems_monitor_region_t *, bool); - -/* partition.c */ -void rtems_monitor_part_canonical(rtems_monitor_part_t *, const void *); -void rtems_monitor_part_dump_header(bool verbose); -void rtems_monitor_part_dump(rtems_monitor_part_t *, bool); - -/* driver.c */ -const void *rtems_monitor_driver_next(void *, rtems_monitor_driver_t *, rtems_id *); -void rtems_monitor_driver_canonical(rtems_monitor_driver_t *, const void *); -void rtems_monitor_driver_dump_header(bool); -void rtems_monitor_driver_dump(rtems_monitor_driver_t *, bool); - -/* symbols.c */ -rtems_symbol_table_t *rtems_symbol_table_create(void); -void rtems_symbol_table_destroy(rtems_symbol_table_t *table); - -rtems_symbol_t *rtems_symbol_create(rtems_symbol_table_t *, const char *, uint32_t); -rtems_symbol_t *rtems_symbol_value_lookup(rtems_symbol_table_t *, uint32_t); -const rtems_symbol_t *rtems_symbol_value_lookup_exact(rtems_symbol_table_t *, uint32_t); -rtems_symbol_t *rtems_symbol_name_lookup(rtems_symbol_table_t *, const char *); -const void *rtems_monitor_symbol_next(void *object_info, rtems_monitor_symbol_t *, rtems_id *); -void rtems_monitor_symbol_canonical(rtems_monitor_symbol_t *, rtems_symbol_t *); -void rtems_monitor_symbol_canonical_by_name(rtems_monitor_symbol_t *, const char *); -void rtems_monitor_symbol_canonical_by_value(rtems_monitor_symbol_t *, void *); -uint32_t rtems_monitor_symbol_dump(rtems_monitor_symbol_t *, bool); -void rtems_monitor_symbol_cmd(int, char **, const rtems_monitor_command_arg_t*, bool); - -#if defined(RTEMS_NETWORKING) -void mon_ifconfig( - int argc, - char *argv[], - uint32_t command_arg, - bool verbose -); -void mon_route( - int argc, - char *argv[], - uint32_t command_arg, - bool verbose -); -#endif - -/* mon-object.c */ -const rtems_monitor_object_info_t *rtems_monitor_object_lookup( - rtems_monitor_object_type_t type -); - -/* shared data */ -extern rtems_symbol_table_t *rtems_monitor_symbols; - -#define MONITOR_WAKEUP_EVENT RTEMS_EVENT_0 - -#ifdef __cplusplus -} -#endif - -#endif /* ! __MONITOR_H */ diff --git a/cpukit/libmisc/mouse/mouse_parser.h b/cpukit/libmisc/mouse/mouse_parser.h deleted file mode 100644 index 27bea1bbbc..0000000000 --- a/cpukit/libmisc/mouse/mouse_parser.h +++ /dev/null @@ -1,121 +0,0 @@ -/** - * @file rtems/mouse_parser.h - * - * @brief Initialize Mouse Parser Engine - * - * This file is the header file for the Mouse Parser Engine. - */ - -/* - * This file is derived from a UNIX Serial Port Mouse Driver with the - * following notice: - * - * ================================================================== - * Copyright (c) 1999 Greg Haerr - * Portions Copyright (c) 1991 David I. Bell - * Permission is granted to use, distribute, or modify this source, - * provided that this copyright notice remains intact. - * - * UNIX Serial Port Mouse Driver - * - * This driver opens a serial port directly, and interprets serial data. - * Microsoft, PC, Logitech and PS/2 mice are supported. The PS/2 mouse - * is only supported if the OS runs the mouse byte codes through the - * serial port. - * - * Mouse Types Supported: pc ms, logi, ps2 - * ================================================================== - * - * It has been modified to support the concept of being just a parser - * fed data from an arbitrary source. It is independent of either - * a PS/2 driver or a serial port. - * - * It was moved to cpukit/libmisc/mouse by Joel Sherrill. - */ - -#ifndef __MOUSE_PARSER_h__ -#define __MOUSE_PARSER_h__ - -#include - -/** - * @defgroup libmisc_mouseparser Mouse Parser Engine - * @ingroup libmisc_mouse - */ -/**@{*/ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * This is the mask for the right button. - * - * @note Use the same definitions as the user interface. - */ -#define RBUTTON MV_BUTTON_RIGHT - -/** - * This is the mask for the center button. - * - * @note Use the same definitions as the user interface. - */ -#define MBUTTON MV_BUTTON_CENTER - -/** - * This is the mask for the left button. - * - * @note Use the same definitions as the user interface. - */ -#define LBUTTON MV_BUTTON_LEFT - -/** - * This type is the device coordinates. - */ -typedef int COORD; - -/** - * This type is the mouse button mask. - */ -typedef unsigned int BUTTON; - -/** - * This type defines a pointer to the enqueue method. It is - * available since some device drivers keep pointers to the method - * to know when to enqueue or not. - */ -typedef void (*mouse_parser_enqueue_handler)(unsigned char *, size_t); - -/** - * @brief Initialize the mouse parser engine. - * - * This method initializes the Mouse Parser Engine for the mouse - * of @a type. The @a type should be one of the following strings: - * pc ms, logi, ps2. - * - * @a param[in] type indicates the type of mouse. - * - * @retval This method returns 0 on success and -1 on error. - */ -int mouse_parser_initialize(const char *type); - -/** - * @brief Enqueue input to the mouse parser engine. - * - * This method is used to pass mouse input to the Mouse Parser Engine. - * - * @a param[in] buffer is the data to enqueue - * @a param[in] size is the amount of data to enqueue - */ -void mouse_parser_enqueue( - unsigned char *buffer, - size_t size -); - -#ifdef __cplusplus -} -#endif - -/**@}*/ - -#endif diff --git a/cpukit/libmisc/mouse/serial_mouse.h b/cpukit/libmisc/mouse/serial_mouse.h deleted file mode 100644 index 174fcfb909..0000000000 --- a/cpukit/libmisc/mouse/serial_mouse.h +++ /dev/null @@ -1,169 +0,0 @@ -/** - * @file - * - * @brief Serial Mouse Driver - * - * This file describes the Serial Mouse Driver for all boards. - * This driver assumes that the BSP or application will provide - * an implementation of the method bsp_get_serial_mouse_device() - * which tells the driver what serial port device to open() and - * what type of mouse is connected. - * - * This driver relies on the Mouse Parser Engine. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef __SERIAL_MOUSE_h__ -#define __SERIAL_MOUSE_h__ - -#include - -/* functions */ - -/** - * @defgroup libmisc_serialmouse Serial Mouse Driver - * @ingroup libmisc_mouse - */ -/**@{*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Standard device file path for a PS2 mouse device. - */ -#define SERIAL_MOUSE_DEVICE_PS2 "/dev/psaux" - -/** - * This macro defines the serial mouse device driver entry points. - */ -#define SERIAL_MOUSE_DRIVER_TABLE_ENTRY \ - { serial_mouse_initialize, serial_mouse_open, serial_mouse_close, \ - serial_mouse_read, serial_mouse_write, serial_mouse_control } - -/** - * @brief The initialization of the serial mouse driver. - * - * This method initializes the serial mouse driver. - * - * @param[in] major is the mouse device major number - * @param[in] minor is the mouse device minor number - * @param[in] arg points to device driver arguments - */ -rtems_device_driver serial_mouse_initialize( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *arg -); - -/** - * @brief Open device driver entry point for the serial mouse driver. - * - * This method implements the Open device driver entry - * point for the serial mouse driver. - * - * @param[in] major is the mouse device major number - * @param[in] minor is the mouse device minor number - * @param[in] arg points to device driver arguments - */ -rtems_device_driver serial_mouse_open( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *arg -); - -/** - * @brief Close device driver entry point for the serial mouse driver. - * - * This method implements the Close device driver entry - * point for the serial mouse driver. - * - * @param[in] major is the mouse device major number - * @param[in] minor is the mouse device minor number - * @param[in] arg points to device driver arguments - */ -rtems_device_driver serial_mouse_close( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *arg -); - -/** - * @brief Read device driver entry point for the serial mouse driver. - * - * This method implements the Read device driver entry - * point for the serial mouse driver. - * - * @param[in] major is the mouse device major number - * @param[in] minor is the mouse device minor number - * @param[in] arg points to device driver arguments - */ -rtems_device_driver serial_mouse_read( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *arg -); - -/** - * @brief Write device driver entry point for the serial mouse driver. - * - * This method implements the Write device driver entry - * point for the serial mouse driver. - * - * @param[in] major is the mouse device major number - * @param[in] minor is the mouse device minor number - * @param[in] arg points to device driver arguments - */ -rtems_device_driver serial_mouse_write( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *arg -); - -/** - * @brief IO Control device driver entry point for the serial mouse driver. - * - * This method implements the IO Control device driver entry - * point for the serial mouse driver. - * - * @param[in] major is the mouse device major number - * @param[in] minor is the mouse device minor number - * @param[in] arg points to device driver arguments - */ -rtems_device_driver serial_mouse_control( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *arg -); - -/** - * @brief Obtain serial mouse configuration information. - * - * This method is implemented by the BSP or application and - * tells the driver what device to open() and what type of - * mouse is connected. - * - * @param[in] name will point to a string with the device name - * of the serial port with the mouse connected. - * @param[in] type will point to a string with the type of mouse connected. - * - * @retval This method returns true on success and false on error. - */ -bool bsp_get_serial_mouse_device( - const char **name, - const char **type -); - -#ifdef __cplusplus -} -#endif -/**@}*/ -#endif /* __tty_drv__ */ diff --git a/cpukit/libmisc/preinstall.am b/cpukit/libmisc/preinstall.am deleted file mode 100644 index f6a7e763d2..0000000000 --- a/cpukit/libmisc/preinstall.am +++ /dev/null @@ -1,9 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -if LIBSHELL -endif diff --git a/cpukit/libmisc/redirector/stdio-redirect.h b/cpukit/libmisc/redirector/stdio-redirect.h deleted file mode 100644 index 6f1d4cdd98..0000000000 --- a/cpukit/libmisc/redirector/stdio-redirect.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (C) 2014 Chris Johns (chrisj@rtems.org) - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution. - * - * This software with is provided ``as is'' and with NO WARRANTY. - */ - -/* - * @brief Redirect an stdio file decriptor. - * - * The is a helper module of code design to redirect an stdio file - * descriptor. You can optionally have the data buffered and/or you can provide - * a handler function that is called when data arrives. - * - * The module uses standard POSIX calls to implement the redirection and if the - * threading was POSIX based the code would be portable. Currently the code - * uses RTEMS threads. - * - * Redirecting stderr and stdout is useful in embedded system because you can - * transport the output off your device or create a web interface that can - * display the output. This can be a very powerful diagnostic and support tool. - * - * The implementation does: - * - * 1. Duplicate the file descriptor (fd) to redirect using the dup call. The - * duplicated desciptor is used to echo the output out the existing path. - * - * 2. Create a pipe using the pipe call. - * - * 3. Duplicate the pipe's writer file descriptor to user's file - * descriptor. This results in any writes to the user's fd being written to - * the pipe. - * - * 4. Create a reader task that blocks on the pipe. It optionally calls a - * handler and if configured buffers the data. - */ - -#if !defined(RTEMS_STDIO_REDIRECT_H) -#define RTEMS_STDIO_REDIRECT_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * Handler called whenever redirected data arrives. - * - * @param buffer The data. - * @param length The amount of data in the buffer. - */ -typedef void (*rtems_stdio_redirect_handler)(const char* buffer, - ssize_t length); - -/* - * Redirector data. - */ -typedef struct -{ - volatile uint32_t state; /**< The state. */ - rtems_id reader; /**< The reader thread. */ - rtems_id lock; /**< Lock for this struct. */ - int fd; /**< The file descriptor to redirect. */ - int fd_dup; /**< Duplicated fd to write to. */ - int pipe[2]; /**< The pipe to the reader thread. */ - char* input; /**< The input buffer the reader uses. */ - ssize_t input_size; /**< The input buffer size. */ - char* buffer; /**< Captured redirected data. */ - ssize_t buffer_size; /**< Capture buffer size. */ - ssize_t in; /**< Buffer in index. */ - bool full; /**< The buffer is full. */ - bool echo; /**< Echo the data out the existing path. */ - rtems_stdio_redirect_handler handler; /**< Redirected data handler. */ -} rtems_stdio_redirect; - -/* - * Open a redirector returning the handle to it. - * - * @param fd The file descriptor to redirect. - * @param priority The priority of the reader thread. - */ -rtems_stdio_redirect* rtems_stdio_redirect_open(int fd, - rtems_task_priority priority, - size_t stack_size, - ssize_t input_size, - ssize_t buffer_size, - bool echo, - rtems_stdio_redirect_handler handler); - -/* - * Close the redirector. - */ -void rtems_stdio_redirect_close(rtems_stdio_redirect* sr); - -/* - * Get data from the capture buffer. Data read is removed from the buffer. - * - * @param sr The stdio redirection handle. - * @param buffer The buffer data is written into. - * @param length The size of the buffer. - * @return ssize_t The amount of data written and -1 or an error. - */ -ssize_t rtems_stdio_redirect_read(rtems_stdio_redirect* sr, - char* buffer, - ssize_t length); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/cpukit/libmisc/rtems-fdt/rtems-fdt-shell.h b/cpukit/libmisc/rtems-fdt/rtems-fdt-shell.h deleted file mode 100644 index 74e9a44aaf..0000000000 --- a/cpukit/libmisc/rtems-fdt/rtems-fdt-shell.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * COPYRIGHT (c) 2013-2017 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ -/** - * @file - * - * @ingroup rtems_fdt - * - * @brief RTEMS Flattened Device Tree Shell Command - * - * Support for loading, managing and accessing FDT blobs in RTEMS. - */ - -#if !defined (_RTEMS_FDT_SHELL_H_) -#define _RTEMS_FDT_SHELL_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * Add a shell command to access memory and registers associated with the DTF. - */ -void rtems_fdt_add_shell_command (void); - -/** - * Get a pointer to the handle. You can use this to load files or register - * blobs and have the shell command access them. - */ -rtems_fdt_handle* rtems_fdt_get_shell_handle (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/cpukit/libmisc/rtems-fdt/rtems-fdt.h b/cpukit/libmisc/rtems-fdt/rtems-fdt.h deleted file mode 100644 index ebc222e4c9..0000000000 --- a/cpukit/libmisc/rtems-fdt/rtems-fdt.h +++ /dev/null @@ -1,621 +0,0 @@ -/* - * COPYRIGHT (c) 2013-2017 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - * - * Interface based on the libdft: - * libfdt - Flat Device Tree manipulation - * Copyright (C) 2006 David Gibson, IBM Corporation. - */ -/** - * @file - * - * @ingroup rtems_fdt - * - * @brief RTEMS Flattened Device Tree - * - * Support for loading, managing and accessing FDT blobs in RTEMS. - */ - -#if !defined (_RTEMS_FDT_H_) -#define _RTEMS_FDT_H_ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * A blob. - */ -struct rtems_fdt_blob; -typedef struct rtems_fdt_blob rtems_fdt_blob; - -/** - * A blob handle is a way to manage access to the FDT blobs. The blob is - * referenced via the handle to allow searches across loaded DTB's to return - * the referenced DTB. - */ -typedef struct -{ - rtems_fdt_blob* blob; /**< The blob the handle references. */ -} rtems_fdt_handle; - -/* - * The following are mappings to the standard FDT calls. - */ - -/** - * RTEMS_FDT_ERR_NOTFOUND: The requested node or property does not exist - */ -#define RTEMS_FDT_ERR_NOTFOUND 1 -/** - * RTEMS_FDT_ERR_EXISTS: Attemped to create a node or property which already - * exists */ -#define RTEMS_FDT_ERR_EXISTS 2 -/** - * RTEMS_FDT_ERR_NOSPACE: Operation needed to expand the device tree, but its - * buffer did not have sufficient space to contain the expanded tree. Use - * rtems_fdt_open_into() to move the device tree to a buffer with more space. - */ -#define RTEMS_FDT_ERR_NOSPACE 3 - -/* Error codes: codes for bad parameters */ -/** - * RTEMS_FDT_ERR_BADOFFSET: Function was passed a structure block offset which - * is out-of-bounds, or which points to an unsuitable part of the structure for - * the operation. - */ -#define RTEMS_FDT_ERR_BADOFFSET 4 -/** - * RTEMS_FDT_ERR_BADPATH: Function was passed a badly formatted path - * (e.g. missing a leading / for a function which requires an absolute path) -*/ -#define RTEMS_FDT_ERR_BADPATH 5 -/** - * RTEMS_FDT_ERR_BADPHANDLE: Function was passed an invalid phandle value. - * phandle values of 0 and -1 are not permitted. - */ -#define RTEMS_FDT_ERR_BADPHANDLE 6 -/** - * RTEMS_FDT_ERR_BADSTATE: Function was passed an incomplete device tree - * created by the sequential-write functions, which is not sufficiently - * complete for the requested operation. - */ -#define RTEMS_FDT_ERR_BADSTATE 7 - -/* Error codes: codes for bad device tree blobs */ - -/** - * RTEMS_FDT_ERR_TRUNCATED: Structure block of the given device tree ends - * without an RTEMS_FDT_END tag. - */ -#define RTEMS_FDT_ERR_TRUNCATED 8 -/** - * RTEMS_FDT_ERR_BADMAGIC: Given "device tree" appears not to be a device tree - * at all - it is missing the flattened device tree magic number. - */ -#define RTEMS_FDT_ERR_BADMAGIC 9 -/** RTEMS_FDT_ERR_BADVERSION: Given device tree has a version which can't be - * handled by the requested operation. For read-write functions, this may mean - * that rtems_fdt_open_into() is required to convert the tree to the expected - * version. - */ -#define RTEMS_FDT_ERR_BADVERSION 10 -/** - * RTEMS_FDT_ERR_BADSTRUCTURE: Given device tree has a corrupt structure block - * or other serious error (e.g. misnested nodes, or subnodes preceding - * properties). - */ -#define RTEMS_FDT_ERR_BADSTRUCTURE 11 -/** - * RTEMS_FDT_ERR_BADLAYOUT: For read-write functions, the given device tree has - * it's sub-blocks in an order that the function can't handle (memory reserve - * map, then structure, then strings). Use rtems_fdt_open_into() to reorganize - * the tree into a form suitable for the read-write operations. - */ -#define RTEMS_FDT_ERR_BADLAYOUT 12 -/** - * "Can't happen" error indicating a bug in libfdt - */ -#define RTEMS_FDT_ERR_INTERNAL 13 - -/* RTEMS error codes. */ - -/** - * Invalid handle. - */ -#define RTEMS_FDT_ERR_INVALID_HANDLE 100 -/** - * No memory. - */ -#define RTEMS_FDT_ERR_NO_MEMORY 101 -/** - * File not found. - */ -#define RTEMS_FDT_ERR_NOT_FOUND 102 -/** - * Cannot read the DTB into memory. - */ -#define RTEMS_FDT_ERR_READ_FAIL 103 -/** - * The blob cannot be unloaded as it is referenced. - */ -#define RTEMS_FDT_ERR_REFERENCED 104 - -#define RTEMS_FDT_ERR_RTEMS_MIN 100 -#define RTEMS_FDT_ERR_MAX 104 - -/** - * Initialise a handle to a default state. - * - * @param handle The handle to initialise. - */ -void rtems_fdt_init_handle (rtems_fdt_handle* handle); - -/** - * Duplicate a handle. The copy must be released. - * - * @param from Duplicate from this handle. - * @param to Duplicate to this handle. - */ -void rtems_fdt_dup_handle (rtems_fdt_handle* from, rtems_fdt_handle* to); - -/** - * Release a blob from a handle and clear it. - * - * @param handle The handle to check. - */ -void rtems_fdt_release_handle (rtems_fdt_handle* handle); - -/** - * Check if a handle had a valid blob assigned. - * - * @param handle The handle to check. - * @retval true The handle has a valid blob. - * @retval false The handle does not have a valid blob. - */ -bool rtems_fdt_valid_handle (const rtems_fdt_handle* handle); - -/** - * Find a tree node by its full path looking across of loaded blobs.. Each path - * component may omit the unit address portion, but the results of this are - * undefined if any such path component is ambiguous (that is if there are - * multiple nodes at the relevant level matching the given component, - * differentiated only by unit address). - * - * If the handle points to a valid blob it is release and the search starts - * from the first blob. - * - * @param handle The FDT handle assigned to the blob if found else left invalid. - * @param path Full path of the node to locate. - * @param int If less than 0 an error code else the node offset is returned. - */ -int rtems_fdt_find_path_offset (rtems_fdt_handle* handle, const char* path); - -/** - * Load a device tree blob or DTB file into memory and register it on the chain - * of blobs. - * - * @param filename The name of the blob file to load. - * @param handle The handle returns the reference to the blob once load. - * @return int If less than 0 it is an error code else it is the blob descriptor. - */ -int rtems_fdt_load (const char* const filename, rtems_fdt_handle* handle); - -/** - * Register a device tree blob or DTB on to the chain of blobs. - * - * @param blob_desc A pointer to the blob. - * @param handle The handle returns the reference to the blob once load. - * @return int If less than 0 it is an error code else it is the blob descriptor. - */ -int rtems_fdt_register (const void* blob, rtems_fdt_handle* handle); - -/** - * Unload a device tree blob or DTB file and release any memory allocated when - * loading. The blob is removed from the list of registered. - * - * @param blob_desc A valid blob descriptor. - * @return int If less than 0 it is an error code else 0 is return on success. - */ -int rtems_fdt_unload (rtems_fdt_handle* handle); - -/** - * Returns the number of entries in the device tree blob's memory - * reservation map. This does not include the terminating 0,0 entry - * or any other (0,0) entries reserved for expansion. - * - * @param blob_desc A valid blob descriptor. - * @return int The number of entries. - */ -int rtems_fdt_num_mem_rsv (rtems_fdt_handle* handle); - -/** - * Retrieve one memory reserve map entry. On success, *address and *size will - * contain the address and size of the n-th reserve map entry from the device - * tree blob, in native-endian format. - * - * @param blob_desc A valid blob descriptor. - * @param address Pointer to 64-bit variables to hold the addresses. - * @param size Pointer to 64-bit variables to hold the size. - * @return int If less than 0 it is an error code else 0 is returned on - * success. - */ -int rtems_fdt_get_mem_rsv (rtems_fdt_handle* handle, - int n, - uint64_t* address, - uint64_t* size); - -/** - * Find a subnode based on substring. Identical to rtems_fdt_subnode_offset(), - * but only examine the first namelen characters of name for matching the - * subnode name. This is useful for finding subnodes based on a portion of a - * larger string, such as a full path. - * - * @param blob_desc A valid blob descriptor. - * @param arentoffset Structure block offset of a node - * @param name Name of the subnode to locate. - * @param namelen Number of characters of name to consider. - * @return int If less than 0 it is an error code else the node offset is - * returned. - */ -int rtems_fdt_subnode_offset_namelen (rtems_fdt_handle* handle, - int parentoffset, - const char* const name, - int namelen); - -/** - * Find a subnode of a given node at structure block offset parentoffset with - * the given name. The name may include a unit address, in which case - * rtems_fdt_subnode_offset() will find the subnode with that unit address, or - * the unit address may be omitted, in which case rtems_fdt_subnode_offset() - * will find an arbitrary subnode whose name excluding unit address matches the - * given name. - * - * @param blob_desc A valid blob descriptor. - * @param parentoffset Structure block offset of a node. - * @param name The name of the subnode to locate. - * @return int If less than 0 it is an error code else the subnode offset is - * returned. - */ -int rtems_fdt_subnode_offset (rtems_fdt_handle* handle, - int parentoffset, - const char* const name); - -/** - * Find a tree node by its full path. Each path component may omit the unit - * address portion, but the results of this are undefined if any such path - * component is ambiguous (that is if there are multiple nodes at the relevant - * level matching the given component, differentiated only by unit address). - * - * @param handle The FDT handle to the current blob. - * @param path Full path of the node to locate. - * @param int If less than 0 an error code else the node offset is returned. - */ -int rtems_fdt_path_offset (rtems_fdt_handle* handle, const char* path); - -/** - * Retrieve the name of a given node (including unit address) of the device - * tree node at structure block offset @nodeoffset. If @length is non-NULL, - * the length of this name is also returned, in the integer pointed to by - * @length. - * - * @param handle The FDT handle to the current blob. - * @param nodeoffset Structure block offset of the starting node. - * @param length Pointer to an integer variable (will be overwritten) or NULL. - * @return const char* The node's name on success or NULL on error. The length - * if non-NULL will hold the error code. - */ -const char* rtems_fdt_get_name (rtems_fdt_handle* handle, - int nodeoffset, - int* length); - -/** - * Get property value based on substring. Identical to rtems_fdt_getprop(), but - * only examine the first namelen characters of name for matching the property - * name. - * - * @param handle The FDT handle to the current blob. - * @param nodeoffset Offset of the node whose property to find - * @param name The name of the property to find - * @param namelen The number of characters of name to consider - * @param length A pointer to an integer variable (will be overwritten) or - * NULL. - * @return const void* The node's property on success or NULL on error. The - * length if non-NULL will hold the error code. - */ -const void *rtems_fdt_getprop_namelen (rtems_fdt_handle* handle, - int nodeoffset, - const char* const name, - int namelen, - int* length); - -/** - * Retrieve the value of a given property. Retrieves a pointer to the value of - * the property named 'name' of the node at offset nodeoffset (this will be a - * pointer to within the device blob itself, not a copy of the value). If lenp - * is non-NULL, the length of the property value is also returned, in the - * integer pointed to by @length. - * - * @param handle The FDT handle to the current blob. - * @param nodeoffset The offset of the node whose property to find. - * @param name The name of the property to find. - * @param length A pointer to an integer variable (will be overwritten) or - * NULL. - * @return const void* The node's property on success or NULL on error. The - * length if non-NULL will hold the error code. - */ -const void *rtems_fdt_getprop (rtems_fdt_handle* handle, - int nodeoffset, - const char* const name, - int* length); - -/** - * Retrieve the phandle of a given of the device tree node at structure block - * offset nodeoffset. - * - * @param handle The FDT handle to the current blob. - * @oaram nodeoffset The structure block offset of the node. - * return uint32_t The phandle of the node at nodeoffset, on success (!= 0, != - * -1) 0, if the node has no phandle, or another error occurs. - */ -uint32_t rtems_fdt_get_phandle (rtems_fdt_handle* handle, int nodeoffset); - -/** - * Get alias based on substring. Identical to rtems_fdt_get_alias(), but only - * examine the first namelen characters of name for matching the alias name. - * - * @param handle The FDT handle to the current blob. - * @param name The name of the alias th look up. - * @param namelen The number of characters of name to consider. - * @return const char* The alias or NULL. - */ -const char *rtems_fdt_get_alias_namelen (rtems_fdt_handle* handle, - const char* const name, - int namelen); - -/** - * Retreive the path referenced by a given alias. That is, the value of the - * property named 'name' in the node /aliases. - * - * @param handle The FDT handle to the current blob. - * @param name The name of the alias to look up. - * @return const char* A pointer to the expansion of the alias named 'name', of - * it exists NULL, if the given alias or the /aliases node - * does not exist - */ -const char* rtems_fdt_get_alias (rtems_fdt_handle* handle, const char* name); - -/** - * Determine the full path of a node. This function is expensive, as it must - * scan the device tree structure from the start to nodeoffset. It computes the - * full path of the node at offset nodeoffset, and records that path in the - * buffer at buf. - * - * @param handle The FDT handle to the current blob. - * @param nodeoffset The offset of the node whose path to find. - * @param buf A character buffer to contain the returned path (will be - * overwritten) - * @param buflen The size of the character buffer at buf. - * @return int 0 on success of an error code. - */ -int rtems_fdt_get_path (rtems_fdt_handle* handle, - int nodeoffset, - char* buf, - int buflen); - -/** - * Find a specific ancestor of a node at a specific depth from the root (where - * the root itself has depth 0, its immediate subnodes depth 1 and so forth). - * So rtems_fdt_supernode_atdepth_offset(blob, nodeoffset, 0, NULL); will - * always return 0, the offset of the root node. If the node at nodeoffset has - * depth D, then: - * rtems_fdt_supernode_atdepth_offset(blob, nodeoffset, D, NULL); - * will return nodeoffset itself. - * - * @param handle The FDT handle to the current blob. - * @param nodeoffset The offset of the node whose parent to find. - * @param supernodedepth The depth of the ancestor to find. - * @oaram nodedepth The pointer to an integer variable (will be overwritten) or - * NULL - * @return int If less than 0 an error else the node offset. - */ -int rtems_fdt_supernode_atdepth_offset (rtems_fdt_handle* handle, - int nodeoffset, - int supernodedepth, - int* nodedepth); - -/** - * Find the depth of a given node. The root node has depth 0, its immediate - * subnodes depth 1 and so forth. - * - * @note This function is expensive, as it must scan the device tree structure - * from the start to nodeoffset. - * - * @param handle The FDT handle to the current blob. - * @param nodeoffset The offset of the node whose parent to find. - * @return int If less than 0 an error else the node offset. - */ -int rtems_fdt_node_depth (rtems_fdt_handle* handle, int nodeoffset); - -/** - * Find the parent of a given node. This funciton locates the parent node of a - * given node (that is, it finds the offset of the node which contains the node - * at nodeoffset as a subnode). - * - * @note This function is expensive, as it must scan the device tree structure - * from the start to nodeoffset, *twice*. - * - * @param handle The FDT handle to the current blob. - * @param nodeoffset The offset of the node whose parent to find. - * @return int If less than 0 an error else the node offset. - */ -int rtems_fdt_parent_offset (rtems_fdt_handle* handle, int nodeoffset); - -/** - * Find nodes with a given property value. This funtion returns the offset of - * the first node after startoffset, which has a property named propname whose - * value is of length proplen and has value equal to propval; or if startoffset - * is -1, the very first such node in the tree. - * - * To iterate through all nodes matching the criterion, the following idiom can - * be used: - * offset = rtemsfdt_node_offset_by_prop_value(blob, -1, propname, - * propval, proplen); - * while (offset != -RTEMS_FDT_ERR_NOTFOUND) { - * // other code here - * offset = rtems_fdt_node_offset_by_prop_value(fdt, offset, propname, - * propval, proplen); - * } - * - * @note The -1 in the first call to the function, if 0 is used here - * instead, the function will never locate the root node, even if it - * matches the criterion. - * - * @param handle The FDT handle to the current blob. - * @param startoffset Only find nodes after this offset. - * @param propname The property name to check. - * @param propval The property value to search for. - * @param proplen The length of the value in propval. - * @return int The structure block offset of the located node (>= 0, - * >startoffset), on success and an error code is less - * than 0. - */ -int rtems_fdt_node_offset_by_prop_value (rtems_fdt_handle* handle, - int startoffset, - const char* const propname, - const void* propval, - int proplen); - -/** - * Find the node with a given phandle returning the offset of the node which - * has the given phandle value. If there is more than one node in the tree - * with the given phandle (an invalid tree), results are undefined. - * - * @param handle The FDT handle to the current blob. - * @param phandle The phandle value. - * @return int If less than 0 an error else the node offset. - */ -int rtems_fdt_node_offset_by_phandle (rtems_fdt_handle* handle, - uint32_t phandle); - -/** - * Check a node's compatible property returning 0 if the given node contains a - * 'compatible' property with the given string as one of its elements, it - * returns non-zero otherwise, or on error. - * - * @param handle The FDT handle to the current blob. - * @param nodeoffset The offset of a tree node. - * @param compatible The string to match against. - * @retval 0, if the node has a 'compatible' property listing the given string. - * @retval 1, if the node has a 'compatible' property, but it does not list the - * given string - */ -int rtems_fdt_node_check_compatible (rtems_fdt_handle* handle, - int nodeoffset, - const char* const compatible); - -/** - * Find nodes with a given 'compatible' value returning the offset of the first - * node after startoffset, which has a 'compatible' property which lists the - * given compatible string; or if startoffset is -1, the very first such node - * in the tree. - * - * To iterate through all nodes matching the criterion, the following idiom can - * be used: - * - * offset = rtems_fdt_node_offset_by_compatible(blob, -1, compatible); - * while (offset != -RTEMS_FDT_ERR_NOTFOUND) { - * // other code here - * offset = rtems_fdt_node_offset_by_compatible(blob, offset, compatible); - * } - * - * @note The -1 in the first call to the function, if 0 is used here instead, - * the function will never locate the root node, even if it matches the - * criterion. - * - * @param handle The FDT handle to the current blob. - * @param startoffset Only find nodes after this offset. - * @param compatible The 'compatible' string to match against. - * @return int If less than 0 an error else the node offset. - */ -int rtems_fdt_node_offset_by_compatible(rtems_fdt_handle* handle, - int startoffset, - const char* compatible); - -/** - * Traverse to the next node. - * - * @param handle The FDT handle to the current blob. - * @param offset The offset in the blob to start looking for the next node. - * @param depth Pointer to return the depth the node is. - * @return int If less than 0 an error else the node offset. - */ -int rtems_fdt_next_node (rtems_fdt_handle* handle, int offset, int* depth); - -/** - * Return an error string given an error value. - * - * @param errval The error value. - * @return const char* The error string. - */ -const char* rtems_fdt_strerror (int errval); - -/** - * Return a property given a path. - */ -int rtems_fdt_prop_value(const char* const path, - const char* const propname, - void* value, - size_t* size); - -/** - * Create a map given a path the property name and the names of the subnodes of - * the path. - */ -int rtems_fdt_prop_map (const char* const path, - const char* const propname, - const char* const names[], - uint32_t* values, - size_t count); - -/* - * Get a value given a path and a property. - */ -int rtems_fdt_get_value (const char* const path, - const char* const property, - size_t size, - uint32_t* value); - -/** - * Get the number of entries in an FDT handle. - */ -int rtems_fdt_num_entries(rtems_fdt_handle* handle); - -/** - * Get the numbered entry name. Note that the id isn't the same as - * the offset - it's numbered 0, 1, 2 ... num_entries-1 - */ -const char *rtems_fdt_entry_name(rtems_fdt_handle* handle, int id); - -/** - * Get the numbered entry offset. Note that the id isn't the same as - * the offset - it's numbered 0, 1, 2 ... num_entries-1 - */ -int rtems_fdt_entry_offset(rtems_fdt_handle* handle, int id); - -/* - * Helper function to convert the void* property result to a 32bit unsigned int. - */ -uint32_t rtems_fdt_get_uint32 (const void* prop); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/cpukit/libmisc/serdbg/serdbg.h b/cpukit/libmisc/serdbg/serdbg.h deleted file mode 100644 index fe106bce44..0000000000 --- a/cpukit/libmisc/serdbg/serdbg.h +++ /dev/null @@ -1,151 +0,0 @@ -/*===============================================================*\ -| Project: RTEMS remote gdb over serial line | -+-----------------------------------------------------------------+ -| File: serdbg.h | -+-----------------------------------------------------------------+ -| Copyright (c) 2002 IMD | -| Ingenieurbuero fuer Microcomputertechnik Th. Doerfler | -| | -| all rights reserved | -+-----------------------------------------------------------------+ -| this file declares intialization functions to add | -| a gdb remote debug stub to an RTEMS system | -| | -+-----------------------------------------------------------------+ -| date history ID | -| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | -| 04.04.02 creation doe | -\*===============================================================*/ -#ifndef _SERDBG_H -#define _SERDBG_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - uint32_t baudrate; /* debug baud rate, e.g. 57600 */ - void (*callout)(void); /* callout pointer during polling */ - int (*open_io)(const char *dev_name, uint32_t baudrate); /* I/O open fnc */ - const char *devname; /* debug device, e.g. "/dev/tty01" */ - bool skip_init_bkpt; /* if TRUE, do not stop when initializing */ -} serdbg_conf_t; - -/* - * must be defined in init module... - */ -extern serdbg_conf_t serdbg_conf; - - -/*=========================================================================*\ -| Function: | -\*-------------------------------------------------------------------------*/ -void putDebugChar -( -/*-------------------------------------------------------------------------*\ -| Purpose: | -| send character to remote debugger | -+---------------------------------------------------------------------------+ -| Input Parameters: | -\*-------------------------------------------------------------------------*/ - char c /* char to send */ - ); -/*-------------------------------------------------------------------------*\ -| Return Value: | -| | -\*=========================================================================*/ - -/*=========================================================================*\ -| Function: | -\*-------------------------------------------------------------------------*/ -int getDebugChar -( -/*-------------------------------------------------------------------------*\ -| Purpose: | -| get character from remote debugger | -+---------------------------------------------------------------------------+ -| Input Parameters: | -\*-------------------------------------------------------------------------*/ - void /* */ - ); -/*-------------------------------------------------------------------------*\ -| Return Value: | -| | -\*=========================================================================*/ - -/*=========================================================================*\ -| Function: | -\*-------------------------------------------------------------------------*/ -void serdbg_exceptionHandler -( -/*-------------------------------------------------------------------------*\ -| Purpose: | -| hook directly to an exception vector | -+---------------------------------------------------------------------------+ -| Input Parameters: | -\*-------------------------------------------------------------------------*/ - int vecnum, /* vector index to hook at */ - void *vector /* address of handler function */ - ); -/*-------------------------------------------------------------------------*\ -| Return Value: | -| | -\*=========================================================================*/ - -/*=========================================================================*\ -| Function: | -\*-------------------------------------------------------------------------*/ -int serdbg_init -( -/*-------------------------------------------------------------------------*\ -| Purpose: | -| initialize remote gdb session over serial line | -+---------------------------------------------------------------------------+ -| Input Parameters: | -\*-------------------------------------------------------------------------*/ - void - ); -/*-------------------------------------------------------------------------*\ -| Return Value: | -| rtems_status_code | -\*=========================================================================*/ - -/* - * stuff from serdbgio.c - */ -/*=========================================================================*\ -| Function: | -\*-------------------------------------------------------------------------*/ -int serdbg_open - -/*-------------------------------------------------------------------------*\ -| Purpose: | -| try to open given serial debug port | -+---------------------------------------------------------------------------+ -| Input Parameters: | -\*-------------------------------------------------------------------------*/ -( - const char *dev_name, /* name of device to open */ - uint32_t baudrate /* baud rate to use */ - ); -/*-------------------------------------------------------------------------*\ -| Return Value: | -| 0 on success, -1 and errno otherwise | -\*=========================================================================*/ - - -extern int serdbg_init_dbg(void); - -/* - * Assumed to be provided by the BSP - */ -extern void set_debug_traps(void); -extern void breakpoint(void); -#ifdef __cplusplus -} -#endif - -#endif /* _SERDBG_H */ diff --git a/cpukit/libmisc/serdbg/serdbgcnf.h b/cpukit/libmisc/serdbg/serdbgcnf.h deleted file mode 100644 index 9d4087ae69..0000000000 --- a/cpukit/libmisc/serdbg/serdbgcnf.h +++ /dev/null @@ -1,91 +0,0 @@ -/** - * @file - * - * @brief Adds a GDB remote Debug Stub to an RTEMS System - */ - -/*===============================================================*\ -| Project: RTEMS configure remote gdb over serial line | -+-----------------------------------------------------------------+ -| File: serdbgcnf.h | -+-----------------------------------------------------------------+ -| Copyright (c) 2002 IMD | -| Ingenieurbuero fuer Microcomputertechnik Th. Doerfler | -| | -| all rights reserved | -+-----------------------------------------------------------------+ -| this file declares intialization functions to add | -| a gdb remote debug stub to an RTEMS system | -| | -+-----------------------------------------------------------------+ -| date history ID | -| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | -| 13.05.02 creation doe | -\*===============================================================*/ -#ifndef _SERDBGCNF_H -#define _SERDBGCNF_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef CONFIGURE_INIT - -/* - * fallback for baud rate to use - */ -#ifndef CONFIGURE_SERDBG_BAUDRATE -#define CONFIGURE_SERDBG_BAUDRATE 9600 -#endif - -/* - * fallback for device name to use - */ -#ifndef CONFIGURE_SERDBG_DEVNAME -#define CONFIGURE_SERDBG_DEVNAME "/dev/tty01" -#endif - -/* - * fill in serdbg_conf structure - */ -serdbg_conf_t serdbg_conf = { - CONFIGURE_SERDBG_BAUDRATE, - -#ifdef CONFIGURE_SERDBG_CALLOUT - CONFIGURE_SERDBG_CALLOUT, -#else - NULL, -#endif - -#ifdef CONFIGURE_SERDBG_USE_POLLED_TERMIOS - serdbg_open, -#else - NULL, -#endif - - CONFIGURE_SERDBG_DEVNAME, - -#ifdef CONFIGURE_SERDBG_SKIP_INIT_BKPT - true, -#else - false, -#endif -}; - -int serdbg_init(void) { -#ifdef CONFIGURE_USE_SERDBG - return serdbg_init_dbg(); -#else - return 0; -#endif -} - -#endif /* CONFIGURE_INIT */ - -#ifdef __cplusplus -} -#endif - -#endif /* _SERDBGCNF_H */ diff --git a/cpukit/libmisc/serdbg/termios_printk.h b/cpukit/libmisc/serdbg/termios_printk.h deleted file mode 100644 index dcb183533a..0000000000 --- a/cpukit/libmisc/serdbg/termios_printk.h +++ /dev/null @@ -1,101 +0,0 @@ -/*===============================================================*\ -| Project: RTEMS remote gdb over serial line | -+-----------------------------------------------------------------+ -| File: termios_printk.h | -+-----------------------------------------------------------------+ -| Copyright (c) 2002 IMD | -| Ingenieurbuero fuer Microcomputertechnik Th. Doerfler | -| | -| all rights reserved | -+-----------------------------------------------------------------+ -| this file declares intialization functions to add | -| printk polled output via termios polled drivers | -| | -+-----------------------------------------------------------------+ -| date history ID | -| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | -| 13.04.02 creation doe | -\*===============================================================*/ -#ifndef _TERMIOS_PRINTK_H -#define _TERMIOS_PRINTK_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - uint32_t baudrate; /* debug baud rate, e.g. 57600 */ - void (*callout)(void); /* callout pointer during polling */ - const char *devname; /* debug device, e.g. "/dev/tty01" */ -} termios_printk_conf_t; - -/* - * must be defined in init module... - */ -extern termios_printk_conf_t termios_printk_conf; - -/*=========================================================================*\ -| Function: | -\*-------------------------------------------------------------------------*/ -void termios_printk_outputchar -/*-------------------------------------------------------------------------*\ -| Purpose: | -| send one character to serial port | -+---------------------------------------------------------------------------+ -| Input Parameters: | -\*-------------------------------------------------------------------------*/ -( - char c /* character to print */ - ); -/*-------------------------------------------------------------------------*\ -| Return Value: | -| | -\*=========================================================================*/ - -/*=========================================================================*\ -| Function: | -\*-------------------------------------------------------------------------*/ -int termios_printk_inputchar -/*-------------------------------------------------------------------------*\ -| Purpose: | -| wait for one character from serial port | -+---------------------------------------------------------------------------+ -| Input Parameters: | -\*-------------------------------------------------------------------------*/ -( - void /* none */ - ); -/*-------------------------------------------------------------------------*\ -| Return Value: | -| received character | -\*=========================================================================*/ - - -/*=========================================================================*\ -| Function: | -\*-------------------------------------------------------------------------*/ -int termios_printk_open - -/*-------------------------------------------------------------------------*\ -| Purpose: | -| try to open given serial debug port | -+---------------------------------------------------------------------------+ -| Input Parameters: | -\*-------------------------------------------------------------------------*/ -( - const char *dev_name, /* name of device to open */ - uint32_t baudrate /* baud rate to use */ - ); -/*-------------------------------------------------------------------------*\ -| Return Value: | -| 0 on success, -1 and errno otherwise | -\*=========================================================================*/ - -#ifdef __cplusplus -} -#endif - -#endif /* _TERMIOS_PRINTK_H */ diff --git a/cpukit/libmisc/serdbg/termios_printk_cnf.h b/cpukit/libmisc/serdbg/termios_printk_cnf.h deleted file mode 100644 index 03c3090c38..0000000000 --- a/cpukit/libmisc/serdbg/termios_printk_cnf.h +++ /dev/null @@ -1,81 +0,0 @@ -/** - * @file - * - * @brief Adds printk Support via Polled termios - */ - -/*===============================================================*\ -| Project: RTEMS configure remote gdb over serial line | -+-----------------------------------------------------------------+ -| File: termios_printk_cnf.h | -+-----------------------------------------------------------------+ -| Copyright (c) 2002 IMD | -| Ingenieurbuero fuer Microcomputertechnik Th. Doerfler | -| | -| all rights reserved | -+-----------------------------------------------------------------+ -| this file declares intialization functions to add | -| printk support via polled termios | -| | -+-----------------------------------------------------------------+ -| date history ID | -| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | -| 13.05.02 creation doe | -\*===============================================================*/ -#ifndef _TERMIOS_PRINTK_CNF_H -#define _TERMIOS_PRINTK_CNF_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef CONFIGURE_INIT - -/* - * fallback for baud rate to use - */ -#ifndef CONFIGURE_TERMIOS_PRINTK_BAUDRATE -#define CONFIGURE_TERMIOS_PRINTK_BAUDRATE 9600 -#endif - -/* - * fallback for device name to use - */ -#ifndef CONFIGURE_TERMIOS_PRINTK_DEVNAME -#define CONFIGURE_TERMIOS_PRINTK_DEVNAME "/dev/console" -#endif - -#ifdef CONFIGURE_USE_TERMIOS_PRINTK -/* - * fill in termios_printk_conf structure - */ -termios_printk_conf_t termios_printk_conf = { - CONFIGURE_TERMIOS_PRINTK_BAUDRATE, - -#ifdef CONFIGURE_TERMIOS_PRINTK_CALLOUT - CONFIGURE_TERMIOS_PRINTK_CALLOUT, -#else - NULL, -#endif - CONFIGURE_TERMIOS_PRINTK_DEVNAME, -}; -#endif - -int termios_printk_init(void) { -#ifdef CONFIGURE_USE_TERMIOS_PRINTK - return termios_printk_open(termios_printk_conf.devname, - termios_printk_conf.baudrate); -#else - return 0; -#endif -} - -#endif /* CONFIGURE_INIT */ - -#ifdef __cplusplus -} -#endif - -#endif /* _TERMIOS_PRINTK_CNF_H */ diff --git a/cpukit/libmisc/shell/shell.h b/cpukit/libmisc/shell/shell.h deleted file mode 100644 index 98ddf0a958..0000000000 --- a/cpukit/libmisc/shell/shell.h +++ /dev/null @@ -1,385 +0,0 @@ -/** - * @file rtems/shell.h - * - * @brief Instantatiate a New Terminal Shell - */ - -/* - * Author: - * - * WORK: fernando.ruiz@ctv.es - * HOME: correo@fernando-ruiz.com - * - * Thanks at: - * Chris Johns - */ - -#ifndef __RTEMS_SHELL_H__ -#define __RTEMS_SHELL_H__ - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Some key labels to define special keys. - */ - -#define RTEMS_SHELL_KEYS_EXTENDED (0x8000) -#define RTEMS_SHELL_KEYS_NORMAL_MASK (0x00ff) -#define RTEMS_SHELL_KEYS_INS (0) -#define RTEMS_SHELL_KEYS_DEL (1) -#define RTEMS_SHELL_KEYS_UARROW (2) -#define RTEMS_SHELL_KEYS_DARROW (3) -#define RTEMS_SHELL_KEYS_LARROW (4) -#define RTEMS_SHELL_KEYS_RARROW (5) -#define RTEMS_SHELL_KEYS_HOME (6) -#define RTEMS_SHELL_KEYS_END (7) -#define RTEMS_SHELL_KEYS_F1 (8) -#define RTEMS_SHELL_KEYS_F2 (9) -#define RTEMS_SHELL_KEYS_F3 (10) -#define RTEMS_SHELL_KEYS_F4 (11) -#define RTEMS_SHELL_KEYS_F5 (12) -#define RTEMS_SHELL_KEYS_F6 (13) -#define RTEMS_SHELL_KEYS_F7 (14) -#define RTEMS_SHELL_KEYS_F8 (15) -#define RTEMS_SHELL_KEYS_F9 (16) -#define RTEMS_SHELL_KEYS_F10 (17) - -typedef bool (*rtems_shell_login_check_t)( - const char * /* user */, - const char * /* passphrase */ -); - -extern bool rtems_shell_login_prompt( - FILE *in, - FILE *out, - const char *device, - rtems_shell_login_check_t check -); - -extern bool rtems_shell_login_check( - const char *user, - const char *passphrase -); - -typedef int (*rtems_shell_command_t)(int argc, char **argv); - -struct rtems_shell_cmd_tt; -typedef struct rtems_shell_cmd_tt rtems_shell_cmd_t; - -struct rtems_shell_cmd_tt { - const char *name; - const char *usage; - const char *topic; - rtems_shell_command_t command; - rtems_shell_cmd_t *alias; - rtems_shell_cmd_t *next; - mode_t mode; - uid_t uid; - gid_t gid; -}; - -typedef struct { - const char *name; - const char *alias; -} rtems_shell_alias_t; - -struct rtems_shell_topic_tt; -typedef struct rtems_shell_topic_tt rtems_shell_topic_t; - -struct rtems_shell_topic_tt { - const char *topic; - rtems_shell_topic_t *next; -}; - -/* - * The return value has RTEMS_SHELL_KEYS_EXTENDED set if the key - * is extended, ie a special key. - */ -extern unsigned int rtems_shell_getchar(FILE *in); - -extern rtems_shell_cmd_t * rtems_shell_lookup_cmd(const char *cmd); - -extern rtems_shell_cmd_t *rtems_shell_add_cmd_struct( - rtems_shell_cmd_t *shell_cmd -); - -rtems_shell_cmd_t * rtems_shell_add_cmd( - const char *cmd, - const char *topic, - const char *usage, - rtems_shell_command_t command -); - -extern rtems_shell_cmd_t * rtems_shell_alias_cmd( - const char *cmd, - const char *alias -); - -extern int rtems_shell_make_args( - char *commandLine, - int *argc_p, - char **argv_p, - int max_args -); - -extern rtems_shell_topic_t * rtems_shell_lookup_topic( - const char *topic -); - -extern bool rtems_shell_can_see_cmd( - const rtems_shell_cmd_t *shell_cmd -); - -extern int rtems_shell_execute_cmd( - const char *cmd, int argc, char *argv[] -); - -/* - * Call to set up the shell environment if you need to execute commands before - * running a shell. - */ -extern void rtems_shell_init_environment( - void -); - -extern int rtems_shell_cat_file( - FILE *out, - const char *name -); - -extern void rtems_shell_write_file( - const char *name, - const char *content -); - -extern int rtems_shell_script_file( - int argc, - char **argv -); - -/** - * Initialise the shell creating tasks to login and run the shell - * sessions. - * - * @param task_name Name of the shell task. - * @param task_stacksize The size of the stack. If 0 the default size is used. - * @param task_priority The priority the shell runs at. - * @param forever Repeat logins. - * @param wait Caller should block until shell exits. - * @param login_check User login check function, NULL disables login checks. - * - */ -extern rtems_status_code rtems_shell_init( - const char *task_name, - size_t task_stacksize, - rtems_task_priority task_priority, - const char *devname, - bool forever, - bool wait, - rtems_shell_login_check_t login_check -); - -/** - * Run a shell script creating a shell tasks to execute the command under. - * - * @param task_name Name of the shell task. - * @param task_stacksize The size of the stack. If 0 the default size is used. - * @param task_priority The priority the shell runs at. - * @param input The file of commands. Can be 'stdin' to use stdin. - * @param output The output file to write commands to. Can be 'stdout', - * 'stderr' or '/dev/null'. - * @param output_append Append the output to the file or truncate the file. - * Create if it does not exist. - * @param wait Wait for the script to finish. - */ -extern rtems_status_code rtems_shell_script( - const char *task_name, - size_t task_stacksize, /* 0 default*/ - rtems_task_priority task_priority, - const char *input, - const char *output, - bool output_append, - bool wait, - bool echo -); - -/** - * Private environment associated with each shell instance. - */ -typedef struct { - /** 'S','E','N','V': Shell Environment */ - rtems_name magic; - const char *devname; - const char *taskname; - bool exit_shell; /* logout */ - bool forever; /* repeat login */ - int errorlevel; - bool echo; - char cwd[256]; - const char *input; - const char *output; - bool output_append; - rtems_id wake_on_end; - rtems_shell_login_check_t login_check; - - /** - * @brief The real and effective UID of the shell task in case no login check - * is present. - */ - uid_t uid; - - /** - * @brief The real and effective GID of the shell task in case no login check - * is present. - */ - gid_t gid; -} rtems_shell_env_t; - -bool rtems_shell_main_loop( - rtems_shell_env_t *rtems_shell_env -); - -extern const rtems_shell_env_t rtems_global_shell_env; - -rtems_shell_env_t *rtems_shell_get_current_env(void); -void rtems_shell_dup_current_env(rtems_shell_env_t *); - -/* - * The types of file systems we can mount. We have them broken out - * out like this so they can be configured by shellconfig.h. The - * mount command needs special treatment due to some file systems - * being dependent on the network stack and some not. If we had - * all possible file systems being included it would force the - * networking stack into the applcation and this may not be - * required. - */ -struct rtems_shell_filesystems_tt; -typedef struct rtems_shell_filesystems_tt rtems_shell_filesystems_t; - -typedef int (*rtems_shell_filesystems_mounter_t)( - const char* driver, - const char* path, - rtems_shell_filesystems_t* fs, - rtems_filesystem_options_t options -); - -struct rtems_shell_filesystems_tt { - rtems_chain_node link; - const char *name; - int driver_needed; - const rtems_filesystem_operations_table *fs_ops; - rtems_shell_filesystems_mounter_t mounter; -}; - -/** - * This method dynamically builds the command line prompt string - * and places it in @a prompt. - * - * @param[in] shell_env is the shell execution environment - * @param[in] prompt is a pointer to a string buffer area - * @param[in] size is length of the prompt buffer area - * - * @return This method fills in the memory pointed to by @a prompt. - * - * @note An application specific implementation can be provided - * by the user. - */ -extern void rtems_shell_get_prompt( - rtems_shell_env_t *shell_env, - char *prompt, - size_t size -); - -/** - * Helper for the mount command. - * - * @param[in] driver The path to the driver. - * @param[in] path The path to mount on. - * @param[in] fs The file system definition. - * @param[in] options Special file system options. - */ -extern int rtems_shell_libc_mounter( - const char* driver, - const char* path, - rtems_shell_filesystems_t* fs, - rtems_filesystem_options_t options -); - -/** - * Add a new file system mount configuration to the mount command. - * - * @param[in] fs The file system mount data. - */ -extern void rtems_shell_mount_add_fsys(rtems_shell_filesystems_t* fs); - -/** - * Delete file system mount configuration from the mount command. - * - * @param[in] fs The file system mount data to remove. - */ -extern void rtems_shell_mount_del_fsys(rtems_shell_filesystems_t* fs); - -typedef void (*rtems_shell_wait_for_input_notification)( - int fd, - int seconds_remaining, - void *arg -); - -/** - * @brief Waits for input. - * - * @retval RTEMS_SUCCESSFUL Input detected. - * @retval RTEMS_TIMEOUT Timeout expired. - * @retval RTEMS_UNSATISFIED Cannot change or restore termios attributes. - */ -extern rtems_status_code rtems_shell_wait_for_input( - int fd, - int timeout_in_seconds, - rtems_shell_wait_for_input_notification notification, - void *notification_arg -); - -/** - * @brief Waits for explicit input. - * - * @param desired_input An explicit unsigned character to wait for or -1 to - * accept any input. - * - * @retval RTEMS_SUCCESSFUL Input detected. - * @retval RTEMS_TIMEOUT Timeout expired. - * @retval RTEMS_UNSATISFIED Cannot change or restore termios attributes. - */ -extern rtems_status_code rtems_shell_wait_for_explicit_input( - int fd, - int timeout_in_seconds, - rtems_shell_wait_for_input_notification notification, - void *notification_arg, - int desired_input -); - -extern int rtems_shell_main_monitor(int argc, char **argv); - -/* - * Provide these commands for application use, as their implementation - * is tedious. - */ -int rtems_shell_main_mv(int argc, char *argv[]); -int rtems_shell_main_cp(int argc, char *argv[]); -int rtems_shell_main_rm(int argc, char *argv[]); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/libmisc/shell/shellconfig.h b/cpukit/libmisc/shell/shellconfig.h deleted file mode 100644 index 9f68b313fb..0000000000 --- a/cpukit/libmisc/shell/shellconfig.h +++ /dev/null @@ -1,554 +0,0 @@ -/** - * @file rtems/shellconfig.h - * - * RTEMS Shell Command Set Configuration - */ - -/* - * COPYRIGHT (c) 1989-2012. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SHELL_CONFIG_h -#define _RTEMS_SHELL_CONFIG_h - -#include - -/* - * Externs for all command definition structures - */ -extern rtems_shell_cmd_t rtems_shell_HELP_Command; -extern rtems_shell_cmd_t rtems_shell_ALIAS_Command; -extern rtems_shell_cmd_t rtems_shell_TIME_Command; -extern rtems_shell_cmd_t rtems_shell_CMDLS_Command; -extern rtems_shell_cmd_t rtems_shell_CMDCHOWN_Command; -extern rtems_shell_cmd_t rtems_shell_CMDCHMOD_Command; -extern rtems_shell_cmd_t rtems_shell_LOGOFF_Command; -extern rtems_shell_cmd_t rtems_shell_SETENV_Command; -extern rtems_shell_cmd_t rtems_shell_GETENV_Command; -extern rtems_shell_cmd_t rtems_shell_UNSETENV_Command; - -extern rtems_shell_cmd_t rtems_shell_MDUMP_Command; -extern rtems_shell_cmd_t rtems_shell_WDUMP_Command; -extern rtems_shell_cmd_t rtems_shell_LDUMP_Command; -extern rtems_shell_cmd_t rtems_shell_MEDIT_Command; -extern rtems_shell_cmd_t rtems_shell_MFILL_Command; -extern rtems_shell_cmd_t rtems_shell_MMOVE_Command; - -extern rtems_shell_cmd_t rtems_shell_JOEL_Command; -extern rtems_shell_cmd_t rtems_shell_DATE_Command; -extern rtems_shell_cmd_t rtems_shell_ECHO_Command; -extern rtems_shell_cmd_t rtems_shell_EDIT_Command; -extern rtems_shell_cmd_t rtems_shell_SLEEP_Command; -extern rtems_shell_cmd_t rtems_shell_ID_Command; -extern rtems_shell_cmd_t rtems_shell_TTY_Command; -extern rtems_shell_cmd_t rtems_shell_WHOAMI_Command; - -extern rtems_shell_cmd_t rtems_shell_CP_Command; -extern rtems_shell_cmd_t rtems_shell_PWD_Command; -extern rtems_shell_cmd_t rtems_shell_LS_Command; -extern rtems_shell_cmd_t rtems_shell_CHDIR_Command; -extern rtems_shell_cmd_t rtems_shell_MKDIR_Command; -extern rtems_shell_cmd_t rtems_shell_RMDIR_Command; -extern rtems_shell_cmd_t rtems_shell_CHROOT_Command; -extern rtems_shell_cmd_t rtems_shell_CHMOD_Command; -extern rtems_shell_cmd_t rtems_shell_CAT_Command; -extern rtems_shell_cmd_t rtems_shell_MKRFS_Command; -extern rtems_shell_cmd_t rtems_shell_MSDOSFMT_Command; -extern rtems_shell_cmd_t rtems_shell_MSDOSFMT_Alias; -extern rtems_shell_cmd_t rtems_shell_MV_Command; -extern rtems_shell_cmd_t rtems_shell_RM_Command; -extern rtems_shell_cmd_t rtems_shell_LN_Command; -extern rtems_shell_cmd_t rtems_shell_MKNOD_Command; -extern rtems_shell_cmd_t rtems_shell_UMASK_Command; -extern rtems_shell_cmd_t rtems_shell_LSOF_Command; -extern rtems_shell_cmd_t rtems_shell_MOUNT_Command; -extern rtems_shell_cmd_t rtems_shell_UNMOUNT_Command; -extern rtems_shell_cmd_t rtems_shell_BLKSYNC_Command; -extern rtems_shell_cmd_t rtems_shell_BLKSTATS_Command; -extern rtems_shell_cmd_t rtems_shell_FDISK_Command; -extern rtems_shell_cmd_t rtems_shell_DD_Command; -extern rtems_shell_cmd_t rtems_shell_HEXDUMP_Command; -extern rtems_shell_cmd_t rtems_shell_DEBUGRFS_Command; -extern rtems_shell_cmd_t rtems_shell_DF_Command; -extern rtems_shell_cmd_t rtems_shell_MD5_Command; - -extern rtems_shell_cmd_t rtems_shell_RTC_Command; - -extern rtems_shell_cmd_t rtems_shell_SHUTDOWN_Command; -extern rtems_shell_cmd_t rtems_shell_CPUINFO_Command; -extern rtems_shell_cmd_t rtems_shell_CPUUSE_Command; -extern rtems_shell_cmd_t rtems_shell_TOP_Command; -extern rtems_shell_cmd_t rtems_shell_STACKUSE_Command; -extern rtems_shell_cmd_t rtems_shell_PERIODUSE_Command; -extern rtems_shell_cmd_t rtems_shell_PROFREPORT_Command; -extern rtems_shell_cmd_t rtems_shell_WKSPACE_INFO_Command; -extern rtems_shell_cmd_t rtems_shell_MALLOC_INFO_Command; -extern rtems_shell_cmd_t rtems_shell_RTRACE_Command; -#if RTEMS_NETWORKING - extern rtems_shell_cmd_t rtems_shell_IFCONFIG_Command; - extern rtems_shell_cmd_t rtems_shell_ROUTE_Command; - extern rtems_shell_cmd_t rtems_shell_NETSTATS_Command; - extern rtems_shell_cmd_t rtems_shell_PING_Command; -#endif - -/* - * Extern for System commands - */ -extern rtems_shell_cmd_t rtems_shell_DRVMGR_Command; -extern rtems_shell_cmd_t rtems_shell_PCI_Command; - -extern rtems_shell_cmd_t * const rtems_shell_Initial_commands[]; - -/* - * Extern for alias commands - */ -extern rtems_shell_alias_t rtems_shell_DIR_Alias; -extern rtems_shell_alias_t rtems_shell_CD_Alias; -extern rtems_shell_alias_t rtems_shell_EXIT_Alias; - -extern rtems_shell_alias_t * const rtems_shell_Initial_aliases[]; - -/* - * If we are configured to alias a command, then make sure the underlying - * command is configured. - */ - -#if !defined(CONFIGURE_SHELL_COMMANDS_ALL) - #if defined(CONFIGURE_SHELL_COMMANDS_DIR) && \ - !defined(CONFIGURE_SHELL_COMMANDS_LS) - #define CONFIGURE_SHELL_COMMAND_LS - #endif - - #if defined(CONFIGURE_SHELL_COMMANDS_CD) && \ - !defined(CONFIGURE_SHELL_COMMANDS_CHDIR) - #define CONFIGURE_SHELL_COMMAND_CHDIR - #endif - - #if defined(CONFIGURE_SHELL_COMMANDS_EXIT) && \ - !defined(CONFIGURE_SHELL_COMMANDS_LOGOFF) - #define CONFIGURE_SHELL_COMMAND_LOGOFF - #endif -#endif - -#if defined(CONFIGURE_SHELL_COMMANDS_INIT) - rtems_shell_alias_t * const rtems_shell_Initial_aliases[] = { - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_DIR)) || \ - defined(CONFIGURE_SHELL_COMMAND_DIR) - &rtems_shell_DIR_Alias, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_CD)) || \ - defined(CONFIGURE_SHELL_COMMAND_CD) - &rtems_shell_CD_Alias, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_EXIT)) || \ - defined(CONFIGURE_SHELL_COMMAND_EXIT) - &rtems_shell_EXIT_Alias, - #endif - - /* - * User defined shell aliases - */ - #if defined(CONFIGURE_SHELL_USER_ALIASES) - CONFIGURE_SHELL_USER_ALIASES, - #endif - NULL - }; - - rtems_shell_cmd_t * const rtems_shell_Initial_commands[] = { - /* - * General comamnds that should be present - */ - &rtems_shell_HELP_Command, - &rtems_shell_ALIAS_Command, - &rtems_shell_TIME_Command, - - /* - * Common commands that can be optional - */ - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_CMDLS)) || \ - defined(CONFIGURE_SHELL_COMMAND_CMDLS) - &rtems_shell_CMDLS_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_CMDCHOWN)) || \ - defined(CONFIGURE_SHELL_COMMAND_CMDCHOWN) - &rtems_shell_CMDCHOWN_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_CMDCHMOD)) || \ - defined(CONFIGURE_SHELL_COMMAND_CMDCHMOD) - &rtems_shell_CMDCHMOD_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_JOEL)) || \ - defined(CONFIGURE_SHELL_COMMAND_JOEL) - &rtems_shell_JOEL_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_DATE)) || \ - defined(CONFIGURE_SHELL_COMMAND_DATE) - &rtems_shell_DATE_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_ECHO)) || \ - defined(CONFIGURE_SHELL_COMMAND_ECHO) - &rtems_shell_ECHO_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_EDIT)) || \ - defined(CONFIGURE_SHELL_COMMAND_EDIT) - &rtems_shell_EDIT_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_SLEEP)) || \ - defined(CONFIGURE_SHELL_COMMAND_SLEEP) - &rtems_shell_SLEEP_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_ID)) || \ - defined(CONFIGURE_SHELL_COMMAND_ID) - &rtems_shell_ID_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_TTY)) || \ - defined(CONFIGURE_SHELL_COMMAND_TTY) - &rtems_shell_TTY_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_WHOAMI)) || \ - defined(CONFIGURE_SHELL_COMMAND_WHOAMI) - &rtems_shell_WHOAMI_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_LOGOFF)) || \ - defined(CONFIGURE_SHELL_COMMAND_LOGOFF) - &rtems_shell_LOGOFF_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_SETENV)) || \ - defined(CONFIGURE_SHELL_COMMAND_SETENV) - &rtems_shell_SETENV_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_GETENV)) || \ - defined(CONFIGURE_SHELL_COMMAND_GETENV) - &rtems_shell_GETENV_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_CRLENV)) || \ - defined(CONFIGURE_SHELL_COMMAND_UNSETENV) - &rtems_shell_UNSETENV_Command, - #endif - - /* - * Memory printing/modification family commands - */ - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_MDUMP)) || \ - defined(CONFIGURE_SHELL_COMMAND_MDUMP) - &rtems_shell_MDUMP_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_WDUMP)) || \ - defined(CONFIGURE_SHELL_COMMAND_WDUMP) - &rtems_shell_WDUMP_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_LDUMP)) || \ - defined(CONFIGURE_SHELL_COMMAND_LDUMP) - &rtems_shell_LDUMP_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_MEDIT)) || \ - defined(CONFIGURE_SHELL_COMMAND_MEDIT) - &rtems_shell_MEDIT_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_MFILL)) || \ - defined(CONFIGURE_SHELL_COMMAND_MFILL) - &rtems_shell_MFILL_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_MMOVE)) || \ - defined(CONFIGURE_SHELL_COMMAND_MMOVE) - &rtems_shell_MMOVE_Command, - #endif - - /* - * File and directory commands - */ - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_CP)) || \ - defined(CONFIGURE_SHELL_COMMAND_CP) - &rtems_shell_CP_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_PWD)) || \ - defined(CONFIGURE_SHELL_COMMAND_PWD) - &rtems_shell_PWD_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_LS)) || \ - defined(CONFIGURE_SHELL_COMMAND_LS) - &rtems_shell_LS_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_CHDIR)) || \ - defined(CONFIGURE_SHELL_COMMAND_CHDIR) - &rtems_shell_CHDIR_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_MKDIR)) || \ - defined(CONFIGURE_SHELL_COMMAND_MKDIR) - &rtems_shell_MKDIR_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_RMDIR)) || \ - defined(CONFIGURE_SHELL_COMMAND_RMDIR) - &rtems_shell_RMDIR_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_CHROOT)) || \ - defined(CONFIGURE_SHELL_COMMAND_CHROOT) - &rtems_shell_CHROOT_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_CHMOD)) || \ - defined(CONFIGURE_SHELL_COMMAND_CHMOD) - &rtems_shell_CHMOD_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_CAT)) || \ - defined(CONFIGURE_SHELL_COMMAND_CAT) - &rtems_shell_CAT_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_MKRFS)) || \ - defined(CONFIGURE_SHELL_COMMAND_MKRFS) - &rtems_shell_MKRFS_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_MSDOSFMT)) || \ - defined(CONFIGURE_SHELL_COMMAND_MSDOSFMT) - &rtems_shell_MSDOSFMT_Command, - &rtems_shell_MSDOSFMT_Alias, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_MV)) || \ - defined(CONFIGURE_SHELL_COMMAND_MV) - &rtems_shell_MV_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_RM)) || \ - defined(CONFIGURE_SHELL_COMMAND_RM) - &rtems_shell_RM_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_LN)) || \ - defined(CONFIGURE_SHELL_COMMAND_LN) - &rtems_shell_LN_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_MKNOD)) || \ - defined(CONFIGURE_SHELL_COMMAND_MKNOD) - &rtems_shell_MKNOD_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_UMASK)) || \ - defined(CONFIGURE_SHELL_COMMAND_UMASK) - &rtems_shell_UMASK_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_LSOF)) || \ - defined(CONFIGURE_SHELL_COMMAND_LSOF) - &rtems_shell_LSOF_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_MOUNT)) || \ - defined(CONFIGURE_SHELL_COMMAND_MOUNT) - &rtems_shell_MOUNT_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_UNMOUNT)) || \ - defined(CONFIGURE_SHELL_COMMAND_UNMOUNT) - &rtems_shell_UNMOUNT_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_BLKSYNC)) || \ - defined(CONFIGURE_SHELL_COMMAND_BLKSYNC) - &rtems_shell_BLKSYNC_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_BLKSTATS)) || \ - defined(CONFIGURE_SHELL_COMMAND_BLKSTATS) - &rtems_shell_BLKSTATS_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_FDISK)) || \ - defined(CONFIGURE_SHELL_COMMAND_FDISK) - &rtems_shell_FDISK_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_DD)) || \ - defined(CONFIGURE_SHELL_COMMAND_DD) - &rtems_shell_DD_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_HEXDUMP)) || \ - defined(CONFIGURE_SHELL_COMMAND_HEXDUMP) - &rtems_shell_HEXDUMP_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_DEBUGRFS)) || \ - defined(CONFIGURE_SHELL_COMMAND_DEBUGRFS) - &rtems_shell_DEBUGRFS_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_DF)) || \ - defined(CONFIGURE_SHELL_COMMAND_DF) - &rtems_shell_DF_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_MD5)) || \ - defined(CONFIGURE_SHELL_COMMAND_MD5) - &rtems_shell_MD5_Command, - #endif - - /* - * RTEMS Related commands - */ - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_SHUTDOWN)) || \ - defined(CONFIGURE_SHELL_COMMAND_SHUTDOWN) - &rtems_shell_SHUTDOWN_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_CPUINFO)) || \ - defined(CONFIGURE_SHELL_COMMAND_CPUINFO) - &rtems_shell_CPUINFO_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_CPUUSE)) || \ - defined(CONFIGURE_SHELL_COMMAND_CPUUSE) - &rtems_shell_CPUUSE_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_TOP)) || \ - defined(CONFIGURE_SHELL_COMMAND_TOP) - &rtems_shell_TOP_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_STACKUSE)) || \ - defined(CONFIGURE_SHELL_COMMAND_STACKUSE) - &rtems_shell_STACKUSE_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_PERIODUSE)) || \ - defined(CONFIGURE_SHELL_COMMAND_PERIODUSE) - &rtems_shell_PERIODUSE_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_PROFREPORT)) || \ - defined(CONFIGURE_SHELL_COMMAND_PROFREPORT) - &rtems_shell_PROFREPORT_Command, - #endif - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_WKSPACE_INFO)) || \ - defined(CONFIGURE_SHELL_COMMAND_WKSPACE_INFO) - &rtems_shell_WKSPACE_INFO_Command, - #endif - - /* - * Malloc family commands - */ - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_MALLOC_INFO)) || \ - defined(CONFIGURE_SHELL_COMMAND_MALLOC_INFO) - &rtems_shell_MALLOC_INFO_Command, - #endif - - /* - * Tracing family commands - */ - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_RTRACE)) || \ - defined(CONFIGURE_SHELL_COMMAND_RTRACE) - &rtems_shell_RTRACE_Command, - #endif - - /* - * Network related commands - */ - #if RTEMS_NETWORKING - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL_NETWORKING) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_IFCONFIG)) || \ - defined(CONFIGURE_SHELL_COMMAND_IFCONFIG) - &rtems_shell_IFCONFIG_Command, - #endif - - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL_NETWORKING) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_ROUTE)) || \ - defined(CONFIGURE_SHELL_COMMAND_ROUTE) - &rtems_shell_ROUTE_Command, - #endif - - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL_NETWORKING) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_NETSTATS)) || \ - defined(CONFIGURE_SHELL_COMMAND_NETSTATS) - &rtems_shell_NETSTATS_Command, - #endif - - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL_NETWORKING) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_PING)) || \ - defined(CONFIGURE_SHELL_COMMAND_PING) - &rtems_shell_PING_Command, - #endif - #endif - - /* Miscanellous shell commands */ - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) \ - && !defined(CONFIGURE_SHELL_NO_COMMAND_RTC)) \ - || defined(CONFIGURE_SHELL_COMMAND_RTC) - &rtems_shell_RTC_Command, - #endif - - /* - * System related commands - */ - #if defined(RTEMS_DRVMGR_STARTUP) || defined(CONFIGURE_SHELL_COMMAND_DRVMGR) - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_DRVMGR)) || \ - defined(CONFIGURE_SHELL_COMMAND_DRVMGR) - &rtems_shell_DRVMGR_Command, - #endif - #endif - - #if defined(RTEMS_PCI_CONFIG_LIB) - #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \ - !defined(CONFIGURE_SHELL_NO_COMMAND_PCI)) || \ - defined(CONFIGURE_SHELL_COMMAND_PCI) - &rtems_shell_PCI_Command, - #endif - #endif - - /* - * User defined shell commands - */ - #if defined(CONFIGURE_SHELL_USER_COMMANDS) - CONFIGURE_SHELL_USER_COMMANDS, - #endif - NULL - }; - -#endif - -#endif diff --git a/cpukit/libmisc/stackchk/stackchk.h b/cpukit/libmisc/stackchk/stackchk.h deleted file mode 100644 index 16fc4f9b9d..0000000000 --- a/cpukit/libmisc/stackchk/stackchk.h +++ /dev/null @@ -1,139 +0,0 @@ -/** - * @file rtems/stackchk.h - * - * @defgroup libmisc_stackchk Stack Checker Mechanism - * - * @ingroup libmisc - * @brief Stack Checker Information - * - * This include file contains information necessary to utilize - * and install the stack checker mechanism. - */ - -/* - * COPYRIGHT (c) 1989-2009. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_STACKCHK_H -#define _RTEMS_STACKCHK_H - -#include /* bool */ - -#include /* Thread_Control */ -#include - -/** - * @defgroup libmisc_stackchk Stack Checker Mechanism - * - * @ingroup libmisc - */ -/**@{*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Checks if current task is blown its stack. - * - * This method is used to determine if the current stack pointer - * of the currently executing task is within bounds. - * - * @retval This method returns true if the currently executing task - * has blown its stack. - * - */ -bool rtems_stack_checker_is_blown( void ); - -/** - * @brief Print the stack usage report using printk. - * - * This method prints a stack usage report for the curently executing - * task. - * - * @note It uses printk to print the report. - */ -void rtems_stack_checker_report_usage( void ); - -/** - * @brief Print the stack usage report using caller's routine. - * - * This method prints a stack usage report for the curently executing - * task. - * - * @param[in] context is the context to pass to the print handler - * @param[in] print is the print handler - * - * @note It uses the caller's routine to print the report. - */ -void rtems_stack_checker_report_usage_with_plugin( - const rtems_printer *printer -); - -/************************************************************* - ************************************************************* - ** Prototyped only so the user extension can be installed ** - ************************************************************* - *************************************************************/ - -/** - * @brief Stack Checker Task Create Extension - * - * This method is the task create extension for the stack checker. - * - * @param[in] running points to the currently executing task - * @param[in] the_thread points to the newly created task - * - * @note If this this the first task created, the stack checker - * will automatically intialize itself. - */ -bool rtems_stack_checker_create_extension( - Thread_Control *running, - Thread_Control *the_thread -); - -/** - * @brief Stack Checker Task Context Switch Extension - * - * This method is the task context switch extension for the stack checker. - * - * @param[in] running points to the currently executing task which - * is being context switched out - * @param[in] running points to the heir task which we are switching to - * - * @note This is called from the internal method _Thread_Dispatch. - */ -void rtems_stack_checker_switch_extension( - Thread_Control *running, - Thread_Control *heir -); - -/** - * @brief Stack Checker Extension Set Definition - * - * This macro defines the user extension handler set for the stack - * checker. This macro is normally only used by confdefs.h. - */ -#define RTEMS_STACK_CHECKER_EXTENSION \ -{ \ - rtems_stack_checker_create_extension, /* rtems_task_create */ \ - 0, /* rtems_task_start */ \ - 0, /* rtems_task_restart */ \ - 0, /* rtems_task_delete */ \ - rtems_stack_checker_switch_extension, /* task_switch */ \ - 0, /* task_begin */ \ - 0, /* task_exitted */ \ - 0 /* rtems_stack_checker_fatal_extension */, /* fatal */ \ - 0, /* terminate */ \ -} - -#ifdef __cplusplus -} -#endif -/**@}*/ -#endif -/* end of include file */ diff --git a/cpukit/libmisc/stringto/stringto.h b/cpukit/libmisc/stringto/stringto.h deleted file mode 100644 index 878814da54..0000000000 --- a/cpukit/libmisc/stringto/stringto.h +++ /dev/null @@ -1,262 +0,0 @@ -/** - * @file rtems/stringto.h - * - * @defgroup libmisc_conv_help Conversion Helpers - * - * @ingroup libmisc - * @brief Convert String to Pointer (with validation) - * - * This file defines the interface to a set of string conversion helpers. - */ - -/* - * COPYRIGHT (c) 2009-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_STRINGTO_H -#define _RTEMS_STRINGTO_H -/** - * @defgroup libmisc_conv_help Conversion Helpers - * - * @ingroup libmisc - */ -/**@{*/ - -#include - -/** - * @brief Convert String to Pointer (with validation). - * - * This method converts a string to a pointer (void *) with - * basic numeric validation. - * - * @param[in] s is the string to convert - * @param[in] n points to the variable to place the converted output in - * @param[in] endptr is used to keep track of the position in the string - * - * @retval This method returns RTEMS_SUCCESSFUL on successful conversion - * and *n is filled in. Otherwise, the status indicates the - * source of the error. - */ -rtems_status_code rtems_string_to_pointer( - const char *s, - void **n, - char **endptr -); - -/** - * @brief Convert String to Unsigned Character (with validation). - * - * This method converts a string to an unsigned character with - * range validation. - * - * @param[in] s is the string to convert - * @param[in] n points to the variable to place the converted output in - * @param[in] endptr is used to keep track of the position in the string - * @param[in] base is the expected base of the number - * - * @retval This method returns RTEMS_SUCCESSFUL on successful conversion - * and *n is filled in. Otherwise, the status indicates the - * source of the error. - */ -rtems_status_code rtems_string_to_unsigned_char( - const char *s, - unsigned char *n, - char **endptr, - int base -); - -/** - * @brief Convert String to Int (with validation). - * - * This method converts a string to an int with range validation. - * - * @param[in] s is the string to convert - * @param[in] n points to the variable to place the converted output in - * @param[in] endptr is used to keep track of the position in the string - * @param[in] base is the expected base of the number - * - * @retval This method returns RTEMS_SUCCESSFUL on successful conversion - * and *n is filled in. Otherwise, the status indicates the - * source of the error. - */ -rtems_status_code rtems_string_to_int( - const char *s, - int *n, - char **endptr, - int base -); - -/** - * @brief Convert String to Unsigned Int (with validation). - * - * This method converts a string to an unsigned int with range validation. - * - * @param[in] s is the string to convert - * @param[in] n points to the variable to place the converted output in - * @param[in] endptr is used to keep track of the position in the string - * @param[in] base is the expected base of the number - * - * @retval This method returns RTEMS_SUCCESSFUL on successful conversion - * and *n is filled in. Otherwise, the status indicates the - * source of the error. - */ -rtems_status_code rtems_string_to_unsigned_int( - const char *s, - unsigned int *n, - char **endptr, - int base -); - -/** - * @brief Convert String to Long (with validation). - * - * This method converts a string to a long with - * range validation. - * - * @param[in] s is the string to convert - * @param[in] n points to the variable to place the converted output in - * @param[in] endptr is used to keep track of the position in the string - * @param[in] base is the expected base of the number - * - * @retval This method returns RTEMS_SUCCESSFUL on successful conversion - * and *n is filled in. Otherwise, the status indicates the - * source of the error. - */ -rtems_status_code rtems_string_to_long( - const char *s, - long *n, - char **endptr, - int base -); - -/** - * @brief Convert String to Unsigned Long (with validation). - * - * This method converts a string to an unsigned long with - * range validation. - * - * @param[in] s is the string to convert - * @param[in] n points to the variable to place the converted output in - * @param[in] endptr is used to keep track of the position in the string - * @param[in] base is the expected base of the number - * - * @retval This method returns RTEMS_SUCCESSFUL on successful conversion - * and *n is filled in. Otherwise, the status indicates the - * source of the error. - */ -rtems_status_code rtems_string_to_unsigned_long( - const char *s, - unsigned long *n, - char **endptr, - int base -); - -/** - * @brief Convert String to Long Long (with validation). - * - * This method converts a string to a long long with - * range validation. - * - * @param[in] s is the string to convert - * @param[in] n points to the variable to place the converted output in - * @param[in] endptr is used to keep track of the position in the string - * @param[in] base is the expected base of the number - * - * @retval This method returns RTEMS_SUCCESSFUL on successful conversion - * and *n is filled in. Otherwise, the status indicates the - * source of the error. - */ -rtems_status_code rtems_string_to_long_long( - const char *s, - long long *n, - char **endptr, - int base -); - -/** - * @brief Convert String to Unsigned Long Long (with validation). - * - * This method converts a string to an unsigned character with - * range validation. - * - * @param[in] s is the string to convert - * @param[in] n points to the variable to place the converted output in - * @param[in] endptr is used to keep track of the position in the string - * @param[in] base is the expected base of the number - * - * @retval This method returns RTEMS_SUCCESSFUL on successful conversion - * and *n is filled in. Otherwise, the status indicates the - * source of the error. - */ -rtems_status_code rtems_string_to_unsigned_long_long( - const char *s, - unsigned long long *n, - char **endptr, - int base -); - -/** - * @brief Convert String to Float (with validation). - * - * This method converts a string to a float with range validation. - * - * @param[in] s is the string to convert - * @param[in] n points to the variable to place the converted output in - * @param[in] endptr is used to keep track of the position in the string - * - * @retval This method returns RTEMS_SUCCESSFUL on successful conversion - * and *n is filled in. Otherwise, the status indicates the - * source of the error. - */ -rtems_status_code rtems_string_to_float( - const char *s, - float *n, - char **endptr -); - -/** - * @brief Convert String to Double (with validation). - * - * This method converts a string to a double with range validation. - * - * @param[in] s is the string to convert - * @param[in] n points to the variable to place the converted output in - * @param[in] endptr is used to keep track of the position in the string - * - * @retval This method returns RTEMS_SUCCESSFUL on successful conversion - * and *n is filled in. Otherwise, the status indicates the - * source of the error. - */ -rtems_status_code rtems_string_to_double( - const char *s, - double *n, - char **endptr -); - -/** - * @brief Convert String to long double (with validation). - * - * This method converts a string to a long double with range validation. - * - * @param[in] s is the string to convert - * @param[in] n points to the variable to place the converted output in - * @param[in] endptr is used to keep track of the position in the string - * - * @retval This method returns RTEMS_SUCCESSFUL on successful conversion - * and *n is filled in. Otherwise, the status indicates the - * source of the error. - */ -rtems_status_code rtems_string_to_long_double( - const char *s, - long double *n, - char **endptr -); - -#endif -/**@}*/ diff --git a/cpukit/libmisc/testsupport/test.h b/cpukit/libmisc/testsupport/test.h deleted file mode 100644 index 3dbdb9e32e..0000000000 --- a/cpukit/libmisc/testsupport/test.h +++ /dev/null @@ -1,314 +0,0 @@ -/* - * Copyright (c) 2014, 2017 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_TEST_H -#define _RTEMS_TEST_H - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup RTEMSTest Test Support - * - * @brief Test support functions. - * - * @{ - */ - -/** - * @brief Each test must define a test name string. - */ -extern const char rtems_test_name[]; - -/** - * @brief Each test must define a printer. - */ -extern rtems_printer rtems_test_printer; - -/** - * @brief Fatal extension for tests. - */ -void rtems_test_fatal_extension( - rtems_fatal_source source, - bool always_set_to_false, - rtems_fatal_code code -); - -/** - * @brief Initial extension for tests. - */ -#define RTEMS_TEST_INITIAL_EXTENSION \ - { NULL, NULL, NULL, NULL, NULL, NULL, NULL, rtems_test_fatal_extension } - -/** - * @brief Test states. - */ -typedef enum -{ - RTEMS_TEST_STATE_PASS, - RTEMS_TEST_STATE_FAIL, - RTEMS_TEST_STATE_USER_INPUT, - RTEMS_TEST_STATE_INDETERMINATE, - RTEMS_TEST_STATE_BENCHMARK -} RTEMS_TEST_STATE; - -#if (TEST_STATE_EXPECTED_FAIL && TEST_STATE_USER_INPUT) || \ - (TEST_STATE_EXPECTED_FAIL && TEST_STATE_INDETERMINATE) || \ - (TEST_STATE_EXPECTED_FAIL && TEST_STATE_BENCHMARK) || \ - (TEST_STATE_USER_INPUT && TEST_STATE_INDETERMINATE) || \ - (TEST_STATE_USER_INPUT && TEST_STATE_BENCHMARK) || \ - (TEST_STATE_INDETERMINATE && TEST_STATE_BENCHMARK) - #error Test states must be unique -#endif - -#if TEST_STATE_EXPECTED_FAIL - #define TEST_STATE RTEMS_TEST_STATE_FAIL -#elif TEST_STATE_USER_INPUT - #define TEST_STATE RTEMS_TEST_STATE_USER_INPUT -#elif TEST_STATE_INDETERMINATE - #define TEST_STATE RTEMS_TEST_STATE_INDETERMINATE -#elif TEST_STATE_BENCHMARK - #define TEST_STATE RTEMS_TEST_STATE_BENCHMARK -#else - #define TEST_STATE RTEMS_TEST_STATE_PASS -#endif - -/** - * @brief Prints a begin of test message using printf(). - * - * @returns As specified by printf(). - */ -int rtems_test_begin(const char* name, const RTEMS_TEST_STATE state); - -/** - * @brief Prints an end of test message using printf(). - * - * @returns As specified by printf(). - */ -int rtems_test_end(const char* name); - -/** - * @brief Exit the test without calling exit() since it closes stdin, etc and - * pulls in stdio code - */ -void rtems_test_exit(int status) RTEMS_NO_RETURN; - -/** - * @brief Prints via the RTEMS printer. - * - * @returns As specified by printf(). - */ -int rtems_test_printf(const char* format, ...) RTEMS_PRINTFLIKE(1, 2); - -#define RTEMS_TEST_PARALLEL_PROCESSOR_MAX 32 - -typedef struct rtems_test_parallel_job rtems_test_parallel_job; - -/** - * @brief Internal context for parallel job execution. - */ -typedef struct { - Atomic_Ulong stop; - SMP_barrier_Control barrier; - size_t worker_count; - rtems_id worker_ids[RTEMS_TEST_PARALLEL_PROCESSOR_MAX]; - rtems_id stop_worker_timer_id; - const struct rtems_test_parallel_job *jobs; - size_t job_count; -} rtems_test_parallel_context; - -/** - * @brief Worker task setup handler. - * - * Called during rtems_test_parallel() to optionally setup a worker task before - * it is started. - * - * @param[in] ctx The parallel context. - * @param[in] worker_index The worker index. - * @param[in] worker_id The worker task identifier. - */ -typedef void (*rtems_test_parallel_worker_setup)( - rtems_test_parallel_context *ctx, - size_t worker_index, - rtems_id worker_id -); - -/** - * @brief Basic parallel job description. - */ -struct rtems_test_parallel_job { - /** - * @brief Job initialization handler. - * - * This handler executes only in the context of the master worker before the - * job body handler. - * - * @param[in] ctx The parallel context. - * @param[in] arg The user specified argument. - * @param[in] active_workers Count of active workers. Depends on the cascade - * option. - * - * @return The desired job body execution time in clock ticks. See - * rtems_test_parallel_stop_job(). - */ - rtems_interval (*init)( - rtems_test_parallel_context *ctx, - void *arg, - size_t active_workers - ); - - /** - * @brief Job body handler. - * - * @param[in] ctx The parallel context. - * @param[in] arg The user specified argument. - * @param[in] active_workers Count of active workers. Depends on the cascade - * option. - * @param[in] worker_index The worker index. It ranges from 0 to the - * processor count minus one. - */ - void (*body)( - rtems_test_parallel_context *ctx, - void *arg, - size_t active_workers, - size_t worker_index - ); - - /** - * @brief Job finalization handler. - * - * This handler executes only in the context of the master worker after the - * job body handler. - * - * @param[in] ctx The parallel context. - * @param[in] arg The user specified argument. - * @param[in] active_workers Count of active workers. Depends on the cascade - * option. - */ - void (*fini)( - rtems_test_parallel_context *ctx, - void *arg, - size_t active_workers - ); - - /** - * @brief Job specific argument. - */ - void *arg; - - /** - * @brief Job cascading flag. - * - * This flag indicates whether the job should be executed in a cascaded - * manner (the job is executed on one processor first, two processors - * afterwards and incremented step by step until all processors are used). - */ - bool cascade; -}; - -/** - * @brief Indicates if a job body should stop its work loop. - * - * @param[in] ctx The parallel context. - * - * @retval true The job body should stop its work loop and return to the caller. - * @retval false Otherwise. - */ -static inline bool rtems_test_parallel_stop_job( - const rtems_test_parallel_context *ctx -) -{ - return _Atomic_Load_ulong(&ctx->stop, ATOMIC_ORDER_RELAXED) != 0; -} - -/** - * @brief Indicates if a worker is the master worker. - * - * The master worker is the thread that called rtems_test_parallel(). - * - * @param[in] worker_index The worker index. - * - * @retval true This is the master worker. - * @retval false Otherwise. - */ -static inline bool rtems_test_parallel_is_master_worker(size_t worker_index) -{ - return worker_index == 0; -} - -/** - * @brief Returns the task identifier for a worker. - * - * @param[in] ctx The parallel context. - * @param[in] worker_index The worker index. - * - * @return The task identifier of the worker. - */ -static inline rtems_id rtems_test_parallel_get_task_id( - const rtems_test_parallel_context *ctx, - size_t worker_index -) -{ - return ctx->worker_ids[worker_index]; -} - -/** - * @brief Runs a bunch of jobs in parallel on all processors of the system. - * - * The worker tasks inherit the priority of the executing task. - * - * There are SMP barriers before and after the job body. - * - * @param[in] ctx The parallel context. - * @param[in] worker_setup Optional handler to setup a worker task before it is - * started. - * @param[in] jobs The table of jobs. - * @param[in] job_count The count of jobs in the job table. - */ -void rtems_test_parallel( - rtems_test_parallel_context *ctx, - rtems_test_parallel_worker_setup worker_setup, - const rtems_test_parallel_job *jobs, - size_t job_count -); - -/** - * @brief Performs a busy loop with the specified iteration count. - * - * This function is optimized to not perform memory accesses and should have a - * small jitter. - * - * @param[in] count The iteration count. - */ -void rtems_test_busy(uint_fast32_t count); - -/** - * @brief Returns a count value for rtems_test_busy() which yields roughly a - * duration of one clock tick. - */ -uint_fast32_t rtems_test_get_one_tick_busy_count(void); - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_TEST_H */ diff --git a/cpukit/libmisc/untar/untar.h b/cpukit/libmisc/untar/untar.h deleted file mode 100644 index bc0a97c103..0000000000 --- a/cpukit/libmisc/untar/untar.h +++ /dev/null @@ -1,260 +0,0 @@ -/** - * @file - * - * @brief Untar an Image - * - * This file defines the interface to methods which can untar an image. - */ - -/* - * Written by: Jake Janovetz - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_UNTAR_H -#define _RTEMS_UNTAR_H - -#include -#include -#include -#include -#include - -#include - -/** - * @defgroup libmisc_untar_img Untar Image - * - * @ingroup libmisc - */ -/**@{*/ -#ifdef __cplusplus -extern "C" { -#endif - -#define UNTAR_SUCCESSFUL 0 -#define UNTAR_FAIL 1 -#define UNTAR_INVALID_CHECKSUM 2 -#define UNTAR_INVALID_HEADER 3 - -#define UNTAR_GZ_INFLATE_FAILED 4 -#define UNTAR_GZ_INFLATE_END_FAILED 5 - -int Untar_FromMemory(void *tar_buf, size_t size); -int Untar_FromMemory_Print(void *tar_buf, size_t size, const rtems_printer* printer); -int Untar_FromFile(const char *tar_name); -int Untar_FromFile_Print(const char *tar_name, const rtems_printer* printer); - -typedef struct { - /** - * @brief Current context state. - */ - enum { - UNTAR_CHUNK_HEADER, - UNTAR_CHUNK_SKIP, - UNTAR_CHUNK_WRITE, - UNTAR_CHUNK_ERROR - } state; - - /** - * @brief Header buffer. - */ - char header[512]; - - /** - * @brief Name buffer. - */ - char fname[100]; - - /** - * @brief Number of bytes of overall length are already processed. - */ - size_t done_bytes; - - /** - * @brief Mode of the file. - */ - unsigned long mode; - - /** - * @brief Overall amount of bytes to be processed. - */ - unsigned long todo_bytes; - - /** - * @brief Overall amount of blocks to be processed. - */ - unsigned long todo_blocks; - - /** - * @brief File descriptor of output file. - */ - int out_fd; -} Untar_ChunkContext; - -typedef struct { - /** - * @brief Instance of Chunk Context needed for tar decompression. - */ - Untar_ChunkContext base; - - /** - * @brief Current zlib context. - */ - z_stream strm; - - /** - * @brief Buffer that contains the inflated data. - */ - void *inflateBuffer; - - /** - * @brief Size of buffer that contains the inflated data. - */ - size_t inflateBufferSize; - -} Untar_GzChunkContext; - -typedef struct { - /** - * @brief Instance of Chunk Context needed for tar decompression. - */ - Untar_ChunkContext base; - - /** - * @brief Xz context. - */ - struct xz_dec* strm; - - /** - * @brief Xz buffer. - */ - struct xz_buf buf; - - /** - * @brief Buffer that contains the inflated data. - */ - void *inflateBuffer; - - /** - * @brief Size of buffer that contains the inflated data. - */ - size_t inflateBufferSize; - -} Untar_XzChunkContext; - -/** - * @brief Initializes the Untar_ChunkContext files out of a part of a block of - * memory. - * - * @param Untar_ChunkContext *context [in] Pointer to a context structure. - */ -void Untar_ChunkContext_Init(Untar_ChunkContext *context); - -/* - * @brief Rips links, directories and files out of a part of a block of memory. - * - * @param Untar_ChunkContext *context [in] Pointer to a context structure. - * @param void *chunk [in] Pointer to a chunk of a TAR buffer. - * @param size_t chunk_size [in] Length of the chunk of a TAR buffer. - * - * @retval UNTAR_SUCCESSFUL (0) on successful completion. - * @retval UNTAR_FAIL for a faulty step within the process. - * @retval UNTAR_INVALID_CHECKSUM for an invalid header checksum. - * @retval UNTAR_INVALID_HEADER for an invalid header. - */ - -int Untar_FromChunk_Print( - Untar_ChunkContext *context, - void *chunk, - size_t chunk_size, - const rtems_printer* printer -); - -/** - * @brief Initializes the Untar_ChunkGzContext. - * - * @param Untar_ChunkGzContext *context [in] Pointer to a context structure. - * @param void *inflateBuffer [in] Pointer to a context structure. - * @param size_t inflateBufferSize [in] Size of inflateBuffer. - */ -int Untar_GzChunkContext_Init( - Untar_GzChunkContext *ctx, - void *inflateBuffer, - size_t inflateBufferSize -); - -/* - * @brief Untars a GZ compressed POSIX TAR file. - * - * This is a subroutine used to rip links, directories, and - * files out of a tar.gz/tgz file. - * - * @param Untar_ChunkContext *context [in] Pointer to a context structure. - * @param ssize buflen [in] Size of valid bytes in input buffer. - * @param z_stream *strm [in] Pointer to the current zlib context. - */ -int Untar_FromGzChunk_Print( - Untar_GzChunkContext *ctx, - void *chunk, - size_t chunk_size, - const rtems_printer* printer -); - -/** - * @brief Initializes the Untar_ChunkXzContext. - * - * @param Untar_ChunkXzContext *context [in] Pointer to a context structure. - * @param enum xz_mode mode [in] Dictionary mode. - * @param uint32_t dict_max [in] Maximum size of dictionary. - * @param void *inflateBuffer [in] Pointer to a context structure. - * @param size_t inflateBufferSize [in] Size of inflateBuffer. - */ -int Untar_XzChunkContext_Init( - Untar_XzChunkContext *ctx, - enum xz_mode mode, - uint32_t dict_max, - void *inflateBuffer, - size_t inflateBufferSize -); - -/* - * @brief Untars a XZ compressed POSIX TAR file. - * - * This is a subroutine used to rip links, directories, and - * files out of a tar.gz/tgz file. - * - * @param Untar_ChunkContext *context [in] Pointer to a context structure. - * @param ssize buflen [in] Size of valid bytes in input buffer. - * @param z_stream *strm [in] Pointer to the current zlib context. - */ -int Untar_FromXzChunk_Print( - Untar_XzChunkContext *ctx, - const void *chunk, - size_t chunk_size, - const rtems_printer* printer -); - -/************************************************************************** - * This converts octal ASCII number representations into an - * unsigned long. Only support 32-bit numbers for now. - *************************************************************************/ -extern unsigned long -_rtems_octal2ulong(const char *octascii, size_t len); - -/************************************************************************ - * Compute the TAR checksum and check with the value in - * the archive. The checksum is computed over the entire - * header, but the checksum field is substituted with blanks. - ************************************************************************/ -extern int -_rtems_tar_header_checksum(const char *bufr); - -#ifdef __cplusplus -} -#endif -/**@}*/ -#endif /* _RTEMS_UNTAR_H */ diff --git a/cpukit/libmisc/utf8proc/utf8proc.h b/cpukit/libmisc/utf8proc/utf8proc.h deleted file mode 100644 index 24a891b6c6..0000000000 --- a/cpukit/libmisc/utf8proc/utf8proc.h +++ /dev/null @@ -1,385 +0,0 @@ -/* - * Copyright (c) 2009 Public Software Group e. V., Berlin, Germany - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - - -/* - * File name: utf8proc.h - * - * Description: - * Header files for libutf8proc, which is a mapping tool for UTF-8 strings - * with following features: - * - decomposing and composing of strings - * - replacing compatibility characters with their equivalents - * - stripping of "default ignorable characters" - * like SOFT-HYPHEN or ZERO-WIDTH-SPACE - * - folding of certain characters for string comparison - * (e.g. HYPHEN U+2010 and MINUS U+2212 to ASCII "-") - * (see "LUMP" option) - * - optional rejection of strings containing non-assigned code points - * - stripping of control characters - * - stripping of character marks (accents, etc.) - * - transformation of LF, CRLF, CR and NEL to line-feed (LF) - * or to the unicode chararacters for paragraph separation (PS) - * or line separation (LS). - * - unicode case folding (for case insensitive string comparisons) - * - rejection of illegal UTF-8 data - * (i.e. UTF-8 encoded UTF-16 surrogates) - * - support for korean hangul characters - * Unicode Version 5.0.0 is supported. - */ - - -#ifndef UTF8PROC_H -#define UTF8PROC_H - - -#include -#include -#ifdef _MSC_VER -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef short int16_t; -typedef unsigned short uint16_t; -typedef int int32_t; -#ifdef _WIN64 -#define ssize_t __int64 -#else -#define ssize_t int -#endif -typedef unsigned char bool; -enum {false, true}; -#else -#include -#include -#endif -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef SSIZE_MAX -#define SSIZE_MAX ((size_t)SIZE_MAX/2) -#endif - -#define UTF8PROC_NULLTERM (1<<0) -#define UTF8PROC_STABLE (1<<1) -#define UTF8PROC_COMPAT (1<<2) -#define UTF8PROC_COMPOSE (1<<3) -#define UTF8PROC_DECOMPOSE (1<<4) -#define UTF8PROC_IGNORE (1<<5) -#define UTF8PROC_REJECTNA (1<<6) -#define UTF8PROC_NLF2LS (1<<7) -#define UTF8PROC_NLF2PS (1<<8) -#define UTF8PROC_NLF2LF (UTF8PROC_NLF2LS | UTF8PROC_NLF2PS) -#define UTF8PROC_STRIPCC (1<<9) -#define UTF8PROC_CASEFOLD (1<<10) -#define UTF8PROC_CHARBOUND (1<<11) -#define UTF8PROC_LUMP (1<<12) -#define UTF8PROC_STRIPMARK (1<<13) -/* - * Flags being regarded by several functions in the library: - * NULLTERM: The given UTF-8 input is NULL terminated. - * STABLE: Unicode Versioning Stability has to be respected. - * COMPAT: Compatiblity decomposition - * (i.e. formatting information is lost) - * COMPOSE: Return a result with composed characters. - * DECOMPOSE: Return a result with decomposed characters. - * IGNORE: Strip "default ignorable characters" - * REJECTNA: Return an error, if the input contains unassigned - * code points. - * NLF2LS: Indicating that NLF-sequences (LF, CRLF, CR, NEL) are - * representing a line break, and should be converted to the - * unicode character for line separation (LS). - * NLF2PS: Indicating that NLF-sequences are representing a paragraph - * break, and should be converted to the unicode character for - * paragraph separation (PS). - * NLF2LF: Indicating that the meaning of NLF-sequences is unknown. - * STRIPCC: Strips and/or convers control characters. - * NLF-sequences are transformed into space, except if one of - * the NLF2LS/PS/LF options is given. - * HorizontalTab (HT) and FormFeed (FF) are treated as a - * NLF-sequence in this case. - * All other control characters are simply removed. - * CASEFOLD: Performs unicode case folding, to be able to do a - * case-insensitive string comparison. - * CHARBOUND: Inserts 0xFF bytes at the beginning of each sequence which - * is representing a single grapheme cluster (see UAX#29). - * LUMP: Lumps certain characters together - * (e.g. HYPHEN U+2010 and MINUS U+2212 to ASCII "-"). - * (See lump.txt for details.) - * If NLF2LF is set, this includes a transformation of - * paragraph and line separators to ASCII line-feed (LF). - * STRIPMARK: Strips all character markings - * (non-spacing, spacing and enclosing) (i.e. accents) - * NOTE: this option works only with COMPOSE or DECOMPOSE - */ - -#define UTF8PROC_ERROR_NOMEM -1 -#define UTF8PROC_ERROR_OVERFLOW -2 -#define UTF8PROC_ERROR_INVALIDUTF8 -3 -#define UTF8PROC_ERROR_NOTASSIGNED -4 -#define UTF8PROC_ERROR_INVALIDOPTS -5 -/* - * Error codes being returned by almost all functions: - * ERROR_NOMEM: Memory could not be allocated. - * ERROR_OVERFLOW: The given string is too long to be processed. - * ERROR_INVALIDUTF8: The given string is not a legal UTF-8 string. - * ERROR_NOTASSIGNED: The REJECTNA flag was set, - * and an unassigned code point was found. - * ERROR_INVALIDOPTS: Invalid options have been used. - */ - -typedef int16_t utf8proc_propval_t; -typedef struct utf8proc_property_struct { - utf8proc_propval_t category; - utf8proc_propval_t combining_class; - utf8proc_propval_t bidi_class; - utf8proc_propval_t decomp_type; - const int32_t *decomp_mapping; - unsigned bidi_mirrored:1; - int32_t uppercase_mapping; - int32_t lowercase_mapping; - int32_t titlecase_mapping; - int32_t comb1st_index; - int32_t comb2nd_index; - unsigned comp_exclusion:1; - unsigned ignorable:1; - unsigned control_boundary:1; - unsigned extend:1; - const int32_t *casefold_mapping; -} utf8proc_property_t; - -#define UTF8PROC_CATEGORY_LU 1 -#define UTF8PROC_CATEGORY_LL 2 -#define UTF8PROC_CATEGORY_LT 3 -#define UTF8PROC_CATEGORY_LM 4 -#define UTF8PROC_CATEGORY_LO 5 -#define UTF8PROC_CATEGORY_MN 6 -#define UTF8PROC_CATEGORY_MC 7 -#define UTF8PROC_CATEGORY_ME 8 -#define UTF8PROC_CATEGORY_ND 9 -#define UTF8PROC_CATEGORY_NL 10 -#define UTF8PROC_CATEGORY_NO 11 -#define UTF8PROC_CATEGORY_PC 12 -#define UTF8PROC_CATEGORY_PD 13 -#define UTF8PROC_CATEGORY_PS 14 -#define UTF8PROC_CATEGORY_PE 15 -#define UTF8PROC_CATEGORY_PI 16 -#define UTF8PROC_CATEGORY_PF 17 -#define UTF8PROC_CATEGORY_PO 18 -#define UTF8PROC_CATEGORY_SM 19 -#define UTF8PROC_CATEGORY_SC 20 -#define UTF8PROC_CATEGORY_SK 21 -#define UTF8PROC_CATEGORY_SO 22 -#define UTF8PROC_CATEGORY_ZS 23 -#define UTF8PROC_CATEGORY_ZL 24 -#define UTF8PROC_CATEGORY_ZP 25 -#define UTF8PROC_CATEGORY_CC 26 -#define UTF8PROC_CATEGORY_CF 27 -#define UTF8PROC_CATEGORY_CS 28 -#define UTF8PROC_CATEGORY_CO 29 -#define UTF8PROC_CATEGORY_CN 30 -#define UTF8PROC_BIDI_CLASS_L 1 -#define UTF8PROC_BIDI_CLASS_LRE 2 -#define UTF8PROC_BIDI_CLASS_LRO 3 -#define UTF8PROC_BIDI_CLASS_R 4 -#define UTF8PROC_BIDI_CLASS_AL 5 -#define UTF8PROC_BIDI_CLASS_RLE 6 -#define UTF8PROC_BIDI_CLASS_RLO 7 -#define UTF8PROC_BIDI_CLASS_PDF 8 -#define UTF8PROC_BIDI_CLASS_EN 9 -#define UTF8PROC_BIDI_CLASS_ES 10 -#define UTF8PROC_BIDI_CLASS_ET 11 -#define UTF8PROC_BIDI_CLASS_AN 12 -#define UTF8PROC_BIDI_CLASS_CS 13 -#define UTF8PROC_BIDI_CLASS_NSM 14 -#define UTF8PROC_BIDI_CLASS_BN 15 -#define UTF8PROC_BIDI_CLASS_B 16 -#define UTF8PROC_BIDI_CLASS_S 17 -#define UTF8PROC_BIDI_CLASS_WS 18 -#define UTF8PROC_BIDI_CLASS_ON 19 -#define UTF8PROC_DECOMP_TYPE_FONT 1 -#define UTF8PROC_DECOMP_TYPE_NOBREAK 2 -#define UTF8PROC_DECOMP_TYPE_INITIAL 3 -#define UTF8PROC_DECOMP_TYPE_MEDIAL 4 -#define UTF8PROC_DECOMP_TYPE_FINAL 5 -#define UTF8PROC_DECOMP_TYPE_ISOLATED 6 -#define UTF8PROC_DECOMP_TYPE_CIRCLE 7 -#define UTF8PROC_DECOMP_TYPE_SUPER 8 -#define UTF8PROC_DECOMP_TYPE_SUB 9 -#define UTF8PROC_DECOMP_TYPE_VERTICAL 10 -#define UTF8PROC_DECOMP_TYPE_WIDE 11 -#define UTF8PROC_DECOMP_TYPE_NARROW 12 -#define UTF8PROC_DECOMP_TYPE_SMALL 13 -#define UTF8PROC_DECOMP_TYPE_SQUARE 14 -#define UTF8PROC_DECOMP_TYPE_FRACTION 15 -#define UTF8PROC_DECOMP_TYPE_COMPAT 16 - -extern const int8_t utf8proc_utf8class[256]; - -const char *utf8proc_version(void); - -const char *utf8proc_errmsg(ssize_t errcode); -/* - * Returns a static error string for the given error code. - */ - -ssize_t utf8proc_iterate(const uint8_t *str, ssize_t strlen, int32_t *dst); -/* - * Reads a single char from the UTF-8 sequence being pointed to by 'str'. - * The maximum number of bytes read is 'strlen', unless 'strlen' is - * negative. - * If a valid unicode char could be read, it is stored in the variable - * being pointed to by 'dst', otherwise that variable will be set to -1. - * In case of success the number of bytes read is returned, otherwise a - * negative error code is returned. - */ - -bool utf8proc_codepoint_valid(int32_t uc); -/* - * Returns 1, if the given unicode code-point is valid, otherwise 0. - */ - -ssize_t utf8proc_encode_char(int32_t uc, uint8_t *dst); -/* - * Encodes the unicode char with the code point 'uc' as an UTF-8 string in - * the byte array being pointed to by 'dst'. This array has to be at least - * 4 bytes long. - * In case of success the number of bytes written is returned, - * otherwise 0. - * This function does not check if 'uc' is a valid unicode code point. - */ - -const utf8proc_property_t *utf8proc_get_property(int32_t uc); -/* - * Returns a pointer to a (constant) struct containing information about - * the unicode char with the given code point 'uc'. - * If the character is not existent a pointer to a special struct is - * returned, where 'category' is a NULL pointer. - * WARNING: The parameter 'uc' has to be in the range of 0x0000 to - * 0x10FFFF, otherwise the program might crash! - */ - -ssize_t utf8proc_decompose_char( - int32_t uc, int32_t *dst, ssize_t bufsize, - int options, int *last_boundclass -); -/* - * Writes a decomposition of the unicode char 'uc' into the array being - * pointed to by 'dst'. - * Following flags in the 'options' field are regarded: - * REJECTNA: an unassigned unicode code point leads to an error - * IGNORE: "default ignorable" chars are stripped - * CASEFOLD: unicode casefolding is applied - * COMPAT: replace certain characters with their - * compatibility decomposition - * CHARBOUND: Inserts 0xFF bytes before each grapheme cluster - * LUMP: lumps certain different characters together - * STRIPMARK: removes all character marks - * The pointer 'last_boundclass' has to point to an integer variable which - * is storing the last character boundary class, if the CHARBOUND option - * is used. - * In case of success the number of chars written is returned, - * in case of an error, a negative error code is returned. - * If the number of written chars would be bigger than 'bufsize', - * the buffer (up to 'bufsize') has inpredictable data, and the needed - * buffer size is returned. - * WARNING: The parameter 'uc' has to be in the range of 0x0000 to - * 0x10FFFF, otherwise the program might crash! - */ - -ssize_t utf8proc_decompose( - const uint8_t *str, ssize_t strlen, - int32_t *buffer, ssize_t bufsize, int options -); -/* - * Does the same as 'utf8proc_decompose_char', but acts on a whole UTF-8 - * string, and orders the decomposed sequences correctly. - * If the NULLTERM flag in 'options' is set, processing will be stopped, - * when a NULL byte is encounted, otherwise 'strlen' bytes are processed. - * The result in form of unicode code points is written into the buffer - * being pointed to by 'buffer', having the length of 'bufsize' entries. - * In case of success the number of chars written is returned, - * in case of an error, a negative error code is returned. - * If the number of written chars would be bigger than 'bufsize', - * the buffer (up to 'bufsize') has inpredictable data, and the needed - * buffer size is returned. - */ - -ssize_t utf8proc_reencode(int32_t *buffer, ssize_t length, int options); -/* - * Reencodes the sequence of unicode characters given by the pointer - * 'buffer' and 'length' as UTF-8. - * The result is stored in the same memory area where the data is read. - * Following flags in the 'options' field are regarded: - * NLF2LS: converts LF, CRLF, CR and NEL into LS - * NLF2PS: converts LF, CRLF, CR and NEL into PS - * NLF2LF: converts LF, CRLF, CR and NEL into LF - * STRIPCC: strips or converts all non-affected control characters - * COMPOSE: tries to combine decomposed characters into composite - * characters - * STABLE: prohibits combining characters which would violate - * the unicode versioning stability - * In case of success the length of the resulting UTF-8 string is - * returned, otherwise a negative error code is returned. - * WARNING: The amount of free space being pointed to by 'buffer', has to - * exceed the amount of the input data by one byte, and the - * entries of the array pointed to by 'str' have to be in the - * range of 0x0000 to 0x10FFFF, otherwise the program might - * crash! - */ - -ssize_t utf8proc_map( - const uint8_t *str, ssize_t strlen, uint8_t **dstptr, int options -); -/* - * Maps the given UTF-8 string being pointed to by 'str' to a new UTF-8 - * string, which is allocated dynamically, and afterwards pointed to by - * the pointer being pointed to by 'dstptr'. - * If the NULLTERM flag in the 'options' field is set, the length is - * determined by a NULL terminator, otherwise the parameter 'strlen' is - * evaluated to determine the string length, but in any case the result - * will be NULL terminated (though it might contain NULL characters - * before). Other flags in the 'options' field are passed to the functions - * defined above, and regarded as described. - * In case of success the length of the new string is returned, - * otherwise a negative error code is returned. - * NOTICE: The memory of the new UTF-8 string will have been allocated with - * 'malloc', and has theirfore to be freed with 'free'. - */ - -uint8_t *utf8proc_NFD(const uint8_t *str); -uint8_t *utf8proc_NFC(const uint8_t *str); -uint8_t *utf8proc_NFKD(const uint8_t *str); -uint8_t *utf8proc_NFKC(const uint8_t *str); -/* - * Returns a pointer to newly allocated memory of a NFD, NFC, NFKD or NFKC - * normalized version of the null-terminated string 'str'. - */ - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/cpukit/libmisc/uuid/uuid.h b/cpukit/libmisc/uuid/uuid.h deleted file mode 100644 index ca846da0f0..0000000000 --- a/cpukit/libmisc/uuid/uuid.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Public include file for the UUID library - * - * Copyright (C) 1996, 1997, 1998 Theodore Ts'o. - * - * %Begin-Header% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, and the entire permission notice in its entirety, - * including the disclaimer of warranties. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF - * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * %End-Header% - */ - -#ifndef _UUID_UUID_H -#define _UUID_UUID_H - -#include -#ifndef _WIN32 -#include -#endif -#include - -typedef unsigned char uuid_t[16]; - -/* UUID Variant definitions */ -#define UUID_VARIANT_NCS 0 -#define UUID_VARIANT_DCE 1 -#define UUID_VARIANT_MICROSOFT 2 -#define UUID_VARIANT_OTHER 3 - -/* UUID Type definitions */ -#define UUID_TYPE_DCE_TIME 1 -#define UUID_TYPE_DCE_RANDOM 4 - -/* Allow UUID constants to be defined */ -#ifdef __GNUC__ -#define UUID_DEFINE(name,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15) \ - static const uuid_t name __attribute__ ((unused)) = {u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15} -#else -#define UUID_DEFINE(name,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15) \ - static const uuid_t name = {u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15} -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* clear.c */ -void uuid_clear(uuid_t uu); - -/* compare.c */ -int uuid_compare(const uuid_t uu1, const uuid_t uu2); - -/* copy.c */ -void uuid_copy(uuid_t dst, const uuid_t src); - -/* gen_uuid.c */ -void uuid_generate(uuid_t out); -void uuid_generate_random(uuid_t out); -void uuid_generate_time(uuid_t out); - -/* isnull.c */ -int uuid_is_null(const uuid_t uu); - -/* parse.c */ -int uuid_parse(const char *in, uuid_t uu); - -/* unparse.c */ -void uuid_unparse(const uuid_t uu, char *out); -void uuid_unparse_lower(const uuid_t uu, char *out); -void uuid_unparse_upper(const uuid_t uu, char *out); - -/* uuid_time.c */ -time_t uuid_time(const uuid_t uu, struct timeval *ret_tv); -int uuid_type(const uuid_t uu); -int uuid_variant(const uuid_t uu); - -#ifdef __cplusplus -} -#endif - -#endif /* _UUID_UUID_H */ diff --git a/cpukit/libmisc/xz/xz.h b/cpukit/libmisc/xz/xz.h deleted file mode 100644 index 0a4b38d33c..0000000000 --- a/cpukit/libmisc/xz/xz.h +++ /dev/null @@ -1,304 +0,0 @@ -/* - * XZ decompressor - * - * Authors: Lasse Collin - * Igor Pavlov - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - */ - -#ifndef XZ_H -#define XZ_H - -#ifdef __KERNEL__ -# include -# include -#else -# include -# include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* In Linux, this is used to make extern functions static when needed. */ -#ifndef XZ_EXTERN -# define XZ_EXTERN extern -#endif - -/** - * enum xz_mode - Operation mode - * - * @XZ_SINGLE: Single-call mode. This uses less RAM than - * than multi-call modes, because the LZMA2 - * dictionary doesn't need to be allocated as - * part of the decoder state. All required data - * structures are allocated at initialization, - * so xz_dec_run() cannot return XZ_MEM_ERROR. - * @XZ_PREALLOC: Multi-call mode with preallocated LZMA2 - * dictionary buffer. All data structures are - * allocated at initialization, so xz_dec_run() - * cannot return XZ_MEM_ERROR. - * @XZ_DYNALLOC: Multi-call mode. The LZMA2 dictionary is - * allocated once the required size has been - * parsed from the stream headers. If the - * allocation fails, xz_dec_run() will return - * XZ_MEM_ERROR. - * - * It is possible to enable support only for a subset of the above - * modes at compile time by defining XZ_DEC_SINGLE, XZ_DEC_PREALLOC, - * or XZ_DEC_DYNALLOC. The xz_dec kernel module is always compiled - * with support for all operation modes, but the preboot code may - * be built with fewer features to minimize code size. - */ -enum xz_mode { - XZ_SINGLE, - XZ_PREALLOC, - XZ_DYNALLOC -}; - -/** - * enum xz_ret - Return codes - * @XZ_OK: Everything is OK so far. More input or more - * output space is required to continue. This - * return code is possible only in multi-call mode - * (XZ_PREALLOC or XZ_DYNALLOC). - * @XZ_STREAM_END: Operation finished successfully. - * @XZ_UNSUPPORTED_CHECK: Integrity check type is not supported. Decoding - * is still possible in multi-call mode by simply - * calling xz_dec_run() again. - * Note that this return value is used only if - * XZ_DEC_ANY_CHECK was defined at build time, - * which is not used in the kernel. Unsupported - * check types return XZ_OPTIONS_ERROR if - * XZ_DEC_ANY_CHECK was not defined at build time. - * @XZ_MEM_ERROR: Allocating memory failed. This return code is - * possible only if the decoder was initialized - * with XZ_DYNALLOC. The amount of memory that was - * tried to be allocated was no more than the - * dict_max argument given to xz_dec_init(). - * @XZ_MEMLIMIT_ERROR: A bigger LZMA2 dictionary would be needed than - * allowed by the dict_max argument given to - * xz_dec_init(). This return value is possible - * only in multi-call mode (XZ_PREALLOC or - * XZ_DYNALLOC); the single-call mode (XZ_SINGLE) - * ignores the dict_max argument. - * @XZ_FORMAT_ERROR: File format was not recognized (wrong magic - * bytes). - * @XZ_OPTIONS_ERROR: This implementation doesn't support the requested - * compression options. In the decoder this means - * that the header CRC32 matches, but the header - * itself specifies something that we don't support. - * @XZ_DATA_ERROR: Compressed data is corrupt. - * @XZ_BUF_ERROR: Cannot make any progress. Details are slightly - * different between multi-call and single-call - * mode; more information below. - * - * In multi-call mode, XZ_BUF_ERROR is returned when two consecutive calls - * to XZ code cannot consume any input and cannot produce any new output. - * This happens when there is no new input available, or the output buffer - * is full while at least one output byte is still pending. Assuming your - * code is not buggy, you can get this error only when decoding a compressed - * stream that is truncated or otherwise corrupt. - * - * In single-call mode, XZ_BUF_ERROR is returned only when the output buffer - * is too small or the compressed input is corrupt in a way that makes the - * decoder produce more output than the caller expected. When it is - * (relatively) clear that the compressed input is truncated, XZ_DATA_ERROR - * is used instead of XZ_BUF_ERROR. - */ -enum xz_ret { - XZ_OK, - XZ_STREAM_END, - XZ_UNSUPPORTED_CHECK, - XZ_MEM_ERROR, - XZ_MEMLIMIT_ERROR, - XZ_FORMAT_ERROR, - XZ_OPTIONS_ERROR, - XZ_DATA_ERROR, - XZ_BUF_ERROR -}; - -/** - * struct xz_buf - Passing input and output buffers to XZ code - * @in: Beginning of the input buffer. This may be NULL if and only - * if in_pos is equal to in_size. - * @in_pos: Current position in the input buffer. This must not exceed - * in_size. - * @in_size: Size of the input buffer - * @out: Beginning of the output buffer. This may be NULL if and only - * if out_pos is equal to out_size. - * @out_pos: Current position in the output buffer. This must not exceed - * out_size. - * @out_size: Size of the output buffer - * - * Only the contents of the output buffer from out[out_pos] onward, and - * the variables in_pos and out_pos are modified by the XZ code. - */ -struct xz_buf { - const uint8_t *in; - size_t in_pos; - size_t in_size; - - uint8_t *out; - size_t out_pos; - size_t out_size; -}; - -/** - * struct xz_dec - Opaque type to hold the XZ decoder state - */ -struct xz_dec; - -/** - * xz_dec_init() - Allocate and initialize a XZ decoder state - * @mode: Operation mode - * @dict_max: Maximum size of the LZMA2 dictionary (history buffer) for - * multi-call decoding. This is ignored in single-call mode - * (mode == XZ_SINGLE). LZMA2 dictionary is always 2^n bytes - * or 2^n + 2^(n-1) bytes (the latter sizes are less common - * in practice), so other values for dict_max don't make sense. - * In the kernel, dictionary sizes of 64 KiB, 128 KiB, 256 KiB, - * 512 KiB, and 1 MiB are probably the only reasonable values, - * except for kernel and initramfs images where a bigger - * dictionary can be fine and useful. - * - * Single-call mode (XZ_SINGLE): xz_dec_run() decodes the whole stream at - * once. The caller must provide enough output space or the decoding will - * fail. The output space is used as the dictionary buffer, which is why - * there is no need to allocate the dictionary as part of the decoder's - * internal state. - * - * Because the output buffer is used as the workspace, streams encoded using - * a big dictionary are not a problem in single-call mode. It is enough that - * the output buffer is big enough to hold the actual uncompressed data; it - * can be smaller than the dictionary size stored in the stream headers. - * - * Multi-call mode with preallocated dictionary (XZ_PREALLOC): dict_max bytes - * of memory is preallocated for the LZMA2 dictionary. This way there is no - * risk that xz_dec_run() could run out of memory, since xz_dec_run() will - * never allocate any memory. Instead, if the preallocated dictionary is too - * small for decoding the given input stream, xz_dec_run() will return - * XZ_MEMLIMIT_ERROR. Thus, it is important to know what kind of data will be - * decoded to avoid allocating excessive amount of memory for the dictionary. - * - * Multi-call mode with dynamically allocated dictionary (XZ_DYNALLOC): - * dict_max specifies the maximum allowed dictionary size that xz_dec_run() - * may allocate once it has parsed the dictionary size from the stream - * headers. This way excessive allocations can be avoided while still - * limiting the maximum memory usage to a sane value to prevent running the - * system out of memory when decompressing streams from untrusted sources. - * - * On success, xz_dec_init() returns a pointer to struct xz_dec, which is - * ready to be used with xz_dec_run(). If memory allocation fails, - * xz_dec_init() returns NULL. - */ -XZ_EXTERN struct xz_dec *xz_dec_init(enum xz_mode mode, uint32_t dict_max); - -/** - * xz_dec_run() - Run the XZ decoder - * @s: Decoder state allocated using xz_dec_init() - * @b: Input and output buffers - * - * The possible return values depend on build options and operation mode. - * See enum xz_ret for details. - * - * Note that if an error occurs in single-call mode (return value is not - * XZ_STREAM_END), b->in_pos and b->out_pos are not modified and the - * contents of the output buffer from b->out[b->out_pos] onward are - * undefined. This is true even after XZ_BUF_ERROR, because with some filter - * chains, there may be a second pass over the output buffer, and this pass - * cannot be properly done if the output buffer is truncated. Thus, you - * cannot give the single-call decoder a too small buffer and then expect to - * get that amount valid data from the beginning of the stream. You must use - * the multi-call decoder if you don't want to uncompress the whole stream. - */ -XZ_EXTERN enum xz_ret xz_dec_run(struct xz_dec *s, struct xz_buf *b); - -/** - * xz_dec_reset() - Reset an already allocated decoder state - * @s: Decoder state allocated using xz_dec_init() - * - * This function can be used to reset the multi-call decoder state without - * freeing and reallocating memory with xz_dec_end() and xz_dec_init(). - * - * In single-call mode, xz_dec_reset() is always called in the beginning of - * xz_dec_run(). Thus, explicit call to xz_dec_reset() is useful only in - * multi-call mode. - */ -XZ_EXTERN void xz_dec_reset(struct xz_dec *s); - -/** - * xz_dec_end() - Free the memory allocated for the decoder state - * @s: Decoder state allocated using xz_dec_init(). If s is NULL, - * this function does nothing. - */ -XZ_EXTERN void xz_dec_end(struct xz_dec *s); - -/* - * Standalone build (userspace build or in-kernel build for boot time use) - * needs a CRC32 implementation. For normal in-kernel use, kernel's own - * CRC32 module is used instead, and users of this module don't need to - * care about the functions below. - */ -#ifndef XZ_INTERNAL_CRC32 -# ifdef __KERNEL__ -# define XZ_INTERNAL_CRC32 0 -# else -# define XZ_INTERNAL_CRC32 1 -# endif -#endif - -/* - * If CRC64 support has been enabled with XZ_USE_CRC64, a CRC64 - * implementation is needed too. - */ -#ifndef XZ_USE_CRC64 -# undef XZ_INTERNAL_CRC64 -# define XZ_INTERNAL_CRC64 0 -#endif -#ifndef XZ_INTERNAL_CRC64 -# ifdef __KERNEL__ -# error Using CRC64 in the kernel has not been implemented. -# else -# define XZ_INTERNAL_CRC64 1 -# endif -#endif - -#if XZ_INTERNAL_CRC32 -/* - * This must be called before any other xz_* function to initialize - * the CRC32 lookup table. - */ -XZ_EXTERN void xz_crc32_init(void); - -/* - * Update CRC32 value using the polynomial from IEEE-802.3. To start a new - * calculation, the third argument must be zero. To continue the calculation, - * the previously returned value is passed as the third argument. - */ -XZ_EXTERN uint32_t xz_crc32(const uint8_t *buf, size_t size, uint32_t crc); -#endif - -#if XZ_INTERNAL_CRC64 -/* - * This must be called before any other xz_* function (except xz_crc32_init()) - * to initialize the CRC64 lookup table. - */ -XZ_EXTERN void xz_crc64_init(void); - -/* - * Update CRC64 value using the polynomial from ECMA-182. To start a new - * calculation, the third argument must be zero. To continue the calculation, - * the previously returned value is passed as the third argument. - */ -XZ_EXTERN uint64_t xz_crc64(const uint8_t *buf, size_t size, uint64_t crc); -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/libnetworking/Makefile.am b/cpukit/libnetworking/Makefile.am index d6c8af89dd..7ff7057457 100644 --- a/cpukit/libnetworking/Makefile.am +++ b/cpukit/libnetworking/Makefile.am @@ -1,8 +1,6 @@ include $(top_srcdir)/automake/multilib.am include $(top_srcdir)/automake/compile.am -AM_CPPFLAGS += -I$(srcdir) - EXTRA_DIST = README EXTRA_DIST += rtems/bootp.h @@ -22,8 +20,6 @@ libnetworking_a_CPPFLAGS = $(AM_CPPFLAGS) $(libnetworking_CPPFLAGS) ## poll.h is not in the list because RTEMS does not have poll() ## and installing poll.h confuses autoconf. -include_HEADERS = resolv.h - libnetworking_a_SOURCES = opt_atalk.h opt_bdg.h opt_compat.h opt_inet6.h \ opt_inet.h opt_ipfw.h opt_ipx.h opt_mac.h opt_mrouting.h opt_netgraph.h \ opt_tcpdebug.h opt_ipsec.h loop.h @@ -32,12 +28,6 @@ libnetworking_a_SOURCES += bpfilter.h # arpa -include_arpadir = $(includedir)/arpa - -include_arpa_HEADERS = arpa/ftp.h -include_arpa_HEADERS += arpa/nameser.h -include_arpa_HEADERS += arpa/nameser_compat.h - ## kern libnetworking_a_SOURCES += kern/kern_mib.c kern/kern_subr.c \ @@ -46,68 +36,16 @@ libnetworking_a_SOURCES += kern/kern_mib.c kern/kern_subr.c \ ## machine -include_machinedir = $(includedir)/machine - -include_machine_HEADERS = machine/_align.h -include_machine_HEADERS += machine/cpu.h -include_machine_HEADERS += machine/cpufunc.h -include_machine_HEADERS += machine/in_cksum.h -include_machine_HEADERS += machine/_kernel_lock.h -include_machine_HEADERS += machine/vmparam.h - libnetworking_a_SOURCES += machine/limits.h ## net -include_netdir = $(includedir)/net - -include_net_HEADERS = net/bpf.h -include_net_HEADERS += net/ethernet.h -include_net_HEADERS += net/if_arp.h -include_net_HEADERS += net/if_dl.h -include_net_HEADERS += net/if_llc.h -include_net_HEADERS += net/if_ppp.h -include_net_HEADERS += net/if_types.h -include_net_HEADERS += net/if_var.h -include_net_HEADERS += net/netisr.h -include_net_HEADERS += net/ppp_defs.h -include_net_HEADERS += net/radix.h -include_net_HEADERS += net/raw_cb.h -include_net_HEADERS += net/route.h -include_net_HEADERS += net/if_pppvar.h -include_net_HEADERS += net/slcompress.h -include_net_HEADERS += net/if_media.h -include_net_HEADERS += net/ppp_comp.h - libnetworking_a_SOURCES += net/if.c net/if_ethersubr.c net/if_loop.c \ net/radix.c net/route.c net/rtsock.c net/raw_cb.c net/raw_usrreq.c \ net/if_ppp.c net/ppp_tty.c net/slcompress.c ## netinet -include_netinetdir = $(includedir)/netinet - -include_netinet_HEADERS = netinet/icmp_var.h -include_netinet_HEADERS += netinet/if_ether.h -include_netinet_HEADERS += netinet/igmp.h -include_netinet_HEADERS += netinet/igmp_var.h -include_netinet_HEADERS += netinet/in_pcb.h -include_netinet_HEADERS += netinet/in_systm.h -include_netinet_HEADERS += netinet/in_var.h -include_netinet_HEADERS += netinet/ip.h -include_netinet_HEADERS += netinet/ip_fw.h -include_netinet_HEADERS += netinet/ip_icmp.h -include_netinet_HEADERS += netinet/ip_mroute.h -include_netinet_HEADERS += netinet/ip_var.h -include_netinet_HEADERS += netinet/tcp_debug.h -include_netinet_HEADERS += netinet/tcp_fsm.h -include_netinet_HEADERS += netinet/tcp_seq.h -include_netinet_HEADERS += netinet/tcp_timer.h -include_netinet_HEADERS += netinet/tcp_var.h -include_netinet_HEADERS += netinet/tcpip.h -include_netinet_HEADERS += netinet/udp.h -include_netinet_HEADERS += netinet/udp_var.h - libnetworking_a_SOURCES += netinet/if_ether.c netinet/igmp.c netinet/in.c \ netinet/in_cksum.c netinet/in_pcb.c netinet/in_proto.c netinet/in_rmx.c \ netinet/ip_divert.c netinet/ip_fw.c netinet/ip_icmp.c netinet/ip_input.c \ @@ -119,40 +57,14 @@ libnetworking_a_SOURCES += netinet/if_ether.c netinet/igmp.c netinet/in.c \ ## netinet6 -include_netinet6dir = $(includedir)/netinet6 - ## nfs -include_nfsdir = $(includedir)/nfs - -include_nfs_HEADERS = nfs/nfsproto.h -include_nfs_HEADERS += nfs/rpcv2.h -include_nfs_HEADERS += nfs/xdr_subs.h - libnetworking_a_SOURCES += nfs/bootp_subr.c ## nfsclient -include_nfsclientdir = $(includedir)/nfsclient - -include_nfsclient_HEADERS = nfsclient/nfsargs.h -include_nfsclient_HEADERS += nfsclient/nfsdiskless.h - ## rtems -include_rtemsdir = $(includedir)/rtems - -include_rtems_HEADERS = rtems/rtems_bsdnet.h -include_rtems_HEADERS += rtems/rtems_bsdnet_internal.h -include_rtems_HEADERS += rtems/dhcp.h -include_rtems_HEADERS += rtems/rtems_dhcp_failsafe.h -include_rtems_HEADERS += rtems/tftp.h -include_rtems_HEADERS += rtems/ftpfs.h -include_rtems_HEADERS += rtems/mkrootfs.h -include_rtems_HEADERS += rtems/rtems_mii_ioctl.h -include_rtems_HEADERS += rtems/rtems_netdb.h -include_rtems_HEADERS += rtems/rtems_netinet_in.h - libnetworking_a_SOURCES += rtems/sghostname.c \ rtems/rtems_glue.c rtems/rtems_malloc_mbuf.c rtems/rtems_syscall.c \ rtems/rtems_bootp.c rtems/rtems_dhcp.c rtems/rtems_dhcp_failsafe.c \ @@ -165,41 +77,9 @@ libnetworking_a_SOURCES += rtems/sghostname.c \ ## sys -include_sysdir = $(includedir)/sys - -include_sys_HEADERS = sys/callout.h -include_sys_HEADERS += sys/conf.h -include_sys_HEADERS += sys/domain.h -include_sys_HEADERS += sys/kernel.h -include_sys_HEADERS += sys/libkern.h -include_sys_HEADERS += sys/linker_set.h -include_sys_HEADERS += sys/malloc.h -include_sys_HEADERS += sys/mbuf.h -include_sys_HEADERS += sys/mount.h -include_sys_HEADERS += sys/proc.h -include_sys_HEADERS += sys/protosw.h -include_sys_HEADERS += sys/reboot.h -include_sys_HEADERS += sys/resourcevar.h -include_sys_HEADERS += sys/selinfo.h -include_sys_HEADERS += sys/signalvar.h -include_sys_HEADERS += sys/socketvar.h -include_sys_HEADERS += sys/sysctl.h -include_sys_HEADERS += sys/systm.h -include_sys_HEADERS += sys/ucred.h - # vm -include_vmdir = $(includedir)/vm - -include_vm_HEADERS = vm/vm.h -include_vm_HEADERS += vm/vm_extern.h -include_vm_HEADERS += vm/vm_kern.h -include_vm_HEADERS += vm/vm_param.h - # dev -include_dev_miidir = $(includedir)/dev/mii -include_dev_mii_HEADERS = dev/mii/mii.h - ## libc libc_CPPFLAGS = -DNOPOLL -DNOSELECT -D__BSD_VISIBLE -D_THREAD_SAFE @@ -207,8 +87,6 @@ libc_CPPFLAGS = -DNOPOLL -DNOSELECT -D__BSD_VISIBLE -D_THREAD_SAFE noinst_LIBRARIES += libc.a libc_a_CPPFLAGS = $(AM_CPPFLAGS) $(libc_CPPFLAGS) -include_HEADERS += ifaddrs.h - libc_a_SOURCES = libc/base64.c \ libc/gethostbydns.c libc/gethostbyht.c libc/gethostbynis.c \ libc/gethostnamadr.c libc/getnetbydns.c libc/getnetbyht.c \ @@ -259,5 +137,5 @@ endif EXTRA_DIST += $(UNUSED_FILES) -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am +include $(srcdir)/headers.am diff --git a/cpukit/libnetworking/headers.am b/cpukit/libnetworking/headers.am new file mode 100644 index 0000000000..62e9e27a8b --- /dev/null +++ b/cpukit/libnetworking/headers.am @@ -0,0 +1,131 @@ +## In contrast to the other headers.am files, this file must be maintained by +## hand. + +include_HEADERS = +include_HEADERS += ifaddrs.h +include_HEADERS += loop.h +include_HEADERS += poll.h +include_HEADERS += resolv.h + +include_arpadir = $(includedir)/arpa +include_arpa_HEADERS = +include_arpa_HEADERS += arpa/ftp.h +include_arpa_HEADERS += arpa/nameser.h +include_arpa_HEADERS += arpa/nameser_compat.h + +include_dev_miidir = $(includedir)/dev/mii +include_dev_mii_HEADERS = +include_dev_mii_HEADERS += dev/mii/mii.h + +include_machinedir = $(includedir)/machine +include_machine_HEADERS = +include_machine_HEADERS += machine/_align.h +include_machine_HEADERS += machine/_kernel_lock.h +include_machine_HEADERS += machine/cpu.h +include_machine_HEADERS += machine/cpufunc.h +include_machine_HEADERS += machine/in_cksum.h +include_machine_HEADERS += machine/limits.h +include_machine_HEADERS += machine/vmparam.h + +include_netdir = $(includedir)/net +include_net_HEADERS = +include_net_HEADERS += net/bpf.h +include_net_HEADERS += net/ethernet.h +include_net_HEADERS += net/if_arp.h +include_net_HEADERS += net/if_dl.h +include_net_HEADERS += net/if_llc.h +include_net_HEADERS += net/if_media.h +include_net_HEADERS += net/if_ppp.h +include_net_HEADERS += net/if_pppvar.h +include_net_HEADERS += net/if_types.h +include_net_HEADERS += net/if_var.h +include_net_HEADERS += net/netisr.h +include_net_HEADERS += net/ppp_comp.h +include_net_HEADERS += net/ppp_defs.h +include_net_HEADERS += net/radix.h +include_net_HEADERS += net/raw_cb.h +include_net_HEADERS += net/route.h +include_net_HEADERS += net/slcompress.h + +include_netinetdir = $(includedir)/netinet +include_netinet_HEADERS = +include_netinet_HEADERS += netinet/icmp_var.h +include_netinet_HEADERS += netinet/if_ether.h +include_netinet_HEADERS += netinet/igmp.h +include_netinet_HEADERS += netinet/igmp_var.h +include_netinet_HEADERS += netinet/in_pcb.h +include_netinet_HEADERS += netinet/in_systm.h +include_netinet_HEADERS += netinet/in_var.h +include_netinet_HEADERS += netinet/ip.h +include_netinet_HEADERS += netinet/ip_fw.h +include_netinet_HEADERS += netinet/ip_icmp.h +include_netinet_HEADERS += netinet/ip_mroute.h +include_netinet_HEADERS += netinet/ip_var.h +include_netinet_HEADERS += netinet/tcp_debug.h +include_netinet_HEADERS += netinet/tcp_fsm.h +include_netinet_HEADERS += netinet/tcp_seq.h +include_netinet_HEADERS += netinet/tcp_timer.h +include_netinet_HEADERS += netinet/tcp_var.h +include_netinet_HEADERS += netinet/tcpip.h +include_netinet_HEADERS += netinet/udp.h +include_netinet_HEADERS += netinet/udp_var.h + +include_nfsdir = $(includedir)/nfs +include_nfs_HEADERS = +include_nfs_HEADERS += nfs/nfsproto.h +include_nfs_HEADERS += nfs/rpcv2.h +include_nfs_HEADERS += nfs/xdr_subs.h + +include_nfsclientdir = $(includedir)/nfsclient +include_nfsclient_HEADERS = +include_nfsclient_HEADERS += nfsclient/nfsargs.h +include_nfsclient_HEADERS += nfsclient/nfsdiskless.h + +include_rtemsdir = $(includedir)/rtems +include_rtems_HEADERS = +include_rtems_HEADERS += rtems/bootp.h +include_rtems_HEADERS += rtems/dhcp.h +include_rtems_HEADERS += rtems/ftpfs.h +include_rtems_HEADERS += rtems/mkrootfs.h +include_rtems_HEADERS += rtems/rtems_bsdnet.h +include_rtems_HEADERS += rtems/rtems_bsdnet_internal.h +include_rtems_HEADERS += rtems/rtems_dhcp_failsafe.h +include_rtems_HEADERS += rtems/rtems_mii_ioctl.h +include_rtems_HEADERS += rtems/rtems_netdb.h +include_rtems_HEADERS += rtems/rtems_netinet_in.h +include_rtems_HEADERS += rtems/rtems_syscall.h +include_rtems_HEADERS += rtems/tftp.h + +include_rtems_bsdnetdir = $(includedir)/rtems/bsdnet +include_rtems_bsdnet_HEADERS = +include_rtems_bsdnet_HEADERS += rtems/bsdnet/_types.h +include_rtems_bsdnet_HEADERS += rtems/bsdnet/servers.h + +include_sysdir = $(includedir)/sys +include_sys_HEADERS = +include_sys_HEADERS += sys/callout.h +include_sys_HEADERS += sys/conf.h +include_sys_HEADERS += sys/domain.h +include_sys_HEADERS += sys/kernel.h +include_sys_HEADERS += sys/libkern.h +include_sys_HEADERS += sys/linker_set.h +include_sys_HEADERS += sys/malloc.h +include_sys_HEADERS += sys/mbuf.h +include_sys_HEADERS += sys/mount.h +include_sys_HEADERS += sys/proc.h +include_sys_HEADERS += sys/protosw.h +include_sys_HEADERS += sys/reboot.h +include_sys_HEADERS += sys/resourcevar.h +include_sys_HEADERS += sys/selinfo.h +include_sys_HEADERS += sys/signalvar.h +include_sys_HEADERS += sys/socketvar.h +include_sys_HEADERS += sys/sysctl.h +include_sys_HEADERS += sys/systm.h +include_sys_HEADERS += sys/ucred.h + +include_vmdir = $(includedir)/vm +include_vm_HEADERS = +include_vm_HEADERS += vm/vm.h +include_vm_HEADERS += vm/vm_extern.h +include_vm_HEADERS += vm/vm_kern.h +include_vm_HEADERS += vm/vm_param.h diff --git a/cpukit/libnetworking/preinstall.am b/cpukit/libnetworking/preinstall.am deleted file mode 100644 index 66d018304c..0000000000 --- a/cpukit/libnetworking/preinstall.am +++ /dev/null @@ -1,424 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -$(PROJECT_INCLUDE)/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE) - @: > $(PROJECT_INCLUDE)/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/$(dirstamp) - -if LIBNETWORKING -$(PROJECT_INCLUDE)/resolv.h: resolv.h $(PROJECT_INCLUDE)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/resolv.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/resolv.h - -$(PROJECT_INCLUDE)/arpa/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/arpa - @: > $(PROJECT_INCLUDE)/arpa/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/arpa/$(dirstamp) - -$(PROJECT_INCLUDE)/arpa/ftp.h: arpa/ftp.h $(PROJECT_INCLUDE)/arpa/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/arpa/ftp.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/arpa/ftp.h - -$(PROJECT_INCLUDE)/arpa/nameser.h: arpa/nameser.h $(PROJECT_INCLUDE)/arpa/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/arpa/nameser.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/arpa/nameser.h - -$(PROJECT_INCLUDE)/arpa/nameser_compat.h: arpa/nameser_compat.h $(PROJECT_INCLUDE)/arpa/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/arpa/nameser_compat.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/arpa/nameser_compat.h - -$(PROJECT_INCLUDE)/machine/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/machine - @: > $(PROJECT_INCLUDE)/machine/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/machine/$(dirstamp) - -$(PROJECT_INCLUDE)/machine/_align.h: machine/_align.h $(PROJECT_INCLUDE)/machine/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/machine/_align.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/machine/_align.h - -$(PROJECT_INCLUDE)/machine/cpu.h: machine/cpu.h $(PROJECT_INCLUDE)/machine/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/machine/cpu.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/machine/cpu.h - -$(PROJECT_INCLUDE)/machine/cpufunc.h: machine/cpufunc.h $(PROJECT_INCLUDE)/machine/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/machine/cpufunc.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/machine/cpufunc.h - -$(PROJECT_INCLUDE)/machine/in_cksum.h: machine/in_cksum.h $(PROJECT_INCLUDE)/machine/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/machine/in_cksum.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/machine/in_cksum.h - -$(PROJECT_INCLUDE)/machine/_kernel_lock.h: machine/_kernel_lock.h $(PROJECT_INCLUDE)/machine/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/machine/_kernel_lock.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/machine/_kernel_lock.h - -$(PROJECT_INCLUDE)/machine/vmparam.h: machine/vmparam.h $(PROJECT_INCLUDE)/machine/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/machine/vmparam.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/machine/vmparam.h - -$(PROJECT_INCLUDE)/net/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/net - @: > $(PROJECT_INCLUDE)/net/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/net/$(dirstamp) - -$(PROJECT_INCLUDE)/net/bpf.h: net/bpf.h $(PROJECT_INCLUDE)/net/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/net/bpf.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/net/bpf.h - -$(PROJECT_INCLUDE)/net/ethernet.h: net/ethernet.h $(PROJECT_INCLUDE)/net/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/net/ethernet.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/net/ethernet.h - -$(PROJECT_INCLUDE)/net/if_arp.h: net/if_arp.h $(PROJECT_INCLUDE)/net/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/net/if_arp.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/net/if_arp.h - -$(PROJECT_INCLUDE)/net/if_dl.h: net/if_dl.h $(PROJECT_INCLUDE)/net/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/net/if_dl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/net/if_dl.h - -$(PROJECT_INCLUDE)/net/if_llc.h: net/if_llc.h $(PROJECT_INCLUDE)/net/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/net/if_llc.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/net/if_llc.h - -$(PROJECT_INCLUDE)/net/if_ppp.h: net/if_ppp.h $(PROJECT_INCLUDE)/net/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/net/if_ppp.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/net/if_ppp.h - -$(PROJECT_INCLUDE)/net/if_types.h: net/if_types.h $(PROJECT_INCLUDE)/net/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/net/if_types.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/net/if_types.h - -$(PROJECT_INCLUDE)/net/if_var.h: net/if_var.h $(PROJECT_INCLUDE)/net/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/net/if_var.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/net/if_var.h - -$(PROJECT_INCLUDE)/net/netisr.h: net/netisr.h $(PROJECT_INCLUDE)/net/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/net/netisr.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/net/netisr.h - -$(PROJECT_INCLUDE)/net/ppp_defs.h: net/ppp_defs.h $(PROJECT_INCLUDE)/net/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/net/ppp_defs.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/net/ppp_defs.h - -$(PROJECT_INCLUDE)/net/radix.h: net/radix.h $(PROJECT_INCLUDE)/net/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/net/radix.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/net/radix.h - -$(PROJECT_INCLUDE)/net/raw_cb.h: net/raw_cb.h $(PROJECT_INCLUDE)/net/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/net/raw_cb.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/net/raw_cb.h - -$(PROJECT_INCLUDE)/net/route.h: net/route.h $(PROJECT_INCLUDE)/net/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/net/route.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/net/route.h - -$(PROJECT_INCLUDE)/net/if_pppvar.h: net/if_pppvar.h $(PROJECT_INCLUDE)/net/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/net/if_pppvar.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/net/if_pppvar.h - -$(PROJECT_INCLUDE)/net/slcompress.h: net/slcompress.h $(PROJECT_INCLUDE)/net/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/net/slcompress.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/net/slcompress.h - -$(PROJECT_INCLUDE)/net/if_media.h: net/if_media.h $(PROJECT_INCLUDE)/net/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/net/if_media.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/net/if_media.h - -$(PROJECT_INCLUDE)/net/ppp_comp.h: net/ppp_comp.h $(PROJECT_INCLUDE)/net/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/net/ppp_comp.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/net/ppp_comp.h - -$(PROJECT_INCLUDE)/netinet/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/netinet - @: > $(PROJECT_INCLUDE)/netinet/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/netinet/$(dirstamp) - -$(PROJECT_INCLUDE)/netinet/icmp_var.h: netinet/icmp_var.h $(PROJECT_INCLUDE)/netinet/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/netinet/icmp_var.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/netinet/icmp_var.h - -$(PROJECT_INCLUDE)/netinet/if_ether.h: netinet/if_ether.h $(PROJECT_INCLUDE)/netinet/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/netinet/if_ether.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/netinet/if_ether.h - -$(PROJECT_INCLUDE)/netinet/igmp.h: netinet/igmp.h $(PROJECT_INCLUDE)/netinet/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/netinet/igmp.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/netinet/igmp.h - -$(PROJECT_INCLUDE)/netinet/igmp_var.h: netinet/igmp_var.h $(PROJECT_INCLUDE)/netinet/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/netinet/igmp_var.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/netinet/igmp_var.h - -$(PROJECT_INCLUDE)/netinet/in_pcb.h: netinet/in_pcb.h $(PROJECT_INCLUDE)/netinet/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/netinet/in_pcb.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/netinet/in_pcb.h - -$(PROJECT_INCLUDE)/netinet/in_systm.h: netinet/in_systm.h $(PROJECT_INCLUDE)/netinet/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/netinet/in_systm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/netinet/in_systm.h - -$(PROJECT_INCLUDE)/netinet/in_var.h: netinet/in_var.h $(PROJECT_INCLUDE)/netinet/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/netinet/in_var.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/netinet/in_var.h - -$(PROJECT_INCLUDE)/netinet/ip.h: netinet/ip.h $(PROJECT_INCLUDE)/netinet/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/netinet/ip.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/netinet/ip.h - -$(PROJECT_INCLUDE)/netinet/ip_fw.h: netinet/ip_fw.h $(PROJECT_INCLUDE)/netinet/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/netinet/ip_fw.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/netinet/ip_fw.h - -$(PROJECT_INCLUDE)/netinet/ip_icmp.h: netinet/ip_icmp.h $(PROJECT_INCLUDE)/netinet/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/netinet/ip_icmp.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/netinet/ip_icmp.h - -$(PROJECT_INCLUDE)/netinet/ip_mroute.h: netinet/ip_mroute.h $(PROJECT_INCLUDE)/netinet/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/netinet/ip_mroute.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/netinet/ip_mroute.h - -$(PROJECT_INCLUDE)/netinet/ip_var.h: netinet/ip_var.h $(PROJECT_INCLUDE)/netinet/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/netinet/ip_var.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/netinet/ip_var.h - -$(PROJECT_INCLUDE)/netinet/tcp_debug.h: netinet/tcp_debug.h $(PROJECT_INCLUDE)/netinet/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/netinet/tcp_debug.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/netinet/tcp_debug.h - -$(PROJECT_INCLUDE)/netinet/tcp_fsm.h: netinet/tcp_fsm.h $(PROJECT_INCLUDE)/netinet/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/netinet/tcp_fsm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/netinet/tcp_fsm.h - -$(PROJECT_INCLUDE)/netinet/tcp_seq.h: netinet/tcp_seq.h $(PROJECT_INCLUDE)/netinet/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/netinet/tcp_seq.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/netinet/tcp_seq.h - -$(PROJECT_INCLUDE)/netinet/tcp_timer.h: netinet/tcp_timer.h $(PROJECT_INCLUDE)/netinet/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/netinet/tcp_timer.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/netinet/tcp_timer.h - -$(PROJECT_INCLUDE)/netinet/tcp_var.h: netinet/tcp_var.h $(PROJECT_INCLUDE)/netinet/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/netinet/tcp_var.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/netinet/tcp_var.h - -$(PROJECT_INCLUDE)/netinet/tcpip.h: netinet/tcpip.h $(PROJECT_INCLUDE)/netinet/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/netinet/tcpip.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/netinet/tcpip.h - -$(PROJECT_INCLUDE)/netinet/udp.h: netinet/udp.h $(PROJECT_INCLUDE)/netinet/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/netinet/udp.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/netinet/udp.h - -$(PROJECT_INCLUDE)/netinet/udp_var.h: netinet/udp_var.h $(PROJECT_INCLUDE)/netinet/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/netinet/udp_var.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/netinet/udp_var.h - -$(PROJECT_INCLUDE)/netinet6/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/netinet6 - @: > $(PROJECT_INCLUDE)/netinet6/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/netinet6/$(dirstamp) - -$(PROJECT_INCLUDE)/nfs/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/nfs - @: > $(PROJECT_INCLUDE)/nfs/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/nfs/$(dirstamp) - -$(PROJECT_INCLUDE)/nfs/nfsproto.h: nfs/nfsproto.h $(PROJECT_INCLUDE)/nfs/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/nfs/nfsproto.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/nfs/nfsproto.h - -$(PROJECT_INCLUDE)/nfs/rpcv2.h: nfs/rpcv2.h $(PROJECT_INCLUDE)/nfs/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/nfs/rpcv2.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/nfs/rpcv2.h - -$(PROJECT_INCLUDE)/nfs/xdr_subs.h: nfs/xdr_subs.h $(PROJECT_INCLUDE)/nfs/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/nfs/xdr_subs.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/nfs/xdr_subs.h - -$(PROJECT_INCLUDE)/nfsclient/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/nfsclient - @: > $(PROJECT_INCLUDE)/nfsclient/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/nfsclient/$(dirstamp) - -$(PROJECT_INCLUDE)/nfsclient/nfsargs.h: nfsclient/nfsargs.h $(PROJECT_INCLUDE)/nfsclient/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/nfsclient/nfsargs.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/nfsclient/nfsargs.h - -$(PROJECT_INCLUDE)/nfsclient/nfsdiskless.h: nfsclient/nfsdiskless.h $(PROJECT_INCLUDE)/nfsclient/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/nfsclient/nfsdiskless.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/nfsclient/nfsdiskless.h - -$(PROJECT_INCLUDE)/rtems/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems - @: > $(PROJECT_INCLUDE)/rtems/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/rtems_bsdnet.h: rtems/rtems_bsdnet.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems_bsdnet.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems_bsdnet.h - -$(PROJECT_INCLUDE)/rtems/rtems_bsdnet_internal.h: rtems/rtems_bsdnet_internal.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems_bsdnet_internal.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems_bsdnet_internal.h - -$(PROJECT_INCLUDE)/rtems/dhcp.h: rtems/dhcp.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/dhcp.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/dhcp.h - -$(PROJECT_INCLUDE)/rtems/rtems_dhcp_failsafe.h: rtems/rtems_dhcp_failsafe.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems_dhcp_failsafe.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems_dhcp_failsafe.h - -$(PROJECT_INCLUDE)/rtems/tftp.h: rtems/tftp.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/tftp.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/tftp.h - -$(PROJECT_INCLUDE)/rtems/ftpfs.h: rtems/ftpfs.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/ftpfs.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/ftpfs.h - -$(PROJECT_INCLUDE)/rtems/mkrootfs.h: rtems/mkrootfs.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/mkrootfs.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/mkrootfs.h - -$(PROJECT_INCLUDE)/rtems/rtems_mii_ioctl.h: rtems/rtems_mii_ioctl.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems_mii_ioctl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems_mii_ioctl.h - -$(PROJECT_INCLUDE)/rtems/rtems_netdb.h: rtems/rtems_netdb.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems_netdb.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems_netdb.h - -$(PROJECT_INCLUDE)/rtems/rtems_netinet_in.h: rtems/rtems_netinet_in.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems_netinet_in.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems_netinet_in.h - -$(PROJECT_INCLUDE)/sys/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/sys - @: > $(PROJECT_INCLUDE)/sys/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/sys/$(dirstamp) - -$(PROJECT_INCLUDE)/sys/callout.h: sys/callout.h $(PROJECT_INCLUDE)/sys/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/callout.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/callout.h - -$(PROJECT_INCLUDE)/sys/conf.h: sys/conf.h $(PROJECT_INCLUDE)/sys/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/conf.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/conf.h - -$(PROJECT_INCLUDE)/sys/domain.h: sys/domain.h $(PROJECT_INCLUDE)/sys/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/domain.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/domain.h - -$(PROJECT_INCLUDE)/sys/kernel.h: sys/kernel.h $(PROJECT_INCLUDE)/sys/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/kernel.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/kernel.h - -$(PROJECT_INCLUDE)/sys/libkern.h: sys/libkern.h $(PROJECT_INCLUDE)/sys/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/libkern.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/libkern.h - -$(PROJECT_INCLUDE)/sys/linker_set.h: sys/linker_set.h $(PROJECT_INCLUDE)/sys/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/linker_set.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/linker_set.h - -$(PROJECT_INCLUDE)/sys/malloc.h: sys/malloc.h $(PROJECT_INCLUDE)/sys/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/malloc.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/malloc.h - -$(PROJECT_INCLUDE)/sys/mbuf.h: sys/mbuf.h $(PROJECT_INCLUDE)/sys/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/mbuf.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/mbuf.h - -$(PROJECT_INCLUDE)/sys/mount.h: sys/mount.h $(PROJECT_INCLUDE)/sys/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/mount.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/mount.h - -$(PROJECT_INCLUDE)/sys/proc.h: sys/proc.h $(PROJECT_INCLUDE)/sys/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/proc.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/proc.h - -$(PROJECT_INCLUDE)/sys/protosw.h: sys/protosw.h $(PROJECT_INCLUDE)/sys/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/protosw.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/protosw.h - -$(PROJECT_INCLUDE)/sys/reboot.h: sys/reboot.h $(PROJECT_INCLUDE)/sys/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/reboot.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/reboot.h - -$(PROJECT_INCLUDE)/sys/resourcevar.h: sys/resourcevar.h $(PROJECT_INCLUDE)/sys/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/resourcevar.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/resourcevar.h - -$(PROJECT_INCLUDE)/sys/selinfo.h: sys/selinfo.h $(PROJECT_INCLUDE)/sys/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/selinfo.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/selinfo.h - -$(PROJECT_INCLUDE)/sys/signalvar.h: sys/signalvar.h $(PROJECT_INCLUDE)/sys/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/signalvar.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/signalvar.h - -$(PROJECT_INCLUDE)/sys/socketvar.h: sys/socketvar.h $(PROJECT_INCLUDE)/sys/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/socketvar.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/socketvar.h - -$(PROJECT_INCLUDE)/sys/sysctl.h: sys/sysctl.h $(PROJECT_INCLUDE)/sys/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/sysctl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/sysctl.h - -$(PROJECT_INCLUDE)/sys/systm.h: sys/systm.h $(PROJECT_INCLUDE)/sys/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/systm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/systm.h - -$(PROJECT_INCLUDE)/sys/ucred.h: sys/ucred.h $(PROJECT_INCLUDE)/sys/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/ucred.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/ucred.h - -$(PROJECT_INCLUDE)/vm/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/vm - @: > $(PROJECT_INCLUDE)/vm/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/vm/$(dirstamp) - -$(PROJECT_INCLUDE)/vm/vm.h: vm/vm.h $(PROJECT_INCLUDE)/vm/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/vm/vm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/vm/vm.h - -$(PROJECT_INCLUDE)/vm/vm_extern.h: vm/vm_extern.h $(PROJECT_INCLUDE)/vm/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/vm/vm_extern.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/vm/vm_extern.h - -$(PROJECT_INCLUDE)/vm/vm_kern.h: vm/vm_kern.h $(PROJECT_INCLUDE)/vm/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/vm/vm_kern.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/vm/vm_kern.h - -$(PROJECT_INCLUDE)/vm/vm_param.h: vm/vm_param.h $(PROJECT_INCLUDE)/vm/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/vm/vm_param.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/vm/vm_param.h - -$(PROJECT_INCLUDE)/dev/mii/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/dev/mii - @: > $(PROJECT_INCLUDE)/dev/mii/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/dev/mii/$(dirstamp) - -$(PROJECT_INCLUDE)/dev/mii/mii.h: dev/mii/mii.h $(PROJECT_INCLUDE)/dev/mii/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/dev/mii/mii.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/dev/mii/mii.h - -$(PROJECT_INCLUDE)/ifaddrs.h: ifaddrs.h $(PROJECT_INCLUDE)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/ifaddrs.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/ifaddrs.h -endif diff --git a/cpukit/libnetworking/sys/poll.h b/cpukit/libnetworking/sys/poll.h deleted file mode 100644 index 9ea42b9ddf..0000000000 --- a/cpukit/libnetworking/sys/poll.h +++ /dev/null @@ -1,104 +0,0 @@ -/*- - * Copyright (c) 1997 Peter Wemm - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: src/sys/sys/poll.h,v 1.13 2002/07/10 04:47:25 mike Exp $ - */ - -#ifndef _SYS_POLL_H_ -#define _SYS_POLL_H_ - -#include - -/* - * This file is intended to be compatible with the traditional poll.h. - */ - -typedef unsigned int nfds_t; - -/* - * This structure is passed as an array to poll(2). - */ -struct pollfd { - int fd; /* which file descriptor to poll */ - short events; /* events we are interested in */ - short revents; /* events found on return */ -}; - -/* - * Requestable events. If poll(2) finds any of these set, they are - * copied to revents on return. - * XXX Note that FreeBSD doesn't make much distinction between POLLPRI - * and POLLRDBAND since none of the file types have distinct priority - * bands - and only some have an urgent "mode". - * XXX Note POLLIN isn't really supported in true SVSV terms. Under SYSV - * POLLIN includes all of normal, band and urgent data. Most poll handlers - * on FreeBSD only treat it as "normal" data. - */ -#define POLLIN 0x0001 /* any readable data available */ -#define POLLPRI 0x0002 /* OOB/Urgent readable data */ -#define POLLOUT 0x0004 /* file descriptor is writeable */ -#define POLLRDNORM 0x0040 /* non-OOB/URG data available */ -#define POLLWRNORM POLLOUT /* no write type differentiation */ -#define POLLRDBAND 0x0080 /* OOB/Urgent readable data */ -#define POLLWRBAND 0x0100 /* OOB/Urgent data can be written */ - -#if __BSD_VISIBLE -/* General FreeBSD extension (currently only supported for sockets): */ -#define POLLINIGNEOF 0x2000 /* like POLLIN, except ignore EOF */ -#endif - -/* - * These events are set if they occur regardless of whether they were - * requested. - */ -#define POLLERR 0x0008 /* some poll error occurred */ -#define POLLHUP 0x0010 /* file descriptor was "hung up" */ -#define POLLNVAL 0x0020 /* requested events "invalid" */ - -#if __BSD_VISIBLE - -#define POLLSTANDARD (POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|\ - POLLWRBAND|POLLERR|POLLHUP|POLLNVAL) - -/* - * Request that poll() wait forever. - * XXX in SYSV, this is defined in stropts.h, which is not included - * by poll.h. - */ -#define INFTIM (-1) - -#endif - -#ifndef _KERNEL - -__BEGIN_DECLS -int poll(struct pollfd _pfd[], nfds_t _nfds, int _timeout); -__END_DECLS - -#endif /* !_KERNEL */ - -#endif /* !_SYS_POLL_H_ */ diff --git a/cpukit/libpci/Makefile.am b/cpukit/libpci/Makefile.am index cff25b35c0..f762d39f8e 100644 --- a/cpukit/libpci/Makefile.am +++ b/cpukit/libpci/Makefile.am @@ -6,14 +6,6 @@ if LIBPCI EXTRA_DIST= ## PCI Library -include_HEADERS = pci.h -include_pcidir = $(includedir)/pci -include_pci_HEADERS = pci/access.h pci/cfg.h \ - pci/cfg_auto.h pci/cfg_static.h \ - pci/cfg_peripheral.h pci/cfg_read.h \ - pci/ids.h pci/ids_extra.h pci/irq.h \ - pci/pcireg.h - noinst_LIBRARIES = libpci.a libpci_a_SOURCES = pci_access.c @@ -39,10 +31,6 @@ libpci_a_SOURCES += pci_print.c # Driver manager PCI bus libpci_a_SOURCES += pci_bus.c -include_drvmgrdir = $(includedir)/drvmgr -include_drvmgr_HEADERS = pci_bus.h - endif -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am diff --git a/cpukit/libpci/pci.h b/cpukit/libpci/pci.h deleted file mode 100644 index a0e008a2d0..0000000000 --- a/cpukit/libpci/pci.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * PCI library. Defines in this file was taken from FreeBSD and auto-generated - * pci_ids.h reused from RTEMS. - * - * COPYRIGHT (c) 2009 Cobham Gaisler AB. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef __PCI_H__ -#define __PCI_H__ - -#include -#include - -#define PCI_INVALID_VENDORDEVICEID 0xffffffff - -#define PCID_CLASS(class, dev) ((class << 8) | dev) -#define PCID_PCI2PCI_BRIDGE PCID_CLASS(PCIC_BRIDGE, PCIS_BRIDGE_PCI) - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* The PCI Library have the following build time configuration options. It is - * up to the BSP header file (bsp.h) to set options properly. - * - * BSP_PCI_BIG_ENDIAN - Access inline routines will be for a big-endian PCI - * bus, if not defined the routines will assume that - * PCI is as the standard defines: little-endian. - * - * Note that drivers may be run-time configurable, - * meaning that they may adopt to either big-endian or - * little-endian PCI bus, the host driver or BSP may - * detect endianness during run-time. - */ - -/* Error return values */ -enum { - PCISTS_ERR = -1, /* Undefined Error */ - PCISTS_OK = 0, - PCISTS_EINVAL = 1, /* Bad input arguments */ - PCISTS_MSTABRT = 2, /* CFG space access error (can be ignored) */ -}; - -/* PCI System type can be used to determine system for drivers. Normally - * the system is Host, but the peripheral configuration library also supports - * being PCI peripheral not allowed to access configuration space. - * - * The active configuration Library set this variable. - */ -enum pci_system_type { - PCI_SYSTEM_NONE = 0, - PCI_SYSTEM_HOST = 1, - PCI_SYSTEM_PERIPHERAL = 2, -}; -extern enum pci_system_type pci_system_type; - -/* PCI Bus Endianness. The PCI specification is little endian, however on some - * embedded systems (AT697-LEON2 for example) the PCI bus is defined as big - * endian (non-standard) in order to avoid byte-twisting. - */ -enum { - PCI_LITTLE_ENDIAN = 0, - PCI_BIG_ENDIAN = 1, -}; -extern int pci_endian; - -/* Return the number of PCI busses in the system */ -extern int pci_bus_count(void); - -/* Scan the PCI bus and print the PCI device/functions/bridges and their - * current resources and size to the system console. - */ -extern void pci_print(void); - -/* Print current configuration of a single PCI device by reading PCI - * configuration space - */ -extern void pci_print_dev(pci_dev_t dev); -extern void pci_print_device(int bus, int slot, int function); - -/*** PCI Configuration Space direct access routines ***/ - -/* Function iterates over all PCI buses/devices/functions and calls - * func(PCIDEV,arg) for each present device. The iteration is stopped if - * func() returns non-zero result the same result is returned. As long - * as func() returns zero the function will keep on iterating, when all - * devices has been processed the function return zero. - * - * The function iterates over all devices/functions on all buses by accessing - * configuration space directly (PCI RAM data structures not used). This - * function is valid to call after PCI buses have been enumrated. - */ -extern int pci_for_each(int (*func)(pci_dev_t, void*), void *arg); - -/* Get PCI Configuration space BUS|SLOT|FUNC for a device matching PCI - * Vendor, Device and instance number 'index'. - * - * Return Values - * -1 pci_find_dev did not find a device matching the criterion. - * 0 device was found, *pdev was updated with the device's BUS|SLOT|FUNC - */ -extern int pci_find(uint16_t ven, uint16_t dev, int index, pci_dev_t *pdev); - -#ifdef __cplusplus -} -#endif - -#endif /* __PCI_H__ */ diff --git a/cpukit/libpci/pci/access.h b/cpukit/libpci/pci/access.h deleted file mode 100644 index 4337db30c3..0000000000 --- a/cpukit/libpci/pci/access.h +++ /dev/null @@ -1,258 +0,0 @@ -/* Routines to access PCI memory/configuration space and other PCI related - * functions the PCI Library provides. - * - * COPYRIGHT (c) 2010 Cobham Gaisler AB. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - - -#ifndef __PCI_ACCESS_H__ -#define __PCI_ACCESS_H__ - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* Identification of a PCI configuration space device (16-bit) */ -typedef uint16_t pci_dev_t; -/* Create a PCI Configuration Space ID */ -#define PCI_DEV(bus, slot, func) (((bus)<<8) | ((slot)<<3) | (func)) -/* Get Bus of a PCI Configuration Space ID */ -#define PCI_DEV_BUS(dev) (((dev) >> 8) & 0xff) -/* Get Slot/Device of a PCI Configuration Space ID */ -#define PCI_DEV_SLOT(dev) (((dev) >> 3) & 0x1f) -/* Get Function of a PCI Configuration Space ID */ -#define PCI_DEV_FUNC(dev) ((dev) & 0x7) -/* Get Device and Function of a PCI Configuration Space ID */ -#define PCI_DEV_DEVFUNC(dev) ((dev) & 0xff) -/* Expand Device into argument lists */ -#define PCI_DEV_EXPAND(dev) PCI_DEV_BUS((dev)), PCI_DEV_SLOT((dev)), PCI_DEV_FUNC((dev)) - -/* Configuration Space Read/Write Operations */ -struct pci_cfg_ops { - /* Configuration Space Access and Setup Routines */ - int (*read8)(pci_dev_t dev, int ofs, uint8_t *data); - int (*read16)(pci_dev_t dev, int ofs, uint16_t *data); - int (*read32)(pci_dev_t dev, int ofs, uint32_t *data); - int (*write8)(pci_dev_t dev, int ofs, uint8_t data); - int (*write16)(pci_dev_t dev, int ofs, uint16_t data); - int (*write32)(pci_dev_t dev, int ofs, uint32_t data); -}; - -/* Read a register over PCI I/O Space, and swap it if necessary (due to - * PCI endianness) - */ -struct pci_io_ops { - uint8_t (*read8)(uint8_t *adr); - uint16_t(*read16)(uint16_t *adr); - uint32_t (*read32)(uint32_t *adr); - void (*write8)(uint8_t *adr, uint8_t data); - void (*write16)(uint16_t *adr, uint16_t data); - void (*write32)(uint32_t *adr, uint32_t data); -}; - -/* Read a register over PCI Memory Space (non-prefetchable memory), and - * swap it if necessary (due to PCI endianness) - */ -struct pci_memreg_ops { - uint8_t (*ld8)(uint8_t *adr); - void (*st8)(uint8_t *adr, uint8_t data); - - uint16_t(*ld_le16)(uint16_t *adr); - void (*st_le16)(uint16_t *adr, uint16_t data); - uint16_t(*ld_be16)(uint16_t *adr); - void (*st_be16)(uint16_t *adr, uint16_t data); - - uint32_t (*ld_le32)(uint32_t *adr); - void (*st_le32)(uint32_t *adr, uint32_t data); - uint32_t (*ld_be32)(uint32_t *adr); - void (*st_be32)(uint32_t *adr, uint32_t data); -}; - -typedef uint8_t (*pci_ld8_t)(uint8_t *adr); -typedef void (*pci_st8_t)(uint8_t *adr, uint8_t data); -typedef uint16_t(pci_ld16_t)(uint16_t *adr); -typedef void (*pci_st16_t)(uint16_t *adr, uint16_t data); -typedef uint32_t (*pci_ld32_t)(uint32_t *adr); -typedef void (*pci_st32_t)(uint32_t *adr, uint32_t data); - -struct pci_access_drv { - /* Configuration */ - struct pci_cfg_ops cfg; - - /* I/O Access operations */ - struct pci_io_ops io; - - /* Registers over Memory Access operations. Note that these funcs - * are only for code that need to be compatible with both Big-Endian - * and Little-Endian PCI bus or for some other reason need function - * pointers to access functions. Normally drivers use the inline - * functions for Registers-over-Memory access to avoid extra function - * call. - */ - struct pci_memreg_ops *memreg; - - /* Translate from PCI address to CPU address (dir=0). Translate - * CPU address to PCI address (dir!=0). The address will can be - * used to perform I/O access or memory access by CPU or PCI DMA - * peripheral. - * - * address In/Out. CPU address or PCI address. - * type Access type. 1=I/O, 2=MEMIO, 3=MEM - * dir Translate direction. 0=PCI-to-CPU, 0!=CPU-to-PCI, - * - * Return Value - * 0 = Success - * -1 = Requested Address not mapped into other address space - * i.e. not accessible - */ - int (*translate)(uint32_t *address, int type, int dir); -}; - -/* Access Routines valid after a PCI-Access-Driver has registered */ -extern struct pci_access_drv pci_access_ops; - -/* Register PCI Access Driver */ -extern int pci_access_drv_register(struct pci_access_drv *drv); - -/* Set/unset bits in command and status register of a PCI device */ -extern void pci_modify_cmdsts(pci_dev_t dev, uint32_t mask, uint32_t val); - -/* Enable Memory in command register */ -RTEMS_INLINE_ROUTINE void pci_mem_enable(pci_dev_t dev) -{ - pci_modify_cmdsts(dev, PCIM_CMD_MEMEN, PCIM_CMD_MEMEN); -} - -RTEMS_INLINE_ROUTINE void pci_mem_disable(pci_dev_t dev) -{ - pci_modify_cmdsts(dev, PCIM_CMD_MEMEN, 0); -} - -RTEMS_INLINE_ROUTINE void pci_io_enable(pci_dev_t dev) -{ - pci_modify_cmdsts(dev, PCIM_CMD_PORTEN, PCIM_CMD_PORTEN); -} - -RTEMS_INLINE_ROUTINE void pci_io_disable(pci_dev_t dev) -{ - pci_modify_cmdsts(dev, PCIM_CMD_PORTEN, 0); -} - -RTEMS_INLINE_ROUTINE void pci_master_enable(pci_dev_t dev) -{ - pci_modify_cmdsts(dev, PCIM_CMD_BUSMASTEREN, PCIM_CMD_BUSMASTEREN); -} - -RTEMS_INLINE_ROUTINE void pci_master_disable(pci_dev_t dev) -{ - pci_modify_cmdsts(dev, PCIM_CMD_BUSMASTEREN, 0); -} - -/* Configuration Space Access Read Routines */ -extern int pci_cfg_r8(pci_dev_t dev, int ofs, uint8_t *data); -extern int pci_cfg_r16(pci_dev_t dev, int ofs, uint16_t *data); -extern int pci_cfg_r32(pci_dev_t dev, int ofs, uint32_t *data); - -/* Configuration Space Access Write Routines */ -extern int pci_cfg_w8(pci_dev_t dev, int ofs, uint8_t data); -extern int pci_cfg_w16(pci_dev_t dev, int ofs, uint16_t data); -extern int pci_cfg_w32(pci_dev_t dev, int ofs, uint32_t data); - -/* Read a register over PCI I/O Space */ -extern uint8_t pci_io_r8(uint32_t adr); -extern uint16_t pci_io_r16(uint32_t adr); -extern uint32_t pci_io_r32(uint32_t adr); - -/* Write a register over PCI I/O Space */ -extern void pci_io_w8(uint32_t adr, uint8_t data); -extern void pci_io_w16(uint32_t adr, uint16_t data); -extern void pci_io_w32(uint32_t adr, uint32_t data); - -/* Translate PCI address into CPU accessible address */ -RTEMS_INLINE_ROUTINE int pci_pci2cpu(uint32_t *address, int type) -{ - return pci_access_ops.translate(address, type, 0); -} - -/* Translate CPU accessible address into PCI address (for DMA) */ -RTEMS_INLINE_ROUTINE int pci_cpu2pci(uint32_t *address, int type) -{ - return pci_access_ops.translate(address, type, 1); -} - -/*** Read/Write a register over PCI Memory Space ***/ - -RTEMS_INLINE_ROUTINE uint8_t pci_ld8(volatile uint8_t *addr) -{ - return *addr; -} - -RTEMS_INLINE_ROUTINE void pci_st8(volatile uint8_t *addr, uint8_t val) -{ - *addr = val; -} - -/* Registers-over-Memory Space access routines. The routines are not inlined - * so it is possible during run-time to select which function implemention - * to use. The use of these functions are not recommended since it will have a - * performance penalty. - * - * 8-bit accesses are the same for Little and Big endian PCI buses. - */ -uint8_t pci_mem_ld8(uint8_t *adr); -void pci_mem_st8(uint8_t *adr, uint8_t data); -/* Registers-over-Memory Space - Generic Big endian PCI bus definitions */ -uint16_t pci_mem_be_ld_le16(uint16_t *adr); -uint16_t pci_mem_be_ld_be16(uint16_t *adr); -uint32_t pci_mem_be_ld_le32(uint32_t *adr); -uint32_t pci_mem_be_ld_be32(uint32_t *adr); -void pci_mem_be_st_le16(uint16_t *adr, uint16_t data); -void pci_mem_be_st_be16(uint16_t *adr, uint16_t data); -void pci_mem_be_st_le32(uint32_t *adr, uint32_t data); -void pci_mem_be_st_be32(uint32_t *adr, uint32_t data); -/* Registers-over-Memory Space - Generic Little endian PCI bus definitions */ -uint16_t pci_mem_le_ld_le16(uint16_t *adr); -uint16_t pci_mem_le_ld_be16(uint16_t *adr); -uint32_t pci_mem_le_ld_le32(uint32_t *adr); -uint32_t pci_mem_le_ld_be32(uint32_t *adr); -void pci_mem_le_st_le16(uint16_t *adr, uint16_t data); -void pci_mem_le_st_be16(uint16_t *adr, uint16_t data); -void pci_mem_le_st_le32(uint32_t *adr, uint32_t data); -void pci_mem_le_st_be32(uint32_t *adr, uint32_t data); - -/* Get Read/Write function for accessing a register over PCI Memory Space - * (non-inline functions). - * - * Arguments - * wr 0(Read), 1(Write) - * size 1(Byte), 2(Word), 4(Double Word) - * func Where function pointer will be stored - * endian PCI_LITTLE_ENDIAN or PCI_BIG_ENDIAN - * type 1(I/O), 3(REG over MEM), 4(CFG) - * - * Return - * 0 Found function - * others No such function defined by host driver or BSP - */ -extern int pci_access_func(int wr, int size, void **func, int endian, int type); - -/* Predefined functions for Host drivers or BSPs that define the - * register-over-memory space functions operations. - */ -extern struct pci_memreg_ops pci_mem_le_ops; /* For Little-Endian PCI bus */ -extern struct pci_memreg_ops pci_mem_be_ops; /* For Big-Endian PCI bus */ - -#ifdef __cplusplus -} -#endif - -#endif /* !__PCI_ACCESS_H__ */ diff --git a/cpukit/libpci/pci/cfg.h b/cpukit/libpci/pci/cfg.h deleted file mode 100644 index 1f55c85971..0000000000 --- a/cpukit/libpci/pci/cfg.h +++ /dev/null @@ -1,254 +0,0 @@ -/* PCI Configuration Library - * - * COPYRIGHT (c) 2010 Cobham Gaisler AB. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -/* Four versions of the library exists: - * - auto configuration (default) - * - read configuration from PnP (inherit BIOS set up) - * - static configuration (user defined config) - * - peripheral configuration, no CFG space accesses are possible instead a - * device tree known at compile-time have been built in. - * all versions are defined through here. - */ - -#ifndef __PCI_CFG_H__ -#define __PCI_CFG_H__ - -#include - -/* PCI Configuration library */ - -/* Return the number of PCI buses in system */ -extern int pci_bus_count(void); - -/* PCI Address assigned to BARs which failed to fit into the PCI Window or - * is disabled by any other cause. - */ -extern uint32_t pci_invalid_address; - -/* PCI Configuration Library of the system */ -enum { - PCI_CONFIG_LIB_NONE = 0, - PCI_CONFIG_LIB_AUTO = 1, - PCI_CONFIG_LIB_STATIC = 2, - PCI_CONFIG_LIB_READ = 3, - PCI_CONFIG_LIB_PERIPHERAL = 4, -}; -extern const int pci_config_lib_type; - -/* Configuration library function pointers, these are set in - * by project configuration or by the BSP. The configuration will pull in the - * PCI Library needed and the PCI initialization functions will call these - * functions on initialization from the host driver. - */ -extern int (*pci_config_lib_init)(void); -extern void (*pci_config_lib_register)(void *config); - -/* Configure PCI devices and bridges, and setup the RAM data structures - * describing the PCI devices currently present in the system. - * - * Returns 0 on success, -1 on failure. - */ -extern int pci_config_init(void); - -/* Register a config-library specific configuration used by the libarary in - * pci_config_init(). - */ -extern void pci_config_register(void *config); - -/* Print current PCI configuration (C-code) to terminal, can be used in - * static and peripheral PCI configuration library. The configuration is - * taken from the current configuration library setup. - */ -extern void pci_cfg_print(void); - -struct pci_bus; /* Bridge Device and secondary bus information */ -struct pci_dev; /* Device/function */ -struct pci_res; /* Resource: BAR, ROM or Bridge Window */ - -/* The Host Bridge and all subdevices (the PCI RAM data structure) */ -extern struct pci_bus pci_hb; - -/* Arguments for pci_for_each_child() search option */ -#define SEARCH_CHILDREN 0 /* direct children of bus only */ -#define SEARCH_DEPTH 1 /* all children of bus */ - -/* Iterate over all PCI devices on a bus (see search options) and call func(), - * iteration is stopped if a non-zero value is returned by func(). - * - * The function iterates over the PCI RAM data structure, it is not - * available until after all devices have been found and pci_hb is populated, - * typically after pci_config_init() is called. - * - * search options: 0 (no child buses), 1 (depth first, recursive) - * - * Return Values - * 0 All PCI devices were processed, func() returned 0 on every call - * X func() returned non-zero X value, the search was stopped - */ -extern int pci_for_each_child( - struct pci_bus *bus, - int (*func)(struct pci_dev *, void *arg), - void *arg, - int search); - -/* Depth first search of all PCI devices in PCI RAM data structure and call - * func(dev, arg), iteration is stopped if a non-zero value is returned by - * func(). - * - * The function iterates over the PCI RAM data structure, it is not - * available until after all devices have been found and pci_hb is populated, - * typically after pci_config_init() is called. - * - * Return Values - * 0 All PCI devices were processed, func() returned 0 on every call - * X func() returned non-zero X value, the search was stopped - */ -extern int pci_for_each_dev( - int (*func)(struct pci_dev *, void *arg), - void *arg); - -/* Get PCI device from RAM device tree for a device matching PCI Vendor, Device - * and instance number 'index'. - * - * Return Values - * -1 pci_find_dev did not find a device matching the criterion. - * 0 device was found, *ppdev was updated with the PCI device address - */ -extern int pci_find_dev(uint16_t ven, uint16_t dev, int index, - struct pci_dev **ppdev); - -/* Get PCI device from RAM device tree by BUS|SLOT|FUNC. - * - * Return Values - * -1 pci_get_dev did not find a device matching the criterion - * 0 device was found, *ppdev was updated with the PCI device address - */ -extern int pci_get_dev(pci_dev_t pcidev, struct pci_dev **ppdev); - -/* Resource flags */ -#define PCI_RES_IO 1 -#define PCI_RES_MEMIO 2 -#define PCI_RES_MEM_PREFETCH 1 -#define PCI_RES_MEM (PCI_RES_MEMIO | PCI_RES_MEM_PREFETCH) -#define PCI_RES_TYPE_MASK 0x3 -#define PCI_RES_IO32 0x08 -#define PCI_RES_FAIL 0x10 /* Alloc Failed */ - -/* BAR Resouces entry */ -struct pci_res { - struct pci_res *next; - uint32_t size; - uint32_t boundary; - unsigned char flags; /* I/O, MEM or MEMIO */ - unsigned char bar; - - /* Assigned Resource (PCI address), zero if not assigned */ - uint32_t start; - uint32_t end; -}; - -/* Get Device from resource pointer. bar is the index of the pci_dev.resources - * array and used to get the device base address of which the resource is - * associated with. - */ -#define RES2DEV(res) ((struct pci_dev *) \ - ((uintptr_t)res - (uintptr_t)(res->bar * (sizeof(struct pci_res))))) - -/* Device flags */ -#define PCI_DEV_BRIDGE 0x01 /* Device is a Bridge (struct pci_bus) */ -#define PCI_DEV_RES_FAIL 0x02 /* Resource alloction for device BARs failed */ - -/* Bus Flags */ -#define PCI_BUS_IO 0x01 /* 16-bit I/O address decoding */ -#define PCI_BUS_MEMIO 0x02 /* Bus support non-prefetchable mem (always) */ -#define PCI_BUS_MEM 0x04 /* Bus support prefetchable memory space */ -#define PCI_BUS_IO32 0x08 /* 32-bit I/O address decoding */ - -#define BRIDGE_RES_COUNT 2 /* Number of BAR resources a bridge can have */ -#define BUS_RES_START BRIDGE_RES_COUNT - -/* Bus Resources Array */ -enum { - BUS_RES_IO = 0, - BUS_RES_MEMIO = 1, - BUS_RES_MEM = 2, -}; - -/* Device Resource array index meaning */ -enum { - /* A Device has up to 6 BARs and an optional ROM BAR */ - DEV_RES_BAR1 = 0, - DEV_RES_BAR2 = 1, - DEV_RES_BAR3 = 2, - DEV_RES_BAR4 = 3, - DEV_RES_BAR5 = 4, - DEV_RES_BAR6 = 5, - DEV_RES_ROM = 6, - - /* Bridges have 2 BARs (BAR1 and BAR2) and 3 Windows to secondary bus - * and an optional ROM BAR - */ - BRIDGE_RES_BAR1 = 0, - BRIDGE_RES_BAR2 = 1, - BRIDGE_RES_IO = 2, - BRIDGE_RES_MEMIO = 3, - BRIDGE_RES_MEM = 4, - BRIDGE_RES_UNUSED1 = 5, - BRIDGE_RES_ROM = 6, -}; - -/* Maximum Number of Resources of a device */ -#define DEV_RES_CNT (DEV_RES_ROM + 1) - -/* PCI Device (Bus|Slot|Function) description */ -struct pci_dev { - struct pci_res resources[DEV_RES_CNT]; /* must be topmost field */ - struct pci_dev *next; - struct pci_bus *bus; - pci_dev_t busdevfun; - uint8_t flags; - uint8_t sysirq; - uint16_t vendor; - uint16_t device; - uint16_t subvendor; - uint16_t subdevice; - uint32_t classrev; - - /* static configuration settings */ - uint16_t command; -}; - -/* PCI Bus description */ -struct pci_bus { - struct pci_dev dev; /* PCI Bridge */ - struct pci_dev *devs; /* Devices on child (secondary) Bus */ - unsigned int flags; - - /* Bridge Information */ - int num; /* Bus number (0=Root-PCI-bus) */ - int pri; /* Primary Bus Number */ - int sord; /* Subordinate Buses (Child bus count) */ - -#if defined(PCI_CFG_AUTO_LIB) - /* Resources of devices on bus. USED INTERNALLY IN AUTO-CFG LIBRARY. - * - * BUS_RES_IO = 0: I/O resources - * BUS_RES_MEMIO = 1: Prefetchable memory resources - * BUS_RES_MEM = 2: Non-Prefetchable memory resources - */ - struct pci_res *busres[3]; -#endif -}; - -#include -#include -#include -#include - -#endif diff --git a/cpukit/libpci/pci/cfg_auto.h b/cpukit/libpci/pci/cfg_auto.h deleted file mode 100644 index e374e2e2d4..0000000000 --- a/cpukit/libpci/pci/cfg_auto.h +++ /dev/null @@ -1,58 +0,0 @@ -/* PCI Auto Configuration Library - * - * COPYRIGHT (c) 2010 Cobham Gaisler AB. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef __PCI_CFG_AUTO_H__ -#define __PCI_CFG_AUTO_H__ - -#define CFGOPT_NOSETUP_IRQ 0x1 /* Skip IRQ setup */ - -/* PCI Memory Layout setup, used by the auto-config library in order to - * determine the addresses of PCI BARs and Buses. - * - * All addresses are in PCI address space, the actual address the CPU access - * may be different, and taken care of elsewhere. - */ -struct pci_auto_setup { - int options; - - /* PCI prefetchable Memory space (OPTIONAL) */ - uint32_t mem_start; - uint32_t mem_size; /* 0 = Use MEMIO space for prefetchable mem BARs */ - - /* PCI non-prefetchable Memory */ - uint32_t memio_start; - uint32_t memio_size; - - /* PCI I/O space (OPTIONAL) */ - uint32_t io_start; - uint32_t io_size; /* 0 = No I/O space */ - - /* Get System IRQ connected to a PCI line of a PCI device on bus0. - * The return IRQ value zero equals no IRQ (IRQ disabled). - */ - uint8_t (*irq_map)(pci_dev_t dev, int irq_pin); - - /* IRQ Bridge routing. Returns the interrupt pin (0..3 = A..D) that - * a device is connected to on parent bus. - */ - int (*irq_route)(pci_dev_t dev, int irq_pin); -}; - -/* Do PCI initialization: Enumrate buses, scan buses for devices, assign - * I/O MEM and MEMIO resources, assign IRQ and so on. - */ -extern int pci_config_auto(void); - -/* Register a configuration for the auto library (struct pci_auto_setup *) */ -extern void pci_config_auto_register(void *config); - -/* PCI memory map */ -extern struct pci_auto_setup pci_auto_cfg; - -#endif diff --git a/cpukit/libpci/pci/cfg_peripheral.h b/cpukit/libpci/pci/cfg_peripheral.h deleted file mode 100644 index f05c8257c6..0000000000 --- a/cpukit/libpci/pci/cfg_peripheral.h +++ /dev/null @@ -1,19 +0,0 @@ -/* PCI Peripheral Configuration Library - * - * COPYRIGHT (c) 2010 Cobham Gaisler AB. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef __PCI_CFG_PERIPHERAL_H__ -#define __PCI_CFG_PERIPHERAL_H__ - -/* The user must provide a PCI configuration using the "struct pci_bus pci_hb" - * structure. Nothing else than setting pci_system_type and pci_bus_cnt is done - * by the peripheral library. - */ -extern int pci_config_peripheral(void); - -#endif diff --git a/cpukit/libpci/pci/cfg_read.h b/cpukit/libpci/pci/cfg_read.h deleted file mode 100644 index 3dd7678279..0000000000 --- a/cpukit/libpci/pci/cfg_read.h +++ /dev/null @@ -1,21 +0,0 @@ -/* PCI Read Configuration Library. Read current config that bootloader/BIOS - * has setup. - * - * COPYRIGHT (c) 2010 Cobham Gaisler AB. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - - -#ifndef __PCI_CFG_READ_H__ -#define __PCI_CFG_READ_H__ - -/* Build PCI device tree in "struct pci_bus pci_hb" according to current setup - * in hardware. Devices/buses are created by reading the resource assignments - * that the BIOS/bootloader has already setup for us. - */ -extern int pci_config_read(void); - -#endif diff --git a/cpukit/libpci/pci/cfg_static.h b/cpukit/libpci/pci/cfg_static.h deleted file mode 100644 index 62ee0dad7d..0000000000 --- a/cpukit/libpci/pci/cfg_static.h +++ /dev/null @@ -1,21 +0,0 @@ -/* Static PCI Auto Configuration Library - * - * COPYRIGHT (c) 2010 Cobham Gaisler AB. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef __PCI_CFG_STATIC_H__ -#define __PCI_CFG_STATIC_H__ - -/* This function initializes all buses and device accorind to a user defined - * "static" configuration. The configuration can manually created with C - * data structures. Or it can be automatically created on a running target - * using the pci_cfg_print() routine after the AUTO or READ Configuration - * Library has setup the PCI bus - */ -extern int pci_config_static(void); - -#endif diff --git a/cpukit/libpci/pci/ids.h b/cpukit/libpci/pci/ids.h deleted file mode 100644 index 88e1ad5e3e..0000000000 --- a/cpukit/libpci/pci/ids.h +++ /dev/null @@ -1,827 +0,0 @@ -/* - * Copyright 1994, Drew Eckhardt - * Copyright 1997, 1998 Martin Mares - * - * This file comes from the auto-generated PCI IDs part of the - * cpukit/include/rtems/pci.h. - * Copyright 2009, Cobham Gaisler AB - * - * For more information, please consult the following manuals (look at - * http://www.pcisig.com/ for how to get them): - * - * PCI BIOS Specification - * PCI Local Bus Specification - * PCI to PCI Bridge Specification - * PCI System Design Guide - */ - -/* PCI Vendor and card ID's: sort these numerically according to vendor - * (and according to card ID within vendor). Send all updates to - * . - */ - -/* For the future this file should be generated - * from the PCI IDS database at http://pciids.sourceforge.net/ ? - */ - -#ifndef __PCI_IDS_H__ -#define __PCI_IDS_H__ - -/* Include non-public PCI ids (not auto generated) */ -#include - -/* Not a valid ID, used to match any device ID */ -#define PCI_ID_ANY 0xffff - -/* - * Vendor and card ID's: sort these numerically according to vendor - * (and according to card ID within vendor). Send all updates to - * . - */ -#define PCIR_VENDOR_COMPAQ 0x0e11 -#define PCIR_DEVICE_COMPAQ_1280 0x3033 -#define PCIR_DEVICE_COMPAQ_TRIFLEX 0x4000 -#define PCIR_DEVICE_COMPAQ_SMART2P 0xae10 -#define PCIR_DEVICE_COMPAQ_NETEL100 0xae32 -#define PCIR_DEVICE_COMPAQ_NETEL10 0xae34 -#define PCIR_DEVICE_COMPAQ_NETFLEX3I 0xae35 -#define PCIR_DEVICE_COMPAQ_NETEL100D 0xae40 -#define PCIR_DEVICE_COMPAQ_NETEL100PI 0xae43 -#define PCIR_DEVICE_COMPAQ_NETEL100I 0xb011 -#define PCIR_DEVICE_COMPAQ_THUNDER 0xf130 -#define PCIR_DEVICE_COMPAQ_NETFLEX3B 0xf150 - -#define PCIR_VENDOR_NCR 0x1000 -#define PCIR_DEVICE_NCR_53C810 0x0001 -#define PCIR_DEVICE_NCR_53C820 0x0002 -#define PCIR_DEVICE_NCR_53C825 0x0003 -#define PCIR_DEVICE_NCR_53C815 0x0004 -#define PCIR_DEVICE_NCR_53C860 0x0006 -#define PCIR_DEVICE_NCR_53C896 0x000b -#define PCIR_DEVICE_NCR_53C895 0x000c -#define PCIR_DEVICE_NCR_53C885 0x000d -#define PCIR_DEVICE_NCR_53C875 0x000f -#define PCIR_DEVICE_NCR_53C875J 0x008f - -#define PCIR_VENDOR_ATI 0x1002 -#define PCIR_DEVICE_ATI_68800 0x4158 -#define PCIR_DEVICE_ATI_215CT222 0x4354 -#define PCIR_DEVICE_ATI_210888CX 0x4358 -#define PCIR_DEVICE_ATI_215GB 0x4742 -#define PCIR_DEVICE_ATI_215GD 0x4744 -#define PCIR_DEVICE_ATI_215GI 0x4749 -#define PCIR_DEVICE_ATI_215GP 0x4750 -#define PCIR_DEVICE_ATI_215GQ 0x4751 -#define PCIR_DEVICE_ATI_215GT 0x4754 -#define PCIR_DEVICE_ATI_215GTB 0x4755 -#define PCIR_DEVICE_ATI_210888GX 0x4758 -#define PCIR_DEVICE_ATI_215LG 0x4c47 -#define PCIR_DEVICE_ATI_264LT 0x4c54 -#define PCIR_DEVICE_ATI_264VT 0x5654 - -#define PCIR_VENDOR_VLSI 0x1004 -#define PCIR_DEVICE_VLSI_82C592 0x0005 -#define PCIR_DEVICE_VLSI_82C593 0x0006 -#define PCIR_DEVICE_VLSI_82C594 0x0007 -#define PCIR_DEVICE_VLSI_82C597 0x0009 -#define PCIR_DEVICE_VLSI_82C541 0x000c -#define PCIR_DEVICE_VLSI_82C543 0x000d -#define PCIR_DEVICE_VLSI_82C532 0x0101 -#define PCIR_DEVICE_VLSI_82C534 0x0102 -#define PCIR_DEVICE_VLSI_82C535 0x0104 -#define PCIR_DEVICE_VLSI_82C147 0x0105 -#define PCIR_DEVICE_VLSI_VAS96011 0x0702 - -#define PCIR_VENDOR_ADL 0x1005 -#define PCIR_DEVICE_ADL_2301 0x2301 - -#define PCIR_VENDOR_NS 0x100b -#define PCIR_DEVICE_NS_87415 0x0002 -#define PCIR_DEVICE_NS_87410 0xd001 - -#define PCIR_VENDOR_TSENG 0x100c -#define PCIR_DEVICE_TSENG_W32P_2 0x3202 -#define PCIR_DEVICE_TSENG_W32P_b 0x3205 -#define PCIR_DEVICE_TSENG_W32P_c 0x3206 -#define PCIR_DEVICE_TSENG_W32P_d 0x3207 -#define PCIR_DEVICE_TSENG_ET6000 0x3208 - -#define PCIR_VENDOR_WEITEK 0x100e -#define PCIR_DEVICE_WEITEK_P9000 0x9001 -#define PCIR_DEVICE_WEITEK_P9100 0x9100 - -#define PCIR_VENDOR_DEC 0x1011 -#define PCIR_DEVICE_DEC_BRD 0x0001 -#define PCIR_DEVICE_DEC_TULIP 0x0002 -#define PCIR_DEVICE_DEC_TGA 0x0004 -#define PCIR_DEVICE_DEC_TULIP_FAST 0x0009 -#define PCIR_DEVICE_DEC_TGA2 0x000D -#define PCIR_DEVICE_DEC_FDDI 0x000F -#define PCIR_DEVICE_DEC_TULIP_PLUS 0x0014 -#define PCIR_DEVICE_DEC_21142 0x0019 -#define PCIR_DEVICE_DEC_21052 0x0021 -#define PCIR_DEVICE_DEC_21150 0x0022 -#define PCIR_DEVICE_DEC_21152 0x0024 - -#define PCIR_VENDOR_CIRRUS 0x1013 -#define PCIR_DEVICE_CIRRUS_7548 0x0038 -#define PCIR_DEVICE_CIRRUS_5430 0x00a0 -#define PCIR_DEVICE_CIRRUS_5434_4 0x00a4 -#define PCIR_DEVICE_CIRRUS_5434_8 0x00a8 -#define PCIR_DEVICE_CIRRUS_5436 0x00ac -#define PCIR_DEVICE_CIRRUS_5446 0x00b8 -#define PCIR_DEVICE_CIRRUS_5480 0x00bc -#define PCIR_DEVICE_CIRRUS_5464 0x00d4 -#define PCIR_DEVICE_CIRRUS_5465 0x00d6 -#define PCIR_DEVICE_CIRRUS_6729 0x1100 -#define PCIR_DEVICE_CIRRUS_6832 0x1110 -#define PCIR_DEVICE_CIRRUS_7542 0x1200 -#define PCIR_DEVICE_CIRRUS_7543 0x1202 -#define PCIR_DEVICE_CIRRUS_7541 0x1204 - -#define PCIR_VENDOR_IBM 0x1014 -#define PCIR_DEVICE_IBM_FIRE_CORAL 0x000a -#define PCIR_DEVICE_IBM_TR 0x0018 -#define PCIR_DEVICE_IBM_82G2675 0x001d -#define PCIR_DEVICE_IBM_MCA 0x0020 -#define PCIR_DEVICE_IBM_82351 0x0022 -#define PCIR_DEVICE_IBM_SERVERAID 0x002e -#define PCIR_DEVICE_IBM_TR_WAKE 0x003e -#define PCIR_DEVICE_IBM_MPIC 0x0046 -#define PCIR_DEVICE_IBM_3780IDSP 0x007d -#define PCIR_DEVICE_IBM_MPIC_2 0xffff - -#define PCIR_VENDOR_WD 0x101c -#define PCIR_DEVICE_WD_7197 0x3296 - -#define PCIR_VENDOR_AMD 0x1022 -#define PCIR_DEVICE_AMD_LANCE 0x2000 -#define PCIR_DEVICE_AMD_SCSI 0x2020 - -#define PCIR_VENDOR_TRIDENT 0x1023 -#define PCIR_DEVICE_TRIDENT_9397 0x9397 -#define PCIR_DEVICE_TRIDENT_9420 0x9420 -#define PCIR_DEVICE_TRIDENT_9440 0x9440 -#define PCIR_DEVICE_TRIDENT_9660 0x9660 -#define PCIR_DEVICE_TRIDENT_9750 0x9750 - -#define PCIR_VENDOR_AI 0x1025 -#define PCIR_DEVICE_AI_M1435 0x1435 - -#define PCIR_VENDOR_MATROX 0x102B -#define PCIR_DEVICE_MATROX_MGA_2 0x0518 -#define PCIR_DEVICE_MATROX_MIL 0x0519 -#define PCIR_DEVICE_MATROX_MYS 0x051A -#define PCIR_DEVICE_MATROX_MIL_2 0x051b -#define PCIR_DEVICE_MATROX_MIL_2_AGP 0x051f -#define PCIR_DEVICE_MATROX_MGA_IMP 0x0d10 - -#define PCIR_VENDOR_CT 0x102c -#define PCIR_DEVICE_CT_65545 0x00d8 -#define PCIR_DEVICE_CT_65548 0x00dc -#define PCIR_DEVICE_CT_65550 0x00e0 -#define PCIR_DEVICE_CT_65554 0x00e4 -#define PCIR_DEVICE_CT_65555 0x00e5 - -#define PCIR_VENDOR_MIRO 0x1031 -#define PCIR_DEVICE_MIRO_36050 0x5601 - -#define PCIR_VENDOR_NEC 0x1033 -#define PCIR_DEVICE_NEC_PCX2 0x0046 - -#define PCIR_VENDOR_FD 0x1036 -#define PCIR_DEVICE_FD_36C70 0x0000 - -#define PCIR_VENDOR_SI 0x1039 -#define PCIR_DEVICE_SI_5591_AGP 0x0001 -#define PCIR_DEVICE_SI_6202 0x0002 -#define PCIR_DEVICE_SI_503 0x0008 -#define PCIR_DEVICE_SI_ACPI 0x0009 -#define PCIR_DEVICE_SI_5597_VGA 0x0200 -#define PCIR_DEVICE_SI_6205 0x0205 -#define PCIR_DEVICE_SI_501 0x0406 -#define PCIR_DEVICE_SI_496 0x0496 -#define PCIR_DEVICE_SI_601 0x0601 -#define PCIR_DEVICE_SI_5107 0x5107 -#define PCIR_DEVICE_SI_5511 0x5511 -#define PCIR_DEVICE_SI_5513 0x5513 -#define PCIR_DEVICE_SI_5571 0x5571 -#define PCIR_DEVICE_SI_5591 0x5591 -#define PCIR_DEVICE_SI_5597 0x5597 -#define PCIR_DEVICE_SI_7001 0x7001 - -#define PCIR_VENDOR_HP 0x103c -#define PCIR_DEVICE_HP_J2585A 0x1030 -#define PCIR_DEVICE_HP_J2585B 0x1031 - -#define PCIR_VENDOR_PCTECH 0x1042 -#define PCIR_DEVICE_PCTECH_RZ1000 0x1000 -#define PCIR_DEVICE_PCTECH_RZ1001 0x1001 -#define PCIR_DEVICE_PCTECH_SAMURAI_0 0x3000 -#define PCIR_DEVICE_PCTECH_SAMURAI_1 0x3010 -#define PCIR_DEVICE_PCTECH_SAMURAI_IDE 0x3020 - -#define PCIR_VENDOR_DPT 0x1044 -#define PCIR_DEVICE_DPT 0xa400 - -#define PCIR_VENDOR_OPTI 0x1045 -#define PCIR_DEVICE_OPTI_92C178 0xc178 -#define PCIR_DEVICE_OPTI_82C557 0xc557 -#define PCIR_DEVICE_OPTI_82C558 0xc558 -#define PCIR_DEVICE_OPTI_82C621 0xc621 -#define PCIR_DEVICE_OPTI_82C700 0xc700 -#define PCIR_DEVICE_OPTI_82C701 0xc701 -#define PCIR_DEVICE_OPTI_82C814 0xc814 -#define PCIR_DEVICE_OPTI_82C822 0xc822 -#define PCIR_DEVICE_OPTI_82C825 0xd568 - -#define PCIR_VENDOR_SGS 0x104a -#define PCIR_DEVICE_SGS_2000 0x0008 -#define PCIR_DEVICE_SGS_1764 0x0009 - -#define PCIR_VENDOR_BUSLOGIC 0x104B -#define PCIR_DEVICE_BUSLOGIC_MULTIMASTER_NC 0x0140 -#define PCIR_DEVICE_BUSLOGIC_MULTIMASTER 0x1040 -#define PCIR_DEVICE_BUSLOGIC_FLASHPOINT 0x8130 - -#define PCIR_VENDOR_TI 0x104c -#define PCIR_DEVICE_TI_TVP4010 0x3d04 -#define PCIR_DEVICE_TI_TVP4020 0x3d07 -#define PCIR_DEVICE_TI_PCI1130 0xac12 -#define PCIR_DEVICE_TI_PCI1031 0xac13 -#define PCIR_DEVICE_TI_PCI1131 0xac15 -#define PCIR_DEVICE_TI_PCI1250 0xac16 -#define PCIR_DEVICE_TI_PCI1220 0xac17 - -#define PCIR_VENDOR_OAK 0x104e -#define PCIR_DEVICE_OAK_OTI107 0x0107 - -/* Winbond have two vendor IDs! See 0x10ad as well */ -#define PCIR_VENDOR_WINBOND2 0x1050 -#define PCIR_DEVICE_WINBOND2_89C940 0x0940 - -#define PCIR_VENDOR_MOTOROLA 0x1057 -#define PCIR_DEVICE_MOTOROLA_MPC105 0x0001 -#define PCIR_DEVICE_MOTOROLA_MPC106 0x0002 -#define PCIR_DEVICE_MOTOROLA_RAVEN 0x4801 - -#define PCIR_VENDOR_PROMISE 0x105a -#define PCIR_DEVICE_PROMISE_20246 0x4d33 -#define PCIR_DEVICE_PROMISE_5300 0x5300 - -#define PCIR_VENDOR_N9 0x105d -#define PCIR_DEVICE_N9_I128 0x2309 -#define PCIR_DEVICE_N9_I128_2 0x2339 -#define PCIR_DEVICE_N9_I128_T2R 0x493d - -#define PCIR_VENDOR_UMC 0x1060 -#define PCIR_DEVICE_UMC_UM8673F 0x0101 -#define PCIR_DEVICE_UMC_UM8891A 0x0891 -#define PCIR_DEVICE_UMC_UM8886BF 0x673a -#define PCIR_DEVICE_UMC_UM8886A 0x886a -#define PCIR_DEVICE_UMC_UM8881F 0x8881 -#define PCIR_DEVICE_UMC_UM8886F 0x8886 -#define PCIR_DEVICE_UMC_UM9017F 0x9017 -#define PCIR_DEVICE_UMC_UM8886N 0xe886 -#define PCIR_DEVICE_UMC_UM8891N 0xe891 - -#define PCIR_VENDOR_X 0x1061 -#define PCIR_DEVICE_X_AGX016 0x0001 - -#define PCIR_VENDOR_PICOP 0x1066 -#define PCIR_DEVICE_PICOP_PT86C52X 0x0001 -#define PCIR_DEVICE_PICOP_PT80C524 0x8002 - -#define PCIR_VENDOR_APPLE 0x106b -#define PCIR_DEVICE_APPLE_BANDIT 0x0001 -#define PCIR_DEVICE_APPLE_GC 0x0002 -#define PCIR_DEVICE_APPLE_HYDRA 0x000e - -#define PCIR_VENDOR_NEXGEN 0x1074 -#define PCIR_DEVICE_NEXGEN_82C501 0x4e78 - -#define PCIR_VENDOR_QLOGIC 0x1077 -#define PCIR_DEVICE_QLOGIC_ISP1020 0x1020 -#define PCIR_DEVICE_QLOGIC_ISP1022 0x1022 - -#define PCIR_VENDOR_CYRIX 0x1078 -#define PCIR_DEVICE_CYRIX_5510 0x0000 -#define PCIR_DEVICE_CYRIX_PCI_MASTER 0x0001 -#define PCIR_DEVICE_CYRIX_5520 0x0002 -#define PCIR_DEVICE_CYRIX_5530_LEGACY 0x0100 -#define PCIR_DEVICE_CYRIX_5530_SMI 0x0101 -#define PCIR_DEVICE_CYRIX_5530_IDE 0x0102 -#define PCIR_DEVICE_CYRIX_5530_AUDIO 0x0103 -#define PCIR_DEVICE_CYRIX_5530_VIDEO 0x0104 - -#define PCIR_VENDOR_LEADTEK 0x107d -#define PCIR_DEVICE_LEADTEK_805 0x0000 - -#define PCIR_VENDOR_CONTAQ 0x1080 -#define PCIR_DEVICE_CONTAQ_82C599 0x0600 -#define PCIR_DEVICE_CONTAQ_82C693 0xc693 - -#define PCIR_VENDOR_FOREX 0x1083 - -#define PCIR_VENDOR_OLICOM 0x108d -#define PCIR_DEVICE_OLICOM_OC3136 0x0001 -#define PCIR_DEVICE_OLICOM_OC2315 0x0011 -#define PCIR_DEVICE_OLICOM_OC2325 0x0012 -#define PCIR_DEVICE_OLICOM_OC2183 0x0013 -#define PCIR_DEVICE_OLICOM_OC2326 0x0014 -#define PCIR_DEVICE_OLICOM_OC6151 0x0021 - -#define PCIR_VENDOR_SUN 0x108e -#define PCIR_DEVICE_SUN_EBUS 0x1000 -#define PCIR_DEVICE_SUN_HAPPYMEAL 0x1001 -#define PCIR_DEVICE_SUN_SIMBA 0x5000 -#define PCIR_DEVICE_SUN_PBM 0x8000 -#define PCIR_DEVICE_SUN_SABRE 0xa000 - -#define PCIR_VENDOR_CMD 0x1095 -#define PCIR_DEVICE_CMD_640 0x0640 -#define PCIR_DEVICE_CMD_643 0x0643 -#define PCIR_DEVICE_CMD_646 0x0646 -#define PCIR_DEVICE_CMD_647 0x0647 -#define PCIR_DEVICE_CMD_670 0x0670 - -#define PCIR_VENDOR_VISION 0x1098 -#define PCIR_DEVICE_VISION_QD8500 0x0001 -#define PCIR_DEVICE_VISION_QD8580 0x0002 - -#define PCIR_VENDOR_BROOKTREE 0x109e -#define PCIR_DEVICE_BROOKTREE_848 0x0350 -#define PCIR_DEVICE_BROOKTREE_849A 0x0351 -#define PCIR_DEVICE_BROOKTREE_8474 0x8474 - -#define PCIR_VENDOR_SIERRA 0x10a8 -#define PCIR_DEVICE_SIERRA_STB 0x0000 - -#define PCIR_VENDOR_ACC 0x10aa -#define PCIR_DEVICE_ACC_2056 0x0000 - -#define PCIR_VENDOR_WINBOND 0x10ad -#define PCIR_DEVICE_WINBOND_83769 0x0001 -#define PCIR_DEVICE_WINBOND_82C105 0x0105 -#define PCIR_DEVICE_WINBOND_83C553 0x0565 - -#define PCIR_VENDOR_DATABOOK 0x10b3 -#define PCIR_DEVICE_DATABOOK_87144 0xb106 - -#define PCIR_VENDOR_PLX 0x10b5 -#define PCIR_DEVICE_PLX_9050 0x9050 -#define PCIR_DEVICE_PLX_9060 0x9060 -#define PCIR_DEVICE_PLX_9060ES 0x906E -#define PCIR_DEVICE_PLX_9060SD 0x906D -#define PCIR_DEVICE_PLX_9080 0x9080 - -#define PCIR_VENDOR_MADGE 0x10b6 -#define PCIR_DEVICE_MADGE_MK2 0x0002 -#define PCIR_DEVICE_MADGE_C155S 0x1001 - -#define PCIR_VENDOR_3COM 0x10b7 -#define PCIR_DEVICE_3COM_3C339 0x3390 -#define PCIR_DEVICE_3COM_3C590 0x5900 -#define PCIR_DEVICE_3COM_3C595TX 0x5950 -#define PCIR_DEVICE_3COM_3C595T4 0x5951 -#define PCIR_DEVICE_3COM_3C595MII 0x5952 -#define PCIR_DEVICE_3COM_3C900TPO 0x9000 -#define PCIR_DEVICE_3COM_3C900COMBO 0x9001 -#define PCIR_DEVICE_3COM_3C905TX 0x9050 -#define PCIR_DEVICE_3COM_3C905T4 0x9051 -#define PCIR_DEVICE_3COM_3C905B_TX 0x9055 - -#define PCIR_VENDOR_SMC 0x10b8 -#define PCIR_DEVICE_SMC_EPIC100 0x0005 - -#define PCIR_VENDOR_AL 0x10b9 -#define PCIR_DEVICE_AL_M1445 0x1445 -#define PCIR_DEVICE_AL_M1449 0x1449 -#define PCIR_DEVICE_AL_M1451 0x1451 -#define PCIR_DEVICE_AL_M1461 0x1461 -#define PCIR_DEVICE_AL_M1489 0x1489 -#define PCIR_DEVICE_AL_M1511 0x1511 -#define PCIR_DEVICE_AL_M1513 0x1513 -#define PCIR_DEVICE_AL_M1521 0x1521 -#define PCIR_DEVICE_AL_M1523 0x1523 -#define PCIR_DEVICE_AL_M1531 0x1531 -#define PCIR_DEVICE_AL_M1533 0x1533 -#define PCIR_DEVICE_AL_M3307 0x3307 -#define PCIR_DEVICE_AL_M4803 0x5215 -#define PCIR_DEVICE_AL_M5219 0x5219 -#define PCIR_DEVICE_AL_M5229 0x5229 -#define PCIR_DEVICE_AL_M5237 0x5237 -#define PCIR_DEVICE_AL_M7101 0x7101 - -#define PCIR_VENDOR_MITSUBISHI 0x10ba - -#define PCIR_VENDOR_SURECOM 0x10bd -#define PCIR_DEVICE_SURECOM_NE34 0x0e34 - -#define PCIR_VENDOR_NEOMAGIC 0x10c8 -#define PCIR_DEVICE_NEOMAGIC_MAGICGRAPH_NM2070 0x0001 -#define PCIR_DEVICE_NEOMAGIC_MAGICGRAPH_128V 0x0002 -#define PCIR_DEVICE_NEOMAGIC_MAGICGRAPH_128ZV 0x0003 -#define PCIR_DEVICE_NEOMAGIC_MAGICGRAPH_NM2160 0x0004 - -#define PCIR_VENDOR_ASP 0x10cd -#define PCIR_DEVICE_ASP_ABP940 0x1200 -#define PCIR_DEVICE_ASP_ABP940U 0x1300 -#define PCIR_DEVICE_ASP_ABP940UW 0x2300 - -#define PCIR_VENDOR_MACRONIX 0x10d9 -#define PCIR_DEVICE_MACRONIX_MX98713 0x0512 -#define PCIR_DEVICE_MACRONIX_MX987x5 0x0531 - -#define PCIR_VENDOR_CERN 0x10dc -#define PCIR_DEVICE_CERN_SPSB_PMC 0x0001 -#define PCIR_DEVICE_CERN_SPSB_PCI 0x0002 -#define PCIR_DEVICE_CERN_HIPPI_DST 0x0021 -#define PCIR_DEVICE_CERN_HIPPI_SRC 0x0022 - -#define PCIR_VENDOR_NVIDIA 0x10de - -#define PCIR_VENDOR_IMS 0x10e0 -#define PCIR_DEVICE_IMS_8849 0x8849 - -#define PCIR_VENDOR_TEKRAM2 0x10e1 -#define PCIR_DEVICE_TEKRAM2_690c 0x690c - -#define PCIR_VENDOR_TUNDRA 0x10e3 -#define PCIR_DEVICE_TUNDRA_CA91C042 0x0000 - -#define PCIR_VENDOR_AMCC 0x10e8 -#define PCIR_DEVICE_AMCC_MYRINET 0x8043 -#define PCIR_DEVICE_AMCC_PARASTATION 0x8062 -#define PCIR_DEVICE_AMCC_S5933 0x807d -#define PCIR_DEVICE_AMCC_S5933_HEPC3 0x809c - -#define PCIR_VENDOR_INTERG 0x10ea -#define PCIR_DEVICE_INTERG_1680 0x1680 -#define PCIR_DEVICE_INTERG_1682 0x1682 - -#define PCIR_VENDOR_REALTEK 0x10ec -#define PCIR_DEVICE_REALTEK_8029 0x8029 -#define PCIR_DEVICE_REALTEK_8129 0x8129 -#define PCIR_DEVICE_REALTEK_8139 0x8139 - -#define PCIR_VENDOR_TRUEVISION 0x10fa -#define PCIR_DEVICE_TRUEVISION_T1000 0x000c - -#define PCIR_VENDOR_INIT 0x1101 -#define PCIR_DEVICE_INIT_320P 0x9100 -#define PCIR_DEVICE_INIT_360P 0x9500 - -#define PCIR_VENDOR_TTI 0x1103 -#define PCIR_DEVICE_TTI_HPT343 0x0003 - -#define PCIR_VENDOR_VIA 0x1106 -#define PCIR_DEVICE_VIA_82C505 0x0505 -#define PCIR_DEVICE_VIA_82C561 0x0561 -#define PCIR_DEVICE_VIA_82C586_1 0x0571 -#define PCIR_DEVICE_VIA_82C576 0x0576 -#define PCIR_DEVICE_VIA_82C585 0x0585 -#define PCIR_DEVICE_VIA_82C586_0 0x0586 -#define PCIR_DEVICE_VIA_82C595 0x0595 -#define PCIR_DEVICE_VIA_82C597_0 0x0597 -#define PCIR_DEVICE_VIA_82C926 0x0926 -#define PCIR_DEVICE_VIA_82C416 0x1571 -#define PCIR_DEVICE_VIA_82C595_97 0x1595 -#define PCIR_DEVICE_VIA_82C586_2 0x3038 -#define PCIR_DEVICE_VIA_82C586_3 0x3040 -#define PCIR_DEVICE_VIA_86C100A 0x6100 -#define PCIR_DEVICE_VIA_82C597_1 0x8597 - -#define PCIR_VENDOR_VORTEX 0x1119 -#define PCIR_DEVICE_VORTEX_GDT60x0 0x0000 -#define PCIR_DEVICE_VORTEX_GDT6000B 0x0001 -#define PCIR_DEVICE_VORTEX_GDT6x10 0x0002 -#define PCIR_DEVICE_VORTEX_GDT6x20 0x0003 -#define PCIR_DEVICE_VORTEX_GDT6530 0x0004 -#define PCIR_DEVICE_VORTEX_GDT6550 0x0005 -#define PCIR_DEVICE_VORTEX_GDT6x17 0x0006 -#define PCIR_DEVICE_VORTEX_GDT6x27 0x0007 -#define PCIR_DEVICE_VORTEX_GDT6537 0x0008 -#define PCIR_DEVICE_VORTEX_GDT6557 0x0009 -#define PCIR_DEVICE_VORTEX_GDT6x15 0x000a -#define PCIR_DEVICE_VORTEX_GDT6x25 0x000b -#define PCIR_DEVICE_VORTEX_GDT6535 0x000c -#define PCIR_DEVICE_VORTEX_GDT6555 0x000d -#define PCIR_DEVICE_VORTEX_GDT6x17RP 0x0100 -#define PCIR_DEVICE_VORTEX_GDT6x27RP 0x0101 -#define PCIR_DEVICE_VORTEX_GDT6537RP 0x0102 -#define PCIR_DEVICE_VORTEX_GDT6557RP 0x0103 -#define PCIR_DEVICE_VORTEX_GDT6x11RP 0x0104 -#define PCIR_DEVICE_VORTEX_GDT6x21RP 0x0105 -#define PCIR_DEVICE_VORTEX_GDT6x17RP1 0x0110 -#define PCIR_DEVICE_VORTEX_GDT6x27RP1 0x0111 -#define PCIR_DEVICE_VORTEX_GDT6537RP1 0x0112 -#define PCIR_DEVICE_VORTEX_GDT6557RP1 0x0113 -#define PCIR_DEVICE_VORTEX_GDT6x11RP1 0x0114 -#define PCIR_DEVICE_VORTEX_GDT6x21RP1 0x0115 -#define PCIR_DEVICE_VORTEX_GDT6x17RP2 0x0120 -#define PCIR_DEVICE_VORTEX_GDT6x27RP2 0x0121 -#define PCIR_DEVICE_VORTEX_GDT6537RP2 0x0122 -#define PCIR_DEVICE_VORTEX_GDT6557RP2 0x0123 -#define PCIR_DEVICE_VORTEX_GDT6x11RP2 0x0124 -#define PCIR_DEVICE_VORTEX_GDT6x21RP2 0x0125 - -#define PCIR_VENDOR_EF 0x111a -#define PCIR_DEVICE_EF_ATM_FPGA 0x0000 -#define PCIR_DEVICE_EF_ATM_ASIC 0x0002 - -#define PCIR_VENDOR_FORE 0x1127 -#define PCIR_DEVICE_FORE_PCA200PC 0x0210 -#define PCIR_DEVICE_FORE_PCA200E 0x0300 - -#define PCIR_VENDOR_IMAGINGTECH 0x112f -#define PCIR_DEVICE_IMAGINGTECH_ICPCI 0x0000 - -#define PCIR_VENDOR_PHILIPS 0x1131 -#define PCIR_DEVICE_PHILIPS_SAA7145 0x7145 -#define PCIR_DEVICE_PHILIPS_SAA7146 0x7146 - -#define PCIR_VENDOR_CYCLONE 0x113c -#define PCIR_DEVICE_CYCLONE_SDK 0x0001 - -#define PCIR_VENDOR_ALLIANCE 0x1142 -#define PCIR_DEVICE_ALLIANCE_PROMOTIO 0x3210 -#define PCIR_DEVICE_ALLIANCE_PROVIDEO 0x6422 -#define PCIR_DEVICE_ALLIANCE_AT24 0x6424 -#define PCIR_DEVICE_ALLIANCE_AT3D 0x643d - -#define PCIR_VENDOR_SK 0x1148 -#define PCIR_DEVICE_SK_FP 0x4000 -#define PCIR_DEVICE_SK_TR 0x4200 -#define PCIR_DEVICE_SK_GE 0x4300 - -#define PCIR_VENDOR_VMIC 0x114a -#define PCIR_DEVICE_VMIC_VME 0x7587 - -#define PCIR_VENDOR_DIGI 0x114f -#define PCIR_DEVICE_DIGI_EPC 0x0002 -#define PCIR_DEVICE_DIGI_RIGHTSWITCH 0x0003 -#define PCIR_DEVICE_DIGI_XEM 0x0004 -#define PCIR_DEVICE_DIGI_XR 0x0005 -#define PCIR_DEVICE_DIGI_CX 0x0006 -#define PCIR_DEVICE_DIGI_XRJ 0x0009 -#define PCIR_DEVICE_DIGI_EPCJ 0x000a -#define PCIR_DEVICE_DIGI_XR_920 0x0027 - -#define PCIR_VENDOR_MUTECH 0x1159 -#define PCIR_DEVICE_MUTECH_MV1000 0x0001 - -#define PCIR_VENDOR_RENDITION 0x1163 -#define PCIR_DEVICE_RENDITION_VERITE 0x0001 -#define PCIR_DEVICE_RENDITION_VERITE2100 0x2000 - -#define PCIR_VENDOR_TOSHIBA 0x1179 -#define PCIR_DEVICE_TOSHIBA_601 0x0601 -#define PCIR_DEVICE_TOSHIBA_TOPIC95 0x060a -#define PCIR_DEVICE_TOSHIBA_TOPIC97 0x060f - -#define PCIR_VENDOR_RICOH 0x1180 -#define PCIR_DEVICE_RICOH_RL5C465 0x0465 -#define PCIR_DEVICE_RICOH_RL5C466 0x0466 -#define PCIR_DEVICE_RICOH_RL5C475 0x0475 -#define PCIR_DEVICE_RICOH_RL5C478 0x0478 - -#define PCIR_VENDOR_ARTOP 0x1191 -#define PCIR_DEVICE_ARTOP_ATP8400 0x0004 -#define PCIR_DEVICE_ARTOP_ATP850UF 0x0005 - -#define PCIR_VENDOR_ZEITNET 0x1193 -#define PCIR_DEVICE_ZEITNET_1221 0x0001 -#define PCIR_DEVICE_ZEITNET_1225 0x0002 - -#define PCIR_VENDOR_OMEGA 0x119b -#define PCIR_DEVICE_OMEGA_82C092G 0x1221 - -#define PCIR_VENDOR_LITEON 0x11ad -#define PCIR_DEVICE_LITEON_LNE100TX 0x0002 - -#define PCIR_VENDOR_NP 0x11bc -#define PCIR_DEVICE_NP_PCI_FDDI 0x0001 - -#define PCIR_VENDOR_ATT 0x11c1 -#define PCIR_DEVICE_ATT_L56XMF 0x0440 - -#define PCIR_VENDOR_SPECIALIX 0x11cb -#define PCIR_DEVICE_SPECIALIX_IO8 0x2000 -#define PCIR_DEVICE_SPECIALIX_XIO 0x4000 -#define PCIR_DEVICE_SPECIALIX_RIO 0x8000 - -#define PCIR_VENDOR_AURAVISION 0x11d1 -#define PCIR_DEVICE_AURAVISION_VXP524 0x01f7 - -#define PCIR_VENDOR_IKON 0x11d5 -#define PCIR_DEVICE_IKON_10115 0x0115 -#define PCIR_DEVICE_IKON_10117 0x0117 - -#define PCIR_VENDOR_ZORAN 0x11de -#define PCIR_DEVICE_ZORAN_36057 0x6057 -#define PCIR_DEVICE_ZORAN_36120 0x6120 - -#define PCIR_VENDOR_KINETIC 0x11f4 -#define PCIR_DEVICE_KINETIC_2915 0x2915 - -#define PCIR_VENDOR_COMPEX 0x11f6 -#define PCIR_DEVICE_COMPEX_ENET100VG4 0x0112 -#define PCIR_DEVICE_COMPEX_RL2000 0x1401 - -#define PCIR_VENDOR_RP 0x11fe -#define PCIR_DEVICE_RP32INTF 0x0001 -#define PCIR_DEVICE_RP8INTF 0x0002 -#define PCIR_DEVICE_RP16INTF 0x0003 -#define PCIR_DEVICE_RP4QUAD 0x0004 -#define PCIR_DEVICE_RP8OCTA 0x0005 -#define PCIR_DEVICE_RP8J 0x0006 -#define PCIR_DEVICE_RPP4 0x000A -#define PCIR_DEVICE_RPP8 0x000B -#define PCIR_DEVICE_RP8M 0x000C - -#define PCIR_VENDOR_CYCLADES 0x120e -#define PCIR_DEVICE_CYCLOM_Y_Lo 0x0100 -#define PCIR_DEVICE_CYCLOM_Y_Hi 0x0101 -#define PCIR_DEVICE_CYCLOM_Z_Lo 0x0200 -#define PCIR_DEVICE_CYCLOM_Z_Hi 0x0201 - -#define PCIR_VENDOR_ESSENTIAL 0x120f -#define PCIR_DEVICE_ESSENTIAL_ROADRUNNER 0x0001 - -#define PCIR_VENDOR_O2 0x1217 -#define PCIR_DEVICE_O2_6729 0x6729 -#define PCIR_DEVICE_O2_6730 0x673a -#define PCIR_DEVICE_O2_6832 0x6832 -#define PCIR_DEVICE_O2_6836 0x6836 - -#define PCIR_VENDOR_3DFX 0x121a -#define PCIR_DEVICE_3DFX_VOODOO 0x0001 -#define PCIR_DEVICE_3DFX_VOODOO2 0x0002 - -#define PCIR_VENDOR_SIGMADES 0x1236 -#define PCIR_DEVICE_SIGMADES_6425 0x6401 - -#define PCIR_VENDOR_CCUBE 0x123f - -#define PCIR_VENDOR_DIPIX 0x1246 - -#define PCIR_VENDOR_STALLION 0x124d -#define PCIR_DEVICE_STALLION_ECHPCI832 0x0000 -#define PCIR_DEVICE_STALLION_ECHPCI864 0x0002 -#define PCIR_DEVICE_STALLION_EIOPCI 0x0003 - -#define PCIR_VENDOR_OPTIBASE 0x1255 -#define PCIR_DEVICE_OPTIBASE_FORGE 0x1110 -#define PCIR_DEVICE_OPTIBASE_FUSION 0x1210 -#define PCIR_DEVICE_OPTIBASE_VPLEX 0x2110 -#define PCIR_DEVICE_OPTIBASE_VPLEXCC 0x2120 -#define PCIR_DEVICE_OPTIBASE_VQUEST 0x2130 - -#define PCIR_VENDOR_SATSAGEM 0x1267 -#define PCIR_DEVICE_SATSAGEM_PCR2101 0x5352 -#define PCIR_DEVICE_SATSAGEM_TELSATTURBO 0x5a4b - -#define PCIR_VENDOR_HUGHES 0x1273 -#define PCIR_DEVICE_HUGHES_DIRECPC 0x0002 - -#define PCIR_VENDOR_ENSONIQ 0x1274 -#define PCIR_DEVICE_ENSONIQ_AUDIOPCI 0x5000 - -#define PCIR_VENDOR_ALTEON 0x12ae -#define PCIR_DEVICE_ALTEON_ACENIC 0x0001 - -#define PCIR_VENDOR_PICTUREL 0x12c5 -#define PCIR_DEVICE_PICTUREL_PCIVST 0x0081 - -#define PCIR_VENDOR_NVIDIA_SGS 0x12d2 -#define PCIR_DEVICE_NVIDIA_SGS_RIVA128 0x0018 - -#define PCIR_VENDOR_CBOARDS 0x1307 -#define PCIR_DEVICE_CBOARDS_DAS1602_16 0x0001 - -#define PCIR_VENDOR_SYMPHONY 0x1c1c -#define PCIR_DEVICE_SYMPHONY_101 0x0001 - -#define PCIR_VENDOR_TEKRAM 0x1de1 -#define PCIR_DEVICE_TEKRAM_DC290 0xdc29 - -#define PCIR_VENDOR_3DLABS 0x3d3d -#define PCIR_DEVICE_3DLABS_300SX 0x0001 -#define PCIR_DEVICE_3DLABS_500TX 0x0002 -#define PCIR_DEVICE_3DLABS_DELTA 0x0003 -#define PCIR_DEVICE_3DLABS_PERMEDIA 0x0004 -#define PCIR_DEVICE_3DLABS_MX 0x0006 - -#define PCIR_VENDOR_AVANCE 0x4005 -#define PCIR_DEVICE_AVANCE_ALG2064 0x2064 -#define PCIR_DEVICE_AVANCE_2302 0x2302 - -#define PCIR_VENDOR_NETVIN 0x4a14 -#define PCIR_DEVICE_NETVIN_NV5000SC 0x5000 - -#define PCIR_VENDOR_S3 0x5333 -#define PCIR_DEVICE_S3_PLATO_PXS 0x0551 -#define PCIR_DEVICE_S3_ViRGE 0x5631 -#define PCIR_DEVICE_S3_TRIO 0x8811 -#define PCIR_DEVICE_S3_AURORA64VP 0x8812 -#define PCIR_DEVICE_S3_TRIO64UVP 0x8814 -#define PCIR_DEVICE_S3_ViRGE_VX 0x883d -#define PCIR_DEVICE_S3_868 0x8880 -#define PCIR_DEVICE_S3_928 0x88b0 -#define PCIR_DEVICE_S3_864_1 0x88c0 -#define PCIR_DEVICE_S3_864_2 0x88c1 -#define PCIR_DEVICE_S3_964_1 0x88d0 -#define PCIR_DEVICE_S3_964_2 0x88d1 -#define PCIR_DEVICE_S3_968 0x88f0 -#define PCIR_DEVICE_S3_TRIO64V2 0x8901 -#define PCIR_DEVICE_S3_PLATO_PXG 0x8902 -#define PCIR_DEVICE_S3_ViRGE_DXGX 0x8a01 -#define PCIR_DEVICE_S3_ViRGE_GX2 0x8a10 -#define PCIR_DEVICE_S3_ViRGE_MX 0x8c01 -#define PCIR_DEVICE_S3_ViRGE_MXP 0x8c02 -#define PCIR_DEVICE_S3_ViRGE_MXPMV 0x8c03 -#define PCIR_DEVICE_S3_SONICVIBES 0xca00 - -#define PCIR_VENDOR_INTEL 0x8086 -#define PCIR_DEVICE_INTEL_82375 0x0482 -#define PCIR_DEVICE_INTEL_82424 0x0483 -#define PCIR_DEVICE_INTEL_82378 0x0484 -#define PCIR_DEVICE_INTEL_82430 0x0486 -#define PCIR_DEVICE_INTEL_82434 0x04a3 -#define PCIR_DEVICE_INTEL_82092AA_0 0x1221 -#define PCIR_DEVICE_INTEL_82092AA_1 0x1222 -#define PCIR_DEVICE_INTEL_7116 0x1223 -#define PCIR_DEVICE_INTEL_82596 0x1226 -#define PCIR_DEVICE_INTEL_82865 0x1227 -#define PCIR_DEVICE_INTEL_82557 0x1229 -#define PCIR_DEVICE_INTEL_82437 0x122d -#define PCIR_DEVICE_INTEL_82371FB_0 0x122e -#define PCIR_DEVICE_INTEL_82371FB_1 0x1230 -#define PCIR_DEVICE_INTEL_82371MX 0x1234 -#define PCIR_DEVICE_INTEL_82437MX 0x1235 -#define PCIR_DEVICE_INTEL_82441 0x1237 -#define PCIR_DEVICE_INTEL_82380FB 0x124b -#define PCIR_DEVICE_INTEL_82439 0x1250 -#define PCIR_DEVICE_INTEL_82371SB_0 0x7000 -#define PCIR_DEVICE_INTEL_82371SB_1 0x7010 -#define PCIR_DEVICE_INTEL_82371SB_2 0x7020 -#define PCIR_DEVICE_INTEL_82437VX 0x7030 -#define PCIR_DEVICE_INTEL_82439TX 0x7100 -#define PCIR_DEVICE_INTEL_82371AB_0 0x7110 -#define PCIR_DEVICE_INTEL_82371AB 0x7111 -#define PCIR_DEVICE_INTEL_82371AB_2 0x7112 -#define PCIR_DEVICE_INTEL_82371AB_3 0x7113 -#define PCIR_DEVICE_INTEL_82443LX_0 0x7180 -#define PCIR_DEVICE_INTEL_82443LX_1 0x7181 -#define PCIR_DEVICE_INTEL_82443BX_0 0x7190 -#define PCIR_DEVICE_INTEL_82443BX_1 0x7191 -#define PCIR_DEVICE_INTEL_82443BX_2 0x7192 -#define PCIR_DEVICE_INTEL_P6 0x84c4 -#define PCIR_DEVICE_INTEL_82450GX 0x84c5 - -#define PCIR_VENDOR_KTI 0x8e2e -#define PCIR_DEVICE_KTI_ET32P2 0x3000 - -#define PCIR_VENDOR_ADAPTEC 0x9004 -#define PCIR_DEVICE_ADAPTEC_7810 0x1078 -#define PCIR_DEVICE_ADAPTEC_7850 0x5078 -#define PCIR_DEVICE_ADAPTEC_7855 0x5578 -#define PCIR_DEVICE_ADAPTEC_5800 0x5800 -#define PCIR_DEVICE_ADAPTEC_1480A 0x6075 -#define PCIR_DEVICE_ADAPTEC_7860 0x6078 -#define PCIR_DEVICE_ADAPTEC_7861 0x6178 -#define PCIR_DEVICE_ADAPTEC_7870 0x7078 -#define PCIR_DEVICE_ADAPTEC_7871 0x7178 -#define PCIR_DEVICE_ADAPTEC_7872 0x7278 -#define PCIR_DEVICE_ADAPTEC_7873 0x7378 -#define PCIR_DEVICE_ADAPTEC_7874 0x7478 -#define PCIR_DEVICE_ADAPTEC_7895 0x7895 -#define PCIR_DEVICE_ADAPTEC_7880 0x8078 -#define PCIR_DEVICE_ADAPTEC_7881 0x8178 -#define PCIR_DEVICE_ADAPTEC_7882 0x8278 -#define PCIR_DEVICE_ADAPTEC_7883 0x8378 -#define PCIR_DEVICE_ADAPTEC_7884 0x8478 -#define PCIR_DEVICE_ADAPTEC_1030 0x8b78 - -#define PCIR_VENDOR_ADAPTEC2 0x9005 -#define PCIR_DEVICE_ADAPTEC2_2940U2 0x0010 -#define PCIR_DEVICE_ADAPTEC2_7890 0x001f -#define PCIR_DEVICE_ADAPTEC2_3940U2 0x0050 -#define PCIR_DEVICE_ADAPTEC2_7896 0x005f - -#define PCIR_VENDOR_ATRONICS 0x907f -#define PCIR_DEVICE_ATRONICS_2015 0x2015 - -#define PCIR_VENDOR_HOLTEK 0x9412 -#define PCIR_DEVICE_HOLTEK_6565 0x6565 - -#define PCIR_VENDOR_TIGERJET 0xe159 -#define PCIR_DEVICE_TIGERJET_300 0x0001 - -#define PCIR_VENDOR_ARK 0xedd8 -#define PCIR_DEVICE_ARK_STING 0xa091 -#define PCIR_DEVICE_ARK_STINGARK 0xa099 -#define PCIR_DEVICE_ARK_2000MT 0xa0a1 - -#endif /* !__PCI_IDS_H__ */ diff --git a/cpukit/libpci/pci/ids_extra.h b/cpukit/libpci/pci/ids_extra.h deleted file mode 100644 index 0b85fe2764..0000000000 --- a/cpukit/libpci/pci/ids_extra.h +++ /dev/null @@ -1,22 +0,0 @@ -/* RTEMS local PCI data base */ - -/* Only included from pci_ids.h */ -#ifndef __PCI_IDS_H__ -#error pci/ids_extra.h should only be included from pci/ids.h -#endif - -/* Gaisler PCI IDs */ -#define PCIID_VENDOR_GAISLER 0x1AC8 -#define PCIID_VENDOR_GAISLER_OLD 0x16E3 - -/* Gaisler PCI Devices */ -#define PCIID_DEVICE_GR_RASTA_IO 0x0010 /* GR-RASTA-IO */ -#define PCIID_DEVICE_GR_RASTA_IO_OLD 0x0210 /* old GR-RASTA-IO ID*/ -#define PCIID_DEVICE_GR_RASTA_TMTC 0x0011 /* GR-RASTA-TMTC */ -#define PCIID_DEVICE_GR_RASTA_ADCDAC 0x0014 /* GR-RASTA-ADCDAC */ -#define PCIID_DEVICE_GR_701 0x0701 /* GR-701 */ -#define PCIID_DEVICE_GR_TMTC_1553 0x0198 /* GR-TMTC-1553 */ -#define PCIID_DEVICE_GR_RASTA_SPW_RTR 0x0062 /* GR-RASTA-SPW-ROUTER */ -#define PCIID_DEVICE_GR_LEON4_N2X 0x0061 /* GR-CPCI-LEON4-N2X */ -#define PCIID_DEVICE_GR_NGMP_PROTO 0x0064 /* GR-NGMP_PROTO */ -#define PCIID_DEVICE_GR_CPCI_GR740 0x0740 /* GR-CPCI-GR740 */ diff --git a/cpukit/libpci/pci/irq.h b/cpukit/libpci/pci/irq.h deleted file mode 100644 index 7622201fd6..0000000000 --- a/cpukit/libpci/pci/irq.h +++ /dev/null @@ -1,118 +0,0 @@ -/* PCI IRQ Library - * - * COPYRIGHT (c) 2010 Cobham Gaisler AB. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -/* IRQ handling does not have so much with PCI to do, this library depends - * on the BSP to implement shared interrupts. - */ - -#ifndef __PCI_IRQ_H__ -#define __PCI_IRQ_H__ - -#include -#include - -/* - * FIXME: This should be available via the IRQ extensions API. - * - * https://devel.rtems.org/ticket/3269 - */ -void BSP_shared_interrupt_clear(int irq); -void BSP_shared_interrupt_unmask(int irq); -void BSP_shared_interrupt_mask(int irq); - -/* PCI Handler (ISR) called when IRQ is generated by any of the PCI devices - * connected to the same PCI IRQ Pin. This has been defined the same way as - * rtems_interrupt_handler in order for BSPs to "direct-map" the register - * and unregister functions rtems_interrupt_handler_install/remove - */ -typedef void (*pci_isr)(void *arg); - -/* Get assigned system IRQ to a PCI Device. If no IRQ 0 is returned */ -extern int pci_dev_irq(pci_dev_t dev); - -/* Register shared PCI IRQ handler, but does not enable it. The system interrupt - * number is read from the PCI board's PCI configuration space header iline - * field. The iline field is initialized by the PCI subsystem during start up, - * the ipin field is translated into a system IRQ and written to iline. The - * board's driver should use the iline field as the irq argument to this - * function. - * - * Arguments - * irq System IRQ number, normally taken from the PCI configuration area - * isr Function pointer to the ISR - * arg Second argument to function isr - */ -RTEMS_INLINE_ROUTINE int pci_interrupt_register(int irq, const char *info, - pci_isr isr, void *arg) -{ - return rtems_interrupt_handler_install(irq, info, - RTEMS_INTERRUPT_SHARED, isr, - arg); -} - -/* Unregister previously registered shared PCI IRQ handler - * - * Arguments - * irq System IRQ number, normally taken from the PCI configuration area - * isr Function pointer to the ISR - * arg Second argument to function isr - */ -RTEMS_INLINE_ROUTINE int pci_interrupt_unregister(int irq, pci_isr isr, - void *arg) -{ - return rtems_interrupt_handler_remove(irq, isr, arg); -} - -/* Enable shared PCI IRQ handler. This function will unmask the interrupt - * controller and mark this interrupt handler ready to handle interrupts. Note - * that since it is a shared interrupt handler service the interrupt may - * already be enabled, however no calls to this specific handler is made - * until it is enabled. - * - * Arguments - * irq System IRQ number, normally taken from the PCI configuration area - * isr Function pointer to the ISR - * arg Second argument to function isr - */ -RTEMS_INLINE_ROUTINE void pci_interrupt_unmask(int irq) -{ - BSP_shared_interrupt_unmask(irq); -} - -/* Disable shared PCI IRQ handler. This function will mask the interrupt - * controller and mark this interrupt handler not ready to receive interrupts. - * Note that since it is a shared interrupt handler service the interrupt may - * still be enabled, however no calls to this specific handler is made - * while it is disabled. - * - * Arguments - * irq System IRQ number, normally taken from the PCI configuration area - * isr Function pointer to the ISR - * arg Second argument to function isr - */ -RTEMS_INLINE_ROUTINE void pci_interrupt_mask(int irq) -{ - BSP_shared_interrupt_mask(irq); -} - -/* Acknowledge the interrupt controller by writing to the interrupt controller. - * Note that since it is a shared interrupt handler service, clearing the - * interrupt source may affect other ISRs registered to this IRQ. - * - * Arguments - * irq System IRQ number, normally taken from the PCI configuration area - * isr Function pointer to the ISR - * arg Second argument to function isr - */ -RTEMS_INLINE_ROUTINE void pci_interrupt_clear(int irq) -{ - BSP_shared_interrupt_clear(irq); -} - -#endif /* !__PCI_IRQ_H__ */ diff --git a/cpukit/libpci/pci/pcireg.h b/cpukit/libpci/pci/pcireg.h deleted file mode 100644 index f2b2b74cf0..0000000000 --- a/cpukit/libpci/pci/pcireg.h +++ /dev/null @@ -1,931 +0,0 @@ -/*- - * Copyright (c) 1997, Stefan Esser - * All rights reserved. - * - * New PCI library written from scratch. Defines in this file was taken from - * FreeBSD commit f1d6f4778d2044502209708bc167c05f9aa48615. - * auto-generated pci_ids.h also reused from RTEMS. - * Copyright 2009, Cobham Gaisler AB - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice unmodified, this list of conditions, and the following - * disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - * - */ - -#ifndef __PCI_REG_H__ -#define __PCI_REG_H__ - -/* - * PCIM_xxx: mask to locate subfield in register - * PCIR_xxx: config register offset - * PCIC_xxx: device class - * PCIS_xxx: device subclass - * PCIP_xxx: device programming interface - * PCIV_xxx: PCI vendor ID (only required to fixup ancient devices) - * PCID_xxx: device ID - * PCIY_xxx: capability identification number - * PCIZ_xxx: extended capability identification number - */ - -/* some PCI bus constants */ -#define PCI_DOMAINMAX 65535 /* highest supported domain number */ -#define PCI_BUSMAX 255 /* highest supported bus number */ -#define PCI_SLOTMAX 31 /* highest supported slot number */ -#define PCI_FUNCMAX 7 /* highest supported function number */ -#define PCI_REGMAX 255 /* highest supported config register addr. */ -#define PCIE_REGMAX 4095 /* highest supported config register addr. */ -#define PCI_MAXHDRTYPE 2 - -#define PCIE_ARI_SLOTMAX 0 -#define PCIE_ARI_FUNCMAX 255 - -#define PCI_RID_BUS_SHIFT 8 -#define PCI_RID_SLOT_SHIFT 3 -#define PCI_RID_FUNC_SHIFT 0 - -#define PCI_RID(bus, slot, func) \ - ((((bus) & PCI_BUSMAX) << PCI_RID_BUS_SHIFT) | \ - (((slot) & PCI_SLOTMAX) << PCI_RID_SLOT_SHIFT) | \ - (((func) & PCI_FUNCMAX) << PCI_RID_FUNC_SHIFT)) - -#define PCI_ARI_RID(bus, func) \ - ((((bus) & PCI_BUSMAX) << PCI_RID_BUS_SHIFT) | \ - (((func) & PCIE_ARI_FUNCMAX) << PCI_RID_FUNC_SHIFT)) - -#define PCI_RID2BUS(rid) (((rid) >> PCI_RID_BUS_SHIFT) & PCI_BUSMAX) -#define PCI_RID2SLOT(rid) (((rid) >> PCI_RID_SLOT_SHIFT) & PCI_SLOTMAX) -#define PCI_RID2FUNC(rid) (((rid) >> PCI_RID_FUNC_SHIFT) & PCI_FUNCMAX) - -#define PCIE_ARI_SLOT(func) (((func) >> PCI_RID_SLOT_SHIFT) & PCI_SLOTMAX) -#define PCIE_ARI_FUNC(func) (((func) >> PCI_RID_FUNC_SHIFT) & PCI_FUNCMAX) - -/* PCI config header registers for all devices */ - -#define PCIR_DEVVENDOR 0x00 -#define PCIR_VENDOR 0x00 -#define PCIR_DEVICE 0x02 -#define PCIR_COMMAND 0x04 -#define PCIM_CMD_PORTEN 0x0001 -#define PCIM_CMD_MEMEN 0x0002 -#define PCIM_CMD_BUSMASTEREN 0x0004 -#define PCIM_CMD_SPECIALEN 0x0008 -#define PCIM_CMD_MWRICEN 0x0010 -#define PCIM_CMD_PERRESPEN 0x0040 -#define PCIM_CMD_SERRESPEN 0x0100 -#define PCIM_CMD_BACKTOBACK 0x0200 -#define PCIM_CMD_INTxDIS 0x0400 -#define PCIR_STATUS 0x06 -#define PCIM_STATUS_INTxSTATE 0x0008 -#define PCIM_STATUS_CAPPRESENT 0x0010 -#define PCIM_STATUS_66CAPABLE 0x0020 -#define PCIM_STATUS_BACKTOBACK 0x0080 -#define PCIM_STATUS_MDPERR 0x0100 -#define PCIM_STATUS_SEL_FAST 0x0000 -#define PCIM_STATUS_SEL_MEDIMUM 0x0200 -#define PCIM_STATUS_SEL_SLOW 0x0400 -#define PCIM_STATUS_SEL_MASK 0x0600 -#define PCIM_STATUS_STABORT 0x0800 -#define PCIM_STATUS_RTABORT 0x1000 -#define PCIM_STATUS_RMABORT 0x2000 -#define PCIM_STATUS_SERR 0x4000 -#define PCIM_STATUS_PERR 0x8000 -#define PCIR_REVID 0x08 -#define PCIR_PROGIF 0x09 -#define PCIR_SUBCLASS 0x0a -#define PCIR_CLASS 0x0b -#define PCIR_CACHELNSZ 0x0c -#define PCIR_LATTIMER 0x0d -#define PCIR_HDRTYPE 0x0e -#define PCIM_HDRTYPE 0x7f -#define PCIM_HDRTYPE_NORMAL 0x00 -#define PCIM_HDRTYPE_BRIDGE 0x01 -#define PCIM_HDRTYPE_CARDBUS 0x02 -#define PCIM_MFDEV 0x80 -#define PCIR_BIST 0x0f - -/* Capability Register Offsets */ - -#define PCICAP_ID 0x0 -#define PCICAP_NEXTPTR 0x1 - -/* Capability Identification Numbers */ - -#define PCIY_PMG 0x01 /* PCI Power Management */ -#define PCIY_AGP 0x02 /* AGP */ -#define PCIY_VPD 0x03 /* Vital Product Data */ -#define PCIY_SLOTID 0x04 /* Slot Identification */ -#define PCIY_MSI 0x05 /* Message Signaled Interrupts */ -#define PCIY_CHSWP 0x06 /* CompactPCI Hot Swap */ -#define PCIY_PCIX 0x07 /* PCI-X */ -#define PCIY_HT 0x08 /* HyperTransport */ -#define PCIY_VENDOR 0x09 /* Vendor Unique */ -#define PCIY_DEBUG 0x0a /* Debug port */ -#define PCIY_CRES 0x0b /* CompactPCI central resource control */ -#define PCIY_HOTPLUG 0x0c /* PCI Hot-Plug */ -#define PCIY_SUBVENDOR 0x0d /* PCI-PCI bridge subvendor ID */ -#define PCIY_AGP8X 0x0e /* AGP 8x */ -#define PCIY_SECDEV 0x0f /* Secure Device */ -#define PCIY_EXPRESS 0x10 /* PCI Express */ -#define PCIY_MSIX 0x11 /* MSI-X */ -#define PCIY_SATA 0x12 /* SATA */ -#define PCIY_PCIAF 0x13 /* PCI Advanced Features */ - -/* Extended Capability Register Fields */ - -#define PCIR_EXTCAP 0x100 -#define PCIM_EXTCAP_ID 0x0000ffff -#define PCIM_EXTCAP_VER 0x000f0000 -#define PCIM_EXTCAP_NEXTPTR 0xfff00000 -#define PCI_EXTCAP_ID(ecap) ((ecap) & PCIM_EXTCAP_ID) -#define PCI_EXTCAP_VER(ecap) (((ecap) & PCIM_EXTCAP_VER) >> 16) -#define PCI_EXTCAP_NEXTPTR(ecap) (((ecap) & PCIM_EXTCAP_NEXTPTR) >> 20) - -/* Extended Capability Identification Numbers */ - -#define PCIZ_AER 0x0001 /* Advanced Error Reporting */ -#define PCIZ_VC 0x0002 /* Virtual Channel if MFVC Ext Cap not set */ -#define PCIZ_SERNUM 0x0003 /* Device Serial Number */ -#define PCIZ_PWRBDGT 0x0004 /* Power Budgeting */ -#define PCIZ_RCLINK_DCL 0x0005 /* Root Complex Link Declaration */ -#define PCIZ_RCLINK_CTL 0x0006 /* Root Complex Internal Link Control */ -#define PCIZ_RCEC_ASSOC 0x0007 /* Root Complex Event Collector Association */ -#define PCIZ_MFVC 0x0008 /* Multi-Function Virtual Channel */ -#define PCIZ_VC2 0x0009 /* Virtual Channel if MFVC Ext Cap set */ -#define PCIZ_RCRB 0x000a /* RCRB Header */ -#define PCIZ_VENDOR 0x000b /* Vendor Unique */ -#define PCIZ_CAC 0x000c /* Configuration Access Correction -- obsolete */ -#define PCIZ_ACS 0x000d /* Access Control Services */ -#define PCIZ_ARI 0x000e /* Alternative Routing-ID Interpretation */ -#define PCIZ_ATS 0x000f /* Address Translation Services */ -#define PCIZ_SRIOV 0x0010 /* Single Root IO Virtualization */ -#define PCIZ_MRIOV 0x0011 /* Multiple Root IO Virtualization */ -#define PCIZ_MULTICAST 0x0012 /* Multicast */ -#define PCIZ_PAGE_REQ 0x0013 /* Page Request */ -#define PCIZ_AMD 0x0014 /* Reserved for AMD */ -#define PCIZ_RESIZE_BAR 0x0015 /* Resizable BAR */ -#define PCIZ_DPA 0x0016 /* Dynamic Power Allocation */ -#define PCIZ_TPH_REQ 0x0017 /* TPH Requester */ -#define PCIZ_LTR 0x0018 /* Latency Tolerance Reporting */ -#define PCIZ_SEC_PCIE 0x0019 /* Secondary PCI Express */ -#define PCIZ_PMUX 0x001a /* Protocol Multiplexing */ -#define PCIZ_PASID 0x001b /* Process Address Space ID */ -#define PCIZ_LN_REQ 0x001c /* LN Requester */ -#define PCIZ_DPC 0x001d /* Downstream Porto Containment */ -#define PCIZ_L1PM 0x001e /* L1 PM Substates */ - -/* config registers for header type 0 devices */ - -#define PCIR_BARS 0x10 -#define PCIR_BAR(x) (PCIR_BARS + (x) * 4) -#define PCIR_MAX_BAR_0 5 -#define PCI_RID2BAR(rid) (((rid) - PCIR_BARS) / 4) -#define PCI_BAR_IO(x) (((x) & PCIM_BAR_SPACE) == PCIM_BAR_IO_SPACE) -#define PCI_BAR_MEM(x) (((x) & PCIM_BAR_SPACE) == PCIM_BAR_MEM_SPACE) -#define PCIM_BAR_SPACE 0x00000001 -#define PCIM_BAR_MEM_SPACE 0 -#define PCIM_BAR_IO_SPACE 1 -#define PCIM_BAR_MEM_TYPE 0x00000006 -#define PCIM_BAR_MEM_32 0 -#define PCIM_BAR_MEM_1MB 2 /* Locate below 1MB in PCI <= 2.1 */ -#define PCIM_BAR_MEM_64 4 -#define PCIM_BAR_MEM_PREFETCH 0x00000008 -#define PCIM_BAR_MEM_BASE 0xfffffffffffffff0ULL -#define PCIM_BAR_IO_RESERVED 0x00000002 -#define PCIM_BAR_IO_BASE 0xfffffffc -#define PCIR_CIS 0x28 -#define PCIM_CIS_ASI_MASK 0x00000007 -#define PCIM_CIS_ASI_CONFIG 0 -#define PCIM_CIS_ASI_BAR0 1 -#define PCIM_CIS_ASI_BAR1 2 -#define PCIM_CIS_ASI_BAR2 3 -#define PCIM_CIS_ASI_BAR3 4 -#define PCIM_CIS_ASI_BAR4 5 -#define PCIM_CIS_ASI_BAR5 6 -#define PCIM_CIS_ASI_ROM 7 -#define PCIM_CIS_ADDR_MASK 0x0ffffff8 -#define PCIM_CIS_ROM_MASK 0xf0000000 -#define PCIM_CIS_CONFIG_MASK 0xff -#define PCIR_SUBVEND_0 0x2c -#define PCIR_SUBDEV_0 0x2e -#define PCIR_BIOS 0x30 -#define PCIM_BIOS_ENABLE 0x01 -#define PCIM_BIOS_ADDR_MASK 0xfffff800 -#define PCIR_CAP_PTR 0x34 -#define PCIR_INTLINE 0x3c -#define PCIR_INTPIN 0x3d -#define PCIR_MINGNT 0x3e -#define PCIR_MAXLAT 0x3f - -/* config registers for header type 1 (PCI-to-PCI bridge) devices */ - -#define PCIR_MAX_BAR_1 1 -#define PCIR_SECSTAT_1 0x1e - -#define PCIR_PRIBUS_1 0x18 -#define PCIR_SECBUS_1 0x19 -#define PCIR_SUBBUS_1 0x1a -#define PCIR_SECLAT_1 0x1b - -#define PCIR_IOBASEL_1 0x1c -#define PCIR_IOLIMITL_1 0x1d -#define PCIR_IOBASEH_1 0x30 -#define PCIR_IOLIMITH_1 0x32 -#define PCIM_BRIO_16 0x0 -#define PCIM_BRIO_32 0x1 -#define PCIM_BRIO_MASK 0xf - -#define PCIR_MEMBASE_1 0x20 -#define PCIR_MEMLIMIT_1 0x22 - -#define PCIR_PMBASEL_1 0x24 -#define PCIR_PMLIMITL_1 0x26 -#define PCIR_PMBASEH_1 0x28 -#define PCIR_PMLIMITH_1 0x2c -#define PCIM_BRPM_32 0x0 -#define PCIM_BRPM_64 0x1 -#define PCIM_BRPM_MASK 0xf - -#define PCIR_BIOS_1 0x38 -#define PCIR_BRIDGECTL_1 0x3e - -/* config registers for header type 2 (CardBus) devices */ - -#define PCIR_MAX_BAR_2 0 -#define PCIR_CAP_PTR_2 0x14 -#define PCIR_SECSTAT_2 0x16 - -#define PCIR_PRIBUS_2 0x18 -#define PCIR_SECBUS_2 0x19 -#define PCIR_SUBBUS_2 0x1a -#define PCIR_SECLAT_2 0x1b - -#define PCIR_MEMBASE0_2 0x1c -#define PCIR_MEMLIMIT0_2 0x20 -#define PCIR_MEMBASE1_2 0x24 -#define PCIR_MEMLIMIT1_2 0x28 -#define PCIR_IOBASE0_2 0x2c -#define PCIR_IOLIMIT0_2 0x30 -#define PCIR_IOBASE1_2 0x34 -#define PCIR_IOLIMIT1_2 0x38 - -#define PCIR_BRIDGECTL_2 0x3e - -#define PCIR_SUBVEND_2 0x40 -#define PCIR_SUBDEV_2 0x42 - -#define PCIR_PCCARDIF_2 0x44 - -/* PCI device class, subclass and programming interface definitions */ - -#define PCIC_OLD 0x00 -#define PCIS_OLD_NONVGA 0x00 -#define PCIS_OLD_VGA 0x01 - -#define PCIC_STORAGE 0x01 -#define PCIS_STORAGE_SCSI 0x00 -#define PCIS_STORAGE_IDE 0x01 -#define PCIP_STORAGE_IDE_MODEPRIM 0x01 -#define PCIP_STORAGE_IDE_PROGINDPRIM 0x02 -#define PCIP_STORAGE_IDE_MODESEC 0x04 -#define PCIP_STORAGE_IDE_PROGINDSEC 0x08 -#define PCIP_STORAGE_IDE_MASTERDEV 0x80 -#define PCIS_STORAGE_FLOPPY 0x02 -#define PCIS_STORAGE_IPI 0x03 -#define PCIS_STORAGE_RAID 0x04 -#define PCIS_STORAGE_ATA_ADMA 0x05 -#define PCIS_STORAGE_SATA 0x06 -#define PCIP_STORAGE_SATA_AHCI_1_0 0x01 -#define PCIS_STORAGE_SAS 0x07 -#define PCIS_STORAGE_NVM 0x08 -#define PCIP_STORAGE_NVM_NVMHCI_1_0 0x01 -#define PCIP_STORAGE_NVM_ENTERPRISE_NVMHCI_1_0 0x02 -#define PCIS_STORAGE_OTHER 0x80 - -#define PCIC_NETWORK 0x02 -#define PCIS_NETWORK_ETHERNET 0x00 -#define PCIS_NETWORK_TOKENRING 0x01 -#define PCIS_NETWORK_FDDI 0x02 -#define PCIS_NETWORK_ATM 0x03 -#define PCIS_NETWORK_ISDN 0x04 -#define PCIS_NETWORK_WORLDFIP 0x05 -#define PCIS_NETWORK_PICMG 0x06 -#define PCIS_NETWORK_OTHER 0x80 - -#define PCIC_DISPLAY 0x03 -#define PCIS_DISPLAY_VGA 0x00 -#define PCIS_DISPLAY_XGA 0x01 -#define PCIS_DISPLAY_3D 0x02 -#define PCIS_DISPLAY_OTHER 0x80 - -#define PCIC_MULTIMEDIA 0x04 -#define PCIS_MULTIMEDIA_VIDEO 0x00 -#define PCIS_MULTIMEDIA_AUDIO 0x01 -#define PCIS_MULTIMEDIA_TELE 0x02 -#define PCIS_MULTIMEDIA_HDA 0x03 -#define PCIS_MULTIMEDIA_OTHER 0x80 - -#define PCIC_MEMORY 0x05 -#define PCIS_MEMORY_RAM 0x00 -#define PCIS_MEMORY_FLASH 0x01 -#define PCIS_MEMORY_OTHER 0x80 - -#define PCIC_BRIDGE 0x06 -#define PCIS_BRIDGE_HOST 0x00 -#define PCIS_BRIDGE_ISA 0x01 -#define PCIS_BRIDGE_EISA 0x02 -#define PCIS_BRIDGE_MCA 0x03 -#define PCIS_BRIDGE_PCI 0x04 -#define PCIP_BRIDGE_PCI_SUBTRACTIVE 0x01 -#define PCIS_BRIDGE_PCMCIA 0x05 -#define PCIS_BRIDGE_NUBUS 0x06 -#define PCIS_BRIDGE_CARDBUS 0x07 -#define PCIS_BRIDGE_RACEWAY 0x08 -#define PCIS_BRIDGE_PCI_TRANSPARENT 0x09 -#define PCIS_BRIDGE_INFINIBAND 0x0a -#define PCIS_BRIDGE_OTHER 0x80 - -#define PCIC_SIMPLECOMM 0x07 -#define PCIS_SIMPLECOMM_UART 0x00 -#define PCIP_SIMPLECOMM_UART_8250 0x00 -#define PCIP_SIMPLECOMM_UART_16450A 0x01 -#define PCIP_SIMPLECOMM_UART_16550A 0x02 -#define PCIP_SIMPLECOMM_UART_16650A 0x03 -#define PCIP_SIMPLECOMM_UART_16750A 0x04 -#define PCIP_SIMPLECOMM_UART_16850A 0x05 -#define PCIP_SIMPLECOMM_UART_16950A 0x06 -#define PCIS_SIMPLECOMM_PAR 0x01 -#define PCIS_SIMPLECOMM_MULSER 0x02 -#define PCIS_SIMPLECOMM_MODEM 0x03 -#define PCIS_SIMPLECOMM_GPIB 0x04 -#define PCIS_SIMPLECOMM_SMART_CARD 0x05 -#define PCIS_SIMPLECOMM_OTHER 0x80 - -#define PCIC_BASEPERIPH 0x08 -#define PCIS_BASEPERIPH_PIC 0x00 -#define PCIP_BASEPERIPH_PIC_8259A 0x00 -#define PCIP_BASEPERIPH_PIC_ISA 0x01 -#define PCIP_BASEPERIPH_PIC_EISA 0x02 -#define PCIP_BASEPERIPH_PIC_IO_APIC 0x10 -#define PCIP_BASEPERIPH_PIC_IOX_APIC 0x20 -#define PCIS_BASEPERIPH_DMA 0x01 -#define PCIS_BASEPERIPH_TIMER 0x02 -#define PCIS_BASEPERIPH_RTC 0x03 -#define PCIS_BASEPERIPH_PCIHOT 0x04 -#define PCIS_BASEPERIPH_SDHC 0x05 -#define PCIS_BASEPERIPH_IOMMU 0x06 -#define PCIS_BASEPERIPH_OTHER 0x80 - -#define PCIC_INPUTDEV 0x09 -#define PCIS_INPUTDEV_KEYBOARD 0x00 -#define PCIS_INPUTDEV_DIGITIZER 0x01 -#define PCIS_INPUTDEV_MOUSE 0x02 -#define PCIS_INPUTDEV_SCANNER 0x03 -#define PCIS_INPUTDEV_GAMEPORT 0x04 -#define PCIS_INPUTDEV_OTHER 0x80 - -#define PCIC_DOCKING 0x0a -#define PCIS_DOCKING_GENERIC 0x00 -#define PCIS_DOCKING_OTHER 0x80 - -#define PCIC_PROCESSOR 0x0b -#define PCIS_PROCESSOR_386 0x00 -#define PCIS_PROCESSOR_486 0x01 -#define PCIS_PROCESSOR_PENTIUM 0x02 -#define PCIS_PROCESSOR_ALPHA 0x10 -#define PCIS_PROCESSOR_POWERPC 0x20 -#define PCIS_PROCESSOR_MIPS 0x30 -#define PCIS_PROCESSOR_COPROC 0x40 - -#define PCIC_SERIALBUS 0x0c -#define PCIS_SERIALBUS_FW 0x00 -#define PCIS_SERIALBUS_ACCESS 0x01 -#define PCIS_SERIALBUS_SSA 0x02 -#define PCIS_SERIALBUS_USB 0x03 -#define PCIP_SERIALBUS_USB_UHCI 0x00 -#define PCIP_SERIALBUS_USB_OHCI 0x10 -#define PCIP_SERIALBUS_USB_EHCI 0x20 -#define PCIP_SERIALBUS_USB_XHCI 0x30 -#define PCIP_SERIALBUS_USB_DEVICE 0xfe -#define PCIS_SERIALBUS_FC 0x04 -#define PCIS_SERIALBUS_SMBUS 0x05 -#define PCIS_SERIALBUS_INFINIBAND 0x06 -#define PCIS_SERIALBUS_IPMI 0x07 -#define PCIP_SERIALBUS_IPMI_SMIC 0x00 -#define PCIP_SERIALBUS_IPMI_KCS 0x01 -#define PCIP_SERIALBUS_IPMI_BT 0x02 -#define PCIS_SERIALBUS_SERCOS 0x08 -#define PCIS_SERIALBUS_CANBUS 0x09 - -#define PCIC_WIRELESS 0x0d -#define PCIS_WIRELESS_IRDA 0x00 -#define PCIS_WIRELESS_IR 0x01 -#define PCIS_WIRELESS_RF 0x10 -#define PCIS_WIRELESS_BLUETOOTH 0x11 -#define PCIS_WIRELESS_BROADBAND 0x12 -#define PCIS_WIRELESS_80211A 0x20 -#define PCIS_WIRELESS_80211B 0x21 -#define PCIS_WIRELESS_OTHER 0x80 - -#define PCIC_INTELLIIO 0x0e -#define PCIS_INTELLIIO_I2O 0x00 - -#define PCIC_SATCOM 0x0f -#define PCIS_SATCOM_TV 0x01 -#define PCIS_SATCOM_AUDIO 0x02 -#define PCIS_SATCOM_VOICE 0x03 -#define PCIS_SATCOM_DATA 0x04 - -#define PCIC_CRYPTO 0x10 -#define PCIS_CRYPTO_NETCOMP 0x00 -#define PCIS_CRYPTO_ENTERTAIN 0x10 -#define PCIS_CRYPTO_OTHER 0x80 - -#define PCIC_DASP 0x11 -#define PCIS_DASP_DPIO 0x00 -#define PCIS_DASP_PERFCNTRS 0x01 -#define PCIS_DASP_COMM_SYNC 0x10 -#define PCIS_DASP_MGMT_CARD 0x20 -#define PCIS_DASP_OTHER 0x80 - -#define PCIC_OTHER 0xff - -/* Bridge Control Values. */ -#define PCIB_BCR_PERR_ENABLE 0x0001 -#define PCIB_BCR_SERR_ENABLE 0x0002 -#define PCIB_BCR_ISA_ENABLE 0x0004 -#define PCIB_BCR_VGA_ENABLE 0x0008 -#define PCIB_BCR_MASTER_ABORT_MODE 0x0020 -#define PCIB_BCR_SECBUS_RESET 0x0040 -#define PCIB_BCR_SECBUS_BACKTOBACK 0x0080 -#define PCIB_BCR_PRI_DISCARD_TIMEOUT 0x0100 -#define PCIB_BCR_SEC_DISCARD_TIMEOUT 0x0200 -#define PCIB_BCR_DISCARD_TIMER_STATUS 0x0400 -#define PCIB_BCR_DISCARD_TIMER_SERREN 0x0800 - -/* PCI power manangement */ -#define PCIR_POWER_CAP 0x2 -#define PCIM_PCAP_SPEC 0x0007 -#define PCIM_PCAP_PMEREQCLK 0x0008 -#define PCIM_PCAP_DEVSPECINIT 0x0020 -#define PCIM_PCAP_AUXPWR_0 0x0000 -#define PCIM_PCAP_AUXPWR_55 0x0040 -#define PCIM_PCAP_AUXPWR_100 0x0080 -#define PCIM_PCAP_AUXPWR_160 0x00c0 -#define PCIM_PCAP_AUXPWR_220 0x0100 -#define PCIM_PCAP_AUXPWR_270 0x0140 -#define PCIM_PCAP_AUXPWR_320 0x0180 -#define PCIM_PCAP_AUXPWR_375 0x01c0 -#define PCIM_PCAP_AUXPWRMASK 0x01c0 -#define PCIM_PCAP_D1SUPP 0x0200 -#define PCIM_PCAP_D2SUPP 0x0400 -#define PCIM_PCAP_D0PME 0x0800 -#define PCIM_PCAP_D1PME 0x1000 -#define PCIM_PCAP_D2PME 0x2000 -#define PCIM_PCAP_D3PME_HOT 0x4000 -#define PCIM_PCAP_D3PME_COLD 0x8000 - -#define PCIR_POWER_STATUS 0x4 -#define PCIM_PSTAT_D0 0x0000 -#define PCIM_PSTAT_D1 0x0001 -#define PCIM_PSTAT_D2 0x0002 -#define PCIM_PSTAT_D3 0x0003 -#define PCIM_PSTAT_DMASK 0x0003 -#define PCIM_PSTAT_NOSOFTRESET 0x0008 -#define PCIM_PSTAT_PMEENABLE 0x0100 -#define PCIM_PSTAT_D0POWER 0x0000 -#define PCIM_PSTAT_D1POWER 0x0200 -#define PCIM_PSTAT_D2POWER 0x0400 -#define PCIM_PSTAT_D3POWER 0x0600 -#define PCIM_PSTAT_D0HEAT 0x0800 -#define PCIM_PSTAT_D1HEAT 0x0a00 -#define PCIM_PSTAT_D2HEAT 0x0c00 -#define PCIM_PSTAT_D3HEAT 0x0e00 -#define PCIM_PSTAT_DATASELMASK 0x1e00 -#define PCIM_PSTAT_DATAUNKN 0x0000 -#define PCIM_PSTAT_DATADIV10 0x2000 -#define PCIM_PSTAT_DATADIV100 0x4000 -#define PCIM_PSTAT_DATADIV1000 0x6000 -#define PCIM_PSTAT_DATADIVMASK 0x6000 -#define PCIM_PSTAT_PME 0x8000 - -#define PCIR_POWER_BSE 0x6 -#define PCIM_PMCSR_BSE_D3B3 0x00 -#define PCIM_PMCSR_BSE_D3B2 0x40 -#define PCIM_PMCSR_BSE_BPCCE 0x80 - -#define PCIR_POWER_DATA 0x7 - -/* VPD capability registers */ -#define PCIR_VPD_ADDR 0x2 -#define PCIR_VPD_DATA 0x4 - -/* PCI Message Signalled Interrupts (MSI) */ -#define PCIR_MSI_CTRL 0x2 -#define PCIM_MSICTRL_VECTOR 0x0100 -#define PCIM_MSICTRL_64BIT 0x0080 -#define PCIM_MSICTRL_MME_MASK 0x0070 -#define PCIM_MSICTRL_MME_1 0x0000 -#define PCIM_MSICTRL_MME_2 0x0010 -#define PCIM_MSICTRL_MME_4 0x0020 -#define PCIM_MSICTRL_MME_8 0x0030 -#define PCIM_MSICTRL_MME_16 0x0040 -#define PCIM_MSICTRL_MME_32 0x0050 -#define PCIM_MSICTRL_MMC_MASK 0x000E -#define PCIM_MSICTRL_MMC_1 0x0000 -#define PCIM_MSICTRL_MMC_2 0x0002 -#define PCIM_MSICTRL_MMC_4 0x0004 -#define PCIM_MSICTRL_MMC_8 0x0006 -#define PCIM_MSICTRL_MMC_16 0x0008 -#define PCIM_MSICTRL_MMC_32 0x000A -#define PCIM_MSICTRL_MSI_ENABLE 0x0001 -#define PCIR_MSI_ADDR 0x4 -#define PCIR_MSI_ADDR_HIGH 0x8 -#define PCIR_MSI_DATA 0x8 -#define PCIR_MSI_DATA_64BIT 0xc -#define PCIR_MSI_MASK 0x10 -#define PCIR_MSI_PENDING 0x14 - -/* PCI-X definitions */ - -/* For header type 0 devices */ -#define PCIXR_COMMAND 0x2 -#define PCIXM_COMMAND_DPERR_E 0x0001 /* Data Parity Error Recovery */ -#define PCIXM_COMMAND_ERO 0x0002 /* Enable Relaxed Ordering */ -#define PCIXM_COMMAND_MAX_READ 0x000c /* Maximum Burst Read Count */ -#define PCIXM_COMMAND_MAX_READ_512 0x0000 -#define PCIXM_COMMAND_MAX_READ_1024 0x0004 -#define PCIXM_COMMAND_MAX_READ_2048 0x0008 -#define PCIXM_COMMAND_MAX_READ_4096 0x000c -#define PCIXM_COMMAND_MAX_SPLITS 0x0070 /* Maximum Split Transactions */ -#define PCIXM_COMMAND_MAX_SPLITS_1 0x0000 -#define PCIXM_COMMAND_MAX_SPLITS_2 0x0010 -#define PCIXM_COMMAND_MAX_SPLITS_3 0x0020 -#define PCIXM_COMMAND_MAX_SPLITS_4 0x0030 -#define PCIXM_COMMAND_MAX_SPLITS_8 0x0040 -#define PCIXM_COMMAND_MAX_SPLITS_12 0x0050 -#define PCIXM_COMMAND_MAX_SPLITS_16 0x0060 -#define PCIXM_COMMAND_MAX_SPLITS_32 0x0070 -#define PCIXM_COMMAND_VERSION 0x3000 -#define PCIXR_STATUS 0x4 -#define PCIXM_STATUS_DEVFN 0x000000FF -#define PCIXM_STATUS_BUS 0x0000FF00 -#define PCIXM_STATUS_64BIT 0x00010000 -#define PCIXM_STATUS_133CAP 0x00020000 -#define PCIXM_STATUS_SC_DISCARDED 0x00040000 -#define PCIXM_STATUS_UNEXP_SC 0x00080000 -#define PCIXM_STATUS_COMPLEX_DEV 0x00100000 -#define PCIXM_STATUS_MAX_READ 0x00600000 -#define PCIXM_STATUS_MAX_READ_512 0x00000000 -#define PCIXM_STATUS_MAX_READ_1024 0x00200000 -#define PCIXM_STATUS_MAX_READ_2048 0x00400000 -#define PCIXM_STATUS_MAX_READ_4096 0x00600000 -#define PCIXM_STATUS_MAX_SPLITS 0x03800000 -#define PCIXM_STATUS_MAX_SPLITS_1 0x00000000 -#define PCIXM_STATUS_MAX_SPLITS_2 0x00800000 -#define PCIXM_STATUS_MAX_SPLITS_3 0x01000000 -#define PCIXM_STATUS_MAX_SPLITS_4 0x01800000 -#define PCIXM_STATUS_MAX_SPLITS_8 0x02000000 -#define PCIXM_STATUS_MAX_SPLITS_12 0x02800000 -#define PCIXM_STATUS_MAX_SPLITS_16 0x03000000 -#define PCIXM_STATUS_MAX_SPLITS_32 0x03800000 -#define PCIXM_STATUS_MAX_CUM_READ 0x1C000000 -#define PCIXM_STATUS_RCVD_SC_ERR 0x20000000 -#define PCIXM_STATUS_266CAP 0x40000000 -#define PCIXM_STATUS_533CAP 0x80000000 - -/* For header type 1 devices (PCI-X bridges) */ -#define PCIXR_SEC_STATUS 0x2 -#define PCIXM_SEC_STATUS_64BIT 0x0001 -#define PCIXM_SEC_STATUS_133CAP 0x0002 -#define PCIXM_SEC_STATUS_SC_DISC 0x0004 -#define PCIXM_SEC_STATUS_UNEXP_SC 0x0008 -#define PCIXM_SEC_STATUS_SC_OVERRUN 0x0010 -#define PCIXM_SEC_STATUS_SR_DELAYED 0x0020 -#define PCIXM_SEC_STATUS_BUS_MODE 0x03c0 -#define PCIXM_SEC_STATUS_VERSION 0x3000 -#define PCIXM_SEC_STATUS_266CAP 0x4000 -#define PCIXM_SEC_STATUS_533CAP 0x8000 -#define PCIXR_BRIDGE_STATUS 0x4 -#define PCIXM_BRIDGE_STATUS_DEVFN 0x000000FF -#define PCIXM_BRIDGE_STATUS_BUS 0x0000FF00 -#define PCIXM_BRIDGE_STATUS_64BIT 0x00010000 -#define PCIXM_BRIDGE_STATUS_133CAP 0x00020000 -#define PCIXM_BRIDGE_STATUS_SC_DISCARDED 0x00040000 -#define PCIXM_BRIDGE_STATUS_UNEXP_SC 0x00080000 -#define PCIXM_BRIDGE_STATUS_SC_OVERRUN 0x00100000 -#define PCIXM_BRIDGE_STATUS_SR_DELAYED 0x00200000 -#define PCIXM_BRIDGE_STATUS_DEVID_MSGCAP 0x20000000 -#define PCIXM_BRIDGE_STATUS_266CAP 0x40000000 -#define PCIXM_BRIDGE_STATUS_533CAP 0x80000000 - -/* HT (HyperTransport) Capability definitions */ -#define PCIR_HT_COMMAND 0x2 -#define PCIM_HTCMD_CAP_MASK 0xf800 /* Capability type. */ -#define PCIM_HTCAP_SLAVE 0x0000 /* 000xx */ -#define PCIM_HTCAP_HOST 0x2000 /* 001xx */ -#define PCIM_HTCAP_SWITCH 0x4000 /* 01000 */ -#define PCIM_HTCAP_INTERRUPT 0x8000 /* 10000 */ -#define PCIM_HTCAP_REVISION_ID 0x8800 /* 10001 */ -#define PCIM_HTCAP_UNITID_CLUMPING 0x9000 /* 10010 */ -#define PCIM_HTCAP_EXT_CONFIG_SPACE 0x9800 /* 10011 */ -#define PCIM_HTCAP_ADDRESS_MAPPING 0xa000 /* 10100 */ -#define PCIM_HTCAP_MSI_MAPPING 0xa800 /* 10101 */ -#define PCIM_HTCAP_DIRECT_ROUTE 0xb000 /* 10110 */ -#define PCIM_HTCAP_VCSET 0xb800 /* 10111 */ -#define PCIM_HTCAP_RETRY_MODE 0xc000 /* 11000 */ -#define PCIM_HTCAP_X86_ENCODING 0xc800 /* 11001 */ -#define PCIM_HTCAP_GEN3 0xd000 /* 11010 */ -#define PCIM_HTCAP_FLE 0xd800 /* 11011 */ -#define PCIM_HTCAP_PM 0xe000 /* 11100 */ -#define PCIM_HTCAP_HIGH_NODE_COUNT 0xe800 /* 11101 */ - -/* HT MSI Mapping Capability definitions. */ -#define PCIM_HTCMD_MSI_ENABLE 0x0001 -#define PCIM_HTCMD_MSI_FIXED 0x0002 -#define PCIR_HTMSI_ADDRESS_LO 0x4 -#define PCIR_HTMSI_ADDRESS_HI 0x8 - -/* PCI Vendor capability definitions */ -#define PCIR_VENDOR_LENGTH 0x2 -#define PCIR_VENDOR_DATA 0x3 - -/* PCI EHCI Debug Port definitions */ -#define PCIR_DEBUG_PORT 0x2 -#define PCIM_DEBUG_PORT_OFFSET 0x1FFF -#define PCIM_DEBUG_PORT_BAR 0xe000 - -/* PCI-PCI Bridge Subvendor definitions */ -#define PCIR_SUBVENDCAP_ID 0x4 - -/* PCI Express definitions */ -#define PCIER_FLAGS 0x2 -#define PCIEM_FLAGS_VERSION 0x000F -#define PCIEM_FLAGS_TYPE 0x00F0 -#define PCIEM_TYPE_ENDPOINT 0x0000 -#define PCIEM_TYPE_LEGACY_ENDPOINT 0x0010 -#define PCIEM_TYPE_ROOT_PORT 0x0040 -#define PCIEM_TYPE_UPSTREAM_PORT 0x0050 -#define PCIEM_TYPE_DOWNSTREAM_PORT 0x0060 -#define PCIEM_TYPE_PCI_BRIDGE 0x0070 -#define PCIEM_TYPE_PCIE_BRIDGE 0x0080 -#define PCIEM_TYPE_ROOT_INT_EP 0x0090 -#define PCIEM_TYPE_ROOT_EC 0x00a0 -#define PCIEM_FLAGS_SLOT 0x0100 -#define PCIEM_FLAGS_IRQ 0x3e00 -#define PCIER_DEVICE_CAP 0x4 -#define PCIEM_CAP_MAX_PAYLOAD 0x00000007 -#define PCIEM_CAP_PHANTHOM_FUNCS 0x00000018 -#define PCIEM_CAP_EXT_TAG_FIELD 0x00000020 -#define PCIEM_CAP_L0S_LATENCY 0x000001c0 -#define PCIEM_CAP_L1_LATENCY 0x00000e00 -#define PCIEM_CAP_ROLE_ERR_RPT 0x00008000 -#define PCIEM_CAP_SLOT_PWR_LIM_VAL 0x03fc0000 -#define PCIEM_CAP_SLOT_PWR_LIM_SCALE 0x0c000000 -#define PCIEM_CAP_FLR 0x10000000 -#define PCIER_DEVICE_CTL 0x8 -#define PCIEM_CTL_COR_ENABLE 0x0001 -#define PCIEM_CTL_NFER_ENABLE 0x0002 -#define PCIEM_CTL_FER_ENABLE 0x0004 -#define PCIEM_CTL_URR_ENABLE 0x0008 -#define PCIEM_CTL_RELAXED_ORD_ENABLE 0x0010 -#define PCIEM_CTL_MAX_PAYLOAD 0x00e0 -#define PCIEM_CTL_EXT_TAG_FIELD 0x0100 -#define PCIEM_CTL_PHANTHOM_FUNCS 0x0200 -#define PCIEM_CTL_AUX_POWER_PM 0x0400 -#define PCIEM_CTL_NOSNOOP_ENABLE 0x0800 -#define PCIEM_CTL_MAX_READ_REQUEST 0x7000 -#define PCIEM_CTL_BRDG_CFG_RETRY 0x8000 /* PCI-E - PCI/PCI-X bridges */ -#define PCIEM_CTL_INITIATE_FLR 0x8000 /* FLR capable endpoints */ -#define PCIER_DEVICE_STA 0xa -#define PCIEM_STA_CORRECTABLE_ERROR 0x0001 -#define PCIEM_STA_NON_FATAL_ERROR 0x0002 -#define PCIEM_STA_FATAL_ERROR 0x0004 -#define PCIEM_STA_UNSUPPORTED_REQ 0x0008 -#define PCIEM_STA_AUX_POWER 0x0010 -#define PCIEM_STA_TRANSACTION_PND 0x0020 -#define PCIER_LINK_CAP 0xc -#define PCIEM_LINK_CAP_MAX_SPEED 0x0000000f -#define PCIEM_LINK_CAP_MAX_WIDTH 0x000003f0 -#define PCIEM_LINK_CAP_ASPM 0x00000c00 -#define PCIEM_LINK_CAP_L0S_EXIT 0x00007000 -#define PCIEM_LINK_CAP_L1_EXIT 0x00038000 -#define PCIEM_LINK_CAP_CLOCK_PM 0x00040000 -#define PCIEM_LINK_CAP_SURPRISE_DOWN 0x00080000 -#define PCIEM_LINK_CAP_DL_ACTIVE 0x00100000 -#define PCIEM_LINK_CAP_LINK_BW_NOTIFY 0x00200000 -#define PCIEM_LINK_CAP_ASPM_COMPLIANCE 0x00400000 -#define PCIEM_LINK_CAP_PORT 0xff000000 -#define PCIER_LINK_CTL 0x10 -#define PCIEM_LINK_CTL_ASPMC_DIS 0x0000 -#define PCIEM_LINK_CTL_ASPMC_L0S 0x0001 -#define PCIEM_LINK_CTL_ASPMC_L1 0x0002 -#define PCIEM_LINK_CTL_ASPMC 0x0003 -#define PCIEM_LINK_CTL_RCB 0x0008 -#define PCIEM_LINK_CTL_LINK_DIS 0x0010 -#define PCIEM_LINK_CTL_RETRAIN_LINK 0x0020 -#define PCIEM_LINK_CTL_COMMON_CLOCK 0x0040 -#define PCIEM_LINK_CTL_EXTENDED_SYNC 0x0080 -#define PCIEM_LINK_CTL_ECPM 0x0100 -#define PCIEM_LINK_CTL_HAWD 0x0200 -#define PCIEM_LINK_CTL_LBMIE 0x0400 -#define PCIEM_LINK_CTL_LABIE 0x0800 -#define PCIER_LINK_STA 0x12 -#define PCIEM_LINK_STA_SPEED 0x000f -#define PCIEM_LINK_STA_WIDTH 0x03f0 -#define PCIEM_LINK_STA_TRAINING_ERROR 0x0400 -#define PCIEM_LINK_STA_TRAINING 0x0800 -#define PCIEM_LINK_STA_SLOT_CLOCK 0x1000 -#define PCIEM_LINK_STA_DL_ACTIVE 0x2000 -#define PCIEM_LINK_STA_LINK_BW_MGMT 0x4000 -#define PCIEM_LINK_STA_LINK_AUTO_BW 0x8000 -#define PCIER_SLOT_CAP 0x14 -#define PCIEM_SLOT_CAP_APB 0x00000001 -#define PCIEM_SLOT_CAP_PCP 0x00000002 -#define PCIEM_SLOT_CAP_MRLSP 0x00000004 -#define PCIEM_SLOT_CAP_AIP 0x00000008 -#define PCIEM_SLOT_CAP_PIP 0x00000010 -#define PCIEM_SLOT_CAP_HPS 0x00000020 -#define PCIEM_SLOT_CAP_HPC 0x00000040 -#define PCIEM_SLOT_CAP_SPLV 0x00007f80 -#define PCIEM_SLOT_CAP_SPLS 0x00018000 -#define PCIEM_SLOT_CAP_EIP 0x00020000 -#define PCIEM_SLOT_CAP_NCCS 0x00040000 -#define PCIEM_SLOT_CAP_PSN 0xfff80000 -#define PCIER_SLOT_CTL 0x18 -#define PCIEM_SLOT_CTL_ABPE 0x0001 -#define PCIEM_SLOT_CTL_PFDE 0x0002 -#define PCIEM_SLOT_CTL_MRLSCE 0x0004 -#define PCIEM_SLOT_CTL_PDCE 0x0008 -#define PCIEM_SLOT_CTL_CCIE 0x0010 -#define PCIEM_SLOT_CTL_HPIE 0x0020 -#define PCIEM_SLOT_CTL_AIC 0x00c0 -#define PCIEM_SLOT_CTL_PIC 0x0300 -#define PCIEM_SLOT_CTL_PCC 0x0400 -#define PCIEM_SLOT_CTL_EIC 0x0800 -#define PCIEM_SLOT_CTL_DLLSCE 0x1000 -#define PCIER_SLOT_STA 0x1a -#define PCIEM_SLOT_STA_ABP 0x0001 -#define PCIEM_SLOT_STA_PFD 0x0002 -#define PCIEM_SLOT_STA_MRLSC 0x0004 -#define PCIEM_SLOT_STA_PDC 0x0008 -#define PCIEM_SLOT_STA_CC 0x0010 -#define PCIEM_SLOT_STA_MRLSS 0x0020 -#define PCIEM_SLOT_STA_PDS 0x0040 -#define PCIEM_SLOT_STA_EIS 0x0080 -#define PCIEM_SLOT_STA_DLLSC 0x0100 -#define PCIER_ROOT_CTL 0x1c -#define PCIEM_ROOT_CTL_SERR_CORR 0x0001 -#define PCIEM_ROOT_CTL_SERR_NONFATAL 0x0002 -#define PCIEM_ROOT_CTL_SERR_FATAL 0x0004 -#define PCIEM_ROOT_CTL_PME 0x0008 -#define PCIEM_ROOT_CTL_CRS_VIS 0x0010 -#define PCIER_ROOT_CAP 0x1e -#define PCIEM_ROOT_CAP_CRS_VIS 0x0001 -#define PCIER_ROOT_STA 0x20 -#define PCIEM_ROOT_STA_PME_REQID_MASK 0x0000ffff -#define PCIEM_ROOT_STA_PME_STATUS 0x00010000 -#define PCIEM_ROOT_STA_PME_PEND 0x00020000 -#define PCIER_DEVICE_CAP2 0x24 -#define PCIEM_CAP2_ARI 0x20 -#define PCIER_DEVICE_CTL2 0x28 -#define PCIEM_CTL2_COMP_TIMEOUT_VAL 0x000f -#define PCIEM_CTL2_COMP_TIMEOUT_DIS 0x0010 -#define PCIEM_CTL2_ARI 0x0020 -#define PCIEM_CTL2_ATOMIC_REQ_ENABLE 0x0040 -#define PCIEM_CTL2_ATOMIC_EGR_BLOCK 0x0080 -#define PCIEM_CTL2_ID_ORDERED_REQ_EN 0x0100 -#define PCIEM_CTL2_ID_ORDERED_CMP_EN 0x0200 -#define PCIEM_CTL2_LTR_ENABLE 0x0400 -#define PCIEM_CTL2_OBFF 0x6000 -#define PCIEM_OBFF_DISABLE 0x0000 -#define PCIEM_OBFF_MSGA_ENABLE 0x2000 -#define PCIEM_OBFF_MSGB_ENABLE 0x4000 -#define PCIEM_OBFF_WAKE_ENABLE 0x6000 -#define PCIEM_CTL2_END2END_TLP 0x8000 -#define PCIER_DEVICE_STA2 0x2a -#define PCIER_LINK_CAP2 0x2c -#define PCIER_LINK_CTL2 0x30 -#define PCIER_LINK_STA2 0x32 -#define PCIER_SLOT_CAP2 0x34 -#define PCIER_SLOT_CTL2 0x38 -#define PCIER_SLOT_STA2 0x3a - -/* MSI-X definitions */ -#define PCIR_MSIX_CTRL 0x2 -#define PCIM_MSIXCTRL_MSIX_ENABLE 0x8000 -#define PCIM_MSIXCTRL_FUNCTION_MASK 0x4000 -#define PCIM_MSIXCTRL_TABLE_SIZE 0x07FF -#define PCIR_MSIX_TABLE 0x4 -#define PCIR_MSIX_PBA 0x8 -#define PCIM_MSIX_BIR_MASK 0x7 -#define PCIM_MSIX_BIR_BAR_10 0 -#define PCIM_MSIX_BIR_BAR_14 1 -#define PCIM_MSIX_BIR_BAR_18 2 -#define PCIM_MSIX_BIR_BAR_1C 3 -#define PCIM_MSIX_BIR_BAR_20 4 -#define PCIM_MSIX_BIR_BAR_24 5 -#define PCIM_MSIX_VCTRL_MASK 0x1 - -/* PCI Advanced Features definitions */ -#define PCIR_PCIAF_CAP 0x3 -#define PCIM_PCIAFCAP_TP 0x01 -#define PCIM_PCIAFCAP_FLR 0x02 -#define PCIR_PCIAF_CTRL 0x4 -#define PCIR_PCIAFCTRL_FLR 0x01 -#define PCIR_PCIAF_STATUS 0x5 -#define PCIR_PCIAFSTATUS_TP 0x01 - -/* Advanced Error Reporting */ -#define PCIR_AER_UC_STATUS 0x04 -#define PCIM_AER_UC_TRAINING_ERROR 0x00000001 -#define PCIM_AER_UC_DL_PROTOCOL_ERROR 0x00000010 -#define PCIM_AER_UC_SURPRISE_LINK_DOWN 0x00000020 -#define PCIM_AER_UC_POISONED_TLP 0x00001000 -#define PCIM_AER_UC_FC_PROTOCOL_ERROR 0x00002000 -#define PCIM_AER_UC_COMPLETION_TIMEOUT 0x00004000 -#define PCIM_AER_UC_COMPLETER_ABORT 0x00008000 -#define PCIM_AER_UC_UNEXPECTED_COMPLETION 0x00010000 -#define PCIM_AER_UC_RECEIVER_OVERFLOW 0x00020000 -#define PCIM_AER_UC_MALFORMED_TLP 0x00040000 -#define PCIM_AER_UC_ECRC_ERROR 0x00080000 -#define PCIM_AER_UC_UNSUPPORTED_REQUEST 0x00100000 -#define PCIM_AER_UC_ACS_VIOLATION 0x00200000 -#define PCIM_AER_UC_INTERNAL_ERROR 0x00400000 -#define PCIM_AER_UC_MC_BLOCKED_TLP 0x00800000 -#define PCIM_AER_UC_ATOMIC_EGRESS_BLK 0x01000000 -#define PCIM_AER_UC_TLP_PREFIX_BLOCKED 0x02000000 -#define PCIR_AER_UC_MASK 0x08 /* Shares bits with UC_STATUS */ -#define PCIR_AER_UC_SEVERITY 0x0c /* Shares bits with UC_STATUS */ -#define PCIR_AER_COR_STATUS 0x10 -#define PCIM_AER_COR_RECEIVER_ERROR 0x00000001 -#define PCIM_AER_COR_BAD_TLP 0x00000040 -#define PCIM_AER_COR_BAD_DLLP 0x00000080 -#define PCIM_AER_COR_REPLAY_ROLLOVER 0x00000100 -#define PCIM_AER_COR_REPLAY_TIMEOUT 0x00001000 -#define PCIM_AER_COR_ADVISORY_NF_ERROR 0x00002000 -#define PCIM_AER_COR_INTERNAL_ERROR 0x00004000 -#define PCIM_AER_COR_HEADER_LOG_OVFLOW 0x00008000 -#define PCIR_AER_COR_MASK 0x14 /* Shares bits with COR_STATUS */ -#define PCIR_AER_CAP_CONTROL 0x18 -#define PCIM_AER_FIRST_ERROR_PTR 0x0000001f -#define PCIM_AER_ECRC_GEN_CAPABLE 0x00000020 -#define PCIM_AER_ECRC_GEN_ENABLE 0x00000040 -#define PCIM_AER_ECRC_CHECK_CAPABLE 0x00000080 -#define PCIM_AER_ECRC_CHECK_ENABLE 0x00000100 -#define PCIM_AER_MULT_HDR_CAPABLE 0x00000200 -#define PCIM_AER_MULT_HDR_ENABLE 0x00000400 -#define PCIM_AER_TLP_PREFIX_LOG_PRESENT 0x00000800 -#define PCIR_AER_HEADER_LOG 0x1c -#define PCIR_AER_ROOTERR_CMD 0x2c /* Only for root complex ports */ -#define PCIM_AER_ROOTERR_COR_ENABLE 0x00000001 -#define PCIM_AER_ROOTERR_NF_ENABLE 0x00000002 -#define PCIM_AER_ROOTERR_F_ENABLE 0x00000004 -#define PCIR_AER_ROOTERR_STATUS 0x30 /* Only for root complex ports */ -#define PCIM_AER_ROOTERR_COR_ERR 0x00000001 -#define PCIM_AER_ROOTERR_MULTI_COR_ERR 0x00000002 -#define PCIM_AER_ROOTERR_UC_ERR 0x00000004 -#define PCIM_AER_ROOTERR_MULTI_UC_ERR 0x00000008 -#define PCIM_AER_ROOTERR_FIRST_UC_FATAL 0x00000010 -#define PCIM_AER_ROOTERR_NF_ERR 0x00000020 -#define PCIM_AER_ROOTERR_F_ERR 0x00000040 -#define PCIM_AER_ROOTERR_INT_MESSAGE 0xf8000000 -#define PCIR_AER_COR_SOURCE_ID 0x34 /* Only for root complex ports */ -#define PCIR_AER_ERR_SOURCE_ID 0x36 /* Only for root complex ports */ -#define PCIR_AER_TLP_PREFIX_LOG 0x38 /* Only for TLP prefix functions */ - -/* Virtual Channel definitions */ -#define PCIR_VC_CAP1 0x04 -#define PCIM_VC_CAP1_EXT_COUNT 0x00000007 -#define PCIM_VC_CAP1_LOWPRI_EXT_COUNT 0x00000070 -#define PCIR_VC_CAP2 0x08 -#define PCIR_VC_CONTROL 0x0C -#define PCIR_VC_STATUS 0x0E -#define PCIR_VC_RESOURCE_CAP(n) (0x10 + (n) * 0x0C) -#define PCIR_VC_RESOURCE_CTL(n) (0x14 + (n) * 0x0C) -#define PCIR_VC_RESOURCE_STA(n) (0x18 + (n) * 0x0C) - -/* Serial Number definitions */ -#define PCIR_SERIAL_LOW 0x04 -#define PCIR_SERIAL_HIGH 0x08 - -#endif /* __PCI_REG_H__*/ diff --git a/cpukit/libpci/pci_bus.h b/cpukit/libpci/pci_bus.h deleted file mode 100644 index b426010da5..0000000000 --- a/cpukit/libpci/pci_bus.h +++ /dev/null @@ -1,161 +0,0 @@ -/* PCI bus driver Interface. - * - * COPYRIGHT (c) 2008 Cobham Gaisler AB. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - * - */ - -/* General part of drvmgr PCI Bus driver. The driver is typically - * initialized from the PCI host driver separating the host - * driver from the common parts in PCI drivers. - * The PCI library must be initialized before starting the - * PCI bus driver. The PCI library have set up BARs and - * assigned system IRQs for targets. - * This PCI bus driver rely on the PCI library (pci.c) for - * interrupt registeration (pci_interrupt_register) and PCI - * target set up. - */ - -#ifndef __PCI_BUS_H__ -#define __PCI_BUS_H__ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* PCI Driver ID generation (VENDOR: 16-bit, DEVICE: 16-bit) */ -#define DRIVER_PCI_ID(vendor, device) \ - DRIVER_ID(DRVMGR_BUS_TYPE_PCI, \ - ((((vendor) & 0xffff) << 16) | ((device) & 0xffff))) - -/* PCI Driver ID generation (CLASS: 24-bit) */ -#define DRIVER_PCI_CLASS(class) \ - DRIVER_ID(DRVMGR_BUS_TYPE_PCI, ((1 << 32) | ((class) & 0xffffff))) - -/* PCI driver IDs (DRIVER_PCI_VENDOR_DEVICE or DRIVER_PCI_CLASS_NAME) */ -#define DRIVER_PCI_GAISLER_RASTAIO_ID DRIVER_PCI_ID(PCIID_VENDOR_GAISLER, PCIID_DEVICE_GR_RASTA_IO) -#define DRIVER_PCI_GAISLER_RASTATMTC_ID DRIVER_PCI_ID(PCIID_VENDOR_GAISLER, PCIID_DEVICE_GR_RASTA_TMTC) -#define DRIVER_PCI_GAISLER_GR701_ID DRIVER_PCI_ID(PCIID_VENDOR_GAISLER, PCIID_DEVICE_GR_701) -#define DRIVER_PCI_GAISLER_RASTAADCDAC_ID DRIVER_PCI_ID(PCIID_VENDOR_GAISLER, PCIID_DEVICE_GR_RASTA_ADCDAC) -#define DRIVER_PCI_GAISLER_TMTC_1553_ID DRIVER_PCI_ID(PCIID_VENDOR_GAISLER, PCIID_DEVICE_GR_TMTC_1553) -#define DRIVER_PCI_GAISLER_RASTA_SPW_ROUTER_ID DRIVER_PCI_ID(PCIID_VENDOR_GAISLER, PCIID_DEVICE_GR_RASTA_SPW_RTR) -#define DRIVER_PCI_GAISLER_LEON4_N2X_ID DRIVER_PCI_ID(PCIID_VENDOR_GAISLER, PCIID_DEVICE_GR_LEON4_N2X) -#define DRIVER_PCI_GAISLER_CPCI_GR740_ID DRIVER_PCI_ID(PCIID_VENDOR_GAISLER, PCIID_DEVICE_GR_CPCI_GR740) - -struct pci_dev_id { - uint16_t vendor; - uint16_t device; - uint16_t subvendor; - uint16_t subdevice; - uint32_t class; /* 24 lower bits */ -}; - -struct pci_dev_id_match { - uint16_t vendor; - uint16_t device; - uint16_t subvendor; - uint16_t subdevice; - uint32_t class; /* 24 lower bits */ - uint32_t class_mask; /* 24 lower bits */ -}; -#define PCIID_DEVVEND(vendor, device) \ - {vendor, device, PCI_ID_ANY, PCI_ID_ANY, 0, 0} -#define PCIID_END_TABLE {0, 0, 0, 0, 0, 0} - -enum { - /* A Device has up to 6 BARs and an optional ROM BAR */ - PCIDEV_RES_BAR1 = 0, - PCIDEV_RES_BAR2 = 1, - PCIDEV_RES_BAR3 = 2, - PCIDEV_RES_BAR4 = 3, - PCIDEV_RES_BAR5 = 4, - PCIDEV_RES_BAR6 = 5, - PCIDEV_RES_ROM = 6, -}; -/* Maximum Number of Resources of a device */ -#define PCIDEV_RES_CNT (PCIDEV_RES_ROM + 1) - -/* IO, MEMIO or MEM resource. Can be BAR, ROM or Bridge Window */ -struct pcibus_res { - uint32_t address; /* Base Address, CPU accessible */ - uint32_t size; /* 0=Unimplemented, 0!=Resource Size */ - struct pci_res *res; /* PCI-layer resource */ -}; - -struct pci_dev_info { - struct pci_dev_id id; - uint8_t rev; - uint8_t irq; /* 0 = NO IRQ */ - pci_dev_t pcidev; - struct pcibus_res resources[PCIDEV_RES_CNT]; - struct pci_dev *pci_device; -}; - -struct pci_drv_info { - struct drvmgr_drv general; /* General bus info */ - /* PCI specific bus information */ - struct pci_dev_id_match *ids; /* Supported hardware */ -}; - -/* Access routines */ -struct pcibus_regmem_ops { - drvmgr_r8 r8; - drvmgr_r16 r16; - drvmgr_r32 r32; - drvmgr_r64 r64; - drvmgr_w8 w8; - drvmgr_w16 w16; - drvmgr_w32 w32; - drvmgr_w64 w64; -}; - -/* Let driver configure PCI bus driver */ -struct pcibus_config { - struct drvmgr_map_entry *maps_up; - struct drvmgr_map_entry *maps_down; -}; - -/* PCI Configuration Space Access - Not implemented (use PCI Lib directly) */ -#define PCI_FUNC_CFG_R8 DRVMGR_RWFUNC(RW_SIZE_1|RW_READ|RW_CFG) -#define PCI_FUNC_CFG_R16 DRVMGR_RWFUNC(RW_SIZE_2|RW_READ|RW_CFG) -#define PCI_FUNC_CFG_R32 DRVMGR_RWFUNC(RW_SIZE_4|RW_READ|RW_CFG) -#define PCI_FUNC_CFG_W8 DRVMGR_RWFUNC(RW_SIZE_1|RW_WRITE|RW_CFG) -#define PCI_FUNC_CFG_W16 DRVMGR_RWFUNC(RW_SIZE_2|RW_WRITE|RW_CFG) -#define PCI_FUNC_CFG_W32 DRVMGR_RWFUNC(RW_SIZE_4|RW_WRITE|RW_CFG) - -/* PCI I/O Register Access - Not implemented (use PCI Lib directly) */ -#define PCI_FUNC_IO_R8 DRVMGR_RWFUNC(RW_SIZE_1|RW_READ|RW_IO) -#define PCI_FUNC_IO_R16 DRVMGR_RWFUNC(RW_SIZE_2|RW_READ|RW_IO) -#define PCI_FUNC_IO_R32 DRVMGR_RWFUNC(RW_SIZE_4|RW_READ|RW_IO) -#define PCI_FUNC_IO_W8 DRVMGR_RWFUNC(RW_SIZE_1|RW_WRITE|RW_IO) -#define PCI_FUNC_IO_W16 DRVMGR_RWFUNC(RW_SIZE_2|RW_WRITE|RW_IO) -#define PCI_FUNC_IO_W32 DRVMGR_RWFUNC(RW_SIZE_4|RW_WRITE|RW_IO) - -/* PCI Register Access over Memory Space (Little Endian) */ -#define PCI_FUNC_MREG_R8 DRVMGR_RWFUNC(RW_SIZE_1|RW_READ|RW_MEMREG) -#define PCI_FUNC_MREG_R16 DRVMGR_RWFUNC(RW_SIZE_2|RW_READ|RW_MEMREG|RW_LITTLE) -#define PCI_FUNC_MREG_R32 DRVMGR_RWFUNC(RW_SIZE_4|RW_READ|RW_MEMREG|RW_LITTLE) -#define PCI_FUNC_MREG_W8 DRVMGR_RWFUNC(RW_SIZE_1|RW_WRITE|RW_MEMREG) -#define PCI_FUNC_MREG_W16 DRVMGR_RWFUNC(RW_SIZE_2|RW_WRITE|RW_MEMREG|RW_LITTLE) -#define PCI_FUNC_MREG_W32 DRVMGR_RWFUNC(RW_SIZE_4|RW_WRITE|RW_MEMREG|RW_LITTLE) - -/* Weak default PCI driver resources, override this from project configuration - * to set PCI Bus resources used to configure PCI device drivers. - */ -extern struct drvmgr_bus_res pcibus_drv_resources; - -/* Attach a PCI bus on top of a PCI Host device */ -extern int pcibus_register(struct drvmgr_dev *dev, struct pcibus_config *cfg); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/libpci/preinstall.am b/cpukit/libpci/preinstall.am deleted file mode 100644 index b9a8dd0400..0000000000 --- a/cpukit/libpci/preinstall.am +++ /dev/null @@ -1,79 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -$(PROJECT_INCLUDE)/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE) - @: > $(PROJECT_INCLUDE)/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/$(dirstamp) - -if LIBPCI -$(PROJECT_INCLUDE)/pci.h: pci.h $(PROJECT_INCLUDE)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/pci.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/pci.h - -$(PROJECT_INCLUDE)/pci/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/pci - @: > $(PROJECT_INCLUDE)/pci/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/pci/$(dirstamp) - -$(PROJECT_INCLUDE)/pci/access.h: pci/access.h $(PROJECT_INCLUDE)/pci/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/pci/access.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/pci/access.h - -$(PROJECT_INCLUDE)/pci/cfg.h: pci/cfg.h $(PROJECT_INCLUDE)/pci/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/pci/cfg.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/pci/cfg.h - -$(PROJECT_INCLUDE)/pci/cfg_auto.h: pci/cfg_auto.h $(PROJECT_INCLUDE)/pci/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/pci/cfg_auto.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/pci/cfg_auto.h - -$(PROJECT_INCLUDE)/pci/cfg_static.h: pci/cfg_static.h $(PROJECT_INCLUDE)/pci/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/pci/cfg_static.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/pci/cfg_static.h - -$(PROJECT_INCLUDE)/pci/cfg_peripheral.h: pci/cfg_peripheral.h $(PROJECT_INCLUDE)/pci/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/pci/cfg_peripheral.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/pci/cfg_peripheral.h - -$(PROJECT_INCLUDE)/pci/cfg_read.h: pci/cfg_read.h $(PROJECT_INCLUDE)/pci/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/pci/cfg_read.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/pci/cfg_read.h - -$(PROJECT_INCLUDE)/pci/ids.h: pci/ids.h $(PROJECT_INCLUDE)/pci/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/pci/ids.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/pci/ids.h - -$(PROJECT_INCLUDE)/pci/ids_extra.h: pci/ids_extra.h $(PROJECT_INCLUDE)/pci/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/pci/ids_extra.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/pci/ids_extra.h - -$(PROJECT_INCLUDE)/pci/irq.h: pci/irq.h $(PROJECT_INCLUDE)/pci/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/pci/irq.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/pci/irq.h - -$(PROJECT_INCLUDE)/pci/pcireg.h: pci/pcireg.h $(PROJECT_INCLUDE)/pci/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/pci/pcireg.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/pci/pcireg.h - -$(PROJECT_INCLUDE)/drvmgr/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/drvmgr - @: > $(PROJECT_INCLUDE)/drvmgr/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/drvmgr/$(dirstamp) - -$(PROJECT_INCLUDE)/drvmgr/pci_bus.h: pci_bus.h $(PROJECT_INCLUDE)/drvmgr/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/drvmgr/pci_bus.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/drvmgr/pci_bus.h -endif diff --git a/cpukit/libqos/qreslib.h b/cpukit/libqos/qreslib.h deleted file mode 100644 index 3de8668fdb..0000000000 --- a/cpukit/libqos/qreslib.h +++ /dev/null @@ -1,269 +0,0 @@ -/** - * @file qreslib.h - * - * @brief Constants and Structures Associated - * with the QoS RES library in RTEMS - * - * This include file contains all the constants and structures - * associated with the QoS RES library in RTEMS. - * - * @note The library is available only together with CBS scheduler. - */ - -/* - * Copyright (C) 2011 Petr Benes. - * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef CONFIGURE_SCHEDULER_CBS - #error "qreslib.h available only with CONFIGURE_SCHEDULER_CBS" -#endif - -#ifndef _QRESLIB_H -#define _QRESLIB_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/** Return values. */ -typedef int qos_rv; - -/* Return codes. */ -#define QOS_OK SCHEDULER_CBS_OK -#define QOS_E_GENERIC SCHEDULER_CBS_ERROR_GENERIC -#define QOS_E_NO_MEMORY SCHEDULER_CBS_ERROR_NO_MEMORY -#define QOS_E_INVALID_PARAM SCHEDULER_CBS_ERROR_INVALID_PARAMETER -#define QOS_E_UNAUTHORIZED SCHEDULER_CBS_ERROR_UNAUTHORIZED -#define QOS_E_UNIMPLEMENTED SCHEDULER_CBS_ERROR_UNIMPLEMENTED -#define QOS_E_MISSING_COMPONENT SCHEDULER_CBS_ERROR_MISSING_COMPONENT -#define QOS_E_INCONSISTENT_STATE SCHEDULER_CBS_ERROR_INCONSISTENT_STATE -#define QOS_E_SYSTEM_OVERLOAD SCHEDULER_CBS_ERROR_SYSTEM_OVERLOAD -#define QOS_E_INTERNAL_ERROR SCHEDULER_CBS_ERROR_INTERNAL_ERROR -#define QOS_E_NOT_FOUND SCHEDULER_CBS_ERROR_NOT_FOUND -#define QOS_E_FULL SCHEDULER_CBS_ERROR_FULL -#define QOS_E_EMPTY SCHEDULER_CBS_ERROR_EMPTY -#define QOS_E_NOSERVER SCHEDULER_CBS_ERROR_NOSERVER - -/** Server id. */ -typedef Scheduler_CBS_Server_id qres_sid_t; - -/** Task id. */ -typedef rtems_id tid_t; - -/** Time value. */ -typedef time_t qres_time_t; - -/** Absolute time value */ -typedef time_t qres_atime_t; - -/** Server parameters. */ -typedef struct { - /** Relative deadline of the server. */ - qres_time_t P; - /** Budget (computation time) of the server. */ - qres_time_t Q; -} qres_params_t; - -/** - * @brief qres init - * - * Initializes the QoS RES library. - * - * @return status code. - */ -RTEMS_INLINE_ROUTINE qos_rv qres_init ( void ) -{ - return _Scheduler_CBS_Initialize(); -} - -/** - * @brief qres cleanup - * - * Cleanup resources associated to the QoS RES Library. - * - * @return status code. - */ -RTEMS_INLINE_ROUTINE qos_rv qres_cleanup ( void ) -{ - return _Scheduler_CBS_Cleanup(); -} - -/** - * @brief qres create server - * - * Create a new server with specified parameters. - * - * @return status code. - */ -RTEMS_INLINE_ROUTINE qos_rv qres_create_server ( - qres_params_t *params, - qres_sid_t *server_id -) -{ - return _Scheduler_CBS_Create_server( - (Scheduler_CBS_Parameters *) params, - NULL, - server_id - ); -} - -/** - * @brief qres attach thread - * - * Attach a task to an already existing server. - * - * @return status code. - */ -RTEMS_INLINE_ROUTINE qos_rv qres_attach_thread ( - qres_sid_t server_id, - pid_t pid, - tid_t task_id -) -{ - return _Scheduler_CBS_Attach_thread( server_id, task_id ); -} - -/** - * @brief qres detach thread - * - * Detach from the QoS Server. - * - * @return status code. - */ -RTEMS_INLINE_ROUTINE qos_rv qres_detach_thread ( - qres_sid_t server_id, - pid_t pid, - tid_t task_id -) -{ - return _Scheduler_CBS_Detach_thread( server_id, task_id ); -} - -/** - * @brief qres destroy server - * - * Detach all tasks from a server and destroy it. - * - * @return status code. - */ -RTEMS_INLINE_ROUTINE qos_rv qres_destroy_server ( - qres_sid_t server_id -) -{ - return _Scheduler_CBS_Destroy_server( server_id ); -} - -/** - * @brief qres get server id - * - * Get a thread server id, or QOS_E_NOT_FOUND if it is not - * attached to any server. - * - * @return status code. - */ -RTEMS_INLINE_ROUTINE qos_rv qres_get_sid ( - pid_t pid, - tid_t task_id, - qres_sid_t *server_id -) -{ - return _Scheduler_CBS_Get_server_id( task_id, server_id ); -} - -/** - * @brief qres get params - * - * Retrieve QoS scheduling parameters. - * - * @return status code. - */ -RTEMS_INLINE_ROUTINE qos_rv qres_get_params ( - qres_sid_t server_id, - qres_params_t *params -) -{ - return _Scheduler_CBS_Get_parameters( - server_id, - (Scheduler_CBS_Parameters *) params - ); -} - -/** - * @brief qres set params - * - * Change QoS scheduling parameters. - * - * @return status code. - */ -RTEMS_INLINE_ROUTINE qos_rv qres_set_params ( - qres_sid_t server_id, - qres_params_t *params -) -{ - return _Scheduler_CBS_Set_parameters( - server_id, - (Scheduler_CBS_Parameters *) params - ); -} - -/** - * @brief qres get execution time - * - * Retrieve time info relative to the current server. - * - * @return status code. - */ -RTEMS_INLINE_ROUTINE qos_rv qres_get_exec_time ( - qres_sid_t server_id, - qres_time_t *exec_time, - qres_atime_t *abs_time -) -{ - return _Scheduler_CBS_Get_execution_time( server_id, exec_time, abs_time ); -} - -/** - * @brief qres get current budget - * - * Retrieve remaining budget for the current server instance. - * - * @return status code. - */ -RTEMS_INLINE_ROUTINE qos_rv qres_get_curr_budget ( - qres_sid_t server_id, - qres_time_t *current_budget -) -{ - return _Scheduler_CBS_Get_remaining_budget( server_id, current_budget ); -} - -/** - * @brief qres get approved budget - * - * Retrieve the budget that has been approved for the subsequent - * server instances. - * - * @return status code. - */ -RTEMS_INLINE_ROUTINE qos_rv qres_get_appr_budget ( - qres_sid_t server_id, - qres_time_t *appr_budget -) -{ - return _Scheduler_CBS_Get_approved_budget( server_id, appr_budget ); -} - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/librpc/Makefile.am b/cpukit/librpc/Makefile.am index edc760fc7d..92a76ba7ff 100644 --- a/cpukit/librpc/Makefile.am +++ b/cpukit/librpc/Makefile.am @@ -4,26 +4,6 @@ include $(top_srcdir)/automake/compile.am EXTRA_DIST = if LIBRPC -include_rpcdir = $(includedir)/rpc - -include_rpc_HEADERS = include/rpc/auth.h -include_rpc_HEADERS += include/rpc/auth_unix.h -include_rpc_HEADERS += include/rpc/clnt.h -include_rpc_HEADERS += include/rpc/clnt_stat.h -include_rpc_HEADERS += include/rpc/clnt_soc.h -include_rpc_HEADERS += include/rpc/svc.h -include_rpc_HEADERS += include/rpc/svc_auth.h -include_rpc_HEADERS += include/rpc/svc_soc.h -include_rpc_HEADERS += include/rpc/pmap_clnt.h -include_rpc_HEADERS += include/rpc/pmap_prot.h -include_rpc_HEADERS += include/rpc/pmap_rmt.h -include_rpc_HEADERS += include/rpc/rpc.h -include_rpc_HEADERS += include/rpc/types.h -include_rpc_HEADERS += include/rpc/xdr.h -include_rpc_HEADERS += include/rpc/rpc_com.h -include_rpc_HEADERS += include/rpc/rpc_msg.h -include_rpc_HEADERS += include/rpc/rpcent.h - man_MANS = noinst_LIBRARIES = libxdr.a @@ -90,5 +70,4 @@ EXTRA_DIST += include/rpcsvc/bootparam_prot.x include/rpcsvc/crypt.x \ include/rpcsvc/ypupdate_prot.x include/rpcsvc/yp.x \ include/rpcsvc/ypxfrd.x -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am diff --git a/cpukit/librpc/include/rpc/auth.h b/cpukit/librpc/include/rpc/auth.h deleted file mode 100644 index 13432bd5d0..0000000000 --- a/cpukit/librpc/include/rpc/auth.h +++ /dev/null @@ -1,262 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - * - * from: @(#)auth.h 1.17 88/02/08 SMI - * from: @(#)auth.h 2.3 88/08/07 4.0 RPCSRC - * $FreeBSD: src/include/rpc/auth.h,v 1.15 1999/08/27 23:45:02 peter Exp $ - */ - -/* - * auth.h, Authentication interface. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * The data structures are completely opaque to the client. The client - * is required to pass a AUTH * to routines that create rpc - * "sessions". - */ - -#ifndef _RPC_AUTH_H -#define _RPC_AUTH_H -#include -#include -#include - -#define MAX_AUTH_BYTES 400 -#define MAXNETNAMELEN 255 /* maximum length of network user's name */ - -/* - * Status returned from authentication check - */ -enum auth_stat { - AUTH_OK=0, - /* - * failed at remote end - */ - AUTH_BADCRED=1, /* bogus credentials (seal broken) */ - AUTH_REJECTEDCRED=2, /* client should begin new session */ - AUTH_BADVERF=3, /* bogus verifier (seal broken) */ - AUTH_REJECTEDVERF=4, /* verifier expired or was replayed */ - AUTH_TOOWEAK=5, /* rejected due to security reasons */ - /* - * failed locally - */ - AUTH_INVALIDRESP=6, /* bogus response verifier */ - AUTH_FAILED=7, /* some unknown reason */ - _AUTH_STAT = 0xffffffff -}; - -union des_block { - struct { - u_int32_t high; - u_int32_t low; - } key; - char c[8]; -}; -typedef union des_block des_block; -__BEGIN_DECLS -extern bool_t xdr_des_block (XDR *, des_block *); -__END_DECLS - -/* - * Authentication info. Opaque to client. - */ -struct opaque_auth { - enum_t oa_flavor; /* flavor of auth */ - caddr_t oa_base; /* address of more auth stuff */ - u_int oa_length; /* not to exceed MAX_AUTH_BYTES */ -}; -__BEGIN_DECLS -bool_t xdr_opaque_auth (XDR *xdrs, struct opaque_auth *ap); -__END_DECLS - - -/* - * Auth handle, interface to client side authenticators. - */ -typedef struct __rpc_auth { - struct opaque_auth ah_cred; - struct opaque_auth ah_verf; - union des_block ah_key; - struct auth_ops { - void (*ah_nextverf) (struct __rpc_auth *); - /* nextverf & serialize */ - int (*ah_marshal) (struct __rpc_auth *, XDR *); - /* validate verifier */ - int (*ah_validate) (struct __rpc_auth *, - struct opaque_auth *); - /* refresh credentials */ - int (*ah_refresh) (struct __rpc_auth *); - /* destroy this structure */ - void (*ah_destroy) (struct __rpc_auth *); - } *ah_ops; - caddr_t ah_private; -} AUTH; - - -/* - * Authentication ops. - * The ops and the auth handle provide the interface to the authenticators. - * - * AUTH *auth; - * XDR *xdrs; - * struct opaque_auth verf; - */ -#define AUTH_NEXTVERF(auth) \ - ((*((auth)->ah_ops->ah_nextverf))(auth)) -#define auth_nextverf(auth) \ - ((*((auth)->ah_ops->ah_nextverf))(auth)) - -#define AUTH_MARSHALL(auth, xdrs) \ - ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) -#define auth_marshall(auth, xdrs) \ - ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) - -#define AUTH_VALIDATE(auth, verfp) \ - ((*((auth)->ah_ops->ah_validate))((auth), verfp)) -#define auth_validate(auth, verfp) \ - ((*((auth)->ah_ops->ah_validate))((auth), verfp)) - -#define AUTH_REFRESH(auth) \ - ((*((auth)->ah_ops->ah_refresh))(auth)) -#define auth_refresh(auth) \ - ((*((auth)->ah_ops->ah_refresh))(auth)) - -#define AUTH_DESTROY(auth) \ - ((*((auth)->ah_ops->ah_destroy))(auth)) -#define auth_destroy(auth) \ - ((*((auth)->ah_ops->ah_destroy))(auth)) - - -extern struct opaque_auth _null_auth; - -/* - * These are the various implementations of client side authenticators. - */ - -/* - * Unix style authentication - * AUTH *authunix_create(machname, uid, gid, len, aup_gids) - * char *machname; - * int uid; - * int gid; - * int len; - * int *aup_gids; - */ -__BEGIN_DECLS -struct sockaddr_in; -extern AUTH *authunix_create (char *, int, int, int, int *); -extern AUTH *authunix_create_default (void); -extern AUTH *authnone_create (void); -__END_DECLS - -/* Forward compatibility with TI-RPC */ -#define authsys_create authunix_create -#define authsys_create_default authunix_create_default - -/* - * DES style authentication - * AUTH *authdes_create(servername, window, timehost, ckey) - * char *servername; - network name of server - * u_int window; - time to live - * struct sockaddr *timehost; - optional hostname to sync with - * des_block *ckey; - optional conversation key to use - */ -__BEGIN_DECLS -extern AUTH *authdes_create ( char *, u_int, struct sockaddr *, des_block * ); -#ifdef NOTYET -/* - * TI-RPC supports this call, but it requires the inclusion of - * NIS+-specific headers which would require the inclusion of other - * headers which would result in a tangled mess. For now, the NIS+ - * code prototypes this routine internally. - */ -extern AUTH *authdes_pk_create ( char *, netobj *, u_int, - struct sockaddr *, des_block *, - nis_server * ); -#endif -__END_DECLS - -/* - * Netname manipulation routines. - */ -__BEGIN_DECLS -extern int netname2user ( char *, uid_t *, gid_t *, int *, gid_t *); -extern int netname2host ( char *, char *, int ); -extern int getnetname ( char * ); -extern int user2netname ( char *, uid_t, char * ); -extern int host2netname ( char *, char *, char * ); -extern void passwd2des ( char *, char * ); -__END_DECLS - -/* - * Keyserv interface routines. - * XXX Should not be here. - */ -#ifndef HEXKEYBYTES -#define HEXKEYBYTES 48 -#endif -typedef char kbuf[HEXKEYBYTES]; -typedef char *namestr; - -struct netstarg { - kbuf st_priv_key; - kbuf st_pub_key; - namestr st_netname; -}; - -__BEGIN_DECLS -extern int key_decryptsession ( const char *, des_block * ); -extern int key_decryptsession_pk ( char *, netobj *, des_block * ); -extern int key_encryptsession ( const char *, des_block * ); -extern int key_encryptsession_pk ( char *, netobj *, des_block * ); -extern int key_gendes ( des_block * ); -extern int key_setsecret ( const char * ); -extern int key_secretkey_is_set ( void ); -extern int key_setnet ( struct netstarg * ); -extern int key_get_conv ( char *, des_block * ); -__END_DECLS - -/* - * Publickey routines. - */ -__BEGIN_DECLS -extern int getpublickey ( char *, char * ); -extern int getpublicandprivatekey ( char *, char * ); -extern int getsecretkey ( char *, char *, char * ); -__END_DECLS - - -#define AUTH_NONE 0 /* no authentication */ -#define AUTH_NULL 0 /* backward compatibility */ -#define AUTH_UNIX 1 /* unix style (uid, gids) */ -#define AUTH_SYS 1 /* forward compatibility */ -#define AUTH_SHORT 2 /* short hand unix style */ -#define AUTH_DES 3 /* des style (encrypted timestamps) */ - -#endif /* !_RPC_AUTH_H */ diff --git a/cpukit/librpc/include/rpc/auth_unix.h b/cpukit/librpc/include/rpc/auth_unix.h deleted file mode 100644 index f822f3dd60..0000000000 --- a/cpukit/librpc/include/rpc/auth_unix.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - * - * from: @(#)auth_unix.h 1.8 88/02/08 SMI - * from: @(#)auth_unix.h 2.2 88/07/29 4.0 RPCSRC - * $FreeBSD: src/include/rpc/auth_unix.h,v 1.10 1999/08/27 23:45:03 peter Exp $ - */ - -/* - * auth_unix.h, Protocol for UNIX style authentication parameters for RPC - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -/* - * The system is very weak. The client uses no encryption for it - * credentials and only sends null verifiers. The server sends backs - * null verifiers or optionally a verifier that suggests a new short hand - * for the credentials. - */ - -#ifndef _RPC_AUTH_UNIX_H -#define _RPC_AUTH_UNIX_H -#include -#include /* opaque_auth */ - -/* The machine name is part of a credential; it may not exceed 255 bytes */ -#define MAX_MACHINE_NAME 255 - -/* gids compose part of a credential; there may not be more than 16 of them */ -#define NGRPS 16 - -/* - * Unix style credentials. - */ -struct authunix_parms { - u_long aup_time; - char *aup_machname; - int aup_uid; - int aup_gid; - u_int aup_len; - int *aup_gids; -}; - -#define authsys_parms authunix_parms - -__BEGIN_DECLS -extern bool_t xdr_authunix_parms(XDR *, struct authunix_parms *); -__END_DECLS - -/* - * If a response verifier has flavor AUTH_SHORT, - * then the body of the response verifier encapsulates the following structure; - * again it is serialized in the obvious fashion. - */ -struct short_hand_verf { - struct opaque_auth new_cred; -}; - -#endif /* !_RPC_AUTH_UNIX_H */ diff --git a/cpukit/librpc/include/rpc/clnt.h b/cpukit/librpc/include/rpc/clnt.h deleted file mode 100644 index 3042abe1b6..0000000000 --- a/cpukit/librpc/include/rpc/clnt.h +++ /dev/null @@ -1,310 +0,0 @@ -/* $NetBSD: clnt.h,v 1.14 2000/06/02 22:57:55 fvdl Exp $ */ - -/* - * The contents of this file are subject to the Sun Standards - * License Version 1.0 the (the "License";) You may not use - * this file except in compliance with the License. You may - * obtain a copy of the License at lib/libc/rpc/LICENSE - * - * Software distributed under the License is distributed on - * an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either - * express or implied. See the License for the specific - * language governing rights and limitations under the License. - * - * The Original Code is Copyright 1998 by Sun Microsystems, Inc - * - * The Initial Developer of the Original Code is: Sun - * Microsystems, Inc. - * - * All Rights Reserved. - * - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - * - * from: @(#)clnt.h 1.31 94/04/29 SMI - * from: @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC - * $FreeBSD: src/include/rpc/clnt.h,v 1.21 2003/01/24 01:47:55 fjoe Exp $ - */ - -/* - * clnt.h - Client side remote procedure call interface. - * - * Copyright (c) 1986-1991,1994-1999 by Sun Microsystems, Inc. - * All rights reserved. - */ - - -#ifndef _RPC_CLNT_H_ -#define _RPC_CLNT_H_ -#include -#include -#include -#include /* auth_stat */ - -/* - * Error info. - */ -struct rpc_err { - enum clnt_stat re_status; - union { - int RE_errno; /* related system error */ - enum auth_stat RE_why; /* why the auth error occurred */ - struct { - rpcvers_t low; /* lowest version supported */ - rpcvers_t high; /* highest version supported */ - } RE_vers; - struct { /* maybe meaningful if RPC_FAILED */ - int32_t s1; - int32_t s2; - } RE_lb; /* life boot & debugging only */ - } ru; -#define re_errno ru.RE_errno -#define re_why ru.RE_why -#define re_vers ru.RE_vers -#define re_lb ru.RE_lb -}; - - -/* - * Client rpc handle. - * Created by individual implementations - * Client is responsible for initializing auth, see e.g. auth_none.c. - */ -typedef struct __rpc_client { - AUTH *cl_auth; /* authenticator */ - struct clnt_ops { - /* call remote procedure */ - enum clnt_stat (*cl_call)(struct __rpc_client *, - rpcproc_t, xdrproc_t, void *, xdrproc_t, - void *, struct timeval); - /* abort a call */ - void (*cl_abort)(void); - /* get specific error code */ - void (*cl_geterr)(struct __rpc_client *, - struct rpc_err *); - /* frees results */ - bool_t (*cl_freeres)(struct __rpc_client *, - xdrproc_t, void *); - /* destroy this structure */ - void (*cl_destroy)(struct __rpc_client *); - /* the ioctl() of rpc */ - bool_t (*cl_control)(struct __rpc_client *, int, - char *); - } *cl_ops; - void *cl_private; /* private stuff */ -} CLIENT; - -#define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */ - -/* - * client side rpc interface ops - * - * Parameter types are: - * - */ - -/* - * enum clnt_stat - * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout) - * CLIENT *rh; - * rpcproc_t proc; - * xdrproc_t xargs; - * void *argsp; - * xdrproc_t xres; - * void *resp; - * struct timeval timeout; - */ -#define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \ - ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, \ - argsp, xres, resp, secs)) -#define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \ - ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, \ - argsp, xres, resp, secs)) - -/* - * void - * CLNT_ABORT(rh); - * CLIENT *rh; - */ -#define CLNT_ABORT(rh) ((*(rh)->cl_ops->cl_abort)(rh)) -#define clnt_abort(rh) ((*(rh)->cl_ops->cl_abort)(rh)) - -/* - * struct rpc_err - * CLNT_GETERR(rh); - * CLIENT *rh; - */ -#define CLNT_GETERR(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) -#define clnt_geterr(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) - - -/* - * bool_t - * CLNT_FREERES(rh, xres, resp); - * CLIENT *rh; - * xdrproc_t xres; - * void *resp; - */ -#define CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) -#define clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) - -/* - * bool_t - * CLNT_CONTROL(cl, request, info) - * CLIENT *cl; - * u_int request; - * char *info; - */ -#define CLNT_CONTROL(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) -#define clnt_control(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) - -/* - * control operations that apply to udp, tcp and unix transports - * - * Note: options marked XXX are no-ops in this implementation of RPC. - * The are present in TI-RPC but can't be implemented here since they - * depend on the presence of STREAMS/TLI, which we don't have. - * - */ -#define CLSET_TIMEOUT 1 /* set timeout (timeval) */ -#define CLGET_TIMEOUT 2 /* get timeout (timeval) */ -#define CLGET_SERVER_ADDR 3 /* get server's address (sockaddr) */ -#define CLGET_FD 6 /* get connections file descriptor */ -#define CLGET_SVC_ADDR 7 /* get server's address (netbuf) */ -#define CLSET_FD_CLOSE 8 /* close fd while clnt_destroy */ -#define CLSET_FD_NCLOSE 9 /* Do not close fd while clnt_destroy */ -#define CLGET_XID 10 /* Get xid */ -#define CLSET_XID 11 /* Set xid */ -#define CLGET_VERS 12 /* Get version number */ -#define CLSET_VERS 13 /* Set version number */ -#define CLGET_PROG 14 /* Get program number */ -#define CLSET_PROG 15 /* Set program number */ -#define CLSET_SVC_ADDR 16 /* get server's address (netbuf) XXX */ -#define CLSET_PUSH_TIMOD 17 /* push timod if not already present XXX */ -#define CLSET_POP_TIMOD 18 /* pop timod XXX */ - -/* - * Connectionless only control operations - */ -#define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */ -#define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */ - -/* - * Operations which GSSAPI needs. (Bletch.) - */ -#define CLGET_LOCAL_ADDR 19 /* get local addr (sockaddr) */ - - -/* - * void - * CLNT_DESTROY(rh); - * CLIENT *rh; - */ -#define CLNT_DESTROY(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) -#define clnt_destroy(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) - - -/* - * RPCTEST is a test program which is accessible on every rpc - * transport/port. It is used for testing, performance evaluation, - * and network administration. - */ - -#define RPCTEST_PROGRAM ((rpcprog_t)1) -#define RPCTEST_VERSION ((rpcvers_t)1) -#define RPCTEST_NULL_PROC ((rpcproc_t)2) -#define RPCTEST_NULL_BATCH_PROC ((rpcproc_t)3) - -/* - * By convention, procedure 0 takes null arguments and returns them - */ - -#define NULLPROC ((rpcproc_t)0) - -/* - * Below are the client handle creation routines for the various - * implementations of client side rpc. They can return NULL if a - * creation failure occurs. - */ - -/* - * Generic client creation routine. Supported protocols are "udp", "tcp" - * and "unix". - */ -__BEGIN_DECLS -extern CLIENT *clnt_create(const char *, const rpcprog_t, const rpcvers_t, - const char *); -__END_DECLS - -/* - * Added for compatibility to old rpc 4.0. Obsoleted by clnt_vc_create(). - */ -__BEGIN_DECLS -extern CLIENT *clntunix_create(struct sockaddr_un *, - u_long, u_long, int *, u_int, u_int); -__END_DECLS - - -/* - * Print why creation failed - */ -__BEGIN_DECLS -extern void clnt_pcreateerror(const char *); /* stderr */ -extern char *clnt_spcreateerror(const char *); /* string */ -__END_DECLS - -/* - * Like clnt_perror(), but is more verbose in its output - */ -__BEGIN_DECLS -extern void clnt_perrno(enum clnt_stat); /* stderr */ -extern char *clnt_sperrno(enum clnt_stat); /* string */ -__END_DECLS - -/* - * Print an English error message, given the client error code - */ -__BEGIN_DECLS -extern void clnt_perror(CLIENT *, const char *); /* stderr */ -extern char *clnt_sperror(CLIENT *, const char *); /* string */ -__END_DECLS - - -/* - * If a creation fails, the following allows the user to figure out why. - */ -struct rpc_createerr { - enum clnt_stat cf_stat; - struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */ -}; - -extern struct rpc_createerr rpc_createerr; - -/* For backward compatibility */ -#include - -#endif /* !_RPC_CLNT_H_ */ diff --git a/cpukit/librpc/include/rpc/clnt_soc.h b/cpukit/librpc/include/rpc/clnt_soc.h deleted file mode 100644 index 9aa99b88ba..0000000000 --- a/cpukit/librpc/include/rpc/clnt_soc.h +++ /dev/null @@ -1,109 +0,0 @@ -/* $NetBSD: clnt_soc.h,v 1.1 2000/06/02 22:57:55 fvdl Exp $ */ -/* $FreeBSD: src/include/rpc/clnt_soc.h,v 1.2 2002/03/23 17:24:55 imp Exp $ */ - -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -/* - * Copyright (c) 1984 - 1991 by Sun Microsystems, Inc. - */ - -/* - * clnt.h - Client side remote procedure call interface. - */ - -#ifndef _RPC_CLNT_SOC_H -#define _RPC_CLNT_SOC_H - -#include - -/* derived from clnt_soc.h 1.3 88/12/17 SMI */ - -/* - * All the following declarations are only for backward compatibility - * with TS-RPC. - */ - -#include -#include - -#define UDPMSGSIZE 8800 /* rpc imposed limit on udp msg size */ - -/* - * TCP based rpc - * CLIENT * - * clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz) - * struct sockaddr_in *raddr; - * u_long prog; - * u_long version; - * register int *sockp; - * u_int sendsz; - * u_int recvsz; - */ -__BEGIN_DECLS -extern CLIENT *clnttcp_create(struct sockaddr_in *, u_long, u_long, int *, - u_int, u_int); -__END_DECLS - -/* - * Raw (memory) rpc. - */ -__BEGIN_DECLS -extern CLIENT *clntraw_create(u_long, u_long); -__END_DECLS - - -/* - * UDP based rpc. - * CLIENT * - * clntudp_create(raddr, program, version, wait, sockp) - * struct sockaddr_in *raddr; - * u_long program; - * u_long version; - * struct timeval wait; - * int *sockp; - * - * Same as above, but you specify max packet sizes. - * CLIENT * - * clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz) - * struct sockaddr_in *raddr; - * u_long program; - * u_long version; - * struct timeval wait; - * int *sockp; - * u_int sendsz; - * u_int recvsz; - */ -__BEGIN_DECLS -extern CLIENT *clntudp_create(struct sockaddr_in *, u_long, u_long, - struct timeval, int *); -extern CLIENT *clntudp_bufcreate(struct sockaddr_in *, u_long, u_long, - struct timeval, int *, u_int, u_int); -__END_DECLS - -#endif /* _RPC_CLNT_SOC_H */ diff --git a/cpukit/librpc/include/rpc/clnt_stat.h b/cpukit/librpc/include/rpc/clnt_stat.h deleted file mode 100644 index 2c68745407..0000000000 --- a/cpukit/librpc/include/rpc/clnt_stat.h +++ /dev/null @@ -1,84 +0,0 @@ -/* $FreeBSD: src/include/rpc/clnt_stat.h,v 1.2 2001/03/20 08:20:50 alfred Exp $ */ -/* - * Copyright (c) 1986 - 1991, 1994, 1996, 1997 by Sun Microsystems, Inc. - * All rights reserved. - */ - -/* - * clnt_stat.h - Client side remote procedure call enum - * - */ - -#ifndef _RPC_CLNT_STAT_H -#define _RPC_CLNT_STAT_H - -/* #pragma ident "@(#)clnt_stat.h 1.2 97/04/28 SMI" */ - -#ifdef __cplusplus -extern "C" { -#endif - -enum clnt_stat { - RPC_SUCCESS = 0, /* call succeeded */ - /* - * local errors - */ - RPC_CANTENCODEARGS = 1, /* can't encode arguments */ - RPC_CANTDECODERES = 2, /* can't decode results */ - RPC_CANTSEND = 3, /* failure in sending call */ - RPC_CANTRECV = 4, - /* failure in receiving result */ - RPC_TIMEDOUT = 5, /* call timed out */ - RPC_INTR = 18, /* call interrupted */ - RPC_UDERROR = 23, /* recv got uderr indication */ - /* - * remote errors - */ - RPC_VERSMISMATCH = 6, /* rpc versions not compatible */ - RPC_AUTHERROR = 7, /* authentication error */ - RPC_PROGUNAVAIL = 8, /* program not available */ - RPC_PROGVERSMISMATCH = 9, /* program version mismatched */ - RPC_PROCUNAVAIL = 10, /* procedure unavailable */ - RPC_CANTDECODEARGS = 11, /* decode arguments error */ - RPC_SYSTEMERROR = 12, /* generic "other problem" */ - - /* - * rpc_call & clnt_create errors - */ - RPC_UNKNOWNHOST = 13, /* unknown host name */ - RPC_UNKNOWNPROTO = 17, /* unknown protocol */ - RPC_UNKNOWNADDR = 19, /* Remote address unknown */ - RPC_NOBROADCAST = 21, /* Broadcasting not supported */ - - /* - * rpcbind errors - */ - RPC_RPCBFAILURE = 14, /* the pmapper failed in its call */ -#define RPC_PMAPFAILURE RPC_RPCBFAILURE - RPC_PROGNOTREGISTERED = 15, /* remote program is not registered */ - RPC_N2AXLATEFAILURE = 22, - /* Name to address translation failed */ - /* - * Misc error in the TLI library - */ - RPC_TLIERROR = 20, - /* - * unspecified error - */ - RPC_FAILED = 16, - /* - * asynchronous errors - */ - RPC_INPROGRESS = 24, - RPC_STALERACHANDLE = 25, - RPC_CANTCONNECT = 26, /* couldn't make connection (cots) */ - RPC_XPRTFAILED = 27, /* received discon from remote (cots) */ - RPC_CANTCREATESTREAM = 28, /* can't push rpc module (cots) */ - _CLNT_STAT = 0xffffffff -}; - -#ifdef __cplusplus -} -#endif - -#endif /* !_RPC_CLNT_STAT_H */ diff --git a/cpukit/librpc/include/rpc/pmap_clnt.h b/cpukit/librpc/include/rpc/pmap_clnt.h deleted file mode 100644 index 86fff6be4f..0000000000 --- a/cpukit/librpc/include/rpc/pmap_clnt.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - * - * from: @(#)pmap_clnt.h 1.11 88/02/08 SMI - * from: @(#)pmap_clnt.h 2.1 88/07/29 4.0 RPCSRC - * $FreeBSD: src/include/rpc/pmap_clnt.h,v 1.11 1999/08/27 23:45:04 peter Exp $ - */ - -/* - * pmap_clnt.h - * Supplies C routines to get to portmap services. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -/* - * Usage: - * success = pmap_set(program, version, protocol, port); - * success = pmap_unset(program, version); - * port = pmap_getport(address, program, version, protocol); - * head = pmap_getmaps(address); - * clnt_stat = pmap_rmtcall(address, program, version, procedure, - * xdrargs, argsp, xdrres, resp, tout, port_ptr) - * (works for udp only.) - * clnt_stat = clnt_broadcast(program, version, procedure, - * xdrargs, argsp, xdrres, resp, eachresult) - * (like pmap_rmtcall, except the call is broadcasted to all - * locally connected nets. For each valid response received, - * the procedure eachresult is called. Its form is: - * done = eachresult(resp, raddr) - * bool_t done; - * caddr_t resp; - * struct sockaddr_in raddr; - * where resp points to the results of the call and raddr is the - * address if the responder to the broadcast. - */ - -#ifndef _RPC_PMAPCLNT_H -#define _RPC_PMAPCLNT_H - -#include -#include /* struct sockaddr_in */ -#include -#include /* xdrproc_t */ - -__BEGIN_DECLS -extern bool_t pmap_set (u_long, u_long, int, int); -extern bool_t pmap_unset (u_long, u_long); -extern struct pmaplist *pmap_getmaps (struct sockaddr_in *); -extern enum clnt_stat pmap_rmtcall (struct sockaddr_in *, - u_long, u_long, u_long, - xdrproc_t, caddr_t, - xdrproc_t, caddr_t, - struct timeval, u_long *); -extern enum clnt_stat clnt_broadcast (u_long, u_long, u_long, - xdrproc_t, char *, - xdrproc_t, char *, - bool_t (*) (caddr_t, - struct sockaddr_in *)); -extern u_short pmap_getport (struct sockaddr_in *, - u_long, u_long, u_int); -__END_DECLS - -#endif /* !_RPC_PMAPCLNT_H */ diff --git a/cpukit/librpc/include/rpc/pmap_prot.h b/cpukit/librpc/include/rpc/pmap_prot.h deleted file mode 100644 index 14720e8cbd..0000000000 --- a/cpukit/librpc/include/rpc/pmap_prot.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - * - * from: @(#)pmap_prot.h 1.14 88/02/08 SMI - * from: @(#)pmap_prot.h 2.1 88/07/29 4.0 RPCSRC - * $FreeBSD: src/include/rpc/pmap_prot.h,v 1.10 1999/08/27 23:45:04 peter Exp $ - */ - -/* - * pmap_prot.h - * Protocol for the local binder service, or pmap. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - * - * The following procedures are supported by the protocol: - * - * PMAPPROC_NULL() returns () - * takes nothing, returns nothing - * - * PMAPPROC_SET(struct pmap) returns (bool_t) - * TRUE is success, FALSE is failure. Registers the tuple - * [prog, vers, prot, port]. - * - * PMAPPROC_UNSET(struct pmap) returns (bool_t) - * TRUE is success, FALSE is failure. Un-registers pair - * [prog, vers]. prot and port are ignored. - * - * PMAPPROC_GETPORT(struct pmap) returns (long unsigned). - * 0 is failure. Otherwise returns the port number where the pair - * [prog, vers] is registered. It may lie! - * - * PMAPPROC_DUMP() RETURNS (struct pmaplist *) - * - * PMAPPROC_CALLIT(unsigned, unsigned, unsigned, string<>) - * RETURNS (port, string<>); - * usage: encapsulatedresults = PMAPPROC_CALLIT(prog, vers, proc, encapsulatedargs); - * Calls the procedure on the local machine. If it is not registered, - * this procedure is quite; ie it does not return error information!!! - * This procedure only is supported on rpc/udp and calls via - * rpc/udp. This routine only passes null authentication parameters. - * This file has no interface to xdr routines for PMAPPROC_CALLIT. - * - * The service supports remote procedure calls on udp/ip or tcp/ip socket 111. - */ - -#ifndef _RPC_PMAPPROT_H -#define _RPC_PMAPPROT_H -#include -#include - -#define PMAPPORT ((u_short)111) -#define PMAPPROG ((u_long)100000) -#define PMAPVERS ((u_long)2) -#define PMAPVERS_PROTO ((u_long)2) -#define PMAPVERS_ORIG ((u_long)1) -#define PMAPPROC_NULL ((u_long)0) -#define PMAPPROC_SET ((u_long)1) -#define PMAPPROC_UNSET ((u_long)2) -#define PMAPPROC_GETPORT ((u_long)3) -#define PMAPPROC_DUMP ((u_long)4) -#define PMAPPROC_CALLIT ((u_long)5) - -struct pmap { - long unsigned pm_prog; - long unsigned pm_vers; - long unsigned pm_prot; - long unsigned pm_port; -}; - -struct pmaplist { - struct pmap pml_map; - struct pmaplist *pml_next; -}; - -__BEGIN_DECLS -extern bool_t xdr_pmap (XDR *, struct pmap *); -extern bool_t xdr_pmaplist (XDR *, struct pmaplist **); -__END_DECLS - -#endif /* !_RPC_PMAPPROT_H */ diff --git a/cpukit/librpc/include/rpc/pmap_rmt.h b/cpukit/librpc/include/rpc/pmap_rmt.h deleted file mode 100644 index a5ea404f45..0000000000 --- a/cpukit/librpc/include/rpc/pmap_rmt.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - * - * from: @(#)pmap_rmt.h 1.2 88/02/08 SMI - * from: @(#)pmap_rmt.h 2.1 88/07/29 4.0 RPCSRC - * $FreeBSD: src/include/rpc/pmap_rmt.h,v 1.10 1999/08/27 23:45:05 peter Exp $ - */ - -/* - * Structures and XDR routines for parameters to and replies from - * the portmapper remote-call-service. - * - * Copyright (C) 1986, Sun Microsystems, Inc. - */ - -#ifndef _RPC_PMAPRMT_H -#define _RPC_PMAPRMT_H -#include -#include - -struct rmtcallargs { - u_long prog, vers, proc, arglen; - caddr_t args_ptr; - xdrproc_t xdr_args; -}; - -struct rmtcallres { - u_long *port_ptr; - u_long resultslen; - caddr_t results_ptr; - xdrproc_t xdr_results; -}; - -__BEGIN_DECLS -extern bool_t xdr_rmtcall_args (XDR *, struct rmtcallargs *); -extern bool_t xdr_rmtcallres (XDR *, struct rmtcallres *); -__END_DECLS - -#endif /* !_RPC_PMAPRMT_H */ diff --git a/cpukit/librpc/include/rpc/rpc.h b/cpukit/librpc/include/rpc/rpc.h deleted file mode 100644 index 20065efd4d..0000000000 --- a/cpukit/librpc/include/rpc/rpc.h +++ /dev/null @@ -1,118 +0,0 @@ -/* $NetBSD: rpc.h,v 1.13 2000/06/02 22:57:56 fvdl Exp $ */ - -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - * - * from: @(#)rpc.h 1.9 88/02/08 SMI - * from: @(#)rpc.h 2.4 89/07/11 4.0 RPCSRC - * $FreeBSD: src/include/rpc/rpc.h,v 1.17 2002/03/23 17:24:55 imp Exp $ - */ - -/* - * rpc.h, Just includes the billions of rpc header files necessary to - * do remote procedure calling. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ -#ifndef _RPC_RPC_H -#define _RPC_RPC_H - -#include /* some typedefs */ -#include - -/* external data representation interfaces */ -#include /* generic (de)serializer */ - -/* Client side only authentication */ -#include /* generic authenticator (client side) */ - -/* Client side (mostly) remote procedure call */ -#include /* generic rpc stuff */ - -/* semi-private protocol headers */ -#include /* protocol for rpc messages */ -#include /* protocol for unix style cred */ - -/* Server side only remote procedure callee */ -#include /* service manager and multiplexer */ -#include /* service side authenticator */ - -#include - -__BEGIN_DECLS -extern int get_myaddress(struct sockaddr_in *); -extern int bindresvport(int, struct sockaddr_in *); -extern int bindresvport_sa(int, struct sockaddr *); -__END_DECLS - -int rtems_rpc_task_init (void); -int rtems_rpc_start_portmapper (int priority); - -#ifdef _RTEMS_RPC_INTERNAL_ -/* - * Multi-threaded support - * Group all global and static variables into a single spot. - * This area will be allocated on a per-task basis - */ -struct _rtems_rpc_task_variables { - int svc_svc_maxfd; - fd_set svc_svc_fdset; - SVCXPRT ** svc_xports; - int svc_xportssize; - int svc__svc_fdsetsize; - fd_set *svc__svc_fdset; - struct svc_callout *svc_svc_head; - - char *clnt_perror_buf; - - struct clnt_raw_private *clnt_raw_private; - - void *call_rpc_private; - - struct call_rpc_private *svc_raw_private; - - struct prog_lst *svc_simple_proglst; - struct prog_lst *svc_simple_pl; - SVCXPRT *svc_simple_transp; - - char *rpcdname_default_domain; - - struct authsvc *svc_auths_Auths; -}; - -struct _rtems_rpc_task_variables *rtems_rpc_task_variables_get(void); -#define rtems_rpc_task_variables rtems_rpc_task_variables_get() - -#define svc_maxfd (rtems_rpc_task_variables->svc_svc_maxfd) -#define svc_fdset (rtems_rpc_task_variables->svc_svc_fdset) -#define __svc_fdsetsize (rtems_rpc_task_variables->svc__svc_fdsetsize) -#define __svc_fdset (rtems_rpc_task_variables->svc__svc_fdset) - -#endif /* _RTEMS_RPC_INTERNAL_ */ - -#endif /* !_RPC_RPC_H */ diff --git a/cpukit/librpc/include/rpc/rpc_com.h b/cpukit/librpc/include/rpc/rpc_com.h deleted file mode 100644 index 9a1ce453ab..0000000000 --- a/cpukit/librpc/include/rpc/rpc_com.h +++ /dev/null @@ -1,65 +0,0 @@ -/* $NetBSD: rpc_com.h,v 1.3 2000/12/10 04:10:08 christos Exp $ */ -/* $FreeBSD: src/include/rpc/rpc_com.h,v 1.6 2003/01/16 07:13:51 mbr Exp $ */ - -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ - -/* - * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. - */ - -/* - * rpc_com.h, Common definitions for both the server and client side. - * All for the topmost layer of rpc - * - */ - -#ifndef _RPC_RPCCOM_H -#define _RPC_RPCCOM_H - -#include - -/* #pragma ident "@(#)rpc_com.h 1.11 93/07/05 SMI" */ - -/* - * The max size of the transport, if the size cannot be determined - * by other means. - */ -#define RPC_MAXDATASIZE 9000 -#define RPC_MAXADDRSIZE 1024 - -__BEGIN_DECLS -extern u_int __rpc_get_a_size(int); -extern u_int __rpc_get_t_size(int, long); -extern int __rpc_dtbsize(void); -extern int _rpc_dtablesize(void); -extern int _rpc_get_default_domain(char **); -__END_DECLS - -#endif /* _RPC_RPCCOM_H */ diff --git a/cpukit/librpc/include/rpc/rpc_msg.h b/cpukit/librpc/include/rpc/rpc_msg.h deleted file mode 100644 index 63a1f360a0..0000000000 --- a/cpukit/librpc/include/rpc/rpc_msg.h +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - * - * from: @(#)rpc_msg.h 1.7 86/07/16 SMI - * from: @(#)rpc_msg.h 2.1 88/07/29 4.0 RPCSRC - * $FreeBSD: src/include/rpc/rpc_msg.h,v 1.15 2003/01/01 18:48:42 schweikh Exp $ - */ - -/* - * rpc_msg.h - * rpc message definition - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#ifndef _RPC_RPC_MSG_H -#define _RPC_RPC_MSG_H - -#include -#include /* xdrproc_t */ -#include /* opaque_auth */ - -struct rpc_err; /* forward */ - -#define RPC_MSG_VERSION ((u_int32_t) 2) -#define RPC_SERVICE_PORT ((u_short) 2048) - -/* - * Bottom up definition of an rpc message. - * NOTE: call and reply use the same overall stuct but - * different parts of unions within it. - */ - -enum msg_type { - CALL=0, - REPLY=1, - _MSG_TYPE = 0xffffffff -}; - -enum reply_stat { - MSG_ACCEPTED=0, - MSG_DENIED=1, - _REPLY_STAT = 0xffffffff -}; - -enum accept_stat { - SUCCESS=0, - PROG_UNAVAIL=1, - PROG_MISMATCH=2, - PROC_UNAVAIL=3, - GARBAGE_ARGS=4, - SYSTEM_ERR=5, - _ACCEPT_STAT = 0xffffffff -}; - -enum reject_stat { - RPC_MISMATCH=0, - AUTH_ERROR=1, - _REJECT_STAT = 0xffffffff -}; - -/* - * Reply part of an rpc exchange - */ - -/* - * Reply to an rpc request that was accepted by the server. - * Note: there could be an error even though the request was - * accepted. - */ -struct accepted_reply { - struct opaque_auth ar_verf; - enum accept_stat ar_stat; - union { - struct { - rpcvers_t low; - rpcvers_t high; - } AR_versions; - struct { - caddr_t where; - xdrproc_t proc; - } AR_results; - /* and many other null cases */ - } ru; -#define ar_results ru.AR_results -#define ar_vers ru.AR_versions -}; - -/* - * Reply to an rpc request that was rejected by the server. - */ -struct rejected_reply { - enum reject_stat rj_stat; - union { - struct { - rpcvers_t low; - rpcvers_t high; - } RJ_versions; - enum auth_stat RJ_why; /* why authentication did not work */ - } ru; -#define rj_vers ru.RJ_versions -#define rj_why ru.RJ_why -}; - -/* - * Body of a reply to an rpc request. - */ -struct reply_body { - enum reply_stat rp_stat; - union { - struct accepted_reply RP_ar; - struct rejected_reply RP_dr; - } ru; -#define rp_acpt ru.RP_ar -#define rp_rjct ru.RP_dr -}; - -/* - * Body of an rpc request call. - */ -struct call_body { - rpcvers_t cb_rpcvers; /* must be equal to two */ - rpcprog_t cb_prog; - rpcvers_t cb_vers; - rpcproc_t cb_proc; - struct opaque_auth cb_cred; - struct opaque_auth cb_verf; /* protocol specific - provided by client */ -}; - -/* - * The rpc message - */ -struct rpc_msg { - u_int32_t rm_xid; - enum msg_type rm_direction; - union { - struct call_body RM_cmb; - struct reply_body RM_rmb; - } ru; -#define rm_call ru.RM_cmb -#define rm_reply ru.RM_rmb -}; -#define acpted_rply ru.RM_rmb.ru.RP_ar -#define rjcted_rply ru.RM_rmb.ru.RP_dr - -__BEGIN_DECLS -/* - * XDR routine to handle a rpc message. - * xdr_callmsg(xdrs, cmsg) - * XDR *xdrs; - * struct rpc_msg *cmsg; - */ -extern bool_t xdr_callmsg(XDR *, struct rpc_msg *); - -/* - * XDR routine to pre-serialize the static part of a rpc message. - * xdr_callhdr(xdrs, cmsg) - * XDR *xdrs; - * struct rpc_msg *cmsg; - */ -extern bool_t xdr_callhdr(XDR *, struct rpc_msg *); - -/* - * XDR routine to handle a rpc reply. - * xdr_replymsg(xdrs, rmsg) - * XDR *xdrs; - * struct rpc_msg *rmsg; - */ -extern bool_t xdr_replymsg(XDR *, struct rpc_msg *); - -/* - * Fills in the error part of a reply message. - * _seterr_reply(msg, error) - * struct rpc_msg *msg; - * struct rpc_err *error; - */ -extern void _seterr_reply(struct rpc_msg *, struct rpc_err *); -__END_DECLS - -#endif /* !_RPC_RPC_MSG_H */ diff --git a/cpukit/librpc/include/rpc/rpcent.h b/cpukit/librpc/include/rpc/rpcent.h deleted file mode 100644 index 1cf4161b81..0000000000 --- a/cpukit/librpc/include/rpc/rpcent.h +++ /dev/null @@ -1,71 +0,0 @@ -/* $NetBSD: rpcent.h,v 1.1 2000/06/02 22:57:56 fvdl Exp $ */ -/* $FreeBSD: src/include/rpc/rpcent.h,v 1.2 2002/03/23 17:24:55 imp Exp $ */ - -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -/* - * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. - */ - -/* - * rpcent.h, - * For converting rpc program numbers to names etc. - * - */ - -#ifndef _RPC_RPCENT_H -#define _RPC_RPCENT_H - -#include - -/* #pragma ident "@(#)rpcent.h 1.13 94/04/25 SMI" */ -/* @(#)rpcent.h 1.1 88/12/06 SMI */ - - -struct rpcent { - char *r_name; /* name of server for this rpc program */ - char **r_aliases; /* alias list */ - int r_number; /* rpc program number */ -}; - -__BEGIN_DECLS -extern struct rpcent *getrpcbyname_r(const char *, struct rpcent *, - char *, int); -extern struct rpcent *getrpcbynumber_r(int, struct rpcent *, char *, int); -extern struct rpcent *getrpcent_r(struct rpcent *, char *, int); - -/* Old interfaces that return a pointer to a static area; MT-unsafe */ -extern struct rpcent *getrpcbyname(char *); -extern struct rpcent *getrpcbynumber(int); -extern struct rpcent *getrpcent(void); -extern void setrpcent(int); -extern void endrpcent(void); -__END_DECLS - -#endif /* !_RPC_CENT_H */ diff --git a/cpukit/librpc/include/rpc/svc.h b/cpukit/librpc/include/rpc/svc.h deleted file mode 100644 index 0808dddc5c..0000000000 --- a/cpukit/librpc/include/rpc/svc.h +++ /dev/null @@ -1,297 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - * - * from: @(#)svc.h 1.35 88/12/17 SMI - * from: @(#)svc.h 1.27 94/04/25 SMI - * $FreeBSD: src/include/rpc/svc.h,v 1.24 2003/06/15 10:32:01 mbr Exp $ - */ - -/* - * svc.h, Server-side remote procedure call interface. - * - * Copyright (C) 1986-1993 by Sun Microsystems, Inc. - */ - -#ifndef _RPC_SVC_H -#define _RPC_SVC_H - -#include -#include -#include /* xdrproc_t */ -#include /* fd_set */ -#include /* socklen_t */ -#include /* struct sockaddr_in */ -#include /* auth_stat */ - -/* - * This interface must manage two items concerning remote procedure calling: - * - * 1) An arbitrary number of transport connections upon which rpc requests - * are received. The two most notable transports are TCP and UDP; they are - * created and registered by routines in svc_tcp.c and svc_udp.c, respectively; - * they in turn call xprt_register and xprt_unregister. - * - * 2) An arbitrary number of locally registered services. Services are - * described by the following four data: program number, version number, - * "service dispatch" function, a transport handle, and a boolean that - * indicates whether or not the exported program should be registered with a - * local binder service; if true the program's number and version and the - * port number from the transport handle are registered with the binder. - * These data are registered with the rpc svc system via svc_register. - * - * A service's dispatch function is called whenever an rpc request comes in - * on a transport. The request's program and version numbers must match - * those of the registered service. The dispatch function is passed two - * parameters, struct svc_req * and SVCXPRT *, defined below. - */ - -enum xprt_stat { - XPRT_DIED, - XPRT_MOREREQS, - XPRT_IDLE, - _XPRT_STAT = 0xffffffff -}; - -struct rpc_msg; - -/* - * Server side transport handle - */ -typedef struct __rpc_svcxprt { - int xp_sock; - u_short xp_port; /* associated port number */ - struct xp_ops { - /* receive incoming requests */ - bool_t (*xp_recv)(struct __rpc_svcxprt *, struct rpc_msg *); - /* get transport status */ - enum xprt_stat (*xp_stat)(struct __rpc_svcxprt *); - /* get arguments */ - bool_t (*xp_getargs)(struct __rpc_svcxprt *, xdrproc_t, - caddr_t args_ptr); - /* send reply */ - bool_t (*xp_reply)(struct __rpc_svcxprt *, struct rpc_msg *); - /* free mem allocated for args */ - bool_t (*xp_freeargs)(struct __rpc_svcxprt *, xdrproc_t, - caddr_t args_ptr); - /* destroy this struct */ - void (*xp_destroy)(struct __rpc_svcxprt *); - } *xp_ops; - socklen_t xp_addrlen; /* length of remote address */ - struct sockaddr_in xp_raddr; /* remote addr. (backward ABI compat) */ - struct opaque_auth xp_verf; /* raw response verifier */ - void *xp_p1; /* private: for use by svc ops */ - void *xp_p2; /* private: for use by svc ops */ -} SVCXPRT; - -/* - * Service request - */ -struct svc_req { - u_int32_t rq_prog; /* service program number */ - u_int32_t rq_vers; /* service protocol version */ - u_int32_t rq_proc; /* the desired procedure */ - struct opaque_auth rq_cred; /* raw creds from the wire */ - caddr_t rq_clntcred; /* read only cooked cred */ - SVCXPRT *rq_xprt; /* associated transport */ -}; - - -/* - * Operations defined on an SVCXPRT handle - * - * SVCXPRT *xprt; - * struct rpc_msg *msg; - * xdrproc_t xargs; - * caddr_t argsp; - */ -#define SVC_RECV(xprt, msg) \ - (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) -#define svc_recv(xprt, msg) \ - (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) - -#define SVC_STAT(xprt) \ - (*(xprt)->xp_ops->xp_stat)(xprt) -#define svc_stat(xprt) \ - (*(xprt)->xp_ops->xp_stat)(xprt) - -#define SVC_GETARGS(xprt, xargs, argsp) \ - (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) -#define svc_getargs(xprt, xargs, argsp) \ - (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) - -#define SVC_REPLY(xprt, msg) \ - (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) -#define svc_reply(xprt, msg) \ - (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) - -#define SVC_FREEARGS(xprt, xargs, argsp) \ - (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) -#define svc_freeargs(xprt, xargs, argsp) \ - (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) - -#define SVC_DESTROY(xprt) \ - (*(xprt)->xp_ops->xp_destroy)(xprt) -#define svc_destroy(xprt) \ - (*(xprt)->xp_ops->xp_destroy)(xprt) - -/* - * Transport registration. - * - * xprt_register(xprt) - * SVCXPRT *xprt; - */ -__BEGIN_DECLS -extern void xprt_register(SVCXPRT *); -__END_DECLS - -/* - * Transport un-register - * - * xprt_unregister(xprt) - * SVCXPRT *xprt; - */ -__BEGIN_DECLS -extern void xprt_unregister(SVCXPRT *); -__END_DECLS - - -/* - * When the service routine is called, it must first check to see if it - * knows about the procedure; if not, it should call svcerr_noproc - * and return. If so, it should deserialize its arguments via - * SVC_GETARGS (defined above). If the deserialization does not work, - * svcerr_decode should be called followed by a return. Successful - * decoding of the arguments should be followed the execution of the - * procedure's code and a call to svc_sendreply. - * - * Also, if the service refuses to execute the procedure due to too- - * weak authentication parameters, svcerr_weakauth should be called. - * Note: do not confuse access-control failure with weak authentication! - * - * NB: In pure implementations of rpc, the caller always waits for a reply - * msg. This message is sent when svc_sendreply is called. - * Therefore pure service implementations should always call - * svc_sendreply even if the function logically returns void; use - * xdr.h - xdr_void for the xdr routine. HOWEVER, tcp based rpc allows - * for the abuse of pure rpc via batched calling or pipelining. In the - * case of a batched call, svc_sendreply should NOT be called since - * this would send a return message, which is what batching tries to avoid. - * It is the service/protocol writer's responsibility to know which calls are - * batched and which are not. Warning: responding to batch calls may - * deadlock the caller and server processes! - */ - -__BEGIN_DECLS -extern bool_t svc_sendreply(SVCXPRT *, xdrproc_t, void *); -extern void svcerr_decode(SVCXPRT *); -extern void svcerr_weakauth(SVCXPRT *); -extern void svcerr_noproc(SVCXPRT *); -extern void svcerr_progvers(SVCXPRT *, rpcvers_t, rpcvers_t); -extern void svcerr_auth(SVCXPRT *, enum auth_stat); -extern void svcerr_noprog(SVCXPRT *); -extern void svcerr_systemerr(SVCXPRT *); -__END_DECLS - -/* - * Lowest level dispatching -OR- who owns this process anyway. - * Somebody has to wait for incoming requests and then call the correct - * service routine. The routine svc_run does infinite waiting; i.e., - * svc_run never returns. - * Since another (co-existant) package may wish to selectively wait for - * incoming calls or other events outside of the rpc architecture, the - * routine svc_getreq is provided. It must be passed readfds, the - * "in-place" results of a select system call (see select, section 2). - */ - -/* - * Global keeper of rpc service descriptors in use - * dynamic; must be inspected before each call to select - */ -extern int svc_maxfd; -extern fd_set svc_fdset; -#define svc_fds svc_fdset.fds_bits[0] /* compatibility */ - -#ifndef _KERNEL -/* - * a small program implemented by the svc_rpc implementation itself; - * also see clnt.h for protocol numbers. - */ -__BEGIN_DECLS -extern void rpctest_service(void); -__END_DECLS -#endif - -__BEGIN_DECLS -extern void svc_getreq(int); -extern void svc_getreqset(fd_set *); -extern void svc_getreqset2(fd_set *, int); /* XXX: nonstd, undoc */ -extern void svc_run(void); -__END_DECLS - -/* - * Socket to use on svcxxx_create call to get default socket - */ -#define RPC_ANYSOCK -1 -#define RPC_ANYFD RPC_ANYSOCK - -/* - * These are the existing service side transport implementations - */ - -__BEGIN_DECLS -/* - * Transport independent svc_create routine. - */ - -/* - * Connectionless and connectionful create routines - */ - -extern SVCXPRT *svc_vc_create(const int, const u_int, const u_int); -/* - * const int fd; -- open connection end point - * const u_int sendsize; -- max send size - * const u_int recvsize; -- max recv size - */ - -/* - * Added for compatibility to old rpc 4.0. Obsoleted by svc_vc_create(). - */ -extern SVCXPRT *svcunix_create(int, u_int, u_int, char *); - -/* - * Added for compatibility to old rpc 4.0. Obsoleted by svc_fd_create(). - */ -extern SVCXPRT *svcunixfd_create(int, u_int, u_int); -__END_DECLS - - -/* for backward compatibility */ -#include - -#endif /* !_RPC_SVC_H */ diff --git a/cpukit/librpc/include/rpc/svc_auth.h b/cpukit/librpc/include/rpc/svc_auth.h deleted file mode 100644 index 846752c294..0000000000 --- a/cpukit/librpc/include/rpc/svc_auth.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - * - * from: @(#)svc_auth.h 1.6 86/07/16 SMI - * from: @(#)svc_auth.h 2.1 88/07/29 4.0 RPCSRC - * $FreeBSD: src/include/rpc/svc_auth.h,v 1.12 1999/08/27 23:45:05 peter Exp $ - */ - -/* - * svc_auth.h, Service side of rpc authentication. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#ifndef _RPC_SVCAUTH_H -#define _RPC_SVCAUTH_H - -#include - -struct rpc_msg; -struct svc_req; - -/* - * Server side authenticator - */ -__BEGIN_DECLS -extern enum auth_stat _authenticate (struct svc_req *, struct rpc_msg *); -extern int svc_auth_reg (int, enum auth_stat (*)(struct svc_req *, - struct rpc_msg *)); -extern enum auth_stat _svcauth_des (struct svc_req *, struct rpc_msg *); -__END_DECLS - -#endif /* !_RPC_SVCAUTH_H */ diff --git a/cpukit/librpc/include/rpc/svc_soc.h b/cpukit/librpc/include/rpc/svc_soc.h deleted file mode 100644 index 5b36fb46ef..0000000000 --- a/cpukit/librpc/include/rpc/svc_soc.h +++ /dev/null @@ -1,125 +0,0 @@ -/* $NetBSD: svc_soc.h,v 1.1 2000/06/02 22:57:57 fvdl Exp $ */ -/* $FreeBSD: src/include/rpc/svc_soc.h,v 1.2 2002/03/23 17:24:55 imp Exp $ */ - -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - */ -/* - * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. - */ - -/* - * svc.h, Server-side remote procedure call interface. - */ - -#ifndef _RPC_SVC_SOC_H -#define _RPC_SVC_SOC_H -#include -#include -#include /* SVCXPRT */ - -/* #pragma ident "@(#)svc_soc.h 1.11 94/04/25 SMI" */ -/* svc_soc.h 1.8 89/05/01 SMI */ - -/* - * All the following declarations are only for backward compatibility - * with TS-RPC - */ - -/* - * Approved way of getting address of caller - */ -#define svc_getcaller(x) (&(x)->xp_raddr) - -/* - * Service registration - * - * svc_register(xprt, prog, vers, dispatch, protocol) - * SVCXPRT *xprt; - * u_long prog; - * u_long vers; - * void (*dispatch)(); - * int protocol; like TCP or UDP, zero means do not register - */ -__BEGIN_DECLS -extern bool_t svc_register(SVCXPRT *, u_long, u_long, - void (*)(struct svc_req *, SVCXPRT *), int); -__END_DECLS - -/* - * Service un-registration - * - * svc_unregister(prog, vers) - * u_long prog; - * u_long vers; - */ -__BEGIN_DECLS -extern void svc_unregister(u_long, u_long); -__END_DECLS - - -/* - * Memory based rpc for testing and timing. - */ -__BEGIN_DECLS -extern SVCXPRT *svcraw_create(void); -__END_DECLS - - -/* - * Udp based rpc. - */ -__BEGIN_DECLS -extern SVCXPRT *svcudp_create(int); -extern SVCXPRT *svcudp_bufcreate(int, u_int, u_int); -__END_DECLS - - -/* - * Tcp based rpc. - */ -__BEGIN_DECLS -extern SVCXPRT *svctcp_create(int, u_int, u_int); -__END_DECLS - -/* - * Fd based rpc. - */ -__BEGIN_DECLS -extern SVCXPRT *svcfd_create(int, u_int, u_int); -__END_DECLS - -/* - * AF_UNIX socket based rpc. - */ -__BEGIN_DECLS -extern SVCXPRT *svcunix_create (int, u_int, u_int, char *); -extern SVCXPRT *svcunixfd_create (int, u_int, u_int); -__END_DECLS - -#endif /* !_RPC_SVC_SOC_H */ diff --git a/cpukit/librpc/include/rpc/types.h b/cpukit/librpc/include/rpc/types.h deleted file mode 100644 index 05375d32e9..0000000000 --- a/cpukit/librpc/include/rpc/types.h +++ /dev/null @@ -1,68 +0,0 @@ -/* $NetBSD: types.h,v 1.13 2000/06/13 01:02:44 thorpej Exp $ */ - -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - * - * from: @(#)types.h 1.18 87/07/24 SMI - * from: @(#)types.h 2.3 88/08/15 4.0 RPCSRC - * $FreeBSD: src/include/rpc/types.h,v 1.11 2003/12/07 21:10:06 marcel Exp $ - */ - -/* - * Rpc additions to - */ -#ifndef _RPC_TYPES_H -#define _RPC_TYPES_H - -#include - -typedef int32_t bool_t; -typedef int32_t enum_t; - -typedef uint32_t rpcprog_t; -typedef uint32_t rpcvers_t; -typedef uint32_t rpcproc_t; -typedef uint32_t rpcprot_t; -typedef uint32_t rpcport_t; -typedef int32_t rpc_inline_t; - -#define __dontcare__ -1 - -#ifndef FALSE -# define FALSE (0) -#endif -#ifndef TRUE -# define TRUE (1) -#endif - -#define mem_alloc(bsize) malloc(bsize) -#define mem_free(ptr, bsize) free(ptr) - -#include - -#endif /* !_RPC_TYPES_H */ diff --git a/cpukit/librpc/include/rpc/xdr.h b/cpukit/librpc/include/rpc/xdr.h deleted file mode 100644 index 30f2bccc0c..0000000000 --- a/cpukit/librpc/include/rpc/xdr.h +++ /dev/null @@ -1,312 +0,0 @@ -/* $NetBSD: xdr.h,v 1.19 2000/07/17 05:00:45 matt Exp $ */ - -/* - * Sun RPC is a product of Sun Microsystems, Inc. and is provided for - * unrestricted use provided that this legend is included on all tape - * media and as a part of the software program in whole or part. Users - * may copy or modify Sun RPC without charge, but are not authorized - * to license or distribute it to anyone else except as part of a product or - * program developed by the user. - * - * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * - * Sun RPC is provided with no support and without any obligation on the - * part of Sun Microsystems, Inc. to assist in its use, correction, - * modification or enhancement. - * - * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE - * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC - * OR ANY PART THEREOF. - * - * In no event will Sun Microsystems, Inc. be liable for any lost revenue - * or profits or other special, indirect and consequential damages, even if - * Sun has been advised of the possibility of such damages. - * - * Sun Microsystems, Inc. - * 2550 Garcia Avenue - * Mountain View, California 94043 - * - * from: @(#)xdr.h 1.19 87/04/22 SMI - * from: @(#)xdr.h 2.2 88/07/29 4.0 RPCSRC - * $FreeBSD: src/include/rpc/xdr.h,v 1.23 2003/03/07 13:19:40 nectar Exp $ - */ - -/* - * xdr.h, External Data Representation Serialization Routines. - * - * Copyright (C) 1984, Sun Microsystems, Inc. - */ - -#ifndef _RPC_XDR_H -#define _RPC_XDR_H - -#include - -#include - -/* - * XDR provides a conventional way for converting between C data - * types and an external bit-string representation. Library supplied - * routines provide for the conversion on built-in C data types. These - * routines and utility routines defined here are used to help implement - * a type encode/decode routine for each user-defined type. - * - * Each data type provides a single procedure which takes two arguments: - * - * bool_t - * xdrproc(xdrs, argresp) - * XDR *xdrs; - * *argresp; - * - * xdrs is an instance of a XDR handle, to which or from which the data - * type is to be converted. argresp is a pointer to the structure to be - * converted. The XDR handle contains an operation field which indicates - * which of the operations (ENCODE, DECODE * or FREE) is to be performed. - * - * XDR_DECODE may allocate space if the pointer argresp is null. This - * data can be freed with the XDR_FREE operation. - * - * We write only one procedure per data type to make it easy - * to keep the encode and decode procedures for a data type consistent. - * In many cases the same code performs all operations on a user defined type, - * because all the hard work is done in the component type routines. - * decode as a series of calls on the nested data types. - */ - -/* - * Xdr operations. XDR_ENCODE causes the type to be encoded into the - * stream. XDR_DECODE causes the type to be extracted from the stream. - * XDR_FREE can be used to release the space allocated by an XDR_DECODE - * request. - */ -enum xdr_op { - XDR_ENCODE=0, - XDR_DECODE=1, - XDR_FREE=2 -}; - -/* - * This is the number of bytes per unit of external data. - */ -#define BYTES_PER_XDR_UNIT (4) -#define RNDUP(x) ((((x) + BYTES_PER_XDR_UNIT - 1) / BYTES_PER_XDR_UNIT) \ - * BYTES_PER_XDR_UNIT) - -/* - * The XDR handle. - * Contains operation which is being applied to the stream, - * an operations vector for the particular implementation (e.g. see xdr_mem.c), - * and two private fields for the use of the particular implementation. - */ -typedef struct __rpc_xdr { - enum xdr_op x_op; /* operation; fast additional param */ - const struct xdr_ops { - /* get a long from underlying stream */ - bool_t (*x_getlong)(struct __rpc_xdr *, long *); - /* put a long to " */ - bool_t (*x_putlong)(struct __rpc_xdr *, const long *); - /* get some bytes from " */ - bool_t (*x_getbytes)(struct __rpc_xdr *, char *, u_int); - /* put some bytes to " */ - bool_t (*x_putbytes)(struct __rpc_xdr *, const char *, u_int); - /* returns bytes off from beginning */ - u_int (*x_getpostn)(struct __rpc_xdr *); - /* lets you reposition the stream */ - bool_t (*x_setpostn)(struct __rpc_xdr *, u_int); - /* buf quick ptr to buffered data */ - int32_t *(*x_inline)(struct __rpc_xdr *, u_int); - /* free privates of this xdr_stream */ - void (*x_destroy)(struct __rpc_xdr *); - } *x_ops; - char * x_public; /* users' data */ - void * x_private; /* pointer to private data */ - char * x_base; /* private used for position info */ - u_int x_handy; /* extra private word */ -} XDR; - -/* - * A xdrproc_t exists for each data type which is to be encoded or decoded. - * - * The second argument to the xdrproc_t is a pointer to an opaque pointer. - * The opaque pointer generally points to a structure of the data type - * to be decoded. If this pointer is 0, then the type routines should - * allocate dynamic storage of the appropriate size and return it. - */ -typedef bool_t (*xdrproc_t) (XDR *, void *, ...); - -/* - * Operations defined on a XDR handle - * - * XDR *xdrs; - * long *longp; - * caddr_t addr; - * u_int len; - * u_int pos; - */ -#define XDR_GETLONG(xdrs, longp) \ - (*(xdrs)->x_ops->x_getlong)(xdrs, longp) -#define xdr_getlong(xdrs, longp) \ - (*(xdrs)->x_ops->x_getlong)(xdrs, longp) - -#define XDR_PUTLONG(xdrs, longp) \ - (*(xdrs)->x_ops->x_putlong)(xdrs, longp) -#define xdr_putlong(xdrs, longp) \ - (*(xdrs)->x_ops->x_putlong)(xdrs, longp) - -#define XDR_GETBYTES(xdrs, addr, len) \ - (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) -#define xdr_getbytes(xdrs, addr, len) \ - (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) - -#define XDR_PUTBYTES(xdrs, addr, len) \ - (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) -#define xdr_putbytes(xdrs, addr, len) \ - (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) - -#define XDR_GETPOS(xdrs) \ - (*(xdrs)->x_ops->x_getpostn)(xdrs) -#define xdr_getpos(xdrs) \ - (*(xdrs)->x_ops->x_getpostn)(xdrs) - -#define XDR_SETPOS(xdrs, pos) \ - (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) -#define xdr_setpos(xdrs, pos) \ - (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) - -#define XDR_INLINE(xdrs, len) \ - (*(xdrs)->x_ops->x_inline)(xdrs, len) -#define xdr_inline(xdrs, len) \ - (*(xdrs)->x_ops->x_inline)(xdrs, len) - -#define XDR_DESTROY(xdrs) \ - if ((xdrs)->x_ops->x_destroy) \ - (*(xdrs)->x_ops->x_destroy)(xdrs) -#define xdr_destroy(xdrs) \ - if ((xdrs)->x_ops->x_destroy) \ - (*(xdrs)->x_ops->x_destroy)(xdrs) - -/* - * Support struct for discriminated unions. - * You create an array of xdrdiscrim structures, terminated with - * an entry with a null procedure pointer. The xdr_union routine gets - * the discriminant value and then searches the array of structures - * for a matching value. If a match is found the associated xdr routine - * is called to handle that part of the union. If there is - * no match, then a default routine may be called. - * If there is no match and no default routine it is an error. - */ -#define NULL_xdrproc_t ((xdrproc_t)0) -struct xdr_discrim { - int value; - xdrproc_t proc; -}; - -/* - * In-line routines for fast encode/decode of primitive data types. - * Caveat emptor: these use single memory cycles to get the - * data from the underlying buffer, and will fail to operate - * properly if the data is not aligned. The standard way to use these - * is to say: - * if ((buf = XDR_INLINE(xdrs, count)) == NULL) - * return (FALSE); - * <<< macro calls >>> - * where ``count'' is the number of bytes of data occupied - * by the primitive data types. - * - * N.B. and frozen for all time: each data type here uses 4 bytes - * of external representation. - */ -#define IXDR_GET_LONG(buf) ((long)ntohl((u_long)*(buf)++)) -#define IXDR_PUT_LONG(buf, v) (*(buf)++ = (long)htonl((u_long)v)) - -#define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_LONG(buf)) -#define IXDR_GET_ENUM(buf, t) ((t)IXDR_GET_LONG(buf)) -#define IXDR_GET_U_LONG(buf) ((u_long)IXDR_GET_LONG(buf)) -#define IXDR_GET_SHORT(buf) ((short)IXDR_GET_LONG(buf)) -#define IXDR_GET_U_SHORT(buf) ((u_short)IXDR_GET_LONG(buf)) - -#define IXDR_PUT_BOOL(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) -#define IXDR_PUT_ENUM(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) -#define IXDR_PUT_U_LONG(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) -#define IXDR_PUT_SHORT(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) -#define IXDR_PUT_U_SHORT(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) - -/* - * These are the "generic" xdr routines. - */ -__BEGIN_DECLS -extern bool_t xdr_void(void); -extern bool_t xdr_int(XDR *, int *); -extern bool_t xdr_u_int(XDR *, u_int *); -extern bool_t xdr_long(XDR *, long *); -extern bool_t xdr_u_long(XDR *, u_long *); -extern bool_t xdr_short(XDR *, short *); -extern bool_t xdr_u_short(XDR *, u_short *); -extern bool_t xdr_int16_t(XDR *, int16_t *); -extern bool_t xdr_u_int16_t(XDR *, u_int16_t *); -extern bool_t xdr_int32_t(XDR *, int32_t *); -extern bool_t xdr_u_int32_t(XDR *, u_int32_t *); -extern bool_t xdr_int64_t(XDR *, int64_t *); -extern bool_t xdr_u_int64_t(XDR *, u_int64_t *); -extern bool_t xdr_bool(XDR *, bool_t *); -extern bool_t xdr_enum(XDR *, enum_t *); -extern bool_t xdr_array(XDR *, char **, u_int *, u_int, u_int, xdrproc_t); -extern bool_t xdr_bytes(XDR *, char **, u_int *, u_int); -extern bool_t xdr_opaque(XDR *, caddr_t, u_int); -extern bool_t xdr_string(XDR *, char **, u_int); -extern bool_t xdr_union(XDR *, enum_t *, char *, const struct xdr_discrim *, xdrproc_t); -extern unsigned long xdr_sizeof (xdrproc_t, void *); -extern bool_t xdr_char(XDR *, char *); -extern bool_t xdr_u_char(XDR *, u_char *); -extern bool_t xdr_vector(XDR *, char *, u_int, u_int, xdrproc_t); -extern bool_t xdr_float(XDR *, float *); -extern bool_t xdr_double(XDR *, double *); -extern bool_t xdr_reference(XDR *, caddr_t *, u_int, xdrproc_t); -extern bool_t xdr_pointer(XDR *, caddr_t *, u_int, xdrproc_t); -extern bool_t xdr_wrapstring(XDR *, char **); -extern void xdr_free(xdrproc_t, char *); -__END_DECLS - -/* - * Common opaque bytes objects used by many rpc protocols; - * declared here due to commonality. - */ -#define MAX_NETOBJ_SZ 1024 -struct netobj { - u_int n_len; - char *n_bytes; -}; -typedef struct netobj netobj; -extern bool_t xdr_netobj(XDR *, struct netobj *); - -/* - * These are the public routines for the various implementations of - * xdr streams. - */ -__BEGIN_DECLS -/* XDR using memory buffers */ -extern void xdrmem_create(XDR *, char *, u_int, enum xdr_op); - -/* XDR using stdio library */ -#ifdef _STDIO_H_ -extern void xdrstdio_create(XDR *, FILE *, enum xdr_op); -#endif - -/* XDR pseudo records for tcp */ -extern void xdrrec_create(XDR *, u_int, u_int, char *, - int (*) (caddr_t, caddr_t, int), - int (*) (caddr_t, caddr_t, int)); - -/* make end of xdr record */ -extern bool_t xdrrec_endofrecord(XDR *, bool_t); - -/* move to beginning of next record */ -extern bool_t xdrrec_skiprecord(XDR *); - -/* true if no more input */ -extern bool_t xdrrec_eof(XDR *); -__END_DECLS - -#endif /* !_RPC_XDR_H */ diff --git a/cpukit/librpc/preinstall.am b/cpukit/librpc/preinstall.am deleted file mode 100644 index 9dd5969507..0000000000 --- a/cpukit/librpc/preinstall.am +++ /dev/null @@ -1,89 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -if LIBRPC -$(PROJECT_INCLUDE)/rpc/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rpc - @: > $(PROJECT_INCLUDE)/rpc/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rpc/$(dirstamp) - -$(PROJECT_INCLUDE)/rpc/auth.h: include/rpc/auth.h $(PROJECT_INCLUDE)/rpc/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rpc/auth.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rpc/auth.h - -$(PROJECT_INCLUDE)/rpc/auth_unix.h: include/rpc/auth_unix.h $(PROJECT_INCLUDE)/rpc/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rpc/auth_unix.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rpc/auth_unix.h - -$(PROJECT_INCLUDE)/rpc/clnt.h: include/rpc/clnt.h $(PROJECT_INCLUDE)/rpc/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rpc/clnt.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rpc/clnt.h - -$(PROJECT_INCLUDE)/rpc/clnt_stat.h: include/rpc/clnt_stat.h $(PROJECT_INCLUDE)/rpc/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rpc/clnt_stat.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rpc/clnt_stat.h - -$(PROJECT_INCLUDE)/rpc/clnt_soc.h: include/rpc/clnt_soc.h $(PROJECT_INCLUDE)/rpc/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rpc/clnt_soc.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rpc/clnt_soc.h - -$(PROJECT_INCLUDE)/rpc/svc.h: include/rpc/svc.h $(PROJECT_INCLUDE)/rpc/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rpc/svc.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rpc/svc.h - -$(PROJECT_INCLUDE)/rpc/svc_auth.h: include/rpc/svc_auth.h $(PROJECT_INCLUDE)/rpc/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rpc/svc_auth.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rpc/svc_auth.h - -$(PROJECT_INCLUDE)/rpc/svc_soc.h: include/rpc/svc_soc.h $(PROJECT_INCLUDE)/rpc/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rpc/svc_soc.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rpc/svc_soc.h - -$(PROJECT_INCLUDE)/rpc/pmap_clnt.h: include/rpc/pmap_clnt.h $(PROJECT_INCLUDE)/rpc/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rpc/pmap_clnt.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rpc/pmap_clnt.h - -$(PROJECT_INCLUDE)/rpc/pmap_prot.h: include/rpc/pmap_prot.h $(PROJECT_INCLUDE)/rpc/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rpc/pmap_prot.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rpc/pmap_prot.h - -$(PROJECT_INCLUDE)/rpc/pmap_rmt.h: include/rpc/pmap_rmt.h $(PROJECT_INCLUDE)/rpc/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rpc/pmap_rmt.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rpc/pmap_rmt.h - -$(PROJECT_INCLUDE)/rpc/rpc.h: include/rpc/rpc.h $(PROJECT_INCLUDE)/rpc/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rpc/rpc.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rpc/rpc.h - -$(PROJECT_INCLUDE)/rpc/types.h: include/rpc/types.h $(PROJECT_INCLUDE)/rpc/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rpc/types.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rpc/types.h - -$(PROJECT_INCLUDE)/rpc/xdr.h: include/rpc/xdr.h $(PROJECT_INCLUDE)/rpc/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rpc/xdr.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rpc/xdr.h - -$(PROJECT_INCLUDE)/rpc/rpc_com.h: include/rpc/rpc_com.h $(PROJECT_INCLUDE)/rpc/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rpc/rpc_com.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rpc/rpc_com.h - -$(PROJECT_INCLUDE)/rpc/rpc_msg.h: include/rpc/rpc_msg.h $(PROJECT_INCLUDE)/rpc/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rpc/rpc_msg.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rpc/rpc_msg.h - -$(PROJECT_INCLUDE)/rpc/rpcent.h: include/rpc/rpcent.h $(PROJECT_INCLUDE)/rpc/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rpc/rpcent.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rpc/rpcent.h -endif diff --git a/cpukit/libstdthreads/Makefile.am b/cpukit/libstdthreads/Makefile.am index b6b9138063..7d6192724d 100644 --- a/cpukit/libstdthreads/Makefile.am +++ b/cpukit/libstdthreads/Makefile.am @@ -1,7 +1,5 @@ include $(top_srcdir)/automake/compile.am -include_HEADERS = - noinst_LIBRARIES = libstdthreads.a libstdthreads_a_CFLAGS = -std=c11 diff --git a/cpukit/mghttpd/Makefile.am b/cpukit/mghttpd/Makefile.am index bb5f84ba16..c3e605c679 100644 --- a/cpukit/mghttpd/Makefile.am +++ b/cpukit/mghttpd/Makefile.am @@ -2,17 +2,18 @@ include $(top_srcdir)/automake/compile.am if LIBNETWORKING if HAS_PTHREADS -include_mghttpddir = $(includedir)/mghttpd - project_lib_LIBRARIES = libmghttpd.a + +$(PROJECT_LIB)/libmghttpd.a: libmghttpd.a + $(INSTALL_DATA) $< $(PROJECT_LIB)/libmghttpd.a +TMPINSTALL_FILES = $(PROJECT_LIB)/libmghttpd.a + libmghttpd_a_CPPFLAGS = $(AM_CPPFLAGS) # libmghttpd_a_CPPFLAGS += -DHAVE_MD5 libmghttpd_a_CPPFLAGS += -DNO_SSL -DNO_POPEN -DNO_CGI -DUSE_WEBSOCKET libmghttpd_a_SOURCES = mongoose.c mongoose.h -include_mghttpd_HEADERS = mongoose.h endif endif -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am diff --git a/cpukit/mghttpd/mongoose.h b/cpukit/mghttpd/mongoose.h deleted file mode 100644 index 330ed6701b..0000000000 --- a/cpukit/mghttpd/mongoose.h +++ /dev/null @@ -1,390 +0,0 @@ -// Copyright (c) 2004-2012 Sergey Lyubka -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#ifndef MONGOOSE_HEADER_INCLUDED -#define MONGOOSE_HEADER_INCLUDED - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus - -struct mg_context; // Handle for the HTTP service itself -struct mg_connection; // Handle for the individual connection - - -// This structure contains information about the HTTP request. -struct mg_request_info { - const char *request_method; // "GET", "POST", etc - const char *uri; // URL-decoded URI - const char *http_version; // E.g. "1.0", "1.1" - const char *query_string; // URL part after '?', not including '?', or NULL - const char *remote_user; // Authenticated user, or NULL if no auth used - long remote_ip; // Client's IP address - int remote_port; // Client's port - int is_ssl; // 1 if SSL-ed, 0 if not - void *user_data; // User data pointer passed to mg_start() - void *conn_data; // Connection-specific user data - - int num_headers; // Number of HTTP headers - struct mg_header { - const char *name; // HTTP header name - const char *value; // HTTP header value - } http_headers[64]; // Maximum 64 headers -}; - - -// This structure needs to be passed to mg_start(), to let mongoose know -// which callbacks to invoke. For detailed description, see -// https://github.com/valenok/mongoose/blob/master/UserManual.md -struct mg_callbacks { - // Called when mongoose has received new HTTP request. - // If callback returns non-zero, - // callback must process the request by sending valid HTTP headers and body, - // and mongoose will not do any further processing. - // If callback returns 0, mongoose processes the request itself. In this case, - // callback must not send any data to the client. - int (*begin_request)(struct mg_connection *); - - // Called when mongoose has finished processing request. - void (*end_request)(const struct mg_connection *, int reply_status_code); - - // Called when mongoose is about to log a message. If callback returns - // non-zero, mongoose does not log anything. - int (*log_message)(const struct mg_connection *, const char *message); - - // Called when mongoose initializes SSL library. - int (*init_ssl)(void *ssl_context, void *user_data); - - // Called when websocket request is received, before websocket handshake. - // If callback returns 0, mongoose proceeds with handshake, otherwise - // cinnection is closed immediately. - int (*websocket_connect)(const struct mg_connection *); - - // Called when websocket handshake is successfully completed, and - // connection is ready for data exchange. - void (*websocket_ready)(struct mg_connection *); - - // Called when data frame has been received from the client. - // Parameters: - // bits: first byte of the websocket frame, see websocket RFC at - // http://tools.ietf.org/html/rfc6455, section 5.2 - // data, data_len: payload, with mask (if any) already applied. - // Return value: - // non-0: keep this websocket connection opened. - // 0: close this websocket connection. - int (*websocket_data)(struct mg_connection *, int bits, - char *data, size_t data_len); - - // Called when mongoose tries to open a file. Used to intercept file open - // calls, and serve file data from memory instead. - // Parameters: - // path: Full path to the file to open. - // data_len: Placeholder for the file size, if file is served from memory. - // Return value: - // NULL: do not serve file from memory, proceed with normal file open. - // non-NULL: pointer to the file contents in memory. data_len must be - // initilized with the size of the memory block. - const char * (*open_file)(const struct mg_connection *, - const char *path, size_t *data_len); - - // Called when mongoose is about to serve Lua server page (.lp file), if - // Lua support is enabled. - // Parameters: - // lua_context: "lua_State *" pointer. - void (*init_lua)(struct mg_connection *, void *lua_context); - - // Called when mongoose has uploaded a file to a temporary directory as a - // result of mg_upload() call. - // Parameters: - // file_file: full path name to the uploaded file. - void (*upload)(struct mg_connection *, const char *file_name); - - // Called when mongoose is about to send HTTP error to the client. - // Implementing this callback allows to create custom error pages. - // Parameters: - // status: HTTP error status code. - int (*http_error)(struct mg_connection *, int status); -}; - -// Start web server. -// -// Parameters: -// callbacks: mg_callbacks structure with user-defined callbacks. -// options: NULL terminated list of option_name, option_value pairs that -// specify Mongoose configuration parameters. -// -// Side-effects: on UNIX, ignores SIGCHLD and SIGPIPE signals. If custom -// processing is required for these, signal handlers must be set up -// after calling mg_start(). -// -// -// Example: -// const char *options[] = { -// "document_root", "/var/www", -// "listening_ports", "80,443s", -// NULL -// }; -// struct mg_context *ctx = mg_start(&my_func, NULL, options); -// -// Refer to https://github.com/valenok/mongoose/blob/master/UserManual.md -// for the list of valid option and their possible values. -// -// Return: -// web server context, or NULL on error. -struct mg_context *mg_start(const struct mg_callbacks *callbacks, - void *user_data, - const char **configuration_options); - - -// Stop the web server. -// -// Must be called last, when an application wants to stop the web server and -// release all associated resources. This function blocks until all Mongoose -// threads are stopped. Context pointer becomes invalid. -void mg_stop(struct mg_context *); - - -// Get the value of particular configuration parameter. -// The value returned is read-only. Mongoose does not allow changing -// configuration at run time. -// If given parameter name is not valid, NULL is returned. For valid -// names, return value is guaranteed to be non-NULL. If parameter is not -// set, zero-length string is returned. -const char *mg_get_option(const struct mg_context *ctx, const char *name); - - -// Return array of strings that represent valid configuration options. -// For each option, option name and default value is returned, i.e. the -// number of entries in the array equals to number_of_options x 2. -// Array is NULL terminated. -const char **mg_get_valid_option_names(void); - - -// Add, edit or delete the entry in the passwords file. -// -// This function allows an application to manipulate .htpasswd files on the -// fly by adding, deleting and changing user records. This is one of the -// several ways of implementing authentication on the server side. For another, -// cookie-based way please refer to the examples/chat.c in the source tree. -// -// If password is not NULL, entry is added (or modified if already exists). -// If password is NULL, entry is deleted. -// -// Return: -// 1 on success, 0 on error. -int mg_modify_passwords_file(const char *passwords_file_name, - const char *domain, - const char *user, - const char *password); - - -// Return information associated with the request. -struct mg_request_info *mg_get_request_info(struct mg_connection *); - - -// Send data to the client. -// Return: -// 0 when the connection has been closed -// -1 on error -// >0 number of bytes written on success -int mg_write(struct mg_connection *, const void *buf, size_t len); - - -// Send data to a websocket client wrapped in a websocket frame. -// It is unsafe to read/write to this connection from another thread. -// This function is available when mongoose is compiled with -DUSE_WEBSOCKET -// -// Return: -// 0 when the connection has been closed -// -1 on error -// >0 number of bytes written on success -int mg_websocket_write(struct mg_connection* conn, int opcode, - const char *data, size_t data_len); - -// Opcodes, from http://tools.ietf.org/html/rfc6455 -enum { - WEBSOCKET_OPCODE_CONTINUATION = 0x0, - WEBSOCKET_OPCODE_TEXT = 0x1, - WEBSOCKET_OPCODE_BINARY = 0x2, - WEBSOCKET_OPCODE_CONNECTION_CLOSE = 0x8, - WEBSOCKET_OPCODE_PING = 0x9, - WEBSOCKET_OPCODE_PONG = 0xa -}; - - -// Macros for enabling compiler-specific checks for printf-like arguments. -#undef PRINTF_FORMAT_STRING -#if defined(_MSC_VER) && _MSC_VER >= 1400 -#include -#if defined(_MSC_VER) && _MSC_VER > 1400 -#define PRINTF_FORMAT_STRING(s) _Printf_format_string_ s -#else -#define PRINTF_FORMAT_STRING(s) __format_string s -#endif -#else -#define PRINTF_FORMAT_STRING(s) s -#endif - -#ifdef __GNUC__ -#define PRINTF_ARGS(x, y) __attribute__((format(printf, x, y))) -#else -#define PRINTF_ARGS(x, y) -#endif - -// Send data to the client using printf() semantics. -// -// Works exactly like mg_write(), but allows to do message formatting. -int mg_printf(struct mg_connection *, - PRINTF_FORMAT_STRING(const char *fmt), ...) PRINTF_ARGS(2, 3); -#ifdef __rtems__ -struct rtems_printer; -void rtems_print_printer_mg_printf(struct rtems_printer *, struct mg_connection *); -#endif /* __rtems__ */ - - -// Send contents of the entire file together with HTTP headers. -void mg_send_file(struct mg_connection *conn, const char *path); - - -// Read data from the remote end, return number of bytes read. -// Return: -// 0 connection has been closed by peer. No more data could be read. -// < 0 read error. No more data could be read from the connection. -// > 0 number of bytes read into the buffer. -int mg_read(struct mg_connection *, void *buf, size_t len); - - -// Get the value of particular HTTP header. -// -// This is a helper function. It traverses request_info->http_headers array, -// and if the header is present in the array, returns its value. If it is -// not present, NULL is returned. -const char *mg_get_header(const struct mg_connection *, const char *name); - - -// Get a value of particular form variable. -// -// Parameters: -// data: pointer to form-uri-encoded buffer. This could be either POST data, -// or request_info.query_string. -// data_len: length of the encoded data. -// var_name: variable name to decode from the buffer -// dst: destination buffer for the decoded variable -// dst_len: length of the destination buffer -// -// Return: -// On success, length of the decoded variable. -// On error: -// -1 (variable not found). -// -2 (destination buffer is NULL, zero length or too small to hold the -// decoded variable). -// -// Destination buffer is guaranteed to be '\0' - terminated if it is not -// NULL or zero length. -int mg_get_var(const char *data, size_t data_len, - const char *var_name, char *dst, size_t dst_len); - -// Fetch value of certain cookie variable into the destination buffer. -// -// Destination buffer is guaranteed to be '\0' - terminated. In case of -// failure, dst[0] == '\0'. Note that RFC allows many occurrences of the same -// parameter. This function returns only first occurrence. -// -// Return: -// On success, value length. -// On error: -// -1 (either "Cookie:" header is not present at all or the requested -// parameter is not found). -// -2 (destination buffer is NULL, zero length or too small to hold the -// value). -int mg_get_cookie(const char *cookie, const char *var_name, - char *buf, size_t buf_len); - - -// Download data from the remote web server. -// host: host name to connect to, e.g. "foo.com", or "10.12.40.1". -// port: port number, e.g. 80. -// use_ssl: wether to use SSL connection. -// error_buffer, error_buffer_size: error message placeholder. -// request_fmt,...: HTTP request. -// Return: -// On success, valid pointer to the new connection, suitable for mg_read(). -// On error, NULL. error_buffer contains error message. -// Example: -// char ebuf[100]; -// struct mg_connection *conn; -// conn = mg_download("google.com", 80, 0, ebuf, sizeof(ebuf), -// "%s", "GET / HTTP/1.0\r\nHost: google.com\r\n\r\n"); -struct mg_connection *mg_download(const char *host, int port, int use_ssl, - char *error_buffer, size_t error_buffer_size, - PRINTF_FORMAT_STRING(const char *request_fmt), - ...) PRINTF_ARGS(6, 7); - - -// Close the connection opened by mg_download(). -void mg_close_connection(struct mg_connection *conn); - - -// File upload functionality. Each uploaded file gets saved into a temporary -// file and MG_UPLOAD event is sent. -// Return number of uploaded files. -int mg_upload(struct mg_connection *conn, const char *destination_dir); - - -// Convenience function -- create detached thread. -// Return: 0 on success, non-0 on error. -typedef void * (*mg_thread_func_t)(void *); -int mg_start_thread(mg_thread_func_t f, void *p); - - -// Return builtin mime type for the given file name. -// For unrecognized extensions, "text/plain" is returned. -const char *mg_get_builtin_mime_type(const char *file_name); - - -// Return Mongoose version. -const char *mg_version(void); - -// URL-decode input buffer into destination buffer. -// 0-terminate the destination buffer. -// form-url-encoded data differs from URI encoding in a way that it -// uses '+' as character for space, see RFC 1866 section 8.2.1 -// http://ftp.ics.uci.edu/pub/ietf/html/rfc1866.txt -// Return: length of the decoded data, or -1 if dst buffer is too small. -int mg_url_decode(const char *src, int src_len, char *dst, - int dst_len, int is_form_url_encoded); - -// MD5 hash given strings. -// Buffer 'buf' must be 33 bytes long. Varargs is a NULL terminated list of -// ASCIIz strings. When function returns, buf will contain human-readable -// MD5 hash. Example: -// char buf[33]; -// mg_md5(buf, "aa", "bb", NULL); -char *mg_md5(char buf[33], ...); - - -#ifdef __cplusplus -} -#endif // __cplusplus - -#endif // MONGOOSE_HEADER_INCLUDED diff --git a/cpukit/mghttpd/preinstall.am b/cpukit/mghttpd/preinstall.am deleted file mode 100644 index b63c98898c..0000000000 --- a/cpukit/mghttpd/preinstall.am +++ /dev/null @@ -1,41 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -all-local: $(TMPINSTALL_FILES) - -TMPINSTALL_FILES = -CLEANFILES += $(TMPINSTALL_FILES) - -$(PROJECT_LIB)/$(dirstamp): - @$(MKDIR_P) $(PROJECT_LIB) - @: > $(PROJECT_LIB)/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_LIB)/$(dirstamp) - -if LIBNETWORKING -if HAS_PTHREADS -$(PROJECT_INCLUDE)/mghttpd/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/mghttpd - @: > $(PROJECT_INCLUDE)/mghttpd/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/mghttpd/$(dirstamp) - -$(PROJECT_LIB)/libmghttpd.a: libmghttpd.a $(PROJECT_LIB)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_LIB)/libmghttpd.a -TMPINSTALL_FILES += $(PROJECT_LIB)/libmghttpd.a - -$(PROJECT_INCLUDE)/mghttpd/mongoose.h: mongoose.h $(PROJECT_INCLUDE)/mghttpd/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/mghttpd/mongoose.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/mghttpd/mongoose.h -endif -endif diff --git a/cpukit/posix/Makefile.am b/cpukit/posix/Makefile.am index 351dc714f8..1c127e1ae2 100644 --- a/cpukit/posix/Makefile.am +++ b/cpukit/posix/Makefile.am @@ -11,46 +11,10 @@ libposix_a_SOURCES = libposix_a_SOURCES += src/nanosleep.c src/clockgettime.c src/clocksettime.c \ src/clockgetres.c src/sysconf.c -include_rtems_posixdir = $(includedir)/rtems/posix - -include_rtems_posix_HEADERS = include/rtems/posix/sigset.h - ## Some POSIX threads features are needed all the time -include_rtems_posix_HEADERS += include/rtems/posix/barrierimpl.h -include_rtems_posix_HEADERS += include/rtems/posix/condimpl.h -include_rtems_posix_HEADERS += include/rtems/posix/key.h -include_rtems_posix_HEADERS += include/rtems/posix/keyimpl.h -include_rtems_posix_HEADERS += include/rtems/posix/config.h -include_rtems_posix_HEADERS += include/rtems/posix/muteximpl.h -include_rtems_posix_HEADERS += include/rtems/posix/posixapi.h -include_rtems_posix_HEADERS += include/rtems/posix/priorityimpl.h -include_rtems_posix_HEADERS += include/rtems/posix/pthreadattrimpl.h -include_rtems_posix_HEADERS += include/rtems/posix/rwlockimpl.h -include_rtems_posix_HEADERS += include/rtems/posix/semaphore.h -include_rtems_posix_HEADERS += include/rtems/posix/semaphoreimpl.h -include_rtems_posix_HEADERS += include/rtems/posix/spinlockimpl.h - if HAS_PTHREADS # include -include_HEADERS = include/aio.h -include_HEADERS += include/mqueue.h - # include/rtems/posix -include_rtems_posix_HEADERS += include/rtems/posix/aio_misc.h -include_rtems_posix_HEADERS += include/rtems/posix/mmanimpl.h -include_rtems_posix_HEADERS += include/rtems/posix/mqueue.h -include_rtems_posix_HEADERS += include/rtems/posix/mqueueimpl.h -include_rtems_posix_HEADERS += include/rtems/posix/psignal.h -include_rtems_posix_HEADERS += include/rtems/posix/psignalimpl.h -include_rtems_posix_HEADERS += include/rtems/posix/pthread.h -include_rtems_posix_HEADERS += include/rtems/posix/pthreadimpl.h -include_rtems_posix_HEADERS += include/rtems/posix/ptimer.h -include_rtems_posix_HEADERS += include/rtems/posix/shm.h -include_rtems_posix_HEADERS += include/rtems/posix/shmimpl.h -include_rtems_posix_HEADERS += include/rtems/posix/threadsup.h -include_rtems_posix_HEADERS += include/rtems/posix/timer.h -include_rtems_posix_HEADERS += include/rtems/posix/timerimpl.h - ## src libposix_a_SOURCES += src/aio_cancel.c src/aio_error.c src/aio_fsync.c \ src/aio_read.c src/aio_return.c src/aio_suspend.c src/aio_write.c \ @@ -236,5 +200,4 @@ endif libposix_a_SOURCES += src/sched_getprioritymin.c libposix_a_SOURCES += src/sched_getprioritymax.c -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am diff --git a/cpukit/posix/include/aio.h b/cpukit/posix/include/aio.h deleted file mode 100644 index 95ed0fdb6c..0000000000 --- a/cpukit/posix/include/aio.h +++ /dev/null @@ -1,193 +0,0 @@ -/** - * @file - * - * @brief POSIX Asynchronous Input and Output - * - * This file contains the definitions related to POSIX Asynchronous - * Input and Output, - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _AIO_H -#define _AIO_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup POSIX_AIO POSIX Asynchronous I/O Support - * - * @ingroup POSIXAPI - * - * @brief POSIX Asynchronous Input and Output - * - */ -/**@{**/ - -#if defined(_POSIX_ASYNCHRONOUS_IO) - -/* - * 6.7.1 Data Definitions for Asynchronous Input and Output, - * P1003.1b-1993, p. 151 - */ - -#include -#include -#include -#include - -/* - * 6.7.1.2 Manifest Constants, P1003.1b-1993, p. 153 - */ - -#define AIO_CANCELED 0 /* all requested operations have been canceled */ -#define AIO_NOTCANCELED 1 /* some of the operations could not be canceled */ - /* since they are in progress */ -#define AIO_ALLDONE 2 /* none of the requested operations could be */ - /* canceled since they are already complete */ - -/* lio_listio() options */ - -/* - * LIO modes - */ -#define LIO_WAIT 0 /* calling process is to suspend until the */ - /* operation is complete */ -#define LIO_NOWAIT 1 /* calling process is to continue execution while */ - /* the operation is performed and no notification */ - /* shall be given when the operation is completed */ - -/* - * LIO opcodes - */ -#define LIO_NOP 0 /* no transfer is requested */ -#define LIO_READ 1 /* request a read() */ -#define LIO_WRITE 2 /* request a write() */ -#define LIO_SYNC 3 /* needed by aio_fsync() */ - -/* - * 6.7.1.1 Asynchronous I/O Control Block, P1003.1b-1993, p. 151 - */ - -struct aiocb { - /* public */ - int aio_fildes; /* File descriptor */ - off_t aio_offset; /* File offset */ - volatile void *aio_buf; /* Location of buffer */ - size_t aio_nbytes; /* Length of transfer */ - int aio_reqprio; /* Request priority offset */ - struct sigevent aio_sigevent; /* Signal number and value */ - int aio_lio_opcode; /* Operation to be performed */ - /* private */ - int error_code; /* Used for aio_error() */ - ssize_t return_value; /* Used for aio_return() */ -}; - -/* - * 6.7.2 Asynchronous Read, P1003.1b-1993, p. 154 - */ - -int aio_read( - struct aiocb *aiocbp -); - -/* - * 6.7.3 Asynchronous Write, P1003.1b-1993, p. 155 - */ - -int aio_write( - struct aiocb *aiocbp -); - -/* - * 6.7.4 List Directed I/O, P1003.1b-1993, p. 158 - */ - -int lio_listio( - int mode, - struct aiocb *__restrict const list[__restrict], - int nent, - struct sigevent *__restrict sig -); - -/* - * 6.7.5 Retrieve Error of Asynchronous I/O Operation, P1003.1b-1993, p. 161 - */ - -int aio_error( - const struct aiocb *aiocbp -); - -/* - * 6.7.6 Retrieve Return Status of Asynchronous I/O Operation, - * P1003.1b-1993, p. 162 - */ - -ssize_t aio_return( - const struct aiocb *aiocbp -); - -/** - * @brief Cancel asynchronous I/O operation. - * - * 6.7.7 Cancel Asynchronous I/O Operation, P1003.1b-1993, p. 163 - * - * @param[in] filedes is the file descriptor - * @param[in] aiocbp is a pointer to the asynchronous I/O control block - * - * @retval AIO_CANCELED The requested operation(s) were canceled. - * @retval AIO_NOTCANCELED Some of the requested operation(s) cannot be - * canceled since they are in progress. - * @retval AIO_ALLDONE None of the requested operation(s) could be canceled - * since they are already complete - */ -int aio_cancel( - int filedes, - struct aiocb *aiocbp -); - -/* - * 6.7.7 Wait for Asynchronous I/O Request, P1003.1b-1993, p. 164 - */ - -int aio_suspend( - const struct aiocb * const list[], - int nent, - const struct timespec *timeout -); - -#if defined(_POSIX_SYNCHRONIZED_IO) - -/* - * 6.7.9 Asynchronous File Synchronization, P1003.1b-1993, p. 166 - */ - -int aio_fsync( - int op, - struct aiocb *aiocbp -); - -#endif /* _POSIX_SYNCHRONIZED_IO */ - -#endif /* _POSIX_ASYNCHRONOUS_IO */ - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/posix/include/mqueue.h b/cpukit/posix/include/mqueue.h deleted file mode 100644 index 36733a4730..0000000000 --- a/cpukit/posix/include/mqueue.h +++ /dev/null @@ -1,218 +0,0 @@ -/** - * @file - * - * @brief POSIX Message Queues - * - * This file contains the definitions related to POSIX Message Queues. - * - * The structure of the routines is identical to that of POSIX - * Message_queues to leave the option of having unnamed message - * queues at a future date. They are currently not part of the - * POSIX standard but unnamed message_queues are. This is also - * the reason for the apparently unnecessary tracking of - * the process_shared attribute. [In addition to the fact that - * it would be trivial to add pshared to the mq_attr structure - * and have process private message queues.] - * - * This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open - * time. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _MQUEUE_H -#define _MQUEUE_H - - -#include - -#if defined(_POSIX_MESSAGE_PASSING) - -#include - -#include -#include - -/** - * @defgroup POSIX_MQUEUE POSIX Message Queues - * - * @ingroup POSIXAPI - * - */ -/**@{**/ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * 15.1.1 Data Structures, P1003.1b-1993, p. 271 - */ - -/** - * Message queue id type. - * - * NOTE: Use uint32_t since all POSIX Ids are 32-bit currently. - */ -typedef uint32_t mqd_t; - -/** - * This is the message queue attributes structure. - */ -struct mq_attr { - /** This is the message queue flags */ - long mq_flags; - /** This is the maximum number of messages */ - long mq_maxmsg; - /** This is the maximum message size */ - long mq_msgsize; - /** This is the mumber of messages currently queued */ - long mq_curmsgs; -}; - -/** - * 15.2.2 Open a Message Queue, P1003.1b-1993, p. 272 - */ -mqd_t mq_open( - const char *name, - int oflag, - ... -); - -/** - * 15.2.2 Close a Message Queue, P1003.1b-1993, p. 275 - */ -int mq_close( - mqd_t mqdes -); - -/** - * @brief Remove a message queue. - * - * 15.2.2 Remove a Message Queue, P1003.1b-1993, p. 276 - * - * NOTE: The structure of the routines is identical to that of POSIX - * Message_queues to leave the option of having unnamed message - * queues at a future date. They are currently not part of the - * POSIX standard but unnamed message_queues are. This is also - * the reason for the apparently unnecessary tracking of - * the process_shared attribute. [In addition to the fact that - * it would be trivial to add pshared to the mq_attr structure - * and have process private message queues.] - * - * This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open - * time. - */ -int mq_unlink( - const char *name -); - -/** - * 15.2.4 Send a Message to a Message Queue, P1003.1b-1993, p. 277 - * - * NOTE; P1003.4b/D8, p. 45 adds mq_timedsend(). - */ -int mq_send( - mqd_t mqdes, - const char *msg_ptr, - size_t msg_len, - unsigned int msg_prio -); - -#if defined(_POSIX_TIMEOUTS) - -#include - -/** - * @brief Send a message to a message queue. - * - * @see mq_send() - */ -int mq_timedsend( - mqd_t mqdes, - const char *msg_ptr, - size_t msg_len, - unsigned int msg_prio, - const struct timespec *abstime -); - -#endif /* _POSIX_TIMEOUTS */ - -/** - * @brief Receive a message from a message queue. - * - * 15.2.5 Receive a Message From a Message Queue, P1003.1b-1993, p. 279 - * - * NOTE: P1003.4b/D8, p. 45 adds mq_timedreceive(). - */ -ssize_t mq_receive( - mqd_t mqdes, - char *msg_ptr, - size_t msg_len, - unsigned int *msg_prio -); - -#if defined(_POSIX_TIMEOUTS) - -ssize_t mq_timedreceive( - mqd_t mqdes, - char *__restrict msg_ptr, - size_t msg_len, - unsigned int *__restrict msg_prio, - const struct timespec *__restrict abstime -); - -#endif /* _POSIX_TIMEOUTS */ - -#if defined(_POSIX_REALTIME_SIGNALS) - -/** - * @brief Notify process that a message is available on a queue. - * - * 15.2.6 Notify Process that a Message is Available on a Queue, - * P1003.1b-1993, p. 280 - */ -int mq_notify( - mqd_t mqdes, - const struct sigevent *notification -); - -#endif /* _POSIX_REALTIME_SIGNALS */ - -/** - * @brief Set message queue attributes. - * - * 15.2.7 Set Message Queue Attributes, P1003.1b-1993, p. 281 - */ -int mq_setattr( - mqd_t mqdes, - const struct mq_attr *__restrict mqstat, - struct mq_attr *__restrict omqstat -); - -/* - * 15.2.8 Get Message Queue Attributes, P1003.1b-1993, p. 283 - */ - -int mq_getattr( - mqd_t mqdes, - struct mq_attr *mqstat -); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* _POSIX_MESSAGE_PASSING */ - -#endif -/* end of include file */ diff --git a/cpukit/posix/include/rtems/posix/aio_misc.h b/cpukit/posix/include/rtems/posix/aio_misc.h deleted file mode 100644 index aeccbad98f..0000000000 --- a/cpukit/posix/include/rtems/posix/aio_misc.h +++ /dev/null @@ -1,113 +0,0 @@ -/** - * @file - * - * @brief POSIX Asynchronous Input and Output Private Support - * - * This defines private information for the AIO implementation. - */ - -/* - * Copyright 2010, Alin Rus - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _AIO_MISC_H -#define _AIO_MISC_H - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - - /* Actual request being processed */ - typedef struct - { - rtems_chain_node next_prio; /* chain requests in order of priority */ - int policy; /* If _POSIX_PRIORITIZED_IO and - _POSIX_PRIORITY_SCHEDULING are defined */ - int priority; /* see above */ - pthread_t caller_thread; /* used for notification */ - struct aiocb *aiocbp; /* aio control block */ - } rtems_aio_request; - - typedef struct - { - rtems_chain_node next_fd; /* order fd chains in queue */ - rtems_chain_control perfd; /* chain of requests for this fd */ - int fildes; /* file descriptor to be processed */ - int new_fd; /* if this is a newly created chain */ - pthread_mutex_t mutex; - pthread_cond_t cond; - - } rtems_aio_request_chain; - - typedef struct - { - pthread_mutex_t mutex; - pthread_cond_t new_req; - pthread_attr_t attr; - - rtems_chain_control work_req; /* chains being worked by active threads */ - rtems_chain_control idle_req; /* fd chains waiting to be processed */ - unsigned int initialized; /* specific value if queue is initialized */ - int active_threads; /* the number of active threads */ - int idle_threads; /* number of idle threads */ - - } rtems_aio_queue; - -extern rtems_aio_queue aio_request_queue; - -#define AIO_QUEUE_INITIALIZED 0xB00B - -#ifndef AIO_MAX_THREADS -#define AIO_MAX_THREADS 5 -#endif - -#ifndef AIO_MAX_QUEUE_SIZE -#define AIO_MAX_QUEUE_SIZE 30 -#endif - -int rtems_aio_init (void); -int rtems_aio_enqueue (rtems_aio_request *req); -rtems_aio_request_chain *rtems_aio_search_fd -( - rtems_chain_control *chain, - int fildes, - int create -); -void rtems_aio_remove_fd (rtems_aio_request_chain *r_chain); -int rtems_aio_remove_req (rtems_chain_control *chain, - struct aiocb *aiocbp); - -#ifdef RTEMS_DEBUG -#include - -#define AIO_assert(_x) assert(_x) -#define AIO_printf(_x) printf(_x) -#else -#define AIO_assert(_x) -#define AIO_printf(_x) -#endif - -#define rtems_aio_set_errno_return_minus_one( _error, _aiocbp ) \ - do { (_aiocbp)->error_code = (_error); \ - (_aiocbp)->return_value = -1; \ - rtems_set_errno_and_return_minus_one (_error);} while(0) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/posix/include/rtems/posix/barrierimpl.h b/cpukit/posix/include/rtems/posix/barrierimpl.h deleted file mode 100644 index a1794b82fd..0000000000 --- a/cpukit/posix/include/rtems/posix/barrierimpl.h +++ /dev/null @@ -1,99 +0,0 @@ -/** - * @file - * - * @brief Inlined Routines from the POSIX Barrier Manager - * - * This file contains the static inlin implementation of the inlined - * routines from the POSIX Barrier Manager. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * Copyright (c) 2017 embedded brains GmbH - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_POSIX_BARRIERIMPL_H -#define _RTEMS_POSIX_BARRIERIMPL_H - -#include -#include - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define POSIX_BARRIER_MAGIC 0x1cf03773UL - -#define POSIX_BARRIER_TQ_OPERATIONS &_Thread_queue_Operations_FIFO - -typedef struct { - unsigned long flags; - Thread_queue_Syslock_queue Queue; - unsigned int count; - unsigned int waiting_threads; -} POSIX_Barrier_Control; - -static inline POSIX_Barrier_Control *_POSIX_Barrier_Get( - pthread_barrier_t *_barrier -) -{ - return (POSIX_Barrier_Control *) _barrier; -} - -static inline Thread_Control *_POSIX_Barrier_Queue_acquire( - POSIX_Barrier_Control *barrier, - Thread_queue_Context *queue_context -) -{ - ISR_Level level; - Thread_Control *executing; - - _Thread_queue_Context_initialize( queue_context ); - _Thread_queue_Context_ISR_disable( queue_context, level ); - _Thread_queue_Context_set_ISR_level( queue_context, level ); - executing = _Thread_Executing; - _Thread_queue_Queue_acquire_critical( - &barrier->Queue.Queue, - &executing->Potpourri_stats, - &queue_context->Lock_context.Lock_context - ); - - return executing; -} - -static inline void _POSIX_Barrier_Queue_release( - POSIX_Barrier_Control *barrier, - Thread_queue_Context *queue_context -) -{ - _Thread_queue_Queue_release( - &barrier->Queue.Queue, - &queue_context->Lock_context.Lock_context - ); -} - -#define POSIX_BARRIER_VALIDATE_OBJECT( bar ) \ - do { \ - if ( \ - ( bar ) == NULL \ - || ( (uintptr_t) ( bar ) ^ POSIX_BARRIER_MAGIC ) != ( bar )->_flags \ - ) { \ - return EINVAL; \ - } \ - } while ( 0 ) - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/posix/include/rtems/posix/condimpl.h b/cpukit/posix/include/rtems/posix/condimpl.h deleted file mode 100644 index 66e09bf6d8..0000000000 --- a/cpukit/posix/include/rtems/posix/condimpl.h +++ /dev/null @@ -1,184 +0,0 @@ -/** - * @file - * - * This include file contains the static inline implementation of the private - * inlined routines for POSIX condition variables. - */ - -/* - * COPYRIGHT (c) 1989-2013. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_POSIX_CONDIMPL_H -#define _RTEMS_POSIX_CONDIMPL_H - -#include -#include - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - unsigned long flags; - Thread_queue_Syslock_queue Queue; - pthread_mutex_t *mutex; -} POSIX_Condition_variables_Control; - -#define POSIX_CONDITION_VARIABLES_CLOCK_MONOTONIC 0x1UL - -#define POSIX_CONDITION_VARIABLES_FLAGS_MASK 0x1UL - -#define POSIX_CONDITION_VARIABLES_MAGIC 0x18dfb1feUL - -/** - * Constant to indicate condition variable does not currently have - * a mutex assigned to it. - */ -#define POSIX_CONDITION_VARIABLES_NO_MUTEX NULL - -#define POSIX_CONDITION_VARIABLES_TQ_OPERATIONS &_Thread_queue_Operations_FIFO - -#define POSIX_CONDITION_VARIABLE_OF_THREAD_QUEUE_QUEUE( queue ) \ - RTEMS_CONTAINER_OF( \ - queue, POSIX_Condition_variables_Control, Queue.Queue ) - -/** - * The default condition variable attributes structure. - */ -extern const pthread_condattr_t _POSIX_Condition_variables_Default_attributes; - -static inline POSIX_Condition_variables_Control *_POSIX_Condition_variables_Get( - pthread_cond_t *cond -) -{ - return (POSIX_Condition_variables_Control *) cond; -} - -RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Initialize( - POSIX_Condition_variables_Control *the_cond, - const pthread_condattr_t *the_attr -) -{ - unsigned long flags; - - _Thread_queue_Queue_initialize( &the_cond->Queue.Queue, NULL ); - the_cond->mutex = POSIX_CONDITION_VARIABLES_NO_MUTEX; - - flags = (uintptr_t) the_cond ^ POSIX_CONDITION_VARIABLES_MAGIC; - flags &= ~POSIX_CONDITION_VARIABLES_FLAGS_MASK; - - if ( the_attr->clock == CLOCK_MONOTONIC ) { - flags |= POSIX_CONDITION_VARIABLES_CLOCK_MONOTONIC; - } - - the_cond->flags = flags; -} - -RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Destroy( - POSIX_Condition_variables_Control *the_cond -) -{ - the_cond->flags = ~the_cond->flags; -} - -RTEMS_INLINE_ROUTINE clockid_t _POSIX_Condition_variables_Get_clock( - unsigned long flags -) -{ - if ( ( flags & POSIX_CONDITION_VARIABLES_CLOCK_MONOTONIC ) != 0 ) { - return CLOCK_MONOTONIC; - } - - return CLOCK_REALTIME; -} - -RTEMS_INLINE_ROUTINE Thread_Control *_POSIX_Condition_variables_Acquire( - POSIX_Condition_variables_Control *the_cond, - Thread_queue_Context *queue_context -) -{ - ISR_Level level; - Thread_Control *executing; - - _Thread_queue_Context_ISR_disable( queue_context, level ); - _Thread_queue_Context_set_ISR_level( queue_context, level ); - executing = _Thread_Executing; - _Thread_queue_Queue_acquire_critical( - &the_cond->Queue.Queue, - &executing->Potpourri_stats, - &queue_context->Lock_context.Lock_context - ); - - return executing; -} - -RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Release( - POSIX_Condition_variables_Control *the_cond, - Thread_queue_Context *queue_context -) -{ - _Thread_queue_Queue_release( - &the_cond->Queue.Queue, - &queue_context->Lock_context.Lock_context - ); -} - -/** - * @brief Implements wake up version of the "signal" operation. - * - * A support routine which implements guts of the broadcast and single task - * wake up version of the "signal" operation. - */ -int _POSIX_Condition_variables_Signal_support( - pthread_cond_t *cond, - bool is_broadcast -); - -/** - * @brief POSIX condition variables wait support. - * - * A support routine which implements guts of the blocking, non-blocking, and - * timed wait version of condition variable wait routines. - */ -int _POSIX_Condition_variables_Wait_support( - pthread_cond_t *cond, - pthread_mutex_t *mutex, - const struct timespec *abstime -); - -bool _POSIX_Condition_variables_Auto_initialization( - POSIX_Condition_variables_Control *the_cond -); - -#define POSIX_CONDITION_VARIABLES_VALIDATE_OBJECT( the_cond, flags ) \ - do { \ - if ( ( the_cond ) == NULL ) { \ - return EINVAL; \ - } \ - flags = ( the_cond )->flags; \ - if ( \ - ( ( (uintptr_t) ( the_cond ) ^ POSIX_CONDITION_VARIABLES_MAGIC ) \ - & ~POSIX_CONDITION_VARIABLES_FLAGS_MASK ) \ - != ( flags & ~POSIX_CONDITION_VARIABLES_FLAGS_MASK ) \ - ) { \ - if ( !_POSIX_Condition_variables_Auto_initialization( the_cond ) ) { \ - return EINVAL; \ - } \ - } \ - } while ( 0 ) - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/posix/include/rtems/posix/config.h b/cpukit/posix/include/rtems/posix/config.h deleted file mode 100644 index e90dc27011..0000000000 --- a/cpukit/posix/include/rtems/posix/config.h +++ /dev/null @@ -1,120 +0,0 @@ -/** - * @file - * - * @brief User Defined Configuration Parameters Specific For The POSIX API - * - * This include file contains the table of user defined configuration - * parameters specific for the POSIX API. - */ - -/* - * COPYRIGHT (c) 1989-2014. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_POSIX_CONFIG_H -#define _RTEMS_POSIX_CONFIG_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicConfig Configuration - * - * @ingroup ClassicRTEMS - * - * This encapsulates functionality related to the application's configuration - * of the Classic API including the maximum number of each class of objects. - */ -/**@{*/ - -/** - * For now, we are only allowing the user to specify the entry point - * and stack size for POSIX initialization threads. - */ -typedef struct { - /** This is the entry point for a POSIX initialization thread. */ - void *(*thread_entry)(void *); - /** This is the stack size for a POSIX initialization thread. */ - int stack_size; -} posix_initialization_threads_table; - -/** - * The following records define the POSIX Configuration Table. - * The information contained in this table is required in all - * RTEMS systems which include POSIX threads support, whether - * single or multiprocessor. This table primarily defines the - * following: - * - * + required number of each object type - */ -typedef struct { - /** - * This field contains the maximum number of POSIX API - * threads which are configured for this application. - */ - uint32_t maximum_threads; - - /** - * This field contains the maximum number of POSIX API - * timers which are configured for this application. - */ - uint32_t maximum_timers; - - /** - * This field contains the maximum number of POSIX API - * queued signals which are configured for this application. - */ - uint32_t maximum_queued_signals; - - /** - * This field contains the maximum number of POSIX API - * message queues which are configured for this application. - */ - uint32_t maximum_message_queues; - - /** - * This field contains the maximum number of POSIX API - * semaphores which are configured for this application. - */ - uint32_t maximum_semaphores; - - /** - * Maximum configured number of POSIX Shared memory objects. - */ - uint32_t maximum_shms; - - /** - * This field contains the number of POSIX API Initialization - * threads listed in @a User_initialization_thread_table. - */ - uint32_t number_of_initialization_threads; - - /** - * This field contains the list of POSIX API Initialization threads. - */ - posix_initialization_threads_table *User_initialization_threads_table; -} posix_api_configuration_table; - -/** - * @brief POSIX API configuration table. - * - * This is the POSIX API Configuration Table expected to be generated - * by confdefs.h. - */ -extern posix_api_configuration_table Configuration_POSIX_API; - -/**@}*/ -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/posix/include/rtems/posix/key.h b/cpukit/posix/include/rtems/posix/key.h deleted file mode 100644 index 1f09916f06..0000000000 --- a/cpukit/posix/include/rtems/posix/key.h +++ /dev/null @@ -1,95 +0,0 @@ -/** - * @file - * - * @brief POSIX Key Private Support - * - * This include file contains all the private support information for - * POSIX key. - */ - -/* - * Copyright (c) 2012 Zhongwei Yao. - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * Copyright (c) 2016 embedded brains GmbH. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_POSIX_KEY_H -#define _RTEMS_POSIX_KEY_H - -#include - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup POSIX_KEY POSIX Key - * - * @ingroup POSIXAPI - * - */ -/**@{**/ - -/** - * @brief Represents POSIX key and value pair. - */ -typedef struct { - /** - * @brief The chain node for the key value pairs chain in POSIX_Keys_Control. - */ - Chain_Node Key_node; - - /** - * @brief The tree node for the lookup tree in Thread_Keys_information. - */ - RBTree_Node Lookup_node; - - /** - * @brief The POSIX key identifier used as the tree key. - */ - pthread_key_t key; - - /** - * @brief The corresponding thread. - */ - Thread_Control *thread; - - /** - * @brief The thread specific POSIX key value. - */ - void *value; -} POSIX_Keys_Key_value_pair; - -/** - * @brief The data structure used to manage a POSIX key. - */ -typedef struct { - /** This field is the Object control structure. */ - Objects_Control Object; - /** This field is the data destructor. */ - void (*destructor) (void *); - - /** - * @brief Key value pairs of this key. - */ - Chain_Control Key_value_pairs; - } POSIX_Keys_Control; - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/posix/include/rtems/posix/keyimpl.h b/cpukit/posix/include/rtems/posix/keyimpl.h deleted file mode 100644 index 1148123638..0000000000 --- a/cpukit/posix/include/rtems/posix/keyimpl.h +++ /dev/null @@ -1,177 +0,0 @@ -/** - * @file - * - * @brief Private Inlined Routines for POSIX Key's - * - * This include file contains the static inline implementation of the private - * inlined routines for POSIX key's. - */ - -/* - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). - * Copyright (c) 2016 embedded brains GmbH. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#include -#include -#include -#include -#include - -#ifndef _RTEMS_POSIX_KEYIMPL_H -#define _RTEMS_POSIX_KEYIMPL_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup POSIX_KEY - * - * @{ - */ - -/** - * @brief The information control block used to manage this class of objects. - */ -extern Objects_Information _POSIX_Keys_Information; - -/** - * @brief This freechain is used as a memory pool for POSIX_Keys_Key_value_pair. - */ -extern Freechain_Control _POSIX_Keys_Keypool; - -#define POSIX_KEYS_RBTREE_NODE_TO_KEY_VALUE_PAIR( node ) \ - RTEMS_CONTAINER_OF( node, POSIX_Keys_Key_value_pair, Lookup_node ) - -/** - * @brief Allocate a keys control block. - * - * This function allocates a keys control block from - * the inactive chain of free keys control blocks. - */ - -RTEMS_INLINE_ROUTINE POSIX_Keys_Control *_POSIX_Keys_Allocate( void ) -{ - return (POSIX_Keys_Control *) _Objects_Allocate( &_POSIX_Keys_Information ); -} - -/** - * @brief Free a keys control block. - * - * This routine frees a keys control block to the - * inactive chain of free keys control blocks. - */ -RTEMS_INLINE_ROUTINE void _POSIX_Keys_Free( - POSIX_Keys_Control *the_key -) -{ - _Objects_Free( &_POSIX_Keys_Information, &the_key->Object ); -} - -RTEMS_INLINE_ROUTINE POSIX_Keys_Control *_POSIX_Keys_Get( pthread_key_t key ) -{ - return (POSIX_Keys_Control *) - _Objects_Get_no_protection( (Objects_Id) key, &_POSIX_Keys_Information ); -} - -RTEMS_INLINE_ROUTINE void _POSIX_Keys_Key_value_acquire( - Thread_Control *the_thread, - ISR_lock_Context *lock_context -) -{ - _ISR_lock_ISR_disable_and_acquire( &the_thread->Keys.Lock, lock_context ); -} - -RTEMS_INLINE_ROUTINE void _POSIX_Keys_Key_value_release( - Thread_Control *the_thread, - ISR_lock_Context *lock_context -) -{ - _ISR_lock_Release_and_ISR_enable( &the_thread->Keys.Lock, lock_context ); -} - -POSIX_Keys_Key_value_pair * _POSIX_Keys_Key_value_allocate( void ); - -RTEMS_INLINE_ROUTINE void _POSIX_Keys_Key_value_free( - POSIX_Keys_Key_value_pair *key_value_pair -) -{ - _Chain_Extract_unprotected( &key_value_pair->Key_node ); - _Freechain_Put( &_POSIX_Keys_Keypool, key_value_pair ); -} - -RTEMS_INLINE_ROUTINE bool _POSIX_Keys_Key_value_equal( - const void *left, - const RBTree_Node *right -) -{ - const pthread_key_t *the_left; - const POSIX_Keys_Key_value_pair *the_right; - - the_left = left; - the_right = POSIX_KEYS_RBTREE_NODE_TO_KEY_VALUE_PAIR( right ); - - return *the_left == the_right->key; -} - -RTEMS_INLINE_ROUTINE bool _POSIX_Keys_Key_value_less( - const void *left, - const RBTree_Node *right -) -{ - const pthread_key_t *the_left; - const POSIX_Keys_Key_value_pair *the_right; - - the_left = left; - the_right = POSIX_KEYS_RBTREE_NODE_TO_KEY_VALUE_PAIR( right ); - - return *the_left < the_right->key; -} - -RTEMS_INLINE_ROUTINE void *_POSIX_Keys_Key_value_map( RBTree_Node *node ) -{ - return POSIX_KEYS_RBTREE_NODE_TO_KEY_VALUE_PAIR( node ); -} - -RTEMS_INLINE_ROUTINE POSIX_Keys_Key_value_pair *_POSIX_Keys_Key_value_find( - pthread_key_t key, - const Thread_Control *the_thread -) -{ - return _RBTree_Find_inline( - &the_thread->Keys.Key_value_pairs, - &key, - _POSIX_Keys_Key_value_equal, - _POSIX_Keys_Key_value_less, - _POSIX_Keys_Key_value_map - ); -} - -RTEMS_INLINE_ROUTINE void _POSIX_Keys_Key_value_insert( - pthread_key_t key, - POSIX_Keys_Key_value_pair *key_value_pair, - Thread_Control *the_thread -) -{ - _RBTree_Insert_inline( - &the_thread->Keys.Key_value_pairs, - &key_value_pair->Lookup_node, - &key, - _POSIX_Keys_Key_value_less - ); -} - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/posix/include/rtems/posix/mmanimpl.h b/cpukit/posix/include/rtems/posix/mmanimpl.h deleted file mode 100644 index e1cc672331..0000000000 --- a/cpukit/posix/include/rtems/posix/mmanimpl.h +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @file - * - * @brief Internal Support for POSIX 1003.1b 6.3.1 - map pages of memory - * - */ - -/* - * Copyright (c) 2012 Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_POSIX_MMANIMPL_H -#define _RTEMS_POSIX_MMANIMPL_H - -#include -#include /* FIXME: use score chains for proper layering? */ -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* FIXME: add Doxygen */ - -/** - * Every mmap'ed region has a mapping. - */ -typedef struct mmap_mappings_s { - rtems_chain_node node; /**< The mapping chain's node */ - void* addr; /**< The address of the mapped memory */ - size_t len; /**< The length of memory mapped */ - int flags; /**< The mapping flags */ - POSIX_Shm_Control *shm; /**< The shared memory object or NULL */ -} mmap_mapping; - -extern rtems_chain_control mmap_mappings; - -static inline void mmap_mappings_lock_obtain( void ) -{ - rtems_libio_lock(); -} - -static inline void mmap_mappings_lock_release( void ) -{ - rtems_libio_unlock(); -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/posix/include/rtems/posix/mqueue.h b/cpukit/posix/include/rtems/posix/mqueue.h deleted file mode 100644 index cdf94514af..0000000000 --- a/cpukit/posix/include/rtems/posix/mqueue.h +++ /dev/null @@ -1,71 +0,0 @@ -/** - * @file - * - * @brief POSIX Message Queues Private Private Support - * - * This include file contains all the private support information for - * POSIX Message Queues. - * - * The structure of the routines is identical to that of POSIX - * Message_queues to leave the option of having unnamed message - * queues at a future date. They are currently not part of the - * POSIX standard but unnamed message_queues are. This is also - * the reason for the apparently unnecessary tracking of - * the process_shared attribute. [In addition to the fact that - * it would be trivial to add pshared to the mq_attr structure - * and have process private message queues.] - * - * This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open - * time. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_POSIX_MQUEUE_H -#define _RTEMS_POSIX_MQUEUE_H - -#include -#include /* struct mq_attr */ -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup POSIX_MQUEUE_P Message Queues Private Support - * - * @ingroup POSIXAPI - * - */ -/**@{**/ - -/* - * Data Structure used to manage a POSIX message queue - */ - -typedef struct { - Objects_Control Object; - CORE_message_queue_Control Message_queue; - bool linked; - uint32_t open_count; - struct sigevent notification; - int oflag; -} POSIX_Message_queue_Control; - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/posix/include/rtems/posix/mqueueimpl.h b/cpukit/posix/include/rtems/posix/mqueueimpl.h deleted file mode 100644 index 6813a3ef88..0000000000 --- a/cpukit/posix/include/rtems/posix/mqueueimpl.h +++ /dev/null @@ -1,183 +0,0 @@ -/** - * @file - * - * @brief Private Inlined Routines for POSIX Message Queue - * - * This include file contains the static inline implementation of the private - * inlined routines for POSIX Message Queue. - */ - -/* - * COPYRIGHT (c) 1989-2013. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_POSIX_MQUEUE_INL -#define _RTEMS_POSIX_MQUEUE_INL - -#include -#include -#include -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * This defines the information control block used to manage - * this class of objects. - */ -extern Objects_Information _POSIX_Message_queue_Information; - -/** - * @brief Delete a POSIX Message Queue - * - * This routine supports the mq_unlink and mq_close routines by - * doing most of the work involved with removing a message queue. - */ -void _POSIX_Message_queue_Delete( - POSIX_Message_queue_Control *the_mq, - Thread_queue_Context *queue_context -); - -/*@ - * @brief POSIX Message Queue Receive Support - * - * This routine supports the various flavors of receiving a message. - * - * @note The structure of the routines is identical to that of POSIX - * Message_queues to leave the option of having unnamed message - * queues at a future date. They are currently not part of the - * POSIX standard but unnamed message_queues are. This is also - * the reason for the apparently unnecessary tracking of - * the process_shared attribute. [In addition to the fact that - * it would be trivial to add pshared to the mq_attr structure - * and have process private message queues.] - * - * @note This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open time. - */ -ssize_t _POSIX_Message_queue_Receive_support( - mqd_t mqdes, - char *msg_ptr, - size_t msg_len, - unsigned int *msg_prio, - const struct timespec *abstime, - Thread_queue_Enqueue_callout enqueue_callout -); - -/** - * @brief POSIX Message Queue Send Support - * - * This routine posts a message to a specified message queue. - */ -int _POSIX_Message_queue_Send_support( - mqd_t mqdes, - const char *msg_ptr, - size_t msg_len, - unsigned int msg_prio, - const struct timespec *abstime, - Thread_queue_Enqueue_callout enqueue_callout -); - -RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control * - _POSIX_Message_queue_Allocate_unprotected( void ) -{ - return (POSIX_Message_queue_Control *) - _Objects_Allocate_unprotected( &_POSIX_Message_queue_Information ); -} - -/** - * @brief POSIX Message Queue Free - * - * This routine frees a message queue control block to the - * inactive chain of free message queue control blocks. - */ -RTEMS_INLINE_ROUTINE void _POSIX_Message_queue_Free( - POSIX_Message_queue_Control *the_mq -) -{ - _Objects_Free( &_POSIX_Message_queue_Information, &the_mq->Object ); -} - - -RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control *_POSIX_Message_queue_Get( - Objects_Id id, - Thread_queue_Context *queue_context -) -{ - _Thread_queue_Context_initialize( queue_context ); - return (POSIX_Message_queue_Control *) _Objects_Get( - id, - &queue_context->Lock_context.Lock_context, - &_POSIX_Message_queue_Information - ); -} - -/* - * @brief POSIX Message Queue Convert Message Priority to Score - * - * This method converts a POSIX message priority to the priorities used - * by the Score. - */ -RTEMS_INLINE_ROUTINE CORE_message_queue_Submit_types - _POSIX_Message_queue_Priority_to_core( - unsigned int priority -) -{ - return (CORE_message_queue_Submit_types) priority * -1; -} - - -/* - * @brief POSIX Message Queue Convert Message Priority from Score - * - * This method converts a POSIX message priority from the priorities used - * by the Score. - */ -RTEMS_INLINE_ROUTINE unsigned int _POSIX_Message_queue_Priority_from_core( - CORE_message_queue_Submit_types priority -) -{ - /* absolute value without a library dependency */ - return (unsigned int) ((priority >= 0) ? priority : -priority); -} - -/** - * @brief POSIX Message Queue Remove from Namespace - */ -RTEMS_INLINE_ROUTINE void _POSIX_Message_queue_Namespace_remove ( - POSIX_Message_queue_Control *the_mq -) -{ - _Objects_Namespace_remove( - &_POSIX_Message_queue_Information, &the_mq->Object ); -} - -RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control * -_POSIX_Message_queue_Get_by_name( - const char *name, - size_t *name_length_p, - Objects_Get_by_name_error *error -) -{ - return (POSIX_Message_queue_Control *) _Objects_Get_by_name( - &_POSIX_Message_queue_Information, - name, - name_length_p, - error - ); -} - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/posix/include/rtems/posix/muteximpl.h b/cpukit/posix/include/rtems/posix/muteximpl.h deleted file mode 100644 index 435b43634d..0000000000 --- a/cpukit/posix/include/rtems/posix/muteximpl.h +++ /dev/null @@ -1,487 +0,0 @@ -/** - * @file - * - * @brief Private Inlined Routines for POSIX Mutex's. - * - * This include file contains the static inline implementation of the private - * inlined routines for POSIX mutex's. - */ - -/* COPYRIGHT (c) 1989-2013. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_POSIX_MUTEXIMPL_H -#define _RTEMS_POSIX_MUTEXIMPL_H - -#include -#include - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - unsigned long flags; - Mutex_recursive_Control Recursive; - Priority_Node Priority_ceiling; - const Scheduler_Control *scheduler; -} POSIX_Mutex_Control; - -#define POSIX_MUTEX_PROTOCOL_MASK 0x3UL - -#define POSIX_MUTEX_RECURSIVE 0x4UL - -#define POSIX_MUTEX_FLAGS_MASK 0x7UL - -#define POSIX_MUTEX_MAGIC 0x961c13b8UL - -#define POSIX_MUTEX_NO_PROTOCOL_TQ_OPERATIONS &_Thread_queue_Operations_FIFO - -#define POSIX_MUTEX_PRIORITY_INHERIT_TQ_OPERATIONS \ - &_Thread_queue_Operations_priority_inherit - -#define POSIX_MUTEX_PRIORITY_CEILING_TQ_OPERATIONS \ - &_Thread_queue_Operations_priority - -/** - * @brief Supported POSIX mutex protocols. - * - * Must be in synchronization with POSIX_Mutex_Control::protocol. - */ -typedef enum { - POSIX_MUTEX_NO_PROTOCOL, - POSIX_MUTEX_PRIORITY_INHERIT, - POSIX_MUTEX_PRIORITY_CEILING -} POSIX_Mutex_Protocol; - -/** - * The default mutex attributes structure. - */ -extern const pthread_mutexattr_t _POSIX_Mutex_Default_attributes; - -RTEMS_INLINE_ROUTINE Thread_Control *_POSIX_Mutex_Acquire( - POSIX_Mutex_Control *the_mutex, - Thread_queue_Context *queue_context -) -{ - ISR_Level level; - Thread_Control *executing; - - _Thread_queue_Context_initialize( queue_context ); - _Thread_queue_Context_ISR_disable( queue_context, level ); - _Thread_queue_Context_set_ISR_level( queue_context, level ); - executing = _Thread_Executing; - _Thread_queue_Queue_acquire_critical( - &the_mutex->Recursive.Mutex.Queue.Queue, - &executing->Potpourri_stats, - &queue_context->Lock_context.Lock_context - ); - - return executing; -} - -RTEMS_INLINE_ROUTINE void _POSIX_Mutex_Release( - POSIX_Mutex_Control *the_mutex, - Thread_queue_Context *queue_context -) -{ - _Thread_queue_Queue_release( - &the_mutex->Recursive.Mutex.Queue.Queue, - &queue_context->Lock_context.Lock_context - ); -} - -RTEMS_INLINE_ROUTINE POSIX_Mutex_Protocol _POSIX_Mutex_Get_protocol( - unsigned long flags -) -{ - return flags & POSIX_MUTEX_PROTOCOL_MASK; -} - -RTEMS_INLINE_ROUTINE bool _POSIX_Mutex_Is_recursive( - unsigned long flags -) -{ - return ( flags & POSIX_MUTEX_RECURSIVE ) != 0; -} - -RTEMS_INLINE_ROUTINE Thread_Control *_POSIX_Mutex_Get_owner( - const POSIX_Mutex_Control *the_mutex -) -{ - return the_mutex->Recursive.Mutex.Queue.Queue.owner; -} - -RTEMS_INLINE_ROUTINE bool _POSIX_Mutex_Is_locked( - const POSIX_Mutex_Control *the_mutex -) -{ - return _POSIX_Mutex_Get_owner( the_mutex ) != NULL; -} - -Status_Control _POSIX_Mutex_Seize_slow( - POSIX_Mutex_Control *the_mutex, - const Thread_queue_Operations *operations, - Thread_Control *executing, - const struct timespec *abstime, - Thread_queue_Context *queue_context -); - -RTEMS_INLINE_ROUTINE void _POSIX_Mutex_Set_owner( - POSIX_Mutex_Control *the_mutex, - Thread_Control *owner -) -{ - the_mutex->Recursive.Mutex.Queue.Queue.owner = owner; -} - -RTEMS_INLINE_ROUTINE bool _POSIX_Mutex_Is_owner( - const POSIX_Mutex_Control *the_mutex, - const Thread_Control *the_thread -) -{ - return _POSIX_Mutex_Get_owner( the_mutex ) == the_thread; -} - -static Status_Control _POSIX_Mutex_Lock_nested( - POSIX_Mutex_Control *the_mutex, - unsigned long flags -) -{ - - if ( _POSIX_Mutex_Is_recursive( flags ) ) { - ++the_mutex->Recursive.nest_level; - return STATUS_SUCCESSFUL; - } else { - return STATUS_NESTING_NOT_ALLOWED; - } -} - -RTEMS_INLINE_ROUTINE Status_Control _POSIX_Mutex_Seize( - POSIX_Mutex_Control *the_mutex, - unsigned long flags, - const Thread_queue_Operations *operations, - Thread_Control *executing, - const struct timespec *abstime, - Thread_queue_Context *queue_context -) -{ - Thread_Control *owner; - - owner = _POSIX_Mutex_Get_owner( the_mutex ); - - if ( owner == NULL ) { - _POSIX_Mutex_Set_owner( the_mutex, executing ); - _Thread_Resource_count_increment( executing ); - _POSIX_Mutex_Release( the_mutex, queue_context ); - return STATUS_SUCCESSFUL; - } - - if ( owner == executing ) { - Status_Control status; - - status = _POSIX_Mutex_Lock_nested( the_mutex, flags ); - _POSIX_Mutex_Release( the_mutex, queue_context ); - return status; - } - - return _POSIX_Mutex_Seize_slow( - the_mutex, - operations, - executing, - abstime, - queue_context - ); -} - -RTEMS_INLINE_ROUTINE Status_Control _POSIX_Mutex_Surrender( - POSIX_Mutex_Control *the_mutex, - const Thread_queue_Operations *operations, - Thread_Control *executing, - Thread_queue_Context *queue_context -) -{ - unsigned int nest_level; - Thread_queue_Heads *heads; - - if ( !_POSIX_Mutex_Is_owner( the_mutex, executing ) ) { - _POSIX_Mutex_Release( the_mutex, queue_context ); - return STATUS_NOT_OWNER; - } - - nest_level = the_mutex->Recursive.nest_level; - - if ( nest_level > 0 ) { - the_mutex->Recursive.nest_level = nest_level - 1; - _POSIX_Mutex_Release( the_mutex, queue_context ); - return STATUS_SUCCESSFUL; - } - - _Thread_Resource_count_decrement( executing ); - _POSIX_Mutex_Set_owner( the_mutex, NULL ); - - heads = the_mutex->Recursive.Mutex.Queue.Queue.heads; - - if ( heads == NULL ) { - _POSIX_Mutex_Release( the_mutex, queue_context ); - return STATUS_SUCCESSFUL; - } - - _Thread_queue_Surrender( - &the_mutex->Recursive.Mutex.Queue.Queue, - heads, - executing, - queue_context, - operations - ); - return STATUS_SUCCESSFUL; -} - -RTEMS_INLINE_ROUTINE const Scheduler_Control *_POSIX_Mutex_Get_scheduler( - const POSIX_Mutex_Control *the_mutex -) -{ -#if defined(RTEMS_SMP) - return the_mutex->scheduler; -#else - return &_Scheduler_Table[ 0 ]; -#endif -} - -RTEMS_INLINE_ROUTINE void _POSIX_Mutex_Set_priority( - POSIX_Mutex_Control *the_mutex, - Priority_Control priority_ceiling, - Thread_queue_Context *queue_context -) -{ - Thread_Control *owner; - - owner = _POSIX_Mutex_Get_owner( the_mutex ); - - if ( owner != NULL ) { - _Thread_Wait_acquire( owner, queue_context ); - _Thread_Priority_change( - owner, - &the_mutex->Priority_ceiling, - priority_ceiling, - false, - queue_context - ); - _Thread_Wait_release( owner, queue_context ); - } else { - the_mutex->Priority_ceiling.priority = priority_ceiling; - } -} - -RTEMS_INLINE_ROUTINE Priority_Control _POSIX_Mutex_Get_priority( - const POSIX_Mutex_Control *the_mutex -) -{ - return the_mutex->Priority_ceiling.priority; -} - -RTEMS_INLINE_ROUTINE Status_Control _POSIX_Mutex_Ceiling_set_owner( - POSIX_Mutex_Control *the_mutex, - Thread_Control *owner, - Thread_queue_Context *queue_context -) -{ - ISR_lock_Context lock_context; - Scheduler_Node *scheduler_node; - Per_CPU_Control *cpu_self; - - _Thread_Wait_acquire_default_critical( owner, &lock_context ); - - scheduler_node = _Thread_Scheduler_get_home_node( owner ); - - if ( - _Priority_Get_priority( &scheduler_node->Wait.Priority ) - < the_mutex->Priority_ceiling.priority - ) { - _Thread_Wait_release_default_critical( owner, &lock_context ); - _POSIX_Mutex_Release( the_mutex, queue_context ); - return STATUS_MUTEX_CEILING_VIOLATED; - } - - _POSIX_Mutex_Set_owner( the_mutex, owner ); - _Thread_Resource_count_increment( owner ); - _Thread_Priority_add( - owner, - &the_mutex->Priority_ceiling, - queue_context - ); - _Thread_Wait_release_default_critical( owner, &lock_context ); - - cpu_self = _Thread_queue_Dispatch_disable( queue_context ); - _POSIX_Mutex_Release( the_mutex, queue_context ); - _Thread_Priority_update( queue_context ); - _Thread_Dispatch_enable( cpu_self ); - return STATUS_SUCCESSFUL; -} - -RTEMS_INLINE_ROUTINE Status_Control _POSIX_Mutex_Ceiling_seize( - POSIX_Mutex_Control *the_mutex, - unsigned long flags, - Thread_Control *executing, - const struct timespec *abstime, - Thread_queue_Context *queue_context -) -{ - Thread_Control *owner; - - owner = _POSIX_Mutex_Get_owner( the_mutex ); - - if ( owner == NULL ) { -#if defined(RTEMS_SMP) - if ( - _Thread_Scheduler_get_home( executing ) - != _POSIX_Mutex_Get_scheduler( the_mutex ) - ) { - _POSIX_Mutex_Release( the_mutex, queue_context ); - return STATUS_NOT_DEFINED; - } -#endif - - _Thread_queue_Context_clear_priority_updates( queue_context ); - return _POSIX_Mutex_Ceiling_set_owner( - the_mutex, - executing, - queue_context - ); - } - - if ( owner == executing ) { - Status_Control status; - - status = _POSIX_Mutex_Lock_nested( the_mutex, flags ); - _POSIX_Mutex_Release( the_mutex, queue_context ); - return status; - } - - return _POSIX_Mutex_Seize_slow( - the_mutex, - POSIX_MUTEX_PRIORITY_CEILING_TQ_OPERATIONS, - executing, - abstime, - queue_context - ); -} - -RTEMS_INLINE_ROUTINE Status_Control _POSIX_Mutex_Ceiling_surrender( - POSIX_Mutex_Control *the_mutex, - Thread_Control *executing, - Thread_queue_Context *queue_context -) -{ - unsigned int nest_level; - ISR_lock_Context lock_context; - Per_CPU_Control *cpu_self; - Thread_queue_Heads *heads; - - if ( !_POSIX_Mutex_Is_owner( the_mutex, executing ) ) { - _POSIX_Mutex_Release( the_mutex, queue_context ); - return STATUS_NOT_OWNER; - } - - nest_level = the_mutex->Recursive.nest_level; - - if ( nest_level > 0 ) { - the_mutex->Recursive.nest_level = nest_level - 1; - _POSIX_Mutex_Release( the_mutex, queue_context ); - return STATUS_SUCCESSFUL; - } - - _Thread_Resource_count_decrement( executing ); - - _Thread_queue_Context_clear_priority_updates( queue_context ); - _Thread_Wait_acquire_default_critical( executing, &lock_context ); - _Thread_Priority_remove( - executing, - &the_mutex->Priority_ceiling, - queue_context - ); - _Thread_Wait_release_default_critical( executing, &lock_context ); - - cpu_self = _Thread_queue_Dispatch_disable( queue_context ); - - heads = the_mutex->Recursive.Mutex.Queue.Queue.heads; - - if ( heads != NULL ) { - const Thread_queue_Operations *operations; - Thread_Control *new_owner; - - operations = POSIX_MUTEX_PRIORITY_CEILING_TQ_OPERATIONS; - new_owner = ( *operations->first )( heads ); - _POSIX_Mutex_Set_owner( the_mutex, new_owner ); - _Thread_Resource_count_increment( new_owner ); - _Thread_Priority_add( - new_owner, - &the_mutex->Priority_ceiling, - queue_context - ); - _Thread_queue_Extract_critical( - &the_mutex->Recursive.Mutex.Queue.Queue, - operations, - new_owner, - queue_context - ); - } else { - _POSIX_Mutex_Set_owner( the_mutex, NULL ); - _POSIX_Mutex_Release( the_mutex, queue_context ); - } - - _Thread_Priority_update( queue_context ); - _Thread_Dispatch_enable( cpu_self ); - return STATUS_SUCCESSFUL; -} - -#define POSIX_MUTEX_ABSTIME_TRY_LOCK ((uintptr_t) 1) - -int _POSIX_Mutex_Lock_support( - pthread_mutex_t *mutex, - const struct timespec *abstime, - Thread_queue_Enqueue_callout enqueue_callout -); - -static inline POSIX_Mutex_Control *_POSIX_Mutex_Get( - pthread_mutex_t *mutex -) -{ - return (POSIX_Mutex_Control *) mutex; -} - -bool _POSIX_Mutex_Auto_initialization( POSIX_Mutex_Control *the_mutex ); - -#define POSIX_MUTEX_VALIDATE_OBJECT( the_mutex, flags ) \ - do { \ - if ( ( the_mutex ) == NULL ) { \ - return EINVAL; \ - } \ - flags = ( the_mutex )->flags; \ - if ( \ - ( ( (uintptr_t) ( the_mutex ) ^ POSIX_MUTEX_MAGIC ) \ - & ~POSIX_MUTEX_FLAGS_MASK ) \ - != ( flags & ~POSIX_MUTEX_FLAGS_MASK ) \ - ) { \ - if ( !_POSIX_Mutex_Auto_initialization( the_mutex ) ) { \ - return EINVAL; \ - } \ - } \ - } while ( 0 ) - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ - diff --git a/cpukit/posix/include/rtems/posix/posixapi.h b/cpukit/posix/include/rtems/posix/posixapi.h deleted file mode 100644 index 29394ab94e..0000000000 --- a/cpukit/posix/include/rtems/posix/posixapi.h +++ /dev/null @@ -1,146 +0,0 @@ -/** - * @file - * - * @brief POSIX API Implementation - * - * This include file defines the top level interface to the POSIX API - * implementation in RTEMS. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_POSIX_POSIXAPI_H -#define _RTEMS_POSIX_POSIXAPI_H - -#include -#include -#include -#include -#include -#include - -#include - -/** - * @defgroup POSIXAPI RTEMS POSIX API - * - * RTEMS POSIX API definitions and modules. - * - */ -/**@{**/ - -/** - * @brief POSIX API Fatal domains. - */ -typedef enum { - POSIX_FD_PTHREAD, /**< A pthread thread error. */ - POSIX_FD_PTHREAD_ONCE /**< A pthread once error. */ -} POSIX_Fatal_domain; - -/** - * @brief POSIX API Fatal error. - * - * A common method of rasing a POSIX API fatal error. - * - * @param[in] domain The POSIX error domain. - * @param[in] eno The error number as defined in errno.h. - */ -void _POSIX_Fatal_error( POSIX_Fatal_domain domain, int eno ); - -extern const int _POSIX_Get_by_name_error_table[ 3 ]; - -RTEMS_INLINE_ROUTINE int _POSIX_Get_by_name_error( - Objects_Get_by_name_error error -) -{ - _Assert( (size_t) error < RTEMS_ARRAY_SIZE( _POSIX_Get_by_name_error_table ) ); - return _POSIX_Get_by_name_error_table[ error ]; -} - -RTEMS_INLINE_ROUTINE int _POSIX_Get_error( Status_Control status ) -{ - return STATUS_GET_POSIX( status ); -} - -RTEMS_INLINE_ROUTINE int _POSIX_Get_error_after_wait( - const Thread_Control *executing -) -{ - return _POSIX_Get_error( _Thread_Wait_get_status( executing ) ); -} - -RTEMS_INLINE_ROUTINE int _POSIX_Zero_or_minus_one_plus_errno( - Status_Control status -) -{ - if ( status == STATUS_SUCCESSFUL ) { - return 0; - } - - rtems_set_errno_and_return_minus_one( _POSIX_Get_error( status ) ); -} - -/** - * @brief Macro to generate a function body to get a POSIX object by - * identifier. - * - * Generates a function body to get the object for the specified identifier. - * Performs automatic initialization if requested and necessary. This is an - * ugly macro, since C lacks support for templates. - */ -#define _POSIX_Get_object_body( \ - type, \ - id, \ - queue_context, \ - info, \ - initializer, \ - init \ -) \ - Objects_Control *the_object; \ - if ( id == NULL ) { \ - return NULL; \ - } \ - _Thread_queue_Context_initialize( queue_context ); \ - the_object = _Objects_Get( \ - (Objects_Id) *id, \ - &queue_context->Lock_context.Lock_context, \ - info \ - ); \ - if ( the_object == NULL ) { \ - _Once_Lock(); \ - if ( *id == initializer ) { \ - init( id, NULL ); \ - } \ - _Once_Unlock(); \ - the_object = _Objects_Get( \ - (Objects_Id) *id, \ - &queue_context->Lock_context.Lock_context, \ - info \ - ); \ - } \ - return (type *) the_object - -/* - * See also The Open Group Base Specifications Issue 7, IEEE Std 1003.1-2008, - * 2016 Edition, subsection 2.9.9, Synchronization Object Copies and - * Alternative Mappings. - * - * http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_09_09 - */ -RTEMS_INLINE_ROUTINE bool _POSIX_Is_valid_pshared( int pshared ) -{ - return pshared == PTHREAD_PROCESS_PRIVATE || - pshared == PTHREAD_PROCESS_SHARED; -} - -/** @} */ - -#endif -/* end of include file */ diff --git a/cpukit/posix/include/rtems/posix/priorityimpl.h b/cpukit/posix/include/rtems/posix/priorityimpl.h deleted file mode 100644 index eb2e3e059f..0000000000 --- a/cpukit/posix/include/rtems/posix/priorityimpl.h +++ /dev/null @@ -1,109 +0,0 @@ -/** - * @file - * - * @brief POSIX Priority Support - * - * This include file defines the interface to the POSIX priority - * implementation. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_POSIX_PRIORITYIMPL_H -#define _RTEMS_POSIX_PRIORITYIMPL_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup POSIX_PRIORITY POSIX Priority Support - * - * @ingroup POSIXAPI - * - * @brief Interface to the POSIX Priority Implementation. - * - * @{ - */ - -/** - * This is the numerically least important POSIX priority. - */ -#define POSIX_SCHEDULER_MINIMUM_PRIORITY (1) - -/** - * @brief Gets the maximum POSIX API priority for this scheduler instance. - * - * Such a priority is valid. A scheduler instance may support priority values - * that are not representable as an integer. - * - * @return The maximum POSIX API priority for this scheduler instance. - */ -RTEMS_INLINE_ROUTINE int _POSIX_Priority_Get_maximum( - const Scheduler_Control *scheduler -) -{ - _Assert( (int) scheduler->maximum_priority > 1 ); - return (int) scheduler->maximum_priority - 1; -} - -/** - * @brief Converts the POSIX API priority to the corresponding SuperCore - * priority and validates it. - * - * According to POSIX, numerically higher values represent higher priorities. - * Thus, SuperCore has priorities run in the opposite sense of the POSIX API. - * - * Let N be the maximum priority of this scheduler instance. The SuperCore - * priority zero is system reserved (PRIORITY_PSEUDO_ISR). There are only - * N - 1 POSIX API priority levels since a thread at SuperCore priority N would - * never run because of the idle threads. This is necessary because GNAT maps - * the lowest Ada task priority to the lowest thread priority. The lowest - * priority Ada task should get to run, so there is a fundamental conflict with - * having N priorities. - * - * @param[in] scheduler The scheduler instance. - * @param[in] priority The POSIX API priority to convert and validate. - * @param[out] valid Indicates if the POSIX API priority is valid and a - * corresponding SuperCore priority in the specified scheduler instance - * exists. - * - * @return The corresponding SuperCore priority. - */ -Priority_Control _POSIX_Priority_To_core( - const Scheduler_Control *scheduler, - int priority, - bool *valid -); - -/** - * @brief Converts the SuperCore priority to the corresponding POSIX API - * priority. - * - * @param[in] scheduler The scheduler instance. - * @param[in] priority The SuperCore priority to convert. - * - * @return The corresponding POSIX API priority. - */ -int _POSIX_Priority_From_core( - const Scheduler_Control *scheduler, - Priority_Control priority -); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/posix/include/rtems/posix/psignal.h b/cpukit/posix/include/rtems/posix/psignal.h deleted file mode 100644 index ed98442e32..0000000000 --- a/cpukit/posix/include/rtems/posix/psignal.h +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @file - * - * @brief Internal Information about POSIX Signals - * - * This include file defines internal information about POSIX signals. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_POSIX_PSIGNAL_H -#define _RTEMS_POSIX_PSIGNAL_H - -#include - -#include - -/* - * POSIX internal siginfo structure - */ - -typedef struct { - Chain_Node Node; - siginfo_t Info; -} POSIX_signals_Siginfo_node; - -#endif -/* end of file */ diff --git a/cpukit/posix/include/rtems/posix/psignalimpl.h b/cpukit/posix/include/rtems/posix/psignalimpl.h deleted file mode 100644 index cccc3dafc9..0000000000 --- a/cpukit/posix/include/rtems/posix/psignalimpl.h +++ /dev/null @@ -1,140 +0,0 @@ -/** - * @file - * - * @brief POSIX Signals Support - * - * This include file defines internal information about POSIX signals. - */ - -/* - * COPYRIGHT (c) 1989-2013. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_POSIX_PSIGNALIMPL_H -#define _RTEMS_POSIX_PSIGNALIMPL_H - -/** - * @defgroup POSIX_SIGNALS POSIX Signals Support - * - * @ingroup POSIXAPI - * - * @brief Internal Information about POSIX Signals - * - */ -/**@{**/ - -#include -#include -#include -#include -#include -#include - -#define POSIX_SIGNALS_TQ_OPERATIONS &_Thread_queue_Operations_FIFO - -#define _States_Is_interruptible_signal( _states ) \ - ( ((_states) & \ - (STATES_WAITING_FOR_SIGNAL|STATES_INTERRUPTIBLE_BY_SIGNAL)) == \ - (STATES_WAITING_FOR_SIGNAL|STATES_INTERRUPTIBLE_BY_SIGNAL)) - -#define SIGACTION_TERMINATE \ - { 0, SIGNAL_ALL_MASK, {_POSIX_signals_Abnormal_termination_handler} } -#define SIGACTION_IGNORE \ - { 0, SIGNAL_ALL_MASK, {SIG_IGN} } -#define SIGACTION_STOP \ - { 0, SIGNAL_ALL_MASK, {_POSIX_signals_Stop_handler} } -#define SIGACTION_CONTINUE \ - { 0, SIGNAL_ALL_MASK, {_POSIX_signals_Continue_handler} } - -#define SIG_ARRAY_MAX (SIGRTMAX + 1) - -/* - * Variables - */ - -extern sigset_t _POSIX_signals_Pending; - -extern const struct sigaction _POSIX_signals_Default_vectors[ SIG_ARRAY_MAX ]; - -extern struct sigaction _POSIX_signals_Vectors[ SIG_ARRAY_MAX ]; - -extern Thread_queue_Control _POSIX_signals_Wait_queue; - -extern Chain_Control _POSIX_signals_Inactive_siginfo; - -extern Chain_Control _POSIX_signals_Siginfo[ SIG_ARRAY_MAX ]; - -/* - * Internal routines - */ - -RTEMS_INLINE_ROUTINE void _POSIX_signals_Acquire( - Thread_queue_Context *queue_context -) -{ - _Thread_queue_Acquire( &_POSIX_signals_Wait_queue, queue_context ); -} - -RTEMS_INLINE_ROUTINE void _POSIX_signals_Release( - Thread_queue_Context *queue_context -) -{ - _Thread_queue_Release( &_POSIX_signals_Wait_queue, queue_context ); -} - -/** - * @brief Unlock POSIX signals thread. - */ -bool _POSIX_signals_Unblock_thread( - Thread_Control *the_thread, - int signo, - siginfo_t *info -); - -/** - * @brief Clear POSIX signals. - */ -bool _POSIX_signals_Clear_signals( - POSIX_API_Control *api, - int signo, - siginfo_t *info, - bool is_global, - bool check_blocked, - bool do_signals_acquire_release -); - -int _POSIX_signals_Send( - pid_t pid, - int sig, - const union sigval *value -); - -/** - * @brief Set POSIX process signals. - */ -void _POSIX_signals_Set_process_signals( - sigset_t mask -); - -void _POSIX_signals_Clear_process_signals( - int signo -); - -/* - * Default signal handlers - */ - -#define _POSIX_signals_Stop_handler NULL -#define _POSIX_signals_Continue_handler NULL - -void _POSIX_signals_Abnormal_termination_handler( int signo ); - -/** @} */ - -#endif -/* end of file */ diff --git a/cpukit/posix/include/rtems/posix/pthread.h b/cpukit/posix/include/rtems/posix/pthread.h deleted file mode 100644 index 05783ff4ad..0000000000 --- a/cpukit/posix/include/rtems/posix/pthread.h +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @file - * - * @brief POSIX Threads Private Support - * - * This include file contains all the private support information for - * POSIX threads. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_POSIX_PTHREAD_H -#define _RTEMS_POSIX_PTHREAD_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup POSIX_PTHREAD POSIX Threads Support - * - * @ingroup POSIXAPI - * - * @brief Private Support Information for POSIX Threads - * - */ -/**@{**/ - -/** - * @brief POSIX threads initialize user threads body. - * - * This routine creates and starts all configured user - * initialization threads. - */ -extern void _POSIX_Threads_Initialize_user_threads_body(void); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/posix/include/rtems/posix/pthreadattrimpl.h b/cpukit/posix/include/rtems/posix/pthreadattrimpl.h deleted file mode 100644 index 12b8559181..0000000000 --- a/cpukit/posix/include/rtems/posix/pthreadattrimpl.h +++ /dev/null @@ -1,95 +0,0 @@ -/** - * @file - * - * @brief POSIX Threads Private Support - * - * This include file contains all the private support information for - * POSIX threads. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_POSIX_PTHREADATTRIMPL_H -#define _RTEMS_POSIX_PTHREADATTRIMPL_H - -#include -#include - -#include -#include -#include -#if defined(RTEMS_POSIX_API) -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup POSIX_PTHREAD - */ -/**@{**/ - -/** - * This variable contains the default POSIX Thread attributes. - */ -extern const pthread_attr_t _POSIX_Threads_Default_attributes; - -RTEMS_INLINE_ROUTINE void _POSIX_Threads_Copy_attributes( - pthread_attr_t *dst_attr, - const pthread_attr_t *src_attr -) -{ - *dst_attr = *src_attr; - _Assert( - dst_attr->affinitysetsize == sizeof(dst_attr->affinitysetpreallocated) - ); - dst_attr->affinityset = &dst_attr->affinitysetpreallocated; -} - -RTEMS_INLINE_ROUTINE void _POSIX_Threads_Initialize_attributes( - pthread_attr_t *attr -) -{ - _POSIX_Threads_Copy_attributes( - attr, - &_POSIX_Threads_Default_attributes - ); -} - -#if defined(RTEMS_POSIX_API) -RTEMS_INLINE_ROUTINE void _POSIX_Threads_Get_sched_param_sporadic( - const Thread_Control *the_thread, - const Scheduler_Control *scheduler, - struct sched_param *param -) -{ - const POSIX_API_Control *api; - - api = the_thread->API_Extensions[ THREAD_API_POSIX ]; - param->sched_ss_low_priority = _POSIX_Priority_From_core( - scheduler, - api->Sporadic.Low_priority.priority - ); - param->sched_ss_repl_period = api->Sporadic.sched_ss_repl_period; - param->sched_ss_init_budget = api->Sporadic.sched_ss_init_budget; - param->sched_ss_max_repl = api->Sporadic.sched_ss_max_repl; -} -#endif - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/posix/include/rtems/posix/pthreadimpl.h b/cpukit/posix/include/rtems/posix/pthreadimpl.h deleted file mode 100644 index 3e2351e57e..0000000000 --- a/cpukit/posix/include/rtems/posix/pthreadimpl.h +++ /dev/null @@ -1,129 +0,0 @@ -/** - * @file - * - * @brief POSIX Threads Private Support - * - * This include file contains all the private support information for - * POSIX threads. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_POSIX_PTHREADIMPL_H -#define _RTEMS_POSIX_PTHREADIMPL_H - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup POSIX_PTHREAD - */ -/**@{**/ - -/** - * The following sets the minimum stack size for POSIX threads. - */ -#define PTHREAD_MINIMUM_STACK_SIZE (_Stack_Minimum() * 2) - -/** - * The following defines the information control block used to manage - * this class of objects. - */ -extern Thread_Information _POSIX_Threads_Information; - -RTEMS_INLINE_ROUTINE void _POSIX_Threads_Sporadic_timer_insert( - Thread_Control *the_thread, - POSIX_API_Control *api -) -{ - the_thread->cpu_time_budget = - _Timespec_To_ticks( &api->Sporadic.sched_ss_init_budget ); - - _Watchdog_Per_CPU_insert_ticks( - &api->Sporadic.Timer, - _Per_CPU_Get(), - _Timespec_To_ticks( &api->Sporadic.sched_ss_repl_period ) - ); -} - -void _POSIX_Threads_Sporadic_timer( Watchdog_Control *watchdog ); - -/** - * @brief POSIX threads sporadic budget callout. - * - * This routine handles the sporadic scheduling algorithm. - * - * @param[in] the_thread is a pointer to the thread whose budget - * has been exceeded. - */ -void _POSIX_Threads_Sporadic_budget_callout( - Thread_Control *the_thread -); - -int _POSIX_Thread_Translate_to_sched_policy( - Thread_CPU_budget_algorithms budget_algorithm -); - -/** - * @brief Translate sched_param into SuperCore terms. - * - * This method translates the POSIX API sched_param into the corresponding - * SuperCore settings. - * - * @param[in] policy is the POSIX scheduling policy - * @param[in] param points to the scheduling parameter structure - * @param[in] budget_algorithm points to the output CPU Budget algorithm - * @param[in] budget_callout points to the output CPU Callout - * - * @retval 0 Indicates success. - * @retval error_code POSIX error code indicating failure. - */ -int _POSIX_Thread_Translate_sched_param( - int policy, - struct sched_param *param, - Thread_CPU_budget_algorithms *budget_algorithm, - Thread_CPU_budget_algorithm_callout *budget_callout -); - -RTEMS_INLINE_ROUTINE Thread_Control *_POSIX_Threads_Allocate(void) -{ - _Objects_Allocator_lock(); - - _Thread_Kill_zombies(); - - return (Thread_Control *) - _Objects_Allocate_unprotected( &_POSIX_Threads_Information.Objects ); -} - -RTEMS_INLINE_ROUTINE void _POSIX_Threads_Free ( - Thread_Control *the_pthread -) -{ - _Objects_Free( &_POSIX_Threads_Information.Objects, &the_pthread->Object ); -} - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/posix/include/rtems/posix/ptimer.h b/cpukit/posix/include/rtems/posix/ptimer.h deleted file mode 100644 index f6de4ccb57..0000000000 --- a/cpukit/posix/include/rtems/posix/ptimer.h +++ /dev/null @@ -1,88 +0,0 @@ -/** - * @file - * - * @brief POSIX Timers Private Support - * - * This include file contains all the private support information for - * POSIX timers. - */ - -/* - * Initial Implementation: - * COPYRIGHT (c) 1998. Alfonso Escalera Piña - * Largely rewritten by Joel Sherrill (1999). - * - * COPYRIGHT (c) 1999-2013. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_POSIX_PTIMER_H -#define _RTEMS_POSIX_PTIMER_H - -/** - * @defgroup POSIX_PRIV_TIMERS POSIX Timers - * - * @ingroup POSIXAPI - */ -/**@{**/ -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/** - * @brief Create a Per-Process Timer - */ -int timer_create( - clockid_t clock_id, - struct sigevent *evp, - timer_t *timerid -); - -/** - * @brief Delete a Per-Process Timer - */ -int timer_delete( - timer_t timerid -); - -/** - * @brief Set a Per-Process Timer - */ -int timer_settime( - timer_t timerid, - int flags, - const struct itimerspec *value, - struct itimerspec *ovalue -); - -/** - * @brief Set a Per-Process Timer - */ -int timer_gettime( - timer_t timerid, - struct itimerspec *value -); - -/** - * @brief Get overrun count for a Per-Process Timer - * - * The expiration of a timer must increase by one a counter. - * After the signal handler associated to the timer finishes - * its execution, _POSIX_Timer_TSR will have to set this counter to 0. - */ -int timer_getoverrun( - timer_t timerid -); - -#ifdef __cplusplus -} -#endif -/** @} */ - -#endif /* _RTEMS_POSIX_PTIMER_H */ diff --git a/cpukit/posix/include/rtems/posix/rwlockimpl.h b/cpukit/posix/include/rtems/posix/rwlockimpl.h deleted file mode 100644 index b92ca9d04c..0000000000 --- a/cpukit/posix/include/rtems/posix/rwlockimpl.h +++ /dev/null @@ -1,64 +0,0 @@ -/** - * @file - * - * @brief Inlined Routines from the POSIX RWLock Manager - * - * This file contains the static inlin implementation of the inlined - * routines from the POSIX RWLock Manager. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_POSIX_RWLOCKIMPL_H -#define _RTEMS_POSIX_RWLOCKIMPL_H - -#include - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define POSIX_RWLOCK_MAGIC 0x9621dabdUL - -typedef struct { - unsigned long flags; - CORE_RWLock_Control RWLock; -} POSIX_RWLock_Control; - -RTEMS_INLINE_ROUTINE POSIX_RWLock_Control *_POSIX_RWLock_Get( - pthread_rwlock_t *rwlock -) -{ - return (POSIX_RWLock_Control *) rwlock; -} - -bool _POSIX_RWLock_Auto_initialization( POSIX_RWLock_Control *the_rwlock ); - -#define POSIX_RWLOCK_VALIDATE_OBJECT( rw ) \ - do { \ - if ( ( rw ) == NULL ) { \ - return EINVAL; \ - } \ - if ( ( (uintptr_t) ( rw ) ^ POSIX_RWLOCK_MAGIC ) != ( rw )->flags ) { \ - if ( !_POSIX_RWLock_Auto_initialization( rw ) ) { \ - return EINVAL; \ - } \ - } \ - } while ( 0 ) - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/posix/include/rtems/posix/semaphore.h b/cpukit/posix/include/rtems/posix/semaphore.h deleted file mode 100644 index 9133db22be..0000000000 --- a/cpukit/posix/include/rtems/posix/semaphore.h +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @file - * - * @brief Private Support Information for POSIX Semaphores - * - * This include file contains all the private support information for - * POSIX Semaphores. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_POSIX_SEMAPHORE_H -#define _RTEMS_POSIX_SEMAPHORE_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup POSIXSemaphorePrivate POSIX Semaphore Private Support - * - * @ingroup POSIXAPI - * - * This defines the internal implementation support for POSIX semaphores. - */ -/**@{*/ - -/* - * Data Structure used to manage a POSIX semaphore - */ - -typedef struct { - Objects_Control Object; - sem_t Semaphore; - bool linked; - uint32_t open_count; -} POSIX_Semaphore_Control; - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/posix/include/rtems/posix/semaphoreimpl.h b/cpukit/posix/include/rtems/posix/semaphoreimpl.h deleted file mode 100644 index fd17743699..0000000000 --- a/cpukit/posix/include/rtems/posix/semaphoreimpl.h +++ /dev/null @@ -1,143 +0,0 @@ -/** - * @file - * - * @brief Private Inlined Routines for POSIX Semaphores - * - * This include file contains the static inline implementation of the private - * inlined routines for POSIX Semaphores. - */ - -/* - * COPYRIGHT (c) 1989-2013. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_POSIX_SEMAPHOREIMPL_H -#define _RTEMS_POSIX_SEMAPHOREIMPL_H - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief This is a random number used to check if a semaphore object is - * properly initialized. - */ -#define POSIX_SEMAPHORE_MAGIC 0x5d367fe7UL - -/** - * This defines the information control block used to manage - * this class of objects. - */ -extern Objects_Information _POSIX_Semaphore_Information; - -RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control * - _POSIX_Semaphore_Allocate_unprotected( void ) -{ - return (POSIX_Semaphore_Control *) - _Objects_Allocate_unprotected( &_POSIX_Semaphore_Information ); -} - -/** - * @brief POSIX Semaphore Free - * - * This routine frees a semaphore control block to the - * inactive chain of free semaphore control blocks. - */ -RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Free ( - POSIX_Semaphore_Control *the_semaphore -) -{ - _Objects_Free( &_POSIX_Semaphore_Information, &the_semaphore->Object ); -} - -RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *_POSIX_Semaphore_Get( - sem_t *sem -) -{ - return RTEMS_CONTAINER_OF( sem, POSIX_Semaphore_Control, Semaphore ); -} - -RTEMS_INLINE_ROUTINE bool _POSIX_Semaphore_Is_named( const sem_t *sem ) -{ - return sem->_Semaphore._Queue._name != NULL; -} - -RTEMS_INLINE_ROUTINE bool _POSIX_Semaphore_Is_busy( const sem_t *sem ) -{ - return sem->_Semaphore._Queue._heads != NULL; -} - -RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Initialize( - sem_t *sem, - const char *name, - unsigned int value -) -{ - sem->_flags = (uintptr_t) sem ^ POSIX_SEMAPHORE_MAGIC; - _Semaphore_Initialize_named( &sem->_Semaphore, name, value ); -} - -RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Destroy( sem_t *sem ) -{ - sem->_flags = 0; - _Semaphore_Destroy( &sem->_Semaphore ); -} - -/** - * @brief POSIX Semaphore Delete - * - * This routine supports the sem_close and sem_unlink routines. - */ -void _POSIX_Semaphore_Delete( POSIX_Semaphore_Control *the_semaphore ); - -/** - * @brief POSIX Semaphore Namespace Remove - */ -RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Namespace_remove ( - POSIX_Semaphore_Control *the_semaphore -) -{ - _Objects_Namespace_remove( - &_POSIX_Semaphore_Information, &the_semaphore->Object ); -} - -RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *_POSIX_Semaphore_Get_by_name( - const char *name, - size_t *name_length_p, - Objects_Get_by_name_error *error -) -{ - return (POSIX_Semaphore_Control *) _Objects_Get_by_name( - &_POSIX_Semaphore_Information, - name, - name_length_p, - error - ); -} - -#define POSIX_SEMAPHORE_VALIDATE_OBJECT( sem ) \ - do { \ - if ( \ - ( sem ) == NULL \ - || ( (uintptr_t) ( sem ) ^ POSIX_SEMAPHORE_MAGIC ) != ( sem )->_flags \ - ) { \ - rtems_set_errno_and_return_minus_one( EINVAL ); \ - } \ - } while ( 0 ) - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/posix/include/rtems/posix/shm.h b/cpukit/posix/include/rtems/posix/shm.h deleted file mode 100644 index d2b6036493..0000000000 --- a/cpukit/posix/include/rtems/posix/shm.h +++ /dev/null @@ -1,213 +0,0 @@ -/** - * @file - * - * @brief Internal Support for POSIX Shared Memory - */ - -/* - * Copyright (c) 2016 Gedare Bloom. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_POSIX_SHM_H -#define _RTEMS_POSIX_SHM_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup POSIXShmPrivate POSIX Shared Memory Private Support - * - * @ingroup POSIXAPI - * - * Internal implementation support for POSIX shared memory. - * @{ - */ -typedef struct POSIX_Shm_Object_operations POSIX_Shm_Object_operations; -extern const POSIX_Shm_Object_operations _POSIX_Shm_Object_operations; - -/** - * @brief Encapsulation for the storage and manipulation of shm objects. - */ -typedef struct { - /** - * @brief The handle is private for finding object storage. - */ - void *handle; - - /** - * @brief The number of bytes allocated to the object. A size of 0 with - * a handle of NULL means no object is allocated. - */ - size_t size; - - /** - * @brief Implementation-specific operations on shm objects. - */ - const POSIX_Shm_Object_operations *ops; -} POSIX_Shm_Object; - -/** - * @brief Operations on POSIX Shared Memory Objects. - */ -struct POSIX_Shm_Object_operations { - /** - * @brief Allocates a new @a shm_obj with initial @a size. - * - * New shared memory is initialized to zeroes. - * - * Returns 0 for success. - */ - int ( *object_create ) ( POSIX_Shm_Object *shm_obj, size_t size ); - - /** - * @brief Changes the @a shm_obj size to @a size. - * - * Zeroes out the portion of the shared memory object that shrinks or grows. - * - * Returns 0 for success. - */ - int ( *object_resize ) ( POSIX_Shm_Object *shm_obj, size_t size ); - - /** - * @brief Deletes the @a shm_obj. - * - * Zeroes out the memory. - * - * Returns 0 for success. - */ - int ( *object_delete ) ( POSIX_Shm_Object *shm_obj ); - - /** - * @brief Copies up to @count bytes of the @a shm_obj data into @a buf. - * - * Returns the number of bytes read (copied) into @a buf. - */ - int ( *object_read ) ( POSIX_Shm_Object *shm_obj, void *buf, size_t count ); - - /** - * @brief Maps a shared memory object. - * - * Establishes a memory mapping between the shared memory object and the - * caller. - * - * Returns the mapped address of the object. - */ - void * ( *object_mmap ) ( POSIX_Shm_Object *shm_obj, size_t len, int prot, off_t off); -}; - -/** - * @brief Control for a POSIX Shared Memory Object - */ -typedef struct { - Objects_Control Object; - Thread_queue_Control Wait_queue; - - int reference_count; - - POSIX_Shm_Object shm_object; - - uid_t uid; - gid_t gid; - mode_t mode; - int oflag; - - time_t atime; - time_t mtime; - time_t ctime; -} POSIX_Shm_Control; - -/** - * @brief object_create operation for shm objects stored in RTEMS Workspace. - */ -extern int _POSIX_Shm_Object_create_from_workspace( - POSIX_Shm_Object *shm_obj, - size_t size -); - -/** - * @brief object_delete operation for shm objects stored in RTEMS Workspace. - */ -extern int _POSIX_Shm_Object_delete_from_workspace( POSIX_Shm_Object *shm_obj ); - -/** - * @brief object_resize operation for shm objects stored in RTEMS Workspace. - */ -extern int _POSIX_Shm_Object_resize_from_workspace( - POSIX_Shm_Object *shm_obj, - size_t size -); - -/** - * @brief object_read operation for shm objects stored in RTEMS Workspace. - */ -extern int _POSIX_Shm_Object_read_from_workspace( - POSIX_Shm_Object *shm_obj, - void *buf, - size_t count -); - -/** - * @brief object_mmap operation for shm objects stored in RTEMS Workspace. - */ -extern void * _POSIX_Shm_Object_mmap_from_workspace( - POSIX_Shm_Object *shm_obj, - size_t len, - int prot, - off_t off -); - -/** - * @brief object_create operation for shm objects stored in C program heap. - */ -extern int _POSIX_Shm_Object_create_from_heap( - POSIX_Shm_Object *shm_obj, - size_t size -); - -/** - * @brief object_delete operation for shm objects stored in C program heap. - */ -extern int _POSIX_Shm_Object_delete_from_heap( POSIX_Shm_Object *shm_obj ); - -/** - * @brief object_resize operation for shm objects stored in C program heap. - */ -extern int _POSIX_Shm_Object_resize_from_heap( - POSIX_Shm_Object *shm_obj, - size_t size -); - -/** - * @brief object_read operation for shm objects stored in C program heap. - */ -extern int _POSIX_Shm_Object_read_from_heap( - POSIX_Shm_Object *shm_obj, - void *buf, - size_t count -); - -/** - * @brief object_mmap operation for shm objects stored in C program heap. - */ -extern void * _POSIX_Shm_Object_mmap_from_heap( - POSIX_Shm_Object *shm_obj, - size_t len, - int prot, - off_t off -); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/posix/include/rtems/posix/shmimpl.h b/cpukit/posix/include/rtems/posix/shmimpl.h deleted file mode 100644 index f16af8123d..0000000000 --- a/cpukit/posix/include/rtems/posix/shmimpl.h +++ /dev/null @@ -1,135 +0,0 @@ -/** - * @file - * - * @brief Private Support Information for POSIX Shared Memory - * - */ - -/* - * Copyright (c) 2016 Gedare Bloom. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_POSIX_SHMIMPL_H -#define _RTEMS_POSIX_SHMIMPL_H - -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @ingroup POSIXShmPrivate - * @{ - */ - -extern Objects_Information _POSIX_Shm_Information; - -RTEMS_INLINE_ROUTINE POSIX_Shm_Control *_POSIX_Shm_Allocate_unprotected( void ) -{ - return (POSIX_Shm_Control *) - _Objects_Allocate_unprotected( &_POSIX_Shm_Information ); -} - -/** - * @brief POSIX Shared Memory Free - * - * This routine frees a shm control block. - */ -RTEMS_INLINE_ROUTINE void _POSIX_Shm_Free ( - POSIX_Shm_Control *the_shm -) -{ - _Objects_Free( &_POSIX_Shm_Information, &the_shm->Object ); -} - -RTEMS_INLINE_ROUTINE POSIX_Shm_Control *_POSIX_Shm_Get_by_name( - const char *name, - size_t *name_length_p, - Objects_Get_by_name_error *error -) -{ - return (POSIX_Shm_Control *) _Objects_Get_by_name( - &_POSIX_Shm_Information, - name, - name_length_p, - error - ); -} - -RTEMS_INLINE_ROUTINE void _POSIX_Shm_Update_atime( - POSIX_Shm_Control *shm -) -{ - struct timeval now; - gettimeofday( &now, 0 ); - shm->atime = now.tv_sec; -} - -RTEMS_INLINE_ROUTINE void _POSIX_Shm_Update_mtime_ctime( - POSIX_Shm_Control *shm -) -{ - struct timeval now; - gettimeofday( &now, 0 ); - shm->mtime = now.tv_sec; - shm->ctime = now.tv_sec; -} - -static inline POSIX_Shm_Control* iop_to_shm( rtems_libio_t *iop ) -{ - return (POSIX_Shm_Control*) iop->data1; -} - -static inline POSIX_Shm_Control* loc_to_shm( - const rtems_filesystem_location_info_t *loc -) -{ - return (POSIX_Shm_Control*) loc->node_access; -} - -static inline int POSIX_Shm_Attempt_delete( - POSIX_Shm_Control* shm -) -{ - Objects_Control *obj; - ISR_lock_Context lock_ctx; - int err; - - err = 0; - - _Objects_Allocator_lock(); - --shm->reference_count; - if ( shm->reference_count == 0 ) { - if ( (*shm->shm_object.ops->object_delete)( &shm->shm_object ) != 0 ) { - err = EIO; - } - } - /* check if the object has been unlinked yet. */ - obj = _Objects_Get( shm->Object.id, &lock_ctx, &_POSIX_Shm_Information ); - if ( obj == NULL ) { - /* if it was unlinked, then it can be freed. */ - _POSIX_Shm_Free( shm ); - } else { - /* it will be freed when it is unlinked. */ - _ISR_lock_ISR_enable( &lock_ctx ); - } - _Objects_Allocator_unlock(); - return err; -} - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/posix/include/rtems/posix/sigset.h b/cpukit/posix/include/rtems/posix/sigset.h deleted file mode 100644 index 96bcc086ba..0000000000 --- a/cpukit/posix/include/rtems/posix/sigset.h +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @file - * - * @brief POSIX Signal Sets Management Helper - * - * This file defines the interface to implementation helper for management - * of POSIX Signal Sets. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_POSIX_SIGSET_H -#define _RTEMS_POSIX_SIGSET_H - -#include // sigset_t - -/* - * Currently 32 signals numbered 1-32 are defined - */ - -#define SIGNAL_EMPTY_MASK 0x00000000L -#define SIGNAL_ALL_MASK 0xffffffffL - -static inline sigset_t signo_to_mask( - uint32_t sig -) -{ - return 1u << (sig - 1); -} - -static inline bool is_valid_signo( - int signo -) -{ - return ((signo) >= 1 && (signo) <= 32 ); -} - -#endif diff --git a/cpukit/posix/include/rtems/posix/spinlockimpl.h b/cpukit/posix/include/rtems/posix/spinlockimpl.h deleted file mode 100644 index d28e0391fc..0000000000 --- a/cpukit/posix/include/rtems/posix/spinlockimpl.h +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @file - * - * @brief Inlined Routines from the POSIX Spinlock Manager - * - * This file contains the static inlin implementation of the inlined - * routines from the POSIX Spinlock Manager. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * Copyright (c) 2016 embedded brains GmbH - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_POSIX_SPINLOCKIMPL_H -#define _RTEMS_POSIX_SPINLOCKIMPL_H - -#include - -#include - -#if defined(RTEMS_SMP) -#include -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { -#if defined(RTEMS_SMP) - SMP_ticket_lock_Control Lock; -#else - unsigned int reserved[ 2 ]; -#endif - ISR_Level interrupt_state; -} POSIX_Spinlock_Control; - -RTEMS_INLINE_ROUTINE POSIX_Spinlock_Control *_POSIX_Spinlock_Get( - pthread_spinlock_t *lock -) -{ - return (POSIX_Spinlock_Control *) lock; -} - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/posix/include/rtems/posix/threadsup.h b/cpukit/posix/include/rtems/posix/threadsup.h deleted file mode 100644 index d3ee5b28bb..0000000000 --- a/cpukit/posix/include/rtems/posix/threadsup.h +++ /dev/null @@ -1,98 +0,0 @@ -/** - * @file - * - * @brief POSIX Thread API Support - * - * This defines the POSIX thread API extension. - */ - -/* - * COPYRIGHT (c) 1989-2014. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_POSIX_THREADSUP_H -#define _RTEMS_POSIX_THREADSUP_H - -#include -#include - -#include -#include - -/** - * @defgroup POSIX_THREAD POSIX Thread API Extension - * - * @ingroup POSIXAPI - * - */ -/**@{**/ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * This defines the POSIX API support structure associated with - * each thread in a system with POSIX configured. - */ -typedef struct { - /** - * @brief Control block for the sporadic server scheduling policy. - */ - struct { - /** The thread of this sporadic control block */ - Thread_Control *thread; - - /** - * @brief This is the timer which controls when the thread executes at high - * and low priority when using the sporadic server scheduling policy. - */ - Watchdog_Control Timer; - - /** - * @brief The low priority when using the sporadic server scheduling - * policy. - */ - Priority_Node Low_priority; - - /** - * @brief Replenishment period for sporadic server. - */ - struct timespec sched_ss_repl_period; - - /** - * @brief Initial budget for sporadic server. - */ - struct timespec sched_ss_init_budget; - - /** - * @brief Maximum pending replenishments. - * - * Only used by pthread_getschedparam() and pthread_getattr_np(). - */ - int sched_ss_max_repl; - } Sporadic; - - /** This is the set of signals which are currently unblocked. */ - sigset_t signals_unblocked; - /** This is the set of signals which are currently pending. */ - sigset_t signals_pending; - - /** - * @brief Signal post-switch action in case signals are pending. - */ - Thread_Action Signal_action; -} POSIX_API_Control; - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/posix/include/rtems/posix/timer.h b/cpukit/posix/include/rtems/posix/timer.h deleted file mode 100644 index 79fe093219..0000000000 --- a/cpukit/posix/include/rtems/posix/timer.h +++ /dev/null @@ -1,60 +0,0 @@ -/** - * @file - * - * @brief POSIX Timers Internal Support - * - * This include files defines the internal support for implementation of - * POSIX Timers. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_POSIX_TIMER_H -#define _RTEMS_POSIX_TIMER_H - -#include -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup POSIX_INTERNAL_TIMERS POSIX Timer Private Support - * - * @ingroup POSIXAPI - */ -/**@{*/ - -/* - * Data for a timer - */ -typedef struct { - Objects_Control Object; - Watchdog_Control Timer; /* Internal Timer */ - pthread_t thread_id; /* Thread identifier */ - char state; /* State of the timer */ - struct sigevent inf; /* Information associated to the timer */ - struct itimerspec timer_data; /* Timing data of the timer */ - uint32_t ticks; /* Number of ticks of the initialization */ - uint32_t overrun; /* Number of expirations of the timer */ - struct timespec time; /* Time at which the timer was started */ -} POSIX_Timer_Control; - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/posix/include/rtems/posix/timerimpl.h b/cpukit/posix/include/rtems/posix/timerimpl.h deleted file mode 100644 index 42a814c992..0000000000 --- a/cpukit/posix/include/rtems/posix/timerimpl.h +++ /dev/null @@ -1,134 +0,0 @@ -/** - * @file - * - * @brief Inlined Routines from the POSIX Timer Manager - * - * This file contains the static inline implementation of the inlined routines - * from the POSIX Timer Manager. - */ - -/* - * COPYRIGHT (c) 1989-2013. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_POSIX_TIMERIMPL_H -#define _RTEMS_POSIX_TIMERIMPL_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** Timer is free */ -#define POSIX_TIMER_STATE_FREE 0x01 - -/** Created timer but not running */ -#define POSIX_TIMER_STATE_CREATE_NEW 0x02 - -/** Created timer and running */ -#define POSIX_TIMER_STATE_CREATE_RUN 0x03 - -/** Created, ran and stopped timer */ -#define POSIX_TIMER_STATE_CREATE_STOP 0x04 - -/** Indicates that the fire time is relative to the current one */ -#define POSIX_TIMER_RELATIVE 0 - -/* - * POSIX defines TIMER_ABSTIME but no constant for relative. So - * we have one internally but we need to be careful it has a different - * value. - */ -#if (POSIX_TIMER_RELATIVE == TIMER_ABSTIME) -#error "POSIX_TIMER_RELATIVE == TIMER_ABSTIME" -#endif - -/** - * The following defines the information control block used to manage - * this class of objects. - */ -extern Objects_Information _POSIX_Timer_Information; - -/** - * @brief POSIX Timer Allocate - * - * This function allocates a timer control block from - * the inactive chain of free timer control blocks. - */ -RTEMS_INLINE_ROUTINE POSIX_Timer_Control *_POSIX_Timer_Allocate( void ) -{ - return (POSIX_Timer_Control *) _Objects_Allocate( &_POSIX_Timer_Information ); -} - -/** - * @brief POSIX Timer Free - * - * This routine frees a timer control block to the - * inactive chain of free timer control blocks. - */ -RTEMS_INLINE_ROUTINE void _POSIX_Timer_Free ( - POSIX_Timer_Control *the_timer -) -{ - _Objects_Free( &_POSIX_Timer_Information, &the_timer->Object ); -} - -void _POSIX_Timer_TSR( Watchdog_Control *the_watchdog ); - -/** - * @brief POSIX Timer Get - * - * This function maps timer IDs to timer control blocks. - * If ID corresponds to a local timer, then it returns - * the timer control pointer which maps to ID and location - * is set to OBJECTS_LOCAL. Otherwise, location is set - * to OBJECTS_ERROR and the returned value is undefined. - */ -RTEMS_INLINE_ROUTINE POSIX_Timer_Control *_POSIX_Timer_Get ( - timer_t id, - ISR_lock_Context *lock_context -) -{ - return (POSIX_Timer_Control *) _Objects_Get( - (Objects_Id) id, - lock_context, - &_POSIX_Timer_Information - ); -} - -RTEMS_INLINE_ROUTINE Per_CPU_Control *_POSIX_Timer_Acquire_critical( - POSIX_Timer_Control *ptimer, - ISR_lock_Context *lock_context -) -{ - Per_CPU_Control *cpu; - - cpu = _Watchdog_Get_CPU( &ptimer->Timer ); - _Watchdog_Per_CPU_acquire_critical( cpu, lock_context ); - - return cpu; -} - -RTEMS_INLINE_ROUTINE void _POSIX_Timer_Release( - Per_CPU_Control *cpu, - ISR_lock_Context *lock_context -) -{ - _Watchdog_Per_CPU_release_critical( cpu, lock_context ); - _ISR_lock_ISR_enable( lock_context ); -} - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/posix/preinstall.am b/cpukit/posix/preinstall.am deleted file mode 100644 index d96cbf75a7..0000000000 --- a/cpukit/posix/preinstall.am +++ /dev/null @@ -1,146 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -$(PROJECT_INCLUDE)/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE) - @: > $(PROJECT_INCLUDE)/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/posix/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/posix - @: > $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/posix/sigset.h: include/rtems/posix/sigset.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/sigset.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/sigset.h - -$(PROJECT_INCLUDE)/rtems/posix/barrierimpl.h: include/rtems/posix/barrierimpl.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/barrierimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/barrierimpl.h - -$(PROJECT_INCLUDE)/rtems/posix/condimpl.h: include/rtems/posix/condimpl.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/condimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/condimpl.h - -$(PROJECT_INCLUDE)/rtems/posix/key.h: include/rtems/posix/key.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/key.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/key.h - -$(PROJECT_INCLUDE)/rtems/posix/keyimpl.h: include/rtems/posix/keyimpl.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/keyimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/keyimpl.h - -$(PROJECT_INCLUDE)/rtems/posix/config.h: include/rtems/posix/config.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/config.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/config.h - -$(PROJECT_INCLUDE)/rtems/posix/muteximpl.h: include/rtems/posix/muteximpl.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/muteximpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/muteximpl.h - -$(PROJECT_INCLUDE)/rtems/posix/posixapi.h: include/rtems/posix/posixapi.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/posixapi.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/posixapi.h - -$(PROJECT_INCLUDE)/rtems/posix/priorityimpl.h: include/rtems/posix/priorityimpl.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/priorityimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/priorityimpl.h - -$(PROJECT_INCLUDE)/rtems/posix/pthreadattrimpl.h: include/rtems/posix/pthreadattrimpl.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/pthreadattrimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/pthreadattrimpl.h - -$(PROJECT_INCLUDE)/rtems/posix/rwlockimpl.h: include/rtems/posix/rwlockimpl.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/rwlockimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/rwlockimpl.h - -$(PROJECT_INCLUDE)/rtems/posix/semaphore.h: include/rtems/posix/semaphore.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/semaphore.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/semaphore.h - -$(PROJECT_INCLUDE)/rtems/posix/semaphoreimpl.h: include/rtems/posix/semaphoreimpl.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/semaphoreimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/semaphoreimpl.h - -$(PROJECT_INCLUDE)/rtems/posix/spinlockimpl.h: include/rtems/posix/spinlockimpl.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/spinlockimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/spinlockimpl.h - -if HAS_PTHREADS -$(PROJECT_INCLUDE)/aio.h: include/aio.h $(PROJECT_INCLUDE)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/aio.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/aio.h - -$(PROJECT_INCLUDE)/mqueue.h: include/mqueue.h $(PROJECT_INCLUDE)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/mqueue.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/mqueue.h - -$(PROJECT_INCLUDE)/rtems/posix/aio_misc.h: include/rtems/posix/aio_misc.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/aio_misc.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/aio_misc.h - -$(PROJECT_INCLUDE)/rtems/posix/mmanimpl.h: include/rtems/posix/mmanimpl.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/mmanimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/mmanimpl.h - -$(PROJECT_INCLUDE)/rtems/posix/mqueue.h: include/rtems/posix/mqueue.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/mqueue.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/mqueue.h - -$(PROJECT_INCLUDE)/rtems/posix/mqueueimpl.h: include/rtems/posix/mqueueimpl.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/mqueueimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/mqueueimpl.h - -$(PROJECT_INCLUDE)/rtems/posix/psignal.h: include/rtems/posix/psignal.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/psignal.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/psignal.h - -$(PROJECT_INCLUDE)/rtems/posix/psignalimpl.h: include/rtems/posix/psignalimpl.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/psignalimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/psignalimpl.h - -$(PROJECT_INCLUDE)/rtems/posix/pthread.h: include/rtems/posix/pthread.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/pthread.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/pthread.h - -$(PROJECT_INCLUDE)/rtems/posix/pthreadimpl.h: include/rtems/posix/pthreadimpl.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/pthreadimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/pthreadimpl.h - -$(PROJECT_INCLUDE)/rtems/posix/ptimer.h: include/rtems/posix/ptimer.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/ptimer.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/ptimer.h - -$(PROJECT_INCLUDE)/rtems/posix/shm.h: include/rtems/posix/shm.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/shm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/shm.h - -$(PROJECT_INCLUDE)/rtems/posix/shmimpl.h: include/rtems/posix/shmimpl.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/shmimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/shmimpl.h - -$(PROJECT_INCLUDE)/rtems/posix/threadsup.h: include/rtems/posix/threadsup.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/threadsup.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/threadsup.h - -$(PROJECT_INCLUDE)/rtems/posix/timer.h: include/rtems/posix/timer.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/timer.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/timer.h - -$(PROJECT_INCLUDE)/rtems/posix/timerimpl.h: include/rtems/posix/timerimpl.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/timerimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/timerimpl.h -endif diff --git a/cpukit/pppd/Makefile.am b/cpukit/pppd/Makefile.am index 2cf38edc69..53a05761f4 100644 --- a/cpukit/pppd/Makefile.am +++ b/cpukit/pppd/Makefile.am @@ -1,10 +1,12 @@ include $(top_srcdir)/automake/compile.am if LIBNETWORKING -include_rtemsdir = $(includedir)/rtems -include_rtems_HEADERS = rtemspppd.h rtemsdialer.h - project_lib_LIBRARIES = libpppd.a + +$(PROJECT_LIB)/libpppd.a: libpppd.a + $(INSTALL_DATA) $< $(PROJECT_LIB)/libpppd.a +TMPINSTALL_FILES = $(PROJECT_LIB)/libpppd.a + libpppd_a_SOURCES = auth.c ccp.c ccp.h chap.c chap.h chap_ms.c chap_ms.h \ chat.c demand.c fsm.c fsm.h ipcp.c ipcp.h lcp.c lcp.h magic.c magic.h \ options.c upap.c upap.h utils.c sys-rtems.c \ @@ -13,5 +15,4 @@ libpppd_a_SOURCES = auth.c ccp.c ccp.h chap.c chap.h chap_ms.c chap_ms.h \ libpppd_a_CPPFLAGS = $(AM_CPPFLAGS) -D__BSD_VISIBLE -I$(srcdir)/../libmd endif -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am diff --git a/cpukit/pppd/preinstall.am b/cpukit/pppd/preinstall.am deleted file mode 100644 index 19f4bc1dda..0000000000 --- a/cpukit/pppd/preinstall.am +++ /dev/null @@ -1,43 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -all-local: $(TMPINSTALL_FILES) - -TMPINSTALL_FILES = -CLEANFILES += $(TMPINSTALL_FILES) - -$(PROJECT_LIB)/$(dirstamp): - @$(MKDIR_P) $(PROJECT_LIB) - @: > $(PROJECT_LIB)/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_LIB)/$(dirstamp) - -if LIBNETWORKING -$(PROJECT_INCLUDE)/rtems/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems - @: > $(PROJECT_INCLUDE)/rtems/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/rtemspppd.h: rtemspppd.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtemspppd.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtemspppd.h - -$(PROJECT_INCLUDE)/rtems/rtemsdialer.h: rtemsdialer.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtemsdialer.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtemsdialer.h - -$(PROJECT_LIB)/libpppd.a: libpppd.a $(PROJECT_LIB)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_LIB)/libpppd.a -TMPINSTALL_FILES += $(PROJECT_LIB)/libpppd.a -endif diff --git a/cpukit/pppd/rtemsdialer.h b/cpukit/pppd/rtemsdialer.h deleted file mode 100644 index 611986b802..0000000000 --- a/cpukit/pppd/rtemsdialer.h +++ /dev/null @@ -1,24 +0,0 @@ - -#ifndef DIALER_H -#define DIALER_H - -/* define constant mode values */ -#define DIALER_INIT 0 -#define DIALER_CONNECT 1 -#define DIALER_WELCOME 2 -#define DIALER_DISCONNECT 3 - -/* define constant return values */ -#define DIALER_SUCCESS 0 -#define DIALER_INVALIDARG 1 -#define DIALER_UNEXPECTED 2 -#define DIALER_TIMEOUT 3 -#define DIALER_CMDFAILED 4 - -/* define typedef for dialer function prototype */ -typedef int (*dialerfp)(int tty, int mode, char *pScript); - -/* declare default chat program dialer */ -extern int chatmain(int tty, int mode, char *pScript); - -#endif diff --git a/cpukit/pppd/rtemspppd.h b/cpukit/pppd/rtemspppd.h deleted file mode 100644 index a6c8d0b398..0000000000 --- a/cpukit/pppd/rtemspppd.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * COPYRIGHT (c) 2001, Michael Siers . - * Poliac Research, Burnsville, Minnesota USA. - * COPYRIGHT (c) 2001, On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef RTEMSPPPD_H -#define RTEMSPPPD_H - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* define hook function identifiers */ -#define RTEMS_PPPD_LINKUP_HOOK 1 -#define RTEMS_PPPD_LINKDOWN_HOOK 2 -#define RTEMS_PPPD_IPUP_HOOK 3 -#define RTEMS_PPPD_IPDOWN_HOOK 4 -#define RTEMS_PPPD_ERROR_HOOK 5 -#define RTEMS_PPPD_EXIT_HOOK 6 - -/* define hook function pointer prototype */ -typedef void (*rtems_pppd_hookfunction)(void); -typedef int (*rtems_pppd_dialerfunction)(int tty, int mode, char *pScript); - - -/* define pppd function prototyes */ -int rtems_pppd_initialize(void); -int rtems_pppd_terminate(void); -int rtems_pppd_reset_options(void); -int rtems_pppd_set_hook(int id, rtems_pppd_hookfunction hookfp); -int rtems_pppd_set_dialer(rtems_pppd_dialerfunction dialerfp); -int rtems_pppd_set_option(const char *pOption, const char *pValue); -int rtems_pppd_connect(void); -int rtems_pppd_disconnect(void); - -struct rtems_bsdnet_ifconfig; - -int rtems_ppp_driver_attach(struct rtems_bsdnet_ifconfig *config, int attaching); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/cpukit/preinstall.am b/cpukit/preinstall.am deleted file mode 100644 index fd26535031..0000000000 --- a/cpukit/preinstall.am +++ /dev/null @@ -1,751 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES += $(PREINSTALL_FILES) - -$(PROJECT_INCLUDE)/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE) - @: > $(PROJECT_INCLUDE)/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/$(dirstamp) - -$(PROJECT_INCLUDE)/endian.h: include/endian.h $(PROJECT_INCLUDE)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/endian.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/endian.h - -$(PROJECT_INCLUDE)/zconf.h: include/zconf.h $(PROJECT_INCLUDE)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/zconf.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/zconf.h - -$(PROJECT_INCLUDE)/rtems/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems - @: > $(PROJECT_INCLUDE)/rtems/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/rtems - @: > $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - -$(PROJECT_INCLUDE)/uuid/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/uuid - @: > $(PROJECT_INCLUDE)/uuid/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/uuid/$(dirstamp) - -$(PROJECT_INCLUDE)/uuid/uuid.h: libmisc/uuid/uuid.h $(PROJECT_INCLUDE)/uuid/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/uuid/uuid.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/uuid/uuid.h - -$(PROJECT_INCLUDE)/utf8proc/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/utf8proc - @: > $(PROJECT_INCLUDE)/utf8proc/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/utf8proc/$(dirstamp) - -$(PROJECT_INCLUDE)/utf8proc/utf8proc.h: libmisc/utf8proc/utf8proc.h $(PROJECT_INCLUDE)/utf8proc/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/utf8proc/utf8proc.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/utf8proc/utf8proc.h - -$(PROJECT_INCLUDE)/sys/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/sys - @: > $(PROJECT_INCLUDE)/sys/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/sys/$(dirstamp) - -$(PROJECT_INCLUDE)/crypt.h: include/crypt.h $(PROJECT_INCLUDE)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/crypt.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/crypt.h - -$(PROJECT_INCLUDE)/memory.h: include/memory.h $(PROJECT_INCLUDE)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/memory.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/memory.h - -$(PROJECT_INCLUDE)/xz.h: libmisc/xz/xz.h $(PROJECT_INCLUDE)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/xz.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/xz.h - -$(PROJECT_INCLUDE)/sys/event.h: libcsupport/include/sys/event.h $(PROJECT_INCLUDE)/sys/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/event.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/event.h - -$(PROJECT_INCLUDE)/sys/poll.h: libcsupport/include/sys/poll.h $(PROJECT_INCLUDE)/sys/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/poll.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/poll.h - -$(PROJECT_INCLUDE)/sys/statvfs.h: libcsupport/include/sys/statvfs.h $(PROJECT_INCLUDE)/sys/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/statvfs.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/statvfs.h - -$(PROJECT_INCLUDE)/sys/utsname.h: libcsupport/include/sys/utsname.h $(PROJECT_INCLUDE)/sys/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/utsname.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/utsname.h - -$(PROJECT_INCLUDE)/sys/endian.h: include/sys/endian.h $(PROJECT_INCLUDE)/sys/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/endian.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/endian.h - -$(PROJECT_INCLUDE)/sys/priority.h: include/sys/priority.h $(PROJECT_INCLUDE)/sys/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/priority.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/priority.h - -if LIBNETWORKING -$(PROJECT_INCLUDE)/rtems/bsdnet/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/bsdnet - @: > $(PROJECT_INCLUDE)/rtems/bsdnet/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/bsdnet/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/bsdnet/servers.h: libnetworking/rtems/bsdnet/servers.h $(PROJECT_INCLUDE)/rtems/bsdnet/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/bsdnet/servers.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/bsdnet/servers.h - -$(PROJECT_INCLUDE)/rtems/bsdnet/_types.h: libnetworking/rtems/bsdnet/_types.h $(PROJECT_INCLUDE)/rtems/bsdnet/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/bsdnet/_types.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/bsdnet/_types.h -endif -if LIBDL -$(PROJECT_INCLUDE)/dlfcn.h: libdl/dlfcn.h $(PROJECT_INCLUDE)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/dlfcn.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/dlfcn.h - -$(PROJECT_INCLUDE)/link.h: libdl/include/link.h $(PROJECT_INCLUDE)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/link.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/link.h - -$(PROJECT_INCLUDE)/link_elf.h: libdl/include/link_elf.h $(PROJECT_INCLUDE)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/link_elf.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/link_elf.h - -$(PROJECT_INCLUDE)/sys/cdefs_elf.h: libdl/include/sys/cdefs_elf.h $(PROJECT_INCLUDE)/sys/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/cdefs_elf.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/cdefs_elf.h - -$(PROJECT_INCLUDE)/sys/exec_elf.h: libdl/include/sys/exec_elf.h $(PROJECT_INCLUDE)/sys/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/exec_elf.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/exec_elf.h - -$(PROJECT_INCLUDE)/machine/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/machine - @: > $(PROJECT_INCLUDE)/machine/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/machine/$(dirstamp) - -$(PROJECT_INCLUDE)/machine/elf_machdep.h: libdl/include/arch/@RTEMS_CPU@/machine/elf_machdep.h $(PROJECT_INCLUDE)/machine/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/machine/elf_machdep.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/machine/elf_machdep.h - -$(PROJECT_INCLUDE)/rtems/rtl/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/rtl - @: > $(PROJECT_INCLUDE)/rtems/rtl/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/rtl/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/rtl/dlfcn-shell.h: libdl/dlfcn-shell.h $(PROJECT_INCLUDE)/rtems/rtl/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtl/dlfcn-shell.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtl/dlfcn-shell.h - -$(PROJECT_INCLUDE)/rtems/rtl/rtl.h: libdl/rtl.h $(PROJECT_INCLUDE)/rtems/rtl/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtl/rtl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtl/rtl.h - -$(PROJECT_INCLUDE)/rtems/rtl/rtl-allocator.h: libdl/rtl-allocator.h $(PROJECT_INCLUDE)/rtems/rtl/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtl/rtl-allocator.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtl/rtl-allocator.h - -$(PROJECT_INCLUDE)/rtems/rtl/rtl-obj-fwd.h: libdl/rtl-obj-fwd.h $(PROJECT_INCLUDE)/rtems/rtl/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtl/rtl-obj-fwd.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtl/rtl-obj-fwd.h - -$(PROJECT_INCLUDE)/rtems/rtl/rtl-fwd.h: libdl/rtl-fwd.h $(PROJECT_INCLUDE)/rtems/rtl/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtl/rtl-fwd.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtl/rtl-fwd.h - -$(PROJECT_INCLUDE)/rtems/rtl/rtl-obj.h: libdl/rtl-obj.h $(PROJECT_INCLUDE)/rtems/rtl/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtl/rtl-obj.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtl/rtl-obj.h - -$(PROJECT_INCLUDE)/rtems/rtl/rtl-obj-cache.h: libdl/rtl-obj-cache.h $(PROJECT_INCLUDE)/rtems/rtl/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtl/rtl-obj-cache.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtl/rtl-obj-cache.h - -$(PROJECT_INCLUDE)/rtems/rtl/rtl-obj-comp.h: libdl/rtl-obj-comp.h $(PROJECT_INCLUDE)/rtems/rtl/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtl/rtl-obj-comp.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtl/rtl-obj-comp.h - -$(PROJECT_INCLUDE)/rtems/rtl/rtl-unresolved.h: libdl/rtl-unresolved.h $(PROJECT_INCLUDE)/rtems/rtl/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtl/rtl-unresolved.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtl/rtl-unresolved.h - -$(PROJECT_INCLUDE)/rtems/rtl/rtl-indirect-ptr.h: libdl/rtl-indirect-ptr.h $(PROJECT_INCLUDE)/rtems/rtl/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtl/rtl-indirect-ptr.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtl/rtl-indirect-ptr.h - -$(PROJECT_INCLUDE)/rtems/rtl/rtl-sym.h: libdl/rtl-sym.h $(PROJECT_INCLUDE)/rtems/rtl/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtl/rtl-sym.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtl/rtl-sym.h - -$(PROJECT_INCLUDE)/rtems/rtl/rtl-trace.h: libdl/rtl-trace.h $(PROJECT_INCLUDE)/rtems/rtl/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtl/rtl-trace.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtl/rtl-trace.h - -$(PROJECT_INCLUDE)/rtems/rtl/rap.h: libdl/rap.h $(PROJECT_INCLUDE)/rtems/rtl/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtl/rap.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtl/rap.h - -$(PROJECT_INCLUDE)/rtems/rtl/rap-shell.h: libdl/rap-shell.h $(PROJECT_INCLUDE)/rtems/rtl/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtl/rap-shell.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtl/rap-shell.h -endif -if LIBDEBUGGER -$(PROJECT_INCLUDE)/rtems/rtems-debugger.h: libdebugger/rtems-debugger.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems-debugger.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems-debugger.h - -$(PROJECT_INCLUDE)/rtems/debugger/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/debugger - @: > $(PROJECT_INCLUDE)/rtems/debugger/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/debugger/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/debugger/rtems-debugger-server.h: libdebugger/rtems-debugger-server.h $(PROJECT_INCLUDE)/rtems/debugger/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/debugger/rtems-debugger-server.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/debugger/rtems-debugger-server.h - -$(PROJECT_INCLUDE)/rtems/debugger/rtems-debugger-remote.h: libdebugger/rtems-debugger-remote.h $(PROJECT_INCLUDE)/rtems/debugger/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/debugger/rtems-debugger-remote.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/debugger/rtems-debugger-remote.h -endif -$(PROJECT_INCLUDE)/rtems/bspIo.h: include/rtems/bspIo.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/bspIo.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/bspIo.h - -$(PROJECT_INCLUDE)/rtems/inttypes.h: include/rtems/inttypes.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/inttypes.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/inttypes.h - -$(PROJECT_INCLUDE)/rtems/print.h: include/rtems/print.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/print.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/print.h - -$(PROJECT_INCLUDE)/rtems/printer.h: include/rtems/printer.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/printer.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/printer.h - -$(PROJECT_INCLUDE)/rtems/userenv.h: include/rtems/userenv.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/userenv.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/userenv.h - -$(PROJECT_INCLUDE)/rtems/fs.h: include/rtems/fs.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/fs.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/fs.h - -if !LIBPCI -$(PROJECT_INCLUDE)/rtems/pci.h: include/rtems/pci.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/pci.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/pci.h -endif -$(PROJECT_INCLUDE)/rtems/concat.h: include/rtems/concat.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/concat.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/concat.h - -$(PROJECT_INCLUDE)/rtems/status-checks.h: include/rtems/status-checks.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/status-checks.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/status-checks.h - -$(PROJECT_INCLUDE)/rtems/endian.h: include/rtems/endian.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/endian.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/endian.h - -$(PROJECT_INCLUDE)/rtems/btimer.h: include/rtems/btimer.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/btimer.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/btimer.h - -$(PROJECT_INCLUDE)/rtems/console.h: include/rtems/console.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/console.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/console.h - -$(PROJECT_INCLUDE)/rtems/clockdrv.h: include/rtems/clockdrv.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/clockdrv.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/clockdrv.h - -$(PROJECT_INCLUDE)/rtems/framebuffer.h: include/rtems/framebuffer.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/framebuffer.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/framebuffer.h - -$(PROJECT_INCLUDE)/rtems/rtc.h: include/rtems/rtc.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtc.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtc.h - -$(PROJECT_INCLUDE)/rtems/watchdogdrv.h: include/rtems/watchdogdrv.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/watchdogdrv.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/watchdogdrv.h - -$(PROJECT_INCLUDE)/rtems/irq.h: include/rtems/irq.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/irq.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/irq.h - -$(PROJECT_INCLUDE)/rtems/irq-extension.h: include/rtems/irq-extension.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/irq-extension.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/irq-extension.h - -$(PROJECT_INCLUDE)/rtems/imfs.h: libfs/src/imfs/imfs.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/imfs.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/imfs.h - -$(PROJECT_INCLUDE)/rtems/pipe.h: libfs/src/pipe/pipe.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/pipe.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/pipe.h - -$(PROJECT_INCLUDE)/rtems/devfs.h: libfs/src/devfs/devfs.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/devfs.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/devfs.h - -if LIBDOSFS -$(PROJECT_INCLUDE)/rtems/dosfs.h: libfs/src/dosfs/dosfs.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/dosfs.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/dosfs.h -endif -$(PROJECT_INCLUDE)/rtems/rtems-rfs.h: libfs/src/rfs/rtems-rfs.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems-rfs.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems-rfs.h - -$(PROJECT_INCLUDE)/rtems/rtems-rfs-format.h: libfs/src/rfs/rtems-rfs-format.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems-rfs-format.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems-rfs-format.h - -$(PROJECT_INCLUDE)/rtems/rtems-rfs-shell.h: libfs/src/rfs/rtems-rfs-shell.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems-rfs-shell.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems-rfs-shell.h - -$(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/rfs - @: > $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-bitmaps.h: libfs/src/rfs/rtems-rfs-bitmaps.h $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-bitmaps.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-bitmaps.h - -$(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-block-pos.h: libfs/src/rfs/rtems-rfs-block-pos.h $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-block-pos.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-block-pos.h - -$(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-block.h: libfs/src/rfs/rtems-rfs-block.h $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-block.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-block.h - -$(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-buffer.h: libfs/src/rfs/rtems-rfs-buffer.h $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-buffer.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-buffer.h - -$(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-data.h: libfs/src/rfs/rtems-rfs-data.h $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-data.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-data.h - -$(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-dir.h: libfs/src/rfs/rtems-rfs-dir.h $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-dir.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-dir.h - -$(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-dir-hash.h: libfs/src/rfs/rtems-rfs-dir-hash.h $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-dir-hash.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-dir-hash.h - -$(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-file.h: libfs/src/rfs/rtems-rfs-file.h $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-file.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-file.h - -$(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-file-system-fwd.h: libfs/src/rfs/rtems-rfs-file-system-fwd.h $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-file-system-fwd.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-file-system-fwd.h - -$(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-file-system.h: libfs/src/rfs/rtems-rfs-file-system.h $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-file-system.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-file-system.h - -$(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-group.h: libfs/src/rfs/rtems-rfs-group.h $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-group.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-group.h - -$(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-inode.h: libfs/src/rfs/rtems-rfs-inode.h $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-inode.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-inode.h - -$(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-link.h: libfs/src/rfs/rtems-rfs-link.h $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-link.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-link.h - -$(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-mutex.h: libfs/src/rfs/rtems-rfs-mutex.h $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-mutex.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-mutex.h - -$(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-trace.h: libfs/src/rfs/rtems-rfs-trace.h $(PROJECT_INCLUDE)/rtems/rfs/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-trace.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rfs/rtems-rfs-trace.h - -$(PROJECT_INCLUDE)/rtems/jffs2.h: libfs/src/jffs2/include/rtems/jffs2.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/jffs2.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/jffs2.h - -$(PROJECT_INCLUDE)/rtems/bdbuf.h: libblock/include/rtems/bdbuf.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/bdbuf.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/bdbuf.h - -$(PROJECT_INCLUDE)/rtems/blkdev.h: libblock/include/rtems/blkdev.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/blkdev.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/blkdev.h - -$(PROJECT_INCLUDE)/rtems/diskdevs.h: libblock/include/rtems/diskdevs.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/diskdevs.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/diskdevs.h - -$(PROJECT_INCLUDE)/rtems/flashdisk.h: libblock/include/rtems/flashdisk.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/flashdisk.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/flashdisk.h - -$(PROJECT_INCLUDE)/rtems/ramdisk.h: libblock/include/rtems/ramdisk.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/ramdisk.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/ramdisk.h - -$(PROJECT_INCLUDE)/rtems/nvdisk.h: libblock/include/rtems/nvdisk.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/nvdisk.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/nvdisk.h - -$(PROJECT_INCLUDE)/rtems/nvdisk-sram.h: libblock/include/rtems/nvdisk-sram.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/nvdisk-sram.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/nvdisk-sram.h - -$(PROJECT_INCLUDE)/rtems/sparse-disk.h: libblock/include/rtems/sparse-disk.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/sparse-disk.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/sparse-disk.h - -$(PROJECT_INCLUDE)/rtems/ide_part_table.h: libblock/include/rtems/ide_part_table.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/ide_part_table.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/ide_part_table.h - -$(PROJECT_INCLUDE)/rtems/bdpart.h: libblock/include/rtems/bdpart.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/bdpart.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/bdpart.h - -$(PROJECT_INCLUDE)/rtems/media.h: libblock/include/rtems/media.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/media.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/media.h - -if LIBNETWORKING -$(PROJECT_INCLUDE)/rtems/ftpd.h: ftpd/ftpd.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/ftpd.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/ftpd.h -endif -$(PROJECT_INCLUDE)/rtems/bspcmdline.h: libmisc/bspcmdline/bspcmdline.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/bspcmdline.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/bspcmdline.h - -$(PROJECT_INCLUDE)/rtems/capture.h: libmisc/capture/capture.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/capture.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/capture.h - -$(PROJECT_INCLUDE)/rtems/capture-cli.h: libmisc/capture/capture-cli.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/capture-cli.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/capture-cli.h - -$(PROJECT_INCLUDE)/rtems/captureimpl.h: libmisc/capture/captureimpl.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/captureimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/captureimpl.h - -$(PROJECT_INCLUDE)/rtems/trace/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/trace - @: > $(PROJECT_INCLUDE)/rtems/trace/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/trace/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/trace/rtems-trace-buffer-vars.h: libmisc/capture/rtems-trace-buffer-vars.h $(PROJECT_INCLUDE)/rtems/trace/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/trace/rtems-trace-buffer-vars.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/trace/rtems-trace-buffer-vars.h - -$(PROJECT_INCLUDE)/rtems/cpuuse.h: libmisc/cpuuse/cpuuse.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/cpuuse.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/cpuuse.h - -$(PROJECT_INCLUDE)/rtems/devnull.h: libmisc/devnull/devnull.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/devnull.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/devnull.h - -$(PROJECT_INCLUDE)/rtems/devzero.h: libmisc/devnull/devzero.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/devzero.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/devzero.h - -$(PROJECT_INCLUDE)/rtems/dumpbuf.h: libmisc/dumpbuf/dumpbuf.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/dumpbuf.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/dumpbuf.h - -$(PROJECT_INCLUDE)/rtems/rtems-fdt.h: libmisc/rtems-fdt/rtems-fdt.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems-fdt.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems-fdt.h - -$(PROJECT_INCLUDE)/rtems/rtems-fdt-shell.h: libmisc/rtems-fdt/rtems-fdt-shell.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems-fdt-shell.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems-fdt-shell.h - -$(PROJECT_INCLUDE)/rtems/monitor.h: libmisc/monitor/monitor.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/monitor.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/monitor.h - -$(PROJECT_INCLUDE)/rtems/fb.h: libmisc/fb/fb.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/fb.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/fb.h - -$(PROJECT_INCLUDE)/rtems/mw_uid.h: libmisc/fb/mw_uid.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/mw_uid.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/mw_uid.h - -$(PROJECT_INCLUDE)/rtems/mouse_parser.h: libmisc/mouse/mouse_parser.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/mouse_parser.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/mouse_parser.h - -$(PROJECT_INCLUDE)/rtems/serial_mouse.h: libmisc/mouse/serial_mouse.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/serial_mouse.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/serial_mouse.h - -$(PROJECT_INCLUDE)/rtems/qreslib.h: libqos/qreslib.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/qreslib.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/qreslib.h - -$(PROJECT_INCLUDE)/rtems/stdio-redirect.h: libmisc/redirector/stdio-redirect.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/stdio-redirect.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/stdio-redirect.h - -if LIBSHELL -$(PROJECT_INCLUDE)/rtems/shell.h: libmisc/shell/shell.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/shell.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/shell.h - -$(PROJECT_INCLUDE)/rtems/shellconfig.h: libmisc/shell/shellconfig.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/shellconfig.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/shellconfig.h -endif -$(PROJECT_INCLUDE)/rtems/stringto.h: libmisc/stringto/stringto.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/stringto.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/stringto.h - -$(PROJECT_INCLUDE)/rtems/test.h: libmisc/testsupport/test.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/test.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/test.h - -$(PROJECT_INCLUDE)/rtems/libi2c.h: libi2c/libi2c.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/libi2c.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/libi2c.h - -if LIBSERDBG -$(PROJECT_INCLUDE)/rtems/serdbgcnf.h: libmisc/serdbg/serdbgcnf.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/serdbgcnf.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/serdbgcnf.h - -$(PROJECT_INCLUDE)/rtems/serdbg.h: libmisc/serdbg/serdbg.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/serdbg.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/serdbg.h - -$(PROJECT_INCLUDE)/rtems/termios_printk_cnf.h: libmisc/serdbg/termios_printk_cnf.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/termios_printk_cnf.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/termios_printk_cnf.h - -$(PROJECT_INCLUDE)/rtems/termios_printk.h: libmisc/serdbg/termios_printk.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/termios_printk.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/termios_printk.h -endif -$(PROJECT_INCLUDE)/rtems/stackchk.h: libmisc/stackchk/stackchk.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/stackchk.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/stackchk.h - -$(PROJECT_INCLUDE)/rtems/untar.h: libmisc/untar/untar.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/untar.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/untar.h - -$(PROJECT_INCLUDE)/rtems/fsmount.h: libmisc/fsmount/fsmount.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/fsmount.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/fsmount.h - -$(PROJECT_INCLUDE)/rtems/tm27-default.h: include/rtems/tm27-default.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/tm27-default.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/tm27-default.h - -if LIBDRVMGR -$(PROJECT_INCLUDE)/drvmgr/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/drvmgr - @: > $(PROJECT_INCLUDE)/drvmgr/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/drvmgr/$(dirstamp) - -$(PROJECT_INCLUDE)/drvmgr/drvmgr.h: libdrvmgr/drvmgr.h $(PROJECT_INCLUDE)/drvmgr/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/drvmgr/drvmgr.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/drvmgr/drvmgr.h - -$(PROJECT_INCLUDE)/drvmgr/drvmgr_confdefs.h: libdrvmgr/drvmgr_confdefs.h $(PROJECT_INCLUDE)/drvmgr/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/drvmgr/drvmgr_confdefs.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/drvmgr/drvmgr_confdefs.h - -$(PROJECT_INCLUDE)/drvmgr/drvmgr_list.h: libdrvmgr/drvmgr_list.h $(PROJECT_INCLUDE)/drvmgr/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/drvmgr/drvmgr_list.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/drvmgr/drvmgr_list.h -endif -if LIBGNAT -$(PROJECT_INCLUDE)/adainclude/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/adainclude - @: > $(PROJECT_INCLUDE)/adainclude/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - -$(PROJECT_INCLUDE)/adainclude/rtems.adb: include/adainclude/rtems.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems.adb - -$(PROJECT_INCLUDE)/adainclude/rtems.ads: include/adainclude/rtems.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-barrier.adb: include/adainclude/rtems-barrier.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-barrier.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-barrier.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-barrier.ads: include/adainclude/rtems-barrier.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-barrier.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-barrier.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-clock.adb: include/adainclude/rtems-clock.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-clock.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-clock.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-clock.ads: include/adainclude/rtems-clock.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-clock.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-clock.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-cpu_usage.ads: include/adainclude/rtems-cpu_usage.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-cpu_usage.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-cpu_usage.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-event.adb: include/adainclude/rtems-event.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-event.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-event.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-event.ads: include/adainclude/rtems-event.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-event.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-event.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-extension.adb: include/adainclude/rtems-extension.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-extension.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-extension.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-extension.ads: include/adainclude/rtems-extension.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-extension.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-extension.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-fatal.adb: include/adainclude/rtems-fatal.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-fatal.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-fatal.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-fatal.ads: include/adainclude/rtems-fatal.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-fatal.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-fatal.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-interrupt.ads: include/adainclude/rtems-interrupt.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-interrupt.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-interrupt.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-io.adb: include/adainclude/rtems-io.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-io.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-io.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-io.ads: include/adainclude/rtems-io.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-io.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-io.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-message_queue.adb: include/adainclude/rtems-message_queue.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-message_queue.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-message_queue.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-message_queue.ads: include/adainclude/rtems-message_queue.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-message_queue.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-message_queue.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-multiprocessing.adb: include/adainclude/rtems-multiprocessing.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-multiprocessing.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-multiprocessing.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-multiprocessing.ads: include/adainclude/rtems-multiprocessing.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-multiprocessing.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-multiprocessing.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-object.adb: include/adainclude/rtems-object.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-object.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-object.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-object.ads: include/adainclude/rtems-object.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-object.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-object.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-partition.adb: include/adainclude/rtems-partition.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-partition.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-partition.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-partition.ads: include/adainclude/rtems-partition.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-partition.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-partition.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-port.adb: include/adainclude/rtems-port.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-port.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-port.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-port.ads: include/adainclude/rtems-port.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-port.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-port.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-rate_monotonic.adb: include/adainclude/rtems-rate_monotonic.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-rate_monotonic.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-rate_monotonic.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-rate_monotonic.ads: include/adainclude/rtems-rate_monotonic.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-rate_monotonic.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-rate_monotonic.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-region.adb: include/adainclude/rtems-region.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-region.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-region.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-region.ads: include/adainclude/rtems-region.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-region.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-region.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-semaphore.adb: include/adainclude/rtems-semaphore.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-semaphore.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-semaphore.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-semaphore.ads: include/adainclude/rtems-semaphore.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-semaphore.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-semaphore.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-signal.adb: include/adainclude/rtems-signal.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-signal.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-signal.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-signal.ads: include/adainclude/rtems-signal.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-signal.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-signal.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-stack_checker.ads: include/adainclude/rtems-stack_checker.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-stack_checker.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-stack_checker.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-tasks.adb: include/adainclude/rtems-tasks.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-tasks.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-tasks.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-tasks.ads: include/adainclude/rtems-tasks.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-tasks.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-tasks.ads - -$(PROJECT_INCLUDE)/adainclude/rtems-timer.adb: include/adainclude/rtems-timer.adb $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-timer.adb -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-timer.adb - -$(PROJECT_INCLUDE)/adainclude/rtems-timer.ads: include/adainclude/rtems-timer.ads $(PROJECT_INCLUDE)/adainclude/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/adainclude/rtems-timer.ads -PREINSTALL_FILES += $(PROJECT_INCLUDE)/adainclude/rtems-timer.ads -endif diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am index da6e302e2e..b8694b8022 100644 --- a/cpukit/rtems/Makefile.am +++ b/cpukit/rtems/Makefile.am @@ -6,63 +6,9 @@ librtems_a_CPPFLAGS = $(AM_CPPFLAGS) # include -include_HEADERS = include/rtems.h - # include/rtems/rtems -include_rtems_rtemsdir = $(includedir)/rtems/rtems -include_rtems_rtems_HEADERS = - -include_rtems_rtems_HEADERS += include/rtems/rtems/asr.h -include_rtems_rtems_HEADERS += include/rtems/rtems/asrimpl.h -include_rtems_rtems_HEADERS += include/rtems/rtems/attr.h -include_rtems_rtems_HEADERS += include/rtems/rtems/attrimpl.h -include_rtems_rtems_HEADERS += include/rtems/rtems/barrier.h -include_rtems_rtems_HEADERS += include/rtems/rtems/barrierimpl.h -include_rtems_rtems_HEADERS += include/rtems/rtems/cache.h -include_rtems_rtems_HEADERS += include/rtems/rtems/clock.h -include_rtems_rtems_HEADERS += include/rtems/rtems/config.h -include_rtems_rtems_HEADERS += include/rtems/rtems/dpmem.h -include_rtems_rtems_HEADERS += include/rtems/rtems/dpmemimpl.h -include_rtems_rtems_HEADERS += include/rtems/rtems/event.h -include_rtems_rtems_HEADERS += include/rtems/rtems/eventimpl.h -include_rtems_rtems_HEADERS += include/rtems/rtems/intr.h -include_rtems_rtems_HEADERS += include/rtems/rtems/message.h -include_rtems_rtems_HEADERS += include/rtems/rtems/messageimpl.h -include_rtems_rtems_HEADERS += include/rtems/rtems/modes.h -include_rtems_rtems_HEADERS += include/rtems/rtems/modesimpl.h -include_rtems_rtems_HEADERS += include/rtems/rtems/object.h -include_rtems_rtems_HEADERS += include/rtems/rtems/options.h -include_rtems_rtems_HEADERS += include/rtems/rtems/optionsimpl.h -include_rtems_rtems_HEADERS += include/rtems/rtems/part.h -include_rtems_rtems_HEADERS += include/rtems/rtems/partimpl.h -include_rtems_rtems_HEADERS += include/rtems/rtems/ratemon.h -include_rtems_rtems_HEADERS += include/rtems/rtems/ratemonimpl.h -include_rtems_rtems_HEADERS += include/rtems/rtems/region.h -include_rtems_rtems_HEADERS += include/rtems/rtems/regionimpl.h -include_rtems_rtems_HEADERS += include/rtems/rtems/sem.h -include_rtems_rtems_HEADERS += include/rtems/rtems/semimpl.h -include_rtems_rtems_HEADERS += include/rtems/rtems/signal.h -include_rtems_rtems_HEADERS += include/rtems/rtems/signalimpl.h -include_rtems_rtems_HEADERS += include/rtems/rtems/smp.h -include_rtems_rtems_HEADERS += include/rtems/rtems/status.h -include_rtems_rtems_HEADERS += include/rtems/rtems/statusimpl.h -include_rtems_rtems_HEADERS += include/rtems/rtems/support.h -include_rtems_rtems_HEADERS += include/rtems/rtems/tasks.h -include_rtems_rtems_HEADERS += include/rtems/rtems/tasksimpl.h -include_rtems_rtems_HEADERS += include/rtems/rtems/timer.h -include_rtems_rtems_HEADERS += include/rtems/rtems/timerimpl.h -include_rtems_rtems_HEADERS += include/rtems/rtems/types.h -include_rtems_rtems_HEADERS += mainpage.h - if HAS_MP ## We only build multiprocessing related files if HAS_MP was defined -include_rtems_rtems_HEADERS += include/rtems/rtems/eventmp.h -include_rtems_rtems_HEADERS += include/rtems/rtems/mp.h -include_rtems_rtems_HEADERS += include/rtems/rtems/msgmp.h -include_rtems_rtems_HEADERS += include/rtems/rtems/partmp.h -include_rtems_rtems_HEADERS += include/rtems/rtems/semmp.h -include_rtems_rtems_HEADERS += include/rtems/rtems/signalmp.h -include_rtems_rtems_HEADERS += include/rtems/rtems/taskmp.h endif ## src @@ -252,5 +198,4 @@ librtems_a_SOURCES += src/signalmp.c librtems_a_SOURCES += src/taskmp.c endif -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am diff --git a/cpukit/rtems/include/rtems.h b/cpukit/rtems/include/rtems.h deleted file mode 100644 index 8e536b449a..0000000000 --- a/cpukit/rtems/include/rtems.h +++ /dev/null @@ -1,192 +0,0 @@ -/** - * @file - * - * @defgroup ClassicRTEMS RTEMS Classic API - * - * @brief RTEMS Classic API - * - * the Public Interface to the RTEMS Classic API - */ - -/* COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_H -#define _RTEMS_H - -/** - * @defgroup ClassicRTEMS RTEMS Classic API - * - * RTEMS Classic API definitions and modules. - */ -/**@{*/ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if defined(RTEMS_MULTIPROCESSING) -#include -#endif -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Returns the pointer to the RTEMS version string. - */ -const char *rtems_get_version_string(void); - -/** - * @brief Indicates whether this processor variant has hardware floating point - * support. - */ -#define RTEMS_HAS_HARDWARE_FP CPU_HARDWARE_FP - -/********************************************************************** - * CONSTANTS WHICH MAY BE USED IN OBJECT NAME TO ID SEARCHES - **********************************************************************/ - -/** - * @brief Indicates that a search is across all nodes. - */ -#define RTEMS_SEARCH_ALL_NODES OBJECTS_SEARCH_ALL_NODES - -/** - * @brief Indicates that a search is across all nodes except the one the call - * is made from. - */ -#define RTEMS_SEARCH_OTHER_NODES OBJECTS_SEARCH_OTHER_NODES - -/** - * @brief Indicates that the search is to be restricted to the local node. - */ -#define RTEMS_SEARCH_LOCAL_NODE OBJECTS_SEARCH_LOCAL_NODE - -/** - * @brief Indicates that the caller wants to obtain the name of the currently - * executing thread. - * - * This constant is only meaningful when obtaining the name of a task. - */ -#define RTEMS_WHO_AM_I OBJECTS_WHO_AM_I - -/********************************************************************** - * Parameters and return Id's for _Objects_Get_next - **********************************************************************/ - -/** - * @brief Lowest valid index value for the index portion of an object - * identifier. - */ -#define RTEMS_OBJECT_ID_INITIAL_INDEX OBJECTS_ID_INITIAL_INDEX - -/** - * @brief Maximum valid index value for the index portion of an object - * identifier. - */ -#define RTEMS_OBJECT_ID_FINAL_INDEX OBJECTS_ID_FINAL_INDEX - -/** - * @brief Returns the identifier of the object with the lowest valid index - * value. - * - * The object is specified by the API @a _api, the object class @a _class and - * the node @a _node where the object resides. - */ -#define RTEMS_OBJECT_ID_INITIAL(_api, _class, _node) \ - OBJECTS_ID_INITIAL(_api, _class, _node) - -/** - * @brief Maximum valid object identifier. - */ -#define RTEMS_OBJECT_ID_FINAL OBJECTS_ID_FINAL - -/** - * @brief Minimum stack size which every thread must exceed. - * - * It is the minimum stack size recommended for use on this processor. This - * value is selected by the RTEMS developers conservatively to minimize the - * risk of blown stacks for most user applications. Using this constant when - * specifying the task stack size, indicates that the stack size will be at - * least RTEMS_MINIMUM_STACK_SIZE bytes in size. If the user configured minimum - * stack size is larger than the recommended minimum, then it will be used. - */ -#define RTEMS_MINIMUM_STACK_SIZE STACK_MINIMUM_SIZE - -/** - * @brief Specifies that the task should be created with the configured minimum - * stack size. - * - * Using this constant when specifying the task stack size indicates that this - * task is to be created with a stack size of the minimum stack size that was - * configured by the application. If not explicitly configured by the - * application, the default configured minimum stack size is the processor - * dependent value RTEMS_MINIMUM_STACK_SIZE. Since this uses the configured - * minimum stack size value, you may get a stack size that is smaller or larger - * than the recommended minimum. This can be used to provide large stacks for - * all tasks on complex applications or small stacks on applications that are - * trying to conserve memory. - */ -#define RTEMS_CONFIGURED_MINIMUM_STACK_SIZE 0 - -/** - * @brief Constant for indefinite wait. - * - * This is actually an illegal interval value. - */ -#define RTEMS_NO_TIMEOUT ((rtems_interval) WATCHDOG_NO_TIMEOUT) - -/** - * @brief An MPCI must support packets of at least this size. - */ -#define RTEMS_MINIMUM_PACKET_SIZE MP_PACKET_MINIMUM_PACKET_SIZE - -/** - * @brief Defines the count of @c uint32_t numbers in a packet which must be - * converted to native format in a heterogeneous system. - * - * In packets longer than this value, some of the extra data may be a user - * message buffer which is not automatically endian swapped. - */ -#define RTEMS_MINIMUN_HETERO_CONVERSION MP_PACKET_MINIMUN_HETERO_CONVERSION - -#ifdef __cplusplus -} -#endif - -/**@}*/ - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/asr.h b/cpukit/rtems/include/rtems/rtems/asr.h deleted file mode 100644 index edd5e2fe62..0000000000 --- a/cpukit/rtems/include/rtems/rtems/asr.h +++ /dev/null @@ -1,156 +0,0 @@ -/** - * @file rtems/rtems/asr.h - * - * @defgroup ClassicASR ASR Support - * - * @ingroup ClassicRTEMS - * @brief Asynchronous Signal Handler - * - * This include file contains all the constants and structures associated - * with the Asynchronous Signal Handler. This Handler provides the low-level - * support required by the Signal Manager. - */ - -/* COPYRIGHT (c) 1989-2013. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_ASR_H -#define _RTEMS_RTEMS_ASR_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicASR ASR Support - * - * @ingroup ClassicRTEMS - * - * This encapsulates functionality related to the Classic API Signal - * Manager. - */ -/**@{*/ - -/** - * The following type defines the control block used to manage - * each signal set. - */ -typedef uint32_t rtems_signal_set; - -/** - * Return type for ASR Handler - */ -typedef void rtems_asr; - -/** - * The following type corresponds to the applications asynchronous - * signal processing routine. - */ -typedef rtems_asr ( *rtems_asr_entry )( - rtems_signal_set - ); - -/** - * The following defines the control structure used to manage - * signals. Each thread has a copy of this record. - */ -typedef struct { - /** This field indicates if are ASRs enabled currently. */ - bool is_enabled; - /** This field indicates if address of the signal handler function. */ - rtems_asr_entry handler; - /** This field indicates if the task mode the signal will run with. */ - Modes_Control mode_set; - /** This field indicates the signal set that is posted. */ - rtems_signal_set signals_posted; - /** This field indicates the signal set that is pending. */ - rtems_signal_set signals_pending; - /** This field indicates if nest level of signals being processed */ - uint32_t nest_level; -} ASR_Information; - -/* - * The following constants define the individual signals which may - * be used to compose a signal set. - */ - -/** This defines the bit in the signal set associated with signal 0. */ -#define RTEMS_SIGNAL_0 0x00000001 -/** This defines the bit in the signal set associated with signal 1. */ -#define RTEMS_SIGNAL_1 0x00000002 -/** This defines the bit in the signal set associated with signal 2. */ -#define RTEMS_SIGNAL_2 0x00000004 -/** This defines the bit in the signal set associated with signal 3. */ -#define RTEMS_SIGNAL_3 0x00000008 -/** This defines the bit in the signal set associated with signal 4. */ -#define RTEMS_SIGNAL_4 0x00000010 -/** This defines the bit in the signal set associated with signal 5. */ -#define RTEMS_SIGNAL_5 0x00000020 -/** This defines the bit in the signal set associated with signal 6. */ -#define RTEMS_SIGNAL_6 0x00000040 -/** This defines the bit in the signal set associated with signal 7. */ -#define RTEMS_SIGNAL_7 0x00000080 -/** This defines the bit in the signal set associated with signal 8. */ -#define RTEMS_SIGNAL_8 0x00000100 -/** This defines the bit in the signal set associated with signal 9. */ -#define RTEMS_SIGNAL_9 0x00000200 -/** This defines the bit in the signal set associated with signal 10. */ -#define RTEMS_SIGNAL_10 0x00000400 -/** This defines the bit in the signal set associated with signal 11. */ -#define RTEMS_SIGNAL_11 0x00000800 -/** This defines the bit in the signal set associated with signal 12. */ -#define RTEMS_SIGNAL_12 0x00001000 -/** This defines the bit in the signal set associated with signal 13. */ -#define RTEMS_SIGNAL_13 0x00002000 -/** This defines the bit in the signal set associated with signal 14. */ -#define RTEMS_SIGNAL_14 0x00004000 -/** This defines the bit in the signal set associated with signal 15. */ -#define RTEMS_SIGNAL_15 0x00008000 -/** This defines the bit in the signal set associated with signal 16. */ -#define RTEMS_SIGNAL_16 0x00010000 -/** This defines the bit in the signal set associated with signal 17. */ -#define RTEMS_SIGNAL_17 0x00020000 -/** This defines the bit in the signal set associated with signal 18. */ -#define RTEMS_SIGNAL_18 0x00040000 -/** This defines the bit in the signal set associated with signal 19. */ -#define RTEMS_SIGNAL_19 0x00080000 -/** This defines the bit in the signal set associated with signal 20. */ -#define RTEMS_SIGNAL_20 0x00100000 -/** This defines the bit in the signal set associated with signal 21. */ -#define RTEMS_SIGNAL_21 0x00200000 -/** This defines the bit in the signal set associated with signal 22. */ -#define RTEMS_SIGNAL_22 0x00400000 -/** This defines the bit in the signal set associated with signal 23. */ -#define RTEMS_SIGNAL_23 0x00800000 -/** This defines the bit in the signal set associated with signal 24. */ -#define RTEMS_SIGNAL_24 0x01000000 -/** This defines the bit in the signal set associated with signal 25. */ -#define RTEMS_SIGNAL_25 0x02000000 -/** This defines the bit in the signal set associated with signal 26. */ -#define RTEMS_SIGNAL_26 0x04000000 -/** This defines the bit in the signal set associated with signal 27. */ -#define RTEMS_SIGNAL_27 0x08000000 -/** This defines the bit in the signal set associated with signal 28. */ -#define RTEMS_SIGNAL_28 0x10000000 -/** This defines the bit in the signal set associated with signal 29. */ -#define RTEMS_SIGNAL_29 0x20000000 -/** This defines the bit in the signal set associated with signal 30. */ -#define RTEMS_SIGNAL_30 0x40000000 -/** This defines the bit in the signal set associated with signal 31. */ -#define RTEMS_SIGNAL_31 0x80000000 - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/asrimpl.h b/cpukit/rtems/include/rtems/rtems/asrimpl.h deleted file mode 100644 index 141c34d4bb..0000000000 --- a/cpukit/rtems/include/rtems/rtems/asrimpl.h +++ /dev/null @@ -1,99 +0,0 @@ -/** - * @file - * - * @ingroup ClassicASRImpl - * - * @brief Classic ASR Implementation - */ - -/* COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_ASRIMPL_H -#define _RTEMS_RTEMS_ASRIMPL_H - -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicASRImpl Classic ASR Implementation - * - * @ingroup ClassicASR - * - * @{ - */ - -/** - * @brief ASR_Initialize - * - * This routine initializes the given RTEMS_ASR information record. - */ -RTEMS_INLINE_ROUTINE void _ASR_Initialize ( - ASR_Information *asr -) -{ - memset(asr, 0, sizeof(*asr)); -} - -/** - * @brief ASR_Is_null_handler - * - * This function returns TRUE if the given asr_handler is NULL and - * FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool _ASR_Is_null_handler ( - rtems_asr_entry asr_handler -) -{ - return asr_handler == NULL; -} - -RTEMS_INLINE_ROUTINE rtems_signal_set _ASR_Swap_signals( ASR_Information *asr ) -{ - rtems_signal_set new_signals_posted; - - new_signals_posted = asr->signals_pending; - asr->signals_pending = asr->signals_posted; - asr->signals_posted = new_signals_posted; - - return new_signals_posted; -} - -RTEMS_INLINE_ROUTINE void _ASR_Post_signals( - rtems_signal_set signals, - rtems_signal_set *signal_set -) -{ - *signal_set |= signals; -} - -RTEMS_INLINE_ROUTINE rtems_signal_set _ASR_Get_posted_signals( - ASR_Information *asr -) -{ - rtems_signal_set signal_set; - - signal_set = asr->signals_posted; - asr->signals_posted = 0; - - return signal_set; -} - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/attr.h b/cpukit/rtems/include/rtems/rtems/attr.h deleted file mode 100644 index 7e8fa4818a..0000000000 --- a/cpukit/rtems/include/rtems/rtems/attr.h +++ /dev/null @@ -1,191 +0,0 @@ -/** - * @file rtems/rtems/attr.h - * - * @defgroup ClassicAttributes Attributes - * - * @ingroup ClassicRTEMS - * @brief Object Attributes Handler - * - * This include file contains all information about the Object Attributes - * Handler. - */ - -/* COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_ATTR_H -#define _RTEMS_RTEMS_ATTR_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicAttributes Attributes - * - * @ingroup ClassicRTEMS - * - * This encapsulates functionality which defines and manages the - * set of Classic API object attributes. - */ -/**@{*/ - -/** - * This defines the type used to contain Classic API attributes. These - * are primarily used when creating objects. - */ -typedef uint32_t rtems_attribute; - -/** This is the default value for an attribute set. */ - -#define RTEMS_DEFAULT_ATTRIBUTES 0x00000000 - -/** - * This is the attribute constant to indicate local resource. - */ -#define RTEMS_LOCAL 0x00000000 - -/** - * This is the attribute constant to indicate global resource. - */ -#define RTEMS_GLOBAL 0x00000002 - -/** - * This is the attribute constant which reflects that blocking - * tasks will be managed using FIFO discipline. - */ -#define RTEMS_FIFO 0x00000000 - -/** - * This is the attribute constant which reflects that blocking - * tasks will be managed using task priority discipline. - */ -#define RTEMS_PRIORITY 0x00000004 - -/******************** RTEMS Task Specific Attributes *********************/ - -/** - * This attribute constant indicates that the task will not use the - * floating point hardware. If the architecture permits it, then - * the FPU will be disabled when the task is executing. - */ -#define RTEMS_NO_FLOATING_POINT 0x00000000 - -/** - * This attribute constant indicates that the task will use the - * floating point hardware. There will be a floating point - * context associated with this task. - */ -#define RTEMS_FLOATING_POINT 0x00000001 - -/***************** RTEMS Semaphore Specific Attributes ********************/ - -/** - * This is the mask for the attribute bits associated with the - * Classic API Semaphore Manager. - */ -#define RTEMS_SEMAPHORE_CLASS 0x00000030 - -/** - * This attribute constant indicates that the Classic API Semaphore - * instance created will be a counting semaphore. - */ -#define RTEMS_COUNTING_SEMAPHORE 0x00000000 - -/** - * This attribute constant indicates that the Classic API Semaphore - * instance created will be a proper binary semaphore or mutex. - */ -#define RTEMS_BINARY_SEMAPHORE 0x00000010 - -/** - * This attribute constant indicates that the Classic API Semaphore - * instance created will be a simple binary semaphore. - */ -#define RTEMS_SIMPLE_BINARY_SEMAPHORE 0x00000020 - -/** - * This attribute constant indicates that the Classic API Semaphore - * instance created will NOT use the Priority Inheritance Protocol. - */ -#define RTEMS_NO_INHERIT_PRIORITY 0x00000000 - -/** - * This attribute constant indicates that the Classic API Semaphore - * instance created will use the Priority Inheritance Protocol. - * - * @note The semaphore instance must be a binary semaphore. - */ -#define RTEMS_INHERIT_PRIORITY 0x00000040 - -/** - * This attribute constant indicates that the Classic API Semaphore - * instance created will NOT use the Priority Ceiling Protocol. - */ -#define RTEMS_NO_PRIORITY_CEILING 0x00000000 - -/** - * This attribute constant indicates that the Classic API Semaphore - * instance created will use the Priority Ceiling Protocol. - * - * @note The semaphore instance must be a binary semaphore. - */ -#define RTEMS_PRIORITY_CEILING 0x00000080 - -/** - * This attribute constant indicates that the Classic API Semaphore instance - * created will NOT use the Multiprocessor Resource Sharing Protocol. - */ -#define RTEMS_NO_MULTIPROCESSOR_RESOURCE_SHARING 0x00000000 - -/** - * This attribute constant indicates that the Classic API Semaphore instance - * created will use the Multiprocessor Resource Sharing Protocol. - * - * @note The semaphore instance must be a binary semaphore. - */ -#define RTEMS_MULTIPROCESSOR_RESOURCE_SHARING 0x00000100 - -/******************** RTEMS Barrier Specific Attributes ********************/ - -/** - * This attribute constant indicates that the Classic API Barrier - * instance created will use an automatic release protocol. - */ -#define RTEMS_BARRIER_AUTOMATIC_RELEASE 0x00000010 - -/** - * This attribute constant indicates that the Classic API Barrier - * instance created will use the manual release protocol. - */ -#define RTEMS_BARRIER_MANUAL_RELEASE 0x00000000 - -/**************** RTEMS Internal Task Specific Attributes ****************/ - -/** - * This attribute constant indicates that the task was created - * by the application using normal Classic API methods. - */ -#define RTEMS_APPLICATION_TASK 0x00000000 - -/** - * This attribute constant indicates that the task was created - * by RTEMS as a support task. - */ -#define RTEMS_SYSTEM_TASK 0x00008000 - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/attrimpl.h b/cpukit/rtems/include/rtems/rtems/attrimpl.h deleted file mode 100644 index bb8e5f8f58..0000000000 --- a/cpukit/rtems/include/rtems/rtems/attrimpl.h +++ /dev/null @@ -1,263 +0,0 @@ -/** - * @file - * - * @ingroup ClassicAttributesImpl - * - * @brief Classic Attributes Implementation - */ - -/* - * COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_ATTR_INL -#define _RTEMS_RTEMS_ATTR_INL - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicAttributesImpl Classic Attributes Implementation - * - * @ingroup ClassicAttributes - * - * @{ - */ - -/****************** Forced Attributes in Configuration ****************/ - -/** - * This attribute constant indicates the attributes that are not - * supportable given the hardware configuration. - */ -#define ATTRIBUTES_NOT_SUPPORTED 0 - -/** - * This attribute constant indicates the attributes that are - * required given the hardware configuration. - */ -#if ( CPU_ALL_TASKS_ARE_FP == TRUE ) -#define ATTRIBUTES_REQUIRED RTEMS_FLOATING_POINT -#else -#define ATTRIBUTES_REQUIRED 0 -#endif - -/** - * @brief Sets the requested new_attributes in the attribute_set passed in. - * - * This function sets the requested new_attributes in the attribute_set - * passed in. The result is returned to the user. - */ -RTEMS_INLINE_ROUTINE rtems_attribute _Attributes_Set ( - rtems_attribute new_attributes, - rtems_attribute attribute_set -) -{ - return attribute_set | new_attributes; -} - -/** - * @brief Clears the requested new_attributes in the attribute_set - * passed in. - * - * This function clears the requested new_attributes in the attribute_set - * passed in. The result is returned to the user. - */ -RTEMS_INLINE_ROUTINE rtems_attribute _Attributes_Clear ( - rtems_attribute attribute_set, - rtems_attribute mask -) -{ - return attribute_set & ~mask; -} - -/** - * @brief Checks if the floating point attribute is - * enabled in the attribute_set. - * - * This function returns TRUE if the floating point attribute is - * enabled in the attribute_set and FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Attributes_Is_floating_point( - rtems_attribute attribute_set -) -{ - return ( attribute_set & RTEMS_FLOATING_POINT ) ? true : false; -} - -#if defined(RTEMS_MULTIPROCESSING) -/** - * @brief Checks if the global object attribute is enabled in - * the attribute_set. - * - * This function returns TRUE if the global object attribute is - * enabled in the attribute_set and FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Attributes_Is_global( - rtems_attribute attribute_set -) -{ - return ( attribute_set & RTEMS_GLOBAL ) ? true : false; -} -#endif - -/** - * @brief Checks if the priority attribute is enabled in the attribute_set. - * - * This function returns TRUE if the priority attribute is - * enabled in the attribute_set and FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Attributes_Is_priority( - rtems_attribute attribute_set -) -{ - return ( attribute_set & RTEMS_PRIORITY ) ? true : false; -} - -/** - * @brief Checks if the binary semaphore attribute is - * enabled in the attribute_set. - * - * This function returns TRUE if the binary semaphore attribute is - * enabled in the attribute_set and FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Attributes_Is_binary_semaphore( - rtems_attribute attribute_set -) -{ - return ((attribute_set & RTEMS_SEMAPHORE_CLASS) == RTEMS_BINARY_SEMAPHORE); -} - -/** - * @brief Checks if the simple binary semaphore attribute is - * enabled in the attribute_set - * - * This function returns TRUE if the simple binary semaphore attribute is - * enabled in the attribute_set and FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Attributes_Is_simple_binary_semaphore( - rtems_attribute attribute_set -) -{ - return - ((attribute_set & RTEMS_SEMAPHORE_CLASS) == RTEMS_SIMPLE_BINARY_SEMAPHORE); -} - -/** - * @brief Checks if the counting semaphore attribute is - * enabled in the attribute_set - * - * This function returns TRUE if the counting semaphore attribute is - * enabled in the attribute_set and FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Attributes_Is_counting_semaphore( - rtems_attribute attribute_set -) -{ - return ((attribute_set & RTEMS_SEMAPHORE_CLASS) == RTEMS_COUNTING_SEMAPHORE); -} - -/** - * @brief Checks if the priority inheritance attribute - * is enabled in the attribute_set - * - * This function returns TRUE if the priority inheritance attribute - * is enabled in the attribute_set and FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Attributes_Is_inherit_priority( - rtems_attribute attribute_set -) -{ - return ( attribute_set & RTEMS_INHERIT_PRIORITY ) ? true : false; -} - -/** - * @brief Returns true if the attribute set has at most one protocol, and false - * otherwise. - * - * The protocols are RTEMS_INHERIT_PRIORITY, RTEMS_PRIORITY_CEILING and - * RTEMS_MULTIPROCESSOR_RESOURCE_SHARING. - */ -RTEMS_INLINE_ROUTINE bool _Attributes_Has_at_most_one_protocol( - rtems_attribute attribute_set -) -{ - attribute_set &= RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY_CEILING - | RTEMS_MULTIPROCESSOR_RESOURCE_SHARING; - - return ( attribute_set & ( attribute_set - 1 ) ) == 0; -} - -/** - * @brief Checks if the priority ceiling attribute - * is enabled in the attribute_set - * - * This function returns TRUE if the priority ceiling attribute - * is enabled in the attribute_set and FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Attributes_Is_priority_ceiling( - rtems_attribute attribute_set -) -{ - return ( attribute_set & RTEMS_PRIORITY_CEILING ) ? true : false; -} - -/** - * @brief Checks if the Multiprocessor Resource Sharing Protocol attribute - * is enabled in the attribute_set - * - * This function returns TRUE if the Multiprocessor Resource Sharing Protocol - * attribute is enabled in the attribute_set and FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Attributes_Is_multiprocessor_resource_sharing( - rtems_attribute attribute_set -) -{ - return ( attribute_set & RTEMS_MULTIPROCESSOR_RESOURCE_SHARING ) != 0; -} - -/** - * @brief Checks if the barrier automatic release - * attribute is enabled in the attribute_set - * - * This function returns TRUE if the barrier automatic release - * attribute is enabled in the attribute_set and FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Attributes_Is_barrier_automatic( - rtems_attribute attribute_set -) -{ - return ( attribute_set & RTEMS_BARRIER_AUTOMATIC_RELEASE ) ? true : false; -} - -/** - * @brief Checks if the system task attribute - * is enabled in the attribute_set. - * - * This function returns TRUE if the system task attribute - * is enabled in the attribute_set and FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Attributes_Is_system_task( - rtems_attribute attribute_set -) -{ - return ( attribute_set & RTEMS_SYSTEM_TASK ) ? true : false; -} - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/barrier.h b/cpukit/rtems/include/rtems/rtems/barrier.h deleted file mode 100644 index 2eea90fa41..0000000000 --- a/cpukit/rtems/include/rtems/rtems/barrier.h +++ /dev/null @@ -1,173 +0,0 @@ -/** - * @file rtems/rtems/barrier.h - * - * @defgroup ClassicBarrier Barriers - * - * @ingroup ClassicRTEMS - * @brief Classic API Barrier Manager - * - * This include file contains all the constants and structures associated - * with the Barrier Manager. - * - * Directives provided are: - * - * - create a barrier - * - get an ID of a barrier - * - delete a barrier - * - wait for a barrier - * - signal a barrier - */ - -/* COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_BARRIER_H -#define _RTEMS_RTEMS_BARRIER_H - -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicBarrier Barriers - * - * @ingroup ClassicRTEMS - * - * This encapsulates functionality which implements the Classic API - * Barrier Manager. - */ -/**@{*/ - -/** - * This type defines the control block used to manage each barrier. - */ -typedef struct { - /** This is used to manage a barrier as an object. */ - Objects_Control Object; - /** This is used to implement the barrier. */ - CORE_barrier_Control Barrier; - /** This is used to specify the attributes of a barrier. */ - rtems_attribute attribute_set; -} Barrier_Control; - -/** - * @brief RTEMS Create Barrier - * - * Barrier Manager -- Create a Barrier Instance - * - * This routine implements the rtems_barrier_create directive. The - * barrier will have the name name. The starting count for - * the barrier is count. The attribute_set determines if - * the barrier is global or local and the thread queue - * discipline. It returns the id of the created barrier in ID. - * - * @param[in] name is the name of this barrier instance. - * @param[in] attribute_set specifies the attributes of this barrier instance. - * @param[in] maximum_waiters is the maximum number of threads which will - * be allowed to concurrently wait at the barrier. - * @param[out] id will contain the id of this barrier. - * - * @retval a status code indicating success or the reason for failure. - */ -rtems_status_code rtems_barrier_create( - rtems_name name, - rtems_attribute attribute_set, - uint32_t maximum_waiters, - rtems_id *id -); - -/** - * @brief RTEMS Barrier name to Id - * - * This routine implements the rtems_barrier_ident directive. - * This directive returns the barrier ID associated with name. - * If more than one barrier is named name, then the barrier - * to which the ID belongs is arbitrary. node indicates the - * extent of the search for the ID of the barrier named name. - * The search can be limited to a particular node or allowed to - * encompass all nodes. - * - * @param[in] name is the name of this barrier instance. - * @param[out] id will contain the id of this barrier. - * - * @retval a status code indicating success or the reason for failure. - */ -rtems_status_code rtems_barrier_ident( - rtems_name name, - rtems_id *id -); - -/** - * @brief RTEMS Delete Barrier - * - * This routine implements the rtems_barrier_delete directive. The - * barrier indicated by @a id is deleted. The barrier is freed back to the - * inactive barrier chain. - * - * - * @param[in] id indicates the barrier to delete - * - * @retval a status code indicating success or the reason for failure. - */ -rtems_status_code rtems_barrier_delete( - rtems_id id -); - -/** - * @brief RTEMS Barrier Wait - * - * This routine implements the rtems_barrier_wait directive. It - * attempts to wait at the barrier associated with @a id. The calling task - * may block waiting for the barrier with an optional timeout of @a timeout - * clock ticks. - * - * @param[in] id indicates the barrier to wait at. - * @param[in] timeout is the maximum length of time in ticks the calling - * thread is willing to block. - * - * @retval a status code indicating success or the reason for failure. - */ -rtems_status_code rtems_barrier_wait( - rtems_id id, - rtems_interval timeout -); - -/** - * @brief RTEMS Barrier Release - * - * Barrier Manager -- Release Tasks Waitng at a Barrier - * - * This routine implements the rtems_barrier_release directive. It - * unblocks all of the threads waiting on the barrier associated with - * @a id. The number of threads unblocked is returned in @a released. - * - * - * @param[in] id indicates the barrier to wait at. - * @param[out] released will contain the number of threads unblocked. - * - * @retval a status code indicating success or the reason for failure. - */ -rtems_status_code rtems_barrier_release( - rtems_id id, - uint32_t *released -); - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/barrierimpl.h b/cpukit/rtems/include/rtems/rtems/barrierimpl.h deleted file mode 100644 index f0b53e0cab..0000000000 --- a/cpukit/rtems/include/rtems/rtems/barrierimpl.h +++ /dev/null @@ -1,92 +0,0 @@ -/** - * @file rtems/rtems/barrier.inl - * - * @defgroup ClassicBarrier Barriers - * - * @ingroup ClassicRTEMS - * @brief Inline Implementation from Barrier Manager - * - * This file contains the static inlin implementation of the inlined - * routines from the Barrier Manager. - */ - -/* - * COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_BARRIERIMPL_H -#define _RTEMS_RTEMS_BARRIERIMPL_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicBarrierImpl Classic Barrier Implementation - * - * @ingroup ClassicBarrier - * - * @{ - */ - -/** - * The following defines the information control block used to manage - * this class of objects. - */ -extern Objects_Information _Barrier_Information; - -/** - * @brief _Barrier_Allocate - * - * This function allocates a barrier control block from - * the inactive chain of free barrier control blocks. - */ -RTEMS_INLINE_ROUTINE Barrier_Control *_Barrier_Allocate( void ) -{ - return (Barrier_Control *) _Objects_Allocate( &_Barrier_Information ); -} - -/** - * @brief _Barrier_Free - * - * This routine frees a barrier control block to the - * inactive chain of free barrier control blocks. - */ -RTEMS_INLINE_ROUTINE void _Barrier_Free ( - Barrier_Control *the_barrier -) -{ - _CORE_barrier_Destroy( &the_barrier->Barrier ); - _Objects_Free( &_Barrier_Information, &the_barrier->Object ); -} - -RTEMS_INLINE_ROUTINE Barrier_Control *_Barrier_Get( - Objects_Id id, - Thread_queue_Context *queue_context -) -{ - _Thread_queue_Context_initialize( queue_context ); - return (Barrier_Control *) _Objects_Get( - id, - &queue_context->Lock_context.Lock_context, - &_Barrier_Information - ); -} - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/cache.h b/cpukit/rtems/include/rtems/rtems/cache.h deleted file mode 100644 index f1dc9bf03d..0000000000 --- a/cpukit/rtems/include/rtems/rtems/cache.h +++ /dev/null @@ -1,370 +0,0 @@ -/** - * @file - * - * @ingroup ClassicCache - */ - -/* COPYRIGHT (c) 1989-2013. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_CACHE_H -#define _RTEMS_RTEMS_CACHE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/** - * @defgroup ClassicCache Cache - * - * @ingroup ClassicRTEMS - * - * @brief The Cache Manager provides functions to perform maintenance - * operations for data and instruction caches. - * - * The actual actions of the Cache Manager operations depend on the hardware - * and the implementation provided by the CPU architecture port or a board - * support package. Cache implementations tend to be highly hardware - * dependent. - * - * @{ - */ - -/** - * @brief Returns the data cache line size in bytes. - * - * For multi-level caches this is the maximum of the cache line sizes of all - * levels. - * - * @retval 0 No data cache is present. - * @retval positive The data cache line size in bytes. - */ -size_t rtems_cache_get_data_line_size( void ); - -/** - * @brief Returns the instruction cache line size in bytes. - * - * For multi-level caches this is the maximum of the cache line sizes of all - * levels. - * - * @retval 0 No instruction cache is present. - * @retval positive The instruction cache line size in bytes. - */ -size_t rtems_cache_get_instruction_line_size( void ); - -/** - * @brief Returns the maximal cache line size of all cache kinds in bytes. - * - * Returns computed or obtained maximal cache line size of all - * all caches in the system. - * - * @retval 0 No cache is present - * @retval positive The maximal cache line size in bytes. - */ -size_t rtems_cache_get_maximal_line_size( void ); - -/** - * @brief Returns the data cache size in bytes. - * - * @param[in] level The cache level of interest. The cache level zero - * specifies the entire data cache. - * - * @returns The data cache size in bytes of the specified level. - */ -size_t rtems_cache_get_data_cache_size( uint32_t level ); - -/** - * @brief Returns the instruction cache size in bytes. - * - * @param[in] level The cache level of interest. The cache level zero - * specifies the entire instruction cache. - * - * @returns The instruction cache size in bytes of the specified level. - */ -size_t rtems_cache_get_instruction_cache_size( uint32_t level ); - -/** - * @brief Flushes multiple data cache lines. - * - * Dirty cache lines covering the area are transfered to memory. Depending on - * the cache implementation this may mark the lines as invalid. - * - * @param[in] addr The start address of the area to flush. - * @param[in] size The size in bytes of the area to flush. - */ -void rtems_cache_flush_multiple_data_lines( const void *addr, size_t size ); - -/** - * @brief Invalidates multiple data cache lines. - * - * The cache lines covering the area are marked as invalid. A later read - * access in the area will load the data from memory. - * - * In case the area is not aligned on cache line boundaries, then this - * operation may destroy unrelated data. - * - * @param[in] addr The start address of the area to invalidate. - * @param[in] size The size in bytes of the area to invalidate. - */ -void rtems_cache_invalidate_multiple_data_lines( - const void *addr, - size_t size -); - -/** - * @brief Invalidates multiple instruction cache lines. - * - * The cache lines covering the area are marked as invalid. A later - * instruction fetch from the area will result in a load from memory. - * In SMP mode, on processors without instruction cache snooping, this - * operation will invalidate the instruction cache lines on all processors. - * It should not be called from interrupt context in such case. - * - * @param[in] addr The start address of the area to invalidate. - * @param[in] size The size in bytes of the area to invalidate. - */ -void rtems_cache_invalidate_multiple_instruction_lines( - const void *addr, - size_t size -); - - -/** - * @brief Ensure necessary synchronization required after code changes - * - * When code is loaded or modified then many Harvard cache equipped - * systems require synchronization of main memory and or updated - * code in data cache to ensure visibility of change in all - * connected CPUs instruction memory view. This operation - * should be used by run time loader for example. - * - * @param[in] addr The start address of the area to invalidate. - * @param[in] size The size in bytes of the area to invalidate. - */ -void rtems_cache_instruction_sync_after_code_change( - const void * code_addr, - size_t n_bytes -); - -/** - * @brief Flushes the entire data cache. - * - * @see rtems_cache_flush_multiple_data_lines(). - */ -void rtems_cache_flush_entire_data( void ); - -/** - * @brief Invalidates the entire instruction cache. - * - * @see rtems_cache_invalidate_multiple_instruction_lines(). - */ -void rtems_cache_invalidate_entire_instruction( void ); - -/** - * This function is responsible for performing a data cache - * invalidate. It invalidates the entire cache. - */ -void rtems_cache_invalidate_entire_data( void ); - -/** - * This function freezes the data cache. - */ -void rtems_cache_freeze_data( void ); - -/** - * This function unfreezes the data cache. - */ -void rtems_cache_unfreeze_data( void ); - -/** - * This function enables the data cache. - */ -void rtems_cache_enable_data( void ); - -/** - * This function disables the data cache. - */ -void rtems_cache_disable_data( void ); - -/** - * This function freezes the instruction cache. - */ -void rtems_cache_freeze_instruction( void ); - -/** - * This function unfreezes the instruction cache. - */ -void rtems_cache_unfreeze_instruction( void ); - -/** - * This function enables the instruction cache. - */ -void rtems_cache_enable_instruction( void ); - -/** - * This function disables the instruction cache. - */ -void rtems_cache_disable_instruction( void ); - -/** - * This function is used to allocate storage that spans an - * integral number of cache blocks. - */ -void *rtems_cache_aligned_malloc ( size_t nbytes ); - -/** - * @brief Allocates a memory area of size @a size bytes from cache coherent - * memory. - * - * A size value of zero will return a unique address which may be freed with - * rtems_cache_coherent_free(). - * - * The memory allocated by this function can be released with a call to - * rtems_cache_coherent_free(). - * - * By default the C program heap allocator is used. In case special memory - * areas must be used, then the BSP or the application must add cache coherent - * memory areas for the allocator via rtems_cache_coherent_add_area(). - * - * This function must be called from driver initialization or task context - * only. - * - * @param[in] alignment If the alignment parameter is not equal to zero, the - * allocated memory area will begin at an address aligned by this value. - * @param[in] boundary If the boundary parameter is not equal to zero, the - * allocated memory area will comply with a boundary constraint. The - * boundary value specifies the set of addresses which are aligned by the - * boundary value. The interior of the allocated memory area will not - * contain an element of this set. The begin or end address of the area may - * be a member of the set. - * - * @retval NULL If no memory is available or the parameters are inconsistent. - * @retval other A pointer to the begin of the allocated memory area. - */ -void *rtems_cache_coherent_allocate( - size_t size, - uintptr_t alignment, - uintptr_t boundary -); - -/** - * @brief Frees memory allocated by rtems_cache_coherent_allocate(). - * - * This function must be called from driver initialization or task context - * only. - * - * @param[in] ptr A pointer returned by rtems_cache_coherent_allocate(). - */ -void rtems_cache_coherent_free( void *ptr ); - -/** - * @brief Adds a cache coherent memory area to the cache coherent allocator. - * - * This function must be called from BSP initialization, driver initialization - * or task context only. - * - * @param[in] area_begin The area begin address. - * @param[in] area_size The area size in bytes. - * - * @see rtems_cache_coherent_allocate(). - */ -void rtems_cache_coherent_add_area( - void *area_begin, - uintptr_t area_size -); - -#if defined( RTEMS_SMP ) - -/** - * @brief Flushes multiple data cache lines for a set of processors - * - * Dirty cache lines covering the area are transferred to memory. - * Depending on the cache implementation this may mark the lines as invalid. - * - * This operation should not be called from interrupt context. - * - * @param[in] addr The start address of the area to flush. - * @param[in] size The size in bytes of the area to flush. - * @param[in] setsize The size of the processor set. - * @param[in] set The target processor set. - */ -void rtems_cache_flush_multiple_data_lines_processor_set( - const void *addr, - size_t size, - const size_t setsize, - const cpu_set_t *set -); - -/** - * @brief Invalidates multiple data cache lines for a set of processors - * - * The cache lines covering the area are marked as invalid. A later read - * access in the area will load the data from memory. - * - * In case the area is not aligned on cache line boundaries, then this - * operation may destroy unrelated data. - * - * This operation should not be called from interrupt context. - * - * @param[in] addr The start address of the area to invalidate. - * @param[in] size The size in bytes of the area to invalidate. - * @param[in] setsize The size of the processor set. - * @param[in] set The target processor set. - */ -void rtems_cache_invalidate_multiple_data_lines_processor_set( - const void *addr, - size_t size, - const size_t setsize, - const cpu_set_t *set -); - -/** - * @brief Flushes the entire data cache for a set of processors - * - * This operation should not be called from interrupt context. - * - * @see rtems_cache_flush_multiple_data_lines(). - * - * @param[in] setsize The size of the processor set. - * @param[in] set The target processor set. - */ -void rtems_cache_flush_entire_data_processor_set( - const size_t setsize, - const cpu_set_t *set -); - -/** - * @brief Invalidates the entire cache for a set of processors - * - * This function is responsible for performing a data cache - * invalidate. It invalidates the entire cache for a set of - * processors. - * - * This operation should not be called from interrupt context. - * - * @param[in] setsize The size of the processor set. - * @param[in] set The target processor set. - */ -void rtems_cache_invalidate_entire_data_processor_set( - const size_t setsize, - const cpu_set_t *set -); - -#endif - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/clock.h b/cpukit/rtems/include/rtems/rtems/clock.h deleted file mode 100644 index a837b88700..0000000000 --- a/cpukit/rtems/include/rtems/rtems/clock.h +++ /dev/null @@ -1,318 +0,0 @@ -/** - * @file rtems/rtems/clock.h - * - * @defgroup ClassicClock Clocks - * - * @ingroup ClassicRTEMS - * @brief Clock Manager API - * - * This include file contains all the constants and structures associated - * with the Clock Manager. This manager provides facilities to set, obtain, - * and continually update the current date and time. - * - * This manager provides directives to: - * - * - set the current date and time - * - obtain the current date and time - * - announce a clock tick - * - obtain the system uptime - */ - -/* COPYRIGHT (c) 1989-2013. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_CLOCK_H -#define _RTEMS_RTEMS_CLOCK_H - -#include -#include -#include -#include -#include -#include - -#include /* struct timeval */ - -/** - * @defgroup ClassicClock Clocks - * - * @ingroup ClassicRTEMS - * - * This encapsulates functionality related to the Classic API Clock - * Manager. - */ -/**@{*/ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Obtain Current Time of Day (Classic TOD) - * - * This routine implements the rtems_clock_get_tod directive. It returns - * the current time of day in the format defined by RTEID. - * - * Clock Manager - rtems_clock_get_tod - * - * @param[in] time_buffer points to the time of day structure - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. If successful, the time_buffer will - * be filled in with the current time of day. - */ -rtems_status_code rtems_clock_get_tod( - rtems_time_of_day *time_buffer -); - -/** - * @brief Obtain TOD in struct timeval Format - * - * This routine implements the rtems_clock_get_tod_timeval - * directive. - * - * @param[in] time points to the struct timeval variable to fill in - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. If successful, the time will - * be filled in with the current time of day. - */ -rtems_status_code rtems_clock_get_tod_timeval( - struct timeval *time -); - -/** - * @brief Obtain Seconds Since Epoch - * - * This routine implements the rtems_clock_get_seconds_since_epoch - * directive. - * - * @param[in] the_interval points to the interval variable to fill in - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. If successful, the time_buffer will - * be filled in with the current time of day. - */ -rtems_status_code rtems_clock_get_seconds_since_epoch( - rtems_interval *the_interval -); - -/** - * @brief Gets the current ticks counter value. - * - * @return The current tick counter value. With a 1ms clock tick, this counter - * overflows after 50 days since boot. - */ -RTEMS_INLINE_ROUTINE rtems_interval rtems_clock_get_ticks_since_boot(void) -{ - return _Watchdog_Ticks_since_boot; -} - -/** - * @brief Returns the ticks counter value delta ticks in the future. - * - * @param[in] delta The ticks delta value. - * - * @return The tick counter value delta ticks in the future. - */ -RTEMS_INLINE_ROUTINE rtems_interval rtems_clock_tick_later( - rtems_interval delta -) -{ - return _Watchdog_Ticks_since_boot + delta; -} - -/** - * @brief Returns the ticks counter value at least delta microseconds in the - * future. - * - * @param[in] delta_in_usec The delta value in microseconds. - * - * @return The tick counter value at least delta microseconds in the future. - */ -RTEMS_INLINE_ROUTINE rtems_interval rtems_clock_tick_later_usec( - rtems_interval delta_in_usec -) -{ - rtems_interval us_per_tick = rtems_configuration_get_microseconds_per_tick(); - - /* - * Add one additional tick, since we don't know the time to the clock next - * tick. - */ - return _Watchdog_Ticks_since_boot - + (delta_in_usec + us_per_tick - 1) / us_per_tick + 1; -} - -/** - * @brief Returns true if the current ticks counter value indicates a time - * before the time specified by the tick value and false otherwise. - * - * @param[in] tick The tick value. - * - * This can be used to write busy loops with a timeout. - * - * @code - * status busy( void ) - * { - * rtems_interval timeout = rtems_clock_tick_later_usec( 10000 ); - * - * do { - * if ( ok() ) { - * return success; - * } - * } while ( rtems_clock_tick_before( timeout ) ); - * - * return timeout; - * } - * @endcode - * - * @retval true The current ticks counter value indicates a time before the - * time specified by the tick value. - * @retval false Otherwise. - */ -RTEMS_INLINE_ROUTINE bool rtems_clock_tick_before( - rtems_interval tick -) -{ - return (int32_t) ( tick - _Watchdog_Ticks_since_boot ) > 0; -} - -/** - * @brief Obtain Ticks Per Seconds - * - * This routine implements the rtems_clock_get_ticks_per_second - * directive. - * - * @retval This method returns the number of ticks per second. It cannot - * fail since RTEMS is always configured to know the number of - * ticks per second. - */ -rtems_interval rtems_clock_get_ticks_per_second(void); - -/* Optimized variant for C/C++ without function call overhead */ -#define rtems_clock_get_ticks_per_second() ( _Watchdog_Ticks_per_second ) - -/** - * @brief Set the Current TOD - * - * This routine implements the rtems_clock_set directive. It sets - * the current time of day to that in the time_buffer record. - * - * @param[in] time_buffer points to the new TOD - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - * - * @note Activities scheduled based upon the current time of day - * may be executed immediately if the time is moved forward. - */ -rtems_status_code rtems_clock_set( - const rtems_time_of_day *time_buffer -); - -/** - * @brief Announce a Clock Tick - * - * This routine implements the rtems_clock_tick directive. It is invoked - * to inform RTEMS of the occurrence of a clock tick. - * - * @retval This directive always returns RTEMS_SUCCESSFUL. - * - * @note This method is typically called from an ISR and is the basis - * for all timeouts and delays. This routine only works for leap-years - * through 2099. - */ -rtems_status_code rtems_clock_tick( void ); - -/** - * @brief Obtain the System Uptime - * - * This directive returns the system uptime. - * - * @param[in] uptime is a pointer to the time structure - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. If successful, the @a uptime will be - * filled in. - */ -rtems_status_code rtems_clock_get_uptime( - struct timespec *uptime -); - -/** - * @brief Gets the System Uptime in the Struct Timeval Format - * - * @param[out] uptime is a pointer to a struct timeval structure. - * - * @retval This methods returns the system uptime. - * - * @note Pointer must not be NULL. - */ -void rtems_clock_get_uptime_timeval( struct timeval *uptime ); - -/** - * @brief Returns the system uptime in seconds. - * - * @retval The system uptime in seconds. - */ -RTEMS_INLINE_ROUTINE time_t rtems_clock_get_uptime_seconds( void ) -{ - return _Timecounter_Time_uptime - 1; -} - -/** - * @brief Returns the system uptime in nanoseconds. - * - * @retval The system uptime in nanoseconds. - */ -uint64_t rtems_clock_get_uptime_nanoseconds( void ); - -/** - * @brief TOD Validate - * - * This support function returns true if @a the_tod contains - * a valid time of day, and false otherwise. - * - * @param[in] the_tod is the TOD structure to validate - * - * @retval This method returns true if the TOD is valid and false otherwise. - * - * @note This routine only works for leap-years through 2099. - */ -bool _TOD_Validate( - const rtems_time_of_day *the_tod -); - -/** - * @brief TOD to Seconds - * - * This function returns the number seconds between the epoch and @a the_tod. - * - * @param[in] the_tod is the TOD structure to convert to seconds - * - * @retval This method returns the number of seconds since epoch represented - * by @a the_tod - */ -Watchdog_Interval _TOD_To_seconds( - const rtems_time_of_day *the_tod -); - -#ifdef __cplusplus -} -#endif - -/**@}*/ - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/config.h b/cpukit/rtems/include/rtems/rtems/config.h deleted file mode 100644 index 77ee798d74..0000000000 --- a/cpukit/rtems/include/rtems/rtems/config.h +++ /dev/null @@ -1,142 +0,0 @@ -/** - * @file rtems/rtems/config.h - * - * @defgroup ClassicConfig Configuration - * - * @ingroup ClassicRTEMS - * @brief Configuration Table - * - * This include file contains the table of user defined configuration - * parameters specific for the RTEMS API. - */ - -/* COPYRIGHT (c) 1989-2013. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_CONFIG_H -#define _RTEMS_RTEMS_CONFIG_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicConfig Configuration - * - * @ingroup ClassicRTEMS - * - * This encapsulates functionality related to the application's configuration - * of the Classic API including the maximum number of each class of objects. - */ -/**@{*/ - -/** - * The following records define the Configuration Table. The - * information contained in this table is required in all - * RTEMS systems, whether single or multiprocessor. This - * table primarily defines the following: - * - * + required number of each object type - */ -typedef struct { - /** - * This field contains the maximum number of Classic API - * Tasks which are configured for this application. - */ - uint32_t maximum_tasks; - - /** - * This field contains the maximum number of Classic API - * Timers which are configured for this application. - */ - uint32_t maximum_timers; - - /** - * This field contains the maximum number of Classic API - * Semaphores which are configured for this application. - */ - uint32_t maximum_semaphores; - - /** - * This field contains the maximum number of Classic API - * Message Queues which are configured for this application. - */ - uint32_t maximum_message_queues; - - /** - * This field contains the maximum number of Classic API - * Partitions which are configured for this application. - */ - uint32_t maximum_partitions; - - /** - * This field contains the maximum number of Classic API - * Regions which are configured for this application. - */ - uint32_t maximum_regions; - - /** - * This field contains the maximum number of Classic API - * Dual Ported Memory Areas which are configured for this - * application. - */ - uint32_t maximum_ports; - - /** - * This field contains the maximum number of Classic API - * Rate Monotonic Periods which are configured for this - * application. - */ - uint32_t maximum_periods; - - /** - * This field contains the maximum number of Classic API - * Barriers which are configured for this application. - */ - uint32_t maximum_barriers; - - /** - * This field contains the number of Classic API Initialization - * Tasks which are configured for this application. - */ - uint32_t number_of_initialization_tasks; - - /** - * This field is the set of Classic API Initialization - * Tasks which are configured for this application. - */ - rtems_initialization_tasks_table *User_initialization_tasks_table; -} rtems_api_configuration_table; - -/** - * @brief RTEMS API Configuration Table - * - * This is the RTEMS API Configuration Table expected to be generated - * by confdefs.h. - */ -extern rtems_api_configuration_table Configuration_RTEMS_API; - -/**@}*/ - -/** - * This macro returns the number of Classic API semaphores configured. - */ -#define rtems_configuration_get_maximum_semaphores() \ - rtems_configuration_get_rtems_api_configuration()->maximum_semaphores - -#ifdef __cplusplus -} -#endif - -/**@}*/ - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/dpmem.h b/cpukit/rtems/include/rtems/rtems/dpmem.h deleted file mode 100644 index e582d2d359..0000000000 --- a/cpukit/rtems/include/rtems/rtems/dpmem.h +++ /dev/null @@ -1,179 +0,0 @@ -/** - * @file rtems/rtems/dpmem.h - * - * @defgroup ClassicDPMEM Dual Ported Memory - * - * @ingroup ClassicRTEMS - * @brief Dual Ported Memory Manager - * - * This include file contains all the constants and structures associated - * with the Dual Ported Memory Manager. This manager provides a mechanism - * for converting addresses between internal and external representations - * for multiple dual-ported memory areas. - * - * Directives provided are: - * - * - create a port - * - get ID of a port - * - delete a port - * - convert external to internal address - * - convert internal to external address - * - */ - -/* COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_DPMEM_H -#define _RTEMS_RTEMS_DPMEM_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicDPMEM Dual Ported Memory - * - * @ingroup ClassicRTEMS - * - * This encapsulates functionality related to the - * Classic API Dual Ported Memory Manager. - */ -/**@{*/ - -/** - * The following structure defines the port control block. Each port - * has a control block associated with it. This control block contains - * all information required to support the port related operations. - */ -typedef struct { - /** This field is the object management portion of a Port instance. */ - Objects_Control Object; - /** This field is the base internal address of the port. */ - void *internal_base; - /** This field is the base external address of the port. */ - void *external_base; - /** This field is the length of dual-ported area of the port. */ - uint32_t length; -} Dual_ported_memory_Control; - -/** - * @brief Creates a port into a dual-ported memory area. - * - * This routine implements the rtems_port_create directive. The port - * will have the name @a name. The port maps onto an area of dual ported - * memory of length bytes which has internal_start and external_start - * as the internal and external starting addresses, respectively. - * It returns the id of the created port in ID. - * - * @param[in] name is the user defined port name - * @param[in] internal_start is the internal start address of port - * @param[in] external_start is the external start address of port - * @param[in] length is the physical length in bytes - * @param[out] id is the address of port id to set - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. If successful, the id will - * be filled in with the port id. - */ -rtems_status_code rtems_port_create( - rtems_name name, - void *internal_start, - void *external_start, - uint32_t length, - rtems_id *id -); - -/** - * @brief RTEMS Port Name to Id - * - * This routine implements the rtems_port_ident directive. This directive - * returns the port ID associated with name. If more than one port is - * named name, then the port to which the ID belongs is arbitrary. - * - * @param[in] name is the user defined port name - * @param[out] id is the pointer to port id - * - * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful - */ -rtems_status_code rtems_port_ident( - rtems_name name, - rtems_id *id -); - -/** - * @brief RTEMS Delete Port - * - * This routine implements the rtems_port_delete directive. It deletes - * the port associated with ID. - * - * @param[in] id is the dual-ported memory area id - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - */ -rtems_status_code rtems_port_delete( - rtems_id id -); - -/** - * @brief RTEMS Port External to Internal - * - * This routine implements the rtems_port_external_to_internal directive. - * It returns the internal port address which maps to the provided - * external port address for the specified port ID. If the given external - * address is an invalid dual-ported address, then the internal address is - * set to the given external address. - * - * @param[in] id is the id of dp memory object - * @param[in] external is the external address - * @param[out] internal is the pointer of internal address to set - * - * @retval RTEMS_SUCCESSFUL - */ -rtems_status_code rtems_port_external_to_internal( - rtems_id id, - void *external, - void **internal -); - -/** - * @brief RTEMS Port Internal to External - * - * This routine implements the Port_internal_to_external directive. - * It returns the external port address which maps to the provided - * internal port address for the specified port ID. If the given - * internal address is an invalid dual-ported address, then the - * external address is set to the given internal address. - * - * @param[in] id is the id of dual-ported memory object - * @param[in] internal is the internal address to set - * @param[in] external is the pointer to external address - * - * @retval RTEMS_SUCCESSFUL and the external will be filled in - * with the external addresses - */ -rtems_status_code rtems_port_internal_to_external( - rtems_id id, - void *internal, - void **external -); - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/dpmemimpl.h b/cpukit/rtems/include/rtems/rtems/dpmemimpl.h deleted file mode 100644 index 52ac48c8dc..0000000000 --- a/cpukit/rtems/include/rtems/rtems/dpmemimpl.h +++ /dev/null @@ -1,85 +0,0 @@ -/** - * @file - * - * @ingroup ClassicDPMEMImpl - * - * @brief Dual Ported Memory Manager Implementation - */ - -/* COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_DPMEM_INL -#define _RTEMS_RTEMS_DPMEM_INL - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicDPMEMImpl Dual Ported Memory Manager Implementation - * - * @ingroup ClassicDPMEM - * - * @{ - */ - -/** - * @brief Define the internal Dual Ported Memory information - * The following define the internal Dual Ported Memory information. - */ -extern Objects_Information _Dual_ported_memory_Information; - -/** - * @brief Allocates a port control block from the inactive chain - * of free port control blocks. - * - * This routine allocates a port control block from the inactive chain - * of free port control blocks. - */ -RTEMS_INLINE_ROUTINE Dual_ported_memory_Control - *_Dual_ported_memory_Allocate ( void ) -{ - return (Dual_ported_memory_Control *) - _Objects_Allocate( &_Dual_ported_memory_Information ); -} - -/** - * @brief Frees a port control block to the inactive chain - * of free port control blocks. - * - * This routine frees a port control block to the inactive chain - * of free port control blocks. - */ -RTEMS_INLINE_ROUTINE void _Dual_ported_memory_Free ( - Dual_ported_memory_Control *the_port -) -{ - _Objects_Free( &_Dual_ported_memory_Information, &the_port->Object ); -} - -RTEMS_INLINE_ROUTINE Dual_ported_memory_Control *_Dual_ported_memory_Get( - Objects_Id id, - ISR_lock_Context *lock_context -) -{ - return (Dual_ported_memory_Control *) - _Objects_Get( id, lock_context, &_Dual_ported_memory_Information ); -} - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif /* _RTEMS_RTEMS_DPMEM_INL */ -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/event.h b/cpukit/rtems/include/rtems/rtems/event.h deleted file mode 100644 index 1cd64c0cfa..0000000000 --- a/cpukit/rtems/include/rtems/rtems/event.h +++ /dev/null @@ -1,526 +0,0 @@ -/** - * @file rtems/rtems/event.h - * - * @defgroup ClassicEvent Events - * - * @ingroup ClassicRTEMS - * @brief Information Related to Event Manager - * - * This include file contains the information pertaining to the Event - * Manager. This manager provides a high performance method of communication - * and synchronization. - * - * Directives provided are: - * - * - send an event set to a task - * - receive event condition - * - */ - -/* COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_EVENT_H -#define _RTEMS_RTEMS_EVENT_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicEventSet Event Set - * - * @ingroup ClassicEvent - * - * @{ - */ - -/** - * @brief Integer type to hold an event set of up to 32 events represented as - * a bit field. - */ -typedef uint32_t rtems_event_set; - -/** - * @brief Constant used to send or receive all events. - */ -#define RTEMS_ALL_EVENTS 0xFFFFFFFF - -/** @brief Defines the bit in the event set associated with event 0. */ -#define RTEMS_EVENT_0 0x00000001 -/** @brief Defines the bit in the event set associated with event 1. */ -#define RTEMS_EVENT_1 0x00000002 -/** @brief Defines the bit in the event set associated with event 2. */ -#define RTEMS_EVENT_2 0x00000004 -/** @brief Defines the bit in the event set associated with event 3. */ -#define RTEMS_EVENT_3 0x00000008 -/** @brief Defines the bit in the event set associated with event 4. */ -#define RTEMS_EVENT_4 0x00000010 -/** @brief Defines the bit in the event set associated with event 5. */ -#define RTEMS_EVENT_5 0x00000020 -/** @brief Defines the bit in the event set associated with event 6. */ -#define RTEMS_EVENT_6 0x00000040 -/** @brief Defines the bit in the event set associated with event 7. */ -#define RTEMS_EVENT_7 0x00000080 -/** @brief Defines the bit in the event set associated with event 8. */ -#define RTEMS_EVENT_8 0x00000100 -/** @brief Defines the bit in the event set associated with event 9. */ -#define RTEMS_EVENT_9 0x00000200 -/** @brief Defines the bit in the event set associated with event 10. */ -#define RTEMS_EVENT_10 0x00000400 -/** @brief Defines the bit in the event set associated with event 11. */ -#define RTEMS_EVENT_11 0x00000800 -/** @brief Defines the bit in the event set associated with event 12. */ -#define RTEMS_EVENT_12 0x00001000 -/** @brief Defines the bit in the event set associated with event 13. */ -#define RTEMS_EVENT_13 0x00002000 -/** @brief Defines the bit in the event set associated with event 14. */ -#define RTEMS_EVENT_14 0x00004000 -/** @brief Defines the bit in the event set associated with event 15. */ -#define RTEMS_EVENT_15 0x00008000 -/** @brief Defines the bit in the event set associated with event 16. */ -#define RTEMS_EVENT_16 0x00010000 -/** @brief Defines the bit in the event set associated with event 17. */ -#define RTEMS_EVENT_17 0x00020000 -/** @brief Defines the bit in the event set associated with event 18. */ -#define RTEMS_EVENT_18 0x00040000 -/** @brief Defines the bit in the event set associated with event 19. */ -#define RTEMS_EVENT_19 0x00080000 -/** @brief Defines the bit in the event set associated with event 20. */ -#define RTEMS_EVENT_20 0x00100000 -/** @brief Defines the bit in the event set associated with event 21. */ -#define RTEMS_EVENT_21 0x00200000 -/** @brief Defines the bit in the event set associated with event 22. */ -#define RTEMS_EVENT_22 0x00400000 -/** @brief Defines the bit in the event set associated with event 23. */ -#define RTEMS_EVENT_23 0x00800000 -/** @brief Defines the bit in the event set associated with event 24. */ -#define RTEMS_EVENT_24 0x01000000 -/** @brief Defines the bit in the event set associated with event 25. */ -#define RTEMS_EVENT_25 0x02000000 -/** @brief Defines the bit in the event set associated with event 26. */ -#define RTEMS_EVENT_26 0x04000000 -/** @brief Defines the bit in the event set associated with event 27. */ -#define RTEMS_EVENT_27 0x08000000 -/** @brief Defines the bit in the event set associated with event 29. */ -#define RTEMS_EVENT_28 0x10000000 -/** @brief Defines the bit in the event set associated with event 29. */ -#define RTEMS_EVENT_29 0x20000000 -/** @brief Defines the bit in the event set associated with event 30. */ -#define RTEMS_EVENT_30 0x40000000 -/** @brief Defines the bit in the event set associated with event 31. */ -#define RTEMS_EVENT_31 0x80000000 - -/** @} */ - -/** - * @defgroup ClassicEvent Events - * - * @ingroup ClassicRTEMS - * - * @brief The event manager provides a high performance method of intertask - * communication and synchronization. - * - * An event flag is used by a task (or ISR) to inform another task of the - * occurrence of a significant situation. Thirty-two event flags are - * associated with each task. A collection of one or more event flags is - * referred to as an event set. The data type rtems_event_set is used to - * manage event sets. - * - * The application developer should remember the following key characteristics - * of event operations when utilizing the event manager: - * - * - Events provide a simple synchronization facility. - * - Events are aimed at tasks. - * - Tasks can wait on more than one event simultaneously. - * - Events are independent of one another. - * - Events do not hold or transport data. - * - Events are not queued. In other words, if an event is sent more than once - * to a task before being received, the second and subsequent send - * operations to that same task have no effect. - * - * An event set is posted when it is directed (or sent) to a task. A pending - * event is an event that has been posted but not received. An event condition - * is used to specify the event set which the task desires to receive and the - * algorithm which will be used to determine when the request is satisfied. An - * event condition is satisfied based upon one of two algorithms which are - * selected by the user. The @ref RTEMS_EVENT_ANY algorithm states that an - * event condition is satisfied when at least a single requested event is - * posted. The @ref RTEMS_EVENT_ALL algorithm states that an event condition - * is satisfied when every requested event is posted. - * - * An event set or condition is built by a bitwise or of the desired events. - * The set of valid events is @ref RTEMS_EVENT_0 through @ref RTEMS_EVENT_31. - * If an event is not explicitly specified in the set or condition, then it is - * not present. Events are specifically designed to be mutually exclusive, - * therefore bitwise or and addition operations are equivalent as long as each - * event appears exactly once in the event set list. - * - * For example, when sending the event set consisting of @ref RTEMS_EVENT_6, - * @ref RTEMS_EVENT_15, and @ref RTEMS_EVENT_31, the event parameter to the - * rtems_event_send() directive should be @ref RTEMS_EVENT_6 | - * @ref RTEMS_EVENT_15 | @ref RTEMS_EVENT_31. - * - * @{ - */ - -/** - * @brief Constant used to receive the set of currently pending events in - * rtems_event_receive(). - */ -#define RTEMS_PENDING_EVENTS 0 - -/** - * @brief Sends an Event Set to the Target Task - * - * This directive sends an event set @a event_in to the task specified by - * @a id. - * - * Based upon the state of the target task, one of the following situations - * applies. The target task is - * - blocked waiting for events. - * If the waiting task's input event condition is - * - satisfied, then the task is made ready for execution. - * - not satisfied, then the event set is posted but left pending and the - * task remains blocked. - * - not waiting for events. - * - The event set is posted and left pending. - * - * Identical events sent to a task are not queued. In other words, the second, - * and subsequent, posting of an event to a task before it can perform an - * rtems_event_receive() has no effect. - * - * The calling task will be preempted if it has preemption enabled and a - * higher priority task is unblocked as the result of this directive. - * - * Sending an event set to a global task which does not reside on the local - * node will generate a request telling the remote node to send the event set - * to the appropriate task. - * - * @param[in] id Identifier of the target task. Specifying @ref RTEMS_SELF - * results in the event set being sent to the calling task. - * @param[in] event_in Event set sent to the target task. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_INVALID_ID Invalid task identifier. - */ -rtems_status_code rtems_event_send ( - rtems_id id, - rtems_event_set event_in -); - -/** - * @brief Receives pending events. - * - * This directive attempts to receive the event condition specified in - * @a event_in. If @a event_in is set to @ref RTEMS_PENDING_EVENTS, then the - * current pending events are returned in @a event_out and left pending. The - * @ref RTEMS_WAIT and @ref RTEMS_NO_WAIT options in the @a option_set - * parameter are used to specify whether or not the task is willing to wait - * for the event condition to be satisfied. The @ref RTEMS_EVENT_ANY and @ref - * RTEMS_EVENT_ALL are used in the @a option_set parameter to specify whether - * at least a single event or the complete event set is necessary to satisfy - * the event condition. The @a event_out parameter is returned to the calling - * task with the value that corresponds to the events in @a event_in that were - * satisfied. - * - * A task can determine the pending event set by using a value of - * @ref RTEMS_PENDING_EVENTS for the input event set @a event_in. The pending - * events are returned to the calling task but the event set is left - * unaltered. - * - * A task can receive all of the currently pending events by using the a value - * of @ref RTEMS_ALL_EVENTS for the input event set @a event_in and - * @ref RTEMS_NO_WAIT | @ref RTEMS_EVENT_ANY for the option set @a option_set. - * The pending events are returned to the calling task and the event set is - * cleared. If no events are pending then the @ref RTEMS_UNSATISFIED status - * code will be returned. - * - * If pending events satisfy the event condition, then @a event_out is set to - * the satisfied events and the pending events in the event condition are - * cleared. If the event condition is not satisfied and @ref RTEMS_NO_WAIT is - * specified, then @a event_out is set to the currently satisfied events. If - * the calling task chooses to wait, then it will block waiting for the event - * condition. - * - * If the calling task must wait for the event condition to be satisfied, then - * the timeout parameter is used to specify the maximum interval to wait. If - * it is set to @ref RTEMS_NO_TIMEOUT, then the calling task will wait forever. - * - * This directive only affects the events specified in @a event_in. Any - * pending events that do not correspond to any of the events specified in - * @a event_in will be left pending. - * - * A clock tick is required to support the wait with time out functionality of - * this directive. - * - * @param[in] event_in Set of requested events (input events). - * @param[in] option_set Use a bitwise or of the following options - * - @ref RTEMS_WAIT - task will wait for event (default), - * - @ref RTEMS_NO_WAIT - task should not wait, - * - @ref RTEMS_EVENT_ALL - return after all events (default), and - * - @ref RTEMS_EVENT_ANY - return after any events. - * @param[in] ticks Time out in ticks. Use @ref RTEMS_NO_TIMEOUT to wait - * without a time out (potentially forever). - * @param[out] event_out Set of received events (output events). - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_UNSATISFIED Input events not satisfied (only with the - * @ref RTEMS_NO_WAIT option). - * @retval RTEMS_INVALID_ADDRESS The @a event_out pointer is @c NULL. - * @retval RTEMS_TIMEOUT Timed out waiting for events. - */ -rtems_status_code rtems_event_receive ( - rtems_event_set event_in, - rtems_option option_set, - rtems_interval ticks, - rtems_event_set *event_out -); - -/** @} */ - -/** - * @defgroup ClassicEventSystem System Events - * - * @ingroup ClassicEvent - * - * System events are similar to normal events. They offer a second set of - * events. These events are intended for internal RTEMS use and should not be - * used by applications (with the exception of the transient system event). - * - * The event @ref RTEMS_EVENT_SYSTEM_TRANSIENT is used for transient usage. - * See also @ref ClassicEventTransient. This event may be used by every entity - * that fulfils its usage pattern. - */ -/**@{**/ - -/** - * @brief Reserved system event for network SBWAIT usage. - */ -#define RTEMS_EVENT_SYSTEM_NETWORK_SBWAIT RTEMS_EVENT_24 - -/** - * @brief Reserved system event for network SOSLEEP usage. - */ -#define RTEMS_EVENT_SYSTEM_NETWORK_SOSLEEP RTEMS_EVENT_25 - -/** - * @brief Reserved system event for network socket close. - */ -#define RTEMS_EVENT_SYSTEM_NETWORK_CLOSE RTEMS_EVENT_26 - -/** - * @brief Reserved system event to resume server threads, e.g timer or - * interrupt server. - */ -#define RTEMS_EVENT_SYSTEM_SERVER_RESUME RTEMS_EVENT_29 - -/** - * @brief Reserved system event for the server threads, e.g timer or interrupt - * server. - */ -#define RTEMS_EVENT_SYSTEM_SERVER RTEMS_EVENT_30 - -/** - * @brief Reserved system event for transient usage. - */ -#define RTEMS_EVENT_SYSTEM_TRANSIENT RTEMS_EVENT_31 - -/** - * @brief See rtems_event_send(). - */ -rtems_status_code rtems_event_system_send( - rtems_id id, - rtems_event_set event_in -); - -/** - * @brief See rtems_event_receive(). - */ -rtems_status_code rtems_event_system_receive( - rtems_event_set event_in, - rtems_option option_set, - rtems_interval ticks, - rtems_event_set *event_out -); - -/** @} */ - -/** - * @defgroup ClassicEventTransient Transient Event - * - * @ingroup ClassicEvent - * - * The transient event can be used by a client task to issue a request to - * another task or interrupt service (server). The server can send the - * transient event to the client task to notify about a request completion, see - * rtems_event_transient_send(). The client task can wait for the transient - * event reception with rtems_event_transient_receive(). - * - * The user of the transient event must ensure that this event is not pending - * once the request is finished or cancelled. A successful reception of the - * transient event with rtems_event_transient_receive() will clear the - * transient event. If a reception with timeout is used the transient event - * state is undefined after a timeout return status. The transient event can - * be cleared unconditionally with the non-blocking - * rtems_event_transient_clear(). - * - * @msc - * hscale="1.6"; - * M [label="Main Task"], IDLE [label="Idle Task"], S [label="Server"], TIME [label="System Tick Handler"]; - * |||; - * --- [label="sequence with request completion"]; - * M box M [label="prepare request\nissue request\nrtems_event_transient_receive()"]; - * M=>>IDLE [label="blocking operation"]; - * IDLE=>>S [label="request completion"]; - * S box S [label="rtems_event_transient_send()"]; - * S=>>M [label="task is ready again"]; - * M box M [label="finish request"]; - * |||; - * --- [label="sequence with early request completion"]; - * M box M [label="prepare request\nissue request"]; - * M=>>S [label="request completion"]; - * S box S [label="rtems_event_transient_send()"]; - * S=>>M [label="transient event is now pending"]; - * M box M [label="rtems_event_transient_receive()\nfinish request"]; - * |||; - * --- [label="sequence with timeout event"]; - * M box M [label="prepare request\nissue request\nrtems_event_transient_receive()"]; - * M=>>IDLE [label="blocking operation"]; - * IDLE=>>TIME [label="timeout expired"]; - * TIME box TIME [label="cancel blocking operation"]; - * TIME=>>M [label="task is ready again"]; - * M box M [label="cancel request\nrtems_event_transient_clear()"]; - * @endmsc - * - * Suppose you have a task that wants to issue a certain request and then waits - * for request completion. It can create a request structure and store its - * task identifier there. Now it can place the request on a work queue of - * another task (or interrupt handler). Afterwards the task waits for the - * reception of the transient event. Once the server task is finished with the - * request it can send the transient event to the waiting task and wake it up. - * - * @code - * #include - * #include - * - * typedef struct { - * rtems_id task_id; - * bool work_done; - * } request; - * - * void server(rtems_task_argument arg) - * { - * rtems_status_code sc; - * request *req = (request *) arg; - * - * req->work_done = true; - * - * sc = rtems_event_transient_send(req->task_id); - * assert(sc == RTEMS_SUCCESSFUL); - * - * sc = rtems_task_delete(RTEMS_SELF); - * assert(sc == RTEMS_SUCCESSFUL); - * } - * - * void issue_request_and_wait_for_completion(void) - * { - * rtems_status_code sc; - * rtems_id id; - * request req; - * - * req.task_id = rtems_task_self(); - * req.work_done = false; - * - * sc = rtems_task_create( - * rtems_build_name('S', 'E', 'R', 'V'), - * 1, - * RTEMS_MINIMUM_STACK_SIZE, - * RTEMS_DEFAULT_MODES, - * RTEMS_DEFAULT_ATTRIBUTES, - * &id - * ); - * assert(sc == RTEMS_SUCCESSFUL); - * - * sc = rtems_task_start(id, server, (rtems_task_argument) &req); - * assert(sc == RTEMS_SUCCESSFUL); - * - * sc = rtems_event_transient_receive(RTEMS_WAIT, RTEMS_NO_TIMEOUT); - * assert(sc == RTEMS_SUCCESSFUL); - * - * assert(req.work_done); - * } - * @endcode - */ -/**@{**/ - -/** - * @brief See rtems_event_system_send(). - * - * The system event @ref RTEMS_EVENT_SYSTEM_TRANSIENT will be sent. - */ -RTEMS_INLINE_ROUTINE rtems_status_code rtems_event_transient_send( - rtems_id id -) -{ - return rtems_event_system_send( id, RTEMS_EVENT_SYSTEM_TRANSIENT ); -} - -/** - * @brief See rtems_event_system_receive(). - * - * The system event @ref RTEMS_EVENT_SYSTEM_TRANSIENT will be received. - */ -RTEMS_INLINE_ROUTINE rtems_status_code rtems_event_transient_receive( - rtems_option option_set, - rtems_interval ticks -) -{ - rtems_event_set event_out; - - return rtems_event_system_receive( - RTEMS_EVENT_SYSTEM_TRANSIENT, - RTEMS_EVENT_ALL | option_set, - ticks, - &event_out - ); -} - -/** - * @brief See rtems_event_system_receive(). - * - * The system event @ref RTEMS_EVENT_SYSTEM_TRANSIENT will be cleared. - */ -RTEMS_INLINE_ROUTINE void rtems_event_transient_clear( void ) -{ - rtems_event_set event_out; - - rtems_event_system_receive( - RTEMS_EVENT_SYSTEM_TRANSIENT, - RTEMS_EVENT_ALL | RTEMS_NO_WAIT, - 0, - &event_out - ); -} - -/** @} */ - -typedef struct { - rtems_event_set pending_events; -} Event_Control; - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/eventimpl.h b/cpukit/rtems/include/rtems/rtems/eventimpl.h deleted file mode 100644 index 933ea0fe2b..0000000000 --- a/cpukit/rtems/include/rtems/rtems/eventimpl.h +++ /dev/null @@ -1,146 +0,0 @@ -/** - * @file - * - * @ingroup ClassicEventImpl - * - * @brief Classic Event Implementation - */ - -/* COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_EVENTIMPL_H -#define _RTEMS_RTEMS_EVENTIMPL_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicEventImpl Classic Event Implementation - * - * @ingroup ClassicEvent - * - * @{ - */ - -/** - * This constant is passed as the event_in to the - * rtems_event_receive directive to determine which events are pending. - */ -#define EVENT_CURRENT 0 - -/** - * The following constant is the value of an event set which - * has no events pending. - */ -#define EVENT_SETS_NONE_PENDING 0 - -rtems_status_code _Event_Seize( - rtems_event_set event_in, - rtems_option option_set, - rtems_interval ticks, - rtems_event_set *event_out, - Thread_Control *executing, - Event_Control *event, - Thread_Wait_flags wait_class, - States_Control block_state, - ISR_lock_Context *lock_context -); - -rtems_status_code _Event_Surrender( - Thread_Control *the_thread, - rtems_event_set event_in, - Event_Control *event, - Thread_Wait_flags wait_class, - ISR_lock_Context *lock_context -); - -/** - * @brief Timeout Event - */ -void _Event_Timeout( - Objects_Id id, - void *arg -); - -RTEMS_INLINE_ROUTINE void _Event_Initialize( Event_Control *event ) -{ - event->pending_events = EVENT_SETS_NONE_PENDING; -} - -/** - * @brief Checks if on events are posted in the event_set. - * - * This function returns TRUE if on events are posted in the event_set, - * and FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Event_sets_Is_empty( - rtems_event_set the_event_set -) -{ - return ( the_event_set == 0 ); -} - -/** - * @brief Posts the given new_events into the event_set passed in. - * - * This routine posts the given new_events into the event_set - * passed in. The result is returned to the user in event_set. - */ -RTEMS_INLINE_ROUTINE void _Event_sets_Post( - rtems_event_set the_new_events, - rtems_event_set *the_event_set -) -{ - *the_event_set |= the_new_events; -} - -/** - * @brief Returns the events in event_condition that are set in event_set. - * - * This function returns the events in event_condition which are - * set in event_set. - */ -RTEMS_INLINE_ROUTINE rtems_event_set _Event_sets_Get( - rtems_event_set the_event_set, - rtems_event_set the_event_condition -) -{ - return ( the_event_set & the_event_condition ); -} - -/** - * @brief Removes the events in mask from the event_set passed in. - * - * This function removes the events in mask from the event_set - * passed in. The result is returned to the user in event_set. - */ -RTEMS_INLINE_ROUTINE rtems_event_set _Event_sets_Clear( - rtems_event_set the_event_set, - rtems_event_set the_mask -) -{ - return ( the_event_set & ~(the_mask) ); -} - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#if defined(RTEMS_MULTIPROCESSING) -#include -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/eventmp.h b/cpukit/rtems/include/rtems/rtems/eventmp.h deleted file mode 100644 index a80e60c4e0..0000000000 --- a/cpukit/rtems/include/rtems/rtems/eventmp.h +++ /dev/null @@ -1,101 +0,0 @@ -/** - * @file rtems/rtems/eventmp.h - * - * @defgroup ClassicEventMP Event MP Support - * - * @ingroup ClassicRTEMS - * @brief Event Manager MP Support - * - * This include file contains all the constants and structures associated - * with the Multiprocessing Support in the Event Manager. - */ - -/* COPYRIGHT (c) 1989-2013. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_EVENTMP_H -#define _RTEMS_RTEMS_EVENTMP_H - -#ifndef _RTEMS_RTEMS_EVENTIMPL_H -# error "Never use directly; include instead." -#endif - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicEventMP Event MP Support - * - * @ingroup ClassicMP - * - * This encapsulates functionality related to the transparent multiprocessing - * support within the Classic API Event Manager. - */ -/**@{*/ - -/* - * @brief Event_MP_Send_process_packet - * - * This routine performs a remote procedure call so that a - * process operation can be performed on another node. - * - * @note This routine is not needed since there are no process - * packets to be sent by this manager. - */ - -/** - * @brief Issues a remote rtems_event_send() request. - */ -rtems_status_code _Event_MP_Send( - rtems_id id, - rtems_event_set event_in -); - -/** - * @brief Event MP Packet Process - * - * This routine performs the actions specific to this package for - * the request from another node. - */ -void _Event_MP_Process_packet ( - rtems_packet_prefix *the_packet_prefix -); - -/* - * @brief Event_MP_Send_object_was_deleted - * - * This routine is invoked indirectly by the thread queue - * when a proxy has been removed from the thread queue and - * the remote node must be informed of this. - * - * This routine is not needed since there are no objects - * deleted by this manager. - */ - -/* - * @brief Event_MP_Send_extract_proxy - * - * This routine is invoked when a task is deleted and it - * has a proxy which must be removed from a thread queue and - * the remote node must be informed of this. - * - * This routine is not needed since there are no objects - * deleted by this manager. - */ - -#ifdef __cplusplus -} -#endif - -/**@}*/ - -#endif -/* end of file */ diff --git a/cpukit/rtems/include/rtems/rtems/intr.h b/cpukit/rtems/include/rtems/rtems/intr.h deleted file mode 100644 index 7f99d93883..0000000000 --- a/cpukit/rtems/include/rtems/rtems/intr.h +++ /dev/null @@ -1,373 +0,0 @@ -/** - * @file rtems/rtems/intr.h - * - * @defgroup ClassicINTR Interrupts - * - * @ingroup ClassicRTEMS - * @brief Header file for Interrupt Manager - * - * This include file contains all the constants and structures associated with - * the Interrupt Manager. - */ - -/* COPYRIGHT (c) 1989-2013. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_INTR_H -#define _RTEMS_RTEMS_INTR_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include - -/** - * @defgroup ClassicINTR Interrupts - * - * @ingroup ClassicRTEMS - * - * This encapsulates functionality related to the Classic API Interrupt - * Manager. - */ -/**@{*/ - -/** - * @brief Interrupt level type. - */ -typedef ISR_Level rtems_interrupt_level; - -/** - * @brief Control block type used to manage the vectors. - */ -typedef ISR_Vector_number rtems_vector_number; - -/** - * @brief Return type for interrupt handler. - */ -typedef ISR_Handler rtems_isr; - -#if (CPU_SIMPLE_VECTORED_INTERRUPTS == FALSE) - -typedef ISR_Handler_entry rtems_isr_entry; - -#else -/** - * @brief Interrupt handler type. - * - * @see rtems_interrupt_catch() - */ -typedef rtems_isr ( *rtems_isr_entry )( - rtems_vector_number - ); - -/** - * @brief RTEMS Interrupt Catch - * - * This directive installs @a new_isr_handler as the RTEMS interrupt service - * routine for the interrupt vector with number @a vector. The previous RTEMS - * interrupt service routine is returned in @a old_isr_handler. - * - * @param[in] new_isr_handler is the address of interrupt service routine - * @param[in] vector is the interrupt vector number - * @param[in] old_isr_handler address at which to store previous ISR address - * - * @retval RTEMS_SUCCESSFUL and *old_isr_handler filled with previous ISR - * address - */ -rtems_status_code rtems_interrupt_catch( - rtems_isr_entry new_isr_handler, - rtems_vector_number vector, - rtems_isr_entry *old_isr_handler -); -#endif - -#if !defined(RTEMS_SMP) - -/** - * @brief Disable RTEMS Interrupt - * - * @note The interrupt level shall be of type @ref rtems_interrupt_level. - * - * This macro is only available on uni-processor configurations. The macro - * rtems_interrupt_local_disable() is available on all configurations. - */ -#define rtems_interrupt_disable( _isr_cookie ) \ - _ISR_Local_disable(_isr_cookie) - -/** - * @brief Enable RTEMS Interrupt - * - * @note The interrupt level shall be of type @ref rtems_interrupt_level. - * - * This macro is only available on uni-processor configurations. The macro - * rtems_interrupt_local_enable() is available on all configurations. - */ -#define rtems_interrupt_enable( _isr_cookie ) \ - _ISR_Local_enable(_isr_cookie) - -/** - * @brief Flash RTEMS Interrupt - * - * @note The interrupt level shall be of type @ref rtems_interrupt_level. - * - * This macro is only available on uni-processor configurations. The macro - * rtems_interrupt_local_disable() and rtems_interrupt_local_enable() is - * available on all configurations. - */ -#define rtems_interrupt_flash( _isr_cookie ) \ - _ISR_Local_flash(_isr_cookie) - -#endif /* RTEMS_SMP */ - -/** - * @brief This macro disables the interrupts on the current processor. - * - * On SMP configurations this will not ensure system wide mutual exclusion. - * Use interrupt locks instead. - * - * @param[in] _isr_cookie The previous interrupt level is returned. The type - * of this variable must be rtems_interrupt_level. - * - * @see rtems_interrupt_local_enable(). - */ -#define rtems_interrupt_local_disable( _isr_cookie ) \ - _ISR_Local_disable( _isr_cookie ) - -/** - * @brief This macro restores the previous interrupt level on the current - * processor. - * - * @param[in] _isr_cookie The previous interrupt level returned by - * rtems_interrupt_local_disable(). - */ -#define rtems_interrupt_local_enable( _isr_cookie ) \ - _ISR_Local_enable( _isr_cookie ) - -/** - * @brief RTEMS Interrupt Is in Progress - * - * A return value of true indicates that the caller is an interrupt service - * routine and @b not a thread. The directives available to an interrupt - * service routine are restricted. - */ -#define rtems_interrupt_is_in_progress() \ - _ISR_Is_in_progress() - -/** - * @brief This routine generates an interrupt. - * - * @note No implementation. - */ -#define rtems_interrupt_cause( _interrupt_to_cause ) - -/** - * @brief This routine clears the specified interrupt. - * - * @note No implementation. - */ -#define rtems_interrupt_clear( _interrupt_to_clear ) - -/** - * @defgroup ClassicINTRLocks Interrupt Locks - * - * @ingroup ClassicINTR - * - * @brief Low-level lock to protect critical sections accessed by threads and - * interrupt service routines. - * - * On single processor configurations the interrupt locks degrade to simple - * interrupt disable/enable sequences. No additional storage or objects are - * required. - * - * This synchronization primitive is supported on SMP configurations. Here SMP - * locks are used. - * @{ - */ - -/** - * @brief Interrupt lock control. - */ -typedef ISR_lock_Control rtems_interrupt_lock; - -/** - * @brief Local interrupt lock context for acquire and release pairs. - */ -typedef ISR_lock_Context rtems_interrupt_lock_context; - -/** - * @brief Defines an interrupt lock member. - * - * Do not add a ';' after this macro. - * - * @param _designator The designator for the interrupt lock. - */ -#define RTEMS_INTERRUPT_LOCK_MEMBER( _designator ) \ - ISR_LOCK_MEMBER( _designator ) - -/** - * @brief Declares an interrupt lock variable. - * - * Do not add a ';' after this macro. - * - * @param _qualifier The qualifier for the interrupt lock, e.g. extern. - * @param _designator The designator for the interrupt lock. - */ -#define RTEMS_INTERRUPT_LOCK_DECLARE( _qualifier, _designator ) \ - ISR_LOCK_DECLARE( _qualifier, _designator ) - -/** - * @brief Defines an interrupt lock variable. - * - * Do not add a ';' after this macro. - * - * @param _qualifier The qualifier for the interrupt lock, e.g. static. - * @param _designator The designator for the interrupt lock. - * @param _name The name for the interrupt lock. It must be a string. The - * name is only used if profiling is enabled. - */ -#define RTEMS_INTERRUPT_LOCK_DEFINE( _qualifier, _designator, _name ) \ - ISR_LOCK_DEFINE( _qualifier, _designator, _name ) - -/** - * @brief Defines an interrupt lock variable reference. - * - * Do not add a ';' after this macro. - * - * @param _designator The designator for the interrupt lock reference. - * @param _target The target for the interrupt lock reference. - */ -#define RTEMS_INTERRUPT_LOCK_REFERENCE( _designator, _target ) \ - ISR_LOCK_REFERENCE( _designator, _target ) - -/** - * @brief Initializer for static initialization of interrupt locks. - * - * @param _name The name for the interrupt lock. It must be a string. The - * name is only used if profiling is enabled. - */ -#define RTEMS_INTERRUPT_LOCK_INITIALIZER( _name ) ISR_LOCK_INITIALIZER( _name ) - -/** - * @brief Initializes an interrupt lock. - * - * Concurrent initialization leads to unpredictable results. - * - * @param[in,out] _lock The interrupt lock. - * @param[in] _name The name for the interrupt lock. This name must be a - * string persistent throughout the life time of this lock. The name is only - * used if profiling is enabled. - */ -#define rtems_interrupt_lock_initialize( _lock, _name ) \ - _ISR_lock_Initialize( _lock, _name ) - -/** - * @brief Destroys an interrupt lock. - * - * Concurrent destruction leads to unpredictable results. - * - * @param[in,out] _lock The interrupt lock control. - */ -#define rtems_interrupt_lock_destroy( _lock ) \ - _ISR_lock_Destroy( _lock ) - -/** - * @brief Disables interrupts on the current processor. - * - * This function can be used in thread and interrupt context. - * - * @param[in,out] _lock_context The local interrupt lock context for an acquire - * and release pair. - * - * @see rtems_interrupt_lock_acquire_isr(). - */ -#define rtems_interrupt_lock_interrupt_disable( _lock_context ) \ - _ISR_lock_ISR_disable( _lock_context ) - -/** - * @brief Acquires an interrupt lock. - * - * Interrupts will be disabled. On SMP configurations this function acquires - * an SMP lock. - * - * This function can be used in thread and interrupt context. - * - * @param[in,out] _lock The interrupt lock. - * @param[in,out] _lock_context The local interrupt lock context for an acquire - * and release pair. - * - * @see rtems_interrupt_lock_release(). - */ -#define rtems_interrupt_lock_acquire( _lock, _lock_context ) \ - _ISR_lock_ISR_disable_and_acquire( _lock, _lock_context ) - -/** - * @brief Releases an interrupt lock. - * - * The interrupt status will be restored. On SMP configurations this function - * releases an SMP lock. - * - * This function can be used in thread and interrupt context. - * - * @param[in,out] _lock The interrupt lock. - * @param[in,out] _lock_context The local interrupt lock context for an acquire - * and release pair. - * - * @see rtems_interrupt_lock_acquire(). - */ -#define rtems_interrupt_lock_release( _lock, _lock_context ) \ - _ISR_lock_Release_and_ISR_enable( _lock, _lock_context ) - -/** - * @brief Acquires an interrupt lock in the corresponding interrupt service - * routine. - * - * The interrupt status will remain unchanged. On SMP configurations this - * function acquires an SMP lock. - * - * In case the corresponding interrupt service routine can be interrupted by - * higher priority interrupts and these interrupts enter the critical section - * protected by this lock, then the result is unpredictable. - * - * @param[in,out] _lock The interrupt lock. - * @param[in,out] _lock_context The local interrupt lock context for an acquire - * and release pair. - * - * @see rtems_interrupt_lock_release_isr(). - */ -#define rtems_interrupt_lock_acquire_isr( _lock, _lock_context ) \ - _ISR_lock_Acquire( _lock, _lock_context ) - -/** - * @brief Releases an interrupt lock in the corresponding interrupt service - * routine. - * - * The interrupt status will remain unchanged. On SMP configurations this - * function releases an SMP lock. - * - * @param[in,out] _lock The interrupt lock. - * @param[in,out] _lock_context The local interrupt lock context for an acquire - * and release pair. - * - * @see rtems_interrupt_lock_acquire_isr(). - */ -#define rtems_interrupt_lock_release_isr( _lock, _lock_context ) \ - _ISR_lock_Release( _lock, _lock_context ) - -/** @} */ - -#ifdef __cplusplus -} -#endif - -/**@}*/ - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/message.h b/cpukit/rtems/include/rtems/rtems/message.h deleted file mode 100644 index 8ae9e156a1..0000000000 --- a/cpukit/rtems/include/rtems/rtems/message.h +++ /dev/null @@ -1,270 +0,0 @@ -/** - * @file rtems/rtems/message.h - * - * @defgroup ClassicMessageQueue Message Queues - * - * @ingroup ClassicRTEMS - * @brief Message Queue Manager - * - * This include file contains all the constants and structures associated - * with the Message Queue Manager. This manager provides a mechanism for - * communication and synchronization between tasks using messages. - * - * Directives provided are: - * - * - create a queue - * - get ID of a queue - * - delete a queue - * - put a message at the rear of a queue - * - put a message at the front of a queue - * - broadcast N messages to a queue - * - receive message from a queue - * - flush all messages on a queue - */ - -/* COPYRIGHT (c) 1989-2013. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_MESSAGE_H -#define _RTEMS_RTEMS_MESSAGE_H - -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @ingroup ClassicMessageQueueImpl - * - * The following records define the control block used to manage - * each message queue. - */ -typedef struct { - /** This field is the inherited object characteristics. */ - Objects_Control Object; - /** This field is the instance of the SuperCore Message Queue. */ - CORE_message_queue_Control message_queue; - /** This field is the attribute set as defined by the API. */ - rtems_attribute attribute_set; -} Message_queue_Control; - -/** - * @defgroup ClassicMessageQueue Message Queues - * - * @ingroup ClassicRTEMS - * - * This encapsulates functionality related to the Classic API Message Queue - * Manager. - */ -/**@{*/ - -/** - * @brief RTEMS Create Message Queue - * - * This routine implements the rtems_message_queue_create directive. The - * message queue will have the @a name. If the @a attribute_set indicates - * that the message queue is to be limited in the number of messages - * that can be outstanding, then @a count indicates the maximum number of - * messages that will be held. It returns the id of the created - * message queue in @a id. - * - * @param[in] name is the user defined queue name - * @param[in] count is the maximum message and reserved buffer count - * @param[in] max_message_size is the maximum size of each message - * @param[in] attribute_set is the process method - * @param[in] id is the pointer to queue - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. If successful, the @a id will - * be filled in with the queue id. - */ -rtems_status_code rtems_message_queue_create( - rtems_name name, - uint32_t count, - size_t max_message_size, - rtems_attribute attribute_set, - rtems_id *id -); - -/** - * @brief RTEMS Message Queue Name to Id - * - * This routine implements the rtems_message_queue_ident directive. - * This directive returns the message queue ID associated with NAME. - * If more than one message queue is named name, then the message - * queue to which the ID belongs is arbitrary. node indicates the - * extent of the search for the ID of the message queue named name. - * The search can be limited to a particular node or allowed to - * encompass all nodes. - * - * @param[in] name is the user defined message queue name - * @param[in] node is the node(s) to be searched - * @param[in] id is the pointer to message queue id - * - * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful and - * *id filled with the message queue id - */ -rtems_status_code rtems_message_queue_ident( - rtems_name name, - uint32_t node, - rtems_id *id -); - -/** - * @brief RTEMS Delete Message Queue - * - * This routine implements the rtems_message_queue_delete directive. The - * message queue indicated by ID is deleted. - * - * @param[in] id is the queue id - * - * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful - */ -rtems_status_code rtems_message_queue_delete( - rtems_id id -); - -/** - * @brief rtems_message_queue_send - * - * Message Queue Manager - rtems_message_queue_send - * - * This routine implements the rtems_message_queue_send directive. - * This directive sends the message buffer to the message queue - * indicated by ID. If one or more tasks is blocked waiting - * to receive a message from this message queue, then one will - * receive the message. The task selected to receive the - * message is based on the task queue discipline algorithm in - * use by this particular message queue. If no tasks are waiting, - * then the message buffer will be placed at the REAR of the - * chain of pending messages for this message queue. - */ -rtems_status_code rtems_message_queue_send( - rtems_id id, - const void *buffer, - size_t size -); - -/** - * @brief RTEMS Urgent Message Queue - * - * This routine implements the rtems_message_queue_urgent directive. - * This directive has the same behavior as rtems_message_queue_send - * except that if no tasks are waiting, the message buffer will - * be placed at the FRONT of the chain of pending messages rather - * than at the REAR. - * - * @param[in] id is the pointer to message queue - * @param[in] buffer is the pointer to message buffer - * @param[in] size is the size of message to send urgently - * - * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful - */ -rtems_status_code rtems_message_queue_urgent( - rtems_id id, - const void *buffer, - size_t size -); - -/** - * @brief RTEMS Broadcast Message Queue - * - * This routine implements the rtems_message_queue_broadcast directive. - * This directive sends the message buffer to all of the tasks blocked - * waiting for a message on the message queue indicated by ID. - * If no tasks are waiting, then the message buffer will not be queued. - * - * @param[in] id is the pointer to message queue - * @param[in] buffer is the pointer to message buffer - * @param[in] size is the size of message to broadcast - * @param[in] count pointer to area to store number of threads made ready - * - * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful and - * *count filled in with number of threads made ready - */ -rtems_status_code rtems_message_queue_broadcast( - rtems_id id, - const void *buffer, - size_t size, - uint32_t *count -); - -/** - * @brief RTEMS Message Queue Receive - * - * This routine implements the rtems_message_queue_receive directive. - * This directive is invoked when the calling task wishes to receive - * a message from the message queue indicated by ID. The received - * message is to be placed in buffer. If no messages are outstanding - * and the option_set indicates that the task is willing to block, - * then the task will be blocked until a message arrives or until, - * optionally, timeout clock ticks have passed. - * - * @param[in] id is the queue id - * @param[in] buffer is the pointer to message buffer - * @param[in] size is the size of message receive - * @param[in] option_set is the options on receive - * @param[in] timeout is the number of ticks to wait - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - */ -rtems_status_code rtems_message_queue_receive( - rtems_id id, - void *buffer, - size_t *size, - rtems_option option_set, - rtems_interval timeout -); - -/** - * @brief rtems_message_queue_flush - * - * This routine implements the rtems_message_queue_flush directive. - * This directive takes all outstanding messages for the message - * queue indicated by ID and returns them to the inactive message - * chain. The number of messages flushed is returned in COUNT. - * - * Message Queue Manager - */ -rtems_status_code rtems_message_queue_flush( - rtems_id id, - uint32_t *count -); - -/** - * @brief RTEMS Message Queue Get Number Pending - * - * Message Queue Manager - * - * This routine implements the rtems_message_queue_get_number_pending - * directive. This directive returns the number of pending - * messages for the message queue indicated by ID - * chain. The number of messages pending is returned in COUNT. - */ -rtems_status_code rtems_message_queue_get_number_pending( - rtems_id id, - uint32_t *count -); - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/messageimpl.h b/cpukit/rtems/include/rtems/rtems/messageimpl.h deleted file mode 100644 index df7cea6829..0000000000 --- a/cpukit/rtems/include/rtems/rtems/messageimpl.h +++ /dev/null @@ -1,120 +0,0 @@ -/** - * @file rtems/rtems/message.inl - * - * This include file contains the static inline implementation of all - * inlined routines in the Message Manager. - */ - -/* COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_MESSAGEIMPL_H -#define _RTEMS_RTEMS_MESSAGEIMPL_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicMessageQueueImpl Classic Message Queue Implementation - * - * @ingroup ClassicMessageQueue - * - * @{ - */ - -/** - * The following enumerated type details the modes in which a message - * may be submitted to a message queue. The message may be posted - * in a send or urgent fashion. - */ -typedef enum { - /** - * This value indicates the user wants to send the message using the - * normal message insertion protocol (FIFO or priority). - */ - MESSAGE_QUEUE_SEND_REQUEST = 0, - /** - * This value indicates the user considers the message to be urgent - * and wants it inserted at the head of the pending message queue. - */ - MESSAGE_QUEUE_URGENT_REQUEST = 1 -} Message_queue_Submit_types; - -/** - * The following defines the information control block used to - * manage this class of objects. - */ -extern Objects_Information _Message_queue_Information; - -/** - * @brief Message_queue_Submit - * - * This routine implements the directives rtems_message_queue_send - * and rtems_message_queue_urgent. It processes a message that is - * to be submitted to the designated message queue. The message will - * either be processed as a send send message which it will be inserted - * at the rear of the queue or it will be processed as an urgent message - * which will be inserted at the front of the queue. - */ -rtems_status_code _Message_queue_Submit( - rtems_id id, - const void *buffer, - size_t size, - Message_queue_Submit_types submit_type -); - -/** - * @brief Deallocates a message queue control block into - * the inactive chain of free message queue control blocks. - * - * This routine deallocates a message queue control block into - * the inactive chain of free message queue control blocks. - */ -RTEMS_INLINE_ROUTINE void _Message_queue_Free ( - Message_queue_Control *the_message_queue -) -{ - _Objects_Free( &_Message_queue_Information, &the_message_queue->Object ); -} - -RTEMS_INLINE_ROUTINE Message_queue_Control *_Message_queue_Get( - Objects_Id id, - Thread_queue_Context *queue_context -) -{ - _Thread_queue_Context_initialize( queue_context ); - return (Message_queue_Control *) _Objects_Get( - id, - &queue_context->Lock_context.Lock_context, - &_Message_queue_Information - ); -} - -RTEMS_INLINE_ROUTINE Message_queue_Control *_Message_queue_Allocate( void ) -{ - return (Message_queue_Control *) - _Objects_Allocate( &_Message_queue_Information ); -} - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#if defined(RTEMS_MULTIPROCESSING) -#include -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/modes.h b/cpukit/rtems/include/rtems/rtems/modes.h deleted file mode 100644 index 547ae13e05..0000000000 --- a/cpukit/rtems/include/rtems/rtems/modes.h +++ /dev/null @@ -1,132 +0,0 @@ -/** - * @file rtems/rtems/modes.h - * - * @defgroup ClassicModes Modes - * - * @ingroup ClassicRTEMS - * @brief RTEMS thread and RTEMS_ASR modes - * - * This include file contains all constants and structures associated - * with the RTEMS thread and RTEMS_ASR modes. - */ - -/* COPYRIGHT (c) 1989-2013. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_MODES_H -#define _RTEMS_RTEMS_MODES_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicModes Modes - * - * @ingroup ClassicRTEMS - * - * This encapsulates functionality related to the task modes supported - * by the Classic API Task Manager. - */ -/**@{*/ - -/** - * The following type defines the control block used to manage - * each a mode set. - */ -typedef uint32_t Modes_Control; - -/** - * The following constants define the individual modes and masks - * which may be used to compose a mode set and to alter modes. - */ -#define RTEMS_ALL_MODE_MASKS 0x0000ffff - -/** - * This mode constant is the default mode set. - */ -#define RTEMS_DEFAULT_MODES 0x00000000 - -/** - * This mode constant is used when the user wishes to obtain their - * current execution mode. - */ -#define RTEMS_CURRENT_MODE 0 - -/** This mode constant corresponds to the timeslice enable/disable bit. */ -#define RTEMS_TIMESLICE_MASK 0x00000200 - -/** This mode constant corresponds to the preemption enable/disable bit. */ -#define RTEMS_PREEMPT_MASK 0x00000100 - -/** This mode constant corresponds to the signal enable/disable bit. */ -#define RTEMS_ASR_MASK 0x00000400 - -/** This mode constant corresponds to the interrupt enable/disable bits. */ -#define RTEMS_INTERRUPT_MASK CPU_MODES_INTERRUPT_MASK - -/** This mode constant is used to indicate preemption is enabled. */ -#define RTEMS_PREEMPT 0x00000000 -/** This mode constant is used to indicate preemption is disabled. */ -#define RTEMS_NO_PREEMPT 0x00000100 - -/** This mode constant is used to indicate timeslicing is disabled. */ -#define RTEMS_NO_TIMESLICE 0x00000000 -/** This mode constant is used to indicate timeslicing is enabled. */ -#define RTEMS_TIMESLICE 0x00000200 - -/** This mode constant is used to indicate signal processing is enabled. */ -#define RTEMS_ASR 0x00000000 -/** This mode constant is used to indicate signal processing is disabled. */ -#define RTEMS_NO_ASR 0x00000400 - -/** - * @brief RTEMS_INTERRUPT_LEVEL - * - * This function returns the processor dependent interrupt - * level which corresponds to the requested interrupt level. - * - * @note RTEMS supports 256 interrupt levels using the least - * significant eight bits of MODES.CONTROL. On any - * particular CPU, fewer than 256 levels may be supported. - */ -#define RTEMS_INTERRUPT_LEVEL( _mode_set ) \ - ( (_mode_set) & RTEMS_INTERRUPT_MASK ) - -/** - * @brief Interrupt Mask Variable - * - * This variable is used by bindings from languages other than C and C++. - */ -extern const uint32_t rtems_interrupt_mask; - -/** - * @brief Body for RTEMS_INTERRUPT_LEVEL Macro - * - * @param[in] level is the desired interrupt level - * - * @retval This methods returns a mode with the desired interrupt - * @a level in the proper bitfield location. - * - * @note This variable is used by bindings from languages other than - * C and C++. - */ -Modes_Control rtems_interrupt_level_body( - uint32_t level -); - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/modesimpl.h b/cpukit/rtems/include/rtems/rtems/modesimpl.h deleted file mode 100644 index 8c1acc7cb9..0000000000 --- a/cpukit/rtems/include/rtems/rtems/modesimpl.h +++ /dev/null @@ -1,146 +0,0 @@ -/** - * @file - * - * @ingroup ClassicModesImpl - * - * @brief Classic Modes Implementation - */ - -/* COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_MODESIMPL_H -#define _RTEMS_RTEMS_MODESIMPL_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicModesImpl Classic Modes Implementation - * - * @ingroup ClassicModes - * - * @{ - */ - -/** - * @brief Checks if any of the mode flags in mask are set in mode_set. - * - * This function returns TRUE if any of the mode flags in mask - * are set in mode_set, and FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Modes_Mask_changed ( - Modes_Control mode_set, - Modes_Control masks -) -{ - return ( mode_set & masks ) ? true : false; -} - -/** - * @brief Checks if mode_set says that Asynchronous Signal Processing is disabled. - * - * This function returns TRUE if mode_set indicates that Asynchronous - * Signal Processing is disabled, and FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Modes_Is_asr_disabled ( - Modes_Control mode_set -) -{ - return (mode_set & RTEMS_ASR_MASK) == RTEMS_NO_ASR; -} - -/** - * @brief Checks if mode_set indicates that preemption is enabled. - * - * This function returns TRUE if mode_set indicates that preemption - * is enabled, and FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Modes_Is_preempt ( - Modes_Control mode_set -) -{ - return (mode_set & RTEMS_PREEMPT_MASK) == RTEMS_PREEMPT; -} - -/** - * @brief Checks if mode_set indicates that timeslicing is enabled. - * - * This function returns TRUE if mode_set indicates that timeslicing - * is enabled, and FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Modes_Is_timeslice ( - Modes_Control mode_set -) -{ - return (mode_set & RTEMS_TIMESLICE_MASK) == RTEMS_TIMESLICE; -} - -/** - * @brief Gets the interrupt level portion of the mode_set. - * - * This function returns the interrupt level portion of the mode_set. - */ -RTEMS_INLINE_ROUTINE ISR_Level _Modes_Get_interrupt_level ( - Modes_Control mode_set -) -{ - return ( mode_set & RTEMS_INTERRUPT_MASK ); -} - -/** - * @brief Sets the current interrupt level to that specified in the mode_set. - * - * This routine sets the current interrupt level to that specified - * in the mode_set. - */ -RTEMS_INLINE_ROUTINE void _Modes_Set_interrupt_level ( - Modes_Control mode_set -) -{ - _ISR_Set_level( _Modes_Get_interrupt_level( mode_set ) ); -} - -/** - * @brief Changes the modes in old_mode_set indicated by - * mask to the requested values in new_mode_set. - * - * This routine changes the modes in old_mode_set indicated by - * mask to the requested values in new_mode_set. The resulting - * mode set is returned in out_mode_set and the modes that changed - * is returned in changed. - */ -RTEMS_INLINE_ROUTINE void _Modes_Change ( - Modes_Control old_mode_set, - Modes_Control new_mode_set, - Modes_Control mask, - Modes_Control *out_mode_set, - Modes_Control *changed -) -{ - Modes_Control _out_mode; - - _out_mode = old_mode_set; - _out_mode &= ~mask; - _out_mode |= new_mode_set & mask; - *changed = _out_mode ^ old_mode_set; - *out_mode_set = _out_mode; -} - -#ifdef __cplusplus -} -#endif - -/**@}*/ - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/mp.h b/cpukit/rtems/include/rtems/rtems/mp.h deleted file mode 100644 index f1b93b6751..0000000000 --- a/cpukit/rtems/include/rtems/rtems/mp.h +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @file rtems/rtems/mp.h - * - * @defgroup ClassicMP Multiprocessing - * - * @ingroup ClassicRTEMS - * @brief Multiprocessing Manager - * - * This include file contains all the constants and structures associated - * with the Multiprocessing Manager. - */ - -/* COPYRIGHT (c) 1989-2013. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_MP_H -#define _RTEMS_RTEMS_MP_H - -/** - * @defgroup ClassicMP Multiprocessing - * - * @ingroup ClassicRTEMS - * - * This encapsulates functionality related to the distributed - * Multiprocessing support in the Classic API. - */ -/**@{*/ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief RTEMS Multiprocessing Announce - * - * This routine implements the MULTIPROCESSING_ANNOUNCE directive. - * It is invoked by the MPCI layer to indicate that an MPCI packet - * has been received. - */ -void rtems_multiprocessing_announce ( void ); - -#ifdef __cplusplus -} -#endif - -/**@}*/ - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/msgmp.h b/cpukit/rtems/include/rtems/rtems/msgmp.h deleted file mode 100644 index 3dabd8d46b..0000000000 --- a/cpukit/rtems/include/rtems/rtems/msgmp.h +++ /dev/null @@ -1,211 +0,0 @@ -/** - * @file rtems/rtems/msgmp.h - * - * @brief Message Manager MP Support - * - * This include file contains all the constants and structures associated - * with the Multiprocessing Support in the Message Manager. - */ - -/* COPYRIGHT (c) 1989-2013. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_MSGMP_H -#define _RTEMS_RTEMS_MSGMP_H - -#ifndef _RTEMS_RTEMS_MESSAGEIMPL_H -# error "Never use directly; include instead." -#endif - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicMsgMP Message Queue MP Support - * - * @ingroup ClassicMP - * - * This encapsulates functionality related to the transparent multiprocessing - * support within the Classic API Message Queue Manager. - */ -/*{*/ - -/** - * The following enumerated type defines the list of - * remote message queue operations. - */ -typedef enum { - MESSAGE_QUEUE_MP_ANNOUNCE_CREATE = 0, - MESSAGE_QUEUE_MP_ANNOUNCE_DELETE = 1, - MESSAGE_QUEUE_MP_EXTRACT_PROXY = 2, - MESSAGE_QUEUE_MP_RECEIVE_REQUEST = 3, - MESSAGE_QUEUE_MP_RECEIVE_RESPONSE = 4, - MESSAGE_QUEUE_MP_SEND_REQUEST = 5, - MESSAGE_QUEUE_MP_SEND_RESPONSE = 6, - MESSAGE_QUEUE_MP_URGENT_REQUEST = 7, - MESSAGE_QUEUE_MP_URGENT_RESPONSE = 8, - MESSAGE_QUEUE_MP_BROADCAST_REQUEST = 9, - MESSAGE_QUEUE_MP_BROADCAST_RESPONSE = 10, - MESSAGE_QUEUE_MP_FLUSH_REQUEST = 11, - MESSAGE_QUEUE_MP_FLUSH_RESPONSE = 12, - MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_REQUEST = 13, - MESSAGE_QUEUE_MP_GET_NUMBER_PENDING_RESPONSE = 14 -} Message_queue_MP_Remote_operations; - -/** - * The following data structure defines the packet used to perform - * remote message queue operations. - */ -typedef struct { - rtems_packet_prefix Prefix; - Message_queue_MP_Remote_operations operation; - rtems_name name; - rtems_option option_set; - Objects_Id proxy_id; - uint32_t count; - size_t size; - uint32_t pad0; - CORE_message_queue_Buffer Buffer; -} Message_queue_MP_Packet; - -#define MESSAGE_QUEUE_MP_PACKET_SIZE \ - offsetof(Message_queue_MP_Packet, Buffer.buffer) - -RTEMS_INLINE_ROUTINE bool _Message_queue_MP_Is_remote( Objects_Id id ) -{ - return _Objects_MP_Is_remote( id, &_Message_queue_Information ); -} - -/** - * @brief Message_queue_Core_message_queue_mp_support - * - * Input parameters: - * the_thread - the remote thread the message was submitted to - * id - id of the message queue - * - * Output parameters: NONE - */ -void _Message_queue_Core_message_queue_mp_support ( - Thread_Control *the_thread, - rtems_id id -); - -/** - * @brief _Message_queue_MP_Send_process_packet - * - * This routine performs a remote procedure call so that a - * process operation can be performed on another node. - */ -void _Message_queue_MP_Send_process_packet ( - Message_queue_MP_Remote_operations operation, - Objects_Id message_queue_id, - rtems_name name, - Objects_Id proxy_id -); - -/** - * @brief Issues a remote rtems_message_queue_broadcast() request. - */ -rtems_status_code _Message_queue_MP_Broadcast( - rtems_id id, - const void *buffer, - size_t size, - uint32_t *count -); - -/** - * @brief Issues a remote rtems_message_queue_flush() request. - */ -rtems_status_code _Message_queue_MP_Flush( - rtems_id id, - uint32_t *count -); - -/** - * @brief Issues a remote rtems_message_queue_get_number_pending() request. - */ -rtems_status_code _Message_queue_MP_Get_number_pending( - rtems_id id, - uint32_t *count -); - -/** - * @brief Issues a remote rtems_message_queue_receive() request. - */ -rtems_status_code _Message_queue_MP_Receive( - rtems_id id, - void *buffer, - size_t *size, - rtems_option option_set, - rtems_interval timeout -); - -/** - * @brief Issues a remote rtems_message_queue_send() request. - */ -rtems_status_code _Message_queue_MP_Send( - rtems_id id, - const void *buffer, - size_t size -); - -/** - * @brief Issues a remote rtems_message_queue_urgent() request. - */ -rtems_status_code _Message_queue_MP_Urgent( - rtems_id id, - const void *buffer, - size_t size -); - -/** - * - * @brief _Message_queue_MP_Process_packet - * - * This routine performs the actions specific to this package for - * the request from another node. - */ -void _Message_queue_MP_Process_packet ( - rtems_packet_prefix *the_packet_prefix -); - -/** - * @brief _Message_queue_MP_Send_object_was_deleted - * - * This routine is invoked indirectly by the thread queue - * when a proxy has been removed from the thread queue and - * the remote node must be informed of this. - */ -void _Message_queue_MP_Send_object_was_deleted ( - Thread_Control *the_proxy, - Objects_Id mp_id -); - -/** - * @brief _Message_queue_MP_Send_extract_proxy - * - * This routine is invoked when a task is deleted and it - * has a proxy which must be removed from a thread queue and - * the remote node must be informed of this. - */ -void _Message_queue_MP_Send_extract_proxy ( - Thread_Control *the_thread, - Objects_Id id -); - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of file */ diff --git a/cpukit/rtems/include/rtems/rtems/object.h b/cpukit/rtems/include/rtems/rtems/object.h deleted file mode 100644 index 2652915462..0000000000 --- a/cpukit/rtems/include/rtems/rtems/object.h +++ /dev/null @@ -1,370 +0,0 @@ -/** - * @file rtems/rtems/object.h - * - * @defgroup ClassicClassInfo Object Class Information - * - * @ingroup ClassicRTEMS - * @brief Classic API interfaces to Object Services - * - * This include file defines Classic API interfaces to Object Services. - */ - -/* COPYRIGHT (c) 1989-2013. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_OBJECT_H -#define _RTEMS_RTEMS_OBJECT_H - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicClassInfo Object Class Information - * - * @ingroup ClassicRTEMS - * - * This encapsulates functionality related to the Classic API Object - * Class Services. - */ -/**@{*/ - -/** - * This structure is used to return information to the application - * about the objects configured for a specific API/Class combination. - */ -typedef struct { - /** This field is the minimum valid object Id for this class. */ - rtems_id minimum_id; - /** This field is the maximum valid object Id for this class. */ - rtems_id maximum_id; - /** This field is the number of object instances configured for this class. */ - uint32_t maximum; - /** This field indicates if the class is configured for auto-extend. */ - bool auto_extend; - /** This field is the number of currently unallocated objects. */ - uint32_t unallocated; -} rtems_object_api_class_information; - -/** - * @brief Build Object Id - * - * This function returns an object id composed of the - * specified @a api, @a class, @a node, - * and @a index. - * - * @param[in] _api indicates the api to use for the Id - * @param[in] _class indicates the class to use for the Id - * @param[in] _node indicates the node to use for the Id - * @param[in] _index indicates the index to use for the Id - * - * @retval This method returns an object Id built from the - * specified values. - * - * @note A body is also provided. - */ -#define rtems_build_id( _api, _class, _node, _index ) \ - _Objects_Build_id( _api, _class, _node, _index ) - -/** - * @brief Build Thirty-Two Bit Object Name - * - * RTEMS Object Helper -- Build an Object Id - * - * This function returns an object name composed of the four characters - * C1, C2, C3, and C4. - * - * @param[in] _C1 is the first character of the name - * @param[in] _C2 is the second character of the name - * @param[in] _C3 is the third character of the name - * @param[in] _C4 is the fourth character of the name - * - * @note This must be implemented as a macro for use in - * Configuration Tables. A body is also provided. - * - */ -#define rtems_build_name( _C1, _C2, _C3, _C4 ) \ - _Objects_Build_name( _C1, _C2, _C3, _C4 ) - -/** - * @brief Obtain Name of Object - * - * This directive returns the name associated with the specified - * object ID. - * - * @param[in] id is the Id of the object to obtain the name of. - * @param[out] name will be set to the name of the object - * - * @note The object must be have a name of the 32-bit form. - * - * @retval @a *name will contain user defined object name - * @retval @a RTEMS_SUCCESSFUL - if successful - * @retval error code - if unsuccessful - */ -rtems_status_code rtems_object_get_classic_name( - rtems_id id, - rtems_name *name -); - -/** - * @brief Obtain Object Name as String - * - * This directive returns the name associated with the specified - * object ID. - * - * @param[in] id is the Id of the object to obtain the name of - * @param[in] length is the length of the output name buffer - * @param[out] name will be set to the name of the object - * - * @retval @a *name will contain user defined object name - * @retval @a name - if successful - * @retval @a NULL - if unsuccessful - */ -char *rtems_object_get_name( - rtems_id id, - size_t length, - char *name -); - -/** - * @brief Set Name of Object - * - * This method allows the caller to set the name of an - * object. This can be used to set the name of objects - * which do not have a naming scheme per their API. - * - * RTEMS Object Helper -- Set Name of Object as String - * - * @param[in] id is the Id of the object to obtain the name of - * @param[out] name will be set to the name of the object - * - * @retval @a *name will contain user defined object name - * @retval @a RTEMS_SUCCESSFUL - if successful - * @retval error code - if unsuccessful - */ -rtems_status_code rtems_object_set_name( - rtems_id id, - const char *name -); - -/** - * @brief Get API Portion of Object Id - * - * RTEMS Object Helper -- Extract API From Id - * - * This function returns the API portion of the Id. - * - * @param[in] _id is the Id of the object to obtain the API from - * - * @retval This method returns the API portion of the provided - * @a _id. - * - * @note This method does NOT validate the @a _id provided. - * - * @note A body is also provided. - */ -#define rtems_object_id_get_api( _id ) \ - _Objects_Get_API( _id ) - -/** - * @brief Get Class Portion of Object Id - * - * This function returns the class portion of the @a _id ID. - * - * @param[in] _id is the Id of the object to obtain the class from - * - * @retval This method returns the class portion of the provided - * @a _id. - * - * @note This method does NOT validate the @a _id provided. - * - * @note A body is also provided. - */ -#define rtems_object_id_get_class( _id ) \ - _Objects_Get_class( _id ) - -/** - * @brief Get Node Portion of Object Id - * - * This function returns the node portion of the ID. - * - * @param[in] _id is the Id of the object to obtain the node from - * - * @retval This method returns the node portion of the provided - * @a _id. - * - * @note This method does NOT validate the @a _id provided. - * - * @note A body is also provided. - */ -#define rtems_object_id_get_node( _id ) \ - _Objects_Get_node( _id ) - -/** - * @brief Get Index Portion of Object Id - * - * This function returns the index portion of the ID. - * - * @param[in] _id is the Id of the object to obtain the index from - * - * @retval This method returns the index portion of the provided - * @a _id. - * - * @note This method does NOT validate the @a _id provided. - * - * @note A body is also provided. - */ -#define rtems_object_id_get_index( _id ) \ - _Objects_Get_index( _id ) - -/** - * @brief Get Lowest Valid API Index - * - * This method returns the lowest valid value for the API - * portion of an RTEMS object Id. - * - * @retval This method returns the least valid value for - * the API portion of an RTEMS object Id. - * - * @note A body is also provided. - */ -#define rtems_object_id_api_minimum() \ - OBJECTS_INTERNAL_API - -/** - * @brief Get Highest Valid API Index - * - * This method returns the highest valid value for the API - * portion of an RTEMS object Id. - * - * @retval This method returns the greatest valid value for - * the API portion of an RTEMS object Id. - * - * @note A body is also provided. - */ -#define rtems_object_id_api_maximum() \ - OBJECTS_APIS_LAST - -/** - * @brief Get Lowest Valid Class Value - * - * This method returns the lowest valid value Class for the - * specified @a api. Each API supports a different number - * of object classes. - * - * @param[in] api is the API to obtain the minimum class of - * - * @retval This method returns the least valid value for - * class number for the specified @a api. - * RTEMS Object Helper -- Get Least Valid Class for an API - */ -int rtems_object_api_minimum_class( - int api -); - -/** - * @brief Get Highest Valid Class Value - * - * This method returns the highest valid value Class for the - * specified @a api. Each API supports a different number - * of object classes. - * - * @param[in] api is the API to obtain the maximum class of - * - * @retval This method returns the greatet valid value for - * class number for the specified @a api. - */ -int rtems_object_api_maximum_class( - int api -); - - -/** - * @brief Get Highest Valid Class Value - * - * This method returns the lowest valid value Class for the - * specified @a api. Each API supports a different number - * of object classes. - * - * @param[in] api is the API to obtain the maximum class of - * - * @retval This method returns the least valid value for - * class number for the specified @a api. - */ -int rtems_object_id_api_maximum_class( - int api -); - -/** - * @brief Get API Name - * - * This method returns a string containing the name of the - * specified @a api. - * - * @param[in] api is the API to obtain the name of - * - * @retval If successful, this method returns the name of - * the specified @a api. Otherwise, it returns - * the string "BAD API" - */ -const char *rtems_object_get_api_name( - int api -); - -/** - * @brief Get Class Name - * - * This method returns a string containing the name of the - * @a class from the specified @a api. - * - * @param[in] the_api is the API for the class - * @param[in] the_class is the class to obtain the name of - * - * @retval If successful, this method returns the name of - * the specified @a class. Otherwise, it returns - * the string "BAD CLASS" - */ -const char *rtems_object_get_api_class_name( - int the_api, - int the_class -); - -/** - * @brief Get Class Information - * - * This method returns a string containing the name of the - * @a the_class from the specified @a api. - * - * @param[in] the_api is the API for the class - * @param[in] the_class is the class to obtain information about - * @param[in] info points to the information structure to fill in - * - * @retval If successful, this method returns the name of - * RTEMS_SUCCESSFUL with @a *info filled in. Otherwise, - * a status is returned to indicate the error. - * - */ -rtems_status_code rtems_object_get_class_information( - int the_api, - int the_class, - rtems_object_api_class_information *info -); - -#ifdef __cplusplus -} -#endif - -/**@}*/ - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/options.h b/cpukit/rtems/include/rtems/rtems/options.h deleted file mode 100644 index 752aefda2e..0000000000 --- a/cpukit/rtems/include/rtems/rtems/options.h +++ /dev/null @@ -1,83 +0,0 @@ -/** - * @file rtems/rtems/options.h - * - * @defgroup ClassicOptions Classic API Options - * - * @ingroup ClassicRTEMS - * @brief Options Available on Many Directives - * - * This include file contains information which defines the - * options available on many directives. - */ - -/* COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_OPTIONS_H -#define _RTEMS_RTEMS_OPTIONS_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicOptions Classic API Options - * - * @ingroup ClassicRTEMS - * - * This encapsulates functionality related to the options argument - * to Classic API blocking operations. The primary option is whether - * or not a task is willing to wait for the operation to complete. - */ -/**@{*/ - -/** - * The following type defines the control block used to manage - * option sets. - */ -typedef uint32_t rtems_option; - -/** - * The following constants define the individual options which may - * be used to compose an option set. - */ -#define RTEMS_DEFAULT_OPTIONS 0x00000000 - -/** - * This option constants indicates that the task is to wait on resource. - */ -#define RTEMS_WAIT 0x00000000 -/** - * This option constants indicates that the task is to not wait on - * the resource. If it is not available, return immediately with - * a status to indicate unsatisfied. - */ -#define RTEMS_NO_WAIT 0x00000001 - -/** - * This option constants indicates that the task wishes to wait until - * all events of interest are available. - */ -#define RTEMS_EVENT_ALL 0x00000000 - -/** - * This option constants indicates that the task wishes to wait until - * ANY events of interest are available. - */ -#define RTEMS_EVENT_ANY 0x00000002 - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/optionsimpl.h b/cpukit/rtems/include/rtems/rtems/optionsimpl.h deleted file mode 100644 index 0263fcf78d..0000000000 --- a/cpukit/rtems/include/rtems/rtems/optionsimpl.h +++ /dev/null @@ -1,67 +0,0 @@ -/** - * @file - * - * @ingroup ClassicOptionsImpl - * - * @brief Classic Options Implementation - */ - -/* COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_OPTIONSIMPL_H -#define _RTEMS_RTEMS_OPTIONSIMPL_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicOptionsImpl Classic Options Implementation - * - * @ingroup ClassicOptions - * - * @{ - */ - -/** - * @brief Checks if the RTEMS_NO_WAIT option is enabled in option_set. - * - * This function returns TRUE if the RTEMS_NO_WAIT option is enabled in - * option_set, and FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Options_Is_no_wait ( - rtems_option option_set -) -{ - return (option_set & RTEMS_NO_WAIT) ? true : false; -} - -/** - * @brief Checks if the RTEMS_EVENT_ANY option is enabled in OPTION_SET. - * - * This function returns TRUE if the RTEMS_EVENT_ANY option is enabled in - * OPTION_SET, and FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Options_Is_any ( - rtems_option option_set -) -{ - return (option_set & RTEMS_EVENT_ANY) ? true : false; -} - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/part.h b/cpukit/rtems/include/rtems/rtems/part.h deleted file mode 100644 index 5b840cc96c..0000000000 --- a/cpukit/rtems/include/rtems/rtems/part.h +++ /dev/null @@ -1,174 +0,0 @@ -/** - * @file rtems/rtems/part.h - * - * @defgroup ClassicPart Partitions - * - * @ingroup ClassicRTEMS - * @brief Partition Manager - * - * This include file contains all the constants and structures associated - * with the Partition Manager. This manager provides facilities to - * dynamically allocate memory in fixed-sized units which are returned - * as buffers. - * - * Directives provided are: - * - * - create a partition - * - get an ID of a partition - * - delete a partition - * - get a buffer from a partition - * - return a buffer to a partition - */ - -/* COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_PART_H -#define _RTEMS_RTEMS_PART_H - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicPart Partitions - * - * @ingroup ClassicRTEMS - * - * This encapsulates functionality related to the - * Classic API Partition Manager. - */ -/**@{*/ - -/** - * The following defines the control block used to manage each partition. - */ -typedef struct { - /** This field is the object management portion of a Partition instance. */ - Objects_Control Object; - /** This field is the lock of the Partition. */ - ISR_LOCK_MEMBER( Lock ) - /** This field is the physical starting address of the Partition. */ - void *starting_address; - /** This field is the size of the Partition in bytes. */ - intptr_t length; - /** This field is the size of each buffer in bytes */ - uint32_t buffer_size; - /** This field is the attribute set provided at create time. */ - rtems_attribute attribute_set; - /** This field is the of allocated buffers. */ - uint32_t number_of_used_blocks; - /** This field is the chain used to manage unallocated buffers. */ - Chain_Control Memory; -} Partition_Control; - -/** - * @brief RTEMS Partition Create - * - * Partition Manager - * - * This routine implements the rtems_partition_create directive. The - * partition will have the name name. The memory area managed by - * the partition is of length bytes and starts at starting_address. - * The memory area will be divided into as many buffers of - * buffer_size bytes as possible. The attribute_set determines if - * the partition is global or local. It returns the id of the - * created partition in ID. - */ -rtems_status_code rtems_partition_create( - rtems_name name, - void *starting_address, - uint32_t length, - uint32_t buffer_size, - rtems_attribute attribute_set, - rtems_id *id -); - -/** - * @brief RTEMS Partition Ident - * - * This routine implements the rtems_partition_ident directive. - * This directive returns the partition ID associated with name. - * If more than one partition is named name, then the partition - * to which the ID belongs is arbitrary. node indicates the - * extent of the search for the ID of the partition named name. - * The search can be limited to a particular node or allowed to - * encompass all nodes. - * - * @param[in] name is the user defined partition name - * @param[in] node is(are) the node(s) to be searched - * @param[in] id is the pointer to partition id - * - * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful and - * *id filled in with the partition id - */ -rtems_status_code rtems_partition_ident( - rtems_name name, - uint32_t node, - rtems_id *id -); - -/** - * @brief RTEMS Delete Partition - * - * This routine implements the rtems_partition_delete directive. The - * partition indicated by ID is deleted, provided that none of its buffers - * are still allocated. - * - * @param[in] id is the partition id - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - */ -rtems_status_code rtems_partition_delete( - rtems_id id -); - -/** - * @brief RTEMS Get Partition Buffer - * - * This routine implements the rtems_partition_get_buffer directive. It - * attempts to allocate a buffer from the partition associated with ID. - * If a buffer is allocated, its address is returned in buffer. - * - * @param[in] id is the partition id - * @param[out] buffer is the pointer to buffer address - * - * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful - */ -rtems_status_code rtems_partition_get_buffer( - rtems_id id, - void **buffer -); - -/** - * @brief rtems_partition_return_buffer - * - * This routine implements the rtems_partition_return_buffer directive. It - * frees the buffer to the partition associated with ID. The buffer must - * have been previously allocated from the same partition. - */ -rtems_status_code rtems_partition_return_buffer( - rtems_id id, - void *buffer -); - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/partimpl.h b/cpukit/rtems/include/rtems/rtems/partimpl.h deleted file mode 100644 index 13ee86b4c2..0000000000 --- a/cpukit/rtems/include/rtems/rtems/partimpl.h +++ /dev/null @@ -1,223 +0,0 @@ -/** - * @file - * - * @ingroup ClassicPartImpl - * - * @brief Classic Partition Manager Implementation - */ - -/* COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_PARTIMPL_H -#define _RTEMS_RTEMS_PARTIMPL_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicPartImpl Classic Partition Manager Implementation - * - * @ingroup ClassicPart - * - * @{ - */ - -/** - * The following defines the information control block used to - * manage this class of objects. - */ -extern Objects_Information _Partition_Information; - -/** - * @brief Allocate a buffer from the_partition. - * - * This function attempts to allocate a buffer from the_partition. - * If successful, it returns the address of the allocated buffer. - * Otherwise, it returns NULL. - */ -RTEMS_INLINE_ROUTINE void *_Partition_Allocate_buffer ( - Partition_Control *the_partition -) -{ - return _Chain_Get_unprotected( &the_partition->Memory ); -} - -/** - * @brief Frees the_buffer to the_partition. - * - * This routine frees the_buffer to the_partition. - */ -RTEMS_INLINE_ROUTINE void _Partition_Free_buffer ( - Partition_Control *the_partition, - Chain_Node *the_buffer -) -{ - _Chain_Append_unprotected( &the_partition->Memory, the_buffer ); -} - -/** - * @brief Checks whether is on a valid buffer boundary for the_partition. - * - * This function returns TRUE if the_buffer is on a valid buffer - * boundary for the_partition, and FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Partition_Is_buffer_on_boundary ( - void *the_buffer, - Partition_Control *the_partition -) -{ - uint32_t offset; - - offset = (uint32_t) _Addresses_Subtract( - the_buffer, - the_partition->starting_address - ); - - return ((offset % the_partition->buffer_size) == 0); -} - -/** - * @brief Checks whether the_buffer is a valid buffer from the_partition. - * - * This function returns TRUE if the_buffer is a valid buffer from - * the_partition, otherwise FALSE is returned. - */ -RTEMS_INLINE_ROUTINE bool _Partition_Is_buffer_valid ( - Chain_Node *the_buffer, - Partition_Control *the_partition -) -{ - void *starting; - void *ending; - - starting = the_partition->starting_address; - ending = _Addresses_Add_offset( starting, the_partition->length ); - - return ( - _Addresses_Is_in_range( the_buffer, starting, ending ) && - _Partition_Is_buffer_on_boundary( the_buffer, the_partition ) - ); -} - -/** - * @brief Checks if partition is buffer size aligned. - * - * This function returns TRUE if the use of the specified buffer_size - * will result in the allocation of buffers whose first byte is - * properly aligned, and FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Partition_Is_buffer_size_aligned ( - uint32_t buffer_size -) -{ - return ((buffer_size % CPU_PARTITION_ALIGNMENT) == 0); -} - -/** - * @brief Allocates a partition control block from the - * inactive chain of free partition control blocks. - * - * This function allocates a partition control block from - * the inactive chain of free partition control blocks. - */ -RTEMS_INLINE_ROUTINE Partition_Control *_Partition_Allocate ( void ) -{ - return (Partition_Control *) _Objects_Allocate( &_Partition_Information ); -} - -RTEMS_INLINE_ROUTINE void _Partition_Initialize( - Partition_Control *the_partition, - void *starting_address, - uint32_t length, - uint32_t buffer_size, - rtems_attribute attribute_set -) -{ - the_partition->starting_address = starting_address; - the_partition->length = length; - the_partition->buffer_size = buffer_size; - the_partition->attribute_set = attribute_set; - the_partition->number_of_used_blocks = 0; - - _Chain_Initialize( - &the_partition->Memory, - starting_address, - length / buffer_size, - buffer_size - ); - - _ISR_lock_Initialize( &the_partition->Lock, "Partition" ); -} - -RTEMS_INLINE_ROUTINE void _Partition_Destroy( - Partition_Control *the_partition -) -{ - _ISR_lock_Destroy( &the_partition->Lock ); -} - -/** - * @brief Frees a partition control block to the - * inactive chain of free partition control blocks. - * - * This routine frees a partition control block to the - * inactive chain of free partition control blocks. - */ -RTEMS_INLINE_ROUTINE void _Partition_Free ( - Partition_Control *the_partition -) -{ - _Objects_Free( &_Partition_Information, &the_partition->Object ); -} - -RTEMS_INLINE_ROUTINE Partition_Control *_Partition_Get( - Objects_Id id, - ISR_lock_Context *lock_context -) -{ - return (Partition_Control *) _Objects_Get( - id, - lock_context, - &_Partition_Information - ); -} - -RTEMS_INLINE_ROUTINE void _Partition_Acquire_critical( - Partition_Control *the_partition, - ISR_lock_Context *lock_context -) -{ - _ISR_lock_Acquire( &the_partition->Lock, lock_context ); -} - -RTEMS_INLINE_ROUTINE void _Partition_Release( - Partition_Control *the_partition, - ISR_lock_Context *lock_context -) -{ - _ISR_lock_Release_and_ISR_enable( &the_partition->Lock, lock_context ); -} - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#if defined(RTEMS_MULTIPROCESSING) -#include -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/partmp.h b/cpukit/rtems/include/rtems/rtems/partmp.h deleted file mode 100644 index b9eaa08b8c..0000000000 --- a/cpukit/rtems/include/rtems/rtems/partmp.h +++ /dev/null @@ -1,144 +0,0 @@ -/** - * @file rtems/rtems/partmp.h - * - * @brief MP Support in Partition Manager - * - * This include file contains all the constants and structures associated - * with the Multiprocessing Support in the Partition Manager. - */ - -/* COPYRIGHT (c) 1989-2013. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_PARTMP_H -#define _RTEMS_RTEMS_PARTMP_H - -#ifndef _RTEMS_RTEMS_PARTIMPL_H -# error "Never use directly; include instead." -#endif - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicPartMP Partition MP Support - * - * @ingroup ClassicMP - * - * This encapsulates functionality related to the transparent multiprocessing - * support within the Classic API Partition Manager. - */ -/*{*/ - -/** - * The following enumerated type defines the list of - * remote partition operations. - */ -typedef enum { - PARTITION_MP_ANNOUNCE_CREATE = 0, - PARTITION_MP_ANNOUNCE_DELETE = 1, - PARTITION_MP_EXTRACT_PROXY = 2, - PARTITION_MP_GET_BUFFER_REQUEST = 3, - PARTITION_MP_GET_BUFFER_RESPONSE = 4, - PARTITION_MP_RETURN_BUFFER_REQUEST = 5, - PARTITION_MP_RETURN_BUFFER_RESPONSE = 6 -} Partition_MP_Remote_operations; - -/** - * The following data structure defines the packet used to perform - * remote partition operations. - */ -typedef struct { - rtems_packet_prefix Prefix; - Partition_MP_Remote_operations operation; - rtems_name name; - void *buffer; - Objects_Id proxy_id; -} Partition_MP_Packet; - -RTEMS_INLINE_ROUTINE bool _Partition_MP_Is_remote( Objects_Id id ) -{ - return _Objects_MP_Is_remote( id, &_Partition_Information ); -} - -/** - * @brief Partition_MP_Send_process_packet - * - * Multiprocessing Support for the Partition Manager - * - * This routine performs a remote procedure call so that a - * process operation can be performed on another node. - */ -void _Partition_MP_Send_process_packet ( - Partition_MP_Remote_operations operation, - Objects_Id partition_id, - rtems_name name, - Objects_Id proxy_id -); - -/** - * @brief Issues a remote rtems_partition_get_buffer() request. - */ -rtems_status_code _Partition_MP_Get_buffer( - rtems_id id, - void **buffer -); - -/** - * @brief Issues a remote rtems_partition_return_buffer() request. - */ -rtems_status_code _Partition_MP_Return_buffer( - rtems_id id, - void *buffer -); - -/** - * - * @brief Partition_MP_Process_packet - * - * This routine performs the actions specific to this package for - * the request from another node. - */ -void _Partition_MP_Process_packet ( - rtems_packet_prefix *the_packet_prefix -); - -/* - * @brief Partition_MP_Send_object_was_deleted - * - * This routine is invoked indirectly by the thread queue - * when a proxy has been removed from the thread queue and - * the remote node must be informed of this. - * - * This routine is not needed by the Partition since a partition - * cannot be deleted when buffers are in use. - */ - -/** - * @brief Partition_MP_Send_extract_proxy - * - * This routine is invoked when a task is deleted and it - * has a proxy which must be removed from a thread queue and - * the remote node must be informed of this. - */ -void _Partition_MP_Send_extract_proxy ( - Thread_Control *the_thread, - Objects_Id id -); - -#ifdef __cplusplus -} -#endif - -/**@}*/ - -#endif -/* end of file */ diff --git a/cpukit/rtems/include/rtems/rtems/ratemon.h b/cpukit/rtems/include/rtems/rtems/ratemon.h deleted file mode 100644 index ca48a92983..0000000000 --- a/cpukit/rtems/include/rtems/rtems/ratemon.h +++ /dev/null @@ -1,430 +0,0 @@ -/** - * @file rtems/rtems/ratemon.h - * - * @defgroup ClassicRateMon Rate Monotonic Scheduler - * - * @ingroup ClassicRTEMS - * @brief Classic API Rate Monotonic Manager. - * - * This include file contains all the constants, structures, and - * prototypes associated with the Rate Monotonic Manager. This manager - * provides facilities to implement threads which execute in a periodic - * fashion. - * - * Directives provided are: - * - * - create a rate monotonic timer - * - cancel a period - * - delete a rate monotonic timer - * - conclude current and start the next period - * - obtain status information on a period - * - obtain the number of postponed jobs - */ - -/* COPYRIGHT (c) 1989-2009, 2016. - * On-Line Applications Research Corporation (OAR). - * COPYRIGHT (c) 2016-2017 Kuan-Hsun Chen. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_RATEMON_H -#define _RTEMS_RTEMS_RATEMON_H - -#include -#include -#include -#include - -struct rtems_printer; - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicRateMon Rate Monotonic Scheduler - * - * @ingroup ClassicRTEMS - * - * This encapsulates functionality related to the Classic API Rate - * Monotonic Manager. - * - * Statistics are kept for each period and can be obtained or printed via - * API calls. The statistics kept include minimum, maximum and average times - * for both cpu usage and wall time. The statistics indicate the execution - * and wall time used by the owning thread between successive calls to - * rtems_rate_monotonic_period. - */ -/**@{*/ - -/** - * This is the public type used for the rate monotonic timing - * statistics. - */ -#include - -typedef struct timespec rtems_rate_monotonic_period_time_t; - -/** - * This is the internal type used for the rate monotonic timing - * statistics. - */ -#include - -/** - * The following enumerated type defines the states in which a - * period may be. - */ -typedef enum { - /** - * This value indicates the period is off the watchdog chain, - * and has never been initialized. - */ - RATE_MONOTONIC_INACTIVE, - - /** - * This value indicates the period is on the watchdog chain, and - * running. The owner should be executed or blocked waiting on - * another object. - */ - RATE_MONOTONIC_ACTIVE, - - /** - * This value indicates the period is off the watchdog chain, and - * has expired. The owner is still executing and has taken too much - * all time to complete this iteration of the period. - */ - RATE_MONOTONIC_EXPIRED -} rtems_rate_monotonic_period_states; - -/** - * The following constant is the interval passed to the rate_monontonic_period - * directive to obtain status information. - */ -#define RTEMS_PERIOD_STATUS WATCHDOG_NO_TIMEOUT - -/** - * The following defines the PUBLIC data structure that has the - * statistics kept on each period instance. - * - * @note The public structure uses struct timespec while the - * internal one uses Timestamp_Control. - */ -typedef struct { - /** This field contains the number of periods executed. */ - uint32_t count; - /** This field contains the number of periods missed. */ - uint32_t missed_count; - - /** This field contains the least amount of CPU time used in a period. */ - rtems_thread_cpu_usage_t min_cpu_time; - /** This field contains the highest amount of CPU time used in a period. */ - rtems_thread_cpu_usage_t max_cpu_time; - /** This field contains the total amount of wall time used in a period. */ - rtems_thread_cpu_usage_t total_cpu_time; - - /** This field contains the least amount of wall time used in a period. */ - rtems_rate_monotonic_period_time_t min_wall_time; - /** This field contains the highest amount of wall time used in a period. */ - rtems_rate_monotonic_period_time_t max_wall_time; - /** This field contains the total amount of CPU time used in a period. */ - rtems_rate_monotonic_period_time_t total_wall_time; -} rtems_rate_monotonic_period_statistics; - -/** - * The following defines the INTERNAL data structure that has the - * statistics kept on each period instance. - */ -typedef struct { - /** This field contains the number of periods executed. */ - uint32_t count; - /** This field contains the number of periods missed. */ - uint32_t missed_count; - - /** This field contains the least amount of CPU time used in a period. */ - Timestamp_Control min_cpu_time; - /** This field contains the highest amount of CPU time used in a period. */ - Timestamp_Control max_cpu_time; - /** This field contains the total amount of wall time used in a period. */ - Timestamp_Control total_cpu_time; - - /** This field contains the least amount of wall time used in a period. */ - Timestamp_Control min_wall_time; - /** This field contains the highest amount of wall time used in a period. */ - Timestamp_Control max_wall_time; - /** This field contains the total amount of CPU time used in a period. */ - Timestamp_Control total_wall_time; -} Rate_monotonic_Statistics; - -/** - * The following defines the period status structure. - */ -typedef struct { - /** This is the Id of the thread using this period. */ - rtems_id owner; - - /** This is the current state of this period. */ - rtems_rate_monotonic_period_states state; - - /** - * This is the length of wall time that has passed since this period - * was last initiated. If the period is expired or has not been initiated, - * then this field has no meaning. - */ - rtems_rate_monotonic_period_time_t since_last_period; - - /** - * This is the amount of CPU time that has been used since this period - * was last initiated. If the period is expired or has not been initiated, - * then this field has no meaning. - */ - rtems_thread_cpu_usage_t executed_since_last_period; - - /** This is the count of postponed jobs of this period. */ - uint32_t postponed_jobs_count; -} rtems_rate_monotonic_period_status; - -/** - * @brief The following structure defines the control block used to manage each - * period. - * - * State changes are protected by the default thread lock of the owner thread. - * The owner thread is the thread that created the period object. The owner - * thread field is immutable after object creation. - */ -typedef struct { - /** This field is the object management portion of a Period instance. */ - Objects_Control Object; - - /** - * @brief Protects the rate monotonic period state. - */ - ISR_LOCK_MEMBER( Lock ) - - /** This is the timer used to provide the unblocking mechanism. */ - Watchdog_Control Timer; - - /** This field indicates the current state of the period. */ - rtems_rate_monotonic_period_states state; - - /** - * @brief A priority node for use by the scheduler job release and cancel - * operations. - */ - Priority_Node Priority; - - /** - * This field contains the length of the next period to be - * executed. - */ - uint32_t next_length; - - /** - * This field contains a pointer to the TCB for the thread - * which owns and uses this period instance. - */ - Thread_Control *owner; - - /** - * This field contains the cpu usage value of the owning thread when - * the period was initiated. It is used to compute the period's - * statistics. - */ - Timestamp_Control cpu_usage_period_initiated; - - /** - * This field contains the wall time value when the period - * was initiated. It is used to compute the period's statistics. - */ - Timestamp_Control time_period_initiated; - - /** - * This field contains the statistics maintained for the period. - */ - Rate_monotonic_Statistics Statistics; - - /** - * This field contains the number of postponed jobs. - * When the watchdog timeout, this variable will be increased immediately. - */ - uint32_t postponed_jobs; - - /** - * This field contains the tick of the latest deadline decided by the period - * watchdog. - */ - uint64_t latest_deadline; -} Rate_monotonic_Control; - -/** - * @brief Create a Period - * - * Rate Monotonic Manager - * - * This routine implements the rate_monotonic_create directive. The - * period will have the name name. It returns the id of the - * created period in ID. - */ -rtems_status_code rtems_rate_monotonic_create( - rtems_name name, - rtems_id *id -); - -/** - * @brief RTEMS Rate Monotonic Name to Id - * - * This routine implements the rtems_rate_monotonic_ident directive. - * It returns the period ID associated with name. If more than one period - * is named name, then the period to which the ID belongs is arbitrary. - * - * @param[in] name is the user defined period name - * @param[in] id is the pointer to period id - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. If successful, the id will - * be filled in with the region id. - */ -rtems_status_code rtems_rate_monotonic_ident( - rtems_name name, - rtems_id *id -); - -/** - * @brief RTEMS Rate Monotonic Cancel - * - * This routine implements the rtems_rate_monotonic_cancel directive. This - * directive stops the period associated with ID from continuing to - * run. - * - * @param[in] id is the rate monotonic id - * - * @retval RTEMS_SUCCESSFUL if successful and caller is not the owning thread - * or error code if unsuccessful - * - */ -rtems_status_code rtems_rate_monotonic_cancel( - rtems_id id -); - -/** - * @brief RTEMS Delete Rate Monotonic - * - * This routine implements the rtems_rate_monotonic_delete directive. The - * period indicated by ID is deleted. - * - * @param[in] id is the rate monotonic id - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - */ -rtems_status_code rtems_rate_monotonic_delete( - rtems_id id -); - -/** - * @brief RTEMS Rate Monotonic Get Status - * - * This routine implements the rtems_rate_monotonic_get_status directive. - * Information about the period indicated by ID is returned. - * - * @param[in] id is the rate monotonic id - * @param[in] status is the pointer to status control block - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - * - */ -rtems_status_code rtems_rate_monotonic_get_status( - rtems_id id, - rtems_rate_monotonic_period_status *status -); - -/** - * @brief RTEMS Rate Monotonic Get Statistics - * - * This routine implements the rtems_rate_monotonic_get_statistics directive. - * Statistics gathered from the use of this period are returned. - * - * @param[in] id is the rate monotonic id - * @param[in] statistics is the pointer to statistics control block - * - * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful - */ -rtems_status_code rtems_rate_monotonic_get_statistics( - rtems_id id, - rtems_rate_monotonic_period_statistics *statistics -); - -/** - * @brief RTEMS Rate Monotonic Reset Statistics - * - * Rate Monotonic Manager -- Reset Statistics - * - * This routine allows a thread to reset the statistics information - * on a specific period instance. - */ -rtems_status_code rtems_rate_monotonic_reset_statistics( - rtems_id id -); - -/** - * @brief rtems_rate_monotonic_reset_all_statistics - * - * This routine allows a thread to reset the statistics information - * on ALL period instances. - */ -void rtems_rate_monotonic_reset_all_statistics( void ); - -/** - * @brief RTEMS Report Rate Monotonic Statistics - * - * This routine allows a thread to print the statistics information - * on ALL period instances which have non-zero counts using the RTEMS - * printer. The implementation of this directive straddles the fence - * between inside and outside of RTEMS. It is presented as part of - * the Manager but actually uses other services of the Manager. - */ -void rtems_rate_monotonic_report_statistics_with_plugin( - const struct rtems_printer *printer -); - -/** - * @brief RTEMS Report Rate Monotonic Statistics - * - * This routine allows a thread to print the statistics information - * on ALL period instances which have non-zero counts using printk. - */ -void rtems_rate_monotonic_report_statistics( void ); - -/** - * @brief RTEMS Rate Monotonic Period - * - * This routine implements the rtems_rate_monotonic_period directive. When - * length is non-zero, this directive initiates the period associated with - * ID from continuing for a period of length. If length is zero, then - * result is set to indicate the current state of the period. - * - * @param[in] id is the rate monotonic id - * @param[in] length is the length of period (in ticks) - * - * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful - */ -rtems_status_code rtems_rate_monotonic_period( - rtems_id id, - rtems_interval length -); - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/ratemonimpl.h b/cpukit/rtems/include/rtems/rtems/ratemonimpl.h deleted file mode 100644 index ba38a3e61a..0000000000 --- a/cpukit/rtems/include/rtems/rtems/ratemonimpl.h +++ /dev/null @@ -1,158 +0,0 @@ -/** - * @file - * - * @ingroup ClassicRateMonImpl - * - * @brief Classic Rate Monotonic Scheduler Implementation - */ - -/* COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * Copyright (c) 2016 embedded brains GmbH. - * COPYRIGHT (c) 2016 Kuan-Hsun Chen. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_RATEMONIMPL_H -#define _RTEMS_RTEMS_RATEMONIMPL_H - -#include -#include -#include -#include -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicRateMonImpl Classic Rate Monotonic Scheduler Implementation - * - * @ingroup ClassicRateMon - * - * @{ - */ - -#define RATE_MONOTONIC_INTEND_TO_BLOCK \ - ( THREAD_WAIT_CLASS_PERIOD | THREAD_WAIT_STATE_INTEND_TO_BLOCK ) - -#define RATE_MONOTONIC_BLOCKED \ - ( THREAD_WAIT_CLASS_PERIOD | THREAD_WAIT_STATE_BLOCKED ) - -#define RATE_MONOTONIC_READY_AGAIN \ - ( THREAD_WAIT_CLASS_PERIOD | THREAD_WAIT_STATE_READY_AGAIN ) - -/** - * @brief Rate Monotonic Period Class Management Structure - * - * This instance of Objects_Information is used to manage the - * set of rate monotonic period instances. - */ -extern Objects_Information _Rate_monotonic_Information; - -/** - * @brief Allocates a period control block from - * the inactive chain of free period control blocks. - * - * This function allocates a period control block from - * the inactive chain of free period control blocks. - */ -RTEMS_INLINE_ROUTINE Rate_monotonic_Control *_Rate_monotonic_Allocate( void ) -{ - return (Rate_monotonic_Control *) - _Objects_Allocate( &_Rate_monotonic_Information ); -} - -RTEMS_INLINE_ROUTINE void _Rate_monotonic_Acquire_critical( - Rate_monotonic_Control *the_period, - ISR_lock_Context *lock_context -) -{ - _ISR_lock_Acquire( &the_period->Lock, lock_context ); -} - -RTEMS_INLINE_ROUTINE void _Rate_monotonic_Release( - Rate_monotonic_Control *the_period, - ISR_lock_Context *lock_context -) -{ - _ISR_lock_Release_and_ISR_enable( &the_period->Lock, lock_context ); -} - -RTEMS_INLINE_ROUTINE Rate_monotonic_Control *_Rate_monotonic_Get( - Objects_Id id, - ISR_lock_Context *lock_context -) -{ - return (Rate_monotonic_Control *) - _Objects_Get( id, lock_context, &_Rate_monotonic_Information ); -} - -void _Rate_monotonic_Timeout( Watchdog_Control *watchdog ); - -/** - * @brief _Rate_monotonic_Get_status( - * - * This routine is invoked to compute the elapsed wall time and cpu - * time for a period. - * - * @param[in] the_period points to the period being operated upon. - * @param[out] wall_since_last_period is set to the wall time elapsed - * since the period was initiated. - * @param[out] cpu_since_last_period is set to the cpu time used by the - * owning thread since the period was initiated. - * - * @retval This routine returns true if the status can be determined - * and false otherwise. - */ -bool _Rate_monotonic_Get_status( - const Rate_monotonic_Control *the_period, - Timestamp_Control *wall_since_last_period, - Timestamp_Control *cpu_since_last_period -); - -void _Rate_monotonic_Restart( - Rate_monotonic_Control *the_period, - Thread_Control *owner, - ISR_lock_Context *lock_context -); - -void _Rate_monotonic_Cancel( - Rate_monotonic_Control *the_period, - Thread_Control *owner, - ISR_lock_Context *lock_context -); - -RTEMS_INLINE_ROUTINE void _Rate_monotonic_Reset_min_time( - Timestamp_Control *min_time -) -{ - _Timestamp_Set( min_time, 0x7fffffff, 0x7fffffff ); -} - -RTEMS_INLINE_ROUTINE void _Rate_monotonic_Reset_statistics( - Rate_monotonic_Control *the_period -) -{ - Rate_monotonic_Statistics *statistics; - - statistics = &the_period->Statistics; - memset( statistics, 0, sizeof( *statistics ) ); - _Rate_monotonic_Reset_min_time( &statistics->min_wall_time ); - _Rate_monotonic_Reset_min_time( &statistics->min_cpu_time ); -} - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/region.h b/cpukit/rtems/include/rtems/rtems/region.h deleted file mode 100644 index 4772e2835b..0000000000 --- a/cpukit/rtems/include/rtems/rtems/region.h +++ /dev/null @@ -1,298 +0,0 @@ -/** - * @file rtems/rtems/region.h - * - * @defgroup ClassicRegion Regions - * - * @ingroup ClassicRTEMS - * @brief Region Manager - * - * This include file contains all the constants and structures associated - * with the Region Manager. This manager provides facilities to dynamically - * allocate memory in variable sized units which are returned as segments. - * - * Directives provided are: - * - * - create a region - * - get an ID of a region - * - delete a region - * - get a segment from a region - * - return a segment to a region - */ - -/* COPYRIGHT (c) 1989-2013. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_REGION_H -#define _RTEMS_RTEMS_REGION_H - -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicRegion Regions - * - * @ingroup ClassicRTEMS - * - * This encapsulates functionality related to the Classic API Region - * Manager. - */ -/**@{*/ - -/** - * The following records define the control block used to manage - * each region. - */ - -typedef struct { - Objects_Control Object; - Thread_queue_Control Wait_queue; /* waiting threads */ - const Thread_queue_Operations *wait_operations; - uintptr_t maximum_segment_size; /* in bytes */ - rtems_attribute attribute_set; - Heap_Control Memory; -} Region_Control; - -/** - * @brief rtems_region_create - * - * Region Manager - * - * This routine implements the rtems_region_create directive. The - * region will have the name name. The memory area managed by - * the region is of length bytes and starts at starting_address. - * The memory area will be divided into as many allocatable units of - * page_size bytes as possible. The attribute_set determines which - * thread queue discipline is used by the region. It returns the - * id of the created region in ID. - */ -rtems_status_code rtems_region_create( - rtems_name name, - void *starting_address, - uintptr_t length, - uintptr_t page_size, - rtems_attribute attribute_set, - rtems_id *id -); - -/** - * @brief RTEMS Extend Region - * - * This routine implements the rtems_region_extend directive. The - * region will have the name name. The memory area managed by - * the region will be attempted to be grown by length bytes using - * the memory starting at starting_address. - * - * @param[in] id is the id of region to grow - * @param[in] starting_address starting address of memory area for extension - * @param[in] length is the physical length in bytes to grow the region - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - */ -rtems_status_code rtems_region_extend( - rtems_id id, - void *starting_address, - uintptr_t length -); - -/** - * @brief RTEMS Region Name to Id - * - * This routine implements the rtems_region_ident directive. - * This directive returns the region ID associated with name. - * If more than one region is named name, then the region - * to which the ID belongs is arbitrary. - * - * @param[in] name is the user defined region name - * @param[in] id is the pointer to region id - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. If successful, the id will - * be filled in with the region id. - */ -rtems_status_code rtems_region_ident( - rtems_name name, - rtems_id *id -); - -/** - * @brief RTEMS Get Region Information - * - * This routine implements the rtems_region_get_information directive. - * This directive returns information about the heap associated with - * this region. - * - * @param[in] id is the region id - * @param[in] the_info is the pointer to region information block - * - * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful and - * *id filled with the region information block - */ -rtems_status_code rtems_region_get_information( - rtems_id id, - Heap_Information_block *the_info -); - -/** - * @brief RTEMS Get Region Free Information - * - * This routine implements the rtems_region_get_free_information directive. - * This directive returns information about the free blocks in the - * heap associated with this region. Information about the used blocks - * will be returned as zero. - * - * @param[in] id is the region id - * @param[in] the_info is the pointer to region information block - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. If successful, the the_info will - * be filled in with the region information block. - */ -rtems_status_code rtems_region_get_free_information( - rtems_id id, - Heap_Information_block *the_info -); - -/** - * @brief RTEMS Delete Region - * - * This routine implements the rtems_region_delete directive. The - * region indicated by ID is deleted, provided that none of its segments are - * still allocated. - * - * @param[in] id is the region id - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - */ -rtems_status_code rtems_region_delete( - rtems_id id -); - -/** - * @brief RTEMS Get Region Segment - * - * This routine implements the rtems_region_get_segment directive. It - * attempts to allocate a segment from the region associated with @a id. - * If a segment of the requested @a size size can be allocated, its address - * is returned in @a segment. If no segment is available, then the task - * may return immediately or block waiting for a segment with an optional - * timeout of @a timeout clock ticks. Whether the task blocks or returns - * immediately is based on the no_wait option in the @a option_set. - * - * @param[in] id is the region id - * @param[in] size is the segment size in bytes - * @param[in] option_set is the wait option - * @param[in] timeout is the number of ticks to wait (0 means wait forever) - * @param[in] segment is the pointer to segment address - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. If successful, the segment will - * be filled in with the segment address. - */ -rtems_status_code rtems_region_get_segment( - rtems_id id, - uintptr_t size, - rtems_option option_set, - rtems_interval timeout, - void **segment -); - -/** - * @brief RTEMS Get Region Segment Size - * - * This routine implements the rtems_region_get_segment_size directive. It - * returns the size in bytes of the specified user memory area. - * - * @param[in] id is the region id - * @param[in] segment is the segment address - * @param[in] size is the pointer to segment size in bytes - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. If successful, the size will - * be filled in with the segment size in bytes. - */ -rtems_status_code rtems_region_get_segment_size( - rtems_id id, - void *segment, - uintptr_t *size -); - -/** - * @brief RTEMS Return Region Segment - * - * This routine implements the rtems_region_return_segment directive. It - * frees the segment to the region associated with ID. The segment must - * have been previously allocated from the same region. If freeing the - * segment results in enough memory being available to satisfy the - * rtems_region_get_segment of the first blocked task, then that task and as - * many subsequent tasks as possible will be unblocked with their requests - * satisfied. - * - * @param[in] id is the region id - * @param[in] segment is the pointer to segment address - * - * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful - */ -rtems_status_code rtems_region_return_segment( - rtems_id id, - void *segment -); - -/** - * @brief Resize RTEMS Region Segment - * - * This routine implements the rtems_region_resize_segment directive. It - * tries to resize segment in the region associated with 'id' to the new size - * 'size' in place. The first 'size' or old size bytes of the segment - * (whatever is less) are guaranteed to remain unmodified. The segment must - * have been previously allocated from the same region. If resizing the - * segment results in enough memory being available to satisfy the - * rtems_region_get_segment of the first blocked task, then that task and as - * many subsequent tasks as possible will be unblocked with their requests - * satisfied. - * - * @param[in] id is the region id - * @param[in] segment is the pointer to segment address - * @param[in] size is the new required size - * @retval RTEMS_SUCCESSFUL if operation successful, RTEMS_UNSATISFIED if the - * the segment can't be resized in place or any other code at failure - * - * @note On RTEMS_SUCCESSFUL or RTEMS_UNSATISFIED exit it returns into the - * 'old_size' the old size in bytes of the user memory area of the - * specified segment. - */ -rtems_status_code rtems_region_resize_segment( - rtems_id id, - void *segment, - uintptr_t size, - uintptr_t *old_size -); - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/regionimpl.h b/cpukit/rtems/include/rtems/rtems/regionimpl.h deleted file mode 100644 index 178b7ea32b..0000000000 --- a/cpukit/rtems/include/rtems/rtems/regionimpl.h +++ /dev/null @@ -1,142 +0,0 @@ -/** - * @file - * - * @ingroup ClassicRegionImpl - * - * @brief Classic Region Manager Implementation - */ - -/* COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_REGIONIMPL_H -#define _RTEMS_RTEMS_REGIONIMPL_H - -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicRegionImpl Classic Region Manager Implementation - * - * @ingroup ClassicRegion - * - * @{ - */ - -#define REGION_OF_THREAD_QUEUE_QUEUE( queue ) \ - RTEMS_CONTAINER_OF( queue, Region_Control, Wait_queue.Queue ) - -/** - * The following defines the information control block used to - * manage this class of objects. - */ -extern Objects_Information _Region_Information; - -/** - * @brief Region_Allocate - * - * This function allocates a region control block from - * the inactive chain of free region control blocks. - */ -RTEMS_INLINE_ROUTINE Region_Control *_Region_Allocate( void ) -{ - return (Region_Control *) _Objects_Allocate( &_Region_Information ); -} - -/** - * @brief Region_Free - * - * This routine frees a region control block to the - * inactive chain of free region control blocks. - */ -RTEMS_INLINE_ROUTINE void _Region_Free ( - Region_Control *the_region -) -{ - _Thread_queue_Destroy( &the_region->Wait_queue ); - _Objects_Free( &_Region_Information, &the_region->Object ); -} - -RTEMS_INLINE_ROUTINE Region_Control *_Region_Get_and_lock( Objects_Id id ) -{ - Region_Control *the_region; - - _RTEMS_Lock_allocator(); - - the_region = (Region_Control *) - _Objects_Get_no_protection( id, &_Region_Information ); - - if ( the_region != NULL ) { - /* Keep allocator lock */ - return the_region; - } - - _RTEMS_Unlock_allocator(); - return NULL; -} - -RTEMS_INLINE_ROUTINE void _Region_Unlock( Region_Control *the_region ) -{ - (void) the_region; - _RTEMS_Unlock_allocator(); -} - -/** - * @brief Region_Allocate_segment - * - * This function attempts to allocate a segment from the_region. - * If successful, it returns the address of the allocated segment. - * Otherwise, it returns NULL. - */ -RTEMS_INLINE_ROUTINE void *_Region_Allocate_segment ( - Region_Control *the_region, - uintptr_t size -) -{ - return _Heap_Allocate( &the_region->Memory, size ); -} - -/** - * @brief Region_Free_segment - * - * This function frees the_segment to the_region. - */ -RTEMS_INLINE_ROUTINE bool _Region_Free_segment ( - Region_Control *the_region, - void *the_segment -) -{ - return _Heap_Free( &the_region->Memory, the_segment ); -} - -/** - * @brief Process Region Queue - * - * This is a helper routine which is invoked any time memory is - * freed. It looks at the set of waiting tasks and attempts to - * satisfy all outstanding requests. - * - * @param[in] the_region is the the region - */ -extern void _Region_Process_queue(Region_Control *the_region); - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/sem.h b/cpukit/rtems/include/rtems/rtems/sem.h deleted file mode 100644 index 41b0061979..0000000000 --- a/cpukit/rtems/include/rtems/rtems/sem.h +++ /dev/null @@ -1,278 +0,0 @@ -/** - * @file - * - * @ingroup ClassicSem - * - * @brief Classic Semaphores API - * - * This include file contains all the constants and structures associated - * with the Semaphore Manager. This manager utilizes standard Dijkstra - * counting semaphores to provide synchronization and mutual exclusion - * capabilities. - * - * Directives provided are: - * - * - create a semaphore - * - get an ID of a semaphore - * - delete a semaphore - * - acquire a semaphore - * - release a semaphore - * - flush a semaphore - * - set ceiling priority for a semaphore - */ - -/* - * COPYRIGHT (c) 1989-2008, 2016. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_SEM_H -#define _RTEMS_RTEMS_SEM_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicSem Semaphores - * - * @ingroup ClassicRTEMS - * - * This encapsulates functionality related to the Classic API - * Semaphore Manager. - */ -/**@{*/ - -/** - * The following defines the control block used to manage each semaphore. - */ -typedef struct { - /** This field is the object management portion of a Semaphore instance. */ - Objects_Control Object; - - /** - * This contains the memory associated with the SuperCore Semaphore or - * Mutex instance that provides the primary functionality of each - * Classic API Semaphore instance. The structure used is dependent - * on the attributes specified by the user on the create directive. - * - * @note Only one of these has meaning in a particular Classic API - * Semaphore instance. - */ - union { - /** - * @brief The thread queue present in all other variants. - */ - Thread_queue_Control Wait_queue; - - /** - * This is the SuperCore Mutex instance associated with this Classic - * API Semaphore instance. - */ - CORE_ceiling_mutex_Control Mutex; - - /** - * This is the SuperCore Semaphore instance associated with this Classic - * API Semaphore instance. - */ - CORE_semaphore_Control Semaphore; - -#if defined(RTEMS_SMP) - MRSP_Control MRSP; -#endif - } Core_control; - - /** - * @brief The semaphore variant. - * - * @see Semaphore_Variant. - */ - unsigned int variant : 3; - - /** - * @brief The semaphore thread queue discipline. - * - * @see Semaphore_Discipline. - */ - unsigned int discipline : 1; - -#if defined(RTEMS_MULTIPROCESSING) - unsigned int is_global : 1; -#endif -} Semaphore_Control; - -/** - * @brief rtems_semaphore_create - * - * This routine implements the rtems_semaphore_create directive. The - * semaphore will have the name name. The starting count for - * the semaphore is count. The attribute_set determines if - * the semaphore is global or local and the thread queue - * discipline. It returns the id of the created semaphore in ID. - */ -rtems_status_code rtems_semaphore_create( - rtems_name name, - uint32_t count, - rtems_attribute attribute_set, - rtems_task_priority priority_ceiling, - rtems_id *id -); - -/** - * @brief RTEMS Semaphore Name to Id - * - * This routine implements the rtems_semaphore_ident directive. - * This directive returns the semaphore ID associated with name. - * If more than one semaphore is named name, then the semaphore - * to which the ID belongs is arbitrary. node indicates the - * extent of the search for the ID of the semaphore named name. - * The search can be limited to a particular node or allowed to - * encompass all nodes. - * - * @param[in] name is the user defined semaphore name - * @param[in] node is(are) the node(s) to be searched - * @param[in] id is the pointer to semaphore id - * - * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful and - * *id filled in with the semaphore id - */ -rtems_status_code rtems_semaphore_ident( - rtems_name name, - uint32_t node, - rtems_id *id -); - -/** - * @brief RTEMS Delete Semaphore - * - * This routine implements the rtems_semaphore_delete directive. The - * semaphore indicated by ID is deleted. - * - * @param[in] id is the semaphore id - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - */ -rtems_status_code rtems_semaphore_delete( - rtems_id id -); - -/** - * @brief RTEMS Obtain Semaphore - * - * This routine implements the rtems_semaphore_obtain directive. It - * attempts to obtain a unit from the semaphore associated with ID. - * If a unit can be allocated, the calling task will return immediately. - * If no unit is available, then the task may return immediately or - * block waiting for a unit with an optional timeout of timeout - * clock ticks. Whether the task blocks or returns immediately - * is based on the RTEMS_NO_WAIT option in the option_set. - * - * @param[in] id is the semaphore id - * @param[in] option_set is the wait option - * @param[in] timeout is the number of ticks to wait (0 means wait forever) - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - */ -rtems_status_code rtems_semaphore_obtain( - rtems_id id, - rtems_option option_set, - rtems_interval timeout -); - -/** - * @brief RTEMS Semaphore Release - * - * This routine implements the rtems_semaphore_release directive. It - * frees a unit to the semaphore associated with ID. If a task was - * blocked waiting for a unit from this semaphore, then that task will - * be readied and the unit given to that task. Otherwise, the unit - * will be returned to the semaphore. - */ -rtems_status_code rtems_semaphore_release( - rtems_id id -); - -/** - * @brief RTEMS Semaphore Flush - * - * This method is the implementation of the flush directive - * of the Semaphore Manager. - * - * This directive allows a thread to flush the threads - * pending on the semaphore. - * - * @param[in] id is the semaphore id - * - * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful - */ -rtems_status_code rtems_semaphore_flush( - rtems_id id -); - -/** - * @brief Sets the priority value with respect to the specified scheduler of a - * semaphore. - * - * The special priority value @ref RTEMS_CURRENT_PRIORITY can be used to get - * the current priority value without changing it. - * - * The interpretation of the priority value depends on the protocol of the - * semaphore object. - * - * - The Multiprocessor Resource Sharing Protocol needs a ceiling priority per - * scheduler instance. This operation can be used to specify these priority - * values. - * - For the Priority Ceiling Protocol the ceiling priority is used with this - * operation. - * - For other protocols this operation is not defined. - * - * @param[in] semaphore_id Identifier of the semaphore. - * @param[in] scheduler_id Identifier of the scheduler. - * @param[in] new_priority The new priority value. Use - * @ref RTEMS_CURRENT_PRIORITY to not set a new priority and only get the - * current priority. - * @param[out] old_priority Reference to store the old priority value. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_INVALID_ID Invalid semaphore or scheduler identifier. - * @retval RTEMS_INVALID_ADDRESS The old priority reference is @c NULL. - * @retval RTEMS_INVALID_PRIORITY The new priority value is invalid. - * @retval RTEMS_NOT_DEFINED The set priority operation is not defined for the - * protocol of this semaphore object. - * @retval RTEMS_ILLEGAL_ON_REMOTE_OBJECT Not supported for remote semaphores. - * - * @see rtems_scheduler_ident() and rtems_task_set_priority(). - */ -rtems_status_code rtems_semaphore_set_priority( - rtems_id semaphore_id, - rtems_id scheduler_id, - rtems_task_priority new_priority, - rtems_task_priority *old_priority -); - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/semimpl.h b/cpukit/rtems/include/rtems/rtems/semimpl.h deleted file mode 100644 index 6d0f156e5c..0000000000 --- a/cpukit/rtems/include/rtems/rtems/semimpl.h +++ /dev/null @@ -1,120 +0,0 @@ -/** - * @file - * - * @ingroup ClassicSem - * - * @brief Classic Semaphores Implementation - */ - -/* COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_SEMIMPL_H -#define _RTEMS_RTEMS_SEMIMPL_H - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Classic semaphore variants. - * - * Must be in synchronization with Semaphore_Control::variant. - */ -typedef enum { - SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY, - SEMAPHORE_VARIANT_MUTEX_PRIORITY_CEILING, - SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL, - SEMAPHORE_VARIANT_SIMPLE_BINARY, - SEMAPHORE_VARIANT_COUNTING -#if defined(RTEMS_SMP) - , - SEMAPHORE_VARIANT_MRSP -#endif -} Semaphore_Variant; - -typedef enum { - SEMAPHORE_DISCIPLINE_PRIORITY, - SEMAPHORE_DISCIPLINE_FIFO -} Semaphore_Discipline; - -/** - * The following defines the information control block used to manage - * this class of objects. - */ -extern Objects_Information _Semaphore_Information; - -RTEMS_INLINE_ROUTINE const Thread_queue_Operations *_Semaphore_Get_operations( - const Semaphore_Control *the_semaphore -) -{ - if ( the_semaphore->variant == SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY ) { - return &_Thread_queue_Operations_priority_inherit; - } - - if ( the_semaphore->discipline == SEMAPHORE_DISCIPLINE_PRIORITY ) { - return &_Thread_queue_Operations_priority; - } - - return &_Thread_queue_Operations_FIFO; -} - -/** - * @brief Allocates a semaphore control block from - * the inactive chain of free semaphore control blocks. - * - * This function allocates a semaphore control block from - * the inactive chain of free semaphore control blocks. - */ -RTEMS_INLINE_ROUTINE Semaphore_Control *_Semaphore_Allocate( void ) -{ - return (Semaphore_Control *) _Objects_Allocate( &_Semaphore_Information ); -} - -/** - * @brief Frees a semaphore control block to the - * inactive chain of free semaphore control blocks. - * - * This routine frees a semaphore control block to the - * inactive chain of free semaphore control blocks. - */ -RTEMS_INLINE_ROUTINE void _Semaphore_Free ( - Semaphore_Control *the_semaphore -) -{ - _Objects_Free( &_Semaphore_Information, &the_semaphore->Object ); -} - -RTEMS_INLINE_ROUTINE Semaphore_Control *_Semaphore_Get( - Objects_Id id, - Thread_queue_Context *queue_context -) -{ - _Thread_queue_Context_initialize( queue_context ); - return (Semaphore_Control *) _Objects_Get( - id, - &queue_context->Lock_context.Lock_context, - &_Semaphore_Information - ); -} - -#ifdef __cplusplus -} -#endif - -#ifdef RTEMS_MULTIPROCESSING -#include -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/semmp.h b/cpukit/rtems/include/rtems/rtems/semmp.h deleted file mode 100644 index 9d7669f43e..0000000000 --- a/cpukit/rtems/include/rtems/rtems/semmp.h +++ /dev/null @@ -1,171 +0,0 @@ -/** - * @file rtems/rtems/semmp.h - * - * @defgroup ClassicSEM Semaphore MP Support - * - * @ingroup ClassicRTEMS - * @brief Semaphore Manager MP Support - * - * This include file contains all the constants and structures associated - * with the Multiprocessing Support in the Semaphore Manager. - */ - -/* COPYRIGHT (c) 1989-2013. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_SEMMP_H -#define _RTEMS_RTEMS_SEMMP_H - -#ifndef _RTEMS_RTEMS_SEMIMPL_H -# error "Never use directly; include instead." -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicSEM Semaphore MP Support - * - * @ingroup ClassicMP - * - * This encapsulates functionality related to the transparent multiprocessing - * support within the Classic API Semaphore Manager. - */ -/**@{*/ - -/** - * The following enumerated type defines the list of - * remote semaphore operations. - */ -typedef enum { - SEMAPHORE_MP_ANNOUNCE_CREATE = 0, - SEMAPHORE_MP_ANNOUNCE_DELETE = 1, - SEMAPHORE_MP_EXTRACT_PROXY = 2, - SEMAPHORE_MP_OBTAIN_REQUEST = 3, - SEMAPHORE_MP_OBTAIN_RESPONSE = 4, - SEMAPHORE_MP_RELEASE_REQUEST = 5, - SEMAPHORE_MP_RELEASE_RESPONSE = 6 -} Semaphore_MP_Remote_operations; - -/** - * The following data structure defines the packet used to perform - * remote semaphore operations. - */ -typedef struct { - rtems_packet_prefix Prefix; - Semaphore_MP_Remote_operations operation; - rtems_name name; - rtems_option option_set; - Objects_Id proxy_id; -} Semaphore_MP_Packet; - -RTEMS_INLINE_ROUTINE bool _Semaphore_MP_Is_remote( Objects_Id id ) -{ - return _Objects_MP_Is_remote( id, &_Semaphore_Information ); -} - -/** - * @brief Semaphore MP Send Process Packet - * - * This routine performs a remote procedure call so that a - * process operation can be performed on another node. - */ -void _Semaphore_MP_Send_process_packet ( - Semaphore_MP_Remote_operations operation, - Objects_Id semaphore_id, - rtems_name name, - Objects_Id proxy_id -); - -/** - * @brief Issues a remote rtems_semaphore_obtain() request. - */ -rtems_status_code _Semaphore_MP_Obtain( - rtems_id id, - rtems_option option_set, - rtems_interval timeout -); - -/** - * @brief Issues a remote rtems_semaphore_release() request. - */ -rtems_status_code _Semaphore_MP_Release( rtems_id id ); - -/** - * @brief Semaphore MP Process Packet - * - * This routine performs the actions specific to this package for - * the request from another node. - */ -void _Semaphore_MP_Process_packet ( - rtems_packet_prefix *the_packet_prefix -); - -/** - * @brief Semaphore MP Send Object was Deleted - * - * This routine is invoked indirectly by the thread queue - * when a proxy has been removed from the thread queue and - * the remote node must be informed of this. - */ -void _Semaphore_MP_Send_object_was_deleted ( - Thread_Control *the_proxy, - Objects_Id mp_id -); - -/** - * @brief Semaphore MP Send Extract Proxy - * - * This routine is invoked when a task is deleted and it - * has a proxy which must be removed from a thread queue and - * the remote node must be informed of this. - */ -void _Semaphore_MP_Send_extract_proxy ( - Thread_Control *the_thread, - Objects_Id id -); - -/** - * @brief Semaphore Core Mutex MP Support - * - * This function processes the global actions necessary for remote - * accesses to a global semaphore based on a core mutex. This function - * is called by the core. - * - * @param[in] the_thread the remote thread the semaphore was surrendered to - * @param[in] id is the id of the surrendered semaphore - */ -void _Semaphore_Core_mutex_mp_support ( - Thread_Control *the_thread, - Objects_Id id -); - -/** - * @brief Semaphore Core MP Support - * - * This function processes the global actions necessary for remote - * accesses to a global semaphore based on a core semaphore. This function - * is called by the core. - * - * @param[in] the_thread the remote thread the semaphore was surrendered to - * @param[in] id is the id of the surrendered semaphore - */ -void _Semaphore_Core_semaphore_mp_support ( - Thread_Control *the_thread, - Objects_Id id -); - -#ifdef __cplusplus -} -#endif - -/**@}*/ - -#endif -/* end of file */ diff --git a/cpukit/rtems/include/rtems/rtems/signal.h b/cpukit/rtems/include/rtems/rtems/signal.h deleted file mode 100644 index f7b7000d9a..0000000000 --- a/cpukit/rtems/include/rtems/rtems/signal.h +++ /dev/null @@ -1,83 +0,0 @@ -/** - * @file - * - * @ingroup ClassicSignal - * - * @brief Signals API - */ - -/* COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_SIGNAL_H -#define _RTEMS_RTEMS_SIGNAL_H - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicSignal Signals - * - * @ingroup ClassicRTEMS - * - * Directives provided are: - * - * + establish an asynchronous signal routine - * + send a signal set to a task - */ -/**@{*/ - -/** - * @brief RTEMS Catch Signal - * - * This routine implements the rtems_signal_catch directive. This directive - * is used to establish asr_handler as the Asynchronous Signal Routine - * (RTEMS_ASR) for the calling task. The asr_handler will execute with a - * mode of mode_set. - * - * @param[in] asr_handler is the address of asynchronous signal routine (asr) - * ( NULL indicates asr is invalid ) - * @param[in] mode_set is the mode value for asr - * - * @retval RTEMS_SUCCESSFUL - */ -rtems_status_code rtems_signal_catch( - rtems_asr_entry asr_handler, - rtems_mode mode_set -); - -/** - * @brief RTEMS Send Signal - * - * This routine implements the rtems_signal_send directive. This directive - * sends the signal_set to the task specified by ID. - * - * @param[in] id is the thread thread id - * @param[in] signal_set is the signal set - * - * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful - */ -rtems_status_code rtems_signal_send( - rtems_id id, - rtems_signal_set signal_set -); - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/signalimpl.h b/cpukit/rtems/include/rtems/rtems/signalimpl.h deleted file mode 100644 index 61848ae95c..0000000000 --- a/cpukit/rtems/include/rtems/rtems/signalimpl.h +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @file - * - * @ingroup ClassicSignalImpl - * - * @brief Signals Implementation - */ - -/* COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_SIGNALIMPL_H -#define _RTEMS_RTEMS_SIGNALIMPL_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicSignalImpl Signals Implementation - * - * @ingroup ClassicSignal - */ -/**@{*/ - -void _Signal_Action_handler( - Thread_Control *executing, - Thread_Action *action, - ISR_lock_Context *lock_context -); - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#if defined(RTEMS_MULTIPROCESSING) -#include -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/signalmp.h b/cpukit/rtems/include/rtems/rtems/signalmp.h deleted file mode 100644 index 57b8682c58..0000000000 --- a/cpukit/rtems/include/rtems/rtems/signalmp.h +++ /dev/null @@ -1,98 +0,0 @@ -/** - * @file rtems/rtems/signalmp.h - * - * @brief Signal MP Support - * - * This include file contains all the constants and structures associated - * with the Multiprocessing Support in the Signal Manager. - */ - -/* COPYRIGHT (c) 1989-2013. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_SIGNALMP_H -#define _RTEMS_RTEMS_SIGNALMP_H - -#ifndef _RTEMS_RTEMS_SIGNALIMPL_H -# error "Never use directly; include instead." -#endif - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicSignalMP Signal MP Support - * - * @ingroup ClassicMP - * - * This encapsulates functionality related to the transparent multiprocessing - * support within the Classic API Signal Manager. - */ -/*{*/ - -/* - * @brief Signal_MP_Send_process_packet - * - * This routine performs a remote procedure call so that a - * process operation can be performed on another node. - * - * This routine is not needed since there are no process - * packets to be sent by this manager. - */ - -/** - * @brief Issues a remote rtems_signal_send() request. - */ -rtems_status_code _Signal_MP_Send( - rtems_id id, - rtems_signal_set signal_set -); - -/** - * @brief Signal MP Process Packet - * - * This routine performs the actions specific to this package for - * the request from another node. - */ -void _Signal_MP_Process_packet ( - rtems_packet_prefix *the_packet_prefix -); - -/* - * @brief Signal_MP_Send_object_was_deleted - * - * This routine is invoked indirectly by the thread queue - * when a proxy has been removed from the thread queue and - * the remote node must be informed of this. - * - * This routine is not needed since there are no objects - * deleted by this manager. - */ - -/* - * @brief Signal_MP_Send_extract_proxy - * - * This routine is invoked when a task is deleted and it - * has a proxy which must be removed from a thread queue and - * the remote node must be informed of this. - * - * This routine is not needed since there are no objects - * deleted by this manager. - */ - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of file */ diff --git a/cpukit/rtems/include/rtems/rtems/smp.h b/cpukit/rtems/include/rtems/rtems/smp.h deleted file mode 100644 index aeb0df6f46..0000000000 --- a/cpukit/rtems/include/rtems/rtems/smp.h +++ /dev/null @@ -1,78 +0,0 @@ -/** - * @file - * - * @ingroup ClassicSMP - * - * @brief SMP Services API - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_SMP_H -#define _RTEMS_RTEMS_SMP_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicSMP SMP Services - * - * @ingroup ClassicRTEMS - * - * This encapsulates functionality which is useful for SMP applications. - * - * @{ - */ - -/** - * @brief Returns the count of processors in the system. - * - * On uni-processor configurations a value of one will be returned. - * - * On SMP configurations this returns the value of a global variable set during - * system initialization to indicate the count of utilized processors. The - * processor count depends on the physically or virtually available processors - * and application configuration. The value will always be less than or equal - * to the maximum count of application configured processors. - * - * @return The count of processors being utilized. - */ -uint32_t rtems_get_processor_count(void); - -/** - * @brief Returns the index of the current processor. - * - * On uni-processor configurations a value of zero will be returned. - * - * On SMP configurations an architecture specific method is used to obtain the - * index of the current processor in the system. The set of processor indices - * is the range of integers starting with zero up to the processor count minus - * one. - * - * Outside of sections with disabled thread dispatching the current processor - * index may change after every instruction since the thread may migrate from - * one processor to another. Sections with disabled interrupts are sections - * with thread dispatching disabled. - * - * @return The index of the current processor. - */ -uint32_t rtems_get_current_processor(void); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/status.h b/cpukit/rtems/include/rtems/rtems/status.h deleted file mode 100644 index c54404ba14..0000000000 --- a/cpukit/rtems/include/rtems/rtems/status.h +++ /dev/null @@ -1,263 +0,0 @@ -/** - * @file rtems/rtems/status.h - * - * @defgroup ClassicStatus Status Codes - * - * @ingroup ClassicRTEMS - * @brief Status Codes Returned from Executive Directives - * - * This include file contains the status codes returned from the - * executive directives. - */ - -/* COPYRIGHT (c) 1989-2013. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_STATUS_H -#define _RTEMS_RTEMS_STATUS_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicStatus Status Codes - * - * @ingroup ClassicRTEMS - * - * This encapsulates functionality related to the status codes returned - * by Classic API directives. - */ -/**@{*/ - -/** - * @brief Classic API Status - * - * This enumerates the possible status values returned b - * Classic API directives. - */ -typedef enum { - /** - * This is the status to indicate successful completion. - */ - RTEMS_SUCCESSFUL = 0, - /** - * This is the status to indicate that a thread exited. - */ - RTEMS_TASK_EXITTED = 1, - /** - * This is the status to indicate multiprocessing is not configured. - */ - RTEMS_MP_NOT_CONFIGURED = 2, - /** - * This is the status to indicate that the object name was invalid. - */ - RTEMS_INVALID_NAME = 3, - /** - * This is the status to indicate that the object Id was invalid. - */ - RTEMS_INVALID_ID = 4, - /** - * This is the status to indicate you have attempted to create too many - * instances of a particular object class. - */ - RTEMS_TOO_MANY = 5, - /** - * This is the status to indicate that a blocking directive timed out. - */ - RTEMS_TIMEOUT = 6, - /** - * This is the status to indicate the the object was deleted - * while the task was blocked waiting. - */ - RTEMS_OBJECT_WAS_DELETED = 7, - /** - * This is the status to indicate that the specified size was invalid. - */ - RTEMS_INVALID_SIZE = 8, - /** - * This is the status to indicate that the specified address is invalid. - */ - RTEMS_INVALID_ADDRESS = 9, - /** - * This is the status to indicate that the specified number was invalid. - */ - RTEMS_INVALID_NUMBER = 10, - /** - * This is the status to indicate that the item has not been initialized. - */ - RTEMS_NOT_DEFINED = 11, - /** - * This is the status to indicate that the object still has - * resources in use. - */ - RTEMS_RESOURCE_IN_USE = 12, - /** - * This is the status to indicate that the request was not satisfied. - */ - RTEMS_UNSATISFIED = 13, - /** - * This is the status to indicate that a thread is in wrong state - * was in the wrong execution state for the requested operation. - */ - RTEMS_INCORRECT_STATE = 14, - /** - * This is the status to indicate thread was already suspended. - */ - RTEMS_ALREADY_SUSPENDED = 15, - /** - * This is the status to indicate that the operation is illegal - * on calling thread. - */ - RTEMS_ILLEGAL_ON_SELF = 16, - /** - * This is the status to indicate illegal for remote object. - */ - RTEMS_ILLEGAL_ON_REMOTE_OBJECT = 17, - /** - * This is the status to indicate that the operation should not be - * called from from this excecution environment. - */ - RTEMS_CALLED_FROM_ISR = 18, - /** - * This is the status to indicate that an invalid thread priority - * was provided. - */ - RTEMS_INVALID_PRIORITY = 19, - /** - * This is the status to indicate that the specified date/time was invalid. - */ - RTEMS_INVALID_CLOCK = 20, - /** - * This is the status to indicate that the specified node Id was invalid. - */ - RTEMS_INVALID_NODE = 21, - /** - * This is the status to indicate that the directive was not configured. - */ - RTEMS_NOT_CONFIGURED = 22, - /** - * This is the status to indicate that the caller is not the - * owner of the resource. - */ - RTEMS_NOT_OWNER_OF_RESOURCE = 23, - /** - * This is the status to indicate the the directive or requested - * portion of the directive is not implemented. This is a hint - * that you have stumbled across an opportunity to submit code - * to the RTEMS Project. - */ - RTEMS_NOT_IMPLEMENTED = 24, - /** - * This is the status to indicate that an internal RTEMS inconsistency - * was detected. - */ - RTEMS_INTERNAL_ERROR = 25, - /** - * This is the status to indicate that the directive attempted to allocate - * memory but was unable to do so. - */ - RTEMS_NO_MEMORY = 26, - /** - * This is the status to indicate an driver IO error. - */ - RTEMS_IO_ERROR = 27, - /** - * This is the status is used internally to RTEMS when performing - * operations on behalf of remote tasks. This is referred to as - * proxying operations and this status indicates that the operation - * could not be completed immediately and the "proxy is blocking." - * - * @note This status will @b NOT be returned to the user. - */ - RTEMS_PROXY_BLOCKING = 28 -} rtems_status_code; - -/** - * This is the lowest valid value for a Classic API status code. - */ -#define RTEMS_STATUS_CODES_FIRST RTEMS_SUCCESSFUL - -/** - * This is the highest valid value for a Classic API status code. - */ -#define RTEMS_STATUS_CODES_LAST RTEMS_PROXY_BLOCKING - -/** - * @brief Checks if the status code is equal to RTEMS_SUCCESSFUL. - * - * This function returns TRUE if the status code is equal to RTEMS_SUCCESSFUL, - * and FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool rtems_is_status_successful( - rtems_status_code code -) -{ - return (code == RTEMS_SUCCESSFUL); -} - -/** - * @brief Checks if the status code1 is equal to code2. - * - * This function returns TRUE if the status code1 is equal to code2, - * and FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool rtems_are_statuses_equal( - rtems_status_code code1, - rtems_status_code code2 -) -{ - return (code1 == code2); -} - -/** - * @brief RTEMS Status Code to Errno Mapping Function - * - * This function recieves an RTEMS status code and returns an - * errno error code. The retval values show the mappings between - * rtems_status_codes and errno error codes. - * - * @retval 0 RTEMS_SUCCESSFUL - * @retval EIO RTEMS_TASK_EXITED, RTEMS_MP_NOT_CONFIGURED, RTEMS_INVALID_ID, - * RTEMS_TOO_MANY, RTEMS_OBJECT_WAS_DELETED, RTEMS_INVALID_SIZE, - * RTEMS_INVALID_ADDRESS, RTEMS_NOT_DEFINED, RTEMS_INCORRECT_STATE, - * RTEMS_ILLEGAL_ON_SELF, RTEMS_ILLEGAL_ON_REMOTE_OBJECT, - * RTEMS_CALLED_FROM_ISR, RTEMS_INVALID_PRIORITY, RTEMS_INTERNAL_ERROR, - * RTEMS_IO_ERROR, RTEMS_PROXY_BLOCKING - * @retval EINVAL RTEMS_INVALID_NAME, RTEMS_INVALID_CLOCK, RTEMS_INVALID_NODE - * @retval ETIMEDOUT RTEMS_TIMEOUT - * @retval EBADF RTEMS_INVALID_NUMBER - * @retval EBUSY RTEMS_RESOURCE_IN_USE - * @retval ENODEV RTEMS_UNSATISFIED - * @retval ENOSYS RTEMS_NOT_IMPLEMENTED, RTEMS_NOT_CONFIGURED - * @retval ENOMEM RTEMS_NO_MEMORY - */ -int rtems_status_code_to_errno(rtems_status_code sc); - -/** - * @brief Returns a text for a status code. - * - * The text for each status code is the enumerator constant. - * - * @param[in] code The status code. - * - * @retval text The status code text. - * @retval "?" The passed status code is invalid. - */ -const char *rtems_status_text( rtems_status_code code ); - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/statusimpl.h b/cpukit/rtems/include/rtems/rtems/statusimpl.h deleted file mode 100644 index 8a51bb8b19..0000000000 --- a/cpukit/rtems/include/rtems/rtems/statusimpl.h +++ /dev/null @@ -1,64 +0,0 @@ -/** - * @file - * - * @ingroup ClassicStatusImpl - * - * @brief Classic Status Implementation - */ - -/* COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_STATUSIMPL_H -#define _RTEMS_RTEMS_STATUSIMPL_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicStatusImpl Classic Status Implementation - * - * @ingroup ClassicStatus - * - * @{ - */ - -/** - * @brief Status Object Name Errors to Status Array - * - * This array is used to map SuperCore Object Handler return - * codes to Classic API status codes. - */ -extern const rtems_status_code _Status_Object_name_errors_to_status[]; - -RTEMS_INLINE_ROUTINE rtems_status_code _Status_Get( - Status_Control status -) -{ - return (rtems_status_code) STATUS_GET_CLASSIC( status ); -} - -RTEMS_INLINE_ROUTINE rtems_status_code _Status_Get_after_wait( - const Thread_Control *executing -) -{ - return _Status_Get( _Thread_Wait_get_status( executing ) ); -} - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/support.h b/cpukit/rtems/include/rtems/rtems/support.h deleted file mode 100644 index 4ebb50cbdf..0000000000 --- a/cpukit/rtems/include/rtems/rtems/support.h +++ /dev/null @@ -1,170 +0,0 @@ -/** - * @file - * - * @defgroup ClassicRTEMSWorkspace Workspace - * - * @ingroup ClassicRTEMS - * @brief Classic API support. - */ - -/* COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_SUPPORT_H -#define _RTEMS_RTEMS_SUPPORT_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ClassicRTEMS - */ -/**@{**/ - -/** - * @brief Returns the number of micro seconds for the milli seconds value @a _ms. - */ -#define RTEMS_MILLISECONDS_TO_MICROSECONDS(_ms) ((_ms) * 1000UL) - -/** - * @brief Returns the number of ticks for the milli seconds value @a _ms. - */ -#define RTEMS_MILLISECONDS_TO_TICKS(_ms) \ - (RTEMS_MILLISECONDS_TO_MICROSECONDS(_ms) / \ - rtems_configuration_get_microseconds_per_tick()) - -/** - * @brief Returns the number of ticks for the micro seconds value @a _us. - */ -#define RTEMS_MICROSECONDS_TO_TICKS(_us) \ - ((_us) / rtems_configuration_get_microseconds_per_tick()) - -/** - * @brief Returns @c true if the name is valid, and @c false otherwise. - */ -RTEMS_INLINE_ROUTINE bool rtems_is_name_valid ( - rtems_name name -) -{ - return ( name != 0 ); -} - -/** - * @brief Breaks the object name into the four component characters @a c1, - * @a c2, @a c3, and @a c4. - */ -RTEMS_INLINE_ROUTINE void rtems_name_to_characters( - rtems_name name, - char *c1, - char *c2, - char *c3, - char *c4 -) -{ - *c1 = (char) ((name >> 24) & 0xff); - *c2 = (char) ((name >> 16) & 0xff); - *c3 = (char) ((name >> 8) & 0xff); - *c4 = (char) ( name & 0xff); -} - -/** @} */ - -/** - * @defgroup ClassicRTEMSWorkspace Workspace - * - * @ingroup ClassicRTEMS - * - * Workspace definitions. - */ -/**@{**/ - -/** - * @brief Gets Workspace Information - * - * Returns information about the heap that is used as the RTEMS Executive - * Workspace in @a the_info. - * - * Returns @c true if successful, and @a false otherwise. - */ -bool rtems_workspace_get_information( - Heap_Information_block *the_info -); - -/** - * @brief Allocates Memory from the Workspace - * - * A number of @a bytes bytes will be allocated from the RTEMS Executive - * Workspace and returned in @a pointer. - * - * Returns @c true if successful, and @a false otherwise. - */ -bool rtems_workspace_allocate( - size_t bytes, - void **pointer -); - -/** - * @brief Frees Memory Allocated from the Workspace - * - * This frees the memory indicated by @a pointer that was allocated from the - * RTEMS Executive Workspace. - * - * Returns @c true if successful, and @a false otherwise. - */ -bool rtems_workspace_free( - void *pointer -); - -/** - * @brief Greedy allocate that empties the workspace. - * - * Afterwards the heap has at most @a block_count allocatable blocks of sizes - * specified by @a block_sizes. The @a block_sizes must point to an array with - * @a block_count members. All other blocks are used. - * - * @see rtems_workspace_greedy_free(). - */ -void *rtems_workspace_greedy_allocate( - const uintptr_t *block_sizes, - size_t block_count -); - -/** - * @brief Greedy allocate all blocks except the largest free block. - * - * Afterwards the heap has at most one allocatable block. This block is the - * largest free block if it exists. The allocatable size of this block is - * stored in @a allocatable_size. All other blocks are used. - * - * @see rtems_workspace_greedy_free(). - */ -void *rtems_workspace_greedy_allocate_all_except_largest( - uintptr_t *allocatable_size -); - -/** - * @brief Frees space of a greedy allocation. - * - * The @a opaque argument must be the return value of - * rtems_workspace_greedy_allocate() or - * rtems_workspace_greedy_allocate_all_except_largest(). - */ -void rtems_workspace_greedy_free( void *opaque ); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/taskmp.h b/cpukit/rtems/include/rtems/rtems/taskmp.h deleted file mode 100644 index e2d70a924e..0000000000 --- a/cpukit/rtems/include/rtems/rtems/taskmp.h +++ /dev/null @@ -1,132 +0,0 @@ -/** - * @file rtems/rtems/taskmp.h - * - * @defgroup ClassicTaskMP Task MP Support - * - * @ingroup ClassicRTEMS - * @brief Task Manager MP Support - * - * This include file contains all the constants and structures associated - * with the multiprocessing support in the task manager. - */ - -/* COPYRIGHT (c) 1989-2013. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_TASKMP_H -#define _RTEMS_RTEMS_TASKMP_H - -#ifndef _RTEMS_RTEMS_TASKSIMPL_H -# error "Never use directly; include instead." -#endif - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicTaskMP Task MP Support - * - * @ingroup ClassicMP - * - * This encapsulates functionality related to the transparent multiprocessing - * support within the Classic API Task Manager. - */ -/**@{*/ - -/** - * The following enumerated type defines the list of - * remote task operations. - */ -typedef enum { - RTEMS_TASKS_MP_ANNOUNCE_CREATE = 0, - RTEMS_TASKS_MP_ANNOUNCE_DELETE = 1, - RTEMS_TASKS_MP_SUSPEND_REQUEST = 2, - RTEMS_TASKS_MP_SUSPEND_RESPONSE = 3, - RTEMS_TASKS_MP_RESUME_REQUEST = 4, - RTEMS_TASKS_MP_RESUME_RESPONSE = 5, - RTEMS_TASKS_MP_SET_PRIORITY_REQUEST = 6, - RTEMS_TASKS_MP_SET_PRIORITY_RESPONSE = 7, -} RTEMS_tasks_MP_Remote_operations; - -/** - * @brief RTEMS Tasks MP Send Process Packet - * - * Multiprocessing Support for the RTEMS Task Manager - * - * This routine performs a remote procedure call so that a - * process operation can be performed on another node. - */ -void _RTEMS_tasks_MP_Send_process_packet ( - RTEMS_tasks_MP_Remote_operations operation, - Objects_Id task_id, - rtems_name name -); - -/** - * @brief Issues a remote rtems_task_set_priority() request. - */ -rtems_status_code _RTEMS_tasks_MP_Set_priority( - rtems_id id, - rtems_task_priority new_priority, - rtems_task_priority *old_priority -); - -/** - * @brief Issues a remote rtems_task_suspend() request. - */ -rtems_status_code _RTEMS_tasks_MP_Suspend( rtems_id id ); - -/** - * @brief Issues a remote rtems_task_resume() request. - */ -rtems_status_code _RTEMS_tasks_MP_Resume( rtems_id id ); - -/** - * @brief _RTEMS_tasks_MP_Process_packet - * - * This routine performs the actions specific to this package for - * the request from another node. - */ -void _RTEMS_tasks_MP_Process_packet ( - rtems_packet_prefix *the_packet_prefix -); - -/** - * @brief _RTEMS_tasks_MP_Send_object_was_deleted - * - * This routine is invoked indirectly by the thread queue - * when a proxy has been removed from the thread queue and - * the remote node must be informed of this. - * - * This routine is not needed by RTEMS_tasks since a task - * cannot be deleted when segments are in use. - */ - -/* - * _RTEMS_tasks_MP_Send_extract_proxy - * - * This routine is invoked when a task is deleted and it - * has a proxy which must be removed from a thread queue and - * the remote node must be informed of this. - * - * This routine is not needed since there are no objects - * deleted by this manager. - * - */ - -#ifdef __cplusplus -} -#endif - -/**@}*/ - -#endif -/* end of file */ diff --git a/cpukit/rtems/include/rtems/rtems/tasks.h b/cpukit/rtems/include/rtems/rtems/tasks.h deleted file mode 100644 index 585f4c449c..0000000000 --- a/cpukit/rtems/include/rtems/rtems/tasks.h +++ /dev/null @@ -1,716 +0,0 @@ -/** - * @file rtems/rtems/tasks.h - * - * @defgroup ClassicTasks Tasks - * - * @ingroup ClassicRTEMS - * @brief RTEMS Tasks - * - * This include file contains all constants and structures associated - * with RTEMS tasks. This manager provides a comprehensive set of directives - * to create, delete, and administer tasks. - * - * Directives provided are: - * - * - create a task - * - get an ID of a task - * - start a task - * - restart a task - * - delete a task - * - suspend a task - * - resume a task - * - set a task's priority - * - change the current task's mode - * - wake up after interval - * - wake up when specified - */ - -/* - * COPYRIGHT (c) 1989-2014. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_TASKS_H -#define _RTEMS_RTEMS_TASKS_H - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicTasks Tasks - * - * @ingroup ClassicRTEMS - * - * This encapsulates the functionality of the Classic API Task Manager. - * This functionality includes task services such as creation, deletion, - * delays, suspend/resume, and manipulation of execution mode and priority. - */ -/**@{*/ - -/** - * Constant to be used as the ID of current task - */ -#define RTEMS_SELF OBJECTS_ID_OF_SELF - -/** - * This constant is passed to the rtems_task_wake_after directive as the - * interval when a task wishes to yield the CPU. - */ -#define RTEMS_YIELD_PROCESSOR WATCHDOG_NO_TIMEOUT - -/** - * Define the type for an RTEMS API task priority. - */ -typedef uint32_t rtems_task_priority; - -/** - * This is the constant used with the rtems_task_set_priority - * directive to indicate that the caller wants to obtain its - * current priority rather than set it as the name of the - * directive indicates. - */ -#define RTEMS_NO_PRIORITY RTEMS_CURRENT_PRIORITY - -/** - * This constant is the least valid value for a Classic API - * task priority. - */ -#define RTEMS_MINIMUM_PRIORITY (PRIORITY_MINIMUM + 1) - -/** - * This constant is the maximum valid value for a Classic API - * task priority. - * - * @note This is actually the priority of the IDLE thread so - * using this priority will result in having a task - * which never executes. This could be useful if you - * want to ensure that a task does not executes during - * certain operations such as a system mode change. - */ -#define RTEMS_MAXIMUM_PRIORITY ((rtems_task_priority) PRIORITY_MAXIMUM) - -/** - * The following constant is passed to rtems_task_set_priority when the - * caller wants to obtain the current priority. - */ -#define RTEMS_CURRENT_PRIORITY PRIORITY_MINIMUM - -/** - * External API name for Thread_Control - */ -typedef Thread_Control rtems_tcb; - -/** - * The following defines the "return type" of an RTEMS task. - */ -typedef void rtems_task; - -/** - * The following defines the argument to an RTEMS task. - */ -typedef Thread_Entry_numeric_type rtems_task_argument; - -/** - * The following defines the type for the entry point of an RTEMS task. - */ -typedef rtems_task ( *rtems_task_entry )( - rtems_task_argument - ); - -/** - * The following records define the Initialization Tasks Table. - * Each entry contains the information required by RTEMS to - * create and start a user task automatically at executive - * initialization time. - */ -typedef struct { - /** This is the Initialization Task's name. */ - rtems_name name; - /** This is the Initialization Task's stack size. */ - size_t stack_size; - /** This is the Initialization Task's priority. */ - rtems_task_priority initial_priority; - /** This is the Initialization Task's attributes. */ - rtems_attribute attribute_set; - /** This is the Initialization Task's entry point. */ - rtems_task_entry entry_point; - /** This is the Initialization Task's initial mode. */ - rtems_mode mode_set; - /** This is the Initialization Task's argument. */ - rtems_task_argument argument; -} rtems_initialization_tasks_table; - -/** - * @brief RTEMS Task Create - * - * This routine implements the rtems_task_create directive. The task - * will have the name name. The attribute_set can be used to indicate - * that the task will be globally accessible or utilize floating point. - * The task's stack will be stack_size bytes. The task will begin - * execution with initial_priority and initial_modes. It returns the - * id of the created task in ID. - * - * @param[in] name is the user defined thread name - * @param[in] initial_priority is the thread priority - * @param[in] stack_size is the stack size in bytes - * @param[in] initial_modes is the initial thread mode - * @param[in] attribute_set is the thread attributes - * @param[in] id is the pointer to thread id - * - * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful - * and *id thread id filled in - */ -rtems_status_code rtems_task_create( - rtems_name name, - rtems_task_priority initial_priority, - size_t stack_size, - rtems_mode initial_modes, - rtems_attribute attribute_set, - rtems_id *id -); - -/** - * @brief RTEMS Task Name to Id - * - * This routine implements the rtems_task_ident directive. - * This directive returns the task ID associated with name. - * If more than one task is named name, then the task to - * which the ID belongs is arbitrary. node indicates the - * extent of the search for the ID of the task named name. - * The search can be limited to a particular node or allowed to - * encompass all nodes. - * - * @param[in] name is the user defined thread name - * @param[in] node is(are) the node(s) to be searched - * @param[in] id is the pointer to thread id - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. If successful, the id will - * be filled in with the thread id. - */ -rtems_status_code rtems_task_ident( - rtems_name name, - uint32_t node, - rtems_id *id -); - -/** - * @brief RTEMS Delete Task - * - * This routine implements the rtems_task_delete directive. The - * task indicated by ID is deleted. The executive halts execution - * of the thread and frees the thread control block. - * - * @param[in] id is the thread id - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error and id is not the requesting thread. Status code is - * returned indicating the source of the error. Nothing - * is returned if id is the requesting thread (always succeeds). - */ -rtems_status_code rtems_task_delete( - rtems_id id -); - -/** - * @brief RTEMS Task Mode - * - * This routine implements the rtems_task_mode directive. The current - * values of the modes indicated by mask of the calling task are changed - * to that indicated in mode_set. The former mode of the task is - * returned in mode_set. - * - * @param[in] mode_set is the new mode - * @param[in] mask is the mask - * @param[in] previous_mode_set is the address of previous mode set - * - * @retval RTEMS_SUCCESSFUL and previous_mode_set filled in with the - * previous mode set - */ -rtems_status_code rtems_task_mode( - rtems_mode mode_set, - rtems_mode mask, - rtems_mode *previous_mode_set -); - -/** - * @brief RTEMS Task Restart - * - * This routine implements the rtems_task_restart directive. The - * task associated with ID is restarted at its initial entry - * point with the new argument. - * - * @param[in] id is the thread id - * @param[in] arg is the thread argument - * - * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful - */ -rtems_status_code rtems_task_restart( - rtems_id id, - uint32_t arg -); - -/** - * @brief RTEMS Suspend Task - * - * This routine implements the rtems_task_suspend directive. The - * SUSPENDED state is set for task associated with ID. Note that the - * suspended state can be in addition to other waiting states. - * - * @param[in] id is the thread id - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - */ -rtems_status_code rtems_task_suspend( - rtems_id id -); - -/** - * @brief RTEMS Resume Task - * - * This routine implements the rtems_task_resume Directive. The - * SUSPENDED state is cleared for task associated with ID. - * - * @param[in] id is the thread id - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - */ -rtems_status_code rtems_task_resume( - rtems_id id -); - -/** - * @brief RTEMS Set Task Priority - * - * This routine implements the rtems_task_set_priority directive. The - * current priority of the task associated with ID is set to - * new_priority. The former priority of that task is returned - * in old_priority. - * - * @param[in] id is the thread to extract - * @param[in] new_priority is the thread to extract - * @param[in] old_priority is the thread to extract - * - * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful and - * and *old_priority filled in with the previous previous priority - */ -rtems_status_code rtems_task_set_priority( - rtems_id id, - rtems_task_priority new_priority, - rtems_task_priority *old_priority -); - -/** - * @brief Gets the current priority of the specified task with respect to the - * specified scheduler instance. - * - * The current priority reflects temporary priority adjustments due to locking - * protocols, the rate-monotonic period objects on some schedulers and other - * mechanisms. - * - * @param[in] task_id Identifier of the task. Use @ref RTEMS_SELF to select - * the executing task. - * @param[in] scheduler_id Identifier of the scheduler instance. - * @param[out] priority Returns the current priority of the specified task with - * respect to the specified scheduler instance. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_ILLEGAL_ON_REMOTE_OBJECT Directive is illegal on remote tasks. - * @retval RTEMS_INVALID_ADDRESS The priority parameter is @c NULL. - * @retval RTEMS_INVALID_ID Invalid task or scheduler identifier. - * @retval RTEMS_NOT_DEFINED The task has no priority within the specified - * scheduler instance. This error is only possible on SMP configurations. - * - * @see rtems_scheduler_ident(). - */ -rtems_status_code rtems_task_get_priority( - rtems_id task_id, - rtems_id scheduler_id, - rtems_task_priority *priority -); - -/** - * @brief RTEMS Start Task - * - * RTEMS Task Manager - * - * This routine implements the rtems_task_start directive. The - * starting execution point of the task associated with ID is - * set to entry_point with the initial argument. - */ -rtems_status_code rtems_task_start( - rtems_id id, - rtems_task_entry entry_point, - rtems_task_argument argument -); - -/** - * @brief RTEMS Task Wake When - * - * This routine implements the rtems_task_wake_when directive. The - * calling task is blocked until the current time of day is - * equal to that indicated by time_buffer. - * - * @param[in] time_buffer is the pointer to the time and date structure - * - * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful - */ -rtems_status_code rtems_task_wake_when( - rtems_time_of_day *time_buffer -); - -/** - * @brief RTEMS Task Wake After - * - * This routine implements the rtems_task_wake_after directive. The - * calling task is blocked until the indicated number of clock - * ticks have occurred. - * - * @param[in] ticks is the number of ticks to wait - * @retval RTEMS_SUCCESSFUL - */ -rtems_status_code rtems_task_wake_after( - rtems_interval ticks -); - -/** - * @brief rtems_task_is_suspended - * - * This directive returns a status indicating whether or not - * the specified task is suspended. - */ -rtems_status_code rtems_task_is_suspended( - rtems_id id -); - -/** - * @brief Gets the processor affinity set of a task. - * - * @param[in] id Identifier of the task. Use @ref RTEMS_SELF to select the - * executing task. - * @param[in] cpusetsize Size of the specified affinity set buffer in - * bytes. This value must be positive. - * @param[out] cpuset The current processor affinity set of the task. A set - * bit in the affinity set means that the task can execute on this processor - * and a cleared bit means the opposite. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_INVALID_ADDRESS The @a cpuset parameter is @c NULL. - * @retval RTEMS_INVALID_ID Invalid task identifier. - * @retval RTEMS_INVALID_NUMBER The affinity set buffer is too small for the - * current processor affinity set of the task. - */ -rtems_status_code rtems_task_get_affinity( - rtems_id id, - size_t cpusetsize, - cpu_set_t *cpuset -); - -/** - * @brief Sets the processor affinity set of a task. - * - * This function will not change the scheduler of the task. The intersection - * of the processor affinity set and the set of processors owned by the - * scheduler of the task must be non-empty. It is not an error if the - * processor affinity set contains processors that are not part of the set of - * processors owned by the scheduler instance of the task. A task will simply - * not run under normal circumstances on these processors since the scheduler - * ignores them. Some locking protocols may temporarily use processors that - * are not included in the processor affinity set of the task. It is also not - * an error if the processor affinity set contains processors that are not part - * of the system. - * - * @param[in] id Identifier of the task. Use @ref RTEMS_SELF to select the - * executing task. - * @param[in] cpusetsize Size of the specified affinity set buffer in - * bytes. This value must be positive. - * @param[in] cpuset The new processor affinity set for the task. A set bit in - * the affinity set means that the task can execute on this processor and a - * cleared bit means the opposite. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_INVALID_ADDRESS The @a cpuset parameter is @c NULL. - * @retval RTEMS_INVALID_ID Invalid task identifier. - * @retval RTEMS_INVALID_NUMBER Invalid processor affinity set. - */ -rtems_status_code rtems_task_set_affinity( - rtems_id id, - size_t cpusetsize, - const cpu_set_t *cpuset -); - -/** - * @brief Gets the scheduler of a task. - * - * @param[in] task_id Identifier of the task. Use @ref RTEMS_SELF to select - * the executing task. - * @param[out] scheduler_id Identifier of the scheduler instance. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_INVALID_ADDRESS The @a scheduler_id parameter is @c NULL. - * @retval RTEMS_INVALID_ID Invalid task identifier. - */ -rtems_status_code rtems_task_get_scheduler( - rtems_id task_id, - rtems_id *scheduler_id -); - -/** - * @brief Sets the scheduler instance of a task. - * - * Initially, the scheduler instance of a task is set to the scheduler instance - * of the task that created it. This directive allows to move a task from its - * current scheduler instance to another specified by the scheduler identifier. - * - * @param[in] task_id Identifier of the task. Use @ref RTEMS_SELF to select - * the executing task. - * @param[in] scheduler_id Identifier of the scheduler instance. - * @param[in] priority The task priority with respect to the new scheduler - * instance. The real and initial priority of the task is set to this value. - * The initial priority is used by rtems_task_restart() for example. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_ILLEGAL_ON_REMOTE_OBJECT Directive is illegal on remote tasks. - * @retval RTEMS_INVALID_ID Invalid task or scheduler identifier. - * @retval RTEMS_INVALID_PRIORITY Invalid priority. - * @retval RTEMS_RESOURCE_IN_USE The task owns resources which deny a scheduler - * change. - * - * @see rtems_scheduler_ident(). - */ -rtems_status_code rtems_task_set_scheduler( - rtems_id task_id, - rtems_id scheduler_id, - rtems_task_priority priority -); - -/** - * @brief RTEMS Get Self Task Id - * - * This directive returns the ID of the currently executing task. - */ -rtems_id rtems_task_self(void); - -/** - * @brief Task visitor. - * - * @param[in] tcb The task control block. - * @param[in] arg The visitor argument. - * - * @retval true Stop the iteration. - * @retval false Otherwise. - * - * @see rtems_task_iterate(). - */ -typedef bool ( *rtems_task_visitor )( rtems_tcb *tcb, void *arg ); - -/** - * @brief Iterates over all tasks in the system. - * - * This operation covers all tasks of all APIs. - * - * Must be called from task context. This operation obtains and releases the - * objects allocator lock. The task visitor is called while owning the objects - * allocator lock. It is possible to perform blocking operations in the task - * visitor, however, take care that no deadlocks via the object allocator lock - * can occur. - * - * @param[in] visitor The task visitor. - * @param[in] arg The visitor argument. - */ -void rtems_task_iterate( - rtems_task_visitor visitor, - void *arg -); - -/** - * @brief Identifies a scheduler by its name. - * - * The scheduler name is determined by the scheduler configuration. - * - * @param[in] name The scheduler name. - * @param[out] id The scheduler identifier associated with the name. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_INVALID_ADDRESS The @a id parameter is @c NULL. - * @retval RTEMS_INVALID_NAME Invalid scheduler name. - */ -rtems_status_code rtems_scheduler_ident( - rtems_name name, - rtems_id *id -); - -/** - * @brief Identifies a scheduler by a processor index. - * - * @param[in] cpu_index The processor index. - * @param[out] id The scheduler identifier associated with the processor index. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_INVALID_ADDRESS The @a id parameter is @c NULL. - * @retval RTEMS_INVALID_NAME Invalid processor index. - * @retval RTEMS_INCORRECT_STATE The processor index is valid, however, this - * processor is not owned by a scheduler. - */ -rtems_status_code rtems_scheduler_ident_by_processor( - uint32_t cpu_index, - rtems_id *id -); - -/** - * @brief Identifies a scheduler by a processor set. - * - * The scheduler is selected according to the highest numbered online processor - * in the specified processor set. - * - * @param[in] cpusetsize Size of the specified processor set buffer in - * bytes. This value must be positive. - * @param[out] cpuset The processor set to identify the scheduler. - * @param[out] id The scheduler identifier associated with the processor set. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_INVALID_ADDRESS The @a id parameter is @c NULL. - * @retval RTEMS_INVALID_SIZE Invalid processor set size. - * @retval RTEMS_INVALID_NAME The processor set contains no online processor. - * @retval RTEMS_INCORRECT_STATE The processor set is valid, however, the - * highest numbered online processor in the specified processor set is not - * owned by a scheduler. - */ -rtems_status_code rtems_scheduler_ident_by_processor_set( - size_t cpusetsize, - const cpu_set_t *cpuset, - rtems_id *id -); - -/** - * @brief Gets the set of processors owned by the specified scheduler instance. - * - * @param[in] scheduler_id Identifier of the scheduler instance. - * @param[in] cpusetsize Size of the specified processor set buffer in - * bytes. This value must be positive. - * @param[out] cpuset The processor set owned by the scheduler. A set bit in - * the processor set means that this processor is owned by the scheduler and a - * cleared bit means the opposite. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_INVALID_ADDRESS The @a cpuset parameter is @c NULL. - * @retval RTEMS_INVALID_ID Invalid scheduler instance identifier. - * @retval RTEMS_INVALID_NUMBER The processor set buffer is too small for the - * set of processors owned by the scheduler. - */ -rtems_status_code rtems_scheduler_get_processor_set( - rtems_id scheduler_id, - size_t cpusetsize, - cpu_set_t *cpuset -); - -/** - * @brief Adds a processor to the set of processors owned by the specified - * scheduler instance. - * - * Must be called from task context. This operation obtains and releases the - * objects allocator lock. - * - * @param[in] scheduler_id Identifier of the scheduler instance. - * @param[in] cpu_index Index of the processor to add. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_INVALID_ID Invalid scheduler instance identifier. - * @retval RTEMS_NOT_CONFIGURED The processor is not configured to be used by - * the application. - * @retval RTEMS_INCORRECT_STATE The processor is configured to be used by - * the application, however, it is not online. - * @retval RTEMS_RESOURCE_IN_USE The processor is already assigned to a - * scheduler instance. - */ -rtems_status_code rtems_scheduler_add_processor( - rtems_id scheduler_id, - uint32_t cpu_index -); - -/** - * @brief Removes a processor from set of processors owned by the specified - * scheduler instance. - * - * Must be called from task context. This operation obtains and releases the - * objects allocator lock. Removing a processor from a scheduler is a complex - * operation that involves all tasks of the system. - * - * @param[in] scheduler_id Identifier of the scheduler instance. - * @param[in] cpu_index Index of the processor to add. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_INVALID_ID Invalid scheduler instance identifier. - * @retval RTEMS_INVALID_NUMBER The processor is not owned by the specified - * scheduler instance. - * @retval RTEMS_RESOURCE_IN_USE The set of processors owned by the specified - * scheduler instance would be empty after the processor removal and there - * exists a non-idle task that uses this scheduler instance as its home - * scheduler instance. - */ -rtems_status_code rtems_scheduler_remove_processor( - rtems_id scheduler_id, - uint32_t cpu_index -); - -/**@}*/ - -/** - * This is the API specific information required by each thread for - * the RTEMS API to function correctly. - * - */ -typedef struct { - /** This field contains the event control for this task. */ - Event_Control Event; - /** This field contains the system event control for this task. */ - Event_Control System_event; - /** This field contains the Classic API Signal information for this task. */ - ASR_Information Signal; - - /** - * @brief Signal post-switch action in case signals are pending. - */ - Thread_Action Signal_action; -} RTEMS_API_Control; - -/** - * @brief _RTEMS_tasks_Initialize_user_tasks_body - * - * This routine creates and starts all configured user - * initialization threads. - * - * Input parameters: NONE - * - * Output parameters: NONE - * - * RTEMS Task Manager - */ - -extern void _RTEMS_tasks_Initialize_user_tasks_body( void ); - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/tasksimpl.h b/cpukit/rtems/include/rtems/rtems/tasksimpl.h deleted file mode 100644 index b0432351f3..0000000000 --- a/cpukit/rtems/include/rtems/rtems/tasksimpl.h +++ /dev/null @@ -1,131 +0,0 @@ -/** - * @file - * - * @ingroup ClassicTasksImpl - * - * @brief Classic Tasks Manager Implementation - */ - -/* COPYRIGHT (c) 1989-2014. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_TASKSIMPL_H -#define _RTEMS_RTEMS_TASKSIMPL_H - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicTasksImpl Classic Tasks Manager Implementation - * - * @ingroup ClassicTasks - * - * @{ - */ - -/** - * The following instantiates the information control block used to - * manage this class of objects. - */ -extern Thread_Information _RTEMS_tasks_Information; - -/** - * @brief RTEMS User Task Initialization - * - * This routine creates and starts all configured user - * initialization threads. - */ -void _RTEMS_tasks_Initialize_user_tasks( void ); - -RTEMS_INLINE_ROUTINE Thread_Control *_RTEMS_tasks_Allocate(void) -{ - _Objects_Allocator_lock(); - - _Thread_Kill_zombies(); - - return (Thread_Control *) - _Objects_Allocate_unprotected( &_RTEMS_tasks_Information.Objects ); -} - -/** - * @brief Frees a task control block. - * - * This routine frees a task control block to the - * inactive chain of free task control blocks. - */ -RTEMS_INLINE_ROUTINE void _RTEMS_tasks_Free ( - Thread_Control *the_task -) -{ - _Objects_Free( - _Objects_Get_information_id( the_task->Object.id ), - &the_task->Object - ); -} - -/** - * @brief Converts the RTEMS API priority to the corresponding SuperCore - * priority and validates it. - * - * The RTEMS API system priority is accepted as valid. - * - * @param[in] scheduler The scheduler instance. - * @param[in] priority The RTEMS API priority to convert and validate. - * @param[out] valid Indicates if the RTEMS API priority is valid and a - * corresponding SuperCore priority in the specified scheduler instance - * exists. - * - * @return The corresponding SuperCore priority. - */ -RTEMS_INLINE_ROUTINE Priority_Control _RTEMS_Priority_To_core( - const Scheduler_Control *scheduler, - rtems_task_priority priority, - bool *valid -) -{ - *valid = ( priority <= scheduler->maximum_priority ); - - return _Scheduler_Map_priority( scheduler, (Priority_Control) priority ); -} - -/** - * @brief Converts the SuperCore priority to the corresponding RTEMS API - * priority. - * - * @param[in] scheduler The scheduler instance. - * @param[in] priority The SuperCore priority to convert. - * - * @return The corresponding RTEMS API priority. - */ -RTEMS_INLINE_ROUTINE rtems_task_priority _RTEMS_Priority_From_core( - const Scheduler_Control *scheduler, - Priority_Control priority -) -{ - return (rtems_task_priority) - _Scheduler_Unmap_priority( scheduler, priority ); -} - -/**@}*/ - -#if defined(RTEMS_MULTIPROCESSING) -#include -#endif - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/timer.h b/cpukit/rtems/include/rtems/rtems/timer.h deleted file mode 100644 index 032c49525a..0000000000 --- a/cpukit/rtems/include/rtems/rtems/timer.h +++ /dev/null @@ -1,384 +0,0 @@ -/** - * @file rtems/rtems/timer.h - * - * @defgroup ClassicTimer Timers - * - * @ingroup ClassicRTEMS - * @brief Instantiate RTEMS Timer Data - * - * This include file contains all the constants, structures, and - * prototypes associated with the Timer Manager. This manager provides - * facilities to configure, initiate, cancel, and delete timers which will - * fire at specified intervals of time. - * - * Directives provided are: - * - * - create a timer - * - get an ID of a timer - * - delete a timer - * - set timer to fire in context of clock tick - * - after a number of ticks have passed - * - when a specified date and time has been reached - * - initiate the timer server task - * - set timer to fire in context of the timer server task - * - after a number of ticks have passed - * - when a specified date and time has been reached - * - reset a timer - * - cancel a time - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * Copyright (c) 2009, 2016 embedded brains GmbH. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_TIMER_H -#define _RTEMS_RTEMS_TIMER_H - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicTimer Timers - * - * @ingroup ClassicRTEMS - * - * This encapsulates functionality related to the Classic API Timer - * Manager. This manager provides functionality which allows the - * application to schedule the execution of methods at a specified - * time in the future. These methods may be scheduled based upon - * interval or wall time and may be executed in either the clock tick - * ISR or in a special dedicated timer server task. - */ -/**@{*/ - -#define TIMER_CLASS_BIT_TIME_OF_DAY 0x1 - -#define TIMER_CLASS_BIT_ON_TASK 0x2 - -#define TIMER_CLASS_BIT_NOT_DORMANT 0x4 - -/** - * The following enumerated type details the classes to which a timer - * may belong. - */ -typedef enum { - /** - * This value indicates the timer is currently not in use. - */ - TIMER_DORMANT, - - /** - * This value indicates the timer is currently in use as an interval - * timer which will fire in the clock tick ISR. - */ - TIMER_INTERVAL = TIMER_CLASS_BIT_NOT_DORMANT, - - /** - * This value indicates the timer is currently in use as an interval - * timer which will fire in the timer server task. - */ - TIMER_INTERVAL_ON_TASK = - TIMER_CLASS_BIT_NOT_DORMANT | TIMER_CLASS_BIT_ON_TASK, - - /** - * This value indicates the timer is currently in use as an time of day - * timer which will fire in the clock tick ISR. - */ - TIMER_TIME_OF_DAY = - TIMER_CLASS_BIT_NOT_DORMANT | TIMER_CLASS_BIT_TIME_OF_DAY, - - /** - * This value indicates the timer is currently in use as an time of day - * timer which will fire in the timer server task. - */ - TIMER_TIME_OF_DAY_ON_TASK = - TIMER_CLASS_BIT_NOT_DORMANT | TIMER_CLASS_BIT_TIME_OF_DAY | - TIMER_CLASS_BIT_ON_TASK -} Timer_Classes; - -/** - * The following types define a pointer to a timer service routine. - */ -typedef void rtems_timer_service_routine; - -/** - * This type defines the type used to manage and indirectly invoke - * Timer Service Routines (TSRs). This defines the prototype and interface - * for a function which is to be used as a TSR. - */ -typedef rtems_timer_service_routine ( *rtems_timer_service_routine_entry )( - rtems_id, - void * - ); - -/** - * The following records define the control block used to manage - * each timer. - */ -typedef struct { - /** This field is the object management portion of a Timer instance. */ - Objects_Control Object; - /** This field is the Watchdog instance which will be the scheduled. */ - Watchdog_Control Ticker; - /** This field indicates what type of timer this currently is. */ - Timer_Classes the_class; - /** This field is the timer service routine. */ - rtems_timer_service_routine_entry routine; - /** This field is the timer service routine user data. */ - void *user_data; - /** This field is the timer interval in ticks or seconds. */ - Watchdog_Interval initial; - /** This field is the timer start time point in ticks. */ - Watchdog_Interval start_time; - /** This field is the timer stop time point in ticks. */ - Watchdog_Interval stop_time; -} Timer_Control; - -/** - * @brief RTEMS Create Timer - * - * This routine implements the rtems_timer_create directive. The - * timer will have the name name. It returns the id of the - * created timer in ID. - * - * @param[in] name is the timer name - * @param[out] id is the pointer to timer id - * - * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful - */ -rtems_status_code rtems_timer_create( - rtems_name name, - rtems_id *id -); - -/** - * @brief RTEMS Timer Name to Id - * - * This routine implements the rtems_timer_ident directive. - * This directive returns the timer ID associated with name. - * If more than one timer is named name, then the timer - * to which the ID belongs is arbitrary. - * - * @param[in] name is the user defined message queue name - * @param[in] id is the pointer to timer id - * - * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful and - * id filled with the message queue id - */ -rtems_status_code rtems_timer_ident( - rtems_name name, - rtems_id *id -); - -/** - * @brief rtems_timer_cancel - * - * This routine implements the rtems_timer_cancel directive. It is used - * to stop the timer associated with ID from firing. - */ -rtems_status_code rtems_timer_cancel( - rtems_id id -); - -/** - * @brief RTEMS Delete Timer - * - * This routine implements the rtems_timer_delete directive. The - * timer indicated by ID is deleted. - * - * @param[in] id is the timer id - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - */ -rtems_status_code rtems_timer_delete( - rtems_id id -); - -/** - * @brief RTEMS Timer Fire After - * - * This routine implements the rtems_timer_fire_after directive. It - * initiates the timer associated with ID to fire in ticks clock ticks. - * When the timer fires, the routine will be invoked in the context - * of the rtems_clock_tick directive which is normally invoked as - * part of servicing a periodic interupt. - * - * @param[in] id is the timer id - * @param[in] ticks is the interval until routine is fired - * @param[in] routine is the routine to schedule - * @param[in] user_data is the passed as argument to routine when it is fired - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - */ -rtems_status_code rtems_timer_fire_after( - rtems_id id, - rtems_interval ticks, - rtems_timer_service_routine_entry routine, - void *user_data -); - -/** - * @brief RTEMS Timer Server Fire After - * - * This routine implements the rtems_timer_server_fire_after directive. It - * initiates the timer associated with ID to fire in ticks clock - * ticks. When the timer fires, the routine will be invoked by the - * Timer Server in the context of a task NOT IN THE CONTEXT of the - * clock tick interrupt. - * - * @param[in] id is the timer id - * @param[in] ticks is the interval until routine is fired - * @param[in] routine is the routine to schedule - * @param[in] user_data is the passed as argument to routine when it is fired - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - */ -rtems_status_code rtems_timer_server_fire_after( - rtems_id id, - rtems_interval ticks, - rtems_timer_service_routine_entry routine, - void *user_data -); - -/** - * @brief RTEMS Timer Fire When - * - * This routine implements the rtems_timer_fire_when directive. It - * initiates the timer associated with ID to fire at wall_time - * When the timer fires, the routine will be invoked in the context - * of the rtems_clock_tick directive which is normally invoked as - * part of servicing a periodic interupt. - * - * @param[in] id is the timer id - * @param[in] wall_time is the time of day to fire timer - * @param[in] routine is the routine to schedule - * @param[in] user_data is the passed as argument to routine when it is fired - * - * @retval This method returns RTEMS_SUCCESSFUL if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - */ -rtems_status_code rtems_timer_fire_when( - rtems_id id, - rtems_time_of_day *wall_time, - rtems_timer_service_routine_entry routine, - void *user_data -); - -/** - * @brief RTEMS Timer Server Fire When Directive - * - * Timer Manager - RTEMS Timer Server Fire When Directive - * - * This routine implements the rtems_timer_server_fire_when directive. It - * initiates the timer associated with ID to fire at wall_time - * When the timer fires, the routine will be invoked by the - * Timer Server in the context of a task NOT IN THE CONTEXT of the - * clock tick interrupt. - */ -rtems_status_code rtems_timer_server_fire_when( - rtems_id id, - rtems_time_of_day *wall_time, - rtems_timer_service_routine_entry routine, - void *user_data -); - -/** - * @brief RTEMS Timer Reset - * - * Timer Manager - RTEMS Timer Reset - * - * This routine implements the rtems_timer_reset directive. It is used - * to reinitialize the interval timer associated with ID just as if - * rtems_timer_fire_after were re-invoked with the same arguments that - * were used to initiate this timer. - */ -rtems_status_code rtems_timer_reset( - rtems_id id -); - -/** - * @brief Initiates the timer server. - * - * This directive creates and starts the server for task-based timers. - * It must be invoked before any task-based timers can be initiated. - * - * @param priority The timer server task priority. - * @param stack_size The stack size in bytes for the timer server task. - * @param attribute_set The timer server task attributes. - * - * @return This method returns RTEMS_SUCCESSFUL if successful and an - * error code otherwise. - */ -rtems_status_code rtems_timer_initiate_server( - rtems_task_priority priority, - size_t stack_size, - rtems_attribute attribute_set -); - -/** - * This is the default value for the priority of the Timer Server. - * When given this priority, a special high priority not accessible - * via the Classic API is used. - */ -#define RTEMS_TIMER_SERVER_DEFAULT_PRIORITY (uint32_t) -1 - -/** - * This is the structure filled in by the timer get information - * service. - */ -typedef struct { - /** This indicates the current type of the timer. */ - Timer_Classes the_class; - /** This indicates the initial requested interval. */ - Watchdog_Interval initial; - /** This indicates the time the timer was initially scheduled. */ - Watchdog_Interval start_time; - /** This indicates the time the timer is scheduled to fire. */ - Watchdog_Interval stop_time; -} rtems_timer_information; - -/** - * @brief RTEMS Get Timer Information - * - * This routine implements the rtems_timer_get_information directive. - * This directive returns information about the timer. - * - * @param[in] id is the timer id - * @param[in] the_info is the pointer to timer information block - * - * @retval RTEMS_SUCCESSFUL if successful or error code if unsuccessful and - * *the_info region information block filled in - */ -rtems_status_code rtems_timer_get_information( - rtems_id id, - rtems_timer_information *the_info -); - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/timerimpl.h b/cpukit/rtems/include/rtems/rtems/timerimpl.h deleted file mode 100644 index d8581bfcd8..0000000000 --- a/cpukit/rtems/include/rtems/rtems/timerimpl.h +++ /dev/null @@ -1,209 +0,0 @@ -/** - * @file - * - * @ingroup ClassicTimerImpl - * - * @brief Classic Timer Implementation - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * Copyright (c) 2016 embedded brains GmbH. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_TIMER_INL -#define _RTEMS_RTEMS_TIMER_INL - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicTimerImpl Classic Timer Implementation - * - * @ingroup ClassicTimer - * - * @{ - */ - -typedef struct Timer_server_Control { - ISR_LOCK_MEMBER( Lock ) - - Chain_Control Pending; - - Objects_Id server_id; -} Timer_server_Control; - -/** - * @brief Pointer to default timer server control block. - * - * This value is @c NULL when the default timer server is not initialized. - */ -extern Timer_server_Control *volatile _Timer_server; - -/** - * The following defines the information control block used to manage - * this class of objects. - */ -extern Objects_Information _Timer_Information; - -/** - * @brief Timer_Allocate - * - * This function allocates a timer control block from - * the inactive chain of free timer control blocks. - */ -RTEMS_INLINE_ROUTINE Timer_Control *_Timer_Allocate( void ) -{ - return (Timer_Control *) _Objects_Allocate( &_Timer_Information ); -} - -/** - * @brief Timer_Free - * - * This routine frees a timer control block to the - * inactive chain of free timer control blocks. - */ -RTEMS_INLINE_ROUTINE void _Timer_Free ( - Timer_Control *the_timer -) -{ - _Objects_Free( &_Timer_Information, &the_timer->Object ); -} - -RTEMS_INLINE_ROUTINE Timer_Control *_Timer_Get( - Objects_Id id, - ISR_lock_Context *lock_context -) -{ - return (Timer_Control *) _Objects_Get( - id, - lock_context, - &_Timer_Information - ); -} - -RTEMS_INLINE_ROUTINE Per_CPU_Control *_Timer_Acquire_critical( - Timer_Control *the_timer, - ISR_lock_Context *lock_context -) -{ - Per_CPU_Control *cpu; - - cpu = _Watchdog_Get_CPU( &the_timer->Ticker ); - _Watchdog_Per_CPU_acquire_critical( cpu, lock_context ); - - return cpu; -} - -RTEMS_INLINE_ROUTINE void _Timer_Release( - Per_CPU_Control *cpu, - ISR_lock_Context *lock_context -) -{ - _Watchdog_Per_CPU_release_critical( cpu, lock_context ); - _ISR_lock_ISR_enable( lock_context ); -} - -RTEMS_INLINE_ROUTINE bool _Timer_Is_interval_class( - Timer_Classes the_class -) -{ - Timer_Classes mask = - TIMER_CLASS_BIT_NOT_DORMANT | TIMER_CLASS_BIT_TIME_OF_DAY; - - return ( the_class & mask ) == TIMER_CLASS_BIT_NOT_DORMANT; -} - -RTEMS_INLINE_ROUTINE bool _Timer_Is_on_task_class( - Timer_Classes the_class -) -{ - Timer_Classes mask = - TIMER_CLASS_BIT_NOT_DORMANT | TIMER_CLASS_BIT_ON_TASK; - - return ( the_class & mask ) == mask; -} - -RTEMS_INLINE_ROUTINE Per_CPU_Watchdog_index _Timer_Watchdog_header_index( - Timer_Classes the_class -) -{ - return ( the_class & TIMER_CLASS_BIT_TIME_OF_DAY ); -} - -RTEMS_INLINE_ROUTINE Watchdog_Interval _Timer_Get_CPU_ticks( - const Per_CPU_Control *cpu -) -{ - return (Watchdog_Interval) cpu->Watchdog.ticks; -} - -rtems_status_code _Timer_Fire( - rtems_id id, - rtems_interval interval, - rtems_timer_service_routine_entry routine, - void *user_data, - Timer_Classes the_class, - Watchdog_Service_routine_entry adaptor -); - -rtems_status_code _Timer_Fire_after( - rtems_id id, - rtems_interval ticks, - rtems_timer_service_routine_entry routine, - void *user_data, - Timer_Classes the_class, - Watchdog_Service_routine_entry adaptor -); - -rtems_status_code _Timer_Fire_when( - rtems_id id, - const rtems_time_of_day *wall_time, - rtems_timer_service_routine_entry routine, - void *user_data, - Timer_Classes the_class, - Watchdog_Service_routine_entry adaptor -); - -void _Timer_Cancel( Per_CPU_Control *cpu, Timer_Control *the_timer ); - -void _Timer_Routine_adaptor( Watchdog_Control *the_watchdog ); - -void _Timer_server_Routine_adaptor( Watchdog_Control *the_watchdog ); - -RTEMS_INLINE_ROUTINE void _Timer_server_Acquire_critical( - Timer_server_Control *timer_server, - ISR_lock_Context *lock_context -) -{ - _ISR_lock_Acquire( &timer_server->Lock, lock_context ); -} - -RTEMS_INLINE_ROUTINE void _Timer_server_Release_critical( - Timer_server_Control *timer_server, - ISR_lock_Context *lock_context -) -{ - _ISR_lock_Release( &timer_server->Lock, lock_context ); -} - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/include/rtems/rtems/types.h b/cpukit/rtems/include/rtems/rtems/types.h deleted file mode 100644 index 82c0edd3c3..0000000000 --- a/cpukit/rtems/include/rtems/rtems/types.h +++ /dev/null @@ -1,235 +0,0 @@ -/** - * @file - * - * @defgroup ClassicTypes Types - * - * @ingroup ClassicRTEMS - * @brief Types used by Classic API. - */ - -/* COPYRIGHT (c) 1989-2009. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RTEMS_TYPES_H -#define _RTEMS_RTEMS_TYPES_H - -/* - * RTEMS basic type definitions - */ - -#include -#include -#include -#include -#include -#include -#if defined(RTEMS_MULTIPROCESSING) -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ClassicRTEMS - */ -/**@{**/ - -#ifdef RTEMS_DEPRECATED_TYPES -/** - * @brief Single precision float type. - * - * @deprecated Use @c float instead. - */ -typedef single_precision rtems_single; - -/** - * @brief Double precision float type. - * - * @deprecated Use @c double instead. - */ -typedef double_precision rtems_double; - -/** - * @brief RTEMS boolean type. - * - * @deprecated Use @c bool instead - */ -typedef boolean rtems_boolean; -#endif - -/** - * @brief Classic API @ref ClassicRTEMSSubSecObjectNames "object name" type. - * - * Contains the name of a Classic API object. It is an unsigned 32-bit integer - * which can be treated as a numeric value or initialized using - * rtems_build_name() to contain four ASCII characters. - */ -typedef uint32_t rtems_name; - -/** - * @brief Used to manage and manipulate - * @ref ClassicRTEMSSubSecObjectIdentifiers "RTEMS object identifiers". - */ -typedef Objects_Id rtems_id; - -/** - * @brief Invalid object identifier value. - * - * No object can have this identifier value. - */ -#define RTEMS_ID_NONE OBJECTS_ID_NONE - -/** - * @brief Public name for task context area. - */ -typedef Context_Control rtems_context; - -#if (CPU_HARDWARE_FP == TRUE) || (CPU_SOFTWARE_FP == TRUE) -/** - * @brief Public name for task floating point context area. - */ -typedef Context_Control_fp rtems_context_fp; -#endif - -#if (CPU_ISR_PASSES_FRAME_POINTER == TRUE) -/** - * @brief Defines the format of the interrupt stack frame as it appears to a - * user ISR. - * - * This data structure is only provided if the interrupt stack frame is passed - * to the ISR handler. - * - * @see rtems_interrupt_catch(). - */ -typedef CPU_Interrupt_frame rtems_interrupt_frame; -#endif - -/** - * @brief Information structure returned by the Heap Handler via the Region - * Manager. - */ -typedef Heap_Information_block region_information_block; - -/** - * @brief Used to manage and manipulate intervals specified by - * @ref ClassicRTEMSSecTime "clock ticks". - */ -typedef Watchdog_Interval rtems_interval; - -/** - * @brief Represents the CPU usage per thread. - * - * When using nanoseconds granularity timing, RTEMS may internally use a - * variety of representations. - */ -typedef struct timespec rtems_thread_cpu_usage_t; - -/** - * @brief Data structure to manage and manipulate calendar - * @ref ClassicRTEMSSecTime "time". - */ -typedef struct { - /** - * @brief Year, A.D. - */ - uint32_t year; - /** - * @brief Month, 1 .. 12. - */ - uint32_t month; - /** - * @brief Day, 1 .. 31. - */ - uint32_t day; - /** - * @brief Hour, 0 .. 23. - */ - uint32_t hour; - /** - * @brief Minute, 0 .. 59. - */ - uint32_t minute; - /** - * @brief Second, 0 .. 59. - */ - uint32_t second; - /** - * @brief Elapsed ticks between seconds. - */ - uint32_t ticks; -} rtems_time_of_day; - -/** - * @brief Task mode type. - */ -typedef Modes_Control rtems_mode; - -/* - * MPCI related entries - */ -#if defined(RTEMS_MULTIPROCESSING) -/** - * @brief Set of MPCI packet classes which are internally dispatched to the - * managers. - */ -typedef MP_packet_Classes rtems_mp_packet_classes; - -/** - * @brief Prefix found at the beginning of each MPCI packet sent between nodes. - */ -typedef MP_packet_Prefix rtems_packet_prefix; - -/** - * @brief Indirect pointer to the initialization entry point for an MPCI - * handler. - */ -typedef MPCI_initialization_entry rtems_mpci_initialization_entry; - -/** - * @brief Indirect pointer to the get_packet entry point for an MPCI handler. - */ -typedef MPCI_get_packet_entry rtems_mpci_get_packet_entry; - -/** - * @brief Indirect pointer to the return_packet entry point for an MPCI - * handler. - */ -typedef MPCI_return_packet_entry rtems_mpci_return_packet_entry; - -/** - * @brief Indirect pointer to the send_packet entry point for an MPCI handler. - */ -typedef MPCI_send_entry rtems_mpci_send_packet_entry; - -/** - * @brief Indirect pointer to the receive entry point for an MPCI handler. - */ -typedef MPCI_receive_entry rtems_mpci_receive_packet_entry; - -/** - * @brief Return type from every MPCI handler routine. - */ -typedef MPCI_Entry rtems_mpci_entry; - -/** - * @brief Structure which is used to configure an MPCI handler. - */ -typedef MPCI_Control rtems_mpci_table; - -#endif - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/rtems/mainpage.h b/cpukit/rtems/mainpage.h deleted file mode 100644 index e2d51328cf..0000000000 --- a/cpukit/rtems/mainpage.h +++ /dev/null @@ -1,927 +0,0 @@ -/** - * @file rtems/rtems/mainpage.h - * - * This file exists to provide a top level description of RTEMS for Doxygen. - */ - -/* - * COPYRIGHT (c) 1989-2014. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -/** - * @mainpage - * - * The RTEMS real-time operating systems is a layered system with each of the - * public APIs implemented in terms of a common foundation layer called the - * SuperCore. This is the Doxygen generated documentation for the RTEMS CPU - * Kit including the Classic API, POSIX API and SuperCore. - */ - -/** - * @page RTEMSPreface RTEMS History and Introduction - * - * In recent years, the cost required to develop a software product has - * increased significantly while the target hardware costs have decreased. Now - * a larger portion of money is expended in developing, using, and maintaining - * software. The trend in computing costs is the complete dominance of software - * over hardware costs. Because of this, it is necessary that formal - * disciplines be established to increase the probability that software is - * characterized by a high degree of correctness, maintainability, and - * portability. In addition, these disciplines must promote practices that aid - * in the consistent and orderly development of a software system within - * schedule and budgetary constraints. To be effective, these disciplines must - * adopt standards which channel individual software efforts toward a common - * goal. - * - * The push for standards in the software development field has been met with - * various degrees of success. The Microprocessor Operating Systems Interfaces - * (MOSI) effort has experienced only limited success. As popular as the UNIX - * operating system has grown, the attempt to develop a standard interface - * definition to allow portable application development has only recently begun - * to produce the results needed in this area. Unfortunately, very little - * effort has been expended to provide standards addressing the needs of the - * real-time community. Several organizations have addressed this need during - * recent years. - * - * The Real Time Executive Interface Definition (RTEID) was developed by - * Motorola with technical input from Software Components Group. RTEID was - * adopted by the VMEbus International Trade Association (VITA) as a baseline - * draft for their proposed standard multiprocessor, real-time executive - * interface, Open Real-Time Kernel Interface Definition (ORKID). These two - * groups are currently working together with the IEEE P1003.4 committee to - * insure that the functionality of their proposed standards is adopted as the - * real-time extensions to POSIX. - * - * This emerging standard defines an interface for the development of real-time - * software to ease the writing of real-time application programs that are - * directly portable across multiple real-time executive implementations. This - * interface includes both the source code interfaces and run-time behavior as - * seen by a real-time application. It does not include the details of how a - * kernel implements these functions. The standard's goal is to serve as a - * complete definition of external interfaces so that application code that - * conforms to these interfaces will execute properly in all real-time - * executive environments. With the use of a standards compliant executive, - * routines that acquire memory blocks, create and manage message queues, - * establish and use semaphores, and send and receive signals need not be - * redeveloped for a different real-time environment as long as the new - * environment is compliant with the standard. Software developers need only - * concentrate on the hardware dependencies of the real-time system. - * Furthermore, most hardware dependencies for real-time applications can be - * localized to the device drivers. - * - * A compliant executive provides simple and flexible real-time - * multiprocessing. It easily lends itself to both tightly-coupled and - * loosely-coupled configurations (depending on the system hardware - * configuration). Objects such as tasks, queues, events, signals, semaphores, - * and memory blocks can be designated as global objects and accessed by any - * task regardless of which processor the object and the accessing task reside. - * - * The acceptance of a standard for real-time executives will produce the same - * advantages enjoyed from the push for UNIX standardization by AT&T's System V - * Interface Definition and IEEE's POSIX efforts. A compliant multiprocessing - * executive will allow close coupling between UNIX systems and real-time - * executives to provide the many benefits of the UNIX development environment - * to be applied to real-time software development. Together they provide the - * necessary laboratory environment to implement real-time, distributed, - * embedded systems using a wide variety of computer architectures. - * - * A study was completed in 1988, within the Research, Development, and - * Engineering Center, U.S. Army Missile Command, which compared the various - * aspects of the Ada programming language as they related to the application - * of Ada code in distributed and/or multiple processing systems. Several - * critical conclusions were derived from the study. These conclusions have a - * major impact on the way the Army develops application software for embedded - * applications. These impacts apply to both in-house software development and - * contractor developed software. - * - * A conclusion of the analysis, which has been previously recognized by other - * agencies attempting to utilize Ada in a distributed or multiprocessing - * environment, is that the Ada programming language does not adequately - * support multiprocessing. Ada does provide a mechanism for multi-tasking, - * however, this capability exists only for a single processor system. The - * language also does not have inherent capabilities to access global named - * variables, flags or program code. These critical features are essential in - * order for data to be shared between processors. However, these drawbacks do - * have workarounds which are sometimes awkward and defeat the intent of - * software maintainability and portability goals. - * - * Another conclusion drawn from the analysis, was that the run time executives - * being delivered with the Ada compilers were too slow and inefficient to be - * used in modern missile systems. A run time executive is the core part of the - * run time system code, or operating system code, that controls task - * scheduling, input/output management and memory management. Traditionally, - * whenever efficient executive (also known as kernel) code was required by the - * application, the user developed in-house software. This software was usually - * written in assembly language for optimization. - * - * Because of this shortcoming in the Ada programming language, software - * developers in research and development and contractors for project managed - * systems, are mandated by technology to purchase and utilize off-the-shelf - * third party kernel code. The contractor, and eventually the Government, must - * pay a licensing fee for every copy of the kernel code used in an embedded - * system. - * - * The main drawback to this development environment is that the Government - * does not own, nor has the right to modify code contained within the kernel. - * V&V techniques in this situation are more difficult than if the complete - * source code were available. Responsibility for system failures due to faulty - * software is yet another area to be resolved under this environment. - * - * The Guidance and Control Directorate began a software development effort to - * address these problems. A project to develop an experimental run time kernel - * was begun that will eliminate the major drawbacks of the Ada programming - * language mentioned above. The Real Time Executive for Multiprocessor Systems - * (RTEMS) provides full capabilities for management of tasks, interrupts, - * time, and multiple processors in addition to those features typical of - * generic operating systems. The code is Government owned, so no licensing - * fees are necessary. RTEMS has been implemented in both the Ada and C - * programming languages. It has been ported to the following processor - * families: - * - * - Altera NIOS II - * - Analog Devices Blackfin - * - ARM - * - Freescale (formerly Motorola) MC68xxx - * - Freescale (formerly Motorola) MC683xx - * - Freescale (formerly Motorola) ColdFire - * - Intel i386 and above - * - Lattice Semiconductor LM32 - * - MIPS - * - PowerPC - * - Renesas (formerly Hitachi) SuperH - * - Renesas (formerly Hitachi) H8/300 - * - SPARC - * - Texas Instruments C3x/C4x - * - UNIX - * - * Support for other processor families, including RISC, CISC, and DSP, is - * planned. Since almost all of RTEMS is written in a high level language, - * ports to additional processor families require minimal effort. - * - * RTEMS multiprocessor support is capable of handling either homogeneous or - * heterogeneous systems. The kernel automatically compensates for - * architectural differences (byte swapping, etc.) between processors. This - * allows a much easier transition from one processor family to another without - * a major system redesign. - * - * Since the proposed standards are still in draft form, RTEMS cannot and does - * not claim compliance. However, the status of the standard is being carefully - * monitored to guarantee that RTEMS provides the functionality specified in - * the standard. Once approved, RTEMS will be made compliant. - */ - -/** - * @page RTEMSOverview RTEMS Overview - * - * @section RTEMSOverviewSecIntroduction Introduction - * - * RTEMS, Real-Time Executive for Multiprocessor Systems, is a real-time - * executive (kernel) which provides a high performance environment for - * embedded military applications including the following features: - * - * - multitasking capabilities - * - homogeneous and heterogeneous multiprocessor systems - * - event-driven, priority-based, preemptive scheduling - * - optional rate monotonic scheduling - * - intertask communication and synchronization - * - priority inheritance - * - responsive interrupt management - * - dynamic memory allocation - * - high level of user configurability - * - * This manual describes the usage of RTEMS for applications written in the C - * programming language. Those implementation details that are processor - * dependent are provided in the Applications Supplement documents. A - * supplement document which addresses specific architectural issues that - * affect RTEMS is provided for each processor type that is supported. - * - * @section RTEMSOverviewSecRealtimeApplicationSystems Real-time Application Systems - * - * Real-time application systems are a special class of computer applications. - * They have a complex set of characteristics that distinguish them from other - * software problems. Generally, they must adhere to more rigorous - * requirements. The correctness of the system depends not only on the results - * of computations, but also on the time at which the results are produced. The - * most important and complex characteristic of real-time application systems - * is that they must receive and respond to a set of external stimuli within - * rigid and critical time constraints referred to as deadlines. Systems can be - * buried by an avalanche of interdependent, asynchronous or cyclical event - * streams. - * - * Deadlines can be further characterized as either hard or soft based upon the - * value of the results when produced after the deadline has passed. A deadline - * is hard if the results have no value or if their use will result in a - * catastrophic event. In contrast, results which are produced after a soft - * deadline may have some value. - * - * Another distinguishing requirement of real-time application systems is the - * ability to coordinate or manage a large number of concurrent activities. - * Since software is a synchronous entity, this presents special problems. One - * instruction follows another in a repeating synchronous cycle. Even though - * mechanisms have been developed to allow for the processing of external - * asynchronous events, the software design efforts required to process and - * manage these events and tasks are growing more complicated. - * - * The design process is complicated further by spreading this activity over a - * set of processors instead of a single processor. The challenges associated - * with designing and building real-time application systems become very - * complex when multiple processors are involved. New requirements such as - * interprocessor communication channels and global resources that must be - * shared between competing processors are introduced. The ramifications of - * multiple processors complicate each and every characteristic of a real-time - * system. - * - * @section RTEMSOverviewSecRealtimeExecutive Real-time Executive - * - * Fortunately, real-time operating systems or real-time executives serve as a - * cornerstone on which to build the application system. A real-time - * multitasking executive allows an application to be cast into a set of - * logical, autonomous processes or tasks which become quite manageable. Each - * task is internally synchronous, but different tasks execute independently, - * resulting in an asynchronous processing stream. Tasks can be dynamically - * paused for many reasons resulting in a different task being allowed to - * execute for a period of time. The executive also provides an interface to - * other system components such as interrupt handlers and device drivers. - * System components may request the executive to allocate and coordinate - * resources, and to wait for and trigger synchronizing conditions. The - * executive system calls effectively extend the CPU instruction set to support - * efficient multitasking. By causing tasks to travel through well-defined - * state transitions, system calls permit an application to demand-switch - * between tasks in response to real-time events. - * - * By proper grouping of responses to stimuli into separate tasks, a system can - * now asynchronously switch between independent streams of execution, directly - * responding to external stimuli as they occur. This allows the system design - * to meet critical performance specifications which are typically measured by - * guaranteed response time and transaction throughput. The multiprocessor - * extensions of RTEMS provide the features necessary to manage the extra - * requirements introduced by a system distributed across several processors. - * It removes the physical barriers of processor boundaries from the world of - * the system designer, enabling more critical aspects of the system to receive - * the required attention. Such a system, based on an efficient real-time, - * multiprocessor executive, is a more realistic model of the outside world or - * environment for which it is designed. As a result, the system will always be - * more logical, efficient, and reliable. - * - * By using the directives provided by RTEMS, the real-time applications - * developer is freed from the problem of controlling and synchronizing - * multiple tasks and processors. In addition, one need not develop, test, - * debug, and document routines to manage memory, pass messages, or provide - * mutual exclusion. The developer is then able to concentrate solely on the - * application. By using standard software components, the time and cost - * required to develop sophisticated real-time applications is significantly - * reduced. - * - * @section RTEMSOverviewSecApplicationArchitecture RTEMS Application Architecture - * - * One important design goal of RTEMS was to provide a bridge between two - * critical layers of typical real-time systems. As shown in the following - * figure, RTEMS serves as a buffer between the project dependent application - * code and the target hardware. Most hardware dependencies for real-time - * applications can be localized to the low level device drivers. - * - * @todo Image RTEMS Application Architecture - * - * The RTEMS I/O interface manager provides an efficient tool for incorporating - * these hardware dependencies into the system while simultaneously providing a - * general mechanism to the application code that accesses them. A well - * designed real-time system can benefit from this architecture by building a - * rich library of standard application components which can be used repeatedly - * in other real-time projects. - * - * @section RTEMSOverviewSecInternalArchitecture RTEMS Internal Architecture - * - * RTEMS can be viewed as a set of layered components that work in harmony to - * provide a set of services to a real-time application system. The executive - * interface presented to the application is formed by grouping directives into - * logical sets called resource managers. Functions utilized by multiple - * managers such as scheduling, dispatching, and object management are provided - * in the executive core. The executive core depends on a small set of CPU - * dependent routines. Together these components provide a powerful run time - * environment that promotes the development of efficient real-time application - * systems. The following figure illustrates this organization: - * - * @todo Image RTEMS Architecture - * - * Subsequent chapters present a detailed description of the capabilities - * provided by each of the following RTEMS managers: - * - * - initialization - * - task - * - interrupt - * - clock - * - timer - * - semaphore - * - message - * - event - * - signal - * - partition - * - region - * - dual ported memory - * - I/O - * - fatal error - * - rate monotonic - * - user extensions - * - multiprocessing - * - * @section RTEMSOverviewSecUserCustomization User Customization and Extensibility - * - * As 32-bit microprocessors have decreased in cost, they have become - * increasingly common in a variety of embedded systems. A wide range of custom - * and general-purpose processor boards are based on various 32-bit - * processors. RTEMS was designed to make no assumptions concerning the - * characteristics of individual microprocessor families or of specific support - * hardware. In addition, RTEMS allows the system developer a high degree of - * freedom in customizing and extending its features. - * - * RTEMS assumes the existence of a supported microprocessor and sufficient - * memory for both RTEMS and the real-time application. Board dependent - * components such as clocks, interrupt controllers, or I/O devices can be - * easily integrated with RTEMS. The customization and extensibility features - * allow RTEMS to efficiently support as many environments as possible. - * - * @section RTEMSOverviewSecPortability Portability - * - * The issue of portability was the major factor in the creation of RTEMS. - * Since RTEMS is designed to isolate the hardware dependencies in the specific - * board support packages, the real-time application should be easily ported to - * any other processor. The use of RTEMS allows the development of real-time - * applications which can be completely independent of a particular - * microprocessor architecture. - * - * @section RTEMSOverviewSecMemoryRequirements Memory Requirements - * - * Since memory is a critical resource in many real-time embedded systems, - * RTEMS was specifically designed to automatically leave out all services that - * are not required from the run-time environment. Features such as networking, - * various fileystems, and many other features are completely optional. This - * allows the application designer the flexibility to tailor RTEMS to most - * efficiently meet system requirements while still satisfying even the most - * stringent memory constraints. As a result, the size of the RTEMS executive - * is application dependent. - * - * RTEMS requires RAM to manage each instance of an RTEMS object that is - * created. Thus the more RTEMS objects an application needs, the more memory - * that must be reserved. See Configuring a System Determining Memory - * Requirements for more details. - * - * @todo Link to Configuring a SystemDetermining Memory Requirements - * - * RTEMS utilizes memory for both code and data space. Although RTEMS' data - * space must be in RAM, its code space can be located in either ROM or RAM. - * - * @section RTEMSOverviewSecAudience Audience - * - * This manual was written for experienced real-time software developers. - * Although some background is provided, it is assumed that the reader is - * familiar with the concepts of task management as well as intertask - * communication and synchronization. Since directives, user related data - * structures, and examples are presented in C, a basic understanding of the C - * programming language is required to fully understand the material presented. - * However, because of the similarity of the Ada and C RTEMS implementations, - * users will find that the use and behavior of the two implementations is very - * similar. A working knowledge of the target processor is helpful in - * understanding some of RTEMS' features. A thorough understanding of the - * executive cannot be obtained without studying the entire manual because many - * of RTEMS' concepts and features are interrelated. Experienced RTEMS users - * will find that the manual organization facilitates its use as a reference - * document. - */ - -/** - * @addtogroup ClassicAPI - * - * The facilities provided by RTEMS are built upon a foundation of very - * powerful concepts. These concepts must be understood before the application - * developer can efficiently utilize RTEMS. The purpose of this chapter is to - * familiarize one with these concepts. - * - * @section ClassicRTEMSSecObjects Objects - * - * RTEMS provides directives which can be used to dynamically create, delete, - * and manipulate a set of predefined object types. These types include tasks, - * message queues, semaphores, memory regions, memory partitions, timers, - * ports, and rate monotonic periods. The object-oriented nature of RTEMS - * encourages the creation of modular applications built upon re-usable - * "building block" routines. - * - * All objects are created on the local node as required by the application and - * have an RTEMS assigned ID. All objects have a user-assigned name. Although a - * relationship exists between an object's name and its RTEMS assigned ID, the - * name and ID are not identical. Object names are completely arbitrary and - * selected by the user as a meaningful "tag" which may commonly reflect the - * object's use in the application. Conversely, object IDs are designed to - * facilitate efficient object manipulation by the executive. - * - * @subsection ClassicRTEMSSubSecObjectNames Object Names - * - * An object name is an unsigned 32-bit entity associated with the - * object by the user. The data type @ref rtems_name is used to store object names. - * - * Although not required by RTEMS, object names are often composed of four - * ASCII characters which help identify that object. For example, a task which - * causes a light to blink might be called "LITE". The rtems_build_name() - * routine is provided to build an object name from four ASCII characters. The - * following example illustrates this: - * - * @code - * rtems_name my_name = rtems_build_name('L', 'I', 'T', 'E'); - * @endcode - * - * However, it is not required that the application use ASCII characters to - * build object names. For example, if an application requires one-hundred - * tasks, it would be difficult to assign meaningful ASCII names to each task. - * A more convenient approach would be to name them the binary values one - * through one-hundred, respectively. - * - * RTEMS provides a helper routine, rtems_object_get_name(), which can be used to - * obtain the name of any RTEMS object using just its ID. This routine attempts - * to convert the name into a printable string. - * - * @subsection ClassicRTEMSSubSecObjectIdentifiers Object Identifiers - * - * An object ID is a unique unsigned integer value which uniquely identifies an - * object instance. Object IDs are passed as arguments to many directives in - * RTEMS and RTEMS translates the ID to an internal object pointer. The - * efficient manipulation of object IDs is critical to the performance of RTEMS - * services. Because of this, there are two object ID formats defined. Each - * target architecture specifies which format it will use. There is a 32-bit - * format which is used for most of the supported architectures and supports - * multiprocessor configurations. There is also a simpler 16-bit format which - * is appropriate for smaller target architectures and does not support - * multiprocessor configurations. - * - * @subsubsection ClassicRTEMSSubSec32BitObjectIdentifierFormat 32-Bit Object Identifier Format - * - * The 32-bit format for an object ID is composed of four parts: API, - * object class, node, and index. The data type @ref rtems_id is used to store - * object IDs. - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Bits3130292827262524232221201918171615141312111009080706050403020100
ContentsClassAPINodeObject Index
- * - * The most significant five bits are the object class. The next three bits - * indicate the API to which the object class belongs. The next eight bits - * (16 .. 23) are the number of the node on which this object was created. The - * node number is always one (1) in a single processor system. The least - * significant 16-bits form an identifier within a particular object type. - * This identifier, called the object index, ranges in value from one to the - * maximum number of objects configured for this object type. - * - * @subsubsection ClassicRTEMSSubSec16BitObjectIdentifierFormat 16-Bit Object Identifier Format - * - * The 16-bit format for an object ID is composed of three parts: API, object - * class, and index. The data type @ref rtems_id is used to store object IDs. - * - * - * - * - * - * - * - * - * - * - * - *
Bits15141312111009080706050403020100
ContentsClassAPIObject Index
- * - * The 16-bit format is designed to be as similar as possible to the 32-bit - * format. The differences are limited to the eliminatation of the node field - * and reduction of the index field from 16-bits to 8-bits. Thus the 16-bit - * format only supports up to 255 object instances per API/Class combination - * and single processor systems. As this format is typically utilized by 16-bit - * processors with limited address space, this is more than enough object - * instances. - * - * @subsection ClassicRTEMSSubSecObjectIdentiferDescription Object Identifer Description - * - * The components of an object ID make it possible to quickly locate any object - * in even the most complicated multiprocessor system. Object ID's are - * associated with an object by RTEMS when the object is created and the - * corresponding ID is returned by the appropriate object create directive. The - * object ID is required as input to all directives involving objects, except - * those which create an object or obtain the ID of an object. - * - * The object identification directives can be used to dynamically obtain a - * particular object's ID given its name. This mapping is accomplished by - * searching the name table associated with this object type. If the name is - * non-unique, then the ID associated with the first occurrence of the name - * will be returned to the application. Since object IDs are returned when the - * object is created, the object identification directives are not necessary in - * a properly designed single processor application. - * - * In addition, services are provided to portably examine the subcomponents of - * an RTEMS ID. These services are described in detail later in this manual but - * are prototyped as follows: - * - * - rtems_object_id_get_api() - * - rtems_object_id_get_class() - * - rtems_object_id_get_node() - * - rtems_object_id_get_index() - * - * An object control block is a data structure defined by RTEMS which contains - * the information necessary to manage a particular object type. For efficiency - * reasons, the format of each object type's control block is different. - * However, many of the fields are similar in function. The number of each type - * of control block is application dependent and determined by the values - * specified in the user's Configuration Table. An object control block is - * allocated at object create time and freed when the object is deleted. With - * the exception of user extension routines, object control blocks are not - * directly manipulated by user applications. - * - * @section ClassicRTEMSSecComSync Communication and Synchronization - * - * In real-time multitasking applications, the ability for cooperating - * execution threads to communicate and synchronize with each other is - * imperative. A real-time executive should provide an application with the - * following capabilities - * - * - data transfer between cooperating tasks, - * - data transfer between tasks and ISRs, - * - synchronization of cooperating tasks, and - * - synchronization of tasks and ISRs. - * - * Most RTEMS managers can be used to provide some form of communication and/or - * synchronization. However, managers dedicated specifically to communication - * and synchronization provide well established mechanisms which directly map - * to the application's varying needs. This level of flexibility allows the - * application designer to match the features of a particular manager with the - * complexity of communication and synchronization required. The following - * managers were specifically designed for communication and synchronization: - * - * - @ref ClassicSem - * - @ref ClassicMessageQueue - * - @ref ClassicEvent - * - @ref ClassicSignal - * - * The semaphore manager supports mutual exclusion involving the - * synchronization of access to one or more shared user resources. Binary - * semaphores may utilize the optional priority inheritance algorithm to avoid - * the problem of priority inversion. The message manager supports both - * communication and synchronization, while the event manager primarily - * provides a high performance synchronization mechanism. The signal manager - * supports only asynchronous communication and is typically used for exception - * handling. - * - * @section ClassicRTEMSSecTime Time - * - * The development of responsive real-time applications requires an - * understanding of how RTEMS maintains and supports time-related operations. - * The basic unit of time in RTEMS is known as a tick. The frequency of clock - * ticks is completely application dependent and determines the granularity and - * accuracy of all interval and calendar time operations. - * - * By tracking time in units of ticks, RTEMS is capable of supporting interval - * timing functions such as task delays, timeouts, timeslicing, the delayed - * execution of timer service routines, and the rate monotonic scheduling of - * tasks. An interval is defined as a number of ticks relative to the current - * time. For example, when a task delays for an interval of ten ticks, it is - * implied that the task will not execute until ten clock ticks have occurred. - * All intervals are specified using data type @ref rtems_interval. - * - * A characteristic of interval timing is that the actual interval period may - * be a fraction of a tick less than the interval requested. This occurs - * because the time at which the delay timer is set up occurs at some time - * between two clock ticks. Therefore, the first countdown tick occurs in less - * than the complete time interval for a tick. This can be a problem if the - * clock granularity is large. - * - * The rate monotonic scheduling algorithm is a hard real-time scheduling - * methodology. This methodology provides rules which allows one to guarantee - * that a set of independent periodic tasks will always meet their deadlines -- - * even under transient overload conditions. The rate monotonic manager - * provides directives built upon the Clock Manager's interval timer support - * routines. - * - * Interval timing is not sufficient for the many applications which require - * that time be kept in wall time or true calendar form. Consequently, RTEMS - * maintains the current date and time. This allows selected time operations to - * be scheduled at an actual calendar date and time. For example, a task could - * request to delay until midnight on New Year's Eve before lowering the ball - * at Times Square. The data type @ref rtems_time_of_day is used to specify - * calendar time in RTEMS services. See Clock Manager Time and Date Data - * Structures. - * - * @todo Link to Clock Manager Time and Date Data Structures - * - * Obviously, the directives which use intervals or wall time cannot operate - * without some external mechanism which provides a periodic clock tick. This - * clock tick is typically provided by a real time clock or counter/timer - * device. - * - * @section ClassicRTEMSSecMemoryManagement Memory Management - * - * RTEMS memory management facilities can be grouped into two classes: dynamic - * memory allocation and address translation. Dynamic memory allocation is - * required by applications whose memory requirements vary through the - * application's course of execution. Address translation is needed by - * applications which share memory with another CPU or an intelligent - * Input/Output processor. The following RTEMS managers provide facilities to - * manage memory: - * - * - @ref ClassicRegion - * - @ref ClassicPart - * - @ref ClassicDPMEM - * - * RTEMS memory management features allow an application to create simple - * memory pools of fixed size buffers and/or more complex memory pools of - * variable size segments. The partition manager provides directives to manage - * and maintain pools of fixed size entities such as resource control blocks. - * Alternatively, the region manager provides a more general purpose memory - * allocation scheme that supports variable size blocks of memory which are - * dynamically obtained and freed by the application. The dual-ported memory - * manager provides executive support for address translation between internal - * and external dual-ported RAM address space. - */ - -/** - * @addtogroup ClassicTasks - * - * @section ClassicTasksSecTaskDefinition Task Definition - * - * Many definitions of a task have been proposed in computer literature. - * Unfortunately, none of these definitions encompasses all facets of the - * concept in a manner which is operating system independent. Several of the - * more common definitions are provided to enable each user to select a - * definition which best matches their own experience and understanding of the - * task concept: - * - * - a "dispatchable" unit. - * - an entity to which the processor is allocated. - * - an atomic unit of a real-time, multiprocessor system. - * - single threads of execution which concurrently compete for resources. - * - a sequence of closely related computations which can execute concurrently - * with other computational sequences. - * - * From RTEMS' perspective, a task is the smallest thread of execution which - * can compete on its own for system resources. A task is manifested by the - * existence of a task control block (TCB). - * - * @section ClassicTasksSecTaskControlBlock Task Control Block - * - * The Task Control Block (TCB) is an RTEMS defined data structure which - * contains all the information that is pertinent to the execution of a task. - * During system initialization, RTEMS reserves a TCB for each task configured. - * A TCB is allocated upon creation of the task and is returned to the TCB free - * list upon deletion of the task. - * - * The TCB's elements are modified as a result of system calls made by the - * application in response to external and internal stimuli. TCBs are the only - * RTEMS internal data structure that can be accessed by an application via - * user extension routines. The TCB contains a task's name, ID, current - * priority, current and starting states, execution mode, TCB user extension - * pointer, scheduling control structures, as well as data required by a - * blocked task. - * - * A task's context is stored in the TCB when a task switch occurs. When the - * task regains control of the processor, its context is restored from the TCB. - * When a task is restarted, the initial state of the task is restored from the - * starting context area in the task's TCB. - * - * @section ClassicTasksSecTaskStates Task States - * - * A task may exist in one of the following five states: - * - * - executing - Currently scheduled to the CPU - * - ready - May be scheduled to the CPU - * - blocked - Unable to be scheduled to the CPU - * - dormant - Created task that is not started - * - non-existent - Uncreated or deleted task - * - * An active task may occupy the executing, ready, blocked or dormant state, - * otherwise the task is considered non-existent. One or more tasks may be - * active in the system simultaneously. Multiple tasks communicate, - * synchronize, and compete for system resources with each other via system - * calls. The multiple tasks appear to execute in parallel, but actually each - * is dispatched to the CPU for periods of time determined by the RTEMS - * scheduling algorithm. The scheduling of a task is based on its current state - * and priority. - * - * @section ClassicTasksSecTaskPriority Task Priority - * - * A task's priority determines its importance in relation to the other tasks - * executing on the same processor. RTEMS supports 255 levels of priority - * ranging from 1 to 255. The data type rtems_task_priority() is used to store - * task priorities. - * - * Tasks of numerically smaller priority values are more important tasks than - * tasks of numerically larger priority values. For example, a task at priority - * level 5 is of higher privilege than a task at priority level 10. There is no - * limit to the number of tasks assigned to the same priority. - * - * Each task has a priority associated with it at all times. The initial value - * of this priority is assigned at task creation time. The priority of a task - * may be changed at any subsequent time. - * - * Priorities are used by the scheduler to determine which ready task will be - * allowed to execute. In general, the higher the logical priority of a task, - * the more likely it is to receive processor execution time. - * - * @section ClassicTasksSecTaskMode Task Mode - * - * A task's execution mode is a combination of the following four components: - * - * - preemption - * - ASR processing - * - timeslicing - * - interrupt level - * - * It is used to modify RTEMS' scheduling process and to alter the execution - * environment of the task. The data type rtems_task_mode() is used to manage - * the task execution mode. - * - * The preemption component allows a task to determine when control of the - * processor is relinquished. If preemption is disabled (@c - * RTEMS_NO_PREEMPT), the task will retain control of the - * processor as long as it is in the executing state -- even if a higher - * priority task is made ready. If preemption is enabled (@c RTEMS_PREEMPT) - * and a higher priority task is made ready, then the processor will be - * taken away from the current task immediately and given to the higher - * priority task. - * - * The timeslicing component is used by the RTEMS scheduler to determine how - * the processor is allocated to tasks of equal priority. If timeslicing is - * enabled (@c RTEMS_TIMESLICE), then RTEMS will limit the amount of time the - * task can execute before the processor is allocated to another ready task of - * equal priority. The length of the timeslice is application dependent and - * specified in the Configuration Table. If timeslicing is disabled (@c - * RTEMS_NO_TIMESLICE), then the task will be allowed to - * execute until a task of higher priority is made ready. If @c - * RTEMS_NO_PREEMPT is selected, then the timeslicing component is ignored by - * the scheduler. - * - * The asynchronous signal processing component is used to determine when - * received signals are to be processed by the task. If signal processing is - * enabled (@c RTEMS_ASR), then signals sent to the task will be processed - * the next time the task executes. If signal processing is disabled (@c - * RTEMS_NO_ASR), then all signals received by the task will - * remain posted until signal processing is enabled. This component affects - * only tasks which have established a routine to process asynchronous signals. - * - * The interrupt level component is used to determine which interrupts will be - * enabled when the task is executing. @c RTEMS_INTERRUPT_LEVEL(n) specifies - * that the task will execute at interrupt level n. - * - * - @ref RTEMS_PREEMPT - enable preemption (default) - * - @ref RTEMS_NO_PREEMPT - disable preemption - * - @ref RTEMS_NO_TIMESLICE - disable timeslicing (default) - * - @ref RTEMS_TIMESLICE - enable timeslicing - * - @ref RTEMS_ASR - enable ASR processing (default) - * - @ref RTEMS_NO_ASR - disable ASR processing - * - @ref RTEMS_INTERRUPT_LEVEL(0) - enable all interrupts (default) - * - @ref RTEMS_INTERRUPT_LEVEL(n) - execute at interrupt level n - * - * The set of default modes may be selected by specifying the @ref - * RTEMS_DEFAULT_MODES constant. - * - * @section ClassicTasksSecAccessingTaskArguments Accessing Task Arguments - * - * All RTEMS tasks are invoked with a single argument which is specified when - * they are started or restarted. The argument is commonly used to communicate - * startup information to the task. The simplest manner in which to define a - * task which accesses it argument is: - * - * @code - * rtems_task user_task( - * rtems_task_argument argument - * ); - * @endcode - * - * Application tasks requiring more information may view this single argument - * as an index into an array of parameter blocks. - * - * @section ClassicTasksSecFloatingPointConsiderations Floating Point Considerations - * - * Creating a task with the @ref RTEMS_FLOATING_POINT attribute flag results in - * additional memory being allocated for the TCB to store the state of the - * numeric coprocessor during task switches. This additional memory is NOT - * allocated for @ref RTEMS_NO_FLOATING_POINT tasks. Saving and restoring the - * context of a @c RTEMS_FLOATING_POINT task takes longer than that of a @c - * RTEMS_NO_FLOATING_POINT task because of the relatively large amount of time - * required for the numeric coprocessor to save or restore its computational - * state. - * - * Since RTEMS was designed specifically for embedded military applications - * which are floating point intensive, the executive is optimized to avoid - * unnecessarily saving and restoring the state of the numeric coprocessor. The - * state of the numeric coprocessor is only saved when a @c - * RTEMS_FLOATING_POINT task is dispatched and that task was not the last task - * to utilize the coprocessor. In a system with only one @c - * RTEMS_FLOATING_POINT task, the state of the numeric coprocessor will never - * be saved or restored. - * - * Although the overhead imposed by @c RTEMS_FLOATING_POINT tasks is minimal, - * some applications may wish to completely avoid the overhead associated with - * @c RTEMS_FLOATING_POINT tasks and still utilize a numeric coprocessor. By - * preventing a task from being preempted while performing a sequence of - * floating point operations, a @c RTEMS_NO_FLOATING_POINT task can utilize - * the numeric coprocessor without incurring the overhead of a @c - * RTEMS_FLOATING_POINT context switch. This approach also avoids the - * allocation of a floating point context area. However, if this approach is - * taken by the application designer, NO tasks should be created as @c - * RTEMS_FLOATING_POINT tasks. Otherwise, the floating point context will not - * be correctly maintained because RTEMS assumes that the state of the numeric - * coprocessor will not be altered by @c RTEMS_NO_FLOATING_POINT tasks. - * - * If the supported processor type does not have hardware floating capabilities - * or a standard numeric coprocessor, RTEMS will not provide built-in support - * for hardware floating point on that processor. In this case, all tasks are - * considered @c RTEMS_NO_FLOATING_POINT whether created as @c - * RTEMS_FLOATING_POINT or @c RTEMS_NO_FLOATING_POINT tasks. A floating point - * emulation software library must be utilized for floating point operations. - * - * On some processors, it is possible to disable the floating point unit - * dynamically. If this capability is supported by the target processor, then - * RTEMS will utilize this capability to enable the floating point unit only - * for tasks which are created with the @c RTEMS_FLOATING_POINT attribute. - * The consequence of a @c RTEMS_NO_FLOATING_POINT task attempting to access - * the floating point unit is CPU dependent but will generally result in an - * exception condition. - * - * @section ClassicTasksSecPerTaskVariables Per Task Variables - * - * Per task variables are no longer available. In particular the - * rtems_task_variable_add(), rtems_task_variable_get() and - * rtems_task_variable_delete() functions are neither declared nor defined - * anymore. Use thread local storage or POSIX Keys instead. - * - * @section ClassicTasksSecBuildingTaskAttributeSet Building a Task Attribute Set - * - * In general, an attribute set is built by a bitwise OR of the desired - * components. The set of valid task attribute components is listed below: - * - * - @ref RTEMS_NO_FLOATING_POINT - does not use coprocessor (default) - * - @ref RTEMS_FLOATING_POINT - uses numeric coprocessor - * - @ref RTEMS_LOCAL - local task (default) - * - @ref RTEMS_GLOBAL - global task - * - * Attribute values are specifically designed to be mutually exclusive, - * therefore bitwise OR and addition operations are equivalent as long as each - * attribute appears exactly once in the component list. A component listed as - * a default is not required to appear in the component list, although it is a - * good programming practice to specify default components. If all defaults are - * desired, then @ref RTEMS_DEFAULT_ATTRIBUTES should be used. This example - * demonstrates the attribute_set parameter needed to create a local task which - * utilizes the numeric coprocessor. The attribute_set parameter could be @c - * RTEMS_FLOATING_POINT or @c RTEMS_LOCAL | @c RTEMS_FLOATING_POINT. The - * attribute_set parameter can be set to @c RTEMS_FLOATING_POINT because @c - * RTEMS_LOCAL is the default for all created tasks. If the task were global - * and used the numeric coprocessor, then the attribute_set parameter would be - * @c RTEMS_GLOBAL | @c RTEMS_FLOATING_POINT. - * - * @section ClassicTasksSecBuildingModeAndMask Building a Mode and Mask - * - * In general, a mode and its corresponding mask is built by a bitwise OR of - * the desired components. The set of valid mode constants and each mode's - * corresponding mask constant is listed below: - * - * - * - * - * - * - * - * - * - * - * - *
Mode ConstantMask ConstantDescription
@ref RTEMS_PREEMPT@ref RTEMS_PREEMPT_MASKenables preemption
@ref RTEMS_NO_PREEMPT@ref RTEMS_PREEMPT_MASKdisables preemption
@ref RTEMS_NO_TIMESLICE@ref RTEMS_TIMESLICE_MASKdisables timeslicing
@ref RTEMS_TIMESLICE@ref RTEMS_TIMESLICE_MASKenables timeslicing
@ref RTEMS_ASR@ref RTEMS_ASR_MASKenables ASR processing
@ref RTEMS_NO_ASR@ref RTEMS_ASR_MASKdisables ASR processing
@ref RTEMS_INTERRUPT_LEVEL(0)@ref RTEMS_INTERRUPT_MASKenables all interrupts
@ref RTEMS_INTERRUPT_LEVEL(n)@ref RTEMS_INTERRUPT_MASKsets interrupts level n
- * - * Mode values are specifically designed to be mutually exclusive, therefore - * bitwise OR and addition operations are equivalent as long as each mode - * appears exactly once in the component list. A mode component listed as a - * default is not required to appear in the mode component list, although it is - * a good programming practice to specify default components. If all defaults - * are desired, the mode @ref RTEMS_DEFAULT_MODES and the mask @ref - * RTEMS_ALL_MODE_MASKS should be used. - * - * The following example demonstrates the mode and mask parameters used with - * the rtems_task_mode() directive to place a task at interrupt level 3 and - * make it non-preemptible. The mode should be set to @c - * RTEMS_INTERRUPT_LEVEL(3) | @c RTEMS_NO_PREEMPT to indicate the desired - * preemption mode and interrupt level, while the mask parameter should be set - * to @c RTEMS_INTERRUPT_MASK | @c RTEMS_PREEMPT_MASK to indicate that - * the calling task's interrupt level and preemption mode are being altered. - */ - - /** - * @defgroup LocalPackages Local Packages - * - * @brief Local packages. - */ diff --git a/cpukit/rtems/preinstall.am b/cpukit/rtems/preinstall.am deleted file mode 100644 index 35e78db889..0000000000 --- a/cpukit/rtems/preinstall.am +++ /dev/null @@ -1,222 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -$(PROJECT_INCLUDE)/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE) - @: > $(PROJECT_INCLUDE)/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems.h: include/rtems.h $(PROJECT_INCLUDE)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems.h - -$(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/rtems - @: > $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/rtems/asr.h: include/rtems/rtems/asr.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/asr.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/asr.h - -$(PROJECT_INCLUDE)/rtems/rtems/asrimpl.h: include/rtems/rtems/asrimpl.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/asrimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/asrimpl.h - -$(PROJECT_INCLUDE)/rtems/rtems/attr.h: include/rtems/rtems/attr.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/attr.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/attr.h - -$(PROJECT_INCLUDE)/rtems/rtems/attrimpl.h: include/rtems/rtems/attrimpl.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/attrimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/attrimpl.h - -$(PROJECT_INCLUDE)/rtems/rtems/barrier.h: include/rtems/rtems/barrier.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/barrier.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/barrier.h - -$(PROJECT_INCLUDE)/rtems/rtems/barrierimpl.h: include/rtems/rtems/barrierimpl.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/barrierimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/barrierimpl.h - -$(PROJECT_INCLUDE)/rtems/rtems/cache.h: include/rtems/rtems/cache.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/cache.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/cache.h - -$(PROJECT_INCLUDE)/rtems/rtems/clock.h: include/rtems/rtems/clock.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/clock.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/clock.h - -$(PROJECT_INCLUDE)/rtems/rtems/config.h: include/rtems/rtems/config.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/config.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/config.h - -$(PROJECT_INCLUDE)/rtems/rtems/dpmem.h: include/rtems/rtems/dpmem.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/dpmem.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/dpmem.h - -$(PROJECT_INCLUDE)/rtems/rtems/dpmemimpl.h: include/rtems/rtems/dpmemimpl.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/dpmemimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/dpmemimpl.h - -$(PROJECT_INCLUDE)/rtems/rtems/event.h: include/rtems/rtems/event.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/event.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/event.h - -$(PROJECT_INCLUDE)/rtems/rtems/eventimpl.h: include/rtems/rtems/eventimpl.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/eventimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/eventimpl.h - -$(PROJECT_INCLUDE)/rtems/rtems/intr.h: include/rtems/rtems/intr.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/intr.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/intr.h - -$(PROJECT_INCLUDE)/rtems/rtems/message.h: include/rtems/rtems/message.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/message.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/message.h - -$(PROJECT_INCLUDE)/rtems/rtems/messageimpl.h: include/rtems/rtems/messageimpl.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/messageimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/messageimpl.h - -$(PROJECT_INCLUDE)/rtems/rtems/modes.h: include/rtems/rtems/modes.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/modes.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/modes.h - -$(PROJECT_INCLUDE)/rtems/rtems/modesimpl.h: include/rtems/rtems/modesimpl.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/modesimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/modesimpl.h - -$(PROJECT_INCLUDE)/rtems/rtems/object.h: include/rtems/rtems/object.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/object.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/object.h - -$(PROJECT_INCLUDE)/rtems/rtems/options.h: include/rtems/rtems/options.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/options.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/options.h - -$(PROJECT_INCLUDE)/rtems/rtems/optionsimpl.h: include/rtems/rtems/optionsimpl.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/optionsimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/optionsimpl.h - -$(PROJECT_INCLUDE)/rtems/rtems/part.h: include/rtems/rtems/part.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/part.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/part.h - -$(PROJECT_INCLUDE)/rtems/rtems/partimpl.h: include/rtems/rtems/partimpl.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/partimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/partimpl.h - -$(PROJECT_INCLUDE)/rtems/rtems/ratemon.h: include/rtems/rtems/ratemon.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/ratemon.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/ratemon.h - -$(PROJECT_INCLUDE)/rtems/rtems/ratemonimpl.h: include/rtems/rtems/ratemonimpl.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/ratemonimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/ratemonimpl.h - -$(PROJECT_INCLUDE)/rtems/rtems/region.h: include/rtems/rtems/region.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/region.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/region.h - -$(PROJECT_INCLUDE)/rtems/rtems/regionimpl.h: include/rtems/rtems/regionimpl.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/regionimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/regionimpl.h - -$(PROJECT_INCLUDE)/rtems/rtems/sem.h: include/rtems/rtems/sem.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/sem.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/sem.h - -$(PROJECT_INCLUDE)/rtems/rtems/semimpl.h: include/rtems/rtems/semimpl.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/semimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/semimpl.h - -$(PROJECT_INCLUDE)/rtems/rtems/signal.h: include/rtems/rtems/signal.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/signal.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/signal.h - -$(PROJECT_INCLUDE)/rtems/rtems/signalimpl.h: include/rtems/rtems/signalimpl.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/signalimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/signalimpl.h - -$(PROJECT_INCLUDE)/rtems/rtems/smp.h: include/rtems/rtems/smp.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/smp.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/smp.h - -$(PROJECT_INCLUDE)/rtems/rtems/status.h: include/rtems/rtems/status.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/status.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/status.h - -$(PROJECT_INCLUDE)/rtems/rtems/statusimpl.h: include/rtems/rtems/statusimpl.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/statusimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/statusimpl.h - -$(PROJECT_INCLUDE)/rtems/rtems/support.h: include/rtems/rtems/support.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/support.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/support.h - -$(PROJECT_INCLUDE)/rtems/rtems/tasks.h: include/rtems/rtems/tasks.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/tasks.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/tasks.h - -$(PROJECT_INCLUDE)/rtems/rtems/tasksimpl.h: include/rtems/rtems/tasksimpl.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/tasksimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/tasksimpl.h - -$(PROJECT_INCLUDE)/rtems/rtems/timer.h: include/rtems/rtems/timer.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/timer.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/timer.h - -$(PROJECT_INCLUDE)/rtems/rtems/timerimpl.h: include/rtems/rtems/timerimpl.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/timerimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/timerimpl.h - -$(PROJECT_INCLUDE)/rtems/rtems/types.h: include/rtems/rtems/types.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/types.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/types.h - -$(PROJECT_INCLUDE)/rtems/rtems/mainpage.h: mainpage.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/mainpage.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/mainpage.h - -if HAS_MP -$(PROJECT_INCLUDE)/rtems/rtems/eventmp.h: include/rtems/rtems/eventmp.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/eventmp.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/eventmp.h - -$(PROJECT_INCLUDE)/rtems/rtems/mp.h: include/rtems/rtems/mp.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/mp.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/mp.h - -$(PROJECT_INCLUDE)/rtems/rtems/msgmp.h: include/rtems/rtems/msgmp.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/msgmp.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/msgmp.h - -$(PROJECT_INCLUDE)/rtems/rtems/partmp.h: include/rtems/rtems/partmp.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/partmp.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/partmp.h - -$(PROJECT_INCLUDE)/rtems/rtems/semmp.h: include/rtems/rtems/semmp.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/semmp.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/semmp.h - -$(PROJECT_INCLUDE)/rtems/rtems/signalmp.h: include/rtems/rtems/signalmp.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/signalmp.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/signalmp.h - -$(PROJECT_INCLUDE)/rtems/rtems/taskmp.h: include/rtems/rtems/taskmp.h $(PROJECT_INCLUDE)/rtems/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rtems/taskmp.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rtems/taskmp.h -endif diff --git a/cpukit/sapi/Makefile.am b/cpukit/sapi/Makefile.am index 326d67f193..4fb7c708cd 100644 --- a/cpukit/sapi/Makefile.am +++ b/cpukit/sapi/Makefile.am @@ -1,29 +1,6 @@ include $(top_srcdir)/automake/multilib.am include $(top_srcdir)/automake/compile.am -include_rtemsdir = $(includedir)/rtems - -include_rtems_HEADERS = include/confdefs.h -include_rtems_HEADERS += include/rtems/bsd.h -include_rtems_HEADERS += include/rtems/chain.h -include_rtems_HEADERS += include/rtems/config.h -include_rtems_HEADERS += include/rtems/counter.h -include_rtems_HEADERS += include/rtems/extension.h -include_rtems_HEADERS += include/rtems/extensionimpl.h -include_rtems_HEADERS += include/rtems/fatal.h -include_rtems_HEADERS += include/rtems/init.h -include_rtems_HEADERS += include/rtems/io.h -include_rtems_HEADERS += include/rtems/ioimpl.h -include_rtems_HEADERS += include/rtems/mptables.h -include_rtems_HEADERS += include/rtems/cbs.h -include_rtems_HEADERS += include/rtems/profiling.h -include_rtems_HEADERS += include/rtems/rbheap.h -include_rtems_HEADERS += include/rtems/rbtree.h -include_rtems_HEADERS += include/rtems/scheduler.h -include_rtems_HEADERS += include/rtems/timecounter.h -include_rtems_HEADERS += include/rtems/timespec.h -include_rtems_HEADERS += include/rtems/version.h - EXTRA_DIST = include/rtems/README noinst_LIBRARIES = libsapi.a @@ -84,5 +61,4 @@ $(srcdir)/src/version.c: version-vc-key.h all-local: generate-vc-key -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h deleted file mode 100755 index 1c993dd099..0000000000 --- a/cpukit/sapi/include/confdefs.h +++ /dev/null @@ -1,3587 +0,0 @@ -/** - * @file - * - * @brief Configuration Table Template that will be Instantiated - * by an Application - * - * This include file contains the configuration table template that will - * be instantiated by an application based on the setting of a number - * of macros. The macros are documented in the Configuring a System - * chapter of the Classic API User's Guide - */ - -/* - * COPYRIGHT (c) 1989-2015. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef __CONFIGURATION_TEMPLATE_h -#define __CONFIGURATION_TEMPLATE_h - -/* - * Include the executive's configuration - */ -#include -#include -#include -#include -#include -#include -#include - -#ifdef CONFIGURE_DISABLE_BSP_SETTINGS - #undef BSP_DEFAULT_UNIFIED_WORK_AREAS - #undef BSP_IDLE_TASK_BODY - #undef BSP_IDLE_TASK_STACK_SIZE - #undef BSP_INITIAL_EXTENSION - #undef BSP_INTERRUPT_STACK_SIZE - #undef BSP_MAXIMUM_DEVICES - #undef BSP_ZERO_WORKSPACE_AUTOMATICALLY - #undef CONFIGURE_BSP_PREREQUISITE_DRIVERS - #undef CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK -#else - #include -#endif - -#ifdef RTEMS_NEWLIB - #include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Internal defines must be prefixed with _CONFIGURE to distinguish them from - * user-provided options which use a CONFIGURE prefix. - */ - -/** - * @defgroup Configuration RTEMS Configuration - * - * This module contains all RTEMS Configuration parameters. - * - * The model is to estimate the memory required for each configured item - * and sum those estimates. The estimate can be too high or too low for - * a variety of reasons: - * - * Reasons estimate is too high: - * + FP contexts (not all tasks are FP) - * - * Reasons estimate is too low: - * + stacks greater than minimum size - * + messages - * + application must account for device driver resources - * + application must account for add-on library resource requirements - * - * NOTE: Eventually this may be able to take into account some of - * the above. This procedure has evolved from just enough to - * support the RTEMS Test Suites into something that can be - * used remarkably reliably by most applications. - */ - -/** - * This is the Classic API initialization tasks table. - */ -extern rtems_initialization_tasks_table Initialization_tasks[]; - -#if defined(RTEMS_MULTIPROCESSING) - /** - * This it the distributed multiprocessing configuration table. - */ - extern rtems_multiprocessing_table Multiprocessing_configuration; -#endif - -#ifdef RTEMS_POSIX_API - /** - * This it the POSIX API configuration table. - */ - extern posix_api_configuration_table Configuration_POSIX_API; -#endif - -/** - * This macro determines whether the RTEMS reentrancy support for - * the Newlib C Library is enabled. - */ -#ifdef RTEMS_SCHEDSIM - #undef RTEMS_NEWLIB -#endif - -#if (defined(RTEMS_NEWLIB) && !defined(CONFIGURE_DISABLE_NEWLIB_REENTRANCY)) - #define _CONFIGURE_NEWLIB_EXTENSION 1 -#else - #define _CONFIGURE_NEWLIB_EXTENSION 0 -#endif - -#ifndef RTEMS_SCHEDSIM -#include - -#ifdef CONFIGURE_INIT - #ifndef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM - RTEMS_SYSINIT_ITEM( - rtems_filesystem_initialize, - RTEMS_SYSINIT_ROOT_FILESYSTEM, - RTEMS_SYSINIT_ORDER_MIDDLE - ); - #endif -#endif -#endif - -/** - * This macro defines the number of POSIX file descriptors allocated - * and managed by libio. These are the "integer" file descriptors that - * are used by calls like open(2) and read(2). - */ -#ifndef CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS - #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 3 -#endif - -/* - * POSIX key count used by the IO library. - */ -#define _CONFIGURE_LIBIO_POSIX_KEYS 1 - -#ifdef CONFIGURE_INIT - rtems_libio_t rtems_libio_iops[CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS]; - - /** - * When instantiating the configuration tables, this variable is - * initialized to specify the maximum number of file descriptors. - */ - const uint32_t rtems_libio_number_iops = RTEMS_ARRAY_SIZE(rtems_libio_iops); -#endif - -/* - * This macro determines if termios is disabled by this application. - * This only means that resources will not be reserved. If you end - * up using termios, it will fail. - */ -#ifdef CONFIGURE_TERMIOS_DISABLED - #define _CONFIGURE_TERMIOS_SEMAPHORES 0 -#else - /** - * This macro specifies the number of serial or PTY ports that will - * use termios. - */ - #ifndef CONFIGURE_NUMBER_OF_TERMIOS_PORTS - #define CONFIGURE_NUMBER_OF_TERMIOS_PORTS 1 - #endif - - /* - * This macro reserves the number of semaphores required by termios - * based upon the number of communication ports that will use it. - */ - #define _CONFIGURE_TERMIOS_SEMAPHORES \ - ((CONFIGURE_NUMBER_OF_TERMIOS_PORTS * 4) + 1) -#endif - -/** - * This macro specifies the number of PTYs that can be concurrently - * active. - */ -#ifndef CONFIGURE_MAXIMUM_PTYS - #define CONFIGURE_MAXIMUM_PTYS 0 -#endif - -/** - * This variable contains the maximum number of PTYs that can be - * concurrently active. - */ -#ifdef CONFIGURE_INIT - int rtems_telnetd_maximum_ptys = CONFIGURE_MAXIMUM_PTYS; -#else - extern int rtems_telnetd_maximum_ptys; -#endif - -#ifdef CONFIGURE_SMP_MAXIMUM_PROCESSORS - #warning "CONFIGURE_SMP_MAXIMUM_PROCESSORS has been renamed to CONFIGURE_MAXIMUM_PROCESSORS since RTEMS 5.1" - #define CONFIGURE_MAXIMUM_PROCESSORS CONFIGURE_SMP_MAXIMUM_PROCESSORS -#endif - -#ifndef CONFIGURE_MAXIMUM_PROCESSORS - #define CONFIGURE_MAXIMUM_PROCESSORS 1 -#endif - -/* - * An internal define to indicate that this is an SMP application - * configuration. - */ -#ifdef RTEMS_SMP - #if !defined(CONFIGURE_DISABLE_SMP_CONFIGURATION) - #define _CONFIGURE_SMP_APPLICATION - #elif CONFIGURE_MAXIMUM_PROCESSORS > 1 - #error "CONFIGURE_DISABLE_SMP_CONFIGURATION and CONFIGURE_MAXIMUM_PROCESSORS > 1 makes no sense" - #endif -#endif - -#ifdef CONFIGURE_SMP_APPLICATION - #warning "CONFIGURE_SMP_APPLICATION is obsolete since RTEMS 5.1" -#endif - -/* - * This sets up the resources for the FIFOs/pipes. - */ - -/** - * This is specified to configure the maximum number of POSIX FIFOs. - */ -#if !defined(CONFIGURE_MAXIMUM_FIFOS) - #define CONFIGURE_MAXIMUM_FIFOS 0 -#endif - -/** - * This is specified to configure the maximum number of POSIX named pipes. - */ -#if !defined(CONFIGURE_MAXIMUM_PIPES) - #define CONFIGURE_MAXIMUM_PIPES 0 -#endif - -/* - * This specifies the number of barriers required for the configured - * number of FIFOs and named pipes. - */ -#if CONFIGURE_MAXIMUM_FIFOS > 0 || CONFIGURE_MAXIMUM_PIPES > 0 - #define _CONFIGURE_BARRIERS_FOR_FIFOS \ - (2 * (CONFIGURE_MAXIMUM_FIFOS + CONFIGURE_MAXIMUM_PIPES)) -#else - #define _CONFIGURE_BARRIERS_FOR_FIFOS 0 -#endif - -/* - * This specifies the number of semaphores required for the configured - * number of FIFOs and named pipes. - */ -#if CONFIGURE_MAXIMUM_FIFOS > 0 || CONFIGURE_MAXIMUM_PIPES > 0 - #define _CONFIGURE_SEMAPHORES_FOR_FIFOS \ - (1 + (CONFIGURE_MAXIMUM_FIFOS + CONFIGURE_MAXIMUM_PIPES)) -#else - #define _CONFIGURE_SEMAPHORES_FOR_FIFOS 0 -#endif - -/** - * @defgroup ConfigFilesystems Filesystems and Mount Table Configuration - * - * @ingroup Configuration - * - * Defines to control the file system: - * - * - CONFIGURE_APPLICATION_DISABLE_FILESYSTEM: - * Disable the RTEMS filesystems. You get an empty DEVFS. - * - * - CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM: - * Use the DEVFS as the root file system. Limited functions are - * provided when this is used. - * - * - CONFIGURE_FILESYSTEM_ALL: - * Add file filesystems to the default filesystem table. - * - * List of available file systems. You can define as many as you like: - * - CONFIGURE_FILESYSTEM_IMFS - In Memory File System (IMFS) - * - CONFIGURE_FILESYSTEM_DEVFS - Device File System (DSVFS) - * - CONFIGURE_FILESYSTEM_TFTPFS - TFTP File System, networking enabled - * - CONFIGURE_FILESYSTEM_FTPFS - FTP File System, networking enabled - * - CONFIGURE_FILESYSTEM_NFS - Network File System, networking enabled - * - CONFIGURE_FILESYSTEM_DOSFS - DOS File System, uses libblock - * - CONFIGURE_FILESYSTEM_RFS - RTEMS File System (RFS), uses libblock - * - CONFIGURE_FILESYSTEM_JFFS2 - Journalling Flash File System, Version 2 - * - * Combinations: - * - * - If nothing is defined the base file system is the IMFS. - * - * - If CONFIGURE_APPLICATION_DISABLE_FILESYSTEM is defined all filesystems - * are disabled by force. - * - * - If CONFIGURE_USE_DEV_AS_BASE_FILESYSTEM is defined all filesystems - * are disabled by force and DEVFS is defined. - */ -/**@{*/ - -#ifdef CONFIGURE_INIT - - /* - * Include all file systems. Do this before checking if the filesystem has - * been disabled. - */ - #ifdef CONFIGURE_FILESYSTEM_ALL - #define CONFIGURE_FILESYSTEM_IMFS - #define CONFIGURE_FILESYSTEM_DEVFS - #define CONFIGURE_FILESYSTEM_TFTPFS - #define CONFIGURE_FILESYSTEM_FTPFS - #define CONFIGURE_FILESYSTEM_NFS - #define CONFIGURE_FILESYSTEM_DOSFS - #define CONFIGURE_FILESYSTEM_RFS - #define CONFIGURE_FILESYSTEM_JFFS2 - #endif - - /* - * If disabling the file system, give a compile error if the user has - * configured other filesystem parameters. - */ - #if defined(CONFIGURE_APPLICATION_DISABLE_FILESYSTEM) - #if defined(CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM) - #error "Filesystem disabled and a base filesystem configured." - #endif - - #if defined(CONFIGURE_FILESYSTEM_IMFS) || \ - defined(CONFIGURE_FILESYSTEM_DEVFS) || \ - defined(CONFIGURE_FILESYSTEM_TFTPFS) || \ - defined(CONFIGURE_FILESYSTEM_FTPFS) || \ - defined(CONFIGURE_FILESYSTEM_NFS) || \ - defined(CONFIGURE_FILESYSTEM_DOSFS) || \ - defined(CONFIGURE_FILESYSTEM_RFS) || \ - defined(CONFIGURE_FILESYSTEM_JFFS2) - #error "Filesystem disabled and a filesystem configured." - #endif - #endif - - /* - * If the base filesystem is DEVFS define it else define IMFS. - * We will have either DEVFS or IMFS defined after this. - */ - #if !defined(CONFIGURE_APPLICATION_DISABLE_FILESYSTEM) - #if defined(CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM) - #define CONFIGURE_FILESYSTEM_DEVFS - #endif - #endif - -#endif - -#ifndef RTEMS_SCHEDSIM -/** - * IMFS - */ -#include - -/** - * This specifies the number of bytes per block for files within the IMFS. - * There are a maximum number of blocks per file so this dictates the maximum - * size of a file. This has to be balanced with the unused portion of each - * block that might be wasted. - */ -#ifndef CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK - #define CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK \ - IMFS_MEMFILE_DEFAULT_BYTES_PER_BLOCK -#endif - -/** - * This defines the IMFS file system table entry. - */ -#if !defined(CONFIGURE_FILESYSTEM_ENTRY_IMFS) && \ - defined(CONFIGURE_FILESYSTEM_IMFS) - #define CONFIGURE_FILESYSTEM_ENTRY_IMFS \ - { RTEMS_FILESYSTEM_TYPE_IMFS, IMFS_initialize } -#endif -#endif - -#ifdef CONFIGURE_USE_MINIIMFS_AS_BASE_FILESYSTEM - #define CONFIGURE_IMFS_DISABLE_CHMOD - #define CONFIGURE_IMFS_DISABLE_CHOWN - #define CONFIGURE_IMFS_DISABLE_UTIME - #define CONFIGURE_IMFS_DISABLE_LINK - #define CONFIGURE_IMFS_DISABLE_SYMLINK - #define CONFIGURE_IMFS_DISABLE_READLINK - #define CONFIGURE_IMFS_DISABLE_RENAME - #define CONFIGURE_IMFS_DISABLE_UNMOUNT -#endif - -/** - * DEVFS - */ -#if !defined(CONFIGURE_FILESYSTEM_ENTRY_DEVFS) && \ - defined(CONFIGURE_FILESYSTEM_DEVFS) -#include - #define CONFIGURE_FILESYSTEM_ENTRY_DEVFS \ - { RTEMS_FILESYSTEM_TYPE_DEVFS, devFS_initialize } -#endif - -/** - * FTPFS - */ -#if !defined(CONFIGURE_FILESYSTEM_ENTRY_FTPFS) && \ - defined(CONFIGURE_FILESYSTEM_FTPFS) - #include - #define CONFIGURE_FILESYSTEM_ENTRY_FTPFS \ - { RTEMS_FILESYSTEM_TYPE_FTPFS, rtems_ftpfs_initialize } -#endif - -/** - * TFTPFS - */ -#if !defined(CONFIGURE_FILESYSTEM_ENTRY_TFTPFS) && \ - defined(CONFIGURE_FILESYSTEM_TFTPFS) - #include - #define CONFIGURE_FILESYSTEM_ENTRY_TFTPFS \ - { RTEMS_FILESYSTEM_TYPE_TFTPFS, rtems_tftpfs_initialize } -#endif - -/** - * NFS - */ -#if !defined(CONFIGURE_FILESYSTEM_ENTRY_NFS) && \ - defined(CONFIGURE_FILESYSTEM_NFS) - #include - #if !defined(CONFIGURE_MAXIMUM_NFS_MOUNTS) - #define CONFIGURE_MAXIMUM_NFS_MOUNTS 1 - #endif - #define CONFIGURE_FILESYSTEM_ENTRY_NFS \ - { RTEMS_FILESYSTEM_TYPE_NFS, rtems_nfs_initialize } - #define _CONFIGURE_SEMAPHORES_FOR_NFS ((CONFIGURE_MAXIMUM_NFS_MOUNTS * 2) + 1) -#else - #define _CONFIGURE_SEMAPHORES_FOR_NFS 0 -#endif - -/** - * DOSFS - */ -#if !defined(CONFIGURE_FILESYSTEM_ENTRY_DOSFS) && \ - defined(CONFIGURE_FILESYSTEM_DOSFS) - #include - #if !defined(CONFIGURE_MAXIMUM_DOSFS_MOUNTS) - #define CONFIGURE_MAXIMUM_DOSFS_MOUNTS 1 - #endif - #define CONFIGURE_FILESYSTEM_ENTRY_DOSFS \ - { RTEMS_FILESYSTEM_TYPE_DOSFS, rtems_dosfs_initialize } - #define _CONFIGURE_SEMAPHORES_FOR_DOSFS CONFIGURE_MAXIMUM_DOSFS_MOUNTS -#else - #define _CONFIGURE_SEMAPHORES_FOR_DOSFS 0 -#endif - -/** - * RFS - */ -#if !defined(CONFIGURE_FILESYSTEM_ENTRY_RFS) && \ - defined(CONFIGURE_FILESYSTEM_RFS) - #include - #if !defined(CONFIGURE_MAXIMUM_RFS_MOUNTS) - #define CONFIGURE_MAXIMUM_RFS_MOUNTS 1 - #endif - #define CONFIGURE_FILESYSTEM_ENTRY_RFS \ - { RTEMS_FILESYSTEM_TYPE_RFS, rtems_rfs_rtems_initialise } - #define _CONFIGURE_SEMAPHORES_FOR_RFS CONFIGURE_MAXIMUM_RFS_MOUNTS -#else - #define _CONFIGURE_SEMAPHORES_FOR_RFS 0 -#endif - -/** - * JFFS2 - */ -#if !defined(CONFIGURE_FILESYSTEM_ENTRY_JFFS2) && \ - defined(CONFIGURE_FILESYSTEM_JFFS2) - #include - #if !defined(CONFIGURE_MAXIMUM_JFFS2_MOUNTS) - #define CONFIGURE_MAXIMUM_JFFS2_MOUNTS 1 - #endif - #define CONFIGURE_FILESYSTEM_ENTRY_JFFS2 \ - { RTEMS_FILESYSTEM_TYPE_JFFS2, rtems_jffs2_initialize } - #define _CONFIGURE_SEMAPHORES_FOR_JFFS2 CONFIGURE_MAXIMUM_JFFS2_MOUNTS -#else - #define _CONFIGURE_SEMAPHORES_FOR_JFFS2 0 -#endif - -/** - * This computes the number of semaphores required for the various - * file systems including the FIFO plugin to the IMFS. - */ -#define _CONFIGURE_SEMAPHORES_FOR_FILE_SYSTEMS \ - (_CONFIGURE_SEMAPHORES_FOR_FIFOS + \ - _CONFIGURE_SEMAPHORES_FOR_NFS + \ - _CONFIGURE_SEMAPHORES_FOR_DOSFS + \ - _CONFIGURE_SEMAPHORES_FOR_RFS + \ - _CONFIGURE_SEMAPHORES_FOR_JFFS2) - -#ifdef CONFIGURE_INIT - - /** - * DEVFS variables. - * - * The number of individual devices that may be registered - * in the system or the CONFIGURE_MAXIMUM_DEVICES variable - * is defaulted to 4 when a filesystem is enabled, unless - * the bsp overwrides this. In which case the value is set - * to BSP_MAXIMUM_DEVICES. - */ - #ifdef CONFIGURE_FILESYSTEM_DEVFS - #ifndef CONFIGURE_MAXIMUM_DEVICES - #if defined(BSP_MAXIMUM_DEVICES) - #define CONFIGURE_MAXIMUM_DEVICES BSP_MAXIMUM_DEVICES - #else - #define CONFIGURE_MAXIMUM_DEVICES 4 - #endif - #endif - #include - #endif - - /** - * Table termination record. - */ - #define CONFIGURE_FILESYSTEM_NULL { NULL, NULL } - -#ifndef RTEMS_SCHEDSIM - #if !defined(CONFIGURE_APPLICATION_DISABLE_FILESYSTEM) && \ - !defined(CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM) - int imfs_rq_memfile_bytes_per_block = - CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK; - #endif - - /** - * The default file system table. Must be terminated with the NULL entry if - * you provide your own. - */ - #if !defined(CONFIGURE_HAS_OWN_FILESYSTEM_TABLE) && \ - !defined(CONFIGURE_APPLICATION_DISABLE_FILESYSTEM) - const rtems_filesystem_table_t rtems_filesystem_table[] = { - #if !defined(CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM) - { "/", IMFS_initialize_support }, - #endif - #if defined(CONFIGURE_FILESYSTEM_IMFS) && \ - defined(CONFIGURE_FILESYSTEM_ENTRY_IMFS) - CONFIGURE_FILESYSTEM_ENTRY_IMFS, - #endif - #if defined(CONFIGURE_FILESYSTEM_DEVFS) && \ - defined(CONFIGURE_FILESYSTEM_ENTRY_DEVFS) - CONFIGURE_FILESYSTEM_ENTRY_DEVFS, - #endif - #if defined(CONFIGURE_FILESYSTEM_TFTPFS) && \ - defined(CONFIGURE_FILESYSTEM_ENTRY_TFTPFS) - CONFIGURE_FILESYSTEM_ENTRY_TFTPFS, - #endif - #if defined(CONFIGURE_FILESYSTEM_FTPFS) && \ - defined(CONFIGURE_FILESYSTEM_ENTRY_FTPFS) - CONFIGURE_FILESYSTEM_ENTRY_FTPFS, - #endif - #if defined(CONFIGURE_FILESYSTEM_NFS) && \ - defined(CONFIGURE_FILESYSTEM_ENTRY_NFS) - CONFIGURE_FILESYSTEM_ENTRY_NFS, - #endif - #if defined(CONFIGURE_FILESYSTEM_DOSFS) && \ - defined(CONFIGURE_FILESYSTEM_ENTRY_DOSFS) - CONFIGURE_FILESYSTEM_ENTRY_DOSFS, - #endif - #if defined(CONFIGURE_FILESYSTEM_RFS) && \ - defined(CONFIGURE_FILESYSTEM_ENTRY_RFS) - CONFIGURE_FILESYSTEM_ENTRY_RFS, - #endif - #if defined(CONFIGURE_FILESYSTEM_JFFS2) && \ - defined(CONFIGURE_FILESYSTEM_ENTRY_JFFS2) - CONFIGURE_FILESYSTEM_ENTRY_JFFS2, - #endif - CONFIGURE_FILESYSTEM_NULL - }; - #endif - - #if !defined(CONFIGURE_HAS_OWN_MOUNT_TABLE) && \ - !defined(CONFIGURE_APPLICATION_DISABLE_FILESYSTEM) - #if defined(CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM) - static devFS_node devFS_root_filesystem_nodes [CONFIGURE_MAXIMUM_DEVICES]; - static const devFS_data devFS_root_filesystem_data = { - devFS_root_filesystem_nodes, - CONFIGURE_MAXIMUM_DEVICES - }; - #else - static IMFS_fs_info_t _Configure_IMFS_fs_info; - - static const rtems_filesystem_operations_table _Configure_IMFS_ops = { - rtems_filesystem_default_lock, - rtems_filesystem_default_unlock, - IMFS_eval_path, - #ifdef CONFIGURE_IMFS_DISABLE_LINK - rtems_filesystem_default_link, - #else - IMFS_link, - #endif - rtems_filesystem_default_are_nodes_equal, - #ifdef CONFIGURE_IMFS_DISABLE_MKNOD - rtems_filesystem_default_mknod, - #else - IMFS_mknod, - #endif - #ifdef CONFIGURE_IMFS_DISABLE_RMNOD - rtems_filesystem_default_rmnod, - #else - IMFS_rmnod, - #endif - #ifdef CONFIGURE_IMFS_DISABLE_CHMOD - rtems_filesystem_default_fchmod, - #else - IMFS_fchmod, - #endif - #ifdef CONFIGURE_IMFS_DISABLE_CHOWN - rtems_filesystem_default_chown, - #else - IMFS_chown, - #endif - IMFS_node_clone, - IMFS_node_free, - #ifdef CONFIGURE_IMFS_DISABLE_MOUNT - rtems_filesystem_default_mount, - #else - IMFS_mount, - #endif - #ifdef CONFIGURE_IMFS_DISABLE_UNMOUNT - rtems_filesystem_default_unmount, - #else - IMFS_unmount, - #endif - rtems_filesystem_default_fsunmount, - #ifdef CONFIGURE_IMFS_DISABLE_UTIME - rtems_filesystem_default_utime, - #else - IMFS_utime, - #endif - #ifdef CONFIGURE_IMFS_DISABLE_SYMLINK - rtems_filesystem_default_symlink, - #else - IMFS_symlink, - #endif - #ifdef CONFIGURE_IMFS_DISABLE_READLINK - rtems_filesystem_default_readlink, - #else - IMFS_readlink, - #endif - #ifdef CONFIGURE_IMFS_DISABLE_RENAME - rtems_filesystem_default_rename, - #else - IMFS_rename, - #endif - rtems_filesystem_default_statvfs - }; - - static const IMFS_mknod_controls _Configure_IMFS_mknod_controls = { - #ifdef CONFIGURE_IMFS_DISABLE_READDIR - &IMFS_mknod_control_dir_minimal, - #else - &IMFS_mknod_control_dir_default, - #endif - &IMFS_mknod_control_device, - #ifdef CONFIGURE_IMFS_DISABLE_MKNOD_FILE - &IMFS_mknod_control_enosys, - #else - &IMFS_mknod_control_memfile, - #endif - #if CONFIGURE_MAXIMUM_FIFOS > 0 || CONFIGURE_MAXIMUM_PIPES > 0 - &IMFS_mknod_control_fifo - #else - &IMFS_mknod_control_enosys - #endif - }; - - static const IMFS_mount_data _Configure_IMFS_mount_data = { - &_Configure_IMFS_fs_info, - &_Configure_IMFS_ops, - &_Configure_IMFS_mknod_controls - }; - #endif - - const rtems_filesystem_mount_configuration - rtems_filesystem_root_configuration = { - NULL, - NULL, - #if defined(CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM) - RTEMS_FILESYSTEM_TYPE_DEVFS, - #else - "/", - #endif - RTEMS_FILESYSTEM_READ_WRITE, - #if defined(CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM) - &devFS_root_filesystem_data - #else - &_Configure_IMFS_mount_data - #endif - }; - #endif - -#endif -#endif -/**@}*/ /* end of file system group */ - -/* - * STACK_CHECKER_ON was still available in 4.9 so give a warning for now. - */ -#if defined(STACK_CHECKER_ON) - #define CONFIGURE_STACK_CHECKER_ENABLED - #warning "STACK_CHECKER_ON deprecated -- use CONFIGURE_STACK_CHECKER_ENABLED" -#endif - -/** - * This configures the stack checker user extension. - */ -#ifdef CONFIGURE_STACK_CHECKER_ENABLED - #define _CONFIGURE_STACK_CHECKER_EXTENSION 1 -#else - #define _CONFIGURE_STACK_CHECKER_EXTENSION 0 -#endif - -/** - * @brief Maximum priority configuration. - * - * This configures the maximum priority value that - * a task may have. - * - * The following applies to the data space requirements - * of the Priority Scheduler. - * - * By reducing the number of priorities in a system, - * the amount of RAM required by RTEMS can be significantly - * reduced. RTEMS allocates a Chain_Control structure per - * priority and this structure contains 3 pointers. So - * the default is (256 * 12) = 3K on 32-bit architectures. - * - * This must be one less than a power of 2 between - * 4 and 256. Valid values along with the application - * priority levels and memory saved when pointers are - * 32-bits in size are: - * - * + 3, 2 application priorities, 3024 bytes saved - * + 7, 5 application priorities, 2976 bytes saved - * + 15, 13 application priorities, 2880 bytes saved - * + 31, 29 application priorities, 2688 bytes saved - * + 63, 61 application priorities, 2304 bytes saved - * + 127, 125 application priorities, 1536 bytes saved - * + 255, 253 application priorities, 0 bytes saved - * - * It is specified in terms of Classic API priority values. - */ -#ifndef CONFIGURE_MAXIMUM_PRIORITY - #define CONFIGURE_MAXIMUM_PRIORITY PRIORITY_DEFAULT_MAXIMUM -#endif - -/** - * @defgroup ConfigScheduler Scheduler configuration - * - * @ingroup Configuration - * - * The scheduler configuration allows an application to select the - * scheduling policy to use. The supported configurations are: - * - * - CONFIGURE_SCHEDULER_PRIORITY - Deterministic Priority Scheduler - * - CONFIGURE_SCHEDULER_PRIORITY_SMP - Deterministic Priority SMP Scheduler - * - CONFIGURE_SCHEDULER_PRIORITY_AFFINITY_SMP - Deterministic - * Priority SMP Affinity Scheduler - * - CONFIGURE_SCHEDULER_STRONG_APA - Strong APA Scheduler - * - CONFIGURE_SCHEDULER_SIMPLE - Light-weight Priority Scheduler - * - CONFIGURE_SCHEDULER_SIMPLE_SMP - Simple SMP Priority Scheduler - * - CONFIGURE_SCHEDULER_EDF - EDF Scheduler - * - CONFIGURE_SCHEDULER_EDF_SMP - EDF SMP Scheduler - * - CONFIGURE_SCHEDULER_CBS - CBS Scheduler - * - CONFIGURE_SCHEDULER_USER - user provided scheduler - * - * If no configuration is specified by the application in a uniprocessor - * configuration, then CONFIGURE_SCHEDULER_PRIORITY is the default. - * - * If no configuration is specified by the application in SMP - * configuration, then CONFIGURE_SCHEDULER_PRIORITY_SMP is the default. - * - * An application can define its own scheduling policy by defining - * CONFIGURE_SCHEDULER_USER and the following: - * - * - CONFIGURE_SCHEDULER_CONTEXT - * - CONFIGURE_SCHEDULER_CONTROLS - * - CONFIGURE_SCHEDULER_USER_PER_THREAD - */ - -#if !defined(CONFIGURE_SCHEDULER_USER) && \ - !defined(CONFIGURE_SCHEDULER_PRIORITY) && \ - !defined(CONFIGURE_SCHEDULER_PRIORITY_SMP) && \ - !defined(CONFIGURE_SCHEDULER_PRIORITY_AFFINITY_SMP) && \ - !defined(CONFIGURE_SCHEDULER_STRONG_APA) && \ - !defined(CONFIGURE_SCHEDULER_SIMPLE) && \ - !defined(CONFIGURE_SCHEDULER_SIMPLE_SMP) && \ - !defined(CONFIGURE_SCHEDULER_EDF) && \ - !defined(CONFIGURE_SCHEDULER_EDF_SMP) && \ - !defined(CONFIGURE_SCHEDULER_CBS) - #if defined(RTEMS_SMP) && CONFIGURE_MAXIMUM_PROCESSORS > 1 - /** - * If no scheduler is specified in an SMP configuration, the - * EDF scheduler is default. - */ - #define CONFIGURE_SCHEDULER_EDF_SMP - #else - /** - * If no scheduler is specified in a uniprocessor configuration, the - * priority scheduler is default. - */ - #define CONFIGURE_SCHEDULER_PRIORITY - #endif -#endif - -#include - -/* - * If the Priority Scheduler is selected, then configure for it. - */ -#if defined(CONFIGURE_SCHEDULER_PRIORITY) - #if !defined(CONFIGURE_SCHEDULER_NAME) - /** Configure the name of the scheduler instance */ - #define CONFIGURE_SCHEDULER_NAME rtems_build_name('U', 'P', 'D', ' ') - #endif - - #if !defined(CONFIGURE_SCHEDULER_CONTROLS) - /** Configure the context needed by the scheduler instance */ - #define CONFIGURE_SCHEDULER_CONTEXT \ - RTEMS_SCHEDULER_CONTEXT_PRIORITY( \ - dflt, \ - CONFIGURE_MAXIMUM_PRIORITY + 1 \ - ) - - /** Configure the controls for this scheduler instance */ - #define CONFIGURE_SCHEDULER_CONTROLS \ - RTEMS_SCHEDULER_CONTROL_PRIORITY(dflt, CONFIGURE_SCHEDULER_NAME) - #endif -#endif - -/* - * If the Deterministic Priority SMP Scheduler is selected, then configure for - * it. - */ -#if defined(CONFIGURE_SCHEDULER_PRIORITY_SMP) - #if !defined(CONFIGURE_SCHEDULER_NAME) - /** Configure the name of the scheduler instance */ - #define CONFIGURE_SCHEDULER_NAME rtems_build_name('M', 'P', 'D', ' ') - #endif - - #if !defined(CONFIGURE_SCHEDULER_CONTROLS) - /** Configure the context needed by the scheduler instance */ - #define CONFIGURE_SCHEDULER_CONTEXT \ - RTEMS_SCHEDULER_CONTEXT_PRIORITY_SMP( \ - dflt, \ - CONFIGURE_MAXIMUM_PRIORITY + 1 \ - ) - - /** Configure the controls for this scheduler instance */ - #define CONFIGURE_SCHEDULER_CONTROLS \ - RTEMS_SCHEDULER_CONTROL_PRIORITY_SMP(dflt, CONFIGURE_SCHEDULER_NAME) - #endif -#endif - -/* - * If the Deterministic Priority Affinity SMP Scheduler is selected, then configure for - * it. - */ -#if defined(CONFIGURE_SCHEDULER_PRIORITY_AFFINITY_SMP) - #if !defined(CONFIGURE_SCHEDULER_NAME) - /** Configure the name of the scheduler instance */ - #define CONFIGURE_SCHEDULER_NAME rtems_build_name('M', 'P', 'A', ' ') - #endif - - #if !defined(CONFIGURE_SCHEDULER_CONTROLS) - /** Configure the context needed by the scheduler instance */ - #define CONFIGURE_SCHEDULER_CONTEXT \ - RTEMS_SCHEDULER_CONTEXT_PRIORITY_AFFINITY_SMP( \ - dflt, \ - CONFIGURE_MAXIMUM_PRIORITY + 1 \ - ) - - /** Configure the controls for this scheduler instance */ - #define CONFIGURE_SCHEDULER_CONTROLS \ - RTEMS_SCHEDULER_CONTROL_PRIORITY_AFFINITY_SMP( \ - dflt, \ - CONFIGURE_SCHEDULER_NAME \ - ) - #endif -#endif - -/* - * If the Strong APA Scheduler is selected, then configure for - * it. - */ -#if defined(CONFIGURE_SCHEDULER_STRONG_APA) - #if !defined(CONFIGURE_SCHEDULER_NAME) - /** Configure the name of the scheduler instance */ - #define CONFIGURE_SCHEDULER_NAME rtems_build_name('M', 'A', 'P', 'A') - #endif - - #if !defined(CONFIGURE_SCHEDULER_CONTROLS) - /** Configure the context needed by the scheduler instance */ - #define CONFIGURE_SCHEDULER_CONTEXT \ - RTEMS_SCHEDULER_CONTEXT_STRONG_APA( \ - dflt, \ - CONFIGURE_MAXIMUM_PRIORITY + 1 \ - ) - - /** Configure the controls for this scheduler instance */ - #define CONFIGURE_SCHEDULER_CONTROLS \ - RTEMS_SCHEDULER_CONTROL_STRONG_APA(dflt, CONFIGURE_SCHEDULER_NAME) - #endif -#endif - -/* - * If the Simple Priority Scheduler is selected, then configure for it. - */ -#if defined(CONFIGURE_SCHEDULER_SIMPLE) - #if !defined(CONFIGURE_SCHEDULER_NAME) - /** Configure the name of the scheduler instance */ - #define CONFIGURE_SCHEDULER_NAME rtems_build_name('U', 'P', 'S', ' ') - #endif - - #if !defined(CONFIGURE_SCHEDULER_CONTROLS) - /** Configure the context needed by the scheduler instance */ - #define CONFIGURE_SCHEDULER_CONTEXT RTEMS_SCHEDULER_CONTEXT_SIMPLE(dflt) - - /** Configure the controls for this scheduler instance */ - #define CONFIGURE_SCHEDULER_CONTROLS \ - RTEMS_SCHEDULER_CONTROL_SIMPLE(dflt, CONFIGURE_SCHEDULER_NAME) - #endif -#endif - -/* - * If the Simple SMP Priority Scheduler is selected, then configure for it. - */ -#if defined(CONFIGURE_SCHEDULER_SIMPLE_SMP) - #if !defined(CONFIGURE_SCHEDULER_NAME) - /** Configure the name of the scheduler instance */ - #define CONFIGURE_SCHEDULER_NAME rtems_build_name('M', 'P', 'S', ' ') - #endif - - #if !defined(CONFIGURE_SCHEDULER_CONTROLS) - /** Configure the context needed by the scheduler instance */ - #define CONFIGURE_SCHEDULER_CONTEXT \ - RTEMS_SCHEDULER_CONTEXT_SIMPLE_SMP(dflt) - - /** Configure the controls for this scheduler instance */ - #define CONFIGURE_SCHEDULER_CONTROLS \ - RTEMS_SCHEDULER_CONTROL_SIMPLE_SMP(dflt, CONFIGURE_SCHEDULER_NAME) - #endif -#endif - -/* - * If the EDF Scheduler is selected, then configure for it. - */ -#if defined(CONFIGURE_SCHEDULER_EDF) - #if !defined(CONFIGURE_SCHEDULER_NAME) - /** Configure the name of the scheduler instance */ - #define CONFIGURE_SCHEDULER_NAME rtems_build_name('U', 'E', 'D', 'F') - #endif - - #if !defined(CONFIGURE_SCHEDULER_CONTROLS) - /** Configure the context needed by the scheduler instance */ - #define CONFIGURE_SCHEDULER_CONTEXT RTEMS_SCHEDULER_CONTEXT_EDF(dflt) - - /** Configure the controls for this scheduler instance */ - #define CONFIGURE_SCHEDULER_CONTROLS \ - RTEMS_SCHEDULER_CONTROL_EDF(dflt, CONFIGURE_SCHEDULER_NAME) - #endif -#endif - -/* - * If the EDF SMP Scheduler is selected, then configure for it. - */ -#if defined(CONFIGURE_SCHEDULER_EDF_SMP) - #if !defined(CONFIGURE_SCHEDULER_NAME) - /** Configure the name of the scheduler instance */ - #define CONFIGURE_SCHEDULER_NAME rtems_build_name('M', 'E', 'D', 'F') - #endif - - #if !defined(CONFIGURE_SCHEDULER_CONTROLS) - /** Configure the context needed by the scheduler instance */ - #define CONFIGURE_SCHEDULER_CONTEXT \ - RTEMS_SCHEDULER_CONTEXT_EDF_SMP(dflt, CONFIGURE_MAXIMUM_PROCESSORS) - - /** Configure the controls for this scheduler instance */ - #define CONFIGURE_SCHEDULER_CONTROLS \ - RTEMS_SCHEDULER_CONTROL_EDF_SMP(dflt, CONFIGURE_SCHEDULER_NAME) - #endif -#endif - -/* - * If the CBS Scheduler is selected, then configure for it. - */ -#if defined(CONFIGURE_SCHEDULER_CBS) - #if !defined(CONFIGURE_SCHEDULER_NAME) - /** Configure the name of the scheduler instance */ - #define CONFIGURE_SCHEDULER_NAME rtems_build_name('U', 'C', 'B', 'S') - #endif - - #if !defined(CONFIGURE_SCHEDULER_CONTROLS) - /** Configure the context needed by the scheduler instance */ - #define CONFIGURE_SCHEDULER_CONTEXT RTEMS_SCHEDULER_CONTEXT_CBS(dflt) - - /** Configure the controls for this scheduler instance */ - #define CONFIGURE_SCHEDULER_CONTROLS \ - RTEMS_SCHEDULER_CONTROL_CBS(dflt, CONFIGURE_SCHEDULER_NAME) - #endif - - #ifndef CONFIGURE_CBS_MAXIMUM_SERVERS - #define CONFIGURE_CBS_MAXIMUM_SERVERS CONFIGURE_MAXIMUM_TASKS - #endif - - #ifdef CONFIGURE_INIT - const uint32_t _Scheduler_CBS_Maximum_servers = - CONFIGURE_CBS_MAXIMUM_SERVERS; - - Scheduler_CBS_Server - _Scheduler_CBS_Server_list[ CONFIGURE_CBS_MAXIMUM_SERVERS ]; - #endif -#endif - -/* - * Set up the scheduler entry points table. The scheduling code uses - * this code to know which scheduler is configured by the user. - */ -#ifdef CONFIGURE_INIT - #if defined(CONFIGURE_SCHEDULER_CONTEXT) - CONFIGURE_SCHEDULER_CONTEXT; - #endif - - const Scheduler_Control _Scheduler_Table[] = { - CONFIGURE_SCHEDULER_CONTROLS - }; - - #define CONFIGURE_SCHEDULER_COUNT RTEMS_ARRAY_SIZE( _Scheduler_Table ) - - #if defined(RTEMS_SMP) - const size_t _Scheduler_Count = CONFIGURE_SCHEDULER_COUNT; - - const Scheduler_Assignment _Scheduler_Initial_assignments[] = { - #if defined(CONFIGURE_SMP_SCHEDULER_ASSIGNMENTS) - CONFIGURE_SMP_SCHEDULER_ASSIGNMENTS - #else - #define _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT \ - RTEMS_SCHEDULER_ASSIGN( \ - 0, \ - RTEMS_SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL \ - ) - _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #if CONFIGURE_MAXIMUM_PROCESSORS >= 2 - , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #endif - #if CONFIGURE_MAXIMUM_PROCESSORS >= 3 - , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #endif - #if CONFIGURE_MAXIMUM_PROCESSORS >= 4 - , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #endif - #if CONFIGURE_MAXIMUM_PROCESSORS >= 5 - , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #endif - #if CONFIGURE_MAXIMUM_PROCESSORS >= 6 - , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #endif - #if CONFIGURE_MAXIMUM_PROCESSORS >= 7 - , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #endif - #if CONFIGURE_MAXIMUM_PROCESSORS >= 8 - , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #endif - #if CONFIGURE_MAXIMUM_PROCESSORS >= 9 - , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #endif - #if CONFIGURE_MAXIMUM_PROCESSORS >= 10 - , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #endif - #if CONFIGURE_MAXIMUM_PROCESSORS >= 11 - , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #endif - #if CONFIGURE_MAXIMUM_PROCESSORS >= 12 - , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #endif - #if CONFIGURE_MAXIMUM_PROCESSORS >= 13 - , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #endif - #if CONFIGURE_MAXIMUM_PROCESSORS >= 14 - , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #endif - #if CONFIGURE_MAXIMUM_PROCESSORS >= 15 - , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #endif - #if CONFIGURE_MAXIMUM_PROCESSORS >= 16 - , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #endif - #if CONFIGURE_MAXIMUM_PROCESSORS >= 17 - , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #endif - #if CONFIGURE_MAXIMUM_PROCESSORS >= 18 - , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #endif - #if CONFIGURE_MAXIMUM_PROCESSORS >= 19 - , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #endif - #if CONFIGURE_MAXIMUM_PROCESSORS >= 20 - , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #endif - #if CONFIGURE_MAXIMUM_PROCESSORS >= 21 - , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #endif - #if CONFIGURE_MAXIMUM_PROCESSORS >= 22 - , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #endif - #if CONFIGURE_MAXIMUM_PROCESSORS >= 23 - , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #endif - #if CONFIGURE_MAXIMUM_PROCESSORS >= 24 - , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #endif - #if CONFIGURE_MAXIMUM_PROCESSORS >= 25 - , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #endif - #if CONFIGURE_MAXIMUM_PROCESSORS >= 26 - , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #endif - #if CONFIGURE_MAXIMUM_PROCESSORS >= 27 - , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #endif - #if CONFIGURE_MAXIMUM_PROCESSORS >= 28 - , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #endif - #if CONFIGURE_MAXIMUM_PROCESSORS >= 29 - , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #endif - #if CONFIGURE_MAXIMUM_PROCESSORS >= 30 - , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #endif - #if CONFIGURE_MAXIMUM_PROCESSORS >= 31 - , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #endif - #if CONFIGURE_MAXIMUM_PROCESSORS >= 32 - , _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #endif - #undef _CONFIGURE_SMP_SCHEDULER_ASSIGN_OPT - #endif - }; - - RTEMS_STATIC_ASSERT( - CONFIGURE_MAXIMUM_PROCESSORS - == RTEMS_ARRAY_SIZE( _Scheduler_Initial_assignments ), - _Scheduler_Initial_assignments - ); - #endif -#endif -/**@}*/ /* end of Scheduler Configuration */ - -/** - * @defgroup ConfigurationIdle IDLE Thread Configuration - * - * @addtogroup Configuration - * - * This module contains configuration parameters related to the - * set of IDLE threads. On a uniprocessor system, there is one - * IDLE thread. On an SMP system, there is one for each core. - */ - -/* - * If you said the IDLE task was going to do application initialization - * and didn't override the IDLE body, then something is amiss. - */ -#if (defined(CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION) && \ - !defined(CONFIGURE_IDLE_TASK_BODY)) - #error "CONFIGURE_ERROR: You did not override the IDLE task body." -#endif - -/** - * @brief Idle task body configuration. - * - * There is a default IDLE thread body provided by RTEMS which - * has the possibility of being CPU specific. There may be a - * BSP specific override of the RTEMS default body and in turn, - * the application may override and provide its own. - */ -#ifndef CONFIGURE_IDLE_TASK_BODY - #if defined(BSP_IDLE_TASK_BODY) - #define CONFIGURE_IDLE_TASK_BODY BSP_IDLE_TASK_BODY - #elif (CPU_PROVIDES_IDLE_THREAD_BODY == TRUE) - #define CONFIGURE_IDLE_TASK_BODY _CPU_Thread_Idle_body - #else - /* only instantiate and compile if used */ - #ifdef CONFIGURE_INIT - void *_Thread_Idle_body(uintptr_t ignored) - { - for( ; ; ) ; - return 0; /* to avoid warning */ - } - #endif - #define CONFIGURE_IDLE_TASK_BODY _Thread_Idle_body - #endif -#endif -/**@}*/ /* end of IDLE thread configuration */ - -/** - * @defgroup ConfigurationStackSize Configuration Thread Stack Size - * - * @addtogroup Configuration - * - * This module contains parameters related to thread aand interrupt stacks. - */ - -/** - * By default, use the minimum stack size requested by this port. - */ -#ifndef CONFIGURE_MINIMUM_TASK_STACK_SIZE - #define CONFIGURE_MINIMUM_TASK_STACK_SIZE CPU_STACK_MINIMUM_SIZE -#endif - -/** - * This specifies the default POSIX thread stack size. By default, it is - * twice that recommended for the port. - */ -#define CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE \ - (2 * CONFIGURE_MINIMUM_TASK_STACK_SIZE) - -/** - * @brief Idle task stack size configuration. - * - * By default, the IDLE task will have a stack of minimum size. - * The BSP or application may override this value. - */ -#ifndef CONFIGURE_IDLE_TASK_STACK_SIZE - #ifdef BSP_IDLE_TASK_STACK_SIZE - #define CONFIGURE_IDLE_TASK_STACK_SIZE BSP_IDLE_TASK_STACK_SIZE - #else - #define CONFIGURE_IDLE_TASK_STACK_SIZE CONFIGURE_MINIMUM_TASK_STACK_SIZE - #endif -#endif -#if CONFIGURE_IDLE_TASK_STACK_SIZE < CONFIGURE_MINIMUM_TASK_STACK_SIZE - #error "CONFIGURE_IDLE_TASK_STACK_SIZE less than CONFIGURE_MINIMUM_TASK_STACK_SIZE" -#endif - -/** - * @brief Interrupt stack size configuration. - * - * By default, the interrupt stack will be of minimum size. - * The BSP or application may override this value. - */ -#ifndef CONFIGURE_INTERRUPT_STACK_SIZE - #ifdef BSP_INTERRUPT_STACK_SIZE - #define CONFIGURE_INTERRUPT_STACK_SIZE BSP_INTERRUPT_STACK_SIZE - #else - #define CONFIGURE_INTERRUPT_STACK_SIZE CONFIGURE_MINIMUM_TASK_STACK_SIZE - #endif -#endif - -/** - * This reserves memory for the interrupt stack if it is to be allocated - * by RTEMS rather than the BSP. - * - * @todo Try to get to the point where all BSPs support allocating the - * memory from the Workspace. - */ -#if (CPU_ALLOCATE_INTERRUPT_STACK == 0) - #define _CONFIGURE_INTERRUPT_STACK_MEMORY 0 -#else - #define _CONFIGURE_INTERRUPT_STACK_MEMORY \ - _Configure_From_workspace( CONFIGURE_INTERRUPT_STACK_SIZE ) -#endif - -/** - * Configure the very much optional task stack allocator initialization - */ -#ifndef CONFIGURE_TASK_STACK_ALLOCATOR_INIT - #define CONFIGURE_TASK_STACK_ALLOCATOR_INIT NULL -#endif - -/* - * Configure the very much optional task stack allocator and deallocator. - */ -#if !defined(CONFIGURE_TASK_STACK_ALLOCATOR) \ - && !defined(CONFIGURE_TASK_STACK_DEALLOCATOR) - /** - * This specifies the task stack allocator method. - */ - #define CONFIGURE_TASK_STACK_ALLOCATOR _Workspace_Allocate - /** - * This specifies the task stack deallocator method. - */ - #define CONFIGURE_TASK_STACK_DEALLOCATOR _Workspace_Free -#elif (defined(CONFIGURE_TASK_STACK_ALLOCATOR) \ - && !defined(CONFIGURE_TASK_STACK_DEALLOCATOR)) \ - || (!defined(CONFIGURE_TASK_STACK_ALLOCATOR) \ - && defined(CONFIGURE_TASK_STACK_DEALLOCATOR)) - #error "CONFIGURE_TASK_STACK_ALLOCATOR and CONFIGURE_TASK_STACK_DEALLOCATOR must be both defined or both undefined" -#endif -/**@}*/ /* end of thread/interrupt stack configuration */ - -/** - * @addtogroup Configuration - */ -/**@{*/ - -/** - * Should the RTEMS Workspace and C Program Heap be cleared automatically - * at system start up? - */ -#ifndef CONFIGURE_ZERO_WORKSPACE_AUTOMATICALLY - #ifdef BSP_ZERO_WORKSPACE_AUTOMATICALLY - #define CONFIGURE_ZERO_WORKSPACE_AUTOMATICALLY \ - BSP_ZERO_WORKSPACE_AUTOMATICALLY - #else - #define CONFIGURE_ZERO_WORKSPACE_AUTOMATICALLY FALSE - #endif -#endif -/**@}*/ /* end of add to group Configuration */ - -/** - * @defgroup ConfigurationMalloc RTEMS Malloc configuration - * - * This module contains parameters related to configuration of the RTEMS - * Malloc implementation. - */ -/**@{*/ -#include - -#ifdef CONFIGURE_INIT - /** - * By default, RTEMS uses separate heaps for the RTEMS Workspace and - * the C Program Heap. The application can choose optionally to combine - * these to provide one larger memory pool. This is particularly - * useful in combination with the unlimited objects configuration. - */ - #ifdef CONFIGURE_UNIFIED_WORK_AREAS - Heap_Control *RTEMS_Malloc_Heap = &_Workspace_Area; - #else - Heap_Control RTEMS_Malloc_Area; - Heap_Control *RTEMS_Malloc_Heap = &RTEMS_Malloc_Area; - #endif -#endif - -#ifdef CONFIGURE_INIT - /** - * This configures the sbrk() support for the malloc family. - * By default it is assumed that the BSP provides all available - * RAM to the malloc family implementation so sbrk()'ing to get - * more memory would always fail anyway. - */ - const rtems_heap_extend_handler rtems_malloc_extend_handler = - #ifdef CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK - rtems_heap_extend_via_sbrk; - #else - rtems_heap_null_extend; - #endif -#endif - -#ifdef CONFIGURE_INIT - /** - * This configures the malloc family plugin which dirties memory - * allocated. This is helpful for finding unitialized data structure - * problems. - */ - rtems_malloc_dirtier_t rtems_malloc_dirty_helper = - #if defined(CONFIGURE_MALLOC_DIRTY) - rtems_malloc_dirty_memory; - #else - NULL; - #endif -#endif -/**@}*/ /* end of Malloc Configuration */ - -/** - * @defgroup ConfigurationHelpers Configuration Helpers - * - * @ingroup Configuration - * - * This module contains items which are used internally to ease - * the configuration calculations. - */ -/**@{*/ - -/** - * Zero of one returns 0 if the parameter is 0 else 1 is returned. - */ -#define _Configure_Zero_or_One(_number) ((_number) ? 1 : 0) - -/** - * General helper to align up a value. - */ -#define _Configure_Align_up(_val, _align) \ - (((_val) + (_align) - 1) - ((_val) + (_align) - 1) % (_align)) - -#define _CONFIGURE_HEAP_MIN_BLOCK_SIZE \ - _Configure_Align_up(sizeof(Heap_Block), CPU_HEAP_ALIGNMENT) - -/** - * This is a helper macro used in calculations in this file. It is used - * to noted when an element is allocated from the RTEMS Workspace and adds - * a factor to account for heap overhead plus an alignment factor that - * may be applied. - */ -#define _Configure_From_workspace(_size) \ - (ssize_t) (_Configure_Zero_or_One(_size) * \ - _Configure_Align_up(_size + HEAP_BLOCK_HEADER_SIZE, \ - _CONFIGURE_HEAP_MIN_BLOCK_SIZE)) - -/** - * This is a helper macro used in stack space calculations in this file. It - * may be provided by the application in case a special task stack allocator - * is used. The default is allocation from the RTEMS Workspace. - */ -#ifdef CONFIGURE_TASK_STACK_FROM_ALLOCATOR - #define _Configure_From_stackspace(_stack_size) \ - CONFIGURE_TASK_STACK_FROM_ALLOCATOR(_stack_size) -#else - #define _Configure_From_stackspace(_stack_size) \ - _Configure_From_workspace(_stack_size) -#endif - -/** - * Do not use the unlimited bit as part of the multiplication - * for memory usage. - */ -#define _Configure_Max_Objects(_max) \ - (_Configure_Zero_or_One(_max) * rtems_resource_maximum_per_allocation(_max)) - -/** - * This macro accounts for how memory for a set of configured objects is - * allocated from the Executive Workspace. - * - * NOTE: It does NOT attempt to address the more complex case of unlimited - * objects. - */ -#define _Configure_Object_RAM(_number, _size) ( \ - _Configure_From_workspace(_Configure_Max_Objects(_number) * (_size)) + \ - _Configure_From_workspace( \ - _Configure_Zero_or_One(_number) * ( \ - (_Configure_Max_Objects(_number) + 1) * sizeof(Objects_Control *) + \ - _Configure_Align_up(sizeof(void *), CPU_ALIGNMENT) + \ - _Configure_Align_up(sizeof(uint32_t), CPU_ALIGNMENT) \ - ) \ - ) \ - ) -/**@}*/ - -/** - * @defgroup ConfigurationInitTasksTable Initialization Tasks Configuration - * - * @addtogroup Configuration - * - * This group contains the elements needed to define the Classic API - * Initialization Tasks Table. - * - * Default User Initialization Task Table. This table guarantees that - * one user initialization table is defined. - */ -#ifdef CONFIGURE_RTEMS_INIT_TASKS_TABLE - -#ifdef CONFIGURE_HAS_OWN_INIT_TASK_TABLE - -/* - * The user is defining their own table information and setting the - * appropriate variables. - */ - -#else - -/** - * When using the default Classic API Initialization Tasks Table, this is - * used to specify the name of the single Classic API task. - */ -#ifndef CONFIGURE_INIT_TASK_NAME - #define CONFIGURE_INIT_TASK_NAME rtems_build_name('U', 'I', '1', ' ') -#endif - -/** - * When using the default Classic API Initialization Tasks Table, this is - * used to specify the stack size of the single Classic API task. - */ -#ifndef CONFIGURE_INIT_TASK_STACK_SIZE - #define CONFIGURE_INIT_TASK_STACK_SIZE CONFIGURE_MINIMUM_TASK_STACK_SIZE -#endif - -/** - * When using the default Classic API Initialization Tasks Table, this is - * used to specify the priority of the single Classic API task. - */ -#ifndef CONFIGURE_INIT_TASK_PRIORITY - #define CONFIGURE_INIT_TASK_PRIORITY 1 -#endif - -/** - * When using the default Classic API Initialization Tasks Table, this is - * used to specify the attributes size of the single Classic API task. - */ -#ifndef CONFIGURE_INIT_TASK_ATTRIBUTES - #define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_DEFAULT_ATTRIBUTES -#endif - -/** - * When using the default Classic API Initialization Tasks Table, this is - * used to specify the entry point of the single Classic API task. - */ -#ifndef CONFIGURE_INIT_TASK_ENTRY_POINT - #ifdef __cplusplus - extern "C" { - #endif - rtems_task Init (rtems_task_argument ); - #ifdef __cplusplus - } - #endif - #define CONFIGURE_INIT_TASK_ENTRY_POINT Init - extern const char* bsp_boot_cmdline; - #define CONFIGURE_INIT_TASK_ARGUMENTS ((rtems_task_argument) &bsp_boot_cmdline) -#endif - -/** - * When using the default Classic API Initialization Tasks Table, this is - * used to specify the initial execution mode of the single Classic API task. - */ -#ifndef CONFIGURE_INIT_TASK_INITIAL_MODES - #ifdef _CONFIGURE_SMP_APPLICATION - #define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_DEFAULT_MODES - #else - #define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_NO_PREEMPT - #endif -#endif - -/** - * When using the default Classic API Initialization Tasks Table, this is - * used to specify the initial argument to the single Classic API task. - */ -#ifndef CONFIGURE_INIT_TASK_ARGUMENTS - #define CONFIGURE_INIT_TASK_ARGUMENTS 0 -#endif - -#ifdef CONFIGURE_INIT - rtems_initialization_tasks_table Initialization_tasks[] = { - { CONFIGURE_INIT_TASK_NAME, - CONFIGURE_INIT_TASK_STACK_SIZE, - CONFIGURE_INIT_TASK_PRIORITY, - CONFIGURE_INIT_TASK_ATTRIBUTES, - CONFIGURE_INIT_TASK_ENTRY_POINT, - CONFIGURE_INIT_TASK_INITIAL_MODES, - CONFIGURE_INIT_TASK_ARGUMENTS - } - }; -#endif - -/** - * This is the name of the Initialization Tasks Table generated. - */ -#define CONFIGURE_INIT_TASK_TABLE Initialization_tasks - -/* - * This is the size of the Initialization Tasks Table generated. - */ -#define CONFIGURE_INIT_TASK_TABLE_SIZE \ - RTEMS_ARRAY_SIZE(CONFIGURE_INIT_TASK_TABLE) - -#endif /* CONFIGURE_HAS_OWN_INIT_TASK_TABLE */ - -#else /* CONFIGURE_RTEMS_INIT_TASKS_TABLE */ - -/* - * This is the name of the Initialization Task when none is configured. - */ -#define CONFIGURE_INIT_TASK_TABLE NULL - -/* - * This is the size of the Initialization Task when none is configured. - */ -#define CONFIGURE_INIT_TASK_TABLE_SIZE 0 - -/* - * This is the stack size of the Initialization Task when none is configured. - */ -#define CONFIGURE_INIT_TASK_STACK_SIZE 0 - -#endif -/**@}*/ /* end of Classic API Initialization Tasks Table */ - -/** - * @defgroup ConfigurationDriverTable Device Driver Table Configuration - * - * @addtogroup Configuration - * - * This group contains parameters related to generating a Device Driver - * Table. - * - * Default Device Driver Table. Each driver needed by the test is explicitly - * choosen by the application. There is always a null driver entry. - */ -/**@{*/ - -/** - * This is an empty device driver slot. - */ -#define NULL_DRIVER_TABLE_ENTRY \ - { NULL, NULL, NULL, NULL, NULL, NULL } - -#if defined(CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER) && \ - defined(CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER) -#error "CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER and CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER are mutually exclusive" -#endif - -#ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER - #include -#endif - -#ifdef CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER - #include - - #ifdef CONFIGURE_INIT - RTEMS_SYSINIT_ITEM( - _Console_simple_Initialize, - RTEMS_SYSINIT_DEVICE_DRIVERS, - RTEMS_SYSINIT_ORDER_SECOND - ); - #endif -#endif - -#ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER - #include -#endif - -#ifdef CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER - #include -#endif - -#ifdef CONFIGURE_APPLICATION_NEEDS_RTC_DRIVER - #include -#endif - -#ifdef CONFIGURE_APPLICATION_NEEDS_WATCHDOG_DRIVER - #include -#endif - -#ifdef CONFIGURE_APPLICATION_NEEDS_FRAME_BUFFER_DRIVER - #include -#endif - -#ifdef CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER - #include -#endif - -#ifdef CONFIGURE_APPLICATION_NEEDS_ZERO_DRIVER - #include -#endif - -#ifdef CONFIGURE_APPLICATION_NEEDS_IDE_DRIVER - /* the ide driver needs the ATA driver */ - #ifndef CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER - #define CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER - #endif - #include -#endif - -#ifdef CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER - #include -#endif - -#ifndef CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE - -/** - * This specifies the maximum number of device drivers that - * can be installed in the system at one time. It must account - * for both the statically and dynamically installed drivers. - */ -#ifndef CONFIGURE_MAXIMUM_DRIVERS - #define CONFIGURE_MAXIMUM_DRIVERS -#endif - -#ifdef CONFIGURE_INIT - rtems_driver_address_table - _IO_Driver_address_table[ CONFIGURE_MAXIMUM_DRIVERS ] = { - #ifdef CONFIGURE_BSP_PREREQUISITE_DRIVERS - CONFIGURE_BSP_PREREQUISITE_DRIVERS, - #endif - #ifdef CONFIGURE_APPLICATION_PREREQUISITE_DRIVERS - CONFIGURE_APPLICATION_PREREQUISITE_DRIVERS, - #endif - #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER - CONSOLE_DRIVER_TABLE_ENTRY, - #endif - #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER - CLOCK_DRIVER_TABLE_ENTRY, - #endif - #ifdef CONFIGURE_APPLICATION_NEEDS_RTC_DRIVER - RTC_DRIVER_TABLE_ENTRY, - #endif - #ifdef CONFIGURE_APPLICATION_NEEDS_WATCHDOG_DRIVER - WATCHDOG_DRIVER_TABLE_ENTRY, - #endif - #ifdef CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER - DEVNULL_DRIVER_TABLE_ENTRY, - #endif - #ifdef CONFIGURE_APPLICATION_NEEDS_ZERO_DRIVER - DEVZERO_DRIVER_TABLE_ENTRY, - #endif - #ifdef CONFIGURE_APPLICATION_NEEDS_IDE_DRIVER - IDE_CONTROLLER_DRIVER_TABLE_ENTRY, - #endif - #ifdef CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER - ATA_DRIVER_TABLE_ENTRY, - #endif - #ifdef CONFIGURE_APPLICATION_NEEDS_FRAME_BUFFER_DRIVER - FRAME_BUFFER_DRIVER_TABLE_ENTRY, - #endif - #ifdef CONFIGURE_APPLICATION_EXTRA_DRIVERS - CONFIGURE_APPLICATION_EXTRA_DRIVERS, - #endif - #ifdef CONFIGURE_APPLICATION_NEEDS_NULL_DRIVER - NULL_DRIVER_TABLE_ENTRY - #elif !defined(CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER) && \ - !defined(CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER) && \ - !defined(CONFIGURE_APPLICATION_NEEDS_RTC_DRIVER) && \ - !defined(CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER) && \ - !defined(CONFIGURE_APPLICATION_NEEDS_ZERO_DRIVER) && \ - !defined(CONFIGURE_APPLICATION_NEEDS_IDE_DRIVER) && \ - !defined(CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER) && \ - !defined(CONFIGURE_APPLICATION_NEEDS_FRAME_BUFFER_DRIVER) && \ - !defined(CONFIGURE_APPLICATION_EXTRA_DRIVERS) - NULL_DRIVER_TABLE_ENTRY - #endif - }; - - const size_t _IO_Number_of_drivers = - RTEMS_ARRAY_SIZE( _IO_Driver_address_table ); -#endif - -#endif /* CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE */ - -#ifdef CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER - /* - * configure the priority of the ATA driver task - */ - #ifndef CONFIGURE_ATA_DRIVER_TASK_PRIORITY - #define CONFIGURE_ATA_DRIVER_TASK_PRIORITY ATA_DRIVER_TASK_DEFAULT_PRIORITY - #endif - #ifdef CONFIGURE_INIT - rtems_task_priority rtems_ata_driver_task_priority - = CONFIGURE_ATA_DRIVER_TASK_PRIORITY; - #endif /* CONFIGURE_INIT */ -#endif -/**@}*/ /* end of Device Driver Table Configuration */ - -/** - * @defgroup ConfigurationLibBlock Configuration of LIBBLOCK - * - * @addtogroup Configuration - * - * This module contains parameters related to the LIBBLOCK buffering - * and caching subsystem. It requires tasks to swap out data to be - * written to non-volatile storage. - */ -/**@{*/ -#ifdef CONFIGURE_APPLICATION_NEEDS_LIBBLOCK - #include - /* - * configure the bdbuf cache parameters - */ - #ifndef CONFIGURE_BDBUF_MAX_READ_AHEAD_BLOCKS - #define CONFIGURE_BDBUF_MAX_READ_AHEAD_BLOCKS \ - RTEMS_BDBUF_MAX_READ_AHEAD_BLOCKS_DEFAULT - #endif - #ifndef CONFIGURE_BDBUF_MAX_WRITE_BLOCKS - #define CONFIGURE_BDBUF_MAX_WRITE_BLOCKS \ - RTEMS_BDBUF_MAX_WRITE_BLOCKS_DEFAULT - #endif - #ifndef CONFIGURE_SWAPOUT_TASK_PRIORITY - #define CONFIGURE_SWAPOUT_TASK_PRIORITY \ - RTEMS_BDBUF_SWAPOUT_TASK_PRIORITY_DEFAULT - #endif - #ifndef CONFIGURE_SWAPOUT_SWAP_PERIOD - #define CONFIGURE_SWAPOUT_SWAP_PERIOD \ - RTEMS_BDBUF_SWAPOUT_TASK_SWAP_PERIOD_DEFAULT - #endif - #ifndef CONFIGURE_SWAPOUT_BLOCK_HOLD - #define CONFIGURE_SWAPOUT_BLOCK_HOLD \ - RTEMS_BDBUF_SWAPOUT_TASK_BLOCK_HOLD_DEFAULT - #endif - #ifndef CONFIGURE_SWAPOUT_WORKER_TASKS - #define CONFIGURE_SWAPOUT_WORKER_TASKS \ - RTEMS_BDBUF_SWAPOUT_WORKER_TASKS_DEFAULT - #endif - #ifndef CONFIGURE_SWAPOUT_WORKER_TASK_PRIORITY - #define CONFIGURE_SWAPOUT_WORKER_TASK_PRIORITY \ - RTEMS_BDBUF_SWAPOUT_WORKER_TASK_PRIORITY_DEFAULT - #endif - #ifndef CONFIGURE_BDBUF_TASK_STACK_SIZE - #define CONFIGURE_BDBUF_TASK_STACK_SIZE \ - RTEMS_BDBUF_TASK_STACK_SIZE_DEFAULT - #endif - #ifndef CONFIGURE_BDBUF_CACHE_MEMORY_SIZE - #define CONFIGURE_BDBUF_CACHE_MEMORY_SIZE \ - RTEMS_BDBUF_CACHE_MEMORY_SIZE_DEFAULT - #endif - #ifndef CONFIGURE_BDBUF_BUFFER_MIN_SIZE - #define CONFIGURE_BDBUF_BUFFER_MIN_SIZE \ - RTEMS_BDBUF_BUFFER_MIN_SIZE_DEFAULT - #endif - #ifndef CONFIGURE_BDBUF_BUFFER_MAX_SIZE - #define CONFIGURE_BDBUF_BUFFER_MAX_SIZE \ - RTEMS_BDBUF_BUFFER_MAX_SIZE_DEFAULT - #endif - #ifndef CONFIGURE_BDBUF_READ_AHEAD_TASK_PRIORITY - #define CONFIGURE_BDBUF_READ_AHEAD_TASK_PRIORITY \ - RTEMS_BDBUF_READ_AHEAD_TASK_PRIORITY_DEFAULT - #endif - #ifdef CONFIGURE_INIT - const rtems_bdbuf_config rtems_bdbuf_configuration = { - CONFIGURE_BDBUF_MAX_READ_AHEAD_BLOCKS, - CONFIGURE_BDBUF_MAX_WRITE_BLOCKS, - CONFIGURE_SWAPOUT_TASK_PRIORITY, - CONFIGURE_SWAPOUT_SWAP_PERIOD, - CONFIGURE_SWAPOUT_BLOCK_HOLD, - CONFIGURE_SWAPOUT_WORKER_TASKS, - CONFIGURE_SWAPOUT_WORKER_TASK_PRIORITY, - CONFIGURE_BDBUF_TASK_STACK_SIZE, - CONFIGURE_BDBUF_CACHE_MEMORY_SIZE, - CONFIGURE_BDBUF_BUFFER_MIN_SIZE, - CONFIGURE_BDBUF_BUFFER_MAX_SIZE, - CONFIGURE_BDBUF_READ_AHEAD_TASK_PRIORITY - }; - #endif - - #define _CONFIGURE_LIBBLOCK_TASKS \ - (1 + CONFIGURE_SWAPOUT_WORKER_TASKS + \ - (CONFIGURE_BDBUF_MAX_READ_AHEAD_BLOCKS != 0)) - - #define _CONFIGURE_LIBBLOCK_TASK_EXTRA_STACKS \ - (_CONFIGURE_LIBBLOCK_TASKS * \ - (CONFIGURE_BDBUF_TASK_STACK_SIZE <= CONFIGURE_MINIMUM_TASK_STACK_SIZE ? \ - 0 : CONFIGURE_BDBUF_TASK_STACK_SIZE - CONFIGURE_MINIMUM_TASK_STACK_SIZE)) - - #ifdef RTEMS_BDBUF_USE_PTHREAD - /* - * Semaphores: - * o disk lock - */ - #define _CONFIGURE_LIBBLOCK_SEMAPHORES 1 - #else - /* - * Semaphores: - * o disk lock - * o bdbuf lock - * o bdbuf sync lock - * o bdbuf access condition - * o bdbuf transfer condition - * o bdbuf buffer condition - */ - #define _CONFIGURE_LIBBLOCK_SEMAPHORES 6 - #endif - - #if defined(CONFIGURE_HAS_OWN_BDBUF_TABLE) || \ - defined(CONFIGURE_BDBUF_BUFFER_SIZE) || \ - defined(CONFIGURE_BDBUF_BUFFER_COUNT) - #error BDBUF Cache does not use a buffer configuration table. Please remove. - #endif -#else - /** This specifies the number of libblock tasks. */ - #define _CONFIGURE_LIBBLOCK_TASKS 0 - /** This specifies the extra stack space configured for libblock tasks. */ - #define _CONFIGURE_LIBBLOCK_TASK_EXTRA_STACKS 0 - /** This specifies the number of Classic API semaphores needed by libblock. */ - #define _CONFIGURE_LIBBLOCK_SEMAPHORES 0 -#endif /* CONFIGURE_APPLICATION_NEEDS_LIBBLOCK */ -/**@}*/ - -/** - * @defgroup ConfigurationMultiprocessing Multiprocessing Configuration - * - * @addtogroup Configuration - * - * This module contains the parameters related to the Multiprocessing - * configuration of RTEMS. - * - * In a single processor or SMP configuration, only two parameters are - * needed and they are defaulted. The user should not have to specify - * any parameters. - */ -/**@{*/ - -/** - * This defines the extra stack space required for the MPCI server thread. - */ -#ifndef CONFIGURE_EXTRA_MPCI_RECEIVE_SERVER_STACK - #define CONFIGURE_EXTRA_MPCI_RECEIVE_SERVER_STACK 0 -#endif - -/** - * This defines the timers required for the shared memory driver in - * a multiprocessing configuration. - */ -#ifndef _CONFIGURE_TIMER_FOR_SHARED_MEMORY_DRIVER - #define _CONFIGURE_TIMER_FOR_SHARED_MEMORY_DRIVER 0 -#endif - - -#if defined(RTEMS_MULTIPROCESSING) - /* - * Default Multiprocessing Configuration Table. The defaults are - * appropriate for most of the RTEMS Multiprocessor Test Suite. Each - * value may be overridden within each test to customize the environment. - */ - - #ifdef CONFIGURE_MP_APPLICATION - #define _CONFIGURE_TIMER_FOR_SHARED_MEMORY_DRIVER 1 - - #ifndef CONFIGURE_HAS_OWN_MULTIPROCESSING_TABLE - - #ifndef CONFIGURE_MP_NODE_NUMBER - #define CONFIGURE_MP_NODE_NUMBER NODE_NUMBER - #endif - - #ifndef CONFIGURE_MP_MAXIMUM_NODES - #define CONFIGURE_MP_MAXIMUM_NODES 2 - #endif - - #ifndef CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS - #define CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS 32 - #endif - #define _CONFIGURE_MEMORY_FOR_GLOBAL_OBJECTS(_global_objects) \ - _Configure_From_workspace( \ - (_global_objects) * sizeof(Objects_MP_Control) \ - ) - - #ifndef CONFIGURE_MP_MAXIMUM_PROXIES - #define CONFIGURE_MP_MAXIMUM_PROXIES 32 - #endif - #define _CONFIGURE_MEMORY_FOR_PROXIES(_proxies) \ - _Configure_From_workspace((_proxies) \ - * (sizeof(Thread_Proxy_control) \ - + THREAD_QUEUE_HEADS_SIZE(CONFIGURE_SCHEDULER_COUNT))) - - #ifndef CONFIGURE_MP_MPCI_TABLE_POINTER - #include - #define CONFIGURE_MP_MPCI_TABLE_POINTER &MPCI_table - #endif - - #ifdef CONFIGURE_INIT - rtems_multiprocessing_table Multiprocessing_configuration = { - CONFIGURE_MP_NODE_NUMBER, /* local node number */ - CONFIGURE_MP_MAXIMUM_NODES, /* maximum # nodes */ - CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS, /* maximum # global objects */ - CONFIGURE_MP_MAXIMUM_PROXIES, /* maximum # proxies */ - CONFIGURE_EXTRA_MPCI_RECEIVE_SERVER_STACK, /* MPCI stack > minimum */ - CONFIGURE_MP_MPCI_TABLE_POINTER /* ptr to MPCI config table */ - }; - #endif - - #define CONFIGURE_MULTIPROCESSING_TABLE &Multiprocessing_configuration - - #define _CONFIGURE_MPCI_RECEIVE_SERVER_COUNT 1 - - #endif /* CONFIGURE_HAS_OWN_MULTIPROCESSING_TABLE */ - - #else - - #define CONFIGURE_MULTIPROCESSING_TABLE NULL - - #define _CONFIGURE_MPCI_RECEIVE_SERVER_COUNT 0 - - #endif /* CONFIGURE_MP_APPLICATION */ -#else - #define _CONFIGURE_MPCI_RECEIVE_SERVER_COUNT 0 -#endif /* RTEMS_MULTIPROCESSING */ -/**@}*/ /* end of Multiprocessing Configuration */ - -/** - * This macro specifies that the user wants to use unlimited objects for any - * classic or posix objects that have not already been given resource limits. - */ -#if defined(CONFIGURE_UNLIMITED_OBJECTS) - #if !defined(CONFIGURE_UNIFIED_WORK_AREAS) && \ - !defined(CONFIGURE_EXECUTIVE_RAM_SIZE) && \ - !defined(CONFIGURE_MEMORY_OVERHEAD) - #error "CONFIGURE_UNLIMITED_OBJECTS requires a unified work area, an executive RAM size, or a defined workspace memory overhead" - #endif - - #if !defined(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) - /** - * This macro specifies a default allocation size for when auto-extending - * unlimited objects if none was given by the user. - */ - #define CONFIGURE_UNLIMITED_ALLOCATION_SIZE 8 - #endif - #if !defined(CONFIGURE_MAXIMUM_TASKS) - #define CONFIGURE_MAXIMUM_TASKS \ - rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) - #endif - #if !defined(CONFIGURE_MAXIMUM_TIMERS) - #define CONFIGURE_MAXIMUM_TIMERS \ - rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) - #endif - #if !defined(CONFIGURE_MAXIMUM_SEMAPHORES) - #define CONFIGURE_MAXIMUM_SEMAPHORES \ - rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) - #endif - #if !defined(CONFIGURE_MAXIMUM_MESSAGE_QUEUES) - #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES \ - rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) - #endif - #if !defined(CONFIGURE_MAXIMUM_PARTITIONS) - #define CONFIGURE_MAXIMUM_PARTITIONS \ - rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) - #endif - #if !defined(CONFIGURE_MAXIMUM_REGIONS) - #define CONFIGURE_MAXIMUM_REGIONS \ - rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) - #endif - #if !defined(CONFIGURE_MAXIMUM_PORTS) - #define CONFIGURE_MAXIMUM_PORTS \ - rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) - #endif - #if !defined(CONFIGURE_MAXIMUM_PERIODS) - #define CONFIGURE_MAXIMUM_PERIODS \ - rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) - #endif - #if !defined(CONFIGURE_MAXIMUM_BARRIERS) - #define CONFIGURE_MAXIMUM_BARRIERS \ - rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) - #endif - #if !defined(CONFIGURE_MAXIMUM_POSIX_KEYS) - #define CONFIGURE_MAXIMUM_POSIX_KEYS \ - rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) - #endif - #if !defined(CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS) - #define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS \ - rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) - #endif - - #ifdef RTEMS_POSIX_API - #if !defined(CONFIGURE_MAXIMUM_POSIX_THREADS) - #define CONFIGURE_MAXIMUM_POSIX_THREADS \ - rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) - #endif - #if !defined(CONFIGURE_MAXIMUM_POSIX_TIMERS) - #define CONFIGURE_MAXIMUM_POSIX_TIMERS \ - rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) - #endif -/* - #if !defined(CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS) - #define CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS \ - rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) - #endif -*/ - #if !defined(CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES) - #define CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES \ - rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) - #endif - #if !defined(CONFIGURE_MAXIMUM_POSIX_SEMAPHORES) - #define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES \ - rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) - #endif - #if !defined(CONFIGURE_MAXIMUM_POSIX_SHMS) - #define CONFIGURE_MAXIMUM_POSIX_SHMS \ - rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE) - #endif - #endif /* RTEMS_POSIX_API */ -#endif /* CONFIGURE_UNLIMITED_OBJECTS */ - - -/** - * @defgroup ConfigurationClassicAPI Classic API Configuration - * - * @ingroup Configuration - * - * This module contains the parameters related to configuration - * of the Classic API services. - */ -/**@{*/ -#ifndef CONFIGURE_HAS_OWN_CONFIGURATION_TABLE - - /** This configures the maximum number of Classic API tasks. */ - #ifndef CONFIGURE_MAXIMUM_TASKS - #define CONFIGURE_MAXIMUM_TASKS 0 - #endif - - /* - * This is calculated to account for the maximum number of Classic API - * tasks used by the application and configured RTEMS capabilities. - */ - #define _CONFIGURE_TASKS \ - (CONFIGURE_MAXIMUM_TASKS + _CONFIGURE_LIBBLOCK_TASKS) - - #ifndef CONFIGURE_MAXIMUM_TIMERS - /** This specifies the maximum number of Classic API timers. */ - #define CONFIGURE_MAXIMUM_TIMERS 0 - /* - * This macro is calculated to specify the memory required for - * Classic API timers. - */ - #define _CONFIGURE_MEMORY_FOR_TIMERS(_timers) 0 - #else - #define _CONFIGURE_MEMORY_FOR_TIMERS(_timers) \ - _Configure_Object_RAM(_timers, sizeof(Timer_Control) ) - #endif - - #ifndef CONFIGURE_MAXIMUM_SEMAPHORES - /** This specifies the maximum number of Classic API semaphores. */ - #define CONFIGURE_MAXIMUM_SEMAPHORES 0 - #endif - - /* - * This specifies the number of Classic API semaphores required - */ - #ifdef RTEMS_NETWORKING - #define _CONFIGURE_NETWORKING_SEMAPHORES 1 - #else - #define _CONFIGURE_NETWORKING_SEMAPHORES 0 - #endif - - /* - * This macro is calculated to specify the number of Classic API - * semaphores required by the application and configured RTEMS - * capabilities. - */ - #define _CONFIGURE_SEMAPHORES \ - (CONFIGURE_MAXIMUM_SEMAPHORES + \ - _CONFIGURE_TERMIOS_SEMAPHORES + _CONFIGURE_LIBBLOCK_SEMAPHORES + \ - _CONFIGURE_SEMAPHORES_FOR_FILE_SYSTEMS + \ - _CONFIGURE_NETWORKING_SEMAPHORES) - - /* - * This macro is calculated to specify the memory required for - * Classic API Semaphores using MRSP. This is only available in - * SMP configurations. - */ - #if !defined(RTEMS_SMP) || \ - !defined(CONFIGURE_MAXIMUM_MRSP_SEMAPHORES) - #define _CONFIGURE_MEMORY_FOR_MRSP_SEMAPHORES 0 - #else - #define _CONFIGURE_MEMORY_FOR_MRSP_SEMAPHORES \ - CONFIGURE_MAXIMUM_MRSP_SEMAPHORES * \ - _Configure_From_workspace( \ - RTEMS_ARRAY_SIZE(_Scheduler_Table) * sizeof(Priority_Control) \ - ) - #endif - - /* - * This macro is calculated to specify the memory required for - * Classic API Semaphores. - * - * If there are no user or support semaphores defined, then we can assume - * that no memory need be allocated at all for semaphores. - */ - #if _CONFIGURE_SEMAPHORES == 0 - #define _CONFIGURE_MEMORY_FOR_SEMAPHORES(_semaphores) 0 - #else - #define _CONFIGURE_MEMORY_FOR_SEMAPHORES(_semaphores) \ - _Configure_Object_RAM(_semaphores, sizeof(Semaphore_Control) ) + \ - _CONFIGURE_MEMORY_FOR_MRSP_SEMAPHORES - #endif - - #ifndef CONFIGURE_MAXIMUM_MESSAGE_QUEUES - /** - * This configuration parameter specifies the maximum number of - * Classic API Message Queues. - */ - #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 0 - /* - * This macro is calculated to specify the RTEMS Workspace required for - * the Classic API Message Queues. - */ - #define _CONFIGURE_MEMORY_FOR_MESSAGE_QUEUES(_queues) 0 - #else - #define _CONFIGURE_MEMORY_FOR_MESSAGE_QUEUES(_queues) \ - _Configure_Object_RAM(_queues, sizeof(Message_queue_Control) ) - #endif - - #ifndef CONFIGURE_MAXIMUM_PARTITIONS - /** - * This configuration parameter specifies the maximum number of - * Classic API Partitions. - */ - #define CONFIGURE_MAXIMUM_PARTITIONS 0 - /* - * This macro is calculated to specify the memory required for - * Classic API - */ - #define _CONFIGURE_MEMORY_FOR_PARTITIONS(_partitions) 0 - #else - #define _CONFIGURE_MEMORY_FOR_PARTITIONS(_partitions) \ - _Configure_Object_RAM(_partitions, sizeof(Partition_Control) ) - #endif - - #ifndef CONFIGURE_MAXIMUM_REGIONS - /** - * This configuration parameter specifies the maximum number of - * Classic API Regions. - */ - #define CONFIGURE_MAXIMUM_REGIONS 0 - /* - * This macro is calculated to specify the memory required for - * Classic API Regions. - */ - #define _CONFIGURE_MEMORY_FOR_REGIONS(_regions) 0 - #else - #define _CONFIGURE_MEMORY_FOR_REGIONS(_regions) \ - _Configure_Object_RAM(_regions, sizeof(Region_Control) ) - #endif - - #ifndef CONFIGURE_MAXIMUM_PORTS - /** - * This configuration parameter specifies the maximum number of - * Classic API Dual-Ported Memory Ports. - */ - #define CONFIGURE_MAXIMUM_PORTS 0 - /** - * This macro is calculated to specify the memory required for - * Classic API Dual-Ported Memory Ports. - */ - #define _CONFIGURE_MEMORY_FOR_PORTS(_ports) 0 - #else - #define _CONFIGURE_MEMORY_FOR_PORTS(_ports) \ - _Configure_Object_RAM(_ports, sizeof(Dual_ported_memory_Control) ) - #endif - - #ifndef CONFIGURE_MAXIMUM_PERIODS - /** - * This configuration parameter specifies the maximum number of - * Classic API Rate Monotonic Periods. - */ - #define CONFIGURE_MAXIMUM_PERIODS 0 - /* - * This macro is calculated to specify the memory required for - * Classic API Rate Monotonic Periods. - */ - #define _CONFIGURE_MEMORY_FOR_PERIODS(_periods) 0 -#else - #define _CONFIGURE_MEMORY_FOR_PERIODS(_periods) \ - _Configure_Object_RAM(_periods, sizeof(Rate_monotonic_Control) ) - #endif - - /** - * This configuration parameter specifies the maximum number of - * Classic API Barriers. - */ - #ifndef CONFIGURE_MAXIMUM_BARRIERS - #define CONFIGURE_MAXIMUM_BARRIERS 0 - #endif - - /* - * This macro is calculated to specify the number of Classic API - * Barriers required by the application and configured capabilities. - */ - #define _CONFIGURE_BARRIERS \ - (CONFIGURE_MAXIMUM_BARRIERS + _CONFIGURE_BARRIERS_FOR_FIFOS) - - /* - * This macro is calculated to specify the memory required for - * Classic API Barriers. - */ - #if _CONFIGURE_BARRIERS == 0 - #define _CONFIGURE_MEMORY_FOR_BARRIERS(_barriers) 0 - #else - #define _CONFIGURE_MEMORY_FOR_BARRIERS(_barriers) \ - _Configure_Object_RAM(_barriers, sizeof(Barrier_Control) ) - #endif - - #ifndef CONFIGURE_MAXIMUM_USER_EXTENSIONS - /** - * This configuration parameter specifies the maximum number of - * Classic API User Extensions. - */ - #define CONFIGURE_MAXIMUM_USER_EXTENSIONS 0 - /* - * This macro is calculated to specify the memory required for - * Classic API User Extensions. - */ - #define _CONFIGURE_MEMORY_FOR_USER_EXTENSIONS(_extensions) 0 - #else - #define _CONFIGURE_MEMORY_FOR_USER_EXTENSIONS(_extensions) \ - _Configure_Object_RAM(_extensions, sizeof(Extension_Control) ) - #endif - /**@}*/ /* end of Classic API Configuration */ - - /** - * @defgroup ConfigurationGeneral General System Configuration - * - * @ingroup Configuration - * - * This module contains configuration parameters that are independent - * of any API but impact general system configuration. - */ - /**@{*/ - - /** The configures the number of microseconds per clock tick. */ - #ifndef CONFIGURE_MICROSECONDS_PER_TICK - #define CONFIGURE_MICROSECONDS_PER_TICK \ - RTEMS_MILLISECONDS_TO_MICROSECONDS(10) - #endif - - #if 1000000 % CONFIGURE_MICROSECONDS_PER_TICK != 0 - #warning "The clock ticks per second is not an integer" - #endif - - #if CONFIGURE_MICROSECONDS_PER_TICK <= 0 - #error "The CONFIGURE_MICROSECONDS_PER_TICK must be positive" - #endif - - #define _CONFIGURE_TICKS_PER_SECOND (1000000 / CONFIGURE_MICROSECONDS_PER_TICK) - - /** The configures the number of clock ticks per timeslice. */ - #ifndef CONFIGURE_TICKS_PER_TIMESLICE - #define CONFIGURE_TICKS_PER_TIMESLICE 50 - #endif - -/**@}*/ /* end of General Configuration */ - -/* - * Initial Extension Set - */ - -#ifdef CONFIGURE_INIT -#ifdef CONFIGURE_STACK_CHECKER_ENABLED -#include -#endif -#include - -#if defined(BSP_INITIAL_EXTENSION) || \ - defined(CONFIGURE_INITIAL_EXTENSIONS) || \ - defined(CONFIGURE_STACK_CHECKER_ENABLED) || \ - (defined(RTEMS_NEWLIB) && !defined(CONFIGURE_DISABLE_NEWLIB_REENTRANCY)) - static const rtems_extensions_table Configuration_Initial_Extensions[] = { - #if !defined(CONFIGURE_DISABLE_NEWLIB_REENTRANCY) - RTEMS_NEWLIB_EXTENSION, - #endif - #if defined(CONFIGURE_STACK_CHECKER_ENABLED) - RTEMS_STACK_CHECKER_EXTENSION, - #endif - #if defined(CONFIGURE_INITIAL_EXTENSIONS) - CONFIGURE_INITIAL_EXTENSIONS, - #endif - #if defined(BSP_INITIAL_EXTENSION) - BSP_INITIAL_EXTENSION - #endif - }; - - #define CONFIGURE_INITIAL_EXTENSION_TABLE Configuration_Initial_Extensions - #define _CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS \ - RTEMS_ARRAY_SIZE(Configuration_Initial_Extensions) - - RTEMS_SYSINIT_ITEM( - _User_extensions_Handler_initialization, - RTEMS_SYSINIT_INITIAL_EXTENSIONS, - RTEMS_SYSINIT_ORDER_MIDDLE - ); -#else - #define CONFIGURE_INITIAL_EXTENSION_TABLE NULL - #define _CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS 0 -#endif - -#if defined(RTEMS_NEWLIB) - struct _reent *__getreent(void) - { - #ifdef CONFIGURE_DISABLE_NEWLIB_REENTRANCY - return _GLOBAL_REENT; - #else - return _Thread_Get_executing()->libc_reent; - #endif - } -#endif - -#endif - -/** - * @defgroup ConfigurationPOSIXAPI POSIX API Configuration Parameters - * - * This module contains the parameters related to configuration - * of the POSIX API services. - */ -/**@{*/ - -#include - -/** - * This configuration parameter specifies the maximum number of - * POSIX API keys. - * - * POSIX Keys are available whether or not the POSIX API is enabled. - */ -#ifndef CONFIGURE_MAXIMUM_POSIX_KEYS - #define CONFIGURE_MAXIMUM_POSIX_KEYS 0 -#endif - -/* - * This macro is calculated to specify the memory required for - * POSIX API key/value pairs. - */ -#ifndef CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS - #define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS \ - (CONFIGURE_MAXIMUM_POSIX_KEYS * \ - (CONFIGURE_MAXIMUM_POSIX_THREADS + CONFIGURE_MAXIMUM_TASKS)) -#endif - -/* - * This macro is calculated to specify the total number of - * POSIX API keys required by the application and configured - * system capabilities. - */ -#define _CONFIGURE_POSIX_KEYS \ - (CONFIGURE_MAXIMUM_POSIX_KEYS + _CONFIGURE_LIBIO_POSIX_KEYS) - -/* - * This macro is calculated to specify the memory required for - * POSIX API keys. - */ -#define _CONFIGURE_MEMORY_FOR_POSIX_KEYS(_keys, _key_value_pairs) \ - (_Configure_Object_RAM(_keys, sizeof(POSIX_Keys_Control) ) \ - + _Configure_From_workspace( \ - _Configure_Max_Objects(_key_value_pairs) \ - * sizeof(POSIX_Keys_Key_value_pair))) - -/* - * The rest of the POSIX threads API features are only available when - * POSIX is enabled. - */ -#ifdef RTEMS_POSIX_API - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - - /* - * Account for the object control structures plus the name - * of the object to be duplicated. - */ - #define _Configure_POSIX_Named_Object_RAM(_number, _size) \ - (_Configure_Object_RAM(_number, _size) \ - + _Configure_Max_Objects(_number) \ - * _Configure_From_workspace(_POSIX_PATH_MAX + 1)) - - /** - * This configuration parameter specifies the maximum number of - * POSIX API threads. - */ - #ifndef CONFIGURE_MAXIMUM_POSIX_THREADS - #define CONFIGURE_MAXIMUM_POSIX_THREADS 0 - #endif - - /** - * This configuration parameter specifies the maximum number of - * POSIX API timers. - */ - #ifndef CONFIGURE_MAXIMUM_POSIX_TIMERS - #define CONFIGURE_MAXIMUM_POSIX_TIMERS 0 - #endif - - /* - * This macro is calculated to specify the memory required for - * POSIX API timers. - */ - #define _CONFIGURE_MEMORY_FOR_POSIX_TIMERS(_timers) \ - _Configure_Object_RAM(_timers, sizeof(POSIX_Timer_Control) ) - - /** - * This configuration parameter specifies the maximum number of - * POSIX API queued signals. - */ - #ifndef CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS - #define CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS 0 - #endif - - /* - * This macro is calculated to specify the memory required for - * POSIX API queued signals. - */ - #define _CONFIGURE_MEMORY_FOR_POSIX_QUEUED_SIGNALS(_queued_signals) \ - _Configure_From_workspace( \ - (_queued_signals) * (sizeof(POSIX_signals_Siginfo_node)) ) - - /** - * This configuration parameter specifies the maximum number of - * POSIX API message queues. - */ - #ifndef CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES - #define CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES 0 - #endif - - /* - * This macro is calculated to specify the memory required for - * POSIX API message queues. - */ - #define _CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUES(_message_queues) \ - _Configure_POSIX_Named_Object_RAM( \ - _message_queues, sizeof(POSIX_Message_queue_Control) ) - - /** - * This configuration parameter specifies the maximum number of - * POSIX API semaphores. - */ - #ifndef CONFIGURE_MAXIMUM_POSIX_SEMAPHORES - #define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES 0 - #endif - - /* - * This macro is calculated to specify the memory required for - * POSIX API semaphores. - */ - #define _CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES(_semaphores) \ - _Configure_POSIX_Named_Object_RAM( \ - _semaphores, sizeof(POSIX_Semaphore_Control) ) - - /** - * Configure the maximum number of POSIX shared memory objects. - */ - #if !defined(CONFIGURE_MAXIMUM_POSIX_SHMS) - #define CONFIGURE_MAXIMUM_POSIX_SHMS 0 - #else - #ifdef CONFIGURE_INIT - #if !defined(CONFIGURE_HAS_OWN_POSIX_SHM_OBJECT_OPERATIONS) - const POSIX_Shm_Object_operations _POSIX_Shm_Object_operations = { - _POSIX_Shm_Object_create_from_workspace, - _POSIX_Shm_Object_resize_from_workspace, - _POSIX_Shm_Object_delete_from_workspace, - _POSIX_Shm_Object_read_from_workspace, - _POSIX_Shm_Object_mmap_from_workspace - }; - #endif - #endif - #endif - - /* - * This macro is calculated to specify the memory required for - * POSIX API shared memory. - */ - #define _CONFIGURE_MEMORY_FOR_POSIX_SHMS(_shms) \ - _Configure_POSIX_Named_Object_RAM(_shms, sizeof(POSIX_Shm_Control) ) - - - #ifdef CONFIGURE_POSIX_INIT_THREAD_TABLE - - #ifdef CONFIGURE_POSIX_HAS_OWN_INIT_THREAD_TABLE - - /* - * The user is defining their own table information and setting the - * appropriate variables for the POSIX Initialization Thread Table. - */ - - #else - - #ifndef CONFIGURE_POSIX_INIT_THREAD_ENTRY_POINT - #define CONFIGURE_POSIX_INIT_THREAD_ENTRY_POINT POSIX_Init - #endif - - #ifndef CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE - #define CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE \ - CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE - #endif - - #ifdef CONFIGURE_INIT - posix_initialization_threads_table POSIX_Initialization_threads[] = { - { CONFIGURE_POSIX_INIT_THREAD_ENTRY_POINT, \ - CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE } - }; - #endif - - #define CONFIGURE_POSIX_INIT_THREAD_TABLE_NAME \ - POSIX_Initialization_threads - - #define CONFIGURE_POSIX_INIT_THREAD_TABLE_SIZE \ - RTEMS_ARRAY_SIZE(CONFIGURE_POSIX_INIT_THREAD_TABLE_NAME) - - #endif /* CONFIGURE_POSIX_HAS_OWN_INIT_TASK_TABLE */ - - #else /* CONFIGURE_POSIX_INIT_THREAD_TABLE */ - - #define CONFIGURE_POSIX_INIT_THREAD_TABLE_NAME NULL - #define CONFIGURE_POSIX_INIT_THREAD_TABLE_SIZE 0 - - #endif - -#else - - /** - * This configuration parameter specifies the maximum number of - * POSIX API threads. - */ - #define CONFIGURE_MAXIMUM_POSIX_THREADS 0 - -#endif /* RTEMS_POSIX_API */ - -/** - * This configuration parameter specifies the stack size of the - * POSIX API Initialization thread (if used). - */ -#ifndef CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE - #define CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE 0 -#endif -/**@}*/ /* end of POSIX API Configuration */ - -/** - * @defgroup ConfigurationGNAT GNAT/RTEMS Configuration - * - * @addtogroup Configuration - * - * This modules includes configuration parameters for applications which - * use GNAT/RTEMS. GNAT implements each Ada task as a POSIX thread. - */ -/**@{*/ -#ifdef CONFIGURE_GNAT_RTEMS - /** - * This is the maximum number of Ada tasks which can be concurrently - * in existence. Twenty (20) are required to run all tests in the - * ACATS (formerly ACVC). - */ - #ifndef CONFIGURE_MAXIMUM_ADA_TASKS - #define CONFIGURE_MAXIMUM_ADA_TASKS 20 - #endif - - /** - * This is the number of non-Ada tasks which invoked Ada code. - */ - #ifndef CONFIGURE_MAXIMUM_FAKE_ADA_TASKS - #define CONFIGURE_MAXIMUM_FAKE_ADA_TASKS 0 - #endif -#else - /** This defines he number of POSIX mutexes GNAT needs. */ - /** This defines he number of Ada tasks needed by the application. */ - #define CONFIGURE_MAXIMUM_ADA_TASKS 0 - /** - * This defines he number of non-Ada tasks/threads that will invoke - * Ada subprograms or functions. - */ - #define CONFIGURE_MAXIMUM_FAKE_ADA_TASKS 0 -#endif -/**@}*/ /* end of GNAT Configuration */ - -/** - * @defgroup ConfigurationGo GCC Go Configuration - * - * @addtogroup Configuration - * - * This modules includes configuration parameters for applications which - * use GCC Go. - */ -/**@{*/ -#ifdef CONFIGURE_ENABLE_GO - - #ifndef CONFIGURE_MAXIMUM_POSIX_THREADS - #define CONFIGURE_MAXIMUM_POSIX_THREADS 1 - #endif - - #ifndef CONFIGURE_MAXIMUM_GOROUTINES - #define CONFIGURE_MAXIMUM_GOROUTINES 400 - #endif - - #ifndef CONFIGURE_MAXIMUM_GO_CHANNELS - #define CONFIGURE_MAXIMUM_GO_CHANNELS 500 - #endif - -#else - /** This specifies the maximum number of Go co-routines. */ - #define CONFIGURE_MAXIMUM_GOROUTINES 0 - - /** This specifies the maximum number of Go channels required. */ - #define CONFIGURE_MAXIMUM_GO_CHANNELS 0 -#endif -/**@}*/ /* end of Go Configuration */ - -/** - * This is so we can account for tasks with stacks greater than minimum - * size. This is in bytes. - */ -#ifndef CONFIGURE_EXTRA_TASK_STACKS - #define CONFIGURE_EXTRA_TASK_STACKS 0 -#endif - -/** - * This macro provides a summation of the various POSIX thread requirements. - */ -#define _CONFIGURE_POSIX_THREADS \ - (CONFIGURE_MAXIMUM_POSIX_THREADS + \ - CONFIGURE_MAXIMUM_ADA_TASKS + \ - CONFIGURE_MAXIMUM_GOROUTINES) - -#ifdef RTEMS_POSIX_API - /* - * This macro is calculated to specify the memory required for - * the POSIX API in its entirety. - */ - #define _CONFIGURE_MEMORY_FOR_POSIX \ - (_CONFIGURE_MEMORY_FOR_POSIX_QUEUED_SIGNALS( \ - CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS) + \ - _CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUES( \ - CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES) + \ - _CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES( \ - CONFIGURE_MAXIMUM_POSIX_SEMAPHORES) + \ - _CONFIGURE_MEMORY_FOR_POSIX_SHMS( \ - CONFIGURE_MAXIMUM_POSIX_SHMS) + \ - _CONFIGURE_MEMORY_FOR_POSIX_TIMERS(CONFIGURE_MAXIMUM_POSIX_TIMERS)) -#else - /* - * This macro is calculated to specify the memory required for - * the POSIX API in its entirety. - */ - #define _CONFIGURE_MEMORY_FOR_POSIX 0 -#endif - -/* - * We must be able to split the free block used for the second last allocation - * into two parts so that we have a free block for the last allocation. See - * _Heap_Block_split(). - */ -#define _CONFIGURE_HEAP_HANDLER_OVERHEAD \ - _Configure_Align_up( HEAP_BLOCK_HEADER_SIZE, CPU_HEAP_ALIGNMENT ) - -/* - * Calculate the RAM size based on the maximum number of objects configured. - */ -#ifndef CONFIGURE_EXECUTIVE_RAM_SIZE - -/* - * Account for allocating the following per object - * + array of object control structures - * + local pointer table -- pointer per object plus a zero'th - * entry in the local pointer table. - */ -#define _CONFIGURE_MEMORY_FOR_TASKS(_tasks, _number_FP_tasks) \ - ( \ - _Configure_Object_RAM(_tasks, sizeof(Configuration_Thread_control)) \ - + _Configure_From_workspace(_Configure_Max_Objects(_tasks) \ - * THREAD_QUEUE_HEADS_SIZE(CONFIGURE_SCHEDULER_COUNT)) \ - + _Configure_Max_Objects(_number_FP_tasks) \ - * _Configure_From_workspace(CONTEXT_FP_SIZE) \ - ) - -/* - * This defines the amount of memory configured for the multiprocessing - * support required by this application. - */ -#ifdef CONFIGURE_MP_APPLICATION - #define _CONFIGURE_MEMORY_FOR_MP \ - (_CONFIGURE_MEMORY_FOR_PROXIES(CONFIGURE_MP_MAXIMUM_PROXIES) + \ - _CONFIGURE_MEMORY_FOR_GLOBAL_OBJECTS(CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS)) -#else - #define _CONFIGURE_MEMORY_FOR_MP 0 -#endif - -/** - * The following macro is used to calculate the memory allocated by RTEMS - * for the message buffers associated with a particular message queue. - * There is a fixed amount of overhead per message. - */ -#define CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(_messages, _size) \ - _Configure_From_workspace( \ - (_messages) * (_Configure_Align_up(_size, sizeof(uintptr_t)) \ - + sizeof(CORE_message_queue_Buffer_control))) - -/* - * This macro is set to the amount of memory required for pending message - * buffers in bytes. It should be constructed by adding together a - * set of values determined by CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE. - */ -#ifndef CONFIGURE_MESSAGE_BUFFER_MEMORY - #define CONFIGURE_MESSAGE_BUFFER_MEMORY 0 -#endif - -/** - * This macro is available just in case the confdefs.h file underallocates - * memory for a particular application. This lets the user add some extra - * memory in case something broken and underestimates. - * - * It is also possible for cases where confdefs.h overallocates memory, - * you could substract memory from the allocated. The estimate is just - * that, an estimate, and assumes worst case alignment and padding on - * each allocated element. So in some cases it could be too conservative. - * - * NOTE: Historically this was used for message buffers. - */ -#ifndef CONFIGURE_MEMORY_OVERHEAD - #define CONFIGURE_MEMORY_OVERHEAD 0 -#endif - -/** - * This calculates the amount of memory reserved for the IDLE tasks. - * In an SMP system, each CPU core has its own idle task. - */ -#define _CONFIGURE_IDLE_TASKS_COUNT CONFIGURE_MAXIMUM_PROCESSORS - -/** - * This defines the formula used to compute the amount of memory - * reserved for internal task control structures. - */ -#if CPU_IDLE_TASK_IS_FP == TRUE - #define _CONFIGURE_MEMORY_FOR_INTERNAL_TASKS \ - _CONFIGURE_MEMORY_FOR_TASKS( \ - _CONFIGURE_IDLE_TASKS_COUNT + _CONFIGURE_MPCI_RECEIVE_SERVER_COUNT, \ - _CONFIGURE_IDLE_TASKS_COUNT + _CONFIGURE_MPCI_RECEIVE_SERVER_COUNT \ - ) -#else - #define _CONFIGURE_MEMORY_FOR_INTERNAL_TASKS \ - _CONFIGURE_MEMORY_FOR_TASKS( \ - _CONFIGURE_IDLE_TASKS_COUNT + _CONFIGURE_MPCI_RECEIVE_SERVER_COUNT, \ - _CONFIGURE_MPCI_RECEIVE_SERVER_COUNT \ - ) -#endif - -/** - * This macro accounts for general RTEMS system overhead. - */ -#define _CONFIGURE_MEMORY_FOR_SYSTEM_OVERHEAD \ - ( _CONFIGURE_MEMORY_FOR_INTERNAL_TASKS + \ - _CONFIGURE_INTERRUPT_STACK_MEMORY \ - ) - -/** - * This macro reserves the memory required by the statically configured - * user extensions. - */ -#define _CONFIGURE_MEMORY_FOR_STATIC_EXTENSIONS \ - (_CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS == 0 ? 0 : \ - _Configure_From_workspace( \ - _CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS \ - * sizeof(User_extensions_Switch_control) \ - )) - -/** - * This macro provides a summation of the memory required by the - * Classic API as configured. - */ -#define _CONFIGURE_MEMORY_FOR_CLASSIC \ - (_CONFIGURE_MEMORY_FOR_TIMERS(CONFIGURE_MAXIMUM_TIMERS + \ - _CONFIGURE_TIMER_FOR_SHARED_MEMORY_DRIVER ) + \ - _CONFIGURE_MEMORY_FOR_SEMAPHORES(_CONFIGURE_SEMAPHORES) + \ - _CONFIGURE_MEMORY_FOR_MESSAGE_QUEUES(CONFIGURE_MAXIMUM_MESSAGE_QUEUES) + \ - _CONFIGURE_MEMORY_FOR_PARTITIONS(CONFIGURE_MAXIMUM_PARTITIONS) + \ - _CONFIGURE_MEMORY_FOR_REGIONS( CONFIGURE_MAXIMUM_REGIONS ) + \ - _CONFIGURE_MEMORY_FOR_PORTS(CONFIGURE_MAXIMUM_PORTS) + \ - _CONFIGURE_MEMORY_FOR_PERIODS(CONFIGURE_MAXIMUM_PERIODS) + \ - _CONFIGURE_MEMORY_FOR_BARRIERS(_CONFIGURE_BARRIERS) + \ - _CONFIGURE_MEMORY_FOR_USER_EXTENSIONS(CONFIGURE_MAXIMUM_USER_EXTENSIONS) \ - ) - -/* - * This macro provides a summation of the memory required by SMP as configured. - */ -#if defined(RTEMS_SMP) - #define _CONFIGURE_MEMORY_FOR_SMP \ - (CONFIGURE_MAXIMUM_PROCESSORS * \ - _Configure_From_workspace( CONFIGURE_INTERRUPT_STACK_SIZE ) \ - ) -#else - #define _CONFIGURE_MEMORY_FOR_SMP 0 -#endif - -/** - * This calculates the memory required for the executive workspace. - * - * This is an internal parameter. - */ -#define CONFIGURE_EXECUTIVE_RAM_SIZE \ -( \ - _CONFIGURE_MEMORY_FOR_SYSTEM_OVERHEAD + \ - _CONFIGURE_MEMORY_FOR_TASKS( \ - _CONFIGURE_TASKS, _CONFIGURE_TASKS) + \ - _CONFIGURE_MEMORY_FOR_TASKS( \ - _CONFIGURE_POSIX_THREADS, _CONFIGURE_POSIX_THREADS) + \ - _CONFIGURE_MEMORY_FOR_CLASSIC + \ - _CONFIGURE_MEMORY_FOR_POSIX_KEYS( \ - _CONFIGURE_POSIX_KEYS, \ - CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS ) + \ - _CONFIGURE_MEMORY_FOR_POSIX + \ - _CONFIGURE_MEMORY_FOR_STATIC_EXTENSIONS + \ - _CONFIGURE_MEMORY_FOR_MP + \ - _CONFIGURE_MEMORY_FOR_SMP + \ - CONFIGURE_MESSAGE_BUFFER_MEMORY + \ - (CONFIGURE_MEMORY_OVERHEAD * 1024) + \ - _CONFIGURE_HEAP_HANDLER_OVERHEAD \ -) - -/* - * Now account for any extra memory that initialization tasks or threads - * may have requested. - */ - -/* - * This accounts for any extra memory required by the Classic API - * Initialization Task. - */ -#if (CONFIGURE_INIT_TASK_STACK_SIZE > CONFIGURE_MINIMUM_TASK_STACK_SIZE) - #define _CONFIGURE_INITIALIZATION_THREADS_STACKS_CLASSIC_PART \ - (CONFIGURE_INIT_TASK_STACK_SIZE - CONFIGURE_MINIMUM_TASK_STACK_SIZE) -#else - #define _CONFIGURE_INITIALIZATION_THREADS_STACKS_CLASSIC_PART 0 -#endif - -/* - * This accounts for any extra memory required by the POSIX API - * Initialization Thread. - */ -#if defined(RTEMS_POSIX_API) && \ - (CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE > \ - CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE) - #define _CONFIGURE_INITIALIZATION_THREADS_STACKS_POSIX_PART \ - (CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE - \ - CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE) -#else - #define _CONFIGURE_INITIALIZATION_THREADS_STACKS_POSIX_PART 0 -#endif - -/* - * This macro provides a summation of the various initialization task - * and thread stack requirements. - */ -#define _CONFIGURE_INITIALIZATION_THREADS_EXTRA_STACKS \ - (_CONFIGURE_INITIALIZATION_THREADS_STACKS_CLASSIC_PART + \ - _CONFIGURE_INITIALIZATION_THREADS_STACKS_POSIX_PART) - -/* - * This macro is calculated to specify the memory required for - * the Idle tasks(s) stack. - */ -#define _CONFIGURE_IDLE_TASKS_STACK \ - (_CONFIGURE_IDLE_TASKS_COUNT * \ - _Configure_From_stackspace( CONFIGURE_IDLE_TASK_STACK_SIZE ) ) - -/* - * This macro is calculated to specify the stack memory required for the MPCI - * task. - */ -#define _CONFIGURE_MPCI_RECEIVE_SERVER_STACK \ - (_CONFIGURE_MPCI_RECEIVE_SERVER_COUNT * \ - _Configure_From_stackspace(CONFIGURE_MINIMUM_TASK_STACK_SIZE)) - -/* - * This macro is calculated to specify the memory required for - * the stacks of all tasks. - */ -#define _CONFIGURE_TASKS_STACK \ - (_Configure_Max_Objects( _CONFIGURE_TASKS ) * \ - _Configure_From_stackspace( CONFIGURE_MINIMUM_TASK_STACK_SIZE ) ) - -/* - * This macro is calculated to specify the memory required for - * the stacks of all POSIX threads. - */ -#define _CONFIGURE_POSIX_THREADS_STACK \ - (_Configure_Max_Objects( CONFIGURE_MAXIMUM_POSIX_THREADS ) * \ - _Configure_From_stackspace( CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE ) ) - -/* - * This macro is calculated to specify the memory required for - * the stacks of all Ada tasks. - */ -#define _CONFIGURE_ADA_TASKS_STACK \ - (_Configure_Max_Objects( CONFIGURE_MAXIMUM_ADA_TASKS ) * \ - _Configure_From_stackspace( CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE ) ) - -/* - * This macro is calculated to specify the memory required for - * the stacks of all Go routines. - */ -#define _CONFIGURE_GOROUTINES_STACK \ - (_Configure_Max_Objects( CONFIGURE_MAXIMUM_GOROUTINES ) * \ - _Configure_From_stackspace( CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE ) ) - -#else /* CONFIGURE_EXECUTIVE_RAM_SIZE */ - -#define _CONFIGURE_IDLE_TASKS_STACK 0 -#define _CONFIGURE_MPCI_RECEIVE_SERVER_STACK 0 -#define _CONFIGURE_INITIALIZATION_THREADS_EXTRA_STACKS 0 -#define _CONFIGURE_TASKS_STACK 0 -#define _CONFIGURE_POSIX_THREADS_STACK 0 -#define _CONFIGURE_GOROUTINES_STACK 0 -#define _CONFIGURE_ADA_TASKS_STACK 0 - -#if CONFIGURE_EXTRA_MPCI_RECEIVE_SERVER_STACK != 0 - #error "CONFIGURE_EXECUTIVE_RAM_SIZE defined with request for CONFIGURE_EXTRA_MPCI_RECEIVE_SERVER_STACK" -#endif - -#if CONFIGURE_EXTRA_TASK_STACKS != 0 - #error "CONFIGURE_EXECUTIVE_RAM_SIZE defined with request for CONFIGURE_EXTRA_TASK_STACKS" -#endif - -#endif /* CONFIGURE_EXECUTIVE_RAM_SIZE */ - -/* - * This macro is calculated to specify the memory required for - * all tasks and threads of all varieties. - */ -#define _CONFIGURE_STACK_SPACE_SIZE \ - ( \ - _CONFIGURE_IDLE_TASKS_STACK + \ - _CONFIGURE_MPCI_RECEIVE_SERVER_STACK + \ - _CONFIGURE_INITIALIZATION_THREADS_EXTRA_STACKS + \ - _CONFIGURE_TASKS_STACK + \ - _CONFIGURE_POSIX_THREADS_STACK + \ - _CONFIGURE_GOROUTINES_STACK + \ - _CONFIGURE_ADA_TASKS_STACK + \ - CONFIGURE_EXTRA_MPCI_RECEIVE_SERVER_STACK + \ - _CONFIGURE_LIBBLOCK_TASK_EXTRA_STACKS + \ - CONFIGURE_EXTRA_TASK_STACKS + \ - _CONFIGURE_HEAP_HANDLER_OVERHEAD \ - ) - -#ifndef CONFIGURE_MAXIMUM_THREAD_NAME_SIZE - #define CONFIGURE_MAXIMUM_THREAD_NAME_SIZE 16 -#endif - -#ifdef CONFIGURE_INIT - typedef union { - Scheduler_Node Base; - #ifdef CONFIGURE_SCHEDULER_CBS - Scheduler_CBS_Node CBS; - #endif - #ifdef CONFIGURE_SCHEDULER_EDF - Scheduler_EDF_Node EDF; - #endif - #ifdef CONFIGURE_SCHEDULER_EDF_SMP - Scheduler_EDF_SMP_Node EDF_SMP; - #endif - #ifdef CONFIGURE_SCHEDULER_PRIORITY - Scheduler_priority_Node Priority; - #endif - #ifdef CONFIGURE_SCHEDULER_SIMPLE_SMP - Scheduler_SMP_Node Simple_SMP; - #endif - #ifdef CONFIGURE_SCHEDULER_PRIORITY_SMP - Scheduler_priority_SMP_Node Priority_SMP; - #endif - #ifdef CONFIGURE_SCHEDULER_PRIORITY_AFFINITY_SMP - Scheduler_priority_affinity_SMP_Node Priority_affinity_SMP; - #endif - #ifdef CONFIGURE_SCHEDULER_STRONG_APA - Scheduler_strong_APA_Node Strong_APA; - #endif - #ifdef CONFIGURE_SCHEDULER_USER_PER_THREAD - CONFIGURE_SCHEDULER_USER_PER_THREAD User; - #endif - } Configuration_Scheduler_node; - - #ifdef RTEMS_SMP - const size_t _Scheduler_Node_size = sizeof( Configuration_Scheduler_node ); - #endif - - const size_t _Thread_Maximum_name_size = CONFIGURE_MAXIMUM_THREAD_NAME_SIZE; - - typedef struct { - Thread_Control Control; - #if CONFIGURE_MAXIMUM_USER_EXTENSIONS > 0 - void *extensions[ CONFIGURE_MAXIMUM_USER_EXTENSIONS + 1 ]; - #endif - Configuration_Scheduler_node Scheduler_nodes[ CONFIGURE_SCHEDULER_COUNT ]; - RTEMS_API_Control API_RTEMS; - #ifdef RTEMS_POSIX_API - POSIX_API_Control API_POSIX; - #endif - #if CONFIGURE_MAXIMUM_THREAD_NAME_SIZE > 1 - char name[ CONFIGURE_MAXIMUM_THREAD_NAME_SIZE ]; - #endif - #if !defined(RTEMS_SCHEDSIM) \ - && defined(RTEMS_NEWLIB) \ - && !defined(CONFIGURE_DISABLE_NEWLIB_REENTRANCY) - struct _reent Newlib; - #else - struct { /* Empty */ } Newlib; - #endif - } Configuration_Thread_control; - - const size_t _Thread_Control_size = sizeof( Configuration_Thread_control ); - - const Thread_Control_add_on _Thread_Control_add_ons[] = { - { - offsetof( Configuration_Thread_control, Control.Scheduler.nodes ), - offsetof( Configuration_Thread_control, Scheduler_nodes ) - }, { - offsetof( - Configuration_Thread_control, - Control.API_Extensions[ THREAD_API_RTEMS ] - ), - offsetof( Configuration_Thread_control, API_RTEMS ) - }, { - offsetof( - Configuration_Thread_control, - Control.libc_reent - ), - offsetof( Configuration_Thread_control, Newlib ) - } - #if CONFIGURE_MAXIMUM_THREAD_NAME_SIZE > 1 - , { - offsetof( - Configuration_Thread_control, - Control.Join_queue.Queue.name - ), - offsetof( Configuration_Thread_control, name ) - } - #endif - #ifdef RTEMS_POSIX_API - , { - offsetof( - Configuration_Thread_control, - Control.API_Extensions[ THREAD_API_POSIX ] - ), - offsetof( Configuration_Thread_control, API_POSIX ) - } - #endif - }; - - const size_t _Thread_Control_add_on_count = - RTEMS_ARRAY_SIZE( _Thread_Control_add_ons ); - - const uint32_t _Watchdog_Nanoseconds_per_tick = - 1000 * CONFIGURE_MICROSECONDS_PER_TICK; - - const uint32_t _Watchdog_Ticks_per_second = _CONFIGURE_TICKS_PER_SECOND; - - const uint64_t _Watchdog_Monotonic_max_seconds = - UINT64_MAX / _CONFIGURE_TICKS_PER_SECOND; - - /** - * This is the Classic API Configuration Table. - */ - rtems_api_configuration_table Configuration_RTEMS_API = { - _CONFIGURE_TASKS, - CONFIGURE_MAXIMUM_TIMERS + _CONFIGURE_TIMER_FOR_SHARED_MEMORY_DRIVER, - _CONFIGURE_SEMAPHORES, - CONFIGURE_MAXIMUM_MESSAGE_QUEUES, - CONFIGURE_MAXIMUM_PARTITIONS, - CONFIGURE_MAXIMUM_REGIONS, - CONFIGURE_MAXIMUM_PORTS, - CONFIGURE_MAXIMUM_PERIODS, - _CONFIGURE_BARRIERS, - CONFIGURE_INIT_TASK_TABLE_SIZE, - CONFIGURE_INIT_TASK_TABLE - }; - - #ifdef RTEMS_POSIX_API - /** - * This is the POSIX API Configuration Table. - */ - posix_api_configuration_table Configuration_POSIX_API = { - _CONFIGURE_POSIX_THREADS, - CONFIGURE_MAXIMUM_POSIX_TIMERS, - CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS, - CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES, - CONFIGURE_MAXIMUM_POSIX_SEMAPHORES, - CONFIGURE_MAXIMUM_POSIX_SHMS, - CONFIGURE_POSIX_INIT_THREAD_TABLE_SIZE, - CONFIGURE_POSIX_INIT_THREAD_TABLE_NAME - }; - #endif - - /** - * This variable specifies the minimum stack size for tasks in an RTEMS - * application. - * - * NOTE: This is left as a simple uint32_t so it can be externed as - * needed without requring being high enough logical to - * include the full configuration table. - */ - uint32_t rtems_minimum_stack_size = - CONFIGURE_MINIMUM_TASK_STACK_SIZE; - - /** - * This is the primary Configuration Table for this application. - */ - const rtems_configuration_table Configuration = { - CONFIGURE_EXECUTIVE_RAM_SIZE, /* required RTEMS workspace */ - _CONFIGURE_STACK_SPACE_SIZE, /* required stack space */ - CONFIGURE_MAXIMUM_USER_EXTENSIONS, /* maximum dynamic extensions */ - _CONFIGURE_POSIX_KEYS, /* POSIX keys are always */ - CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS, /* enabled */ - CONFIGURE_MICROSECONDS_PER_TICK, /* microseconds per clock tick */ - CONFIGURE_TICKS_PER_TIMESLICE, /* ticks per timeslice quantum */ - CONFIGURE_IDLE_TASK_BODY, /* user's IDLE task */ - CONFIGURE_IDLE_TASK_STACK_SIZE, /* IDLE task stack size */ - CONFIGURE_INTERRUPT_STACK_SIZE, /* interrupt stack size */ - CONFIGURE_TASK_STACK_ALLOCATOR_INIT, /* stack allocator init */ - CONFIGURE_TASK_STACK_ALLOCATOR, /* stack allocator */ - CONFIGURE_TASK_STACK_DEALLOCATOR, /* stack deallocator */ - CONFIGURE_ZERO_WORKSPACE_AUTOMATICALLY, /* true to clear memory */ - #ifdef CONFIGURE_UNIFIED_WORK_AREAS /* true for unified work areas */ - true, - #else - false, - #endif - #ifdef CONFIGURE_TASK_STACK_ALLOCATOR_AVOIDS_WORK_SPACE /* true to avoid - work space for thread stack - allocation */ - true, - #else - false, - #endif - #ifdef RTEMS_SMP - #ifdef _CONFIGURE_SMP_APPLICATION - true, - #else - false, - #endif - #endif - _CONFIGURE_NUMBER_OF_INITIAL_EXTENSIONS, /* number of static extensions */ - CONFIGURE_INITIAL_EXTENSION_TABLE, /* pointer to static extensions */ - #if defined(RTEMS_MULTIPROCESSING) - CONFIGURE_MULTIPROCESSING_TABLE, /* pointer to MP config table */ - #endif - #ifdef RTEMS_SMP - CONFIGURE_MAXIMUM_PROCESSORS, - #endif - }; -#endif - -#endif /* CONFIGURE_HAS_OWN_CONFIGURATION_TABLE */ - -#if defined(RTEMS_SMP) - /* - * Instantiate the Per CPU information based upon the user configuration. - */ - #if defined(CONFIGURE_INIT) - Per_CPU_Control_envelope _Per_CPU_Information[CONFIGURE_MAXIMUM_PROCESSORS]; - #endif - -#endif - -/* - * If the user has configured a set of Classic API Initialization Tasks, - * then we need to install the code that runs that loop. - */ -#ifdef CONFIGURE_INIT - #if defined(CONFIGURE_RTEMS_INIT_TASKS_TABLE) || \ - defined(CONFIGURE_HAS_OWN_INIT_TASK_TABLE) - RTEMS_SYSINIT_ITEM( - _RTEMS_tasks_Initialize_user_tasks_body, - RTEMS_SYSINIT_CLASSIC_USER_TASKS, - RTEMS_SYSINIT_ORDER_MIDDLE - ); - #endif -#endif - -/* - * If the user has configured a set of POSIX Initialization Threads, - * then we need to install the code that runs that loop. - */ -#ifdef RTEMS_POSIX_API - #ifdef CONFIGURE_INIT - #if defined(CONFIGURE_POSIX_INIT_THREAD_TABLE) || \ - defined(CONFIGURE_POSIX_HAS_OWN_INIT_THREAD_TABLE) - RTEMS_SYSINIT_ITEM( - _POSIX_Threads_Initialize_user_threads_body, - RTEMS_SYSINIT_POSIX_USER_THREADS, - RTEMS_SYSINIT_ORDER_MIDDLE - ); - #endif - #endif -#endif - -/* - * Select PCI Configuration Library - */ -#ifdef RTEMS_PCI_CONFIG_LIB - #ifdef CONFIGURE_INIT - #define PCI_LIB_NONE 0 - #define PCI_LIB_AUTO 1 - #define PCI_LIB_STATIC 2 - #define PCI_LIB_READ 3 - #define PCI_LIB_PERIPHERAL 4 - #if CONFIGURE_PCI_LIB == PCI_LIB_AUTO - #define PCI_CFG_AUTO_LIB - #include - struct pci_bus pci_hb; - #define PCI_LIB_INIT pci_config_auto - #define PCI_LIB_CONFIG pci_config_auto_register - #elif CONFIGURE_PCI_LIB == PCI_LIB_STATIC - #define PCI_CFG_STATIC_LIB - #include - #define PCI_LIB_INIT pci_config_static - #define PCI_LIB_CONFIG NULL - /* Let user define PCI configuration (struct pci_bus pci_hb) */ - #elif CONFIGURE_PCI_LIB == PCI_LIB_READ - #define PCI_CFG_READ_LIB - #include - #define PCI_LIB_INIT pci_config_read - #define PCI_LIB_CONFIG NULL - struct pci_bus pci_hb; - #elif CONFIGURE_PCI_LIB == PCI_LIB_PERIPHERAL - #define PCI_LIB_INIT pci_config_peripheral - #define PCI_LIB_CONFIG NULL - /* Let user define PCI configuration (struct pci_bus pci_hb) */ - #elif CONFIGURE_PCI_LIB == PCI_LIB_NONE - #define PCI_LIB_INIT NULL - #define PCI_LIB_CONFIG NULL - /* No PCI Configuration at all, user can use/debug access routines */ - #else - #error NO PCI LIBRARY DEFINED - #endif - - const int pci_config_lib_type = CONFIGURE_PCI_LIB; - int (*pci_config_lib_init)(void) = PCI_LIB_INIT; - void (*pci_config_lib_register)(void *config) = PCI_LIB_CONFIG; - #endif -#endif - -#ifdef __cplusplus -} -#endif - -/****************************************************************** - ****************************************************************** - ****************************************************************** - * CONFIGURATION WARNINGS AND ERROR CHECKING * - ****************************************************************** - ****************************************************************** - ****************************************************************** - */ - -#if defined(CONFIGURE_CONFDEFS_DEBUG) && defined(CONFIGURE_INIT) - /** - * This is a debug mechanism, so if you need to, the executable will - * have a structure with various partial values. Add to this as you - * need to. Viewing this structure in gdb combined with dumping - * the Configuration structures generated should help a lot in tracing - * down errors and analyzing where over and under allocations are. - */ - typedef struct { - uint32_t SYSTEM_OVERHEAD; - uint32_t STATIC_EXTENSIONS; - uint32_t INITIALIZATION_THREADS_STACKS; - - uint32_t PER_INTEGER_TASK; - uint32_t FP_OVERHEAD; - uint32_t CLASSIC; - uint32_t POSIX; - - /* System overhead pieces */ - uint32_t INTERRUPT_STACK_MEMORY; - uint32_t MEMORY_FOR_IDLE_TASK; - - /* Classic API Pieces */ - uint32_t CLASSIC_TASKS; - uint32_t TIMERS; - uint32_t SEMAPHORES; - uint32_t MESSAGE_QUEUES; - uint32_t PARTITIONS; - uint32_t REGIONS; - uint32_t PORTS; - uint32_t PERIODS; - uint32_t BARRIERS; - uint32_t USER_EXTENSIONS; - - /* POSIX API managers that are always enabled */ - uint32_t POSIX_KEYS; - -#ifdef RTEMS_POSIX_API - /* POSIX API Pieces */ - uint32_t POSIX_TIMERS; - uint32_t POSIX_QUEUED_SIGNALS; - uint32_t POSIX_MESSAGE_QUEUES; - uint32_t POSIX_SEMAPHORES; - uint32_t POSIX_SHMS; -#endif - - /* Stack space sizes */ - uint32_t IDLE_TASKS_STACK; - uint32_t INITIALIZATION_THREADS_EXTRA_STACKS; - uint32_t TASKS_STACK; - uint32_t POSIX_THREADS_STACK; - uint32_t GOROUTINES_STACK; - uint32_t ADA_TASKS_STACK; - uint32_t EXTRA_MPCI_RECEIVE_SERVER_STACK; - uint32_t EXTRA_TASK_STACKS; - } Configuration_Debug_t; - - Configuration_Debug_t Configuration_Memory_Debug = { - /* General Information */ - _CONFIGURE_MEMORY_FOR_SYSTEM_OVERHEAD, - _CONFIGURE_MEMORY_FOR_STATIC_EXTENSIONS, - _CONFIGURE_INITIALIZATION_THREADS_EXTRA_STACKS, - _CONFIGURE_MEMORY_FOR_TASKS(1, 0), - _CONFIGURE_MEMORY_FOR_TASKS(0, 1), - _CONFIGURE_MEMORY_FOR_CLASSIC, - _CONFIGURE_MEMORY_FOR_POSIX, - - /* System overhead pieces */ - _CONFIGURE_INTERRUPT_STACK_MEMORY, - _CONFIGURE_MEMORY_FOR_INTERNAL_TASKS, - - /* Classic API Pieces */ - _CONFIGURE_MEMORY_FOR_TASKS(CONFIGURE_MAXIMUM_TASKS, 0), - _CONFIGURE_MEMORY_FOR_TIMERS(CONFIGURE_MAXIMUM_TIMERS), - _CONFIGURE_MEMORY_FOR_SEMAPHORES(_CONFIGURE_SEMAPHORES), - _CONFIGURE_MEMORY_FOR_MESSAGE_QUEUES(CONFIGURE_MAXIMUM_MESSAGE_QUEUES), - _CONFIGURE_MEMORY_FOR_PARTITIONS(CONFIGURE_MAXIMUM_PARTITIONS), - _CONFIGURE_MEMORY_FOR_REGIONS( CONFIGURE_MAXIMUM_REGIONS ), - _CONFIGURE_MEMORY_FOR_PORTS(CONFIGURE_MAXIMUM_PORTS), - _CONFIGURE_MEMORY_FOR_PERIODS(CONFIGURE_MAXIMUM_PERIODS), - _CONFIGURE_MEMORY_FOR_BARRIERS(_CONFIGURE_BARRIERS), - _CONFIGURE_MEMORY_FOR_USER_EXTENSIONS(CONFIGURE_MAXIMUM_USER_EXTENSIONS), - _CONFIGURE_MEMORY_FOR_POSIX_KEYS( _CONFIGURE_POSIX_KEYS, \ - CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS ), - -#ifdef RTEMS_POSIX_API - /* POSIX API Pieces */ - _CONFIGURE_MEMORY_FOR_POSIX_QUEUED_SIGNALS( - CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS ), - _CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUES( - CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES ), - _CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES( CONFIGURE_MAXIMUM_POSIX_SEMAPHORES ), - _CONFIGURE_MEMORY_FOR_POSIX_SHMS( CONFIGURE_MAXIMUM_POSIX_SHMS ), - _CONFIGURE_MEMORY_FOR_POSIX_TIMERS( CONFIGURE_MAXIMUM_POSIX_TIMERS ), -#endif - - /* Stack space sizes */ - _CONFIGURE_IDLE_TASKS_STACK, - _CONFIGURE_INITIALIZATION_THREADS_EXTRA_STACKS, - _CONFIGURE_TASKS_STACK, - _CONFIGURE_POSIX_THREADS_STACK, - _CONFIGURE_GOROUTINES_STACK, - _CONFIGURE_ADA_TASKS_STACK, - CONFIGURE_EXTRA_MPCI_RECEIVE_SERVER_STACK, - CONFIGURE_EXTRA_TASK_STACKS - }; -#endif - -/* - * Make sure a task/thread of some sort is configured. - * - * When analyzing RTEMS to find the smallest possible of memory - * that must be allocated, you probably do want to configure 0 - * tasks/threads so there is a smaller set of calls to _Workspace_Allocate - * to analyze. - */ -#if !defined(CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION) - #if (CONFIGURE_MAXIMUM_TASKS == 0) && \ - (CONFIGURE_MAXIMUM_POSIX_THREADS == 0) && \ - (CONFIGURE_MAXIMUM_ADA_TASKS == 0) && \ - (CONFIGURE_MAXIMUM_GOROUTINES == 0) - #error "CONFIGURATION ERROR: No tasks or threads configured!!" - #endif -#endif - -#ifndef RTEMS_SCHEDSIM -/* - * Make sure at least one of the initialization task/thread - * tables was defined. - */ -#if !defined(CONFIGURE_RTEMS_INIT_TASKS_TABLE) && \ - !defined(CONFIGURE_POSIX_INIT_THREAD_TABLE) && \ - !defined(CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION) -#error "CONFIGURATION ERROR: No initialization tasks or threads configured!!" -#endif -#endif - -/* - * If the user is trying to configure a multiprocessing application and - * RTEMS was not configured and built multiprocessing, then error out. - */ -#if defined(CONFIGURE_MP_APPLICATION) && \ - !defined(RTEMS_MULTIPROCESSING) -#error "CONFIGURATION ERROR: RTEMS not configured for multiprocessing!!" -#endif - -/* - * If an attempt was made to configure POSIX objects and - * the POSIX API was not configured into RTEMS, error out. - * - * @note POSIX Keys are always available so the parameters - * CONFIGURE_MAXIMUM_POSIX_KEYS and - * CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS are not in this list. - */ -#if !defined(RTEMS_POSIX_API) - #if ((CONFIGURE_MAXIMUM_POSIX_THREADS != 0) || \ - (CONFIGURE_MAXIMUM_POSIX_TIMERS != 0) || \ - (CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS != 0) || \ - (CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES != 0) || \ - (CONFIGURE_MAXIMUM_POSIX_SEMAPHORES != 0) || \ - (CONFIGURE_MAXIMUM_POSIX_SHMS != 0) || \ - defined(CONFIGURE_POSIX_INIT_THREAD_TABLE)) - #error "CONFIGURATION ERROR: POSIX API support not configured!!" - #endif -#endif - -#if !defined(RTEMS_SCHEDSIM) - #if !defined(CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE) - /* - * You must either explicity include or exclude the clock driver. - * It is such a common newbie error to leave it out. Maybe this - * will put an end to it. - * - * NOTE: If you are using the timer driver, it is considered - * mutually exclusive with the clock driver because the - * drivers are assumed to use the same "timer" hardware - * on many boards. - */ - #if !defined(CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER) && \ - !defined(CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER) && \ - !defined(CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER) - #error "CONFIGURATION ERROR: Do you want the clock driver or not?!?" - #endif - - /* - * Only one of the following three configuration parameters should be - * defined at a time. - */ - #if ((defined(CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER) + \ - defined(CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER) + \ - defined(CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER)) > 1) - #error "CONFIGURATION ERROR: More than one clock/timer driver configuration parameter specified?!?" - #endif - #endif /* !defined(CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE) */ -#endif /* !defined(RTEMS_SCHEDSIM) */ - -/* - * These names have been obsoleted so make the user application stop compiling - */ -#if defined(CONFIGURE_TEST_NEEDS_TIMER_DRIVER) || \ - defined(CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER) || \ - defined(CONFIGURE_TEST_NEEDS_CLOCK_DRIVER) || \ - defined(CONFIGURE_TEST_NEEDS_RTC_DRIVER) || \ - defined(CONFIGURE_TEST_NEEDS_STUB_DRIVER) -#error "CONFIGURATION ERROR: CONFIGURE_TEST_XXX constants are obsolete" -#endif - -/* - * Validate the configured maximum priority - */ -#if ((CONFIGURE_MAXIMUM_PRIORITY != 3) && \ - (CONFIGURE_MAXIMUM_PRIORITY != 7) && \ - (CONFIGURE_MAXIMUM_PRIORITY != 15) && \ - (CONFIGURE_MAXIMUM_PRIORITY != 31) && \ - (CONFIGURE_MAXIMUM_PRIORITY != 63) && \ - (CONFIGURE_MAXIMUM_PRIORITY != 127) && \ - (CONFIGURE_MAXIMUM_PRIORITY != 255)) - #error "Maximum priority is not 1 less than a power of 2 between 4 and 256" -#endif - -#if (CONFIGURE_MAXIMUM_PRIORITY > PRIORITY_DEFAULT_MAXIMUM) - #error "Maximum priority configured higher than supported by target." -#endif - -#ifdef CONFIGURE_MAXIMUM_POSIX_BARRIERS - #warning "The CONFIGURE_MAXIMUM_POSIX_BARRIERS configuration option is obsolete since RTEMS 5.1" -#endif - -#ifdef CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES - #warning "The CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES configuration option is obsolete since RTEMS 5.1" -#endif - -#ifdef CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUE_DESCRIPTORS - #warning "The CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUE_DESCRIPTORS configuration option is obsolete since RTEMS 5.1" -#endif - -#ifdef CONFIGURE_MAXIMUM_POSIX_MUTEXES - #warning "The CONFIGURE_MAXIMUM_POSIX_MUTEXES configuration option is obsolete since RTEMS 5.1" -#endif - -#ifdef CONFIGURE_MAXIMUM_POSIX_RWLOCKS - #warning "The CONFIGURE_MAXIMUM_POSIX_RWLOCKS configuration option is obsolete since RTEMS 5.1" -#endif - -#ifdef CONFIGURE_MAXIMUM_POSIX_SPINLOCKS - #warning "The CONFIGURE_MAXIMUM_POSIX_SPINLOCKS configuration option is obsolete since RTEMS 5.1" -#endif - -/* - * POSIX Key pair shouldn't be less than POSIX Key, which is highly - * likely to be error. - */ -#if (CONFIGURE_MAXIMUM_POSIX_KEYS != 0) && \ - (CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS != 0) - #if (CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS < CONFIGURE_MAXIMUM_POSIX_KEYS) - #error "Fewer POSIX Key pairs than POSIX Key!" - #endif -#endif - -/* - * IMFS block size for in memory files (memfiles) must be a power of - * two between 16 and 512 inclusive. - */ -#if ((CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 16) && \ - (CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 32) && \ - (CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 64) && \ - (CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 128) && \ - (CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 256) && \ - (CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK != 512)) - #error "IMFS Memfile block size must be a power of 2 between 16 and 512" -#endif - - -#endif -/* end of include file */ diff --git a/cpukit/sapi/include/rtems/bsd.h b/cpukit/sapi/include/rtems/bsd.h deleted file mode 100644 index 0c44e3787d..0000000000 --- a/cpukit/sapi/include/rtems/bsd.h +++ /dev/null @@ -1,141 +0,0 @@ -/** - * @file - * - * @ingroup BSD - * - * @brief BSD Compatibility API - */ - -/* - * Copyright (c) 2015 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_BSD_H -#define _RTEMS_BSD_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup BSD BSD Compatibility Support - * - * @{ - */ - -/** - * @copydoc _Timecounter_Bintime() - */ -RTEMS_INLINE_ROUTINE void rtems_bsd_bintime( struct bintime *bt ) -{ - _Timecounter_Bintime( bt ); -} - -/** - * @copydoc _Timecounter_Nanotime() - */ -RTEMS_INLINE_ROUTINE void rtems_bsd_nanotime( struct timespec *ts ) -{ - _Timecounter_Nanotime( ts ); -} - -/** - * @copydoc _Timecounter_Microtime() - */ -RTEMS_INLINE_ROUTINE void rtems_bsd_microtime( struct timeval *tv ) -{ - _Timecounter_Microtime( tv ); -} - -/** - * @copydoc _Timecounter_Binuptime() - */ -RTEMS_INLINE_ROUTINE void rtems_bsd_binuptime( struct bintime *bt ) -{ - _Timecounter_Binuptime( bt ); -} - -/** - * @copydoc _Timecounter_Nanouptime() - */ -RTEMS_INLINE_ROUTINE void rtems_bsd_nanouptime( struct timespec *ts ) -{ - _Timecounter_Nanouptime( ts ); -} - -/** - * @copydoc _Timecounter_Microtime() - */ -RTEMS_INLINE_ROUTINE void rtems_bsd_microuptime( struct timeval *tv ) -{ - _Timecounter_Microuptime( tv ); -} - -/** - * @copydoc _Timecounter_Getbintime() - */ -RTEMS_INLINE_ROUTINE void rtems_bsd_getbintime( struct bintime *bt ) -{ - _Timecounter_Getbintime( bt ); -} - -/** - * @copydoc _Timecounter_Getnanotime() - */ -RTEMS_INLINE_ROUTINE void rtems_bsd_getnanotime( struct timespec *ts ) -{ - _Timecounter_Getnanotime( ts ); -} - -/** - * @copydoc _Timecounter_Getmicrotime() - */ -RTEMS_INLINE_ROUTINE void rtems_bsd_getmicrotime( struct timeval *tv ) -{ - _Timecounter_Getmicrotime( tv ); -} - -/** - * @copydoc _Timecounter_Getbinuptime() - */ -RTEMS_INLINE_ROUTINE void rtems_bsd_getbinuptime( struct bintime *bt ) -{ - _Timecounter_Getbinuptime( bt ); -} - -/** - * @copydoc _Timecounter_Getnanouptime() - */ -RTEMS_INLINE_ROUTINE void rtems_bsd_getnanouptime( struct timespec *ts ) -{ - _Timecounter_Getnanouptime( ts ); -} - -/** - * @copydoc _Timecounter_Getmicrouptime() - */ -RTEMS_INLINE_ROUTINE void rtems_bsd_getmicrouptime( struct timeval *tv ) -{ - _Timecounter_Getmicrouptime( tv ); -} - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_BSD_H */ diff --git a/cpukit/sapi/include/rtems/cbs.h b/cpukit/sapi/include/rtems/cbs.h deleted file mode 100644 index a42061ddc0..0000000000 --- a/cpukit/sapi/include/rtems/cbs.h +++ /dev/null @@ -1,244 +0,0 @@ -/** - * @file - * - * @brief Constants and Structures Associated - * with the CBS library in RTEMS - * - * This include file contains all the constants and structures associated - * with the CBS library in RTEMS. - */ - -/* - * Copyright (C) 2011 Petr Benes. - * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef CONFIGURE_SCHEDULER_CBS - #error "cbs.h available only with CONFIGURE_SCHEDULER_CBS" -#endif - -#ifndef _RTEMS_CBS_H -#define _RTEMS_CBS_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* Return codes. */ -#define RTEMS_CBS_OK SCHEDULER_CBS_OK -#define RTEMS_CBS_ERROR_GENERIC SCHEDULER_CBS_ERROR_GENERIC -#define RTEMS_CBS_ERROR_NO_MEMORY SCHEDULER_CBS_ERROR_NO_MEMORY -#define RTEMS_CBS_ERROR_INVALID_PARAMETER SCHEDULER_CBS_ERROR_INVALID_PARAM -#define RTEMS_CBS_ERROR_UNAUTHORIZED SCHEDULER_CBS_ERROR_UNAUTHORIZED -#define RTEMS_CBS_ERROR_UNIMPLEMENTED SCHEDULER_CBS_ERROR_UNIMPLEMENTED -#define RTEMS_CBS_ERROR_MISSING_COMPONENT SCHEDULER_CBS_ERROR_MISSING_COMPONENT -#define RTEMS_CBS_ERROR_INCONSISTENT_STATE SCHEDULER_CBS_ERROR_INCONSISTENT_STATE -#define RTEMS_CBS_ERROR_SYSTEM_OVERLOAD SCHEDULER_CBS_ERROR_SYSTEM_OVERLOAD -#define RTEMS_CBS_ERROR_INTERNAL_ERROR SCHEDULER_CBS_ERROR_INTERNAL_ERROR -#define RTEMS_CBS_ERROR_NOT_FOUND SCHEDULER_CBS_ERROR_NOT_FOUND -#define RTEMS_CBS_ERROR_FULL SCHEDULER_CBS_ERROR_FULL -#define RTEMS_CBS_ERROR_EMPTY SCHEDULER_CBS_ERROR_EMPTY -#define RTEMS_CBS_ERROR_NOSERVER SCHEDULER_CBS_ERROR_NOSERVER - -/** Callback function invoked when a budget overrun of a task occurs. */ -typedef Scheduler_CBS_Budget_overrun rtems_cbs_budget_overrun; - -/** Server id. */ -typedef Scheduler_CBS_Server_id rtems_cbs_server_id; - -/** Server parameters. */ -typedef Scheduler_CBS_Parameters rtems_cbs_parameters; - -/** - * @brief Initialize the CBS library. - * - * Initializes the CBS library. - * - * @return status code. - */ -RTEMS_INLINE_ROUTINE int rtems_cbs_initialize ( void ) -{ - return _Scheduler_CBS_Initialize(); -} - -/** - * @brief Cleanup resources associated to the CBS Library - * - * Cleanup resources associated to the CBS Library. - * - * @return status code. - */ -RTEMS_INLINE_ROUTINE int rtems_cbs_cleanup ( void ) -{ - return _Scheduler_CBS_Cleanup(); -} - -/** - * @brief Create a new server with specified parameters. - * - * Create a new server with specified parameters. - * - * @return status code. - */ -RTEMS_INLINE_ROUTINE int rtems_cbs_create_server ( - rtems_cbs_parameters *params, - rtems_cbs_budget_overrun budget_overrun_callback, - rtems_cbs_server_id *server_id -) -{ - return _Scheduler_CBS_Create_server( - params, - budget_overrun_callback, - server_id - ); -} - -/** - * @brief Attach a task to an already existing server. - * - * Attach a task to an already existing server. - * - * @return status code. - */ -RTEMS_INLINE_ROUTINE int rtems_cbs_attach_thread ( - rtems_cbs_server_id server_id, - rtems_id task_id -) -{ - return _Scheduler_CBS_Attach_thread( server_id, task_id ); -} - -/** - * @brief Detach from the CBS server. - * - * Detach from the CBS Server. - * - * @return status code. - */ -RTEMS_INLINE_ROUTINE int rtems_cbs_detach_thread ( - rtems_cbs_server_id server_id, - rtems_id task_id -) -{ - return _Scheduler_CBS_Detach_thread( server_id, task_id ); -} - -/** - * @brief Detach all tasks from a server and destroy it. - * - * Detach all tasks from a server and destroy it. - * - * @return status code. - */ -RTEMS_INLINE_ROUTINE int rtems_cbs_destroy_server ( - rtems_cbs_server_id server_id -) -{ - return _Scheduler_CBS_Destroy_server( server_id ); -} - -/** - * @brief Get CBS server id. - * - * Get a thread server id, or RTEMS_CBS_E_NOT_FOUND if it is not - * attached to any server. - * - * @return status code. - */ -RTEMS_INLINE_ROUTINE int rtems_cbs_get_server_id ( - rtems_id task_id, - rtems_cbs_server_id *server_id -) -{ - return _Scheduler_CBS_Get_server_id( task_id, server_id ); -} - -/** - * @brief Get CBS parameters. - * - * Retrieve CBS scheduling parameters. - * - * @return status code. - */ -RTEMS_INLINE_ROUTINE int rtems_cbs_get_parameters ( - rtems_cbs_server_id server_id, - rtems_cbs_parameters *params -) -{ - return _Scheduler_CBS_Get_parameters( server_id, params ); -} - -/** - * @brief Set CBS parameters. - * - * Change CBS scheduling parameters. - * - * @return status code. - */ -RTEMS_INLINE_ROUTINE int rtems_cbs_set_parameters ( - rtems_cbs_server_id server_id, - rtems_cbs_parameters *params -) -{ - return _Scheduler_CBS_Set_parameters( server_id, params ); -} - -/** - * @brief Get the CBS get execution time. - * - * Retrieve time info relative to the current server. - * - * @return status code. - */ -RTEMS_INLINE_ROUTINE int rtems_cbs_get_execution_time ( - rtems_cbs_server_id server_id, - time_t *exec_time, - time_t *abs_time -) -{ - return _Scheduler_CBS_Get_execution_time( server_id, exec_time, abs_time ); -} - -/** - * @brief Get the remaining CBS budget. - * - * Retrieve remaining budget for the current server instance. - * - * @return status code. - */ -RTEMS_INLINE_ROUTINE int rtems_cbs_get_remaining_budget ( - rtems_cbs_server_id server_id, - time_t *remaining_budget -) -{ - return _Scheduler_CBS_Get_remaining_budget( server_id, remaining_budget ); -} - -/** - * @brief Get the approved CBS budget. - * - * Retrieve the budget that has been approved for the subsequent - * server instances. - * - * @return status code. - */ -RTEMS_INLINE_ROUTINE int rtems_cbs_get_approved_budget ( - rtems_cbs_server_id server_id, - time_t *appr_budget -) -{ - return _Scheduler_CBS_Get_approved_budget( server_id, appr_budget ); -} - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/sapi/include/rtems/chain.h b/cpukit/sapi/include/rtems/chain.h deleted file mode 100644 index f0e7ee4f40..0000000000 --- a/cpukit/sapi/include/rtems/chain.h +++ /dev/null @@ -1,789 +0,0 @@ -/** - * @file - * - * @brief Chain API - */ - -/* - * Copyright (c) 2010-2014 embedded brains GmbH. - * - * COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_CHAIN_H -#define _RTEMS_CHAIN_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicChains Chains - * - * @ingroup ClassicRTEMS - * - * @brief Chain API - */ -/**@{**/ - -typedef Chain_Node rtems_chain_node; - -typedef Chain_Control rtems_chain_control; - -/** - * @brief Chain initializer for an empty chain with designator @a name. - */ -#define RTEMS_CHAIN_INITIALIZER_EMPTY( name ) \ - CHAIN_INITIALIZER_EMPTY( name ) - -/** - * @brief Chain initializer for a chain with one @a node. - * - * @see RTEMS_CHAIN_NODE_INITIALIZER_ONE_NODE_CHAIN(). - */ -#define RTEMS_CHAIN_INITIALIZER_ONE_NODE( node ) \ - CHAIN_INITIALIZER_ONE_NODE( node ) - -/** - * @brief Chain node initializer for a @a chain containing exactly this node. - * - * @see RTEMS_CHAIN_INITIALIZER_ONE_NODE(). - */ -#define RTEMS_CHAIN_NODE_INITIALIZER_ONE_NODE_CHAIN( chain ) \ - CHAIN_NODE_INITIALIZER_ONE_NODE_CHAIN( chain ) - -/** - * @brief Chain definition for an empty chain with designator @a name. - */ -#define RTEMS_CHAIN_DEFINE_EMPTY( name ) \ - rtems_chain_control name = RTEMS_CHAIN_INITIALIZER_EMPTY( name ) - -/** - * @brief Appends the @a node to the @a chain and sends the @a events to the - * @a task if the @a chain was empty before the append. - * - * @see rtems_chain_append_with_empty_check() and rtems_event_send(). - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_INVALID_ID No such task. - */ -rtems_status_code rtems_chain_append_with_notification( - rtems_chain_control *chain, - rtems_chain_node *node, - rtems_id task, - rtems_event_set events -); - -/** - * @brief Prepends the @a node to the @a chain and sends the @a events to the - * @a task if the @a chain was empty before the prepend. - * - * @see rtems_chain_prepend_with_empty_check() and rtems_event_send(). - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_INVALID_ID No such task. - */ -rtems_status_code rtems_chain_prepend_with_notification( - rtems_chain_control *chain, - rtems_chain_node *node, - rtems_id task, - rtems_event_set events -); - -/** - * @brief Gets the first @a node of the @a chain and sends the @a events to the - * @a task if the @a chain is empty after the get. - * - * @see rtems_chain_get_with_empty_check() and rtems_event_send(). - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_INVALID_ID No such task. - */ -rtems_status_code rtems_chain_get_with_notification( - rtems_chain_control *chain, - rtems_id task, - rtems_event_set events, - rtems_chain_node **node -); - -/** - * @brief Gets the first @a node of the @a chain and sends the @a events to the - * @a task if the @a chain is empty afterwards. - * - * @see rtems_chain_get() and rtems_event_receive(). - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_TIMEOUT Timeout. - */ -rtems_status_code rtems_chain_get_with_wait( - rtems_chain_control *chain, - rtems_event_set events, - rtems_interval timeout, - rtems_chain_node **node -); - -/** - * @brief Initialize a chain Header. - * - * This routine initializes @a the_chain structure to manage the - * contiguous array of @a number_nodes nodes which starts at - * @a starting_address. Each node is of @a node_size bytes. - * - * @param[in] the_chain specifies the chain to initialize - * @param[in] starting_address is the starting address of the array - * of elements - * @param[in] number_nodes is the number of nodes that will be in the chain - * @param[in] node_size is the size of each node - */ -RTEMS_INLINE_ROUTINE void rtems_chain_initialize( - rtems_chain_control *the_chain, - void *starting_address, - size_t number_nodes, - size_t node_size -) -{ - _Chain_Initialize( - the_chain, - starting_address, - number_nodes, - node_size - ); -} - -/** - * @brief Initialize this chain as empty. - * - * This routine initializes the specified chain to contain zero nodes. - * - * @param[in] the_chain is the chain to be initialized. - */ -RTEMS_INLINE_ROUTINE void rtems_chain_initialize_empty( - rtems_chain_control *the_chain -) -{ - _Chain_Initialize_empty( the_chain ); -} - -/** - * @brief Set off chain. - * - * This function sets the next and previous fields of the @a node to NULL - * indicating the @a node is not part of a chain. - * - * @param[in] node the node set to off chain. - */ -RTEMS_INLINE_ROUTINE void rtems_chain_set_off_chain( - rtems_chain_node *node -) -{ - _Chain_Set_off_chain( node ); -} - -/** - * @brief Initializes a chain node. - * - * In debug configurations, the node is set off chain. In all other - * configurations, this function does nothing. - * - * @param[in] the_node The chain node to initialize. - */ -RTEMS_INLINE_ROUTINE void rtems_chain_initialize_node( - rtems_chain_node *node -) -{ - _Chain_Initialize_node( node ); -} - -/** - * @brief Is the node off chain. - * - * This function returns true if the @a node is not on a chain. A @a node is - * off chain if the next and previous fields are set to NULL. - * - * @param[in] node is the node off chain. - * - * @retval true The node is off chain. - * @retval false The node is not off chain. - */ -RTEMS_INLINE_ROUTINE bool rtems_chain_is_node_off_chain( - const rtems_chain_node *node -) -{ - return _Chain_Is_node_off_chain( node ); -} - -/** - * @brief Is the chain node pointer NULL. - * - * This function returns true if the_node is NULL and false otherwise. - * - * @param[in] the_node is the node pointer to check. - * - * @retval true The chain node pointer is NULL. - * @retval false The chain node pointer is not NULL. - */ -RTEMS_INLINE_ROUTINE bool rtems_chain_is_null_node( - const rtems_chain_node *the_node -) -{ - return _Chain_Is_null_node( the_node ); -} - -/** - * @brief Return pointer to Chain Head - * - * This function returns a pointer to the first node on the chain. - * - * @param[in] the_chain is the chain to be operated upon. - * - * @return This method returns the permanent node of the chain. - */ -RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_head( - rtems_chain_control *the_chain -) -{ - return _Chain_Head( the_chain ); -} - -/** - * @brief Return pointer to immutable Chain Head - * - * This function returns a pointer to the head node on the chain. - * - * @param[in] the_chain is the chain to be operated upon. - * - * @return This method returns the permanent head node of the chain. - */ -RTEMS_INLINE_ROUTINE const rtems_chain_node *rtems_chain_immutable_head( - const rtems_chain_control *the_chain -) -{ - return _Chain_Immutable_head( the_chain ); -} - -/** - * @brief Return pointer to Chain Tail - * - * This function returns a pointer to the tail node on the chain. - * - * @param[in] the_chain is the chain to be operated upon. - * - * @return This method returns the permanent tail node of the chain. - */ -RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_tail( - rtems_chain_control *the_chain -) -{ - return _Chain_Tail( the_chain ); -} - -/** - * @brief Return pointer to immutable Chain Tail - * - * This function returns a pointer to the tail node on the chain. - * - * @param[in] the_chain is the chain to be operated upon. - * - * @return This method returns the permanent tail node of the chain. - */ -RTEMS_INLINE_ROUTINE const rtems_chain_node *rtems_chain_immutable_tail( - const rtems_chain_control *the_chain -) -{ - return _Chain_Immutable_tail( the_chain ); -} - -/** - * @brief Return pointer to Chain's First node after the permanent head. - * - * This function returns a pointer to the first node on the chain after the - * head. - * - * @param[in] the_chain is the chain to be operated upon. - * - * @return This method returns the first node of the chain. - */ -RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_first( - const rtems_chain_control *the_chain -) -{ - return _Chain_First( the_chain ); -} - -/** - * @brief Return pointer to immutable Chain's First node - * - * This function returns a pointer to the first node on the chain after the - * head. - * - * @param[in] the_chain is the chain to be operated upon. - * - * @return This method returns the first node of the chain. - */ -RTEMS_INLINE_ROUTINE const rtems_chain_node *rtems_chain_immutable_first( - const rtems_chain_control *the_chain -) -{ - return _Chain_Immutable_first( the_chain ); -} - -/** - * @brief Return pointer to Chain's Last node before the permanent tail. - * - * This function returns a pointer to the last node on the chain just before - * the tail. - * - * @param[in] the_chain is the chain to be operated upon. - * - * @return This method returns the last node of the chain. - */ -RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_last( - const rtems_chain_control *the_chain -) -{ - return _Chain_Last( the_chain ); -} - -/** - * @brief Return pointer to immutable Chain's Last node - * - * This function returns a pointer to the last node on the chain just before - * the tail. - * - * @param[in] the_chain is the chain to be operated upon. - * - * @return This method returns the last node of the chain. - */ -RTEMS_INLINE_ROUTINE const rtems_chain_node *rtems_chain_immutable_last( - const rtems_chain_control *the_chain -) -{ - return _Chain_Immutable_last( the_chain ); -} - -/** - * @brief Return pointer the next node from this node - * - * This function returns a pointer to the next node after this node. - * - * @param[in] the_node is the node to be operated upon. - * - * @return This method returns the next node on the chain. - */ -RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_next( - const rtems_chain_node *the_node -) -{ - return _Chain_Next( the_node ); -} - -/** - * @brief Return pointer the immutable next node from this node - * - * This function returns a pointer to the next node after this node. - * - * @param[in] the_node is the node to be operated upon. - * - * @return This method returns the next node on the chain. - */ -RTEMS_INLINE_ROUTINE const rtems_chain_node *rtems_chain_immutable_next( - const rtems_chain_node *the_node -) -{ - return _Chain_Immutable_next( the_node ); -} - -/** - * @brief Return pointer the previous node from this node - * - * This function returns a pointer to the previous node on this chain. - * - * @param[in] the_node is the node to be operated upon. - * - * @return This method returns the previous node on the chain. - */ -RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_previous( - const rtems_chain_node *the_node -) -{ - return _Chain_Previous( the_node ); -} - -/** - * @brief Return pointer the immutable previous node from this node. - * - * This function returns a pointer to the previous node on this chain. - * - * @param[in] the_node is the node to be operated upon. - * - * @return This method returns the previous node on the chain. - */ -RTEMS_INLINE_ROUTINE const rtems_chain_node *rtems_chain_immutable_previous( - const rtems_chain_node *the_node -) -{ - return _Chain_Immutable_previous( the_node ); -} - -/** - * @brief Are Two nodes equal. - * - * This function returns true if @a left and @a right are equal, - * and false otherwise. - * - * @param[in] left is the node on the left hand side of the comparison. - * @param[in] right is the node on the left hand side of the comparison. - * - * @retval true @a left is equal to @a right. - * @retval false @a left is not equal to @a right - */ -RTEMS_INLINE_ROUTINE bool rtems_chain_are_nodes_equal( - const rtems_chain_node *left, - const rtems_chain_node *right -) -{ - return _Chain_Are_nodes_equal( left, right ); -} - -/** - * @brief Is the chain empty - * - * This function returns true if there a no nodes on @a the_chain and - * false otherwise. - * - * @param[in] the_chain is the chain to be operated upon. - * - * @retval true The chain is empty. - * @retval false The chain is not empty. - */ -RTEMS_INLINE_ROUTINE bool rtems_chain_is_empty( - const rtems_chain_control *the_chain -) -{ - return _Chain_Is_empty( the_chain ); -} - -/** - * @brief Is this the first node on the chain. - * - * This function returns true if the_node is the first node on a chain and - * false otherwise. - * - * @param[in] the_node is the node the caller wants to know if it is - * the first node on a chain. - * - * @retval true @a the_node is the first node on a chain. - * @retval false @a the_node is not the first node on a chain. - */ -RTEMS_INLINE_ROUTINE bool rtems_chain_is_first( - const rtems_chain_node *the_node -) -{ - return _Chain_Is_first( the_node ); -} - -/** - * @brief Is this the last node on the chain. - * - * This function returns true if @a the_node is the last node on a chain and - * false otherwise. - * - * @param[in] the_node is the node to check as the last node. - * - * @retval true @a the_node is the last node on a chain. - * @retval false @a the_node is not the last node on a chain - */ -RTEMS_INLINE_ROUTINE bool rtems_chain_is_last( - const rtems_chain_node *the_node -) -{ - return _Chain_Is_last( the_node ); -} - -/** - * @brief Does this chain have only one node. - * - * This function returns true if there is only one node on @a the_chain and - * false otherwise. - * - * @param[in] the_chain is the chain to be operated upon. - * - * @retval true The chain has only one node. - * @retval false The chain has more than one nodes. - */ -RTEMS_INLINE_ROUTINE bool rtems_chain_has_only_one_node( - const rtems_chain_control *the_chain -) -{ - return _Chain_Has_only_one_node( the_chain ); -} - -/** - * @brief Is this node the chain head. - * - * This function returns true if @a the_node is the head of the_chain and - * false otherwise. - * - * @param[in] the_chain is the chain to be operated upon. - * @param[in] the_node is the node to check for being the Chain Head. - * - * @retval true @a the_node is the head of @a the_chain. - * @retval false @a the_node is not the head of @a the_chain. - */ -RTEMS_INLINE_ROUTINE bool rtems_chain_is_head( - const rtems_chain_control *the_chain, - const rtems_chain_node *the_node -) -{ - return _Chain_Is_head( the_chain, the_node ); -} - -/** - * @brief Is this node the chain tail. - * - * This function returns true if the_node is the tail of the_chain and - * false otherwise. - * - * @param[in] the_chain is the chain to be operated upon. - * @param[in] the_node is the node to check for being the Chain Tail. - * - * @retval true @a the_node is the tail of @a the_chain. - * @retval false @a the_node is not the tail of @a the_chain. - */ -RTEMS_INLINE_ROUTINE bool rtems_chain_is_tail( - const rtems_chain_control *the_chain, - const rtems_chain_node *the_node -) -{ - return _Chain_Is_tail( the_chain, the_node ); -} - -/** - * @brief Extract the specified node from a chain. - * - * This routine extracts @a the_node from the chain on which it resides. - * It disables interrupts to ensure the atomicity of the - * extract operation. - * - * @arg the_node specifies the node to extract - */ -void rtems_chain_extract( - rtems_chain_node *the_node -); - -/** - * @brief Extract the specified node from a chain (unprotected). - * - * This routine extracts @a the_node from the chain on which it resides. - * - * NOTE: It does NOT disable interrupts to ensure the atomicity of the - * append operation. - */ -RTEMS_INLINE_ROUTINE void rtems_chain_extract_unprotected( - rtems_chain_node *the_node -) -{ - _Chain_Extract_unprotected( the_node ); -} - -/** - * @brief Obtain the first node on a chain. - * - * This function removes the first node from @a the_chain and returns - * a pointer to that node. If @a the_chain is empty, then NULL is returned. - * - * @return This method returns a pointer a node. If a node was removed, - * then a pointer to that node is returned. If @a the_chain was - * empty, then NULL is returned. - * - * NOTE: It disables interrupts to ensure the atomicity of the get operation. - */ -rtems_chain_node *rtems_chain_get( - rtems_chain_control *the_chain -); - -/** - * @brief See _Chain_Get_unprotected(). - */ -RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_get_unprotected( - rtems_chain_control *the_chain -) -{ - return _Chain_Get_unprotected( the_chain ); -} - -/** - * @brief See _Chain_Get_first_unprotected(). - */ -RTEMS_INLINE_ROUTINE rtems_chain_node *rtems_chain_get_first_unprotected( - rtems_chain_control *the_chain -) -{ - return _Chain_Get_first_unprotected( the_chain ); -} - -/** - * @brief Insert a node on a chain - * - * This routine inserts @a the_node on a chain immediately following - * @a after_node. - * - * NOTE: It disables interrupts to ensure the atomicity - * of the extract operation. - */ -void rtems_chain_insert( - rtems_chain_node *after_node, - rtems_chain_node *the_node -); - -/** - * @brief See _Chain_Insert_unprotected(). - */ -RTEMS_INLINE_ROUTINE void rtems_chain_insert_unprotected( - rtems_chain_node *after_node, - rtems_chain_node *the_node -) -{ - _Chain_Insert_unprotected( after_node, the_node ); -} - -/** - * @brief Append a node on the end of a chain. - * - * This routine appends @a the_node onto the end of @a the_chain. - * - * NOTE: It disables interrupts to ensure the atomicity of the - * append operation. - */ -void rtems_chain_append( - rtems_chain_control *the_chain, - rtems_chain_node *the_node -); - -/** - * @brief Append a node on the end of a chain (unprotected). - * - * This routine appends @a the_node onto the end of @a the_chain. - * - * NOTE: It does NOT disable interrupts to ensure the atomicity of the - * append operation. - */ -RTEMS_INLINE_ROUTINE void rtems_chain_append_unprotected( - rtems_chain_control *the_chain, - rtems_chain_node *the_node -) -{ - _Chain_Append_unprotected( the_chain, the_node ); -} - -/** - * @brief Prepend a node. - * - * This routine prepends the_node onto the front of the_chain. - * - * @param[in] the_chain is the chain to be operated upon. - * @param[in] the_node is the node to be prepended. - * - * NOTE: It disables interrupts to ensure the atomicity of the - * prepend operation. - */ -void rtems_chain_prepend( - rtems_chain_control *the_chain, - rtems_chain_node *the_node -); - -/** - * @brief Prepend a node (unprotected). - * - * This routine prepends the_node onto the front of the_chain. - * - * @param[in] the_chain is the chain to be operated upon. - * @param[in] the_node is the node to be prepended. - * - * NOTE: It does NOT disable interrupts to ensure the atomicity of the - * prepend operation. - */ -RTEMS_INLINE_ROUTINE void rtems_chain_prepend_unprotected( - rtems_chain_control *the_chain, - rtems_chain_node *the_node -) -{ - _Chain_Prepend_unprotected( the_chain, the_node ); -} - -/** - * @brief Checks if the @a chain is empty and appends the @a node. - * - * Interrupts are disabled to ensure the atomicity of the operation. - * - * @retval true The chain was empty before the append. - * @retval false The chain contained at least one node before the append. - */ -bool rtems_chain_append_with_empty_check( - rtems_chain_control *chain, - rtems_chain_node *node -); - -/** - * @brief Checks if the @a chain is empty and prepends the @a node. - * - * Interrupts are disabled to ensure the atomicity of the operation. - * - * @retval true The chain was empty before the prepend. - * @retval false The chain contained at least one node before the prepend. - */ -bool rtems_chain_prepend_with_empty_check( - rtems_chain_control *chain, - rtems_chain_node *node -); - -/** - * @brief Tries to get the first @a node and check if the @a chain is empty - * afterwards. - * - * This function removes the first node from the @a chain and returns a pointer - * to that node in @a node. If the @a chain is empty, then @c NULL is returned. - * - * Interrupts are disabled to ensure the atomicity of the operation. - * - * @retval true The chain is empty after the node removal. - * @retval false The chain contained at least one node after the node removal. - */ -bool rtems_chain_get_with_empty_check( - rtems_chain_control *chain, - rtems_chain_node **node -); - -/** - * @brief Returns the node count of the chain. - * - * @param[in] chain The chain. - * - * @note It does NOT disable interrupts to ensure the atomicity of the - * operation. - * - * @return The node count of the chain. - */ -RTEMS_INLINE_ROUTINE size_t rtems_chain_node_count_unprotected( - const rtems_chain_control *chain -) -{ - return _Chain_Node_count_unprotected( chain ); -} - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/sapi/include/rtems/config.h b/cpukit/sapi/include/rtems/config.h deleted file mode 100644 index 6b97376511..0000000000 --- a/cpukit/sapi/include/rtems/config.h +++ /dev/null @@ -1,397 +0,0 @@ -/** - * @file - * - * @brief Table of User Defined Configuration Parameters - * - * This include file contains the table of user defined configuration - * parameters. - */ - -/* - * COPYRIGHT (c) 1989-2014. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_CONFIG_H -#define _RTEMS_CONFIG_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Unlimited object support. Changes the configuration table entry for POSIX - * or RTEMS APIs to bounded only by the memory of the work-space. - * - * Use the macro to define the resource unlimited before placing in - * the configuration table. - */ - -#include -#define RTEMS_UNLIMITED_OBJECTS OBJECTS_UNLIMITED_OBJECTS - -#define rtems_resource_unlimited(resource) \ - ( resource | RTEMS_UNLIMITED_OBJECTS ) - -#define rtems_resource_is_unlimited(resource) \ - _Objects_Is_unlimited(resource) - -#define rtems_resource_maximum_per_allocation(resource) \ - _Objects_Maximum_per_allocation(resource) - -#include - -/* - * This is kind of kludgy but it allows targets to totally ignore the - * optional APIs like POSIX safely. - */ - -#ifdef RTEMS_POSIX_API -#include -#else -typedef void *posix_api_configuration_table; -#endif - -#include - -#include -#if defined(RTEMS_MULTIPROCESSING) -#include -#endif - -#if defined(RTEMS_MULTIPROCESSING) -/* - * The following records define the Multiprocessor Configuration - * Table. This table defines the multiprocessor system - * characteristics which must be known by RTEMS in a multiprocessor - * system. - */ -typedef struct { - /** This is the local node number. */ - uint32_t node; - /** This is the maximum number of nodes in system. */ - uint32_t maximum_nodes; - /** This is the maximum number of global objects. */ - uint32_t maximum_global_objects; - /** This is the maximum number of proxies. */ - uint32_t maximum_proxies; - - /** - * The MPCI Receive server is assumed to have a stack of at least - * minimum stack size. This field specifies the amount of extra - * stack this task will be given in bytes. - */ - uint32_t extra_mpci_receive_server_stack; - - /** This is a pointer to User/BSP provided MPCI Table. */ - rtems_mpci_table *User_mpci_table; -} rtems_multiprocessing_table; -#endif - -/** - * @brief Task stack allocator initialization hook. - * - * @param[in] stack_space_size is the size of the stack space in bytes. - */ -typedef void (*rtems_stack_allocate_init_hook)( size_t stack_space_size ); - -/** - * @brief Task stack allocator hook. - * - * @param[in] stack_size is the Size of the task stack in bytes. - * - * @retval NULL Not enough memory. - * @retval other Pointer to task stack. - */ -typedef void *(*rtems_stack_allocate_hook)( size_t stack_size ); - -/** - * @brief Task stack deallocator hook. - * - * @param[in] addr is a pointer to previously allocated task stack. - */ -typedef void (*rtems_stack_free_hook)( void *addr ); - -/* - * The following records define the Configuration Table. The - * information contained in this table is required in all - * RTEMS systems, whether single or multiprocessor. This - * table primarily defines the following: - * - * + location and size of the RTEMS Workspace - * + microseconds per clock tick - * + clock ticks per task timeslice - * + required number of each object type for each API configured - */ -typedef struct { - /** - * This field specifies the size in bytes of the RTEMS Workspace. - */ - uintptr_t work_space_size; - - /** - * This field specifies the size in bytes of the RTEMS thread stack space. - */ - uintptr_t stack_space_size; - - /** - * This field specifies the maximum number of dynamically installed - * used extensions. - */ - uint32_t maximum_extensions; - - /** - * This field contains the maximum number of POSIX API - * keys which are configured for this application. - */ - uint32_t maximum_keys; - - /** - * This field contains the maximum number of POSIX API - * key value pairs which are configured for this application. - * - * @note There can be potentially be a key/value pair for - * every thread to use every key. But normally this - * many are not needed in a system. - */ - uint32_t maximum_key_value_pairs; - - /** - * This field specifies the number of microseconds which elapse - * between clock ticks. This is the basis for RTEMS timing. - */ - uint32_t microseconds_per_tick; - - /** - * This field specifies the number of ticks in each task's timeslice. - */ - uint32_t ticks_per_timeslice; - - /** - * This element points to the BSP's optional idle task which may override - * the default one provided with RTEMS. - */ - void *(*idle_task)( uintptr_t ); - - /** - * This field specifies the size of the IDLE task's stack. If less than or - * equal to the minimum stack size, then the IDLE task will have the minimum - * stack size. - */ - uint32_t idle_task_stack_size; - - /** - * This field specifies the size of the interrupt stack. If less than or - * equal to the minimum stack size, then the interrupt stack will be of - * minimum stack size. - */ - uint32_t interrupt_stack_size; - - /** - * @brief Optional task stack allocator initialization hook. - */ - rtems_stack_allocate_init_hook stack_allocate_init_hook; - - /** - * @brief Optional task stack allocator hook. - */ - rtems_stack_allocate_hook stack_allocate_hook; - - /** - * @brief Optional task stack free hook. - */ - rtems_stack_free_hook stack_free_hook; - - /** - * If this element is TRUE, then RTEMS will zero the Executive Workspace. - * When this element is FALSE, it is assumed that the BSP or invoking - * environment has ensured that memory was cleared before RTEMS was - * invoked. - */ - bool do_zero_of_workspace; - - /** - * @brief Specifies if a unified work area is used or not. - * - * If this element is @a true, then the RTEMS Workspace and the C Program - * Heap use the same heap, otherwise they use separate heaps. - */ - bool unified_work_area; - - /** - * @brief Specifies if the stack allocator avoids the work space. - * - * If this element is @a true, then the stack allocator must not allocate the - * thread stacks from the RTEMS Workspace, otherwise it should allocate the - * thread stacks from the RTEMS Workspace. - */ - bool stack_allocator_avoids_work_space; - - #ifdef RTEMS_SMP - bool smp_enabled; - #endif - - uint32_t number_of_initial_extensions; - const rtems_extensions_table *User_extension_table; - #if defined(RTEMS_MULTIPROCESSING) - rtems_multiprocessing_table *User_multiprocessing_table; - #endif - #ifdef RTEMS_SMP - uint32_t maximum_processors; - #endif -} rtems_configuration_table; - -/** - * This is the configuration table generated by confdefs.h. - */ -extern const rtems_configuration_table Configuration; - -#if defined(RTEMS_MULTIPROCESSING) - /** - * This points to the multiprocessing configuration table. - */ - extern rtems_multiprocessing_table *_Configuration_MP_table; -#endif - -#if defined(RTEMS_MULTIPROCESSING) - /** - * @brief RTEMS multiprocessing configuration table. - * - * This is the RTEMS Multiprocessing Configuration Table expected to - * be generated by confdefs.h. - */ - extern rtems_multiprocessing_table Multiprocessing_configuration; - - /* - * This is the default Multiprocessing Configuration Table. - * It is used in single processor configurations. - */ - extern const rtems_multiprocessing_table - _Initialization_Default_multiprocessing_table; -#endif - - -/* - * Some handy macros to avoid dependencies on either the BSP - * or the exact format of the configuration table. - */ - -#define rtems_configuration_get_unified_work_area() \ - (Configuration.unified_work_area) - -#define rtems_configuration_get_stack_allocator_avoids_work_space() \ - (Configuration.stack_allocator_avoids_work_space) - -#define rtems_configuration_get_stack_space_size() \ - (Configuration.stack_space_size) - -#define rtems_configuration_get_work_space_size() \ - (Configuration.work_space_size + \ - (rtems_configuration_get_stack_allocator_avoids_work_space() ? \ - 0 : rtems_configuration_get_stack_space_size())) - -#define rtems_configuration_get_maximum_extensions() \ - (Configuration.maximum_extensions) - -#define rtems_configuration_get_microseconds_per_tick() \ - (Configuration.microseconds_per_tick) -#define rtems_configuration_get_milliseconds_per_tick() \ - (Configuration.microseconds_per_tick / 1000) -#define rtems_configuration_get_nanoseconds_per_tick() \ - (_Watchdog_Nanoseconds_per_tick) - -#define rtems_configuration_get_ticks_per_timeslice() \ - (Configuration.ticks_per_timeslice) - -#define rtems_configuration_get_idle_task() \ - (Configuration.idle_task) - -#define rtems_configuration_get_idle_task_stack_size() \ - (Configuration.idle_task_stack_size) - -#define rtems_configuration_get_interrupt_stack_size() \ - (Configuration.interrupt_stack_size) - -#define rtems_configuration_get_stack_allocate_init_hook() \ - (Configuration.stack_allocate_init_hook) - -#define rtems_configuration_get_stack_allocate_hook() \ - (Configuration.stack_allocate_hook) - -#define rtems_configuration_get_stack_free_hook() \ - (Configuration.stack_free_hook) - - /** - * This macro assists in accessing the field which indicates whether - * RTEMS is responsible for zeroing the Executive Workspace. - */ -#define rtems_configuration_get_do_zero_of_workspace() \ - (Configuration.do_zero_of_workspace) - -#define rtems_configuration_get_number_of_initial_extensions() \ - (Configuration.number_of_initial_extensions) - -#define rtems_configuration_get_user_extension_table() \ - (Configuration.User_extension_table) - -#if defined(RTEMS_MULTIPROCESSING) - #define rtems_configuration_get_user_multiprocessing_table() \ - (Configuration.User_multiprocessing_table) -#else - #define rtems_configuration_get_user_multiprocessing_table() \ - NULL -#endif - -/** - * @brief Returns true if the SMP mode of operation is enabled, and false - * otherwise. - * - * In uni-processor configurations this is a compile-time constant which - * evaluates to false. - * - * @retval true SMP mode of operation is enabled. - * @retval false Otherwise. - */ -#ifdef RTEMS_SMP - #define rtems_configuration_is_smp_enabled() \ - (Configuration.smp_enabled) -#else - #define rtems_configuration_is_smp_enabled() \ - false -#endif - -/** - * @brief Returns the configured maximum count of processors. - * - * The actual number of processors available for the application will be less - * than or equal to the configured maximum count of processors. - * - * On single-processor configurations this is a compile time constant which - * evaluates to one. - * - * @return The configured maximum count of processors. - */ -#ifdef RTEMS_SMP - #define rtems_configuration_get_maximum_processors() \ - (Configuration.maximum_processors) -#else - #define rtems_configuration_get_maximum_processors() \ - 1 -#endif - -#define rtems_configuration_get_rtems_api_configuration() \ - (&Configuration_RTEMS_API) - -#define rtems_configuration_get_posix_api_configuration() \ - (&Configuration_POSIX_API) - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/sapi/include/rtems/counter.h b/cpukit/sapi/include/rtems/counter.h deleted file mode 100644 index 3b428402a8..0000000000 --- a/cpukit/sapi/include/rtems/counter.h +++ /dev/null @@ -1,160 +0,0 @@ -/** - * @file - * - * @ingroup ClassicCounter - * - * @brief Free-Running Counter and Busy Wait Delay API - */ - -/* - * Copyright (c) 2014 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SAPI_COUNTER_H -#define _RTEMS_SAPI_COUNTER_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup ClassicCounter Free-Running Counter and Busy Wait Delay - * - * @ingroup ClassicRTEMS - * - * @brief Free-running counter and busy wait delay functions. - * - * The RTEMS counter is some free-running counter. It ticks usually with a - * frequency close to the CPU or system bus clock. - * - * The counter can be used in case the overhead of the - * rtems_clock_get_uptime_nanoseconds() is too high. The step from counter - * ticks to/from nanoseconds is explicit in this API unlike to - * rtems_clock_get_uptime_nanoseconds() which performs the conversion on each - * invocation. - * - * This counter works without a clock driver and during system initialization. - * - * The counter can be used to profile low-level operations like SMP locks or - * interrupt disabled critical sections. The counter can act also as an - * entropy source for a random number generator. - * - * The period of the counter depends on the actual hardware. - * - * @{ - */ - -/** - * @brief Unsigned integer type for counter values. - */ -typedef CPU_Counter_ticks rtems_counter_ticks; - -/** - * @brief Reads the current counter values. - * - * @return The current counter values. - */ -static inline rtems_counter_ticks rtems_counter_read( void ) -{ - return _CPU_Counter_read(); -} - -/** - * @brief Returns the difference between the second and first CPU counter - * value. - * - * This operation may be carried out as a modulo operation depending on the - * range of the CPU counter device. - * - * @param[in] second The second CPU counter value. - * @param[in] first The first CPU counter value. - * - * @return Returns second minus first modulo counter period. - */ -static inline rtems_counter_ticks rtems_counter_difference( - rtems_counter_ticks second, - rtems_counter_ticks first -) -{ - return _CPU_Counter_difference( second, first ); -} - -/** - * @brief Converts counter ticks into nanoseconds. - * - * @param[in] ticks Some counter ticks. - * - * @return The nanoseconds corresponding to the counter ticks. The value is - * rounded up. - */ -uint64_t rtems_counter_ticks_to_nanoseconds( - rtems_counter_ticks ticks -); - -/** - * @brief Converts nanoseconds into counter ticks. - * - * @param[in] nanoseconds Some nanoseconds. - * - * @return The counter ticks corresponding to the nanoseconds. The value is - * rounded up. - */ -rtems_counter_ticks rtems_counter_nanoseconds_to_ticks( - uint32_t nanoseconds -); - -/** - * @brief Initializes the counter ticks to/from nanoseconds converter functions. - * - * This function must be used to initialize the - * rtems_counter_ticks_to_nanoseconds() and - * rtems_counter_nanoseconds_to_ticks() functions. It should be called during - * system initialization by the board support package. - * - * @param[in] frequency The current counter frequency in Hz. - */ -void rtems_counter_initialize_converter( uint32_t frequency ); - -/** - * @brief Busy wait for some counter ticks. - * - * This function does not disable interrupts. Thus task switches and - * interrupts can interfere with this busy wait may prolong the delay. This - * function busy waits at least the specified time. Due to some overhead the - * actual delay may be longer. - * - * @param[in] ticks The minimum busy wait time in counter ticks. - */ -void rtems_counter_delay_ticks( rtems_counter_ticks ticks ); - -/** - * @brief Busy wait for some nanoseconds. - * - * This function does not disable interrupts. Thus task switches and - * interrupts can interfere with this busy wait may prolong the delay. This - * function busy waits at least the specified time. Due to some overhead the - * actual delay may be longer. - * - * @param[in] nanoseconds The minimum busy wait time in nanoseconds. - */ -void rtems_counter_delay_nanoseconds( uint32_t nanoseconds ); - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_SAPI_COUNTER_H */ diff --git a/cpukit/sapi/include/rtems/extension.h b/cpukit/sapi/include/rtems/extension.h deleted file mode 100644 index f22abf7f18..0000000000 --- a/cpukit/sapi/include/rtems/extension.h +++ /dev/null @@ -1,245 +0,0 @@ -/** - * @file - * - * @brief User Extensions API. - */ - -/* - * COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_EXTENSION_H -#define _RTEMS_EXTENSION_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include - -typedef struct { - Objects_Control Object; - User_extensions_Control Extension; -} Extension_Control; - -typedef User_extensions_routine - rtems_extension RTEMS_DEPRECATED; - -/** - * @defgroup ClassicUserExtensions User Extensions - * - * @ingroup ClassicRTEMS - * - * @brief The User Extensions Manager allows the application developer to - * augment the executive by allowing them to supply extension routines which - * are invoked at critical system events. - * - * @section ClassicUserExtensionsSets Extension Sets - * - * An @ref User_extensions_Table "extension set" is defined as a set of - * routines which are invoked at each of the critical system events at which - * user extension routines are invoked. Together a set of these routines - * typically perform a specific functionality such as performance monitoring or - * debugger support. - * - * RTEMS allows the user to have multiple extension sets active at the same - * time. First, a single static extension set may be defined as the - * application's User Extension Table which is included as part of the - * Configuration Table. This extension set is active for the entire life of the - * system and may not be deleted. This extension set is especially important - * because it is the only way the application can provided a fatal error - * extension which is invoked if RTEMS fails during the - * rtems_initialize_data_structures() directive. The static extension set is - * optional and may be configured as @c NULL if no static extension set is - * required. - * - * Second, the user can install dynamic extensions using the - * rtems_extension_create() directive. These extensions are RTEMS objects in - * that they have a name, an ID, and can be dynamically created and deleted. In - * contrast to the static extension set, these extensions can only be created - * and installed after the rtems_initialize_data_structures() directive - * successfully completes execution. Dynamic extensions are useful for - * encapsulating the functionality of an extension set. For example, the - * application could use extensions to manage a special coprocessor, do - * performance monitoring, and to do stack bounds checking. Each of these - * extension sets could be written and installed independently of the others. - * - * All user extensions are optional and RTEMS places no naming restrictions on - * the user. The user extension entry points are copied into an internal RTEMS - * structure. This means the user does not need to keep the table after - * creating it, and changing the handler entry points dynamically in a table - * once created has no effect. Creating a table local to a function can save - * space in space limited applications. - * - * Extension switches do not effect the context switch overhead if no switch - * handler is installed. - * - * @section ClassicUserExtensionsTCB Task Control Block Area - * - * RTEMS provides for a pointer to a user-defined data area for each extension - * set to be linked to each task's control block (TCB). This area is only - * available for the dynamic extensions. This set of pointers is an extension - * of the TCB and can be used to store additional data required by the user's - * extension functions. - * - * The TCB extension is an array of pointers in the TCB. The index into the - * table can be obtained from the extension identifier returned when the - * extension is created: - * - * @code - * rtems_tcb *task = some_task; - * size_t index = rtems_object_id_get_index(extension_id); - * void *extension_data = task->extensions [index]; - * @endcode - * - * The number of pointers in the area is the same as the number of user - * extension sets configured. This allows an application to augment the TCB - * with user-defined information. For example, an application could implement - * task profiling by storing timing statistics in the TCB's extended memory - * area. When a task context switch is being executed, the task switch - * extension could read a real-time clock to calculate how long the task being - * swapped out has run as well as timestamp the starting time for the task - * being swapped in. - * - * If used, the extended memory area for the TCB should be allocated and the - * TCB extension pointer should be set at the time the task is created or - * started by either the task create or task start extension. The application - * is responsible for managing this extended memory area for the TCBs. The - * memory may be reinitialized by the task restart extension and should be - * deallocated by the task delete extension when the task is deleted. Since the - * TCB extension buffers would most likely be of a fixed size, the RTEMS - * partition manager could be used to manage the application's extended memory - * area. The application could create a partition of fixed size TCB extension - * buffers and use the partition manager's allocation and deallocation - * directives to obtain and release the extension buffers. - * - * @section ClassicUserExtensionsOrder Order of Invokation - * - * When one of the critical system events occur, the user extensions are - * invoked in either @a forward or @a reverse order. Forward order indicates - * that the static extension set is invoked followed by the dynamic extension - * sets in the order in which they were created. Reverse order means that the - * dynamic extension sets are invoked in the opposite of the order in which - * they were created followed by the static extension set. By invoking the - * extension sets in this order, extensions can be built upon one another. At - * the following system events, the extensions are invoked in forward order: - * - * - Task creation - * - Task start - * - Task restart - * - Task context switch - * - Post task context switch - * - Task begins to execute - * - * At the following system events, the extensions are invoked in reverse order: - * - * - Task exit - * - Task deletion - * - Fatal error detection - * - * At these system events, the extensions are invoked in reverse order to - * insure that if an extension set is built upon another, the more complicated - * extension is invoked before the extension set it is built upon. For example, - * by invoking the static extension set last it is known that the "system" - * fatal error extension will be the last fatal error extension executed. - * Another example is use of the task delete extension by the Standard C - * Library. Extension sets which are installed after the Standard C Library - * will operate correctly even if they utilize the C Library because the C - * Library's task delete extension is invoked after that of the other - * extensions. - */ -/**@{**/ - -typedef User_extensions_thread_create_extension rtems_task_create_extension; -typedef User_extensions_thread_delete_extension rtems_task_delete_extension; -typedef User_extensions_thread_start_extension rtems_task_start_extension; -typedef User_extensions_thread_restart_extension rtems_task_restart_extension; -typedef User_extensions_thread_switch_extension rtems_task_switch_extension; -typedef User_extensions_thread_begin_extension rtems_task_begin_extension; -typedef User_extensions_thread_exitted_extension rtems_task_exitted_extension; -typedef User_extensions_fatal_extension rtems_fatal_extension; -typedef User_extensions_thread_terminate_extension rtems_task_terminate_extension; - -typedef User_extensions_Table rtems_extensions_table; - -typedef Internal_errors_Source rtems_fatal_source; - -typedef Internal_errors_t rtems_fatal_code; - -/** - * @brief Creates an extension set object. - * - * This directive creates a extension set object from the extension table - * @a extension_table. The assigned extension set identifier is returned in - * @a id. The identifier is used to access this extension set in other - * extension set related directives. The name @a name will be assigned to the - * extension set object. - * - * Newly created extension sets are immediately installed and are invoked upon - * the next system event supporting an extension. - * - * This directive will not cause the calling task to be preempted. - * - * @retval RTEMS_SUCCESSFUL Extension set created successfully. - * @retval RTEMS_INVALID_ADDRESS Identifier pointer is @c NULL. - * @retval RTEMS_INVALID_NAME Invalid extension set name. - * @retval RTEMS_TOO_MANY Too many extension sets created. - */ -rtems_status_code rtems_extension_create( - rtems_name name, - const rtems_extensions_table *extension_table, - rtems_id *id -); - -/** - * @brief Identifies an extension set object by a name. - * - * This directive obtains an extension set identifier in @a id associated with - * the extension set name @a name. If the extension set name is not unique, - * then the extension set identifier will match one of the extension sets with - * that name. However, this extension set identifier is not guaranteed to - * correspond to the desired extension set. The extension set identifier is - * used to access this extension set in other extension set related directives. - * - * This directive will not cause the calling task to be preempted. - * - * @retval RTEMS_SUCCESSFUL Extension set identified successfully. - * @retval RTEMS_INVALID_ADDRESS Identifier pointer is @c NULL. - * @retval RTEMS_INVALID_NAME Extension set name not found or invalid name. - */ -rtems_status_code rtems_extension_ident( - rtems_name name, - rtems_id *id -); - -/** - * @brief Deletes an extension set object specified by the identifier @a id. - * - * Any subsequent references to the extension's name and identifier are - * invalid. - * - * This directive will not cause the calling task to be preempted. - * - * @retval RTEMS_SUCCESSFUL Extension set deleted successfully. - * @retval RTEMS_INVALID_ID Invalid extension set identifier. - */ -rtems_status_code rtems_extension_delete( - rtems_id id -); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/sapi/include/rtems/extensionimpl.h b/cpukit/sapi/include/rtems/extensionimpl.h deleted file mode 100644 index fb4eeaff7c..0000000000 --- a/cpukit/sapi/include/rtems/extensionimpl.h +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @file - * - * @ingroup ClassicUserExtensions - * - * @brief User Extensions API - */ - -/* - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_EXTENSIONIMPL_H -#define _RTEMS_EXTENSIONIMPL_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -extern Objects_Information _Extension_Information; - -RTEMS_INLINE_ROUTINE Extension_Control *_Extension_Allocate( void ) -{ - return (Extension_Control *) _Objects_Allocate( &_Extension_Information ); -} - -RTEMS_INLINE_ROUTINE void _Extension_Free ( - Extension_Control *the_extension -) -{ - _Objects_Free( &_Extension_Information, &the_extension->Object ); -} - -RTEMS_INLINE_ROUTINE Extension_Control *_Extension_Get( Objects_Id id ) -{ - return (Extension_Control *) - _Objects_Get_no_protection( id, &_Extension_Information ); -} - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/sapi/include/rtems/fatal.h b/cpukit/sapi/include/rtems/fatal.h deleted file mode 100644 index 291af42c6e..0000000000 --- a/cpukit/sapi/include/rtems/fatal.h +++ /dev/null @@ -1,134 +0,0 @@ -/** - * @file - * - * @brief Fatal API. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_FATAL_H -#define _RTEMS_FATAL_H - -#include /* RTEMS_NO_RETURN */ -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicFatal Fatal - * - * @ingroup ClassicRTEMS - * - * @brief The Fatal Manager provides functions for fatal system states and or - * irrecoverable errors. - */ -/**@{**/ - -/** - * @brief Assert context. - */ -typedef struct { - const char *file; - int line; - const char *function; - const char *failed_expression; -} rtems_assert_context; - -/** - * @brief Exception frame. - */ -typedef CPU_Exception_frame rtems_exception_frame; - -/** - * @brief Prints the exception frame via printk(). - * - * @see rtems_fatal() and RTEMS_FATAL_SOURCE_EXCEPTION. - */ -static inline void rtems_exception_frame_print( - const rtems_exception_frame *frame -) -{ - _CPU_Exception_frame_print( frame ); -} - -/** - * @brief Invokes the internal error handler with a source of - * INTERNAL_ERROR_RTEMS_API and is internal set to false. - * - * @param[in] the_error is a 32-bit fatal error code. - * - * @see _Terminate(). - */ -void rtems_fatal_error_occurred( - uint32_t the_error -) RTEMS_NO_RETURN; - -/** - * @brief Terminates the system. - * - * @param[in] fatal_source The fatal source. - * @param[in] error_code The error code. - * - * @see _Terminate(). - */ -RTEMS_NO_RETURN RTEMS_INLINE_ROUTINE void rtems_fatal( - rtems_fatal_source fatal_source, - rtems_fatal_code error_code -) -{ - _Terminate( fatal_source, error_code ); -} - -/** - * @brief Prints the specified message via printk() and terminates the system. - * - * @param[in] fmt The message format. - * @param[in] ... The message parameters. - * - * @see _Terminate(). - */ -RTEMS_NO_RETURN void rtems_panic( - const char *fmt, ... -) RTEMS_PRINTFLIKE( 1, 2 ); - -/** - * @brief Returns a text for a fatal source. - * - * The text for each fatal source is the enumerator constant. - * - * @param[in] source is the fatal source. - * - * @retval text The fatal source text. - * @retval "?" The passed fatal source is invalid. - */ -const char *rtems_fatal_source_text( rtems_fatal_source source ); - -/** - * @brief Returns a text for an internal error code. - * - * The text for each internal error code is the enumerator constant. - * - * @param[in] error is the error code. - * - * @retval text The error code text. - * @retval "?" The passed error code is invalid. - */ -const char *rtems_internal_error_text( rtems_fatal_code error ); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/sapi/include/rtems/init.h b/cpukit/sapi/include/rtems/init.h deleted file mode 100644 index fa3108ea50..0000000000 --- a/cpukit/sapi/include/rtems/init.h +++ /dev/null @@ -1,69 +0,0 @@ -/** - * @file - * - * @brief Constants and Structures Associated - * with the Initialization Manager - * - * This include file contains all the constants and structures associated - * with the Initialization Manager. This manager is responsible for - * initializing RTEMS, creating and starting all configured initialization - * tasks, invoking the initialization routine for each user-supplied device - * driver, and initializing the optional multiprocessor layer. - * - * This manager provides directives to: - * - * + initialize the RTEMS executive - * + shutdown the RTEMS executive - */ - -/* - * COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_INIT_H -#define _RTEMS_INIT_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include - -/** - * @brief Initializes the system and starts multitasking. - * - * Iterates through the system initialization linker set and invokes the - * registered handlers. The final step is to start multitasking. - * - * This directive should be called by boot_card() only. - * - * This directive does not return. - */ -void rtems_initialize_executive(void) - RTEMS_NO_RETURN; - -/** - * @brief Shutdown the RTEMS environment. - * - * This routine implements the rtems_shutdown_executive directive. The - * invocation of this directive results in the RTEMS environment being - * shutdown and multitasking halted. The system is terminated with a fatal - * source of RTEMS_FATAL_SOURCE_EXIT and the specified result code. - */ -void rtems_shutdown_executive( - uint32_t result -) RTEMS_NO_RETURN; - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/sapi/include/rtems/io.h b/cpukit/sapi/include/rtems/io.h deleted file mode 100644 index 760d412bb8..0000000000 --- a/cpukit/sapi/include/rtems/io.h +++ /dev/null @@ -1,254 +0,0 @@ -/** - * @file - * - * @brief Classic Input/Output Manager API - * - * This file emulates the old Classic RTEMS IO manager directives - * which register and lookup names using the in-memory filesystem. - */ - -/* - * COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_IO_H -#define _RTEMS_IO_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicIO Input/Output - * - * @ingroup ClassicRTEMS - * - */ -/**@{**/ - -typedef uint32_t rtems_device_major_number; - -typedef uint32_t rtems_device_minor_number; - -typedef rtems_status_code rtems_device_driver; - -typedef rtems_device_driver (*rtems_device_driver_entry)( - rtems_device_major_number, - rtems_device_minor_number, - void * -); - -typedef struct { - rtems_device_driver_entry initialization_entry; - rtems_device_driver_entry open_entry; - rtems_device_driver_entry close_entry; - rtems_device_driver_entry read_entry; - rtems_device_driver_entry write_entry; - rtems_device_driver_entry control_entry; -} rtems_driver_address_table; - -/** - * @name Device Driver Maintainance - */ -/**@{**/ - -/** - * @brief Returns @c RTEMS_IO_ERROR. - * - * @retval RTEMS_IO_ERROR Only this one. - */ -rtems_status_code rtems_io_driver_io_error( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *arg -); - -/** - * @brief Registers and initializes the device with the device driver table - * @a driver_table and major number @a major. - * - * If the major number equals zero a major number will be obtained. The major - * number of the registered driver will be returned in @a registered_major. - * - * After a successful registration rtems_io_initialize() will be called to - * initialize the device. - * - * @retval RTEMS_SUCCESSFUL Device successfully registered and initialized. - * @retval RTEMS_INVALID_ADDRESS Pointer to driver table or to registered - * major number are invalid. Device driver table is empty. - * @retval RTEMS_INVALID_NUMBER Invalid major number. - * @retval RTEMS_TOO_MANY No major number available. - * @retval RTEMS_RESOURCE_IN_USE Major number in use. - * @retval RTEMS_CALLED_FROM_ISR Called from interrupt context. - * @retval * Status code depends on rtems_io_initialize(). - */ -rtems_status_code rtems_io_register_driver( - rtems_device_major_number major, - const rtems_driver_address_table *driver_table, - rtems_device_major_number *registered_major -); - -/** - * @brief Unregister a driver from the device driver table. - * - * @param[in] major is the device major number. - * - * @retval RTEMS_SUCCESSFUL Device driver successfully unregistered. - * @retval RTEMS_UNSATISFIED Invalid major number. - * @retval RTEMS_CALLED_FROM_ISR Called from interrupt context. - */ -rtems_status_code rtems_io_unregister_driver( - rtems_device_major_number major -); - -/** - * @brief Registers the name @a device_name in the file system for the device - * with number tuple @a major and @a minor. - * - * This assumes that all registered devices are character devices. - * - * @retval RTEMS_SUCCESSFUL Name successfully registered. - * @retval RTEMS_TOO_MANY Name already in use or other errors. - */ -rtems_status_code rtems_io_register_name( - const char *device_name, - rtems_device_major_number major, - rtems_device_minor_number minor -); - -/** @} */ - -/** - * @brief IO driver initialization. - * - * This routine is the initialization directive of the IO manager. - * - * @param[in] major is the device drive number - * @param[in] minor is the device number - * @param[in] argument is the pointer to the argument(s) - * - * @return status code - */ -rtems_status_code rtems_io_initialize( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *argument -); - -/** - * @brief Opening for the IO manager. - * - * Opens a device driver with the number @a major. - * - * @param[in] major is the device driver number. - * @param[in] minor is the device number. - * @param[in] argument is the pointer to the argument(s). - * - * @return Status code. - */ -rtems_status_code rtems_io_open( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *argument -); - -/** - * @brief Closing for the IO manager. - * - * This routine is the close directive of the IO manager. - * - * @param[in] major is the device driver number. - * @param[in] minor is the device number. - * @param[in] argument is the pointer to the argument(s). - * - * @return Status code. - */ -rtems_status_code rtems_io_close( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *argument -); - -/** - * @brief Reading for the IO manager. - * - * This routine is the read directive of the IO manager. - * - * @param[in] major is the device driver number. - * @param[in] minor is the device number. - * @param[in] argument is the pointer to the argument(s). - * - * @return Status code. - */ -rtems_status_code rtems_io_read( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *argument -); - -/** - * @brief Writing for the IO manager. - * - * This routine is the write directive of the IO manager. - * - * @param[in] major is the device driver number. - * @param[in] minor is the device number. - * @param[in] argument is the pointer to the argument(s). - * - * @return Status code. - */ -rtems_status_code rtems_io_write( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *argument -); - -/** - * @brief Control for the IO manager. - * - * This routine is the control directive of the IO manager. - * - * @param[in] major is the device driver number. - * @param[in] minor is the device number. - * @param[in] argument is the pointer to the argument(s). - * - * @return Status code. - */ -rtems_status_code rtems_io_control( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *argument -); - -/** @} */ - -/** @} */ - -typedef struct { - const char *device_name; - size_t device_name_length; - rtems_device_major_number major; - rtems_device_minor_number minor; -} rtems_driver_name_t; - -/** - * @deprecated Use stat() instead. - */ -rtems_status_code rtems_io_lookup_name( - const char *name, - rtems_driver_name_t *device_info -) RTEMS_DEPRECATED; - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/sapi/include/rtems/ioimpl.h b/cpukit/sapi/include/rtems/ioimpl.h deleted file mode 100644 index 5c4a82eea6..0000000000 --- a/cpukit/sapi/include/rtems/ioimpl.h +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @file - * - * @brief Classic Input/Output Manager Implementation API - */ - -/* - * COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_IOIMPL_H -#define _RTEMS_IOIMPL_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -extern const size_t _IO_Number_of_drivers; - -extern rtems_driver_address_table _IO_Driver_address_table[]; - -extern bool _IO_All_drivers_initialized; - -/** - * @brief Initialization of all device drivers. - * - * Initializes all device drivers. - */ -void _IO_Initialize_all_drivers( void ); - -ISR_LOCK_DECLARE( extern, _IO_Driver_registration_lock ) - -RTEMS_INLINE_ROUTINE void _IO_Driver_registration_acquire( - ISR_lock_Context *lock_context -) -{ - _ISR_lock_ISR_disable_and_acquire( - &_IO_Driver_registration_lock, - lock_context - ); -} - -RTEMS_INLINE_ROUTINE void _IO_Driver_registration_release( - ISR_lock_Context *lock_context -) -{ - _ISR_lock_Release_and_ISR_enable( - &_IO_Driver_registration_lock, - lock_context - ); -} - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_IOIMPL_H */ diff --git a/cpukit/sapi/include/rtems/mptables.h b/cpukit/sapi/include/rtems/mptables.h deleted file mode 100644 index 01e5b653b4..0000000000 --- a/cpukit/sapi/include/rtems/mptables.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @file - * - * @brief Executive's Pre-Initialized Tables used in a - * Multiprocessor Configuration - * - * This include file contains the executive's pre-initialized tables - * used in a multiprocessor configuration. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_MPTABLES_H -#define _RTEMS_MPTABLES_H - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/sapi/include/rtems/profiling.h b/cpukit/sapi/include/rtems/profiling.h deleted file mode 100644 index 9e434b2a3c..0000000000 --- a/cpukit/sapi/include/rtems/profiling.h +++ /dev/null @@ -1,333 +0,0 @@ -/** - * @file - * - * @ingroup Profiling - * - * @brief Profiling API - */ - -/* - * Copyright (c) 2014 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_PROFILING_H -#define _RTEMS_PROFILING_H - -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup Profiling Profiling Support - * - * @brief The profiling support offers functions to report profiling - * information available in the system. - * - * Profiling support is by default disabled. It must be enabled via the - * configure command line with the --enable-profiling option. In this - * case the RTEMS_PROFILING pre-processor symbol is defined and profiling - * statistics will be gathered during system run-time. The profiling support - * increases the time of critical sections and has some memory overhead. The - * overhead should be acceptable for most applications. The aim of the - * profiling implementation is to be available even for production systems so - * that verification is simplified. - * - * Profiling information includes critical timing values such as the maximum - * time of disabled thread dispatching which is a measure for the thread - * dispatch latency. On SMP configurations statistics of all SMP locks in the - * system are available. - * - * Profiling information can be retrieved via rtems_profiling_iterate() and - * reported as an XML dump via rtems_profiling_report_xml(). These functions - * are always available, but actual profiling data is only available if enabled - * at build configuration time. - * - * @{ - */ - -/** - * @brief Type of profiling data. - */ -typedef enum { - /** - * @brief Type of per-CPU profiling data. - * - * @see rtems_profiling_per_cpu. - */ - RTEMS_PROFILING_PER_CPU, - - /** - * @brief Type of SMP lock profiling data. - * - * @see rtems_profiling_smp_lock. - */ - RTEMS_PROFILING_SMP_LOCK -} rtems_profiling_type; - -/** - * @brief The profiling data header. - */ -typedef struct { - /** - * @brief The profiling data type. - */ - rtems_profiling_type type; -} rtems_profiling_header; - -/** - * @brief Per-CPU profiling data. - * - * Theoretically all values in this structure can overflow, but the integer - * types are chosen so that they cannot overflow in practice. On systems with - * a 1GHz CPU counter, the 64-bit integers can overflow in about 58 years. - * Since the system should not spend most of the time in critical sections the - * actual system run-time is much longer. Several other counters in the system - * will overflow before we get a problem in the profiling area. - */ -typedef struct { - /** - * @brief The profiling data header. - */ - rtems_profiling_header header; - - /** - * @brief The processor index of this profiling data. - */ - uint32_t processor_index; - - /** - * @brief The maximum time of disabled thread dispatching in nanoseconds. - */ - uint32_t max_thread_dispatch_disabled_time; - - /** - * @brief Count of times when the thread dispatch disable level changes from - * zero to one in thread context. - * - * This value may overflow. - */ - uint64_t thread_dispatch_disabled_count; - - /** - * @brief Total time of disabled thread dispatching in nanoseconds. - * - * The average time of disabled thread dispatching is the total time of - * disabled thread dispatching divided by the thread dispatch disabled - * count. - * - * This value may overflow. - */ - uint64_t total_thread_dispatch_disabled_time; - - /** - * @brief The maximum interrupt delay in nanoseconds if supported by the - * hardware. - * - * The interrupt delay is the time interval from the recognition of an - * interrupt signal by the hardware up to the execution start of the - * corresponding high-level handler. The interrupt delay is the main - * contributor to the interrupt latency. To measure this time hardware - * support is required. A time stamp unit must capture the interrupt signal - * recognition time. If no hardware support is available, then this field - * will have a constant value of zero. - */ - uint32_t max_interrupt_delay; - - /** - * @brief The maximum time spent to process a single sequence of nested - * interrupts in nanoseconds. - * - * This is the time interval between the change of the interrupt nest level - * from zero to one and the change back from one to zero. It is the measured - * worst-case execution time of interrupt service routines. Please note that - * in case of nested interrupts this time includes the combined execution - * time and not the maximum time of an individual interrupt service routine. - */ - uint32_t max_interrupt_time; - - /** - * @brief Count of times when the interrupt nest level changes from zero to - * one. - * - * This value may overflow. - */ - uint64_t interrupt_count; - - /** - * @brief Total time of interrupt processing in nanoseconds. - * - * The average time of interrupt processing is the total time of interrupt - * processing divided by the interrupt count. - * - * This value may overflow. - */ - uint64_t total_interrupt_time; -} rtems_profiling_per_cpu; - -/** - * @brief Count of lock contention counters for SMP lock profiling. - */ -#define RTEMS_PROFILING_SMP_LOCK_CONTENTION_COUNTS 4 - -/** - * @brief SMP lock profiling data. - * - * The lock acquire attempt instant is the point in time right after the - * interrupt disable action in the lock acquire sequence. - * - * The lock acquire instant is the point in time right after the lock - * acquisition. This is the begin of the critical section code execution. - * - * The lock acquire time is the time elapsed between the lock acquire attempt - * instant and the lock acquire instant. - * - * The lock release instant is the point in time right before the interrupt - * enable action in the lock release sequence. - * - * The lock section time is the time elapsed between the lock acquire instant - * and the lock release instant. - */ -typedef struct { - /** - * @brief The profiling data header. - */ - rtems_profiling_header header; - - /** - * @brief The lock name. - */ - const char *name; - - /** - * @brief The maximum lock acquire time in nanoseconds. - */ - uint32_t max_acquire_time; - - /** - * @brief The maximum lock section time in nanoseconds. - */ - uint32_t max_section_time; - - /** - * @brief The count of lock uses. - * - * This value may overflow. - */ - uint64_t usage_count; - - /** - * @brief Total lock acquire time in nanoseconds. - * - * The average lock acquire time is the total acquire time divided by the - * lock usage count. The ration of the total section and total acquire times - * gives a measure for the lock contention. - * - * This value may overflow. - */ - uint64_t total_acquire_time; - - /** - * @brief Total lock section time in nanoseconds. - * - * The average lock section time is the total section time divided by the - * lock usage count. - * - * This value may overflow. - */ - uint64_t total_section_time; - - /** - * @brief The counts of lock acquire operations by contention. - * - * The contention count for index N corresponds to a lock acquire attempt - * with an initial queue length of N. The last index corresponds to all - * lock acquire attempts with an initial queue length greater than or equal - * to RTEMS_PROFILING_SMP_LOCK_CONTENTION_COUNTS minus one. - * - * The values may overflow. - */ - uint64_t contention_counts[RTEMS_PROFILING_SMP_LOCK_CONTENTION_COUNTS]; -} rtems_profiling_smp_lock; - -/** - * @brief Collection of profiling data. - */ -typedef union { - /** - * @brief Header to specify the actual profiling data. - */ - rtems_profiling_header header; - - /** - * @brief Per-CPU profiling data if indicated by the header. - */ - rtems_profiling_per_cpu per_cpu; - - /** - * @brief SMP lock profiling data if indicated by the header. - */ - rtems_profiling_smp_lock smp_lock; -} rtems_profiling_data; - -/** - * @brief Visitor function for the profiling iteration. - * - * @param[in, out] arg The visitor argument. - * @param[in] data The current profiling data. - * - * @see rtems_profiling_iterate(). - */ -typedef void (*rtems_profiling_visitor)( - void *arg, - const rtems_profiling_data *data -); - -/** - * @brief Iterates through all profiling data of the system. - * - * @param[in] visitor The visitor. - * @param[in, out] visitor_arg The visitor argument. - */ -void rtems_profiling_iterate( - rtems_profiling_visitor visitor, - void *visitor_arg -); - -/** - * @brief Reports profiling data as XML. - * - * @param[in] name The name of the profiling report. - * @param[in] printer The RTEMS printer to send the output too. - * @param[in] indentation_level The current indentation level. - * @param[in] indentation The string used for indentation. - * - * @returns As specified by printf(). - */ -int rtems_profiling_report_xml( - const char *name, - const rtems_printer *printer, - uint32_t indentation_level, - const char *indentation -); - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_PROFILING_H */ diff --git a/cpukit/sapi/include/rtems/rbheap.h b/cpukit/sapi/include/rtems/rbheap.h deleted file mode 100644 index 735aa6c8fd..0000000000 --- a/cpukit/sapi/include/rtems/rbheap.h +++ /dev/null @@ -1,268 +0,0 @@ -/** - * @file - * - * @brief Red-Black Tree Heap API - */ - -/* - * Copyright (c) 2012 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Obere Lagerstr. 30 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RBHEAP_H -#define _RTEMS_RBHEAP_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup RBHeap Red-Black Tree Heap - * - * @ingroup ClassicRTEMS - * - * @brief Red-Black Tree Heap API. - * - * The red-black tree heap provides a memory allocator suitable to implement - * the malloc() and free() interface. It uses a first-fit allocation strategy. - * In the red-black tree heap the administration data structures are not - * contained in the managed memory area. Thus writing beyond the boundaries of - * a chunk does not damage the data to maintain the heap. This can be used for - * example in a task stack allocator which protects the task stacks from access - * by other tasks. The allocated and free memory parts of the managed area are - * called chunks. Each chunk needs a descriptor which is stored outside of the - * managed area. - */ -/**@{*/ - -/** - * @brief Red-black heap chunk descriptor. - */ -typedef struct { - /** - * This chain node can be used in two chains - * - the chain of spare chunk descriptors and - * - the chain of free chunks in the managed memory area. - * - * In case this chain node is not part of a chain, the chunk represents a - * used chunk in the managed memory area. - */ - rtems_chain_node chain_node; - - /** - * Tree node for chunks that represent a part of the managed memory area. - * These chunks are either free or used. - */ - rtems_rbtree_node tree_node; - - /** - * Begin address of the chunk. The address alignment it specified in the - * @ref rtems_rbheap_control. - */ - uintptr_t begin; - - /** - * Size of the chunk in bytes. - */ - uintptr_t size; -} rtems_rbheap_chunk; - -typedef struct rtems_rbheap_control rtems_rbheap_control; - -/** - * @brief Handler to extend the available chunk descriptors. - * - * This handler is called when no more chunk descriptors are available. An - * example implementation is this: - * - * @code - * void extend_descriptors_with_malloc(rtems_rbheap_control *control) - * { - * rtems_rbheap_chunk *chunk = malloc(sizeof(*chunk)); - * - * if (chunk != NULL) { - * rtems_rbheap_add_to_spare_descriptor_chain(control, chunk); - * } - * } - * @endcode - * - * @see rtems_rbheap_extend_descriptors_never() and - * rtems_rbheap_extend_descriptors_with_malloc(). - */ -typedef void (*rtems_rbheap_extend_descriptors)(rtems_rbheap_control *control); - -/** - * @brief Red-black heap control. - */ -struct rtems_rbheap_control { - /** - * Chain of free chunks in the managed memory area. - */ - rtems_chain_control free_chunk_chain; - - /** - * Chain of free chunk descriptors. Descriptors are consumed during - * allocation and may be produced during free if contiguous chunks can be - * coalesced. In case of descriptor starvation the @ref extend_descriptors - * handler will be called. - */ - rtems_chain_control spare_descriptor_chain; - - /** - * Tree of chunks representing the state of the managed memory area. - */ - rtems_rbtree_control chunk_tree; - - /** - * Minimum chunk begin alignment in bytes. - */ - uintptr_t alignment; - - /** - * Handler to extend the available chunk descriptors. - */ - rtems_rbheap_extend_descriptors extend_descriptors; - - /** - * User specified argument handler for private handler data. - */ - void *handler_arg; -}; - -/** - * @brief Initializes the red-black tree heap @a control. - * - * @param[in, out] control The red-black tree heap. - * @param[in] area_begin The managed memory area begin. - * @param[in] area_size The managed memory area size. - * @param[in] alignment The minimum chunk alignment. - * @param[in] extend_descriptors The handler to extend the available chunk - * descriptors. - * @param[in] handler_arg The handler argument. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_INVALID_ADDRESS The memory area is invalid. - * @retval RTEMS_NO_MEMORY Not enough chunk descriptors. - */ -rtems_status_code rtems_rbheap_initialize( - rtems_rbheap_control *control, - void *area_begin, - uintptr_t area_size, - uintptr_t alignment, - rtems_rbheap_extend_descriptors extend_descriptors, - void *handler_arg -); - -/** - * @brief Allocates a chunk of memory of at least @a size bytes from the - * red-black tree heap @a control. - * - * The chunk begin is aligned by the value specified in - * rtems_rbheap_initialize(). - * - * @param[in, out] control The red-black tree heap. - * @param[in] size The requested chunk size in bytes. - * - * @retval NULL Not enough free space in the heap. - * @retval otherwise Pointer to allocated chunk of memory. - */ -void *rtems_rbheap_allocate(rtems_rbheap_control *control, size_t size); - -/** - * @brief Frees a chunk of memory @a ptr allocated from the red-black tree heap - * @a control. - * - * @param[in, out] control The red-black tree heap. - * @param[in] ptr The pointer to the chunk of memory. - * - * @retval RTEMS_SUCCESSFUL Successful operation. - * @retval RTEMS_INVALID_ID The chunk of memory is not a valid chunk in the - * red-black tree heap. - * @retval RTEMS_INCORRECT_STATE The chunk of memory is not in the right state. - */ -rtems_status_code rtems_rbheap_free(rtems_rbheap_control *control, void *ptr); - -static inline rtems_chain_control *rtems_rbheap_get_spare_descriptor_chain( - rtems_rbheap_control *control -) -{ - return &control->spare_descriptor_chain; -} - -static inline void rtems_rbheap_add_to_spare_descriptor_chain( - rtems_rbheap_control *control, - rtems_rbheap_chunk *chunk -) -{ - rtems_chain_control *chain = - rtems_rbheap_get_spare_descriptor_chain(control); - - rtems_chain_initialize_node(&chunk->chain_node); - rtems_chain_prepend_unprotected(chain, &chunk->chain_node); -} - -static inline void rtems_rbheap_set_extend_descriptors( - rtems_rbheap_control *control, - rtems_rbheap_extend_descriptors extend_descriptors -) -{ - control->extend_descriptors = extend_descriptors; -} - -static inline void *rtems_rbheap_get_handler_arg( - const rtems_rbheap_control *control -) -{ - return control->handler_arg; -} - -static inline void rtems_rbheap_set_handler_arg( - rtems_rbheap_control *control, - void *handler_arg -) -{ - control->handler_arg = handler_arg; -} - -/** - * @brief Chunk descriptor extend handler that does nothing. - */ -void rtems_rbheap_extend_descriptors_never(rtems_rbheap_control *control); - -/** - * @brief Chunk descriptor extend handler that uses malloc(). - */ -void rtems_rbheap_extend_descriptors_with_malloc( - rtems_rbheap_control *control -); - -/** @} */ - -/* Private API */ - -#define rtems_rbheap_chunk_of_node(node) \ - RTEMS_CONTAINER_OF(node, rtems_rbheap_chunk, tree_node) - -static inline bool rtems_rbheap_is_chunk_free(const rtems_rbheap_chunk *chunk) -{ - return !rtems_chain_is_node_off_chain(&chunk->chain_node); -} - -#ifdef __cplusplus -} -#endif - -#endif /* _RTEMS_RBHEAP_H */ diff --git a/cpukit/sapi/include/rtems/rbtree.h b/cpukit/sapi/include/rtems/rbtree.h deleted file mode 100644 index 57821cf31d..0000000000 --- a/cpukit/sapi/include/rtems/rbtree.h +++ /dev/null @@ -1,456 +0,0 @@ -/** - * @file - * - * @brief Constants and Structures Associated with the RBTree API in RTEMS - * - * This include file contains all the constants and structures associated - * with the RBTree API in RTEMS. The rbtree is a Red Black Tree that - * is part of the Super Core. This is the published interface to that - * code. - */ - -/* - * Copyright (c) 2010 Gedare Bloom. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_RBTREE_H -#define _RTEMS_RBTREE_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicRBTrees Red-Black Trees - * - * @ingroup ClassicRTEMS - * - * @brief A Red-Black Tree container. - * - * The red-black tree container offers no internal protection against - * concurrent access. The user must ensure that at most one thread at once can - * access a red-black tree instance. - * - * @{ - */ - -/** - * @typedef rtems_rbtree_node - * - * A node that can be manipulated in the rbtree. - */ -typedef RBTree_Node rtems_rbtree_node; - -/** - * @typedef rtems_rbtree_control - * - * The rbtree's control anchors the rbtree. - */ -typedef RBTree_Control rtems_rbtree_control; - -/** - * @brief Integer type for compare results. - * - * The type is large enough to represent pointers and 32-bit signed integers. - * - * @see rtems_rbtree_compare. - */ -typedef long rtems_rbtree_compare_result; - -/** - * @brief Compares two red-black tree nodes. - * - * @param[in] first The first node. - * @param[in] second The second node. - * - * @retval positive The key value of the first node is greater than the one of - * the second node. - * @retval 0 The key value of the first node is equal to the one of the second - * node. - * @retval negative The key value of the first node is less than the one of the - * second node. - */ -typedef rtems_rbtree_compare_result ( *rtems_rbtree_compare )( - const RBTree_Node *first, - const RBTree_Node *second -); - -/** - * @brief RBTree initializer for an empty rbtree with designator @a name. - */ -#define RTEMS_RBTREE_INITIALIZER_EMPTY(name) \ - RBTREE_INITIALIZER_EMPTY(name) - -/** - * @brief RBTree definition for an empty rbtree with designator @a name. - */ -#define RTEMS_RBTREE_DEFINE_EMPTY(name) \ - RBTREE_DEFINE_EMPTY(name) - -/** - * @brief Initialize a RBTree header. - * - * This routine initializes @a the_rbtree structure to manage the - * contiguous array of @a number_nodes nodes which starts at - * @a starting_address. Each node is of @a node_size bytes. - * - * @param[in] the_rbtree is the pointer to rbtree header - * @param[in] compare The node compare function. - * @param[in] starting_address is the starting address of first node - * @param[in] number_nodes is the number of nodes in rbtree - * @param[in] node_size is the size of node in bytes - * @param[in] is_unique If true, then reject nodes with a duplicate key, else - * otherwise. - */ -void rtems_rbtree_initialize( - rtems_rbtree_control *the_rbtree, - rtems_rbtree_compare compare, - void *starting_address, - size_t number_nodes, - size_t node_size, - bool is_unique -); - -/** - * @brief Initialize this RBTree as Empty - * - * This routine initializes @a the_rbtree to contain zero nodes. - */ -RTEMS_INLINE_ROUTINE void rtems_rbtree_initialize_empty( - rtems_rbtree_control *the_rbtree -) -{ - _RBTree_Initialize_empty( the_rbtree ); -} - -/** - * @brief Set off RBtree. - * - * This function sets the next and previous fields of the @a node to NULL - * indicating the @a node is not part of any rbtree. - */ -RTEMS_INLINE_ROUTINE void rtems_rbtree_set_off_tree( - rtems_rbtree_node *node -) -{ - _RBTree_Set_off_tree( node ); -} - -/** - * @brief Is the Node off RBTree. - * - * This function returns true if the @a node is not on a rbtree. A @a node is - * off rbtree if the next and previous fields are set to NULL. - */ -RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_node_off_tree( - const rtems_rbtree_node *node -) -{ - return _RBTree_Is_node_off_tree( node ); -} - -/** - * @brief Return pointer to RBTree root. - * - * This function returns a pointer to the root node of @a the_rbtree. - */ -RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_root( - const rtems_rbtree_control *the_rbtree -) -{ - return _RBTree_Root( the_rbtree ); -} - -/** - * @copydoc _RBTree_Minimum() - */ -RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_min( - const rtems_rbtree_control *the_rbtree -) -{ - return _RBTree_Minimum( the_rbtree ); -} - -/** - * @copydoc _RBTree_Maximum() - */ -RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_max( - const rtems_rbtree_control *the_rbtree -) -{ - return _RBTree_Maximum( the_rbtree ); -} - -/** - * @brief Return pointer to the left child node from this node. - * - * This function returns a pointer to the left child node of @a the_node. - */ -RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_left( - const rtems_rbtree_node *the_node -) -{ - return _RBTree_Left( the_node ); -} - -/** - * @brief Return pointer to the right child node from this node. - * - * This function returns a pointer to the right child node of @a the_node. - */ -RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_right( - const rtems_rbtree_node *the_node -) -{ - return _RBTree_Right( the_node ); -} - -/** - * @copydoc _RBTree_Parent() - */ -RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_parent( - const rtems_rbtree_node *the_node -) -{ - return _RBTree_Parent( the_node ); -} - -/** - * @brief Is the RBTree empty. - * - * This function returns true if there a no nodes on @a the_rbtree and - * false otherwise. - */ -RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_empty( - const rtems_rbtree_control *the_rbtree -) -{ - return _RBTree_Is_empty( the_rbtree ); -} - -/** - * @brief Is this the minimum node on the RBTree. - * - * This function returns true if @a the_node is the min node on @a the_rbtree - * and false otherwise. - */ -RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_min( - const rtems_rbtree_control *the_rbtree, - const rtems_rbtree_node *the_node -) -{ - return rtems_rbtree_min( the_rbtree ) == the_node; -} - -/** - * @brief Is this the maximum node on the RBTree. - * - * This function returns true if @a the_node is the max node on @a the_rbtree - * and false otherwise. - */ -RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_max( - const rtems_rbtree_control *the_rbtree, - const rtems_rbtree_node *the_node -) -{ - return rtems_rbtree_max( the_rbtree ) == the_node; -} - -/** - * @copydoc _RBTree_Is_root() - */ -RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_root( - const rtems_rbtree_node *the_node -) -{ - return _RBTree_Is_root( the_node ); -} - -RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_equal( - rtems_rbtree_compare_result compare_result -) -{ - return compare_result == 0; -} - -RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_greater( - rtems_rbtree_compare_result compare_result -) -{ - return compare_result > 0; -} - -RTEMS_INLINE_ROUTINE bool rtems_rbtree_is_lesser( - rtems_rbtree_compare_result compare_result -) -{ - return compare_result < 0; -} - -/** - * @brief Tries to find a node for the specified key in the tree. - * - * @param[in] the_rbtree The red-black tree control. - * @param[in] the_node A node specifying the key. - * @param[in] compare The node compare function. - * @param[in] is_unique If true, then return the first node with a key equal to - * the one of the node specified if it exits, else return the last node if it - * exists. - * - * @retval node A node corresponding to the key. If the tree is not unique - * and contains duplicate keys, the set of duplicate keys acts as FIFO. - * @retval NULL No node exists in the tree for the key. - */ -rtems_rbtree_node* rtems_rbtree_find( - const rtems_rbtree_control *the_rbtree, - const rtems_rbtree_node *the_node, - rtems_rbtree_compare compare, - bool is_unique -); - -/** - * @copydoc _RBTree_Predecessor() - */ -RTEMS_INLINE_ROUTINE rtems_rbtree_node* rtems_rbtree_predecessor( - const rtems_rbtree_node *node -) -{ - return _RBTree_Predecessor( node ); -} - -/** - * @copydoc _RBTree_Successor() - */ -RTEMS_INLINE_ROUTINE rtems_rbtree_node* rtems_rbtree_successor( - const rtems_rbtree_node *node -) -{ - return _RBTree_Successor( node ); -} - -/** - * @copydoc _RBTree_Extract() - */ -RTEMS_INLINE_ROUTINE void rtems_rbtree_extract( - rtems_rbtree_control *the_rbtree, - rtems_rbtree_node *the_node -) -{ - _RBTree_Extract( the_rbtree, the_node ); -} - -/** - * @brief Gets a node with the minimum key value from the red-black tree. - * - * This function extracts a node with the minimum key value from - * tree and returns a pointer to that node if it exists. In case multiple - * nodes with a minimum key value exist, then they are extracted in FIFO order. - * - * @param[in] the_rbtree The red-black tree control. - * - * @retval NULL The tree is empty. - * @retval node A node with the minimal key value on the tree. - */ -RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_get_min( - rtems_rbtree_control *the_rbtree -) -{ - rtems_rbtree_node *the_node = rtems_rbtree_min( the_rbtree ); - - if ( the_node != NULL ) { - rtems_rbtree_extract( the_rbtree, the_node ); - } - - return the_node; -} - -/** - * @brief Gets a node with the maximal key value from the red-black tree. - * - * This function extracts a node with the maximum key value from tree and - * returns a pointer to that node if it exists. In case multiple nodes with a - * maximum key value exist, then they are extracted in LIFO order. - * - * @param[in] the_rbtree The red-black tree control. - * - * @retval NULL The tree is empty. - * @retval node A node with the maximal key value on the tree. - */ -RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_get_max( - rtems_rbtree_control *the_rbtree -) -{ - rtems_rbtree_node *the_node = rtems_rbtree_max( the_rbtree ); - - if ( the_node != NULL ) { - rtems_rbtree_extract( the_rbtree, the_node ); - } - - return the_node; -} - -/** - * @brief Peek at the min node on a rbtree. - * - * This function returns a pointer to the min node from @a the_rbtree - * without changing the tree. If @a the_rbtree is empty, - * then NULL is returned. - */ -RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_peek_min( - const rtems_rbtree_control *the_rbtree -) -{ - return rtems_rbtree_min( the_rbtree ); -} - -/** - * @brief Peek at the max node on a rbtree. - * - * This function returns a pointer to the max node from @a the_rbtree - * without changing the tree. If @a the_rbtree is empty, - * then NULL is returned. - */ -RTEMS_INLINE_ROUTINE rtems_rbtree_node *rtems_rbtree_peek_max( - const rtems_rbtree_control *the_rbtree -) -{ - return rtems_rbtree_max( the_rbtree ); -} - -/** - * @brief Inserts the node into the red-black tree. - * - * In case the node is already a node of a tree, then this function yields - * unpredictable results. - * - * @param[in] the_rbtree The red-black tree control. - * @param[in] the_node The node to insert. - * @param[in] compare The node compare function. - * @param[in] is_unique If true, then reject nodes with a duplicate key, else - * insert nodes in FIFO order in case the key value is equal to existing nodes. - * - * @retval NULL Successfully inserted. - * @retval existing_node This is a unique insert and there exists a node with - * an equal key in the tree already. - */ -rtems_rbtree_node *rtems_rbtree_insert( - RBTree_Control *the_rbtree, - RBTree_Node *the_node, - rtems_rbtree_compare compare, - bool is_unique -); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/sapi/include/rtems/scheduler.h b/cpukit/sapi/include/rtems/scheduler.h deleted file mode 100644 index 8684b798f7..0000000000 --- a/cpukit/sapi/include/rtems/scheduler.h +++ /dev/null @@ -1,247 +0,0 @@ -/** - * @file - * - * @brief Scheduler Configuration API - */ - -/* - * Copyright (c) 2014, 2017 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SAPI_SCHEDULER_H -#define _RTEMS_SAPI_SCHEDULER_H - -#include - -#define RTEMS_SCHEDULER_CONTEXT_NAME( name ) \ - _Configuration_Scheduler_ ## name - -#if defined(RTEMS_SMP) - /* This object doesn't exist and indicates a configuration error */ - extern const Scheduler_Control RTEMS_SCHEDULER_INVALID_INDEX; - - #define RTEMS_SCHEDULER_ASSIGN_DEFAULT \ - SCHEDULER_ASSIGN_DEFAULT - - #define RTEMS_SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL \ - SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL - - #define RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY \ - SCHEDULER_ASSIGN_PROCESSOR_MANDATORY - - #define RTEMS_SCHEDULER_ASSIGN( index, attr ) \ - { \ - ( index ) < RTEMS_ARRAY_SIZE( _Scheduler_Table ) ? \ - &_Scheduler_Table[ ( index ) ] : &RTEMS_SCHEDULER_INVALID_INDEX, \ - ( attr ) \ - } - - #define RTEMS_SCHEDULER_ASSIGN_NO_SCHEDULER { NULL, 0 } -#endif - -/* - * This file should be only included in the context of . - * Define the scheduler configuration macros only in case the corresponding - * configure symbol is defined. This is necessary to prevent invalid workspace - * size estimates since we have to account for the per-thread scheduler - * information. - */ - -#ifdef CONFIGURE_SCHEDULER_CBS - #include - - #define RTEMS_SCHEDULER_CONTEXT_CBS_NAME( name ) \ - RTEMS_SCHEDULER_CONTEXT_NAME( CBS_ ## name ) - - #define RTEMS_SCHEDULER_CONTEXT_CBS( name ) \ - static Scheduler_EDF_Context RTEMS_SCHEDULER_CONTEXT_CBS_NAME( name ) - - #define RTEMS_SCHEDULER_CONTROL_CBS( name, obj_name ) \ - { \ - &RTEMS_SCHEDULER_CONTEXT_CBS_NAME( name ).Base, \ - SCHEDULER_CBS_ENTRY_POINTS, \ - SCHEDULER_CBS_MAXIMUM_PRIORITY, \ - ( obj_name ) \ - } -#endif - -#ifdef CONFIGURE_SCHEDULER_EDF - #include - - #define RTEMS_SCHEDULER_CONTEXT_EDF_NAME( name ) \ - RTEMS_SCHEDULER_CONTEXT_NAME( EDF_ ## name ) - - #define RTEMS_SCHEDULER_CONTEXT_EDF( name ) \ - static Scheduler_EDF_Context RTEMS_SCHEDULER_CONTEXT_EDF_NAME( name ) - - #define RTEMS_SCHEDULER_CONTROL_EDF( name, obj_name ) \ - { \ - &RTEMS_SCHEDULER_CONTEXT_EDF_NAME( name ).Base, \ - SCHEDULER_EDF_ENTRY_POINTS, \ - SCHEDULER_EDF_MAXIMUM_PRIORITY, \ - ( obj_name ) \ - } -#endif - -#ifdef CONFIGURE_SCHEDULER_EDF_SMP - #include - - #define RTEMS_SCHEDULER_CONTEXT_EDF_SMP_NAME( name ) \ - RTEMS_SCHEDULER_CONTEXT_NAME( EDF_SMP_ ## name ) - - #define RTEMS_SCHEDULER_CONTEXT_EDF_SMP( name, max_cpu_count ) \ - static struct { \ - Scheduler_EDF_SMP_Context Base; \ - Scheduler_EDF_SMP_Ready_queue Ready[ ( max_cpu_count ) + 1 ]; \ - } RTEMS_SCHEDULER_CONTEXT_EDF_SMP_NAME( name ) - - #define RTEMS_SCHEDULER_CONTROL_EDF_SMP( name, obj_name ) \ - { \ - &RTEMS_SCHEDULER_CONTEXT_EDF_SMP_NAME( name ).Base.Base.Base, \ - SCHEDULER_EDF_SMP_ENTRY_POINTS, \ - SCHEDULER_EDF_MAXIMUM_PRIORITY, \ - ( obj_name ) \ - } -#endif - -#ifdef CONFIGURE_SCHEDULER_PRIORITY - #include - - #define RTEMS_SCHEDULER_CONTEXT_PRIORITY_NAME( name ) \ - RTEMS_SCHEDULER_CONTEXT_NAME( priority_ ## name ) - - #define RTEMS_SCHEDULER_CONTEXT_PRIORITY( name, prio_count ) \ - static struct { \ - Scheduler_priority_Context Base; \ - Chain_Control Ready[ ( prio_count ) ]; \ - } RTEMS_SCHEDULER_CONTEXT_PRIORITY_NAME( name ) - - #define RTEMS_SCHEDULER_CONTROL_PRIORITY( name, obj_name ) \ - { \ - &RTEMS_SCHEDULER_CONTEXT_PRIORITY_NAME( name ).Base.Base, \ - SCHEDULER_PRIORITY_ENTRY_POINTS, \ - RTEMS_ARRAY_SIZE( \ - RTEMS_SCHEDULER_CONTEXT_PRIORITY_NAME( name ).Ready \ - ) - 1, \ - ( obj_name ) \ - } -#endif - -#ifdef CONFIGURE_SCHEDULER_PRIORITY_AFFINITY_SMP - #include - - #define RTEMS_SCHEDULER_CONTEXT_PRIORITY_AFFINITY_SMP_NAME( name ) \ - RTEMS_SCHEDULER_CONTEXT_NAME( priority_affinity_SMP_ ## name ) - - #define RTEMS_SCHEDULER_CONTEXT_PRIORITY_AFFINITY_SMP( name, prio_count ) \ - static struct { \ - Scheduler_priority_SMP_Context Base; \ - Chain_Control Ready[ ( prio_count ) ]; \ - } RTEMS_SCHEDULER_CONTEXT_PRIORITY_AFFINITY_SMP_NAME( name ) - - #define RTEMS_SCHEDULER_CONTROL_PRIORITY_AFFINITY_SMP( name, obj_name ) \ - { \ - &RTEMS_SCHEDULER_CONTEXT_PRIORITY_AFFINITY_SMP_NAME( name ).Base.Base.Base, \ - SCHEDULER_PRIORITY_AFFINITY_SMP_ENTRY_POINTS, \ - RTEMS_ARRAY_SIZE( \ - RTEMS_SCHEDULER_CONTEXT_PRIORITY_AFFINITY_SMP_NAME( name ).Ready \ - ) - 1, \ - ( obj_name ) \ - } -#endif - -#ifdef CONFIGURE_SCHEDULER_PRIORITY_SMP - #include - - #define RTEMS_SCHEDULER_CONTEXT_PRIORITY_SMP_NAME( name ) \ - RTEMS_SCHEDULER_CONTEXT_NAME( priority_SMP_ ## name ) - - #define RTEMS_SCHEDULER_CONTEXT_PRIORITY_SMP( name, prio_count ) \ - static struct { \ - Scheduler_priority_SMP_Context Base; \ - Chain_Control Ready[ ( prio_count ) ]; \ - } RTEMS_SCHEDULER_CONTEXT_PRIORITY_SMP_NAME( name ) - - #define RTEMS_SCHEDULER_CONTROL_PRIORITY_SMP( name, obj_name ) \ - { \ - &RTEMS_SCHEDULER_CONTEXT_PRIORITY_SMP_NAME( name ).Base.Base.Base, \ - SCHEDULER_PRIORITY_SMP_ENTRY_POINTS, \ - RTEMS_ARRAY_SIZE( \ - RTEMS_SCHEDULER_CONTEXT_PRIORITY_SMP_NAME( name ).Ready \ - ) - 1, \ - ( obj_name ) \ - } -#endif - -#ifdef CONFIGURE_SCHEDULER_STRONG_APA - #include - - #define RTEMS_SCHEDULER_CONTEXT_STRONG_APA_NAME( name ) \ - RTEMS_SCHEDULER_CONTEXT_NAME( strong_APA_ ## name ) - - #define RTEMS_SCHEDULER_CONTEXT_STRONG_APA( name, prio_count ) \ - static struct { \ - Scheduler_strong_APA_Context Base; \ - Chain_Control Ready[ ( prio_count ) ]; \ - } RTEMS_SCHEDULER_CONTEXT_STRONG_APA_NAME( name ) - - #define RTEMS_SCHEDULER_CONTROL_STRONG_APA( name, obj_name ) \ - { \ - &RTEMS_SCHEDULER_CONTEXT_STRONG_APA_NAME( name ).Base.Base.Base, \ - SCHEDULER_STRONG_APA_ENTRY_POINTS, \ - RTEMS_ARRAY_SIZE( \ - RTEMS_SCHEDULER_CONTEXT_STRONG_APA_NAME( name ).Ready \ - ) - 1, \ - ( obj_name ) \ - } -#endif - -#ifdef CONFIGURE_SCHEDULER_SIMPLE - #include - - #define RTEMS_SCHEDULER_CONTEXT_SIMPLE_NAME( name ) \ - RTEMS_SCHEDULER_CONTEXT_NAME( simple_ ## name ) - - #define RTEMS_SCHEDULER_CONTEXT_SIMPLE( name ) \ - static Scheduler_simple_Context \ - RTEMS_SCHEDULER_CONTEXT_SIMPLE_NAME( name ) - - #define RTEMS_SCHEDULER_CONTROL_SIMPLE( name, obj_name ) \ - { \ - &RTEMS_SCHEDULER_CONTEXT_SIMPLE_NAME( name ).Base, \ - SCHEDULER_SIMPLE_ENTRY_POINTS, \ - SCHEDULER_SIMPLE_MAXIMUM_PRIORITY, \ - ( obj_name ) \ - } -#endif - -#ifdef CONFIGURE_SCHEDULER_SIMPLE_SMP - #include - - #define RTEMS_SCHEDULER_CONTEXT_SIMPLE_SMP_NAME( name ) \ - RTEMS_SCHEDULER_CONTEXT_NAME( simple_SMP_ ## name ) - - #define RTEMS_SCHEDULER_CONTEXT_SIMPLE_SMP( name ) \ - static Scheduler_simple_SMP_Context \ - RTEMS_SCHEDULER_CONTEXT_SIMPLE_SMP_NAME( name ) - - #define RTEMS_SCHEDULER_CONTROL_SIMPLE_SMP( name, obj_name ) \ - { \ - &RTEMS_SCHEDULER_CONTEXT_SIMPLE_SMP_NAME( name ).Base.Base, \ - SCHEDULER_SIMPLE_SMP_ENTRY_POINTS, \ - SCHEDULER_SIMPLE_SMP_MAXIMUM_PRIORITY, \ - ( obj_name ) \ - } -#endif - -#endif /* _RTEMS_SAPI_SCHEDULER_H */ diff --git a/cpukit/sapi/include/rtems/timecounter.h b/cpukit/sapi/include/rtems/timecounter.h deleted file mode 100644 index 8d1bd78618..0000000000 --- a/cpukit/sapi/include/rtems/timecounter.h +++ /dev/null @@ -1,335 +0,0 @@ -/** - * @file - * - * @ingroup SAPITimecounter - * - * @brief Timecounter API - */ - -/* - * Copyright (c) 2015 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_TIMECOUNTER_H -#define _RTEMS_TIMECOUNTER_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup SAPITimecounter Timecounter Support - * - * @{ - */ - -/** - * @brief Timecounter quality for the clock drivers. - * - * Timecounter with higher quality value are used in favour of those with lower - * quality value. - */ -#define RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER 100 - -/** - * @copydoc _Timecounter_Install() - * - * Below is an exemplary code snippet that shows the adjustable parameters and - * the following call of the install routine. - * - * @code - * struct timecounter tc; - * - * uint32_t get_timecount( struct timecounter *tc ) - * { - * return some_free_running_counter; - * } - * - * void install( void ) - * { - * tc.tc_get_timecount = get_timecount; - * tc.tc_counter_mask = 0xffffffff; - * tc.tc_frequency = 123456; - * tc.tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER; - * rtems_timecounter_install( &tc ); - * } - * @endcode - */ -RTEMS_INLINE_ROUTINE void rtems_timecounter_install( - struct timecounter *tc -) -{ - _Timecounter_Install( tc ); -} - -/** - * @copydoc _Timecounter_Tick() - */ -RTEMS_INLINE_ROUTINE void rtems_timecounter_tick(void) -{ - _Timecounter_Tick(); -} - -/** - * @brief Simple timecounter to support legacy clock drivers. - */ -typedef struct { - struct timecounter tc; - uint64_t scaler; - uint32_t real_interval; - uint32_t binary_interval; -} rtems_timecounter_simple; - -/** - * @brief At tick handling done under protection of the timecounter lock. - */ -typedef void rtems_timecounter_simple_at_tick( - rtems_timecounter_simple *tc -); - -/** - * @brief Returns the current value of a simple timecounter. - */ -typedef uint32_t rtems_timecounter_simple_get( - rtems_timecounter_simple *tc -); - -/** - * @brief Returns true if the interrupt of a simple timecounter is pending, and - * false otherwise. - */ -typedef bool rtems_timecounter_simple_is_pending( - rtems_timecounter_simple *tc -); - -/** - * @brief Initializes and installs a simple timecounter. - * - * A simple timecounter can be used if the hardware provides no free running - * counter. A periodic hardware counter must be provided. The counter period - * must be synchronous to the clock tick. The counter ticks per clock tick is - * scaled up to the next power of two. - * - * @param[in] tc Zero initialized simple timecounter. - * @param[in] counter_frequency_in_hz The hardware counter frequency in Hz. - * @param[in] counter_ticks_per_clock_tick The hardware counter ticks per clock - * tick. - * @param[in] get_timecount The method to get the current time count. - * - * @code - * #include - * - * static rtems_timecounter_simple some_tc; - * - * static uint32_t some_tc_get( rtems_timecounter_simple *tc ) - * { - * return some.value; - * } - * - * static bool some_tc_is_pending( rtems_timecounter_simple *tc ) - * { - * return some.is_pending; - * } - * - * static uint32_t some_tc_get_timecount( struct timecounter *tc ) - * { - * return rtems_timecounter_simple_downcounter_get( - * tc, - * some_tc_get, - * some_tc_is_pending - * ); - * } - * - * static void some_tc_tick( void ) - * { - * rtems_timecounter_simple_downcounter_tick( &some_tc, some_tc_get ); - * } - * - * void some_tc_init( void ) - * { - * uint64_t us_per_tick; - * uint32_t counter_frequency_in_hz; - * uint32_t counter_ticks_per_clock_tick; - * - * us_per_tick = rtems_configuration_get_microseconds_per_tick(); - * counter_frequency_in_hz = some_tc_get_frequency(); - * counter_ticks_per_clock_tick = - * (uint32_t) ( counter_frequency_in_hz * us_per_tick ) / 1000000; - * - * some_tc_init_hardware( counter_ticks_per_clock_tick ); - * some_tc_init_clock_tick_interrupt( some_tc_tick ); - * - * rtems_timecounter_simple_install( - * &some_tc, - * counter_frequency_in_hz, - * counter_ticks_per_clock_tick, - * some_tc_get_timecount - * ); - * } - * @endcode - * - * @see rtems_timecounter_simple_downcounter_get(), - * rtems_timecounter_simple_downcounter_tick(), - * rtems_timecounter_simple_upcounter_get() and - * rtems_timecounter_simple_upcounter_tick(). - */ -void rtems_timecounter_simple_install( - rtems_timecounter_simple *tc, - uint32_t counter_frequency_in_hz, - uint32_t counter_ticks_per_clock_tick, - timecounter_get_t *get_timecount -); - -/** - * @brief Maps a simple timecounter value into its binary frequency domain. - * - * @param[in] tc The simple timecounter. - * @param[in] value The value of the simple timecounter. - * - * @return The scaled value. - */ -RTEMS_INLINE_ROUTINE uint32_t rtems_timecounter_simple_scale( - const rtems_timecounter_simple *tc, - uint32_t value -) -{ - return (uint32_t) ( ( value * tc->scaler ) >> 32 ); -} - -/** - * @brief Performs a simple timecounter tick for downcounters. - * - * @param[in] tc The simple timecounter. - * @param[in] get The method to get the value of the simple timecounter. - * @param[in] at_tick The method to perform work under timecounter lock - * protection at this tick, e.g. clear a pending flag. - */ -RTEMS_INLINE_ROUTINE void rtems_timecounter_simple_downcounter_tick( - rtems_timecounter_simple *tc, - rtems_timecounter_simple_get get, - rtems_timecounter_simple_at_tick at_tick -) -{ - ISR_lock_Context lock_context; - uint32_t current; - - _Timecounter_Acquire( &lock_context ); - - ( *at_tick )( tc ); - - current = rtems_timecounter_simple_scale( - tc, - tc->real_interval - ( *get )( tc ) - ); - - _Timecounter_Tick_simple( tc->binary_interval, current, &lock_context ); -} - -/** - * @brief Performs a simple timecounter tick for upcounters. - * - * @param[in] tc The simple timecounter. - * @param[in] get The method to get the value of the simple timecounter. - * @param[in] at_tick The method to perform work under timecounter lock - * protection at this tick, e.g. clear a pending flag. - */ -RTEMS_INLINE_ROUTINE void rtems_timecounter_simple_upcounter_tick( - rtems_timecounter_simple *tc, - rtems_timecounter_simple_get get, - rtems_timecounter_simple_at_tick at_tick -) -{ - ISR_lock_Context lock_context; - uint32_t current; - - _Timecounter_Acquire( &lock_context ); - - ( *at_tick )( tc ); - - current = rtems_timecounter_simple_scale( tc, ( *get )( tc ) ); - - _Timecounter_Tick_simple( tc->binary_interval, current, &lock_context ); -} - -/** - * @brief Gets the simple timecounter value mapped to its binary frequency - * domain for downcounters. - * - * @param[in] tc The simple timecounter. - * @param[in] get The method to get the value of the simple timecounter. - * @param[in] is_pending The method which indicates if the interrupt of the - * simple timecounter is pending. - */ -RTEMS_INLINE_ROUTINE uint32_t rtems_timecounter_simple_downcounter_get( - struct timecounter *tc_base, - rtems_timecounter_simple_get get, - rtems_timecounter_simple_is_pending is_pending -) -{ - rtems_timecounter_simple *tc; - uint32_t counter; - uint32_t interval; - - tc = (rtems_timecounter_simple *) tc_base; - counter = ( *get )( tc ); - interval = tc->real_interval; - - if ( ( *is_pending )( tc ) ) { - counter = ( *get )( tc ); - interval *= 2; - } - - return rtems_timecounter_simple_scale( tc, interval - counter ); -} - -/** - * @brief Gets the simple timecounter value mapped to its binary frequency - * domain for upcounters. - * - * @param[in] tc The simple timecounter. - * @param[in] get The method to get the value of the simple timecounter. - * @param[in] is_pending The method which indicates if the interrupt of the - * simple timecounter is pending. - */ -RTEMS_INLINE_ROUTINE uint32_t rtems_timecounter_simple_upcounter_get( - struct timecounter *tc_base, - rtems_timecounter_simple_get get, - rtems_timecounter_simple_is_pending is_pending -) -{ - rtems_timecounter_simple *tc; - uint32_t counter; - uint32_t interval; - - tc = (rtems_timecounter_simple *) tc_base; - counter = ( *get )( tc ); - interval = 0; - - if ( ( *is_pending )( tc ) ) { - counter = ( *get )( tc ); - interval = tc->real_interval; - } - - return rtems_timecounter_simple_scale( tc, interval + counter ); -} - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_TIMECOUNTER_H */ diff --git a/cpukit/sapi/include/rtems/timespec.h b/cpukit/sapi/include/rtems/timespec.h deleted file mode 100644 index e82d271492..0000000000 --- a/cpukit/sapi/include/rtems/timespec.h +++ /dev/null @@ -1,305 +0,0 @@ -/** - * @file - * - * @brief Timespec API - * - * This include file contains API for manipulating timespecs. - */ - -/* - * Copyright (c) 2012. - * Krzysztof Miesowicz - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_TIMESPEC_H -#define _RTEMS_TIMESPEC_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup TimespecAPI Timespec - * - * @ingroup ClassicRTEMS - * - * @brief Timespec API - * - * @{ - * - */ - -/** - * @brief Is timespec valid - * - * This method determines the validity of a timespec. - * - * @param[in] time is the timespec instance to validate. - * - * @retval true The timespec is valid. - * @retval false The timespec is not valid. - */ -RTEMS_INLINE_ROUTINE bool rtems_timespec_is_valid( - const struct timespec *time -) -{ - return _Timespec_Is_valid(time); -} - -/** - * @brief Timespec less than operator. - * - * This method is the less than operator for timespecs. - * - * @param[in] lhs is the left hand side timespec - * @param[in] rhs is the right hand side timespec - * - * @retval true @a lhs is less than @a rhs. - * @retval false @a lhs is not less than @a rhs. - * - */ -RTEMS_INLINE_ROUTINE bool rtems_timespec_less_than( - const struct timespec *lhs, - const struct timespec *rhs -) -{ - return _Timespec_Less_than(lhs,rhs); -} - -/** - * @brief Add to a timespec. - * - * This routine adds two timespecs. The second argument is added - * to the first. - * - * @param[in] time is the base time to be added to - * @param[in] add is the timespec to add to the first argument - * - * @return This method returns the number of seconds @a time increased by. - */ -RTEMS_INLINE_ROUTINE uint32_t rtems_timespec_add_to( - struct timespec *time, - const struct timespec *add -) -{ - return _Timespec_Add_to(time,add); -} - -/** - * @brief Convert timespec to number of ticks. - * - * This routine convert the @a time timespec to the corresponding number - * of clock ticks. - * - * @param[in] time is the time to be converted - * - * @return This method returns the number of ticks computed. - */ -RTEMS_INLINE_ROUTINE uint32_t rtems_timespec_to_ticks( - const struct timespec *time -) -{ - return _Timespec_To_ticks(time); -} - -/** - * @brief Convert ticks to timespec. - * - * This routine converts the @a ticks value to the corresponding - * timespec format @a time. - * - * @param[in] time is the timespec format time result - * @param[in] ticks is the number of ticks to convert - */ - -RTEMS_INLINE_ROUTINE void rtems_timespec_from_ticks( - uint32_t ticks, - struct timespec *time -) -{ - _Timespec_From_ticks(ticks,time); -} - -/** - * @brief Subtract two timespec. - * - * This routine subtracts two timespecs. @a result is set to - * @a end - @a start. - * - * @param[in] start is the starting time - * @param[in] end is the ending time - * @param[in] result is the difference between starting and ending time. - * - * @return This method fills in @a result. - */ -RTEMS_INLINE_ROUTINE void rtems_timespec_subtract( - const struct timespec *start, - const struct timespec *end, - struct timespec *result -) -{ - _Timespec_Subtract(start,end,result); -} - -/** - * @brief Divide timespec by integer. - * - * This routine divides a timespec by an integer value. The expected - * use is to assist in benchmark calculations where you typically - * divide a duration by a number of iterations. - * - * @param[in] time is the total - * @param[in] iterations is the number of iterations - * @param[in] result is the average time. - * - * @return This method fills in @a result. - */ -RTEMS_INLINE_ROUTINE void rtems_timespec_divide_by_integer( - const struct timespec *time, - uint32_t iterations, - struct timespec *result -) -{ - _Timespec_Divide_by_integer(time,iterations,result); -} - -/** - * @brief Divide timespec. - * - * This routine divides a timespec by another timespec. The - * intended use is for calculating percentages to three decimal points. - * - * @param[in] lhs is the left hand number - * @param[in] rhs is the right hand number - * @param[in] ival_percentage is the integer portion of the average - * @param[in] fval_percentage is the thousandths of percentage - * - * @return This method fills in @a result. - */ -RTEMS_INLINE_ROUTINE void rtems_timespec_divide( - const struct timespec *lhs, - const struct timespec *rhs, - uint32_t *ival_percentage, - uint32_t *fval_percentage -) -{ - _Timespec_Divide(lhs,rhs,ival_percentage,fval_percentage); -} - -/** - * @brief Set timespec to seconds nanosecond. - * - * This method sets the timespec to the specified seconds and nanoseconds - * value. - * - * @param[in] _time points to the timespec instance to validate. - * @param[in] _seconds is the seconds portion of the timespec - * @param[in] _nanoseconds is the nanoseconds portion of the timespec - */ -RTEMS_INLINE_ROUTINE void rtems_timespec_set( - struct timespec *_time, - time_t _seconds, - uint32_t _nanoseconds -) -{ - _Timespec_Set( _time, _seconds, _nanoseconds ); -} - -/** - * @brief Zero timespec. - * - * This method sets the timespec to zero. - * value. - * - * @param[in] _time points to the timespec instance to zero. - */ -RTEMS_INLINE_ROUTINE void rtems_timespec_zero( - struct timespec *_time -) -{ - _Timespec_Set_to_zero( _time ); -} - -/** - * @brief Get seconds portion of timespec. - * - * This method returns the seconds portion of the specified timespec - * - * @param[in] _time points to the timespec - * - * @return The seconds portion of @a _time. - */ -RTEMS_INLINE_ROUTINE time_t rtems_timespec_get_seconds( - struct timespec *_time -) -{ - return _Timespec_Get_seconds( _time ); -} - -/** - * @brief Get nanoseconds portion of timespec. - * - * This method returns the nanoseconds portion of the specified timespec - * - * @param[in] _time points to the timespec - * - * @return The nanoseconds portion of @a _time. - */ -RTEMS_INLINE_ROUTINE uint32_t rtems_timespec_get_nanoseconds( - struct timespec *_time -) -{ - return _Timespec_Get_nanoseconds( _time ); -} - -/** - * @brief Timespec greater than operator. - * - * This method is the greater than operator for timespecs. - * - * @param[in] _lhs is the left hand side timespec - * @param[in] _rhs is the right hand side timespec - * - * @retval true @a _lhs is greater than @a _rhs. - * @retval false @a _lhs is not greater than @a _rhs. - */ -RTEMS_INLINE_ROUTINE bool rtems_timespec_greater_than( - const struct timespec *_lhs, - const struct timespec *_rhs -) -{ - return _Timespec_Greater_than( _lhs, _rhs ); -} -/** - * @brief Timespec equal to Operator - * - * This method is the is equal to than operator for timespecs. - * - * @param[in] lhs is the left hand side timespec - * @param[in] rhs is the right hand side timespec - * - * @retval true @a lhs is equal to @a rhs. - * @retval false @a lhs is not equal to @a rhs. - */ -RTEMS_INLINE_ROUTINE bool rtems_timespec_equal_to( - const struct timespec *lhs, - const struct timespec *rhs -) -{ - return _Timespec_Equal_to( lhs, rhs); -} - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/sapi/include/rtems/version.h b/cpukit/sapi/include/rtems/version.h deleted file mode 100644 index b806cb8c2f..0000000000 --- a/cpukit/sapi/include/rtems/version.h +++ /dev/null @@ -1,77 +0,0 @@ -/** - * @file - * - * @brief Version API. - */ - -/* - * Copyright (C) 2017. - * Chris Johns - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_VERSION_H -#define _RTEMS_VERSION_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ClassicVersion Version - * - * @ingroup ClassicVersion - * - * @brief The Version API provides functions to return the version or parts of - * the version of RTEMS you are using. - */ -/**@{**/ - -/** - * @brief Returns the version string. - * - * @retval text The version as a string. - */ -const char *rtems_version( void ); - -/** - * @brief Returns the version's major number. - * - * @retval int The version's major number. - */ -int rtems_version_major( void ); - -/** - * @brief Returns the version's minor number. - * - * @retval int The version's minor number. - */ -int rtems_version_minor( void ); - -/** - * @brief Returns the version's revision number. - * - * @retval int The version's revision number. - */ -int rtems_version_revision( void ); - -/** - * @brief Returns the version control key for the current version of code that - * has been built. The key is specific to the version control system being used - * and allows the built version to be identified. - * - * @retval int The version's version control key. - */ -const char *rtems_version_control_key( void ); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/sapi/preinstall.am b/cpukit/sapi/preinstall.am deleted file mode 100644 index a6b0ba30df..0000000000 --- a/cpukit/sapi/preinstall.am +++ /dev/null @@ -1,100 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -$(PROJECT_INCLUDE)/rtems/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems - @: > $(PROJECT_INCLUDE)/rtems/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/confdefs.h: include/confdefs.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/confdefs.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/confdefs.h - -$(PROJECT_INCLUDE)/rtems/bsd.h: include/rtems/bsd.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/bsd.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/bsd.h - -$(PROJECT_INCLUDE)/rtems/chain.h: include/rtems/chain.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/chain.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/chain.h - -$(PROJECT_INCLUDE)/rtems/config.h: include/rtems/config.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/config.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/config.h - -$(PROJECT_INCLUDE)/rtems/counter.h: include/rtems/counter.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/counter.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/counter.h - -$(PROJECT_INCLUDE)/rtems/extension.h: include/rtems/extension.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/extension.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/extension.h - -$(PROJECT_INCLUDE)/rtems/extensionimpl.h: include/rtems/extensionimpl.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/extensionimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/extensionimpl.h - -$(PROJECT_INCLUDE)/rtems/fatal.h: include/rtems/fatal.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/fatal.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/fatal.h - -$(PROJECT_INCLUDE)/rtems/init.h: include/rtems/init.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/init.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/init.h - -$(PROJECT_INCLUDE)/rtems/io.h: include/rtems/io.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/io.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/io.h - -$(PROJECT_INCLUDE)/rtems/ioimpl.h: include/rtems/ioimpl.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/ioimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/ioimpl.h - -$(PROJECT_INCLUDE)/rtems/mptables.h: include/rtems/mptables.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/mptables.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/mptables.h - -$(PROJECT_INCLUDE)/rtems/cbs.h: include/rtems/cbs.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/cbs.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/cbs.h - -$(PROJECT_INCLUDE)/rtems/profiling.h: include/rtems/profiling.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/profiling.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/profiling.h - -$(PROJECT_INCLUDE)/rtems/rbheap.h: include/rtems/rbheap.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rbheap.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rbheap.h - -$(PROJECT_INCLUDE)/rtems/rbtree.h: include/rtems/rbtree.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/rbtree.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/rbtree.h - -$(PROJECT_INCLUDE)/rtems/scheduler.h: include/rtems/scheduler.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/scheduler.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/scheduler.h - -$(PROJECT_INCLUDE)/rtems/timecounter.h: include/rtems/timecounter.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/timecounter.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/timecounter.h - -$(PROJECT_INCLUDE)/rtems/timespec.h: include/rtems/timespec.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/timespec.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/timespec.h - -$(PROJECT_INCLUDE)/rtems/version.h: include/rtems/version.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/version.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/version.h - diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am index b7edf09dde..8054df1d8f 100644 --- a/cpukit/score/Makefile.am +++ b/cpukit/score/Makefile.am @@ -5,132 +5,11 @@ _SUBDIRS = cpu ## include -include_sysdir = $(includedir)/sys - -include_sys_HEADERS = -include_sys_HEADERS += include/sys/_ffcounter.h -include_sys_HEADERS += include/sys/timeffc.h -include_sys_HEADERS += include/sys/timepps.h -include_sys_HEADERS += include/sys/timetc.h -include_sys_HEADERS += include/sys/timex.h - -include_rtemsdir = $(includedir)/rtems - -include_rtems_HEADERS = -include_rtems_HEADERS += include/rtems/linkersets.h -include_rtems_HEADERS += include/rtems/sysinit.h -include_rtems_HEADERS += include/rtems/system.h -include_rtems_HEADERS += include/rtems/seterr.h - -include_rtems_scoredir = $(includedir)/rtems/score - -include_rtems_score_HEADERS = include/rtems/score/address.h -include_rtems_score_HEADERS += include/rtems/score/apimutex.h -include_rtems_score_HEADERS += include/rtems/score/assert.h -include_rtems_score_HEADERS += include/rtems/score/atomic.h -include_rtems_score_HEADERS += include/rtems/score/chain.h -include_rtems_score_HEADERS += include/rtems/score/chainimpl.h -include_rtems_score_HEADERS += include/rtems/score/context.h -include_rtems_score_HEADERS += include/rtems/score/copyrt.h -include_rtems_score_HEADERS += include/rtems/score/corebarrier.h -include_rtems_score_HEADERS += include/rtems/score/corebarrierimpl.h -include_rtems_score_HEADERS += include/rtems/score/coremsg.h -include_rtems_score_HEADERS += include/rtems/score/coremsgimpl.h -include_rtems_score_HEADERS += include/rtems/score/coremutex.h -include_rtems_score_HEADERS += include/rtems/score/coremuteximpl.h -include_rtems_score_HEADERS += include/rtems/score/corerwlockimpl.h -include_rtems_score_HEADERS += include/rtems/score/coresem.h -include_rtems_score_HEADERS += include/rtems/score/coresemimpl.h -include_rtems_score_HEADERS += include/rtems/score/cpustdatomic.h -include_rtems_score_HEADERS += include/rtems/score/heap.h -include_rtems_score_HEADERS += include/rtems/score/heapimpl.h -include_rtems_score_HEADERS += include/rtems/score/protectedheap.h -include_rtems_score_HEADERS += include/rtems/score/interr.h -include_rtems_score_HEADERS += include/rtems/score/io.h -include_rtems_score_HEADERS += include/rtems/score/isr.h -include_rtems_score_HEADERS += include/rtems/score/isrlevel.h -include_rtems_score_HEADERS += include/rtems/score/isrlock.h -include_rtems_score_HEADERS += include/rtems/score/freechain.h -include_rtems_score_HEADERS += include/rtems/score/mrsp.h -include_rtems_score_HEADERS += include/rtems/score/mrspimpl.h -include_rtems_score_HEADERS += include/rtems/score/muteximpl.h -include_rtems_score_HEADERS += include/rtems/score/object.h -include_rtems_score_HEADERS += include/rtems/score/objectimpl.h -include_rtems_score_HEADERS += include/rtems/score/onceimpl.h -include_rtems_score_HEADERS += include/rtems/score/percpu.h -include_rtems_score_HEADERS += include/rtems/score/priority.h -include_rtems_score_HEADERS += include/rtems/score/priorityimpl.h -include_rtems_score_HEADERS += include/rtems/score/prioritybitmap.h -include_rtems_score_HEADERS += include/rtems/score/prioritybitmapimpl.h -include_rtems_score_HEADERS += include/rtems/score/profiling.h -include_rtems_score_HEADERS += include/rtems/score/processormask.h -include_rtems_score_HEADERS += include/rtems/score/rbtree.h -include_rtems_score_HEADERS += include/rtems/score/rbtreeimpl.h -include_rtems_score_HEADERS += include/rtems/score/scheduler.h -include_rtems_score_HEADERS += include/rtems/score/schedulerimpl.h -include_rtems_score_HEADERS += include/rtems/score/schedulercbs.h -include_rtems_score_HEADERS += include/rtems/score/schedulercbsimpl.h -include_rtems_score_HEADERS += include/rtems/score/scheduleredf.h -include_rtems_score_HEADERS += include/rtems/score/scheduleredfimpl.h -include_rtems_score_HEADERS += include/rtems/score/schedulernode.h -include_rtems_score_HEADERS += include/rtems/score/schedulernodeimpl.h -include_rtems_score_HEADERS += include/rtems/score/schedulerpriority.h -include_rtems_score_HEADERS += include/rtems/score/schedulerpriorityimpl.h -include_rtems_score_HEADERS += include/rtems/score/schedulerprioritysmp.h -include_rtems_score_HEADERS += include/rtems/score/schedulersimple.h -include_rtems_score_HEADERS += include/rtems/score/schedulersimpleimpl.h -include_rtems_score_HEADERS += include/rtems/score/schedulersmp.h -include_rtems_score_HEADERS += include/rtems/score/schedulersmpimpl.h -include_rtems_score_HEADERS += include/rtems/score/semaphoreimpl.h -include_rtems_score_HEADERS += include/rtems/score/smp.h -include_rtems_score_HEADERS += include/rtems/score/smpbarrier.h -include_rtems_score_HEADERS += include/rtems/score/smplock.h -include_rtems_score_HEADERS += include/rtems/score/smplockseq.h -include_rtems_score_HEADERS += include/rtems/score/smpimpl.h -include_rtems_score_HEADERS += include/rtems/score/stack.h -include_rtems_score_HEADERS += include/rtems/score/stackimpl.h -include_rtems_score_HEADERS += include/rtems/score/states.h -include_rtems_score_HEADERS += include/rtems/score/statesimpl.h -include_rtems_score_HEADERS += include/rtems/score/status.h -include_rtems_score_HEADERS += include/rtems/score/sysstate.h -include_rtems_score_HEADERS += include/rtems/score/thread.h -include_rtems_score_HEADERS += include/rtems/score/threadimpl.h -include_rtems_score_HEADERS += include/rtems/score/threaddispatch.h -include_rtems_score_HEADERS += include/rtems/score/threadq.h -include_rtems_score_HEADERS += include/rtems/score/threadqimpl.h -include_rtems_score_HEADERS += include/rtems/score/timespec.h -include_rtems_score_HEADERS += include/rtems/score/timestamp.h -include_rtems_score_HEADERS += include/rtems/score/timecounter.h -include_rtems_score_HEADERS += include/rtems/score/timecounterimpl.h -include_rtems_score_HEADERS += include/rtems/score/tls.h -include_rtems_score_HEADERS += include/rtems/score/tod.h -include_rtems_score_HEADERS += include/rtems/score/todimpl.h -include_rtems_score_HEADERS += include/rtems/score/userext.h -include_rtems_score_HEADERS += include/rtems/score/userextimpl.h -include_rtems_score_HEADERS += include/rtems/score/watchdog.h -include_rtems_score_HEADERS += include/rtems/score/watchdogimpl.h -include_rtems_score_HEADERS += include/rtems/score/wkspace.h -include_rtems_score_HEADERS += include/rtems/score/cpuopts.h -include_rtems_score_HEADERS += include/rtems/score/basedefs.h - if HAS_MP # We only build multiprocessing related files if HAS_MP was defined -include_rtems_score_HEADERS += include/rtems/score/mpci.h -include_rtems_score_HEADERS += include/rtems/score/mpciimpl.h -include_rtems_score_HEADERS += include/rtems/score/mppkt.h -include_rtems_score_HEADERS += include/rtems/score/objectmp.h -include_rtems_score_HEADERS += include/rtems/score/threadmp.h endif if HAS_SMP -include_rtems_score_HEADERS += include/rtems/score/scheduleredfsmp.h -include_rtems_score_HEADERS += include/rtems/score/schedulerprioritysmpimpl.h -include_rtems_score_HEADERS += include/rtems/score/schedulerpriorityaffinitysmp.h -include_rtems_score_HEADERS += include/rtems/score/schedulersimplesmp.h -include_rtems_score_HEADERS += include/rtems/score/schedulerstrongapa.h -include_rtems_score_HEADERS += include/rtems/score/smplockmcs.h -include_rtems_score_HEADERS += include/rtems/score/smplockstats.h -include_rtems_score_HEADERS += include/rtems/score/smplockticket.h endif ## src @@ -352,8 +231,10 @@ libscore_a_SOURCES += src/processormaskcopy.c EXTRA_DIST = src/Unlimited.txt -DISTCLEANFILES = include/rtems/score/cpuopts.h +# This file is in the build tree +DISTCLEANFILES = ../..include/rtems/score/cpuopts.h +include_rtems_scoredir = $(includedir)/rtems/score +include_rtems_score_HEADERS = ../../include/rtems/score/cpuopts.h -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/subdirs.am include $(top_srcdir)/automake/local.am diff --git a/cpukit/score/cpu/arm/Makefile.am b/cpukit/score/cpu/arm/Makefile.am index a0881e80e9..865a750477 100644 --- a/cpukit/score/cpu/arm/Makefile.am +++ b/cpukit/score/cpu/arm/Makefile.am @@ -1,20 +1,4 @@ include $(top_srcdir)/automake/compile.am -include_rtemsdir = $(includedir)/rtems -include_rtems_HEADERS = rtems/asm.h - -include_rtems_scoredir = $(includedir)/rtems/score -include_rtems_score_HEADERS = rtems/score/cpu.h -include_rtems_score_HEADERS += rtems/score/cpuimpl.h -include_rtems_score_HEADERS += rtems/score/cpu_asm.h -include_rtems_score_HEADERS += rtems/score/arm.h -include_rtems_score_HEADERS += rtems/score/armv4.h -include_rtems_score_HEADERS += rtems/score/armv7m.h -include_rtems_score_HEADERS += rtems/score/types.h -include_rtems_score_HEADERS += rtems/score/cpuatomic.h - -include_libcpudir = $(includedir)/libcpu -include_libcpu_HEADERS = include/libcpu/arm-cp15.h - noinst_LIBRARIES = libscorecpu.a libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS) libscorecpu_a_SOURCES = @@ -48,5 +32,5 @@ libscorecpu_a_SOURCES += armv7m-isr-level-set.c libscorecpu_a_SOURCES += armv7m-isr-vector-install.c libscorecpu_a_SOURCES += armv7m-multitasking-start-stop.c -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am +include $(srcdir)/headers.am diff --git a/cpukit/score/cpu/arm/headers.am b/cpukit/score/cpu/arm/headers.am new file mode 100644 index 0000000000..61a055f79a --- /dev/null +++ b/cpukit/score/cpu/arm/headers.am @@ -0,0 +1,24 @@ +## This file was generated by "./boostrap -H". + +include_libcpudir = $(includedir)/libcpu +include_libcpu_HEADERS = +include_libcpu_HEADERS += include/libcpu/arm-cp15.h + +include_machinedir = $(includedir)/machine +include_machine_HEADERS = +include_machine_HEADERS += include/machine/elf_machdep.h + +include_rtemsdir = $(includedir)/rtems +include_rtems_HEADERS = +include_rtems_HEADERS += include/rtems/asm.h + +include_rtems_scoredir = $(includedir)/rtems/score +include_rtems_score_HEADERS = +include_rtems_score_HEADERS += include/rtems/score/arm.h +include_rtems_score_HEADERS += include/rtems/score/armv4.h +include_rtems_score_HEADERS += include/rtems/score/armv7m.h +include_rtems_score_HEADERS += include/rtems/score/cpu.h +include_rtems_score_HEADERS += include/rtems/score/cpu_asm.h +include_rtems_score_HEADERS += include/rtems/score/cpuatomic.h +include_rtems_score_HEADERS += include/rtems/score/cpuimpl.h +include_rtems_score_HEADERS += include/rtems/score/types.h diff --git a/cpukit/score/cpu/arm/include/machine/elf_machdep.h b/cpukit/score/cpu/arm/include/machine/elf_machdep.h new file mode 100644 index 0000000000..8f01d05212 --- /dev/null +++ b/cpukit/score/cpu/arm/include/machine/elf_machdep.h @@ -0,0 +1,132 @@ +/* $NetBSD: elf_machdep.h,v 1.8 2009/05/30 05:56:52 skrll Exp $ */ + +#if defined(__ARMEB__) +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB +#else +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB +#endif + +#define ELF64_MACHDEP_ENDIANNESS XXX /* break compilation */ +#define ELF64_MACHDEP_ID_CASES \ + /* no 64-bit ELF machine types supported */ + +/* Processor specific flags for the ELF header e_flags field. */ +#define EF_ARM_RELEXEC 0x00000001 +#define EF_ARM_HASENTRY 0x00000002 +#define EF_ARM_INTERWORK 0x00000004 /* GNU binutils 000413 */ +#define EF_ARM_SYMSARESORTED 0x00000004 /* ARM ELF A08 */ +#define EF_ARM_APCS_26 0x00000008 /* GNU binutils 000413 */ +#define EF_ARM_DYNSYMSUSESEGIDX 0x00000008 /* ARM ELF B01 */ +#define EF_ARM_APCS_FLOAT 0x00000010 /* GNU binutils 000413 */ +#define EF_ARM_MAPSYMSFIRST 0x00000010 /* ARM ELF B01 */ +#define EF_ARM_PIC 0x00000020 +#define EF_ARM_ALIGN8 0x00000040 /* 8-bit structure alignment. */ +#define EF_ARM_NEW_ABI 0x00000080 +#define EF_ARM_OLD_ABI 0x00000100 +#define EF_ARM_SOFT_FLOAT 0x00000200 +#define EF_ARM_EABIMASK 0xff000000 + +#define ELF32_MACHDEP_ID_CASES \ + case EM_ARM: \ + break; + +#define ELF32_MACHDEP_ID EM_ARM + +#define ARCH_ELFSIZE 32 /* MD native binary size */ + +/* Processor specific relocation types */ + +#define R_ARM_NONE 0 +#define R_ARM_PC24 1 +#define R_ARM_ABS32 2 +#define R_ARM_REL32 3 +#define R_ARM_PC13 4 +#define R_ARM_ABS16 5 +#define R_ARM_ABS12 6 +#define R_ARM_THM_ABS5 7 +#define R_ARM_ABS8 8 +#define R_ARM_SBREL32 9 +#define R_ARM_THM_CALL 10 +#define R_ARM_THM_PC8 11 +#define R_ARM_AMP_VCALL9 12 +#define R_ARM_SWI24 13 +#define R_ARM_THM_SWI8 14 +#define R_ARM_XPC25 15 +#define R_ARM_THM_XPC22 16 + +/* TLS relocations */ +#define R_ARM_TLS_DTPMOD32 17 /* ID of module containing symbol */ +#define R_ARM_TLS_DTPOFF32 18 /* Offset in TLS block */ +#define R_ARM_TLS_TPOFF32 19 /* Offset in static TLS block */ + +/* 20-31 are reserved for ARM Linux. */ +#define R_ARM_COPY 20 +#define R_ARM_GLOB_DAT 21 +#define R_ARM_JUMP_SLOT 22 +#define R_ARM_RELATIVE 23 +#define R_ARM_GOTOFF 24 +#define R_ARM_GOTPC 25 +#define R_ARM_GOT32 26 +#define R_ARM_PLT32 27 +#define R_ARM_CALL 28 +#define R_ARM_JUMP24 29 +#define R_ARM_THM_JUMP24 30 +#define R_ARM_BASE_ABS 31 + +#define R_ARM_ALU_PCREL_7_0 32 +#define R_ARM_ALU_PCREL_15_8 33 +#define R_ARM_ALU_PCREL_23_15 34 +#define R_ARM_ALU_SBREL_11_0 35 +#define R_ARM_ALU_SBREL_19_12 36 +#define R_ARM_ALU_SBREL_27_20 37 +#define R_ARM_V4BX 40 +#define R_ARM_TARGET2 41 +#define R_ARM_PREL31 42 + +#define R_ARM_MOVW_ABS_NC 43 +#define R_ARM_MOVT_ABS 44 + +#define R_ARM_THM_MOVW_ABS_NC 47 +#define R_ARM_THM_MOVT_ABS 48 + +#define R_ARM_THM_JUMP19 51 + +/* 96-111 are reserved to G++. */ +#define R_ARM_GNU_VTENTRY 100 +#define R_ARM_GNU_VTINHERIT 101 +#define R_ARM_THM_JUMP11 102 +#define R_ARM_THM_JUMP8 103 + +/* More TLS relocations */ +#define R_ARM_TLS_GD32 104 /* PC-rel 32 bit for global dynamic */ +#define R_ARM_TLS_LDM32 105 /* PC-rel 32 bit for local dynamic */ +#define R_ARM_TLS_LDO32 106 /* 32 bit offset relative to TLS */ +#define R_ARM_TLS_IE32 107 /* PC-rel 32 bit for GOT entry of */ +#define R_ARM_TLS_LE32 108 +#define R_ARM_TLS_LDO12 109 +#define R_ARM_TLS_LE12 110 +#define R_ARM_TLS_IE12GP 111 + +/* 112-127 are reserved for private experiments. */ + +#define R_ARM_RXPC25 249 +#define R_ARM_RSBREL32 250 +#define R_ARM_THM_RPC22 251 +#define R_ARM_RREL32 252 +#define R_ARM_RABS32 253 +#define R_ARM_RPC24 254 +#define R_ARM_RBASE 255 + +#define R_TYPE(name) __CONCAT(R_ARM_,name) + +/* Processor specific program header flags */ +#define PF_ARM_SB 0x10000000 +#define PF_ARM_PI 0x20000000 +#define PF_ARM_ENTRY 0x80000000 + +/* Processor specific section header flags */ +#define SHF_ENTRYSECT 0x10000000 +#define SHF_COMDEF 0x80000000 + +/* Processor specific symbol types */ +#define STT_ARM_TFUNC STT_LOPROC diff --git a/cpukit/score/cpu/arm/include/rtems/asm.h b/cpukit/score/cpu/arm/include/rtems/asm.h new file mode 100644 index 0000000000..f72df32325 --- /dev/null +++ b/cpukit/score/cpu/arm/include/rtems/asm.h @@ -0,0 +1,231 @@ +/** + * @file + * + * @brief ARM Assembler Support API + * + * This include file attempts to address the problems + * caused by incompatible flavors of assemblers and + * toolsets. It primarily addresses variations in the + * use of leading underscores on symbols and the requirement + * that register names be preceded by a %. + * + * + * NOTE: The spacing in the use of these macros + * is critical to them working as advertised. + */ + +/* + * COPYRIGHT: + * + * This file is based on similar code found in newlib available + * from ftp.cygnus.com. The file which was used had no copyright + * notice. This file is freely distributable as long as the source + * of the file is noted. This file is: + * + * COPYRIGHT (c) 2000 Canon Research Centre France SA. + * Emmanuel Raguet, mailto:raguet@crf.canon.fr + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + */ + +#ifndef _RTEMS_ASM_H +#define _RTEMS_ASM_H + +/* + * Indicate we are in an assembly file and get the basic CPU definitions. + */ + +#ifndef ASM +#define ASM +#endif +#include + +/** + * @defgroup ScoreCPUARMASM ARM Assembler Support + * + * @ingroup ScoreCPU + * + * @brief ARM Assembler Support + */ +/**@{**/ + +/* + * Recent versions of GNU cpp define variables which indicate the + * need for underscores and percents. If not using GNU cpp or + * the version does not support this, then you will obviously + * have to define these as appropriate. + */ + +#ifndef __USER_LABEL_PREFIX__ +#define __USER_LABEL_PREFIX__ _ +#endif + +#ifndef __REGISTER_PREFIX__ +#define __REGISTER_PREFIX__ +#endif + +#include + +/* Use the right prefix for global labels. */ + +#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) + +/* Use the right prefix for registers. */ + +#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) + +/* + * define macros for all of the registers on this CPU + * + * EXAMPLE: #define d0 REG (d0) + */ + +#define r0 REG(r0) +#define r1 REG(r1) +#define r2 REG(r2) +#define r3 REG(r3) +#define r4 REG(r4) +#define r5 REG(r5) +#define r6 REG(r6) +#define r7 REG(r7) +#define r8 REG(r8) +#define r9 REG(r9) +#define r10 REG(r10) +#define r11 REG(r11) +#define r12 REG(r12) +#define r13 REG(r13) +#define r14 REG(r14) +#define r15 REG(r15) + +#define CPSR REG(CPSR) + +#define SPSR REG(SPSR) + +#define NUM_IRQ_VECTOR 6 // IRQ number +#define NUM_FIQ_VECTOR 7 // IRQ number + // // +#define CPSR_IRQ_DISABLE 0x80 // FIQ disabled when =1 +#define CPSR_FIQ_DISABLE 0x40 // FIQ disabled when =1 +#define CPSR_THUMB_ENABLE 0x20 // Thumb mode when =1 +#define CPSR_FIQ_MODE 0x11 +#define CPSR_IRQ_MODE 0x12 +#define CPSR_SUPERVISOR_MODE 0x13 +#define CPSR_UNDEF_MODE 0x1B + +#define CPSR_MODE_BITS 0x1F + +/* + * Define macros to handle section beginning and ends. + */ + + +#define BEGIN_CODE_DCL .text +#define END_CODE_DCL +#define BEGIN_DATA_DCL .data +#define END_DATA_DCL +#define BEGIN_CODE .text +#define END_CODE +#define BEGIN_DATA +#define END_DATA +#define BEGIN_BSS +#define END_BSS +#define END + +/* + * Following must be tailor for a particular flavor of the C compiler. + * They may need to put underscores in front of the symbols. + */ + +#define PUBLIC(sym) .globl SYM (sym) +#define EXTERN(sym) .globl SYM (sym) + +#define FUNCTION_THUMB_ENTRY(name) \ + .thumb; \ + .thumb_func; \ + .align 2; \ + .globl name; \ + .type name, %function; \ + name: + +#define FUNCTION_ENTRY(name) \ + .align 2; \ + .globl name; \ + .type name, %function; \ + name: + +#define FUNCTION_END(name) \ + .size name, . - name + +#if defined(ARM_MULTILIB_ARCH_V7M) + #define DEFINE_FUNCTION_ARM(name) \ + .thumb_func ; .globl name ; name: +#elif defined(__thumb__) + #define DEFINE_FUNCTION_ARM(name) \ + .thumb_func ; .globl name ; name: ; bx pc ; \ + .arm ; .globl name ## _arm ; name ## _arm: +#else + #define DEFINE_FUNCTION_ARM(name) \ + .globl name ; name: ; .globl name ## _arm ; name ## _arm: +#endif + +.macro SWITCH_FROM_THUMB_TO_ARM +#ifdef __thumb__ +.align 2 + bx pc +.arm +#endif /* __thumb__ */ +.endm + +.macro SWITCH_FROM_ARM_TO_THUMB REG +#ifdef __thumb__ + add \REG, pc, #1 + bx \REG +.thumb +#endif /* __thumb__ */ +.endm + +.macro SWITCH_FROM_THUMB_2_TO_ARM +#ifdef __thumb2__ +.align 2 + bx pc +.arm +#endif /* __thumb__ */ +.endm + +.macro SWITCH_FROM_ARM_TO_THUMB_2 REG +#ifdef __thumb2__ + add \REG, pc, #1 + bx \REG +.thumb +#endif /* __thumb__ */ +.endm + +.macro BLX_TO_THUMB_1 TARGET +#if defined(__thumb__) && !defined(__thumb2__) + add lr, pc, #1 + bx lr +.thumb + bl \TARGET +.align 2 + bx pc +.arm +#else + bl \TARGET +#endif +.endm + +.macro GET_SELF_CPU_CONTROL REG +#ifdef RTEMS_SMP + /* Use PL1 only Thread ID Register (TPIDRPRW) */ + mrc p15, 0, \REG, c13, c0, 4 +#else + ldr \REG, =_Per_CPU_Information +#endif +.endm + +/** @} */ + +#endif /* _RTEMS_ASM_H */ diff --git a/cpukit/score/cpu/arm/include/rtems/score/arm.h b/cpukit/score/cpu/arm/include/rtems/score/arm.h new file mode 100755 index 0000000000..f08da1dc57 --- /dev/null +++ b/cpukit/score/cpu/arm/include/rtems/score/arm.h @@ -0,0 +1,94 @@ +/** + * @file + * + * @brief ARM Assembler Support API + */ + +/* + * COPYRIGHT (c) 2000 Canon Research Centre France SA. + * Emmanuel Raguet, mailto:raguet@crf.canon.fr + * + * Copyright (c) 2002 Advent Networks, Inc. + * Jay Monkman + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + */ + +#ifndef _RTEMS_SCORE_ARM_H +#define _RTEMS_SCORE_ARM_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup ScoreCPU + */ +/**@{**/ + +#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) + #define CPU_MODEL_NAME "ARMv7M" + #define ARM_MULTILIB_ARCH_V7M +#elif defined(__ARM_ARCH_6M__) + #define CPU_MODEL_NAME "ARMv6M" + #define ARM_MULTILIB_ARCH_V6M +#else + #define CPU_MODEL_NAME "ARMv4" + #define ARM_MULTILIB_ARCH_V4 +#endif + +#if defined(__ARM_ARCH_7A__) \ + || defined(__ARM_ARCH_7R__) \ + || defined(__ARM_ARCH_7M__) \ + || defined(__ARM_ARCH_7EM__) + #define ARM_MULTILIB_HAS_WFI + #define ARM_MULTILIB_HAS_LOAD_STORE_EXCLUSIVE + #define ARM_MULTILIB_HAS_BARRIER_INSTRUCTIONS +#endif + +#if defined(__ARM_ARCH_7A__) \ + || defined(__ARM_ARCH_7R__) + #define ARM_MULTILIB_HAS_THREAD_ID_REGISTER +#endif + +#if defined(__ARM_ARCH_7A__) + #define ARM_MULTILIB_CACHE_LINE_MAX_64 +#endif + +#if defined(__ARM_ARCH_7A__) \ + || defined(__ARM_ARCH_7M__) \ + || defined(__ARM_ARCH_7EM__) + #define ARM_MULTILIB_HAS_CPACR +#endif + +#if !defined(__SOFTFP__) + #if defined(__ARM_NEON__) + #define ARM_MULTILIB_VFP_D32 + #elif defined(__VFP_FP__) + #define ARM_MULTILIB_VFP_D16 + #else + #error "FPU support not implemented" + #endif +#endif + +#if defined(ARM_MULTILIB_VFP_D16) \ + || defined(ARM_MULTILIB_VFP_D32) + #define ARM_MULTILIB_VFP +#endif + +/* + * Define the name of the CPU family. + */ + +#define CPU_NAME "ARM" + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_SCORE_ARM_H */ diff --git a/cpukit/score/cpu/arm/include/rtems/score/armv4.h b/cpukit/score/cpu/arm/include/rtems/score/armv4.h new file mode 100644 index 0000000000..caeaa3e553 --- /dev/null +++ b/cpukit/score/cpu/arm/include/rtems/score/armv4.h @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2013 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef RTEMS_SCORE_ARMV4_H +#define RTEMS_SCORE_ARMV4_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#ifdef ARM_MULTILIB_ARCH_V4 + +void bsp_interrupt_dispatch( void ); + +void _ARMV4_Exception_interrupt( void ); + +typedef void ARMV4_Exception_abort_handler( CPU_Exception_frame *frame ); + +void _ARMV4_Exception_data_abort_set_handler( + ARMV4_Exception_abort_handler handler +); + +void _ARMV4_Exception_data_abort( void ); + +void _ARMV4_Exception_prefetch_abort_set_handler( + ARMV4_Exception_abort_handler handler +); + +void _ARMV4_Exception_prefetch_abort( void ); + +void _ARMV4_Exception_undef_default( void ); + +void _ARMV4_Exception_swi_default( void ); + +void _ARMV4_Exception_data_abort_default( void ); + +void _ARMV4_Exception_pref_abort_default( void ); + +void _ARMV4_Exception_reserved_default( void ); + +void _ARMV4_Exception_irq_default( void ); + +void _ARMV4_Exception_fiq_default( void ); + +static inline uint32_t _ARMV4_Status_irq_enable( void ) +{ + uint32_t arm_switch_reg; + uint32_t psr; + + RTEMS_COMPILER_MEMORY_BARRIER(); + + __asm__ volatile ( + ARM_SWITCH_TO_ARM + "mrs %[psr], cpsr\n" + "bic %[arm_switch_reg], %[psr], #0x80\n" + "msr cpsr, %[arm_switch_reg]\n" + ARM_SWITCH_BACK + : [arm_switch_reg] "=&r" (arm_switch_reg), [psr] "=&r" (psr) + ); + + return psr; +} + +static inline void _ARMV4_Status_restore( uint32_t psr ) +{ + ARM_SWITCH_REGISTERS; + + __asm__ volatile ( + ARM_SWITCH_TO_ARM + "msr cpsr, %[psr]\n" + ARM_SWITCH_BACK + : ARM_SWITCH_OUTPUT + : [psr] "r" (psr) + ); + + RTEMS_COMPILER_MEMORY_BARRIER(); +} + +#endif /* ARM_MULTILIB_ARCH_V4 */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RTEMS_SCORE_ARMV4_H */ diff --git a/cpukit/score/cpu/arm/include/rtems/score/armv7m.h b/cpukit/score/cpu/arm/include/rtems/score/armv7m.h new file mode 100644 index 0000000000..a6cc8a34ac --- /dev/null +++ b/cpukit/score/cpu/arm/include/rtems/score/armv7m.h @@ -0,0 +1,620 @@ +/** + * @file + * + * @brief ARMV7M Architecture Support + */ + +/* + * Copyright (c) 2011-2014 Sebastian Huber. All rights reserved. + * + * embedded brains GmbH + * Obere Lagerstr. 30 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef RTEMS_SCORE_ARMV7M_H +#define RTEMS_SCORE_ARMV7M_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#ifdef ARM_MULTILIB_ARCH_V7M + +/* Coprocessor Access Control Register, CPACR */ +#define ARMV7M_CPACR 0xe000ed88 + +#ifndef ASM + +typedef struct { + uint32_t reserved_0; + uint32_t ictr; + uint32_t actlr; + uint32_t reserved_1; +} ARMV7M_ICTAC; + +typedef void (*ARMV7M_Exception_handler)(void); + +typedef struct { + uint32_t register_r0; + uint32_t register_r1; + uint32_t register_r2; + uint32_t register_r3; + uint32_t register_r12; + void *register_lr; + void *register_pc; + uint32_t register_xpsr; +#ifdef ARM_MULTILIB_VFP + uint32_t register_s0; + uint32_t register_s1; + uint32_t register_s2; + uint32_t register_s3; + uint32_t register_s4; + uint32_t register_s5; + uint32_t register_s6; + uint32_t register_s7; + uint32_t register_s8; + uint32_t register_s9; + uint32_t register_s10; + uint32_t register_s11; + uint32_t register_s12; + uint32_t register_s13; + uint32_t register_s14; + uint32_t register_s15; + uint32_t register_fpscr; + uint32_t reserved; +#endif +} ARMV7M_Exception_frame; + +typedef struct { + uint32_t comp; + uint32_t mask; + uint32_t function; + uint32_t reserved; +} ARMV7M_DWT_comparator; + +typedef struct { +#define ARMV7M_DWT_CTRL_NOCYCCNT (1U << 25) +#define ARMV7M_DWT_CTRL_CYCCNTENA (1U << 0) + uint32_t ctrl; + uint32_t cyccnt; + uint32_t cpicnt; + uint32_t exccnt; + uint32_t sleepcnt; + uint32_t lsucnt; + uint32_t foldcnt; + uint32_t pcsr; + ARMV7M_DWT_comparator comparator[249]; +#define ARMV7M_DWT_LAR_UNLOCK_MAGIC 0xc5acce55U + uint32_t lar; + uint32_t lsr; +} ARMV7M_DWT; + +typedef struct { + uint32_t cpuid; + +#define ARMV7M_SCB_ICSR_NMIPENDSET (1U << 31) +#define ARMV7M_SCB_ICSR_PENDSVSET (1U << 28) +#define ARMV7M_SCB_ICSR_PENDSVCLR (1U << 27) +#define ARMV7M_SCB_ICSR_PENDSTSET (1U << 26) +#define ARMV7M_SCB_ICSR_PENDSTCLR (1U << 25) +#define ARMV7M_SCB_ICSR_ISRPREEMPT (1U << 23) +#define ARMV7M_SCB_ICSR_ISRPENDING (1U << 22) +#define ARMV7M_SCB_ICSR_VECTPENDING_GET(reg) (((reg) >> 12) & 0x1ffU) +#define ARMV7M_SCB_ICSR_RETTOBASE (1U << 11) +#define ARMV7M_SCB_ICSR_VECTACTIVE_GET(reg) ((reg) & 0x1ffU) + uint32_t icsr; + + ARMV7M_Exception_handler *vtor; + +#define ARMV7M_SCB_AIRCR_VECTKEY (0x05fa << 16) +#define ARMV7M_SCB_AIRCR_ENDIANESS (1U << 15) +#define ARMV7M_SCB_AIRCR_PRIGROUP_SHIFT 8 +#define ARMV7M_SCB_AIRCR_PRIGROUP_MASK \ + ((0x7U) << ARMV7M_SCB_AIRCR_PRIGROUP_SHIFT) +#define ARMV7M_SCB_AIRCR_PRIGROUP(val) \ + (((val) << ARMV7M_SCB_AIRCR_PRIGROUP_SHIFT) & ARMV7M_SCB_AIRCR_PRIGROUP_MASK) +#define ARMV7M_SCB_AIRCR_PRIGROUP_GET(reg) \ + (((val) & ARMV7M_SCB_AIRCR_PRIGROUP_MASK) >> ARMV7M_SCB_AIRCR_PRIGROUP_SHIFT) +#define ARMV7M_SCB_AIRCR_PRIGROUP_SET(reg, val) \ + (((reg) & ~ARMV7M_SCB_AIRCR_PRIGROUP_MASK) | ARMV7M_SCB_AIRCR_PRIGROUP(val)) +#define ARMV7M_SCB_AIRCR_SYSRESETREQ (1U << 2) +#define ARMV7M_SCB_AIRCR_VECTCLRACTIVE (1U << 1) +#define ARMV7M_SCB_AIRCR_VECTRESET (1U << 0) + uint32_t aircr; + + uint32_t scr; + uint32_t ccr; + uint8_t shpr [12]; + +#define ARMV7M_SCB_SHCSR_USGFAULTENA (1U << 18) +#define ARMV7M_SCB_SHCSR_BUSFAULTENA (1U << 17) +#define ARMV7M_SCB_SHCSR_MEMFAULTENA (1U << 16) + uint32_t shcsr; + + uint32_t cfsr; + uint32_t hfsr; + uint32_t dfsr; + uint32_t mmfar; + uint32_t bfar; + uint32_t afsr; + uint32_t reserved_e000ed40[18]; + uint32_t cpacr; + uint32_t reserved_e000ed8c[106]; + uint32_t fpccr; + uint32_t fpcar; + uint32_t fpdscr; + uint32_t mvfr0; + uint32_t mvfr1; +} ARMV7M_SCB; + +typedef struct { +#define ARMV7M_SYSTICK_CSR_COUNTFLAG (1U << 16) +#define ARMV7M_SYSTICK_CSR_CLKSOURCE (1U << 2) +#define ARMV7M_SYSTICK_CSR_TICKINT (1U << 1) +#define ARMV7M_SYSTICK_CSR_ENABLE (1U << 0) + uint32_t csr; + + uint32_t rvr; + uint32_t cvr; + +#define ARMV7M_SYSTICK_CALIB_NOREF (1U << 31) +#define ARMV7M_SYSTICK_CALIB_SKEW (1U << 30) +#define ARMV7M_SYSTICK_CALIB_TENMS_GET(reg) ((reg) & 0xffffffU) + uint32_t calib; +} ARMV7M_Systick; + +typedef struct { + uint32_t iser [8]; + uint32_t reserved_0 [24]; + uint32_t icer [8]; + uint32_t reserved_1 [24]; + uint32_t ispr [8]; + uint32_t reserved_2 [24]; + uint32_t icpr [8]; + uint32_t reserved_3 [24]; + uint32_t iabr [8]; + uint32_t reserved_4 [56]; + uint8_t ipr [240]; + uint32_t reserved_5 [644]; + uint32_t stir; +} ARMV7M_NVIC; + +typedef struct { +#define ARMV7M_MPU_TYPE_IREGION_GET(reg) (((reg) >> 16) & 0xffU) +#define ARMV7M_MPU_TYPE_DREGION_GET(reg) (((reg) >> 8) & 0xffU) +#define ARMV7M_MPU_TYPE_SEPARATE (1U << 0) + uint32_t type; + +#define ARMV7M_MPU_CTRL_PRIVDEFENA (1U << 2) +#define ARMV7M_MPU_CTRL_HFNMIENA (1U << 1) +#define ARMV7M_MPU_CTRL_ENABLE (1U << 0) + uint32_t ctrl; + + uint32_t rnr; + +#define ARMV7M_MPU_RBAR_ADDR_SHIFT 5 +#define ARMV7M_MPU_RBAR_ADDR_MASK \ + ((0x7ffffffU) << ARMV7M_MPU_RBAR_ADDR_SHIFT) +#define ARMV7M_MPU_RBAR_ADDR(val) \ + (((val) << ARMV7M_MPU_RBAR_ADDR_SHIFT) & ARMV7M_MPU_RBAR_ADDR_MASK) +#define ARMV7M_MPU_RBAR_ADDR_GET(reg) \ + (((val) & ARMV7M_MPU_RBAR_ADDR_MASK) >> ARMV7M_MPU_RBAR_ADDR_SHIFT) +#define ARMV7M_MPU_RBAR_ADDR_SET(reg, val) \ + (((reg) & ~ARMV7M_MPU_RBAR_ADDR_MASK) | ARMV7M_MPU_RBAR_ADDR(val)) +#define ARMV7M_MPU_RBAR_VALID (1U << 4) +#define ARMV7M_MPU_RBAR_REGION_SHIFT 0 +#define ARMV7M_MPU_RBAR_REGION_MASK \ + ((0xfU) << ARMV7M_MPU_RBAR_REGION_SHIFT) +#define ARMV7M_MPU_RBAR_REGION(val) \ + (((val) << ARMV7M_MPU_RBAR_REGION_SHIFT) & ARMV7M_MPU_RBAR_REGION_MASK) +#define ARMV7M_MPU_RBAR_REGION_GET(reg) \ + (((val) & ARMV7M_MPU_RBAR_REGION_MASK) >> ARMV7M_MPU_RBAR_REGION_SHIFT) +#define ARMV7M_MPU_RBAR_REGION_SET(reg, val) \ + (((reg) & ~ARMV7M_MPU_RBAR_REGION_MASK) | ARMV7M_MPU_RBAR_REGION(val)) + uint32_t rbar; + +#define ARMV7M_MPU_RASR_XN (1U << 28) +#define ARMV7M_MPU_RASR_AP_SHIFT 24 +#define ARMV7M_MPU_RASR_AP_MASK \ + ((0x7U) << ARMV7M_MPU_RASR_AP_SHIFT) +#define ARMV7M_MPU_RASR_AP(val) \ + (((val) << ARMV7M_MPU_RASR_AP_SHIFT) & ARMV7M_MPU_RASR_AP_MASK) +#define ARMV7M_MPU_RASR_AP_GET(reg) \ + (((val) & ARMV7M_MPU_RASR_AP_MASK) >> ARMV7M_MPU_RASR_AP_SHIFT) +#define ARMV7M_MPU_RASR_AP_SET(reg, val) \ + (((reg) & ~ARMV7M_MPU_RASR_AP_MASK) | ARMV7M_MPU_RASR_AP(val)) +#define ARMV7M_MPU_RASR_TEX_SHIFT 19 +#define ARMV7M_MPU_RASR_TEX_MASK \ + ((0x7U) << ARMV7M_MPU_RASR_TEX_SHIFT) +#define ARMV7M_MPU_RASR_TEX(val) \ + (((val) << ARMV7M_MPU_RASR_TEX_SHIFT) & ARMV7M_MPU_RASR_TEX_MASK) +#define ARMV7M_MPU_RASR_TEX_GET(reg) \ + (((val) & ARMV7M_MPU_RASR_TEX_MASK) >> ARMV7M_MPU_RASR_TEX_SHIFT) +#define ARMV7M_MPU_RASR_TEX_SET(reg, val) \ + (((reg) & ~ARMV7M_MPU_RASR_TEX_MASK) | ARMV7M_MPU_RASR_TEX(val)) +#define ARMV7M_MPU_RASR_S (1U << 18) +#define ARMV7M_MPU_RASR_C (1U << 17) +#define ARMV7M_MPU_RASR_B (1U << 16) +#define ARMV7M_MPU_RASR_SRD_SHIFT 8 +#define ARMV7M_MPU_RASR_SRD_MASK \ + ((0xffU) << ARMV7M_MPU_RASR_SRD_SHIFT) +#define ARMV7M_MPU_RASR_SRD(val) \ + (((val) << ARMV7M_MPU_RASR_SRD_SHIFT) & ARMV7M_MPU_RASR_SRD_MASK) +#define ARMV7M_MPU_RASR_SRD_GET(reg) \ + (((val) & ARMV7M_MPU_RASR_SRD_MASK) >> ARMV7M_MPU_RASR_SRD_SHIFT) +#define ARMV7M_MPU_RASR_SRD_SET(reg, val) \ + (((reg) & ~ARMV7M_MPU_RASR_SRD_MASK) | ARMV7M_MPU_RASR_SRD(val)) +#define ARMV7M_MPU_RASR_SIZE_SHIFT 1 +#define ARMV7M_MPU_RASR_SIZE_MASK \ + ((0x1fU) << ARMV7M_MPU_RASR_SIZE_SHIFT) +#define ARMV7M_MPU_RASR_SIZE(val) \ + (((val) << ARMV7M_MPU_RASR_SIZE_SHIFT) & ARMV7M_MPU_RASR_SIZE_MASK) +#define ARMV7M_MPU_RASR_SIZE_GET(reg) \ + (((val) & ARMV7M_MPU_RASR_SIZE_MASK) >> ARMV7M_MPU_RASR_SIZE_SHIFT) +#define ARMV7M_MPU_RASR_SIZE_SET(reg, val) \ + (((reg) & ~ARMV7M_MPU_RASR_SIZE_MASK) | ARMV7M_MPU_RASR_SIZE(val)) +#define ARMV7M_MPU_RASR_ENABLE (1U << 0) + uint32_t rasr; + + uint32_t rbar_a1; + uint32_t rasr_a1; + uint32_t rbar_a2; + uint32_t rasr_a2; + uint32_t rbar_a3; + uint32_t rasr_a3; +} ARMV7M_MPU; + +typedef enum { + ARMV7M_MPU_AP_PRIV_NO_USER_NO, + ARMV7M_MPU_AP_PRIV_RW_USER_NO, + ARMV7M_MPU_AP_PRIV_RW_USER_RO, + ARMV7M_MPU_AP_PRIV_RW_USER_RW, + ARMV7M_MPU_AP_PRIV_RO_USER_NO = 0x5, + ARMV7M_MPU_AP_PRIV_RO_USER_RO, +} ARMV7M_MPU_Access_permissions; + +typedef enum { + ARMV7M_MPU_ATTR_R = ARMV7M_MPU_RASR_AP(ARMV7M_MPU_AP_PRIV_RO_USER_NO) + | ARMV7M_MPU_RASR_C | ARMV7M_MPU_RASR_XN, + ARMV7M_MPU_ATTR_RW = ARMV7M_MPU_RASR_AP(ARMV7M_MPU_AP_PRIV_RW_USER_NO) + | ARMV7M_MPU_RASR_C | ARMV7M_MPU_RASR_XN | ARMV7M_MPU_RASR_B, + ARMV7M_MPU_ATTR_RWX = ARMV7M_MPU_RASR_AP(ARMV7M_MPU_AP_PRIV_RW_USER_NO) + | ARMV7M_MPU_RASR_C | ARMV7M_MPU_RASR_B, + ARMV7M_MPU_ATTR_X = ARMV7M_MPU_RASR_AP(ARMV7M_MPU_AP_PRIV_NO_USER_NO) + | ARMV7M_MPU_RASR_C, + ARMV7M_MPU_ATTR_RX = ARMV7M_MPU_RASR_AP(ARMV7M_MPU_AP_PRIV_RO_USER_NO) + | ARMV7M_MPU_RASR_C, + ARMV7M_MPU_ATTR_IO = ARMV7M_MPU_RASR_AP(ARMV7M_MPU_AP_PRIV_RW_USER_NO) + | ARMV7M_MPU_RASR_XN, +} ARMV7M_MPU_Attributes; + +typedef enum { + ARMV7M_MPU_SIZE_32_B = 0x4, + ARMV7M_MPU_SIZE_64_B, + ARMV7M_MPU_SIZE_128_B, + ARMV7M_MPU_SIZE_256_B, + ARMV7M_MPU_SIZE_512_B, + ARMV7M_MPU_SIZE_1_KB, + ARMV7M_MPU_SIZE_2_KB, + ARMV7M_MPU_SIZE_4_KB, + ARMV7M_MPU_SIZE_8_KB, + ARMV7M_MPU_SIZE_16_KB, + ARMV7M_MPU_SIZE_32_KB, + ARMV7M_MPU_SIZE_64_KB, + ARMV7M_MPU_SIZE_128_KB, + ARMV7M_MPU_SIZE_256_KB, + ARMV7M_MPU_SIZE_512_KB, + ARMV7M_MPU_SIZE_1_MB, + ARMV7M_MPU_SIZE_2_MB, + ARMV7M_MPU_SIZE_4_MB, + ARMV7M_MPU_SIZE_8_MB, + ARMV7M_MPU_SIZE_16_MB, + ARMV7M_MPU_SIZE_32_MB, + ARMV7M_MPU_SIZE_64_MB, + ARMV7M_MPU_SIZE_128_MB, + ARMV7M_MPU_SIZE_256_MB, + ARMV7M_MPU_SIZE_512_MB, + ARMV7M_MPU_SIZE_1_GB, + ARMV7M_MPU_SIZE_2_GB, + ARMV7M_MPU_SIZE_4_GB +} ARMV7M_MPU_Size; + +typedef struct { + uint32_t rbar; + uint32_t rasr; +} ARMV7M_MPU_Region; + +#define ARMV7M_MPU_REGION_INITIALIZER(idx, addr, size, attr) \ + { \ + ((addr) & ARMV7M_MPU_RBAR_ADDR_MASK) \ + | ARMV7M_MPU_RBAR_VALID \ + | ARMV7M_MPU_RBAR_REGION(idx), \ + ARMV7M_MPU_RASR_SIZE(size) | (attr) | ARMV7M_MPU_RASR_ENABLE \ + } + +#define ARMV7M_MPU_REGION_DISABLED_INITIALIZER(idx) \ + { \ + ARMV7M_MPU_RBAR_VALID | ARMV7M_MPU_RBAR_REGION(idx), \ + 0 \ + } + +typedef struct { + uint32_t dhcsr; + uint32_t dcrsr; + uint32_t dcrdr; +#define ARMV7M_DEBUG_DEMCR_VC_CORERESET (1U << 0) +#define ARMV7M_DEBUG_DEMCR_VC_MMERR (1U << 4) +#define ARMV7M_DEBUG_DEMCR_VC_NOCPERR (1U << 5) +#define ARMV7M_DEBUG_DEMCR_VC_CHKERR (1U << 6) +#define ARMV7M_DEBUG_DEMCR_VC_STATERR (1U << 7) +#define ARMV7M_DEBUG_DEMCR_VC_BUSERR (1U << 8) +#define ARMV7M_DEBUG_DEMCR_VC_INTERR (1U << 9) +#define ARMV7M_DEBUG_DEMCR_VC_HARDERR (1U << 10) +#define ARMV7M_DEBUG_DEMCR_MON_EN (1U << 16) +#define ARMV7M_DEBUG_DEMCR_MON_PEND (1U << 17) +#define ARMV7M_DEBUG_DEMCR_MON_STEP (1U << 18) +#define ARMV7M_DEBUG_DEMCR_MON_REQ (1U << 19) +#define ARMV7M_DEBUG_DEMCR_TRCENA (1U << 24) + uint32_t demcr; +} ARMV7M_DEBUG; + +#define ARMV7M_DWT_BASE 0xe0001000 +#define ARMV7M_SCS_BASE 0xe000e000 +#define ARMV7M_ICTAC_BASE (ARMV7M_SCS_BASE + 0x0) +#define ARMV7M_SYSTICK_BASE (ARMV7M_SCS_BASE + 0x10) +#define ARMV7M_NVIC_BASE (ARMV7M_SCS_BASE + 0x100) +#define ARMV7M_SCB_BASE (ARMV7M_SCS_BASE + 0xd00) +#define ARMV7M_MPU_BASE (ARMV7M_SCS_BASE + 0xd90) +#define ARMV7M_DEBUG_BASE (ARMV7M_SCS_BASE + 0xdf0) + +#define _ARMV7M_DWT \ + ((volatile ARMV7M_DWT *) ARMV7M_DWT_BASE) +#define _ARMV7M_ICTAC \ + ((volatile ARMV7M_ICTAC *) ARMV7M_ICTAC_BASE) +#define _ARMV7M_SCB \ + ((volatile ARMV7M_SCB *) ARMV7M_SCB_BASE) +#define _ARMV7M_Systick \ + ((volatile ARMV7M_Systick *) ARMV7M_SYSTICK_BASE) +#define _ARMV7M_NVIC \ + ((volatile ARMV7M_NVIC *) ARMV7M_NVIC_BASE) +#define _ARMV7M_MPU \ + ((volatile ARMV7M_MPU *) ARMV7M_MPU_BASE) +#define _ARMV7M_DEBUG \ + ((volatile ARMV7M_DEBUG *) ARMV7M_DEBUG_BASE) + +#define ARMV7M_VECTOR_MSP 0 +#define ARMV7M_VECTOR_RESET 1 +#define ARMV7M_VECTOR_NMI 2 +#define ARMV7M_VECTOR_HARD_FAULT 3 +#define ARMV7M_VECTOR_MEM_MANAGE 4 +#define ARMV7M_VECTOR_BUS_FAULT 5 +#define ARMV7M_VECTOR_USAGE_FAULT 6 +#define ARMV7M_VECTOR_SVC 11 +#define ARMV7M_VECTOR_DEBUG_MONITOR 12 +#define ARMV7M_VECTOR_PENDSV 14 +#define ARMV7M_VECTOR_SYSTICK 15 +#define ARMV7M_VECTOR_IRQ(n) ((n) + 16) +#define ARMV7M_IRQ_OF_VECTOR(n) ((n) - 16) + +#define ARMV7M_EXCEPTION_PRIORITY_LOWEST 255 + +static inline bool _ARMV7M_Is_vector_an_irq( int vector ) +{ + /* External (i.e. non-system) IRQs start after the SysTick vector. */ + return vector > ARMV7M_VECTOR_SYSTICK; +} + +static inline uint32_t _ARMV7M_Get_basepri(void) +{ + uint32_t val; + __asm__ volatile ("mrs %[val], basepri\n" : [val] "=&r" (val)); + return val; +} + +static inline void _ARMV7M_Set_basepri(uint32_t val) +{ + __asm__ volatile ("msr basepri, %[val]\n" : : [val] "r" (val)); +} + +static inline uint32_t _ARMV7M_Get_primask(void) +{ + uint32_t val; + __asm__ volatile ("mrs %[val], primask\n" : [val] "=&r" (val)); + return val; +} + +static inline void _ARMV7M_Set_primask(uint32_t val) +{ + __asm__ volatile ("msr primask, %[val]\n" : : [val] "r" (val)); +} + +static inline uint32_t _ARMV7M_Get_faultmask(void) +{ + uint32_t val; + __asm__ volatile ("mrs %[val], faultmask\n" : [val] "=&r" (val)); + return val; +} + +static inline void _ARMV7M_Set_faultmask(uint32_t val) +{ + __asm__ volatile ("msr faultmask, %[val]\n" : : [val] "r" (val)); +} + +static inline uint32_t _ARMV7M_Get_control(void) +{ + uint32_t val; + __asm__ volatile ("mrs %[val], control\n" : [val] "=&r" (val)); + return val; +} + +static inline void _ARMV7M_Set_control(uint32_t val) +{ + __asm__ volatile ("msr control, %[val]\n" : : [val] "r" (val)); +} + +static inline uint32_t _ARMV7M_Get_MSP(void) +{ + uint32_t val; + __asm__ volatile ("mrs %[val], msp\n" : [val] "=&r" (val)); + return val; +} + +static inline void _ARMV7M_Set_MSP(uint32_t val) +{ + __asm__ volatile ("msr msp, %[val]\n" : : [val] "r" (val)); +} + +static inline uint32_t _ARMV7M_Get_PSP(void) +{ + uint32_t val; + __asm__ volatile ("mrs %[val], psp\n" : [val] "=&r" (val)); + return val; +} + +static inline void _ARMV7M_Set_PSP(uint32_t val) +{ + __asm__ volatile ("msr psp, %[val]\n" : : [val] "r" (val)); +} + +static inline uint32_t _ARMV7M_Get_XPSR(void) +{ + uint32_t val; + __asm__ volatile ("mrs %[val], xpsr\n" : [val] "=&r" (val)); + return val; +} + +static inline bool _ARMV7M_NVIC_Is_enabled( int irq ) +{ + int index = irq >> 5; + uint32_t bit = 1U << (irq & 0x1f); + + return (_ARMV7M_NVIC->iser [index] & bit) != 0; +} + +static inline void _ARMV7M_NVIC_Set_enable( int irq ) +{ + int index = irq >> 5; + uint32_t bit = 1U << (irq & 0x1f); + + _ARMV7M_NVIC->iser [index] = bit; +} + +static inline void _ARMV7M_NVIC_Clear_enable( int irq ) +{ + int index = irq >> 5; + uint32_t bit = 1U << (irq & 0x1f); + + _ARMV7M_NVIC->icer [index] = bit; +} + +static inline bool _ARMV7M_NVIC_Is_pending( int irq ) +{ + int index = irq >> 5; + uint32_t bit = 1U << (irq & 0x1f); + + return (_ARMV7M_NVIC->ispr [index] & bit) != 0; +} + +static inline void _ARMV7M_NVIC_Set_pending( int irq ) +{ + int index = irq >> 5; + uint32_t bit = 1U << (irq & 0x1f); + + _ARMV7M_NVIC->ispr [index] = bit; +} + +static inline void _ARMV7M_NVIC_Clear_pending( int irq ) +{ + int index = irq >> 5; + uint32_t bit = 1U << (irq & 0x1f); + + _ARMV7M_NVIC->icpr [index] = bit; +} + +static inline bool _ARMV7M_NVIC_Is_active( int irq ) +{ + int index = irq >> 5; + uint32_t bit = 1U << (irq & 0x1f); + + return (_ARMV7M_NVIC->iabr [index] & bit) != 0; +} + +static inline void _ARMV7M_NVIC_Set_priority( int irq, int priority ) +{ + _ARMV7M_NVIC->ipr [irq] = (uint8_t) priority; +} + +static inline int _ARMV7M_NVIC_Get_priority( int irq ) +{ + return _ARMV7M_NVIC->ipr [irq]; +} + +static inline bool _ARMV7M_DWT_Enable_CYCCNT( void ) +{ + uint32_t demcr; + uint32_t dwt_ctrl; + + demcr = _ARMV7M_DEBUG->demcr; + _ARMV7M_DEBUG->demcr = demcr | ARMV7M_DEBUG_DEMCR_TRCENA; + _ARM_Data_synchronization_barrier(); + + dwt_ctrl = _ARMV7M_DWT->ctrl; + if ((dwt_ctrl & ARMV7M_DWT_CTRL_NOCYCCNT) == 0) { + _ARMV7M_DWT->lar = ARMV7M_DWT_LAR_UNLOCK_MAGIC; + _ARM_Data_synchronization_barrier(); + _ARMV7M_DWT->ctrl = dwt_ctrl | ARMV7M_DWT_CTRL_CYCCNTENA; + return true; + } else { + _ARMV7M_DEBUG->demcr = demcr; + return false; + } +} + +int _ARMV7M_Get_exception_priority( int vector ); + +void _ARMV7M_Set_exception_priority( int vector, int priority ); + +ARMV7M_Exception_handler _ARMV7M_Get_exception_handler( int index ); + +void _ARMV7M_Set_exception_handler( + int index, + ARMV7M_Exception_handler handler +); + +/** + * @brief ARMV7M set exception priority and handler. + */ +void _ARMV7M_Set_exception_priority_and_handler( + int index, + int priority, + ARMV7M_Exception_handler handler +); + +void _ARMV7M_Exception_default( void ); + +void _ARMV7M_Interrupt_service_enter( void ); + +void _ARMV7M_Interrupt_service_leave( void ); + +void _ARMV7M_Pendable_service_call( void ); + +void _ARMV7M_Supervisor_call( void ); + +#endif /* ASM */ + +#endif /* ARM_MULTILIB_ARCH_V7M */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RTEMS_SCORE_ARMV7M_H */ diff --git a/cpukit/score/cpu/arm/include/rtems/score/cpu.h b/cpukit/score/cpu/arm/include/rtems/score/cpu.h new file mode 100644 index 0000000000..05e236c75a --- /dev/null +++ b/cpukit/score/cpu/arm/include/rtems/score/cpu.h @@ -0,0 +1,702 @@ +/** + * @file + * + * @brief ARM Architecture Support API + */ + +/* + * This include file contains information pertaining to the ARM + * processor. + * + * Copyright (c) 2009, 2017 embedded brains GmbH + * + * Copyright (c) 2007 Ray Xu + * + * Copyright (c) 2006 OAR Corporation + * + * Copyright (c) 2002 Advent Networks, Inc. + * Jay Monkman + * + * COPYRIGHT (c) 2000 Canon Research Centre France SA. + * Emmanuel Raguet, mailto:raguet@crf.canon.fr + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + */ + +#ifndef _RTEMS_SCORE_CPU_H +#define _RTEMS_SCORE_CPU_H + +#include +#include + +#if defined(ARM_MULTILIB_ARCH_V4) + +/** + * @defgroup ScoreCPUARM ARM Specific Support + * + * @ingroup ScoreCPU + * + * @brief ARM specific support. + */ +/**@{**/ + +#if defined(__thumb__) && !defined(__thumb2__) + #define ARM_SWITCH_REGISTERS uint32_t arm_switch_reg + #define ARM_SWITCH_TO_ARM ".align 2\nbx pc\n.arm\n" + #define ARM_SWITCH_BACK "add %[arm_switch_reg], pc, #1\nbx %[arm_switch_reg]\n.thumb\n" + #define ARM_SWITCH_OUTPUT [arm_switch_reg] "=&r" (arm_switch_reg) + #define ARM_SWITCH_ADDITIONAL_OUTPUT , ARM_SWITCH_OUTPUT +#else + #define ARM_SWITCH_REGISTERS + #define ARM_SWITCH_TO_ARM + #define ARM_SWITCH_BACK + #define ARM_SWITCH_OUTPUT + #define ARM_SWITCH_ADDITIONAL_OUTPUT +#endif + +/** + * @name Program Status Register + */ +/**@{**/ + +#define ARM_PSR_N (1 << 31) +#define ARM_PSR_Z (1 << 30) +#define ARM_PSR_C (1 << 29) +#define ARM_PSR_V (1 << 28) +#define ARM_PSR_Q (1 << 27) +#define ARM_PSR_J (1 << 24) +#define ARM_PSR_GE_SHIFT 16 +#define ARM_PSR_GE_MASK (0xf << ARM_PSR_GE_SHIFT) +#define ARM_PSR_E (1 << 9) +#define ARM_PSR_A (1 << 8) +#define ARM_PSR_I (1 << 7) +#define ARM_PSR_F (1 << 6) +#define ARM_PSR_T (1 << 5) +#define ARM_PSR_M_SHIFT 0 +#define ARM_PSR_M_MASK (0x1f << ARM_PSR_M_SHIFT) +#define ARM_PSR_M_USR 0x10 +#define ARM_PSR_M_FIQ 0x11 +#define ARM_PSR_M_IRQ 0x12 +#define ARM_PSR_M_SVC 0x13 +#define ARM_PSR_M_ABT 0x17 +#define ARM_PSR_M_HYP 0x1a +#define ARM_PSR_M_UND 0x1b +#define ARM_PSR_M_SYS 0x1f + +/** @} */ + +/** @} */ + +#endif /* defined(ARM_MULTILIB_ARCH_V4) */ + +/** + * @addtogroup ScoreCPU + */ +/**@{**/ + +/* + * The ARM uses the PIC interrupt model. + */ +#define CPU_SIMPLE_VECTORED_INTERRUPTS FALSE + +#define CPU_HAS_SOFTWARE_INTERRUPT_STACK FALSE + +#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE + +#define CPU_ALLOCATE_INTERRUPT_STACK FALSE + +#define CPU_ISR_PASSES_FRAME_POINTER FALSE + +#define CPU_HARDWARE_FP FALSE + +#define CPU_SOFTWARE_FP FALSE + +#define CPU_ALL_TASKS_ARE_FP FALSE + +#define CPU_IDLE_TASK_IS_FP FALSE + +#define CPU_USE_DEFERRED_FP_SWITCH FALSE + +#define CPU_ENABLE_ROBUST_THREAD_DISPATCH TRUE + +#if defined(ARM_MULTILIB_HAS_WFI) + #define CPU_PROVIDES_IDLE_THREAD_BODY TRUE +#else + #define CPU_PROVIDES_IDLE_THREAD_BODY FALSE +#endif + +#define CPU_STACK_GROWS_UP FALSE + +#if defined(ARM_MULTILIB_CACHE_LINE_MAX_64) + #define CPU_CACHE_LINE_BYTES 64 +#else + #define CPU_CACHE_LINE_BYTES 32 +#endif + +#define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES ) + +#define CPU_MODES_INTERRUPT_MASK 0x1 + +#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp ) + +#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0 + +#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE + +#define CPU_STACK_MINIMUM_SIZE (1024 * 4) + +/* AAPCS, section 4.1, Fundamental Data Types */ +#define CPU_SIZEOF_POINTER 4 + +/* AAPCS, section 4.1, Fundamental Data Types */ +#define CPU_ALIGNMENT 8 + +#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT + +/* AAPCS, section 4.3.1, Aggregates */ +#define CPU_PARTITION_ALIGNMENT 4 + +/* AAPCS, section 5.2.1.2, Stack constraints at a public interface */ +#define CPU_STACK_ALIGNMENT 8 + +/* + * Bitfield handler macros. + * + * If we had a particularly fast function for finding the first + * bit set in a word, it would go here. Since we don't (*), we'll + * just use the universal macros. + * + * (*) On ARM V5 and later, there's a CLZ function which could be + * used to implement much quicker than the default macro. + */ + +#define CPU_USE_GENERIC_BITFIELD_CODE TRUE + +#define CPU_MAXIMUM_PROCESSORS 32 + +/** @} */ + +#ifdef ARM_MULTILIB_HAS_THREAD_ID_REGISTER + #define ARM_CONTEXT_CONTROL_THREAD_ID_OFFSET 44 +#endif + +#ifdef ARM_MULTILIB_VFP + #define ARM_CONTEXT_CONTROL_D8_OFFSET 48 +#endif + +#ifdef ARM_MULTILIB_ARCH_V4 + #define ARM_CONTEXT_CONTROL_ISR_DISPATCH_DISABLE 40 +#endif + +#ifdef RTEMS_SMP + #if defined(ARM_MULTILIB_VFP) + #define ARM_CONTEXT_CONTROL_IS_EXECUTING_OFFSET 112 + #elif defined(ARM_MULTILIB_HAS_THREAD_ID_REGISTER) + #define ARM_CONTEXT_CONTROL_IS_EXECUTING_OFFSET 48 + #else + #define ARM_CONTEXT_CONTROL_IS_EXECUTING_OFFSET 44 + #endif +#endif + +#define ARM_EXCEPTION_FRAME_SIZE 80 + +#define ARM_EXCEPTION_FRAME_REGISTER_SP_OFFSET 52 + +#define ARM_EXCEPTION_FRAME_VFP_CONTEXT_OFFSET 72 + +#define ARM_VFP_CONTEXT_SIZE 264 + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup ScoreCPU + */ +/**@{**/ + +typedef struct { +#if defined(ARM_MULTILIB_ARCH_V4) + uint32_t register_r4; + uint32_t register_r5; + uint32_t register_r6; + uint32_t register_r7; + uint32_t register_r8; + uint32_t register_r9; + uint32_t register_r10; + uint32_t register_fp; + uint32_t register_sp; + uint32_t register_lr; + uint32_t isr_dispatch_disable; +#elif defined(ARM_MULTILIB_ARCH_V6M) || defined(ARM_MULTILIB_ARCH_V7M) + uint32_t register_r4; + uint32_t register_r5; + uint32_t register_r6; + uint32_t register_r7; + uint32_t register_r8; + uint32_t register_r9; + uint32_t register_r10; + uint32_t register_r11; + void *register_lr; + void *register_sp; + uint32_t isr_nest_level; +#else + void *register_sp; +#endif +#ifdef ARM_MULTILIB_HAS_THREAD_ID_REGISTER + uint32_t thread_id; +#endif +#ifdef ARM_MULTILIB_VFP + uint64_t register_d8; + uint64_t register_d9; + uint64_t register_d10; + uint64_t register_d11; + uint64_t register_d12; + uint64_t register_d13; + uint64_t register_d14; + uint64_t register_d15; +#endif +#ifdef RTEMS_SMP + volatile bool is_executing; +#endif +} Context_Control; + +typedef struct { + /* Not supported */ +} Context_Control_fp; + +static inline void _ARM_Data_memory_barrier( void ) +{ +#ifdef ARM_MULTILIB_HAS_BARRIER_INSTRUCTIONS + __asm__ volatile ( "dmb" : : : "memory" ); +#else + RTEMS_COMPILER_MEMORY_BARRIER(); +#endif +} + +static inline void _ARM_Data_synchronization_barrier( void ) +{ +#ifdef ARM_MULTILIB_HAS_BARRIER_INSTRUCTIONS + __asm__ volatile ( "dsb" : : : "memory" ); +#else + RTEMS_COMPILER_MEMORY_BARRIER(); +#endif +} + +static inline void _ARM_Instruction_synchronization_barrier( void ) +{ +#ifdef ARM_MULTILIB_HAS_BARRIER_INSTRUCTIONS + __asm__ volatile ( "isb" : : : "memory" ); +#else + RTEMS_COMPILER_MEMORY_BARRIER(); +#endif +} + +static inline uint32_t arm_interrupt_disable( void ) +{ + uint32_t level; + +#if defined(ARM_MULTILIB_ARCH_V4) + uint32_t arm_switch_reg; + + /* + * Disable only normal interrupts (IRQ). + * + * In order to support fast interrupts (FIQ) such that they can do something + * useful, we have to disable the operating system support for FIQs. Having + * operating system support for them would require that FIQs are disabled + * during critical sections of the operating system and application. At this + * level IRQs and FIQs would be equal. It is true that FIQs could interrupt + * the non critical sections of IRQs, so here they would have a small + * advantage. Without operating system support, the FIQs can execute at any + * time (of course not during the service of another FIQ). If someone needs + * operating system support for a FIQ, she can trigger a software interrupt and + * service the request in a two-step process. + */ + __asm__ volatile ( + ARM_SWITCH_TO_ARM + "mrs %[level], cpsr\n" + "orr %[arm_switch_reg], %[level], #0x80\n" + "msr cpsr, %[arm_switch_reg]\n" + ARM_SWITCH_BACK + : [arm_switch_reg] "=&r" (arm_switch_reg), [level] "=&r" (level) + ); +#elif defined(ARM_MULTILIB_ARCH_V7M) + uint32_t basepri = 0x80; + + __asm__ volatile ( + "mrs %[level], basepri\n" + "msr basepri_max, %[basepri]\n" + : [level] "=&r" (level) + : [basepri] "r" (basepri) + ); +#endif + + return level; +} + +static inline void arm_interrupt_enable( uint32_t level ) +{ +#if defined(ARM_MULTILIB_ARCH_V4) + ARM_SWITCH_REGISTERS; + + __asm__ volatile ( + ARM_SWITCH_TO_ARM + "msr cpsr, %[level]\n" + ARM_SWITCH_BACK + : ARM_SWITCH_OUTPUT + : [level] "r" (level) + ); +#elif defined(ARM_MULTILIB_ARCH_V7M) + __asm__ volatile ( + "msr basepri, %[level]\n" + : + : [level] "r" (level) + ); +#endif +} + +static inline void arm_interrupt_flash( uint32_t level ) +{ +#if defined(ARM_MULTILIB_ARCH_V4) + uint32_t arm_switch_reg; + + __asm__ volatile ( + ARM_SWITCH_TO_ARM + "mrs %[arm_switch_reg], cpsr\n" + "msr cpsr, %[level]\n" + "msr cpsr, %[arm_switch_reg]\n" + ARM_SWITCH_BACK + : [arm_switch_reg] "=&r" (arm_switch_reg) + : [level] "r" (level) + ); +#elif defined(ARM_MULTILIB_ARCH_V7M) + uint32_t basepri; + + __asm__ volatile ( + "mrs %[basepri], basepri\n" + "msr basepri, %[level]\n" + "msr basepri, %[basepri]\n" + : [basepri] "=&r" (basepri) + : [level] "r" (level) + ); +#endif +} + +#define _CPU_ISR_Disable( _isr_cookie ) \ + do { \ + _isr_cookie = arm_interrupt_disable(); \ + } while (0) + +#define _CPU_ISR_Enable( _isr_cookie ) \ + arm_interrupt_enable( _isr_cookie ) + +#define _CPU_ISR_Flash( _isr_cookie ) \ + arm_interrupt_flash( _isr_cookie ) + +RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) +{ +#if defined(ARM_MULTILIB_ARCH_V4) + return ( level & 0x80 ) == 0; +#elif defined(ARM_MULTILIB_ARCH_V7M) + return level == 0; +#endif +} + +void _CPU_ISR_Set_level( uint32_t level ); + +uint32_t _CPU_ISR_Get_level( void ); + +void _CPU_Context_Initialize( + Context_Control *the_context, + void *stack_area_begin, + size_t stack_area_size, + uint32_t new_level, + void (*entry_point)( void ), + bool is_fp, + void *tls_area +); + +#define _CPU_Context_Get_SP( _context ) \ + (_context)->register_sp + +#ifdef RTEMS_SMP + static inline bool _CPU_Context_Get_is_executing( + const Context_Control *context + ) + { + return context->is_executing; + } + + static inline void _CPU_Context_Set_is_executing( + Context_Control *context, + bool is_executing + ) + { + context->is_executing = is_executing; + } +#endif + +#define _CPU_Context_Restart_self( _the_context ) \ + _CPU_Context_restore( (_the_context) ); + +#define _CPU_Context_Initialize_fp( _destination ) \ + do { \ + *(*(_destination)) = _CPU_Null_fp_context; \ + } while (0) + +#define _CPU_Fatal_halt( _source, _err ) \ + do { \ + uint32_t _level; \ + uint32_t _error = _err; \ + _CPU_ISR_Disable( _level ); \ + (void) _level; \ + __asm__ volatile ("mov r0, %0\n" \ + : "=r" (_error) \ + : "0" (_error) \ + : "r0" ); \ + while (1); \ + } while (0); + +/** + * @brief CPU initialization. + */ +void _CPU_Initialize( void ); + +void _CPU_ISR_install_vector( + uint32_t vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +/** + * @brief CPU switch context. + */ +void _CPU_Context_switch( Context_Control *run, Context_Control *heir ); + +void _CPU_Context_restore( Context_Control *new_context ) + RTEMS_NO_RETURN; + +#if defined(ARM_MULTILIB_ARCH_V7M) + void _ARMV7M_Start_multitasking( Context_Control *heir ) + RTEMS_NO_RETURN; + #define _CPU_Start_multitasking _ARMV7M_Start_multitasking +#endif + +void _CPU_Context_volatile_clobber( uintptr_t pattern ); + +void _CPU_Context_validate( uintptr_t pattern ); + +#ifdef RTEMS_SMP + uint32_t _CPU_SMP_Initialize( void ); + + bool _CPU_SMP_Start_processor( uint32_t cpu_index ); + + void _CPU_SMP_Finalize_initialization( uint32_t cpu_count ); + + void _CPU_SMP_Prepare_start_multitasking( void ); + + static inline uint32_t _CPU_SMP_Get_current_processor( void ) + { + uint32_t mpidr; + + /* Use ARMv7 Multiprocessor Affinity Register (MPIDR) */ + __asm__ volatile ( + "mrc p15, 0, %[mpidr], c0, c0, 5\n" + : [mpidr] "=&r" (mpidr) + ); + + return mpidr & 0xffU; + } + + void _CPU_SMP_Send_interrupt( uint32_t target_processor_index ); + + static inline void _ARM_Send_event( void ) + { + __asm__ volatile ( "sev" : : : "memory" ); + } + + static inline void _ARM_Wait_for_event( void ) + { + __asm__ volatile ( "wfe" : : : "memory" ); + } + + static inline void _CPU_SMP_Processor_event_broadcast( void ) + { + _ARM_Data_synchronization_barrier(); + _ARM_Send_event(); + } + + static inline void _CPU_SMP_Processor_event_receive( void ) + { + _ARM_Wait_for_event(); + _ARM_Data_memory_barrier(); + } +#endif + + +static inline uint32_t CPU_swap_u32( uint32_t value ) +{ +#if defined(__thumb2__) + __asm__ volatile ( + "rev %0, %0" + : "=r" (value) + : "0" (value) + ); + return value; +#elif defined(__thumb__) + uint32_t byte1, byte2, byte3, byte4, swapped; + + byte4 = (value >> 24) & 0xff; + byte3 = (value >> 16) & 0xff; + byte2 = (value >> 8) & 0xff; + byte1 = value & 0xff; + + swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4; + return swapped; +#else + uint32_t tmp = value; /* make compiler warnings go away */ + __asm__ volatile ("EOR %1, %0, %0, ROR #16\n" + "BIC %1, %1, #0xff0000\n" + "MOV %0, %0, ROR #8\n" + "EOR %0, %0, %1, LSR #8\n" + : "=r" (value), "=r" (tmp) + : "0" (value), "1" (tmp)); + return value; +#endif +} + +static inline uint16_t CPU_swap_u16( uint16_t value ) +{ +#if defined(__thumb2__) + __asm__ volatile ( + "rev16 %0, %0" + : "=r" (value) + : "0" (value) + ); + return value; +#else + return (uint16_t) (((value & 0xffU) << 8) | ((value >> 8) & 0xffU)); +#endif +} + +typedef uint32_t CPU_Counter_ticks; + +CPU_Counter_ticks _CPU_Counter_read( void ); + +CPU_Counter_ticks _CPU_Counter_difference( + CPU_Counter_ticks second, + CPU_Counter_ticks first +); + +#if CPU_PROVIDES_IDLE_THREAD_BODY == TRUE + void *_CPU_Thread_Idle_body( uintptr_t ignored ); +#endif + +/** @} */ + +/** + * @addtogroup ScoreCPUARM + */ +/**@{**/ + +#if defined(ARM_MULTILIB_ARCH_V4) + +typedef enum { + ARM_EXCEPTION_RESET = 0, + ARM_EXCEPTION_UNDEF = 1, + ARM_EXCEPTION_SWI = 2, + ARM_EXCEPTION_PREF_ABORT = 3, + ARM_EXCEPTION_DATA_ABORT = 4, + ARM_EXCEPTION_RESERVED = 5, + ARM_EXCEPTION_IRQ = 6, + ARM_EXCEPTION_FIQ = 7, + MAX_EXCEPTIONS = 8, + ARM_EXCEPTION_MAKE_ENUM_32_BIT = 0xffffffff +} Arm_symbolic_exception_name; + +#endif /* defined(ARM_MULTILIB_ARCH_V4) */ + +typedef struct { + uint32_t register_fpexc; + uint32_t register_fpscr; + uint64_t register_d0; + uint64_t register_d1; + uint64_t register_d2; + uint64_t register_d3; + uint64_t register_d4; + uint64_t register_d5; + uint64_t register_d6; + uint64_t register_d7; + uint64_t register_d8; + uint64_t register_d9; + uint64_t register_d10; + uint64_t register_d11; + uint64_t register_d12; + uint64_t register_d13; + uint64_t register_d14; + uint64_t register_d15; + uint64_t register_d16; + uint64_t register_d17; + uint64_t register_d18; + uint64_t register_d19; + uint64_t register_d20; + uint64_t register_d21; + uint64_t register_d22; + uint64_t register_d23; + uint64_t register_d24; + uint64_t register_d25; + uint64_t register_d26; + uint64_t register_d27; + uint64_t register_d28; + uint64_t register_d29; + uint64_t register_d30; + uint64_t register_d31; +} ARM_VFP_context; + +typedef struct { + uint32_t register_r0; + uint32_t register_r1; + uint32_t register_r2; + uint32_t register_r3; + uint32_t register_r4; + uint32_t register_r5; + uint32_t register_r6; + uint32_t register_r7; + uint32_t register_r8; + uint32_t register_r9; + uint32_t register_r10; + uint32_t register_r11; + uint32_t register_r12; + uint32_t register_sp; + void *register_lr; + void *register_pc; +#if defined(ARM_MULTILIB_ARCH_V4) + uint32_t register_cpsr; + Arm_symbolic_exception_name vector; +#elif defined(ARM_MULTILIB_ARCH_V6M) || defined(ARM_MULTILIB_ARCH_V7M) + uint32_t register_xpsr; + uint32_t vector; +#endif + const ARM_VFP_context *vfp_context; + uint32_t reserved_for_stack_alignment; +} CPU_Exception_frame; + +void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); + +void _ARM_Exception_default( CPU_Exception_frame *frame ); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ASM */ + +#endif /* _RTEMS_SCORE_CPU_H */ diff --git a/cpukit/score/cpu/arm/include/rtems/score/cpu_asm.h b/cpukit/score/cpu/arm/include/rtems/score/cpu_asm.h new file mode 100644 index 0000000000..c430911373 --- /dev/null +++ b/cpukit/score/cpu/arm/include/rtems/score/cpu_asm.h @@ -0,0 +1,39 @@ +/** + * @file + * + * @ingroup ScoreCPU + * + * @brief ARM Assembler Support API + */ + +/* + * COPYRIGHT (c) 2002 by Advent Networks, Inc. + * Jay Monkman + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + * This file is the include file for cpu_asm.S + */ + +#ifndef _RTEMS_SCORE_CPU_ASM_H +#define _RTEMS_SCORE_CPU_ASM_H + + +/* Registers saved in context switch: */ +.set REG_CPSR, 0 +.set REG_R4, 4 +.set REG_R5, 8 +.set REG_R6, 12 +.set REG_R7, 16 +.set REG_R8, 20 +.set REG_R9, 24 +.set REG_R10, 28 +.set REG_R11, 32 +.set REG_SP, 36 +.set REG_LR, 40 +.set REG_PC, 44 +.set SIZE_REGS, REG_PC + 4 + +#endif diff --git a/cpukit/score/cpu/arm/include/rtems/score/cpuatomic.h b/cpukit/score/cpu/arm/include/rtems/score/cpuatomic.h new file mode 100644 index 0000000000..598ee76b20 --- /dev/null +++ b/cpukit/score/cpu/arm/include/rtems/score/cpuatomic.h @@ -0,0 +1,14 @@ +/* + * COPYRIGHT (c) 2012-2013 Deng Hengyi. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_ATOMIC_CPU_H +#define _RTEMS_SCORE_ATOMIC_CPU_H + +#include + +#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/arm/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/arm/include/rtems/score/cpuimpl.h new file mode 100644 index 0000000000..0885c2ef39 --- /dev/null +++ b/cpukit/score/cpu/arm/include/rtems/score/cpuimpl.h @@ -0,0 +1,111 @@ +/** + * @file + * + * @brief CPU Port Implementation API + */ + +/* + * Copyright (c) 2013, 2016 embedded brains GmbH + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPUIMPL_H +#define _RTEMS_SCORE_CPUIMPL_H + +#include + +#define CPU_PER_CPU_CONTROL_SIZE 0 + +#ifdef ARM_MULTILIB_ARCH_V4 + +#if defined(ARM_MULTILIB_VFP_D32) +#define CPU_INTERRUPT_FRAME_SIZE 240 +#elif defined(ARM_MULTILIB_VFP) +#define CPU_INTERRUPT_FRAME_SIZE 112 +#else +#define CPU_INTERRUPT_FRAME_SIZE 40 +#endif + +#endif /* ARM_MULTILIB_ARCH_V4 */ + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef ARM_MULTILIB_ARCH_V4 + +typedef struct { +#ifdef ARM_MULTILIB_VFP + uint32_t fpscr; +#ifdef ARM_MULTILIB_VFP_D32 + double d16; + double d17; + double d18; + double d19; + double d20; + double d21; + double d22; + double d23; + double d24; + double d25; + double d26; + double d27; + double d28; + double d29; + double d30; + double d31; +#endif /* ARM_MULTILIB_VFP_D32 */ + double d0; + double d1; + double d2; + double d3; + double d4; + double d5; + double d6; + double d7; +#endif /* ARM_MULTILIB_VFP */ + uint32_t r9; + uint32_t lr; + uint32_t r0; + uint32_t r1; + uint32_t r2; + uint32_t r3; + uint32_t return_pc; + uint32_t return_cpsr; + uint32_t r7; + uint32_t r12; +} CPU_Interrupt_frame; + +#ifdef RTEMS_SMP + +static inline struct Per_CPU_Control *_ARM_Get_current_per_CPU_control( void ) +{ + struct Per_CPU_Control *cpu_self; + + /* Use PL1 only Thread ID Register (TPIDRPRW) */ + __asm__ volatile ( + "mrc p15, 0, %0, c13, c0, 4" + : "=r" ( cpu_self ) + ); + + return cpu_self; +} + +#define _CPU_Get_current_per_CPU_control() _ARM_Get_current_per_CPU_control() + +#endif /* RTEMS_SMP */ + +#endif /* ARM_MULTILIB_ARCH_V4 */ + +#ifdef __cplusplus +} +#endif + +#endif /* ASM */ + +#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/arm/include/rtems/score/types.h b/cpukit/score/cpu/arm/include/rtems/score/types.h new file mode 100644 index 0000000000..37a56df029 --- /dev/null +++ b/cpukit/score/cpu/arm/include/rtems/score/types.h @@ -0,0 +1,51 @@ +/** + * @file + * + * @brief ARM Architecture Types API + */ + +/* + * This include file contains type definitions pertaining to the + * arm processor family. + * + * COPYRIGHT (c) 2000 Canon Research Centre France SA. + * Emmanuel Raguet, mailto:raguet@crf.canon.fr + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + */ + +#ifndef _RTEMS_SCORE_TYPES_H +#define _RTEMS_SCORE_TYPES_H + +#include + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup ScoreCPU + */ +/**@{**/ + +/* + * This section defines the basic types for this processor. + */ + +/** Type that can store a 32-bit integer or a pointer. */ +typedef uintptr_t CPU_Uint32ptr; + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* !ASM */ + +#endif diff --git a/cpukit/score/cpu/arm/preinstall.am b/cpukit/score/cpu/arm/preinstall.am deleted file mode 100644 index 3bdbb63561..0000000000 --- a/cpukit/score/cpu/arm/preinstall.am +++ /dev/null @@ -1,70 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -$(PROJECT_INCLUDE)/rtems/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems - @: > $(PROJECT_INCLUDE)/rtems/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/asm.h: rtems/asm.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/asm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/asm.h - -$(PROJECT_INCLUDE)/rtems/score/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/score - @: > $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/score/cpu.h: rtems/score/cpu.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpu.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpu.h - -$(PROJECT_INCLUDE)/rtems/score/cpuimpl.h: rtems/score/cpuimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h - -$(PROJECT_INCLUDE)/rtems/score/cpu_asm.h: rtems/score/cpu_asm.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpu_asm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpu_asm.h - -$(PROJECT_INCLUDE)/rtems/score/arm.h: rtems/score/arm.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/arm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/arm.h - -$(PROJECT_INCLUDE)/rtems/score/armv4.h: rtems/score/armv4.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/armv4.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/armv4.h - -$(PROJECT_INCLUDE)/rtems/score/armv7m.h: rtems/score/armv7m.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/armv7m.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/armv7m.h - -$(PROJECT_INCLUDE)/rtems/score/types.h: rtems/score/types.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/types.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/types.h - -$(PROJECT_INCLUDE)/rtems/score/cpuatomic.h: rtems/score/cpuatomic.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h - -$(PROJECT_INCLUDE)/libcpu/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/libcpu - @: > $(PROJECT_INCLUDE)/libcpu/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/libcpu/$(dirstamp) - -$(PROJECT_INCLUDE)/libcpu/arm-cp15.h: include/libcpu/arm-cp15.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/arm-cp15.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/arm-cp15.h - diff --git a/cpukit/score/cpu/arm/rtems/asm.h b/cpukit/score/cpu/arm/rtems/asm.h deleted file mode 100644 index f72df32325..0000000000 --- a/cpukit/score/cpu/arm/rtems/asm.h +++ /dev/null @@ -1,231 +0,0 @@ -/** - * @file - * - * @brief ARM Assembler Support API - * - * This include file attempts to address the problems - * caused by incompatible flavors of assemblers and - * toolsets. It primarily addresses variations in the - * use of leading underscores on symbols and the requirement - * that register names be preceded by a %. - * - * - * NOTE: The spacing in the use of these macros - * is critical to them working as advertised. - */ - -/* - * COPYRIGHT: - * - * This file is based on similar code found in newlib available - * from ftp.cygnus.com. The file which was used had no copyright - * notice. This file is freely distributable as long as the source - * of the file is noted. This file is: - * - * COPYRIGHT (c) 2000 Canon Research Centre France SA. - * Emmanuel Raguet, mailto:raguet@crf.canon.fr - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - * - */ - -#ifndef _RTEMS_ASM_H -#define _RTEMS_ASM_H - -/* - * Indicate we are in an assembly file and get the basic CPU definitions. - */ - -#ifndef ASM -#define ASM -#endif -#include - -/** - * @defgroup ScoreCPUARMASM ARM Assembler Support - * - * @ingroup ScoreCPU - * - * @brief ARM Assembler Support - */ -/**@{**/ - -/* - * Recent versions of GNU cpp define variables which indicate the - * need for underscores and percents. If not using GNU cpp or - * the version does not support this, then you will obviously - * have to define these as appropriate. - */ - -#ifndef __USER_LABEL_PREFIX__ -#define __USER_LABEL_PREFIX__ _ -#endif - -#ifndef __REGISTER_PREFIX__ -#define __REGISTER_PREFIX__ -#endif - -#include - -/* Use the right prefix for global labels. */ - -#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) - -/* Use the right prefix for registers. */ - -#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) - -/* - * define macros for all of the registers on this CPU - * - * EXAMPLE: #define d0 REG (d0) - */ - -#define r0 REG(r0) -#define r1 REG(r1) -#define r2 REG(r2) -#define r3 REG(r3) -#define r4 REG(r4) -#define r5 REG(r5) -#define r6 REG(r6) -#define r7 REG(r7) -#define r8 REG(r8) -#define r9 REG(r9) -#define r10 REG(r10) -#define r11 REG(r11) -#define r12 REG(r12) -#define r13 REG(r13) -#define r14 REG(r14) -#define r15 REG(r15) - -#define CPSR REG(CPSR) - -#define SPSR REG(SPSR) - -#define NUM_IRQ_VECTOR 6 // IRQ number -#define NUM_FIQ_VECTOR 7 // IRQ number - // // -#define CPSR_IRQ_DISABLE 0x80 // FIQ disabled when =1 -#define CPSR_FIQ_DISABLE 0x40 // FIQ disabled when =1 -#define CPSR_THUMB_ENABLE 0x20 // Thumb mode when =1 -#define CPSR_FIQ_MODE 0x11 -#define CPSR_IRQ_MODE 0x12 -#define CPSR_SUPERVISOR_MODE 0x13 -#define CPSR_UNDEF_MODE 0x1B - -#define CPSR_MODE_BITS 0x1F - -/* - * Define macros to handle section beginning and ends. - */ - - -#define BEGIN_CODE_DCL .text -#define END_CODE_DCL -#define BEGIN_DATA_DCL .data -#define END_DATA_DCL -#define BEGIN_CODE .text -#define END_CODE -#define BEGIN_DATA -#define END_DATA -#define BEGIN_BSS -#define END_BSS -#define END - -/* - * Following must be tailor for a particular flavor of the C compiler. - * They may need to put underscores in front of the symbols. - */ - -#define PUBLIC(sym) .globl SYM (sym) -#define EXTERN(sym) .globl SYM (sym) - -#define FUNCTION_THUMB_ENTRY(name) \ - .thumb; \ - .thumb_func; \ - .align 2; \ - .globl name; \ - .type name, %function; \ - name: - -#define FUNCTION_ENTRY(name) \ - .align 2; \ - .globl name; \ - .type name, %function; \ - name: - -#define FUNCTION_END(name) \ - .size name, . - name - -#if defined(ARM_MULTILIB_ARCH_V7M) - #define DEFINE_FUNCTION_ARM(name) \ - .thumb_func ; .globl name ; name: -#elif defined(__thumb__) - #define DEFINE_FUNCTION_ARM(name) \ - .thumb_func ; .globl name ; name: ; bx pc ; \ - .arm ; .globl name ## _arm ; name ## _arm: -#else - #define DEFINE_FUNCTION_ARM(name) \ - .globl name ; name: ; .globl name ## _arm ; name ## _arm: -#endif - -.macro SWITCH_FROM_THUMB_TO_ARM -#ifdef __thumb__ -.align 2 - bx pc -.arm -#endif /* __thumb__ */ -.endm - -.macro SWITCH_FROM_ARM_TO_THUMB REG -#ifdef __thumb__ - add \REG, pc, #1 - bx \REG -.thumb -#endif /* __thumb__ */ -.endm - -.macro SWITCH_FROM_THUMB_2_TO_ARM -#ifdef __thumb2__ -.align 2 - bx pc -.arm -#endif /* __thumb__ */ -.endm - -.macro SWITCH_FROM_ARM_TO_THUMB_2 REG -#ifdef __thumb2__ - add \REG, pc, #1 - bx \REG -.thumb -#endif /* __thumb__ */ -.endm - -.macro BLX_TO_THUMB_1 TARGET -#if defined(__thumb__) && !defined(__thumb2__) - add lr, pc, #1 - bx lr -.thumb - bl \TARGET -.align 2 - bx pc -.arm -#else - bl \TARGET -#endif -.endm - -.macro GET_SELF_CPU_CONTROL REG -#ifdef RTEMS_SMP - /* Use PL1 only Thread ID Register (TPIDRPRW) */ - mrc p15, 0, \REG, c13, c0, 4 -#else - ldr \REG, =_Per_CPU_Information -#endif -.endm - -/** @} */ - -#endif /* _RTEMS_ASM_H */ diff --git a/cpukit/score/cpu/arm/rtems/score/arm.h b/cpukit/score/cpu/arm/rtems/score/arm.h deleted file mode 100755 index f08da1dc57..0000000000 --- a/cpukit/score/cpu/arm/rtems/score/arm.h +++ /dev/null @@ -1,94 +0,0 @@ -/** - * @file - * - * @brief ARM Assembler Support API - */ - -/* - * COPYRIGHT (c) 2000 Canon Research Centre France SA. - * Emmanuel Raguet, mailto:raguet@crf.canon.fr - * - * Copyright (c) 2002 Advent Networks, Inc. - * Jay Monkman - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - * - */ - -#ifndef _RTEMS_SCORE_ARM_H -#define _RTEMS_SCORE_ARM_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ScoreCPU - */ -/**@{**/ - -#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) - #define CPU_MODEL_NAME "ARMv7M" - #define ARM_MULTILIB_ARCH_V7M -#elif defined(__ARM_ARCH_6M__) - #define CPU_MODEL_NAME "ARMv6M" - #define ARM_MULTILIB_ARCH_V6M -#else - #define CPU_MODEL_NAME "ARMv4" - #define ARM_MULTILIB_ARCH_V4 -#endif - -#if defined(__ARM_ARCH_7A__) \ - || defined(__ARM_ARCH_7R__) \ - || defined(__ARM_ARCH_7M__) \ - || defined(__ARM_ARCH_7EM__) - #define ARM_MULTILIB_HAS_WFI - #define ARM_MULTILIB_HAS_LOAD_STORE_EXCLUSIVE - #define ARM_MULTILIB_HAS_BARRIER_INSTRUCTIONS -#endif - -#if defined(__ARM_ARCH_7A__) \ - || defined(__ARM_ARCH_7R__) - #define ARM_MULTILIB_HAS_THREAD_ID_REGISTER -#endif - -#if defined(__ARM_ARCH_7A__) - #define ARM_MULTILIB_CACHE_LINE_MAX_64 -#endif - -#if defined(__ARM_ARCH_7A__) \ - || defined(__ARM_ARCH_7M__) \ - || defined(__ARM_ARCH_7EM__) - #define ARM_MULTILIB_HAS_CPACR -#endif - -#if !defined(__SOFTFP__) - #if defined(__ARM_NEON__) - #define ARM_MULTILIB_VFP_D32 - #elif defined(__VFP_FP__) - #define ARM_MULTILIB_VFP_D16 - #else - #error "FPU support not implemented" - #endif -#endif - -#if defined(ARM_MULTILIB_VFP_D16) \ - || defined(ARM_MULTILIB_VFP_D32) - #define ARM_MULTILIB_VFP -#endif - -/* - * Define the name of the CPU family. - */ - -#define CPU_NAME "ARM" - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* _RTEMS_SCORE_ARM_H */ diff --git a/cpukit/score/cpu/arm/rtems/score/armv4.h b/cpukit/score/cpu/arm/rtems/score/armv4.h deleted file mode 100644 index caeaa3e553..0000000000 --- a/cpukit/score/cpu/arm/rtems/score/armv4.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2013 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef RTEMS_SCORE_ARMV4_H -#define RTEMS_SCORE_ARMV4_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#ifdef ARM_MULTILIB_ARCH_V4 - -void bsp_interrupt_dispatch( void ); - -void _ARMV4_Exception_interrupt( void ); - -typedef void ARMV4_Exception_abort_handler( CPU_Exception_frame *frame ); - -void _ARMV4_Exception_data_abort_set_handler( - ARMV4_Exception_abort_handler handler -); - -void _ARMV4_Exception_data_abort( void ); - -void _ARMV4_Exception_prefetch_abort_set_handler( - ARMV4_Exception_abort_handler handler -); - -void _ARMV4_Exception_prefetch_abort( void ); - -void _ARMV4_Exception_undef_default( void ); - -void _ARMV4_Exception_swi_default( void ); - -void _ARMV4_Exception_data_abort_default( void ); - -void _ARMV4_Exception_pref_abort_default( void ); - -void _ARMV4_Exception_reserved_default( void ); - -void _ARMV4_Exception_irq_default( void ); - -void _ARMV4_Exception_fiq_default( void ); - -static inline uint32_t _ARMV4_Status_irq_enable( void ) -{ - uint32_t arm_switch_reg; - uint32_t psr; - - RTEMS_COMPILER_MEMORY_BARRIER(); - - __asm__ volatile ( - ARM_SWITCH_TO_ARM - "mrs %[psr], cpsr\n" - "bic %[arm_switch_reg], %[psr], #0x80\n" - "msr cpsr, %[arm_switch_reg]\n" - ARM_SWITCH_BACK - : [arm_switch_reg] "=&r" (arm_switch_reg), [psr] "=&r" (psr) - ); - - return psr; -} - -static inline void _ARMV4_Status_restore( uint32_t psr ) -{ - ARM_SWITCH_REGISTERS; - - __asm__ volatile ( - ARM_SWITCH_TO_ARM - "msr cpsr, %[psr]\n" - ARM_SWITCH_BACK - : ARM_SWITCH_OUTPUT - : [psr] "r" (psr) - ); - - RTEMS_COMPILER_MEMORY_BARRIER(); -} - -#endif /* ARM_MULTILIB_ARCH_V4 */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* RTEMS_SCORE_ARMV4_H */ diff --git a/cpukit/score/cpu/arm/rtems/score/armv7m.h b/cpukit/score/cpu/arm/rtems/score/armv7m.h deleted file mode 100644 index a6cc8a34ac..0000000000 --- a/cpukit/score/cpu/arm/rtems/score/armv7m.h +++ /dev/null @@ -1,620 +0,0 @@ -/** - * @file - * - * @brief ARMV7M Architecture Support - */ - -/* - * Copyright (c) 2011-2014 Sebastian Huber. All rights reserved. - * - * embedded brains GmbH - * Obere Lagerstr. 30 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef RTEMS_SCORE_ARMV7M_H -#define RTEMS_SCORE_ARMV7M_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#ifdef ARM_MULTILIB_ARCH_V7M - -/* Coprocessor Access Control Register, CPACR */ -#define ARMV7M_CPACR 0xe000ed88 - -#ifndef ASM - -typedef struct { - uint32_t reserved_0; - uint32_t ictr; - uint32_t actlr; - uint32_t reserved_1; -} ARMV7M_ICTAC; - -typedef void (*ARMV7M_Exception_handler)(void); - -typedef struct { - uint32_t register_r0; - uint32_t register_r1; - uint32_t register_r2; - uint32_t register_r3; - uint32_t register_r12; - void *register_lr; - void *register_pc; - uint32_t register_xpsr; -#ifdef ARM_MULTILIB_VFP - uint32_t register_s0; - uint32_t register_s1; - uint32_t register_s2; - uint32_t register_s3; - uint32_t register_s4; - uint32_t register_s5; - uint32_t register_s6; - uint32_t register_s7; - uint32_t register_s8; - uint32_t register_s9; - uint32_t register_s10; - uint32_t register_s11; - uint32_t register_s12; - uint32_t register_s13; - uint32_t register_s14; - uint32_t register_s15; - uint32_t register_fpscr; - uint32_t reserved; -#endif -} ARMV7M_Exception_frame; - -typedef struct { - uint32_t comp; - uint32_t mask; - uint32_t function; - uint32_t reserved; -} ARMV7M_DWT_comparator; - -typedef struct { -#define ARMV7M_DWT_CTRL_NOCYCCNT (1U << 25) -#define ARMV7M_DWT_CTRL_CYCCNTENA (1U << 0) - uint32_t ctrl; - uint32_t cyccnt; - uint32_t cpicnt; - uint32_t exccnt; - uint32_t sleepcnt; - uint32_t lsucnt; - uint32_t foldcnt; - uint32_t pcsr; - ARMV7M_DWT_comparator comparator[249]; -#define ARMV7M_DWT_LAR_UNLOCK_MAGIC 0xc5acce55U - uint32_t lar; - uint32_t lsr; -} ARMV7M_DWT; - -typedef struct { - uint32_t cpuid; - -#define ARMV7M_SCB_ICSR_NMIPENDSET (1U << 31) -#define ARMV7M_SCB_ICSR_PENDSVSET (1U << 28) -#define ARMV7M_SCB_ICSR_PENDSVCLR (1U << 27) -#define ARMV7M_SCB_ICSR_PENDSTSET (1U << 26) -#define ARMV7M_SCB_ICSR_PENDSTCLR (1U << 25) -#define ARMV7M_SCB_ICSR_ISRPREEMPT (1U << 23) -#define ARMV7M_SCB_ICSR_ISRPENDING (1U << 22) -#define ARMV7M_SCB_ICSR_VECTPENDING_GET(reg) (((reg) >> 12) & 0x1ffU) -#define ARMV7M_SCB_ICSR_RETTOBASE (1U << 11) -#define ARMV7M_SCB_ICSR_VECTACTIVE_GET(reg) ((reg) & 0x1ffU) - uint32_t icsr; - - ARMV7M_Exception_handler *vtor; - -#define ARMV7M_SCB_AIRCR_VECTKEY (0x05fa << 16) -#define ARMV7M_SCB_AIRCR_ENDIANESS (1U << 15) -#define ARMV7M_SCB_AIRCR_PRIGROUP_SHIFT 8 -#define ARMV7M_SCB_AIRCR_PRIGROUP_MASK \ - ((0x7U) << ARMV7M_SCB_AIRCR_PRIGROUP_SHIFT) -#define ARMV7M_SCB_AIRCR_PRIGROUP(val) \ - (((val) << ARMV7M_SCB_AIRCR_PRIGROUP_SHIFT) & ARMV7M_SCB_AIRCR_PRIGROUP_MASK) -#define ARMV7M_SCB_AIRCR_PRIGROUP_GET(reg) \ - (((val) & ARMV7M_SCB_AIRCR_PRIGROUP_MASK) >> ARMV7M_SCB_AIRCR_PRIGROUP_SHIFT) -#define ARMV7M_SCB_AIRCR_PRIGROUP_SET(reg, val) \ - (((reg) & ~ARMV7M_SCB_AIRCR_PRIGROUP_MASK) | ARMV7M_SCB_AIRCR_PRIGROUP(val)) -#define ARMV7M_SCB_AIRCR_SYSRESETREQ (1U << 2) -#define ARMV7M_SCB_AIRCR_VECTCLRACTIVE (1U << 1) -#define ARMV7M_SCB_AIRCR_VECTRESET (1U << 0) - uint32_t aircr; - - uint32_t scr; - uint32_t ccr; - uint8_t shpr [12]; - -#define ARMV7M_SCB_SHCSR_USGFAULTENA (1U << 18) -#define ARMV7M_SCB_SHCSR_BUSFAULTENA (1U << 17) -#define ARMV7M_SCB_SHCSR_MEMFAULTENA (1U << 16) - uint32_t shcsr; - - uint32_t cfsr; - uint32_t hfsr; - uint32_t dfsr; - uint32_t mmfar; - uint32_t bfar; - uint32_t afsr; - uint32_t reserved_e000ed40[18]; - uint32_t cpacr; - uint32_t reserved_e000ed8c[106]; - uint32_t fpccr; - uint32_t fpcar; - uint32_t fpdscr; - uint32_t mvfr0; - uint32_t mvfr1; -} ARMV7M_SCB; - -typedef struct { -#define ARMV7M_SYSTICK_CSR_COUNTFLAG (1U << 16) -#define ARMV7M_SYSTICK_CSR_CLKSOURCE (1U << 2) -#define ARMV7M_SYSTICK_CSR_TICKINT (1U << 1) -#define ARMV7M_SYSTICK_CSR_ENABLE (1U << 0) - uint32_t csr; - - uint32_t rvr; - uint32_t cvr; - -#define ARMV7M_SYSTICK_CALIB_NOREF (1U << 31) -#define ARMV7M_SYSTICK_CALIB_SKEW (1U << 30) -#define ARMV7M_SYSTICK_CALIB_TENMS_GET(reg) ((reg) & 0xffffffU) - uint32_t calib; -} ARMV7M_Systick; - -typedef struct { - uint32_t iser [8]; - uint32_t reserved_0 [24]; - uint32_t icer [8]; - uint32_t reserved_1 [24]; - uint32_t ispr [8]; - uint32_t reserved_2 [24]; - uint32_t icpr [8]; - uint32_t reserved_3 [24]; - uint32_t iabr [8]; - uint32_t reserved_4 [56]; - uint8_t ipr [240]; - uint32_t reserved_5 [644]; - uint32_t stir; -} ARMV7M_NVIC; - -typedef struct { -#define ARMV7M_MPU_TYPE_IREGION_GET(reg) (((reg) >> 16) & 0xffU) -#define ARMV7M_MPU_TYPE_DREGION_GET(reg) (((reg) >> 8) & 0xffU) -#define ARMV7M_MPU_TYPE_SEPARATE (1U << 0) - uint32_t type; - -#define ARMV7M_MPU_CTRL_PRIVDEFENA (1U << 2) -#define ARMV7M_MPU_CTRL_HFNMIENA (1U << 1) -#define ARMV7M_MPU_CTRL_ENABLE (1U << 0) - uint32_t ctrl; - - uint32_t rnr; - -#define ARMV7M_MPU_RBAR_ADDR_SHIFT 5 -#define ARMV7M_MPU_RBAR_ADDR_MASK \ - ((0x7ffffffU) << ARMV7M_MPU_RBAR_ADDR_SHIFT) -#define ARMV7M_MPU_RBAR_ADDR(val) \ - (((val) << ARMV7M_MPU_RBAR_ADDR_SHIFT) & ARMV7M_MPU_RBAR_ADDR_MASK) -#define ARMV7M_MPU_RBAR_ADDR_GET(reg) \ - (((val) & ARMV7M_MPU_RBAR_ADDR_MASK) >> ARMV7M_MPU_RBAR_ADDR_SHIFT) -#define ARMV7M_MPU_RBAR_ADDR_SET(reg, val) \ - (((reg) & ~ARMV7M_MPU_RBAR_ADDR_MASK) | ARMV7M_MPU_RBAR_ADDR(val)) -#define ARMV7M_MPU_RBAR_VALID (1U << 4) -#define ARMV7M_MPU_RBAR_REGION_SHIFT 0 -#define ARMV7M_MPU_RBAR_REGION_MASK \ - ((0xfU) << ARMV7M_MPU_RBAR_REGION_SHIFT) -#define ARMV7M_MPU_RBAR_REGION(val) \ - (((val) << ARMV7M_MPU_RBAR_REGION_SHIFT) & ARMV7M_MPU_RBAR_REGION_MASK) -#define ARMV7M_MPU_RBAR_REGION_GET(reg) \ - (((val) & ARMV7M_MPU_RBAR_REGION_MASK) >> ARMV7M_MPU_RBAR_REGION_SHIFT) -#define ARMV7M_MPU_RBAR_REGION_SET(reg, val) \ - (((reg) & ~ARMV7M_MPU_RBAR_REGION_MASK) | ARMV7M_MPU_RBAR_REGION(val)) - uint32_t rbar; - -#define ARMV7M_MPU_RASR_XN (1U << 28) -#define ARMV7M_MPU_RASR_AP_SHIFT 24 -#define ARMV7M_MPU_RASR_AP_MASK \ - ((0x7U) << ARMV7M_MPU_RASR_AP_SHIFT) -#define ARMV7M_MPU_RASR_AP(val) \ - (((val) << ARMV7M_MPU_RASR_AP_SHIFT) & ARMV7M_MPU_RASR_AP_MASK) -#define ARMV7M_MPU_RASR_AP_GET(reg) \ - (((val) & ARMV7M_MPU_RASR_AP_MASK) >> ARMV7M_MPU_RASR_AP_SHIFT) -#define ARMV7M_MPU_RASR_AP_SET(reg, val) \ - (((reg) & ~ARMV7M_MPU_RASR_AP_MASK) | ARMV7M_MPU_RASR_AP(val)) -#define ARMV7M_MPU_RASR_TEX_SHIFT 19 -#define ARMV7M_MPU_RASR_TEX_MASK \ - ((0x7U) << ARMV7M_MPU_RASR_TEX_SHIFT) -#define ARMV7M_MPU_RASR_TEX(val) \ - (((val) << ARMV7M_MPU_RASR_TEX_SHIFT) & ARMV7M_MPU_RASR_TEX_MASK) -#define ARMV7M_MPU_RASR_TEX_GET(reg) \ - (((val) & ARMV7M_MPU_RASR_TEX_MASK) >> ARMV7M_MPU_RASR_TEX_SHIFT) -#define ARMV7M_MPU_RASR_TEX_SET(reg, val) \ - (((reg) & ~ARMV7M_MPU_RASR_TEX_MASK) | ARMV7M_MPU_RASR_TEX(val)) -#define ARMV7M_MPU_RASR_S (1U << 18) -#define ARMV7M_MPU_RASR_C (1U << 17) -#define ARMV7M_MPU_RASR_B (1U << 16) -#define ARMV7M_MPU_RASR_SRD_SHIFT 8 -#define ARMV7M_MPU_RASR_SRD_MASK \ - ((0xffU) << ARMV7M_MPU_RASR_SRD_SHIFT) -#define ARMV7M_MPU_RASR_SRD(val) \ - (((val) << ARMV7M_MPU_RASR_SRD_SHIFT) & ARMV7M_MPU_RASR_SRD_MASK) -#define ARMV7M_MPU_RASR_SRD_GET(reg) \ - (((val) & ARMV7M_MPU_RASR_SRD_MASK) >> ARMV7M_MPU_RASR_SRD_SHIFT) -#define ARMV7M_MPU_RASR_SRD_SET(reg, val) \ - (((reg) & ~ARMV7M_MPU_RASR_SRD_MASK) | ARMV7M_MPU_RASR_SRD(val)) -#define ARMV7M_MPU_RASR_SIZE_SHIFT 1 -#define ARMV7M_MPU_RASR_SIZE_MASK \ - ((0x1fU) << ARMV7M_MPU_RASR_SIZE_SHIFT) -#define ARMV7M_MPU_RASR_SIZE(val) \ - (((val) << ARMV7M_MPU_RASR_SIZE_SHIFT) & ARMV7M_MPU_RASR_SIZE_MASK) -#define ARMV7M_MPU_RASR_SIZE_GET(reg) \ - (((val) & ARMV7M_MPU_RASR_SIZE_MASK) >> ARMV7M_MPU_RASR_SIZE_SHIFT) -#define ARMV7M_MPU_RASR_SIZE_SET(reg, val) \ - (((reg) & ~ARMV7M_MPU_RASR_SIZE_MASK) | ARMV7M_MPU_RASR_SIZE(val)) -#define ARMV7M_MPU_RASR_ENABLE (1U << 0) - uint32_t rasr; - - uint32_t rbar_a1; - uint32_t rasr_a1; - uint32_t rbar_a2; - uint32_t rasr_a2; - uint32_t rbar_a3; - uint32_t rasr_a3; -} ARMV7M_MPU; - -typedef enum { - ARMV7M_MPU_AP_PRIV_NO_USER_NO, - ARMV7M_MPU_AP_PRIV_RW_USER_NO, - ARMV7M_MPU_AP_PRIV_RW_USER_RO, - ARMV7M_MPU_AP_PRIV_RW_USER_RW, - ARMV7M_MPU_AP_PRIV_RO_USER_NO = 0x5, - ARMV7M_MPU_AP_PRIV_RO_USER_RO, -} ARMV7M_MPU_Access_permissions; - -typedef enum { - ARMV7M_MPU_ATTR_R = ARMV7M_MPU_RASR_AP(ARMV7M_MPU_AP_PRIV_RO_USER_NO) - | ARMV7M_MPU_RASR_C | ARMV7M_MPU_RASR_XN, - ARMV7M_MPU_ATTR_RW = ARMV7M_MPU_RASR_AP(ARMV7M_MPU_AP_PRIV_RW_USER_NO) - | ARMV7M_MPU_RASR_C | ARMV7M_MPU_RASR_XN | ARMV7M_MPU_RASR_B, - ARMV7M_MPU_ATTR_RWX = ARMV7M_MPU_RASR_AP(ARMV7M_MPU_AP_PRIV_RW_USER_NO) - | ARMV7M_MPU_RASR_C | ARMV7M_MPU_RASR_B, - ARMV7M_MPU_ATTR_X = ARMV7M_MPU_RASR_AP(ARMV7M_MPU_AP_PRIV_NO_USER_NO) - | ARMV7M_MPU_RASR_C, - ARMV7M_MPU_ATTR_RX = ARMV7M_MPU_RASR_AP(ARMV7M_MPU_AP_PRIV_RO_USER_NO) - | ARMV7M_MPU_RASR_C, - ARMV7M_MPU_ATTR_IO = ARMV7M_MPU_RASR_AP(ARMV7M_MPU_AP_PRIV_RW_USER_NO) - | ARMV7M_MPU_RASR_XN, -} ARMV7M_MPU_Attributes; - -typedef enum { - ARMV7M_MPU_SIZE_32_B = 0x4, - ARMV7M_MPU_SIZE_64_B, - ARMV7M_MPU_SIZE_128_B, - ARMV7M_MPU_SIZE_256_B, - ARMV7M_MPU_SIZE_512_B, - ARMV7M_MPU_SIZE_1_KB, - ARMV7M_MPU_SIZE_2_KB, - ARMV7M_MPU_SIZE_4_KB, - ARMV7M_MPU_SIZE_8_KB, - ARMV7M_MPU_SIZE_16_KB, - ARMV7M_MPU_SIZE_32_KB, - ARMV7M_MPU_SIZE_64_KB, - ARMV7M_MPU_SIZE_128_KB, - ARMV7M_MPU_SIZE_256_KB, - ARMV7M_MPU_SIZE_512_KB, - ARMV7M_MPU_SIZE_1_MB, - ARMV7M_MPU_SIZE_2_MB, - ARMV7M_MPU_SIZE_4_MB, - ARMV7M_MPU_SIZE_8_MB, - ARMV7M_MPU_SIZE_16_MB, - ARMV7M_MPU_SIZE_32_MB, - ARMV7M_MPU_SIZE_64_MB, - ARMV7M_MPU_SIZE_128_MB, - ARMV7M_MPU_SIZE_256_MB, - ARMV7M_MPU_SIZE_512_MB, - ARMV7M_MPU_SIZE_1_GB, - ARMV7M_MPU_SIZE_2_GB, - ARMV7M_MPU_SIZE_4_GB -} ARMV7M_MPU_Size; - -typedef struct { - uint32_t rbar; - uint32_t rasr; -} ARMV7M_MPU_Region; - -#define ARMV7M_MPU_REGION_INITIALIZER(idx, addr, size, attr) \ - { \ - ((addr) & ARMV7M_MPU_RBAR_ADDR_MASK) \ - | ARMV7M_MPU_RBAR_VALID \ - | ARMV7M_MPU_RBAR_REGION(idx), \ - ARMV7M_MPU_RASR_SIZE(size) | (attr) | ARMV7M_MPU_RASR_ENABLE \ - } - -#define ARMV7M_MPU_REGION_DISABLED_INITIALIZER(idx) \ - { \ - ARMV7M_MPU_RBAR_VALID | ARMV7M_MPU_RBAR_REGION(idx), \ - 0 \ - } - -typedef struct { - uint32_t dhcsr; - uint32_t dcrsr; - uint32_t dcrdr; -#define ARMV7M_DEBUG_DEMCR_VC_CORERESET (1U << 0) -#define ARMV7M_DEBUG_DEMCR_VC_MMERR (1U << 4) -#define ARMV7M_DEBUG_DEMCR_VC_NOCPERR (1U << 5) -#define ARMV7M_DEBUG_DEMCR_VC_CHKERR (1U << 6) -#define ARMV7M_DEBUG_DEMCR_VC_STATERR (1U << 7) -#define ARMV7M_DEBUG_DEMCR_VC_BUSERR (1U << 8) -#define ARMV7M_DEBUG_DEMCR_VC_INTERR (1U << 9) -#define ARMV7M_DEBUG_DEMCR_VC_HARDERR (1U << 10) -#define ARMV7M_DEBUG_DEMCR_MON_EN (1U << 16) -#define ARMV7M_DEBUG_DEMCR_MON_PEND (1U << 17) -#define ARMV7M_DEBUG_DEMCR_MON_STEP (1U << 18) -#define ARMV7M_DEBUG_DEMCR_MON_REQ (1U << 19) -#define ARMV7M_DEBUG_DEMCR_TRCENA (1U << 24) - uint32_t demcr; -} ARMV7M_DEBUG; - -#define ARMV7M_DWT_BASE 0xe0001000 -#define ARMV7M_SCS_BASE 0xe000e000 -#define ARMV7M_ICTAC_BASE (ARMV7M_SCS_BASE + 0x0) -#define ARMV7M_SYSTICK_BASE (ARMV7M_SCS_BASE + 0x10) -#define ARMV7M_NVIC_BASE (ARMV7M_SCS_BASE + 0x100) -#define ARMV7M_SCB_BASE (ARMV7M_SCS_BASE + 0xd00) -#define ARMV7M_MPU_BASE (ARMV7M_SCS_BASE + 0xd90) -#define ARMV7M_DEBUG_BASE (ARMV7M_SCS_BASE + 0xdf0) - -#define _ARMV7M_DWT \ - ((volatile ARMV7M_DWT *) ARMV7M_DWT_BASE) -#define _ARMV7M_ICTAC \ - ((volatile ARMV7M_ICTAC *) ARMV7M_ICTAC_BASE) -#define _ARMV7M_SCB \ - ((volatile ARMV7M_SCB *) ARMV7M_SCB_BASE) -#define _ARMV7M_Systick \ - ((volatile ARMV7M_Systick *) ARMV7M_SYSTICK_BASE) -#define _ARMV7M_NVIC \ - ((volatile ARMV7M_NVIC *) ARMV7M_NVIC_BASE) -#define _ARMV7M_MPU \ - ((volatile ARMV7M_MPU *) ARMV7M_MPU_BASE) -#define _ARMV7M_DEBUG \ - ((volatile ARMV7M_DEBUG *) ARMV7M_DEBUG_BASE) - -#define ARMV7M_VECTOR_MSP 0 -#define ARMV7M_VECTOR_RESET 1 -#define ARMV7M_VECTOR_NMI 2 -#define ARMV7M_VECTOR_HARD_FAULT 3 -#define ARMV7M_VECTOR_MEM_MANAGE 4 -#define ARMV7M_VECTOR_BUS_FAULT 5 -#define ARMV7M_VECTOR_USAGE_FAULT 6 -#define ARMV7M_VECTOR_SVC 11 -#define ARMV7M_VECTOR_DEBUG_MONITOR 12 -#define ARMV7M_VECTOR_PENDSV 14 -#define ARMV7M_VECTOR_SYSTICK 15 -#define ARMV7M_VECTOR_IRQ(n) ((n) + 16) -#define ARMV7M_IRQ_OF_VECTOR(n) ((n) - 16) - -#define ARMV7M_EXCEPTION_PRIORITY_LOWEST 255 - -static inline bool _ARMV7M_Is_vector_an_irq( int vector ) -{ - /* External (i.e. non-system) IRQs start after the SysTick vector. */ - return vector > ARMV7M_VECTOR_SYSTICK; -} - -static inline uint32_t _ARMV7M_Get_basepri(void) -{ - uint32_t val; - __asm__ volatile ("mrs %[val], basepri\n" : [val] "=&r" (val)); - return val; -} - -static inline void _ARMV7M_Set_basepri(uint32_t val) -{ - __asm__ volatile ("msr basepri, %[val]\n" : : [val] "r" (val)); -} - -static inline uint32_t _ARMV7M_Get_primask(void) -{ - uint32_t val; - __asm__ volatile ("mrs %[val], primask\n" : [val] "=&r" (val)); - return val; -} - -static inline void _ARMV7M_Set_primask(uint32_t val) -{ - __asm__ volatile ("msr primask, %[val]\n" : : [val] "r" (val)); -} - -static inline uint32_t _ARMV7M_Get_faultmask(void) -{ - uint32_t val; - __asm__ volatile ("mrs %[val], faultmask\n" : [val] "=&r" (val)); - return val; -} - -static inline void _ARMV7M_Set_faultmask(uint32_t val) -{ - __asm__ volatile ("msr faultmask, %[val]\n" : : [val] "r" (val)); -} - -static inline uint32_t _ARMV7M_Get_control(void) -{ - uint32_t val; - __asm__ volatile ("mrs %[val], control\n" : [val] "=&r" (val)); - return val; -} - -static inline void _ARMV7M_Set_control(uint32_t val) -{ - __asm__ volatile ("msr control, %[val]\n" : : [val] "r" (val)); -} - -static inline uint32_t _ARMV7M_Get_MSP(void) -{ - uint32_t val; - __asm__ volatile ("mrs %[val], msp\n" : [val] "=&r" (val)); - return val; -} - -static inline void _ARMV7M_Set_MSP(uint32_t val) -{ - __asm__ volatile ("msr msp, %[val]\n" : : [val] "r" (val)); -} - -static inline uint32_t _ARMV7M_Get_PSP(void) -{ - uint32_t val; - __asm__ volatile ("mrs %[val], psp\n" : [val] "=&r" (val)); - return val; -} - -static inline void _ARMV7M_Set_PSP(uint32_t val) -{ - __asm__ volatile ("msr psp, %[val]\n" : : [val] "r" (val)); -} - -static inline uint32_t _ARMV7M_Get_XPSR(void) -{ - uint32_t val; - __asm__ volatile ("mrs %[val], xpsr\n" : [val] "=&r" (val)); - return val; -} - -static inline bool _ARMV7M_NVIC_Is_enabled( int irq ) -{ - int index = irq >> 5; - uint32_t bit = 1U << (irq & 0x1f); - - return (_ARMV7M_NVIC->iser [index] & bit) != 0; -} - -static inline void _ARMV7M_NVIC_Set_enable( int irq ) -{ - int index = irq >> 5; - uint32_t bit = 1U << (irq & 0x1f); - - _ARMV7M_NVIC->iser [index] = bit; -} - -static inline void _ARMV7M_NVIC_Clear_enable( int irq ) -{ - int index = irq >> 5; - uint32_t bit = 1U << (irq & 0x1f); - - _ARMV7M_NVIC->icer [index] = bit; -} - -static inline bool _ARMV7M_NVIC_Is_pending( int irq ) -{ - int index = irq >> 5; - uint32_t bit = 1U << (irq & 0x1f); - - return (_ARMV7M_NVIC->ispr [index] & bit) != 0; -} - -static inline void _ARMV7M_NVIC_Set_pending( int irq ) -{ - int index = irq >> 5; - uint32_t bit = 1U << (irq & 0x1f); - - _ARMV7M_NVIC->ispr [index] = bit; -} - -static inline void _ARMV7M_NVIC_Clear_pending( int irq ) -{ - int index = irq >> 5; - uint32_t bit = 1U << (irq & 0x1f); - - _ARMV7M_NVIC->icpr [index] = bit; -} - -static inline bool _ARMV7M_NVIC_Is_active( int irq ) -{ - int index = irq >> 5; - uint32_t bit = 1U << (irq & 0x1f); - - return (_ARMV7M_NVIC->iabr [index] & bit) != 0; -} - -static inline void _ARMV7M_NVIC_Set_priority( int irq, int priority ) -{ - _ARMV7M_NVIC->ipr [irq] = (uint8_t) priority; -} - -static inline int _ARMV7M_NVIC_Get_priority( int irq ) -{ - return _ARMV7M_NVIC->ipr [irq]; -} - -static inline bool _ARMV7M_DWT_Enable_CYCCNT( void ) -{ - uint32_t demcr; - uint32_t dwt_ctrl; - - demcr = _ARMV7M_DEBUG->demcr; - _ARMV7M_DEBUG->demcr = demcr | ARMV7M_DEBUG_DEMCR_TRCENA; - _ARM_Data_synchronization_barrier(); - - dwt_ctrl = _ARMV7M_DWT->ctrl; - if ((dwt_ctrl & ARMV7M_DWT_CTRL_NOCYCCNT) == 0) { - _ARMV7M_DWT->lar = ARMV7M_DWT_LAR_UNLOCK_MAGIC; - _ARM_Data_synchronization_barrier(); - _ARMV7M_DWT->ctrl = dwt_ctrl | ARMV7M_DWT_CTRL_CYCCNTENA; - return true; - } else { - _ARMV7M_DEBUG->demcr = demcr; - return false; - } -} - -int _ARMV7M_Get_exception_priority( int vector ); - -void _ARMV7M_Set_exception_priority( int vector, int priority ); - -ARMV7M_Exception_handler _ARMV7M_Get_exception_handler( int index ); - -void _ARMV7M_Set_exception_handler( - int index, - ARMV7M_Exception_handler handler -); - -/** - * @brief ARMV7M set exception priority and handler. - */ -void _ARMV7M_Set_exception_priority_and_handler( - int index, - int priority, - ARMV7M_Exception_handler handler -); - -void _ARMV7M_Exception_default( void ); - -void _ARMV7M_Interrupt_service_enter( void ); - -void _ARMV7M_Interrupt_service_leave( void ); - -void _ARMV7M_Pendable_service_call( void ); - -void _ARMV7M_Supervisor_call( void ); - -#endif /* ASM */ - -#endif /* ARM_MULTILIB_ARCH_V7M */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* RTEMS_SCORE_ARMV7M_H */ diff --git a/cpukit/score/cpu/arm/rtems/score/cpu.h b/cpukit/score/cpu/arm/rtems/score/cpu.h deleted file mode 100644 index 05e236c75a..0000000000 --- a/cpukit/score/cpu/arm/rtems/score/cpu.h +++ /dev/null @@ -1,702 +0,0 @@ -/** - * @file - * - * @brief ARM Architecture Support API - */ - -/* - * This include file contains information pertaining to the ARM - * processor. - * - * Copyright (c) 2009, 2017 embedded brains GmbH - * - * Copyright (c) 2007 Ray Xu - * - * Copyright (c) 2006 OAR Corporation - * - * Copyright (c) 2002 Advent Networks, Inc. - * Jay Monkman - * - * COPYRIGHT (c) 2000 Canon Research Centre France SA. - * Emmanuel Raguet, mailto:raguet@crf.canon.fr - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - * - */ - -#ifndef _RTEMS_SCORE_CPU_H -#define _RTEMS_SCORE_CPU_H - -#include -#include - -#if defined(ARM_MULTILIB_ARCH_V4) - -/** - * @defgroup ScoreCPUARM ARM Specific Support - * - * @ingroup ScoreCPU - * - * @brief ARM specific support. - */ -/**@{**/ - -#if defined(__thumb__) && !defined(__thumb2__) - #define ARM_SWITCH_REGISTERS uint32_t arm_switch_reg - #define ARM_SWITCH_TO_ARM ".align 2\nbx pc\n.arm\n" - #define ARM_SWITCH_BACK "add %[arm_switch_reg], pc, #1\nbx %[arm_switch_reg]\n.thumb\n" - #define ARM_SWITCH_OUTPUT [arm_switch_reg] "=&r" (arm_switch_reg) - #define ARM_SWITCH_ADDITIONAL_OUTPUT , ARM_SWITCH_OUTPUT -#else - #define ARM_SWITCH_REGISTERS - #define ARM_SWITCH_TO_ARM - #define ARM_SWITCH_BACK - #define ARM_SWITCH_OUTPUT - #define ARM_SWITCH_ADDITIONAL_OUTPUT -#endif - -/** - * @name Program Status Register - */ -/**@{**/ - -#define ARM_PSR_N (1 << 31) -#define ARM_PSR_Z (1 << 30) -#define ARM_PSR_C (1 << 29) -#define ARM_PSR_V (1 << 28) -#define ARM_PSR_Q (1 << 27) -#define ARM_PSR_J (1 << 24) -#define ARM_PSR_GE_SHIFT 16 -#define ARM_PSR_GE_MASK (0xf << ARM_PSR_GE_SHIFT) -#define ARM_PSR_E (1 << 9) -#define ARM_PSR_A (1 << 8) -#define ARM_PSR_I (1 << 7) -#define ARM_PSR_F (1 << 6) -#define ARM_PSR_T (1 << 5) -#define ARM_PSR_M_SHIFT 0 -#define ARM_PSR_M_MASK (0x1f << ARM_PSR_M_SHIFT) -#define ARM_PSR_M_USR 0x10 -#define ARM_PSR_M_FIQ 0x11 -#define ARM_PSR_M_IRQ 0x12 -#define ARM_PSR_M_SVC 0x13 -#define ARM_PSR_M_ABT 0x17 -#define ARM_PSR_M_HYP 0x1a -#define ARM_PSR_M_UND 0x1b -#define ARM_PSR_M_SYS 0x1f - -/** @} */ - -/** @} */ - -#endif /* defined(ARM_MULTILIB_ARCH_V4) */ - -/** - * @addtogroup ScoreCPU - */ -/**@{**/ - -/* - * The ARM uses the PIC interrupt model. - */ -#define CPU_SIMPLE_VECTORED_INTERRUPTS FALSE - -#define CPU_HAS_SOFTWARE_INTERRUPT_STACK FALSE - -#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE - -#define CPU_ALLOCATE_INTERRUPT_STACK FALSE - -#define CPU_ISR_PASSES_FRAME_POINTER FALSE - -#define CPU_HARDWARE_FP FALSE - -#define CPU_SOFTWARE_FP FALSE - -#define CPU_ALL_TASKS_ARE_FP FALSE - -#define CPU_IDLE_TASK_IS_FP FALSE - -#define CPU_USE_DEFERRED_FP_SWITCH FALSE - -#define CPU_ENABLE_ROBUST_THREAD_DISPATCH TRUE - -#if defined(ARM_MULTILIB_HAS_WFI) - #define CPU_PROVIDES_IDLE_THREAD_BODY TRUE -#else - #define CPU_PROVIDES_IDLE_THREAD_BODY FALSE -#endif - -#define CPU_STACK_GROWS_UP FALSE - -#if defined(ARM_MULTILIB_CACHE_LINE_MAX_64) - #define CPU_CACHE_LINE_BYTES 64 -#else - #define CPU_CACHE_LINE_BYTES 32 -#endif - -#define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES ) - -#define CPU_MODES_INTERRUPT_MASK 0x1 - -#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp ) - -#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0 - -#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE - -#define CPU_STACK_MINIMUM_SIZE (1024 * 4) - -/* AAPCS, section 4.1, Fundamental Data Types */ -#define CPU_SIZEOF_POINTER 4 - -/* AAPCS, section 4.1, Fundamental Data Types */ -#define CPU_ALIGNMENT 8 - -#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT - -/* AAPCS, section 4.3.1, Aggregates */ -#define CPU_PARTITION_ALIGNMENT 4 - -/* AAPCS, section 5.2.1.2, Stack constraints at a public interface */ -#define CPU_STACK_ALIGNMENT 8 - -/* - * Bitfield handler macros. - * - * If we had a particularly fast function for finding the first - * bit set in a word, it would go here. Since we don't (*), we'll - * just use the universal macros. - * - * (*) On ARM V5 and later, there's a CLZ function which could be - * used to implement much quicker than the default macro. - */ - -#define CPU_USE_GENERIC_BITFIELD_CODE TRUE - -#define CPU_MAXIMUM_PROCESSORS 32 - -/** @} */ - -#ifdef ARM_MULTILIB_HAS_THREAD_ID_REGISTER - #define ARM_CONTEXT_CONTROL_THREAD_ID_OFFSET 44 -#endif - -#ifdef ARM_MULTILIB_VFP - #define ARM_CONTEXT_CONTROL_D8_OFFSET 48 -#endif - -#ifdef ARM_MULTILIB_ARCH_V4 - #define ARM_CONTEXT_CONTROL_ISR_DISPATCH_DISABLE 40 -#endif - -#ifdef RTEMS_SMP - #if defined(ARM_MULTILIB_VFP) - #define ARM_CONTEXT_CONTROL_IS_EXECUTING_OFFSET 112 - #elif defined(ARM_MULTILIB_HAS_THREAD_ID_REGISTER) - #define ARM_CONTEXT_CONTROL_IS_EXECUTING_OFFSET 48 - #else - #define ARM_CONTEXT_CONTROL_IS_EXECUTING_OFFSET 44 - #endif -#endif - -#define ARM_EXCEPTION_FRAME_SIZE 80 - -#define ARM_EXCEPTION_FRAME_REGISTER_SP_OFFSET 52 - -#define ARM_EXCEPTION_FRAME_VFP_CONTEXT_OFFSET 72 - -#define ARM_VFP_CONTEXT_SIZE 264 - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ScoreCPU - */ -/**@{**/ - -typedef struct { -#if defined(ARM_MULTILIB_ARCH_V4) - uint32_t register_r4; - uint32_t register_r5; - uint32_t register_r6; - uint32_t register_r7; - uint32_t register_r8; - uint32_t register_r9; - uint32_t register_r10; - uint32_t register_fp; - uint32_t register_sp; - uint32_t register_lr; - uint32_t isr_dispatch_disable; -#elif defined(ARM_MULTILIB_ARCH_V6M) || defined(ARM_MULTILIB_ARCH_V7M) - uint32_t register_r4; - uint32_t register_r5; - uint32_t register_r6; - uint32_t register_r7; - uint32_t register_r8; - uint32_t register_r9; - uint32_t register_r10; - uint32_t register_r11; - void *register_lr; - void *register_sp; - uint32_t isr_nest_level; -#else - void *register_sp; -#endif -#ifdef ARM_MULTILIB_HAS_THREAD_ID_REGISTER - uint32_t thread_id; -#endif -#ifdef ARM_MULTILIB_VFP - uint64_t register_d8; - uint64_t register_d9; - uint64_t register_d10; - uint64_t register_d11; - uint64_t register_d12; - uint64_t register_d13; - uint64_t register_d14; - uint64_t register_d15; -#endif -#ifdef RTEMS_SMP - volatile bool is_executing; -#endif -} Context_Control; - -typedef struct { - /* Not supported */ -} Context_Control_fp; - -static inline void _ARM_Data_memory_barrier( void ) -{ -#ifdef ARM_MULTILIB_HAS_BARRIER_INSTRUCTIONS - __asm__ volatile ( "dmb" : : : "memory" ); -#else - RTEMS_COMPILER_MEMORY_BARRIER(); -#endif -} - -static inline void _ARM_Data_synchronization_barrier( void ) -{ -#ifdef ARM_MULTILIB_HAS_BARRIER_INSTRUCTIONS - __asm__ volatile ( "dsb" : : : "memory" ); -#else - RTEMS_COMPILER_MEMORY_BARRIER(); -#endif -} - -static inline void _ARM_Instruction_synchronization_barrier( void ) -{ -#ifdef ARM_MULTILIB_HAS_BARRIER_INSTRUCTIONS - __asm__ volatile ( "isb" : : : "memory" ); -#else - RTEMS_COMPILER_MEMORY_BARRIER(); -#endif -} - -static inline uint32_t arm_interrupt_disable( void ) -{ - uint32_t level; - -#if defined(ARM_MULTILIB_ARCH_V4) - uint32_t arm_switch_reg; - - /* - * Disable only normal interrupts (IRQ). - * - * In order to support fast interrupts (FIQ) such that they can do something - * useful, we have to disable the operating system support for FIQs. Having - * operating system support for them would require that FIQs are disabled - * during critical sections of the operating system and application. At this - * level IRQs and FIQs would be equal. It is true that FIQs could interrupt - * the non critical sections of IRQs, so here they would have a small - * advantage. Without operating system support, the FIQs can execute at any - * time (of course not during the service of another FIQ). If someone needs - * operating system support for a FIQ, she can trigger a software interrupt and - * service the request in a two-step process. - */ - __asm__ volatile ( - ARM_SWITCH_TO_ARM - "mrs %[level], cpsr\n" - "orr %[arm_switch_reg], %[level], #0x80\n" - "msr cpsr, %[arm_switch_reg]\n" - ARM_SWITCH_BACK - : [arm_switch_reg] "=&r" (arm_switch_reg), [level] "=&r" (level) - ); -#elif defined(ARM_MULTILIB_ARCH_V7M) - uint32_t basepri = 0x80; - - __asm__ volatile ( - "mrs %[level], basepri\n" - "msr basepri_max, %[basepri]\n" - : [level] "=&r" (level) - : [basepri] "r" (basepri) - ); -#endif - - return level; -} - -static inline void arm_interrupt_enable( uint32_t level ) -{ -#if defined(ARM_MULTILIB_ARCH_V4) - ARM_SWITCH_REGISTERS; - - __asm__ volatile ( - ARM_SWITCH_TO_ARM - "msr cpsr, %[level]\n" - ARM_SWITCH_BACK - : ARM_SWITCH_OUTPUT - : [level] "r" (level) - ); -#elif defined(ARM_MULTILIB_ARCH_V7M) - __asm__ volatile ( - "msr basepri, %[level]\n" - : - : [level] "r" (level) - ); -#endif -} - -static inline void arm_interrupt_flash( uint32_t level ) -{ -#if defined(ARM_MULTILIB_ARCH_V4) - uint32_t arm_switch_reg; - - __asm__ volatile ( - ARM_SWITCH_TO_ARM - "mrs %[arm_switch_reg], cpsr\n" - "msr cpsr, %[level]\n" - "msr cpsr, %[arm_switch_reg]\n" - ARM_SWITCH_BACK - : [arm_switch_reg] "=&r" (arm_switch_reg) - : [level] "r" (level) - ); -#elif defined(ARM_MULTILIB_ARCH_V7M) - uint32_t basepri; - - __asm__ volatile ( - "mrs %[basepri], basepri\n" - "msr basepri, %[level]\n" - "msr basepri, %[basepri]\n" - : [basepri] "=&r" (basepri) - : [level] "r" (level) - ); -#endif -} - -#define _CPU_ISR_Disable( _isr_cookie ) \ - do { \ - _isr_cookie = arm_interrupt_disable(); \ - } while (0) - -#define _CPU_ISR_Enable( _isr_cookie ) \ - arm_interrupt_enable( _isr_cookie ) - -#define _CPU_ISR_Flash( _isr_cookie ) \ - arm_interrupt_flash( _isr_cookie ) - -RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) -{ -#if defined(ARM_MULTILIB_ARCH_V4) - return ( level & 0x80 ) == 0; -#elif defined(ARM_MULTILIB_ARCH_V7M) - return level == 0; -#endif -} - -void _CPU_ISR_Set_level( uint32_t level ); - -uint32_t _CPU_ISR_Get_level( void ); - -void _CPU_Context_Initialize( - Context_Control *the_context, - void *stack_area_begin, - size_t stack_area_size, - uint32_t new_level, - void (*entry_point)( void ), - bool is_fp, - void *tls_area -); - -#define _CPU_Context_Get_SP( _context ) \ - (_context)->register_sp - -#ifdef RTEMS_SMP - static inline bool _CPU_Context_Get_is_executing( - const Context_Control *context - ) - { - return context->is_executing; - } - - static inline void _CPU_Context_Set_is_executing( - Context_Control *context, - bool is_executing - ) - { - context->is_executing = is_executing; - } -#endif - -#define _CPU_Context_Restart_self( _the_context ) \ - _CPU_Context_restore( (_the_context) ); - -#define _CPU_Context_Initialize_fp( _destination ) \ - do { \ - *(*(_destination)) = _CPU_Null_fp_context; \ - } while (0) - -#define _CPU_Fatal_halt( _source, _err ) \ - do { \ - uint32_t _level; \ - uint32_t _error = _err; \ - _CPU_ISR_Disable( _level ); \ - (void) _level; \ - __asm__ volatile ("mov r0, %0\n" \ - : "=r" (_error) \ - : "0" (_error) \ - : "r0" ); \ - while (1); \ - } while (0); - -/** - * @brief CPU initialization. - */ -void _CPU_Initialize( void ); - -void _CPU_ISR_install_vector( - uint32_t vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -/** - * @brief CPU switch context. - */ -void _CPU_Context_switch( Context_Control *run, Context_Control *heir ); - -void _CPU_Context_restore( Context_Control *new_context ) - RTEMS_NO_RETURN; - -#if defined(ARM_MULTILIB_ARCH_V7M) - void _ARMV7M_Start_multitasking( Context_Control *heir ) - RTEMS_NO_RETURN; - #define _CPU_Start_multitasking _ARMV7M_Start_multitasking -#endif - -void _CPU_Context_volatile_clobber( uintptr_t pattern ); - -void _CPU_Context_validate( uintptr_t pattern ); - -#ifdef RTEMS_SMP - uint32_t _CPU_SMP_Initialize( void ); - - bool _CPU_SMP_Start_processor( uint32_t cpu_index ); - - void _CPU_SMP_Finalize_initialization( uint32_t cpu_count ); - - void _CPU_SMP_Prepare_start_multitasking( void ); - - static inline uint32_t _CPU_SMP_Get_current_processor( void ) - { - uint32_t mpidr; - - /* Use ARMv7 Multiprocessor Affinity Register (MPIDR) */ - __asm__ volatile ( - "mrc p15, 0, %[mpidr], c0, c0, 5\n" - : [mpidr] "=&r" (mpidr) - ); - - return mpidr & 0xffU; - } - - void _CPU_SMP_Send_interrupt( uint32_t target_processor_index ); - - static inline void _ARM_Send_event( void ) - { - __asm__ volatile ( "sev" : : : "memory" ); - } - - static inline void _ARM_Wait_for_event( void ) - { - __asm__ volatile ( "wfe" : : : "memory" ); - } - - static inline void _CPU_SMP_Processor_event_broadcast( void ) - { - _ARM_Data_synchronization_barrier(); - _ARM_Send_event(); - } - - static inline void _CPU_SMP_Processor_event_receive( void ) - { - _ARM_Wait_for_event(); - _ARM_Data_memory_barrier(); - } -#endif - - -static inline uint32_t CPU_swap_u32( uint32_t value ) -{ -#if defined(__thumb2__) - __asm__ volatile ( - "rev %0, %0" - : "=r" (value) - : "0" (value) - ); - return value; -#elif defined(__thumb__) - uint32_t byte1, byte2, byte3, byte4, swapped; - - byte4 = (value >> 24) & 0xff; - byte3 = (value >> 16) & 0xff; - byte2 = (value >> 8) & 0xff; - byte1 = value & 0xff; - - swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4; - return swapped; -#else - uint32_t tmp = value; /* make compiler warnings go away */ - __asm__ volatile ("EOR %1, %0, %0, ROR #16\n" - "BIC %1, %1, #0xff0000\n" - "MOV %0, %0, ROR #8\n" - "EOR %0, %0, %1, LSR #8\n" - : "=r" (value), "=r" (tmp) - : "0" (value), "1" (tmp)); - return value; -#endif -} - -static inline uint16_t CPU_swap_u16( uint16_t value ) -{ -#if defined(__thumb2__) - __asm__ volatile ( - "rev16 %0, %0" - : "=r" (value) - : "0" (value) - ); - return value; -#else - return (uint16_t) (((value & 0xffU) << 8) | ((value >> 8) & 0xffU)); -#endif -} - -typedef uint32_t CPU_Counter_ticks; - -CPU_Counter_ticks _CPU_Counter_read( void ); - -CPU_Counter_ticks _CPU_Counter_difference( - CPU_Counter_ticks second, - CPU_Counter_ticks first -); - -#if CPU_PROVIDES_IDLE_THREAD_BODY == TRUE - void *_CPU_Thread_Idle_body( uintptr_t ignored ); -#endif - -/** @} */ - -/** - * @addtogroup ScoreCPUARM - */ -/**@{**/ - -#if defined(ARM_MULTILIB_ARCH_V4) - -typedef enum { - ARM_EXCEPTION_RESET = 0, - ARM_EXCEPTION_UNDEF = 1, - ARM_EXCEPTION_SWI = 2, - ARM_EXCEPTION_PREF_ABORT = 3, - ARM_EXCEPTION_DATA_ABORT = 4, - ARM_EXCEPTION_RESERVED = 5, - ARM_EXCEPTION_IRQ = 6, - ARM_EXCEPTION_FIQ = 7, - MAX_EXCEPTIONS = 8, - ARM_EXCEPTION_MAKE_ENUM_32_BIT = 0xffffffff -} Arm_symbolic_exception_name; - -#endif /* defined(ARM_MULTILIB_ARCH_V4) */ - -typedef struct { - uint32_t register_fpexc; - uint32_t register_fpscr; - uint64_t register_d0; - uint64_t register_d1; - uint64_t register_d2; - uint64_t register_d3; - uint64_t register_d4; - uint64_t register_d5; - uint64_t register_d6; - uint64_t register_d7; - uint64_t register_d8; - uint64_t register_d9; - uint64_t register_d10; - uint64_t register_d11; - uint64_t register_d12; - uint64_t register_d13; - uint64_t register_d14; - uint64_t register_d15; - uint64_t register_d16; - uint64_t register_d17; - uint64_t register_d18; - uint64_t register_d19; - uint64_t register_d20; - uint64_t register_d21; - uint64_t register_d22; - uint64_t register_d23; - uint64_t register_d24; - uint64_t register_d25; - uint64_t register_d26; - uint64_t register_d27; - uint64_t register_d28; - uint64_t register_d29; - uint64_t register_d30; - uint64_t register_d31; -} ARM_VFP_context; - -typedef struct { - uint32_t register_r0; - uint32_t register_r1; - uint32_t register_r2; - uint32_t register_r3; - uint32_t register_r4; - uint32_t register_r5; - uint32_t register_r6; - uint32_t register_r7; - uint32_t register_r8; - uint32_t register_r9; - uint32_t register_r10; - uint32_t register_r11; - uint32_t register_r12; - uint32_t register_sp; - void *register_lr; - void *register_pc; -#if defined(ARM_MULTILIB_ARCH_V4) - uint32_t register_cpsr; - Arm_symbolic_exception_name vector; -#elif defined(ARM_MULTILIB_ARCH_V6M) || defined(ARM_MULTILIB_ARCH_V7M) - uint32_t register_xpsr; - uint32_t vector; -#endif - const ARM_VFP_context *vfp_context; - uint32_t reserved_for_stack_alignment; -} CPU_Exception_frame; - -void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); - -void _ARM_Exception_default( CPU_Exception_frame *frame ); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ASM */ - -#endif /* _RTEMS_SCORE_CPU_H */ diff --git a/cpukit/score/cpu/arm/rtems/score/cpu_asm.h b/cpukit/score/cpu/arm/rtems/score/cpu_asm.h deleted file mode 100644 index c430911373..0000000000 --- a/cpukit/score/cpu/arm/rtems/score/cpu_asm.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @file - * - * @ingroup ScoreCPU - * - * @brief ARM Assembler Support API - */ - -/* - * COPYRIGHT (c) 2002 by Advent Networks, Inc. - * Jay Monkman - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - * - * This file is the include file for cpu_asm.S - */ - -#ifndef _RTEMS_SCORE_CPU_ASM_H -#define _RTEMS_SCORE_CPU_ASM_H - - -/* Registers saved in context switch: */ -.set REG_CPSR, 0 -.set REG_R4, 4 -.set REG_R5, 8 -.set REG_R6, 12 -.set REG_R7, 16 -.set REG_R8, 20 -.set REG_R9, 24 -.set REG_R10, 28 -.set REG_R11, 32 -.set REG_SP, 36 -.set REG_LR, 40 -.set REG_PC, 44 -.set SIZE_REGS, REG_PC + 4 - -#endif diff --git a/cpukit/score/cpu/arm/rtems/score/cpuatomic.h b/cpukit/score/cpu/arm/rtems/score/cpuatomic.h deleted file mode 100644 index 598ee76b20..0000000000 --- a/cpukit/score/cpu/arm/rtems/score/cpuatomic.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * COPYRIGHT (c) 2012-2013 Deng Hengyi. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_ATOMIC_CPU_H -#define _RTEMS_SCORE_ATOMIC_CPU_H - -#include - -#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/arm/rtems/score/cpuimpl.h b/cpukit/score/cpu/arm/rtems/score/cpuimpl.h deleted file mode 100644 index 0885c2ef39..0000000000 --- a/cpukit/score/cpu/arm/rtems/score/cpuimpl.h +++ /dev/null @@ -1,111 +0,0 @@ -/** - * @file - * - * @brief CPU Port Implementation API - */ - -/* - * Copyright (c) 2013, 2016 embedded brains GmbH - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPUIMPL_H -#define _RTEMS_SCORE_CPUIMPL_H - -#include - -#define CPU_PER_CPU_CONTROL_SIZE 0 - -#ifdef ARM_MULTILIB_ARCH_V4 - -#if defined(ARM_MULTILIB_VFP_D32) -#define CPU_INTERRUPT_FRAME_SIZE 240 -#elif defined(ARM_MULTILIB_VFP) -#define CPU_INTERRUPT_FRAME_SIZE 112 -#else -#define CPU_INTERRUPT_FRAME_SIZE 40 -#endif - -#endif /* ARM_MULTILIB_ARCH_V4 */ - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef ARM_MULTILIB_ARCH_V4 - -typedef struct { -#ifdef ARM_MULTILIB_VFP - uint32_t fpscr; -#ifdef ARM_MULTILIB_VFP_D32 - double d16; - double d17; - double d18; - double d19; - double d20; - double d21; - double d22; - double d23; - double d24; - double d25; - double d26; - double d27; - double d28; - double d29; - double d30; - double d31; -#endif /* ARM_MULTILIB_VFP_D32 */ - double d0; - double d1; - double d2; - double d3; - double d4; - double d5; - double d6; - double d7; -#endif /* ARM_MULTILIB_VFP */ - uint32_t r9; - uint32_t lr; - uint32_t r0; - uint32_t r1; - uint32_t r2; - uint32_t r3; - uint32_t return_pc; - uint32_t return_cpsr; - uint32_t r7; - uint32_t r12; -} CPU_Interrupt_frame; - -#ifdef RTEMS_SMP - -static inline struct Per_CPU_Control *_ARM_Get_current_per_CPU_control( void ) -{ - struct Per_CPU_Control *cpu_self; - - /* Use PL1 only Thread ID Register (TPIDRPRW) */ - __asm__ volatile ( - "mrc p15, 0, %0, c13, c0, 4" - : "=r" ( cpu_self ) - ); - - return cpu_self; -} - -#define _CPU_Get_current_per_CPU_control() _ARM_Get_current_per_CPU_control() - -#endif /* RTEMS_SMP */ - -#endif /* ARM_MULTILIB_ARCH_V4 */ - -#ifdef __cplusplus -} -#endif - -#endif /* ASM */ - -#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/arm/rtems/score/types.h b/cpukit/score/cpu/arm/rtems/score/types.h deleted file mode 100644 index 37a56df029..0000000000 --- a/cpukit/score/cpu/arm/rtems/score/types.h +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @file - * - * @brief ARM Architecture Types API - */ - -/* - * This include file contains type definitions pertaining to the - * arm processor family. - * - * COPYRIGHT (c) 2000 Canon Research Centre France SA. - * Emmanuel Raguet, mailto:raguet@crf.canon.fr - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - * - */ - -#ifndef _RTEMS_SCORE_TYPES_H -#define _RTEMS_SCORE_TYPES_H - -#include - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ScoreCPU - */ -/**@{**/ - -/* - * This section defines the basic types for this processor. - */ - -/** Type that can store a 32-bit integer or a pointer. */ -typedef uintptr_t CPU_Uint32ptr; - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* !ASM */ - -#endif diff --git a/cpukit/score/cpu/bfin/Makefile.am b/cpukit/score/cpu/bfin/Makefile.am index 8fa75df995..3d7483a220 100644 --- a/cpukit/score/cpu/bfin/Makefile.am +++ b/cpukit/score/cpu/bfin/Makefile.am @@ -1,26 +1,10 @@ include $(top_srcdir)/automake/compile.am -include_rtemsdir = $(includedir)/rtems -include_rtems_HEADERS = rtems/asm.h - -include_rtems_bfindir = $(includedir)/rtems/bfin -include_rtems_bfin_HEADERS = rtems/bfin/bfin.h -include_rtems_bfin_HEADERS += rtems/bfin/bf533.h -include_rtems_bfin_HEADERS += rtems/bfin/bf52x.h - -include_rtems_scoredir = $(includedir)/rtems/score -include_rtems_score_HEADERS = rtems/score/cpu.h -include_rtems_score_HEADERS += rtems/score/cpuimpl.h -include_rtems_score_HEADERS += rtems/score/bfin.h -include_rtems_score_HEADERS += rtems/score/cpu_asm.h -include_rtems_score_HEADERS += rtems/score/types.h -include_rtems_score_HEADERS += rtems/score/cpuatomic.h - noinst_LIBRARIES = libscorecpu.a libscorecpu_a_SOURCES = cpu.c cpu_asm.S libscorecpu_a_SOURCES += ../no_cpu/cpucounterread.c libscorecpu_a_SOURCES += bfin-exception-frame-print.c libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS) -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am +include $(srcdir)/headers.am diff --git a/cpukit/score/cpu/bfin/headers.am b/cpukit/score/cpu/bfin/headers.am new file mode 100644 index 0000000000..b9eba7b181 --- /dev/null +++ b/cpukit/score/cpu/bfin/headers.am @@ -0,0 +1,24 @@ +## This file was generated by "./boostrap -H". + +include_machinedir = $(includedir)/machine +include_machine_HEADERS = +include_machine_HEADERS += include/machine/elf_machdep.h + +include_rtemsdir = $(includedir)/rtems +include_rtems_HEADERS = +include_rtems_HEADERS += include/rtems/asm.h + +include_rtems_bfindir = $(includedir)/rtems/bfin +include_rtems_bfin_HEADERS = +include_rtems_bfin_HEADERS += include/rtems/bfin/bf52x.h +include_rtems_bfin_HEADERS += include/rtems/bfin/bf533.h +include_rtems_bfin_HEADERS += include/rtems/bfin/bfin.h + +include_rtems_scoredir = $(includedir)/rtems/score +include_rtems_score_HEADERS = +include_rtems_score_HEADERS += include/rtems/score/bfin.h +include_rtems_score_HEADERS += include/rtems/score/cpu.h +include_rtems_score_HEADERS += include/rtems/score/cpu_asm.h +include_rtems_score_HEADERS += include/rtems/score/cpuatomic.h +include_rtems_score_HEADERS += include/rtems/score/cpuimpl.h +include_rtems_score_HEADERS += include/rtems/score/types.h diff --git a/cpukit/score/cpu/bfin/include/machine/elf_machdep.h b/cpukit/score/cpu/bfin/include/machine/elf_machdep.h new file mode 100644 index 0000000000..cf0dc19221 --- /dev/null +++ b/cpukit/score/cpu/bfin/include/machine/elf_machdep.h @@ -0,0 +1,28 @@ +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB + +#define ELF32_MACHDEP_ID_CASES \ + case EM_BLACKFIN: \ + break; + +#define ELF32_MACHDEP_ID EM_BLACKFIN + +#define ARCH_ELFSIZE 32 + +#define R_BFIN_UNUSED0 0 + +#define R_BFIN_RIMM16 5 +#define R_BFIN_LUIMM16 6 +#define R_BFIN_HUIMM16 7 +#define R_BFIN_PCREL12_JUMP_S 8 +#define R_BFIN_PCREL24_JUMP_X 9 +#define R_BFIN_PCREL24 10 +#define R_BFIN_PCREL24_JU 13 +#define R_BFIN_PCREL24_CALL_X 14 + +#define R_BFIN_BYTE_DATA 16 +#define R_BFIN_BYTE2_DATA 17 +#define R_BFIN_BYTE4_DATA 18 + + + +#define R_TYPE(name) __CONCAT(R_BFIN_,name) diff --git a/cpukit/score/cpu/bfin/include/rtems/asm.h b/cpukit/score/cpu/bfin/include/rtems/asm.h new file mode 100644 index 0000000000..5d133ddbdd --- /dev/null +++ b/cpukit/score/cpu/bfin/include/rtems/asm.h @@ -0,0 +1,127 @@ +/** + * @file + * + * @brief Address the Problems Caused by Incompatible Flavor of + * Assemblers and Toolsets + * + * This include file attempts to address the problems + * caused by incompatible flavors of assemblers and + * toolsets. It primarily addresses variations in the + * use of leading underscores on symbols and the requirement + * that register names be preceded by a %. + * + * @note The spacing in the use of these macros + * is critical to them working as advertised. + */ + +/* + * COPYRIGHT: + * + * This file is based on similar code found in newlib available + * from ftp.cygnus.com. The file which was used had no copyright + * notice. This file is freely distributable as long as the source + * of the file is noted. This file is: + * + * COPYRIGHT (c) 1994-2006. + * On-Line Applications Research Corporation (OAR). + */ + +#ifndef _RTEMS_ASM_H +#define _RTEMS_ASM_H + +/* + * Indicate we are in an assembly file and get the basic CPU definitions. + */ + +#ifndef ASM +#define ASM +#endif +#include +#include + +#ifndef __USER_LABEL_PREFIX__ +/** + * Recent versions of GNU cpp define variables which indicate the + * need for underscores and percents. If not using GNU cpp or + * the version does not support this, then you will obviously + * have to define these as appropriate. + * + * This symbol is prefixed to all C program symbols. + */ +#define __USER_LABEL_PREFIX__ _ +#endif + +#ifndef __REGISTER_PREFIX__ +/** + * Recent versions of GNU cpp define variables which indicate the + * need for underscores and percents. If not using GNU cpp or + * the version does not support this, then you will obviously + * have to define these as appropriate. + * + * This symbol is prefixed to all register names. + */ +#define __REGISTER_PREFIX__ +#endif + +#include + +/** Use the right prefix for global labels. */ +#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) + +/** Use the right prefix for registers. */ +#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) + +/* + * define macros for all of the registers on this CPU + * + * EXAMPLE: #define d0 REG (d0) + */ + +/* + * Define macros to handle section beginning and ends. + */ + + +/** This macro is used to denote the beginning of a code declaration. */ +#define BEGIN_CODE_DCL .text +/** This macro is used to denote the end of a code declaration. */ +#define END_CODE_DCL +/** This macro is used to denote the beginning of a data declaration section. */ +#define BEGIN_DATA_DCL .data +/** This macro is used to denote the end of a data declaration section. */ +#define END_DATA_DCL +/** This macro is used to denote the beginning of a code section. */ +#define BEGIN_CODE .text +/** This macro is used to denote the end of a code section. */ +#define END_CODE +/** This macro is used to denote the beginning of a data section. */ +#define BEGIN_DATA +/** This macro is used to denote the end of a data section. */ +#define END_DATA +/** + * This macro is used to denote the beginning of the + * unitialized data section. + */ +#define BEGIN_BSS +/** This macro is used to denote the end of the unitialized data section. */ +#define END_BSS +/** This macro is used to denote the end of the assembly file. */ +#define END + +/** + * This macro is used to declare a public global symbol. + * + * @note This must be tailored for a particular flavor of the C compiler. + * They may need to put underscores in front of the symbols. + */ +#define PUBLIC(sym) .globl SYM (sym) + +/** + * This macro is used to prototype a public global symbol. + * + * @note This must be tailored for a particular flavor of the C compiler. + * They may need to put underscores in front of the symbols. + */ +#define EXTERN(sym) .globl SYM (sym) + +#endif diff --git a/cpukit/score/cpu/bfin/include/rtems/bfin/bf52x.h b/cpukit/score/cpu/bfin/include/rtems/bfin/bf52x.h new file mode 100644 index 0000000000..86142a6c62 --- /dev/null +++ b/cpukit/score/cpu/bfin/include/rtems/bfin/bf52x.h @@ -0,0 +1,430 @@ +/** + * @file + * + * @brief Basic MMR for the Blackfin 52x CPU + * + * This file defines basic MMR for the Blackfin 52x CPU. + * The MMR have been taken from the ADSP-BF52x Blackfin Processor + * Hardware Reference from Analog Devices. Mentioned Chapters + * refer to this Documentation. + * + * Based on bf533.h + */ + +/* + * COPYRIGHT (c) 2006. + * Atos Automacao Industrial LTDA. + * modified by Alain Schaefer + * and Antonio Giovanini + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + * + * Author: Rohan Kangralkar, ECE Department Northeastern University + * Date: 02/15/2011 + */ + +#ifndef _RTEMS_BFIN_52x_H +#define _RTEMS_BFIN_52x_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Clock and System Control Chapter 8 */ +#define PLL_CTL 0xFFC00000L +#define PLL_DIV 0xFFC00004L +#define VR_CTL 0xFFC00008L +#define PLL_STAT 0xFFC0000CL +#define PLL_LOCKCNT 0xFFC00010L +#define SWRST 0xFFC00100L +#define SYSCR 0xFFC00104L + +/* SPI Controller Chapter 10 */ +#define SPI_CTL 0xFFC00500L +#define SPI_FLG 0xFFC00504L +#define SPI_STAT 0xFFC00508L +#define SPI_TDBR 0xFFC0050CL +#define SPI_RDBR 0xFFC00510L +#define SPI_BAUD 0xFFC00514L +#define SPI_SHADOW 0xFFC00518L + +/* SPORT0 Controller */ +#define SPORT0_TCR1 0xFFC00800L +#define SPORT0_TCR2 0xFFC00804L +#define SPORT0_TCLKDIV 0xFFC00808L +#define SPORT0_TFSDIV 0xFFC0080CL +#define SPORT0_TX 0xFFC00810L +#define SPORT0_RX 0xFFC00818L +#define SPORT0_RCR1 0xFFC00820L +#define SPORT0_RCR2 0xFFC00824L +#define SPORT0_RCLKDIV 0xFFC00828L +#define SPORT0_RFSDIV 0xFFC0082CL +#define SPORT0_STAT 0xFFC00830L +#define SPORT0_CHNL 0xFFC00834L +#define SPORT0_MCMC1 0xFFC00838L +#define SPORT0_MCMC2 0xFFC0083CL +#define SPORT0_MTCS0 0xFFC00840L +#define SPORT0_MTCS1 0xFFC00844L +#define SPORT0_MTCS2 0xFFC00848L +#define SPORT0_MTCS3 0xFFC0084CL +#define SPORT0_MRCS0 0xFFC00850L +#define SPORT0_MRCS1 0xFFC00854L +#define SPORT0_MRCS2 0xFFC00858L +#define SPORT0_MRCS3 0xFFC0085CL + +/* Parallel Peripheral Interface (PPI) Chapter 11 */ + +#define PPI_CONTROL 0xFFC01000L +#define PPI_STATUS 0xFFC01004L +#define PPI_COUNT 0xFFC01008L +#define PPI_DELAY 0xFFC0100CL +#define PPI_FRAME 0xFFC01010L + +/********* PPI MASKS ***********/ +/* PPI_CONTROL Masks */ +#define PORT_EN 0x00000001 +#define PORT_DIR 0x00000002 +#define XFR_TYPE 0x0000000C +#define PORT_CFG 0x00000030 +#define FLD_SEL 0x00000040 +#define PACK_EN 0x00000080 +#define DMA32 0x00000100 +#define SKIP_EN 0x00000200 +#define SKIP_EO 0x00000400 +#define DLENGTH 0x00003800 +#define DLEN_8 0x0 +#define DLEN(x) (((x-9) & 0x07) << 11) +#define POL 0x0000C000 + +/* PPI_STATUS Masks */ +#define FLD 0x00000400 +#define FT_ERR 0x00000800 +#define OVR 0x00001000 +#define UNDR 0x00002000 +#define ERR_DET 0x00004000 +#define ERR_NCOR 0x00008000 + +/* SPORT1 Controller Chapter 12 */ +#define SPORT1_TCR1 0xFFC00900L +#define SPORT1_TCR2 0xFFC00904L +#define SPORT1_TCLKDIV 0xFFC00908L +#define SPORT1_TFSDIV 0xFFC0090CL +#define SPORT1_TX 0xFFC00910L +#define SPORT1_RX 0xFFC00918L +#define SPORT1_RCR1 0xFFC00920L +#define SPORT1_RCR2 0xFFC00924L +#define SPORT1_RCLKDIV 0xFFC00928L +#define SPORT1_RFSDIV 0xFFC0092CL +#define SPORT1_STAT 0xFFC00930L +#define SPORT1_CHNL 0xFFC00934L +#define SPORT1_MCMC1 0xFFC00938L +#define SPORT1_MCMC2 0xFFC0093CL +#define SPORT1_MTCS0 0xFFC00940L +#define SPORT1_MTCS1 0xFFC00944L +#define SPORT1_MTCS2 0xFFC00948L +#define SPORT1_MTCS3 0xFFC0094CL +#define SPORT1_MRCS0 0xFFC00950L +#define SPORT1_MRCS1 0xFFC00954L +#define SPORT1_MRCS2 0xFFC00958L +#define SPORT1_MRCS3 0xFFC0095CL + +/* SPORTx_TCR1 Masks */ +#define TSPEN 0x0001 +#define ITCLK 0x0002 +#define TDTYPE 0x000C +#define TLSBIT 0x0010 +#define ITFS 0x0200 +#define TFSR 0x0400 +#define DITFS 0x0800 +#define LTFS 0x1000 +#define LATFS 0x2000 +#define TCKFE 0x4000 + +/* SPORTx_TCR2 Masks */ +#define SLEN 0x001F +#define TXSE 0x0100 +#define TSFSE 0x0200 +#define TRFST 0x0400 + +/* SPORTx_RCR1 Masks */ +#define RSPEN 0x0001 +#define IRCLK 0x0002 +#define RDTYPE 0x000C +#define RULAW 0x0008 +#define RALAW 0x000C +#define RLSBIT 0x0010 +#define IRFS 0x0200 +#define RFSR 0x0400 +#define LRFS 0x1000 +#define LARFS 0x2000 +#define RCKFE 0x4000 + +/* SPORTx_RCR2 Masks */ +#define SLEN 0x001F +#define RXSE 0x0100 +#define RSFSE 0x0200 +#define RRFST 0x0400 + +/* SPORTx_STAT Masks */ +#define RXNE 0x0001 +#define RUVF 0x0002 +#define ROVF 0x0004 +#define TXF 0x0008 +#define TUVF 0x0010 +#define TOVF 0x0020 +#define TXHRE 0x0040 + +/* SPORTx_MCMC1 Masks */ +#define WSIZE 0x0000F000 +#define WOFF 0x000003FF + +/* SPORTx_MCMC2 Masks */ +#define MCCRM 0x00000003 +#define MCDTXPE 0x00000004 +#define MCDRXPE 0x00000008 +#define MCMEN 0x00000010 +#define FSDR 0x00000080 +#define MFD 0x0000F000 + +/* UART Controller Chapter 13 */ +#define UART_THR 0xFFC00400L +#define UART_RBR 0xFFC00400L +#define UART_DLL 0xFFC00400L +#define UART_IER 0xFFC00404L +#define UART_DLH 0xFFC00404L +#define UART_IIR 0xFFC00408L +#define UART_LCR 0xFFC0040CL +#define UART_MCR 0xFFC00410L +#define UART_LSR 0xFFC00414L +#define UART_SCR 0xFFC0041CL +#define UART_GCTL 0xFFC00424L + +/* + * UART CONTROLLER MASKS + */ + +/* UART_LCR */ +#define DLAB 0x80 +#define SB 0x40 +#define STP 0x20 +#define EPS 0x10 +#define PEN 0x08 +#define STB 0x04 +#define WLS(x) ((x-5) & 0x03) + +#define DLAB_P 0x07 +#define SB_P 0x06 +#define STP_P 0x05 +#define EPS_P 0x04 +#define PEN_P 0x03 +#define STB_P 0x02 +#define WLS_P1 0x01 +#define WLS_P0 0x00 + +/* UART_MCR */ +#define LOOP_ENA 0x10 +#define LOOP_ENA_P 0x04 + +/* UART_LSR */ +#define TEMT 0x40 +#define THRE 0x20 +#define BI 0x10 +#define FE 0x08 +#define PE 0x04 +#define OE 0x02 +#define DR 0x01 + +#define TEMP_P 0x06 +#define THRE_P 0x05 +#define BI_P 0x04 +#define FE_P 0x03 +#define PE_P 0x02 +#define OE_P 0x01 +#define DR_P 0x00 + +/* UART_IER */ +#define ELSI 0x04 +#define ETBEI 0x02 +#define ERBFI 0x01 + +#define ELSI_P 0x02 +#define ETBEI_P 0x01 +#define ERBFI_P 0x00 + +/* UART_IIR */ +#define STATUS(x) ((x << 1) & 0x06) +#define NINT 0x01 +#define STATUS_P1 0x02 +#define STATUS_P0 0x01 +#define NINT_P 0x00 + +/* UART_GCTL */ +#define FFE 0x20 +#define FPE 0x10 +#define RPOLC 0x08 +#define TPOLC 0x04 +#define IREN 0x02 +#define UCEN 0x01 + +#define FFE_P 0x05 +#define FPE_P 0x04 +#define RPOLC_P 0x03 +#define TPOLC_P 0x02 +#define IREN_P 0x01 +#define UCEN_P 0x00 + +/* General Purpose IO Chapter 14*/ +#define FIO_FLAG_D 0xFFC00700L +#define FIO_FLAG_C 0xFFC00704L +#define FIO_FLAG_S 0xFFC00708L +#define FIO_FLAG_T 0xFFC0070CL +#define FIO_MASKA_D 0xFFC00710L +#define FIO_MASKA_C 0xFFC00714L +#define FIO_MASKA_S 0xFFC00718L +#define FIO_MASKA_T 0xFFC0071CL +#define FIO_MASKB_D 0xFFC00720L +#define FIO_MASKB_C 0xFFC00724L +#define FIO_MASKB_S 0xFFC00728L +#define FIO_MASKB_T 0xFFC0072CL +#define FIO_DIR 0xFFC00730L +#define FIO_POLAR 0xFFC00734L +#define FIO_EDGE 0xFFC00738L +#define FIO_BOTH 0xFFC0073CL +#define FIO_INEN 0xFFC00740L + + +/* General Purpose IO Chapter 9*/ +#define PORTH_FER 0xFFC03208 +#define PORTH_MUX 0xFFC03218 +#define PORTHIO_DIR 0xFFC01730 +#define PORTHIO_INEN 0xFFC01740 +#define PORTHIO 0xFFC01700 +#define PORTHIO_SET 0xFFC01708 +#define PORTHIO_CLEAR 0xFFC01704 +#define PORTHIO_TOGGLE 0xFFC0170C + + +#define FIO_INEN 0xFFC00740L +#define FIO_POLAR 0xFFC00734L +#define FIO_EDGE 0xFFC00738L +#define FIO_BOTH 0xFFC0073CL + + + +#define FIO_FLAG_C 0xFFC00704L +#define FIO_FLAG_S 0xFFC00708L +#define FIO_FLAG_T 0xFFC0070CL +#define FIO_MASKA_D 0xFFC00710L +#define FIO_MASKA_C 0xFFC00714L +#define FIO_MASKA_S 0xFFC00718L +#define FIO_MASKA_T 0xFFC0071CL +#define FIO_MASKB_D 0xFFC00720L +#define FIO_MASKB_C 0xFFC00724L +#define FIO_MASKB_S 0xFFC00728L +#define FIO_MASKB_T 0xFFC0072CL + + +/* General Purpose IO Masks */ +#define PF0 0x0001 +#define PF1 0x0002 +#define PF2 0x0004 +#define PF3 0x0008 +#define PF4 0x0010 +#define PF5 0x0020 +#define PF6 0x0040 +#define PF7 0x0080 +#define PF8 0x0100 +#define PF9 0x0200 +#define PF10 0x0400 +#define PF11 0x0800 +#define PF12 0x1000 +#define PF13 0x2000 +#define PF14 0x4000 +#define PF15 0x8000 + + +/* TIMER 0, 1, 2 Chapter 15 */ +#define TIMER0_CONFIG 0xFFC00600L +#define TIMER0_COUNTER 0xFFC00604L +#define TIMER0_PERIOD 0xFFC00608L +#define TIMER0_WIDTH 0xFFC0060CL + +#define TIMER1_CONFIG 0xFFC00610L +#define TIMER1_COUNTER 0xFFC00614L +#define TIMER1_PERIOD 0xFFC00618L +#define TIMER1_WIDTH 0xFFC0061CL + +#define TIMER2_CONFIG 0xFFC00620L +#define TIMER2_COUNTER 0xFFC00624L +#define TIMER2_PERIOD 0xFFC00628L +#define TIMER2_WIDTH 0xFFC0062CL + +#define TIMER_ENABLE 0xFFC00640L +#define TIMER_DISABLE 0xFFC00644L +#define TIMER_STATUS 0xFFC00648L + +/* Real Time Clock Chapter 16 */ +#define RTC_STAT 0xFFC00300L +#define RTC_ICTL 0xFFC00304L +#define RTC_ISTAT 0xFFC00308L +#define RTC_SWCNT 0xFFC0030CL +#define RTC_ALARM 0xFFC00310L +#define RTC_FAST 0xFFC00314L +#define RTC_PREN 0xFFC00314L + +/* RTC_FAST Mask (RTC_PREN Mask) */ +#define ENABLE_PRESCALE 0x00000001 +#define PREN 0x00000001 + +/* Asynchronous Memory Controller EBUI, Chapter 17*/ +#define EBIU_AMGCTL 0xFFC00A00L +#define EBIU_AMBCTL0 0xFFC00A04L +#define EBIU_AMBCTL1 0xFFC00A08L + +/* SDRAM Controller External Bus Interface Unit */ + +#define EBIU_SDGCTL 0xFFC00A10L +#define EBIU_SDBCTL 0xFFC00A14L +#define EBIU_SDRRC 0xFFC00A18L +#define EBIU_SDSTAT 0xFFC00A1CL + + + + +/* DCPLB_DATA and ICPLB_DATA Registers */ +/*** Bit Positions */ +#define CPLB_VALID_P 0x00000000 /* 0=invalid entry, 1=valid entry */ +#define CPLB_LOCK_P 0x00000001 /* 0=entry may be replaced, 1=entry locked */ +#define CPLB_USER_RD_P 0x00000002 /* 0=no read access, 1=read access allowed (user mode) */ +/*** Masks */ +#define CPLB_VALID 0x00000001 /* 0=invalid entry, 1=valid entry */ +#define CPLB_LOCK 0x00000002 /* 0=entry may be replaced, 1=entry locked */ +#define CPLB_USER_RD 0x00000004 /* 0=no read access, 1=read access allowed (user mode) */ +#define PAGE_SIZE_1KB 0x00000000 /* 1 KB page size */ +#define PAGE_SIZE_4KB 0x00010000 /* 4 KB page size */ +#define PAGE_SIZE_1MB 0x00020000 /* 1 MB page size */ +#define PAGE_SIZE_4MB 0x00030000 /* 4 MB page size */ +#define CPLB_PORTPRIO 0x00000200 /* 0=low priority port, 1= high priority port */ +#define CPLB_L1_CHBL 0x00001000 /* 0=non-cacheable in L1, 1=cacheable in L1 */ +/*** ICPLB_DATA only */ +#define CPLB_LRUPRIO 0x00000100 /* 0=can be replaced by any line, 1=priority for non-replacement */ +/*** DCPLB_DATA only */ +#define CPLB_USER_WR 0x00000008 /* 0=no write access, 0=write access allowed (user mode) */ +#define CPLB_SUPV_WR 0x00000010 /* 0=no write access, 0=write access allowed (supervisor mode) */ +#define CPLB_DIRTY 0x00000080 /* 1=dirty, 0=clean */ +#define CPLB_L1_AOW 0x00008000 /* 0=do not allocate cache lines on write-through writes, */ + /* 1= allocate cache lines on write-through writes. */ +#define CPLB_WT 0x00004000 /* 0=write-back, 1=write-through */ + + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_SCORE_BFIN_H */ diff --git a/cpukit/score/cpu/bfin/include/rtems/bfin/bf533.h b/cpukit/score/cpu/bfin/include/rtems/bfin/bf533.h new file mode 100644 index 0000000000..682aad4bbb --- /dev/null +++ b/cpukit/score/cpu/bfin/include/rtems/bfin/bf533.h @@ -0,0 +1,396 @@ +/** + * @file + * + * @brief Basic MMR for the Blackfin 531/532/533 CPU + * + * This file defines basic MMR for the Blackfin 531/532/533 CPU. + * The MMR have been taken from the ADSP-BF533 Blackfin Processor + * Hardware Reference from Analog Devices. Mentioned Chapters + * refer to this Documentation. + * + * The Blackfins MMRs are divided into core MMRs (0xFFE0 0000–0xFFFF FFFF) + * and System MMRs (0xFFC0 0000–0xFFE0 0000). The core MMRs are defined + * in bfin.h which is included. + */ +/* + * COPYRIGHT (c) 2006. + * Atos Automacao Industrial LTDA. + * modified by Alain Schaefer + * and Antonio Giovanini + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + */ + +#ifndef _RTEMS_BFIN_533_H +#define _RTEMS_BFIN_533_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Clock and System Control Chapter 8 */ +#define PLL_CTL 0xFFC00000L +#define PLL_DIV 0xFFC00004L +#define VR_CTL 0xFFC00008L +#define PLL_STAT 0xFFC0000CL +#define PLL_LOCKCNT 0xFFC00010L +#define SWRST 0xFFC00100L +#define SYSCR 0xFFC00104L + +/* SPI Controller Chapter 10 */ +#define SPI_CTL 0xFFC00500L +#define SPI_FLG 0xFFC00504L +#define SPI_STAT 0xFFC00508L +#define SPI_TDBR 0xFFC0050CL +#define SPI_RDBR 0xFFC00510L +#define SPI_BAUD 0xFFC00514L +#define SPI_SHADOW 0xFFC00518L + +/* SPORT0 Controller */ +#define SPORT0_TCR1 0xFFC00800L +#define SPORT0_TCR2 0xFFC00804L +#define SPORT0_TCLKDIV 0xFFC00808L +#define SPORT0_TFSDIV 0xFFC0080CL +#define SPORT0_TX 0xFFC00810L +#define SPORT0_RX 0xFFC00818L +#define SPORT0_RCR1 0xFFC00820L +#define SPORT0_RCR2 0xFFC00824L +#define SPORT0_RCLKDIV 0xFFC00828L +#define SPORT0_RFSDIV 0xFFC0082CL +#define SPORT0_STAT 0xFFC00830L +#define SPORT0_CHNL 0xFFC00834L +#define SPORT0_MCMC1 0xFFC00838L +#define SPORT0_MCMC2 0xFFC0083CL +#define SPORT0_MTCS0 0xFFC00840L +#define SPORT0_MTCS1 0xFFC00844L +#define SPORT0_MTCS2 0xFFC00848L +#define SPORT0_MTCS3 0xFFC0084CL +#define SPORT0_MRCS0 0xFFC00850L +#define SPORT0_MRCS1 0xFFC00854L +#define SPORT0_MRCS2 0xFFC00858L +#define SPORT0_MRCS3 0xFFC0085CL + +/* Parallel Peripheral Interface (PPI) Chapter 11 */ + +#define PPI_CONTROL 0xFFC01000L +#define PPI_STATUS 0xFFC01004L +#define PPI_COUNT 0xFFC01008L +#define PPI_DELAY 0xFFC0100CL +#define PPI_FRAME 0xFFC01010L + +/********* PPI MASKS ***********/ +/* PPI_CONTROL Masks */ +#define PORT_EN 0x00000001 +#define PORT_DIR 0x00000002 +#define XFR_TYPE 0x0000000C +#define PORT_CFG 0x00000030 +#define FLD_SEL 0x00000040 +#define PACK_EN 0x00000080 +#define DMA32 0x00000100 +#define SKIP_EN 0x00000200 +#define SKIP_EO 0x00000400 +#define DLENGTH 0x00003800 +#define DLEN_8 0x0 +#define DLEN(x) (((x-9) & 0x07) << 11) +#define POL 0x0000C000 + +/* PPI_STATUS Masks */ +#define FLD 0x00000400 +#define FT_ERR 0x00000800 +#define OVR 0x00001000 +#define UNDR 0x00002000 +#define ERR_DET 0x00004000 +#define ERR_NCOR 0x00008000 + +/* SPORT1 Controller Chapter 12 */ +#define SPORT1_TCR1 0xFFC00900L +#define SPORT1_TCR2 0xFFC00904L +#define SPORT1_TCLKDIV 0xFFC00908L +#define SPORT1_TFSDIV 0xFFC0090CL +#define SPORT1_TX 0xFFC00910L +#define SPORT1_RX 0xFFC00918L +#define SPORT1_RCR1 0xFFC00920L +#define SPORT1_RCR2 0xFFC00924L +#define SPORT1_RCLKDIV 0xFFC00928L +#define SPORT1_RFSDIV 0xFFC0092CL +#define SPORT1_STAT 0xFFC00930L +#define SPORT1_CHNL 0xFFC00934L +#define SPORT1_MCMC1 0xFFC00938L +#define SPORT1_MCMC2 0xFFC0093CL +#define SPORT1_MTCS0 0xFFC00940L +#define SPORT1_MTCS1 0xFFC00944L +#define SPORT1_MTCS2 0xFFC00948L +#define SPORT1_MTCS3 0xFFC0094CL +#define SPORT1_MRCS0 0xFFC00950L +#define SPORT1_MRCS1 0xFFC00954L +#define SPORT1_MRCS2 0xFFC00958L +#define SPORT1_MRCS3 0xFFC0095CL + +/* SPORTx_TCR1 Masks */ +#define TSPEN 0x0001 +#define ITCLK 0x0002 +#define TDTYPE 0x000C +#define TLSBIT 0x0010 +#define ITFS 0x0200 +#define TFSR 0x0400 +#define DITFS 0x0800 +#define LTFS 0x1000 +#define LATFS 0x2000 +#define TCKFE 0x4000 + +/* SPORTx_TCR2 Masks */ +#define SLEN 0x001F +#define TXSE 0x0100 +#define TSFSE 0x0200 +#define TRFST 0x0400 + +/* SPORTx_RCR1 Masks */ +#define RSPEN 0x0001 +#define IRCLK 0x0002 +#define RDTYPE 0x000C +#define RULAW 0x0008 +#define RALAW 0x000C +#define RLSBIT 0x0010 +#define IRFS 0x0200 +#define RFSR 0x0400 +#define LRFS 0x1000 +#define LARFS 0x2000 +#define RCKFE 0x4000 + +/* SPORTx_RCR2 Masks */ +#define SLEN 0x001F +#define RXSE 0x0100 +#define RSFSE 0x0200 +#define RRFST 0x0400 + +/* SPORTx_STAT Masks */ +#define RXNE 0x0001 +#define RUVF 0x0002 +#define ROVF 0x0004 +#define TXF 0x0008 +#define TUVF 0x0010 +#define TOVF 0x0020 +#define TXHRE 0x0040 + +/* SPORTx_MCMC1 Masks */ +#define WSIZE 0x0000F000 +#define WOFF 0x000003FF + +/* SPORTx_MCMC2 Masks */ +#define MCCRM 0x00000003 +#define MCDTXPE 0x00000004 +#define MCDRXPE 0x00000008 +#define MCMEN 0x00000010 +#define FSDR 0x00000080 +#define MFD 0x0000F000 + +/* UART Controller Chapter 13 */ +#define UART_THR 0xFFC00400L +#define UART_RBR 0xFFC00400L +#define UART_DLL 0xFFC00400L +#define UART_IER 0xFFC00404L +#define UART_DLH 0xFFC00404L +#define UART_IIR 0xFFC00408L +#define UART_LCR 0xFFC0040CL +#define UART_MCR 0xFFC00410L +#define UART_LSR 0xFFC00414L +#define UART_SCR 0xFFC0041CL +#define UART_GCTL 0xFFC00424L + +/* + * UART CONTROLLER MASKS + */ + +/* UART_LCR */ +#define DLAB 0x80 +#define SB 0x40 +#define STP 0x20 +#define EPS 0x10 +#define PEN 0x08 +#define STB 0x04 +#define WLS(x) ((x-5) & 0x03) + +#define DLAB_P 0x07 +#define SB_P 0x06 +#define STP_P 0x05 +#define EPS_P 0x04 +#define PEN_P 0x03 +#define STB_P 0x02 +#define WLS_P1 0x01 +#define WLS_P0 0x00 + +/* UART_MCR */ +#define LOOP_ENA 0x10 +#define LOOP_ENA_P 0x04 + +/* UART_LSR */ +#define TEMT 0x40 +#define THRE 0x20 +#define BI 0x10 +#define FE 0x08 +#define PE 0x04 +#define OE 0x02 +#define DR 0x01 + +#define TEMP_P 0x06 +#define THRE_P 0x05 +#define BI_P 0x04 +#define FE_P 0x03 +#define PE_P 0x02 +#define OE_P 0x01 +#define DR_P 0x00 + +/* UART_IER */ +#define ELSI 0x04 +#define ETBEI 0x02 +#define ERBFI 0x01 + +#define ELSI_P 0x02 +#define ETBEI_P 0x01 +#define ERBFI_P 0x00 + +/* UART_IIR */ +#define STATUS(x) ((x << 1) & 0x06) +#define NINT 0x01 +#define STATUS_P1 0x02 +#define STATUS_P0 0x01 +#define NINT_P 0x00 + +/* UART_GCTL */ +#define FFE 0x20 +#define FPE 0x10 +#define RPOLC 0x08 +#define TPOLC 0x04 +#define IREN 0x02 +#define UCEN 0x01 + +#define FFE_P 0x05 +#define FPE_P 0x04 +#define RPOLC_P 0x03 +#define TPOLC_P 0x02 +#define IREN_P 0x01 +#define UCEN_P 0x00 + +/* General Purpose IO Chapter 14*/ +#define FIO_FLAG_D 0xFFC00700L +#define FIO_FLAG_C 0xFFC00704L +#define FIO_FLAG_S 0xFFC00708L +#define FIO_FLAG_T 0xFFC0070CL +#define FIO_MASKA_D 0xFFC00710L +#define FIO_MASKA_C 0xFFC00714L +#define FIO_MASKA_S 0xFFC00718L +#define FIO_MASKA_T 0xFFC0071CL +#define FIO_MASKB_D 0xFFC00720L +#define FIO_MASKB_C 0xFFC00724L +#define FIO_MASKB_S 0xFFC00728L +#define FIO_MASKB_T 0xFFC0072CL +#define FIO_DIR 0xFFC00730L +#define FIO_POLAR 0xFFC00734L +#define FIO_EDGE 0xFFC00738L +#define FIO_BOTH 0xFFC0073CL +#define FIO_INEN 0xFFC00740L + +/* General Purpose IO Masks */ +#define PF0 0x0001 +#define PF1 0x0002 +#define PF2 0x0004 +#define PF3 0x0008 +#define PF4 0x0010 +#define PF5 0x0020 +#define PF6 0x0040 +#define PF7 0x0080 +#define PF8 0x0100 +#define PF9 0x0200 +#define PF10 0x0400 +#define PF11 0x0800 +#define PF12 0x1000 +#define PF13 0x2000 +#define PF14 0x4000 +#define PF15 0x8000 + + +/* TIMER 0, 1, 2 Chapter 15 */ +#define TIMER0_CONFIG 0xFFC00600L +#define TIMER0_COUNTER 0xFFC00604L +#define TIMER0_PERIOD 0xFFC00608L +#define TIMER0_WIDTH 0xFFC0060CL + +#define TIMER1_CONFIG 0xFFC00610L +#define TIMER1_COUNTER 0xFFC00614L +#define TIMER1_PERIOD 0xFFC00618L +#define TIMER1_WIDTH 0xFFC0061CL + +#define TIMER2_CONFIG 0xFFC00620L +#define TIMER2_COUNTER 0xFFC00624L +#define TIMER2_PERIOD 0xFFC00628L +#define TIMER2_WIDTH 0xFFC0062CL + +#define TIMER_ENABLE 0xFFC00640L +#define TIMER_DISABLE 0xFFC00644L +#define TIMER_STATUS 0xFFC00648L + +/* Real Time Clock Chapter 16 */ +#define RTC_STAT 0xFFC00300L +#define RTC_ICTL 0xFFC00304L +#define RTC_ISTAT 0xFFC00308L +#define RTC_SWCNT 0xFFC0030CL +#define RTC_ALARM 0xFFC00310L +#define RTC_FAST 0xFFC00314L +#define RTC_PREN 0xFFC00314L + +/* RTC_FAST Mask (RTC_PREN Mask) */ +#define ENABLE_PRESCALE 0x00000001 +#define PREN 0x00000001 + +/* Asynchronous Memory Controller EBUI, Chapter 17*/ +#define EBIU_AMGCTL 0xFFC00A00L +#define EBIU_AMBCTL0 0xFFC00A04L +#define EBIU_AMBCTL1 0xFFC00A08L + +/* SDRAM Controller External Bus Interface Unit */ + +#define EBIU_SDGCTL 0xFFC00A10L +#define EBIU_SDBCTL 0xFFC00A14L +#define EBIU_SDRRC 0xFFC00A18L +#define EBIU_SDSTAT 0xFFC00A1CL + + + + +/* DCPLB_DATA and ICPLB_DATA Registers */ +/*** Bit Positions */ +#define CPLB_VALID_P 0x00000000 /* 0=invalid entry, 1=valid entry */ +#define CPLB_LOCK_P 0x00000001 /* 0=entry may be replaced, 1=entry locked */ +#define CPLB_USER_RD_P 0x00000002 /* 0=no read access, 1=read access allowed (user mode) */ +/*** Masks */ +#define CPLB_VALID 0x00000001 /* 0=invalid entry, 1=valid entry */ +#define CPLB_LOCK 0x00000002 /* 0=entry may be replaced, 1=entry locked */ +#define CPLB_USER_RD 0x00000004 /* 0=no read access, 1=read access allowed (user mode) */ +#define PAGE_SIZE_1KB 0x00000000 /* 1 KB page size */ +#define PAGE_SIZE_4KB 0x00010000 /* 4 KB page size */ +#define PAGE_SIZE_1MB 0x00020000 /* 1 MB page size */ +#define PAGE_SIZE_4MB 0x00030000 /* 4 MB page size */ +#define CPLB_PORTPRIO 0x00000200 /* 0=low priority port, 1= high priority port */ +#define CPLB_L1_CHBL 0x00001000 /* 0=non-cacheable in L1, 1=cacheable in L1 */ +/*** ICPLB_DATA only */ +#define CPLB_LRUPRIO 0x00000100 /* 0=can be replaced by any line, 1=priority for non-replacement */ +/*** DCPLB_DATA only */ +#define CPLB_USER_WR 0x00000008 /* 0=no write access, 0=write access allowed (user mode) */ +#define CPLB_SUPV_WR 0x00000010 /* 0=no write access, 0=write access allowed (supervisor mode) */ +#define CPLB_DIRTY 0x00000080 /* 1=dirty, 0=clean */ +#define CPLB_L1_AOW 0x00008000 /* 0=do not allocate cache lines on write-through writes, */ + /* 1= allocate cache lines on write-through writes. */ +#define CPLB_WT 0x00004000 /* 0=write-back, 1=write-through */ + + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_SCORE_BFIN_H */ diff --git a/cpukit/score/cpu/bfin/include/rtems/bfin/bfin.h b/cpukit/score/cpu/bfin/include/rtems/bfin/bfin.h new file mode 100644 index 0000000000..4ba0b2b295 --- /dev/null +++ b/cpukit/score/cpu/bfin/include/rtems/bfin/bfin.h @@ -0,0 +1,88 @@ +/** + * @file + * + * @brief Macros for MMR register common to all Blackfin Processors + * + * This file defines Macros for MMR register common to all Blackfin + * Processors. + */ + +/* + * COPYRIGHT (c) 2006 by Atos Automacao Industrial Ltda. + * modified by Alain Schaefer + * and Antonio Giovanini + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + */ + +#ifndef _RTEMS_BFIN_BFIN_H +#define _RTEMS_BFIN_BFIN_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Scratchpad SRAM */ + +#define SCRATCH 0xFFB00000 +#define SCRATCH_SIZE 0x1000 +#define SCRATCH_TOP 0xFFB00ffc + + +/* System Interrupt Controller Chapter 4*/ +#define SIC_RVECT 0xFFC00108 +#define SIC_IMASK 0xFFC0010C +#define SIC_IAR0 0xFFC00110 +#define SIC_IAR1 0xFFC00114 +#define SIC_IAR2 0xFFC00118 +#define SIC_ISR 0xFFC00120 +#define SIC_IWR 0xFFC00124 + +/* Event Vector Table Chapter 4 */ + +#define EVT0 0xFFE02000 +#define EVT1 0xFFE02004 +#define EVT2 0xFFE02008 +#define EVT3 0xFFE0200C +#define EVT4 0xFFE02010 +#define EVT5 0xFFE02014 +#define EVT6 0xFFE02018 +#define EVT7 0xFFE0201C +#define EVT8 0xFFE02020 +#define EVT9 0xFFE02024 +#define EVT10 0xFFE02028 +#define EVT11 0xFFE0202C +#define EVT12 0xFFE02030 +#define EVT13 0xFFE02034 +#define EVT14 0xFFE02038 +#define EVT15 0xFFE0203C +#define IMASK 0xFFE02104 +#define IPEND 0xFFE02108 +#define ILAT 0xFFE0210C +#define IPRIO 0xFFE02110 + + +#define TCNTL 0xFFE03000 +#define TPERIOD 0xFFE03004 +#define TSCALE 0xFFE03008 +#define TCOUNT 0xFFE0300C + +/* Masks for Timer Control */ +#define TMPWR 0x00000001 +#define TMREN 0x00000002 +#define TAUTORLD 0x00000004 +#define TINT 0x00000008 + +/* Event Bit Positions */ +#define EVT_IVTMR_P 0x00000006 + +#define EVT_IVTMR (1 << EVT_IVTMR_P) + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_SCORE_BFIN_H */ diff --git a/cpukit/score/cpu/bfin/include/rtems/score/bfin.h b/cpukit/score/cpu/bfin/include/rtems/score/bfin.h new file mode 100644 index 0000000000..caa3a51830 --- /dev/null +++ b/cpukit/score/cpu/bfin/include/rtems/score/bfin.h @@ -0,0 +1,69 @@ +/** + * @file + * + * @brief Blackfin Set up Basic CPU Dependency Settings Based on + * Compiler Settings + * + * This file sets up basic CPU dependency settings based on + * compiler settings. For example, it can determine if + * floating point is available. This particular implementation + * is specified to the Blackfin port. + */ + +/* + * + * COPYRIGHT (c) 1989-2006. + * On-Line Applications Research Corporation (OAR). + * modified by Alain Schaefer + * and Antonio Giovanini + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + */ + +#ifndef _RTEMS_SCORE_BFIN_H +#define _RTEMS_SCORE_BFIN_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * This file contains the information required to build + * RTEMS for a particular member of the Blackfin family. + * It does this by setting variables to indicate which + * implementation dependent features are present in a particular + * member of the family. + * + * This is a good place to list all the known CPU models + * that this port supports and which RTEMS CPU model they correspond + * to. + */ + +/* + * Figure out all CPU Model Feature Flags based upon compiler + * predefines. + */ +#if defined(__BFIN__) +#define CPU_MODEL_NAME "BF533" +#define BF_HAS_FPU 0 +#else + +#error "Unsupported CPU Model" + +#endif + +/* + * Define the name of the CPU family. + */ + +#define CPU_NAME "BFIN" + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_SCORE_BFIN_H */ diff --git a/cpukit/score/cpu/bfin/include/rtems/score/cpu.h b/cpukit/score/cpu/bfin/include/rtems/score/cpu.h new file mode 100644 index 0000000000..7c90fc6575 --- /dev/null +++ b/cpukit/score/cpu/bfin/include/rtems/score/cpu.h @@ -0,0 +1,1001 @@ +/** + * @file + * + * @brief Blackfin CPU Department Source + * + * This include file contains information pertaining to the Blackfin + * processor. + */ + +/* + * COPYRIGHT (c) 1989-2006. + * On-Line Applications Research Corporation (OAR). + * adapted to Blackfin by Alain Schaefer + * and Antonio Giovanini + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPU_H +#define _RTEMS_SCORE_CPU_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* conditional compilation parameters */ + +/** + * Does RTEMS manage a dedicated interrupt stack in software? + * + * If TRUE, then a stack is allocated in @ref _ISR_Handler_initialization. + * If FALSE, nothing is done. + * + * If the CPU supports a dedicated interrupt stack in hardware, + * then it is generally the responsibility of the BSP to allocate it + * and set it up. + * + * If the CPU does not support a dedicated interrupt stack, then + * the porter has two options: (1) execute interrupts on the + * stack of the interrupted task, and (2) have RTEMS manage a dedicated + * interrupt stack. + * + * If this is TRUE, @ref CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. + * + * Only one of @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK and + * @ref CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is + * possible that both are FALSE for a particular CPU. Although it + * is unclear what that would imply about the interrupt processing + * procedure on that CPU. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_HAS_SOFTWARE_INTERRUPT_STACK TRUE + +/* + * Does the CPU follow the simple vectored interrupt model? + * + * If TRUE, then RTEMS allocates the vector table it internally manages. + * If FALSE, then the BSP is assumed to allocate and manage the vector + * table + * + * BFIN Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_SIMPLE_VECTORED_INTERRUPTS TRUE + +/** + * Does this CPU have hardware support for a dedicated interrupt stack? + * + * If TRUE, then it must be installed during initialization. + * If FALSE, then no installation is performed. + * + * If this is TRUE, @ref CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. + * + * Only one of @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK and + * @ref CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is + * possible that both are FALSE for a particular CPU. Although it + * is unclear what that would imply about the interrupt processing + * procedure on that CPU. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE + +/** + * Does RTEMS allocate a dedicated interrupt stack in the Interrupt Manager? + * + * If TRUE, then the memory is allocated during initialization. + * If FALSE, then the memory is allocated during initialization. + * + * This should be TRUE is CPU_HAS_SOFTWARE_INTERRUPT_STACK is TRUE. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_ALLOCATE_INTERRUPT_STACK TRUE + +/** + * Does the RTEMS invoke the user's ISR with the vector number and + * a pointer to the saved interrupt frame (1) or just the vector + * number (0)? + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_ISR_PASSES_FRAME_POINTER TRUE + +/** + * @def CPU_HARDWARE_FP + * + * Does the CPU have hardware floating point? + * + * If TRUE, then the RTEMS_FLOATING_POINT task attribute is supported. + * If FALSE, then the RTEMS_FLOATING_POINT task attribute is ignored. + * + * If there is a FP coprocessor such as the i387 or mc68881, then + * the answer is TRUE. + * + * The macro name "NO_CPU_HAS_FPU" should be made CPU specific. + * It indicates whether or not this CPU model has FP support. For + * example, it would be possible to have an i386_nofp CPU model + * which set this to false to indicate that you have an i386 without + * an i387 and wish to leave floating point support out of RTEMS. + */ + +/** + * @def CPU_SOFTWARE_FP + * + * Does the CPU have no hardware floating point and GCC provides a + * software floating point implementation which must be context + * switched? + * + * This feature conditional is used to indicate whether or not there + * is software implemented floating point that must be context + * switched. The determination of whether or not this applies + * is very tool specific and the state saved/restored is also + * compiler specific. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#if ( BLACKFIN_CPU_HAS_FPU == 1 ) +#define CPU_HARDWARE_FP TRUE +#else +#define CPU_HARDWARE_FP FALSE +#endif +#define CPU_SOFTWARE_FP FALSE + +/** + * Are all tasks RTEMS_FLOATING_POINT tasks implicitly? + * + * If TRUE, then the RTEMS_FLOATING_POINT task attribute is assumed. + * If FALSE, then the RTEMS_FLOATING_POINT task attribute is followed. + * + * So far, the only CPUs in which this option has been used are the + * HP PA-RISC and PowerPC. On the PA-RISC, The HP C compiler and + * gcc both implicitly used the floating point registers to perform + * integer multiplies. Similarly, the PowerPC port of gcc has been + * seen to allocate floating point local variables and touch the FPU + * even when the flow through a subroutine (like vfprintf()) might + * not use floating point formats. + * + * If a function which you would not think utilize the FP unit DOES, + * then one can not easily predict which tasks will use the FP hardware. + * In this case, this option should be TRUE. + * + * If @ref CPU_HARDWARE_FP is FALSE, then this should be FALSE as well. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_ALL_TASKS_ARE_FP FALSE + +/** + * Should the IDLE task have a floating point context? + * + * If TRUE, then the IDLE task is created as a RTEMS_FLOATING_POINT task + * and it has a floating point context which is switched in and out. + * If FALSE, then the IDLE task does not have a floating point context. + * + * Setting this to TRUE negatively impacts the time required to preempt + * the IDLE task from an interrupt because the floating point context + * must be saved as part of the preemption. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_IDLE_TASK_IS_FP FALSE + +/** + * Should the saving of the floating point registers be deferred + * until a context switch is made to another different floating point + * task? + * + * If TRUE, then the floating point context will not be stored until + * necessary. It will remain in the floating point registers and not + * disturned until another floating point task is switched to. + * + * If FALSE, then the floating point context is saved when a floating + * point task is switched out and restored when the next floating point + * task is restored. The state of the floating point registers between + * those two operations is not specified. + * + * If the floating point context does NOT have to be saved as part of + * interrupt dispatching, then it should be safe to set this to TRUE. + * + * Setting this flag to TRUE results in using a different algorithm + * for deciding when to save and restore the floating point context. + * The deferred FP switch algorithm minimizes the number of times + * the FP context is saved and restored. The FP context is not saved + * until a context switch is made to another, different FP task. + * Thus in a system with only one FP task, the FP context will never + * be saved or restored. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_USE_DEFERRED_FP_SWITCH TRUE + +#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE + +/** + * Does this port provide a CPU dependent IDLE task implementation? + * + * If TRUE, then the routine @ref _CPU_Thread_Idle_body + * must be provided and is the default IDLE thread body instead of + * @ref _CPU_Thread_Idle_body. + * + * If FALSE, then use the generic IDLE thread body if the BSP does + * not provide one. + * + * This is intended to allow for supporting processors which have + * a low power or idle mode. When the IDLE thread is executed, then + * the CPU can be powered down. + * + * The order of precedence for selecting the IDLE thread body is: + * + * -# BSP provided + * -# CPU dependent (if provided) + * -# generic (if no BSP and no CPU dependent) + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_PROVIDES_IDLE_THREAD_BODY TRUE + +/** + * Does the stack grow up (toward higher addresses) or down + * (toward lower addresses)? + * + * If TRUE, then the grows upward. + * If FALSE, then the grows toward smaller addresses. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_STACK_GROWS_UP FALSE + +/* FIXME: Is this the right value? */ +#define CPU_CACHE_LINE_BYTES 32 + +#define CPU_STRUCTURE_ALIGNMENT + +/** + * @ingroup CPUInterrupt + * The following defines the number of bits actually used in the + * interrupt field of the task mode. How those bits map to the + * CPU interrupt levels is defined by the routine @ref _CPU_ISR_Set_level. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_MODES_INTERRUPT_MASK 0x00000001 + +#define CPU_MAXIMUM_PROCESSORS 32 + +/* + * Processor defined structures required for cpukit/score. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ + +/* may need to put some structures here. */ + +#ifndef ASM + +/** + * @defgroup CPUContext Processor Dependent Context Management + * + * From the highest level viewpoint, there are 2 types of context to save. + * + * -# Interrupt registers to save + * -# Task level registers to save + * + * Since RTEMS handles integer and floating point contexts separately, this + * means we have the following 3 context items: + * + * -# task level context stuff:: Context_Control + * -# floating point task stuff:: Context_Control_fp + * -# special interrupt level context :: CPU_Interrupt_frame + * + * On some processors, it is cost-effective to save only the callee + * preserved registers during a task context switch. This means + * that the ISR code needs to save those registers which do not + * persist across function calls. It is not mandatory to make this + * distinctions between the caller/callee saves registers for the + * purpose of minimizing context saved during task switch and on interrupts. + * If the cost of saving extra registers is minimal, simplicity is the + * choice. Save the same context on interrupt entry as for tasks in + * this case. + * + * Additionally, if gdb is to be made aware of RTEMS tasks for this CPU, then + * care should be used in designing the context area. + * + * On some CPUs with hardware floating point support, the Context_Control_fp + * structure will not be used or it simply consist of an array of a + * fixed number of bytes. This is done when the floating point context + * is dumped by a "FP save context" type instruction and the format + * is not really defined by the CPU. In this case, there is no need + * to figure out the exact format -- only the size. Of course, although + * this is enough information for RTEMS, it is probably not enough for + * a debugger such as gdb. But that is another problem. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +/**@{**/ + +/** + * This defines the minimal set of integer and processor state registers + * that must be saved during a voluntary context switch from one thread + * to another. + */ + +/* make sure this stays in sync with the assembly function + __CPU_Context_switch in cpu_asm.S */ +typedef struct { + uint32_t register_r4; + uint32_t register_r5; + uint32_t register_r6; + uint32_t register_r7; + + uint32_t register_p3; + uint32_t register_p4; + uint32_t register_p5; + uint32_t register_fp; + uint32_t register_sp; + + uint32_t register_rets; + + uint32_t imask; +} Context_Control; + +#define _CPU_Context_Get_SP( _context ) \ + (_context)->register_sp + +/** + * This defines the complete set of floating point registers that must + * be saved during any context switch from one thread to another. + */ +typedef struct { + /* FPU registers are listed here */ + /* Blackfin has no Floating Point */ +} Context_Control_fp; + +/** + * This defines the set of integer and processor state registers that must + * be saved during an interrupt. This set does not include any which are + * in @ref Context_Control. + */ +typedef struct { + /** This field is a hint that a port will have a number of integer + * registers that need to be saved when an interrupt occurs or + * when a context switch occurs at the end of an ISR. + */ + /*uint32_t special_interrupt_register;*/ +} CPU_Interrupt_frame; + +/** @} */ + +/** + * @defgroup CPUInterrupt Processor Dependent Interrupt Management + * + * On some CPUs, RTEMS supports a software managed interrupt stack. + * This stack is allocated by the Interrupt Manager and the switch + * is performed in @ref _ISR_Handler. These variables contain pointers + * to the lowest and highest addresses in the chunk of memory allocated + * for the interrupt stack. Since it is unknown whether the stack + * grows up or down (in general), this give the CPU dependent + * code the option of picking the version it wants to use. + * + * @note These two variables are required if the macro + * @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK is defined as TRUE. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +/**@{**/ + +/* + * Nothing prevents the porter from declaring more CPU specific variables. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ + +/* XXX: if needed, put more variables here */ + +/** + * @ingroup CPUContext + * The size of the floating point context area. On some CPUs this + * will not be a "sizeof" because the format of the floating point + * area is not defined -- only the size is. This is usually on + * CPUs with a "floating point save context" instruction. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp ) + +#endif /* ASM */ + +/** + * Amount of extra stack (above minimum stack size) required by + * MPCI receive server thread. Remember that in a multiprocessor + * system this thread must exist and be able to process all directives. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0 + +/** + * @ingroup CPUInterrupt + * This defines the number of entries in the @ref _ISR_Vector_table managed + * by RTEMS. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_INTERRUPT_NUMBER_OF_VECTORS 16 + +/** + * @ingroup CPUInterrupt + * This defines the highest interrupt vector number for this port. + */ +#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER (CPU_INTERRUPT_NUMBER_OF_VECTORS - 1) + +/** + * @ingroup CPUInterrupt + * This is defined if the port has a special way to report the ISR nesting + * level. Most ports maintain the variable @a _ISR_Nest_level. + */ +#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE + +/** @} */ + +/** + * @ingroup CPUContext + * Should be large enough to run all RTEMS tests. This ensures + * that a "reasonable" small application should not have any problems. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_STACK_MINIMUM_SIZE (1024*8) + +#define CPU_SIZEOF_POINTER 4 + +/** + * CPU's worst alignment requirement for data types on a byte boundary. This + * alignment does not take into account the requirements for the stack. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_ALIGNMENT 8 + +/** + * This number corresponds to the byte alignment requirement for the + * heap handler. This alignment requirement may be stricter than that + * for the data types alignment specified by @ref CPU_ALIGNMENT. It is + * common for the heap to follow the same alignment requirement as + * @ref CPU_ALIGNMENT. If the @ref CPU_ALIGNMENT is strict enough for + * the heap, then this should be set to @ref CPU_ALIGNMENT. + * + * @note This does not have to be a power of 2 although it should be + * a multiple of 2 greater than or equal to 2. The requirement + * to be a multiple of 2 is because the heap uses the least + * significant field of the front and back flags to indicate + * that a block is in use or free. So you do not want any odd + * length blocks really putting length data in that bit. + * + * On byte oriented architectures, @ref CPU_HEAP_ALIGNMENT normally will + * have to be greater or equal to than @ref CPU_ALIGNMENT to ensure that + * elements allocated from the heap meet all restrictions. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT + +/** + * This number corresponds to the byte alignment requirement for memory + * buffers allocated by the partition manager. This alignment requirement + * may be stricter than that for the data types alignment specified by + * @ref CPU_ALIGNMENT. It is common for the partition to follow the same + * alignment requirement as @ref CPU_ALIGNMENT. If the @ref CPU_ALIGNMENT is + * strict enough for the partition, then this should be set to + * @ref CPU_ALIGNMENT. + * + * @note This does not have to be a power of 2. It does have to + * be greater or equal to than @ref CPU_ALIGNMENT. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT + +/** + * This number corresponds to the byte alignment requirement for the + * stack. This alignment requirement may be stricter than that for the + * data types alignment specified by @ref CPU_ALIGNMENT. If the + * @ref CPU_ALIGNMENT is strict enough for the stack, then this should be + * set to 0. + * + * @note This must be a power of 2 either 0 or greater than @ref CPU_ALIGNMENT. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_STACK_ALIGNMENT 8 + +#ifndef ASM + +/* + * ISR handler macros + */ + +/** + * @addtogroup CPUInterrupt + */ +/**@{**/ + +/** + * Support routine to initialize the RTEMS vector table after it is allocated. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_Initialize_vectors() + +/** + * Disable all interrupts for an RTEMS critical section. The previous + * level is returned in @a _isr_cookie. + * + * @param[out] _isr_cookie will contain the previous level cookie + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_ISR_Disable( _level ) \ + { \ + __asm__ volatile ("cli %0; csync \n" : "=d" (_level) ); \ + } + + +/** + * Enable interrupts to the previous level (returned by _CPU_ISR_Disable). + * This indicates the end of an RTEMS critical section. The parameter + * @a _isr_cookie is not modified. + * + * @param[in] _isr_cookie contain the previous level cookie + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_ISR_Enable( _level ) { \ + __asm__ __volatile__ ("sti %0; csync \n" : : "d" (_level) ); \ + } + +/** + * This temporarily restores the interrupt to @a _isr_cookie before immediately + * disabling them again. This is used to divide long RTEMS critical + * sections into two or more parts. The parameter @a _isr_cookie is not + * modified. + * + * @param[in] _isr_cookie contain the previous level cookie + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_ISR_Flash( _level ) { \ + __asm__ __volatile__ ("sti %0; csync; cli r0; csync" \ + : : "d"(_level) : "R0" ); \ + } + +RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) +{ + return level != 0; +} + +/** + * This routine and @ref _CPU_ISR_Get_level + * Map the interrupt level in task mode onto the hardware that the CPU + * actually provides. Currently, interrupt levels which do not + * map onto the CPU in a generic fashion are undefined. Someday, + * it would be nice if these were "mapped" by the application + * via a callout. For example, m68k has 8 levels 0 - 7, levels + * 8 - 255 would be available for bsp/application specific meaning. + * This could be used to manage a programmable interrupt controller + * via the rtems_task_mode directive. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_ISR_Set_level( _new_level ) \ + { \ + __asm__ __volatile__ ( "sti %0; csync" : : "d"(_new_level ? 0 : 0xffff) ); \ + } + +/** + * Return the current interrupt disable level for this task in + * the format used by the interrupt level portion of the task mode. + * + * @note This routine usually must be implemented as a subroutine. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +uint32_t _CPU_ISR_Get_level( void ); + +/* end of ISR handler macros */ + +/** @} */ + +/* Context handler macros */ + +/** + * @ingroup CPUContext + * Initialize the context to a state suitable for starting a + * task after a context restore operation. Generally, this + * involves: + * + * - setting a starting address + * - preparing the stack + * - preparing the stack and frame pointers + * - setting the proper interrupt level in the context + * - initializing the floating point context + * + * This routine generally does not set any unnecessary register + * in the context. The state of the "general data" registers is + * undefined at task start time. + * + * @param[in] _the_context is the context structure to be initialized + * @param[in] _stack_base is the lowest physical address of this task's stack + * @param[in] _size is the size of this task's stack + * @param[in] _isr is the interrupt disable level + * @param[in] _entry_point is the thread's entry point. This is + * always @a _Thread_Handler + * @param[in] _is_fp is TRUE if the thread is to be a floating + * point thread. This is typically only used on CPUs where the + * FPU may be easily disabled by software such as on the SPARC + * where the PSR contains an enable FPU bit. + * @param[in] tls_area is the thread-local storage (TLS) area + * + * Port Specific Information: + * + * See implementation in cpu.c + */ +void _CPU_Context_Initialize( + Context_Control *the_context, + uint32_t *stack_base, + uint32_t size, + uint32_t new_level, + void *entry_point, + bool is_fp, + void *tls_area +); + +/** + * This routine is responsible for somehow restarting the currently + * executing task. If you are lucky, then all that is necessary + * is restoring the context. Otherwise, there will need to be + * a special assembly routine which does something special in this + * case. For many ports, simply adding a label to the restore path + * of @ref _CPU_Context_switch will work. On other ports, it may be + * possibly to load a few arguments and jump to the restore path. It will + * not work if restarting self conflicts with the stack frame + * assumptions of restoring a context. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_Context_Restart_self( _the_context ) \ + _CPU_Context_restore( (_the_context) ); + +#define _CPU_Context_Initialize_fp( _destination ) \ + memset( *( _destination ), 0, CPU_CONTEXT_FP_SIZE ); + +/* end of Context handler macros */ + +/* Fatal Error manager macros */ + +/** + * This routine copies _error into a known place -- typically a stack + * location or a register, optionally disables interrupts, and + * halts/stops the CPU. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_Fatal_halt( _source, _error ) \ + { \ + __asm__ volatile ( "cli R1; \ + R1 = %0; \ + _halt: \ + idle; \ + jump _halt;"\ + : : "r" (_error) ); \ + } + +/* end of Fatal Error manager macros */ + +#define CPU_USE_GENERIC_BITFIELD_CODE TRUE + +/* functions */ + +/** + * @brief CPU initialize. + * This routine performs CPU dependent initialization. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_Initialize(void); + +/** + * @ingroup CPUInterrupt + * This routine installs a "raw" interrupt handler directly into the + * processor's vector table. + * + * @param[in] vector is the vector number + * @param[in] new_handler is the raw ISR handler to install + * @param[in] old_handler is the previously installed ISR Handler + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_ISR_install_raw_handler( + uint32_t vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +/** + * @ingroup CPUInterrupt + * This routine installs an interrupt vector. + * + * @param[in] vector is the vector number + * @param[in] new_handler is the RTEMS ISR handler to install + * @param[in] old_handler is the previously installed ISR Handler + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_ISR_install_vector( + uint32_t vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +/** + * @ingroup CPUInterrupt + * This routine installs the hardware interrupt stack pointer. + * + * @note It need only be provided if @ref CPU_HAS_HARDWARE_INTERRUPT_STACK + * is TRUE. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_Install_interrupt_stack( void ); + +/** + * This routine is the CPU dependent IDLE thread body. + * + * @note It need only be provided if @ref CPU_PROVIDES_IDLE_THREAD_BODY + * is TRUE. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void *_CPU_Thread_Idle_body( uintptr_t ignored ); + +/** + * @addtogroup CPUContext + */ +/**@{**/ + +/** + * This routine switches from the run context to the heir context. + * + * @param[in] run points to the context of the currently executing task + * @param[in] heir points to the context of the heir task + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_Context_switch( + Context_Control *run, + Context_Control *heir +); + +/** + * This routine is generally used only to restart self in an + * efficient manner. It may simply be a label in @ref _CPU_Context_switch. + * + * @param[in] new_context points to the context to be restored. + * + * @note May be unnecessary to reload some registers. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_Context_restore( + Context_Control *new_context +) RTEMS_NO_RETURN; + +/** + * This routine saves the floating point context passed to it. + * + * @param[in] fp_context_ptr is a pointer to a pointer to a floating + * point context area + * + * @return on output @a *fp_context_ptr will contain the address that + * should be used with @ref _CPU_Context_restore_fp to restore this context. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_Context_save_fp( + Context_Control_fp **fp_context_ptr +); + +/** + * This routine restores the floating point context passed to it. + * + * @param[in] fp_context_ptr is a pointer to a pointer to a floating + * point context area to restore + * + * @return on output @a *fp_context_ptr will contain the address that + * should be used with @ref _CPU_Context_save_fp to save this context. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_Context_restore_fp( + Context_Control_fp **fp_context_ptr +); + +static inline void _CPU_Context_volatile_clobber( uintptr_t pattern ) +{ + /* TODO */ +} + +static inline void _CPU_Context_validate( uintptr_t pattern ) +{ + while (1) { + /* TODO */ + } +} + +/** @} */ + +/* FIXME */ +typedef CPU_Interrupt_frame CPU_Exception_frame; + +void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); + +/** + * @ingroup CPUEndian + * The following routine swaps the endian format of an unsigned int. + * It must be static because it is referenced indirectly. + * + * This version will work on any processor, but if there is a better + * way for your CPU PLEASE use it. The most common way to do this is to: + * + * swap least significant two bytes with 16-bit rotate + * swap upper and lower 16-bits + * swap most significant two bytes with 16-bit rotate + * + * Some CPUs have special instructions which swap a 32-bit quantity in + * a single instruction (e.g. i486). It is probably best to avoid + * an "endian swapping control bit" in the CPU. One good reason is + * that interrupts would probably have to be disabled to ensure that + * an interrupt does not try to access the same "chunk" with the wrong + * endian. Another good reason is that on some CPUs, the endian bit + * endianness for ALL fetches -- both code and data -- so the code + * will be fetched incorrectly. + * + * @param[in] value is the value to be swapped + * @return the value after being endian swapped + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +static inline uint32_t CPU_swap_u32( + uint32_t value +) +{ + uint32_t byte1, byte2, byte3, byte4, swapped; + + byte4 = (value >> 24) & 0xff; + byte3 = (value >> 16) & 0xff; + byte2 = (value >> 8) & 0xff; + byte1 = value & 0xff; + + swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4; + return( swapped ); +} + +/** + * @ingroup CPUEndian + * This routine swaps a 16 bir quantity. + * + * @param[in] value is the value to be swapped + * @return the value after being endian swapped + */ +#define CPU_swap_u16( value ) \ + (((value&0xff) << 8) | ((value >> 8)&0xff)) + +typedef uint32_t CPU_Counter_ticks; + +CPU_Counter_ticks _CPU_Counter_read( void ); + +static inline CPU_Counter_ticks _CPU_Counter_difference( + CPU_Counter_ticks second, + CPU_Counter_ticks first +) +{ + return second - first; +} + +#endif /* ASM */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/score/cpu/bfin/include/rtems/score/cpu_asm.h b/cpukit/score/cpu/bfin/include/rtems/score/cpu_asm.h new file mode 100644 index 0000000000..4f78c9d358 --- /dev/null +++ b/cpukit/score/cpu/bfin/include/rtems/score/cpu_asm.h @@ -0,0 +1,27 @@ +/** + * @file + * + * @brief Blackfin Assembly File + * + * Defines a couple of Macros used in cpu_asm.S + */ + +/* + * COPYRIGHT (c) 2006 by Atos Automacao Industrial Ltda. + * written by Alain Schaefer + * and Antonio Giovanini + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + */ + +#ifndef _RTEMS_SCORE_CPU_ASM_H +#define _RTEMS_SCORE_CPU_ASM_H + + + +#endif + +/* end of file */ diff --git a/cpukit/score/cpu/bfin/include/rtems/score/cpuatomic.h b/cpukit/score/cpu/bfin/include/rtems/score/cpuatomic.h new file mode 100644 index 0000000000..598ee76b20 --- /dev/null +++ b/cpukit/score/cpu/bfin/include/rtems/score/cpuatomic.h @@ -0,0 +1,14 @@ +/* + * COPYRIGHT (c) 2012-2013 Deng Hengyi. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_ATOMIC_CPU_H +#define _RTEMS_SCORE_ATOMIC_CPU_H + +#include + +#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/bfin/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/bfin/include/rtems/score/cpuimpl.h new file mode 100644 index 0000000000..789f2badd9 --- /dev/null +++ b/cpukit/score/cpu/bfin/include/rtems/score/cpuimpl.h @@ -0,0 +1,34 @@ +/** + * @file + * + * @brief CPU Port Implementation API + */ + +/* + * Copyright (c) 2013 embedded brains GmbH + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPUIMPL_H +#define _RTEMS_SCORE_CPUIMPL_H + +#include + +#define CPU_PER_CPU_CONTROL_SIZE 0 + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ASM */ + +#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/bfin/include/rtems/score/types.h b/cpukit/score/cpu/bfin/include/rtems/score/types.h new file mode 100644 index 0000000000..9865357cdd --- /dev/null +++ b/cpukit/score/cpu/bfin/include/rtems/score/types.h @@ -0,0 +1,49 @@ +/** + * @file + * + * @brief Blackfin CPU Type Definitions + * + * This include file contains type definitions pertaining to the + * Blackfin processor family. + */ + +/* + * COPYRIGHT (c) 1989-2006. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_TYPES_H +#define _RTEMS_SCORE_TYPES_H + +#include + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This section defines the basic types for this processor. + */ + +/** Type that can store a 32-bit integer or a pointer. */ +typedef uintptr_t CPU_Uint32ptr; + +/** This defines the return type for an ISR entry point. */ +typedef void blackfin_isr; + +/** This defines the prototype for an ISR entry point. */ +typedef blackfin_isr ( *blackfin_isr_entry )( void ); + +#ifdef __cplusplus +} +#endif + +#endif /* !ASM */ + +#endif diff --git a/cpukit/score/cpu/bfin/preinstall.am b/cpukit/score/cpu/bfin/preinstall.am deleted file mode 100644 index 0ede1d7450..0000000000 --- a/cpukit/score/cpu/bfin/preinstall.am +++ /dev/null @@ -1,70 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -$(PROJECT_INCLUDE)/rtems/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems - @: > $(PROJECT_INCLUDE)/rtems/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/asm.h: rtems/asm.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/asm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/asm.h - -$(PROJECT_INCLUDE)/rtems/bfin/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/bfin - @: > $(PROJECT_INCLUDE)/rtems/bfin/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/bfin/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/bfin/bfin.h: rtems/bfin/bfin.h $(PROJECT_INCLUDE)/rtems/bfin/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/bfin/bfin.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/bfin/bfin.h - -$(PROJECT_INCLUDE)/rtems/bfin/bf533.h: rtems/bfin/bf533.h $(PROJECT_INCLUDE)/rtems/bfin/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/bfin/bf533.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/bfin/bf533.h - -$(PROJECT_INCLUDE)/rtems/bfin/bf52x.h: rtems/bfin/bf52x.h $(PROJECT_INCLUDE)/rtems/bfin/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/bfin/bf52x.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/bfin/bf52x.h - -$(PROJECT_INCLUDE)/rtems/score/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/score - @: > $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/score/cpu.h: rtems/score/cpu.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpu.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpu.h - -$(PROJECT_INCLUDE)/rtems/score/cpuimpl.h: rtems/score/cpuimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h - -$(PROJECT_INCLUDE)/rtems/score/bfin.h: rtems/score/bfin.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/bfin.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/bfin.h - -$(PROJECT_INCLUDE)/rtems/score/cpu_asm.h: rtems/score/cpu_asm.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpu_asm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpu_asm.h - -$(PROJECT_INCLUDE)/rtems/score/types.h: rtems/score/types.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/types.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/types.h - -$(PROJECT_INCLUDE)/rtems/score/cpuatomic.h: rtems/score/cpuatomic.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h - diff --git a/cpukit/score/cpu/bfin/rtems/asm.h b/cpukit/score/cpu/bfin/rtems/asm.h deleted file mode 100644 index 5d133ddbdd..0000000000 --- a/cpukit/score/cpu/bfin/rtems/asm.h +++ /dev/null @@ -1,127 +0,0 @@ -/** - * @file - * - * @brief Address the Problems Caused by Incompatible Flavor of - * Assemblers and Toolsets - * - * This include file attempts to address the problems - * caused by incompatible flavors of assemblers and - * toolsets. It primarily addresses variations in the - * use of leading underscores on symbols and the requirement - * that register names be preceded by a %. - * - * @note The spacing in the use of these macros - * is critical to them working as advertised. - */ - -/* - * COPYRIGHT: - * - * This file is based on similar code found in newlib available - * from ftp.cygnus.com. The file which was used had no copyright - * notice. This file is freely distributable as long as the source - * of the file is noted. This file is: - * - * COPYRIGHT (c) 1994-2006. - * On-Line Applications Research Corporation (OAR). - */ - -#ifndef _RTEMS_ASM_H -#define _RTEMS_ASM_H - -/* - * Indicate we are in an assembly file and get the basic CPU definitions. - */ - -#ifndef ASM -#define ASM -#endif -#include -#include - -#ifndef __USER_LABEL_PREFIX__ -/** - * Recent versions of GNU cpp define variables which indicate the - * need for underscores and percents. If not using GNU cpp or - * the version does not support this, then you will obviously - * have to define these as appropriate. - * - * This symbol is prefixed to all C program symbols. - */ -#define __USER_LABEL_PREFIX__ _ -#endif - -#ifndef __REGISTER_PREFIX__ -/** - * Recent versions of GNU cpp define variables which indicate the - * need for underscores and percents. If not using GNU cpp or - * the version does not support this, then you will obviously - * have to define these as appropriate. - * - * This symbol is prefixed to all register names. - */ -#define __REGISTER_PREFIX__ -#endif - -#include - -/** Use the right prefix for global labels. */ -#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) - -/** Use the right prefix for registers. */ -#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) - -/* - * define macros for all of the registers on this CPU - * - * EXAMPLE: #define d0 REG (d0) - */ - -/* - * Define macros to handle section beginning and ends. - */ - - -/** This macro is used to denote the beginning of a code declaration. */ -#define BEGIN_CODE_DCL .text -/** This macro is used to denote the end of a code declaration. */ -#define END_CODE_DCL -/** This macro is used to denote the beginning of a data declaration section. */ -#define BEGIN_DATA_DCL .data -/** This macro is used to denote the end of a data declaration section. */ -#define END_DATA_DCL -/** This macro is used to denote the beginning of a code section. */ -#define BEGIN_CODE .text -/** This macro is used to denote the end of a code section. */ -#define END_CODE -/** This macro is used to denote the beginning of a data section. */ -#define BEGIN_DATA -/** This macro is used to denote the end of a data section. */ -#define END_DATA -/** - * This macro is used to denote the beginning of the - * unitialized data section. - */ -#define BEGIN_BSS -/** This macro is used to denote the end of the unitialized data section. */ -#define END_BSS -/** This macro is used to denote the end of the assembly file. */ -#define END - -/** - * This macro is used to declare a public global symbol. - * - * @note This must be tailored for a particular flavor of the C compiler. - * They may need to put underscores in front of the symbols. - */ -#define PUBLIC(sym) .globl SYM (sym) - -/** - * This macro is used to prototype a public global symbol. - * - * @note This must be tailored for a particular flavor of the C compiler. - * They may need to put underscores in front of the symbols. - */ -#define EXTERN(sym) .globl SYM (sym) - -#endif diff --git a/cpukit/score/cpu/bfin/rtems/bfin/bf52x.h b/cpukit/score/cpu/bfin/rtems/bfin/bf52x.h deleted file mode 100644 index 86142a6c62..0000000000 --- a/cpukit/score/cpu/bfin/rtems/bfin/bf52x.h +++ /dev/null @@ -1,430 +0,0 @@ -/** - * @file - * - * @brief Basic MMR for the Blackfin 52x CPU - * - * This file defines basic MMR for the Blackfin 52x CPU. - * The MMR have been taken from the ADSP-BF52x Blackfin Processor - * Hardware Reference from Analog Devices. Mentioned Chapters - * refer to this Documentation. - * - * Based on bf533.h - */ - -/* - * COPYRIGHT (c) 2006. - * Atos Automacao Industrial LTDA. - * modified by Alain Schaefer - * and Antonio Giovanini - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - * - * - * Author: Rohan Kangralkar, ECE Department Northeastern University - * Date: 02/15/2011 - */ - -#ifndef _RTEMS_BFIN_52x_H -#define _RTEMS_BFIN_52x_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -/* Clock and System Control Chapter 8 */ -#define PLL_CTL 0xFFC00000L -#define PLL_DIV 0xFFC00004L -#define VR_CTL 0xFFC00008L -#define PLL_STAT 0xFFC0000CL -#define PLL_LOCKCNT 0xFFC00010L -#define SWRST 0xFFC00100L -#define SYSCR 0xFFC00104L - -/* SPI Controller Chapter 10 */ -#define SPI_CTL 0xFFC00500L -#define SPI_FLG 0xFFC00504L -#define SPI_STAT 0xFFC00508L -#define SPI_TDBR 0xFFC0050CL -#define SPI_RDBR 0xFFC00510L -#define SPI_BAUD 0xFFC00514L -#define SPI_SHADOW 0xFFC00518L - -/* SPORT0 Controller */ -#define SPORT0_TCR1 0xFFC00800L -#define SPORT0_TCR2 0xFFC00804L -#define SPORT0_TCLKDIV 0xFFC00808L -#define SPORT0_TFSDIV 0xFFC0080CL -#define SPORT0_TX 0xFFC00810L -#define SPORT0_RX 0xFFC00818L -#define SPORT0_RCR1 0xFFC00820L -#define SPORT0_RCR2 0xFFC00824L -#define SPORT0_RCLKDIV 0xFFC00828L -#define SPORT0_RFSDIV 0xFFC0082CL -#define SPORT0_STAT 0xFFC00830L -#define SPORT0_CHNL 0xFFC00834L -#define SPORT0_MCMC1 0xFFC00838L -#define SPORT0_MCMC2 0xFFC0083CL -#define SPORT0_MTCS0 0xFFC00840L -#define SPORT0_MTCS1 0xFFC00844L -#define SPORT0_MTCS2 0xFFC00848L -#define SPORT0_MTCS3 0xFFC0084CL -#define SPORT0_MRCS0 0xFFC00850L -#define SPORT0_MRCS1 0xFFC00854L -#define SPORT0_MRCS2 0xFFC00858L -#define SPORT0_MRCS3 0xFFC0085CL - -/* Parallel Peripheral Interface (PPI) Chapter 11 */ - -#define PPI_CONTROL 0xFFC01000L -#define PPI_STATUS 0xFFC01004L -#define PPI_COUNT 0xFFC01008L -#define PPI_DELAY 0xFFC0100CL -#define PPI_FRAME 0xFFC01010L - -/********* PPI MASKS ***********/ -/* PPI_CONTROL Masks */ -#define PORT_EN 0x00000001 -#define PORT_DIR 0x00000002 -#define XFR_TYPE 0x0000000C -#define PORT_CFG 0x00000030 -#define FLD_SEL 0x00000040 -#define PACK_EN 0x00000080 -#define DMA32 0x00000100 -#define SKIP_EN 0x00000200 -#define SKIP_EO 0x00000400 -#define DLENGTH 0x00003800 -#define DLEN_8 0x0 -#define DLEN(x) (((x-9) & 0x07) << 11) -#define POL 0x0000C000 - -/* PPI_STATUS Masks */ -#define FLD 0x00000400 -#define FT_ERR 0x00000800 -#define OVR 0x00001000 -#define UNDR 0x00002000 -#define ERR_DET 0x00004000 -#define ERR_NCOR 0x00008000 - -/* SPORT1 Controller Chapter 12 */ -#define SPORT1_TCR1 0xFFC00900L -#define SPORT1_TCR2 0xFFC00904L -#define SPORT1_TCLKDIV 0xFFC00908L -#define SPORT1_TFSDIV 0xFFC0090CL -#define SPORT1_TX 0xFFC00910L -#define SPORT1_RX 0xFFC00918L -#define SPORT1_RCR1 0xFFC00920L -#define SPORT1_RCR2 0xFFC00924L -#define SPORT1_RCLKDIV 0xFFC00928L -#define SPORT1_RFSDIV 0xFFC0092CL -#define SPORT1_STAT 0xFFC00930L -#define SPORT1_CHNL 0xFFC00934L -#define SPORT1_MCMC1 0xFFC00938L -#define SPORT1_MCMC2 0xFFC0093CL -#define SPORT1_MTCS0 0xFFC00940L -#define SPORT1_MTCS1 0xFFC00944L -#define SPORT1_MTCS2 0xFFC00948L -#define SPORT1_MTCS3 0xFFC0094CL -#define SPORT1_MRCS0 0xFFC00950L -#define SPORT1_MRCS1 0xFFC00954L -#define SPORT1_MRCS2 0xFFC00958L -#define SPORT1_MRCS3 0xFFC0095CL - -/* SPORTx_TCR1 Masks */ -#define TSPEN 0x0001 -#define ITCLK 0x0002 -#define TDTYPE 0x000C -#define TLSBIT 0x0010 -#define ITFS 0x0200 -#define TFSR 0x0400 -#define DITFS 0x0800 -#define LTFS 0x1000 -#define LATFS 0x2000 -#define TCKFE 0x4000 - -/* SPORTx_TCR2 Masks */ -#define SLEN 0x001F -#define TXSE 0x0100 -#define TSFSE 0x0200 -#define TRFST 0x0400 - -/* SPORTx_RCR1 Masks */ -#define RSPEN 0x0001 -#define IRCLK 0x0002 -#define RDTYPE 0x000C -#define RULAW 0x0008 -#define RALAW 0x000C -#define RLSBIT 0x0010 -#define IRFS 0x0200 -#define RFSR 0x0400 -#define LRFS 0x1000 -#define LARFS 0x2000 -#define RCKFE 0x4000 - -/* SPORTx_RCR2 Masks */ -#define SLEN 0x001F -#define RXSE 0x0100 -#define RSFSE 0x0200 -#define RRFST 0x0400 - -/* SPORTx_STAT Masks */ -#define RXNE 0x0001 -#define RUVF 0x0002 -#define ROVF 0x0004 -#define TXF 0x0008 -#define TUVF 0x0010 -#define TOVF 0x0020 -#define TXHRE 0x0040 - -/* SPORTx_MCMC1 Masks */ -#define WSIZE 0x0000F000 -#define WOFF 0x000003FF - -/* SPORTx_MCMC2 Masks */ -#define MCCRM 0x00000003 -#define MCDTXPE 0x00000004 -#define MCDRXPE 0x00000008 -#define MCMEN 0x00000010 -#define FSDR 0x00000080 -#define MFD 0x0000F000 - -/* UART Controller Chapter 13 */ -#define UART_THR 0xFFC00400L -#define UART_RBR 0xFFC00400L -#define UART_DLL 0xFFC00400L -#define UART_IER 0xFFC00404L -#define UART_DLH 0xFFC00404L -#define UART_IIR 0xFFC00408L -#define UART_LCR 0xFFC0040CL -#define UART_MCR 0xFFC00410L -#define UART_LSR 0xFFC00414L -#define UART_SCR 0xFFC0041CL -#define UART_GCTL 0xFFC00424L - -/* - * UART CONTROLLER MASKS - */ - -/* UART_LCR */ -#define DLAB 0x80 -#define SB 0x40 -#define STP 0x20 -#define EPS 0x10 -#define PEN 0x08 -#define STB 0x04 -#define WLS(x) ((x-5) & 0x03) - -#define DLAB_P 0x07 -#define SB_P 0x06 -#define STP_P 0x05 -#define EPS_P 0x04 -#define PEN_P 0x03 -#define STB_P 0x02 -#define WLS_P1 0x01 -#define WLS_P0 0x00 - -/* UART_MCR */ -#define LOOP_ENA 0x10 -#define LOOP_ENA_P 0x04 - -/* UART_LSR */ -#define TEMT 0x40 -#define THRE 0x20 -#define BI 0x10 -#define FE 0x08 -#define PE 0x04 -#define OE 0x02 -#define DR 0x01 - -#define TEMP_P 0x06 -#define THRE_P 0x05 -#define BI_P 0x04 -#define FE_P 0x03 -#define PE_P 0x02 -#define OE_P 0x01 -#define DR_P 0x00 - -/* UART_IER */ -#define ELSI 0x04 -#define ETBEI 0x02 -#define ERBFI 0x01 - -#define ELSI_P 0x02 -#define ETBEI_P 0x01 -#define ERBFI_P 0x00 - -/* UART_IIR */ -#define STATUS(x) ((x << 1) & 0x06) -#define NINT 0x01 -#define STATUS_P1 0x02 -#define STATUS_P0 0x01 -#define NINT_P 0x00 - -/* UART_GCTL */ -#define FFE 0x20 -#define FPE 0x10 -#define RPOLC 0x08 -#define TPOLC 0x04 -#define IREN 0x02 -#define UCEN 0x01 - -#define FFE_P 0x05 -#define FPE_P 0x04 -#define RPOLC_P 0x03 -#define TPOLC_P 0x02 -#define IREN_P 0x01 -#define UCEN_P 0x00 - -/* General Purpose IO Chapter 14*/ -#define FIO_FLAG_D 0xFFC00700L -#define FIO_FLAG_C 0xFFC00704L -#define FIO_FLAG_S 0xFFC00708L -#define FIO_FLAG_T 0xFFC0070CL -#define FIO_MASKA_D 0xFFC00710L -#define FIO_MASKA_C 0xFFC00714L -#define FIO_MASKA_S 0xFFC00718L -#define FIO_MASKA_T 0xFFC0071CL -#define FIO_MASKB_D 0xFFC00720L -#define FIO_MASKB_C 0xFFC00724L -#define FIO_MASKB_S 0xFFC00728L -#define FIO_MASKB_T 0xFFC0072CL -#define FIO_DIR 0xFFC00730L -#define FIO_POLAR 0xFFC00734L -#define FIO_EDGE 0xFFC00738L -#define FIO_BOTH 0xFFC0073CL -#define FIO_INEN 0xFFC00740L - - -/* General Purpose IO Chapter 9*/ -#define PORTH_FER 0xFFC03208 -#define PORTH_MUX 0xFFC03218 -#define PORTHIO_DIR 0xFFC01730 -#define PORTHIO_INEN 0xFFC01740 -#define PORTHIO 0xFFC01700 -#define PORTHIO_SET 0xFFC01708 -#define PORTHIO_CLEAR 0xFFC01704 -#define PORTHIO_TOGGLE 0xFFC0170C - - -#define FIO_INEN 0xFFC00740L -#define FIO_POLAR 0xFFC00734L -#define FIO_EDGE 0xFFC00738L -#define FIO_BOTH 0xFFC0073CL - - - -#define FIO_FLAG_C 0xFFC00704L -#define FIO_FLAG_S 0xFFC00708L -#define FIO_FLAG_T 0xFFC0070CL -#define FIO_MASKA_D 0xFFC00710L -#define FIO_MASKA_C 0xFFC00714L -#define FIO_MASKA_S 0xFFC00718L -#define FIO_MASKA_T 0xFFC0071CL -#define FIO_MASKB_D 0xFFC00720L -#define FIO_MASKB_C 0xFFC00724L -#define FIO_MASKB_S 0xFFC00728L -#define FIO_MASKB_T 0xFFC0072CL - - -/* General Purpose IO Masks */ -#define PF0 0x0001 -#define PF1 0x0002 -#define PF2 0x0004 -#define PF3 0x0008 -#define PF4 0x0010 -#define PF5 0x0020 -#define PF6 0x0040 -#define PF7 0x0080 -#define PF8 0x0100 -#define PF9 0x0200 -#define PF10 0x0400 -#define PF11 0x0800 -#define PF12 0x1000 -#define PF13 0x2000 -#define PF14 0x4000 -#define PF15 0x8000 - - -/* TIMER 0, 1, 2 Chapter 15 */ -#define TIMER0_CONFIG 0xFFC00600L -#define TIMER0_COUNTER 0xFFC00604L -#define TIMER0_PERIOD 0xFFC00608L -#define TIMER0_WIDTH 0xFFC0060CL - -#define TIMER1_CONFIG 0xFFC00610L -#define TIMER1_COUNTER 0xFFC00614L -#define TIMER1_PERIOD 0xFFC00618L -#define TIMER1_WIDTH 0xFFC0061CL - -#define TIMER2_CONFIG 0xFFC00620L -#define TIMER2_COUNTER 0xFFC00624L -#define TIMER2_PERIOD 0xFFC00628L -#define TIMER2_WIDTH 0xFFC0062CL - -#define TIMER_ENABLE 0xFFC00640L -#define TIMER_DISABLE 0xFFC00644L -#define TIMER_STATUS 0xFFC00648L - -/* Real Time Clock Chapter 16 */ -#define RTC_STAT 0xFFC00300L -#define RTC_ICTL 0xFFC00304L -#define RTC_ISTAT 0xFFC00308L -#define RTC_SWCNT 0xFFC0030CL -#define RTC_ALARM 0xFFC00310L -#define RTC_FAST 0xFFC00314L -#define RTC_PREN 0xFFC00314L - -/* RTC_FAST Mask (RTC_PREN Mask) */ -#define ENABLE_PRESCALE 0x00000001 -#define PREN 0x00000001 - -/* Asynchronous Memory Controller EBUI, Chapter 17*/ -#define EBIU_AMGCTL 0xFFC00A00L -#define EBIU_AMBCTL0 0xFFC00A04L -#define EBIU_AMBCTL1 0xFFC00A08L - -/* SDRAM Controller External Bus Interface Unit */ - -#define EBIU_SDGCTL 0xFFC00A10L -#define EBIU_SDBCTL 0xFFC00A14L -#define EBIU_SDRRC 0xFFC00A18L -#define EBIU_SDSTAT 0xFFC00A1CL - - - - -/* DCPLB_DATA and ICPLB_DATA Registers */ -/*** Bit Positions */ -#define CPLB_VALID_P 0x00000000 /* 0=invalid entry, 1=valid entry */ -#define CPLB_LOCK_P 0x00000001 /* 0=entry may be replaced, 1=entry locked */ -#define CPLB_USER_RD_P 0x00000002 /* 0=no read access, 1=read access allowed (user mode) */ -/*** Masks */ -#define CPLB_VALID 0x00000001 /* 0=invalid entry, 1=valid entry */ -#define CPLB_LOCK 0x00000002 /* 0=entry may be replaced, 1=entry locked */ -#define CPLB_USER_RD 0x00000004 /* 0=no read access, 1=read access allowed (user mode) */ -#define PAGE_SIZE_1KB 0x00000000 /* 1 KB page size */ -#define PAGE_SIZE_4KB 0x00010000 /* 4 KB page size */ -#define PAGE_SIZE_1MB 0x00020000 /* 1 MB page size */ -#define PAGE_SIZE_4MB 0x00030000 /* 4 MB page size */ -#define CPLB_PORTPRIO 0x00000200 /* 0=low priority port, 1= high priority port */ -#define CPLB_L1_CHBL 0x00001000 /* 0=non-cacheable in L1, 1=cacheable in L1 */ -/*** ICPLB_DATA only */ -#define CPLB_LRUPRIO 0x00000100 /* 0=can be replaced by any line, 1=priority for non-replacement */ -/*** DCPLB_DATA only */ -#define CPLB_USER_WR 0x00000008 /* 0=no write access, 0=write access allowed (user mode) */ -#define CPLB_SUPV_WR 0x00000010 /* 0=no write access, 0=write access allowed (supervisor mode) */ -#define CPLB_DIRTY 0x00000080 /* 1=dirty, 0=clean */ -#define CPLB_L1_AOW 0x00008000 /* 0=do not allocate cache lines on write-through writes, */ - /* 1= allocate cache lines on write-through writes. */ -#define CPLB_WT 0x00004000 /* 0=write-back, 1=write-through */ - - -#ifdef __cplusplus -} -#endif - -#endif /* _RTEMS_SCORE_BFIN_H */ diff --git a/cpukit/score/cpu/bfin/rtems/bfin/bf533.h b/cpukit/score/cpu/bfin/rtems/bfin/bf533.h deleted file mode 100644 index 682aad4bbb..0000000000 --- a/cpukit/score/cpu/bfin/rtems/bfin/bf533.h +++ /dev/null @@ -1,396 +0,0 @@ -/** - * @file - * - * @brief Basic MMR for the Blackfin 531/532/533 CPU - * - * This file defines basic MMR for the Blackfin 531/532/533 CPU. - * The MMR have been taken from the ADSP-BF533 Blackfin Processor - * Hardware Reference from Analog Devices. Mentioned Chapters - * refer to this Documentation. - * - * The Blackfins MMRs are divided into core MMRs (0xFFE0 0000–0xFFFF FFFF) - * and System MMRs (0xFFC0 0000–0xFFE0 0000). The core MMRs are defined - * in bfin.h which is included. - */ -/* - * COPYRIGHT (c) 2006. - * Atos Automacao Industrial LTDA. - * modified by Alain Schaefer - * and Antonio Giovanini - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - * - */ - -#ifndef _RTEMS_BFIN_533_H -#define _RTEMS_BFIN_533_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -/* Clock and System Control Chapter 8 */ -#define PLL_CTL 0xFFC00000L -#define PLL_DIV 0xFFC00004L -#define VR_CTL 0xFFC00008L -#define PLL_STAT 0xFFC0000CL -#define PLL_LOCKCNT 0xFFC00010L -#define SWRST 0xFFC00100L -#define SYSCR 0xFFC00104L - -/* SPI Controller Chapter 10 */ -#define SPI_CTL 0xFFC00500L -#define SPI_FLG 0xFFC00504L -#define SPI_STAT 0xFFC00508L -#define SPI_TDBR 0xFFC0050CL -#define SPI_RDBR 0xFFC00510L -#define SPI_BAUD 0xFFC00514L -#define SPI_SHADOW 0xFFC00518L - -/* SPORT0 Controller */ -#define SPORT0_TCR1 0xFFC00800L -#define SPORT0_TCR2 0xFFC00804L -#define SPORT0_TCLKDIV 0xFFC00808L -#define SPORT0_TFSDIV 0xFFC0080CL -#define SPORT0_TX 0xFFC00810L -#define SPORT0_RX 0xFFC00818L -#define SPORT0_RCR1 0xFFC00820L -#define SPORT0_RCR2 0xFFC00824L -#define SPORT0_RCLKDIV 0xFFC00828L -#define SPORT0_RFSDIV 0xFFC0082CL -#define SPORT0_STAT 0xFFC00830L -#define SPORT0_CHNL 0xFFC00834L -#define SPORT0_MCMC1 0xFFC00838L -#define SPORT0_MCMC2 0xFFC0083CL -#define SPORT0_MTCS0 0xFFC00840L -#define SPORT0_MTCS1 0xFFC00844L -#define SPORT0_MTCS2 0xFFC00848L -#define SPORT0_MTCS3 0xFFC0084CL -#define SPORT0_MRCS0 0xFFC00850L -#define SPORT0_MRCS1 0xFFC00854L -#define SPORT0_MRCS2 0xFFC00858L -#define SPORT0_MRCS3 0xFFC0085CL - -/* Parallel Peripheral Interface (PPI) Chapter 11 */ - -#define PPI_CONTROL 0xFFC01000L -#define PPI_STATUS 0xFFC01004L -#define PPI_COUNT 0xFFC01008L -#define PPI_DELAY 0xFFC0100CL -#define PPI_FRAME 0xFFC01010L - -/********* PPI MASKS ***********/ -/* PPI_CONTROL Masks */ -#define PORT_EN 0x00000001 -#define PORT_DIR 0x00000002 -#define XFR_TYPE 0x0000000C -#define PORT_CFG 0x00000030 -#define FLD_SEL 0x00000040 -#define PACK_EN 0x00000080 -#define DMA32 0x00000100 -#define SKIP_EN 0x00000200 -#define SKIP_EO 0x00000400 -#define DLENGTH 0x00003800 -#define DLEN_8 0x0 -#define DLEN(x) (((x-9) & 0x07) << 11) -#define POL 0x0000C000 - -/* PPI_STATUS Masks */ -#define FLD 0x00000400 -#define FT_ERR 0x00000800 -#define OVR 0x00001000 -#define UNDR 0x00002000 -#define ERR_DET 0x00004000 -#define ERR_NCOR 0x00008000 - -/* SPORT1 Controller Chapter 12 */ -#define SPORT1_TCR1 0xFFC00900L -#define SPORT1_TCR2 0xFFC00904L -#define SPORT1_TCLKDIV 0xFFC00908L -#define SPORT1_TFSDIV 0xFFC0090CL -#define SPORT1_TX 0xFFC00910L -#define SPORT1_RX 0xFFC00918L -#define SPORT1_RCR1 0xFFC00920L -#define SPORT1_RCR2 0xFFC00924L -#define SPORT1_RCLKDIV 0xFFC00928L -#define SPORT1_RFSDIV 0xFFC0092CL -#define SPORT1_STAT 0xFFC00930L -#define SPORT1_CHNL 0xFFC00934L -#define SPORT1_MCMC1 0xFFC00938L -#define SPORT1_MCMC2 0xFFC0093CL -#define SPORT1_MTCS0 0xFFC00940L -#define SPORT1_MTCS1 0xFFC00944L -#define SPORT1_MTCS2 0xFFC00948L -#define SPORT1_MTCS3 0xFFC0094CL -#define SPORT1_MRCS0 0xFFC00950L -#define SPORT1_MRCS1 0xFFC00954L -#define SPORT1_MRCS2 0xFFC00958L -#define SPORT1_MRCS3 0xFFC0095CL - -/* SPORTx_TCR1 Masks */ -#define TSPEN 0x0001 -#define ITCLK 0x0002 -#define TDTYPE 0x000C -#define TLSBIT 0x0010 -#define ITFS 0x0200 -#define TFSR 0x0400 -#define DITFS 0x0800 -#define LTFS 0x1000 -#define LATFS 0x2000 -#define TCKFE 0x4000 - -/* SPORTx_TCR2 Masks */ -#define SLEN 0x001F -#define TXSE 0x0100 -#define TSFSE 0x0200 -#define TRFST 0x0400 - -/* SPORTx_RCR1 Masks */ -#define RSPEN 0x0001 -#define IRCLK 0x0002 -#define RDTYPE 0x000C -#define RULAW 0x0008 -#define RALAW 0x000C -#define RLSBIT 0x0010 -#define IRFS 0x0200 -#define RFSR 0x0400 -#define LRFS 0x1000 -#define LARFS 0x2000 -#define RCKFE 0x4000 - -/* SPORTx_RCR2 Masks */ -#define SLEN 0x001F -#define RXSE 0x0100 -#define RSFSE 0x0200 -#define RRFST 0x0400 - -/* SPORTx_STAT Masks */ -#define RXNE 0x0001 -#define RUVF 0x0002 -#define ROVF 0x0004 -#define TXF 0x0008 -#define TUVF 0x0010 -#define TOVF 0x0020 -#define TXHRE 0x0040 - -/* SPORTx_MCMC1 Masks */ -#define WSIZE 0x0000F000 -#define WOFF 0x000003FF - -/* SPORTx_MCMC2 Masks */ -#define MCCRM 0x00000003 -#define MCDTXPE 0x00000004 -#define MCDRXPE 0x00000008 -#define MCMEN 0x00000010 -#define FSDR 0x00000080 -#define MFD 0x0000F000 - -/* UART Controller Chapter 13 */ -#define UART_THR 0xFFC00400L -#define UART_RBR 0xFFC00400L -#define UART_DLL 0xFFC00400L -#define UART_IER 0xFFC00404L -#define UART_DLH 0xFFC00404L -#define UART_IIR 0xFFC00408L -#define UART_LCR 0xFFC0040CL -#define UART_MCR 0xFFC00410L -#define UART_LSR 0xFFC00414L -#define UART_SCR 0xFFC0041CL -#define UART_GCTL 0xFFC00424L - -/* - * UART CONTROLLER MASKS - */ - -/* UART_LCR */ -#define DLAB 0x80 -#define SB 0x40 -#define STP 0x20 -#define EPS 0x10 -#define PEN 0x08 -#define STB 0x04 -#define WLS(x) ((x-5) & 0x03) - -#define DLAB_P 0x07 -#define SB_P 0x06 -#define STP_P 0x05 -#define EPS_P 0x04 -#define PEN_P 0x03 -#define STB_P 0x02 -#define WLS_P1 0x01 -#define WLS_P0 0x00 - -/* UART_MCR */ -#define LOOP_ENA 0x10 -#define LOOP_ENA_P 0x04 - -/* UART_LSR */ -#define TEMT 0x40 -#define THRE 0x20 -#define BI 0x10 -#define FE 0x08 -#define PE 0x04 -#define OE 0x02 -#define DR 0x01 - -#define TEMP_P 0x06 -#define THRE_P 0x05 -#define BI_P 0x04 -#define FE_P 0x03 -#define PE_P 0x02 -#define OE_P 0x01 -#define DR_P 0x00 - -/* UART_IER */ -#define ELSI 0x04 -#define ETBEI 0x02 -#define ERBFI 0x01 - -#define ELSI_P 0x02 -#define ETBEI_P 0x01 -#define ERBFI_P 0x00 - -/* UART_IIR */ -#define STATUS(x) ((x << 1) & 0x06) -#define NINT 0x01 -#define STATUS_P1 0x02 -#define STATUS_P0 0x01 -#define NINT_P 0x00 - -/* UART_GCTL */ -#define FFE 0x20 -#define FPE 0x10 -#define RPOLC 0x08 -#define TPOLC 0x04 -#define IREN 0x02 -#define UCEN 0x01 - -#define FFE_P 0x05 -#define FPE_P 0x04 -#define RPOLC_P 0x03 -#define TPOLC_P 0x02 -#define IREN_P 0x01 -#define UCEN_P 0x00 - -/* General Purpose IO Chapter 14*/ -#define FIO_FLAG_D 0xFFC00700L -#define FIO_FLAG_C 0xFFC00704L -#define FIO_FLAG_S 0xFFC00708L -#define FIO_FLAG_T 0xFFC0070CL -#define FIO_MASKA_D 0xFFC00710L -#define FIO_MASKA_C 0xFFC00714L -#define FIO_MASKA_S 0xFFC00718L -#define FIO_MASKA_T 0xFFC0071CL -#define FIO_MASKB_D 0xFFC00720L -#define FIO_MASKB_C 0xFFC00724L -#define FIO_MASKB_S 0xFFC00728L -#define FIO_MASKB_T 0xFFC0072CL -#define FIO_DIR 0xFFC00730L -#define FIO_POLAR 0xFFC00734L -#define FIO_EDGE 0xFFC00738L -#define FIO_BOTH 0xFFC0073CL -#define FIO_INEN 0xFFC00740L - -/* General Purpose IO Masks */ -#define PF0 0x0001 -#define PF1 0x0002 -#define PF2 0x0004 -#define PF3 0x0008 -#define PF4 0x0010 -#define PF5 0x0020 -#define PF6 0x0040 -#define PF7 0x0080 -#define PF8 0x0100 -#define PF9 0x0200 -#define PF10 0x0400 -#define PF11 0x0800 -#define PF12 0x1000 -#define PF13 0x2000 -#define PF14 0x4000 -#define PF15 0x8000 - - -/* TIMER 0, 1, 2 Chapter 15 */ -#define TIMER0_CONFIG 0xFFC00600L -#define TIMER0_COUNTER 0xFFC00604L -#define TIMER0_PERIOD 0xFFC00608L -#define TIMER0_WIDTH 0xFFC0060CL - -#define TIMER1_CONFIG 0xFFC00610L -#define TIMER1_COUNTER 0xFFC00614L -#define TIMER1_PERIOD 0xFFC00618L -#define TIMER1_WIDTH 0xFFC0061CL - -#define TIMER2_CONFIG 0xFFC00620L -#define TIMER2_COUNTER 0xFFC00624L -#define TIMER2_PERIOD 0xFFC00628L -#define TIMER2_WIDTH 0xFFC0062CL - -#define TIMER_ENABLE 0xFFC00640L -#define TIMER_DISABLE 0xFFC00644L -#define TIMER_STATUS 0xFFC00648L - -/* Real Time Clock Chapter 16 */ -#define RTC_STAT 0xFFC00300L -#define RTC_ICTL 0xFFC00304L -#define RTC_ISTAT 0xFFC00308L -#define RTC_SWCNT 0xFFC0030CL -#define RTC_ALARM 0xFFC00310L -#define RTC_FAST 0xFFC00314L -#define RTC_PREN 0xFFC00314L - -/* RTC_FAST Mask (RTC_PREN Mask) */ -#define ENABLE_PRESCALE 0x00000001 -#define PREN 0x00000001 - -/* Asynchronous Memory Controller EBUI, Chapter 17*/ -#define EBIU_AMGCTL 0xFFC00A00L -#define EBIU_AMBCTL0 0xFFC00A04L -#define EBIU_AMBCTL1 0xFFC00A08L - -/* SDRAM Controller External Bus Interface Unit */ - -#define EBIU_SDGCTL 0xFFC00A10L -#define EBIU_SDBCTL 0xFFC00A14L -#define EBIU_SDRRC 0xFFC00A18L -#define EBIU_SDSTAT 0xFFC00A1CL - - - - -/* DCPLB_DATA and ICPLB_DATA Registers */ -/*** Bit Positions */ -#define CPLB_VALID_P 0x00000000 /* 0=invalid entry, 1=valid entry */ -#define CPLB_LOCK_P 0x00000001 /* 0=entry may be replaced, 1=entry locked */ -#define CPLB_USER_RD_P 0x00000002 /* 0=no read access, 1=read access allowed (user mode) */ -/*** Masks */ -#define CPLB_VALID 0x00000001 /* 0=invalid entry, 1=valid entry */ -#define CPLB_LOCK 0x00000002 /* 0=entry may be replaced, 1=entry locked */ -#define CPLB_USER_RD 0x00000004 /* 0=no read access, 1=read access allowed (user mode) */ -#define PAGE_SIZE_1KB 0x00000000 /* 1 KB page size */ -#define PAGE_SIZE_4KB 0x00010000 /* 4 KB page size */ -#define PAGE_SIZE_1MB 0x00020000 /* 1 MB page size */ -#define PAGE_SIZE_4MB 0x00030000 /* 4 MB page size */ -#define CPLB_PORTPRIO 0x00000200 /* 0=low priority port, 1= high priority port */ -#define CPLB_L1_CHBL 0x00001000 /* 0=non-cacheable in L1, 1=cacheable in L1 */ -/*** ICPLB_DATA only */ -#define CPLB_LRUPRIO 0x00000100 /* 0=can be replaced by any line, 1=priority for non-replacement */ -/*** DCPLB_DATA only */ -#define CPLB_USER_WR 0x00000008 /* 0=no write access, 0=write access allowed (user mode) */ -#define CPLB_SUPV_WR 0x00000010 /* 0=no write access, 0=write access allowed (supervisor mode) */ -#define CPLB_DIRTY 0x00000080 /* 1=dirty, 0=clean */ -#define CPLB_L1_AOW 0x00008000 /* 0=do not allocate cache lines on write-through writes, */ - /* 1= allocate cache lines on write-through writes. */ -#define CPLB_WT 0x00004000 /* 0=write-back, 1=write-through */ - - -#ifdef __cplusplus -} -#endif - -#endif /* _RTEMS_SCORE_BFIN_H */ diff --git a/cpukit/score/cpu/bfin/rtems/bfin/bfin.h b/cpukit/score/cpu/bfin/rtems/bfin/bfin.h deleted file mode 100644 index 4ba0b2b295..0000000000 --- a/cpukit/score/cpu/bfin/rtems/bfin/bfin.h +++ /dev/null @@ -1,88 +0,0 @@ -/** - * @file - * - * @brief Macros for MMR register common to all Blackfin Processors - * - * This file defines Macros for MMR register common to all Blackfin - * Processors. - */ - -/* - * COPYRIGHT (c) 2006 by Atos Automacao Industrial Ltda. - * modified by Alain Schaefer - * and Antonio Giovanini - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - * - */ - -#ifndef _RTEMS_BFIN_BFIN_H -#define _RTEMS_BFIN_BFIN_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Scratchpad SRAM */ - -#define SCRATCH 0xFFB00000 -#define SCRATCH_SIZE 0x1000 -#define SCRATCH_TOP 0xFFB00ffc - - -/* System Interrupt Controller Chapter 4*/ -#define SIC_RVECT 0xFFC00108 -#define SIC_IMASK 0xFFC0010C -#define SIC_IAR0 0xFFC00110 -#define SIC_IAR1 0xFFC00114 -#define SIC_IAR2 0xFFC00118 -#define SIC_ISR 0xFFC00120 -#define SIC_IWR 0xFFC00124 - -/* Event Vector Table Chapter 4 */ - -#define EVT0 0xFFE02000 -#define EVT1 0xFFE02004 -#define EVT2 0xFFE02008 -#define EVT3 0xFFE0200C -#define EVT4 0xFFE02010 -#define EVT5 0xFFE02014 -#define EVT6 0xFFE02018 -#define EVT7 0xFFE0201C -#define EVT8 0xFFE02020 -#define EVT9 0xFFE02024 -#define EVT10 0xFFE02028 -#define EVT11 0xFFE0202C -#define EVT12 0xFFE02030 -#define EVT13 0xFFE02034 -#define EVT14 0xFFE02038 -#define EVT15 0xFFE0203C -#define IMASK 0xFFE02104 -#define IPEND 0xFFE02108 -#define ILAT 0xFFE0210C -#define IPRIO 0xFFE02110 - - -#define TCNTL 0xFFE03000 -#define TPERIOD 0xFFE03004 -#define TSCALE 0xFFE03008 -#define TCOUNT 0xFFE0300C - -/* Masks for Timer Control */ -#define TMPWR 0x00000001 -#define TMREN 0x00000002 -#define TAUTORLD 0x00000004 -#define TINT 0x00000008 - -/* Event Bit Positions */ -#define EVT_IVTMR_P 0x00000006 - -#define EVT_IVTMR (1 << EVT_IVTMR_P) - -#ifdef __cplusplus -} -#endif - -#endif /* _RTEMS_SCORE_BFIN_H */ diff --git a/cpukit/score/cpu/bfin/rtems/score/bfin.h b/cpukit/score/cpu/bfin/rtems/score/bfin.h deleted file mode 100644 index caa3a51830..0000000000 --- a/cpukit/score/cpu/bfin/rtems/score/bfin.h +++ /dev/null @@ -1,69 +0,0 @@ -/** - * @file - * - * @brief Blackfin Set up Basic CPU Dependency Settings Based on - * Compiler Settings - * - * This file sets up basic CPU dependency settings based on - * compiler settings. For example, it can determine if - * floating point is available. This particular implementation - * is specified to the Blackfin port. - */ - -/* - * - * COPYRIGHT (c) 1989-2006. - * On-Line Applications Research Corporation (OAR). - * modified by Alain Schaefer - * and Antonio Giovanini - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - * - */ - -#ifndef _RTEMS_SCORE_BFIN_H -#define _RTEMS_SCORE_BFIN_H - -#ifdef __cplusplus -extern "C" { -#endif - - -/* - * This file contains the information required to build - * RTEMS for a particular member of the Blackfin family. - * It does this by setting variables to indicate which - * implementation dependent features are present in a particular - * member of the family. - * - * This is a good place to list all the known CPU models - * that this port supports and which RTEMS CPU model they correspond - * to. - */ - -/* - * Figure out all CPU Model Feature Flags based upon compiler - * predefines. - */ -#if defined(__BFIN__) -#define CPU_MODEL_NAME "BF533" -#define BF_HAS_FPU 0 -#else - -#error "Unsupported CPU Model" - -#endif - -/* - * Define the name of the CPU family. - */ - -#define CPU_NAME "BFIN" - -#ifdef __cplusplus -} -#endif - -#endif /* _RTEMS_SCORE_BFIN_H */ diff --git a/cpukit/score/cpu/bfin/rtems/score/cpu.h b/cpukit/score/cpu/bfin/rtems/score/cpu.h deleted file mode 100644 index 7c90fc6575..0000000000 --- a/cpukit/score/cpu/bfin/rtems/score/cpu.h +++ /dev/null @@ -1,1001 +0,0 @@ -/** - * @file - * - * @brief Blackfin CPU Department Source - * - * This include file contains information pertaining to the Blackfin - * processor. - */ - -/* - * COPYRIGHT (c) 1989-2006. - * On-Line Applications Research Corporation (OAR). - * adapted to Blackfin by Alain Schaefer - * and Antonio Giovanini - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPU_H -#define _RTEMS_SCORE_CPU_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/* conditional compilation parameters */ - -/** - * Does RTEMS manage a dedicated interrupt stack in software? - * - * If TRUE, then a stack is allocated in @ref _ISR_Handler_initialization. - * If FALSE, nothing is done. - * - * If the CPU supports a dedicated interrupt stack in hardware, - * then it is generally the responsibility of the BSP to allocate it - * and set it up. - * - * If the CPU does not support a dedicated interrupt stack, then - * the porter has two options: (1) execute interrupts on the - * stack of the interrupted task, and (2) have RTEMS manage a dedicated - * interrupt stack. - * - * If this is TRUE, @ref CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. - * - * Only one of @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK and - * @ref CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is - * possible that both are FALSE for a particular CPU. Although it - * is unclear what that would imply about the interrupt processing - * procedure on that CPU. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_HAS_SOFTWARE_INTERRUPT_STACK TRUE - -/* - * Does the CPU follow the simple vectored interrupt model? - * - * If TRUE, then RTEMS allocates the vector table it internally manages. - * If FALSE, then the BSP is assumed to allocate and manage the vector - * table - * - * BFIN Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_SIMPLE_VECTORED_INTERRUPTS TRUE - -/** - * Does this CPU have hardware support for a dedicated interrupt stack? - * - * If TRUE, then it must be installed during initialization. - * If FALSE, then no installation is performed. - * - * If this is TRUE, @ref CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. - * - * Only one of @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK and - * @ref CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is - * possible that both are FALSE for a particular CPU. Although it - * is unclear what that would imply about the interrupt processing - * procedure on that CPU. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE - -/** - * Does RTEMS allocate a dedicated interrupt stack in the Interrupt Manager? - * - * If TRUE, then the memory is allocated during initialization. - * If FALSE, then the memory is allocated during initialization. - * - * This should be TRUE is CPU_HAS_SOFTWARE_INTERRUPT_STACK is TRUE. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_ALLOCATE_INTERRUPT_STACK TRUE - -/** - * Does the RTEMS invoke the user's ISR with the vector number and - * a pointer to the saved interrupt frame (1) or just the vector - * number (0)? - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_ISR_PASSES_FRAME_POINTER TRUE - -/** - * @def CPU_HARDWARE_FP - * - * Does the CPU have hardware floating point? - * - * If TRUE, then the RTEMS_FLOATING_POINT task attribute is supported. - * If FALSE, then the RTEMS_FLOATING_POINT task attribute is ignored. - * - * If there is a FP coprocessor such as the i387 or mc68881, then - * the answer is TRUE. - * - * The macro name "NO_CPU_HAS_FPU" should be made CPU specific. - * It indicates whether or not this CPU model has FP support. For - * example, it would be possible to have an i386_nofp CPU model - * which set this to false to indicate that you have an i386 without - * an i387 and wish to leave floating point support out of RTEMS. - */ - -/** - * @def CPU_SOFTWARE_FP - * - * Does the CPU have no hardware floating point and GCC provides a - * software floating point implementation which must be context - * switched? - * - * This feature conditional is used to indicate whether or not there - * is software implemented floating point that must be context - * switched. The determination of whether or not this applies - * is very tool specific and the state saved/restored is also - * compiler specific. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#if ( BLACKFIN_CPU_HAS_FPU == 1 ) -#define CPU_HARDWARE_FP TRUE -#else -#define CPU_HARDWARE_FP FALSE -#endif -#define CPU_SOFTWARE_FP FALSE - -/** - * Are all tasks RTEMS_FLOATING_POINT tasks implicitly? - * - * If TRUE, then the RTEMS_FLOATING_POINT task attribute is assumed. - * If FALSE, then the RTEMS_FLOATING_POINT task attribute is followed. - * - * So far, the only CPUs in which this option has been used are the - * HP PA-RISC and PowerPC. On the PA-RISC, The HP C compiler and - * gcc both implicitly used the floating point registers to perform - * integer multiplies. Similarly, the PowerPC port of gcc has been - * seen to allocate floating point local variables and touch the FPU - * even when the flow through a subroutine (like vfprintf()) might - * not use floating point formats. - * - * If a function which you would not think utilize the FP unit DOES, - * then one can not easily predict which tasks will use the FP hardware. - * In this case, this option should be TRUE. - * - * If @ref CPU_HARDWARE_FP is FALSE, then this should be FALSE as well. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_ALL_TASKS_ARE_FP FALSE - -/** - * Should the IDLE task have a floating point context? - * - * If TRUE, then the IDLE task is created as a RTEMS_FLOATING_POINT task - * and it has a floating point context which is switched in and out. - * If FALSE, then the IDLE task does not have a floating point context. - * - * Setting this to TRUE negatively impacts the time required to preempt - * the IDLE task from an interrupt because the floating point context - * must be saved as part of the preemption. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_IDLE_TASK_IS_FP FALSE - -/** - * Should the saving of the floating point registers be deferred - * until a context switch is made to another different floating point - * task? - * - * If TRUE, then the floating point context will not be stored until - * necessary. It will remain in the floating point registers and not - * disturned until another floating point task is switched to. - * - * If FALSE, then the floating point context is saved when a floating - * point task is switched out and restored when the next floating point - * task is restored. The state of the floating point registers between - * those two operations is not specified. - * - * If the floating point context does NOT have to be saved as part of - * interrupt dispatching, then it should be safe to set this to TRUE. - * - * Setting this flag to TRUE results in using a different algorithm - * for deciding when to save and restore the floating point context. - * The deferred FP switch algorithm minimizes the number of times - * the FP context is saved and restored. The FP context is not saved - * until a context switch is made to another, different FP task. - * Thus in a system with only one FP task, the FP context will never - * be saved or restored. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_USE_DEFERRED_FP_SWITCH TRUE - -#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE - -/** - * Does this port provide a CPU dependent IDLE task implementation? - * - * If TRUE, then the routine @ref _CPU_Thread_Idle_body - * must be provided and is the default IDLE thread body instead of - * @ref _CPU_Thread_Idle_body. - * - * If FALSE, then use the generic IDLE thread body if the BSP does - * not provide one. - * - * This is intended to allow for supporting processors which have - * a low power or idle mode. When the IDLE thread is executed, then - * the CPU can be powered down. - * - * The order of precedence for selecting the IDLE thread body is: - * - * -# BSP provided - * -# CPU dependent (if provided) - * -# generic (if no BSP and no CPU dependent) - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_PROVIDES_IDLE_THREAD_BODY TRUE - -/** - * Does the stack grow up (toward higher addresses) or down - * (toward lower addresses)? - * - * If TRUE, then the grows upward. - * If FALSE, then the grows toward smaller addresses. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_STACK_GROWS_UP FALSE - -/* FIXME: Is this the right value? */ -#define CPU_CACHE_LINE_BYTES 32 - -#define CPU_STRUCTURE_ALIGNMENT - -/** - * @ingroup CPUInterrupt - * The following defines the number of bits actually used in the - * interrupt field of the task mode. How those bits map to the - * CPU interrupt levels is defined by the routine @ref _CPU_ISR_Set_level. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_MODES_INTERRUPT_MASK 0x00000001 - -#define CPU_MAXIMUM_PROCESSORS 32 - -/* - * Processor defined structures required for cpukit/score. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ - -/* may need to put some structures here. */ - -#ifndef ASM - -/** - * @defgroup CPUContext Processor Dependent Context Management - * - * From the highest level viewpoint, there are 2 types of context to save. - * - * -# Interrupt registers to save - * -# Task level registers to save - * - * Since RTEMS handles integer and floating point contexts separately, this - * means we have the following 3 context items: - * - * -# task level context stuff:: Context_Control - * -# floating point task stuff:: Context_Control_fp - * -# special interrupt level context :: CPU_Interrupt_frame - * - * On some processors, it is cost-effective to save only the callee - * preserved registers during a task context switch. This means - * that the ISR code needs to save those registers which do not - * persist across function calls. It is not mandatory to make this - * distinctions between the caller/callee saves registers for the - * purpose of minimizing context saved during task switch and on interrupts. - * If the cost of saving extra registers is minimal, simplicity is the - * choice. Save the same context on interrupt entry as for tasks in - * this case. - * - * Additionally, if gdb is to be made aware of RTEMS tasks for this CPU, then - * care should be used in designing the context area. - * - * On some CPUs with hardware floating point support, the Context_Control_fp - * structure will not be used or it simply consist of an array of a - * fixed number of bytes. This is done when the floating point context - * is dumped by a "FP save context" type instruction and the format - * is not really defined by the CPU. In this case, there is no need - * to figure out the exact format -- only the size. Of course, although - * this is enough information for RTEMS, it is probably not enough for - * a debugger such as gdb. But that is another problem. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -/**@{**/ - -/** - * This defines the minimal set of integer and processor state registers - * that must be saved during a voluntary context switch from one thread - * to another. - */ - -/* make sure this stays in sync with the assembly function - __CPU_Context_switch in cpu_asm.S */ -typedef struct { - uint32_t register_r4; - uint32_t register_r5; - uint32_t register_r6; - uint32_t register_r7; - - uint32_t register_p3; - uint32_t register_p4; - uint32_t register_p5; - uint32_t register_fp; - uint32_t register_sp; - - uint32_t register_rets; - - uint32_t imask; -} Context_Control; - -#define _CPU_Context_Get_SP( _context ) \ - (_context)->register_sp - -/** - * This defines the complete set of floating point registers that must - * be saved during any context switch from one thread to another. - */ -typedef struct { - /* FPU registers are listed here */ - /* Blackfin has no Floating Point */ -} Context_Control_fp; - -/** - * This defines the set of integer and processor state registers that must - * be saved during an interrupt. This set does not include any which are - * in @ref Context_Control. - */ -typedef struct { - /** This field is a hint that a port will have a number of integer - * registers that need to be saved when an interrupt occurs or - * when a context switch occurs at the end of an ISR. - */ - /*uint32_t special_interrupt_register;*/ -} CPU_Interrupt_frame; - -/** @} */ - -/** - * @defgroup CPUInterrupt Processor Dependent Interrupt Management - * - * On some CPUs, RTEMS supports a software managed interrupt stack. - * This stack is allocated by the Interrupt Manager and the switch - * is performed in @ref _ISR_Handler. These variables contain pointers - * to the lowest and highest addresses in the chunk of memory allocated - * for the interrupt stack. Since it is unknown whether the stack - * grows up or down (in general), this give the CPU dependent - * code the option of picking the version it wants to use. - * - * @note These two variables are required if the macro - * @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK is defined as TRUE. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -/**@{**/ - -/* - * Nothing prevents the porter from declaring more CPU specific variables. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ - -/* XXX: if needed, put more variables here */ - -/** - * @ingroup CPUContext - * The size of the floating point context area. On some CPUs this - * will not be a "sizeof" because the format of the floating point - * area is not defined -- only the size is. This is usually on - * CPUs with a "floating point save context" instruction. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp ) - -#endif /* ASM */ - -/** - * Amount of extra stack (above minimum stack size) required by - * MPCI receive server thread. Remember that in a multiprocessor - * system this thread must exist and be able to process all directives. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0 - -/** - * @ingroup CPUInterrupt - * This defines the number of entries in the @ref _ISR_Vector_table managed - * by RTEMS. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_INTERRUPT_NUMBER_OF_VECTORS 16 - -/** - * @ingroup CPUInterrupt - * This defines the highest interrupt vector number for this port. - */ -#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER (CPU_INTERRUPT_NUMBER_OF_VECTORS - 1) - -/** - * @ingroup CPUInterrupt - * This is defined if the port has a special way to report the ISR nesting - * level. Most ports maintain the variable @a _ISR_Nest_level. - */ -#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE - -/** @} */ - -/** - * @ingroup CPUContext - * Should be large enough to run all RTEMS tests. This ensures - * that a "reasonable" small application should not have any problems. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_STACK_MINIMUM_SIZE (1024*8) - -#define CPU_SIZEOF_POINTER 4 - -/** - * CPU's worst alignment requirement for data types on a byte boundary. This - * alignment does not take into account the requirements for the stack. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_ALIGNMENT 8 - -/** - * This number corresponds to the byte alignment requirement for the - * heap handler. This alignment requirement may be stricter than that - * for the data types alignment specified by @ref CPU_ALIGNMENT. It is - * common for the heap to follow the same alignment requirement as - * @ref CPU_ALIGNMENT. If the @ref CPU_ALIGNMENT is strict enough for - * the heap, then this should be set to @ref CPU_ALIGNMENT. - * - * @note This does not have to be a power of 2 although it should be - * a multiple of 2 greater than or equal to 2. The requirement - * to be a multiple of 2 is because the heap uses the least - * significant field of the front and back flags to indicate - * that a block is in use or free. So you do not want any odd - * length blocks really putting length data in that bit. - * - * On byte oriented architectures, @ref CPU_HEAP_ALIGNMENT normally will - * have to be greater or equal to than @ref CPU_ALIGNMENT to ensure that - * elements allocated from the heap meet all restrictions. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT - -/** - * This number corresponds to the byte alignment requirement for memory - * buffers allocated by the partition manager. This alignment requirement - * may be stricter than that for the data types alignment specified by - * @ref CPU_ALIGNMENT. It is common for the partition to follow the same - * alignment requirement as @ref CPU_ALIGNMENT. If the @ref CPU_ALIGNMENT is - * strict enough for the partition, then this should be set to - * @ref CPU_ALIGNMENT. - * - * @note This does not have to be a power of 2. It does have to - * be greater or equal to than @ref CPU_ALIGNMENT. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT - -/** - * This number corresponds to the byte alignment requirement for the - * stack. This alignment requirement may be stricter than that for the - * data types alignment specified by @ref CPU_ALIGNMENT. If the - * @ref CPU_ALIGNMENT is strict enough for the stack, then this should be - * set to 0. - * - * @note This must be a power of 2 either 0 or greater than @ref CPU_ALIGNMENT. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_STACK_ALIGNMENT 8 - -#ifndef ASM - -/* - * ISR handler macros - */ - -/** - * @addtogroup CPUInterrupt - */ -/**@{**/ - -/** - * Support routine to initialize the RTEMS vector table after it is allocated. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_Initialize_vectors() - -/** - * Disable all interrupts for an RTEMS critical section. The previous - * level is returned in @a _isr_cookie. - * - * @param[out] _isr_cookie will contain the previous level cookie - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_ISR_Disable( _level ) \ - { \ - __asm__ volatile ("cli %0; csync \n" : "=d" (_level) ); \ - } - - -/** - * Enable interrupts to the previous level (returned by _CPU_ISR_Disable). - * This indicates the end of an RTEMS critical section. The parameter - * @a _isr_cookie is not modified. - * - * @param[in] _isr_cookie contain the previous level cookie - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_ISR_Enable( _level ) { \ - __asm__ __volatile__ ("sti %0; csync \n" : : "d" (_level) ); \ - } - -/** - * This temporarily restores the interrupt to @a _isr_cookie before immediately - * disabling them again. This is used to divide long RTEMS critical - * sections into two or more parts. The parameter @a _isr_cookie is not - * modified. - * - * @param[in] _isr_cookie contain the previous level cookie - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_ISR_Flash( _level ) { \ - __asm__ __volatile__ ("sti %0; csync; cli r0; csync" \ - : : "d"(_level) : "R0" ); \ - } - -RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) -{ - return level != 0; -} - -/** - * This routine and @ref _CPU_ISR_Get_level - * Map the interrupt level in task mode onto the hardware that the CPU - * actually provides. Currently, interrupt levels which do not - * map onto the CPU in a generic fashion are undefined. Someday, - * it would be nice if these were "mapped" by the application - * via a callout. For example, m68k has 8 levels 0 - 7, levels - * 8 - 255 would be available for bsp/application specific meaning. - * This could be used to manage a programmable interrupt controller - * via the rtems_task_mode directive. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_ISR_Set_level( _new_level ) \ - { \ - __asm__ __volatile__ ( "sti %0; csync" : : "d"(_new_level ? 0 : 0xffff) ); \ - } - -/** - * Return the current interrupt disable level for this task in - * the format used by the interrupt level portion of the task mode. - * - * @note This routine usually must be implemented as a subroutine. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -uint32_t _CPU_ISR_Get_level( void ); - -/* end of ISR handler macros */ - -/** @} */ - -/* Context handler macros */ - -/** - * @ingroup CPUContext - * Initialize the context to a state suitable for starting a - * task after a context restore operation. Generally, this - * involves: - * - * - setting a starting address - * - preparing the stack - * - preparing the stack and frame pointers - * - setting the proper interrupt level in the context - * - initializing the floating point context - * - * This routine generally does not set any unnecessary register - * in the context. The state of the "general data" registers is - * undefined at task start time. - * - * @param[in] _the_context is the context structure to be initialized - * @param[in] _stack_base is the lowest physical address of this task's stack - * @param[in] _size is the size of this task's stack - * @param[in] _isr is the interrupt disable level - * @param[in] _entry_point is the thread's entry point. This is - * always @a _Thread_Handler - * @param[in] _is_fp is TRUE if the thread is to be a floating - * point thread. This is typically only used on CPUs where the - * FPU may be easily disabled by software such as on the SPARC - * where the PSR contains an enable FPU bit. - * @param[in] tls_area is the thread-local storage (TLS) area - * - * Port Specific Information: - * - * See implementation in cpu.c - */ -void _CPU_Context_Initialize( - Context_Control *the_context, - uint32_t *stack_base, - uint32_t size, - uint32_t new_level, - void *entry_point, - bool is_fp, - void *tls_area -); - -/** - * This routine is responsible for somehow restarting the currently - * executing task. If you are lucky, then all that is necessary - * is restoring the context. Otherwise, there will need to be - * a special assembly routine which does something special in this - * case. For many ports, simply adding a label to the restore path - * of @ref _CPU_Context_switch will work. On other ports, it may be - * possibly to load a few arguments and jump to the restore path. It will - * not work if restarting self conflicts with the stack frame - * assumptions of restoring a context. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_Context_Restart_self( _the_context ) \ - _CPU_Context_restore( (_the_context) ); - -#define _CPU_Context_Initialize_fp( _destination ) \ - memset( *( _destination ), 0, CPU_CONTEXT_FP_SIZE ); - -/* end of Context handler macros */ - -/* Fatal Error manager macros */ - -/** - * This routine copies _error into a known place -- typically a stack - * location or a register, optionally disables interrupts, and - * halts/stops the CPU. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_Fatal_halt( _source, _error ) \ - { \ - __asm__ volatile ( "cli R1; \ - R1 = %0; \ - _halt: \ - idle; \ - jump _halt;"\ - : : "r" (_error) ); \ - } - -/* end of Fatal Error manager macros */ - -#define CPU_USE_GENERIC_BITFIELD_CODE TRUE - -/* functions */ - -/** - * @brief CPU initialize. - * This routine performs CPU dependent initialization. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_Initialize(void); - -/** - * @ingroup CPUInterrupt - * This routine installs a "raw" interrupt handler directly into the - * processor's vector table. - * - * @param[in] vector is the vector number - * @param[in] new_handler is the raw ISR handler to install - * @param[in] old_handler is the previously installed ISR Handler - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_ISR_install_raw_handler( - uint32_t vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -/** - * @ingroup CPUInterrupt - * This routine installs an interrupt vector. - * - * @param[in] vector is the vector number - * @param[in] new_handler is the RTEMS ISR handler to install - * @param[in] old_handler is the previously installed ISR Handler - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_ISR_install_vector( - uint32_t vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -/** - * @ingroup CPUInterrupt - * This routine installs the hardware interrupt stack pointer. - * - * @note It need only be provided if @ref CPU_HAS_HARDWARE_INTERRUPT_STACK - * is TRUE. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_Install_interrupt_stack( void ); - -/** - * This routine is the CPU dependent IDLE thread body. - * - * @note It need only be provided if @ref CPU_PROVIDES_IDLE_THREAD_BODY - * is TRUE. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void *_CPU_Thread_Idle_body( uintptr_t ignored ); - -/** - * @addtogroup CPUContext - */ -/**@{**/ - -/** - * This routine switches from the run context to the heir context. - * - * @param[in] run points to the context of the currently executing task - * @param[in] heir points to the context of the heir task - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_Context_switch( - Context_Control *run, - Context_Control *heir -); - -/** - * This routine is generally used only to restart self in an - * efficient manner. It may simply be a label in @ref _CPU_Context_switch. - * - * @param[in] new_context points to the context to be restored. - * - * @note May be unnecessary to reload some registers. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_Context_restore( - Context_Control *new_context -) RTEMS_NO_RETURN; - -/** - * This routine saves the floating point context passed to it. - * - * @param[in] fp_context_ptr is a pointer to a pointer to a floating - * point context area - * - * @return on output @a *fp_context_ptr will contain the address that - * should be used with @ref _CPU_Context_restore_fp to restore this context. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_Context_save_fp( - Context_Control_fp **fp_context_ptr -); - -/** - * This routine restores the floating point context passed to it. - * - * @param[in] fp_context_ptr is a pointer to a pointer to a floating - * point context area to restore - * - * @return on output @a *fp_context_ptr will contain the address that - * should be used with @ref _CPU_Context_save_fp to save this context. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_Context_restore_fp( - Context_Control_fp **fp_context_ptr -); - -static inline void _CPU_Context_volatile_clobber( uintptr_t pattern ) -{ - /* TODO */ -} - -static inline void _CPU_Context_validate( uintptr_t pattern ) -{ - while (1) { - /* TODO */ - } -} - -/** @} */ - -/* FIXME */ -typedef CPU_Interrupt_frame CPU_Exception_frame; - -void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); - -/** - * @ingroup CPUEndian - * The following routine swaps the endian format of an unsigned int. - * It must be static because it is referenced indirectly. - * - * This version will work on any processor, but if there is a better - * way for your CPU PLEASE use it. The most common way to do this is to: - * - * swap least significant two bytes with 16-bit rotate - * swap upper and lower 16-bits - * swap most significant two bytes with 16-bit rotate - * - * Some CPUs have special instructions which swap a 32-bit quantity in - * a single instruction (e.g. i486). It is probably best to avoid - * an "endian swapping control bit" in the CPU. One good reason is - * that interrupts would probably have to be disabled to ensure that - * an interrupt does not try to access the same "chunk" with the wrong - * endian. Another good reason is that on some CPUs, the endian bit - * endianness for ALL fetches -- both code and data -- so the code - * will be fetched incorrectly. - * - * @param[in] value is the value to be swapped - * @return the value after being endian swapped - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -static inline uint32_t CPU_swap_u32( - uint32_t value -) -{ - uint32_t byte1, byte2, byte3, byte4, swapped; - - byte4 = (value >> 24) & 0xff; - byte3 = (value >> 16) & 0xff; - byte2 = (value >> 8) & 0xff; - byte1 = value & 0xff; - - swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4; - return( swapped ); -} - -/** - * @ingroup CPUEndian - * This routine swaps a 16 bir quantity. - * - * @param[in] value is the value to be swapped - * @return the value after being endian swapped - */ -#define CPU_swap_u16( value ) \ - (((value&0xff) << 8) | ((value >> 8)&0xff)) - -typedef uint32_t CPU_Counter_ticks; - -CPU_Counter_ticks _CPU_Counter_read( void ); - -static inline CPU_Counter_ticks _CPU_Counter_difference( - CPU_Counter_ticks second, - CPU_Counter_ticks first -) -{ - return second - first; -} - -#endif /* ASM */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/score/cpu/bfin/rtems/score/cpu_asm.h b/cpukit/score/cpu/bfin/rtems/score/cpu_asm.h deleted file mode 100644 index 4f78c9d358..0000000000 --- a/cpukit/score/cpu/bfin/rtems/score/cpu_asm.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @file - * - * @brief Blackfin Assembly File - * - * Defines a couple of Macros used in cpu_asm.S - */ - -/* - * COPYRIGHT (c) 2006 by Atos Automacao Industrial Ltda. - * written by Alain Schaefer - * and Antonio Giovanini - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - * - */ - -#ifndef _RTEMS_SCORE_CPU_ASM_H -#define _RTEMS_SCORE_CPU_ASM_H - - - -#endif - -/* end of file */ diff --git a/cpukit/score/cpu/bfin/rtems/score/cpuatomic.h b/cpukit/score/cpu/bfin/rtems/score/cpuatomic.h deleted file mode 100644 index 598ee76b20..0000000000 --- a/cpukit/score/cpu/bfin/rtems/score/cpuatomic.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * COPYRIGHT (c) 2012-2013 Deng Hengyi. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_ATOMIC_CPU_H -#define _RTEMS_SCORE_ATOMIC_CPU_H - -#include - -#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/bfin/rtems/score/cpuimpl.h b/cpukit/score/cpu/bfin/rtems/score/cpuimpl.h deleted file mode 100644 index 789f2badd9..0000000000 --- a/cpukit/score/cpu/bfin/rtems/score/cpuimpl.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @file - * - * @brief CPU Port Implementation API - */ - -/* - * Copyright (c) 2013 embedded brains GmbH - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPUIMPL_H -#define _RTEMS_SCORE_CPUIMPL_H - -#include - -#define CPU_PER_CPU_CONTROL_SIZE 0 - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* ASM */ - -#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/bfin/rtems/score/types.h b/cpukit/score/cpu/bfin/rtems/score/types.h deleted file mode 100644 index 9865357cdd..0000000000 --- a/cpukit/score/cpu/bfin/rtems/score/types.h +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @file - * - * @brief Blackfin CPU Type Definitions - * - * This include file contains type definitions pertaining to the - * Blackfin processor family. - */ - -/* - * COPYRIGHT (c) 1989-2006. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_TYPES_H -#define _RTEMS_SCORE_TYPES_H - -#include - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This section defines the basic types for this processor. - */ - -/** Type that can store a 32-bit integer or a pointer. */ -typedef uintptr_t CPU_Uint32ptr; - -/** This defines the return type for an ISR entry point. */ -typedef void blackfin_isr; - -/** This defines the prototype for an ISR entry point. */ -typedef blackfin_isr ( *blackfin_isr_entry )( void ); - -#ifdef __cplusplus -} -#endif - -#endif /* !ASM */ - -#endif diff --git a/cpukit/score/cpu/epiphany/Makefile.am b/cpukit/score/cpu/epiphany/Makefile.am index ed99b436e6..96b0de0054 100644 --- a/cpukit/score/cpu/epiphany/Makefile.am +++ b/cpukit/score/cpu/epiphany/Makefile.am @@ -3,21 +3,6 @@ include $(top_srcdir)/automake/compile.am CLEANFILES = DISTCLEANFILES = -include_rtemsdir = $(includedir)/rtems - -include_rtems_HEADERS = rtems/asm.h - -include_rtems_scoredir = $(includedir)/rtems/score - -include_rtems_score_HEADERS = -include_rtems_score_HEADERS += rtems/score/cpu.h -include_rtems_score_HEADERS += rtems/score/cpuimpl.h -include_rtems_score_HEADERS += rtems/score/cpuatomic.h -include_rtems_score_HEADERS += rtems/score/cpu_asm.h -include_rtems_score_HEADERS += rtems/score/types.h -include_rtems_score_HEADERS += rtems/score/epiphany.h -include_rtems_score_HEADERS += rtems/score/epiphany-utility.h - noinst_LIBRARIES = libscorecpu.a libscorecpu_a_SOURCES = cpu.c @@ -29,5 +14,5 @@ libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS) all-local: $(PREINSTALL_FILES) -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am +include $(srcdir)/headers.am diff --git a/cpukit/score/cpu/epiphany/headers.am b/cpukit/score/cpu/epiphany/headers.am new file mode 100644 index 0000000000..125a88dcd9 --- /dev/null +++ b/cpukit/score/cpu/epiphany/headers.am @@ -0,0 +1,15 @@ +## This file was generated by "./boostrap -H". + +include_rtemsdir = $(includedir)/rtems +include_rtems_HEADERS = +include_rtems_HEADERS += include/rtems/asm.h + +include_rtems_scoredir = $(includedir)/rtems/score +include_rtems_score_HEADERS = +include_rtems_score_HEADERS += include/rtems/score/cpu.h +include_rtems_score_HEADERS += include/rtems/score/cpu_asm.h +include_rtems_score_HEADERS += include/rtems/score/cpuatomic.h +include_rtems_score_HEADERS += include/rtems/score/cpuimpl.h +include_rtems_score_HEADERS += include/rtems/score/epiphany-utility.h +include_rtems_score_HEADERS += include/rtems/score/epiphany.h +include_rtems_score_HEADERS += include/rtems/score/types.h diff --git a/cpukit/score/cpu/epiphany/include/rtems/asm.h b/cpukit/score/cpu/epiphany/include/rtems/asm.h new file mode 100644 index 0000000000..87e0cca1cb --- /dev/null +++ b/cpukit/score/cpu/epiphany/include/rtems/asm.h @@ -0,0 +1,120 @@ +/** + * @file rtems/asm.h + * + * This include file attempts to address the problems + * caused by incompatible flavors of assemblers and + * toolsets. It primarily addresses variations in the + * use of leading underscores on symbols and the requirement + * that register names be preceded by a %. + */ + +/* + * NOTE: The spacing in the use of these macros + * is critical to them working as advertised. + * + * This file is based on similar code found in newlib available + * from ftp.cygnus.com. The file which was used had no copyright + * notice. This file is freely distributable as long as the source + * of the file is noted. This file is: + * + * Copyright (c) 2015 University of York. + * Hesham ALMatary + * + * + * COPYRIGHT (c) 1994-1997. + * On-Line Applications Research Corporation (OAR). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef __EPIPHANY_ASM_H +#define __EPIPHANY_ASM_H + +/* + * Indicate we are in an assembly file and get the basic CPU definitions. + */ + +#ifndef ASM +#define ASM +#endif +#include +#include + +/* + * Recent versions of GNU cpp define variables which indicate the + * need for underscores and percents. If not using GNU cpp or + * the version does not support this, then you will obviously + * have to define these as appropriate. + */ + +#ifndef __USER_LABEL_PREFIX__ +#define __USER_LABEL_PREFIX__ _ +#endif + +#ifndef __REGISTER_PREFIX__ +#define __REGISTER_PREFIX__ +#endif + +/* ANSI concatenation macros. */ + +#define CONCAT1(a, b) CONCAT2(a, b) +#define CONCAT2(a, b) a ## b + +/* Use the right prefix for global labels. */ + +#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) + +/* Use the right prefix for registers. */ + +#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) + +/* + * define macros for all of the registers on this CPU + * + * EXAMPLE: #define d0 REG (d0) + */ + +/* + * Define macros to handle section beginning and ends. + */ +#define BEGIN_CODE_DCL .text +#define END_CODE_DCL +#define BEGIN_DATA_DCL .data +#define END_DATA_DCL +#define BEGIN_CODE .text +#define END_CODE +#define BEGIN_DATA +#define END_DATA +#define BEGIN_BSS +#define END_BSS +#define END + +/* + * Following must be tailor for a particular flavor of the C compiler. + * They may need to put underscores in front of the symbols. + */ + +#define PUBLIC(sym) .global SYM (sym) +#define EXTERN(sym) .extern SYM (sym) +#define TYPE_FUNC(sym) .type SYM (sym), %function + +#endif diff --git a/cpukit/score/cpu/epiphany/include/rtems/score/cpu.h b/cpukit/score/cpu/epiphany/include/rtems/score/cpu.h new file mode 100644 index 0000000000..34ac8ae6c6 --- /dev/null +++ b/cpukit/score/cpu/epiphany/include/rtems/score/cpu.h @@ -0,0 +1,873 @@ +/** + * @file rtems/score/cpu.h + */ + +/* + * + * Copyright (c) 2015 University of York. + * Hesham ALMatary + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _EPIPHANY_CPU_H +#define _EPIPHANY_CPU_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include /* pick up machine definitions */ +#include +#ifndef ASM +#include +#include +#include /* for printk */ +#endif + +/* conditional compilation parameters */ + +/* + * Does RTEMS manage a dedicated interrupt stack in software? + * + * If TRUE, then a stack is allocated in _ISR_Handler_initialization. + * If FALSE, nothing is done. + * + * If the CPU supports a dedicated interrupt stack in hardware, + * then it is generally the responsibility of the BSP to allocate it + * and set it up. + * + * If the CPU does not support a dedicated interrupt stack, then + * the porter has two options: (1) execute interrupts on the + * stack of the interrupted task, and (2) have RTEMS manage a dedicated + * interrupt stack. + * + * If this is TRUE, CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. + * + * Only one of CPU_HAS_SOFTWARE_INTERRUPT_STACK and + * CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is + * possible that both are FALSE for a particular CPU. Although it + * is unclear what that would imply about the interrupt processing + * procedure on that CPU. + * + * Currently, for epiphany port, _ISR_Handler is responsible for switching to + * RTEMS dedicated interrupt task. + * + */ + +#define CPU_HAS_SOFTWARE_INTERRUPT_STACK TRUE + +/* + * Does this CPU have hardware support for a dedicated interrupt stack? + * + * If TRUE, then it must be installed during initialization. + * If FALSE, then no installation is performed. + * + * If this is TRUE, CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. + * + * Only one of CPU_HAS_SOFTWARE_INTERRUPT_STACK and + * CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is + * possible that both are FALSE for a particular CPU. Although it + * is unclear what that would imply about the interrupt processing + * procedure on that CPU. + * + */ + +#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE + +/* + * Does RTEMS allocate a dedicated interrupt stack in the Interrupt Manager? + * + * If TRUE, then the memory is allocated during initialization. + * If FALSE, then the memory is allocated during initialization. + * + * This should be TRUE is CPU_HAS_SOFTWARE_INTERRUPT_STACK is TRUE + * or CPU_INSTALL_HARDWARE_INTERRUPT_STACK is TRUE. + * + */ + +#define CPU_ALLOCATE_INTERRUPT_STACK TRUE + +/* + * Does the RTEMS invoke the user's ISR with the vector number and + * a pointer to the saved interrupt frame (1) or just the vector + * number (0)? + * + */ + +#define CPU_ISR_PASSES_FRAME_POINTER TRUE + +/* + * Does the CPU have hardware floating point? + * + * If TRUE, then the RTEMS_FLOATING_POINT task attribute is supported. + * If FALSE, then the RTEMS_FLOATING_POINT task attribute is ignored. + * + * If there is a FP coprocessor such as the i387 or mc68881, then + * the answer is TRUE. + * + * The macro name "epiphany_HAS_FPU" should be made CPU specific. + * It indicates whether or not this CPU model has FP support. For + * example, it would be possible to have an i386_nofp CPU model + * which set this to false to indicate that you have an i386 without + * an i387 and wish to leave floating point support out of RTEMS. + * + * The CPU_SOFTWARE_FP is used to indicate whether or not there + * is software implemented floating point that must be context + * switched. The determination of whether or not this applies + * is very tool specific and the state saved/restored is also + * compiler specific. + * + * epiphany Specific Information: + * + * At this time there are no implementations of Epiphany that are + * expected to implement floating point. + */ + +#define CPU_HARDWARE_FP FALSE +#define CPU_SOFTWARE_FP FALSE + +/* + * Are all tasks RTEMS_FLOATING_POINT tasks implicitly? + * + * If TRUE, then the RTEMS_FLOATING_POINT task attribute is assumed. + * If FALSE, then the RTEMS_FLOATING_POINT task attribute is followed. + * + * If CPU_HARDWARE_FP is FALSE, then this should be FALSE as well. + * + */ + +#define CPU_ALL_TASKS_ARE_FP FALSE + +/* + * Should the IDLE task have a floating point context? + * + * If TRUE, then the IDLE task is created as a RTEMS_FLOATING_POINT task + * and it has a floating point context which is switched in and out. + * If FALSE, then the IDLE task does not have a floating point context. + * + * Setting this to TRUE negatively impacts the time required to preempt + * the IDLE task from an interrupt because the floating point context + * must be saved as part of the preemption. + * + */ + +#define CPU_IDLE_TASK_IS_FP FALSE + +/* + * Should the saving of the floating point registers be deferred + * until a context switch is made to another different floating point + * task? + * + * If TRUE, then the floating point context will not be stored until + * necessary. It will remain in the floating point registers and not + * disturned until another floating point task is switched to. + * + * If FALSE, then the floating point context is saved when a floating + * point task is switched out and restored when the next floating point + * task is restored. The state of the floating point registers between + * those two operations is not specified. + * + * If the floating point context does NOT have to be saved as part of + * interrupt dispatching, then it should be safe to set this to TRUE. + * + * Setting this flag to TRUE results in using a different algorithm + * for deciding when to save and restore the floating point context. + * The deferred FP switch algorithm minimizes the number of times + * the FP context is saved and restored. The FP context is not saved + * until a context switch is made to another, different FP task. + * Thus in a system with only one FP task, the FP context will never + * be saved or restored. + * + */ + +#define CPU_USE_DEFERRED_FP_SWITCH FALSE + +#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE + +/* + * Does this port provide a CPU dependent IDLE task implementation? + * + * If TRUE, then the routine _CPU_Thread_Idle_body + * must be provided and is the default IDLE thread body instead of + * _CPU_Thread_Idle_body. + * + * If FALSE, then use the generic IDLE thread body if the BSP does + * not provide one. + * + * This is intended to allow for supporting processors which have + * a low power or idle mode. When the IDLE thread is executed, then + * the CPU can be powered down. + * + * The order of precedence for selecting the IDLE thread body is: + * + * 1. BSP provided + * 2. CPU dependent (if provided) + * 3. generic (if no BSP and no CPU dependent) + * + */ + +#define CPU_PROVIDES_IDLE_THREAD_BODY TRUE + +/* + * Does the stack grow up (toward higher addresses) or down + * (toward lower addresses)? + * + * If TRUE, then the grows upward. + * If FALSE, then the grows toward smaller addresses. + * + */ + +#define CPU_STACK_GROWS_UP FALSE + +/* FIXME: Is this the right value? */ +#define CPU_CACHE_LINE_BYTES 64 + +#define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES ) + +/* + * Define what is required to specify how the network to host conversion + * routines are handled. + * + * epiphany Specific Information: + * + * This version of RTEMS is designed specifically to run with + * big endian architectures. If you want little endian, you'll + * have to make the appropriate adjustments here and write + * efficient routines for byte swapping. The epiphany architecture + * doesn't do this very well. + */ + +#define CPU_HAS_OWN_HOST_TO_NETWORK_ROUTINES FALSE + +/* + * The following defines the number of bits actually used in the + * interrupt field of the task mode. How those bits map to the + * CPU interrupt levels is defined by the routine _CPU_ISR_Set_level(). + * + */ + +#define CPU_MODES_INTERRUPT_MASK 0x00000001 + +/* + * Processor defined structures required for cpukit/score. + */ + +/* + * Contexts + * + * Generally there are 2 types of context to save. + * 1. Interrupt registers to save + * 2. Task level registers to save + * + * This means we have the following 3 context items: + * 1. task level context stuff:: Context_Control + * 2. floating point task stuff:: Context_Control_fp + * 3. special interrupt level context :: Context_Control_interrupt + * + * On some processors, it is cost-effective to save only the callee + * preserved registers during a task context switch. This means + * that the ISR code needs to save those registers which do not + * persist across function calls. It is not mandatory to make this + * distinctions between the caller/callee saves registers for the + * purpose of minimizing context saved during task switch and on interrupts. + * If the cost of saving extra registers is minimal, simplicity is the + * choice. Save the same context on interrupt entry as for tasks in + * this case. + * + * Additionally, if gdb is to be made aware of RTEMS tasks for this CPU, then + * care should be used in designing the context area. + * + * On some CPUs with hardware floating point support, the Context_Control_fp + * structure will not be used or it simply consist of an array of a + * fixed number of bytes. This is done when the floating point context + * is dumped by a "FP save context" type instruction and the format + * is not really defined by the CPU. In this case, there is no need + * to figure out the exact format -- only the size. Of course, although + * this is enough information for RTEMS, it is probably not enough for + * a debugger such as gdb. But that is another problem. + * + * + */ +#ifndef ASM + +typedef struct { + uint32_t r[64]; + + uint32_t status; + uint32_t config; + uint32_t iret; + +#ifdef RTEMS_SMP + /** + * @brief On SMP configurations the thread context must contain a boolean + * indicator to signal if this context is executing on a processor. + * + * This field must be updated during a context switch. The context switch + * to the heir must wait until the heir context indicates that it is no + * longer executing on a processor. The context switch must also check if + * a thread dispatch is necessary to honor updates of the heir thread for + * this processor. This indicator must be updated using an atomic test and + * set operation to ensure that at most one processor uses the heir + * context at the same time. + * + * @code + * void _CPU_Context_switch( + * Context_Control *executing, + * Context_Control *heir + * ) + * { + * save( executing ); + * + * executing->is_executing = false; + * memory_barrier(); + * + * if ( test_and_set( &heir->is_executing ) ) { + * do { + * Per_CPU_Control *cpu_self = _Per_CPU_Get_snapshot(); + * + * if ( cpu_self->dispatch_necessary ) { + * heir = _Thread_Get_heir_and_make_it_executing( cpu_self ); + * } + * } while ( test_and_set( &heir->is_executing ) ); + * } + * + * restore( heir ); + * } + * @endcode + */ + volatile bool is_executing; +#endif +} Context_Control; + +#define _CPU_Context_Get_SP( _context ) \ + (_context)->r[13] + +typedef struct { + /** FPU registers are listed here */ + double some_float_register; +} Context_Control_fp; + +typedef Context_Control CPU_Interrupt_frame; + +/* + * The size of the floating point context area. On some CPUs this + * will not be a "sizeof" because the format of the floating point + * area is not defined -- only the size is. This is usually on + * CPUs with a "floating point save context" instruction. + * + * epiphany Specific Information: + * + */ + +#define CPU_CONTEXT_FP_SIZE 0 + +/* + * Amount of extra stack (above minimum stack size) required by + * MPCI receive server thread. Remember that in a multiprocessor + * system this thread must exist and be able to process all directives. + * + */ + +#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0 + +/* + * Should be large enough to run all RTEMS tests. This insures + * that a "reasonable" small application should not have any problems. + * + */ + +#define CPU_STACK_MINIMUM_SIZE 4096 + +/* + * CPU's worst alignment requirement for data types on a byte boundary. This + * alignment does not take into account the requirements for the stack. + * + */ + +#define CPU_ALIGNMENT 8 + +/* + * This is defined if the port has a special way to report the ISR nesting + * level. Most ports maintain the variable _ISR_Nest_level. + */ +#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE + +/* + * This number corresponds to the byte alignment requirement for the + * heap handler. This alignment requirement may be stricter than that + * for the data types alignment specified by CPU_ALIGNMENT. It is + * common for the heap to follow the same alignment requirement as + * CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict enough for the heap, + * then this should be set to CPU_ALIGNMENT. + * + * NOTE: This does not have to be a power of 2 although it should be + * a multiple of 2 greater than or equal to 2. The requirement + * to be a multiple of 2 is because the heap uses the least + * significant field of the front and back flags to indicate + * that a block is in use or free. So you do not want any odd + * length blocks really putting length data in that bit. + * + * On byte oriented architectures, CPU_HEAP_ALIGNMENT normally will + * have to be greater or equal to than CPU_ALIGNMENT to ensure that + * elements allocated from the heap meet all restrictions. + * + */ + +#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT + +/* + * This number corresponds to the byte alignment requirement for memory + * buffers allocated by the partition manager. This alignment requirement + * may be stricter than that for the data types alignment specified by + * CPU_ALIGNMENT. It is common for the partition to follow the same + * alignment requirement as CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict + * enough for the partition, then this should be set to CPU_ALIGNMENT. + * + * NOTE: This does not have to be a power of 2. It does have to + * be greater or equal to than CPU_ALIGNMENT. + * + */ + +#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT + +/* + * This number corresponds to the byte alignment requirement for the + * stack. This alignment requirement may be stricter than that for the + * data types alignment specified by CPU_ALIGNMENT. If the CPU_ALIGNMENT + * is strict enough for the stack, then this should be set to 0. + * + * NOTE: This must be a power of 2 either 0 or greater than CPU_ALIGNMENT. + * + */ + +#define CPU_STACK_ALIGNMENT 8 + +/* ISR handler macros */ + +/* + * Support routine to initialize the RTEMS vector table after it is allocated. + * + * NO_CPU Specific Information: + * + * XXX document implementation including references if appropriate + */ + +#define _CPU_Initialize_vectors() + +/* + * Disable all interrupts for an RTEMS critical section. The previous + * level is returned in _level. + * + */ + +static inline uint32_t epiphany_interrupt_disable( void ) +{ + uint32_t sr; + __asm__ __volatile__ ("movfs %[sr], status \n" : [sr] "=r" (sr):); + __asm__ __volatile__("gid \n"); + return sr; +} + +static inline void epiphany_interrupt_enable(uint32_t level) +{ + __asm__ __volatile__("gie \n"); + __asm__ __volatile__ ("movts status, %[level] \n" :: [level] "r" (level):); +} + +#define _CPU_ISR_Disable( _level ) \ + _level = epiphany_interrupt_disable() + +/* + * Enable interrupts to the previous level (returned by _CPU_ISR_Disable). + * This indicates the end of an RTEMS critical section. The parameter + * _level is not modified. + * + */ + +#define _CPU_ISR_Enable( _level ) \ + epiphany_interrupt_enable( _level ) + +/* + * This temporarily restores the interrupt to _level before immediately + * disabling them again. This is used to divide long RTEMS critical + * sections into two or more parts. The parameter _level is not + * modified. + * + */ + +#define _CPU_ISR_Flash( _level ) \ + do{ \ + if ( (_level & 0x2) != 0 ) \ + _CPU_ISR_Enable( _level ); \ + epiphany_interrupt_disable(); \ + } while(0) + +RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) +{ + return ( level & 0x2 ) != 0; +} + +/* + * Map interrupt level in task mode onto the hardware that the CPU + * actually provides. Currently, interrupt levels which do not + * map onto the CPU in a generic fashion are undefined. Someday, + * it would be nice if these were "mapped" by the application + * via a callout. For example, m68k has 8 levels 0 - 7, levels + * 8 - 255 would be available for bsp/application specific meaning. + * This could be used to manage a programmable interrupt controller + * via the rtems_task_mode directive. + * + * The get routine usually must be implemented as a subroutine. + * + */ + +void _CPU_ISR_Set_level( uint32_t level ); + +uint32_t _CPU_ISR_Get_level( void ); + +/* end of ISR handler macros */ + +/* Context handler macros */ + +/* + * Initialize the context to a state suitable for starting a + * task after a context restore operation. Generally, this + * involves: + * + * - setting a starting address + * - preparing the stack + * - preparing the stack and frame pointers + * - setting the proper interrupt level in the context + * - initializing the floating point context + * + * This routine generally does not set any unnecessary register + * in the context. The state of the "general data" registers is + * undefined at task start time. + * + * NOTE: This is_fp parameter is TRUE if the thread is to be a floating + * point thread. This is typically only used on CPUs where the + * FPU may be easily disabled by software such as on the SPARC + * where the PSR contains an enable FPU bit. + * + */ + +/** + * @brief Account for GCC red-zone + * + * The following macro is used when initializing task's stack + * to account for GCC red-zone. + */ + +#define EPIPHANY_GCC_RED_ZONE_SIZE 128 + +/** + * @brief Initializes the CPU context. + * + * The following steps are performed: + * - setting a starting address + * - preparing the stack + * - preparing the stack and frame pointers + * - setting the proper interrupt level in the context + * + * @param[in] context points to the context area + * @param[in] stack_area_begin is the low address of the allocated stack area + * @param[in] stack_area_size is the size of the stack area in bytes + * @param[in] new_level is the interrupt level for the task + * @param[in] entry_point is the task's entry point + * @param[in] is_fp is set to @c true if the task is a floating point task + * @param[in] tls_area is the thread-local storage (TLS) area + */ +void _CPU_Context_Initialize( + Context_Control *context, + void *stack_area_begin, + size_t stack_area_size, + uint32_t new_level, + void (*entry_point)( void ), + bool is_fp, + void *tls_area +); + +/* + * This routine is responsible for somehow restarting the currently + * executing task. If you are lucky, then all that is necessary + * is restoring the context. Otherwise, there will need to be + * a special assembly routine which does something special in this + * case. Context_Restore should work most of the time. It will + * not work if restarting self conflicts with the stack frame + * assumptions of restoring a context. + * + */ + +#define _CPU_Context_Restart_self( _the_context ) \ + _CPU_Context_restore( (_the_context) ) + +#define _CPU_Context_Initialize_fp( _destination ) \ + memset( *( _destination ), 0, CPU_CONTEXT_FP_SIZE ); + +/* end of Context handler macros */ + +/* Fatal Error manager macros */ + +/* + * This routine copies _error into a known place -- typically a stack + * location or a register, optionally disables interrupts, and + * halts/stops the CPU. + * + */ + +#include + +#define _CPU_Fatal_halt(_source, _error ) \ + printk("Fatal Error %d.%" PRIu32 " Halted\n",_source, _error); \ + asm("trap 3" :: "r" (_error)); \ + for(;;) + +/* end of Fatal Error manager macros */ + +#define CPU_USE_GENERIC_BITFIELD_CODE TRUE + +#endif /* ASM */ + +/** + * Size of a pointer. + * + * This must be an integer literal that can be used by the assembler. This + * value will be used to calculate offsets of structure members. These + * offsets will be used in assembler code. + */ +#define CPU_SIZEOF_POINTER 4 +#define CPU_EXCEPTION_FRAME_SIZE 260 + +#define CPU_MAXIMUM_PROCESSORS 32 + +#ifndef ASM + +typedef struct { + uint32_t r[62]; + uint32_t status; + uint32_t config; + uint32_t iret; +} CPU_Exception_frame; + +/** + * @brief Prints the exception frame via printk(). + * + * @see rtems_fatal() and RTEMS_FATAL_SOURCE_EXCEPTION. + */ +void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); + + +/* end of Priority handler macros */ + +/* functions */ + +/* + * _CPU_Initialize + * + * This routine performs CPU dependent initialization. + * + */ + +void _CPU_Initialize( + void +); + +/* + * _CPU_ISR_install_raw_handler + * + * This routine installs a "raw" interrupt handler directly into the + * processor's vector table. + * + */ + +void _CPU_ISR_install_raw_handler( + uint32_t vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +/* + * _CPU_ISR_install_vector + * + * This routine installs an interrupt vector. + * + * NO_CPU Specific Information: + * + * XXX document implementation including references if appropriate + */ + +void _CPU_ISR_install_vector( + uint32_t vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +/* + * _CPU_Install_interrupt_stack + * + * This routine installs the hardware interrupt stack pointer. + * + * NOTE: It need only be provided if CPU_HAS_HARDWARE_INTERRUPT_STACK + * is TRUE. + * + */ + +void _CPU_Install_interrupt_stack( void ); + +/* + * _CPU_Thread_Idle_body + * + * This routine is the CPU dependent IDLE thread body. + * + * NOTE: It need only be provided if CPU_PROVIDES_IDLE_THREAD_BODY + * is TRUE. + * + */ + +void *_CPU_Thread_Idle_body( uintptr_t ignored ); + +/* + * _CPU_Context_switch + * + * This routine switches from the run context to the heir context. + * + * epiphany Specific Information: + * + * Please see the comments in the .c file for a description of how + * this function works. There are several things to be aware of. + */ + +void _CPU_Context_switch( + Context_Control *run, + Context_Control *heir +); + +/* + * _CPU_Context_restore + * + * This routine is generally used only to restart self in an + * efficient manner. It may simply be a label in _CPU_Context_switch. + * + * NOTE: May be unnecessary to reload some registers. + * + */ + +void _CPU_Context_restore( + Context_Control *new_context +) RTEMS_NO_RETURN; + +/* + * _CPU_Context_save_fp + * + * This routine saves the floating point context passed to it. + * + */ + +void _CPU_Context_save_fp( + void **fp_context_ptr +); + +/* + * _CPU_Context_restore_fp + * + * This routine restores the floating point context passed to it. + * + */ + +void _CPU_Context_restore_fp( + void **fp_context_ptr +); + +/* The following routine swaps the endian format of an unsigned int. + * It must be static because it is referenced indirectly. + * + * This version will work on any processor, but if there is a better + * way for your CPU PLEASE use it. The most common way to do this is to: + * + * swap least significant two bytes with 16-bit rotate + * swap upper and lower 16-bits + * swap most significant two bytes with 16-bit rotate + * + * Some CPUs have special instructions which swap a 32-bit quantity in + * a single instruction (e.g. i486). It is probably best to avoid + * an "endian swapping control bit" in the CPU. One good reason is + * that interrupts would probably have to be disabled to insure that + * an interrupt does not try to access the same "chunk" with the wrong + * endian. Another good reason is that on some CPUs, the endian bit + * endianness for ALL fetches -- both code and data -- so the code + * will be fetched incorrectly. + * + */ + +static inline unsigned int CPU_swap_u32( + unsigned int value +) +{ + uint32_t byte1, byte2, byte3, byte4, swapped; + + byte4 = (value >> 24) & 0xff; + byte3 = (value >> 16) & 0xff; + byte2 = (value >> 8) & 0xff; + byte1 = value & 0xff; + + swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4; + return( swapped ); +} + +#define CPU_swap_u16( value ) \ + (((value&0xff) << 8) | ((value >> 8)&0xff)) + +static inline void _CPU_Context_volatile_clobber( uintptr_t pattern ) +{ + /* TODO */ +} + +static inline void _CPU_Context_validate( uintptr_t pattern ) +{ + while (1) { + /* TODO */ + } +} + +typedef uint32_t CPU_Counter_ticks; + +CPU_Counter_ticks _CPU_Counter_read( void ); + +static inline CPU_Counter_ticks _CPU_Counter_difference( + CPU_Counter_ticks second, + CPU_Counter_ticks first +) +{ + return second - first; +} + +#endif /* ASM */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/score/cpu/epiphany/include/rtems/score/cpu_asm.h b/cpukit/score/cpu/epiphany/include/rtems/score/cpu_asm.h new file mode 100644 index 0000000000..cc091fa909 --- /dev/null +++ b/cpukit/score/cpu/epiphany/include/rtems/score/cpu_asm.h @@ -0,0 +1,74 @@ +/** + * @file + * + * @brief Epiphany Assembly File + * + * Very loose template for an include file for the cpu_asm.? file + * if it is implemented as a ".S" file (preprocessed by cpp) instead + * of a ".s" file (preprocessed by gm4 or gasp). + */ + +/* + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + */ + +#ifndef _RTEMS_SCORE_CPU_ASM_H +#define _RTEMS_SCORE_CPU_ASM_H + +/* pull in the generated offsets */ + +/* +#include +*/ + +/* + * Hardware General Registers + */ + +/* put something here */ + +/* + * Hardware Floating Point Registers + */ + +/* put something here */ + +/* + * Hardware Control Registers + */ + +/* put something here */ + +/* + * Calling Convention + */ + +/* put something here */ + +/* + * Temporary registers + */ + +/* put something here */ + +/* + * Floating Point Registers - SW Conventions + */ + +/* put something here */ + +/* + * Temporary floating point registers + */ + +/* put something here */ + +#endif + +/* end of file */ diff --git a/cpukit/score/cpu/epiphany/include/rtems/score/cpuatomic.h b/cpukit/score/cpu/epiphany/include/rtems/score/cpuatomic.h new file mode 100644 index 0000000000..598ee76b20 --- /dev/null +++ b/cpukit/score/cpu/epiphany/include/rtems/score/cpuatomic.h @@ -0,0 +1,14 @@ +/* + * COPYRIGHT (c) 2012-2013 Deng Hengyi. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_ATOMIC_CPU_H +#define _RTEMS_SCORE_ATOMIC_CPU_H + +#include + +#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/epiphany/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/epiphany/include/rtems/score/cpuimpl.h new file mode 100644 index 0000000000..789f2badd9 --- /dev/null +++ b/cpukit/score/cpu/epiphany/include/rtems/score/cpuimpl.h @@ -0,0 +1,34 @@ +/** + * @file + * + * @brief CPU Port Implementation API + */ + +/* + * Copyright (c) 2013 embedded brains GmbH + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPUIMPL_H +#define _RTEMS_SCORE_CPUIMPL_H + +#include + +#define CPU_PER_CPU_CONTROL_SIZE 0 + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ASM */ + +#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/epiphany/include/rtems/score/epiphany-utility.h b/cpukit/score/cpu/epiphany/include/rtems/score/epiphany-utility.h new file mode 100644 index 0000000000..bf223f93bf --- /dev/null +++ b/cpukit/score/cpu/epiphany/include/rtems/score/epiphany-utility.h @@ -0,0 +1,180 @@ +/** + * @file + * + * @ingroup ScoreCPU + * + * @brief This include file contains macros pertaining to the + * Epiphany processor family. + */ + +/* + * Copyright (c) 2015 University of York. + * Hesham ALMatary + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _EPIPHANY_UTILITY_H +#define _EPIPHANY_UTILITY_H + +/* eCore IRQs */ +typedef enum +{ + START, + SW_EXCEPTION, + MEM_FAULT, + TIMER0, + TIMER1, + SMP_MESSAGE, + DMA0, + DMA1, + SER, +} EPIPHANY_IRQ_PER_CORE_T; + +/* Per-core IO mapped register addresses + * @see Epiphany architecture reference. + */ +#define EPIPHANY_PER_CORE_REG_CONFIG 0xF0400 +#define EPIPHANY_PER_CORE_REG_STATUS 0xF0404 +#define EPIPHANY_PER_CORE_REG_PC 0xF0408 +#define EPIPHANY_PER_CORE_REG_DEBUGSTATUS 0xF040C +#define EPIPHANY_PER_CORE_REG_LC 0xF0414 +#define EPIPHANY_PER_CORE_REG_LS 0xF0418 +#define EPIPHANY_PER_CORE_REG_LE 0xF041C +#define EPIPHANY_PER_CORE_REG_IRET 0xF0420 +#define EPIPHANY_PER_CORE_REG_IMASK 0xF0424 +#define EPIPHANY_PER_CORE_REG_ILAT 0xF0428 +#define EPIPHANY_PER_CORE_REG_ILATST 0xF042C +#define EPIPHANY_PER_CORE_REG_ILATCL 0xF0430 +#define EPIPHANY_PER_CORE_REG_IPEND 0xF0434 +#define EPIPHANY_PER_CORE_REG_FSTATUS 0xF0440 +#define EPIPHANY_PER_CORE_REG_DEBUGCMD 0xF0448 +#define EPIPHANY_PER_CORE_REG_RESETCORE 0xF070C + +/* Event timer registers */ +#define EPIPHANY_PER_CORE_REG_CTIMER0 0xF0438 +#define EPIPHANY_PER_CORE_REG_CTIMER1 0xF043C + +/* Processor control registers */ +#define EPIPHANY_PER_CORE_REG_MEMSTATUS 0xF0604 +#define EPIPHANY_PER_CORE_REG_MEMPROTECT 0xF0608 + +/* DMA Registers */ +#define EPIPHANY_PER_CORE_REG_DMA0CONFIG 0xF0500 +#define EPIPHANY_PER_CORE_REG_DMA0STRIDE 0xF0504 +#define EPIPHANY_PER_CORE_REG_DMA0COUNT 0xF0508 +#define EPIPHANY_PER_CORE_REG_DMA0SRCADDR 0xF050C +#define EPIPHANY_PER_CORE_REG_DMA0DSTADDR 0xF0510 +#define EPIPHANY_PER_CORE_REG_DMA0AUTO0 0xF0514 +#define EPIPHANY_PER_CORE_REG_DMA0AUTO1 0xF0518 +#define EPIPHANY_PER_CORE_REG_DMA0STATUS 0xF051C +#define EPIPHANY_PER_CORE_REG_DMA1CONFIG 0xF0520 +#define EPIPHANY_PER_CORE_REG_DMA1STRIDE 0xF0524 +#define EPIPHANY_PER_CORE_REG_DMA1COUNT 0xF0528 +#define EPIPHANY_PER_CORE_REG_DMA1SRCADDR 0xF052C +#define EPIPHANY_PER_CORE_REG_DMA1DSTADDR 0xF0530 +#define EPIPHANY_PER_CORE_REG_DMA1AUTO0 0xF0534 +#define EPIPHANY_PER_CORE_REG_DMA1AUTO1 0xF0538 +#define EPIPHANY_PER_CORE_REG_DMA1STATUS 0xF053C + +/* Mesh Node Control Registers */ +#define EPIPHANY_PER_CORE_REG_MESHCONFIG 0xF0700 +#define EPIPHANY_PER_CORE_REG_COREID 0xF0704 +#define EPIPHANY_PER_CORE_REG_MULTICAST 0xF0708 +#define EPIPHANY_PER_CORE_REG_CMESHROUTE 0xF0710 +#define EPIPHANY_PER_CORE_REG_XMESHROUTE 0xF0714 +#define EPIPHANY_PER_CORE_REG_RMESHROUTE 0xF0718 + +/* This macros constructs an address space of epiphany cores + * from their IDs. + */ +#define EPIPHANY_COREID_TO_MSB_ADDR(id) (id) << 20 + +/* Construct a complete/absolute IO mapped address register from + * core ID and register name + */ +#define EPIPHANY_GET_REG_ABSOLUTE_ADDR(coreid, reg) \ + (EPIPHANY_COREID_TO_MSB_ADDR(coreid) | (reg)) + +#define EPIPHANY_REG(reg) (uint32_t *) (reg) + +/* Read register with its absolute address */ +static inline uint32_t read_epiphany_reg(volatile uint32_t reg_addr) +{ + return *(EPIPHANY_REG(reg_addr)); +} + +/* Write register with its abolute address */ +static inline void write_epiphany_reg(volatile uint32_t reg_addr, uint32_t val) +{ + *(EPIPHANY_REG(reg_addr)) = val; +} + +/* Epiphany uses 12 bits for defining core IDs, while RTEMS uses + * linear IDs. The following function converts RTEMS linear IDs to + * Epiphany corresponding ones + */ +static const uint32_t map[16] = +{ + 0x808, 0x809, 0x80A, 0x80B, + 0x848, 0x849, 0x84A, 0x84B, + 0x888, 0x889, 0x88A, 0x88B, + 0x8C8, 0x8C9, 0x8CA, 0x8CB +}; + +static inline uint32_t rtems_coreid_to_epiphany_map(uint32_t rtems_id) +{ + return map[rtems_id]; +} + +/* Epiphany uses 12 bits for defining core IDs, while RTEMS uses + * linear IDs. The following function is used to map Epiphany IDs to + * RTEMS linear IDs. + */ +static inline uint32_t epiphany_coreid_to_rtems_map(uint32_t epiphany_id) +{ + register uint32_t coreid asm ("r17") = epiphany_id; + + /* Mapping from Epiphany IDs to 0-16 IDs macro */ + __asm__ __volatile__(" \ + movfs r17, coreid \ + mov r19, #0x003 \ + mov r20, #0x0F0 \ + and r19, r17, r19 \ + and r20, r17, r20 \ + lsr r20, r20, #4 \ + add r17, r19, r20 \ + "); + + /* coreid or r17 now holds the rtems core id */ + return coreid; +} + +static inline uint32_t _Epiphany_Get_current_processor() +{ + uint32_t coreid; + + asm volatile ("movfs %0, coreid" : "=r" (coreid): ); + + return epiphany_coreid_to_rtems_map(coreid); +} +#endif /* _EPIPHANY_UTILITY_H */ diff --git a/cpukit/score/cpu/epiphany/include/rtems/score/epiphany.h b/cpukit/score/cpu/epiphany/include/rtems/score/epiphany.h new file mode 100644 index 0000000000..60d975581f --- /dev/null +++ b/cpukit/score/cpu/epiphany/include/rtems/score/epiphany.h @@ -0,0 +1,64 @@ +/** + * @file rtems/score/epiphany.h + */ + +/* + * Copyright (c) 2015 University of York. + * Hesham ALMatary + * + * COPYRIGHT (c) 1989-1999, 2010. + * On-Line Applications Research Corporation (OAR). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _RTEMS_SCORE_EPIPHANY_H +#define _RTEMS_SCORE_EPIPHANY_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This file contains the information required to build + * RTEMS for a particular member of the Epiphany family. + * It does this by setting variables to indicate which + * implementation dependent features are present in a particular + * member of the family. + * + * This is a good place to list all the known CPU models + * that this port supports and which RTEMS CPU model they correspond + * to. + */ + + /* + * Define the name of the CPU family and specific model. + */ + +#define CPU_NAME "EPIPHANY" +#define CPU_MODEL_NAME "EPIPHANY" + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_SCORE_EPIPHANY_H */ diff --git a/cpukit/score/cpu/epiphany/include/rtems/score/types.h b/cpukit/score/cpu/epiphany/include/rtems/score/types.h new file mode 100644 index 0000000000..24c8955fd3 --- /dev/null +++ b/cpukit/score/cpu/epiphany/include/rtems/score/types.h @@ -0,0 +1,67 @@ +/** + * @file + * + * @brief Epiphany Architecture Types API + */ + +/* + * Copyright (c) 2015 University of York. + * Hesham ALMatary + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + + #ifndef _RTEMS_SCORE_TYPES_H +#define _RTEMS_SCORE_TYPES_H + +#include + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup ScoreCPU + */ +/**@{**/ + +/* + * This section defines the basic types for this processor. + */ + +/** Type that can store a 32-bit integer or a pointer. */ +typedef uintptr_t CPU_Uint32ptr; + +typedef void epiphany_isr; +typedef void ( *epiphany_isr_entry )( void ); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* !ASM */ + +#endif diff --git a/cpukit/score/cpu/epiphany/preinstall.am b/cpukit/score/cpu/epiphany/preinstall.am deleted file mode 100644 index e12a51695e..0000000000 --- a/cpukit/score/cpu/epiphany/preinstall.am +++ /dev/null @@ -1,57 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES += $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES += $(PREINSTALL_FILES) - -$(PROJECT_INCLUDE)/rtems/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems - @: > $(PROJECT_INCLUDE)/rtems/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/asm.h: rtems/asm.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/asm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/asm.h - -$(PROJECT_INCLUDE)/rtems/score/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/score - @: > $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/score/cpu.h: rtems/score/cpu.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpu.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpu.h - -$(PROJECT_INCLUDE)/rtems/score/cpuimpl.h: rtems/score/cpuimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h - -$(PROJECT_INCLUDE)/rtems/score/cpuatomic.h: rtems/score/cpuatomic.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h - -$(PROJECT_INCLUDE)/rtems/score/cpu_asm.h: rtems/score/cpu_asm.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpu_asm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpu_asm.h - -$(PROJECT_INCLUDE)/rtems/score/types.h: rtems/score/types.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/types.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/types.h - -$(PROJECT_INCLUDE)/rtems/score/epiphany.h: rtems/score/epiphany.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/epiphany.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/epiphany.h - -$(PROJECT_INCLUDE)/rtems/score/epiphany-utility.h: rtems/score/epiphany-utility.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/epiphany-utility.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/epiphany-utility.h - diff --git a/cpukit/score/cpu/epiphany/rtems/asm.h b/cpukit/score/cpu/epiphany/rtems/asm.h deleted file mode 100644 index 87e0cca1cb..0000000000 --- a/cpukit/score/cpu/epiphany/rtems/asm.h +++ /dev/null @@ -1,120 +0,0 @@ -/** - * @file rtems/asm.h - * - * This include file attempts to address the problems - * caused by incompatible flavors of assemblers and - * toolsets. It primarily addresses variations in the - * use of leading underscores on symbols and the requirement - * that register names be preceded by a %. - */ - -/* - * NOTE: The spacing in the use of these macros - * is critical to them working as advertised. - * - * This file is based on similar code found in newlib available - * from ftp.cygnus.com. The file which was used had no copyright - * notice. This file is freely distributable as long as the source - * of the file is noted. This file is: - * - * Copyright (c) 2015 University of York. - * Hesham ALMatary - * - * - * COPYRIGHT (c) 1994-1997. - * On-Line Applications Research Corporation (OAR). - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef __EPIPHANY_ASM_H -#define __EPIPHANY_ASM_H - -/* - * Indicate we are in an assembly file and get the basic CPU definitions. - */ - -#ifndef ASM -#define ASM -#endif -#include -#include - -/* - * Recent versions of GNU cpp define variables which indicate the - * need for underscores and percents. If not using GNU cpp or - * the version does not support this, then you will obviously - * have to define these as appropriate. - */ - -#ifndef __USER_LABEL_PREFIX__ -#define __USER_LABEL_PREFIX__ _ -#endif - -#ifndef __REGISTER_PREFIX__ -#define __REGISTER_PREFIX__ -#endif - -/* ANSI concatenation macros. */ - -#define CONCAT1(a, b) CONCAT2(a, b) -#define CONCAT2(a, b) a ## b - -/* Use the right prefix for global labels. */ - -#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) - -/* Use the right prefix for registers. */ - -#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) - -/* - * define macros for all of the registers on this CPU - * - * EXAMPLE: #define d0 REG (d0) - */ - -/* - * Define macros to handle section beginning and ends. - */ -#define BEGIN_CODE_DCL .text -#define END_CODE_DCL -#define BEGIN_DATA_DCL .data -#define END_DATA_DCL -#define BEGIN_CODE .text -#define END_CODE -#define BEGIN_DATA -#define END_DATA -#define BEGIN_BSS -#define END_BSS -#define END - -/* - * Following must be tailor for a particular flavor of the C compiler. - * They may need to put underscores in front of the symbols. - */ - -#define PUBLIC(sym) .global SYM (sym) -#define EXTERN(sym) .extern SYM (sym) -#define TYPE_FUNC(sym) .type SYM (sym), %function - -#endif diff --git a/cpukit/score/cpu/epiphany/rtems/score/cpu.h b/cpukit/score/cpu/epiphany/rtems/score/cpu.h deleted file mode 100644 index 34ac8ae6c6..0000000000 --- a/cpukit/score/cpu/epiphany/rtems/score/cpu.h +++ /dev/null @@ -1,873 +0,0 @@ -/** - * @file rtems/score/cpu.h - */ - -/* - * - * Copyright (c) 2015 University of York. - * Hesham ALMatary - * - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _EPIPHANY_CPU_H -#define _EPIPHANY_CPU_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include /* pick up machine definitions */ -#include -#ifndef ASM -#include -#include -#include /* for printk */ -#endif - -/* conditional compilation parameters */ - -/* - * Does RTEMS manage a dedicated interrupt stack in software? - * - * If TRUE, then a stack is allocated in _ISR_Handler_initialization. - * If FALSE, nothing is done. - * - * If the CPU supports a dedicated interrupt stack in hardware, - * then it is generally the responsibility of the BSP to allocate it - * and set it up. - * - * If the CPU does not support a dedicated interrupt stack, then - * the porter has two options: (1) execute interrupts on the - * stack of the interrupted task, and (2) have RTEMS manage a dedicated - * interrupt stack. - * - * If this is TRUE, CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. - * - * Only one of CPU_HAS_SOFTWARE_INTERRUPT_STACK and - * CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is - * possible that both are FALSE for a particular CPU. Although it - * is unclear what that would imply about the interrupt processing - * procedure on that CPU. - * - * Currently, for epiphany port, _ISR_Handler is responsible for switching to - * RTEMS dedicated interrupt task. - * - */ - -#define CPU_HAS_SOFTWARE_INTERRUPT_STACK TRUE - -/* - * Does this CPU have hardware support for a dedicated interrupt stack? - * - * If TRUE, then it must be installed during initialization. - * If FALSE, then no installation is performed. - * - * If this is TRUE, CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. - * - * Only one of CPU_HAS_SOFTWARE_INTERRUPT_STACK and - * CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is - * possible that both are FALSE for a particular CPU. Although it - * is unclear what that would imply about the interrupt processing - * procedure on that CPU. - * - */ - -#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE - -/* - * Does RTEMS allocate a dedicated interrupt stack in the Interrupt Manager? - * - * If TRUE, then the memory is allocated during initialization. - * If FALSE, then the memory is allocated during initialization. - * - * This should be TRUE is CPU_HAS_SOFTWARE_INTERRUPT_STACK is TRUE - * or CPU_INSTALL_HARDWARE_INTERRUPT_STACK is TRUE. - * - */ - -#define CPU_ALLOCATE_INTERRUPT_STACK TRUE - -/* - * Does the RTEMS invoke the user's ISR with the vector number and - * a pointer to the saved interrupt frame (1) or just the vector - * number (0)? - * - */ - -#define CPU_ISR_PASSES_FRAME_POINTER TRUE - -/* - * Does the CPU have hardware floating point? - * - * If TRUE, then the RTEMS_FLOATING_POINT task attribute is supported. - * If FALSE, then the RTEMS_FLOATING_POINT task attribute is ignored. - * - * If there is a FP coprocessor such as the i387 or mc68881, then - * the answer is TRUE. - * - * The macro name "epiphany_HAS_FPU" should be made CPU specific. - * It indicates whether or not this CPU model has FP support. For - * example, it would be possible to have an i386_nofp CPU model - * which set this to false to indicate that you have an i386 without - * an i387 and wish to leave floating point support out of RTEMS. - * - * The CPU_SOFTWARE_FP is used to indicate whether or not there - * is software implemented floating point that must be context - * switched. The determination of whether or not this applies - * is very tool specific and the state saved/restored is also - * compiler specific. - * - * epiphany Specific Information: - * - * At this time there are no implementations of Epiphany that are - * expected to implement floating point. - */ - -#define CPU_HARDWARE_FP FALSE -#define CPU_SOFTWARE_FP FALSE - -/* - * Are all tasks RTEMS_FLOATING_POINT tasks implicitly? - * - * If TRUE, then the RTEMS_FLOATING_POINT task attribute is assumed. - * If FALSE, then the RTEMS_FLOATING_POINT task attribute is followed. - * - * If CPU_HARDWARE_FP is FALSE, then this should be FALSE as well. - * - */ - -#define CPU_ALL_TASKS_ARE_FP FALSE - -/* - * Should the IDLE task have a floating point context? - * - * If TRUE, then the IDLE task is created as a RTEMS_FLOATING_POINT task - * and it has a floating point context which is switched in and out. - * If FALSE, then the IDLE task does not have a floating point context. - * - * Setting this to TRUE negatively impacts the time required to preempt - * the IDLE task from an interrupt because the floating point context - * must be saved as part of the preemption. - * - */ - -#define CPU_IDLE_TASK_IS_FP FALSE - -/* - * Should the saving of the floating point registers be deferred - * until a context switch is made to another different floating point - * task? - * - * If TRUE, then the floating point context will not be stored until - * necessary. It will remain in the floating point registers and not - * disturned until another floating point task is switched to. - * - * If FALSE, then the floating point context is saved when a floating - * point task is switched out and restored when the next floating point - * task is restored. The state of the floating point registers between - * those two operations is not specified. - * - * If the floating point context does NOT have to be saved as part of - * interrupt dispatching, then it should be safe to set this to TRUE. - * - * Setting this flag to TRUE results in using a different algorithm - * for deciding when to save and restore the floating point context. - * The deferred FP switch algorithm minimizes the number of times - * the FP context is saved and restored. The FP context is not saved - * until a context switch is made to another, different FP task. - * Thus in a system with only one FP task, the FP context will never - * be saved or restored. - * - */ - -#define CPU_USE_DEFERRED_FP_SWITCH FALSE - -#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE - -/* - * Does this port provide a CPU dependent IDLE task implementation? - * - * If TRUE, then the routine _CPU_Thread_Idle_body - * must be provided and is the default IDLE thread body instead of - * _CPU_Thread_Idle_body. - * - * If FALSE, then use the generic IDLE thread body if the BSP does - * not provide one. - * - * This is intended to allow for supporting processors which have - * a low power or idle mode. When the IDLE thread is executed, then - * the CPU can be powered down. - * - * The order of precedence for selecting the IDLE thread body is: - * - * 1. BSP provided - * 2. CPU dependent (if provided) - * 3. generic (if no BSP and no CPU dependent) - * - */ - -#define CPU_PROVIDES_IDLE_THREAD_BODY TRUE - -/* - * Does the stack grow up (toward higher addresses) or down - * (toward lower addresses)? - * - * If TRUE, then the grows upward. - * If FALSE, then the grows toward smaller addresses. - * - */ - -#define CPU_STACK_GROWS_UP FALSE - -/* FIXME: Is this the right value? */ -#define CPU_CACHE_LINE_BYTES 64 - -#define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES ) - -/* - * Define what is required to specify how the network to host conversion - * routines are handled. - * - * epiphany Specific Information: - * - * This version of RTEMS is designed specifically to run with - * big endian architectures. If you want little endian, you'll - * have to make the appropriate adjustments here and write - * efficient routines for byte swapping. The epiphany architecture - * doesn't do this very well. - */ - -#define CPU_HAS_OWN_HOST_TO_NETWORK_ROUTINES FALSE - -/* - * The following defines the number of bits actually used in the - * interrupt field of the task mode. How those bits map to the - * CPU interrupt levels is defined by the routine _CPU_ISR_Set_level(). - * - */ - -#define CPU_MODES_INTERRUPT_MASK 0x00000001 - -/* - * Processor defined structures required for cpukit/score. - */ - -/* - * Contexts - * - * Generally there are 2 types of context to save. - * 1. Interrupt registers to save - * 2. Task level registers to save - * - * This means we have the following 3 context items: - * 1. task level context stuff:: Context_Control - * 2. floating point task stuff:: Context_Control_fp - * 3. special interrupt level context :: Context_Control_interrupt - * - * On some processors, it is cost-effective to save only the callee - * preserved registers during a task context switch. This means - * that the ISR code needs to save those registers which do not - * persist across function calls. It is not mandatory to make this - * distinctions between the caller/callee saves registers for the - * purpose of minimizing context saved during task switch and on interrupts. - * If the cost of saving extra registers is minimal, simplicity is the - * choice. Save the same context on interrupt entry as for tasks in - * this case. - * - * Additionally, if gdb is to be made aware of RTEMS tasks for this CPU, then - * care should be used in designing the context area. - * - * On some CPUs with hardware floating point support, the Context_Control_fp - * structure will not be used or it simply consist of an array of a - * fixed number of bytes. This is done when the floating point context - * is dumped by a "FP save context" type instruction and the format - * is not really defined by the CPU. In this case, there is no need - * to figure out the exact format -- only the size. Of course, although - * this is enough information for RTEMS, it is probably not enough for - * a debugger such as gdb. But that is another problem. - * - * - */ -#ifndef ASM - -typedef struct { - uint32_t r[64]; - - uint32_t status; - uint32_t config; - uint32_t iret; - -#ifdef RTEMS_SMP - /** - * @brief On SMP configurations the thread context must contain a boolean - * indicator to signal if this context is executing on a processor. - * - * This field must be updated during a context switch. The context switch - * to the heir must wait until the heir context indicates that it is no - * longer executing on a processor. The context switch must also check if - * a thread dispatch is necessary to honor updates of the heir thread for - * this processor. This indicator must be updated using an atomic test and - * set operation to ensure that at most one processor uses the heir - * context at the same time. - * - * @code - * void _CPU_Context_switch( - * Context_Control *executing, - * Context_Control *heir - * ) - * { - * save( executing ); - * - * executing->is_executing = false; - * memory_barrier(); - * - * if ( test_and_set( &heir->is_executing ) ) { - * do { - * Per_CPU_Control *cpu_self = _Per_CPU_Get_snapshot(); - * - * if ( cpu_self->dispatch_necessary ) { - * heir = _Thread_Get_heir_and_make_it_executing( cpu_self ); - * } - * } while ( test_and_set( &heir->is_executing ) ); - * } - * - * restore( heir ); - * } - * @endcode - */ - volatile bool is_executing; -#endif -} Context_Control; - -#define _CPU_Context_Get_SP( _context ) \ - (_context)->r[13] - -typedef struct { - /** FPU registers are listed here */ - double some_float_register; -} Context_Control_fp; - -typedef Context_Control CPU_Interrupt_frame; - -/* - * The size of the floating point context area. On some CPUs this - * will not be a "sizeof" because the format of the floating point - * area is not defined -- only the size is. This is usually on - * CPUs with a "floating point save context" instruction. - * - * epiphany Specific Information: - * - */ - -#define CPU_CONTEXT_FP_SIZE 0 - -/* - * Amount of extra stack (above minimum stack size) required by - * MPCI receive server thread. Remember that in a multiprocessor - * system this thread must exist and be able to process all directives. - * - */ - -#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0 - -/* - * Should be large enough to run all RTEMS tests. This insures - * that a "reasonable" small application should not have any problems. - * - */ - -#define CPU_STACK_MINIMUM_SIZE 4096 - -/* - * CPU's worst alignment requirement for data types on a byte boundary. This - * alignment does not take into account the requirements for the stack. - * - */ - -#define CPU_ALIGNMENT 8 - -/* - * This is defined if the port has a special way to report the ISR nesting - * level. Most ports maintain the variable _ISR_Nest_level. - */ -#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE - -/* - * This number corresponds to the byte alignment requirement for the - * heap handler. This alignment requirement may be stricter than that - * for the data types alignment specified by CPU_ALIGNMENT. It is - * common for the heap to follow the same alignment requirement as - * CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict enough for the heap, - * then this should be set to CPU_ALIGNMENT. - * - * NOTE: This does not have to be a power of 2 although it should be - * a multiple of 2 greater than or equal to 2. The requirement - * to be a multiple of 2 is because the heap uses the least - * significant field of the front and back flags to indicate - * that a block is in use or free. So you do not want any odd - * length blocks really putting length data in that bit. - * - * On byte oriented architectures, CPU_HEAP_ALIGNMENT normally will - * have to be greater or equal to than CPU_ALIGNMENT to ensure that - * elements allocated from the heap meet all restrictions. - * - */ - -#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT - -/* - * This number corresponds to the byte alignment requirement for memory - * buffers allocated by the partition manager. This alignment requirement - * may be stricter than that for the data types alignment specified by - * CPU_ALIGNMENT. It is common for the partition to follow the same - * alignment requirement as CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict - * enough for the partition, then this should be set to CPU_ALIGNMENT. - * - * NOTE: This does not have to be a power of 2. It does have to - * be greater or equal to than CPU_ALIGNMENT. - * - */ - -#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT - -/* - * This number corresponds to the byte alignment requirement for the - * stack. This alignment requirement may be stricter than that for the - * data types alignment specified by CPU_ALIGNMENT. If the CPU_ALIGNMENT - * is strict enough for the stack, then this should be set to 0. - * - * NOTE: This must be a power of 2 either 0 or greater than CPU_ALIGNMENT. - * - */ - -#define CPU_STACK_ALIGNMENT 8 - -/* ISR handler macros */ - -/* - * Support routine to initialize the RTEMS vector table after it is allocated. - * - * NO_CPU Specific Information: - * - * XXX document implementation including references if appropriate - */ - -#define _CPU_Initialize_vectors() - -/* - * Disable all interrupts for an RTEMS critical section. The previous - * level is returned in _level. - * - */ - -static inline uint32_t epiphany_interrupt_disable( void ) -{ - uint32_t sr; - __asm__ __volatile__ ("movfs %[sr], status \n" : [sr] "=r" (sr):); - __asm__ __volatile__("gid \n"); - return sr; -} - -static inline void epiphany_interrupt_enable(uint32_t level) -{ - __asm__ __volatile__("gie \n"); - __asm__ __volatile__ ("movts status, %[level] \n" :: [level] "r" (level):); -} - -#define _CPU_ISR_Disable( _level ) \ - _level = epiphany_interrupt_disable() - -/* - * Enable interrupts to the previous level (returned by _CPU_ISR_Disable). - * This indicates the end of an RTEMS critical section. The parameter - * _level is not modified. - * - */ - -#define _CPU_ISR_Enable( _level ) \ - epiphany_interrupt_enable( _level ) - -/* - * This temporarily restores the interrupt to _level before immediately - * disabling them again. This is used to divide long RTEMS critical - * sections into two or more parts. The parameter _level is not - * modified. - * - */ - -#define _CPU_ISR_Flash( _level ) \ - do{ \ - if ( (_level & 0x2) != 0 ) \ - _CPU_ISR_Enable( _level ); \ - epiphany_interrupt_disable(); \ - } while(0) - -RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) -{ - return ( level & 0x2 ) != 0; -} - -/* - * Map interrupt level in task mode onto the hardware that the CPU - * actually provides. Currently, interrupt levels which do not - * map onto the CPU in a generic fashion are undefined. Someday, - * it would be nice if these were "mapped" by the application - * via a callout. For example, m68k has 8 levels 0 - 7, levels - * 8 - 255 would be available for bsp/application specific meaning. - * This could be used to manage a programmable interrupt controller - * via the rtems_task_mode directive. - * - * The get routine usually must be implemented as a subroutine. - * - */ - -void _CPU_ISR_Set_level( uint32_t level ); - -uint32_t _CPU_ISR_Get_level( void ); - -/* end of ISR handler macros */ - -/* Context handler macros */ - -/* - * Initialize the context to a state suitable for starting a - * task after a context restore operation. Generally, this - * involves: - * - * - setting a starting address - * - preparing the stack - * - preparing the stack and frame pointers - * - setting the proper interrupt level in the context - * - initializing the floating point context - * - * This routine generally does not set any unnecessary register - * in the context. The state of the "general data" registers is - * undefined at task start time. - * - * NOTE: This is_fp parameter is TRUE if the thread is to be a floating - * point thread. This is typically only used on CPUs where the - * FPU may be easily disabled by software such as on the SPARC - * where the PSR contains an enable FPU bit. - * - */ - -/** - * @brief Account for GCC red-zone - * - * The following macro is used when initializing task's stack - * to account for GCC red-zone. - */ - -#define EPIPHANY_GCC_RED_ZONE_SIZE 128 - -/** - * @brief Initializes the CPU context. - * - * The following steps are performed: - * - setting a starting address - * - preparing the stack - * - preparing the stack and frame pointers - * - setting the proper interrupt level in the context - * - * @param[in] context points to the context area - * @param[in] stack_area_begin is the low address of the allocated stack area - * @param[in] stack_area_size is the size of the stack area in bytes - * @param[in] new_level is the interrupt level for the task - * @param[in] entry_point is the task's entry point - * @param[in] is_fp is set to @c true if the task is a floating point task - * @param[in] tls_area is the thread-local storage (TLS) area - */ -void _CPU_Context_Initialize( - Context_Control *context, - void *stack_area_begin, - size_t stack_area_size, - uint32_t new_level, - void (*entry_point)( void ), - bool is_fp, - void *tls_area -); - -/* - * This routine is responsible for somehow restarting the currently - * executing task. If you are lucky, then all that is necessary - * is restoring the context. Otherwise, there will need to be - * a special assembly routine which does something special in this - * case. Context_Restore should work most of the time. It will - * not work if restarting self conflicts with the stack frame - * assumptions of restoring a context. - * - */ - -#define _CPU_Context_Restart_self( _the_context ) \ - _CPU_Context_restore( (_the_context) ) - -#define _CPU_Context_Initialize_fp( _destination ) \ - memset( *( _destination ), 0, CPU_CONTEXT_FP_SIZE ); - -/* end of Context handler macros */ - -/* Fatal Error manager macros */ - -/* - * This routine copies _error into a known place -- typically a stack - * location or a register, optionally disables interrupts, and - * halts/stops the CPU. - * - */ - -#include - -#define _CPU_Fatal_halt(_source, _error ) \ - printk("Fatal Error %d.%" PRIu32 " Halted\n",_source, _error); \ - asm("trap 3" :: "r" (_error)); \ - for(;;) - -/* end of Fatal Error manager macros */ - -#define CPU_USE_GENERIC_BITFIELD_CODE TRUE - -#endif /* ASM */ - -/** - * Size of a pointer. - * - * This must be an integer literal that can be used by the assembler. This - * value will be used to calculate offsets of structure members. These - * offsets will be used in assembler code. - */ -#define CPU_SIZEOF_POINTER 4 -#define CPU_EXCEPTION_FRAME_SIZE 260 - -#define CPU_MAXIMUM_PROCESSORS 32 - -#ifndef ASM - -typedef struct { - uint32_t r[62]; - uint32_t status; - uint32_t config; - uint32_t iret; -} CPU_Exception_frame; - -/** - * @brief Prints the exception frame via printk(). - * - * @see rtems_fatal() and RTEMS_FATAL_SOURCE_EXCEPTION. - */ -void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); - - -/* end of Priority handler macros */ - -/* functions */ - -/* - * _CPU_Initialize - * - * This routine performs CPU dependent initialization. - * - */ - -void _CPU_Initialize( - void -); - -/* - * _CPU_ISR_install_raw_handler - * - * This routine installs a "raw" interrupt handler directly into the - * processor's vector table. - * - */ - -void _CPU_ISR_install_raw_handler( - uint32_t vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -/* - * _CPU_ISR_install_vector - * - * This routine installs an interrupt vector. - * - * NO_CPU Specific Information: - * - * XXX document implementation including references if appropriate - */ - -void _CPU_ISR_install_vector( - uint32_t vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -/* - * _CPU_Install_interrupt_stack - * - * This routine installs the hardware interrupt stack pointer. - * - * NOTE: It need only be provided if CPU_HAS_HARDWARE_INTERRUPT_STACK - * is TRUE. - * - */ - -void _CPU_Install_interrupt_stack( void ); - -/* - * _CPU_Thread_Idle_body - * - * This routine is the CPU dependent IDLE thread body. - * - * NOTE: It need only be provided if CPU_PROVIDES_IDLE_THREAD_BODY - * is TRUE. - * - */ - -void *_CPU_Thread_Idle_body( uintptr_t ignored ); - -/* - * _CPU_Context_switch - * - * This routine switches from the run context to the heir context. - * - * epiphany Specific Information: - * - * Please see the comments in the .c file for a description of how - * this function works. There are several things to be aware of. - */ - -void _CPU_Context_switch( - Context_Control *run, - Context_Control *heir -); - -/* - * _CPU_Context_restore - * - * This routine is generally used only to restart self in an - * efficient manner. It may simply be a label in _CPU_Context_switch. - * - * NOTE: May be unnecessary to reload some registers. - * - */ - -void _CPU_Context_restore( - Context_Control *new_context -) RTEMS_NO_RETURN; - -/* - * _CPU_Context_save_fp - * - * This routine saves the floating point context passed to it. - * - */ - -void _CPU_Context_save_fp( - void **fp_context_ptr -); - -/* - * _CPU_Context_restore_fp - * - * This routine restores the floating point context passed to it. - * - */ - -void _CPU_Context_restore_fp( - void **fp_context_ptr -); - -/* The following routine swaps the endian format of an unsigned int. - * It must be static because it is referenced indirectly. - * - * This version will work on any processor, but if there is a better - * way for your CPU PLEASE use it. The most common way to do this is to: - * - * swap least significant two bytes with 16-bit rotate - * swap upper and lower 16-bits - * swap most significant two bytes with 16-bit rotate - * - * Some CPUs have special instructions which swap a 32-bit quantity in - * a single instruction (e.g. i486). It is probably best to avoid - * an "endian swapping control bit" in the CPU. One good reason is - * that interrupts would probably have to be disabled to insure that - * an interrupt does not try to access the same "chunk" with the wrong - * endian. Another good reason is that on some CPUs, the endian bit - * endianness for ALL fetches -- both code and data -- so the code - * will be fetched incorrectly. - * - */ - -static inline unsigned int CPU_swap_u32( - unsigned int value -) -{ - uint32_t byte1, byte2, byte3, byte4, swapped; - - byte4 = (value >> 24) & 0xff; - byte3 = (value >> 16) & 0xff; - byte2 = (value >> 8) & 0xff; - byte1 = value & 0xff; - - swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4; - return( swapped ); -} - -#define CPU_swap_u16( value ) \ - (((value&0xff) << 8) | ((value >> 8)&0xff)) - -static inline void _CPU_Context_volatile_clobber( uintptr_t pattern ) -{ - /* TODO */ -} - -static inline void _CPU_Context_validate( uintptr_t pattern ) -{ - while (1) { - /* TODO */ - } -} - -typedef uint32_t CPU_Counter_ticks; - -CPU_Counter_ticks _CPU_Counter_read( void ); - -static inline CPU_Counter_ticks _CPU_Counter_difference( - CPU_Counter_ticks second, - CPU_Counter_ticks first -) -{ - return second - first; -} - -#endif /* ASM */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/score/cpu/epiphany/rtems/score/cpu_asm.h b/cpukit/score/cpu/epiphany/rtems/score/cpu_asm.h deleted file mode 100644 index cc091fa909..0000000000 --- a/cpukit/score/cpu/epiphany/rtems/score/cpu_asm.h +++ /dev/null @@ -1,74 +0,0 @@ -/** - * @file - * - * @brief Epiphany Assembly File - * - * Very loose template for an include file for the cpu_asm.? file - * if it is implemented as a ".S" file (preprocessed by cpp) instead - * of a ".s" file (preprocessed by gm4 or gasp). - */ - -/* - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - * - */ - -#ifndef _RTEMS_SCORE_CPU_ASM_H -#define _RTEMS_SCORE_CPU_ASM_H - -/* pull in the generated offsets */ - -/* -#include -*/ - -/* - * Hardware General Registers - */ - -/* put something here */ - -/* - * Hardware Floating Point Registers - */ - -/* put something here */ - -/* - * Hardware Control Registers - */ - -/* put something here */ - -/* - * Calling Convention - */ - -/* put something here */ - -/* - * Temporary registers - */ - -/* put something here */ - -/* - * Floating Point Registers - SW Conventions - */ - -/* put something here */ - -/* - * Temporary floating point registers - */ - -/* put something here */ - -#endif - -/* end of file */ diff --git a/cpukit/score/cpu/epiphany/rtems/score/cpuatomic.h b/cpukit/score/cpu/epiphany/rtems/score/cpuatomic.h deleted file mode 100644 index 598ee76b20..0000000000 --- a/cpukit/score/cpu/epiphany/rtems/score/cpuatomic.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * COPYRIGHT (c) 2012-2013 Deng Hengyi. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_ATOMIC_CPU_H -#define _RTEMS_SCORE_ATOMIC_CPU_H - -#include - -#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/epiphany/rtems/score/cpuimpl.h b/cpukit/score/cpu/epiphany/rtems/score/cpuimpl.h deleted file mode 100644 index 789f2badd9..0000000000 --- a/cpukit/score/cpu/epiphany/rtems/score/cpuimpl.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @file - * - * @brief CPU Port Implementation API - */ - -/* - * Copyright (c) 2013 embedded brains GmbH - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPUIMPL_H -#define _RTEMS_SCORE_CPUIMPL_H - -#include - -#define CPU_PER_CPU_CONTROL_SIZE 0 - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* ASM */ - -#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/epiphany/rtems/score/epiphany-utility.h b/cpukit/score/cpu/epiphany/rtems/score/epiphany-utility.h deleted file mode 100644 index bf223f93bf..0000000000 --- a/cpukit/score/cpu/epiphany/rtems/score/epiphany-utility.h +++ /dev/null @@ -1,180 +0,0 @@ -/** - * @file - * - * @ingroup ScoreCPU - * - * @brief This include file contains macros pertaining to the - * Epiphany processor family. - */ - -/* - * Copyright (c) 2015 University of York. - * Hesham ALMatary - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _EPIPHANY_UTILITY_H -#define _EPIPHANY_UTILITY_H - -/* eCore IRQs */ -typedef enum -{ - START, - SW_EXCEPTION, - MEM_FAULT, - TIMER0, - TIMER1, - SMP_MESSAGE, - DMA0, - DMA1, - SER, -} EPIPHANY_IRQ_PER_CORE_T; - -/* Per-core IO mapped register addresses - * @see Epiphany architecture reference. - */ -#define EPIPHANY_PER_CORE_REG_CONFIG 0xF0400 -#define EPIPHANY_PER_CORE_REG_STATUS 0xF0404 -#define EPIPHANY_PER_CORE_REG_PC 0xF0408 -#define EPIPHANY_PER_CORE_REG_DEBUGSTATUS 0xF040C -#define EPIPHANY_PER_CORE_REG_LC 0xF0414 -#define EPIPHANY_PER_CORE_REG_LS 0xF0418 -#define EPIPHANY_PER_CORE_REG_LE 0xF041C -#define EPIPHANY_PER_CORE_REG_IRET 0xF0420 -#define EPIPHANY_PER_CORE_REG_IMASK 0xF0424 -#define EPIPHANY_PER_CORE_REG_ILAT 0xF0428 -#define EPIPHANY_PER_CORE_REG_ILATST 0xF042C -#define EPIPHANY_PER_CORE_REG_ILATCL 0xF0430 -#define EPIPHANY_PER_CORE_REG_IPEND 0xF0434 -#define EPIPHANY_PER_CORE_REG_FSTATUS 0xF0440 -#define EPIPHANY_PER_CORE_REG_DEBUGCMD 0xF0448 -#define EPIPHANY_PER_CORE_REG_RESETCORE 0xF070C - -/* Event timer registers */ -#define EPIPHANY_PER_CORE_REG_CTIMER0 0xF0438 -#define EPIPHANY_PER_CORE_REG_CTIMER1 0xF043C - -/* Processor control registers */ -#define EPIPHANY_PER_CORE_REG_MEMSTATUS 0xF0604 -#define EPIPHANY_PER_CORE_REG_MEMPROTECT 0xF0608 - -/* DMA Registers */ -#define EPIPHANY_PER_CORE_REG_DMA0CONFIG 0xF0500 -#define EPIPHANY_PER_CORE_REG_DMA0STRIDE 0xF0504 -#define EPIPHANY_PER_CORE_REG_DMA0COUNT 0xF0508 -#define EPIPHANY_PER_CORE_REG_DMA0SRCADDR 0xF050C -#define EPIPHANY_PER_CORE_REG_DMA0DSTADDR 0xF0510 -#define EPIPHANY_PER_CORE_REG_DMA0AUTO0 0xF0514 -#define EPIPHANY_PER_CORE_REG_DMA0AUTO1 0xF0518 -#define EPIPHANY_PER_CORE_REG_DMA0STATUS 0xF051C -#define EPIPHANY_PER_CORE_REG_DMA1CONFIG 0xF0520 -#define EPIPHANY_PER_CORE_REG_DMA1STRIDE 0xF0524 -#define EPIPHANY_PER_CORE_REG_DMA1COUNT 0xF0528 -#define EPIPHANY_PER_CORE_REG_DMA1SRCADDR 0xF052C -#define EPIPHANY_PER_CORE_REG_DMA1DSTADDR 0xF0530 -#define EPIPHANY_PER_CORE_REG_DMA1AUTO0 0xF0534 -#define EPIPHANY_PER_CORE_REG_DMA1AUTO1 0xF0538 -#define EPIPHANY_PER_CORE_REG_DMA1STATUS 0xF053C - -/* Mesh Node Control Registers */ -#define EPIPHANY_PER_CORE_REG_MESHCONFIG 0xF0700 -#define EPIPHANY_PER_CORE_REG_COREID 0xF0704 -#define EPIPHANY_PER_CORE_REG_MULTICAST 0xF0708 -#define EPIPHANY_PER_CORE_REG_CMESHROUTE 0xF0710 -#define EPIPHANY_PER_CORE_REG_XMESHROUTE 0xF0714 -#define EPIPHANY_PER_CORE_REG_RMESHROUTE 0xF0718 - -/* This macros constructs an address space of epiphany cores - * from their IDs. - */ -#define EPIPHANY_COREID_TO_MSB_ADDR(id) (id) << 20 - -/* Construct a complete/absolute IO mapped address register from - * core ID and register name - */ -#define EPIPHANY_GET_REG_ABSOLUTE_ADDR(coreid, reg) \ - (EPIPHANY_COREID_TO_MSB_ADDR(coreid) | (reg)) - -#define EPIPHANY_REG(reg) (uint32_t *) (reg) - -/* Read register with its absolute address */ -static inline uint32_t read_epiphany_reg(volatile uint32_t reg_addr) -{ - return *(EPIPHANY_REG(reg_addr)); -} - -/* Write register with its abolute address */ -static inline void write_epiphany_reg(volatile uint32_t reg_addr, uint32_t val) -{ - *(EPIPHANY_REG(reg_addr)) = val; -} - -/* Epiphany uses 12 bits for defining core IDs, while RTEMS uses - * linear IDs. The following function converts RTEMS linear IDs to - * Epiphany corresponding ones - */ -static const uint32_t map[16] = -{ - 0x808, 0x809, 0x80A, 0x80B, - 0x848, 0x849, 0x84A, 0x84B, - 0x888, 0x889, 0x88A, 0x88B, - 0x8C8, 0x8C9, 0x8CA, 0x8CB -}; - -static inline uint32_t rtems_coreid_to_epiphany_map(uint32_t rtems_id) -{ - return map[rtems_id]; -} - -/* Epiphany uses 12 bits for defining core IDs, while RTEMS uses - * linear IDs. The following function is used to map Epiphany IDs to - * RTEMS linear IDs. - */ -static inline uint32_t epiphany_coreid_to_rtems_map(uint32_t epiphany_id) -{ - register uint32_t coreid asm ("r17") = epiphany_id; - - /* Mapping from Epiphany IDs to 0-16 IDs macro */ - __asm__ __volatile__(" \ - movfs r17, coreid \ - mov r19, #0x003 \ - mov r20, #0x0F0 \ - and r19, r17, r19 \ - and r20, r17, r20 \ - lsr r20, r20, #4 \ - add r17, r19, r20 \ - "); - - /* coreid or r17 now holds the rtems core id */ - return coreid; -} - -static inline uint32_t _Epiphany_Get_current_processor() -{ - uint32_t coreid; - - asm volatile ("movfs %0, coreid" : "=r" (coreid): ); - - return epiphany_coreid_to_rtems_map(coreid); -} -#endif /* _EPIPHANY_UTILITY_H */ diff --git a/cpukit/score/cpu/epiphany/rtems/score/epiphany.h b/cpukit/score/cpu/epiphany/rtems/score/epiphany.h deleted file mode 100644 index 60d975581f..0000000000 --- a/cpukit/score/cpu/epiphany/rtems/score/epiphany.h +++ /dev/null @@ -1,64 +0,0 @@ -/** - * @file rtems/score/epiphany.h - */ - -/* - * Copyright (c) 2015 University of York. - * Hesham ALMatary - * - * COPYRIGHT (c) 1989-1999, 2010. - * On-Line Applications Research Corporation (OAR). - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _RTEMS_SCORE_EPIPHANY_H -#define _RTEMS_SCORE_EPIPHANY_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This file contains the information required to build - * RTEMS for a particular member of the Epiphany family. - * It does this by setting variables to indicate which - * implementation dependent features are present in a particular - * member of the family. - * - * This is a good place to list all the known CPU models - * that this port supports and which RTEMS CPU model they correspond - * to. - */ - - /* - * Define the name of the CPU family and specific model. - */ - -#define CPU_NAME "EPIPHANY" -#define CPU_MODEL_NAME "EPIPHANY" - -#ifdef __cplusplus -} -#endif - -#endif /* _RTEMS_SCORE_EPIPHANY_H */ diff --git a/cpukit/score/cpu/epiphany/rtems/score/types.h b/cpukit/score/cpu/epiphany/rtems/score/types.h deleted file mode 100644 index 24c8955fd3..0000000000 --- a/cpukit/score/cpu/epiphany/rtems/score/types.h +++ /dev/null @@ -1,67 +0,0 @@ -/** - * @file - * - * @brief Epiphany Architecture Types API - */ - -/* - * Copyright (c) 2015 University of York. - * Hesham ALMatary - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - - #ifndef _RTEMS_SCORE_TYPES_H -#define _RTEMS_SCORE_TYPES_H - -#include - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ScoreCPU - */ -/**@{**/ - -/* - * This section defines the basic types for this processor. - */ - -/** Type that can store a 32-bit integer or a pointer. */ -typedef uintptr_t CPU_Uint32ptr; - -typedef void epiphany_isr; -typedef void ( *epiphany_isr_entry )( void ); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* !ASM */ - -#endif diff --git a/cpukit/score/cpu/h8300/headers.am b/cpukit/score/cpu/h8300/headers.am new file mode 100644 index 0000000000..6f4357916f --- /dev/null +++ b/cpukit/score/cpu/h8300/headers.am @@ -0,0 +1,5 @@ +## This file was generated by "./boostrap -H". + +include_machinedir = $(includedir)/machine +include_machine_HEADERS = +include_machine_HEADERS += include/machine/elf_machdep.h diff --git a/cpukit/score/cpu/h8300/include/machine/elf_machdep.h b/cpukit/score/cpu/h8300/include/machine/elf_machdep.h new file mode 100644 index 0000000000..3d049157eb --- /dev/null +++ b/cpukit/score/cpu/h8300/include/machine/elf_machdep.h @@ -0,0 +1,59 @@ + +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB + +#define ELF32_MACHDEP_ID_CASES \ + case EM_H8_300: \ + case EM_H8_300H: \ + case EM_H8S: \ + case EM_H8_500: \ + break; + +#define ELF32_MACHDEP_ID EM_H8_300 +#define ARCH_ELFSIZE 32 + +#define R_H8_NONE 0 +#define R_H8_DIR32 1 +#define R_H8_DIR32_28 2 +#define R_H8_DIR32_24 3 +#define R_H8_DIR32_16 4 +#define R_H8_DIR32U 6 +#define R_H8_DIR32U_28 7 +#define R_H8_DIR32U_24 8 +#define R_H8_DIR32U_20 9 +#define R_H8_DIR32U_16 10 +#define R_H8_DIR24 11 +#define R_H8_DIR24_20 12 +#define R_H8_DIR24_16 13 +#define R_H8_DIR24U 14 +#define R_H8_DIR24U_20 15 +#define R_H8_DIR24U_16 16 +#define R_H8_DIR16 17 +#define R_H8_DIR16U 18 +#define R_H8_DIR16S_32 19 +#define R_H8_DIR16S_28 20 +#define R_H8_DIR16S_24 21 +#define R_H8_DIR16S_20 22 +#define R_H8_DIR16S 23 +#define R_H8_DIR8 24 +#define R_H8_DIR8U 25 +#define R_H8_DIR8Z_32 26 +#define R_H8_DIR8Z_28 27 +#define R_H8_DIR8Z_24 28 +#define R_H8_DIR8Z_20 29 +#define R_H8_DIR8Z_16 30 +#define R_H8_PCREL16 31 +#define R_H8_PCREL8 32 +#define R_H8_BPOS 33 +#define R_H8_PCREL32 34 +#define R_H8_GOT32O 35 +#define R_H8_GOT16O 36 +#define R_H8_DIR16A8 59 +#define R_H8_DIR16R8 60 +#define R_H8_DIR24A8 61 +#define R_H8_DIR24R8 62 +#define R_H8_DIR32A16 63 +#define R_H8_ABS32 65 +#define R_H8_ABS32A16 127 + + +#define R_TYPE(name) __CONCAT(R_H8_,name) diff --git a/cpukit/score/cpu/i386/Makefile.am b/cpukit/score/cpu/i386/Makefile.am index 7fb2a081b6..fe7fa5582c 100644 --- a/cpukit/score/cpu/i386/Makefile.am +++ b/cpukit/score/cpu/i386/Makefile.am @@ -1,22 +1,9 @@ include $(top_srcdir)/automake/compile.am -include_rtemsdir = $(includedir)/rtems -include_rtems_HEADERS= rtems/asm.h - -include_rtems_scoredir = $(includedir)/rtems/score -include_rtems_score_HEADERS = rtems/score/cpu.h -include_rtems_score_HEADERS += rtems/score/cpuimpl.h -include_rtems_score_HEADERS += rtems/score/i386.h -include_rtems_score_HEADERS += rtems/score/types.h -include_rtems_score_HEADERS += rtems/score/interrupts.h -include_rtems_score_HEADERS += rtems/score/registers.h -include_rtems_score_HEADERS += rtems/score/idtr.h -include_rtems_score_HEADERS += rtems/score/cpuatomic.h - noinst_LIBRARIES = libscorecpu.a libscorecpu_a_SOURCES = cpu.c cpu_asm.S libscorecpu_a_SOURCES += ../no_cpu/cpucounterread.c libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS) -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am +include $(srcdir)/headers.am diff --git a/cpukit/score/cpu/i386/headers.am b/cpukit/score/cpu/i386/headers.am new file mode 100644 index 0000000000..ea07edcbd4 --- /dev/null +++ b/cpukit/score/cpu/i386/headers.am @@ -0,0 +1,20 @@ +## This file was generated by "./boostrap -H". + +include_machinedir = $(includedir)/machine +include_machine_HEADERS = +include_machine_HEADERS += include/machine/elf_machdep.h + +include_rtemsdir = $(includedir)/rtems +include_rtems_HEADERS = +include_rtems_HEADERS += include/rtems/asm.h + +include_rtems_scoredir = $(includedir)/rtems/score +include_rtems_score_HEADERS = +include_rtems_score_HEADERS += include/rtems/score/cpu.h +include_rtems_score_HEADERS += include/rtems/score/cpuatomic.h +include_rtems_score_HEADERS += include/rtems/score/cpuimpl.h +include_rtems_score_HEADERS += include/rtems/score/i386.h +include_rtems_score_HEADERS += include/rtems/score/idtr.h +include_rtems_score_HEADERS += include/rtems/score/interrupts.h +include_rtems_score_HEADERS += include/rtems/score/registers.h +include_rtems_score_HEADERS += include/rtems/score/types.h diff --git a/cpukit/score/cpu/i386/include/machine/elf_machdep.h b/cpukit/score/cpu/i386/include/machine/elf_machdep.h new file mode 100644 index 0000000000..442c561a9c --- /dev/null +++ b/cpukit/score/cpu/i386/include/machine/elf_machdep.h @@ -0,0 +1,63 @@ +/* $NetBSD: elf_machdep.h,v 1.10 2009/05/30 05:56:52 skrll Exp $ */ + +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB +#define ELF32_MACHDEP_ID_CASES \ + case EM_386: \ + case EM_486: \ + break; + +#define ELF64_MACHDEP_ENDIANNESS XXX /* break compilation */ +#define ELF64_MACHDEP_ID_CASES \ + /* no 64-bit ELF machine types supported */ + +#define ELF32_MACHDEP_ID EM_386 + +#define ARCH_ELFSIZE 32 /* MD native binary size */ + +/* i386 relocations */ +#define R_386_NONE 0 +#define R_386_32 1 +#define R_386_PC32 2 +#define R_386_GOT32 3 +#define R_386_PLT32 4 +#define R_386_COPY 5 +#define R_386_GLOB_DAT 6 +#define R_386_JMP_SLOT 7 +#define R_386_RELATIVE 8 +#define R_386_GOTOFF 9 +#define R_386_GOTPC 10 + +/* TLS relocations */ +#define R_386_TLS_TPOFF 14 +#define R_386_TLS_IE 15 +#define R_386_TLS_GOTIE 16 +#define R_386_TLS_LE 17 +#define R_386_TLS_GD 18 +#define R_386_TLS_LDM 19 + +/* The following relocations are GNU extensions. */ +#define R_386_16 20 +#define R_386_PC16 21 +#define R_386_8 22 +#define R_386_PC8 23 + +/* More TLS relocations */ +#define R_386_TLS_GD_32 24 +#define R_386_TLS_GD_PUSH 25 +#define R_386_TLS_GD_CALL 26 +#define R_386_TLS_GD_POP 27 +#define R_386_TLS_LDM_32 28 +#define R_386_TLS_LDM_PUSH 29 +#define R_386_TLS_LDM_CALL 30 +#define R_386_TLS_LDM_POP 31 +#define R_386_TLS_LDO_32 32 +#define R_386_TLS_IE_32 33 +#define R_386_TLS_LE_32 34 +#define R_386_TLS_DTPMOD32 35 +#define R_386_TLS_DTPOFF32 36 +#define R_386_TLS_TPOFF32 37 +#define R_386_TLS_GOTDESC 39 +#define R_386_TLS_DESC_CALL 40 +#define R_386_TLS_DESC 41 + +#define R_TYPE(name) __CONCAT(R_386_,name) diff --git a/cpukit/score/cpu/i386/include/rtems/asm.h b/cpukit/score/cpu/i386/include/rtems/asm.h new file mode 100644 index 0000000000..50b0fd71a0 --- /dev/null +++ b/cpukit/score/cpu/i386/include/rtems/asm.h @@ -0,0 +1,140 @@ +/** + * @file + * + * @brief Address the Problems Caused by Incompatible Flavor of + * Assemblers and Toolsets + * + * This include file attempts to address the problems + * caused by incompatible flavors of assemblers and + * toolsets. It primarily addresses variations in the + * use of leading underscores on symbols and the requirement + * that register names be preceded by a %. + * + * NOTE: The spacing in the use of these macros + * is critical to them working as advertised. + */ + +/* + * COPYRIGHT: + * + * This file is based on similar code found in newlib available + * from ftp.cygnus.com. The file which was used had no copyright + * notice. This file is freely distributable as long as the source + * of the file is noted. This file is: + * + * COPYRIGHT (c) 1994-1997. + * On-Line Applications Research Corporation (OAR). + */ + +#ifndef _RTEMS_ASM_H +#define _RTEMS_ASM_H + +/* + * Indicate we are in an assembly file and get the basic CPU definitions. + */ + +#ifndef ASM +#define ASM +#endif +#include +#include + +/* + * Recent versions of GNU cpp define variables which indicate the + * need for underscores and percents. If not using GNU cpp or + * the version does not support this, then you will obviously + * have to define these as appropriate. + */ + +#ifndef __USER_LABEL_PREFIX__ +#define __USER_LABEL_PREFIX__ +#endif + +/* + * Looks like there is a bug in gcc 2.6.2 where this is not + * defined correctly when configured as i386-coff and + * i386-aout. + */ + +#undef __REGISTER_PREFIX__ +#define __REGISTER_PREFIX__ % + +/* +#ifndef __REGISTER_PREFIX__ +#define __REGISTER_PREFIX__ +#endif +*/ + +#include + +/* Use the right prefix for global labels. */ + +#define SYM(x) CONCAT0 (__USER_LABEL_PREFIX__, x) + +/* Use the right prefix for registers. */ + +#define REG(x) CONCAT0 (__REGISTER_PREFIX__, x) + +#define eax REG (eax) +#define ebx REG (ebx) +#define ecx REG (ecx) +#define edx REG (edx) +#define esi REG (esi) +#define edi REG (edi) +#define esp REG (esp) +#define ebp REG (ebp) +#define cr0 REG (cr0) +#define cr4 REG (cr4) + +#define ax REG (ax) +#define bx REG (bx) +#define cx REG (cx) +#define dx REG (dx) +#define si REG (si) +#define di REG (di) +#define sp REG (sp) +#define bp REG (bp) + +#define ah REG (ah) +#define bh REG (bh) +#define ch REG (ch) +#define dh REG (dh) + +#define al REG (al) +#define bl REG (bl) +#define cl REG (cl) +#define dl REG (dl) + +#define cs REG (cs) +#define ds REG (ds) +#define es REG (es) +#define fs REG (fs) +#define gs REG (gs) +#define ss REG (ss) + +/* + * Define macros to handle section beginning and ends. + */ + + +#define BEGIN_CODE_DCL .text +#define END_CODE_DCL +#define BEGIN_DATA_DCL .data +#define END_DATA_DCL +#define BEGIN_CODE .text +#define END_CODE +#define BEGIN_DATA .data +#define END_DATA +#define BEGIN_BSS .bss +#define END_BSS +#define END + +/* + * Following must be tailor for a particular flavor of the C compiler. + * They may need to put underscores in front of the symbols. + */ + +#define PUBLIC(sym) .globl SYM (sym) +#define EXTERN(sym) .globl SYM (sym) + +#endif diff --git a/cpukit/score/cpu/i386/include/rtems/score/cpu.h b/cpukit/score/cpu/i386/include/rtems/score/cpu.h new file mode 100644 index 0000000000..f78149c24b --- /dev/null +++ b/cpukit/score/cpu/i386/include/rtems/score/cpu.h @@ -0,0 +1,700 @@ +/** + * @file + * + * @brief Intel I386 CPU Dependent Source + * + * This include file contains information pertaining to the Intel + * i386 processor. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPU_H +#define _RTEMS_SCORE_CPU_H + +#ifndef ASM +#include /* for memcpy */ +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* conditional compilation parameters */ + +/* + * Does the CPU follow the simple vectored interrupt model? + * + * If TRUE, then RTEMS allocates the vector table it internally manages. + * If FALSE, then the BSP is assumed to allocate and manage the vector + * table + * + * PowerPC Specific Information: + * + * The PowerPC and x86 were the first to use the PIC interrupt model. + * They do not use the simple vectored interrupt model. + */ +#define CPU_SIMPLE_VECTORED_INTERRUPTS FALSE + +/* + * i386 has an RTEMS allocated and managed interrupt stack. + */ + +#define CPU_HAS_SOFTWARE_INTERRUPT_STACK TRUE +#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE +#define CPU_ALLOCATE_INTERRUPT_STACK TRUE + +/* + * Does the RTEMS invoke the user's ISR with the vector number and + * a pointer to the saved interrupt frame (1) or just the vector + * number (0)? + */ + +#define CPU_ISR_PASSES_FRAME_POINTER FALSE + +/* + * Some family members have no FP, some have an FPU such as the i387 + * for the i386, others have it built in (i486DX, Pentium). + */ + +#ifdef __SSE__ +#define CPU_HARDWARE_FP TRUE +#define CPU_SOFTWARE_FP FALSE + +#define CPU_ALL_TASKS_ARE_FP TRUE +#define CPU_IDLE_TASK_IS_FP TRUE +#define CPU_USE_DEFERRED_FP_SWITCH FALSE +#else /* __SSE__ */ + +#if ( I386_HAS_FPU == 1 ) +#define CPU_HARDWARE_FP TRUE /* i387 for i386 */ +#else +#define CPU_HARDWARE_FP FALSE +#endif +#define CPU_SOFTWARE_FP FALSE + +#define CPU_ALL_TASKS_ARE_FP FALSE +#define CPU_IDLE_TASK_IS_FP FALSE +#if defined(RTEMS_SMP) + #define CPU_USE_DEFERRED_FP_SWITCH FALSE +#else + #define CPU_USE_DEFERRED_FP_SWITCH TRUE +#endif +#endif /* __SSE__ */ + +#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE + +#define CPU_STACK_GROWS_UP FALSE + +/* FIXME: The Pentium 4 used 128 bytes, it this processor still relevant? */ +#define CPU_CACHE_LINE_BYTES 64 + +#define CPU_STRUCTURE_ALIGNMENT + +/* + * Does this port provide a CPU dependent IDLE task implementation? + * + * If TRUE, then the routine _CPU_Thread_Idle_body + * must be provided and is the default IDLE thread body instead of + * _CPU_Thread_Idle_body. + * + * If FALSE, then use the generic IDLE thread body if the BSP does + * not provide one. + */ + +#define CPU_PROVIDES_IDLE_THREAD_BODY FALSE + +#define CPU_MAXIMUM_PROCESSORS 32 + +#define I386_CONTEXT_CONTROL_EFLAGS_OFFSET 0 +#define I386_CONTEXT_CONTROL_ESP_OFFSET 4 +#define I386_CONTEXT_CONTROL_EBP_OFFSET 8 +#define I386_CONTEXT_CONTROL_EBX_OFFSET 12 +#define I386_CONTEXT_CONTROL_ESI_OFFSET 16 +#define I386_CONTEXT_CONTROL_EDI_OFFSET 20 +#define I386_CONTEXT_CONTROL_GS_0_OFFSET 24 +#define I386_CONTEXT_CONTROL_GS_1_OFFSET 28 + +#ifdef RTEMS_SMP + #define I386_CONTEXT_CONTROL_IS_EXECUTING_OFFSET 32 +#endif + +/* structures */ + +#ifndef ASM + +/* + * Basic integer context for the i386 family. + */ + +typedef struct { + uint32_t eflags; /* extended flags register */ + void *esp; /* extended stack pointer register */ + void *ebp; /* extended base pointer register */ + uint32_t ebx; /* extended bx register */ + uint32_t esi; /* extended source index register */ + uint32_t edi; /* extended destination index flags register */ + segment_descriptors gs; /* gs segment descriptor */ +#ifdef RTEMS_SMP + volatile bool is_executing; +#endif +} Context_Control; + +#define _CPU_Context_Get_SP( _context ) \ + (_context)->esp + +#ifdef RTEMS_SMP + static inline bool _CPU_Context_Get_is_executing( + const Context_Control *context + ) + { + return context->is_executing; + } + + static inline void _CPU_Context_Set_is_executing( + Context_Control *context, + bool is_executing + ) + { + context->is_executing = is_executing; + } +#endif + +/* + * FP context save area for the i387 numeric coprocessors. + */ +#ifdef __SSE__ +/* All FPU and SSE registers are volatile; hence, as long + * as we are within normally executing C code (including + * a task switch) there is no need for saving/restoring + * any of those registers. + * We must save/restore the full FPU/SSE context across + * interrupts and exceptions, however: + * - after ISR execution a _Thread_Dispatch() may happen + * and it is therefore necessary to save the FPU/SSE + * registers to be restored when control is returned + * to the interrupted task. + * - gcc may implicitly use FPU/SSE instructions in + * an ISR. + * + * Even though there is no explicit mentioning of the FPU + * control word in the SYSV ABI (i386) being non-volatile + * we maintain MXCSR and the FPU control-word for each task. + */ +typedef struct { + uint32_t mxcsr; + uint16_t fpucw; +} Context_Control_fp; + +#else + +typedef struct { + uint8_t fp_save_area[108]; /* context size area for I80387 */ + /* 28 bytes for environment */ +} Context_Control_fp; + +#endif + + +/* + * The following structure defines the set of information saved + * on the current stack by RTEMS upon receipt of execptions. + * + * idtIndex is either the interrupt number or the trap/exception number. + * faultCode is the code pushed by the processor on some exceptions. + * + * Since the first registers are directly pushed by the CPU they + * may not respect 16-byte stack alignment, which is, however, + * mandatory for the SSE register area. + * Therefore, these registers are stored at an aligned address + * and a pointer is stored in the CPU_Exception_frame. + * If the executive was compiled without SSE support then + * this pointer is NULL. + */ + +struct Context_Control_sse; + +typedef struct { + struct Context_Control_sse *fp_ctxt; + uint32_t edi; + uint32_t esi; + uint32_t ebp; + uint32_t esp0; + uint32_t ebx; + uint32_t edx; + uint32_t ecx; + uint32_t eax; + uint32_t idtIndex; + uint32_t faultCode; + uint32_t eip; + uint32_t cs; + uint32_t eflags; +} CPU_Exception_frame; + +#ifdef __SSE__ +typedef struct Context_Control_sse { + uint16_t fcw; + uint16_t fsw; + uint8_t ftw; + uint8_t res_1; + uint16_t fop; + uint32_t fpu_ip; + uint16_t cs; + uint16_t res_2; + uint32_t fpu_dp; + uint16_t ds; + uint16_t res_3; + uint32_t mxcsr; + uint32_t mxcsr_mask; + struct { + uint8_t fpreg[10]; + uint8_t res_4[ 6]; + } fp_mmregs[8]; + uint8_t xmmregs[8][16]; + uint8_t res_5[224]; +} Context_Control_sse +__attribute__((aligned(16))) +; +#endif + +typedef void (*cpuExcHandlerType) (CPU_Exception_frame*); +extern cpuExcHandlerType _currentExcHandler; +extern void rtems_exception_init_mngt(void); + +/* + * This port does not pass any frame info to the + * interrupt handler. + */ + +typedef void CPU_Interrupt_frame; + +typedef enum { + I386_EXCEPTION_DIVIDE_BY_ZERO = 0, + I386_EXCEPTION_DEBUG = 1, + I386_EXCEPTION_NMI = 2, + I386_EXCEPTION_BREAKPOINT = 3, + I386_EXCEPTION_OVERFLOW = 4, + I386_EXCEPTION_BOUND = 5, + I386_EXCEPTION_ILLEGAL_INSTR = 6, + I386_EXCEPTION_MATH_COPROC_UNAVAIL = 7, + I386_EXCEPTION_DOUBLE_FAULT = 8, + I386_EXCEPTION_I386_COPROC_SEG_ERR = 9, + I386_EXCEPTION_INVALID_TSS = 10, + I386_EXCEPTION_SEGMENT_NOT_PRESENT = 11, + I386_EXCEPTION_STACK_SEGMENT_FAULT = 12, + I386_EXCEPTION_GENERAL_PROT_ERR = 13, + I386_EXCEPTION_PAGE_FAULT = 14, + I386_EXCEPTION_INTEL_RES15 = 15, + I386_EXCEPTION_FLOAT_ERROR = 16, + I386_EXCEPTION_ALIGN_CHECK = 17, + I386_EXCEPTION_MACHINE_CHECK = 18, + I386_EXCEPTION_ENTER_RDBG = 50 /* to enter manually RDBG */ + +} Intel_symbolic_exception_name; + + +/* + * context size area for floating point + * + * NOTE: This is out of place on the i386 to avoid a forward reference. + */ + +#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp ) + +/* variables */ + +extern Context_Control_fp _CPU_Null_fp_context; + +#endif /* ASM */ + +/* constants */ + +/* + * This defines the number of levels and the mask used to pick those + * bits out of a thread mode. + */ + +#define CPU_MODES_INTERRUPT_LEVEL 0x00000001 /* interrupt level in mode */ +#define CPU_MODES_INTERRUPT_MASK 0x00000001 /* interrupt level in mode */ + +/* + * extra stack required by the MPCI receive server thread + */ + +#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 1024 + +/* + * This is defined if the port has a special way to report the ISR nesting + * level. Most ports maintain the variable _ISR_Nest_level. + */ + +#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE + +/* + * Minimum size of a thread's stack. + */ + +#define CPU_STACK_MINIMUM_SIZE 4096 + +#define CPU_SIZEOF_POINTER 4 + +/* + * i386 is pretty tolerant of alignment. Just put things on 4 byte boundaries. + */ + +#define CPU_ALIGNMENT 4 +#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT +#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT + +/* + * On i386 thread stacks require no further alignment after allocation + * from the Workspace. However, since gcc maintains 16-byte alignment + * we try to respect that. If you find an option to let gcc squeeze + * the stack more tightly then setting CPU_STACK_ALIGNMENT to 16 still + * doesn't waste much space since this only determines the *initial* + * alignment. + */ + +#define CPU_STACK_ALIGNMENT 16 + +/* macros */ + +#ifndef ASM +/* + * ISR handler macros + * + * These macros perform the following functions: + * + initialize the RTEMS vector table + * + disable all maskable CPU interrupts + * + restore previous interrupt level (enable) + * + temporarily restore interrupts (flash) + * + set a particular level + */ + +#if !defined(RTEMS_PARAVIRT) +#define _CPU_ISR_Disable( _level ) i386_disable_interrupts( _level ) + +#define _CPU_ISR_Enable( _level ) i386_enable_interrupts( _level ) + +#define _CPU_ISR_Flash( _level ) i386_flash_interrupts( _level ) + +#define _CPU_ISR_Set_level( _new_level ) \ + { \ + if ( _new_level ) __asm__ volatile ( "cli" ); \ + else __asm__ volatile ( "sti" ); \ + } +#else +#define _CPU_ISR_Disable( _level ) _level = i386_disable_interrupts() +#define _CPU_ISR_Enable( _level ) i386_enable_interrupts( _level ) +#define _CPU_ISR_Flash( _level ) i386_flash_interrupts( _level ) +#define _CPU_ISR_Set_level( _new_level ) i386_set_interrupt_level(_new_level) +#endif + +RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) +{ + return ( level & EFLAGS_INTR_ENABLE ) != 0; +} + +uint32_t _CPU_ISR_Get_level( void ); + +/* Make sure interrupt stack has space for ISR + * 'vector' arg at the top and that it is aligned + * properly. + */ + +#define _CPU_Interrupt_stack_setup( _lo, _hi ) \ + do { \ + _hi = (void*)(((uintptr_t)(_hi) - 4) & ~ (CPU_STACK_ALIGNMENT - 1)); \ + } while (0) + +#endif /* ASM */ + +/* end of ISR handler macros */ + +/* + * Context handler macros + * + * These macros perform the following functions: + * + initialize a context area + * + restart the current thread + * + calculate the initial pointer into a FP context area + * + initialize an FP context area + */ + +#define CPU_EFLAGS_INTERRUPTS_ON 0x00003202 +#define CPU_EFLAGS_INTERRUPTS_OFF 0x00003002 + +#ifndef ASM + +void _CPU_Context_Initialize( + Context_Control *the_context, + void *stack_area_begin, + size_t stack_area_size, + uint32_t new_level, + void (*entry_point)( void ), + bool is_fp, + void *tls_area +); + +#define _CPU_Context_Restart_self( _the_context ) \ + _CPU_Context_restore( (_the_context) ); + +#if defined(RTEMS_SMP) + uint32_t _CPU_SMP_Initialize( void ); + + bool _CPU_SMP_Start_processor( uint32_t cpu_index ); + + void _CPU_SMP_Finalize_initialization( uint32_t cpu_count ); + + /* Nothing to do */ + #define _CPU_SMP_Prepare_start_multitasking() do { } while ( 0 ) + + uint32_t _CPU_SMP_Get_current_processor( void ); + + void _CPU_SMP_Send_interrupt( uint32_t target_processor_index ); + + static inline void _CPU_SMP_Processor_event_broadcast( void ) + { + __asm__ volatile ( "" : : : "memory" ); + } + + static inline void _CPU_SMP_Processor_event_receive( void ) + { + __asm__ volatile ( "" : : : "memory" ); + } +#endif + +#define _CPU_Context_Initialize_fp( _fp_area ) \ + { \ + memcpy( *_fp_area, &_CPU_Null_fp_context, CPU_CONTEXT_FP_SIZE ); \ + } + +/* end of Context handler macros */ + +/* + * Fatal Error manager macros + * + * These macros perform the following functions: + * + disable interrupts and halt the CPU + */ + +extern void _CPU_Fatal_halt(uint32_t source, uint32_t error) + RTEMS_NO_RETURN; + +#endif /* ASM */ + +/* end of Fatal Error manager macros */ + +/* + * Bitfield handler macros + * + * These macros perform the following functions: + * + scan for the highest numbered (MSB) set in a 16 bit bitfield + */ + +#define CPU_USE_GENERIC_BITFIELD_CODE FALSE + +#define _CPU_Bitfield_Find_first_bit( _value, _output ) \ + { \ + register uint16_t __value_in_register = ( _value ); \ + uint16_t __output = 0; \ + __asm__ volatile ( "bsfw %0,%1 " \ + : "=r" ( __value_in_register ), "=r" ( __output ) \ + : "0" ( __value_in_register ), "1" ( __output ) \ + ); \ + ( _output ) = __output; \ + } + +/* end of Bitfield handler macros */ + +/* + * Priority handler macros + * + * These macros perform the following functions: + * + return a mask with the bit for this major/minor portion of + * of thread priority set. + * + translate the bit number returned by "Bitfield_find_first_bit" + * into an index into the thread ready chain bit maps + */ + +#define _CPU_Priority_Mask( _bit_number ) \ + ( 1 << (_bit_number) ) + +#define _CPU_Priority_bits_index( _priority ) \ + (_priority) + +/* functions */ + +#ifndef ASM +/* + * _CPU_Initialize + * + * This routine performs CPU dependent initialization. + */ + +void _CPU_Initialize(void); + +/* + * _CPU_ISR_install_raw_handler + * + * This routine installs a "raw" interrupt handler directly into the + * processor's vector table. + */ + +void _CPU_ISR_install_raw_handler( + uint32_t vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +/* + * _CPU_ISR_install_vector + * + * This routine installs an interrupt vector. + */ + +void _CPU_ISR_install_vector( + uint32_t vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +/* + * _CPU_Thread_Idle_body + * + * Use the halt instruction of low power mode of a particular i386 model. + */ + +#if (CPU_PROVIDES_IDLE_THREAD_BODY == TRUE) + +void *_CPU_Thread_Idle_body( uintptr_t ignored ); + +#endif /* CPU_PROVIDES_IDLE_THREAD_BODY */ + +/* + * _CPU_Context_switch + * + * This routine switches from the run context to the heir context. + */ + +void _CPU_Context_switch( + Context_Control *run, + Context_Control *heir +); + +/* + * _CPU_Context_restore + * + * This routine is generally used only to restart self in an + * efficient manner and avoid stack conflicts. + */ + +void _CPU_Context_restore( + Context_Control *new_context +) RTEMS_NO_RETURN; + +/* + * _CPU_Context_save_fp + * + * This routine saves the floating point context passed to it. + */ + +#ifdef __SSE__ +#define _CPU_Context_save_fp(fp_context_pp) \ + do { \ + __asm__ __volatile__( \ + "fstcw %0" \ + :"=m"((*(fp_context_pp))->fpucw) \ + ); \ + __asm__ __volatile__( \ + "stmxcsr %0" \ + :"=m"((*(fp_context_pp))->mxcsr) \ + ); \ + } while (0) +#else +void _CPU_Context_save_fp( + Context_Control_fp **fp_context_ptr +); +#endif + +/* + * _CPU_Context_restore_fp + * + * This routine restores the floating point context passed to it. + */ +#ifdef __SSE__ +#define _CPU_Context_restore_fp(fp_context_pp) \ + do { \ + __asm__ __volatile__( \ + "fldcw %0" \ + ::"m"((*(fp_context_pp))->fpucw) \ + :"fpcr" \ + ); \ + __builtin_ia32_ldmxcsr(_Thread_Executing->fp_context->mxcsr); \ + } while (0) +#else +void _CPU_Context_restore_fp( + Context_Control_fp **fp_context_ptr +); +#endif + +#ifdef __SSE__ +#define _CPU_Context_Initialization_at_thread_begin() \ + do { \ + __asm__ __volatile__( \ + "finit" \ + : \ + : \ + :"st","st(1)","st(2)","st(3)", \ + "st(4)","st(5)","st(6)","st(7)", \ + "fpsr","fpcr" \ + ); \ + if ( _Thread_Executing->fp_context ) { \ + _CPU_Context_restore_fp(&_Thread_Executing->fp_context); \ + } \ + } while (0) +#endif + +static inline void _CPU_Context_volatile_clobber( uintptr_t pattern ) +{ + /* TODO */ +} + +static inline void _CPU_Context_validate( uintptr_t pattern ) +{ + while (1) { + /* TODO */ + } +} + +void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); + +typedef uint32_t CPU_Counter_ticks; + +CPU_Counter_ticks _CPU_Counter_read( void ); + +static inline CPU_Counter_ticks _CPU_Counter_difference( + CPU_Counter_ticks second, + CPU_Counter_ticks first +) +{ + return second - first; +} + +#endif /* ASM */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/score/cpu/i386/include/rtems/score/cpuatomic.h b/cpukit/score/cpu/i386/include/rtems/score/cpuatomic.h new file mode 100644 index 0000000000..598ee76b20 --- /dev/null +++ b/cpukit/score/cpu/i386/include/rtems/score/cpuatomic.h @@ -0,0 +1,14 @@ +/* + * COPYRIGHT (c) 2012-2013 Deng Hengyi. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_ATOMIC_CPU_H +#define _RTEMS_SCORE_ATOMIC_CPU_H + +#include + +#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/i386/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/i386/include/rtems/score/cpuimpl.h new file mode 100644 index 0000000000..789f2badd9 --- /dev/null +++ b/cpukit/score/cpu/i386/include/rtems/score/cpuimpl.h @@ -0,0 +1,34 @@ +/** + * @file + * + * @brief CPU Port Implementation API + */ + +/* + * Copyright (c) 2013 embedded brains GmbH + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPUIMPL_H +#define _RTEMS_SCORE_CPUIMPL_H + +#include + +#define CPU_PER_CPU_CONTROL_SIZE 0 + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ASM */ + +#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/i386/include/rtems/score/i386.h b/cpukit/score/cpu/i386/include/rtems/score/i386.h new file mode 100644 index 0000000000..2555d13b8b --- /dev/null +++ b/cpukit/score/cpu/i386/include/rtems/score/i386.h @@ -0,0 +1,670 @@ +/** + * @file + * + * @brief Intel I386 CPU Dependent Source + * + * This include file contains information pertaining to the Intel + * i386 processor. + */ + +/* + * COPYRIGHT (c) 1989-2016. + * On-Line Applications Research Corporation (OAR). + * + * Copyright (C) 1998 Eric Valette (valette@crf.canon.fr) + * Canon Centre Recherche France. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_I386_H +#define _RTEMS_SCORE_I386_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* + * This section contains the information required to build + * RTEMS for a particular member of the Intel i386 + * family when executing in protected mode. It does + * this by setting variables to indicate which implementation + * dependent features are present in a particular member + * of the family. + * + * Currently recognized: + * i386_fp (i386 DX or SX w/i387) + * i486dx + * pentium + * pentiumpro + * + * CPU Model Feature Flags: + * + * I386_HAS_BSWAP: Defined to "1" if the instruction for endian swapping + * (bswap) should be used. This instruction appears to + * be present in all i486's and above. + * + * I386_HAS_FPU: Defined to "1" if the CPU has an FPU. + * As of at least gcc 4.7, i386 soft-float was obsoleted. + * Thus this is always set to "1". + */ +#define I386_HAS_FPU 1 + +#if defined(__pentiumpro__) + + #define CPU_MODEL_NAME "Pentium Pro" + +#elif defined(__i586__) + + #if defined(__pentium__) + #define CPU_MODEL_NAME "Pentium" + #elif defined(__k6__) + #define CPU_MODEL_NAME "K6" + #else + #define CPU_MODEL_NAME "i586" + #endif + +#elif defined(__i486__) + + #define CPU_MODEL_NAME "i486dx" + +#elif defined(__i386__) + + #define I386_HAS_BSWAP 0 + #define CPU_MODEL_NAME "i386 with i387" + +#else + #error "Unknown CPU Model" +#endif + +/* + * Set default values for CPU model feature flags + * + * NOTE: These settings are chosen to reflect most of the family members. + */ +#ifndef I386_HAS_BSWAP +#define I386_HAS_BSWAP 1 +#endif + +/* + * Define the name of the CPU family. + */ +#define CPU_NAME "Intel i386" + +#ifndef ASM + +/* + * The following routine swaps the endian format of an unsigned int. + * It must be static so it can be referenced indirectly. + */ + +static inline uint32_t i386_swap_u32( + uint32_t value +) +{ + uint32_t lout; + +#if (I386_HAS_BSWAP == 0) + __asm__ volatile( "rorw $8,%%ax;" + "rorl $16,%0;" + "rorw $8,%%ax" : "=a" (lout) : "0" (value) ); +#else + __asm__ volatile( "bswap %0" : "=r" (lout) : "0" (value)); +#endif + return( lout ); +} +#define CPU_swap_u32( _value ) i386_swap_u32( _value ) + +static inline uint16_t i386_swap_u16( + uint16_t value +) +{ + unsigned short sout; + + __asm__ volatile( "rorw $8,%0" : "=r" (sout) : "0" (value)); + return (sout); +} +#define CPU_swap_u16( _value ) i386_swap_u16( _value ) + +/* + * Added for pagination management + */ +static inline unsigned int i386_get_cr0(void) +{ + register unsigned int segment = 0; + + __asm__ volatile ( "movl %%cr0,%0" : "=r" (segment) : "0" (segment) ); + + return segment; +} + +static inline void i386_set_cr0(unsigned int segment) +{ + __asm__ volatile ( "movl %0,%%cr0" : "=r" (segment) : "0" (segment) ); +} + +static inline unsigned int i386_get_cr2(void) +{ + register unsigned int segment = 0; + + __asm__ volatile ( "movl %%cr2,%0" : "=r" (segment) : "0" (segment) ); + + return segment; +} + +static inline unsigned int i386_get_cr3(void) +{ + register unsigned int segment = 0; + + __asm__ volatile ( "movl %%cr3,%0" : "=r" (segment) : "0" (segment) ); + + return segment; +} + +static inline void i386_set_cr3(unsigned int segment) +{ + __asm__ volatile ( "movl %0,%%cr3" : "=r" (segment) : "0" (segment) ); +} + +/* routines */ + +/* + * i386_Logical_to_physical + * + * Converts logical address to physical address. + */ +void *i386_Logical_to_physical( + unsigned short segment, + void *address +); + +/* + * i386_Physical_to_logical + * + * Converts physical address to logical address. + */ +void *i386_Physical_to_logical( + unsigned short segment, + void *address +); + +/** + * @brief Converts real mode pointer {segment, offset} to physical address. + * + * i386_Real_to_physical + * + * @param[in] segment used with \p offset to compute physical address + * @param[in] offset used with \p segment to compute physical address + * @retval physical address + */ +RTEMS_INLINE_ROUTINE void *i386_Real_to_physical( + uint16_t segment, + uint16_t offset) +{ + return (void *)(((uint32_t)segment<<4)+offset); +} + +/** + * @brief Retrieves real mode pointer elements {segmnet, offset} from + * physical address. + * + * i386_Physical_to_real + * Function returns the highest segment (base) address possible. + * Example: input address - 0x4B3A2 + * output segment - 0x4B3A + * offset - 0x2 + * input address - 0x10F12E + * output segment - 0xFFFF + * offset - 0xF13E + * + * @param[in] address address to be converted, must be less than 0x10FFEF + * @param[out] segment segment computed from \p address + * @param[out] offset offset computed from \p address + * @retval 0 address not convertible + * @retval 1 segment and offset extracted + */ +int i386_Physical_to_real( + void *address, + uint16_t *segment, + uint16_t *offset +); + +/* + * Segment Access Routines + * + * NOTE: Unfortunately, these are still static inlines even when the + * "macro" implementation of the generic code is used. + */ + +static __inline__ unsigned short i386_get_cs(void) +{ + register unsigned short segment = 0; + + __asm__ volatile ( "movw %%cs,%0" : "=r" (segment) : "0" (segment) ); + + return segment; +} + +static __inline__ unsigned short i386_get_ds(void) +{ + register unsigned short segment = 0; + + __asm__ volatile ( "movw %%ds,%0" : "=r" (segment) : "0" (segment) ); + + return segment; +} + +static __inline__ unsigned short i386_get_es(void) +{ + register unsigned short segment = 0; + + __asm__ volatile ( "movw %%es,%0" : "=r" (segment) : "0" (segment) ); + + return segment; +} + +static __inline__ unsigned short i386_get_ss(void) +{ + register unsigned short segment = 0; + + __asm__ volatile ( "movw %%ss,%0" : "=r" (segment) : "0" (segment) ); + + return segment; +} + +static __inline__ unsigned short i386_get_fs(void) +{ + register unsigned short segment = 0; + + __asm__ volatile ( "movw %%fs,%0" : "=r" (segment) : "0" (segment) ); + + return segment; +} + +static __inline__ unsigned short i386_get_gs(void) +{ + register unsigned short segment = 0; + + __asm__ volatile ( "movw %%gs,%0" : "=r" (segment) : "0" (segment) ); + + return segment; +} + +/* + * IO Port Access Routines + */ + +#define i386_outport_byte( _port, _value ) \ +do { register unsigned short __port = _port; \ + register unsigned char __value = _value; \ + \ + __asm__ volatile ( "outb %0,%1" : : "a" (__value), "d" (__port) ); \ + } while (0) + +#define i386_outport_word( _port, _value ) \ +do { register unsigned short __port = _port; \ + register unsigned short __value = _value; \ + \ + __asm__ volatile ( "outw %0,%1" : : "a" (__value), "d" (__port) ); \ + } while (0) + +#define i386_outport_long( _port, _value ) \ +do { register unsigned short __port = _port; \ + register unsigned int __value = _value; \ + \ + __asm__ volatile ( "outl %0,%1" : : "a" (__value), "d" (__port) ); \ + } while (0) + +#define i386_inport_byte( _port, _value ) \ +do { register unsigned short __port = _port; \ + register unsigned char __value = 0; \ + \ + __asm__ volatile ( "inb %1,%0" : "=a" (__value) \ + : "d" (__port) \ + ); \ + _value = __value; \ + } while (0) + +#define i386_inport_word( _port, _value ) \ +do { register unsigned short __port = _port; \ + register unsigned short __value = 0; \ + \ + __asm__ volatile ( "inw %1,%0" : "=a" (__value) \ + : "d" (__port) \ + ); \ + _value = __value; \ + } while (0) + +#define i386_inport_long( _port, _value ) \ +do { register unsigned short __port = _port; \ + register unsigned int __value = 0; \ + \ + __asm__ volatile ( "inl %1,%0" : "=a" (__value) \ + : "d" (__port) \ + ); \ + _value = __value; \ + } while (0) + +/* + * Type definition for raw interrupts. + */ + +typedef unsigned char rtems_vector_offset; + +typedef struct __rtems_raw_irq_connect_data__{ + /* + * IDT vector offset (IRQ line + PC386_IRQ_VECTOR_BASE) + */ + rtems_vector_offset idtIndex; + /* + * IDT raw handler. See comment on handler properties below in function prototype. + */ + rtems_raw_irq_hdl hdl; + /* + * function for enabling raw interrupts. In order to be consistent + * with the fact that the raw connexion can defined in the + * libcpu library, this library should have no knowledge of + * board specific hardware to manage interrupts and thus the + * "on" routine must enable the irq both at device and PIC level. + * + */ + rtems_raw_irq_enable on; + /* + * function for disabling raw interrupts. In order to be consistent + * with the fact that the raw connexion can defined in the + * libcpu library, this library should have no knowledge of + * board specific hardware to manage interrupts and thus the + * "on" routine must disable the irq both at device and PIC level. + * + */ + rtems_raw_irq_disable off; + /* + * function enabling to know what interrupt may currently occur + */ + rtems_raw_irq_is_enabled isOn; +}rtems_raw_irq_connect_data; + +typedef struct { + /* + * size of all the table fields (*Tbl) described below. + */ + unsigned int idtSize; + /* + * Default handler used when disconnecting interrupts. + */ + rtems_raw_irq_connect_data defaultRawEntry; + /* + * Table containing initials/current value. + */ + rtems_raw_irq_connect_data* rawIrqHdlTbl; +}rtems_raw_irq_global_settings; + +#include + +/* + * C callable function enabling to get handler currently connected to a vector + * + */ +rtems_raw_irq_hdl get_hdl_from_vector(rtems_vector_offset); + +/* + * C callable function enabling to set up one raw idt entry + */ +extern int i386_set_idt_entry (const rtems_raw_irq_connect_data*); + +/* + * C callable function enabling to get one current raw idt entry + */ +extern int i386_get_current_idt_entry (rtems_raw_irq_connect_data*); + +/* + * C callable function enabling to remove one current raw idt entry + */ +extern int i386_delete_idt_entry (const rtems_raw_irq_connect_data*); + +/* + * C callable function enabling to init idt. + * + * CAUTION : this function assumes that the IDTR register + * has been already set. + */ +extern int i386_init_idt (rtems_raw_irq_global_settings* config); + +/* + * C callable function enabling to get actual idt configuration + */ +extern int i386_get_idt_config (rtems_raw_irq_global_settings** config); + + +/* + * See page 11.12 Figure 11-8. + * + */ +/** + * @brief describes one entry of Global/Local Descriptor Table + */ +typedef struct { + unsigned int limit_15_0 : 16; + unsigned int base_address_15_0 : 16; + unsigned int base_address_23_16 : 8; + unsigned int type : 4; + unsigned int descriptor_type : 1; + unsigned int privilege : 2; + unsigned int present : 1; + unsigned int limit_19_16 : 4; + unsigned int available : 1; + unsigned int fixed_value_bits : 1; + unsigned int operation_size : 1; + unsigned int granularity : 1; + unsigned int base_address_31_24 : 8; +} RTEMS_PACKED segment_descriptors; + +/* + * C callable function enabling to get easilly usable info from + * the actual value of GDT register. + */ +extern void i386_get_info_from_GDTR (segment_descriptors** table, + uint16_t* limit); +/* + * C callable function enabling to change the value of GDT register. Must be called + * with interrupts masked at processor level!!!. + */ +extern void i386_set_GDTR (segment_descriptors*, + uint16_t limit); + +/** + * @brief Allows to set a GDT entry. + * + * Puts global descriptor \p sd to the global descriptor table on index + * \p segment_selector_index + * + * @param[in] segment_selector_index index to GDT entry + * @param[in] sd structure to be coppied to given \p segment_selector in GDT + * @retval 0 FAILED out of GDT range or index is 0, which is not valid + * index in GDT + * @retval 1 SUCCESS + */ +extern uint32_t i386_raw_gdt_entry (uint16_t segment_selector_index, + segment_descriptors* sd); + +/** + * @brief fills \p sd with provided \p base in appropriate fields of \p sd + * + * @param[in] base 32-bit address to be set as descriptor's base + * @param[out] sd descriptor being filled with \p base + */ +extern void i386_fill_segment_desc_base (uint32_t base, + segment_descriptors* sd); + +/** + * @brief fills \p sd with provided \p limit in appropriate fields of \p sd + * + * sets granularity bit if necessary + * + * @param[in] limit 32-bit value representing number of limit bytes + * @param[out] sd descriptor being filled with \p limit + */ +extern void i386_fill_segment_desc_limit (uint32_t limit, + segment_descriptors* sd); + +/* + * C callable function enabling to set up one raw interrupt handler + */ +extern uint32_t i386_set_gdt_entry (uint16_t segment_selector, + uint32_t base, + uint32_t limit); + +/** + * @brief Returns next empty descriptor in GDT. + * + * Number of descriptors that can be returned depends on \a GDT_SIZE + * + * @retval 0 FAILED GDT is full + * @retval <1;65535> segment_selector number as index to GDT + */ +extern uint16_t i386_next_empty_gdt_entry (void); + +/** + * @brief Copies GDT entry at index \p segment_selector to structure + * pointed to by \p struct_to_fill + * + * @param[in] segment_selector index to GDT table specifying descriptor to copy + * @param[out] struct_to_fill pointer to memory where will be descriptor coppied + * @retval 0 FAILED segment_selector out of GDT range + * @retval <1;65535> retrieved segment_selector + */ +extern uint16_t i386_cpy_gdt_entry (uint16_t segment_selector, + segment_descriptors* struct_to_fill); + +/** + * @brief Returns pointer to GDT table at index given by \p segment_selector + * + * @param[in] sgmnt_selector index to GDT table for specifying descriptor to get + * @retval NULL FAILED segment_selector out of GDT range + * @retval pointer to GDT table at \p segment_selector + */ +extern segment_descriptors* i386_get_gdt_entry (uint16_t sgmnt_selector); + +/** + * @brief Extracts base address from GDT entry pointed to by \p gdt_entry + * + * @param[in] gdt_entry pointer to entry from which base should be retrieved + * @retval base address from GDT entry +*/ +RTEMS_INLINE_ROUTINE void* i386_base_gdt_entry (segment_descriptors* gdt_entry) +{ + return (void*)(gdt_entry->base_address_15_0 | + (gdt_entry->base_address_23_16<<16) | + (gdt_entry->base_address_31_24<<24)); +} + +/** + * @brief Extracts limit in bytes from GDT entry pointed to by \p gdt_entry + * + * @param[in] gdt_entry pointer to entry from which limit should be retrieved + * @retval limit value in bytes from GDT entry + */ +extern uint32_t i386_limit_gdt_entry (segment_descriptors* gdt_entry); + +/* + * See page 11.18 Figure 11-12. + * + */ + +typedef struct { + unsigned int offset : 12; + unsigned int page : 10; + unsigned int directory : 10; +}la_bits; + +typedef union { + la_bits bits; + unsigned int address; +}linear_address; + + +/* + * See page 11.20 Figure 11-14. + * + */ + +typedef struct { + unsigned int present : 1; + unsigned int writable : 1; + unsigned int user : 1; + unsigned int write_through : 1; + unsigned int cache_disable : 1; + unsigned int accessed : 1; + unsigned int reserved1 : 1; + unsigned int page_size : 1; + unsigned int reserved2 : 1; + unsigned int available : 3; + unsigned int page_frame_address : 20; +}page_dir_bits; + +typedef union { + page_dir_bits bits; + unsigned int dir_entry; +}page_dir_entry; + +typedef struct { + unsigned int present : 1; + unsigned int writable : 1; + unsigned int user : 1; + unsigned int write_through : 1; + unsigned int cache_disable : 1; + unsigned int accessed : 1; + unsigned int dirty : 1; + unsigned int reserved2 : 2; + unsigned int available : 3; + unsigned int page_frame_address : 20; +}page_table_bits; + +typedef union { + page_table_bits bits; + unsigned int table_entry; +} page_table_entry; + +/* + * definitions related to page table entry + */ +#define PG_SIZE 0x1000 +#define MASK_OFFSET 0xFFF +#define MAX_ENTRY (PG_SIZE/sizeof(page_dir_entry)) +#define FOUR_MB 0x400000 +#define MASK_FLAGS 0x1A + +#define PTE_PRESENT 0x01 +#define PTE_WRITABLE 0x02 +#define PTE_USER 0x04 +#define PTE_WRITE_THROUGH 0x08 +#define PTE_CACHE_DISABLE 0x10 + +typedef struct { + page_dir_entry pageDirEntry[MAX_ENTRY]; +} page_directory; + +typedef struct { + page_table_entry pageTableEntry[MAX_ENTRY]; +} page_table; + +/* Simpler names for the i80x86 I/O instructions */ +#define outport_byte( _port, _value ) i386_outport_byte( _port, _value ) +#define outport_word( _port, _value ) i386_outport_word( _port, _value ) +#define outport_long( _port, _value ) i386_outport_long( _port, _value ) +#define inport_byte( _port, _value ) i386_inport_byte( _port, _value ) +#define inport_word( _port, _value ) i386_inport_word( _port, _value ) +#define inport_long( _port, _value ) i386_inport_long( _port, _value ) + +#ifdef __cplusplus +} +#endif + +#endif /* !ASM */ + +#endif diff --git a/cpukit/score/cpu/i386/include/rtems/score/idtr.h b/cpukit/score/cpu/i386/include/rtems/score/idtr.h new file mode 100644 index 0000000000..a79af40792 --- /dev/null +++ b/cpukit/score/cpu/i386/include/rtems/score/idtr.h @@ -0,0 +1,66 @@ +/** + * @file + * + * @brief Intel I386 Data Structures + * + * This file contains definitions for data structure related + * to Intel system programming. More information can be found + * on Intel site and more precisely in the following book : + * + * Pentium Processor familly + * Developper's Manual + * + * Volume 3 : Architecture and Programming Manual + * + * Formerly contained in and extracted from libcpu/i386/cpu.h. + */ + +/* + * COPYRIGHT (C) 1998 Eric Valette (valette@crf.canon.fr) + * Canon Centre Recherche France. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + * Applications must not include this file directly. + */ + +#ifndef _RTEMS_SCORE_IDTR_H +#define _RTEMS_SCORE_IDTR_H + +/* + * See page 14.9 Figure 14-2. + * + */ +typedef struct +{ + unsigned int low_offsets_bits:16; + unsigned int segment_selector:16; + unsigned int fixed_value_bits:8; + unsigned int gate_type:5; + unsigned int privilege:2; + unsigned int present:1; + unsigned int high_offsets_bits:16; +} interrupt_gate_descriptor; + +/* + * C callable function enabling to create a interrupt_gate_descriptor + */ +extern void create_interrupt_gate_descriptor (interrupt_gate_descriptor*, rtems_raw_irq_hdl); + +/* + * C callable function enabling to get easily usable info from + * the actual value of IDT register. + */ +extern void i386_get_info_from_IDTR (interrupt_gate_descriptor** table, + unsigned* limit); + +/* + * C callable function enabling to change the value of IDT register. Must be called + * with interrupts masked at processor level!!!. + */ +extern void i386_set_IDTR (interrupt_gate_descriptor* table, + unsigned limit); + +#endif diff --git a/cpukit/score/cpu/i386/include/rtems/score/interrupts.h b/cpukit/score/cpu/i386/include/rtems/score/interrupts.h new file mode 100644 index 0000000000..3a7971c1ff --- /dev/null +++ b/cpukit/score/cpu/i386/include/rtems/score/interrupts.h @@ -0,0 +1,85 @@ +/** + * @file + * + * @brief Intel I386 Interrupt Macros + * + * Formerly contained in and extracted from libcpu/i386/cpu.h + */ + +/* + * COPYRIGHT (c) 1998 valette@crf.canon.fr + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + * Applications must not include this file directly. + */ + +#ifndef _RTEMS_SCORE_INTERRUPTS_H +#define _RTEMS_SCORE_INTERRUPTS_H + +#ifndef ASM + +struct __rtems_raw_irq_connect_data__; + +typedef void (*rtems_raw_irq_hdl) (void); +typedef void (*rtems_raw_irq_enable) (const struct __rtems_raw_irq_connect_data__*); +typedef void (*rtems_raw_irq_disable) (const struct __rtems_raw_irq_connect_data__*); +typedef int (*rtems_raw_irq_is_enabled) (const struct __rtems_raw_irq_connect_data__*); + +/** + * @name Interrupt Level Macros + * + */ +/**@{**/ +#if !defined(RTEMS_PARAVIRT) +#define i386_disable_interrupts( _level ) \ + { \ + __asm__ volatile ( "pushf ; \ + cli ; \ + pop %0" \ + : "=rm" ((_level)) \ + ); \ + } + +#define i386_enable_interrupts( _level ) \ + { \ + __asm__ volatile ( "push %0 ; \ + popf" \ + : : "rm" ((_level)) : "cc" \ + ); \ + } + +#define i386_flash_interrupts( _level ) \ + { \ + __asm__ volatile ( "push %0 ; \ + popf ; \ + cli" \ + : : "rm" ((_level)) : "cc" \ + ); \ + } + +#define i386_get_interrupt_level( _level ) \ + do { \ + register uint32_t _eflags; \ + \ + __asm__ volatile ( "pushf ; \ + pop %0" \ + : "=rm" ((_eflags)) \ + ); \ + \ + _level = (_eflags & EFLAGS_INTR_ENABLE) ? 0 : 1; \ + } while (0) +#else +uint32_t i386_disable_interrupts( void ); +void i386_enable_interrupts(uint32_t level); +void i386_flash_interrupts(uint32_t level); +void i386_set_interrupt_level(uint32_t new_level); +uint32_t i386_get_interrupt_level( void ); +#endif /* PARAVIRT */ + +/** @} */ + +#endif +#endif diff --git a/cpukit/score/cpu/i386/include/rtems/score/registers.h b/cpukit/score/cpu/i386/include/rtems/score/registers.h new file mode 100644 index 0000000000..254fef701b --- /dev/null +++ b/cpukit/score/cpu/i386/include/rtems/score/registers.h @@ -0,0 +1,72 @@ +/** + * @file + * + * @brief Intel CPU Constants and Definitions + * + * This file contains definition and constants related to Intel Cpu + */ + +/* + * COPYRIGHT (c) 1998 valette@crf.canon.fr + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_REGISTERS_H +#define _RTEMS_SCORE_REGISTERS_H + +/* + * definition related to EFLAGS + */ +#define EFLAGS_CARRY 0x1 +#define EFLAGS_PARITY 0x4 + +#define EFLAGS_AUX_CARRY 0x10 +#define EFLAGS_ZERO 0x40 +#define EFLAGS_SIGN 0x80 + +#define EFLAGS_TRAP 0x100 +#define EFLAGS_INTR_ENABLE 0x200 +#define EFLAGS_DIRECTION 0x400 +#define EFLAGS_OVERFLOW 0x800 + +#define EFLAGS_IOPL_MASK 0x3000 +#define EFLAGS_NESTED_TASK 0x8000 + +#define EFLAGS_RESUME 0x10000 +#define EFLAGS_VIRTUAL_MODE 0x20000 +#define EFLAGS_ALIGN_CHECK 0x40000 +#define EFLAGS_VIRTUAL_INTR 0x80000 + +#define EFLAGS_VIRTUAL_INTR_PEND 0x100000 +#define EFLAGS_ID 0x200000 + +/* + * definitions related to CR0 + */ +#define CR0_PROTECTION_ENABLE 0x1 +#define CR0_MONITOR_COPROC 0x2 +#define CR0_COPROC_SOFT_EMUL 0x4 +#define CR0_FLOATING_INSTR_EXCEPTION 0x8 + +#define CR0_EXTENSION_TYPE 0x10 +#define CR0_NUMERIC_ERROR 0x20 + +#define CR0_WRITE_PROTECT 0x10000 +#define CR0_ALIGMENT_MASK 0x40000 + +#define CR0_NO_WRITE_THROUGH 0x20000000 +#define CR0_PAGE_LEVEL_CACHE_DISABLE 0x40000000 +#define CR0_PAGING 0x80000000 + +/* + * definitions related to CR3 + */ + +#define CR3_PAGE_CACHE_DISABLE 0x10 +#define CR3_PAGE_WRITE_THROUGH 0x8 +#define CR3_PAGE_DIRECTORY_MASK 0xFFFFF000 + +#endif diff --git a/cpukit/score/cpu/i386/include/rtems/score/types.h b/cpukit/score/cpu/i386/include/rtems/score/types.h new file mode 100644 index 0000000000..00555d41b5 --- /dev/null +++ b/cpukit/score/cpu/i386/include/rtems/score/types.h @@ -0,0 +1,46 @@ +/** + * @file + * + * @brief Intel I386 CPU Type Definitions + * + * This include file contains type definitions pertaining to the Intel + * i386 processor family. + */ + +/* + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_TYPES_H +#define _RTEMS_SCORE_TYPES_H + +#include + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This section defines the basic types for this processor. + */ + +/** Type that can store a 32-bit integer or a pointer. */ +typedef uintptr_t CPU_Uint32ptr; + +typedef void i386_isr; +typedef i386_isr ( *i386_isr_entry )( void ); + +#ifdef __cplusplus +} +#endif + +#endif /* !ASM */ + +#endif diff --git a/cpukit/score/cpu/i386/preinstall.am b/cpukit/score/cpu/i386/preinstall.am deleted file mode 100644 index 6eda753836..0000000000 --- a/cpukit/score/cpu/i386/preinstall.am +++ /dev/null @@ -1,61 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -$(PROJECT_INCLUDE)/rtems/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems - @: > $(PROJECT_INCLUDE)/rtems/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/asm.h: rtems/asm.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/asm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/asm.h - -$(PROJECT_INCLUDE)/rtems/score/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/score - @: > $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/score/cpu.h: rtems/score/cpu.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpu.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpu.h - -$(PROJECT_INCLUDE)/rtems/score/cpuimpl.h: rtems/score/cpuimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h - -$(PROJECT_INCLUDE)/rtems/score/i386.h: rtems/score/i386.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/i386.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/i386.h - -$(PROJECT_INCLUDE)/rtems/score/types.h: rtems/score/types.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/types.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/types.h - -$(PROJECT_INCLUDE)/rtems/score/interrupts.h: rtems/score/interrupts.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/interrupts.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/interrupts.h - -$(PROJECT_INCLUDE)/rtems/score/registers.h: rtems/score/registers.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/registers.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/registers.h - -$(PROJECT_INCLUDE)/rtems/score/idtr.h: rtems/score/idtr.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/idtr.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/idtr.h - -$(PROJECT_INCLUDE)/rtems/score/cpuatomic.h: rtems/score/cpuatomic.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h - diff --git a/cpukit/score/cpu/i386/rtems/asm.h b/cpukit/score/cpu/i386/rtems/asm.h deleted file mode 100644 index 50b0fd71a0..0000000000 --- a/cpukit/score/cpu/i386/rtems/asm.h +++ /dev/null @@ -1,140 +0,0 @@ -/** - * @file - * - * @brief Address the Problems Caused by Incompatible Flavor of - * Assemblers and Toolsets - * - * This include file attempts to address the problems - * caused by incompatible flavors of assemblers and - * toolsets. It primarily addresses variations in the - * use of leading underscores on symbols and the requirement - * that register names be preceded by a %. - * - * NOTE: The spacing in the use of these macros - * is critical to them working as advertised. - */ - -/* - * COPYRIGHT: - * - * This file is based on similar code found in newlib available - * from ftp.cygnus.com. The file which was used had no copyright - * notice. This file is freely distributable as long as the source - * of the file is noted. This file is: - * - * COPYRIGHT (c) 1994-1997. - * On-Line Applications Research Corporation (OAR). - */ - -#ifndef _RTEMS_ASM_H -#define _RTEMS_ASM_H - -/* - * Indicate we are in an assembly file and get the basic CPU definitions. - */ - -#ifndef ASM -#define ASM -#endif -#include -#include - -/* - * Recent versions of GNU cpp define variables which indicate the - * need for underscores and percents. If not using GNU cpp or - * the version does not support this, then you will obviously - * have to define these as appropriate. - */ - -#ifndef __USER_LABEL_PREFIX__ -#define __USER_LABEL_PREFIX__ -#endif - -/* - * Looks like there is a bug in gcc 2.6.2 where this is not - * defined correctly when configured as i386-coff and - * i386-aout. - */ - -#undef __REGISTER_PREFIX__ -#define __REGISTER_PREFIX__ % - -/* -#ifndef __REGISTER_PREFIX__ -#define __REGISTER_PREFIX__ -#endif -*/ - -#include - -/* Use the right prefix for global labels. */ - -#define SYM(x) CONCAT0 (__USER_LABEL_PREFIX__, x) - -/* Use the right prefix for registers. */ - -#define REG(x) CONCAT0 (__REGISTER_PREFIX__, x) - -#define eax REG (eax) -#define ebx REG (ebx) -#define ecx REG (ecx) -#define edx REG (edx) -#define esi REG (esi) -#define edi REG (edi) -#define esp REG (esp) -#define ebp REG (ebp) -#define cr0 REG (cr0) -#define cr4 REG (cr4) - -#define ax REG (ax) -#define bx REG (bx) -#define cx REG (cx) -#define dx REG (dx) -#define si REG (si) -#define di REG (di) -#define sp REG (sp) -#define bp REG (bp) - -#define ah REG (ah) -#define bh REG (bh) -#define ch REG (ch) -#define dh REG (dh) - -#define al REG (al) -#define bl REG (bl) -#define cl REG (cl) -#define dl REG (dl) - -#define cs REG (cs) -#define ds REG (ds) -#define es REG (es) -#define fs REG (fs) -#define gs REG (gs) -#define ss REG (ss) - -/* - * Define macros to handle section beginning and ends. - */ - - -#define BEGIN_CODE_DCL .text -#define END_CODE_DCL -#define BEGIN_DATA_DCL .data -#define END_DATA_DCL -#define BEGIN_CODE .text -#define END_CODE -#define BEGIN_DATA .data -#define END_DATA -#define BEGIN_BSS .bss -#define END_BSS -#define END - -/* - * Following must be tailor for a particular flavor of the C compiler. - * They may need to put underscores in front of the symbols. - */ - -#define PUBLIC(sym) .globl SYM (sym) -#define EXTERN(sym) .globl SYM (sym) - -#endif diff --git a/cpukit/score/cpu/i386/rtems/score/cpu.h b/cpukit/score/cpu/i386/rtems/score/cpu.h deleted file mode 100644 index f78149c24b..0000000000 --- a/cpukit/score/cpu/i386/rtems/score/cpu.h +++ /dev/null @@ -1,700 +0,0 @@ -/** - * @file - * - * @brief Intel I386 CPU Dependent Source - * - * This include file contains information pertaining to the Intel - * i386 processor. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPU_H -#define _RTEMS_SCORE_CPU_H - -#ifndef ASM -#include /* for memcpy */ -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/* conditional compilation parameters */ - -/* - * Does the CPU follow the simple vectored interrupt model? - * - * If TRUE, then RTEMS allocates the vector table it internally manages. - * If FALSE, then the BSP is assumed to allocate and manage the vector - * table - * - * PowerPC Specific Information: - * - * The PowerPC and x86 were the first to use the PIC interrupt model. - * They do not use the simple vectored interrupt model. - */ -#define CPU_SIMPLE_VECTORED_INTERRUPTS FALSE - -/* - * i386 has an RTEMS allocated and managed interrupt stack. - */ - -#define CPU_HAS_SOFTWARE_INTERRUPT_STACK TRUE -#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE -#define CPU_ALLOCATE_INTERRUPT_STACK TRUE - -/* - * Does the RTEMS invoke the user's ISR with the vector number and - * a pointer to the saved interrupt frame (1) or just the vector - * number (0)? - */ - -#define CPU_ISR_PASSES_FRAME_POINTER FALSE - -/* - * Some family members have no FP, some have an FPU such as the i387 - * for the i386, others have it built in (i486DX, Pentium). - */ - -#ifdef __SSE__ -#define CPU_HARDWARE_FP TRUE -#define CPU_SOFTWARE_FP FALSE - -#define CPU_ALL_TASKS_ARE_FP TRUE -#define CPU_IDLE_TASK_IS_FP TRUE -#define CPU_USE_DEFERRED_FP_SWITCH FALSE -#else /* __SSE__ */ - -#if ( I386_HAS_FPU == 1 ) -#define CPU_HARDWARE_FP TRUE /* i387 for i386 */ -#else -#define CPU_HARDWARE_FP FALSE -#endif -#define CPU_SOFTWARE_FP FALSE - -#define CPU_ALL_TASKS_ARE_FP FALSE -#define CPU_IDLE_TASK_IS_FP FALSE -#if defined(RTEMS_SMP) - #define CPU_USE_DEFERRED_FP_SWITCH FALSE -#else - #define CPU_USE_DEFERRED_FP_SWITCH TRUE -#endif -#endif /* __SSE__ */ - -#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE - -#define CPU_STACK_GROWS_UP FALSE - -/* FIXME: The Pentium 4 used 128 bytes, it this processor still relevant? */ -#define CPU_CACHE_LINE_BYTES 64 - -#define CPU_STRUCTURE_ALIGNMENT - -/* - * Does this port provide a CPU dependent IDLE task implementation? - * - * If TRUE, then the routine _CPU_Thread_Idle_body - * must be provided and is the default IDLE thread body instead of - * _CPU_Thread_Idle_body. - * - * If FALSE, then use the generic IDLE thread body if the BSP does - * not provide one. - */ - -#define CPU_PROVIDES_IDLE_THREAD_BODY FALSE - -#define CPU_MAXIMUM_PROCESSORS 32 - -#define I386_CONTEXT_CONTROL_EFLAGS_OFFSET 0 -#define I386_CONTEXT_CONTROL_ESP_OFFSET 4 -#define I386_CONTEXT_CONTROL_EBP_OFFSET 8 -#define I386_CONTEXT_CONTROL_EBX_OFFSET 12 -#define I386_CONTEXT_CONTROL_ESI_OFFSET 16 -#define I386_CONTEXT_CONTROL_EDI_OFFSET 20 -#define I386_CONTEXT_CONTROL_GS_0_OFFSET 24 -#define I386_CONTEXT_CONTROL_GS_1_OFFSET 28 - -#ifdef RTEMS_SMP - #define I386_CONTEXT_CONTROL_IS_EXECUTING_OFFSET 32 -#endif - -/* structures */ - -#ifndef ASM - -/* - * Basic integer context for the i386 family. - */ - -typedef struct { - uint32_t eflags; /* extended flags register */ - void *esp; /* extended stack pointer register */ - void *ebp; /* extended base pointer register */ - uint32_t ebx; /* extended bx register */ - uint32_t esi; /* extended source index register */ - uint32_t edi; /* extended destination index flags register */ - segment_descriptors gs; /* gs segment descriptor */ -#ifdef RTEMS_SMP - volatile bool is_executing; -#endif -} Context_Control; - -#define _CPU_Context_Get_SP( _context ) \ - (_context)->esp - -#ifdef RTEMS_SMP - static inline bool _CPU_Context_Get_is_executing( - const Context_Control *context - ) - { - return context->is_executing; - } - - static inline void _CPU_Context_Set_is_executing( - Context_Control *context, - bool is_executing - ) - { - context->is_executing = is_executing; - } -#endif - -/* - * FP context save area for the i387 numeric coprocessors. - */ -#ifdef __SSE__ -/* All FPU and SSE registers are volatile; hence, as long - * as we are within normally executing C code (including - * a task switch) there is no need for saving/restoring - * any of those registers. - * We must save/restore the full FPU/SSE context across - * interrupts and exceptions, however: - * - after ISR execution a _Thread_Dispatch() may happen - * and it is therefore necessary to save the FPU/SSE - * registers to be restored when control is returned - * to the interrupted task. - * - gcc may implicitly use FPU/SSE instructions in - * an ISR. - * - * Even though there is no explicit mentioning of the FPU - * control word in the SYSV ABI (i386) being non-volatile - * we maintain MXCSR and the FPU control-word for each task. - */ -typedef struct { - uint32_t mxcsr; - uint16_t fpucw; -} Context_Control_fp; - -#else - -typedef struct { - uint8_t fp_save_area[108]; /* context size area for I80387 */ - /* 28 bytes for environment */ -} Context_Control_fp; - -#endif - - -/* - * The following structure defines the set of information saved - * on the current stack by RTEMS upon receipt of execptions. - * - * idtIndex is either the interrupt number or the trap/exception number. - * faultCode is the code pushed by the processor on some exceptions. - * - * Since the first registers are directly pushed by the CPU they - * may not respect 16-byte stack alignment, which is, however, - * mandatory for the SSE register area. - * Therefore, these registers are stored at an aligned address - * and a pointer is stored in the CPU_Exception_frame. - * If the executive was compiled without SSE support then - * this pointer is NULL. - */ - -struct Context_Control_sse; - -typedef struct { - struct Context_Control_sse *fp_ctxt; - uint32_t edi; - uint32_t esi; - uint32_t ebp; - uint32_t esp0; - uint32_t ebx; - uint32_t edx; - uint32_t ecx; - uint32_t eax; - uint32_t idtIndex; - uint32_t faultCode; - uint32_t eip; - uint32_t cs; - uint32_t eflags; -} CPU_Exception_frame; - -#ifdef __SSE__ -typedef struct Context_Control_sse { - uint16_t fcw; - uint16_t fsw; - uint8_t ftw; - uint8_t res_1; - uint16_t fop; - uint32_t fpu_ip; - uint16_t cs; - uint16_t res_2; - uint32_t fpu_dp; - uint16_t ds; - uint16_t res_3; - uint32_t mxcsr; - uint32_t mxcsr_mask; - struct { - uint8_t fpreg[10]; - uint8_t res_4[ 6]; - } fp_mmregs[8]; - uint8_t xmmregs[8][16]; - uint8_t res_5[224]; -} Context_Control_sse -__attribute__((aligned(16))) -; -#endif - -typedef void (*cpuExcHandlerType) (CPU_Exception_frame*); -extern cpuExcHandlerType _currentExcHandler; -extern void rtems_exception_init_mngt(void); - -/* - * This port does not pass any frame info to the - * interrupt handler. - */ - -typedef void CPU_Interrupt_frame; - -typedef enum { - I386_EXCEPTION_DIVIDE_BY_ZERO = 0, - I386_EXCEPTION_DEBUG = 1, - I386_EXCEPTION_NMI = 2, - I386_EXCEPTION_BREAKPOINT = 3, - I386_EXCEPTION_OVERFLOW = 4, - I386_EXCEPTION_BOUND = 5, - I386_EXCEPTION_ILLEGAL_INSTR = 6, - I386_EXCEPTION_MATH_COPROC_UNAVAIL = 7, - I386_EXCEPTION_DOUBLE_FAULT = 8, - I386_EXCEPTION_I386_COPROC_SEG_ERR = 9, - I386_EXCEPTION_INVALID_TSS = 10, - I386_EXCEPTION_SEGMENT_NOT_PRESENT = 11, - I386_EXCEPTION_STACK_SEGMENT_FAULT = 12, - I386_EXCEPTION_GENERAL_PROT_ERR = 13, - I386_EXCEPTION_PAGE_FAULT = 14, - I386_EXCEPTION_INTEL_RES15 = 15, - I386_EXCEPTION_FLOAT_ERROR = 16, - I386_EXCEPTION_ALIGN_CHECK = 17, - I386_EXCEPTION_MACHINE_CHECK = 18, - I386_EXCEPTION_ENTER_RDBG = 50 /* to enter manually RDBG */ - -} Intel_symbolic_exception_name; - - -/* - * context size area for floating point - * - * NOTE: This is out of place on the i386 to avoid a forward reference. - */ - -#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp ) - -/* variables */ - -extern Context_Control_fp _CPU_Null_fp_context; - -#endif /* ASM */ - -/* constants */ - -/* - * This defines the number of levels and the mask used to pick those - * bits out of a thread mode. - */ - -#define CPU_MODES_INTERRUPT_LEVEL 0x00000001 /* interrupt level in mode */ -#define CPU_MODES_INTERRUPT_MASK 0x00000001 /* interrupt level in mode */ - -/* - * extra stack required by the MPCI receive server thread - */ - -#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 1024 - -/* - * This is defined if the port has a special way to report the ISR nesting - * level. Most ports maintain the variable _ISR_Nest_level. - */ - -#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE - -/* - * Minimum size of a thread's stack. - */ - -#define CPU_STACK_MINIMUM_SIZE 4096 - -#define CPU_SIZEOF_POINTER 4 - -/* - * i386 is pretty tolerant of alignment. Just put things on 4 byte boundaries. - */ - -#define CPU_ALIGNMENT 4 -#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT -#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT - -/* - * On i386 thread stacks require no further alignment after allocation - * from the Workspace. However, since gcc maintains 16-byte alignment - * we try to respect that. If you find an option to let gcc squeeze - * the stack more tightly then setting CPU_STACK_ALIGNMENT to 16 still - * doesn't waste much space since this only determines the *initial* - * alignment. - */ - -#define CPU_STACK_ALIGNMENT 16 - -/* macros */ - -#ifndef ASM -/* - * ISR handler macros - * - * These macros perform the following functions: - * + initialize the RTEMS vector table - * + disable all maskable CPU interrupts - * + restore previous interrupt level (enable) - * + temporarily restore interrupts (flash) - * + set a particular level - */ - -#if !defined(RTEMS_PARAVIRT) -#define _CPU_ISR_Disable( _level ) i386_disable_interrupts( _level ) - -#define _CPU_ISR_Enable( _level ) i386_enable_interrupts( _level ) - -#define _CPU_ISR_Flash( _level ) i386_flash_interrupts( _level ) - -#define _CPU_ISR_Set_level( _new_level ) \ - { \ - if ( _new_level ) __asm__ volatile ( "cli" ); \ - else __asm__ volatile ( "sti" ); \ - } -#else -#define _CPU_ISR_Disable( _level ) _level = i386_disable_interrupts() -#define _CPU_ISR_Enable( _level ) i386_enable_interrupts( _level ) -#define _CPU_ISR_Flash( _level ) i386_flash_interrupts( _level ) -#define _CPU_ISR_Set_level( _new_level ) i386_set_interrupt_level(_new_level) -#endif - -RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) -{ - return ( level & EFLAGS_INTR_ENABLE ) != 0; -} - -uint32_t _CPU_ISR_Get_level( void ); - -/* Make sure interrupt stack has space for ISR - * 'vector' arg at the top and that it is aligned - * properly. - */ - -#define _CPU_Interrupt_stack_setup( _lo, _hi ) \ - do { \ - _hi = (void*)(((uintptr_t)(_hi) - 4) & ~ (CPU_STACK_ALIGNMENT - 1)); \ - } while (0) - -#endif /* ASM */ - -/* end of ISR handler macros */ - -/* - * Context handler macros - * - * These macros perform the following functions: - * + initialize a context area - * + restart the current thread - * + calculate the initial pointer into a FP context area - * + initialize an FP context area - */ - -#define CPU_EFLAGS_INTERRUPTS_ON 0x00003202 -#define CPU_EFLAGS_INTERRUPTS_OFF 0x00003002 - -#ifndef ASM - -void _CPU_Context_Initialize( - Context_Control *the_context, - void *stack_area_begin, - size_t stack_area_size, - uint32_t new_level, - void (*entry_point)( void ), - bool is_fp, - void *tls_area -); - -#define _CPU_Context_Restart_self( _the_context ) \ - _CPU_Context_restore( (_the_context) ); - -#if defined(RTEMS_SMP) - uint32_t _CPU_SMP_Initialize( void ); - - bool _CPU_SMP_Start_processor( uint32_t cpu_index ); - - void _CPU_SMP_Finalize_initialization( uint32_t cpu_count ); - - /* Nothing to do */ - #define _CPU_SMP_Prepare_start_multitasking() do { } while ( 0 ) - - uint32_t _CPU_SMP_Get_current_processor( void ); - - void _CPU_SMP_Send_interrupt( uint32_t target_processor_index ); - - static inline void _CPU_SMP_Processor_event_broadcast( void ) - { - __asm__ volatile ( "" : : : "memory" ); - } - - static inline void _CPU_SMP_Processor_event_receive( void ) - { - __asm__ volatile ( "" : : : "memory" ); - } -#endif - -#define _CPU_Context_Initialize_fp( _fp_area ) \ - { \ - memcpy( *_fp_area, &_CPU_Null_fp_context, CPU_CONTEXT_FP_SIZE ); \ - } - -/* end of Context handler macros */ - -/* - * Fatal Error manager macros - * - * These macros perform the following functions: - * + disable interrupts and halt the CPU - */ - -extern void _CPU_Fatal_halt(uint32_t source, uint32_t error) - RTEMS_NO_RETURN; - -#endif /* ASM */ - -/* end of Fatal Error manager macros */ - -/* - * Bitfield handler macros - * - * These macros perform the following functions: - * + scan for the highest numbered (MSB) set in a 16 bit bitfield - */ - -#define CPU_USE_GENERIC_BITFIELD_CODE FALSE - -#define _CPU_Bitfield_Find_first_bit( _value, _output ) \ - { \ - register uint16_t __value_in_register = ( _value ); \ - uint16_t __output = 0; \ - __asm__ volatile ( "bsfw %0,%1 " \ - : "=r" ( __value_in_register ), "=r" ( __output ) \ - : "0" ( __value_in_register ), "1" ( __output ) \ - ); \ - ( _output ) = __output; \ - } - -/* end of Bitfield handler macros */ - -/* - * Priority handler macros - * - * These macros perform the following functions: - * + return a mask with the bit for this major/minor portion of - * of thread priority set. - * + translate the bit number returned by "Bitfield_find_first_bit" - * into an index into the thread ready chain bit maps - */ - -#define _CPU_Priority_Mask( _bit_number ) \ - ( 1 << (_bit_number) ) - -#define _CPU_Priority_bits_index( _priority ) \ - (_priority) - -/* functions */ - -#ifndef ASM -/* - * _CPU_Initialize - * - * This routine performs CPU dependent initialization. - */ - -void _CPU_Initialize(void); - -/* - * _CPU_ISR_install_raw_handler - * - * This routine installs a "raw" interrupt handler directly into the - * processor's vector table. - */ - -void _CPU_ISR_install_raw_handler( - uint32_t vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -/* - * _CPU_ISR_install_vector - * - * This routine installs an interrupt vector. - */ - -void _CPU_ISR_install_vector( - uint32_t vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -/* - * _CPU_Thread_Idle_body - * - * Use the halt instruction of low power mode of a particular i386 model. - */ - -#if (CPU_PROVIDES_IDLE_THREAD_BODY == TRUE) - -void *_CPU_Thread_Idle_body( uintptr_t ignored ); - -#endif /* CPU_PROVIDES_IDLE_THREAD_BODY */ - -/* - * _CPU_Context_switch - * - * This routine switches from the run context to the heir context. - */ - -void _CPU_Context_switch( - Context_Control *run, - Context_Control *heir -); - -/* - * _CPU_Context_restore - * - * This routine is generally used only to restart self in an - * efficient manner and avoid stack conflicts. - */ - -void _CPU_Context_restore( - Context_Control *new_context -) RTEMS_NO_RETURN; - -/* - * _CPU_Context_save_fp - * - * This routine saves the floating point context passed to it. - */ - -#ifdef __SSE__ -#define _CPU_Context_save_fp(fp_context_pp) \ - do { \ - __asm__ __volatile__( \ - "fstcw %0" \ - :"=m"((*(fp_context_pp))->fpucw) \ - ); \ - __asm__ __volatile__( \ - "stmxcsr %0" \ - :"=m"((*(fp_context_pp))->mxcsr) \ - ); \ - } while (0) -#else -void _CPU_Context_save_fp( - Context_Control_fp **fp_context_ptr -); -#endif - -/* - * _CPU_Context_restore_fp - * - * This routine restores the floating point context passed to it. - */ -#ifdef __SSE__ -#define _CPU_Context_restore_fp(fp_context_pp) \ - do { \ - __asm__ __volatile__( \ - "fldcw %0" \ - ::"m"((*(fp_context_pp))->fpucw) \ - :"fpcr" \ - ); \ - __builtin_ia32_ldmxcsr(_Thread_Executing->fp_context->mxcsr); \ - } while (0) -#else -void _CPU_Context_restore_fp( - Context_Control_fp **fp_context_ptr -); -#endif - -#ifdef __SSE__ -#define _CPU_Context_Initialization_at_thread_begin() \ - do { \ - __asm__ __volatile__( \ - "finit" \ - : \ - : \ - :"st","st(1)","st(2)","st(3)", \ - "st(4)","st(5)","st(6)","st(7)", \ - "fpsr","fpcr" \ - ); \ - if ( _Thread_Executing->fp_context ) { \ - _CPU_Context_restore_fp(&_Thread_Executing->fp_context); \ - } \ - } while (0) -#endif - -static inline void _CPU_Context_volatile_clobber( uintptr_t pattern ) -{ - /* TODO */ -} - -static inline void _CPU_Context_validate( uintptr_t pattern ) -{ - while (1) { - /* TODO */ - } -} - -void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); - -typedef uint32_t CPU_Counter_ticks; - -CPU_Counter_ticks _CPU_Counter_read( void ); - -static inline CPU_Counter_ticks _CPU_Counter_difference( - CPU_Counter_ticks second, - CPU_Counter_ticks first -) -{ - return second - first; -} - -#endif /* ASM */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/score/cpu/i386/rtems/score/cpuatomic.h b/cpukit/score/cpu/i386/rtems/score/cpuatomic.h deleted file mode 100644 index 598ee76b20..0000000000 --- a/cpukit/score/cpu/i386/rtems/score/cpuatomic.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * COPYRIGHT (c) 2012-2013 Deng Hengyi. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_ATOMIC_CPU_H -#define _RTEMS_SCORE_ATOMIC_CPU_H - -#include - -#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/i386/rtems/score/cpuimpl.h b/cpukit/score/cpu/i386/rtems/score/cpuimpl.h deleted file mode 100644 index 789f2badd9..0000000000 --- a/cpukit/score/cpu/i386/rtems/score/cpuimpl.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @file - * - * @brief CPU Port Implementation API - */ - -/* - * Copyright (c) 2013 embedded brains GmbH - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPUIMPL_H -#define _RTEMS_SCORE_CPUIMPL_H - -#include - -#define CPU_PER_CPU_CONTROL_SIZE 0 - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* ASM */ - -#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/i386/rtems/score/i386.h b/cpukit/score/cpu/i386/rtems/score/i386.h deleted file mode 100644 index 2555d13b8b..0000000000 --- a/cpukit/score/cpu/i386/rtems/score/i386.h +++ /dev/null @@ -1,670 +0,0 @@ -/** - * @file - * - * @brief Intel I386 CPU Dependent Source - * - * This include file contains information pertaining to the Intel - * i386 processor. - */ - -/* - * COPYRIGHT (c) 1989-2016. - * On-Line Applications Research Corporation (OAR). - * - * Copyright (C) 1998 Eric Valette (valette@crf.canon.fr) - * Canon Centre Recherche France. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_I386_H -#define _RTEMS_SCORE_I386_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/* - * This section contains the information required to build - * RTEMS for a particular member of the Intel i386 - * family when executing in protected mode. It does - * this by setting variables to indicate which implementation - * dependent features are present in a particular member - * of the family. - * - * Currently recognized: - * i386_fp (i386 DX or SX w/i387) - * i486dx - * pentium - * pentiumpro - * - * CPU Model Feature Flags: - * - * I386_HAS_BSWAP: Defined to "1" if the instruction for endian swapping - * (bswap) should be used. This instruction appears to - * be present in all i486's and above. - * - * I386_HAS_FPU: Defined to "1" if the CPU has an FPU. - * As of at least gcc 4.7, i386 soft-float was obsoleted. - * Thus this is always set to "1". - */ -#define I386_HAS_FPU 1 - -#if defined(__pentiumpro__) - - #define CPU_MODEL_NAME "Pentium Pro" - -#elif defined(__i586__) - - #if defined(__pentium__) - #define CPU_MODEL_NAME "Pentium" - #elif defined(__k6__) - #define CPU_MODEL_NAME "K6" - #else - #define CPU_MODEL_NAME "i586" - #endif - -#elif defined(__i486__) - - #define CPU_MODEL_NAME "i486dx" - -#elif defined(__i386__) - - #define I386_HAS_BSWAP 0 - #define CPU_MODEL_NAME "i386 with i387" - -#else - #error "Unknown CPU Model" -#endif - -/* - * Set default values for CPU model feature flags - * - * NOTE: These settings are chosen to reflect most of the family members. - */ -#ifndef I386_HAS_BSWAP -#define I386_HAS_BSWAP 1 -#endif - -/* - * Define the name of the CPU family. - */ -#define CPU_NAME "Intel i386" - -#ifndef ASM - -/* - * The following routine swaps the endian format of an unsigned int. - * It must be static so it can be referenced indirectly. - */ - -static inline uint32_t i386_swap_u32( - uint32_t value -) -{ - uint32_t lout; - -#if (I386_HAS_BSWAP == 0) - __asm__ volatile( "rorw $8,%%ax;" - "rorl $16,%0;" - "rorw $8,%%ax" : "=a" (lout) : "0" (value) ); -#else - __asm__ volatile( "bswap %0" : "=r" (lout) : "0" (value)); -#endif - return( lout ); -} -#define CPU_swap_u32( _value ) i386_swap_u32( _value ) - -static inline uint16_t i386_swap_u16( - uint16_t value -) -{ - unsigned short sout; - - __asm__ volatile( "rorw $8,%0" : "=r" (sout) : "0" (value)); - return (sout); -} -#define CPU_swap_u16( _value ) i386_swap_u16( _value ) - -/* - * Added for pagination management - */ -static inline unsigned int i386_get_cr0(void) -{ - register unsigned int segment = 0; - - __asm__ volatile ( "movl %%cr0,%0" : "=r" (segment) : "0" (segment) ); - - return segment; -} - -static inline void i386_set_cr0(unsigned int segment) -{ - __asm__ volatile ( "movl %0,%%cr0" : "=r" (segment) : "0" (segment) ); -} - -static inline unsigned int i386_get_cr2(void) -{ - register unsigned int segment = 0; - - __asm__ volatile ( "movl %%cr2,%0" : "=r" (segment) : "0" (segment) ); - - return segment; -} - -static inline unsigned int i386_get_cr3(void) -{ - register unsigned int segment = 0; - - __asm__ volatile ( "movl %%cr3,%0" : "=r" (segment) : "0" (segment) ); - - return segment; -} - -static inline void i386_set_cr3(unsigned int segment) -{ - __asm__ volatile ( "movl %0,%%cr3" : "=r" (segment) : "0" (segment) ); -} - -/* routines */ - -/* - * i386_Logical_to_physical - * - * Converts logical address to physical address. - */ -void *i386_Logical_to_physical( - unsigned short segment, - void *address -); - -/* - * i386_Physical_to_logical - * - * Converts physical address to logical address. - */ -void *i386_Physical_to_logical( - unsigned short segment, - void *address -); - -/** - * @brief Converts real mode pointer {segment, offset} to physical address. - * - * i386_Real_to_physical - * - * @param[in] segment used with \p offset to compute physical address - * @param[in] offset used with \p segment to compute physical address - * @retval physical address - */ -RTEMS_INLINE_ROUTINE void *i386_Real_to_physical( - uint16_t segment, - uint16_t offset) -{ - return (void *)(((uint32_t)segment<<4)+offset); -} - -/** - * @brief Retrieves real mode pointer elements {segmnet, offset} from - * physical address. - * - * i386_Physical_to_real - * Function returns the highest segment (base) address possible. - * Example: input address - 0x4B3A2 - * output segment - 0x4B3A - * offset - 0x2 - * input address - 0x10F12E - * output segment - 0xFFFF - * offset - 0xF13E - * - * @param[in] address address to be converted, must be less than 0x10FFEF - * @param[out] segment segment computed from \p address - * @param[out] offset offset computed from \p address - * @retval 0 address not convertible - * @retval 1 segment and offset extracted - */ -int i386_Physical_to_real( - void *address, - uint16_t *segment, - uint16_t *offset -); - -/* - * Segment Access Routines - * - * NOTE: Unfortunately, these are still static inlines even when the - * "macro" implementation of the generic code is used. - */ - -static __inline__ unsigned short i386_get_cs(void) -{ - register unsigned short segment = 0; - - __asm__ volatile ( "movw %%cs,%0" : "=r" (segment) : "0" (segment) ); - - return segment; -} - -static __inline__ unsigned short i386_get_ds(void) -{ - register unsigned short segment = 0; - - __asm__ volatile ( "movw %%ds,%0" : "=r" (segment) : "0" (segment) ); - - return segment; -} - -static __inline__ unsigned short i386_get_es(void) -{ - register unsigned short segment = 0; - - __asm__ volatile ( "movw %%es,%0" : "=r" (segment) : "0" (segment) ); - - return segment; -} - -static __inline__ unsigned short i386_get_ss(void) -{ - register unsigned short segment = 0; - - __asm__ volatile ( "movw %%ss,%0" : "=r" (segment) : "0" (segment) ); - - return segment; -} - -static __inline__ unsigned short i386_get_fs(void) -{ - register unsigned short segment = 0; - - __asm__ volatile ( "movw %%fs,%0" : "=r" (segment) : "0" (segment) ); - - return segment; -} - -static __inline__ unsigned short i386_get_gs(void) -{ - register unsigned short segment = 0; - - __asm__ volatile ( "movw %%gs,%0" : "=r" (segment) : "0" (segment) ); - - return segment; -} - -/* - * IO Port Access Routines - */ - -#define i386_outport_byte( _port, _value ) \ -do { register unsigned short __port = _port; \ - register unsigned char __value = _value; \ - \ - __asm__ volatile ( "outb %0,%1" : : "a" (__value), "d" (__port) ); \ - } while (0) - -#define i386_outport_word( _port, _value ) \ -do { register unsigned short __port = _port; \ - register unsigned short __value = _value; \ - \ - __asm__ volatile ( "outw %0,%1" : : "a" (__value), "d" (__port) ); \ - } while (0) - -#define i386_outport_long( _port, _value ) \ -do { register unsigned short __port = _port; \ - register unsigned int __value = _value; \ - \ - __asm__ volatile ( "outl %0,%1" : : "a" (__value), "d" (__port) ); \ - } while (0) - -#define i386_inport_byte( _port, _value ) \ -do { register unsigned short __port = _port; \ - register unsigned char __value = 0; \ - \ - __asm__ volatile ( "inb %1,%0" : "=a" (__value) \ - : "d" (__port) \ - ); \ - _value = __value; \ - } while (0) - -#define i386_inport_word( _port, _value ) \ -do { register unsigned short __port = _port; \ - register unsigned short __value = 0; \ - \ - __asm__ volatile ( "inw %1,%0" : "=a" (__value) \ - : "d" (__port) \ - ); \ - _value = __value; \ - } while (0) - -#define i386_inport_long( _port, _value ) \ -do { register unsigned short __port = _port; \ - register unsigned int __value = 0; \ - \ - __asm__ volatile ( "inl %1,%0" : "=a" (__value) \ - : "d" (__port) \ - ); \ - _value = __value; \ - } while (0) - -/* - * Type definition for raw interrupts. - */ - -typedef unsigned char rtems_vector_offset; - -typedef struct __rtems_raw_irq_connect_data__{ - /* - * IDT vector offset (IRQ line + PC386_IRQ_VECTOR_BASE) - */ - rtems_vector_offset idtIndex; - /* - * IDT raw handler. See comment on handler properties below in function prototype. - */ - rtems_raw_irq_hdl hdl; - /* - * function for enabling raw interrupts. In order to be consistent - * with the fact that the raw connexion can defined in the - * libcpu library, this library should have no knowledge of - * board specific hardware to manage interrupts and thus the - * "on" routine must enable the irq both at device and PIC level. - * - */ - rtems_raw_irq_enable on; - /* - * function for disabling raw interrupts. In order to be consistent - * with the fact that the raw connexion can defined in the - * libcpu library, this library should have no knowledge of - * board specific hardware to manage interrupts and thus the - * "on" routine must disable the irq both at device and PIC level. - * - */ - rtems_raw_irq_disable off; - /* - * function enabling to know what interrupt may currently occur - */ - rtems_raw_irq_is_enabled isOn; -}rtems_raw_irq_connect_data; - -typedef struct { - /* - * size of all the table fields (*Tbl) described below. - */ - unsigned int idtSize; - /* - * Default handler used when disconnecting interrupts. - */ - rtems_raw_irq_connect_data defaultRawEntry; - /* - * Table containing initials/current value. - */ - rtems_raw_irq_connect_data* rawIrqHdlTbl; -}rtems_raw_irq_global_settings; - -#include - -/* - * C callable function enabling to get handler currently connected to a vector - * - */ -rtems_raw_irq_hdl get_hdl_from_vector(rtems_vector_offset); - -/* - * C callable function enabling to set up one raw idt entry - */ -extern int i386_set_idt_entry (const rtems_raw_irq_connect_data*); - -/* - * C callable function enabling to get one current raw idt entry - */ -extern int i386_get_current_idt_entry (rtems_raw_irq_connect_data*); - -/* - * C callable function enabling to remove one current raw idt entry - */ -extern int i386_delete_idt_entry (const rtems_raw_irq_connect_data*); - -/* - * C callable function enabling to init idt. - * - * CAUTION : this function assumes that the IDTR register - * has been already set. - */ -extern int i386_init_idt (rtems_raw_irq_global_settings* config); - -/* - * C callable function enabling to get actual idt configuration - */ -extern int i386_get_idt_config (rtems_raw_irq_global_settings** config); - - -/* - * See page 11.12 Figure 11-8. - * - */ -/** - * @brief describes one entry of Global/Local Descriptor Table - */ -typedef struct { - unsigned int limit_15_0 : 16; - unsigned int base_address_15_0 : 16; - unsigned int base_address_23_16 : 8; - unsigned int type : 4; - unsigned int descriptor_type : 1; - unsigned int privilege : 2; - unsigned int present : 1; - unsigned int limit_19_16 : 4; - unsigned int available : 1; - unsigned int fixed_value_bits : 1; - unsigned int operation_size : 1; - unsigned int granularity : 1; - unsigned int base_address_31_24 : 8; -} RTEMS_PACKED segment_descriptors; - -/* - * C callable function enabling to get easilly usable info from - * the actual value of GDT register. - */ -extern void i386_get_info_from_GDTR (segment_descriptors** table, - uint16_t* limit); -/* - * C callable function enabling to change the value of GDT register. Must be called - * with interrupts masked at processor level!!!. - */ -extern void i386_set_GDTR (segment_descriptors*, - uint16_t limit); - -/** - * @brief Allows to set a GDT entry. - * - * Puts global descriptor \p sd to the global descriptor table on index - * \p segment_selector_index - * - * @param[in] segment_selector_index index to GDT entry - * @param[in] sd structure to be coppied to given \p segment_selector in GDT - * @retval 0 FAILED out of GDT range or index is 0, which is not valid - * index in GDT - * @retval 1 SUCCESS - */ -extern uint32_t i386_raw_gdt_entry (uint16_t segment_selector_index, - segment_descriptors* sd); - -/** - * @brief fills \p sd with provided \p base in appropriate fields of \p sd - * - * @param[in] base 32-bit address to be set as descriptor's base - * @param[out] sd descriptor being filled with \p base - */ -extern void i386_fill_segment_desc_base (uint32_t base, - segment_descriptors* sd); - -/** - * @brief fills \p sd with provided \p limit in appropriate fields of \p sd - * - * sets granularity bit if necessary - * - * @param[in] limit 32-bit value representing number of limit bytes - * @param[out] sd descriptor being filled with \p limit - */ -extern void i386_fill_segment_desc_limit (uint32_t limit, - segment_descriptors* sd); - -/* - * C callable function enabling to set up one raw interrupt handler - */ -extern uint32_t i386_set_gdt_entry (uint16_t segment_selector, - uint32_t base, - uint32_t limit); - -/** - * @brief Returns next empty descriptor in GDT. - * - * Number of descriptors that can be returned depends on \a GDT_SIZE - * - * @retval 0 FAILED GDT is full - * @retval <1;65535> segment_selector number as index to GDT - */ -extern uint16_t i386_next_empty_gdt_entry (void); - -/** - * @brief Copies GDT entry at index \p segment_selector to structure - * pointed to by \p struct_to_fill - * - * @param[in] segment_selector index to GDT table specifying descriptor to copy - * @param[out] struct_to_fill pointer to memory where will be descriptor coppied - * @retval 0 FAILED segment_selector out of GDT range - * @retval <1;65535> retrieved segment_selector - */ -extern uint16_t i386_cpy_gdt_entry (uint16_t segment_selector, - segment_descriptors* struct_to_fill); - -/** - * @brief Returns pointer to GDT table at index given by \p segment_selector - * - * @param[in] sgmnt_selector index to GDT table for specifying descriptor to get - * @retval NULL FAILED segment_selector out of GDT range - * @retval pointer to GDT table at \p segment_selector - */ -extern segment_descriptors* i386_get_gdt_entry (uint16_t sgmnt_selector); - -/** - * @brief Extracts base address from GDT entry pointed to by \p gdt_entry - * - * @param[in] gdt_entry pointer to entry from which base should be retrieved - * @retval base address from GDT entry -*/ -RTEMS_INLINE_ROUTINE void* i386_base_gdt_entry (segment_descriptors* gdt_entry) -{ - return (void*)(gdt_entry->base_address_15_0 | - (gdt_entry->base_address_23_16<<16) | - (gdt_entry->base_address_31_24<<24)); -} - -/** - * @brief Extracts limit in bytes from GDT entry pointed to by \p gdt_entry - * - * @param[in] gdt_entry pointer to entry from which limit should be retrieved - * @retval limit value in bytes from GDT entry - */ -extern uint32_t i386_limit_gdt_entry (segment_descriptors* gdt_entry); - -/* - * See page 11.18 Figure 11-12. - * - */ - -typedef struct { - unsigned int offset : 12; - unsigned int page : 10; - unsigned int directory : 10; -}la_bits; - -typedef union { - la_bits bits; - unsigned int address; -}linear_address; - - -/* - * See page 11.20 Figure 11-14. - * - */ - -typedef struct { - unsigned int present : 1; - unsigned int writable : 1; - unsigned int user : 1; - unsigned int write_through : 1; - unsigned int cache_disable : 1; - unsigned int accessed : 1; - unsigned int reserved1 : 1; - unsigned int page_size : 1; - unsigned int reserved2 : 1; - unsigned int available : 3; - unsigned int page_frame_address : 20; -}page_dir_bits; - -typedef union { - page_dir_bits bits; - unsigned int dir_entry; -}page_dir_entry; - -typedef struct { - unsigned int present : 1; - unsigned int writable : 1; - unsigned int user : 1; - unsigned int write_through : 1; - unsigned int cache_disable : 1; - unsigned int accessed : 1; - unsigned int dirty : 1; - unsigned int reserved2 : 2; - unsigned int available : 3; - unsigned int page_frame_address : 20; -}page_table_bits; - -typedef union { - page_table_bits bits; - unsigned int table_entry; -} page_table_entry; - -/* - * definitions related to page table entry - */ -#define PG_SIZE 0x1000 -#define MASK_OFFSET 0xFFF -#define MAX_ENTRY (PG_SIZE/sizeof(page_dir_entry)) -#define FOUR_MB 0x400000 -#define MASK_FLAGS 0x1A - -#define PTE_PRESENT 0x01 -#define PTE_WRITABLE 0x02 -#define PTE_USER 0x04 -#define PTE_WRITE_THROUGH 0x08 -#define PTE_CACHE_DISABLE 0x10 - -typedef struct { - page_dir_entry pageDirEntry[MAX_ENTRY]; -} page_directory; - -typedef struct { - page_table_entry pageTableEntry[MAX_ENTRY]; -} page_table; - -/* Simpler names for the i80x86 I/O instructions */ -#define outport_byte( _port, _value ) i386_outport_byte( _port, _value ) -#define outport_word( _port, _value ) i386_outport_word( _port, _value ) -#define outport_long( _port, _value ) i386_outport_long( _port, _value ) -#define inport_byte( _port, _value ) i386_inport_byte( _port, _value ) -#define inport_word( _port, _value ) i386_inport_word( _port, _value ) -#define inport_long( _port, _value ) i386_inport_long( _port, _value ) - -#ifdef __cplusplus -} -#endif - -#endif /* !ASM */ - -#endif diff --git a/cpukit/score/cpu/i386/rtems/score/idtr.h b/cpukit/score/cpu/i386/rtems/score/idtr.h deleted file mode 100644 index a79af40792..0000000000 --- a/cpukit/score/cpu/i386/rtems/score/idtr.h +++ /dev/null @@ -1,66 +0,0 @@ -/** - * @file - * - * @brief Intel I386 Data Structures - * - * This file contains definitions for data structure related - * to Intel system programming. More information can be found - * on Intel site and more precisely in the following book : - * - * Pentium Processor familly - * Developper's Manual - * - * Volume 3 : Architecture and Programming Manual - * - * Formerly contained in and extracted from libcpu/i386/cpu.h. - */ - -/* - * COPYRIGHT (C) 1998 Eric Valette (valette@crf.canon.fr) - * Canon Centre Recherche France. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - * - * Applications must not include this file directly. - */ - -#ifndef _RTEMS_SCORE_IDTR_H -#define _RTEMS_SCORE_IDTR_H - -/* - * See page 14.9 Figure 14-2. - * - */ -typedef struct -{ - unsigned int low_offsets_bits:16; - unsigned int segment_selector:16; - unsigned int fixed_value_bits:8; - unsigned int gate_type:5; - unsigned int privilege:2; - unsigned int present:1; - unsigned int high_offsets_bits:16; -} interrupt_gate_descriptor; - -/* - * C callable function enabling to create a interrupt_gate_descriptor - */ -extern void create_interrupt_gate_descriptor (interrupt_gate_descriptor*, rtems_raw_irq_hdl); - -/* - * C callable function enabling to get easily usable info from - * the actual value of IDT register. - */ -extern void i386_get_info_from_IDTR (interrupt_gate_descriptor** table, - unsigned* limit); - -/* - * C callable function enabling to change the value of IDT register. Must be called - * with interrupts masked at processor level!!!. - */ -extern void i386_set_IDTR (interrupt_gate_descriptor* table, - unsigned limit); - -#endif diff --git a/cpukit/score/cpu/i386/rtems/score/interrupts.h b/cpukit/score/cpu/i386/rtems/score/interrupts.h deleted file mode 100644 index 3a7971c1ff..0000000000 --- a/cpukit/score/cpu/i386/rtems/score/interrupts.h +++ /dev/null @@ -1,85 +0,0 @@ -/** - * @file - * - * @brief Intel I386 Interrupt Macros - * - * Formerly contained in and extracted from libcpu/i386/cpu.h - */ - -/* - * COPYRIGHT (c) 1998 valette@crf.canon.fr - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - * - * Applications must not include this file directly. - */ - -#ifndef _RTEMS_SCORE_INTERRUPTS_H -#define _RTEMS_SCORE_INTERRUPTS_H - -#ifndef ASM - -struct __rtems_raw_irq_connect_data__; - -typedef void (*rtems_raw_irq_hdl) (void); -typedef void (*rtems_raw_irq_enable) (const struct __rtems_raw_irq_connect_data__*); -typedef void (*rtems_raw_irq_disable) (const struct __rtems_raw_irq_connect_data__*); -typedef int (*rtems_raw_irq_is_enabled) (const struct __rtems_raw_irq_connect_data__*); - -/** - * @name Interrupt Level Macros - * - */ -/**@{**/ -#if !defined(RTEMS_PARAVIRT) -#define i386_disable_interrupts( _level ) \ - { \ - __asm__ volatile ( "pushf ; \ - cli ; \ - pop %0" \ - : "=rm" ((_level)) \ - ); \ - } - -#define i386_enable_interrupts( _level ) \ - { \ - __asm__ volatile ( "push %0 ; \ - popf" \ - : : "rm" ((_level)) : "cc" \ - ); \ - } - -#define i386_flash_interrupts( _level ) \ - { \ - __asm__ volatile ( "push %0 ; \ - popf ; \ - cli" \ - : : "rm" ((_level)) : "cc" \ - ); \ - } - -#define i386_get_interrupt_level( _level ) \ - do { \ - register uint32_t _eflags; \ - \ - __asm__ volatile ( "pushf ; \ - pop %0" \ - : "=rm" ((_eflags)) \ - ); \ - \ - _level = (_eflags & EFLAGS_INTR_ENABLE) ? 0 : 1; \ - } while (0) -#else -uint32_t i386_disable_interrupts( void ); -void i386_enable_interrupts(uint32_t level); -void i386_flash_interrupts(uint32_t level); -void i386_set_interrupt_level(uint32_t new_level); -uint32_t i386_get_interrupt_level( void ); -#endif /* PARAVIRT */ - -/** @} */ - -#endif -#endif diff --git a/cpukit/score/cpu/i386/rtems/score/registers.h b/cpukit/score/cpu/i386/rtems/score/registers.h deleted file mode 100644 index 254fef701b..0000000000 --- a/cpukit/score/cpu/i386/rtems/score/registers.h +++ /dev/null @@ -1,72 +0,0 @@ -/** - * @file - * - * @brief Intel CPU Constants and Definitions - * - * This file contains definition and constants related to Intel Cpu - */ - -/* - * COPYRIGHT (c) 1998 valette@crf.canon.fr - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_REGISTERS_H -#define _RTEMS_SCORE_REGISTERS_H - -/* - * definition related to EFLAGS - */ -#define EFLAGS_CARRY 0x1 -#define EFLAGS_PARITY 0x4 - -#define EFLAGS_AUX_CARRY 0x10 -#define EFLAGS_ZERO 0x40 -#define EFLAGS_SIGN 0x80 - -#define EFLAGS_TRAP 0x100 -#define EFLAGS_INTR_ENABLE 0x200 -#define EFLAGS_DIRECTION 0x400 -#define EFLAGS_OVERFLOW 0x800 - -#define EFLAGS_IOPL_MASK 0x3000 -#define EFLAGS_NESTED_TASK 0x8000 - -#define EFLAGS_RESUME 0x10000 -#define EFLAGS_VIRTUAL_MODE 0x20000 -#define EFLAGS_ALIGN_CHECK 0x40000 -#define EFLAGS_VIRTUAL_INTR 0x80000 - -#define EFLAGS_VIRTUAL_INTR_PEND 0x100000 -#define EFLAGS_ID 0x200000 - -/* - * definitions related to CR0 - */ -#define CR0_PROTECTION_ENABLE 0x1 -#define CR0_MONITOR_COPROC 0x2 -#define CR0_COPROC_SOFT_EMUL 0x4 -#define CR0_FLOATING_INSTR_EXCEPTION 0x8 - -#define CR0_EXTENSION_TYPE 0x10 -#define CR0_NUMERIC_ERROR 0x20 - -#define CR0_WRITE_PROTECT 0x10000 -#define CR0_ALIGMENT_MASK 0x40000 - -#define CR0_NO_WRITE_THROUGH 0x20000000 -#define CR0_PAGE_LEVEL_CACHE_DISABLE 0x40000000 -#define CR0_PAGING 0x80000000 - -/* - * definitions related to CR3 - */ - -#define CR3_PAGE_CACHE_DISABLE 0x10 -#define CR3_PAGE_WRITE_THROUGH 0x8 -#define CR3_PAGE_DIRECTORY_MASK 0xFFFFF000 - -#endif diff --git a/cpukit/score/cpu/i386/rtems/score/types.h b/cpukit/score/cpu/i386/rtems/score/types.h deleted file mode 100644 index 00555d41b5..0000000000 --- a/cpukit/score/cpu/i386/rtems/score/types.h +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @file - * - * @brief Intel I386 CPU Type Definitions - * - * This include file contains type definitions pertaining to the Intel - * i386 processor family. - */ - -/* - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_TYPES_H -#define _RTEMS_SCORE_TYPES_H - -#include - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This section defines the basic types for this processor. - */ - -/** Type that can store a 32-bit integer or a pointer. */ -typedef uintptr_t CPU_Uint32ptr; - -typedef void i386_isr; -typedef i386_isr ( *i386_isr_entry )( void ); - -#ifdef __cplusplus -} -#endif - -#endif /* !ASM */ - -#endif diff --git a/cpukit/score/cpu/lm32/Makefile.am b/cpukit/score/cpu/lm32/Makefile.am index 72cb69abcc..75bcba5793 100644 --- a/cpukit/score/cpu/lm32/Makefile.am +++ b/cpukit/score/cpu/lm32/Makefile.am @@ -1,21 +1,10 @@ include $(top_srcdir)/automake/compile.am -include_rtemsdir = $(includedir)/rtems -include_rtems_HEADERS = rtems/asm.h - -include_rtems_scoredir = $(includedir)/rtems/score -include_rtems_score_HEADERS = rtems/score/cpu.h -include_rtems_score_HEADERS += rtems/score/cpuimpl.h -include_rtems_score_HEADERS += rtems/score/lm32.h -include_rtems_score_HEADERS += rtems/score/cpu_asm.h -include_rtems_score_HEADERS += rtems/score/types.h -include_rtems_score_HEADERS += rtems/score/cpuatomic.h - noinst_LIBRARIES = libscorecpu.a libscorecpu_a_SOURCES = cpu.c cpu_asm.S irq.c libscorecpu_a_SOURCES += ../no_cpu/cpucounterread.c libscorecpu_a_SOURCES += lm32-exception-frame-print.c libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS) -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am +include $(srcdir)/headers.am diff --git a/cpukit/score/cpu/lm32/headers.am b/cpukit/score/cpu/lm32/headers.am new file mode 100644 index 0000000000..68128ca00b --- /dev/null +++ b/cpukit/score/cpu/lm32/headers.am @@ -0,0 +1,18 @@ +## This file was generated by "./boostrap -H". + +include_machinedir = $(includedir)/machine +include_machine_HEADERS = +include_machine_HEADERS += include/machine/elf_machdep.h + +include_rtemsdir = $(includedir)/rtems +include_rtems_HEADERS = +include_rtems_HEADERS += include/rtems/asm.h + +include_rtems_scoredir = $(includedir)/rtems/score +include_rtems_score_HEADERS = +include_rtems_score_HEADERS += include/rtems/score/cpu.h +include_rtems_score_HEADERS += include/rtems/score/cpu_asm.h +include_rtems_score_HEADERS += include/rtems/score/cpuatomic.h +include_rtems_score_HEADERS += include/rtems/score/cpuimpl.h +include_rtems_score_HEADERS += include/rtems/score/lm32.h +include_rtems_score_HEADERS += include/rtems/score/types.h diff --git a/cpukit/score/cpu/lm32/include/machine/elf_machdep.h b/cpukit/score/cpu/lm32/include/machine/elf_machdep.h new file mode 100644 index 0000000000..29c75b89db --- /dev/null +++ b/cpukit/score/cpu/lm32/include/machine/elf_machdep.h @@ -0,0 +1,34 @@ +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB + +#define ELF32_MACHDEP_ID_CASES \ + case EM_LATTICEMICO32: \ + break; + +#define ELF32_MACHDEP_ID EM_LATTICEMICO32 + +#define EF_MACH32_MACH 0x00000001 + +//#define EF_BLACKFIN + +#define ARCH_ELFSIZE 32 + +#define R_LM32_NONE 0 +#define R_LM32_8 1 +#define R_LM32_16 2 +#define R_LM32_32 3 +#define R_LM32_HI16 4 +#define R_LM32_LO16 5 +#define R_LM32_GPREL16 6 +#define R_LM32_CALL 7 +#define R_LM32_BRANCH 8 +#define R_LM32_GNU_VTINHERIT 9 +#define R_LM32_GNU_VTENTRY 10 +#define R_LM32_16_GOT 11 +#define R_LM32_GOTOFF_HI16 12 +#define R_LM32_GOTOFF_LO16 13 +#define R_LM32_COPY 14 +#define R_LM32_GLOT_DAT 15 +#define R_LM32_JMP_SLOT 16 +#define R_LM32_RELATIVE 17 + +#define R_TYPE(name) __CONCAT(R_LM32_,name) diff --git a/cpukit/score/cpu/lm32/include/rtems/asm.h b/cpukit/score/cpu/lm32/include/rtems/asm.h new file mode 100644 index 0000000000..15046df81c --- /dev/null +++ b/cpukit/score/cpu/lm32/include/rtems/asm.h @@ -0,0 +1,127 @@ +/** + * @file + * + * @brief Address the Problems Caused by Incompatible Flavor of + * Assemblers and Toolsets + * + * This include file attempts to address the problems + * caused by incompatible flavors of assemblers and + * toolsets. It primarily addresses variations in the + * use of leading underscores on symbols and the requirement + * that register names be preceded by a %. + * + * NOTE: The spacing in the use of these macros + * is critical to them working as advertised. + */ + +/* + * COPYRIGHT: + * + * This file is based on similar code found in newlib available + * from ftp.cygnus.com. The file which was used had no copyright + * notice. This file is freely distributable as long as the source + * of the file is noted. This file is: + * + * COPYRIGHT (c) 1994-2006. + * On-Line Applications Research Corporation (OAR). + */ + +#ifndef _RTEMS_ASM_H +#define _RTEMS_ASM_H + +/* + * Indicate we are in an assembly file and get the basic CPU definitions. + */ + +#ifndef ASM +#define ASM +#endif +#include +#include + +#ifndef __USER_LABEL_PREFIX__ +/** + * Recent versions of GNU cpp define variables which indicate the + * need for underscores and percents. If not using GNU cpp or + * the version does not support this, then you will obviously + * have to define these as appropriate. + * + * This symbol is prefixed to all C program symbols. + */ +#define __USER_LABEL_PREFIX__ _ +#endif + +#ifndef __REGISTER_PREFIX__ +/** + * Recent versions of GNU cpp define variables which indicate the + * need for underscores and percents. If not using GNU cpp or + * the version does not support this, then you will obviously + * have to define these as appropriate. + * + * This symbol is prefixed to all register names. + */ +#define __REGISTER_PREFIX__ +#endif + +#include + +/** Use the right prefix for global labels. */ +#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) + +/** Use the right prefix for registers. */ +#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) + +/* + * define macros for all of the registers on this CPU + * + * EXAMPLE: #define d0 REG (d0) + */ + +/* + * Define macros to handle section beginning and ends. + */ + + +/** This macro is used to denote the beginning of a code declaration. */ +#define BEGIN_CODE_DCL .text +/** This macro is used to denote the end of a code declaration. */ +#define END_CODE_DCL +/** This macro is used to denote the beginning of a data declaration section. */ +#define BEGIN_DATA_DCL .data +/** This macro is used to denote the end of a data declaration section. */ +#define END_DATA_DCL +/** This macro is used to denote the beginning of a code section. */ +#define BEGIN_CODE .text +/** This macro is used to denote the end of a code section. */ +#define END_CODE +/** This macro is used to denote the beginning of a data section. */ +#define BEGIN_DATA +/** This macro is used to denote the end of a data section. */ +#define END_DATA +/** + * This macro is used to denote the beginning of the + * unitialized data section. + */ +#define BEGIN_BSS +/** This macro is used to denote the end of the unitialized data section. */ +#define END_BSS +/** This macro is used to denote the end of the assembly file. */ +#define END + +/** + * This macro is used to declare a public global symbol. + * + * NOTE: This must be tailored for a particular flavor of the C compiler. + * They may need to put underscores in front of the symbols. + */ +#define PUBLIC(sym) .globl SYM (sym) + +/** + * This macro is used to prototype a public global symbol. + * + * NOTE: This must be tailored for a particular flavor of the C compiler. + * They may need to put underscores in front of the symbols. + */ +#define EXTERN(sym) .globl SYM (sym) + +#endif diff --git a/cpukit/score/cpu/lm32/include/rtems/score/cpu.h b/cpukit/score/cpu/lm32/include/rtems/score/cpu.h new file mode 100644 index 0000000000..9d229948aa --- /dev/null +++ b/cpukit/score/cpu/lm32/include/rtems/score/cpu.h @@ -0,0 +1,1035 @@ +/** + * @file + * + * @brief LM32 CPU Department Source + * + * This include file contains information pertaining to the LM32 + * processor. + */ + +/* + * COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPU_H +#define _RTEMS_SCORE_CPU_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* conditional compilation parameters */ + +/** + * Does RTEMS manage a dedicated interrupt stack in software? + * + * If TRUE, then a stack is allocated in @ref _ISR_Handler_initialization. + * If FALSE, nothing is done. + * + * If the CPU supports a dedicated interrupt stack in hardware, + * then it is generally the responsibility of the BSP to allocate it + * and set it up. + * + * If the CPU does not support a dedicated interrupt stack, then + * the porter has two options: (1) execute interrupts on the + * stack of the interrupted task, and (2) have RTEMS manage a dedicated + * interrupt stack. + * + * If this is TRUE, @ref CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. + * + * Only one of @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK and + * @ref CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is + * possible that both are FALSE for a particular CPU. Although it + * is unclear what that would imply about the interrupt processing + * procedure on that CPU. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_HAS_SOFTWARE_INTERRUPT_STACK TRUE + +/** + * Does the CPU follow the simple vectored interrupt model? + * + * If TRUE, then RTEMS allocates the vector table it internally manages. + * If FALSE, then the BSP is assumed to allocate and manage the vector + * table + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_SIMPLE_VECTORED_INTERRUPTS TRUE + +/** + * Does this CPU have hardware support for a dedicated interrupt stack? + * + * If TRUE, then it must be installed during initialization. + * If FALSE, then no installation is performed. + * + * If this is TRUE, @ref CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. + * + * Only one of @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK and + * @ref CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is + * possible that both are FALSE for a particular CPU. Although it + * is unclear what that would imply about the interrupt processing + * procedure on that CPU. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE + +/** + * Does RTEMS allocate a dedicated interrupt stack in the Interrupt Manager? + * + * If TRUE, then the memory is allocated during initialization. + * If FALSE, then the memory is allocated during initialization. + * + * This should be TRUE is CPU_HAS_SOFTWARE_INTERRUPT_STACK is TRUE. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_ALLOCATE_INTERRUPT_STACK TRUE + +/** + * Does the RTEMS invoke the user's ISR with the vector number and + * a pointer to the saved interrupt frame (1) or just the vector + * number (0)? + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_ISR_PASSES_FRAME_POINTER TRUE + +/** + * @def CPU_HARDWARE_FP + * + * Does the CPU have hardware floating point? + * + * If TRUE, then the RTEMS_FLOATING_POINT task attribute is supported. + * If FALSE, then the RTEMS_FLOATING_POINT task attribute is ignored. + * + * If there is a FP coprocessor such as the i387 or mc68881, then + * the answer is TRUE. + * + * The macro name "NO_CPU_HAS_FPU" should be made CPU specific. + * It indicates whether or not this CPU model has FP support. For + * example, it would be possible to have an i386_nofp CPU model + * which set this to false to indicate that you have an i386 without + * an i387 and wish to leave floating point support out of RTEMS. + */ + +/** + * @def CPU_SOFTWARE_FP + * + * Does the CPU have no hardware floating point and GCC provides a + * software floating point implementation which must be context + * switched? + * + * This feature conditional is used to indicate whether or not there + * is software implemented floating point that must be context + * switched. The determination of whether or not this applies + * is very tool specific and the state saved/restored is also + * compiler specific. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_HARDWARE_FP FALSE +#define CPU_SOFTWARE_FP FALSE + +/** + * Are all tasks RTEMS_FLOATING_POINT tasks implicitly? + * + * If TRUE, then the RTEMS_FLOATING_POINT task attribute is assumed. + * If FALSE, then the RTEMS_FLOATING_POINT task attribute is followed. + * + * So far, the only CPUs in which this option has been used are the + * HP PA-RISC and PowerPC. On the PA-RISC, The HP C compiler and + * gcc both implicitly used the floating point registers to perform + * integer multiplies. Similarly, the PowerPC port of gcc has been + * seen to allocate floating point local variables and touch the FPU + * even when the flow through a subroutine (like vfprintf()) might + * not use floating point formats. + * + * If a function which you would not think utilize the FP unit DOES, + * then one can not easily predict which tasks will use the FP hardware. + * In this case, this option should be TRUE. + * + * If @ref CPU_HARDWARE_FP is FALSE, then this should be FALSE as well. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_ALL_TASKS_ARE_FP FALSE + +/** + * Should the IDLE task have a floating point context? + * + * If TRUE, then the IDLE task is created as a RTEMS_FLOATING_POINT task + * and it has a floating point context which is switched in and out. + * If FALSE, then the IDLE task does not have a floating point context. + * + * Setting this to TRUE negatively impacts the time required to preempt + * the IDLE task from an interrupt because the floating point context + * must be saved as part of the preemption. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_IDLE_TASK_IS_FP FALSE + +/** + * Should the saving of the floating point registers be deferred + * until a context switch is made to another different floating point + * task? + * + * If TRUE, then the floating point context will not be stored until + * necessary. It will remain in the floating point registers and not + * disturned until another floating point task is switched to. + * + * If FALSE, then the floating point context is saved when a floating + * point task is switched out and restored when the next floating point + * task is restored. The state of the floating point registers between + * those two operations is not specified. + * + * If the floating point context does NOT have to be saved as part of + * interrupt dispatching, then it should be safe to set this to TRUE. + * + * Setting this flag to TRUE results in using a different algorithm + * for deciding when to save and restore the floating point context. + * The deferred FP switch algorithm minimizes the number of times + * the FP context is saved and restored. The FP context is not saved + * until a context switch is made to another, different FP task. + * Thus in a system with only one FP task, the FP context will never + * be saved or restored. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_USE_DEFERRED_FP_SWITCH TRUE + +#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE + +/** + * Does this port provide a CPU dependent IDLE task implementation? + * + * If TRUE, then the routine @ref _CPU_Thread_Idle_body + * must be provided and is the default IDLE thread body instead of + * @ref _CPU_Thread_Idle_body. + * + * If FALSE, then use the generic IDLE thread body if the BSP does + * not provide one. + * + * This is intended to allow for supporting processors which have + * a low power or idle mode. When the IDLE thread is executed, then + * the CPU can be powered down. + * + * The order of precedence for selecting the IDLE thread body is: + * + * -# BSP provided + * -# CPU dependent (if provided) + * -# generic (if no BSP and no CPU dependent) + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_PROVIDES_IDLE_THREAD_BODY TRUE + +/** + * Does the stack grow up (toward higher addresses) or down + * (toward lower addresses)? + * + * If TRUE, then the grows upward. + * If FALSE, then the grows toward smaller addresses. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_STACK_GROWS_UP FALSE + +/* L2 cache lines are 32 bytes in Milkymist SoC */ +#define CPU_CACHE_LINE_BYTES 32 + +#define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES ) + +/** + * @ingroup CPUInterrupt + * The following defines the number of bits actually used in the + * interrupt field of the task mode. How those bits map to the + * CPU interrupt levels is defined by the routine @ref _CPU_ISR_Set_level. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_MODES_INTERRUPT_MASK 0x00000001 + +#define CPU_MAXIMUM_PROCESSORS 32 + +/* + * Processor defined structures required for cpukit/score. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ + +/* may need to put some structures here. */ + +/** + * @defgroup CPUContext Processor Dependent Context Management + * + * From the highest level viewpoint, there are 2 types of context to save. + * + * -# Interrupt registers to save + * -# Task level registers to save + * + * Since RTEMS handles integer and floating point contexts separately, this + * means we have the following 3 context items: + * + * -# task level context stuff:: Context_Control + * -# floating point task stuff:: Context_Control_fp + * -# special interrupt level context :: CPU_Interrupt_frame + * + * On some processors, it is cost-effective to save only the callee + * preserved registers during a task context switch. This means + * that the ISR code needs to save those registers which do not + * persist across function calls. It is not mandatory to make this + * distinctions between the caller/callee saves registers for the + * purpose of minimizing context saved during task switch and on interrupts. + * If the cost of saving extra registers is minimal, simplicity is the + * choice. Save the same context on interrupt entry as for tasks in + * this case. + * + * Additionally, if gdb is to be made aware of RTEMS tasks for this CPU, then + * care should be used in designing the context area. + * + * On some CPUs with hardware floating point support, the Context_Control_fp + * structure will not be used or it simply consist of an array of a + * fixed number of bytes. This is done when the floating point context + * is dumped by a "FP save context" type instruction and the format + * is not really defined by the CPU. In this case, there is no need + * to figure out the exact format -- only the size. Of course, although + * this is enough information for RTEMS, it is probably not enough for + * a debugger such as gdb. But that is another problem. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +/**@{**/ + +/** + * This defines the minimal set of integer and processor state registers + * that must be saved during a voluntary context switch from one thread + * to another. + */ +typedef struct { + uint32_t r11; + uint32_t r12; + uint32_t r13; + uint32_t r14; + uint32_t r15; + uint32_t r16; + uint32_t r17; + uint32_t r18; + uint32_t r19; + uint32_t r20; + uint32_t r21; + uint32_t r22; + uint32_t r23; + uint32_t r24; + uint32_t r25; + uint32_t gp; + uint32_t fp; + uint32_t sp; + uint32_t ra; + uint32_t ie; + uint32_t epc; +} Context_Control; + +/** + * + * This macro returns the stack pointer associated with @a _context. + * + * @param[in] _context is the thread context area to access + * + * @return This method returns the stack pointer. + */ +#define _CPU_Context_Get_SP( _context ) \ + (_context)->sp + +/** + * This defines the complete set of floating point registers that must + * be saved during any context switch from one thread to another. + */ +typedef struct { +} Context_Control_fp; + +/** + * This defines the set of integer and processor state registers that must + * be saved during an interrupt. This set does not include any which are + * in @ref Context_Control. + */ +typedef struct { + uint32_t r1; + uint32_t r2; + uint32_t r3; + uint32_t r4; + uint32_t r5; + uint32_t r6; + uint32_t r7; + uint32_t r8; + uint32_t r9; + uint32_t r10; + uint32_t ra; + uint32_t ba; + uint32_t ea; +} CPU_Interrupt_frame; + +/** + * This variable is optional. It is used on CPUs on which it is difficult + * to generate an "uninitialized" FP context. It is filled in by + * @ref _CPU_Initialize and copied into the task's FP context area during + * @ref _CPU_Context_Initialize. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#if 0 +extern Context_Control_fp _CPU_Null_fp_context; +#endif + +/** @} */ + +/** + * @defgroup CPUInterrupt Processor Dependent Interrupt Management + * + * On some CPUs, RTEMS supports a software managed interrupt stack. + * This stack is allocated by the Interrupt Manager and the switch + * is performed in @ref _ISR_Handler. These variables contain pointers + * to the lowest and highest addresses in the chunk of memory allocated + * for the interrupt stack. Since it is unknown whether the stack + * grows up or down (in general), this give the CPU dependent + * code the option of picking the version it wants to use. + * + * NOTE: These two variables are required if the macro + * @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK is defined as TRUE. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +/**@{**/ + +/* + * Nothing prevents the porter from declaring more CPU specific variables. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ + +/* XXX: if needed, put more variables here */ + +/** + * @ingroup CPUContext + * The size of the floating point context area. On some CPUs this + * will not be a "sizeof" because the format of the floating point + * area is not defined -- only the size is. This is usually on + * CPUs with a "floating point save context" instruction. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp ) + +/** + * Amount of extra stack (above minimum stack size) required by + * MPCI receive server thread. Remember that in a multiprocessor + * system this thread must exist and be able to process all directives. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0 + +/** + * This defines the number of entries in the @ref _ISR_Vector_table managed + * by RTEMS. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_INTERRUPT_NUMBER_OF_VECTORS 32 + +/** + * This defines the highest interrupt vector number for this port. + */ +#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER (CPU_INTERRUPT_NUMBER_OF_VECTORS - 1) + +/** + * This is defined if the port has a special way to report the ISR nesting + * level. Most ports maintain the variable @a _ISR_Nest_level. + */ +#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE + +/** @} */ + +/** + * @ingroup CPUContext + * Should be large enough to run all RTEMS tests. This ensures + * that a "reasonable" small application should not have any problems. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_STACK_MINIMUM_SIZE (1024*4) + +#define CPU_SIZEOF_POINTER 4 + +/** + * CPU's worst alignment requirement for data types on a byte boundary. This + * alignment does not take into account the requirements for the stack. + * + * Port Specific Information: + * The LM32 architecture manual simply states: "All memory accesses must be + * aligned to the size of the access", and there is no hardware support + * whatsoever for 64-bit numbers. + * (lm32_archman.pdf, July 2009, p. 15) + */ +#define CPU_ALIGNMENT 4 + +/** + * This number corresponds to the byte alignment requirement for the + * heap handler. This alignment requirement may be stricter than that + * for the data types alignment specified by @ref CPU_ALIGNMENT. It is + * common for the heap to follow the same alignment requirement as + * @ref CPU_ALIGNMENT. If the @ref CPU_ALIGNMENT is strict enough for + * the heap, then this should be set to @ref CPU_ALIGNMENT. + * + * NOTE: This does not have to be a power of 2 although it should be + * a multiple of 2 greater than or equal to 2. The requirement + * to be a multiple of 2 is because the heap uses the least + * significant field of the front and back flags to indicate + * that a block is in use or free. So you do not want any odd + * length blocks really putting length data in that bit. + * + * On byte oriented architectures, @ref CPU_HEAP_ALIGNMENT normally will + * have to be greater or equal to than @ref CPU_ALIGNMENT to ensure that + * elements allocated from the heap meet all restrictions. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT + +/** + * This number corresponds to the byte alignment requirement for memory + * buffers allocated by the partition manager. This alignment requirement + * may be stricter than that for the data types alignment specified by + * @ref CPU_ALIGNMENT. It is common for the partition to follow the same + * alignment requirement as @ref CPU_ALIGNMENT. If the @ref CPU_ALIGNMENT is + * strict enough for the partition, then this should be set to + * @ref CPU_ALIGNMENT. + * + * NOTE: This does not have to be a power of 2. It does have to + * be greater or equal to than @ref CPU_ALIGNMENT. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT + +/** + * This number corresponds to the byte alignment requirement for the + * stack. This alignment requirement may be stricter than that for the + * data types alignment specified by @ref CPU_ALIGNMENT. + * + * + * Port Specific Information: + * + * Stack is software-managed + */ +#define CPU_STACK_ALIGNMENT CPU_ALIGNMENT + +/* + * ISR handler macros + */ + +/** + * @addtogroup CPUInterrupt + */ +/**@{**/ + +/** + * Support routine to initialize the RTEMS vector table after it is allocated. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_Initialize_vectors() + +/** + * Disable all interrupts for an RTEMS critical section. The previous + * level is returned in @a _isr_cookie. + * + * @param[out] _isr_cookie will contain the previous level cookie + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_ISR_Disable( _isr_cookie ) \ + lm32_disable_interrupts( _isr_cookie ); + +/** + * Enable interrupts to the previous level (returned by _CPU_ISR_Disable). + * This indicates the end of an RTEMS critical section. The parameter + * @a _isr_cookie is not modified. + * + * @param[in] _isr_cookie contain the previous level cookie + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_ISR_Enable( _isr_cookie ) \ + lm32_enable_interrupts( _isr_cookie ); + +/** + * This temporarily restores the interrupt to @a _isr_cookie before immediately + * disabling them again. This is used to divide long RTEMS critical + * sections into two or more parts. The parameter @a _isr_cookie is not + * modified. + * + * @param[in] _isr_cookie contain the previous level cookie + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_ISR_Flash( _isr_cookie ) \ + lm32_flash_interrupts( _isr_cookie ); + +RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) +{ + return ( level & 0x0001 ) != 0; +} + +/** + * This routine and @ref _CPU_ISR_Get_level + * Map the interrupt level in task mode onto the hardware that the CPU + * actually provides. Currently, interrupt levels which do not + * map onto the CPU in a generic fashion are undefined. Someday, + * it would be nice if these were "mapped" by the application + * via a callout. For example, m68k has 8 levels 0 - 7, levels + * 8 - 255 would be available for bsp/application specific meaning. + * This could be used to manage a programmable interrupt controller + * via the rtems_task_mode directive. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_ISR_Set_level( new_level ) \ + { \ + _CPU_ISR_Enable( ( new_level==0 ) ? 1 : 0 ); \ + } + +/** + * Return the current interrupt disable level for this task in + * the format used by the interrupt level portion of the task mode. + * + * NOTE: This routine usually must be implemented as a subroutine. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +uint32_t _CPU_ISR_Get_level( void ); + +/* end of ISR handler macros */ + +/** @} */ + +/* Context handler macros */ + +/** + * @ingroup CPUContext + * Initialize the context to a state suitable for starting a + * task after a context restore operation. Generally, this + * involves: + * + * - setting a starting address + * - preparing the stack + * - preparing the stack and frame pointers + * - setting the proper interrupt level in the context + * - initializing the floating point context + * + * This routine generally does not set any unnecessary register + * in the context. The state of the "general data" registers is + * undefined at task start time. + * + * @param[in] _the_context is the context structure to be initialized + * @param[in] _stack_base is the lowest physical address of this task's stack + * @param[in] _size is the size of this task's stack + * @param[in] _isr is the interrupt disable level + * @param[in] _entry_point is the thread's entry point. This is + * always @a _Thread_Handler + * @param[in] _is_fp is TRUE if the thread is to be a floating + * point thread. This is typically only used on CPUs where the + * FPU may be easily disabled by software such as on the SPARC + * where the PSR contains an enable FPU bit. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +extern char _gp[]; + +#define _CPU_Context_Initialize( _the_context, _stack_base, _size, \ + _isr, _entry_point, _is_fp, _tls_area ) \ + do { \ + uint32_t _stack = (uint32_t)(_stack_base) + (_size) - 4; \ + \ + (void) _is_fp; /* avoid warning for being unused */ \ + (void) _isr; /* avoid warning for being unused */ \ + (_the_context)->gp = (uint32_t)_gp; \ + (_the_context)->fp = (uint32_t)_stack; \ + (_the_context)->sp = (uint32_t)_stack; \ + (_the_context)->ra = (uint32_t)(_entry_point); \ + } while ( 0 ) + +/** + * This routine is responsible for somehow restarting the currently + * executing task. If you are lucky, then all that is necessary + * is restoring the context. Otherwise, there will need to be + * a special assembly routine which does something special in this + * case. For many ports, simply adding a label to the restore path + * of @ref _CPU_Context_switch will work. On other ports, it may be + * possibly to load a few arguments and jump to the restore path. It will + * not work if restarting self conflicts with the stack frame + * assumptions of restoring a context. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_Context_Restart_self( _the_context ) \ + _CPU_Context_restore( (_the_context) ); + +/** + * This routine initializes the FP context area passed to it to. + * There are a few standard ways in which to initialize the + * floating point context. The code included for this macro assumes + * that this is a CPU in which a "initial" FP context was saved into + * @a _CPU_Null_fp_context and it simply copies it to the destination + * context passed to it. + * + * Other floating point context save/restore models include: + * -# not doing anything, and + * -# putting a "null FP status word" in the correct place in the FP context. + * + * @param[in] _destination is the floating point context area + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_Context_Initialize_fp( _destination ) +#if 0 + { \ + *(*(_destination)) = _CPU_Null_fp_context; \ + } +#endif + +/* end of Context handler macros */ + +/* Fatal Error manager macros */ + +/** + * This routine copies _error into a known place -- typically a stack + * location or a register, optionally disables interrupts, and + * halts/stops the CPU. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_Fatal_halt( _source, _error ) \ + { \ + } + +/* end of Fatal Error manager macros */ + +#define CPU_USE_GENERIC_BITFIELD_CODE TRUE + +/* functions */ + +/** + * This routine performs CPU dependent initialization. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_Initialize(void); + +/** + * @addtogroup CPUInterrupt + */ +/**@{**/ + +/** + * This routine installs a "raw" interrupt handler directly into the + * processor's vector table. + * + * @param[in] vector is the vector number + * @param[in] new_handler is the raw ISR handler to install + * @param[in] old_handler is the previously installed ISR Handler + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_ISR_install_raw_handler( + uint32_t vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +/** + * This routine installs an interrupt vector. + * + * @param[in] vector is the vector number + * @param[in] new_handler is the RTEMS ISR handler to install + * @param[in] old_handler is the previously installed ISR Handler + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_ISR_install_vector( + uint32_t vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +/** + * This routine installs the hardware interrupt stack pointer. + * + * NOTE: It need only be provided if @ref CPU_HAS_HARDWARE_INTERRUPT_STACK + * is TRUE. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_Install_interrupt_stack( void ); + +/** @} */ + +/** + * This routine is the CPU dependent IDLE thread body. + * + * NOTE: It need only be provided if @ref CPU_PROVIDES_IDLE_THREAD_BODY + * is TRUE. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void *_CPU_Thread_Idle_body( uintptr_t ignored ); + +/** + * @ingroup CPUContext + * This routine switches from the run context to the heir context. + * + * @param[in] run points to the context of the currently executing task + * @param[in] heir points to the context of the heir task + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_Context_switch( + Context_Control *run, + Context_Control *heir +); + +/** + * @addtogroup CPUContext + */ +/**@{**/ + +/** + * This routine is generally used only to restart self in an + * efficient manner. It may simply be a label in @ref _CPU_Context_switch. + * + * @param[in] new_context points to the context to be restored. + * + * NOTE: May be unnecessary to reload some registers. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_Context_restore( + Context_Control *new_context +) RTEMS_NO_RETURN; + +/** + * This routine saves the floating point context passed to it. + * + * @param[in] fp_context_ptr is a pointer to a pointer to a floating + * point context area + * + * @return on output @a *fp_context_ptr will contain the address that + * should be used with @ref _CPU_Context_restore_fp to restore this context. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_Context_save_fp( + Context_Control_fp **fp_context_ptr +); + +/** + * This routine restores the floating point context passed to it. + * + * @param[in] fp_context_ptr is a pointer to a pointer to a floating + * point context area to restore + * + * @return on output @a *fp_context_ptr will contain the address that + * should be used with @ref _CPU_Context_save_fp to save this context. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_Context_restore_fp( + Context_Control_fp **fp_context_ptr +); + +static inline void _CPU_Context_volatile_clobber( uintptr_t pattern ) +{ + /* TODO */ +} + +static inline void _CPU_Context_validate( uintptr_t pattern ) +{ + while (1) { + /* TODO */ + } +} + +/** @} */ + +/* FIXME */ +typedef CPU_Interrupt_frame CPU_Exception_frame; + +void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); + +/** + * @ingroup CPUEndian + * The following routine swaps the endian format of an unsigned int. + * It must be static because it is referenced indirectly. + * + * This version will work on any processor, but if there is a better + * way for your CPU PLEASE use it. The most common way to do this is to: + * + * swap least significant two bytes with 16-bit rotate + * swap upper and lower 16-bits + * swap most significant two bytes with 16-bit rotate + * + * Some CPUs have special instructions which swap a 32-bit quantity in + * a single instruction (e.g. i486). It is probably best to avoid + * an "endian swapping control bit" in the CPU. One good reason is + * that interrupts would probably have to be disabled to ensure that + * an interrupt does not try to access the same "chunk" with the wrong + * endian. Another good reason is that on some CPUs, the endian bit + * endianness for ALL fetches -- both code and data -- so the code + * will be fetched incorrectly. + * + * @param[in] value is the value to be swapped + * @return the value after being endian swapped + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +static inline uint32_t CPU_swap_u32( + uint32_t value +) +{ + uint32_t byte1, byte2, byte3, byte4, swapped; + + byte4 = (value >> 24) & 0xff; + byte3 = (value >> 16) & 0xff; + byte2 = (value >> 8) & 0xff; + byte1 = value & 0xff; + + swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4; + return swapped; +} + +/** + * @ingroup CPUEndian + * This routine swaps a 16 bir quantity. + * + * @param[in] value is the value to be swapped + * @return the value after being endian swapped + */ +static inline uint16_t CPU_swap_u16(uint16_t v) +{ + return v << 8 | v >> 8; +} + +typedef uint32_t CPU_Counter_ticks; + +CPU_Counter_ticks _CPU_Counter_read( void ); + +static inline CPU_Counter_ticks _CPU_Counter_difference( + CPU_Counter_ticks second, + CPU_Counter_ticks first +) +{ + return second - first; +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/score/cpu/lm32/include/rtems/score/cpu_asm.h b/cpukit/score/cpu/lm32/include/rtems/score/cpu_asm.h new file mode 100644 index 0000000000..3909c1d608 --- /dev/null +++ b/cpukit/score/cpu/lm32/include/rtems/score/cpu_asm.h @@ -0,0 +1,74 @@ +/** + * @file + * + * @brief LM32 CPU Assembly File + * + * Very loose template for an include file for the cpu_asm.? file + * if it is implemented as a ".S" file (preprocessed by cpp) instead + * of a ".s" file (preprocessed by gm4 or gasp). + */ + +/* + * COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + */ + +#ifndef _RTEMS_SCORE_CPU_ASM_H +#define _RTEMS_SCORE_CPU_ASM_H + +/* pull in the generated offsets */ + +/* +#include +*/ + +/* + * Hardware General Registers + */ + +/* put something here */ + +/* + * Hardware Floating Point Registers + */ + +/* put something here */ + +/* + * Hardware Control Registers + */ + +/* put something here */ + +/* + * Calling Convention + */ + +/* put something here */ + +/* + * Temporary registers + */ + +/* put something here */ + +/* + * Floating Point Registers - SW Conventions + */ + +/* put something here */ + +/* + * Temporary floating point registers + */ + +/* put something here */ + +#endif + +/* end of file */ diff --git a/cpukit/score/cpu/lm32/include/rtems/score/cpuatomic.h b/cpukit/score/cpu/lm32/include/rtems/score/cpuatomic.h new file mode 100644 index 0000000000..598ee76b20 --- /dev/null +++ b/cpukit/score/cpu/lm32/include/rtems/score/cpuatomic.h @@ -0,0 +1,14 @@ +/* + * COPYRIGHT (c) 2012-2013 Deng Hengyi. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_ATOMIC_CPU_H +#define _RTEMS_SCORE_ATOMIC_CPU_H + +#include + +#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/lm32/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/lm32/include/rtems/score/cpuimpl.h new file mode 100644 index 0000000000..789f2badd9 --- /dev/null +++ b/cpukit/score/cpu/lm32/include/rtems/score/cpuimpl.h @@ -0,0 +1,34 @@ +/** + * @file + * + * @brief CPU Port Implementation API + */ + +/* + * Copyright (c) 2013 embedded brains GmbH + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPUIMPL_H +#define _RTEMS_SCORE_CPUIMPL_H + +#include + +#define CPU_PER_CPU_CONTROL_SIZE 0 + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ASM */ + +#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/lm32/include/rtems/score/lm32.h b/cpukit/score/cpu/lm32/include/rtems/score/lm32.h new file mode 100644 index 0000000000..e8fecdf2f6 --- /dev/null +++ b/cpukit/score/cpu/lm32/include/rtems/score/lm32.h @@ -0,0 +1,112 @@ +/** + * @file + * + * @brief LM32 Set up Basic CPU Dependency Settings Based on Compiler Settings + * + * This file sets up basic CPU dependency settings based on + * compiler settings. For example, it can determine if + * floating point is available. This particular implementation + * is specified to the NO CPU port. + */ +/* + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + * Jukka Pietarinen , 2008, + * Micro-Research Finland Oy + */ + +#ifndef _RTEMS_SCORE_LM32_H +#define _RTEMS_SCORE_LM32_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This file contains the information required to build + * RTEMS for a particular member of the NO CPU family. + * It does this by setting variables to indicate which + * implementation dependent features are present in a particular + * member of the family. + * + * This is a good place to list all the known CPU models + * that this port supports and which RTEMS CPU model they correspond + * to. + */ + +#if defined(rtems_multilib) +/* + * Figure out all CPU Model Feature Flags based upon compiler + * predefines. + */ + +#define CPU_MODEL_NAME "rtems_multilib" +#define LM32_HAS_FPU 0 + +#elif defined(__lm32__) + +#define CPU_MODEL_NAME "lm32" +#define LM32_HAS_FPU 0 + +#else + +#error "Unsupported CPU Model" + +#endif + +/* + * Define the name of the CPU family. + */ + +#define CPU_NAME "LM32" + +#ifdef __cplusplus +} +#endif + +#define lm32_read_interrupts( _ip) \ + __asm__ volatile ("rcsr %0, ip":"=r"(_ip)); + +#define lm32_disable_interrupts( _level ) \ + do { register uint32_t ie; \ + __asm__ volatile ("rcsr %0,ie":"=r"(ie)); \ + (_level) = ie; \ + ie &= (~0x0001); \ + __asm__ volatile ("wcsr ie,%0"::"r"(ie)); \ + } while (0) + +#define lm32_enable_interrupts( _level ) \ + __asm__ volatile ("wcsr ie,%0"::"r"(_level)); + +#define lm32_flash_interrupts( _level ) \ + do { register uint32_t ie; \ + __asm__ volatile ("wcsr ie,%0"::"r"(_level)); \ + ie = (_level) & (~0x0001); \ + __asm__ volatile ("wcsr ie,%0"::"r"(ie)); \ + } while (0) + +#define lm32_interrupt_unmask( _mask ) \ + do { register uint32_t im; \ + __asm__ volatile ("rcsr %0,im":"=r"(im)); \ + im |= _mask; \ + __asm__ volatile ("wcsr im,%0"::"r"(im)); \ + } while (0) + +#define lm32_interrupt_mask( _mask ) \ + do { register uint32_t im; \ + __asm__ volatile ("rcsr %0,im":"=r"(im)); \ + im &= ~(_mask); \ + __asm__ volatile ("wcsr im,%0"::"r"(im)); \ + } while (0) + +#define lm32_interrupt_ack( _mask ) \ + do { register uint32_t ip = _mask; \ + __asm__ volatile ("wcsr ip,%0"::"r"(ip)); \ + } while (0) + +#endif /* _RTEMS_SCORE_LM32_H */ diff --git a/cpukit/score/cpu/lm32/include/rtems/score/types.h b/cpukit/score/cpu/lm32/include/rtems/score/types.h new file mode 100644 index 0000000000..c3d8666de4 --- /dev/null +++ b/cpukit/score/cpu/lm32/include/rtems/score/types.h @@ -0,0 +1,46 @@ +/** + * @file + * + * @brief LM32 CPU Type Definitions + * + * This include file contains type definitions pertaining to the + * Lattice lm32 processor family. + */ + +/* + * COPYRIGHT (c) 1989-2006. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + * Jukka Pietarinen , 2008, + * Micro-Research Finland Oy + */ + +#ifndef _RTEMS_SCORE_TYPES_H +#define _RTEMS_SCORE_TYPES_H + +#include + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This section defines the basic types for this processor. + */ + +/** Type that can store a 32-bit integer or a pointer. */ +typedef uintptr_t CPU_Uint32ptr; + +#ifdef __cplusplus +} +#endif + +#endif /* !ASM */ + +#endif diff --git a/cpukit/score/cpu/lm32/preinstall.am b/cpukit/score/cpu/lm32/preinstall.am deleted file mode 100644 index 282353f3f7..0000000000 --- a/cpukit/score/cpu/lm32/preinstall.am +++ /dev/null @@ -1,53 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -$(PROJECT_INCLUDE)/rtems/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems - @: > $(PROJECT_INCLUDE)/rtems/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/asm.h: rtems/asm.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/asm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/asm.h - -$(PROJECT_INCLUDE)/rtems/score/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/score - @: > $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/score/cpu.h: rtems/score/cpu.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpu.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpu.h - -$(PROJECT_INCLUDE)/rtems/score/cpuimpl.h: rtems/score/cpuimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h - -$(PROJECT_INCLUDE)/rtems/score/lm32.h: rtems/score/lm32.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/lm32.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/lm32.h - -$(PROJECT_INCLUDE)/rtems/score/cpu_asm.h: rtems/score/cpu_asm.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpu_asm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpu_asm.h - -$(PROJECT_INCLUDE)/rtems/score/types.h: rtems/score/types.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/types.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/types.h - -$(PROJECT_INCLUDE)/rtems/score/cpuatomic.h: rtems/score/cpuatomic.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h - diff --git a/cpukit/score/cpu/lm32/rtems/asm.h b/cpukit/score/cpu/lm32/rtems/asm.h deleted file mode 100644 index 15046df81c..0000000000 --- a/cpukit/score/cpu/lm32/rtems/asm.h +++ /dev/null @@ -1,127 +0,0 @@ -/** - * @file - * - * @brief Address the Problems Caused by Incompatible Flavor of - * Assemblers and Toolsets - * - * This include file attempts to address the problems - * caused by incompatible flavors of assemblers and - * toolsets. It primarily addresses variations in the - * use of leading underscores on symbols and the requirement - * that register names be preceded by a %. - * - * NOTE: The spacing in the use of these macros - * is critical to them working as advertised. - */ - -/* - * COPYRIGHT: - * - * This file is based on similar code found in newlib available - * from ftp.cygnus.com. The file which was used had no copyright - * notice. This file is freely distributable as long as the source - * of the file is noted. This file is: - * - * COPYRIGHT (c) 1994-2006. - * On-Line Applications Research Corporation (OAR). - */ - -#ifndef _RTEMS_ASM_H -#define _RTEMS_ASM_H - -/* - * Indicate we are in an assembly file and get the basic CPU definitions. - */ - -#ifndef ASM -#define ASM -#endif -#include -#include - -#ifndef __USER_LABEL_PREFIX__ -/** - * Recent versions of GNU cpp define variables which indicate the - * need for underscores and percents. If not using GNU cpp or - * the version does not support this, then you will obviously - * have to define these as appropriate. - * - * This symbol is prefixed to all C program symbols. - */ -#define __USER_LABEL_PREFIX__ _ -#endif - -#ifndef __REGISTER_PREFIX__ -/** - * Recent versions of GNU cpp define variables which indicate the - * need for underscores and percents. If not using GNU cpp or - * the version does not support this, then you will obviously - * have to define these as appropriate. - * - * This symbol is prefixed to all register names. - */ -#define __REGISTER_PREFIX__ -#endif - -#include - -/** Use the right prefix for global labels. */ -#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) - -/** Use the right prefix for registers. */ -#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) - -/* - * define macros for all of the registers on this CPU - * - * EXAMPLE: #define d0 REG (d0) - */ - -/* - * Define macros to handle section beginning and ends. - */ - - -/** This macro is used to denote the beginning of a code declaration. */ -#define BEGIN_CODE_DCL .text -/** This macro is used to denote the end of a code declaration. */ -#define END_CODE_DCL -/** This macro is used to denote the beginning of a data declaration section. */ -#define BEGIN_DATA_DCL .data -/** This macro is used to denote the end of a data declaration section. */ -#define END_DATA_DCL -/** This macro is used to denote the beginning of a code section. */ -#define BEGIN_CODE .text -/** This macro is used to denote the end of a code section. */ -#define END_CODE -/** This macro is used to denote the beginning of a data section. */ -#define BEGIN_DATA -/** This macro is used to denote the end of a data section. */ -#define END_DATA -/** - * This macro is used to denote the beginning of the - * unitialized data section. - */ -#define BEGIN_BSS -/** This macro is used to denote the end of the unitialized data section. */ -#define END_BSS -/** This macro is used to denote the end of the assembly file. */ -#define END - -/** - * This macro is used to declare a public global symbol. - * - * NOTE: This must be tailored for a particular flavor of the C compiler. - * They may need to put underscores in front of the symbols. - */ -#define PUBLIC(sym) .globl SYM (sym) - -/** - * This macro is used to prototype a public global symbol. - * - * NOTE: This must be tailored for a particular flavor of the C compiler. - * They may need to put underscores in front of the symbols. - */ -#define EXTERN(sym) .globl SYM (sym) - -#endif diff --git a/cpukit/score/cpu/lm32/rtems/score/cpu.h b/cpukit/score/cpu/lm32/rtems/score/cpu.h deleted file mode 100644 index 9d229948aa..0000000000 --- a/cpukit/score/cpu/lm32/rtems/score/cpu.h +++ /dev/null @@ -1,1035 +0,0 @@ -/** - * @file - * - * @brief LM32 CPU Department Source - * - * This include file contains information pertaining to the LM32 - * processor. - */ - -/* - * COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPU_H -#define _RTEMS_SCORE_CPU_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/* conditional compilation parameters */ - -/** - * Does RTEMS manage a dedicated interrupt stack in software? - * - * If TRUE, then a stack is allocated in @ref _ISR_Handler_initialization. - * If FALSE, nothing is done. - * - * If the CPU supports a dedicated interrupt stack in hardware, - * then it is generally the responsibility of the BSP to allocate it - * and set it up. - * - * If the CPU does not support a dedicated interrupt stack, then - * the porter has two options: (1) execute interrupts on the - * stack of the interrupted task, and (2) have RTEMS manage a dedicated - * interrupt stack. - * - * If this is TRUE, @ref CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. - * - * Only one of @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK and - * @ref CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is - * possible that both are FALSE for a particular CPU. Although it - * is unclear what that would imply about the interrupt processing - * procedure on that CPU. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_HAS_SOFTWARE_INTERRUPT_STACK TRUE - -/** - * Does the CPU follow the simple vectored interrupt model? - * - * If TRUE, then RTEMS allocates the vector table it internally manages. - * If FALSE, then the BSP is assumed to allocate and manage the vector - * table - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_SIMPLE_VECTORED_INTERRUPTS TRUE - -/** - * Does this CPU have hardware support for a dedicated interrupt stack? - * - * If TRUE, then it must be installed during initialization. - * If FALSE, then no installation is performed. - * - * If this is TRUE, @ref CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. - * - * Only one of @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK and - * @ref CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is - * possible that both are FALSE for a particular CPU. Although it - * is unclear what that would imply about the interrupt processing - * procedure on that CPU. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE - -/** - * Does RTEMS allocate a dedicated interrupt stack in the Interrupt Manager? - * - * If TRUE, then the memory is allocated during initialization. - * If FALSE, then the memory is allocated during initialization. - * - * This should be TRUE is CPU_HAS_SOFTWARE_INTERRUPT_STACK is TRUE. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_ALLOCATE_INTERRUPT_STACK TRUE - -/** - * Does the RTEMS invoke the user's ISR with the vector number and - * a pointer to the saved interrupt frame (1) or just the vector - * number (0)? - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_ISR_PASSES_FRAME_POINTER TRUE - -/** - * @def CPU_HARDWARE_FP - * - * Does the CPU have hardware floating point? - * - * If TRUE, then the RTEMS_FLOATING_POINT task attribute is supported. - * If FALSE, then the RTEMS_FLOATING_POINT task attribute is ignored. - * - * If there is a FP coprocessor such as the i387 or mc68881, then - * the answer is TRUE. - * - * The macro name "NO_CPU_HAS_FPU" should be made CPU specific. - * It indicates whether or not this CPU model has FP support. For - * example, it would be possible to have an i386_nofp CPU model - * which set this to false to indicate that you have an i386 without - * an i387 and wish to leave floating point support out of RTEMS. - */ - -/** - * @def CPU_SOFTWARE_FP - * - * Does the CPU have no hardware floating point and GCC provides a - * software floating point implementation which must be context - * switched? - * - * This feature conditional is used to indicate whether or not there - * is software implemented floating point that must be context - * switched. The determination of whether or not this applies - * is very tool specific and the state saved/restored is also - * compiler specific. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_HARDWARE_FP FALSE -#define CPU_SOFTWARE_FP FALSE - -/** - * Are all tasks RTEMS_FLOATING_POINT tasks implicitly? - * - * If TRUE, then the RTEMS_FLOATING_POINT task attribute is assumed. - * If FALSE, then the RTEMS_FLOATING_POINT task attribute is followed. - * - * So far, the only CPUs in which this option has been used are the - * HP PA-RISC and PowerPC. On the PA-RISC, The HP C compiler and - * gcc both implicitly used the floating point registers to perform - * integer multiplies. Similarly, the PowerPC port of gcc has been - * seen to allocate floating point local variables and touch the FPU - * even when the flow through a subroutine (like vfprintf()) might - * not use floating point formats. - * - * If a function which you would not think utilize the FP unit DOES, - * then one can not easily predict which tasks will use the FP hardware. - * In this case, this option should be TRUE. - * - * If @ref CPU_HARDWARE_FP is FALSE, then this should be FALSE as well. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_ALL_TASKS_ARE_FP FALSE - -/** - * Should the IDLE task have a floating point context? - * - * If TRUE, then the IDLE task is created as a RTEMS_FLOATING_POINT task - * and it has a floating point context which is switched in and out. - * If FALSE, then the IDLE task does not have a floating point context. - * - * Setting this to TRUE negatively impacts the time required to preempt - * the IDLE task from an interrupt because the floating point context - * must be saved as part of the preemption. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_IDLE_TASK_IS_FP FALSE - -/** - * Should the saving of the floating point registers be deferred - * until a context switch is made to another different floating point - * task? - * - * If TRUE, then the floating point context will not be stored until - * necessary. It will remain in the floating point registers and not - * disturned until another floating point task is switched to. - * - * If FALSE, then the floating point context is saved when a floating - * point task is switched out and restored when the next floating point - * task is restored. The state of the floating point registers between - * those two operations is not specified. - * - * If the floating point context does NOT have to be saved as part of - * interrupt dispatching, then it should be safe to set this to TRUE. - * - * Setting this flag to TRUE results in using a different algorithm - * for deciding when to save and restore the floating point context. - * The deferred FP switch algorithm minimizes the number of times - * the FP context is saved and restored. The FP context is not saved - * until a context switch is made to another, different FP task. - * Thus in a system with only one FP task, the FP context will never - * be saved or restored. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_USE_DEFERRED_FP_SWITCH TRUE - -#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE - -/** - * Does this port provide a CPU dependent IDLE task implementation? - * - * If TRUE, then the routine @ref _CPU_Thread_Idle_body - * must be provided and is the default IDLE thread body instead of - * @ref _CPU_Thread_Idle_body. - * - * If FALSE, then use the generic IDLE thread body if the BSP does - * not provide one. - * - * This is intended to allow for supporting processors which have - * a low power or idle mode. When the IDLE thread is executed, then - * the CPU can be powered down. - * - * The order of precedence for selecting the IDLE thread body is: - * - * -# BSP provided - * -# CPU dependent (if provided) - * -# generic (if no BSP and no CPU dependent) - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_PROVIDES_IDLE_THREAD_BODY TRUE - -/** - * Does the stack grow up (toward higher addresses) or down - * (toward lower addresses)? - * - * If TRUE, then the grows upward. - * If FALSE, then the grows toward smaller addresses. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_STACK_GROWS_UP FALSE - -/* L2 cache lines are 32 bytes in Milkymist SoC */ -#define CPU_CACHE_LINE_BYTES 32 - -#define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES ) - -/** - * @ingroup CPUInterrupt - * The following defines the number of bits actually used in the - * interrupt field of the task mode. How those bits map to the - * CPU interrupt levels is defined by the routine @ref _CPU_ISR_Set_level. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_MODES_INTERRUPT_MASK 0x00000001 - -#define CPU_MAXIMUM_PROCESSORS 32 - -/* - * Processor defined structures required for cpukit/score. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ - -/* may need to put some structures here. */ - -/** - * @defgroup CPUContext Processor Dependent Context Management - * - * From the highest level viewpoint, there are 2 types of context to save. - * - * -# Interrupt registers to save - * -# Task level registers to save - * - * Since RTEMS handles integer and floating point contexts separately, this - * means we have the following 3 context items: - * - * -# task level context stuff:: Context_Control - * -# floating point task stuff:: Context_Control_fp - * -# special interrupt level context :: CPU_Interrupt_frame - * - * On some processors, it is cost-effective to save only the callee - * preserved registers during a task context switch. This means - * that the ISR code needs to save those registers which do not - * persist across function calls. It is not mandatory to make this - * distinctions between the caller/callee saves registers for the - * purpose of minimizing context saved during task switch and on interrupts. - * If the cost of saving extra registers is minimal, simplicity is the - * choice. Save the same context on interrupt entry as for tasks in - * this case. - * - * Additionally, if gdb is to be made aware of RTEMS tasks for this CPU, then - * care should be used in designing the context area. - * - * On some CPUs with hardware floating point support, the Context_Control_fp - * structure will not be used or it simply consist of an array of a - * fixed number of bytes. This is done when the floating point context - * is dumped by a "FP save context" type instruction and the format - * is not really defined by the CPU. In this case, there is no need - * to figure out the exact format -- only the size. Of course, although - * this is enough information for RTEMS, it is probably not enough for - * a debugger such as gdb. But that is another problem. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -/**@{**/ - -/** - * This defines the minimal set of integer and processor state registers - * that must be saved during a voluntary context switch from one thread - * to another. - */ -typedef struct { - uint32_t r11; - uint32_t r12; - uint32_t r13; - uint32_t r14; - uint32_t r15; - uint32_t r16; - uint32_t r17; - uint32_t r18; - uint32_t r19; - uint32_t r20; - uint32_t r21; - uint32_t r22; - uint32_t r23; - uint32_t r24; - uint32_t r25; - uint32_t gp; - uint32_t fp; - uint32_t sp; - uint32_t ra; - uint32_t ie; - uint32_t epc; -} Context_Control; - -/** - * - * This macro returns the stack pointer associated with @a _context. - * - * @param[in] _context is the thread context area to access - * - * @return This method returns the stack pointer. - */ -#define _CPU_Context_Get_SP( _context ) \ - (_context)->sp - -/** - * This defines the complete set of floating point registers that must - * be saved during any context switch from one thread to another. - */ -typedef struct { -} Context_Control_fp; - -/** - * This defines the set of integer and processor state registers that must - * be saved during an interrupt. This set does not include any which are - * in @ref Context_Control. - */ -typedef struct { - uint32_t r1; - uint32_t r2; - uint32_t r3; - uint32_t r4; - uint32_t r5; - uint32_t r6; - uint32_t r7; - uint32_t r8; - uint32_t r9; - uint32_t r10; - uint32_t ra; - uint32_t ba; - uint32_t ea; -} CPU_Interrupt_frame; - -/** - * This variable is optional. It is used on CPUs on which it is difficult - * to generate an "uninitialized" FP context. It is filled in by - * @ref _CPU_Initialize and copied into the task's FP context area during - * @ref _CPU_Context_Initialize. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#if 0 -extern Context_Control_fp _CPU_Null_fp_context; -#endif - -/** @} */ - -/** - * @defgroup CPUInterrupt Processor Dependent Interrupt Management - * - * On some CPUs, RTEMS supports a software managed interrupt stack. - * This stack is allocated by the Interrupt Manager and the switch - * is performed in @ref _ISR_Handler. These variables contain pointers - * to the lowest and highest addresses in the chunk of memory allocated - * for the interrupt stack. Since it is unknown whether the stack - * grows up or down (in general), this give the CPU dependent - * code the option of picking the version it wants to use. - * - * NOTE: These two variables are required if the macro - * @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK is defined as TRUE. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -/**@{**/ - -/* - * Nothing prevents the porter from declaring more CPU specific variables. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ - -/* XXX: if needed, put more variables here */ - -/** - * @ingroup CPUContext - * The size of the floating point context area. On some CPUs this - * will not be a "sizeof" because the format of the floating point - * area is not defined -- only the size is. This is usually on - * CPUs with a "floating point save context" instruction. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp ) - -/** - * Amount of extra stack (above minimum stack size) required by - * MPCI receive server thread. Remember that in a multiprocessor - * system this thread must exist and be able to process all directives. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0 - -/** - * This defines the number of entries in the @ref _ISR_Vector_table managed - * by RTEMS. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_INTERRUPT_NUMBER_OF_VECTORS 32 - -/** - * This defines the highest interrupt vector number for this port. - */ -#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER (CPU_INTERRUPT_NUMBER_OF_VECTORS - 1) - -/** - * This is defined if the port has a special way to report the ISR nesting - * level. Most ports maintain the variable @a _ISR_Nest_level. - */ -#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE - -/** @} */ - -/** - * @ingroup CPUContext - * Should be large enough to run all RTEMS tests. This ensures - * that a "reasonable" small application should not have any problems. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_STACK_MINIMUM_SIZE (1024*4) - -#define CPU_SIZEOF_POINTER 4 - -/** - * CPU's worst alignment requirement for data types on a byte boundary. This - * alignment does not take into account the requirements for the stack. - * - * Port Specific Information: - * The LM32 architecture manual simply states: "All memory accesses must be - * aligned to the size of the access", and there is no hardware support - * whatsoever for 64-bit numbers. - * (lm32_archman.pdf, July 2009, p. 15) - */ -#define CPU_ALIGNMENT 4 - -/** - * This number corresponds to the byte alignment requirement for the - * heap handler. This alignment requirement may be stricter than that - * for the data types alignment specified by @ref CPU_ALIGNMENT. It is - * common for the heap to follow the same alignment requirement as - * @ref CPU_ALIGNMENT. If the @ref CPU_ALIGNMENT is strict enough for - * the heap, then this should be set to @ref CPU_ALIGNMENT. - * - * NOTE: This does not have to be a power of 2 although it should be - * a multiple of 2 greater than or equal to 2. The requirement - * to be a multiple of 2 is because the heap uses the least - * significant field of the front and back flags to indicate - * that a block is in use or free. So you do not want any odd - * length blocks really putting length data in that bit. - * - * On byte oriented architectures, @ref CPU_HEAP_ALIGNMENT normally will - * have to be greater or equal to than @ref CPU_ALIGNMENT to ensure that - * elements allocated from the heap meet all restrictions. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT - -/** - * This number corresponds to the byte alignment requirement for memory - * buffers allocated by the partition manager. This alignment requirement - * may be stricter than that for the data types alignment specified by - * @ref CPU_ALIGNMENT. It is common for the partition to follow the same - * alignment requirement as @ref CPU_ALIGNMENT. If the @ref CPU_ALIGNMENT is - * strict enough for the partition, then this should be set to - * @ref CPU_ALIGNMENT. - * - * NOTE: This does not have to be a power of 2. It does have to - * be greater or equal to than @ref CPU_ALIGNMENT. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT - -/** - * This number corresponds to the byte alignment requirement for the - * stack. This alignment requirement may be stricter than that for the - * data types alignment specified by @ref CPU_ALIGNMENT. - * - * - * Port Specific Information: - * - * Stack is software-managed - */ -#define CPU_STACK_ALIGNMENT CPU_ALIGNMENT - -/* - * ISR handler macros - */ - -/** - * @addtogroup CPUInterrupt - */ -/**@{**/ - -/** - * Support routine to initialize the RTEMS vector table after it is allocated. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_Initialize_vectors() - -/** - * Disable all interrupts for an RTEMS critical section. The previous - * level is returned in @a _isr_cookie. - * - * @param[out] _isr_cookie will contain the previous level cookie - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_ISR_Disable( _isr_cookie ) \ - lm32_disable_interrupts( _isr_cookie ); - -/** - * Enable interrupts to the previous level (returned by _CPU_ISR_Disable). - * This indicates the end of an RTEMS critical section. The parameter - * @a _isr_cookie is not modified. - * - * @param[in] _isr_cookie contain the previous level cookie - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_ISR_Enable( _isr_cookie ) \ - lm32_enable_interrupts( _isr_cookie ); - -/** - * This temporarily restores the interrupt to @a _isr_cookie before immediately - * disabling them again. This is used to divide long RTEMS critical - * sections into two or more parts. The parameter @a _isr_cookie is not - * modified. - * - * @param[in] _isr_cookie contain the previous level cookie - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_ISR_Flash( _isr_cookie ) \ - lm32_flash_interrupts( _isr_cookie ); - -RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) -{ - return ( level & 0x0001 ) != 0; -} - -/** - * This routine and @ref _CPU_ISR_Get_level - * Map the interrupt level in task mode onto the hardware that the CPU - * actually provides. Currently, interrupt levels which do not - * map onto the CPU in a generic fashion are undefined. Someday, - * it would be nice if these were "mapped" by the application - * via a callout. For example, m68k has 8 levels 0 - 7, levels - * 8 - 255 would be available for bsp/application specific meaning. - * This could be used to manage a programmable interrupt controller - * via the rtems_task_mode directive. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_ISR_Set_level( new_level ) \ - { \ - _CPU_ISR_Enable( ( new_level==0 ) ? 1 : 0 ); \ - } - -/** - * Return the current interrupt disable level for this task in - * the format used by the interrupt level portion of the task mode. - * - * NOTE: This routine usually must be implemented as a subroutine. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -uint32_t _CPU_ISR_Get_level( void ); - -/* end of ISR handler macros */ - -/** @} */ - -/* Context handler macros */ - -/** - * @ingroup CPUContext - * Initialize the context to a state suitable for starting a - * task after a context restore operation. Generally, this - * involves: - * - * - setting a starting address - * - preparing the stack - * - preparing the stack and frame pointers - * - setting the proper interrupt level in the context - * - initializing the floating point context - * - * This routine generally does not set any unnecessary register - * in the context. The state of the "general data" registers is - * undefined at task start time. - * - * @param[in] _the_context is the context structure to be initialized - * @param[in] _stack_base is the lowest physical address of this task's stack - * @param[in] _size is the size of this task's stack - * @param[in] _isr is the interrupt disable level - * @param[in] _entry_point is the thread's entry point. This is - * always @a _Thread_Handler - * @param[in] _is_fp is TRUE if the thread is to be a floating - * point thread. This is typically only used on CPUs where the - * FPU may be easily disabled by software such as on the SPARC - * where the PSR contains an enable FPU bit. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -extern char _gp[]; - -#define _CPU_Context_Initialize( _the_context, _stack_base, _size, \ - _isr, _entry_point, _is_fp, _tls_area ) \ - do { \ - uint32_t _stack = (uint32_t)(_stack_base) + (_size) - 4; \ - \ - (void) _is_fp; /* avoid warning for being unused */ \ - (void) _isr; /* avoid warning for being unused */ \ - (_the_context)->gp = (uint32_t)_gp; \ - (_the_context)->fp = (uint32_t)_stack; \ - (_the_context)->sp = (uint32_t)_stack; \ - (_the_context)->ra = (uint32_t)(_entry_point); \ - } while ( 0 ) - -/** - * This routine is responsible for somehow restarting the currently - * executing task. If you are lucky, then all that is necessary - * is restoring the context. Otherwise, there will need to be - * a special assembly routine which does something special in this - * case. For many ports, simply adding a label to the restore path - * of @ref _CPU_Context_switch will work. On other ports, it may be - * possibly to load a few arguments and jump to the restore path. It will - * not work if restarting self conflicts with the stack frame - * assumptions of restoring a context. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_Context_Restart_self( _the_context ) \ - _CPU_Context_restore( (_the_context) ); - -/** - * This routine initializes the FP context area passed to it to. - * There are a few standard ways in which to initialize the - * floating point context. The code included for this macro assumes - * that this is a CPU in which a "initial" FP context was saved into - * @a _CPU_Null_fp_context and it simply copies it to the destination - * context passed to it. - * - * Other floating point context save/restore models include: - * -# not doing anything, and - * -# putting a "null FP status word" in the correct place in the FP context. - * - * @param[in] _destination is the floating point context area - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_Context_Initialize_fp( _destination ) -#if 0 - { \ - *(*(_destination)) = _CPU_Null_fp_context; \ - } -#endif - -/* end of Context handler macros */ - -/* Fatal Error manager macros */ - -/** - * This routine copies _error into a known place -- typically a stack - * location or a register, optionally disables interrupts, and - * halts/stops the CPU. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_Fatal_halt( _source, _error ) \ - { \ - } - -/* end of Fatal Error manager macros */ - -#define CPU_USE_GENERIC_BITFIELD_CODE TRUE - -/* functions */ - -/** - * This routine performs CPU dependent initialization. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_Initialize(void); - -/** - * @addtogroup CPUInterrupt - */ -/**@{**/ - -/** - * This routine installs a "raw" interrupt handler directly into the - * processor's vector table. - * - * @param[in] vector is the vector number - * @param[in] new_handler is the raw ISR handler to install - * @param[in] old_handler is the previously installed ISR Handler - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_ISR_install_raw_handler( - uint32_t vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -/** - * This routine installs an interrupt vector. - * - * @param[in] vector is the vector number - * @param[in] new_handler is the RTEMS ISR handler to install - * @param[in] old_handler is the previously installed ISR Handler - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_ISR_install_vector( - uint32_t vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -/** - * This routine installs the hardware interrupt stack pointer. - * - * NOTE: It need only be provided if @ref CPU_HAS_HARDWARE_INTERRUPT_STACK - * is TRUE. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_Install_interrupt_stack( void ); - -/** @} */ - -/** - * This routine is the CPU dependent IDLE thread body. - * - * NOTE: It need only be provided if @ref CPU_PROVIDES_IDLE_THREAD_BODY - * is TRUE. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void *_CPU_Thread_Idle_body( uintptr_t ignored ); - -/** - * @ingroup CPUContext - * This routine switches from the run context to the heir context. - * - * @param[in] run points to the context of the currently executing task - * @param[in] heir points to the context of the heir task - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_Context_switch( - Context_Control *run, - Context_Control *heir -); - -/** - * @addtogroup CPUContext - */ -/**@{**/ - -/** - * This routine is generally used only to restart self in an - * efficient manner. It may simply be a label in @ref _CPU_Context_switch. - * - * @param[in] new_context points to the context to be restored. - * - * NOTE: May be unnecessary to reload some registers. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_Context_restore( - Context_Control *new_context -) RTEMS_NO_RETURN; - -/** - * This routine saves the floating point context passed to it. - * - * @param[in] fp_context_ptr is a pointer to a pointer to a floating - * point context area - * - * @return on output @a *fp_context_ptr will contain the address that - * should be used with @ref _CPU_Context_restore_fp to restore this context. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_Context_save_fp( - Context_Control_fp **fp_context_ptr -); - -/** - * This routine restores the floating point context passed to it. - * - * @param[in] fp_context_ptr is a pointer to a pointer to a floating - * point context area to restore - * - * @return on output @a *fp_context_ptr will contain the address that - * should be used with @ref _CPU_Context_save_fp to save this context. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_Context_restore_fp( - Context_Control_fp **fp_context_ptr -); - -static inline void _CPU_Context_volatile_clobber( uintptr_t pattern ) -{ - /* TODO */ -} - -static inline void _CPU_Context_validate( uintptr_t pattern ) -{ - while (1) { - /* TODO */ - } -} - -/** @} */ - -/* FIXME */ -typedef CPU_Interrupt_frame CPU_Exception_frame; - -void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); - -/** - * @ingroup CPUEndian - * The following routine swaps the endian format of an unsigned int. - * It must be static because it is referenced indirectly. - * - * This version will work on any processor, but if there is a better - * way for your CPU PLEASE use it. The most common way to do this is to: - * - * swap least significant two bytes with 16-bit rotate - * swap upper and lower 16-bits - * swap most significant two bytes with 16-bit rotate - * - * Some CPUs have special instructions which swap a 32-bit quantity in - * a single instruction (e.g. i486). It is probably best to avoid - * an "endian swapping control bit" in the CPU. One good reason is - * that interrupts would probably have to be disabled to ensure that - * an interrupt does not try to access the same "chunk" with the wrong - * endian. Another good reason is that on some CPUs, the endian bit - * endianness for ALL fetches -- both code and data -- so the code - * will be fetched incorrectly. - * - * @param[in] value is the value to be swapped - * @return the value after being endian swapped - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -static inline uint32_t CPU_swap_u32( - uint32_t value -) -{ - uint32_t byte1, byte2, byte3, byte4, swapped; - - byte4 = (value >> 24) & 0xff; - byte3 = (value >> 16) & 0xff; - byte2 = (value >> 8) & 0xff; - byte1 = value & 0xff; - - swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4; - return swapped; -} - -/** - * @ingroup CPUEndian - * This routine swaps a 16 bir quantity. - * - * @param[in] value is the value to be swapped - * @return the value after being endian swapped - */ -static inline uint16_t CPU_swap_u16(uint16_t v) -{ - return v << 8 | v >> 8; -} - -typedef uint32_t CPU_Counter_ticks; - -CPU_Counter_ticks _CPU_Counter_read( void ); - -static inline CPU_Counter_ticks _CPU_Counter_difference( - CPU_Counter_ticks second, - CPU_Counter_ticks first -) -{ - return second - first; -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/score/cpu/lm32/rtems/score/cpu_asm.h b/cpukit/score/cpu/lm32/rtems/score/cpu_asm.h deleted file mode 100644 index 3909c1d608..0000000000 --- a/cpukit/score/cpu/lm32/rtems/score/cpu_asm.h +++ /dev/null @@ -1,74 +0,0 @@ -/** - * @file - * - * @brief LM32 CPU Assembly File - * - * Very loose template for an include file for the cpu_asm.? file - * if it is implemented as a ".S" file (preprocessed by cpp) instead - * of a ".s" file (preprocessed by gm4 or gasp). - */ - -/* - * COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - * - */ - -#ifndef _RTEMS_SCORE_CPU_ASM_H -#define _RTEMS_SCORE_CPU_ASM_H - -/* pull in the generated offsets */ - -/* -#include -*/ - -/* - * Hardware General Registers - */ - -/* put something here */ - -/* - * Hardware Floating Point Registers - */ - -/* put something here */ - -/* - * Hardware Control Registers - */ - -/* put something here */ - -/* - * Calling Convention - */ - -/* put something here */ - -/* - * Temporary registers - */ - -/* put something here */ - -/* - * Floating Point Registers - SW Conventions - */ - -/* put something here */ - -/* - * Temporary floating point registers - */ - -/* put something here */ - -#endif - -/* end of file */ diff --git a/cpukit/score/cpu/lm32/rtems/score/cpuatomic.h b/cpukit/score/cpu/lm32/rtems/score/cpuatomic.h deleted file mode 100644 index 598ee76b20..0000000000 --- a/cpukit/score/cpu/lm32/rtems/score/cpuatomic.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * COPYRIGHT (c) 2012-2013 Deng Hengyi. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_ATOMIC_CPU_H -#define _RTEMS_SCORE_ATOMIC_CPU_H - -#include - -#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/lm32/rtems/score/cpuimpl.h b/cpukit/score/cpu/lm32/rtems/score/cpuimpl.h deleted file mode 100644 index 789f2badd9..0000000000 --- a/cpukit/score/cpu/lm32/rtems/score/cpuimpl.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @file - * - * @brief CPU Port Implementation API - */ - -/* - * Copyright (c) 2013 embedded brains GmbH - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPUIMPL_H -#define _RTEMS_SCORE_CPUIMPL_H - -#include - -#define CPU_PER_CPU_CONTROL_SIZE 0 - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* ASM */ - -#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/lm32/rtems/score/lm32.h b/cpukit/score/cpu/lm32/rtems/score/lm32.h deleted file mode 100644 index e8fecdf2f6..0000000000 --- a/cpukit/score/cpu/lm32/rtems/score/lm32.h +++ /dev/null @@ -1,112 +0,0 @@ -/** - * @file - * - * @brief LM32 Set up Basic CPU Dependency Settings Based on Compiler Settings - * - * This file sets up basic CPU dependency settings based on - * compiler settings. For example, it can determine if - * floating point is available. This particular implementation - * is specified to the NO CPU port. - */ -/* - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - * - * Jukka Pietarinen , 2008, - * Micro-Research Finland Oy - */ - -#ifndef _RTEMS_SCORE_LM32_H -#define _RTEMS_SCORE_LM32_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This file contains the information required to build - * RTEMS for a particular member of the NO CPU family. - * It does this by setting variables to indicate which - * implementation dependent features are present in a particular - * member of the family. - * - * This is a good place to list all the known CPU models - * that this port supports and which RTEMS CPU model they correspond - * to. - */ - -#if defined(rtems_multilib) -/* - * Figure out all CPU Model Feature Flags based upon compiler - * predefines. - */ - -#define CPU_MODEL_NAME "rtems_multilib" -#define LM32_HAS_FPU 0 - -#elif defined(__lm32__) - -#define CPU_MODEL_NAME "lm32" -#define LM32_HAS_FPU 0 - -#else - -#error "Unsupported CPU Model" - -#endif - -/* - * Define the name of the CPU family. - */ - -#define CPU_NAME "LM32" - -#ifdef __cplusplus -} -#endif - -#define lm32_read_interrupts( _ip) \ - __asm__ volatile ("rcsr %0, ip":"=r"(_ip)); - -#define lm32_disable_interrupts( _level ) \ - do { register uint32_t ie; \ - __asm__ volatile ("rcsr %0,ie":"=r"(ie)); \ - (_level) = ie; \ - ie &= (~0x0001); \ - __asm__ volatile ("wcsr ie,%0"::"r"(ie)); \ - } while (0) - -#define lm32_enable_interrupts( _level ) \ - __asm__ volatile ("wcsr ie,%0"::"r"(_level)); - -#define lm32_flash_interrupts( _level ) \ - do { register uint32_t ie; \ - __asm__ volatile ("wcsr ie,%0"::"r"(_level)); \ - ie = (_level) & (~0x0001); \ - __asm__ volatile ("wcsr ie,%0"::"r"(ie)); \ - } while (0) - -#define lm32_interrupt_unmask( _mask ) \ - do { register uint32_t im; \ - __asm__ volatile ("rcsr %0,im":"=r"(im)); \ - im |= _mask; \ - __asm__ volatile ("wcsr im,%0"::"r"(im)); \ - } while (0) - -#define lm32_interrupt_mask( _mask ) \ - do { register uint32_t im; \ - __asm__ volatile ("rcsr %0,im":"=r"(im)); \ - im &= ~(_mask); \ - __asm__ volatile ("wcsr im,%0"::"r"(im)); \ - } while (0) - -#define lm32_interrupt_ack( _mask ) \ - do { register uint32_t ip = _mask; \ - __asm__ volatile ("wcsr ip,%0"::"r"(ip)); \ - } while (0) - -#endif /* _RTEMS_SCORE_LM32_H */ diff --git a/cpukit/score/cpu/lm32/rtems/score/types.h b/cpukit/score/cpu/lm32/rtems/score/types.h deleted file mode 100644 index c3d8666de4..0000000000 --- a/cpukit/score/cpu/lm32/rtems/score/types.h +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @file - * - * @brief LM32 CPU Type Definitions - * - * This include file contains type definitions pertaining to the - * Lattice lm32 processor family. - */ - -/* - * COPYRIGHT (c) 1989-2006. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - * - * Jukka Pietarinen , 2008, - * Micro-Research Finland Oy - */ - -#ifndef _RTEMS_SCORE_TYPES_H -#define _RTEMS_SCORE_TYPES_H - -#include - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This section defines the basic types for this processor. - */ - -/** Type that can store a 32-bit integer or a pointer. */ -typedef uintptr_t CPU_Uint32ptr; - -#ifdef __cplusplus -} -#endif - -#endif /* !ASM */ - -#endif diff --git a/cpukit/score/cpu/m32c/Makefile.am b/cpukit/score/cpu/m32c/Makefile.am index 993cf4b4d3..22bec7fce0 100644 --- a/cpukit/score/cpu/m32c/Makefile.am +++ b/cpukit/score/cpu/m32c/Makefile.am @@ -1,18 +1,5 @@ include $(top_srcdir)/automake/compile.am -include_HEADERS = varvects.h - -include_rtemsdir = $(includedir)/rtems -include_rtems_HEADERS = rtems/asm.h - -include_rtems_scoredir = $(includedir)/rtems/score -include_rtems_score_HEADERS = rtems/score/cpu.h -include_rtems_score_HEADERS += rtems/score/cpuimpl.h -include_rtems_score_HEADERS += rtems/score/m32c.h -include_rtems_score_HEADERS += rtems/score/cpu_asm.h -include_rtems_score_HEADERS += rtems/score/types.h -include_rtems_score_HEADERS += rtems/score/cpuatomic.h - noinst_LIBRARIES = libscorecpu.a libscorecpu_a_SOURCES = cpu.c cpu_asm.c context_switch.S context_init.c \ varvects.S @@ -20,5 +7,5 @@ libscorecpu_a_SOURCES += ../no_cpu/cpucounterread.c libscorecpu_a_SOURCES += m32c-exception-frame-print.c libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS) -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am +include $(srcdir)/headers.am diff --git a/cpukit/score/cpu/m32c/headers.am b/cpukit/score/cpu/m32c/headers.am new file mode 100644 index 0000000000..f67d070b88 --- /dev/null +++ b/cpukit/score/cpu/m32c/headers.am @@ -0,0 +1,17 @@ +## This file was generated by "./boostrap -H". + +include_HEADERS = +include_HEADERS += include/varvects.h + +include_rtemsdir = $(includedir)/rtems +include_rtems_HEADERS = +include_rtems_HEADERS += include/rtems/asm.h + +include_rtems_scoredir = $(includedir)/rtems/score +include_rtems_score_HEADERS = +include_rtems_score_HEADERS += include/rtems/score/cpu.h +include_rtems_score_HEADERS += include/rtems/score/cpu_asm.h +include_rtems_score_HEADERS += include/rtems/score/cpuatomic.h +include_rtems_score_HEADERS += include/rtems/score/cpuimpl.h +include_rtems_score_HEADERS += include/rtems/score/m32c.h +include_rtems_score_HEADERS += include/rtems/score/types.h diff --git a/cpukit/score/cpu/m32c/include/rtems/asm.h b/cpukit/score/cpu/m32c/include/rtems/asm.h new file mode 100644 index 0000000000..f3f244d066 --- /dev/null +++ b/cpukit/score/cpu/m32c/include/rtems/asm.h @@ -0,0 +1,124 @@ +/** + * @file + * + * @brief Address the Problems Caused by Incompatible Flavor of + * Assemblers and Toolsets + * + * This include file attempts to address the problems + * caused by incompatible flavors of assemblers and + * toolsets. It primarily addresses variations in the + * use of leading underscores on symbols and the requirement + * that register names be preceded by a %. + * + * NOTE: The spacing in the use of these macros + * is critical to them working as advertised. + */ + +/* + * COPYRIGHT: + * + * This file is based on similar code found in newlib available + * from ftp.cygnus.com. The file which was used had no copyright + * notice. This file is freely distributable as long as the source + * of the file is noted. This file is: + * + * COPYRIGHT (c) 1994-2006. + * On-Line Applications Research Corporation (OAR). + */ + +#ifndef _RTEMS_ASM_H +#define _RTEMS_ASM_H + +/* + * Indicate we are in an assembly file and get the basic CPU definitions. + */ + +#ifndef ASM +#define ASM +#endif +#include +#include + +#ifndef __USER_LABEL_PREFIX__ +/** + * Recent versions of GNU cpp define variables which indicate the + * need for underscores and percents. If not using GNU cpp or + * the version does not support this, then you will obviously + * have to define these as appropriate. + * + * This symbol is prefixed to all C program symbols. + */ +#define __USER_LABEL_PREFIX__ _ +#endif + +#ifndef __REGISTER_PREFIX__ +/** + * @see __USER_LABEL_PREFIX__ + * + * This symbol is prefixed to all register names. + */ +#define __REGISTER_PREFIX__ +#endif + +#include + +/** Use the right prefix for global labels. */ +#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) + +/** Use the right prefix for registers. */ +#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) + +/* + * define macros for all of the registers on this CPU + * + * EXAMPLE: #define d0 REG (d0) + */ + +/* + * Define macros to handle section beginning and ends. + */ + + +/** This macro is used to denote the beginning of a code declaration. */ +#define BEGIN_CODE_DCL .text +/** This macro is used to denote the end of a code declaration. */ +#define END_CODE_DCL +/** + * This macro is used to denote the beginning of a data declaration section. + */ +#define BEGIN_DATA_DCL .data +/** This macro is used to denote the end of a data declaration section. */ +#define END_DATA_DCL +/** This macro is used to denote the beginning of a code section. */ +#define BEGIN_CODE .text +/** This macro is used to denote the end of a code section. */ +#define END_CODE +/** This macro is used to denote the beginning of a data section. */ +#define BEGIN_DATA +/** This macro is used to denote the end of a data section. */ +#define END_DATA +/** This macro is used to denote the beginning of the + * unitialized data section. + */ +#define BEGIN_BSS +/** This macro is used to denote the end of the unitialized data section. */ +#define END_BSS +/** This macro is used to denote the end of the assembly file. */ +#define END + +/** + * This macro is used to declare a public global symbol. + * + * NOTE: This must be tailored for a particular flavor of the C compiler. + * They may need to put underscores in front of the symbols. + */ +#define PUBLIC(sym) .globl SYM (sym) + +/** + * This macro is used to prototype a public global symbol. + * + * @see PUBLIC(sym) .globl SYM (sym) + */ +#define EXTERN(sym) .globl SYM (sym) + +#endif diff --git a/cpukit/score/cpu/m32c/include/rtems/score/cpu.h b/cpukit/score/cpu/m32c/include/rtems/score/cpu.h new file mode 100644 index 0000000000..af1c3412ea --- /dev/null +++ b/cpukit/score/cpu/m32c/include/rtems/score/cpu.h @@ -0,0 +1,985 @@ +/** + * @file + * + * @brief M32C CPU Dependent Source + */ + +/* + * This include file contains information pertaining to the XXX + * processor. + * + * @note This file is part of a porting template that is intended + * to be used as the starting point when porting RTEMS to a new + * CPU family. The following needs to be done when using this as + * the starting point for a new port: + * + * + Anywhere there is an XXX, it should be replaced + * with information about the CPU family being ported to. + * + * + At the end of each comment section, there is a heading which + * says "Port Specific Information:". When porting to RTEMS, + * add CPU family specific information in this section + */ + +/* + * COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPU_H +#define _RTEMS_SCORE_CPU_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* conditional compilation parameters */ + +#define RTEMS_USE_16_BIT_OBJECT + +/** + * Does RTEMS manage a dedicated interrupt stack in software? + * + * If TRUE, then a stack is allocated in @ref _ISR_Handler_initialization. + * If FALSE, nothing is done. + * + * If the CPU supports a dedicated interrupt stack in hardware, + * then it is generally the responsibility of the BSP to allocate it + * and set it up. + * + * If the CPU does not support a dedicated interrupt stack, then + * the porter has two options: (1) execute interrupts on the + * stack of the interrupted task, and (2) have RTEMS manage a dedicated + * interrupt stack. + * + * If this is TRUE, @ref CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. + * + * Only one of @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK and + * @ref CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is + * possible that both are FALSE for a particular CPU. Although it + * is unclear what that would imply about the interrupt processing + * procedure on that CPU. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_HAS_SOFTWARE_INTERRUPT_STACK FALSE + +/** + * Does the CPU follow the simple vectored interrupt model? + * + * If TRUE, then RTEMS allocates the vector table it internally manages. + * If FALSE, then the BSP is assumed to allocate and manage the vector + * table + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_SIMPLE_VECTORED_INTERRUPTS TRUE + +/** + * Does this CPU have hardware support for a dedicated interrupt stack? + * + * If TRUE, then it must be installed during initialization. + * If FALSE, then no installation is performed. + * + * If this is TRUE, @ref CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. + * + * Only one of @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK and + * @ref CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is + * possible that both are FALSE for a particular CPU. Although it + * is unclear what that would imply about the interrupt processing + * procedure on that CPU. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_HAS_HARDWARE_INTERRUPT_STACK TRUE + +/** + * Does RTEMS allocate a dedicated interrupt stack in the Interrupt Manager? + * + * If TRUE, then the memory is allocated during initialization. + * If FALSE, then the memory is allocated during initialization. + * + * This should be TRUE is CPU_HAS_SOFTWARE_INTERRUPT_STACK is TRUE. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_ALLOCATE_INTERRUPT_STACK TRUE + +/** + * Does the RTEMS invoke the user's ISR with the vector number and + * a pointer to the saved interrupt frame (1) or just the vector + * number (0)? + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_ISR_PASSES_FRAME_POINTER FALSE + +/** + * @def CPU_HARDWARE_FP + * + * Does the CPU have hardware floating point? + * + * If TRUE, then the RTEMS_FLOATING_POINT task attribute is supported. + * If FALSE, then the RTEMS_FLOATING_POINT task attribute is ignored. + * + * If there is a FP coprocessor such as the i387 or mc68881, then + * the answer is TRUE. + * + * The macro name "M32C_HAS_FPU" should be made CPU specific. + * It indicates whether or not this CPU model has FP support. For + * example, it would be possible to have an i386_nofp CPU model + * which set this to false to indicate that you have an i386 without + * an i387 and wish to leave floating point support out of RTEMS. + */ + +/** + * @def CPU_SOFTWARE_FP + * + * Does the CPU have no hardware floating point and GCC provides a + * software floating point implementation which must be context + * switched? + * + * This feature conditional is used to indicate whether or not there + * is software implemented floating point that must be context + * switched. The determination of whether or not this applies + * is very tool specific and the state saved/restored is also + * compiler specific. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#if ( M32C_HAS_FPU == 1 ) +#define CPU_HARDWARE_FP TRUE +#else +#define CPU_HARDWARE_FP FALSE +#endif +#define CPU_SOFTWARE_FP FALSE + +#define CPU_CONTEXT_FP_SIZE 0 + +/** + * Are all tasks RTEMS_FLOATING_POINT tasks implicitly? + * + * If TRUE, then the RTEMS_FLOATING_POINT task attribute is assumed. + * If FALSE, then the RTEMS_FLOATING_POINT task attribute is followed. + * + * So far, the only CPUs in which this option has been used are the + * HP PA-RISC and PowerPC. On the PA-RISC, The HP C compiler and + * gcc both implicitly used the floating point registers to perform + * integer multiplies. Similarly, the PowerPC port of gcc has been + * seen to allocate floating point local variables and touch the FPU + * even when the flow through a subroutine (like vfprintf()) might + * not use floating point formats. + * + * If a function which you would not think utilize the FP unit DOES, + * then one can not easily predict which tasks will use the FP hardware. + * In this case, this option should be TRUE. + * + * If @ref CPU_HARDWARE_FP is FALSE, then this should be FALSE as well. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_ALL_TASKS_ARE_FP TRUE + +/** + * Should the IDLE task have a floating point context? + * + * If TRUE, then the IDLE task is created as a RTEMS_FLOATING_POINT task + * and it has a floating point context which is switched in and out. + * If FALSE, then the IDLE task does not have a floating point context. + * + * Setting this to TRUE negatively impacts the time required to preempt + * the IDLE task from an interrupt because the floating point context + * must be saved as part of the preemption. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_IDLE_TASK_IS_FP FALSE + +/** + * Should the saving of the floating point registers be deferred + * until a context switch is made to another different floating point + * task? + * + * If TRUE, then the floating point context will not be stored until + * necessary. It will remain in the floating point registers and not + * disturned until another floating point task is switched to. + * + * If FALSE, then the floating point context is saved when a floating + * point task is switched out and restored when the next floating point + * task is restored. The state of the floating point registers between + * those two operations is not specified. + * + * If the floating point context does NOT have to be saved as part of + * interrupt dispatching, then it should be safe to set this to TRUE. + * + * Setting this flag to TRUE results in using a different algorithm + * for deciding when to save and restore the floating point context. + * The deferred FP switch algorithm minimizes the number of times + * the FP context is saved and restored. The FP context is not saved + * until a context switch is made to another, different FP task. + * Thus in a system with only one FP task, the FP context will never + * be saved or restored. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_USE_DEFERRED_FP_SWITCH TRUE + +#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE + +/** + * Does this port provide a CPU dependent IDLE task implementation? + * + * If TRUE, then the routine @ref _CPU_Thread_Idle_body + * must be provided and is the default IDLE thread body instead of + * @ref _CPU_Thread_Idle_body. + * + * If FALSE, then use the generic IDLE thread body if the BSP does + * not provide one. + * + * This is intended to allow for supporting processors which have + * a low power or idle mode. When the IDLE thread is executed, then + * the CPU can be powered down. + * + * The order of precedence for selecting the IDLE thread body is: + * + * -# BSP provided + * -# CPU dependent (if provided) + * -# generic (if no BSP and no CPU dependent) + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_PROVIDES_IDLE_THREAD_BODY TRUE + +/** + * Does the stack grow up (toward higher addresses) or down + * (toward lower addresses)? + * + * If TRUE, then the grows upward. + * If FALSE, then the grows toward smaller addresses. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_STACK_GROWS_UP TRUE + +/* FIXME: Is this the right value? */ +#define CPU_CACHE_LINE_BYTES 2 + +#define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES ) + +/** + * @ingroup CPUInterrupt + * + * The following defines the number of bits actually used in the + * interrupt field of the task mode. How those bits map to the + * CPU interrupt levels is defined by the routine @ref _CPU_ISR_Set_level. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_MODES_INTERRUPT_MASK 0x00000001 + +#define CPU_MAXIMUM_PROCESSORS 32 + +/* + * Processor defined structures required for cpukit/score. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ + +/* may need to put some structures here. */ + +/** + * @defgroup CPUContext Processor Dependent Context Management + * + * From the highest level viewpoint, there are 2 types of context to save. + * + * -# Interrupt registers to save + * -# Task level registers to save + * + * Since RTEMS handles integer and floating point contexts separately, this + * means we have the following 3 context items: + * + * -# task level context stuff:: Context_Control + * -# floating point task stuff:: Context_Control_fp + * -# special interrupt level context :: CPU_Interrupt_frame + * + * On some processors, it is cost-effective to save only the callee + * preserved registers during a task context switch. This means + * that the ISR code needs to save those registers which do not + * persist across function calls. It is not mandatory to make this + * distinctions between the caller/callee saves registers for the + * purpose of minimizing context saved during task switch and on interrupts. + * If the cost of saving extra registers is minimal, simplicity is the + * choice. Save the same context on interrupt entry as for tasks in + * this case. + * + * Additionally, if gdb is to be made aware of RTEMS tasks for this CPU, then + * care should be used in designing the context area. + * + * On some CPUs with hardware floating point support, the Context_Control_fp + * structure will not be used or it simply consist of an array of a + * fixed number of bytes. This is done when the floating point context + * is dumped by a "FP save context" type instruction and the format + * is not really defined by the CPU. In this case, there is no need + * to figure out the exact format -- only the size. Of course, although + * this is enough information for RTEMS, it is probably not enough for + * a debugger such as gdb. But that is another problem. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +/**@{**/ + +/** + * @ingroup Management + * + * This defines the minimal set of integer and processor state registers + * that must be saved during a voluntary context switch from one thread + * to another. + */ +typedef struct { + /** This will contain the stack pointer. */ + uint32_t sp; + /** This will contain the frame base pointer. */ + uint32_t fb; +} Context_Control; + +/** + * @ingroup Management + * + * This macro returns the stack pointer associated with @a _context. + * + * @param[in] _context is the thread context area to access + * + * @return This method returns the stack pointer. + */ +#define _CPU_Context_Get_SP( _context ) \ + (_context)->sp + +/** + * @ingroup Management + * + * This defines the set of integer and processor state registers that must + * be saved during an interrupt. This set does not include any which are + * in @ref Context_Control. + */ +typedef struct { + /** + * This field is a hint that a port will have a number of integer + * registers that need to be saved when an interrupt occurs or + * when a context switch occurs at the end of an ISR. + */ + uint32_t special_interrupt_register; +} CPU_Interrupt_frame; + +/** @} */ + +/** + * @defgroup CPUInterrupt Processor Dependent Interrupt Management + * + * On some CPUs, RTEMS supports a software managed interrupt stack. + * This stack is allocated by the Interrupt Manager and the switch + * is performed in @ref _ISR_Handler. These variables contain pointers + * to the lowest and highest addresses in the chunk of memory allocated + * for the interrupt stack. Since it is unknown whether the stack + * grows up or down (in general), this give the CPU dependent + * code the option of picking the version it wants to use. + * + * NOTE: These two variables are required if the macro + * @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK is defined as TRUE. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + * + */ +/**@{**/ + +/* + * Nothing prevents the porter from declaring more CPU specific variables. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ + +/* XXX: if needed, put more variables here */ + +/** + * Amount of extra stack (above minimum stack size) required by + * MPCI receive server thread. Remember that in a multiprocessor + * system this thread must exist and be able to process all directives. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0 + +/** + * This defines the number of entries in the @ref _ISR_Vector_table managed + * by RTEMS. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_INTERRUPT_NUMBER_OF_VECTORS 32 + +/** This defines the highest interrupt vector number for this port. */ +#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER (CPU_INTERRUPT_NUMBER_OF_VECTORS - 1) + +/** + * This is defined if the port has a special way to report the ISR nesting + * level. Most ports maintain the variable @a _ISR_Nest_level. + */ +#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE + +/** @} */ + +/** + * @ingroup CPUContext + * + * Should be large enough to run all RTEMS tests. This ensures + * that a "reasonable" small application should not have any problems. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_STACK_MINIMUM_SIZE (2048L) + +#ifdef __m32cm_cpu__ + #define CPU_SIZEOF_POINTER 4 +#else + #define CPU_SIZEOF_POINTER 2 +#endif + +/** + * CPU's worst alignment requirement for data types on a byte boundary. This + * alignment does not take into account the requirements for the stack. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_ALIGNMENT 2 + +/** + * This number corresponds to the byte alignment requirement for the + * heap handler. This alignment requirement may be stricter than that + * for the data types alignment specified by @ref CPU_ALIGNMENT. It is + * common for the heap to follow the same alignment requirement as + * @ref CPU_ALIGNMENT. If the @ref CPU_ALIGNMENT is strict enough for + * the heap, then this should be set to @ref CPU_ALIGNMENT. + * + * NOTE: This does not have to be a power of 2 although it should be + * a multiple of 2 greater than or equal to 2. The requirement + * to be a multiple of 2 is because the heap uses the least + * significant field of the front and back flags to indicate + * that a block is in use or free. So you do not want any odd + * length blocks really putting length data in that bit. + * + * On byte oriented architectures, @ref CPU_HEAP_ALIGNMENT normally will + * have to be greater or equal to than @ref CPU_ALIGNMENT to ensure that + * elements allocated from the heap meet all restrictions. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_HEAP_ALIGNMENT 4 + +/** + * This number corresponds to the byte alignment requirement for memory + * buffers allocated by the partition manager. This alignment requirement + * may be stricter than that for the data types alignment specified by + * @ref CPU_ALIGNMENT. It is common for the partition to follow the same + * alignment requirement as @ref CPU_ALIGNMENT. If the @ref CPU_ALIGNMENT is + * strict enough for the partition, then this should be set to + * @ref CPU_ALIGNMENT. + * + * NOTE: This does not have to be a power of 2. It does have to + * be greater or equal to than @ref CPU_ALIGNMENT. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT + +/** + * This number corresponds to the byte alignment requirement for the + * stack. This alignment requirement may be stricter than that for the + * data types alignment specified by @ref CPU_ALIGNMENT. If the + * @ref CPU_ALIGNMENT is strict enough for the stack, then this should be + * set to 0. + * + * NOTE: This must be a power of 2 either 0 or greater than @ref CPU_ALIGNMENT. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_STACK_ALIGNMENT 0 + +/* + * ISR handler macros + */ + +/** + * @ingroup CPUInterrupt + * + * Support routine to initialize the RTEMS vector table after it is allocated. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_Initialize_vectors() + +/** + * @ingroup CPUInterrupt + * + * Disable all interrupts for an RTEMS critical section. The previous + * level is returned in @a _isr_cookie. + * + * @param[out] _isr_cookie will contain the previous level cookie + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_ISR_Disable( _isr_cookie ) \ + do { \ + int _flg; \ + m32c_get_flg( _flg ); \ + _isr_cookie = _flg; \ + __asm__ volatile( "fclr I" ); \ + } while(0) + +/** + * @ingroup CPUInterrupt + * + * Enable interrupts to the previous level (returned by _CPU_ISR_Disable). + * This indicates the end of an RTEMS critical section. The parameter + * @a _isr_cookie is not modified. + * + * @param[in] _isr_cookie contain the previous level cookie + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_ISR_Enable(_isr_cookie) \ + do { \ + int _flg = (int) (_isr_cookie); \ + m32c_set_flg( _flg ); \ + } while(0) + +/** + * @ingroup CPUInterrupt + * + * This temporarily restores the interrupt to @a _isr_cookie before immediately + * disabling them again. This is used to divide long RTEMS critical + * sections into two or more parts. The parameter @a _isr_cookie is not + * modified. + * + * @param[in] _isr_cookie contain the previous level cookie + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_ISR_Flash( _isr_cookie ) \ + do { \ + int _flg = (int) (_isr_cookie); \ + m32c_set_flg( _flg ); \ + __asm__ volatile( "fclr I" ); \ + } while(0) + +RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) +{ + return ( level & 0x40 ) != 0; +} + +/** + * @ingroup CPUInterrupt + * + * This routine and @ref _CPU_ISR_Get_level + * Map the interrupt level in task mode onto the hardware that the CPU + * actually provides. Currently, interrupt levels which do not + * map onto the CPU in a generic fashion are undefined. Someday, + * it would be nice if these were "mapped" by the application + * via a callout. For example, m68k has 8 levels 0 - 7, levels + * 8 - 255 would be available for bsp/application specific meaning. + *This could be used to manage a programmable interrupt controller + * via the rtems_task_mode directive. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_ISR_Set_level( _new_level ) \ + do { \ + if (_new_level) __asm__ volatile( "fclr I" ); \ + else __asm__ volatile( "fset I" ); \ + } while(0) + +/** + * @ingroup CPUInterrupt + * + * Return the current interrupt disable level for this task in + * the format used by the interrupt level portion of the task mode. + * + * NOTE: This routine usually must be implemented as a subroutine. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +uint32_t _CPU_ISR_Get_level( void ); + +/* end of ISR handler macros */ + +/* Context handler macros */ + +/** + * @ingroup CPUContext + * + * Initialize the context to a state suitable for starting a + * task after a context restore operation. Generally, this + * involves: + * + * - setting a starting address + * - preparing the stack + * - preparing the stack and frame pointers + * - setting the proper interrupt level in the context + * - initializing the floating point context + * + * This routine generally does not set any unnecessary register + * in the context. The state of the "general data" registers is + * undefined at task start time. + * + * @param[in] _the_context is the context structure to be initialized + * @param[in] _stack_base is the lowest physical address of this task's stack + * @param[in] _size is the size of this task's stack + * @param[in] _isr is the interrupt disable level + * @param[in] _entry_point is the thread's entry point. This is + * always @a _Thread_Handler + * @param[in] _is_fp is TRUE if the thread is to be a floating + * point thread. This is typically only used on CPUs where the + * FPU may be easily disabled by software such as on the SPARC + * where the PSR contains an enable FPU bit. + * @param[in] tls_area is the thread-local storage (TLS) area + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_Context_Initialize( + Context_Control *the_context, + uint32_t *stack_base, + size_t size, + uint32_t new_level, + void *entry_point, + bool is_fp, + void *tls_area +); + +/** + * This routine is responsible for somehow restarting the currently + * executing task. If you are lucky, then all that is necessary + * is restoring the context. Otherwise, there will need to be + * a special assembly routine which does something special in this + * case. For many ports, simply adding a label to the restore path + * of @ref _CPU_Context_switch will work. On other ports, it may be + * possibly to load a few arguments and jump to the restore path. It will + * not work if restarting self conflicts with the stack frame + * assumptions of restoring a context. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_Context_Restart_self( + Context_Control *the_context +) RTEMS_NO_RETURN; + +/** + * This routine initializes the FP context area passed to it to. + * There are a few standard ways in which to initialize the + * floating point context. The code included for this macro assumes + * that this is a CPU in which a "initial" FP context was saved into + * @a _CPU_Null_fp_context and it simply copies it to the destination + * context passed to it. + * + * Other floating point context save/restore models include: + * -# not doing anything, and + * -# putting a "null FP status word" in the correct place in the FP context. + * + * @param[in] _destination is the floating point context area + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_Context_Initialize_fp( _destination ) \ + { \ + *(*(_destination)) = _CPU_Null_fp_context; \ + } + +/* end of Context handler macros */ + +/* Fatal Error manager macros */ + +/** + * This routine copies _error into a known place -- typically a stack + * location or a register, optionally disables interrupts, and + * halts/stops the CPU. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_Fatal_halt( _source, _error ) \ + { \ + } + +/* end of Fatal Error manager macros */ + +#define CPU_USE_GENERIC_BITFIELD_CODE TRUE + +/* functions */ + +/** + * This routine performs CPU dependent initialization. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_Initialize(void); + +/** + * @ingroup CPUInterrupt + * + * This routine installs a "raw" interrupt handler directly into the + * processor's vector table. + * + * @param[in] vector is the vector number + * @param[in] new_handler is the raw ISR handler to install + * @param[in] old_handler is the previously installed ISR Handler + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_ISR_install_raw_handler( + uint32_t vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +/** + * @ingroup CPUInterrupt + * + * This routine installs an interrupt vector. + * + * @param[in] vector is the vector number + * @param[in] new_handler is the RTEMS ISR handler to install + * @param[in] old_handler is the previously installed ISR Handler + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_ISR_install_vector( + uint32_t vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +/** + * @ingroup CPUInterrupt + * + * This routine installs the hardware interrupt stack pointer. + * + * NOTE: It need only be provided if @ref CPU_HAS_HARDWARE_INTERRUPT_STACK + * is TRUE. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_Install_interrupt_stack( void ); + +/** + * This routine is the CPU dependent IDLE thread body. + * + * NOTE: It need only be provided if @ref CPU_PROVIDES_IDLE_THREAD_BODY + * is TRUE. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void *_CPU_Thread_Idle_body( uintptr_t ignored ); + +/** + * @ingroup CPUContext + * + * This routine switches from the run context to the heir context. + * + * @param[in] run points to the context of the currently executing task + * @param[in] heir points to the context of the heir task + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_Context_switch( + Context_Control *run, + Context_Control *heir +); + +/** + * @ingroup CPUContext + * + * This routine is generally used only to restart self in an + * efficient manner. It may simply be a label in @ref _CPU_Context_switch. + * + * @param[in] new_context points to the context to be restored. + * + * NOTE: May be unnecessary to reload some registers. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_Context_restore( + Context_Control *new_context +) RTEMS_NO_RETURN; + +static inline void _CPU_Context_volatile_clobber( uintptr_t pattern ) +{ + /* TODO */ +} + +static inline void _CPU_Context_validate( uintptr_t pattern ) +{ + while (1) { + /* TODO */ + } +} + +/* FIXME */ +typedef CPU_Interrupt_frame CPU_Exception_frame; + +void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); + +/** + * @ingroup CPUEndian + * + * The following routine swaps the endian format of an unsigned int. + * It must be static because it is referenced indirectly. + * + * This version will work on any processor, but if there is a better + * way for your CPU PLEASE use it. The most common way to do this is to: + * + * swap least significant two bytes with 16-bit rotate + * swap upper and lower 16-bits + * swap most significant two bytes with 16-bit rotate + * + * Some CPUs have special instructions which swap a 32-bit quantity in + * a single instruction (e.g. i486). It is probably best to avoid + * an "endian swapping control bit" in the CPU. One good reason is + * that interrupts would probably have to be disabled to ensure that + * an interrupt does not try to access the same "chunk" with the wrong + * endian. Another good reason is that on some CPUs, the endian bit + * endianness for ALL fetches -- both code and data -- so the code + * will be fetched incorrectly. + * + * @param[in] value is the value to be swapped + * @return the value after being endian swapped + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +static inline uint32_t CPU_swap_u32( + uint32_t value +) +{ + uint32_t byte1, byte2, byte3, byte4, swapped; + + byte4 = (value >> 24) & 0xff; + byte3 = (value >> 16) & 0xff; + byte2 = (value >> 8) & 0xff; + byte1 = value & 0xff; + + swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4; + return swapped; +} + +/** + * @ingroup CPUEndian + * + * This routine swaps a 16 bir quantity. + * + * @param[in] value is the value to be swapped + * @return the value after being endian swapped + */ +#define CPU_swap_u16( value ) \ + (((value&0xff) << 8) | ((value >> 8)&0xff)) + +typedef uint32_t CPU_Counter_ticks; + +CPU_Counter_ticks _CPU_Counter_read( void ); + +static inline CPU_Counter_ticks _CPU_Counter_difference( + CPU_Counter_ticks second, + CPU_Counter_ticks first +) +{ + return second - first; +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/score/cpu/m32c/include/rtems/score/cpu_asm.h b/cpukit/score/cpu/m32c/include/rtems/score/cpu_asm.h new file mode 100644 index 0000000000..451c022d75 --- /dev/null +++ b/cpukit/score/cpu/m32c/include/rtems/score/cpu_asm.h @@ -0,0 +1,72 @@ +/** + * @file + * + * @brief M32C CPU Assembly File + * + * Very loose template for an include file for the cpu_asm.? file + * if it is implemented as a ".S" file (preprocessed by cpp) instead + * of a ".s" file (preprocessed by gm4 or gasp). + */ + +/* + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + */ + +#ifndef _RTEMS_SCORE_CPU_ASM_H +#define _RTEMS_SCORE_CPU_ASM_H + +/* pull in the generated offsets */ + +#include + +/* + * Hardware General Registers + */ + +/* put something here */ + +/* + * Hardware Floating Point Registers + */ + +/* put something here */ + +/* + * Hardware Control Registers + */ + +/* put something here */ + +/* + * Calling Convention + */ + +/* put something here */ + +/* + * Temporary registers + */ + +/* put something here */ + +/* + * Floating Point Registers - SW Conventions + */ + +/* put something here */ + +/* + * Temporary floating point registers + */ + +/* put something here */ + +#endif + +/* end of file */ diff --git a/cpukit/score/cpu/m32c/include/rtems/score/cpuatomic.h b/cpukit/score/cpu/m32c/include/rtems/score/cpuatomic.h new file mode 100644 index 0000000000..598ee76b20 --- /dev/null +++ b/cpukit/score/cpu/m32c/include/rtems/score/cpuatomic.h @@ -0,0 +1,14 @@ +/* + * COPYRIGHT (c) 2012-2013 Deng Hengyi. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_ATOMIC_CPU_H +#define _RTEMS_SCORE_ATOMIC_CPU_H + +#include + +#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/m32c/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/m32c/include/rtems/score/cpuimpl.h new file mode 100644 index 0000000000..789f2badd9 --- /dev/null +++ b/cpukit/score/cpu/m32c/include/rtems/score/cpuimpl.h @@ -0,0 +1,34 @@ +/** + * @file + * + * @brief CPU Port Implementation API + */ + +/* + * Copyright (c) 2013 embedded brains GmbH + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPUIMPL_H +#define _RTEMS_SCORE_CPUIMPL_H + +#include + +#define CPU_PER_CPU_CONTROL_SIZE 0 + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ASM */ + +#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/m32c/include/rtems/score/m32c.h b/cpukit/score/cpu/m32c/include/rtems/score/m32c.h new file mode 100644 index 0000000000..e1936fdcfb --- /dev/null +++ b/cpukit/score/cpu/m32c/include/rtems/score/m32c.h @@ -0,0 +1,76 @@ +/** + * @file + * + * @brief M32C Set up Basic CPU Dependency Settings Based on Compiler Settings + * + * This file sets up basic CPU dependency settings based on + * compiler settings. For example, it can determine if + * floating point is available. This particular implementation + * is specified to the NO CPU port. + */ + +/* + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_NO_CPU_H +#define _RTEMS_SCORE_NO_CPU_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This file contains the information required to build + * RTEMS for a particular member of the NO CPU family. + * It does this by setting variables to indicate which + * implementation dependent features are present in a particular + * member of the family. + * + * This is a good place to list all the known CPU models + * that this port supports and which RTEMS CPU model they correspond + * to. + */ + +#if defined(rtems_multilib) +/* + * Figure out all CPU Model Feature Flags based upon compiler + * predefines. + */ + +#define CPU_MODEL_NAME "rtems_multilib" +#define NOCPU_HAS_FPU 1 + +#elif defined(__m32c__) + +#define CPU_MODEL_NAME "m32c" +#define M32C_HAS_FPU 0 + +#else + +#error "Unsupported CPU Model" + +#endif + +/* + * Define the name of the CPU family. + */ + +#define CPU_NAME "m32c" + +#define m32c_get_flg( _flg ) \ + __asm__ volatile( "stc flg, %0" : "=r" (_flg)) + +#define m32c_set_flg( _flg ) \ + __asm__ volatile( "ldc %1, flg" : "=r" (_flg) : "r" (_flg) ) + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_SCORE_NO_CPU_H */ diff --git a/cpukit/score/cpu/m32c/include/rtems/score/types.h b/cpukit/score/cpu/m32c/include/rtems/score/types.h new file mode 100644 index 0000000000..99d8297143 --- /dev/null +++ b/cpukit/score/cpu/m32c/include/rtems/score/types.h @@ -0,0 +1,49 @@ +/** + * @file + * + * @brief M32C CPU Type Definitions + * + * This include file contains type definitions pertaining to the Intel + * m32c processor family. + */ + +/* + * COPYRIGHT (c) 1989-2006. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_TYPES_H +#define _RTEMS_SCORE_TYPES_H + +#include + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This section defines the basic types for this processor. + */ + +/** Type that can store a 32-bit integer or a pointer. */ +typedef unsigned long CPU_Uint32ptr; + +/** This defines the return type for an ISR entry point. */ +typedef void m32c_isr; + +/** This defines the prototype for an ISR entry point. */ +typedef m32c_isr ( *m32c_isr_entry )( void ); + +#ifdef __cplusplus +} +#endif + +#endif /* !ASM */ + +#endif diff --git a/cpukit/score/cpu/m32c/include/varvects.h b/cpukit/score/cpu/m32c/include/varvects.h new file mode 100644 index 0000000000..7168482b54 --- /dev/null +++ b/cpukit/score/cpu/m32c/include/varvects.h @@ -0,0 +1,58 @@ +/** + * @file + * + * @brief M32C Built-in Variable Vector Table Interface + * + * This file defines the interface to the built-in variable vector + * table in R8C/M16C/M32C chips. + */ + +/* + * Copyright (c) 2008 Red Hat Incorporated. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * The name of Red Hat Incorporated may not be used to endorse + * or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _VARVECTS_H_ +#define _VARVECTS_H_ + +typedef void (*_m32c_interrupt_func)(void) __attribute__((mode(SI))); +extern _m32c_interrupt_func _var_vects[]; + +#if defined(__r8c_cpu__) || defined (__m16c_cpu__) + +#define _set_var_vect(f,n) \ + { __asm__ ("mov.w #%%lo16(%d0),__var_vects+%d1" : : "s" (f), "g" (n*4)); \ + __asm__ ("mov.w #%%hi16(%d0),__var_vects+%d1" : : "s" (f), "g" (n*4+2)); } + +#else + +#define _set_var_vect(f,n) \ + _var_vects[n] = f + +#endif +#endif diff --git a/cpukit/score/cpu/m32c/preinstall.am b/cpukit/score/cpu/m32c/preinstall.am deleted file mode 100644 index 3e12ca477d..0000000000 --- a/cpukit/score/cpu/m32c/preinstall.am +++ /dev/null @@ -1,62 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -$(PROJECT_INCLUDE)/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE) - @: > $(PROJECT_INCLUDE)/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/$(dirstamp) - -$(PROJECT_INCLUDE)/varvects.h: varvects.h $(PROJECT_INCLUDE)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/varvects.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/varvects.h - -$(PROJECT_INCLUDE)/rtems/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems - @: > $(PROJECT_INCLUDE)/rtems/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/asm.h: rtems/asm.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/asm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/asm.h - -$(PROJECT_INCLUDE)/rtems/score/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/score - @: > $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/score/cpu.h: rtems/score/cpu.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpu.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpu.h - -$(PROJECT_INCLUDE)/rtems/score/cpuimpl.h: rtems/score/cpuimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h - -$(PROJECT_INCLUDE)/rtems/score/m32c.h: rtems/score/m32c.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/m32c.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/m32c.h - -$(PROJECT_INCLUDE)/rtems/score/cpu_asm.h: rtems/score/cpu_asm.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpu_asm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpu_asm.h - -$(PROJECT_INCLUDE)/rtems/score/types.h: rtems/score/types.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/types.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/types.h - -$(PROJECT_INCLUDE)/rtems/score/cpuatomic.h: rtems/score/cpuatomic.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h - diff --git a/cpukit/score/cpu/m32c/rtems/asm.h b/cpukit/score/cpu/m32c/rtems/asm.h deleted file mode 100644 index f3f244d066..0000000000 --- a/cpukit/score/cpu/m32c/rtems/asm.h +++ /dev/null @@ -1,124 +0,0 @@ -/** - * @file - * - * @brief Address the Problems Caused by Incompatible Flavor of - * Assemblers and Toolsets - * - * This include file attempts to address the problems - * caused by incompatible flavors of assemblers and - * toolsets. It primarily addresses variations in the - * use of leading underscores on symbols and the requirement - * that register names be preceded by a %. - * - * NOTE: The spacing in the use of these macros - * is critical to them working as advertised. - */ - -/* - * COPYRIGHT: - * - * This file is based on similar code found in newlib available - * from ftp.cygnus.com. The file which was used had no copyright - * notice. This file is freely distributable as long as the source - * of the file is noted. This file is: - * - * COPYRIGHT (c) 1994-2006. - * On-Line Applications Research Corporation (OAR). - */ - -#ifndef _RTEMS_ASM_H -#define _RTEMS_ASM_H - -/* - * Indicate we are in an assembly file and get the basic CPU definitions. - */ - -#ifndef ASM -#define ASM -#endif -#include -#include - -#ifndef __USER_LABEL_PREFIX__ -/** - * Recent versions of GNU cpp define variables which indicate the - * need for underscores and percents. If not using GNU cpp or - * the version does not support this, then you will obviously - * have to define these as appropriate. - * - * This symbol is prefixed to all C program symbols. - */ -#define __USER_LABEL_PREFIX__ _ -#endif - -#ifndef __REGISTER_PREFIX__ -/** - * @see __USER_LABEL_PREFIX__ - * - * This symbol is prefixed to all register names. - */ -#define __REGISTER_PREFIX__ -#endif - -#include - -/** Use the right prefix for global labels. */ -#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) - -/** Use the right prefix for registers. */ -#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) - -/* - * define macros for all of the registers on this CPU - * - * EXAMPLE: #define d0 REG (d0) - */ - -/* - * Define macros to handle section beginning and ends. - */ - - -/** This macro is used to denote the beginning of a code declaration. */ -#define BEGIN_CODE_DCL .text -/** This macro is used to denote the end of a code declaration. */ -#define END_CODE_DCL -/** - * This macro is used to denote the beginning of a data declaration section. - */ -#define BEGIN_DATA_DCL .data -/** This macro is used to denote the end of a data declaration section. */ -#define END_DATA_DCL -/** This macro is used to denote the beginning of a code section. */ -#define BEGIN_CODE .text -/** This macro is used to denote the end of a code section. */ -#define END_CODE -/** This macro is used to denote the beginning of a data section. */ -#define BEGIN_DATA -/** This macro is used to denote the end of a data section. */ -#define END_DATA -/** This macro is used to denote the beginning of the - * unitialized data section. - */ -#define BEGIN_BSS -/** This macro is used to denote the end of the unitialized data section. */ -#define END_BSS -/** This macro is used to denote the end of the assembly file. */ -#define END - -/** - * This macro is used to declare a public global symbol. - * - * NOTE: This must be tailored for a particular flavor of the C compiler. - * They may need to put underscores in front of the symbols. - */ -#define PUBLIC(sym) .globl SYM (sym) - -/** - * This macro is used to prototype a public global symbol. - * - * @see PUBLIC(sym) .globl SYM (sym) - */ -#define EXTERN(sym) .globl SYM (sym) - -#endif diff --git a/cpukit/score/cpu/m32c/rtems/score/cpu.h b/cpukit/score/cpu/m32c/rtems/score/cpu.h deleted file mode 100644 index af1c3412ea..0000000000 --- a/cpukit/score/cpu/m32c/rtems/score/cpu.h +++ /dev/null @@ -1,985 +0,0 @@ -/** - * @file - * - * @brief M32C CPU Dependent Source - */ - -/* - * This include file contains information pertaining to the XXX - * processor. - * - * @note This file is part of a porting template that is intended - * to be used as the starting point when porting RTEMS to a new - * CPU family. The following needs to be done when using this as - * the starting point for a new port: - * - * + Anywhere there is an XXX, it should be replaced - * with information about the CPU family being ported to. - * - * + At the end of each comment section, there is a heading which - * says "Port Specific Information:". When porting to RTEMS, - * add CPU family specific information in this section - */ - -/* - * COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPU_H -#define _RTEMS_SCORE_CPU_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/* conditional compilation parameters */ - -#define RTEMS_USE_16_BIT_OBJECT - -/** - * Does RTEMS manage a dedicated interrupt stack in software? - * - * If TRUE, then a stack is allocated in @ref _ISR_Handler_initialization. - * If FALSE, nothing is done. - * - * If the CPU supports a dedicated interrupt stack in hardware, - * then it is generally the responsibility of the BSP to allocate it - * and set it up. - * - * If the CPU does not support a dedicated interrupt stack, then - * the porter has two options: (1) execute interrupts on the - * stack of the interrupted task, and (2) have RTEMS manage a dedicated - * interrupt stack. - * - * If this is TRUE, @ref CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. - * - * Only one of @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK and - * @ref CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is - * possible that both are FALSE for a particular CPU. Although it - * is unclear what that would imply about the interrupt processing - * procedure on that CPU. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_HAS_SOFTWARE_INTERRUPT_STACK FALSE - -/** - * Does the CPU follow the simple vectored interrupt model? - * - * If TRUE, then RTEMS allocates the vector table it internally manages. - * If FALSE, then the BSP is assumed to allocate and manage the vector - * table - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_SIMPLE_VECTORED_INTERRUPTS TRUE - -/** - * Does this CPU have hardware support for a dedicated interrupt stack? - * - * If TRUE, then it must be installed during initialization. - * If FALSE, then no installation is performed. - * - * If this is TRUE, @ref CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. - * - * Only one of @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK and - * @ref CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is - * possible that both are FALSE for a particular CPU. Although it - * is unclear what that would imply about the interrupt processing - * procedure on that CPU. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_HAS_HARDWARE_INTERRUPT_STACK TRUE - -/** - * Does RTEMS allocate a dedicated interrupt stack in the Interrupt Manager? - * - * If TRUE, then the memory is allocated during initialization. - * If FALSE, then the memory is allocated during initialization. - * - * This should be TRUE is CPU_HAS_SOFTWARE_INTERRUPT_STACK is TRUE. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_ALLOCATE_INTERRUPT_STACK TRUE - -/** - * Does the RTEMS invoke the user's ISR with the vector number and - * a pointer to the saved interrupt frame (1) or just the vector - * number (0)? - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_ISR_PASSES_FRAME_POINTER FALSE - -/** - * @def CPU_HARDWARE_FP - * - * Does the CPU have hardware floating point? - * - * If TRUE, then the RTEMS_FLOATING_POINT task attribute is supported. - * If FALSE, then the RTEMS_FLOATING_POINT task attribute is ignored. - * - * If there is a FP coprocessor such as the i387 or mc68881, then - * the answer is TRUE. - * - * The macro name "M32C_HAS_FPU" should be made CPU specific. - * It indicates whether or not this CPU model has FP support. For - * example, it would be possible to have an i386_nofp CPU model - * which set this to false to indicate that you have an i386 without - * an i387 and wish to leave floating point support out of RTEMS. - */ - -/** - * @def CPU_SOFTWARE_FP - * - * Does the CPU have no hardware floating point and GCC provides a - * software floating point implementation which must be context - * switched? - * - * This feature conditional is used to indicate whether or not there - * is software implemented floating point that must be context - * switched. The determination of whether or not this applies - * is very tool specific and the state saved/restored is also - * compiler specific. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#if ( M32C_HAS_FPU == 1 ) -#define CPU_HARDWARE_FP TRUE -#else -#define CPU_HARDWARE_FP FALSE -#endif -#define CPU_SOFTWARE_FP FALSE - -#define CPU_CONTEXT_FP_SIZE 0 - -/** - * Are all tasks RTEMS_FLOATING_POINT tasks implicitly? - * - * If TRUE, then the RTEMS_FLOATING_POINT task attribute is assumed. - * If FALSE, then the RTEMS_FLOATING_POINT task attribute is followed. - * - * So far, the only CPUs in which this option has been used are the - * HP PA-RISC and PowerPC. On the PA-RISC, The HP C compiler and - * gcc both implicitly used the floating point registers to perform - * integer multiplies. Similarly, the PowerPC port of gcc has been - * seen to allocate floating point local variables and touch the FPU - * even when the flow through a subroutine (like vfprintf()) might - * not use floating point formats. - * - * If a function which you would not think utilize the FP unit DOES, - * then one can not easily predict which tasks will use the FP hardware. - * In this case, this option should be TRUE. - * - * If @ref CPU_HARDWARE_FP is FALSE, then this should be FALSE as well. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_ALL_TASKS_ARE_FP TRUE - -/** - * Should the IDLE task have a floating point context? - * - * If TRUE, then the IDLE task is created as a RTEMS_FLOATING_POINT task - * and it has a floating point context which is switched in and out. - * If FALSE, then the IDLE task does not have a floating point context. - * - * Setting this to TRUE negatively impacts the time required to preempt - * the IDLE task from an interrupt because the floating point context - * must be saved as part of the preemption. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_IDLE_TASK_IS_FP FALSE - -/** - * Should the saving of the floating point registers be deferred - * until a context switch is made to another different floating point - * task? - * - * If TRUE, then the floating point context will not be stored until - * necessary. It will remain in the floating point registers and not - * disturned until another floating point task is switched to. - * - * If FALSE, then the floating point context is saved when a floating - * point task is switched out and restored when the next floating point - * task is restored. The state of the floating point registers between - * those two operations is not specified. - * - * If the floating point context does NOT have to be saved as part of - * interrupt dispatching, then it should be safe to set this to TRUE. - * - * Setting this flag to TRUE results in using a different algorithm - * for deciding when to save and restore the floating point context. - * The deferred FP switch algorithm minimizes the number of times - * the FP context is saved and restored. The FP context is not saved - * until a context switch is made to another, different FP task. - * Thus in a system with only one FP task, the FP context will never - * be saved or restored. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_USE_DEFERRED_FP_SWITCH TRUE - -#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE - -/** - * Does this port provide a CPU dependent IDLE task implementation? - * - * If TRUE, then the routine @ref _CPU_Thread_Idle_body - * must be provided and is the default IDLE thread body instead of - * @ref _CPU_Thread_Idle_body. - * - * If FALSE, then use the generic IDLE thread body if the BSP does - * not provide one. - * - * This is intended to allow for supporting processors which have - * a low power or idle mode. When the IDLE thread is executed, then - * the CPU can be powered down. - * - * The order of precedence for selecting the IDLE thread body is: - * - * -# BSP provided - * -# CPU dependent (if provided) - * -# generic (if no BSP and no CPU dependent) - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_PROVIDES_IDLE_THREAD_BODY TRUE - -/** - * Does the stack grow up (toward higher addresses) or down - * (toward lower addresses)? - * - * If TRUE, then the grows upward. - * If FALSE, then the grows toward smaller addresses. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_STACK_GROWS_UP TRUE - -/* FIXME: Is this the right value? */ -#define CPU_CACHE_LINE_BYTES 2 - -#define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES ) - -/** - * @ingroup CPUInterrupt - * - * The following defines the number of bits actually used in the - * interrupt field of the task mode. How those bits map to the - * CPU interrupt levels is defined by the routine @ref _CPU_ISR_Set_level. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_MODES_INTERRUPT_MASK 0x00000001 - -#define CPU_MAXIMUM_PROCESSORS 32 - -/* - * Processor defined structures required for cpukit/score. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ - -/* may need to put some structures here. */ - -/** - * @defgroup CPUContext Processor Dependent Context Management - * - * From the highest level viewpoint, there are 2 types of context to save. - * - * -# Interrupt registers to save - * -# Task level registers to save - * - * Since RTEMS handles integer and floating point contexts separately, this - * means we have the following 3 context items: - * - * -# task level context stuff:: Context_Control - * -# floating point task stuff:: Context_Control_fp - * -# special interrupt level context :: CPU_Interrupt_frame - * - * On some processors, it is cost-effective to save only the callee - * preserved registers during a task context switch. This means - * that the ISR code needs to save those registers which do not - * persist across function calls. It is not mandatory to make this - * distinctions between the caller/callee saves registers for the - * purpose of minimizing context saved during task switch and on interrupts. - * If the cost of saving extra registers is minimal, simplicity is the - * choice. Save the same context on interrupt entry as for tasks in - * this case. - * - * Additionally, if gdb is to be made aware of RTEMS tasks for this CPU, then - * care should be used in designing the context area. - * - * On some CPUs with hardware floating point support, the Context_Control_fp - * structure will not be used or it simply consist of an array of a - * fixed number of bytes. This is done when the floating point context - * is dumped by a "FP save context" type instruction and the format - * is not really defined by the CPU. In this case, there is no need - * to figure out the exact format -- only the size. Of course, although - * this is enough information for RTEMS, it is probably not enough for - * a debugger such as gdb. But that is another problem. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -/**@{**/ - -/** - * @ingroup Management - * - * This defines the minimal set of integer and processor state registers - * that must be saved during a voluntary context switch from one thread - * to another. - */ -typedef struct { - /** This will contain the stack pointer. */ - uint32_t sp; - /** This will contain the frame base pointer. */ - uint32_t fb; -} Context_Control; - -/** - * @ingroup Management - * - * This macro returns the stack pointer associated with @a _context. - * - * @param[in] _context is the thread context area to access - * - * @return This method returns the stack pointer. - */ -#define _CPU_Context_Get_SP( _context ) \ - (_context)->sp - -/** - * @ingroup Management - * - * This defines the set of integer and processor state registers that must - * be saved during an interrupt. This set does not include any which are - * in @ref Context_Control. - */ -typedef struct { - /** - * This field is a hint that a port will have a number of integer - * registers that need to be saved when an interrupt occurs or - * when a context switch occurs at the end of an ISR. - */ - uint32_t special_interrupt_register; -} CPU_Interrupt_frame; - -/** @} */ - -/** - * @defgroup CPUInterrupt Processor Dependent Interrupt Management - * - * On some CPUs, RTEMS supports a software managed interrupt stack. - * This stack is allocated by the Interrupt Manager and the switch - * is performed in @ref _ISR_Handler. These variables contain pointers - * to the lowest and highest addresses in the chunk of memory allocated - * for the interrupt stack. Since it is unknown whether the stack - * grows up or down (in general), this give the CPU dependent - * code the option of picking the version it wants to use. - * - * NOTE: These two variables are required if the macro - * @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK is defined as TRUE. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - * - */ -/**@{**/ - -/* - * Nothing prevents the porter from declaring more CPU specific variables. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ - -/* XXX: if needed, put more variables here */ - -/** - * Amount of extra stack (above minimum stack size) required by - * MPCI receive server thread. Remember that in a multiprocessor - * system this thread must exist and be able to process all directives. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0 - -/** - * This defines the number of entries in the @ref _ISR_Vector_table managed - * by RTEMS. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_INTERRUPT_NUMBER_OF_VECTORS 32 - -/** This defines the highest interrupt vector number for this port. */ -#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER (CPU_INTERRUPT_NUMBER_OF_VECTORS - 1) - -/** - * This is defined if the port has a special way to report the ISR nesting - * level. Most ports maintain the variable @a _ISR_Nest_level. - */ -#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE - -/** @} */ - -/** - * @ingroup CPUContext - * - * Should be large enough to run all RTEMS tests. This ensures - * that a "reasonable" small application should not have any problems. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_STACK_MINIMUM_SIZE (2048L) - -#ifdef __m32cm_cpu__ - #define CPU_SIZEOF_POINTER 4 -#else - #define CPU_SIZEOF_POINTER 2 -#endif - -/** - * CPU's worst alignment requirement for data types on a byte boundary. This - * alignment does not take into account the requirements for the stack. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_ALIGNMENT 2 - -/** - * This number corresponds to the byte alignment requirement for the - * heap handler. This alignment requirement may be stricter than that - * for the data types alignment specified by @ref CPU_ALIGNMENT. It is - * common for the heap to follow the same alignment requirement as - * @ref CPU_ALIGNMENT. If the @ref CPU_ALIGNMENT is strict enough for - * the heap, then this should be set to @ref CPU_ALIGNMENT. - * - * NOTE: This does not have to be a power of 2 although it should be - * a multiple of 2 greater than or equal to 2. The requirement - * to be a multiple of 2 is because the heap uses the least - * significant field of the front and back flags to indicate - * that a block is in use or free. So you do not want any odd - * length blocks really putting length data in that bit. - * - * On byte oriented architectures, @ref CPU_HEAP_ALIGNMENT normally will - * have to be greater or equal to than @ref CPU_ALIGNMENT to ensure that - * elements allocated from the heap meet all restrictions. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_HEAP_ALIGNMENT 4 - -/** - * This number corresponds to the byte alignment requirement for memory - * buffers allocated by the partition manager. This alignment requirement - * may be stricter than that for the data types alignment specified by - * @ref CPU_ALIGNMENT. It is common for the partition to follow the same - * alignment requirement as @ref CPU_ALIGNMENT. If the @ref CPU_ALIGNMENT is - * strict enough for the partition, then this should be set to - * @ref CPU_ALIGNMENT. - * - * NOTE: This does not have to be a power of 2. It does have to - * be greater or equal to than @ref CPU_ALIGNMENT. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT - -/** - * This number corresponds to the byte alignment requirement for the - * stack. This alignment requirement may be stricter than that for the - * data types alignment specified by @ref CPU_ALIGNMENT. If the - * @ref CPU_ALIGNMENT is strict enough for the stack, then this should be - * set to 0. - * - * NOTE: This must be a power of 2 either 0 or greater than @ref CPU_ALIGNMENT. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_STACK_ALIGNMENT 0 - -/* - * ISR handler macros - */ - -/** - * @ingroup CPUInterrupt - * - * Support routine to initialize the RTEMS vector table after it is allocated. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_Initialize_vectors() - -/** - * @ingroup CPUInterrupt - * - * Disable all interrupts for an RTEMS critical section. The previous - * level is returned in @a _isr_cookie. - * - * @param[out] _isr_cookie will contain the previous level cookie - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_ISR_Disable( _isr_cookie ) \ - do { \ - int _flg; \ - m32c_get_flg( _flg ); \ - _isr_cookie = _flg; \ - __asm__ volatile( "fclr I" ); \ - } while(0) - -/** - * @ingroup CPUInterrupt - * - * Enable interrupts to the previous level (returned by _CPU_ISR_Disable). - * This indicates the end of an RTEMS critical section. The parameter - * @a _isr_cookie is not modified. - * - * @param[in] _isr_cookie contain the previous level cookie - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_ISR_Enable(_isr_cookie) \ - do { \ - int _flg = (int) (_isr_cookie); \ - m32c_set_flg( _flg ); \ - } while(0) - -/** - * @ingroup CPUInterrupt - * - * This temporarily restores the interrupt to @a _isr_cookie before immediately - * disabling them again. This is used to divide long RTEMS critical - * sections into two or more parts. The parameter @a _isr_cookie is not - * modified. - * - * @param[in] _isr_cookie contain the previous level cookie - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_ISR_Flash( _isr_cookie ) \ - do { \ - int _flg = (int) (_isr_cookie); \ - m32c_set_flg( _flg ); \ - __asm__ volatile( "fclr I" ); \ - } while(0) - -RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) -{ - return ( level & 0x40 ) != 0; -} - -/** - * @ingroup CPUInterrupt - * - * This routine and @ref _CPU_ISR_Get_level - * Map the interrupt level in task mode onto the hardware that the CPU - * actually provides. Currently, interrupt levels which do not - * map onto the CPU in a generic fashion are undefined. Someday, - * it would be nice if these were "mapped" by the application - * via a callout. For example, m68k has 8 levels 0 - 7, levels - * 8 - 255 would be available for bsp/application specific meaning. - *This could be used to manage a programmable interrupt controller - * via the rtems_task_mode directive. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_ISR_Set_level( _new_level ) \ - do { \ - if (_new_level) __asm__ volatile( "fclr I" ); \ - else __asm__ volatile( "fset I" ); \ - } while(0) - -/** - * @ingroup CPUInterrupt - * - * Return the current interrupt disable level for this task in - * the format used by the interrupt level portion of the task mode. - * - * NOTE: This routine usually must be implemented as a subroutine. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -uint32_t _CPU_ISR_Get_level( void ); - -/* end of ISR handler macros */ - -/* Context handler macros */ - -/** - * @ingroup CPUContext - * - * Initialize the context to a state suitable for starting a - * task after a context restore operation. Generally, this - * involves: - * - * - setting a starting address - * - preparing the stack - * - preparing the stack and frame pointers - * - setting the proper interrupt level in the context - * - initializing the floating point context - * - * This routine generally does not set any unnecessary register - * in the context. The state of the "general data" registers is - * undefined at task start time. - * - * @param[in] _the_context is the context structure to be initialized - * @param[in] _stack_base is the lowest physical address of this task's stack - * @param[in] _size is the size of this task's stack - * @param[in] _isr is the interrupt disable level - * @param[in] _entry_point is the thread's entry point. This is - * always @a _Thread_Handler - * @param[in] _is_fp is TRUE if the thread is to be a floating - * point thread. This is typically only used on CPUs where the - * FPU may be easily disabled by software such as on the SPARC - * where the PSR contains an enable FPU bit. - * @param[in] tls_area is the thread-local storage (TLS) area - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_Context_Initialize( - Context_Control *the_context, - uint32_t *stack_base, - size_t size, - uint32_t new_level, - void *entry_point, - bool is_fp, - void *tls_area -); - -/** - * This routine is responsible for somehow restarting the currently - * executing task. If you are lucky, then all that is necessary - * is restoring the context. Otherwise, there will need to be - * a special assembly routine which does something special in this - * case. For many ports, simply adding a label to the restore path - * of @ref _CPU_Context_switch will work. On other ports, it may be - * possibly to load a few arguments and jump to the restore path. It will - * not work if restarting self conflicts with the stack frame - * assumptions of restoring a context. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_Context_Restart_self( - Context_Control *the_context -) RTEMS_NO_RETURN; - -/** - * This routine initializes the FP context area passed to it to. - * There are a few standard ways in which to initialize the - * floating point context. The code included for this macro assumes - * that this is a CPU in which a "initial" FP context was saved into - * @a _CPU_Null_fp_context and it simply copies it to the destination - * context passed to it. - * - * Other floating point context save/restore models include: - * -# not doing anything, and - * -# putting a "null FP status word" in the correct place in the FP context. - * - * @param[in] _destination is the floating point context area - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_Context_Initialize_fp( _destination ) \ - { \ - *(*(_destination)) = _CPU_Null_fp_context; \ - } - -/* end of Context handler macros */ - -/* Fatal Error manager macros */ - -/** - * This routine copies _error into a known place -- typically a stack - * location or a register, optionally disables interrupts, and - * halts/stops the CPU. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_Fatal_halt( _source, _error ) \ - { \ - } - -/* end of Fatal Error manager macros */ - -#define CPU_USE_GENERIC_BITFIELD_CODE TRUE - -/* functions */ - -/** - * This routine performs CPU dependent initialization. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_Initialize(void); - -/** - * @ingroup CPUInterrupt - * - * This routine installs a "raw" interrupt handler directly into the - * processor's vector table. - * - * @param[in] vector is the vector number - * @param[in] new_handler is the raw ISR handler to install - * @param[in] old_handler is the previously installed ISR Handler - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_ISR_install_raw_handler( - uint32_t vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -/** - * @ingroup CPUInterrupt - * - * This routine installs an interrupt vector. - * - * @param[in] vector is the vector number - * @param[in] new_handler is the RTEMS ISR handler to install - * @param[in] old_handler is the previously installed ISR Handler - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_ISR_install_vector( - uint32_t vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -/** - * @ingroup CPUInterrupt - * - * This routine installs the hardware interrupt stack pointer. - * - * NOTE: It need only be provided if @ref CPU_HAS_HARDWARE_INTERRUPT_STACK - * is TRUE. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_Install_interrupt_stack( void ); - -/** - * This routine is the CPU dependent IDLE thread body. - * - * NOTE: It need only be provided if @ref CPU_PROVIDES_IDLE_THREAD_BODY - * is TRUE. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void *_CPU_Thread_Idle_body( uintptr_t ignored ); - -/** - * @ingroup CPUContext - * - * This routine switches from the run context to the heir context. - * - * @param[in] run points to the context of the currently executing task - * @param[in] heir points to the context of the heir task - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_Context_switch( - Context_Control *run, - Context_Control *heir -); - -/** - * @ingroup CPUContext - * - * This routine is generally used only to restart self in an - * efficient manner. It may simply be a label in @ref _CPU_Context_switch. - * - * @param[in] new_context points to the context to be restored. - * - * NOTE: May be unnecessary to reload some registers. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_Context_restore( - Context_Control *new_context -) RTEMS_NO_RETURN; - -static inline void _CPU_Context_volatile_clobber( uintptr_t pattern ) -{ - /* TODO */ -} - -static inline void _CPU_Context_validate( uintptr_t pattern ) -{ - while (1) { - /* TODO */ - } -} - -/* FIXME */ -typedef CPU_Interrupt_frame CPU_Exception_frame; - -void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); - -/** - * @ingroup CPUEndian - * - * The following routine swaps the endian format of an unsigned int. - * It must be static because it is referenced indirectly. - * - * This version will work on any processor, but if there is a better - * way for your CPU PLEASE use it. The most common way to do this is to: - * - * swap least significant two bytes with 16-bit rotate - * swap upper and lower 16-bits - * swap most significant two bytes with 16-bit rotate - * - * Some CPUs have special instructions which swap a 32-bit quantity in - * a single instruction (e.g. i486). It is probably best to avoid - * an "endian swapping control bit" in the CPU. One good reason is - * that interrupts would probably have to be disabled to ensure that - * an interrupt does not try to access the same "chunk" with the wrong - * endian. Another good reason is that on some CPUs, the endian bit - * endianness for ALL fetches -- both code and data -- so the code - * will be fetched incorrectly. - * - * @param[in] value is the value to be swapped - * @return the value after being endian swapped - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -static inline uint32_t CPU_swap_u32( - uint32_t value -) -{ - uint32_t byte1, byte2, byte3, byte4, swapped; - - byte4 = (value >> 24) & 0xff; - byte3 = (value >> 16) & 0xff; - byte2 = (value >> 8) & 0xff; - byte1 = value & 0xff; - - swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4; - return swapped; -} - -/** - * @ingroup CPUEndian - * - * This routine swaps a 16 bir quantity. - * - * @param[in] value is the value to be swapped - * @return the value after being endian swapped - */ -#define CPU_swap_u16( value ) \ - (((value&0xff) << 8) | ((value >> 8)&0xff)) - -typedef uint32_t CPU_Counter_ticks; - -CPU_Counter_ticks _CPU_Counter_read( void ); - -static inline CPU_Counter_ticks _CPU_Counter_difference( - CPU_Counter_ticks second, - CPU_Counter_ticks first -) -{ - return second - first; -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/score/cpu/m32c/rtems/score/cpu_asm.h b/cpukit/score/cpu/m32c/rtems/score/cpu_asm.h deleted file mode 100644 index 451c022d75..0000000000 --- a/cpukit/score/cpu/m32c/rtems/score/cpu_asm.h +++ /dev/null @@ -1,72 +0,0 @@ -/** - * @file - * - * @brief M32C CPU Assembly File - * - * Very loose template for an include file for the cpu_asm.? file - * if it is implemented as a ".S" file (preprocessed by cpp) instead - * of a ".s" file (preprocessed by gm4 or gasp). - */ - -/* - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - * - */ - -#ifndef _RTEMS_SCORE_CPU_ASM_H -#define _RTEMS_SCORE_CPU_ASM_H - -/* pull in the generated offsets */ - -#include - -/* - * Hardware General Registers - */ - -/* put something here */ - -/* - * Hardware Floating Point Registers - */ - -/* put something here */ - -/* - * Hardware Control Registers - */ - -/* put something here */ - -/* - * Calling Convention - */ - -/* put something here */ - -/* - * Temporary registers - */ - -/* put something here */ - -/* - * Floating Point Registers - SW Conventions - */ - -/* put something here */ - -/* - * Temporary floating point registers - */ - -/* put something here */ - -#endif - -/* end of file */ diff --git a/cpukit/score/cpu/m32c/rtems/score/cpuatomic.h b/cpukit/score/cpu/m32c/rtems/score/cpuatomic.h deleted file mode 100644 index 598ee76b20..0000000000 --- a/cpukit/score/cpu/m32c/rtems/score/cpuatomic.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * COPYRIGHT (c) 2012-2013 Deng Hengyi. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_ATOMIC_CPU_H -#define _RTEMS_SCORE_ATOMIC_CPU_H - -#include - -#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/m32c/rtems/score/cpuimpl.h b/cpukit/score/cpu/m32c/rtems/score/cpuimpl.h deleted file mode 100644 index 789f2badd9..0000000000 --- a/cpukit/score/cpu/m32c/rtems/score/cpuimpl.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @file - * - * @brief CPU Port Implementation API - */ - -/* - * Copyright (c) 2013 embedded brains GmbH - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPUIMPL_H -#define _RTEMS_SCORE_CPUIMPL_H - -#include - -#define CPU_PER_CPU_CONTROL_SIZE 0 - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* ASM */ - -#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/m32c/rtems/score/m32c.h b/cpukit/score/cpu/m32c/rtems/score/m32c.h deleted file mode 100644 index e1936fdcfb..0000000000 --- a/cpukit/score/cpu/m32c/rtems/score/m32c.h +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @file - * - * @brief M32C Set up Basic CPU Dependency Settings Based on Compiler Settings - * - * This file sets up basic CPU dependency settings based on - * compiler settings. For example, it can determine if - * floating point is available. This particular implementation - * is specified to the NO CPU port. - */ - -/* - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_NO_CPU_H -#define _RTEMS_SCORE_NO_CPU_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This file contains the information required to build - * RTEMS for a particular member of the NO CPU family. - * It does this by setting variables to indicate which - * implementation dependent features are present in a particular - * member of the family. - * - * This is a good place to list all the known CPU models - * that this port supports and which RTEMS CPU model they correspond - * to. - */ - -#if defined(rtems_multilib) -/* - * Figure out all CPU Model Feature Flags based upon compiler - * predefines. - */ - -#define CPU_MODEL_NAME "rtems_multilib" -#define NOCPU_HAS_FPU 1 - -#elif defined(__m32c__) - -#define CPU_MODEL_NAME "m32c" -#define M32C_HAS_FPU 0 - -#else - -#error "Unsupported CPU Model" - -#endif - -/* - * Define the name of the CPU family. - */ - -#define CPU_NAME "m32c" - -#define m32c_get_flg( _flg ) \ - __asm__ volatile( "stc flg, %0" : "=r" (_flg)) - -#define m32c_set_flg( _flg ) \ - __asm__ volatile( "ldc %1, flg" : "=r" (_flg) : "r" (_flg) ) - -#ifdef __cplusplus -} -#endif - -#endif /* _RTEMS_SCORE_NO_CPU_H */ diff --git a/cpukit/score/cpu/m32c/rtems/score/types.h b/cpukit/score/cpu/m32c/rtems/score/types.h deleted file mode 100644 index 99d8297143..0000000000 --- a/cpukit/score/cpu/m32c/rtems/score/types.h +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @file - * - * @brief M32C CPU Type Definitions - * - * This include file contains type definitions pertaining to the Intel - * m32c processor family. - */ - -/* - * COPYRIGHT (c) 1989-2006. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_TYPES_H -#define _RTEMS_SCORE_TYPES_H - -#include - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This section defines the basic types for this processor. - */ - -/** Type that can store a 32-bit integer or a pointer. */ -typedef unsigned long CPU_Uint32ptr; - -/** This defines the return type for an ISR entry point. */ -typedef void m32c_isr; - -/** This defines the prototype for an ISR entry point. */ -typedef m32c_isr ( *m32c_isr_entry )( void ); - -#ifdef __cplusplus -} -#endif - -#endif /* !ASM */ - -#endif diff --git a/cpukit/score/cpu/m32c/varvects.h b/cpukit/score/cpu/m32c/varvects.h deleted file mode 100644 index 7168482b54..0000000000 --- a/cpukit/score/cpu/m32c/varvects.h +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @file - * - * @brief M32C Built-in Variable Vector Table Interface - * - * This file defines the interface to the built-in variable vector - * table in R8C/M16C/M32C chips. - */ - -/* - * Copyright (c) 2008 Red Hat Incorporated. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * The name of Red Hat Incorporated may not be used to endorse - * or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _VARVECTS_H_ -#define _VARVECTS_H_ - -typedef void (*_m32c_interrupt_func)(void) __attribute__((mode(SI))); -extern _m32c_interrupt_func _var_vects[]; - -#if defined(__r8c_cpu__) || defined (__m16c_cpu__) - -#define _set_var_vect(f,n) \ - { __asm__ ("mov.w #%%lo16(%d0),__var_vects+%d1" : : "s" (f), "g" (n*4)); \ - __asm__ ("mov.w #%%hi16(%d0),__var_vects+%d1" : : "s" (f), "g" (n*4+2)); } - -#else - -#define _set_var_vect(f,n) \ - _var_vects[n] = f - -#endif -#endif diff --git a/cpukit/score/cpu/m68k/Makefile.am b/cpukit/score/cpu/m68k/Makefile.am index 04eebcba85..68fd3a253a 100644 --- a/cpukit/score/cpu/m68k/Makefile.am +++ b/cpukit/score/cpu/m68k/Makefile.am @@ -3,26 +3,10 @@ include $(top_srcdir)/automake/compile.am noinst_LIBRARIES = libscorecpu.a libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS) -include_rtemsdir = $(includedir)/rtems -include_rtems_HEADERS = rtems/asm.h - -include_rtems_m68kdir = $(includedir)/rtems/m68k -include_rtems_m68k_HEADERS = rtems/m68k/m68302.h -include_rtems_m68k_HEADERS += rtems/m68k/m68360.h -include_rtems_m68k_HEADERS += rtems/m68k/qsm.h -include_rtems_m68k_HEADERS += rtems/m68k/sim.h - -include_rtems_scoredir = $(includedir)/rtems/score -include_rtems_score_HEADERS = rtems/score/cpu.h -include_rtems_score_HEADERS += rtems/score/cpuimpl.h -include_rtems_score_HEADERS += rtems/score/m68k.h -include_rtems_score_HEADERS += rtems/score/types.h -include_rtems_score_HEADERS += rtems/score/cpuatomic.h - libscorecpu_a_SOURCES = cpu.c cpu_asm.S libscorecpu_a_SOURCES += ../no_cpu/cpucounterread.c libscorecpu_a_SOURCES += m68k-exception-frame-print.c libscorecpu_a_SOURCES += __m68k_read_tp.c -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am +include $(srcdir)/headers.am diff --git a/cpukit/score/cpu/m68k/headers.am b/cpukit/score/cpu/m68k/headers.am new file mode 100644 index 0000000000..e02fad3906 --- /dev/null +++ b/cpukit/score/cpu/m68k/headers.am @@ -0,0 +1,24 @@ +## This file was generated by "./boostrap -H". + +include_machinedir = $(includedir)/machine +include_machine_HEADERS = +include_machine_HEADERS += include/machine/elf_machdep.h + +include_rtemsdir = $(includedir)/rtems +include_rtems_HEADERS = +include_rtems_HEADERS += include/rtems/asm.h + +include_rtems_m68kdir = $(includedir)/rtems/m68k +include_rtems_m68k_HEADERS = +include_rtems_m68k_HEADERS += include/rtems/m68k/m68302.h +include_rtems_m68k_HEADERS += include/rtems/m68k/m68360.h +include_rtems_m68k_HEADERS += include/rtems/m68k/qsm.h +include_rtems_m68k_HEADERS += include/rtems/m68k/sim.h + +include_rtems_scoredir = $(includedir)/rtems/score +include_rtems_score_HEADERS = +include_rtems_score_HEADERS += include/rtems/score/cpu.h +include_rtems_score_HEADERS += include/rtems/score/cpuatomic.h +include_rtems_score_HEADERS += include/rtems/score/cpuimpl.h +include_rtems_score_HEADERS += include/rtems/score/m68k.h +include_rtems_score_HEADERS += include/rtems/score/types.h diff --git a/cpukit/score/cpu/m68k/include/machine/elf_machdep.h b/cpukit/score/cpu/m68k/include/machine/elf_machdep.h new file mode 100644 index 0000000000..9a987c69b5 --- /dev/null +++ b/cpukit/score/cpu/m68k/include/machine/elf_machdep.h @@ -0,0 +1,47 @@ +/* $NetBSD: elf_machdep.h,v 1.7 2002/01/28 21:34:48 thorpej Exp $ */ + +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB +#define ELF32_MACHDEP_ID_CASES \ + case EM_68K: \ + break; + +#define ELF64_MACHDEP_ENDIANNESS XXX /* break compilation */ +#define ELF64_MACHDEP_ID_CASES \ + /* no 64-bit ELF machine types supported */ + +#define ELF32_MACHDEP_ID EM_68K + +/* + * Machine-dependent ELF flags. These are defined by the GNU tools. + */ +#define EF_CPU32 0x00810000 +#define EF_M68000 0x01000000 + +#define ARCH_ELFSIZE 32 /* MD native binary size */ + +/* m68k relocation types */ +#define R_68K_NONE 0 +#define R_68K_32 1 +#define R_68K_16 2 +#define R_68K_8 3 +#define R_68K_PC32 4 +#define R_68K_PC16 5 +#define R_68K_PC8 6 +#define R_68K_GOT32 7 +#define R_68K_GOT16 8 +#define R_68K_GOT8 9 +#define R_68K_GOT32O 10 +#define R_68K_GOT16O 11 +#define R_68K_GOT8O 12 +#define R_68K_PLT32 13 +#define R_68K_PLT16 14 +#define R_68K_PLT8 15 +#define R_68K_PLT32O 16 +#define R_68K_PLT16O 17 +#define R_68K_PLT8O 18 +#define R_68K_COPY 19 +#define R_68K_GLOB_DAT 20 +#define R_68K_JMP_SLOT 21 +#define R_68K_RELATIVE 22 + +#define R_TYPE(name) __CONCAT(R_68K_,name) diff --git a/cpukit/score/cpu/m68k/include/rtems/asm.h b/cpukit/score/cpu/m68k/include/rtems/asm.h new file mode 100644 index 0000000000..cbd2a7f8b2 --- /dev/null +++ b/cpukit/score/cpu/m68k/include/rtems/asm.h @@ -0,0 +1,152 @@ +/** + * @file + * + * @brief Address the Problems Caused by Incompatible Flavor of + * Assemblers and Toolsets + * + * This include file attempts to address the problems + * caused by incompatible flavors of assemblers and + * toolsets. It primarily addresses variations in the + * use of leading underscores on symbols and the requirement + * that register names be preceded by a %. + * + * NOTE: The spacing in the use of these macros + * is critical to them working as advertised. + */ + +/* + * COPYRIGHT: + * + * This file is based on similar code found in newlib available + * from ftp.cygnus.com. The file which was used had no copyright + * notice. This file is freely distributable as long as the source + * of the file is noted. This file is: + * + * COPYRIGHT (c) 1994-1997. + * On-Line Applications Research Corporation (OAR). + */ + +#ifndef _RTEMS_ASM_H +#define _RTEMS_ASM_H + +/* + * Indicate we are in an assembly file and get the basic CPU definitions. + */ + +#ifndef ASM +#define ASM +#endif +#include +#include + +/* + * Recent versions of GNU cpp define variables which indicate the + * need for underscores and percents. If not using GNU cpp or + * the version does not support this, then you will obviously + * have to define these as appropriate. + */ + +#ifndef __USER_LABEL_PREFIX__ +#define __USER_LABEL_PREFIX__ _ +#endif + +#ifndef __REGISTER_PREFIX__ +#define __REGISTER_PREFIX__ +#endif + +#include + +/* Use the right prefix for global labels. */ + +#define SYM(x) CONCAT0 (__USER_LABEL_PREFIX__, x) + +/* Use the right prefix for registers. */ + +#define REG(x) CONCAT0 (__REGISTER_PREFIX__, x) + +#define d0 REG (d0) +#define d1 REG (d1) +#define d2 REG (d2) +#define d3 REG (d3) +#define d4 REG (d4) +#define d5 REG (d5) +#define d6 REG (d6) +#define d7 REG (d7) +#define a0 REG (a0) +#define a1 REG (a1) +#define a2 REG (a2) +#define a3 REG (a3) +#define a4 REG (a4) +#define a5 REG (a5) +#define a6 REG (a6) +#define a7 REG (a7) +#define sp REG (sp) + +#define msp REG (msp) +#define usp REG (usp) +#define isp REG (isp) +#define sr REG (sr) +#define vbr REG (vbr) +#define dfc REG (dfc) +#define sfc REG (sfc) + +/* mcf52xx special regs */ +#define cacr REG (cacr) +#define acr0 REG (acr0) +#define acr1 REG (acr1) +#define rambar0 REG (rambar0) +#define mbar REG (mbar) + +/* additional v4e special regs */ +#define rambar1 REG (rambar1) +#define macsr REG (macsr) +#define acc0 REG (acc0) +#define acc1 REG (acc1) +#define acc2 REG (acc2) +#define acc3 REG (acc3) +#define accext01 REG (accext01) +#define accext23 REG (accext23) +#define mask REG (mask) + + +#define fp0 REG (fp0) +#define fp1 REG (fp1) +#define fp2 REG (fp2) +#define fp3 REG (fp3) +#define fp4 REG (fp4) +#define fp5 REG (fp5) +#define fp6 REG (fp6) +#define fp7 REG (fp7) + +#define fpc REG (fpc) +#define fpi REG (fpi) +#define fps REG (fps) +#define fpsr REG (fpsr) + + +/* + * Define macros to handle section beginning and ends. + */ + + +#define BEGIN_CODE_DCL .text +#define END_CODE_DCL +#define BEGIN_DATA_DCL .data +#define END_DATA_DCL +#define BEGIN_CODE .text +#define END_CODE +#define BEGIN_DATA .data +#define END_DATA +#define BEGIN_BSS .bss +#define END_BSS +#define END + +/* + * Following must be tailor for a particular flavor of the C compiler. + * They may need to put underscores in front of the symbols. + */ + +#define PUBLIC(sym) .globl SYM (sym) +#define EXTERN(sym) .globl SYM (sym) + +#endif diff --git a/cpukit/score/cpu/m68k/include/rtems/m68k/m68302.h b/cpukit/score/cpu/m68k/include/rtems/m68k/m68302.h new file mode 100644 index 0000000000..acf55f50c5 --- /dev/null +++ b/cpukit/score/cpu/m68k/include/rtems/m68k/m68302.h @@ -0,0 +1,659 @@ +/** + * @file + * + * @brief Definitions for Motorola MC68302 Processor + * + * Section references in this file refer to revision 2 of Motorola's + * "MC68302 Integrated Multiprotocol Processor User's Manual". + * (Motorola document MC68302UM/AD REV 2.) + * + * Based on Don Meyer's cpu68302.h that was posted in comp.sys.m68k + * on 17 February, 1993. + */ + +/* + * COPYRIGHT 1995 David W. Glessner. + * + * Redistribution and use in source and binary forms are permitted + * provided that the following conditions are met: + * 1. Redistribution of source code and documentation must retain + * the above copyright notice, this list of conditions and the + * following disclaimer. + * 2. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * This software is provided "AS IS" without warranty of any kind, + * either expressed or implied, including, but not limited to, the + * implied warranties of merchantability, title and fitness for a + * particular purpose. + * + *------------------------------------------------------------------ + */ + +#ifndef _RTEMS_M68K_M68302_H +#define _RTEMS_M68K_M68302_H + +/* + * BAR - Base Address Register + * Section 2.7 + */ +#define M302_BAR (*((volatile uint16_t *) 0xf2)) + +/* + * SCR - System Control Register + * Section 3.8.1 + */ +#define M302_SCR (*((volatile uint32_t *) 0xf4)) +/* + * SCR bits + */ +#define RBIT_SCR_IPA 0x08000000 +#define RBIT_SCR_HWT 0x04000000 +#define RBIT_SCR_WPV 0x02000000 +#define RBIT_SCR_ADC 0x01000000 + +#define RBIT_SCR_ERRE 0x00400000 +#define RBIT_SCR_VGE 0x00200000 +#define RBIT_SCR_WPVE 0x00100000 +#define RBIT_SCR_RMCST 0x00080000 +#define RBIT_SCR_EMWS 0x00040000 +#define RBIT_SCR_ADCE 0x00020000 +#define RBIT_SCR_BCLM 0x00010000 + +#define RBIT_SCR_FRZW 0x00008000 +#define RBIT_SCR_FRZ2 0x00004000 +#define RBIT_SCR_FRZ1 0x00002000 +#define RBIT_SCR_SAM 0x00001000 +#define RBIT_SCR_HWDEN 0x00000800 +#define RBIT_SCR_HWDCN2 0x00000400 +#define RBIT_SCR_HWDCN1 0x00000200 /* 512 clocks */ +#define RBIT_SCR_HWDCN0 0x00000100 /* 128 clocks */ + +#define RBIT_SCR_LPREC 0x00000080 +#define RBIT_SCR_LPP16 0x00000040 +#define RBIT_SCR_LPEN 0x00000020 +#define RBIT_SCR_LPCLKDIV 0x0000001f + + +/* + * 68000 interrupt and trap vector numbers + */ +#define M68K_IVEC_BUS_ERROR 2 +#define M68K_IVEC_ADDRESS_ERROR 3 +#define M68K_IVEC_ILLEGAL_OPCODE 4 +#define M68K_IVEC_ZERO_DIVIDE 5 +#define M68K_IVEC_CHK 6 +#define M68K_IVEC_TRAPV 7 +#define M68K_IVEC_PRIVILEGE 8 +#define M68K_IVEC_TRACE 9 +#define M68K_IVEC_LINE_A 10 +#define M68K_IVEC_LINE_F 11 +/* Unassigned, Reserved 12-14 */ +#define M68K_IVEC_UNINITIALIZED_INT 15 +/* Unassigned, Reserved 16-23 */ +#define M68K_IVEC_SPURIOUS_INT 24 + +#define M68K_IVEC_LEVEL1_AUTOVECTOR 25 +#define M68K_IVEC_LEVEL2_AUTOVECTOR 26 +#define M68K_IVEC_LEVEL3_AUTOVECTOR 27 +#define M68K_IVEC_LEVEL4_AUTOVECTOR 28 +#define M68K_IVEC_LEVEL5_AUTOVECTOR 29 +#define M68K_IVEC_LEVEL6_AUTOVECTOR 30 +#define M68K_IVEC_LEVEL7_AUTOVECTOR 31 + +#define M68K_IVEC_TRAP0 32 +#define M68K_IVEC_TRAP1 33 +#define M68K_IVEC_TRAP2 34 +#define M68K_IVEC_TRAP3 35 +#define M68K_IVEC_TRAP4 36 +#define M68K_IVEC_TRAP5 37 +#define M68K_IVEC_TRAP6 38 +#define M68K_IVEC_TRAP7 39 +#define M68K_IVEC_TRAP8 40 +#define M68K_IVEC_TRAP9 41 +#define M68K_IVEC_TRAP10 42 +#define M68K_IVEC_TRAP11 43 +#define M68K_IVEC_TRAP12 44 +#define M68K_IVEC_TRAP13 45 +#define M68K_IVEC_TRAP14 46 +#define M68K_IVEC_TRAP15 47 +/* + * Unassigned, Reserved 48-59 + * + * Note: Vectors 60-63 are used by the MC68302 (e.g. BAR, SCR). + */ + +/* + * MC68302 Interrupt Vectors + * Section 3.2 + */ +enum m68302_ivec_e { + M302_IVEC_ERR =0, + M302_IVEC_PB8 =1, /* General-Purpose Interrupt 0 */ + M302_IVEC_SMC2 =2, + M302_IVEC_SMC1 =3, + M302_IVEC_TIMER3 =4, + M302_IVEC_SCP =5, + M302_IVEC_TIMER2 =6, + M302_IVEC_PB9 =7, /* General-Purpose Interrupt 1 */ + M302_IVEC_SCC3 =8, + M302_IVEC_TIMER1 =9, + M302_IVEC_SCC2 =10, + M302_IVEC_IDMA =11, + M302_IVEC_SDMA =12, /* SDMA Channels Bus Error */ + M302_IVEC_SCC1 =13, + M302_IVEC_PB10 =14, /* General-Purpose Interrupt 2 */ + M302_IVEC_PB11 =15, /* General-Purpose Interrupt 3 */ + M302_IVEC_IRQ1 =17, /* External Device */ + M302_IVEC_IRQ6 =22, /* External Device */ + M302_IVEC_IRQ7 =23 /* External Device */ +}; + + +/* + * GIMR - Global Interrupt Mode Register + * Section 3.2.5.1 + */ +#define RBIT_GIMR_MOD (1<<15) +#define RBIT_GIMR_IV7 (1<<14) +#define RBIT_GIMR_IV6 (1<<13) +#define RBIT_GIMR_IV1 (1<<12) +#define RBIT_GIMR_ET7 (1<<10) +#define RBIT_GIMR_ET6 (1<<9) +#define RBIT_GIMR_ET1 (1<<8) +#define RBIT_GIMR_VECTOR (7<<5) + +/* + * IPR - Interrupt Pending Register (Section 3.2.5.2) + * IMR - Interrupt Mask Register (Section 3.2.5.3) + * ISR - Interrupt In-Service Register (Section 3.2.5.4) + */ +#define RBIT_IPR_PB11 (1<<15) +#define RBIT_IPR_PB10 (1<<14) +#define RBIT_IPR_SCC1 (1<<13) +#define RBIT_IPR_SDMA (1<<12) +#define RBIT_IPR_IDMA (1<<11) +#define RBIT_IPR_SCC2 (1<<10) +#define RBIT_IPR_TIMER1 (1<<9) +#define RBIT_IPR_SCC3 (1<<8) +#define RBIT_IPR_PB9 (1<<7) +#define RBIT_IPR_TIMER2 (1<<6) +#define RBIT_IPR_SCP (1<<5) +#define RBIT_IPR_TIMER3 (1<<4) +#define RBIT_IPR_SMC1 (1<<3) +#define RBIT_IPR_SMC2 (1<<2) +#define RBIT_IPR_PB8 (1<<1) +#define RBIT_IPR_ERR (1<<0) + +#define RBIT_ISR_PB11 (1<<15) +#define RBIT_ISR_PB10 (1<<14) +#define RBIT_ISR_SCC1 (1<<13) +#define RBIT_ISR_SDMA (1<<12) +#define RBIT_ISR_IDMA (1<<11) +#define RBIT_ISR_SCC2 (1<<10) +#define RBIT_ISR_TIMER1 (1<<9) +#define RBIT_ISR_SCC3 (1<<8) +#define RBIT_ISR_PB9 (1<<7) +#define RBIT_ISR_TIMER2 (1<<6) +#define RBIT_ISR_SCP (1<<5) +#define RBIT_ISR_TIMER3 (1<<4) +#define RBIT_ISR_SMC1 (1<<3) +#define RBIT_ISR_SMC2 (1<<2) +#define RBIT_ISR_PB8 (1<<1) + +#define RBIT_IMR_PB11 (1<<15) /* PB11 Interrupt Mask */ +#define RBIT_IMR_PB10 (1<<14) /* PB10 Interrupt Mask */ +#define RBIT_IMR_SCC1 (1<<13) /* SCC1 Interrupt Mask */ +#define RBIT_IMR_SDMA (1<<12) /* SDMA Interrupt Mask */ +#define RBIT_IMR_IDMA (1<<11) /* IDMA Interrupt Mask */ +#define RBIT_IMR_SCC2 (1<<10) /* SCC2 Interrupt Mask */ +#define RBIT_IMR_TIMER1 (1<<9) /* TIMER1 Interrupt Mask */ +#define RBIT_IMR_SCC3 (1<<8) /* SCC3 Interrupt Mask */ +#define RBIT_IMR_PB9 (1<<7) /* PB9 Interrupt Mask */ +#define RBIT_IMR_TIMER2 (1<<6) /* TIMER2 Interrupt Mask */ +#define RBIT_IMR_SCP (1<<5) /* SCP Interrupt Mask */ +#define RBIT_IMR_TIMER3 (1<<4) /* TIMER3 Interrupt Mask */ +#define RBIT_IMR_SMC1 (1<<3) /* SMC1 Interrupt Mask */ +#define RBIT_IMR_SMC2 (1<<2) /* SMC2 Interrupt Mask */ +#define RBIT_IMR_PB8 (1<<1) /* PB8 Interrupt Mask */ + + +/* + * DRAM Refresh + * Section 3.9 + * + * The DRAM refresh memory map replaces the SCC2 Tx BD 6 and Tx BD 7 + * structures in the parameter RAM. + * + * Access to the DRAM registers can be accomplished by + * the following approach: + * + * volatile m302_DRAM_refresh_t *dram; + * dram = (volatile m302_DRAM_refresh_t *) &m302.scc2.bd.tx[6]; + * + * Then simply use pointer references (e.g. dram->count = 3). + */ +typedef struct { + uint16_t dram_high; /* DRAM high address and FC */ + uint16_t dram_low; /* DRAM low address */ + uint16_t increment; /* increment step (bytes/row) */ + uint16_t count; /* RAM refresh cycle count (#rows) */ + uint16_t t_ptr_h; /* temporary refresh high addr & FC */ + uint16_t t_ptr_l; /* temporary refresh low address */ + uint16_t t_count; /* temporary refresh cycles count */ + uint16_t res; /* reserved */ +} m302_DRAM_refresh_t; + + +/* + * TMR - Timer Mode Register (for timers 1 and 2) + * Section 3.5.2.1 + */ +#define RBIT_TMR_ICLK_STOP (0<<1) +#define RBIT_TMR_ICLK_MASTER (1<<1) +#define RBIT_TMR_ICLK_MASTER16 (2<<1) +#define RBIT_TMR_ICLK_TIN (3<<1) + +#define RBIT_TMR_OM (1<<5) +#define RBIT_TMR_ORI (1<<4) +#define RBIT_TMR_FRR (1<<3) +#define RBIT_TMR_RST (1<<0) + + +/* + * TER - Timer Event Register (for timers 1 and 2) + * Section 3.5.2.5 + */ +#define RBIT_TER_REF (1<<1) /* Output Reference Event */ +#define RBIT_TER_CAP (1<<0) /* Capture Event */ + + +/* + * SCC Buffer Descriptors and Buffer Descriptors Table + * Section 4.5.5 + */ +typedef struct m302_SCC_bd { + uint16_t status; /* status and control */ + uint16_t length; /* data length */ + volatile uint8_t *buffer; /* data buffer pointer */ +} m302_SCC_bd_t; + +typedef struct { + m302_SCC_bd_t rx[8]; /* receive buffer descriptors */ + m302_SCC_bd_t tx[8]; /* transmit buffer descriptors */ +} m302_SCC_bd_table_t; + + +/* + * SCC Parameter RAM (offset 0x080 from an SCC Base) + * Section 4.5.6 + * + * Each SCC parameter RAM area begins at offset 0x80 from each SCC base + * area (0x400, 0x500, or 0x600 from the dual-port RAM base). + * + * Offsets 0x9c-0xbf from each SCC base area compose the protocol-specific + * portion of the SCC parameter RAM. + */ +typedef struct { + uint8_t rfcr; /* Rx Function Code */ + uint8_t tfcr; /* Tx Function Code */ + uint16_t mrblr; /* Maximum Rx Buffer Length */ + uint16_t _rstate; /* Rx Internal State */ + uint8_t res2; + uint8_t rbd; /* Rx Internal Buffer Number */ + uint32_t _rdptr; /* Rx Internal Data Pointer */ + uint16_t _rcount; /* Rx Internal Byte Count */ + uint16_t _rtmp; /* Rx Temp */ + uint16_t _tstate; /* Tx Internal State */ + uint8_t res7; + uint8_t tbd; /* Tx Internal Buffer Number */ + uint32_t _tdptr; /* Tx Internal Data Pointer */ + uint16_t _tcount; /* Tx Internal Byte Count */ + uint16_t _ttmp; /* Tx Temp */ +} m302_SCC_parameters_t; + +/* + * UART-Specific SCC Parameter RAM + * Section 4.5.11.3 + */ +typedef struct { + uint16_t max_idl; /* Maximum IDLE Characters (rx) */ + uint16_t idlc; /* Temporary rx IDLE counter */ + uint16_t brkcr; /* Break Count Register (tx) */ + uint16_t parec; /* Receive Parity Error Counter */ + uint16_t frmec; /* Receive Framing Error Counter */ + uint16_t nosec; /* Receive Noise Counter */ + uint16_t brkec; /* Receive Break Condition Counter */ + uint16_t uaddr1; /* UART ADDRESS Character 1 */ + uint16_t uaddr2; /* UART ADDRESS Character 2 */ + uint16_t rccr; /* Receive Control Character Register */ + uint16_t character[8]; /* Control Characters 1 through 8*/ +} m302_SCC_UartSpecific_t; +/* + * This definition allows for the checking of receive buffers + * for errors. + */ + +#define RCV_ERR 0x003F + +/* + * UART receive buffer descriptor bit definitions. + * Section 4.5.11.14 + */ +#define RBIT_UART_CTRL (1<<11) /* buffer contains a control char */ +#define RBIT_UART_ADDR (1<<10) /* first byte contains an address */ +#define RBIT_UART_MATCH (1<<9) /* indicates which addr char matched */ +#define RBIT_UART_IDLE (1<<8) /* buffer closed due to IDLE sequence */ +#define RBIT_UART_BR (1<<5) /* break sequence was received */ +#define RBIT_UART_FR (1<<4) /* framing error was received */ +#define RBIT_UART_PR (1<<3) /* parity error was received */ +#define RBIT_UART_OV (1<<1) /* receiver overrun occurred */ +#define RBIT_UART_CD (1<<0) /* carrier detect lost */ +#define RBIT_UART_STATUS 0x003B /* all status bits */ + +/* + * UART transmit buffer descriptor bit definitions. + * Section 4.5.11.15 + */ +#define RBIT_UART_CR (1<<11) /* clear-to-send report + * this results in two idle bits + * between back-to-back frames + */ +#define RBIT_UART_A (1<<10) /* buffer contains address characters + * only valid in multidrop mode (UM0=1) + */ +#define RBIT_UART_PREAMBLE (1<<9) /* send preamble before data */ +#define RBIT_UART_CTS_LOST (1<<0) /* CTS lost */ + +/* + * UART event register + * Section 4.5.11.16 + */ +#define M302_UART_EV_CTS (1<<7) /* CTS status changed */ +#define M302_UART_EV_CD (1<<6) /* carrier detect status changed */ +#define M302_UART_EV_IDL (1<<5) /* IDLE sequence status changed */ +#define M302_UART_EV_BRK (1<<4) /* break character was received */ +#define M302_UART_EV_CCR (1<<3) /* control character received */ +#define M302_UART_EV_TX (1<<1) /* buffer has been transmitted */ +#define M302_UART_EV_RX (1<<0) /* buffer has been received */ + + +/* + * HDLC-Specific SCC Parameter RAM + * Section 4.5.12.3 + * + * c_mask_l should be 0xF0B8 for 16-bit CRC, 0xdebb for 32-bit CRC + * c_mask_h is a don't care for 16-bit CRC, 0x20E2 for 32-bit CRC + */ +typedef struct { + uint16_t rcrc_l; /* Temp Receive CRC Low */ + uint16_t rcrc_h; /* Temp Receive CRC High */ + uint16_t c_mask_l; /* CRC Mask Low */ + uint16_t c_mask_h; /* CRC Mask High */ + uint16_t tcrc_l; /* Temp Transmit CRC Low */ + uint16_t tcrc_h; /* Temp Transmit CRC High */ + + uint16_t disfc; /* Discard Frame Counter */ + uint16_t crcec; /* CRC Error Counter */ + uint16_t abtsc; /* Abort Sequence Counter */ + uint16_t nmarc; /* Nonmatching Address Received Cntr */ + uint16_t retrc; /* Frame Retransmission Counter */ + + uint16_t mflr; /* Maximum Frame Length Register */ + uint16_t max_cnt; /* Maximum_Length Counter */ + + uint16_t hmask; /* User Defined Frame Address Mask */ + uint16_t haddr1; /* User Defined Frame Address */ + uint16_t haddr2; /* " */ + uint16_t haddr3; /* " */ + uint16_t haddr4; /* " */ +} m302_SCC_HdlcSpecific_t; +/* + * HDLC receiver buffer descriptor bit definitions + * Section 4.5.12.10 + */ +#define RBIT_HDLC_EMPTY_BIT 0x8000 /* buffer associated with BD is empty */ +#define RBIT_HDLC_LAST_BIT 0x0800 /* buffer is last in a frame */ +#define RBIT_HDLC_FIRST_BIT 0x0400 /* buffer is first in a frame */ +#define RBIT_HDLC_FRAME_LEN 0x0020 /* receiver frame length violation */ +#define RBIT_HDLC_NONOCT_Rx 0x0010 /* received non-octet aligned frame */ +#define RBIT_HDLC_ABORT_SEQ 0x0008 /* received abort sequence */ +#define RBIT_HDLC_CRC_ERROR 0x0004 /* frame contains a CRC error */ +#define RBIT_HDLC_OVERRUN 0x0002 /* receiver overrun occurred */ +#define RBIT_HDLC_CD_LOST 0x0001 /* carrier detect lost */ + +/* + * HDLC transmit buffer descriptor bit definitions + * Section 4.5.12.11 + */ +#define RBIT_HDLC_READY_BIT 0x8000 /* buffer is ready to transmit */ +#define RBIT_HDLC_EXT_BUFFER 0x4000 /* buffer is in external memory */ +#define RBIT_HDLC_WRAP_BIT 0x2000 /* last buffer in bd table, so wrap */ +#define RBIT_HDLC_WAKE_UP 0x1000 /* interrupt when buffer serviced */ +#define RBIT_HDLC_LAST_BIT 0x0800 /* buffer is last in the frame */ +#define RBIT_HDLC_TxCRC_BIT 0x0400 /* transmit a CRC sequence */ +#define RBIT_HDLC_UNDERRUN 0x0002 /* transmitter underrun */ +#define RBIT_HDLC_CTS_LOST 0x0001 /* CTS lost */ + +/* + * HDLC event register bit definitions + * Section 4.5.12.12 + */ +#define RBIT_HDLC_CTS 0x80 /* CTS status changed */ +#define RBIT_HDLC_CD 0x40 /* carrier detect status changed */ +#define RBIT_HDLC_IDL 0x20 /* IDLE sequence status changed */ +#define RBIT_HDLC_TXE 0x10 /* transmit error */ +#define RBIT_HDLC_RXF 0x08 /* received frame */ +#define RBIT_HDLC_BSY 0x04 /* frame rcvd and discarded due to + * lack of buffers + */ +#define RBIT_HDLC_TXB 0x02 /* buffer has been transmitted */ +#define RBIT_HDLC_RXB 0x01 /* received buffer */ + + + +typedef struct { + m302_SCC_bd_table_t bd; /* +000 Buffer Descriptor Table */ + m302_SCC_parameters_t parm; /* +080 Common Parameter RAM */ + union { /* +09C Protocol-Specific Parm RAM */ + m302_SCC_UartSpecific_t uart; + m302_SCC_HdlcSpecific_t hdlc; + } prot; + uint8_t res[0x040]; /* +0C0 reserved, (not implemented) */ +} m302_SCC_t; + + +/* + * Common SCC Registers + */ +typedef struct { + uint16_t res1; + uint16_t scon; /* SCC Configuration Register 4.5.2 */ + uint16_t scm; /* SCC Mode Register 4.5.3 */ + uint16_t dsr; /* SCC Data Synchronization Register 4.5.4 */ + uint8_t scce; /* SCC Event Register 4.5.8.1 */ + uint8_t res2; + uint8_t sccm; /* SCC Mask Register 4.5.8.2 */ + uint8_t res3; + uint8_t sccs; /* SCC Status Register 4.5.8.3 */ + uint8_t res4; + uint16_t res5; +} m302_SCC_Registers_t; + +/* + * SCON - SCC Configuration Register + * Section 4.5.2 + */ +#define RBIT_SCON_WOMS (1<<15) /* Wired-OR Mode Select (NMSI mode only) + * When set, the TXD driver is an + * open-drain output */ +#define RBIT_SCON_EXTC (1<<14) /* External Clock Source */ +#define RBIT_SCON_TCS (1<<13) /* Transmit Clock Source */ +#define RBIT_SCON_RCS (1<<12) /* Receive Clock Source */ + +/* + * SCM - SCC Mode Register bit definitions + * Section 4.5.3 + * The parameter-specific mode bits occupy bits 15 through 6. + */ +#define RBIT_SCM_ENR (1<<3) /* Enable receiver */ +#define RBIT_SCM_ENT (1<<2) /* Enable transmitter */ + + +/* + * Internal MC68302 Registers + * starts at offset 0x800 from dual-port RAM base + * Section 2.8 + */ +typedef struct { + /* offset +800 */ + uint16_t res0; + uint16_t cmr; /* IDMA Channel Mode Register */ + uint32_t sapr; /* IDMA Source Address Pointer */ + uint32_t dapr; /* IDMA Destination Address Pointer */ + uint16_t bcr; /* IDMA Byte Count Register */ + uint8_t csr; /* IDMA Channel Status Register */ + uint8_t res1; + uint8_t fcr; /* IDMA Function Code Register */ + uint8_t res2; + + /* offset +812 */ + uint16_t gimr; /* Global Interrupt Mode Register */ + uint16_t ipr; /* Interrupt Pending Register */ + uint16_t imr; /* Interrupt Mask Register */ + uint16_t isr; /* Interrupt In-Service Register */ + uint16_t res3; + uint16_t res4; + + /* offset +81e */ + uint16_t pacnt; /* Port A Control Register */ + uint16_t paddr; /* Port A Data Direction Register */ + uint16_t padat; /* Port A Data Register */ + uint16_t pbcnt; /* Port B Control Register */ + uint16_t pbddr; /* Port B Data Direction Register */ + uint16_t pbdat; /* Port B Data Register */ + uint16_t res5; + + /* offset +82c */ + uint16_t res6; + uint16_t res7; + + uint16_t br0; /* Base Register (CS0) */ + uint16_t or0; /* Option Register (CS0) */ + uint16_t br1; /* Base Register (CS1) */ + uint16_t or1; /* Option Register (CS1) */ + uint16_t br2; /* Base Register (CS2) */ + uint16_t or2; /* Option Register (CS2) */ + uint16_t br3; /* Base Register (CS3) */ + uint16_t or3; /* Option Register (CS3) */ + + /* offset +840 */ + uint16_t tmr1; /* Timer Unit 1 Mode Register */ + uint16_t trr1; /* Timer Unit 1 Reference Register */ + uint16_t tcr1; /* Timer Unit 1 Capture Register */ + uint16_t tcn1; /* Timer Unit 1 Counter */ + uint8_t res8; + uint8_t ter1; /* Timer Unit 1 Event Register */ + uint16_t wrr; /* Watchdog Reference Register */ + uint16_t wcn; /* Watchdog Counter */ + uint16_t res9; + uint16_t tmr2; /* Timer Unit 2 Mode Register */ + uint16_t trr2; /* Timer Unit 2 Reference Register */ + uint16_t tcr2; /* Timer Unit 2 Capture Register */ + uint16_t tcn2; /* Timer Unit 2 Counter */ + uint8_t resa; + uint8_t ter2; /* Timer Unit 2 Event Register */ + uint16_t resb; + uint16_t resc; + uint16_t resd; + + /* offset +860 */ + uint8_t cr; /* Command Register */ + uint8_t rese[0x1f]; + + /* offset +880, +890, +8a0 */ + m302_SCC_Registers_t scc[3]; /* SCC1, SCC2, SCC3 Registers */ + + /* offset +8b0 */ + uint16_t spmode; /* SCP,SMC Mode and Clock Cntrl Reg */ + uint16_t simask; /* Serial Interface Mask Register */ + uint16_t simode; /* Serial Interface Mode Register */ +} m302_internalReg_t ; + + +/* + * MC68302 dual-port RAM structure. + * (Includes System RAM, Parameter RAM, and Internal Registers). + * Section 2.8 + */ +typedef struct { + uint8_t mem[0x240]; /* +000 User Data Memory */ + uint8_t res1[0x1c0]; /* +240 reserved, (not implemented) */ + m302_SCC_t scc1; /* +400 SCC1 */ + m302_SCC_t scc2; /* +500 SCC2 */ + m302_SCC_t scc3; /* +600 SCC3 */ + uint8_t res2[0x100]; /* +700 reserved, (not implemented) */ + m302_internalReg_t reg; /* +800 68302 Internal Registers */ +} m302_dualPortRAM_t; + +/* some useful defines the some of the registers above */ + + +/* ---- + MC68302 Chip Select Registers + p3-46 2nd Edition + + */ +#define BR_ENABLED 1 +#define BR_DISABLED 0 +#define BR_FC_NULL 0 +#define BR_READ_ONLY 0 +#define BR_READ_WRITE 2 +#define OR_DTACK_0 0x0000 +#define OR_DTACK_1 0x2000 +#define OR_DTACK_2 0x4000 +#define OR_DTACK_3 0x6000 +#define OR_DTACK_4 0x8000 +#define OR_DTACK_5 0xA000 +#define OR_DTACK_6 0xC000 +#define OR_DTACK_EXT 0xE000 +#define OR_SIZE_64K 0x1FE0 +#define OR_SIZE_128K 0x1FC0 +#define OR_SIZE_256K 0x1F80 +#define OR_SIZE_512K 0x1F00 +#define OR_SIZE_1M 0x1E00 +#define OR_SIZE_2M 0x1C00 +#define OR_MASK_RW 0x0000 +#define OR_NO_MASK_RW 0x0002 +#define OR_MASK_FC 0x0000 +#define OR_NO_MASK_FC 0x0001 + +#define MAKE_BR(base_address, enable, rw, fc) \ + ((base_address >> 11) | fc | rw | enable) + +#define MAKE_OR(bsize, DtAck, RW_Mask, FC_Mask) \ + (DtAck | ((~(bsize - 1) & 0x00FFFFFF) >> 11) | FC_Mask | RW_Mask) + +#define __REG_CAT(r, n) r ## n +#define WRITE_BR(csel, base_address, enable, rw, fc) \ + __REG_CAT(m302.reg.br, csel) = MAKE_BR(base_address, enable, rw, fc) +#define WRITE_OR(csel, bsize, DtAck, RW_Mask, FC_Mask) \ + __REG_CAT(m302.reg.or, csel) = MAKE_OR(bsize, DtAck, RW_Mask, FC_Mask) + +/* ---- + MC68302 Watchdog Timer Enable Bit + + */ +#define WATCHDOG_ENABLE (1) +#define WATCHDOG_TRIGGER() (m302.reg.wrr = 0x10 | WATCHDOG_ENABLE, m302.reg.wcn = 0) +#define WATCHDOG_TOGGLE() (m302.reg.wcn = WATCHDOG_TIMEOUT_PERIOD) +#define DISABLE_WATCHDOG() (m302.reg.wrr = 0) + +/* + * Declare the variable that's used to reference the variables in + * the dual-port RAM. + */ +extern volatile m302_dualPortRAM_t m302; + +#endif diff --git a/cpukit/score/cpu/m68k/include/rtems/m68k/m68360.h b/cpukit/score/cpu/m68k/include/rtems/m68k/m68360.h new file mode 100644 index 0000000000..dc181d0cdf --- /dev/null +++ b/cpukit/score/cpu/m68k/include/rtems/m68k/m68360.h @@ -0,0 +1,899 @@ +/** + * @file + * + * @brief Definitions for Motorola MC68360 Processor + */ +/* + ************************************************************************** + ************************************************************************** + ** ** + ** MOTOROLA MC68360 QUAD INTEGRATED COMMUNICATIONS CONTROLLER (QUICC) ** + ** ** + ** HARDWARE DECLARATIONS ** + ** ** + ** ** + ** Submitted By: ** + ** ** + ** W. Eric Norum ** + ** Saskatchewan Accelerator Laboratory ** + ** University of Saskatchewan ** + ** 107 North Road ** + ** Saskatoon, Saskatchewan, CANADA ** + ** S7N 5C6 ** + ** ** + ** eric@skatter.usask.ca ** + ** ** + ************************************************************************** + ************************************************************************** + */ + +#ifndef _RTEMS_M68K_M68360_H +#define _RTEMS_M68K_M68360_H + +/* + ************************************************************************* + * REGISTER SUBBLOCKS * + ************************************************************************* + */ + +/* + * Memory controller registers + */ +typedef struct m360MEMCRegisters_ { + unsigned long br; + unsigned long or; + unsigned long _pad[2]; +} m360MEMCRegisters_t; + +/* + * Serial Communications Controller registers + */ +typedef struct m360SCCRegisters_ { + unsigned long gsmr_l; + unsigned long gsmr_h; + unsigned short psmr; + unsigned short _pad0; + unsigned short todr; + unsigned short dsr; + unsigned short scce; + unsigned short _pad1; + unsigned short sccm; + unsigned char _pad2; + unsigned char sccs; + unsigned long _pad3[2]; +} m360SCCRegisters_t; + +/* + * Serial Management Controller registers + */ +typedef struct m360SMCRegisters_ { + unsigned short _pad0; + unsigned short smcmr; + unsigned short _pad1; + unsigned char smce; + unsigned char _pad2; + unsigned short _pad3; + unsigned char smcm; + unsigned char _pad4; + unsigned long _pad5; +} m360SMCRegisters_t; + + +/* + ************************************************************************* + * Miscellaneous Parameters * + ************************************************************************* + */ +typedef struct m360MiscParms_ { + unsigned short rev_num; + unsigned short _res1; + unsigned long _res2; + unsigned long _res3; +} m360MiscParms_t; + +/* + ************************************************************************* + * RISC Timers * + ************************************************************************* + */ +typedef struct m360TimerParms_ { + unsigned short tm_base; + unsigned short _tm_ptr; + unsigned short _r_tmr; + unsigned short _r_tmv; + unsigned long tm_cmd; + unsigned long tm_cnt; +} m360TimerParms_t; + +/* + * RISC Controller Configuration Register (RCCR) + * All other bits in this register are either reserved or + * used only with a Motorola-supplied RAM microcode packge. + */ +#define M360_RCCR_TIME (1<<15) /* Enable timer */ +#define M360_RCCR_TIMEP(x) ((x)<<8) /* Timer period */ + +/* + * Command register + * Set up this register before issuing a M360_CR_OP_SET_TIMER command. + */ +#define M360_TM_CMD_V (1<<31) /* Set to enable timer */ +#define M360_TM_CMD_R (1<<30) /* Set for automatic restart */ +#define M360_TM_CMD_TIMER(x) ((x)<<16) /* Select timer */ +#define M360_TM_CMD_PERIOD(x) (x) /* Timer period (16 bits) */ + +/* + ************************************************************************* + * DMA Controllers * + ************************************************************************* + */ +typedef struct m360IDMAparms_ { + unsigned short ibase; + unsigned short ibptr; + unsigned long _istate; + unsigned long _itemp; +} m360IDMAparms_t; + +/* + ************************************************************************* + * Serial Communication Controllers * + ************************************************************************* + */ +typedef struct m360SCCparms_ { + unsigned short rbase; + unsigned short tbase; + unsigned char rfcr; + unsigned char tfcr; + unsigned short mrblr; + unsigned long _rstate; + unsigned long _pad0; + unsigned short _rbptr; + unsigned short _pad1; + unsigned long _pad2; + unsigned long _tstate; + unsigned long _pad3; + unsigned short _tbptr; + unsigned short _pad4; + unsigned long _pad5; + unsigned long _rcrc; + unsigned long _tcrc; + union { + struct { + unsigned long _res0; + unsigned long _res1; + unsigned short max_idl; + unsigned short _idlc; + unsigned short brkcr; + unsigned short parec; + unsigned short frmec; + unsigned short nosec; + unsigned short brkec; + unsigned short brklen; + unsigned short uaddr[2]; + unsigned short _rtemp; + unsigned short toseq; + unsigned short character[8]; + unsigned short rccm; + unsigned short rccr; + unsigned short rlbc; + } uart; + struct { + unsigned long crc_p; + unsigned long crc_c; + } transparent; + + } un; +} m360SCCparms_t; + +typedef struct m360SCCENparms_ { + unsigned short rbase; + unsigned short tbase; + unsigned char rfcr; + unsigned char tfcr; + unsigned short mrblr; + unsigned long _rstate; + unsigned long _pad0; + unsigned short _rbptr; + unsigned short _pad1; + unsigned long _pad2; + unsigned long _tstate; + unsigned long _pad3; + unsigned short _tbptr; + unsigned short _pad4; + unsigned long _pad5; + unsigned long _rcrc; + unsigned long _tcrc; + union { + struct { + unsigned long _res0; + unsigned long _res1; + unsigned short max_idl; + unsigned short _idlc; + unsigned short brkcr; + unsigned short parec; + unsigned short frmec; + unsigned short nosec; + unsigned short brkec; + unsigned short brklen; + unsigned short uaddr[2]; + unsigned short _rtemp; + unsigned short toseq; + unsigned short character[8]; + unsigned short rccm; + unsigned short rccr; + unsigned short rlbc; + } uart; + struct { + unsigned long c_pres; + unsigned long c_mask; + unsigned long crcec; + unsigned long alec; + unsigned long disfc; + unsigned short pads; + unsigned short ret_lim; + unsigned short _ret_cnt; + unsigned short mflr; + unsigned short minflr; + unsigned short maxd1; + unsigned short maxd2; + unsigned short _maxd; + unsigned short dma_cnt; + unsigned short _max_b; + unsigned short gaddr1; + unsigned short gaddr2; + unsigned short gaddr3; + unsigned short gaddr4; + unsigned long _tbuf0data0; + unsigned long _tbuf0data1; + unsigned long _tbuf0rba0; + unsigned long _tbuf0crc; + unsigned short _tbuf0bcnt; + unsigned short paddr_h; + unsigned short paddr_m; + unsigned short paddr_l; + unsigned short p_per; + unsigned short _rfbd_ptr; + unsigned short _tfbd_ptr; + unsigned short _tlbd_ptr; + unsigned long _tbuf1data0; + unsigned long _tbuf1data1; + unsigned long _tbuf1rba0; + unsigned long _tbuf1crc; + unsigned short _tbuf1bcnt; + unsigned short _tx_len; + unsigned short iaddr1; + unsigned short iaddr2; + unsigned short iaddr3; + unsigned short iaddr4; + unsigned short _boff_cnt; + unsigned short taddr_h; + unsigned short taddr_m; + unsigned short taddr_l; + } ethernet; + struct { + unsigned long crc_p; + unsigned long crc_c; + } transparent; + } un; +} m360SCCENparms_t; + +/* + * Receive and transmit function code register bits + * These apply to the function code registers of all devices, not just SCC. + */ +#define M360_RFCR_MOT (1<<4) +#define M360_RFCR_DMA_SPACE 0x8 +#define M360_TFCR_MOT (1<<4) +#define M360_TFCR_DMA_SPACE 0x8 + +/* + ************************************************************************* + * Serial Management Controllers * + ************************************************************************* + */ +typedef struct m360SMCparms_ { + unsigned short rbase; + unsigned short tbase; + unsigned char rfcr; + unsigned char tfcr; + unsigned short mrblr; + unsigned long _rstate; + unsigned long _pad0; + unsigned short _rbptr; + unsigned short _pad1; + unsigned long _pad2; + unsigned long _tstate; + unsigned long _pad3; + unsigned short _tbptr; + unsigned short _pad4; + unsigned long _pad5; + union { + struct { + unsigned short max_idl; + unsigned short _pad0; + unsigned short brklen; + unsigned short brkec; + unsigned short brkcr; + unsigned short _r_mask; + } uart; + struct { + unsigned short _pad0[5]; + } transparent; + } un; +} m360SMCparms_t; + +/* + * Mode register + */ +#define M360_SMCMR_CLEN(x) ((x)<<11) /* Character length */ +#define M360_SMCMR_2STOP (1<<10) /* 2 stop bits */ +#define M360_SMCMR_PARITY (1<<9) /* Enable parity */ +#define M360_SMCMR_EVEN (1<<8) /* Even parity */ +#define M360_SMCMR_SM_GCI (0<<4) /* GCI Mode */ +#define M360_SMCMR_SM_UART (2<<4) /* UART Mode */ +#define M360_SMCMR_SM_TRANSPARENT (3<<4) /* Transparent Mode */ +#define M360_SMCMR_DM_LOOPBACK (1<<2) /* Local loopback mode */ +#define M360_SMCMR_DM_ECHO (2<<2) /* Echo mode */ +#define M360_SMCMR_TEN (1<<1) /* Enable transmitter */ +#define M360_SMCMR_REN (1<<0) /* Enable receiver */ + +/* + * Event and mask registers (SMCE, SMCM) + */ +#define M360_SMCE_BRK (1<<4) +#define M360_SMCE_BSY (1<<2) +#define M360_SMCE_TX (1<<1) +#define M360_SMCE_RX (1<<0) + +/* + ************************************************************************* + * Serial Peripheral Interface * + ************************************************************************* + */ +typedef struct m360SPIparms_ { + unsigned short rbase; + unsigned short tbase; + unsigned char rfcr; + unsigned char tfcr; + unsigned short mrblr; + unsigned long _rstate; + unsigned long _pad0; + unsigned short _rbptr; + unsigned short _pad1; + unsigned long _pad2; + unsigned long _tstate; + unsigned long _pad3; + unsigned short _tbptr; + unsigned short _pad4; + unsigned long _pad5; +} m360SPIparms_t; + +/* + * Mode register (SPMODE) + */ +#define M360_SPMODE_LOOP (1<<14) /* Local loopback mode */ +#define M360_SPMODE_CI (1<<13) /* Clock invert */ +#define M360_SPMODE_CP (1<<12) /* Clock phase */ +#define M360_SPMODE_DIV16 (1<<11) /* Divide BRGCLK by 16 */ +#define M360_SPMODE_REV (1<<10) /* Reverse data */ +#define M360_SPMODE_MASTER (1<<9) /* SPI is master */ +#define M360_SPMODE_EN (1<<8) /* Enable SPI */ +#define M360_SPMODE_CLEN(x) ((x)<<4) /* Character length */ +#define M360_SPMODE_PM(x) (x) /* Prescaler modulus */ + +/* + * Mode register (SPCOM) + */ +#define M360_SPCOM_STR (1<<7) /* Start transmit */ + +/* + * Event and mask registers (SPIE, SPIM) + */ +#define M360_SPIE_MME (1<<5) /* Multi-master error */ +#define M360_SPIE_TXE (1<<4) /* Tx error */ +#define M360_SPIE_BSY (1<<2) /* Busy condition*/ +#define M360_SPIE_TXB (1<<1) /* Tx buffer */ +#define M360_SPIE_RXB (1<<0) /* Rx buffer */ + +/* + ************************************************************************* + * SDMA (SCC, SMC, SPI) Buffer Descriptors * + ************************************************************************* + */ +typedef struct m360BufferDescriptor_ { + unsigned short status; + unsigned short length; + volatile void *buffer; +} m360BufferDescriptor_t; + +/* + * Bits in receive buffer descriptor status word + */ +#define M360_BD_EMPTY (1<<15) /* Ethernet, SCC UART, SMC UART, SPI */ +#define M360_BD_WRAP (1<<13) /* Ethernet, SCC UART, SMC UART, SPI */ +#define M360_BD_INTERRUPT (1<<12) /* Ethernet, SCC UART, SMC UART, SPI */ +#define M360_BD_LAST (1<<11) /* Ethernet, SPI */ +#define M360_BD_CONTROL_CHAR (1<<11) /* SCC UART */ +#define M360_BD_FIRST_IN_FRAME (1<<10) /* Ethernet */ +#define M360_BD_ADDRESS (1<<10) /* SCC UART */ +#define M360_BD_CONTINUOUS (1<<9) /* SCC UART, SMC UART, SPI */ +#define M360_BD_MISS (1<<8) /* Ethernet */ +#define M360_BD_IDLE (1<<8) /* SCC UART, SMC UART */ +#define M360_BD_ADDRSS_MATCH (1<<7) /* SCC UART */ +#define M360_BD_LONG (1<<5) /* Ethernet */ +#define M360_BD_BREAK (1<<5) /* SCC UART, SMC UART */ +#define M360_BD_NONALIGNED (1<<4) /* Ethernet */ +#define M360_BD_FRAMING_ERROR (1<<4) /* SCC UART, SMC UART */ +#define M360_BD_SHORT (1<<3) /* Ethernet */ +#define M360_BD_PARITY_ERROR (1<<3) /* SCC UART, SMC UART */ +#define M360_BD_CRC_ERROR (1<<2) /* Ethernet */ +#define M360_BD_OVERRUN (1<<1) /* Ethernet, SCC UART, SMC UART, SPI */ +#define M360_BD_COLLISION (1<<0) /* Ethernet */ +#define M360_BD_CARRIER_LOST (1<<0) /* SCC UART */ +#define M360_BD_MASTER_ERROR (1<<0) /* SPI */ + +/* + * Bits in transmit buffer descriptor status word + * Many bits have the same meaning as those in receiver buffer descriptors. + */ +#define M360_BD_READY (1<<15) /* Ethernet, SCC UART, SMC UART, SPI */ +#define M360_BD_PAD (1<<14) /* Ethernet */ +#define M360_BD_CTS_REPORT (1<<11) /* SCC UART */ +#define M360_BD_TX_CRC (1<<10) /* Ethernet */ +#define M360_BD_DEFER (1<<9) /* Ethernet */ +#define M360_BD_HEARTBEAT (1<<8) /* Ethernet */ +#define M360_BD_PREAMBLE (1<<8) /* SCC UART, SMC UART */ +#define M360_BD_LATE_COLLISION (1<<7) /* Ethernet */ +#define M360_BD_NO_STOP_BIT (1<<7) /* SCC UART */ +#define M360_BD_RETRY_LIMIT (1<<6) /* Ethernet */ +#define M360_BD_RETRY_COUNT(x) (((x)&0x3C)>>2) /* Ethernet */ +#define M360_BD_UNDERRUN (1<<1) /* Ethernet, SPI */ +#define M360_BD_CARRIER_LOST (1<<0) /* Ethernet */ +#define M360_BD_CTS_LOST (1<<0) /* SCC UART */ + +/* + ************************************************************************* + * IDMA Buffer Descriptors * + ************************************************************************* + */ +typedef struct m360IDMABufferDescriptor_ { + unsigned short status; + unsigned short _pad; + unsigned long length; + void *source; + void *destination; +} m360IDMABufferDescriptor_t; + +/* + ************************************************************************* + * RISC Communication Processor Module Command Register (CR) * + ************************************************************************* + */ +#define M360_CR_RST (1<<15) /* Reset communication processor */ +#define M360_CR_OP_INIT_RX_TX (0<<8) /* SCC, SMC UART, SMC GCI, SPI */ +#define M360_CR_OP_INIT_RX (1<<8) /* SCC, SMC UART, SPI */ +#define M360_CR_OP_INIT_TX (2<<8) /* SCC, SMC UART, SPI */ +#define M360_CR_OP_INIT_HUNT (3<<8) /* SCC, SMC UART */ +#define M360_CR_OP_STOP_TX (4<<8) /* SCC, SMC UART */ +#define M360_CR_OP_GR_STOP_TX (5<<8) /* SCC */ +#define M360_CR_OP_INIT_IDMA (5<<8) /* IDMA */ +#define M360_CR_OP_RESTART_TX (6<<8) /* SCC, SMC UART */ +#define M360_CR_OP_CLOSE_RX_BD (7<<8) /* SCC, SMC UART, SPI */ +#define M360_CR_OP_SET_GRP_ADDR (8<<8) /* SCC */ +#define M360_CR_OP_SET_TIMER (8<<8) /* Timer */ +#define M360_CR_OP_GCI_TIMEOUT (9<<8) /* SMC GCI */ +#define M360_CR_OP_RESERT_BCS (10<<8) /* SCC */ +#define M360_CR_OP_GCI_ABORT (10<<8) /* SMC GCI */ +#define M360_CR_CHAN_SCC1 (0<<4) /* Channel selection */ +#define M360_CR_CHAN_SCC2 (4<<4) +#define M360_CR_CHAN_SPI (5<<4) +#define M360_CR_CHAN_TIMER (5<<4) +#define M360_CR_CHAN_SCC3 (8<<4) +#define M360_CR_CHAN_SMC1 (9<<4) +#define M360_CR_CHAN_IDMA1 (9<<4) +#define M360_CR_CHAN_SCC4 (12<<4) +#define M360_CR_CHAN_SMC2 (13<<4) +#define M360_CR_CHAN_IDMA2 (13<<4) +#define M360_CR_FLG (1<<0) /* Command flag */ + +/* + ************************************************************************* + * System Protection Control Register (SYPCR) * + ************************************************************************* + */ +#define M360_SYPCR_SWE (1<<7) /* Software watchdog enable */ +#define M360_SYPCR_SWRI (1<<6) /* Software watchdog reset select */ +#define M360_SYPCR_SWT1 (1<<5) /* Software watchdog timing bit 1 */ +#define M360_SYPCR_SWT0 (1<<4) /* Software watchdog timing bit 0 */ +#define M360_SYPCR_DBFE (1<<3) /* Double bus fault monitor enable */ +#define M360_SYPCR_BME (1<<2) /* Bus monitor external enable */ +#define M360_SYPCR_BMT1 (1<<1) /* Bus monitor timing bit 1 */ +#define M360_SYPCR_BMT0 (1<<0) /* Bus monitor timing bit 0 */ + +/* + ************************************************************************* + * Memory Control Registers * + ************************************************************************* + */ +#define M360_GMR_RCNT(x) ((x)<<24) /* Refresh count */ +#define M360_GMR_RFEN (1<<23) /* Refresh enable */ +#define M360_GMR_RCYC(x) ((x)<<21) /* Refresh cycle length */ +#define M360_GMR_PGS(x) ((x)<<18) /* Page size */ +#define M360_GMR_DPS_32BIT (0<<16) /* DRAM port size */ +#define M360_GMR_DPS_16BIT (1<<16) +#define M360_GMR_DPS_8BIT (2<<16) +#define M360_GMR_DPS_DSACK (3<<16) +#define M360_GMR_WBT40 (1<<15) /* Wait between 040 transfers */ +#define M360_GMR_WBTQ (1<<14) /* Wait between 360 transfers */ +#define M360_GMR_SYNC (1<<13) /* Synchronous external access */ +#define M360_GMR_EMWS (1<<12) /* External master wait state */ +#define M360_GMR_OPAR (1<<11) /* Odd parity */ +#define M360_GMR_PBEE (1<<10) /* Parity bus error enable */ +#define M360_GMR_TSS40 (1<<9) /* TS* sample for 040 */ +#define M360_GMR_NCS (1<<8) /* No CPU space */ +#define M360_GMR_DWQ (1<<7) /* Delay write for 360 */ +#define M360_GMR_DW40 (1<<6) /* Delay write for 040 */ +#define M360_GMR_GAMX (1<<5) /* Global address mux enable */ + +#define M360_MEMC_BR_FC(x) ((x)<<7) /* Function code limit */ +#define M360_MEMC_BR_TRLXQ (1<<6) /* Relax timing requirements */ +#define M360_MEMC_BR_BACK40 (1<<5) /* Burst acknowledge to 040 */ +#define M360_MEMC_BR_CSNT40 (1<<4) /* CS* negate timing for 040 */ +#define M360_MEMC_BR_CSNTQ (1<<3) /* CS* negate timing for 360 */ +#define M360_MEMC_BR_PAREN (1<<2) /* Enable parity checking */ +#define M360_MEMC_BR_WP (1<<1) /* Write Protect */ +#define M360_MEMC_BR_V (1<<0) /* Base/Option register are valid */ + +#define M360_MEMC_OR_TCYC(x) ((x)<<28) /* Cycle length (clocks) */ +#define M360_MEMC_OR_WAITS(x) M360_MEMC_OR_TCYC((x)+1) +#define M360_MEMC_OR_2KB 0x0FFFF800 /* Address range */ +#define M360_MEMC_OR_4KB 0x0FFFF000 +#define M360_MEMC_OR_8KB 0x0FFFE000 +#define M360_MEMC_OR_16KB 0x0FFFC000 +#define M360_MEMC_OR_32KB 0x0FFF8000 +#define M360_MEMC_OR_64KB 0x0FFF0000 +#define M360_MEMC_OR_128KB 0x0FFE0000 +#define M360_MEMC_OR_256KB 0x0FFC0000 +#define M360_MEMC_OR_512KB 0x0FF80000 +#define M360_MEMC_OR_1MB 0x0FF00000 +#define M360_MEMC_OR_2MB 0x0FE00000 +#define M360_MEMC_OR_4MB 0x0FC00000 +#define M360_MEMC_OR_8MB 0x0F800000 +#define M360_MEMC_OR_16MB 0x0F000000 +#define M360_MEMC_OR_32MB 0x0E000000 +#define M360_MEMC_OR_64MB 0x0C000000 +#define M360_MEMC_OR_128MB 0x08000000 +#define M360_MEMC_OR_256MB 0x00000000 +#define M360_MEMC_OR_FCMC(x) ((x)<<7) /* Function code mask */ +#define M360_MEMC_OR_BCYC(x) ((x)<<5) /* Burst cycle length (clocks) */ +#define M360_MEMC_OR_PGME (1<<3) /* Page mode enable */ +#define M360_MEMC_OR_32BIT (0<<1) /* Port size */ +#define M360_MEMC_OR_16BIT (1<<1) +#define M360_MEMC_OR_8BIT (2<<1) +#define M360_MEMC_OR_DSACK (3<<1) +#define M360_MEMC_OR_DRAM (1<<0) /* Dynamic RAM select */ + +/* + ************************************************************************* + * SI Mode Register (SIMODE) * + ************************************************************************* + */ +#define M360_SI_SMC2_BITS 0xFFFF0000 /* All SMC2 bits */ +#define M360_SI_SMC2_TDM (1<<31) /* Multiplexed SMC2 */ +#define M360_SI_SMC2_BRG1 (0<<28) /* SMC2 clock souce */ +#define M360_SI_SMC2_BRG2 (1<<28) +#define M360_SI_SMC2_BRG3 (2<<28) +#define M360_SI_SMC2_BRG4 (3<<28) +#define M360_SI_SMC2_CLK5 (0<<28) +#define M360_SI_SMC2_CLK6 (1<<28) +#define M360_SI_SMC2_CLK7 (2<<28) +#define M360_SI_SMC2_CLK8 (3<<28) +#define M360_SI_SMC1_BITS 0x0000FFFF /* All SMC1 bits */ +#define M360_SI_SMC1_TDM (1<<15) /* Multiplexed SMC1 */ +#define M360_SI_SMC1_BRG1 (0<<12) /* SMC1 clock souce */ +#define M360_SI_SMC1_BRG2 (1<<12) +#define M360_SI_SMC1_BRG3 (2<<12) +#define M360_SI_SMC1_BRG4 (3<<12) +#define M360_SI_SMC1_CLK1 (0<<12) +#define M360_SI_SMC1_CLK2 (1<<12) +#define M360_SI_SMC1_CLK3 (2<<12) +#define M360_SI_SMC1_CLK4 (3<<12) + +/* + ************************************************************************* + * SDMA Configuration Register (SDMA) * + ************************************************************************* + */ +#define M360_SDMA_FREEZE (2<<13) /* Freeze on next bus cycle */ +#define M360_SDMA_SISM_7 (7<<8) /* Normal interrupt service mask */ +#define M360_SDMA_SAID_4 (4<<4) /* Normal arbitration ID */ +#define M360_SDMA_INTE (1<<1) /* SBER interrupt enable */ +#define M360_SDMA_INTB (1<<0) /* SBKP interrupt enable */ + +/* + ************************************************************************* + * Baud (sic) Rate Generators * + ************************************************************************* + */ +#define M360_BRG_RST (1<<17) /* Reset generator */ +#define M360_BRG_EN (1<<16) /* Enable generator */ +#define M360_BRG_EXTC_BRGCLK (0<<14) /* Source is BRGCLK */ +#define M360_BRG_EXTC_CLK2 (1<<14) /* Source is CLK2 pin */ +#define M360_BRG_EXTC_CLK6 (2<<14) /* Source is CLK6 pin */ +#define M360_BRG_ATB (1<<13) /* Autobaud */ +#define M360_BRG_115200 (13<<1) /* Assume 25 MHz clock */ +#define M360_BRG_57600 (26<<1) +#define M360_BRG_38400 (40<<1) +#define M360_BRG_19200 (80<<1) +#define M360_BRG_9600 (162<<1) +#define M360_BRG_4800 (324<<1) +#define M360_BRG_2400 (650<<1) +#define M360_BRG_1200 (1301<<1) +#define M360_BRG_600 (2603<<1) +#define M360_BRG_300 ((324<<1) | 1) +#define M360_BRG_150 ((650<<1) | 1) +#define M360_BRG_75 ((1301<<1) | 1) + +/* + ************************************************************************* + * MC68360 DUAL-PORT RAM AND REGISTERS * + ************************************************************************* + */ +typedef struct m360_ { + /* + * Dual-port RAM + */ + unsigned char dpram0[0x400]; /* Microcode program */ + unsigned char dpram1[0x200]; + unsigned char dpram2[0x100]; /* Microcode scratch */ + unsigned char dpram3[0x100]; /* Not on REV A or B masks */ + unsigned char _rsv0[0xC00-0x800]; + m360SCCENparms_t scc1p; + unsigned char _rsv1[0xCB0-0xC00-sizeof(m360SCCENparms_t)]; + m360MiscParms_t miscp; + unsigned char _rsv2[0xD00-0xCB0-sizeof(m360MiscParms_t)]; + m360SCCparms_t scc2p; + unsigned char _rsv3[0xD80-0xD00-sizeof(m360SCCparms_t)]; + m360SPIparms_t spip; + unsigned char _rsv4[0xDB0-0xD80-sizeof(m360SPIparms_t)]; + m360TimerParms_t tmp; + unsigned char _rsv5[0xE00-0xDB0-sizeof(m360TimerParms_t)]; + m360SCCparms_t scc3p; + unsigned char _rsv6[0xE70-0xE00-sizeof(m360SCCparms_t)]; + m360IDMAparms_t idma1p; + unsigned char _rsv7[0xE80-0xE70-sizeof(m360IDMAparms_t)]; + m360SMCparms_t smc1p; + unsigned char _rsv8[0xF00-0xE80-sizeof(m360SMCparms_t)]; + m360SCCparms_t scc4p; + unsigned char _rsv9[0xF70-0xF00-sizeof(m360SCCparms_t)]; + m360IDMAparms_t idma2p; + unsigned char _rsv10[0xF80-0xF70-sizeof(m360IDMAparms_t)]; + m360SMCparms_t smc2p; + unsigned char _rsv11[0x1000-0xF80-sizeof(m360SMCparms_t)]; + + /* + * SIM Block + */ + unsigned long mcr; + unsigned long _pad00; + unsigned char avr; + unsigned char rsr; + unsigned short _pad01; + unsigned char clkocr; + unsigned char _pad02; + unsigned short _pad03; + unsigned short pllcr; + unsigned short _pad04; + unsigned short cdvcr; + unsigned short pepar; + unsigned long _pad05[2]; + unsigned short _pad06; + unsigned char sypcr; + unsigned char swiv; + unsigned short _pad07; + unsigned short picr; + unsigned short _pad08; + unsigned short pitr; + unsigned short _pad09; + unsigned char _pad10; + unsigned char swsr; + unsigned long bkar; + unsigned long bcar; + unsigned long _pad11[2]; + + /* + * MEMC Block + */ + unsigned long gmr; + unsigned short mstat; + unsigned short _pad12; + unsigned long _pad13[2]; + m360MEMCRegisters_t memc[8]; + unsigned char _pad14[0xF0-0xD0]; + unsigned char _pad15[0x100-0xF0]; + unsigned char _pad16[0x500-0x100]; + + /* + * IDMA1 Block + */ + unsigned short iccr; + unsigned short _pad17; + unsigned short cmr1; + unsigned short _pad18; + unsigned long sapr1; + unsigned long dapr1; + unsigned long bcr1; + unsigned char fcr1; + unsigned char _pad19; + unsigned char cmar1; + unsigned char _pad20; + unsigned char csr1; + unsigned char _pad21; + unsigned short _pad22; + + /* + * SDMA Block + */ + unsigned char sdsr; + unsigned char _pad23; + unsigned short sdcr; + unsigned long sdar; + + /* + * IDMA2 Block + */ + unsigned short _pad24; + unsigned short cmr2; + unsigned long sapr2; + unsigned long dapr2; + unsigned long bcr2; + unsigned char fcr2; + unsigned char _pad26; + unsigned char cmar2; + unsigned char _pad27; + unsigned char csr2; + unsigned char _pad28; + unsigned short _pad29; + unsigned long _pad30; + + /* + * CPIC Block + */ + unsigned long cicr; + unsigned long cipr; + unsigned long cimr; + unsigned long cisr; + + /* + * Parallel I/O Block + */ + unsigned short padir; + unsigned short papar; + unsigned short paodr; + unsigned short padat; + unsigned long _pad31[2]; + unsigned short pcdir; + unsigned short pcpar; + unsigned short pcso; + unsigned short pcdat; + unsigned short pcint; + unsigned short _pad32; + unsigned long _pad33[5]; + + /* + * TIMER Block + */ + unsigned short tgcr; + unsigned short _pad34; + unsigned long _pad35[3]; + unsigned short tmr1; + unsigned short tmr2; + unsigned short trr1; + unsigned short trr2; + unsigned short tcr1; + unsigned short tcr2; + unsigned short tcn1; + unsigned short tcn2; + unsigned short tmr3; + unsigned short tmr4; + unsigned short trr3; + unsigned short trr4; + unsigned short tcr3; + unsigned short tcr4; + unsigned short tcn3; + unsigned short tcn4; + unsigned short ter1; + unsigned short ter2; + unsigned short ter3; + unsigned short ter4; + unsigned long _pad36[2]; + + /* + * CP Block + */ + unsigned short cr; + unsigned short _pad37; + unsigned short rccr; + unsigned short _pad38; + unsigned long _pad39[3]; + unsigned short _pad40; + unsigned short rter; + unsigned short _pad41; + unsigned short rtmr; + unsigned long _pad42[5]; + + /* + * BRG Block + */ + unsigned long brgc1; + unsigned long brgc2; + unsigned long brgc3; + unsigned long brgc4; + + /* + * SCC Block + */ + m360SCCRegisters_t scc1; + m360SCCRegisters_t scc2; + m360SCCRegisters_t scc3; + m360SCCRegisters_t scc4; + + /* + * SMC Block + */ + m360SMCRegisters_t smc1; + m360SMCRegisters_t smc2; + + /* + * SPI Block + */ + unsigned short spmode; + unsigned short _pad43[2]; + unsigned char spie; + unsigned char _pad44; + unsigned short _pad45; + unsigned char spim; + unsigned char _pad46[2]; + unsigned char spcom; + unsigned short _pad47[2]; + + /* + * PIP Block + */ + unsigned short pipc; + unsigned short _pad48; + unsigned short ptpr; + unsigned long pbdir; + unsigned long pbpar; + unsigned short _pad49; + unsigned short pbodr; + unsigned long pbdat; + unsigned long _pad50[6]; + + /* + * SI Block + */ + unsigned long simode; + unsigned char sigmr; + unsigned char _pad51; + unsigned char sistr; + unsigned char sicmr; + unsigned long _pad52; + unsigned long sicr; + unsigned short _pad53; + unsigned short sirp[2]; + unsigned short _pad54; + unsigned long _pad55[2]; + unsigned char siram[256]; +} m360_t; + +extern volatile m360_t m360; + +/* + * definitions for the port b SPI pin bits + */ +#define M360_PB_SPI_MISO_MSK (1<< 3) +#define M360_PB_SPI_MOSI_MSK (1<< 2) +#define M360_PB_SPI_CLK_MSK (1<< 1) + +#endif /* _RTEMS_M68K_M68360_H */ diff --git a/cpukit/score/cpu/m68k/include/rtems/m68k/qsm.h b/cpukit/score/cpu/m68k/include/rtems/m68k/qsm.h new file mode 100644 index 0000000000..32dbc1d5f9 --- /dev/null +++ b/cpukit/score/cpu/m68k/include/rtems/m68k/qsm.h @@ -0,0 +1,204 @@ +/** + * @file + * + * @brief Motorola M68K Queued Serial Module + * + * The QSM contains two serial interfaces: (a) the queued serial + * peripheral interface (QSPI) and the serial communication interface + * (SCI). The QSPI provides peripheral expansion and/or interprocessor + * communication through a full-duplex, synchronous, three-wire bus. A + * self contained RAM queue permits serial data transfers without CPU + * intervention and automatic continuous sampling. The SCI provides a + * standard non-return to zero mark/space format with wakeup functions + * to allow the CPU to run uninterrupted until woken + * + * For more information, refer to Motorola's "Modular Microcontroller + * Family Queued Serial Module Reference Manual" (Motorola document + * QSMRM/AD). + */ + +/* + * This file was created by John S. Gwynne to support Motorola's 68332 MCU. + * + * Redistribution and use in source and binary forms are permitted + * provided that the following conditions are met: + * 1. Redistribution of source code and documentation must retain + * the above authorship, this list of conditions and the + * following disclaimer. + * 2. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * This software is provided "AS IS" without warranty of any kind, + * either expressed or implied, including, but not limited to, the + * implied warranties of merchantability, title and fitness for a + * particular purpose. + * + *------------------------------------------------------------------ + */ + +#ifndef _RTEMS_M68K_QSM_H +#define _RTEMS_M68K_QSM_H + +/* SAM-- shift and mask */ +#undef SAM +#define SAM(a,b,c) ((a << b) & c) + + +/* QSM_CRB (QSM Control Register Block) base address of the QSM + control registers */ +#if SIM_MM == 0 +#define QSM_CRB 0x7ffc00 +#else +#undef SIM_MM +#define SIM_MM 1 +#define QSM_CRB 0xfffc00 +#endif + + +#define QSMCR (volatile unsigned short int * const)(0x00 + QSM_CRB) + /* QSM Configuration Register */ +#define STOP 0x8000 /* Stop Enable */ +#define FRZ 0x6000 /* Freeze Control */ +#define SUPV 0x0080 /* Supervisor/Unrestricted */ +#define IARB 0x000f /* Inerrupt Arbitration */ + + +#define QTEST (volatile unsigned short int * const)(0x02 + QSM_CRB) + /* QSM Test Register */ +/* Used only for factor testing */ + + +#define QILR (volatile unsigned char * const)(0x04 + QSM_CRB) + /* QSM Interrupt Level Register */ +#define ILQSPI 0x38 /* Interrupt Level for QSPI */ +#define ILSCI 0x07 /* Interrupt Level for SCI */ + + +#define QIVR (volatile unsigned char * const)(0x05 + QSM_CRB) + /* QSM Interrupt Vector Register */ +#define INTV 0xff /* Interrupt Vector Number */ + + +#define SCCR0 (volatile unsigned short int * const)(0x08 + QSM_CRB) + /* SCI Control Register 0 */ +#define SCBR 0x1fff /* SCI Baud Rate */ + + +#define SCCR1 (volatile unsigned short int * const)(0x0a + QSM_CRB) + /* SCI Control Register 1 */ +#define LOOPS 0x4000 /* Loop Mode */ +#define WOMS 0x2000 /* Wired-OR Mode for SCI Pins */ +#define ILT 0x1000 /* Idle-Line Detect Type */ +#define PT 0x0800 /* Parity Type */ +#define PE 0x0400 /* Parity Enable */ +#define M 0x0200 /* Mode Select */ +#define WAKE 0x0100 /* Wakeup by Address Mark */ +#define TIE 0x0080 /* Transmit Complete Interrupt Enable */ +#define TCIE 0x0040 /* Transmit Complete Interrupt Enable */ +#define RIE 0x0020 /* Receiver Interrupt Enable */ +#define ILIE 0x0010 /* Idle-Line Interrupt Enable */ +#define TE 0x0008 /* Transmitter Enable */ +#define RE 0x0004 /* Receiver Enable */ +#define RWU 0x0002 /* Receiver Wakeup */ +#define SBK 0x0001 /* Send Break */ + + +#define SCSR (volatile unsigned short int * const)(0x0c + QSM_CRB) + /* SCI Status Register */ +#define TDRE 0x0100 /* Transmit Data Register Empty */ +#define TC 0x0080 /* Transmit Complete */ +#define RDRF 0x0040 /* Receive Data Register Full */ +#define RAF 0x0020 /* Receiver Active */ +#define IDLE 0x0010 /* Idle-Line Detected */ +#define OR 0x0008 /* Overrun Error */ +#define NF 0x0004 /* Noise Error Flag */ +#define FE 0x0002 /* Framing Error */ +#define PF 0x0001 /* Parity Error */ + + +#define SCDR (volatile unsigned short int * const)(0x0e + QSM_CRB) + /* SCI Data Register */ + + +#define PORTQS (volatile unsigned char * const)(0x15 + QSM_CRB) + /* Port QS Data Register */ + +#define PQSPAR (volatile unsigned char * const)(0x16 + QSM_CRB) + /* PORT QS Pin Assignment Rgister */ +/* Any bit cleared (zero) defines the corresponding pin to be an I/O + pin. Any bit set defines the corresponding pin to be a QSPI + signal. */ +/* note: PQS2 is a digital I/O pin unless the SPI is enabled in which + case it becomes the SPI serial clock SCK. */ +/* note: PQS7 is a digital I/O pin unless the SCI transmitter is + enabled in which case it becomes the SCI serial output TxD. */ +#define QSMFun 0x0 +#define QSMDis 0x1 +/* + * PQSPAR Field | QSM Function | Discrete I/O pin + *------------------+--------------+------------------ */ +#define PQSPA0 0 /* MISO | PQS0 */ +#define PQSPA1 1 /* MOSI | PQS1 */ +#define PQSPA2 2 /* SCK | PQS2 (see note)*/ +#define PQSPA3 3 /* PCSO/!SS | PQS3 */ +#define PQSPA4 4 /* PCS1 | PQS4 */ +#define PQSPA5 5 /* PCS2 | PQS5 */ +#define PQSPA6 6 /* PCS3 | PQS6 */ +#define PQSPA7 7 /* TxD | PQS7 (see note)*/ + + +#define DDRQS (volatile unsigned char * const)(0x17 + QSM_CRB) + /* PORT QS Data Direction Register */ +/* Clearing a bit makes the corresponding pin an input; setting a bit + makes the pin an output. */ + + +#define SPCR0 (volatile unsigned short int * const)(0x18 + QSM_CRB) + /* QSPI Control Register 0 */ +#define MSTR 0x8000 /* Master/Slave Mode Select */ +#define WOMQ 0x4000 /* Wired-OR Mode for QSPI Pins */ +#define BITS 0x3c00 /* Bits Per Transfer */ +#define CPOL 0x0200 /* Clock Polarity */ +#define CPHA 0x0100 /* Clock Phase */ +#define SPBR 0x00ff /* Serial Clock Baud Rate */ + + +#define SPCR1 (volatile unsigned short int * const)(0x1a + QSM_CRB) + /* QSPI Control Register 1 */ +#define SPE 0x8000 /* QSPI Enable */ +#define DSCKL 0x7f00 /* Delay before SCK */ +#define DTL 0x00ff /* Length of Delay after Transfer */ + + +#define SPCR2 (volatile unsigned short int * const)(0x1c + QSM_CRB) + /* QSPI Control Register 2 */ +#define SPIFIE 0x8000 /* SPI Finished Interrupt Enable */ +#define WREN 0x4000 /* Wrap Enable */ +#define WRTO 0x2000 /* Wrap To */ +#define ENDQP 0x0f00 /* Ending Queue Pointer */ +#define NEWQP 0x000f /* New Queue Pointer Value */ + + +#define SPCR3 (volatile unsigned char * const)(0x1e + QSM_CRB) + /* QSPI Control Register 3 */ +#define LOOPQ 0x0400 /* QSPI Loop Mode */ +#define HMIE 0x0200 /* HALTA and MODF Interrupt Enable */ +#define HALT 0x0100 /* Halt */ + + +#define SPSR (volatile unsigned char * const)(0x1f + QSM_CRB) + /* QSPI Status Register */ +#define SPIF 0x0080 /* QSPI Finished Flag */ +#define MODF 0x0040 /* Mode Fault Flag */ +#define HALTA 0x0020 /* Halt Acknowlwdge Flag */ +#define CPTQP x0000f /* Completed Queue Pointer */ + +#define QSPIRR (volatile unsigned char * const)(0x100 + QSM_CRB) + /* QSPI Receive Data RAM */ +#define QSPITR (volatile unsigned char * const)(0x120 + QSM_CRB) + /* QSPI Transmit Data RAM */ +#define QSPIcR (volatile unsigned char * const)(0x140 + QSM_CRB) + /* QSPI Command RAM */ + +#endif /* _RTEMS_M68K_QSM_H */ diff --git a/cpukit/score/cpu/m68k/include/rtems/m68k/sim.h b/cpukit/score/cpu/m68k/include/rtems/m68k/sim.h new file mode 100644 index 0000000000..cec6b84cc1 --- /dev/null +++ b/cpukit/score/cpu/m68k/include/rtems/m68k/sim.h @@ -0,0 +1,333 @@ +/** + * @file + * + * @brief Motorola M68K System Integration Module + * + * The system integration module (SIM) is used on many Motorola 16- + * and 32-bit MCUs for the following functions: + * + * () System configuration and protection. Bus and software watchdog + * monitors are provided in addition to periodic interrupt generators. + * + * () Clock signal generation for other intermodule bus (IMB) members + * and external devices. + * + * () The generation of chip-select signals that simplify external + * circuitry interface. + * + * () Data ports that are available for general purpose input and + * output. + * + * () A system test block that is intended only for factory tests. + * + * For more information, refer to Motorola's "Modular Microcontroller + * Family System Integration Module Reference Manual" (Motorola document + * SIMRM/AD). + */ + +/* + * This file was created by John S. Gwynne to support Motorola's 68332 MCU. + * + * Redistribution and use in source and binary forms are permitted + * provided that the following conditions are met: + * 1. Redistribution of source code and documentation must retain + * the above authorship, this list of conditions and the + * following disclaimer. + * 2. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * This software is provided "AS IS" without warranty of any kind, + * either expressed or implied, including, but not limited to, the + * implied warranties of merchantability, title and fitness for a + * particular purpose. + * + *------------------------------------------------------------------ + */ + +#ifndef _RTEMS_M68K_SIM_H +#define _RTEMS_M68K_SIM_H + + +/* SAM-- shift and mask */ +#undef SAM +#define SAM(a,b,c) ((a << b) & c) + +/* + * These macros make this file usable from assembly. + */ + +#ifdef ASM +#define SIM_VOLATILE_USHORT_POINTER +#define SIM_VOLATILE_UCHAR_POINTER +#else +#define SIM_VOLATILE_USHORT_POINTER (volatile unsigned short int * const) +#define SIM_VOLATILE_UCHAR_POINTER (volatile unsigned char * const) +#endif + +/* SIM_CRB (SIM Control Register Block) base address of the SIM + control registers */ +#ifndef SIM_CRB +#if SIM_MM == 0 +#define SIM_CRB 0x7ffa00 +#else /* SIM_MM */ +#undef SIM_MM +#define SIM_MM 1 +#define SIM_CRB 0xfffa00 +#endif /* SIM_MM */ +#endif /* SIM_CRB */ + + +#define SIMCR SIM_VOLATILE_USHORT_POINTER(0x00 + SIM_CRB) + /* Module Configuration Register */ +#define EXOFF 0x8000 /* External Clock Off */ +#define FRZSW 0x4000 /* Freeze Software Enable */ +#define FRZBM 0x2000 /* Freeze Bus Monitor Enable */ +#define SLVEN 0x0800 /* Factory Test Model Enabled (ro)*/ +#define SHEN 0x0300 /* Show Cycle Enable */ +#define SUPV 0x0080 /* Supervisor/Unrestricted Data Space */ +#define MM 0x0040 /* Module Mapping */ +#define IARB 0x000f /* Interrupt Arbitration Field */ + + + +#define SIMTR SIM_VOLATILE_USHORT_POINTER(0x02 + SIM_CRB) + /* SIM Test Register */ +/* Used only for factor testing */ + + + +#define SYNCR SIM_VOLATILE_USHORT_POINTER(0x04 + SIM_CRB) + /* Clock Synthesizer Control Register */ +#define VCO 0x8000 /* Frequency Control (VCO) */ +#define PRESCALE 0x4000 /* Frequency Control Bit (Prescale) */ +#define COUNTER 0x3f00 /* Frequency Control Counter */ +#define EDIV 0x0080 /* ECLK Divide Rate */ +#define SLIMP 0x0010 /* Limp Mode Status */ +#define SLOCK 0x0008 /* Synthesizer Lock */ +#define RSTEN 0x0004 /* Reset Enable */ +#define STSIM 0x0002 /* Stop Mode SIM Clock */ +#define STEXT 0x0001 /* Stop Mode External Clock */ + + + +#define RSR SIM_VOLATILE_UCHAR_POINTER(0x07 + SIM_CRB) + /* Reset Status Register */ +#define EXT 0x0080 /* External Reset */ +#define POW 0x0040 /* Power-On Reset */ +#define SW 0x0020 /* Software Watchdog Reset */ +#define DBF 0x0010 /* Double Bus Fault Reset */ +#define LOC 0x0004 /* Loss of Clock Reset */ +#define SYS 0x0002 /* System Reset */ +#define TST 0x0001 /* Test Submodule Reset */ + + + +#define SIMTRE SIM_VOLATILE_USHORT_POINTER(0x08 + SIM_CRB) + /* System Integration Test Register */ +/* Used only for factor testing */ + + + +#define PORTE0 SIM_VOLATILE_UCHAR_POINTER(0x11 + SIM_CRB) +#define PORTE1 SIM_VOLATILE_UCHAR_POINTER(0x13 + SIM_CRB) + /* Port E Data Register */ +#define DDRE SIM_VOLATILE_UCHAR_POINTER(0x15 + SIM_CRB) + /* Port E Data Direction Register */ +#define PEPAR SIM_VOLATILE_UCHAR_POINTER(0x17 + SIM_CRB) + /* Port E Pin Assignment Register */ +/* Any bit cleared (zero) defines the corresponding pin to be an I/O + pin. Any bit set defines the corresponding pin to be a bus control + signal. */ + + + +#define PORTF0 SIM_VOLATILE_UCHAR_POINTER(0x19 + SIM_CRB) +#define PORTF1 SIM_VOLATILE_UCHAR_POINTER(0x1b + SIM_CRB) + /* Port F Data Register */ +#define DDRF SIM_VOLATILE_UCHAR_POINTER(0x1d + SIM_CRB) + /* Port E Data Direction Register */ +#define PFPAR SIM_VOLATILE_UCHAR_POINTER(0x1f + SIM_CRB) +/* Any bit cleared (zero) defines the corresponding pin to be an I/O + pin. Any bit set defines the corresponding pin to be a bus control + signal. */ + + + +#define SYPCR SIM_VOLATILE_UCHAR_POINTER(0x21 + SIM_CRB) +/* !!! can write to only once after reset !!! */ + /* System Protection Control Register */ +#define SWE 0x80 /* Software Watch Enable */ +#define SWP 0x40 /* Software Watchdog Prescale */ +#define SWT 0x30 /* Software Watchdog Timing */ +#define HME 0x08 /* Halt Monitor Enable */ +#define BME 0x04 /* Bus Monitor External Enable */ +#define BMT 0x03 /* Bus Monitor Timing */ + + + +#define PICR SIM_VOLATILE_USHORT_POINTER(0x22 + SIM_CRB) + /* Periodic Interrupt Control Reg. */ +#define PIRQL 0x0700 /* Periodic Interrupt Request Level */ +#define PIV 0x00ff /* Periodic Interrupt Level */ + + + +#define PITR SIM_VOLATILE_USHORT_POINTER(0x24 + SIM_CRB) + /* Periodic Interrupt Timer Register */ +#define PTP 0x0100 /* Periodic Timer Prescaler Control */ +#define PITM 0x00ff /* Periodic Interrupt Timing Modulus */ + + + +#define SWSR SIM_VOLATILE_UCHAR_POINTER(0x27 + SIM_CRB) + /* Software Service Register */ +/* write 0x55 then 0xaa to service the software watchdog */ + + + +#define TSTMSRA SIM_VOLATILE_USHORT_POINTER(0x30 + SIM_CRB) + /* Test Module Master Shift A */ +#define TSTMSRB SIM_VOLATILE_USHORT_POINTER(0x32 + SIM_CRB) + /* Test Module Master Shift A */ +#define TSTSC SIM_VOLATILE_USHORT_POINTER(0x34 + SIM_CRB) + /* Test Module Shift Count */ +#define TSTRC SIM_VOLATILE_USHORT_POINTER(0x36 + SIM_CRB) + /* Test Module Repetition Counter */ +#define CREG SIM_VOLATILE_USHORT_POINTER(0x38 + SIM_CRB) + /* Test Module Control */ +#define DREG SIM_VOLATILE_USHORT_POINTER(0x3a + SIM_CRB) + /* Test Module Distributed */ +/* Used only for factor testing */ + + + +#define PORTC SIM_VOLATILE_UCHAR_POINTER(0x41 + SIM_CRB) + /* Port C Data */ + + + +#define CSPAR0 SIM_VOLATILE_USHORT_POINTER(0x44 + SIM_CRB) + /* Chip Select Pin Assignment + Resgister 0 */ +/* CSPAR0 contains seven two-bit fields that determine the functions + of corresponding chip-select pins. CSPAR0[15:14] are not + used. These bits always read zero; write have no effect. CSPAR0 bit + 1 always reads one; writes to CSPAR0 bit 1 have no effect. */ +#define CSPAR1 SIM_VOLATILE_USHORT_POINTER(0x46 + SIM_CRB) + /* Chip Select Pin Assignment + Register 1 */ +/* CSPAR1 contains five two-bit fields that determine the finctions of + corresponding chip-select pins. CSPAR1[15:10] are not used. These + bits always read zero; writes have no effect. */ +/* + * + * Bit Field | Description + * ------------+--------------- + * 00 | Discrete Output + * 01 | Alternate Function + * 10 | Chip Select (8-bit port) + * 11 | Chip Select (16-bit port) + */ +#define DisOut 0x0 +#define AltFun 0x1 +#define CS8bit 0x2 +#define CS16bit 0x3 +/* + * + * CSPARx Field |Chip Select Signal | Alternate Signal | Discrete Output + *-----------------+--------------------+--------------------+---------------*/ +#define CS_5 12 /* !CS5 | FC2 | PC2 */ +#define CS_4 10 /* !CS4 | FC1 | PC1 */ +#define CS_3 8 /* !CS3 | FC0 | PC0 */ +#define CS_2 6 /* !CS2 | !BGACK | */ +#define CS_1 4 /* !CS1 | !BG | */ +#define CS_0 2 /* !CS0 | !BR | */ +#define CSBOOT 0 /* !CSBOOT | | */ +/* | | | */ +#define CS_10 8 /* !CS10 | ADDR23 | ECLK */ +#define CS_9 6 /* !CS9 | ADDR22 | PC6 */ +#define CS_8 4 /* !CS8 | ADDR21 | PC5 */ +#define CS_7 2 /* !CS7 | ADDR20 | PC4 */ +#define CS_6 0 /* !CS6 | ADDR19 | PC3 */ + +#define BS_2K 0x0 +#define BS_8K 0x1 +#define BS_16K 0x2 +#define BS_64K 0x3 +#define BS_128K 0x4 +#define BS_256K 0x5 +#define BS_512K 0x6 +#define BS_1M 0x7 + +#define CSBARBT SIM_VOLATILE_USHORT_POINTER(0x48 + SIM_CRB) +#define CSBAR0 SIM_VOLATILE_USHORT_POINTER(0x4c + SIM_CRB) +#define CSBAR1 SIM_VOLATILE_USHORT_POINTER(0x50 + SIM_CRB) +#define CSBAR2 SIM_VOLATILE_USHORT_POINTER(0x54 + SIM_CRB) +#define CSBAR3 SIM_VOLATILE_USHORT_POINTER(0x58 + SIM_CRB) +#define CSBAR4 SIM_VOLATILE_USHORT_POINTER(0x5c + SIM_CRB) +#define CSBAR5 SIM_VOLATILE_USHORT_POINTER(0x60 + SIM_CRB) +#define CSBAR6 SIM_VOLATILE_USHORT_POINTER(0x64 + SIM_CRB) +#define CSBAR7 SIM_VOLATILE_USHORT_POINTER(0x68 + SIM_CRB) +#define CSBAR8 SIM_VOLATILE_USHORT_POINTER(0x6c + SIM_CRB) +#define CSBAR9 SIM_VOLATILE_USHORT_POINTER(0x70 + SIM_CRB) +#define CSBAR10 SIM_VOLATILE_USHORT_POINTER(0x74 + SIM_CRB) + +#define MODE 0x8000 +#define Disable 0 +#define LowerByte 0x2000 +#define UpperByte 0x4000 +#define BothBytes 0x6000 +#define ReadOnly 0x0800 +#define WriteOnly 0x1000 +#define ReadWrite 0x1800 +#define SyncAS 0x0 +#define SyncDS 0x0400 + +#define WaitStates_0 (0x0 << 6) +#define WaitStates_1 (0x1 << 6) +#define WaitStates_2 (0x2 << 6) +#define WaitStates_3 (0x3 << 6) +#define WaitStates_4 (0x4 << 6) +#define WaitStates_5 (0x5 << 6) +#define WaitStates_6 (0x6 << 6) +#define WaitStates_7 (0x7 << 6) +#define WaitStates_8 (0x8 << 6) +#define WaitStates_9 (0x9 << 6) +#define WaitStates_10 (0xa << 6) +#define WaitStates_11 (0xb << 6) +#define WaitStates_12 (0xc << 6) +#define WaitStates_13 (0xd << 6) +#define FastTerm (0xe << 6) +#define External (0xf << 6) + +#define CPUSpace (0x0 << 4) +#define UserSpace (0x1 << 4) +#define SupSpace (0x2 << 4) +#define UserSupSpace (0x3 << 4) + +#define IPLevel_any 0x0 +#define IPLevel_1 0x2 +#define IPLevel_2 0x4 +#define IPLevel_3 0x6 +#define IPLevel_4 0x8 +#define IPLevel_5 0xa +#define IPLevel_6 0xc +#define IPLevel_7 0xe + +#define AVEC 1 + +#define CSORBT SIM_VOLATILE_USHORT_POINTER(0x4a + SIM_CRB) +#define CSOR0 SIM_VOLATILE_USHORT_POINTER(0x4e + SIM_CRB) +#define CSOR1 SIM_VOLATILE_USHORT_POINTER(0x52 + SIM_CRB) +#define CSOR2 SIM_VOLATILE_USHORT_POINTER(0x56 + SIM_CRB) +#define CSOR3 SIM_VOLATILE_USHORT_POINTER(0x5a + SIM_CRB) +#define CSOR4 SIM_VOLATILE_USHORT_POINTER(0x5e + SIM_CRB) +#define CSOR5 SIM_VOLATILE_USHORT_POINTER(0x62 + SIM_CRB) +#define CSOR6 SIM_VOLATILE_USHORT_POINTER(0x66 + SIM_CRB) +#define CSOR7 SIM_VOLATILE_USHORT_POINTER(0x6a + SIM_CRB) +#define CSOR8 SIM_VOLATILE_USHORT_POINTER(0x6e + SIM_CRB) +#define CSOR9 SIM_VOLATILE_USHORT_POINTER(0x72 + SIM_CRB) +#define CSOR10 SIM_VOLATILE_USHORT_POINTER(0x76 + SIM_CRB) + +#endif /* _RTEMS_M68K_SIM_H */ diff --git a/cpukit/score/cpu/m68k/include/rtems/score/cpu.h b/cpukit/score/cpu/m68k/include/rtems/score/cpu.h new file mode 100644 index 0000000000..2be10c9638 --- /dev/null +++ b/cpukit/score/cpu/m68k/include/rtems/score/cpu.h @@ -0,0 +1,735 @@ +/** + * @file + * + * @brief Motorola M68K CPU Dependent Source + * + * This include file contains information pertaining to the Motorola + * m68xxx processor family. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPU_H +#define _RTEMS_SCORE_CPU_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* conditional compilation parameters */ + +/* + * Does the CPU follow the simple vectored interrupt model? + * + * If TRUE, then RTEMS allocates the vector table it internally manages. + * If FALSE, then the BSP is assumed to allocate and manage the vector + * table + * + * M68K Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_SIMPLE_VECTORED_INTERRUPTS TRUE + +/* + * Use the m68k's hardware interrupt stack support and have the + * interrupt manager allocate the memory for it. + */ + +#if ( M68K_HAS_SEPARATE_STACKS == 1) +#define CPU_HAS_SOFTWARE_INTERRUPT_STACK 0 +#define CPU_HAS_HARDWARE_INTERRUPT_STACK 1 +#else +#define CPU_HAS_SOFTWARE_INTERRUPT_STACK 1 +#define CPU_HAS_HARDWARE_INTERRUPT_STACK 0 +#endif +#define CPU_ALLOCATE_INTERRUPT_STACK 1 + +/* + * Does the RTEMS invoke the user's ISR with the vector number and + * a pointer to the saved interrupt frame (1) or just the vector + * number (0)? + */ + +#define CPU_ISR_PASSES_FRAME_POINTER FALSE + +/* + * Some family members have no FP, some have an FPU such as the + * MC68881/MC68882 for the MC68020, others have it built in (MC68030, 040). + * + * NOTE: If on a CPU without hardware FP, then one can use software + * emulation. The gcc software FP emulation code has data which + * must be contexted switched on a per task basis. + */ + +#if ( M68K_HAS_FPU == 1 ) || ( M68K_HAS_EMAC == 1 ) + #define CPU_HARDWARE_FP TRUE + #define CPU_SOFTWARE_FP FALSE +#else + #define CPU_HARDWARE_FP FALSE + #if defined( __GNUC__ ) + #define CPU_SOFTWARE_FP TRUE + #else + #define CPU_SOFTWARE_FP FALSE + #endif +#endif + +/* + * All tasks are not by default floating point tasks on this CPU. + * The IDLE task does not have a floating point context on this CPU. + * It is safe to use the deferred floating point context switch + * algorithm on this CPU. + */ + +#define CPU_ALL_TASKS_ARE_FP FALSE +#define CPU_IDLE_TASK_IS_FP FALSE +#define CPU_USE_DEFERRED_FP_SWITCH TRUE +#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE + +#define CPU_PROVIDES_IDLE_THREAD_BODY TRUE +#define CPU_STACK_GROWS_UP FALSE + +/* FIXME: Is this the right value? */ +#define CPU_CACHE_LINE_BYTES 16 + +#define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES ) + +#define CPU_MAXIMUM_PROCESSORS 32 + +#if ( CPU_HARDWARE_FP == TRUE ) && !defined( __mcoldfire__ ) + #if defined( __mc68060__ ) + #define M68K_FP_STATE_SIZE 16 + #else + #define M68K_FP_STATE_SIZE 216 + #endif +#endif + +#ifndef ASM + +/* structures */ + +/* + * Basic integer context for the m68k family. + */ + +typedef struct { + uint32_t sr; /* (sr) status register */ + uint32_t d2; /* (d2) data register 2 */ + uint32_t d3; /* (d3) data register 3 */ + uint32_t d4; /* (d4) data register 4 */ + uint32_t d5; /* (d5) data register 5 */ + uint32_t d6; /* (d6) data register 6 */ + uint32_t d7; /* (d7) data register 7 */ + void *a2; /* (a2) address register 2 */ + void *a3; /* (a3) address register 3 */ + void *a4; /* (a4) address register 4 */ + void *a5; /* (a5) address register 5 */ + void *a6; /* (a6) address register 6 */ + void *a7_msp; /* (a7) master stack pointer */ + #if defined( __mcoldfire__ ) && ( M68K_HAS_FPU == 1 ) + uint8_t fpu_dis; + #endif +} Context_Control; + +#define _CPU_Context_Get_SP( _context ) \ + (_context)->a7_msp + +/* + * Floating point context areas and support routines + */ + +#if ( CPU_SOFTWARE_FP == TRUE ) + /* + * This is the same as gcc's view of the software FP condition code + * register _fpCCR. The implementation of the emulation code is + * in the gcc-VERSION/config/m68k directory. This structure is + * correct as of gcc 2.7.2.2. + */ + typedef struct { + uint16_t _exception_bits; + uint16_t _trap_enable_bits; + uint16_t _sticky_bits; + uint16_t _rounding_mode; + uint16_t _format; + uint16_t _last_operation; + union { + float sf; + double df; + } _operand1; + union { + float sf; + double df; + } _operand2; + } Context_Control_fp; + + #define _CPU_Context_Initialize_fp( _fp_area ) \ + { \ + Context_Control_fp *_fp; \ + _fp = *(Context_Control_fp **)_fp_area; \ + _fp->_exception_bits = 0; \ + _fp->_trap_enable_bits = 0; \ + _fp->_sticky_bits = 0; \ + _fp->_rounding_mode = 0; /* ROUND_TO_NEAREST */ \ + _fp->_format = 0; /* NIL */ \ + _fp->_last_operation = 0; /* NOOP */ \ + _fp->_operand1.df = 0; \ + _fp->_operand2.df = 0; \ + } +#endif + +#if ( CPU_HARDWARE_FP == TRUE ) + #if defined( __mcoldfire__ ) + /* We need memset() to initialize the FP context */ + #include + + #if ( M68K_HAS_FPU == 1 ) + /* + * The Cache Control Register (CACR) has write-only access. It is also + * used to enable and disable the FPU. We need to maintain a copy of + * this register to allow per thread values. + */ + extern uint32_t _CPU_cacr_shadow; + #endif + + /* We assume that each ColdFire core with a FPU has also an EMAC unit */ + typedef struct { + uint32_t emac_macsr; + uint32_t emac_acc0; + uint32_t emac_acc1; + uint32_t emac_acc2; + uint32_t emac_acc3; + uint32_t emac_accext01; + uint32_t emac_accext23; + uint32_t emac_mask; + #if ( M68K_HAS_FPU == 1 ) + uint16_t fp_state_format; + uint16_t fp_state_fpcr; + double fp_state_op; + uint32_t fp_state_fpsr; + + /* + * We need to save the FP Instruction Address Register (FPIAR), because + * a context switch can occur within a FP exception before the handler + * was able to save this register. + */ + uint32_t fp_fpiar; + + double fp_data [8]; + #endif + } Context_Control_fp; + + /* + * The reset value for all context relevant registers except the FP data + * registers is zero. The reset value of the FP data register is NAN. The + * restore of the reset FP state will reset the FP data registers, so the + * initial value of them can be arbitrary here. + */ + #define _CPU_Context_Initialize_fp( _fp_area ) \ + memset( *(_fp_area), 0, sizeof( Context_Control_fp ) ) + #else + /* + * FP context save area for the M68881/M68882 and 68060 numeric + * coprocessors. + */ + typedef struct { + /* + * M68K_FP_STATE_SIZE bytes for FSAVE/FRESTORE + * 96 bytes for FMOVEM FP0-7 + * 12 bytes for FMOVEM CREGS + * 4 bytes for non-null flag + */ + uint8_t fp_save_area [M68K_FP_STATE_SIZE + 112]; + } Context_Control_fp; + + /* + * The floating-point context is saved/restored via FSAVE/FRESTORE which + * use a growing down stack. Initialize the stack and adjust the FP area + * pointer accordingly. + */ + #define _CPU_Context_Initialize_fp( _fp_area ) \ + { \ + uint32_t *_fp_context = _Addresses_Add_offset( \ + *(_fp_area), CPU_CONTEXT_FP_SIZE - 4); \ + *(--(_fp_context)) = 0; \ + *(_fp_area) = (void *)(_fp_context); \ + } + #endif +#endif + +/* + * The following structures define the set of information saved + * on the current stack by RTEMS upon receipt of each exc/interrupt. + * These are not used by m68k handlers. + * The exception frame is for rdbg. + */ + +typedef struct { + uint32_t vecnum; /* vector number */ +} CPU_Interrupt_frame; + +typedef struct { + uint32_t vecnum; /* vector number */ + uint32_t sr; /* status register */ + uint32_t pc; /* program counter */ + uint32_t d0, d1, d2, d3, d4, d5, d6, d7; + uint32_t a0, a1, a2, a3, a4, a5, a6, a7; +} CPU_Exception_frame; + +/* variables */ + +extern void* _VBR; + +#endif /* ASM */ + +/* constants */ + +/* + * This defines the number of levels and the mask used to pick those + * bits out of a thread mode. + */ + +#define CPU_MODES_INTERRUPT_LEVEL 0x00000007 /* interrupt level in mode */ +#define CPU_MODES_INTERRUPT_MASK 0x00000007 /* interrupt level in mode */ + +/* + * context size area for floating point + */ + +#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp ) + +/* + * extra stack required by the MPCI receive server thread + */ + +#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 1024 + +/* + * m68k family supports 256 distinct vectors. + */ + +#define CPU_INTERRUPT_NUMBER_OF_VECTORS 256 +#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER (CPU_INTERRUPT_NUMBER_OF_VECTORS - 1) + +/* + * This is defined if the port has a special way to report the ISR nesting + * level. Most ports maintain the variable _ISR_Nest_level. + */ + +#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE + +/* + * Minimum size of a thread's stack. + */ + +#define CPU_STACK_MINIMUM_SIZE M68K_CPU_STACK_MINIMUM_SIZE + +/* + * Maximum priority of a thread. Note based from 0 which is the idle task. + */ +#define CPU_PRIORITY_MAXIMUM M68K_CPU_PRIORITY_MAXIMUM + +#define CPU_SIZEOF_POINTER 4 + +/* + * m68k is pretty tolerant of alignment. Just put things on 4 byte boundaries. + */ + +#define CPU_ALIGNMENT 4 +#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT +#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT + +/* + * On m68k thread stacks require no further alignment after allocation + * from the Workspace. + */ + +#define CPU_STACK_ALIGNMENT 0 + +#ifndef ASM + +/* macros */ + +/* + * ISR handler macros + * + * These macros perform the following functions: + * + initialize the RTEMS vector table + * + disable all maskable CPU interrupts + * + restore previous interrupt level (enable) + * + temporarily restore interrupts (flash) + * + set a particular level + */ + +#define _CPU_Initialize_vectors() + +#define _CPU_ISR_Disable( _level ) \ + m68k_disable_interrupts( _level ) + +#define _CPU_ISR_Enable( _level ) \ + m68k_enable_interrupts( _level ) + +#define _CPU_ISR_Flash( _level ) \ + m68k_flash_interrupts( _level ) + +RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) +{ + return ( level & 0x0700 ) == 0; +} + +#define _CPU_ISR_Set_level( _newlevel ) \ + m68k_set_interrupt_level( _newlevel ) + +uint32_t _CPU_ISR_Get_level( void ); + +/* end of ISR handler macros */ + +/* + * Context handler macros + * + * These macros perform the following functions: + * + initialize a context area + * + restart the current thread + * + calculate the initial pointer into a FP context area + * + initialize an FP context area + */ + +void _CPU_Context_Initialize( + Context_Control *the_context, + void *stack_area_begin, + size_t stack_area_size, + uint32_t new_level, + void (*entry_point)( void ), + bool is_fp, + void *tls_area +); + +/* end of Context handler macros */ + +/* + * _CPU_Thread_Idle_body + * + * This routine is the CPU dependent IDLE thread body. + * + * NOTE: It need only be provided if CPU_PROVIDES_IDLE_THREAD_BODY + * is TRUE. + */ + +void *_CPU_Thread_Idle_body( uintptr_t ignored ); + +/* + * Fatal Error manager macros + * + * These macros perform the following functions: + * + disable interrupts and halt the CPU + */ + +#if ( defined(__mcoldfire__) ) +#define _CPU_Fatal_halt( _source, _error ) \ + { __asm__ volatile( "move.w %%sr,%%d0\n\t" \ + "or.l %2,%%d0\n\t" \ + "move.w %%d0,%%sr\n\t" \ + "move.l %1,%%d0\n\t" \ + "move.l #0xDEADBEEF,%%d1\n\t" \ + "halt" \ + : "=g" (_error) \ + : "0" (_error), "d"(0x0700) \ + : "d0", "d1" ); \ + } +#else +#define _CPU_Fatal_halt( _source, _error ) \ + { __asm__ volatile( "movl %0,%%d0; " \ + "orw #0x0700,%%sr; " \ + "stop #0x2700" : "=d" ((_error)) : "0" ((_error)) ); \ + } +#endif + +/* end of Fatal Error manager macros */ + +/* + * Bitfield handler macros + * + * These macros perform the following functions: + * + scan for the highest numbered (MSB) set in a 16 bit bitfield + * + * NOTE: + * + * It appears that on the M68020 bitfield are always 32 bits wide + * when in a register. This code forces the bitfield to be in + * memory (it really always is anyway). This allows us to + * have a real 16 bit wide bitfield which operates "correctly." + */ + +#define CPU_USE_GENERIC_BITFIELD_CODE FALSE + +#if ( M68K_HAS_BFFFO != 1 ) +/* + * Lookup table for BFFFO simulation + */ +extern const unsigned char _CPU_m68k_BFFFO_table[256]; +#endif + +#if ( M68K_HAS_BFFFO == 1 ) + +#define _CPU_Bitfield_Find_first_bit( _value, _output ) \ + __asm__ volatile( "bfffo (%1),#0,#16,%0" : "=d" (_output) : "a" (&_value)); + +#elif ( __mcfisaaplus__ ) + /* This is simplified by the fact that RTEMS never calls it with _value=0 */ +#define _CPU_Bitfield_Find_first_bit( _value, _output ) \ + __asm__ volatile ( \ + " swap %0\n" \ + " ff1.l %0\n" \ + : "=d" ((_output)) \ + : "0" ((_value)) \ + : "cc" ) ; + +#else +/* duplicates BFFFO results for 16 bits (i.e., 15-(_priority) in + _CPU_Priority_bits_index is not needed), handles the 0 case, and + does not molest _value -- jsg */ +#if ( defined(__mcoldfire__) ) + +#define _CPU_Bitfield_Find_first_bit( _value, _output ) \ + { \ + register int dumby; \ + \ + __asm__ volatile ( \ + " clr.l %1\n" \ + " move.w %2,%1\n" \ + " lsr.l #8,%1\n" \ + " beq.s 1f\n" \ + " move.b (%3,%1),%0\n" \ + " bra.s 0f\n" \ + "1: move.w %2,%1\n" \ + " move.b (%3,%1),%0\n" \ + " addq.l #8,%0\n" \ + "0: and.l #0xff,%0\n" \ + : "=&d" ((_output)), "=&d" ((dumby)) \ + : "d" ((_value)), "ao" ((_CPU_m68k_BFFFO_table)) \ + : "cc" ) ; \ + } +#elif ( M68K_HAS_EXTB_L == 1 ) +#define _CPU_Bitfield_Find_first_bit( _value, _output ) \ + { \ + register int dumby; \ + \ + __asm__ volatile ( " move.w %2,%1\n" \ + " lsr.w #8,%1\n" \ + " beq.s 1f\n" \ + " move.b (%3,%1.w),%0\n" \ + " extb.l %0\n" \ + " bra.s 0f\n" \ + "1: moveq.l #8,%0\n" \ + " add.b (%3,%2.w),%0\n" \ + "0:\n" \ + : "=&d" ((_output)), "=&d" ((dumby)) \ + : "d" ((_value)), "ao" ((_CPU_m68k_BFFFO_table)) \ + : "cc" ) ; \ + } +#else +#define _CPU_Bitfield_Find_first_bit( _value, _output ) \ + { \ + register int dumby; \ + \ + __asm__ volatile ( " move.w %2,%1\n" \ + " lsr.w #8,%1\n" \ + " beq.s 1f\n" \ + " move.b (%3,%1.w),%0\n" \ + " and.l #0x000000ff,%0\n"\ + " bra.s 0f\n" \ + "1: moveq.l #8,%0\n" \ + " add.b (%3,%2.w),%0\n" \ + "0:\n" \ + : "=&d" ((_output)), "=&d" ((dumby)) \ + : "d" ((_value)), "ao" ((_CPU_m68k_BFFFO_table)) \ + : "cc" ) ; \ + } +#endif + +#endif + +/* end of Bitfield handler macros */ + +/* + * Priority handler macros + * + * These macros perform the following functions: + * + return a mask with the bit for this major/minor portion of + * of thread priority set. + * + translate the bit number returned by "Bitfield_find_first_bit" + * into an index into the thread ready chain bit maps + */ + +#define _CPU_Priority_Mask( _bit_number ) \ + ( 0x8000 >> (_bit_number) ) + +#define _CPU_Priority_bits_index( _priority ) \ + (_priority) + +/* end of Priority handler macros */ + +/* functions */ + +/* + * _CPU_Initialize + * + * This routine performs CPU dependent initialization. + */ + +void _CPU_Initialize(void); + +/* + * _CPU_ISR_install_raw_handler + * + * This routine installs a "raw" interrupt handler directly into the + * processor's vector table. + */ + +void _CPU_ISR_install_raw_handler( + uint32_t vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +/* + * _CPU_ISR_install_vector + * + * This routine installs an interrupt vector. + */ + +void _CPU_ISR_install_vector( + uint32_t vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +/* + * _CPU_Install_interrupt_stack + * + * This routine installs the hardware interrupt stack pointer. + */ + +void _CPU_Install_interrupt_stack( void ); + +/* + * _CPU_Context_switch + * + * This routine switches from the run context to the heir context. + */ + +void _CPU_Context_switch( + Context_Control *run, + Context_Control *heir +); + +void _CPU_Context_Restart_self( + Context_Control *the_context +) RTEMS_NO_RETURN; + +/* + * _CPU_Context_save_fp + * + * This routine saves the floating point context passed to it. + */ + +void _CPU_Context_save_fp( + Context_Control_fp **fp_context_ptr +); + +/* + * _CPU_Context_restore_fp + * + * This routine restores the floating point context passed to it. + */ + +void _CPU_Context_restore_fp( + Context_Control_fp **fp_context_ptr +); + +static inline void _CPU_Context_volatile_clobber( uintptr_t pattern ) +{ + /* TODO */ +} + +static inline void _CPU_Context_validate( uintptr_t pattern ) +{ + while (1) { + /* TODO */ + } +} + +/** + * This method prints the CPU exception frame. + * + * @param[in] frame points to the frame to be printed + */ +void _CPU_Exception_frame_print( + const CPU_Exception_frame *frame +); + +typedef uint32_t CPU_Counter_ticks; + +CPU_Counter_ticks _CPU_Counter_read( void ); + +static inline CPU_Counter_ticks _CPU_Counter_difference( + CPU_Counter_ticks second, + CPU_Counter_ticks first +) +{ + return second - first; +} + +#if (M68K_HAS_FPSP_PACKAGE == 1) +/* + * Hooks for the Floating Point Support Package (FPSP) provided by Motorola + * + * NOTES: + * + * Motorola 68k family CPU's before the 68040 used a coprocessor + * (68881 or 68882) to handle floating point. The 68040 has internal + * floating point support -- but *not* the complete support provided by + * the 68881 or 68882. The leftover functions are taken care of by the + * M68040 Floating Point Support Package. Quoting from the MC68040 + * Microprocessors User's Manual, Section 9, Floating-Point Unit (MC68040): + * + * "When used with the M68040FPSP, the MC68040 FPU is fully + * compliant with IEEE floating-point standards." + * + * M68KFPSPInstallExceptionHandlers is in libcpu/m68k/MODEL/fpsp and + * is invoked early in the application code to ensure that proper FP + * behavior is installed. This is not left to the BSP to call, since + * this would force all applications using that BSP to use FPSP which + * is not necessarily desirable. + * + * There is a similar package for the 68060 but RTEMS does not yet + * support the 68060. + */ + +void M68KFPSPInstallExceptionHandlers (void); + +extern int (*_FPSP_install_raw_handler)( + uint32_t vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +#endif + + +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/score/cpu/m68k/include/rtems/score/cpuatomic.h b/cpukit/score/cpu/m68k/include/rtems/score/cpuatomic.h new file mode 100644 index 0000000000..598ee76b20 --- /dev/null +++ b/cpukit/score/cpu/m68k/include/rtems/score/cpuatomic.h @@ -0,0 +1,14 @@ +/* + * COPYRIGHT (c) 2012-2013 Deng Hengyi. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_ATOMIC_CPU_H +#define _RTEMS_SCORE_ATOMIC_CPU_H + +#include + +#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/m68k/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/m68k/include/rtems/score/cpuimpl.h new file mode 100644 index 0000000000..789f2badd9 --- /dev/null +++ b/cpukit/score/cpu/m68k/include/rtems/score/cpuimpl.h @@ -0,0 +1,34 @@ +/** + * @file + * + * @brief CPU Port Implementation API + */ + +/* + * Copyright (c) 2013 embedded brains GmbH + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPUIMPL_H +#define _RTEMS_SCORE_CPUIMPL_H + +#include + +#define CPU_PER_CPU_CONTROL_SIZE 0 + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ASM */ + +#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/m68k/include/rtems/score/m68k.h b/cpukit/score/cpu/m68k/include/rtems/score/m68k.h new file mode 100644 index 0000000000..818578c078 --- /dev/null +++ b/cpukit/score/cpu/m68k/include/rtems/score/m68k.h @@ -0,0 +1,502 @@ +/** + * @file + * + * @brief Motorola M68K CPU Dependent Source + * + * This include file contains information pertaining to the Motorola + * m68xxx processor family. + */ + +/* + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_M68K_H +#define _RTEMS_SCORE_M68K_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This section contains the information required to build + * RTEMS for a particular member of the Motorola MC68xxx + * family. It does this by setting variables to indicate + * which implementation dependent features are present in + * a particular member of the family. + * + * Currently recognized: + * -m68000 + * -m68000 -msoft-float + * -m68020 + * -m68020 -msoft-float + * -m68030 + * -m68040 -msoft-float + * -m68040 + * -m68040 -msoft-float + * -m68060 + * -m68060 -msoft-float + * -m68302 (no FP) (deprecated, use -m68000) + * -m68332 (no FP) (deprecated, use -mcpu32) + * -mcpu32 (no FP) + * -m5200 (no FP) + * -m528x (no FP, ISA A+) + * + * As of gcc 2.8.1 and egcs 1.1, there is no distinction made between + * the CPU32 and CPU32+. The option -mcpu32 generates code which can + * be run on either core. RTEMS distinguishes between these two cores + * because they have different alignment rules which impact performance. + * If you are using a CPU32+, then the symbol RTEMS__mcpu32p__ should + * be defined in your custom file (see make/custom/gen68360.cfg for an + * example of how to do this. If gcc ever distinguishes between these + * two cores, then RTEMS__mcpu32p__ usage will be replaced with the + * appropriate compiler defined predefine. + * + * Here is some information on the 040 variants (courtesy of Doug McBride, + * mcbride@rodin.colorado.edu): + * + * "The 68040 is a superset of the 68EC040 and the 68LC040. The + * 68EC040 and 68LC040 do not have FPU's. The 68LC040 and the + * 68EC040 have renamed the DLE pin as JS0 which must be tied to + * Gnd or Vcc. The 68EC040 has renamed the MDIS pin as JS1. The + * 68EC040 has access control units instead of memory management units. + * The 68EC040 should not have the PFLUSH or PTEST instructions executed + * (cause an indeterminate result). The 68EC040 and 68LC040 do not + * implement the DLE or multiplexed bus modes. The 68EC040 does not + * implement the output buffer impedance selection mode of operation." + * + * M68K_HAS_EXTB_L is used to enable/disable usage of the extb.l instruction + * which is not available for 68000 or 68ec000 cores (68000, 68001, 68008, + * 68010, 68302, 68306, 68307). This instruction is available on the 68020 + * up and the cpu32 based models. + * + * M68K_HAS_MISALIGNED is non-zero if the CPU allows byte-misaligned + * data access (68020, 68030, 68040, 68060, CPU32+). + * + * NOTE: + * Eventually it would be nice to evaluate doing a lot of this section + * by having each model specify which core it uses and then go from there. + */ + +/* + * Handle the Coldfire family based on the instruction set. + */ +#if defined(__mcoldfire__) + +# define CPU_NAME "Motorola ColdFire" + +# if defined(__mcfisaa__) +/* Motorola ColdFire ISA A */ +# define CPU_MODEL_NAME "mcfisaa" +# define M68K_HAS_VBR 1 +# define M68K_HAS_BFFFO 0 +# define M68K_HAS_SEPARATE_STACKS 0 +# define M68K_HAS_PREINDEXING 0 +# define M68K_HAS_EXTB_L 1 +# define M68K_HAS_MISALIGNED 1 + +# elif defined(__mcfisaaplus__) +/* Motorola ColdFire ISA A+ */ +# define CPU_MODEL_NAME "mcfisaaplus" +# define M68K_HAS_VBR 1 +# define M68K_HAS_BFFFO 0 +# define M68K_HAS_SEPARATE_STACKS 0 +# define M68K_HAS_PREINDEXING 0 +# define M68K_HAS_EXTB_L 1 +# define M68K_HAS_MISALIGNED 1 + +# elif defined(__mcfisab__) +/* Motorola ColdFire ISA B */ +# define CPU_MODEL_NAME "mcfisab" +# define M68K_HAS_VBR 1 +# define M68K_HAS_BFFFO 0 +# define M68K_HAS_SEPARATE_STACKS 0 +# define M68K_HAS_PREINDEXING 0 +# define M68K_HAS_EXTB_L 1 +# define M68K_HAS_MISALIGNED 1 + +# else +# error "Unsupported Coldfire ISA -- Please notify RTEMS" +# endif + +/* + * Assume the FPU support is independent. I think it is just the ISA B + * instruction set. + */ +# if defined (__mcffpu__) +# define M68K_HAS_FPU 1 + /* + * td: can we be sure that all CFs with FPU also have an EMAC? + */ +# define M68K_HAS_EMAC 1 +# define M68K_HAS_FPSP_PACKAGE 0 +# else +# define M68K_HAS_FPU 0 +# define M68K_HAS_FPSP_PACKAGE 0 +# endif + +/* + * Tiny RTEMS support. Small stack and limited priorities. + * + * These CPUs have very limited on-CPU memory which cannot + * be expanded. We have to be gentle with them or nothing + * will every run. + */ +# if (defined(__mcf_cpu_52221) || \ + defined(__mcf_cpu_52223) || \ + defined(__mcf_cpu_52230) || \ + defined(__mcf_cpu_52231) || \ + defined(__mcf_cpu_52232) || \ + defined(__mcf_cpu_52233) || \ + defined(__mcf_cpu_52234) || \ + defined(__mcf_cpu_52235) || \ + defined(__mcf_cpu_52225) || \ + defined(__mcf_cpu_52235)) + #define M68K_CPU_STACK_MINIMUM_SIZE 1024 + /* Define the lowest priority. Based from 0 to this is 16 levels. */ + #define M68K_CPU_PRIORITY_MAXIMUM 15 +# else + #define M68K_CPU_STACK_MINIMUM_SIZE 4096 + /* Use the default number of priorities */ + #define M68K_CPU_PRIORITY_MAXIMUM 255 +# endif + +#else + +/* + * Figure out all CPU Model Feature Flags based upon compiler + * predefines. Notice the only exception to this is that + * gcc does not distinguish between CPU32 and CPU32+. This + * feature selection logic is setup such that if RTEMS__mcpu32p__ + * is defined, then CPU32+ rules are used. Otherwise, the safe + * but less efficient CPU32 rules are used for the CPU32+. + */ + +# define CPU_NAME "Motorola MC68xxx" + +/* + * One stack size fits all 68000 processors. + */ +# define M68K_CPU_STACK_MINIMUM_SIZE 4096 + +# if (defined(__mc68020__) && !defined(__mcpu32__)) + +# define CPU_MODEL_NAME "m68020" +# define M68K_HAS_VBR 1 +# define M68K_HAS_SEPARATE_STACKS 1 +# define M68K_HAS_BFFFO 1 +# define M68K_HAS_PREINDEXING 1 +# define M68K_HAS_EXTB_L 1 +# define M68K_HAS_MISALIGNED 1 +# if defined (__HAVE_68881__) +# define M68K_HAS_FPU 1 +# define M68K_HAS_FPSP_PACKAGE 0 +# else +# define M68K_HAS_FPU 0 +# define M68K_HAS_FPSP_PACKAGE 0 +# endif + +# elif defined(__mc68030__) + +# define CPU_MODEL_NAME "m68030" +# define M68K_HAS_VBR 1 +# define M68K_HAS_SEPARATE_STACKS 1 +# define M68K_HAS_BFFFO 1 +# define M68K_HAS_PREINDEXING 1 +# define M68K_HAS_EXTB_L 1 +# define M68K_HAS_MISALIGNED 1 +# if defined (__HAVE_68881__) +# define M68K_HAS_FPU 1 +# define M68K_HAS_FPSP_PACKAGE 0 +# else +# define M68K_HAS_FPU 0 +# define M68K_HAS_FPSP_PACKAGE 0 +# endif + +# elif defined(__mc68040__) + +# define CPU_MODEL_NAME "m68040" +# define M68K_HAS_VBR 1 +# define M68K_HAS_SEPARATE_STACKS 1 +# define M68K_HAS_BFFFO 1 +# define M68K_HAS_PREINDEXING 1 +# define M68K_HAS_EXTB_L 1 +# define M68K_HAS_MISALIGNED 1 +# if defined (__HAVE_68881__) +# define M68K_HAS_FPU 1 +# define M68K_HAS_FPSP_PACKAGE 1 +# else +# define M68K_HAS_FPU 0 +# define M68K_HAS_FPSP_PACKAGE 0 +# endif + +# elif defined(__mc68060__) + +# define CPU_MODEL_NAME "m68060" +# define M68K_HAS_VBR 1 +# define M68K_HAS_SEPARATE_STACKS 0 +# define M68K_HAS_BFFFO 1 +# define M68K_HAS_PREINDEXING 1 +# define M68K_HAS_EXTB_L 1 +# define M68K_HAS_MISALIGNED 1 +# if defined (__HAVE_68881__) +# define M68K_HAS_FPU 1 +# define M68K_HAS_FPSP_PACKAGE 0 +# else +# define M68K_HAS_FPU 0 +# define M68K_HAS_FPSP_PACKAGE 0 +# endif + +# elif defined(__mc68302__) + +# define CPU_MODEL_NAME "m68302" +# define M68K_HAS_VBR 0 +# define M68K_HAS_SEPARATE_STACKS 0 +# define M68K_HAS_BFFFO 0 +# define M68K_HAS_PREINDEXING 0 +# define M68K_HAS_EXTB_L 0 +# define M68K_HAS_MISALIGNED 0 +# define M68K_HAS_FPU 0 +# define M68K_HAS_FPSP_PACKAGE 0 + + /* gcc and egcs do not distinguish between CPU32 and CPU32+ */ +# elif defined(RTEMS__mcpu32p__) + +# define CPU_MODEL_NAME "mcpu32+" +# define M68K_HAS_VBR 1 +# define M68K_HAS_SEPARATE_STACKS 0 +# define M68K_HAS_BFFFO 0 +# define M68K_HAS_PREINDEXING 1 +# define M68K_HAS_EXTB_L 1 +# define M68K_HAS_MISALIGNED 1 +# define M68K_HAS_FPU 0 +# define M68K_HAS_FPSP_PACKAGE 0 + +# elif defined(__mcpu32__) + +# define CPU_MODEL_NAME "mcpu32" +# define M68K_HAS_VBR 1 +# define M68K_HAS_SEPARATE_STACKS 0 +# define M68K_HAS_BFFFO 0 +# define M68K_HAS_PREINDEXING 1 +# define M68K_HAS_EXTB_L 1 +# define M68K_HAS_MISALIGNED 0 +# define M68K_HAS_FPU 0 +# define M68K_HAS_FPSP_PACKAGE 0 + +# elif defined(__mc68000__) + +# define CPU_MODEL_NAME "m68000" +# define M68K_HAS_VBR 0 +# define M68K_HAS_SEPARATE_STACKS 0 +# define M68K_HAS_BFFFO 0 +# define M68K_HAS_PREINDEXING 0 +# define M68K_HAS_EXTB_L 0 +# define M68K_HAS_MISALIGNED 0 +# if defined (__HAVE_68881__) +# define M68K_HAS_FPU 1 +# define M68K_HAS_FPSP_PACKAGE 0 +# else +# define M68K_HAS_FPU 0 +# define M68K_HAS_FPSP_PACKAGE 0 +# endif + +# else + +# error "Unsupported 68000 CPU model -- are you sure you're running a 68k compiler?" + +# endif + +/* + * No Tiny RTEMS support on the standard 68000 family. + */ +# define M68K_CPU_STACK_MINIMUM_SIZE 4096 +# define M68K_CPU_PRIORITY_MAXIMUM 255 + +#endif + +/* + * OBSOLETE: Backward compatibility only - Don't use. + * Use __mcoldfire__ instead. + */ +#if defined(__mcoldfire__) +#define M68K_COLDFIRE_ARCH 1 +#else +#define M68K_COLDFIRE_ARCH 0 +#endif + +#ifndef ASM + +#if ( defined(__mcoldfire__) ) +#define m68k_disable_interrupts( _level ) \ + do { register uint32_t _tmpsr = 0x0700; \ + __asm__ volatile ( "move.w %%sr,%0\n\t" \ + "or.l %0,%1\n\t" \ + "move.w %1,%%sr" \ + : "=d" (_level), "=d"(_tmpsr) : "1"(_tmpsr) \ + : "cc" ); \ + } while( 0 ) +#else +#define m68k_disable_interrupts( _level ) \ + __asm__ volatile ( "move.w %%sr,%0\n\t" \ + "or.w #0x0700,%%sr" \ + : "=d" (_level) \ + : : "cc" ) +#endif + +#define m68k_enable_interrupts( _level ) \ + __asm__ volatile ( "move.w %0,%%sr " : : "d" (_level) : "cc"); + +#if ( defined(__mcoldfire__) ) +#define m68k_flash_interrupts( _level ) \ + do { register uint32_t _tmpsr = 0x0700; \ + asm volatile ( "move.w %2,%%sr\n\t" \ + "or.l %2,%1\n\t" \ + "move.w %1,%%sr" \ + : "=d"(_tmpsr) : "0"(_tmpsr), "d"(_level) \ + : "cc"); \ + } while( 0 ) +#else +#define m68k_flash_interrupts( _level ) \ + __asm__ volatile ( "move.w %0,%%sr\n\t" \ + "or.w #0x0700,%%sr" \ + : : "d" (_level) \ + : "cc" ) +#endif + +#define m68k_get_interrupt_level( _level ) \ + do { \ + register uint32_t _tmpsr; \ + \ + __asm__ volatile( "move.w %%sr,%0" : "=d" (_tmpsr)); \ + _level = (_tmpsr & 0x0700) >> 8; \ + } while (0) + +#define m68k_set_interrupt_level( _newlevel ) \ + do { \ + register uint32_t _tmpsr; \ + \ + __asm__ volatile( "move.w %%sr,%0" : "=d" (_tmpsr)); \ + _tmpsr = (_tmpsr & 0xf8ff) | ((_newlevel) << 8); \ + __asm__ volatile( "move.w %0,%%sr" : : "d" (_tmpsr)); \ + } while (0) + +#if ( M68K_HAS_VBR == 1 && !defined(__mcoldfire__) ) +#define m68k_get_vbr( vbr ) \ + __asm__ volatile ( "movec %%vbr,%0 " : "=r" (vbr)) + +#define m68k_set_vbr( vbr ) \ + __asm__ volatile ( "movec %0,%%vbr " : : "r" (vbr)) + +#elif ( defined(__mcoldfire__) ) +extern void* _VBR; +#define m68k_get_vbr( _vbr ) _vbr = &_VBR + +#define m68k_set_vbr( _vbr ) \ + do { \ + __asm__ volatile ( "movec %0,%%vbr " : : "r" (_vbr)); \ + _VBR = (void *)_vbr; \ + } while(0) + +#else +#define m68k_get_vbr( _vbr ) _vbr = (void *)_VBR +#define m68k_set_vbr( _vbr ) +#endif + +/* + * Access Control Registers + */ +#define m68k_set_cacr(_cacr) __asm__ volatile ("movec %0,%%cacr" : : "d" (_cacr)) +#define m68k_set_acr0(_acr0) __asm__ volatile ("movec %0,%%acr0" : : "d" (_acr0)) +#define m68k_set_acr1(_acr1) __asm__ volatile ("movec %0,%%acr1" : : "d" (_acr1)) + +/* + * The following routine swaps the endian format of an unsigned int. + * It must be static because it is referenced indirectly. + */ +#if ( defined(__mcoldfire__) ) + +/* There are no rotate commands in Coldfire architecture. We will use + * generic implementation of endian swapping for Coldfire. + */ +static inline uint32_t m68k_swap_u32( + uint32_t value + ) +{ + uint32_t byte1, byte2, byte3, byte4, swapped; + + byte4 = (value >> 24) & 0xff; + byte3 = (value >> 16) & 0xff; + byte2 = (value >> 8) & 0xff; + byte1 = value & 0xff; + + swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4; + return( swapped ); +} + +static inline uint16_t m68k_swap_u16( + uint16_t value +) +{ + return (((value & 0xff) << 8) | ((value >> 8) & 0xff)); +} + +#else + +static inline uint32_t m68k_swap_u32( + uint32_t value +) +{ + uint32_t swapped = value; + + __asm__ volatile( "rorw #8,%0" : "=d" (swapped) : "0" (swapped) ); + __asm__ volatile( "swap %0" : "=d" (swapped) : "0" (swapped) ); + __asm__ volatile( "rorw #8,%0" : "=d" (swapped) : "0" (swapped) ); + + return( swapped ); +} + +static inline uint16_t m68k_swap_u16( + uint16_t value +) +{ + uint16_t swapped = value; + + __asm__ volatile( "rorw #8,%0" : "=d" (swapped) : "0" (swapped) ); + + return( swapped ); +} +#endif + +#define CPU_swap_u32( value ) m68k_swap_u32( value ) +#define CPU_swap_u16( value ) m68k_swap_u16( value ) + + +/* + * _CPU_virtual_to_physical + * + * This function is used to map virtual addresses to physical + * addresses. + * + * FIXME: ASSUMES THAT VIRTUAL ADDRESSES ARE THE SAME AS THE + * PHYSICAL ADDRESSES + */ +static inline void * _CPU_virtual_to_physical ( + const void * d_addr ) +{ + return (void *) d_addr; +} + + +#endif /* !ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_SCORE_M68K_H */ diff --git a/cpukit/score/cpu/m68k/include/rtems/score/types.h b/cpukit/score/cpu/m68k/include/rtems/score/types.h new file mode 100644 index 0000000000..947c6ace69 --- /dev/null +++ b/cpukit/score/cpu/m68k/include/rtems/score/types.h @@ -0,0 +1,43 @@ +/** + * @file + * + * @brief Motorola M68K CPU Type Definitions + * + * This include file contains type definitions pertaining to the Motorola + * m68xxx processor family. + */ + +/* + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_TYPES_H +#define _RTEMS_SCORE_TYPES_H + +#include + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This section defines the basic types for this processor. + */ + +/** Type that can store a 32-bit integer or a pointer. */ +typedef uintptr_t CPU_Uint32ptr; + +#ifdef __cplusplus +} +#endif + +#endif /* !ASM */ + +#endif diff --git a/cpukit/score/cpu/m68k/preinstall.am b/cpukit/score/cpu/m68k/preinstall.am deleted file mode 100644 index a580b7a4b5..0000000000 --- a/cpukit/score/cpu/m68k/preinstall.am +++ /dev/null @@ -1,70 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -$(PROJECT_INCLUDE)/rtems/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems - @: > $(PROJECT_INCLUDE)/rtems/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/asm.h: rtems/asm.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/asm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/asm.h - -$(PROJECT_INCLUDE)/rtems/m68k/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/m68k - @: > $(PROJECT_INCLUDE)/rtems/m68k/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/m68k/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/m68k/m68302.h: rtems/m68k/m68302.h $(PROJECT_INCLUDE)/rtems/m68k/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/m68k/m68302.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/m68k/m68302.h - -$(PROJECT_INCLUDE)/rtems/m68k/m68360.h: rtems/m68k/m68360.h $(PROJECT_INCLUDE)/rtems/m68k/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/m68k/m68360.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/m68k/m68360.h - -$(PROJECT_INCLUDE)/rtems/m68k/qsm.h: rtems/m68k/qsm.h $(PROJECT_INCLUDE)/rtems/m68k/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/m68k/qsm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/m68k/qsm.h - -$(PROJECT_INCLUDE)/rtems/m68k/sim.h: rtems/m68k/sim.h $(PROJECT_INCLUDE)/rtems/m68k/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/m68k/sim.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/m68k/sim.h - -$(PROJECT_INCLUDE)/rtems/score/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/score - @: > $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/score/cpu.h: rtems/score/cpu.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpu.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpu.h - -$(PROJECT_INCLUDE)/rtems/score/cpuimpl.h: rtems/score/cpuimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h - -$(PROJECT_INCLUDE)/rtems/score/m68k.h: rtems/score/m68k.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/m68k.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/m68k.h - -$(PROJECT_INCLUDE)/rtems/score/types.h: rtems/score/types.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/types.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/types.h - -$(PROJECT_INCLUDE)/rtems/score/cpuatomic.h: rtems/score/cpuatomic.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h - diff --git a/cpukit/score/cpu/m68k/rtems/asm.h b/cpukit/score/cpu/m68k/rtems/asm.h deleted file mode 100644 index cbd2a7f8b2..0000000000 --- a/cpukit/score/cpu/m68k/rtems/asm.h +++ /dev/null @@ -1,152 +0,0 @@ -/** - * @file - * - * @brief Address the Problems Caused by Incompatible Flavor of - * Assemblers and Toolsets - * - * This include file attempts to address the problems - * caused by incompatible flavors of assemblers and - * toolsets. It primarily addresses variations in the - * use of leading underscores on symbols and the requirement - * that register names be preceded by a %. - * - * NOTE: The spacing in the use of these macros - * is critical to them working as advertised. - */ - -/* - * COPYRIGHT: - * - * This file is based on similar code found in newlib available - * from ftp.cygnus.com. The file which was used had no copyright - * notice. This file is freely distributable as long as the source - * of the file is noted. This file is: - * - * COPYRIGHT (c) 1994-1997. - * On-Line Applications Research Corporation (OAR). - */ - -#ifndef _RTEMS_ASM_H -#define _RTEMS_ASM_H - -/* - * Indicate we are in an assembly file and get the basic CPU definitions. - */ - -#ifndef ASM -#define ASM -#endif -#include -#include - -/* - * Recent versions of GNU cpp define variables which indicate the - * need for underscores and percents. If not using GNU cpp or - * the version does not support this, then you will obviously - * have to define these as appropriate. - */ - -#ifndef __USER_LABEL_PREFIX__ -#define __USER_LABEL_PREFIX__ _ -#endif - -#ifndef __REGISTER_PREFIX__ -#define __REGISTER_PREFIX__ -#endif - -#include - -/* Use the right prefix for global labels. */ - -#define SYM(x) CONCAT0 (__USER_LABEL_PREFIX__, x) - -/* Use the right prefix for registers. */ - -#define REG(x) CONCAT0 (__REGISTER_PREFIX__, x) - -#define d0 REG (d0) -#define d1 REG (d1) -#define d2 REG (d2) -#define d3 REG (d3) -#define d4 REG (d4) -#define d5 REG (d5) -#define d6 REG (d6) -#define d7 REG (d7) -#define a0 REG (a0) -#define a1 REG (a1) -#define a2 REG (a2) -#define a3 REG (a3) -#define a4 REG (a4) -#define a5 REG (a5) -#define a6 REG (a6) -#define a7 REG (a7) -#define sp REG (sp) - -#define msp REG (msp) -#define usp REG (usp) -#define isp REG (isp) -#define sr REG (sr) -#define vbr REG (vbr) -#define dfc REG (dfc) -#define sfc REG (sfc) - -/* mcf52xx special regs */ -#define cacr REG (cacr) -#define acr0 REG (acr0) -#define acr1 REG (acr1) -#define rambar0 REG (rambar0) -#define mbar REG (mbar) - -/* additional v4e special regs */ -#define rambar1 REG (rambar1) -#define macsr REG (macsr) -#define acc0 REG (acc0) -#define acc1 REG (acc1) -#define acc2 REG (acc2) -#define acc3 REG (acc3) -#define accext01 REG (accext01) -#define accext23 REG (accext23) -#define mask REG (mask) - - -#define fp0 REG (fp0) -#define fp1 REG (fp1) -#define fp2 REG (fp2) -#define fp3 REG (fp3) -#define fp4 REG (fp4) -#define fp5 REG (fp5) -#define fp6 REG (fp6) -#define fp7 REG (fp7) - -#define fpc REG (fpc) -#define fpi REG (fpi) -#define fps REG (fps) -#define fpsr REG (fpsr) - - -/* - * Define macros to handle section beginning and ends. - */ - - -#define BEGIN_CODE_DCL .text -#define END_CODE_DCL -#define BEGIN_DATA_DCL .data -#define END_DATA_DCL -#define BEGIN_CODE .text -#define END_CODE -#define BEGIN_DATA .data -#define END_DATA -#define BEGIN_BSS .bss -#define END_BSS -#define END - -/* - * Following must be tailor for a particular flavor of the C compiler. - * They may need to put underscores in front of the symbols. - */ - -#define PUBLIC(sym) .globl SYM (sym) -#define EXTERN(sym) .globl SYM (sym) - -#endif diff --git a/cpukit/score/cpu/m68k/rtems/m68k/m68302.h b/cpukit/score/cpu/m68k/rtems/m68k/m68302.h deleted file mode 100644 index acf55f50c5..0000000000 --- a/cpukit/score/cpu/m68k/rtems/m68k/m68302.h +++ /dev/null @@ -1,659 +0,0 @@ -/** - * @file - * - * @brief Definitions for Motorola MC68302 Processor - * - * Section references in this file refer to revision 2 of Motorola's - * "MC68302 Integrated Multiprotocol Processor User's Manual". - * (Motorola document MC68302UM/AD REV 2.) - * - * Based on Don Meyer's cpu68302.h that was posted in comp.sys.m68k - * on 17 February, 1993. - */ - -/* - * COPYRIGHT 1995 David W. Glessner. - * - * Redistribution and use in source and binary forms are permitted - * provided that the following conditions are met: - * 1. Redistribution of source code and documentation must retain - * the above copyright notice, this list of conditions and the - * following disclaimer. - * 2. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * This software is provided "AS IS" without warranty of any kind, - * either expressed or implied, including, but not limited to, the - * implied warranties of merchantability, title and fitness for a - * particular purpose. - * - *------------------------------------------------------------------ - */ - -#ifndef _RTEMS_M68K_M68302_H -#define _RTEMS_M68K_M68302_H - -/* - * BAR - Base Address Register - * Section 2.7 - */ -#define M302_BAR (*((volatile uint16_t *) 0xf2)) - -/* - * SCR - System Control Register - * Section 3.8.1 - */ -#define M302_SCR (*((volatile uint32_t *) 0xf4)) -/* - * SCR bits - */ -#define RBIT_SCR_IPA 0x08000000 -#define RBIT_SCR_HWT 0x04000000 -#define RBIT_SCR_WPV 0x02000000 -#define RBIT_SCR_ADC 0x01000000 - -#define RBIT_SCR_ERRE 0x00400000 -#define RBIT_SCR_VGE 0x00200000 -#define RBIT_SCR_WPVE 0x00100000 -#define RBIT_SCR_RMCST 0x00080000 -#define RBIT_SCR_EMWS 0x00040000 -#define RBIT_SCR_ADCE 0x00020000 -#define RBIT_SCR_BCLM 0x00010000 - -#define RBIT_SCR_FRZW 0x00008000 -#define RBIT_SCR_FRZ2 0x00004000 -#define RBIT_SCR_FRZ1 0x00002000 -#define RBIT_SCR_SAM 0x00001000 -#define RBIT_SCR_HWDEN 0x00000800 -#define RBIT_SCR_HWDCN2 0x00000400 -#define RBIT_SCR_HWDCN1 0x00000200 /* 512 clocks */ -#define RBIT_SCR_HWDCN0 0x00000100 /* 128 clocks */ - -#define RBIT_SCR_LPREC 0x00000080 -#define RBIT_SCR_LPP16 0x00000040 -#define RBIT_SCR_LPEN 0x00000020 -#define RBIT_SCR_LPCLKDIV 0x0000001f - - -/* - * 68000 interrupt and trap vector numbers - */ -#define M68K_IVEC_BUS_ERROR 2 -#define M68K_IVEC_ADDRESS_ERROR 3 -#define M68K_IVEC_ILLEGAL_OPCODE 4 -#define M68K_IVEC_ZERO_DIVIDE 5 -#define M68K_IVEC_CHK 6 -#define M68K_IVEC_TRAPV 7 -#define M68K_IVEC_PRIVILEGE 8 -#define M68K_IVEC_TRACE 9 -#define M68K_IVEC_LINE_A 10 -#define M68K_IVEC_LINE_F 11 -/* Unassigned, Reserved 12-14 */ -#define M68K_IVEC_UNINITIALIZED_INT 15 -/* Unassigned, Reserved 16-23 */ -#define M68K_IVEC_SPURIOUS_INT 24 - -#define M68K_IVEC_LEVEL1_AUTOVECTOR 25 -#define M68K_IVEC_LEVEL2_AUTOVECTOR 26 -#define M68K_IVEC_LEVEL3_AUTOVECTOR 27 -#define M68K_IVEC_LEVEL4_AUTOVECTOR 28 -#define M68K_IVEC_LEVEL5_AUTOVECTOR 29 -#define M68K_IVEC_LEVEL6_AUTOVECTOR 30 -#define M68K_IVEC_LEVEL7_AUTOVECTOR 31 - -#define M68K_IVEC_TRAP0 32 -#define M68K_IVEC_TRAP1 33 -#define M68K_IVEC_TRAP2 34 -#define M68K_IVEC_TRAP3 35 -#define M68K_IVEC_TRAP4 36 -#define M68K_IVEC_TRAP5 37 -#define M68K_IVEC_TRAP6 38 -#define M68K_IVEC_TRAP7 39 -#define M68K_IVEC_TRAP8 40 -#define M68K_IVEC_TRAP9 41 -#define M68K_IVEC_TRAP10 42 -#define M68K_IVEC_TRAP11 43 -#define M68K_IVEC_TRAP12 44 -#define M68K_IVEC_TRAP13 45 -#define M68K_IVEC_TRAP14 46 -#define M68K_IVEC_TRAP15 47 -/* - * Unassigned, Reserved 48-59 - * - * Note: Vectors 60-63 are used by the MC68302 (e.g. BAR, SCR). - */ - -/* - * MC68302 Interrupt Vectors - * Section 3.2 - */ -enum m68302_ivec_e { - M302_IVEC_ERR =0, - M302_IVEC_PB8 =1, /* General-Purpose Interrupt 0 */ - M302_IVEC_SMC2 =2, - M302_IVEC_SMC1 =3, - M302_IVEC_TIMER3 =4, - M302_IVEC_SCP =5, - M302_IVEC_TIMER2 =6, - M302_IVEC_PB9 =7, /* General-Purpose Interrupt 1 */ - M302_IVEC_SCC3 =8, - M302_IVEC_TIMER1 =9, - M302_IVEC_SCC2 =10, - M302_IVEC_IDMA =11, - M302_IVEC_SDMA =12, /* SDMA Channels Bus Error */ - M302_IVEC_SCC1 =13, - M302_IVEC_PB10 =14, /* General-Purpose Interrupt 2 */ - M302_IVEC_PB11 =15, /* General-Purpose Interrupt 3 */ - M302_IVEC_IRQ1 =17, /* External Device */ - M302_IVEC_IRQ6 =22, /* External Device */ - M302_IVEC_IRQ7 =23 /* External Device */ -}; - - -/* - * GIMR - Global Interrupt Mode Register - * Section 3.2.5.1 - */ -#define RBIT_GIMR_MOD (1<<15) -#define RBIT_GIMR_IV7 (1<<14) -#define RBIT_GIMR_IV6 (1<<13) -#define RBIT_GIMR_IV1 (1<<12) -#define RBIT_GIMR_ET7 (1<<10) -#define RBIT_GIMR_ET6 (1<<9) -#define RBIT_GIMR_ET1 (1<<8) -#define RBIT_GIMR_VECTOR (7<<5) - -/* - * IPR - Interrupt Pending Register (Section 3.2.5.2) - * IMR - Interrupt Mask Register (Section 3.2.5.3) - * ISR - Interrupt In-Service Register (Section 3.2.5.4) - */ -#define RBIT_IPR_PB11 (1<<15) -#define RBIT_IPR_PB10 (1<<14) -#define RBIT_IPR_SCC1 (1<<13) -#define RBIT_IPR_SDMA (1<<12) -#define RBIT_IPR_IDMA (1<<11) -#define RBIT_IPR_SCC2 (1<<10) -#define RBIT_IPR_TIMER1 (1<<9) -#define RBIT_IPR_SCC3 (1<<8) -#define RBIT_IPR_PB9 (1<<7) -#define RBIT_IPR_TIMER2 (1<<6) -#define RBIT_IPR_SCP (1<<5) -#define RBIT_IPR_TIMER3 (1<<4) -#define RBIT_IPR_SMC1 (1<<3) -#define RBIT_IPR_SMC2 (1<<2) -#define RBIT_IPR_PB8 (1<<1) -#define RBIT_IPR_ERR (1<<0) - -#define RBIT_ISR_PB11 (1<<15) -#define RBIT_ISR_PB10 (1<<14) -#define RBIT_ISR_SCC1 (1<<13) -#define RBIT_ISR_SDMA (1<<12) -#define RBIT_ISR_IDMA (1<<11) -#define RBIT_ISR_SCC2 (1<<10) -#define RBIT_ISR_TIMER1 (1<<9) -#define RBIT_ISR_SCC3 (1<<8) -#define RBIT_ISR_PB9 (1<<7) -#define RBIT_ISR_TIMER2 (1<<6) -#define RBIT_ISR_SCP (1<<5) -#define RBIT_ISR_TIMER3 (1<<4) -#define RBIT_ISR_SMC1 (1<<3) -#define RBIT_ISR_SMC2 (1<<2) -#define RBIT_ISR_PB8 (1<<1) - -#define RBIT_IMR_PB11 (1<<15) /* PB11 Interrupt Mask */ -#define RBIT_IMR_PB10 (1<<14) /* PB10 Interrupt Mask */ -#define RBIT_IMR_SCC1 (1<<13) /* SCC1 Interrupt Mask */ -#define RBIT_IMR_SDMA (1<<12) /* SDMA Interrupt Mask */ -#define RBIT_IMR_IDMA (1<<11) /* IDMA Interrupt Mask */ -#define RBIT_IMR_SCC2 (1<<10) /* SCC2 Interrupt Mask */ -#define RBIT_IMR_TIMER1 (1<<9) /* TIMER1 Interrupt Mask */ -#define RBIT_IMR_SCC3 (1<<8) /* SCC3 Interrupt Mask */ -#define RBIT_IMR_PB9 (1<<7) /* PB9 Interrupt Mask */ -#define RBIT_IMR_TIMER2 (1<<6) /* TIMER2 Interrupt Mask */ -#define RBIT_IMR_SCP (1<<5) /* SCP Interrupt Mask */ -#define RBIT_IMR_TIMER3 (1<<4) /* TIMER3 Interrupt Mask */ -#define RBIT_IMR_SMC1 (1<<3) /* SMC1 Interrupt Mask */ -#define RBIT_IMR_SMC2 (1<<2) /* SMC2 Interrupt Mask */ -#define RBIT_IMR_PB8 (1<<1) /* PB8 Interrupt Mask */ - - -/* - * DRAM Refresh - * Section 3.9 - * - * The DRAM refresh memory map replaces the SCC2 Tx BD 6 and Tx BD 7 - * structures in the parameter RAM. - * - * Access to the DRAM registers can be accomplished by - * the following approach: - * - * volatile m302_DRAM_refresh_t *dram; - * dram = (volatile m302_DRAM_refresh_t *) &m302.scc2.bd.tx[6]; - * - * Then simply use pointer references (e.g. dram->count = 3). - */ -typedef struct { - uint16_t dram_high; /* DRAM high address and FC */ - uint16_t dram_low; /* DRAM low address */ - uint16_t increment; /* increment step (bytes/row) */ - uint16_t count; /* RAM refresh cycle count (#rows) */ - uint16_t t_ptr_h; /* temporary refresh high addr & FC */ - uint16_t t_ptr_l; /* temporary refresh low address */ - uint16_t t_count; /* temporary refresh cycles count */ - uint16_t res; /* reserved */ -} m302_DRAM_refresh_t; - - -/* - * TMR - Timer Mode Register (for timers 1 and 2) - * Section 3.5.2.1 - */ -#define RBIT_TMR_ICLK_STOP (0<<1) -#define RBIT_TMR_ICLK_MASTER (1<<1) -#define RBIT_TMR_ICLK_MASTER16 (2<<1) -#define RBIT_TMR_ICLK_TIN (3<<1) - -#define RBIT_TMR_OM (1<<5) -#define RBIT_TMR_ORI (1<<4) -#define RBIT_TMR_FRR (1<<3) -#define RBIT_TMR_RST (1<<0) - - -/* - * TER - Timer Event Register (for timers 1 and 2) - * Section 3.5.2.5 - */ -#define RBIT_TER_REF (1<<1) /* Output Reference Event */ -#define RBIT_TER_CAP (1<<0) /* Capture Event */ - - -/* - * SCC Buffer Descriptors and Buffer Descriptors Table - * Section 4.5.5 - */ -typedef struct m302_SCC_bd { - uint16_t status; /* status and control */ - uint16_t length; /* data length */ - volatile uint8_t *buffer; /* data buffer pointer */ -} m302_SCC_bd_t; - -typedef struct { - m302_SCC_bd_t rx[8]; /* receive buffer descriptors */ - m302_SCC_bd_t tx[8]; /* transmit buffer descriptors */ -} m302_SCC_bd_table_t; - - -/* - * SCC Parameter RAM (offset 0x080 from an SCC Base) - * Section 4.5.6 - * - * Each SCC parameter RAM area begins at offset 0x80 from each SCC base - * area (0x400, 0x500, or 0x600 from the dual-port RAM base). - * - * Offsets 0x9c-0xbf from each SCC base area compose the protocol-specific - * portion of the SCC parameter RAM. - */ -typedef struct { - uint8_t rfcr; /* Rx Function Code */ - uint8_t tfcr; /* Tx Function Code */ - uint16_t mrblr; /* Maximum Rx Buffer Length */ - uint16_t _rstate; /* Rx Internal State */ - uint8_t res2; - uint8_t rbd; /* Rx Internal Buffer Number */ - uint32_t _rdptr; /* Rx Internal Data Pointer */ - uint16_t _rcount; /* Rx Internal Byte Count */ - uint16_t _rtmp; /* Rx Temp */ - uint16_t _tstate; /* Tx Internal State */ - uint8_t res7; - uint8_t tbd; /* Tx Internal Buffer Number */ - uint32_t _tdptr; /* Tx Internal Data Pointer */ - uint16_t _tcount; /* Tx Internal Byte Count */ - uint16_t _ttmp; /* Tx Temp */ -} m302_SCC_parameters_t; - -/* - * UART-Specific SCC Parameter RAM - * Section 4.5.11.3 - */ -typedef struct { - uint16_t max_idl; /* Maximum IDLE Characters (rx) */ - uint16_t idlc; /* Temporary rx IDLE counter */ - uint16_t brkcr; /* Break Count Register (tx) */ - uint16_t parec; /* Receive Parity Error Counter */ - uint16_t frmec; /* Receive Framing Error Counter */ - uint16_t nosec; /* Receive Noise Counter */ - uint16_t brkec; /* Receive Break Condition Counter */ - uint16_t uaddr1; /* UART ADDRESS Character 1 */ - uint16_t uaddr2; /* UART ADDRESS Character 2 */ - uint16_t rccr; /* Receive Control Character Register */ - uint16_t character[8]; /* Control Characters 1 through 8*/ -} m302_SCC_UartSpecific_t; -/* - * This definition allows for the checking of receive buffers - * for errors. - */ - -#define RCV_ERR 0x003F - -/* - * UART receive buffer descriptor bit definitions. - * Section 4.5.11.14 - */ -#define RBIT_UART_CTRL (1<<11) /* buffer contains a control char */ -#define RBIT_UART_ADDR (1<<10) /* first byte contains an address */ -#define RBIT_UART_MATCH (1<<9) /* indicates which addr char matched */ -#define RBIT_UART_IDLE (1<<8) /* buffer closed due to IDLE sequence */ -#define RBIT_UART_BR (1<<5) /* break sequence was received */ -#define RBIT_UART_FR (1<<4) /* framing error was received */ -#define RBIT_UART_PR (1<<3) /* parity error was received */ -#define RBIT_UART_OV (1<<1) /* receiver overrun occurred */ -#define RBIT_UART_CD (1<<0) /* carrier detect lost */ -#define RBIT_UART_STATUS 0x003B /* all status bits */ - -/* - * UART transmit buffer descriptor bit definitions. - * Section 4.5.11.15 - */ -#define RBIT_UART_CR (1<<11) /* clear-to-send report - * this results in two idle bits - * between back-to-back frames - */ -#define RBIT_UART_A (1<<10) /* buffer contains address characters - * only valid in multidrop mode (UM0=1) - */ -#define RBIT_UART_PREAMBLE (1<<9) /* send preamble before data */ -#define RBIT_UART_CTS_LOST (1<<0) /* CTS lost */ - -/* - * UART event register - * Section 4.5.11.16 - */ -#define M302_UART_EV_CTS (1<<7) /* CTS status changed */ -#define M302_UART_EV_CD (1<<6) /* carrier detect status changed */ -#define M302_UART_EV_IDL (1<<5) /* IDLE sequence status changed */ -#define M302_UART_EV_BRK (1<<4) /* break character was received */ -#define M302_UART_EV_CCR (1<<3) /* control character received */ -#define M302_UART_EV_TX (1<<1) /* buffer has been transmitted */ -#define M302_UART_EV_RX (1<<0) /* buffer has been received */ - - -/* - * HDLC-Specific SCC Parameter RAM - * Section 4.5.12.3 - * - * c_mask_l should be 0xF0B8 for 16-bit CRC, 0xdebb for 32-bit CRC - * c_mask_h is a don't care for 16-bit CRC, 0x20E2 for 32-bit CRC - */ -typedef struct { - uint16_t rcrc_l; /* Temp Receive CRC Low */ - uint16_t rcrc_h; /* Temp Receive CRC High */ - uint16_t c_mask_l; /* CRC Mask Low */ - uint16_t c_mask_h; /* CRC Mask High */ - uint16_t tcrc_l; /* Temp Transmit CRC Low */ - uint16_t tcrc_h; /* Temp Transmit CRC High */ - - uint16_t disfc; /* Discard Frame Counter */ - uint16_t crcec; /* CRC Error Counter */ - uint16_t abtsc; /* Abort Sequence Counter */ - uint16_t nmarc; /* Nonmatching Address Received Cntr */ - uint16_t retrc; /* Frame Retransmission Counter */ - - uint16_t mflr; /* Maximum Frame Length Register */ - uint16_t max_cnt; /* Maximum_Length Counter */ - - uint16_t hmask; /* User Defined Frame Address Mask */ - uint16_t haddr1; /* User Defined Frame Address */ - uint16_t haddr2; /* " */ - uint16_t haddr3; /* " */ - uint16_t haddr4; /* " */ -} m302_SCC_HdlcSpecific_t; -/* - * HDLC receiver buffer descriptor bit definitions - * Section 4.5.12.10 - */ -#define RBIT_HDLC_EMPTY_BIT 0x8000 /* buffer associated with BD is empty */ -#define RBIT_HDLC_LAST_BIT 0x0800 /* buffer is last in a frame */ -#define RBIT_HDLC_FIRST_BIT 0x0400 /* buffer is first in a frame */ -#define RBIT_HDLC_FRAME_LEN 0x0020 /* receiver frame length violation */ -#define RBIT_HDLC_NONOCT_Rx 0x0010 /* received non-octet aligned frame */ -#define RBIT_HDLC_ABORT_SEQ 0x0008 /* received abort sequence */ -#define RBIT_HDLC_CRC_ERROR 0x0004 /* frame contains a CRC error */ -#define RBIT_HDLC_OVERRUN 0x0002 /* receiver overrun occurred */ -#define RBIT_HDLC_CD_LOST 0x0001 /* carrier detect lost */ - -/* - * HDLC transmit buffer descriptor bit definitions - * Section 4.5.12.11 - */ -#define RBIT_HDLC_READY_BIT 0x8000 /* buffer is ready to transmit */ -#define RBIT_HDLC_EXT_BUFFER 0x4000 /* buffer is in external memory */ -#define RBIT_HDLC_WRAP_BIT 0x2000 /* last buffer in bd table, so wrap */ -#define RBIT_HDLC_WAKE_UP 0x1000 /* interrupt when buffer serviced */ -#define RBIT_HDLC_LAST_BIT 0x0800 /* buffer is last in the frame */ -#define RBIT_HDLC_TxCRC_BIT 0x0400 /* transmit a CRC sequence */ -#define RBIT_HDLC_UNDERRUN 0x0002 /* transmitter underrun */ -#define RBIT_HDLC_CTS_LOST 0x0001 /* CTS lost */ - -/* - * HDLC event register bit definitions - * Section 4.5.12.12 - */ -#define RBIT_HDLC_CTS 0x80 /* CTS status changed */ -#define RBIT_HDLC_CD 0x40 /* carrier detect status changed */ -#define RBIT_HDLC_IDL 0x20 /* IDLE sequence status changed */ -#define RBIT_HDLC_TXE 0x10 /* transmit error */ -#define RBIT_HDLC_RXF 0x08 /* received frame */ -#define RBIT_HDLC_BSY 0x04 /* frame rcvd and discarded due to - * lack of buffers - */ -#define RBIT_HDLC_TXB 0x02 /* buffer has been transmitted */ -#define RBIT_HDLC_RXB 0x01 /* received buffer */ - - - -typedef struct { - m302_SCC_bd_table_t bd; /* +000 Buffer Descriptor Table */ - m302_SCC_parameters_t parm; /* +080 Common Parameter RAM */ - union { /* +09C Protocol-Specific Parm RAM */ - m302_SCC_UartSpecific_t uart; - m302_SCC_HdlcSpecific_t hdlc; - } prot; - uint8_t res[0x040]; /* +0C0 reserved, (not implemented) */ -} m302_SCC_t; - - -/* - * Common SCC Registers - */ -typedef struct { - uint16_t res1; - uint16_t scon; /* SCC Configuration Register 4.5.2 */ - uint16_t scm; /* SCC Mode Register 4.5.3 */ - uint16_t dsr; /* SCC Data Synchronization Register 4.5.4 */ - uint8_t scce; /* SCC Event Register 4.5.8.1 */ - uint8_t res2; - uint8_t sccm; /* SCC Mask Register 4.5.8.2 */ - uint8_t res3; - uint8_t sccs; /* SCC Status Register 4.5.8.3 */ - uint8_t res4; - uint16_t res5; -} m302_SCC_Registers_t; - -/* - * SCON - SCC Configuration Register - * Section 4.5.2 - */ -#define RBIT_SCON_WOMS (1<<15) /* Wired-OR Mode Select (NMSI mode only) - * When set, the TXD driver is an - * open-drain output */ -#define RBIT_SCON_EXTC (1<<14) /* External Clock Source */ -#define RBIT_SCON_TCS (1<<13) /* Transmit Clock Source */ -#define RBIT_SCON_RCS (1<<12) /* Receive Clock Source */ - -/* - * SCM - SCC Mode Register bit definitions - * Section 4.5.3 - * The parameter-specific mode bits occupy bits 15 through 6. - */ -#define RBIT_SCM_ENR (1<<3) /* Enable receiver */ -#define RBIT_SCM_ENT (1<<2) /* Enable transmitter */ - - -/* - * Internal MC68302 Registers - * starts at offset 0x800 from dual-port RAM base - * Section 2.8 - */ -typedef struct { - /* offset +800 */ - uint16_t res0; - uint16_t cmr; /* IDMA Channel Mode Register */ - uint32_t sapr; /* IDMA Source Address Pointer */ - uint32_t dapr; /* IDMA Destination Address Pointer */ - uint16_t bcr; /* IDMA Byte Count Register */ - uint8_t csr; /* IDMA Channel Status Register */ - uint8_t res1; - uint8_t fcr; /* IDMA Function Code Register */ - uint8_t res2; - - /* offset +812 */ - uint16_t gimr; /* Global Interrupt Mode Register */ - uint16_t ipr; /* Interrupt Pending Register */ - uint16_t imr; /* Interrupt Mask Register */ - uint16_t isr; /* Interrupt In-Service Register */ - uint16_t res3; - uint16_t res4; - - /* offset +81e */ - uint16_t pacnt; /* Port A Control Register */ - uint16_t paddr; /* Port A Data Direction Register */ - uint16_t padat; /* Port A Data Register */ - uint16_t pbcnt; /* Port B Control Register */ - uint16_t pbddr; /* Port B Data Direction Register */ - uint16_t pbdat; /* Port B Data Register */ - uint16_t res5; - - /* offset +82c */ - uint16_t res6; - uint16_t res7; - - uint16_t br0; /* Base Register (CS0) */ - uint16_t or0; /* Option Register (CS0) */ - uint16_t br1; /* Base Register (CS1) */ - uint16_t or1; /* Option Register (CS1) */ - uint16_t br2; /* Base Register (CS2) */ - uint16_t or2; /* Option Register (CS2) */ - uint16_t br3; /* Base Register (CS3) */ - uint16_t or3; /* Option Register (CS3) */ - - /* offset +840 */ - uint16_t tmr1; /* Timer Unit 1 Mode Register */ - uint16_t trr1; /* Timer Unit 1 Reference Register */ - uint16_t tcr1; /* Timer Unit 1 Capture Register */ - uint16_t tcn1; /* Timer Unit 1 Counter */ - uint8_t res8; - uint8_t ter1; /* Timer Unit 1 Event Register */ - uint16_t wrr; /* Watchdog Reference Register */ - uint16_t wcn; /* Watchdog Counter */ - uint16_t res9; - uint16_t tmr2; /* Timer Unit 2 Mode Register */ - uint16_t trr2; /* Timer Unit 2 Reference Register */ - uint16_t tcr2; /* Timer Unit 2 Capture Register */ - uint16_t tcn2; /* Timer Unit 2 Counter */ - uint8_t resa; - uint8_t ter2; /* Timer Unit 2 Event Register */ - uint16_t resb; - uint16_t resc; - uint16_t resd; - - /* offset +860 */ - uint8_t cr; /* Command Register */ - uint8_t rese[0x1f]; - - /* offset +880, +890, +8a0 */ - m302_SCC_Registers_t scc[3]; /* SCC1, SCC2, SCC3 Registers */ - - /* offset +8b0 */ - uint16_t spmode; /* SCP,SMC Mode and Clock Cntrl Reg */ - uint16_t simask; /* Serial Interface Mask Register */ - uint16_t simode; /* Serial Interface Mode Register */ -} m302_internalReg_t ; - - -/* - * MC68302 dual-port RAM structure. - * (Includes System RAM, Parameter RAM, and Internal Registers). - * Section 2.8 - */ -typedef struct { - uint8_t mem[0x240]; /* +000 User Data Memory */ - uint8_t res1[0x1c0]; /* +240 reserved, (not implemented) */ - m302_SCC_t scc1; /* +400 SCC1 */ - m302_SCC_t scc2; /* +500 SCC2 */ - m302_SCC_t scc3; /* +600 SCC3 */ - uint8_t res2[0x100]; /* +700 reserved, (not implemented) */ - m302_internalReg_t reg; /* +800 68302 Internal Registers */ -} m302_dualPortRAM_t; - -/* some useful defines the some of the registers above */ - - -/* ---- - MC68302 Chip Select Registers - p3-46 2nd Edition - - */ -#define BR_ENABLED 1 -#define BR_DISABLED 0 -#define BR_FC_NULL 0 -#define BR_READ_ONLY 0 -#define BR_READ_WRITE 2 -#define OR_DTACK_0 0x0000 -#define OR_DTACK_1 0x2000 -#define OR_DTACK_2 0x4000 -#define OR_DTACK_3 0x6000 -#define OR_DTACK_4 0x8000 -#define OR_DTACK_5 0xA000 -#define OR_DTACK_6 0xC000 -#define OR_DTACK_EXT 0xE000 -#define OR_SIZE_64K 0x1FE0 -#define OR_SIZE_128K 0x1FC0 -#define OR_SIZE_256K 0x1F80 -#define OR_SIZE_512K 0x1F00 -#define OR_SIZE_1M 0x1E00 -#define OR_SIZE_2M 0x1C00 -#define OR_MASK_RW 0x0000 -#define OR_NO_MASK_RW 0x0002 -#define OR_MASK_FC 0x0000 -#define OR_NO_MASK_FC 0x0001 - -#define MAKE_BR(base_address, enable, rw, fc) \ - ((base_address >> 11) | fc | rw | enable) - -#define MAKE_OR(bsize, DtAck, RW_Mask, FC_Mask) \ - (DtAck | ((~(bsize - 1) & 0x00FFFFFF) >> 11) | FC_Mask | RW_Mask) - -#define __REG_CAT(r, n) r ## n -#define WRITE_BR(csel, base_address, enable, rw, fc) \ - __REG_CAT(m302.reg.br, csel) = MAKE_BR(base_address, enable, rw, fc) -#define WRITE_OR(csel, bsize, DtAck, RW_Mask, FC_Mask) \ - __REG_CAT(m302.reg.or, csel) = MAKE_OR(bsize, DtAck, RW_Mask, FC_Mask) - -/* ---- - MC68302 Watchdog Timer Enable Bit - - */ -#define WATCHDOG_ENABLE (1) -#define WATCHDOG_TRIGGER() (m302.reg.wrr = 0x10 | WATCHDOG_ENABLE, m302.reg.wcn = 0) -#define WATCHDOG_TOGGLE() (m302.reg.wcn = WATCHDOG_TIMEOUT_PERIOD) -#define DISABLE_WATCHDOG() (m302.reg.wrr = 0) - -/* - * Declare the variable that's used to reference the variables in - * the dual-port RAM. - */ -extern volatile m302_dualPortRAM_t m302; - -#endif diff --git a/cpukit/score/cpu/m68k/rtems/m68k/m68360.h b/cpukit/score/cpu/m68k/rtems/m68k/m68360.h deleted file mode 100644 index dc181d0cdf..0000000000 --- a/cpukit/score/cpu/m68k/rtems/m68k/m68360.h +++ /dev/null @@ -1,899 +0,0 @@ -/** - * @file - * - * @brief Definitions for Motorola MC68360 Processor - */ -/* - ************************************************************************** - ************************************************************************** - ** ** - ** MOTOROLA MC68360 QUAD INTEGRATED COMMUNICATIONS CONTROLLER (QUICC) ** - ** ** - ** HARDWARE DECLARATIONS ** - ** ** - ** ** - ** Submitted By: ** - ** ** - ** W. Eric Norum ** - ** Saskatchewan Accelerator Laboratory ** - ** University of Saskatchewan ** - ** 107 North Road ** - ** Saskatoon, Saskatchewan, CANADA ** - ** S7N 5C6 ** - ** ** - ** eric@skatter.usask.ca ** - ** ** - ************************************************************************** - ************************************************************************** - */ - -#ifndef _RTEMS_M68K_M68360_H -#define _RTEMS_M68K_M68360_H - -/* - ************************************************************************* - * REGISTER SUBBLOCKS * - ************************************************************************* - */ - -/* - * Memory controller registers - */ -typedef struct m360MEMCRegisters_ { - unsigned long br; - unsigned long or; - unsigned long _pad[2]; -} m360MEMCRegisters_t; - -/* - * Serial Communications Controller registers - */ -typedef struct m360SCCRegisters_ { - unsigned long gsmr_l; - unsigned long gsmr_h; - unsigned short psmr; - unsigned short _pad0; - unsigned short todr; - unsigned short dsr; - unsigned short scce; - unsigned short _pad1; - unsigned short sccm; - unsigned char _pad2; - unsigned char sccs; - unsigned long _pad3[2]; -} m360SCCRegisters_t; - -/* - * Serial Management Controller registers - */ -typedef struct m360SMCRegisters_ { - unsigned short _pad0; - unsigned short smcmr; - unsigned short _pad1; - unsigned char smce; - unsigned char _pad2; - unsigned short _pad3; - unsigned char smcm; - unsigned char _pad4; - unsigned long _pad5; -} m360SMCRegisters_t; - - -/* - ************************************************************************* - * Miscellaneous Parameters * - ************************************************************************* - */ -typedef struct m360MiscParms_ { - unsigned short rev_num; - unsigned short _res1; - unsigned long _res2; - unsigned long _res3; -} m360MiscParms_t; - -/* - ************************************************************************* - * RISC Timers * - ************************************************************************* - */ -typedef struct m360TimerParms_ { - unsigned short tm_base; - unsigned short _tm_ptr; - unsigned short _r_tmr; - unsigned short _r_tmv; - unsigned long tm_cmd; - unsigned long tm_cnt; -} m360TimerParms_t; - -/* - * RISC Controller Configuration Register (RCCR) - * All other bits in this register are either reserved or - * used only with a Motorola-supplied RAM microcode packge. - */ -#define M360_RCCR_TIME (1<<15) /* Enable timer */ -#define M360_RCCR_TIMEP(x) ((x)<<8) /* Timer period */ - -/* - * Command register - * Set up this register before issuing a M360_CR_OP_SET_TIMER command. - */ -#define M360_TM_CMD_V (1<<31) /* Set to enable timer */ -#define M360_TM_CMD_R (1<<30) /* Set for automatic restart */ -#define M360_TM_CMD_TIMER(x) ((x)<<16) /* Select timer */ -#define M360_TM_CMD_PERIOD(x) (x) /* Timer period (16 bits) */ - -/* - ************************************************************************* - * DMA Controllers * - ************************************************************************* - */ -typedef struct m360IDMAparms_ { - unsigned short ibase; - unsigned short ibptr; - unsigned long _istate; - unsigned long _itemp; -} m360IDMAparms_t; - -/* - ************************************************************************* - * Serial Communication Controllers * - ************************************************************************* - */ -typedef struct m360SCCparms_ { - unsigned short rbase; - unsigned short tbase; - unsigned char rfcr; - unsigned char tfcr; - unsigned short mrblr; - unsigned long _rstate; - unsigned long _pad0; - unsigned short _rbptr; - unsigned short _pad1; - unsigned long _pad2; - unsigned long _tstate; - unsigned long _pad3; - unsigned short _tbptr; - unsigned short _pad4; - unsigned long _pad5; - unsigned long _rcrc; - unsigned long _tcrc; - union { - struct { - unsigned long _res0; - unsigned long _res1; - unsigned short max_idl; - unsigned short _idlc; - unsigned short brkcr; - unsigned short parec; - unsigned short frmec; - unsigned short nosec; - unsigned short brkec; - unsigned short brklen; - unsigned short uaddr[2]; - unsigned short _rtemp; - unsigned short toseq; - unsigned short character[8]; - unsigned short rccm; - unsigned short rccr; - unsigned short rlbc; - } uart; - struct { - unsigned long crc_p; - unsigned long crc_c; - } transparent; - - } un; -} m360SCCparms_t; - -typedef struct m360SCCENparms_ { - unsigned short rbase; - unsigned short tbase; - unsigned char rfcr; - unsigned char tfcr; - unsigned short mrblr; - unsigned long _rstate; - unsigned long _pad0; - unsigned short _rbptr; - unsigned short _pad1; - unsigned long _pad2; - unsigned long _tstate; - unsigned long _pad3; - unsigned short _tbptr; - unsigned short _pad4; - unsigned long _pad5; - unsigned long _rcrc; - unsigned long _tcrc; - union { - struct { - unsigned long _res0; - unsigned long _res1; - unsigned short max_idl; - unsigned short _idlc; - unsigned short brkcr; - unsigned short parec; - unsigned short frmec; - unsigned short nosec; - unsigned short brkec; - unsigned short brklen; - unsigned short uaddr[2]; - unsigned short _rtemp; - unsigned short toseq; - unsigned short character[8]; - unsigned short rccm; - unsigned short rccr; - unsigned short rlbc; - } uart; - struct { - unsigned long c_pres; - unsigned long c_mask; - unsigned long crcec; - unsigned long alec; - unsigned long disfc; - unsigned short pads; - unsigned short ret_lim; - unsigned short _ret_cnt; - unsigned short mflr; - unsigned short minflr; - unsigned short maxd1; - unsigned short maxd2; - unsigned short _maxd; - unsigned short dma_cnt; - unsigned short _max_b; - unsigned short gaddr1; - unsigned short gaddr2; - unsigned short gaddr3; - unsigned short gaddr4; - unsigned long _tbuf0data0; - unsigned long _tbuf0data1; - unsigned long _tbuf0rba0; - unsigned long _tbuf0crc; - unsigned short _tbuf0bcnt; - unsigned short paddr_h; - unsigned short paddr_m; - unsigned short paddr_l; - unsigned short p_per; - unsigned short _rfbd_ptr; - unsigned short _tfbd_ptr; - unsigned short _tlbd_ptr; - unsigned long _tbuf1data0; - unsigned long _tbuf1data1; - unsigned long _tbuf1rba0; - unsigned long _tbuf1crc; - unsigned short _tbuf1bcnt; - unsigned short _tx_len; - unsigned short iaddr1; - unsigned short iaddr2; - unsigned short iaddr3; - unsigned short iaddr4; - unsigned short _boff_cnt; - unsigned short taddr_h; - unsigned short taddr_m; - unsigned short taddr_l; - } ethernet; - struct { - unsigned long crc_p; - unsigned long crc_c; - } transparent; - } un; -} m360SCCENparms_t; - -/* - * Receive and transmit function code register bits - * These apply to the function code registers of all devices, not just SCC. - */ -#define M360_RFCR_MOT (1<<4) -#define M360_RFCR_DMA_SPACE 0x8 -#define M360_TFCR_MOT (1<<4) -#define M360_TFCR_DMA_SPACE 0x8 - -/* - ************************************************************************* - * Serial Management Controllers * - ************************************************************************* - */ -typedef struct m360SMCparms_ { - unsigned short rbase; - unsigned short tbase; - unsigned char rfcr; - unsigned char tfcr; - unsigned short mrblr; - unsigned long _rstate; - unsigned long _pad0; - unsigned short _rbptr; - unsigned short _pad1; - unsigned long _pad2; - unsigned long _tstate; - unsigned long _pad3; - unsigned short _tbptr; - unsigned short _pad4; - unsigned long _pad5; - union { - struct { - unsigned short max_idl; - unsigned short _pad0; - unsigned short brklen; - unsigned short brkec; - unsigned short brkcr; - unsigned short _r_mask; - } uart; - struct { - unsigned short _pad0[5]; - } transparent; - } un; -} m360SMCparms_t; - -/* - * Mode register - */ -#define M360_SMCMR_CLEN(x) ((x)<<11) /* Character length */ -#define M360_SMCMR_2STOP (1<<10) /* 2 stop bits */ -#define M360_SMCMR_PARITY (1<<9) /* Enable parity */ -#define M360_SMCMR_EVEN (1<<8) /* Even parity */ -#define M360_SMCMR_SM_GCI (0<<4) /* GCI Mode */ -#define M360_SMCMR_SM_UART (2<<4) /* UART Mode */ -#define M360_SMCMR_SM_TRANSPARENT (3<<4) /* Transparent Mode */ -#define M360_SMCMR_DM_LOOPBACK (1<<2) /* Local loopback mode */ -#define M360_SMCMR_DM_ECHO (2<<2) /* Echo mode */ -#define M360_SMCMR_TEN (1<<1) /* Enable transmitter */ -#define M360_SMCMR_REN (1<<0) /* Enable receiver */ - -/* - * Event and mask registers (SMCE, SMCM) - */ -#define M360_SMCE_BRK (1<<4) -#define M360_SMCE_BSY (1<<2) -#define M360_SMCE_TX (1<<1) -#define M360_SMCE_RX (1<<0) - -/* - ************************************************************************* - * Serial Peripheral Interface * - ************************************************************************* - */ -typedef struct m360SPIparms_ { - unsigned short rbase; - unsigned short tbase; - unsigned char rfcr; - unsigned char tfcr; - unsigned short mrblr; - unsigned long _rstate; - unsigned long _pad0; - unsigned short _rbptr; - unsigned short _pad1; - unsigned long _pad2; - unsigned long _tstate; - unsigned long _pad3; - unsigned short _tbptr; - unsigned short _pad4; - unsigned long _pad5; -} m360SPIparms_t; - -/* - * Mode register (SPMODE) - */ -#define M360_SPMODE_LOOP (1<<14) /* Local loopback mode */ -#define M360_SPMODE_CI (1<<13) /* Clock invert */ -#define M360_SPMODE_CP (1<<12) /* Clock phase */ -#define M360_SPMODE_DIV16 (1<<11) /* Divide BRGCLK by 16 */ -#define M360_SPMODE_REV (1<<10) /* Reverse data */ -#define M360_SPMODE_MASTER (1<<9) /* SPI is master */ -#define M360_SPMODE_EN (1<<8) /* Enable SPI */ -#define M360_SPMODE_CLEN(x) ((x)<<4) /* Character length */ -#define M360_SPMODE_PM(x) (x) /* Prescaler modulus */ - -/* - * Mode register (SPCOM) - */ -#define M360_SPCOM_STR (1<<7) /* Start transmit */ - -/* - * Event and mask registers (SPIE, SPIM) - */ -#define M360_SPIE_MME (1<<5) /* Multi-master error */ -#define M360_SPIE_TXE (1<<4) /* Tx error */ -#define M360_SPIE_BSY (1<<2) /* Busy condition*/ -#define M360_SPIE_TXB (1<<1) /* Tx buffer */ -#define M360_SPIE_RXB (1<<0) /* Rx buffer */ - -/* - ************************************************************************* - * SDMA (SCC, SMC, SPI) Buffer Descriptors * - ************************************************************************* - */ -typedef struct m360BufferDescriptor_ { - unsigned short status; - unsigned short length; - volatile void *buffer; -} m360BufferDescriptor_t; - -/* - * Bits in receive buffer descriptor status word - */ -#define M360_BD_EMPTY (1<<15) /* Ethernet, SCC UART, SMC UART, SPI */ -#define M360_BD_WRAP (1<<13) /* Ethernet, SCC UART, SMC UART, SPI */ -#define M360_BD_INTERRUPT (1<<12) /* Ethernet, SCC UART, SMC UART, SPI */ -#define M360_BD_LAST (1<<11) /* Ethernet, SPI */ -#define M360_BD_CONTROL_CHAR (1<<11) /* SCC UART */ -#define M360_BD_FIRST_IN_FRAME (1<<10) /* Ethernet */ -#define M360_BD_ADDRESS (1<<10) /* SCC UART */ -#define M360_BD_CONTINUOUS (1<<9) /* SCC UART, SMC UART, SPI */ -#define M360_BD_MISS (1<<8) /* Ethernet */ -#define M360_BD_IDLE (1<<8) /* SCC UART, SMC UART */ -#define M360_BD_ADDRSS_MATCH (1<<7) /* SCC UART */ -#define M360_BD_LONG (1<<5) /* Ethernet */ -#define M360_BD_BREAK (1<<5) /* SCC UART, SMC UART */ -#define M360_BD_NONALIGNED (1<<4) /* Ethernet */ -#define M360_BD_FRAMING_ERROR (1<<4) /* SCC UART, SMC UART */ -#define M360_BD_SHORT (1<<3) /* Ethernet */ -#define M360_BD_PARITY_ERROR (1<<3) /* SCC UART, SMC UART */ -#define M360_BD_CRC_ERROR (1<<2) /* Ethernet */ -#define M360_BD_OVERRUN (1<<1) /* Ethernet, SCC UART, SMC UART, SPI */ -#define M360_BD_COLLISION (1<<0) /* Ethernet */ -#define M360_BD_CARRIER_LOST (1<<0) /* SCC UART */ -#define M360_BD_MASTER_ERROR (1<<0) /* SPI */ - -/* - * Bits in transmit buffer descriptor status word - * Many bits have the same meaning as those in receiver buffer descriptors. - */ -#define M360_BD_READY (1<<15) /* Ethernet, SCC UART, SMC UART, SPI */ -#define M360_BD_PAD (1<<14) /* Ethernet */ -#define M360_BD_CTS_REPORT (1<<11) /* SCC UART */ -#define M360_BD_TX_CRC (1<<10) /* Ethernet */ -#define M360_BD_DEFER (1<<9) /* Ethernet */ -#define M360_BD_HEARTBEAT (1<<8) /* Ethernet */ -#define M360_BD_PREAMBLE (1<<8) /* SCC UART, SMC UART */ -#define M360_BD_LATE_COLLISION (1<<7) /* Ethernet */ -#define M360_BD_NO_STOP_BIT (1<<7) /* SCC UART */ -#define M360_BD_RETRY_LIMIT (1<<6) /* Ethernet */ -#define M360_BD_RETRY_COUNT(x) (((x)&0x3C)>>2) /* Ethernet */ -#define M360_BD_UNDERRUN (1<<1) /* Ethernet, SPI */ -#define M360_BD_CARRIER_LOST (1<<0) /* Ethernet */ -#define M360_BD_CTS_LOST (1<<0) /* SCC UART */ - -/* - ************************************************************************* - * IDMA Buffer Descriptors * - ************************************************************************* - */ -typedef struct m360IDMABufferDescriptor_ { - unsigned short status; - unsigned short _pad; - unsigned long length; - void *source; - void *destination; -} m360IDMABufferDescriptor_t; - -/* - ************************************************************************* - * RISC Communication Processor Module Command Register (CR) * - ************************************************************************* - */ -#define M360_CR_RST (1<<15) /* Reset communication processor */ -#define M360_CR_OP_INIT_RX_TX (0<<8) /* SCC, SMC UART, SMC GCI, SPI */ -#define M360_CR_OP_INIT_RX (1<<8) /* SCC, SMC UART, SPI */ -#define M360_CR_OP_INIT_TX (2<<8) /* SCC, SMC UART, SPI */ -#define M360_CR_OP_INIT_HUNT (3<<8) /* SCC, SMC UART */ -#define M360_CR_OP_STOP_TX (4<<8) /* SCC, SMC UART */ -#define M360_CR_OP_GR_STOP_TX (5<<8) /* SCC */ -#define M360_CR_OP_INIT_IDMA (5<<8) /* IDMA */ -#define M360_CR_OP_RESTART_TX (6<<8) /* SCC, SMC UART */ -#define M360_CR_OP_CLOSE_RX_BD (7<<8) /* SCC, SMC UART, SPI */ -#define M360_CR_OP_SET_GRP_ADDR (8<<8) /* SCC */ -#define M360_CR_OP_SET_TIMER (8<<8) /* Timer */ -#define M360_CR_OP_GCI_TIMEOUT (9<<8) /* SMC GCI */ -#define M360_CR_OP_RESERT_BCS (10<<8) /* SCC */ -#define M360_CR_OP_GCI_ABORT (10<<8) /* SMC GCI */ -#define M360_CR_CHAN_SCC1 (0<<4) /* Channel selection */ -#define M360_CR_CHAN_SCC2 (4<<4) -#define M360_CR_CHAN_SPI (5<<4) -#define M360_CR_CHAN_TIMER (5<<4) -#define M360_CR_CHAN_SCC3 (8<<4) -#define M360_CR_CHAN_SMC1 (9<<4) -#define M360_CR_CHAN_IDMA1 (9<<4) -#define M360_CR_CHAN_SCC4 (12<<4) -#define M360_CR_CHAN_SMC2 (13<<4) -#define M360_CR_CHAN_IDMA2 (13<<4) -#define M360_CR_FLG (1<<0) /* Command flag */ - -/* - ************************************************************************* - * System Protection Control Register (SYPCR) * - ************************************************************************* - */ -#define M360_SYPCR_SWE (1<<7) /* Software watchdog enable */ -#define M360_SYPCR_SWRI (1<<6) /* Software watchdog reset select */ -#define M360_SYPCR_SWT1 (1<<5) /* Software watchdog timing bit 1 */ -#define M360_SYPCR_SWT0 (1<<4) /* Software watchdog timing bit 0 */ -#define M360_SYPCR_DBFE (1<<3) /* Double bus fault monitor enable */ -#define M360_SYPCR_BME (1<<2) /* Bus monitor external enable */ -#define M360_SYPCR_BMT1 (1<<1) /* Bus monitor timing bit 1 */ -#define M360_SYPCR_BMT0 (1<<0) /* Bus monitor timing bit 0 */ - -/* - ************************************************************************* - * Memory Control Registers * - ************************************************************************* - */ -#define M360_GMR_RCNT(x) ((x)<<24) /* Refresh count */ -#define M360_GMR_RFEN (1<<23) /* Refresh enable */ -#define M360_GMR_RCYC(x) ((x)<<21) /* Refresh cycle length */ -#define M360_GMR_PGS(x) ((x)<<18) /* Page size */ -#define M360_GMR_DPS_32BIT (0<<16) /* DRAM port size */ -#define M360_GMR_DPS_16BIT (1<<16) -#define M360_GMR_DPS_8BIT (2<<16) -#define M360_GMR_DPS_DSACK (3<<16) -#define M360_GMR_WBT40 (1<<15) /* Wait between 040 transfers */ -#define M360_GMR_WBTQ (1<<14) /* Wait between 360 transfers */ -#define M360_GMR_SYNC (1<<13) /* Synchronous external access */ -#define M360_GMR_EMWS (1<<12) /* External master wait state */ -#define M360_GMR_OPAR (1<<11) /* Odd parity */ -#define M360_GMR_PBEE (1<<10) /* Parity bus error enable */ -#define M360_GMR_TSS40 (1<<9) /* TS* sample for 040 */ -#define M360_GMR_NCS (1<<8) /* No CPU space */ -#define M360_GMR_DWQ (1<<7) /* Delay write for 360 */ -#define M360_GMR_DW40 (1<<6) /* Delay write for 040 */ -#define M360_GMR_GAMX (1<<5) /* Global address mux enable */ - -#define M360_MEMC_BR_FC(x) ((x)<<7) /* Function code limit */ -#define M360_MEMC_BR_TRLXQ (1<<6) /* Relax timing requirements */ -#define M360_MEMC_BR_BACK40 (1<<5) /* Burst acknowledge to 040 */ -#define M360_MEMC_BR_CSNT40 (1<<4) /* CS* negate timing for 040 */ -#define M360_MEMC_BR_CSNTQ (1<<3) /* CS* negate timing for 360 */ -#define M360_MEMC_BR_PAREN (1<<2) /* Enable parity checking */ -#define M360_MEMC_BR_WP (1<<1) /* Write Protect */ -#define M360_MEMC_BR_V (1<<0) /* Base/Option register are valid */ - -#define M360_MEMC_OR_TCYC(x) ((x)<<28) /* Cycle length (clocks) */ -#define M360_MEMC_OR_WAITS(x) M360_MEMC_OR_TCYC((x)+1) -#define M360_MEMC_OR_2KB 0x0FFFF800 /* Address range */ -#define M360_MEMC_OR_4KB 0x0FFFF000 -#define M360_MEMC_OR_8KB 0x0FFFE000 -#define M360_MEMC_OR_16KB 0x0FFFC000 -#define M360_MEMC_OR_32KB 0x0FFF8000 -#define M360_MEMC_OR_64KB 0x0FFF0000 -#define M360_MEMC_OR_128KB 0x0FFE0000 -#define M360_MEMC_OR_256KB 0x0FFC0000 -#define M360_MEMC_OR_512KB 0x0FF80000 -#define M360_MEMC_OR_1MB 0x0FF00000 -#define M360_MEMC_OR_2MB 0x0FE00000 -#define M360_MEMC_OR_4MB 0x0FC00000 -#define M360_MEMC_OR_8MB 0x0F800000 -#define M360_MEMC_OR_16MB 0x0F000000 -#define M360_MEMC_OR_32MB 0x0E000000 -#define M360_MEMC_OR_64MB 0x0C000000 -#define M360_MEMC_OR_128MB 0x08000000 -#define M360_MEMC_OR_256MB 0x00000000 -#define M360_MEMC_OR_FCMC(x) ((x)<<7) /* Function code mask */ -#define M360_MEMC_OR_BCYC(x) ((x)<<5) /* Burst cycle length (clocks) */ -#define M360_MEMC_OR_PGME (1<<3) /* Page mode enable */ -#define M360_MEMC_OR_32BIT (0<<1) /* Port size */ -#define M360_MEMC_OR_16BIT (1<<1) -#define M360_MEMC_OR_8BIT (2<<1) -#define M360_MEMC_OR_DSACK (3<<1) -#define M360_MEMC_OR_DRAM (1<<0) /* Dynamic RAM select */ - -/* - ************************************************************************* - * SI Mode Register (SIMODE) * - ************************************************************************* - */ -#define M360_SI_SMC2_BITS 0xFFFF0000 /* All SMC2 bits */ -#define M360_SI_SMC2_TDM (1<<31) /* Multiplexed SMC2 */ -#define M360_SI_SMC2_BRG1 (0<<28) /* SMC2 clock souce */ -#define M360_SI_SMC2_BRG2 (1<<28) -#define M360_SI_SMC2_BRG3 (2<<28) -#define M360_SI_SMC2_BRG4 (3<<28) -#define M360_SI_SMC2_CLK5 (0<<28) -#define M360_SI_SMC2_CLK6 (1<<28) -#define M360_SI_SMC2_CLK7 (2<<28) -#define M360_SI_SMC2_CLK8 (3<<28) -#define M360_SI_SMC1_BITS 0x0000FFFF /* All SMC1 bits */ -#define M360_SI_SMC1_TDM (1<<15) /* Multiplexed SMC1 */ -#define M360_SI_SMC1_BRG1 (0<<12) /* SMC1 clock souce */ -#define M360_SI_SMC1_BRG2 (1<<12) -#define M360_SI_SMC1_BRG3 (2<<12) -#define M360_SI_SMC1_BRG4 (3<<12) -#define M360_SI_SMC1_CLK1 (0<<12) -#define M360_SI_SMC1_CLK2 (1<<12) -#define M360_SI_SMC1_CLK3 (2<<12) -#define M360_SI_SMC1_CLK4 (3<<12) - -/* - ************************************************************************* - * SDMA Configuration Register (SDMA) * - ************************************************************************* - */ -#define M360_SDMA_FREEZE (2<<13) /* Freeze on next bus cycle */ -#define M360_SDMA_SISM_7 (7<<8) /* Normal interrupt service mask */ -#define M360_SDMA_SAID_4 (4<<4) /* Normal arbitration ID */ -#define M360_SDMA_INTE (1<<1) /* SBER interrupt enable */ -#define M360_SDMA_INTB (1<<0) /* SBKP interrupt enable */ - -/* - ************************************************************************* - * Baud (sic) Rate Generators * - ************************************************************************* - */ -#define M360_BRG_RST (1<<17) /* Reset generator */ -#define M360_BRG_EN (1<<16) /* Enable generator */ -#define M360_BRG_EXTC_BRGCLK (0<<14) /* Source is BRGCLK */ -#define M360_BRG_EXTC_CLK2 (1<<14) /* Source is CLK2 pin */ -#define M360_BRG_EXTC_CLK6 (2<<14) /* Source is CLK6 pin */ -#define M360_BRG_ATB (1<<13) /* Autobaud */ -#define M360_BRG_115200 (13<<1) /* Assume 25 MHz clock */ -#define M360_BRG_57600 (26<<1) -#define M360_BRG_38400 (40<<1) -#define M360_BRG_19200 (80<<1) -#define M360_BRG_9600 (162<<1) -#define M360_BRG_4800 (324<<1) -#define M360_BRG_2400 (650<<1) -#define M360_BRG_1200 (1301<<1) -#define M360_BRG_600 (2603<<1) -#define M360_BRG_300 ((324<<1) | 1) -#define M360_BRG_150 ((650<<1) | 1) -#define M360_BRG_75 ((1301<<1) | 1) - -/* - ************************************************************************* - * MC68360 DUAL-PORT RAM AND REGISTERS * - ************************************************************************* - */ -typedef struct m360_ { - /* - * Dual-port RAM - */ - unsigned char dpram0[0x400]; /* Microcode program */ - unsigned char dpram1[0x200]; - unsigned char dpram2[0x100]; /* Microcode scratch */ - unsigned char dpram3[0x100]; /* Not on REV A or B masks */ - unsigned char _rsv0[0xC00-0x800]; - m360SCCENparms_t scc1p; - unsigned char _rsv1[0xCB0-0xC00-sizeof(m360SCCENparms_t)]; - m360MiscParms_t miscp; - unsigned char _rsv2[0xD00-0xCB0-sizeof(m360MiscParms_t)]; - m360SCCparms_t scc2p; - unsigned char _rsv3[0xD80-0xD00-sizeof(m360SCCparms_t)]; - m360SPIparms_t spip; - unsigned char _rsv4[0xDB0-0xD80-sizeof(m360SPIparms_t)]; - m360TimerParms_t tmp; - unsigned char _rsv5[0xE00-0xDB0-sizeof(m360TimerParms_t)]; - m360SCCparms_t scc3p; - unsigned char _rsv6[0xE70-0xE00-sizeof(m360SCCparms_t)]; - m360IDMAparms_t idma1p; - unsigned char _rsv7[0xE80-0xE70-sizeof(m360IDMAparms_t)]; - m360SMCparms_t smc1p; - unsigned char _rsv8[0xF00-0xE80-sizeof(m360SMCparms_t)]; - m360SCCparms_t scc4p; - unsigned char _rsv9[0xF70-0xF00-sizeof(m360SCCparms_t)]; - m360IDMAparms_t idma2p; - unsigned char _rsv10[0xF80-0xF70-sizeof(m360IDMAparms_t)]; - m360SMCparms_t smc2p; - unsigned char _rsv11[0x1000-0xF80-sizeof(m360SMCparms_t)]; - - /* - * SIM Block - */ - unsigned long mcr; - unsigned long _pad00; - unsigned char avr; - unsigned char rsr; - unsigned short _pad01; - unsigned char clkocr; - unsigned char _pad02; - unsigned short _pad03; - unsigned short pllcr; - unsigned short _pad04; - unsigned short cdvcr; - unsigned short pepar; - unsigned long _pad05[2]; - unsigned short _pad06; - unsigned char sypcr; - unsigned char swiv; - unsigned short _pad07; - unsigned short picr; - unsigned short _pad08; - unsigned short pitr; - unsigned short _pad09; - unsigned char _pad10; - unsigned char swsr; - unsigned long bkar; - unsigned long bcar; - unsigned long _pad11[2]; - - /* - * MEMC Block - */ - unsigned long gmr; - unsigned short mstat; - unsigned short _pad12; - unsigned long _pad13[2]; - m360MEMCRegisters_t memc[8]; - unsigned char _pad14[0xF0-0xD0]; - unsigned char _pad15[0x100-0xF0]; - unsigned char _pad16[0x500-0x100]; - - /* - * IDMA1 Block - */ - unsigned short iccr; - unsigned short _pad17; - unsigned short cmr1; - unsigned short _pad18; - unsigned long sapr1; - unsigned long dapr1; - unsigned long bcr1; - unsigned char fcr1; - unsigned char _pad19; - unsigned char cmar1; - unsigned char _pad20; - unsigned char csr1; - unsigned char _pad21; - unsigned short _pad22; - - /* - * SDMA Block - */ - unsigned char sdsr; - unsigned char _pad23; - unsigned short sdcr; - unsigned long sdar; - - /* - * IDMA2 Block - */ - unsigned short _pad24; - unsigned short cmr2; - unsigned long sapr2; - unsigned long dapr2; - unsigned long bcr2; - unsigned char fcr2; - unsigned char _pad26; - unsigned char cmar2; - unsigned char _pad27; - unsigned char csr2; - unsigned char _pad28; - unsigned short _pad29; - unsigned long _pad30; - - /* - * CPIC Block - */ - unsigned long cicr; - unsigned long cipr; - unsigned long cimr; - unsigned long cisr; - - /* - * Parallel I/O Block - */ - unsigned short padir; - unsigned short papar; - unsigned short paodr; - unsigned short padat; - unsigned long _pad31[2]; - unsigned short pcdir; - unsigned short pcpar; - unsigned short pcso; - unsigned short pcdat; - unsigned short pcint; - unsigned short _pad32; - unsigned long _pad33[5]; - - /* - * TIMER Block - */ - unsigned short tgcr; - unsigned short _pad34; - unsigned long _pad35[3]; - unsigned short tmr1; - unsigned short tmr2; - unsigned short trr1; - unsigned short trr2; - unsigned short tcr1; - unsigned short tcr2; - unsigned short tcn1; - unsigned short tcn2; - unsigned short tmr3; - unsigned short tmr4; - unsigned short trr3; - unsigned short trr4; - unsigned short tcr3; - unsigned short tcr4; - unsigned short tcn3; - unsigned short tcn4; - unsigned short ter1; - unsigned short ter2; - unsigned short ter3; - unsigned short ter4; - unsigned long _pad36[2]; - - /* - * CP Block - */ - unsigned short cr; - unsigned short _pad37; - unsigned short rccr; - unsigned short _pad38; - unsigned long _pad39[3]; - unsigned short _pad40; - unsigned short rter; - unsigned short _pad41; - unsigned short rtmr; - unsigned long _pad42[5]; - - /* - * BRG Block - */ - unsigned long brgc1; - unsigned long brgc2; - unsigned long brgc3; - unsigned long brgc4; - - /* - * SCC Block - */ - m360SCCRegisters_t scc1; - m360SCCRegisters_t scc2; - m360SCCRegisters_t scc3; - m360SCCRegisters_t scc4; - - /* - * SMC Block - */ - m360SMCRegisters_t smc1; - m360SMCRegisters_t smc2; - - /* - * SPI Block - */ - unsigned short spmode; - unsigned short _pad43[2]; - unsigned char spie; - unsigned char _pad44; - unsigned short _pad45; - unsigned char spim; - unsigned char _pad46[2]; - unsigned char spcom; - unsigned short _pad47[2]; - - /* - * PIP Block - */ - unsigned short pipc; - unsigned short _pad48; - unsigned short ptpr; - unsigned long pbdir; - unsigned long pbpar; - unsigned short _pad49; - unsigned short pbodr; - unsigned long pbdat; - unsigned long _pad50[6]; - - /* - * SI Block - */ - unsigned long simode; - unsigned char sigmr; - unsigned char _pad51; - unsigned char sistr; - unsigned char sicmr; - unsigned long _pad52; - unsigned long sicr; - unsigned short _pad53; - unsigned short sirp[2]; - unsigned short _pad54; - unsigned long _pad55[2]; - unsigned char siram[256]; -} m360_t; - -extern volatile m360_t m360; - -/* - * definitions for the port b SPI pin bits - */ -#define M360_PB_SPI_MISO_MSK (1<< 3) -#define M360_PB_SPI_MOSI_MSK (1<< 2) -#define M360_PB_SPI_CLK_MSK (1<< 1) - -#endif /* _RTEMS_M68K_M68360_H */ diff --git a/cpukit/score/cpu/m68k/rtems/m68k/qsm.h b/cpukit/score/cpu/m68k/rtems/m68k/qsm.h deleted file mode 100644 index 32dbc1d5f9..0000000000 --- a/cpukit/score/cpu/m68k/rtems/m68k/qsm.h +++ /dev/null @@ -1,204 +0,0 @@ -/** - * @file - * - * @brief Motorola M68K Queued Serial Module - * - * The QSM contains two serial interfaces: (a) the queued serial - * peripheral interface (QSPI) and the serial communication interface - * (SCI). The QSPI provides peripheral expansion and/or interprocessor - * communication through a full-duplex, synchronous, three-wire bus. A - * self contained RAM queue permits serial data transfers without CPU - * intervention and automatic continuous sampling. The SCI provides a - * standard non-return to zero mark/space format with wakeup functions - * to allow the CPU to run uninterrupted until woken - * - * For more information, refer to Motorola's "Modular Microcontroller - * Family Queued Serial Module Reference Manual" (Motorola document - * QSMRM/AD). - */ - -/* - * This file was created by John S. Gwynne to support Motorola's 68332 MCU. - * - * Redistribution and use in source and binary forms are permitted - * provided that the following conditions are met: - * 1. Redistribution of source code and documentation must retain - * the above authorship, this list of conditions and the - * following disclaimer. - * 2. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * This software is provided "AS IS" without warranty of any kind, - * either expressed or implied, including, but not limited to, the - * implied warranties of merchantability, title and fitness for a - * particular purpose. - * - *------------------------------------------------------------------ - */ - -#ifndef _RTEMS_M68K_QSM_H -#define _RTEMS_M68K_QSM_H - -/* SAM-- shift and mask */ -#undef SAM -#define SAM(a,b,c) ((a << b) & c) - - -/* QSM_CRB (QSM Control Register Block) base address of the QSM - control registers */ -#if SIM_MM == 0 -#define QSM_CRB 0x7ffc00 -#else -#undef SIM_MM -#define SIM_MM 1 -#define QSM_CRB 0xfffc00 -#endif - - -#define QSMCR (volatile unsigned short int * const)(0x00 + QSM_CRB) - /* QSM Configuration Register */ -#define STOP 0x8000 /* Stop Enable */ -#define FRZ 0x6000 /* Freeze Control */ -#define SUPV 0x0080 /* Supervisor/Unrestricted */ -#define IARB 0x000f /* Inerrupt Arbitration */ - - -#define QTEST (volatile unsigned short int * const)(0x02 + QSM_CRB) - /* QSM Test Register */ -/* Used only for factor testing */ - - -#define QILR (volatile unsigned char * const)(0x04 + QSM_CRB) - /* QSM Interrupt Level Register */ -#define ILQSPI 0x38 /* Interrupt Level for QSPI */ -#define ILSCI 0x07 /* Interrupt Level for SCI */ - - -#define QIVR (volatile unsigned char * const)(0x05 + QSM_CRB) - /* QSM Interrupt Vector Register */ -#define INTV 0xff /* Interrupt Vector Number */ - - -#define SCCR0 (volatile unsigned short int * const)(0x08 + QSM_CRB) - /* SCI Control Register 0 */ -#define SCBR 0x1fff /* SCI Baud Rate */ - - -#define SCCR1 (volatile unsigned short int * const)(0x0a + QSM_CRB) - /* SCI Control Register 1 */ -#define LOOPS 0x4000 /* Loop Mode */ -#define WOMS 0x2000 /* Wired-OR Mode for SCI Pins */ -#define ILT 0x1000 /* Idle-Line Detect Type */ -#define PT 0x0800 /* Parity Type */ -#define PE 0x0400 /* Parity Enable */ -#define M 0x0200 /* Mode Select */ -#define WAKE 0x0100 /* Wakeup by Address Mark */ -#define TIE 0x0080 /* Transmit Complete Interrupt Enable */ -#define TCIE 0x0040 /* Transmit Complete Interrupt Enable */ -#define RIE 0x0020 /* Receiver Interrupt Enable */ -#define ILIE 0x0010 /* Idle-Line Interrupt Enable */ -#define TE 0x0008 /* Transmitter Enable */ -#define RE 0x0004 /* Receiver Enable */ -#define RWU 0x0002 /* Receiver Wakeup */ -#define SBK 0x0001 /* Send Break */ - - -#define SCSR (volatile unsigned short int * const)(0x0c + QSM_CRB) - /* SCI Status Register */ -#define TDRE 0x0100 /* Transmit Data Register Empty */ -#define TC 0x0080 /* Transmit Complete */ -#define RDRF 0x0040 /* Receive Data Register Full */ -#define RAF 0x0020 /* Receiver Active */ -#define IDLE 0x0010 /* Idle-Line Detected */ -#define OR 0x0008 /* Overrun Error */ -#define NF 0x0004 /* Noise Error Flag */ -#define FE 0x0002 /* Framing Error */ -#define PF 0x0001 /* Parity Error */ - - -#define SCDR (volatile unsigned short int * const)(0x0e + QSM_CRB) - /* SCI Data Register */ - - -#define PORTQS (volatile unsigned char * const)(0x15 + QSM_CRB) - /* Port QS Data Register */ - -#define PQSPAR (volatile unsigned char * const)(0x16 + QSM_CRB) - /* PORT QS Pin Assignment Rgister */ -/* Any bit cleared (zero) defines the corresponding pin to be an I/O - pin. Any bit set defines the corresponding pin to be a QSPI - signal. */ -/* note: PQS2 is a digital I/O pin unless the SPI is enabled in which - case it becomes the SPI serial clock SCK. */ -/* note: PQS7 is a digital I/O pin unless the SCI transmitter is - enabled in which case it becomes the SCI serial output TxD. */ -#define QSMFun 0x0 -#define QSMDis 0x1 -/* - * PQSPAR Field | QSM Function | Discrete I/O pin - *------------------+--------------+------------------ */ -#define PQSPA0 0 /* MISO | PQS0 */ -#define PQSPA1 1 /* MOSI | PQS1 */ -#define PQSPA2 2 /* SCK | PQS2 (see note)*/ -#define PQSPA3 3 /* PCSO/!SS | PQS3 */ -#define PQSPA4 4 /* PCS1 | PQS4 */ -#define PQSPA5 5 /* PCS2 | PQS5 */ -#define PQSPA6 6 /* PCS3 | PQS6 */ -#define PQSPA7 7 /* TxD | PQS7 (see note)*/ - - -#define DDRQS (volatile unsigned char * const)(0x17 + QSM_CRB) - /* PORT QS Data Direction Register */ -/* Clearing a bit makes the corresponding pin an input; setting a bit - makes the pin an output. */ - - -#define SPCR0 (volatile unsigned short int * const)(0x18 + QSM_CRB) - /* QSPI Control Register 0 */ -#define MSTR 0x8000 /* Master/Slave Mode Select */ -#define WOMQ 0x4000 /* Wired-OR Mode for QSPI Pins */ -#define BITS 0x3c00 /* Bits Per Transfer */ -#define CPOL 0x0200 /* Clock Polarity */ -#define CPHA 0x0100 /* Clock Phase */ -#define SPBR 0x00ff /* Serial Clock Baud Rate */ - - -#define SPCR1 (volatile unsigned short int * const)(0x1a + QSM_CRB) - /* QSPI Control Register 1 */ -#define SPE 0x8000 /* QSPI Enable */ -#define DSCKL 0x7f00 /* Delay before SCK */ -#define DTL 0x00ff /* Length of Delay after Transfer */ - - -#define SPCR2 (volatile unsigned short int * const)(0x1c + QSM_CRB) - /* QSPI Control Register 2 */ -#define SPIFIE 0x8000 /* SPI Finished Interrupt Enable */ -#define WREN 0x4000 /* Wrap Enable */ -#define WRTO 0x2000 /* Wrap To */ -#define ENDQP 0x0f00 /* Ending Queue Pointer */ -#define NEWQP 0x000f /* New Queue Pointer Value */ - - -#define SPCR3 (volatile unsigned char * const)(0x1e + QSM_CRB) - /* QSPI Control Register 3 */ -#define LOOPQ 0x0400 /* QSPI Loop Mode */ -#define HMIE 0x0200 /* HALTA and MODF Interrupt Enable */ -#define HALT 0x0100 /* Halt */ - - -#define SPSR (volatile unsigned char * const)(0x1f + QSM_CRB) - /* QSPI Status Register */ -#define SPIF 0x0080 /* QSPI Finished Flag */ -#define MODF 0x0040 /* Mode Fault Flag */ -#define HALTA 0x0020 /* Halt Acknowlwdge Flag */ -#define CPTQP x0000f /* Completed Queue Pointer */ - -#define QSPIRR (volatile unsigned char * const)(0x100 + QSM_CRB) - /* QSPI Receive Data RAM */ -#define QSPITR (volatile unsigned char * const)(0x120 + QSM_CRB) - /* QSPI Transmit Data RAM */ -#define QSPIcR (volatile unsigned char * const)(0x140 + QSM_CRB) - /* QSPI Command RAM */ - -#endif /* _RTEMS_M68K_QSM_H */ diff --git a/cpukit/score/cpu/m68k/rtems/m68k/sim.h b/cpukit/score/cpu/m68k/rtems/m68k/sim.h deleted file mode 100644 index cec6b84cc1..0000000000 --- a/cpukit/score/cpu/m68k/rtems/m68k/sim.h +++ /dev/null @@ -1,333 +0,0 @@ -/** - * @file - * - * @brief Motorola M68K System Integration Module - * - * The system integration module (SIM) is used on many Motorola 16- - * and 32-bit MCUs for the following functions: - * - * () System configuration and protection. Bus and software watchdog - * monitors are provided in addition to periodic interrupt generators. - * - * () Clock signal generation for other intermodule bus (IMB) members - * and external devices. - * - * () The generation of chip-select signals that simplify external - * circuitry interface. - * - * () Data ports that are available for general purpose input and - * output. - * - * () A system test block that is intended only for factory tests. - * - * For more information, refer to Motorola's "Modular Microcontroller - * Family System Integration Module Reference Manual" (Motorola document - * SIMRM/AD). - */ - -/* - * This file was created by John S. Gwynne to support Motorola's 68332 MCU. - * - * Redistribution and use in source and binary forms are permitted - * provided that the following conditions are met: - * 1. Redistribution of source code and documentation must retain - * the above authorship, this list of conditions and the - * following disclaimer. - * 2. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * This software is provided "AS IS" without warranty of any kind, - * either expressed or implied, including, but not limited to, the - * implied warranties of merchantability, title and fitness for a - * particular purpose. - * - *------------------------------------------------------------------ - */ - -#ifndef _RTEMS_M68K_SIM_H -#define _RTEMS_M68K_SIM_H - - -/* SAM-- shift and mask */ -#undef SAM -#define SAM(a,b,c) ((a << b) & c) - -/* - * These macros make this file usable from assembly. - */ - -#ifdef ASM -#define SIM_VOLATILE_USHORT_POINTER -#define SIM_VOLATILE_UCHAR_POINTER -#else -#define SIM_VOLATILE_USHORT_POINTER (volatile unsigned short int * const) -#define SIM_VOLATILE_UCHAR_POINTER (volatile unsigned char * const) -#endif - -/* SIM_CRB (SIM Control Register Block) base address of the SIM - control registers */ -#ifndef SIM_CRB -#if SIM_MM == 0 -#define SIM_CRB 0x7ffa00 -#else /* SIM_MM */ -#undef SIM_MM -#define SIM_MM 1 -#define SIM_CRB 0xfffa00 -#endif /* SIM_MM */ -#endif /* SIM_CRB */ - - -#define SIMCR SIM_VOLATILE_USHORT_POINTER(0x00 + SIM_CRB) - /* Module Configuration Register */ -#define EXOFF 0x8000 /* External Clock Off */ -#define FRZSW 0x4000 /* Freeze Software Enable */ -#define FRZBM 0x2000 /* Freeze Bus Monitor Enable */ -#define SLVEN 0x0800 /* Factory Test Model Enabled (ro)*/ -#define SHEN 0x0300 /* Show Cycle Enable */ -#define SUPV 0x0080 /* Supervisor/Unrestricted Data Space */ -#define MM 0x0040 /* Module Mapping */ -#define IARB 0x000f /* Interrupt Arbitration Field */ - - - -#define SIMTR SIM_VOLATILE_USHORT_POINTER(0x02 + SIM_CRB) - /* SIM Test Register */ -/* Used only for factor testing */ - - - -#define SYNCR SIM_VOLATILE_USHORT_POINTER(0x04 + SIM_CRB) - /* Clock Synthesizer Control Register */ -#define VCO 0x8000 /* Frequency Control (VCO) */ -#define PRESCALE 0x4000 /* Frequency Control Bit (Prescale) */ -#define COUNTER 0x3f00 /* Frequency Control Counter */ -#define EDIV 0x0080 /* ECLK Divide Rate */ -#define SLIMP 0x0010 /* Limp Mode Status */ -#define SLOCK 0x0008 /* Synthesizer Lock */ -#define RSTEN 0x0004 /* Reset Enable */ -#define STSIM 0x0002 /* Stop Mode SIM Clock */ -#define STEXT 0x0001 /* Stop Mode External Clock */ - - - -#define RSR SIM_VOLATILE_UCHAR_POINTER(0x07 + SIM_CRB) - /* Reset Status Register */ -#define EXT 0x0080 /* External Reset */ -#define POW 0x0040 /* Power-On Reset */ -#define SW 0x0020 /* Software Watchdog Reset */ -#define DBF 0x0010 /* Double Bus Fault Reset */ -#define LOC 0x0004 /* Loss of Clock Reset */ -#define SYS 0x0002 /* System Reset */ -#define TST 0x0001 /* Test Submodule Reset */ - - - -#define SIMTRE SIM_VOLATILE_USHORT_POINTER(0x08 + SIM_CRB) - /* System Integration Test Register */ -/* Used only for factor testing */ - - - -#define PORTE0 SIM_VOLATILE_UCHAR_POINTER(0x11 + SIM_CRB) -#define PORTE1 SIM_VOLATILE_UCHAR_POINTER(0x13 + SIM_CRB) - /* Port E Data Register */ -#define DDRE SIM_VOLATILE_UCHAR_POINTER(0x15 + SIM_CRB) - /* Port E Data Direction Register */ -#define PEPAR SIM_VOLATILE_UCHAR_POINTER(0x17 + SIM_CRB) - /* Port E Pin Assignment Register */ -/* Any bit cleared (zero) defines the corresponding pin to be an I/O - pin. Any bit set defines the corresponding pin to be a bus control - signal. */ - - - -#define PORTF0 SIM_VOLATILE_UCHAR_POINTER(0x19 + SIM_CRB) -#define PORTF1 SIM_VOLATILE_UCHAR_POINTER(0x1b + SIM_CRB) - /* Port F Data Register */ -#define DDRF SIM_VOLATILE_UCHAR_POINTER(0x1d + SIM_CRB) - /* Port E Data Direction Register */ -#define PFPAR SIM_VOLATILE_UCHAR_POINTER(0x1f + SIM_CRB) -/* Any bit cleared (zero) defines the corresponding pin to be an I/O - pin. Any bit set defines the corresponding pin to be a bus control - signal. */ - - - -#define SYPCR SIM_VOLATILE_UCHAR_POINTER(0x21 + SIM_CRB) -/* !!! can write to only once after reset !!! */ - /* System Protection Control Register */ -#define SWE 0x80 /* Software Watch Enable */ -#define SWP 0x40 /* Software Watchdog Prescale */ -#define SWT 0x30 /* Software Watchdog Timing */ -#define HME 0x08 /* Halt Monitor Enable */ -#define BME 0x04 /* Bus Monitor External Enable */ -#define BMT 0x03 /* Bus Monitor Timing */ - - - -#define PICR SIM_VOLATILE_USHORT_POINTER(0x22 + SIM_CRB) - /* Periodic Interrupt Control Reg. */ -#define PIRQL 0x0700 /* Periodic Interrupt Request Level */ -#define PIV 0x00ff /* Periodic Interrupt Level */ - - - -#define PITR SIM_VOLATILE_USHORT_POINTER(0x24 + SIM_CRB) - /* Periodic Interrupt Timer Register */ -#define PTP 0x0100 /* Periodic Timer Prescaler Control */ -#define PITM 0x00ff /* Periodic Interrupt Timing Modulus */ - - - -#define SWSR SIM_VOLATILE_UCHAR_POINTER(0x27 + SIM_CRB) - /* Software Service Register */ -/* write 0x55 then 0xaa to service the software watchdog */ - - - -#define TSTMSRA SIM_VOLATILE_USHORT_POINTER(0x30 + SIM_CRB) - /* Test Module Master Shift A */ -#define TSTMSRB SIM_VOLATILE_USHORT_POINTER(0x32 + SIM_CRB) - /* Test Module Master Shift A */ -#define TSTSC SIM_VOLATILE_USHORT_POINTER(0x34 + SIM_CRB) - /* Test Module Shift Count */ -#define TSTRC SIM_VOLATILE_USHORT_POINTER(0x36 + SIM_CRB) - /* Test Module Repetition Counter */ -#define CREG SIM_VOLATILE_USHORT_POINTER(0x38 + SIM_CRB) - /* Test Module Control */ -#define DREG SIM_VOLATILE_USHORT_POINTER(0x3a + SIM_CRB) - /* Test Module Distributed */ -/* Used only for factor testing */ - - - -#define PORTC SIM_VOLATILE_UCHAR_POINTER(0x41 + SIM_CRB) - /* Port C Data */ - - - -#define CSPAR0 SIM_VOLATILE_USHORT_POINTER(0x44 + SIM_CRB) - /* Chip Select Pin Assignment - Resgister 0 */ -/* CSPAR0 contains seven two-bit fields that determine the functions - of corresponding chip-select pins. CSPAR0[15:14] are not - used. These bits always read zero; write have no effect. CSPAR0 bit - 1 always reads one; writes to CSPAR0 bit 1 have no effect. */ -#define CSPAR1 SIM_VOLATILE_USHORT_POINTER(0x46 + SIM_CRB) - /* Chip Select Pin Assignment - Register 1 */ -/* CSPAR1 contains five two-bit fields that determine the finctions of - corresponding chip-select pins. CSPAR1[15:10] are not used. These - bits always read zero; writes have no effect. */ -/* - * - * Bit Field | Description - * ------------+--------------- - * 00 | Discrete Output - * 01 | Alternate Function - * 10 | Chip Select (8-bit port) - * 11 | Chip Select (16-bit port) - */ -#define DisOut 0x0 -#define AltFun 0x1 -#define CS8bit 0x2 -#define CS16bit 0x3 -/* - * - * CSPARx Field |Chip Select Signal | Alternate Signal | Discrete Output - *-----------------+--------------------+--------------------+---------------*/ -#define CS_5 12 /* !CS5 | FC2 | PC2 */ -#define CS_4 10 /* !CS4 | FC1 | PC1 */ -#define CS_3 8 /* !CS3 | FC0 | PC0 */ -#define CS_2 6 /* !CS2 | !BGACK | */ -#define CS_1 4 /* !CS1 | !BG | */ -#define CS_0 2 /* !CS0 | !BR | */ -#define CSBOOT 0 /* !CSBOOT | | */ -/* | | | */ -#define CS_10 8 /* !CS10 | ADDR23 | ECLK */ -#define CS_9 6 /* !CS9 | ADDR22 | PC6 */ -#define CS_8 4 /* !CS8 | ADDR21 | PC5 */ -#define CS_7 2 /* !CS7 | ADDR20 | PC4 */ -#define CS_6 0 /* !CS6 | ADDR19 | PC3 */ - -#define BS_2K 0x0 -#define BS_8K 0x1 -#define BS_16K 0x2 -#define BS_64K 0x3 -#define BS_128K 0x4 -#define BS_256K 0x5 -#define BS_512K 0x6 -#define BS_1M 0x7 - -#define CSBARBT SIM_VOLATILE_USHORT_POINTER(0x48 + SIM_CRB) -#define CSBAR0 SIM_VOLATILE_USHORT_POINTER(0x4c + SIM_CRB) -#define CSBAR1 SIM_VOLATILE_USHORT_POINTER(0x50 + SIM_CRB) -#define CSBAR2 SIM_VOLATILE_USHORT_POINTER(0x54 + SIM_CRB) -#define CSBAR3 SIM_VOLATILE_USHORT_POINTER(0x58 + SIM_CRB) -#define CSBAR4 SIM_VOLATILE_USHORT_POINTER(0x5c + SIM_CRB) -#define CSBAR5 SIM_VOLATILE_USHORT_POINTER(0x60 + SIM_CRB) -#define CSBAR6 SIM_VOLATILE_USHORT_POINTER(0x64 + SIM_CRB) -#define CSBAR7 SIM_VOLATILE_USHORT_POINTER(0x68 + SIM_CRB) -#define CSBAR8 SIM_VOLATILE_USHORT_POINTER(0x6c + SIM_CRB) -#define CSBAR9 SIM_VOLATILE_USHORT_POINTER(0x70 + SIM_CRB) -#define CSBAR10 SIM_VOLATILE_USHORT_POINTER(0x74 + SIM_CRB) - -#define MODE 0x8000 -#define Disable 0 -#define LowerByte 0x2000 -#define UpperByte 0x4000 -#define BothBytes 0x6000 -#define ReadOnly 0x0800 -#define WriteOnly 0x1000 -#define ReadWrite 0x1800 -#define SyncAS 0x0 -#define SyncDS 0x0400 - -#define WaitStates_0 (0x0 << 6) -#define WaitStates_1 (0x1 << 6) -#define WaitStates_2 (0x2 << 6) -#define WaitStates_3 (0x3 << 6) -#define WaitStates_4 (0x4 << 6) -#define WaitStates_5 (0x5 << 6) -#define WaitStates_6 (0x6 << 6) -#define WaitStates_7 (0x7 << 6) -#define WaitStates_8 (0x8 << 6) -#define WaitStates_9 (0x9 << 6) -#define WaitStates_10 (0xa << 6) -#define WaitStates_11 (0xb << 6) -#define WaitStates_12 (0xc << 6) -#define WaitStates_13 (0xd << 6) -#define FastTerm (0xe << 6) -#define External (0xf << 6) - -#define CPUSpace (0x0 << 4) -#define UserSpace (0x1 << 4) -#define SupSpace (0x2 << 4) -#define UserSupSpace (0x3 << 4) - -#define IPLevel_any 0x0 -#define IPLevel_1 0x2 -#define IPLevel_2 0x4 -#define IPLevel_3 0x6 -#define IPLevel_4 0x8 -#define IPLevel_5 0xa -#define IPLevel_6 0xc -#define IPLevel_7 0xe - -#define AVEC 1 - -#define CSORBT SIM_VOLATILE_USHORT_POINTER(0x4a + SIM_CRB) -#define CSOR0 SIM_VOLATILE_USHORT_POINTER(0x4e + SIM_CRB) -#define CSOR1 SIM_VOLATILE_USHORT_POINTER(0x52 + SIM_CRB) -#define CSOR2 SIM_VOLATILE_USHORT_POINTER(0x56 + SIM_CRB) -#define CSOR3 SIM_VOLATILE_USHORT_POINTER(0x5a + SIM_CRB) -#define CSOR4 SIM_VOLATILE_USHORT_POINTER(0x5e + SIM_CRB) -#define CSOR5 SIM_VOLATILE_USHORT_POINTER(0x62 + SIM_CRB) -#define CSOR6 SIM_VOLATILE_USHORT_POINTER(0x66 + SIM_CRB) -#define CSOR7 SIM_VOLATILE_USHORT_POINTER(0x6a + SIM_CRB) -#define CSOR8 SIM_VOLATILE_USHORT_POINTER(0x6e + SIM_CRB) -#define CSOR9 SIM_VOLATILE_USHORT_POINTER(0x72 + SIM_CRB) -#define CSOR10 SIM_VOLATILE_USHORT_POINTER(0x76 + SIM_CRB) - -#endif /* _RTEMS_M68K_SIM_H */ diff --git a/cpukit/score/cpu/m68k/rtems/score/cpu.h b/cpukit/score/cpu/m68k/rtems/score/cpu.h deleted file mode 100644 index 2be10c9638..0000000000 --- a/cpukit/score/cpu/m68k/rtems/score/cpu.h +++ /dev/null @@ -1,735 +0,0 @@ -/** - * @file - * - * @brief Motorola M68K CPU Dependent Source - * - * This include file contains information pertaining to the Motorola - * m68xxx processor family. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPU_H -#define _RTEMS_SCORE_CPU_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/* conditional compilation parameters */ - -/* - * Does the CPU follow the simple vectored interrupt model? - * - * If TRUE, then RTEMS allocates the vector table it internally manages. - * If FALSE, then the BSP is assumed to allocate and manage the vector - * table - * - * M68K Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_SIMPLE_VECTORED_INTERRUPTS TRUE - -/* - * Use the m68k's hardware interrupt stack support and have the - * interrupt manager allocate the memory for it. - */ - -#if ( M68K_HAS_SEPARATE_STACKS == 1) -#define CPU_HAS_SOFTWARE_INTERRUPT_STACK 0 -#define CPU_HAS_HARDWARE_INTERRUPT_STACK 1 -#else -#define CPU_HAS_SOFTWARE_INTERRUPT_STACK 1 -#define CPU_HAS_HARDWARE_INTERRUPT_STACK 0 -#endif -#define CPU_ALLOCATE_INTERRUPT_STACK 1 - -/* - * Does the RTEMS invoke the user's ISR with the vector number and - * a pointer to the saved interrupt frame (1) or just the vector - * number (0)? - */ - -#define CPU_ISR_PASSES_FRAME_POINTER FALSE - -/* - * Some family members have no FP, some have an FPU such as the - * MC68881/MC68882 for the MC68020, others have it built in (MC68030, 040). - * - * NOTE: If on a CPU without hardware FP, then one can use software - * emulation. The gcc software FP emulation code has data which - * must be contexted switched on a per task basis. - */ - -#if ( M68K_HAS_FPU == 1 ) || ( M68K_HAS_EMAC == 1 ) - #define CPU_HARDWARE_FP TRUE - #define CPU_SOFTWARE_FP FALSE -#else - #define CPU_HARDWARE_FP FALSE - #if defined( __GNUC__ ) - #define CPU_SOFTWARE_FP TRUE - #else - #define CPU_SOFTWARE_FP FALSE - #endif -#endif - -/* - * All tasks are not by default floating point tasks on this CPU. - * The IDLE task does not have a floating point context on this CPU. - * It is safe to use the deferred floating point context switch - * algorithm on this CPU. - */ - -#define CPU_ALL_TASKS_ARE_FP FALSE -#define CPU_IDLE_TASK_IS_FP FALSE -#define CPU_USE_DEFERRED_FP_SWITCH TRUE -#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE - -#define CPU_PROVIDES_IDLE_THREAD_BODY TRUE -#define CPU_STACK_GROWS_UP FALSE - -/* FIXME: Is this the right value? */ -#define CPU_CACHE_LINE_BYTES 16 - -#define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES ) - -#define CPU_MAXIMUM_PROCESSORS 32 - -#if ( CPU_HARDWARE_FP == TRUE ) && !defined( __mcoldfire__ ) - #if defined( __mc68060__ ) - #define M68K_FP_STATE_SIZE 16 - #else - #define M68K_FP_STATE_SIZE 216 - #endif -#endif - -#ifndef ASM - -/* structures */ - -/* - * Basic integer context for the m68k family. - */ - -typedef struct { - uint32_t sr; /* (sr) status register */ - uint32_t d2; /* (d2) data register 2 */ - uint32_t d3; /* (d3) data register 3 */ - uint32_t d4; /* (d4) data register 4 */ - uint32_t d5; /* (d5) data register 5 */ - uint32_t d6; /* (d6) data register 6 */ - uint32_t d7; /* (d7) data register 7 */ - void *a2; /* (a2) address register 2 */ - void *a3; /* (a3) address register 3 */ - void *a4; /* (a4) address register 4 */ - void *a5; /* (a5) address register 5 */ - void *a6; /* (a6) address register 6 */ - void *a7_msp; /* (a7) master stack pointer */ - #if defined( __mcoldfire__ ) && ( M68K_HAS_FPU == 1 ) - uint8_t fpu_dis; - #endif -} Context_Control; - -#define _CPU_Context_Get_SP( _context ) \ - (_context)->a7_msp - -/* - * Floating point context areas and support routines - */ - -#if ( CPU_SOFTWARE_FP == TRUE ) - /* - * This is the same as gcc's view of the software FP condition code - * register _fpCCR. The implementation of the emulation code is - * in the gcc-VERSION/config/m68k directory. This structure is - * correct as of gcc 2.7.2.2. - */ - typedef struct { - uint16_t _exception_bits; - uint16_t _trap_enable_bits; - uint16_t _sticky_bits; - uint16_t _rounding_mode; - uint16_t _format; - uint16_t _last_operation; - union { - float sf; - double df; - } _operand1; - union { - float sf; - double df; - } _operand2; - } Context_Control_fp; - - #define _CPU_Context_Initialize_fp( _fp_area ) \ - { \ - Context_Control_fp *_fp; \ - _fp = *(Context_Control_fp **)_fp_area; \ - _fp->_exception_bits = 0; \ - _fp->_trap_enable_bits = 0; \ - _fp->_sticky_bits = 0; \ - _fp->_rounding_mode = 0; /* ROUND_TO_NEAREST */ \ - _fp->_format = 0; /* NIL */ \ - _fp->_last_operation = 0; /* NOOP */ \ - _fp->_operand1.df = 0; \ - _fp->_operand2.df = 0; \ - } -#endif - -#if ( CPU_HARDWARE_FP == TRUE ) - #if defined( __mcoldfire__ ) - /* We need memset() to initialize the FP context */ - #include - - #if ( M68K_HAS_FPU == 1 ) - /* - * The Cache Control Register (CACR) has write-only access. It is also - * used to enable and disable the FPU. We need to maintain a copy of - * this register to allow per thread values. - */ - extern uint32_t _CPU_cacr_shadow; - #endif - - /* We assume that each ColdFire core with a FPU has also an EMAC unit */ - typedef struct { - uint32_t emac_macsr; - uint32_t emac_acc0; - uint32_t emac_acc1; - uint32_t emac_acc2; - uint32_t emac_acc3; - uint32_t emac_accext01; - uint32_t emac_accext23; - uint32_t emac_mask; - #if ( M68K_HAS_FPU == 1 ) - uint16_t fp_state_format; - uint16_t fp_state_fpcr; - double fp_state_op; - uint32_t fp_state_fpsr; - - /* - * We need to save the FP Instruction Address Register (FPIAR), because - * a context switch can occur within a FP exception before the handler - * was able to save this register. - */ - uint32_t fp_fpiar; - - double fp_data [8]; - #endif - } Context_Control_fp; - - /* - * The reset value for all context relevant registers except the FP data - * registers is zero. The reset value of the FP data register is NAN. The - * restore of the reset FP state will reset the FP data registers, so the - * initial value of them can be arbitrary here. - */ - #define _CPU_Context_Initialize_fp( _fp_area ) \ - memset( *(_fp_area), 0, sizeof( Context_Control_fp ) ) - #else - /* - * FP context save area for the M68881/M68882 and 68060 numeric - * coprocessors. - */ - typedef struct { - /* - * M68K_FP_STATE_SIZE bytes for FSAVE/FRESTORE - * 96 bytes for FMOVEM FP0-7 - * 12 bytes for FMOVEM CREGS - * 4 bytes for non-null flag - */ - uint8_t fp_save_area [M68K_FP_STATE_SIZE + 112]; - } Context_Control_fp; - - /* - * The floating-point context is saved/restored via FSAVE/FRESTORE which - * use a growing down stack. Initialize the stack and adjust the FP area - * pointer accordingly. - */ - #define _CPU_Context_Initialize_fp( _fp_area ) \ - { \ - uint32_t *_fp_context = _Addresses_Add_offset( \ - *(_fp_area), CPU_CONTEXT_FP_SIZE - 4); \ - *(--(_fp_context)) = 0; \ - *(_fp_area) = (void *)(_fp_context); \ - } - #endif -#endif - -/* - * The following structures define the set of information saved - * on the current stack by RTEMS upon receipt of each exc/interrupt. - * These are not used by m68k handlers. - * The exception frame is for rdbg. - */ - -typedef struct { - uint32_t vecnum; /* vector number */ -} CPU_Interrupt_frame; - -typedef struct { - uint32_t vecnum; /* vector number */ - uint32_t sr; /* status register */ - uint32_t pc; /* program counter */ - uint32_t d0, d1, d2, d3, d4, d5, d6, d7; - uint32_t a0, a1, a2, a3, a4, a5, a6, a7; -} CPU_Exception_frame; - -/* variables */ - -extern void* _VBR; - -#endif /* ASM */ - -/* constants */ - -/* - * This defines the number of levels and the mask used to pick those - * bits out of a thread mode. - */ - -#define CPU_MODES_INTERRUPT_LEVEL 0x00000007 /* interrupt level in mode */ -#define CPU_MODES_INTERRUPT_MASK 0x00000007 /* interrupt level in mode */ - -/* - * context size area for floating point - */ - -#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp ) - -/* - * extra stack required by the MPCI receive server thread - */ - -#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 1024 - -/* - * m68k family supports 256 distinct vectors. - */ - -#define CPU_INTERRUPT_NUMBER_OF_VECTORS 256 -#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER (CPU_INTERRUPT_NUMBER_OF_VECTORS - 1) - -/* - * This is defined if the port has a special way to report the ISR nesting - * level. Most ports maintain the variable _ISR_Nest_level. - */ - -#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE - -/* - * Minimum size of a thread's stack. - */ - -#define CPU_STACK_MINIMUM_SIZE M68K_CPU_STACK_MINIMUM_SIZE - -/* - * Maximum priority of a thread. Note based from 0 which is the idle task. - */ -#define CPU_PRIORITY_MAXIMUM M68K_CPU_PRIORITY_MAXIMUM - -#define CPU_SIZEOF_POINTER 4 - -/* - * m68k is pretty tolerant of alignment. Just put things on 4 byte boundaries. - */ - -#define CPU_ALIGNMENT 4 -#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT -#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT - -/* - * On m68k thread stacks require no further alignment after allocation - * from the Workspace. - */ - -#define CPU_STACK_ALIGNMENT 0 - -#ifndef ASM - -/* macros */ - -/* - * ISR handler macros - * - * These macros perform the following functions: - * + initialize the RTEMS vector table - * + disable all maskable CPU interrupts - * + restore previous interrupt level (enable) - * + temporarily restore interrupts (flash) - * + set a particular level - */ - -#define _CPU_Initialize_vectors() - -#define _CPU_ISR_Disable( _level ) \ - m68k_disable_interrupts( _level ) - -#define _CPU_ISR_Enable( _level ) \ - m68k_enable_interrupts( _level ) - -#define _CPU_ISR_Flash( _level ) \ - m68k_flash_interrupts( _level ) - -RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) -{ - return ( level & 0x0700 ) == 0; -} - -#define _CPU_ISR_Set_level( _newlevel ) \ - m68k_set_interrupt_level( _newlevel ) - -uint32_t _CPU_ISR_Get_level( void ); - -/* end of ISR handler macros */ - -/* - * Context handler macros - * - * These macros perform the following functions: - * + initialize a context area - * + restart the current thread - * + calculate the initial pointer into a FP context area - * + initialize an FP context area - */ - -void _CPU_Context_Initialize( - Context_Control *the_context, - void *stack_area_begin, - size_t stack_area_size, - uint32_t new_level, - void (*entry_point)( void ), - bool is_fp, - void *tls_area -); - -/* end of Context handler macros */ - -/* - * _CPU_Thread_Idle_body - * - * This routine is the CPU dependent IDLE thread body. - * - * NOTE: It need only be provided if CPU_PROVIDES_IDLE_THREAD_BODY - * is TRUE. - */ - -void *_CPU_Thread_Idle_body( uintptr_t ignored ); - -/* - * Fatal Error manager macros - * - * These macros perform the following functions: - * + disable interrupts and halt the CPU - */ - -#if ( defined(__mcoldfire__) ) -#define _CPU_Fatal_halt( _source, _error ) \ - { __asm__ volatile( "move.w %%sr,%%d0\n\t" \ - "or.l %2,%%d0\n\t" \ - "move.w %%d0,%%sr\n\t" \ - "move.l %1,%%d0\n\t" \ - "move.l #0xDEADBEEF,%%d1\n\t" \ - "halt" \ - : "=g" (_error) \ - : "0" (_error), "d"(0x0700) \ - : "d0", "d1" ); \ - } -#else -#define _CPU_Fatal_halt( _source, _error ) \ - { __asm__ volatile( "movl %0,%%d0; " \ - "orw #0x0700,%%sr; " \ - "stop #0x2700" : "=d" ((_error)) : "0" ((_error)) ); \ - } -#endif - -/* end of Fatal Error manager macros */ - -/* - * Bitfield handler macros - * - * These macros perform the following functions: - * + scan for the highest numbered (MSB) set in a 16 bit bitfield - * - * NOTE: - * - * It appears that on the M68020 bitfield are always 32 bits wide - * when in a register. This code forces the bitfield to be in - * memory (it really always is anyway). This allows us to - * have a real 16 bit wide bitfield which operates "correctly." - */ - -#define CPU_USE_GENERIC_BITFIELD_CODE FALSE - -#if ( M68K_HAS_BFFFO != 1 ) -/* - * Lookup table for BFFFO simulation - */ -extern const unsigned char _CPU_m68k_BFFFO_table[256]; -#endif - -#if ( M68K_HAS_BFFFO == 1 ) - -#define _CPU_Bitfield_Find_first_bit( _value, _output ) \ - __asm__ volatile( "bfffo (%1),#0,#16,%0" : "=d" (_output) : "a" (&_value)); - -#elif ( __mcfisaaplus__ ) - /* This is simplified by the fact that RTEMS never calls it with _value=0 */ -#define _CPU_Bitfield_Find_first_bit( _value, _output ) \ - __asm__ volatile ( \ - " swap %0\n" \ - " ff1.l %0\n" \ - : "=d" ((_output)) \ - : "0" ((_value)) \ - : "cc" ) ; - -#else -/* duplicates BFFFO results for 16 bits (i.e., 15-(_priority) in - _CPU_Priority_bits_index is not needed), handles the 0 case, and - does not molest _value -- jsg */ -#if ( defined(__mcoldfire__) ) - -#define _CPU_Bitfield_Find_first_bit( _value, _output ) \ - { \ - register int dumby; \ - \ - __asm__ volatile ( \ - " clr.l %1\n" \ - " move.w %2,%1\n" \ - " lsr.l #8,%1\n" \ - " beq.s 1f\n" \ - " move.b (%3,%1),%0\n" \ - " bra.s 0f\n" \ - "1: move.w %2,%1\n" \ - " move.b (%3,%1),%0\n" \ - " addq.l #8,%0\n" \ - "0: and.l #0xff,%0\n" \ - : "=&d" ((_output)), "=&d" ((dumby)) \ - : "d" ((_value)), "ao" ((_CPU_m68k_BFFFO_table)) \ - : "cc" ) ; \ - } -#elif ( M68K_HAS_EXTB_L == 1 ) -#define _CPU_Bitfield_Find_first_bit( _value, _output ) \ - { \ - register int dumby; \ - \ - __asm__ volatile ( " move.w %2,%1\n" \ - " lsr.w #8,%1\n" \ - " beq.s 1f\n" \ - " move.b (%3,%1.w),%0\n" \ - " extb.l %0\n" \ - " bra.s 0f\n" \ - "1: moveq.l #8,%0\n" \ - " add.b (%3,%2.w),%0\n" \ - "0:\n" \ - : "=&d" ((_output)), "=&d" ((dumby)) \ - : "d" ((_value)), "ao" ((_CPU_m68k_BFFFO_table)) \ - : "cc" ) ; \ - } -#else -#define _CPU_Bitfield_Find_first_bit( _value, _output ) \ - { \ - register int dumby; \ - \ - __asm__ volatile ( " move.w %2,%1\n" \ - " lsr.w #8,%1\n" \ - " beq.s 1f\n" \ - " move.b (%3,%1.w),%0\n" \ - " and.l #0x000000ff,%0\n"\ - " bra.s 0f\n" \ - "1: moveq.l #8,%0\n" \ - " add.b (%3,%2.w),%0\n" \ - "0:\n" \ - : "=&d" ((_output)), "=&d" ((dumby)) \ - : "d" ((_value)), "ao" ((_CPU_m68k_BFFFO_table)) \ - : "cc" ) ; \ - } -#endif - -#endif - -/* end of Bitfield handler macros */ - -/* - * Priority handler macros - * - * These macros perform the following functions: - * + return a mask with the bit for this major/minor portion of - * of thread priority set. - * + translate the bit number returned by "Bitfield_find_first_bit" - * into an index into the thread ready chain bit maps - */ - -#define _CPU_Priority_Mask( _bit_number ) \ - ( 0x8000 >> (_bit_number) ) - -#define _CPU_Priority_bits_index( _priority ) \ - (_priority) - -/* end of Priority handler macros */ - -/* functions */ - -/* - * _CPU_Initialize - * - * This routine performs CPU dependent initialization. - */ - -void _CPU_Initialize(void); - -/* - * _CPU_ISR_install_raw_handler - * - * This routine installs a "raw" interrupt handler directly into the - * processor's vector table. - */ - -void _CPU_ISR_install_raw_handler( - uint32_t vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -/* - * _CPU_ISR_install_vector - * - * This routine installs an interrupt vector. - */ - -void _CPU_ISR_install_vector( - uint32_t vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -/* - * _CPU_Install_interrupt_stack - * - * This routine installs the hardware interrupt stack pointer. - */ - -void _CPU_Install_interrupt_stack( void ); - -/* - * _CPU_Context_switch - * - * This routine switches from the run context to the heir context. - */ - -void _CPU_Context_switch( - Context_Control *run, - Context_Control *heir -); - -void _CPU_Context_Restart_self( - Context_Control *the_context -) RTEMS_NO_RETURN; - -/* - * _CPU_Context_save_fp - * - * This routine saves the floating point context passed to it. - */ - -void _CPU_Context_save_fp( - Context_Control_fp **fp_context_ptr -); - -/* - * _CPU_Context_restore_fp - * - * This routine restores the floating point context passed to it. - */ - -void _CPU_Context_restore_fp( - Context_Control_fp **fp_context_ptr -); - -static inline void _CPU_Context_volatile_clobber( uintptr_t pattern ) -{ - /* TODO */ -} - -static inline void _CPU_Context_validate( uintptr_t pattern ) -{ - while (1) { - /* TODO */ - } -} - -/** - * This method prints the CPU exception frame. - * - * @param[in] frame points to the frame to be printed - */ -void _CPU_Exception_frame_print( - const CPU_Exception_frame *frame -); - -typedef uint32_t CPU_Counter_ticks; - -CPU_Counter_ticks _CPU_Counter_read( void ); - -static inline CPU_Counter_ticks _CPU_Counter_difference( - CPU_Counter_ticks second, - CPU_Counter_ticks first -) -{ - return second - first; -} - -#if (M68K_HAS_FPSP_PACKAGE == 1) -/* - * Hooks for the Floating Point Support Package (FPSP) provided by Motorola - * - * NOTES: - * - * Motorola 68k family CPU's before the 68040 used a coprocessor - * (68881 or 68882) to handle floating point. The 68040 has internal - * floating point support -- but *not* the complete support provided by - * the 68881 or 68882. The leftover functions are taken care of by the - * M68040 Floating Point Support Package. Quoting from the MC68040 - * Microprocessors User's Manual, Section 9, Floating-Point Unit (MC68040): - * - * "When used with the M68040FPSP, the MC68040 FPU is fully - * compliant with IEEE floating-point standards." - * - * M68KFPSPInstallExceptionHandlers is in libcpu/m68k/MODEL/fpsp and - * is invoked early in the application code to ensure that proper FP - * behavior is installed. This is not left to the BSP to call, since - * this would force all applications using that BSP to use FPSP which - * is not necessarily desirable. - * - * There is a similar package for the 68060 but RTEMS does not yet - * support the 68060. - */ - -void M68KFPSPInstallExceptionHandlers (void); - -extern int (*_FPSP_install_raw_handler)( - uint32_t vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -#endif - - -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/score/cpu/m68k/rtems/score/cpuatomic.h b/cpukit/score/cpu/m68k/rtems/score/cpuatomic.h deleted file mode 100644 index 598ee76b20..0000000000 --- a/cpukit/score/cpu/m68k/rtems/score/cpuatomic.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * COPYRIGHT (c) 2012-2013 Deng Hengyi. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_ATOMIC_CPU_H -#define _RTEMS_SCORE_ATOMIC_CPU_H - -#include - -#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/m68k/rtems/score/cpuimpl.h b/cpukit/score/cpu/m68k/rtems/score/cpuimpl.h deleted file mode 100644 index 789f2badd9..0000000000 --- a/cpukit/score/cpu/m68k/rtems/score/cpuimpl.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @file - * - * @brief CPU Port Implementation API - */ - -/* - * Copyright (c) 2013 embedded brains GmbH - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPUIMPL_H -#define _RTEMS_SCORE_CPUIMPL_H - -#include - -#define CPU_PER_CPU_CONTROL_SIZE 0 - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* ASM */ - -#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/m68k/rtems/score/m68k.h b/cpukit/score/cpu/m68k/rtems/score/m68k.h deleted file mode 100644 index 818578c078..0000000000 --- a/cpukit/score/cpu/m68k/rtems/score/m68k.h +++ /dev/null @@ -1,502 +0,0 @@ -/** - * @file - * - * @brief Motorola M68K CPU Dependent Source - * - * This include file contains information pertaining to the Motorola - * m68xxx processor family. - */ - -/* - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_M68K_H -#define _RTEMS_SCORE_M68K_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This section contains the information required to build - * RTEMS for a particular member of the Motorola MC68xxx - * family. It does this by setting variables to indicate - * which implementation dependent features are present in - * a particular member of the family. - * - * Currently recognized: - * -m68000 - * -m68000 -msoft-float - * -m68020 - * -m68020 -msoft-float - * -m68030 - * -m68040 -msoft-float - * -m68040 - * -m68040 -msoft-float - * -m68060 - * -m68060 -msoft-float - * -m68302 (no FP) (deprecated, use -m68000) - * -m68332 (no FP) (deprecated, use -mcpu32) - * -mcpu32 (no FP) - * -m5200 (no FP) - * -m528x (no FP, ISA A+) - * - * As of gcc 2.8.1 and egcs 1.1, there is no distinction made between - * the CPU32 and CPU32+. The option -mcpu32 generates code which can - * be run on either core. RTEMS distinguishes between these two cores - * because they have different alignment rules which impact performance. - * If you are using a CPU32+, then the symbol RTEMS__mcpu32p__ should - * be defined in your custom file (see make/custom/gen68360.cfg for an - * example of how to do this. If gcc ever distinguishes between these - * two cores, then RTEMS__mcpu32p__ usage will be replaced with the - * appropriate compiler defined predefine. - * - * Here is some information on the 040 variants (courtesy of Doug McBride, - * mcbride@rodin.colorado.edu): - * - * "The 68040 is a superset of the 68EC040 and the 68LC040. The - * 68EC040 and 68LC040 do not have FPU's. The 68LC040 and the - * 68EC040 have renamed the DLE pin as JS0 which must be tied to - * Gnd or Vcc. The 68EC040 has renamed the MDIS pin as JS1. The - * 68EC040 has access control units instead of memory management units. - * The 68EC040 should not have the PFLUSH or PTEST instructions executed - * (cause an indeterminate result). The 68EC040 and 68LC040 do not - * implement the DLE or multiplexed bus modes. The 68EC040 does not - * implement the output buffer impedance selection mode of operation." - * - * M68K_HAS_EXTB_L is used to enable/disable usage of the extb.l instruction - * which is not available for 68000 or 68ec000 cores (68000, 68001, 68008, - * 68010, 68302, 68306, 68307). This instruction is available on the 68020 - * up and the cpu32 based models. - * - * M68K_HAS_MISALIGNED is non-zero if the CPU allows byte-misaligned - * data access (68020, 68030, 68040, 68060, CPU32+). - * - * NOTE: - * Eventually it would be nice to evaluate doing a lot of this section - * by having each model specify which core it uses and then go from there. - */ - -/* - * Handle the Coldfire family based on the instruction set. - */ -#if defined(__mcoldfire__) - -# define CPU_NAME "Motorola ColdFire" - -# if defined(__mcfisaa__) -/* Motorola ColdFire ISA A */ -# define CPU_MODEL_NAME "mcfisaa" -# define M68K_HAS_VBR 1 -# define M68K_HAS_BFFFO 0 -# define M68K_HAS_SEPARATE_STACKS 0 -# define M68K_HAS_PREINDEXING 0 -# define M68K_HAS_EXTB_L 1 -# define M68K_HAS_MISALIGNED 1 - -# elif defined(__mcfisaaplus__) -/* Motorola ColdFire ISA A+ */ -# define CPU_MODEL_NAME "mcfisaaplus" -# define M68K_HAS_VBR 1 -# define M68K_HAS_BFFFO 0 -# define M68K_HAS_SEPARATE_STACKS 0 -# define M68K_HAS_PREINDEXING 0 -# define M68K_HAS_EXTB_L 1 -# define M68K_HAS_MISALIGNED 1 - -# elif defined(__mcfisab__) -/* Motorola ColdFire ISA B */ -# define CPU_MODEL_NAME "mcfisab" -# define M68K_HAS_VBR 1 -# define M68K_HAS_BFFFO 0 -# define M68K_HAS_SEPARATE_STACKS 0 -# define M68K_HAS_PREINDEXING 0 -# define M68K_HAS_EXTB_L 1 -# define M68K_HAS_MISALIGNED 1 - -# else -# error "Unsupported Coldfire ISA -- Please notify RTEMS" -# endif - -/* - * Assume the FPU support is independent. I think it is just the ISA B - * instruction set. - */ -# if defined (__mcffpu__) -# define M68K_HAS_FPU 1 - /* - * td: can we be sure that all CFs with FPU also have an EMAC? - */ -# define M68K_HAS_EMAC 1 -# define M68K_HAS_FPSP_PACKAGE 0 -# else -# define M68K_HAS_FPU 0 -# define M68K_HAS_FPSP_PACKAGE 0 -# endif - -/* - * Tiny RTEMS support. Small stack and limited priorities. - * - * These CPUs have very limited on-CPU memory which cannot - * be expanded. We have to be gentle with them or nothing - * will every run. - */ -# if (defined(__mcf_cpu_52221) || \ - defined(__mcf_cpu_52223) || \ - defined(__mcf_cpu_52230) || \ - defined(__mcf_cpu_52231) || \ - defined(__mcf_cpu_52232) || \ - defined(__mcf_cpu_52233) || \ - defined(__mcf_cpu_52234) || \ - defined(__mcf_cpu_52235) || \ - defined(__mcf_cpu_52225) || \ - defined(__mcf_cpu_52235)) - #define M68K_CPU_STACK_MINIMUM_SIZE 1024 - /* Define the lowest priority. Based from 0 to this is 16 levels. */ - #define M68K_CPU_PRIORITY_MAXIMUM 15 -# else - #define M68K_CPU_STACK_MINIMUM_SIZE 4096 - /* Use the default number of priorities */ - #define M68K_CPU_PRIORITY_MAXIMUM 255 -# endif - -#else - -/* - * Figure out all CPU Model Feature Flags based upon compiler - * predefines. Notice the only exception to this is that - * gcc does not distinguish between CPU32 and CPU32+. This - * feature selection logic is setup such that if RTEMS__mcpu32p__ - * is defined, then CPU32+ rules are used. Otherwise, the safe - * but less efficient CPU32 rules are used for the CPU32+. - */ - -# define CPU_NAME "Motorola MC68xxx" - -/* - * One stack size fits all 68000 processors. - */ -# define M68K_CPU_STACK_MINIMUM_SIZE 4096 - -# if (defined(__mc68020__) && !defined(__mcpu32__)) - -# define CPU_MODEL_NAME "m68020" -# define M68K_HAS_VBR 1 -# define M68K_HAS_SEPARATE_STACKS 1 -# define M68K_HAS_BFFFO 1 -# define M68K_HAS_PREINDEXING 1 -# define M68K_HAS_EXTB_L 1 -# define M68K_HAS_MISALIGNED 1 -# if defined (__HAVE_68881__) -# define M68K_HAS_FPU 1 -# define M68K_HAS_FPSP_PACKAGE 0 -# else -# define M68K_HAS_FPU 0 -# define M68K_HAS_FPSP_PACKAGE 0 -# endif - -# elif defined(__mc68030__) - -# define CPU_MODEL_NAME "m68030" -# define M68K_HAS_VBR 1 -# define M68K_HAS_SEPARATE_STACKS 1 -# define M68K_HAS_BFFFO 1 -# define M68K_HAS_PREINDEXING 1 -# define M68K_HAS_EXTB_L 1 -# define M68K_HAS_MISALIGNED 1 -# if defined (__HAVE_68881__) -# define M68K_HAS_FPU 1 -# define M68K_HAS_FPSP_PACKAGE 0 -# else -# define M68K_HAS_FPU 0 -# define M68K_HAS_FPSP_PACKAGE 0 -# endif - -# elif defined(__mc68040__) - -# define CPU_MODEL_NAME "m68040" -# define M68K_HAS_VBR 1 -# define M68K_HAS_SEPARATE_STACKS 1 -# define M68K_HAS_BFFFO 1 -# define M68K_HAS_PREINDEXING 1 -# define M68K_HAS_EXTB_L 1 -# define M68K_HAS_MISALIGNED 1 -# if defined (__HAVE_68881__) -# define M68K_HAS_FPU 1 -# define M68K_HAS_FPSP_PACKAGE 1 -# else -# define M68K_HAS_FPU 0 -# define M68K_HAS_FPSP_PACKAGE 0 -# endif - -# elif defined(__mc68060__) - -# define CPU_MODEL_NAME "m68060" -# define M68K_HAS_VBR 1 -# define M68K_HAS_SEPARATE_STACKS 0 -# define M68K_HAS_BFFFO 1 -# define M68K_HAS_PREINDEXING 1 -# define M68K_HAS_EXTB_L 1 -# define M68K_HAS_MISALIGNED 1 -# if defined (__HAVE_68881__) -# define M68K_HAS_FPU 1 -# define M68K_HAS_FPSP_PACKAGE 0 -# else -# define M68K_HAS_FPU 0 -# define M68K_HAS_FPSP_PACKAGE 0 -# endif - -# elif defined(__mc68302__) - -# define CPU_MODEL_NAME "m68302" -# define M68K_HAS_VBR 0 -# define M68K_HAS_SEPARATE_STACKS 0 -# define M68K_HAS_BFFFO 0 -# define M68K_HAS_PREINDEXING 0 -# define M68K_HAS_EXTB_L 0 -# define M68K_HAS_MISALIGNED 0 -# define M68K_HAS_FPU 0 -# define M68K_HAS_FPSP_PACKAGE 0 - - /* gcc and egcs do not distinguish between CPU32 and CPU32+ */ -# elif defined(RTEMS__mcpu32p__) - -# define CPU_MODEL_NAME "mcpu32+" -# define M68K_HAS_VBR 1 -# define M68K_HAS_SEPARATE_STACKS 0 -# define M68K_HAS_BFFFO 0 -# define M68K_HAS_PREINDEXING 1 -# define M68K_HAS_EXTB_L 1 -# define M68K_HAS_MISALIGNED 1 -# define M68K_HAS_FPU 0 -# define M68K_HAS_FPSP_PACKAGE 0 - -# elif defined(__mcpu32__) - -# define CPU_MODEL_NAME "mcpu32" -# define M68K_HAS_VBR 1 -# define M68K_HAS_SEPARATE_STACKS 0 -# define M68K_HAS_BFFFO 0 -# define M68K_HAS_PREINDEXING 1 -# define M68K_HAS_EXTB_L 1 -# define M68K_HAS_MISALIGNED 0 -# define M68K_HAS_FPU 0 -# define M68K_HAS_FPSP_PACKAGE 0 - -# elif defined(__mc68000__) - -# define CPU_MODEL_NAME "m68000" -# define M68K_HAS_VBR 0 -# define M68K_HAS_SEPARATE_STACKS 0 -# define M68K_HAS_BFFFO 0 -# define M68K_HAS_PREINDEXING 0 -# define M68K_HAS_EXTB_L 0 -# define M68K_HAS_MISALIGNED 0 -# if defined (__HAVE_68881__) -# define M68K_HAS_FPU 1 -# define M68K_HAS_FPSP_PACKAGE 0 -# else -# define M68K_HAS_FPU 0 -# define M68K_HAS_FPSP_PACKAGE 0 -# endif - -# else - -# error "Unsupported 68000 CPU model -- are you sure you're running a 68k compiler?" - -# endif - -/* - * No Tiny RTEMS support on the standard 68000 family. - */ -# define M68K_CPU_STACK_MINIMUM_SIZE 4096 -# define M68K_CPU_PRIORITY_MAXIMUM 255 - -#endif - -/* - * OBSOLETE: Backward compatibility only - Don't use. - * Use __mcoldfire__ instead. - */ -#if defined(__mcoldfire__) -#define M68K_COLDFIRE_ARCH 1 -#else -#define M68K_COLDFIRE_ARCH 0 -#endif - -#ifndef ASM - -#if ( defined(__mcoldfire__) ) -#define m68k_disable_interrupts( _level ) \ - do { register uint32_t _tmpsr = 0x0700; \ - __asm__ volatile ( "move.w %%sr,%0\n\t" \ - "or.l %0,%1\n\t" \ - "move.w %1,%%sr" \ - : "=d" (_level), "=d"(_tmpsr) : "1"(_tmpsr) \ - : "cc" ); \ - } while( 0 ) -#else -#define m68k_disable_interrupts( _level ) \ - __asm__ volatile ( "move.w %%sr,%0\n\t" \ - "or.w #0x0700,%%sr" \ - : "=d" (_level) \ - : : "cc" ) -#endif - -#define m68k_enable_interrupts( _level ) \ - __asm__ volatile ( "move.w %0,%%sr " : : "d" (_level) : "cc"); - -#if ( defined(__mcoldfire__) ) -#define m68k_flash_interrupts( _level ) \ - do { register uint32_t _tmpsr = 0x0700; \ - asm volatile ( "move.w %2,%%sr\n\t" \ - "or.l %2,%1\n\t" \ - "move.w %1,%%sr" \ - : "=d"(_tmpsr) : "0"(_tmpsr), "d"(_level) \ - : "cc"); \ - } while( 0 ) -#else -#define m68k_flash_interrupts( _level ) \ - __asm__ volatile ( "move.w %0,%%sr\n\t" \ - "or.w #0x0700,%%sr" \ - : : "d" (_level) \ - : "cc" ) -#endif - -#define m68k_get_interrupt_level( _level ) \ - do { \ - register uint32_t _tmpsr; \ - \ - __asm__ volatile( "move.w %%sr,%0" : "=d" (_tmpsr)); \ - _level = (_tmpsr & 0x0700) >> 8; \ - } while (0) - -#define m68k_set_interrupt_level( _newlevel ) \ - do { \ - register uint32_t _tmpsr; \ - \ - __asm__ volatile( "move.w %%sr,%0" : "=d" (_tmpsr)); \ - _tmpsr = (_tmpsr & 0xf8ff) | ((_newlevel) << 8); \ - __asm__ volatile( "move.w %0,%%sr" : : "d" (_tmpsr)); \ - } while (0) - -#if ( M68K_HAS_VBR == 1 && !defined(__mcoldfire__) ) -#define m68k_get_vbr( vbr ) \ - __asm__ volatile ( "movec %%vbr,%0 " : "=r" (vbr)) - -#define m68k_set_vbr( vbr ) \ - __asm__ volatile ( "movec %0,%%vbr " : : "r" (vbr)) - -#elif ( defined(__mcoldfire__) ) -extern void* _VBR; -#define m68k_get_vbr( _vbr ) _vbr = &_VBR - -#define m68k_set_vbr( _vbr ) \ - do { \ - __asm__ volatile ( "movec %0,%%vbr " : : "r" (_vbr)); \ - _VBR = (void *)_vbr; \ - } while(0) - -#else -#define m68k_get_vbr( _vbr ) _vbr = (void *)_VBR -#define m68k_set_vbr( _vbr ) -#endif - -/* - * Access Control Registers - */ -#define m68k_set_cacr(_cacr) __asm__ volatile ("movec %0,%%cacr" : : "d" (_cacr)) -#define m68k_set_acr0(_acr0) __asm__ volatile ("movec %0,%%acr0" : : "d" (_acr0)) -#define m68k_set_acr1(_acr1) __asm__ volatile ("movec %0,%%acr1" : : "d" (_acr1)) - -/* - * The following routine swaps the endian format of an unsigned int. - * It must be static because it is referenced indirectly. - */ -#if ( defined(__mcoldfire__) ) - -/* There are no rotate commands in Coldfire architecture. We will use - * generic implementation of endian swapping for Coldfire. - */ -static inline uint32_t m68k_swap_u32( - uint32_t value - ) -{ - uint32_t byte1, byte2, byte3, byte4, swapped; - - byte4 = (value >> 24) & 0xff; - byte3 = (value >> 16) & 0xff; - byte2 = (value >> 8) & 0xff; - byte1 = value & 0xff; - - swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4; - return( swapped ); -} - -static inline uint16_t m68k_swap_u16( - uint16_t value -) -{ - return (((value & 0xff) << 8) | ((value >> 8) & 0xff)); -} - -#else - -static inline uint32_t m68k_swap_u32( - uint32_t value -) -{ - uint32_t swapped = value; - - __asm__ volatile( "rorw #8,%0" : "=d" (swapped) : "0" (swapped) ); - __asm__ volatile( "swap %0" : "=d" (swapped) : "0" (swapped) ); - __asm__ volatile( "rorw #8,%0" : "=d" (swapped) : "0" (swapped) ); - - return( swapped ); -} - -static inline uint16_t m68k_swap_u16( - uint16_t value -) -{ - uint16_t swapped = value; - - __asm__ volatile( "rorw #8,%0" : "=d" (swapped) : "0" (swapped) ); - - return( swapped ); -} -#endif - -#define CPU_swap_u32( value ) m68k_swap_u32( value ) -#define CPU_swap_u16( value ) m68k_swap_u16( value ) - - -/* - * _CPU_virtual_to_physical - * - * This function is used to map virtual addresses to physical - * addresses. - * - * FIXME: ASSUMES THAT VIRTUAL ADDRESSES ARE THE SAME AS THE - * PHYSICAL ADDRESSES - */ -static inline void * _CPU_virtual_to_physical ( - const void * d_addr ) -{ - return (void *) d_addr; -} - - -#endif /* !ASM */ - -#ifdef __cplusplus -} -#endif - -#endif /* _RTEMS_SCORE_M68K_H */ diff --git a/cpukit/score/cpu/m68k/rtems/score/types.h b/cpukit/score/cpu/m68k/rtems/score/types.h deleted file mode 100644 index 947c6ace69..0000000000 --- a/cpukit/score/cpu/m68k/rtems/score/types.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file - * - * @brief Motorola M68K CPU Type Definitions - * - * This include file contains type definitions pertaining to the Motorola - * m68xxx processor family. - */ - -/* - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_TYPES_H -#define _RTEMS_SCORE_TYPES_H - -#include - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This section defines the basic types for this processor. - */ - -/** Type that can store a 32-bit integer or a pointer. */ -typedef uintptr_t CPU_Uint32ptr; - -#ifdef __cplusplus -} -#endif - -#endif /* !ASM */ - -#endif diff --git a/cpukit/score/cpu/mips/Makefile.am b/cpukit/score/cpu/mips/Makefile.am index 123e5232b9..fe7fa5582c 100644 --- a/cpukit/score/cpu/mips/Makefile.am +++ b/cpukit/score/cpu/mips/Makefile.am @@ -1,23 +1,9 @@ include $(top_srcdir)/automake/compile.am -include_rtemsdir = $(includedir)/rtems -include_rtems_HEADERS = rtems/asm.h - -include_rtems_mipsdir = $(includedir)/rtems/mips -include_rtems_mips_HEADERS = rtems/mips/idtcpu.h -include_rtems_mips_HEADERS += rtems/mips/iregdef.h - -include_rtems_scoredir = $(includedir)/rtems/score -include_rtems_score_HEADERS = rtems/score/cpu.h -include_rtems_score_HEADERS += rtems/score/cpuimpl.h -include_rtems_score_HEADERS += rtems/score/mips.h -include_rtems_score_HEADERS += rtems/score/types.h -include_rtems_score_HEADERS += rtems/score/cpuatomic.h - noinst_LIBRARIES = libscorecpu.a libscorecpu_a_SOURCES = cpu.c cpu_asm.S libscorecpu_a_SOURCES += ../no_cpu/cpucounterread.c libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS) -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am +include $(srcdir)/headers.am diff --git a/cpukit/score/cpu/mips/headers.am b/cpukit/score/cpu/mips/headers.am new file mode 100644 index 0000000000..cbcf1dd91f --- /dev/null +++ b/cpukit/score/cpu/mips/headers.am @@ -0,0 +1,22 @@ +## This file was generated by "./boostrap -H". + +include_machinedir = $(includedir)/machine +include_machine_HEADERS = +include_machine_HEADERS += include/machine/elf_machdep.h + +include_rtemsdir = $(includedir)/rtems +include_rtems_HEADERS = +include_rtems_HEADERS += include/rtems/asm.h + +include_rtems_mipsdir = $(includedir)/rtems/mips +include_rtems_mips_HEADERS = +include_rtems_mips_HEADERS += include/rtems/mips/idtcpu.h +include_rtems_mips_HEADERS += include/rtems/mips/iregdef.h + +include_rtems_scoredir = $(includedir)/rtems/score +include_rtems_score_HEADERS = +include_rtems_score_HEADERS += include/rtems/score/cpu.h +include_rtems_score_HEADERS += include/rtems/score/cpuatomic.h +include_rtems_score_HEADERS += include/rtems/score/cpuimpl.h +include_rtems_score_HEADERS += include/rtems/score/mips.h +include_rtems_score_HEADERS += include/rtems/score/types.h diff --git a/cpukit/score/cpu/mips/include/machine/elf_machdep.h b/cpukit/score/cpu/mips/include/machine/elf_machdep.h new file mode 100644 index 0000000000..26700ce4ce --- /dev/null +++ b/cpukit/score/cpu/mips/include/machine/elf_machdep.h @@ -0,0 +1,199 @@ +/* $NetBSD: elf_machdep.h,v 1.15 2011/03/15 07:39:22 matt Exp $ */ + +#ifndef _MIPS_ELF_MACHDEP_H_ +#define _MIPS_ELF_MACHDEP_H_ + +#ifdef _LP64 +#define ARCH_ELFSIZE 64 /* MD native binary size */ +#else +#define ARCH_ELFSIZE 32 /* MD native binary size */ +#endif + +#if ARCH_ELFSIZE == 32 +#define ELF32_MACHDEP_ID_CASES \ + case EM_MIPS: \ + break; + +#define ELF32_MACHDEP_ID EM_MIPS + +#elif ARCH_ELFSIZE == 64 +#define ELF64_MACHDEP_ID_CASES \ + case EM_MIPS: \ + break; + +#define ELF64_MACHDEP_ID EM_MIPS + +#endif + + +/* mips relocs. */ + +#define R_MIPS_NONE 0 +#define R_MIPS_16 1 +#define R_MIPS_32 2 +#define R_MIPS_REL32 3 +#define R_MIPS_REL R_MIPS_REL32 +#define R_MIPS_26 4 +#define R_MIPS_HI16 5 /* high 16 bits of symbol value */ +#define R_MIPS_LO16 6 /* low 16 bits of symbol value */ +#define R_MIPS_GPREL16 7 /* GP-relative reference */ +#define R_MIPS_LITERAL 8 /* Reference to literal section */ +#define R_MIPS_GOT16 9 /* Reference to global offset table */ +#define R_MIPS_GOT R_MIPS_GOT16 +#define R_MIPS_PC16 10 /* 16 bit PC relative reference */ +#define R_MIPS_CALL16 11 /* 16 bit call thru glbl offset tbl */ +#define R_MIPS_CALL R_MIPS_CALL16 +#define R_MIPS_GPREL32 12 + +/* 13, 14, 15 are not defined at this point. */ +#define R_MIPS_UNUSED1 13 +#define R_MIPS_UNUSED2 14 +#define R_MIPS_UNUSED3 15 + +/* + * The remaining relocs are apparently part of the 64-bit Irix ELF ABI. + */ +#define R_MIPS_SHIFT5 16 +#define R_MIPS_SHIFT6 17 + +#define R_MIPS_64 18 +#define R_MIPS_GOT_DISP 19 +#define R_MIPS_GOT_PAGE 20 +#define R_MIPS_GOT_OFST 21 +#define R_MIPS_GOT_HI16 22 +#define R_MIPS_GOT_LO16 23 +#define R_MIPS_SUB 24 +#define R_MIPS_INSERT_A 25 +#define R_MIPS_INSERT_B 26 +#define R_MIPS_DELETE 27 +#define R_MIPS_HIGHER 28 +#define R_MIPS_HIGHEST 29 +#define R_MIPS_CALL_HI16 30 +#define R_MIPS_CALL_LO16 31 +#define R_MIPS_SCN_DISP 32 +#define R_MIPS_REL16 33 +#define R_MIPS_ADD_IMMEDIATE 34 +#define R_MIPS_PJUMP 35 +#define R_MIPS_RELGOT 36 +#define R_MIPS_JALR 37 +/* TLS relocations */ + +#define R_MIPS_TLS_DTPMOD32 38 /* Module number 32 bit */ +#define R_MIPS_TLS_DTPREL32 39 /* Module-relative offset 32 bit */ +#define R_MIPS_TLS_DTPMOD64 40 /* Module number 64 bit */ +#define R_MIPS_TLS_DTPREL64 41 /* Module-relative offset 64 bit */ +#define R_MIPS_TLS_GD 42 /* 16 bit GOT offset for GD */ +#define R_MIPS_TLS_LDM 43 /* 16 bit GOT offset for LDM */ +#define R_MIPS_TLS_DTPREL_HI16 44 /* Module-relative offset, high 16 bits */ +#define R_MIPS_TLS_DTPREL_LO16 45 /* Module-relative offset, low 16 bits */ +#define R_MIPS_TLS_GOTTPREL 46 /* 16 bit GOT offset for IE */ +#define R_MIPS_TLS_TPREL32 47 /* TP-relative offset, 32 bit */ +#define R_MIPS_TLS_TPREL64 48 /* TP-relative offset, 64 bit */ +#define R_MIPS_TLS_TPREL_HI16 49 /* TP-relative offset, high 16 bits */ +#define R_MIPS_TLS_TPREL_LO16 50 /* TP-relative offset, low 16 bits */ + +#define R_MIPS_max 51 + +#define R_TYPE(name) __CONCAT(R_MIPS_,name) + +#define R_MIPS16_min 100 +#define R_MIPS16_26 100 +#define R_MIPS16_GPREL 101 +#define R_MIPS16_GOT16 102 +#define R_MIPS16_CALL16 103 +#define R_MIPS16_HI16 104 +#define R_MIPS16_LO16 105 +#define R_MIPS16_max 106 + + +/* mips dynamic tags */ + +#define DT_MIPS_RLD_VERSION 0x70000001 +#define DT_MIPS_TIME_STAMP 0x70000002 +#define DT_MIPS_ICHECKSUM 0x70000003 +#define DT_MIPS_IVERSION 0x70000004 +#define DT_MIPS_FLAGS 0x70000005 +#define DT_MIPS_BASE_ADDRESS 0x70000006 +#define DT_MIPS_CONFLICT 0x70000008 +#define DT_MIPS_LIBLIST 0x70000009 +#define DT_MIPS_CONFLICTNO 0x7000000b +#define DT_MIPS_LOCAL_GOTNO 0x7000000a /* number of local got ents */ +#define DT_MIPS_LIBLISTNO 0x70000010 +#define DT_MIPS_SYMTABNO 0x70000011 /* number of .dynsym entries */ +#define DT_MIPS_UNREFEXTNO 0x70000012 +#define DT_MIPS_GOTSYM 0x70000013 /* first dynamic sym in got */ +#define DT_MIPS_HIPAGENO 0x70000014 +#define DT_MIPS_RLD_MAP 0x70000016 /* address of loader map */ + +/* + * ELF Flags + */ +#define EF_MIPS_PIC 0x00000002 /* Contains PIC code */ +#define EF_MIPS_CPIC 0x00000004 /* STD PIC calling sequence */ +#define EF_MIPS_ABI2 0x00000020 /* N32 */ + +#define EF_MIPS_ARCH_ASE 0x0f000000 /* Architectural extensions */ +#define EF_MIPS_ARCH_MDMX 0x08000000 /* MDMX multimedia extension */ +#define EF_MIPS_ARCH_M16 0x04000000 /* MIPS-16 ISA extensions */ + +#define EF_MIPS_ARCH 0xf0000000 /* Architecture field */ +#define EF_MIPS_ARCH_1 0x00000000 /* -mips1 code */ +#define EF_MIPS_ARCH_2 0x10000000 /* -mips2 code */ +#define EF_MIPS_ARCH_3 0x20000000 /* -mips3 code */ +#define EF_MIPS_ARCH_4 0x30000000 /* -mips4 code */ +#define EF_MIPS_ARCH_5 0x40000000 /* -mips5 code */ +#define EF_MIPS_ARCH_32 0x50000000 /* -mips32 code */ +#define EF_MIPS_ARCH_64 0x60000000 /* -mips64 code */ +#define EF_MIPS_ARCH_32R2 0x70000000 /* -mips32r2 code */ +#define EF_MIPS_ARCH_64R2 0x80000000 /* -mips64r2 code */ + +#define EF_MIPS_ABI 0x0000f000 +#define EF_MIPS_ABI_O32 0x00001000 +#define EF_MIPS_ABI_O64 0x00002000 +#define EF_MIPS_ABI_EABI32 0x00003000 +#define EF_MIPS_ABI_EABI64 0x00004000 + +#if defined(__MIPSEB__) +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB +#define ELF64_MACHDEP_ENDIANNESS ELFDATA2MSB +#elif defined(__MIPSEL__) +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB +#define ELF64_MACHDEP_ENDIANNESS ELFDATA2LSB +#elif !defined(HAVE_NBTOOL_CONFIG_H) +#error neither __MIPSEL__ nor __MIPSEB__ are defined. +#endif + +#ifdef _KERNEL +#ifdef _KERNEL_OPT +#include "opt_compat_netbsd.h" +#endif +#ifdef COMPAT_16 +/* + * Up to 1.6, the ELF dynamic loader (ld.elf_so) was not relocatable. + * Tell the kernel ELF exec code not to try relocating the interpreter + * for dynamically-linked ELF binaries. + */ +#define ELF_INTERP_NON_RELOCATABLE +#endif /* COMPAT_16 */ + +/* + * We need to be able to include the ELF header so we can pick out the + * ABI being used. + */ +#ifdef ELFSIZE +#define ELF_MD_PROBE_FUNC ELFNAME2(mips_netbsd,probe) +#define ELF_MD_COREDUMP_SETUP ELFNAME2(coredump,setup) +#endif + +struct exec_package; + +int mips_netbsd_elf32_probe(struct lwp *, struct exec_package *, void *, char *, + vaddr_t *); +void coredump_elf32_setup(struct lwp *, void *); + +int mips_netbsd_elf64_probe(struct lwp *, struct exec_package *, void *, char *, + vaddr_t *); +void coredump_elf64_setup(struct lwp *, void *); +#endif /* _KERNEL */ + +#endif /* _MIPS_ELF_MACHDEP_H_ */ diff --git a/cpukit/score/cpu/mips/include/rtems/asm.h b/cpukit/score/cpu/mips/include/rtems/asm.h new file mode 100644 index 0000000000..9c84f61990 --- /dev/null +++ b/cpukit/score/cpu/mips/include/rtems/asm.h @@ -0,0 +1,160 @@ +/** + * @file + * + * @brief Address the Problems Caused by Incompatible Flavor of + * Assemblers and Toolsets + * + * This include file attempts to address the problems + * caused by incompatible flavors of assemblers and + * toolsets. It primarily addresses variations in the + * use of leading underscores on symbols and the requirement + * that register names be preceded by a %. + * + * NOTE: The spacing in the use of these macros + * is critical to them working as advertised. + */ + +/* + * COPYRIGHT: + * + * This file is based on similar code found in newlib available + * from ftp.cygnus.com. The file which was used had no copyright + * notice. This file is freely distributable as long as the source + * of the file is noted. This file is: + * + * COPYRIGHT (c) 1994-1997. + * On-Line Applications Research Corporation (OAR). + */ +/* @(#)asm.h 03/15/96 1.1 */ + +#ifndef _RTEMS_ASM_H +#define _RTEMS_ASM_H + +/* + * Indicate we are in an assembly file and get the basic CPU definitions. + */ + +#ifndef ASM +#define ASM +#endif +#include +#include +#include + +/* + * Recent versions of GNU cpp define variables which indicate the + * need for underscores and percents. If not using GNU cpp or + * the version does not support this, then you will obviously + * have to define these as appropriate. + */ + +#ifndef __USER_LABEL_PREFIX__ +#define __USER_LABEL_PREFIX__ _ +#endif + +#ifndef __REGISTER_PREFIX__ +#define __REGISTER_PREFIX__ +#endif + +#include + +/* Use the right prefix for global labels. */ + +#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) + +/* Use the right prefix for registers. */ + +#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) + +/* + * define macros for all of the registers on this CPU + * + * EXAMPLE: #define d0 REG (d0) + */ + +/* + * Define macros to handle section beginning and ends. + */ + + +#define BEGIN_CODE_DCL .text +#define END_CODE_DCL +#define BEGIN_DATA_DCL .data +#define END_DATA_DCL +#define BEGIN_CODE .text +#define END_CODE +#define BEGIN_DATA +#define END_DATA +#define BEGIN_BSS +#define END_BSS +#define END + +/* + * Following must be tailor for a particular flavor of the C compiler. + * They may need to put underscores in front of the symbols. + */ + +#define PUBLIC(sym) .globl SYM (sym) +#define EXTERN(sym) .globl SYM (sym) + +/* + * Debugger macros for assembly language routines. Allows the + * programmer to set up the necessary stack frame info + * required by debuggers to do stack traces. + */ + +#ifndef XDS +#define FRAME(name,frm_reg,offset,ret_reg) \ + .globl name; \ + .ent name; \ +name:; \ + .frame frm_reg,offset,ret_reg +#define ENDFRAME(name) \ + .end name +#else +#define FRAME(name,frm_reg,offset,ret_reg) \ + .globl _##name;\ +_##name: +#define ENDFRAME(name) +#endif /* XDS */ + +/* + * Hardware Floating Point Registers + */ + +#define R_FP0 0 +#define R_FP1 1 +#define R_FP2 2 +#define R_FP3 3 +#define R_FP4 4 +#define R_FP5 5 +#define R_FP6 6 +#define R_FP7 7 +#define R_FP8 8 +#define R_FP9 9 +#define R_FP10 10 +#define R_FP11 11 +#define R_FP12 12 +#define R_FP13 13 +#define R_FP14 14 +#define R_FP15 15 +#define R_FP16 16 +#define R_FP17 17 +#define R_FP18 18 +#define R_FP19 19 +#define R_FP20 20 +#define R_FP21 21 +#define R_FP22 22 +#define R_FP23 23 +#define R_FP24 24 +#define R_FP25 25 +#define R_FP26 26 +#define R_FP27 27 +#define R_FP28 28 +#define R_FP29 29 +#define R_FP30 30 +#define R_FP31 31 + +#endif +/* end of include file */ + diff --git a/cpukit/score/cpu/mips/include/rtems/mips/idtcpu.h b/cpukit/score/cpu/mips/include/rtems/mips/idtcpu.h new file mode 100644 index 0000000000..927bbec133 --- /dev/null +++ b/cpukit/score/cpu/mips/include/rtems/mips/idtcpu.h @@ -0,0 +1,708 @@ +/** + * @file idtcpu.h + * + * @brief CPU Related Definitions + * + * 950313: Ketan added sreg/lreg and R_SZ for 64-bit saves + * added Register definition for XContext reg. + * Look towards end of this file. + */ + +/* + * Based upon IDT provided code with the following release: + * + * This source code has been made available to you by IDT on an AS-IS + * basis. Anyone receiving this source is licensed under IDT copyrights + * to use it in any way he or she deems fit, including copying it, + * modifying it, compiling it, and redistributing it either with or + * without modifications. No license under IDT patents or patent + * applications is to be implied by the copyright license. + * + * Any user of this software should understand that IDT cannot provide + * technical support for this software and will not be responsible for + * any consequences resulting from the use of this software. + * + * Any person who transfers this source code or any derivative work must + * include the IDT copyright notice, this paragraph, and the preceeding + * two paragraphs in the transferred software. + * + * COPYRIGHT IDT CORPORATION 1996 + * LICENSED MATERIAL - PROGRAM PROPERTY OF IDT + */ + +#ifndef _RTEMS_MIPS_IDTCPU_H +#define _RTEMS_MIPS_IDTCPU_H + +/** + * @defgroup MipsSet_idtcpu CPU Related Definitions + * + * @ingroup MIPS + * + */ +/**@{*/ + +/* + * 950313: Ketan added Register definition for XContext reg. + * added define for WAIT instruction. + * 950421: Ketan added Register definition for Config reg (R3081) + */ + +/* +** memory configuration and mapping +*/ +#define K0BASE 0x80000000 +#define K0SIZE 0x20000000 +#define K1BASE 0xa0000000 +#define K1SIZE 0x20000000 +#define K2BASE 0xc0000000 +#define K2SIZE 0x20000000 +#if __mips == 3 +#define KSBASE 0xe0000000 +#define KSSIZE 0x20000000 +#endif + +#define KUBASE 0 +#define KUSIZE 0x80000000 + +/* +** Exception Vectors +*/ +#if __mips == 1 +#define UT_VEC K0BASE /* utlbmiss vector */ +#define DB_VEC (K0BASE+0x40) /* debug vector */ +#define E_VEC (K0BASE+0x80) /* exception vector */ +#elif __mips == 32 +#define T_VEC (K0BASE+0x000) /* tlbmiss vector */ +#define X_VEC (K0BASE+0x080) /* xtlbmiss vector */ +#define C_VEC (K0BASE+0x100) /* cache error vector */ +#define E_VEC (K0BASE+0x180) /* exception vector */ +#elif __mips == 3 +#define T_VEC (K0BASE+0x000) /* tlbmiss vector */ +#define X_VEC (K0BASE+0x080) /* xtlbmiss vector */ +#define C_VEC (K0BASE+0x100) /* cache error vector */ +#define E_VEC (K0BASE+0x180) /* exception vector */ +#else +#error "EXCEPTION VECTORS: unknown ISA level" +#endif +#define R_VEC (K1BASE+0x1fc00000) /* reset vector */ + +/* +** Address conversion macros +*/ +#ifdef CLANGUAGE +#define CAST(as) (as) +#else +#define CAST(as) +#endif +#define K0_TO_K1(x) (CAST(unsigned)(x)|0xA0000000) /* kseg0 to kseg1 */ +#define K1_TO_K0(x) (CAST(unsigned)(x)&0x9FFFFFFF) /* kseg1 to kseg0 */ +#define K0_TO_PHYS(x) (CAST(unsigned)(x)&0x1FFFFFFF) /* kseg0 to physical */ +#define K1_TO_PHYS(x) (CAST(unsigned)(x)&0x1FFFFFFF) /* kseg1 to physical */ +#define PHYS_TO_K0(x) (CAST(unsigned)(x)|0x80000000) /* physical to kseg0 */ +#define PHYS_TO_K1(x) (CAST(unsigned)(x)|0xA0000000) /* physical to kseg1 */ + +/* +** Cache size constants +*/ +#define MINCACHE 0x200 /* 512 For 3041. */ +#define MAXCACHE 0x40000 /* 256*1024 256k */ + +#if __mips == 32 +/* R4000 configuration register definitions */ +#define CFG_CM 0x80000000 /* Master-Checker mode */ +#define CFG_ECMASK 0x70000000 /* System Clock Ratio */ +#define CFG_ECBY2 0x00000000 /* divide by 2 */ +#define CFG_ECBY3 0x10000000 /* divide by 3 */ +#define CFG_ECBY4 0x20000000 /* divide by 4 */ +#define CFG_EPMASK 0x0f000000 /* Transmit data pattern */ +#define CFG_EPD 0x00000000 /* D */ +#define CFG_EPDDX 0x01000000 /* DDX */ +#define CFG_EPDDXX 0x02000000 /* DDXX */ +#define CFG_EPDXDX 0x03000000 /* DXDX */ +#define CFG_EPDDXXX 0x04000000 /* DDXXX */ +#define CFG_EPDDXXXX 0x05000000 /* DDXXXX */ +#define CFG_EPDXXDXX 0x06000000 /* DXXDXX */ +#define CFG_EPDDXXXXX 0x07000000 /* DDXXXXX */ +#define CFG_EPDXXXDXXX 0x08000000 /* DXXXDXXX */ +#define CFG_SBMASK 0x00c00000 /* Secondary cache block size */ +#define CFG_SBSHIFT 22 +#define CFG_SB4 0x00000000 /* 4 words */ +#define CFG_SB8 0x00400000 /* 8 words */ +#define CFG_SB16 0x00800000 /* 16 words */ +#define CFG_SB32 0x00c00000 /* 32 words */ +#define CFG_SS 0x00200000 /* Split secondary cache */ +#define CFG_SW 0x00100000 /* Secondary cache port width */ +#define CFG_EWMASK 0x000c0000 /* System port width */ +#define CFG_EWSHIFT 18 +#define CFG_EW64 0x00000000 /* 64 bit */ +#define CFG_EW32 0x00010000 /* 32 bit */ +#define CFG_SC 0x00020000 /* Secondary cache absent */ +#define CFG_SM 0x00010000 /* Dirty Shared mode disabled */ +#define CFG_BE 0x00008000 /* Big Endian */ +#define CFG_EM 0x00004000 /* ECC mode enable */ +#define CFG_EB 0x00002000 /* Block ordering */ +#define CFG_ICMASK 0x00000e00 /* Instruction cache size */ +#define CFG_ICSHIFT 9 +#define CFG_DCMASK 0x000001c0 /* Data cache size */ +#define CFG_DCSHIFT 6 +#define CFG_IB 0x00000020 /* Instruction cache block size */ +#define CFG_DB 0x00000010 /* Data cache block size */ +#define CFG_CU 0x00000008 /* Update on Store Conditional */ +#define CFG_K0MASK 0x00000007 /* KSEG0 coherency algorithm */ + +/* + * R4000 primary cache mode + */ +#define CFG_C_UNCACHED 2 +#define CFG_C_NONCOHERENT 3 +#define CFG_C_COHERENTXCL 4 +#define CFG_C_COHERENTXCLW 5 +#define CFG_C_COHERENTUPD 6 + +/* + * R4000 cache operations (should be in assembler...?) + */ +#define Index_Invalidate_I 0x0 /* 0 0 */ +#define Index_Writeback_Inv_D 0x1 /* 0 1 */ +#define Index_Invalidate_SI 0x2 /* 0 2 */ +#define Index_Writeback_Inv_SD 0x3 /* 0 3 */ +#define Index_Load_Tag_I 0x4 /* 1 0 */ +#define Index_Load_Tag_D 0x5 /* 1 1 */ +#define Index_Load_Tag_SI 0x6 /* 1 2 */ +#define Index_Load_Tag_SD 0x7 /* 1 3 */ +#define Index_Store_Tag_I 0x8 /* 2 0 */ +#define Index_Store_Tag_D 0x9 /* 2 1 */ +#define Index_Store_Tag_SI 0xA /* 2 2 */ +#define Index_Store_Tag_SD 0xB /* 2 3 */ +#define Create_Dirty_Exc_D 0xD /* 3 1 */ +#define Create_Dirty_Exc_SD 0xF /* 3 3 */ +#define Hit_Invalidate_I 0x10 /* 4 0 */ +#define Hit_Invalidate_D 0x11 /* 4 1 */ +#define Hit_Invalidate_SI 0x12 /* 4 2 */ +#define Hit_Invalidate_SD 0x13 /* 4 3 */ +#define Hit_Writeback_Inv_D 0x15 /* 5 1 */ +#define Hit_Writeback_Inv_SD 0x17 /* 5 3 */ +#define Fill_I 0x14 /* 5 0 */ +#define Hit_Writeback_D 0x19 /* 6 1 */ +#define Hit_Writeback_SD 0x1B /* 6 3 */ +#define Hit_Writeback_I 0x18 /* 6 0 */ +#define Hit_Set_Virtual_SI 0x1E /* 7 2 */ +#define Hit_Set_Virtual_SD 0x1F /* 7 3 */ + +/* Disabled by chris -- horrible overload of common word. +#ifndef WAIT +#define WAIT .word 0x42000020 +#endif +*/ +/* Disabled by joel -- horrible overload of common word. +#ifndef wait +#define wait .word 0x42000020 +#endif wait +*/ + +#endif + +#if __mips == 3 +/* R4000 configuration register definitions */ +#define CFG_CM 0x80000000 /* Master-Checker mode */ +#define CFG_ECMASK 0x70000000 /* System Clock Ratio */ +#define CFG_ECBY2 0x00000000 /* divide by 2 */ +#define CFG_ECBY3 0x10000000 /* divide by 3 */ +#define CFG_ECBY4 0x20000000 /* divide by 4 */ +#define CFG_EPMASK 0x0f000000 /* Transmit data pattern */ +#define CFG_EPD 0x00000000 /* D */ +#define CFG_EPDDX 0x01000000 /* DDX */ +#define CFG_EPDDXX 0x02000000 /* DDXX */ +#define CFG_EPDXDX 0x03000000 /* DXDX */ +#define CFG_EPDDXXX 0x04000000 /* DDXXX */ +#define CFG_EPDDXXXX 0x05000000 /* DDXXXX */ +#define CFG_EPDXXDXX 0x06000000 /* DXXDXX */ +#define CFG_EPDDXXXXX 0x07000000 /* DDXXXXX */ +#define CFG_EPDXXXDXXX 0x08000000 /* DXXXDXXX */ +#define CFG_SBMASK 0x00c00000 /* Secondary cache block size */ +#define CFG_SBSHIFT 22 +#define CFG_SB4 0x00000000 /* 4 words */ +#define CFG_SB8 0x00400000 /* 8 words */ +#define CFG_SB16 0x00800000 /* 16 words */ +#define CFG_SB32 0x00c00000 /* 32 words */ +#define CFG_SS 0x00200000 /* Split secondary cache */ +#define CFG_SW 0x00100000 /* Secondary cache port width */ +#define CFG_EWMASK 0x000c0000 /* System port width */ +#define CFG_EWSHIFT 18 +#define CFG_EW64 0x00000000 /* 64 bit */ +#define CFG_EW32 0x00010000 /* 32 bit */ +#define CFG_SC 0x00020000 /* Secondary cache absent */ +#define CFG_SM 0x00010000 /* Dirty Shared mode disabled */ +#define CFG_BE 0x00008000 /* Big Endian */ +#define CFG_EM 0x00004000 /* ECC mode enable */ +#define CFG_EB 0x00002000 /* Block ordering */ +#define CFG_ICMASK 0x00000e00 /* Instruction cache size */ +#define CFG_ICSHIFT 9 +#define CFG_DCMASK 0x000001c0 /* Data cache size */ +#define CFG_DCSHIFT 6 +#define CFG_IB 0x00000020 /* Instruction cache block size */ +#define CFG_DB 0x00000010 /* Data cache block size */ +#define CFG_CU 0x00000008 /* Update on Store Conditional */ +#define CFG_K0MASK 0x00000007 /* KSEG0 coherency algorithm */ + +/* + * R4000 primary cache mode + */ +#define CFG_C_UNCACHED 2 +#define CFG_C_NONCOHERENT 3 +#define CFG_C_COHERENTXCL 4 +#define CFG_C_COHERENTXCLW 5 +#define CFG_C_COHERENTUPD 6 + +/* + * R4000 cache operations (should be in assembler...?) + */ +#define Index_Invalidate_I 0x0 /* 0 0 */ +#define Index_Writeback_Inv_D 0x1 /* 0 1 */ +#define Index_Invalidate_SI 0x2 /* 0 2 */ +#define Index_Writeback_Inv_SD 0x3 /* 0 3 */ +#define Index_Load_Tag_I 0x4 /* 1 0 */ +#define Index_Load_Tag_D 0x5 /* 1 1 */ +#define Index_Load_Tag_SI 0x6 /* 1 2 */ +#define Index_Load_Tag_SD 0x7 /* 1 3 */ +#define Index_Store_Tag_I 0x8 /* 2 0 */ +#define Index_Store_Tag_D 0x9 /* 2 1 */ +#define Index_Store_Tag_SI 0xA /* 2 2 */ +#define Index_Store_Tag_SD 0xB /* 2 3 */ +#define Create_Dirty_Exc_D 0xD /* 3 1 */ +#define Create_Dirty_Exc_SD 0xF /* 3 3 */ +#define Hit_Invalidate_I 0x10 /* 4 0 */ +#define Hit_Invalidate_D 0x11 /* 4 1 */ +#define Hit_Invalidate_SI 0x12 /* 4 2 */ +#define Hit_Invalidate_SD 0x13 /* 4 3 */ +#define Hit_Writeback_Inv_D 0x15 /* 5 1 */ +#define Hit_Writeback_Inv_SD 0x17 /* 5 3 */ +#define Fill_I 0x14 /* 5 0 */ +#define Hit_Writeback_D 0x19 /* 6 1 */ +#define Hit_Writeback_SD 0x1B /* 6 3 */ +#define Hit_Writeback_I 0x18 /* 6 0 */ +#define Hit_Set_Virtual_SI 0x1E /* 7 2 */ +#define Hit_Set_Virtual_SD 0x1F /* 7 3 */ + +/* Disabled by chris -- horrible overload of common word. +#ifndef WAIT +#define WAIT .word 0x42000020 +#endif +*/ +/* Disabled by joel -- horrible overload of common word. +#ifndef wait +#define wait .word 0x42000020 +#endif wait +*/ + +#endif + +/* +** TLB resource defines +*/ +#if __mips == 1 +#define N_TLB_ENTRIES 64 +#define TLB_PGSIZE 0x1000 +#define RANDBASE 8 +#define TLBLO_PFNMASK 0xfffff000 +#define TLBLO_PFNSHIFT 12 +#define TLBLO_N 0x800 /* non-cacheable */ +#define TLBLO_D 0x400 /* writeable */ +#define TLBLO_V 0x200 /* valid bit */ +#define TLBLO_G 0x100 /* global access bit */ + +#define TLBHI_VPNMASK 0xfffff000 +#define TLBHI_VPNSHIFT 12 +#define TLBHI_PIDMASK 0xfc0 +#define TLBHI_PIDSHIFT 6 +#define TLBHI_NPID 64 + +#define TLBINX_PROBE 0x80000000 +#define TLBINX_INXMASK 0x00003f00 +#define TLBINX_INXSHIFT 8 + +#define TLBRAND_RANDMASK 0x00003f00 +#define TLBRAND_RANDSHIFT 8 + +#define TLBCTXT_BASEMASK 0xffe00000 +#define TLBCTXT_BASESHIFT 21 + +#define TLBCTXT_VPNMASK 0x001ffffc +#define TLBCTXT_VPNSHIFT 2 +#endif +#if __mips == 3 +#define N_TLB_ENTRIES 48 + +#define TLBHI_VPN2MASK 0xffffe000 +#define TLBHI_PIDMASK 0x000000ff +#define TLBHI_NPID 256 + +#define TLBLO_PFNMASK 0x3fffffc0 +#define TLBLO_PFNSHIFT 6 +#define TLBLO_D 0x00000004 /* writeable */ +#define TLBLO_V 0x00000002 /* valid bit */ +#define TLBLO_G 0x00000001 /* global access bit */ +#define TLBLO_CMASK 0x00000038 /* cache algorithm mask */ +#define TLBLO_CSHIFT 3 + +#define TLBLO_UNCACHED (CFG_C_UNCACHED< k, 1 => u */ +#define SR_IEO 0x00000010 /* old interrupt enable, 1 => enable */ +#define SR_KUP 0x00000008 /* prev kernel/user, 0 => k, 1 => u */ +#define SR_IEP 0x00000004 /* prev interrupt enable, 1 => enable */ +#define SR_KUC 0x00000002 /* cur kernel/user, 0 => k, 1 => u */ +#define SR_IEC 0x00000001 /* cur interrupt enable, 1 => enable */ +#endif + +#if __mips == 3 +#define SR_CUMASK 0xf0000000 /* coproc usable bits */ +#define SR_CU3 0x80000000 /* Coprocessor 3 usable */ +#define SR_CU2 0x40000000 /* Coprocessor 2 usable */ +#define SR_CU1 0x20000000 /* Coprocessor 1 usable */ +#define SR_CU0 0x10000000 /* Coprocessor 0 usable */ + +#define SR_RP 0x08000000 /* Reduced power operation */ +#define SR_FR 0x04000000 /* Additional floating point registers */ +#define SR_RE 0x02000000 /* Reverse endian in user mode */ + +#define SR_BEV 0x00400000 /* Use boot exception vectors */ +#define SR_TS 0x00200000 /* TLB shutdown */ +#define SR_SR 0x00100000 /* Soft reset */ +#define SR_CH 0x00040000 /* Cache hit */ +#define SR_CE 0x00020000 /* Use cache ECC */ +#define SR_DE 0x00010000 /* Disable cache exceptions */ + +/* +** status register interrupt masks and bits +*/ + +#define SR_IMASK 0x0000ff00 /* Interrupt mask */ +#define SR_IMASK8 0x00000000 /* mask level 8 */ +#define SR_IMASK7 0x00008000 /* mask level 7 */ +#define SR_IMASK6 0x0000c000 /* mask level 6 */ +#define SR_IMASK5 0x0000e000 /* mask level 5 */ +#define SR_IMASK4 0x0000f000 /* mask level 4 */ +#define SR_IMASK3 0x0000f800 /* mask level 3 */ +#define SR_IMASK2 0x0000fc00 /* mask level 2 */ +#define SR_IMASK1 0x0000fe00 /* mask level 1 */ +#define SR_IMASK0 0x0000ff00 /* mask level 0 */ + +#define SR_IMASKSHIFT 8 + +#define SR_IBIT8 0x00008000 /* bit level 8 */ +#define SR_IBIT7 0x00004000 /* bit level 7 */ +#define SR_IBIT6 0x00002000 /* bit level 6 */ +#define SR_IBIT5 0x00001000 /* bit level 5 */ +#define SR_IBIT4 0x00000800 /* bit level 4 */ +#define SR_IBIT3 0x00000400 /* bit level 3 */ +#define SR_IBIT2 0x00000200 /* bit level 2 */ +#define SR_IBIT1 0x00000100 /* bit level 1 */ + +#define SR_KSMASK 0x00000018 /* Kernel mode mask */ +#define SR_KSUSER 0x00000010 /* User mode */ +#define SR_KSSUPER 0x00000008 /* Supervisor mode */ +#define SR_KSKERNEL 0x00000000 /* Kernel mode */ +#define SR_ERL 0x00000004 /* Error level */ +#define SR_EXL 0x00000002 /* Exception level */ +#define SR_IE 0x00000001 /* Interrupts enabled */ +#endif + +#if __mips == 32 +#define SR_CUMASK 0xf0000000 /* coproc usable bits */ +#define SR_CU3 0x80000000 /* Coprocessor 3 usable */ +#define SR_CU2 0x40000000 /* Coprocessor 2 usable */ +#define SR_CU1 0x20000000 /* Coprocessor 1 usable */ +#define SR_CU0 0x10000000 /* Coprocessor 0 usable */ + +#define SR_RP 0x08000000 /* Reduced power operation */ +#define SR_FR 0x04000000 /* Additional floating point registers */ +#define SR_RE 0x02000000 /* Reverse endian in user mode */ + +#define SR_BEV 0x00400000 /* Use boot exception vectors */ +#define SR_TS 0x00200000 /* TLB shutdown */ +#define SR_SR 0x00100000 /* Soft reset */ +#define SR_CH 0x00040000 /* Cache hit */ +#define SR_CE 0x00020000 /* Use cache ECC */ +#define SR_DE 0x00010000 /* Disable cache exceptions */ + +/* +** status register interrupt masks and bits +*/ + +#define SR_IMASK 0x0000ff00 /* Interrupt mask */ +#define SR_IMASK8 0x00000000 /* mask level 8 */ +#define SR_IMASK7 0x00008000 /* mask level 7 */ +#define SR_IMASK6 0x0000c000 /* mask level 6 */ +#define SR_IMASK5 0x0000e000 /* mask level 5 */ +#define SR_IMASK4 0x0000f000 /* mask level 4 */ +#define SR_IMASK3 0x0000f800 /* mask level 3 */ +#define SR_IMASK2 0x0000fc00 /* mask level 2 */ +#define SR_IMASK1 0x0000fe00 /* mask level 1 */ +#define SR_IMASK0 0x0000ff00 /* mask level 0 */ + +#define SR_IMASKSHIFT 8 + +#define SR_IBIT8 0x00008000 /* bit level 8 */ +#define SR_IBIT7 0x00004000 /* bit level 7 */ +#define SR_IBIT6 0x00002000 /* bit level 6 */ +#define SR_IBIT5 0x00001000 /* bit level 5 */ +#define SR_IBIT4 0x00000800 /* bit level 4 */ +#define SR_IBIT3 0x00000400 /* bit level 3 */ +#define SR_IBIT2 0x00000200 /* bit level 2 */ +#define SR_IBIT1 0x00000100 /* bit level 1 */ + +#define SR_KSMASK 0x00000018 /* Kernel mode mask */ +#define SR_KSUSER 0x00000010 /* User mode */ +#define SR_KSSUPER 0x00000008 /* Supervisor mode */ +#define SR_KSKERNEL 0x00000000 /* Kernel mode */ +#define SR_ERL 0x00000004 /* Error level */ +#define SR_EXL 0x00000002 /* Exception level */ +#define SR_IE 0x00000001 /* Interrupts enabled */ +#endif + +/* + * Cause Register + */ +#define CAUSE_BD 0x80000000 /* Branch delay slot */ +#define CAUSE_BT 0x40000000 /* Branch Taken */ +#define CAUSE_CEMASK 0x30000000 /* coprocessor error */ +#define CAUSE_CESHIFT 28 + + +#define CAUSE_IPMASK 0x0000FF00 /* Pending interrupt mask */ +#define CAUSE_IPSHIFT 8 + +#define CAUSE_EXCMASK 0x0000003C /* Cause code bits */ +#define CAUSE_EXCSHIFT 2 + +#ifndef XDS +/* +** Coprocessor 0 registers +*/ +#define C0_INX $0 /* tlb index */ +#define C0_RAND $1 /* tlb random */ +#if __mips == 1 +#define C0_TLBLO $2 /* tlb entry low */ +#endif +#if __mips == 3 +#define C0_TLBLO0 $2 /* tlb entry low 0 */ +#define C0_TLBLO1 $3 /* tlb entry low 1 */ +#endif + +#if __mips == 32 +#define C0_TLBLO0 $2 /* tlb entry low 0 */ +#define C0_TLBLO1 $3 /* tlb entry low 1 */ +#endif + + +#define C0_CTXT $4 /* tlb context */ + +#if __mips == 3 +#define C0_PAGEMASK $5 /* tlb page mask */ +#define C0_WIRED $6 /* number of wired tlb entries */ +#endif + +#if __mips == 32 +#define C0_PAGEMASK $5 /* tlb page mask */ +#define C0_WIRED $6 /* number of wired tlb entries */ +#endif + +#if __mips == 1 +#define C0_TAR $6 +#endif + +#define C0_BADVADDR $8 /* bad virtual address */ + +#if __mips == 3 +#define C0_COUNT $9 /* cycle count */ +#endif +#if __mips == 32 +#define C0_COUNT $9 /* cycle count */ +#endif + +#define C0_TLBHI $10 /* tlb entry hi */ + +#if __mips == 3 +#define C0_COMPARE $11 /* cyccle count comparator */ +#endif + +#if __mips == 32 +#define C0_COMPARE $11 /* cyccle count comparator */ +#endif + +#define C0_SR $12 /* status register */ +#define C0_CAUSE $13 /* exception cause */ +#define C0_EPC $14 /* exception pc */ +#define C0_PRID $15 /* revision identifier */ + +#if __mips == 1 +#define C0_CONFIG $3 /* configuration register R3081*/ +#endif + +#if __mips == 3 +#define C0_CONFIG $16 /* configuration register */ +#define C0_LLADDR $17 /* linked load address */ +#define C0_WATCHLO $18 /* watchpoint trap register */ +#define C0_WATCHHI $19 /* watchpoint trap register */ +#define C0_XCTXT $20 /* extended tlb context */ +#define C0_ECC $26 /* secondary cache ECC control */ +#define C0_CACHEERR $27 /* cache error status */ +#define C0_TAGLO $28 /* cache tag lo */ +#define C0_TAGHI $29 /* cache tag hi */ +#define C0_ERRPC $30 /* cache error pc */ +#endif + +#if __mips == 32 +#define C0_CONFIG $16 /* configuration register */ +#define C0_LLADDR $17 /* linked load address */ +#define C0_WATCHLO $18 /* watchpoint trap register */ +#define C0_WATCHHI $19 /* watchpoint trap register */ +#define C0_XCTXT $20 /* extended tlb context */ +#define C0_ECC $26 /* secondary cache ECC control */ +#define C0_CACHEERR $27 /* cache error status */ +#define C0_TAGLO $28 /* cache tag lo */ +#define C0_TAGHI $29 /* cache tag hi */ +#define C0_ERRPC $30 /* cache error pc */ +#endif + + +#define C1_REVISION $0 +#define C1_STATUS $31 + +#endif /* XDS */ + +#ifdef R4650 +#define IWATCH $18 +#define DWATCH $19 +#define IBASE $0 +#define IBOUND $1 +#define DBASE $2 +#define DBOUND $3 +#define CALG $17 +#endif + +/**@}*/ +#endif /* _RTEMS_MIPS_IDTCPU_H */ diff --git a/cpukit/score/cpu/mips/include/rtems/mips/iregdef.h b/cpukit/score/cpu/mips/include/rtems/mips/iregdef.h new file mode 100644 index 0000000000..5d41074184 --- /dev/null +++ b/cpukit/score/cpu/mips/include/rtems/mips/iregdef.h @@ -0,0 +1,337 @@ +/** + * @file iregdef.h + * + * @brief IDT R3000 Register Structure + * + * 950313: Ketan added sreg/lreg and R_SZ for 64-bit saves + * added Register definition for XContext reg. + * Look towards end of this file. + */ + +/* + * Copyright 1989 Integrated Device Technology, Inc + * All Rights Reserved + * + * Based upon IDT provided code with the following release: + * + * This source code has been made available to you by IDT on an AS-IS + * basis. Anyone receiving this source is licensed under IDT copyrights + * to use it in any way he or she deems fit, including copying it, + * modifying it, compiling it, and redistributing it either with or + * without modifications. No license under IDT patents or patent + * applications is to be implied by the copyright license. + * + * Any user of this software should understand that IDT cannot provide + * technical support for this software and will not be responsible for + * any consequences resulting from the use of this software. + * + * Any person who transfers this source code or any derivative work must + * include the IDT copyright notice, this paragraph, and the preceeding + * two paragraphs in the transferred software. + * + * COPYRIGHT IDT CORPORATION 1996 + * LICENSED MATERIAL - PROGRAM PROPERTY OF IDT + */ + +#ifndef _RTEMS_MIPS_IREGDEF_H +#define _RTEMS_MIPS_IREGDEF_H + +/** + * @defgroup MipsSet_iregdef Register Structure + * + * @ingroup MIPS + * + */ +/**@{*/ + +/* register names */ + +#define r0 $0 +#define r1 $1 +#define r2 $2 +#define r3 $3 +#define r4 $4 +#define r5 $5 +#define r6 $6 +#define r7 $7 +#define r8 $8 +#define r9 $9 +#define r10 $10 +#define r11 $11 +#define r12 $12 +#define r13 $13 + +#define r14 $14 +#define r15 $15 +#define r16 $16 +#define r17 $17 +#define r18 $18 +#define r19 $19 +#define r20 $20 +#define r21 $21 +#define r22 $22 +#define r23 $23 +#define r24 $24 +#define r25 $25 +#define r26 $26 +#define r27 $27 +#define r28 $28 +#define r29 $29 +#define r30 $30 +#define r31 $31 + +#define fp0 $f0 +#define fp1 $f1 +#define fp2 $f2 +#define fp3 $f3 +#define fp4 $f4 +#define fp5 $f5 +#define fp6 $f6 +#define fp7 $f7 +#define fp8 $f8 +#define fp9 $f9 +#define fp10 $f10 +#define fp11 $f11 +#define fp12 $f12 +#define fp13 $f13 +#define fp14 $f14 +#define fp15 $f15 +#define fp16 $f16 +#define fp17 $f17 +#define fp18 $f18 +#define fp19 $f19 +#define fp20 $f20 +#define fp21 $f21 +#define fp22 $f22 +#define fp23 $f23 +#define fp24 $f24 +#define fp25 $f25 +#define fp26 $f26 +#define fp27 $f27 +#define fp28 $f28 +#define fp29 $f29 +#define fp30 $f30 +#define fp31 $f31 + +#define fcr0 $0 +#define fcr30 $30 +#define fcr31 $31 + +#define zero $0 /* wired zero */ +#define AT $at /* assembler temp */ +#define v0 $2 /* return value */ +#define v1 $3 +#define a0 $4 /* argument registers a0-a3 */ +#define a1 $5 +#define a2 $6 +#define a3 $7 +#define t0 $8 /* caller saved t0-t9 */ +#define t1 $9 +#define t2 $10 +#define t3 $11 +#define t4 $12 +#define t5 $13 +#define t6 $14 +#define t7 $15 +#define s0 $16 /* callee saved s0-s8 */ +#define s1 $17 +#define s2 $18 +#define s3 $19 +#define s4 $20 +#define s5 $21 +#define s6 $22 +#define s7 $23 +#define t8 $24 +#define t9 $25 +#define k0 $26 /* kernel usage */ +#define k1 $27 /* kernel usage */ +#define gp $28 /* sdata pointer */ +#define sp $29 /* stack pointer */ +#define s8 $30 /* yet another saved reg for the callee */ +#define fp $30 /* frame pointer - this is being phased out by MIPS */ +#define ra $31 /* return address */ + + +/* +** relative position of registers in interrupt/exception frame +*/ +#define R_R0 0 +#define R_R1 1 +#define R_R2 2 +#define R_R3 3 +#define R_R4 4 +#define R_R5 5 +#define R_R6 6 +#define R_R7 7 +#define R_R8 8 +#define R_R9 9 +#define R_R10 10 +#define R_R11 11 +#define R_R12 12 +#define R_R13 13 +#define R_R14 14 +#define R_R15 15 +#define R_R16 16 +#define R_R17 17 +#define R_R18 18 +#define R_R19 19 +#define R_R20 20 +#define R_R21 21 +#define R_R22 22 +#define R_R23 23 +#define R_R24 24 +#define R_R25 25 +#define R_R26 26 +#define R_R27 27 +#define R_R28 28 +#define R_R29 29 +#define R_R30 30 +#define R_R31 31 + +#define R_SR 32 +#define R_MDLO 33 +#define R_MDHI 34 +#define R_BADVADDR 35 +#define R_CAUSE 36 +#define R_EPC 37 + +#define R_F0 38 +#define R_F1 39 +#define R_F2 40 +#define R_F3 41 +#define R_F4 42 +#define R_F5 43 +#define R_F6 44 +#define R_F7 45 +#define R_F8 46 +#define R_F9 47 +#define R_F10 48 +#define R_F11 49 +#define R_F12 50 +#define R_F13 41 +#define R_F14 42 +#define R_F15 43 +#define R_F16 44 +#define R_F17 45 +#define R_F18 56 +#define R_F19 57 +#define R_F20 58 +#define R_F21 59 +#define R_F22 60 +#define R_F23 61 +#define R_F24 62 +#define R_F25 63 +#define R_F26 64 +#define R_F27 65 +#define R_F28 66 +#define R_F29 67 +#define R_F30 68 +#define R_F31 69 +#define R_FCSR 70 +#define R_FEIR 71 +#define R_TLBHI 72 + +#if __mips == 1 +#define R_TLBLO 73 +#endif +#if (__mips == 3 ) || ( __mips == 32) +#define R_TLBLO0 73 +#endif + +#define R_INX 74 +#define R_RAND 75 +#define R_CTXT 76 +#define R_EXCTYPE 77 +#define R_MODE 78 +#define R_PRID 79 +#define R_TAR 80 +#if __mips == 1 +#define NREGS 81 +#endif +#if (__mips == 3 ) || ( __mips == 32) +#define R_TLBLO1 81 +#define R_PAGEMASK 82 +#define R_WIRED 83 +#define R_COUNT 84 +#define R_COMPARE 85 +#define R_CONFIG 86 +#define R_LLADDR 87 +#define R_WATCHLO 88 +#define R_WATCHHI 89 +#define R_ECC 90 +#define R_CACHEERR 91 +#define R_TAGLO 92 +#define R_TAGHI 93 +#define R_ERRPC 94 +#define R_XCTXT 95 /* Ketan added from SIM64bit */ + +#define NREGS 96 +#endif + +/* +** For those who like to think in terms of the compiler names for the regs +*/ +#define R_ZERO R_R0 +#define R_AT R_R1 +#define R_V0 R_R2 +#define R_V1 R_R3 +#define R_A0 R_R4 +#define R_A1 R_R5 +#define R_A2 R_R6 +#define R_A3 R_R7 +#define R_T0 R_R8 +#define R_T1 R_R9 +#define R_T2 R_R10 +#define R_T3 R_R11 +#define R_T4 R_R12 +#define R_T5 R_R13 +#define R_T6 R_R14 +#define R_T7 R_R15 +#define R_S0 R_R16 +#define R_S1 R_R17 +#define R_S2 R_R18 +#define R_S3 R_R19 +#define R_S4 R_R20 +#define R_S5 R_R21 +#define R_S6 R_R22 +#define R_S7 R_R23 +#define R_T8 R_R24 +#define R_T9 R_R25 +#define R_K0 R_R26 +#define R_K1 R_R27 +#define R_GP R_R28 +#define R_SP R_R29 +#define R_FP R_R30 +#define R_RA R_R31 + +/* disabled for RTEMS */ +#if 0 +/* Ketan added the following */ +#if __mips == 1 +#define sreg sw +#define lreg lw +#define rmfc0 mfc0 +#define rmtc0 mtc0 +#define R_SZ 4 +#endif /* __mips == 1 */ + +/* #ifdef __mips == 3 */ +#if __mips < 3 +#define sreg sw +#define lreg lw +#define rmfc0 mfc0 +#define rmtc0 mtc0 +#define R_SZ 4 +#else +#define sreg sd +#define lreg ld +#define rmfc0 dmfc0 +#define rmtc0 dmtc0 +#define R_SZ 8 +#endif +/* #endif __mips == 3 */ +/* Ketan till here */ +#endif + +/**@}*/ +#endif /* _RTEMS_MIPS_IREGDEF_H */ diff --git a/cpukit/score/cpu/mips/include/rtems/score/cpu.h b/cpukit/score/cpu/mips/include/rtems/score/cpu.h new file mode 100644 index 0000000000..74afc800b9 --- /dev/null +++ b/cpukit/score/cpu/mips/include/rtems/score/cpu.h @@ -0,0 +1,1010 @@ +/** + * @file + * + * @brief Mips CPU Dependent Header File + */ + +/* + * Conversion to MIPS port by Alan Cudmore and + * Joel Sherrill . + * + * These changes made the code conditional on standard cpp predefines, + * merged the mips1 and mips3 code sequences as much as possible, + * and moved some of the assembly code to C. Alan did much of the + * initial analysis and rework. Joel took over from there and + * wrote the JMR3904 BSP so this could be tested. Joel also + * added the new interrupt vectoring support in libcpu and + * tried to better support the various interrupt controllers. + * + */ + +/* + * Original MIP64ORION port by Craig Lebakken + * COPYRIGHT (c) 1996 by Transition Networks Inc. + * + * To anyone who acknowledges that this file is provided "AS IS" + * without any express or implied warranty: + * permission to use, copy, modify, and distribute this file + * for any purpose is hereby granted without fee, provided that + * the above copyright notice and this notice appears in all + * copies, and that the name of Transition Networks not be used in + * advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * Transition Networks makes no representations about the suitability + * of this software for any purpose. + * + * COPYRIGHT (c) 1989-2012. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPU_H +#define _RTEMS_SCORE_CPU_H + +/** + * @defgroup ScoreCPU CPU CPU + * + * @ingroup Score + * + */ +/**@{*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* conditional compilation parameters */ + +/* + * Does RTEMS manage a dedicated interrupt stack in software? + * + * If TRUE, then a stack is allocated in _Interrupt_Manager_initialization. + * If FALSE, nothing is done. + * + * If the CPU supports a dedicated interrupt stack in hardware, + * then it is generally the responsibility of the BSP to allocate it + * and set it up. + * + * If the CPU does not support a dedicated interrupt stack, then + * the porter has two options: (1) execute interrupts on the + * stack of the interrupted task, and (2) have RTEMS manage a dedicated + * interrupt stack. + * + * If this is TRUE, CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. + * + * Only one of CPU_HAS_SOFTWARE_INTERRUPT_STACK and + * CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is + * possible that both are FALSE for a particular CPU. Although it + * is unclear what that would imply about the interrupt processing + * procedure on that CPU. + */ + +#define CPU_HAS_SOFTWARE_INTERRUPT_STACK FALSE + +/* + * Does the CPU follow the simple vectored interrupt model? + * + * If TRUE, then RTEMS allocates the vector table it internally manages. + * If FALSE, then the BSP is assumed to allocate and manage the vector + * table + * + * MIPS Specific Information: + * + * Up to and including RTEMS 4.10, the MIPS port used simple vectored + * interrupts. But this was changed to the PIC model after 4.10. + */ +#define CPU_SIMPLE_VECTORED_INTERRUPTS FALSE + +/* + * Does this CPU have hardware support for a dedicated interrupt stack? + * + * If TRUE, then it must be installed during initialization. + * If FALSE, then no installation is performed. + * + * If this is TRUE, CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. + * + * Only one of CPU_HAS_SOFTWARE_INTERRUPT_STACK and + * CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is + * possible that both are FALSE for a particular CPU. Although it + * is unclear what that would imply about the interrupt processing + * procedure on that CPU. + */ + +#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE + +/* + * Does RTEMS allocate a dedicated interrupt stack in the Interrupt Manager? + * + * If TRUE, then the memory is allocated during initialization. + * If FALSE, then the memory is allocated during initialization. + * + * This should be TRUE is CPU_HAS_SOFTWARE_INTERRUPT_STACK is TRUE. + */ + +#define CPU_ALLOCATE_INTERRUPT_STACK FALSE + +/* + * Does the RTEMS invoke the user's ISR with the vector number and + * a pointer to the saved interrupt frame (1) or just the vector + * number (0)? + * + */ + +#define CPU_ISR_PASSES_FRAME_POINTER TRUE + + + +/* + * Does the CPU have hardware floating point? + * + * If TRUE, then the RTEMS_FLOATING_POINT task attribute is supported. + * If FALSE, then the RTEMS_FLOATING_POINT task attribute is ignored. + * + * If there is a FP coprocessor such as the i387 or mc68881, then + * the answer is TRUE. + * + * The macro name "MIPS_HAS_FPU" should be made CPU specific. + * It indicates whether or not this CPU model has FP support. For + * example, it would be possible to have an i386_nofp CPU model + * which set this to false to indicate that you have an i386 without + * an i387 and wish to leave floating point support out of RTEMS. + */ + +#if ( MIPS_HAS_FPU == 1 ) +#define CPU_HARDWARE_FP TRUE +#else +#define CPU_HARDWARE_FP FALSE +#endif + +/* + * Are all tasks RTEMS_FLOATING_POINT tasks implicitly? + * + * If TRUE, then the RTEMS_FLOATING_POINT task attribute is assumed. + * If FALSE, then the RTEMS_FLOATING_POINT task attribute is followed. + * + * So far, the only CPU in which this option has been used is the + * HP PA-RISC. The HP C compiler and gcc both implicitly use the + * floating point registers to perform integer multiplies. If + * a function which you would not think utilize the FP unit DOES, + * then one can not easily predict which tasks will use the FP hardware. + * In this case, this option should be TRUE. + * + * If CPU_HARDWARE_FP is FALSE, then this should be FALSE as well. + * + * Mips Note: It appears the GCC can implicitly generate FPU + * and Altivec instructions when you least expect them. So make + * all tasks floating point. + */ + +#define CPU_ALL_TASKS_ARE_FP CPU_HARDWARE_FP + +/* + * Should the IDLE task have a floating point context? + * + * If TRUE, then the IDLE task is created as a RTEMS_FLOATING_POINT task + * and it has a floating point context which is switched in and out. + * If FALSE, then the IDLE task does not have a floating point context. + * + * Setting this to TRUE negatively impacts the time required to preempt + * the IDLE task from an interrupt because the floating point context + * must be saved as part of the preemption. + */ + +#define CPU_IDLE_TASK_IS_FP FALSE + +/* + * Should the saving of the floating point registers be deferred + * until a context switch is made to another different floating point + * task? + * + * If TRUE, then the floating point context will not be stored until + * necessary. It will remain in the floating point registers and not + * disturned until another floating point task is switched to. + * + * If FALSE, then the floating point context is saved when a floating + * point task is switched out and restored when the next floating point + * task is restored. The state of the floating point registers between + * those two operations is not specified. + * + * If the floating point context does NOT have to be saved as part of + * interrupt dispatching, then it should be safe to set this to TRUE. + * + * Setting this flag to TRUE results in using a different algorithm + * for deciding when to save and restore the floating point context. + * The deferred FP switch algorithm minimizes the number of times + * the FP context is saved and restored. The FP context is not saved + * until a context switch is made to another, different FP task. + * Thus in a system with only one FP task, the FP context will never + * be saved or restored. + */ + +#define CPU_USE_DEFERRED_FP_SWITCH TRUE + +#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE + +/* + * Does this port provide a CPU dependent IDLE task implementation? + * + * If TRUE, then the routine _CPU_Internal_threads_Idle_thread_body + * must be provided and is the default IDLE thread body instead of + * _Internal_threads_Idle_thread_body. + * + * If FALSE, then use the generic IDLE thread body if the BSP does + * not provide one. + * + * This is intended to allow for supporting processors which have + * a low power or idle mode. When the IDLE thread is executed, then + * the CPU can be powered down. + * + * The order of precedence for selecting the IDLE thread body is: + * + * 1. BSP provided + * 2. CPU dependent (if provided) + * 3. generic (if no BSP and no CPU dependent) + */ + +/* we can use the low power wait instruction for the IDLE thread */ +#define CPU_PROVIDES_IDLE_THREAD_BODY TRUE + +/* + * Does the stack grow up (toward higher addresses) or down + * (toward lower addresses)? + * + * If TRUE, then the grows upward. + * If FALSE, then the grows toward smaller addresses. + */ + +/* our stack grows down */ +#define CPU_STACK_GROWS_UP FALSE + +/* FIXME: Is this the right value? */ +#define CPU_CACHE_LINE_BYTES 16 + +#define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES ) + +/* + * The following defines the number of bits actually used in the + * interrupt field of the task mode. How those bits map to the + * CPU interrupt levels is defined by the routine _CPU_ISR_Set_level(). + */ + +#define CPU_MODES_INTERRUPT_MASK 0x000000ff + +#define CPU_SIZEOF_POINTER 4 + +#define CPU_MAXIMUM_PROCESSORS 32 + +/* + * Processor defined structures + * + * Examples structures include the descriptor tables from the i386 + * and the processor control structure on the i960ca. + */ + +/* may need to put some structures here. */ + +/* + * Contexts + * + * Generally there are 2 types of context to save. + * 1. Interrupt registers to save + * 2. Task level registers to save + * + * This means we have the following 3 context items: + * 1. task level context stuff:: Context_Control + * 2. floating point task stuff:: Context_Control_fp + * 3. special interrupt level context :: Context_Control_interrupt + * + * On some processors, it is cost-effective to save only the callee + * preserved registers during a task context switch. This means + * that the ISR code needs to save those registers which do not + * persist across function calls. It is not mandatory to make this + * distinctions between the caller/callee saves registers for the + * purpose of minimizing context saved during task switch and on interrupts. + * If the cost of saving extra registers is minimal, simplicity is the + * choice. Save the same context on interrupt entry as for tasks in + * this case. + * + * Additionally, if gdb is to be made aware of RTEMS tasks for this CPU, then + * care should be used in designing the context area. + * + * On some CPUs with hardware floating point support, the Context_Control_fp + * structure will not be used or it simply consist of an array of a + * fixed number of bytes. This is done when the floating point context + * is dumped by a "FP save context" type instruction and the format + * is not really defined by the CPU. In this case, there is no need + * to figure out the exact format -- only the size. Of course, although + * this is enough information for RTEMS, it is probably not enough for + * a debugger such as gdb. But that is another problem. + */ + +#ifndef ASM + +/* WARNING: If this structure is modified, the constants in cpu.h must be updated. */ +#if (__mips == 1) || (__mips == 32) +#define __MIPS_REGISTER_TYPE uint32_t +#define __MIPS_FPU_REGISTER_TYPE uint32_t +#elif __mips == 3 +#define __MIPS_REGISTER_TYPE uint64_t +#define __MIPS_FPU_REGISTER_TYPE uint64_t +#else +#error "mips register size: unknown architecture level!!" +#endif +typedef struct { + __MIPS_REGISTER_TYPE s0; + __MIPS_REGISTER_TYPE s1; + __MIPS_REGISTER_TYPE s2; + __MIPS_REGISTER_TYPE s3; + __MIPS_REGISTER_TYPE s4; + __MIPS_REGISTER_TYPE s5; + __MIPS_REGISTER_TYPE s6; + __MIPS_REGISTER_TYPE s7; + __MIPS_REGISTER_TYPE sp; + __MIPS_REGISTER_TYPE fp; + __MIPS_REGISTER_TYPE ra; + __MIPS_REGISTER_TYPE c0_sr; + __MIPS_REGISTER_TYPE c0_epc; +} Context_Control; + +#define _CPU_Context_Get_SP( _context ) \ + (uintptr_t) (_context)->sp + +/* WARNING: If this structure is modified, the constants in cpu.h + * must also be updated. + */ + +typedef struct { +#if ( CPU_HARDWARE_FP == TRUE ) + __MIPS_FPU_REGISTER_TYPE fp0; + __MIPS_FPU_REGISTER_TYPE fp1; + __MIPS_FPU_REGISTER_TYPE fp2; + __MIPS_FPU_REGISTER_TYPE fp3; + __MIPS_FPU_REGISTER_TYPE fp4; + __MIPS_FPU_REGISTER_TYPE fp5; + __MIPS_FPU_REGISTER_TYPE fp6; + __MIPS_FPU_REGISTER_TYPE fp7; + __MIPS_FPU_REGISTER_TYPE fp8; + __MIPS_FPU_REGISTER_TYPE fp9; + __MIPS_FPU_REGISTER_TYPE fp10; + __MIPS_FPU_REGISTER_TYPE fp11; + __MIPS_FPU_REGISTER_TYPE fp12; + __MIPS_FPU_REGISTER_TYPE fp13; + __MIPS_FPU_REGISTER_TYPE fp14; + __MIPS_FPU_REGISTER_TYPE fp15; + __MIPS_FPU_REGISTER_TYPE fp16; + __MIPS_FPU_REGISTER_TYPE fp17; + __MIPS_FPU_REGISTER_TYPE fp18; + __MIPS_FPU_REGISTER_TYPE fp19; + __MIPS_FPU_REGISTER_TYPE fp20; + __MIPS_FPU_REGISTER_TYPE fp21; + __MIPS_FPU_REGISTER_TYPE fp22; + __MIPS_FPU_REGISTER_TYPE fp23; + __MIPS_FPU_REGISTER_TYPE fp24; + __MIPS_FPU_REGISTER_TYPE fp25; + __MIPS_FPU_REGISTER_TYPE fp26; + __MIPS_FPU_REGISTER_TYPE fp27; + __MIPS_FPU_REGISTER_TYPE fp28; + __MIPS_FPU_REGISTER_TYPE fp29; + __MIPS_FPU_REGISTER_TYPE fp30; + __MIPS_FPU_REGISTER_TYPE fp31; + uint32_t fpcs; +#endif +} Context_Control_fp; + +/* + * This struct reflects the stack frame employed in ISR_Handler. Note + * that the ISR routine save some of the registers to this frame for + * all interrupts and exceptions. Other registers are saved only on + * exceptions, while others are not touched at all. The untouched + * registers are not normally disturbed by high-level language + * programs so they can be accessed when required. + * + * The registers and their ordering in this struct must directly + * correspond to the layout and ordering of * shown in iregdef.h, + * as cpu_asm.S uses those definitions to fill the stack frame. + * This struct provides access to the stack frame for C code. + * + * Similarly, this structure is used by debugger stubs and exception + * processing routines so be careful when changing the format. + * + * NOTE: The comments with this structure and cpu_asm.S should be kept + * in sync. When in doubt, look in the code to see if the + * registers you're interested in are actually treated as expected. + * The order of the first portion of this structure follows the + * order of registers expected by gdb. + */ + +typedef struct +{ + __MIPS_REGISTER_TYPE r0; /* 0 -- NOT FILLED IN */ + __MIPS_REGISTER_TYPE at; /* 1 -- saved always */ + __MIPS_REGISTER_TYPE v0; /* 2 -- saved always */ + __MIPS_REGISTER_TYPE v1; /* 3 -- saved always */ + __MIPS_REGISTER_TYPE a0; /* 4 -- saved always */ + __MIPS_REGISTER_TYPE a1; /* 5 -- saved always */ + __MIPS_REGISTER_TYPE a2; /* 6 -- saved always */ + __MIPS_REGISTER_TYPE a3; /* 7 -- saved always */ + __MIPS_REGISTER_TYPE t0; /* 8 -- saved always */ + __MIPS_REGISTER_TYPE t1; /* 9 -- saved always */ + __MIPS_REGISTER_TYPE t2; /* 10 -- saved always */ + __MIPS_REGISTER_TYPE t3; /* 11 -- saved always */ + __MIPS_REGISTER_TYPE t4; /* 12 -- saved always */ + __MIPS_REGISTER_TYPE t5; /* 13 -- saved always */ + __MIPS_REGISTER_TYPE t6; /* 14 -- saved always */ + __MIPS_REGISTER_TYPE t7; /* 15 -- saved always */ + __MIPS_REGISTER_TYPE s0; /* 16 -- saved on exceptions */ + __MIPS_REGISTER_TYPE s1; /* 17 -- saved on exceptions */ + __MIPS_REGISTER_TYPE s2; /* 18 -- saved on exceptions */ + __MIPS_REGISTER_TYPE s3; /* 19 -- saved on exceptions */ + __MIPS_REGISTER_TYPE s4; /* 20 -- saved on exceptions */ + __MIPS_REGISTER_TYPE s5; /* 21 -- saved on exceptions */ + __MIPS_REGISTER_TYPE s6; /* 22 -- saved on exceptions */ + __MIPS_REGISTER_TYPE s7; /* 23 -- saved on exceptions */ + __MIPS_REGISTER_TYPE t8; /* 24 -- saved always */ + __MIPS_REGISTER_TYPE t9; /* 25 -- saved always */ + __MIPS_REGISTER_TYPE k0; /* 26 -- NOT FILLED IN, kernel tmp reg */ + __MIPS_REGISTER_TYPE k1; /* 27 -- NOT FILLED IN, kernel tmp reg */ + __MIPS_REGISTER_TYPE gp; /* 28 -- saved always */ + __MIPS_REGISTER_TYPE sp; /* 29 -- saved on exceptions NOT RESTORED */ + __MIPS_REGISTER_TYPE fp; /* 30 -- saved always */ + __MIPS_REGISTER_TYPE ra; /* 31 -- saved always */ + __MIPS_REGISTER_TYPE c0_sr; /* 32 -- saved always, some bits are */ + /* manipulated per-thread */ + __MIPS_REGISTER_TYPE mdlo; /* 33 -- saved always */ + __MIPS_REGISTER_TYPE mdhi; /* 34 -- saved always */ + __MIPS_REGISTER_TYPE badvaddr; /* 35 -- saved on exceptions, read-only */ + __MIPS_REGISTER_TYPE cause; /* 36 -- saved on exceptions NOT restored */ + __MIPS_REGISTER_TYPE epc; /* 37 -- saved always, read-only register */ + /* but logically restored */ + __MIPS_FPU_REGISTER_TYPE f0; /* 38 -- saved if FP enabled */ + __MIPS_FPU_REGISTER_TYPE f1; /* 39 -- saved if FP enabled */ + __MIPS_FPU_REGISTER_TYPE f2; /* 40 -- saved if FP enabled */ + __MIPS_FPU_REGISTER_TYPE f3; /* 41 -- saved if FP enabled */ + __MIPS_FPU_REGISTER_TYPE f4; /* 42 -- saved if FP enabled */ + __MIPS_FPU_REGISTER_TYPE f5; /* 43 -- saved if FP enabled */ + __MIPS_FPU_REGISTER_TYPE f6; /* 44 -- saved if FP enabled */ + __MIPS_FPU_REGISTER_TYPE f7; /* 45 -- saved if FP enabled */ + __MIPS_FPU_REGISTER_TYPE f8; /* 46 -- saved if FP enabled */ + __MIPS_FPU_REGISTER_TYPE f9; /* 47 -- saved if FP enabled */ + __MIPS_FPU_REGISTER_TYPE f10; /* 48 -- saved if FP enabled */ + __MIPS_FPU_REGISTER_TYPE f11; /* 49 -- saved if FP enabled */ + __MIPS_FPU_REGISTER_TYPE f12; /* 50 -- saved if FP enabled */ + __MIPS_FPU_REGISTER_TYPE f13; /* 51 -- saved if FP enabled */ + __MIPS_FPU_REGISTER_TYPE f14; /* 52 -- saved if FP enabled */ + __MIPS_FPU_REGISTER_TYPE f15; /* 53 -- saved if FP enabled */ + __MIPS_FPU_REGISTER_TYPE f16; /* 54 -- saved if FP enabled */ + __MIPS_FPU_REGISTER_TYPE f17; /* 55 -- saved if FP enabled */ + __MIPS_FPU_REGISTER_TYPE f18; /* 56 -- saved if FP enabled */ + __MIPS_FPU_REGISTER_TYPE f19; /* 57 -- saved if FP enabled */ + __MIPS_FPU_REGISTER_TYPE f20; /* 58 -- saved if FP enabled */ + __MIPS_FPU_REGISTER_TYPE f21; /* 59 -- saved if FP enabled */ + __MIPS_FPU_REGISTER_TYPE f22; /* 60 -- saved if FP enabled */ + __MIPS_FPU_REGISTER_TYPE f23; /* 61 -- saved if FP enabled */ + __MIPS_FPU_REGISTER_TYPE f24; /* 62 -- saved if FP enabled */ + __MIPS_FPU_REGISTER_TYPE f25; /* 63 -- saved if FP enabled */ + __MIPS_FPU_REGISTER_TYPE f26; /* 64 -- saved if FP enabled */ + __MIPS_FPU_REGISTER_TYPE f27; /* 65 -- saved if FP enabled */ + __MIPS_FPU_REGISTER_TYPE f28; /* 66 -- saved if FP enabled */ + __MIPS_FPU_REGISTER_TYPE f29; /* 67 -- saved if FP enabled */ + __MIPS_FPU_REGISTER_TYPE f30; /* 68 -- saved if FP enabled */ + __MIPS_FPU_REGISTER_TYPE f31; /* 69 -- saved if FP enabled */ + __MIPS_REGISTER_TYPE fcsr; /* 70 -- saved on exceptions */ + /* (oddly not documented on MGV) */ + __MIPS_REGISTER_TYPE feir; /* 71 -- saved on exceptions */ + /* (oddly not documented on MGV) */ + + /* GDB does not seem to care about anything past this point */ + + __MIPS_REGISTER_TYPE tlbhi; /* 72 - NOT FILLED IN, doesn't exist on */ + /* all MIPS CPUs (at least MGV) */ +#if __mips == 1 + __MIPS_REGISTER_TYPE tlblo; /* 73 - NOT FILLED IN, doesn't exist on */ + /* all MIPS CPUs (at least MGV) */ +#endif +#if (__mips == 3) || (__mips == 32) + __MIPS_REGISTER_TYPE tlblo0; /* 73 - NOT FILLED IN, doesn't exist on */ + /* all MIPS CPUs (at least MGV) */ +#endif + + __MIPS_REGISTER_TYPE inx; /* 74 -- NOT FILLED IN, doesn't exist on */ + /* all MIPS CPUs (at least MGV) */ + __MIPS_REGISTER_TYPE rand; /* 75 -- NOT FILLED IN, doesn't exist on */ + /* all MIPS CPUs (at least MGV) */ + __MIPS_REGISTER_TYPE ctxt; /* 76 -- NOT FILLED IN, doesn't exist on */ + /* all MIPS CPUs (at least MGV) */ + __MIPS_REGISTER_TYPE exctype; /* 77 -- NOT FILLED IN (not enough info) */ + __MIPS_REGISTER_TYPE mode; /* 78 -- NOT FILLED IN (not enough info) */ + __MIPS_REGISTER_TYPE prid; /* 79 -- NOT FILLED IN (not need to do so) */ + __MIPS_REGISTER_TYPE tar ; /* 80 -- target address register, filled on exceptions */ + /* end of __mips == 1 so NREGS == 81 */ +#if (__mips == 3) || (__mips == 32) + __MIPS_REGISTER_TYPE tlblo1; /* 81 -- NOT FILLED IN */ + __MIPS_REGISTER_TYPE pagemask; /* 82 -- NOT FILLED IN */ + __MIPS_REGISTER_TYPE wired; /* 83 -- NOT FILLED IN */ + __MIPS_REGISTER_TYPE count; /* 84 -- NOT FILLED IN */ + __MIPS_REGISTER_TYPE compare; /* 85 -- NOT FILLED IN */ + __MIPS_REGISTER_TYPE config; /* 86 -- NOT FILLED IN */ + __MIPS_REGISTER_TYPE lladdr; /* 87 -- NOT FILLED IN */ + __MIPS_REGISTER_TYPE watchlo; /* 88 -- NOT FILLED IN */ + __MIPS_REGISTER_TYPE watchhi; /* 89 -- NOT FILLED IN */ + __MIPS_REGISTER_TYPE ecc; /* 90 -- NOT FILLED IN */ + __MIPS_REGISTER_TYPE cacheerr; /* 91 -- NOT FILLED IN */ + __MIPS_REGISTER_TYPE taglo; /* 92 -- NOT FILLED IN */ + __MIPS_REGISTER_TYPE taghi; /* 93 -- NOT FILLED IN */ + __MIPS_REGISTER_TYPE errpc; /* 94 -- NOT FILLED IN */ + __MIPS_REGISTER_TYPE xctxt; /* 95 -- NOT FILLED IN */ + /* end of __mips == 3 so NREGS == 96 */ +#endif + +} CPU_Interrupt_frame; + +typedef CPU_Interrupt_frame CPU_Exception_frame; + +/* + * This variable is optional. It is used on CPUs on which it is difficult + * to generate an "uninitialized" FP context. It is filled in by + * _CPU_Initialize and copied into the task's FP context area during + * _CPU_Context_Initialize. + */ + +extern Context_Control_fp _CPU_Null_fp_context; + +/* + * Nothing prevents the porter from declaring more CPU specific variables. + */ + +/* XXX: if needed, put more variables here */ + +/* + * The size of the floating point context area. On some CPUs this + * will not be a "sizeof" because the format of the floating point + * area is not defined -- only the size is. This is usually on + * CPUs with a "floating point save context" instruction. + */ + +#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp ) + +/* + * Amount of extra stack (above minimum stack size) required by + * system initialization thread. Remember that in a multiprocessor + * system the system intialization thread becomes the MP server thread. + */ + +#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0 + +/* + * Should be large enough to run all RTEMS tests. This ensures + * that a "reasonable" small application should not have any problems. + */ + +#define CPU_STACK_MINIMUM_SIZE (8 * 1024) + +/* + * CPU's worst alignment requirement for data types on a byte boundary. This + * alignment does not take into account the requirements for the stack. + */ + +#define CPU_ALIGNMENT 8 + +/* + * This number corresponds to the byte alignment requirement for the + * heap handler. This alignment requirement may be stricter than that + * for the data types alignment specified by CPU_ALIGNMENT. It is + * common for the heap to follow the same alignment requirement as + * CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict enough for the heap, + * then this should be set to CPU_ALIGNMENT. + * + * NOTE: This does not have to be a power of 2. It does have to + * be greater or equal to than CPU_ALIGNMENT. + */ + +#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT + +/* + * This number corresponds to the byte alignment requirement for memory + * buffers allocated by the partition manager. This alignment requirement + * may be stricter than that for the data types alignment specified by + * CPU_ALIGNMENT. It is common for the partition to follow the same + * alignment requirement as CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict + * enough for the partition, then this should be set to CPU_ALIGNMENT. + * + * NOTE: This does not have to be a power of 2. It does have to + * be greater or equal to than CPU_ALIGNMENT. + */ + +#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT + +/* + * This number corresponds to the byte alignment requirement for the + * stack. This alignment requirement may be stricter than that for the + * data types alignment specified by CPU_ALIGNMENT. If the CPU_ALIGNMENT + * is strict enough for the stack, then this should be set to 0. + * + * NOTE: This must be a power of 2 either 0 or greater than CPU_ALIGNMENT. + */ + +#define CPU_STACK_ALIGNMENT CPU_ALIGNMENT + +void mips_vector_exceptions( CPU_Interrupt_frame *frame ); + +/* + * ISR handler macros + */ + +/* + * Declare the function that is present in the shared libcpu directory, + * that returns the processor dependent interrupt mask. + */ + +uint32_t mips_interrupt_mask( void ); + +/* + * Disable all interrupts for an RTEMS critical section. The previous + * level is returned in _level. + */ + +#define _CPU_ISR_Disable( _level ) \ + do { \ + unsigned int _scratch; \ + mips_get_sr( _scratch ); \ + mips_set_sr( _scratch & ~SR_INTERRUPT_ENABLE_BITS ); \ + _level = _scratch & SR_INTERRUPT_ENABLE_BITS; \ + } while(0) + +/* + * Enable interrupts to the previous level (returned by _CPU_ISR_Disable). + * This indicates the end of an RTEMS critical section. The parameter + * _level is not modified. + */ + +#define _CPU_ISR_Enable( _level ) \ + do { \ + unsigned int _scratch; \ + mips_get_sr( _scratch ); \ + mips_set_sr( (_scratch & ~SR_INTERRUPT_ENABLE_BITS) | (_level & SR_INTERRUPT_ENABLE_BITS) ); \ + } while(0) + +/* + * This temporarily restores the interrupt to _level before immediately + * disabling them again. This is used to divide long RTEMS critical + * sections into two or more parts. The parameter _level is not + * modified. + */ + +#define _CPU_ISR_Flash( _xlevel ) \ + do { \ + unsigned int _scratch2 = _xlevel; \ + _CPU_ISR_Enable( _scratch2 ); \ + _CPU_ISR_Disable( _scratch2 ); \ + _xlevel = _scratch2; \ + } while(0) + +RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) +{ + return ( level & SR_INTERRUPT_ENABLE_BITS ) != 0; +} + +/* + * Map interrupt level in task mode onto the hardware that the CPU + * actually provides. Currently, interrupt levels which do not + * map onto the CPU in a generic fashion are undefined. Someday, + * it would be nice if these were "mapped" by the application + * via a callout. For example, m68k has 8 levels 0 - 7, levels + * 8 - 255 would be available for bsp/application specific meaning. + * This could be used to manage a programmable interrupt controller + * via the rtems_task_mode directive. + * + * On the MIPS, 0 is all on. Non-zero is all off. This only + * manipulates the IEC. + */ + +uint32_t _CPU_ISR_Get_level( void ); /* in cpu.c */ + +void _CPU_ISR_Set_level( uint32_t ); /* in cpu.c */ + +/* end of ISR handler macros */ + +/* Context handler macros */ + +/* + * Initialize the context to a state suitable for starting a + * task after a context restore operation. Generally, this + * involves: + * + * - setting a starting address + * - preparing the stack + * - preparing the stack and frame pointers + * - setting the proper interrupt level in the context + * - initializing the floating point context + * + * This routine generally does not set any unnecessary register + * in the context. The state of the "general data" registers is + * undefined at task start time. + * + * NOTE: This is_fp parameter is TRUE if the thread is to be a floating + * point thread. This is typically only used on CPUs where the + * FPU may be easily disabled by software such as on the SPARC + * where the PSR contains an enable FPU bit. + * + * The per-thread status register holds the interrupt enable, FP enable + * and global interrupt enable for that thread. It means each thread can + * enable its own set of interrupts. If interrupts are disabled, RTEMS + * can still dispatch via blocking calls. This is the function of the + * "Interrupt Level", and on the MIPS, it controls the IEC bit and all + * the hardware interrupts as defined in the SR. Software ints + * are automatically enabled for all threads, as they will only occur under + * program control anyhow. Besides, the interrupt level parm is only 8 bits, + * and controlling the software ints plus the others would require 9. + * + * If the Interrupt Level is 0, all ints are on. Otherwise, the + * Interrupt Level should supply a bit pattern to impose on the SR + * interrupt bits; bit 0 applies to the mips1 IEC bit/mips3 EXL&IE, bits 1 thru 6 + * apply to the SR register Intr bits from bit 10 thru bit 15. Bit 7 of + * the Interrupt Level parameter is unused at this time. + * + * These are the only per-thread SR bits, the others are maintained + * globally & explicitly preserved by the Context Switch code in cpu_asm.s + */ + + +#if (__mips == 3) || (__mips == 32) +#define _INTON SR_IE +#if __mips_fpr==64 +#define _EXTRABITS SR_FR +#else +#define _EXTRABITS 0 +#endif /* __mips_fpr==64 */ +#endif /* __mips == 3 */ +#if __mips == 1 +#define _INTON SR_IEC +#define _EXTRABITS 0 /* make sure we're in user mode on MIPS1 processors */ +#endif /* __mips == 1 */ + + +void _CPU_Context_Initialize( + Context_Control *the_context, + uintptr_t *stack_base, + uint32_t size, + uint32_t new_level, + void *entry_point, + bool is_fp, + void *tls_area +); + + +/* + * This routine is responsible for somehow restarting the currently + * executing task. If you are lucky, then all that is necessary + * is restoring the context. Otherwise, there will need to be + * a special assembly routine which does something special in this + * case. Context_Restore should work most of the time. It will + * not work if restarting self conflicts with the stack frame + * assumptions of restoring a context. + */ + +#define _CPU_Context_Restart_self( _the_context ) \ + _CPU_Context_restore( (_the_context) ); + +/* + * This routine initializes the FP context area passed to it to. + * There are a few standard ways in which to initialize the + * floating point context. The code included for this macro assumes + * that this is a CPU in which a "initial" FP context was saved into + * _CPU_Null_fp_context and it simply copies it to the destination + * context passed to it. + * + * Other models include (1) not doing anything, and (2) putting + * a "null FP status word" in the correct place in the FP context. + */ + +#if ( CPU_HARDWARE_FP == TRUE ) +#define _CPU_Context_Initialize_fp( _destination ) \ + { \ + *(*(_destination)) = _CPU_Null_fp_context; \ + } +#endif + +/* end of Context handler macros */ + +/* Fatal Error manager macros */ + +/* + * This routine copies _error into a known place -- typically a stack + * location or a register, optionally disables interrupts, and + * halts/stops the CPU. + */ + +#define _CPU_Fatal_halt( _source, _error ) \ + do { \ + unsigned int _level; \ + _CPU_ISR_Disable(_level); \ + (void)_level; \ + loop: goto loop; \ + } while (0) + + +extern void mips_break( int error ); + +#define CPU_USE_GENERIC_BITFIELD_CODE TRUE + +/* functions */ + +/* + * _CPU_Initialize + * + * This routine performs CPU dependent initialization. + */ + +void _CPU_Initialize(void); + +/* + * _CPU_ISR_install_raw_handler + * + * This routine installs a "raw" interrupt handler directly into the + * processor's vector table. + */ + +void _CPU_ISR_install_raw_handler( + uint32_t vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +/* + * _CPU_ISR_install_vector + * + * This routine installs an interrupt vector. + */ + +void _CPU_ISR_install_vector( + uint32_t vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +/* + * _CPU_Install_interrupt_stack + * + * This routine installs the hardware interrupt stack pointer. + * + * NOTE: It need only be provided if CPU_HAS_HARDWARE_INTERRUPT_STACK + * is TRUE. + */ + +void _CPU_Install_interrupt_stack( void ); + +/* + * _CPU_Internal_threads_Idle_thread_body + * + * This routine is the CPU dependent IDLE thread body. + * + * NOTE: It need only be provided if CPU_PROVIDES_IDLE_THREAD_BODY + * is TRUE. + */ + +void *_CPU_Thread_Idle_body( uintptr_t ignored ); + +/* + * _CPU_Context_switch + * + * This routine switches from the run context to the heir context. + */ + +void _CPU_Context_switch( + Context_Control *run, + Context_Control *heir +); + +/* + * _CPU_Context_restore + * + * This routine is generally used only to restart self in an + * efficient manner. It may simply be a label in _CPU_Context_switch. + * + * NOTE: May be unnecessary to reload some registers. + */ + +void _CPU_Context_restore( + Context_Control *new_context +) RTEMS_NO_RETURN; + +/* + * _CPU_Context_save_fp + * + * This routine saves the floating point context passed to it. + */ + +void _CPU_Context_save_fp( + Context_Control_fp **fp_context_ptr +); + +/* + * _CPU_Context_restore_fp + * + * This routine restores the floating point context passed to it. + */ + +void _CPU_Context_restore_fp( + Context_Control_fp **fp_context_ptr +); + +static inline void _CPU_Context_volatile_clobber( uintptr_t pattern ) +{ + /* TODO */ +} + +static inline void _CPU_Context_validate( uintptr_t pattern ) +{ + while (1) { + /* TODO */ + } +} + +void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); + +/* The following routine swaps the endian format of an unsigned int. + * It must be static because it is referenced indirectly. + * + * This version will work on any processor, but if there is a better + * way for your CPU PLEASE use it. The most common way to do this is to: + * + * swap least significant two bytes with 16-bit rotate + * swap upper and lower 16-bits + * swap most significant two bytes with 16-bit rotate + * + * Some CPUs have special instructions which swap a 32-bit quantity in + * a single instruction (e.g. i486). It is probably best to avoid + * an "endian swapping control bit" in the CPU. One good reason is + * that interrupts would probably have to be disabled to ensure that + * an interrupt does not try to access the same "chunk" with the wrong + * endian. Another good reason is that on some CPUs, the endian bit + * endianness for ALL fetches -- both code and data -- so the code + * will be fetched incorrectly. + */ + +static inline uint32_t CPU_swap_u32( + uint32_t value +) +{ + uint32_t byte1, byte2, byte3, byte4, swapped; + + byte4 = (value >> 24) & 0xff; + byte3 = (value >> 16) & 0xff; + byte2 = (value >> 8) & 0xff; + byte1 = value & 0xff; + + swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4; + return( swapped ); +} + +#define CPU_swap_u16( value ) \ + (((value&0xff) << 8) | ((value >> 8)&0xff)) + +typedef uint32_t CPU_Counter_ticks; + +CPU_Counter_ticks _CPU_Counter_read( void ); + +static inline CPU_Counter_ticks _CPU_Counter_difference( + CPU_Counter_ticks second, + CPU_Counter_ticks first +) +{ + return second - first; +} + +#endif + + + +#ifdef __cplusplus +} +#endif + +/**@}*/ +#endif diff --git a/cpukit/score/cpu/mips/include/rtems/score/cpuatomic.h b/cpukit/score/cpu/mips/include/rtems/score/cpuatomic.h new file mode 100644 index 0000000000..598ee76b20 --- /dev/null +++ b/cpukit/score/cpu/mips/include/rtems/score/cpuatomic.h @@ -0,0 +1,14 @@ +/* + * COPYRIGHT (c) 2012-2013 Deng Hengyi. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_ATOMIC_CPU_H +#define _RTEMS_SCORE_ATOMIC_CPU_H + +#include + +#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/mips/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/mips/include/rtems/score/cpuimpl.h new file mode 100644 index 0000000000..789f2badd9 --- /dev/null +++ b/cpukit/score/cpu/mips/include/rtems/score/cpuimpl.h @@ -0,0 +1,34 @@ +/** + * @file + * + * @brief CPU Port Implementation API + */ + +/* + * Copyright (c) 2013 embedded brains GmbH + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPUIMPL_H +#define _RTEMS_SCORE_CPUIMPL_H + +#include + +#define CPU_PER_CPU_CONTROL_SIZE 0 + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ASM */ + +#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/mips/include/rtems/score/mips.h b/cpukit/score/cpu/mips/include/rtems/score/mips.h new file mode 100644 index 0000000000..4c2c53fa6d --- /dev/null +++ b/cpukit/score/cpu/mips/include/rtems/score/mips.h @@ -0,0 +1,299 @@ +/** + * @file rtems/score/mips.h + * + * @brief Information to build RTEMS for a "no cpu" while in protected mode. + * + * This file contains the information required to build + * RTEMS for a particular member of the "no cpu" + * family when executing in protected mode. It does + * this by setting variables to indicate which implementation + * dependent features are present in a particular member + * of the family. + */ + +/* + * COPYRIGHT (c) 1989-2001. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_MIPS_H +#define _RTEMS_SCORE_MIPS_H + +/** + * @defgroup ScoreMips RTEMS no cpu Build Information + * + * @ingroup Score + * + */ +/**@{*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef ASM +#include +#endif + +/* + * SR bits that enable/disable interrupts + * + * NOTE: XXX what about SR_ERL? + */ + +#if (__mips == 3) || (__mips == 32) +#ifdef ASM +#define SR_INTERRUPT_ENABLE_BITS 0x01 +#else +#define SR_INTERRUPT_ENABLE_BITS SR_IE +#endif + +#elif __mips == 1 +#define SR_INTERRUPT_ENABLE_BITS SR_IEC + +#else +#error "mips interrupt enable bits: unknown architecture level!" +#endif + +/* + * This file contains the information required to build + * RTEMS for a particular member of the "no cpu" + * family when executing in protected mode. It does + * this by setting variables to indicate which implementation + * dependent features are present in a particular member + * of the family. + */ + +#if defined(__mips_soft_float) +#define MIPS_HAS_FPU 0 +#else +#define MIPS_HAS_FPU 1 +#endif + + +#if (__mips == 1) +#define CPU_MODEL_NAME "ISA Level 1 or 2" +#elif (__mips == 3) || (__mips == 32) +#if defined(__mips64) +#define CPU_MODEL_NAME "ISA Level 4" +#else +#define CPU_MODEL_NAME "ISA Level 3" +#endif +#else +#error "Unknown MIPS ISA level" +#endif + +/* + * Define the name of the CPU family. + */ + +#define CPU_NAME "MIPS" + +/* + * RTEMS Vector numbers for exception conditions. This is a direct + * map to the causes. + */ + +#define MIPS_EXCEPTION_BASE 0 + +#define MIPS_EXCEPTION_INT MIPS_EXCEPTION_BASE+0 +#define MIPS_EXCEPTION_MOD MIPS_EXCEPTION_BASE+1 +#define MIPS_EXCEPTION_TLBL MIPS_EXCEPTION_BASE+2 +#define MIPS_EXCEPTION_TLBS MIPS_EXCEPTION_BASE+3 +#define MIPS_EXCEPTION_ADEL MIPS_EXCEPTION_BASE+4 +#define MIPS_EXCEPTION_ADES MIPS_EXCEPTION_BASE+5 +#define MIPS_EXCEPTION_IBE MIPS_EXCEPTION_BASE+6 +#define MIPS_EXCEPTION_DBE MIPS_EXCEPTION_BASE+7 +#define MIPS_EXCEPTION_SYSCALL MIPS_EXCEPTION_BASE+8 +#define MIPS_EXCEPTION_BREAK MIPS_EXCEPTION_BASE+9 +#define MIPS_EXCEPTION_RI MIPS_EXCEPTION_BASE+10 +#define MIPS_EXCEPTION_CPU MIPS_EXCEPTION_BASE+11 +#define MIPS_EXCEPTION_OVERFLOW MIPS_EXCEPTION_BASE+12 +#define MIPS_EXCEPTION_TRAP MIPS_EXCEPTION_BASE+13 +#define MIPS_EXCEPTION_VCEI MIPS_EXCEPTION_BASE+14 +/* FPE only on mips2 and higher */ +#define MIPS_EXCEPTION_FPE MIPS_EXCEPTION_BASE+15 +#define MIPS_EXCEPTION_C2E MIPS_EXCEPTION_BASE+16 +/* 17-22 reserved */ +#define MIPS_EXCEPTION_WATCH MIPS_EXCEPTION_BASE+23 +/* 24-30 reserved */ +#define MIPS_EXCEPTION_VCED MIPS_EXCEPTION_BASE+31 + +#define MIPS_INTERRUPT_BASE MIPS_EXCEPTION_BASE+32 + +/* + * Some macros to access registers + */ + +#define mips_get_sr( _x ) \ + do { \ + __asm__ volatile( "mfc0 %0, $12; nop" : "=r" (_x) : ); \ + } while (0) + +#define mips_set_sr( _x ) \ + do { \ + register unsigned int __x = (_x); \ + __asm__ volatile( "mtc0 %0, $12; nop" : : "r" (__x) ); \ + } while (0) + + +/* + * Access the Cause register + */ + +#define mips_get_cause( _x ) \ + do { \ + __asm__ volatile( "mfc0 %0, $13; nop" : "=r" (_x) : ); \ + } while (0) + + +#define mips_set_cause( _x ) \ + do { \ + register unsigned int __x = (_x); \ + __asm__ volatile( "mtc0 %0, $13; nop" : : "r" (__x) ); \ + } while (0) + + + + +/* + * Access the Debug Cache Invalidate Control register + */ + +#define mips_get_dcic( _x ) \ + do { \ + __asm__ volatile( "mfc0 %0, $7; nop" : "=r" (_x) : ); \ + } while (0) + + +#define mips_set_dcic( _x ) \ + do { \ + register unsigned int __x = (_x); \ + __asm__ volatile( "mtc0 %0, $7; nop" : : "r" (__x) ); \ + } while (0) + + + + +/* + * Access the Breakpoint Program Counter & Mask registers + * (_x for BPC, _y for mask) + */ + +#define mips_get_bpcrm( _x, _y ) \ + do { \ + __asm__ volatile( "mfc0 %0, $3; nop" : "=r" (_x) : ); \ + __asm__ volatile( "mfc0 %0, $11; nop" : "=r" (_y) : ); \ + } while (0) + + +#define mips_set_bpcrm( _x, _y ) \ + do { \ + register unsigned int __x = (_x); \ + register unsigned int __y = (_y); \ + __asm__ volatile( "mtc0 %0, $11; nop" : : "r" (__y) ); \ + __asm__ volatile( "mtc0 %0, $3; nop" : : "r" (__x) ); \ + } while (0) + + + + + + +/* + * Access the Breakpoint Data Address & Mask registers + * (_x for BDA, _y for mask) + */ + +#define mips_get_bdarm( _x, _y ) \ + do { \ + __asm__ volatile( "mfc0 %0, $5; nop" : "=r" (_x) : ); \ + __asm__ volatile( "mfc0 %0, $9; nop" : "=r" (_y) : ); \ + } while (0) + + +#define mips_set_bdarm( _x, _y ) \ + do { \ + register unsigned int __x = (_x); \ + register unsigned int __y = (_y); \ + __asm__ volatile( "mtc0 %0, $9; nop" : : "r" (__y) ); \ + __asm__ volatile( "mtc0 %0, $5; nop" : : "r" (__x) ); \ + } while (0) + + + + + + + +/* + * Access FCR31 + */ + +#if ( MIPS_HAS_FPU == 1 ) + +#define mips_get_fcr31( _x ) \ + do { \ + __asm__ volatile( "cfc1 %0, $31; nop" : "=r" (_x) : ); \ + } while(0) + + +#define mips_set_fcr31( _x ) \ + do { \ + register unsigned int __x = (_x); \ + __asm__ volatile( "ctc1 %0, $31; nop" : : "r" (__x) ); \ + } while(0) + +#else + +#define mips_get_fcr31( _x ) +#define mips_set_fcr31( _x ) + +#endif + +/* + * Manipulate interrupt mask + * + * mips_unmask_interrupt( _mask) + * enables interrupts - mask is positioned so it only needs to be or'ed + * into the status reg. This also does some other things !!!! Caution + * should be used if invoking this while in the middle of a debugging + * session where the client may have nested interrupts. + * + * mips_mask_interrupt( _mask ) + * disable the interrupt - mask is the complement of the bits to be + * cleared - i.e. to clear ext int 5 the mask would be - 0xffff7fff + * + * + * NOTE: mips_mask_interrupt() used to be disable_int(). + * mips_unmask_interrupt() used to be enable_int(). + * + */ + +#define mips_enable_in_interrupt_mask( _mask ) \ + do { \ + unsigned int _sr; \ + mips_get_sr( _sr ); \ + _sr |= (_mask); \ + mips_set_sr( _sr ); \ + } while (0) + +#define mips_disable_in_interrupt_mask( _mask ) \ + do { \ + unsigned int _sr; \ + mips_get_sr( _sr ); \ + _sr &= ~(_mask); \ + mips_set_sr( _sr ); \ + } while (0) + +#ifdef __cplusplus +} +#endif + +/**@}*/ +#endif /* _RTEMS_SCORE_MIPS_H */ +/* end of include file */ diff --git a/cpukit/score/cpu/mips/include/rtems/score/types.h b/cpukit/score/cpu/mips/include/rtems/score/types.h new file mode 100644 index 0000000000..e3226a3bb4 --- /dev/null +++ b/cpukit/score/cpu/mips/include/rtems/score/types.h @@ -0,0 +1,56 @@ +/** + * @file rtems/score/types.h + * + * @brief Type Definitions Pertaining to the MIPS Processor Family + * + * This include file contains type definitions pertaining to the MIPS + * processor family. + */ + +/* + * COPYRIGHT (c) 1989-2001. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ +/* @(#)mipstypes.h 08/20/96 1.4 */ + +#ifndef _RTEMS_SCORE_TYPES_H +#define _RTEMS_SCORE_TYPES_H + +/** + * @defgroup ScoreTypes MIPS Processor Family Type Definitions + * + * @ingroup Score + * + */ +/**@{*/ + +#include + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This section defines the basic types for this processor. + */ + +/** Type that can store a 32-bit integer or a pointer. */ +typedef uintptr_t CPU_Uint32ptr; + +typedef void mips_isr; +typedef void ( *mips_isr_entry )( void ); + +#ifdef __cplusplus +} +#endif + +#endif /* !ASM */ + +/**@}*/ +#endif diff --git a/cpukit/score/cpu/mips/preinstall.am b/cpukit/score/cpu/mips/preinstall.am deleted file mode 100644 index 8fa3cc67a3..0000000000 --- a/cpukit/score/cpu/mips/preinstall.am +++ /dev/null @@ -1,62 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -$(PROJECT_INCLUDE)/rtems/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems - @: > $(PROJECT_INCLUDE)/rtems/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/asm.h: rtems/asm.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/asm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/asm.h - -$(PROJECT_INCLUDE)/rtems/mips/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/mips - @: > $(PROJECT_INCLUDE)/rtems/mips/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/mips/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/mips/idtcpu.h: rtems/mips/idtcpu.h $(PROJECT_INCLUDE)/rtems/mips/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/mips/idtcpu.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/mips/idtcpu.h - -$(PROJECT_INCLUDE)/rtems/mips/iregdef.h: rtems/mips/iregdef.h $(PROJECT_INCLUDE)/rtems/mips/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/mips/iregdef.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/mips/iregdef.h - -$(PROJECT_INCLUDE)/rtems/score/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/score - @: > $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/score/cpu.h: rtems/score/cpu.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpu.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpu.h - -$(PROJECT_INCLUDE)/rtems/score/cpuimpl.h: rtems/score/cpuimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h - -$(PROJECT_INCLUDE)/rtems/score/mips.h: rtems/score/mips.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/mips.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/mips.h - -$(PROJECT_INCLUDE)/rtems/score/types.h: rtems/score/types.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/types.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/types.h - -$(PROJECT_INCLUDE)/rtems/score/cpuatomic.h: rtems/score/cpuatomic.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h - diff --git a/cpukit/score/cpu/mips/rtems/asm.h b/cpukit/score/cpu/mips/rtems/asm.h deleted file mode 100644 index 9c84f61990..0000000000 --- a/cpukit/score/cpu/mips/rtems/asm.h +++ /dev/null @@ -1,160 +0,0 @@ -/** - * @file - * - * @brief Address the Problems Caused by Incompatible Flavor of - * Assemblers and Toolsets - * - * This include file attempts to address the problems - * caused by incompatible flavors of assemblers and - * toolsets. It primarily addresses variations in the - * use of leading underscores on symbols and the requirement - * that register names be preceded by a %. - * - * NOTE: The spacing in the use of these macros - * is critical to them working as advertised. - */ - -/* - * COPYRIGHT: - * - * This file is based on similar code found in newlib available - * from ftp.cygnus.com. The file which was used had no copyright - * notice. This file is freely distributable as long as the source - * of the file is noted. This file is: - * - * COPYRIGHT (c) 1994-1997. - * On-Line Applications Research Corporation (OAR). - */ -/* @(#)asm.h 03/15/96 1.1 */ - -#ifndef _RTEMS_ASM_H -#define _RTEMS_ASM_H - -/* - * Indicate we are in an assembly file and get the basic CPU definitions. - */ - -#ifndef ASM -#define ASM -#endif -#include -#include -#include - -/* - * Recent versions of GNU cpp define variables which indicate the - * need for underscores and percents. If not using GNU cpp or - * the version does not support this, then you will obviously - * have to define these as appropriate. - */ - -#ifndef __USER_LABEL_PREFIX__ -#define __USER_LABEL_PREFIX__ _ -#endif - -#ifndef __REGISTER_PREFIX__ -#define __REGISTER_PREFIX__ -#endif - -#include - -/* Use the right prefix for global labels. */ - -#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) - -/* Use the right prefix for registers. */ - -#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) - -/* - * define macros for all of the registers on this CPU - * - * EXAMPLE: #define d0 REG (d0) - */ - -/* - * Define macros to handle section beginning and ends. - */ - - -#define BEGIN_CODE_DCL .text -#define END_CODE_DCL -#define BEGIN_DATA_DCL .data -#define END_DATA_DCL -#define BEGIN_CODE .text -#define END_CODE -#define BEGIN_DATA -#define END_DATA -#define BEGIN_BSS -#define END_BSS -#define END - -/* - * Following must be tailor for a particular flavor of the C compiler. - * They may need to put underscores in front of the symbols. - */ - -#define PUBLIC(sym) .globl SYM (sym) -#define EXTERN(sym) .globl SYM (sym) - -/* - * Debugger macros for assembly language routines. Allows the - * programmer to set up the necessary stack frame info - * required by debuggers to do stack traces. - */ - -#ifndef XDS -#define FRAME(name,frm_reg,offset,ret_reg) \ - .globl name; \ - .ent name; \ -name:; \ - .frame frm_reg,offset,ret_reg -#define ENDFRAME(name) \ - .end name -#else -#define FRAME(name,frm_reg,offset,ret_reg) \ - .globl _##name;\ -_##name: -#define ENDFRAME(name) -#endif /* XDS */ - -/* - * Hardware Floating Point Registers - */ - -#define R_FP0 0 -#define R_FP1 1 -#define R_FP2 2 -#define R_FP3 3 -#define R_FP4 4 -#define R_FP5 5 -#define R_FP6 6 -#define R_FP7 7 -#define R_FP8 8 -#define R_FP9 9 -#define R_FP10 10 -#define R_FP11 11 -#define R_FP12 12 -#define R_FP13 13 -#define R_FP14 14 -#define R_FP15 15 -#define R_FP16 16 -#define R_FP17 17 -#define R_FP18 18 -#define R_FP19 19 -#define R_FP20 20 -#define R_FP21 21 -#define R_FP22 22 -#define R_FP23 23 -#define R_FP24 24 -#define R_FP25 25 -#define R_FP26 26 -#define R_FP27 27 -#define R_FP28 28 -#define R_FP29 29 -#define R_FP30 30 -#define R_FP31 31 - -#endif -/* end of include file */ - diff --git a/cpukit/score/cpu/mips/rtems/mips/idtcpu.h b/cpukit/score/cpu/mips/rtems/mips/idtcpu.h deleted file mode 100644 index 927bbec133..0000000000 --- a/cpukit/score/cpu/mips/rtems/mips/idtcpu.h +++ /dev/null @@ -1,708 +0,0 @@ -/** - * @file idtcpu.h - * - * @brief CPU Related Definitions - * - * 950313: Ketan added sreg/lreg and R_SZ for 64-bit saves - * added Register definition for XContext reg. - * Look towards end of this file. - */ - -/* - * Based upon IDT provided code with the following release: - * - * This source code has been made available to you by IDT on an AS-IS - * basis. Anyone receiving this source is licensed under IDT copyrights - * to use it in any way he or she deems fit, including copying it, - * modifying it, compiling it, and redistributing it either with or - * without modifications. No license under IDT patents or patent - * applications is to be implied by the copyright license. - * - * Any user of this software should understand that IDT cannot provide - * technical support for this software and will not be responsible for - * any consequences resulting from the use of this software. - * - * Any person who transfers this source code or any derivative work must - * include the IDT copyright notice, this paragraph, and the preceeding - * two paragraphs in the transferred software. - * - * COPYRIGHT IDT CORPORATION 1996 - * LICENSED MATERIAL - PROGRAM PROPERTY OF IDT - */ - -#ifndef _RTEMS_MIPS_IDTCPU_H -#define _RTEMS_MIPS_IDTCPU_H - -/** - * @defgroup MipsSet_idtcpu CPU Related Definitions - * - * @ingroup MIPS - * - */ -/**@{*/ - -/* - * 950313: Ketan added Register definition for XContext reg. - * added define for WAIT instruction. - * 950421: Ketan added Register definition for Config reg (R3081) - */ - -/* -** memory configuration and mapping -*/ -#define K0BASE 0x80000000 -#define K0SIZE 0x20000000 -#define K1BASE 0xa0000000 -#define K1SIZE 0x20000000 -#define K2BASE 0xc0000000 -#define K2SIZE 0x20000000 -#if __mips == 3 -#define KSBASE 0xe0000000 -#define KSSIZE 0x20000000 -#endif - -#define KUBASE 0 -#define KUSIZE 0x80000000 - -/* -** Exception Vectors -*/ -#if __mips == 1 -#define UT_VEC K0BASE /* utlbmiss vector */ -#define DB_VEC (K0BASE+0x40) /* debug vector */ -#define E_VEC (K0BASE+0x80) /* exception vector */ -#elif __mips == 32 -#define T_VEC (K0BASE+0x000) /* tlbmiss vector */ -#define X_VEC (K0BASE+0x080) /* xtlbmiss vector */ -#define C_VEC (K0BASE+0x100) /* cache error vector */ -#define E_VEC (K0BASE+0x180) /* exception vector */ -#elif __mips == 3 -#define T_VEC (K0BASE+0x000) /* tlbmiss vector */ -#define X_VEC (K0BASE+0x080) /* xtlbmiss vector */ -#define C_VEC (K0BASE+0x100) /* cache error vector */ -#define E_VEC (K0BASE+0x180) /* exception vector */ -#else -#error "EXCEPTION VECTORS: unknown ISA level" -#endif -#define R_VEC (K1BASE+0x1fc00000) /* reset vector */ - -/* -** Address conversion macros -*/ -#ifdef CLANGUAGE -#define CAST(as) (as) -#else -#define CAST(as) -#endif -#define K0_TO_K1(x) (CAST(unsigned)(x)|0xA0000000) /* kseg0 to kseg1 */ -#define K1_TO_K0(x) (CAST(unsigned)(x)&0x9FFFFFFF) /* kseg1 to kseg0 */ -#define K0_TO_PHYS(x) (CAST(unsigned)(x)&0x1FFFFFFF) /* kseg0 to physical */ -#define K1_TO_PHYS(x) (CAST(unsigned)(x)&0x1FFFFFFF) /* kseg1 to physical */ -#define PHYS_TO_K0(x) (CAST(unsigned)(x)|0x80000000) /* physical to kseg0 */ -#define PHYS_TO_K1(x) (CAST(unsigned)(x)|0xA0000000) /* physical to kseg1 */ - -/* -** Cache size constants -*/ -#define MINCACHE 0x200 /* 512 For 3041. */ -#define MAXCACHE 0x40000 /* 256*1024 256k */ - -#if __mips == 32 -/* R4000 configuration register definitions */ -#define CFG_CM 0x80000000 /* Master-Checker mode */ -#define CFG_ECMASK 0x70000000 /* System Clock Ratio */ -#define CFG_ECBY2 0x00000000 /* divide by 2 */ -#define CFG_ECBY3 0x10000000 /* divide by 3 */ -#define CFG_ECBY4 0x20000000 /* divide by 4 */ -#define CFG_EPMASK 0x0f000000 /* Transmit data pattern */ -#define CFG_EPD 0x00000000 /* D */ -#define CFG_EPDDX 0x01000000 /* DDX */ -#define CFG_EPDDXX 0x02000000 /* DDXX */ -#define CFG_EPDXDX 0x03000000 /* DXDX */ -#define CFG_EPDDXXX 0x04000000 /* DDXXX */ -#define CFG_EPDDXXXX 0x05000000 /* DDXXXX */ -#define CFG_EPDXXDXX 0x06000000 /* DXXDXX */ -#define CFG_EPDDXXXXX 0x07000000 /* DDXXXXX */ -#define CFG_EPDXXXDXXX 0x08000000 /* DXXXDXXX */ -#define CFG_SBMASK 0x00c00000 /* Secondary cache block size */ -#define CFG_SBSHIFT 22 -#define CFG_SB4 0x00000000 /* 4 words */ -#define CFG_SB8 0x00400000 /* 8 words */ -#define CFG_SB16 0x00800000 /* 16 words */ -#define CFG_SB32 0x00c00000 /* 32 words */ -#define CFG_SS 0x00200000 /* Split secondary cache */ -#define CFG_SW 0x00100000 /* Secondary cache port width */ -#define CFG_EWMASK 0x000c0000 /* System port width */ -#define CFG_EWSHIFT 18 -#define CFG_EW64 0x00000000 /* 64 bit */ -#define CFG_EW32 0x00010000 /* 32 bit */ -#define CFG_SC 0x00020000 /* Secondary cache absent */ -#define CFG_SM 0x00010000 /* Dirty Shared mode disabled */ -#define CFG_BE 0x00008000 /* Big Endian */ -#define CFG_EM 0x00004000 /* ECC mode enable */ -#define CFG_EB 0x00002000 /* Block ordering */ -#define CFG_ICMASK 0x00000e00 /* Instruction cache size */ -#define CFG_ICSHIFT 9 -#define CFG_DCMASK 0x000001c0 /* Data cache size */ -#define CFG_DCSHIFT 6 -#define CFG_IB 0x00000020 /* Instruction cache block size */ -#define CFG_DB 0x00000010 /* Data cache block size */ -#define CFG_CU 0x00000008 /* Update on Store Conditional */ -#define CFG_K0MASK 0x00000007 /* KSEG0 coherency algorithm */ - -/* - * R4000 primary cache mode - */ -#define CFG_C_UNCACHED 2 -#define CFG_C_NONCOHERENT 3 -#define CFG_C_COHERENTXCL 4 -#define CFG_C_COHERENTXCLW 5 -#define CFG_C_COHERENTUPD 6 - -/* - * R4000 cache operations (should be in assembler...?) - */ -#define Index_Invalidate_I 0x0 /* 0 0 */ -#define Index_Writeback_Inv_D 0x1 /* 0 1 */ -#define Index_Invalidate_SI 0x2 /* 0 2 */ -#define Index_Writeback_Inv_SD 0x3 /* 0 3 */ -#define Index_Load_Tag_I 0x4 /* 1 0 */ -#define Index_Load_Tag_D 0x5 /* 1 1 */ -#define Index_Load_Tag_SI 0x6 /* 1 2 */ -#define Index_Load_Tag_SD 0x7 /* 1 3 */ -#define Index_Store_Tag_I 0x8 /* 2 0 */ -#define Index_Store_Tag_D 0x9 /* 2 1 */ -#define Index_Store_Tag_SI 0xA /* 2 2 */ -#define Index_Store_Tag_SD 0xB /* 2 3 */ -#define Create_Dirty_Exc_D 0xD /* 3 1 */ -#define Create_Dirty_Exc_SD 0xF /* 3 3 */ -#define Hit_Invalidate_I 0x10 /* 4 0 */ -#define Hit_Invalidate_D 0x11 /* 4 1 */ -#define Hit_Invalidate_SI 0x12 /* 4 2 */ -#define Hit_Invalidate_SD 0x13 /* 4 3 */ -#define Hit_Writeback_Inv_D 0x15 /* 5 1 */ -#define Hit_Writeback_Inv_SD 0x17 /* 5 3 */ -#define Fill_I 0x14 /* 5 0 */ -#define Hit_Writeback_D 0x19 /* 6 1 */ -#define Hit_Writeback_SD 0x1B /* 6 3 */ -#define Hit_Writeback_I 0x18 /* 6 0 */ -#define Hit_Set_Virtual_SI 0x1E /* 7 2 */ -#define Hit_Set_Virtual_SD 0x1F /* 7 3 */ - -/* Disabled by chris -- horrible overload of common word. -#ifndef WAIT -#define WAIT .word 0x42000020 -#endif -*/ -/* Disabled by joel -- horrible overload of common word. -#ifndef wait -#define wait .word 0x42000020 -#endif wait -*/ - -#endif - -#if __mips == 3 -/* R4000 configuration register definitions */ -#define CFG_CM 0x80000000 /* Master-Checker mode */ -#define CFG_ECMASK 0x70000000 /* System Clock Ratio */ -#define CFG_ECBY2 0x00000000 /* divide by 2 */ -#define CFG_ECBY3 0x10000000 /* divide by 3 */ -#define CFG_ECBY4 0x20000000 /* divide by 4 */ -#define CFG_EPMASK 0x0f000000 /* Transmit data pattern */ -#define CFG_EPD 0x00000000 /* D */ -#define CFG_EPDDX 0x01000000 /* DDX */ -#define CFG_EPDDXX 0x02000000 /* DDXX */ -#define CFG_EPDXDX 0x03000000 /* DXDX */ -#define CFG_EPDDXXX 0x04000000 /* DDXXX */ -#define CFG_EPDDXXXX 0x05000000 /* DDXXXX */ -#define CFG_EPDXXDXX 0x06000000 /* DXXDXX */ -#define CFG_EPDDXXXXX 0x07000000 /* DDXXXXX */ -#define CFG_EPDXXXDXXX 0x08000000 /* DXXXDXXX */ -#define CFG_SBMASK 0x00c00000 /* Secondary cache block size */ -#define CFG_SBSHIFT 22 -#define CFG_SB4 0x00000000 /* 4 words */ -#define CFG_SB8 0x00400000 /* 8 words */ -#define CFG_SB16 0x00800000 /* 16 words */ -#define CFG_SB32 0x00c00000 /* 32 words */ -#define CFG_SS 0x00200000 /* Split secondary cache */ -#define CFG_SW 0x00100000 /* Secondary cache port width */ -#define CFG_EWMASK 0x000c0000 /* System port width */ -#define CFG_EWSHIFT 18 -#define CFG_EW64 0x00000000 /* 64 bit */ -#define CFG_EW32 0x00010000 /* 32 bit */ -#define CFG_SC 0x00020000 /* Secondary cache absent */ -#define CFG_SM 0x00010000 /* Dirty Shared mode disabled */ -#define CFG_BE 0x00008000 /* Big Endian */ -#define CFG_EM 0x00004000 /* ECC mode enable */ -#define CFG_EB 0x00002000 /* Block ordering */ -#define CFG_ICMASK 0x00000e00 /* Instruction cache size */ -#define CFG_ICSHIFT 9 -#define CFG_DCMASK 0x000001c0 /* Data cache size */ -#define CFG_DCSHIFT 6 -#define CFG_IB 0x00000020 /* Instruction cache block size */ -#define CFG_DB 0x00000010 /* Data cache block size */ -#define CFG_CU 0x00000008 /* Update on Store Conditional */ -#define CFG_K0MASK 0x00000007 /* KSEG0 coherency algorithm */ - -/* - * R4000 primary cache mode - */ -#define CFG_C_UNCACHED 2 -#define CFG_C_NONCOHERENT 3 -#define CFG_C_COHERENTXCL 4 -#define CFG_C_COHERENTXCLW 5 -#define CFG_C_COHERENTUPD 6 - -/* - * R4000 cache operations (should be in assembler...?) - */ -#define Index_Invalidate_I 0x0 /* 0 0 */ -#define Index_Writeback_Inv_D 0x1 /* 0 1 */ -#define Index_Invalidate_SI 0x2 /* 0 2 */ -#define Index_Writeback_Inv_SD 0x3 /* 0 3 */ -#define Index_Load_Tag_I 0x4 /* 1 0 */ -#define Index_Load_Tag_D 0x5 /* 1 1 */ -#define Index_Load_Tag_SI 0x6 /* 1 2 */ -#define Index_Load_Tag_SD 0x7 /* 1 3 */ -#define Index_Store_Tag_I 0x8 /* 2 0 */ -#define Index_Store_Tag_D 0x9 /* 2 1 */ -#define Index_Store_Tag_SI 0xA /* 2 2 */ -#define Index_Store_Tag_SD 0xB /* 2 3 */ -#define Create_Dirty_Exc_D 0xD /* 3 1 */ -#define Create_Dirty_Exc_SD 0xF /* 3 3 */ -#define Hit_Invalidate_I 0x10 /* 4 0 */ -#define Hit_Invalidate_D 0x11 /* 4 1 */ -#define Hit_Invalidate_SI 0x12 /* 4 2 */ -#define Hit_Invalidate_SD 0x13 /* 4 3 */ -#define Hit_Writeback_Inv_D 0x15 /* 5 1 */ -#define Hit_Writeback_Inv_SD 0x17 /* 5 3 */ -#define Fill_I 0x14 /* 5 0 */ -#define Hit_Writeback_D 0x19 /* 6 1 */ -#define Hit_Writeback_SD 0x1B /* 6 3 */ -#define Hit_Writeback_I 0x18 /* 6 0 */ -#define Hit_Set_Virtual_SI 0x1E /* 7 2 */ -#define Hit_Set_Virtual_SD 0x1F /* 7 3 */ - -/* Disabled by chris -- horrible overload of common word. -#ifndef WAIT -#define WAIT .word 0x42000020 -#endif -*/ -/* Disabled by joel -- horrible overload of common word. -#ifndef wait -#define wait .word 0x42000020 -#endif wait -*/ - -#endif - -/* -** TLB resource defines -*/ -#if __mips == 1 -#define N_TLB_ENTRIES 64 -#define TLB_PGSIZE 0x1000 -#define RANDBASE 8 -#define TLBLO_PFNMASK 0xfffff000 -#define TLBLO_PFNSHIFT 12 -#define TLBLO_N 0x800 /* non-cacheable */ -#define TLBLO_D 0x400 /* writeable */ -#define TLBLO_V 0x200 /* valid bit */ -#define TLBLO_G 0x100 /* global access bit */ - -#define TLBHI_VPNMASK 0xfffff000 -#define TLBHI_VPNSHIFT 12 -#define TLBHI_PIDMASK 0xfc0 -#define TLBHI_PIDSHIFT 6 -#define TLBHI_NPID 64 - -#define TLBINX_PROBE 0x80000000 -#define TLBINX_INXMASK 0x00003f00 -#define TLBINX_INXSHIFT 8 - -#define TLBRAND_RANDMASK 0x00003f00 -#define TLBRAND_RANDSHIFT 8 - -#define TLBCTXT_BASEMASK 0xffe00000 -#define TLBCTXT_BASESHIFT 21 - -#define TLBCTXT_VPNMASK 0x001ffffc -#define TLBCTXT_VPNSHIFT 2 -#endif -#if __mips == 3 -#define N_TLB_ENTRIES 48 - -#define TLBHI_VPN2MASK 0xffffe000 -#define TLBHI_PIDMASK 0x000000ff -#define TLBHI_NPID 256 - -#define TLBLO_PFNMASK 0x3fffffc0 -#define TLBLO_PFNSHIFT 6 -#define TLBLO_D 0x00000004 /* writeable */ -#define TLBLO_V 0x00000002 /* valid bit */ -#define TLBLO_G 0x00000001 /* global access bit */ -#define TLBLO_CMASK 0x00000038 /* cache algorithm mask */ -#define TLBLO_CSHIFT 3 - -#define TLBLO_UNCACHED (CFG_C_UNCACHED< k, 1 => u */ -#define SR_IEO 0x00000010 /* old interrupt enable, 1 => enable */ -#define SR_KUP 0x00000008 /* prev kernel/user, 0 => k, 1 => u */ -#define SR_IEP 0x00000004 /* prev interrupt enable, 1 => enable */ -#define SR_KUC 0x00000002 /* cur kernel/user, 0 => k, 1 => u */ -#define SR_IEC 0x00000001 /* cur interrupt enable, 1 => enable */ -#endif - -#if __mips == 3 -#define SR_CUMASK 0xf0000000 /* coproc usable bits */ -#define SR_CU3 0x80000000 /* Coprocessor 3 usable */ -#define SR_CU2 0x40000000 /* Coprocessor 2 usable */ -#define SR_CU1 0x20000000 /* Coprocessor 1 usable */ -#define SR_CU0 0x10000000 /* Coprocessor 0 usable */ - -#define SR_RP 0x08000000 /* Reduced power operation */ -#define SR_FR 0x04000000 /* Additional floating point registers */ -#define SR_RE 0x02000000 /* Reverse endian in user mode */ - -#define SR_BEV 0x00400000 /* Use boot exception vectors */ -#define SR_TS 0x00200000 /* TLB shutdown */ -#define SR_SR 0x00100000 /* Soft reset */ -#define SR_CH 0x00040000 /* Cache hit */ -#define SR_CE 0x00020000 /* Use cache ECC */ -#define SR_DE 0x00010000 /* Disable cache exceptions */ - -/* -** status register interrupt masks and bits -*/ - -#define SR_IMASK 0x0000ff00 /* Interrupt mask */ -#define SR_IMASK8 0x00000000 /* mask level 8 */ -#define SR_IMASK7 0x00008000 /* mask level 7 */ -#define SR_IMASK6 0x0000c000 /* mask level 6 */ -#define SR_IMASK5 0x0000e000 /* mask level 5 */ -#define SR_IMASK4 0x0000f000 /* mask level 4 */ -#define SR_IMASK3 0x0000f800 /* mask level 3 */ -#define SR_IMASK2 0x0000fc00 /* mask level 2 */ -#define SR_IMASK1 0x0000fe00 /* mask level 1 */ -#define SR_IMASK0 0x0000ff00 /* mask level 0 */ - -#define SR_IMASKSHIFT 8 - -#define SR_IBIT8 0x00008000 /* bit level 8 */ -#define SR_IBIT7 0x00004000 /* bit level 7 */ -#define SR_IBIT6 0x00002000 /* bit level 6 */ -#define SR_IBIT5 0x00001000 /* bit level 5 */ -#define SR_IBIT4 0x00000800 /* bit level 4 */ -#define SR_IBIT3 0x00000400 /* bit level 3 */ -#define SR_IBIT2 0x00000200 /* bit level 2 */ -#define SR_IBIT1 0x00000100 /* bit level 1 */ - -#define SR_KSMASK 0x00000018 /* Kernel mode mask */ -#define SR_KSUSER 0x00000010 /* User mode */ -#define SR_KSSUPER 0x00000008 /* Supervisor mode */ -#define SR_KSKERNEL 0x00000000 /* Kernel mode */ -#define SR_ERL 0x00000004 /* Error level */ -#define SR_EXL 0x00000002 /* Exception level */ -#define SR_IE 0x00000001 /* Interrupts enabled */ -#endif - -#if __mips == 32 -#define SR_CUMASK 0xf0000000 /* coproc usable bits */ -#define SR_CU3 0x80000000 /* Coprocessor 3 usable */ -#define SR_CU2 0x40000000 /* Coprocessor 2 usable */ -#define SR_CU1 0x20000000 /* Coprocessor 1 usable */ -#define SR_CU0 0x10000000 /* Coprocessor 0 usable */ - -#define SR_RP 0x08000000 /* Reduced power operation */ -#define SR_FR 0x04000000 /* Additional floating point registers */ -#define SR_RE 0x02000000 /* Reverse endian in user mode */ - -#define SR_BEV 0x00400000 /* Use boot exception vectors */ -#define SR_TS 0x00200000 /* TLB shutdown */ -#define SR_SR 0x00100000 /* Soft reset */ -#define SR_CH 0x00040000 /* Cache hit */ -#define SR_CE 0x00020000 /* Use cache ECC */ -#define SR_DE 0x00010000 /* Disable cache exceptions */ - -/* -** status register interrupt masks and bits -*/ - -#define SR_IMASK 0x0000ff00 /* Interrupt mask */ -#define SR_IMASK8 0x00000000 /* mask level 8 */ -#define SR_IMASK7 0x00008000 /* mask level 7 */ -#define SR_IMASK6 0x0000c000 /* mask level 6 */ -#define SR_IMASK5 0x0000e000 /* mask level 5 */ -#define SR_IMASK4 0x0000f000 /* mask level 4 */ -#define SR_IMASK3 0x0000f800 /* mask level 3 */ -#define SR_IMASK2 0x0000fc00 /* mask level 2 */ -#define SR_IMASK1 0x0000fe00 /* mask level 1 */ -#define SR_IMASK0 0x0000ff00 /* mask level 0 */ - -#define SR_IMASKSHIFT 8 - -#define SR_IBIT8 0x00008000 /* bit level 8 */ -#define SR_IBIT7 0x00004000 /* bit level 7 */ -#define SR_IBIT6 0x00002000 /* bit level 6 */ -#define SR_IBIT5 0x00001000 /* bit level 5 */ -#define SR_IBIT4 0x00000800 /* bit level 4 */ -#define SR_IBIT3 0x00000400 /* bit level 3 */ -#define SR_IBIT2 0x00000200 /* bit level 2 */ -#define SR_IBIT1 0x00000100 /* bit level 1 */ - -#define SR_KSMASK 0x00000018 /* Kernel mode mask */ -#define SR_KSUSER 0x00000010 /* User mode */ -#define SR_KSSUPER 0x00000008 /* Supervisor mode */ -#define SR_KSKERNEL 0x00000000 /* Kernel mode */ -#define SR_ERL 0x00000004 /* Error level */ -#define SR_EXL 0x00000002 /* Exception level */ -#define SR_IE 0x00000001 /* Interrupts enabled */ -#endif - -/* - * Cause Register - */ -#define CAUSE_BD 0x80000000 /* Branch delay slot */ -#define CAUSE_BT 0x40000000 /* Branch Taken */ -#define CAUSE_CEMASK 0x30000000 /* coprocessor error */ -#define CAUSE_CESHIFT 28 - - -#define CAUSE_IPMASK 0x0000FF00 /* Pending interrupt mask */ -#define CAUSE_IPSHIFT 8 - -#define CAUSE_EXCMASK 0x0000003C /* Cause code bits */ -#define CAUSE_EXCSHIFT 2 - -#ifndef XDS -/* -** Coprocessor 0 registers -*/ -#define C0_INX $0 /* tlb index */ -#define C0_RAND $1 /* tlb random */ -#if __mips == 1 -#define C0_TLBLO $2 /* tlb entry low */ -#endif -#if __mips == 3 -#define C0_TLBLO0 $2 /* tlb entry low 0 */ -#define C0_TLBLO1 $3 /* tlb entry low 1 */ -#endif - -#if __mips == 32 -#define C0_TLBLO0 $2 /* tlb entry low 0 */ -#define C0_TLBLO1 $3 /* tlb entry low 1 */ -#endif - - -#define C0_CTXT $4 /* tlb context */ - -#if __mips == 3 -#define C0_PAGEMASK $5 /* tlb page mask */ -#define C0_WIRED $6 /* number of wired tlb entries */ -#endif - -#if __mips == 32 -#define C0_PAGEMASK $5 /* tlb page mask */ -#define C0_WIRED $6 /* number of wired tlb entries */ -#endif - -#if __mips == 1 -#define C0_TAR $6 -#endif - -#define C0_BADVADDR $8 /* bad virtual address */ - -#if __mips == 3 -#define C0_COUNT $9 /* cycle count */ -#endif -#if __mips == 32 -#define C0_COUNT $9 /* cycle count */ -#endif - -#define C0_TLBHI $10 /* tlb entry hi */ - -#if __mips == 3 -#define C0_COMPARE $11 /* cyccle count comparator */ -#endif - -#if __mips == 32 -#define C0_COMPARE $11 /* cyccle count comparator */ -#endif - -#define C0_SR $12 /* status register */ -#define C0_CAUSE $13 /* exception cause */ -#define C0_EPC $14 /* exception pc */ -#define C0_PRID $15 /* revision identifier */ - -#if __mips == 1 -#define C0_CONFIG $3 /* configuration register R3081*/ -#endif - -#if __mips == 3 -#define C0_CONFIG $16 /* configuration register */ -#define C0_LLADDR $17 /* linked load address */ -#define C0_WATCHLO $18 /* watchpoint trap register */ -#define C0_WATCHHI $19 /* watchpoint trap register */ -#define C0_XCTXT $20 /* extended tlb context */ -#define C0_ECC $26 /* secondary cache ECC control */ -#define C0_CACHEERR $27 /* cache error status */ -#define C0_TAGLO $28 /* cache tag lo */ -#define C0_TAGHI $29 /* cache tag hi */ -#define C0_ERRPC $30 /* cache error pc */ -#endif - -#if __mips == 32 -#define C0_CONFIG $16 /* configuration register */ -#define C0_LLADDR $17 /* linked load address */ -#define C0_WATCHLO $18 /* watchpoint trap register */ -#define C0_WATCHHI $19 /* watchpoint trap register */ -#define C0_XCTXT $20 /* extended tlb context */ -#define C0_ECC $26 /* secondary cache ECC control */ -#define C0_CACHEERR $27 /* cache error status */ -#define C0_TAGLO $28 /* cache tag lo */ -#define C0_TAGHI $29 /* cache tag hi */ -#define C0_ERRPC $30 /* cache error pc */ -#endif - - -#define C1_REVISION $0 -#define C1_STATUS $31 - -#endif /* XDS */ - -#ifdef R4650 -#define IWATCH $18 -#define DWATCH $19 -#define IBASE $0 -#define IBOUND $1 -#define DBASE $2 -#define DBOUND $3 -#define CALG $17 -#endif - -/**@}*/ -#endif /* _RTEMS_MIPS_IDTCPU_H */ diff --git a/cpukit/score/cpu/mips/rtems/mips/iregdef.h b/cpukit/score/cpu/mips/rtems/mips/iregdef.h deleted file mode 100644 index 5d41074184..0000000000 --- a/cpukit/score/cpu/mips/rtems/mips/iregdef.h +++ /dev/null @@ -1,337 +0,0 @@ -/** - * @file iregdef.h - * - * @brief IDT R3000 Register Structure - * - * 950313: Ketan added sreg/lreg and R_SZ for 64-bit saves - * added Register definition for XContext reg. - * Look towards end of this file. - */ - -/* - * Copyright 1989 Integrated Device Technology, Inc - * All Rights Reserved - * - * Based upon IDT provided code with the following release: - * - * This source code has been made available to you by IDT on an AS-IS - * basis. Anyone receiving this source is licensed under IDT copyrights - * to use it in any way he or she deems fit, including copying it, - * modifying it, compiling it, and redistributing it either with or - * without modifications. No license under IDT patents or patent - * applications is to be implied by the copyright license. - * - * Any user of this software should understand that IDT cannot provide - * technical support for this software and will not be responsible for - * any consequences resulting from the use of this software. - * - * Any person who transfers this source code or any derivative work must - * include the IDT copyright notice, this paragraph, and the preceeding - * two paragraphs in the transferred software. - * - * COPYRIGHT IDT CORPORATION 1996 - * LICENSED MATERIAL - PROGRAM PROPERTY OF IDT - */ - -#ifndef _RTEMS_MIPS_IREGDEF_H -#define _RTEMS_MIPS_IREGDEF_H - -/** - * @defgroup MipsSet_iregdef Register Structure - * - * @ingroup MIPS - * - */ -/**@{*/ - -/* register names */ - -#define r0 $0 -#define r1 $1 -#define r2 $2 -#define r3 $3 -#define r4 $4 -#define r5 $5 -#define r6 $6 -#define r7 $7 -#define r8 $8 -#define r9 $9 -#define r10 $10 -#define r11 $11 -#define r12 $12 -#define r13 $13 - -#define r14 $14 -#define r15 $15 -#define r16 $16 -#define r17 $17 -#define r18 $18 -#define r19 $19 -#define r20 $20 -#define r21 $21 -#define r22 $22 -#define r23 $23 -#define r24 $24 -#define r25 $25 -#define r26 $26 -#define r27 $27 -#define r28 $28 -#define r29 $29 -#define r30 $30 -#define r31 $31 - -#define fp0 $f0 -#define fp1 $f1 -#define fp2 $f2 -#define fp3 $f3 -#define fp4 $f4 -#define fp5 $f5 -#define fp6 $f6 -#define fp7 $f7 -#define fp8 $f8 -#define fp9 $f9 -#define fp10 $f10 -#define fp11 $f11 -#define fp12 $f12 -#define fp13 $f13 -#define fp14 $f14 -#define fp15 $f15 -#define fp16 $f16 -#define fp17 $f17 -#define fp18 $f18 -#define fp19 $f19 -#define fp20 $f20 -#define fp21 $f21 -#define fp22 $f22 -#define fp23 $f23 -#define fp24 $f24 -#define fp25 $f25 -#define fp26 $f26 -#define fp27 $f27 -#define fp28 $f28 -#define fp29 $f29 -#define fp30 $f30 -#define fp31 $f31 - -#define fcr0 $0 -#define fcr30 $30 -#define fcr31 $31 - -#define zero $0 /* wired zero */ -#define AT $at /* assembler temp */ -#define v0 $2 /* return value */ -#define v1 $3 -#define a0 $4 /* argument registers a0-a3 */ -#define a1 $5 -#define a2 $6 -#define a3 $7 -#define t0 $8 /* caller saved t0-t9 */ -#define t1 $9 -#define t2 $10 -#define t3 $11 -#define t4 $12 -#define t5 $13 -#define t6 $14 -#define t7 $15 -#define s0 $16 /* callee saved s0-s8 */ -#define s1 $17 -#define s2 $18 -#define s3 $19 -#define s4 $20 -#define s5 $21 -#define s6 $22 -#define s7 $23 -#define t8 $24 -#define t9 $25 -#define k0 $26 /* kernel usage */ -#define k1 $27 /* kernel usage */ -#define gp $28 /* sdata pointer */ -#define sp $29 /* stack pointer */ -#define s8 $30 /* yet another saved reg for the callee */ -#define fp $30 /* frame pointer - this is being phased out by MIPS */ -#define ra $31 /* return address */ - - -/* -** relative position of registers in interrupt/exception frame -*/ -#define R_R0 0 -#define R_R1 1 -#define R_R2 2 -#define R_R3 3 -#define R_R4 4 -#define R_R5 5 -#define R_R6 6 -#define R_R7 7 -#define R_R8 8 -#define R_R9 9 -#define R_R10 10 -#define R_R11 11 -#define R_R12 12 -#define R_R13 13 -#define R_R14 14 -#define R_R15 15 -#define R_R16 16 -#define R_R17 17 -#define R_R18 18 -#define R_R19 19 -#define R_R20 20 -#define R_R21 21 -#define R_R22 22 -#define R_R23 23 -#define R_R24 24 -#define R_R25 25 -#define R_R26 26 -#define R_R27 27 -#define R_R28 28 -#define R_R29 29 -#define R_R30 30 -#define R_R31 31 - -#define R_SR 32 -#define R_MDLO 33 -#define R_MDHI 34 -#define R_BADVADDR 35 -#define R_CAUSE 36 -#define R_EPC 37 - -#define R_F0 38 -#define R_F1 39 -#define R_F2 40 -#define R_F3 41 -#define R_F4 42 -#define R_F5 43 -#define R_F6 44 -#define R_F7 45 -#define R_F8 46 -#define R_F9 47 -#define R_F10 48 -#define R_F11 49 -#define R_F12 50 -#define R_F13 41 -#define R_F14 42 -#define R_F15 43 -#define R_F16 44 -#define R_F17 45 -#define R_F18 56 -#define R_F19 57 -#define R_F20 58 -#define R_F21 59 -#define R_F22 60 -#define R_F23 61 -#define R_F24 62 -#define R_F25 63 -#define R_F26 64 -#define R_F27 65 -#define R_F28 66 -#define R_F29 67 -#define R_F30 68 -#define R_F31 69 -#define R_FCSR 70 -#define R_FEIR 71 -#define R_TLBHI 72 - -#if __mips == 1 -#define R_TLBLO 73 -#endif -#if (__mips == 3 ) || ( __mips == 32) -#define R_TLBLO0 73 -#endif - -#define R_INX 74 -#define R_RAND 75 -#define R_CTXT 76 -#define R_EXCTYPE 77 -#define R_MODE 78 -#define R_PRID 79 -#define R_TAR 80 -#if __mips == 1 -#define NREGS 81 -#endif -#if (__mips == 3 ) || ( __mips == 32) -#define R_TLBLO1 81 -#define R_PAGEMASK 82 -#define R_WIRED 83 -#define R_COUNT 84 -#define R_COMPARE 85 -#define R_CONFIG 86 -#define R_LLADDR 87 -#define R_WATCHLO 88 -#define R_WATCHHI 89 -#define R_ECC 90 -#define R_CACHEERR 91 -#define R_TAGLO 92 -#define R_TAGHI 93 -#define R_ERRPC 94 -#define R_XCTXT 95 /* Ketan added from SIM64bit */ - -#define NREGS 96 -#endif - -/* -** For those who like to think in terms of the compiler names for the regs -*/ -#define R_ZERO R_R0 -#define R_AT R_R1 -#define R_V0 R_R2 -#define R_V1 R_R3 -#define R_A0 R_R4 -#define R_A1 R_R5 -#define R_A2 R_R6 -#define R_A3 R_R7 -#define R_T0 R_R8 -#define R_T1 R_R9 -#define R_T2 R_R10 -#define R_T3 R_R11 -#define R_T4 R_R12 -#define R_T5 R_R13 -#define R_T6 R_R14 -#define R_T7 R_R15 -#define R_S0 R_R16 -#define R_S1 R_R17 -#define R_S2 R_R18 -#define R_S3 R_R19 -#define R_S4 R_R20 -#define R_S5 R_R21 -#define R_S6 R_R22 -#define R_S7 R_R23 -#define R_T8 R_R24 -#define R_T9 R_R25 -#define R_K0 R_R26 -#define R_K1 R_R27 -#define R_GP R_R28 -#define R_SP R_R29 -#define R_FP R_R30 -#define R_RA R_R31 - -/* disabled for RTEMS */ -#if 0 -/* Ketan added the following */ -#if __mips == 1 -#define sreg sw -#define lreg lw -#define rmfc0 mfc0 -#define rmtc0 mtc0 -#define R_SZ 4 -#endif /* __mips == 1 */ - -/* #ifdef __mips == 3 */ -#if __mips < 3 -#define sreg sw -#define lreg lw -#define rmfc0 mfc0 -#define rmtc0 mtc0 -#define R_SZ 4 -#else -#define sreg sd -#define lreg ld -#define rmfc0 dmfc0 -#define rmtc0 dmtc0 -#define R_SZ 8 -#endif -/* #endif __mips == 3 */ -/* Ketan till here */ -#endif - -/**@}*/ -#endif /* _RTEMS_MIPS_IREGDEF_H */ diff --git a/cpukit/score/cpu/mips/rtems/score/cpu.h b/cpukit/score/cpu/mips/rtems/score/cpu.h deleted file mode 100644 index 74afc800b9..0000000000 --- a/cpukit/score/cpu/mips/rtems/score/cpu.h +++ /dev/null @@ -1,1010 +0,0 @@ -/** - * @file - * - * @brief Mips CPU Dependent Header File - */ - -/* - * Conversion to MIPS port by Alan Cudmore and - * Joel Sherrill . - * - * These changes made the code conditional on standard cpp predefines, - * merged the mips1 and mips3 code sequences as much as possible, - * and moved some of the assembly code to C. Alan did much of the - * initial analysis and rework. Joel took over from there and - * wrote the JMR3904 BSP so this could be tested. Joel also - * added the new interrupt vectoring support in libcpu and - * tried to better support the various interrupt controllers. - * - */ - -/* - * Original MIP64ORION port by Craig Lebakken - * COPYRIGHT (c) 1996 by Transition Networks Inc. - * - * To anyone who acknowledges that this file is provided "AS IS" - * without any express or implied warranty: - * permission to use, copy, modify, and distribute this file - * for any purpose is hereby granted without fee, provided that - * the above copyright notice and this notice appears in all - * copies, and that the name of Transition Networks not be used in - * advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. - * Transition Networks makes no representations about the suitability - * of this software for any purpose. - * - * COPYRIGHT (c) 1989-2012. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPU_H -#define _RTEMS_SCORE_CPU_H - -/** - * @defgroup ScoreCPU CPU CPU - * - * @ingroup Score - * - */ -/**@{*/ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/* conditional compilation parameters */ - -/* - * Does RTEMS manage a dedicated interrupt stack in software? - * - * If TRUE, then a stack is allocated in _Interrupt_Manager_initialization. - * If FALSE, nothing is done. - * - * If the CPU supports a dedicated interrupt stack in hardware, - * then it is generally the responsibility of the BSP to allocate it - * and set it up. - * - * If the CPU does not support a dedicated interrupt stack, then - * the porter has two options: (1) execute interrupts on the - * stack of the interrupted task, and (2) have RTEMS manage a dedicated - * interrupt stack. - * - * If this is TRUE, CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. - * - * Only one of CPU_HAS_SOFTWARE_INTERRUPT_STACK and - * CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is - * possible that both are FALSE for a particular CPU. Although it - * is unclear what that would imply about the interrupt processing - * procedure on that CPU. - */ - -#define CPU_HAS_SOFTWARE_INTERRUPT_STACK FALSE - -/* - * Does the CPU follow the simple vectored interrupt model? - * - * If TRUE, then RTEMS allocates the vector table it internally manages. - * If FALSE, then the BSP is assumed to allocate and manage the vector - * table - * - * MIPS Specific Information: - * - * Up to and including RTEMS 4.10, the MIPS port used simple vectored - * interrupts. But this was changed to the PIC model after 4.10. - */ -#define CPU_SIMPLE_VECTORED_INTERRUPTS FALSE - -/* - * Does this CPU have hardware support for a dedicated interrupt stack? - * - * If TRUE, then it must be installed during initialization. - * If FALSE, then no installation is performed. - * - * If this is TRUE, CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. - * - * Only one of CPU_HAS_SOFTWARE_INTERRUPT_STACK and - * CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is - * possible that both are FALSE for a particular CPU. Although it - * is unclear what that would imply about the interrupt processing - * procedure on that CPU. - */ - -#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE - -/* - * Does RTEMS allocate a dedicated interrupt stack in the Interrupt Manager? - * - * If TRUE, then the memory is allocated during initialization. - * If FALSE, then the memory is allocated during initialization. - * - * This should be TRUE is CPU_HAS_SOFTWARE_INTERRUPT_STACK is TRUE. - */ - -#define CPU_ALLOCATE_INTERRUPT_STACK FALSE - -/* - * Does the RTEMS invoke the user's ISR with the vector number and - * a pointer to the saved interrupt frame (1) or just the vector - * number (0)? - * - */ - -#define CPU_ISR_PASSES_FRAME_POINTER TRUE - - - -/* - * Does the CPU have hardware floating point? - * - * If TRUE, then the RTEMS_FLOATING_POINT task attribute is supported. - * If FALSE, then the RTEMS_FLOATING_POINT task attribute is ignored. - * - * If there is a FP coprocessor such as the i387 or mc68881, then - * the answer is TRUE. - * - * The macro name "MIPS_HAS_FPU" should be made CPU specific. - * It indicates whether or not this CPU model has FP support. For - * example, it would be possible to have an i386_nofp CPU model - * which set this to false to indicate that you have an i386 without - * an i387 and wish to leave floating point support out of RTEMS. - */ - -#if ( MIPS_HAS_FPU == 1 ) -#define CPU_HARDWARE_FP TRUE -#else -#define CPU_HARDWARE_FP FALSE -#endif - -/* - * Are all tasks RTEMS_FLOATING_POINT tasks implicitly? - * - * If TRUE, then the RTEMS_FLOATING_POINT task attribute is assumed. - * If FALSE, then the RTEMS_FLOATING_POINT task attribute is followed. - * - * So far, the only CPU in which this option has been used is the - * HP PA-RISC. The HP C compiler and gcc both implicitly use the - * floating point registers to perform integer multiplies. If - * a function which you would not think utilize the FP unit DOES, - * then one can not easily predict which tasks will use the FP hardware. - * In this case, this option should be TRUE. - * - * If CPU_HARDWARE_FP is FALSE, then this should be FALSE as well. - * - * Mips Note: It appears the GCC can implicitly generate FPU - * and Altivec instructions when you least expect them. So make - * all tasks floating point. - */ - -#define CPU_ALL_TASKS_ARE_FP CPU_HARDWARE_FP - -/* - * Should the IDLE task have a floating point context? - * - * If TRUE, then the IDLE task is created as a RTEMS_FLOATING_POINT task - * and it has a floating point context which is switched in and out. - * If FALSE, then the IDLE task does not have a floating point context. - * - * Setting this to TRUE negatively impacts the time required to preempt - * the IDLE task from an interrupt because the floating point context - * must be saved as part of the preemption. - */ - -#define CPU_IDLE_TASK_IS_FP FALSE - -/* - * Should the saving of the floating point registers be deferred - * until a context switch is made to another different floating point - * task? - * - * If TRUE, then the floating point context will not be stored until - * necessary. It will remain in the floating point registers and not - * disturned until another floating point task is switched to. - * - * If FALSE, then the floating point context is saved when a floating - * point task is switched out and restored when the next floating point - * task is restored. The state of the floating point registers between - * those two operations is not specified. - * - * If the floating point context does NOT have to be saved as part of - * interrupt dispatching, then it should be safe to set this to TRUE. - * - * Setting this flag to TRUE results in using a different algorithm - * for deciding when to save and restore the floating point context. - * The deferred FP switch algorithm minimizes the number of times - * the FP context is saved and restored. The FP context is not saved - * until a context switch is made to another, different FP task. - * Thus in a system with only one FP task, the FP context will never - * be saved or restored. - */ - -#define CPU_USE_DEFERRED_FP_SWITCH TRUE - -#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE - -/* - * Does this port provide a CPU dependent IDLE task implementation? - * - * If TRUE, then the routine _CPU_Internal_threads_Idle_thread_body - * must be provided and is the default IDLE thread body instead of - * _Internal_threads_Idle_thread_body. - * - * If FALSE, then use the generic IDLE thread body if the BSP does - * not provide one. - * - * This is intended to allow for supporting processors which have - * a low power or idle mode. When the IDLE thread is executed, then - * the CPU can be powered down. - * - * The order of precedence for selecting the IDLE thread body is: - * - * 1. BSP provided - * 2. CPU dependent (if provided) - * 3. generic (if no BSP and no CPU dependent) - */ - -/* we can use the low power wait instruction for the IDLE thread */ -#define CPU_PROVIDES_IDLE_THREAD_BODY TRUE - -/* - * Does the stack grow up (toward higher addresses) or down - * (toward lower addresses)? - * - * If TRUE, then the grows upward. - * If FALSE, then the grows toward smaller addresses. - */ - -/* our stack grows down */ -#define CPU_STACK_GROWS_UP FALSE - -/* FIXME: Is this the right value? */ -#define CPU_CACHE_LINE_BYTES 16 - -#define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES ) - -/* - * The following defines the number of bits actually used in the - * interrupt field of the task mode. How those bits map to the - * CPU interrupt levels is defined by the routine _CPU_ISR_Set_level(). - */ - -#define CPU_MODES_INTERRUPT_MASK 0x000000ff - -#define CPU_SIZEOF_POINTER 4 - -#define CPU_MAXIMUM_PROCESSORS 32 - -/* - * Processor defined structures - * - * Examples structures include the descriptor tables from the i386 - * and the processor control structure on the i960ca. - */ - -/* may need to put some structures here. */ - -/* - * Contexts - * - * Generally there are 2 types of context to save. - * 1. Interrupt registers to save - * 2. Task level registers to save - * - * This means we have the following 3 context items: - * 1. task level context stuff:: Context_Control - * 2. floating point task stuff:: Context_Control_fp - * 3. special interrupt level context :: Context_Control_interrupt - * - * On some processors, it is cost-effective to save only the callee - * preserved registers during a task context switch. This means - * that the ISR code needs to save those registers which do not - * persist across function calls. It is not mandatory to make this - * distinctions between the caller/callee saves registers for the - * purpose of minimizing context saved during task switch and on interrupts. - * If the cost of saving extra registers is minimal, simplicity is the - * choice. Save the same context on interrupt entry as for tasks in - * this case. - * - * Additionally, if gdb is to be made aware of RTEMS tasks for this CPU, then - * care should be used in designing the context area. - * - * On some CPUs with hardware floating point support, the Context_Control_fp - * structure will not be used or it simply consist of an array of a - * fixed number of bytes. This is done when the floating point context - * is dumped by a "FP save context" type instruction and the format - * is not really defined by the CPU. In this case, there is no need - * to figure out the exact format -- only the size. Of course, although - * this is enough information for RTEMS, it is probably not enough for - * a debugger such as gdb. But that is another problem. - */ - -#ifndef ASM - -/* WARNING: If this structure is modified, the constants in cpu.h must be updated. */ -#if (__mips == 1) || (__mips == 32) -#define __MIPS_REGISTER_TYPE uint32_t -#define __MIPS_FPU_REGISTER_TYPE uint32_t -#elif __mips == 3 -#define __MIPS_REGISTER_TYPE uint64_t -#define __MIPS_FPU_REGISTER_TYPE uint64_t -#else -#error "mips register size: unknown architecture level!!" -#endif -typedef struct { - __MIPS_REGISTER_TYPE s0; - __MIPS_REGISTER_TYPE s1; - __MIPS_REGISTER_TYPE s2; - __MIPS_REGISTER_TYPE s3; - __MIPS_REGISTER_TYPE s4; - __MIPS_REGISTER_TYPE s5; - __MIPS_REGISTER_TYPE s6; - __MIPS_REGISTER_TYPE s7; - __MIPS_REGISTER_TYPE sp; - __MIPS_REGISTER_TYPE fp; - __MIPS_REGISTER_TYPE ra; - __MIPS_REGISTER_TYPE c0_sr; - __MIPS_REGISTER_TYPE c0_epc; -} Context_Control; - -#define _CPU_Context_Get_SP( _context ) \ - (uintptr_t) (_context)->sp - -/* WARNING: If this structure is modified, the constants in cpu.h - * must also be updated. - */ - -typedef struct { -#if ( CPU_HARDWARE_FP == TRUE ) - __MIPS_FPU_REGISTER_TYPE fp0; - __MIPS_FPU_REGISTER_TYPE fp1; - __MIPS_FPU_REGISTER_TYPE fp2; - __MIPS_FPU_REGISTER_TYPE fp3; - __MIPS_FPU_REGISTER_TYPE fp4; - __MIPS_FPU_REGISTER_TYPE fp5; - __MIPS_FPU_REGISTER_TYPE fp6; - __MIPS_FPU_REGISTER_TYPE fp7; - __MIPS_FPU_REGISTER_TYPE fp8; - __MIPS_FPU_REGISTER_TYPE fp9; - __MIPS_FPU_REGISTER_TYPE fp10; - __MIPS_FPU_REGISTER_TYPE fp11; - __MIPS_FPU_REGISTER_TYPE fp12; - __MIPS_FPU_REGISTER_TYPE fp13; - __MIPS_FPU_REGISTER_TYPE fp14; - __MIPS_FPU_REGISTER_TYPE fp15; - __MIPS_FPU_REGISTER_TYPE fp16; - __MIPS_FPU_REGISTER_TYPE fp17; - __MIPS_FPU_REGISTER_TYPE fp18; - __MIPS_FPU_REGISTER_TYPE fp19; - __MIPS_FPU_REGISTER_TYPE fp20; - __MIPS_FPU_REGISTER_TYPE fp21; - __MIPS_FPU_REGISTER_TYPE fp22; - __MIPS_FPU_REGISTER_TYPE fp23; - __MIPS_FPU_REGISTER_TYPE fp24; - __MIPS_FPU_REGISTER_TYPE fp25; - __MIPS_FPU_REGISTER_TYPE fp26; - __MIPS_FPU_REGISTER_TYPE fp27; - __MIPS_FPU_REGISTER_TYPE fp28; - __MIPS_FPU_REGISTER_TYPE fp29; - __MIPS_FPU_REGISTER_TYPE fp30; - __MIPS_FPU_REGISTER_TYPE fp31; - uint32_t fpcs; -#endif -} Context_Control_fp; - -/* - * This struct reflects the stack frame employed in ISR_Handler. Note - * that the ISR routine save some of the registers to this frame for - * all interrupts and exceptions. Other registers are saved only on - * exceptions, while others are not touched at all. The untouched - * registers are not normally disturbed by high-level language - * programs so they can be accessed when required. - * - * The registers and their ordering in this struct must directly - * correspond to the layout and ordering of * shown in iregdef.h, - * as cpu_asm.S uses those definitions to fill the stack frame. - * This struct provides access to the stack frame for C code. - * - * Similarly, this structure is used by debugger stubs and exception - * processing routines so be careful when changing the format. - * - * NOTE: The comments with this structure and cpu_asm.S should be kept - * in sync. When in doubt, look in the code to see if the - * registers you're interested in are actually treated as expected. - * The order of the first portion of this structure follows the - * order of registers expected by gdb. - */ - -typedef struct -{ - __MIPS_REGISTER_TYPE r0; /* 0 -- NOT FILLED IN */ - __MIPS_REGISTER_TYPE at; /* 1 -- saved always */ - __MIPS_REGISTER_TYPE v0; /* 2 -- saved always */ - __MIPS_REGISTER_TYPE v1; /* 3 -- saved always */ - __MIPS_REGISTER_TYPE a0; /* 4 -- saved always */ - __MIPS_REGISTER_TYPE a1; /* 5 -- saved always */ - __MIPS_REGISTER_TYPE a2; /* 6 -- saved always */ - __MIPS_REGISTER_TYPE a3; /* 7 -- saved always */ - __MIPS_REGISTER_TYPE t0; /* 8 -- saved always */ - __MIPS_REGISTER_TYPE t1; /* 9 -- saved always */ - __MIPS_REGISTER_TYPE t2; /* 10 -- saved always */ - __MIPS_REGISTER_TYPE t3; /* 11 -- saved always */ - __MIPS_REGISTER_TYPE t4; /* 12 -- saved always */ - __MIPS_REGISTER_TYPE t5; /* 13 -- saved always */ - __MIPS_REGISTER_TYPE t6; /* 14 -- saved always */ - __MIPS_REGISTER_TYPE t7; /* 15 -- saved always */ - __MIPS_REGISTER_TYPE s0; /* 16 -- saved on exceptions */ - __MIPS_REGISTER_TYPE s1; /* 17 -- saved on exceptions */ - __MIPS_REGISTER_TYPE s2; /* 18 -- saved on exceptions */ - __MIPS_REGISTER_TYPE s3; /* 19 -- saved on exceptions */ - __MIPS_REGISTER_TYPE s4; /* 20 -- saved on exceptions */ - __MIPS_REGISTER_TYPE s5; /* 21 -- saved on exceptions */ - __MIPS_REGISTER_TYPE s6; /* 22 -- saved on exceptions */ - __MIPS_REGISTER_TYPE s7; /* 23 -- saved on exceptions */ - __MIPS_REGISTER_TYPE t8; /* 24 -- saved always */ - __MIPS_REGISTER_TYPE t9; /* 25 -- saved always */ - __MIPS_REGISTER_TYPE k0; /* 26 -- NOT FILLED IN, kernel tmp reg */ - __MIPS_REGISTER_TYPE k1; /* 27 -- NOT FILLED IN, kernel tmp reg */ - __MIPS_REGISTER_TYPE gp; /* 28 -- saved always */ - __MIPS_REGISTER_TYPE sp; /* 29 -- saved on exceptions NOT RESTORED */ - __MIPS_REGISTER_TYPE fp; /* 30 -- saved always */ - __MIPS_REGISTER_TYPE ra; /* 31 -- saved always */ - __MIPS_REGISTER_TYPE c0_sr; /* 32 -- saved always, some bits are */ - /* manipulated per-thread */ - __MIPS_REGISTER_TYPE mdlo; /* 33 -- saved always */ - __MIPS_REGISTER_TYPE mdhi; /* 34 -- saved always */ - __MIPS_REGISTER_TYPE badvaddr; /* 35 -- saved on exceptions, read-only */ - __MIPS_REGISTER_TYPE cause; /* 36 -- saved on exceptions NOT restored */ - __MIPS_REGISTER_TYPE epc; /* 37 -- saved always, read-only register */ - /* but logically restored */ - __MIPS_FPU_REGISTER_TYPE f0; /* 38 -- saved if FP enabled */ - __MIPS_FPU_REGISTER_TYPE f1; /* 39 -- saved if FP enabled */ - __MIPS_FPU_REGISTER_TYPE f2; /* 40 -- saved if FP enabled */ - __MIPS_FPU_REGISTER_TYPE f3; /* 41 -- saved if FP enabled */ - __MIPS_FPU_REGISTER_TYPE f4; /* 42 -- saved if FP enabled */ - __MIPS_FPU_REGISTER_TYPE f5; /* 43 -- saved if FP enabled */ - __MIPS_FPU_REGISTER_TYPE f6; /* 44 -- saved if FP enabled */ - __MIPS_FPU_REGISTER_TYPE f7; /* 45 -- saved if FP enabled */ - __MIPS_FPU_REGISTER_TYPE f8; /* 46 -- saved if FP enabled */ - __MIPS_FPU_REGISTER_TYPE f9; /* 47 -- saved if FP enabled */ - __MIPS_FPU_REGISTER_TYPE f10; /* 48 -- saved if FP enabled */ - __MIPS_FPU_REGISTER_TYPE f11; /* 49 -- saved if FP enabled */ - __MIPS_FPU_REGISTER_TYPE f12; /* 50 -- saved if FP enabled */ - __MIPS_FPU_REGISTER_TYPE f13; /* 51 -- saved if FP enabled */ - __MIPS_FPU_REGISTER_TYPE f14; /* 52 -- saved if FP enabled */ - __MIPS_FPU_REGISTER_TYPE f15; /* 53 -- saved if FP enabled */ - __MIPS_FPU_REGISTER_TYPE f16; /* 54 -- saved if FP enabled */ - __MIPS_FPU_REGISTER_TYPE f17; /* 55 -- saved if FP enabled */ - __MIPS_FPU_REGISTER_TYPE f18; /* 56 -- saved if FP enabled */ - __MIPS_FPU_REGISTER_TYPE f19; /* 57 -- saved if FP enabled */ - __MIPS_FPU_REGISTER_TYPE f20; /* 58 -- saved if FP enabled */ - __MIPS_FPU_REGISTER_TYPE f21; /* 59 -- saved if FP enabled */ - __MIPS_FPU_REGISTER_TYPE f22; /* 60 -- saved if FP enabled */ - __MIPS_FPU_REGISTER_TYPE f23; /* 61 -- saved if FP enabled */ - __MIPS_FPU_REGISTER_TYPE f24; /* 62 -- saved if FP enabled */ - __MIPS_FPU_REGISTER_TYPE f25; /* 63 -- saved if FP enabled */ - __MIPS_FPU_REGISTER_TYPE f26; /* 64 -- saved if FP enabled */ - __MIPS_FPU_REGISTER_TYPE f27; /* 65 -- saved if FP enabled */ - __MIPS_FPU_REGISTER_TYPE f28; /* 66 -- saved if FP enabled */ - __MIPS_FPU_REGISTER_TYPE f29; /* 67 -- saved if FP enabled */ - __MIPS_FPU_REGISTER_TYPE f30; /* 68 -- saved if FP enabled */ - __MIPS_FPU_REGISTER_TYPE f31; /* 69 -- saved if FP enabled */ - __MIPS_REGISTER_TYPE fcsr; /* 70 -- saved on exceptions */ - /* (oddly not documented on MGV) */ - __MIPS_REGISTER_TYPE feir; /* 71 -- saved on exceptions */ - /* (oddly not documented on MGV) */ - - /* GDB does not seem to care about anything past this point */ - - __MIPS_REGISTER_TYPE tlbhi; /* 72 - NOT FILLED IN, doesn't exist on */ - /* all MIPS CPUs (at least MGV) */ -#if __mips == 1 - __MIPS_REGISTER_TYPE tlblo; /* 73 - NOT FILLED IN, doesn't exist on */ - /* all MIPS CPUs (at least MGV) */ -#endif -#if (__mips == 3) || (__mips == 32) - __MIPS_REGISTER_TYPE tlblo0; /* 73 - NOT FILLED IN, doesn't exist on */ - /* all MIPS CPUs (at least MGV) */ -#endif - - __MIPS_REGISTER_TYPE inx; /* 74 -- NOT FILLED IN, doesn't exist on */ - /* all MIPS CPUs (at least MGV) */ - __MIPS_REGISTER_TYPE rand; /* 75 -- NOT FILLED IN, doesn't exist on */ - /* all MIPS CPUs (at least MGV) */ - __MIPS_REGISTER_TYPE ctxt; /* 76 -- NOT FILLED IN, doesn't exist on */ - /* all MIPS CPUs (at least MGV) */ - __MIPS_REGISTER_TYPE exctype; /* 77 -- NOT FILLED IN (not enough info) */ - __MIPS_REGISTER_TYPE mode; /* 78 -- NOT FILLED IN (not enough info) */ - __MIPS_REGISTER_TYPE prid; /* 79 -- NOT FILLED IN (not need to do so) */ - __MIPS_REGISTER_TYPE tar ; /* 80 -- target address register, filled on exceptions */ - /* end of __mips == 1 so NREGS == 81 */ -#if (__mips == 3) || (__mips == 32) - __MIPS_REGISTER_TYPE tlblo1; /* 81 -- NOT FILLED IN */ - __MIPS_REGISTER_TYPE pagemask; /* 82 -- NOT FILLED IN */ - __MIPS_REGISTER_TYPE wired; /* 83 -- NOT FILLED IN */ - __MIPS_REGISTER_TYPE count; /* 84 -- NOT FILLED IN */ - __MIPS_REGISTER_TYPE compare; /* 85 -- NOT FILLED IN */ - __MIPS_REGISTER_TYPE config; /* 86 -- NOT FILLED IN */ - __MIPS_REGISTER_TYPE lladdr; /* 87 -- NOT FILLED IN */ - __MIPS_REGISTER_TYPE watchlo; /* 88 -- NOT FILLED IN */ - __MIPS_REGISTER_TYPE watchhi; /* 89 -- NOT FILLED IN */ - __MIPS_REGISTER_TYPE ecc; /* 90 -- NOT FILLED IN */ - __MIPS_REGISTER_TYPE cacheerr; /* 91 -- NOT FILLED IN */ - __MIPS_REGISTER_TYPE taglo; /* 92 -- NOT FILLED IN */ - __MIPS_REGISTER_TYPE taghi; /* 93 -- NOT FILLED IN */ - __MIPS_REGISTER_TYPE errpc; /* 94 -- NOT FILLED IN */ - __MIPS_REGISTER_TYPE xctxt; /* 95 -- NOT FILLED IN */ - /* end of __mips == 3 so NREGS == 96 */ -#endif - -} CPU_Interrupt_frame; - -typedef CPU_Interrupt_frame CPU_Exception_frame; - -/* - * This variable is optional. It is used on CPUs on which it is difficult - * to generate an "uninitialized" FP context. It is filled in by - * _CPU_Initialize and copied into the task's FP context area during - * _CPU_Context_Initialize. - */ - -extern Context_Control_fp _CPU_Null_fp_context; - -/* - * Nothing prevents the porter from declaring more CPU specific variables. - */ - -/* XXX: if needed, put more variables here */ - -/* - * The size of the floating point context area. On some CPUs this - * will not be a "sizeof" because the format of the floating point - * area is not defined -- only the size is. This is usually on - * CPUs with a "floating point save context" instruction. - */ - -#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp ) - -/* - * Amount of extra stack (above minimum stack size) required by - * system initialization thread. Remember that in a multiprocessor - * system the system intialization thread becomes the MP server thread. - */ - -#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0 - -/* - * Should be large enough to run all RTEMS tests. This ensures - * that a "reasonable" small application should not have any problems. - */ - -#define CPU_STACK_MINIMUM_SIZE (8 * 1024) - -/* - * CPU's worst alignment requirement for data types on a byte boundary. This - * alignment does not take into account the requirements for the stack. - */ - -#define CPU_ALIGNMENT 8 - -/* - * This number corresponds to the byte alignment requirement for the - * heap handler. This alignment requirement may be stricter than that - * for the data types alignment specified by CPU_ALIGNMENT. It is - * common for the heap to follow the same alignment requirement as - * CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict enough for the heap, - * then this should be set to CPU_ALIGNMENT. - * - * NOTE: This does not have to be a power of 2. It does have to - * be greater or equal to than CPU_ALIGNMENT. - */ - -#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT - -/* - * This number corresponds to the byte alignment requirement for memory - * buffers allocated by the partition manager. This alignment requirement - * may be stricter than that for the data types alignment specified by - * CPU_ALIGNMENT. It is common for the partition to follow the same - * alignment requirement as CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict - * enough for the partition, then this should be set to CPU_ALIGNMENT. - * - * NOTE: This does not have to be a power of 2. It does have to - * be greater or equal to than CPU_ALIGNMENT. - */ - -#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT - -/* - * This number corresponds to the byte alignment requirement for the - * stack. This alignment requirement may be stricter than that for the - * data types alignment specified by CPU_ALIGNMENT. If the CPU_ALIGNMENT - * is strict enough for the stack, then this should be set to 0. - * - * NOTE: This must be a power of 2 either 0 or greater than CPU_ALIGNMENT. - */ - -#define CPU_STACK_ALIGNMENT CPU_ALIGNMENT - -void mips_vector_exceptions( CPU_Interrupt_frame *frame ); - -/* - * ISR handler macros - */ - -/* - * Declare the function that is present in the shared libcpu directory, - * that returns the processor dependent interrupt mask. - */ - -uint32_t mips_interrupt_mask( void ); - -/* - * Disable all interrupts for an RTEMS critical section. The previous - * level is returned in _level. - */ - -#define _CPU_ISR_Disable( _level ) \ - do { \ - unsigned int _scratch; \ - mips_get_sr( _scratch ); \ - mips_set_sr( _scratch & ~SR_INTERRUPT_ENABLE_BITS ); \ - _level = _scratch & SR_INTERRUPT_ENABLE_BITS; \ - } while(0) - -/* - * Enable interrupts to the previous level (returned by _CPU_ISR_Disable). - * This indicates the end of an RTEMS critical section. The parameter - * _level is not modified. - */ - -#define _CPU_ISR_Enable( _level ) \ - do { \ - unsigned int _scratch; \ - mips_get_sr( _scratch ); \ - mips_set_sr( (_scratch & ~SR_INTERRUPT_ENABLE_BITS) | (_level & SR_INTERRUPT_ENABLE_BITS) ); \ - } while(0) - -/* - * This temporarily restores the interrupt to _level before immediately - * disabling them again. This is used to divide long RTEMS critical - * sections into two or more parts. The parameter _level is not - * modified. - */ - -#define _CPU_ISR_Flash( _xlevel ) \ - do { \ - unsigned int _scratch2 = _xlevel; \ - _CPU_ISR_Enable( _scratch2 ); \ - _CPU_ISR_Disable( _scratch2 ); \ - _xlevel = _scratch2; \ - } while(0) - -RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) -{ - return ( level & SR_INTERRUPT_ENABLE_BITS ) != 0; -} - -/* - * Map interrupt level in task mode onto the hardware that the CPU - * actually provides. Currently, interrupt levels which do not - * map onto the CPU in a generic fashion are undefined. Someday, - * it would be nice if these were "mapped" by the application - * via a callout. For example, m68k has 8 levels 0 - 7, levels - * 8 - 255 would be available for bsp/application specific meaning. - * This could be used to manage a programmable interrupt controller - * via the rtems_task_mode directive. - * - * On the MIPS, 0 is all on. Non-zero is all off. This only - * manipulates the IEC. - */ - -uint32_t _CPU_ISR_Get_level( void ); /* in cpu.c */ - -void _CPU_ISR_Set_level( uint32_t ); /* in cpu.c */ - -/* end of ISR handler macros */ - -/* Context handler macros */ - -/* - * Initialize the context to a state suitable for starting a - * task after a context restore operation. Generally, this - * involves: - * - * - setting a starting address - * - preparing the stack - * - preparing the stack and frame pointers - * - setting the proper interrupt level in the context - * - initializing the floating point context - * - * This routine generally does not set any unnecessary register - * in the context. The state of the "general data" registers is - * undefined at task start time. - * - * NOTE: This is_fp parameter is TRUE if the thread is to be a floating - * point thread. This is typically only used on CPUs where the - * FPU may be easily disabled by software such as on the SPARC - * where the PSR contains an enable FPU bit. - * - * The per-thread status register holds the interrupt enable, FP enable - * and global interrupt enable for that thread. It means each thread can - * enable its own set of interrupts. If interrupts are disabled, RTEMS - * can still dispatch via blocking calls. This is the function of the - * "Interrupt Level", and on the MIPS, it controls the IEC bit and all - * the hardware interrupts as defined in the SR. Software ints - * are automatically enabled for all threads, as they will only occur under - * program control anyhow. Besides, the interrupt level parm is only 8 bits, - * and controlling the software ints plus the others would require 9. - * - * If the Interrupt Level is 0, all ints are on. Otherwise, the - * Interrupt Level should supply a bit pattern to impose on the SR - * interrupt bits; bit 0 applies to the mips1 IEC bit/mips3 EXL&IE, bits 1 thru 6 - * apply to the SR register Intr bits from bit 10 thru bit 15. Bit 7 of - * the Interrupt Level parameter is unused at this time. - * - * These are the only per-thread SR bits, the others are maintained - * globally & explicitly preserved by the Context Switch code in cpu_asm.s - */ - - -#if (__mips == 3) || (__mips == 32) -#define _INTON SR_IE -#if __mips_fpr==64 -#define _EXTRABITS SR_FR -#else -#define _EXTRABITS 0 -#endif /* __mips_fpr==64 */ -#endif /* __mips == 3 */ -#if __mips == 1 -#define _INTON SR_IEC -#define _EXTRABITS 0 /* make sure we're in user mode on MIPS1 processors */ -#endif /* __mips == 1 */ - - -void _CPU_Context_Initialize( - Context_Control *the_context, - uintptr_t *stack_base, - uint32_t size, - uint32_t new_level, - void *entry_point, - bool is_fp, - void *tls_area -); - - -/* - * This routine is responsible for somehow restarting the currently - * executing task. If you are lucky, then all that is necessary - * is restoring the context. Otherwise, there will need to be - * a special assembly routine which does something special in this - * case. Context_Restore should work most of the time. It will - * not work if restarting self conflicts with the stack frame - * assumptions of restoring a context. - */ - -#define _CPU_Context_Restart_self( _the_context ) \ - _CPU_Context_restore( (_the_context) ); - -/* - * This routine initializes the FP context area passed to it to. - * There are a few standard ways in which to initialize the - * floating point context. The code included for this macro assumes - * that this is a CPU in which a "initial" FP context was saved into - * _CPU_Null_fp_context and it simply copies it to the destination - * context passed to it. - * - * Other models include (1) not doing anything, and (2) putting - * a "null FP status word" in the correct place in the FP context. - */ - -#if ( CPU_HARDWARE_FP == TRUE ) -#define _CPU_Context_Initialize_fp( _destination ) \ - { \ - *(*(_destination)) = _CPU_Null_fp_context; \ - } -#endif - -/* end of Context handler macros */ - -/* Fatal Error manager macros */ - -/* - * This routine copies _error into a known place -- typically a stack - * location or a register, optionally disables interrupts, and - * halts/stops the CPU. - */ - -#define _CPU_Fatal_halt( _source, _error ) \ - do { \ - unsigned int _level; \ - _CPU_ISR_Disable(_level); \ - (void)_level; \ - loop: goto loop; \ - } while (0) - - -extern void mips_break( int error ); - -#define CPU_USE_GENERIC_BITFIELD_CODE TRUE - -/* functions */ - -/* - * _CPU_Initialize - * - * This routine performs CPU dependent initialization. - */ - -void _CPU_Initialize(void); - -/* - * _CPU_ISR_install_raw_handler - * - * This routine installs a "raw" interrupt handler directly into the - * processor's vector table. - */ - -void _CPU_ISR_install_raw_handler( - uint32_t vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -/* - * _CPU_ISR_install_vector - * - * This routine installs an interrupt vector. - */ - -void _CPU_ISR_install_vector( - uint32_t vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -/* - * _CPU_Install_interrupt_stack - * - * This routine installs the hardware interrupt stack pointer. - * - * NOTE: It need only be provided if CPU_HAS_HARDWARE_INTERRUPT_STACK - * is TRUE. - */ - -void _CPU_Install_interrupt_stack( void ); - -/* - * _CPU_Internal_threads_Idle_thread_body - * - * This routine is the CPU dependent IDLE thread body. - * - * NOTE: It need only be provided if CPU_PROVIDES_IDLE_THREAD_BODY - * is TRUE. - */ - -void *_CPU_Thread_Idle_body( uintptr_t ignored ); - -/* - * _CPU_Context_switch - * - * This routine switches from the run context to the heir context. - */ - -void _CPU_Context_switch( - Context_Control *run, - Context_Control *heir -); - -/* - * _CPU_Context_restore - * - * This routine is generally used only to restart self in an - * efficient manner. It may simply be a label in _CPU_Context_switch. - * - * NOTE: May be unnecessary to reload some registers. - */ - -void _CPU_Context_restore( - Context_Control *new_context -) RTEMS_NO_RETURN; - -/* - * _CPU_Context_save_fp - * - * This routine saves the floating point context passed to it. - */ - -void _CPU_Context_save_fp( - Context_Control_fp **fp_context_ptr -); - -/* - * _CPU_Context_restore_fp - * - * This routine restores the floating point context passed to it. - */ - -void _CPU_Context_restore_fp( - Context_Control_fp **fp_context_ptr -); - -static inline void _CPU_Context_volatile_clobber( uintptr_t pattern ) -{ - /* TODO */ -} - -static inline void _CPU_Context_validate( uintptr_t pattern ) -{ - while (1) { - /* TODO */ - } -} - -void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); - -/* The following routine swaps the endian format of an unsigned int. - * It must be static because it is referenced indirectly. - * - * This version will work on any processor, but if there is a better - * way for your CPU PLEASE use it. The most common way to do this is to: - * - * swap least significant two bytes with 16-bit rotate - * swap upper and lower 16-bits - * swap most significant two bytes with 16-bit rotate - * - * Some CPUs have special instructions which swap a 32-bit quantity in - * a single instruction (e.g. i486). It is probably best to avoid - * an "endian swapping control bit" in the CPU. One good reason is - * that interrupts would probably have to be disabled to ensure that - * an interrupt does not try to access the same "chunk" with the wrong - * endian. Another good reason is that on some CPUs, the endian bit - * endianness for ALL fetches -- both code and data -- so the code - * will be fetched incorrectly. - */ - -static inline uint32_t CPU_swap_u32( - uint32_t value -) -{ - uint32_t byte1, byte2, byte3, byte4, swapped; - - byte4 = (value >> 24) & 0xff; - byte3 = (value >> 16) & 0xff; - byte2 = (value >> 8) & 0xff; - byte1 = value & 0xff; - - swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4; - return( swapped ); -} - -#define CPU_swap_u16( value ) \ - (((value&0xff) << 8) | ((value >> 8)&0xff)) - -typedef uint32_t CPU_Counter_ticks; - -CPU_Counter_ticks _CPU_Counter_read( void ); - -static inline CPU_Counter_ticks _CPU_Counter_difference( - CPU_Counter_ticks second, - CPU_Counter_ticks first -) -{ - return second - first; -} - -#endif - - - -#ifdef __cplusplus -} -#endif - -/**@}*/ -#endif diff --git a/cpukit/score/cpu/mips/rtems/score/cpuatomic.h b/cpukit/score/cpu/mips/rtems/score/cpuatomic.h deleted file mode 100644 index 598ee76b20..0000000000 --- a/cpukit/score/cpu/mips/rtems/score/cpuatomic.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * COPYRIGHT (c) 2012-2013 Deng Hengyi. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_ATOMIC_CPU_H -#define _RTEMS_SCORE_ATOMIC_CPU_H - -#include - -#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/mips/rtems/score/cpuimpl.h b/cpukit/score/cpu/mips/rtems/score/cpuimpl.h deleted file mode 100644 index 789f2badd9..0000000000 --- a/cpukit/score/cpu/mips/rtems/score/cpuimpl.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @file - * - * @brief CPU Port Implementation API - */ - -/* - * Copyright (c) 2013 embedded brains GmbH - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPUIMPL_H -#define _RTEMS_SCORE_CPUIMPL_H - -#include - -#define CPU_PER_CPU_CONTROL_SIZE 0 - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* ASM */ - -#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/mips/rtems/score/mips.h b/cpukit/score/cpu/mips/rtems/score/mips.h deleted file mode 100644 index 4c2c53fa6d..0000000000 --- a/cpukit/score/cpu/mips/rtems/score/mips.h +++ /dev/null @@ -1,299 +0,0 @@ -/** - * @file rtems/score/mips.h - * - * @brief Information to build RTEMS for a "no cpu" while in protected mode. - * - * This file contains the information required to build - * RTEMS for a particular member of the "no cpu" - * family when executing in protected mode. It does - * this by setting variables to indicate which implementation - * dependent features are present in a particular member - * of the family. - */ - -/* - * COPYRIGHT (c) 1989-2001. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_MIPS_H -#define _RTEMS_SCORE_MIPS_H - -/** - * @defgroup ScoreMips RTEMS no cpu Build Information - * - * @ingroup Score - * - */ -/**@{*/ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef ASM -#include -#endif - -/* - * SR bits that enable/disable interrupts - * - * NOTE: XXX what about SR_ERL? - */ - -#if (__mips == 3) || (__mips == 32) -#ifdef ASM -#define SR_INTERRUPT_ENABLE_BITS 0x01 -#else -#define SR_INTERRUPT_ENABLE_BITS SR_IE -#endif - -#elif __mips == 1 -#define SR_INTERRUPT_ENABLE_BITS SR_IEC - -#else -#error "mips interrupt enable bits: unknown architecture level!" -#endif - -/* - * This file contains the information required to build - * RTEMS for a particular member of the "no cpu" - * family when executing in protected mode. It does - * this by setting variables to indicate which implementation - * dependent features are present in a particular member - * of the family. - */ - -#if defined(__mips_soft_float) -#define MIPS_HAS_FPU 0 -#else -#define MIPS_HAS_FPU 1 -#endif - - -#if (__mips == 1) -#define CPU_MODEL_NAME "ISA Level 1 or 2" -#elif (__mips == 3) || (__mips == 32) -#if defined(__mips64) -#define CPU_MODEL_NAME "ISA Level 4" -#else -#define CPU_MODEL_NAME "ISA Level 3" -#endif -#else -#error "Unknown MIPS ISA level" -#endif - -/* - * Define the name of the CPU family. - */ - -#define CPU_NAME "MIPS" - -/* - * RTEMS Vector numbers for exception conditions. This is a direct - * map to the causes. - */ - -#define MIPS_EXCEPTION_BASE 0 - -#define MIPS_EXCEPTION_INT MIPS_EXCEPTION_BASE+0 -#define MIPS_EXCEPTION_MOD MIPS_EXCEPTION_BASE+1 -#define MIPS_EXCEPTION_TLBL MIPS_EXCEPTION_BASE+2 -#define MIPS_EXCEPTION_TLBS MIPS_EXCEPTION_BASE+3 -#define MIPS_EXCEPTION_ADEL MIPS_EXCEPTION_BASE+4 -#define MIPS_EXCEPTION_ADES MIPS_EXCEPTION_BASE+5 -#define MIPS_EXCEPTION_IBE MIPS_EXCEPTION_BASE+6 -#define MIPS_EXCEPTION_DBE MIPS_EXCEPTION_BASE+7 -#define MIPS_EXCEPTION_SYSCALL MIPS_EXCEPTION_BASE+8 -#define MIPS_EXCEPTION_BREAK MIPS_EXCEPTION_BASE+9 -#define MIPS_EXCEPTION_RI MIPS_EXCEPTION_BASE+10 -#define MIPS_EXCEPTION_CPU MIPS_EXCEPTION_BASE+11 -#define MIPS_EXCEPTION_OVERFLOW MIPS_EXCEPTION_BASE+12 -#define MIPS_EXCEPTION_TRAP MIPS_EXCEPTION_BASE+13 -#define MIPS_EXCEPTION_VCEI MIPS_EXCEPTION_BASE+14 -/* FPE only on mips2 and higher */ -#define MIPS_EXCEPTION_FPE MIPS_EXCEPTION_BASE+15 -#define MIPS_EXCEPTION_C2E MIPS_EXCEPTION_BASE+16 -/* 17-22 reserved */ -#define MIPS_EXCEPTION_WATCH MIPS_EXCEPTION_BASE+23 -/* 24-30 reserved */ -#define MIPS_EXCEPTION_VCED MIPS_EXCEPTION_BASE+31 - -#define MIPS_INTERRUPT_BASE MIPS_EXCEPTION_BASE+32 - -/* - * Some macros to access registers - */ - -#define mips_get_sr( _x ) \ - do { \ - __asm__ volatile( "mfc0 %0, $12; nop" : "=r" (_x) : ); \ - } while (0) - -#define mips_set_sr( _x ) \ - do { \ - register unsigned int __x = (_x); \ - __asm__ volatile( "mtc0 %0, $12; nop" : : "r" (__x) ); \ - } while (0) - - -/* - * Access the Cause register - */ - -#define mips_get_cause( _x ) \ - do { \ - __asm__ volatile( "mfc0 %0, $13; nop" : "=r" (_x) : ); \ - } while (0) - - -#define mips_set_cause( _x ) \ - do { \ - register unsigned int __x = (_x); \ - __asm__ volatile( "mtc0 %0, $13; nop" : : "r" (__x) ); \ - } while (0) - - - - -/* - * Access the Debug Cache Invalidate Control register - */ - -#define mips_get_dcic( _x ) \ - do { \ - __asm__ volatile( "mfc0 %0, $7; nop" : "=r" (_x) : ); \ - } while (0) - - -#define mips_set_dcic( _x ) \ - do { \ - register unsigned int __x = (_x); \ - __asm__ volatile( "mtc0 %0, $7; nop" : : "r" (__x) ); \ - } while (0) - - - - -/* - * Access the Breakpoint Program Counter & Mask registers - * (_x for BPC, _y for mask) - */ - -#define mips_get_bpcrm( _x, _y ) \ - do { \ - __asm__ volatile( "mfc0 %0, $3; nop" : "=r" (_x) : ); \ - __asm__ volatile( "mfc0 %0, $11; nop" : "=r" (_y) : ); \ - } while (0) - - -#define mips_set_bpcrm( _x, _y ) \ - do { \ - register unsigned int __x = (_x); \ - register unsigned int __y = (_y); \ - __asm__ volatile( "mtc0 %0, $11; nop" : : "r" (__y) ); \ - __asm__ volatile( "mtc0 %0, $3; nop" : : "r" (__x) ); \ - } while (0) - - - - - - -/* - * Access the Breakpoint Data Address & Mask registers - * (_x for BDA, _y for mask) - */ - -#define mips_get_bdarm( _x, _y ) \ - do { \ - __asm__ volatile( "mfc0 %0, $5; nop" : "=r" (_x) : ); \ - __asm__ volatile( "mfc0 %0, $9; nop" : "=r" (_y) : ); \ - } while (0) - - -#define mips_set_bdarm( _x, _y ) \ - do { \ - register unsigned int __x = (_x); \ - register unsigned int __y = (_y); \ - __asm__ volatile( "mtc0 %0, $9; nop" : : "r" (__y) ); \ - __asm__ volatile( "mtc0 %0, $5; nop" : : "r" (__x) ); \ - } while (0) - - - - - - - -/* - * Access FCR31 - */ - -#if ( MIPS_HAS_FPU == 1 ) - -#define mips_get_fcr31( _x ) \ - do { \ - __asm__ volatile( "cfc1 %0, $31; nop" : "=r" (_x) : ); \ - } while(0) - - -#define mips_set_fcr31( _x ) \ - do { \ - register unsigned int __x = (_x); \ - __asm__ volatile( "ctc1 %0, $31; nop" : : "r" (__x) ); \ - } while(0) - -#else - -#define mips_get_fcr31( _x ) -#define mips_set_fcr31( _x ) - -#endif - -/* - * Manipulate interrupt mask - * - * mips_unmask_interrupt( _mask) - * enables interrupts - mask is positioned so it only needs to be or'ed - * into the status reg. This also does some other things !!!! Caution - * should be used if invoking this while in the middle of a debugging - * session where the client may have nested interrupts. - * - * mips_mask_interrupt( _mask ) - * disable the interrupt - mask is the complement of the bits to be - * cleared - i.e. to clear ext int 5 the mask would be - 0xffff7fff - * - * - * NOTE: mips_mask_interrupt() used to be disable_int(). - * mips_unmask_interrupt() used to be enable_int(). - * - */ - -#define mips_enable_in_interrupt_mask( _mask ) \ - do { \ - unsigned int _sr; \ - mips_get_sr( _sr ); \ - _sr |= (_mask); \ - mips_set_sr( _sr ); \ - } while (0) - -#define mips_disable_in_interrupt_mask( _mask ) \ - do { \ - unsigned int _sr; \ - mips_get_sr( _sr ); \ - _sr &= ~(_mask); \ - mips_set_sr( _sr ); \ - } while (0) - -#ifdef __cplusplus -} -#endif - -/**@}*/ -#endif /* _RTEMS_SCORE_MIPS_H */ -/* end of include file */ diff --git a/cpukit/score/cpu/mips/rtems/score/types.h b/cpukit/score/cpu/mips/rtems/score/types.h deleted file mode 100644 index e3226a3bb4..0000000000 --- a/cpukit/score/cpu/mips/rtems/score/types.h +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @file rtems/score/types.h - * - * @brief Type Definitions Pertaining to the MIPS Processor Family - * - * This include file contains type definitions pertaining to the MIPS - * processor family. - */ - -/* - * COPYRIGHT (c) 1989-2001. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ -/* @(#)mipstypes.h 08/20/96 1.4 */ - -#ifndef _RTEMS_SCORE_TYPES_H -#define _RTEMS_SCORE_TYPES_H - -/** - * @defgroup ScoreTypes MIPS Processor Family Type Definitions - * - * @ingroup Score - * - */ -/**@{*/ - -#include - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This section defines the basic types for this processor. - */ - -/** Type that can store a 32-bit integer or a pointer. */ -typedef uintptr_t CPU_Uint32ptr; - -typedef void mips_isr; -typedef void ( *mips_isr_entry )( void ); - -#ifdef __cplusplus -} -#endif - -#endif /* !ASM */ - -/**@}*/ -#endif diff --git a/cpukit/score/cpu/moxie/Makefile.am b/cpukit/score/cpu/moxie/Makefile.am index edd2bd4699..29c9a656c5 100644 --- a/cpukit/score/cpu/moxie/Makefile.am +++ b/cpukit/score/cpu/moxie/Makefile.am @@ -4,19 +4,10 @@ include $(top_srcdir)/automake/compile.am -include_rtemsdir = $(includedir)/rtems -include_rtems_HEADERS = rtems/asm.h - -include_rtems_scoredir = $(includedir)/rtems/score -include_rtems_score_HEADERS = rtems/score/cpu.h rtems/score/moxie.h \ - rtems/score/types.h -include_rtems_score_HEADERS += rtems/score/cpuimpl.h -include_rtems_score_HEADERS += rtems/score/cpuatomic.h - noinst_LIBRARIES = libscorecpu.a libscorecpu_a_SOURCES = cpu.c moxie-exception-frame-print.c cpu_asm.S libscorecpu_a_SOURCES += ../no_cpu/cpucounterread.c libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS) -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am +include $(srcdir)/headers.am diff --git a/cpukit/score/cpu/moxie/headers.am b/cpukit/score/cpu/moxie/headers.am new file mode 100644 index 0000000000..4f253a662b --- /dev/null +++ b/cpukit/score/cpu/moxie/headers.am @@ -0,0 +1,17 @@ +## This file was generated by "./boostrap -H". + +include_machinedir = $(includedir)/machine +include_machine_HEADERS = +include_machine_HEADERS += include/machine/elf_machdep.h + +include_rtemsdir = $(includedir)/rtems +include_rtems_HEADERS = +include_rtems_HEADERS += include/rtems/asm.h + +include_rtems_scoredir = $(includedir)/rtems/score +include_rtems_score_HEADERS = +include_rtems_score_HEADERS += include/rtems/score/cpu.h +include_rtems_score_HEADERS += include/rtems/score/cpuatomic.h +include_rtems_score_HEADERS += include/rtems/score/cpuimpl.h +include_rtems_score_HEADERS += include/rtems/score/moxie.h +include_rtems_score_HEADERS += include/rtems/score/types.h diff --git a/cpukit/score/cpu/moxie/include/machine/elf_machdep.h b/cpukit/score/cpu/moxie/include/machine/elf_machdep.h new file mode 100644 index 0000000000..3f0df23cdc --- /dev/null +++ b/cpukit/score/cpu/moxie/include/machine/elf_machdep.h @@ -0,0 +1,15 @@ +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB + +#define ELF32_MACHDEP_ID_CASES \ + case EM_MOXIE: \ + break; + +#define ELF32_MACHDEP_ID EM_MOXIE + +#define ARCH_ELFSIZE 32 + +#define R_MOXIE_NONE 0 +#define R_MOXIE_32 1 +#define R_MOXIE_PCREL10 2 + +#define R_TYPE(name) __CONCAT(R_MOXIE_,name) diff --git a/cpukit/score/cpu/moxie/include/rtems/asm.h b/cpukit/score/cpu/moxie/include/rtems/asm.h new file mode 100644 index 0000000000..fdb182f32f --- /dev/null +++ b/cpukit/score/cpu/moxie/include/rtems/asm.h @@ -0,0 +1,116 @@ +/** + * @file rtems/asm.h + * + * This include file attempts to address the problems + * caused by incompatible flavors of assemblers and + * toolsets. It primarily addresses variations in the + * use of leading underscores on symbols and the requirement + * that register names be preceded by a %. + */ + +/* + * NOTE: The spacing in the use of these macros + * is critical to them working as advertised. + * + * COPYRIGHT: + * + * This file is based on similar code found in newlib available + * from ftp.cygnus.com. The file which was used had no copyright + * notice. This file is freely distributable as long as the source + * of the file is noted. This file is: + * + * COPYRIGHT (c) 2011 + * Anthony Green + * + * COPYRIGHT (c) 1989-1999, 2010. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + * $Id: asm.h,v 1.9 2010/06/29 00:31:09 joel Exp $ + */ + +#ifndef _RTEMS_ASM_H +#define _RTEMS_ASM_H + +/* + * Indicate we are in an assembly file and get the basic CPU definitions. + */ + +#include + +/* + * Recent versions of GNU cpp define variables which indicate the + * need for underscores and percents. If not using GNU cpp or + * the version does not support this, then you will obviously + * have to define these as appropriate. + */ + +#ifndef __USER_LABEL_PREFIX__ +#define __USER_LABEL_PREFIX__ +#endif + +#ifndef __REGISTER_PREFIX__ +#define __REGISTER_PREFIX__ "$" +#endif + +#include + +/* Use the right prefix for global labels. */ + +#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) + +/* Use the right prefix for registers. */ + +#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) + +/* + * define macros for all of the registers on this CPU + * + * EXAMPLE: #define d0 REG (d0) + */ +#define fp REG(fp) +#define sp REG(sp) +#define r0 REG(r0) +#define r1 REG(r1) +#define r2 REG(r2) +#define r3 REG(r3) +#define r4 REG(r4) +#define r5 REG(r5) +#define r6 REG(r6) +#define r7 REG(r7) +#define r8 REG(r8) +#define r9 REG(r9) +#define r10 REG(r10) +#define r11 REG(r11) +#define r12 REG(r12) +#define r13 REG(r13) + +/* + * Define macros to handle section beginning and ends. + */ + + +#define BEGIN_CODE_DCL .text +#define END_CODE_DCL +#define BEGIN_DATA_DCL .data +#define END_DATA_DCL +#define BEGIN_CODE asm ( ".text +#define END_CODE "); +#define BEGIN_DATA +#define END_DATA +#define BEGIN_BSS +#define END_BSS +#define END + +/* + * Following must be tailor for a particular flavor of the C compiler. + * They may need to put underscores in front of the symbols. + */ + +#define PUBLIC(sym) .globl SYM (sym) +#define EXTERN(sym) .globl SYM (sym) + +#endif diff --git a/cpukit/score/cpu/moxie/include/rtems/score/cpu.h b/cpukit/score/cpu/moxie/include/rtems/score/cpu.h new file mode 100644 index 0000000000..a3aac9ee41 --- /dev/null +++ b/cpukit/score/cpu/moxie/include/rtems/score/cpu.h @@ -0,0 +1,852 @@ +/** + * @file rtems/score/cpu.h + */ + +/* + * This include file contains information pertaining to the Moxie + * processor. + * + * Copyright (c) 2013 Anthony Green + * + * Based on code with the following copyright.. + * COPYRIGHT (c) 1989-2006, 2010. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPU_H +#define _RTEMS_SCORE_CPU_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include /* pick up machine definitions */ + +#include /* printk */ + +/* conditional compilation parameters */ + +/* + * Should this target use 16 or 32 bit object Ids? + * + */ +#define RTEMS_USE_32_BIT_OBJECT + +/* + * Does RTEMS manage a dedicated interrupt stack in software? + * + * If TRUE, then a stack is allocated in _ISR_Handler_initialization. + * If FALSE, nothing is done. + * + * If the CPU supports a dedicated interrupt stack in hardware, + * then it is generally the responsibility of the BSP to allocate it + * and set it up. + * + * If the CPU does not support a dedicated interrupt stack, then + * the porter has two options: (1) execute interrupts on the + * stack of the interrupted task, and (2) have RTEMS manage a dedicated + * interrupt stack. + * + * If this is TRUE, CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. + * + * Only one of CPU_HAS_SOFTWARE_INTERRUPT_STACK and + * CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is + * possible that both are FALSE for a particular CPU. Although it + * is unclear what that would imply about the interrupt processing + * procedure on that CPU. + * + * MOXIE Specific Information: + * + * XXX + */ +#define CPU_HAS_SOFTWARE_INTERRUPT_STACK TRUE + +/* + * Does the CPU follow the simple vectored interrupt model? + * + * If TRUE, then RTEMS allocates the vector table it internally manages. + * If FALSE, then the BSP is assumed to allocate and manage the vector + * table + * + * MOXIE Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_SIMPLE_VECTORED_INTERRUPTS TRUE + +/* + * Does this CPU have hardware support for a dedicated interrupt stack? + * + * If TRUE, then it must be installed during initialization. + * If FALSE, then no installation is performed. + * + * If this is TRUE, CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. + * + * Only one of CPU_HAS_SOFTWARE_INTERRUPT_STACK and + * CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is + * possible that both are FALSE for a particular CPU. Although it + * is unclear what that would imply about the interrupt processing + * procedure on that CPU. + * + * MOXIE Specific Information: + * + * XXX + */ +#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE + +/* + * Does RTEMS allocate a dedicated interrupt stack in the Interrupt Manager? + * + * If TRUE, then the memory is allocated during initialization. + * If FALSE, then the memory is allocated during initialization. + * + * This should be TRUE is CPU_HAS_SOFTWARE_INTERRUPT_STACK is TRUE. + * + * MOXIE Specific Information: + * + * XXX + */ +#define CPU_ALLOCATE_INTERRUPT_STACK TRUE + +/* + * Does the CPU have hardware floating point? + * + * If TRUE, then the RTEMS_FLOATING_POINT task attribute is supported. + * If FALSE, then the RTEMS_FLOATING_POINT task attribute is ignored. + * + * If there is a FP coprocessor such as the i387 or mc68881, then + * the answer is TRUE. + * + * The macro name "MOXIE_HAS_FPU" should be made CPU specific. + * It indicates whether or not this CPU model has FP support. For + * example, it would be possible to have an i386_nofp CPU model + * which set this to false to indicate that you have an i386 without + * an i387 and wish to leave floating point support out of RTEMS. + * + * MOXIE Specific Information: + * + * XXX + */ +#define CPU_HARDWARE_FP FALSE + +/* + * Are all tasks RTEMS_FLOATING_POINT tasks implicitly? + * + * If TRUE, then the RTEMS_FLOATING_POINT task attribute is assumed. + * If FALSE, then the RTEMS_FLOATING_POINT task attribute is followed. + * + * If CPU_HARDWARE_FP is FALSE, then this should be FALSE as well. + * + * MOXIE Specific Information: + * + * XXX + */ +#define CPU_ALL_TASKS_ARE_FP FALSE + +/* + * Should the IDLE task have a floating point context? + * + * If TRUE, then the IDLE task is created as a RTEMS_FLOATING_POINT task + * and it has a floating point context which is switched in and out. + * If FALSE, then the IDLE task does not have a floating point context. + * + * Setting this to TRUE negatively impacts the time required to preempt + * the IDLE task from an interrupt because the floating point context + * must be saved as part of the preemption. + * + * MOXIE Specific Information: + * + * XXX + */ +#define CPU_IDLE_TASK_IS_FP FALSE + +/* + * Should the saving of the floating point registers be deferred + * until a context switch is made to another different floating point + * task? + * + * If TRUE, then the floating point context will not be stored until + * necessary. It will remain in the floating point registers and not + * disturned until another floating point task is switched to. + * + * If FALSE, then the floating point context is saved when a floating + * point task is switched out and restored when the next floating point + * task is restored. The state of the floating point registers between + * those two operations is not specified. + * + * If the floating point context does NOT have to be saved as part of + * interrupt dispatching, then it should be safe to set this to TRUE. + * + * Setting this flag to TRUE results in using a different algorithm + * for deciding when to save and restore the floating point context. + * The deferred FP switch algorithm minimizes the number of times + * the FP context is saved and restored. The FP context is not saved + * until a context switch is made to another, different FP task. + * Thus in a system with only one FP task, the FP context will never + * be saved or restored. + * + * MOXIE Specific Information: + * + * XXX + */ +#define CPU_USE_DEFERRED_FP_SWITCH TRUE + +#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE + +/* + * Does this port provide a CPU dependent IDLE task implementation? + * + * If TRUE, then the routine _CPU_Internal_threads_Idle_thread_body + * must be provided and is the default IDLE thread body instead of + * _Internal_threads_Idle_thread_body. + * + * If FALSE, then use the generic IDLE thread body if the BSP does + * not provide one. + * + * This is intended to allow for supporting processors which have + * a low power or idle mode. When the IDLE thread is executed, then + * the CPU can be powered down. + * + * The order of precedence for selecting the IDLE thread body is: + * + * 1. BSP provided + * 2. CPU dependent (if provided) + * 3. generic (if no BSP and no CPU dependent) + * + * MOXIE Specific Information: + * + * XXX + * The port initially called a BSP dependent routine called + * IDLE_Monitor. The idle task body can be overridden by + * the BSP in newer versions of RTEMS. + */ +#define CPU_PROVIDES_IDLE_THREAD_BODY FALSE + +/* + * Does the stack grow up (toward higher addresses) or down + * (toward lower addresses)? + * + * If TRUE, then the grows upward. + * If FALSE, then the grows toward smaller addresses. + * + * MOXIE Specific Information: + * + * XXX + */ +#define CPU_STACK_GROWS_UP FALSE + +/* FIXME: Is this the right value? */ +#define CPU_CACHE_LINE_BYTES 32 + +#define CPU_STRUCTURE_ALIGNMENT + +/* + * The following defines the number of bits actually used in the + * interrupt field of the task mode. How those bits map to the + * CPU interrupt levels is defined by the routine _CPU_ISR_Set_level(). + * + * MOXIE Specific Information: + * + * XXX + */ +#define CPU_MODES_INTERRUPT_MASK 0x00000001 + +#define CPU_MAXIMUM_PROCESSORS 32 + +/* + * Processor defined structures required for cpukit/score. + * + * MOXIE Specific Information: + * + * XXX + */ + +/* may need to put some structures here. */ + +/* + * Contexts + * + * Generally there are 2 types of context to save. + * 1. Interrupt registers to save + * 2. Task level registers to save + * + * This means we have the following 3 context items: + * 1. task level context stuff:: Context_Control + * 2. floating point task stuff:: Context_Control_fp + * 3. special interrupt level context :: Context_Control_interrupt + * + * On some processors, it is cost-effective to save only the callee + * preserved registers during a task context switch. This means + * that the ISR code needs to save those registers which do not + * persist across function calls. It is not mandatory to make this + * distinctions between the caller/callee saves registers for the + * purpose of minimizing context saved during task switch and on interrupts. + * If the cost of saving extra registers is minimal, simplicity is the + * choice. Save the same context on interrupt entry as for tasks in + * this case. + * + * Additionally, if gdb is to be made aware of RTEMS tasks for this CPU, then + * care should be used in designing the context area. + * + * On some CPUs with hardware floating point support, the Context_Control_fp + * structure will not be used or it simply consist of an array of a + * fixed number of bytes. This is done when the floating point context + * is dumped by a "FP save context" type instruction and the format + * is not really defined by the CPU. In this case, there is no need + * to figure out the exact format -- only the size. Of course, although + * this is enough information for RTEMS, it is probably not enough for + * a debugger such as gdb. But that is another problem. + * + * MOXIE Specific Information: + * + * XXX + */ + +#define nogap __attribute__ ((packed)) + +typedef struct { + void *fp nogap; + void *sp nogap; + uint32_t r0 nogap; + uint32_t r1 nogap; + uint32_t r2 nogap; + uint32_t r3 nogap; + uint32_t r4 nogap; + uint32_t r5 nogap; + uint32_t r6 nogap; + uint32_t r7 nogap; + uint32_t r8 nogap; + uint32_t r9 nogap; + uint32_t r10 nogap; + uint32_t r11 nogap; + uint32_t r12 nogap; + uint32_t r13 nogap; +} Context_Control; + +#define _CPU_Context_Get_SP( _context ) \ + (_context)->sp + +typedef struct { + double some_float_register[2]; +} Context_Control_fp; + +typedef struct { + uint32_t special_interrupt_register; +} CPU_Interrupt_frame; + +/* + * Nothing prevents the porter from declaring more CPU specific variables. + * + * MOXIE Specific Information: + * + * XXX + */ + +/* + * The size of the floating point context area. On some CPUs this + * will not be a "sizeof" because the format of the floating point + * area is not defined -- only the size is. This is usually on + * CPUs with a "floating point save context" instruction. + * + * MOXIE Specific Information: + * + * XXX + */ +#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp ) + +/* + * Amount of extra stack (above minimum stack size) required by + * system initialization thread. Remember that in a multiprocessor + * system the system intialization thread becomes the MP server thread. + * + * MOXIE Specific Information: + * + * It is highly unlikely the MOXIE will get used in a multiprocessor system. + */ +#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0 + +/* + * This defines the number of entries in the ISR_Vector_table managed + * by RTEMS. + * + * MOXIE Specific Information: + * + * XXX + */ +#define CPU_INTERRUPT_NUMBER_OF_VECTORS 64 +#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER \ + (CPU_INTERRUPT_NUMBER_OF_VECTORS - 1) + +/* + * This is defined if the port has a special way to report the ISR nesting + * level. Most ports maintain the variable _ISR_Nest_level. + */ +#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE + +/* + * Should be large enough to run all RTEMS tests. This ensures + * that a "reasonable" small application should not have any problems. + * + * MOXIE Specific Information: + * + * XXX + */ +#define CPU_STACK_MINIMUM_SIZE (1536) + +/** + * Size of a pointer. + * + * This must be an integer literal that can be used by the assembler. This + * value will be used to calculate offsets of structure members. These + * offsets will be used in assembler code. + */ +#define CPU_SIZEOF_POINTER 4 + +/* + * CPU's worst alignment requirement for data types on a byte boundary. This + * alignment does not take into account the requirements for the stack. + * + * MOXIE Specific Information: + * + * XXX + */ +#define CPU_ALIGNMENT 8 + +/* + * This number corresponds to the byte alignment requirement for the + * heap handler. This alignment requirement may be stricter than that + * for the data types alignment specified by CPU_ALIGNMENT. It is + * common for the heap to follow the same alignment requirement as + * CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict enough for the heap, + * then this should be set to CPU_ALIGNMENT. + * + * NOTE: This does not have to be a power of 2. It does have to + * be greater or equal to than CPU_ALIGNMENT. + * + * MOXIE Specific Information: + * + * XXX + */ +#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT + +/* + * This number corresponds to the byte alignment requirement for memory + * buffers allocated by the partition manager. This alignment requirement + * may be stricter than that for the data types alignment specified by + * CPU_ALIGNMENT. It is common for the partition to follow the same + * alignment requirement as CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict + * enough for the partition, then this should be set to CPU_ALIGNMENT. + * + * NOTE: This does not have to be a power of 2. It does have to + * be greater or equal to than CPU_ALIGNMENT. + * + * MOXIE Specific Information: + * + * XXX + */ +#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT + +/* + * This number corresponds to the byte alignment requirement for the + * stack. This alignment requirement may be stricter than that for the + * data types alignment specified by CPU_ALIGNMENT. If the CPU_ALIGNMENT + * is strict enough for the stack, then this should be set to 0. + * + * NOTE: This must be a power of 2 either 0 or greater than CPU_ALIGNMENT. + * + * MOXIE Specific Information: + * + * XXX + */ +#define CPU_STACK_ALIGNMENT 0 + +/* + * ISR handler macros + */ + +/* + * Support routine to initialize the RTEMS vector table after it is allocated. + */ +#define _CPU_Initialize_vectors() + +/* + * Disable all interrupts for an RTEMS critical section. The previous + * level is returned in _level. + * + * MOXIE Specific Information: + * + * TODO: As of 7 October 2014, this method is not implemented. + */ +#define _CPU_ISR_Disable( _isr_cookie ) \ + do { \ + (_isr_cookie) = 0; \ + } while (0) + +/* + * Enable interrupts to the previous level (returned by _CPU_ISR_Disable). + * This indicates the end of an RTEMS critical section. The parameter + * _level is not modified. + * + * MOXIE Specific Information: + * + * TODO: As of 7 October 2014, this method is not implemented. + */ +#define _CPU_ISR_Enable( _isr_cookie ) \ + do { \ + (_isr_cookie) = (_isr_cookie); \ + } while (0) + +/* + * This temporarily restores the interrupt to _level before immediately + * disabling them again. This is used to divide long RTEMS critical + * sections into two or more parts. The parameter _level is not + * modified. + * + * MOXIE Specific Information: + * + * TODO: As of 7 October 2014, this method is not implemented. + */ +#define _CPU_ISR_Flash( _isr_cookie ) \ + do { \ + _CPU_ISR_Enable( _isr_cookie ); \ + _CPU_ISR_Disable( _isr_cookie ); \ + } while (0) + +RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) +{ + return true; +} + +/* + * Map interrupt level in task mode onto the hardware that the CPU + * actually provides. Currently, interrupt levels which do not + * map onto the CPU in a generic fashion are undefined. Someday, + * it would be nice if these were "mapped" by the application + * via a callout. For example, m68k has 8 levels 0 - 7, levels + * 8 - 255 would be available for bsp/application specific meaning. + * This could be used to manage a programmable interrupt controller + * via the rtems_task_mode directive. + * + * MOXIE Specific Information: + * + * TODO: As of 7 October 2014, this method is not implemented. + */ +#define _CPU_ISR_Set_level( _new_level ) \ + { \ + if (_new_level) asm volatile ( "nop\n" ); \ + else asm volatile ( "nop\n" ); \ + } + +uint32_t _CPU_ISR_Get_level( void ); + +/* end of ISR handler macros */ + +/* Context handler macros */ + +/* + * Initialize the context to a state suitable for starting a + * task after a context restore operation. Generally, this + * involves: + * + * - setting a starting address + * - preparing the stack + * - preparing the stack and frame pointers + * - setting the proper interrupt level in the context + * - initializing the floating point context + * + * This routine generally does not set any unnecessary register + * in the context. The state of the "general data" registers is + * undefined at task start time. + * + * NOTE: This is_fp parameter is TRUE if the thread is to be a floating + * point thread. This is typically only used on CPUs where the + * FPU may be easily disabled by software such as on the SPARC + * where the PSR contains an enable FPU bit. + * + * MOXIE Specific Information: + * + * TODO: As of 7 October 2014, this method does not ensure that the context + * is set up with interrupts disabled/enabled as requested. + */ +#define CPU_CCR_INTERRUPTS_ON 0x80 +#define CPU_CCR_INTERRUPTS_OFF 0x00 + +#define _CPU_Context_Initialize( _the_context, _stack_base, _size, \ + _isr, _entry_point, _is_fp, _tls_area ) \ + /* Locate Me */ \ + do { \ + uintptr_t _stack; \ + \ + (void) _is_fp; /* avoid warning for being unused */ \ + (void) _isr; /* avoid warning for being unused */ \ + _stack = ((uintptr_t)(_stack_base)) + (_size) - 8; \ + *((proc_ptr *)(_stack)) = (_entry_point); \ + _stack -= 4; \ + (_the_context)->fp = (void *)_stack; \ + (_the_context)->sp = (void *)_stack; \ + } while (0) + + +/* + * This routine is responsible for somehow restarting the currently + * executing task. If you are lucky, then all that is necessary + * is restoring the context. Otherwise, there will need to be + * a special assembly routine which does something special in this + * case. Context_Restore should work most of the time. It will + * not work if restarting self conflicts with the stack frame + * assumptions of restoring a context. + * + * MOXIE Specific Information: + * + * XXX + */ +#define _CPU_Context_Restart_self( _the_context ) \ + _CPU_Context_restore( (_the_context) ); + +#define _CPU_Context_Initialize_fp( _destination ) \ + memset( *( _destination ), 0, CPU_CONTEXT_FP_SIZE ); + +/* end of Context handler macros */ + +/* Fatal Error manager macros */ + +/* + * This routine copies _error into a known place -- typically a stack + * location or a register, optionally disables interrupts, and + * halts/stops the CPU. + * + * MOXIE Specific Information: + * + * XXX + */ +#define _CPU_Fatal_halt( _source, _error ) \ + printk("Fatal Error %d.%lu Halted\n",_source,_error); \ + for(;;) + +/* end of Fatal Error manager macros */ + +#define CPU_USE_GENERIC_BITFIELD_CODE TRUE + +/* functions */ + +/* + * _CPU_Initialize + * + * This routine performs CPU dependent initialization. + * + * MOXIE Specific Information: + * + * XXX + */ +void _CPU_Initialize(void); + +/* + * _CPU_ISR_install_raw_handler + * + * This routine installs a "raw" interrupt handler directly into the + * processor's vector table. + * + * MOXIE Specific Information: + * + * XXX + */ +void _CPU_ISR_install_raw_handler( + uint32_t vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +/* + * _CPU_ISR_install_vector + * + * This routine installs an interrupt vector. + * + * MOXIE Specific Information: + * + * XXX + */ +void _CPU_ISR_install_vector( + uint32_t vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +/* + * _CPU_Install_interrupt_stack + * + * This routine installs the hardware interrupt stack pointer. + * + * NOTE: It need only be provided if CPU_HAS_HARDWARE_INTERRUPT_STACK + * is TRUE. + * + * MOXIE Specific Information: + * + * XXX + */ +void _CPU_Install_interrupt_stack( void ); + +/* + * _CPU_Internal_threads_Idle_thread_body + * + * This routine is the CPU dependent IDLE thread body. + * + * NOTE: It need only be provided if CPU_PROVIDES_IDLE_THREAD_BODY + * is TRUE. + * + * MOXIE Specific Information: + * + * XXX + */ +void *_CPU_Thread_Idle_body( uint32_t ); + +/* + * _CPU_Context_switch + * + * This routine switches from the run context to the heir context. + * + * MOXIE Specific Information: + * + * XXX + */ +void _CPU_Context_switch( + Context_Control *run, + Context_Control *heir +); + +/* + * _CPU_Context_restore + * + * This routine is generallu used only to restart self in an + * efficient manner. It may simply be a label in _CPU_Context_switch. + * + * NOTE: May be unnecessary to reload some registers. + * + * MOXIE Specific Information: + * + * XXX + */ +void _CPU_Context_restore( + Context_Control *new_context +) RTEMS_NO_RETURN; + +/* + * _CPU_Context_save_fp + * + * This routine saves the floating point context passed to it. + * + * MOXIE Specific Information: + * + * XXX + */ +void _CPU_Context_save_fp( + Context_Control_fp **fp_context_ptr +); + +/* + * _CPU_Context_restore_fp + * + * This routine restores the floating point context passed to it. + * + * MOXIE Specific Information: + * + * XXX + */ +void _CPU_Context_restore_fp( + Context_Control_fp **fp_context_ptr +); + +static inline void _CPU_Context_volatile_clobber( uintptr_t pattern ) +{ + /* TODO */ +} + +static inline void _CPU_Context_validate( uintptr_t pattern ) +{ + while (1) { + /* TODO */ + } +} + +/** + * @brief The set of registers that specifies the complete processor state. + * + * The CPU exception frame may be available in fatal error conditions like for + * example illegal opcodes, instruction fetch errors, or data access errors. + * + * @see rtems_fatal(), RTEMS_FATAL_SOURCE_EXCEPTION, and + * rtems_exception_frame_print(). + */ +typedef struct { + uint32_t integer_registers [16]; +} CPU_Exception_frame; + +/** + * @brief Prints the exception frame via printk(). + * + * @see rtems_fatal() and RTEMS_FATAL_SOURCE_EXCEPTION. + */ +void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); + +/* The following routine swaps the endian format of an unsigned int. + * It must be static because it is referenced indirectly. + * + * This version will work on any processor, but if there is a better + * way for your CPU PLEASE use it. The most common way to do this is to: + * + * swap least significant two bytes with 16-bit rotate + * swap upper and lower 16-bits + * swap most significant two bytes with 16-bit rotate + * + * Some CPUs have special instructions which swap a 32-bit quantity in + * a single instruction (e.g. i486). It is probably best to avoid + * an "endian swapping control bit" in the CPU. One good reason is + * that interrupts would probably have to be disabled to ensure that + * an interrupt does not try to access the same "chunk" with the wrong + * endian. Another good reason is that on some CPUs, the endian bit + * endianness for ALL fetches -- both code and data -- so the code + * will be fetched incorrectly. + * + * MOXIE Specific Information: + * + * This is the generic implementation. + */ +static inline uint32_t CPU_swap_u32( + uint32_t value +) +{ + uint32_t byte1, byte2, byte3, byte4, swapped; + + byte4 = (value >> 24) & 0xff; + byte3 = (value >> 16) & 0xff; + byte2 = (value >> 8) & 0xff; + byte1 = value & 0xff; + + swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4; + return( swapped ); +} + +#define CPU_swap_u16( value ) \ + (((value&0xff) << 8) | ((value >> 8)&0xff)) + +typedef uint32_t CPU_Counter_ticks; + +CPU_Counter_ticks _CPU_Counter_read( void ); + +static inline CPU_Counter_ticks _CPU_Counter_difference( + CPU_Counter_ticks second, + CPU_Counter_ticks first +) +{ + return second - first; +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/score/cpu/moxie/include/rtems/score/cpuatomic.h b/cpukit/score/cpu/moxie/include/rtems/score/cpuatomic.h new file mode 100644 index 0000000000..598ee76b20 --- /dev/null +++ b/cpukit/score/cpu/moxie/include/rtems/score/cpuatomic.h @@ -0,0 +1,14 @@ +/* + * COPYRIGHT (c) 2012-2013 Deng Hengyi. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_ATOMIC_CPU_H +#define _RTEMS_SCORE_ATOMIC_CPU_H + +#include + +#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/moxie/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/moxie/include/rtems/score/cpuimpl.h new file mode 100644 index 0000000000..789f2badd9 --- /dev/null +++ b/cpukit/score/cpu/moxie/include/rtems/score/cpuimpl.h @@ -0,0 +1,34 @@ +/** + * @file + * + * @brief CPU Port Implementation API + */ + +/* + * Copyright (c) 2013 embedded brains GmbH + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPUIMPL_H +#define _RTEMS_SCORE_CPUIMPL_H + +#include + +#define CPU_PER_CPU_CONTROL_SIZE 0 + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ASM */ + +#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/moxie/include/rtems/score/moxie.h b/cpukit/score/cpu/moxie/include/rtems/score/moxie.h new file mode 100644 index 0000000000..66f771aadf --- /dev/null +++ b/cpukit/score/cpu/moxie/include/rtems/score/moxie.h @@ -0,0 +1,43 @@ +/** + * @file rtems/score/moxie.h + */ + +/* + * This file contains information pertaining to the Moxie processor. + * + * COPYRIGHT (c) 2011, 2013 + * Anthony Green + * + * Based on code with the following copyright... + * COPYRIGHT (c) 1989-1999, 2010. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_MOXIE_H +#define _RTEMS_SCORE_MOXIE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This file contains the information required to build + * RTEMS for a particular member of the "moxie" + * family when executing in protected mode. It does + * this by setting variables to indicate which implementation + * dependent features are present in a particular member + * of the family. + */ + +#define CPU_NAME "Moxie" +#define CPU_MODEL_NAME "MoxieLite" + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/score/cpu/moxie/include/rtems/score/types.h b/cpukit/score/cpu/moxie/include/rtems/score/types.h new file mode 100644 index 0000000000..99402b0208 --- /dev/null +++ b/cpukit/score/cpu/moxie/include/rtems/score/types.h @@ -0,0 +1,56 @@ +/** + * @file rtems/score/types.h + */ + +/* + * This file contains information pertaining to the Moxie processor. + * + * COPYRIGHT (c) 2011 + * Anthony Green + * + * Based on code with the following copyright... + * COPYRIGHT (c) 1989-1999, 2010. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_TYPES_H +#define _RTEMS_SCORE_TYPES_H + +#include + +#ifndef ASM + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This section defines the basic types for this processor. + */ + +/** Type that can store a 32-bit integer or a pointer. */ +typedef uintptr_t CPU_Uint32ptr; + +typedef void moxie_isr; +typedef void ( *moxie_isr_entry )( void ); + +#ifdef RTEMS_DEPRECATED_TYPES +typedef bool boolean; /* Boolean value */ +typedef float single_precision; /* single precision float */ +typedef double double_precision; /* double precision float */ +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* !ASM */ + +#endif diff --git a/cpukit/score/cpu/moxie/preinstall.am b/cpukit/score/cpu/moxie/preinstall.am deleted file mode 100644 index 9753489081..0000000000 --- a/cpukit/score/cpu/moxie/preinstall.am +++ /dev/null @@ -1,49 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -$(PROJECT_INCLUDE)/rtems/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems - @: > $(PROJECT_INCLUDE)/rtems/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/asm.h: rtems/asm.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/asm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/asm.h - -$(PROJECT_INCLUDE)/rtems/score/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/score - @: > $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/score/cpu.h: rtems/score/cpu.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpu.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpu.h - -$(PROJECT_INCLUDE)/rtems/score/moxie.h: rtems/score/moxie.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/moxie.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/moxie.h - -$(PROJECT_INCLUDE)/rtems/score/types.h: rtems/score/types.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/types.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/types.h - -$(PROJECT_INCLUDE)/rtems/score/cpuimpl.h: rtems/score/cpuimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h - -$(PROJECT_INCLUDE)/rtems/score/cpuatomic.h: rtems/score/cpuatomic.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h - diff --git a/cpukit/score/cpu/moxie/rtems/asm.h b/cpukit/score/cpu/moxie/rtems/asm.h deleted file mode 100644 index fdb182f32f..0000000000 --- a/cpukit/score/cpu/moxie/rtems/asm.h +++ /dev/null @@ -1,116 +0,0 @@ -/** - * @file rtems/asm.h - * - * This include file attempts to address the problems - * caused by incompatible flavors of assemblers and - * toolsets. It primarily addresses variations in the - * use of leading underscores on symbols and the requirement - * that register names be preceded by a %. - */ - -/* - * NOTE: The spacing in the use of these macros - * is critical to them working as advertised. - * - * COPYRIGHT: - * - * This file is based on similar code found in newlib available - * from ftp.cygnus.com. The file which was used had no copyright - * notice. This file is freely distributable as long as the source - * of the file is noted. This file is: - * - * COPYRIGHT (c) 2011 - * Anthony Green - * - * COPYRIGHT (c) 1989-1999, 2010. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - * - * $Id: asm.h,v 1.9 2010/06/29 00:31:09 joel Exp $ - */ - -#ifndef _RTEMS_ASM_H -#define _RTEMS_ASM_H - -/* - * Indicate we are in an assembly file and get the basic CPU definitions. - */ - -#include - -/* - * Recent versions of GNU cpp define variables which indicate the - * need for underscores and percents. If not using GNU cpp or - * the version does not support this, then you will obviously - * have to define these as appropriate. - */ - -#ifndef __USER_LABEL_PREFIX__ -#define __USER_LABEL_PREFIX__ -#endif - -#ifndef __REGISTER_PREFIX__ -#define __REGISTER_PREFIX__ "$" -#endif - -#include - -/* Use the right prefix for global labels. */ - -#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) - -/* Use the right prefix for registers. */ - -#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) - -/* - * define macros for all of the registers on this CPU - * - * EXAMPLE: #define d0 REG (d0) - */ -#define fp REG(fp) -#define sp REG(sp) -#define r0 REG(r0) -#define r1 REG(r1) -#define r2 REG(r2) -#define r3 REG(r3) -#define r4 REG(r4) -#define r5 REG(r5) -#define r6 REG(r6) -#define r7 REG(r7) -#define r8 REG(r8) -#define r9 REG(r9) -#define r10 REG(r10) -#define r11 REG(r11) -#define r12 REG(r12) -#define r13 REG(r13) - -/* - * Define macros to handle section beginning and ends. - */ - - -#define BEGIN_CODE_DCL .text -#define END_CODE_DCL -#define BEGIN_DATA_DCL .data -#define END_DATA_DCL -#define BEGIN_CODE asm ( ".text -#define END_CODE "); -#define BEGIN_DATA -#define END_DATA -#define BEGIN_BSS -#define END_BSS -#define END - -/* - * Following must be tailor for a particular flavor of the C compiler. - * They may need to put underscores in front of the symbols. - */ - -#define PUBLIC(sym) .globl SYM (sym) -#define EXTERN(sym) .globl SYM (sym) - -#endif diff --git a/cpukit/score/cpu/moxie/rtems/score/cpu.h b/cpukit/score/cpu/moxie/rtems/score/cpu.h deleted file mode 100644 index a3aac9ee41..0000000000 --- a/cpukit/score/cpu/moxie/rtems/score/cpu.h +++ /dev/null @@ -1,852 +0,0 @@ -/** - * @file rtems/score/cpu.h - */ - -/* - * This include file contains information pertaining to the Moxie - * processor. - * - * Copyright (c) 2013 Anthony Green - * - * Based on code with the following copyright.. - * COPYRIGHT (c) 1989-2006, 2010. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPU_H -#define _RTEMS_SCORE_CPU_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include /* pick up machine definitions */ - -#include /* printk */ - -/* conditional compilation parameters */ - -/* - * Should this target use 16 or 32 bit object Ids? - * - */ -#define RTEMS_USE_32_BIT_OBJECT - -/* - * Does RTEMS manage a dedicated interrupt stack in software? - * - * If TRUE, then a stack is allocated in _ISR_Handler_initialization. - * If FALSE, nothing is done. - * - * If the CPU supports a dedicated interrupt stack in hardware, - * then it is generally the responsibility of the BSP to allocate it - * and set it up. - * - * If the CPU does not support a dedicated interrupt stack, then - * the porter has two options: (1) execute interrupts on the - * stack of the interrupted task, and (2) have RTEMS manage a dedicated - * interrupt stack. - * - * If this is TRUE, CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. - * - * Only one of CPU_HAS_SOFTWARE_INTERRUPT_STACK and - * CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is - * possible that both are FALSE for a particular CPU. Although it - * is unclear what that would imply about the interrupt processing - * procedure on that CPU. - * - * MOXIE Specific Information: - * - * XXX - */ -#define CPU_HAS_SOFTWARE_INTERRUPT_STACK TRUE - -/* - * Does the CPU follow the simple vectored interrupt model? - * - * If TRUE, then RTEMS allocates the vector table it internally manages. - * If FALSE, then the BSP is assumed to allocate and manage the vector - * table - * - * MOXIE Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_SIMPLE_VECTORED_INTERRUPTS TRUE - -/* - * Does this CPU have hardware support for a dedicated interrupt stack? - * - * If TRUE, then it must be installed during initialization. - * If FALSE, then no installation is performed. - * - * If this is TRUE, CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. - * - * Only one of CPU_HAS_SOFTWARE_INTERRUPT_STACK and - * CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is - * possible that both are FALSE for a particular CPU. Although it - * is unclear what that would imply about the interrupt processing - * procedure on that CPU. - * - * MOXIE Specific Information: - * - * XXX - */ -#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE - -/* - * Does RTEMS allocate a dedicated interrupt stack in the Interrupt Manager? - * - * If TRUE, then the memory is allocated during initialization. - * If FALSE, then the memory is allocated during initialization. - * - * This should be TRUE is CPU_HAS_SOFTWARE_INTERRUPT_STACK is TRUE. - * - * MOXIE Specific Information: - * - * XXX - */ -#define CPU_ALLOCATE_INTERRUPT_STACK TRUE - -/* - * Does the CPU have hardware floating point? - * - * If TRUE, then the RTEMS_FLOATING_POINT task attribute is supported. - * If FALSE, then the RTEMS_FLOATING_POINT task attribute is ignored. - * - * If there is a FP coprocessor such as the i387 or mc68881, then - * the answer is TRUE. - * - * The macro name "MOXIE_HAS_FPU" should be made CPU specific. - * It indicates whether or not this CPU model has FP support. For - * example, it would be possible to have an i386_nofp CPU model - * which set this to false to indicate that you have an i386 without - * an i387 and wish to leave floating point support out of RTEMS. - * - * MOXIE Specific Information: - * - * XXX - */ -#define CPU_HARDWARE_FP FALSE - -/* - * Are all tasks RTEMS_FLOATING_POINT tasks implicitly? - * - * If TRUE, then the RTEMS_FLOATING_POINT task attribute is assumed. - * If FALSE, then the RTEMS_FLOATING_POINT task attribute is followed. - * - * If CPU_HARDWARE_FP is FALSE, then this should be FALSE as well. - * - * MOXIE Specific Information: - * - * XXX - */ -#define CPU_ALL_TASKS_ARE_FP FALSE - -/* - * Should the IDLE task have a floating point context? - * - * If TRUE, then the IDLE task is created as a RTEMS_FLOATING_POINT task - * and it has a floating point context which is switched in and out. - * If FALSE, then the IDLE task does not have a floating point context. - * - * Setting this to TRUE negatively impacts the time required to preempt - * the IDLE task from an interrupt because the floating point context - * must be saved as part of the preemption. - * - * MOXIE Specific Information: - * - * XXX - */ -#define CPU_IDLE_TASK_IS_FP FALSE - -/* - * Should the saving of the floating point registers be deferred - * until a context switch is made to another different floating point - * task? - * - * If TRUE, then the floating point context will not be stored until - * necessary. It will remain in the floating point registers and not - * disturned until another floating point task is switched to. - * - * If FALSE, then the floating point context is saved when a floating - * point task is switched out and restored when the next floating point - * task is restored. The state of the floating point registers between - * those two operations is not specified. - * - * If the floating point context does NOT have to be saved as part of - * interrupt dispatching, then it should be safe to set this to TRUE. - * - * Setting this flag to TRUE results in using a different algorithm - * for deciding when to save and restore the floating point context. - * The deferred FP switch algorithm minimizes the number of times - * the FP context is saved and restored. The FP context is not saved - * until a context switch is made to another, different FP task. - * Thus in a system with only one FP task, the FP context will never - * be saved or restored. - * - * MOXIE Specific Information: - * - * XXX - */ -#define CPU_USE_DEFERRED_FP_SWITCH TRUE - -#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE - -/* - * Does this port provide a CPU dependent IDLE task implementation? - * - * If TRUE, then the routine _CPU_Internal_threads_Idle_thread_body - * must be provided and is the default IDLE thread body instead of - * _Internal_threads_Idle_thread_body. - * - * If FALSE, then use the generic IDLE thread body if the BSP does - * not provide one. - * - * This is intended to allow for supporting processors which have - * a low power or idle mode. When the IDLE thread is executed, then - * the CPU can be powered down. - * - * The order of precedence for selecting the IDLE thread body is: - * - * 1. BSP provided - * 2. CPU dependent (if provided) - * 3. generic (if no BSP and no CPU dependent) - * - * MOXIE Specific Information: - * - * XXX - * The port initially called a BSP dependent routine called - * IDLE_Monitor. The idle task body can be overridden by - * the BSP in newer versions of RTEMS. - */ -#define CPU_PROVIDES_IDLE_THREAD_BODY FALSE - -/* - * Does the stack grow up (toward higher addresses) or down - * (toward lower addresses)? - * - * If TRUE, then the grows upward. - * If FALSE, then the grows toward smaller addresses. - * - * MOXIE Specific Information: - * - * XXX - */ -#define CPU_STACK_GROWS_UP FALSE - -/* FIXME: Is this the right value? */ -#define CPU_CACHE_LINE_BYTES 32 - -#define CPU_STRUCTURE_ALIGNMENT - -/* - * The following defines the number of bits actually used in the - * interrupt field of the task mode. How those bits map to the - * CPU interrupt levels is defined by the routine _CPU_ISR_Set_level(). - * - * MOXIE Specific Information: - * - * XXX - */ -#define CPU_MODES_INTERRUPT_MASK 0x00000001 - -#define CPU_MAXIMUM_PROCESSORS 32 - -/* - * Processor defined structures required for cpukit/score. - * - * MOXIE Specific Information: - * - * XXX - */ - -/* may need to put some structures here. */ - -/* - * Contexts - * - * Generally there are 2 types of context to save. - * 1. Interrupt registers to save - * 2. Task level registers to save - * - * This means we have the following 3 context items: - * 1. task level context stuff:: Context_Control - * 2. floating point task stuff:: Context_Control_fp - * 3. special interrupt level context :: Context_Control_interrupt - * - * On some processors, it is cost-effective to save only the callee - * preserved registers during a task context switch. This means - * that the ISR code needs to save those registers which do not - * persist across function calls. It is not mandatory to make this - * distinctions between the caller/callee saves registers for the - * purpose of minimizing context saved during task switch and on interrupts. - * If the cost of saving extra registers is minimal, simplicity is the - * choice. Save the same context on interrupt entry as for tasks in - * this case. - * - * Additionally, if gdb is to be made aware of RTEMS tasks for this CPU, then - * care should be used in designing the context area. - * - * On some CPUs with hardware floating point support, the Context_Control_fp - * structure will not be used or it simply consist of an array of a - * fixed number of bytes. This is done when the floating point context - * is dumped by a "FP save context" type instruction and the format - * is not really defined by the CPU. In this case, there is no need - * to figure out the exact format -- only the size. Of course, although - * this is enough information for RTEMS, it is probably not enough for - * a debugger such as gdb. But that is another problem. - * - * MOXIE Specific Information: - * - * XXX - */ - -#define nogap __attribute__ ((packed)) - -typedef struct { - void *fp nogap; - void *sp nogap; - uint32_t r0 nogap; - uint32_t r1 nogap; - uint32_t r2 nogap; - uint32_t r3 nogap; - uint32_t r4 nogap; - uint32_t r5 nogap; - uint32_t r6 nogap; - uint32_t r7 nogap; - uint32_t r8 nogap; - uint32_t r9 nogap; - uint32_t r10 nogap; - uint32_t r11 nogap; - uint32_t r12 nogap; - uint32_t r13 nogap; -} Context_Control; - -#define _CPU_Context_Get_SP( _context ) \ - (_context)->sp - -typedef struct { - double some_float_register[2]; -} Context_Control_fp; - -typedef struct { - uint32_t special_interrupt_register; -} CPU_Interrupt_frame; - -/* - * Nothing prevents the porter from declaring more CPU specific variables. - * - * MOXIE Specific Information: - * - * XXX - */ - -/* - * The size of the floating point context area. On some CPUs this - * will not be a "sizeof" because the format of the floating point - * area is not defined -- only the size is. This is usually on - * CPUs with a "floating point save context" instruction. - * - * MOXIE Specific Information: - * - * XXX - */ -#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp ) - -/* - * Amount of extra stack (above minimum stack size) required by - * system initialization thread. Remember that in a multiprocessor - * system the system intialization thread becomes the MP server thread. - * - * MOXIE Specific Information: - * - * It is highly unlikely the MOXIE will get used in a multiprocessor system. - */ -#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0 - -/* - * This defines the number of entries in the ISR_Vector_table managed - * by RTEMS. - * - * MOXIE Specific Information: - * - * XXX - */ -#define CPU_INTERRUPT_NUMBER_OF_VECTORS 64 -#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER \ - (CPU_INTERRUPT_NUMBER_OF_VECTORS - 1) - -/* - * This is defined if the port has a special way to report the ISR nesting - * level. Most ports maintain the variable _ISR_Nest_level. - */ -#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE - -/* - * Should be large enough to run all RTEMS tests. This ensures - * that a "reasonable" small application should not have any problems. - * - * MOXIE Specific Information: - * - * XXX - */ -#define CPU_STACK_MINIMUM_SIZE (1536) - -/** - * Size of a pointer. - * - * This must be an integer literal that can be used by the assembler. This - * value will be used to calculate offsets of structure members. These - * offsets will be used in assembler code. - */ -#define CPU_SIZEOF_POINTER 4 - -/* - * CPU's worst alignment requirement for data types on a byte boundary. This - * alignment does not take into account the requirements for the stack. - * - * MOXIE Specific Information: - * - * XXX - */ -#define CPU_ALIGNMENT 8 - -/* - * This number corresponds to the byte alignment requirement for the - * heap handler. This alignment requirement may be stricter than that - * for the data types alignment specified by CPU_ALIGNMENT. It is - * common for the heap to follow the same alignment requirement as - * CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict enough for the heap, - * then this should be set to CPU_ALIGNMENT. - * - * NOTE: This does not have to be a power of 2. It does have to - * be greater or equal to than CPU_ALIGNMENT. - * - * MOXIE Specific Information: - * - * XXX - */ -#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT - -/* - * This number corresponds to the byte alignment requirement for memory - * buffers allocated by the partition manager. This alignment requirement - * may be stricter than that for the data types alignment specified by - * CPU_ALIGNMENT. It is common for the partition to follow the same - * alignment requirement as CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict - * enough for the partition, then this should be set to CPU_ALIGNMENT. - * - * NOTE: This does not have to be a power of 2. It does have to - * be greater or equal to than CPU_ALIGNMENT. - * - * MOXIE Specific Information: - * - * XXX - */ -#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT - -/* - * This number corresponds to the byte alignment requirement for the - * stack. This alignment requirement may be stricter than that for the - * data types alignment specified by CPU_ALIGNMENT. If the CPU_ALIGNMENT - * is strict enough for the stack, then this should be set to 0. - * - * NOTE: This must be a power of 2 either 0 or greater than CPU_ALIGNMENT. - * - * MOXIE Specific Information: - * - * XXX - */ -#define CPU_STACK_ALIGNMENT 0 - -/* - * ISR handler macros - */ - -/* - * Support routine to initialize the RTEMS vector table after it is allocated. - */ -#define _CPU_Initialize_vectors() - -/* - * Disable all interrupts for an RTEMS critical section. The previous - * level is returned in _level. - * - * MOXIE Specific Information: - * - * TODO: As of 7 October 2014, this method is not implemented. - */ -#define _CPU_ISR_Disable( _isr_cookie ) \ - do { \ - (_isr_cookie) = 0; \ - } while (0) - -/* - * Enable interrupts to the previous level (returned by _CPU_ISR_Disable). - * This indicates the end of an RTEMS critical section. The parameter - * _level is not modified. - * - * MOXIE Specific Information: - * - * TODO: As of 7 October 2014, this method is not implemented. - */ -#define _CPU_ISR_Enable( _isr_cookie ) \ - do { \ - (_isr_cookie) = (_isr_cookie); \ - } while (0) - -/* - * This temporarily restores the interrupt to _level before immediately - * disabling them again. This is used to divide long RTEMS critical - * sections into two or more parts. The parameter _level is not - * modified. - * - * MOXIE Specific Information: - * - * TODO: As of 7 October 2014, this method is not implemented. - */ -#define _CPU_ISR_Flash( _isr_cookie ) \ - do { \ - _CPU_ISR_Enable( _isr_cookie ); \ - _CPU_ISR_Disable( _isr_cookie ); \ - } while (0) - -RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) -{ - return true; -} - -/* - * Map interrupt level in task mode onto the hardware that the CPU - * actually provides. Currently, interrupt levels which do not - * map onto the CPU in a generic fashion are undefined. Someday, - * it would be nice if these were "mapped" by the application - * via a callout. For example, m68k has 8 levels 0 - 7, levels - * 8 - 255 would be available for bsp/application specific meaning. - * This could be used to manage a programmable interrupt controller - * via the rtems_task_mode directive. - * - * MOXIE Specific Information: - * - * TODO: As of 7 October 2014, this method is not implemented. - */ -#define _CPU_ISR_Set_level( _new_level ) \ - { \ - if (_new_level) asm volatile ( "nop\n" ); \ - else asm volatile ( "nop\n" ); \ - } - -uint32_t _CPU_ISR_Get_level( void ); - -/* end of ISR handler macros */ - -/* Context handler macros */ - -/* - * Initialize the context to a state suitable for starting a - * task after a context restore operation. Generally, this - * involves: - * - * - setting a starting address - * - preparing the stack - * - preparing the stack and frame pointers - * - setting the proper interrupt level in the context - * - initializing the floating point context - * - * This routine generally does not set any unnecessary register - * in the context. The state of the "general data" registers is - * undefined at task start time. - * - * NOTE: This is_fp parameter is TRUE if the thread is to be a floating - * point thread. This is typically only used on CPUs where the - * FPU may be easily disabled by software such as on the SPARC - * where the PSR contains an enable FPU bit. - * - * MOXIE Specific Information: - * - * TODO: As of 7 October 2014, this method does not ensure that the context - * is set up with interrupts disabled/enabled as requested. - */ -#define CPU_CCR_INTERRUPTS_ON 0x80 -#define CPU_CCR_INTERRUPTS_OFF 0x00 - -#define _CPU_Context_Initialize( _the_context, _stack_base, _size, \ - _isr, _entry_point, _is_fp, _tls_area ) \ - /* Locate Me */ \ - do { \ - uintptr_t _stack; \ - \ - (void) _is_fp; /* avoid warning for being unused */ \ - (void) _isr; /* avoid warning for being unused */ \ - _stack = ((uintptr_t)(_stack_base)) + (_size) - 8; \ - *((proc_ptr *)(_stack)) = (_entry_point); \ - _stack -= 4; \ - (_the_context)->fp = (void *)_stack; \ - (_the_context)->sp = (void *)_stack; \ - } while (0) - - -/* - * This routine is responsible for somehow restarting the currently - * executing task. If you are lucky, then all that is necessary - * is restoring the context. Otherwise, there will need to be - * a special assembly routine which does something special in this - * case. Context_Restore should work most of the time. It will - * not work if restarting self conflicts with the stack frame - * assumptions of restoring a context. - * - * MOXIE Specific Information: - * - * XXX - */ -#define _CPU_Context_Restart_self( _the_context ) \ - _CPU_Context_restore( (_the_context) ); - -#define _CPU_Context_Initialize_fp( _destination ) \ - memset( *( _destination ), 0, CPU_CONTEXT_FP_SIZE ); - -/* end of Context handler macros */ - -/* Fatal Error manager macros */ - -/* - * This routine copies _error into a known place -- typically a stack - * location or a register, optionally disables interrupts, and - * halts/stops the CPU. - * - * MOXIE Specific Information: - * - * XXX - */ -#define _CPU_Fatal_halt( _source, _error ) \ - printk("Fatal Error %d.%lu Halted\n",_source,_error); \ - for(;;) - -/* end of Fatal Error manager macros */ - -#define CPU_USE_GENERIC_BITFIELD_CODE TRUE - -/* functions */ - -/* - * _CPU_Initialize - * - * This routine performs CPU dependent initialization. - * - * MOXIE Specific Information: - * - * XXX - */ -void _CPU_Initialize(void); - -/* - * _CPU_ISR_install_raw_handler - * - * This routine installs a "raw" interrupt handler directly into the - * processor's vector table. - * - * MOXIE Specific Information: - * - * XXX - */ -void _CPU_ISR_install_raw_handler( - uint32_t vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -/* - * _CPU_ISR_install_vector - * - * This routine installs an interrupt vector. - * - * MOXIE Specific Information: - * - * XXX - */ -void _CPU_ISR_install_vector( - uint32_t vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -/* - * _CPU_Install_interrupt_stack - * - * This routine installs the hardware interrupt stack pointer. - * - * NOTE: It need only be provided if CPU_HAS_HARDWARE_INTERRUPT_STACK - * is TRUE. - * - * MOXIE Specific Information: - * - * XXX - */ -void _CPU_Install_interrupt_stack( void ); - -/* - * _CPU_Internal_threads_Idle_thread_body - * - * This routine is the CPU dependent IDLE thread body. - * - * NOTE: It need only be provided if CPU_PROVIDES_IDLE_THREAD_BODY - * is TRUE. - * - * MOXIE Specific Information: - * - * XXX - */ -void *_CPU_Thread_Idle_body( uint32_t ); - -/* - * _CPU_Context_switch - * - * This routine switches from the run context to the heir context. - * - * MOXIE Specific Information: - * - * XXX - */ -void _CPU_Context_switch( - Context_Control *run, - Context_Control *heir -); - -/* - * _CPU_Context_restore - * - * This routine is generallu used only to restart self in an - * efficient manner. It may simply be a label in _CPU_Context_switch. - * - * NOTE: May be unnecessary to reload some registers. - * - * MOXIE Specific Information: - * - * XXX - */ -void _CPU_Context_restore( - Context_Control *new_context -) RTEMS_NO_RETURN; - -/* - * _CPU_Context_save_fp - * - * This routine saves the floating point context passed to it. - * - * MOXIE Specific Information: - * - * XXX - */ -void _CPU_Context_save_fp( - Context_Control_fp **fp_context_ptr -); - -/* - * _CPU_Context_restore_fp - * - * This routine restores the floating point context passed to it. - * - * MOXIE Specific Information: - * - * XXX - */ -void _CPU_Context_restore_fp( - Context_Control_fp **fp_context_ptr -); - -static inline void _CPU_Context_volatile_clobber( uintptr_t pattern ) -{ - /* TODO */ -} - -static inline void _CPU_Context_validate( uintptr_t pattern ) -{ - while (1) { - /* TODO */ - } -} - -/** - * @brief The set of registers that specifies the complete processor state. - * - * The CPU exception frame may be available in fatal error conditions like for - * example illegal opcodes, instruction fetch errors, or data access errors. - * - * @see rtems_fatal(), RTEMS_FATAL_SOURCE_EXCEPTION, and - * rtems_exception_frame_print(). - */ -typedef struct { - uint32_t integer_registers [16]; -} CPU_Exception_frame; - -/** - * @brief Prints the exception frame via printk(). - * - * @see rtems_fatal() and RTEMS_FATAL_SOURCE_EXCEPTION. - */ -void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); - -/* The following routine swaps the endian format of an unsigned int. - * It must be static because it is referenced indirectly. - * - * This version will work on any processor, but if there is a better - * way for your CPU PLEASE use it. The most common way to do this is to: - * - * swap least significant two bytes with 16-bit rotate - * swap upper and lower 16-bits - * swap most significant two bytes with 16-bit rotate - * - * Some CPUs have special instructions which swap a 32-bit quantity in - * a single instruction (e.g. i486). It is probably best to avoid - * an "endian swapping control bit" in the CPU. One good reason is - * that interrupts would probably have to be disabled to ensure that - * an interrupt does not try to access the same "chunk" with the wrong - * endian. Another good reason is that on some CPUs, the endian bit - * endianness for ALL fetches -- both code and data -- so the code - * will be fetched incorrectly. - * - * MOXIE Specific Information: - * - * This is the generic implementation. - */ -static inline uint32_t CPU_swap_u32( - uint32_t value -) -{ - uint32_t byte1, byte2, byte3, byte4, swapped; - - byte4 = (value >> 24) & 0xff; - byte3 = (value >> 16) & 0xff; - byte2 = (value >> 8) & 0xff; - byte1 = value & 0xff; - - swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4; - return( swapped ); -} - -#define CPU_swap_u16( value ) \ - (((value&0xff) << 8) | ((value >> 8)&0xff)) - -typedef uint32_t CPU_Counter_ticks; - -CPU_Counter_ticks _CPU_Counter_read( void ); - -static inline CPU_Counter_ticks _CPU_Counter_difference( - CPU_Counter_ticks second, - CPU_Counter_ticks first -) -{ - return second - first; -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/score/cpu/moxie/rtems/score/cpuatomic.h b/cpukit/score/cpu/moxie/rtems/score/cpuatomic.h deleted file mode 100644 index 598ee76b20..0000000000 --- a/cpukit/score/cpu/moxie/rtems/score/cpuatomic.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * COPYRIGHT (c) 2012-2013 Deng Hengyi. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_ATOMIC_CPU_H -#define _RTEMS_SCORE_ATOMIC_CPU_H - -#include - -#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/moxie/rtems/score/cpuimpl.h b/cpukit/score/cpu/moxie/rtems/score/cpuimpl.h deleted file mode 100644 index 789f2badd9..0000000000 --- a/cpukit/score/cpu/moxie/rtems/score/cpuimpl.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @file - * - * @brief CPU Port Implementation API - */ - -/* - * Copyright (c) 2013 embedded brains GmbH - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPUIMPL_H -#define _RTEMS_SCORE_CPUIMPL_H - -#include - -#define CPU_PER_CPU_CONTROL_SIZE 0 - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* ASM */ - -#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/moxie/rtems/score/moxie.h b/cpukit/score/cpu/moxie/rtems/score/moxie.h deleted file mode 100644 index 66f771aadf..0000000000 --- a/cpukit/score/cpu/moxie/rtems/score/moxie.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file rtems/score/moxie.h - */ - -/* - * This file contains information pertaining to the Moxie processor. - * - * COPYRIGHT (c) 2011, 2013 - * Anthony Green - * - * Based on code with the following copyright... - * COPYRIGHT (c) 1989-1999, 2010. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_MOXIE_H -#define _RTEMS_SCORE_MOXIE_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This file contains the information required to build - * RTEMS for a particular member of the "moxie" - * family when executing in protected mode. It does - * this by setting variables to indicate which implementation - * dependent features are present in a particular member - * of the family. - */ - -#define CPU_NAME "Moxie" -#define CPU_MODEL_NAME "MoxieLite" - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/score/cpu/moxie/rtems/score/types.h b/cpukit/score/cpu/moxie/rtems/score/types.h deleted file mode 100644 index 99402b0208..0000000000 --- a/cpukit/score/cpu/moxie/rtems/score/types.h +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @file rtems/score/types.h - */ - -/* - * This file contains information pertaining to the Moxie processor. - * - * COPYRIGHT (c) 2011 - * Anthony Green - * - * Based on code with the following copyright... - * COPYRIGHT (c) 1989-1999, 2010. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_TYPES_H -#define _RTEMS_SCORE_TYPES_H - -#include - -#ifndef ASM - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This section defines the basic types for this processor. - */ - -/** Type that can store a 32-bit integer or a pointer. */ -typedef uintptr_t CPU_Uint32ptr; - -typedef void moxie_isr; -typedef void ( *moxie_isr_entry )( void ); - -#ifdef RTEMS_DEPRECATED_TYPES -typedef bool boolean; /* Boolean value */ -typedef float single_precision; /* single precision float */ -typedef double double_precision; /* double precision float */ -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* !ASM */ - -#endif diff --git a/cpukit/score/cpu/nios2/Makefile.am b/cpukit/score/cpu/nios2/Makefile.am index b3e9d28c01..243f937e51 100644 --- a/cpukit/score/cpu/nios2/Makefile.am +++ b/cpukit/score/cpu/nios2/Makefile.am @@ -3,22 +3,6 @@ include $(top_srcdir)/automake/compile.am CLEANFILES = DISTCLEANFILES = -include_rtemsdir = $(includedir)/rtems - -include_rtems_HEADERS = rtems/asm.h - -include_rtems_scoredir = $(includedir)/rtems/score - -include_rtems_score_HEADERS = -include_rtems_score_HEADERS += rtems/score/cpu.h -include_rtems_score_HEADERS += rtems/score/cpuimpl.h -include_rtems_score_HEADERS += rtems/score/nios2.h -include_rtems_score_HEADERS += rtems/score/nios2-utility.h -include_rtems_score_HEADERS += rtems/score/nios2-count-zeros.h -include_rtems_score_HEADERS += rtems/score/cpu_asm.h -include_rtems_score_HEADERS += rtems/score/types.h -include_rtems_score_HEADERS += rtems/score/cpuatomic.h - noinst_LIBRARIES = libscorecpu.a libscorecpu_a_SOURCES = @@ -50,6 +34,6 @@ libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS) all-local: $(PREINSTALL_FILES) -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am +include $(srcdir)/headers.am diff --git a/cpukit/score/cpu/nios2/headers.am b/cpukit/score/cpu/nios2/headers.am new file mode 100644 index 0000000000..8cf15f1242 --- /dev/null +++ b/cpukit/score/cpu/nios2/headers.am @@ -0,0 +1,20 @@ +## This file was generated by "./boostrap -H". + +include_machinedir = $(includedir)/machine +include_machine_HEADERS = +include_machine_HEADERS += include/machine/elf_machdep.h + +include_rtemsdir = $(includedir)/rtems +include_rtems_HEADERS = +include_rtems_HEADERS += include/rtems/asm.h + +include_rtems_scoredir = $(includedir)/rtems/score +include_rtems_score_HEADERS = +include_rtems_score_HEADERS += include/rtems/score/cpu.h +include_rtems_score_HEADERS += include/rtems/score/cpu_asm.h +include_rtems_score_HEADERS += include/rtems/score/cpuatomic.h +include_rtems_score_HEADERS += include/rtems/score/cpuimpl.h +include_rtems_score_HEADERS += include/rtems/score/nios2-count-zeros.h +include_rtems_score_HEADERS += include/rtems/score/nios2-utility.h +include_rtems_score_HEADERS += include/rtems/score/nios2.h +include_rtems_score_HEADERS += include/rtems/score/types.h diff --git a/cpukit/score/cpu/nios2/include/machine/elf_machdep.h b/cpukit/score/cpu/nios2/include/machine/elf_machdep.h new file mode 100644 index 0000000000..3f3c108bf5 --- /dev/null +++ b/cpukit/score/cpu/nios2/include/machine/elf_machdep.h @@ -0,0 +1,46 @@ +/* $NetBSD: elf_machdep.h,v 1.7 2002/01/28 21:34:48 thorpej Exp $ */ + +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB +#define ELF32_MACHDEP_ID_CASES \ + case EM_ALTERA_NIOS2: \ + break; + +#define ELF64_MACHDEP_ENDIANNESS XXX /* break compilation */ +#define ELF64_MACHDEP_ID_CASES \ + /* no 64-bit ELF machine types supported */ + +#define ELF32_MACHDEP_ID EM_ALTERA_NIOS2 + +/* + * Machine-dependent ELF flags. These are defined by the GNU tools. + */ +#define EF_NIOS2 0x00810000 + +#define ARCH_ELFSIZE 32 /* MD native binary size */ + +/* NIOS2 relocation types */ +#define R_NIOS2_NONE 0 +#define R_NIOS2_32 1 +#define R_NIOS2_16 2 +#define R_NIOS2_8 3 +#define R_NIOS2_PC32 4 +#define R_NIOS2_PC16 5 +#define R_NIOS2_PC8 6 +#define R_NIOS2_GOT32 7 +#define R_NIOS2_GOT16 8 +#define R_NIOS2_GOT8 9 +#define R_NIOS2_GOT32O 10 +#define R_NIOS2_GOT16O 11 +#define R_NIOS2_GOT8O 12 +#define R_NIOS2_PLT32 13 +#define R_NIOS2_PLT16 14 +#define R_NIOS2_PLT8 15 +#define R_NIOS2_PLT32O 16 +#define R_NIOS2_PLT16O 17 +#define R_NIOS2_PLT8O 18 +#define R_NIOS2_COPY 19 +#define R_NIOS2_GLOB_DAT 20 +#define R_NIOS2_JMP_SLOT 21 +#define R_NIOS2_RELATIVE 22 + +#define R_TYPE(name) __CONCAT(R_NIOS2_,name) diff --git a/cpukit/score/cpu/nios2/include/rtems/asm.h b/cpukit/score/cpu/nios2/include/rtems/asm.h new file mode 100644 index 0000000000..45ccd8b050 --- /dev/null +++ b/cpukit/score/cpu/nios2/include/rtems/asm.h @@ -0,0 +1,98 @@ +/** + * @file + * + * @brief Address the Problems Caused by Incompatible Flavor of + * Assemblers and Toolsets + * + * This include file attempts to address the problems + * caused by incompatible flavors of assemblers and + * toolsets. It primarily addresses variations in the + * use of leading underscores on symbols and the requirement + * that register names be preceded by a %. + * + * @note The spacing in the use of these macros + * is critical to them working as advertised. + */ + +/* + * COPYRIGHT: + * + * This file is based on similar code found in newlib available + * from ftp.cygnus.com. The file which was used had no copyright + * notice. This file is freely distributable as long as the source + * of the file is noted. This file is: + * + * COPYRIGHT (c) 1994-1997. + * On-Line Applications Research Corporation (OAR). + */ + +#ifndef _RTEMS_ASM_H +#define _RTEMS_ASM_H + +/* + * Indicate we are in an assembly file and get the basic CPU definitions. + */ + +#ifndef ASM +#define ASM +#endif +#include +#include + +/* + * Recent versions of GNU cpp define variables which indicate the + * need for underscores and percents. If not using GNU cpp or + * the version does not support this, then you will obviously + * have to define these as appropriate. + */ + +#ifndef __USER_LABEL_PREFIX__ +#define __USER_LABEL_PREFIX__ _ +#endif + +#ifndef __REGISTER_PREFIX__ +#define __REGISTER_PREFIX__ +#endif + +#include + +/* Use the right prefix for global labels. */ + +#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) + +/* Use the right prefix for registers. */ + +#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) + +/* + * define macros for all of the registers on this CPU + * + * EXAMPLE: #define d0 REG (d0) + */ + +/* + * Define macros to handle section beginning and ends. + */ + + +#define BEGIN_CODE_DCL .text +#define END_CODE_DCL +#define BEGIN_DATA_DCL .data +#define END_DATA_DCL +#define BEGIN_CODE .text +#define END_CODE +#define BEGIN_DATA +#define END_DATA +#define BEGIN_BSS +#define END_BSS +#define END + +/* + * Following must be tailor for a particular flavor of the C compiler. + * They may need to put underscores in front of the symbols. + */ + +#define PUBLIC(sym) .globl SYM (sym) +#define EXTERN(sym) .globl SYM (sym) + +#endif diff --git a/cpukit/score/cpu/nios2/include/rtems/score/cpu.h b/cpukit/score/cpu/nios2/include/rtems/score/cpu.h new file mode 100644 index 0000000000..a3f2f03d36 --- /dev/null +++ b/cpukit/score/cpu/nios2/include/rtems/score/cpu.h @@ -0,0 +1,372 @@ +/** + * @file + * + * @brief Altera Nios II CPU Department Source + */ + +/* + * Copyright (c) 2011 embedded brains GmbH + * + * Copyright (c) 2006 Kolja Waschk (rtemsdev/ixo.de) + * + * COPYRIGHT (c) 1989-2004. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPU_H +#define _RTEMS_SCORE_CPU_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#define CPU_HAS_SOFTWARE_INTERRUPT_STACK TRUE + +#define CPU_SIMPLE_VECTORED_INTERRUPTS TRUE + +#define CPU_INTERRUPT_NUMBER_OF_VECTORS 32 + +#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER (CPU_INTERRUPT_NUMBER_OF_VECTORS - 1) + +#define CPU_PROVIDES_ISR_IS_IN_PROGRESS TRUE + +#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE + +#define CPU_ALLOCATE_INTERRUPT_STACK TRUE + +#define CPU_ISR_PASSES_FRAME_POINTER FALSE + +#define CPU_HARDWARE_FP FALSE + +#define CPU_SOFTWARE_FP FALSE + +#define CPU_CONTEXT_FP_SIZE 0 + +#define CPU_ALL_TASKS_ARE_FP FALSE + +#define CPU_IDLE_TASK_IS_FP FALSE + +#define CPU_USE_DEFERRED_FP_SWITCH FALSE + +#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE + +#define CPU_PROVIDES_IDLE_THREAD_BODY FALSE + +#define CPU_STACK_GROWS_UP FALSE + +/* FIXME: Is this the right value? */ +#define CPU_CACHE_LINE_BYTES 32 + +#define CPU_STRUCTURE_ALIGNMENT \ + RTEMS_SECTION( ".sdata" ) RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES ) + +#define CPU_STACK_MINIMUM_SIZE (4 * 1024) + +#define CPU_SIZEOF_POINTER 4 + +/* + * Alignment value according to "Nios II Processor Reference" chapter 7 + * "Application Binary Interface" section "Memory Alignment". + */ +#define CPU_ALIGNMENT 4 + +#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT + +#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT + +/* + * Alignment value according to "Nios II Processor Reference" chapter 7 + * "Application Binary Interface" section "Stacks". + */ +#define CPU_STACK_ALIGNMENT 4 + +/* + * A Nios II configuration with an external interrupt controller (EIC) supports + * up to 64 interrupt levels. A Nios II configuration with an internal + * interrupt controller (IIC) has only two interrupt levels (enabled and + * disabled). The _CPU_ISR_Get_level() and _CPU_ISR_Set_level() functions will + * take care about configuration specific mappings. + */ +#define CPU_MODES_INTERRUPT_MASK 0x3f + +#define CPU_USE_GENERIC_BITFIELD_CODE TRUE + +#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0 + +#define CPU_MAXIMUM_PROCESSORS 32 + +#ifndef ASM + +/** + * @brief Thread register context. + * + * The thread register context covers the non-volatile registers, the thread + * stack pointer, the return address, and the processor status. + * + * There is no need to save the global pointer (gp) since it is a system wide + * constant and set-up with the C runtime environment. + * + * The @a thread_dispatch_disabled field is used for the external interrupt + * controller (EIC) support. + * + * @see _Nios2_Thread_dispatch_disabled + */ +typedef struct { + uint32_t r16; + uint32_t r17; + uint32_t r18; + uint32_t r19; + uint32_t r20; + uint32_t r21; + uint32_t r22; + uint32_t r23; + uint32_t fp; + uint32_t status; + uint32_t sp; + uint32_t ra; + uint32_t thread_dispatch_disabled; + uint32_t stack_mpubase; + uint32_t stack_mpuacc; +} Context_Control; + +#define _CPU_Context_Get_SP( _context ) \ + (_context)->sp + +typedef void CPU_Interrupt_frame; + +typedef struct { + uint32_t r1; + uint32_t r2; + uint32_t r3; + uint32_t r4; + uint32_t r5; + uint32_t r6; + uint32_t r7; + uint32_t r8; + uint32_t r9; + uint32_t r10; + uint32_t r11; + uint32_t r12; + uint32_t r13; + uint32_t r14; + uint32_t r15; + uint32_t r16; + uint32_t r17; + uint32_t r18; + uint32_t r19; + uint32_t r20; + uint32_t r21; + uint32_t r22; + uint32_t r23; + uint32_t gp; + uint32_t fp; + uint32_t sp; + uint32_t ra; + uint32_t et; + uint32_t ea; + uint32_t status; + uint32_t ienable; + uint32_t ipending; +} CPU_Exception_frame; + +#define _CPU_Initialize_vectors() + +/** + * @brief Macro to disable interrupts. + * + * The processor status before disabling the interrupts will be stored in + * @a _isr_cookie. This value will be used in _CPU_ISR_Flash() and + * _CPU_ISR_Enable(). + * + * The global symbol _Nios2_ISR_Status_mask will be used to clear the bits in + * the status register representing the interrupt level. The global symbol + * _Nios2_ISR_Status_bits will be used to set the bits representing an + * interrupt level that disables interrupts. Both global symbols must be + * provided by the board support package. + * + * In case the Nios II uses the internal interrupt controller (IIC), then only + * the PIE status bit is used. + * + * In case the Nios II uses the external interrupt controller (EIC), then the + * RSIE status bit or the IL status field is used depending on the interrupt + * handling variant and the shadow register usage. + */ +#define _CPU_ISR_Disable( _isr_cookie ) \ + do { \ + int _tmp; \ + __asm__ volatile ( \ + "rdctl %0, status\n" \ + "movhi %1, %%hiadj(_Nios2_ISR_Status_mask)\n" \ + "addi %1, %1, %%lo(_Nios2_ISR_Status_mask)\n" \ + "and %1, %0, %1\n" \ + "ori %1, %1, %%lo(_Nios2_ISR_Status_bits)\n" \ + "wrctl status, %1" \ + : "=&r" (_isr_cookie), "=&r" (_tmp) \ + ); \ + } while ( 0 ) + +/** + * @brief Macro to restore the processor status. + * + * The @a _isr_cookie must contain the processor status returned by + * _CPU_ISR_Disable(). The value is not modified. + */ +#define _CPU_ISR_Enable( _isr_cookie ) \ + __builtin_wrctl( 0, (int) _isr_cookie ) + +/** + * @brief Macro to restore the processor status and disable the interrupts + * again. + * + * The @a _isr_cookie must contain the processor status returned by + * _CPU_ISR_Disable(). The value is not modified. + * + * This flash code is optimal for all Nios II configurations. The rdctl does + * not flush the pipeline and has only a late result penalty. The wrctl on + * the other hand leads to a pipeline flush. + */ +#define _CPU_ISR_Flash( _isr_cookie ) \ + do { \ + int _status = __builtin_rdctl( 0 ); \ + __builtin_wrctl( 0, (int) _isr_cookie ); \ + __builtin_wrctl( 0, _status ); \ + } while ( 0 ) + +bool _CPU_ISR_Is_enabled( uint32_t level ); + +/** + * @brief Sets the interrupt level for the executing thread. + * + * The valid values of @a new_level depend on the Nios II configuration. A + * value of zero represents enabled interrupts in all configurations. + * + * @see _CPU_ISR_Get_level() + */ +void _CPU_ISR_Set_level( uint32_t new_level ); + +/** + * @brief Returns the interrupt level of the executing thread. + * + * @retval 0 Interrupts are enabled. + * @retval otherwise The value depends on the Nios II configuration. In case + * of an internal interrupt controller (IIC) the only valid value is one which + * indicates disabled interrupts. In case of an external interrupt controller + * (EIC) there are two possibilities. Firstly if the RSIE status bit is used + * to disable interrupts, then one is the only valid value indicating disabled + * interrupts. Secondly if the IL status field is used to disable interrupts, + * then this value will be returned. Interrupts are disabled at the maximum + * level specified by the _Nios2_ISR_Status_bits. + */ +uint32_t _CPU_ISR_Get_level( void ); + +/** + * @brief Initializes the CPU context. + * + * The following steps are performed: + * - setting a starting address + * - preparing the stack + * - preparing the stack and frame pointers + * - setting the proper interrupt level in the context + * + * @param[in] context points to the context area + * @param[in] stack_area_begin is the low address of the allocated stack area + * @param[in] stack_area_size is the size of the stack area in bytes + * @param[in] new_level is the interrupt level for the task + * @param[in] entry_point is the task's entry point + * @param[in] is_fp is set to @c true if the task is a floating point task + * @param[in] tls_area is the thread-local storage (TLS) area + */ +void _CPU_Context_Initialize( + Context_Control *context, + void *stack_area_begin, + size_t stack_area_size, + uint32_t new_level, + void (*entry_point)( void ), + bool is_fp, + void *tls_area +); + +#define _CPU_Context_Restart_self( _the_context ) \ + _CPU_Context_restore( (_the_context) ); + +void _CPU_Fatal_halt( uint32_t _source, uint32_t _error ) + RTEMS_NO_RETURN; + +/** + * @brief CPU initialization. + */ +void _CPU_Initialize( void ); + +/** + * @brief CPU ISR install raw handler. + */ +void _CPU_ISR_install_raw_handler( + uint32_t vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +/** + * @brief CPU ISR install vector. + */ +void _CPU_ISR_install_vector( + uint32_t vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +void _CPU_Context_switch( Context_Control *run, Context_Control *heir ); + +void _CPU_Context_restore( + Context_Control *new_context +) RTEMS_NO_RETURN; + +void _CPU_Context_volatile_clobber( uintptr_t pattern ); + +void _CPU_Context_validate( uintptr_t pattern ); + +void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); + +static inline uint32_t CPU_swap_u32( uint32_t value ) +{ + uint32_t byte1, byte2, byte3, byte4, swapped; + + byte4 = (value >> 24) & 0xff; + byte3 = (value >> 16) & 0xff; + byte2 = (value >> 8) & 0xff; + byte1 = value & 0xff; + + swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4; + + return swapped; +} + +#define CPU_swap_u16( value ) \ + (((value&0xff) << 8) | ((value >> 8)&0xff)) + +typedef uint32_t CPU_Counter_ticks; + +CPU_Counter_ticks _CPU_Counter_read( void ); + +static inline CPU_Counter_ticks _CPU_Counter_difference( + CPU_Counter_ticks second, + CPU_Counter_ticks first +) +{ + return second - first; +} + +#endif /* ASM */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/score/cpu/nios2/include/rtems/score/cpu_asm.h b/cpukit/score/cpu/nios2/include/rtems/score/cpu_asm.h new file mode 100644 index 0000000000..81a19c8d69 --- /dev/null +++ b/cpukit/score/cpu/nios2/include/rtems/score/cpu_asm.h @@ -0,0 +1,74 @@ +/** + * @file + * + * @brief Altera Nios II Assembly File + * + * Very loose template for an include file for the cpu_asm.? file + * if it is implemented as a ".S" file (preprocessed by cpp) instead + * of a ".s" file (preprocessed by gm4 or gasp). + */ + +/* + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + */ + +#ifndef _RTEMS_SCORE_CPU_ASM_H +#define _RTEMS_SCORE_CPU_ASM_H + +/* pull in the generated offsets */ + +/* +#include +*/ + +/* + * Hardware General Registers + */ + +/* put something here */ + +/* + * Hardware Floating Point Registers + */ + +/* put something here */ + +/* + * Hardware Control Registers + */ + +/* put something here */ + +/* + * Calling Convention + */ + +/* put something here */ + +/* + * Temporary registers + */ + +/* put something here */ + +/* + * Floating Point Registers - SW Conventions + */ + +/* put something here */ + +/* + * Temporary floating point registers + */ + +/* put something here */ + +#endif + +/* end of file */ diff --git a/cpukit/score/cpu/nios2/include/rtems/score/cpuatomic.h b/cpukit/score/cpu/nios2/include/rtems/score/cpuatomic.h new file mode 100644 index 0000000000..598ee76b20 --- /dev/null +++ b/cpukit/score/cpu/nios2/include/rtems/score/cpuatomic.h @@ -0,0 +1,14 @@ +/* + * COPYRIGHT (c) 2012-2013 Deng Hengyi. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_ATOMIC_CPU_H +#define _RTEMS_SCORE_ATOMIC_CPU_H + +#include + +#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/nios2/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/nios2/include/rtems/score/cpuimpl.h new file mode 100644 index 0000000000..789f2badd9 --- /dev/null +++ b/cpukit/score/cpu/nios2/include/rtems/score/cpuimpl.h @@ -0,0 +1,34 @@ +/** + * @file + * + * @brief CPU Port Implementation API + */ + +/* + * Copyright (c) 2013 embedded brains GmbH + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPUIMPL_H +#define _RTEMS_SCORE_CPUIMPL_H + +#include + +#define CPU_PER_CPU_CONTROL_SIZE 0 + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ASM */ + +#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/nios2/include/rtems/score/nios2-count-zeros.h b/cpukit/score/cpu/nios2/include/rtems/score/nios2-count-zeros.h new file mode 100644 index 0000000000..bf2390a51f --- /dev/null +++ b/cpukit/score/cpu/nios2/include/rtems/score/nios2-count-zeros.h @@ -0,0 +1,70 @@ +/* + * Author: Jeffrey O. Hill + * + * Copyright 2012. Los Alamos National Security, LLC. + * This material was produced under U.S. Government contract + * DE-AC52-06NA25396 for Los Alamos National Laboratory (LANL), + * which is operated by Los Alamos National Security, LLC for + * the U.S. Department of Energy. The U.S. Government has rights + * to use, reproduce, and distribute this software. NEITHER THE + * GOVERNMENT NOR LOS ALAMOS NATIONAL SECURITY, LLC MAKES ANY + * WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LIABILITY FOR + * THE USE OF THIS SOFTWARE. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _NIOS2_COUNT_ZEROS_H +#define _NIOS2_COUNT_ZEROS_H + +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * This implementation is currently much more efficient than + * the GCC provided __builtin_clz + */ +static inline unsigned _Nios2_Count_leading_zeros( uint32_t p ) +{ + unsigned bitIdx; + + if ( p <= 0xffffu ) { + if ( p < 0x100u ) { + bitIdx = _Bitfield_Leading_zeros[ p ] + 24u; + } else { + bitIdx = _Bitfield_Leading_zeros[ p >> 8u ] + 16u; + } + } else { + p >>= 16u; + + if ( p < 0x100u ) { + bitIdx = _Bitfield_Leading_zeros[ p ] + 8u; + } else { + bitIdx = _Bitfield_Leading_zeros[ p >> 8u ]; + } + } + + return bitIdx; +} + +/* + * This implementation is currently much more efficient than + * the GCC provided __builtin_ctz + */ +static inline unsigned _Nios2_Count_trailing_zeros( uint32_t p ) +{ + return 31u - _Nios2_Count_leading_zeros( p & ( -p ) ); +} + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _NIOS2_COUNT_ZEROS_H */ diff --git a/cpukit/score/cpu/nios2/include/rtems/score/nios2-utility.h b/cpukit/score/cpu/nios2/include/rtems/score/nios2-utility.h new file mode 100644 index 0000000000..d5eb4b3597 --- /dev/null +++ b/cpukit/score/cpu/nios2/include/rtems/score/nios2-utility.h @@ -0,0 +1,516 @@ +/** + * @file + * + * @brief NIOS II Utility + */ +/* + * Copyright (c) 2011 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Obere Lagerstr. 30 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_NIOS2_UTILITY_H +#define _RTEMS_SCORE_NIOS2_UTILITY_H + +#define NIOS2_CTLREG_INDEX_STATUS 0 +#define NIOS2_CTLREG_INDEX_ESTATUS 1 +#define NIOS2_CTLREG_INDEX_BSTATUS 2 +#define NIOS2_CTLREG_INDEX_IENABLE 3 +#define NIOS2_CTLREG_INDEX_IPENDING 4 +#define NIOS2_CTLREG_INDEX_CPUID 5 +#define NIOS2_CTLREG_INDEX_EXCEPTION 7 +#define NIOS2_CTLREG_INDEX_PTEADDR 8 +#define NIOS2_CTLREG_INDEX_TLBACC 9 +#define NIOS2_CTLREG_INDEX_TLBMISC 10 +#define NIOS2_CTLREG_INDEX_BADADDR 12 +#define NIOS2_CTLREG_INDEX_CONFIG 13 +#define NIOS2_CTLREG_INDEX_MPUBASE 14 +#define NIOS2_CTLREG_INDEX_MPUACC 15 + +#define NIOS2_CONTEXT_OFFSET_R16 0 +#define NIOS2_CONTEXT_OFFSET_R17 4 +#define NIOS2_CONTEXT_OFFSET_R18 8 +#define NIOS2_CONTEXT_OFFSET_R19 12 +#define NIOS2_CONTEXT_OFFSET_R20 16 +#define NIOS2_CONTEXT_OFFSET_R21 20 +#define NIOS2_CONTEXT_OFFSET_R22 24 +#define NIOS2_CONTEXT_OFFSET_R23 28 +#define NIOS2_CONTEXT_OFFSET_FP 32 +#define NIOS2_CONTEXT_OFFSET_STATUS 36 +#define NIOS2_CONTEXT_OFFSET_SP 40 +#define NIOS2_CONTEXT_OFFSET_RA 44 +#define NIOS2_CONTEXT_OFFSET_THREAD_DISPATCH_DISABLED 48 +#define NIOS2_CONTEXT_OFFSET_STACK_MPUBASE 52 +#define NIOS2_CONTEXT_OFFSET_STACK_MPUACC 56 + +#define NIOS2_ISR_STATUS_MASK_IIC 0xfffffffe +#define NIOS2_ISR_STATUS_BITS_IIC 0x00000000 + +#define NIOS2_ISR_STATUS_MASK_EIC_IL 0xfffffc0f +#define NIOS2_ISR_STATUS_BITS_EIC_IL 0x000003f0 + +#define NIOS2_ISR_STATUS_MASK_EIC_RSIE 0xf7ffffff +#define NIOS2_ISR_STATUS_BITS_EIC_RSIE 0x00000000 + +#define NIOS2_STATUS_RSIE (1 << 23) +#define NIOS2_STATUS_NMI (1 << 22) +#define NIOS2_STATUS_PRS_OFFSET 16 +#define NIOS2_STATUS_PRS_MASK (0x3f << NIOS2_STATUS_PRS_OFFSET) +#define NIOS2_STATUS_CRS_OFFSET 10 +#define NIOS2_STATUS_CRS_MASK (0x3f << NIOS2_STATUS_CRS_OFFSET) +#define NIOS2_STATUS_IL_OFFSET 4 +#define NIOS2_STATUS_IL_MASK (0x3f << NIOS2_STATUS_IL_OFFSET) +#define NIOS2_STATUS_IH (1 << 3) +#define NIOS2_STATUS_EH (1 << 2) +#define NIOS2_STATUS_U (1 << 1) +#define NIOS2_STATUS_PIE (1 << 0) + +#define NIOS2_EXCEPTION_CAUSE_OFFSET 2 +#define NIOS2_EXCEPTION_CAUSE_MASK (0x1f << NIOS2_EXCEPTION_CAUSE_OFFSET) + +#define NIOS2_PTEADDR_PTBASE_OFFSET 22 +#define NIOS2_PTEADDR_PTBASE_MASK (0x3ff << NIOS2_PTEADDR_PTBASE_OFFSET) +#define NIOS2_PTEADDR_VPN_OFFSET 2 +#define NIOS2_PTEADDR_VPN_MASK (0xfffff << NIOS2_PTEADDR_VPN_OFFSET) + +#define NIOS2_TLBACC_IG_OFFSET 25 +#define NIOS2_TLBACC_IG_MASK (0x3ff << NIOS2_TLBACC_IG_OFFSET) +#define NIOS2_TLBACC_C (1 << 24) +#define NIOS2_TLBACC_R (1 << 23) +#define NIOS2_TLBACC_W (1 << 22) +#define NIOS2_TLBACC_X (1 << 21) +#define NIOS2_TLBACC_G (1 << 20) +#define NIOS2_TLBACC_PFN_OFFSET 2 +#define NIOS2_TLBACC_PFN_MASK (0xfffff << NIOS2_TLBACC_PFN_OFFSET) + +#define NIOS2_TLBMISC_WAY_OFFSET 20 +#define NIOS2_TLBMISC_WAY_MASK (0xf << NIOS2_TLBMISC_WAY_OFFSET) +#define NIOS2_TLBMISC_RD (1 << 19) +#define NIOS2_TLBMISC_WE (1 << 18) +#define NIOS2_TLBMISC_PID_OFFSET 5 +#define NIOS2_TLBMISC_PID_MASK (0x3fff << NIOS2_TLBMISC_PID_OFFSET) +#define NIOS2_TLBMISC_DBL (1 << 3) +#define NIOS2_TLBMISC_BAD (1 << 2) +#define NIOS2_TLBMISC_PERM (1 << 1) +#define NIOS2_TLBMISC_D (1 << 0) + +#define NIOS2_CONFIG_ANI (1 << 1) +#define NIOS2_CONFIG_PE (1 << 0) + +#define NIOS2_MPUBASE_BASE_OFFSET 6 +#define NIOS2_MPUBASE_BASE_MASK (0x1ffffff << NIOS2_MPUBASE_BASE_OFFSET) +#define NIOS2_MPUBASE_INDEX_OFFSET 1 + +/* Avoid redefines with Altera HAL */ +#define NIOS2_MPUBASE_INDEX_MASK (0x0000003e) + +#define NIOS2_MPUBASE_D (1 << 0) + +#define NIOS2_MPUACC_MASK_OFFSET 6 + +/* Avoid redefines with Altera HAL */ +#define NIOS2_MPUACC_MASK_MASK (0x7fffffc0) + +#define NIOS2_MPUACC_LIMIT_OFFSET 6 + +/* Avoid redefines with Altera HAL */ +#define NIOS2_MPUACC_LIMIT_MASK (0xffffffc0) + +#define NIOS2_MPUACC_C (1 << 5) +#define NIOS2_MPUACC_PERM_OFFSET 2 + +/* Avoid redefines with Altera HAL */ +#define NIOS2_MPUACC_PERM_MASK (0x0000001c) + +#define NIOS2_MPUACC_RD (1 << 1) +#define NIOS2_MPUACC_WR (1 << 0) + +#ifndef ASM + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @brief Nios II specific thread dispatch disabled indicator. + * + * This global variable is used by the interrupt dispatch support for the + * external interrupt controller (EIC) with shadow registers. This makes it + * possible to do the thread dispatch after an interrupt without disabled + * interrupts and thus probably reduce the maximum interrupt latency. Its + * purpose is to prevent unbounded stack usage of the interrupted thread. + */ +extern uint32_t _Nios2_Thread_dispatch_disabled; + +/** + * @brief This global symbol specifies the status register mask used to disable + * interrupts. + * + * The board support package must provide a global symbol with this name to + * specify the status register mask used in _CPU_ISR_Disable(). + */ +extern char _Nios2_ISR_Status_mask []; + +/** + * @brief This symbol specifies the status register bits used to disable + * interrupts. + * + * The board support package must provide a global symbol with this name to + * specify the status register bits used in _CPU_ISR_Disable(). + */ +extern char _Nios2_ISR_Status_bits []; + +static inline void _Nios2_Flush_pipeline( void ) +{ + __asm__ volatile ("flushp"); +} + +static inline uint32_t _Nios2_Get_ctlreg_status( void ) +{ + return (uint32_t) __builtin_rdctl( NIOS2_CTLREG_INDEX_STATUS ); +} + +static inline void _Nios2_Set_ctlreg_status( uint32_t value ) +{ + __builtin_wrctl( NIOS2_CTLREG_INDEX_STATUS, (int) value ); +} + +static inline uint32_t _Nios2_Get_ctlreg_estatus( void ) +{ + return (uint32_t) __builtin_rdctl( NIOS2_CTLREG_INDEX_ESTATUS ); +} + +static inline void _Nios2_Set_ctlreg_estatus( uint32_t value ) +{ + __builtin_wrctl( NIOS2_CTLREG_INDEX_ESTATUS, (int) value ); +} + +static inline uint32_t _Nios2_Get_ctlreg_bstatus( void ) +{ + return (uint32_t) __builtin_rdctl( NIOS2_CTLREG_INDEX_BSTATUS ); +} + +static inline void _Nios2_Set_ctlreg_bstatus( uint32_t value ) +{ + __builtin_wrctl( NIOS2_CTLREG_INDEX_BSTATUS, (int) value ); +} + +static inline uint32_t _Nios2_Get_ctlreg_ienable( void ) +{ + return (uint32_t) __builtin_rdctl( NIOS2_CTLREG_INDEX_IENABLE ); +} + +static inline void _Nios2_Set_ctlreg_ienable( uint32_t value ) +{ + __builtin_wrctl( NIOS2_CTLREG_INDEX_IENABLE, (int) value ); +} + +static inline uint32_t _Nios2_Get_ctlreg_ipending( void ) +{ + return (uint32_t) __builtin_rdctl( NIOS2_CTLREG_INDEX_IPENDING ); +} + +static inline uint32_t _Nios2_Get_ctlreg_cpuid( void ) +{ + return (uint32_t) __builtin_rdctl( NIOS2_CTLREG_INDEX_CPUID ); +} + +static inline uint32_t _Nios2_Get_ctlreg_exception( void ) +{ + return (uint32_t) __builtin_rdctl( NIOS2_CTLREG_INDEX_EXCEPTION ); +} + +static inline uint32_t _Nios2_Get_ctlreg_pteaddr( void ) +{ + return (uint32_t) __builtin_rdctl( NIOS2_CTLREG_INDEX_PTEADDR ); +} + +static inline void _Nios2_Set_ctlreg_pteaddr( uint32_t value ) +{ + __builtin_wrctl( NIOS2_CTLREG_INDEX_PTEADDR, (int) value ); +} + +static inline uint32_t _Nios2_Get_ctlreg_tlbacc( void ) +{ + return (uint32_t) __builtin_rdctl( NIOS2_CTLREG_INDEX_TLBACC ); +} + +static inline void _Nios2_Set_ctlreg_tlbacc( uint32_t value ) +{ + __builtin_wrctl( NIOS2_CTLREG_INDEX_TLBACC, (int) value ); +} + +static inline uint32_t _Nios2_Get_ctlreg_tlbmisc( void ) +{ + return (uint32_t) __builtin_rdctl( NIOS2_CTLREG_INDEX_TLBMISC ); +} + +static inline void _Nios2_Set_ctlreg_tlbmisc( uint32_t value ) +{ + __builtin_wrctl( NIOS2_CTLREG_INDEX_TLBMISC, (int) value ); +} + +static inline uint32_t _Nios2_Get_ctlreg_badaddr( void ) +{ + return (uint32_t) __builtin_rdctl( NIOS2_CTLREG_INDEX_BADADDR ); +} + +static inline uint32_t _Nios2_Get_ctlreg_config( void ) +{ + return (uint32_t) __builtin_rdctl( NIOS2_CTLREG_INDEX_CONFIG ); +} + +static inline void _Nios2_Set_ctlreg_config( uint32_t value ) +{ + __builtin_wrctl( NIOS2_CTLREG_INDEX_CONFIG, (int) value ); +} + +static inline uint32_t _Nios2_Get_ctlreg_mpubase( void ) +{ + return (uint32_t) __builtin_rdctl( NIOS2_CTLREG_INDEX_MPUBASE ); +} + +static inline void _Nios2_Set_ctlreg_mpubase( uint32_t value ) +{ + __builtin_wrctl( NIOS2_CTLREG_INDEX_MPUBASE, (int) value ); +} + +static inline uint32_t _Nios2_Get_ctlreg_mpuacc( void ) +{ + return (uint32_t) __builtin_rdctl( NIOS2_CTLREG_INDEX_MPUACC ); +} + +static inline void _Nios2_Set_ctlreg_mpuacc( uint32_t value ) +{ + __builtin_wrctl( NIOS2_CTLREG_INDEX_MPUACC, (int) value ); +} + +static inline uint32_t _Nios2_ISR_Get_status_mask( void ) +{ + return (uint32_t) &_Nios2_ISR_Status_mask [0]; +} + +static inline uint32_t _Nios2_ISR_Get_status_bits( void ) +{ + return (uint32_t) &_Nios2_ISR_Status_bits [0]; +} + +static inline bool _Nios2_Has_internal_interrupt_controller( void ) +{ + return _Nios2_ISR_Get_status_mask() == NIOS2_ISR_STATUS_MASK_IIC; +} + +uint32_t _Nios2_ISR_Set_level( uint32_t new_level, uint32_t status ); + +typedef struct { + int data_address_width; + int instruction_address_width; + int data_region_size_log2; + int instruction_region_size_log2; + int data_region_count; + int instruction_region_count; + int data_index_for_stack_protection; + bool region_uses_limit; + bool enable_data_cache_for_stack; +} Nios2_MPU_Configuration; + +void _Nios2_MPU_Set_configuration( const Nios2_MPU_Configuration *config ); + +const Nios2_MPU_Configuration *_Nios2_MPU_Get_configuration( void ); + +typedef enum { + NIOS2_MPU_INST_PERM_SVR_NONE_USER_NONE = 0, + NIOS2_MPU_INST_PERM_SVR_EXECUTE_USER_NONE, + NIOS2_MPU_INST_PERM_SVR_EXECUTE_USER_EXECUTE, + NIOS2_MPU_DATA_PERM_SVR_NONE_USER_NONE = 0, + NIOS2_MPU_DATA_PERM_SVR_READONLY_USER_NONE, + NIOS2_MPU_DATA_PERM_SVR_READONLY_USER_READONLY, + NIOS2_MPU_DATA_PERM_SVR_READWRITE_USER_NONE = 4, + NIOS2_MPU_DATA_PERM_SVR_READWRITE_USER_READONLY, + NIOS2_MPU_DATA_PERM_SVR_READWRITE_USER_READWRITE +} Nios2_MPU_Region_permissions; + +typedef struct { + int index; + const void *base; + const void *end; + Nios2_MPU_Region_permissions perm; + bool data; + bool cacheable; + bool read; + bool write; +} Nios2_MPU_Region_descriptor; + +#define NIOS2_MPU_REGION_DESC_INST( index, base, end ) \ + { \ + (index), (base), (end), NIOS2_MPU_INST_PERM_SVR_EXECUTE_USER_NONE, \ + false, false, false, true \ + } + +#define NIOS2_MPU_REGION_DESC_DATA_RO( index, base, end ) \ + { \ + (index), (base), (end), NIOS2_MPU_DATA_PERM_SVR_READONLY_USER_NONE, \ + true, true, false, true \ + } + +#define NIOS2_MPU_REGION_DESC_DATA_RW( index, base, end ) \ + { \ + (index), (base), (end), NIOS2_MPU_DATA_PERM_SVR_READWRITE_USER_NONE, \ + true, true, false, true \ + } + +#define NIOS2_MPU_REGION_DESC_DATA_IO( index, base, end ) \ + { \ + (index), (base), (end), NIOS2_MPU_DATA_PERM_SVR_READWRITE_USER_NONE, \ + true, false, false, true \ + } + +static inline int _Nios2_MPU_Get_region_count( + const Nios2_MPU_Configuration *config, + bool data +) +{ + return data ? + config->data_region_count + : config->instruction_region_count; +} + +static inline bool _Nios2_MPU_Is_valid_index( + const Nios2_MPU_Configuration *config, + int index, + bool data +) +{ + return 0 <= index + && index < _Nios2_MPU_Get_region_count( config, data ); +} + +bool _Nios2_MPU_Setup_region_registers( + const Nios2_MPU_Configuration *config, + const Nios2_MPU_Region_descriptor *desc, + uint32_t *mpubase, + uint32_t *mpuacc +); + +bool _Nios2_MPU_Get_region_descriptor( + const Nios2_MPU_Configuration *config, + int index, + bool data, + Nios2_MPU_Region_descriptor *desc +); + +/** + * @brief Searches the region table part for a disabled region. + * + * The table will be searched between indices @a begin and @a end. The @a end + * index is not part of the search range. If @a end is negative, then the + * region count will be used. Thus a @a begin of 0 and a @a end of -1 will + * specify the complete table. + * + * @retval -1 No disabled region is available. + * @retval other Index of disabled region. + */ +int _Nios2_MPU_Get_disabled_region_index( + const Nios2_MPU_Configuration *config, + bool data, + int begin, + int end +); + +/** + * @brief Adds a region according to region descriptor @a desc. + * + * If @a force is true, then an enabled region will be overwritten. + * + * @retval true Successful operation. + * @retval false Invalid region descriptor or region already in use. + */ +bool _Nios2_MPU_Add_region( + const Nios2_MPU_Configuration *config, + const Nios2_MPU_Region_descriptor *desc, + bool force +); + +static inline void _Nios2_MPU_Get_region_registers( + int index, + bool data, + uint32_t *mpubase, + uint32_t *mpuacc +) +{ + uint32_t base = (uint32_t) + (((index << NIOS2_MPUBASE_INDEX_OFFSET) & NIOS2_MPUBASE_INDEX_MASK) + | (data ? NIOS2_MPUBASE_D : 0)); + + _Nios2_Set_ctlreg_mpubase( base ); + _Nios2_Set_ctlreg_mpuacc( NIOS2_MPUACC_RD ); + _Nios2_Flush_pipeline(); + *mpubase = _Nios2_Get_ctlreg_mpubase() | base; + *mpuacc = _Nios2_Get_ctlreg_mpuacc(); +} + +static inline void _Nios2_MPU_Set_region_registers( + uint32_t mpubase, + uint32_t mpuacc +) +{ + _Nios2_Set_ctlreg_mpubase( mpubase ); + _Nios2_Set_ctlreg_mpuacc( mpuacc ); + _Nios2_Flush_pipeline(); +} + +static inline void _Nios2_MPU_Enable( void ) +{ + uint32_t config = _Nios2_Get_ctlreg_config(); + + _Nios2_Set_ctlreg_config( config | NIOS2_CONFIG_PE ); +} + +static inline uint32_t _Nios2_MPU_Disable( void ) +{ + uint32_t config = _Nios2_Get_ctlreg_config(); + uint32_t config_pe = NIOS2_CONFIG_PE; + + _Nios2_Set_ctlreg_config( config & ~config_pe ); + + return config; +} + +static inline void _Nios2_MPU_Restore( uint32_t config ) +{ + _Nios2_Set_ctlreg_config( config ); +} + +uint32_t _Nios2_MPU_Disable_protected( void ); + +void _Nios2_MPU_Reset( const Nios2_MPU_Configuration *config ); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#else /* ASM */ + + .macro NIOS2_ASM_DISABLE_INTERRUPTS new_status, current_status + movhi \new_status, %hiadj(_Nios2_ISR_Status_mask) + addi \new_status, \new_status, %lo(_Nios2_ISR_Status_mask) + and \new_status, \current_status, \new_status + ori \new_status, \new_status, %lo(_Nios2_ISR_Status_bits) + wrctl status, \new_status + .endm + +#endif /* ASM */ + +#endif /* _RTEMS_SCORE_NIOS2_UTILITY_H */ diff --git a/cpukit/score/cpu/nios2/include/rtems/score/nios2.h b/cpukit/score/cpu/nios2/include/rtems/score/nios2.h new file mode 100644 index 0000000000..26d76bcbfa --- /dev/null +++ b/cpukit/score/cpu/nios2/include/rtems/score/nios2.h @@ -0,0 +1,65 @@ +/** + * @file + * + * @brief NIOS II Set up Basic CPU Dependency Settings Based on + * Compiler Settings + * + * This file sets up basic CPU dependency settings based on + * compiler settings. For example, it can determine if + * floating point is available. This particular implementation + * is specific to the NIOS2 port. + */ + +/* + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + */ + +#ifndef _RTEMS_SCORE_NIOS2_H +#define _RTEMS_SCORE_NIOS2_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This file contains the information required to build + * RTEMS for a particular member of the NIOS2 family. + * It does this by setting variables to indicate which + * implementation dependent features are present in a particular + * member of the family. + * + * This is a good place to list all the known CPU models + * that this port supports and which RTEMS CPU model they correspond + * to. + */ + +/* + * Define the name of the CPU family and specific model. + */ + +#define CPU_NAME "NIOS2" +#define CPU_MODEL_NAME "nios2" + +/* + * See also nios2-rtems-gcc -print-multi-lib for all valid combinations of + * + * -mno-hw-mul + * -mhw-mulx + * -mstack-check + * -pg + * -EB + * -mcustom-fpu-cfg=60-1 + * -mcustom-fpu-cfg=60-2 + */ + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_SCORE_NIOS2_H */ diff --git a/cpukit/score/cpu/nios2/include/rtems/score/types.h b/cpukit/score/cpu/nios2/include/rtems/score/types.h new file mode 100644 index 0000000000..23cf39419b --- /dev/null +++ b/cpukit/score/cpu/nios2/include/rtems/score/types.h @@ -0,0 +1,46 @@ +/** + * @file + * + * @brief Altera Nios II CPU Type Definitions + * + * This include file contains type definitions pertaining to the + * Altera Nios II processor family. + */ + +/* + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_TYPES_H +#define _RTEMS_SCORE_TYPES_H + +#include + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This section defines the basic types for this processor. + */ + +/** Type that can store a 32-bit integer or a pointer. */ +typedef uintptr_t CPU_Uint32ptr; + +typedef void nios2_isr; +typedef void ( *nios2_isr_entry )( void ); + +#ifdef __cplusplus +} +#endif + +#endif /* !ASM */ + +#endif diff --git a/cpukit/score/cpu/nios2/preinstall.am b/cpukit/score/cpu/nios2/preinstall.am deleted file mode 100644 index fa07df865d..0000000000 --- a/cpukit/score/cpu/nios2/preinstall.am +++ /dev/null @@ -1,61 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES += $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES += $(PREINSTALL_FILES) - -$(PROJECT_INCLUDE)/rtems/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems - @: > $(PROJECT_INCLUDE)/rtems/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/asm.h: rtems/asm.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/asm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/asm.h - -$(PROJECT_INCLUDE)/rtems/score/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/score - @: > $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/score/cpu.h: rtems/score/cpu.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpu.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpu.h - -$(PROJECT_INCLUDE)/rtems/score/cpuimpl.h: rtems/score/cpuimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h - -$(PROJECT_INCLUDE)/rtems/score/nios2.h: rtems/score/nios2.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/nios2.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/nios2.h - -$(PROJECT_INCLUDE)/rtems/score/nios2-utility.h: rtems/score/nios2-utility.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/nios2-utility.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/nios2-utility.h - -$(PROJECT_INCLUDE)/rtems/score/nios2-count-zeros.h: rtems/score/nios2-count-zeros.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/nios2-count-zeros.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/nios2-count-zeros.h - -$(PROJECT_INCLUDE)/rtems/score/cpu_asm.h: rtems/score/cpu_asm.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpu_asm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpu_asm.h - -$(PROJECT_INCLUDE)/rtems/score/types.h: rtems/score/types.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/types.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/types.h - -$(PROJECT_INCLUDE)/rtems/score/cpuatomic.h: rtems/score/cpuatomic.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h - diff --git a/cpukit/score/cpu/nios2/rtems/asm.h b/cpukit/score/cpu/nios2/rtems/asm.h deleted file mode 100644 index 45ccd8b050..0000000000 --- a/cpukit/score/cpu/nios2/rtems/asm.h +++ /dev/null @@ -1,98 +0,0 @@ -/** - * @file - * - * @brief Address the Problems Caused by Incompatible Flavor of - * Assemblers and Toolsets - * - * This include file attempts to address the problems - * caused by incompatible flavors of assemblers and - * toolsets. It primarily addresses variations in the - * use of leading underscores on symbols and the requirement - * that register names be preceded by a %. - * - * @note The spacing in the use of these macros - * is critical to them working as advertised. - */ - -/* - * COPYRIGHT: - * - * This file is based on similar code found in newlib available - * from ftp.cygnus.com. The file which was used had no copyright - * notice. This file is freely distributable as long as the source - * of the file is noted. This file is: - * - * COPYRIGHT (c) 1994-1997. - * On-Line Applications Research Corporation (OAR). - */ - -#ifndef _RTEMS_ASM_H -#define _RTEMS_ASM_H - -/* - * Indicate we are in an assembly file and get the basic CPU definitions. - */ - -#ifndef ASM -#define ASM -#endif -#include -#include - -/* - * Recent versions of GNU cpp define variables which indicate the - * need for underscores and percents. If not using GNU cpp or - * the version does not support this, then you will obviously - * have to define these as appropriate. - */ - -#ifndef __USER_LABEL_PREFIX__ -#define __USER_LABEL_PREFIX__ _ -#endif - -#ifndef __REGISTER_PREFIX__ -#define __REGISTER_PREFIX__ -#endif - -#include - -/* Use the right prefix for global labels. */ - -#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) - -/* Use the right prefix for registers. */ - -#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) - -/* - * define macros for all of the registers on this CPU - * - * EXAMPLE: #define d0 REG (d0) - */ - -/* - * Define macros to handle section beginning and ends. - */ - - -#define BEGIN_CODE_DCL .text -#define END_CODE_DCL -#define BEGIN_DATA_DCL .data -#define END_DATA_DCL -#define BEGIN_CODE .text -#define END_CODE -#define BEGIN_DATA -#define END_DATA -#define BEGIN_BSS -#define END_BSS -#define END - -/* - * Following must be tailor for a particular flavor of the C compiler. - * They may need to put underscores in front of the symbols. - */ - -#define PUBLIC(sym) .globl SYM (sym) -#define EXTERN(sym) .globl SYM (sym) - -#endif diff --git a/cpukit/score/cpu/nios2/rtems/score/cpu.h b/cpukit/score/cpu/nios2/rtems/score/cpu.h deleted file mode 100644 index a3f2f03d36..0000000000 --- a/cpukit/score/cpu/nios2/rtems/score/cpu.h +++ /dev/null @@ -1,372 +0,0 @@ -/** - * @file - * - * @brief Altera Nios II CPU Department Source - */ - -/* - * Copyright (c) 2011 embedded brains GmbH - * - * Copyright (c) 2006 Kolja Waschk (rtemsdev/ixo.de) - * - * COPYRIGHT (c) 1989-2004. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPU_H -#define _RTEMS_SCORE_CPU_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -#define CPU_HAS_SOFTWARE_INTERRUPT_STACK TRUE - -#define CPU_SIMPLE_VECTORED_INTERRUPTS TRUE - -#define CPU_INTERRUPT_NUMBER_OF_VECTORS 32 - -#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER (CPU_INTERRUPT_NUMBER_OF_VECTORS - 1) - -#define CPU_PROVIDES_ISR_IS_IN_PROGRESS TRUE - -#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE - -#define CPU_ALLOCATE_INTERRUPT_STACK TRUE - -#define CPU_ISR_PASSES_FRAME_POINTER FALSE - -#define CPU_HARDWARE_FP FALSE - -#define CPU_SOFTWARE_FP FALSE - -#define CPU_CONTEXT_FP_SIZE 0 - -#define CPU_ALL_TASKS_ARE_FP FALSE - -#define CPU_IDLE_TASK_IS_FP FALSE - -#define CPU_USE_DEFERRED_FP_SWITCH FALSE - -#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE - -#define CPU_PROVIDES_IDLE_THREAD_BODY FALSE - -#define CPU_STACK_GROWS_UP FALSE - -/* FIXME: Is this the right value? */ -#define CPU_CACHE_LINE_BYTES 32 - -#define CPU_STRUCTURE_ALIGNMENT \ - RTEMS_SECTION( ".sdata" ) RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES ) - -#define CPU_STACK_MINIMUM_SIZE (4 * 1024) - -#define CPU_SIZEOF_POINTER 4 - -/* - * Alignment value according to "Nios II Processor Reference" chapter 7 - * "Application Binary Interface" section "Memory Alignment". - */ -#define CPU_ALIGNMENT 4 - -#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT - -#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT - -/* - * Alignment value according to "Nios II Processor Reference" chapter 7 - * "Application Binary Interface" section "Stacks". - */ -#define CPU_STACK_ALIGNMENT 4 - -/* - * A Nios II configuration with an external interrupt controller (EIC) supports - * up to 64 interrupt levels. A Nios II configuration with an internal - * interrupt controller (IIC) has only two interrupt levels (enabled and - * disabled). The _CPU_ISR_Get_level() and _CPU_ISR_Set_level() functions will - * take care about configuration specific mappings. - */ -#define CPU_MODES_INTERRUPT_MASK 0x3f - -#define CPU_USE_GENERIC_BITFIELD_CODE TRUE - -#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0 - -#define CPU_MAXIMUM_PROCESSORS 32 - -#ifndef ASM - -/** - * @brief Thread register context. - * - * The thread register context covers the non-volatile registers, the thread - * stack pointer, the return address, and the processor status. - * - * There is no need to save the global pointer (gp) since it is a system wide - * constant and set-up with the C runtime environment. - * - * The @a thread_dispatch_disabled field is used for the external interrupt - * controller (EIC) support. - * - * @see _Nios2_Thread_dispatch_disabled - */ -typedef struct { - uint32_t r16; - uint32_t r17; - uint32_t r18; - uint32_t r19; - uint32_t r20; - uint32_t r21; - uint32_t r22; - uint32_t r23; - uint32_t fp; - uint32_t status; - uint32_t sp; - uint32_t ra; - uint32_t thread_dispatch_disabled; - uint32_t stack_mpubase; - uint32_t stack_mpuacc; -} Context_Control; - -#define _CPU_Context_Get_SP( _context ) \ - (_context)->sp - -typedef void CPU_Interrupt_frame; - -typedef struct { - uint32_t r1; - uint32_t r2; - uint32_t r3; - uint32_t r4; - uint32_t r5; - uint32_t r6; - uint32_t r7; - uint32_t r8; - uint32_t r9; - uint32_t r10; - uint32_t r11; - uint32_t r12; - uint32_t r13; - uint32_t r14; - uint32_t r15; - uint32_t r16; - uint32_t r17; - uint32_t r18; - uint32_t r19; - uint32_t r20; - uint32_t r21; - uint32_t r22; - uint32_t r23; - uint32_t gp; - uint32_t fp; - uint32_t sp; - uint32_t ra; - uint32_t et; - uint32_t ea; - uint32_t status; - uint32_t ienable; - uint32_t ipending; -} CPU_Exception_frame; - -#define _CPU_Initialize_vectors() - -/** - * @brief Macro to disable interrupts. - * - * The processor status before disabling the interrupts will be stored in - * @a _isr_cookie. This value will be used in _CPU_ISR_Flash() and - * _CPU_ISR_Enable(). - * - * The global symbol _Nios2_ISR_Status_mask will be used to clear the bits in - * the status register representing the interrupt level. The global symbol - * _Nios2_ISR_Status_bits will be used to set the bits representing an - * interrupt level that disables interrupts. Both global symbols must be - * provided by the board support package. - * - * In case the Nios II uses the internal interrupt controller (IIC), then only - * the PIE status bit is used. - * - * In case the Nios II uses the external interrupt controller (EIC), then the - * RSIE status bit or the IL status field is used depending on the interrupt - * handling variant and the shadow register usage. - */ -#define _CPU_ISR_Disable( _isr_cookie ) \ - do { \ - int _tmp; \ - __asm__ volatile ( \ - "rdctl %0, status\n" \ - "movhi %1, %%hiadj(_Nios2_ISR_Status_mask)\n" \ - "addi %1, %1, %%lo(_Nios2_ISR_Status_mask)\n" \ - "and %1, %0, %1\n" \ - "ori %1, %1, %%lo(_Nios2_ISR_Status_bits)\n" \ - "wrctl status, %1" \ - : "=&r" (_isr_cookie), "=&r" (_tmp) \ - ); \ - } while ( 0 ) - -/** - * @brief Macro to restore the processor status. - * - * The @a _isr_cookie must contain the processor status returned by - * _CPU_ISR_Disable(). The value is not modified. - */ -#define _CPU_ISR_Enable( _isr_cookie ) \ - __builtin_wrctl( 0, (int) _isr_cookie ) - -/** - * @brief Macro to restore the processor status and disable the interrupts - * again. - * - * The @a _isr_cookie must contain the processor status returned by - * _CPU_ISR_Disable(). The value is not modified. - * - * This flash code is optimal for all Nios II configurations. The rdctl does - * not flush the pipeline and has only a late result penalty. The wrctl on - * the other hand leads to a pipeline flush. - */ -#define _CPU_ISR_Flash( _isr_cookie ) \ - do { \ - int _status = __builtin_rdctl( 0 ); \ - __builtin_wrctl( 0, (int) _isr_cookie ); \ - __builtin_wrctl( 0, _status ); \ - } while ( 0 ) - -bool _CPU_ISR_Is_enabled( uint32_t level ); - -/** - * @brief Sets the interrupt level for the executing thread. - * - * The valid values of @a new_level depend on the Nios II configuration. A - * value of zero represents enabled interrupts in all configurations. - * - * @see _CPU_ISR_Get_level() - */ -void _CPU_ISR_Set_level( uint32_t new_level ); - -/** - * @brief Returns the interrupt level of the executing thread. - * - * @retval 0 Interrupts are enabled. - * @retval otherwise The value depends on the Nios II configuration. In case - * of an internal interrupt controller (IIC) the only valid value is one which - * indicates disabled interrupts. In case of an external interrupt controller - * (EIC) there are two possibilities. Firstly if the RSIE status bit is used - * to disable interrupts, then one is the only valid value indicating disabled - * interrupts. Secondly if the IL status field is used to disable interrupts, - * then this value will be returned. Interrupts are disabled at the maximum - * level specified by the _Nios2_ISR_Status_bits. - */ -uint32_t _CPU_ISR_Get_level( void ); - -/** - * @brief Initializes the CPU context. - * - * The following steps are performed: - * - setting a starting address - * - preparing the stack - * - preparing the stack and frame pointers - * - setting the proper interrupt level in the context - * - * @param[in] context points to the context area - * @param[in] stack_area_begin is the low address of the allocated stack area - * @param[in] stack_area_size is the size of the stack area in bytes - * @param[in] new_level is the interrupt level for the task - * @param[in] entry_point is the task's entry point - * @param[in] is_fp is set to @c true if the task is a floating point task - * @param[in] tls_area is the thread-local storage (TLS) area - */ -void _CPU_Context_Initialize( - Context_Control *context, - void *stack_area_begin, - size_t stack_area_size, - uint32_t new_level, - void (*entry_point)( void ), - bool is_fp, - void *tls_area -); - -#define _CPU_Context_Restart_self( _the_context ) \ - _CPU_Context_restore( (_the_context) ); - -void _CPU_Fatal_halt( uint32_t _source, uint32_t _error ) - RTEMS_NO_RETURN; - -/** - * @brief CPU initialization. - */ -void _CPU_Initialize( void ); - -/** - * @brief CPU ISR install raw handler. - */ -void _CPU_ISR_install_raw_handler( - uint32_t vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -/** - * @brief CPU ISR install vector. - */ -void _CPU_ISR_install_vector( - uint32_t vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -void _CPU_Context_switch( Context_Control *run, Context_Control *heir ); - -void _CPU_Context_restore( - Context_Control *new_context -) RTEMS_NO_RETURN; - -void _CPU_Context_volatile_clobber( uintptr_t pattern ); - -void _CPU_Context_validate( uintptr_t pattern ); - -void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); - -static inline uint32_t CPU_swap_u32( uint32_t value ) -{ - uint32_t byte1, byte2, byte3, byte4, swapped; - - byte4 = (value >> 24) & 0xff; - byte3 = (value >> 16) & 0xff; - byte2 = (value >> 8) & 0xff; - byte1 = value & 0xff; - - swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4; - - return swapped; -} - -#define CPU_swap_u16( value ) \ - (((value&0xff) << 8) | ((value >> 8)&0xff)) - -typedef uint32_t CPU_Counter_ticks; - -CPU_Counter_ticks _CPU_Counter_read( void ); - -static inline CPU_Counter_ticks _CPU_Counter_difference( - CPU_Counter_ticks second, - CPU_Counter_ticks first -) -{ - return second - first; -} - -#endif /* ASM */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/score/cpu/nios2/rtems/score/cpu_asm.h b/cpukit/score/cpu/nios2/rtems/score/cpu_asm.h deleted file mode 100644 index 81a19c8d69..0000000000 --- a/cpukit/score/cpu/nios2/rtems/score/cpu_asm.h +++ /dev/null @@ -1,74 +0,0 @@ -/** - * @file - * - * @brief Altera Nios II Assembly File - * - * Very loose template for an include file for the cpu_asm.? file - * if it is implemented as a ".S" file (preprocessed by cpp) instead - * of a ".s" file (preprocessed by gm4 or gasp). - */ - -/* - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - * - */ - -#ifndef _RTEMS_SCORE_CPU_ASM_H -#define _RTEMS_SCORE_CPU_ASM_H - -/* pull in the generated offsets */ - -/* -#include -*/ - -/* - * Hardware General Registers - */ - -/* put something here */ - -/* - * Hardware Floating Point Registers - */ - -/* put something here */ - -/* - * Hardware Control Registers - */ - -/* put something here */ - -/* - * Calling Convention - */ - -/* put something here */ - -/* - * Temporary registers - */ - -/* put something here */ - -/* - * Floating Point Registers - SW Conventions - */ - -/* put something here */ - -/* - * Temporary floating point registers - */ - -/* put something here */ - -#endif - -/* end of file */ diff --git a/cpukit/score/cpu/nios2/rtems/score/cpuatomic.h b/cpukit/score/cpu/nios2/rtems/score/cpuatomic.h deleted file mode 100644 index 598ee76b20..0000000000 --- a/cpukit/score/cpu/nios2/rtems/score/cpuatomic.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * COPYRIGHT (c) 2012-2013 Deng Hengyi. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_ATOMIC_CPU_H -#define _RTEMS_SCORE_ATOMIC_CPU_H - -#include - -#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/nios2/rtems/score/cpuimpl.h b/cpukit/score/cpu/nios2/rtems/score/cpuimpl.h deleted file mode 100644 index 789f2badd9..0000000000 --- a/cpukit/score/cpu/nios2/rtems/score/cpuimpl.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @file - * - * @brief CPU Port Implementation API - */ - -/* - * Copyright (c) 2013 embedded brains GmbH - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPUIMPL_H -#define _RTEMS_SCORE_CPUIMPL_H - -#include - -#define CPU_PER_CPU_CONTROL_SIZE 0 - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* ASM */ - -#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/nios2/rtems/score/nios2-count-zeros.h b/cpukit/score/cpu/nios2/rtems/score/nios2-count-zeros.h deleted file mode 100644 index bf2390a51f..0000000000 --- a/cpukit/score/cpu/nios2/rtems/score/nios2-count-zeros.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Author: Jeffrey O. Hill - * - * Copyright 2012. Los Alamos National Security, LLC. - * This material was produced under U.S. Government contract - * DE-AC52-06NA25396 for Los Alamos National Laboratory (LANL), - * which is operated by Los Alamos National Security, LLC for - * the U.S. Department of Energy. The U.S. Government has rights - * to use, reproduce, and distribute this software. NEITHER THE - * GOVERNMENT NOR LOS ALAMOS NATIONAL SECURITY, LLC MAKES ANY - * WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LIABILITY FOR - * THE USE OF THIS SOFTWARE. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _NIOS2_COUNT_ZEROS_H -#define _NIOS2_COUNT_ZEROS_H - -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * This implementation is currently much more efficient than - * the GCC provided __builtin_clz - */ -static inline unsigned _Nios2_Count_leading_zeros( uint32_t p ) -{ - unsigned bitIdx; - - if ( p <= 0xffffu ) { - if ( p < 0x100u ) { - bitIdx = _Bitfield_Leading_zeros[ p ] + 24u; - } else { - bitIdx = _Bitfield_Leading_zeros[ p >> 8u ] + 16u; - } - } else { - p >>= 16u; - - if ( p < 0x100u ) { - bitIdx = _Bitfield_Leading_zeros[ p ] + 8u; - } else { - bitIdx = _Bitfield_Leading_zeros[ p >> 8u ]; - } - } - - return bitIdx; -} - -/* - * This implementation is currently much more efficient than - * the GCC provided __builtin_ctz - */ -static inline unsigned _Nios2_Count_trailing_zeros( uint32_t p ) -{ - return 31u - _Nios2_Count_leading_zeros( p & ( -p ) ); -} - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _NIOS2_COUNT_ZEROS_H */ diff --git a/cpukit/score/cpu/nios2/rtems/score/nios2-utility.h b/cpukit/score/cpu/nios2/rtems/score/nios2-utility.h deleted file mode 100644 index d5eb4b3597..0000000000 --- a/cpukit/score/cpu/nios2/rtems/score/nios2-utility.h +++ /dev/null @@ -1,516 +0,0 @@ -/** - * @file - * - * @brief NIOS II Utility - */ -/* - * Copyright (c) 2011 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Obere Lagerstr. 30 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_NIOS2_UTILITY_H -#define _RTEMS_SCORE_NIOS2_UTILITY_H - -#define NIOS2_CTLREG_INDEX_STATUS 0 -#define NIOS2_CTLREG_INDEX_ESTATUS 1 -#define NIOS2_CTLREG_INDEX_BSTATUS 2 -#define NIOS2_CTLREG_INDEX_IENABLE 3 -#define NIOS2_CTLREG_INDEX_IPENDING 4 -#define NIOS2_CTLREG_INDEX_CPUID 5 -#define NIOS2_CTLREG_INDEX_EXCEPTION 7 -#define NIOS2_CTLREG_INDEX_PTEADDR 8 -#define NIOS2_CTLREG_INDEX_TLBACC 9 -#define NIOS2_CTLREG_INDEX_TLBMISC 10 -#define NIOS2_CTLREG_INDEX_BADADDR 12 -#define NIOS2_CTLREG_INDEX_CONFIG 13 -#define NIOS2_CTLREG_INDEX_MPUBASE 14 -#define NIOS2_CTLREG_INDEX_MPUACC 15 - -#define NIOS2_CONTEXT_OFFSET_R16 0 -#define NIOS2_CONTEXT_OFFSET_R17 4 -#define NIOS2_CONTEXT_OFFSET_R18 8 -#define NIOS2_CONTEXT_OFFSET_R19 12 -#define NIOS2_CONTEXT_OFFSET_R20 16 -#define NIOS2_CONTEXT_OFFSET_R21 20 -#define NIOS2_CONTEXT_OFFSET_R22 24 -#define NIOS2_CONTEXT_OFFSET_R23 28 -#define NIOS2_CONTEXT_OFFSET_FP 32 -#define NIOS2_CONTEXT_OFFSET_STATUS 36 -#define NIOS2_CONTEXT_OFFSET_SP 40 -#define NIOS2_CONTEXT_OFFSET_RA 44 -#define NIOS2_CONTEXT_OFFSET_THREAD_DISPATCH_DISABLED 48 -#define NIOS2_CONTEXT_OFFSET_STACK_MPUBASE 52 -#define NIOS2_CONTEXT_OFFSET_STACK_MPUACC 56 - -#define NIOS2_ISR_STATUS_MASK_IIC 0xfffffffe -#define NIOS2_ISR_STATUS_BITS_IIC 0x00000000 - -#define NIOS2_ISR_STATUS_MASK_EIC_IL 0xfffffc0f -#define NIOS2_ISR_STATUS_BITS_EIC_IL 0x000003f0 - -#define NIOS2_ISR_STATUS_MASK_EIC_RSIE 0xf7ffffff -#define NIOS2_ISR_STATUS_BITS_EIC_RSIE 0x00000000 - -#define NIOS2_STATUS_RSIE (1 << 23) -#define NIOS2_STATUS_NMI (1 << 22) -#define NIOS2_STATUS_PRS_OFFSET 16 -#define NIOS2_STATUS_PRS_MASK (0x3f << NIOS2_STATUS_PRS_OFFSET) -#define NIOS2_STATUS_CRS_OFFSET 10 -#define NIOS2_STATUS_CRS_MASK (0x3f << NIOS2_STATUS_CRS_OFFSET) -#define NIOS2_STATUS_IL_OFFSET 4 -#define NIOS2_STATUS_IL_MASK (0x3f << NIOS2_STATUS_IL_OFFSET) -#define NIOS2_STATUS_IH (1 << 3) -#define NIOS2_STATUS_EH (1 << 2) -#define NIOS2_STATUS_U (1 << 1) -#define NIOS2_STATUS_PIE (1 << 0) - -#define NIOS2_EXCEPTION_CAUSE_OFFSET 2 -#define NIOS2_EXCEPTION_CAUSE_MASK (0x1f << NIOS2_EXCEPTION_CAUSE_OFFSET) - -#define NIOS2_PTEADDR_PTBASE_OFFSET 22 -#define NIOS2_PTEADDR_PTBASE_MASK (0x3ff << NIOS2_PTEADDR_PTBASE_OFFSET) -#define NIOS2_PTEADDR_VPN_OFFSET 2 -#define NIOS2_PTEADDR_VPN_MASK (0xfffff << NIOS2_PTEADDR_VPN_OFFSET) - -#define NIOS2_TLBACC_IG_OFFSET 25 -#define NIOS2_TLBACC_IG_MASK (0x3ff << NIOS2_TLBACC_IG_OFFSET) -#define NIOS2_TLBACC_C (1 << 24) -#define NIOS2_TLBACC_R (1 << 23) -#define NIOS2_TLBACC_W (1 << 22) -#define NIOS2_TLBACC_X (1 << 21) -#define NIOS2_TLBACC_G (1 << 20) -#define NIOS2_TLBACC_PFN_OFFSET 2 -#define NIOS2_TLBACC_PFN_MASK (0xfffff << NIOS2_TLBACC_PFN_OFFSET) - -#define NIOS2_TLBMISC_WAY_OFFSET 20 -#define NIOS2_TLBMISC_WAY_MASK (0xf << NIOS2_TLBMISC_WAY_OFFSET) -#define NIOS2_TLBMISC_RD (1 << 19) -#define NIOS2_TLBMISC_WE (1 << 18) -#define NIOS2_TLBMISC_PID_OFFSET 5 -#define NIOS2_TLBMISC_PID_MASK (0x3fff << NIOS2_TLBMISC_PID_OFFSET) -#define NIOS2_TLBMISC_DBL (1 << 3) -#define NIOS2_TLBMISC_BAD (1 << 2) -#define NIOS2_TLBMISC_PERM (1 << 1) -#define NIOS2_TLBMISC_D (1 << 0) - -#define NIOS2_CONFIG_ANI (1 << 1) -#define NIOS2_CONFIG_PE (1 << 0) - -#define NIOS2_MPUBASE_BASE_OFFSET 6 -#define NIOS2_MPUBASE_BASE_MASK (0x1ffffff << NIOS2_MPUBASE_BASE_OFFSET) -#define NIOS2_MPUBASE_INDEX_OFFSET 1 - -/* Avoid redefines with Altera HAL */ -#define NIOS2_MPUBASE_INDEX_MASK (0x0000003e) - -#define NIOS2_MPUBASE_D (1 << 0) - -#define NIOS2_MPUACC_MASK_OFFSET 6 - -/* Avoid redefines with Altera HAL */ -#define NIOS2_MPUACC_MASK_MASK (0x7fffffc0) - -#define NIOS2_MPUACC_LIMIT_OFFSET 6 - -/* Avoid redefines with Altera HAL */ -#define NIOS2_MPUACC_LIMIT_MASK (0xffffffc0) - -#define NIOS2_MPUACC_C (1 << 5) -#define NIOS2_MPUACC_PERM_OFFSET 2 - -/* Avoid redefines with Altera HAL */ -#define NIOS2_MPUACC_PERM_MASK (0x0000001c) - -#define NIOS2_MPUACC_RD (1 << 1) -#define NIOS2_MPUACC_WR (1 << 0) - -#ifndef ASM - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @brief Nios II specific thread dispatch disabled indicator. - * - * This global variable is used by the interrupt dispatch support for the - * external interrupt controller (EIC) with shadow registers. This makes it - * possible to do the thread dispatch after an interrupt without disabled - * interrupts and thus probably reduce the maximum interrupt latency. Its - * purpose is to prevent unbounded stack usage of the interrupted thread. - */ -extern uint32_t _Nios2_Thread_dispatch_disabled; - -/** - * @brief This global symbol specifies the status register mask used to disable - * interrupts. - * - * The board support package must provide a global symbol with this name to - * specify the status register mask used in _CPU_ISR_Disable(). - */ -extern char _Nios2_ISR_Status_mask []; - -/** - * @brief This symbol specifies the status register bits used to disable - * interrupts. - * - * The board support package must provide a global symbol with this name to - * specify the status register bits used in _CPU_ISR_Disable(). - */ -extern char _Nios2_ISR_Status_bits []; - -static inline void _Nios2_Flush_pipeline( void ) -{ - __asm__ volatile ("flushp"); -} - -static inline uint32_t _Nios2_Get_ctlreg_status( void ) -{ - return (uint32_t) __builtin_rdctl( NIOS2_CTLREG_INDEX_STATUS ); -} - -static inline void _Nios2_Set_ctlreg_status( uint32_t value ) -{ - __builtin_wrctl( NIOS2_CTLREG_INDEX_STATUS, (int) value ); -} - -static inline uint32_t _Nios2_Get_ctlreg_estatus( void ) -{ - return (uint32_t) __builtin_rdctl( NIOS2_CTLREG_INDEX_ESTATUS ); -} - -static inline void _Nios2_Set_ctlreg_estatus( uint32_t value ) -{ - __builtin_wrctl( NIOS2_CTLREG_INDEX_ESTATUS, (int) value ); -} - -static inline uint32_t _Nios2_Get_ctlreg_bstatus( void ) -{ - return (uint32_t) __builtin_rdctl( NIOS2_CTLREG_INDEX_BSTATUS ); -} - -static inline void _Nios2_Set_ctlreg_bstatus( uint32_t value ) -{ - __builtin_wrctl( NIOS2_CTLREG_INDEX_BSTATUS, (int) value ); -} - -static inline uint32_t _Nios2_Get_ctlreg_ienable( void ) -{ - return (uint32_t) __builtin_rdctl( NIOS2_CTLREG_INDEX_IENABLE ); -} - -static inline void _Nios2_Set_ctlreg_ienable( uint32_t value ) -{ - __builtin_wrctl( NIOS2_CTLREG_INDEX_IENABLE, (int) value ); -} - -static inline uint32_t _Nios2_Get_ctlreg_ipending( void ) -{ - return (uint32_t) __builtin_rdctl( NIOS2_CTLREG_INDEX_IPENDING ); -} - -static inline uint32_t _Nios2_Get_ctlreg_cpuid( void ) -{ - return (uint32_t) __builtin_rdctl( NIOS2_CTLREG_INDEX_CPUID ); -} - -static inline uint32_t _Nios2_Get_ctlreg_exception( void ) -{ - return (uint32_t) __builtin_rdctl( NIOS2_CTLREG_INDEX_EXCEPTION ); -} - -static inline uint32_t _Nios2_Get_ctlreg_pteaddr( void ) -{ - return (uint32_t) __builtin_rdctl( NIOS2_CTLREG_INDEX_PTEADDR ); -} - -static inline void _Nios2_Set_ctlreg_pteaddr( uint32_t value ) -{ - __builtin_wrctl( NIOS2_CTLREG_INDEX_PTEADDR, (int) value ); -} - -static inline uint32_t _Nios2_Get_ctlreg_tlbacc( void ) -{ - return (uint32_t) __builtin_rdctl( NIOS2_CTLREG_INDEX_TLBACC ); -} - -static inline void _Nios2_Set_ctlreg_tlbacc( uint32_t value ) -{ - __builtin_wrctl( NIOS2_CTLREG_INDEX_TLBACC, (int) value ); -} - -static inline uint32_t _Nios2_Get_ctlreg_tlbmisc( void ) -{ - return (uint32_t) __builtin_rdctl( NIOS2_CTLREG_INDEX_TLBMISC ); -} - -static inline void _Nios2_Set_ctlreg_tlbmisc( uint32_t value ) -{ - __builtin_wrctl( NIOS2_CTLREG_INDEX_TLBMISC, (int) value ); -} - -static inline uint32_t _Nios2_Get_ctlreg_badaddr( void ) -{ - return (uint32_t) __builtin_rdctl( NIOS2_CTLREG_INDEX_BADADDR ); -} - -static inline uint32_t _Nios2_Get_ctlreg_config( void ) -{ - return (uint32_t) __builtin_rdctl( NIOS2_CTLREG_INDEX_CONFIG ); -} - -static inline void _Nios2_Set_ctlreg_config( uint32_t value ) -{ - __builtin_wrctl( NIOS2_CTLREG_INDEX_CONFIG, (int) value ); -} - -static inline uint32_t _Nios2_Get_ctlreg_mpubase( void ) -{ - return (uint32_t) __builtin_rdctl( NIOS2_CTLREG_INDEX_MPUBASE ); -} - -static inline void _Nios2_Set_ctlreg_mpubase( uint32_t value ) -{ - __builtin_wrctl( NIOS2_CTLREG_INDEX_MPUBASE, (int) value ); -} - -static inline uint32_t _Nios2_Get_ctlreg_mpuacc( void ) -{ - return (uint32_t) __builtin_rdctl( NIOS2_CTLREG_INDEX_MPUACC ); -} - -static inline void _Nios2_Set_ctlreg_mpuacc( uint32_t value ) -{ - __builtin_wrctl( NIOS2_CTLREG_INDEX_MPUACC, (int) value ); -} - -static inline uint32_t _Nios2_ISR_Get_status_mask( void ) -{ - return (uint32_t) &_Nios2_ISR_Status_mask [0]; -} - -static inline uint32_t _Nios2_ISR_Get_status_bits( void ) -{ - return (uint32_t) &_Nios2_ISR_Status_bits [0]; -} - -static inline bool _Nios2_Has_internal_interrupt_controller( void ) -{ - return _Nios2_ISR_Get_status_mask() == NIOS2_ISR_STATUS_MASK_IIC; -} - -uint32_t _Nios2_ISR_Set_level( uint32_t new_level, uint32_t status ); - -typedef struct { - int data_address_width; - int instruction_address_width; - int data_region_size_log2; - int instruction_region_size_log2; - int data_region_count; - int instruction_region_count; - int data_index_for_stack_protection; - bool region_uses_limit; - bool enable_data_cache_for_stack; -} Nios2_MPU_Configuration; - -void _Nios2_MPU_Set_configuration( const Nios2_MPU_Configuration *config ); - -const Nios2_MPU_Configuration *_Nios2_MPU_Get_configuration( void ); - -typedef enum { - NIOS2_MPU_INST_PERM_SVR_NONE_USER_NONE = 0, - NIOS2_MPU_INST_PERM_SVR_EXECUTE_USER_NONE, - NIOS2_MPU_INST_PERM_SVR_EXECUTE_USER_EXECUTE, - NIOS2_MPU_DATA_PERM_SVR_NONE_USER_NONE = 0, - NIOS2_MPU_DATA_PERM_SVR_READONLY_USER_NONE, - NIOS2_MPU_DATA_PERM_SVR_READONLY_USER_READONLY, - NIOS2_MPU_DATA_PERM_SVR_READWRITE_USER_NONE = 4, - NIOS2_MPU_DATA_PERM_SVR_READWRITE_USER_READONLY, - NIOS2_MPU_DATA_PERM_SVR_READWRITE_USER_READWRITE -} Nios2_MPU_Region_permissions; - -typedef struct { - int index; - const void *base; - const void *end; - Nios2_MPU_Region_permissions perm; - bool data; - bool cacheable; - bool read; - bool write; -} Nios2_MPU_Region_descriptor; - -#define NIOS2_MPU_REGION_DESC_INST( index, base, end ) \ - { \ - (index), (base), (end), NIOS2_MPU_INST_PERM_SVR_EXECUTE_USER_NONE, \ - false, false, false, true \ - } - -#define NIOS2_MPU_REGION_DESC_DATA_RO( index, base, end ) \ - { \ - (index), (base), (end), NIOS2_MPU_DATA_PERM_SVR_READONLY_USER_NONE, \ - true, true, false, true \ - } - -#define NIOS2_MPU_REGION_DESC_DATA_RW( index, base, end ) \ - { \ - (index), (base), (end), NIOS2_MPU_DATA_PERM_SVR_READWRITE_USER_NONE, \ - true, true, false, true \ - } - -#define NIOS2_MPU_REGION_DESC_DATA_IO( index, base, end ) \ - { \ - (index), (base), (end), NIOS2_MPU_DATA_PERM_SVR_READWRITE_USER_NONE, \ - true, false, false, true \ - } - -static inline int _Nios2_MPU_Get_region_count( - const Nios2_MPU_Configuration *config, - bool data -) -{ - return data ? - config->data_region_count - : config->instruction_region_count; -} - -static inline bool _Nios2_MPU_Is_valid_index( - const Nios2_MPU_Configuration *config, - int index, - bool data -) -{ - return 0 <= index - && index < _Nios2_MPU_Get_region_count( config, data ); -} - -bool _Nios2_MPU_Setup_region_registers( - const Nios2_MPU_Configuration *config, - const Nios2_MPU_Region_descriptor *desc, - uint32_t *mpubase, - uint32_t *mpuacc -); - -bool _Nios2_MPU_Get_region_descriptor( - const Nios2_MPU_Configuration *config, - int index, - bool data, - Nios2_MPU_Region_descriptor *desc -); - -/** - * @brief Searches the region table part for a disabled region. - * - * The table will be searched between indices @a begin and @a end. The @a end - * index is not part of the search range. If @a end is negative, then the - * region count will be used. Thus a @a begin of 0 and a @a end of -1 will - * specify the complete table. - * - * @retval -1 No disabled region is available. - * @retval other Index of disabled region. - */ -int _Nios2_MPU_Get_disabled_region_index( - const Nios2_MPU_Configuration *config, - bool data, - int begin, - int end -); - -/** - * @brief Adds a region according to region descriptor @a desc. - * - * If @a force is true, then an enabled region will be overwritten. - * - * @retval true Successful operation. - * @retval false Invalid region descriptor or region already in use. - */ -bool _Nios2_MPU_Add_region( - const Nios2_MPU_Configuration *config, - const Nios2_MPU_Region_descriptor *desc, - bool force -); - -static inline void _Nios2_MPU_Get_region_registers( - int index, - bool data, - uint32_t *mpubase, - uint32_t *mpuacc -) -{ - uint32_t base = (uint32_t) - (((index << NIOS2_MPUBASE_INDEX_OFFSET) & NIOS2_MPUBASE_INDEX_MASK) - | (data ? NIOS2_MPUBASE_D : 0)); - - _Nios2_Set_ctlreg_mpubase( base ); - _Nios2_Set_ctlreg_mpuacc( NIOS2_MPUACC_RD ); - _Nios2_Flush_pipeline(); - *mpubase = _Nios2_Get_ctlreg_mpubase() | base; - *mpuacc = _Nios2_Get_ctlreg_mpuacc(); -} - -static inline void _Nios2_MPU_Set_region_registers( - uint32_t mpubase, - uint32_t mpuacc -) -{ - _Nios2_Set_ctlreg_mpubase( mpubase ); - _Nios2_Set_ctlreg_mpuacc( mpuacc ); - _Nios2_Flush_pipeline(); -} - -static inline void _Nios2_MPU_Enable( void ) -{ - uint32_t config = _Nios2_Get_ctlreg_config(); - - _Nios2_Set_ctlreg_config( config | NIOS2_CONFIG_PE ); -} - -static inline uint32_t _Nios2_MPU_Disable( void ) -{ - uint32_t config = _Nios2_Get_ctlreg_config(); - uint32_t config_pe = NIOS2_CONFIG_PE; - - _Nios2_Set_ctlreg_config( config & ~config_pe ); - - return config; -} - -static inline void _Nios2_MPU_Restore( uint32_t config ) -{ - _Nios2_Set_ctlreg_config( config ); -} - -uint32_t _Nios2_MPU_Disable_protected( void ); - -void _Nios2_MPU_Reset( const Nios2_MPU_Configuration *config ); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#else /* ASM */ - - .macro NIOS2_ASM_DISABLE_INTERRUPTS new_status, current_status - movhi \new_status, %hiadj(_Nios2_ISR_Status_mask) - addi \new_status, \new_status, %lo(_Nios2_ISR_Status_mask) - and \new_status, \current_status, \new_status - ori \new_status, \new_status, %lo(_Nios2_ISR_Status_bits) - wrctl status, \new_status - .endm - -#endif /* ASM */ - -#endif /* _RTEMS_SCORE_NIOS2_UTILITY_H */ diff --git a/cpukit/score/cpu/nios2/rtems/score/nios2.h b/cpukit/score/cpu/nios2/rtems/score/nios2.h deleted file mode 100644 index 26d76bcbfa..0000000000 --- a/cpukit/score/cpu/nios2/rtems/score/nios2.h +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @file - * - * @brief NIOS II Set up Basic CPU Dependency Settings Based on - * Compiler Settings - * - * This file sets up basic CPU dependency settings based on - * compiler settings. For example, it can determine if - * floating point is available. This particular implementation - * is specific to the NIOS2 port. - */ - -/* - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - * - */ - -#ifndef _RTEMS_SCORE_NIOS2_H -#define _RTEMS_SCORE_NIOS2_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This file contains the information required to build - * RTEMS for a particular member of the NIOS2 family. - * It does this by setting variables to indicate which - * implementation dependent features are present in a particular - * member of the family. - * - * This is a good place to list all the known CPU models - * that this port supports and which RTEMS CPU model they correspond - * to. - */ - -/* - * Define the name of the CPU family and specific model. - */ - -#define CPU_NAME "NIOS2" -#define CPU_MODEL_NAME "nios2" - -/* - * See also nios2-rtems-gcc -print-multi-lib for all valid combinations of - * - * -mno-hw-mul - * -mhw-mulx - * -mstack-check - * -pg - * -EB - * -mcustom-fpu-cfg=60-1 - * -mcustom-fpu-cfg=60-2 - */ - -#ifdef __cplusplus -} -#endif - -#endif /* _RTEMS_SCORE_NIOS2_H */ diff --git a/cpukit/score/cpu/nios2/rtems/score/types.h b/cpukit/score/cpu/nios2/rtems/score/types.h deleted file mode 100644 index 23cf39419b..0000000000 --- a/cpukit/score/cpu/nios2/rtems/score/types.h +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @file - * - * @brief Altera Nios II CPU Type Definitions - * - * This include file contains type definitions pertaining to the - * Altera Nios II processor family. - */ - -/* - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_TYPES_H -#define _RTEMS_SCORE_TYPES_H - -#include - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This section defines the basic types for this processor. - */ - -/** Type that can store a 32-bit integer or a pointer. */ -typedef uintptr_t CPU_Uint32ptr; - -typedef void nios2_isr; -typedef void ( *nios2_isr_entry )( void ); - -#ifdef __cplusplus -} -#endif - -#endif /* !ASM */ - -#endif diff --git a/cpukit/score/cpu/no_cpu/Makefile.am b/cpukit/score/cpu/no_cpu/Makefile.am index 3134c01da8..556d3dea34 100644 --- a/cpukit/score/cpu/no_cpu/Makefile.am +++ b/cpukit/score/cpu/no_cpu/Makefile.am @@ -1,19 +1,9 @@ include $(top_srcdir)/automake/compile.am -include_rtemsdir = $(includedir)/rtems -include_rtems_HEADERS = rtems/asm.h - -include_rtems_scoredir = $(includedir)/rtems/score -include_rtems_score_HEADERS = rtems/score/cpu.h -include_rtems_score_HEADERS += rtems/score/cpuimpl.h -include_rtems_score_HEADERS += rtems/score/no_cpu.h -include_rtems_score_HEADERS += rtems/score/cpu_asm.h -include_rtems_score_HEADERS += rtems/score/types.h - noinst_LIBRARIES = libscorecpu.a libscorecpu_a_SOURCES = cpu.c cpu_asm.c libscorecpu_a_SOURCES += cpucounterread.c libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS) -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am +include $(srcdir)/headers.am diff --git a/cpukit/score/cpu/no_cpu/headers.am b/cpukit/score/cpu/no_cpu/headers.am new file mode 100644 index 0000000000..faf934fb1e --- /dev/null +++ b/cpukit/score/cpu/no_cpu/headers.am @@ -0,0 +1,13 @@ +## This file was generated by "./boostrap -H". + +include_rtemsdir = $(includedir)/rtems +include_rtems_HEADERS = +include_rtems_HEADERS += include/rtems/asm.h + +include_rtems_scoredir = $(includedir)/rtems/score +include_rtems_score_HEADERS = +include_rtems_score_HEADERS += include/rtems/score/cpu.h +include_rtems_score_HEADERS += include/rtems/score/cpu_asm.h +include_rtems_score_HEADERS += include/rtems/score/cpuimpl.h +include_rtems_score_HEADERS += include/rtems/score/no_cpu.h +include_rtems_score_HEADERS += include/rtems/score/types.h diff --git a/cpukit/score/cpu/no_cpu/include/rtems/asm.h b/cpukit/score/cpu/no_cpu/include/rtems/asm.h new file mode 100644 index 0000000000..926e3964e5 --- /dev/null +++ b/cpukit/score/cpu/no_cpu/include/rtems/asm.h @@ -0,0 +1,133 @@ +/** + * @file rtems/asm.h + * + * @brief Addresses Incompatible Flavors Problems + * + * This include file attempts to address the problems + * caused by incompatible flavors of assemblers and + * toolsets. It primarily addresses variations in the + * use of leading underscores on symbols and the requirement + * that register names be preceded by a %. + * + * NOTE: The spacing in the use of these macros + * is critical to them working as advertised. + */ + +/* + * COPYRIGHT: + * + * This file is based on similar code found in newlib available + * from ftp.cygnus.com. The file which was used had no copyright + * notice. This file is freely distributable as long as the source + * of the file is noted. This file is: + * + * COPYRIGHT (c) 1994-2006. + * On-Line Applications Research Corporation (OAR). + */ + +#ifndef _RTEMS_ASM_H +#define _RTEMS_ASM_H + +/** + * @defgroup no_cpuAsm Address Incompatible Flavors Problems + * + * @ingroup no_cpu + */ +/**@{*/ + +/* + * Indicate we are in an assembly file and get the basic CPU definitions. + */ + +#ifndef ASM +#define ASM +#endif +#include +#include + +#ifndef __USER_LABEL_PREFIX__ +/** + * Recent versions of GNU cpp define variables which indicate the + * need for underscores and percents. If not using GNU cpp or + * the version does not support this, then you will obviously + * have to define these as appropriate. + * + * This symbol is prefixed to all C program symbols. + */ +#define __USER_LABEL_PREFIX__ _ +#endif + +#ifndef __REGISTER_PREFIX__ +/** + * Recent versions of GNU cpp define variables which indicate the + * need for underscores and percents. If not using GNU cpp or + * the version does not support this, then you will obviously + * have to define these as appropriate. + * + * This symbol is prefixed to all register names. + */ +#define __REGISTER_PREFIX__ +#endif + +#include + +/** Use the right prefix for global labels. */ +#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) + +/** Use the right prefix for registers. */ +#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) + +/* + * define macros for all of the registers on this CPU + * + * EXAMPLE: #define d0 REG (d0) + */ + +/* + * Define macros to handle section beginning and ends. + */ + + +/** This macro is used to denote the beginning of a code declaration. */ +#define BEGIN_CODE_DCL .text +/** This macro is used to denote the end of a code declaration. */ +#define END_CODE_DCL +/** This macro is used to denote the beginning of a data declaration section. */ +#define BEGIN_DATA_DCL .data +/** This macro is used to denote the end of a data declaration section. */ +#define END_DATA_DCL +/** This macro is used to denote the beginning of a code section. */ +#define BEGIN_CODE .text +/** This macro is used to denote the end of a code section. */ +#define END_CODE +/** This macro is used to denote the beginning of a data section. */ +#define BEGIN_DATA +/** This macro is used to denote the end of a data section. */ +#define END_DATA +/** This macro is used to denote the beginning of the + * unitialized data section. + */ +#define BEGIN_BSS +/** This macro is used to denote the end of the unitialized data section. */ +#define END_BSS +/** This macro is used to denote the end of the assembly file. */ +#define END + +/** + * This macro is used to declare a public global symbol. + * + * @note This must be tailored for a particular flavor of the C compiler. + * They may need to put underscores in front of the symbols. + */ +#define PUBLIC(sym) .globl SYM (sym) + +/** + * This macro is used to prototype a public global symbol. + * + * @note This must be tailored for a particular flavor of the C compiler. + * They may need to put underscores in front of the symbols. + */ +#define EXTERN(sym) .globl SYM (sym) + +/**@}*/ +#endif diff --git a/cpukit/score/cpu/no_cpu/include/rtems/score/cpu.h b/cpukit/score/cpu/no_cpu/include/rtems/score/cpu.h new file mode 100644 index 0000000000..c16adc7327 --- /dev/null +++ b/cpukit/score/cpu/no_cpu/include/rtems/score/cpu.h @@ -0,0 +1,1501 @@ +/** + * @file rtems/score/cpu.h + * + * @brief NO_CPU Department Source + * + * This include file contains information pertaining to the NO_CPU + * processor. + */ + +/* + * This include file contains information pertaining to the XXX + * processor. + * + * @note This file is part of a porting template that is intended + * to be used as the starting point when porting RTEMS to a new + * CPU family. The following needs to be done when using this as + * the starting point for a new port: + * + * + Anywhere there is an XXX, it should be replaced + * with information about the CPU family being ported to. + * + * + At the end of each comment section, there is a heading which + * says "Port Specific Information:". When porting to RTEMS, + * add CPU family specific information in this section + */ + +/* + * COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPU_H +#define _RTEMS_SCORE_CPU_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* conditional compilation parameters */ + +/** + * Does RTEMS manage a dedicated interrupt stack in software? + * + * If TRUE, then a stack is allocated in @ref _ISR_Handler_initialization. + * If FALSE, nothing is done. + * + * If the CPU supports a dedicated interrupt stack in hardware, + * then it is generally the responsibility of the BSP to allocate it + * and set it up. + * + * If the CPU does not support a dedicated interrupt stack, then + * the porter has two options: (1) execute interrupts on the + * stack of the interrupted task, and (2) have RTEMS manage a dedicated + * interrupt stack. + * + * If this is TRUE, @ref CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. + * + * Only one of @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK and + * @ref CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is + * possible that both are FALSE for a particular CPU. Although it + * is unclear what that would imply about the interrupt processing + * procedure on that CPU. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_HAS_SOFTWARE_INTERRUPT_STACK FALSE + +/** + * Does the CPU follow the simple vectored interrupt model? + * + * If TRUE, then RTEMS allocates the vector table it internally manages. + * If FALSE, then the BSP is assumed to allocate and manage the vector + * table + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_SIMPLE_VECTORED_INTERRUPTS TRUE + +/** + * Does this CPU have hardware support for a dedicated interrupt stack? + * + * If TRUE, then it must be installed during initialization. + * If FALSE, then no installation is performed. + * + * If this is TRUE, @ref CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. + * + * Only one of @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK and + * @ref CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is + * possible that both are FALSE for a particular CPU. Although it + * is unclear what that would imply about the interrupt processing + * procedure on that CPU. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_HAS_HARDWARE_INTERRUPT_STACK TRUE + +/** + * Does RTEMS allocate a dedicated interrupt stack in the Interrupt Manager? + * + * If TRUE, then the memory is allocated during initialization. + * If FALSE, then the memory is allocated during initialization. + * + * This should be TRUE is CPU_HAS_SOFTWARE_INTERRUPT_STACK is TRUE. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_ALLOCATE_INTERRUPT_STACK TRUE + +/** + * Does the RTEMS invoke the user's ISR with the vector number and + * a pointer to the saved interrupt frame (1) or just the vector + * number (0)? + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_ISR_PASSES_FRAME_POINTER FALSE + +/** + * @def CPU_HARDWARE_FP + * + * Does the CPU have hardware floating point? + * + * If TRUE, then the RTEMS_FLOATING_POINT task attribute is supported. + * If FALSE, then the RTEMS_FLOATING_POINT task attribute is ignored. + * + * If there is a FP coprocessor such as the i387 or mc68881, then + * the answer is TRUE. + * + * The macro name "NO_CPU_HAS_FPU" should be made CPU specific. + * It indicates whether or not this CPU model has FP support. For + * example, it would be possible to have an i386_nofp CPU model + * which set this to false to indicate that you have an i386 without + * an i387 and wish to leave floating point support out of RTEMS. + */ + +/** + * @def CPU_SOFTWARE_FP + * + * Does the CPU have no hardware floating point and GCC provides a + * software floating point implementation which must be context + * switched? + * + * This feature conditional is used to indicate whether or not there + * is software implemented floating point that must be context + * switched. The determination of whether or not this applies + * is very tool specific and the state saved/restored is also + * compiler specific. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#if ( NO_CPU_HAS_FPU == 1 ) +#define CPU_HARDWARE_FP TRUE +#else +#define CPU_HARDWARE_FP FALSE +#endif +#define CPU_SOFTWARE_FP FALSE + +/** + * Are all tasks RTEMS_FLOATING_POINT tasks implicitly? + * + * If TRUE, then the RTEMS_FLOATING_POINT task attribute is assumed. + * If FALSE, then the RTEMS_FLOATING_POINT task attribute is followed. + * + * So far, the only CPUs in which this option has been used are the + * HP PA-RISC and PowerPC. On the PA-RISC, The HP C compiler and + * gcc both implicitly used the floating point registers to perform + * integer multiplies. Similarly, the PowerPC port of gcc has been + * seen to allocate floating point local variables and touch the FPU + * even when the flow through a subroutine (like vfprintf()) might + * not use floating point formats. + * + * If a function which you would not think utilize the FP unit DOES, + * then one can not easily predict which tasks will use the FP hardware. + * In this case, this option should be TRUE. + * + * If @ref CPU_HARDWARE_FP is FALSE, then this should be FALSE as well. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_ALL_TASKS_ARE_FP TRUE + +/** + * Should the IDLE task have a floating point context? + * + * If TRUE, then the IDLE task is created as a RTEMS_FLOATING_POINT task + * and it has a floating point context which is switched in and out. + * If FALSE, then the IDLE task does not have a floating point context. + * + * Setting this to TRUE negatively impacts the time required to preempt + * the IDLE task from an interrupt because the floating point context + * must be saved as part of the preemption. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_IDLE_TASK_IS_FP FALSE + +/** + * Should the saving of the floating point registers be deferred + * until a context switch is made to another different floating point + * task? + * + * If TRUE, then the floating point context will not be stored until + * necessary. It will remain in the floating point registers and not + * disturned until another floating point task is switched to. + * + * If FALSE, then the floating point context is saved when a floating + * point task is switched out and restored when the next floating point + * task is restored. The state of the floating point registers between + * those two operations is not specified. + * + * If the floating point context does NOT have to be saved as part of + * interrupt dispatching, then it should be safe to set this to TRUE. + * + * Setting this flag to TRUE results in using a different algorithm + * for deciding when to save and restore the floating point context. + * The deferred FP switch algorithm minimizes the number of times + * the FP context is saved and restored. The FP context is not saved + * until a context switch is made to another, different FP task. + * Thus in a system with only one FP task, the FP context will never + * be saved or restored. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_USE_DEFERRED_FP_SWITCH TRUE + +/** + * @brief Enables a robust thread dispatch if set to TRUE. + * + * In general, it is an application bug to call blocking operating system + * services with interrupts disabled. In most situations this only increases + * the interrupt latency. However, on SMP configurations or on some CPU port + * like ARM Cortex-M it leads to undefined system behaviour. It order to ease + * the application development, this error condition is checked at run-time in + * case this CPU port option is defined to TRUE. + */ +#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE + +/** + * Does this port provide a CPU dependent IDLE task implementation? + * + * If TRUE, then the routine @ref _CPU_Thread_Idle_body + * must be provided and is the default IDLE thread body instead of + * @ref _CPU_Thread_Idle_body. + * + * If FALSE, then use the generic IDLE thread body if the BSP does + * not provide one. + * + * This is intended to allow for supporting processors which have + * a low power or idle mode. When the IDLE thread is executed, then + * the CPU can be powered down. + * + * The order of precedence for selecting the IDLE thread body is: + * + * -# BSP provided + * -# CPU dependent (if provided) + * -# generic (if no BSP and no CPU dependent) + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_PROVIDES_IDLE_THREAD_BODY TRUE + +/** + * Does the stack grow up (toward higher addresses) or down + * (toward lower addresses)? + * + * If TRUE, then the grows upward. + * If FALSE, then the grows toward smaller addresses. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_STACK_GROWS_UP TRUE + +/** + * The maximum cache line size in bytes. + * + * The actual processor may use no cache or a smaller cache line size. + */ +#define CPU_CACHE_LINE_BYTES 32 + +/** + * The following is the variable attribute used to force alignment + * of critical RTEMS structures. On some processors it may make + * sense to have these aligned on tighter boundaries than + * the minimum requirements of the compiler in order to have as + * much of the critical data area as possible in a cache line. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES ) + +/** + * @ingroup CPUInterrupt + * + * The following defines the number of bits actually used in the + * interrupt field of the task mode. How those bits map to the + * CPU interrupt levels is defined by the routine @ref _CPU_ISR_Set_level. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_MODES_INTERRUPT_MASK 0x00000001 + +/** + * @brief Maximum number of processors of all systems supported by this CPU + * port. + */ +#define CPU_MAXIMUM_PROCESSORS 32 + +/* + * Processor defined structures required for cpukit/score. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ + +/* may need to put some structures here. */ + +/** + * @defgroup CPUContext Processor Dependent Context Management + * + * From the highest level viewpoint, there are 2 types of context to save. + * + * -# Interrupt registers to save + * -# Task level registers to save + * + * Since RTEMS handles integer and floating point contexts separately, this + * means we have the following 3 context items: + * + * -# task level context stuff:: Context_Control + * -# floating point task stuff:: Context_Control_fp + * -# special interrupt level context :: CPU_Interrupt_frame + * + * On some processors, it is cost-effective to save only the callee + * preserved registers during a task context switch. This means + * that the ISR code needs to save those registers which do not + * persist across function calls. It is not mandatory to make this + * distinctions between the caller/callee saves registers for the + * purpose of minimizing context saved during task switch and on interrupts. + * If the cost of saving extra registers is minimal, simplicity is the + * choice. Save the same context on interrupt entry as for tasks in + * this case. + * + * Additionally, if gdb is to be made aware of RTEMS tasks for this CPU, then + * care should be used in designing the context area. + * + * On some CPUs with hardware floating point support, the Context_Control_fp + * structure will not be used or it simply consist of an array of a + * fixed number of bytes. This is done when the floating point context + * is dumped by a "FP save context" type instruction and the format + * is not really defined by the CPU. In this case, there is no need + * to figure out the exact format -- only the size. Of course, although + * this is enough information for RTEMS, it is probably not enough for + * a debugger such as gdb. But that is another problem. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + * + */ +/**@{**/ + +/** + * @ingroup Management + * This defines the minimal set of integer and processor state registers + * that must be saved during a voluntary context switch from one thread + * to another. + */ +typedef struct { + /** + * This field is a hint that a port will have a number of integer + * registers that need to be saved at a context switch. + */ + uint32_t some_integer_register; + /** + * This field is a hint that a port will have a number of system + * registers that need to be saved at a context switch. + */ + uint32_t some_system_register; + + /** + * This field is a hint that a port will have a register that + * is the stack pointer. + */ + uint32_t stack_pointer; + +#ifdef RTEMS_SMP + /** + * @brief On SMP configurations the thread context must contain a boolean + * indicator to signal if this context is executing on a processor. + * + * This field must be updated during a context switch. The context switch + * to the heir must wait until the heir context indicates that it is no + * longer executing on a processor. This indicator must be updated using + * an atomic test and set operation to ensure that at most one processor + * uses the heir context at the same time. The context switch must also + * check for a potential new heir thread for this processor in case the + * heir context is not immediately available. Update the executing thread + * for this processor only if necessary to avoid a cache line + * monopolization. + * + * @code + * void _CPU_Context_switch( + * Context_Control *executing_context, + * Context_Control *heir_context + * ) + * { + * save( executing_context ); + * + * executing_context->is_executing = false; + * memory_barrier(); + * + * if ( test_and_set( &heir_context->is_executing ) ) { + * do { + * Per_CPU_Control *cpu_self = _Per_CPU_Get_snapshot(); + * Thread_Control *executing = cpu_self->executing; + * Thread_Control *heir = cpu_self->heir; + * + * if ( heir != executing ) { + * cpu_self->executing = heir; + * heir_context = (Context_Control *) + * ((uintptr_t) heir + (uintptr_t) executing_context + * - (uintptr_t) executing) + * } + * } while ( test_and_set( &heir_context->is_executing ) ); + * } + * + * restore( heir_context ); + * } + * @endcode + */ + volatile bool is_executing; +#endif +} Context_Control; + +/** + * @ingroup Management + * + * This macro returns the stack pointer associated with @a _context. + * + * @param[in] _context is the thread context area to access + * + * @return This method returns the stack pointer. + */ +#define _CPU_Context_Get_SP( _context ) \ + (_context)->stack_pointer + +/** + * @ingroup Management + * + * This defines the complete set of floating point registers that must + * be saved during any context switch from one thread to another. + */ +typedef struct { + /** FPU registers are listed here */ + double some_float_register; +} Context_Control_fp; + +/** + * @ingroup Management + * + * This defines the set of integer and processor state registers that must + * be saved during an interrupt. This set does not include any which are + * in @ref Context_Control. + */ +typedef struct { + /** + * This field is a hint that a port will have a number of integer + * registers that need to be saved when an interrupt occurs or + * when a context switch occurs at the end of an ISR. + */ + uint32_t special_interrupt_register; +} CPU_Interrupt_frame; + +/** + * This variable is optional. It is used on CPUs on which it is difficult + * to generate an "uninitialized" FP context. It is filled in by + * @ref _CPU_Initialize and copied into the task's FP context area during + * @ref _CPU_Context_Initialize. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +extern Context_Control_fp _CPU_Null_fp_context; + +/** @} */ + +/** + * @defgroup CPUInterrupt Processor Dependent Interrupt Management + * + * On some CPUs, RTEMS supports a software managed interrupt stack. + * This stack is allocated by the Interrupt Manager and the switch + * is performed in @ref _ISR_Handler. These variables contain pointers + * to the lowest and highest addresses in the chunk of memory allocated + * for the interrupt stack. Since it is unknown whether the stack + * grows up or down (in general), this give the CPU dependent + * code the option of picking the version it wants to use. + * + * NOTE: These two variables are required if the macro + * @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK is defined as TRUE. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ + +/* + * Nothing prevents the porter from declaring more CPU specific variables. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ + +/* XXX: if needed, put more variables here */ + +/** + * @ingroup CPUContext + * + * The size of the floating point context area. On some CPUs this + * will not be a "sizeof" because the format of the floating point + * area is not defined -- only the size is. This is usually on + * CPUs with a "floating point save context" instruction. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp ) + +/** + * Amount of extra stack (above minimum stack size) required by + * MPCI receive server thread. Remember that in a multiprocessor + * system this thread must exist and be able to process all directives. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0 + +/** + * @ingroup CPUInterrupt + * + * This defines the number of entries in the _ISR_Vector_table managed by RTEMS + * in case CPU_SIMPLE_VECTORED_INTERRUPTS is defined to TRUE. It must be a + * compile-time constant. + * + * It must be undefined in case CPU_SIMPLE_VECTORED_INTERRUPTS is defined to + * FALSE. + */ +#define CPU_INTERRUPT_NUMBER_OF_VECTORS 32 + +/** + * @ingroup CPUInterrupt + * + * This defines the highest interrupt vector number for this port in case + * CPU_SIMPLE_VECTORED_INTERRUPTS is defined to TRUE. It must be less than + * CPU_INTERRUPT_NUMBER_OF_VECTORS. It may be not a compile-time constant. + * + * It must be undefined in case CPU_SIMPLE_VECTORED_INTERRUPTS is defined to + * FALSE. + */ +#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER (CPU_INTERRUPT_NUMBER_OF_VECTORS - 1) + +/** + * @ingroup CPUInterrupt + * + * This is defined if the port has a special way to report the ISR nesting + * level. Most ports maintain the variable @a _ISR_Nest_level. + */ +#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE + +/** + * @ingroup CPUContext + * + * Should be large enough to run all RTEMS tests. This ensures + * that a "reasonable" small application should not have any problems. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_STACK_MINIMUM_SIZE (1024*4) + +/** + * Size of a pointer. + * + * This must be an integer literal that can be used by the assembler. This + * value will be used to calculate offsets of structure members. These + * offsets will be used in assembler code. + */ +#define CPU_SIZEOF_POINTER 4 + +/** + * CPU's worst alignment requirement for data types on a byte boundary. This + * alignment does not take into account the requirements for the stack. It + * must be a power of two greater than or equal to two. The power of two + * requirement makes it possible to align values easily using simple bit + * operations. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_ALIGNMENT 8 + +/** + * This number corresponds to the byte alignment requirement for the + * heap handler. This alignment requirement may be stricter than that + * for the data types alignment specified by @ref CPU_ALIGNMENT. It is + * common for the heap to follow the same alignment requirement as + * @ref CPU_ALIGNMENT. If the @ref CPU_ALIGNMENT is strict enough for + * the heap, then this should be set to @ref CPU_ALIGNMENT. + * + * NOTE: It must be a power of two greater than or equal to two. The + * requirement to be a multiple of two is because the heap uses the + * least significant field of the front and back flags to indicate that + * a block is in use or free. So you do not want any odd length blocks + * really putting length data in that bit. + * + * On byte oriented architectures, @ref CPU_HEAP_ALIGNMENT normally will + * have to be greater or equal to than @ref CPU_ALIGNMENT to ensure that + * elements allocated from the heap meet all restrictions. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT + +/** + * This number corresponds to the byte alignment requirement for memory + * buffers allocated by the partition manager. This alignment requirement + * may be stricter than that for the data types alignment specified by + * @ref CPU_ALIGNMENT. It is common for the partition to follow the same + * alignment requirement as @ref CPU_ALIGNMENT. If the @ref CPU_ALIGNMENT is + * strict enough for the partition, then this should be set to + * @ref CPU_ALIGNMENT. + * + * NOTE: This does not have to be a power of 2. It does have to + * be greater or equal to than @ref CPU_ALIGNMENT. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT + +/** + * This number corresponds to the byte alignment requirement for the + * stack. This alignment requirement may be stricter than that for the + * data types alignment specified by @ref CPU_ALIGNMENT. If the + * @ref CPU_ALIGNMENT is strict enough for the stack, then this should be + * set to 0. + * + * NOTE: This must be a power of 2 either 0 or greater than @ref CPU_ALIGNMENT. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_STACK_ALIGNMENT 0 + +/* + * ISR handler macros + */ + +/** + * @ingroup CPUInterrupt + * + * Support routine to initialize the RTEMS vector table after it is allocated. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_Initialize_vectors() + +/** + * @ingroup CPUInterrupt + * + * Disable all interrupts for an RTEMS critical section. The previous + * level is returned in @a _isr_cookie. + * + * @param[out] _isr_cookie will contain the previous level cookie + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_ISR_Disable( _isr_cookie ) \ + { \ + (_isr_cookie) = 0; /* do something to prevent warnings */ \ + } + +/** + * @ingroup CPUInterrupt + * + * Enable interrupts to the previous level (returned by _CPU_ISR_Disable). + * This indicates the end of an RTEMS critical section. The parameter + * @a _isr_cookie is not modified. + * + * @param[in] _isr_cookie contain the previous level cookie + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_ISR_Enable( _isr_cookie ) \ + { \ + } + +/** + * @ingroup CPUInterrupt + * + * This temporarily restores the interrupt to @a _isr_cookie before immediately + * disabling them again. This is used to divide long RTEMS critical + * sections into two or more parts. The parameter @a _isr_cookie is not + * modified. + * + * @param[in] _isr_cookie contain the previous level cookie + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_ISR_Flash( _isr_cookie ) \ + { \ + } + +/** + * @brief Returns true if interrupts are enabled in the specified ISR level, + * otherwise returns false. + * + * @param[in] level The ISR level. + * + * @retval true Interrupts are enabled in the ISR level. + * @retval false Otherwise. + */ +RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) +{ + return false; +} + +/** + * @ingroup CPUInterrupt + * + * This routine and @ref _CPU_ISR_Get_level + * Map the interrupt level in task mode onto the hardware that the CPU + * actually provides. Currently, interrupt levels which do not + * map onto the CPU in a generic fashion are undefined. Someday, + * it would be nice if these were "mapped" by the application + * via a callout. For example, m68k has 8 levels 0 - 7, levels + * 8 - 255 would be available for bsp/application specific meaning. + * This could be used to manage a programmable interrupt controller + * via the rtems_task_mode directive. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_ISR_Set_level( new_level ) \ + { \ + } + +/** + * @ingroup CPUInterrupt + * + * Return the current interrupt disable level for this task in + * the format used by the interrupt level portion of the task mode. + * + * NOTE: This routine usually must be implemented as a subroutine. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +uint32_t _CPU_ISR_Get_level( void ); + +/* end of ISR handler macros */ + +/* Context handler macros */ + +/** + * @ingroup CPUContext + * + * @brief Destroys the context of the thread. + * + * It must be implemented as a macro and an implementation is optional. The + * default implementation does nothing. + * + * @param[in] _the_thread The corresponding thread. + * @param[in] _the_context The context to destroy. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_Context_Destroy( _the_thread, _the_context ) \ + { \ + } + +/** + * @ingroup CPUContext + * + * Initialize the context to a state suitable for starting a + * task after a context restore operation. Generally, this + * involves: + * + * - setting a starting address + * - preparing the stack + * - preparing the stack and frame pointers + * - setting the proper interrupt level in the context + * - initializing the floating point context + * + * This routine generally does not set any unnecessary register + * in the context. The state of the "general data" registers is + * undefined at task start time. + * + * The ISR dispatch disable field of the context must be cleared to zero if it + * is used by the CPU port. Otherwise, a thread restart results in + * unpredictable behaviour. + * + * @param[in] _the_context is the context structure to be initialized + * @param[in] _stack_base is the lowest physical address of this task's stack + * @param[in] _size is the size of this task's stack + * @param[in] _isr is the interrupt disable level + * @param[in] _entry_point is the thread's entry point. This is + * always @a _Thread_Handler + * @param[in] _is_fp is TRUE if the thread is to be a floating + * point thread. This is typically only used on CPUs where the + * FPU may be easily disabled by software such as on the SPARC + * where the PSR contains an enable FPU bit. + * @param[in] _tls_area The thread-local storage (TLS) area. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_Context_Initialize( _the_context, _stack_base, _size, \ + _isr, _entry_point, _is_fp, _tls_area ) \ + { \ + } + +/** + * This routine is responsible for somehow restarting the currently + * executing task. If you are lucky, then all that is necessary + * is restoring the context. Otherwise, there will need to be + * a special assembly routine which does something special in this + * case. For many ports, simply adding a label to the restore path + * of @ref _CPU_Context_switch will work. On other ports, it may be + * possibly to load a few arguments and jump to the restore path. It will + * not work if restarting self conflicts with the stack frame + * assumptions of restoring a context. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_Context_Restart_self( _the_context ) \ + _CPU_Context_restore( (_the_context) ); + +/** + * This routine initializes the FP context area passed to it to. + * There are a few standard ways in which to initialize the + * floating point context. The code included for this macro assumes + * that this is a CPU in which a "initial" FP context was saved into + * @a _CPU_Null_fp_context and it simply copies it to the destination + * context passed to it. + * + * Other floating point context save/restore models include: + * -# not doing anything, and + * -# putting a "null FP status word" in the correct place in the FP context. + * + * @param[in] _destination is the floating point context area + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_Context_Initialize_fp( _destination ) \ + { \ + *(*(_destination)) = _CPU_Null_fp_context; \ + } + +/* end of Context handler macros */ + +/* Fatal Error manager macros */ + +/** + * This routine copies _error into a known place -- typically a stack + * location or a register, optionally disables interrupts, and + * halts/stops the CPU. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_Fatal_halt( _source, _error ) \ + { \ + } + +/* end of Fatal Error manager macros */ + +/* Bitfield handler macros */ + +/** + * @defgroup CPUBitfield Processor Dependent Bitfield Manipulation + * + * This set of routines are used to implement fast searches for + * the most important ready task. + * + */ +/**@{**/ + +/** + * This definition is set to TRUE if the port uses the generic bitfield + * manipulation implementation. + */ +#define CPU_USE_GENERIC_BITFIELD_CODE TRUE + +/** + * This routine sets @a _output to the bit number of the first bit + * set in @a _value. @a _value is of CPU dependent type + * @a Priority_bit_map_Word. This type may be either 16 or 32 bits + * wide although only the 16 least significant bits will be used. + * + * There are a number of variables in using a "find first bit" type + * instruction. + * + * -# What happens when run on a value of zero? + * -# Bits may be numbered from MSB to LSB or vice-versa. + * -# The numbering may be zero or one based. + * -# The "find first bit" instruction may search from MSB or LSB. + * + * RTEMS guarantees that (1) will never happen so it is not a concern. + * (2),(3), (4) are handled by the macros @ref _CPU_Priority_Mask and + * @ref _CPU_Priority_bits_index. These three form a set of routines + * which must logically operate together. Bits in the _value are + * set and cleared based on masks built by @ref _CPU_Priority_Mask. + * The basic major and minor values calculated by @ref _Priority_Major + * and @ref _Priority_Minor are "massaged" by @ref _CPU_Priority_bits_index + * to properly range between the values returned by the "find first bit" + * instruction. This makes it possible for @ref _Priority_Get_highest to + * calculate the major and directly index into the minor table. + * This mapping is necessary to ensure that 0 (a high priority major/minor) + * is the first bit found. + * + * This entire "find first bit" and mapping process depends heavily + * on the manner in which a priority is broken into a major and minor + * components with the major being the 4 MSB of a priority and minor + * the 4 LSB. Thus (0 << 4) + 0 corresponds to priority 0 -- the highest + * priority. And (15 << 4) + 14 corresponds to priority 254 -- the next + * to the lowest priority. + * + * If your CPU does not have a "find first bit" instruction, then + * there are ways to make do without it. Here are a handful of ways + * to implement this in software: + * +@verbatim + - a series of 16 bit test instructions + - a "binary search using if's" + - _number = 0 + if _value > 0x00ff + _value >>=8 + _number = 8; + + if _value > 0x0000f + _value >=8 + _number += 4 + + _number += bit_set_table[ _value ] +@endverbatim + + * where bit_set_table[ 16 ] has values which indicate the first + * bit set + * + * @param[in] _value is the value to be scanned + * @param[in] _output is the first bit set + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ + +#if (CPU_USE_GENERIC_BITFIELD_CODE == FALSE) +#define _CPU_Bitfield_Find_first_bit( _value, _output ) \ + { \ + (_output) = 0; /* do something to prevent warnings */ \ + } +#endif + +/** @} */ + +/* end of Bitfield handler macros */ + +/** + * This routine builds the mask which corresponds to the bit fields + * as searched by @ref _CPU_Bitfield_Find_first_bit. See the discussion + * for that routine. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#if (CPU_USE_GENERIC_BITFIELD_CODE == FALSE) + +#define _CPU_Priority_Mask( _bit_number ) \ + ( 1 << (_bit_number) ) + +#endif + +/** + * @ingroup CPUBitfield + * + * This routine translates the bit numbers returned by + * @ref _CPU_Bitfield_Find_first_bit into something suitable for use as + * a major or minor component of a priority. See the discussion + * for that routine. + * + * @param[in] _priority is the major or minor number to translate + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#if (CPU_USE_GENERIC_BITFIELD_CODE == FALSE) + +#define _CPU_Priority_bits_index( _priority ) \ + (_priority) + +#endif + +/* end of Priority handler macros */ + +/* functions */ + +/** + * This routine performs CPU dependent initialization. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_Initialize(void); + +/** + * @ingroup CPUInterrupt + * + * This routine installs a "raw" interrupt handler directly into the + * processor's vector table. + * + * @param[in] vector is the vector number + * @param[in] new_handler is the raw ISR handler to install + * @param[in] old_handler is the previously installed ISR Handler + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_ISR_install_raw_handler( + uint32_t vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +/** + * @ingroup CPUInterrupt + * + * This routine installs an interrupt vector. + * + * @param[in] vector is the vector number + * @param[in] new_handler is the RTEMS ISR handler to install + * @param[in] old_handler is the previously installed ISR Handler + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_ISR_install_vector( + uint32_t vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +/** + * @ingroup CPUInterrupt + * This routine installs the hardware interrupt stack pointer. + * + * NOTE: It need only be provided if @ref CPU_HAS_HARDWARE_INTERRUPT_STACK + * is TRUE. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_Install_interrupt_stack( void ); + +/** + * This routine is the CPU dependent IDLE thread body. + * + * NOTE: It need only be provided if @ref CPU_PROVIDES_IDLE_THREAD_BODY + * is TRUE. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void *_CPU_Thread_Idle_body( uintptr_t ignored ); + +/** + * @ingroup CPUContext + * + * This routine switches from the run context to the heir context. + * + * @param[in] run points to the context of the currently executing task + * @param[in] heir points to the context of the heir task + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_Context_switch( + Context_Control *run, + Context_Control *heir +); + +/** + * @ingroup CPUContext + * + * This routine is generally used only to restart self in an + * efficient manner. It may simply be a label in @ref _CPU_Context_switch. + * + * @param[in] new_context points to the context to be restored. + * + * NOTE: May be unnecessary to reload some registers. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_Context_restore( + Context_Control *new_context +) RTEMS_NO_RETURN; + +/** + * @ingroup CPUContext + * + * This routine saves the floating point context passed to it. + * + * @param[in] fp_context_ptr is a pointer to a pointer to a floating + * point context area + * + * @return on output @a *fp_context_ptr will contain the address that + * should be used with @ref _CPU_Context_restore_fp to restore this context. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_Context_save_fp( + Context_Control_fp **fp_context_ptr +); + +/** + * @ingroup CPUContext + * + * This routine restores the floating point context passed to it. + * + * @param[in] fp_context_ptr is a pointer to a pointer to a floating + * point context area to restore + * + * @return on output @a *fp_context_ptr will contain the address that + * should be used with @ref _CPU_Context_save_fp to save this context. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_Context_restore_fp( + Context_Control_fp **fp_context_ptr +); + +/** + * @ingroup CPUContext + * + * @brief Clobbers all volatile registers with values derived from the pattern + * parameter. + * + * This function is used only in test sptests/spcontext01. + * + * @param[in] pattern Pattern used to generate distinct register values. + * + * @see _CPU_Context_validate(). + */ +void _CPU_Context_volatile_clobber( uintptr_t pattern ); + +/** + * @ingroup CPUContext + * + * @brief Initializes and validates the CPU context with values derived from + * the pattern parameter. + * + * This function will not return if the CPU context remains consistent. In + * case this function returns the CPU port is broken. + * + * This function is used only in test sptests/spcontext01. + * + * @param[in] pattern Pattern used to generate distinct register values. + * + * @see _CPU_Context_volatile_clobber(). + */ +void _CPU_Context_validate( uintptr_t pattern ); + +/** + * @brief The set of registers that specifies the complete processor state. + * + * The CPU exception frame may be available in fatal error conditions like for + * example illegal opcodes, instruction fetch errors, or data access errors. + * + * @see rtems_fatal(), RTEMS_FATAL_SOURCE_EXCEPTION, and + * rtems_exception_frame_print(). + */ +typedef struct { + uint32_t processor_state_register; + uint32_t integer_registers [1]; + double float_registers [1]; +} CPU_Exception_frame; + +/** + * @brief Prints the exception frame via printk(). + * + * @see rtems_fatal() and RTEMS_FATAL_SOURCE_EXCEPTION. + */ +void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); + +/** + * @ingroup CPUEndian + * + * The following routine swaps the endian format of an unsigned int. + * It must be static because it is referenced indirectly. + * + * This version will work on any processor, but if there is a better + * way for your CPU PLEASE use it. The most common way to do this is to: + * + * swap least significant two bytes with 16-bit rotate + * swap upper and lower 16-bits + * swap most significant two bytes with 16-bit rotate + * + * Some CPUs have special instructions which swap a 32-bit quantity in + * a single instruction (e.g. i486). It is probably best to avoid + * an "endian swapping control bit" in the CPU. One good reason is + * that interrupts would probably have to be disabled to ensure that + * an interrupt does not try to access the same "chunk" with the wrong + * endian. Another good reason is that on some CPUs, the endian bit + * endianness for ALL fetches -- both code and data -- so the code + * will be fetched incorrectly. + * + * @param[in] value is the value to be swapped + * @return the value after being endian swapped + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +static inline uint32_t CPU_swap_u32( + uint32_t value +) +{ + uint32_t byte1, byte2, byte3, byte4, swapped; + + byte4 = (value >> 24) & 0xff; + byte3 = (value >> 16) & 0xff; + byte2 = (value >> 8) & 0xff; + byte1 = value & 0xff; + + swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4; + return swapped; +} + +/** + * @ingroup CPUEndian + * + * This routine swaps a 16 bir quantity. + * + * @param[in] value is the value to be swapped + * @return the value after being endian swapped + */ +#define CPU_swap_u16( value ) \ + (((value&0xff) << 8) | ((value >> 8)&0xff)) + +/** + * @brief Unsigned integer type for CPU counter values. + */ +typedef uint32_t CPU_Counter_ticks; + +/** + * @brief Returns the current CPU counter value. + * + * A CPU counter is some free-running counter. It ticks usually with a + * frequency close to the CPU or system bus clock. The board support package + * must ensure that this function works before the RTEMS initialization. + * Otherwise invalid profiling statistics will be gathered. + * + * @return The current CPU counter value. + */ +CPU_Counter_ticks _CPU_Counter_read( void ); + +/** + * @brief Returns the difference between the second and first CPU counter + * value. + * + * This operation may be carried out as a modulo operation depending on the + * range of the CPU counter device. + * + * @param[in] second The second CPU counter value. + * @param[in] first The first CPU counter value. + * + * @return Returns second minus first modulo counter period. + */ +CPU_Counter_ticks _CPU_Counter_difference( + CPU_Counter_ticks second, + CPU_Counter_ticks first +); + +#ifdef RTEMS_SMP + /** + * @brief Performs CPU specific SMP initialization in the context of the boot + * processor. + * + * This function is invoked on the boot processor during system + * initialization. All interrupt stacks are allocated at this point in case + * the CPU port allocates the interrupt stacks. This function is called + * before _CPU_SMP_Start_processor() or _CPU_SMP_Finalize_initialization() is + * used. + * + * @return The count of physically or virtually available processors. + * Depending on the configuration the application may use not all processors. + */ + uint32_t _CPU_SMP_Initialize( void ); + + /** + * @brief Starts a processor specified by its index. + * + * This function is invoked on the boot processor during system + * initialization. + * + * This function will be called after _CPU_SMP_Initialize(). + * + * @param[in] cpu_index The processor index. + * + * @retval true Successful operation. + * @retval false Unable to start this processor. + */ + bool _CPU_SMP_Start_processor( uint32_t cpu_index ); + + /** + * @brief Performs final steps of CPU specific SMP initialization in the + * context of the boot processor. + * + * This function is invoked on the boot processor during system + * initialization. + * + * This function will be called after all processors requested by the + * application have been started. + * + * @param[in] cpu_count The minimum value of the count of processors + * requested by the application configuration and the count of physically or + * virtually available processors. + */ + void _CPU_SMP_Finalize_initialization( uint32_t cpu_count ); + + /** + * @brief Prepares a CPU to start multitasking in terms of SMP. + * + * This function is invoked on all processors requested by the application + * during system initialization. + * + * This function will be called after all processors requested by the + * application have been started right before the context switch to the first + * thread takes place. + */ + void _CPU_SMP_Prepare_start_multitasking( void ); + + /** + * @brief Returns the index of the current processor. + * + * An architecture specific method must be used to obtain the index of the + * current processor in the system. The set of processor indices is the + * range of integers starting with zero up to the processor count minus one. + */ + static inline uint32_t _CPU_SMP_Get_current_processor( void ) + { + return 123; + } + + /** + * @brief Sends an inter-processor interrupt to the specified target + * processor. + * + * This operation is undefined for target processor indices out of range. + * + * @param[in] target_processor_index The target processor index. + */ + void _CPU_SMP_Send_interrupt( uint32_t target_processor_index ); + + /** + * @brief Broadcasts a processor event. + * + * Some architectures provide a low-level synchronization primitive for + * processors in a multi-processor environment. Processors waiting for this + * event may go into a low-power state and stop generating system bus + * transactions. This function must ensure that preceding store operations + * can be observed by other processors. + * + * @see _CPU_SMP_Processor_event_receive(). + */ + static inline void _CPU_SMP_Processor_event_broadcast( void ) + { + __asm__ volatile ( "" : : : "memory" ); + } + + /** + * @brief Receives a processor event. + * + * This function will wait for the processor event and may wait forever if no + * such event arrives. + * + * @see _CPU_SMP_Processor_event_broadcast(). + */ + static inline void _CPU_SMP_Processor_event_receive( void ) + { + __asm__ volatile ( "" : : : "memory" ); + } + + /** + * @brief Gets the is executing indicator of the thread context. + * + * @param[in] context The context. + */ + static inline bool _CPU_Context_Get_is_executing( + const Context_Control *context + ) + { + return context->is_executing; + } + + /** + * @brief Sets the is executing indicator of the thread context. + * + * @param[in] context The context. + * @param[in] is_executing The new value for the is executing indicator. + */ + static inline void _CPU_Context_Set_is_executing( + Context_Control *context, + bool is_executing + ) + { + context->is_executing = is_executing; + } +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/score/cpu/no_cpu/include/rtems/score/cpu_asm.h b/cpukit/score/cpu/no_cpu/include/rtems/score/cpu_asm.h new file mode 100644 index 0000000000..747fd3a1c1 --- /dev/null +++ b/cpukit/score/cpu/no_cpu/include/rtems/score/cpu_asm.h @@ -0,0 +1,74 @@ +/** + * @file + * + * @brief No-CPU Assembly File + * + * Very loose template for an include file for the cpu_asm.? file + * if it is implemented as a ".S" file (preprocessed by cpp) instead + * of a ".s" file (preprocessed by gm4 or gasp). + */ + +/* + * + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + */ + +#ifndef _RTEMS_SCORE_CPU_ASM_H +#define _RTEMS_SCORE_CPU_ASM_H + +/* pull in the generated offsets */ + +#include + +/* + * Hardware General Registers + */ + +/* put something here */ + +/* + * Hardware Floating Point Registers + */ + +/* put something here */ + +/* + * Hardware Control Registers + */ + +/* put something here */ + +/* + * Calling Convention + */ + +/* put something here */ + +/* + * Temporary registers + */ + +/* put something here */ + +/* + * Floating Point Registers - SW Conventions + */ + +/* put something here */ + +/* + * Temporary floating point registers + */ + +/* put something here */ + +#endif + +/* end of file */ diff --git a/cpukit/score/cpu/no_cpu/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/no_cpu/include/rtems/score/cpuimpl.h new file mode 100644 index 0000000000..85214d7f6c --- /dev/null +++ b/cpukit/score/cpu/no_cpu/include/rtems/score/cpuimpl.h @@ -0,0 +1,82 @@ +/** + * @file + * + * @brief CPU Port Implementation API + */ + +/* + * Copyright (c) 2013, 2016 embedded brains GmbH + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPUIMPL_H +#define _RTEMS_SCORE_CPUIMPL_H + +#include + +/** + * @brief The size of the CPU specific per-CPU control. + * + * This define must be visible to assember files since it is used to derive + * structure offsets. + */ +#define CPU_PER_CPU_CONTROL_SIZE 0 + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief The CPU specific per-CPU control. + * + * The CPU port can place here all state information that must be available and + * maintained for each processor in the system. This structure must contain at + * least one field for C/C++ compatibility. In GNU C empty structures have a + * size of zero. In C++ structures have a non-zero size. In case + * CPU_PER_CPU_CONTROL_SIZE is defined to zero, then this structure is not + * used. + */ +typedef struct { + /* CPU specific per-CPU state */ +} CPU_Per_CPU_control; + +/** + * @brief Special register pointing to the per-CPU control of the current + * processor. + * + * This is optional. Not every CPU port needs this. It is only an optional + * optimization variant. + */ +register struct Per_CPU_Control *_CPU_Per_CPU_current asm( "rX" ); + +/** + * @brief Optional method to obtain the per-CPU control of the current processor. + * + * This is optional. Not every CPU port needs this. It is only an optional + * optimization variant. In case this macro is undefined, the default + * implementation using the current processor index will be used. + */ +#define _CPU_Get_current_per_CPU_control() ( _CPU_Per_CPU_current ) + +/** + * @brief Optional method to get the executing thread. + * + * This is optional. Not every CPU port needs this. It is only an optional + * optimization variant. In case this macro is undefined, the default + * implementation uses the per-CPU information and the current processor index + * to get the executing thread. + */ +#define _CPU_Get_thread_executing() ( _CPU_Per_CPU_current->executing ) + +#ifdef __cplusplus +} +#endif + +#endif /* ASM */ + +#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/no_cpu/include/rtems/score/no_cpu.h b/cpukit/score/cpu/no_cpu/include/rtems/score/no_cpu.h new file mode 100644 index 0000000000..d1bbceccc0 --- /dev/null +++ b/cpukit/score/cpu/no_cpu/include/rtems/score/no_cpu.h @@ -0,0 +1,67 @@ +/* no_cpu.h + * + * This file sets up basic CPU dependency settings based on + * compiler settings. For example, it can determine if + * floating point is available. This particular implementation + * is specified to the NO CPU port. + * + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + */ + +#ifndef _RTEMS_SCORE_NO_CPU_H +#define _RTEMS_SCORE_NO_CPU_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This file contains the information required to build + * RTEMS for a particular member of the NO CPU family. + * It does this by setting variables to indicate which + * implementation dependent features are present in a particular + * member of the family. + * + * This is a good place to list all the known CPU models + * that this port supports and which RTEMS CPU model they correspond + * to. + */ + +#if defined(rtems_multilib) +/* + * Figure out all CPU Model Feature Flags based upon compiler + * predefines. + */ + +#define CPU_MODEL_NAME "rtems_multilib" +#define NOCPU_HAS_FPU 1 + +#elif defined(no_cpu) + +#define CPU_MODEL_NAME "no_cpu_model" +#define NOCPU_HAS_FPU 1 + +#else + +#error "Unsupported CPU Model" + +#endif + +/* + * Define the name of the CPU family. + */ + +#define CPU_NAME "NO CPU" + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_SCORE_NO_CPU_H */ diff --git a/cpukit/score/cpu/no_cpu/include/rtems/score/types.h b/cpukit/score/cpu/no_cpu/include/rtems/score/types.h new file mode 100644 index 0000000000..b330c33904 --- /dev/null +++ b/cpukit/score/cpu/no_cpu/include/rtems/score/types.h @@ -0,0 +1,43 @@ +/** + * @file + * + * @brief No-CPU Type Definitions + * + * This include file contains type definitions pertaining to the Intel + * no_cpu processor family. + */ + +/* + * COPYRIGHT (c) 1989-2006. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_TYPES_H +#define _RTEMS_SCORE_TYPES_H + +#include + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This section defines the basic types for this processor. + */ + +/** Type that can store a 32-bit integer or a pointer. */ +typedef uintptr_t CPU_Uint32ptr; + +#ifdef __cplusplus +} +#endif + +#endif /* !ASM */ + +#endif diff --git a/cpukit/score/cpu/no_cpu/preinstall.am b/cpukit/score/cpu/no_cpu/preinstall.am deleted file mode 100644 index fa63e6a812..0000000000 --- a/cpukit/score/cpu/no_cpu/preinstall.am +++ /dev/null @@ -1,49 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -$(PROJECT_INCLUDE)/rtems/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems - @: > $(PROJECT_INCLUDE)/rtems/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/asm.h: rtems/asm.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/asm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/asm.h - -$(PROJECT_INCLUDE)/rtems/score/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/score - @: > $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/score/cpu.h: rtems/score/cpu.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpu.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpu.h - -$(PROJECT_INCLUDE)/rtems/score/cpuimpl.h: rtems/score/cpuimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h - -$(PROJECT_INCLUDE)/rtems/score/no_cpu.h: rtems/score/no_cpu.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/no_cpu.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/no_cpu.h - -$(PROJECT_INCLUDE)/rtems/score/cpu_asm.h: rtems/score/cpu_asm.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpu_asm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpu_asm.h - -$(PROJECT_INCLUDE)/rtems/score/types.h: rtems/score/types.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/types.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/types.h - diff --git a/cpukit/score/cpu/no_cpu/rtems/asm.h b/cpukit/score/cpu/no_cpu/rtems/asm.h deleted file mode 100644 index 926e3964e5..0000000000 --- a/cpukit/score/cpu/no_cpu/rtems/asm.h +++ /dev/null @@ -1,133 +0,0 @@ -/** - * @file rtems/asm.h - * - * @brief Addresses Incompatible Flavors Problems - * - * This include file attempts to address the problems - * caused by incompatible flavors of assemblers and - * toolsets. It primarily addresses variations in the - * use of leading underscores on symbols and the requirement - * that register names be preceded by a %. - * - * NOTE: The spacing in the use of these macros - * is critical to them working as advertised. - */ - -/* - * COPYRIGHT: - * - * This file is based on similar code found in newlib available - * from ftp.cygnus.com. The file which was used had no copyright - * notice. This file is freely distributable as long as the source - * of the file is noted. This file is: - * - * COPYRIGHT (c) 1994-2006. - * On-Line Applications Research Corporation (OAR). - */ - -#ifndef _RTEMS_ASM_H -#define _RTEMS_ASM_H - -/** - * @defgroup no_cpuAsm Address Incompatible Flavors Problems - * - * @ingroup no_cpu - */ -/**@{*/ - -/* - * Indicate we are in an assembly file and get the basic CPU definitions. - */ - -#ifndef ASM -#define ASM -#endif -#include -#include - -#ifndef __USER_LABEL_PREFIX__ -/** - * Recent versions of GNU cpp define variables which indicate the - * need for underscores and percents. If not using GNU cpp or - * the version does not support this, then you will obviously - * have to define these as appropriate. - * - * This symbol is prefixed to all C program symbols. - */ -#define __USER_LABEL_PREFIX__ _ -#endif - -#ifndef __REGISTER_PREFIX__ -/** - * Recent versions of GNU cpp define variables which indicate the - * need for underscores and percents. If not using GNU cpp or - * the version does not support this, then you will obviously - * have to define these as appropriate. - * - * This symbol is prefixed to all register names. - */ -#define __REGISTER_PREFIX__ -#endif - -#include - -/** Use the right prefix for global labels. */ -#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) - -/** Use the right prefix for registers. */ -#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) - -/* - * define macros for all of the registers on this CPU - * - * EXAMPLE: #define d0 REG (d0) - */ - -/* - * Define macros to handle section beginning and ends. - */ - - -/** This macro is used to denote the beginning of a code declaration. */ -#define BEGIN_CODE_DCL .text -/** This macro is used to denote the end of a code declaration. */ -#define END_CODE_DCL -/** This macro is used to denote the beginning of a data declaration section. */ -#define BEGIN_DATA_DCL .data -/** This macro is used to denote the end of a data declaration section. */ -#define END_DATA_DCL -/** This macro is used to denote the beginning of a code section. */ -#define BEGIN_CODE .text -/** This macro is used to denote the end of a code section. */ -#define END_CODE -/** This macro is used to denote the beginning of a data section. */ -#define BEGIN_DATA -/** This macro is used to denote the end of a data section. */ -#define END_DATA -/** This macro is used to denote the beginning of the - * unitialized data section. - */ -#define BEGIN_BSS -/** This macro is used to denote the end of the unitialized data section. */ -#define END_BSS -/** This macro is used to denote the end of the assembly file. */ -#define END - -/** - * This macro is used to declare a public global symbol. - * - * @note This must be tailored for a particular flavor of the C compiler. - * They may need to put underscores in front of the symbols. - */ -#define PUBLIC(sym) .globl SYM (sym) - -/** - * This macro is used to prototype a public global symbol. - * - * @note This must be tailored for a particular flavor of the C compiler. - * They may need to put underscores in front of the symbols. - */ -#define EXTERN(sym) .globl SYM (sym) - -/**@}*/ -#endif diff --git a/cpukit/score/cpu/no_cpu/rtems/score/cpu.h b/cpukit/score/cpu/no_cpu/rtems/score/cpu.h deleted file mode 100644 index c16adc7327..0000000000 --- a/cpukit/score/cpu/no_cpu/rtems/score/cpu.h +++ /dev/null @@ -1,1501 +0,0 @@ -/** - * @file rtems/score/cpu.h - * - * @brief NO_CPU Department Source - * - * This include file contains information pertaining to the NO_CPU - * processor. - */ - -/* - * This include file contains information pertaining to the XXX - * processor. - * - * @note This file is part of a porting template that is intended - * to be used as the starting point when porting RTEMS to a new - * CPU family. The following needs to be done when using this as - * the starting point for a new port: - * - * + Anywhere there is an XXX, it should be replaced - * with information about the CPU family being ported to. - * - * + At the end of each comment section, there is a heading which - * says "Port Specific Information:". When porting to RTEMS, - * add CPU family specific information in this section - */ - -/* - * COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPU_H -#define _RTEMS_SCORE_CPU_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/* conditional compilation parameters */ - -/** - * Does RTEMS manage a dedicated interrupt stack in software? - * - * If TRUE, then a stack is allocated in @ref _ISR_Handler_initialization. - * If FALSE, nothing is done. - * - * If the CPU supports a dedicated interrupt stack in hardware, - * then it is generally the responsibility of the BSP to allocate it - * and set it up. - * - * If the CPU does not support a dedicated interrupt stack, then - * the porter has two options: (1) execute interrupts on the - * stack of the interrupted task, and (2) have RTEMS manage a dedicated - * interrupt stack. - * - * If this is TRUE, @ref CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. - * - * Only one of @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK and - * @ref CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is - * possible that both are FALSE for a particular CPU. Although it - * is unclear what that would imply about the interrupt processing - * procedure on that CPU. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_HAS_SOFTWARE_INTERRUPT_STACK FALSE - -/** - * Does the CPU follow the simple vectored interrupt model? - * - * If TRUE, then RTEMS allocates the vector table it internally manages. - * If FALSE, then the BSP is assumed to allocate and manage the vector - * table - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_SIMPLE_VECTORED_INTERRUPTS TRUE - -/** - * Does this CPU have hardware support for a dedicated interrupt stack? - * - * If TRUE, then it must be installed during initialization. - * If FALSE, then no installation is performed. - * - * If this is TRUE, @ref CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. - * - * Only one of @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK and - * @ref CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is - * possible that both are FALSE for a particular CPU. Although it - * is unclear what that would imply about the interrupt processing - * procedure on that CPU. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_HAS_HARDWARE_INTERRUPT_STACK TRUE - -/** - * Does RTEMS allocate a dedicated interrupt stack in the Interrupt Manager? - * - * If TRUE, then the memory is allocated during initialization. - * If FALSE, then the memory is allocated during initialization. - * - * This should be TRUE is CPU_HAS_SOFTWARE_INTERRUPT_STACK is TRUE. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_ALLOCATE_INTERRUPT_STACK TRUE - -/** - * Does the RTEMS invoke the user's ISR with the vector number and - * a pointer to the saved interrupt frame (1) or just the vector - * number (0)? - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_ISR_PASSES_FRAME_POINTER FALSE - -/** - * @def CPU_HARDWARE_FP - * - * Does the CPU have hardware floating point? - * - * If TRUE, then the RTEMS_FLOATING_POINT task attribute is supported. - * If FALSE, then the RTEMS_FLOATING_POINT task attribute is ignored. - * - * If there is a FP coprocessor such as the i387 or mc68881, then - * the answer is TRUE. - * - * The macro name "NO_CPU_HAS_FPU" should be made CPU specific. - * It indicates whether or not this CPU model has FP support. For - * example, it would be possible to have an i386_nofp CPU model - * which set this to false to indicate that you have an i386 without - * an i387 and wish to leave floating point support out of RTEMS. - */ - -/** - * @def CPU_SOFTWARE_FP - * - * Does the CPU have no hardware floating point and GCC provides a - * software floating point implementation which must be context - * switched? - * - * This feature conditional is used to indicate whether or not there - * is software implemented floating point that must be context - * switched. The determination of whether or not this applies - * is very tool specific and the state saved/restored is also - * compiler specific. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#if ( NO_CPU_HAS_FPU == 1 ) -#define CPU_HARDWARE_FP TRUE -#else -#define CPU_HARDWARE_FP FALSE -#endif -#define CPU_SOFTWARE_FP FALSE - -/** - * Are all tasks RTEMS_FLOATING_POINT tasks implicitly? - * - * If TRUE, then the RTEMS_FLOATING_POINT task attribute is assumed. - * If FALSE, then the RTEMS_FLOATING_POINT task attribute is followed. - * - * So far, the only CPUs in which this option has been used are the - * HP PA-RISC and PowerPC. On the PA-RISC, The HP C compiler and - * gcc both implicitly used the floating point registers to perform - * integer multiplies. Similarly, the PowerPC port of gcc has been - * seen to allocate floating point local variables and touch the FPU - * even when the flow through a subroutine (like vfprintf()) might - * not use floating point formats. - * - * If a function which you would not think utilize the FP unit DOES, - * then one can not easily predict which tasks will use the FP hardware. - * In this case, this option should be TRUE. - * - * If @ref CPU_HARDWARE_FP is FALSE, then this should be FALSE as well. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_ALL_TASKS_ARE_FP TRUE - -/** - * Should the IDLE task have a floating point context? - * - * If TRUE, then the IDLE task is created as a RTEMS_FLOATING_POINT task - * and it has a floating point context which is switched in and out. - * If FALSE, then the IDLE task does not have a floating point context. - * - * Setting this to TRUE negatively impacts the time required to preempt - * the IDLE task from an interrupt because the floating point context - * must be saved as part of the preemption. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_IDLE_TASK_IS_FP FALSE - -/** - * Should the saving of the floating point registers be deferred - * until a context switch is made to another different floating point - * task? - * - * If TRUE, then the floating point context will not be stored until - * necessary. It will remain in the floating point registers and not - * disturned until another floating point task is switched to. - * - * If FALSE, then the floating point context is saved when a floating - * point task is switched out and restored when the next floating point - * task is restored. The state of the floating point registers between - * those two operations is not specified. - * - * If the floating point context does NOT have to be saved as part of - * interrupt dispatching, then it should be safe to set this to TRUE. - * - * Setting this flag to TRUE results in using a different algorithm - * for deciding when to save and restore the floating point context. - * The deferred FP switch algorithm minimizes the number of times - * the FP context is saved and restored. The FP context is not saved - * until a context switch is made to another, different FP task. - * Thus in a system with only one FP task, the FP context will never - * be saved or restored. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_USE_DEFERRED_FP_SWITCH TRUE - -/** - * @brief Enables a robust thread dispatch if set to TRUE. - * - * In general, it is an application bug to call blocking operating system - * services with interrupts disabled. In most situations this only increases - * the interrupt latency. However, on SMP configurations or on some CPU port - * like ARM Cortex-M it leads to undefined system behaviour. It order to ease - * the application development, this error condition is checked at run-time in - * case this CPU port option is defined to TRUE. - */ -#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE - -/** - * Does this port provide a CPU dependent IDLE task implementation? - * - * If TRUE, then the routine @ref _CPU_Thread_Idle_body - * must be provided and is the default IDLE thread body instead of - * @ref _CPU_Thread_Idle_body. - * - * If FALSE, then use the generic IDLE thread body if the BSP does - * not provide one. - * - * This is intended to allow for supporting processors which have - * a low power or idle mode. When the IDLE thread is executed, then - * the CPU can be powered down. - * - * The order of precedence for selecting the IDLE thread body is: - * - * -# BSP provided - * -# CPU dependent (if provided) - * -# generic (if no BSP and no CPU dependent) - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_PROVIDES_IDLE_THREAD_BODY TRUE - -/** - * Does the stack grow up (toward higher addresses) or down - * (toward lower addresses)? - * - * If TRUE, then the grows upward. - * If FALSE, then the grows toward smaller addresses. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_STACK_GROWS_UP TRUE - -/** - * The maximum cache line size in bytes. - * - * The actual processor may use no cache or a smaller cache line size. - */ -#define CPU_CACHE_LINE_BYTES 32 - -/** - * The following is the variable attribute used to force alignment - * of critical RTEMS structures. On some processors it may make - * sense to have these aligned on tighter boundaries than - * the minimum requirements of the compiler in order to have as - * much of the critical data area as possible in a cache line. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES ) - -/** - * @ingroup CPUInterrupt - * - * The following defines the number of bits actually used in the - * interrupt field of the task mode. How those bits map to the - * CPU interrupt levels is defined by the routine @ref _CPU_ISR_Set_level. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_MODES_INTERRUPT_MASK 0x00000001 - -/** - * @brief Maximum number of processors of all systems supported by this CPU - * port. - */ -#define CPU_MAXIMUM_PROCESSORS 32 - -/* - * Processor defined structures required for cpukit/score. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ - -/* may need to put some structures here. */ - -/** - * @defgroup CPUContext Processor Dependent Context Management - * - * From the highest level viewpoint, there are 2 types of context to save. - * - * -# Interrupt registers to save - * -# Task level registers to save - * - * Since RTEMS handles integer and floating point contexts separately, this - * means we have the following 3 context items: - * - * -# task level context stuff:: Context_Control - * -# floating point task stuff:: Context_Control_fp - * -# special interrupt level context :: CPU_Interrupt_frame - * - * On some processors, it is cost-effective to save only the callee - * preserved registers during a task context switch. This means - * that the ISR code needs to save those registers which do not - * persist across function calls. It is not mandatory to make this - * distinctions between the caller/callee saves registers for the - * purpose of minimizing context saved during task switch and on interrupts. - * If the cost of saving extra registers is minimal, simplicity is the - * choice. Save the same context on interrupt entry as for tasks in - * this case. - * - * Additionally, if gdb is to be made aware of RTEMS tasks for this CPU, then - * care should be used in designing the context area. - * - * On some CPUs with hardware floating point support, the Context_Control_fp - * structure will not be used or it simply consist of an array of a - * fixed number of bytes. This is done when the floating point context - * is dumped by a "FP save context" type instruction and the format - * is not really defined by the CPU. In this case, there is no need - * to figure out the exact format -- only the size. Of course, although - * this is enough information for RTEMS, it is probably not enough for - * a debugger such as gdb. But that is another problem. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - * - */ -/**@{**/ - -/** - * @ingroup Management - * This defines the minimal set of integer and processor state registers - * that must be saved during a voluntary context switch from one thread - * to another. - */ -typedef struct { - /** - * This field is a hint that a port will have a number of integer - * registers that need to be saved at a context switch. - */ - uint32_t some_integer_register; - /** - * This field is a hint that a port will have a number of system - * registers that need to be saved at a context switch. - */ - uint32_t some_system_register; - - /** - * This field is a hint that a port will have a register that - * is the stack pointer. - */ - uint32_t stack_pointer; - -#ifdef RTEMS_SMP - /** - * @brief On SMP configurations the thread context must contain a boolean - * indicator to signal if this context is executing on a processor. - * - * This field must be updated during a context switch. The context switch - * to the heir must wait until the heir context indicates that it is no - * longer executing on a processor. This indicator must be updated using - * an atomic test and set operation to ensure that at most one processor - * uses the heir context at the same time. The context switch must also - * check for a potential new heir thread for this processor in case the - * heir context is not immediately available. Update the executing thread - * for this processor only if necessary to avoid a cache line - * monopolization. - * - * @code - * void _CPU_Context_switch( - * Context_Control *executing_context, - * Context_Control *heir_context - * ) - * { - * save( executing_context ); - * - * executing_context->is_executing = false; - * memory_barrier(); - * - * if ( test_and_set( &heir_context->is_executing ) ) { - * do { - * Per_CPU_Control *cpu_self = _Per_CPU_Get_snapshot(); - * Thread_Control *executing = cpu_self->executing; - * Thread_Control *heir = cpu_self->heir; - * - * if ( heir != executing ) { - * cpu_self->executing = heir; - * heir_context = (Context_Control *) - * ((uintptr_t) heir + (uintptr_t) executing_context - * - (uintptr_t) executing) - * } - * } while ( test_and_set( &heir_context->is_executing ) ); - * } - * - * restore( heir_context ); - * } - * @endcode - */ - volatile bool is_executing; -#endif -} Context_Control; - -/** - * @ingroup Management - * - * This macro returns the stack pointer associated with @a _context. - * - * @param[in] _context is the thread context area to access - * - * @return This method returns the stack pointer. - */ -#define _CPU_Context_Get_SP( _context ) \ - (_context)->stack_pointer - -/** - * @ingroup Management - * - * This defines the complete set of floating point registers that must - * be saved during any context switch from one thread to another. - */ -typedef struct { - /** FPU registers are listed here */ - double some_float_register; -} Context_Control_fp; - -/** - * @ingroup Management - * - * This defines the set of integer and processor state registers that must - * be saved during an interrupt. This set does not include any which are - * in @ref Context_Control. - */ -typedef struct { - /** - * This field is a hint that a port will have a number of integer - * registers that need to be saved when an interrupt occurs or - * when a context switch occurs at the end of an ISR. - */ - uint32_t special_interrupt_register; -} CPU_Interrupt_frame; - -/** - * This variable is optional. It is used on CPUs on which it is difficult - * to generate an "uninitialized" FP context. It is filled in by - * @ref _CPU_Initialize and copied into the task's FP context area during - * @ref _CPU_Context_Initialize. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -extern Context_Control_fp _CPU_Null_fp_context; - -/** @} */ - -/** - * @defgroup CPUInterrupt Processor Dependent Interrupt Management - * - * On some CPUs, RTEMS supports a software managed interrupt stack. - * This stack is allocated by the Interrupt Manager and the switch - * is performed in @ref _ISR_Handler. These variables contain pointers - * to the lowest and highest addresses in the chunk of memory allocated - * for the interrupt stack. Since it is unknown whether the stack - * grows up or down (in general), this give the CPU dependent - * code the option of picking the version it wants to use. - * - * NOTE: These two variables are required if the macro - * @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK is defined as TRUE. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ - -/* - * Nothing prevents the porter from declaring more CPU specific variables. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ - -/* XXX: if needed, put more variables here */ - -/** - * @ingroup CPUContext - * - * The size of the floating point context area. On some CPUs this - * will not be a "sizeof" because the format of the floating point - * area is not defined -- only the size is. This is usually on - * CPUs with a "floating point save context" instruction. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp ) - -/** - * Amount of extra stack (above minimum stack size) required by - * MPCI receive server thread. Remember that in a multiprocessor - * system this thread must exist and be able to process all directives. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0 - -/** - * @ingroup CPUInterrupt - * - * This defines the number of entries in the _ISR_Vector_table managed by RTEMS - * in case CPU_SIMPLE_VECTORED_INTERRUPTS is defined to TRUE. It must be a - * compile-time constant. - * - * It must be undefined in case CPU_SIMPLE_VECTORED_INTERRUPTS is defined to - * FALSE. - */ -#define CPU_INTERRUPT_NUMBER_OF_VECTORS 32 - -/** - * @ingroup CPUInterrupt - * - * This defines the highest interrupt vector number for this port in case - * CPU_SIMPLE_VECTORED_INTERRUPTS is defined to TRUE. It must be less than - * CPU_INTERRUPT_NUMBER_OF_VECTORS. It may be not a compile-time constant. - * - * It must be undefined in case CPU_SIMPLE_VECTORED_INTERRUPTS is defined to - * FALSE. - */ -#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER (CPU_INTERRUPT_NUMBER_OF_VECTORS - 1) - -/** - * @ingroup CPUInterrupt - * - * This is defined if the port has a special way to report the ISR nesting - * level. Most ports maintain the variable @a _ISR_Nest_level. - */ -#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE - -/** - * @ingroup CPUContext - * - * Should be large enough to run all RTEMS tests. This ensures - * that a "reasonable" small application should not have any problems. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_STACK_MINIMUM_SIZE (1024*4) - -/** - * Size of a pointer. - * - * This must be an integer literal that can be used by the assembler. This - * value will be used to calculate offsets of structure members. These - * offsets will be used in assembler code. - */ -#define CPU_SIZEOF_POINTER 4 - -/** - * CPU's worst alignment requirement for data types on a byte boundary. This - * alignment does not take into account the requirements for the stack. It - * must be a power of two greater than or equal to two. The power of two - * requirement makes it possible to align values easily using simple bit - * operations. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_ALIGNMENT 8 - -/** - * This number corresponds to the byte alignment requirement for the - * heap handler. This alignment requirement may be stricter than that - * for the data types alignment specified by @ref CPU_ALIGNMENT. It is - * common for the heap to follow the same alignment requirement as - * @ref CPU_ALIGNMENT. If the @ref CPU_ALIGNMENT is strict enough for - * the heap, then this should be set to @ref CPU_ALIGNMENT. - * - * NOTE: It must be a power of two greater than or equal to two. The - * requirement to be a multiple of two is because the heap uses the - * least significant field of the front and back flags to indicate that - * a block is in use or free. So you do not want any odd length blocks - * really putting length data in that bit. - * - * On byte oriented architectures, @ref CPU_HEAP_ALIGNMENT normally will - * have to be greater or equal to than @ref CPU_ALIGNMENT to ensure that - * elements allocated from the heap meet all restrictions. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT - -/** - * This number corresponds to the byte alignment requirement for memory - * buffers allocated by the partition manager. This alignment requirement - * may be stricter than that for the data types alignment specified by - * @ref CPU_ALIGNMENT. It is common for the partition to follow the same - * alignment requirement as @ref CPU_ALIGNMENT. If the @ref CPU_ALIGNMENT is - * strict enough for the partition, then this should be set to - * @ref CPU_ALIGNMENT. - * - * NOTE: This does not have to be a power of 2. It does have to - * be greater or equal to than @ref CPU_ALIGNMENT. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT - -/** - * This number corresponds to the byte alignment requirement for the - * stack. This alignment requirement may be stricter than that for the - * data types alignment specified by @ref CPU_ALIGNMENT. If the - * @ref CPU_ALIGNMENT is strict enough for the stack, then this should be - * set to 0. - * - * NOTE: This must be a power of 2 either 0 or greater than @ref CPU_ALIGNMENT. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_STACK_ALIGNMENT 0 - -/* - * ISR handler macros - */ - -/** - * @ingroup CPUInterrupt - * - * Support routine to initialize the RTEMS vector table after it is allocated. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_Initialize_vectors() - -/** - * @ingroup CPUInterrupt - * - * Disable all interrupts for an RTEMS critical section. The previous - * level is returned in @a _isr_cookie. - * - * @param[out] _isr_cookie will contain the previous level cookie - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_ISR_Disable( _isr_cookie ) \ - { \ - (_isr_cookie) = 0; /* do something to prevent warnings */ \ - } - -/** - * @ingroup CPUInterrupt - * - * Enable interrupts to the previous level (returned by _CPU_ISR_Disable). - * This indicates the end of an RTEMS critical section. The parameter - * @a _isr_cookie is not modified. - * - * @param[in] _isr_cookie contain the previous level cookie - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_ISR_Enable( _isr_cookie ) \ - { \ - } - -/** - * @ingroup CPUInterrupt - * - * This temporarily restores the interrupt to @a _isr_cookie before immediately - * disabling them again. This is used to divide long RTEMS critical - * sections into two or more parts. The parameter @a _isr_cookie is not - * modified. - * - * @param[in] _isr_cookie contain the previous level cookie - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_ISR_Flash( _isr_cookie ) \ - { \ - } - -/** - * @brief Returns true if interrupts are enabled in the specified ISR level, - * otherwise returns false. - * - * @param[in] level The ISR level. - * - * @retval true Interrupts are enabled in the ISR level. - * @retval false Otherwise. - */ -RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) -{ - return false; -} - -/** - * @ingroup CPUInterrupt - * - * This routine and @ref _CPU_ISR_Get_level - * Map the interrupt level in task mode onto the hardware that the CPU - * actually provides. Currently, interrupt levels which do not - * map onto the CPU in a generic fashion are undefined. Someday, - * it would be nice if these were "mapped" by the application - * via a callout. For example, m68k has 8 levels 0 - 7, levels - * 8 - 255 would be available for bsp/application specific meaning. - * This could be used to manage a programmable interrupt controller - * via the rtems_task_mode directive. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_ISR_Set_level( new_level ) \ - { \ - } - -/** - * @ingroup CPUInterrupt - * - * Return the current interrupt disable level for this task in - * the format used by the interrupt level portion of the task mode. - * - * NOTE: This routine usually must be implemented as a subroutine. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -uint32_t _CPU_ISR_Get_level( void ); - -/* end of ISR handler macros */ - -/* Context handler macros */ - -/** - * @ingroup CPUContext - * - * @brief Destroys the context of the thread. - * - * It must be implemented as a macro and an implementation is optional. The - * default implementation does nothing. - * - * @param[in] _the_thread The corresponding thread. - * @param[in] _the_context The context to destroy. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_Context_Destroy( _the_thread, _the_context ) \ - { \ - } - -/** - * @ingroup CPUContext - * - * Initialize the context to a state suitable for starting a - * task after a context restore operation. Generally, this - * involves: - * - * - setting a starting address - * - preparing the stack - * - preparing the stack and frame pointers - * - setting the proper interrupt level in the context - * - initializing the floating point context - * - * This routine generally does not set any unnecessary register - * in the context. The state of the "general data" registers is - * undefined at task start time. - * - * The ISR dispatch disable field of the context must be cleared to zero if it - * is used by the CPU port. Otherwise, a thread restart results in - * unpredictable behaviour. - * - * @param[in] _the_context is the context structure to be initialized - * @param[in] _stack_base is the lowest physical address of this task's stack - * @param[in] _size is the size of this task's stack - * @param[in] _isr is the interrupt disable level - * @param[in] _entry_point is the thread's entry point. This is - * always @a _Thread_Handler - * @param[in] _is_fp is TRUE if the thread is to be a floating - * point thread. This is typically only used on CPUs where the - * FPU may be easily disabled by software such as on the SPARC - * where the PSR contains an enable FPU bit. - * @param[in] _tls_area The thread-local storage (TLS) area. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_Context_Initialize( _the_context, _stack_base, _size, \ - _isr, _entry_point, _is_fp, _tls_area ) \ - { \ - } - -/** - * This routine is responsible for somehow restarting the currently - * executing task. If you are lucky, then all that is necessary - * is restoring the context. Otherwise, there will need to be - * a special assembly routine which does something special in this - * case. For many ports, simply adding a label to the restore path - * of @ref _CPU_Context_switch will work. On other ports, it may be - * possibly to load a few arguments and jump to the restore path. It will - * not work if restarting self conflicts with the stack frame - * assumptions of restoring a context. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_Context_Restart_self( _the_context ) \ - _CPU_Context_restore( (_the_context) ); - -/** - * This routine initializes the FP context area passed to it to. - * There are a few standard ways in which to initialize the - * floating point context. The code included for this macro assumes - * that this is a CPU in which a "initial" FP context was saved into - * @a _CPU_Null_fp_context and it simply copies it to the destination - * context passed to it. - * - * Other floating point context save/restore models include: - * -# not doing anything, and - * -# putting a "null FP status word" in the correct place in the FP context. - * - * @param[in] _destination is the floating point context area - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_Context_Initialize_fp( _destination ) \ - { \ - *(*(_destination)) = _CPU_Null_fp_context; \ - } - -/* end of Context handler macros */ - -/* Fatal Error manager macros */ - -/** - * This routine copies _error into a known place -- typically a stack - * location or a register, optionally disables interrupts, and - * halts/stops the CPU. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_Fatal_halt( _source, _error ) \ - { \ - } - -/* end of Fatal Error manager macros */ - -/* Bitfield handler macros */ - -/** - * @defgroup CPUBitfield Processor Dependent Bitfield Manipulation - * - * This set of routines are used to implement fast searches for - * the most important ready task. - * - */ -/**@{**/ - -/** - * This definition is set to TRUE if the port uses the generic bitfield - * manipulation implementation. - */ -#define CPU_USE_GENERIC_BITFIELD_CODE TRUE - -/** - * This routine sets @a _output to the bit number of the first bit - * set in @a _value. @a _value is of CPU dependent type - * @a Priority_bit_map_Word. This type may be either 16 or 32 bits - * wide although only the 16 least significant bits will be used. - * - * There are a number of variables in using a "find first bit" type - * instruction. - * - * -# What happens when run on a value of zero? - * -# Bits may be numbered from MSB to LSB or vice-versa. - * -# The numbering may be zero or one based. - * -# The "find first bit" instruction may search from MSB or LSB. - * - * RTEMS guarantees that (1) will never happen so it is not a concern. - * (2),(3), (4) are handled by the macros @ref _CPU_Priority_Mask and - * @ref _CPU_Priority_bits_index. These three form a set of routines - * which must logically operate together. Bits in the _value are - * set and cleared based on masks built by @ref _CPU_Priority_Mask. - * The basic major and minor values calculated by @ref _Priority_Major - * and @ref _Priority_Minor are "massaged" by @ref _CPU_Priority_bits_index - * to properly range between the values returned by the "find first bit" - * instruction. This makes it possible for @ref _Priority_Get_highest to - * calculate the major and directly index into the minor table. - * This mapping is necessary to ensure that 0 (a high priority major/minor) - * is the first bit found. - * - * This entire "find first bit" and mapping process depends heavily - * on the manner in which a priority is broken into a major and minor - * components with the major being the 4 MSB of a priority and minor - * the 4 LSB. Thus (0 << 4) + 0 corresponds to priority 0 -- the highest - * priority. And (15 << 4) + 14 corresponds to priority 254 -- the next - * to the lowest priority. - * - * If your CPU does not have a "find first bit" instruction, then - * there are ways to make do without it. Here are a handful of ways - * to implement this in software: - * -@verbatim - - a series of 16 bit test instructions - - a "binary search using if's" - - _number = 0 - if _value > 0x00ff - _value >>=8 - _number = 8; - - if _value > 0x0000f - _value >=8 - _number += 4 - - _number += bit_set_table[ _value ] -@endverbatim - - * where bit_set_table[ 16 ] has values which indicate the first - * bit set - * - * @param[in] _value is the value to be scanned - * @param[in] _output is the first bit set - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ - -#if (CPU_USE_GENERIC_BITFIELD_CODE == FALSE) -#define _CPU_Bitfield_Find_first_bit( _value, _output ) \ - { \ - (_output) = 0; /* do something to prevent warnings */ \ - } -#endif - -/** @} */ - -/* end of Bitfield handler macros */ - -/** - * This routine builds the mask which corresponds to the bit fields - * as searched by @ref _CPU_Bitfield_Find_first_bit. See the discussion - * for that routine. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#if (CPU_USE_GENERIC_BITFIELD_CODE == FALSE) - -#define _CPU_Priority_Mask( _bit_number ) \ - ( 1 << (_bit_number) ) - -#endif - -/** - * @ingroup CPUBitfield - * - * This routine translates the bit numbers returned by - * @ref _CPU_Bitfield_Find_first_bit into something suitable for use as - * a major or minor component of a priority. See the discussion - * for that routine. - * - * @param[in] _priority is the major or minor number to translate - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#if (CPU_USE_GENERIC_BITFIELD_CODE == FALSE) - -#define _CPU_Priority_bits_index( _priority ) \ - (_priority) - -#endif - -/* end of Priority handler macros */ - -/* functions */ - -/** - * This routine performs CPU dependent initialization. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_Initialize(void); - -/** - * @ingroup CPUInterrupt - * - * This routine installs a "raw" interrupt handler directly into the - * processor's vector table. - * - * @param[in] vector is the vector number - * @param[in] new_handler is the raw ISR handler to install - * @param[in] old_handler is the previously installed ISR Handler - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_ISR_install_raw_handler( - uint32_t vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -/** - * @ingroup CPUInterrupt - * - * This routine installs an interrupt vector. - * - * @param[in] vector is the vector number - * @param[in] new_handler is the RTEMS ISR handler to install - * @param[in] old_handler is the previously installed ISR Handler - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_ISR_install_vector( - uint32_t vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -/** - * @ingroup CPUInterrupt - * This routine installs the hardware interrupt stack pointer. - * - * NOTE: It need only be provided if @ref CPU_HAS_HARDWARE_INTERRUPT_STACK - * is TRUE. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_Install_interrupt_stack( void ); - -/** - * This routine is the CPU dependent IDLE thread body. - * - * NOTE: It need only be provided if @ref CPU_PROVIDES_IDLE_THREAD_BODY - * is TRUE. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void *_CPU_Thread_Idle_body( uintptr_t ignored ); - -/** - * @ingroup CPUContext - * - * This routine switches from the run context to the heir context. - * - * @param[in] run points to the context of the currently executing task - * @param[in] heir points to the context of the heir task - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_Context_switch( - Context_Control *run, - Context_Control *heir -); - -/** - * @ingroup CPUContext - * - * This routine is generally used only to restart self in an - * efficient manner. It may simply be a label in @ref _CPU_Context_switch. - * - * @param[in] new_context points to the context to be restored. - * - * NOTE: May be unnecessary to reload some registers. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_Context_restore( - Context_Control *new_context -) RTEMS_NO_RETURN; - -/** - * @ingroup CPUContext - * - * This routine saves the floating point context passed to it. - * - * @param[in] fp_context_ptr is a pointer to a pointer to a floating - * point context area - * - * @return on output @a *fp_context_ptr will contain the address that - * should be used with @ref _CPU_Context_restore_fp to restore this context. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_Context_save_fp( - Context_Control_fp **fp_context_ptr -); - -/** - * @ingroup CPUContext - * - * This routine restores the floating point context passed to it. - * - * @param[in] fp_context_ptr is a pointer to a pointer to a floating - * point context area to restore - * - * @return on output @a *fp_context_ptr will contain the address that - * should be used with @ref _CPU_Context_save_fp to save this context. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_Context_restore_fp( - Context_Control_fp **fp_context_ptr -); - -/** - * @ingroup CPUContext - * - * @brief Clobbers all volatile registers with values derived from the pattern - * parameter. - * - * This function is used only in test sptests/spcontext01. - * - * @param[in] pattern Pattern used to generate distinct register values. - * - * @see _CPU_Context_validate(). - */ -void _CPU_Context_volatile_clobber( uintptr_t pattern ); - -/** - * @ingroup CPUContext - * - * @brief Initializes and validates the CPU context with values derived from - * the pattern parameter. - * - * This function will not return if the CPU context remains consistent. In - * case this function returns the CPU port is broken. - * - * This function is used only in test sptests/spcontext01. - * - * @param[in] pattern Pattern used to generate distinct register values. - * - * @see _CPU_Context_volatile_clobber(). - */ -void _CPU_Context_validate( uintptr_t pattern ); - -/** - * @brief The set of registers that specifies the complete processor state. - * - * The CPU exception frame may be available in fatal error conditions like for - * example illegal opcodes, instruction fetch errors, or data access errors. - * - * @see rtems_fatal(), RTEMS_FATAL_SOURCE_EXCEPTION, and - * rtems_exception_frame_print(). - */ -typedef struct { - uint32_t processor_state_register; - uint32_t integer_registers [1]; - double float_registers [1]; -} CPU_Exception_frame; - -/** - * @brief Prints the exception frame via printk(). - * - * @see rtems_fatal() and RTEMS_FATAL_SOURCE_EXCEPTION. - */ -void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); - -/** - * @ingroup CPUEndian - * - * The following routine swaps the endian format of an unsigned int. - * It must be static because it is referenced indirectly. - * - * This version will work on any processor, but if there is a better - * way for your CPU PLEASE use it. The most common way to do this is to: - * - * swap least significant two bytes with 16-bit rotate - * swap upper and lower 16-bits - * swap most significant two bytes with 16-bit rotate - * - * Some CPUs have special instructions which swap a 32-bit quantity in - * a single instruction (e.g. i486). It is probably best to avoid - * an "endian swapping control bit" in the CPU. One good reason is - * that interrupts would probably have to be disabled to ensure that - * an interrupt does not try to access the same "chunk" with the wrong - * endian. Another good reason is that on some CPUs, the endian bit - * endianness for ALL fetches -- both code and data -- so the code - * will be fetched incorrectly. - * - * @param[in] value is the value to be swapped - * @return the value after being endian swapped - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -static inline uint32_t CPU_swap_u32( - uint32_t value -) -{ - uint32_t byte1, byte2, byte3, byte4, swapped; - - byte4 = (value >> 24) & 0xff; - byte3 = (value >> 16) & 0xff; - byte2 = (value >> 8) & 0xff; - byte1 = value & 0xff; - - swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4; - return swapped; -} - -/** - * @ingroup CPUEndian - * - * This routine swaps a 16 bir quantity. - * - * @param[in] value is the value to be swapped - * @return the value after being endian swapped - */ -#define CPU_swap_u16( value ) \ - (((value&0xff) << 8) | ((value >> 8)&0xff)) - -/** - * @brief Unsigned integer type for CPU counter values. - */ -typedef uint32_t CPU_Counter_ticks; - -/** - * @brief Returns the current CPU counter value. - * - * A CPU counter is some free-running counter. It ticks usually with a - * frequency close to the CPU or system bus clock. The board support package - * must ensure that this function works before the RTEMS initialization. - * Otherwise invalid profiling statistics will be gathered. - * - * @return The current CPU counter value. - */ -CPU_Counter_ticks _CPU_Counter_read( void ); - -/** - * @brief Returns the difference between the second and first CPU counter - * value. - * - * This operation may be carried out as a modulo operation depending on the - * range of the CPU counter device. - * - * @param[in] second The second CPU counter value. - * @param[in] first The first CPU counter value. - * - * @return Returns second minus first modulo counter period. - */ -CPU_Counter_ticks _CPU_Counter_difference( - CPU_Counter_ticks second, - CPU_Counter_ticks first -); - -#ifdef RTEMS_SMP - /** - * @brief Performs CPU specific SMP initialization in the context of the boot - * processor. - * - * This function is invoked on the boot processor during system - * initialization. All interrupt stacks are allocated at this point in case - * the CPU port allocates the interrupt stacks. This function is called - * before _CPU_SMP_Start_processor() or _CPU_SMP_Finalize_initialization() is - * used. - * - * @return The count of physically or virtually available processors. - * Depending on the configuration the application may use not all processors. - */ - uint32_t _CPU_SMP_Initialize( void ); - - /** - * @brief Starts a processor specified by its index. - * - * This function is invoked on the boot processor during system - * initialization. - * - * This function will be called after _CPU_SMP_Initialize(). - * - * @param[in] cpu_index The processor index. - * - * @retval true Successful operation. - * @retval false Unable to start this processor. - */ - bool _CPU_SMP_Start_processor( uint32_t cpu_index ); - - /** - * @brief Performs final steps of CPU specific SMP initialization in the - * context of the boot processor. - * - * This function is invoked on the boot processor during system - * initialization. - * - * This function will be called after all processors requested by the - * application have been started. - * - * @param[in] cpu_count The minimum value of the count of processors - * requested by the application configuration and the count of physically or - * virtually available processors. - */ - void _CPU_SMP_Finalize_initialization( uint32_t cpu_count ); - - /** - * @brief Prepares a CPU to start multitasking in terms of SMP. - * - * This function is invoked on all processors requested by the application - * during system initialization. - * - * This function will be called after all processors requested by the - * application have been started right before the context switch to the first - * thread takes place. - */ - void _CPU_SMP_Prepare_start_multitasking( void ); - - /** - * @brief Returns the index of the current processor. - * - * An architecture specific method must be used to obtain the index of the - * current processor in the system. The set of processor indices is the - * range of integers starting with zero up to the processor count minus one. - */ - static inline uint32_t _CPU_SMP_Get_current_processor( void ) - { - return 123; - } - - /** - * @brief Sends an inter-processor interrupt to the specified target - * processor. - * - * This operation is undefined for target processor indices out of range. - * - * @param[in] target_processor_index The target processor index. - */ - void _CPU_SMP_Send_interrupt( uint32_t target_processor_index ); - - /** - * @brief Broadcasts a processor event. - * - * Some architectures provide a low-level synchronization primitive for - * processors in a multi-processor environment. Processors waiting for this - * event may go into a low-power state and stop generating system bus - * transactions. This function must ensure that preceding store operations - * can be observed by other processors. - * - * @see _CPU_SMP_Processor_event_receive(). - */ - static inline void _CPU_SMP_Processor_event_broadcast( void ) - { - __asm__ volatile ( "" : : : "memory" ); - } - - /** - * @brief Receives a processor event. - * - * This function will wait for the processor event and may wait forever if no - * such event arrives. - * - * @see _CPU_SMP_Processor_event_broadcast(). - */ - static inline void _CPU_SMP_Processor_event_receive( void ) - { - __asm__ volatile ( "" : : : "memory" ); - } - - /** - * @brief Gets the is executing indicator of the thread context. - * - * @param[in] context The context. - */ - static inline bool _CPU_Context_Get_is_executing( - const Context_Control *context - ) - { - return context->is_executing; - } - - /** - * @brief Sets the is executing indicator of the thread context. - * - * @param[in] context The context. - * @param[in] is_executing The new value for the is executing indicator. - */ - static inline void _CPU_Context_Set_is_executing( - Context_Control *context, - bool is_executing - ) - { - context->is_executing = is_executing; - } -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/score/cpu/no_cpu/rtems/score/cpu_asm.h b/cpukit/score/cpu/no_cpu/rtems/score/cpu_asm.h deleted file mode 100644 index 747fd3a1c1..0000000000 --- a/cpukit/score/cpu/no_cpu/rtems/score/cpu_asm.h +++ /dev/null @@ -1,74 +0,0 @@ -/** - * @file - * - * @brief No-CPU Assembly File - * - * Very loose template for an include file for the cpu_asm.? file - * if it is implemented as a ".S" file (preprocessed by cpp) instead - * of a ".s" file (preprocessed by gm4 or gasp). - */ - -/* - * - * - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - * - */ - -#ifndef _RTEMS_SCORE_CPU_ASM_H -#define _RTEMS_SCORE_CPU_ASM_H - -/* pull in the generated offsets */ - -#include - -/* - * Hardware General Registers - */ - -/* put something here */ - -/* - * Hardware Floating Point Registers - */ - -/* put something here */ - -/* - * Hardware Control Registers - */ - -/* put something here */ - -/* - * Calling Convention - */ - -/* put something here */ - -/* - * Temporary registers - */ - -/* put something here */ - -/* - * Floating Point Registers - SW Conventions - */ - -/* put something here */ - -/* - * Temporary floating point registers - */ - -/* put something here */ - -#endif - -/* end of file */ diff --git a/cpukit/score/cpu/no_cpu/rtems/score/cpuimpl.h b/cpukit/score/cpu/no_cpu/rtems/score/cpuimpl.h deleted file mode 100644 index 85214d7f6c..0000000000 --- a/cpukit/score/cpu/no_cpu/rtems/score/cpuimpl.h +++ /dev/null @@ -1,82 +0,0 @@ -/** - * @file - * - * @brief CPU Port Implementation API - */ - -/* - * Copyright (c) 2013, 2016 embedded brains GmbH - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPUIMPL_H -#define _RTEMS_SCORE_CPUIMPL_H - -#include - -/** - * @brief The size of the CPU specific per-CPU control. - * - * This define must be visible to assember files since it is used to derive - * structure offsets. - */ -#define CPU_PER_CPU_CONTROL_SIZE 0 - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief The CPU specific per-CPU control. - * - * The CPU port can place here all state information that must be available and - * maintained for each processor in the system. This structure must contain at - * least one field for C/C++ compatibility. In GNU C empty structures have a - * size of zero. In C++ structures have a non-zero size. In case - * CPU_PER_CPU_CONTROL_SIZE is defined to zero, then this structure is not - * used. - */ -typedef struct { - /* CPU specific per-CPU state */ -} CPU_Per_CPU_control; - -/** - * @brief Special register pointing to the per-CPU control of the current - * processor. - * - * This is optional. Not every CPU port needs this. It is only an optional - * optimization variant. - */ -register struct Per_CPU_Control *_CPU_Per_CPU_current asm( "rX" ); - -/** - * @brief Optional method to obtain the per-CPU control of the current processor. - * - * This is optional. Not every CPU port needs this. It is only an optional - * optimization variant. In case this macro is undefined, the default - * implementation using the current processor index will be used. - */ -#define _CPU_Get_current_per_CPU_control() ( _CPU_Per_CPU_current ) - -/** - * @brief Optional method to get the executing thread. - * - * This is optional. Not every CPU port needs this. It is only an optional - * optimization variant. In case this macro is undefined, the default - * implementation uses the per-CPU information and the current processor index - * to get the executing thread. - */ -#define _CPU_Get_thread_executing() ( _CPU_Per_CPU_current->executing ) - -#ifdef __cplusplus -} -#endif - -#endif /* ASM */ - -#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/no_cpu/rtems/score/no_cpu.h b/cpukit/score/cpu/no_cpu/rtems/score/no_cpu.h deleted file mode 100644 index d1bbceccc0..0000000000 --- a/cpukit/score/cpu/no_cpu/rtems/score/no_cpu.h +++ /dev/null @@ -1,67 +0,0 @@ -/* no_cpu.h - * - * This file sets up basic CPU dependency settings based on - * compiler settings. For example, it can determine if - * floating point is available. This particular implementation - * is specified to the NO CPU port. - * - * - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - * - */ - -#ifndef _RTEMS_SCORE_NO_CPU_H -#define _RTEMS_SCORE_NO_CPU_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This file contains the information required to build - * RTEMS for a particular member of the NO CPU family. - * It does this by setting variables to indicate which - * implementation dependent features are present in a particular - * member of the family. - * - * This is a good place to list all the known CPU models - * that this port supports and which RTEMS CPU model they correspond - * to. - */ - -#if defined(rtems_multilib) -/* - * Figure out all CPU Model Feature Flags based upon compiler - * predefines. - */ - -#define CPU_MODEL_NAME "rtems_multilib" -#define NOCPU_HAS_FPU 1 - -#elif defined(no_cpu) - -#define CPU_MODEL_NAME "no_cpu_model" -#define NOCPU_HAS_FPU 1 - -#else - -#error "Unsupported CPU Model" - -#endif - -/* - * Define the name of the CPU family. - */ - -#define CPU_NAME "NO CPU" - -#ifdef __cplusplus -} -#endif - -#endif /* _RTEMS_SCORE_NO_CPU_H */ diff --git a/cpukit/score/cpu/no_cpu/rtems/score/types.h b/cpukit/score/cpu/no_cpu/rtems/score/types.h deleted file mode 100644 index b330c33904..0000000000 --- a/cpukit/score/cpu/no_cpu/rtems/score/types.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file - * - * @brief No-CPU Type Definitions - * - * This include file contains type definitions pertaining to the Intel - * no_cpu processor family. - */ - -/* - * COPYRIGHT (c) 1989-2006. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_TYPES_H -#define _RTEMS_SCORE_TYPES_H - -#include - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This section defines the basic types for this processor. - */ - -/** Type that can store a 32-bit integer or a pointer. */ -typedef uintptr_t CPU_Uint32ptr; - -#ifdef __cplusplus -} -#endif - -#endif /* !ASM */ - -#endif diff --git a/cpukit/score/cpu/or1k/Makefile.am b/cpukit/score/cpu/or1k/Makefile.am index c9f28595f8..e4c5b7cdd2 100644 --- a/cpukit/score/cpu/or1k/Makefile.am +++ b/cpukit/score/cpu/or1k/Makefile.am @@ -3,21 +3,6 @@ include $(top_srcdir)/automake/compile.am CLEANFILES = DISTCLEANFILES = -include_rtemsdir = $(includedir)/rtems - -include_rtems_HEADERS = rtems/asm.h - -include_rtems_scoredir = $(includedir)/rtems/score - -include_rtems_score_HEADERS = -include_rtems_score_HEADERS += rtems/score/cpu.h -include_rtems_score_HEADERS += rtems/score/cpuimpl.h -include_rtems_score_HEADERS += rtems/score/cpuatomic.h -include_rtems_score_HEADERS += rtems/score/cpu_asm.h -include_rtems_score_HEADERS += rtems/score/types.h -include_rtems_score_HEADERS += rtems/score/or1k.h -include_rtems_score_HEADERS += rtems/score/or1k-utility.h - noinst_LIBRARIES = libscorecpu.a libscorecpu_a_SOURCES = @@ -34,5 +19,5 @@ libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS) all-local: $(PREINSTALL_FILES) -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am +include $(srcdir)/headers.am diff --git a/cpukit/score/cpu/or1k/headers.am b/cpukit/score/cpu/or1k/headers.am new file mode 100644 index 0000000000..1ddc654793 --- /dev/null +++ b/cpukit/score/cpu/or1k/headers.am @@ -0,0 +1,15 @@ +## This file was generated by "./boostrap -H". + +include_rtemsdir = $(includedir)/rtems +include_rtems_HEADERS = +include_rtems_HEADERS += include/rtems/asm.h + +include_rtems_scoredir = $(includedir)/rtems/score +include_rtems_score_HEADERS = +include_rtems_score_HEADERS += include/rtems/score/cpu.h +include_rtems_score_HEADERS += include/rtems/score/cpu_asm.h +include_rtems_score_HEADERS += include/rtems/score/cpuatomic.h +include_rtems_score_HEADERS += include/rtems/score/cpuimpl.h +include_rtems_score_HEADERS += include/rtems/score/or1k-utility.h +include_rtems_score_HEADERS += include/rtems/score/or1k.h +include_rtems_score_HEADERS += include/rtems/score/types.h diff --git a/cpukit/score/cpu/or1k/include/rtems/asm.h b/cpukit/score/cpu/or1k/include/rtems/asm.h new file mode 100644 index 0000000000..4d2c22698b --- /dev/null +++ b/cpukit/score/cpu/or1k/include/rtems/asm.h @@ -0,0 +1,99 @@ +/** + * @file rtems/asm.h + * + * This include file attempts to address the problems + * caused by incompatible flavors of assemblers and + * toolsets. It primarily addresses variations in the + * use of leading underscores on symbols and the requirement + * that register names be preceded by a %. + */ + +/* + * NOTE: The spacing in the use of these macros + * is critical to them working as advertised. + * + * COPYRIGHT: + * + * This file is based on similar code found in newlib available + * from ftp.cygnus.com. The file which was used had no copyright + * notice. This file is freely distributable as long as the source + * of the file is noted. This file is: + * + * COPYRIGHT (c) 1994-1997. + * On-Line Applications Research Corporation (OAR). + * + */ + +#ifndef __OR1K_ASM_h +#define __OR1K_ASM_h + +/* + * Indicate we are in an assembly file and get the basic CPU definitions. + */ + +#ifndef ASM +#define ASM +#endif +#include +#include + +/* + * Recent versions of GNU cpp define variables which indicate the + * need for underscores and percents. If not using GNU cpp or + * the version does not support this, then you will obviously + * have to define these as appropriate. + */ + +#ifndef __USER_LABEL_PREFIX__ +#define __USER_LABEL_PREFIX__ _ +#endif + +#ifndef __REGISTER_PREFIX__ +#define __REGISTER_PREFIX__ +#endif + +/* ANSI concatenation macros. */ + +#define CONCAT1(a, b) CONCAT2(a, b) +#define CONCAT2(a, b) a ## b + +/* Use the right prefix for global labels. */ + +#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) + +/* Use the right prefix for registers. */ + +#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) + +/* + * define macros for all of the registers on this CPU + * + * EXAMPLE: #define d0 REG (d0) + */ + +/* + * Define macros to handle section beginning and ends. + */ + + +#define BEGIN_CODE_DCL .text +#define END_CODE_DCL +#define BEGIN_DATA_DCL .data +#define END_DATA_DCL +#define BEGIN_CODE .text +#define END_CODE +#define BEGIN_DATA +#define END_DATA +#define BEGIN_BSS +#define END_BSS +#define END + +/* + * Following must be tailor for a particular flavor of the C compiler. + * They may need to put underscores in front of the symbols. + */ + +#define PUBLIC(sym) .global SYM (sym) +#define EXTERN(sym) .global SYM (sym) + +#endif diff --git a/cpukit/score/cpu/or1k/include/rtems/score/cpu.h b/cpukit/score/cpu/or1k/include/rtems/score/cpu.h new file mode 100644 index 0000000000..6daca10f9c --- /dev/null +++ b/cpukit/score/cpu/or1k/include/rtems/score/cpu.h @@ -0,0 +1,872 @@ +/** + * @file rtems/score/cpu.h + */ + +/* + * This include file contains macros pertaining to the Opencores + * or1k processor family. + * + * COPYRIGHT (c) 2014 Hesham ALMatary + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + * This file adapted from no_cpu example of the RTEMS distribution. + * The body has been modified for the Opencores OR1k implementation by + * Chris Ziomkowski. + * + */ + +#ifndef _OR1K_CPU_H +#define _OR1K_CPU_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#include /* pick up machine definitions */ +#include +#include +#ifndef ASM +#include +#include +#include /* for printk */ +#endif + +/* conditional compilation parameters */ + +/* + * Does RTEMS manage a dedicated interrupt stack in software? + * + * If TRUE, then a stack is allocated in _ISR_Handler_initialization. + * If FALSE, nothing is done. + * + * If the CPU supports a dedicated interrupt stack in hardware, + * then it is generally the responsibility of the BSP to allocate it + * and set it up. + * + * If the CPU does not support a dedicated interrupt stack, then + * the porter has two options: (1) execute interrupts on the + * stack of the interrupted task, and (2) have RTEMS manage a dedicated + * interrupt stack. + * + * If this is TRUE, CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. + * + * Only one of CPU_HAS_SOFTWARE_INTERRUPT_STACK and + * CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is + * possible that both are FALSE for a particular CPU. Although it + * is unclear what that would imply about the interrupt processing + * procedure on that CPU. + * + * Currently, for or1k port, _ISR_Handler is responsible for switching to + * RTEMS dedicated interrupt task. + * + */ + +#define CPU_HAS_SOFTWARE_INTERRUPT_STACK TRUE + +/* + * Does this CPU have hardware support for a dedicated interrupt stack? + * + * If TRUE, then it must be installed during initialization. + * If FALSE, then no installation is performed. + * + * If this is TRUE, CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. + * + * Only one of CPU_HAS_SOFTWARE_INTERRUPT_STACK and + * CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is + * possible that both are FALSE for a particular CPU. Although it + * is unclear what that would imply about the interrupt processing + * procedure on that CPU. + * + */ + +#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE + +/* + * Does RTEMS allocate a dedicated interrupt stack in the Interrupt Manager? + * + * If TRUE, then the memory is allocated during initialization. + * If FALSE, then the memory is allocated during initialization. + * + * This should be TRUE is CPU_HAS_SOFTWARE_INTERRUPT_STACK is TRUE + * or CPU_INSTALL_HARDWARE_INTERRUPT_STACK is TRUE. + * + */ + +#define CPU_ALLOCATE_INTERRUPT_STACK TRUE + +/* + * Does the RTEMS invoke the user's ISR with the vector number and + * a pointer to the saved interrupt frame (1) or just the vector + * number (0)? + * + */ + +#define CPU_ISR_PASSES_FRAME_POINTER TRUE + +/* + * Does the CPU have hardware floating point? + * + * If TRUE, then the RTEMS_FLOATING_POINT task attribute is supported. + * If FALSE, then the RTEMS_FLOATING_POINT task attribute is ignored. + * + * If there is a FP coprocessor such as the i387 or mc68881, then + * the answer is TRUE. + * + * The macro name "OR1K_HAS_FPU" should be made CPU specific. + * It indicates whether or not this CPU model has FP support. For + * example, it would be possible to have an i386_nofp CPU model + * which set this to false to indicate that you have an i386 without + * an i387 and wish to leave floating point support out of RTEMS. + * + * The CPU_SOFTWARE_FP is used to indicate whether or not there + * is software implemented floating point that must be context + * switched. The determination of whether or not this applies + * is very tool specific and the state saved/restored is also + * compiler specific. + * + * Or1k Specific Information: + * + * At this time there are no implementations of Or1k that are + * expected to implement floating point. More importantly, the + * floating point architecture is expected to change significantly + * before such chips are fabricated. + */ + +#define CPU_HARDWARE_FP FALSE +#define CPU_SOFTWARE_FP FALSE + +/* + * Are all tasks RTEMS_FLOATING_POINT tasks implicitly? + * + * If TRUE, then the RTEMS_FLOATING_POINT task attribute is assumed. + * If FALSE, then the RTEMS_FLOATING_POINT task attribute is followed. + * + * If CPU_HARDWARE_FP is FALSE, then this should be FALSE as well. + * + */ + +#define CPU_ALL_TASKS_ARE_FP FALSE + +/* + * Should the IDLE task have a floating point context? + * + * If TRUE, then the IDLE task is created as a RTEMS_FLOATING_POINT task + * and it has a floating point context which is switched in and out. + * If FALSE, then the IDLE task does not have a floating point context. + * + * Setting this to TRUE negatively impacts the time required to preempt + * the IDLE task from an interrupt because the floating point context + * must be saved as part of the preemption. + * + */ + +#define CPU_IDLE_TASK_IS_FP FALSE + +/* + * Should the saving of the floating point registers be deferred + * until a context switch is made to another different floating point + * task? + * + * If TRUE, then the floating point context will not be stored until + * necessary. It will remain in the floating point registers and not + * disturned until another floating point task is switched to. + * + * If FALSE, then the floating point context is saved when a floating + * point task is switched out and restored when the next floating point + * task is restored. The state of the floating point registers between + * those two operations is not specified. + * + * If the floating point context does NOT have to be saved as part of + * interrupt dispatching, then it should be safe to set this to TRUE. + * + * Setting this flag to TRUE results in using a different algorithm + * for deciding when to save and restore the floating point context. + * The deferred FP switch algorithm minimizes the number of times + * the FP context is saved and restored. The FP context is not saved + * until a context switch is made to another, different FP task. + * Thus in a system with only one FP task, the FP context will never + * be saved or restored. + * + */ + +#define CPU_USE_DEFERRED_FP_SWITCH TRUE + +#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE + +/* + * Does this port provide a CPU dependent IDLE task implementation? + * + * If TRUE, then the routine _CPU_Thread_Idle_body + * must be provided and is the default IDLE thread body instead of + * _CPU_Thread_Idle_body. + * + * If FALSE, then use the generic IDLE thread body if the BSP does + * not provide one. + * + * This is intended to allow for supporting processors which have + * a low power or idle mode. When the IDLE thread is executed, then + * the CPU can be powered down. + * + * The order of precedence for selecting the IDLE thread body is: + * + * 1. BSP provided + * 2. CPU dependent (if provided) + * 3. generic (if no BSP and no CPU dependent) + * + */ + +#define CPU_PROVIDES_IDLE_THREAD_BODY TRUE + +/* + * Does the stack grow up (toward higher addresses) or down + * (toward lower addresses)? + * + * If TRUE, then the grows upward. + * If FALSE, then the grows toward smaller addresses. + * + */ + +#define CPU_STACK_GROWS_UP FALSE + +/* FIXME: Is this the right value? */ +#define CPU_CACHE_LINE_BYTES 32 + +#define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES ) + +/* + * Define what is required to specify how the network to host conversion + * routines are handled. + * + * Or1k Specific Information: + * + * This version of RTEMS is designed specifically to run with + * big endian architectures. If you want little endian, you'll + * have to make the appropriate adjustments here and write + * efficient routines for byte swapping. The Or1k architecture + * doesn't do this very well. + */ + +#define CPU_HAS_OWN_HOST_TO_NETWORK_ROUTINES FALSE + +/* + * The following defines the number of bits actually used in the + * interrupt field of the task mode. How those bits map to the + * CPU interrupt levels is defined by the routine _CPU_ISR_Set_level(). + * + */ + +#define CPU_MODES_INTERRUPT_MASK 0x00000001 + +/* + * Processor defined structures required for cpukit/score. + */ + + +/* + * Contexts + * + * Generally there are 2 types of context to save. + * 1. Interrupt registers to save + * 2. Task level registers to save + * + * This means we have the following 3 context items: + * 1. task level context stuff:: Context_Control + * 2. floating point task stuff:: Context_Control_fp + * 3. special interrupt level context :: Context_Control_interrupt + * + * On some processors, it is cost-effective to save only the callee + * preserved registers during a task context switch. This means + * that the ISR code needs to save those registers which do not + * persist across function calls. It is not mandatory to make this + * distinctions between the caller/callee saves registers for the + * purpose of minimizing context saved during task switch and on interrupts. + * If the cost of saving extra registers is minimal, simplicity is the + * choice. Save the same context on interrupt entry as for tasks in + * this case. + * + * Additionally, if gdb is to be made aware of RTEMS tasks for this CPU, then + * care should be used in designing the context area. + * + * On some CPUs with hardware floating point support, the Context_Control_fp + * structure will not be used or it simply consist of an array of a + * fixed number of bytes. This is done when the floating point context + * is dumped by a "FP save context" type instruction and the format + * is not really defined by the CPU. In this case, there is no need + * to figure out the exact format -- only the size. Of course, although + * this is enough information for RTEMS, it is probably not enough for + * a debugger such as gdb. But that is another problem. + * + * + */ +#ifndef ASM +#ifdef OR1K_64BIT_ARCH +#define or1kreg uint64_t +#else +#define or1kreg uint32_t +#endif + +typedef struct { + uint32_t r1; /* Stack pointer */ + uint32_t r2; /* Frame pointer */ + uint32_t r3; + uint32_t r4; + uint32_t r5; + uint32_t r6; + uint32_t r7; + uint32_t r8; + uint32_t r9; + uint32_t r10; + uint32_t r11; + uint32_t r12; + uint32_t r13; + uint32_t r14; + uint32_t r15; + uint32_t r16; + uint32_t r17; + uint32_t r18; + uint32_t r19; + uint32_t r20; + uint32_t r21; + uint32_t r22; + uint32_t r23; + uint32_t r24; + uint32_t r25; + uint32_t r26; + uint32_t r27; + uint32_t r28; + uint32_t r29; + uint32_t r30; + uint32_t r31; + + uint32_t sr; /* Current supervision register non persistent values */ + uint32_t epcr; + uint32_t eear; + uint32_t esr; +} Context_Control; + +#define _CPU_Context_Get_SP( _context ) \ + (_context)->r1 + +typedef struct { + /** FPU registers are listed here */ + double some_float_register; +} Context_Control_fp; + +typedef Context_Control CPU_Interrupt_frame; + +/* + * The size of the floating point context area. On some CPUs this + * will not be a "sizeof" because the format of the floating point + * area is not defined -- only the size is. This is usually on + * CPUs with a "floating point save context" instruction. + * + * Or1k Specific Information: + * + */ + +#define CPU_CONTEXT_FP_SIZE 0 + +/* + * Amount of extra stack (above minimum stack size) required by + * MPCI receive server thread. Remember that in a multiprocessor + * system this thread must exist and be able to process all directives. + * + */ + +#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0 + +/* + * Should be large enough to run all RTEMS tests. This insures + * that a "reasonable" small application should not have any problems. + * + */ + +#define CPU_STACK_MINIMUM_SIZE 4096 + +/* + * CPU's worst alignment requirement for data types on a byte boundary. This + * alignment does not take into account the requirements for the stack. + * + */ + +#define CPU_ALIGNMENT 8 + +/* + * This is defined if the port has a special way to report the ISR nesting + * level. Most ports maintain the variable _ISR_Nest_level. + */ +#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE + +/** + * Size of a pointer. + * + * This must be an integer literal that can be used by the assembler. This + * value will be used to calculate offsets of structure members. These + * offsets will be used in assembler code. + */ +#define CPU_SIZEOF_POINTER 4 + +/* + * This number corresponds to the byte alignment requirement for the + * heap handler. This alignment requirement may be stricter than that + * for the data types alignment specified by CPU_ALIGNMENT. It is + * common for the heap to follow the same alignment requirement as + * CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict enough for the heap, + * then this should be set to CPU_ALIGNMENT. + * + * NOTE: This does not have to be a power of 2 although it should be + * a multiple of 2 greater than or equal to 2. The requirement + * to be a multiple of 2 is because the heap uses the least + * significant field of the front and back flags to indicate + * that a block is in use or free. So you do not want any odd + * length blocks really putting length data in that bit. + * + * On byte oriented architectures, CPU_HEAP_ALIGNMENT normally will + * have to be greater or equal to than CPU_ALIGNMENT to ensure that + * elements allocated from the heap meet all restrictions. + * + */ + +#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT + +/* + * This number corresponds to the byte alignment requirement for memory + * buffers allocated by the partition manager. This alignment requirement + * may be stricter than that for the data types alignment specified by + * CPU_ALIGNMENT. It is common for the partition to follow the same + * alignment requirement as CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict + * enough for the partition, then this should be set to CPU_ALIGNMENT. + * + * NOTE: This does not have to be a power of 2. It does have to + * be greater or equal to than CPU_ALIGNMENT. + * + */ + +#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT + +/* + * This number corresponds to the byte alignment requirement for the + * stack. This alignment requirement may be stricter than that for the + * data types alignment specified by CPU_ALIGNMENT. If the CPU_ALIGNMENT + * is strict enough for the stack, then this should be set to 0. + * + * NOTE: This must be a power of 2 either 0 or greater than CPU_ALIGNMENT. + * + */ + +#define CPU_STACK_ALIGNMENT 0 + +/* ISR handler macros */ + +/* + * Support routine to initialize the RTEMS vector table after it is allocated. + * + * NO_CPU Specific Information: + * + * XXX document implementation including references if appropriate + */ + +#define _CPU_Initialize_vectors() + +/* + * Disable all interrupts for an RTEMS critical section. The previous + * level is returned in _level. + * + */ + +static inline uint32_t or1k_interrupt_disable( void ) +{ + uint32_t sr; + sr = _OR1K_mfspr(CPU_OR1K_SPR_SR); + + _OR1K_mtspr(CPU_OR1K_SPR_SR, (sr & ~CPU_OR1K_SPR_SR_IEE)); + + return sr; +} + +static inline void or1k_interrupt_enable(uint32_t level) +{ + uint32_t sr; + + /* Enable interrupts and restore rs */ + sr = level | CPU_OR1K_SPR_SR_IEE | CPU_OR1K_SPR_SR_TEE; + _OR1K_mtspr(CPU_OR1K_SPR_SR, sr); + +} + +#define _CPU_ISR_Disable( _level ) \ + _level = or1k_interrupt_disable() + + +/* + * Enable interrupts to the previous level (returned by _CPU_ISR_Disable). + * This indicates the end of an RTEMS critical section. The parameter + * _level is not modified. + * + */ + +#define _CPU_ISR_Enable( _level ) \ + or1k_interrupt_enable( _level ) + +/* + * This temporarily restores the interrupt to _level before immediately + * disabling them again. This is used to divide long RTEMS critical + * sections into two or more parts. The parameter _level is not + * modified. + * + */ + +#define _CPU_ISR_Flash( _level ) \ + do{ \ + _CPU_ISR_Enable( _level ); \ + _OR1K_mtspr(CPU_OR1K_SPR_SR, (_level & ~CPU_OR1K_SPR_SR_IEE)); \ + } while(0) + +RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) +{ + return ( level & CPU_OR1K_SPR_SR ) != 0; +} + +/* + * Map interrupt level in task mode onto the hardware that the CPU + * actually provides. Currently, interrupt levels which do not + * map onto the CPU in a generic fashion are undefined. Someday, + * it would be nice if these were "mapped" by the application + * via a callout. For example, m68k has 8 levels 0 - 7, levels + * 8 - 255 would be available for bsp/application specific meaning. + * This could be used to manage a programmable interrupt controller + * via the rtems_task_mode directive. + * + * The get routine usually must be implemented as a subroutine. + * + */ + +void _CPU_ISR_Set_level( uint32_t level ); + +uint32_t _CPU_ISR_Get_level( void ); + +/* end of ISR handler macros */ + +/* Context handler macros */ + +#define OR1K_FAST_CONTEXT_SWITCH_ENABLED FALSE +/* + * Initialize the context to a state suitable for starting a + * task after a context restore operation. Generally, this + * involves: + * + * - setting a starting address + * - preparing the stack + * - preparing the stack and frame pointers + * - setting the proper interrupt level in the context + * - initializing the floating point context + * + * This routine generally does not set any unnecessary register + * in the context. The state of the "general data" registers is + * undefined at task start time. + * + * NOTE: This is_fp parameter is TRUE if the thread is to be a floating + * point thread. This is typically only used on CPUs where the + * FPU may be easily disabled by software such as on the SPARC + * where the PSR contains an enable FPU bit. + * + */ + +/** + * @brief Initializes the CPU context. + * + * The following steps are performed: + * - setting a starting address + * - preparing the stack + * - preparing the stack and frame pointers + * - setting the proper interrupt level in the context + * + * @param[in] context points to the context area + * @param[in] stack_area_begin is the low address of the allocated stack area + * @param[in] stack_area_size is the size of the stack area in bytes + * @param[in] new_level is the interrupt level for the task + * @param[in] entry_point is the task's entry point + * @param[in] is_fp is set to @c true if the task is a floating point task + * @param[in] tls_area is the thread-local storage (TLS) area + */ +void _CPU_Context_Initialize( + Context_Control *context, + void *stack_area_begin, + size_t stack_area_size, + uint32_t new_level, + void (*entry_point)( void ), + bool is_fp, + void *tls_area +); + +/* + * This routine is responsible for somehow restarting the currently + * executing task. If you are lucky, then all that is necessary + * is restoring the context. Otherwise, there will need to be + * a special assembly routine which does something special in this + * case. Context_Restore should work most of the time. It will + * not work if restarting self conflicts with the stack frame + * assumptions of restoring a context. + * + */ + +#define _CPU_Context_Restart_self( _the_context ) \ + _CPU_Context_restore( (_the_context) ); + +/* + * This routine is responsible to initialize the FP context. + * + * The FP area pointer is passed by reference to allow the initial pointer + * into a floating point context area (used to save the floating point + * context) to be at an arbitrary place in the floating point context area. + * + * This is necessary because some FP units are designed to have + * their context saved as a stack which grows into lower addresses. + * Other FP units can be saved by simply moving registers into offsets + * from the base of the context area. Finally some FP units provide + * a "dump context" instruction which could fill in from high to low + * or low to high based on the whim of the CPU designers. + */ +#define _CPU_Context_Initialize_fp( _fp_area_p ) \ + memset( *( _fp_area_p ), 0, CPU_CONTEXT_FP_SIZE ) + +/* end of Context handler macros */ + +/* Fatal Error manager macros */ + +/* + * This routine copies _error into a known place -- typically a stack + * location or a register, optionally disables interrupts, and + * halts/stops the CPU. + * + */ + +#include + +#define _CPU_Fatal_halt(_source, _error ) \ + printk("Fatal Error %d.%" PRId32 " Halted\n",_source, _error); \ + _OR1KSIM_CPU_Halt(); \ + for(;;) + +/* end of Fatal Error manager macros */ + +#define CPU_USE_GENERIC_BITFIELD_CODE TRUE + +#endif /* ASM */ + +#define CPU_SIZEOF_POINTER 4 + +#define CPU_MAXIMUM_PROCESSORS 32 + +#ifndef ASM +typedef uint32_t CPU_Counter_ticks; + +typedef struct { + uint32_t r[32]; + + /* The following registers must be saved if we have + fast context switch disabled and nested interrupt + levels are enabled. + */ +#if !OR1K_FAST_CONTEXT_SWITCH_ENABLED + uint32_t epcr; /* exception PC register */ + uint32_t eear; /* exception effective address register */ + uint32_t esr; /* exception supervision register */ +#endif + +} CPU_Exception_frame; + +/** + * @brief Prints the exception frame via printk(). + * + * @see rtems_fatal() and RTEMS_FATAL_SOURCE_EXCEPTION. + */ +void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); + + +/* end of Priority handler macros */ + +/* functions */ + +/* + * _CPU_Initialize + * + * This routine performs CPU dependent initialization. + * + */ + +void _CPU_Initialize( + void +); + +/* + * _CPU_ISR_install_raw_handler + * + * This routine installs a "raw" interrupt handler directly into the + * processor's vector table. + * + */ + +void _CPU_ISR_install_raw_handler( + uint32_t vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +/* + * _CPU_ISR_install_vector + * + * This routine installs an interrupt vector. + * + * NO_CPU Specific Information: + * + * XXX document implementation including references if appropriate + */ + +void _CPU_ISR_install_vector( + uint32_t vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +/* + * _CPU_Install_interrupt_stack + * + * This routine installs the hardware interrupt stack pointer. + * + * NOTE: It need only be provided if CPU_HAS_HARDWARE_INTERRUPT_STACK + * is TRUE. + * + */ + +void _CPU_Install_interrupt_stack( void ); + +/* + * _CPU_Thread_Idle_body + * + * This routine is the CPU dependent IDLE thread body. + * + * NOTE: It need only be provided if CPU_PROVIDES_IDLE_THREAD_BODY + * is TRUE. + * + */ + +void *_CPU_Thread_Idle_body( uintptr_t ignored ); + +/* + * _CPU_Context_switch + * + * This routine switches from the run context to the heir context. + * + * Or1k Specific Information: + * + * Please see the comments in the .c file for a description of how + * this function works. There are several things to be aware of. + */ + +void _CPU_Context_switch( + Context_Control *run, + Context_Control *heir +); + +/* + * _CPU_Context_restore + * + * This routine is generally used only to restart self in an + * efficient manner. It may simply be a label in _CPU_Context_switch. + * + * NOTE: May be unnecessary to reload some registers. + * + */ + +void _CPU_Context_restore( + Context_Control *new_context +) RTEMS_NO_RETURN; + +/* + * _CPU_Context_save_fp + * + * This routine saves the floating point context passed to it. + * + */ + +void _CPU_Context_save_fp( + void **fp_context_ptr +); + +/* + * _CPU_Context_restore_fp + * + * This routine restores the floating point context passed to it. + * + */ + +void _CPU_Context_restore_fp( + void **fp_context_ptr +); + +/* The following routine swaps the endian format of an unsigned int. + * It must be static because it is referenced indirectly. + * + * This version will work on any processor, but if there is a better + * way for your CPU PLEASE use it. The most common way to do this is to: + * + * swap least significant two bytes with 16-bit rotate + * swap upper and lower 16-bits + * swap most significant two bytes with 16-bit rotate + * + * Some CPUs have special instructions which swap a 32-bit quantity in + * a single instruction (e.g. i486). It is probably best to avoid + * an "endian swapping control bit" in the CPU. One good reason is + * that interrupts would probably have to be disabled to insure that + * an interrupt does not try to access the same "chunk" with the wrong + * endian. Another good reason is that on some CPUs, the endian bit + * endianness for ALL fetches -- both code and data -- so the code + * will be fetched incorrectly. + * + */ + +void _CPU_Context_volatile_clobber( uintptr_t pattern ); + +void _CPU_Context_validate( uintptr_t pattern ); + +static inline unsigned int CPU_swap_u32( + unsigned int value +) +{ + uint32_t byte1, byte2, byte3, byte4, swapped; + + byte4 = (value >> 24) & 0xff; + byte3 = (value >> 16) & 0xff; + byte2 = (value >> 8) & 0xff; + byte1 = value & 0xff; + + swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4; + return( swapped ); +} + +#define CPU_swap_u16( value ) \ + (((value&0xff) << 8) | ((value >> 8)&0xff)) + +typedef uint32_t CPU_Counter_ticks; + +CPU_Counter_ticks _CPU_Counter_read( void ); + +CPU_Counter_ticks _CPU_Counter_difference( + CPU_Counter_ticks second, + CPU_Counter_ticks first +); + +#endif /* ASM */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/score/cpu/or1k/include/rtems/score/cpu_asm.h b/cpukit/score/cpu/or1k/include/rtems/score/cpu_asm.h new file mode 100644 index 0000000000..a5659f35ce --- /dev/null +++ b/cpukit/score/cpu/or1k/include/rtems/score/cpu_asm.h @@ -0,0 +1,74 @@ +/** + * @file + * + * @brief OR1K Assembly File + * + * Very loose template for an include file for the cpu_asm.? file + * if it is implemented as a ".S" file (preprocessed by cpp) instead + * of a ".s" file (preprocessed by gm4 or gasp). + */ + +/* + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + */ + +#ifndef _RTEMS_SCORE_CPU_ASM_H +#define _RTEMS_SCORE_CPU_ASM_H + +/* pull in the generated offsets */ + +/* +#include +*/ + +/* + * Hardware General Registers + */ + +/* put something here */ + +/* + * Hardware Floating Point Registers + */ + +/* put something here */ + +/* + * Hardware Control Registers + */ + +/* put something here */ + +/* + * Calling Convention + */ + +/* put something here */ + +/* + * Temporary registers + */ + +/* put something here */ + +/* + * Floating Point Registers - SW Conventions + */ + +/* put something here */ + +/* + * Temporary floating point registers + */ + +/* put something here */ + +#endif + +/* end of file */ diff --git a/cpukit/score/cpu/or1k/include/rtems/score/cpuatomic.h b/cpukit/score/cpu/or1k/include/rtems/score/cpuatomic.h new file mode 100644 index 0000000000..598ee76b20 --- /dev/null +++ b/cpukit/score/cpu/or1k/include/rtems/score/cpuatomic.h @@ -0,0 +1,14 @@ +/* + * COPYRIGHT (c) 2012-2013 Deng Hengyi. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_ATOMIC_CPU_H +#define _RTEMS_SCORE_ATOMIC_CPU_H + +#include + +#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/or1k/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/or1k/include/rtems/score/cpuimpl.h new file mode 100644 index 0000000000..789f2badd9 --- /dev/null +++ b/cpukit/score/cpu/or1k/include/rtems/score/cpuimpl.h @@ -0,0 +1,34 @@ +/** + * @file + * + * @brief CPU Port Implementation API + */ + +/* + * Copyright (c) 2013 embedded brains GmbH + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPUIMPL_H +#define _RTEMS_SCORE_CPUIMPL_H + +#include + +#define CPU_PER_CPU_CONTROL_SIZE 0 + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ASM */ + +#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/or1k/include/rtems/score/or1k-utility.h b/cpukit/score/cpu/or1k/include/rtems/score/or1k-utility.h new file mode 100644 index 0000000000..98bbe41b00 --- /dev/null +++ b/cpukit/score/cpu/or1k/include/rtems/score/or1k-utility.h @@ -0,0 +1,396 @@ +/** + * @file + * + * @brief OR1K utility + */ +/* + * COPYRIGHT (c) 2014 Hesham ALMatary + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_OR1K_UTILITY_H +#define _RTEMS_SCORE_OR1K_UTILITY_H + +/* SPR groups definitions */ +#define SPR_GRP_SHAMT 11 +#define SPR_GRP0_SYS_CTRL (0 << SPR_GRP_SHAMT) +#define SPR_GRP1_DMMU (1 << SPR_GRP_SHAMT) +#define SPR_GRP2_IMMU (2 << SPR_GRP_SHAMT) +#define SPR_GRP3_DC (3 << SPR_GRP_SHAMT) +#define SPR_GRP4_IC (4 << SPR_GRP_SHAMT) +#define SPR_GRP5_MAC (5 << SPR_GRP_SHAMT) +#define SPR_GRP6_DEBUG (6 << SPR_GRP_SHAMT) +#define SPR_GRP7_PERF_CTR (7 << SPR_GRP_SHAMT) +#define SPR_GRP8_PWR_MNG (8 << SPR_GRP_SHAMT) +#define SPR_GRP9_PIC (9 << SPR_GRP_SHAMT) +#define SPR_GPR10_TICK_TMR (10 << SPR_GRP_SHAMT) +#define SPR_GPR11_FPU (11 << SPR_GRP_SHAMT) + +/* SPR registers definitions */ + +/* Group 0: System control registers */ +#define CPU_OR1K_SPR_VR (SPR_GRP0_SYS_CTRL + 0) +#define CPU_OR1K_SPR_UPR (SPR_GRP0_SYS_CTRL + 1) +#define CPU_OR1K_SPR_CPUCFGR (SPR_GRP0_SYS_CTRL + 2) +#define CPU_OR1K_SPR_DMMUCFGR (SPR_GRP0_SYS_CTRL + 3) +#define CPU_OR1K_SPR_IMMUCFGR (SPR_GRP0_SYS_CTRL + 4) +#define CPU_OR1K_SPR_DCCFGR (SPR_GRP0_SYS_CTRL + 5) +#define CPU_OR1K_SPR_ICCFGR (SPR_GRP0_SYS_CTRL + 6) +#define CPU_OR1K_SPR_DCFGR (SPR_GRP0_SYS_CTRL + 7) +#define CPU_OR1K_SPR_PCCFGR (SPR_GRP0_SYS_CTRL + 8) +#define CPU_OR1K_SPR_VR2 (SPR_GRP0_SYS_CTRL + 9) +#define CPU_OR1K_SPR_AVR (SPR_GRP0_SYS_CTRL + 10) +#define CPU_OR1K_SPR_EVBAR (SPR_GRP0_SYS_CTRL + 11) +#define CPU_OR1K_SPR_AECR (SPR_GRP0_SYS_CTRL + 12) +#define CPU_OR1K_SPR_AESR (SPR_GRP0_SYS_CTRL + 13) +#define CPU_OR1K_SPR_NPC (SPR_GRP0_SYS_CTRL + 16) +#define CPU_OR1K_SPR_SR (SPR_GRP0_SYS_CTRL + 17) +#define CPU_OR1K_SPR_PPC (SPR_GRP0_SYS_CTRL + 18) +#define CPU_OR1K_SPR_FPCSR (SPR_GRP0_SYS_CTRL + 20) +#define CPU_OR1K_SPR_EPCR0 (SPR_GRP0_SYS_CTRL + 32) +#define CPU_OR1K_SPR_EPCR1 (SPR_GRP0_SYS_CTRL + 33) +#define CPU_OR1K_SPR_EPCR2 (SPR_GRP0_SYS_CTRL + 34) +#define CPU_OR1K_SPR_EPCR3 (SPR_GRP0_SYS_CTRL + 35) +#define CPU_OR1K_SPR_EPCR4 (SPR_GRP0_SYS_CTRL + 36) +#define CPU_OR1K_SPR_EPCR5 (SPR_GRP0_SYS_CTRL + 37) +#define CPU_OR1K_SPR_EPCR6 (SPR_GRP0_SYS_CTRL + 38) +#define CPU_OR1K_SPR_EPCR7 (SPR_GRP0_SYS_CTRL + 39) +#define CPU_OR1K_SPR_EPCR8 (SPR_GRP0_SYS_CTRL + 40) +#define CPU_OR1K_SPR_EPCR9 (SPR_GRP0_SYS_CTRL + 41) +#define CPU_OR1K_SPR_EPCR10 (SPR_GRP0_SYS_CTRL + 42) +#define CPU_OR1K_SPR_EPCR11 (SPR_GRP0_SYS_CTRL + 43) +#define CPU_OR1K_SPR_EPCR12 (SPR_GRP0_SYS_CTRL + 44) +#define CPU_OR1K_SPR_EPCR13 (SPR_GRP0_SYS_CTRL + 45) +#define CPU_OR1K_SPR_EPCR14 (SPR_GRP0_SYS_CTRL + 46) +#define CPU_OR1K_SPR_EPCR15 (SPR_GRP0_SYS_CTRL + 47) +#define CPU_OR1K_SPR_EEAR0 (SPR_GRP0_SYS_CTRL + 48) +#define CPU_OR1K_SPR_EEAR1 (SPR_GRP0_SYS_CTRL + 49) +#define CPU_OR1K_SPR_EEAR2 (SPR_GRP0_SYS_CTRL + 50) +#define CPU_OR1K_SPR_EEAR3 (SPR_GRP0_SYS_CTRL + 51) +#define CPU_OR1K_SPR_EEAR4 (SPR_GRP0_SYS_CTRL + 52) +#define CPU_OR1K_SPR_EEAR5 (SPR_GRP0_SYS_CTRL + 53) +#define CPU_OR1K_SPR_EEAR6 (SPR_GRP0_SYS_CTRL + 54) +#define CPU_OR1K_SPR_EEAR7 (SPR_GRP0_SYS_CTRL + 55) +#define CPU_OR1K_SPR_EEAR8 (SPR_GRP0_SYS_CTRL + 56) +#define CPU_OR1K_SPR_EEAR9 (SPR_GRP0_SYS_CTRL + 57) +#define CPU_OR1K_SPR_EEAR10 (SPR_GRP0_SYS_CTRL + 58) +#define CPU_OR1K_SPR_EEAR11 (SPR_GRP0_SYS_CTRL + 59) +#define CPU_OR1K_SPR_EEAR12 (SPR_GRP0_SYS_CTRL + 60) +#define CPU_OR1K_SPR_EEAR13 (SPR_GRP0_SYS_CTRL + 61) +#define CPU_OR1K_SPR_EEAR14 (SPR_GRP0_SYS_CTRL + 62) +#define CPU_OR1K_SPR_EEAR15 (SPR_GRP0_SYS_CTRL + 63) +#define CPU_OR1K_SPR_ESR0 (SPR_GRP0_SYS_CTRL + 64) +#define CPU_OR1K_SPR_ESR1 (SPR_GRP0_SYS_CTRL + 65) +#define CPU_OR1K_SPR_ESR2 (SPR_GRP0_SYS_CTRL + 66) +#define CPU_OR1K_SPR_ESR3 (SPR_GRP0_SYS_CTRL + 67) +#define CPU_OR1K_SPR_ESR4 (SPR_GRP0_SYS_CTRL + 68) +#define CPU_OR1K_SPR_ESR5 (SPR_GRP0_SYS_CTRL + 69) +#define CPU_OR1K_SPR_ESR6 (SPR_GRP0_SYS_CTRL + 70) +#define CPU_OR1K_SPR_ESR7 (SPR_GRP0_SYS_CTRL + 71) +#define CPU_OR1K_SPR_ESR8 (SPR_GRP0_SYS_CTRL + 72) +#define CPU_OR1K_SPR_ESR9 (SPR_GRP0_SYS_CTRL + 73) +#define CPU_OR1K_SPR_ESR10 (SPR_GRP0_SYS_CTRL + 74) +#define CPU_OR1K_SPR_ESR11 (SPR_GRP0_SYS_CTRL + 75) +#define CPU_OR1K_SPR_ESR12 (SPR_GRP0_SYS_CTRL + 76) +#define CPU_OR1K_SPR_ESR13 (SPR_GRP0_SYS_CTRL + 77) +#define CPU_OR1K_SPR_ESR14 (SPR_GRP0_SYS_CTRL + 78) +#define CPU_OR1K_SPR_ESR15 (SPR_GRP0_SYS_CTRL + 79) + +/* Shadow registers base */ +#define CPU_OR1K_SPR_GPR32 (SPR_GRP0_SYS_CTRL + 1024) + +/* Group1: Data MMU registers */ +#define CPU_OR1K_SPR_DMMUCR (SPR_GRP1_DMMU + 0) +#define CPU_OR1K_SPR_DMMUPR (SPR_GRP1_DMMU + 1) +#define CPU_OR1K_SPR_DTLBEIR (SPR_GRP1_DMMU + 2) +#define CPU_OR1K_SPR_DATBMR0 (SPR_GRP1_DMMU + 4) +#define CPU_OR1K_SPR_DATBMR1 (SPR_GRP1_DMMU + 5) +#define CPU_OR1K_SPR_DATBMR2 (SPR_GRP1_DMMU + 6) +#define CPU_OR1K_SPR_DATBMR3 (SPR_GRP1_DMMU + 7) +#define CPU_OR1K_SPR_DATBTR0 (SPR_GRP1_DMMU + 8) +#define CPU_OR1K_SPR_DATBTR1 (SPR_GRP1_DMMU + 9) +#define CPU_OR1K_SPR_DATBTR2 (SPR_GRP1_DMMU + 10) +#define CPU_OR1K_SPR_DATBTR3 (SPR_GRP1_DMMU + 11) + +/* Group2: Instruction MMU registers */ +#define CPU_OR1K_SPR_IMMUCR (SPR_GRP2_IMMU + 0) +#define CPU_OR1K_SPR_IMMUPR (SPR_GRP2_IMMU + 1) +#define CPU_OR1K_SPR_ITLBEIR (SPR_GRP2_IMMU + 2) +#define CPU_OR1K_SPR_IATBMR0 (SPR_GRP2_IMMU + 4) +#define CPU_OR1K_SPR_IATBMR1 (SPR_GRP2_IMMU + 5) +#define CPU_OR1K_SPR_IATBMR2 (SPR_GRP2_IMMU + 6) +#define CPU_OR1K_SPR_IATBMR3 (SPR_GRP2_IMMU + 7) +#define CPU_OR1K_SPR_IATBTR0 (SPR_GRP2_IMMU + 8) +#define CPU_OR1K_SPR_IATBTR1 (SPR_GRP2_IMMU + 9) +#define CPU_OR1K_SPR_IATBTR2 (SPR_GRP2_IMMU + 10) +#define CPU_OR1K_SPR_IATBTR3 (SPR_GRP2_IMMU + 11) + +/* Group3: Data Cache registers */ +#define CPU_OR1K_SPR_DCCR (SPR_GRP3_DC + 0) +#define CPU_OR1K_SPR_DCBPR (SPR_GRP3_DC + 1) +#define CPU_OR1K_SPR_DCBFR (SPR_GRP3_DC + 2) +#define CPU_OR1K_SPR_DCBIR (SPR_GRP3_DC + 3) +#define CPU_OR1K_SPR_DCBWR (SPR_GRP3_DC + 4) +#define CPU_OR1K_SPR_DCBLR (SPR_GRP3_DC + 5) + +/* Group4: Instruction Cache registers */ +#define CPU_OR1K_SPR_ICCR (SPR_GRP4_IC + 0) +#define CPU_OR1K_SPR_ICBPR (SPR_GRP4_IC + 1) +#define CPU_OR1K_SPR_ICBIR (SPR_GRP4_IC + 2) +#define CPU_OR1K_SPR_ICBLR (SPR_GRP4_IC + 3) + +/* Group5: MAC registers */ +#define CPU_OR1K_SPR_MACLO (SPR_GRP5_MAC + 1) +#define CPU_OR1K_SPR_MACHI (SPR_GRP5_MAC + 2) + +/* Group6: Debug registers */ +#define CPU_OR1K_SPR_DVR0 (SPR_GRP6_DEBUG + 0) +#define CPU_OR1K_SPR_DVR1 (SPR_GRP6_DEBUG + 1) +#define CPU_OR1K_SPR_DVR2 (SPR_GRP6_DEBUG + 2) +#define CPU_OR1K_SPR_DVR3 (SPR_GRP6_DEBUG + 3) +#define CPU_OR1K_SPR_DVR4 (SPR_GRP6_DEBUG + 4) +#define CPU_OR1K_SPR_DVR5 (SPR_GRP6_DEBUG + 5) +#define CPU_OR1K_SPR_DVR6 (SPR_GRP6_DEBUG + 6) +#define CPU_OR1K_SPR_DVR7 (SPR_GRP6_DEBUG + 7) +#define CPU_OR1K_SPR_DCR0 (SPR_GRP6_DEBUG + 8) +#define CPU_OR1K_SPR_DCR1 (SPR_GRP6_DEBUG + 9) +#define CPU_OR1K_SPR_DCR2 (SPR_GRP6_DEBUG + 10) +#define CPU_OR1K_SPR_DCR3 (SPR_GRP6_DEBUG + 11) +#define CPU_OR1K_SPR_DCR4 (SPR_GRP6_DEBUG + 12) +#define CPU_OR1K_SPR_DCR5 (SPR_GRP6_DEBUG + 13) +#define CPU_OR1K_SPR_DCR6 (SPR_GRP6_DEBUG + 14) +#define CPU_OR1K_SPR_DCR7 (SPR_GRP6_DEBUG + 15) +#define CPU_OR1K_SPR_DMR1 (SPR_GRP6_DEBUG + 16) +#define CPU_OR1K_SPR_DMR2 (SPR_GRP6_DEBUG + 17) +#define CPU_OR1K_SPR_DCWR0 (SPR_GRP6_DEBUG + 18) +#define CPU_OR1K_SPR_DCWR1 (SPR_GRP6_DEBUG + 19) +#define CPU_OR1K_SPR_DSR (SPR_GRP6_DEBUG + 20) +#define CPU_OR1K_SPR_DRR (SPR_GRP6_DEBUG + 21) + +/* Group7: Performance counters registers */ +#define CPU_OR1K_SPR_PCCR0 (SPR_GRP7_PERF_CTR + 0) +#define CPU_OR1K_SPR_PCCR1 (SPR_GRP7_PERF_CTR + 1) +#define CPU_OR1K_SPR_PCCR2 (SPR_GRP7_PERF_CTR + 2) +#define CPU_OR1K_SPR_PCCR3 (SPR_GRP7_PERF_CTR + 3) +#define CPU_OR1K_SPR_PCCR4 (SPR_GRP7_PERF_CTR + 4) +#define CPU_OR1K_SPR_PCCR5 (SPR_GRP7_PERF_CTR + 5) +#define CPU_OR1K_SPR_PCCR6 (SPR_GRP7_PERF_CTR + 6) +#define CPU_OR1K_SPR_PCCR7 (SPR_GRP7_PERF_CTR + 7) +#define CPU_OR1K_SPR_PCMR0 (SPR_GRP7_PERF_CTR + 8) +#define CPU_OR1K_SPR_PCMR1 (SPR_GRP7_PERF_CTR + 9) +#define CPU_OR1K_SPR_PCMR2 (SPR_GRP7_PERF_CTR + 10) +#define CPU_OR1K_SPR_PCMR3 (SPR_GRP7_PERF_CTR + 11) +#define CPU_OR1K_SPR_PCMR4 (SPR_GRP7_PERF_CTR + 12) +#define CPU_OR1K_SPR_PCMR5 (SPR_GRP7_PERF_CTR + 13) +#define CPU_OR1K_SPR_PCMR6 (SPR_GRP7_PERF_CTR + 14) +#define CPU_OR1K_SPR_PCMR7 (SPR_GRP7_PERF_CTR + 15) + +/* Group8: Power management register */ +#define CPU_OR1K_SPR_PMR (SPR_GRP8_PWR_MNG + 0) + +/* Group9: PIC registers */ +#define CPU_OR1K_SPR_PICMR (SPR_GRP9_PIC + 0) +#define CPU_OR1K_SPR_PICSR (SPR_GRP9_PIC + 2) + +/* Group10: Tick Timer registers */ +#define CPU_OR1K_SPR_TTMR (SPR_GPR10_TICK_TMR + 0) +#define CPU_OR1K_SPR_TTCR (SPR_GPR10_TICK_TMR + 1) + + /* Shift amount macros for bits position in Supervision Register */ +#define CPU_OR1K_SPR_SR_SHAMT_SM (0) +#define CPU_OR1K_SPR_SR_SHAMT_TEE (1) +#define CPU_OR1K_SPR_SR_SHAMT_IEE (2) +#define CPU_OR1K_SPR_SR_SHAMT_DCE (3) +#define CPU_OR1K_SPR_SR_SHAMT_ICE (4) +#define CPU_OR1K_SPR_SR_SHAMT_DME (5) +#define CPU_OR1K_SPR_SR_SHAMT_IME (6) +#define CPU_OR1K_SPR_SR_SHAMT_LEE (7) +#define CPU_OR1K_SPR_SR_SHAMT_CE (8) +#define CPU_OR1K_SPR_SR_SHAMT_F (9) +#define CPU_OR1K_SPR_SR_SHAMT_CY (10) +#define CPU_OR1K_SPR_SR_SHAMT_OV (11) +#define CPU_OR1K_SPR_SR_SHAMT_OVE (12) +#define CPU_OR1K_SPR_SR_SHAMT_DSX (13) +#define CPU_OR1K_SPR_SR_SHAMT_EPH (14) +#define CPU_OR1K_SPR_SR_SHAMT_FO (15) +#define CPU_OR1K_SPR_SR_SHAMT_SUMRA (16) +#define CPU_OR1K_SPR_SR_SHAMT_CID (28) + +/* Supervision Mode Register. @see OpenRISC architecture manual*/ + + /* Supervisor Mode */ +#define CPU_OR1K_SPR_SR_SM (1 << CPU_OR1K_SPR_SR_SHAMT_SM) +/* Tick Timer Exception Enabled */ +#define CPU_OR1K_SPR_SR_TEE (1 << CPU_OR1K_SPR_SR_SHAMT_TEE) +/* Interrupt Exception Enabled */ +#define CPU_OR1K_SPR_SR_IEE (1 << CPU_OR1K_SPR_SR_SHAMT_IEE) +/* Data Cache Enable */ +#define CPU_OR1K_SPR_SR_DCE (1 << CPU_OR1K_SPR_SR_SHAMT_DCE) +/* Instruction Cache Enable */ +#define CPU_OR1K_SPR_SR_ICE (1 << CPU_OR1K_SPR_SR_SHAMT_ICE) +/* Data MMU Enable */ +#define CPU_OR1K_SPR_SR_DME (1 << CPU_OR1K_SPR_SR_SHAMT_DME) +/* Instruction MMU Enable */ +#define CPU_OR1K_SPR_SR_IME (1 << CPU_OR1K_SPR_SR_SHAMT_IME) +/* Little Endian Enable */ +#define CPU_OR1K_SPR_SR_LEE (1 << CPU_OR1K_SPR_SR_SHAMT_LEE) +/* CID Enable */ +#define CPU_OR1K_SPR_SR_CE (1 << CPU_OR1K_SPR_SR_SHAMT_CE) +/* Conditional branch flag */ +#define CPU_OR1K_SPR_SR_F (1 << CPU_OR1K_SPR_SR_SHAMT_F) +/* Carry flag */ +#define CPU_OR1K_SPR_SR_CY (1 << CPU_OR1K_SPR_SR_SHAMT_CY) +/* Overflow flag */ +#define CPU_OR1K_SPR_SR_OV (1 << CPU_OR1K_SPR_SR_SHAMT_OV) +/* Overflow flag Exception */ +#define CPU_OR1K_SPR_SR_OVE (1 << CPU_OR1K_SPR_SR_SHAMT_OVE) +/* Delay Slot Exception */ +#define CPU_OR1K_SPR_SR_DSX (1 << CPU_OR1K_SPR_SR_SHAMT_DSX) + /* Exception Prefix High */ +#define CPU_OR1K_SPR_SR_EPH (1 << CPU_OR1K_SPR_SR_SHAMT_EPH) +/* Fixed One */ +#define CPU_OR1K_SPR_SR_FO (1 << CPU_OR1K_SPR_SR_SHAMT_FO) +/* SPRs User Mode Read Access */ +#define CPU_OR1K_SPR_SR_SUMRA (1 << CPU_OR1K_SPR_SR_SHAMT_SUMRA) +/*Context ID (Fast Context Switching) */ +#define CPU_OR1K_SPR_SR_CID (F << CPU_OR1K_SPR_SR_SHAMT_CID) + +/* Tick timer configuration bits */ +#define CPU_OR1K_SPR_TTMR_SHAMT_IP 28 +#define CPU_OR1K_SPR_TTMR_SHAMT_IE 29 +#define CPU_OR1K_SPR_TTMR_SHAMT_MODE 30 + +#define CPU_OR1K_SPR_TTMR_TP_MASK (0x0FFFFFFF) +#define CPU_OR1K_SPR_TTMR_IP (1 << CPU_OR1K_SPR_TTMR_SHAMT_IP) +#define CPU_OR1K_SPR_TTMR_IE (1 << CPU_OR1K_SPR_TTMR_SHAMT_IE) +#define CPU_OR1K_SPR_TTMR_MODE_RESTART (1 << CPU_OR1K_SPR_TTMR_SHAMT_MODE) +#define CPU_OR1K_SPR_TTMR_MODE_ONE_SHOT (2 << CPU_OR1K_SPR_TTMR_SHAMT_MODE) +#define CPU_OR1K_SPR_TTMR_MODE_CONT (3 << CPU_OR1K_SPR_TTMR_SHAMT_MODE) + +/* Power management register bits */ + +/* Shift amount macros for bit positions in Power Management register */ +#define CPU_OR1K_SPR_PMR_SHAMT_SDF 0 +#define CPU_OR1K_SPR_PMR_SHAMT_DME 4 +#define CPU_OR1K_SPR_PMR_SHAMT_SME 5 +#define CPU_OR1K_SPR_PMR_SHAMT_DCGE 6 +#define CPU_OR1K_SPR_PMR_SHAMT_SUME 7 + +#define CPU_OR1K_SPR_PMR_SDF (0xF << CPU_OR1K_SPR_PMR_SHAMT_SDF) +#define CPU_OR1K_SPR_PMR_DME (1 << CPU_OR1K_SPR_PMR_SHAMT_DME) +#define CPU_OR1K_SPR_PMR_SME (1 << CPU_OR1K_SPR_PMR_SHAMT_SME) +#define CPU_OR1K_SPR_PMR_DCGE (1 << CPU_OR1K_SPR_PMR_SHAMT_DCGE) +#define CPU_OR1K_SPR_PMR_SUME (1 << CPU_OR1K_SPR_PMR_SHAMT_SUME) + +#ifndef ASM + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @brief Supervision Mode registers definitions. + * + * @see OpenRISC architecture manual - revision 0. + */ +typedef enum { + OR1K_EXCEPTION_RESET = 1, + OR1K_EXCEPTION_BUS_ERR = 2, + OR1K_EXCEPTION_D_PF = 3, /* Data Page Fault */ + OR1K_EXCEPTION_I_PF = 4, /* Instruction Page Fault */ + OR1K_EXCEPTION_TICK_TIMER = 5, + OR1K_EXCEPTION_ALIGNMENT = 6, + OR1K_EXCEPTION_I_UNDEF= 7, /* Undefiend instruction */ + OR1K_EXCEPTION_IRQ = 8, /* External interrupt */ + OR1K_EXCPETION_D_TLB = 9, /* Data TLB miss */ + OR1K_EXCPETION_I_TLB = 10, /* Instruction TLB miss */ + OR1K_EXCPETION_RANGE = 11, /* Range exception */ + OR1K_EXCPETION_SYS_CALL = 12, + OR1K_EXCPETION_FP = 13, /* Floating point exception */ + OR1K_EXCPETION_TRAP = 14, /* Caused by l.trap instruction or by debug unit */ + OR1K_EXCPETION_RESERVED1 = 15, + OR1K_EXCPETION_RESERVED2 = 16, + OR1K_EXCPETION_RESERVED3 = 17, + MAX_EXCEPTIONS = 17, + OR1K_EXCEPTION_MAKE_ENUM_32_BIT = 0xffffffff +} OR1K_Symbolic_exception_name; + +static inline uint32_t _OR1K_mfspr(uint32_t reg) +{ + uint32_t spr_value; + + asm volatile ( + "l.mfspr %0, %1, 0;\n\t" + : "=r" (spr_value) : "r" (reg)); + + return spr_value; +} + +static inline void _OR1K_mtspr(uint32_t reg, uint32_t value) +{ + asm volatile ( + "l.mtspr %1, %0, 0;\n\t" + :: "r" (value), "r" (reg) + ); +} + +/** + * @brief The slow down feature takes advantage of the low-power + * dividers in external clock generation circuitry to enable full + * functionality, but at a lower frequency so that power consumption + * is reduced. @see OpenRISC architecture manual, power management section. + * + * @param[in] value is 4 bit value to be written in PMR[SDF]. + * A lower value specifies higher expected performance from the processor core. + * + */ +#define _OR1K_CPU_SlowDown(value) \ + _OR1K_mtspr(CPU_OR1K_SPR_PMR, (value & CPU_OR1K_SPR_PMR_SDF)) + + +#define _OR1K_CPU_Doze() \ + _OR1K_mtspr(CPU_OR1K_SPR_PMR, CPU_OR1K_SPR_PMR_DME) + + +#define _OR1K_CPU_Sleep() \ + _OR1K_mtspr(CPU_OR1K_SPR_PMR, CPU_OR1K_SPR_PMR_SME) + +#define _OR1K_CPU_Suspend() \ + _OR1K_mtspr(CPU_OR1K_SPR_PMR, CPU_OR1K_SPR_PMR_SME) + +static inline void _OR1K_Sync_mem( void ) +{ + asm volatile("l.msync"); +} + +static inline void _OR1K_Sync_pipeline( void ) +{ + asm volatile("l.psync"); +} + +/** + * @brief or1ksim simulator can be sent a halt signal from RTEMS to tell + * the running or1ksim process on the host machine to exit. The following + * implementation has no effect on QEMU or hardware implementation and will + * be treated as normal l.nop. + * + */ +#define _OR1KSIM_CPU_Halt() \ + asm volatile ("l.nop 0xc") + +#ifdef __cplusplus +} +#endif + +#else /* ASM */ + +#endif /* ASM */ + +#endif /* _RTEMS_SCORE_OR1K_UTILITY_H */ diff --git a/cpukit/score/cpu/or1k/include/rtems/score/or1k.h b/cpukit/score/cpu/or1k/include/rtems/score/or1k.h new file mode 100644 index 0000000000..e1a3ddce42 --- /dev/null +++ b/cpukit/score/cpu/or1k/include/rtems/score/or1k.h @@ -0,0 +1,49 @@ +/** + * @file rtems/score/or1k.h + */ + +/* + * This file contains information pertaining to the OR1K processor. + * + * COPYRIGHT (c) 2014 Hesham ALMatary + * + * Based on code with the following copyright... + * COPYRIGHT (c) 1989-1999, 2010. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_OR1K_H +#define _RTEMS_SCORE_OR1K_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This file contains the information required to build + * RTEMS for a particular member of the OR1K family. + * It does this by setting variables to indicate which + * implementation dependent features are present in a particular + * member of the family. + * + * This is a good place to list all the known CPU models + * that this port supports and which RTEMS CPU model they correspond + * to. + */ + + /* + * Define the name of the CPU family and specific model. + */ + +#define CPU_NAME "OR1K" +#define CPU_MODEL_NAME "OR1200" + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_SCORE_OR1K_H */ diff --git a/cpukit/score/cpu/or1k/include/rtems/score/types.h b/cpukit/score/cpu/or1k/include/rtems/score/types.h new file mode 100644 index 0000000000..09790feb29 --- /dev/null +++ b/cpukit/score/cpu/or1k/include/rtems/score/types.h @@ -0,0 +1,53 @@ +/** + * @file + * + * @brief OR1K Architecture Types API + */ + +/* + * This include file contains type definitions pertaining to the + * arm processor family. + * + * COPYRIGHT (c) 2014 Hesham ALMatary + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + */ + + #ifndef _RTEMS_SCORE_TYPES_H +#define _RTEMS_SCORE_TYPES_H + +#include + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup ScoreCPU + */ +/**@{**/ + +/* + * This section defines the basic types for this processor. + */ + +/** Type that can store a 32-bit integer or a pointer. */ +typedef uintptr_t CPU_Uint32ptr; + +typedef void or1k_isr; +typedef void ( *or1k_isr_entry )( void ); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* !ASM */ + +#endif diff --git a/cpukit/score/cpu/or1k/preinstall.am b/cpukit/score/cpu/or1k/preinstall.am deleted file mode 100644 index eae1e46d14..0000000000 --- a/cpukit/score/cpu/or1k/preinstall.am +++ /dev/null @@ -1,57 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES += $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES += $(PREINSTALL_FILES) - -$(PROJECT_INCLUDE)/rtems/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems - @: > $(PROJECT_INCLUDE)/rtems/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/asm.h: rtems/asm.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/asm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/asm.h - -$(PROJECT_INCLUDE)/rtems/score/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/score - @: > $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/score/cpu.h: rtems/score/cpu.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpu.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpu.h - -$(PROJECT_INCLUDE)/rtems/score/cpuimpl.h: rtems/score/cpuimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h - -$(PROJECT_INCLUDE)/rtems/score/cpuatomic.h: rtems/score/cpuatomic.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h - -$(PROJECT_INCLUDE)/rtems/score/cpu_asm.h: rtems/score/cpu_asm.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpu_asm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpu_asm.h - -$(PROJECT_INCLUDE)/rtems/score/types.h: rtems/score/types.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/types.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/types.h - -$(PROJECT_INCLUDE)/rtems/score/or1k.h: rtems/score/or1k.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/or1k.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/or1k.h - -$(PROJECT_INCLUDE)/rtems/score/or1k-utility.h: rtems/score/or1k-utility.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/or1k-utility.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/or1k-utility.h - diff --git a/cpukit/score/cpu/or1k/rtems/asm.h b/cpukit/score/cpu/or1k/rtems/asm.h deleted file mode 100644 index 4d2c22698b..0000000000 --- a/cpukit/score/cpu/or1k/rtems/asm.h +++ /dev/null @@ -1,99 +0,0 @@ -/** - * @file rtems/asm.h - * - * This include file attempts to address the problems - * caused by incompatible flavors of assemblers and - * toolsets. It primarily addresses variations in the - * use of leading underscores on symbols and the requirement - * that register names be preceded by a %. - */ - -/* - * NOTE: The spacing in the use of these macros - * is critical to them working as advertised. - * - * COPYRIGHT: - * - * This file is based on similar code found in newlib available - * from ftp.cygnus.com. The file which was used had no copyright - * notice. This file is freely distributable as long as the source - * of the file is noted. This file is: - * - * COPYRIGHT (c) 1994-1997. - * On-Line Applications Research Corporation (OAR). - * - */ - -#ifndef __OR1K_ASM_h -#define __OR1K_ASM_h - -/* - * Indicate we are in an assembly file and get the basic CPU definitions. - */ - -#ifndef ASM -#define ASM -#endif -#include -#include - -/* - * Recent versions of GNU cpp define variables which indicate the - * need for underscores and percents. If not using GNU cpp or - * the version does not support this, then you will obviously - * have to define these as appropriate. - */ - -#ifndef __USER_LABEL_PREFIX__ -#define __USER_LABEL_PREFIX__ _ -#endif - -#ifndef __REGISTER_PREFIX__ -#define __REGISTER_PREFIX__ -#endif - -/* ANSI concatenation macros. */ - -#define CONCAT1(a, b) CONCAT2(a, b) -#define CONCAT2(a, b) a ## b - -/* Use the right prefix for global labels. */ - -#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) - -/* Use the right prefix for registers. */ - -#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) - -/* - * define macros for all of the registers on this CPU - * - * EXAMPLE: #define d0 REG (d0) - */ - -/* - * Define macros to handle section beginning and ends. - */ - - -#define BEGIN_CODE_DCL .text -#define END_CODE_DCL -#define BEGIN_DATA_DCL .data -#define END_DATA_DCL -#define BEGIN_CODE .text -#define END_CODE -#define BEGIN_DATA -#define END_DATA -#define BEGIN_BSS -#define END_BSS -#define END - -/* - * Following must be tailor for a particular flavor of the C compiler. - * They may need to put underscores in front of the symbols. - */ - -#define PUBLIC(sym) .global SYM (sym) -#define EXTERN(sym) .global SYM (sym) - -#endif diff --git a/cpukit/score/cpu/or1k/rtems/score/cpu.h b/cpukit/score/cpu/or1k/rtems/score/cpu.h deleted file mode 100644 index 6daca10f9c..0000000000 --- a/cpukit/score/cpu/or1k/rtems/score/cpu.h +++ /dev/null @@ -1,872 +0,0 @@ -/** - * @file rtems/score/cpu.h - */ - -/* - * This include file contains macros pertaining to the Opencores - * or1k processor family. - * - * COPYRIGHT (c) 2014 Hesham ALMatary - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - * - * This file adapted from no_cpu example of the RTEMS distribution. - * The body has been modified for the Opencores OR1k implementation by - * Chris Ziomkowski. - * - */ - -#ifndef _OR1K_CPU_H -#define _OR1K_CPU_H - -#ifdef __cplusplus -extern "C" { -#endif - - -#include /* pick up machine definitions */ -#include -#include -#ifndef ASM -#include -#include -#include /* for printk */ -#endif - -/* conditional compilation parameters */ - -/* - * Does RTEMS manage a dedicated interrupt stack in software? - * - * If TRUE, then a stack is allocated in _ISR_Handler_initialization. - * If FALSE, nothing is done. - * - * If the CPU supports a dedicated interrupt stack in hardware, - * then it is generally the responsibility of the BSP to allocate it - * and set it up. - * - * If the CPU does not support a dedicated interrupt stack, then - * the porter has two options: (1) execute interrupts on the - * stack of the interrupted task, and (2) have RTEMS manage a dedicated - * interrupt stack. - * - * If this is TRUE, CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. - * - * Only one of CPU_HAS_SOFTWARE_INTERRUPT_STACK and - * CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is - * possible that both are FALSE for a particular CPU. Although it - * is unclear what that would imply about the interrupt processing - * procedure on that CPU. - * - * Currently, for or1k port, _ISR_Handler is responsible for switching to - * RTEMS dedicated interrupt task. - * - */ - -#define CPU_HAS_SOFTWARE_INTERRUPT_STACK TRUE - -/* - * Does this CPU have hardware support for a dedicated interrupt stack? - * - * If TRUE, then it must be installed during initialization. - * If FALSE, then no installation is performed. - * - * If this is TRUE, CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. - * - * Only one of CPU_HAS_SOFTWARE_INTERRUPT_STACK and - * CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is - * possible that both are FALSE for a particular CPU. Although it - * is unclear what that would imply about the interrupt processing - * procedure on that CPU. - * - */ - -#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE - -/* - * Does RTEMS allocate a dedicated interrupt stack in the Interrupt Manager? - * - * If TRUE, then the memory is allocated during initialization. - * If FALSE, then the memory is allocated during initialization. - * - * This should be TRUE is CPU_HAS_SOFTWARE_INTERRUPT_STACK is TRUE - * or CPU_INSTALL_HARDWARE_INTERRUPT_STACK is TRUE. - * - */ - -#define CPU_ALLOCATE_INTERRUPT_STACK TRUE - -/* - * Does the RTEMS invoke the user's ISR with the vector number and - * a pointer to the saved interrupt frame (1) or just the vector - * number (0)? - * - */ - -#define CPU_ISR_PASSES_FRAME_POINTER TRUE - -/* - * Does the CPU have hardware floating point? - * - * If TRUE, then the RTEMS_FLOATING_POINT task attribute is supported. - * If FALSE, then the RTEMS_FLOATING_POINT task attribute is ignored. - * - * If there is a FP coprocessor such as the i387 or mc68881, then - * the answer is TRUE. - * - * The macro name "OR1K_HAS_FPU" should be made CPU specific. - * It indicates whether or not this CPU model has FP support. For - * example, it would be possible to have an i386_nofp CPU model - * which set this to false to indicate that you have an i386 without - * an i387 and wish to leave floating point support out of RTEMS. - * - * The CPU_SOFTWARE_FP is used to indicate whether or not there - * is software implemented floating point that must be context - * switched. The determination of whether or not this applies - * is very tool specific and the state saved/restored is also - * compiler specific. - * - * Or1k Specific Information: - * - * At this time there are no implementations of Or1k that are - * expected to implement floating point. More importantly, the - * floating point architecture is expected to change significantly - * before such chips are fabricated. - */ - -#define CPU_HARDWARE_FP FALSE -#define CPU_SOFTWARE_FP FALSE - -/* - * Are all tasks RTEMS_FLOATING_POINT tasks implicitly? - * - * If TRUE, then the RTEMS_FLOATING_POINT task attribute is assumed. - * If FALSE, then the RTEMS_FLOATING_POINT task attribute is followed. - * - * If CPU_HARDWARE_FP is FALSE, then this should be FALSE as well. - * - */ - -#define CPU_ALL_TASKS_ARE_FP FALSE - -/* - * Should the IDLE task have a floating point context? - * - * If TRUE, then the IDLE task is created as a RTEMS_FLOATING_POINT task - * and it has a floating point context which is switched in and out. - * If FALSE, then the IDLE task does not have a floating point context. - * - * Setting this to TRUE negatively impacts the time required to preempt - * the IDLE task from an interrupt because the floating point context - * must be saved as part of the preemption. - * - */ - -#define CPU_IDLE_TASK_IS_FP FALSE - -/* - * Should the saving of the floating point registers be deferred - * until a context switch is made to another different floating point - * task? - * - * If TRUE, then the floating point context will not be stored until - * necessary. It will remain in the floating point registers and not - * disturned until another floating point task is switched to. - * - * If FALSE, then the floating point context is saved when a floating - * point task is switched out and restored when the next floating point - * task is restored. The state of the floating point registers between - * those two operations is not specified. - * - * If the floating point context does NOT have to be saved as part of - * interrupt dispatching, then it should be safe to set this to TRUE. - * - * Setting this flag to TRUE results in using a different algorithm - * for deciding when to save and restore the floating point context. - * The deferred FP switch algorithm minimizes the number of times - * the FP context is saved and restored. The FP context is not saved - * until a context switch is made to another, different FP task. - * Thus in a system with only one FP task, the FP context will never - * be saved or restored. - * - */ - -#define CPU_USE_DEFERRED_FP_SWITCH TRUE - -#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE - -/* - * Does this port provide a CPU dependent IDLE task implementation? - * - * If TRUE, then the routine _CPU_Thread_Idle_body - * must be provided and is the default IDLE thread body instead of - * _CPU_Thread_Idle_body. - * - * If FALSE, then use the generic IDLE thread body if the BSP does - * not provide one. - * - * This is intended to allow for supporting processors which have - * a low power or idle mode. When the IDLE thread is executed, then - * the CPU can be powered down. - * - * The order of precedence for selecting the IDLE thread body is: - * - * 1. BSP provided - * 2. CPU dependent (if provided) - * 3. generic (if no BSP and no CPU dependent) - * - */ - -#define CPU_PROVIDES_IDLE_THREAD_BODY TRUE - -/* - * Does the stack grow up (toward higher addresses) or down - * (toward lower addresses)? - * - * If TRUE, then the grows upward. - * If FALSE, then the grows toward smaller addresses. - * - */ - -#define CPU_STACK_GROWS_UP FALSE - -/* FIXME: Is this the right value? */ -#define CPU_CACHE_LINE_BYTES 32 - -#define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES ) - -/* - * Define what is required to specify how the network to host conversion - * routines are handled. - * - * Or1k Specific Information: - * - * This version of RTEMS is designed specifically to run with - * big endian architectures. If you want little endian, you'll - * have to make the appropriate adjustments here and write - * efficient routines for byte swapping. The Or1k architecture - * doesn't do this very well. - */ - -#define CPU_HAS_OWN_HOST_TO_NETWORK_ROUTINES FALSE - -/* - * The following defines the number of bits actually used in the - * interrupt field of the task mode. How those bits map to the - * CPU interrupt levels is defined by the routine _CPU_ISR_Set_level(). - * - */ - -#define CPU_MODES_INTERRUPT_MASK 0x00000001 - -/* - * Processor defined structures required for cpukit/score. - */ - - -/* - * Contexts - * - * Generally there are 2 types of context to save. - * 1. Interrupt registers to save - * 2. Task level registers to save - * - * This means we have the following 3 context items: - * 1. task level context stuff:: Context_Control - * 2. floating point task stuff:: Context_Control_fp - * 3. special interrupt level context :: Context_Control_interrupt - * - * On some processors, it is cost-effective to save only the callee - * preserved registers during a task context switch. This means - * that the ISR code needs to save those registers which do not - * persist across function calls. It is not mandatory to make this - * distinctions between the caller/callee saves registers for the - * purpose of minimizing context saved during task switch and on interrupts. - * If the cost of saving extra registers is minimal, simplicity is the - * choice. Save the same context on interrupt entry as for tasks in - * this case. - * - * Additionally, if gdb is to be made aware of RTEMS tasks for this CPU, then - * care should be used in designing the context area. - * - * On some CPUs with hardware floating point support, the Context_Control_fp - * structure will not be used or it simply consist of an array of a - * fixed number of bytes. This is done when the floating point context - * is dumped by a "FP save context" type instruction and the format - * is not really defined by the CPU. In this case, there is no need - * to figure out the exact format -- only the size. Of course, although - * this is enough information for RTEMS, it is probably not enough for - * a debugger such as gdb. But that is another problem. - * - * - */ -#ifndef ASM -#ifdef OR1K_64BIT_ARCH -#define or1kreg uint64_t -#else -#define or1kreg uint32_t -#endif - -typedef struct { - uint32_t r1; /* Stack pointer */ - uint32_t r2; /* Frame pointer */ - uint32_t r3; - uint32_t r4; - uint32_t r5; - uint32_t r6; - uint32_t r7; - uint32_t r8; - uint32_t r9; - uint32_t r10; - uint32_t r11; - uint32_t r12; - uint32_t r13; - uint32_t r14; - uint32_t r15; - uint32_t r16; - uint32_t r17; - uint32_t r18; - uint32_t r19; - uint32_t r20; - uint32_t r21; - uint32_t r22; - uint32_t r23; - uint32_t r24; - uint32_t r25; - uint32_t r26; - uint32_t r27; - uint32_t r28; - uint32_t r29; - uint32_t r30; - uint32_t r31; - - uint32_t sr; /* Current supervision register non persistent values */ - uint32_t epcr; - uint32_t eear; - uint32_t esr; -} Context_Control; - -#define _CPU_Context_Get_SP( _context ) \ - (_context)->r1 - -typedef struct { - /** FPU registers are listed here */ - double some_float_register; -} Context_Control_fp; - -typedef Context_Control CPU_Interrupt_frame; - -/* - * The size of the floating point context area. On some CPUs this - * will not be a "sizeof" because the format of the floating point - * area is not defined -- only the size is. This is usually on - * CPUs with a "floating point save context" instruction. - * - * Or1k Specific Information: - * - */ - -#define CPU_CONTEXT_FP_SIZE 0 - -/* - * Amount of extra stack (above minimum stack size) required by - * MPCI receive server thread. Remember that in a multiprocessor - * system this thread must exist and be able to process all directives. - * - */ - -#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0 - -/* - * Should be large enough to run all RTEMS tests. This insures - * that a "reasonable" small application should not have any problems. - * - */ - -#define CPU_STACK_MINIMUM_SIZE 4096 - -/* - * CPU's worst alignment requirement for data types on a byte boundary. This - * alignment does not take into account the requirements for the stack. - * - */ - -#define CPU_ALIGNMENT 8 - -/* - * This is defined if the port has a special way to report the ISR nesting - * level. Most ports maintain the variable _ISR_Nest_level. - */ -#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE - -/** - * Size of a pointer. - * - * This must be an integer literal that can be used by the assembler. This - * value will be used to calculate offsets of structure members. These - * offsets will be used in assembler code. - */ -#define CPU_SIZEOF_POINTER 4 - -/* - * This number corresponds to the byte alignment requirement for the - * heap handler. This alignment requirement may be stricter than that - * for the data types alignment specified by CPU_ALIGNMENT. It is - * common for the heap to follow the same alignment requirement as - * CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict enough for the heap, - * then this should be set to CPU_ALIGNMENT. - * - * NOTE: This does not have to be a power of 2 although it should be - * a multiple of 2 greater than or equal to 2. The requirement - * to be a multiple of 2 is because the heap uses the least - * significant field of the front and back flags to indicate - * that a block is in use or free. So you do not want any odd - * length blocks really putting length data in that bit. - * - * On byte oriented architectures, CPU_HEAP_ALIGNMENT normally will - * have to be greater or equal to than CPU_ALIGNMENT to ensure that - * elements allocated from the heap meet all restrictions. - * - */ - -#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT - -/* - * This number corresponds to the byte alignment requirement for memory - * buffers allocated by the partition manager. This alignment requirement - * may be stricter than that for the data types alignment specified by - * CPU_ALIGNMENT. It is common for the partition to follow the same - * alignment requirement as CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict - * enough for the partition, then this should be set to CPU_ALIGNMENT. - * - * NOTE: This does not have to be a power of 2. It does have to - * be greater or equal to than CPU_ALIGNMENT. - * - */ - -#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT - -/* - * This number corresponds to the byte alignment requirement for the - * stack. This alignment requirement may be stricter than that for the - * data types alignment specified by CPU_ALIGNMENT. If the CPU_ALIGNMENT - * is strict enough for the stack, then this should be set to 0. - * - * NOTE: This must be a power of 2 either 0 or greater than CPU_ALIGNMENT. - * - */ - -#define CPU_STACK_ALIGNMENT 0 - -/* ISR handler macros */ - -/* - * Support routine to initialize the RTEMS vector table after it is allocated. - * - * NO_CPU Specific Information: - * - * XXX document implementation including references if appropriate - */ - -#define _CPU_Initialize_vectors() - -/* - * Disable all interrupts for an RTEMS critical section. The previous - * level is returned in _level. - * - */ - -static inline uint32_t or1k_interrupt_disable( void ) -{ - uint32_t sr; - sr = _OR1K_mfspr(CPU_OR1K_SPR_SR); - - _OR1K_mtspr(CPU_OR1K_SPR_SR, (sr & ~CPU_OR1K_SPR_SR_IEE)); - - return sr; -} - -static inline void or1k_interrupt_enable(uint32_t level) -{ - uint32_t sr; - - /* Enable interrupts and restore rs */ - sr = level | CPU_OR1K_SPR_SR_IEE | CPU_OR1K_SPR_SR_TEE; - _OR1K_mtspr(CPU_OR1K_SPR_SR, sr); - -} - -#define _CPU_ISR_Disable( _level ) \ - _level = or1k_interrupt_disable() - - -/* - * Enable interrupts to the previous level (returned by _CPU_ISR_Disable). - * This indicates the end of an RTEMS critical section. The parameter - * _level is not modified. - * - */ - -#define _CPU_ISR_Enable( _level ) \ - or1k_interrupt_enable( _level ) - -/* - * This temporarily restores the interrupt to _level before immediately - * disabling them again. This is used to divide long RTEMS critical - * sections into two or more parts. The parameter _level is not - * modified. - * - */ - -#define _CPU_ISR_Flash( _level ) \ - do{ \ - _CPU_ISR_Enable( _level ); \ - _OR1K_mtspr(CPU_OR1K_SPR_SR, (_level & ~CPU_OR1K_SPR_SR_IEE)); \ - } while(0) - -RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) -{ - return ( level & CPU_OR1K_SPR_SR ) != 0; -} - -/* - * Map interrupt level in task mode onto the hardware that the CPU - * actually provides. Currently, interrupt levels which do not - * map onto the CPU in a generic fashion are undefined. Someday, - * it would be nice if these were "mapped" by the application - * via a callout. For example, m68k has 8 levels 0 - 7, levels - * 8 - 255 would be available for bsp/application specific meaning. - * This could be used to manage a programmable interrupt controller - * via the rtems_task_mode directive. - * - * The get routine usually must be implemented as a subroutine. - * - */ - -void _CPU_ISR_Set_level( uint32_t level ); - -uint32_t _CPU_ISR_Get_level( void ); - -/* end of ISR handler macros */ - -/* Context handler macros */ - -#define OR1K_FAST_CONTEXT_SWITCH_ENABLED FALSE -/* - * Initialize the context to a state suitable for starting a - * task after a context restore operation. Generally, this - * involves: - * - * - setting a starting address - * - preparing the stack - * - preparing the stack and frame pointers - * - setting the proper interrupt level in the context - * - initializing the floating point context - * - * This routine generally does not set any unnecessary register - * in the context. The state of the "general data" registers is - * undefined at task start time. - * - * NOTE: This is_fp parameter is TRUE if the thread is to be a floating - * point thread. This is typically only used on CPUs where the - * FPU may be easily disabled by software such as on the SPARC - * where the PSR contains an enable FPU bit. - * - */ - -/** - * @brief Initializes the CPU context. - * - * The following steps are performed: - * - setting a starting address - * - preparing the stack - * - preparing the stack and frame pointers - * - setting the proper interrupt level in the context - * - * @param[in] context points to the context area - * @param[in] stack_area_begin is the low address of the allocated stack area - * @param[in] stack_area_size is the size of the stack area in bytes - * @param[in] new_level is the interrupt level for the task - * @param[in] entry_point is the task's entry point - * @param[in] is_fp is set to @c true if the task is a floating point task - * @param[in] tls_area is the thread-local storage (TLS) area - */ -void _CPU_Context_Initialize( - Context_Control *context, - void *stack_area_begin, - size_t stack_area_size, - uint32_t new_level, - void (*entry_point)( void ), - bool is_fp, - void *tls_area -); - -/* - * This routine is responsible for somehow restarting the currently - * executing task. If you are lucky, then all that is necessary - * is restoring the context. Otherwise, there will need to be - * a special assembly routine which does something special in this - * case. Context_Restore should work most of the time. It will - * not work if restarting self conflicts with the stack frame - * assumptions of restoring a context. - * - */ - -#define _CPU_Context_Restart_self( _the_context ) \ - _CPU_Context_restore( (_the_context) ); - -/* - * This routine is responsible to initialize the FP context. - * - * The FP area pointer is passed by reference to allow the initial pointer - * into a floating point context area (used to save the floating point - * context) to be at an arbitrary place in the floating point context area. - * - * This is necessary because some FP units are designed to have - * their context saved as a stack which grows into lower addresses. - * Other FP units can be saved by simply moving registers into offsets - * from the base of the context area. Finally some FP units provide - * a "dump context" instruction which could fill in from high to low - * or low to high based on the whim of the CPU designers. - */ -#define _CPU_Context_Initialize_fp( _fp_area_p ) \ - memset( *( _fp_area_p ), 0, CPU_CONTEXT_FP_SIZE ) - -/* end of Context handler macros */ - -/* Fatal Error manager macros */ - -/* - * This routine copies _error into a known place -- typically a stack - * location or a register, optionally disables interrupts, and - * halts/stops the CPU. - * - */ - -#include - -#define _CPU_Fatal_halt(_source, _error ) \ - printk("Fatal Error %d.%" PRId32 " Halted\n",_source, _error); \ - _OR1KSIM_CPU_Halt(); \ - for(;;) - -/* end of Fatal Error manager macros */ - -#define CPU_USE_GENERIC_BITFIELD_CODE TRUE - -#endif /* ASM */ - -#define CPU_SIZEOF_POINTER 4 - -#define CPU_MAXIMUM_PROCESSORS 32 - -#ifndef ASM -typedef uint32_t CPU_Counter_ticks; - -typedef struct { - uint32_t r[32]; - - /* The following registers must be saved if we have - fast context switch disabled and nested interrupt - levels are enabled. - */ -#if !OR1K_FAST_CONTEXT_SWITCH_ENABLED - uint32_t epcr; /* exception PC register */ - uint32_t eear; /* exception effective address register */ - uint32_t esr; /* exception supervision register */ -#endif - -} CPU_Exception_frame; - -/** - * @brief Prints the exception frame via printk(). - * - * @see rtems_fatal() and RTEMS_FATAL_SOURCE_EXCEPTION. - */ -void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); - - -/* end of Priority handler macros */ - -/* functions */ - -/* - * _CPU_Initialize - * - * This routine performs CPU dependent initialization. - * - */ - -void _CPU_Initialize( - void -); - -/* - * _CPU_ISR_install_raw_handler - * - * This routine installs a "raw" interrupt handler directly into the - * processor's vector table. - * - */ - -void _CPU_ISR_install_raw_handler( - uint32_t vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -/* - * _CPU_ISR_install_vector - * - * This routine installs an interrupt vector. - * - * NO_CPU Specific Information: - * - * XXX document implementation including references if appropriate - */ - -void _CPU_ISR_install_vector( - uint32_t vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -/* - * _CPU_Install_interrupt_stack - * - * This routine installs the hardware interrupt stack pointer. - * - * NOTE: It need only be provided if CPU_HAS_HARDWARE_INTERRUPT_STACK - * is TRUE. - * - */ - -void _CPU_Install_interrupt_stack( void ); - -/* - * _CPU_Thread_Idle_body - * - * This routine is the CPU dependent IDLE thread body. - * - * NOTE: It need only be provided if CPU_PROVIDES_IDLE_THREAD_BODY - * is TRUE. - * - */ - -void *_CPU_Thread_Idle_body( uintptr_t ignored ); - -/* - * _CPU_Context_switch - * - * This routine switches from the run context to the heir context. - * - * Or1k Specific Information: - * - * Please see the comments in the .c file for a description of how - * this function works. There are several things to be aware of. - */ - -void _CPU_Context_switch( - Context_Control *run, - Context_Control *heir -); - -/* - * _CPU_Context_restore - * - * This routine is generally used only to restart self in an - * efficient manner. It may simply be a label in _CPU_Context_switch. - * - * NOTE: May be unnecessary to reload some registers. - * - */ - -void _CPU_Context_restore( - Context_Control *new_context -) RTEMS_NO_RETURN; - -/* - * _CPU_Context_save_fp - * - * This routine saves the floating point context passed to it. - * - */ - -void _CPU_Context_save_fp( - void **fp_context_ptr -); - -/* - * _CPU_Context_restore_fp - * - * This routine restores the floating point context passed to it. - * - */ - -void _CPU_Context_restore_fp( - void **fp_context_ptr -); - -/* The following routine swaps the endian format of an unsigned int. - * It must be static because it is referenced indirectly. - * - * This version will work on any processor, but if there is a better - * way for your CPU PLEASE use it. The most common way to do this is to: - * - * swap least significant two bytes with 16-bit rotate - * swap upper and lower 16-bits - * swap most significant two bytes with 16-bit rotate - * - * Some CPUs have special instructions which swap a 32-bit quantity in - * a single instruction (e.g. i486). It is probably best to avoid - * an "endian swapping control bit" in the CPU. One good reason is - * that interrupts would probably have to be disabled to insure that - * an interrupt does not try to access the same "chunk" with the wrong - * endian. Another good reason is that on some CPUs, the endian bit - * endianness for ALL fetches -- both code and data -- so the code - * will be fetched incorrectly. - * - */ - -void _CPU_Context_volatile_clobber( uintptr_t pattern ); - -void _CPU_Context_validate( uintptr_t pattern ); - -static inline unsigned int CPU_swap_u32( - unsigned int value -) -{ - uint32_t byte1, byte2, byte3, byte4, swapped; - - byte4 = (value >> 24) & 0xff; - byte3 = (value >> 16) & 0xff; - byte2 = (value >> 8) & 0xff; - byte1 = value & 0xff; - - swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4; - return( swapped ); -} - -#define CPU_swap_u16( value ) \ - (((value&0xff) << 8) | ((value >> 8)&0xff)) - -typedef uint32_t CPU_Counter_ticks; - -CPU_Counter_ticks _CPU_Counter_read( void ); - -CPU_Counter_ticks _CPU_Counter_difference( - CPU_Counter_ticks second, - CPU_Counter_ticks first -); - -#endif /* ASM */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/score/cpu/or1k/rtems/score/cpu_asm.h b/cpukit/score/cpu/or1k/rtems/score/cpu_asm.h deleted file mode 100644 index a5659f35ce..0000000000 --- a/cpukit/score/cpu/or1k/rtems/score/cpu_asm.h +++ /dev/null @@ -1,74 +0,0 @@ -/** - * @file - * - * @brief OR1K Assembly File - * - * Very loose template for an include file for the cpu_asm.? file - * if it is implemented as a ".S" file (preprocessed by cpp) instead - * of a ".s" file (preprocessed by gm4 or gasp). - */ - -/* - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - * - */ - -#ifndef _RTEMS_SCORE_CPU_ASM_H -#define _RTEMS_SCORE_CPU_ASM_H - -/* pull in the generated offsets */ - -/* -#include -*/ - -/* - * Hardware General Registers - */ - -/* put something here */ - -/* - * Hardware Floating Point Registers - */ - -/* put something here */ - -/* - * Hardware Control Registers - */ - -/* put something here */ - -/* - * Calling Convention - */ - -/* put something here */ - -/* - * Temporary registers - */ - -/* put something here */ - -/* - * Floating Point Registers - SW Conventions - */ - -/* put something here */ - -/* - * Temporary floating point registers - */ - -/* put something here */ - -#endif - -/* end of file */ diff --git a/cpukit/score/cpu/or1k/rtems/score/cpuatomic.h b/cpukit/score/cpu/or1k/rtems/score/cpuatomic.h deleted file mode 100644 index 598ee76b20..0000000000 --- a/cpukit/score/cpu/or1k/rtems/score/cpuatomic.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * COPYRIGHT (c) 2012-2013 Deng Hengyi. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_ATOMIC_CPU_H -#define _RTEMS_SCORE_ATOMIC_CPU_H - -#include - -#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/or1k/rtems/score/cpuimpl.h b/cpukit/score/cpu/or1k/rtems/score/cpuimpl.h deleted file mode 100644 index 789f2badd9..0000000000 --- a/cpukit/score/cpu/or1k/rtems/score/cpuimpl.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @file - * - * @brief CPU Port Implementation API - */ - -/* - * Copyright (c) 2013 embedded brains GmbH - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPUIMPL_H -#define _RTEMS_SCORE_CPUIMPL_H - -#include - -#define CPU_PER_CPU_CONTROL_SIZE 0 - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* ASM */ - -#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/or1k/rtems/score/or1k-utility.h b/cpukit/score/cpu/or1k/rtems/score/or1k-utility.h deleted file mode 100644 index 98bbe41b00..0000000000 --- a/cpukit/score/cpu/or1k/rtems/score/or1k-utility.h +++ /dev/null @@ -1,396 +0,0 @@ -/** - * @file - * - * @brief OR1K utility - */ -/* - * COPYRIGHT (c) 2014 Hesham ALMatary - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_OR1K_UTILITY_H -#define _RTEMS_SCORE_OR1K_UTILITY_H - -/* SPR groups definitions */ -#define SPR_GRP_SHAMT 11 -#define SPR_GRP0_SYS_CTRL (0 << SPR_GRP_SHAMT) -#define SPR_GRP1_DMMU (1 << SPR_GRP_SHAMT) -#define SPR_GRP2_IMMU (2 << SPR_GRP_SHAMT) -#define SPR_GRP3_DC (3 << SPR_GRP_SHAMT) -#define SPR_GRP4_IC (4 << SPR_GRP_SHAMT) -#define SPR_GRP5_MAC (5 << SPR_GRP_SHAMT) -#define SPR_GRP6_DEBUG (6 << SPR_GRP_SHAMT) -#define SPR_GRP7_PERF_CTR (7 << SPR_GRP_SHAMT) -#define SPR_GRP8_PWR_MNG (8 << SPR_GRP_SHAMT) -#define SPR_GRP9_PIC (9 << SPR_GRP_SHAMT) -#define SPR_GPR10_TICK_TMR (10 << SPR_GRP_SHAMT) -#define SPR_GPR11_FPU (11 << SPR_GRP_SHAMT) - -/* SPR registers definitions */ - -/* Group 0: System control registers */ -#define CPU_OR1K_SPR_VR (SPR_GRP0_SYS_CTRL + 0) -#define CPU_OR1K_SPR_UPR (SPR_GRP0_SYS_CTRL + 1) -#define CPU_OR1K_SPR_CPUCFGR (SPR_GRP0_SYS_CTRL + 2) -#define CPU_OR1K_SPR_DMMUCFGR (SPR_GRP0_SYS_CTRL + 3) -#define CPU_OR1K_SPR_IMMUCFGR (SPR_GRP0_SYS_CTRL + 4) -#define CPU_OR1K_SPR_DCCFGR (SPR_GRP0_SYS_CTRL + 5) -#define CPU_OR1K_SPR_ICCFGR (SPR_GRP0_SYS_CTRL + 6) -#define CPU_OR1K_SPR_DCFGR (SPR_GRP0_SYS_CTRL + 7) -#define CPU_OR1K_SPR_PCCFGR (SPR_GRP0_SYS_CTRL + 8) -#define CPU_OR1K_SPR_VR2 (SPR_GRP0_SYS_CTRL + 9) -#define CPU_OR1K_SPR_AVR (SPR_GRP0_SYS_CTRL + 10) -#define CPU_OR1K_SPR_EVBAR (SPR_GRP0_SYS_CTRL + 11) -#define CPU_OR1K_SPR_AECR (SPR_GRP0_SYS_CTRL + 12) -#define CPU_OR1K_SPR_AESR (SPR_GRP0_SYS_CTRL + 13) -#define CPU_OR1K_SPR_NPC (SPR_GRP0_SYS_CTRL + 16) -#define CPU_OR1K_SPR_SR (SPR_GRP0_SYS_CTRL + 17) -#define CPU_OR1K_SPR_PPC (SPR_GRP0_SYS_CTRL + 18) -#define CPU_OR1K_SPR_FPCSR (SPR_GRP0_SYS_CTRL + 20) -#define CPU_OR1K_SPR_EPCR0 (SPR_GRP0_SYS_CTRL + 32) -#define CPU_OR1K_SPR_EPCR1 (SPR_GRP0_SYS_CTRL + 33) -#define CPU_OR1K_SPR_EPCR2 (SPR_GRP0_SYS_CTRL + 34) -#define CPU_OR1K_SPR_EPCR3 (SPR_GRP0_SYS_CTRL + 35) -#define CPU_OR1K_SPR_EPCR4 (SPR_GRP0_SYS_CTRL + 36) -#define CPU_OR1K_SPR_EPCR5 (SPR_GRP0_SYS_CTRL + 37) -#define CPU_OR1K_SPR_EPCR6 (SPR_GRP0_SYS_CTRL + 38) -#define CPU_OR1K_SPR_EPCR7 (SPR_GRP0_SYS_CTRL + 39) -#define CPU_OR1K_SPR_EPCR8 (SPR_GRP0_SYS_CTRL + 40) -#define CPU_OR1K_SPR_EPCR9 (SPR_GRP0_SYS_CTRL + 41) -#define CPU_OR1K_SPR_EPCR10 (SPR_GRP0_SYS_CTRL + 42) -#define CPU_OR1K_SPR_EPCR11 (SPR_GRP0_SYS_CTRL + 43) -#define CPU_OR1K_SPR_EPCR12 (SPR_GRP0_SYS_CTRL + 44) -#define CPU_OR1K_SPR_EPCR13 (SPR_GRP0_SYS_CTRL + 45) -#define CPU_OR1K_SPR_EPCR14 (SPR_GRP0_SYS_CTRL + 46) -#define CPU_OR1K_SPR_EPCR15 (SPR_GRP0_SYS_CTRL + 47) -#define CPU_OR1K_SPR_EEAR0 (SPR_GRP0_SYS_CTRL + 48) -#define CPU_OR1K_SPR_EEAR1 (SPR_GRP0_SYS_CTRL + 49) -#define CPU_OR1K_SPR_EEAR2 (SPR_GRP0_SYS_CTRL + 50) -#define CPU_OR1K_SPR_EEAR3 (SPR_GRP0_SYS_CTRL + 51) -#define CPU_OR1K_SPR_EEAR4 (SPR_GRP0_SYS_CTRL + 52) -#define CPU_OR1K_SPR_EEAR5 (SPR_GRP0_SYS_CTRL + 53) -#define CPU_OR1K_SPR_EEAR6 (SPR_GRP0_SYS_CTRL + 54) -#define CPU_OR1K_SPR_EEAR7 (SPR_GRP0_SYS_CTRL + 55) -#define CPU_OR1K_SPR_EEAR8 (SPR_GRP0_SYS_CTRL + 56) -#define CPU_OR1K_SPR_EEAR9 (SPR_GRP0_SYS_CTRL + 57) -#define CPU_OR1K_SPR_EEAR10 (SPR_GRP0_SYS_CTRL + 58) -#define CPU_OR1K_SPR_EEAR11 (SPR_GRP0_SYS_CTRL + 59) -#define CPU_OR1K_SPR_EEAR12 (SPR_GRP0_SYS_CTRL + 60) -#define CPU_OR1K_SPR_EEAR13 (SPR_GRP0_SYS_CTRL + 61) -#define CPU_OR1K_SPR_EEAR14 (SPR_GRP0_SYS_CTRL + 62) -#define CPU_OR1K_SPR_EEAR15 (SPR_GRP0_SYS_CTRL + 63) -#define CPU_OR1K_SPR_ESR0 (SPR_GRP0_SYS_CTRL + 64) -#define CPU_OR1K_SPR_ESR1 (SPR_GRP0_SYS_CTRL + 65) -#define CPU_OR1K_SPR_ESR2 (SPR_GRP0_SYS_CTRL + 66) -#define CPU_OR1K_SPR_ESR3 (SPR_GRP0_SYS_CTRL + 67) -#define CPU_OR1K_SPR_ESR4 (SPR_GRP0_SYS_CTRL + 68) -#define CPU_OR1K_SPR_ESR5 (SPR_GRP0_SYS_CTRL + 69) -#define CPU_OR1K_SPR_ESR6 (SPR_GRP0_SYS_CTRL + 70) -#define CPU_OR1K_SPR_ESR7 (SPR_GRP0_SYS_CTRL + 71) -#define CPU_OR1K_SPR_ESR8 (SPR_GRP0_SYS_CTRL + 72) -#define CPU_OR1K_SPR_ESR9 (SPR_GRP0_SYS_CTRL + 73) -#define CPU_OR1K_SPR_ESR10 (SPR_GRP0_SYS_CTRL + 74) -#define CPU_OR1K_SPR_ESR11 (SPR_GRP0_SYS_CTRL + 75) -#define CPU_OR1K_SPR_ESR12 (SPR_GRP0_SYS_CTRL + 76) -#define CPU_OR1K_SPR_ESR13 (SPR_GRP0_SYS_CTRL + 77) -#define CPU_OR1K_SPR_ESR14 (SPR_GRP0_SYS_CTRL + 78) -#define CPU_OR1K_SPR_ESR15 (SPR_GRP0_SYS_CTRL + 79) - -/* Shadow registers base */ -#define CPU_OR1K_SPR_GPR32 (SPR_GRP0_SYS_CTRL + 1024) - -/* Group1: Data MMU registers */ -#define CPU_OR1K_SPR_DMMUCR (SPR_GRP1_DMMU + 0) -#define CPU_OR1K_SPR_DMMUPR (SPR_GRP1_DMMU + 1) -#define CPU_OR1K_SPR_DTLBEIR (SPR_GRP1_DMMU + 2) -#define CPU_OR1K_SPR_DATBMR0 (SPR_GRP1_DMMU + 4) -#define CPU_OR1K_SPR_DATBMR1 (SPR_GRP1_DMMU + 5) -#define CPU_OR1K_SPR_DATBMR2 (SPR_GRP1_DMMU + 6) -#define CPU_OR1K_SPR_DATBMR3 (SPR_GRP1_DMMU + 7) -#define CPU_OR1K_SPR_DATBTR0 (SPR_GRP1_DMMU + 8) -#define CPU_OR1K_SPR_DATBTR1 (SPR_GRP1_DMMU + 9) -#define CPU_OR1K_SPR_DATBTR2 (SPR_GRP1_DMMU + 10) -#define CPU_OR1K_SPR_DATBTR3 (SPR_GRP1_DMMU + 11) - -/* Group2: Instruction MMU registers */ -#define CPU_OR1K_SPR_IMMUCR (SPR_GRP2_IMMU + 0) -#define CPU_OR1K_SPR_IMMUPR (SPR_GRP2_IMMU + 1) -#define CPU_OR1K_SPR_ITLBEIR (SPR_GRP2_IMMU + 2) -#define CPU_OR1K_SPR_IATBMR0 (SPR_GRP2_IMMU + 4) -#define CPU_OR1K_SPR_IATBMR1 (SPR_GRP2_IMMU + 5) -#define CPU_OR1K_SPR_IATBMR2 (SPR_GRP2_IMMU + 6) -#define CPU_OR1K_SPR_IATBMR3 (SPR_GRP2_IMMU + 7) -#define CPU_OR1K_SPR_IATBTR0 (SPR_GRP2_IMMU + 8) -#define CPU_OR1K_SPR_IATBTR1 (SPR_GRP2_IMMU + 9) -#define CPU_OR1K_SPR_IATBTR2 (SPR_GRP2_IMMU + 10) -#define CPU_OR1K_SPR_IATBTR3 (SPR_GRP2_IMMU + 11) - -/* Group3: Data Cache registers */ -#define CPU_OR1K_SPR_DCCR (SPR_GRP3_DC + 0) -#define CPU_OR1K_SPR_DCBPR (SPR_GRP3_DC + 1) -#define CPU_OR1K_SPR_DCBFR (SPR_GRP3_DC + 2) -#define CPU_OR1K_SPR_DCBIR (SPR_GRP3_DC + 3) -#define CPU_OR1K_SPR_DCBWR (SPR_GRP3_DC + 4) -#define CPU_OR1K_SPR_DCBLR (SPR_GRP3_DC + 5) - -/* Group4: Instruction Cache registers */ -#define CPU_OR1K_SPR_ICCR (SPR_GRP4_IC + 0) -#define CPU_OR1K_SPR_ICBPR (SPR_GRP4_IC + 1) -#define CPU_OR1K_SPR_ICBIR (SPR_GRP4_IC + 2) -#define CPU_OR1K_SPR_ICBLR (SPR_GRP4_IC + 3) - -/* Group5: MAC registers */ -#define CPU_OR1K_SPR_MACLO (SPR_GRP5_MAC + 1) -#define CPU_OR1K_SPR_MACHI (SPR_GRP5_MAC + 2) - -/* Group6: Debug registers */ -#define CPU_OR1K_SPR_DVR0 (SPR_GRP6_DEBUG + 0) -#define CPU_OR1K_SPR_DVR1 (SPR_GRP6_DEBUG + 1) -#define CPU_OR1K_SPR_DVR2 (SPR_GRP6_DEBUG + 2) -#define CPU_OR1K_SPR_DVR3 (SPR_GRP6_DEBUG + 3) -#define CPU_OR1K_SPR_DVR4 (SPR_GRP6_DEBUG + 4) -#define CPU_OR1K_SPR_DVR5 (SPR_GRP6_DEBUG + 5) -#define CPU_OR1K_SPR_DVR6 (SPR_GRP6_DEBUG + 6) -#define CPU_OR1K_SPR_DVR7 (SPR_GRP6_DEBUG + 7) -#define CPU_OR1K_SPR_DCR0 (SPR_GRP6_DEBUG + 8) -#define CPU_OR1K_SPR_DCR1 (SPR_GRP6_DEBUG + 9) -#define CPU_OR1K_SPR_DCR2 (SPR_GRP6_DEBUG + 10) -#define CPU_OR1K_SPR_DCR3 (SPR_GRP6_DEBUG + 11) -#define CPU_OR1K_SPR_DCR4 (SPR_GRP6_DEBUG + 12) -#define CPU_OR1K_SPR_DCR5 (SPR_GRP6_DEBUG + 13) -#define CPU_OR1K_SPR_DCR6 (SPR_GRP6_DEBUG + 14) -#define CPU_OR1K_SPR_DCR7 (SPR_GRP6_DEBUG + 15) -#define CPU_OR1K_SPR_DMR1 (SPR_GRP6_DEBUG + 16) -#define CPU_OR1K_SPR_DMR2 (SPR_GRP6_DEBUG + 17) -#define CPU_OR1K_SPR_DCWR0 (SPR_GRP6_DEBUG + 18) -#define CPU_OR1K_SPR_DCWR1 (SPR_GRP6_DEBUG + 19) -#define CPU_OR1K_SPR_DSR (SPR_GRP6_DEBUG + 20) -#define CPU_OR1K_SPR_DRR (SPR_GRP6_DEBUG + 21) - -/* Group7: Performance counters registers */ -#define CPU_OR1K_SPR_PCCR0 (SPR_GRP7_PERF_CTR + 0) -#define CPU_OR1K_SPR_PCCR1 (SPR_GRP7_PERF_CTR + 1) -#define CPU_OR1K_SPR_PCCR2 (SPR_GRP7_PERF_CTR + 2) -#define CPU_OR1K_SPR_PCCR3 (SPR_GRP7_PERF_CTR + 3) -#define CPU_OR1K_SPR_PCCR4 (SPR_GRP7_PERF_CTR + 4) -#define CPU_OR1K_SPR_PCCR5 (SPR_GRP7_PERF_CTR + 5) -#define CPU_OR1K_SPR_PCCR6 (SPR_GRP7_PERF_CTR + 6) -#define CPU_OR1K_SPR_PCCR7 (SPR_GRP7_PERF_CTR + 7) -#define CPU_OR1K_SPR_PCMR0 (SPR_GRP7_PERF_CTR + 8) -#define CPU_OR1K_SPR_PCMR1 (SPR_GRP7_PERF_CTR + 9) -#define CPU_OR1K_SPR_PCMR2 (SPR_GRP7_PERF_CTR + 10) -#define CPU_OR1K_SPR_PCMR3 (SPR_GRP7_PERF_CTR + 11) -#define CPU_OR1K_SPR_PCMR4 (SPR_GRP7_PERF_CTR + 12) -#define CPU_OR1K_SPR_PCMR5 (SPR_GRP7_PERF_CTR + 13) -#define CPU_OR1K_SPR_PCMR6 (SPR_GRP7_PERF_CTR + 14) -#define CPU_OR1K_SPR_PCMR7 (SPR_GRP7_PERF_CTR + 15) - -/* Group8: Power management register */ -#define CPU_OR1K_SPR_PMR (SPR_GRP8_PWR_MNG + 0) - -/* Group9: PIC registers */ -#define CPU_OR1K_SPR_PICMR (SPR_GRP9_PIC + 0) -#define CPU_OR1K_SPR_PICSR (SPR_GRP9_PIC + 2) - -/* Group10: Tick Timer registers */ -#define CPU_OR1K_SPR_TTMR (SPR_GPR10_TICK_TMR + 0) -#define CPU_OR1K_SPR_TTCR (SPR_GPR10_TICK_TMR + 1) - - /* Shift amount macros for bits position in Supervision Register */ -#define CPU_OR1K_SPR_SR_SHAMT_SM (0) -#define CPU_OR1K_SPR_SR_SHAMT_TEE (1) -#define CPU_OR1K_SPR_SR_SHAMT_IEE (2) -#define CPU_OR1K_SPR_SR_SHAMT_DCE (3) -#define CPU_OR1K_SPR_SR_SHAMT_ICE (4) -#define CPU_OR1K_SPR_SR_SHAMT_DME (5) -#define CPU_OR1K_SPR_SR_SHAMT_IME (6) -#define CPU_OR1K_SPR_SR_SHAMT_LEE (7) -#define CPU_OR1K_SPR_SR_SHAMT_CE (8) -#define CPU_OR1K_SPR_SR_SHAMT_F (9) -#define CPU_OR1K_SPR_SR_SHAMT_CY (10) -#define CPU_OR1K_SPR_SR_SHAMT_OV (11) -#define CPU_OR1K_SPR_SR_SHAMT_OVE (12) -#define CPU_OR1K_SPR_SR_SHAMT_DSX (13) -#define CPU_OR1K_SPR_SR_SHAMT_EPH (14) -#define CPU_OR1K_SPR_SR_SHAMT_FO (15) -#define CPU_OR1K_SPR_SR_SHAMT_SUMRA (16) -#define CPU_OR1K_SPR_SR_SHAMT_CID (28) - -/* Supervision Mode Register. @see OpenRISC architecture manual*/ - - /* Supervisor Mode */ -#define CPU_OR1K_SPR_SR_SM (1 << CPU_OR1K_SPR_SR_SHAMT_SM) -/* Tick Timer Exception Enabled */ -#define CPU_OR1K_SPR_SR_TEE (1 << CPU_OR1K_SPR_SR_SHAMT_TEE) -/* Interrupt Exception Enabled */ -#define CPU_OR1K_SPR_SR_IEE (1 << CPU_OR1K_SPR_SR_SHAMT_IEE) -/* Data Cache Enable */ -#define CPU_OR1K_SPR_SR_DCE (1 << CPU_OR1K_SPR_SR_SHAMT_DCE) -/* Instruction Cache Enable */ -#define CPU_OR1K_SPR_SR_ICE (1 << CPU_OR1K_SPR_SR_SHAMT_ICE) -/* Data MMU Enable */ -#define CPU_OR1K_SPR_SR_DME (1 << CPU_OR1K_SPR_SR_SHAMT_DME) -/* Instruction MMU Enable */ -#define CPU_OR1K_SPR_SR_IME (1 << CPU_OR1K_SPR_SR_SHAMT_IME) -/* Little Endian Enable */ -#define CPU_OR1K_SPR_SR_LEE (1 << CPU_OR1K_SPR_SR_SHAMT_LEE) -/* CID Enable */ -#define CPU_OR1K_SPR_SR_CE (1 << CPU_OR1K_SPR_SR_SHAMT_CE) -/* Conditional branch flag */ -#define CPU_OR1K_SPR_SR_F (1 << CPU_OR1K_SPR_SR_SHAMT_F) -/* Carry flag */ -#define CPU_OR1K_SPR_SR_CY (1 << CPU_OR1K_SPR_SR_SHAMT_CY) -/* Overflow flag */ -#define CPU_OR1K_SPR_SR_OV (1 << CPU_OR1K_SPR_SR_SHAMT_OV) -/* Overflow flag Exception */ -#define CPU_OR1K_SPR_SR_OVE (1 << CPU_OR1K_SPR_SR_SHAMT_OVE) -/* Delay Slot Exception */ -#define CPU_OR1K_SPR_SR_DSX (1 << CPU_OR1K_SPR_SR_SHAMT_DSX) - /* Exception Prefix High */ -#define CPU_OR1K_SPR_SR_EPH (1 << CPU_OR1K_SPR_SR_SHAMT_EPH) -/* Fixed One */ -#define CPU_OR1K_SPR_SR_FO (1 << CPU_OR1K_SPR_SR_SHAMT_FO) -/* SPRs User Mode Read Access */ -#define CPU_OR1K_SPR_SR_SUMRA (1 << CPU_OR1K_SPR_SR_SHAMT_SUMRA) -/*Context ID (Fast Context Switching) */ -#define CPU_OR1K_SPR_SR_CID (F << CPU_OR1K_SPR_SR_SHAMT_CID) - -/* Tick timer configuration bits */ -#define CPU_OR1K_SPR_TTMR_SHAMT_IP 28 -#define CPU_OR1K_SPR_TTMR_SHAMT_IE 29 -#define CPU_OR1K_SPR_TTMR_SHAMT_MODE 30 - -#define CPU_OR1K_SPR_TTMR_TP_MASK (0x0FFFFFFF) -#define CPU_OR1K_SPR_TTMR_IP (1 << CPU_OR1K_SPR_TTMR_SHAMT_IP) -#define CPU_OR1K_SPR_TTMR_IE (1 << CPU_OR1K_SPR_TTMR_SHAMT_IE) -#define CPU_OR1K_SPR_TTMR_MODE_RESTART (1 << CPU_OR1K_SPR_TTMR_SHAMT_MODE) -#define CPU_OR1K_SPR_TTMR_MODE_ONE_SHOT (2 << CPU_OR1K_SPR_TTMR_SHAMT_MODE) -#define CPU_OR1K_SPR_TTMR_MODE_CONT (3 << CPU_OR1K_SPR_TTMR_SHAMT_MODE) - -/* Power management register bits */ - -/* Shift amount macros for bit positions in Power Management register */ -#define CPU_OR1K_SPR_PMR_SHAMT_SDF 0 -#define CPU_OR1K_SPR_PMR_SHAMT_DME 4 -#define CPU_OR1K_SPR_PMR_SHAMT_SME 5 -#define CPU_OR1K_SPR_PMR_SHAMT_DCGE 6 -#define CPU_OR1K_SPR_PMR_SHAMT_SUME 7 - -#define CPU_OR1K_SPR_PMR_SDF (0xF << CPU_OR1K_SPR_PMR_SHAMT_SDF) -#define CPU_OR1K_SPR_PMR_DME (1 << CPU_OR1K_SPR_PMR_SHAMT_DME) -#define CPU_OR1K_SPR_PMR_SME (1 << CPU_OR1K_SPR_PMR_SHAMT_SME) -#define CPU_OR1K_SPR_PMR_DCGE (1 << CPU_OR1K_SPR_PMR_SHAMT_DCGE) -#define CPU_OR1K_SPR_PMR_SUME (1 << CPU_OR1K_SPR_PMR_SHAMT_SUME) - -#ifndef ASM - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @brief Supervision Mode registers definitions. - * - * @see OpenRISC architecture manual - revision 0. - */ -typedef enum { - OR1K_EXCEPTION_RESET = 1, - OR1K_EXCEPTION_BUS_ERR = 2, - OR1K_EXCEPTION_D_PF = 3, /* Data Page Fault */ - OR1K_EXCEPTION_I_PF = 4, /* Instruction Page Fault */ - OR1K_EXCEPTION_TICK_TIMER = 5, - OR1K_EXCEPTION_ALIGNMENT = 6, - OR1K_EXCEPTION_I_UNDEF= 7, /* Undefiend instruction */ - OR1K_EXCEPTION_IRQ = 8, /* External interrupt */ - OR1K_EXCPETION_D_TLB = 9, /* Data TLB miss */ - OR1K_EXCPETION_I_TLB = 10, /* Instruction TLB miss */ - OR1K_EXCPETION_RANGE = 11, /* Range exception */ - OR1K_EXCPETION_SYS_CALL = 12, - OR1K_EXCPETION_FP = 13, /* Floating point exception */ - OR1K_EXCPETION_TRAP = 14, /* Caused by l.trap instruction or by debug unit */ - OR1K_EXCPETION_RESERVED1 = 15, - OR1K_EXCPETION_RESERVED2 = 16, - OR1K_EXCPETION_RESERVED3 = 17, - MAX_EXCEPTIONS = 17, - OR1K_EXCEPTION_MAKE_ENUM_32_BIT = 0xffffffff -} OR1K_Symbolic_exception_name; - -static inline uint32_t _OR1K_mfspr(uint32_t reg) -{ - uint32_t spr_value; - - asm volatile ( - "l.mfspr %0, %1, 0;\n\t" - : "=r" (spr_value) : "r" (reg)); - - return spr_value; -} - -static inline void _OR1K_mtspr(uint32_t reg, uint32_t value) -{ - asm volatile ( - "l.mtspr %1, %0, 0;\n\t" - :: "r" (value), "r" (reg) - ); -} - -/** - * @brief The slow down feature takes advantage of the low-power - * dividers in external clock generation circuitry to enable full - * functionality, but at a lower frequency so that power consumption - * is reduced. @see OpenRISC architecture manual, power management section. - * - * @param[in] value is 4 bit value to be written in PMR[SDF]. - * A lower value specifies higher expected performance from the processor core. - * - */ -#define _OR1K_CPU_SlowDown(value) \ - _OR1K_mtspr(CPU_OR1K_SPR_PMR, (value & CPU_OR1K_SPR_PMR_SDF)) - - -#define _OR1K_CPU_Doze() \ - _OR1K_mtspr(CPU_OR1K_SPR_PMR, CPU_OR1K_SPR_PMR_DME) - - -#define _OR1K_CPU_Sleep() \ - _OR1K_mtspr(CPU_OR1K_SPR_PMR, CPU_OR1K_SPR_PMR_SME) - -#define _OR1K_CPU_Suspend() \ - _OR1K_mtspr(CPU_OR1K_SPR_PMR, CPU_OR1K_SPR_PMR_SME) - -static inline void _OR1K_Sync_mem( void ) -{ - asm volatile("l.msync"); -} - -static inline void _OR1K_Sync_pipeline( void ) -{ - asm volatile("l.psync"); -} - -/** - * @brief or1ksim simulator can be sent a halt signal from RTEMS to tell - * the running or1ksim process on the host machine to exit. The following - * implementation has no effect on QEMU or hardware implementation and will - * be treated as normal l.nop. - * - */ -#define _OR1KSIM_CPU_Halt() \ - asm volatile ("l.nop 0xc") - -#ifdef __cplusplus -} -#endif - -#else /* ASM */ - -#endif /* ASM */ - -#endif /* _RTEMS_SCORE_OR1K_UTILITY_H */ diff --git a/cpukit/score/cpu/or1k/rtems/score/or1k.h b/cpukit/score/cpu/or1k/rtems/score/or1k.h deleted file mode 100644 index e1a3ddce42..0000000000 --- a/cpukit/score/cpu/or1k/rtems/score/or1k.h +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @file rtems/score/or1k.h - */ - -/* - * This file contains information pertaining to the OR1K processor. - * - * COPYRIGHT (c) 2014 Hesham ALMatary - * - * Based on code with the following copyright... - * COPYRIGHT (c) 1989-1999, 2010. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_OR1K_H -#define _RTEMS_SCORE_OR1K_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This file contains the information required to build - * RTEMS for a particular member of the OR1K family. - * It does this by setting variables to indicate which - * implementation dependent features are present in a particular - * member of the family. - * - * This is a good place to list all the known CPU models - * that this port supports and which RTEMS CPU model they correspond - * to. - */ - - /* - * Define the name of the CPU family and specific model. - */ - -#define CPU_NAME "OR1K" -#define CPU_MODEL_NAME "OR1200" - -#ifdef __cplusplus -} -#endif - -#endif /* _RTEMS_SCORE_OR1K_H */ diff --git a/cpukit/score/cpu/or1k/rtems/score/types.h b/cpukit/score/cpu/or1k/rtems/score/types.h deleted file mode 100644 index 09790feb29..0000000000 --- a/cpukit/score/cpu/or1k/rtems/score/types.h +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @file - * - * @brief OR1K Architecture Types API - */ - -/* - * This include file contains type definitions pertaining to the - * arm processor family. - * - * COPYRIGHT (c) 2014 Hesham ALMatary - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - * - */ - - #ifndef _RTEMS_SCORE_TYPES_H -#define _RTEMS_SCORE_TYPES_H - -#include - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ScoreCPU - */ -/**@{**/ - -/* - * This section defines the basic types for this processor. - */ - -/** Type that can store a 32-bit integer or a pointer. */ -typedef uintptr_t CPU_Uint32ptr; - -typedef void or1k_isr; -typedef void ( *or1k_isr_entry )( void ); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* !ASM */ - -#endif diff --git a/cpukit/score/cpu/powerpc/Makefile.am b/cpukit/score/cpu/powerpc/Makefile.am index 7ed1f7996f..05ab2f480d 100644 --- a/cpukit/score/cpu/powerpc/Makefile.am +++ b/cpukit/score/cpu/powerpc/Makefile.am @@ -1,18 +1,5 @@ include $(top_srcdir)/automake/compile.am -include_rtemsdir = $(includedir)/rtems -include_rtems_HEADERS = rtems/asm.h - -include_rtems_scoredir = $(includedir)/rtems/score -include_rtems_score_HEADERS = rtems/score/powerpc.h -include_rtems_score_HEADERS += rtems/score/cpu.h -include_rtems_score_HEADERS += rtems/score/cpuimpl.h -include_rtems_score_HEADERS += rtems/score/types.h -include_rtems_score_HEADERS += rtems/score/cpuatomic.h - -include_rtems_powerpcdir = $(includedir)/rtems/powerpc -include_rtems_powerpc_HEADERS = rtems/powerpc/registers.h - noinst_LIBRARIES = libscorecpu.a libscorecpu_a_SOURCES = cpu.c libscorecpu_a_SOURCES += ppc-context-volatile-clobber.S @@ -21,5 +8,5 @@ libscorecpu_a_SOURCES += ppc-isr-disable-mask.S libscorecpu_a_SOURCES += ppc-isr-vector-install.c libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS) -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am +include $(srcdir)/headers.am diff --git a/cpukit/score/cpu/powerpc/headers.am b/cpukit/score/cpu/powerpc/headers.am new file mode 100644 index 0000000000..d8253e84f9 --- /dev/null +++ b/cpukit/score/cpu/powerpc/headers.am @@ -0,0 +1,21 @@ +## This file was generated by "./boostrap -H". + +include_machinedir = $(includedir)/machine +include_machine_HEADERS = +include_machine_HEADERS += include/machine/elf_machdep.h + +include_rtemsdir = $(includedir)/rtems +include_rtems_HEADERS = +include_rtems_HEADERS += include/rtems/asm.h + +include_rtems_powerpcdir = $(includedir)/rtems/powerpc +include_rtems_powerpc_HEADERS = +include_rtems_powerpc_HEADERS += include/rtems/powerpc/registers.h + +include_rtems_scoredir = $(includedir)/rtems/score +include_rtems_score_HEADERS = +include_rtems_score_HEADERS += include/rtems/score/cpu.h +include_rtems_score_HEADERS += include/rtems/score/cpuatomic.h +include_rtems_score_HEADERS += include/rtems/score/cpuimpl.h +include_rtems_score_HEADERS += include/rtems/score/powerpc.h +include_rtems_score_HEADERS += include/rtems/score/types.h diff --git a/cpukit/score/cpu/powerpc/include/machine/elf_machdep.h b/cpukit/score/cpu/powerpc/include/machine/elf_machdep.h new file mode 100644 index 0000000000..f0fdb3f33b --- /dev/null +++ b/cpukit/score/cpu/powerpc/include/machine/elf_machdep.h @@ -0,0 +1,105 @@ +/* $NetBSD: elf_machdep.h,v 1.9 2011/01/15 10:00:07 matt Exp $ */ + +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB +#define ELF32_MACHDEP_ID_CASES \ + case EM_PPC: \ + break; + +#define ELF64_MACHDEP_ENDIANNESS ELFDATA2MSB +#define ELF64_MACHDEP_ID_CASES \ + case EM_PPC64: \ + break; + +#define ELF32_MACHDEP_ID EM_PPC +#define ELF64_MACHDEP_ID EM_PPC64 + +#ifdef _LP64 +#define ARCH_ELFSIZE 64 /* MD native binary size */ +#else +#define ARCH_ELFSIZE 32 /* MD native binary size */ +#endif + +/* Specify the value of _GLOBAL_OFFSET_TABLE_ */ +#define DT_PPC_GOT DT_LOPROC + +#define R_PPC_NONE 0 +#define R_PPC_32 1 +#define R_PPC_24 2 +#define R_PPC_16 3 +#define R_PPC_16_LO 4 +#define R_PPC_16_HI 5 /* R_PPC_ADDIS */ +#define R_PPC_16_HA 6 +#define R_PPC_14 7 +#define R_PPC_14_TAKEN 8 +#define R_PPC_14_NTAKEN 9 +#define R_PPC_REL24 10 /* R_PPC_BRANCH */ +#define R_PPC_REL14 11 +#define R_PPC_REL14_TAKEN 12 +#define R_PPC_REL14_NTAKEN 13 +#define R_PPC_GOT16 14 +#define R_PPC_GOT16_LO 15 +#define R_PPC_GOT16_HI 16 +#define R_PPC_GOT16_HA 17 +#define R_PPC_PLT24 18 +#define R_PPC_COPY 19 +#define R_PPC_GLOB_DAT 20 +#define R_PPC_JMP_SLOT 21 +#define R_PPC_RELATIVE 22 +#define R_PPC_LOCAL24PC 23 +#define R_PPC_U32 24 +#define R_PPC_U16 25 +#define R_PPC_REL32 26 +#define R_PPC_PLT32 27 +#define R_PPC_PLTREL32 28 +#define R_PPC_PLT16_LO 29 +#define R_PPC_PLT16_HI 30 +#define R_PPC_PLT16_HA 31 +#define R_PPC_SDAREL16 32 +#define R_PPC_SECTOFF 33 +#define R_PPC_SECTOFF_LO 34 +#define R_PPC_SECTOFF_HI 35 +#define R_PPC_SECTOFF_HA 36 +#define R_PPC_ADDR30 37 + +/* TLS relocations */ +#define R_PPC_TLS 67 + +#define R_PPC_DTPMOD32 68 +#define R_PPC_TPREL16 69 +#define R_PPC_TPREL16_LO 70 +#define R_PPC_TPREL16_HI 71 +#define R_PPC_TPREL16_HA 72 +#define R_PPC_TPREL32 73 +#define R_PPC_DTPREL16 74 +#define R_PPC_DTPREL16_LO 75 +#define R_PPC_DTPREL16_HI 76 +#define R_PPC_DTPREL16_HA 77 +#define R_PPC_DTPREL32 78 + +#define R_PPC_GOT_TLSGD16 79 +#define R_PPC_GOT_TLSGD16_LO 80 +#define R_PPC_GOT_TLSGD16_HI 81 +#define R_PPC_GOT_TLSGD16_HA 82 +#define R_PPC_GOT_TLSLD16 83 +#define R_PPC_GOT_TLSLD16_LO 84 +#define R_PPC_GOT_TLSLD16_HI 85 +#define R_PPC_GOT_TLSLD16_HA 86 + +#define R_PPC_GOT_TPREL16 87 +#define R_PPC_GOT_TPREL16_LO 88 +#define R_PPC_GOT_TPREL16_HI 89 +#define R_PPC_GOT_TPREL16_HA 90 +#define R_PPC_GOT_DTPREL16 91 +#define R_PPC_GOT_DTPREL16_LO 92 +#define R_PPC_GOT_DTPREL16_HI 93 +#define R_PPC_GOT_DTPREL16_HA 94 +#define R_PPC_TLSGD 95 +#define R_PPC_TLSLD 96 + +/* Used for the secure-plt PIC code sequences */ +#define R_PPC_REL16 249 +#define R_PPC_REL16_LO 250 +#define R_PPC_REL16_HI 251 +#define R_PPC_REL16_HA 252 + +#define R_TYPE(name) __CONCAT(R_PPC_,name) diff --git a/cpukit/score/cpu/powerpc/include/rtems/asm.h b/cpukit/score/cpu/powerpc/include/rtems/asm.h new file mode 100644 index 0000000000..2fddf56e6d --- /dev/null +++ b/cpukit/score/cpu/powerpc/include/rtems/asm.h @@ -0,0 +1,310 @@ +/** + * @file + * + * @brief Address the Problems Caused by Incompatible Flavor of + * Assemblers and Toolsets + * + * This include file attempts to address the problems + * caused by incompatible flavors of assemblers and + * toolsets. It primarily addresses variations in the + * use of leading underscores on symbols and the requirement + * that register names be preceded by a %. + * + * NOTE: The spacing in the use of these macros + * is critical to them working as advertised. + */ + +/* + * COPYRIGHT: + * + * This file is based on similar code found in newlib available + * from ftp.cygnus.com. The file which was used had no copyright + * notice. This file is freely distributable as long as the source + * of the file is noted. This file is: + * + * COPYRIGHT (c) 1995. + * i-cubed ltd. + * + * COPYRIGHT (c) 1994. + * On-Line Applications Research Corporation (OAR). + */ + +#ifndef _RTEMS_ASM_H +#define _RTEMS_ASM_H + +/* + * Indicate we are in an assembly file and get the basic CPU definitions. + */ + +#ifndef ASM +#define ASM +#endif +#include +#include + +/* + * Recent versions of GNU cpp define variables which indicate the + * need for underscores and percents. If not using GNU cpp or + * the version does not support this, then you will obviously + * have to define these as appropriate. + */ + +#ifndef __USER_LABEL_PREFIX__ +#define __USER_LABEL_PREFIX__ +#endif + +#ifndef __REGISTER_PREFIX__ +#define __REGISTER_PREFIX__ +#endif + +#ifndef __FLOAT_REGISTER_PREFIX__ +#define __FLOAT_REGISTER_PREFIX__ __REGISTER_PREFIX__ +#endif + +#ifndef __PROC_LABEL_PREFIX__ +#define __PROC_LABEL_PREFIX__ __USER_LABEL_PREFIX__ +#endif + +#include + +/* Use the right prefix for global labels. */ + +#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) + +/* Use the right prefix for procedure labels. */ + +#define PROC(x) CONCAT1 (__PROC_LABEL_PREFIX__, x) + +/* Use the right prefix for registers. */ + +#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) + +/* Use the right prefix for floating point registers. */ + +#define FREG(x) CONCAT1 (__FLOAT_REGISTER_PREFIX__, x) + +/* + * define macros for all of the registers on this CPU + * + * EXAMPLE: #define d0 REG (d0) + */ +#define r0 REG(0) +#define r1 REG(1) +#define r2 REG(2) +#define r3 REG(3) +#define r4 REG(4) +#define r5 REG(5) +#define r6 REG(6) +#define r7 REG(7) +#define r8 REG(8) +#define r9 REG(9) +#define r10 REG(10) +#define r11 REG(11) +#define r12 REG(12) +#define r13 REG(13) +#define r14 REG(14) +#define r15 REG(15) +#define r16 REG(16) +#define r17 REG(17) +#define r18 REG(18) +#define r19 REG(19) +#define r20 REG(20) +#define r21 REG(21) +#define r22 REG(22) +#define r23 REG(23) +#define r24 REG(24) +#define r25 REG(25) +#define r26 REG(26) +#define r27 REG(27) +#define r28 REG(28) +#define r29 REG(29) +#define r30 REG(30) +#define r31 REG(31) +#define f0 FREG(0) +#define f1 FREG(1) +#define f2 FREG(2) +#define f3 FREG(3) +#define f4 FREG(4) +#define f5 FREG(5) +#define f6 FREG(6) +#define f7 FREG(7) +#define f8 FREG(8) +#define f9 FREG(9) +#define f10 FREG(10) +#define f11 FREG(11) +#define f12 FREG(12) +#define f13 FREG(13) +#define f14 FREG(14) +#define f15 FREG(15) +#define f16 FREG(16) +#define f17 FREG(17) +#define f18 FREG(18) +#define f19 FREG(19) +#define f20 FREG(20) +#define f21 FREG(21) +#define f22 FREG(22) +#define f23 FREG(23) +#define f24 FREG(24) +#define f25 FREG(25) +#define f26 FREG(26) +#define f27 FREG(27) +#define f28 FREG(28) +#define f29 FREG(29) +#define f30 FREG(30) +#define f31 FREG(31) +#define v0 0 +#define v1 1 +#define v2 2 +#define v3 3 +#define v4 4 +#define v5 5 +#define v6 6 +#define v7 7 +#define v8 8 +#define v9 9 +#define v10 10 +#define v11 11 +#define v12 12 +#define v13 13 +#define v14 14 +#define v15 15 +#define v16 16 +#define v17 17 +#define v18 18 +#define v19 19 +#define v20 20 +#define v21 21 +#define v22 22 +#define v23 23 +#define v24 24 +#define v25 25 +#define v26 26 +#define v27 27 +#define v28 28 +#define v29 29 +#define v30 30 +#define v31 31 + +/* + * Some special purpose registers (SPRs). + */ +#define srr0 0x01a +#define srr1 0x01b +#define srr2 0x3de /* IBM 400 series only */ +#define srr3 0x3df /* IBM 400 series only */ +#define csrr0 58 /* Book E */ +#define csrr1 59 /* Book E */ +#define mcsrr0 570 /* e500 */ +#define mcsrr1 571 /* e500 */ +#define dsrr0 574 /* e200 */ +#define dsrr1 575 /* e200 */ + +#define sprg0 0x110 +#define sprg1 0x111 +#define sprg2 0x112 +#define sprg3 0x113 +#define sprg4 276 +#define sprg5 277 +#define sprg6 278 +#define sprg7 279 + +#define usprg0 256 + +#define dar 0x013 /* Data Address Register */ +#define dec 0x016 /* Decrementer Register */ + +#if defined(ppc403) || defined(ppc405) +/* the following SPR/DCR registers exist only in IBM 400 series */ +#define dear 0x3d5 +#define evpr 0x3d6 /* SPR: exception vector prefix register */ +#define iccr 0x3fb /* SPR: instruction cache control reg. */ +#define dccr 0x3fa /* SPR: data cache control reg. */ + +#if defined (ppc403) +#define exisr 0x040 /* DCR: external interrupt status register */ +#define exier 0x042 /* DCR: external interrupt enable register */ +#endif /* ppc403 */ +#if defined(ppc405) +#define exisr 0x0C0 /* DCR: external interrupt status register */ +#define exier 0x0C2 /* DCR: external interrupt enable register */ +#endif /* ppc405 */ + +#define br0 0x080 /* DCR: memory bank register 0 */ +#define br1 0x081 /* DCR: memory bank register 1 */ +#define br2 0x082 /* DCR: memory bank register 2 */ +#define br3 0x083 /* DCR: memory bank register 3 */ +#define br4 0x084 /* DCR: memory bank register 4 */ +#define br5 0x085 /* DCR: memory bank register 5 */ +#define br6 0x086 /* DCR: memory bank register 6 */ +#define br7 0x087 /* DCR: memory bank register 7 */ + +/* end of IBM400 series register definitions */ + +#elif defined(mpc555) +/* The following registers are for the MPC5xx */ +#define eie 0x050 /* External Interrupt Enable Register */ +#define eid 0x051 /* External Interrupt Disable Register */ +#define nri 0x052 /* Non-Recoverable Interrupt Register */ + +#elif defined(mpc860) || defined(mpc821) +/* The following registers are for the MPC8x0 */ +#define der 0x095 /* Debug Enable Register */ +#define ictrl 0x09E /* Instruction Support Control Register */ +#define immr 0x27E /* Internal Memory Map Register */ +/* end of MPC8x0 registers */ +#endif + +/* + * Following must be tailor for a particular flavor of the C compiler. + * They may need to put underscores in front of the symbols. + */ + +#define PUBLIC_VAR(sym) .globl SYM (sym) +#define EXTERN_VAR(sym) .extern SYM (sym) +#define PUBLIC_PROC(sym) .globl PROC (sym) +#define EXTERN_PROC(sym) .extern PROC (sym) + +/* Other potentially assembler specific operations */ +#if PPC_ASM == PPC_ASM_ELF +#define ALIGN(n,p) .align p +#define DESCRIPTOR(x) \ + .section .descriptors,"aw"; \ + PUBLIC_VAR (x); \ +SYM (x):; \ + .long PROC (x); \ + .long s.got; \ + .long 0 + +#define EXT_SYM_REF(x) .long x +#define EXT_PROC_REF(x) .long x + +/* + * Define macros to handle section beginning and ends. + */ + +#define BEGIN_CODE_DCL .text +#define END_CODE_DCL +#define BEGIN_DATA_DCL .data +#define END_DATA_DCL +#define BEGIN_CODE .text +#define END_CODE +#define BEGIN_DATA .data +#define END_DATA +#define BEGIN_BSS .bss +#define END_BSS +#define END + +#else +#error "PPC_ASM_TYPE is not properly defined" +#endif +#ifndef PPC_ASM +#error "PPC_ASM_TYPE is not properly defined" +#endif + +#if defined(__powerpc64__) +#define PPC64_NOP_FOR_LINKER_TOC_POINTER_RESTORE nop +#else +#define PPC64_NOP_FOR_LINKER_TOC_POINTER_RESTORE +#endif + +#endif diff --git a/cpukit/score/cpu/powerpc/include/rtems/powerpc/registers.h b/cpukit/score/cpu/powerpc/include/rtems/powerpc/registers.h new file mode 100644 index 0000000000..4d9350324e --- /dev/null +++ b/cpukit/score/cpu/powerpc/include/rtems/powerpc/registers.h @@ -0,0 +1,774 @@ +/** + * @file + * + * @brief PowerPc MSR and Registers Access Definitions + * + * This file contains some powerpc MSR and registers access definitions. + */ + +/* + * COPYRIGHT (C) 1999 Eric Valette (valette@crf.canon.fr) + * Canon Centre Recherche France. + * + * Added MPC8260 Andy Dachs + * Surrey Satellite Technology Limited + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_POWERPC_REGISTERS_H +#define _RTEMS_POWERPC_REGISTERS_H + +/* Bit encodings for Machine State Register (MSR) */ +#define MSR_CM (1<<31) /* Computation mode */ +#define MSR_GS (1<<28) /* Guest state */ +#define MSR_UCLE (1<<26) /* User-mode cache lock enable (e500) */ +#define MSR_VE (1<<25) /* Alti-Vec enable (7400+) */ +#define MSR_SPE (1<<25) /* SPE enable (e500) */ +#define MSR_AP (1<<25) /* Auxiliary processor available */ +#define MSR_APE (1<<19) /* APU exception enable */ +#define MSR_POW (1<<18) /* Enable Power Management */ +#define MSR_WE (1<<18) /* Wait state enable (e500, 4xx) */ +#define MSR_TGPR (1<<17) /* TLB Update registers in use */ +#define MSR_CE (1<<17) /* BookE critical interrupt */ +#define MSR_ILE (1<<16) /* Interrupt Little-Endian enable */ +#define MSR_EE (1<<15) /* External Interrupt enable */ +#define MSR_PR (1<<14) /* Supervisor/User privilege */ +#define MSR_FP (1<<13) /* Floating Point enable */ +#define MSR_ME (1<<12) /* Machine Check enable */ +#define MSR_FE0 (1<<11) /* Floating Exception mode 0 */ +#define MSR_SE (1<<10) /* Single Step */ +#define MSR_UBLE (1<<10) /* User-mode BTB lock enable (e500) */ +#define MSR_DWE (1<<10) /* Debug wait enable (4xx) */ +#define MSR_BE (1<<9) /* Branch Trace */ +#define MSR_DE (1<<9) /* BookE debug exception */ +#define MSR_FE1 (1<<8) /* Floating Exception mode 1 */ +#define MSR_E300_CE (1<<7) /* e300 critical interrupt */ +#define MSR_IP (1<<6) /* Exception prefix 0x000/0xFFF */ +#define MSR_IR (1<<5) /* Instruction MMU enable */ +#define MSR_DR (1<<4) /* Data MMU enable */ +#define MSR_IS (1<<5) /* Instruction address space */ +#define MSR_DS (1<<4) /* Data address space */ +#define MSR_PMM (1<<2) /* Performance monitor mark */ +#define MSR_RI (1<<1) /* Recoverable Exception */ +#define MSR_LE (1<<0) /* Little-Endian enable */ + +/* Bit encodings for Hardware Implementation Register (HID0) + on PowerPC 603, 604, etc. processors (not 601). */ + +/* WARNING: HID0/HID1 are *truely* implementation dependent! + * you *cannot* rely on the same bits to be present, + * at the same place or even in the same register + * on different CPU familys. + * E.g., EMCP isHID0_DOZE is HID0_HI_BAT_EN on the + * on the 7450s. IFFT is XBSEN on 7450 and so on... + */ +#define HID0_EMCP (1<<31) /* Enable Machine Check pin */ +#define HID0_EBA (1<<29) /* Enable Bus Address Parity */ +#define HID0_EBD (1<<28) /* Enable Bus Data Parity */ +#define HID0_SBCLK (1<<27) +#define HID0_TBEN (1<<26) /* 7455:this bit must be set + * and TBEN signal must be asserted + * to enable the time base and + * decrementer. + */ +#define HID0_EICE (1<<26) +#define HID0_ECLK (1<<25) +#define HID0_PAR (1<<24) +#define HID0_DOZE (1<<23) +/* this HI_BAT_EN only on 7445, 7447, 7448, 7455 & 7457 !! */ +#define HID0_7455_HIGH_BAT_EN (1<<23) + +#define HID0_NAP (1<<22) +#define HID0_SLEEP (1<<21) +#define HID0_DPM (1<<20) +#define HID0_ICE (1<<15) /* Instruction Cache Enable */ +#define HID0_DCE (1<<14) /* Data Cache Enable */ +#define HID0_ILOCK (1<<13) /* Instruction Cache Lock */ +#define HID0_DLOCK (1<<12) /* Data Cache Lock */ +#define HID0_ICFI (1<<11) /* Instruction Cache Flash Invalidate */ +#define HID0_DCI (1<<10) /* Data Cache Invalidate */ +/* this bit is XSBSEN (xtended block size enable) on 7447, 7448, 7455 and 7457 only */ +#define HID0_7455_XBSEN (1<<8) +#define HID0_SIED (1<<7) /* Serial Instruction Execution [Disable] */ +#define HID0_BTIC (1<<5) /* Branch Target Instruction Cache [Enable] */ +/* S.K. Feng 10/03, added for MPC7455 */ +#define HID0_LRSTK (1<<4) /* Link register stack enable (7455) */ +#define HID0_FOLD (1<<3) /* Branch folding enable (7455) */ + +#define HID0_BHTE (1<<2) /* Branch History Table Enable */ +#define HID0_BTCD (1<<1) /* Branch target cache disable */ + +/* fpscr settings */ +#define FPSCR_FX (1<<31) +#define FPSCR_FEX (1<<30) + +#define _MACH_prep 1 +#define _MACH_Pmac 2 /* pmac or pmac clone (non-chrp) */ +#define _MACH_chrp 4 /* chrp machine */ +#define _MACH_mbx 8 /* Motorola MBX board */ +#define _MACH_apus 16 /* amiga with phase5 powerup */ +#define _MACH_fads 32 /* Motorola FADS board */ + +/* see residual.h for these */ +#define _PREP_Motorola 0x01 /* motorola prep */ +#define _PREP_Firm 0x02 /* firmworks prep */ +#define _PREP_IBM 0x00 /* ibm prep */ +#define _PREP_Bull 0x03 /* bull prep */ + +/* these are arbitrary */ +#define _CHRP_Motorola 0x04 /* motorola chrp, the cobra */ +#define _CHRP_IBM 0x05 /* IBM chrp, the longtrail and longtrail 2 */ + +#define _GLOBAL(n)\ + .globl n;\ +n: + +#define TBRU 269 /* Time base Upper/Lower (Reading) */ +#define TBRL 268 +#define TBWU 285 /* Time base Upper/Lower (Writing) */ +#define TBWL 284 +#define PPC_XER 1 +#define PPC_LR 8 +#define PPC_CTR 9 +#define HID0 1008 /* Hardware Implementation 0 */ +#define HID1 1009 /* Hardware Implementation 1 */ +#define HID2 1011 /* Hardware Implementation 2 */ +#define DABR 1013 /* Data Access Breakpoint */ +#define PPC_PVR 287 /* Processor Version */ +#define IBAT0U 528 /* Instruction BAT #0 Upper/Lower */ +#define IBAT0L 529 +#define IBAT1U 530 /* Instruction BAT #1 Upper/Lower */ +#define IBAT1L 531 +#define IBAT2U 532 /* Instruction BAT #2 Upper/Lower */ +#define IBAT2L 533 +#define IBAT3U 534 /* Instruction BAT #3 Upper/Lower */ +#define IBAT3L 535 + +/* Only present on 7445, 7447, 7448, 7455 and 7457 (if HID0[HIGH_BAT_EN]) */ +#define IBAT4U 560 /* Instruction BAT #4 Upper/Lower */ +#define IBAT4L 561 +#define IBAT5U 562 /* Instruction BAT #5 Upper/Lower */ +#define IBAT5L 563 +#define IBAT6U 564 /* Instruction BAT #6 Upper/Lower */ +#define IBAT6L 565 +#define IBAT7U 566 /* Instruction BAT #7 Upper/Lower */ +#define IBAT7L 567 + +#define DBAT0U 536 /* Data BAT #0 Upper/Lower */ +#define DBAT0L 537 +#define DBAT1U 538 /* Data BAT #1 Upper/Lower */ +#define DBAT1L 539 +#define DBAT2U 540 /* Data BAT #2 Upper/Lower */ +#define DBAT2L 541 +#define DBAT3U 542 /* Data BAT #3 Upper/Lower */ +#define DBAT3L 543 + +/* Only present on 7445, 7447, 7448, 7455 and 7457 (if HID0[HIGH_BAT_EN]) */ +#define DBAT4U 568 /* Instruction BAT #4 Upper/Lower */ +#define DBAT4L 569 +#define DBAT5U 570 /* Instruction BAT #5 Upper/Lower */ +#define DBAT5L 571 +#define DBAT6U 572 /* Instruction BAT #6 Upper/Lower */ +#define DBAT6L 573 +#define DBAT7U 574 /* Instruction BAT #7 Upper/Lower */ +#define DBAT7L 575 + +#define DMISS 976 /* TLB Lookup/Refresh registers */ +#define DCMP 977 +#define HASH1 978 +#define HASH2 979 +#define IMISS 980 +#define ICMP 981 +#define PPC_RPA 982 +#define SDR1 25 /* MMU hash base register */ +#define PPC_DAR 19 /* Data Address Register */ +#define DEAR_BOOKE 61 +#define DEAR_405 981 +#define SPR0 272 /* Supervisor Private Registers */ +#define SPRG0 272 +#define SPR1 273 +#define SPRG1 273 +#define SPR2 274 +#define SPRG2 274 +#define SPR3 275 +#define SPRG3 275 +#define SPRG4 276 +#define SPRG5 277 +#define SPRG6 278 +#define SPRG7 279 +#define USPRG0 256 +#define DSISR 18 +#define SRR0 26 /* Saved Registers (exception) */ +#define SRR1 27 +#define IABR 1010 /* Instruction Address Breakpoint */ +#define PPC_DEC 22 /* Decrementer */ +#define PPC_EAR 282 /* External Address Register */ + +#define MSSCR0 1014 /* Memory Subsystem Control Register */ + +#define L2CR 1017 /* PPC 750 and 74xx L2 control register */ + +#define L2CR_L2E (1<<31) /* enable */ +#define L2CR_L2I (1<<21) /* global invalidate */ + +/* watch out L2IO and L2DO are different between 745x and 7400/7410 */ +/* Oddly, the following L2CR bit defintions in 745x + * is different from that of 7400 and 7410. + * Though not used in 7400 and 7410, it is appeded with _745x just + * to be clarified. + */ +#define L2CR_L2IO_745x 0x100000 /* (1<<20) L2 Instruction-Only */ +#define L2CR_L2DO_745x 0x10000 /* (1<<16) L2 Data-Only */ +#define L2CR_LOCK_745x (L2CR_L2IO_745x|L2CR_L2DO_745x) +#define L2CR_L3OH0 0x00080000 /* 12:L3 output hold 0 */ + +#define L3CR 1018 /* PPC 7450/7455 L3 control register */ +#define L3CR_L3IO_745x 0x400000 /* (1<<22) L3 Instruction-Only */ +#define L3CR_L3DO_745x 0x40 /* (1<<6) L3 Data-Only */ + +#define L3CR_LOCK_745x (L3CR_L3IO_745x|L3CR_L3DO_745x) + +#define L3CR_RESERVED 0x0438003a /* Reserved bits in L3CR */ +#define L3CR_L3E 0x80000000 /* 0: L3 enable */ +#define L3CR_L3PE 0x40000000 /* 1: L3 data parity checking enable */ +#define L3CR_L3APE 0x20000000 /* 2: L3 address parity checking enable */ +#define L3CR_L3SIZ 0x10000000 /* 3: L3 size (0=1MB, 1=2MB) */ +#define L3SIZ_1M 0x00000000 +#define L3SIZ_2M 0x10000000 +#define L3CR_L3CLKEN 0x08000000 /* 4: Enables the L3_CLK[0:1] signals */ +#define L3CR_L3CLK 0x03800000 /* 6-8: L3 clock ratio */ +#define L3CLK_60 0x00000000 /* core clock / 6 */ +#define L3CLK_20 0x01000000 /* / 2 */ +#define L3CLK_25 0x01800000 /* / 2.5 */ +#define L3CLK_30 0x02000000 /* / 3 */ +#define L3CLK_35 0x02800000 /* / 3.5 */ +#define L3CLK_40 0x03000000 /* / 4 */ +#define L3CLK_50 0x03800000 /* / 5 */ +#define L3CR_L3IO 0x00400000 /* 9: L3 instruction-only mode */ +#define L3CR_L3SPO 0x00040000 /* 13: L3 sample point override */ +#define L3CR_L3CKSP 0x00030000 /* 14-15: L3 clock sample point */ +#define L3CKSP_2 0x00000000 /* 2 clocks */ +#define L3CKSP_3 0x00010000 /* 3 clocks */ +#define L3CKSP_4 0x00020000 /* 4 clocks */ +#define L3CKSP_5 0x00030000 /* 5 clocks */ +#define L3CR_L3PSP 0x0000e000 /* 16-18: L3 P-clock sample point */ +#define L3PSP_0 0x00000000 /* 0 clocks */ +#define L3PSP_1 0x00002000 /* 1 clocks */ +#define L3PSP_2 0x00004000 /* 2 clocks */ +#define L3PSP_3 0x00006000 /* 3 clocks */ +#define L3PSP_4 0x00008000 /* 4 clocks */ +#define L3PSP_5 0x0000a000 /* 5 clocks */ +#define L3CR_L3REP 0x00001000 /* 19: L3 replacement algorithm (0=default, 1=alternate) */ +#define L3CR_L3HWF 0x00000800 /* 20: L3 hardware flush */ +#define L3CR_L3I 0x00000400 /* 21: L3 global invaregisters.h.orig +lidate */ +#define L3CR_L3RT 0x00000300 /* 22-23: L3 SRAM type */ +#define L3RT_MSUG2_DDR 0x00000000 /* MSUG2 DDR SRAM */ +#define L3RT_PIPELINE_LATE 0x00000100 /* Pipelined (register-register) synchronous late-write SRAM */ +#define L3RT_PB2_SRAM 0x00000300 /* PB2 SRAM */ +#define L3CR_L3NIRCA 0x00000080 /* 24: L3 non-integer ratios clock adjustment for the SRAM */ +#define L3CR_L3DO 0x00000040 /* 25: L3 data-only mode */ +#define L3CR_PMEN 0x00000004 /* 29: Private memory enable */ +#define L3CR_PMSIZ 0x00000004 /* 31: Private memory size (0=1MB, 1=2MB) */ + +#define THRM1 1020 +#define THRM2 1021 +#define THRM3 1022 +#define THRM1_TIN (1<<(31-0)) +#define THRM1_TIV (1<<(31-1)) +#define THRM1_THRES (0x7f<<(31-8)) +#define THRM1_TID (1<<(31-29)) +#define THRM1_TIE (1<<(31-30)) +#define THRM1_V (1<<(31-31)) +#define THRM3_SITV (0x1fff << (31-30)) +#define THRM3_E (1<<(31-31)) + +/* Segment Registers */ +#define PPC_SR0 0 +#define PPC_SR1 1 +#define PPC_SR2 2 +#define PPC_SR3 3 +#define PPC_SR4 4 +#define PPC_SR5 5 +#define PPC_SR6 6 +#define PPC_SR7 7 +#define PPC_SR8 8 +#define PPC_SR9 9 +#define PPC_SR10 10 +#define PPC_SR11 11 +#define PPC_SR12 12 +#define PPC_SR13 13 +#define PPC_SR14 14 +#define PPC_SR15 15 + +#define BOOKE_DECAR 54 + +#define PPC405_MCSR 0x23C +#define PPC405_ESR 0x3D4 +#define PPC405_DEAR 0x3D5 +#define BOOKE_DEAR 61 + +#define PPC405_TSR 0x3D8 +#define BOOKE_TSR 336 +#define BOOKE_TSR_ENW (1<<31) +#define BOOKE_TSR_WIS (1<<30) +#define BOOKE_TSR_DIS (1<<27) +#define BOOKE_TSR_FIS (1<<26) + +#define PPC405_TCR 0x3DA +#define BOOKE_TCR 340 +#define BOOKE_TCR_WP(x) (((x)&3)<<30) +#define BOOKE_TCR_WP_MASK (3<<30) +#define BOOKE_TCR_WRC(x) (((x)&3)<<28) +#define BOOKE_TCR_WRC_MASK (3<<28) +#define BOOKE_TCR_WIE (1<<27) +#define BOOKE_TCR_DIE (1<<26) +#define BOOKE_TCR_FP(x) (((x)&3)<<24) +#define BOOKE_TCR_FIE (1<<23) +#define BOOKE_TCR_ARE (1<<22) +#define BOOKE_TCR_WPEXT(x) (((x)&0xf)<<17) +#define BOOKE_TCR_WPEXT_MASK (0xf<<17) +#define BOOKE_TCR_FPEXT(x) (((x)&0xf)<<13) +#define BOOKE_TCR_FPEXT_MASK (0xf<<13) + +#define BOOKE_PID 48 /* Process ID */ +#define BOOKE_CSRR0 58 /* Critical Save/Restore Register 0 */ +#define BOOKE_CSRR1 59 /* Critical Save/Restore Register 1 */ +#define BOOKE_ESR 62 /* Exception Syndrome Register */ +#define BOOKE_IVPR 63 /* Interrupt Vector Prefix Register */ +#define BOOKE_SPRG4_W 260 /* Special Purpose Register General 4 (WO) */ +#define BOOKE_SPRG5_W 261 /* Special Purpose Register General 5 (WO) */ +#define BOOKE_SPRG6_W 262 /* Special Purpose Register General 6 (WO) */ +#define BOOKE_SPRG7_W 263 /* Special Purpose Register General 7 (WO) */ +#define BOOKE_PIR 286 /* Processor ID Register */ +#define BOOKE_DBSR 304 /* Debug Status Register */ + +#define BOOKE_EPCR 307 /* Embedded Processor Control Register */ +#define BOOKE_EPCR_EXTGS (1 << 31) +#define BOOKE_EPCR_DTLBGS (1 << 30) +#define BOOKE_EPCR_ITLBGS (1 << 29) +#define BOOKE_EPCR_DSIGS (1 << 28) +#define BOOKE_EPCR_ISIGS (1 << 27) +#define BOOKE_EPCR_DUVD (1 << 26) +#define BOOKE_EPCR_ICM (1 << 25) +#define BOOKE_EPCR_GICM (1 << 24) +#define BOOKE_EPCR_DGTMI (1 << 23) +#define BOOKE_EPCR_DMIUH (1 << 22) +#define BOOKE_EPCR_PMGS (1 << 21) + +#define BOOKE_DBCR0 308 /* Debug Control Register 0 */ +#define BOOKE_DBCR1 309 /* Debug Control Register 1 */ +#define BOOKE_DBCR2 310 /* Debug Control Register 2 */ +#define BOOKE_IAC1 312 /* Instruction Address Compare 1 */ +#define BOOKE_IAC2 313 /* Instruction Address Compare 2 */ +#define BOOKE_IAC3 314 /* Instruction Address Compare 3 */ +#define BOOKE_IAC4 315 /* Instruction Address Compare 4 */ +#define BOOKE_DAC1 316 /* Data Address Compare 1 */ +#define BOOKE_DAC2 317 /* Data Address Compare 2 */ +#define BOOKE_DVC1 318 /* Data Value Compare 1 */ +#define BOOKE_DVC2 319 /* Data Value Compare 2 */ +#define BOOKE_GSRR0 378 /* Guest Save/Restore Register 0 */ +#define BOOKE_GSRR1 379 /* Guest Save/Restore Register 1 */ +#define BOOKE_GEPR 380 /* Guest External Proxy Register */ +#define BOOKE_GDEAR 381 /* Guest Data Exception Address Register */ +#define BOOKE_GPIR 382 /* Guest Processor ID Register */ +#define BOOKE_GESR 383 /* Guest Exception Syndrome Register */ +#define BOOKE_IVOR0 400 /* Interrupt Vector Offset Register 0 */ +#define BOOKE_IVOR1 401 /* Interrupt Vector Offset Register 1 */ +#define BOOKE_IVOR2 402 /* Interrupt Vector Offset Register 2 */ +#define BOOKE_IVOR3 403 /* Interrupt Vector Offset Register 3 */ +#define BOOKE_IVOR4 404 /* Interrupt Vector Offset Register 4 */ +#define BOOKE_IVOR5 405 /* Interrupt Vector Offset Register 5 */ +#define BOOKE_IVOR6 406 /* Interrupt Vector Offset Register 6 */ +#define BOOKE_IVOR7 407 /* Interrupt Vector Offset Register 7 */ +#define BOOKE_IVOR8 408 /* Interrupt Vector Offset Register 8 */ +#define BOOKE_IVOR9 409 /* Interrupt Vector Offset Register 9 */ +#define BOOKE_IVOR10 410 /* Interrupt Vector Offset Register 10 */ +#define BOOKE_IVOR11 411 /* Interrupt Vector Offset Register 11 */ +#define BOOKE_IVOR12 412 /* Interrupt Vector Offset Register 12 */ +#define BOOKE_IVOR13 413 /* Interrupt Vector Offset Register 13 */ +#define BOOKE_IVOR14 414 /* Interrupt Vector Offset Register 14 */ +#define BOOKE_IVOR15 415 /* Interrupt Vector Offset Register 15 */ +#define BOOKE_IVOR42 436 /* Interrupt Vector Offset Register 42 */ +#define BOOKE_IVOR32 528 /* Interrupt Vector Offset Register 32 */ +#define BOOKE_IVOR33 529 /* Interrupt Vector Offset Register 33 */ +#define BOOKE_IVOR34 530 /* Interrupt Vector Offset Register 34 */ +#define BOOKE_IVOR35 531 /* Interrupt Vector Offset Register 35 */ +#define BOOKE_IVOR36 532 /* Interrupt Vector Offset Register 36 */ +#define BOOKE_IVOR37 533 /* Interrupt Vector Offset Register 37 */ +#define BOOKE_IVOR38 432 /* Interrupt Vector Offset Register 38 */ +#define BOOKE_IVOR39 433 /* Interrupt Vector Offset Register 39 */ +#define BOOKE_IVOR40 434 /* Interrupt Vector Offset Register 40 */ +#define BOOKE_IVOR41 435 /* Interrupt Vector Offset Register 41 */ +#define BOOKE_GIVOR2 440 /* Guest Interrupt Vector Offset Register 2 */ +#define BOOKE_GIVOR3 441 /* Guest Interrupt Vector Offset Register 3 */ +#define BOOKE_GIVOR4 442 /* Guest Interrupt Vector Offset Register 4 */ +#define BOOKE_GIVOR8 443 /* Guest Interrupt Vector Offset Register 8 */ +#define BOOKE_GIVOR13 444 /* Guest Interrupt Vector Offset Register 13 */ +#define BOOKE_GIVOR14 445 /* Guest Interrupt Vector Offset Register 14 */ +#define BOOKE_GIVPR 446 /* Guest Interrupt Vector Prefix Register */ +#define BOOKE_MCSRR0 570 /* Machine Check Save/Restore Register 0 */ +#define BOOKE_MCSRR1 571 /* Machine Check Save/Restore Register 1 */ +#define BOOKE_MCSR 572 /* Machine Check Status Register */ +#define BOOKE_DSRR0 574 /* Debug Save/Restore Register 0 */ +#define BOOKE_DSRR1 575 /* Debug Save/Restore Register 1 */ + +#define PPC440_INV0 880 /* Instruction Cache Normal Victim 0 */ +#define PPC440_INV1 881 /* Instruction Cache Normal Victim 1 */ +#define PPC440_INV2 882 /* Instruction Cache Normal Victim 2 */ +#define PPC440_INV3 883 /* Instruction Cache Normal Victim 3 */ +#define PPC440_ITV0 884 /* Instruction Cache Transient Victim 0 */ +#define PPC440_ITV1 885 /* Instruction Cache Transient Victim 1 */ +#define PPC440_ITV2 886 /* Instruction Cache Transient Victim 2 */ +#define PPC440_ITV3 887 /* Instruction Cache Transient Victim 3 */ +#define PPC440_CCR1 888 /* Core Configuration Register 1 */ +#define PPC440_DNV0 912 /* Data Cache Normal Victim 0 */ +#define PPC440_DNV1 913 /* Data Cache Normal Victim 1 */ +#define PPC440_DNV2 914 /* Data Cache Normal Victim 2 */ +#define PPC440_DNV3 915 /* Data Cache Normal Victim 3 */ +#define PPC440_DTV0 916 /* Data Cache Transient Victim 0 */ +#define PPC440_DTV1 917 /* Data Cache Transient Victim 1 */ +#define PPC440_DTV2 918 /* Data Cache Transient Victim 2 */ +#define PPC440_DTV3 919 /* Data Cache Transient Victim 3 */ +#define PPC440_DVLIM 920 /* Data Cache Victim Limit */ +#define PPC440_IVLIM 921 /* Instruction Cache Victim Limit */ +#define PPC440_RSTCFG 923 /* Reset Configuration */ +#define PPC440_DCDBTRL 924 /* Data Cache Debug Tag Register Low */ +#define PPC440_DCDBTRH 925 /* Data Cache Debug Tag Register High */ +#define PPC440_ICDBTRL 926 /* Instruction Cache Debug Tag Register Low */ +#define PPC440_ICDBTRH 927 /* Instruction Cache Debug Tag Register High */ +#define PPC440_MMUCR 946 /* Memory Management Unit Control Register */ +#define PPC440_CCR0 947 /* Core Configuration Register 0 */ +#define PPC440_ICDBDR 979 /* Instruction Cache Debug Data Register */ +#define PPC440_DBDR 1011 /* Debug Data Register */ + +#define PPC440_TLB0_EPN(n) ( (((1<<22)-1)&(n)) << (31-21)) /* Etended Page Number */ +#define PPC440_TLB0_EPN_GET(n) ( ((n) >> (31-21)) & ((1<<22)-1)) +#define PPC440_TLB0_V ( 1 << (31-22)) /* Entry valid */ +#define PPC440_TLB0_TS ( 1 << (31-23)) /* Translation space */ +#define PPC440_TLB0_TSIZE(n) ( (0xf & (n)) << (31-27)) /* Page size */ +#define PPC440_TLB0_TSIZE_GET(n) ( ((n) >> (31-27)) & 0xf) +#define PPC440_TLB0_TPAR(n) ( (0xf & (n)) << (31-31)) /* Tag Parity */ +#define PPC440_TLB0_TPAR_GET(n) ( ((n) >> (31-31)) & 0xf) + +#define PPC440_PID_TID(n) ( (0xff & (n)) << (31-31)) /* Translation ID */ +#define PPC440_PID_TID_GET(n) ( ((n) >> (31-31)) & 0xff) + +#define PPC440_TLB1_RPN(n) ( (((1<<22)-1)&(n)) << (31-21)) /* Real Page Number */ +#define PPC440_TLB1_RPN_GET(n) ( ((n) >> (31-21)) & ((1<<22)-1)) +#define PPC440_TLB1_PAR1(n) ( (0x3 & (n)) << (31-23)) /* Parity for TLB word 1 */ +#define PPC440_TLB1_PAR1_GET(n) ( ((n) >> (31-23)) & 0x3) +#define PPC440_TLB1_ERPN(n) ( (0xf & (n)) << (31-31)) /* Extended Real Page No. */ +#define PPC440_TLB1_ERPN_GET(n) ( ((n) >> (31-31)) & 0xf) + +#define PPC440_TLB2_PAR2(n) ( (0x3 & (n)) << (31- 1)) /* Parity for TLB word 2 */ +#define PPC440_TLB2_PAR2_GET(n) ( ((n) >> (31- 1)) & 0x3) +#define PPC440_TLB2_U0 ( 1 << (31-16)) /* User attr. 0 */ +#define PPC440_TLB2_U1 ( 1 << (31-17)) /* User attr. 1 */ +#define PPC440_TLB2_U2 ( 1 << (31-18)) /* User attr. 2 */ +#define PPC440_TLB2_U3 ( 1 << (31-19)) /* User attr. 3 */ +#define PPC440_TLB2_W ( 1 << (31-20)) /* Write-through */ +#define PPC440_TLB2_I ( 1 << (31-21)) /* Cache-inhibited */ +#define PPC440_TLB2_M ( 1 << (31-22)) /* Memory-coherence req. */ +#define PPC440_TLB2_G ( 1 << (31-23)) /* Guarded */ +#define PPC440_TLB2_E ( 1 << (31-24)) /* Little-endian */ +#define PPC440_TLB2_UX ( 1 << (31-26)) /* User exec. */ +#define PPC440_TLB2_UW ( 1 << (31-27)) /* User write */ +#define PPC440_TLB2_UR ( 1 << (31-28)) /* User read */ +#define PPC440_TLB2_SX ( 1 << (31-29)) /* Super exec. */ +#define PPC440_TLB2_SW ( 1 << (31-30)) /* Super write */ +#define PPC440_TLB2_SR ( 1 << (31-31)) /* Super read */ + +#define PPC440_TLB2_ATTR(x) ( ((x) & 0x1ff) << 7 ) +#define PPC440_TLB2_ATTR_GET(x) ( ((x) >> 7) & 0x1ff ) + +#define PPC440_TLB2_PERM(n) ( (n) & 0x3f ) +#define PPC440_TLB2_PERM_GET(n) ( (n) & 0x3f ) + +/* Freescale Book E Implementation Standards (EIS): Branch Operations */ + +#define FSL_EIS_BUCSR 1013 +#define FSL_EIS_BUCSR_STAC_EN (1 << (63 - 39)) +#define FSL_EIS_BUCSR_LS_EN (1 << (63 - 41)) +#define FSL_EIS_BUCSR_BBFI (1 << (63 - 54)) +#define FSL_EIS_BUCSR_BALLOC_ALL (0x0 << (63 - 59)) +#define FSL_EIS_BUCSR_BALLOC_FORWARD (0x1 << (63 - 59)) +#define FSL_EIS_BUCSR_BALLOC_BACKWARD (0x2 << (63 - 59)) +#define FSL_EIS_BUCSR_BALLOC_NONE (0x3 << (63 - 59)) +#define FSL_EIS_BUCSR_BPRED_TAKEN (0x0 << (63 - 61)) +#define FSL_EIS_BUCSR_BPRED_TAKEN_ONLY_FORWARD (0x1 << (63 - 62)) +#define FSL_EIS_BUCSR_BPRED_TAKEN_ONLY_BACKWARD (0x2 << (63 - 62)) +#define FSL_EIS_BUCSR_BPRED_NOT_TAKEN (0x3 << (63 - 62)) +#define FSL_EIS_BUCSR_BPEN (1 << (63 - 63)) + +/* Freescale Book E Implementation Standards (EIS): Hardware Implementation-Dependent Registers */ + +#define FSL_EIS_SVR 1023 + +/* Freescale Book E Implementation Standards (EIS): Thread Management and Control Registers */ + +#define FSL_EIS_TENSR 437 +#define FSL_EIS_TENS 438 +#define FSL_EIS_TENC 439 +#define FSL_EIS_PPR32 898 + +/* Freescale Book E Implementation Standards (EIS): MMU Control and Status */ + +#define FSL_EIS_MAS0 624 +#define FSL_EIS_MAS0_TLBSEL (1 << (63 - 35)) +#define FSL_EIS_MAS0_ESEL(n) ((0xf & (n)) << (63 - 47)) +#define FSL_EIS_MAS0_ESEL_GET(m) (((m) >> (63 - 47)) & 0xf) +#define FSL_EIS_MAS0_NV (1 << (63 - 63)) + +#define FSL_EIS_MAS1 625 +#define FSL_EIS_MAS1_V (1 << (63 - 32)) +#define FSL_EIS_MAS1_IPROT (1 << (63 - 33)) +#define FSL_EIS_MAS1_TID(n) ((0xff & (n)) << (63 - 47)) +#define FSL_EIS_MAS1_TID_GET(n) (((n) >> (63 - 47)) & 0xfff) +#define FSL_EIS_MAS1_TS (1 << (63 - 51)) +#define FSL_EIS_MAS1_TSIZE(n) ((0xf & (n)) << (63 - 55)) +#define FSL_EIS_MAS1_TSIZE_GET(n) (((n)>>(63 - 55)) & 0xf) + +#define FSL_EIS_MAS2 626 +#define FSL_EIS_MAS2_EPN(n) ((((1 << 21) - 1)&(n)) << (63-51)) +#define FSL_EIS_MAS2_EPN_GET(n) (((n) >> (63 - 51)) & 0xfffff) +#define FSL_EIS_MAS2_EA(n) FSL_EIS_MAS2_EPN((n) >> 12) +#define FSL_EIS_MAS2_EA_GET(n) (FSL_EIS_MAS2_EPN_GET(n) << 12) +#define FSL_EIS_MAS2_X0 (1 << (63 - 57)) +#define FSL_EIS_MAS2_X1 (1 << (63 - 58)) +#define FSL_EIS_MAS2_W (1 << (63 - 59)) +#define FSL_EIS_MAS2_I (1 << (63 - 60)) +#define FSL_EIS_MAS2_M (1 << (63 - 61)) +#define FSL_EIS_MAS2_G (1 << (63 - 62)) +#define FSL_EIS_MAS2_E (1 << (63 - 63)) +#define FSL_EIS_MAS2_ATTR(x) ((x) & 0x7f) +#define FSL_EIS_MAS2_ATTR_GET(x) ((x) & 0x7f) + +#define FSL_EIS_MAS3 627 +#define FSL_EIS_MAS3_RPN(n) ((((1 << 21) - 1) & (n)) << (63-51)) +#define FSL_EIS_MAS3_RPN_GET(n) (((n)>>(63 - 51)) & 0xfffff) +#define FSL_EIS_MAS3_RA(n) FSL_EIS_MAS3_RPN((n) >> 12) +#define FSL_EIS_MAS3_RA_GET(n) (FSL_EIS_MAS3_RPN_GET(n) << 12) +#define FSL_EIS_MAS3_U0 (1 << (63 - 54)) +#define FSL_EIS_MAS3_U1 (1 << (63 - 55)) +#define FSL_EIS_MAS3_U2 (1 << (63 - 56)) +#define FSL_EIS_MAS3_U3 (1 << (63 - 57)) +#define FSL_EIS_MAS3_UX (1 << (63 - 58)) +#define FSL_EIS_MAS3_SX (1 << (63 - 59)) +#define FSL_EIS_MAS3_UW (1 << (63 - 60)) +#define FSL_EIS_MAS3_SW (1 << (63 - 61)) +#define FSL_EIS_MAS3_UR (1 << (63 - 62)) +#define FSL_EIS_MAS3_SR (1 << (63 - 63)) +#define FSL_EIS_MAS3_PERM(n) ((n) & 0x3ff) +#define FSL_EIS_MAS3_PERM_GET(n) ((n) & 0x3ff) + +#define FSL_EIS_MAS4 628 +#define FSL_EIS_MAS4_TLBSELD (1 << (63 - 35)) +#define FSL_EIS_MAS4_TIDSELD(n) ((0x3 & (n)) << (63 - 47)) +#define FSL_EIS_MAS4_TSIZED(n) ((0xf & (n)) << (63 - 55)) +#define FSL_EIS_MAS4_X0D FSL_EIS_MAS2_X0 +#define FSL_EIS_MAS4_X1D FSL_EIS_MAS2_X1 +#define FSL_EIS_MAS4_WD FSL_EIS_MAS2_W +#define FSL_EIS_MAS4_ID FSL_EIS_MAS2_I +#define FSL_EIS_MAS4_MD FSL_EIS_MAS2_M +#define FSL_EIS_MAS4_GD FSL_EIS_MAS2_G +#define FSL_EIS_MAS4_ED FSL_EIS_MAS2_E + +#define FSL_EIS_MAS5 629 + +#define FSL_EIS_MAS6 630 +#define FSL_EIS_MAS6_SPID0(n) ((0xff & (n)) << (63 - 55)) +#define FSL_EIS_MAS6_SAS (1 << (63 - 63)) + +#define FSL_EIS_MAS7 944 + +#define FSL_EIS_MAS8 341 + +#define FSL_EIS_MMUCFG 1015 +#define FSL_EIS_MMUCSR0 1012 +#define FSL_EIS_PID0 48 +#define FSL_EIS_PID1 633 +#define FSL_EIS_PID2 634 +#define FSL_EIS_TLB0CFG 688 +#define FSL_EIS_TLB1CFG 689 + +/* Freescale Book E Implementation Standards (EIS): L1 Cache */ + +#define FSL_EIS_L1CFG0 515 +#define FSL_EIS_L1CFG1 516 +#define FSL_EIS_L1CSR0 1010 +#define FSL_EIS_L1CSR0_CFI (1 << (63 - 62)) +#define FSL_EIS_L1CSR1 1011 +#define FSL_EIS_L1CSR1_ICFI (1 << (63 - 62)) + +/* Freescale Book E Implementation Standards (EIS): L2 Cache */ + +#define FSL_EIS_L2CFG0 519 +#define FSL_EIS_L2CSR0 1017 +#define FSL_EIS_L2CSR0_L2FI (1 << (63 - 42)) +#define FSL_EIS_L2CSR0_L2FL (1 << (63 - 52)) +#define FSL_EIS_L2CSR1 1018 + +/* Freescale Book E Implementation Standards (EIS): Timer */ + +#define FSL_EIS_ATBL 526 +#define FSL_EIS_ATBU 527 + +/* Freescale Book E Implementation Standards (EIS): Interrupt */ + +#define FSL_EIS_MCAR 573 +#define FSL_EIS_DSRR0 574 +#define FSL_EIS_DSRR1 575 +#define FSL_EIS_EPR 702 + +/* Freescale Book E Implementation Standards (EIS): Signal Processing Engine (SPE) */ + +#define FSL_EIS_SPEFSCR 512 + +/* Freescale Book E Implementation Standards (EIS): Software-Use SPRs */ + +#define FSL_EIS_SPRG8 604 +#define FSL_EIS_SPRG9 605 + +/* Freescale Book E Implementation Standards (EIS): Debug */ + +#define FSL_EIS_DBCR3 561 +#define FSL_EIS_DBCR4 563 +#define FSL_EIS_DBCR5 564 +#define FSL_EIS_DBCR6 603 +#define FSL_EIS_DBCNT 562 + +/** + * @brief Default value for the interrupt disable mask. + * + * The interrupt disable mask is stored in the global symbol + * _PPC_INTERRUPT_DISABLE_MASK. + */ +#define PPC_INTERRUPT_DISABLE_MASK_DEFAULT MSR_EE + +#ifndef ASM + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define _CPU_MSR_GET( _msr_value ) \ + do { \ + _msr_value = 0; \ + __asm__ volatile ("mfmsr %0" : "=&r" ((_msr_value)) : "0" ((_msr_value))); \ + } while (0) + +#define _CPU_MSR_SET( _msr_value ) \ +{ __asm__ volatile ("mtmsr %0" : "=&r" ((_msr_value)) : "0" ((_msr_value))); } + +/** + * @brief A global symbol used to disable interrupts in the MSR. + * + * A one bit means that this bit should be cleared. + */ +extern char _PPC_INTERRUPT_DISABLE_MASK[]; + +static inline uint32_t ppc_interrupt_get_disable_mask( void ) +{ + return (uint32_t) (uintptr_t) _PPC_INTERRUPT_DISABLE_MASK; +} + +static inline uint32_t ppc_interrupt_disable( void ) +{ + uint32_t level; + +#if defined(__PPC_CPU_E6500__) + __asm__ volatile ( + "mfmsr %0;" + "wrteei 0" + : "=r" (level) + ); +#else + uint32_t mask; + + __asm__ volatile ( + "mfmsr %0;" + "lis %1, _PPC_INTERRUPT_DISABLE_MASK@h;" + "ori %1, %1, _PPC_INTERRUPT_DISABLE_MASK@l;" + "andc %1, %0, %1;" + "mtmsr %1" + : "=r" (level), "=r" (mask) + ); +#endif + + return level; +} + +static inline void ppc_interrupt_enable( uint32_t level ) +{ +#if defined(__PPC_CPU_E6500__) + __asm__ volatile ( + "wrtee %0" + : + : "r" (level) + ); +#else + __asm__ volatile ( + "mtmsr %0" + : + : "r" (level) + ); +#endif +} + +static inline void ppc_interrupt_flash( uint32_t level ) +{ + uint32_t current_level; + + __asm__ volatile ( + "mfmsr %0;" + "mtmsr %1;" + "mtmsr %0" + : "=&r" (current_level) + : "r" (level) + ); +} + +#define _CPU_ISR_Disable( _isr_cookie ) \ + do { \ + _isr_cookie = ppc_interrupt_disable(); \ + } while (0) + +/* + * Enable interrupts to the previous level (returned by _CPU_ISR_Disable). + * This indicates the end of an RTEMS critical section. The parameter + * _isr_cookie is not modified. + */ + +#define _CPU_ISR_Enable( _isr_cookie ) \ + ppc_interrupt_enable(_isr_cookie) + +/* + * This temporarily restores the interrupt to _isr_cookie before immediately + * disabling them again. This is used to divide long RTEMS critical + * sections into two or more parts. The parameter _isr_cookie is not + * modified. + * + * NOTE: The version being used is not very optimized but it does + * not trip a problem in gcc where the disable mask does not + * get loaded. Check this for future (post 10/97 gcc versions. + */ + +#define _CPU_ISR_Flash( _isr_cookie ) \ + ppc_interrupt_flash(_isr_cookie) + +/* end of ISR handler macros */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* ASM */ + +#endif /* _RTEMS_POWERPC_REGISTERS_H */ diff --git a/cpukit/score/cpu/powerpc/include/rtems/score/cpu.h b/cpukit/score/cpu/powerpc/include/rtems/score/cpu.h new file mode 100644 index 0000000000..8c0f200641 --- /dev/null +++ b/cpukit/score/cpu/powerpc/include/rtems/score/cpu.h @@ -0,0 +1,1257 @@ +/** + * @file + * + * @brief PowerPC CPU Department Source + */ + +/* + * COPYRIGHT (c) 1989-2012. + * On-Line Applications Research Corporation (OAR). + * + * COPYRIGHT (c) 1995 i-cubed ltd. + * + * To anyone who acknowledges that this file is provided "AS IS" + * without any express or implied warranty: + * permission to use, copy, modify, and distribute this file + * for any purpose is hereby granted without fee, provided that + * the above copyright notice and this notice appears in all + * copies, and that the name of i-cubed limited not be used in + * advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * i-cubed limited makes no representations about the suitability + * of this software for any purpose. + * + * Copyright (c) 2001 Andy Dachs . + * + * Copyright (c) 2001 Surrey Satellite Technology Limited (SSTL). + * + * Copyright (c) 2010, 2017 embedded brains GmbH. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPU_H +#define _RTEMS_SCORE_CPU_H + +#include +#include +#include + +#ifndef ASM + #include /* for memset() */ +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* conditional compilation parameters */ + +/* + * Does this port provide a CPU dependent IDLE task implementation? + * + * If TRUE, then the routine _CPU_Thread_Idle_body + * must be provided and is the default IDLE thread body instead of + * _CPU_Thread_Idle_body. + * + * If FALSE, then use the generic IDLE thread body if the BSP does + * not provide one. + * + * This is intended to allow for supporting processors which have + * a low power or idle mode. When the IDLE thread is executed, then + * the CPU can be powered down. + * + * The order of precedence for selecting the IDLE thread body is: + * + * 1. BSP provided + * 2. CPU dependent (if provided) + * 3. generic (if no BSP and no CPU dependent) + */ + +#define CPU_PROVIDES_IDLE_THREAD_BODY FALSE + +/* + * Does the stack grow up (toward higher addresses) or down + * (toward lower addresses)? + * + * If TRUE, then the grows upward. + * If FALSE, then the grows toward smaller addresses. + */ + +#define CPU_STACK_GROWS_UP FALSE + +#define CPU_CACHE_LINE_BYTES PPC_STRUCTURE_ALIGNMENT + +#define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES ) + +/* + * Does the CPU have hardware floating point? + * + * If TRUE, then the RTEMS_FLOATING_POINT task attribute is supported. + * If FALSE, then the RTEMS_FLOATING_POINT task attribute is ignored. + * + * If there is a FP coprocessor such as the i387 or mc68881, then + * the answer is TRUE. + * + * The macro name "PPC_HAS_FPU" should be made CPU specific. + * It indicates whether or not this CPU model has FP support. For + * example, it would be possible to have an i386_nofp CPU model + * which set this to false to indicate that you have an i386 without + * an i387 and wish to leave floating point support out of RTEMS. + */ + +#if ( PPC_HAS_FPU == 1 ) +#define CPU_HARDWARE_FP TRUE +#define CPU_SOFTWARE_FP FALSE +#else +#define CPU_HARDWARE_FP FALSE +#define CPU_SOFTWARE_FP FALSE +#endif + +/* + * Are all tasks RTEMS_FLOATING_POINT tasks implicitly? + * + * If TRUE, then the RTEMS_FLOATING_POINT task attribute is assumed. + * If FALSE, then the RTEMS_FLOATING_POINT task attribute is followed. + * + * If CPU_HARDWARE_FP is FALSE, then this should be FALSE as well. + * + * PowerPC Note: It appears the GCC can implicitly generate FPU + * and Altivec instructions when you least expect them. So make + * all tasks floating point. + */ + +#define CPU_ALL_TASKS_ARE_FP CPU_HARDWARE_FP + +/* + * Should the IDLE task have a floating point context? + * + * If TRUE, then the IDLE task is created as a RTEMS_FLOATING_POINT task + * and it has a floating point context which is switched in and out. + * If FALSE, then the IDLE task does not have a floating point context. + * + * Setting this to TRUE negatively impacts the time required to preempt + * the IDLE task from an interrupt because the floating point context + * must be saved as part of the preemption. + */ + +#define CPU_IDLE_TASK_IS_FP FALSE + +#define CPU_MAXIMUM_PROCESSORS 32 + +/* + * Processor defined structures required for cpukit/score. + */ + +/* + * Contexts + * + * Generally there are 2 types of context to save. + * 1. Interrupt registers to save + * 2. Task level registers to save + * + * This means we have the following 3 context items: + * 1. task level context stuff:: Context_Control + * 2. floating point task stuff:: Context_Control_fp + * 3. special interrupt level context :: Context_Control_interrupt + * + * On some processors, it is cost-effective to save only the callee + * preserved registers during a task context switch. This means + * that the ISR code needs to save those registers which do not + * persist across function calls. It is not mandatory to make this + * distinctions between the caller/callee saves registers for the + * purpose of minimizing context saved during task switch and on interrupts. + * If the cost of saving extra registers is minimal, simplicity is the + * choice. Save the same context on interrupt entry as for tasks in + * this case. + * + * Additionally, if gdb is to be made aware of RTEMS tasks for this CPU, then + * care should be used in designing the context area. + * + * On some CPUs with hardware floating point support, the Context_Control_fp + * structure will not be used or it simply consist of an array of a + * fixed number of bytes. This is done when the floating point context + * is dumped by a "FP save context" type instruction and the format + * is not really defined by the CPU. In this case, there is no need + * to figure out the exact format -- only the size. Of course, although + * this is enough information for RTEMS, it is probably not enough for + * a debugger such as gdb. But that is another problem. + */ + +#ifndef __SPE__ + #define PPC_GPR_TYPE uintptr_t + #if defined(__powerpc64__) + #define PPC_GPR_SIZE 8 + #define PPC_GPR_LOAD ld + #define PPC_GPR_STORE std + #else + #define PPC_GPR_SIZE 4 + #define PPC_GPR_LOAD lwz + #define PPC_GPR_STORE stw + #endif +#else + #define PPC_GPR_TYPE uint64_t + #define PPC_GPR_SIZE 8 + #define PPC_GPR_LOAD evldd + #define PPC_GPR_STORE evstdd +#endif + +#if defined(__powerpc64__) + #define PPC_REG_SIZE 8 + #define PPC_REG_LOAD ld + #define PPC_REG_STORE std + #define PPC_REG_STORE_UPDATE stdu + #define PPC_REG_CMP cmpd +#else + #define PPC_REG_SIZE 4 + #define PPC_REG_LOAD lwz + #define PPC_REG_STORE stw + #define PPC_REG_STORE_UPDATE stwu + #define PPC_REG_CMP cmpw +#endif + +#ifndef ASM + +/* + * Non-volatile context according to E500ABIUG, EABI and 32-bit TLS (according + * to "Power Architecture 32-bit Application Binary Interface Supplement 1.0 - + * Linux and Embedded") + */ +typedef struct { + uint32_t msr; + uint32_t cr; + uintptr_t gpr1; + uintptr_t lr; + PPC_GPR_TYPE gpr14; + PPC_GPR_TYPE gpr15; + PPC_GPR_TYPE gpr16; + PPC_GPR_TYPE gpr17; + PPC_GPR_TYPE gpr18; + PPC_GPR_TYPE gpr19; + PPC_GPR_TYPE gpr20; + PPC_GPR_TYPE gpr21; + PPC_GPR_TYPE gpr22; + PPC_GPR_TYPE gpr23; + PPC_GPR_TYPE gpr24; + PPC_GPR_TYPE gpr25; + PPC_GPR_TYPE gpr26; + PPC_GPR_TYPE gpr27; + PPC_GPR_TYPE gpr28; + PPC_GPR_TYPE gpr29; + PPC_GPR_TYPE gpr30; + PPC_GPR_TYPE gpr31; + uint32_t isr_dispatch_disable; + uint32_t reserved_for_alignment; + #if defined(PPC_MULTILIB_ALTIVEC) + uint8_t v20[16]; + uint8_t v21[16]; + uint8_t v22[16]; + uint8_t v23[16]; + uint8_t v24[16]; + uint8_t v25[16]; + uint8_t v26[16]; + uint8_t v27[16]; + uint8_t v28[16]; + uint8_t v29[16]; + uint8_t v30[16]; + uint8_t v31[16]; + uint32_t vrsave; + #elif defined(__ALTIVEC__) + /* + * 12 non-volatile vector registers, cache-aligned area for vscr/vrsave + * and padding to ensure cache-alignment. Unfortunately, we can't verify + * the cache line size here in the cpukit but altivec support code will + * produce an error if this is ever different from 32 bytes. + * + * Note: it is the BSP/CPU-support's responsibility to save/restore + * volatile vregs across interrupts and exceptions. + */ + uint8_t altivec[16*12 + 32 + PPC_DEFAULT_CACHE_LINE_SIZE]; + #endif + #if defined(PPC_MULTILIB_FPU) + double f14; + double f15; + double f16; + double f17; + double f18; + double f19; + double f20; + double f21; + double f22; + double f23; + double f24; + double f25; + double f26; + double f27; + double f28; + double f29; + double f30; + double f31; + #endif + /* + * The following items are at the structure end, so that we can use dcbz for + * the previous items to optimize the context switch. We must not set the + * following items to zero via the dcbz. + */ + uintptr_t tp; + #if defined(RTEMS_SMP) + volatile uint32_t is_executing; + #endif +} ppc_context; + +typedef struct { + uint8_t context [ + PPC_DEFAULT_CACHE_LINE_SIZE + + sizeof(ppc_context) + + (sizeof(ppc_context) % PPC_DEFAULT_CACHE_LINE_SIZE == 0 + ? 0 + : PPC_DEFAULT_CACHE_LINE_SIZE + - sizeof(ppc_context) % PPC_DEFAULT_CACHE_LINE_SIZE) + ]; +} Context_Control; + +static inline ppc_context *ppc_get_context( const Context_Control *context ) +{ + uintptr_t clsz = PPC_DEFAULT_CACHE_LINE_SIZE; + uintptr_t mask = clsz - 1; + uintptr_t addr = (uintptr_t) context; + + return (ppc_context *) ((addr & ~mask) + clsz); +} + +#define _CPU_Context_Get_SP( _context ) \ + ppc_get_context(_context)->gpr1 + +#ifdef RTEMS_SMP + static inline bool _CPU_Context_Get_is_executing( + const Context_Control *context + ) + { + return ppc_get_context(context)->is_executing; + } + + static inline void _CPU_Context_Set_is_executing( + Context_Control *context, + bool is_executing + ) + { + ppc_get_context(context)->is_executing = is_executing; + } +#endif +#endif /* ASM */ + +#define PPC_CONTEXT_OFFSET_MSR (PPC_DEFAULT_CACHE_LINE_SIZE) +#define PPC_CONTEXT_OFFSET_CR (PPC_DEFAULT_CACHE_LINE_SIZE + 4) +#define PPC_CONTEXT_OFFSET_GPR1 (PPC_DEFAULT_CACHE_LINE_SIZE + 8) +#define PPC_CONTEXT_OFFSET_LR (PPC_DEFAULT_CACHE_LINE_SIZE + PPC_REG_SIZE + 8) + +#define PPC_CONTEXT_GPR_OFFSET( gpr ) \ + (((gpr) - 14) * PPC_GPR_SIZE + \ + PPC_DEFAULT_CACHE_LINE_SIZE + 8 + 2 * PPC_REG_SIZE) + +#define PPC_CONTEXT_OFFSET_GPR14 PPC_CONTEXT_GPR_OFFSET( 14 ) +#define PPC_CONTEXT_OFFSET_GPR15 PPC_CONTEXT_GPR_OFFSET( 15 ) +#define PPC_CONTEXT_OFFSET_GPR16 PPC_CONTEXT_GPR_OFFSET( 16 ) +#define PPC_CONTEXT_OFFSET_GPR17 PPC_CONTEXT_GPR_OFFSET( 17 ) +#define PPC_CONTEXT_OFFSET_GPR18 PPC_CONTEXT_GPR_OFFSET( 18 ) +#define PPC_CONTEXT_OFFSET_GPR19 PPC_CONTEXT_GPR_OFFSET( 19 ) +#define PPC_CONTEXT_OFFSET_GPR20 PPC_CONTEXT_GPR_OFFSET( 20 ) +#define PPC_CONTEXT_OFFSET_GPR21 PPC_CONTEXT_GPR_OFFSET( 21 ) +#define PPC_CONTEXT_OFFSET_GPR22 PPC_CONTEXT_GPR_OFFSET( 22 ) +#define PPC_CONTEXT_OFFSET_GPR23 PPC_CONTEXT_GPR_OFFSET( 23 ) +#define PPC_CONTEXT_OFFSET_GPR24 PPC_CONTEXT_GPR_OFFSET( 24 ) +#define PPC_CONTEXT_OFFSET_GPR25 PPC_CONTEXT_GPR_OFFSET( 25 ) +#define PPC_CONTEXT_OFFSET_GPR26 PPC_CONTEXT_GPR_OFFSET( 26 ) +#define PPC_CONTEXT_OFFSET_GPR27 PPC_CONTEXT_GPR_OFFSET( 27 ) +#define PPC_CONTEXT_OFFSET_GPR28 PPC_CONTEXT_GPR_OFFSET( 28 ) +#define PPC_CONTEXT_OFFSET_GPR29 PPC_CONTEXT_GPR_OFFSET( 29 ) +#define PPC_CONTEXT_OFFSET_GPR30 PPC_CONTEXT_GPR_OFFSET( 30 ) +#define PPC_CONTEXT_OFFSET_GPR31 PPC_CONTEXT_GPR_OFFSET( 31 ) +#define PPC_CONTEXT_OFFSET_ISR_DISPATCH_DISABLE PPC_CONTEXT_GPR_OFFSET( 32 ) + +#ifdef PPC_MULTILIB_ALTIVEC + #define PPC_CONTEXT_OFFSET_V( v ) \ + ( ( ( v ) - 20 ) * 16 + PPC_CONTEXT_OFFSET_ISR_DISPATCH_DISABLE + 8) + #define PPC_CONTEXT_OFFSET_V20 PPC_CONTEXT_OFFSET_V( 20 ) + #define PPC_CONTEXT_OFFSET_V21 PPC_CONTEXT_OFFSET_V( 21 ) + #define PPC_CONTEXT_OFFSET_V22 PPC_CONTEXT_OFFSET_V( 22 ) + #define PPC_CONTEXT_OFFSET_V23 PPC_CONTEXT_OFFSET_V( 23 ) + #define PPC_CONTEXT_OFFSET_V24 PPC_CONTEXT_OFFSET_V( 24 ) + #define PPC_CONTEXT_OFFSET_V25 PPC_CONTEXT_OFFSET_V( 25 ) + #define PPC_CONTEXT_OFFSET_V26 PPC_CONTEXT_OFFSET_V( 26 ) + #define PPC_CONTEXT_OFFSET_V27 PPC_CONTEXT_OFFSET_V( 27 ) + #define PPC_CONTEXT_OFFSET_V28 PPC_CONTEXT_OFFSET_V( 28 ) + #define PPC_CONTEXT_OFFSET_V29 PPC_CONTEXT_OFFSET_V( 29 ) + #define PPC_CONTEXT_OFFSET_V30 PPC_CONTEXT_OFFSET_V( 30 ) + #define PPC_CONTEXT_OFFSET_V31 PPC_CONTEXT_OFFSET_V( 31 ) + #define PPC_CONTEXT_OFFSET_VRSAVE PPC_CONTEXT_OFFSET_V( 32 ) + #define PPC_CONTEXT_OFFSET_F( f ) \ + ( ( ( f ) - 14 ) * 8 + PPC_CONTEXT_OFFSET_VRSAVE + 8 ) +#else + #define PPC_CONTEXT_OFFSET_F( f ) \ + ( ( ( f ) - 14 ) * 8 + PPC_CONTEXT_OFFSET_ISR_DISPATCH_DISABLE + 8 ) +#endif + +#ifdef PPC_MULTILIB_FPU + #define PPC_CONTEXT_OFFSET_F14 PPC_CONTEXT_OFFSET_F( 14 ) + #define PPC_CONTEXT_OFFSET_F15 PPC_CONTEXT_OFFSET_F( 15 ) + #define PPC_CONTEXT_OFFSET_F16 PPC_CONTEXT_OFFSET_F( 16 ) + #define PPC_CONTEXT_OFFSET_F17 PPC_CONTEXT_OFFSET_F( 17 ) + #define PPC_CONTEXT_OFFSET_F18 PPC_CONTEXT_OFFSET_F( 18 ) + #define PPC_CONTEXT_OFFSET_F19 PPC_CONTEXT_OFFSET_F( 19 ) + #define PPC_CONTEXT_OFFSET_F20 PPC_CONTEXT_OFFSET_F( 20 ) + #define PPC_CONTEXT_OFFSET_F21 PPC_CONTEXT_OFFSET_F( 21 ) + #define PPC_CONTEXT_OFFSET_F22 PPC_CONTEXT_OFFSET_F( 22 ) + #define PPC_CONTEXT_OFFSET_F23 PPC_CONTEXT_OFFSET_F( 23 ) + #define PPC_CONTEXT_OFFSET_F24 PPC_CONTEXT_OFFSET_F( 24 ) + #define PPC_CONTEXT_OFFSET_F25 PPC_CONTEXT_OFFSET_F( 25 ) + #define PPC_CONTEXT_OFFSET_F26 PPC_CONTEXT_OFFSET_F( 26 ) + #define PPC_CONTEXT_OFFSET_F27 PPC_CONTEXT_OFFSET_F( 27 ) + #define PPC_CONTEXT_OFFSET_F28 PPC_CONTEXT_OFFSET_F( 28 ) + #define PPC_CONTEXT_OFFSET_F29 PPC_CONTEXT_OFFSET_F( 29 ) + #define PPC_CONTEXT_OFFSET_F30 PPC_CONTEXT_OFFSET_F( 30 ) + #define PPC_CONTEXT_OFFSET_F31 PPC_CONTEXT_OFFSET_F( 31 ) +#endif + +#if defined(PPC_MULTILIB_FPU) + #define PPC_CONTEXT_VOLATILE_SIZE PPC_CONTEXT_OFFSET_F( 32 ) +#elif defined(PPC_MULTILIB_ALTIVEC) + #define PPC_CONTEXT_VOLATILE_SIZE (PPC_CONTEXT_OFFSET_VRSAVE + 4) +#elif defined(__ALTIVEC__) + #define PPC_CONTEXT_VOLATILE_SIZE \ + (PPC_CONTEXT_GPR_OFFSET( 32 ) + 8 \ + + 16 * 12 + 32 + PPC_DEFAULT_CACHE_LINE_SIZE) +#else + #define PPC_CONTEXT_VOLATILE_SIZE (PPC_CONTEXT_GPR_OFFSET( 32 ) + 8) +#endif + +#define PPC_CONTEXT_OFFSET_TP PPC_CONTEXT_VOLATILE_SIZE + +#ifdef RTEMS_SMP + #define PPC_CONTEXT_OFFSET_IS_EXECUTING \ + (PPC_CONTEXT_OFFSET_TP + PPC_REG_SIZE) +#endif + +#ifndef ASM +typedef struct { +#if (PPC_HAS_FPU == 1) + /* The ABIs (PowerOpen/SVR4/EABI) only require saving f14-f31 over + * procedure calls. However, this would mean that the interrupt + * frame had to hold f0-f13, and the fpscr. And as the majority + * of tasks will not have an FP context, we will save the whole + * context here. + */ +#if (PPC_HAS_DOUBLE == 1) + double f[32]; + uint64_t fpscr; +#else + float f[32]; + uint32_t fpscr; +#endif +#endif /* (PPC_HAS_FPU == 1) */ +} Context_Control_fp; + +#endif /* ASM */ + +/* + * Does the CPU follow the simple vectored interrupt model? + * + * If TRUE, then RTEMS allocates the vector table it internally manages. + * If FALSE, then the BSP is assumed to allocate and manage the vector + * table + * + * PowerPC Specific Information: + * + * The PowerPC and x86 were the first to use the PIC interrupt model. + * They do not use the simple vectored interrupt model. + */ +#define CPU_SIMPLE_VECTORED_INTERRUPTS FALSE + +/* + * Does RTEMS manage a dedicated interrupt stack in software? + * + * If TRUE, then a stack is allocated in _ISR_Handler_initialization. + * If FALSE, nothing is done. + * + * If the CPU supports a dedicated interrupt stack in hardware, + * then it is generally the responsibility of the BSP to allocate it + * and set it up. + * + * If the CPU does not support a dedicated interrupt stack, then + * the porter has two options: (1) execute interrupts on the + * stack of the interrupted task, and (2) have RTEMS manage a dedicated + * interrupt stack. + * + * If this is TRUE, CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. + * + * Only one of CPU_HAS_SOFTWARE_INTERRUPT_STACK and + * CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is + * possible that both are FALSE for a particular CPU. Although it + * is unclear what that would imply about the interrupt processing + * procedure on that CPU. + */ + +#define CPU_HAS_SOFTWARE_INTERRUPT_STACK TRUE + +/* + * Does this CPU have hardware support for a dedicated interrupt stack? + * + * If TRUE, then it must be installed during initialization. + * If FALSE, then no installation is performed. + * + * If this is TRUE, CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. + * + * Only one of CPU_HAS_SOFTWARE_INTERRUPT_STACK and + * CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is + * possible that both are FALSE for a particular CPU. Although it + * is unclear what that would imply about the interrupt processing + * procedure on that CPU. + */ + +#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE + +/* + * Does RTEMS allocate a dedicated interrupt stack in the Interrupt Manager? + * + * If TRUE, then the memory is allocated during initialization. + * If FALSE, then the memory is allocated during initialization. + * + * This should be TRUE is CPU_HAS_SOFTWARE_INTERRUPT_STACK is TRUE. + */ + +#define CPU_ALLOCATE_INTERRUPT_STACK TRUE + +/* + * Does the RTEMS invoke the user's ISR with the vector number and + * a pointer to the saved interrupt frame (1) or just the vector + * number (0)? + */ + +#define CPU_ISR_PASSES_FRAME_POINTER FALSE + +/* + * Should the saving of the floating point registers be deferred + * until a context switch is made to another different floating point + * task? + * + * If TRUE, then the floating point context will not be stored until + * necessary. It will remain in the floating point registers and not + * disturned until another floating point task is switched to. + * + * If FALSE, then the floating point context is saved when a floating + * point task is switched out and restored when the next floating point + * task is restored. The state of the floating point registers between + * those two operations is not specified. + * + * If the floating point context does NOT have to be saved as part of + * interrupt dispatching, then it should be safe to set this to TRUE. + * + * Setting this flag to TRUE results in using a different algorithm + * for deciding when to save and restore the floating point context. + * The deferred FP switch algorithm minimizes the number of times + * the FP context is saved and restored. The FP context is not saved + * until a context switch is made to another, different FP task. + * Thus in a system with only one FP task, the FP context will never + * be saved or restored. + * + * Note, however that compilers may use floating point registers/ + * instructions for optimization or they may save/restore FP registers + * on the stack. You must not use deferred switching in these cases + * and on the PowerPC attempting to do so will raise a "FP unavailable" + * exception. + */ +/* + * ACB Note: This could make debugging tricky.. + */ + +/* conservative setting (FALSE); probably doesn't affect performance too much */ +#define CPU_USE_DEFERRED_FP_SWITCH FALSE + +#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE + +/* + * Processor defined structures required for cpukit/score. + */ + +#ifndef ASM + +/* + * This variable is optional. It is used on CPUs on which it is difficult + * to generate an "uninitialized" FP context. It is filled in by + * _CPU_Initialize and copied into the task's FP context area during + * _CPU_Context_Initialize. + */ + +/* EXTERN Context_Control_fp _CPU_Null_fp_context; */ + +#endif /* ndef ASM */ + +/* + * This defines the number of levels and the mask used to pick those + * bits out of a thread mode. + */ + +#define CPU_MODES_INTERRUPT_LEVEL 0x00000001 /* interrupt level in mode */ +#define CPU_MODES_INTERRUPT_MASK 0x00000001 /* interrupt level in mode */ + +/* + * The size of the floating point context area. On some CPUs this + * will not be a "sizeof" because the format of the floating point + * area is not defined -- only the size is. This is usually on + * CPUs with a "floating point save context" instruction. + */ + +#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp ) + +/* + * (Optional) # of bytes for libmisc/stackchk to check + * If not specifed, then it defaults to something reasonable + * for most architectures. + */ + +#define CPU_STACK_CHECK_PATTERN_INITIALIZER \ + { 0xFEEDF00D, 0x0BAD0D06, 0xDEADF00D, 0x600D0D06, \ + 0xFEEDF00D, 0x0BAD0D06, 0xDEADF00D, 0x600D0D06, \ + 0xFEEDF00D, 0x0BAD0D06, 0xDEADF00D, 0x600D0D06, \ + 0xFEEDF00D, 0x0BAD0D06, 0xDEADF00D, 0x600D0D06, \ + 0xFEEDF00D, 0x0BAD0D06, 0xDEADF00D, 0x600D0D06, \ + 0xFEEDF00D, 0x0BAD0D06, 0xDEADF00D, 0x600D0D06, \ + 0xFEEDF00D, 0x0BAD0D06, 0xDEADF00D, 0x600D0D06, \ + 0xFEEDF00D, 0x0BAD0D06, 0xDEADF00D, 0x600D0D06 } + +/* + * Amount of extra stack (above minimum stack size) required by + * MPCI receive server thread. Remember that in a multiprocessor + * system this thread must exist and be able to process all directives. + */ + +#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0 + +/* + * This is defined if the port has a special way to report the ISR nesting + * level. Most ports maintain the variable _ISR_Nest_level. Note that + * this is not an option - RTEMS/score _relies_ on _ISR_Nest_level + * being maintained (e.g. watchdog queues). + */ + +#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE + +/* + * ISR handler macros + */ + +/* + * Disable all interrupts for an RTEMS critical section. The previous + * level is returned in _isr_cookie. + */ + +#ifndef ASM + +RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) +{ + return ( level & MSR_EE ) != 0; +} + +static inline uint32_t _CPU_ISR_Get_level( void ) +{ + register unsigned int msr; + _CPU_MSR_GET(msr); + if (msr & MSR_EE) return 0; + else return 1; +} + +static inline void _CPU_ISR_Set_level( uint32_t level ) +{ + register unsigned int msr; + _CPU_MSR_GET(msr); + if (!(level & CPU_MODES_INTERRUPT_MASK)) { + msr |= ppc_interrupt_get_disable_mask(); + } + else { + msr &= ~ppc_interrupt_get_disable_mask(); + } + _CPU_MSR_SET(msr); +} + +#endif /* ASM */ + +#define _CPU_Fatal_halt( _source, _error ) \ + do { \ + ppc_interrupt_disable(); \ + __asm__ volatile ( \ + "mr 3, %0\n" \ + "mr 4, %1\n" \ + "1:\n" \ + "b 1b\n" \ + : \ + : "r" (_source), "r" (_error) \ + : "memory" \ + ); \ + } while ( 0 ) + +/* + * Should be large enough to run all RTEMS tests. This ensures + * that a "reasonable" small application should not have any problems. + */ + +#define CPU_STACK_MINIMUM_SIZE (1024*8) + +#if defined(__powerpc64__) +#define CPU_SIZEOF_POINTER 8 +#else +#define CPU_SIZEOF_POINTER 4 +#endif + +/* + * CPU's worst alignment requirement for data types on a byte boundary. This + * alignment does not take into account the requirements for the stack. + */ + +#define CPU_ALIGNMENT (PPC_ALIGNMENT) + +/* + * This number corresponds to the byte alignment requirement for the + * heap handler. This alignment requirement may be stricter than that + * for the data types alignment specified by CPU_ALIGNMENT. It is + * common for the heap to follow the same alignment requirement as + * CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict enough for the heap, + * then this should be set to CPU_ALIGNMENT. + * + * NOTE: This does not have to be a power of 2. It does have to + * be greater or equal to than CPU_ALIGNMENT. + */ + +#define CPU_HEAP_ALIGNMENT (PPC_ALIGNMENT) + +/* + * This number corresponds to the byte alignment requirement for memory + * buffers allocated by the partition manager. This alignment requirement + * may be stricter than that for the data types alignment specified by + * CPU_ALIGNMENT. It is common for the partition to follow the same + * alignment requirement as CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict + * enough for the partition, then this should be set to CPU_ALIGNMENT. + * + * NOTE: This does not have to be a power of 2. It does have to + * be greater or equal to than CPU_ALIGNMENT. + */ + +#define CPU_PARTITION_ALIGNMENT (PPC_ALIGNMENT) + +/* + * This number corresponds to the byte alignment requirement for the + * stack. This alignment requirement may be stricter than that for the + * data types alignment specified by CPU_ALIGNMENT. If the CPU_ALIGNMENT + * is strict enough for the stack, then this should be set to 0. + * + * NOTE: This must be a power of 2 either 0 or greater than CPU_ALIGNMENT. + */ + +#define CPU_STACK_ALIGNMENT (PPC_STACK_ALIGNMENT) + +#ifndef ASM +/* The following routine swaps the endian format of an unsigned int. + * It must be static because it is referenced indirectly. + * + * This version will work on any processor, but if there is a better + * way for your CPU PLEASE use it. The most common way to do this is to: + * + * swap least significant two bytes with 16-bit rotate + * swap upper and lower 16-bits + * swap most significant two bytes with 16-bit rotate + * + * Some CPUs have special instructions which swap a 32-bit quantity in + * a single instruction (e.g. i486). It is probably best to avoid + * an "endian swapping control bit" in the CPU. One good reason is + * that interrupts would probably have to be disabled to ensure that + * an interrupt does not try to access the same "chunk" with the wrong + * endian. Another good reason is that on some CPUs, the endian bit + * endianness for ALL fetches -- both code and data -- so the code + * will be fetched incorrectly. + */ + +static inline uint32_t CPU_swap_u32( + uint32_t value +) +{ + uint32_t swapped; + + __asm__ volatile("rlwimi %0,%1,8,24,31;" + "rlwimi %0,%1,24,16,23;" + "rlwimi %0,%1,8,8,15;" + "rlwimi %0,%1,24,0,7;" : + "=&r" ((swapped)) : "r" ((value))); + + return( swapped ); +} + +#define CPU_swap_u16( value ) \ + (((value&0xff) << 8) | ((value >> 8)&0xff)) + +typedef uint32_t CPU_Counter_ticks; + +static inline CPU_Counter_ticks _CPU_Counter_read( void ) +{ + CPU_Counter_ticks value; + +#if defined(__PPC_CPU_E6500__) + /* Use Alternate Time Base */ + __asm__ volatile( "mfspr %0, 526" : "=r" (value) ); +#else + __asm__ volatile( "mfspr %0, 268" : "=r" (value) ); +#endif + + return value; +} + +static inline CPU_Counter_ticks _CPU_Counter_difference( + CPU_Counter_ticks second, + CPU_Counter_ticks first +) +{ + return second - first; +} + +#endif /* ASM */ + + +#ifndef ASM +/* Context handler macros */ + +/* + * Initialize the context to a state suitable for starting a + * task after a context restore operation. Generally, this + * involves: + * + * - setting a starting address + * - preparing the stack + * - preparing the stack and frame pointers + * - setting the proper interrupt level in the context + * - initializing the floating point context + * + * This routine generally does not set any unnecessary register + * in the context. The state of the "general data" registers is + * undefined at task start time. + */ + +void _CPU_Context_Initialize( + Context_Control *the_context, + void *stack_base, + size_t size, + uint32_t new_level, + void *entry_point, + bool is_fp, + void *tls_area +); + +/* + * This routine is responsible for somehow restarting the currently + * executing task. If you are lucky, then all that is necessary + * is restoring the context. Otherwise, there will need to be + * a special assembly routine which does something special in this + * case. Context_Restore should work most of the time. It will + * not work if restarting self conflicts with the stack frame + * assumptions of restoring a context. + */ + +#define _CPU_Context_Restart_self( _the_context ) \ + _CPU_Context_restore( (_the_context) ); + +/* + * This routine initializes the FP context area passed to it to. + * There are a few standard ways in which to initialize the + * floating point context. The code included for this macro assumes + * that this is a CPU in which a "initial" FP context was saved into + * _CPU_Null_fp_context and it simply copies it to the destination + * context passed to it. + * + * Other models include (1) not doing anything, and (2) putting + * a "null FP status word" in the correct place in the FP context. + */ + +#define _CPU_Context_Initialize_fp( _destination ) \ + memset( *(_destination), 0, sizeof( **(_destination) ) ) + +/* end of Context handler macros */ +#endif /* ASM */ + +#ifndef ASM +/* Bitfield handler macros */ + +#define CPU_USE_GENERIC_BITFIELD_CODE FALSE + +/* + * This routine sets _output to the bit number of the first bit + * set in _value. _value is of CPU dependent type Priority_bit_map_Word. + * This type may be either 16 or 32 bits wide although only the 16 + * least significant bits will be used. + * + * There are a number of variables in using a "find first bit" type + * instruction. + * + * (1) What happens when run on a value of zero? + * (2) Bits may be numbered from MSB to LSB or vice-versa. + * (3) The numbering may be zero or one based. + * (4) The "find first bit" instruction may search from MSB or LSB. + * + * RTEMS guarantees that (1) will never happen so it is not a concern. + * (2),(3), (4) are handled by the macros _CPU_Priority_mask() and + * _CPU_Priority_Bits_index(). These three form a set of routines + * which must logically operate together. Bits in the _value are + * set and cleared based on masks built by _CPU_Priority_mask(). + * The basic major and minor values calculated by _Priority_Major() + * and _Priority_Minor() are "massaged" by _CPU_Priority_Bits_index() + * to properly range between the values returned by the "find first bit" + * instruction. This makes it possible for _Priority_Get_highest() to + * calculate the major and directly index into the minor table. + * This mapping is necessary to ensure that 0 (a high priority major/minor) + * is the first bit found. + * + * This entire "find first bit" and mapping process depends heavily + * on the manner in which a priority is broken into a major and minor + * components with the major being the 4 MSB of a priority and minor + * the 4 LSB. Thus (0 << 4) + 0 corresponds to priority 0 -- the highest + * priority. And (15 << 4) + 14 corresponds to priority 254 -- the next + * to the lowest priority. + * + * If your CPU does not have a "find first bit" instruction, then + * there are ways to make do without it. Here are a handful of ways + * to implement this in software: + * + * - a series of 16 bit test instructions + * - a "binary search using if's" + * - _number = 0 + * if _value > 0x00ff + * _value >>=8 + * _number = 8; + * + * if _value > 0x0000f + * _value >=8 + * _number += 4 + * + * _number += bit_set_table[ _value ] + * + * where bit_set_table[ 16 ] has values which indicate the first + * bit set + */ + +#define _CPU_Bitfield_Find_first_bit( _value, _output ) \ + { \ + __asm__ volatile ("cntlzw %0, %1" : "=r" ((_output)), "=r" ((_value)) : \ + "1" ((_value))); \ + (_output) = (_output) - 16; \ + } + +/* end of Bitfield handler macros */ + +/* + * This routine builds the mask which corresponds to the bit fields + * as searched by _CPU_Bitfield_Find_first_bit(). See the discussion + * for that routine. + */ + +#define _CPU_Priority_Mask( _bit_number ) \ + ( 0x8000u >> (_bit_number) ) + +/* + * This routine translates the bit numbers returned by + * _CPU_Bitfield_Find_first_bit() into something suitable for use as + * a major or minor component of a priority. See the discussion + * for that routine. + */ + +#define _CPU_Priority_bits_index( _priority ) \ + (_priority) + +/* end of Priority handler macros */ +#endif /* ASM */ + +/* functions */ + +#ifndef ASM + +/* + * _CPU_Initialize + * + * This routine performs CPU dependent initialization. + */ + +void _CPU_Initialize(void); + +/* + * _CPU_ISR_install_vector + * + * This routine installs an interrupt vector. + */ + +void _CPU_ISR_install_vector( + uint32_t vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +/* + * _CPU_Context_switch + * + * This routine switches from the run context to the heir context. + */ + +void _CPU_Context_switch( + Context_Control *run, + Context_Control *heir +); + +/* + * _CPU_Context_restore + * + * This routine is generallu used only to restart self in an + * efficient manner. It may simply be a label in _CPU_Context_switch. + * + * NOTE: May be unnecessary to reload some registers. + */ + +void _CPU_Context_restore( + Context_Control *new_context +) RTEMS_NO_RETURN; + +/* + * _CPU_Context_save_fp + * + * This routine saves the floating point context passed to it. + */ + +void _CPU_Context_save_fp( + Context_Control_fp **fp_context_ptr +); + +/* + * _CPU_Context_restore_fp + * + * This routine restores the floating point context passed to it. + */ + +void _CPU_Context_restore_fp( + Context_Control_fp **fp_context_ptr +); + +void _CPU_Context_volatile_clobber( uintptr_t pattern ); + +void _CPU_Context_validate( uintptr_t pattern ); + +#ifdef RTEMS_SMP + uint32_t _CPU_SMP_Initialize( void ); + + bool _CPU_SMP_Start_processor( uint32_t cpu_index ); + + void _CPU_SMP_Finalize_initialization( uint32_t cpu_count ); + + void _CPU_SMP_Prepare_start_multitasking( void ); + + static inline uint32_t _CPU_SMP_Get_current_processor( void ) + { + uint32_t pir; + + /* Use Book E Processor ID Register (PIR) */ + __asm__ volatile ( + "mfspr %[pir], 286" + : [pir] "=&r" (pir) + ); + + return pir; + } + + void _CPU_SMP_Send_interrupt( uint32_t target_processor_index ); + + static inline void _CPU_SMP_Processor_event_broadcast( void ) + { + __asm__ volatile ( "" : : : "memory" ); + } + + static inline void _CPU_SMP_Processor_event_receive( void ) + { + __asm__ volatile ( "" : : : "memory" ); + } +#endif + +typedef struct { + uintptr_t EXC_SRR0; + uintptr_t EXC_SRR1; + uint32_t _EXC_number; + uint32_t RESERVED_FOR_ALIGNMENT_0; + uint32_t EXC_CR; + uint32_t EXC_XER; + uintptr_t EXC_CTR; + uintptr_t EXC_LR; + uintptr_t RESERVED_FOR_ALIGNMENT_1; + #ifdef __SPE__ + uint32_t EXC_SPEFSCR; + uint64_t EXC_ACC; + #endif + PPC_GPR_TYPE GPR0; + PPC_GPR_TYPE GPR1; + PPC_GPR_TYPE GPR2; + PPC_GPR_TYPE GPR3; + PPC_GPR_TYPE GPR4; + PPC_GPR_TYPE GPR5; + PPC_GPR_TYPE GPR6; + PPC_GPR_TYPE GPR7; + PPC_GPR_TYPE GPR8; + PPC_GPR_TYPE GPR9; + PPC_GPR_TYPE GPR10; + PPC_GPR_TYPE GPR11; + PPC_GPR_TYPE GPR12; + PPC_GPR_TYPE GPR13; + PPC_GPR_TYPE GPR14; + PPC_GPR_TYPE GPR15; + PPC_GPR_TYPE GPR16; + PPC_GPR_TYPE GPR17; + PPC_GPR_TYPE GPR18; + PPC_GPR_TYPE GPR19; + PPC_GPR_TYPE GPR20; + PPC_GPR_TYPE GPR21; + PPC_GPR_TYPE GPR22; + PPC_GPR_TYPE GPR23; + PPC_GPR_TYPE GPR24; + PPC_GPR_TYPE GPR25; + PPC_GPR_TYPE GPR26; + PPC_GPR_TYPE GPR27; + PPC_GPR_TYPE GPR28; + PPC_GPR_TYPE GPR29; + PPC_GPR_TYPE GPR30; + PPC_GPR_TYPE GPR31; + uintptr_t RESERVED_FOR_ALIGNMENT_2; + #ifdef PPC_MULTILIB_ALTIVEC + uint32_t VRSAVE; + uint32_t RESERVED_FOR_ALIGNMENT_3[3]; + + /* This field must take stvewx/lvewx requirements into account */ + uint32_t RESERVED_FOR_ALIGNMENT_4[3]; + uint32_t VSCR; + + uint8_t V0[16]; + uint8_t V1[16]; + uint8_t V2[16]; + uint8_t V3[16]; + uint8_t V4[16]; + uint8_t V5[16]; + uint8_t V6[16]; + uint8_t V7[16]; + uint8_t V8[16]; + uint8_t V9[16]; + uint8_t V10[16]; + uint8_t V11[16]; + uint8_t V12[16]; + uint8_t V13[16]; + uint8_t V14[16]; + uint8_t V15[16]; + uint8_t V16[16]; + uint8_t V17[16]; + uint8_t V18[16]; + uint8_t V19[16]; + uint8_t V20[16]; + uint8_t V21[16]; + uint8_t V22[16]; + uint8_t V23[16]; + uint8_t V24[16]; + uint8_t V25[16]; + uint8_t V26[16]; + uint8_t V27[16]; + uint8_t V28[16]; + uint8_t V29[16]; + uint8_t V30[16]; + uint8_t V31[16]; + #endif + #ifdef PPC_MULTILIB_FPU + double F0; + double F1; + double F2; + double F3; + double F4; + double F5; + double F6; + double F7; + double F8; + double F9; + double F10; + double F11; + double F12; + double F13; + double F14; + double F15; + double F16; + double F17; + double F18; + double F19; + double F20; + double F21; + double F22; + double F23; + double F24; + double F25; + double F26; + double F27; + double F28; + double F29; + double F30; + double F31; + uint64_t FPSCR; + uint64_t RESERVED_FOR_ALIGNMENT_5; + #endif +} CPU_Exception_frame; + +void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); + +/* + * _CPU_Initialize_altivec() + * + * Global altivec-related initialization. + */ +void +_CPU_Initialize_altivec(void); + +/* + * _CPU_Context_switch_altivec + * + * This routine switches the altivec contexts passed to it. + */ + +void +_CPU_Context_switch_altivec( + ppc_context *from, + ppc_context *to +); + +/* + * _CPU_Context_restore_altivec + * + * This routine restores the altivec context passed to it. + */ + +void +_CPU_Context_restore_altivec( + ppc_context *ctxt +); + +/* + * _CPU_Context_initialize_altivec + * + * This routine initializes the altivec context passed to it. + */ + +void +_CPU_Context_initialize_altivec( + ppc_context *ctxt +); + +void _CPU_Fatal_error( + uint32_t _error +); + +#endif /* ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_SCORE_CPU_H */ diff --git a/cpukit/score/cpu/powerpc/include/rtems/score/cpuatomic.h b/cpukit/score/cpu/powerpc/include/rtems/score/cpuatomic.h new file mode 100644 index 0000000000..598ee76b20 --- /dev/null +++ b/cpukit/score/cpu/powerpc/include/rtems/score/cpuatomic.h @@ -0,0 +1,14 @@ +/* + * COPYRIGHT (c) 2012-2013 Deng Hengyi. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_ATOMIC_CPU_H +#define _RTEMS_SCORE_ATOMIC_CPU_H + +#include + +#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/powerpc/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/powerpc/include/rtems/score/cpuimpl.h new file mode 100644 index 0000000000..792a8111ad --- /dev/null +++ b/cpukit/score/cpu/powerpc/include/rtems/score/cpuimpl.h @@ -0,0 +1,247 @@ +/** + * @file + * + * @brief CPU Port Implementation API + */ + +/* + * Copyright (C) 1999 Eric Valette (valette@crf.canon.fr) + * Canon Centre Recherche France. + * + * Copyright (C) 2007 Till Straumann + * + * Copyright (c) 2009, 2017 embedded brains GmbH + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPUIMPL_H +#define _RTEMS_SCORE_CPUIMPL_H + +#include + +/* Exception stack frame -> BSP_Exception_frame */ +#ifdef __powerpc64__ + #define FRAME_LINK_SPACE 32 +#else + #define FRAME_LINK_SPACE 8 +#endif + +#define SRR0_FRAME_OFFSET FRAME_LINK_SPACE +#define SRR1_FRAME_OFFSET (SRR0_FRAME_OFFSET + PPC_REG_SIZE) +#define EXCEPTION_NUMBER_OFFSET (SRR1_FRAME_OFFSET + PPC_REG_SIZE) +#define PPC_EXC_INTERRUPT_ENTRY_INSTANT_OFFSET (EXCEPTION_NUMBER_OFFSET + 4) +#define EXC_CR_OFFSET (EXCEPTION_NUMBER_OFFSET + 8) +#define EXC_XER_OFFSET (EXC_CR_OFFSET + 4) +#define EXC_CTR_OFFSET (EXC_XER_OFFSET + 4) +#define EXC_LR_OFFSET (EXC_CTR_OFFSET + PPC_REG_SIZE) +#define PPC_EXC_INTERRUPT_FRAME_OFFSET (EXC_LR_OFFSET + PPC_REG_SIZE) + +#ifndef __SPE__ + #define PPC_EXC_GPR_OFFSET(gpr) \ + ((gpr) * PPC_GPR_SIZE + PPC_EXC_INTERRUPT_FRAME_OFFSET + PPC_REG_SIZE) + #define PPC_EXC_GPR3_PROLOGUE_OFFSET PPC_EXC_GPR_OFFSET(3) + #if defined(PPC_MULTILIB_ALTIVEC) && defined(PPC_MULTILIB_FPU) + #define PPC_EXC_VRSAVE_OFFSET PPC_EXC_GPR_OFFSET(33) + #define PPC_EXC_VSCR_OFFSET (PPC_EXC_VRSAVE_OFFSET + 28) + #define PPC_EXC_VR_OFFSET(v) ((v) * 16 + PPC_EXC_VSCR_OFFSET + 4) + #define PPC_EXC_FR_OFFSET(f) ((f) * 8 + PPC_EXC_VR_OFFSET(32)) + #define PPC_EXC_FPSCR_OFFSET PPC_EXC_FR_OFFSET(32) + #define PPC_EXC_FRAME_SIZE PPC_EXC_FR_OFFSET(34) + #define PPC_EXC_MIN_VSCR_OFFSET (PPC_EXC_GPR_OFFSET(13) + 12) + #define PPC_EXC_MIN_VR_OFFSET(v) ((v) * 16 + PPC_EXC_MIN_VSCR_OFFSET + 4) + #define PPC_EXC_MIN_FR_OFFSET(f) ((f) * 8 + PPC_EXC_MIN_VR_OFFSET(20)) + #define PPC_EXC_MIN_FPSCR_OFFSET PPC_EXC_MIN_FR_OFFSET(14) + #define CPU_INTERRUPT_FRAME_SIZE \ + (PPC_EXC_MIN_FR_OFFSET(16) + PPC_STACK_RED_ZONE_SIZE) + #elif defined(PPC_MULTILIB_ALTIVEC) + #define PPC_EXC_VRSAVE_OFFSET PPC_EXC_GPR_OFFSET(33) + #define PPC_EXC_VSCR_OFFSET (PPC_EXC_VRSAVE_OFFSET + 28) + #define PPC_EXC_VR_OFFSET(v) ((v) * 16 + PPC_EXC_VSCR_OFFSET + 4) + #define PPC_EXC_FRAME_SIZE PPC_EXC_VR_OFFSET(32) + #define PPC_EXC_MIN_VSCR_OFFSET (PPC_EXC_GPR_OFFSET(13) + 12) + #define PPC_EXC_MIN_VR_OFFSET(v) ((v) * 16 + PPC_EXC_MIN_VSCR_OFFSET + 4) + #define CPU_INTERRUPT_FRAME_SIZE \ + (PPC_EXC_MIN_VR_OFFSET(20) + PPC_STACK_RED_ZONE_SIZE) + #elif defined(PPC_MULTILIB_FPU) + #define PPC_EXC_FR_OFFSET(f) ((f) * 8 + PPC_EXC_GPR_OFFSET(33)) + #define PPC_EXC_FPSCR_OFFSET PPC_EXC_FR_OFFSET(32) + #define PPC_EXC_FRAME_SIZE PPC_EXC_FR_OFFSET(34) + #define PPC_EXC_MIN_FR_OFFSET(f) ((f) * 8 + PPC_EXC_GPR_OFFSET(13)) + #define PPC_EXC_MIN_FPSCR_OFFSET PPC_EXC_MIN_FR_OFFSET(14) + #define CPU_INTERRUPT_FRAME_SIZE \ + (PPC_EXC_MIN_FR_OFFSET(16) + PPC_STACK_RED_ZONE_SIZE) + #else + #define PPC_EXC_FRAME_SIZE PPC_EXC_GPR_OFFSET(33) + #define CPU_INTERRUPT_FRAME_SIZE \ + (PPC_EXC_GPR_OFFSET(13) + PPC_STACK_RED_ZONE_SIZE) + #endif +#else + #define PPC_EXC_SPEFSCR_OFFSET 44 + #define PPC_EXC_ACC_OFFSET 48 + #define PPC_EXC_GPR_OFFSET(gpr) ((gpr) * PPC_GPR_SIZE + 56) + #define PPC_EXC_GPR3_PROLOGUE_OFFSET (PPC_EXC_GPR_OFFSET(3) + 4) + #define CPU_INTERRUPT_FRAME_SIZE (160 + PPC_STACK_RED_ZONE_SIZE) + #define PPC_EXC_FRAME_SIZE 320 +#endif + +#define GPR0_OFFSET PPC_EXC_GPR_OFFSET(0) +#define GPR1_OFFSET PPC_EXC_GPR_OFFSET(1) +#define GPR2_OFFSET PPC_EXC_GPR_OFFSET(2) +#define GPR3_OFFSET PPC_EXC_GPR_OFFSET(3) +#define GPR4_OFFSET PPC_EXC_GPR_OFFSET(4) +#define GPR5_OFFSET PPC_EXC_GPR_OFFSET(5) +#define GPR6_OFFSET PPC_EXC_GPR_OFFSET(6) +#define GPR7_OFFSET PPC_EXC_GPR_OFFSET(7) +#define GPR8_OFFSET PPC_EXC_GPR_OFFSET(8) +#define GPR9_OFFSET PPC_EXC_GPR_OFFSET(9) +#define GPR10_OFFSET PPC_EXC_GPR_OFFSET(10) +#define GPR11_OFFSET PPC_EXC_GPR_OFFSET(11) +#define GPR12_OFFSET PPC_EXC_GPR_OFFSET(12) +#define GPR13_OFFSET PPC_EXC_GPR_OFFSET(13) +#define GPR14_OFFSET PPC_EXC_GPR_OFFSET(14) +#define GPR15_OFFSET PPC_EXC_GPR_OFFSET(15) +#define GPR16_OFFSET PPC_EXC_GPR_OFFSET(16) +#define GPR17_OFFSET PPC_EXC_GPR_OFFSET(17) +#define GPR18_OFFSET PPC_EXC_GPR_OFFSET(18) +#define GPR19_OFFSET PPC_EXC_GPR_OFFSET(19) +#define GPR20_OFFSET PPC_EXC_GPR_OFFSET(20) +#define GPR21_OFFSET PPC_EXC_GPR_OFFSET(21) +#define GPR22_OFFSET PPC_EXC_GPR_OFFSET(22) +#define GPR23_OFFSET PPC_EXC_GPR_OFFSET(23) +#define GPR24_OFFSET PPC_EXC_GPR_OFFSET(24) +#define GPR25_OFFSET PPC_EXC_GPR_OFFSET(25) +#define GPR26_OFFSET PPC_EXC_GPR_OFFSET(26) +#define GPR27_OFFSET PPC_EXC_GPR_OFFSET(27) +#define GPR28_OFFSET PPC_EXC_GPR_OFFSET(28) +#define GPR29_OFFSET PPC_EXC_GPR_OFFSET(29) +#define GPR30_OFFSET PPC_EXC_GPR_OFFSET(30) +#define GPR31_OFFSET PPC_EXC_GPR_OFFSET(31) + +#define CPU_PER_CPU_CONTROL_SIZE 0 + +#ifdef RTEMS_SMP + +/* Use SPRG0 for the per-CPU control of the current processor */ +#define PPC_PER_CPU_CONTROL_REGISTER 272 + +#endif /* RTEMS_SMP */ + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + uintptr_t FRAME_SP; + #ifdef __powerpc64__ + uint32_t FRAME_CR; + uint32_t FRAME_RESERVED; + #endif + uintptr_t FRAME_LR; + #ifdef __powerpc64__ + uintptr_t FRAME_TOC; + #endif + uintptr_t EXC_SRR0; + uintptr_t EXC_SRR1; + uint32_t RESERVED_FOR_ALIGNMENT_0; + uint32_t EXC_INTERRUPT_ENTRY_INSTANT; + uint32_t EXC_CR; + uint32_t EXC_XER; + uintptr_t EXC_CTR; + uintptr_t EXC_LR; + uintptr_t EXC_INTERRUPT_FRAME; + #ifdef __SPE__ + uint32_t EXC_SPEFSCR; + uint64_t EXC_ACC; + #endif + PPC_GPR_TYPE GPR0; + PPC_GPR_TYPE GPR1; + PPC_GPR_TYPE GPR2; + PPC_GPR_TYPE GPR3; + PPC_GPR_TYPE GPR4; + PPC_GPR_TYPE GPR5; + PPC_GPR_TYPE GPR6; + PPC_GPR_TYPE GPR7; + PPC_GPR_TYPE GPR8; + PPC_GPR_TYPE GPR9; + PPC_GPR_TYPE GPR10; + PPC_GPR_TYPE GPR11; + PPC_GPR_TYPE GPR12; + #ifdef PPC_MULTILIB_ALTIVEC + /* This field must take stvewx/lvewx requirements into account */ + uint32_t RESERVED_FOR_ALIGNMENT_3[3]; + uint32_t VSCR; + + uint8_t V0[16]; + uint8_t V1[16]; + uint8_t V2[16]; + uint8_t V3[16]; + uint8_t V4[16]; + uint8_t V5[16]; + uint8_t V6[16]; + uint8_t V7[16]; + uint8_t V8[16]; + uint8_t V9[16]; + uint8_t V10[16]; + uint8_t V11[16]; + uint8_t V12[16]; + uint8_t V13[16]; + uint8_t V14[16]; + uint8_t V15[16]; + uint8_t V16[16]; + uint8_t V17[16]; + uint8_t V18[16]; + uint8_t V19[16]; + #endif + #ifdef PPC_MULTILIB_FPU + double F0; + double F1; + double F2; + double F3; + double F4; + double F5; + double F6; + double F7; + double F8; + double F9; + double F10; + double F11; + double F12; + double F13; + uint64_t FPSCR; + uint64_t RESERVED_FOR_ALIGNMENT_4; + #endif + #if PPC_STACK_RED_ZONE_SIZE > 0 + uint8_t RED_ZONE[ PPC_STACK_RED_ZONE_SIZE ]; + #endif +} CPU_Interrupt_frame; + +#ifdef RTEMS_SMP + +static inline struct Per_CPU_Control *_PPC_Get_current_per_CPU_control( void ) +{ + struct Per_CPU_Control *cpu_self; + + __asm__ volatile ( + "mfspr %0, " RTEMS_XSTRING( PPC_PER_CPU_CONTROL_REGISTER ) + : "=r" ( cpu_self ) + ); + + return cpu_self; +} + +#define _CPU_Get_current_per_CPU_control() _PPC_Get_current_per_CPU_control() + +#endif /* RTEMS_SMP */ + +#ifdef __cplusplus +} +#endif + +#endif /* ASM */ + +#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/powerpc/include/rtems/score/powerpc.h b/cpukit/score/cpu/powerpc/include/rtems/score/powerpc.h new file mode 100644 index 0000000000..88ee0020e6 --- /dev/null +++ b/cpukit/score/cpu/powerpc/include/rtems/score/powerpc.h @@ -0,0 +1,187 @@ +/** + * @file + * + * @brief IBM/Motorola Power Pc Definitions + * + * This file contains definitions for the IBM/Motorola PowerPC + * family members. + */ + +/* + * Author: Andrew Bray + * + * COPYRIGHT (c) 1995 by i-cubed ltd. + * + * MPC860 support code was added by Jay Monkman + * MPC8260 support added by Andy Dachs + * Surrey Satellite Technology Limited + * + * To anyone who acknowledges that this file is provided "AS IS" + * without any express or implied warranty: + * permission to use, copy, modify, and distribute this file + * for any purpose is hereby granted without fee, provided that + * the above copyright notice and this notice appears in all + * copies, and that the name of i-cubed limited not be used in + * advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * i-cubed limited makes no representations about the suitability + * of this software for any purpose. + * + * Derived from c/src/exec/cpu/no_cpu/no_cpu.h: + * + * COPYRIGHT (c) 1989-1997. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may in + * the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + * + * Note: + * This file is included by both C and assembler code ( -DASM ) + */ + + +#ifndef _RTEMS_SCORE_POWERPC_H +#define _RTEMS_SCORE_POWERPC_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* + * Define the name of the CPU family. + */ + +#define CPU_NAME "PowerPC" + +/* + * This file contains the information required to build + * RTEMS for the PowerPC family. + */ + +/* Generic ppc */ + +#ifdef _SOFT_FLOAT +#define CPU_MODEL_NAME "Generic (no FPU)" +#elif defined(__NO_FPRS__) || defined(__SPE__) +#define CPU_MODEL_NAME "Generic (E500/float-gprs/SPE)" +#else +#define CPU_MODEL_NAME "Generic (classic FPU)" +#endif + +#ifdef __PPC_CPU_E6500__ +#define PPC_DEFAULT_CACHE_LINE_POWER 6 +#else +#define PPC_DEFAULT_CACHE_LINE_POWER 5 +#endif + +#define PPC_DEFAULT_CACHE_LINE_SIZE (1 << PPC_DEFAULT_CACHE_LINE_POWER) + +#define PPC_STRUCTURE_ALIGNMENT PPC_DEFAULT_CACHE_LINE_SIZE + +/* + * Application binary interfaces. + * + * PPC_ABI MUST be defined as one of these. + * Only big endian is currently supported. + */ + +/* + * SVR4 ABI + */ +#define PPC_ABI_SVR4 2 +/* + * Embedded ABI + */ +#define PPC_ABI_EABI 3 + +/* + * Default to the EABI used by current GNU tools + */ + +#ifndef PPC_ABI +#define PPC_ABI PPC_ABI_EABI +#endif + +/* + * Use worst case stack alignment. For the EABI an 8-byte alignment would be + * sufficient. + */ + +#define PPC_STACK_ALIGN_POWER 4 +#define PPC_STACK_ALIGNMENT (1 << PPC_STACK_ALIGN_POWER) + +/* + * Assume PPC_HAS_FPU to be a synonym for _SOFT_FLOAT. + */ + +#if defined(_SOFT_FLOAT) \ + || defined(__NO_FPRS__) /* e500 has unified integer/FP registers */ \ + || defined(__PPC_CPU_E6500__) +#define PPC_HAS_FPU 0 +#else +#define PPC_HAS_FPU 1 +#endif + +#if defined(__PPC_CPU_E6500__) && defined(__ALTIVEC__) +#define PPC_MULTILIB_ALTIVEC +#endif + +#if defined(__PPC_CPU_E6500__) && !defined(_SOFT_FLOAT) +#define PPC_MULTILIB_FPU +#endif + +#ifdef PPC_MULTILIB_ALTIVEC +#define PPC_ALIGNMENT 16 +#else +#define PPC_ALIGNMENT 8 +#endif + +#ifdef __powerpc64__ +#define PPC_STACK_RED_ZONE_SIZE 512 +#else +#define PPC_STACK_RED_ZONE_SIZE 0 +#endif + +/* + * Unless specified above, If the model has FP support, it is assumed to + * support doubles (8-byte floating point numbers). + * + * If the model does NOT have FP support, then the model does + * NOT have double length FP registers. + */ + +#if (PPC_HAS_FPU) +#define PPC_HAS_DOUBLE 1 +#else +#define PPC_HAS_DOUBLE 0 +#endif + +/* + * Assemblers. + * PPC_ASM MUST be defined as one of these. + * + * PPC_ASM_ELF: ELF assembler. Currently used for all ABIs. + * + * NOTE: Only PPC_ABI_ELF is currently fully supported. + * + * Also NOTE: cpukit doesn't need this but asm.h which is defined + * in cpukit for consistency with other ports does. + */ + +#define PPC_ASM_ELF 0 + +/* + * Default to the assembler format used by the current GNU tools. + */ +#define PPC_ASM PPC_ASM_ELF + + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_SCORE_POWERPC_H */ diff --git a/cpukit/score/cpu/powerpc/include/rtems/score/types.h b/cpukit/score/cpu/powerpc/include/rtems/score/types.h new file mode 100644 index 0000000000..cdab30234d --- /dev/null +++ b/cpukit/score/cpu/powerpc/include/rtems/score/types.h @@ -0,0 +1,62 @@ +/** + * @file + * + * @brief PowerPC CPU Type Definitions + * + * This include file contains type definitions pertaining to the PowerPC + * processor family. + */ + +/* + * Author: Andrew Bray + * + * COPYRIGHT (c) 1995 by i-cubed ltd. + * + * To anyone who acknowledges that this file is provided "AS IS" + * without any express or implied warranty: + * permission to use, copy, modify, and distribute this file + * for any purpose is hereby granted without fee, provided that + * the above copyright notice and this notice appears in all + * copies, and that the name of i-cubed limited not be used in + * advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. + * i-cubed limited makes no representations about the suitability + * of this software for any purpose. + * + * Derived from c/src/exec/cpu/no_cpu/no_cputypes.h: + * + * COPYRIGHT (c) 1989-1997. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may in + * the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_TYPES_H +#define _RTEMS_SCORE_TYPES_H + +#include + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This section defines the basic types for this processor. + */ + +/** Type that can store a 32-bit integer or a pointer. */ +typedef uintptr_t CPU_Uint32ptr; + +typedef void ppc_isr; + +#ifdef __cplusplus +} +#endif + +#endif /* !ASM */ + +#endif diff --git a/cpukit/score/cpu/powerpc/preinstall.am b/cpukit/score/cpu/powerpc/preinstall.am deleted file mode 100644 index b0f59c24f9..0000000000 --- a/cpukit/score/cpu/powerpc/preinstall.am +++ /dev/null @@ -1,58 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -$(PROJECT_INCLUDE)/rtems/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems - @: > $(PROJECT_INCLUDE)/rtems/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/asm.h: rtems/asm.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/asm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/asm.h - -$(PROJECT_INCLUDE)/rtems/score/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/score - @: > $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/score/powerpc.h: rtems/score/powerpc.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/powerpc.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/powerpc.h - -$(PROJECT_INCLUDE)/rtems/score/cpu.h: rtems/score/cpu.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpu.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpu.h - -$(PROJECT_INCLUDE)/rtems/score/cpuimpl.h: rtems/score/cpuimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h - -$(PROJECT_INCLUDE)/rtems/score/types.h: rtems/score/types.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/types.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/types.h - -$(PROJECT_INCLUDE)/rtems/score/cpuatomic.h: rtems/score/cpuatomic.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h - -$(PROJECT_INCLUDE)/rtems/powerpc/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/powerpc - @: > $(PROJECT_INCLUDE)/rtems/powerpc/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/powerpc/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/powerpc/registers.h: rtems/powerpc/registers.h $(PROJECT_INCLUDE)/rtems/powerpc/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/powerpc/registers.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/powerpc/registers.h - diff --git a/cpukit/score/cpu/powerpc/rtems/asm.h b/cpukit/score/cpu/powerpc/rtems/asm.h deleted file mode 100644 index 2fddf56e6d..0000000000 --- a/cpukit/score/cpu/powerpc/rtems/asm.h +++ /dev/null @@ -1,310 +0,0 @@ -/** - * @file - * - * @brief Address the Problems Caused by Incompatible Flavor of - * Assemblers and Toolsets - * - * This include file attempts to address the problems - * caused by incompatible flavors of assemblers and - * toolsets. It primarily addresses variations in the - * use of leading underscores on symbols and the requirement - * that register names be preceded by a %. - * - * NOTE: The spacing in the use of these macros - * is critical to them working as advertised. - */ - -/* - * COPYRIGHT: - * - * This file is based on similar code found in newlib available - * from ftp.cygnus.com. The file which was used had no copyright - * notice. This file is freely distributable as long as the source - * of the file is noted. This file is: - * - * COPYRIGHT (c) 1995. - * i-cubed ltd. - * - * COPYRIGHT (c) 1994. - * On-Line Applications Research Corporation (OAR). - */ - -#ifndef _RTEMS_ASM_H -#define _RTEMS_ASM_H - -/* - * Indicate we are in an assembly file and get the basic CPU definitions. - */ - -#ifndef ASM -#define ASM -#endif -#include -#include - -/* - * Recent versions of GNU cpp define variables which indicate the - * need for underscores and percents. If not using GNU cpp or - * the version does not support this, then you will obviously - * have to define these as appropriate. - */ - -#ifndef __USER_LABEL_PREFIX__ -#define __USER_LABEL_PREFIX__ -#endif - -#ifndef __REGISTER_PREFIX__ -#define __REGISTER_PREFIX__ -#endif - -#ifndef __FLOAT_REGISTER_PREFIX__ -#define __FLOAT_REGISTER_PREFIX__ __REGISTER_PREFIX__ -#endif - -#ifndef __PROC_LABEL_PREFIX__ -#define __PROC_LABEL_PREFIX__ __USER_LABEL_PREFIX__ -#endif - -#include - -/* Use the right prefix for global labels. */ - -#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) - -/* Use the right prefix for procedure labels. */ - -#define PROC(x) CONCAT1 (__PROC_LABEL_PREFIX__, x) - -/* Use the right prefix for registers. */ - -#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) - -/* Use the right prefix for floating point registers. */ - -#define FREG(x) CONCAT1 (__FLOAT_REGISTER_PREFIX__, x) - -/* - * define macros for all of the registers on this CPU - * - * EXAMPLE: #define d0 REG (d0) - */ -#define r0 REG(0) -#define r1 REG(1) -#define r2 REG(2) -#define r3 REG(3) -#define r4 REG(4) -#define r5 REG(5) -#define r6 REG(6) -#define r7 REG(7) -#define r8 REG(8) -#define r9 REG(9) -#define r10 REG(10) -#define r11 REG(11) -#define r12 REG(12) -#define r13 REG(13) -#define r14 REG(14) -#define r15 REG(15) -#define r16 REG(16) -#define r17 REG(17) -#define r18 REG(18) -#define r19 REG(19) -#define r20 REG(20) -#define r21 REG(21) -#define r22 REG(22) -#define r23 REG(23) -#define r24 REG(24) -#define r25 REG(25) -#define r26 REG(26) -#define r27 REG(27) -#define r28 REG(28) -#define r29 REG(29) -#define r30 REG(30) -#define r31 REG(31) -#define f0 FREG(0) -#define f1 FREG(1) -#define f2 FREG(2) -#define f3 FREG(3) -#define f4 FREG(4) -#define f5 FREG(5) -#define f6 FREG(6) -#define f7 FREG(7) -#define f8 FREG(8) -#define f9 FREG(9) -#define f10 FREG(10) -#define f11 FREG(11) -#define f12 FREG(12) -#define f13 FREG(13) -#define f14 FREG(14) -#define f15 FREG(15) -#define f16 FREG(16) -#define f17 FREG(17) -#define f18 FREG(18) -#define f19 FREG(19) -#define f20 FREG(20) -#define f21 FREG(21) -#define f22 FREG(22) -#define f23 FREG(23) -#define f24 FREG(24) -#define f25 FREG(25) -#define f26 FREG(26) -#define f27 FREG(27) -#define f28 FREG(28) -#define f29 FREG(29) -#define f30 FREG(30) -#define f31 FREG(31) -#define v0 0 -#define v1 1 -#define v2 2 -#define v3 3 -#define v4 4 -#define v5 5 -#define v6 6 -#define v7 7 -#define v8 8 -#define v9 9 -#define v10 10 -#define v11 11 -#define v12 12 -#define v13 13 -#define v14 14 -#define v15 15 -#define v16 16 -#define v17 17 -#define v18 18 -#define v19 19 -#define v20 20 -#define v21 21 -#define v22 22 -#define v23 23 -#define v24 24 -#define v25 25 -#define v26 26 -#define v27 27 -#define v28 28 -#define v29 29 -#define v30 30 -#define v31 31 - -/* - * Some special purpose registers (SPRs). - */ -#define srr0 0x01a -#define srr1 0x01b -#define srr2 0x3de /* IBM 400 series only */ -#define srr3 0x3df /* IBM 400 series only */ -#define csrr0 58 /* Book E */ -#define csrr1 59 /* Book E */ -#define mcsrr0 570 /* e500 */ -#define mcsrr1 571 /* e500 */ -#define dsrr0 574 /* e200 */ -#define dsrr1 575 /* e200 */ - -#define sprg0 0x110 -#define sprg1 0x111 -#define sprg2 0x112 -#define sprg3 0x113 -#define sprg4 276 -#define sprg5 277 -#define sprg6 278 -#define sprg7 279 - -#define usprg0 256 - -#define dar 0x013 /* Data Address Register */ -#define dec 0x016 /* Decrementer Register */ - -#if defined(ppc403) || defined(ppc405) -/* the following SPR/DCR registers exist only in IBM 400 series */ -#define dear 0x3d5 -#define evpr 0x3d6 /* SPR: exception vector prefix register */ -#define iccr 0x3fb /* SPR: instruction cache control reg. */ -#define dccr 0x3fa /* SPR: data cache control reg. */ - -#if defined (ppc403) -#define exisr 0x040 /* DCR: external interrupt status register */ -#define exier 0x042 /* DCR: external interrupt enable register */ -#endif /* ppc403 */ -#if defined(ppc405) -#define exisr 0x0C0 /* DCR: external interrupt status register */ -#define exier 0x0C2 /* DCR: external interrupt enable register */ -#endif /* ppc405 */ - -#define br0 0x080 /* DCR: memory bank register 0 */ -#define br1 0x081 /* DCR: memory bank register 1 */ -#define br2 0x082 /* DCR: memory bank register 2 */ -#define br3 0x083 /* DCR: memory bank register 3 */ -#define br4 0x084 /* DCR: memory bank register 4 */ -#define br5 0x085 /* DCR: memory bank register 5 */ -#define br6 0x086 /* DCR: memory bank register 6 */ -#define br7 0x087 /* DCR: memory bank register 7 */ - -/* end of IBM400 series register definitions */ - -#elif defined(mpc555) -/* The following registers are for the MPC5xx */ -#define eie 0x050 /* External Interrupt Enable Register */ -#define eid 0x051 /* External Interrupt Disable Register */ -#define nri 0x052 /* Non-Recoverable Interrupt Register */ - -#elif defined(mpc860) || defined(mpc821) -/* The following registers are for the MPC8x0 */ -#define der 0x095 /* Debug Enable Register */ -#define ictrl 0x09E /* Instruction Support Control Register */ -#define immr 0x27E /* Internal Memory Map Register */ -/* end of MPC8x0 registers */ -#endif - -/* - * Following must be tailor for a particular flavor of the C compiler. - * They may need to put underscores in front of the symbols. - */ - -#define PUBLIC_VAR(sym) .globl SYM (sym) -#define EXTERN_VAR(sym) .extern SYM (sym) -#define PUBLIC_PROC(sym) .globl PROC (sym) -#define EXTERN_PROC(sym) .extern PROC (sym) - -/* Other potentially assembler specific operations */ -#if PPC_ASM == PPC_ASM_ELF -#define ALIGN(n,p) .align p -#define DESCRIPTOR(x) \ - .section .descriptors,"aw"; \ - PUBLIC_VAR (x); \ -SYM (x):; \ - .long PROC (x); \ - .long s.got; \ - .long 0 - -#define EXT_SYM_REF(x) .long x -#define EXT_PROC_REF(x) .long x - -/* - * Define macros to handle section beginning and ends. - */ - -#define BEGIN_CODE_DCL .text -#define END_CODE_DCL -#define BEGIN_DATA_DCL .data -#define END_DATA_DCL -#define BEGIN_CODE .text -#define END_CODE -#define BEGIN_DATA .data -#define END_DATA -#define BEGIN_BSS .bss -#define END_BSS -#define END - -#else -#error "PPC_ASM_TYPE is not properly defined" -#endif -#ifndef PPC_ASM -#error "PPC_ASM_TYPE is not properly defined" -#endif - -#if defined(__powerpc64__) -#define PPC64_NOP_FOR_LINKER_TOC_POINTER_RESTORE nop -#else -#define PPC64_NOP_FOR_LINKER_TOC_POINTER_RESTORE -#endif - -#endif diff --git a/cpukit/score/cpu/powerpc/rtems/powerpc/registers.h b/cpukit/score/cpu/powerpc/rtems/powerpc/registers.h deleted file mode 100644 index 4d9350324e..0000000000 --- a/cpukit/score/cpu/powerpc/rtems/powerpc/registers.h +++ /dev/null @@ -1,774 +0,0 @@ -/** - * @file - * - * @brief PowerPc MSR and Registers Access Definitions - * - * This file contains some powerpc MSR and registers access definitions. - */ - -/* - * COPYRIGHT (C) 1999 Eric Valette (valette@crf.canon.fr) - * Canon Centre Recherche France. - * - * Added MPC8260 Andy Dachs - * Surrey Satellite Technology Limited - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_POWERPC_REGISTERS_H -#define _RTEMS_POWERPC_REGISTERS_H - -/* Bit encodings for Machine State Register (MSR) */ -#define MSR_CM (1<<31) /* Computation mode */ -#define MSR_GS (1<<28) /* Guest state */ -#define MSR_UCLE (1<<26) /* User-mode cache lock enable (e500) */ -#define MSR_VE (1<<25) /* Alti-Vec enable (7400+) */ -#define MSR_SPE (1<<25) /* SPE enable (e500) */ -#define MSR_AP (1<<25) /* Auxiliary processor available */ -#define MSR_APE (1<<19) /* APU exception enable */ -#define MSR_POW (1<<18) /* Enable Power Management */ -#define MSR_WE (1<<18) /* Wait state enable (e500, 4xx) */ -#define MSR_TGPR (1<<17) /* TLB Update registers in use */ -#define MSR_CE (1<<17) /* BookE critical interrupt */ -#define MSR_ILE (1<<16) /* Interrupt Little-Endian enable */ -#define MSR_EE (1<<15) /* External Interrupt enable */ -#define MSR_PR (1<<14) /* Supervisor/User privilege */ -#define MSR_FP (1<<13) /* Floating Point enable */ -#define MSR_ME (1<<12) /* Machine Check enable */ -#define MSR_FE0 (1<<11) /* Floating Exception mode 0 */ -#define MSR_SE (1<<10) /* Single Step */ -#define MSR_UBLE (1<<10) /* User-mode BTB lock enable (e500) */ -#define MSR_DWE (1<<10) /* Debug wait enable (4xx) */ -#define MSR_BE (1<<9) /* Branch Trace */ -#define MSR_DE (1<<9) /* BookE debug exception */ -#define MSR_FE1 (1<<8) /* Floating Exception mode 1 */ -#define MSR_E300_CE (1<<7) /* e300 critical interrupt */ -#define MSR_IP (1<<6) /* Exception prefix 0x000/0xFFF */ -#define MSR_IR (1<<5) /* Instruction MMU enable */ -#define MSR_DR (1<<4) /* Data MMU enable */ -#define MSR_IS (1<<5) /* Instruction address space */ -#define MSR_DS (1<<4) /* Data address space */ -#define MSR_PMM (1<<2) /* Performance monitor mark */ -#define MSR_RI (1<<1) /* Recoverable Exception */ -#define MSR_LE (1<<0) /* Little-Endian enable */ - -/* Bit encodings for Hardware Implementation Register (HID0) - on PowerPC 603, 604, etc. processors (not 601). */ - -/* WARNING: HID0/HID1 are *truely* implementation dependent! - * you *cannot* rely on the same bits to be present, - * at the same place or even in the same register - * on different CPU familys. - * E.g., EMCP isHID0_DOZE is HID0_HI_BAT_EN on the - * on the 7450s. IFFT is XBSEN on 7450 and so on... - */ -#define HID0_EMCP (1<<31) /* Enable Machine Check pin */ -#define HID0_EBA (1<<29) /* Enable Bus Address Parity */ -#define HID0_EBD (1<<28) /* Enable Bus Data Parity */ -#define HID0_SBCLK (1<<27) -#define HID0_TBEN (1<<26) /* 7455:this bit must be set - * and TBEN signal must be asserted - * to enable the time base and - * decrementer. - */ -#define HID0_EICE (1<<26) -#define HID0_ECLK (1<<25) -#define HID0_PAR (1<<24) -#define HID0_DOZE (1<<23) -/* this HI_BAT_EN only on 7445, 7447, 7448, 7455 & 7457 !! */ -#define HID0_7455_HIGH_BAT_EN (1<<23) - -#define HID0_NAP (1<<22) -#define HID0_SLEEP (1<<21) -#define HID0_DPM (1<<20) -#define HID0_ICE (1<<15) /* Instruction Cache Enable */ -#define HID0_DCE (1<<14) /* Data Cache Enable */ -#define HID0_ILOCK (1<<13) /* Instruction Cache Lock */ -#define HID0_DLOCK (1<<12) /* Data Cache Lock */ -#define HID0_ICFI (1<<11) /* Instruction Cache Flash Invalidate */ -#define HID0_DCI (1<<10) /* Data Cache Invalidate */ -/* this bit is XSBSEN (xtended block size enable) on 7447, 7448, 7455 and 7457 only */ -#define HID0_7455_XBSEN (1<<8) -#define HID0_SIED (1<<7) /* Serial Instruction Execution [Disable] */ -#define HID0_BTIC (1<<5) /* Branch Target Instruction Cache [Enable] */ -/* S.K. Feng 10/03, added for MPC7455 */ -#define HID0_LRSTK (1<<4) /* Link register stack enable (7455) */ -#define HID0_FOLD (1<<3) /* Branch folding enable (7455) */ - -#define HID0_BHTE (1<<2) /* Branch History Table Enable */ -#define HID0_BTCD (1<<1) /* Branch target cache disable */ - -/* fpscr settings */ -#define FPSCR_FX (1<<31) -#define FPSCR_FEX (1<<30) - -#define _MACH_prep 1 -#define _MACH_Pmac 2 /* pmac or pmac clone (non-chrp) */ -#define _MACH_chrp 4 /* chrp machine */ -#define _MACH_mbx 8 /* Motorola MBX board */ -#define _MACH_apus 16 /* amiga with phase5 powerup */ -#define _MACH_fads 32 /* Motorola FADS board */ - -/* see residual.h for these */ -#define _PREP_Motorola 0x01 /* motorola prep */ -#define _PREP_Firm 0x02 /* firmworks prep */ -#define _PREP_IBM 0x00 /* ibm prep */ -#define _PREP_Bull 0x03 /* bull prep */ - -/* these are arbitrary */ -#define _CHRP_Motorola 0x04 /* motorola chrp, the cobra */ -#define _CHRP_IBM 0x05 /* IBM chrp, the longtrail and longtrail 2 */ - -#define _GLOBAL(n)\ - .globl n;\ -n: - -#define TBRU 269 /* Time base Upper/Lower (Reading) */ -#define TBRL 268 -#define TBWU 285 /* Time base Upper/Lower (Writing) */ -#define TBWL 284 -#define PPC_XER 1 -#define PPC_LR 8 -#define PPC_CTR 9 -#define HID0 1008 /* Hardware Implementation 0 */ -#define HID1 1009 /* Hardware Implementation 1 */ -#define HID2 1011 /* Hardware Implementation 2 */ -#define DABR 1013 /* Data Access Breakpoint */ -#define PPC_PVR 287 /* Processor Version */ -#define IBAT0U 528 /* Instruction BAT #0 Upper/Lower */ -#define IBAT0L 529 -#define IBAT1U 530 /* Instruction BAT #1 Upper/Lower */ -#define IBAT1L 531 -#define IBAT2U 532 /* Instruction BAT #2 Upper/Lower */ -#define IBAT2L 533 -#define IBAT3U 534 /* Instruction BAT #3 Upper/Lower */ -#define IBAT3L 535 - -/* Only present on 7445, 7447, 7448, 7455 and 7457 (if HID0[HIGH_BAT_EN]) */ -#define IBAT4U 560 /* Instruction BAT #4 Upper/Lower */ -#define IBAT4L 561 -#define IBAT5U 562 /* Instruction BAT #5 Upper/Lower */ -#define IBAT5L 563 -#define IBAT6U 564 /* Instruction BAT #6 Upper/Lower */ -#define IBAT6L 565 -#define IBAT7U 566 /* Instruction BAT #7 Upper/Lower */ -#define IBAT7L 567 - -#define DBAT0U 536 /* Data BAT #0 Upper/Lower */ -#define DBAT0L 537 -#define DBAT1U 538 /* Data BAT #1 Upper/Lower */ -#define DBAT1L 539 -#define DBAT2U 540 /* Data BAT #2 Upper/Lower */ -#define DBAT2L 541 -#define DBAT3U 542 /* Data BAT #3 Upper/Lower */ -#define DBAT3L 543 - -/* Only present on 7445, 7447, 7448, 7455 and 7457 (if HID0[HIGH_BAT_EN]) */ -#define DBAT4U 568 /* Instruction BAT #4 Upper/Lower */ -#define DBAT4L 569 -#define DBAT5U 570 /* Instruction BAT #5 Upper/Lower */ -#define DBAT5L 571 -#define DBAT6U 572 /* Instruction BAT #6 Upper/Lower */ -#define DBAT6L 573 -#define DBAT7U 574 /* Instruction BAT #7 Upper/Lower */ -#define DBAT7L 575 - -#define DMISS 976 /* TLB Lookup/Refresh registers */ -#define DCMP 977 -#define HASH1 978 -#define HASH2 979 -#define IMISS 980 -#define ICMP 981 -#define PPC_RPA 982 -#define SDR1 25 /* MMU hash base register */ -#define PPC_DAR 19 /* Data Address Register */ -#define DEAR_BOOKE 61 -#define DEAR_405 981 -#define SPR0 272 /* Supervisor Private Registers */ -#define SPRG0 272 -#define SPR1 273 -#define SPRG1 273 -#define SPR2 274 -#define SPRG2 274 -#define SPR3 275 -#define SPRG3 275 -#define SPRG4 276 -#define SPRG5 277 -#define SPRG6 278 -#define SPRG7 279 -#define USPRG0 256 -#define DSISR 18 -#define SRR0 26 /* Saved Registers (exception) */ -#define SRR1 27 -#define IABR 1010 /* Instruction Address Breakpoint */ -#define PPC_DEC 22 /* Decrementer */ -#define PPC_EAR 282 /* External Address Register */ - -#define MSSCR0 1014 /* Memory Subsystem Control Register */ - -#define L2CR 1017 /* PPC 750 and 74xx L2 control register */ - -#define L2CR_L2E (1<<31) /* enable */ -#define L2CR_L2I (1<<21) /* global invalidate */ - -/* watch out L2IO and L2DO are different between 745x and 7400/7410 */ -/* Oddly, the following L2CR bit defintions in 745x - * is different from that of 7400 and 7410. - * Though not used in 7400 and 7410, it is appeded with _745x just - * to be clarified. - */ -#define L2CR_L2IO_745x 0x100000 /* (1<<20) L2 Instruction-Only */ -#define L2CR_L2DO_745x 0x10000 /* (1<<16) L2 Data-Only */ -#define L2CR_LOCK_745x (L2CR_L2IO_745x|L2CR_L2DO_745x) -#define L2CR_L3OH0 0x00080000 /* 12:L3 output hold 0 */ - -#define L3CR 1018 /* PPC 7450/7455 L3 control register */ -#define L3CR_L3IO_745x 0x400000 /* (1<<22) L3 Instruction-Only */ -#define L3CR_L3DO_745x 0x40 /* (1<<6) L3 Data-Only */ - -#define L3CR_LOCK_745x (L3CR_L3IO_745x|L3CR_L3DO_745x) - -#define L3CR_RESERVED 0x0438003a /* Reserved bits in L3CR */ -#define L3CR_L3E 0x80000000 /* 0: L3 enable */ -#define L3CR_L3PE 0x40000000 /* 1: L3 data parity checking enable */ -#define L3CR_L3APE 0x20000000 /* 2: L3 address parity checking enable */ -#define L3CR_L3SIZ 0x10000000 /* 3: L3 size (0=1MB, 1=2MB) */ -#define L3SIZ_1M 0x00000000 -#define L3SIZ_2M 0x10000000 -#define L3CR_L3CLKEN 0x08000000 /* 4: Enables the L3_CLK[0:1] signals */ -#define L3CR_L3CLK 0x03800000 /* 6-8: L3 clock ratio */ -#define L3CLK_60 0x00000000 /* core clock / 6 */ -#define L3CLK_20 0x01000000 /* / 2 */ -#define L3CLK_25 0x01800000 /* / 2.5 */ -#define L3CLK_30 0x02000000 /* / 3 */ -#define L3CLK_35 0x02800000 /* / 3.5 */ -#define L3CLK_40 0x03000000 /* / 4 */ -#define L3CLK_50 0x03800000 /* / 5 */ -#define L3CR_L3IO 0x00400000 /* 9: L3 instruction-only mode */ -#define L3CR_L3SPO 0x00040000 /* 13: L3 sample point override */ -#define L3CR_L3CKSP 0x00030000 /* 14-15: L3 clock sample point */ -#define L3CKSP_2 0x00000000 /* 2 clocks */ -#define L3CKSP_3 0x00010000 /* 3 clocks */ -#define L3CKSP_4 0x00020000 /* 4 clocks */ -#define L3CKSP_5 0x00030000 /* 5 clocks */ -#define L3CR_L3PSP 0x0000e000 /* 16-18: L3 P-clock sample point */ -#define L3PSP_0 0x00000000 /* 0 clocks */ -#define L3PSP_1 0x00002000 /* 1 clocks */ -#define L3PSP_2 0x00004000 /* 2 clocks */ -#define L3PSP_3 0x00006000 /* 3 clocks */ -#define L3PSP_4 0x00008000 /* 4 clocks */ -#define L3PSP_5 0x0000a000 /* 5 clocks */ -#define L3CR_L3REP 0x00001000 /* 19: L3 replacement algorithm (0=default, 1=alternate) */ -#define L3CR_L3HWF 0x00000800 /* 20: L3 hardware flush */ -#define L3CR_L3I 0x00000400 /* 21: L3 global invaregisters.h.orig -lidate */ -#define L3CR_L3RT 0x00000300 /* 22-23: L3 SRAM type */ -#define L3RT_MSUG2_DDR 0x00000000 /* MSUG2 DDR SRAM */ -#define L3RT_PIPELINE_LATE 0x00000100 /* Pipelined (register-register) synchronous late-write SRAM */ -#define L3RT_PB2_SRAM 0x00000300 /* PB2 SRAM */ -#define L3CR_L3NIRCA 0x00000080 /* 24: L3 non-integer ratios clock adjustment for the SRAM */ -#define L3CR_L3DO 0x00000040 /* 25: L3 data-only mode */ -#define L3CR_PMEN 0x00000004 /* 29: Private memory enable */ -#define L3CR_PMSIZ 0x00000004 /* 31: Private memory size (0=1MB, 1=2MB) */ - -#define THRM1 1020 -#define THRM2 1021 -#define THRM3 1022 -#define THRM1_TIN (1<<(31-0)) -#define THRM1_TIV (1<<(31-1)) -#define THRM1_THRES (0x7f<<(31-8)) -#define THRM1_TID (1<<(31-29)) -#define THRM1_TIE (1<<(31-30)) -#define THRM1_V (1<<(31-31)) -#define THRM3_SITV (0x1fff << (31-30)) -#define THRM3_E (1<<(31-31)) - -/* Segment Registers */ -#define PPC_SR0 0 -#define PPC_SR1 1 -#define PPC_SR2 2 -#define PPC_SR3 3 -#define PPC_SR4 4 -#define PPC_SR5 5 -#define PPC_SR6 6 -#define PPC_SR7 7 -#define PPC_SR8 8 -#define PPC_SR9 9 -#define PPC_SR10 10 -#define PPC_SR11 11 -#define PPC_SR12 12 -#define PPC_SR13 13 -#define PPC_SR14 14 -#define PPC_SR15 15 - -#define BOOKE_DECAR 54 - -#define PPC405_MCSR 0x23C -#define PPC405_ESR 0x3D4 -#define PPC405_DEAR 0x3D5 -#define BOOKE_DEAR 61 - -#define PPC405_TSR 0x3D8 -#define BOOKE_TSR 336 -#define BOOKE_TSR_ENW (1<<31) -#define BOOKE_TSR_WIS (1<<30) -#define BOOKE_TSR_DIS (1<<27) -#define BOOKE_TSR_FIS (1<<26) - -#define PPC405_TCR 0x3DA -#define BOOKE_TCR 340 -#define BOOKE_TCR_WP(x) (((x)&3)<<30) -#define BOOKE_TCR_WP_MASK (3<<30) -#define BOOKE_TCR_WRC(x) (((x)&3)<<28) -#define BOOKE_TCR_WRC_MASK (3<<28) -#define BOOKE_TCR_WIE (1<<27) -#define BOOKE_TCR_DIE (1<<26) -#define BOOKE_TCR_FP(x) (((x)&3)<<24) -#define BOOKE_TCR_FIE (1<<23) -#define BOOKE_TCR_ARE (1<<22) -#define BOOKE_TCR_WPEXT(x) (((x)&0xf)<<17) -#define BOOKE_TCR_WPEXT_MASK (0xf<<17) -#define BOOKE_TCR_FPEXT(x) (((x)&0xf)<<13) -#define BOOKE_TCR_FPEXT_MASK (0xf<<13) - -#define BOOKE_PID 48 /* Process ID */ -#define BOOKE_CSRR0 58 /* Critical Save/Restore Register 0 */ -#define BOOKE_CSRR1 59 /* Critical Save/Restore Register 1 */ -#define BOOKE_ESR 62 /* Exception Syndrome Register */ -#define BOOKE_IVPR 63 /* Interrupt Vector Prefix Register */ -#define BOOKE_SPRG4_W 260 /* Special Purpose Register General 4 (WO) */ -#define BOOKE_SPRG5_W 261 /* Special Purpose Register General 5 (WO) */ -#define BOOKE_SPRG6_W 262 /* Special Purpose Register General 6 (WO) */ -#define BOOKE_SPRG7_W 263 /* Special Purpose Register General 7 (WO) */ -#define BOOKE_PIR 286 /* Processor ID Register */ -#define BOOKE_DBSR 304 /* Debug Status Register */ - -#define BOOKE_EPCR 307 /* Embedded Processor Control Register */ -#define BOOKE_EPCR_EXTGS (1 << 31) -#define BOOKE_EPCR_DTLBGS (1 << 30) -#define BOOKE_EPCR_ITLBGS (1 << 29) -#define BOOKE_EPCR_DSIGS (1 << 28) -#define BOOKE_EPCR_ISIGS (1 << 27) -#define BOOKE_EPCR_DUVD (1 << 26) -#define BOOKE_EPCR_ICM (1 << 25) -#define BOOKE_EPCR_GICM (1 << 24) -#define BOOKE_EPCR_DGTMI (1 << 23) -#define BOOKE_EPCR_DMIUH (1 << 22) -#define BOOKE_EPCR_PMGS (1 << 21) - -#define BOOKE_DBCR0 308 /* Debug Control Register 0 */ -#define BOOKE_DBCR1 309 /* Debug Control Register 1 */ -#define BOOKE_DBCR2 310 /* Debug Control Register 2 */ -#define BOOKE_IAC1 312 /* Instruction Address Compare 1 */ -#define BOOKE_IAC2 313 /* Instruction Address Compare 2 */ -#define BOOKE_IAC3 314 /* Instruction Address Compare 3 */ -#define BOOKE_IAC4 315 /* Instruction Address Compare 4 */ -#define BOOKE_DAC1 316 /* Data Address Compare 1 */ -#define BOOKE_DAC2 317 /* Data Address Compare 2 */ -#define BOOKE_DVC1 318 /* Data Value Compare 1 */ -#define BOOKE_DVC2 319 /* Data Value Compare 2 */ -#define BOOKE_GSRR0 378 /* Guest Save/Restore Register 0 */ -#define BOOKE_GSRR1 379 /* Guest Save/Restore Register 1 */ -#define BOOKE_GEPR 380 /* Guest External Proxy Register */ -#define BOOKE_GDEAR 381 /* Guest Data Exception Address Register */ -#define BOOKE_GPIR 382 /* Guest Processor ID Register */ -#define BOOKE_GESR 383 /* Guest Exception Syndrome Register */ -#define BOOKE_IVOR0 400 /* Interrupt Vector Offset Register 0 */ -#define BOOKE_IVOR1 401 /* Interrupt Vector Offset Register 1 */ -#define BOOKE_IVOR2 402 /* Interrupt Vector Offset Register 2 */ -#define BOOKE_IVOR3 403 /* Interrupt Vector Offset Register 3 */ -#define BOOKE_IVOR4 404 /* Interrupt Vector Offset Register 4 */ -#define BOOKE_IVOR5 405 /* Interrupt Vector Offset Register 5 */ -#define BOOKE_IVOR6 406 /* Interrupt Vector Offset Register 6 */ -#define BOOKE_IVOR7 407 /* Interrupt Vector Offset Register 7 */ -#define BOOKE_IVOR8 408 /* Interrupt Vector Offset Register 8 */ -#define BOOKE_IVOR9 409 /* Interrupt Vector Offset Register 9 */ -#define BOOKE_IVOR10 410 /* Interrupt Vector Offset Register 10 */ -#define BOOKE_IVOR11 411 /* Interrupt Vector Offset Register 11 */ -#define BOOKE_IVOR12 412 /* Interrupt Vector Offset Register 12 */ -#define BOOKE_IVOR13 413 /* Interrupt Vector Offset Register 13 */ -#define BOOKE_IVOR14 414 /* Interrupt Vector Offset Register 14 */ -#define BOOKE_IVOR15 415 /* Interrupt Vector Offset Register 15 */ -#define BOOKE_IVOR42 436 /* Interrupt Vector Offset Register 42 */ -#define BOOKE_IVOR32 528 /* Interrupt Vector Offset Register 32 */ -#define BOOKE_IVOR33 529 /* Interrupt Vector Offset Register 33 */ -#define BOOKE_IVOR34 530 /* Interrupt Vector Offset Register 34 */ -#define BOOKE_IVOR35 531 /* Interrupt Vector Offset Register 35 */ -#define BOOKE_IVOR36 532 /* Interrupt Vector Offset Register 36 */ -#define BOOKE_IVOR37 533 /* Interrupt Vector Offset Register 37 */ -#define BOOKE_IVOR38 432 /* Interrupt Vector Offset Register 38 */ -#define BOOKE_IVOR39 433 /* Interrupt Vector Offset Register 39 */ -#define BOOKE_IVOR40 434 /* Interrupt Vector Offset Register 40 */ -#define BOOKE_IVOR41 435 /* Interrupt Vector Offset Register 41 */ -#define BOOKE_GIVOR2 440 /* Guest Interrupt Vector Offset Register 2 */ -#define BOOKE_GIVOR3 441 /* Guest Interrupt Vector Offset Register 3 */ -#define BOOKE_GIVOR4 442 /* Guest Interrupt Vector Offset Register 4 */ -#define BOOKE_GIVOR8 443 /* Guest Interrupt Vector Offset Register 8 */ -#define BOOKE_GIVOR13 444 /* Guest Interrupt Vector Offset Register 13 */ -#define BOOKE_GIVOR14 445 /* Guest Interrupt Vector Offset Register 14 */ -#define BOOKE_GIVPR 446 /* Guest Interrupt Vector Prefix Register */ -#define BOOKE_MCSRR0 570 /* Machine Check Save/Restore Register 0 */ -#define BOOKE_MCSRR1 571 /* Machine Check Save/Restore Register 1 */ -#define BOOKE_MCSR 572 /* Machine Check Status Register */ -#define BOOKE_DSRR0 574 /* Debug Save/Restore Register 0 */ -#define BOOKE_DSRR1 575 /* Debug Save/Restore Register 1 */ - -#define PPC440_INV0 880 /* Instruction Cache Normal Victim 0 */ -#define PPC440_INV1 881 /* Instruction Cache Normal Victim 1 */ -#define PPC440_INV2 882 /* Instruction Cache Normal Victim 2 */ -#define PPC440_INV3 883 /* Instruction Cache Normal Victim 3 */ -#define PPC440_ITV0 884 /* Instruction Cache Transient Victim 0 */ -#define PPC440_ITV1 885 /* Instruction Cache Transient Victim 1 */ -#define PPC440_ITV2 886 /* Instruction Cache Transient Victim 2 */ -#define PPC440_ITV3 887 /* Instruction Cache Transient Victim 3 */ -#define PPC440_CCR1 888 /* Core Configuration Register 1 */ -#define PPC440_DNV0 912 /* Data Cache Normal Victim 0 */ -#define PPC440_DNV1 913 /* Data Cache Normal Victim 1 */ -#define PPC440_DNV2 914 /* Data Cache Normal Victim 2 */ -#define PPC440_DNV3 915 /* Data Cache Normal Victim 3 */ -#define PPC440_DTV0 916 /* Data Cache Transient Victim 0 */ -#define PPC440_DTV1 917 /* Data Cache Transient Victim 1 */ -#define PPC440_DTV2 918 /* Data Cache Transient Victim 2 */ -#define PPC440_DTV3 919 /* Data Cache Transient Victim 3 */ -#define PPC440_DVLIM 920 /* Data Cache Victim Limit */ -#define PPC440_IVLIM 921 /* Instruction Cache Victim Limit */ -#define PPC440_RSTCFG 923 /* Reset Configuration */ -#define PPC440_DCDBTRL 924 /* Data Cache Debug Tag Register Low */ -#define PPC440_DCDBTRH 925 /* Data Cache Debug Tag Register High */ -#define PPC440_ICDBTRL 926 /* Instruction Cache Debug Tag Register Low */ -#define PPC440_ICDBTRH 927 /* Instruction Cache Debug Tag Register High */ -#define PPC440_MMUCR 946 /* Memory Management Unit Control Register */ -#define PPC440_CCR0 947 /* Core Configuration Register 0 */ -#define PPC440_ICDBDR 979 /* Instruction Cache Debug Data Register */ -#define PPC440_DBDR 1011 /* Debug Data Register */ - -#define PPC440_TLB0_EPN(n) ( (((1<<22)-1)&(n)) << (31-21)) /* Etended Page Number */ -#define PPC440_TLB0_EPN_GET(n) ( ((n) >> (31-21)) & ((1<<22)-1)) -#define PPC440_TLB0_V ( 1 << (31-22)) /* Entry valid */ -#define PPC440_TLB0_TS ( 1 << (31-23)) /* Translation space */ -#define PPC440_TLB0_TSIZE(n) ( (0xf & (n)) << (31-27)) /* Page size */ -#define PPC440_TLB0_TSIZE_GET(n) ( ((n) >> (31-27)) & 0xf) -#define PPC440_TLB0_TPAR(n) ( (0xf & (n)) << (31-31)) /* Tag Parity */ -#define PPC440_TLB0_TPAR_GET(n) ( ((n) >> (31-31)) & 0xf) - -#define PPC440_PID_TID(n) ( (0xff & (n)) << (31-31)) /* Translation ID */ -#define PPC440_PID_TID_GET(n) ( ((n) >> (31-31)) & 0xff) - -#define PPC440_TLB1_RPN(n) ( (((1<<22)-1)&(n)) << (31-21)) /* Real Page Number */ -#define PPC440_TLB1_RPN_GET(n) ( ((n) >> (31-21)) & ((1<<22)-1)) -#define PPC440_TLB1_PAR1(n) ( (0x3 & (n)) << (31-23)) /* Parity for TLB word 1 */ -#define PPC440_TLB1_PAR1_GET(n) ( ((n) >> (31-23)) & 0x3) -#define PPC440_TLB1_ERPN(n) ( (0xf & (n)) << (31-31)) /* Extended Real Page No. */ -#define PPC440_TLB1_ERPN_GET(n) ( ((n) >> (31-31)) & 0xf) - -#define PPC440_TLB2_PAR2(n) ( (0x3 & (n)) << (31- 1)) /* Parity for TLB word 2 */ -#define PPC440_TLB2_PAR2_GET(n) ( ((n) >> (31- 1)) & 0x3) -#define PPC440_TLB2_U0 ( 1 << (31-16)) /* User attr. 0 */ -#define PPC440_TLB2_U1 ( 1 << (31-17)) /* User attr. 1 */ -#define PPC440_TLB2_U2 ( 1 << (31-18)) /* User attr. 2 */ -#define PPC440_TLB2_U3 ( 1 << (31-19)) /* User attr. 3 */ -#define PPC440_TLB2_W ( 1 << (31-20)) /* Write-through */ -#define PPC440_TLB2_I ( 1 << (31-21)) /* Cache-inhibited */ -#define PPC440_TLB2_M ( 1 << (31-22)) /* Memory-coherence req. */ -#define PPC440_TLB2_G ( 1 << (31-23)) /* Guarded */ -#define PPC440_TLB2_E ( 1 << (31-24)) /* Little-endian */ -#define PPC440_TLB2_UX ( 1 << (31-26)) /* User exec. */ -#define PPC440_TLB2_UW ( 1 << (31-27)) /* User write */ -#define PPC440_TLB2_UR ( 1 << (31-28)) /* User read */ -#define PPC440_TLB2_SX ( 1 << (31-29)) /* Super exec. */ -#define PPC440_TLB2_SW ( 1 << (31-30)) /* Super write */ -#define PPC440_TLB2_SR ( 1 << (31-31)) /* Super read */ - -#define PPC440_TLB2_ATTR(x) ( ((x) & 0x1ff) << 7 ) -#define PPC440_TLB2_ATTR_GET(x) ( ((x) >> 7) & 0x1ff ) - -#define PPC440_TLB2_PERM(n) ( (n) & 0x3f ) -#define PPC440_TLB2_PERM_GET(n) ( (n) & 0x3f ) - -/* Freescale Book E Implementation Standards (EIS): Branch Operations */ - -#define FSL_EIS_BUCSR 1013 -#define FSL_EIS_BUCSR_STAC_EN (1 << (63 - 39)) -#define FSL_EIS_BUCSR_LS_EN (1 << (63 - 41)) -#define FSL_EIS_BUCSR_BBFI (1 << (63 - 54)) -#define FSL_EIS_BUCSR_BALLOC_ALL (0x0 << (63 - 59)) -#define FSL_EIS_BUCSR_BALLOC_FORWARD (0x1 << (63 - 59)) -#define FSL_EIS_BUCSR_BALLOC_BACKWARD (0x2 << (63 - 59)) -#define FSL_EIS_BUCSR_BALLOC_NONE (0x3 << (63 - 59)) -#define FSL_EIS_BUCSR_BPRED_TAKEN (0x0 << (63 - 61)) -#define FSL_EIS_BUCSR_BPRED_TAKEN_ONLY_FORWARD (0x1 << (63 - 62)) -#define FSL_EIS_BUCSR_BPRED_TAKEN_ONLY_BACKWARD (0x2 << (63 - 62)) -#define FSL_EIS_BUCSR_BPRED_NOT_TAKEN (0x3 << (63 - 62)) -#define FSL_EIS_BUCSR_BPEN (1 << (63 - 63)) - -/* Freescale Book E Implementation Standards (EIS): Hardware Implementation-Dependent Registers */ - -#define FSL_EIS_SVR 1023 - -/* Freescale Book E Implementation Standards (EIS): Thread Management and Control Registers */ - -#define FSL_EIS_TENSR 437 -#define FSL_EIS_TENS 438 -#define FSL_EIS_TENC 439 -#define FSL_EIS_PPR32 898 - -/* Freescale Book E Implementation Standards (EIS): MMU Control and Status */ - -#define FSL_EIS_MAS0 624 -#define FSL_EIS_MAS0_TLBSEL (1 << (63 - 35)) -#define FSL_EIS_MAS0_ESEL(n) ((0xf & (n)) << (63 - 47)) -#define FSL_EIS_MAS0_ESEL_GET(m) (((m) >> (63 - 47)) & 0xf) -#define FSL_EIS_MAS0_NV (1 << (63 - 63)) - -#define FSL_EIS_MAS1 625 -#define FSL_EIS_MAS1_V (1 << (63 - 32)) -#define FSL_EIS_MAS1_IPROT (1 << (63 - 33)) -#define FSL_EIS_MAS1_TID(n) ((0xff & (n)) << (63 - 47)) -#define FSL_EIS_MAS1_TID_GET(n) (((n) >> (63 - 47)) & 0xfff) -#define FSL_EIS_MAS1_TS (1 << (63 - 51)) -#define FSL_EIS_MAS1_TSIZE(n) ((0xf & (n)) << (63 - 55)) -#define FSL_EIS_MAS1_TSIZE_GET(n) (((n)>>(63 - 55)) & 0xf) - -#define FSL_EIS_MAS2 626 -#define FSL_EIS_MAS2_EPN(n) ((((1 << 21) - 1)&(n)) << (63-51)) -#define FSL_EIS_MAS2_EPN_GET(n) (((n) >> (63 - 51)) & 0xfffff) -#define FSL_EIS_MAS2_EA(n) FSL_EIS_MAS2_EPN((n) >> 12) -#define FSL_EIS_MAS2_EA_GET(n) (FSL_EIS_MAS2_EPN_GET(n) << 12) -#define FSL_EIS_MAS2_X0 (1 << (63 - 57)) -#define FSL_EIS_MAS2_X1 (1 << (63 - 58)) -#define FSL_EIS_MAS2_W (1 << (63 - 59)) -#define FSL_EIS_MAS2_I (1 << (63 - 60)) -#define FSL_EIS_MAS2_M (1 << (63 - 61)) -#define FSL_EIS_MAS2_G (1 << (63 - 62)) -#define FSL_EIS_MAS2_E (1 << (63 - 63)) -#define FSL_EIS_MAS2_ATTR(x) ((x) & 0x7f) -#define FSL_EIS_MAS2_ATTR_GET(x) ((x) & 0x7f) - -#define FSL_EIS_MAS3 627 -#define FSL_EIS_MAS3_RPN(n) ((((1 << 21) - 1) & (n)) << (63-51)) -#define FSL_EIS_MAS3_RPN_GET(n) (((n)>>(63 - 51)) & 0xfffff) -#define FSL_EIS_MAS3_RA(n) FSL_EIS_MAS3_RPN((n) >> 12) -#define FSL_EIS_MAS3_RA_GET(n) (FSL_EIS_MAS3_RPN_GET(n) << 12) -#define FSL_EIS_MAS3_U0 (1 << (63 - 54)) -#define FSL_EIS_MAS3_U1 (1 << (63 - 55)) -#define FSL_EIS_MAS3_U2 (1 << (63 - 56)) -#define FSL_EIS_MAS3_U3 (1 << (63 - 57)) -#define FSL_EIS_MAS3_UX (1 << (63 - 58)) -#define FSL_EIS_MAS3_SX (1 << (63 - 59)) -#define FSL_EIS_MAS3_UW (1 << (63 - 60)) -#define FSL_EIS_MAS3_SW (1 << (63 - 61)) -#define FSL_EIS_MAS3_UR (1 << (63 - 62)) -#define FSL_EIS_MAS3_SR (1 << (63 - 63)) -#define FSL_EIS_MAS3_PERM(n) ((n) & 0x3ff) -#define FSL_EIS_MAS3_PERM_GET(n) ((n) & 0x3ff) - -#define FSL_EIS_MAS4 628 -#define FSL_EIS_MAS4_TLBSELD (1 << (63 - 35)) -#define FSL_EIS_MAS4_TIDSELD(n) ((0x3 & (n)) << (63 - 47)) -#define FSL_EIS_MAS4_TSIZED(n) ((0xf & (n)) << (63 - 55)) -#define FSL_EIS_MAS4_X0D FSL_EIS_MAS2_X0 -#define FSL_EIS_MAS4_X1D FSL_EIS_MAS2_X1 -#define FSL_EIS_MAS4_WD FSL_EIS_MAS2_W -#define FSL_EIS_MAS4_ID FSL_EIS_MAS2_I -#define FSL_EIS_MAS4_MD FSL_EIS_MAS2_M -#define FSL_EIS_MAS4_GD FSL_EIS_MAS2_G -#define FSL_EIS_MAS4_ED FSL_EIS_MAS2_E - -#define FSL_EIS_MAS5 629 - -#define FSL_EIS_MAS6 630 -#define FSL_EIS_MAS6_SPID0(n) ((0xff & (n)) << (63 - 55)) -#define FSL_EIS_MAS6_SAS (1 << (63 - 63)) - -#define FSL_EIS_MAS7 944 - -#define FSL_EIS_MAS8 341 - -#define FSL_EIS_MMUCFG 1015 -#define FSL_EIS_MMUCSR0 1012 -#define FSL_EIS_PID0 48 -#define FSL_EIS_PID1 633 -#define FSL_EIS_PID2 634 -#define FSL_EIS_TLB0CFG 688 -#define FSL_EIS_TLB1CFG 689 - -/* Freescale Book E Implementation Standards (EIS): L1 Cache */ - -#define FSL_EIS_L1CFG0 515 -#define FSL_EIS_L1CFG1 516 -#define FSL_EIS_L1CSR0 1010 -#define FSL_EIS_L1CSR0_CFI (1 << (63 - 62)) -#define FSL_EIS_L1CSR1 1011 -#define FSL_EIS_L1CSR1_ICFI (1 << (63 - 62)) - -/* Freescale Book E Implementation Standards (EIS): L2 Cache */ - -#define FSL_EIS_L2CFG0 519 -#define FSL_EIS_L2CSR0 1017 -#define FSL_EIS_L2CSR0_L2FI (1 << (63 - 42)) -#define FSL_EIS_L2CSR0_L2FL (1 << (63 - 52)) -#define FSL_EIS_L2CSR1 1018 - -/* Freescale Book E Implementation Standards (EIS): Timer */ - -#define FSL_EIS_ATBL 526 -#define FSL_EIS_ATBU 527 - -/* Freescale Book E Implementation Standards (EIS): Interrupt */ - -#define FSL_EIS_MCAR 573 -#define FSL_EIS_DSRR0 574 -#define FSL_EIS_DSRR1 575 -#define FSL_EIS_EPR 702 - -/* Freescale Book E Implementation Standards (EIS): Signal Processing Engine (SPE) */ - -#define FSL_EIS_SPEFSCR 512 - -/* Freescale Book E Implementation Standards (EIS): Software-Use SPRs */ - -#define FSL_EIS_SPRG8 604 -#define FSL_EIS_SPRG9 605 - -/* Freescale Book E Implementation Standards (EIS): Debug */ - -#define FSL_EIS_DBCR3 561 -#define FSL_EIS_DBCR4 563 -#define FSL_EIS_DBCR5 564 -#define FSL_EIS_DBCR6 603 -#define FSL_EIS_DBCNT 562 - -/** - * @brief Default value for the interrupt disable mask. - * - * The interrupt disable mask is stored in the global symbol - * _PPC_INTERRUPT_DISABLE_MASK. - */ -#define PPC_INTERRUPT_DISABLE_MASK_DEFAULT MSR_EE - -#ifndef ASM - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define _CPU_MSR_GET( _msr_value ) \ - do { \ - _msr_value = 0; \ - __asm__ volatile ("mfmsr %0" : "=&r" ((_msr_value)) : "0" ((_msr_value))); \ - } while (0) - -#define _CPU_MSR_SET( _msr_value ) \ -{ __asm__ volatile ("mtmsr %0" : "=&r" ((_msr_value)) : "0" ((_msr_value))); } - -/** - * @brief A global symbol used to disable interrupts in the MSR. - * - * A one bit means that this bit should be cleared. - */ -extern char _PPC_INTERRUPT_DISABLE_MASK[]; - -static inline uint32_t ppc_interrupt_get_disable_mask( void ) -{ - return (uint32_t) (uintptr_t) _PPC_INTERRUPT_DISABLE_MASK; -} - -static inline uint32_t ppc_interrupt_disable( void ) -{ - uint32_t level; - -#if defined(__PPC_CPU_E6500__) - __asm__ volatile ( - "mfmsr %0;" - "wrteei 0" - : "=r" (level) - ); -#else - uint32_t mask; - - __asm__ volatile ( - "mfmsr %0;" - "lis %1, _PPC_INTERRUPT_DISABLE_MASK@h;" - "ori %1, %1, _PPC_INTERRUPT_DISABLE_MASK@l;" - "andc %1, %0, %1;" - "mtmsr %1" - : "=r" (level), "=r" (mask) - ); -#endif - - return level; -} - -static inline void ppc_interrupt_enable( uint32_t level ) -{ -#if defined(__PPC_CPU_E6500__) - __asm__ volatile ( - "wrtee %0" - : - : "r" (level) - ); -#else - __asm__ volatile ( - "mtmsr %0" - : - : "r" (level) - ); -#endif -} - -static inline void ppc_interrupt_flash( uint32_t level ) -{ - uint32_t current_level; - - __asm__ volatile ( - "mfmsr %0;" - "mtmsr %1;" - "mtmsr %0" - : "=&r" (current_level) - : "r" (level) - ); -} - -#define _CPU_ISR_Disable( _isr_cookie ) \ - do { \ - _isr_cookie = ppc_interrupt_disable(); \ - } while (0) - -/* - * Enable interrupts to the previous level (returned by _CPU_ISR_Disable). - * This indicates the end of an RTEMS critical section. The parameter - * _isr_cookie is not modified. - */ - -#define _CPU_ISR_Enable( _isr_cookie ) \ - ppc_interrupt_enable(_isr_cookie) - -/* - * This temporarily restores the interrupt to _isr_cookie before immediately - * disabling them again. This is used to divide long RTEMS critical - * sections into two or more parts. The parameter _isr_cookie is not - * modified. - * - * NOTE: The version being used is not very optimized but it does - * not trip a problem in gcc where the disable mask does not - * get loaded. Check this for future (post 10/97 gcc versions. - */ - -#define _CPU_ISR_Flash( _isr_cookie ) \ - ppc_interrupt_flash(_isr_cookie) - -/* end of ISR handler macros */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* ASM */ - -#endif /* _RTEMS_POWERPC_REGISTERS_H */ diff --git a/cpukit/score/cpu/powerpc/rtems/score/cpu.h b/cpukit/score/cpu/powerpc/rtems/score/cpu.h deleted file mode 100644 index 8c0f200641..0000000000 --- a/cpukit/score/cpu/powerpc/rtems/score/cpu.h +++ /dev/null @@ -1,1257 +0,0 @@ -/** - * @file - * - * @brief PowerPC CPU Department Source - */ - -/* - * COPYRIGHT (c) 1989-2012. - * On-Line Applications Research Corporation (OAR). - * - * COPYRIGHT (c) 1995 i-cubed ltd. - * - * To anyone who acknowledges that this file is provided "AS IS" - * without any express or implied warranty: - * permission to use, copy, modify, and distribute this file - * for any purpose is hereby granted without fee, provided that - * the above copyright notice and this notice appears in all - * copies, and that the name of i-cubed limited not be used in - * advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. - * i-cubed limited makes no representations about the suitability - * of this software for any purpose. - * - * Copyright (c) 2001 Andy Dachs . - * - * Copyright (c) 2001 Surrey Satellite Technology Limited (SSTL). - * - * Copyright (c) 2010, 2017 embedded brains GmbH. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPU_H -#define _RTEMS_SCORE_CPU_H - -#include -#include -#include - -#ifndef ASM - #include /* for memset() */ -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* conditional compilation parameters */ - -/* - * Does this port provide a CPU dependent IDLE task implementation? - * - * If TRUE, then the routine _CPU_Thread_Idle_body - * must be provided and is the default IDLE thread body instead of - * _CPU_Thread_Idle_body. - * - * If FALSE, then use the generic IDLE thread body if the BSP does - * not provide one. - * - * This is intended to allow for supporting processors which have - * a low power or idle mode. When the IDLE thread is executed, then - * the CPU can be powered down. - * - * The order of precedence for selecting the IDLE thread body is: - * - * 1. BSP provided - * 2. CPU dependent (if provided) - * 3. generic (if no BSP and no CPU dependent) - */ - -#define CPU_PROVIDES_IDLE_THREAD_BODY FALSE - -/* - * Does the stack grow up (toward higher addresses) or down - * (toward lower addresses)? - * - * If TRUE, then the grows upward. - * If FALSE, then the grows toward smaller addresses. - */ - -#define CPU_STACK_GROWS_UP FALSE - -#define CPU_CACHE_LINE_BYTES PPC_STRUCTURE_ALIGNMENT - -#define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES ) - -/* - * Does the CPU have hardware floating point? - * - * If TRUE, then the RTEMS_FLOATING_POINT task attribute is supported. - * If FALSE, then the RTEMS_FLOATING_POINT task attribute is ignored. - * - * If there is a FP coprocessor such as the i387 or mc68881, then - * the answer is TRUE. - * - * The macro name "PPC_HAS_FPU" should be made CPU specific. - * It indicates whether or not this CPU model has FP support. For - * example, it would be possible to have an i386_nofp CPU model - * which set this to false to indicate that you have an i386 without - * an i387 and wish to leave floating point support out of RTEMS. - */ - -#if ( PPC_HAS_FPU == 1 ) -#define CPU_HARDWARE_FP TRUE -#define CPU_SOFTWARE_FP FALSE -#else -#define CPU_HARDWARE_FP FALSE -#define CPU_SOFTWARE_FP FALSE -#endif - -/* - * Are all tasks RTEMS_FLOATING_POINT tasks implicitly? - * - * If TRUE, then the RTEMS_FLOATING_POINT task attribute is assumed. - * If FALSE, then the RTEMS_FLOATING_POINT task attribute is followed. - * - * If CPU_HARDWARE_FP is FALSE, then this should be FALSE as well. - * - * PowerPC Note: It appears the GCC can implicitly generate FPU - * and Altivec instructions when you least expect them. So make - * all tasks floating point. - */ - -#define CPU_ALL_TASKS_ARE_FP CPU_HARDWARE_FP - -/* - * Should the IDLE task have a floating point context? - * - * If TRUE, then the IDLE task is created as a RTEMS_FLOATING_POINT task - * and it has a floating point context which is switched in and out. - * If FALSE, then the IDLE task does not have a floating point context. - * - * Setting this to TRUE negatively impacts the time required to preempt - * the IDLE task from an interrupt because the floating point context - * must be saved as part of the preemption. - */ - -#define CPU_IDLE_TASK_IS_FP FALSE - -#define CPU_MAXIMUM_PROCESSORS 32 - -/* - * Processor defined structures required for cpukit/score. - */ - -/* - * Contexts - * - * Generally there are 2 types of context to save. - * 1. Interrupt registers to save - * 2. Task level registers to save - * - * This means we have the following 3 context items: - * 1. task level context stuff:: Context_Control - * 2. floating point task stuff:: Context_Control_fp - * 3. special interrupt level context :: Context_Control_interrupt - * - * On some processors, it is cost-effective to save only the callee - * preserved registers during a task context switch. This means - * that the ISR code needs to save those registers which do not - * persist across function calls. It is not mandatory to make this - * distinctions between the caller/callee saves registers for the - * purpose of minimizing context saved during task switch and on interrupts. - * If the cost of saving extra registers is minimal, simplicity is the - * choice. Save the same context on interrupt entry as for tasks in - * this case. - * - * Additionally, if gdb is to be made aware of RTEMS tasks for this CPU, then - * care should be used in designing the context area. - * - * On some CPUs with hardware floating point support, the Context_Control_fp - * structure will not be used or it simply consist of an array of a - * fixed number of bytes. This is done when the floating point context - * is dumped by a "FP save context" type instruction and the format - * is not really defined by the CPU. In this case, there is no need - * to figure out the exact format -- only the size. Of course, although - * this is enough information for RTEMS, it is probably not enough for - * a debugger such as gdb. But that is another problem. - */ - -#ifndef __SPE__ - #define PPC_GPR_TYPE uintptr_t - #if defined(__powerpc64__) - #define PPC_GPR_SIZE 8 - #define PPC_GPR_LOAD ld - #define PPC_GPR_STORE std - #else - #define PPC_GPR_SIZE 4 - #define PPC_GPR_LOAD lwz - #define PPC_GPR_STORE stw - #endif -#else - #define PPC_GPR_TYPE uint64_t - #define PPC_GPR_SIZE 8 - #define PPC_GPR_LOAD evldd - #define PPC_GPR_STORE evstdd -#endif - -#if defined(__powerpc64__) - #define PPC_REG_SIZE 8 - #define PPC_REG_LOAD ld - #define PPC_REG_STORE std - #define PPC_REG_STORE_UPDATE stdu - #define PPC_REG_CMP cmpd -#else - #define PPC_REG_SIZE 4 - #define PPC_REG_LOAD lwz - #define PPC_REG_STORE stw - #define PPC_REG_STORE_UPDATE stwu - #define PPC_REG_CMP cmpw -#endif - -#ifndef ASM - -/* - * Non-volatile context according to E500ABIUG, EABI and 32-bit TLS (according - * to "Power Architecture 32-bit Application Binary Interface Supplement 1.0 - - * Linux and Embedded") - */ -typedef struct { - uint32_t msr; - uint32_t cr; - uintptr_t gpr1; - uintptr_t lr; - PPC_GPR_TYPE gpr14; - PPC_GPR_TYPE gpr15; - PPC_GPR_TYPE gpr16; - PPC_GPR_TYPE gpr17; - PPC_GPR_TYPE gpr18; - PPC_GPR_TYPE gpr19; - PPC_GPR_TYPE gpr20; - PPC_GPR_TYPE gpr21; - PPC_GPR_TYPE gpr22; - PPC_GPR_TYPE gpr23; - PPC_GPR_TYPE gpr24; - PPC_GPR_TYPE gpr25; - PPC_GPR_TYPE gpr26; - PPC_GPR_TYPE gpr27; - PPC_GPR_TYPE gpr28; - PPC_GPR_TYPE gpr29; - PPC_GPR_TYPE gpr30; - PPC_GPR_TYPE gpr31; - uint32_t isr_dispatch_disable; - uint32_t reserved_for_alignment; - #if defined(PPC_MULTILIB_ALTIVEC) - uint8_t v20[16]; - uint8_t v21[16]; - uint8_t v22[16]; - uint8_t v23[16]; - uint8_t v24[16]; - uint8_t v25[16]; - uint8_t v26[16]; - uint8_t v27[16]; - uint8_t v28[16]; - uint8_t v29[16]; - uint8_t v30[16]; - uint8_t v31[16]; - uint32_t vrsave; - #elif defined(__ALTIVEC__) - /* - * 12 non-volatile vector registers, cache-aligned area for vscr/vrsave - * and padding to ensure cache-alignment. Unfortunately, we can't verify - * the cache line size here in the cpukit but altivec support code will - * produce an error if this is ever different from 32 bytes. - * - * Note: it is the BSP/CPU-support's responsibility to save/restore - * volatile vregs across interrupts and exceptions. - */ - uint8_t altivec[16*12 + 32 + PPC_DEFAULT_CACHE_LINE_SIZE]; - #endif - #if defined(PPC_MULTILIB_FPU) - double f14; - double f15; - double f16; - double f17; - double f18; - double f19; - double f20; - double f21; - double f22; - double f23; - double f24; - double f25; - double f26; - double f27; - double f28; - double f29; - double f30; - double f31; - #endif - /* - * The following items are at the structure end, so that we can use dcbz for - * the previous items to optimize the context switch. We must not set the - * following items to zero via the dcbz. - */ - uintptr_t tp; - #if defined(RTEMS_SMP) - volatile uint32_t is_executing; - #endif -} ppc_context; - -typedef struct { - uint8_t context [ - PPC_DEFAULT_CACHE_LINE_SIZE - + sizeof(ppc_context) - + (sizeof(ppc_context) % PPC_DEFAULT_CACHE_LINE_SIZE == 0 - ? 0 - : PPC_DEFAULT_CACHE_LINE_SIZE - - sizeof(ppc_context) % PPC_DEFAULT_CACHE_LINE_SIZE) - ]; -} Context_Control; - -static inline ppc_context *ppc_get_context( const Context_Control *context ) -{ - uintptr_t clsz = PPC_DEFAULT_CACHE_LINE_SIZE; - uintptr_t mask = clsz - 1; - uintptr_t addr = (uintptr_t) context; - - return (ppc_context *) ((addr & ~mask) + clsz); -} - -#define _CPU_Context_Get_SP( _context ) \ - ppc_get_context(_context)->gpr1 - -#ifdef RTEMS_SMP - static inline bool _CPU_Context_Get_is_executing( - const Context_Control *context - ) - { - return ppc_get_context(context)->is_executing; - } - - static inline void _CPU_Context_Set_is_executing( - Context_Control *context, - bool is_executing - ) - { - ppc_get_context(context)->is_executing = is_executing; - } -#endif -#endif /* ASM */ - -#define PPC_CONTEXT_OFFSET_MSR (PPC_DEFAULT_CACHE_LINE_SIZE) -#define PPC_CONTEXT_OFFSET_CR (PPC_DEFAULT_CACHE_LINE_SIZE + 4) -#define PPC_CONTEXT_OFFSET_GPR1 (PPC_DEFAULT_CACHE_LINE_SIZE + 8) -#define PPC_CONTEXT_OFFSET_LR (PPC_DEFAULT_CACHE_LINE_SIZE + PPC_REG_SIZE + 8) - -#define PPC_CONTEXT_GPR_OFFSET( gpr ) \ - (((gpr) - 14) * PPC_GPR_SIZE + \ - PPC_DEFAULT_CACHE_LINE_SIZE + 8 + 2 * PPC_REG_SIZE) - -#define PPC_CONTEXT_OFFSET_GPR14 PPC_CONTEXT_GPR_OFFSET( 14 ) -#define PPC_CONTEXT_OFFSET_GPR15 PPC_CONTEXT_GPR_OFFSET( 15 ) -#define PPC_CONTEXT_OFFSET_GPR16 PPC_CONTEXT_GPR_OFFSET( 16 ) -#define PPC_CONTEXT_OFFSET_GPR17 PPC_CONTEXT_GPR_OFFSET( 17 ) -#define PPC_CONTEXT_OFFSET_GPR18 PPC_CONTEXT_GPR_OFFSET( 18 ) -#define PPC_CONTEXT_OFFSET_GPR19 PPC_CONTEXT_GPR_OFFSET( 19 ) -#define PPC_CONTEXT_OFFSET_GPR20 PPC_CONTEXT_GPR_OFFSET( 20 ) -#define PPC_CONTEXT_OFFSET_GPR21 PPC_CONTEXT_GPR_OFFSET( 21 ) -#define PPC_CONTEXT_OFFSET_GPR22 PPC_CONTEXT_GPR_OFFSET( 22 ) -#define PPC_CONTEXT_OFFSET_GPR23 PPC_CONTEXT_GPR_OFFSET( 23 ) -#define PPC_CONTEXT_OFFSET_GPR24 PPC_CONTEXT_GPR_OFFSET( 24 ) -#define PPC_CONTEXT_OFFSET_GPR25 PPC_CONTEXT_GPR_OFFSET( 25 ) -#define PPC_CONTEXT_OFFSET_GPR26 PPC_CONTEXT_GPR_OFFSET( 26 ) -#define PPC_CONTEXT_OFFSET_GPR27 PPC_CONTEXT_GPR_OFFSET( 27 ) -#define PPC_CONTEXT_OFFSET_GPR28 PPC_CONTEXT_GPR_OFFSET( 28 ) -#define PPC_CONTEXT_OFFSET_GPR29 PPC_CONTEXT_GPR_OFFSET( 29 ) -#define PPC_CONTEXT_OFFSET_GPR30 PPC_CONTEXT_GPR_OFFSET( 30 ) -#define PPC_CONTEXT_OFFSET_GPR31 PPC_CONTEXT_GPR_OFFSET( 31 ) -#define PPC_CONTEXT_OFFSET_ISR_DISPATCH_DISABLE PPC_CONTEXT_GPR_OFFSET( 32 ) - -#ifdef PPC_MULTILIB_ALTIVEC - #define PPC_CONTEXT_OFFSET_V( v ) \ - ( ( ( v ) - 20 ) * 16 + PPC_CONTEXT_OFFSET_ISR_DISPATCH_DISABLE + 8) - #define PPC_CONTEXT_OFFSET_V20 PPC_CONTEXT_OFFSET_V( 20 ) - #define PPC_CONTEXT_OFFSET_V21 PPC_CONTEXT_OFFSET_V( 21 ) - #define PPC_CONTEXT_OFFSET_V22 PPC_CONTEXT_OFFSET_V( 22 ) - #define PPC_CONTEXT_OFFSET_V23 PPC_CONTEXT_OFFSET_V( 23 ) - #define PPC_CONTEXT_OFFSET_V24 PPC_CONTEXT_OFFSET_V( 24 ) - #define PPC_CONTEXT_OFFSET_V25 PPC_CONTEXT_OFFSET_V( 25 ) - #define PPC_CONTEXT_OFFSET_V26 PPC_CONTEXT_OFFSET_V( 26 ) - #define PPC_CONTEXT_OFFSET_V27 PPC_CONTEXT_OFFSET_V( 27 ) - #define PPC_CONTEXT_OFFSET_V28 PPC_CONTEXT_OFFSET_V( 28 ) - #define PPC_CONTEXT_OFFSET_V29 PPC_CONTEXT_OFFSET_V( 29 ) - #define PPC_CONTEXT_OFFSET_V30 PPC_CONTEXT_OFFSET_V( 30 ) - #define PPC_CONTEXT_OFFSET_V31 PPC_CONTEXT_OFFSET_V( 31 ) - #define PPC_CONTEXT_OFFSET_VRSAVE PPC_CONTEXT_OFFSET_V( 32 ) - #define PPC_CONTEXT_OFFSET_F( f ) \ - ( ( ( f ) - 14 ) * 8 + PPC_CONTEXT_OFFSET_VRSAVE + 8 ) -#else - #define PPC_CONTEXT_OFFSET_F( f ) \ - ( ( ( f ) - 14 ) * 8 + PPC_CONTEXT_OFFSET_ISR_DISPATCH_DISABLE + 8 ) -#endif - -#ifdef PPC_MULTILIB_FPU - #define PPC_CONTEXT_OFFSET_F14 PPC_CONTEXT_OFFSET_F( 14 ) - #define PPC_CONTEXT_OFFSET_F15 PPC_CONTEXT_OFFSET_F( 15 ) - #define PPC_CONTEXT_OFFSET_F16 PPC_CONTEXT_OFFSET_F( 16 ) - #define PPC_CONTEXT_OFFSET_F17 PPC_CONTEXT_OFFSET_F( 17 ) - #define PPC_CONTEXT_OFFSET_F18 PPC_CONTEXT_OFFSET_F( 18 ) - #define PPC_CONTEXT_OFFSET_F19 PPC_CONTEXT_OFFSET_F( 19 ) - #define PPC_CONTEXT_OFFSET_F20 PPC_CONTEXT_OFFSET_F( 20 ) - #define PPC_CONTEXT_OFFSET_F21 PPC_CONTEXT_OFFSET_F( 21 ) - #define PPC_CONTEXT_OFFSET_F22 PPC_CONTEXT_OFFSET_F( 22 ) - #define PPC_CONTEXT_OFFSET_F23 PPC_CONTEXT_OFFSET_F( 23 ) - #define PPC_CONTEXT_OFFSET_F24 PPC_CONTEXT_OFFSET_F( 24 ) - #define PPC_CONTEXT_OFFSET_F25 PPC_CONTEXT_OFFSET_F( 25 ) - #define PPC_CONTEXT_OFFSET_F26 PPC_CONTEXT_OFFSET_F( 26 ) - #define PPC_CONTEXT_OFFSET_F27 PPC_CONTEXT_OFFSET_F( 27 ) - #define PPC_CONTEXT_OFFSET_F28 PPC_CONTEXT_OFFSET_F( 28 ) - #define PPC_CONTEXT_OFFSET_F29 PPC_CONTEXT_OFFSET_F( 29 ) - #define PPC_CONTEXT_OFFSET_F30 PPC_CONTEXT_OFFSET_F( 30 ) - #define PPC_CONTEXT_OFFSET_F31 PPC_CONTEXT_OFFSET_F( 31 ) -#endif - -#if defined(PPC_MULTILIB_FPU) - #define PPC_CONTEXT_VOLATILE_SIZE PPC_CONTEXT_OFFSET_F( 32 ) -#elif defined(PPC_MULTILIB_ALTIVEC) - #define PPC_CONTEXT_VOLATILE_SIZE (PPC_CONTEXT_OFFSET_VRSAVE + 4) -#elif defined(__ALTIVEC__) - #define PPC_CONTEXT_VOLATILE_SIZE \ - (PPC_CONTEXT_GPR_OFFSET( 32 ) + 8 \ - + 16 * 12 + 32 + PPC_DEFAULT_CACHE_LINE_SIZE) -#else - #define PPC_CONTEXT_VOLATILE_SIZE (PPC_CONTEXT_GPR_OFFSET( 32 ) + 8) -#endif - -#define PPC_CONTEXT_OFFSET_TP PPC_CONTEXT_VOLATILE_SIZE - -#ifdef RTEMS_SMP - #define PPC_CONTEXT_OFFSET_IS_EXECUTING \ - (PPC_CONTEXT_OFFSET_TP + PPC_REG_SIZE) -#endif - -#ifndef ASM -typedef struct { -#if (PPC_HAS_FPU == 1) - /* The ABIs (PowerOpen/SVR4/EABI) only require saving f14-f31 over - * procedure calls. However, this would mean that the interrupt - * frame had to hold f0-f13, and the fpscr. And as the majority - * of tasks will not have an FP context, we will save the whole - * context here. - */ -#if (PPC_HAS_DOUBLE == 1) - double f[32]; - uint64_t fpscr; -#else - float f[32]; - uint32_t fpscr; -#endif -#endif /* (PPC_HAS_FPU == 1) */ -} Context_Control_fp; - -#endif /* ASM */ - -/* - * Does the CPU follow the simple vectored interrupt model? - * - * If TRUE, then RTEMS allocates the vector table it internally manages. - * If FALSE, then the BSP is assumed to allocate and manage the vector - * table - * - * PowerPC Specific Information: - * - * The PowerPC and x86 were the first to use the PIC interrupt model. - * They do not use the simple vectored interrupt model. - */ -#define CPU_SIMPLE_VECTORED_INTERRUPTS FALSE - -/* - * Does RTEMS manage a dedicated interrupt stack in software? - * - * If TRUE, then a stack is allocated in _ISR_Handler_initialization. - * If FALSE, nothing is done. - * - * If the CPU supports a dedicated interrupt stack in hardware, - * then it is generally the responsibility of the BSP to allocate it - * and set it up. - * - * If the CPU does not support a dedicated interrupt stack, then - * the porter has two options: (1) execute interrupts on the - * stack of the interrupted task, and (2) have RTEMS manage a dedicated - * interrupt stack. - * - * If this is TRUE, CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. - * - * Only one of CPU_HAS_SOFTWARE_INTERRUPT_STACK and - * CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is - * possible that both are FALSE for a particular CPU. Although it - * is unclear what that would imply about the interrupt processing - * procedure on that CPU. - */ - -#define CPU_HAS_SOFTWARE_INTERRUPT_STACK TRUE - -/* - * Does this CPU have hardware support for a dedicated interrupt stack? - * - * If TRUE, then it must be installed during initialization. - * If FALSE, then no installation is performed. - * - * If this is TRUE, CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. - * - * Only one of CPU_HAS_SOFTWARE_INTERRUPT_STACK and - * CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is - * possible that both are FALSE for a particular CPU. Although it - * is unclear what that would imply about the interrupt processing - * procedure on that CPU. - */ - -#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE - -/* - * Does RTEMS allocate a dedicated interrupt stack in the Interrupt Manager? - * - * If TRUE, then the memory is allocated during initialization. - * If FALSE, then the memory is allocated during initialization. - * - * This should be TRUE is CPU_HAS_SOFTWARE_INTERRUPT_STACK is TRUE. - */ - -#define CPU_ALLOCATE_INTERRUPT_STACK TRUE - -/* - * Does the RTEMS invoke the user's ISR with the vector number and - * a pointer to the saved interrupt frame (1) or just the vector - * number (0)? - */ - -#define CPU_ISR_PASSES_FRAME_POINTER FALSE - -/* - * Should the saving of the floating point registers be deferred - * until a context switch is made to another different floating point - * task? - * - * If TRUE, then the floating point context will not be stored until - * necessary. It will remain in the floating point registers and not - * disturned until another floating point task is switched to. - * - * If FALSE, then the floating point context is saved when a floating - * point task is switched out and restored when the next floating point - * task is restored. The state of the floating point registers between - * those two operations is not specified. - * - * If the floating point context does NOT have to be saved as part of - * interrupt dispatching, then it should be safe to set this to TRUE. - * - * Setting this flag to TRUE results in using a different algorithm - * for deciding when to save and restore the floating point context. - * The deferred FP switch algorithm minimizes the number of times - * the FP context is saved and restored. The FP context is not saved - * until a context switch is made to another, different FP task. - * Thus in a system with only one FP task, the FP context will never - * be saved or restored. - * - * Note, however that compilers may use floating point registers/ - * instructions for optimization or they may save/restore FP registers - * on the stack. You must not use deferred switching in these cases - * and on the PowerPC attempting to do so will raise a "FP unavailable" - * exception. - */ -/* - * ACB Note: This could make debugging tricky.. - */ - -/* conservative setting (FALSE); probably doesn't affect performance too much */ -#define CPU_USE_DEFERRED_FP_SWITCH FALSE - -#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE - -/* - * Processor defined structures required for cpukit/score. - */ - -#ifndef ASM - -/* - * This variable is optional. It is used on CPUs on which it is difficult - * to generate an "uninitialized" FP context. It is filled in by - * _CPU_Initialize and copied into the task's FP context area during - * _CPU_Context_Initialize. - */ - -/* EXTERN Context_Control_fp _CPU_Null_fp_context; */ - -#endif /* ndef ASM */ - -/* - * This defines the number of levels and the mask used to pick those - * bits out of a thread mode. - */ - -#define CPU_MODES_INTERRUPT_LEVEL 0x00000001 /* interrupt level in mode */ -#define CPU_MODES_INTERRUPT_MASK 0x00000001 /* interrupt level in mode */ - -/* - * The size of the floating point context area. On some CPUs this - * will not be a "sizeof" because the format of the floating point - * area is not defined -- only the size is. This is usually on - * CPUs with a "floating point save context" instruction. - */ - -#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp ) - -/* - * (Optional) # of bytes for libmisc/stackchk to check - * If not specifed, then it defaults to something reasonable - * for most architectures. - */ - -#define CPU_STACK_CHECK_PATTERN_INITIALIZER \ - { 0xFEEDF00D, 0x0BAD0D06, 0xDEADF00D, 0x600D0D06, \ - 0xFEEDF00D, 0x0BAD0D06, 0xDEADF00D, 0x600D0D06, \ - 0xFEEDF00D, 0x0BAD0D06, 0xDEADF00D, 0x600D0D06, \ - 0xFEEDF00D, 0x0BAD0D06, 0xDEADF00D, 0x600D0D06, \ - 0xFEEDF00D, 0x0BAD0D06, 0xDEADF00D, 0x600D0D06, \ - 0xFEEDF00D, 0x0BAD0D06, 0xDEADF00D, 0x600D0D06, \ - 0xFEEDF00D, 0x0BAD0D06, 0xDEADF00D, 0x600D0D06, \ - 0xFEEDF00D, 0x0BAD0D06, 0xDEADF00D, 0x600D0D06 } - -/* - * Amount of extra stack (above minimum stack size) required by - * MPCI receive server thread. Remember that in a multiprocessor - * system this thread must exist and be able to process all directives. - */ - -#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0 - -/* - * This is defined if the port has a special way to report the ISR nesting - * level. Most ports maintain the variable _ISR_Nest_level. Note that - * this is not an option - RTEMS/score _relies_ on _ISR_Nest_level - * being maintained (e.g. watchdog queues). - */ - -#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE - -/* - * ISR handler macros - */ - -/* - * Disable all interrupts for an RTEMS critical section. The previous - * level is returned in _isr_cookie. - */ - -#ifndef ASM - -RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) -{ - return ( level & MSR_EE ) != 0; -} - -static inline uint32_t _CPU_ISR_Get_level( void ) -{ - register unsigned int msr; - _CPU_MSR_GET(msr); - if (msr & MSR_EE) return 0; - else return 1; -} - -static inline void _CPU_ISR_Set_level( uint32_t level ) -{ - register unsigned int msr; - _CPU_MSR_GET(msr); - if (!(level & CPU_MODES_INTERRUPT_MASK)) { - msr |= ppc_interrupt_get_disable_mask(); - } - else { - msr &= ~ppc_interrupt_get_disable_mask(); - } - _CPU_MSR_SET(msr); -} - -#endif /* ASM */ - -#define _CPU_Fatal_halt( _source, _error ) \ - do { \ - ppc_interrupt_disable(); \ - __asm__ volatile ( \ - "mr 3, %0\n" \ - "mr 4, %1\n" \ - "1:\n" \ - "b 1b\n" \ - : \ - : "r" (_source), "r" (_error) \ - : "memory" \ - ); \ - } while ( 0 ) - -/* - * Should be large enough to run all RTEMS tests. This ensures - * that a "reasonable" small application should not have any problems. - */ - -#define CPU_STACK_MINIMUM_SIZE (1024*8) - -#if defined(__powerpc64__) -#define CPU_SIZEOF_POINTER 8 -#else -#define CPU_SIZEOF_POINTER 4 -#endif - -/* - * CPU's worst alignment requirement for data types on a byte boundary. This - * alignment does not take into account the requirements for the stack. - */ - -#define CPU_ALIGNMENT (PPC_ALIGNMENT) - -/* - * This number corresponds to the byte alignment requirement for the - * heap handler. This alignment requirement may be stricter than that - * for the data types alignment specified by CPU_ALIGNMENT. It is - * common for the heap to follow the same alignment requirement as - * CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict enough for the heap, - * then this should be set to CPU_ALIGNMENT. - * - * NOTE: This does not have to be a power of 2. It does have to - * be greater or equal to than CPU_ALIGNMENT. - */ - -#define CPU_HEAP_ALIGNMENT (PPC_ALIGNMENT) - -/* - * This number corresponds to the byte alignment requirement for memory - * buffers allocated by the partition manager. This alignment requirement - * may be stricter than that for the data types alignment specified by - * CPU_ALIGNMENT. It is common for the partition to follow the same - * alignment requirement as CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict - * enough for the partition, then this should be set to CPU_ALIGNMENT. - * - * NOTE: This does not have to be a power of 2. It does have to - * be greater or equal to than CPU_ALIGNMENT. - */ - -#define CPU_PARTITION_ALIGNMENT (PPC_ALIGNMENT) - -/* - * This number corresponds to the byte alignment requirement for the - * stack. This alignment requirement may be stricter than that for the - * data types alignment specified by CPU_ALIGNMENT. If the CPU_ALIGNMENT - * is strict enough for the stack, then this should be set to 0. - * - * NOTE: This must be a power of 2 either 0 or greater than CPU_ALIGNMENT. - */ - -#define CPU_STACK_ALIGNMENT (PPC_STACK_ALIGNMENT) - -#ifndef ASM -/* The following routine swaps the endian format of an unsigned int. - * It must be static because it is referenced indirectly. - * - * This version will work on any processor, but if there is a better - * way for your CPU PLEASE use it. The most common way to do this is to: - * - * swap least significant two bytes with 16-bit rotate - * swap upper and lower 16-bits - * swap most significant two bytes with 16-bit rotate - * - * Some CPUs have special instructions which swap a 32-bit quantity in - * a single instruction (e.g. i486). It is probably best to avoid - * an "endian swapping control bit" in the CPU. One good reason is - * that interrupts would probably have to be disabled to ensure that - * an interrupt does not try to access the same "chunk" with the wrong - * endian. Another good reason is that on some CPUs, the endian bit - * endianness for ALL fetches -- both code and data -- so the code - * will be fetched incorrectly. - */ - -static inline uint32_t CPU_swap_u32( - uint32_t value -) -{ - uint32_t swapped; - - __asm__ volatile("rlwimi %0,%1,8,24,31;" - "rlwimi %0,%1,24,16,23;" - "rlwimi %0,%1,8,8,15;" - "rlwimi %0,%1,24,0,7;" : - "=&r" ((swapped)) : "r" ((value))); - - return( swapped ); -} - -#define CPU_swap_u16( value ) \ - (((value&0xff) << 8) | ((value >> 8)&0xff)) - -typedef uint32_t CPU_Counter_ticks; - -static inline CPU_Counter_ticks _CPU_Counter_read( void ) -{ - CPU_Counter_ticks value; - -#if defined(__PPC_CPU_E6500__) - /* Use Alternate Time Base */ - __asm__ volatile( "mfspr %0, 526" : "=r" (value) ); -#else - __asm__ volatile( "mfspr %0, 268" : "=r" (value) ); -#endif - - return value; -} - -static inline CPU_Counter_ticks _CPU_Counter_difference( - CPU_Counter_ticks second, - CPU_Counter_ticks first -) -{ - return second - first; -} - -#endif /* ASM */ - - -#ifndef ASM -/* Context handler macros */ - -/* - * Initialize the context to a state suitable for starting a - * task after a context restore operation. Generally, this - * involves: - * - * - setting a starting address - * - preparing the stack - * - preparing the stack and frame pointers - * - setting the proper interrupt level in the context - * - initializing the floating point context - * - * This routine generally does not set any unnecessary register - * in the context. The state of the "general data" registers is - * undefined at task start time. - */ - -void _CPU_Context_Initialize( - Context_Control *the_context, - void *stack_base, - size_t size, - uint32_t new_level, - void *entry_point, - bool is_fp, - void *tls_area -); - -/* - * This routine is responsible for somehow restarting the currently - * executing task. If you are lucky, then all that is necessary - * is restoring the context. Otherwise, there will need to be - * a special assembly routine which does something special in this - * case. Context_Restore should work most of the time. It will - * not work if restarting self conflicts with the stack frame - * assumptions of restoring a context. - */ - -#define _CPU_Context_Restart_self( _the_context ) \ - _CPU_Context_restore( (_the_context) ); - -/* - * This routine initializes the FP context area passed to it to. - * There are a few standard ways in which to initialize the - * floating point context. The code included for this macro assumes - * that this is a CPU in which a "initial" FP context was saved into - * _CPU_Null_fp_context and it simply copies it to the destination - * context passed to it. - * - * Other models include (1) not doing anything, and (2) putting - * a "null FP status word" in the correct place in the FP context. - */ - -#define _CPU_Context_Initialize_fp( _destination ) \ - memset( *(_destination), 0, sizeof( **(_destination) ) ) - -/* end of Context handler macros */ -#endif /* ASM */ - -#ifndef ASM -/* Bitfield handler macros */ - -#define CPU_USE_GENERIC_BITFIELD_CODE FALSE - -/* - * This routine sets _output to the bit number of the first bit - * set in _value. _value is of CPU dependent type Priority_bit_map_Word. - * This type may be either 16 or 32 bits wide although only the 16 - * least significant bits will be used. - * - * There are a number of variables in using a "find first bit" type - * instruction. - * - * (1) What happens when run on a value of zero? - * (2) Bits may be numbered from MSB to LSB or vice-versa. - * (3) The numbering may be zero or one based. - * (4) The "find first bit" instruction may search from MSB or LSB. - * - * RTEMS guarantees that (1) will never happen so it is not a concern. - * (2),(3), (4) are handled by the macros _CPU_Priority_mask() and - * _CPU_Priority_Bits_index(). These three form a set of routines - * which must logically operate together. Bits in the _value are - * set and cleared based on masks built by _CPU_Priority_mask(). - * The basic major and minor values calculated by _Priority_Major() - * and _Priority_Minor() are "massaged" by _CPU_Priority_Bits_index() - * to properly range between the values returned by the "find first bit" - * instruction. This makes it possible for _Priority_Get_highest() to - * calculate the major and directly index into the minor table. - * This mapping is necessary to ensure that 0 (a high priority major/minor) - * is the first bit found. - * - * This entire "find first bit" and mapping process depends heavily - * on the manner in which a priority is broken into a major and minor - * components with the major being the 4 MSB of a priority and minor - * the 4 LSB. Thus (0 << 4) + 0 corresponds to priority 0 -- the highest - * priority. And (15 << 4) + 14 corresponds to priority 254 -- the next - * to the lowest priority. - * - * If your CPU does not have a "find first bit" instruction, then - * there are ways to make do without it. Here are a handful of ways - * to implement this in software: - * - * - a series of 16 bit test instructions - * - a "binary search using if's" - * - _number = 0 - * if _value > 0x00ff - * _value >>=8 - * _number = 8; - * - * if _value > 0x0000f - * _value >=8 - * _number += 4 - * - * _number += bit_set_table[ _value ] - * - * where bit_set_table[ 16 ] has values which indicate the first - * bit set - */ - -#define _CPU_Bitfield_Find_first_bit( _value, _output ) \ - { \ - __asm__ volatile ("cntlzw %0, %1" : "=r" ((_output)), "=r" ((_value)) : \ - "1" ((_value))); \ - (_output) = (_output) - 16; \ - } - -/* end of Bitfield handler macros */ - -/* - * This routine builds the mask which corresponds to the bit fields - * as searched by _CPU_Bitfield_Find_first_bit(). See the discussion - * for that routine. - */ - -#define _CPU_Priority_Mask( _bit_number ) \ - ( 0x8000u >> (_bit_number) ) - -/* - * This routine translates the bit numbers returned by - * _CPU_Bitfield_Find_first_bit() into something suitable for use as - * a major or minor component of a priority. See the discussion - * for that routine. - */ - -#define _CPU_Priority_bits_index( _priority ) \ - (_priority) - -/* end of Priority handler macros */ -#endif /* ASM */ - -/* functions */ - -#ifndef ASM - -/* - * _CPU_Initialize - * - * This routine performs CPU dependent initialization. - */ - -void _CPU_Initialize(void); - -/* - * _CPU_ISR_install_vector - * - * This routine installs an interrupt vector. - */ - -void _CPU_ISR_install_vector( - uint32_t vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -/* - * _CPU_Context_switch - * - * This routine switches from the run context to the heir context. - */ - -void _CPU_Context_switch( - Context_Control *run, - Context_Control *heir -); - -/* - * _CPU_Context_restore - * - * This routine is generallu used only to restart self in an - * efficient manner. It may simply be a label in _CPU_Context_switch. - * - * NOTE: May be unnecessary to reload some registers. - */ - -void _CPU_Context_restore( - Context_Control *new_context -) RTEMS_NO_RETURN; - -/* - * _CPU_Context_save_fp - * - * This routine saves the floating point context passed to it. - */ - -void _CPU_Context_save_fp( - Context_Control_fp **fp_context_ptr -); - -/* - * _CPU_Context_restore_fp - * - * This routine restores the floating point context passed to it. - */ - -void _CPU_Context_restore_fp( - Context_Control_fp **fp_context_ptr -); - -void _CPU_Context_volatile_clobber( uintptr_t pattern ); - -void _CPU_Context_validate( uintptr_t pattern ); - -#ifdef RTEMS_SMP - uint32_t _CPU_SMP_Initialize( void ); - - bool _CPU_SMP_Start_processor( uint32_t cpu_index ); - - void _CPU_SMP_Finalize_initialization( uint32_t cpu_count ); - - void _CPU_SMP_Prepare_start_multitasking( void ); - - static inline uint32_t _CPU_SMP_Get_current_processor( void ) - { - uint32_t pir; - - /* Use Book E Processor ID Register (PIR) */ - __asm__ volatile ( - "mfspr %[pir], 286" - : [pir] "=&r" (pir) - ); - - return pir; - } - - void _CPU_SMP_Send_interrupt( uint32_t target_processor_index ); - - static inline void _CPU_SMP_Processor_event_broadcast( void ) - { - __asm__ volatile ( "" : : : "memory" ); - } - - static inline void _CPU_SMP_Processor_event_receive( void ) - { - __asm__ volatile ( "" : : : "memory" ); - } -#endif - -typedef struct { - uintptr_t EXC_SRR0; - uintptr_t EXC_SRR1; - uint32_t _EXC_number; - uint32_t RESERVED_FOR_ALIGNMENT_0; - uint32_t EXC_CR; - uint32_t EXC_XER; - uintptr_t EXC_CTR; - uintptr_t EXC_LR; - uintptr_t RESERVED_FOR_ALIGNMENT_1; - #ifdef __SPE__ - uint32_t EXC_SPEFSCR; - uint64_t EXC_ACC; - #endif - PPC_GPR_TYPE GPR0; - PPC_GPR_TYPE GPR1; - PPC_GPR_TYPE GPR2; - PPC_GPR_TYPE GPR3; - PPC_GPR_TYPE GPR4; - PPC_GPR_TYPE GPR5; - PPC_GPR_TYPE GPR6; - PPC_GPR_TYPE GPR7; - PPC_GPR_TYPE GPR8; - PPC_GPR_TYPE GPR9; - PPC_GPR_TYPE GPR10; - PPC_GPR_TYPE GPR11; - PPC_GPR_TYPE GPR12; - PPC_GPR_TYPE GPR13; - PPC_GPR_TYPE GPR14; - PPC_GPR_TYPE GPR15; - PPC_GPR_TYPE GPR16; - PPC_GPR_TYPE GPR17; - PPC_GPR_TYPE GPR18; - PPC_GPR_TYPE GPR19; - PPC_GPR_TYPE GPR20; - PPC_GPR_TYPE GPR21; - PPC_GPR_TYPE GPR22; - PPC_GPR_TYPE GPR23; - PPC_GPR_TYPE GPR24; - PPC_GPR_TYPE GPR25; - PPC_GPR_TYPE GPR26; - PPC_GPR_TYPE GPR27; - PPC_GPR_TYPE GPR28; - PPC_GPR_TYPE GPR29; - PPC_GPR_TYPE GPR30; - PPC_GPR_TYPE GPR31; - uintptr_t RESERVED_FOR_ALIGNMENT_2; - #ifdef PPC_MULTILIB_ALTIVEC - uint32_t VRSAVE; - uint32_t RESERVED_FOR_ALIGNMENT_3[3]; - - /* This field must take stvewx/lvewx requirements into account */ - uint32_t RESERVED_FOR_ALIGNMENT_4[3]; - uint32_t VSCR; - - uint8_t V0[16]; - uint8_t V1[16]; - uint8_t V2[16]; - uint8_t V3[16]; - uint8_t V4[16]; - uint8_t V5[16]; - uint8_t V6[16]; - uint8_t V7[16]; - uint8_t V8[16]; - uint8_t V9[16]; - uint8_t V10[16]; - uint8_t V11[16]; - uint8_t V12[16]; - uint8_t V13[16]; - uint8_t V14[16]; - uint8_t V15[16]; - uint8_t V16[16]; - uint8_t V17[16]; - uint8_t V18[16]; - uint8_t V19[16]; - uint8_t V20[16]; - uint8_t V21[16]; - uint8_t V22[16]; - uint8_t V23[16]; - uint8_t V24[16]; - uint8_t V25[16]; - uint8_t V26[16]; - uint8_t V27[16]; - uint8_t V28[16]; - uint8_t V29[16]; - uint8_t V30[16]; - uint8_t V31[16]; - #endif - #ifdef PPC_MULTILIB_FPU - double F0; - double F1; - double F2; - double F3; - double F4; - double F5; - double F6; - double F7; - double F8; - double F9; - double F10; - double F11; - double F12; - double F13; - double F14; - double F15; - double F16; - double F17; - double F18; - double F19; - double F20; - double F21; - double F22; - double F23; - double F24; - double F25; - double F26; - double F27; - double F28; - double F29; - double F30; - double F31; - uint64_t FPSCR; - uint64_t RESERVED_FOR_ALIGNMENT_5; - #endif -} CPU_Exception_frame; - -void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); - -/* - * _CPU_Initialize_altivec() - * - * Global altivec-related initialization. - */ -void -_CPU_Initialize_altivec(void); - -/* - * _CPU_Context_switch_altivec - * - * This routine switches the altivec contexts passed to it. - */ - -void -_CPU_Context_switch_altivec( - ppc_context *from, - ppc_context *to -); - -/* - * _CPU_Context_restore_altivec - * - * This routine restores the altivec context passed to it. - */ - -void -_CPU_Context_restore_altivec( - ppc_context *ctxt -); - -/* - * _CPU_Context_initialize_altivec - * - * This routine initializes the altivec context passed to it. - */ - -void -_CPU_Context_initialize_altivec( - ppc_context *ctxt -); - -void _CPU_Fatal_error( - uint32_t _error -); - -#endif /* ASM */ - -#ifdef __cplusplus -} -#endif - -#endif /* _RTEMS_SCORE_CPU_H */ diff --git a/cpukit/score/cpu/powerpc/rtems/score/cpuatomic.h b/cpukit/score/cpu/powerpc/rtems/score/cpuatomic.h deleted file mode 100644 index 598ee76b20..0000000000 --- a/cpukit/score/cpu/powerpc/rtems/score/cpuatomic.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * COPYRIGHT (c) 2012-2013 Deng Hengyi. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_ATOMIC_CPU_H -#define _RTEMS_SCORE_ATOMIC_CPU_H - -#include - -#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/powerpc/rtems/score/cpuimpl.h b/cpukit/score/cpu/powerpc/rtems/score/cpuimpl.h deleted file mode 100644 index 792a8111ad..0000000000 --- a/cpukit/score/cpu/powerpc/rtems/score/cpuimpl.h +++ /dev/null @@ -1,247 +0,0 @@ -/** - * @file - * - * @brief CPU Port Implementation API - */ - -/* - * Copyright (C) 1999 Eric Valette (valette@crf.canon.fr) - * Canon Centre Recherche France. - * - * Copyright (C) 2007 Till Straumann - * - * Copyright (c) 2009, 2017 embedded brains GmbH - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPUIMPL_H -#define _RTEMS_SCORE_CPUIMPL_H - -#include - -/* Exception stack frame -> BSP_Exception_frame */ -#ifdef __powerpc64__ - #define FRAME_LINK_SPACE 32 -#else - #define FRAME_LINK_SPACE 8 -#endif - -#define SRR0_FRAME_OFFSET FRAME_LINK_SPACE -#define SRR1_FRAME_OFFSET (SRR0_FRAME_OFFSET + PPC_REG_SIZE) -#define EXCEPTION_NUMBER_OFFSET (SRR1_FRAME_OFFSET + PPC_REG_SIZE) -#define PPC_EXC_INTERRUPT_ENTRY_INSTANT_OFFSET (EXCEPTION_NUMBER_OFFSET + 4) -#define EXC_CR_OFFSET (EXCEPTION_NUMBER_OFFSET + 8) -#define EXC_XER_OFFSET (EXC_CR_OFFSET + 4) -#define EXC_CTR_OFFSET (EXC_XER_OFFSET + 4) -#define EXC_LR_OFFSET (EXC_CTR_OFFSET + PPC_REG_SIZE) -#define PPC_EXC_INTERRUPT_FRAME_OFFSET (EXC_LR_OFFSET + PPC_REG_SIZE) - -#ifndef __SPE__ - #define PPC_EXC_GPR_OFFSET(gpr) \ - ((gpr) * PPC_GPR_SIZE + PPC_EXC_INTERRUPT_FRAME_OFFSET + PPC_REG_SIZE) - #define PPC_EXC_GPR3_PROLOGUE_OFFSET PPC_EXC_GPR_OFFSET(3) - #if defined(PPC_MULTILIB_ALTIVEC) && defined(PPC_MULTILIB_FPU) - #define PPC_EXC_VRSAVE_OFFSET PPC_EXC_GPR_OFFSET(33) - #define PPC_EXC_VSCR_OFFSET (PPC_EXC_VRSAVE_OFFSET + 28) - #define PPC_EXC_VR_OFFSET(v) ((v) * 16 + PPC_EXC_VSCR_OFFSET + 4) - #define PPC_EXC_FR_OFFSET(f) ((f) * 8 + PPC_EXC_VR_OFFSET(32)) - #define PPC_EXC_FPSCR_OFFSET PPC_EXC_FR_OFFSET(32) - #define PPC_EXC_FRAME_SIZE PPC_EXC_FR_OFFSET(34) - #define PPC_EXC_MIN_VSCR_OFFSET (PPC_EXC_GPR_OFFSET(13) + 12) - #define PPC_EXC_MIN_VR_OFFSET(v) ((v) * 16 + PPC_EXC_MIN_VSCR_OFFSET + 4) - #define PPC_EXC_MIN_FR_OFFSET(f) ((f) * 8 + PPC_EXC_MIN_VR_OFFSET(20)) - #define PPC_EXC_MIN_FPSCR_OFFSET PPC_EXC_MIN_FR_OFFSET(14) - #define CPU_INTERRUPT_FRAME_SIZE \ - (PPC_EXC_MIN_FR_OFFSET(16) + PPC_STACK_RED_ZONE_SIZE) - #elif defined(PPC_MULTILIB_ALTIVEC) - #define PPC_EXC_VRSAVE_OFFSET PPC_EXC_GPR_OFFSET(33) - #define PPC_EXC_VSCR_OFFSET (PPC_EXC_VRSAVE_OFFSET + 28) - #define PPC_EXC_VR_OFFSET(v) ((v) * 16 + PPC_EXC_VSCR_OFFSET + 4) - #define PPC_EXC_FRAME_SIZE PPC_EXC_VR_OFFSET(32) - #define PPC_EXC_MIN_VSCR_OFFSET (PPC_EXC_GPR_OFFSET(13) + 12) - #define PPC_EXC_MIN_VR_OFFSET(v) ((v) * 16 + PPC_EXC_MIN_VSCR_OFFSET + 4) - #define CPU_INTERRUPT_FRAME_SIZE \ - (PPC_EXC_MIN_VR_OFFSET(20) + PPC_STACK_RED_ZONE_SIZE) - #elif defined(PPC_MULTILIB_FPU) - #define PPC_EXC_FR_OFFSET(f) ((f) * 8 + PPC_EXC_GPR_OFFSET(33)) - #define PPC_EXC_FPSCR_OFFSET PPC_EXC_FR_OFFSET(32) - #define PPC_EXC_FRAME_SIZE PPC_EXC_FR_OFFSET(34) - #define PPC_EXC_MIN_FR_OFFSET(f) ((f) * 8 + PPC_EXC_GPR_OFFSET(13)) - #define PPC_EXC_MIN_FPSCR_OFFSET PPC_EXC_MIN_FR_OFFSET(14) - #define CPU_INTERRUPT_FRAME_SIZE \ - (PPC_EXC_MIN_FR_OFFSET(16) + PPC_STACK_RED_ZONE_SIZE) - #else - #define PPC_EXC_FRAME_SIZE PPC_EXC_GPR_OFFSET(33) - #define CPU_INTERRUPT_FRAME_SIZE \ - (PPC_EXC_GPR_OFFSET(13) + PPC_STACK_RED_ZONE_SIZE) - #endif -#else - #define PPC_EXC_SPEFSCR_OFFSET 44 - #define PPC_EXC_ACC_OFFSET 48 - #define PPC_EXC_GPR_OFFSET(gpr) ((gpr) * PPC_GPR_SIZE + 56) - #define PPC_EXC_GPR3_PROLOGUE_OFFSET (PPC_EXC_GPR_OFFSET(3) + 4) - #define CPU_INTERRUPT_FRAME_SIZE (160 + PPC_STACK_RED_ZONE_SIZE) - #define PPC_EXC_FRAME_SIZE 320 -#endif - -#define GPR0_OFFSET PPC_EXC_GPR_OFFSET(0) -#define GPR1_OFFSET PPC_EXC_GPR_OFFSET(1) -#define GPR2_OFFSET PPC_EXC_GPR_OFFSET(2) -#define GPR3_OFFSET PPC_EXC_GPR_OFFSET(3) -#define GPR4_OFFSET PPC_EXC_GPR_OFFSET(4) -#define GPR5_OFFSET PPC_EXC_GPR_OFFSET(5) -#define GPR6_OFFSET PPC_EXC_GPR_OFFSET(6) -#define GPR7_OFFSET PPC_EXC_GPR_OFFSET(7) -#define GPR8_OFFSET PPC_EXC_GPR_OFFSET(8) -#define GPR9_OFFSET PPC_EXC_GPR_OFFSET(9) -#define GPR10_OFFSET PPC_EXC_GPR_OFFSET(10) -#define GPR11_OFFSET PPC_EXC_GPR_OFFSET(11) -#define GPR12_OFFSET PPC_EXC_GPR_OFFSET(12) -#define GPR13_OFFSET PPC_EXC_GPR_OFFSET(13) -#define GPR14_OFFSET PPC_EXC_GPR_OFFSET(14) -#define GPR15_OFFSET PPC_EXC_GPR_OFFSET(15) -#define GPR16_OFFSET PPC_EXC_GPR_OFFSET(16) -#define GPR17_OFFSET PPC_EXC_GPR_OFFSET(17) -#define GPR18_OFFSET PPC_EXC_GPR_OFFSET(18) -#define GPR19_OFFSET PPC_EXC_GPR_OFFSET(19) -#define GPR20_OFFSET PPC_EXC_GPR_OFFSET(20) -#define GPR21_OFFSET PPC_EXC_GPR_OFFSET(21) -#define GPR22_OFFSET PPC_EXC_GPR_OFFSET(22) -#define GPR23_OFFSET PPC_EXC_GPR_OFFSET(23) -#define GPR24_OFFSET PPC_EXC_GPR_OFFSET(24) -#define GPR25_OFFSET PPC_EXC_GPR_OFFSET(25) -#define GPR26_OFFSET PPC_EXC_GPR_OFFSET(26) -#define GPR27_OFFSET PPC_EXC_GPR_OFFSET(27) -#define GPR28_OFFSET PPC_EXC_GPR_OFFSET(28) -#define GPR29_OFFSET PPC_EXC_GPR_OFFSET(29) -#define GPR30_OFFSET PPC_EXC_GPR_OFFSET(30) -#define GPR31_OFFSET PPC_EXC_GPR_OFFSET(31) - -#define CPU_PER_CPU_CONTROL_SIZE 0 - -#ifdef RTEMS_SMP - -/* Use SPRG0 for the per-CPU control of the current processor */ -#define PPC_PER_CPU_CONTROL_REGISTER 272 - -#endif /* RTEMS_SMP */ - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - uintptr_t FRAME_SP; - #ifdef __powerpc64__ - uint32_t FRAME_CR; - uint32_t FRAME_RESERVED; - #endif - uintptr_t FRAME_LR; - #ifdef __powerpc64__ - uintptr_t FRAME_TOC; - #endif - uintptr_t EXC_SRR0; - uintptr_t EXC_SRR1; - uint32_t RESERVED_FOR_ALIGNMENT_0; - uint32_t EXC_INTERRUPT_ENTRY_INSTANT; - uint32_t EXC_CR; - uint32_t EXC_XER; - uintptr_t EXC_CTR; - uintptr_t EXC_LR; - uintptr_t EXC_INTERRUPT_FRAME; - #ifdef __SPE__ - uint32_t EXC_SPEFSCR; - uint64_t EXC_ACC; - #endif - PPC_GPR_TYPE GPR0; - PPC_GPR_TYPE GPR1; - PPC_GPR_TYPE GPR2; - PPC_GPR_TYPE GPR3; - PPC_GPR_TYPE GPR4; - PPC_GPR_TYPE GPR5; - PPC_GPR_TYPE GPR6; - PPC_GPR_TYPE GPR7; - PPC_GPR_TYPE GPR8; - PPC_GPR_TYPE GPR9; - PPC_GPR_TYPE GPR10; - PPC_GPR_TYPE GPR11; - PPC_GPR_TYPE GPR12; - #ifdef PPC_MULTILIB_ALTIVEC - /* This field must take stvewx/lvewx requirements into account */ - uint32_t RESERVED_FOR_ALIGNMENT_3[3]; - uint32_t VSCR; - - uint8_t V0[16]; - uint8_t V1[16]; - uint8_t V2[16]; - uint8_t V3[16]; - uint8_t V4[16]; - uint8_t V5[16]; - uint8_t V6[16]; - uint8_t V7[16]; - uint8_t V8[16]; - uint8_t V9[16]; - uint8_t V10[16]; - uint8_t V11[16]; - uint8_t V12[16]; - uint8_t V13[16]; - uint8_t V14[16]; - uint8_t V15[16]; - uint8_t V16[16]; - uint8_t V17[16]; - uint8_t V18[16]; - uint8_t V19[16]; - #endif - #ifdef PPC_MULTILIB_FPU - double F0; - double F1; - double F2; - double F3; - double F4; - double F5; - double F6; - double F7; - double F8; - double F9; - double F10; - double F11; - double F12; - double F13; - uint64_t FPSCR; - uint64_t RESERVED_FOR_ALIGNMENT_4; - #endif - #if PPC_STACK_RED_ZONE_SIZE > 0 - uint8_t RED_ZONE[ PPC_STACK_RED_ZONE_SIZE ]; - #endif -} CPU_Interrupt_frame; - -#ifdef RTEMS_SMP - -static inline struct Per_CPU_Control *_PPC_Get_current_per_CPU_control( void ) -{ - struct Per_CPU_Control *cpu_self; - - __asm__ volatile ( - "mfspr %0, " RTEMS_XSTRING( PPC_PER_CPU_CONTROL_REGISTER ) - : "=r" ( cpu_self ) - ); - - return cpu_self; -} - -#define _CPU_Get_current_per_CPU_control() _PPC_Get_current_per_CPU_control() - -#endif /* RTEMS_SMP */ - -#ifdef __cplusplus -} -#endif - -#endif /* ASM */ - -#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/powerpc/rtems/score/powerpc.h b/cpukit/score/cpu/powerpc/rtems/score/powerpc.h deleted file mode 100644 index 88ee0020e6..0000000000 --- a/cpukit/score/cpu/powerpc/rtems/score/powerpc.h +++ /dev/null @@ -1,187 +0,0 @@ -/** - * @file - * - * @brief IBM/Motorola Power Pc Definitions - * - * This file contains definitions for the IBM/Motorola PowerPC - * family members. - */ - -/* - * Author: Andrew Bray - * - * COPYRIGHT (c) 1995 by i-cubed ltd. - * - * MPC860 support code was added by Jay Monkman - * MPC8260 support added by Andy Dachs - * Surrey Satellite Technology Limited - * - * To anyone who acknowledges that this file is provided "AS IS" - * without any express or implied warranty: - * permission to use, copy, modify, and distribute this file - * for any purpose is hereby granted without fee, provided that - * the above copyright notice and this notice appears in all - * copies, and that the name of i-cubed limited not be used in - * advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. - * i-cubed limited makes no representations about the suitability - * of this software for any purpose. - * - * Derived from c/src/exec/cpu/no_cpu/no_cpu.h: - * - * COPYRIGHT (c) 1989-1997. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may in - * the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - * - * - * Note: - * This file is included by both C and assembler code ( -DASM ) - */ - - -#ifndef _RTEMS_SCORE_POWERPC_H -#define _RTEMS_SCORE_POWERPC_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/* - * Define the name of the CPU family. - */ - -#define CPU_NAME "PowerPC" - -/* - * This file contains the information required to build - * RTEMS for the PowerPC family. - */ - -/* Generic ppc */ - -#ifdef _SOFT_FLOAT -#define CPU_MODEL_NAME "Generic (no FPU)" -#elif defined(__NO_FPRS__) || defined(__SPE__) -#define CPU_MODEL_NAME "Generic (E500/float-gprs/SPE)" -#else -#define CPU_MODEL_NAME "Generic (classic FPU)" -#endif - -#ifdef __PPC_CPU_E6500__ -#define PPC_DEFAULT_CACHE_LINE_POWER 6 -#else -#define PPC_DEFAULT_CACHE_LINE_POWER 5 -#endif - -#define PPC_DEFAULT_CACHE_LINE_SIZE (1 << PPC_DEFAULT_CACHE_LINE_POWER) - -#define PPC_STRUCTURE_ALIGNMENT PPC_DEFAULT_CACHE_LINE_SIZE - -/* - * Application binary interfaces. - * - * PPC_ABI MUST be defined as one of these. - * Only big endian is currently supported. - */ - -/* - * SVR4 ABI - */ -#define PPC_ABI_SVR4 2 -/* - * Embedded ABI - */ -#define PPC_ABI_EABI 3 - -/* - * Default to the EABI used by current GNU tools - */ - -#ifndef PPC_ABI -#define PPC_ABI PPC_ABI_EABI -#endif - -/* - * Use worst case stack alignment. For the EABI an 8-byte alignment would be - * sufficient. - */ - -#define PPC_STACK_ALIGN_POWER 4 -#define PPC_STACK_ALIGNMENT (1 << PPC_STACK_ALIGN_POWER) - -/* - * Assume PPC_HAS_FPU to be a synonym for _SOFT_FLOAT. - */ - -#if defined(_SOFT_FLOAT) \ - || defined(__NO_FPRS__) /* e500 has unified integer/FP registers */ \ - || defined(__PPC_CPU_E6500__) -#define PPC_HAS_FPU 0 -#else -#define PPC_HAS_FPU 1 -#endif - -#if defined(__PPC_CPU_E6500__) && defined(__ALTIVEC__) -#define PPC_MULTILIB_ALTIVEC -#endif - -#if defined(__PPC_CPU_E6500__) && !defined(_SOFT_FLOAT) -#define PPC_MULTILIB_FPU -#endif - -#ifdef PPC_MULTILIB_ALTIVEC -#define PPC_ALIGNMENT 16 -#else -#define PPC_ALIGNMENT 8 -#endif - -#ifdef __powerpc64__ -#define PPC_STACK_RED_ZONE_SIZE 512 -#else -#define PPC_STACK_RED_ZONE_SIZE 0 -#endif - -/* - * Unless specified above, If the model has FP support, it is assumed to - * support doubles (8-byte floating point numbers). - * - * If the model does NOT have FP support, then the model does - * NOT have double length FP registers. - */ - -#if (PPC_HAS_FPU) -#define PPC_HAS_DOUBLE 1 -#else -#define PPC_HAS_DOUBLE 0 -#endif - -/* - * Assemblers. - * PPC_ASM MUST be defined as one of these. - * - * PPC_ASM_ELF: ELF assembler. Currently used for all ABIs. - * - * NOTE: Only PPC_ABI_ELF is currently fully supported. - * - * Also NOTE: cpukit doesn't need this but asm.h which is defined - * in cpukit for consistency with other ports does. - */ - -#define PPC_ASM_ELF 0 - -/* - * Default to the assembler format used by the current GNU tools. - */ -#define PPC_ASM PPC_ASM_ELF - - -#ifdef __cplusplus -} -#endif - -#endif /* _RTEMS_SCORE_POWERPC_H */ diff --git a/cpukit/score/cpu/powerpc/rtems/score/types.h b/cpukit/score/cpu/powerpc/rtems/score/types.h deleted file mode 100644 index cdab30234d..0000000000 --- a/cpukit/score/cpu/powerpc/rtems/score/types.h +++ /dev/null @@ -1,62 +0,0 @@ -/** - * @file - * - * @brief PowerPC CPU Type Definitions - * - * This include file contains type definitions pertaining to the PowerPC - * processor family. - */ - -/* - * Author: Andrew Bray - * - * COPYRIGHT (c) 1995 by i-cubed ltd. - * - * To anyone who acknowledges that this file is provided "AS IS" - * without any express or implied warranty: - * permission to use, copy, modify, and distribute this file - * for any purpose is hereby granted without fee, provided that - * the above copyright notice and this notice appears in all - * copies, and that the name of i-cubed limited not be used in - * advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. - * i-cubed limited makes no representations about the suitability - * of this software for any purpose. - * - * Derived from c/src/exec/cpu/no_cpu/no_cputypes.h: - * - * COPYRIGHT (c) 1989-1997. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may in - * the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_TYPES_H -#define _RTEMS_SCORE_TYPES_H - -#include - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This section defines the basic types for this processor. - */ - -/** Type that can store a 32-bit integer or a pointer. */ -typedef uintptr_t CPU_Uint32ptr; - -typedef void ppc_isr; - -#ifdef __cplusplus -} -#endif - -#endif /* !ASM */ - -#endif diff --git a/cpukit/score/cpu/riscv/Makefile.am b/cpukit/score/cpu/riscv/Makefile.am index 1de5b2da42..3630c038a7 100644 --- a/cpukit/score/cpu/riscv/Makefile.am +++ b/cpukit/score/cpu/riscv/Makefile.am @@ -1,16 +1,4 @@ include $(top_srcdir)/automake/compile.am -include_rtemsdir = $(includedir)/rtems -include_rtems_HEADERS = rtems/asm.h - -include_rtems_scoredir = $(includedir)/rtems/score -include_rtems_score_HEADERS = rtems/score/cpu.h -include_rtems_score_HEADERS += rtems/score/cpuatomic.h -include_rtems_score_HEADERS += rtems/score/cpuimpl.h -include_rtems_score_HEADERS += rtems/score/cpu_asm.h -include_rtems_score_HEADERS += rtems/score/types.h -include_rtems_score_HEADERS += rtems/score/riscv.h -include_rtems_score_HEADERS += rtems/score/riscv-utility.h - noinst_LIBRARIES = libscorecpu.a libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS) libscorecpu_a_SOURCES = cpu.c @@ -22,5 +10,5 @@ libscorecpu_a_SOURCES += riscv-context-initialize.c libscorecpu_a_SOURCES += riscv-context-validate.S libscorecpu_a_SOURCES += riscv-context-volatile-clobber.S -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am +include $(srcdir)/headers.am diff --git a/cpukit/score/cpu/riscv/headers.am b/cpukit/score/cpu/riscv/headers.am new file mode 100644 index 0000000000..b5d3295c33 --- /dev/null +++ b/cpukit/score/cpu/riscv/headers.am @@ -0,0 +1,15 @@ +## This file was generated by "./boostrap -H". + +include_rtemsdir = $(includedir)/rtems +include_rtems_HEADERS = +include_rtems_HEADERS += include/rtems/asm.h + +include_rtems_scoredir = $(includedir)/rtems/score +include_rtems_score_HEADERS = +include_rtems_score_HEADERS += include/rtems/score/cpu.h +include_rtems_score_HEADERS += include/rtems/score/cpu_asm.h +include_rtems_score_HEADERS += include/rtems/score/cpuatomic.h +include_rtems_score_HEADERS += include/rtems/score/cpuimpl.h +include_rtems_score_HEADERS += include/rtems/score/riscv-utility.h +include_rtems_score_HEADERS += include/rtems/score/riscv.h +include_rtems_score_HEADERS += include/rtems/score/types.h diff --git a/cpukit/score/cpu/riscv/include/rtems/asm.h b/cpukit/score/cpu/riscv/include/rtems/asm.h new file mode 100644 index 0000000000..34b6474515 --- /dev/null +++ b/cpukit/score/cpu/riscv/include/rtems/asm.h @@ -0,0 +1,120 @@ +/** + * @file rtems/asm.h + * + * This include file attempts to address the problems + * caused by incompatible flavors of assemblers and + * toolsets. It primarily addresses variations in the + * use of leading underscores on symbols and the requirement + * that register names be preceded by a %. + */ + +/* + * NOTE: The spacing in the use of these macros + * is critical to them working as advertised. + * + * This file is based on similar code found in newlib available + * from ftp.cygnus.com. The file which was used had no copyright + * notice. This file is freely distributable as long as the source + * of the file is noted. This file is: + * + * Copyright (c) 2015 University of York. + * Hesham Almatary + * + * + * COPYRIGHT (c) 1994-1997. + * On-Line Applications Research Corporation (OAR). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef __RISCV_ASM_H +#define __RISCV_ASM_H + +/* + * Indicate we are in an assembly file and get the basic CPU definitions. + */ + +#ifndef ASM +#define ASM +#endif +#include +#include + +/* + * Recent versions of GNU cpp define variables which indicate the + * need for underscores and percents. If not using GNU cpp or + * the version does not support this, then you will obviously + * have to define these as appropriate. + */ + +#ifndef __USER_LABEL_PREFIX__ +#define __USER_LABEL_PREFIX__ _ +#endif + +#ifndef __REGISTER_PREFIX__ +#define __REGISTER_PREFIX__ +#endif + +/* ANSI concatenation macros. */ + +#define CONCAT1(a, b) CONCAT2(a, b) +#define CONCAT2(a, b) a ## b + +/* Use the right prefix for global labels. */ + +#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) + +/* Use the right prefix for registers. */ + +#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) + +/* + * define macros for all of the registers on this CPU + * + * EXAMPLE: #define d0 REG (d0) + */ + +/* + * Define macros to handle section beginning and ends. + */ +#define BEGIN_CODE_DCL .text +#define END_CODE_DCL +#define BEGIN_DATA_DCL .data +#define END_DATA_DCL +#define BEGIN_CODE .text +#define END_CODE +#define BEGIN_DATA +#define END_DATA +#define BEGIN_BSS +#define END_BSS +#define END + +/* + * Following must be tailor for a particular flavor of the C compiler. + * They may need to put underscores in front of the symbols. + */ + +#define PUBLIC(sym) .global SYM (sym) +#define EXTERN(sym) .extern SYM (sym) +#define TYPE_FUNC(sym) .type SYM (sym), %function + +#endif diff --git a/cpukit/score/cpu/riscv/include/rtems/score/cpu.h b/cpukit/score/cpu/riscv/include/rtems/score/cpu.h new file mode 100644 index 0000000000..3f8af862bf --- /dev/null +++ b/cpukit/score/cpu/riscv/include/rtems/score/cpu.h @@ -0,0 +1,604 @@ +/** + * @file rtems/score/cpu.h + */ + +/* + * + * Copyright (c) 2015 University of York. + * Hesham Almatary + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _RISCV_CPU_H +#define _RISCV_CPU_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include /* pick up machine definitions */ +#include +#include +#ifndef ASM +#include +#include +#include /* for printk */ +#endif + +#define CPU_INLINE_ENABLE_DISPATCH FALSE +#define CPU_UNROLL_ENQUEUE_PRIORITY TRUE +#define CPU_HAS_SOFTWARE_INTERRUPT_STACK TRUE +#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE +#define CPU_ALLOCATE_INTERRUPT_STACK TRUE +#define CPU_ISR_PASSES_FRAME_POINTER 1 +#define CPU_HARDWARE_FP FALSE +#define CPU_SOFTWARE_FP FALSE +#define CPU_ALL_TASKS_ARE_FP FALSE +#define CPU_IDLE_TASK_IS_FP FALSE +#define CPU_USE_DEFERRED_FP_SWITCH FALSE +#define CPU_PROVIDES_IDLE_THREAD_BODY TRUE +#define CPU_STACK_GROWS_UP FALSE + +#define CPU_STRUCTURE_ALIGNMENT __attribute__ ((aligned (64))) +#define CPU_HAS_OWN_HOST_TO_NETWORK_ROUTINES FALSE +#define CPU_BIG_ENDIAN FALSE +#define CPU_LITTLE_ENDIAN TRUE +#define CPU_MODES_INTERRUPT_MASK 0x0000000000000001 + +/* + * Processor defined structures required for cpukit/score. + */ + +#ifndef ASM + +typedef struct { + /* riscv has 32 xlen-bit (where xlen can be 32 or 64) general purpose registers (x0-x31)*/ + unsigned long x[32]; + + /* Special purpose registers */ + unsigned long mstatus; + unsigned long mcause; + unsigned long mepc; +#ifdef RTEMS_SMP + /** + * @brief On SMP configurations the thread context must contain a boolean + * indicator to signal if this context is executing on a processor. + * + * This field must be updated during a context switch. The context switch + * to the heir must wait until the heir context indicates that it is no + * longer executing on a processor. The context switch must also check if + * a thread dispatch is necessary to honor updates of the heir thread for + * this processor. This indicator must be updated using an atomic test and + * set operation to ensure that at most one processor uses the heir + * context at the same time. + * + * @code + * void _CPU_Context_switch( + * Context_Control *executing, + * Context_Control *heir + * ) + * { + * save( executing ); + * + * executing->is_executing = false; + * memory_barrier(); + * + * if ( test_and_set( &heir->is_executing ) ) { + * do { + * Per_CPU_Control *cpu_self = _Per_CPU_Get_snapshot(); + * + * if ( cpu_self->dispatch_necessary ) { + * heir = _Thread_Get_heir_and_make_it_executing( cpu_self ); + * } + * } while ( test_and_set( &heir->is_executing ) ); + * } + * + * restore( heir ); + * } + * @endcode + */ + volatile bool is_executing; +#endif +} Context_Control; + +#define _CPU_Context_Get_SP( _context ) \ + (_context)->x[2] + +typedef struct { + /** TODO FPU registers are listed here */ + double some_float_register; +} Context_Control_fp; + +typedef Context_Control CPU_Interrupt_frame; + +#define CPU_CONTEXT_FP_SIZE 0 +Context_Control_fp _CPU_Null_fp_context; + +#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0 +#if __riscv_xlen == 32 +#define CPU_STACK_MINIMUM_SIZE 4096 +#else +#define CPU_STACK_MINIMUM_SIZE 4096 * 2 +#endif +#define CPU_ALIGNMENT 8 +#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE +#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT +#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT +#define CPU_STACK_ALIGNMENT 8 +#define _CPU_Initialize_vectors() + +/* + * Disable all interrupts for an RTEMS critical section. The previous + * level is returned in _level. + * + */ + +static inline unsigned long riscv_interrupt_disable( void ) +{ + register unsigned long status = read_csr(mstatus); + clear_csr(mstatus, MSTATUS_MIE); + return status; +} + +static inline void riscv_interrupt_enable(unsigned long level) +{ + write_csr(mstatus, level); +} + +#define _CPU_ISR_Disable( _level ) \ + _level = riscv_interrupt_disable() + +#define _CPU_ISR_Enable( _level ) \ + riscv_interrupt_enable( _level ) + +#define _CPU_ISR_Flash( _level ) \ + do{ \ + _CPU_ISR_Enable( _level ); \ + riscv_interrupt_disable(); \ + } while(0) + +RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( unsigned long level ) +{ + return ( level & MSTATUS_MIE ) != 0; +} + +void _CPU_ISR_Set_level( unsigned long level ); + +unsigned long _CPU_ISR_Get_level( void ); + +/* end of ISR handler macros */ + +/* Context handler macros */ +#define RISCV_GCC_RED_ZONE_SIZE 128 + +void _CPU_Context_Initialize( + Context_Control *context, + void *stack_area_begin, + size_t stack_area_size, + unsigned long new_level, + void (*entry_point)( void ), + bool is_fp, + void *tls_area +); + +#define _CPU_Context_Restart_self( _the_context ) \ + _CPU_Context_restore( (_the_context) ) + + +#define _CPU_Context_Fp_start( _base, _offset ) \ + ( (void *) _Addresses_Add_offset( (_base), (_offset) ) ) + +#define _CPU_Context_Initialize_fp( _destination ) \ + { \ + *(*(_destination)) = _CPU_Null_fp_context; \ + } + +extern void _CPU_Fatal_halt(uint32_t source, uint32_t error) RTEMS_NO_RETURN; + +/* end of Fatal Error manager macros */ + +#define CPU_USE_GENERIC_BITFIELD_CODE TRUE +#define CPU_USE_GENERIC_BITFIELD_DATA TRUE + +#if (CPU_USE_GENERIC_BITFIELD_CODE == FALSE) + +#define _CPU_Bitfield_Find_first_bit( _value, _output ) \ + { \ + (_output) = 0; /* do something to prevent warnings */ \ + } +#endif + +/* end of Bitfield handler macros */ + +/* + * This routine builds the mask which corresponds to the bit fields + * as searched by _CPU_Bitfield_Find_first_bit(). See the discussion + * for that routine. + * + */ + +#if (CPU_USE_GENERIC_BITFIELD_CODE == FALSE) + +#define _CPU_Priority_Mask( _bit_number ) \ + (1 << _bit_number) + +#endif + +#if (CPU_USE_GENERIC_BITFIELD_CODE == FALSE) + +#define _CPU_Priority_bits_index( _priority ) \ + (_priority) + +#endif + +#define CPU_MAXIMUM_PROCESSORS 32 + +#define CPU_TIMESTAMP_USE_STRUCT_TIMESPEC FALSE +#define CPU_TIMESTAMP_USE_INT64 TRUE +#define CPU_TIMESTAMP_USE_INT64_INLINE FALSE + +typedef struct { + /* There is no CPU specific per-CPU state */ +} CPU_Per_CPU_control; +#endif /* ASM */ + +#if __riscv_xlen == 32 +#define CPU_SIZEOF_POINTER 4 + +/* 32-bit load/store instructions */ +#define LREG lw +#define SREG sw + +#define CPU_EXCEPTION_FRAME_SIZE 128 +#else /* xlen = 64 */ +#define CPU_SIZEOF_POINTER 8 + +/* 64-bit load/store instructions */ +#define LREG ld +#define SREG sd + +#define CPU_EXCEPTION_FRAME_SIZE 256 +#endif + +#define CPU_PER_CPU_CONTROL_SIZE 0 + +#ifndef ASM +typedef uint16_t Priority_bit_map_Word; + +typedef struct { + unsigned long x[32];; +} CPU_Exception_frame; + +/** + * @brief Prints the exception frame via printk(). + * + * @see rtems_fatal() and RTEMS_FATAL_SOURCE_EXCEPTION. + */ +void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); + + +/* end of Priority handler macros */ + +/* functions */ + +/* + * _CPU_Initialize + * + * This routine performs CPU dependent initialization. + * + */ + +void _CPU_Initialize( + void +); + +/* + * _CPU_ISR_install_raw_handler + * + * This routine installs a "raw" interrupt handler directly into the + * processor's vector table. + * + */ + +void _CPU_ISR_install_raw_handler( + uint32_t vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +/* + * _CPU_ISR_install_vector + * + * This routine installs an interrupt vector. + * + * NO_CPU Specific Information: + * + * XXX document implementation including references if appropriate + */ + +void _CPU_ISR_install_vector( + unsigned long vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +/* + * _CPU_Install_interrupt_stack + * + * This routine installs the hardware interrupt stack pointer. + * + * NOTE: It need only be provided if CPU_HAS_HARDWARE_INTERRUPT_STACK + * is TRUE. + * + */ + +void _CPU_Install_interrupt_stack( void ); + +/* + * _CPU_Thread_Idle_body + * + * This routine is the CPU dependent IDLE thread body. + * + * NOTE: It need only be provided if CPU_PROVIDES_IDLE_THREAD_BODY + * is TRUE. + * + */ + +void *_CPU_Thread_Idle_body( uintptr_t ignored ); + +/* + * _CPU_Context_switch + * + * This routine switches from the run context to the heir context. + * + * RISCV Specific Information: + * + * Please see the comments in the .c file for a description of how + * this function works. There are several things to be aware of. + */ + +void _CPU_Context_switch( + Context_Control *run, + Context_Control *heir +); + +/* + * _CPU_Context_restore + * + * This routine is generally used only to restart self in an + * efficient manner. It may simply be a label in _CPU_Context_switch. + * + * NOTE: May be unnecessary to reload some registers. + * + */ + +void _CPU_Context_restore( + Context_Control *new_context +) RTEMS_NO_RETURN; + +/* + * _CPU_Context_save_fp + * + * This routine saves the floating point context passed to it. + * + */ + +void _CPU_Context_save_fp( + void **fp_context_ptr +); + +/* + * _CPU_Context_restore_fp + * + * This routine restores the floating point context passed to it. + * + */ + +void _CPU_Context_restore_fp( + void **fp_context_ptr +); + +/* The following routine swaps the endian format of an unsigned int. + * It must be static because it is referenced indirectly. + * + * This version will work on any processor, but if there is a better + * way for your CPU PLEASE use it. The most common way to do this is to: + * + * swap least significant two bytes with 16-bit rotate + * swap upper and lower 16-bits + * swap most significant two bytes with 16-bit rotate + * + * Some CPUs have special instructions which swap a 32-bit quantity in + * a single instruction (e.g. i486). It is probably best to avoid + * an "endian swapping control bit" in the CPU. One good reason is + * that interrupts would probably have to be disabled to insure that + * an interrupt does not try to access the same "chunk" with the wrong + * endian. Another good reason is that on some CPUs, the endian bit + * endianness for ALL fetches -- both code and data -- so the code + * will be fetched incorrectly. + * + */ + +static inline uint32_t CPU_swap_u32( + uint32_t value +) +{ + uint32_t byte1, byte2, byte3, byte4, swapped; + + byte4 = (value >> 24) & 0xff; + byte3 = (value >> 16) & 0xff; + byte2 = (value >> 8) & 0xff; + byte1 = value & 0xff; + + swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4; + return ( swapped ); +} + +#define CPU_swap_u16( value ) \ + (((value&0xff) << 8) | ((value >> 8)&0xff)) + +static inline void _CPU_Context_volatile_clobber( uintptr_t pattern ) +{ + /* TODO */ +} + +static inline void _CPU_Context_validate( uintptr_t pattern ) +{ + while (1) { + /* TODO */ + } +} + +typedef uint32_t CPU_Counter_ticks; + +CPU_Counter_ticks _CPU_Counter_read( void ); + +#ifdef RTEMS_SMP +/** + * @brief Performs CPU specific SMP initialization in the context of the boot + * processor. + * + * This function is invoked on the boot processor during system + * initialization. All interrupt stacks are allocated at this point in case + * the CPU port allocates the interrupt stacks. This function is called + * before _CPU_SMP_Start_processor() or _CPU_SMP_Finalize_initialization() is + * used. + * + * @return The count of physically or virtually available processors. + * Depending on the configuration the application may use not all processors. + */ +uint32_t _CPU_SMP_Initialize( void ); + +/** + * @brief Starts a processor specified by its index. + * + * This function is invoked on the boot processor during system + * initialization. + * + * This function will be called after _CPU_SMP_Initialize(). + * + * @param[in] cpu_index The processor index. + * + * @retval true Successful operation. + * @retval false Unable to start this processor. + */ +bool _CPU_SMP_Start_processor( uint32_t cpu_index ); + +/** + * @brief Performs final steps of CPU specific SMP initialization in the + * context of the boot processor. + * + * This function is invoked on the boot processor during system + * initialization. + * + * This function will be called after all processors requested by the + * application have been started. + * + * @param[in] cpu_count The minimum value of the count of processors + * requested by the application configuration and the count of physically or + * virtually available processors. + */ +void _CPU_SMP_Finalize_initialization( uint32_t cpu_count ); + +/** + * @brief Returns the index of the current processor. + * + * An architecture specific method must be used to obtain the index of the + * current processor in the system. The set of processor indices is the + * range of integers starting with zero up to the processor count minus one. + */ +uint32_t _CPU_SMP_Get_current_processor( void ); + +/** + * @brief Sends an inter-processor interrupt to the specified target + * processor. + * + * This operation is undefined for target processor indices out of range. + * + * @param[in] target_processor_index The target processor index. + */ +void _CPU_SMP_Send_interrupt( uint32_t target_processor_index ); + +/** + * @brief Broadcasts a processor event. + * + * Some architectures provide a low-level synchronization primitive for + * processors in a multi-processor environment. Processors waiting for this + * event may go into a low-power state and stop generating system bus + * transactions. This function must ensure that preceding store operations + * can be observed by other processors. + * + * @see _CPU_SMP_Processor_event_receive(). + */ +void _CPU_SMP_Processor_event_broadcast( void ); + +/** + * @brief Receives a processor event. + * + * This function will wait for the processor event and may wait forever if no + * such event arrives. + * + * @see _CPU_SMP_Processor_event_broadcast(). + */ +static inline void _CPU_SMP_Processor_event_receive( void ) +{ + __asm__ volatile ( "" : : : "memory" ); +} + +/** + * @brief Gets the is executing indicator of the thread context. + * + * @param[in] context The context. + */ +static inline bool _CPU_Context_Get_is_executing( + const Context_Control *context +) +{ + return context->is_executing; +} + +/** + * @brief Sets the is executing indicator of the thread context. + * + * @param[in] context The context. + * @param[in] is_executing The new value for the is executing indicator. + */ +static inline void _CPU_Context_Set_is_executing( + Context_Control *context, + bool is_executing +) +{ + context->is_executing = is_executing; +} +#endif /* RTEMS_SMP */ + +#endif /* ASM */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/score/cpu/riscv/include/rtems/score/cpu_asm.h b/cpukit/score/cpu/riscv/include/rtems/score/cpu_asm.h new file mode 100644 index 0000000000..b5a56f3e22 --- /dev/null +++ b/cpukit/score/cpu/riscv/include/rtems/score/cpu_asm.h @@ -0,0 +1,90 @@ +/** + * @file + * + * @brief riscv32 Assembly File + * + * Very loose template for an include file for the cpu_asm.? file + * if it is implemented as a ".S" file (preprocessed by cpp) instead + * of a ".s" file (preprocessed by gm4 or gasp). + */ + +/* + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _RTEMS_SCORE_CPU_ASM_H +#define _RTEMS_SCORE_CPU_ASM_H + +/* pull in the generated offsets */ + +/* +#include +*/ + +/* + * Hardware General Registers + */ + +/* put something here */ + +/* + * Hardware Floating Point Registers + */ + +/* put something here */ + +/* + * Hardware Control Registers + */ + +/* put something here */ + +/* + * Calling Convention + */ + +/* put something here */ + +/* + * Temporary registers + */ + +/* put something here */ + +/* + * Floating Point Registers - SW Conventions + */ + +/* put something here */ + +/* + * Temporary floating point registers + */ + +/* put something here */ + +#endif + +/* end of file */ diff --git a/cpukit/score/cpu/riscv/include/rtems/score/cpuatomic.h b/cpukit/score/cpu/riscv/include/rtems/score/cpuatomic.h new file mode 100644 index 0000000000..8ee9606b44 --- /dev/null +++ b/cpukit/score/cpu/riscv/include/rtems/score/cpuatomic.h @@ -0,0 +1,31 @@ +/* + * COPYRIGHT (c) 2012-2013 Deng Hengyi. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _RTEMS_SCORE_ATOMIC_CPU_H +#define _RTEMS_SCORE_ATOMIC_CPU_H + +#include + +#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/riscv/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/riscv/include/rtems/score/cpuimpl.h new file mode 100644 index 0000000000..3904c84bf9 --- /dev/null +++ b/cpukit/score/cpu/riscv/include/rtems/score/cpuimpl.h @@ -0,0 +1,51 @@ +/** + * @file + * + * @brief CPU Port Implementation API + */ + +/* + * Copyright (c) 2013 embedded brains GmbH + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _RTEMS_SCORE_CPUIMPL_H +#define _RTEMS_SCORE_CPUIMPL_H + +#include + +#define CPU_PER_CPU_CONTROL_SIZE 0 + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ASM */ + +#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/riscv/include/rtems/score/riscv-utility.h b/cpukit/score/cpu/riscv/include/rtems/score/riscv-utility.h new file mode 100644 index 0000000000..dc4836bee2 --- /dev/null +++ b/cpukit/score/cpu/riscv/include/rtems/score/riscv-utility.h @@ -0,0 +1,1526 @@ +/* Copyright (c) 2013, The Regents of the University of California (Regents). + * All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Regents nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. + * + * IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, + * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST + * PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF + * REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO,THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED + * HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE + * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + */ + +/** + * @file + * + * @brief RISCV utility + */ +/* + * COPYRIGHT (c) 2015 Hesham Almatary + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +/* This file is copied from riscv-tools/encoding.h with additions/modifications to work + * with RTEMS. + */ +#ifndef _RTEMS_SCORE_RISCV_UTILITY_H +#define _RTEMS_SCORE_RISCV_UTILITY_H + +#define MSTATUS_UIE 0x00000001 +#define MSTATUS_SIE 0x00000002 +#define MSTATUS_HIE 0x00000004 +#define MSTATUS_MIE 0x00000008 +#define MSTATUS_UPIE 0x00000010 +#define MSTATUS_SPIE 0x00000020 +#define MSTATUS_HPIE 0x00000040 +#define MSTATUS_MPIE 0x00000080 +#define MSTATUS_SPP 0x00000100 +#define MSTATUS_HPP 0x00000600 +#define MSTATUS_MPP 0x00001800 +#define MSTATUS_FS 0x00006000 +#define MSTATUS_XS 0x00018000 +#define MSTATUS_MPRV 0x00020000 +#define MSTATUS_SUM 0x00040000 +#define MSTATUS_MXR 0x00080000 +#define MSTATUS_TVM 0x00100000 +#define MSTATUS_TW 0x00200000 +#define MSTATUS_TSR 0x00400000 +#define MSTATUS32_SD 0x80000000 +#define MSTATUS64_SD 0x8000000000000000 + +#define SSTATUS_UIE 0x00000001 +#define SSTATUS_SIE 0x00000002 +#define SSTATUS_UPIE 0x00000010 +#define SSTATUS_SPIE 0x00000020 +#define SSTATUS_SPP 0x00000100 +#define SSTATUS_FS 0x00006000 +#define SSTATUS_XS 0x00018000 +#define SSTATUS_SUM 0x00040000 +#define SSTATUS_MXR 0x00080000 +#define SSTATUS32_SD 0x80000000 +#define SSTATUS64_SD 0x8000000000000000 + +#define DCSR_XDEBUGVER (3U<<30) +#define DCSR_NDRESET (1<<29) +#define DCSR_FULLRESET (1<<28) +#define DCSR_EBREAKM (1<<15) +#define DCSR_EBREAKH (1<<14) +#define DCSR_EBREAKS (1<<13) +#define DCSR_EBREAKU (1<<12) +#define DCSR_STOPCYCLE (1<<10) +#define DCSR_STOPTIME (1<<9) +#define DCSR_CAUSE (7<<6) +#define DCSR_DEBUGINT (1<<5) +#define DCSR_HALT (1<<3) +#define DCSR_STEP (1<<2) +#define DCSR_PRV (3<<0) + +#define DCSR_CAUSE_NONE 0 +#define DCSR_CAUSE_SWBP 1 +#define DCSR_CAUSE_HWBP 2 +#define DCSR_CAUSE_DEBUGINT 3 +#define DCSR_CAUSE_STEP 4 +#define DCSR_CAUSE_HALT 5 + +#define MCONTROL_TYPE(xlen) (0xfULL<<((xlen)-4)) +#define MCONTROL_DMODE(xlen) (1ULL<<((xlen)-5)) +#define MCONTROL_MASKMAX(xlen) (0x3fULL<<((xlen)-11)) + +#define MCONTROL_SELECT (1<<19) +#define MCONTROL_TIMING (1<<18) +#define MCONTROL_ACTION (0x3f<<12) +#define MCONTROL_CHAIN (1<<11) +#define MCONTROL_MATCH (0xf<<7) +#define MCONTROL_M (1<<6) +#define MCONTROL_H (1<<5) +#define MCONTROL_S (1<<4) +#define MCONTROL_U (1<<3) +#define MCONTROL_EXECUTE (1<<2) +#define MCONTROL_STORE (1<<1) +#define MCONTROL_LOAD (1<<0) + +#define MCONTROL_TYPE_NONE 0 +#define MCONTROL_TYPE_MATCH 2 + +#define MCONTROL_ACTION_DEBUG_EXCEPTION 0 +#define MCONTROL_ACTION_DEBUG_MODE 1 +#define MCONTROL_ACTION_TRACE_START 2 +#define MCONTROL_ACTION_TRACE_STOP 3 +#define MCONTROL_ACTION_TRACE_EMIT 4 + +#define MCONTROL_MATCH_EQUAL 0 +#define MCONTROL_MATCH_NAPOT 1 +#define MCONTROL_MATCH_GE 2 +#define MCONTROL_MATCH_LT 3 +#define MCONTROL_MATCH_MASK_LOW 4 +#define MCONTROL_MATCH_MASK_HIGH 5 + +#define MIP_SSIP (1 << IRQ_S_SOFT) +#define MIP_HSIP (1 << IRQ_H_SOFT) +#define MIP_MSIP (1 << IRQ_M_SOFT) +#define MIP_STIP (1 << IRQ_S_TIMER) +#define MIP_HTIP (1 << IRQ_H_TIMER) +#define MIP_MTIP (1 << IRQ_M_TIMER) +#define MIP_SEIP (1 << IRQ_S_EXT) +#define MIP_HEIP (1 << IRQ_H_EXT) +#define MIP_MEIP (1 << IRQ_M_EXT) + +#define SIP_SSIP MIP_SSIP +#define SIP_STIP MIP_STIP + +#define PRV_U 0 +#define PRV_S 1 +#define PRV_H 2 +#define PRV_M 3 + +#define SPTBR32_MODE 0x80000000 +#define SPTBR32_ASID 0x7FC00000 +#define SPTBR32_PPN 0x003FFFFF +#define SPTBR64_MODE 0xF000000000000000 +#define SPTBR64_ASID 0x0FFFF00000000000 +#define SPTBR64_PPN 0x00000FFFFFFFFFFF + +#define SPTBR_MODE_OFF 0 +#define SPTBR_MODE_SV32 1 +#define SPTBR_MODE_SV39 8 +#define SPTBR_MODE_SV48 9 +#define SPTBR_MODE_SV57 10 +#define SPTBR_MODE_SV64 11 + +#define PMP_R 0x01 +#define PMP_W 0x02 +#define PMP_X 0x04 +#define PMP_A 0x18 +#define PMP_L 0x80 +#define PMP_SHIFT 2 + +#define PMP_TOR 0x08 +#define PMP_NA4 0x10 +#define PMP_NAPOT 0x18 + +#define IRQ_S_SOFT 1 +#define IRQ_H_SOFT 2 +#define IRQ_M_SOFT 3 +#define IRQ_S_TIMER 5 +#define IRQ_H_TIMER 6 +#define IRQ_M_TIMER 7 +#define IRQ_S_EXT 9 +#define IRQ_H_EXT 10 +#define IRQ_M_EXT 11 +#define IRQ_COP 12 +#define IRQ_HOST 13 + +#define DEFAULT_RSTVEC 0x00001000 +#define CLINT_BASE 0x02000000 +#define CLINT_SIZE 0x000c0000 +#define EXT_IO_BASE 0x40000000 +#define DRAM_BASE 0x80000000 + +// page table entry (PTE) fields +#define PTE_V 0x001 // Valid +#define PTE_R 0x002 // Read +#define PTE_W 0x004 // Write +#define PTE_X 0x008 // Execute +#define PTE_U 0x010 // User +#define PTE_G 0x020 // Global +#define PTE_A 0x040 // Accessed +#define PTE_D 0x080 // Dirty +#define PTE_SOFT 0x300 // Reserved for Software + +#define PTE_PPN_SHIFT 10 + +#define PTE_TABLE(PTE) (((PTE) & (PTE_V | PTE_R | PTE_W | PTE_X)) == PTE_V) + +#ifdef __riscv + +#if __riscv_xlen == 64 +# define MSTATUS_SD MSTATUS64_SD +# define SSTATUS_SD SSTATUS64_SD +# define RISCV_PGLEVEL_BITS 9 +# define SPTBR_MODE SPTBR64_MODE +#else +# define MSTATUS_SD MSTATUS32_SD +# define SSTATUS_SD SSTATUS32_SD +# define RISCV_PGLEVEL_BITS 10 +# define SPTBR_MODE SPTBR32_MODE +#endif +#define RISCV_PGSHIFT 12 +#define RISCV_PGSIZE (1 << RISCV_PGSHIFT) + +#ifndef __ASSEMBLER__ + +/** + * @brief Priv Mode registers definitions. + * + * @see RISC-V priv-spec 1.10. + */ +typedef enum { + RISCV_USER_INTERRUPT = 0, + RISCV_SUPERVISOR_SW_INTERRUPT = 1, + RISCV_MACHINE_SW_INTERRUPT = 3, + RISCV_USER_TIMER_INTERRUPT = 4, + RISCV_SUPERVISOR_TIMER_INTERRUPT = 4, + RISCV_MACHINE_TIMER_INTERRUPT = 7, + RISCV_USER_EXTERNAL_INTERRUPT = 8, + RISCV_SUPERVISOR_EXTERNAL_INTERRUPT = 9, + RISCV_MACHINE_EXTERNAL_INTERRUPT = 11 +} RISCV_Symbolic_interrupt_name; + +#ifdef __GNUC__ + +#define read_csr(reg) ({ unsigned long __tmp; \ + asm volatile ("csrr %0, " #reg : "=r"(__tmp)); \ + __tmp; }) + +#define write_csr(reg, val) ({ \ + asm volatile ("csrw " #reg ", %0" :: "rK"(val)); }) + +#define swap_csr(reg, val) ({ unsigned long __tmp; \ + asm volatile ("csrrw %0, " #reg ", %1" : "=r"(__tmp) : "rK"(val)); \ + __tmp; }) + +#define set_csr(reg, bit) ({ unsigned long __tmp; \ + asm volatile ("csrrs %0, " #reg ", %1" : "=r"(__tmp) : "rK"(bit)); \ + __tmp; }) + +#define clear_csr(reg, bit) ({ unsigned long __tmp; \ + asm volatile ("csrrc %0, " #reg ", %1" : "=r"(__tmp) : "rK"(bit)); \ + __tmp; }) + +#define rdtime() read_csr(time) +#define rdcycle() read_csr(cycle) +#define rdinstret() read_csr(instret) + +#endif + +#endif + +#endif + +#endif +/* Automatically generated by parse-opcodes. */ +#ifndef RISCV_ENCODING_H +#define RISCV_ENCODING_H +#define MATCH_BEQ 0x63 +#define MASK_BEQ 0x707f +#define MATCH_BNE 0x1063 +#define MASK_BNE 0x707f +#define MATCH_BLT 0x4063 +#define MASK_BLT 0x707f +#define MATCH_BGE 0x5063 +#define MASK_BGE 0x707f +#define MATCH_BLTU 0x6063 +#define MASK_BLTU 0x707f +#define MATCH_BGEU 0x7063 +#define MASK_BGEU 0x707f +#define MATCH_JALR 0x67 +#define MASK_JALR 0x707f +#define MATCH_JAL 0x6f +#define MASK_JAL 0x7f +#define MATCH_LUI 0x37 +#define MASK_LUI 0x7f +#define MATCH_AUIPC 0x17 +#define MASK_AUIPC 0x7f +#define MATCH_ADDI 0x13 +#define MASK_ADDI 0x707f +#define MATCH_SLLI 0x1013 +#define MASK_SLLI 0xfc00707f +#define MATCH_SLTI 0x2013 +#define MASK_SLTI 0x707f +#define MATCH_SLTIU 0x3013 +#define MASK_SLTIU 0x707f +#define MATCH_XORI 0x4013 +#define MASK_XORI 0x707f +#define MATCH_SRLI 0x5013 +#define MASK_SRLI 0xfc00707f +#define MATCH_SRAI 0x40005013 +#define MASK_SRAI 0xfc00707f +#define MATCH_ORI 0x6013 +#define MASK_ORI 0x707f +#define MATCH_ANDI 0x7013 +#define MASK_ANDI 0x707f +#define MATCH_ADD 0x33 +#define MASK_ADD 0xfe00707f +#define MATCH_SUB 0x40000033 +#define MASK_SUB 0xfe00707f +#define MATCH_SLL 0x1033 +#define MASK_SLL 0xfe00707f +#define MATCH_SLT 0x2033 +#define MASK_SLT 0xfe00707f +#define MATCH_SLTU 0x3033 +#define MASK_SLTU 0xfe00707f +#define MATCH_XOR 0x4033 +#define MASK_XOR 0xfe00707f +#define MATCH_SRL 0x5033 +#define MASK_SRL 0xfe00707f +#define MATCH_SRA 0x40005033 +#define MASK_SRA 0xfe00707f +#define MATCH_OR 0x6033 +#define MASK_OR 0xfe00707f +#define MATCH_AND 0x7033 +#define MASK_AND 0xfe00707f +#define MATCH_ADDIW 0x1b +#define MASK_ADDIW 0x707f +#define MATCH_SLLIW 0x101b +#define MASK_SLLIW 0xfe00707f +#define MATCH_SRLIW 0x501b +#define MASK_SRLIW 0xfe00707f +#define MATCH_SRAIW 0x4000501b +#define MASK_SRAIW 0xfe00707f +#define MATCH_ADDW 0x3b +#define MASK_ADDW 0xfe00707f +#define MATCH_SUBW 0x4000003b +#define MASK_SUBW 0xfe00707f +#define MATCH_SLLW 0x103b +#define MASK_SLLW 0xfe00707f +#define MATCH_SRLW 0x503b +#define MASK_SRLW 0xfe00707f +#define MATCH_SRAW 0x4000503b +#define MASK_SRAW 0xfe00707f +#define MATCH_LB 0x3 +#define MASK_LB 0x707f +#define MATCH_LH 0x1003 +#define MASK_LH 0x707f +#define MATCH_LW 0x2003 +#define MASK_LW 0x707f +#define MATCH_LD 0x3003 +#define MASK_LD 0x707f +#define MATCH_LBU 0x4003 +#define MASK_LBU 0x707f +#define MATCH_LHU 0x5003 +#define MASK_LHU 0x707f +#define MATCH_LWU 0x6003 +#define MASK_LWU 0x707f +#define MATCH_SB 0x23 +#define MASK_SB 0x707f +#define MATCH_SH 0x1023 +#define MASK_SH 0x707f +#define MATCH_SW 0x2023 +#define MASK_SW 0x707f +#define MATCH_SD 0x3023 +#define MASK_SD 0x707f +#define MATCH_FENCE 0xf +#define MASK_FENCE 0x707f +#define MATCH_FENCE_I 0x100f +#define MASK_FENCE_I 0x707f +#define MATCH_MUL 0x2000033 +#define MASK_MUL 0xfe00707f +#define MATCH_MULH 0x2001033 +#define MASK_MULH 0xfe00707f +#define MATCH_MULHSU 0x2002033 +#define MASK_MULHSU 0xfe00707f +#define MATCH_MULHU 0x2003033 +#define MASK_MULHU 0xfe00707f +#define MATCH_DIV 0x2004033 +#define MASK_DIV 0xfe00707f +#define MATCH_DIVU 0x2005033 +#define MASK_DIVU 0xfe00707f +#define MATCH_REM 0x2006033 +#define MASK_REM 0xfe00707f +#define MATCH_REMU 0x2007033 +#define MASK_REMU 0xfe00707f +#define MATCH_MULW 0x200003b +#define MASK_MULW 0xfe00707f +#define MATCH_DIVW 0x200403b +#define MASK_DIVW 0xfe00707f +#define MATCH_DIVUW 0x200503b +#define MASK_DIVUW 0xfe00707f +#define MATCH_REMW 0x200603b +#define MASK_REMW 0xfe00707f +#define MATCH_REMUW 0x200703b +#define MASK_REMUW 0xfe00707f +#define MATCH_AMOADD_W 0x202f +#define MASK_AMOADD_W 0xf800707f +#define MATCH_AMOXOR_W 0x2000202f +#define MASK_AMOXOR_W 0xf800707f +#define MATCH_AMOOR_W 0x4000202f +#define MASK_AMOOR_W 0xf800707f +#define MATCH_AMOAND_W 0x6000202f +#define MASK_AMOAND_W 0xf800707f +#define MATCH_AMOMIN_W 0x8000202f +#define MASK_AMOMIN_W 0xf800707f +#define MATCH_AMOMAX_W 0xa000202f +#define MASK_AMOMAX_W 0xf800707f +#define MATCH_AMOMINU_W 0xc000202f +#define MASK_AMOMINU_W 0xf800707f +#define MATCH_AMOMAXU_W 0xe000202f +#define MASK_AMOMAXU_W 0xf800707f +#define MATCH_AMOSWAP_W 0x800202f +#define MASK_AMOSWAP_W 0xf800707f +#define MATCH_LR_W 0x1000202f +#define MASK_LR_W 0xf9f0707f +#define MATCH_SC_W 0x1800202f +#define MASK_SC_W 0xf800707f +#define MATCH_AMOADD_D 0x302f +#define MASK_AMOADD_D 0xf800707f +#define MATCH_AMOXOR_D 0x2000302f +#define MASK_AMOXOR_D 0xf800707f +#define MATCH_AMOOR_D 0x4000302f +#define MASK_AMOOR_D 0xf800707f +#define MATCH_AMOAND_D 0x6000302f +#define MASK_AMOAND_D 0xf800707f +#define MATCH_AMOMIN_D 0x8000302f +#define MASK_AMOMIN_D 0xf800707f +#define MATCH_AMOMAX_D 0xa000302f +#define MASK_AMOMAX_D 0xf800707f +#define MATCH_AMOMINU_D 0xc000302f +#define MASK_AMOMINU_D 0xf800707f +#define MATCH_AMOMAXU_D 0xe000302f +#define MASK_AMOMAXU_D 0xf800707f +#define MATCH_AMOSWAP_D 0x800302f +#define MASK_AMOSWAP_D 0xf800707f +#define MATCH_LR_D 0x1000302f +#define MASK_LR_D 0xf9f0707f +#define MATCH_SC_D 0x1800302f +#define MASK_SC_D 0xf800707f +#define MATCH_ECALL 0x73 +#define MASK_ECALL 0xffffffff +#define MATCH_EBREAK 0x100073 +#define MASK_EBREAK 0xffffffff +#define MATCH_URET 0x200073 +#define MASK_URET 0xffffffff +#define MATCH_SRET 0x10200073 +#define MASK_SRET 0xffffffff +#define MATCH_MRET 0x30200073 +#define MASK_MRET 0xffffffff +#define MATCH_DRET 0x7b200073 +#define MASK_DRET 0xffffffff +#define MATCH_SFENCE_VMA 0x12000073 +#define MASK_SFENCE_VMA 0xfe007fff +#define MATCH_WFI 0x10500073 +#define MASK_WFI 0xffffffff +#define MATCH_CSRRW 0x1073 +#define MASK_CSRRW 0x707f +#define MATCH_CSRRS 0x2073 +#define MASK_CSRRS 0x707f +#define MATCH_CSRRC 0x3073 +#define MASK_CSRRC 0x707f +#define MATCH_CSRRWI 0x5073 +#define MASK_CSRRWI 0x707f +#define MATCH_CSRRSI 0x6073 +#define MASK_CSRRSI 0x707f +#define MATCH_CSRRCI 0x7073 +#define MASK_CSRRCI 0x707f +#define MATCH_FADD_S 0x53 +#define MASK_FADD_S 0xfe00007f +#define MATCH_FSUB_S 0x8000053 +#define MASK_FSUB_S 0xfe00007f +#define MATCH_FMUL_S 0x10000053 +#define MASK_FMUL_S 0xfe00007f +#define MATCH_FDIV_S 0x18000053 +#define MASK_FDIV_S 0xfe00007f +#define MATCH_FSGNJ_S 0x20000053 +#define MASK_FSGNJ_S 0xfe00707f +#define MATCH_FSGNJN_S 0x20001053 +#define MASK_FSGNJN_S 0xfe00707f +#define MATCH_FSGNJX_S 0x20002053 +#define MASK_FSGNJX_S 0xfe00707f +#define MATCH_FMIN_S 0x28000053 +#define MASK_FMIN_S 0xfe00707f +#define MATCH_FMAX_S 0x28001053 +#define MASK_FMAX_S 0xfe00707f +#define MATCH_FSQRT_S 0x58000053 +#define MASK_FSQRT_S 0xfff0007f +#define MATCH_FADD_D 0x2000053 +#define MASK_FADD_D 0xfe00007f +#define MATCH_FSUB_D 0xa000053 +#define MASK_FSUB_D 0xfe00007f +#define MATCH_FMUL_D 0x12000053 +#define MASK_FMUL_D 0xfe00007f +#define MATCH_FDIV_D 0x1a000053 +#define MASK_FDIV_D 0xfe00007f +#define MATCH_FSGNJ_D 0x22000053 +#define MASK_FSGNJ_D 0xfe00707f +#define MATCH_FSGNJN_D 0x22001053 +#define MASK_FSGNJN_D 0xfe00707f +#define MATCH_FSGNJX_D 0x22002053 +#define MASK_FSGNJX_D 0xfe00707f +#define MATCH_FMIN_D 0x2a000053 +#define MASK_FMIN_D 0xfe00707f +#define MATCH_FMAX_D 0x2a001053 +#define MASK_FMAX_D 0xfe00707f +#define MATCH_FCVT_S_D 0x40100053 +#define MASK_FCVT_S_D 0xfff0007f +#define MATCH_FCVT_D_S 0x42000053 +#define MASK_FCVT_D_S 0xfff0007f +#define MATCH_FSQRT_D 0x5a000053 +#define MASK_FSQRT_D 0xfff0007f +#define MATCH_FADD_Q 0x6000053 +#define MASK_FADD_Q 0xfe00007f +#define MATCH_FSUB_Q 0xe000053 +#define MASK_FSUB_Q 0xfe00007f +#define MATCH_FMUL_Q 0x16000053 +#define MASK_FMUL_Q 0xfe00007f +#define MATCH_FDIV_Q 0x1e000053 +#define MASK_FDIV_Q 0xfe00007f +#define MATCH_FSGNJ_Q 0x26000053 +#define MASK_FSGNJ_Q 0xfe00707f +#define MATCH_FSGNJN_Q 0x26001053 +#define MASK_FSGNJN_Q 0xfe00707f +#define MATCH_FSGNJX_Q 0x26002053 +#define MASK_FSGNJX_Q 0xfe00707f +#define MATCH_FMIN_Q 0x2e000053 +#define MASK_FMIN_Q 0xfe00707f +#define MATCH_FMAX_Q 0x2e001053 +#define MASK_FMAX_Q 0xfe00707f +#define MATCH_FCVT_S_Q 0x40300053 +#define MASK_FCVT_S_Q 0xfff0007f +#define MATCH_FCVT_Q_S 0x46000053 +#define MASK_FCVT_Q_S 0xfff0007f +#define MATCH_FCVT_D_Q 0x42300053 +#define MASK_FCVT_D_Q 0xfff0007f +#define MATCH_FCVT_Q_D 0x46100053 +#define MASK_FCVT_Q_D 0xfff0007f +#define MATCH_FSQRT_Q 0x5e000053 +#define MASK_FSQRT_Q 0xfff0007f +#define MATCH_FLE_S 0xa0000053 +#define MASK_FLE_S 0xfe00707f +#define MATCH_FLT_S 0xa0001053 +#define MASK_FLT_S 0xfe00707f +#define MATCH_FEQ_S 0xa0002053 +#define MASK_FEQ_S 0xfe00707f +#define MATCH_FLE_D 0xa2000053 +#define MASK_FLE_D 0xfe00707f +#define MATCH_FLT_D 0xa2001053 +#define MASK_FLT_D 0xfe00707f +#define MATCH_FEQ_D 0xa2002053 +#define MASK_FEQ_D 0xfe00707f +#define MATCH_FLE_Q 0xa6000053 +#define MASK_FLE_Q 0xfe00707f +#define MATCH_FLT_Q 0xa6001053 +#define MASK_FLT_Q 0xfe00707f +#define MATCH_FEQ_Q 0xa6002053 +#define MASK_FEQ_Q 0xfe00707f +#define MATCH_FCVT_W_S 0xc0000053 +#define MASK_FCVT_W_S 0xfff0007f +#define MATCH_FCVT_WU_S 0xc0100053 +#define MASK_FCVT_WU_S 0xfff0007f +#define MATCH_FCVT_L_S 0xc0200053 +#define MASK_FCVT_L_S 0xfff0007f +#define MATCH_FCVT_LU_S 0xc0300053 +#define MASK_FCVT_LU_S 0xfff0007f +#define MATCH_FMV_X_W 0xe0000053 +#define MASK_FMV_X_W 0xfff0707f +#define MATCH_FCLASS_S 0xe0001053 +#define MASK_FCLASS_S 0xfff0707f +#define MATCH_FCVT_W_D 0xc2000053 +#define MASK_FCVT_W_D 0xfff0007f +#define MATCH_FCVT_WU_D 0xc2100053 +#define MASK_FCVT_WU_D 0xfff0007f +#define MATCH_FCVT_L_D 0xc2200053 +#define MASK_FCVT_L_D 0xfff0007f +#define MATCH_FCVT_LU_D 0xc2300053 +#define MASK_FCVT_LU_D 0xfff0007f +#define MATCH_FMV_X_D 0xe2000053 +#define MASK_FMV_X_D 0xfff0707f +#define MATCH_FCLASS_D 0xe2001053 +#define MASK_FCLASS_D 0xfff0707f +#define MATCH_FCVT_W_Q 0xc6000053 +#define MASK_FCVT_W_Q 0xfff0007f +#define MATCH_FCVT_WU_Q 0xc6100053 +#define MASK_FCVT_WU_Q 0xfff0007f +#define MATCH_FCVT_L_Q 0xc6200053 +#define MASK_FCVT_L_Q 0xfff0007f +#define MATCH_FCVT_LU_Q 0xc6300053 +#define MASK_FCVT_LU_Q 0xfff0007f +#define MATCH_FMV_X_Q 0xe6000053 +#define MASK_FMV_X_Q 0xfff0707f +#define MATCH_FCLASS_Q 0xe6001053 +#define MASK_FCLASS_Q 0xfff0707f +#define MATCH_FCVT_S_W 0xd0000053 +#define MASK_FCVT_S_W 0xfff0007f +#define MATCH_FCVT_S_WU 0xd0100053 +#define MASK_FCVT_S_WU 0xfff0007f +#define MATCH_FCVT_S_L 0xd0200053 +#define MASK_FCVT_S_L 0xfff0007f +#define MATCH_FCVT_S_LU 0xd0300053 +#define MASK_FCVT_S_LU 0xfff0007f +#define MATCH_FMV_W_X 0xf0000053 +#define MASK_FMV_W_X 0xfff0707f +#define MATCH_FCVT_D_W 0xd2000053 +#define MASK_FCVT_D_W 0xfff0007f +#define MATCH_FCVT_D_WU 0xd2100053 +#define MASK_FCVT_D_WU 0xfff0007f +#define MATCH_FCVT_D_L 0xd2200053 +#define MASK_FCVT_D_L 0xfff0007f +#define MATCH_FCVT_D_LU 0xd2300053 +#define MASK_FCVT_D_LU 0xfff0007f +#define MATCH_FMV_D_X 0xf2000053 +#define MASK_FMV_D_X 0xfff0707f +#define MATCH_FCVT_Q_W 0xd6000053 +#define MASK_FCVT_Q_W 0xfff0007f +#define MATCH_FCVT_Q_WU 0xd6100053 +#define MASK_FCVT_Q_WU 0xfff0007f +#define MATCH_FCVT_Q_L 0xd6200053 +#define MASK_FCVT_Q_L 0xfff0007f +#define MATCH_FCVT_Q_LU 0xd6300053 +#define MASK_FCVT_Q_LU 0xfff0007f +#define MATCH_FMV_Q_X 0xf6000053 +#define MASK_FMV_Q_X 0xfff0707f +#define MATCH_FLW 0x2007 +#define MASK_FLW 0x707f +#define MATCH_FLD 0x3007 +#define MASK_FLD 0x707f +#define MATCH_FLQ 0x4007 +#define MASK_FLQ 0x707f +#define MATCH_FSW 0x2027 +#define MASK_FSW 0x707f +#define MATCH_FSD 0x3027 +#define MASK_FSD 0x707f +#define MATCH_FSQ 0x4027 +#define MASK_FSQ 0x707f +#define MATCH_FMADD_S 0x43 +#define MASK_FMADD_S 0x600007f +#define MATCH_FMSUB_S 0x47 +#define MASK_FMSUB_S 0x600007f +#define MATCH_FNMSUB_S 0x4b +#define MASK_FNMSUB_S 0x600007f +#define MATCH_FNMADD_S 0x4f +#define MASK_FNMADD_S 0x600007f +#define MATCH_FMADD_D 0x2000043 +#define MASK_FMADD_D 0x600007f +#define MATCH_FMSUB_D 0x2000047 +#define MASK_FMSUB_D 0x600007f +#define MATCH_FNMSUB_D 0x200004b +#define MASK_FNMSUB_D 0x600007f +#define MATCH_FNMADD_D 0x200004f +#define MASK_FNMADD_D 0x600007f +#define MATCH_FMADD_Q 0x6000043 +#define MASK_FMADD_Q 0x600007f +#define MATCH_FMSUB_Q 0x6000047 +#define MASK_FMSUB_Q 0x600007f +#define MATCH_FNMSUB_Q 0x600004b +#define MASK_FNMSUB_Q 0x600007f +#define MATCH_FNMADD_Q 0x600004f +#define MASK_FNMADD_Q 0x600007f +#define MATCH_C_NOP 0x1 +#define MASK_C_NOP 0xffff +#define MATCH_C_ADDI16SP 0x6101 +#define MASK_C_ADDI16SP 0xef83 +#define MATCH_C_JR 0x8002 +#define MASK_C_JR 0xf07f +#define MATCH_C_JALR 0x9002 +#define MASK_C_JALR 0xf07f +#define MATCH_C_EBREAK 0x9002 +#define MASK_C_EBREAK 0xffff +#define MATCH_C_LD 0x6000 +#define MASK_C_LD 0xe003 +#define MATCH_C_SD 0xe000 +#define MASK_C_SD 0xe003 +#define MATCH_C_ADDIW 0x2001 +#define MASK_C_ADDIW 0xe003 +#define MATCH_C_LDSP 0x6002 +#define MASK_C_LDSP 0xe003 +#define MATCH_C_SDSP 0xe002 +#define MASK_C_SDSP 0xe003 +#define MATCH_C_ADDI4SPN 0x0 +#define MASK_C_ADDI4SPN 0xe003 +#define MATCH_C_FLD 0x2000 +#define MASK_C_FLD 0xe003 +#define MATCH_C_LW 0x4000 +#define MASK_C_LW 0xe003 +#define MATCH_C_FLW 0x6000 +#define MASK_C_FLW 0xe003 +#define MATCH_C_FSD 0xa000 +#define MASK_C_FSD 0xe003 +#define MATCH_C_SW 0xc000 +#define MASK_C_SW 0xe003 +#define MATCH_C_FSW 0xe000 +#define MASK_C_FSW 0xe003 +#define MATCH_C_ADDI 0x1 +#define MASK_C_ADDI 0xe003 +#define MATCH_C_JAL 0x2001 +#define MASK_C_JAL 0xe003 +#define MATCH_C_LI 0x4001 +#define MASK_C_LI 0xe003 +#define MATCH_C_LUI 0x6001 +#define MASK_C_LUI 0xe003 +#define MATCH_C_SRLI 0x8001 +#define MASK_C_SRLI 0xec03 +#define MATCH_C_SRAI 0x8401 +#define MASK_C_SRAI 0xec03 +#define MATCH_C_ANDI 0x8801 +#define MASK_C_ANDI 0xec03 +#define MATCH_C_SUB 0x8c01 +#define MASK_C_SUB 0xfc63 +#define MATCH_C_XOR 0x8c21 +#define MASK_C_XOR 0xfc63 +#define MATCH_C_OR 0x8c41 +#define MASK_C_OR 0xfc63 +#define MATCH_C_AND 0x8c61 +#define MASK_C_AND 0xfc63 +#define MATCH_C_SUBW 0x9c01 +#define MASK_C_SUBW 0xfc63 +#define MATCH_C_ADDW 0x9c21 +#define MASK_C_ADDW 0xfc63 +#define MATCH_C_J 0xa001 +#define MASK_C_J 0xe003 +#define MATCH_C_BEQZ 0xc001 +#define MASK_C_BEQZ 0xe003 +#define MATCH_C_BNEZ 0xe001 +#define MASK_C_BNEZ 0xe003 +#define MATCH_C_SLLI 0x2 +#define MASK_C_SLLI 0xe003 +#define MATCH_C_FLDSP 0x2002 +#define MASK_C_FLDSP 0xe003 +#define MATCH_C_LWSP 0x4002 +#define MASK_C_LWSP 0xe003 +#define MATCH_C_FLWSP 0x6002 +#define MASK_C_FLWSP 0xe003 +#define MATCH_C_MV 0x8002 +#define MASK_C_MV 0xf003 +#define MATCH_C_ADD 0x9002 +#define MASK_C_ADD 0xf003 +#define MATCH_C_FSDSP 0xa002 +#define MASK_C_FSDSP 0xe003 +#define MATCH_C_SWSP 0xc002 +#define MASK_C_SWSP 0xe003 +#define MATCH_C_FSWSP 0xe002 +#define MASK_C_FSWSP 0xe003 +#define MATCH_CUSTOM0 0xb +#define MASK_CUSTOM0 0x707f +#define MATCH_CUSTOM0_RS1 0x200b +#define MASK_CUSTOM0_RS1 0x707f +#define MATCH_CUSTOM0_RS1_RS2 0x300b +#define MASK_CUSTOM0_RS1_RS2 0x707f +#define MATCH_CUSTOM0_RD 0x400b +#define MASK_CUSTOM0_RD 0x707f +#define MATCH_CUSTOM0_RD_RS1 0x600b +#define MASK_CUSTOM0_RD_RS1 0x707f +#define MATCH_CUSTOM0_RD_RS1_RS2 0x700b +#define MASK_CUSTOM0_RD_RS1_RS2 0x707f +#define MATCH_CUSTOM1 0x2b +#define MASK_CUSTOM1 0x707f +#define MATCH_CUSTOM1_RS1 0x202b +#define MASK_CUSTOM1_RS1 0x707f +#define MATCH_CUSTOM1_RS1_RS2 0x302b +#define MASK_CUSTOM1_RS1_RS2 0x707f +#define MATCH_CUSTOM1_RD 0x402b +#define MASK_CUSTOM1_RD 0x707f +#define MATCH_CUSTOM1_RD_RS1 0x602b +#define MASK_CUSTOM1_RD_RS1 0x707f +#define MATCH_CUSTOM1_RD_RS1_RS2 0x702b +#define MASK_CUSTOM1_RD_RS1_RS2 0x707f +#define MATCH_CUSTOM2 0x5b +#define MASK_CUSTOM2 0x707f +#define MATCH_CUSTOM2_RS1 0x205b +#define MASK_CUSTOM2_RS1 0x707f +#define MATCH_CUSTOM2_RS1_RS2 0x305b +#define MASK_CUSTOM2_RS1_RS2 0x707f +#define MATCH_CUSTOM2_RD 0x405b +#define MASK_CUSTOM2_RD 0x707f +#define MATCH_CUSTOM2_RD_RS1 0x605b +#define MASK_CUSTOM2_RD_RS1 0x707f +#define MATCH_CUSTOM2_RD_RS1_RS2 0x705b +#define MASK_CUSTOM2_RD_RS1_RS2 0x707f +#define MATCH_CUSTOM3 0x7b +#define MASK_CUSTOM3 0x707f +#define MATCH_CUSTOM3_RS1 0x207b +#define MASK_CUSTOM3_RS1 0x707f +#define MATCH_CUSTOM3_RS1_RS2 0x307b +#define MASK_CUSTOM3_RS1_RS2 0x707f +#define MATCH_CUSTOM3_RD 0x407b +#define MASK_CUSTOM3_RD 0x707f +#define MATCH_CUSTOM3_RD_RS1 0x607b +#define MASK_CUSTOM3_RD_RS1 0x707f +#define MATCH_CUSTOM3_RD_RS1_RS2 0x707b +#define MASK_CUSTOM3_RD_RS1_RS2 0x707f +#define CSR_FFLAGS 0x1 +#define CSR_FRM 0x2 +#define CSR_FCSR 0x3 +#define CSR_CYCLE 0xc00 +#define CSR_TIME 0xc01 +#define CSR_INSTRET 0xc02 +#define CSR_HPMCOUNTER3 0xc03 +#define CSR_HPMCOUNTER4 0xc04 +#define CSR_HPMCOUNTER5 0xc05 +#define CSR_HPMCOUNTER6 0xc06 +#define CSR_HPMCOUNTER7 0xc07 +#define CSR_HPMCOUNTER8 0xc08 +#define CSR_HPMCOUNTER9 0xc09 +#define CSR_HPMCOUNTER10 0xc0a +#define CSR_HPMCOUNTER11 0xc0b +#define CSR_HPMCOUNTER12 0xc0c +#define CSR_HPMCOUNTER13 0xc0d +#define CSR_HPMCOUNTER14 0xc0e +#define CSR_HPMCOUNTER15 0xc0f +#define CSR_HPMCOUNTER16 0xc10 +#define CSR_HPMCOUNTER17 0xc11 +#define CSR_HPMCOUNTER18 0xc12 +#define CSR_HPMCOUNTER19 0xc13 +#define CSR_HPMCOUNTER20 0xc14 +#define CSR_HPMCOUNTER21 0xc15 +#define CSR_HPMCOUNTER22 0xc16 +#define CSR_HPMCOUNTER23 0xc17 +#define CSR_HPMCOUNTER24 0xc18 +#define CSR_HPMCOUNTER25 0xc19 +#define CSR_HPMCOUNTER26 0xc1a +#define CSR_HPMCOUNTER27 0xc1b +#define CSR_HPMCOUNTER28 0xc1c +#define CSR_HPMCOUNTER29 0xc1d +#define CSR_HPMCOUNTER30 0xc1e +#define CSR_HPMCOUNTER31 0xc1f +#define CSR_SSTATUS 0x100 +#define CSR_SIE 0x104 +#define CSR_STVEC 0x105 +#define CSR_SCOUNTEREN 0x106 +#define CSR_SSCRATCH 0x140 +#define CSR_SEPC 0x141 +#define CSR_SCAUSE 0x142 +#define CSR_SBADADDR 0x143 +#define CSR_SIP 0x144 +#define CSR_SPTBR 0x180 +#define CSR_MSTATUS 0x300 +#define CSR_MISA 0x301 +#define CSR_MEDELEG 0x302 +#define CSR_MIDELEG 0x303 +#define CSR_MIE 0x304 +#define CSR_MTVEC 0x305 +#define CSR_MCOUNTEREN 0x306 +#define CSR_MSCRATCH 0x340 +#define CSR_MEPC 0x341 +#define CSR_MCAUSE 0x342 +#define CSR_MBADADDR 0x343 +#define CSR_MIP 0x344 +#define CSR_PMPCFG0 0x3a0 +#define CSR_PMPCFG1 0x3a1 +#define CSR_PMPCFG2 0x3a2 +#define CSR_PMPCFG3 0x3a3 +#define CSR_PMPADDR0 0x3b0 +#define CSR_PMPADDR1 0x3b1 +#define CSR_PMPADDR2 0x3b2 +#define CSR_PMPADDR3 0x3b3 +#define CSR_PMPADDR4 0x3b4 +#define CSR_PMPADDR5 0x3b5 +#define CSR_PMPADDR6 0x3b6 +#define CSR_PMPADDR7 0x3b7 +#define CSR_PMPADDR8 0x3b8 +#define CSR_PMPADDR9 0x3b9 +#define CSR_PMPADDR10 0x3ba +#define CSR_PMPADDR11 0x3bb +#define CSR_PMPADDR12 0x3bc +#define CSR_PMPADDR13 0x3bd +#define CSR_PMPADDR14 0x3be +#define CSR_PMPADDR15 0x3bf +#define CSR_TSELECT 0x7a0 +#define CSR_TDATA1 0x7a1 +#define CSR_TDATA2 0x7a2 +#define CSR_TDATA3 0x7a3 +#define CSR_DCSR 0x7b0 +#define CSR_DPC 0x7b1 +#define CSR_DSCRATCH 0x7b2 +#define CSR_MCYCLE 0xb00 +#define CSR_MINSTRET 0xb02 +#define CSR_MHPMCOUNTER3 0xb03 +#define CSR_MHPMCOUNTER4 0xb04 +#define CSR_MHPMCOUNTER5 0xb05 +#define CSR_MHPMCOUNTER6 0xb06 +#define CSR_MHPMCOUNTER7 0xb07 +#define CSR_MHPMCOUNTER8 0xb08 +#define CSR_MHPMCOUNTER9 0xb09 +#define CSR_MHPMCOUNTER10 0xb0a +#define CSR_MHPMCOUNTER11 0xb0b +#define CSR_MHPMCOUNTER12 0xb0c +#define CSR_MHPMCOUNTER13 0xb0d +#define CSR_MHPMCOUNTER14 0xb0e +#define CSR_MHPMCOUNTER15 0xb0f +#define CSR_MHPMCOUNTER16 0xb10 +#define CSR_MHPMCOUNTER17 0xb11 +#define CSR_MHPMCOUNTER18 0xb12 +#define CSR_MHPMCOUNTER19 0xb13 +#define CSR_MHPMCOUNTER20 0xb14 +#define CSR_MHPMCOUNTER21 0xb15 +#define CSR_MHPMCOUNTER22 0xb16 +#define CSR_MHPMCOUNTER23 0xb17 +#define CSR_MHPMCOUNTER24 0xb18 +#define CSR_MHPMCOUNTER25 0xb19 +#define CSR_MHPMCOUNTER26 0xb1a +#define CSR_MHPMCOUNTER27 0xb1b +#define CSR_MHPMCOUNTER28 0xb1c +#define CSR_MHPMCOUNTER29 0xb1d +#define CSR_MHPMCOUNTER30 0xb1e +#define CSR_MHPMCOUNTER31 0xb1f +#define CSR_MHPMEVENT3 0x323 +#define CSR_MHPMEVENT4 0x324 +#define CSR_MHPMEVENT5 0x325 +#define CSR_MHPMEVENT6 0x326 +#define CSR_MHPMEVENT7 0x327 +#define CSR_MHPMEVENT8 0x328 +#define CSR_MHPMEVENT9 0x329 +#define CSR_MHPMEVENT10 0x32a +#define CSR_MHPMEVENT11 0x32b +#define CSR_MHPMEVENT12 0x32c +#define CSR_MHPMEVENT13 0x32d +#define CSR_MHPMEVENT14 0x32e +#define CSR_MHPMEVENT15 0x32f +#define CSR_MHPMEVENT16 0x330 +#define CSR_MHPMEVENT17 0x331 +#define CSR_MHPMEVENT18 0x332 +#define CSR_MHPMEVENT19 0x333 +#define CSR_MHPMEVENT20 0x334 +#define CSR_MHPMEVENT21 0x335 +#define CSR_MHPMEVENT22 0x336 +#define CSR_MHPMEVENT23 0x337 +#define CSR_MHPMEVENT24 0x338 +#define CSR_MHPMEVENT25 0x339 +#define CSR_MHPMEVENT26 0x33a +#define CSR_MHPMEVENT27 0x33b +#define CSR_MHPMEVENT28 0x33c +#define CSR_MHPMEVENT29 0x33d +#define CSR_MHPMEVENT30 0x33e +#define CSR_MHPMEVENT31 0x33f +#define CSR_MVENDORID 0xf11 +#define CSR_MARCHID 0xf12 +#define CSR_MIMPID 0xf13 +#define CSR_MHARTID 0xf14 +#define CSR_CYCLEH 0xc80 +#define CSR_TIMEH 0xc81 +#define CSR_INSTRETH 0xc82 +#define CSR_HPMCOUNTER3H 0xc83 +#define CSR_HPMCOUNTER4H 0xc84 +#define CSR_HPMCOUNTER5H 0xc85 +#define CSR_HPMCOUNTER6H 0xc86 +#define CSR_HPMCOUNTER7H 0xc87 +#define CSR_HPMCOUNTER8H 0xc88 +#define CSR_HPMCOUNTER9H 0xc89 +#define CSR_HPMCOUNTER10H 0xc8a +#define CSR_HPMCOUNTER11H 0xc8b +#define CSR_HPMCOUNTER12H 0xc8c +#define CSR_HPMCOUNTER13H 0xc8d +#define CSR_HPMCOUNTER14H 0xc8e +#define CSR_HPMCOUNTER15H 0xc8f +#define CSR_HPMCOUNTER16H 0xc90 +#define CSR_HPMCOUNTER17H 0xc91 +#define CSR_HPMCOUNTER18H 0xc92 +#define CSR_HPMCOUNTER19H 0xc93 +#define CSR_HPMCOUNTER20H 0xc94 +#define CSR_HPMCOUNTER21H 0xc95 +#define CSR_HPMCOUNTER22H 0xc96 +#define CSR_HPMCOUNTER23H 0xc97 +#define CSR_HPMCOUNTER24H 0xc98 +#define CSR_HPMCOUNTER25H 0xc99 +#define CSR_HPMCOUNTER26H 0xc9a +#define CSR_HPMCOUNTER27H 0xc9b +#define CSR_HPMCOUNTER28H 0xc9c +#define CSR_HPMCOUNTER29H 0xc9d +#define CSR_HPMCOUNTER30H 0xc9e +#define CSR_HPMCOUNTER31H 0xc9f +#define CSR_MCYCLEH 0xb80 +#define CSR_MINSTRETH 0xb82 +#define CSR_MHPMCOUNTER3H 0xb83 +#define CSR_MHPMCOUNTER4H 0xb84 +#define CSR_MHPMCOUNTER5H 0xb85 +#define CSR_MHPMCOUNTER6H 0xb86 +#define CSR_MHPMCOUNTER7H 0xb87 +#define CSR_MHPMCOUNTER8H 0xb88 +#define CSR_MHPMCOUNTER9H 0xb89 +#define CSR_MHPMCOUNTER10H 0xb8a +#define CSR_MHPMCOUNTER11H 0xb8b +#define CSR_MHPMCOUNTER12H 0xb8c +#define CSR_MHPMCOUNTER13H 0xb8d +#define CSR_MHPMCOUNTER14H 0xb8e +#define CSR_MHPMCOUNTER15H 0xb8f +#define CSR_MHPMCOUNTER16H 0xb90 +#define CSR_MHPMCOUNTER17H 0xb91 +#define CSR_MHPMCOUNTER18H 0xb92 +#define CSR_MHPMCOUNTER19H 0xb93 +#define CSR_MHPMCOUNTER20H 0xb94 +#define CSR_MHPMCOUNTER21H 0xb95 +#define CSR_MHPMCOUNTER22H 0xb96 +#define CSR_MHPMCOUNTER23H 0xb97 +#define CSR_MHPMCOUNTER24H 0xb98 +#define CSR_MHPMCOUNTER25H 0xb99 +#define CSR_MHPMCOUNTER26H 0xb9a +#define CSR_MHPMCOUNTER27H 0xb9b +#define CSR_MHPMCOUNTER28H 0xb9c +#define CSR_MHPMCOUNTER29H 0xb9d +#define CSR_MHPMCOUNTER30H 0xb9e +#define CSR_MHPMCOUNTER31H 0xb9f +#define CAUSE_MISALIGNED_FETCH 0x0 +#define CAUSE_FETCH_ACCESS 0x1 +#define CAUSE_ILLEGAL_INSTRUCTION 0x2 +#define CAUSE_BREAKPOINT 0x3 +#define CAUSE_MISALIGNED_LOAD 0x4 +#define CAUSE_LOAD_ACCESS 0x5 +#define CAUSE_MISALIGNED_STORE 0x6 +#define CAUSE_STORE_ACCESS 0x7 +#define CAUSE_USER_ECALL 0x8 +#define CAUSE_SUPERVISOR_ECALL 0x9 +#define CAUSE_HYPERVISOR_ECALL 0xa +#define CAUSE_MACHINE_ECALL 0xb +#define CAUSE_FETCH_PAGE_FAULT 0xc +#define CAUSE_LOAD_PAGE_FAULT 0xd +#define CAUSE_STORE_PAGE_FAULT 0xf +#endif +#ifdef DECLARE_INSN +DECLARE_INSN(beq, MATCH_BEQ, MASK_BEQ) +DECLARE_INSN(bne, MATCH_BNE, MASK_BNE) +DECLARE_INSN(blt, MATCH_BLT, MASK_BLT) +DECLARE_INSN(bge, MATCH_BGE, MASK_BGE) +DECLARE_INSN(bltu, MATCH_BLTU, MASK_BLTU) +DECLARE_INSN(bgeu, MATCH_BGEU, MASK_BGEU) +DECLARE_INSN(jalr, MATCH_JALR, MASK_JALR) +DECLARE_INSN(jal, MATCH_JAL, MASK_JAL) +DECLARE_INSN(lui, MATCH_LUI, MASK_LUI) +DECLARE_INSN(auipc, MATCH_AUIPC, MASK_AUIPC) +DECLARE_INSN(addi, MATCH_ADDI, MASK_ADDI) +DECLARE_INSN(slli, MATCH_SLLI, MASK_SLLI) +DECLARE_INSN(slti, MATCH_SLTI, MASK_SLTI) +DECLARE_INSN(sltiu, MATCH_SLTIU, MASK_SLTIU) +DECLARE_INSN(xori, MATCH_XORI, MASK_XORI) +DECLARE_INSN(srli, MATCH_SRLI, MASK_SRLI) +DECLARE_INSN(srai, MATCH_SRAI, MASK_SRAI) +DECLARE_INSN(ori, MATCH_ORI, MASK_ORI) +DECLARE_INSN(andi, MATCH_ANDI, MASK_ANDI) +DECLARE_INSN(add, MATCH_ADD, MASK_ADD) +DECLARE_INSN(sub, MATCH_SUB, MASK_SUB) +DECLARE_INSN(sll, MATCH_SLL, MASK_SLL) +DECLARE_INSN(slt, MATCH_SLT, MASK_SLT) +DECLARE_INSN(sltu, MATCH_SLTU, MASK_SLTU) +DECLARE_INSN(xor, MATCH_XOR, MASK_XOR) +DECLARE_INSN(srl, MATCH_SRL, MASK_SRL) +DECLARE_INSN(sra, MATCH_SRA, MASK_SRA) +DECLARE_INSN( or , MATCH_OR, MASK_OR) +DECLARE_INSN( and , MATCH_AND, MASK_AND) +DECLARE_INSN(addiw, MATCH_ADDIW, MASK_ADDIW) +DECLARE_INSN(slliw, MATCH_SLLIW, MASK_SLLIW) +DECLARE_INSN(srliw, MATCH_SRLIW, MASK_SRLIW) +DECLARE_INSN(sraiw, MATCH_SRAIW, MASK_SRAIW) +DECLARE_INSN(addw, MATCH_ADDW, MASK_ADDW) +DECLARE_INSN(subw, MATCH_SUBW, MASK_SUBW) +DECLARE_INSN(sllw, MATCH_SLLW, MASK_SLLW) +DECLARE_INSN(srlw, MATCH_SRLW, MASK_SRLW) +DECLARE_INSN(sraw, MATCH_SRAW, MASK_SRAW) +DECLARE_INSN(lb, MATCH_LB, MASK_LB) +DECLARE_INSN(lh, MATCH_LH, MASK_LH) +DECLARE_INSN(lw, MATCH_LW, MASK_LW) +DECLARE_INSN(ld, MATCH_LD, MASK_LD) +DECLARE_INSN(lbu, MATCH_LBU, MASK_LBU) +DECLARE_INSN(lhu, MATCH_LHU, MASK_LHU) +DECLARE_INSN(lwu, MATCH_LWU, MASK_LWU) +DECLARE_INSN(sb, MATCH_SB, MASK_SB) +DECLARE_INSN(sh, MATCH_SH, MASK_SH) +DECLARE_INSN(sw, MATCH_SW, MASK_SW) +DECLARE_INSN(sd, MATCH_SD, MASK_SD) +DECLARE_INSN(fence, MATCH_FENCE, MASK_FENCE) +DECLARE_INSN(fence_i, MATCH_FENCE_I, MASK_FENCE_I) +DECLARE_INSN(mul, MATCH_MUL, MASK_MUL) +DECLARE_INSN(mulh, MATCH_MULH, MASK_MULH) +DECLARE_INSN(mulhsu, MATCH_MULHSU, MASK_MULHSU) +DECLARE_INSN(mulhu, MATCH_MULHU, MASK_MULHU) +DECLARE_INSN(div, MATCH_DIV, MASK_DIV) +DECLARE_INSN(divu, MATCH_DIVU, MASK_DIVU) +DECLARE_INSN(rem, MATCH_REM, MASK_REM) +DECLARE_INSN(remu, MATCH_REMU, MASK_REMU) +DECLARE_INSN(mulw, MATCH_MULW, MASK_MULW) +DECLARE_INSN(divw, MATCH_DIVW, MASK_DIVW) +DECLARE_INSN(divuw, MATCH_DIVUW, MASK_DIVUW) +DECLARE_INSN(remw, MATCH_REMW, MASK_REMW) +DECLARE_INSN(remuw, MATCH_REMUW, MASK_REMUW) +DECLARE_INSN(amoadd_w, MATCH_AMOADD_W, MASK_AMOADD_W) +DECLARE_INSN(amoxor_w, MATCH_AMOXOR_W, MASK_AMOXOR_W) +DECLARE_INSN(amoor_w, MATCH_AMOOR_W, MASK_AMOOR_W) +DECLARE_INSN(amoand_w, MATCH_AMOAND_W, MASK_AMOAND_W) +DECLARE_INSN(amomin_w, MATCH_AMOMIN_W, MASK_AMOMIN_W) +DECLARE_INSN(amomax_w, MATCH_AMOMAX_W, MASK_AMOMAX_W) +DECLARE_INSN(amominu_w, MATCH_AMOMINU_W, MASK_AMOMINU_W) +DECLARE_INSN(amomaxu_w, MATCH_AMOMAXU_W, MASK_AMOMAXU_W) +DECLARE_INSN(amoswap_w, MATCH_AMOSWAP_W, MASK_AMOSWAP_W) +DECLARE_INSN(lr_w, MATCH_LR_W, MASK_LR_W) +DECLARE_INSN(sc_w, MATCH_SC_W, MASK_SC_W) +DECLARE_INSN(amoadd_d, MATCH_AMOADD_D, MASK_AMOADD_D) +DECLARE_INSN(amoxor_d, MATCH_AMOXOR_D, MASK_AMOXOR_D) +DECLARE_INSN(amoor_d, MATCH_AMOOR_D, MASK_AMOOR_D) +DECLARE_INSN(amoand_d, MATCH_AMOAND_D, MASK_AMOAND_D) +DECLARE_INSN(amomin_d, MATCH_AMOMIN_D, MASK_AMOMIN_D) +DECLARE_INSN(amomax_d, MATCH_AMOMAX_D, MASK_AMOMAX_D) +DECLARE_INSN(amominu_d, MATCH_AMOMINU_D, MASK_AMOMINU_D) +DECLARE_INSN(amomaxu_d, MATCH_AMOMAXU_D, MASK_AMOMAXU_D) +DECLARE_INSN(amoswap_d, MATCH_AMOSWAP_D, MASK_AMOSWAP_D) +DECLARE_INSN(lr_d, MATCH_LR_D, MASK_LR_D) +DECLARE_INSN(sc_d, MATCH_SC_D, MASK_SC_D) +DECLARE_INSN(ecall, MATCH_ECALL, MASK_ECALL) +DECLARE_INSN(ebreak, MATCH_EBREAK, MASK_EBREAK) +DECLARE_INSN(uret, MATCH_URET, MASK_URET) +DECLARE_INSN(sret, MATCH_SRET, MASK_SRET) +DECLARE_INSN(mret, MATCH_MRET, MASK_MRET) +DECLARE_INSN(dret, MATCH_DRET, MASK_DRET) +DECLARE_INSN(sfence_vma, MATCH_SFENCE_VMA, MASK_SFENCE_VMA) +DECLARE_INSN(wfi, MATCH_WFI, MASK_WFI) +DECLARE_INSN(csrrw, MATCH_CSRRW, MASK_CSRRW) +DECLARE_INSN(csrrs, MATCH_CSRRS, MASK_CSRRS) +DECLARE_INSN(csrrc, MATCH_CSRRC, MASK_CSRRC) +DECLARE_INSN(csrrwi, MATCH_CSRRWI, MASK_CSRRWI) +DECLARE_INSN(csrrsi, MATCH_CSRRSI, MASK_CSRRSI) +DECLARE_INSN(csrrci, MATCH_CSRRCI, MASK_CSRRCI) +DECLARE_INSN(fadd_s, MATCH_FADD_S, MASK_FADD_S) +DECLARE_INSN(fsub_s, MATCH_FSUB_S, MASK_FSUB_S) +DECLARE_INSN(fmul_s, MATCH_FMUL_S, MASK_FMUL_S) +DECLARE_INSN(fdiv_s, MATCH_FDIV_S, MASK_FDIV_S) +DECLARE_INSN(fsgnj_s, MATCH_FSGNJ_S, MASK_FSGNJ_S) +DECLARE_INSN(fsgnjn_s, MATCH_FSGNJN_S, MASK_FSGNJN_S) +DECLARE_INSN(fsgnjx_s, MATCH_FSGNJX_S, MASK_FSGNJX_S) +DECLARE_INSN(fmin_s, MATCH_FMIN_S, MASK_FMIN_S) +DECLARE_INSN(fmax_s, MATCH_FMAX_S, MASK_FMAX_S) +DECLARE_INSN(fsqrt_s, MATCH_FSQRT_S, MASK_FSQRT_S) +DECLARE_INSN(fadd_d, MATCH_FADD_D, MASK_FADD_D) +DECLARE_INSN(fsub_d, MATCH_FSUB_D, MASK_FSUB_D) +DECLARE_INSN(fmul_d, MATCH_FMUL_D, MASK_FMUL_D) +DECLARE_INSN(fdiv_d, MATCH_FDIV_D, MASK_FDIV_D) +DECLARE_INSN(fsgnj_d, MATCH_FSGNJ_D, MASK_FSGNJ_D) +DECLARE_INSN(fsgnjn_d, MATCH_FSGNJN_D, MASK_FSGNJN_D) +DECLARE_INSN(fsgnjx_d, MATCH_FSGNJX_D, MASK_FSGNJX_D) +DECLARE_INSN(fmin_d, MATCH_FMIN_D, MASK_FMIN_D) +DECLARE_INSN(fmax_d, MATCH_FMAX_D, MASK_FMAX_D) +DECLARE_INSN(fcvt_s_d, MATCH_FCVT_S_D, MASK_FCVT_S_D) +DECLARE_INSN(fcvt_d_s, MATCH_FCVT_D_S, MASK_FCVT_D_S) +DECLARE_INSN(fsqrt_d, MATCH_FSQRT_D, MASK_FSQRT_D) +DECLARE_INSN(fadd_q, MATCH_FADD_Q, MASK_FADD_Q) +DECLARE_INSN(fsub_q, MATCH_FSUB_Q, MASK_FSUB_Q) +DECLARE_INSN(fmul_q, MATCH_FMUL_Q, MASK_FMUL_Q) +DECLARE_INSN(fdiv_q, MATCH_FDIV_Q, MASK_FDIV_Q) +DECLARE_INSN(fsgnj_q, MATCH_FSGNJ_Q, MASK_FSGNJ_Q) +DECLARE_INSN(fsgnjn_q, MATCH_FSGNJN_Q, MASK_FSGNJN_Q) +DECLARE_INSN(fsgnjx_q, MATCH_FSGNJX_Q, MASK_FSGNJX_Q) +DECLARE_INSN(fmin_q, MATCH_FMIN_Q, MASK_FMIN_Q) +DECLARE_INSN(fmax_q, MATCH_FMAX_Q, MASK_FMAX_Q) +DECLARE_INSN(fcvt_s_q, MATCH_FCVT_S_Q, MASK_FCVT_S_Q) +DECLARE_INSN(fcvt_q_s, MATCH_FCVT_Q_S, MASK_FCVT_Q_S) +DECLARE_INSN(fcvt_d_q, MATCH_FCVT_D_Q, MASK_FCVT_D_Q) +DECLARE_INSN(fcvt_q_d, MATCH_FCVT_Q_D, MASK_FCVT_Q_D) +DECLARE_INSN(fsqrt_q, MATCH_FSQRT_Q, MASK_FSQRT_Q) +DECLARE_INSN(fle_s, MATCH_FLE_S, MASK_FLE_S) +DECLARE_INSN(flt_s, MATCH_FLT_S, MASK_FLT_S) +DECLARE_INSN(feq_s, MATCH_FEQ_S, MASK_FEQ_S) +DECLARE_INSN(fle_d, MATCH_FLE_D, MASK_FLE_D) +DECLARE_INSN(flt_d, MATCH_FLT_D, MASK_FLT_D) +DECLARE_INSN(feq_d, MATCH_FEQ_D, MASK_FEQ_D) +DECLARE_INSN(fle_q, MATCH_FLE_Q, MASK_FLE_Q) +DECLARE_INSN(flt_q, MATCH_FLT_Q, MASK_FLT_Q) +DECLARE_INSN(feq_q, MATCH_FEQ_Q, MASK_FEQ_Q) +DECLARE_INSN(fcvt_w_s, MATCH_FCVT_W_S, MASK_FCVT_W_S) +DECLARE_INSN(fcvt_wu_s, MATCH_FCVT_WU_S, MASK_FCVT_WU_S) +DECLARE_INSN(fcvt_l_s, MATCH_FCVT_L_S, MASK_FCVT_L_S) +DECLARE_INSN(fcvt_lu_s, MATCH_FCVT_LU_S, MASK_FCVT_LU_S) +DECLARE_INSN(fmv_x_w, MATCH_FMV_X_W, MASK_FMV_X_W) +DECLARE_INSN(fclass_s, MATCH_FCLASS_S, MASK_FCLASS_S) +DECLARE_INSN(fcvt_w_d, MATCH_FCVT_W_D, MASK_FCVT_W_D) +DECLARE_INSN(fcvt_wu_d, MATCH_FCVT_WU_D, MASK_FCVT_WU_D) +DECLARE_INSN(fcvt_l_d, MATCH_FCVT_L_D, MASK_FCVT_L_D) +DECLARE_INSN(fcvt_lu_d, MATCH_FCVT_LU_D, MASK_FCVT_LU_D) +DECLARE_INSN(fmv_x_d, MATCH_FMV_X_D, MASK_FMV_X_D) +DECLARE_INSN(fclass_d, MATCH_FCLASS_D, MASK_FCLASS_D) +DECLARE_INSN(fcvt_w_q, MATCH_FCVT_W_Q, MASK_FCVT_W_Q) +DECLARE_INSN(fcvt_wu_q, MATCH_FCVT_WU_Q, MASK_FCVT_WU_Q) +DECLARE_INSN(fcvt_l_q, MATCH_FCVT_L_Q, MASK_FCVT_L_Q) +DECLARE_INSN(fcvt_lu_q, MATCH_FCVT_LU_Q, MASK_FCVT_LU_Q) +DECLARE_INSN(fmv_x_q, MATCH_FMV_X_Q, MASK_FMV_X_Q) +DECLARE_INSN(fclass_q, MATCH_FCLASS_Q, MASK_FCLASS_Q) +DECLARE_INSN(fcvt_s_w, MATCH_FCVT_S_W, MASK_FCVT_S_W) +DECLARE_INSN(fcvt_s_wu, MATCH_FCVT_S_WU, MASK_FCVT_S_WU) +DECLARE_INSN(fcvt_s_l, MATCH_FCVT_S_L, MASK_FCVT_S_L) +DECLARE_INSN(fcvt_s_lu, MATCH_FCVT_S_LU, MASK_FCVT_S_LU) +DECLARE_INSN(fmv_w_x, MATCH_FMV_W_X, MASK_FMV_W_X) +DECLARE_INSN(fcvt_d_w, MATCH_FCVT_D_W, MASK_FCVT_D_W) +DECLARE_INSN(fcvt_d_wu, MATCH_FCVT_D_WU, MASK_FCVT_D_WU) +DECLARE_INSN(fcvt_d_l, MATCH_FCVT_D_L, MASK_FCVT_D_L) +DECLARE_INSN(fcvt_d_lu, MATCH_FCVT_D_LU, MASK_FCVT_D_LU) +DECLARE_INSN(fmv_d_x, MATCH_FMV_D_X, MASK_FMV_D_X) +DECLARE_INSN(fcvt_q_w, MATCH_FCVT_Q_W, MASK_FCVT_Q_W) +DECLARE_INSN(fcvt_q_wu, MATCH_FCVT_Q_WU, MASK_FCVT_Q_WU) +DECLARE_INSN(fcvt_q_l, MATCH_FCVT_Q_L, MASK_FCVT_Q_L) +DECLARE_INSN(fcvt_q_lu, MATCH_FCVT_Q_LU, MASK_FCVT_Q_LU) +DECLARE_INSN(fmv_q_x, MATCH_FMV_Q_X, MASK_FMV_Q_X) +DECLARE_INSN(flw, MATCH_FLW, MASK_FLW) +DECLARE_INSN(fld, MATCH_FLD, MASK_FLD) +DECLARE_INSN(flq, MATCH_FLQ, MASK_FLQ) +DECLARE_INSN(fsw, MATCH_FSW, MASK_FSW) +DECLARE_INSN(fsd, MATCH_FSD, MASK_FSD) +DECLARE_INSN(fsq, MATCH_FSQ, MASK_FSQ) +DECLARE_INSN(fmadd_s, MATCH_FMADD_S, MASK_FMADD_S) +DECLARE_INSN(fmsub_s, MATCH_FMSUB_S, MASK_FMSUB_S) +DECLARE_INSN(fnmsub_s, MATCH_FNMSUB_S, MASK_FNMSUB_S) +DECLARE_INSN(fnmadd_s, MATCH_FNMADD_S, MASK_FNMADD_S) +DECLARE_INSN(fmadd_d, MATCH_FMADD_D, MASK_FMADD_D) +DECLARE_INSN(fmsub_d, MATCH_FMSUB_D, MASK_FMSUB_D) +DECLARE_INSN(fnmsub_d, MATCH_FNMSUB_D, MASK_FNMSUB_D) +DECLARE_INSN(fnmadd_d, MATCH_FNMADD_D, MASK_FNMADD_D) +DECLARE_INSN(fmadd_q, MATCH_FMADD_Q, MASK_FMADD_Q) +DECLARE_INSN(fmsub_q, MATCH_FMSUB_Q, MASK_FMSUB_Q) +DECLARE_INSN(fnmsub_q, MATCH_FNMSUB_Q, MASK_FNMSUB_Q) +DECLARE_INSN(fnmadd_q, MATCH_FNMADD_Q, MASK_FNMADD_Q) +DECLARE_INSN(c_nop, MATCH_C_NOP, MASK_C_NOP) +DECLARE_INSN(c_addi16sp, MATCH_C_ADDI16SP, MASK_C_ADDI16SP) +DECLARE_INSN(c_jr, MATCH_C_JR, MASK_C_JR) +DECLARE_INSN(c_jalr, MATCH_C_JALR, MASK_C_JALR) +DECLARE_INSN(c_ebreak, MATCH_C_EBREAK, MASK_C_EBREAK) +DECLARE_INSN(c_ld, MATCH_C_LD, MASK_C_LD) +DECLARE_INSN(c_sd, MATCH_C_SD, MASK_C_SD) +DECLARE_INSN(c_addiw, MATCH_C_ADDIW, MASK_C_ADDIW) +DECLARE_INSN(c_ldsp, MATCH_C_LDSP, MASK_C_LDSP) +DECLARE_INSN(c_sdsp, MATCH_C_SDSP, MASK_C_SDSP) +DECLARE_INSN(c_addi4spn, MATCH_C_ADDI4SPN, MASK_C_ADDI4SPN) +DECLARE_INSN(c_fld, MATCH_C_FLD, MASK_C_FLD) +DECLARE_INSN(c_lw, MATCH_C_LW, MASK_C_LW) +DECLARE_INSN(c_flw, MATCH_C_FLW, MASK_C_FLW) +DECLARE_INSN(c_fsd, MATCH_C_FSD, MASK_C_FSD) +DECLARE_INSN(c_sw, MATCH_C_SW, MASK_C_SW) +DECLARE_INSN(c_fsw, MATCH_C_FSW, MASK_C_FSW) +DECLARE_INSN(c_addi, MATCH_C_ADDI, MASK_C_ADDI) +DECLARE_INSN(c_jal, MATCH_C_JAL, MASK_C_JAL) +DECLARE_INSN(c_li, MATCH_C_LI, MASK_C_LI) +DECLARE_INSN(c_lui, MATCH_C_LUI, MASK_C_LUI) +DECLARE_INSN(c_srli, MATCH_C_SRLI, MASK_C_SRLI) +DECLARE_INSN(c_srai, MATCH_C_SRAI, MASK_C_SRAI) +DECLARE_INSN(c_andi, MATCH_C_ANDI, MASK_C_ANDI) +DECLARE_INSN(c_sub, MATCH_C_SUB, MASK_C_SUB) +DECLARE_INSN(c_xor, MATCH_C_XOR, MASK_C_XOR) +DECLARE_INSN(c_or, MATCH_C_OR, MASK_C_OR) +DECLARE_INSN(c_and, MATCH_C_AND, MASK_C_AND) +DECLARE_INSN(c_subw, MATCH_C_SUBW, MASK_C_SUBW) +DECLARE_INSN(c_addw, MATCH_C_ADDW, MASK_C_ADDW) +DECLARE_INSN(c_j, MATCH_C_J, MASK_C_J) +DECLARE_INSN(c_beqz, MATCH_C_BEQZ, MASK_C_BEQZ) +DECLARE_INSN(c_bnez, MATCH_C_BNEZ, MASK_C_BNEZ) +DECLARE_INSN(c_slli, MATCH_C_SLLI, MASK_C_SLLI) +DECLARE_INSN(c_fldsp, MATCH_C_FLDSP, MASK_C_FLDSP) +DECLARE_INSN(c_lwsp, MATCH_C_LWSP, MASK_C_LWSP) +DECLARE_INSN(c_flwsp, MATCH_C_FLWSP, MASK_C_FLWSP) +DECLARE_INSN(c_mv, MATCH_C_MV, MASK_C_MV) +DECLARE_INSN(c_add, MATCH_C_ADD, MASK_C_ADD) +DECLARE_INSN(c_fsdsp, MATCH_C_FSDSP, MASK_C_FSDSP) +DECLARE_INSN(c_swsp, MATCH_C_SWSP, MASK_C_SWSP) +DECLARE_INSN(c_fswsp, MATCH_C_FSWSP, MASK_C_FSWSP) +DECLARE_INSN(custom0, MATCH_CUSTOM0, MASK_CUSTOM0) +DECLARE_INSN(custom0_rs1, MATCH_CUSTOM0_RS1, MASK_CUSTOM0_RS1) +DECLARE_INSN(custom0_rs1_rs2, MATCH_CUSTOM0_RS1_RS2, MASK_CUSTOM0_RS1_RS2) +DECLARE_INSN(custom0_rd, MATCH_CUSTOM0_RD, MASK_CUSTOM0_RD) +DECLARE_INSN(custom0_rd_rs1, MATCH_CUSTOM0_RD_RS1, MASK_CUSTOM0_RD_RS1) +DECLARE_INSN(custom0_rd_rs1_rs2, MATCH_CUSTOM0_RD_RS1_RS2, MASK_CUSTOM0_RD_RS1_RS2) +DECLARE_INSN(custom1, MATCH_CUSTOM1, MASK_CUSTOM1) +DECLARE_INSN(custom1_rs1, MATCH_CUSTOM1_RS1, MASK_CUSTOM1_RS1) +DECLARE_INSN(custom1_rs1_rs2, MATCH_CUSTOM1_RS1_RS2, MASK_CUSTOM1_RS1_RS2) +DECLARE_INSN(custom1_rd, MATCH_CUSTOM1_RD, MASK_CUSTOM1_RD) +DECLARE_INSN(custom1_rd_rs1, MATCH_CUSTOM1_RD_RS1, MASK_CUSTOM1_RD_RS1) +DECLARE_INSN(custom1_rd_rs1_rs2, MATCH_CUSTOM1_RD_RS1_RS2, MASK_CUSTOM1_RD_RS1_RS2) +DECLARE_INSN(custom2, MATCH_CUSTOM2, MASK_CUSTOM2) +DECLARE_INSN(custom2_rs1, MATCH_CUSTOM2_RS1, MASK_CUSTOM2_RS1) +DECLARE_INSN(custom2_rs1_rs2, MATCH_CUSTOM2_RS1_RS2, MASK_CUSTOM2_RS1_RS2) +DECLARE_INSN(custom2_rd, MATCH_CUSTOM2_RD, MASK_CUSTOM2_RD) +DECLARE_INSN(custom2_rd_rs1, MATCH_CUSTOM2_RD_RS1, MASK_CUSTOM2_RD_RS1) +DECLARE_INSN(custom2_rd_rs1_rs2, MATCH_CUSTOM2_RD_RS1_RS2, MASK_CUSTOM2_RD_RS1_RS2) +DECLARE_INSN(custom3, MATCH_CUSTOM3, MASK_CUSTOM3) +DECLARE_INSN(custom3_rs1, MATCH_CUSTOM3_RS1, MASK_CUSTOM3_RS1) +DECLARE_INSN(custom3_rs1_rs2, MATCH_CUSTOM3_RS1_RS2, MASK_CUSTOM3_RS1_RS2) +DECLARE_INSN(custom3_rd, MATCH_CUSTOM3_RD, MASK_CUSTOM3_RD) +DECLARE_INSN(custom3_rd_rs1, MATCH_CUSTOM3_RD_RS1, MASK_CUSTOM3_RD_RS1) +DECLARE_INSN(custom3_rd_rs1_rs2, MATCH_CUSTOM3_RD_RS1_RS2, MASK_CUSTOM3_RD_RS1_RS2) +#endif +#ifdef DECLARE_CSR +DECLARE_CSR(fflags, CSR_FFLAGS) +DECLARE_CSR(frm, CSR_FRM) +DECLARE_CSR(fcsr, CSR_FCSR) +DECLARE_CSR(cycle, CSR_CYCLE) +DECLARE_CSR(time, CSR_TIME) +DECLARE_CSR(instret, CSR_INSTRET) +DECLARE_CSR(hpmcounter3, CSR_HPMCOUNTER3) +DECLARE_CSR(hpmcounter4, CSR_HPMCOUNTER4) +DECLARE_CSR(hpmcounter5, CSR_HPMCOUNTER5) +DECLARE_CSR(hpmcounter6, CSR_HPMCOUNTER6) +DECLARE_CSR(hpmcounter7, CSR_HPMCOUNTER7) +DECLARE_CSR(hpmcounter8, CSR_HPMCOUNTER8) +DECLARE_CSR(hpmcounter9, CSR_HPMCOUNTER9) +DECLARE_CSR(hpmcounter10, CSR_HPMCOUNTER10) +DECLARE_CSR(hpmcounter11, CSR_HPMCOUNTER11) +DECLARE_CSR(hpmcounter12, CSR_HPMCOUNTER12) +DECLARE_CSR(hpmcounter13, CSR_HPMCOUNTER13) +DECLARE_CSR(hpmcounter14, CSR_HPMCOUNTER14) +DECLARE_CSR(hpmcounter15, CSR_HPMCOUNTER15) +DECLARE_CSR(hpmcounter16, CSR_HPMCOUNTER16) +DECLARE_CSR(hpmcounter17, CSR_HPMCOUNTER17) +DECLARE_CSR(hpmcounter18, CSR_HPMCOUNTER18) +DECLARE_CSR(hpmcounter19, CSR_HPMCOUNTER19) +DECLARE_CSR(hpmcounter20, CSR_HPMCOUNTER20) +DECLARE_CSR(hpmcounter21, CSR_HPMCOUNTER21) +DECLARE_CSR(hpmcounter22, CSR_HPMCOUNTER22) +DECLARE_CSR(hpmcounter23, CSR_HPMCOUNTER23) +DECLARE_CSR(hpmcounter24, CSR_HPMCOUNTER24) +DECLARE_CSR(hpmcounter25, CSR_HPMCOUNTER25) +DECLARE_CSR(hpmcounter26, CSR_HPMCOUNTER26) +DECLARE_CSR(hpmcounter27, CSR_HPMCOUNTER27) +DECLARE_CSR(hpmcounter28, CSR_HPMCOUNTER28) +DECLARE_CSR(hpmcounter29, CSR_HPMCOUNTER29) +DECLARE_CSR(hpmcounter30, CSR_HPMCOUNTER30) +DECLARE_CSR(hpmcounter31, CSR_HPMCOUNTER31) +DECLARE_CSR(sstatus, CSR_SSTATUS) +DECLARE_CSR(sie, CSR_SIE) +DECLARE_CSR(stvec, CSR_STVEC) +DECLARE_CSR(scounteren, CSR_SCOUNTEREN) +DECLARE_CSR(sscratch, CSR_SSCRATCH) +DECLARE_CSR(sepc, CSR_SEPC) +DECLARE_CSR(scause, CSR_SCAUSE) +DECLARE_CSR(sbadaddr, CSR_SBADADDR) +DECLARE_CSR(sip, CSR_SIP) +DECLARE_CSR(sptbr, CSR_SPTBR) +DECLARE_CSR(mstatus, CSR_MSTATUS) +DECLARE_CSR(misa, CSR_MISA) +DECLARE_CSR(medeleg, CSR_MEDELEG) +DECLARE_CSR(mideleg, CSR_MIDELEG) +DECLARE_CSR(mie, CSR_MIE) +DECLARE_CSR(mtvec, CSR_MTVEC) +DECLARE_CSR(mcounteren, CSR_MCOUNTEREN) +DECLARE_CSR(mscratch, CSR_MSCRATCH) +DECLARE_CSR(mepc, CSR_MEPC) +DECLARE_CSR(mcause, CSR_MCAUSE) +DECLARE_CSR(mbadaddr, CSR_MBADADDR) +DECLARE_CSR(mip, CSR_MIP) +DECLARE_CSR(pmpcfg0, CSR_PMPCFG0) +DECLARE_CSR(pmpcfg1, CSR_PMPCFG1) +DECLARE_CSR(pmpcfg2, CSR_PMPCFG2) +DECLARE_CSR(pmpcfg3, CSR_PMPCFG3) +DECLARE_CSR(pmpaddr0, CSR_PMPADDR0) +DECLARE_CSR(pmpaddr1, CSR_PMPADDR1) +DECLARE_CSR(pmpaddr2, CSR_PMPADDR2) +DECLARE_CSR(pmpaddr3, CSR_PMPADDR3) +DECLARE_CSR(pmpaddr4, CSR_PMPADDR4) +DECLARE_CSR(pmpaddr5, CSR_PMPADDR5) +DECLARE_CSR(pmpaddr6, CSR_PMPADDR6) +DECLARE_CSR(pmpaddr7, CSR_PMPADDR7) +DECLARE_CSR(pmpaddr8, CSR_PMPADDR8) +DECLARE_CSR(pmpaddr9, CSR_PMPADDR9) +DECLARE_CSR(pmpaddr10, CSR_PMPADDR10) +DECLARE_CSR(pmpaddr11, CSR_PMPADDR11) +DECLARE_CSR(pmpaddr12, CSR_PMPADDR12) +DECLARE_CSR(pmpaddr13, CSR_PMPADDR13) +DECLARE_CSR(pmpaddr14, CSR_PMPADDR14) +DECLARE_CSR(pmpaddr15, CSR_PMPADDR15) +DECLARE_CSR(tselect, CSR_TSELECT) +DECLARE_CSR(tdata1, CSR_TDATA1) +DECLARE_CSR(tdata2, CSR_TDATA2) +DECLARE_CSR(tdata3, CSR_TDATA3) +DECLARE_CSR(dcsr, CSR_DCSR) +DECLARE_CSR(dpc, CSR_DPC) +DECLARE_CSR(dscratch, CSR_DSCRATCH) +DECLARE_CSR(mcycle, CSR_MCYCLE) +DECLARE_CSR(minstret, CSR_MINSTRET) +DECLARE_CSR(mhpmcounter3, CSR_MHPMCOUNTER3) +DECLARE_CSR(mhpmcounter4, CSR_MHPMCOUNTER4) +DECLARE_CSR(mhpmcounter5, CSR_MHPMCOUNTER5) +DECLARE_CSR(mhpmcounter6, CSR_MHPMCOUNTER6) +DECLARE_CSR(mhpmcounter7, CSR_MHPMCOUNTER7) +DECLARE_CSR(mhpmcounter8, CSR_MHPMCOUNTER8) +DECLARE_CSR(mhpmcounter9, CSR_MHPMCOUNTER9) +DECLARE_CSR(mhpmcounter10, CSR_MHPMCOUNTER10) +DECLARE_CSR(mhpmcounter11, CSR_MHPMCOUNTER11) +DECLARE_CSR(mhpmcounter12, CSR_MHPMCOUNTER12) +DECLARE_CSR(mhpmcounter13, CSR_MHPMCOUNTER13) +DECLARE_CSR(mhpmcounter14, CSR_MHPMCOUNTER14) +DECLARE_CSR(mhpmcounter15, CSR_MHPMCOUNTER15) +DECLARE_CSR(mhpmcounter16, CSR_MHPMCOUNTER16) +DECLARE_CSR(mhpmcounter17, CSR_MHPMCOUNTER17) +DECLARE_CSR(mhpmcounter18, CSR_MHPMCOUNTER18) +DECLARE_CSR(mhpmcounter19, CSR_MHPMCOUNTER19) +DECLARE_CSR(mhpmcounter20, CSR_MHPMCOUNTER20) +DECLARE_CSR(mhpmcounter21, CSR_MHPMCOUNTER21) +DECLARE_CSR(mhpmcounter22, CSR_MHPMCOUNTER22) +DECLARE_CSR(mhpmcounter23, CSR_MHPMCOUNTER23) +DECLARE_CSR(mhpmcounter24, CSR_MHPMCOUNTER24) +DECLARE_CSR(mhpmcounter25, CSR_MHPMCOUNTER25) +DECLARE_CSR(mhpmcounter26, CSR_MHPMCOUNTER26) +DECLARE_CSR(mhpmcounter27, CSR_MHPMCOUNTER27) +DECLARE_CSR(mhpmcounter28, CSR_MHPMCOUNTER28) +DECLARE_CSR(mhpmcounter29, CSR_MHPMCOUNTER29) +DECLARE_CSR(mhpmcounter30, CSR_MHPMCOUNTER30) +DECLARE_CSR(mhpmcounter31, CSR_MHPMCOUNTER31) +DECLARE_CSR(mhpmevent3, CSR_MHPMEVENT3) +DECLARE_CSR(mhpmevent4, CSR_MHPMEVENT4) +DECLARE_CSR(mhpmevent5, CSR_MHPMEVENT5) +DECLARE_CSR(mhpmevent6, CSR_MHPMEVENT6) +DECLARE_CSR(mhpmevent7, CSR_MHPMEVENT7) +DECLARE_CSR(mhpmevent8, CSR_MHPMEVENT8) +DECLARE_CSR(mhpmevent9, CSR_MHPMEVENT9) +DECLARE_CSR(mhpmevent10, CSR_MHPMEVENT10) +DECLARE_CSR(mhpmevent11, CSR_MHPMEVENT11) +DECLARE_CSR(mhpmevent12, CSR_MHPMEVENT12) +DECLARE_CSR(mhpmevent13, CSR_MHPMEVENT13) +DECLARE_CSR(mhpmevent14, CSR_MHPMEVENT14) +DECLARE_CSR(mhpmevent15, CSR_MHPMEVENT15) +DECLARE_CSR(mhpmevent16, CSR_MHPMEVENT16) +DECLARE_CSR(mhpmevent17, CSR_MHPMEVENT17) +DECLARE_CSR(mhpmevent18, CSR_MHPMEVENT18) +DECLARE_CSR(mhpmevent19, CSR_MHPMEVENT19) +DECLARE_CSR(mhpmevent20, CSR_MHPMEVENT20) +DECLARE_CSR(mhpmevent21, CSR_MHPMEVENT21) +DECLARE_CSR(mhpmevent22, CSR_MHPMEVENT22) +DECLARE_CSR(mhpmevent23, CSR_MHPMEVENT23) +DECLARE_CSR(mhpmevent24, CSR_MHPMEVENT24) +DECLARE_CSR(mhpmevent25, CSR_MHPMEVENT25) +DECLARE_CSR(mhpmevent26, CSR_MHPMEVENT26) +DECLARE_CSR(mhpmevent27, CSR_MHPMEVENT27) +DECLARE_CSR(mhpmevent28, CSR_MHPMEVENT28) +DECLARE_CSR(mhpmevent29, CSR_MHPMEVENT29) +DECLARE_CSR(mhpmevent30, CSR_MHPMEVENT30) +DECLARE_CSR(mhpmevent31, CSR_MHPMEVENT31) +DECLARE_CSR(mvendorid, CSR_MVENDORID) +DECLARE_CSR(marchid, CSR_MARCHID) +DECLARE_CSR(mimpid, CSR_MIMPID) +DECLARE_CSR(mhartid, CSR_MHARTID) +DECLARE_CSR(cycleh, CSR_CYCLEH) +DECLARE_CSR(timeh, CSR_TIMEH) +DECLARE_CSR(instreth, CSR_INSTRETH) +DECLARE_CSR(hpmcounter3h, CSR_HPMCOUNTER3H) +DECLARE_CSR(hpmcounter4h, CSR_HPMCOUNTER4H) +DECLARE_CSR(hpmcounter5h, CSR_HPMCOUNTER5H) +DECLARE_CSR(hpmcounter6h, CSR_HPMCOUNTER6H) +DECLARE_CSR(hpmcounter7h, CSR_HPMCOUNTER7H) +DECLARE_CSR(hpmcounter8h, CSR_HPMCOUNTER8H) +DECLARE_CSR(hpmcounter9h, CSR_HPMCOUNTER9H) +DECLARE_CSR(hpmcounter10h, CSR_HPMCOUNTER10H) +DECLARE_CSR(hpmcounter11h, CSR_HPMCOUNTER11H) +DECLARE_CSR(hpmcounter12h, CSR_HPMCOUNTER12H) +DECLARE_CSR(hpmcounter13h, CSR_HPMCOUNTER13H) +DECLARE_CSR(hpmcounter14h, CSR_HPMCOUNTER14H) +DECLARE_CSR(hpmcounter15h, CSR_HPMCOUNTER15H) +DECLARE_CSR(hpmcounter16h, CSR_HPMCOUNTER16H) +DECLARE_CSR(hpmcounter17h, CSR_HPMCOUNTER17H) +DECLARE_CSR(hpmcounter18h, CSR_HPMCOUNTER18H) +DECLARE_CSR(hpmcounter19h, CSR_HPMCOUNTER19H) +DECLARE_CSR(hpmcounter20h, CSR_HPMCOUNTER20H) +DECLARE_CSR(hpmcounter21h, CSR_HPMCOUNTER21H) +DECLARE_CSR(hpmcounter22h, CSR_HPMCOUNTER22H) +DECLARE_CSR(hpmcounter23h, CSR_HPMCOUNTER23H) +DECLARE_CSR(hpmcounter24h, CSR_HPMCOUNTER24H) +DECLARE_CSR(hpmcounter25h, CSR_HPMCOUNTER25H) +DECLARE_CSR(hpmcounter26h, CSR_HPMCOUNTER26H) +DECLARE_CSR(hpmcounter27h, CSR_HPMCOUNTER27H) +DECLARE_CSR(hpmcounter28h, CSR_HPMCOUNTER28H) +DECLARE_CSR(hpmcounter29h, CSR_HPMCOUNTER29H) +DECLARE_CSR(hpmcounter30h, CSR_HPMCOUNTER30H) +DECLARE_CSR(hpmcounter31h, CSR_HPMCOUNTER31H) +DECLARE_CSR(mcycleh, CSR_MCYCLEH) +DECLARE_CSR(minstreth, CSR_MINSTRETH) +DECLARE_CSR(mhpmcounter3h, CSR_MHPMCOUNTER3H) +DECLARE_CSR(mhpmcounter4h, CSR_MHPMCOUNTER4H) +DECLARE_CSR(mhpmcounter5h, CSR_MHPMCOUNTER5H) +DECLARE_CSR(mhpmcounter6h, CSR_MHPMCOUNTER6H) +DECLARE_CSR(mhpmcounter7h, CSR_MHPMCOUNTER7H) +DECLARE_CSR(mhpmcounter8h, CSR_MHPMCOUNTER8H) +DECLARE_CSR(mhpmcounter9h, CSR_MHPMCOUNTER9H) +DECLARE_CSR(mhpmcounter10h, CSR_MHPMCOUNTER10H) +DECLARE_CSR(mhpmcounter11h, CSR_MHPMCOUNTER11H) +DECLARE_CSR(mhpmcounter12h, CSR_MHPMCOUNTER12H) +DECLARE_CSR(mhpmcounter13h, CSR_MHPMCOUNTER13H) +DECLARE_CSR(mhpmcounter14h, CSR_MHPMCOUNTER14H) +DECLARE_CSR(mhpmcounter15h, CSR_MHPMCOUNTER15H) +DECLARE_CSR(mhpmcounter16h, CSR_MHPMCOUNTER16H) +DECLARE_CSR(mhpmcounter17h, CSR_MHPMCOUNTER17H) +DECLARE_CSR(mhpmcounter18h, CSR_MHPMCOUNTER18H) +DECLARE_CSR(mhpmcounter19h, CSR_MHPMCOUNTER19H) +DECLARE_CSR(mhpmcounter20h, CSR_MHPMCOUNTER20H) +DECLARE_CSR(mhpmcounter21h, CSR_MHPMCOUNTER21H) +DECLARE_CSR(mhpmcounter22h, CSR_MHPMCOUNTER22H) +DECLARE_CSR(mhpmcounter23h, CSR_MHPMCOUNTER23H) +DECLARE_CSR(mhpmcounter24h, CSR_MHPMCOUNTER24H) +DECLARE_CSR(mhpmcounter25h, CSR_MHPMCOUNTER25H) +DECLARE_CSR(mhpmcounter26h, CSR_MHPMCOUNTER26H) +DECLARE_CSR(mhpmcounter27h, CSR_MHPMCOUNTER27H) +DECLARE_CSR(mhpmcounter28h, CSR_MHPMCOUNTER28H) +DECLARE_CSR(mhpmcounter29h, CSR_MHPMCOUNTER29H) +DECLARE_CSR(mhpmcounter30h, CSR_MHPMCOUNTER30H) +DECLARE_CSR(mhpmcounter31h, CSR_MHPMCOUNTER31H) +#endif +#ifdef DECLARE_CAUSE +DECLARE_CAUSE("misaligned fetch", CAUSE_MISALIGNED_FETCH) +DECLARE_CAUSE("fetch access", CAUSE_FETCH_ACCESS) +DECLARE_CAUSE("illegal instruction", CAUSE_ILLEGAL_INSTRUCTION) +DECLARE_CAUSE("breakpoint", CAUSE_BREAKPOINT) +DECLARE_CAUSE("misaligned load", CAUSE_MISALIGNED_LOAD) +DECLARE_CAUSE("load access", CAUSE_LOAD_ACCESS) +DECLARE_CAUSE("misaligned store", CAUSE_MISALIGNED_STORE) +DECLARE_CAUSE("store access", CAUSE_STORE_ACCESS) +DECLARE_CAUSE("user_ecall", CAUSE_USER_ECALL) +DECLARE_CAUSE("supervisor_ecall", CAUSE_SUPERVISOR_ECALL) +DECLARE_CAUSE("hypervisor_ecall", CAUSE_HYPERVISOR_ECALL) +DECLARE_CAUSE("machine_ecall", CAUSE_MACHINE_ECALL) +DECLARE_CAUSE("fetch page fault", CAUSE_FETCH_PAGE_FAULT) +DECLARE_CAUSE("load page fault", CAUSE_LOAD_PAGE_FAULT) +DECLARE_CAUSE("store page fault", CAUSE_STORE_PAGE_FAULT) +#endif diff --git a/cpukit/score/cpu/riscv/include/rtems/score/riscv.h b/cpukit/score/cpu/riscv/include/rtems/score/riscv.h new file mode 100644 index 0000000000..6e7f1370c6 --- /dev/null +++ b/cpukit/score/cpu/riscv/include/rtems/score/riscv.h @@ -0,0 +1,66 @@ +/** + * @file rtems/score/riscv.h + */ + +/* + * This file contains information pertaining to the riscv32 processor. + * + * COPYRIGHT (c) 2014 Hesham Almatary + * + * Based on code with the following copyright... + * COPYRIGHT (c) 1989-1999, 2010. + * On-Line Applications Research Corporation (OAR). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _RTEMS_SCORE_RISCV_H +#define _RTEMS_SCORE_RISCV_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This file contains the information required to build + * RTEMS for a particular member of the RISCV family. + * It does this by setting variables to indicate which + * implementation dependent features are present in a particular + * member of the family. + * + * This is a good place to list all the known CPU models + * that this port supports and which RTEMS CPU model they correspond + * to. + */ + +/* +* Define the name of the CPU family and specific model. +*/ + +#define CPU_NAME "RISCV" +#define CPU_MODEL_NAME "RISCV" + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_SCORE_RISCV_H */ diff --git a/cpukit/score/cpu/riscv/include/rtems/score/types.h b/cpukit/score/cpu/riscv/include/rtems/score/types.h new file mode 100644 index 0000000000..d1440fb319 --- /dev/null +++ b/cpukit/score/cpu/riscv/include/rtems/score/types.h @@ -0,0 +1,70 @@ +/** + * @file + * + * @brief RISC-V Architecture Types API + */ + +/* + * This include file contains type definitions pertaining to the + * RISC-V processor family. + * + * COPYRIGHT (c) 2014 Hesham Almatary + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _RTEMS_SCORE_TYPES_H +#define _RTEMS_SCORE_TYPES_H + +#include + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup ScoreCPU + */ +/**@{**/ + +/* + * This section defines the basic types for this processor. + */ + +/** Type that can store a 32-bit integer or a pointer. */ +typedef uintptr_t CPU_Uint32ptr; + +typedef uint16_t Priority_bit_map_Word; +typedef void riscv_isr; +typedef void ( *riscv_isr_entry )( void ); + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* !ASM */ + +#endif diff --git a/cpukit/score/cpu/riscv/preinstall.am b/cpukit/score/cpu/riscv/preinstall.am deleted file mode 100644 index 14256ba876..0000000000 --- a/cpukit/score/cpu/riscv/preinstall.am +++ /dev/null @@ -1,57 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -$(PROJECT_INCLUDE)/rtems/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems - @: > $(PROJECT_INCLUDE)/rtems/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/asm.h: rtems/asm.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/asm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/asm.h - -$(PROJECT_INCLUDE)/rtems/score/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/score - @: > $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/score/cpu.h: rtems/score/cpu.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpu.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpu.h - -$(PROJECT_INCLUDE)/rtems/score/cpuatomic.h: rtems/score/cpuatomic.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h - -$(PROJECT_INCLUDE)/rtems/score/cpuimpl.h: rtems/score/cpuimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h - -$(PROJECT_INCLUDE)/rtems/score/cpu_asm.h: rtems/score/cpu_asm.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpu_asm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpu_asm.h - -$(PROJECT_INCLUDE)/rtems/score/types.h: rtems/score/types.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/types.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/types.h - -$(PROJECT_INCLUDE)/rtems/score/riscv.h: rtems/score/riscv.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/riscv.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/riscv.h - -$(PROJECT_INCLUDE)/rtems/score/riscv-utility.h: rtems/score/riscv-utility.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/riscv-utility.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/riscv-utility.h - diff --git a/cpukit/score/cpu/riscv/rtems/asm.h b/cpukit/score/cpu/riscv/rtems/asm.h deleted file mode 100644 index 34b6474515..0000000000 --- a/cpukit/score/cpu/riscv/rtems/asm.h +++ /dev/null @@ -1,120 +0,0 @@ -/** - * @file rtems/asm.h - * - * This include file attempts to address the problems - * caused by incompatible flavors of assemblers and - * toolsets. It primarily addresses variations in the - * use of leading underscores on symbols and the requirement - * that register names be preceded by a %. - */ - -/* - * NOTE: The spacing in the use of these macros - * is critical to them working as advertised. - * - * This file is based on similar code found in newlib available - * from ftp.cygnus.com. The file which was used had no copyright - * notice. This file is freely distributable as long as the source - * of the file is noted. This file is: - * - * Copyright (c) 2015 University of York. - * Hesham Almatary - * - * - * COPYRIGHT (c) 1994-1997. - * On-Line Applications Research Corporation (OAR). - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef __RISCV_ASM_H -#define __RISCV_ASM_H - -/* - * Indicate we are in an assembly file and get the basic CPU definitions. - */ - -#ifndef ASM -#define ASM -#endif -#include -#include - -/* - * Recent versions of GNU cpp define variables which indicate the - * need for underscores and percents. If not using GNU cpp or - * the version does not support this, then you will obviously - * have to define these as appropriate. - */ - -#ifndef __USER_LABEL_PREFIX__ -#define __USER_LABEL_PREFIX__ _ -#endif - -#ifndef __REGISTER_PREFIX__ -#define __REGISTER_PREFIX__ -#endif - -/* ANSI concatenation macros. */ - -#define CONCAT1(a, b) CONCAT2(a, b) -#define CONCAT2(a, b) a ## b - -/* Use the right prefix for global labels. */ - -#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) - -/* Use the right prefix for registers. */ - -#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) - -/* - * define macros for all of the registers on this CPU - * - * EXAMPLE: #define d0 REG (d0) - */ - -/* - * Define macros to handle section beginning and ends. - */ -#define BEGIN_CODE_DCL .text -#define END_CODE_DCL -#define BEGIN_DATA_DCL .data -#define END_DATA_DCL -#define BEGIN_CODE .text -#define END_CODE -#define BEGIN_DATA -#define END_DATA -#define BEGIN_BSS -#define END_BSS -#define END - -/* - * Following must be tailor for a particular flavor of the C compiler. - * They may need to put underscores in front of the symbols. - */ - -#define PUBLIC(sym) .global SYM (sym) -#define EXTERN(sym) .extern SYM (sym) -#define TYPE_FUNC(sym) .type SYM (sym), %function - -#endif diff --git a/cpukit/score/cpu/riscv/rtems/score/cpu.h b/cpukit/score/cpu/riscv/rtems/score/cpu.h deleted file mode 100644 index 3f8af862bf..0000000000 --- a/cpukit/score/cpu/riscv/rtems/score/cpu.h +++ /dev/null @@ -1,604 +0,0 @@ -/** - * @file rtems/score/cpu.h - */ - -/* - * - * Copyright (c) 2015 University of York. - * Hesham Almatary - * - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _RISCV_CPU_H -#define _RISCV_CPU_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include /* pick up machine definitions */ -#include -#include -#ifndef ASM -#include -#include -#include /* for printk */ -#endif - -#define CPU_INLINE_ENABLE_DISPATCH FALSE -#define CPU_UNROLL_ENQUEUE_PRIORITY TRUE -#define CPU_HAS_SOFTWARE_INTERRUPT_STACK TRUE -#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE -#define CPU_ALLOCATE_INTERRUPT_STACK TRUE -#define CPU_ISR_PASSES_FRAME_POINTER 1 -#define CPU_HARDWARE_FP FALSE -#define CPU_SOFTWARE_FP FALSE -#define CPU_ALL_TASKS_ARE_FP FALSE -#define CPU_IDLE_TASK_IS_FP FALSE -#define CPU_USE_DEFERRED_FP_SWITCH FALSE -#define CPU_PROVIDES_IDLE_THREAD_BODY TRUE -#define CPU_STACK_GROWS_UP FALSE - -#define CPU_STRUCTURE_ALIGNMENT __attribute__ ((aligned (64))) -#define CPU_HAS_OWN_HOST_TO_NETWORK_ROUTINES FALSE -#define CPU_BIG_ENDIAN FALSE -#define CPU_LITTLE_ENDIAN TRUE -#define CPU_MODES_INTERRUPT_MASK 0x0000000000000001 - -/* - * Processor defined structures required for cpukit/score. - */ - -#ifndef ASM - -typedef struct { - /* riscv has 32 xlen-bit (where xlen can be 32 or 64) general purpose registers (x0-x31)*/ - unsigned long x[32]; - - /* Special purpose registers */ - unsigned long mstatus; - unsigned long mcause; - unsigned long mepc; -#ifdef RTEMS_SMP - /** - * @brief On SMP configurations the thread context must contain a boolean - * indicator to signal if this context is executing on a processor. - * - * This field must be updated during a context switch. The context switch - * to the heir must wait until the heir context indicates that it is no - * longer executing on a processor. The context switch must also check if - * a thread dispatch is necessary to honor updates of the heir thread for - * this processor. This indicator must be updated using an atomic test and - * set operation to ensure that at most one processor uses the heir - * context at the same time. - * - * @code - * void _CPU_Context_switch( - * Context_Control *executing, - * Context_Control *heir - * ) - * { - * save( executing ); - * - * executing->is_executing = false; - * memory_barrier(); - * - * if ( test_and_set( &heir->is_executing ) ) { - * do { - * Per_CPU_Control *cpu_self = _Per_CPU_Get_snapshot(); - * - * if ( cpu_self->dispatch_necessary ) { - * heir = _Thread_Get_heir_and_make_it_executing( cpu_self ); - * } - * } while ( test_and_set( &heir->is_executing ) ); - * } - * - * restore( heir ); - * } - * @endcode - */ - volatile bool is_executing; -#endif -} Context_Control; - -#define _CPU_Context_Get_SP( _context ) \ - (_context)->x[2] - -typedef struct { - /** TODO FPU registers are listed here */ - double some_float_register; -} Context_Control_fp; - -typedef Context_Control CPU_Interrupt_frame; - -#define CPU_CONTEXT_FP_SIZE 0 -Context_Control_fp _CPU_Null_fp_context; - -#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0 -#if __riscv_xlen == 32 -#define CPU_STACK_MINIMUM_SIZE 4096 -#else -#define CPU_STACK_MINIMUM_SIZE 4096 * 2 -#endif -#define CPU_ALIGNMENT 8 -#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE -#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT -#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT -#define CPU_STACK_ALIGNMENT 8 -#define _CPU_Initialize_vectors() - -/* - * Disable all interrupts for an RTEMS critical section. The previous - * level is returned in _level. - * - */ - -static inline unsigned long riscv_interrupt_disable( void ) -{ - register unsigned long status = read_csr(mstatus); - clear_csr(mstatus, MSTATUS_MIE); - return status; -} - -static inline void riscv_interrupt_enable(unsigned long level) -{ - write_csr(mstatus, level); -} - -#define _CPU_ISR_Disable( _level ) \ - _level = riscv_interrupt_disable() - -#define _CPU_ISR_Enable( _level ) \ - riscv_interrupt_enable( _level ) - -#define _CPU_ISR_Flash( _level ) \ - do{ \ - _CPU_ISR_Enable( _level ); \ - riscv_interrupt_disable(); \ - } while(0) - -RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( unsigned long level ) -{ - return ( level & MSTATUS_MIE ) != 0; -} - -void _CPU_ISR_Set_level( unsigned long level ); - -unsigned long _CPU_ISR_Get_level( void ); - -/* end of ISR handler macros */ - -/* Context handler macros */ -#define RISCV_GCC_RED_ZONE_SIZE 128 - -void _CPU_Context_Initialize( - Context_Control *context, - void *stack_area_begin, - size_t stack_area_size, - unsigned long new_level, - void (*entry_point)( void ), - bool is_fp, - void *tls_area -); - -#define _CPU_Context_Restart_self( _the_context ) \ - _CPU_Context_restore( (_the_context) ) - - -#define _CPU_Context_Fp_start( _base, _offset ) \ - ( (void *) _Addresses_Add_offset( (_base), (_offset) ) ) - -#define _CPU_Context_Initialize_fp( _destination ) \ - { \ - *(*(_destination)) = _CPU_Null_fp_context; \ - } - -extern void _CPU_Fatal_halt(uint32_t source, uint32_t error) RTEMS_NO_RETURN; - -/* end of Fatal Error manager macros */ - -#define CPU_USE_GENERIC_BITFIELD_CODE TRUE -#define CPU_USE_GENERIC_BITFIELD_DATA TRUE - -#if (CPU_USE_GENERIC_BITFIELD_CODE == FALSE) - -#define _CPU_Bitfield_Find_first_bit( _value, _output ) \ - { \ - (_output) = 0; /* do something to prevent warnings */ \ - } -#endif - -/* end of Bitfield handler macros */ - -/* - * This routine builds the mask which corresponds to the bit fields - * as searched by _CPU_Bitfield_Find_first_bit(). See the discussion - * for that routine. - * - */ - -#if (CPU_USE_GENERIC_BITFIELD_CODE == FALSE) - -#define _CPU_Priority_Mask( _bit_number ) \ - (1 << _bit_number) - -#endif - -#if (CPU_USE_GENERIC_BITFIELD_CODE == FALSE) - -#define _CPU_Priority_bits_index( _priority ) \ - (_priority) - -#endif - -#define CPU_MAXIMUM_PROCESSORS 32 - -#define CPU_TIMESTAMP_USE_STRUCT_TIMESPEC FALSE -#define CPU_TIMESTAMP_USE_INT64 TRUE -#define CPU_TIMESTAMP_USE_INT64_INLINE FALSE - -typedef struct { - /* There is no CPU specific per-CPU state */ -} CPU_Per_CPU_control; -#endif /* ASM */ - -#if __riscv_xlen == 32 -#define CPU_SIZEOF_POINTER 4 - -/* 32-bit load/store instructions */ -#define LREG lw -#define SREG sw - -#define CPU_EXCEPTION_FRAME_SIZE 128 -#else /* xlen = 64 */ -#define CPU_SIZEOF_POINTER 8 - -/* 64-bit load/store instructions */ -#define LREG ld -#define SREG sd - -#define CPU_EXCEPTION_FRAME_SIZE 256 -#endif - -#define CPU_PER_CPU_CONTROL_SIZE 0 - -#ifndef ASM -typedef uint16_t Priority_bit_map_Word; - -typedef struct { - unsigned long x[32];; -} CPU_Exception_frame; - -/** - * @brief Prints the exception frame via printk(). - * - * @see rtems_fatal() and RTEMS_FATAL_SOURCE_EXCEPTION. - */ -void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); - - -/* end of Priority handler macros */ - -/* functions */ - -/* - * _CPU_Initialize - * - * This routine performs CPU dependent initialization. - * - */ - -void _CPU_Initialize( - void -); - -/* - * _CPU_ISR_install_raw_handler - * - * This routine installs a "raw" interrupt handler directly into the - * processor's vector table. - * - */ - -void _CPU_ISR_install_raw_handler( - uint32_t vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -/* - * _CPU_ISR_install_vector - * - * This routine installs an interrupt vector. - * - * NO_CPU Specific Information: - * - * XXX document implementation including references if appropriate - */ - -void _CPU_ISR_install_vector( - unsigned long vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -/* - * _CPU_Install_interrupt_stack - * - * This routine installs the hardware interrupt stack pointer. - * - * NOTE: It need only be provided if CPU_HAS_HARDWARE_INTERRUPT_STACK - * is TRUE. - * - */ - -void _CPU_Install_interrupt_stack( void ); - -/* - * _CPU_Thread_Idle_body - * - * This routine is the CPU dependent IDLE thread body. - * - * NOTE: It need only be provided if CPU_PROVIDES_IDLE_THREAD_BODY - * is TRUE. - * - */ - -void *_CPU_Thread_Idle_body( uintptr_t ignored ); - -/* - * _CPU_Context_switch - * - * This routine switches from the run context to the heir context. - * - * RISCV Specific Information: - * - * Please see the comments in the .c file for a description of how - * this function works. There are several things to be aware of. - */ - -void _CPU_Context_switch( - Context_Control *run, - Context_Control *heir -); - -/* - * _CPU_Context_restore - * - * This routine is generally used only to restart self in an - * efficient manner. It may simply be a label in _CPU_Context_switch. - * - * NOTE: May be unnecessary to reload some registers. - * - */ - -void _CPU_Context_restore( - Context_Control *new_context -) RTEMS_NO_RETURN; - -/* - * _CPU_Context_save_fp - * - * This routine saves the floating point context passed to it. - * - */ - -void _CPU_Context_save_fp( - void **fp_context_ptr -); - -/* - * _CPU_Context_restore_fp - * - * This routine restores the floating point context passed to it. - * - */ - -void _CPU_Context_restore_fp( - void **fp_context_ptr -); - -/* The following routine swaps the endian format of an unsigned int. - * It must be static because it is referenced indirectly. - * - * This version will work on any processor, but if there is a better - * way for your CPU PLEASE use it. The most common way to do this is to: - * - * swap least significant two bytes with 16-bit rotate - * swap upper and lower 16-bits - * swap most significant two bytes with 16-bit rotate - * - * Some CPUs have special instructions which swap a 32-bit quantity in - * a single instruction (e.g. i486). It is probably best to avoid - * an "endian swapping control bit" in the CPU. One good reason is - * that interrupts would probably have to be disabled to insure that - * an interrupt does not try to access the same "chunk" with the wrong - * endian. Another good reason is that on some CPUs, the endian bit - * endianness for ALL fetches -- both code and data -- so the code - * will be fetched incorrectly. - * - */ - -static inline uint32_t CPU_swap_u32( - uint32_t value -) -{ - uint32_t byte1, byte2, byte3, byte4, swapped; - - byte4 = (value >> 24) & 0xff; - byte3 = (value >> 16) & 0xff; - byte2 = (value >> 8) & 0xff; - byte1 = value & 0xff; - - swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4; - return ( swapped ); -} - -#define CPU_swap_u16( value ) \ - (((value&0xff) << 8) | ((value >> 8)&0xff)) - -static inline void _CPU_Context_volatile_clobber( uintptr_t pattern ) -{ - /* TODO */ -} - -static inline void _CPU_Context_validate( uintptr_t pattern ) -{ - while (1) { - /* TODO */ - } -} - -typedef uint32_t CPU_Counter_ticks; - -CPU_Counter_ticks _CPU_Counter_read( void ); - -#ifdef RTEMS_SMP -/** - * @brief Performs CPU specific SMP initialization in the context of the boot - * processor. - * - * This function is invoked on the boot processor during system - * initialization. All interrupt stacks are allocated at this point in case - * the CPU port allocates the interrupt stacks. This function is called - * before _CPU_SMP_Start_processor() or _CPU_SMP_Finalize_initialization() is - * used. - * - * @return The count of physically or virtually available processors. - * Depending on the configuration the application may use not all processors. - */ -uint32_t _CPU_SMP_Initialize( void ); - -/** - * @brief Starts a processor specified by its index. - * - * This function is invoked on the boot processor during system - * initialization. - * - * This function will be called after _CPU_SMP_Initialize(). - * - * @param[in] cpu_index The processor index. - * - * @retval true Successful operation. - * @retval false Unable to start this processor. - */ -bool _CPU_SMP_Start_processor( uint32_t cpu_index ); - -/** - * @brief Performs final steps of CPU specific SMP initialization in the - * context of the boot processor. - * - * This function is invoked on the boot processor during system - * initialization. - * - * This function will be called after all processors requested by the - * application have been started. - * - * @param[in] cpu_count The minimum value of the count of processors - * requested by the application configuration and the count of physically or - * virtually available processors. - */ -void _CPU_SMP_Finalize_initialization( uint32_t cpu_count ); - -/** - * @brief Returns the index of the current processor. - * - * An architecture specific method must be used to obtain the index of the - * current processor in the system. The set of processor indices is the - * range of integers starting with zero up to the processor count minus one. - */ -uint32_t _CPU_SMP_Get_current_processor( void ); - -/** - * @brief Sends an inter-processor interrupt to the specified target - * processor. - * - * This operation is undefined for target processor indices out of range. - * - * @param[in] target_processor_index The target processor index. - */ -void _CPU_SMP_Send_interrupt( uint32_t target_processor_index ); - -/** - * @brief Broadcasts a processor event. - * - * Some architectures provide a low-level synchronization primitive for - * processors in a multi-processor environment. Processors waiting for this - * event may go into a low-power state and stop generating system bus - * transactions. This function must ensure that preceding store operations - * can be observed by other processors. - * - * @see _CPU_SMP_Processor_event_receive(). - */ -void _CPU_SMP_Processor_event_broadcast( void ); - -/** - * @brief Receives a processor event. - * - * This function will wait for the processor event and may wait forever if no - * such event arrives. - * - * @see _CPU_SMP_Processor_event_broadcast(). - */ -static inline void _CPU_SMP_Processor_event_receive( void ) -{ - __asm__ volatile ( "" : : : "memory" ); -} - -/** - * @brief Gets the is executing indicator of the thread context. - * - * @param[in] context The context. - */ -static inline bool _CPU_Context_Get_is_executing( - const Context_Control *context -) -{ - return context->is_executing; -} - -/** - * @brief Sets the is executing indicator of the thread context. - * - * @param[in] context The context. - * @param[in] is_executing The new value for the is executing indicator. - */ -static inline void _CPU_Context_Set_is_executing( - Context_Control *context, - bool is_executing -) -{ - context->is_executing = is_executing; -} -#endif /* RTEMS_SMP */ - -#endif /* ASM */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/score/cpu/riscv/rtems/score/cpu_asm.h b/cpukit/score/cpu/riscv/rtems/score/cpu_asm.h deleted file mode 100644 index b5a56f3e22..0000000000 --- a/cpukit/score/cpu/riscv/rtems/score/cpu_asm.h +++ /dev/null @@ -1,90 +0,0 @@ -/** - * @file - * - * @brief riscv32 Assembly File - * - * Very loose template for an include file for the cpu_asm.? file - * if it is implemented as a ".S" file (preprocessed by cpp) instead - * of a ".s" file (preprocessed by gm4 or gasp). - */ - -/* - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _RTEMS_SCORE_CPU_ASM_H -#define _RTEMS_SCORE_CPU_ASM_H - -/* pull in the generated offsets */ - -/* -#include -*/ - -/* - * Hardware General Registers - */ - -/* put something here */ - -/* - * Hardware Floating Point Registers - */ - -/* put something here */ - -/* - * Hardware Control Registers - */ - -/* put something here */ - -/* - * Calling Convention - */ - -/* put something here */ - -/* - * Temporary registers - */ - -/* put something here */ - -/* - * Floating Point Registers - SW Conventions - */ - -/* put something here */ - -/* - * Temporary floating point registers - */ - -/* put something here */ - -#endif - -/* end of file */ diff --git a/cpukit/score/cpu/riscv/rtems/score/cpuatomic.h b/cpukit/score/cpu/riscv/rtems/score/cpuatomic.h deleted file mode 100644 index 8ee9606b44..0000000000 --- a/cpukit/score/cpu/riscv/rtems/score/cpuatomic.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * COPYRIGHT (c) 2012-2013 Deng Hengyi. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _RTEMS_SCORE_ATOMIC_CPU_H -#define _RTEMS_SCORE_ATOMIC_CPU_H - -#include - -#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/riscv/rtems/score/cpuimpl.h b/cpukit/score/cpu/riscv/rtems/score/cpuimpl.h deleted file mode 100644 index 3904c84bf9..0000000000 --- a/cpukit/score/cpu/riscv/rtems/score/cpuimpl.h +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @file - * - * @brief CPU Port Implementation API - */ - -/* - * Copyright (c) 2013 embedded brains GmbH - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _RTEMS_SCORE_CPUIMPL_H -#define _RTEMS_SCORE_CPUIMPL_H - -#include - -#define CPU_PER_CPU_CONTROL_SIZE 0 - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* ASM */ - -#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/riscv/rtems/score/riscv-utility.h b/cpukit/score/cpu/riscv/rtems/score/riscv-utility.h deleted file mode 100644 index dc4836bee2..0000000000 --- a/cpukit/score/cpu/riscv/rtems/score/riscv-utility.h +++ /dev/null @@ -1,1526 +0,0 @@ -/* Copyright (c) 2013, The Regents of the University of California (Regents). - * All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Regents nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, - * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST - * PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF - * REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO,THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED - * HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE - * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - */ - -/** - * @file - * - * @brief RISCV utility - */ -/* - * COPYRIGHT (c) 2015 Hesham Almatary - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -/* This file is copied from riscv-tools/encoding.h with additions/modifications to work - * with RTEMS. - */ -#ifndef _RTEMS_SCORE_RISCV_UTILITY_H -#define _RTEMS_SCORE_RISCV_UTILITY_H - -#define MSTATUS_UIE 0x00000001 -#define MSTATUS_SIE 0x00000002 -#define MSTATUS_HIE 0x00000004 -#define MSTATUS_MIE 0x00000008 -#define MSTATUS_UPIE 0x00000010 -#define MSTATUS_SPIE 0x00000020 -#define MSTATUS_HPIE 0x00000040 -#define MSTATUS_MPIE 0x00000080 -#define MSTATUS_SPP 0x00000100 -#define MSTATUS_HPP 0x00000600 -#define MSTATUS_MPP 0x00001800 -#define MSTATUS_FS 0x00006000 -#define MSTATUS_XS 0x00018000 -#define MSTATUS_MPRV 0x00020000 -#define MSTATUS_SUM 0x00040000 -#define MSTATUS_MXR 0x00080000 -#define MSTATUS_TVM 0x00100000 -#define MSTATUS_TW 0x00200000 -#define MSTATUS_TSR 0x00400000 -#define MSTATUS32_SD 0x80000000 -#define MSTATUS64_SD 0x8000000000000000 - -#define SSTATUS_UIE 0x00000001 -#define SSTATUS_SIE 0x00000002 -#define SSTATUS_UPIE 0x00000010 -#define SSTATUS_SPIE 0x00000020 -#define SSTATUS_SPP 0x00000100 -#define SSTATUS_FS 0x00006000 -#define SSTATUS_XS 0x00018000 -#define SSTATUS_SUM 0x00040000 -#define SSTATUS_MXR 0x00080000 -#define SSTATUS32_SD 0x80000000 -#define SSTATUS64_SD 0x8000000000000000 - -#define DCSR_XDEBUGVER (3U<<30) -#define DCSR_NDRESET (1<<29) -#define DCSR_FULLRESET (1<<28) -#define DCSR_EBREAKM (1<<15) -#define DCSR_EBREAKH (1<<14) -#define DCSR_EBREAKS (1<<13) -#define DCSR_EBREAKU (1<<12) -#define DCSR_STOPCYCLE (1<<10) -#define DCSR_STOPTIME (1<<9) -#define DCSR_CAUSE (7<<6) -#define DCSR_DEBUGINT (1<<5) -#define DCSR_HALT (1<<3) -#define DCSR_STEP (1<<2) -#define DCSR_PRV (3<<0) - -#define DCSR_CAUSE_NONE 0 -#define DCSR_CAUSE_SWBP 1 -#define DCSR_CAUSE_HWBP 2 -#define DCSR_CAUSE_DEBUGINT 3 -#define DCSR_CAUSE_STEP 4 -#define DCSR_CAUSE_HALT 5 - -#define MCONTROL_TYPE(xlen) (0xfULL<<((xlen)-4)) -#define MCONTROL_DMODE(xlen) (1ULL<<((xlen)-5)) -#define MCONTROL_MASKMAX(xlen) (0x3fULL<<((xlen)-11)) - -#define MCONTROL_SELECT (1<<19) -#define MCONTROL_TIMING (1<<18) -#define MCONTROL_ACTION (0x3f<<12) -#define MCONTROL_CHAIN (1<<11) -#define MCONTROL_MATCH (0xf<<7) -#define MCONTROL_M (1<<6) -#define MCONTROL_H (1<<5) -#define MCONTROL_S (1<<4) -#define MCONTROL_U (1<<3) -#define MCONTROL_EXECUTE (1<<2) -#define MCONTROL_STORE (1<<1) -#define MCONTROL_LOAD (1<<0) - -#define MCONTROL_TYPE_NONE 0 -#define MCONTROL_TYPE_MATCH 2 - -#define MCONTROL_ACTION_DEBUG_EXCEPTION 0 -#define MCONTROL_ACTION_DEBUG_MODE 1 -#define MCONTROL_ACTION_TRACE_START 2 -#define MCONTROL_ACTION_TRACE_STOP 3 -#define MCONTROL_ACTION_TRACE_EMIT 4 - -#define MCONTROL_MATCH_EQUAL 0 -#define MCONTROL_MATCH_NAPOT 1 -#define MCONTROL_MATCH_GE 2 -#define MCONTROL_MATCH_LT 3 -#define MCONTROL_MATCH_MASK_LOW 4 -#define MCONTROL_MATCH_MASK_HIGH 5 - -#define MIP_SSIP (1 << IRQ_S_SOFT) -#define MIP_HSIP (1 << IRQ_H_SOFT) -#define MIP_MSIP (1 << IRQ_M_SOFT) -#define MIP_STIP (1 << IRQ_S_TIMER) -#define MIP_HTIP (1 << IRQ_H_TIMER) -#define MIP_MTIP (1 << IRQ_M_TIMER) -#define MIP_SEIP (1 << IRQ_S_EXT) -#define MIP_HEIP (1 << IRQ_H_EXT) -#define MIP_MEIP (1 << IRQ_M_EXT) - -#define SIP_SSIP MIP_SSIP -#define SIP_STIP MIP_STIP - -#define PRV_U 0 -#define PRV_S 1 -#define PRV_H 2 -#define PRV_M 3 - -#define SPTBR32_MODE 0x80000000 -#define SPTBR32_ASID 0x7FC00000 -#define SPTBR32_PPN 0x003FFFFF -#define SPTBR64_MODE 0xF000000000000000 -#define SPTBR64_ASID 0x0FFFF00000000000 -#define SPTBR64_PPN 0x00000FFFFFFFFFFF - -#define SPTBR_MODE_OFF 0 -#define SPTBR_MODE_SV32 1 -#define SPTBR_MODE_SV39 8 -#define SPTBR_MODE_SV48 9 -#define SPTBR_MODE_SV57 10 -#define SPTBR_MODE_SV64 11 - -#define PMP_R 0x01 -#define PMP_W 0x02 -#define PMP_X 0x04 -#define PMP_A 0x18 -#define PMP_L 0x80 -#define PMP_SHIFT 2 - -#define PMP_TOR 0x08 -#define PMP_NA4 0x10 -#define PMP_NAPOT 0x18 - -#define IRQ_S_SOFT 1 -#define IRQ_H_SOFT 2 -#define IRQ_M_SOFT 3 -#define IRQ_S_TIMER 5 -#define IRQ_H_TIMER 6 -#define IRQ_M_TIMER 7 -#define IRQ_S_EXT 9 -#define IRQ_H_EXT 10 -#define IRQ_M_EXT 11 -#define IRQ_COP 12 -#define IRQ_HOST 13 - -#define DEFAULT_RSTVEC 0x00001000 -#define CLINT_BASE 0x02000000 -#define CLINT_SIZE 0x000c0000 -#define EXT_IO_BASE 0x40000000 -#define DRAM_BASE 0x80000000 - -// page table entry (PTE) fields -#define PTE_V 0x001 // Valid -#define PTE_R 0x002 // Read -#define PTE_W 0x004 // Write -#define PTE_X 0x008 // Execute -#define PTE_U 0x010 // User -#define PTE_G 0x020 // Global -#define PTE_A 0x040 // Accessed -#define PTE_D 0x080 // Dirty -#define PTE_SOFT 0x300 // Reserved for Software - -#define PTE_PPN_SHIFT 10 - -#define PTE_TABLE(PTE) (((PTE) & (PTE_V | PTE_R | PTE_W | PTE_X)) == PTE_V) - -#ifdef __riscv - -#if __riscv_xlen == 64 -# define MSTATUS_SD MSTATUS64_SD -# define SSTATUS_SD SSTATUS64_SD -# define RISCV_PGLEVEL_BITS 9 -# define SPTBR_MODE SPTBR64_MODE -#else -# define MSTATUS_SD MSTATUS32_SD -# define SSTATUS_SD SSTATUS32_SD -# define RISCV_PGLEVEL_BITS 10 -# define SPTBR_MODE SPTBR32_MODE -#endif -#define RISCV_PGSHIFT 12 -#define RISCV_PGSIZE (1 << RISCV_PGSHIFT) - -#ifndef __ASSEMBLER__ - -/** - * @brief Priv Mode registers definitions. - * - * @see RISC-V priv-spec 1.10. - */ -typedef enum { - RISCV_USER_INTERRUPT = 0, - RISCV_SUPERVISOR_SW_INTERRUPT = 1, - RISCV_MACHINE_SW_INTERRUPT = 3, - RISCV_USER_TIMER_INTERRUPT = 4, - RISCV_SUPERVISOR_TIMER_INTERRUPT = 4, - RISCV_MACHINE_TIMER_INTERRUPT = 7, - RISCV_USER_EXTERNAL_INTERRUPT = 8, - RISCV_SUPERVISOR_EXTERNAL_INTERRUPT = 9, - RISCV_MACHINE_EXTERNAL_INTERRUPT = 11 -} RISCV_Symbolic_interrupt_name; - -#ifdef __GNUC__ - -#define read_csr(reg) ({ unsigned long __tmp; \ - asm volatile ("csrr %0, " #reg : "=r"(__tmp)); \ - __tmp; }) - -#define write_csr(reg, val) ({ \ - asm volatile ("csrw " #reg ", %0" :: "rK"(val)); }) - -#define swap_csr(reg, val) ({ unsigned long __tmp; \ - asm volatile ("csrrw %0, " #reg ", %1" : "=r"(__tmp) : "rK"(val)); \ - __tmp; }) - -#define set_csr(reg, bit) ({ unsigned long __tmp; \ - asm volatile ("csrrs %0, " #reg ", %1" : "=r"(__tmp) : "rK"(bit)); \ - __tmp; }) - -#define clear_csr(reg, bit) ({ unsigned long __tmp; \ - asm volatile ("csrrc %0, " #reg ", %1" : "=r"(__tmp) : "rK"(bit)); \ - __tmp; }) - -#define rdtime() read_csr(time) -#define rdcycle() read_csr(cycle) -#define rdinstret() read_csr(instret) - -#endif - -#endif - -#endif - -#endif -/* Automatically generated by parse-opcodes. */ -#ifndef RISCV_ENCODING_H -#define RISCV_ENCODING_H -#define MATCH_BEQ 0x63 -#define MASK_BEQ 0x707f -#define MATCH_BNE 0x1063 -#define MASK_BNE 0x707f -#define MATCH_BLT 0x4063 -#define MASK_BLT 0x707f -#define MATCH_BGE 0x5063 -#define MASK_BGE 0x707f -#define MATCH_BLTU 0x6063 -#define MASK_BLTU 0x707f -#define MATCH_BGEU 0x7063 -#define MASK_BGEU 0x707f -#define MATCH_JALR 0x67 -#define MASK_JALR 0x707f -#define MATCH_JAL 0x6f -#define MASK_JAL 0x7f -#define MATCH_LUI 0x37 -#define MASK_LUI 0x7f -#define MATCH_AUIPC 0x17 -#define MASK_AUIPC 0x7f -#define MATCH_ADDI 0x13 -#define MASK_ADDI 0x707f -#define MATCH_SLLI 0x1013 -#define MASK_SLLI 0xfc00707f -#define MATCH_SLTI 0x2013 -#define MASK_SLTI 0x707f -#define MATCH_SLTIU 0x3013 -#define MASK_SLTIU 0x707f -#define MATCH_XORI 0x4013 -#define MASK_XORI 0x707f -#define MATCH_SRLI 0x5013 -#define MASK_SRLI 0xfc00707f -#define MATCH_SRAI 0x40005013 -#define MASK_SRAI 0xfc00707f -#define MATCH_ORI 0x6013 -#define MASK_ORI 0x707f -#define MATCH_ANDI 0x7013 -#define MASK_ANDI 0x707f -#define MATCH_ADD 0x33 -#define MASK_ADD 0xfe00707f -#define MATCH_SUB 0x40000033 -#define MASK_SUB 0xfe00707f -#define MATCH_SLL 0x1033 -#define MASK_SLL 0xfe00707f -#define MATCH_SLT 0x2033 -#define MASK_SLT 0xfe00707f -#define MATCH_SLTU 0x3033 -#define MASK_SLTU 0xfe00707f -#define MATCH_XOR 0x4033 -#define MASK_XOR 0xfe00707f -#define MATCH_SRL 0x5033 -#define MASK_SRL 0xfe00707f -#define MATCH_SRA 0x40005033 -#define MASK_SRA 0xfe00707f -#define MATCH_OR 0x6033 -#define MASK_OR 0xfe00707f -#define MATCH_AND 0x7033 -#define MASK_AND 0xfe00707f -#define MATCH_ADDIW 0x1b -#define MASK_ADDIW 0x707f -#define MATCH_SLLIW 0x101b -#define MASK_SLLIW 0xfe00707f -#define MATCH_SRLIW 0x501b -#define MASK_SRLIW 0xfe00707f -#define MATCH_SRAIW 0x4000501b -#define MASK_SRAIW 0xfe00707f -#define MATCH_ADDW 0x3b -#define MASK_ADDW 0xfe00707f -#define MATCH_SUBW 0x4000003b -#define MASK_SUBW 0xfe00707f -#define MATCH_SLLW 0x103b -#define MASK_SLLW 0xfe00707f -#define MATCH_SRLW 0x503b -#define MASK_SRLW 0xfe00707f -#define MATCH_SRAW 0x4000503b -#define MASK_SRAW 0xfe00707f -#define MATCH_LB 0x3 -#define MASK_LB 0x707f -#define MATCH_LH 0x1003 -#define MASK_LH 0x707f -#define MATCH_LW 0x2003 -#define MASK_LW 0x707f -#define MATCH_LD 0x3003 -#define MASK_LD 0x707f -#define MATCH_LBU 0x4003 -#define MASK_LBU 0x707f -#define MATCH_LHU 0x5003 -#define MASK_LHU 0x707f -#define MATCH_LWU 0x6003 -#define MASK_LWU 0x707f -#define MATCH_SB 0x23 -#define MASK_SB 0x707f -#define MATCH_SH 0x1023 -#define MASK_SH 0x707f -#define MATCH_SW 0x2023 -#define MASK_SW 0x707f -#define MATCH_SD 0x3023 -#define MASK_SD 0x707f -#define MATCH_FENCE 0xf -#define MASK_FENCE 0x707f -#define MATCH_FENCE_I 0x100f -#define MASK_FENCE_I 0x707f -#define MATCH_MUL 0x2000033 -#define MASK_MUL 0xfe00707f -#define MATCH_MULH 0x2001033 -#define MASK_MULH 0xfe00707f -#define MATCH_MULHSU 0x2002033 -#define MASK_MULHSU 0xfe00707f -#define MATCH_MULHU 0x2003033 -#define MASK_MULHU 0xfe00707f -#define MATCH_DIV 0x2004033 -#define MASK_DIV 0xfe00707f -#define MATCH_DIVU 0x2005033 -#define MASK_DIVU 0xfe00707f -#define MATCH_REM 0x2006033 -#define MASK_REM 0xfe00707f -#define MATCH_REMU 0x2007033 -#define MASK_REMU 0xfe00707f -#define MATCH_MULW 0x200003b -#define MASK_MULW 0xfe00707f -#define MATCH_DIVW 0x200403b -#define MASK_DIVW 0xfe00707f -#define MATCH_DIVUW 0x200503b -#define MASK_DIVUW 0xfe00707f -#define MATCH_REMW 0x200603b -#define MASK_REMW 0xfe00707f -#define MATCH_REMUW 0x200703b -#define MASK_REMUW 0xfe00707f -#define MATCH_AMOADD_W 0x202f -#define MASK_AMOADD_W 0xf800707f -#define MATCH_AMOXOR_W 0x2000202f -#define MASK_AMOXOR_W 0xf800707f -#define MATCH_AMOOR_W 0x4000202f -#define MASK_AMOOR_W 0xf800707f -#define MATCH_AMOAND_W 0x6000202f -#define MASK_AMOAND_W 0xf800707f -#define MATCH_AMOMIN_W 0x8000202f -#define MASK_AMOMIN_W 0xf800707f -#define MATCH_AMOMAX_W 0xa000202f -#define MASK_AMOMAX_W 0xf800707f -#define MATCH_AMOMINU_W 0xc000202f -#define MASK_AMOMINU_W 0xf800707f -#define MATCH_AMOMAXU_W 0xe000202f -#define MASK_AMOMAXU_W 0xf800707f -#define MATCH_AMOSWAP_W 0x800202f -#define MASK_AMOSWAP_W 0xf800707f -#define MATCH_LR_W 0x1000202f -#define MASK_LR_W 0xf9f0707f -#define MATCH_SC_W 0x1800202f -#define MASK_SC_W 0xf800707f -#define MATCH_AMOADD_D 0x302f -#define MASK_AMOADD_D 0xf800707f -#define MATCH_AMOXOR_D 0x2000302f -#define MASK_AMOXOR_D 0xf800707f -#define MATCH_AMOOR_D 0x4000302f -#define MASK_AMOOR_D 0xf800707f -#define MATCH_AMOAND_D 0x6000302f -#define MASK_AMOAND_D 0xf800707f -#define MATCH_AMOMIN_D 0x8000302f -#define MASK_AMOMIN_D 0xf800707f -#define MATCH_AMOMAX_D 0xa000302f -#define MASK_AMOMAX_D 0xf800707f -#define MATCH_AMOMINU_D 0xc000302f -#define MASK_AMOMINU_D 0xf800707f -#define MATCH_AMOMAXU_D 0xe000302f -#define MASK_AMOMAXU_D 0xf800707f -#define MATCH_AMOSWAP_D 0x800302f -#define MASK_AMOSWAP_D 0xf800707f -#define MATCH_LR_D 0x1000302f -#define MASK_LR_D 0xf9f0707f -#define MATCH_SC_D 0x1800302f -#define MASK_SC_D 0xf800707f -#define MATCH_ECALL 0x73 -#define MASK_ECALL 0xffffffff -#define MATCH_EBREAK 0x100073 -#define MASK_EBREAK 0xffffffff -#define MATCH_URET 0x200073 -#define MASK_URET 0xffffffff -#define MATCH_SRET 0x10200073 -#define MASK_SRET 0xffffffff -#define MATCH_MRET 0x30200073 -#define MASK_MRET 0xffffffff -#define MATCH_DRET 0x7b200073 -#define MASK_DRET 0xffffffff -#define MATCH_SFENCE_VMA 0x12000073 -#define MASK_SFENCE_VMA 0xfe007fff -#define MATCH_WFI 0x10500073 -#define MASK_WFI 0xffffffff -#define MATCH_CSRRW 0x1073 -#define MASK_CSRRW 0x707f -#define MATCH_CSRRS 0x2073 -#define MASK_CSRRS 0x707f -#define MATCH_CSRRC 0x3073 -#define MASK_CSRRC 0x707f -#define MATCH_CSRRWI 0x5073 -#define MASK_CSRRWI 0x707f -#define MATCH_CSRRSI 0x6073 -#define MASK_CSRRSI 0x707f -#define MATCH_CSRRCI 0x7073 -#define MASK_CSRRCI 0x707f -#define MATCH_FADD_S 0x53 -#define MASK_FADD_S 0xfe00007f -#define MATCH_FSUB_S 0x8000053 -#define MASK_FSUB_S 0xfe00007f -#define MATCH_FMUL_S 0x10000053 -#define MASK_FMUL_S 0xfe00007f -#define MATCH_FDIV_S 0x18000053 -#define MASK_FDIV_S 0xfe00007f -#define MATCH_FSGNJ_S 0x20000053 -#define MASK_FSGNJ_S 0xfe00707f -#define MATCH_FSGNJN_S 0x20001053 -#define MASK_FSGNJN_S 0xfe00707f -#define MATCH_FSGNJX_S 0x20002053 -#define MASK_FSGNJX_S 0xfe00707f -#define MATCH_FMIN_S 0x28000053 -#define MASK_FMIN_S 0xfe00707f -#define MATCH_FMAX_S 0x28001053 -#define MASK_FMAX_S 0xfe00707f -#define MATCH_FSQRT_S 0x58000053 -#define MASK_FSQRT_S 0xfff0007f -#define MATCH_FADD_D 0x2000053 -#define MASK_FADD_D 0xfe00007f -#define MATCH_FSUB_D 0xa000053 -#define MASK_FSUB_D 0xfe00007f -#define MATCH_FMUL_D 0x12000053 -#define MASK_FMUL_D 0xfe00007f -#define MATCH_FDIV_D 0x1a000053 -#define MASK_FDIV_D 0xfe00007f -#define MATCH_FSGNJ_D 0x22000053 -#define MASK_FSGNJ_D 0xfe00707f -#define MATCH_FSGNJN_D 0x22001053 -#define MASK_FSGNJN_D 0xfe00707f -#define MATCH_FSGNJX_D 0x22002053 -#define MASK_FSGNJX_D 0xfe00707f -#define MATCH_FMIN_D 0x2a000053 -#define MASK_FMIN_D 0xfe00707f -#define MATCH_FMAX_D 0x2a001053 -#define MASK_FMAX_D 0xfe00707f -#define MATCH_FCVT_S_D 0x40100053 -#define MASK_FCVT_S_D 0xfff0007f -#define MATCH_FCVT_D_S 0x42000053 -#define MASK_FCVT_D_S 0xfff0007f -#define MATCH_FSQRT_D 0x5a000053 -#define MASK_FSQRT_D 0xfff0007f -#define MATCH_FADD_Q 0x6000053 -#define MASK_FADD_Q 0xfe00007f -#define MATCH_FSUB_Q 0xe000053 -#define MASK_FSUB_Q 0xfe00007f -#define MATCH_FMUL_Q 0x16000053 -#define MASK_FMUL_Q 0xfe00007f -#define MATCH_FDIV_Q 0x1e000053 -#define MASK_FDIV_Q 0xfe00007f -#define MATCH_FSGNJ_Q 0x26000053 -#define MASK_FSGNJ_Q 0xfe00707f -#define MATCH_FSGNJN_Q 0x26001053 -#define MASK_FSGNJN_Q 0xfe00707f -#define MATCH_FSGNJX_Q 0x26002053 -#define MASK_FSGNJX_Q 0xfe00707f -#define MATCH_FMIN_Q 0x2e000053 -#define MASK_FMIN_Q 0xfe00707f -#define MATCH_FMAX_Q 0x2e001053 -#define MASK_FMAX_Q 0xfe00707f -#define MATCH_FCVT_S_Q 0x40300053 -#define MASK_FCVT_S_Q 0xfff0007f -#define MATCH_FCVT_Q_S 0x46000053 -#define MASK_FCVT_Q_S 0xfff0007f -#define MATCH_FCVT_D_Q 0x42300053 -#define MASK_FCVT_D_Q 0xfff0007f -#define MATCH_FCVT_Q_D 0x46100053 -#define MASK_FCVT_Q_D 0xfff0007f -#define MATCH_FSQRT_Q 0x5e000053 -#define MASK_FSQRT_Q 0xfff0007f -#define MATCH_FLE_S 0xa0000053 -#define MASK_FLE_S 0xfe00707f -#define MATCH_FLT_S 0xa0001053 -#define MASK_FLT_S 0xfe00707f -#define MATCH_FEQ_S 0xa0002053 -#define MASK_FEQ_S 0xfe00707f -#define MATCH_FLE_D 0xa2000053 -#define MASK_FLE_D 0xfe00707f -#define MATCH_FLT_D 0xa2001053 -#define MASK_FLT_D 0xfe00707f -#define MATCH_FEQ_D 0xa2002053 -#define MASK_FEQ_D 0xfe00707f -#define MATCH_FLE_Q 0xa6000053 -#define MASK_FLE_Q 0xfe00707f -#define MATCH_FLT_Q 0xa6001053 -#define MASK_FLT_Q 0xfe00707f -#define MATCH_FEQ_Q 0xa6002053 -#define MASK_FEQ_Q 0xfe00707f -#define MATCH_FCVT_W_S 0xc0000053 -#define MASK_FCVT_W_S 0xfff0007f -#define MATCH_FCVT_WU_S 0xc0100053 -#define MASK_FCVT_WU_S 0xfff0007f -#define MATCH_FCVT_L_S 0xc0200053 -#define MASK_FCVT_L_S 0xfff0007f -#define MATCH_FCVT_LU_S 0xc0300053 -#define MASK_FCVT_LU_S 0xfff0007f -#define MATCH_FMV_X_W 0xe0000053 -#define MASK_FMV_X_W 0xfff0707f -#define MATCH_FCLASS_S 0xe0001053 -#define MASK_FCLASS_S 0xfff0707f -#define MATCH_FCVT_W_D 0xc2000053 -#define MASK_FCVT_W_D 0xfff0007f -#define MATCH_FCVT_WU_D 0xc2100053 -#define MASK_FCVT_WU_D 0xfff0007f -#define MATCH_FCVT_L_D 0xc2200053 -#define MASK_FCVT_L_D 0xfff0007f -#define MATCH_FCVT_LU_D 0xc2300053 -#define MASK_FCVT_LU_D 0xfff0007f -#define MATCH_FMV_X_D 0xe2000053 -#define MASK_FMV_X_D 0xfff0707f -#define MATCH_FCLASS_D 0xe2001053 -#define MASK_FCLASS_D 0xfff0707f -#define MATCH_FCVT_W_Q 0xc6000053 -#define MASK_FCVT_W_Q 0xfff0007f -#define MATCH_FCVT_WU_Q 0xc6100053 -#define MASK_FCVT_WU_Q 0xfff0007f -#define MATCH_FCVT_L_Q 0xc6200053 -#define MASK_FCVT_L_Q 0xfff0007f -#define MATCH_FCVT_LU_Q 0xc6300053 -#define MASK_FCVT_LU_Q 0xfff0007f -#define MATCH_FMV_X_Q 0xe6000053 -#define MASK_FMV_X_Q 0xfff0707f -#define MATCH_FCLASS_Q 0xe6001053 -#define MASK_FCLASS_Q 0xfff0707f -#define MATCH_FCVT_S_W 0xd0000053 -#define MASK_FCVT_S_W 0xfff0007f -#define MATCH_FCVT_S_WU 0xd0100053 -#define MASK_FCVT_S_WU 0xfff0007f -#define MATCH_FCVT_S_L 0xd0200053 -#define MASK_FCVT_S_L 0xfff0007f -#define MATCH_FCVT_S_LU 0xd0300053 -#define MASK_FCVT_S_LU 0xfff0007f -#define MATCH_FMV_W_X 0xf0000053 -#define MASK_FMV_W_X 0xfff0707f -#define MATCH_FCVT_D_W 0xd2000053 -#define MASK_FCVT_D_W 0xfff0007f -#define MATCH_FCVT_D_WU 0xd2100053 -#define MASK_FCVT_D_WU 0xfff0007f -#define MATCH_FCVT_D_L 0xd2200053 -#define MASK_FCVT_D_L 0xfff0007f -#define MATCH_FCVT_D_LU 0xd2300053 -#define MASK_FCVT_D_LU 0xfff0007f -#define MATCH_FMV_D_X 0xf2000053 -#define MASK_FMV_D_X 0xfff0707f -#define MATCH_FCVT_Q_W 0xd6000053 -#define MASK_FCVT_Q_W 0xfff0007f -#define MATCH_FCVT_Q_WU 0xd6100053 -#define MASK_FCVT_Q_WU 0xfff0007f -#define MATCH_FCVT_Q_L 0xd6200053 -#define MASK_FCVT_Q_L 0xfff0007f -#define MATCH_FCVT_Q_LU 0xd6300053 -#define MASK_FCVT_Q_LU 0xfff0007f -#define MATCH_FMV_Q_X 0xf6000053 -#define MASK_FMV_Q_X 0xfff0707f -#define MATCH_FLW 0x2007 -#define MASK_FLW 0x707f -#define MATCH_FLD 0x3007 -#define MASK_FLD 0x707f -#define MATCH_FLQ 0x4007 -#define MASK_FLQ 0x707f -#define MATCH_FSW 0x2027 -#define MASK_FSW 0x707f -#define MATCH_FSD 0x3027 -#define MASK_FSD 0x707f -#define MATCH_FSQ 0x4027 -#define MASK_FSQ 0x707f -#define MATCH_FMADD_S 0x43 -#define MASK_FMADD_S 0x600007f -#define MATCH_FMSUB_S 0x47 -#define MASK_FMSUB_S 0x600007f -#define MATCH_FNMSUB_S 0x4b -#define MASK_FNMSUB_S 0x600007f -#define MATCH_FNMADD_S 0x4f -#define MASK_FNMADD_S 0x600007f -#define MATCH_FMADD_D 0x2000043 -#define MASK_FMADD_D 0x600007f -#define MATCH_FMSUB_D 0x2000047 -#define MASK_FMSUB_D 0x600007f -#define MATCH_FNMSUB_D 0x200004b -#define MASK_FNMSUB_D 0x600007f -#define MATCH_FNMADD_D 0x200004f -#define MASK_FNMADD_D 0x600007f -#define MATCH_FMADD_Q 0x6000043 -#define MASK_FMADD_Q 0x600007f -#define MATCH_FMSUB_Q 0x6000047 -#define MASK_FMSUB_Q 0x600007f -#define MATCH_FNMSUB_Q 0x600004b -#define MASK_FNMSUB_Q 0x600007f -#define MATCH_FNMADD_Q 0x600004f -#define MASK_FNMADD_Q 0x600007f -#define MATCH_C_NOP 0x1 -#define MASK_C_NOP 0xffff -#define MATCH_C_ADDI16SP 0x6101 -#define MASK_C_ADDI16SP 0xef83 -#define MATCH_C_JR 0x8002 -#define MASK_C_JR 0xf07f -#define MATCH_C_JALR 0x9002 -#define MASK_C_JALR 0xf07f -#define MATCH_C_EBREAK 0x9002 -#define MASK_C_EBREAK 0xffff -#define MATCH_C_LD 0x6000 -#define MASK_C_LD 0xe003 -#define MATCH_C_SD 0xe000 -#define MASK_C_SD 0xe003 -#define MATCH_C_ADDIW 0x2001 -#define MASK_C_ADDIW 0xe003 -#define MATCH_C_LDSP 0x6002 -#define MASK_C_LDSP 0xe003 -#define MATCH_C_SDSP 0xe002 -#define MASK_C_SDSP 0xe003 -#define MATCH_C_ADDI4SPN 0x0 -#define MASK_C_ADDI4SPN 0xe003 -#define MATCH_C_FLD 0x2000 -#define MASK_C_FLD 0xe003 -#define MATCH_C_LW 0x4000 -#define MASK_C_LW 0xe003 -#define MATCH_C_FLW 0x6000 -#define MASK_C_FLW 0xe003 -#define MATCH_C_FSD 0xa000 -#define MASK_C_FSD 0xe003 -#define MATCH_C_SW 0xc000 -#define MASK_C_SW 0xe003 -#define MATCH_C_FSW 0xe000 -#define MASK_C_FSW 0xe003 -#define MATCH_C_ADDI 0x1 -#define MASK_C_ADDI 0xe003 -#define MATCH_C_JAL 0x2001 -#define MASK_C_JAL 0xe003 -#define MATCH_C_LI 0x4001 -#define MASK_C_LI 0xe003 -#define MATCH_C_LUI 0x6001 -#define MASK_C_LUI 0xe003 -#define MATCH_C_SRLI 0x8001 -#define MASK_C_SRLI 0xec03 -#define MATCH_C_SRAI 0x8401 -#define MASK_C_SRAI 0xec03 -#define MATCH_C_ANDI 0x8801 -#define MASK_C_ANDI 0xec03 -#define MATCH_C_SUB 0x8c01 -#define MASK_C_SUB 0xfc63 -#define MATCH_C_XOR 0x8c21 -#define MASK_C_XOR 0xfc63 -#define MATCH_C_OR 0x8c41 -#define MASK_C_OR 0xfc63 -#define MATCH_C_AND 0x8c61 -#define MASK_C_AND 0xfc63 -#define MATCH_C_SUBW 0x9c01 -#define MASK_C_SUBW 0xfc63 -#define MATCH_C_ADDW 0x9c21 -#define MASK_C_ADDW 0xfc63 -#define MATCH_C_J 0xa001 -#define MASK_C_J 0xe003 -#define MATCH_C_BEQZ 0xc001 -#define MASK_C_BEQZ 0xe003 -#define MATCH_C_BNEZ 0xe001 -#define MASK_C_BNEZ 0xe003 -#define MATCH_C_SLLI 0x2 -#define MASK_C_SLLI 0xe003 -#define MATCH_C_FLDSP 0x2002 -#define MASK_C_FLDSP 0xe003 -#define MATCH_C_LWSP 0x4002 -#define MASK_C_LWSP 0xe003 -#define MATCH_C_FLWSP 0x6002 -#define MASK_C_FLWSP 0xe003 -#define MATCH_C_MV 0x8002 -#define MASK_C_MV 0xf003 -#define MATCH_C_ADD 0x9002 -#define MASK_C_ADD 0xf003 -#define MATCH_C_FSDSP 0xa002 -#define MASK_C_FSDSP 0xe003 -#define MATCH_C_SWSP 0xc002 -#define MASK_C_SWSP 0xe003 -#define MATCH_C_FSWSP 0xe002 -#define MASK_C_FSWSP 0xe003 -#define MATCH_CUSTOM0 0xb -#define MASK_CUSTOM0 0x707f -#define MATCH_CUSTOM0_RS1 0x200b -#define MASK_CUSTOM0_RS1 0x707f -#define MATCH_CUSTOM0_RS1_RS2 0x300b -#define MASK_CUSTOM0_RS1_RS2 0x707f -#define MATCH_CUSTOM0_RD 0x400b -#define MASK_CUSTOM0_RD 0x707f -#define MATCH_CUSTOM0_RD_RS1 0x600b -#define MASK_CUSTOM0_RD_RS1 0x707f -#define MATCH_CUSTOM0_RD_RS1_RS2 0x700b -#define MASK_CUSTOM0_RD_RS1_RS2 0x707f -#define MATCH_CUSTOM1 0x2b -#define MASK_CUSTOM1 0x707f -#define MATCH_CUSTOM1_RS1 0x202b -#define MASK_CUSTOM1_RS1 0x707f -#define MATCH_CUSTOM1_RS1_RS2 0x302b -#define MASK_CUSTOM1_RS1_RS2 0x707f -#define MATCH_CUSTOM1_RD 0x402b -#define MASK_CUSTOM1_RD 0x707f -#define MATCH_CUSTOM1_RD_RS1 0x602b -#define MASK_CUSTOM1_RD_RS1 0x707f -#define MATCH_CUSTOM1_RD_RS1_RS2 0x702b -#define MASK_CUSTOM1_RD_RS1_RS2 0x707f -#define MATCH_CUSTOM2 0x5b -#define MASK_CUSTOM2 0x707f -#define MATCH_CUSTOM2_RS1 0x205b -#define MASK_CUSTOM2_RS1 0x707f -#define MATCH_CUSTOM2_RS1_RS2 0x305b -#define MASK_CUSTOM2_RS1_RS2 0x707f -#define MATCH_CUSTOM2_RD 0x405b -#define MASK_CUSTOM2_RD 0x707f -#define MATCH_CUSTOM2_RD_RS1 0x605b -#define MASK_CUSTOM2_RD_RS1 0x707f -#define MATCH_CUSTOM2_RD_RS1_RS2 0x705b -#define MASK_CUSTOM2_RD_RS1_RS2 0x707f -#define MATCH_CUSTOM3 0x7b -#define MASK_CUSTOM3 0x707f -#define MATCH_CUSTOM3_RS1 0x207b -#define MASK_CUSTOM3_RS1 0x707f -#define MATCH_CUSTOM3_RS1_RS2 0x307b -#define MASK_CUSTOM3_RS1_RS2 0x707f -#define MATCH_CUSTOM3_RD 0x407b -#define MASK_CUSTOM3_RD 0x707f -#define MATCH_CUSTOM3_RD_RS1 0x607b -#define MASK_CUSTOM3_RD_RS1 0x707f -#define MATCH_CUSTOM3_RD_RS1_RS2 0x707b -#define MASK_CUSTOM3_RD_RS1_RS2 0x707f -#define CSR_FFLAGS 0x1 -#define CSR_FRM 0x2 -#define CSR_FCSR 0x3 -#define CSR_CYCLE 0xc00 -#define CSR_TIME 0xc01 -#define CSR_INSTRET 0xc02 -#define CSR_HPMCOUNTER3 0xc03 -#define CSR_HPMCOUNTER4 0xc04 -#define CSR_HPMCOUNTER5 0xc05 -#define CSR_HPMCOUNTER6 0xc06 -#define CSR_HPMCOUNTER7 0xc07 -#define CSR_HPMCOUNTER8 0xc08 -#define CSR_HPMCOUNTER9 0xc09 -#define CSR_HPMCOUNTER10 0xc0a -#define CSR_HPMCOUNTER11 0xc0b -#define CSR_HPMCOUNTER12 0xc0c -#define CSR_HPMCOUNTER13 0xc0d -#define CSR_HPMCOUNTER14 0xc0e -#define CSR_HPMCOUNTER15 0xc0f -#define CSR_HPMCOUNTER16 0xc10 -#define CSR_HPMCOUNTER17 0xc11 -#define CSR_HPMCOUNTER18 0xc12 -#define CSR_HPMCOUNTER19 0xc13 -#define CSR_HPMCOUNTER20 0xc14 -#define CSR_HPMCOUNTER21 0xc15 -#define CSR_HPMCOUNTER22 0xc16 -#define CSR_HPMCOUNTER23 0xc17 -#define CSR_HPMCOUNTER24 0xc18 -#define CSR_HPMCOUNTER25 0xc19 -#define CSR_HPMCOUNTER26 0xc1a -#define CSR_HPMCOUNTER27 0xc1b -#define CSR_HPMCOUNTER28 0xc1c -#define CSR_HPMCOUNTER29 0xc1d -#define CSR_HPMCOUNTER30 0xc1e -#define CSR_HPMCOUNTER31 0xc1f -#define CSR_SSTATUS 0x100 -#define CSR_SIE 0x104 -#define CSR_STVEC 0x105 -#define CSR_SCOUNTEREN 0x106 -#define CSR_SSCRATCH 0x140 -#define CSR_SEPC 0x141 -#define CSR_SCAUSE 0x142 -#define CSR_SBADADDR 0x143 -#define CSR_SIP 0x144 -#define CSR_SPTBR 0x180 -#define CSR_MSTATUS 0x300 -#define CSR_MISA 0x301 -#define CSR_MEDELEG 0x302 -#define CSR_MIDELEG 0x303 -#define CSR_MIE 0x304 -#define CSR_MTVEC 0x305 -#define CSR_MCOUNTEREN 0x306 -#define CSR_MSCRATCH 0x340 -#define CSR_MEPC 0x341 -#define CSR_MCAUSE 0x342 -#define CSR_MBADADDR 0x343 -#define CSR_MIP 0x344 -#define CSR_PMPCFG0 0x3a0 -#define CSR_PMPCFG1 0x3a1 -#define CSR_PMPCFG2 0x3a2 -#define CSR_PMPCFG3 0x3a3 -#define CSR_PMPADDR0 0x3b0 -#define CSR_PMPADDR1 0x3b1 -#define CSR_PMPADDR2 0x3b2 -#define CSR_PMPADDR3 0x3b3 -#define CSR_PMPADDR4 0x3b4 -#define CSR_PMPADDR5 0x3b5 -#define CSR_PMPADDR6 0x3b6 -#define CSR_PMPADDR7 0x3b7 -#define CSR_PMPADDR8 0x3b8 -#define CSR_PMPADDR9 0x3b9 -#define CSR_PMPADDR10 0x3ba -#define CSR_PMPADDR11 0x3bb -#define CSR_PMPADDR12 0x3bc -#define CSR_PMPADDR13 0x3bd -#define CSR_PMPADDR14 0x3be -#define CSR_PMPADDR15 0x3bf -#define CSR_TSELECT 0x7a0 -#define CSR_TDATA1 0x7a1 -#define CSR_TDATA2 0x7a2 -#define CSR_TDATA3 0x7a3 -#define CSR_DCSR 0x7b0 -#define CSR_DPC 0x7b1 -#define CSR_DSCRATCH 0x7b2 -#define CSR_MCYCLE 0xb00 -#define CSR_MINSTRET 0xb02 -#define CSR_MHPMCOUNTER3 0xb03 -#define CSR_MHPMCOUNTER4 0xb04 -#define CSR_MHPMCOUNTER5 0xb05 -#define CSR_MHPMCOUNTER6 0xb06 -#define CSR_MHPMCOUNTER7 0xb07 -#define CSR_MHPMCOUNTER8 0xb08 -#define CSR_MHPMCOUNTER9 0xb09 -#define CSR_MHPMCOUNTER10 0xb0a -#define CSR_MHPMCOUNTER11 0xb0b -#define CSR_MHPMCOUNTER12 0xb0c -#define CSR_MHPMCOUNTER13 0xb0d -#define CSR_MHPMCOUNTER14 0xb0e -#define CSR_MHPMCOUNTER15 0xb0f -#define CSR_MHPMCOUNTER16 0xb10 -#define CSR_MHPMCOUNTER17 0xb11 -#define CSR_MHPMCOUNTER18 0xb12 -#define CSR_MHPMCOUNTER19 0xb13 -#define CSR_MHPMCOUNTER20 0xb14 -#define CSR_MHPMCOUNTER21 0xb15 -#define CSR_MHPMCOUNTER22 0xb16 -#define CSR_MHPMCOUNTER23 0xb17 -#define CSR_MHPMCOUNTER24 0xb18 -#define CSR_MHPMCOUNTER25 0xb19 -#define CSR_MHPMCOUNTER26 0xb1a -#define CSR_MHPMCOUNTER27 0xb1b -#define CSR_MHPMCOUNTER28 0xb1c -#define CSR_MHPMCOUNTER29 0xb1d -#define CSR_MHPMCOUNTER30 0xb1e -#define CSR_MHPMCOUNTER31 0xb1f -#define CSR_MHPMEVENT3 0x323 -#define CSR_MHPMEVENT4 0x324 -#define CSR_MHPMEVENT5 0x325 -#define CSR_MHPMEVENT6 0x326 -#define CSR_MHPMEVENT7 0x327 -#define CSR_MHPMEVENT8 0x328 -#define CSR_MHPMEVENT9 0x329 -#define CSR_MHPMEVENT10 0x32a -#define CSR_MHPMEVENT11 0x32b -#define CSR_MHPMEVENT12 0x32c -#define CSR_MHPMEVENT13 0x32d -#define CSR_MHPMEVENT14 0x32e -#define CSR_MHPMEVENT15 0x32f -#define CSR_MHPMEVENT16 0x330 -#define CSR_MHPMEVENT17 0x331 -#define CSR_MHPMEVENT18 0x332 -#define CSR_MHPMEVENT19 0x333 -#define CSR_MHPMEVENT20 0x334 -#define CSR_MHPMEVENT21 0x335 -#define CSR_MHPMEVENT22 0x336 -#define CSR_MHPMEVENT23 0x337 -#define CSR_MHPMEVENT24 0x338 -#define CSR_MHPMEVENT25 0x339 -#define CSR_MHPMEVENT26 0x33a -#define CSR_MHPMEVENT27 0x33b -#define CSR_MHPMEVENT28 0x33c -#define CSR_MHPMEVENT29 0x33d -#define CSR_MHPMEVENT30 0x33e -#define CSR_MHPMEVENT31 0x33f -#define CSR_MVENDORID 0xf11 -#define CSR_MARCHID 0xf12 -#define CSR_MIMPID 0xf13 -#define CSR_MHARTID 0xf14 -#define CSR_CYCLEH 0xc80 -#define CSR_TIMEH 0xc81 -#define CSR_INSTRETH 0xc82 -#define CSR_HPMCOUNTER3H 0xc83 -#define CSR_HPMCOUNTER4H 0xc84 -#define CSR_HPMCOUNTER5H 0xc85 -#define CSR_HPMCOUNTER6H 0xc86 -#define CSR_HPMCOUNTER7H 0xc87 -#define CSR_HPMCOUNTER8H 0xc88 -#define CSR_HPMCOUNTER9H 0xc89 -#define CSR_HPMCOUNTER10H 0xc8a -#define CSR_HPMCOUNTER11H 0xc8b -#define CSR_HPMCOUNTER12H 0xc8c -#define CSR_HPMCOUNTER13H 0xc8d -#define CSR_HPMCOUNTER14H 0xc8e -#define CSR_HPMCOUNTER15H 0xc8f -#define CSR_HPMCOUNTER16H 0xc90 -#define CSR_HPMCOUNTER17H 0xc91 -#define CSR_HPMCOUNTER18H 0xc92 -#define CSR_HPMCOUNTER19H 0xc93 -#define CSR_HPMCOUNTER20H 0xc94 -#define CSR_HPMCOUNTER21H 0xc95 -#define CSR_HPMCOUNTER22H 0xc96 -#define CSR_HPMCOUNTER23H 0xc97 -#define CSR_HPMCOUNTER24H 0xc98 -#define CSR_HPMCOUNTER25H 0xc99 -#define CSR_HPMCOUNTER26H 0xc9a -#define CSR_HPMCOUNTER27H 0xc9b -#define CSR_HPMCOUNTER28H 0xc9c -#define CSR_HPMCOUNTER29H 0xc9d -#define CSR_HPMCOUNTER30H 0xc9e -#define CSR_HPMCOUNTER31H 0xc9f -#define CSR_MCYCLEH 0xb80 -#define CSR_MINSTRETH 0xb82 -#define CSR_MHPMCOUNTER3H 0xb83 -#define CSR_MHPMCOUNTER4H 0xb84 -#define CSR_MHPMCOUNTER5H 0xb85 -#define CSR_MHPMCOUNTER6H 0xb86 -#define CSR_MHPMCOUNTER7H 0xb87 -#define CSR_MHPMCOUNTER8H 0xb88 -#define CSR_MHPMCOUNTER9H 0xb89 -#define CSR_MHPMCOUNTER10H 0xb8a -#define CSR_MHPMCOUNTER11H 0xb8b -#define CSR_MHPMCOUNTER12H 0xb8c -#define CSR_MHPMCOUNTER13H 0xb8d -#define CSR_MHPMCOUNTER14H 0xb8e -#define CSR_MHPMCOUNTER15H 0xb8f -#define CSR_MHPMCOUNTER16H 0xb90 -#define CSR_MHPMCOUNTER17H 0xb91 -#define CSR_MHPMCOUNTER18H 0xb92 -#define CSR_MHPMCOUNTER19H 0xb93 -#define CSR_MHPMCOUNTER20H 0xb94 -#define CSR_MHPMCOUNTER21H 0xb95 -#define CSR_MHPMCOUNTER22H 0xb96 -#define CSR_MHPMCOUNTER23H 0xb97 -#define CSR_MHPMCOUNTER24H 0xb98 -#define CSR_MHPMCOUNTER25H 0xb99 -#define CSR_MHPMCOUNTER26H 0xb9a -#define CSR_MHPMCOUNTER27H 0xb9b -#define CSR_MHPMCOUNTER28H 0xb9c -#define CSR_MHPMCOUNTER29H 0xb9d -#define CSR_MHPMCOUNTER30H 0xb9e -#define CSR_MHPMCOUNTER31H 0xb9f -#define CAUSE_MISALIGNED_FETCH 0x0 -#define CAUSE_FETCH_ACCESS 0x1 -#define CAUSE_ILLEGAL_INSTRUCTION 0x2 -#define CAUSE_BREAKPOINT 0x3 -#define CAUSE_MISALIGNED_LOAD 0x4 -#define CAUSE_LOAD_ACCESS 0x5 -#define CAUSE_MISALIGNED_STORE 0x6 -#define CAUSE_STORE_ACCESS 0x7 -#define CAUSE_USER_ECALL 0x8 -#define CAUSE_SUPERVISOR_ECALL 0x9 -#define CAUSE_HYPERVISOR_ECALL 0xa -#define CAUSE_MACHINE_ECALL 0xb -#define CAUSE_FETCH_PAGE_FAULT 0xc -#define CAUSE_LOAD_PAGE_FAULT 0xd -#define CAUSE_STORE_PAGE_FAULT 0xf -#endif -#ifdef DECLARE_INSN -DECLARE_INSN(beq, MATCH_BEQ, MASK_BEQ) -DECLARE_INSN(bne, MATCH_BNE, MASK_BNE) -DECLARE_INSN(blt, MATCH_BLT, MASK_BLT) -DECLARE_INSN(bge, MATCH_BGE, MASK_BGE) -DECLARE_INSN(bltu, MATCH_BLTU, MASK_BLTU) -DECLARE_INSN(bgeu, MATCH_BGEU, MASK_BGEU) -DECLARE_INSN(jalr, MATCH_JALR, MASK_JALR) -DECLARE_INSN(jal, MATCH_JAL, MASK_JAL) -DECLARE_INSN(lui, MATCH_LUI, MASK_LUI) -DECLARE_INSN(auipc, MATCH_AUIPC, MASK_AUIPC) -DECLARE_INSN(addi, MATCH_ADDI, MASK_ADDI) -DECLARE_INSN(slli, MATCH_SLLI, MASK_SLLI) -DECLARE_INSN(slti, MATCH_SLTI, MASK_SLTI) -DECLARE_INSN(sltiu, MATCH_SLTIU, MASK_SLTIU) -DECLARE_INSN(xori, MATCH_XORI, MASK_XORI) -DECLARE_INSN(srli, MATCH_SRLI, MASK_SRLI) -DECLARE_INSN(srai, MATCH_SRAI, MASK_SRAI) -DECLARE_INSN(ori, MATCH_ORI, MASK_ORI) -DECLARE_INSN(andi, MATCH_ANDI, MASK_ANDI) -DECLARE_INSN(add, MATCH_ADD, MASK_ADD) -DECLARE_INSN(sub, MATCH_SUB, MASK_SUB) -DECLARE_INSN(sll, MATCH_SLL, MASK_SLL) -DECLARE_INSN(slt, MATCH_SLT, MASK_SLT) -DECLARE_INSN(sltu, MATCH_SLTU, MASK_SLTU) -DECLARE_INSN(xor, MATCH_XOR, MASK_XOR) -DECLARE_INSN(srl, MATCH_SRL, MASK_SRL) -DECLARE_INSN(sra, MATCH_SRA, MASK_SRA) -DECLARE_INSN( or , MATCH_OR, MASK_OR) -DECLARE_INSN( and , MATCH_AND, MASK_AND) -DECLARE_INSN(addiw, MATCH_ADDIW, MASK_ADDIW) -DECLARE_INSN(slliw, MATCH_SLLIW, MASK_SLLIW) -DECLARE_INSN(srliw, MATCH_SRLIW, MASK_SRLIW) -DECLARE_INSN(sraiw, MATCH_SRAIW, MASK_SRAIW) -DECLARE_INSN(addw, MATCH_ADDW, MASK_ADDW) -DECLARE_INSN(subw, MATCH_SUBW, MASK_SUBW) -DECLARE_INSN(sllw, MATCH_SLLW, MASK_SLLW) -DECLARE_INSN(srlw, MATCH_SRLW, MASK_SRLW) -DECLARE_INSN(sraw, MATCH_SRAW, MASK_SRAW) -DECLARE_INSN(lb, MATCH_LB, MASK_LB) -DECLARE_INSN(lh, MATCH_LH, MASK_LH) -DECLARE_INSN(lw, MATCH_LW, MASK_LW) -DECLARE_INSN(ld, MATCH_LD, MASK_LD) -DECLARE_INSN(lbu, MATCH_LBU, MASK_LBU) -DECLARE_INSN(lhu, MATCH_LHU, MASK_LHU) -DECLARE_INSN(lwu, MATCH_LWU, MASK_LWU) -DECLARE_INSN(sb, MATCH_SB, MASK_SB) -DECLARE_INSN(sh, MATCH_SH, MASK_SH) -DECLARE_INSN(sw, MATCH_SW, MASK_SW) -DECLARE_INSN(sd, MATCH_SD, MASK_SD) -DECLARE_INSN(fence, MATCH_FENCE, MASK_FENCE) -DECLARE_INSN(fence_i, MATCH_FENCE_I, MASK_FENCE_I) -DECLARE_INSN(mul, MATCH_MUL, MASK_MUL) -DECLARE_INSN(mulh, MATCH_MULH, MASK_MULH) -DECLARE_INSN(mulhsu, MATCH_MULHSU, MASK_MULHSU) -DECLARE_INSN(mulhu, MATCH_MULHU, MASK_MULHU) -DECLARE_INSN(div, MATCH_DIV, MASK_DIV) -DECLARE_INSN(divu, MATCH_DIVU, MASK_DIVU) -DECLARE_INSN(rem, MATCH_REM, MASK_REM) -DECLARE_INSN(remu, MATCH_REMU, MASK_REMU) -DECLARE_INSN(mulw, MATCH_MULW, MASK_MULW) -DECLARE_INSN(divw, MATCH_DIVW, MASK_DIVW) -DECLARE_INSN(divuw, MATCH_DIVUW, MASK_DIVUW) -DECLARE_INSN(remw, MATCH_REMW, MASK_REMW) -DECLARE_INSN(remuw, MATCH_REMUW, MASK_REMUW) -DECLARE_INSN(amoadd_w, MATCH_AMOADD_W, MASK_AMOADD_W) -DECLARE_INSN(amoxor_w, MATCH_AMOXOR_W, MASK_AMOXOR_W) -DECLARE_INSN(amoor_w, MATCH_AMOOR_W, MASK_AMOOR_W) -DECLARE_INSN(amoand_w, MATCH_AMOAND_W, MASK_AMOAND_W) -DECLARE_INSN(amomin_w, MATCH_AMOMIN_W, MASK_AMOMIN_W) -DECLARE_INSN(amomax_w, MATCH_AMOMAX_W, MASK_AMOMAX_W) -DECLARE_INSN(amominu_w, MATCH_AMOMINU_W, MASK_AMOMINU_W) -DECLARE_INSN(amomaxu_w, MATCH_AMOMAXU_W, MASK_AMOMAXU_W) -DECLARE_INSN(amoswap_w, MATCH_AMOSWAP_W, MASK_AMOSWAP_W) -DECLARE_INSN(lr_w, MATCH_LR_W, MASK_LR_W) -DECLARE_INSN(sc_w, MATCH_SC_W, MASK_SC_W) -DECLARE_INSN(amoadd_d, MATCH_AMOADD_D, MASK_AMOADD_D) -DECLARE_INSN(amoxor_d, MATCH_AMOXOR_D, MASK_AMOXOR_D) -DECLARE_INSN(amoor_d, MATCH_AMOOR_D, MASK_AMOOR_D) -DECLARE_INSN(amoand_d, MATCH_AMOAND_D, MASK_AMOAND_D) -DECLARE_INSN(amomin_d, MATCH_AMOMIN_D, MASK_AMOMIN_D) -DECLARE_INSN(amomax_d, MATCH_AMOMAX_D, MASK_AMOMAX_D) -DECLARE_INSN(amominu_d, MATCH_AMOMINU_D, MASK_AMOMINU_D) -DECLARE_INSN(amomaxu_d, MATCH_AMOMAXU_D, MASK_AMOMAXU_D) -DECLARE_INSN(amoswap_d, MATCH_AMOSWAP_D, MASK_AMOSWAP_D) -DECLARE_INSN(lr_d, MATCH_LR_D, MASK_LR_D) -DECLARE_INSN(sc_d, MATCH_SC_D, MASK_SC_D) -DECLARE_INSN(ecall, MATCH_ECALL, MASK_ECALL) -DECLARE_INSN(ebreak, MATCH_EBREAK, MASK_EBREAK) -DECLARE_INSN(uret, MATCH_URET, MASK_URET) -DECLARE_INSN(sret, MATCH_SRET, MASK_SRET) -DECLARE_INSN(mret, MATCH_MRET, MASK_MRET) -DECLARE_INSN(dret, MATCH_DRET, MASK_DRET) -DECLARE_INSN(sfence_vma, MATCH_SFENCE_VMA, MASK_SFENCE_VMA) -DECLARE_INSN(wfi, MATCH_WFI, MASK_WFI) -DECLARE_INSN(csrrw, MATCH_CSRRW, MASK_CSRRW) -DECLARE_INSN(csrrs, MATCH_CSRRS, MASK_CSRRS) -DECLARE_INSN(csrrc, MATCH_CSRRC, MASK_CSRRC) -DECLARE_INSN(csrrwi, MATCH_CSRRWI, MASK_CSRRWI) -DECLARE_INSN(csrrsi, MATCH_CSRRSI, MASK_CSRRSI) -DECLARE_INSN(csrrci, MATCH_CSRRCI, MASK_CSRRCI) -DECLARE_INSN(fadd_s, MATCH_FADD_S, MASK_FADD_S) -DECLARE_INSN(fsub_s, MATCH_FSUB_S, MASK_FSUB_S) -DECLARE_INSN(fmul_s, MATCH_FMUL_S, MASK_FMUL_S) -DECLARE_INSN(fdiv_s, MATCH_FDIV_S, MASK_FDIV_S) -DECLARE_INSN(fsgnj_s, MATCH_FSGNJ_S, MASK_FSGNJ_S) -DECLARE_INSN(fsgnjn_s, MATCH_FSGNJN_S, MASK_FSGNJN_S) -DECLARE_INSN(fsgnjx_s, MATCH_FSGNJX_S, MASK_FSGNJX_S) -DECLARE_INSN(fmin_s, MATCH_FMIN_S, MASK_FMIN_S) -DECLARE_INSN(fmax_s, MATCH_FMAX_S, MASK_FMAX_S) -DECLARE_INSN(fsqrt_s, MATCH_FSQRT_S, MASK_FSQRT_S) -DECLARE_INSN(fadd_d, MATCH_FADD_D, MASK_FADD_D) -DECLARE_INSN(fsub_d, MATCH_FSUB_D, MASK_FSUB_D) -DECLARE_INSN(fmul_d, MATCH_FMUL_D, MASK_FMUL_D) -DECLARE_INSN(fdiv_d, MATCH_FDIV_D, MASK_FDIV_D) -DECLARE_INSN(fsgnj_d, MATCH_FSGNJ_D, MASK_FSGNJ_D) -DECLARE_INSN(fsgnjn_d, MATCH_FSGNJN_D, MASK_FSGNJN_D) -DECLARE_INSN(fsgnjx_d, MATCH_FSGNJX_D, MASK_FSGNJX_D) -DECLARE_INSN(fmin_d, MATCH_FMIN_D, MASK_FMIN_D) -DECLARE_INSN(fmax_d, MATCH_FMAX_D, MASK_FMAX_D) -DECLARE_INSN(fcvt_s_d, MATCH_FCVT_S_D, MASK_FCVT_S_D) -DECLARE_INSN(fcvt_d_s, MATCH_FCVT_D_S, MASK_FCVT_D_S) -DECLARE_INSN(fsqrt_d, MATCH_FSQRT_D, MASK_FSQRT_D) -DECLARE_INSN(fadd_q, MATCH_FADD_Q, MASK_FADD_Q) -DECLARE_INSN(fsub_q, MATCH_FSUB_Q, MASK_FSUB_Q) -DECLARE_INSN(fmul_q, MATCH_FMUL_Q, MASK_FMUL_Q) -DECLARE_INSN(fdiv_q, MATCH_FDIV_Q, MASK_FDIV_Q) -DECLARE_INSN(fsgnj_q, MATCH_FSGNJ_Q, MASK_FSGNJ_Q) -DECLARE_INSN(fsgnjn_q, MATCH_FSGNJN_Q, MASK_FSGNJN_Q) -DECLARE_INSN(fsgnjx_q, MATCH_FSGNJX_Q, MASK_FSGNJX_Q) -DECLARE_INSN(fmin_q, MATCH_FMIN_Q, MASK_FMIN_Q) -DECLARE_INSN(fmax_q, MATCH_FMAX_Q, MASK_FMAX_Q) -DECLARE_INSN(fcvt_s_q, MATCH_FCVT_S_Q, MASK_FCVT_S_Q) -DECLARE_INSN(fcvt_q_s, MATCH_FCVT_Q_S, MASK_FCVT_Q_S) -DECLARE_INSN(fcvt_d_q, MATCH_FCVT_D_Q, MASK_FCVT_D_Q) -DECLARE_INSN(fcvt_q_d, MATCH_FCVT_Q_D, MASK_FCVT_Q_D) -DECLARE_INSN(fsqrt_q, MATCH_FSQRT_Q, MASK_FSQRT_Q) -DECLARE_INSN(fle_s, MATCH_FLE_S, MASK_FLE_S) -DECLARE_INSN(flt_s, MATCH_FLT_S, MASK_FLT_S) -DECLARE_INSN(feq_s, MATCH_FEQ_S, MASK_FEQ_S) -DECLARE_INSN(fle_d, MATCH_FLE_D, MASK_FLE_D) -DECLARE_INSN(flt_d, MATCH_FLT_D, MASK_FLT_D) -DECLARE_INSN(feq_d, MATCH_FEQ_D, MASK_FEQ_D) -DECLARE_INSN(fle_q, MATCH_FLE_Q, MASK_FLE_Q) -DECLARE_INSN(flt_q, MATCH_FLT_Q, MASK_FLT_Q) -DECLARE_INSN(feq_q, MATCH_FEQ_Q, MASK_FEQ_Q) -DECLARE_INSN(fcvt_w_s, MATCH_FCVT_W_S, MASK_FCVT_W_S) -DECLARE_INSN(fcvt_wu_s, MATCH_FCVT_WU_S, MASK_FCVT_WU_S) -DECLARE_INSN(fcvt_l_s, MATCH_FCVT_L_S, MASK_FCVT_L_S) -DECLARE_INSN(fcvt_lu_s, MATCH_FCVT_LU_S, MASK_FCVT_LU_S) -DECLARE_INSN(fmv_x_w, MATCH_FMV_X_W, MASK_FMV_X_W) -DECLARE_INSN(fclass_s, MATCH_FCLASS_S, MASK_FCLASS_S) -DECLARE_INSN(fcvt_w_d, MATCH_FCVT_W_D, MASK_FCVT_W_D) -DECLARE_INSN(fcvt_wu_d, MATCH_FCVT_WU_D, MASK_FCVT_WU_D) -DECLARE_INSN(fcvt_l_d, MATCH_FCVT_L_D, MASK_FCVT_L_D) -DECLARE_INSN(fcvt_lu_d, MATCH_FCVT_LU_D, MASK_FCVT_LU_D) -DECLARE_INSN(fmv_x_d, MATCH_FMV_X_D, MASK_FMV_X_D) -DECLARE_INSN(fclass_d, MATCH_FCLASS_D, MASK_FCLASS_D) -DECLARE_INSN(fcvt_w_q, MATCH_FCVT_W_Q, MASK_FCVT_W_Q) -DECLARE_INSN(fcvt_wu_q, MATCH_FCVT_WU_Q, MASK_FCVT_WU_Q) -DECLARE_INSN(fcvt_l_q, MATCH_FCVT_L_Q, MASK_FCVT_L_Q) -DECLARE_INSN(fcvt_lu_q, MATCH_FCVT_LU_Q, MASK_FCVT_LU_Q) -DECLARE_INSN(fmv_x_q, MATCH_FMV_X_Q, MASK_FMV_X_Q) -DECLARE_INSN(fclass_q, MATCH_FCLASS_Q, MASK_FCLASS_Q) -DECLARE_INSN(fcvt_s_w, MATCH_FCVT_S_W, MASK_FCVT_S_W) -DECLARE_INSN(fcvt_s_wu, MATCH_FCVT_S_WU, MASK_FCVT_S_WU) -DECLARE_INSN(fcvt_s_l, MATCH_FCVT_S_L, MASK_FCVT_S_L) -DECLARE_INSN(fcvt_s_lu, MATCH_FCVT_S_LU, MASK_FCVT_S_LU) -DECLARE_INSN(fmv_w_x, MATCH_FMV_W_X, MASK_FMV_W_X) -DECLARE_INSN(fcvt_d_w, MATCH_FCVT_D_W, MASK_FCVT_D_W) -DECLARE_INSN(fcvt_d_wu, MATCH_FCVT_D_WU, MASK_FCVT_D_WU) -DECLARE_INSN(fcvt_d_l, MATCH_FCVT_D_L, MASK_FCVT_D_L) -DECLARE_INSN(fcvt_d_lu, MATCH_FCVT_D_LU, MASK_FCVT_D_LU) -DECLARE_INSN(fmv_d_x, MATCH_FMV_D_X, MASK_FMV_D_X) -DECLARE_INSN(fcvt_q_w, MATCH_FCVT_Q_W, MASK_FCVT_Q_W) -DECLARE_INSN(fcvt_q_wu, MATCH_FCVT_Q_WU, MASK_FCVT_Q_WU) -DECLARE_INSN(fcvt_q_l, MATCH_FCVT_Q_L, MASK_FCVT_Q_L) -DECLARE_INSN(fcvt_q_lu, MATCH_FCVT_Q_LU, MASK_FCVT_Q_LU) -DECLARE_INSN(fmv_q_x, MATCH_FMV_Q_X, MASK_FMV_Q_X) -DECLARE_INSN(flw, MATCH_FLW, MASK_FLW) -DECLARE_INSN(fld, MATCH_FLD, MASK_FLD) -DECLARE_INSN(flq, MATCH_FLQ, MASK_FLQ) -DECLARE_INSN(fsw, MATCH_FSW, MASK_FSW) -DECLARE_INSN(fsd, MATCH_FSD, MASK_FSD) -DECLARE_INSN(fsq, MATCH_FSQ, MASK_FSQ) -DECLARE_INSN(fmadd_s, MATCH_FMADD_S, MASK_FMADD_S) -DECLARE_INSN(fmsub_s, MATCH_FMSUB_S, MASK_FMSUB_S) -DECLARE_INSN(fnmsub_s, MATCH_FNMSUB_S, MASK_FNMSUB_S) -DECLARE_INSN(fnmadd_s, MATCH_FNMADD_S, MASK_FNMADD_S) -DECLARE_INSN(fmadd_d, MATCH_FMADD_D, MASK_FMADD_D) -DECLARE_INSN(fmsub_d, MATCH_FMSUB_D, MASK_FMSUB_D) -DECLARE_INSN(fnmsub_d, MATCH_FNMSUB_D, MASK_FNMSUB_D) -DECLARE_INSN(fnmadd_d, MATCH_FNMADD_D, MASK_FNMADD_D) -DECLARE_INSN(fmadd_q, MATCH_FMADD_Q, MASK_FMADD_Q) -DECLARE_INSN(fmsub_q, MATCH_FMSUB_Q, MASK_FMSUB_Q) -DECLARE_INSN(fnmsub_q, MATCH_FNMSUB_Q, MASK_FNMSUB_Q) -DECLARE_INSN(fnmadd_q, MATCH_FNMADD_Q, MASK_FNMADD_Q) -DECLARE_INSN(c_nop, MATCH_C_NOP, MASK_C_NOP) -DECLARE_INSN(c_addi16sp, MATCH_C_ADDI16SP, MASK_C_ADDI16SP) -DECLARE_INSN(c_jr, MATCH_C_JR, MASK_C_JR) -DECLARE_INSN(c_jalr, MATCH_C_JALR, MASK_C_JALR) -DECLARE_INSN(c_ebreak, MATCH_C_EBREAK, MASK_C_EBREAK) -DECLARE_INSN(c_ld, MATCH_C_LD, MASK_C_LD) -DECLARE_INSN(c_sd, MATCH_C_SD, MASK_C_SD) -DECLARE_INSN(c_addiw, MATCH_C_ADDIW, MASK_C_ADDIW) -DECLARE_INSN(c_ldsp, MATCH_C_LDSP, MASK_C_LDSP) -DECLARE_INSN(c_sdsp, MATCH_C_SDSP, MASK_C_SDSP) -DECLARE_INSN(c_addi4spn, MATCH_C_ADDI4SPN, MASK_C_ADDI4SPN) -DECLARE_INSN(c_fld, MATCH_C_FLD, MASK_C_FLD) -DECLARE_INSN(c_lw, MATCH_C_LW, MASK_C_LW) -DECLARE_INSN(c_flw, MATCH_C_FLW, MASK_C_FLW) -DECLARE_INSN(c_fsd, MATCH_C_FSD, MASK_C_FSD) -DECLARE_INSN(c_sw, MATCH_C_SW, MASK_C_SW) -DECLARE_INSN(c_fsw, MATCH_C_FSW, MASK_C_FSW) -DECLARE_INSN(c_addi, MATCH_C_ADDI, MASK_C_ADDI) -DECLARE_INSN(c_jal, MATCH_C_JAL, MASK_C_JAL) -DECLARE_INSN(c_li, MATCH_C_LI, MASK_C_LI) -DECLARE_INSN(c_lui, MATCH_C_LUI, MASK_C_LUI) -DECLARE_INSN(c_srli, MATCH_C_SRLI, MASK_C_SRLI) -DECLARE_INSN(c_srai, MATCH_C_SRAI, MASK_C_SRAI) -DECLARE_INSN(c_andi, MATCH_C_ANDI, MASK_C_ANDI) -DECLARE_INSN(c_sub, MATCH_C_SUB, MASK_C_SUB) -DECLARE_INSN(c_xor, MATCH_C_XOR, MASK_C_XOR) -DECLARE_INSN(c_or, MATCH_C_OR, MASK_C_OR) -DECLARE_INSN(c_and, MATCH_C_AND, MASK_C_AND) -DECLARE_INSN(c_subw, MATCH_C_SUBW, MASK_C_SUBW) -DECLARE_INSN(c_addw, MATCH_C_ADDW, MASK_C_ADDW) -DECLARE_INSN(c_j, MATCH_C_J, MASK_C_J) -DECLARE_INSN(c_beqz, MATCH_C_BEQZ, MASK_C_BEQZ) -DECLARE_INSN(c_bnez, MATCH_C_BNEZ, MASK_C_BNEZ) -DECLARE_INSN(c_slli, MATCH_C_SLLI, MASK_C_SLLI) -DECLARE_INSN(c_fldsp, MATCH_C_FLDSP, MASK_C_FLDSP) -DECLARE_INSN(c_lwsp, MATCH_C_LWSP, MASK_C_LWSP) -DECLARE_INSN(c_flwsp, MATCH_C_FLWSP, MASK_C_FLWSP) -DECLARE_INSN(c_mv, MATCH_C_MV, MASK_C_MV) -DECLARE_INSN(c_add, MATCH_C_ADD, MASK_C_ADD) -DECLARE_INSN(c_fsdsp, MATCH_C_FSDSP, MASK_C_FSDSP) -DECLARE_INSN(c_swsp, MATCH_C_SWSP, MASK_C_SWSP) -DECLARE_INSN(c_fswsp, MATCH_C_FSWSP, MASK_C_FSWSP) -DECLARE_INSN(custom0, MATCH_CUSTOM0, MASK_CUSTOM0) -DECLARE_INSN(custom0_rs1, MATCH_CUSTOM0_RS1, MASK_CUSTOM0_RS1) -DECLARE_INSN(custom0_rs1_rs2, MATCH_CUSTOM0_RS1_RS2, MASK_CUSTOM0_RS1_RS2) -DECLARE_INSN(custom0_rd, MATCH_CUSTOM0_RD, MASK_CUSTOM0_RD) -DECLARE_INSN(custom0_rd_rs1, MATCH_CUSTOM0_RD_RS1, MASK_CUSTOM0_RD_RS1) -DECLARE_INSN(custom0_rd_rs1_rs2, MATCH_CUSTOM0_RD_RS1_RS2, MASK_CUSTOM0_RD_RS1_RS2) -DECLARE_INSN(custom1, MATCH_CUSTOM1, MASK_CUSTOM1) -DECLARE_INSN(custom1_rs1, MATCH_CUSTOM1_RS1, MASK_CUSTOM1_RS1) -DECLARE_INSN(custom1_rs1_rs2, MATCH_CUSTOM1_RS1_RS2, MASK_CUSTOM1_RS1_RS2) -DECLARE_INSN(custom1_rd, MATCH_CUSTOM1_RD, MASK_CUSTOM1_RD) -DECLARE_INSN(custom1_rd_rs1, MATCH_CUSTOM1_RD_RS1, MASK_CUSTOM1_RD_RS1) -DECLARE_INSN(custom1_rd_rs1_rs2, MATCH_CUSTOM1_RD_RS1_RS2, MASK_CUSTOM1_RD_RS1_RS2) -DECLARE_INSN(custom2, MATCH_CUSTOM2, MASK_CUSTOM2) -DECLARE_INSN(custom2_rs1, MATCH_CUSTOM2_RS1, MASK_CUSTOM2_RS1) -DECLARE_INSN(custom2_rs1_rs2, MATCH_CUSTOM2_RS1_RS2, MASK_CUSTOM2_RS1_RS2) -DECLARE_INSN(custom2_rd, MATCH_CUSTOM2_RD, MASK_CUSTOM2_RD) -DECLARE_INSN(custom2_rd_rs1, MATCH_CUSTOM2_RD_RS1, MASK_CUSTOM2_RD_RS1) -DECLARE_INSN(custom2_rd_rs1_rs2, MATCH_CUSTOM2_RD_RS1_RS2, MASK_CUSTOM2_RD_RS1_RS2) -DECLARE_INSN(custom3, MATCH_CUSTOM3, MASK_CUSTOM3) -DECLARE_INSN(custom3_rs1, MATCH_CUSTOM3_RS1, MASK_CUSTOM3_RS1) -DECLARE_INSN(custom3_rs1_rs2, MATCH_CUSTOM3_RS1_RS2, MASK_CUSTOM3_RS1_RS2) -DECLARE_INSN(custom3_rd, MATCH_CUSTOM3_RD, MASK_CUSTOM3_RD) -DECLARE_INSN(custom3_rd_rs1, MATCH_CUSTOM3_RD_RS1, MASK_CUSTOM3_RD_RS1) -DECLARE_INSN(custom3_rd_rs1_rs2, MATCH_CUSTOM3_RD_RS1_RS2, MASK_CUSTOM3_RD_RS1_RS2) -#endif -#ifdef DECLARE_CSR -DECLARE_CSR(fflags, CSR_FFLAGS) -DECLARE_CSR(frm, CSR_FRM) -DECLARE_CSR(fcsr, CSR_FCSR) -DECLARE_CSR(cycle, CSR_CYCLE) -DECLARE_CSR(time, CSR_TIME) -DECLARE_CSR(instret, CSR_INSTRET) -DECLARE_CSR(hpmcounter3, CSR_HPMCOUNTER3) -DECLARE_CSR(hpmcounter4, CSR_HPMCOUNTER4) -DECLARE_CSR(hpmcounter5, CSR_HPMCOUNTER5) -DECLARE_CSR(hpmcounter6, CSR_HPMCOUNTER6) -DECLARE_CSR(hpmcounter7, CSR_HPMCOUNTER7) -DECLARE_CSR(hpmcounter8, CSR_HPMCOUNTER8) -DECLARE_CSR(hpmcounter9, CSR_HPMCOUNTER9) -DECLARE_CSR(hpmcounter10, CSR_HPMCOUNTER10) -DECLARE_CSR(hpmcounter11, CSR_HPMCOUNTER11) -DECLARE_CSR(hpmcounter12, CSR_HPMCOUNTER12) -DECLARE_CSR(hpmcounter13, CSR_HPMCOUNTER13) -DECLARE_CSR(hpmcounter14, CSR_HPMCOUNTER14) -DECLARE_CSR(hpmcounter15, CSR_HPMCOUNTER15) -DECLARE_CSR(hpmcounter16, CSR_HPMCOUNTER16) -DECLARE_CSR(hpmcounter17, CSR_HPMCOUNTER17) -DECLARE_CSR(hpmcounter18, CSR_HPMCOUNTER18) -DECLARE_CSR(hpmcounter19, CSR_HPMCOUNTER19) -DECLARE_CSR(hpmcounter20, CSR_HPMCOUNTER20) -DECLARE_CSR(hpmcounter21, CSR_HPMCOUNTER21) -DECLARE_CSR(hpmcounter22, CSR_HPMCOUNTER22) -DECLARE_CSR(hpmcounter23, CSR_HPMCOUNTER23) -DECLARE_CSR(hpmcounter24, CSR_HPMCOUNTER24) -DECLARE_CSR(hpmcounter25, CSR_HPMCOUNTER25) -DECLARE_CSR(hpmcounter26, CSR_HPMCOUNTER26) -DECLARE_CSR(hpmcounter27, CSR_HPMCOUNTER27) -DECLARE_CSR(hpmcounter28, CSR_HPMCOUNTER28) -DECLARE_CSR(hpmcounter29, CSR_HPMCOUNTER29) -DECLARE_CSR(hpmcounter30, CSR_HPMCOUNTER30) -DECLARE_CSR(hpmcounter31, CSR_HPMCOUNTER31) -DECLARE_CSR(sstatus, CSR_SSTATUS) -DECLARE_CSR(sie, CSR_SIE) -DECLARE_CSR(stvec, CSR_STVEC) -DECLARE_CSR(scounteren, CSR_SCOUNTEREN) -DECLARE_CSR(sscratch, CSR_SSCRATCH) -DECLARE_CSR(sepc, CSR_SEPC) -DECLARE_CSR(scause, CSR_SCAUSE) -DECLARE_CSR(sbadaddr, CSR_SBADADDR) -DECLARE_CSR(sip, CSR_SIP) -DECLARE_CSR(sptbr, CSR_SPTBR) -DECLARE_CSR(mstatus, CSR_MSTATUS) -DECLARE_CSR(misa, CSR_MISA) -DECLARE_CSR(medeleg, CSR_MEDELEG) -DECLARE_CSR(mideleg, CSR_MIDELEG) -DECLARE_CSR(mie, CSR_MIE) -DECLARE_CSR(mtvec, CSR_MTVEC) -DECLARE_CSR(mcounteren, CSR_MCOUNTEREN) -DECLARE_CSR(mscratch, CSR_MSCRATCH) -DECLARE_CSR(mepc, CSR_MEPC) -DECLARE_CSR(mcause, CSR_MCAUSE) -DECLARE_CSR(mbadaddr, CSR_MBADADDR) -DECLARE_CSR(mip, CSR_MIP) -DECLARE_CSR(pmpcfg0, CSR_PMPCFG0) -DECLARE_CSR(pmpcfg1, CSR_PMPCFG1) -DECLARE_CSR(pmpcfg2, CSR_PMPCFG2) -DECLARE_CSR(pmpcfg3, CSR_PMPCFG3) -DECLARE_CSR(pmpaddr0, CSR_PMPADDR0) -DECLARE_CSR(pmpaddr1, CSR_PMPADDR1) -DECLARE_CSR(pmpaddr2, CSR_PMPADDR2) -DECLARE_CSR(pmpaddr3, CSR_PMPADDR3) -DECLARE_CSR(pmpaddr4, CSR_PMPADDR4) -DECLARE_CSR(pmpaddr5, CSR_PMPADDR5) -DECLARE_CSR(pmpaddr6, CSR_PMPADDR6) -DECLARE_CSR(pmpaddr7, CSR_PMPADDR7) -DECLARE_CSR(pmpaddr8, CSR_PMPADDR8) -DECLARE_CSR(pmpaddr9, CSR_PMPADDR9) -DECLARE_CSR(pmpaddr10, CSR_PMPADDR10) -DECLARE_CSR(pmpaddr11, CSR_PMPADDR11) -DECLARE_CSR(pmpaddr12, CSR_PMPADDR12) -DECLARE_CSR(pmpaddr13, CSR_PMPADDR13) -DECLARE_CSR(pmpaddr14, CSR_PMPADDR14) -DECLARE_CSR(pmpaddr15, CSR_PMPADDR15) -DECLARE_CSR(tselect, CSR_TSELECT) -DECLARE_CSR(tdata1, CSR_TDATA1) -DECLARE_CSR(tdata2, CSR_TDATA2) -DECLARE_CSR(tdata3, CSR_TDATA3) -DECLARE_CSR(dcsr, CSR_DCSR) -DECLARE_CSR(dpc, CSR_DPC) -DECLARE_CSR(dscratch, CSR_DSCRATCH) -DECLARE_CSR(mcycle, CSR_MCYCLE) -DECLARE_CSR(minstret, CSR_MINSTRET) -DECLARE_CSR(mhpmcounter3, CSR_MHPMCOUNTER3) -DECLARE_CSR(mhpmcounter4, CSR_MHPMCOUNTER4) -DECLARE_CSR(mhpmcounter5, CSR_MHPMCOUNTER5) -DECLARE_CSR(mhpmcounter6, CSR_MHPMCOUNTER6) -DECLARE_CSR(mhpmcounter7, CSR_MHPMCOUNTER7) -DECLARE_CSR(mhpmcounter8, CSR_MHPMCOUNTER8) -DECLARE_CSR(mhpmcounter9, CSR_MHPMCOUNTER9) -DECLARE_CSR(mhpmcounter10, CSR_MHPMCOUNTER10) -DECLARE_CSR(mhpmcounter11, CSR_MHPMCOUNTER11) -DECLARE_CSR(mhpmcounter12, CSR_MHPMCOUNTER12) -DECLARE_CSR(mhpmcounter13, CSR_MHPMCOUNTER13) -DECLARE_CSR(mhpmcounter14, CSR_MHPMCOUNTER14) -DECLARE_CSR(mhpmcounter15, CSR_MHPMCOUNTER15) -DECLARE_CSR(mhpmcounter16, CSR_MHPMCOUNTER16) -DECLARE_CSR(mhpmcounter17, CSR_MHPMCOUNTER17) -DECLARE_CSR(mhpmcounter18, CSR_MHPMCOUNTER18) -DECLARE_CSR(mhpmcounter19, CSR_MHPMCOUNTER19) -DECLARE_CSR(mhpmcounter20, CSR_MHPMCOUNTER20) -DECLARE_CSR(mhpmcounter21, CSR_MHPMCOUNTER21) -DECLARE_CSR(mhpmcounter22, CSR_MHPMCOUNTER22) -DECLARE_CSR(mhpmcounter23, CSR_MHPMCOUNTER23) -DECLARE_CSR(mhpmcounter24, CSR_MHPMCOUNTER24) -DECLARE_CSR(mhpmcounter25, CSR_MHPMCOUNTER25) -DECLARE_CSR(mhpmcounter26, CSR_MHPMCOUNTER26) -DECLARE_CSR(mhpmcounter27, CSR_MHPMCOUNTER27) -DECLARE_CSR(mhpmcounter28, CSR_MHPMCOUNTER28) -DECLARE_CSR(mhpmcounter29, CSR_MHPMCOUNTER29) -DECLARE_CSR(mhpmcounter30, CSR_MHPMCOUNTER30) -DECLARE_CSR(mhpmcounter31, CSR_MHPMCOUNTER31) -DECLARE_CSR(mhpmevent3, CSR_MHPMEVENT3) -DECLARE_CSR(mhpmevent4, CSR_MHPMEVENT4) -DECLARE_CSR(mhpmevent5, CSR_MHPMEVENT5) -DECLARE_CSR(mhpmevent6, CSR_MHPMEVENT6) -DECLARE_CSR(mhpmevent7, CSR_MHPMEVENT7) -DECLARE_CSR(mhpmevent8, CSR_MHPMEVENT8) -DECLARE_CSR(mhpmevent9, CSR_MHPMEVENT9) -DECLARE_CSR(mhpmevent10, CSR_MHPMEVENT10) -DECLARE_CSR(mhpmevent11, CSR_MHPMEVENT11) -DECLARE_CSR(mhpmevent12, CSR_MHPMEVENT12) -DECLARE_CSR(mhpmevent13, CSR_MHPMEVENT13) -DECLARE_CSR(mhpmevent14, CSR_MHPMEVENT14) -DECLARE_CSR(mhpmevent15, CSR_MHPMEVENT15) -DECLARE_CSR(mhpmevent16, CSR_MHPMEVENT16) -DECLARE_CSR(mhpmevent17, CSR_MHPMEVENT17) -DECLARE_CSR(mhpmevent18, CSR_MHPMEVENT18) -DECLARE_CSR(mhpmevent19, CSR_MHPMEVENT19) -DECLARE_CSR(mhpmevent20, CSR_MHPMEVENT20) -DECLARE_CSR(mhpmevent21, CSR_MHPMEVENT21) -DECLARE_CSR(mhpmevent22, CSR_MHPMEVENT22) -DECLARE_CSR(mhpmevent23, CSR_MHPMEVENT23) -DECLARE_CSR(mhpmevent24, CSR_MHPMEVENT24) -DECLARE_CSR(mhpmevent25, CSR_MHPMEVENT25) -DECLARE_CSR(mhpmevent26, CSR_MHPMEVENT26) -DECLARE_CSR(mhpmevent27, CSR_MHPMEVENT27) -DECLARE_CSR(mhpmevent28, CSR_MHPMEVENT28) -DECLARE_CSR(mhpmevent29, CSR_MHPMEVENT29) -DECLARE_CSR(mhpmevent30, CSR_MHPMEVENT30) -DECLARE_CSR(mhpmevent31, CSR_MHPMEVENT31) -DECLARE_CSR(mvendorid, CSR_MVENDORID) -DECLARE_CSR(marchid, CSR_MARCHID) -DECLARE_CSR(mimpid, CSR_MIMPID) -DECLARE_CSR(mhartid, CSR_MHARTID) -DECLARE_CSR(cycleh, CSR_CYCLEH) -DECLARE_CSR(timeh, CSR_TIMEH) -DECLARE_CSR(instreth, CSR_INSTRETH) -DECLARE_CSR(hpmcounter3h, CSR_HPMCOUNTER3H) -DECLARE_CSR(hpmcounter4h, CSR_HPMCOUNTER4H) -DECLARE_CSR(hpmcounter5h, CSR_HPMCOUNTER5H) -DECLARE_CSR(hpmcounter6h, CSR_HPMCOUNTER6H) -DECLARE_CSR(hpmcounter7h, CSR_HPMCOUNTER7H) -DECLARE_CSR(hpmcounter8h, CSR_HPMCOUNTER8H) -DECLARE_CSR(hpmcounter9h, CSR_HPMCOUNTER9H) -DECLARE_CSR(hpmcounter10h, CSR_HPMCOUNTER10H) -DECLARE_CSR(hpmcounter11h, CSR_HPMCOUNTER11H) -DECLARE_CSR(hpmcounter12h, CSR_HPMCOUNTER12H) -DECLARE_CSR(hpmcounter13h, CSR_HPMCOUNTER13H) -DECLARE_CSR(hpmcounter14h, CSR_HPMCOUNTER14H) -DECLARE_CSR(hpmcounter15h, CSR_HPMCOUNTER15H) -DECLARE_CSR(hpmcounter16h, CSR_HPMCOUNTER16H) -DECLARE_CSR(hpmcounter17h, CSR_HPMCOUNTER17H) -DECLARE_CSR(hpmcounter18h, CSR_HPMCOUNTER18H) -DECLARE_CSR(hpmcounter19h, CSR_HPMCOUNTER19H) -DECLARE_CSR(hpmcounter20h, CSR_HPMCOUNTER20H) -DECLARE_CSR(hpmcounter21h, CSR_HPMCOUNTER21H) -DECLARE_CSR(hpmcounter22h, CSR_HPMCOUNTER22H) -DECLARE_CSR(hpmcounter23h, CSR_HPMCOUNTER23H) -DECLARE_CSR(hpmcounter24h, CSR_HPMCOUNTER24H) -DECLARE_CSR(hpmcounter25h, CSR_HPMCOUNTER25H) -DECLARE_CSR(hpmcounter26h, CSR_HPMCOUNTER26H) -DECLARE_CSR(hpmcounter27h, CSR_HPMCOUNTER27H) -DECLARE_CSR(hpmcounter28h, CSR_HPMCOUNTER28H) -DECLARE_CSR(hpmcounter29h, CSR_HPMCOUNTER29H) -DECLARE_CSR(hpmcounter30h, CSR_HPMCOUNTER30H) -DECLARE_CSR(hpmcounter31h, CSR_HPMCOUNTER31H) -DECLARE_CSR(mcycleh, CSR_MCYCLEH) -DECLARE_CSR(minstreth, CSR_MINSTRETH) -DECLARE_CSR(mhpmcounter3h, CSR_MHPMCOUNTER3H) -DECLARE_CSR(mhpmcounter4h, CSR_MHPMCOUNTER4H) -DECLARE_CSR(mhpmcounter5h, CSR_MHPMCOUNTER5H) -DECLARE_CSR(mhpmcounter6h, CSR_MHPMCOUNTER6H) -DECLARE_CSR(mhpmcounter7h, CSR_MHPMCOUNTER7H) -DECLARE_CSR(mhpmcounter8h, CSR_MHPMCOUNTER8H) -DECLARE_CSR(mhpmcounter9h, CSR_MHPMCOUNTER9H) -DECLARE_CSR(mhpmcounter10h, CSR_MHPMCOUNTER10H) -DECLARE_CSR(mhpmcounter11h, CSR_MHPMCOUNTER11H) -DECLARE_CSR(mhpmcounter12h, CSR_MHPMCOUNTER12H) -DECLARE_CSR(mhpmcounter13h, CSR_MHPMCOUNTER13H) -DECLARE_CSR(mhpmcounter14h, CSR_MHPMCOUNTER14H) -DECLARE_CSR(mhpmcounter15h, CSR_MHPMCOUNTER15H) -DECLARE_CSR(mhpmcounter16h, CSR_MHPMCOUNTER16H) -DECLARE_CSR(mhpmcounter17h, CSR_MHPMCOUNTER17H) -DECLARE_CSR(mhpmcounter18h, CSR_MHPMCOUNTER18H) -DECLARE_CSR(mhpmcounter19h, CSR_MHPMCOUNTER19H) -DECLARE_CSR(mhpmcounter20h, CSR_MHPMCOUNTER20H) -DECLARE_CSR(mhpmcounter21h, CSR_MHPMCOUNTER21H) -DECLARE_CSR(mhpmcounter22h, CSR_MHPMCOUNTER22H) -DECLARE_CSR(mhpmcounter23h, CSR_MHPMCOUNTER23H) -DECLARE_CSR(mhpmcounter24h, CSR_MHPMCOUNTER24H) -DECLARE_CSR(mhpmcounter25h, CSR_MHPMCOUNTER25H) -DECLARE_CSR(mhpmcounter26h, CSR_MHPMCOUNTER26H) -DECLARE_CSR(mhpmcounter27h, CSR_MHPMCOUNTER27H) -DECLARE_CSR(mhpmcounter28h, CSR_MHPMCOUNTER28H) -DECLARE_CSR(mhpmcounter29h, CSR_MHPMCOUNTER29H) -DECLARE_CSR(mhpmcounter30h, CSR_MHPMCOUNTER30H) -DECLARE_CSR(mhpmcounter31h, CSR_MHPMCOUNTER31H) -#endif -#ifdef DECLARE_CAUSE -DECLARE_CAUSE("misaligned fetch", CAUSE_MISALIGNED_FETCH) -DECLARE_CAUSE("fetch access", CAUSE_FETCH_ACCESS) -DECLARE_CAUSE("illegal instruction", CAUSE_ILLEGAL_INSTRUCTION) -DECLARE_CAUSE("breakpoint", CAUSE_BREAKPOINT) -DECLARE_CAUSE("misaligned load", CAUSE_MISALIGNED_LOAD) -DECLARE_CAUSE("load access", CAUSE_LOAD_ACCESS) -DECLARE_CAUSE("misaligned store", CAUSE_MISALIGNED_STORE) -DECLARE_CAUSE("store access", CAUSE_STORE_ACCESS) -DECLARE_CAUSE("user_ecall", CAUSE_USER_ECALL) -DECLARE_CAUSE("supervisor_ecall", CAUSE_SUPERVISOR_ECALL) -DECLARE_CAUSE("hypervisor_ecall", CAUSE_HYPERVISOR_ECALL) -DECLARE_CAUSE("machine_ecall", CAUSE_MACHINE_ECALL) -DECLARE_CAUSE("fetch page fault", CAUSE_FETCH_PAGE_FAULT) -DECLARE_CAUSE("load page fault", CAUSE_LOAD_PAGE_FAULT) -DECLARE_CAUSE("store page fault", CAUSE_STORE_PAGE_FAULT) -#endif diff --git a/cpukit/score/cpu/riscv/rtems/score/riscv.h b/cpukit/score/cpu/riscv/rtems/score/riscv.h deleted file mode 100644 index 6e7f1370c6..0000000000 --- a/cpukit/score/cpu/riscv/rtems/score/riscv.h +++ /dev/null @@ -1,66 +0,0 @@ -/** - * @file rtems/score/riscv.h - */ - -/* - * This file contains information pertaining to the riscv32 processor. - * - * COPYRIGHT (c) 2014 Hesham Almatary - * - * Based on code with the following copyright... - * COPYRIGHT (c) 1989-1999, 2010. - * On-Line Applications Research Corporation (OAR). - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _RTEMS_SCORE_RISCV_H -#define _RTEMS_SCORE_RISCV_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This file contains the information required to build - * RTEMS for a particular member of the RISCV family. - * It does this by setting variables to indicate which - * implementation dependent features are present in a particular - * member of the family. - * - * This is a good place to list all the known CPU models - * that this port supports and which RTEMS CPU model they correspond - * to. - */ - -/* -* Define the name of the CPU family and specific model. -*/ - -#define CPU_NAME "RISCV" -#define CPU_MODEL_NAME "RISCV" - -#ifdef __cplusplus -} -#endif - -#endif /* _RTEMS_SCORE_RISCV_H */ diff --git a/cpukit/score/cpu/riscv/rtems/score/types.h b/cpukit/score/cpu/riscv/rtems/score/types.h deleted file mode 100644 index d1440fb319..0000000000 --- a/cpukit/score/cpu/riscv/rtems/score/types.h +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @file - * - * @brief RISC-V Architecture Types API - */ - -/* - * This include file contains type definitions pertaining to the - * RISC-V processor family. - * - * COPYRIGHT (c) 2014 Hesham Almatary - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _RTEMS_SCORE_TYPES_H -#define _RTEMS_SCORE_TYPES_H - -#include - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ScoreCPU - */ -/**@{**/ - -/* - * This section defines the basic types for this processor. - */ - -/** Type that can store a 32-bit integer or a pointer. */ -typedef uintptr_t CPU_Uint32ptr; - -typedef uint16_t Priority_bit_map_Word; -typedef void riscv_isr; -typedef void ( *riscv_isr_entry )( void ); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* !ASM */ - -#endif diff --git a/cpukit/score/cpu/sh/Makefile.am b/cpukit/score/cpu/sh/Makefile.am index b480b1aa26..6a19ce4cb8 100644 --- a/cpukit/score/cpu/sh/Makefile.am +++ b/cpukit/score/cpu/sh/Makefile.am @@ -1,21 +1,10 @@ include $(top_srcdir)/automake/compile.am -include_rtemsdir = $(includedir)/rtems -include_rtems_HEADERS = rtems/asm.h - -include_rtems_scoredir = $(includedir)/rtems/score -include_rtems_score_HEADERS = rtems/score/cpu.h -include_rtems_score_HEADERS += rtems/score/cpuimpl.h -include_rtems_score_HEADERS += rtems/score/types.h -include_rtems_score_HEADERS += rtems/score/sh.h -include_rtems_score_HEADERS += rtems/score/sh_io.h -include_rtems_score_HEADERS += rtems/score/cpuatomic.h - noinst_LIBRARIES = libscorecpu.a libscorecpu_a_SOURCES = cpu.c context.c libscorecpu_a_SOURCES += ../no_cpu/cpucounterread.c libscorecpu_a_SOURCES += sh-exception-frame-print.c libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS) -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am +include $(srcdir)/headers.am diff --git a/cpukit/score/cpu/sh/headers.am b/cpukit/score/cpu/sh/headers.am new file mode 100644 index 0000000000..40073e7186 --- /dev/null +++ b/cpukit/score/cpu/sh/headers.am @@ -0,0 +1,14 @@ +## This file was generated by "./boostrap -H". + +include_rtemsdir = $(includedir)/rtems +include_rtems_HEADERS = +include_rtems_HEADERS += include/rtems/asm.h + +include_rtems_scoredir = $(includedir)/rtems/score +include_rtems_score_HEADERS = +include_rtems_score_HEADERS += include/rtems/score/cpu.h +include_rtems_score_HEADERS += include/rtems/score/cpuatomic.h +include_rtems_score_HEADERS += include/rtems/score/cpuimpl.h +include_rtems_score_HEADERS += include/rtems/score/sh.h +include_rtems_score_HEADERS += include/rtems/score/sh_io.h +include_rtems_score_HEADERS += include/rtems/score/types.h diff --git a/cpukit/score/cpu/sh/include/rtems/asm.h b/cpukit/score/cpu/sh/include/rtems/asm.h new file mode 100644 index 0000000000..ac730310cd --- /dev/null +++ b/cpukit/score/cpu/sh/include/rtems/asm.h @@ -0,0 +1,137 @@ +/** + * @file + * + * @brief Address the Problems Caused by Incompatible Flavor of + * Assemblers and Toolsets + * + * This include file attempts to address the problems + * caused by incompatible flavors of assemblers and + * toolsets. It primarily addresses variations in the + * use of leading underscores on symbols and the requirement + * that register names be preceded by a %. + * + * @note The spacing in the use of these macros + * is critical to them working as advertised. + */ + +/* + * Authors: Ralf Corsepius (corsepiu@faw.uni-ulm.de) and + * Bernd Becker (becker@faw.uni-ulm.de) + * + * COPYRIGHT: + * + * This file is based on similar code found in newlib available + * from ftp.cygnus.com. The file which was used had no copyright + * notice. This file is freely distributable as long as the source + * of the file is noted. This file is: + * + * + * COPYRIGHT (c) 1997-1998, FAW Ulm, Germany + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * + * COPYRIGHT (c) 1998-2001. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_ASM_H +#define _RTEMS_ASM_H + +/* + * Indicate we are in an assembly file and get the basic CPU definitions. + */ + +#ifndef ASM +#define ASM +#endif + +#include +#include + +/* + * Recent versions of GNU cpp define variables which indicate the + * need for underscores and percents. If not using GNU cpp or + * the version does not support this, then you will obviously + * have to define these as appropriate. + */ + +#ifndef __USER_LABEL_PREFIX__ +#define __USER_LABEL_PREFIX__ _ +#endif + +#ifndef __REGISTER_PREFIX__ +#define __REGISTER_PREFIX__ +#endif + +#include + +/* Use the right prefix for global labels. */ + +#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) + +/* Use the right prefix for registers. */ + +#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) + +/* + * define macros for all of the registers on this CPU + * + * EXAMPLE: #define d0 REG (d0) + */ +#define r0 REG (r0) +#define r1 REG (r1) +#define r2 REG (r2) +#define r3 REG (r3) +#define r4 REG (r4) +#define r5 REG (r5) +#define r6 REG (r6) +#define r7 REG (r7) +#define r8 REG (r8) +#define r9 REG (r9) +#define r10 REG (r10) +#define r11 REG (r11) +#define r12 REG (r12) +#define r13 REG (r13) +#define r14 REG (r14) +#define r15 REG (r15) +#define vbr REG (vbr) +#define gbr REG (gbr) +#define pr REG (pr) +#define mach REG (mach) +#define macl REG (macl) +#define sr REG (sr) +#define pc REG (pc) + +/* + * Define macros to handle section beginning and ends. + */ + + +#define BEGIN_CODE_DCL .text +#define END_CODE_DCL +#define BEGIN_DATA_DCL .data +#define END_DATA_DCL +#define BEGIN_CODE .text +#define END_CODE +#define BEGIN_DATA +#define END_DATA +#define BEGIN_BSS +#define END_BSS +#define END + +/* + * Following must be tailor for a particular flavor of the C compiler. + * They may need to put underscores in front of the symbols. + */ + +#define PUBLIC(sym) .global SYM (sym) +#define EXTERN(sym) .global SYM (sym) + +#endif diff --git a/cpukit/score/cpu/sh/include/rtems/score/cpu.h b/cpukit/score/cpu/sh/include/rtems/score/cpu.h new file mode 100644 index 0000000000..c2b7081e9e --- /dev/null +++ b/cpukit/score/cpu/sh/include/rtems/score/cpu.h @@ -0,0 +1,738 @@ +/** + * @file rtems/score/cpu.h + */ + +/* + * This include file contains information pertaining to the Hitachi SH + * processor. + * + * Authors: Ralf Corsepius (corsepiu@faw.uni-ulm.de) and + * Bernd Becker (becker@faw.uni-ulm.de) + * + * COPYRIGHT (c) 1997-1998, FAW Ulm, Germany + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * + * COPYRIGHT (c) 1998-2006. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPU_H +#define _RTEMS_SCORE_CPU_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* conditional compilation parameters */ + +/* + * Does the CPU follow the simple vectored interrupt model? + * + * If TRUE, then RTEMS allocates the vector table it internally manages. + * If FALSE, then the BSP is assumed to allocate and manage the vector + * table + * + * SH Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_SIMPLE_VECTORED_INTERRUPTS TRUE + +/* + * Does RTEMS manage a dedicated interrupt stack in software? + * + * If TRUE, then a stack is allocated in _ISR_Handler_initialization. + * If FALSE, nothing is done. + * + * If the CPU supports a dedicated interrupt stack in hardware, + * then it is generally the responsibility of the BSP to allocate it + * and set it up. + * + * If the CPU does not support a dedicated interrupt stack, then + * the porter has two options: (1) execute interrupts on the + * stack of the interrupted task, and (2) have RTEMS manage a dedicated + * interrupt stack. + * + * If this is TRUE, CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. + * + * Only one of CPU_HAS_SOFTWARE_INTERRUPT_STACK and + * CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is + * possible that both are FALSE for a particular CPU. Although it + * is unclear what that would imply about the interrupt processing + * procedure on that CPU. + */ + +#define CPU_HAS_SOFTWARE_INTERRUPT_STACK TRUE +#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE + +/* + * We define the interrupt stack in the linker script + */ +#define CPU_ALLOCATE_INTERRUPT_STACK FALSE + +/* + * Does the RTEMS invoke the user's ISR with the vector number and + * a pointer to the saved interrupt frame (1) or just the vector + * number (0)? + */ + +#define CPU_ISR_PASSES_FRAME_POINTER FALSE + +/* + * Does the CPU have hardware floating point? + * + * If TRUE, then the RTEMS_FLOATING_POINT task attribute is supported. + * If FALSE, then the RTEMS_FLOATING_POINT task attribute is ignored. + * + * We currently support sh1 only, which has no FPU, other SHes have an FPU + * + * The macro name "SH_HAS_FPU" should be made CPU specific. + * It indicates whether or not this CPU model has FP support. For + * example, it would be possible to have an i386_nofp CPU model + * which set this to false to indicate that you have an i386 without + * an i387 and wish to leave floating point support out of RTEMS. + */ + +#if SH_HAS_FPU +#define CPU_HARDWARE_FP TRUE +#define CPU_SOFTWARE_FP FALSE +#else +#define CPU_SOFTWARE_FP FALSE +#define CPU_HARDWARE_FP FALSE +#endif + +/* + * Are all tasks RTEMS_FLOATING_POINT tasks implicitly? + * + * If TRUE, then the RTEMS_FLOATING_POINT task attribute is assumed. + * If FALSE, then the RTEMS_FLOATING_POINT task attribute is followed. + * + * If CPU_HARDWARE_FP is FALSE, then this should be FALSE as well. + */ + +#if SH_HAS_FPU +#define CPU_ALL_TASKS_ARE_FP TRUE +#else +#define CPU_ALL_TASKS_ARE_FP FALSE +#endif + +/* + * Should the IDLE task have a floating point context? + * + * If TRUE, then the IDLE task is created as a RTEMS_FLOATING_POINT task + * and it has a floating point context which is switched in and out. + * If FALSE, then the IDLE task does not have a floating point context. + * + * Setting this to TRUE negatively impacts the time required to preempt + * the IDLE task from an interrupt because the floating point context + * must be saved as part of the preemption. + */ + +#if SH_HAS_FPU +#define CPU_IDLE_TASK_IS_FP TRUE +#else +#define CPU_IDLE_TASK_IS_FP FALSE +#endif + +/* + * Should the saving of the floating point registers be deferred + * until a context switch is made to another different floating point + * task? + * + * If TRUE, then the floating point context will not be stored until + * necessary. It will remain in the floating point registers and not + * disturned until another floating point task is switched to. + * + * If FALSE, then the floating point context is saved when a floating + * point task is switched out and restored when the next floating point + * task is restored. The state of the floating point registers between + * those two operations is not specified. + * + * If the floating point context does NOT have to be saved as part of + * interrupt dispatching, then it should be safe to set this to TRUE. + * + * Setting this flag to TRUE results in using a different algorithm + * for deciding when to save and restore the floating point context. + * The deferred FP switch algorithm minimizes the number of times + * the FP context is saved and restored. The FP context is not saved + * until a context switch is made to another, different FP task. + * Thus in a system with only one FP task, the FP context will never + * be saved or restored. + */ + +#if SH_HAS_FPU +#define CPU_USE_DEFERRED_FP_SWITCH FALSE +#else +#define CPU_USE_DEFERRED_FP_SWITCH TRUE +#endif + +#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE + +/* + * Does this port provide a CPU dependent IDLE task implementation? + * + * If TRUE, then the routine _CPU_Thread_Idle_body + * must be provided and is the default IDLE thread body instead of + * _CPU_Thread_Idle_body. + * + * If FALSE, then use the generic IDLE thread body if the BSP does + * not provide one. + * + * This is intended to allow for supporting processors which have + * a low power or idle mode. When the IDLE thread is executed, then + * the CPU can be powered down. + * + * The order of precedence for selecting the IDLE thread body is: + * + * 1. BSP provided + * 2. CPU dependent (if provided) + * 3. generic (if no BSP and no CPU dependent) + */ + +#define CPU_PROVIDES_IDLE_THREAD_BODY TRUE + +/* + * Does the stack grow up (toward higher addresses) or down + * (toward lower addresses)? + * + * If TRUE, then the grows upward. + * If FALSE, then the grows toward smaller addresses. + */ + +#define CPU_STACK_GROWS_UP FALSE + +/* FIXME: Is this the right value? */ +#define CPU_CACHE_LINE_BYTES 16 + +#define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES ) + +/* + * The following defines the number of bits actually used in the + * interrupt field of the task mode. How those bits map to the + * CPU interrupt levels is defined by the routine _CPU_ISR_Set_level(). + */ + +#define CPU_MODES_INTERRUPT_MASK 0x0000000f + +#define CPU_MAXIMUM_PROCESSORS 32 + +/* + * Processor defined structures required for cpukit/score. + */ + +/* may need to put some structures here. */ + +/* + * Contexts + * + * Generally there are 2 types of context to save. + * 1. Interrupt registers to save + * 2. Task level registers to save + * + * This means we have the following 3 context items: + * 1. task level context stuff:: Context_Control + * 2. floating point task stuff:: Context_Control_fp + * 3. special interrupt level context :: Context_Control_interrupt + * + * On some processors, it is cost-effective to save only the callee + * preserved registers during a task context switch. This means + * that the ISR code needs to save those registers which do not + * persist across function calls. It is not mandatory to make this + * distinctions between the caller/callee saves registers for the + * purpose of minimizing context saved during task switch and on interrupts. + * If the cost of saving extra registers is minimal, simplicity is the + * choice. Save the same context on interrupt entry as for tasks in + * this case. + * + * Additionally, if gdb is to be made aware of RTEMS tasks for this CPU, then + * care should be used in designing the context area. + * + * On some CPUs with hardware floating point support, the Context_Control_fp + * structure will not be used or it simply consist of an array of a + * fixed number of bytes. This is done when the floating point context + * is dumped by a "FP save context" type instruction and the format + * is not really defined by the CPU. In this case, there is no need + * to figure out the exact format -- only the size. Of course, although + * this is enough information for RTEMS, it is probably not enough for + * a debugger such as gdb. But that is another problem. + */ + +typedef struct { + uint32_t *r15; /* stack pointer */ + + uint32_t macl; + uint32_t mach; + uint32_t *pr; + + uint32_t *r14; /* frame pointer/call saved */ + + uint32_t r13; /* call saved */ + uint32_t r12; /* call saved */ + uint32_t r11; /* call saved */ + uint32_t r10; /* call saved */ + uint32_t r9; /* call saved */ + uint32_t r8; /* call saved */ + + uint32_t *r7; /* arg in */ + uint32_t *r6; /* arg in */ + +#if 0 + uint32_t *r5; /* arg in */ + uint32_t *r4; /* arg in */ +#endif + + uint32_t *r3; /* scratch */ + uint32_t *r2; /* scratch */ + uint32_t *r1; /* scratch */ + + uint32_t *r0; /* arg return */ + + uint32_t gbr; + uint32_t sr; + +} Context_Control; + +#define _CPU_Context_Get_SP( _context ) \ + (_context)->r15 + +typedef struct { +#if SH_HAS_FPU +#ifdef SH4_USE_X_REGISTERS + union { + float f[16]; + double d[8]; + } x; +#endif + union { + float f[16]; + double d[8]; + } r; + float fpul; /* fp communication register */ + uint32_t fpscr; /* fp control register */ +#endif /* SH_HAS_FPU */ +} Context_Control_fp; + +typedef struct { +} CPU_Interrupt_frame; + +/* + * This variable is optional. It is used on CPUs on which it is difficult + * to generate an "uninitialized" FP context. It is filled in by + * _CPU_Initialize and copied into the task's FP context area during + * _CPU_Context_Initialize. + */ + +#if SH_HAS_FPU +extern Context_Control_fp _CPU_Null_fp_context; +#endif + +/* + * Nothing prevents the porter from declaring more CPU specific variables. + */ + +/* XXX: if needed, put more variables here */ +void CPU_delay( uint32_t microseconds ); + +/* + * The size of the floating point context area. On some CPUs this + * will not be a "sizeof" because the format of the floating point + * area is not defined -- only the size is. This is usually on + * CPUs with a "floating point save context" instruction. + */ + +#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp ) + +/* + * Amount of extra stack (above minimum stack size) required by + * MPCI receive server thread. Remember that in a multiprocessor + * system this thread must exist and be able to process all directives. + */ + +#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0 + +/* + * This defines the number of entries in the ISR_Vector_table managed + * by RTEMS. + */ + +#define CPU_INTERRUPT_NUMBER_OF_VECTORS 256 +#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER (CPU_INTERRUPT_NUMBER_OF_VECTORS - 1) + +/* + * This is defined if the port has a special way to report the ISR nesting + * level. Most ports maintain the variable _ISR_Nest_level. + */ + +#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE + +/* + * Should be large enough to run all RTEMS tests. This ensures + * that a "reasonable" small application should not have any problems. + * + * We have been able to run the sptests with this value, but have not + * been able to run the tmtest suite. + */ + +#define CPU_STACK_MINIMUM_SIZE 4096 + +#define CPU_SIZEOF_POINTER 4 + +/* + * CPU's worst alignment requirement for data types on a byte boundary. This + * alignment does not take into account the requirements for the stack. + */ +#if defined(__SH4__) +/* FIXME: sh3 and SH3E? */ +#define CPU_ALIGNMENT 8 +#else +#define CPU_ALIGNMENT 4 +#endif + +/* + * This number corresponds to the byte alignment requirement for the + * heap handler. This alignment requirement may be stricter than that + * for the data types alignment specified by CPU_ALIGNMENT. It is + * common for the heap to follow the same alignment requirement as + * CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict enough for the heap, + * then this should be set to CPU_ALIGNMENT. + * + * NOTE: This does not have to be a power of 2. It does have to + * be greater or equal to than CPU_ALIGNMENT. + */ + +#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT + +/* + * This number corresponds to the byte alignment requirement for memory + * buffers allocated by the partition manager. This alignment requirement + * may be stricter than that for the data types alignment specified by + * CPU_ALIGNMENT. It is common for the partition to follow the same + * alignment requirement as CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict + * enough for the partition, then this should be set to CPU_ALIGNMENT. + * + * NOTE: This does not have to be a power of 2. It does have to + * be greater or equal to than CPU_ALIGNMENT. + */ + +#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT + +/* + * This number corresponds to the byte alignment requirement for the + * stack. This alignment requirement may be stricter than that for the + * data types alignment specified by CPU_ALIGNMENT. If the CPU_ALIGNMENT + * is strict enough for the stack, then this should be set to 0. + * + * NOTE: This must be a power of 2 either 0 or greater than CPU_ALIGNMENT. + */ + +#define CPU_STACK_ALIGNMENT CPU_ALIGNMENT + +/* + * ISR handler macros + */ + +/* + * Support routine to initialize the RTEMS vector table after it is allocated. + * + * SH Specific Information: NONE + */ + +#define _CPU_Initialize_vectors() + +/* + * Disable all interrupts for an RTEMS critical section. The previous + * level is returned in _level. + */ + +#define _CPU_ISR_Disable( _level) \ + sh_disable_interrupts( _level ) + +/* + * Enable interrupts to the previous level (returned by _CPU_ISR_Disable). + * This indicates the end of an RTEMS critical section. The parameter + * _level is not modified. + */ + +#define _CPU_ISR_Enable( _level) \ + sh_enable_interrupts( _level) + +/* + * This temporarily restores the interrupt to _level before immediately + * disabling them again. This is used to divide long RTEMS critical + * sections into two or more parts. The parameter _level is not + * modified. + */ + +#define _CPU_ISR_Flash( _level) \ + sh_flash_interrupts( _level) + +RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) +{ + sh_get_interrupt_level( level ); + return level == 0; +} + +/* + * Map interrupt level in task mode onto the hardware that the CPU + * actually provides. Currently, interrupt levels which do not + * map onto the CPU in a generic fashion are undefined. Someday, + * it would be nice if these were "mapped" by the application + * via a callout. For example, m68k has 8 levels 0 - 7, levels + * 8 - 255 would be available for bsp/application specific meaning. + * This could be used to manage a programmable interrupt controller + * via the rtems_task_mode directive. + */ + +#define _CPU_ISR_Set_level( _newlevel) \ + sh_set_interrupt_level(_newlevel) + +uint32_t _CPU_ISR_Get_level( void ); + +/* end of ISR handler macros */ + +/* Context handler macros */ + +/* + * Initialize the context to a state suitable for starting a + * task after a context restore operation. Generally, this + * involves: + * + * - setting a starting address + * - preparing the stack + * - preparing the stack and frame pointers + * - setting the proper interrupt level in the context + * - initializing the floating point context + * + * This routine generally does not set any unnecessary register + * in the context. The state of the "general data" registers is + * undefined at task start time. + * + * NOTE: This is_fp parameter is TRUE if the thread is to be a floating + * point thread. This is typically only used on CPUs where the + * FPU may be easily disabled by software such as on the SPARC + * where the PSR contains an enable FPU bit. + */ + +/* + * FIXME: defined as a function for debugging - should be a macro + */ +void _CPU_Context_Initialize( + Context_Control *_the_context, + void *_stack_base, + uint32_t _size, + uint32_t _isr, + void (*_entry_point)(void), + int _is_fp, + void *_tls_area ); + +/* + * This routine is responsible for somehow restarting the currently + * executing task. If you are lucky, then all that is necessary + * is restoring the context. Otherwise, there will need to be + * a special assembly routine which does something special in this + * case. Context_Restore should work most of the time. It will + * not work if restarting self conflicts with the stack frame + * assumptions of restoring a context. + */ + +#define _CPU_Context_Restart_self( _the_context ) \ + _CPU_Context_restore( (_the_context) ); + +/* + * This routine initializes the FP context area passed to it to. + * There are a few standard ways in which to initialize the + * floating point context. The code included for this macro assumes + * that this is a CPU in which a "initial" FP context was saved into + * _CPU_Null_fp_context and it simply copies it to the destination + * context passed to it. + * + * Other models include (1) not doing anything, and (2) putting + * a "null FP status word" in the correct place in the FP context. + * SH1, SH2, SH3 have no FPU, but the SH3e and SH4 have. + */ + +#if SH_HAS_FPU +#define _CPU_Context_Initialize_fp( _destination ) \ + do { \ + *(*(_destination)) = _CPU_Null_fp_context;\ + } while(0) +#else +#define _CPU_Context_Initialize_fp( _destination ) \ + { } +#endif + +/* end of Context handler macros */ + +/* Fatal Error manager macros */ + +/* + * FIXME: Trap32 ??? + * + * This routine copies _error into a known place -- typically a stack + * location or a register, optionally disables interrupts, and + * invokes a Trap32 Instruction which returns to the breakpoint + * routine of cmon. + */ + +#ifdef BSP_FATAL_HALT + /* we manage the fatal error in the board support package */ + void bsp_fatal_halt( uint32_t _error); +#define _CPU_Fatal_halt( _source, _error ) bsp_fatal_halt( _error) +#else +#define _CPU_Fatal_halt( _source, _error)\ +{ \ + __asm__ volatile("mov.l %0,r0"::"m" (_error)); \ + __asm__ volatile("mov #1, r4"); \ + __asm__ volatile("trapa #34"); \ +} +#endif + +/* end of Fatal Error manager macros */ + +#define CPU_USE_GENERIC_BITFIELD_CODE TRUE + +/* functions */ + +/* + * @brief CPU Initialize + * + * _CPU_Initialize + * + * This routine performs CPU dependent initialization. + */ +void _CPU_Initialize(void); + +/* + * _CPU_ISR_install_raw_handler + * + * This routine installs a "raw" interrupt handler directly into the + * processor's vector table. + */ + +void _CPU_ISR_install_raw_handler( + uint32_t vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +/* + * _CPU_ISR_install_vector + * + * This routine installs an interrupt vector. + */ + +void _CPU_ISR_install_vector( + uint32_t vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +/* + * _CPU_Install_interrupt_stack + * + * This routine installs the hardware interrupt stack pointer. + * + * NOTE: It needs only be provided if CPU_HAS_HARDWARE_INTERRUPT_STACK + * is TRUE. + */ + +void _CPU_Install_interrupt_stack( void ); + +/* + * _CPU_Thread_Idle_body + * + * This routine is the CPU dependent IDLE thread body. + * + * NOTE: It need only be provided if CPU_PROVIDES_IDLE_THREAD_BODY + * is TRUE. + */ + +void *_CPU_Thread_Idle_body( uintptr_t ignored ); + +/* + * _CPU_Context_switch + * + * This routine switches from the run context to the heir context. + */ + +void _CPU_Context_switch( + Context_Control *run, + Context_Control *heir +); + +/* + * _CPU_Context_restore + * + * This routine is generally used only to restart self in an + * efficient manner. It may simply be a label in _CPU_Context_switch. + */ + +void _CPU_Context_restore( + Context_Control *new_context +) RTEMS_NO_RETURN; + +/* + * @brief This routine saves the floating point context passed to it. + * + * _CPU_Context_save_fp + * + */ +void _CPU_Context_save_fp( + Context_Control_fp **fp_context_ptr +); + +/* + * @brief This routine restores the floating point context passed to it. + * + * _CPU_Context_restore_fp + * + */ +void _CPU_Context_restore_fp( + Context_Control_fp **fp_context_ptr +); + +static inline void _CPU_Context_volatile_clobber( uintptr_t pattern ) +{ + /* TODO */ +} + +static inline void _CPU_Context_validate( uintptr_t pattern ) +{ + while (1) { + /* TODO */ + } +} + +/* FIXME */ +typedef CPU_Interrupt_frame CPU_Exception_frame; + +void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); + +typedef uint32_t CPU_Counter_ticks; + +CPU_Counter_ticks _CPU_Counter_read( void ); + +static inline CPU_Counter_ticks _CPU_Counter_difference( + CPU_Counter_ticks second, + CPU_Counter_ticks first +) +{ + return second - first; +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/score/cpu/sh/include/rtems/score/cpuatomic.h b/cpukit/score/cpu/sh/include/rtems/score/cpuatomic.h new file mode 100644 index 0000000000..598ee76b20 --- /dev/null +++ b/cpukit/score/cpu/sh/include/rtems/score/cpuatomic.h @@ -0,0 +1,14 @@ +/* + * COPYRIGHT (c) 2012-2013 Deng Hengyi. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_ATOMIC_CPU_H +#define _RTEMS_SCORE_ATOMIC_CPU_H + +#include + +#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/sh/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/sh/include/rtems/score/cpuimpl.h new file mode 100644 index 0000000000..789f2badd9 --- /dev/null +++ b/cpukit/score/cpu/sh/include/rtems/score/cpuimpl.h @@ -0,0 +1,34 @@ +/** + * @file + * + * @brief CPU Port Implementation API + */ + +/* + * Copyright (c) 2013 embedded brains GmbH + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPUIMPL_H +#define _RTEMS_SCORE_CPUIMPL_H + +#include + +#define CPU_PER_CPU_CONTROL_SIZE 0 + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ASM */ + +#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/sh/include/rtems/score/sh.h b/cpukit/score/cpu/sh/include/rtems/score/sh.h new file mode 100644 index 0000000000..4e26478b8b --- /dev/null +++ b/cpukit/score/cpu/sh/include/rtems/score/sh.h @@ -0,0 +1,277 @@ +/** + * @file + * + * @brief Hitachi SH CPU Department Source + * + * This include file contains information pertaining to the Hitachi SH + * processor. + */ + +/* + * Authors: Ralf Corsepius (corsepiu@faw.uni-ulm.de) and + * Bernd Becker (becker@faw.uni-ulm.de) + * + * COPYRIGHT (c) 1997-1998, FAW Ulm, Germany + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE + * + * + * COPYRIGHT (c) 1998-2001. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SH_H +#define _RTEMS_SCORE_SH_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This file contains the information required to build + * RTEMS for a particular member of the "SH" family. + * + * It does this by setting variables to indicate which implementation + * dependent features are present in a particular member of the family. + */ + +/* + * Figure out all CPU Model Feature Flags based upon compiler + * predefines. + */ + +#if defined(__SH2E__) || defined(__SH3E__) + +/* FIXME: SH-DSP context not currently supported */ +#define SH_HAS_FPU 0 + +#elif defined(__SH4__) || defined(__SH4_SINGLE_ONLY__) + +/* + * Define this if you want to use XD-registers. + * Then this registers will be saved/restored on context switch. + * ! They will not be saved/restored on interrupts! + */ +#define SH4_USE_X_REGISTERS 0 + +#if defined(__LITTLE_ENDIAN__) +#define SH_HAS_FPU 1 +#else +/* FIXME: Context_Control_fp does not support big endian */ +#warning FPU not supported +#define SH_HAS_FPU 0 +#endif + +#elif defined(__sh1__) || defined(__sh2__) || defined(__sh3__) +#define SH_HAS_FPU 0 +#else +#warning Cannot detect FPU support, assuming no FPU +#define SH_HAS_FPU 0 +#endif + +/* this should not be here */ +#ifndef CPU_MODEL_NAME +#define CPU_MODEL_NAME "SH-Multilib" +#endif + +/* + * If the following macro is set to 0 there will be no software irq stack + */ + +#ifndef SH_HAS_SEPARATE_STACKS +#define SH_HAS_SEPARATE_STACKS 1 +#endif + +/* + * Define the name of the CPU family. + */ + +#define CPU_NAME "Hitachi SH" + +#ifndef ASM + +#if defined(__sh1__) || defined(__sh2__) + +/* + * Mask for disabling interrupts + */ +#define SH_IRQDIS_VALUE 0xf0 + +#define sh_disable_interrupts( _level ) \ + __asm__ volatile ( \ + "stc sr,%0\n\t" \ + "ldc %1,sr\n\t"\ + : "=&r" (_level ) \ + : "r" (SH_IRQDIS_VALUE) ); + +#define sh_enable_interrupts( _level ) \ + __asm__ volatile( "ldc %0,sr\n\t" \ + "nop\n\t" \ + :: "r" (_level) ); + +/* + * This temporarily restores the interrupt to _level before immediately + * disabling them again. This is used to divide long RTEMS critical + * sections into two or more parts. The parameter _level is not + * modified. + */ + +#define sh_flash_interrupts( _level ) \ + __asm__ volatile( \ + "ldc %1,sr\n\t" \ + "nop\n\t" \ + "ldc %0,sr\n\t" \ + "nop\n\t" \ + : : "r" (SH_IRQDIS_VALUE), "r" (_level) ); + +#else + +#define SH_IRQDIS_MASK 0xf0 + +#define sh_disable_interrupts( _level ) \ + __asm__ volatile ( \ + "stc sr,%0\n\t" \ + "mov %0,r5\n\t" \ + "or %1,r5\n\t" \ + "ldc r5,sr\n\t"\ + : "=&r" (_level ) \ + : "r" (SH_IRQDIS_MASK) \ + : "r5" ); + +#define sh_enable_interrupts( _level ) \ + __asm__ volatile( "ldc %0,sr\n\t" \ + "nop\n\t" \ + :: "r" (_level) ); + +/* + * This temporarily restores the interrupt to _level before immediately + * disabling them again. This is used to divide long RTEMS critical + * sections into two or more parts. The parameter _level is not + * modified. + */ + +#define sh_flash_interrupts( _level ) \ + __asm__ volatile( \ + "stc sr,r5\n\t" \ + "ldc %1,sr\n\t" \ + "nop\n\t" \ + "or %0,r5\n\t" \ + "ldc r5,sr\n\t" \ + "nop\n\t" \ + : : "r" (SH_IRQDIS_MASK), "r" (_level) : "r5"); + +#endif + +#define sh_get_interrupt_level( _level ) \ +{ \ + register uint32_t _tmpsr ; \ + \ + __asm__ volatile( "stc sr, %0" : "=r" (_tmpsr) ); \ + _level = (_tmpsr & 0xf0) >> 4 ; \ +} + +#define sh_set_interrupt_level( _newlevel ) \ +{ \ + register uint32_t _tmpsr; \ + \ + __asm__ volatile ( "stc sr, %0" : "=r" (_tmpsr) ); \ + _tmpsr = ( _tmpsr & ~0xf0 ) | ((_newlevel) << 4) ; \ + __asm__ volatile( "ldc %0,sr" :: "r" (_tmpsr) ); \ +} + +/* + * The following routine swaps the endian format of an unsigned int. + * It must be static because it is referenced indirectly. + */ + +static inline uint32_t sh_swap_u32( + uint32_t value +) +{ + register uint32_t swapped; + + __asm__ volatile ( + "swap.b %1,%0; " + "swap.w %0,%0; " + "swap.b %0,%0" + : "=r" (swapped) + : "r" (value) ); + + return( swapped ); +} + +static inline uint16_t sh_swap_u16( + uint16_t value +) +{ + register uint16_t swapped ; + + __asm__ volatile ( "swap.b %1,%0" : "=r" (swapped) : "r" (value) ); + + return( swapped ); +} + +#define CPU_swap_u32( value ) sh_swap_u32( value ) +#define CPU_swap_u16( value ) sh_swap_u16( value ) + +extern unsigned int sh_set_irq_priority( + unsigned int irq, + unsigned int prio ); + +#endif /* !ASM */ + +/* + * Bits on SH-4 registers. + * See SH-4 Programming manual for more details. + * + * Added by Alexandra Kossovsky + */ + +#if defined(__SH4__) +#define SH4_SR_MD 0x40000000 /* Priveleged mode */ +#define SH4_SR_RB 0x20000000 /* General register bank specifier */ +#define SH4_SR_BL 0x10000000 /* Exeption/interrupt masking bit */ +#define SH4_SR_FD 0x00008000 /* FPU disable bit */ +#define SH4_SR_M 0x00000200 /* For signed division: + divisor (module) is negative */ +#define SH4_SR_Q 0x00000100 /* For signed division: + dividend (and quotient) is negative */ +#define SH4_SR_IMASK 0x000000f0 /* Interrupt mask level */ +#define SH4_SR_IMASK_S 4 +#define SH4_SR_S 0x00000002 /* Saturation for MAC instruction: + if set, data in MACH/L register + is restricted to 48/32 bits + for MAC.W/L instructions */ +#define SH4_SR_T 0x00000001 /* 1 if last condiyion was true */ +#define SH4_SR_RESERV 0x8fff7d0d /* Reserved bits, read/write as 0 */ + +/* FPSCR -- FPU Status/Control Register */ +#define SH4_FPSCR_FR 0x00200000 /* FPU register bank specifier */ +#define SH4_FPSCR_SZ 0x00100000 /* FMOV 64-bit transfer mode */ +#define SH4_FPSCR_PR 0x00080000 /* Double-percision floating-point + operations flag */ + /* SH4_FPSCR_SZ & SH4_FPSCR_PR != 1 */ +#define SH4_FPSCR_DN 0x00040000 /* Treat denormalized number as zero */ +#define SH4_FPSCR_CAUSE 0x0003f000 /* FPU exeption cause field */ +#define SH4_FPSCR_CAUSE_S 12 +#define SH4_FPSCR_ENABLE 0x00000f80 /* FPU exeption enable field */ +#define SH4_FPSCR_ENABLE_s 7 +#define SH4_FPSCR_FLAG 0x0000007d /* FPU exeption flag field */ +#define SH4_FPSCR_FLAG_S 2 +#define SH4_FPSCR_RM 0x00000001 /* Rounding mode: + 1/0 -- round to zero/nearest */ +#define SH4_FPSCR_RESERV 0xffd00000 /* Reserved bits, read/write as 0 */ + +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/score/cpu/sh/include/rtems/score/sh_io.h b/cpukit/score/cpu/sh/include/rtems/score/sh_io.h new file mode 100644 index 0000000000..8d81965f78 --- /dev/null +++ b/cpukit/score/cpu/sh/include/rtems/score/sh_io.h @@ -0,0 +1,51 @@ +/** + * @file + * + * @brief Macros to Access Memory Mapped Devices on the SH7000-Architecture + * + * These are some macros to access memory mapped devices + * on the SH7000-architecture. + */ + +/* + * Inspired from the linux kernel's include/asm/io.h + * + * Authors: Ralf Corsepius (corsepiu@faw.uni-ulm.de) and + * Bernd Becker (becker@faw.uni-ulm.de) + * + * COPYRIGHT (c) 1996-1998, FAW Ulm, Germany + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * + * COPYRIGHT (c) 1998-2001. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SH_IO_H +#define _RTEMS_SCORE_SH_IO_H + +#define readb(addr) (*(volatile unsigned char *) (addr)) +#define readw(addr) (*(volatile unsigned short *) (addr)) +#define readl(addr) (*(volatile unsigned int *) (addr)) +#define read8(addr) (*(volatile uint8_t *) (addr)) +#define read16(addr) (*(volatile uint16_t *) (addr)) +#define read32(addr) (*(volatile uint32_t *) (addr)) + +#define writeb(b,addr) ((*(volatile unsigned char *) (addr)) = (b)) +#define writew(b,addr) ((*(volatile unsigned short *) (addr)) = (b)) +#define writel(b,addr) ((*(volatile unsigned int *) (addr)) = (b)) +#define write8(b,addr) ((*(volatile uint8_t *) (addr)) = (b)) +#define write16(b,addr) ((*(volatile uint16_t *) (addr)) = (b)) +#define write32(b,addr) ((*(volatile uint32_t *) (addr)) = (b)) + +#define inb(addr) readb(addr) +#define outb(b,addr) writeb(b,addr) + +#endif diff --git a/cpukit/score/cpu/sh/include/rtems/score/types.h b/cpukit/score/cpu/sh/include/rtems/score/types.h new file mode 100644 index 0000000000..a449a6d6e3 --- /dev/null +++ b/cpukit/score/cpu/sh/include/rtems/score/types.h @@ -0,0 +1,56 @@ +/** + * @file + * + * @brief Hitachi SH CPU Type Definitions + * + * This include file contains information pertaining to the Hitachi SH + * processor. + */ + +/* + * Authors: Ralf Corsepius (corsepiu@faw.uni-ulm.de) and + * Bernd Becker (becker@faw.uni-ulm.de) + * + * COPYRIGHT (c) 1997-1998, FAW Ulm, Germany + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * + * COPYRIGHT (c) 1998-2001. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_TYPES_H +#define _RTEMS_SCORE_TYPES_H + +#include + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This section defines the basic types for this processor. + */ + +/** Type that can store a 32-bit integer or a pointer. */ +typedef uintptr_t CPU_Uint32ptr; + +typedef void sh_isr; +typedef void ( *sh_isr_entry )( void ); + +#ifdef __cplusplus +} +#endif + +#endif /* !ASM */ + +#endif diff --git a/cpukit/score/cpu/sh/preinstall.am b/cpukit/score/cpu/sh/preinstall.am deleted file mode 100644 index 08d2352709..0000000000 --- a/cpukit/score/cpu/sh/preinstall.am +++ /dev/null @@ -1,53 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -$(PROJECT_INCLUDE)/rtems/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems - @: > $(PROJECT_INCLUDE)/rtems/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/asm.h: rtems/asm.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/asm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/asm.h - -$(PROJECT_INCLUDE)/rtems/score/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/score - @: > $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/score/cpu.h: rtems/score/cpu.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpu.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpu.h - -$(PROJECT_INCLUDE)/rtems/score/cpuimpl.h: rtems/score/cpuimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h - -$(PROJECT_INCLUDE)/rtems/score/types.h: rtems/score/types.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/types.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/types.h - -$(PROJECT_INCLUDE)/rtems/score/sh.h: rtems/score/sh.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/sh.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/sh.h - -$(PROJECT_INCLUDE)/rtems/score/sh_io.h: rtems/score/sh_io.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/sh_io.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/sh_io.h - -$(PROJECT_INCLUDE)/rtems/score/cpuatomic.h: rtems/score/cpuatomic.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h - diff --git a/cpukit/score/cpu/sh/rtems/asm.h b/cpukit/score/cpu/sh/rtems/asm.h deleted file mode 100644 index ac730310cd..0000000000 --- a/cpukit/score/cpu/sh/rtems/asm.h +++ /dev/null @@ -1,137 +0,0 @@ -/** - * @file - * - * @brief Address the Problems Caused by Incompatible Flavor of - * Assemblers and Toolsets - * - * This include file attempts to address the problems - * caused by incompatible flavors of assemblers and - * toolsets. It primarily addresses variations in the - * use of leading underscores on symbols and the requirement - * that register names be preceded by a %. - * - * @note The spacing in the use of these macros - * is critical to them working as advertised. - */ - -/* - * Authors: Ralf Corsepius (corsepiu@faw.uni-ulm.de) and - * Bernd Becker (becker@faw.uni-ulm.de) - * - * COPYRIGHT: - * - * This file is based on similar code found in newlib available - * from ftp.cygnus.com. The file which was used had no copyright - * notice. This file is freely distributable as long as the source - * of the file is noted. This file is: - * - * - * COPYRIGHT (c) 1997-1998, FAW Ulm, Germany - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * - * COPYRIGHT (c) 1998-2001. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_ASM_H -#define _RTEMS_ASM_H - -/* - * Indicate we are in an assembly file and get the basic CPU definitions. - */ - -#ifndef ASM -#define ASM -#endif - -#include -#include - -/* - * Recent versions of GNU cpp define variables which indicate the - * need for underscores and percents. If not using GNU cpp or - * the version does not support this, then you will obviously - * have to define these as appropriate. - */ - -#ifndef __USER_LABEL_PREFIX__ -#define __USER_LABEL_PREFIX__ _ -#endif - -#ifndef __REGISTER_PREFIX__ -#define __REGISTER_PREFIX__ -#endif - -#include - -/* Use the right prefix for global labels. */ - -#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) - -/* Use the right prefix for registers. */ - -#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) - -/* - * define macros for all of the registers on this CPU - * - * EXAMPLE: #define d0 REG (d0) - */ -#define r0 REG (r0) -#define r1 REG (r1) -#define r2 REG (r2) -#define r3 REG (r3) -#define r4 REG (r4) -#define r5 REG (r5) -#define r6 REG (r6) -#define r7 REG (r7) -#define r8 REG (r8) -#define r9 REG (r9) -#define r10 REG (r10) -#define r11 REG (r11) -#define r12 REG (r12) -#define r13 REG (r13) -#define r14 REG (r14) -#define r15 REG (r15) -#define vbr REG (vbr) -#define gbr REG (gbr) -#define pr REG (pr) -#define mach REG (mach) -#define macl REG (macl) -#define sr REG (sr) -#define pc REG (pc) - -/* - * Define macros to handle section beginning and ends. - */ - - -#define BEGIN_CODE_DCL .text -#define END_CODE_DCL -#define BEGIN_DATA_DCL .data -#define END_DATA_DCL -#define BEGIN_CODE .text -#define END_CODE -#define BEGIN_DATA -#define END_DATA -#define BEGIN_BSS -#define END_BSS -#define END - -/* - * Following must be tailor for a particular flavor of the C compiler. - * They may need to put underscores in front of the symbols. - */ - -#define PUBLIC(sym) .global SYM (sym) -#define EXTERN(sym) .global SYM (sym) - -#endif diff --git a/cpukit/score/cpu/sh/rtems/score/cpu.h b/cpukit/score/cpu/sh/rtems/score/cpu.h deleted file mode 100644 index c2b7081e9e..0000000000 --- a/cpukit/score/cpu/sh/rtems/score/cpu.h +++ /dev/null @@ -1,738 +0,0 @@ -/** - * @file rtems/score/cpu.h - */ - -/* - * This include file contains information pertaining to the Hitachi SH - * processor. - * - * Authors: Ralf Corsepius (corsepiu@faw.uni-ulm.de) and - * Bernd Becker (becker@faw.uni-ulm.de) - * - * COPYRIGHT (c) 1997-1998, FAW Ulm, Germany - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * - * COPYRIGHT (c) 1998-2006. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPU_H -#define _RTEMS_SCORE_CPU_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/* conditional compilation parameters */ - -/* - * Does the CPU follow the simple vectored interrupt model? - * - * If TRUE, then RTEMS allocates the vector table it internally manages. - * If FALSE, then the BSP is assumed to allocate and manage the vector - * table - * - * SH Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_SIMPLE_VECTORED_INTERRUPTS TRUE - -/* - * Does RTEMS manage a dedicated interrupt stack in software? - * - * If TRUE, then a stack is allocated in _ISR_Handler_initialization. - * If FALSE, nothing is done. - * - * If the CPU supports a dedicated interrupt stack in hardware, - * then it is generally the responsibility of the BSP to allocate it - * and set it up. - * - * If the CPU does not support a dedicated interrupt stack, then - * the porter has two options: (1) execute interrupts on the - * stack of the interrupted task, and (2) have RTEMS manage a dedicated - * interrupt stack. - * - * If this is TRUE, CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. - * - * Only one of CPU_HAS_SOFTWARE_INTERRUPT_STACK and - * CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is - * possible that both are FALSE for a particular CPU. Although it - * is unclear what that would imply about the interrupt processing - * procedure on that CPU. - */ - -#define CPU_HAS_SOFTWARE_INTERRUPT_STACK TRUE -#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE - -/* - * We define the interrupt stack in the linker script - */ -#define CPU_ALLOCATE_INTERRUPT_STACK FALSE - -/* - * Does the RTEMS invoke the user's ISR with the vector number and - * a pointer to the saved interrupt frame (1) or just the vector - * number (0)? - */ - -#define CPU_ISR_PASSES_FRAME_POINTER FALSE - -/* - * Does the CPU have hardware floating point? - * - * If TRUE, then the RTEMS_FLOATING_POINT task attribute is supported. - * If FALSE, then the RTEMS_FLOATING_POINT task attribute is ignored. - * - * We currently support sh1 only, which has no FPU, other SHes have an FPU - * - * The macro name "SH_HAS_FPU" should be made CPU specific. - * It indicates whether or not this CPU model has FP support. For - * example, it would be possible to have an i386_nofp CPU model - * which set this to false to indicate that you have an i386 without - * an i387 and wish to leave floating point support out of RTEMS. - */ - -#if SH_HAS_FPU -#define CPU_HARDWARE_FP TRUE -#define CPU_SOFTWARE_FP FALSE -#else -#define CPU_SOFTWARE_FP FALSE -#define CPU_HARDWARE_FP FALSE -#endif - -/* - * Are all tasks RTEMS_FLOATING_POINT tasks implicitly? - * - * If TRUE, then the RTEMS_FLOATING_POINT task attribute is assumed. - * If FALSE, then the RTEMS_FLOATING_POINT task attribute is followed. - * - * If CPU_HARDWARE_FP is FALSE, then this should be FALSE as well. - */ - -#if SH_HAS_FPU -#define CPU_ALL_TASKS_ARE_FP TRUE -#else -#define CPU_ALL_TASKS_ARE_FP FALSE -#endif - -/* - * Should the IDLE task have a floating point context? - * - * If TRUE, then the IDLE task is created as a RTEMS_FLOATING_POINT task - * and it has a floating point context which is switched in and out. - * If FALSE, then the IDLE task does not have a floating point context. - * - * Setting this to TRUE negatively impacts the time required to preempt - * the IDLE task from an interrupt because the floating point context - * must be saved as part of the preemption. - */ - -#if SH_HAS_FPU -#define CPU_IDLE_TASK_IS_FP TRUE -#else -#define CPU_IDLE_TASK_IS_FP FALSE -#endif - -/* - * Should the saving of the floating point registers be deferred - * until a context switch is made to another different floating point - * task? - * - * If TRUE, then the floating point context will not be stored until - * necessary. It will remain in the floating point registers and not - * disturned until another floating point task is switched to. - * - * If FALSE, then the floating point context is saved when a floating - * point task is switched out and restored when the next floating point - * task is restored. The state of the floating point registers between - * those two operations is not specified. - * - * If the floating point context does NOT have to be saved as part of - * interrupt dispatching, then it should be safe to set this to TRUE. - * - * Setting this flag to TRUE results in using a different algorithm - * for deciding when to save and restore the floating point context. - * The deferred FP switch algorithm minimizes the number of times - * the FP context is saved and restored. The FP context is not saved - * until a context switch is made to another, different FP task. - * Thus in a system with only one FP task, the FP context will never - * be saved or restored. - */ - -#if SH_HAS_FPU -#define CPU_USE_DEFERRED_FP_SWITCH FALSE -#else -#define CPU_USE_DEFERRED_FP_SWITCH TRUE -#endif - -#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE - -/* - * Does this port provide a CPU dependent IDLE task implementation? - * - * If TRUE, then the routine _CPU_Thread_Idle_body - * must be provided and is the default IDLE thread body instead of - * _CPU_Thread_Idle_body. - * - * If FALSE, then use the generic IDLE thread body if the BSP does - * not provide one. - * - * This is intended to allow for supporting processors which have - * a low power or idle mode. When the IDLE thread is executed, then - * the CPU can be powered down. - * - * The order of precedence for selecting the IDLE thread body is: - * - * 1. BSP provided - * 2. CPU dependent (if provided) - * 3. generic (if no BSP and no CPU dependent) - */ - -#define CPU_PROVIDES_IDLE_THREAD_BODY TRUE - -/* - * Does the stack grow up (toward higher addresses) or down - * (toward lower addresses)? - * - * If TRUE, then the grows upward. - * If FALSE, then the grows toward smaller addresses. - */ - -#define CPU_STACK_GROWS_UP FALSE - -/* FIXME: Is this the right value? */ -#define CPU_CACHE_LINE_BYTES 16 - -#define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES ) - -/* - * The following defines the number of bits actually used in the - * interrupt field of the task mode. How those bits map to the - * CPU interrupt levels is defined by the routine _CPU_ISR_Set_level(). - */ - -#define CPU_MODES_INTERRUPT_MASK 0x0000000f - -#define CPU_MAXIMUM_PROCESSORS 32 - -/* - * Processor defined structures required for cpukit/score. - */ - -/* may need to put some structures here. */ - -/* - * Contexts - * - * Generally there are 2 types of context to save. - * 1. Interrupt registers to save - * 2. Task level registers to save - * - * This means we have the following 3 context items: - * 1. task level context stuff:: Context_Control - * 2. floating point task stuff:: Context_Control_fp - * 3. special interrupt level context :: Context_Control_interrupt - * - * On some processors, it is cost-effective to save only the callee - * preserved registers during a task context switch. This means - * that the ISR code needs to save those registers which do not - * persist across function calls. It is not mandatory to make this - * distinctions between the caller/callee saves registers for the - * purpose of minimizing context saved during task switch and on interrupts. - * If the cost of saving extra registers is minimal, simplicity is the - * choice. Save the same context on interrupt entry as for tasks in - * this case. - * - * Additionally, if gdb is to be made aware of RTEMS tasks for this CPU, then - * care should be used in designing the context area. - * - * On some CPUs with hardware floating point support, the Context_Control_fp - * structure will not be used or it simply consist of an array of a - * fixed number of bytes. This is done when the floating point context - * is dumped by a "FP save context" type instruction and the format - * is not really defined by the CPU. In this case, there is no need - * to figure out the exact format -- only the size. Of course, although - * this is enough information for RTEMS, it is probably not enough for - * a debugger such as gdb. But that is another problem. - */ - -typedef struct { - uint32_t *r15; /* stack pointer */ - - uint32_t macl; - uint32_t mach; - uint32_t *pr; - - uint32_t *r14; /* frame pointer/call saved */ - - uint32_t r13; /* call saved */ - uint32_t r12; /* call saved */ - uint32_t r11; /* call saved */ - uint32_t r10; /* call saved */ - uint32_t r9; /* call saved */ - uint32_t r8; /* call saved */ - - uint32_t *r7; /* arg in */ - uint32_t *r6; /* arg in */ - -#if 0 - uint32_t *r5; /* arg in */ - uint32_t *r4; /* arg in */ -#endif - - uint32_t *r3; /* scratch */ - uint32_t *r2; /* scratch */ - uint32_t *r1; /* scratch */ - - uint32_t *r0; /* arg return */ - - uint32_t gbr; - uint32_t sr; - -} Context_Control; - -#define _CPU_Context_Get_SP( _context ) \ - (_context)->r15 - -typedef struct { -#if SH_HAS_FPU -#ifdef SH4_USE_X_REGISTERS - union { - float f[16]; - double d[8]; - } x; -#endif - union { - float f[16]; - double d[8]; - } r; - float fpul; /* fp communication register */ - uint32_t fpscr; /* fp control register */ -#endif /* SH_HAS_FPU */ -} Context_Control_fp; - -typedef struct { -} CPU_Interrupt_frame; - -/* - * This variable is optional. It is used on CPUs on which it is difficult - * to generate an "uninitialized" FP context. It is filled in by - * _CPU_Initialize and copied into the task's FP context area during - * _CPU_Context_Initialize. - */ - -#if SH_HAS_FPU -extern Context_Control_fp _CPU_Null_fp_context; -#endif - -/* - * Nothing prevents the porter from declaring more CPU specific variables. - */ - -/* XXX: if needed, put more variables here */ -void CPU_delay( uint32_t microseconds ); - -/* - * The size of the floating point context area. On some CPUs this - * will not be a "sizeof" because the format of the floating point - * area is not defined -- only the size is. This is usually on - * CPUs with a "floating point save context" instruction. - */ - -#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp ) - -/* - * Amount of extra stack (above minimum stack size) required by - * MPCI receive server thread. Remember that in a multiprocessor - * system this thread must exist and be able to process all directives. - */ - -#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0 - -/* - * This defines the number of entries in the ISR_Vector_table managed - * by RTEMS. - */ - -#define CPU_INTERRUPT_NUMBER_OF_VECTORS 256 -#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER (CPU_INTERRUPT_NUMBER_OF_VECTORS - 1) - -/* - * This is defined if the port has a special way to report the ISR nesting - * level. Most ports maintain the variable _ISR_Nest_level. - */ - -#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE - -/* - * Should be large enough to run all RTEMS tests. This ensures - * that a "reasonable" small application should not have any problems. - * - * We have been able to run the sptests with this value, but have not - * been able to run the tmtest suite. - */ - -#define CPU_STACK_MINIMUM_SIZE 4096 - -#define CPU_SIZEOF_POINTER 4 - -/* - * CPU's worst alignment requirement for data types on a byte boundary. This - * alignment does not take into account the requirements for the stack. - */ -#if defined(__SH4__) -/* FIXME: sh3 and SH3E? */ -#define CPU_ALIGNMENT 8 -#else -#define CPU_ALIGNMENT 4 -#endif - -/* - * This number corresponds to the byte alignment requirement for the - * heap handler. This alignment requirement may be stricter than that - * for the data types alignment specified by CPU_ALIGNMENT. It is - * common for the heap to follow the same alignment requirement as - * CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict enough for the heap, - * then this should be set to CPU_ALIGNMENT. - * - * NOTE: This does not have to be a power of 2. It does have to - * be greater or equal to than CPU_ALIGNMENT. - */ - -#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT - -/* - * This number corresponds to the byte alignment requirement for memory - * buffers allocated by the partition manager. This alignment requirement - * may be stricter than that for the data types alignment specified by - * CPU_ALIGNMENT. It is common for the partition to follow the same - * alignment requirement as CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict - * enough for the partition, then this should be set to CPU_ALIGNMENT. - * - * NOTE: This does not have to be a power of 2. It does have to - * be greater or equal to than CPU_ALIGNMENT. - */ - -#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT - -/* - * This number corresponds to the byte alignment requirement for the - * stack. This alignment requirement may be stricter than that for the - * data types alignment specified by CPU_ALIGNMENT. If the CPU_ALIGNMENT - * is strict enough for the stack, then this should be set to 0. - * - * NOTE: This must be a power of 2 either 0 or greater than CPU_ALIGNMENT. - */ - -#define CPU_STACK_ALIGNMENT CPU_ALIGNMENT - -/* - * ISR handler macros - */ - -/* - * Support routine to initialize the RTEMS vector table after it is allocated. - * - * SH Specific Information: NONE - */ - -#define _CPU_Initialize_vectors() - -/* - * Disable all interrupts for an RTEMS critical section. The previous - * level is returned in _level. - */ - -#define _CPU_ISR_Disable( _level) \ - sh_disable_interrupts( _level ) - -/* - * Enable interrupts to the previous level (returned by _CPU_ISR_Disable). - * This indicates the end of an RTEMS critical section. The parameter - * _level is not modified. - */ - -#define _CPU_ISR_Enable( _level) \ - sh_enable_interrupts( _level) - -/* - * This temporarily restores the interrupt to _level before immediately - * disabling them again. This is used to divide long RTEMS critical - * sections into two or more parts. The parameter _level is not - * modified. - */ - -#define _CPU_ISR_Flash( _level) \ - sh_flash_interrupts( _level) - -RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) -{ - sh_get_interrupt_level( level ); - return level == 0; -} - -/* - * Map interrupt level in task mode onto the hardware that the CPU - * actually provides. Currently, interrupt levels which do not - * map onto the CPU in a generic fashion are undefined. Someday, - * it would be nice if these were "mapped" by the application - * via a callout. For example, m68k has 8 levels 0 - 7, levels - * 8 - 255 would be available for bsp/application specific meaning. - * This could be used to manage a programmable interrupt controller - * via the rtems_task_mode directive. - */ - -#define _CPU_ISR_Set_level( _newlevel) \ - sh_set_interrupt_level(_newlevel) - -uint32_t _CPU_ISR_Get_level( void ); - -/* end of ISR handler macros */ - -/* Context handler macros */ - -/* - * Initialize the context to a state suitable for starting a - * task after a context restore operation. Generally, this - * involves: - * - * - setting a starting address - * - preparing the stack - * - preparing the stack and frame pointers - * - setting the proper interrupt level in the context - * - initializing the floating point context - * - * This routine generally does not set any unnecessary register - * in the context. The state of the "general data" registers is - * undefined at task start time. - * - * NOTE: This is_fp parameter is TRUE if the thread is to be a floating - * point thread. This is typically only used on CPUs where the - * FPU may be easily disabled by software such as on the SPARC - * where the PSR contains an enable FPU bit. - */ - -/* - * FIXME: defined as a function for debugging - should be a macro - */ -void _CPU_Context_Initialize( - Context_Control *_the_context, - void *_stack_base, - uint32_t _size, - uint32_t _isr, - void (*_entry_point)(void), - int _is_fp, - void *_tls_area ); - -/* - * This routine is responsible for somehow restarting the currently - * executing task. If you are lucky, then all that is necessary - * is restoring the context. Otherwise, there will need to be - * a special assembly routine which does something special in this - * case. Context_Restore should work most of the time. It will - * not work if restarting self conflicts with the stack frame - * assumptions of restoring a context. - */ - -#define _CPU_Context_Restart_self( _the_context ) \ - _CPU_Context_restore( (_the_context) ); - -/* - * This routine initializes the FP context area passed to it to. - * There are a few standard ways in which to initialize the - * floating point context. The code included for this macro assumes - * that this is a CPU in which a "initial" FP context was saved into - * _CPU_Null_fp_context and it simply copies it to the destination - * context passed to it. - * - * Other models include (1) not doing anything, and (2) putting - * a "null FP status word" in the correct place in the FP context. - * SH1, SH2, SH3 have no FPU, but the SH3e and SH4 have. - */ - -#if SH_HAS_FPU -#define _CPU_Context_Initialize_fp( _destination ) \ - do { \ - *(*(_destination)) = _CPU_Null_fp_context;\ - } while(0) -#else -#define _CPU_Context_Initialize_fp( _destination ) \ - { } -#endif - -/* end of Context handler macros */ - -/* Fatal Error manager macros */ - -/* - * FIXME: Trap32 ??? - * - * This routine copies _error into a known place -- typically a stack - * location or a register, optionally disables interrupts, and - * invokes a Trap32 Instruction which returns to the breakpoint - * routine of cmon. - */ - -#ifdef BSP_FATAL_HALT - /* we manage the fatal error in the board support package */ - void bsp_fatal_halt( uint32_t _error); -#define _CPU_Fatal_halt( _source, _error ) bsp_fatal_halt( _error) -#else -#define _CPU_Fatal_halt( _source, _error)\ -{ \ - __asm__ volatile("mov.l %0,r0"::"m" (_error)); \ - __asm__ volatile("mov #1, r4"); \ - __asm__ volatile("trapa #34"); \ -} -#endif - -/* end of Fatal Error manager macros */ - -#define CPU_USE_GENERIC_BITFIELD_CODE TRUE - -/* functions */ - -/* - * @brief CPU Initialize - * - * _CPU_Initialize - * - * This routine performs CPU dependent initialization. - */ -void _CPU_Initialize(void); - -/* - * _CPU_ISR_install_raw_handler - * - * This routine installs a "raw" interrupt handler directly into the - * processor's vector table. - */ - -void _CPU_ISR_install_raw_handler( - uint32_t vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -/* - * _CPU_ISR_install_vector - * - * This routine installs an interrupt vector. - */ - -void _CPU_ISR_install_vector( - uint32_t vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -/* - * _CPU_Install_interrupt_stack - * - * This routine installs the hardware interrupt stack pointer. - * - * NOTE: It needs only be provided if CPU_HAS_HARDWARE_INTERRUPT_STACK - * is TRUE. - */ - -void _CPU_Install_interrupt_stack( void ); - -/* - * _CPU_Thread_Idle_body - * - * This routine is the CPU dependent IDLE thread body. - * - * NOTE: It need only be provided if CPU_PROVIDES_IDLE_THREAD_BODY - * is TRUE. - */ - -void *_CPU_Thread_Idle_body( uintptr_t ignored ); - -/* - * _CPU_Context_switch - * - * This routine switches from the run context to the heir context. - */ - -void _CPU_Context_switch( - Context_Control *run, - Context_Control *heir -); - -/* - * _CPU_Context_restore - * - * This routine is generally used only to restart self in an - * efficient manner. It may simply be a label in _CPU_Context_switch. - */ - -void _CPU_Context_restore( - Context_Control *new_context -) RTEMS_NO_RETURN; - -/* - * @brief This routine saves the floating point context passed to it. - * - * _CPU_Context_save_fp - * - */ -void _CPU_Context_save_fp( - Context_Control_fp **fp_context_ptr -); - -/* - * @brief This routine restores the floating point context passed to it. - * - * _CPU_Context_restore_fp - * - */ -void _CPU_Context_restore_fp( - Context_Control_fp **fp_context_ptr -); - -static inline void _CPU_Context_volatile_clobber( uintptr_t pattern ) -{ - /* TODO */ -} - -static inline void _CPU_Context_validate( uintptr_t pattern ) -{ - while (1) { - /* TODO */ - } -} - -/* FIXME */ -typedef CPU_Interrupt_frame CPU_Exception_frame; - -void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); - -typedef uint32_t CPU_Counter_ticks; - -CPU_Counter_ticks _CPU_Counter_read( void ); - -static inline CPU_Counter_ticks _CPU_Counter_difference( - CPU_Counter_ticks second, - CPU_Counter_ticks first -) -{ - return second - first; -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/score/cpu/sh/rtems/score/cpuatomic.h b/cpukit/score/cpu/sh/rtems/score/cpuatomic.h deleted file mode 100644 index 598ee76b20..0000000000 --- a/cpukit/score/cpu/sh/rtems/score/cpuatomic.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * COPYRIGHT (c) 2012-2013 Deng Hengyi. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_ATOMIC_CPU_H -#define _RTEMS_SCORE_ATOMIC_CPU_H - -#include - -#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/sh/rtems/score/cpuimpl.h b/cpukit/score/cpu/sh/rtems/score/cpuimpl.h deleted file mode 100644 index 789f2badd9..0000000000 --- a/cpukit/score/cpu/sh/rtems/score/cpuimpl.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @file - * - * @brief CPU Port Implementation API - */ - -/* - * Copyright (c) 2013 embedded brains GmbH - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPUIMPL_H -#define _RTEMS_SCORE_CPUIMPL_H - -#include - -#define CPU_PER_CPU_CONTROL_SIZE 0 - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* ASM */ - -#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/sh/rtems/score/sh.h b/cpukit/score/cpu/sh/rtems/score/sh.h deleted file mode 100644 index 4e26478b8b..0000000000 --- a/cpukit/score/cpu/sh/rtems/score/sh.h +++ /dev/null @@ -1,277 +0,0 @@ -/** - * @file - * - * @brief Hitachi SH CPU Department Source - * - * This include file contains information pertaining to the Hitachi SH - * processor. - */ - -/* - * Authors: Ralf Corsepius (corsepiu@faw.uni-ulm.de) and - * Bernd Becker (becker@faw.uni-ulm.de) - * - * COPYRIGHT (c) 1997-1998, FAW Ulm, Germany - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE - * - * - * COPYRIGHT (c) 1998-2001. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SH_H -#define _RTEMS_SCORE_SH_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This file contains the information required to build - * RTEMS for a particular member of the "SH" family. - * - * It does this by setting variables to indicate which implementation - * dependent features are present in a particular member of the family. - */ - -/* - * Figure out all CPU Model Feature Flags based upon compiler - * predefines. - */ - -#if defined(__SH2E__) || defined(__SH3E__) - -/* FIXME: SH-DSP context not currently supported */ -#define SH_HAS_FPU 0 - -#elif defined(__SH4__) || defined(__SH4_SINGLE_ONLY__) - -/* - * Define this if you want to use XD-registers. - * Then this registers will be saved/restored on context switch. - * ! They will not be saved/restored on interrupts! - */ -#define SH4_USE_X_REGISTERS 0 - -#if defined(__LITTLE_ENDIAN__) -#define SH_HAS_FPU 1 -#else -/* FIXME: Context_Control_fp does not support big endian */ -#warning FPU not supported -#define SH_HAS_FPU 0 -#endif - -#elif defined(__sh1__) || defined(__sh2__) || defined(__sh3__) -#define SH_HAS_FPU 0 -#else -#warning Cannot detect FPU support, assuming no FPU -#define SH_HAS_FPU 0 -#endif - -/* this should not be here */ -#ifndef CPU_MODEL_NAME -#define CPU_MODEL_NAME "SH-Multilib" -#endif - -/* - * If the following macro is set to 0 there will be no software irq stack - */ - -#ifndef SH_HAS_SEPARATE_STACKS -#define SH_HAS_SEPARATE_STACKS 1 -#endif - -/* - * Define the name of the CPU family. - */ - -#define CPU_NAME "Hitachi SH" - -#ifndef ASM - -#if defined(__sh1__) || defined(__sh2__) - -/* - * Mask for disabling interrupts - */ -#define SH_IRQDIS_VALUE 0xf0 - -#define sh_disable_interrupts( _level ) \ - __asm__ volatile ( \ - "stc sr,%0\n\t" \ - "ldc %1,sr\n\t"\ - : "=&r" (_level ) \ - : "r" (SH_IRQDIS_VALUE) ); - -#define sh_enable_interrupts( _level ) \ - __asm__ volatile( "ldc %0,sr\n\t" \ - "nop\n\t" \ - :: "r" (_level) ); - -/* - * This temporarily restores the interrupt to _level before immediately - * disabling them again. This is used to divide long RTEMS critical - * sections into two or more parts. The parameter _level is not - * modified. - */ - -#define sh_flash_interrupts( _level ) \ - __asm__ volatile( \ - "ldc %1,sr\n\t" \ - "nop\n\t" \ - "ldc %0,sr\n\t" \ - "nop\n\t" \ - : : "r" (SH_IRQDIS_VALUE), "r" (_level) ); - -#else - -#define SH_IRQDIS_MASK 0xf0 - -#define sh_disable_interrupts( _level ) \ - __asm__ volatile ( \ - "stc sr,%0\n\t" \ - "mov %0,r5\n\t" \ - "or %1,r5\n\t" \ - "ldc r5,sr\n\t"\ - : "=&r" (_level ) \ - : "r" (SH_IRQDIS_MASK) \ - : "r5" ); - -#define sh_enable_interrupts( _level ) \ - __asm__ volatile( "ldc %0,sr\n\t" \ - "nop\n\t" \ - :: "r" (_level) ); - -/* - * This temporarily restores the interrupt to _level before immediately - * disabling them again. This is used to divide long RTEMS critical - * sections into two or more parts. The parameter _level is not - * modified. - */ - -#define sh_flash_interrupts( _level ) \ - __asm__ volatile( \ - "stc sr,r5\n\t" \ - "ldc %1,sr\n\t" \ - "nop\n\t" \ - "or %0,r5\n\t" \ - "ldc r5,sr\n\t" \ - "nop\n\t" \ - : : "r" (SH_IRQDIS_MASK), "r" (_level) : "r5"); - -#endif - -#define sh_get_interrupt_level( _level ) \ -{ \ - register uint32_t _tmpsr ; \ - \ - __asm__ volatile( "stc sr, %0" : "=r" (_tmpsr) ); \ - _level = (_tmpsr & 0xf0) >> 4 ; \ -} - -#define sh_set_interrupt_level( _newlevel ) \ -{ \ - register uint32_t _tmpsr; \ - \ - __asm__ volatile ( "stc sr, %0" : "=r" (_tmpsr) ); \ - _tmpsr = ( _tmpsr & ~0xf0 ) | ((_newlevel) << 4) ; \ - __asm__ volatile( "ldc %0,sr" :: "r" (_tmpsr) ); \ -} - -/* - * The following routine swaps the endian format of an unsigned int. - * It must be static because it is referenced indirectly. - */ - -static inline uint32_t sh_swap_u32( - uint32_t value -) -{ - register uint32_t swapped; - - __asm__ volatile ( - "swap.b %1,%0; " - "swap.w %0,%0; " - "swap.b %0,%0" - : "=r" (swapped) - : "r" (value) ); - - return( swapped ); -} - -static inline uint16_t sh_swap_u16( - uint16_t value -) -{ - register uint16_t swapped ; - - __asm__ volatile ( "swap.b %1,%0" : "=r" (swapped) : "r" (value) ); - - return( swapped ); -} - -#define CPU_swap_u32( value ) sh_swap_u32( value ) -#define CPU_swap_u16( value ) sh_swap_u16( value ) - -extern unsigned int sh_set_irq_priority( - unsigned int irq, - unsigned int prio ); - -#endif /* !ASM */ - -/* - * Bits on SH-4 registers. - * See SH-4 Programming manual for more details. - * - * Added by Alexandra Kossovsky - */ - -#if defined(__SH4__) -#define SH4_SR_MD 0x40000000 /* Priveleged mode */ -#define SH4_SR_RB 0x20000000 /* General register bank specifier */ -#define SH4_SR_BL 0x10000000 /* Exeption/interrupt masking bit */ -#define SH4_SR_FD 0x00008000 /* FPU disable bit */ -#define SH4_SR_M 0x00000200 /* For signed division: - divisor (module) is negative */ -#define SH4_SR_Q 0x00000100 /* For signed division: - dividend (and quotient) is negative */ -#define SH4_SR_IMASK 0x000000f0 /* Interrupt mask level */ -#define SH4_SR_IMASK_S 4 -#define SH4_SR_S 0x00000002 /* Saturation for MAC instruction: - if set, data in MACH/L register - is restricted to 48/32 bits - for MAC.W/L instructions */ -#define SH4_SR_T 0x00000001 /* 1 if last condiyion was true */ -#define SH4_SR_RESERV 0x8fff7d0d /* Reserved bits, read/write as 0 */ - -/* FPSCR -- FPU Status/Control Register */ -#define SH4_FPSCR_FR 0x00200000 /* FPU register bank specifier */ -#define SH4_FPSCR_SZ 0x00100000 /* FMOV 64-bit transfer mode */ -#define SH4_FPSCR_PR 0x00080000 /* Double-percision floating-point - operations flag */ - /* SH4_FPSCR_SZ & SH4_FPSCR_PR != 1 */ -#define SH4_FPSCR_DN 0x00040000 /* Treat denormalized number as zero */ -#define SH4_FPSCR_CAUSE 0x0003f000 /* FPU exeption cause field */ -#define SH4_FPSCR_CAUSE_S 12 -#define SH4_FPSCR_ENABLE 0x00000f80 /* FPU exeption enable field */ -#define SH4_FPSCR_ENABLE_s 7 -#define SH4_FPSCR_FLAG 0x0000007d /* FPU exeption flag field */ -#define SH4_FPSCR_FLAG_S 2 -#define SH4_FPSCR_RM 0x00000001 /* Rounding mode: - 1/0 -- round to zero/nearest */ -#define SH4_FPSCR_RESERV 0xffd00000 /* Reserved bits, read/write as 0 */ - -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/score/cpu/sh/rtems/score/sh_io.h b/cpukit/score/cpu/sh/rtems/score/sh_io.h deleted file mode 100644 index 8d81965f78..0000000000 --- a/cpukit/score/cpu/sh/rtems/score/sh_io.h +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @file - * - * @brief Macros to Access Memory Mapped Devices on the SH7000-Architecture - * - * These are some macros to access memory mapped devices - * on the SH7000-architecture. - */ - -/* - * Inspired from the linux kernel's include/asm/io.h - * - * Authors: Ralf Corsepius (corsepiu@faw.uni-ulm.de) and - * Bernd Becker (becker@faw.uni-ulm.de) - * - * COPYRIGHT (c) 1996-1998, FAW Ulm, Germany - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * - * COPYRIGHT (c) 1998-2001. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SH_IO_H -#define _RTEMS_SCORE_SH_IO_H - -#define readb(addr) (*(volatile unsigned char *) (addr)) -#define readw(addr) (*(volatile unsigned short *) (addr)) -#define readl(addr) (*(volatile unsigned int *) (addr)) -#define read8(addr) (*(volatile uint8_t *) (addr)) -#define read16(addr) (*(volatile uint16_t *) (addr)) -#define read32(addr) (*(volatile uint32_t *) (addr)) - -#define writeb(b,addr) ((*(volatile unsigned char *) (addr)) = (b)) -#define writew(b,addr) ((*(volatile unsigned short *) (addr)) = (b)) -#define writel(b,addr) ((*(volatile unsigned int *) (addr)) = (b)) -#define write8(b,addr) ((*(volatile uint8_t *) (addr)) = (b)) -#define write16(b,addr) ((*(volatile uint16_t *) (addr)) = (b)) -#define write32(b,addr) ((*(volatile uint32_t *) (addr)) = (b)) - -#define inb(addr) readb(addr) -#define outb(b,addr) writeb(b,addr) - -#endif diff --git a/cpukit/score/cpu/sh/rtems/score/types.h b/cpukit/score/cpu/sh/rtems/score/types.h deleted file mode 100644 index a449a6d6e3..0000000000 --- a/cpukit/score/cpu/sh/rtems/score/types.h +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @file - * - * @brief Hitachi SH CPU Type Definitions - * - * This include file contains information pertaining to the Hitachi SH - * processor. - */ - -/* - * Authors: Ralf Corsepius (corsepiu@faw.uni-ulm.de) and - * Bernd Becker (becker@faw.uni-ulm.de) - * - * COPYRIGHT (c) 1997-1998, FAW Ulm, Germany - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * - * COPYRIGHT (c) 1998-2001. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_TYPES_H -#define _RTEMS_SCORE_TYPES_H - -#include - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This section defines the basic types for this processor. - */ - -/** Type that can store a 32-bit integer or a pointer. */ -typedef uintptr_t CPU_Uint32ptr; - -typedef void sh_isr; -typedef void ( *sh_isr_entry )( void ); - -#ifdef __cplusplus -} -#endif - -#endif /* !ASM */ - -#endif diff --git a/cpukit/score/cpu/sparc/Makefile.am b/cpukit/score/cpu/sparc/Makefile.am index e03aabc0ff..1a76a2f009 100644 --- a/cpukit/score/cpu/sparc/Makefile.am +++ b/cpukit/score/cpu/sparc/Makefile.am @@ -1,19 +1,5 @@ include $(top_srcdir)/automake/compile.am -include_libcpudir = $(includedir)/libcpu -include_libcpu_HEADERS = include/libcpu/byteorder.h - -include_rtemsdir = $(includedir)/rtems -include_rtems_HEADERS = rtems/asm.h - -include_rtems_scoredir = $(includedir)/rtems/score -include_rtems_score_HEADERS = rtems/score/sparc.h -include_rtems_score_HEADERS += rtems/score/cpu.h -include_rtems_score_HEADERS += rtems/score/cpuimpl.h -include_rtems_score_HEADERS += rtems/score/sparcimpl.h -include_rtems_score_HEADERS += rtems/score/types.h -include_rtems_score_HEADERS += rtems/score/cpuatomic.h - noinst_LIBRARIES = libscorecpu.a libscorecpu_a_SOURCES = cpu.c libscorecpu_a_SOURCES += sparc-context-volatile-clobber.S @@ -22,5 +8,5 @@ libscorecpu_a_SOURCES += sparc-counter.c libscorecpu_a_SOURCES += sparc-counter-asm.S libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS) -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am +include $(srcdir)/headers.am diff --git a/cpukit/score/cpu/sparc/headers.am b/cpukit/score/cpu/sparc/headers.am new file mode 100644 index 0000000000..89f4f63cf2 --- /dev/null +++ b/cpukit/score/cpu/sparc/headers.am @@ -0,0 +1,22 @@ +## This file was generated by "./boostrap -H". + +include_libcpudir = $(includedir)/libcpu +include_libcpu_HEADERS = +include_libcpu_HEADERS += include/libcpu/byteorder.h + +include_machinedir = $(includedir)/machine +include_machine_HEADERS = +include_machine_HEADERS += include/machine/elf_machdep.h + +include_rtemsdir = $(includedir)/rtems +include_rtems_HEADERS = +include_rtems_HEADERS += include/rtems/asm.h + +include_rtems_scoredir = $(includedir)/rtems/score +include_rtems_score_HEADERS = +include_rtems_score_HEADERS += include/rtems/score/cpu.h +include_rtems_score_HEADERS += include/rtems/score/cpuatomic.h +include_rtems_score_HEADERS += include/rtems/score/cpuimpl.h +include_rtems_score_HEADERS += include/rtems/score/sparc.h +include_rtems_score_HEADERS += include/rtems/score/sparcimpl.h +include_rtems_score_HEADERS += include/rtems/score/types.h diff --git a/cpukit/score/cpu/sparc/include/machine/elf_machdep.h b/cpukit/score/cpu/sparc/include/machine/elf_machdep.h new file mode 100644 index 0000000000..e8f2b630c2 --- /dev/null +++ b/cpukit/score/cpu/sparc/include/machine/elf_machdep.h @@ -0,0 +1,92 @@ +/* $NetBSD: elf_machdep.h,v 1.7 2009/05/30 05:56:53 skrll Exp $ */ + +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2MSB +#define ELF32_MACHDEP_ID_CASES \ + case EM_SPARC: \ + case EM_SPARC32PLUS: \ + break; + +#define ELF64_MACHDEP_ENDIANNESS ELFDATA2MSB +#define ELF64_MACHDEP_ID_CASES \ + case EM_SPARC32PLUS: \ + case EM_SPARCV9: \ + /* no 64-bit ELF machine types supported */ + +#define ELF32_MACHDEP_ID EM_SPARC /* XXX right? */ + +#define ARCH_ELFSIZE 32 /* MD native binary size */ + +#define R_SPARC_NONE 0 +#define R_SPARC_8 1 +#define R_SPARC_16 2 +#define R_SPARC_32 3 +#define R_SPARC_DISP8 4 +#define R_SPARC_DISP16 5 +#define R_SPARC_DISP32 6 +#define R_SPARC_WDISP30 7 +#define R_SPARC_WDISP22 8 +#define R_SPARC_HI22 9 +#define R_SPARC_22 10 +#define R_SPARC_13 11 +#define R_SPARC_LO10 12 +#define R_SPARC_GOT10 13 +#define R_SPARC_GOT13 14 +#define R_SPARC_GOT22 15 +#define R_SPARC_PC10 16 +#define R_SPARC_PC22 17 +#define R_SPARC_WPLT30 18 +#define R_SPARC_COPY 19 +#define R_SPARC_GLOB_DAT 20 +#define R_SPARC_JMP_SLOT 21 +#define R_SPARC_RELATIVE 22 +#define R_SPARC_UA32 23 +#define R_SPARC_PLT32 24 +#define R_SPARC_HIPLT22 25 +#define R_SPARC_LOPLT10 26 +#define R_SPARC_PCPLT32 27 +#define R_SPARC_PCPLT22 28 +#define R_SPARC_PCPLT10 29 +#define R_SPARC_10 30 +#define R_SPARC_11 31 +#define R_SPARC_64 32 +#define R_SPARC_OLO10 33 +#define R_SPARC_HH22 34 +#define R_SPARC_HM10 35 +#define R_SPARC_LM22 36 +#define R_SPARC_PC_HH22 37 +#define R_SPARC_PC_HM10 38 +#define R_SPARC_PC_LM22 39 +#define R_SPARC_WDISP16 40 +#define R_SPARC_WDISP19 41 +#define R_SPARC_GLOB_JMP 42 +#define R_SPARC_7 43 +#define R_SPARC_5 44 +#define R_SPARC_6 45 + +/* TLS relocations */ +#define R_SPARC_TLS_GD_HI22 56 +#define R_SPARC_TLS_GD_LO10 57 +#define R_SPARC_TLS_GD_ADD 58 +#define R_SPARC_TLS_GD_CALL 59 +#define R_SPARC_TLS_LDM_HI22 60 +#define R_SPARC_TLS_LDM_LO10 61 +#define R_SPARC_TLS_LDM_ADD 62 +#define R_SPARC_TLS_LDM_CALL 63 +#define R_SPARC_TLS_LDO_HIX22 64 +#define R_SPARC_TLS_LDO_LOX10 65 +#define R_SPARC_TLS_LDO_ADD 66 +#define R_SPARC_TLS_IE_HI22 67 +#define R_SPARC_TLS_IE_LO10 68 +#define R_SPARC_TLS_IE_LD 69 +#define R_SPARC_TLS_IE_LDX 70 +#define R_SPARC_TLS_IE_ADD 71 +#define R_SPARC_TLS_LE_HIX22 72 +#define R_SPARC_TLS_LE_LOX10 73 +#define R_SPARC_TLS_DTPMOD32 74 +#define R_SPARC_TLS_DTPMOD64 75 +#define R_SPARC_TLS_DTPOFF32 76 +#define R_SPARC_TLS_DTPOFF64 77 +#define R_SPARC_TLS_TPOFF32 78 +#define R_SPARC_TLS_TPOFF64 79 + +#define R_TYPE(name) __CONCAT(R_SPARC_,name) diff --git a/cpukit/score/cpu/sparc/include/rtems/asm.h b/cpukit/score/cpu/sparc/include/rtems/asm.h new file mode 100644 index 0000000000..a2b11f63fc --- /dev/null +++ b/cpukit/score/cpu/sparc/include/rtems/asm.h @@ -0,0 +1,120 @@ +/** + * @file + * + * @brief Address the Problems Caused by Incompatible Flavor of + * Assemblers and Toolsets + * + * This include file attempts to address the problems + * caused by incompatible flavors of assemblers and + * toolsets. It primarily addresses variations in the + * use of leading underscores on symbols and the requirement + * that register names be preceded by a %. + * + * NOTE: The spacing in the use of these macros + * is critical to them working as advertised. + */ + +/* + * COPYRIGHT: + * + * This file is based on similar code found in newlib available + * from ftp.cygnus.com. The file which was used had no copyright + * notice. This file is freely distributable as long as the source + * of the file is noted. + */ + +#ifndef _RTEMS_ASM_H +#define _RTEMS_ASM_H + +/* + * Indicate we are in an assembly file and get the basic CPU definitions. + */ + +#ifndef ASM +#define ASM +#endif + +#include +#include + +/* + * Recent versions of GNU cpp define variables which indicate the + * need for underscores and percents. If not using GNU cpp or + * the version does not support this, then you will obviously + * have to define these as appropriate. + */ + +/* XXX __USER_LABEL_PREFIX__ and __REGISTER_PREFIX__ do not work on gcc 2.7.0 */ +/* XXX The following ifdef magic fixes the problem but results in a warning */ +/* XXX when compiling assembly code. */ + +#ifndef __USER_LABEL_PREFIX__ +#define __USER_LABEL_PREFIX__ _ +#endif + +#ifndef __REGISTER_PREFIX__ +#define __REGISTER_PREFIX__ +#endif + +#include + +/* Use the right prefix for global labels. */ + +#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) + +/* Use the right prefix for registers. */ + +#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) + +/* + * define macros for all of the registers on this CPU + * + * EXAMPLE: #define d0 REG (d0) + */ + +/* + * Define macros to handle section beginning and ends. + */ + + +#define BEGIN_CODE_DCL .text +#define END_CODE_DCL +#define BEGIN_DATA_DCL .data +#define END_DATA_DCL +#define BEGIN_CODE .text +#define END_CODE +#define BEGIN_DATA +#define END_DATA +#define BEGIN_BSS +#define END_BSS +#define END + +/* + * Following must be tailor for a particular flavor of the C compiler. + * They may need to put underscores in front of the symbols. + */ + +#define PUBLIC(sym) .globl SYM (sym) +#define EXTERN(sym) .globl SYM (sym) + +/* + * Entry for traps which jump to a programmer-specified trap handler. + */ + +#define TRAP(_vector, _handler) \ + mov %psr, %l0 ; \ + sethi %hi(_handler), %l4 ; \ + jmp %l4+%lo(_handler); \ + mov _vector, %l3 + +/* + * Used for the reset trap to avoid a supervisor instruction + */ + +#define RTRAP(_vector, _handler) \ + mov %g0, %l0 ; \ + sethi %hi(_handler), %l4 ; \ + jmp %l4+%lo(_handler); \ + mov _vector, %l3 + +#endif diff --git a/cpukit/score/cpu/sparc/include/rtems/score/cpu.h b/cpukit/score/cpu/sparc/include/rtems/score/cpu.h new file mode 100644 index 0000000000..2b50592e08 --- /dev/null +++ b/cpukit/score/cpu/sparc/include/rtems/score/cpu.h @@ -0,0 +1,1202 @@ +/** + * @file + * + * @brief SPARC CPU Department Source + * + * This include file contains information pertaining to the port of + * the executive to the SPARC processor. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPU_H +#define _RTEMS_SCORE_CPU_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* conditional compilation parameters */ + +/* + * The SPARC ABI is a bit special with respect to the floating point context. + * The complete floating point context is volatile. Thus, from an ABI point + * of view nothing needs to be saved and restored during a context switch. + * Instead the floating point context must be saved and restored during + * interrupt processing. Historically, the deferred floating point switch was + * used for SPARC and the complete floating point context is saved and + * restored during a context switch to the new floating point unit owner. + * This is a bit dangerous since post-switch actions (e.g. signal handlers) + * and context switch extensions may silently corrupt the floating point + * context. + * + * The floating point unit is disabled for interrupt handlers. Thus, in case + * an interrupt handler uses the floating point unit then this will result in a + * trap (INTERNAL_ERROR_ILLEGAL_USE_OF_FLOATING_POINT_UNIT). + * + * In uniprocessor configurations, a lazy floating point context switch is + * used. In case an active floating point thread is interrupted (PSR[EF] == 1) + * and a thread dispatch is carried out, then this thread is registered as the + * floating point owner. When a floating point owner is present during a + * context switch, the floating point unit is disabled for the heir thread + * (PSR[EF] == 0). The floating point disabled trap checks that the use of the + * floating point unit is allowed and saves/restores the floating point context + * on demand. + * + * In SMP configurations, the deferred floating point switch is not supported + * in principle. So, use here a synchronous floating point switching. + * Synchronous means that the volatile floating point context is saved and + * restored around a thread dispatch issued during interrupt processing. Thus + * post-switch actions and context switch extensions may safely use the + * floating point unit. + */ +#if SPARC_HAS_FPU == 1 + #if defined(RTEMS_SMP) + #define SPARC_USE_SYNCHRONOUS_FP_SWITCH + #else + #define SPARC_USE_LAZY_FP_SWITCH + #endif +#endif + +/** + * Does the executive manage a dedicated interrupt stack in software? + * + * If TRUE, then a stack is allocated in _ISR_Handler_initialization. + * If FALSE, nothing is done. + * + * The SPARC does not have a dedicated HW interrupt stack and one has + * been implemented in SW. + */ +#define CPU_HAS_SOFTWARE_INTERRUPT_STACK TRUE + +/** + * Does the CPU follow the simple vectored interrupt model? + * + * - If TRUE, then RTEMS allocates the vector table it internally manages. + * - If FALSE, then the BSP is assumed to allocate and manage the vector + * table + * + * THe SPARC is a simple vectored architecture. Usually there is no + * PIC and the CPU directly vectors the interrupts. + */ +#define CPU_SIMPLE_VECTORED_INTERRUPTS TRUE + +/** + * Does this CPU have hardware support for a dedicated interrupt stack? + * + * - If TRUE, then it must be installed during initialization. + * - If FALSE, then no installation is performed. + * + * The SPARC does not have a dedicated HW interrupt stack. + */ +#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE + +/** + * Do we allocate a dedicated interrupt stack in the Interrupt Manager? + * + * - If TRUE, then the memory is allocated during initialization. + * - If FALSE, then the memory is allocated during initialization. + * + * The SPARC does not have hardware support for switching to a + * dedicated interrupt stack. The port includes support for doing this + * in software. + * + */ +#define CPU_ALLOCATE_INTERRUPT_STACK TRUE + +/** + * Does the RTEMS invoke the user's ISR with the vector number and + * a pointer to the saved interrupt frame (1) or just the vector + * number (0)? + * + * The SPARC port does not pass an Interrupt Stack Frame pointer to + * interrupt handlers. + */ +#define CPU_ISR_PASSES_FRAME_POINTER FALSE + +/** + * Does the CPU have hardware floating point? + * + * - If TRUE, then the FLOATING_POINT task attribute is supported. + * - If FALSE, then the FLOATING_POINT task attribute is ignored. + * + * This is set based upon the multilib settings. + */ +#if ( SPARC_HAS_FPU == 1 ) && !defined(SPARC_USE_SYNCHRONOUS_FP_SWITCH) + #define CPU_HARDWARE_FP TRUE +#else + #define CPU_HARDWARE_FP FALSE +#endif + +/** + * The SPARC GCC port does not have a software floating point library + * that requires RTEMS assistance. + */ +#define CPU_SOFTWARE_FP FALSE + +/** + * Are all tasks FLOATING_POINT tasks implicitly? + * + * - If TRUE, then the FLOATING_POINT task attribute is assumed. + * - If FALSE, then the FLOATING_POINT task attribute is followed. + * + * The SPARC GCC port does not implicitly use floating point registers. + */ +#define CPU_ALL_TASKS_ARE_FP FALSE + +/** + * Should the IDLE task have a floating point context? + * + * - If TRUE, then the IDLE task is created as a FLOATING_POINT task + * and it has a floating point context which is switched in and out. + * - If FALSE, then the IDLE task does not have a floating point context. + * + * The IDLE task does not have to be floating point on the SPARC. + */ +#define CPU_IDLE_TASK_IS_FP FALSE + +#define CPU_USE_DEFERRED_FP_SWITCH FALSE + +#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE + +/** + * Does this port provide a CPU dependent IDLE task implementation? + * + * - If TRUE, then the routine _CPU_Thread_Idle_body + * must be provided and is the default IDLE thread body instead of + * _CPU_Thread_Idle_body. + * + * - If FALSE, then use the generic IDLE thread body if the BSP does + * not provide one. + * + * The SPARC architecture does not have a low power or halt instruction. + * It is left to the BSP and/or CPU specific code to provide an IDLE + * thread body which is aware of low power modes. + */ +#define CPU_PROVIDES_IDLE_THREAD_BODY FALSE + +/** + * Does the stack grow up (toward higher addresses) or down + * (toward lower addresses)? + * + * - If TRUE, then the grows upward. + * - If FALSE, then the grows toward smaller addresses. + * + * The stack grows to lower addresses on the SPARC. + */ +#define CPU_STACK_GROWS_UP FALSE + +/* LEON3 systems may use a cache line size of 64 */ +#define CPU_CACHE_LINE_BYTES 64 + +#define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES ) + +/** + * The following defines the number of bits actually used in the + * interrupt field of the task mode. How those bits map to the + * CPU interrupt levels is defined by the routine _CPU_ISR_Set_level(). + * + * The SPARC has 16 interrupt levels in the PIL field of the PSR. + */ +#define CPU_MODES_INTERRUPT_MASK 0x0000000F + +#ifndef ASM +/** + * This structure represents the organization of the minimum stack frame + * for the SPARC. More framing information is required in certain situaions + * such as when there are a large number of out parameters or when the callee + * must save floating point registers. + */ +typedef struct { + /** This is the offset of the l0 register. */ + uint32_t l0; + /** This is the offset of the l1 register. */ + uint32_t l1; + /** This is the offset of the l2 register. */ + uint32_t l2; + /** This is the offset of the l3 register. */ + uint32_t l3; + /** This is the offset of the l4 register. */ + uint32_t l4; + /** This is the offset of the l5 register. */ + uint32_t l5; + /** This is the offset of the l6 register. */ + uint32_t l6; + /** This is the offset of the l7 register. */ + uint32_t l7; + /** This is the offset of the l0 register. */ + uint32_t i0; + /** This is the offset of the i1 register. */ + uint32_t i1; + /** This is the offset of the i2 register. */ + uint32_t i2; + /** This is the offset of the i3 register. */ + uint32_t i3; + /** This is the offset of the i4 register. */ + uint32_t i4; + /** This is the offset of the i5 register. */ + uint32_t i5; + /** This is the offset of the i6 register. */ + uint32_t i6_fp; + /** This is the offset of the i7 register. */ + uint32_t i7; + /** This is the offset of the register used to return structures. */ + void *structure_return_address; + + /* + * The following are for the callee to save the register arguments in + * should this be necessary. + */ + /** This is the offset of the register for saved argument 0. */ + uint32_t saved_arg0; + /** This is the offset of the register for saved argument 1. */ + uint32_t saved_arg1; + /** This is the offset of the register for saved argument 2. */ + uint32_t saved_arg2; + /** This is the offset of the register for saved argument 3. */ + uint32_t saved_arg3; + /** This is the offset of the register for saved argument 4. */ + uint32_t saved_arg4; + /** This is the offset of the register for saved argument 5. */ + uint32_t saved_arg5; + /** This field pads the structure so ldd and std instructions can be used. */ + uint32_t pad0; +} SPARC_Minimum_stack_frame; + +#endif /* ASM */ + +/** This macro defines an offset into the stack frame for use in assembly. */ +#define CPU_STACK_FRAME_L0_OFFSET 0x00 +/** This macro defines an offset into the stack frame for use in assembly. */ +#define CPU_STACK_FRAME_L1_OFFSET 0x04 +/** This macro defines an offset into the stack frame for use in assembly. */ +#define CPU_STACK_FRAME_L2_OFFSET 0x08 +/** This macro defines an offset into the stack frame for use in assembly. */ +#define CPU_STACK_FRAME_L3_OFFSET 0x0c +/** This macro defines an offset into the stack frame for use in assembly. */ +#define CPU_STACK_FRAME_L4_OFFSET 0x10 +/** This macro defines an offset into the stack frame for use in assembly. */ +#define CPU_STACK_FRAME_L5_OFFSET 0x14 +/** This macro defines an offset into the stack frame for use in assembly. */ +#define CPU_STACK_FRAME_L6_OFFSET 0x18 +/** This macro defines an offset into the stack frame for use in assembly. */ +#define CPU_STACK_FRAME_L7_OFFSET 0x1c +/** This macro defines an offset into the stack frame for use in assembly. */ +#define CPU_STACK_FRAME_I0_OFFSET 0x20 +/** This macro defines an offset into the stack frame for use in assembly. */ +#define CPU_STACK_FRAME_I1_OFFSET 0x24 +/** This macro defines an offset into the stack frame for use in assembly. */ +#define CPU_STACK_FRAME_I2_OFFSET 0x28 +/** This macro defines an offset into the stack frame for use in assembly. */ +#define CPU_STACK_FRAME_I3_OFFSET 0x2c +/** This macro defines an offset into the stack frame for use in assembly. */ +#define CPU_STACK_FRAME_I4_OFFSET 0x30 +/** This macro defines an offset into the stack frame for use in assembly. */ +#define CPU_STACK_FRAME_I5_OFFSET 0x34 +/** This macro defines an offset into the stack frame for use in assembly. */ +#define CPU_STACK_FRAME_I6_FP_OFFSET 0x38 +/** This macro defines an offset into the stack frame for use in assembly. */ +#define CPU_STACK_FRAME_I7_OFFSET 0x3c +/** This macro defines an offset into the stack frame for use in assembly. */ +#define CPU_STRUCTURE_RETURN_ADDRESS_OFFSET 0x40 +/** This macro defines an offset into the stack frame for use in assembly. */ +#define CPU_STACK_FRAME_SAVED_ARG0_OFFSET 0x44 +/** This macro defines an offset into the stack frame for use in assembly. */ +#define CPU_STACK_FRAME_SAVED_ARG1_OFFSET 0x48 +/** This macro defines an offset into the stack frame for use in assembly. */ +#define CPU_STACK_FRAME_SAVED_ARG2_OFFSET 0x4c +/** This macro defines an offset into the stack frame for use in assembly. */ +#define CPU_STACK_FRAME_SAVED_ARG3_OFFSET 0x50 +/** This macro defines an offset into the stack frame for use in assembly. */ +#define CPU_STACK_FRAME_SAVED_ARG4_OFFSET 0x54 +/** This macro defines an offset into the stack frame for use in assembly. */ +#define CPU_STACK_FRAME_SAVED_ARG5_OFFSET 0x58 +/** This macro defines an offset into the stack frame for use in assembly. */ +#define CPU_STACK_FRAME_PAD0_OFFSET 0x5c + +#define CPU_MAXIMUM_PROCESSORS 32 + +/** + * @defgroup Contexts SPARC Context Structures + * + * @ingroup Score + * + * Generally there are 2 types of context to save. + * + Interrupt registers to save + * + Task level registers to save + * + * This means we have the following 3 context items: + * + task level context stuff:: Context_Control + * + floating point task stuff:: Context_Control_fp + * + special interrupt level context :: Context_Control_interrupt + * + * On the SPARC, we are relatively conservative in that we save most + * of the CPU state in the context area. The ET (enable trap) bit and + * the CWP (current window pointer) fields of the PSR are considered + * system wide resources and are not maintained on a per-thread basis. + */ +/**@{**/ + +#ifndef ASM +typedef struct Context_Control_fp Context_Control_fp; + +/** + * @brief SPARC basic context. + * + * This structure defines the non-volatile integer and processor state context + * for the SPARC architecture according to "SYSTEM V APPLICATION BINARY + * INTERFACE - SPARC Processor Supplement", Third Edition. + * + * The registers g2 through g4 are reserved for applications. GCC uses them as + * volatile registers by default. So they are treated like volatile registers + * in RTEMS as well. + * + * The register g6 contains the per-CPU control of the current processor. It + * is an invariant of the processor context. This register must not be saved + * and restored during context switches or interrupt services. + */ +typedef struct { + /** This will contain the contents of the g5 register. */ + uint32_t g5; + /** This will contain the contents of the g7 register. */ + uint32_t g7; + + /** + * This will contain the contents of the l0 and l1 registers. + * + * Using a double l0_and_l1 will put everything in this structure on a double + * word boundary which allows us to use double word loads and stores safely + * in the context switch. + */ + double l0_and_l1; + /** This will contain the contents of the l2 register. */ + uint32_t l2; + /** This will contain the contents of the l3 register. */ + uint32_t l3; + /** This will contain the contents of the l4 register. */ + uint32_t l4; + /** This will contain the contents of the l5 registeer.*/ + uint32_t l5; + /** This will contain the contents of the l6 register. */ + uint32_t l6; + /** This will contain the contents of the l7 register. */ + uint32_t l7; + + /** This will contain the contents of the i0 register. */ + uint32_t i0; + /** This will contain the contents of the i1 register. */ + uint32_t i1; + /** This will contain the contents of the i2 register. */ + uint32_t i2; + /** This will contain the contents of the i3 register. */ + uint32_t i3; + /** This will contain the contents of the i4 register. */ + uint32_t i4; + /** This will contain the contents of the i5 register. */ + uint32_t i5; + /** This will contain the contents of the i6 (e.g. frame pointer) register. */ + uint32_t i6_fp; + /** This will contain the contents of the i7 register. */ + uint32_t i7; + + /** This will contain the contents of the o6 (e.g. frame pointer) register. */ + uint32_t o6_sp; + /** + * This will contain the contents of the o7 (e.g. address of CALL + * instruction) register. + */ + uint32_t o7; + + /** This will contain the contents of the processor status register. */ + uint32_t psr; + /** + * This field is used to prevent heavy nesting of calls to _Thread_Dispatch + * on an interrupted task's stack. This is problematic on the slower + * SPARC CPU models at high interrupt rates. + */ + uint32_t isr_dispatch_disable; + +#if defined(SPARC_USE_LAZY_FP_SWITCH) + Context_Control_fp *fp_context; +#endif + +#if defined(RTEMS_SMP) + volatile uint32_t is_executing; +#endif +} Context_Control; + +/** + * This macro provides a CPU independent way for RTEMS to access the + * stack pointer in a context structure. The actual name and offset is + * CPU architecture dependent. + */ +#define _CPU_Context_Get_SP( _context ) \ + (_context)->o6_sp + +#ifdef RTEMS_SMP + static inline bool _CPU_Context_Get_is_executing( + const Context_Control *context + ) + { + return context->is_executing; + } + + static inline void _CPU_Context_Set_is_executing( + Context_Control *context, + bool is_executing + ) + { + context->is_executing = is_executing; + } +#endif + +#endif /* ASM */ + +/* + * Offsets of fields with Context_Control for assembly routines. + */ + +/** This macro defines an offset into the context for use in assembly. */ +#define G5_OFFSET 0x00 +/** This macro defines an offset into the context for use in assembly. */ +#define G7_OFFSET 0x04 + +/** This macro defines an offset into the context for use in assembly. */ +#define L0_OFFSET 0x08 +/** This macro defines an offset into the context for use in assembly. */ +#define L1_OFFSET 0x0C +/** This macro defines an offset into the context for use in assembly. */ +#define L2_OFFSET 0x10 +/** This macro defines an offset into the context for use in assembly. */ +#define L3_OFFSET 0x14 +/** This macro defines an offset into the context for use in assembly. */ +#define L4_OFFSET 0x18 +/** This macro defines an offset into the context for use in assembly. */ +#define L5_OFFSET 0x1C +/** This macro defines an offset into the context for use in assembly. */ +#define L6_OFFSET 0x20 +/** This macro defines an offset into the context for use in assembly. */ +#define L7_OFFSET 0x24 + +/** This macro defines an offset into the context for use in assembly. */ +#define I0_OFFSET 0x28 +/** This macro defines an offset into the context for use in assembly. */ +#define I1_OFFSET 0x2C +/** This macro defines an offset into the context for use in assembly. */ +#define I2_OFFSET 0x30 +/** This macro defines an offset into the context for use in assembly. */ +#define I3_OFFSET 0x34 +/** This macro defines an offset into the context for use in assembly. */ +#define I4_OFFSET 0x38 +/** This macro defines an offset into the context for use in assembly. */ +#define I5_OFFSET 0x3C +/** This macro defines an offset into the context for use in assembly. */ +#define I6_FP_OFFSET 0x40 +/** This macro defines an offset into the context for use in assembly. */ +#define I7_OFFSET 0x44 + +/** This macro defines an offset into the context for use in assembly. */ +#define O6_SP_OFFSET 0x48 +/** This macro defines an offset into the context for use in assembly. */ +#define O7_OFFSET 0x4C + +/** This macro defines an offset into the context for use in assembly. */ +#define PSR_OFFSET 0x50 +/** This macro defines an offset into the context for use in assembly. */ +#define ISR_DISPATCH_DISABLE_STACK_OFFSET 0x54 + +#if defined(RTEMS_SMP) + #define SPARC_CONTEXT_CONTROL_IS_EXECUTING_OFFSET 0x58 +#endif + +#ifndef ASM +/** + * @brief SPARC basic context. + * + * This structure defines floating point context area. + */ +struct Context_Control_fp { + /** This will contain the contents of the f0 and f1 register. */ + double f0_f1; + /** This will contain the contents of the f2 and f3 register. */ + double f2_f3; + /** This will contain the contents of the f4 and f5 register. */ + double f4_f5; + /** This will contain the contents of the f6 and f7 register. */ + double f6_f7; + /** This will contain the contents of the f8 and f9 register. */ + double f8_f9; + /** This will contain the contents of the f10 and f11 register. */ + double f10_f11; + /** This will contain the contents of the f12 and f13 register. */ + double f12_f13; + /** This will contain the contents of the f14 and f15 register. */ + double f14_f15; + /** This will contain the contents of the f16 and f17 register. */ + double f16_f17; + /** This will contain the contents of the f18 and f19 register. */ + double f18_f19; + /** This will contain the contents of the f20 and f21 register. */ + double f20_f21; + /** This will contain the contents of the f22 and f23 register. */ + double f22_f23; + /** This will contain the contents of the f24 and f25 register. */ + double f24_f25; + /** This will contain the contents of the f26 and f27 register. */ + double f26_f27; + /** This will contain the contents of the f28 and f29 register. */ + double f28_f29; + /** This will contain the contents of the f30 and f31 register. */ + double f30_f31; + /** This will contain the contents of the floating point status register. */ + uint32_t fsr; +}; + +#endif /* ASM */ + +/* + * Offsets of fields with Context_Control_fp for assembly routines. + */ + +/** This macro defines an offset into the FPU context for use in assembly. */ +#define FO_F1_OFFSET 0x00 +/** This macro defines an offset into the FPU context for use in assembly. */ +#define F2_F3_OFFSET 0x08 +/** This macro defines an offset into the FPU context for use in assembly. */ +#define F4_F5_OFFSET 0x10 +/** This macro defines an offset into the FPU context for use in assembly. */ +#define F6_F7_OFFSET 0x18 +/** This macro defines an offset into the FPU context for use in assembly. */ +#define F8_F9_OFFSET 0x20 +/** This macro defines an offset into the FPU context for use in assembly. */ +#define F1O_F11_OFFSET 0x28 +/** This macro defines an offset into the FPU context for use in assembly. */ +#define F12_F13_OFFSET 0x30 +/** This macro defines an offset into the FPU context for use in assembly. */ +#define F14_F15_OFFSET 0x38 +/** This macro defines an offset into the FPU context for use in assembly. */ +#define F16_F17_OFFSET 0x40 +/** This macro defines an offset into the FPU context for use in assembly. */ +#define F18_F19_OFFSET 0x48 +/** This macro defines an offset into the FPU context for use in assembly. */ +#define F2O_F21_OFFSET 0x50 +/** This macro defines an offset into the FPU context for use in assembly. */ +#define F22_F23_OFFSET 0x58 +/** This macro defines an offset into the FPU context for use in assembly. */ +#define F24_F25_OFFSET 0x60 +/** This macro defines an offset into the FPU context for use in assembly. */ +#define F26_F27_OFFSET 0x68 +/** This macro defines an offset into the FPU context for use in assembly. */ +#define F28_F29_OFFSET 0x70 +/** This macro defines an offset into the FPU context for use in assembly. */ +#define F3O_F31_OFFSET 0x78 +/** This macro defines an offset into the FPU context for use in assembly. */ +#define FSR_OFFSET 0x80 + +/** This defines the size of the FPU context area for use in assembly. */ +#define CONTEXT_CONTROL_FP_SIZE 0x84 + +#ifndef ASM + +/** @} */ + +/** + * @brief Interrupt stack frame (ISF). + * + * Context saved on stack for an interrupt. + * + * NOTE: The PSR, PC, and NPC are only saved in this structure for the + * benefit of the user's handler. + */ +typedef struct { + /** On an interrupt, we must save the minimum stack frame. */ + SPARC_Minimum_stack_frame Stack_frame; + /** This is the offset of the PSR on an ISF. */ + uint32_t psr; + /** This is the offset of the XXX on an ISF. */ + uint32_t pc; + /** This is the offset of the XXX on an ISF. */ + uint32_t npc; + /** This is the offset of the g1 register on an ISF. */ + uint32_t g1; + /** This is the offset of the g2 register on an ISF. */ + uint32_t g2; + /** This is the offset of the g3 register on an ISF. */ + uint32_t g3; + /** This is the offset of the g4 register on an ISF. */ + uint32_t g4; + /** This is the offset of the g5 register on an ISF. */ + uint32_t g5; + /** This is the offset is reserved for alignment on an ISF. */ + uint32_t reserved_for_alignment; + /** This is the offset of the g7 register on an ISF. */ + uint32_t g7; + /** This is the offset of the i0 register on an ISF. */ + uint32_t i0; + /** This is the offset of the i1 register on an ISF. */ + uint32_t i1; + /** This is the offset of the i2 register on an ISF. */ + uint32_t i2; + /** This is the offset of the i3 register on an ISF. */ + uint32_t i3; + /** This is the offset of the i4 register on an ISF. */ + uint32_t i4; + /** This is the offset of the i5 register on an ISF. */ + uint32_t i5; + /** This is the offset of the i6 register on an ISF. */ + uint32_t i6_fp; + /** This is the offset of the i7 register on an ISF. */ + uint32_t i7; + /** This is the offset of the y register on an ISF. */ + uint32_t y; + /** This is the offset of the tpc register on an ISF. */ + uint32_t tpc; +} CPU_Interrupt_frame; + +#endif /* ASM */ + +#ifndef ASM +/** + * The following type defines an entry in the SPARC's trap table. + * + * NOTE: The instructions chosen are RTEMS dependent although one is + * obligated to use two of the four instructions to perform a + * long jump. The other instructions load one register with the + * trap type (a.k.a. vector) and another with the psr. + */ +typedef struct { + /** This will contain a "mov %psr, %l0" instruction. */ + uint32_t mov_psr_l0; + /** This will contain a "sethi %hi(_handler), %l4" instruction. */ + uint32_t sethi_of_handler_to_l4; + /** This will contain a "jmp %l4 + %lo(_handler)" instruction. */ + uint32_t jmp_to_low_of_handler_plus_l4; + /** This will contain a " mov _vector, %l3" instruction. */ + uint32_t mov_vector_l3; +} CPU_Trap_table_entry; + +/** + * This is the set of opcodes for the instructions loaded into a trap + * table entry. The routine which installs a handler is responsible + * for filling in the fields for the _handler address and the _vector + * trap type. + * + * The constants following this structure are masks for the fields which + * must be filled in when the handler is installed. + */ +extern const CPU_Trap_table_entry _CPU_Trap_slot_template; + +/** + * The size of the floating point context area. + */ +#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp ) + +#endif + +/** + * Amount of extra stack (above minimum stack size) required by + * MPCI receive server thread. Remember that in a multiprocessor + * system this thread must exist and be able to process all directives. + */ +#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 1024 + +/** + * This defines the number of entries in the ISR_Vector_table managed + * by the executive. + * + * On the SPARC, there are really only 256 vectors. However, the executive + * has no easy, fast, reliable way to determine which traps are synchronous + * and which are asynchronous. By default, synchronous traps return to the + * instruction which caused the interrupt. So if you install a software + * trap handler as an executive interrupt handler (which is desirable since + * RTEMS takes care of window and register issues), then the executive needs + * to know that the return address is to the trap rather than the instruction + * following the trap. + * + * So vectors 0 through 255 are treated as regular asynchronous traps which + * provide the "correct" return address. Vectors 256 through 512 are assumed + * by the executive to be synchronous and to require that the return address + * be fudged. + * + * If you use this mechanism to install a trap handler which must reexecute + * the instruction which caused the trap, then it should be installed as + * an asynchronous trap. This will avoid the executive changing the return + * address. + */ +#define CPU_INTERRUPT_NUMBER_OF_VECTORS 256 + +/** + * The SPARC has 256 vectors but the port treats 256-512 as synchronous + * traps. + */ +#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER 511 + +/** + * This is the bit step in a vector number to indicate it is being installed + * as a synchronous trap. + */ +#define SPARC_SYNCHRONOUS_TRAP_BIT_MASK 0x100 + +/** + * This macro indicates that @a _trap as an asynchronous trap. + */ +#define SPARC_ASYNCHRONOUS_TRAP( _trap ) (_trap) + +/** + * This macro indicates that @a _trap as a synchronous trap. + */ +#define SPARC_SYNCHRONOUS_TRAP( _trap ) ((_trap) + 256 ) + +/** + * This macro returns the real hardware vector number associated with @a _trap. + */ +#define SPARC_REAL_TRAP_NUMBER( _trap ) ((_trap) % 256) + +/** + * This is defined if the port has a special way to report the ISR nesting + * level. Most ports maintain the variable _ISR_Nest_level. + */ +#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE + +/** + * Should be large enough to run all tests. This ensures + * that a "reasonable" small application should not have any problems. + * + * This appears to be a fairly generous number for the SPARC since + * represents a call depth of about 20 routines based on the minimum + * stack frame. + */ +#define CPU_STACK_MINIMUM_SIZE (1024*4) + +/** + * What is the size of a pointer on this architecture? + */ +#define CPU_SIZEOF_POINTER 4 + +/** + * CPU's worst alignment requirement for data types on a byte boundary. This + * alignment does not take into account the requirements for the stack. + * + * On the SPARC, this is required for double word loads and stores. + */ +#define CPU_ALIGNMENT 8 + +/** + * This number corresponds to the byte alignment requirement for the + * heap handler. This alignment requirement may be stricter than that + * for the data types alignment specified by CPU_ALIGNMENT. It is + * common for the heap to follow the same alignment requirement as + * CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict enough for the heap, + * then this should be set to CPU_ALIGNMENT. + * + * NOTE: This does not have to be a power of 2. It does have to + * be greater or equal to than CPU_ALIGNMENT. + */ +#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT + +/** + * This number corresponds to the byte alignment requirement for memory + * buffers allocated by the partition manager. This alignment requirement + * may be stricter than that for the data types alignment specified by + * CPU_ALIGNMENT. It is common for the partition to follow the same + * alignment requirement as CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict + * enough for the partition, then this should be set to CPU_ALIGNMENT. + * + * NOTE: This does not have to be a power of 2. It does have to + * be greater or equal to than CPU_ALIGNMENT. + */ +#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT + +/** + * Stack frames must be doubleword aligned according to the System V ABI for + * SPARC. + */ +#define CPU_STACK_ALIGNMENT CPU_ALIGNMENT + +#ifndef ASM + +/* + * ISR handler macros + */ + +/** + * Support routine to initialize the RTEMS vector table after it is allocated. + */ +#define _CPU_Initialize_vectors() + +/** + * Disable all interrupts for a critical section. The previous + * level is returned in _level. + */ +#define _CPU_ISR_Disable( _level ) \ + (_level) = sparc_disable_interrupts() + +/** + * Enable interrupts to the previous level (returned by _CPU_ISR_Disable). + * This indicates the end of a critical section. The parameter + * _level is not modified. + */ +#define _CPU_ISR_Enable( _level ) \ + sparc_enable_interrupts( _level ) + +/** + * This temporarily restores the interrupt to _level before immediately + * disabling them again. This is used to divide long critical + * sections into two or more parts. The parameter _level is not + * modified. + */ +#define _CPU_ISR_Flash( _level ) \ + sparc_flash_interrupts( _level ) + +#define _CPU_ISR_Is_enabled( _isr_cookie ) \ + sparc_interrupt_is_enabled( _isr_cookie ) + +RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) +{ + return ( level & SPARC_PSR_PIL_MASK ) == 0; +} + +/** + * Map interrupt level in task mode onto the hardware that the CPU + * actually provides. Currently, interrupt levels which do not + * map onto the CPU in a straight fashion are undefined. + */ +#define _CPU_ISR_Set_level( _newlevel ) \ + sparc_enable_interrupts( _newlevel << 8) + +/** + * @brief Obtain the current interrupt disable level. + * + * This method is invoked to return the current interrupt disable level. + * + * @return This method returns the current interrupt disable level. + */ +uint32_t _CPU_ISR_Get_level( void ); + +/* end of ISR handler macros */ + +/* Context handler macros */ + +/** + * Initialize the context to a state suitable for starting a + * task after a context restore operation. Generally, this + * involves: + * + * - setting a starting address + * - preparing the stack + * - preparing the stack and frame pointers + * - setting the proper interrupt level in the context + * - initializing the floating point context + * + * @param[in] the_context points to the context area + * @param[in] stack_base is the low address of the allocated stack area + * @param[in] size is the size of the stack area in bytes + * @param[in] new_level is the interrupt level for the task + * @param[in] entry_point is the task's entry point + * @param[in] is_fp is set to TRUE if the task is a floating point task + * @param[in] tls_area is the thread-local storage (TLS) area + * + * NOTE: Implemented as a subroutine for the SPARC port. + */ +void _CPU_Context_Initialize( + Context_Control *the_context, + uint32_t *stack_base, + uint32_t size, + uint32_t new_level, + void *entry_point, + bool is_fp, + void *tls_area +); + +/** + * This macro is invoked from _Thread_Handler to do whatever CPU + * specific magic is required that must be done in the context of + * the thread when it starts. + * + * On the SPARC, this is setting the frame pointer so GDB is happy. + * Make GDB stop unwinding at _Thread_Handler, previous register window + * Frame pointer is 0 and calling address must be a function with starting + * with a SAVE instruction. If return address is leaf-function (no SAVE) + * GDB will not look at prev reg window fp. + * + * _Thread_Handler is known to start with SAVE. + */ +#define _CPU_Context_Initialization_at_thread_begin() \ + do { \ + __asm__ volatile ("set _Thread_Handler,%%i7\n"::); \ + } while (0) + +/** + * This routine is responsible for somehow restarting the currently + * executing task. + * + * On the SPARC, this is is relatively painless but requires a small + * amount of wrapper code before using the regular restore code in + * of the context switch. + */ +#define _CPU_Context_Restart_self( _the_context ) \ + _CPU_Context_restore( (_the_context) ); + +/** + * @brief Nothing to do due to the synchronous or lazy floating point switch. + */ +#define _CPU_Context_Initialize_fp( _destination ) \ + do { } while ( 0 ) + +/** + * @brief Nothing to do due to the synchronous or lazy floating point switch. + */ +#define _CPU_Context_save_fp( _fp_context_ptr ) \ + do { } while ( 0 ) + +/** + * @brief Nothing to do due to the synchronous or lazy floating point switch. + */ +#define _CPU_Context_restore_fp( _fp_context_ptr ) \ + do { } while ( 0 ) +/* end of Context handler macros */ + +/* Fatal Error manager macros */ + +/** + * This routine copies _error into a known place -- typically a stack + * location or a register, optionally disables interrupts, and + * halts/stops the CPU. + */ +extern void _CPU_Fatal_halt(uint32_t source, uint32_t error) + RTEMS_NO_RETURN; + +/* end of Fatal Error manager macros */ + +/* Bitfield handler macros */ + +#if ( SPARC_HAS_BITSCAN == 0 ) + /** + * The SPARC port uses the generic C algorithm for bitfield scan if the + * CPU model does not have a scan instruction. + */ + #define CPU_USE_GENERIC_BITFIELD_CODE TRUE +#else + #error "scan instruction not currently supported by RTEMS!!" +#endif + +/* end of Bitfield handler macros */ + +/* functions */ + +/** + * @brief SPARC specific initialization. + * + * This routine performs CPU dependent initialization. + */ +void _CPU_Initialize(void); + +/** + * @brief SPARC specific raw ISR installer. + * + * This routine installs @a new_handler to be directly called from the trap + * table. + * + * @param[in] vector is the vector number + * @param[in] new_handler is the new ISR handler + * @param[in] old_handler will contain the old ISR handler + */ +void _CPU_ISR_install_raw_handler( + uint32_t vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +/** + * @brief SPARC specific RTEMS ISR installer. + * + * This routine installs an interrupt vector. + * + * @param[in] vector is the vector number + * @param[in] new_handler is the new ISR handler + * @param[in] old_handler will contain the old ISR handler + */ + +void _CPU_ISR_install_vector( + uint32_t vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +/** + * @brief SPARC specific context switch. + * + * This routine switches from the run context to the heir context. + * + * @param[in] run is the currently executing thread + * @param[in] heir will become the currently executing thread + */ +void _CPU_Context_switch( + Context_Control *run, + Context_Control *heir +); + +/** + * @brief SPARC specific context restore. + * + * This routine is generally used only to restart self in an + * efficient manner. + * + * @param[in] new_context is the context to restore + */ +void _CPU_Context_restore( + Context_Control *new_context +) RTEMS_NO_RETURN; + +#if defined(RTEMS_SMP) + uint32_t _CPU_SMP_Initialize( void ); + + bool _CPU_SMP_Start_processor( uint32_t cpu_index ); + + void _CPU_SMP_Finalize_initialization( uint32_t cpu_count ); + + void _CPU_SMP_Prepare_start_multitasking( void ); + + #if defined(__leon__) && !defined(RTEMS_PARAVIRT) + static inline uint32_t _CPU_SMP_Get_current_processor( void ) + { + return _LEON3_Get_current_processor(); + } + #else + uint32_t _CPU_SMP_Get_current_processor( void ); + #endif + + void _CPU_SMP_Send_interrupt( uint32_t target_processor_index ); + + static inline void _CPU_SMP_Processor_event_broadcast( void ) + { + __asm__ volatile ( "" : : : "memory" ); + } + + static inline void _CPU_SMP_Processor_event_receive( void ) + { + __asm__ volatile ( "" : : : "memory" ); + } +#endif + +#if defined(SPARC_USE_LAZY_FP_SWITCH) +#define _CPU_Context_Destroy( _the_thread, _the_context ) \ + do { \ + Per_CPU_Control *cpu_self = _Per_CPU_Get(); \ + Thread_Control *_fp_owner = cpu_self->cpu_per_cpu.fp_owner; \ + if ( _fp_owner == _the_thread ) { \ + cpu_self->cpu_per_cpu.fp_owner = NULL; \ + } \ + } while ( 0 ) +#endif + +void _CPU_Context_volatile_clobber( uintptr_t pattern ); + +void _CPU_Context_validate( uintptr_t pattern ); + +typedef struct { + uint32_t trap; + CPU_Interrupt_frame *isf; +} CPU_Exception_frame; + +void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); + +/** + * @brief SPARC specific method to endian swap an uint32_t. + * + * The following routine swaps the endian format of an unsigned int. + * It must be static because it is referenced indirectly. + * + * @param[in] value is the value to endian swap + * + * This version will work on any processor, but if you come across a better + * way for the SPARC PLEASE use it. The most common way to swap a 32-bit + * entity as shown below is not any more efficient on the SPARC. + * + * - swap least significant two bytes with 16-bit rotate + * - swap upper and lower 16-bits + * - swap most significant two bytes with 16-bit rotate + * + * It is not obvious how the SPARC can do significantly better than the + * generic code. gcc 2.7.0 only generates about 12 instructions for the + * following code at optimization level four (i.e. -O4). + */ +static inline uint32_t CPU_swap_u32( + uint32_t value +) +{ + uint32_t byte1, byte2, byte3, byte4, swapped; + + byte4 = (value >> 24) & 0xff; + byte3 = (value >> 16) & 0xff; + byte2 = (value >> 8) & 0xff; + byte1 = value & 0xff; + + swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4; + return( swapped ); +} + +/** + * @brief SPARC specific method to endian swap an uint16_t. + * + * The following routine swaps the endian format of a uint16_t. + * + * @param[in] value is the value to endian swap + */ +#define CPU_swap_u16( value ) \ + (((value&0xff) << 8) | ((value >> 8)&0xff)) + +typedef uint32_t CPU_Counter_ticks; + +typedef CPU_Counter_ticks ( *SPARC_Counter_read )( void ); + +typedef CPU_Counter_ticks ( *SPARC_Counter_difference )( + CPU_Counter_ticks second, + CPU_Counter_ticks first +); + +/* + * The SPARC processors supported by RTEMS have no built-in CPU counter + * support. We have to use some hardware counter module for this purpose, for + * example the GPTIMER instance used by the clock driver. The BSP must provide + * an implementation of the CPU counter read and difference functions. This + * allows the use of dynamic hardware enumeration. + */ +typedef struct { + SPARC_Counter_read counter_read; + SPARC_Counter_difference counter_difference; + volatile const CPU_Counter_ticks *counter_address; +} SPARC_Counter; + +extern const SPARC_Counter _SPARC_Counter; + +static inline CPU_Counter_ticks _CPU_Counter_read( void ) +{ + return ( *_SPARC_Counter.counter_read )(); +} + +static inline CPU_Counter_ticks _CPU_Counter_difference( + CPU_Counter_ticks second, + CPU_Counter_ticks first +) +{ + return ( *_SPARC_Counter.counter_difference )( second, first ); +} + +#endif /* ASM */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/score/cpu/sparc/include/rtems/score/cpuatomic.h b/cpukit/score/cpu/sparc/include/rtems/score/cpuatomic.h new file mode 100644 index 0000000000..598ee76b20 --- /dev/null +++ b/cpukit/score/cpu/sparc/include/rtems/score/cpuatomic.h @@ -0,0 +1,14 @@ +/* + * COPYRIGHT (c) 2012-2013 Deng Hengyi. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_ATOMIC_CPU_H +#define _RTEMS_SCORE_ATOMIC_CPU_H + +#include + +#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/sparc/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/sparc/include/rtems/score/cpuimpl.h new file mode 100644 index 0000000000..4f2311e755 --- /dev/null +++ b/cpukit/score/cpu/sparc/include/rtems/score/cpuimpl.h @@ -0,0 +1,155 @@ +/** + * @file + * + * @brief CPU Port Implementation API + */ + +/* + * Copyright (c) 1989, 2007 On-Line Applications Research Corporation (OAR) + * Copyright (c) 2013, 2016 embedded brains GmbH + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPUIMPL_H +#define _RTEMS_SCORE_CPUIMPL_H + +#include + +/** This defines the size of the minimum stack frame. */ +#define SPARC_MINIMUM_STACK_FRAME_SIZE 0x60 + +/* + * Offsets of fields with CPU_Interrupt_frame for assembly routines. + */ + +/** This macro defines an offset into the ISF for use in assembly. */ +#define ISF_PSR_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x00 +/** This macro defines an offset into the ISF for use in assembly. */ +#define ISF_PC_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x04 +/** This macro defines an offset into the ISF for use in assembly. */ +#define ISF_NPC_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x08 +/** This macro defines an offset into the ISF for use in assembly. */ +#define ISF_G1_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x0c +/** This macro defines an offset into the ISF for use in assembly. */ +#define ISF_G2_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x10 +/** This macro defines an offset into the ISF for use in assembly. */ +#define ISF_G3_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x14 +/** This macro defines an offset into the ISF for use in assembly. */ +#define ISF_G4_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x18 +/** This macro defines an offset into the ISF for use in assembly. */ +#define ISF_G5_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x1c +/** This macro defines an offset into the ISF for use in assembly. */ +#define ISF_G7_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x24 +/** This macro defines an offset into the ISF for use in assembly. */ +#define ISF_I0_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x28 +/** This macro defines an offset into the ISF for use in assembly. */ +#define ISF_I1_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x2c +/** This macro defines an offset into the ISF for use in assembly. */ +#define ISF_I2_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x30 +/** This macro defines an offset into the ISF for use in assembly. */ +#define ISF_I3_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x34 +/** This macro defines an offset into the ISF for use in assembly. */ +#define ISF_I4_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x38 +/** This macro defines an offset into the ISF for use in assembly. */ +#define ISF_I5_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x3c +/** This macro defines an offset into the ISF for use in assembly. */ +#define ISF_I6_FP_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x40 +/** This macro defines an offset into the ISF for use in assembly. */ +#define ISF_I7_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x44 +/** This macro defines an offset into the ISF for use in assembly. */ +#define ISF_Y_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x48 +/** This macro defines an offset into the ISF for use in assembly. */ +#define ISF_TPC_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x4c + +/** This defines the size of the ISF area for use in assembly. */ +#define CPU_INTERRUPT_FRAME_SIZE SPARC_MINIMUM_STACK_FRAME_SIZE + 0x50 + +#define SPARC_FP_CONTEXT_OFFSET_F0_F1 0 +#define SPARC_FP_CONTEXT_OFFSET_F2_F3 8 +#define SPARC_FP_CONTEXT_OFFSET_F4_F5 16 +#define SPARC_FP_CONTEXT_OFFSET_F6_F7 24 +#define SPARC_FP_CONTEXT_OFFSET_F8_F9 32 +#define SPARC_FP_CONTEXT_OFFSET_F10_F11 40 +#define SPARC_FP_CONTEXT_OFFSET_F12_F13 48 +#define SPARC_FP_CONTEXT_OFFSET_F14_F15 56 +#define SPARC_FP_CONTEXT_OFFSET_F16_F17 64 +#define SPARC_FP_CONTEXT_OFFSET_F18_F19 72 +#define SPARC_FP_CONTEXT_OFFSET_F20_F21 80 +#define SPARC_FP_CONTEXT_OFFSET_F22_F23 88 +#define SPARC_FP_CONTEXT_OFFSET_F24_F25 96 +#define SPARC_FP_CONTEXT_OFFSET_F26_F27 104 +#define SPARC_FP_CONTEXT_OFFSET_F28_F29 112 +#define SPARC_FP_CONTEXT_OFFSET_F30_F31 120 +#define SPARC_FP_CONTEXT_OFFSET_FSR 128 + +#if ( SPARC_HAS_FPU == 1 ) + #define CPU_PER_CPU_CONTROL_SIZE 8 +#else + #define CPU_PER_CPU_CONTROL_SIZE 0 +#endif + +#if ( SPARC_HAS_FPU == 1 ) + /** + * @brief Offset of the CPU_Per_CPU_control::fsr field relative to the + * Per_CPU_Control begin. + */ + #define SPARC_PER_CPU_FSR_OFFSET 0 + + #if defined(SPARC_USE_LAZY_FP_SWITCH) + /** + * @brief Offset of the CPU_Per_CPU_control::fp_owner field relative to the + * Per_CPU_Control begin. + */ + #define SPARC_PER_CPU_FP_OWNER_OFFSET 4 + #endif +#endif + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { +#if ( SPARC_HAS_FPU == 1 ) + /** + * @brief Memory location to store the FSR register during interrupt + * processing. + * + * This is a write-only field. The FSR is written to force a completion of + * floating point operations in progress. + */ + uint32_t fsr; + +#if defined(SPARC_USE_LAZY_FP_SWITCH) + /** + * @brief The current floating point owner. + */ + struct _Thread_Control *fp_owner; +#else + /* See Per_CPU_Control::Interrupt_frame */ + uint32_t reserved_for_alignment_of_interrupt_frame; +#endif +#endif +} CPU_Per_CPU_control; + +/** + * @brief The pointer to the current per-CPU control is available via register + * g6. + */ +register struct Per_CPU_Control *_SPARC_Per_CPU_current __asm__( "g6" ); + +#define _CPU_Get_current_per_CPU_control() _SPARC_Per_CPU_current + +#define _CPU_Get_thread_executing() ( _SPARC_Per_CPU_current->executing ) + +#ifdef __cplusplus +} +#endif + +#endif /* ASM */ + +#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/sparc/include/rtems/score/sparc.h b/cpukit/score/cpu/sparc/include/rtems/score/sparc.h new file mode 100644 index 0000000000..747d013559 --- /dev/null +++ b/cpukit/score/cpu/sparc/include/rtems/score/sparc.h @@ -0,0 +1,418 @@ +/** + * @file + * + * @brief Information Required to Build RTEMS for a Particular Member + * of the SPARC Family + * + * This file contains the information required to build + * RTEMS for a particular member of the SPARC family. It does + * this by setting variables to indicate which implementation + * dependent features are present in a particular member + * of the family. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SPARC_H +#define _RTEMS_SCORE_SPARC_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * + * Currently recognized feature flags: + * + * + SPARC_HAS_FPU + * 0 - no HW FPU + * 1 - has HW FPU (assumed to be compatible w/90C602) + * + * + SPARC_HAS_BITSCAN + * 0 - does not have scan instructions + * 1 - has scan instruction (not currently implemented) + * + * + SPARC_NUMBER_OF_REGISTER_WINDOWS + * 8 is the most common number supported by SPARC implementations. + * SPARC_PSR_CWP_MASK is derived from this value. + */ + +/** + * Some higher end SPARCs have a bitscan instructions. It would + * be nice to take advantage of them. Right now, there is no + * port to a CPU model with this feature and no (untested) code + * that is based on this feature flag. + */ +#define SPARC_HAS_BITSCAN 0 + +/** + * This should be OK until a port to a higher end SPARC processor + * is made that has more than 8 register windows. If this cannot + * be determined based on multilib settings (v7/v8/v9), then the + * cpu_asm.S code that depends on this will have to move to libcpu. + */ +#define SPARC_NUMBER_OF_REGISTER_WINDOWS 8 + +/** + * See GRLIB-TN-0009: "LEON3FT Stale Cache Entry After Store with + * Data Tag Parity Error" + */ +#if defined(__FIX_LEON3FT_B2BST) + #define SPARC_LEON3FT_B2BST_NOP nop +#else + #define SPARC_LEON3FT_B2BST_NOP +#endif + +/** + * This macro indicates whether this multilib variation has hardware + * floating point or not. We use the gcc cpp predefine _SOFT_FLOAT + * to determine that. + */ +#if defined(_SOFT_FLOAT) + #define SPARC_HAS_FPU 0 +#else + #define SPARC_HAS_FPU 1 +#endif + +/** + * This macro contains a string describing the multilib variant being + * build. + */ +#if SPARC_HAS_FPU + #define CPU_MODEL_NAME "w/FPU" +#else + #define CPU_MODEL_NAME "w/soft-float" +#endif + +/** + * Define the name of the CPU family. + */ +#define CPU_NAME "SPARC" + +/* + * Miscellaneous constants + */ + +/** + * PSR masks and starting bit positions + * + * NOTE: Reserved bits are ignored. + */ +#if (SPARC_NUMBER_OF_REGISTER_WINDOWS == 8) + #define SPARC_PSR_CWP_MASK 0x07 /* bits 0 - 4 */ +#elif (SPARC_NUMBER_OF_REGISTER_WINDOWS == 16) + #define SPARC_PSR_CWP_MASK 0x0F /* bits 0 - 4 */ +#elif (SPARC_NUMBER_OF_REGISTER_WINDOWS == 32) + #define SPARC_PSR_CWP_MASK 0x1F /* bits 0 - 4 */ +#else + #error "Unsupported number of register windows for this cpu" +#endif + +/** This constant is a mask for the ET bits in the PSR. */ +#define SPARC_PSR_ET_MASK 0x00000020 /* bit 5 */ +/** This constant is a mask for the PS bits in the PSR. */ +#define SPARC_PSR_PS_MASK 0x00000040 /* bit 6 */ +/** This constant is a mask for the S bits in the PSR. */ +#define SPARC_PSR_S_MASK 0x00000080 /* bit 7 */ +/** This constant is a mask for the PIL bits in the PSR. */ +#define SPARC_PSR_PIL_MASK 0x00000F00 /* bits 8 - 11 */ +/** This constant is a mask for the EF bits in the PSR. */ +#define SPARC_PSR_EF_MASK 0x00001000 /* bit 12 */ +/** This constant is a mask for the EC bits in the PSR. */ +#define SPARC_PSR_EC_MASK 0x00002000 /* bit 13 */ +/** This constant is a mask for the ICC bits in the PSR. */ +#define SPARC_PSR_ICC_MASK 0x00F00000 /* bits 20 - 23 */ +/** This constant is a mask for the VER bits in the PSR. */ +#define SPARC_PSR_VER_MASK 0x0F000000 /* bits 24 - 27 */ +/** This constant is a mask for the IMPL bits in the PSR. */ +#define SPARC_PSR_IMPL_MASK 0xF0000000 /* bits 28 - 31 */ + +/** This constant is the starting bit position of the CWP in the PSR. */ +#define SPARC_PSR_CWP_BIT_POSITION 0 /* bits 0 - 4 */ +/** This constant is the starting bit position of the ET in the PSR. */ +#define SPARC_PSR_ET_BIT_POSITION 5 /* bit 5 */ +/** This constant is the starting bit position of the PS in the PSR. */ +#define SPARC_PSR_PS_BIT_POSITION 6 /* bit 6 */ +/** This constant is the starting bit position of the S in the PSR. */ +#define SPARC_PSR_S_BIT_POSITION 7 /* bit 7 */ +/** This constant is the starting bit position of the PIL in the PSR. */ +#define SPARC_PSR_PIL_BIT_POSITION 8 /* bits 8 - 11 */ +/** This constant is the starting bit position of the EF in the PSR. */ +#define SPARC_PSR_EF_BIT_POSITION 12 /* bit 12 */ +/** This constant is the starting bit position of the EC in the PSR. */ +#define SPARC_PSR_EC_BIT_POSITION 13 /* bit 13 */ +/** This constant is the starting bit position of the ICC in the PSR. */ +#define SPARC_PSR_ICC_BIT_POSITION 20 /* bits 20 - 23 */ +/** This constant is the starting bit position of the VER in the PSR. */ +#define SPARC_PSR_VER_BIT_POSITION 24 /* bits 24 - 27 */ +/** This constant is the starting bit position of the IMPL in the PSR. */ +#define SPARC_PSR_IMPL_BIT_POSITION 28 /* bits 28 - 31 */ + +#define LEON3_ASR17_PROCESSOR_INDEX_SHIFT 28 + +/* SPARC Software Trap number definitions */ +#define SPARC_SWTRAP_SYSCALL 0 +#define SPARC_SWTRAP_IRQDIS 9 +#define SPARC_SWTRAP_IRQEN 10 +#if SPARC_HAS_FPU == 1 +#define SPARC_SWTRAP_IRQDIS_FP 11 +#endif + +#ifndef ASM + +/** + * This macro is a standard nop instruction. + */ +#define nop() \ + do { \ + __asm__ volatile ( "nop" ); \ + } while ( 0 ) + +/** + * @brief Macro to obtain the PSR. + * + * This macro returns the current contents of the PSR register in @a _psr. + */ +#if defined(RTEMS_PARAVIRT) + +uint32_t _SPARC_Get_PSR( void ); + +#define sparc_get_psr( _psr ) \ + (_psr) = _SPARC_Get_PSR() + +#else /* RTEMS_PARAVIRT */ + +#define sparc_get_psr( _psr ) \ + do { \ + (_psr) = 0; \ + __asm__ volatile( "rd %%psr, %0" : "=r" (_psr) : "0" (_psr) ); \ + } while ( 0 ) + +#endif /* RTEMS_PARAVIRT */ + +/** + * @brief Macro to set the PSR. + * + * This macro sets the PSR register to the value in @a _psr. + */ +#if defined(RTEMS_PARAVIRT) + +void _SPARC_Set_PSR( uint32_t new_psr ); + +#define sparc_set_psr( _psr ) \ + _SPARC_Set_PSR( _psr ) + +#else /* RTEMS_PARAVIRT */ + +#define sparc_set_psr( _psr ) \ + do { \ + __asm__ volatile ( "mov %0, %%psr " : "=r" ((_psr)) : "0" ((_psr)) ); \ + nop(); \ + nop(); \ + nop(); \ + } while ( 0 ) + +#endif /* RTEMS_PARAVIRT */ + +/** + * @brief Macro to obtain the TBR. + * + * This macro returns the current contents of the TBR register in @a _tbr. + */ +#if defined(RTEMS_PARAVIRT) + +uint32_t _SPARC_Get_TBR( void ); + +#define sparc_get_tbr( _tbr ) \ + (_tbr) = _SPARC_Get_TBR() + +#else /* RTEMS_PARAVIRT */ + +#define sparc_get_tbr( _tbr ) \ + do { \ + (_tbr) = 0; /* to avoid unitialized warnings */ \ + __asm__ volatile( "rd %%tbr, %0" : "=r" (_tbr) : "0" (_tbr) ); \ + } while ( 0 ) + +#endif /* RTEMS_PARAVIRT */ + +/** + * @brief Macro to set the TBR. + * + * This macro sets the TBR register to the value in @a _tbr. + */ +#if defined(RTEMS_PARAVIRT) + +void _SPARC_Set_TBR( uint32_t new_tbr ); + +#define sparc_set_tbr( _tbr ) \ + _SPARC_Set_TBR((_tbr)) + +#else /* RTEMS_PARAVIRT */ + +#define sparc_set_tbr( _tbr ) \ + do { \ + __asm__ volatile( "wr %0, 0, %%tbr" : "=r" (_tbr) : "0" (_tbr) ); \ + } while ( 0 ) + +#endif /* RTEMS_PARAVIRT */ + +/** + * @brief Macro to obtain the WIM. + * + * This macro returns the current contents of the WIM field in @a _wim. + */ +#define sparc_get_wim( _wim ) \ + do { \ + __asm__ volatile( "rd %%wim, %0" : "=r" (_wim) : "0" (_wim) ); \ + } while ( 0 ) + +/** + * @brief Macro to set the WIM. + * + * This macro sets the WIM field to the value in @a _wim. + */ +#define sparc_set_wim( _wim ) \ + do { \ + __asm__ volatile( "wr %0, %%wim" : "=r" (_wim) : "0" (_wim) ); \ + nop(); \ + nop(); \ + nop(); \ + } while ( 0 ) + +/** + * @brief Macro to obtain the Y register. + * + * This macro returns the current contents of the Y register in @a _y. + */ +#define sparc_get_y( _y ) \ + do { \ + __asm__ volatile( "rd %%y, %0" : "=r" (_y) : "0" (_y) ); \ + } while ( 0 ) + +/** + * @brief Macro to set the Y register. + * + * This macro sets the Y register to the value in @a _y. + */ +#define sparc_set_y( _y ) \ + do { \ + __asm__ volatile( "wr %0, %%y" : "=r" (_y) : "0" (_y) ); \ + } while ( 0 ) + +/** + * @brief SPARC disable processor interrupts. + * + * This method is invoked to disable all maskable interrupts. + * + * @return This method returns the entire PSR contents. + */ +static inline uint32_t sparc_disable_interrupts(void) +{ + register uint32_t psr __asm__("g1"); /* return value of trap handler */ + __asm__ volatile ( "ta %1\n\t" : "=r" (psr) : "i" (SPARC_SWTRAP_IRQDIS)); + return psr; +} + +/** + * @brief SPARC enable processor interrupts. + * + * This method is invoked to enable all maskable interrupts. + * + * @param[in] psr is the PSR returned by @ref sparc_disable_interrupts. + */ +static inline void sparc_enable_interrupts(uint32_t psr) +{ + register uint32_t _psr __asm__("g1") = psr; /* input to trap handler */ + + /* + * The trap instruction has a higher trap priority than the interrupts + * according to "The SPARC Architecture Manual: Version 8", Table 7-1 + * "Exception and Interrupt Request Priority and tt Values". Add a nop to + * prevent a trap instruction right after the interrupt enable trap. + */ + __asm__ volatile ( "ta %0\nnop\n" :: "i" (SPARC_SWTRAP_IRQEN), "r" (_psr)); +} + +/** + * @brief SPARC exit through system call 1 + * + * This method is invoked to go into system error halt. The optional + * arguments can be given to hypervisor, hardware debugger, simulator or + * similar. + * + * System error mode is entered when taking a trap when traps have been + * disabled. What happens when error mode is entered depends on the motherboard. + * In a typical development systems the CPU relingish control to the debugger, + * simulator, hypervisor or similar. The following steps are taken: + * + * 1. Going into system error mode by Software Trap 0 + * 2. %g1=1 (syscall 1 - Exit) + * 3. %g2=Primary exit code + * 4. %g3=Secondary exit code. Dependends on %g2 exit type. + * + * This function never returns. + * + * @param[in] exitcode1 Primary exit code stored in CPU g2 register after exit + * @param[in] exitcode2 Primary exit code stored in CPU g3 register after exit + */ +void sparc_syscall_exit(uint32_t exitcode1, uint32_t exitcode2) + RTEMS_NO_RETURN; + +/** + * @brief SPARC flash processor interrupts. + * + * This method is invoked to temporarily enable all maskable interrupts. + * + * @param[in] _psr is the PSR returned by @ref sparc_disable_interrupts. + */ +#define sparc_flash_interrupts( _psr ) \ + do { \ + sparc_enable_interrupts( (_psr) ); \ + _psr = sparc_disable_interrupts(); \ + } while ( 0 ) + +/** + * @brief SPARC obtain interrupt level. + * + * This method is invoked to obtain the current interrupt disable level. + * + * @param[in] _level is the PSR returned by @ref sparc_disable_interrupts. + */ +#define sparc_get_interrupt_level( _level ) \ + do { \ + register uint32_t _psr_level = 0; \ + \ + sparc_get_psr( _psr_level ); \ + (_level) = \ + (_psr_level & SPARC_PSR_PIL_MASK) >> SPARC_PSR_PIL_BIT_POSITION; \ + } while ( 0 ) + +static inline uint32_t _LEON3_Get_current_processor( void ) +{ + uint32_t asr17; + + __asm__ volatile ( + "rd %%asr17, %0" + : "=&r" (asr17) + ); + + return asr17 >> LEON3_ASR17_PROCESSOR_INDEX_SHIFT; +} + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_SCORE_SPARC_H */ diff --git a/cpukit/score/cpu/sparc/include/rtems/score/sparcimpl.h b/cpukit/score/cpu/sparc/include/rtems/score/sparcimpl.h new file mode 100644 index 0000000000..9f9999b063 --- /dev/null +++ b/cpukit/score/cpu/sparc/include/rtems/score/sparcimpl.h @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2016 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SPARCIMPL_H +#define _RTEMS_SCORE_SPARCIMPL_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * Provides a mutable alias to _SPARC_Counter for use in + * _SPARC_Counter_initialize(). The _SPARC_Counter and _SPARC_Counter_mutable + * are defined via the SPARC_COUNTER_DEFINITION define. + */ +extern SPARC_Counter _SPARC_Counter_mutable; + +CPU_Counter_ticks _SPARC_Counter_read_address( void ); + +CPU_Counter_ticks _SPARC_Counter_read_asr23( void ); + +CPU_Counter_ticks _SPARC_Counter_difference_normal( + CPU_Counter_ticks second, + CPU_Counter_ticks first +); + +CPU_Counter_ticks _SPARC_Counter_difference_clock_period( + CPU_Counter_ticks second, + CPU_Counter_ticks first +); + +/* + * Returns always a value of one regardless of the parameters. This prevents + * an infinite loop in rtems_counter_delay_ticks(). Its only a reasonably safe + * default. + */ +CPU_Counter_ticks _SPARC_Counter_difference_one( + CPU_Counter_ticks second, + CPU_Counter_ticks first +); + +static inline void _SPARC_Counter_initialize( + SPARC_Counter_read counter_read, + SPARC_Counter_difference counter_difference, + volatile const CPU_Counter_ticks *counter_address +) +{ + _SPARC_Counter_mutable.counter_read = counter_read; + _SPARC_Counter_mutable.counter_difference = counter_difference; + _SPARC_Counter_mutable.counter_address = counter_address; +} + +/* + * Defines the _SPARC_Counter and _SPARC_Counter_mutable global variables. + * Place this define in the global file scope of the CPU counter support file + * of the BSP. + */ +#define SPARC_COUNTER_DEFINITION \ + __asm__ ( \ + "\t.global\t_SPARC_Counter\n" \ + "\t.global\t_SPARC_Counter_mutable\n" \ + "\t.section\t.data._SPARC_Counter,\"aw\",@progbits\n" \ + "\t.align\t4\n" \ + "\t.type\t_SPARC_Counter, #object\n" \ + "\t.size\t_SPARC_Counter, 12\n" \ + "_SPARC_Counter:\n" \ + "_SPARC_Counter_mutable:\n" \ + "\t.long\t_SPARC_Counter_read_address\n" \ + "\t.long\t_SPARC_Counter_difference_one\n" \ + "\t.long\t_SPARC_Counter\n" \ + ) + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _RTEMS_SCORE_SPARCIMPL_H */ diff --git a/cpukit/score/cpu/sparc/include/rtems/score/types.h b/cpukit/score/cpu/sparc/include/rtems/score/types.h new file mode 100644 index 0000000000..6419c9f15f --- /dev/null +++ b/cpukit/score/cpu/sparc/include/rtems/score/types.h @@ -0,0 +1,53 @@ +/** + * @file + * + * @brief SPARC CPU Type Definitions + * + * This include file contains type definitions pertaining to the + * SPARC processor family. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_TYPES_H +#define _RTEMS_SCORE_TYPES_H + +#include + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +/** Type that can store a 32-bit integer or a pointer. */ +typedef uintptr_t CPU_Uint32ptr; + +/** + * @brief SPARC ISR handler return type. + * + * This is the type which SPARC ISR Handlers return. + */ +typedef void sparc_isr; + +/** + * @brief SPARC ISR handler prototype. + * + * This is the prototype for SPARC ISR Handlers. + */ +typedef void ( *sparc_isr_entry )( void ); + +#ifdef __cplusplus +} +#endif + +#endif /* !ASM */ + +#endif diff --git a/cpukit/score/cpu/sparc/preinstall.am b/cpukit/score/cpu/sparc/preinstall.am deleted file mode 100644 index 13caf27e22..0000000000 --- a/cpukit/score/cpu/sparc/preinstall.am +++ /dev/null @@ -1,62 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -$(PROJECT_INCLUDE)/libcpu/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/libcpu - @: > $(PROJECT_INCLUDE)/libcpu/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/libcpu/$(dirstamp) - -$(PROJECT_INCLUDE)/libcpu/byteorder.h: include/libcpu/byteorder.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/byteorder.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/byteorder.h - -$(PROJECT_INCLUDE)/rtems/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems - @: > $(PROJECT_INCLUDE)/rtems/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/asm.h: rtems/asm.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/asm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/asm.h - -$(PROJECT_INCLUDE)/rtems/score/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/score - @: > $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/score/sparc.h: rtems/score/sparc.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/sparc.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/sparc.h - -$(PROJECT_INCLUDE)/rtems/score/cpu.h: rtems/score/cpu.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpu.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpu.h - -$(PROJECT_INCLUDE)/rtems/score/cpuimpl.h: rtems/score/cpuimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h - -$(PROJECT_INCLUDE)/rtems/score/sparcimpl.h: rtems/score/sparcimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/sparcimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/sparcimpl.h - -$(PROJECT_INCLUDE)/rtems/score/types.h: rtems/score/types.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/types.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/types.h - -$(PROJECT_INCLUDE)/rtems/score/cpuatomic.h: rtems/score/cpuatomic.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h - diff --git a/cpukit/score/cpu/sparc/rtems/asm.h b/cpukit/score/cpu/sparc/rtems/asm.h deleted file mode 100644 index a2b11f63fc..0000000000 --- a/cpukit/score/cpu/sparc/rtems/asm.h +++ /dev/null @@ -1,120 +0,0 @@ -/** - * @file - * - * @brief Address the Problems Caused by Incompatible Flavor of - * Assemblers and Toolsets - * - * This include file attempts to address the problems - * caused by incompatible flavors of assemblers and - * toolsets. It primarily addresses variations in the - * use of leading underscores on symbols and the requirement - * that register names be preceded by a %. - * - * NOTE: The spacing in the use of these macros - * is critical to them working as advertised. - */ - -/* - * COPYRIGHT: - * - * This file is based on similar code found in newlib available - * from ftp.cygnus.com. The file which was used had no copyright - * notice. This file is freely distributable as long as the source - * of the file is noted. - */ - -#ifndef _RTEMS_ASM_H -#define _RTEMS_ASM_H - -/* - * Indicate we are in an assembly file and get the basic CPU definitions. - */ - -#ifndef ASM -#define ASM -#endif - -#include -#include - -/* - * Recent versions of GNU cpp define variables which indicate the - * need for underscores and percents. If not using GNU cpp or - * the version does not support this, then you will obviously - * have to define these as appropriate. - */ - -/* XXX __USER_LABEL_PREFIX__ and __REGISTER_PREFIX__ do not work on gcc 2.7.0 */ -/* XXX The following ifdef magic fixes the problem but results in a warning */ -/* XXX when compiling assembly code. */ - -#ifndef __USER_LABEL_PREFIX__ -#define __USER_LABEL_PREFIX__ _ -#endif - -#ifndef __REGISTER_PREFIX__ -#define __REGISTER_PREFIX__ -#endif - -#include - -/* Use the right prefix for global labels. */ - -#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) - -/* Use the right prefix for registers. */ - -#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) - -/* - * define macros for all of the registers on this CPU - * - * EXAMPLE: #define d0 REG (d0) - */ - -/* - * Define macros to handle section beginning and ends. - */ - - -#define BEGIN_CODE_DCL .text -#define END_CODE_DCL -#define BEGIN_DATA_DCL .data -#define END_DATA_DCL -#define BEGIN_CODE .text -#define END_CODE -#define BEGIN_DATA -#define END_DATA -#define BEGIN_BSS -#define END_BSS -#define END - -/* - * Following must be tailor for a particular flavor of the C compiler. - * They may need to put underscores in front of the symbols. - */ - -#define PUBLIC(sym) .globl SYM (sym) -#define EXTERN(sym) .globl SYM (sym) - -/* - * Entry for traps which jump to a programmer-specified trap handler. - */ - -#define TRAP(_vector, _handler) \ - mov %psr, %l0 ; \ - sethi %hi(_handler), %l4 ; \ - jmp %l4+%lo(_handler); \ - mov _vector, %l3 - -/* - * Used for the reset trap to avoid a supervisor instruction - */ - -#define RTRAP(_vector, _handler) \ - mov %g0, %l0 ; \ - sethi %hi(_handler), %l4 ; \ - jmp %l4+%lo(_handler); \ - mov _vector, %l3 - -#endif diff --git a/cpukit/score/cpu/sparc/rtems/score/cpu.h b/cpukit/score/cpu/sparc/rtems/score/cpu.h deleted file mode 100644 index 2b50592e08..0000000000 --- a/cpukit/score/cpu/sparc/rtems/score/cpu.h +++ /dev/null @@ -1,1202 +0,0 @@ -/** - * @file - * - * @brief SPARC CPU Department Source - * - * This include file contains information pertaining to the port of - * the executive to the SPARC processor. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPU_H -#define _RTEMS_SCORE_CPU_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/* conditional compilation parameters */ - -/* - * The SPARC ABI is a bit special with respect to the floating point context. - * The complete floating point context is volatile. Thus, from an ABI point - * of view nothing needs to be saved and restored during a context switch. - * Instead the floating point context must be saved and restored during - * interrupt processing. Historically, the deferred floating point switch was - * used for SPARC and the complete floating point context is saved and - * restored during a context switch to the new floating point unit owner. - * This is a bit dangerous since post-switch actions (e.g. signal handlers) - * and context switch extensions may silently corrupt the floating point - * context. - * - * The floating point unit is disabled for interrupt handlers. Thus, in case - * an interrupt handler uses the floating point unit then this will result in a - * trap (INTERNAL_ERROR_ILLEGAL_USE_OF_FLOATING_POINT_UNIT). - * - * In uniprocessor configurations, a lazy floating point context switch is - * used. In case an active floating point thread is interrupted (PSR[EF] == 1) - * and a thread dispatch is carried out, then this thread is registered as the - * floating point owner. When a floating point owner is present during a - * context switch, the floating point unit is disabled for the heir thread - * (PSR[EF] == 0). The floating point disabled trap checks that the use of the - * floating point unit is allowed and saves/restores the floating point context - * on demand. - * - * In SMP configurations, the deferred floating point switch is not supported - * in principle. So, use here a synchronous floating point switching. - * Synchronous means that the volatile floating point context is saved and - * restored around a thread dispatch issued during interrupt processing. Thus - * post-switch actions and context switch extensions may safely use the - * floating point unit. - */ -#if SPARC_HAS_FPU == 1 - #if defined(RTEMS_SMP) - #define SPARC_USE_SYNCHRONOUS_FP_SWITCH - #else - #define SPARC_USE_LAZY_FP_SWITCH - #endif -#endif - -/** - * Does the executive manage a dedicated interrupt stack in software? - * - * If TRUE, then a stack is allocated in _ISR_Handler_initialization. - * If FALSE, nothing is done. - * - * The SPARC does not have a dedicated HW interrupt stack and one has - * been implemented in SW. - */ -#define CPU_HAS_SOFTWARE_INTERRUPT_STACK TRUE - -/** - * Does the CPU follow the simple vectored interrupt model? - * - * - If TRUE, then RTEMS allocates the vector table it internally manages. - * - If FALSE, then the BSP is assumed to allocate and manage the vector - * table - * - * THe SPARC is a simple vectored architecture. Usually there is no - * PIC and the CPU directly vectors the interrupts. - */ -#define CPU_SIMPLE_VECTORED_INTERRUPTS TRUE - -/** - * Does this CPU have hardware support for a dedicated interrupt stack? - * - * - If TRUE, then it must be installed during initialization. - * - If FALSE, then no installation is performed. - * - * The SPARC does not have a dedicated HW interrupt stack. - */ -#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE - -/** - * Do we allocate a dedicated interrupt stack in the Interrupt Manager? - * - * - If TRUE, then the memory is allocated during initialization. - * - If FALSE, then the memory is allocated during initialization. - * - * The SPARC does not have hardware support for switching to a - * dedicated interrupt stack. The port includes support for doing this - * in software. - * - */ -#define CPU_ALLOCATE_INTERRUPT_STACK TRUE - -/** - * Does the RTEMS invoke the user's ISR with the vector number and - * a pointer to the saved interrupt frame (1) or just the vector - * number (0)? - * - * The SPARC port does not pass an Interrupt Stack Frame pointer to - * interrupt handlers. - */ -#define CPU_ISR_PASSES_FRAME_POINTER FALSE - -/** - * Does the CPU have hardware floating point? - * - * - If TRUE, then the FLOATING_POINT task attribute is supported. - * - If FALSE, then the FLOATING_POINT task attribute is ignored. - * - * This is set based upon the multilib settings. - */ -#if ( SPARC_HAS_FPU == 1 ) && !defined(SPARC_USE_SYNCHRONOUS_FP_SWITCH) - #define CPU_HARDWARE_FP TRUE -#else - #define CPU_HARDWARE_FP FALSE -#endif - -/** - * The SPARC GCC port does not have a software floating point library - * that requires RTEMS assistance. - */ -#define CPU_SOFTWARE_FP FALSE - -/** - * Are all tasks FLOATING_POINT tasks implicitly? - * - * - If TRUE, then the FLOATING_POINT task attribute is assumed. - * - If FALSE, then the FLOATING_POINT task attribute is followed. - * - * The SPARC GCC port does not implicitly use floating point registers. - */ -#define CPU_ALL_TASKS_ARE_FP FALSE - -/** - * Should the IDLE task have a floating point context? - * - * - If TRUE, then the IDLE task is created as a FLOATING_POINT task - * and it has a floating point context which is switched in and out. - * - If FALSE, then the IDLE task does not have a floating point context. - * - * The IDLE task does not have to be floating point on the SPARC. - */ -#define CPU_IDLE_TASK_IS_FP FALSE - -#define CPU_USE_DEFERRED_FP_SWITCH FALSE - -#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE - -/** - * Does this port provide a CPU dependent IDLE task implementation? - * - * - If TRUE, then the routine _CPU_Thread_Idle_body - * must be provided and is the default IDLE thread body instead of - * _CPU_Thread_Idle_body. - * - * - If FALSE, then use the generic IDLE thread body if the BSP does - * not provide one. - * - * The SPARC architecture does not have a low power or halt instruction. - * It is left to the BSP and/or CPU specific code to provide an IDLE - * thread body which is aware of low power modes. - */ -#define CPU_PROVIDES_IDLE_THREAD_BODY FALSE - -/** - * Does the stack grow up (toward higher addresses) or down - * (toward lower addresses)? - * - * - If TRUE, then the grows upward. - * - If FALSE, then the grows toward smaller addresses. - * - * The stack grows to lower addresses on the SPARC. - */ -#define CPU_STACK_GROWS_UP FALSE - -/* LEON3 systems may use a cache line size of 64 */ -#define CPU_CACHE_LINE_BYTES 64 - -#define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( CPU_CACHE_LINE_BYTES ) - -/** - * The following defines the number of bits actually used in the - * interrupt field of the task mode. How those bits map to the - * CPU interrupt levels is defined by the routine _CPU_ISR_Set_level(). - * - * The SPARC has 16 interrupt levels in the PIL field of the PSR. - */ -#define CPU_MODES_INTERRUPT_MASK 0x0000000F - -#ifndef ASM -/** - * This structure represents the organization of the minimum stack frame - * for the SPARC. More framing information is required in certain situaions - * such as when there are a large number of out parameters or when the callee - * must save floating point registers. - */ -typedef struct { - /** This is the offset of the l0 register. */ - uint32_t l0; - /** This is the offset of the l1 register. */ - uint32_t l1; - /** This is the offset of the l2 register. */ - uint32_t l2; - /** This is the offset of the l3 register. */ - uint32_t l3; - /** This is the offset of the l4 register. */ - uint32_t l4; - /** This is the offset of the l5 register. */ - uint32_t l5; - /** This is the offset of the l6 register. */ - uint32_t l6; - /** This is the offset of the l7 register. */ - uint32_t l7; - /** This is the offset of the l0 register. */ - uint32_t i0; - /** This is the offset of the i1 register. */ - uint32_t i1; - /** This is the offset of the i2 register. */ - uint32_t i2; - /** This is the offset of the i3 register. */ - uint32_t i3; - /** This is the offset of the i4 register. */ - uint32_t i4; - /** This is the offset of the i5 register. */ - uint32_t i5; - /** This is the offset of the i6 register. */ - uint32_t i6_fp; - /** This is the offset of the i7 register. */ - uint32_t i7; - /** This is the offset of the register used to return structures. */ - void *structure_return_address; - - /* - * The following are for the callee to save the register arguments in - * should this be necessary. - */ - /** This is the offset of the register for saved argument 0. */ - uint32_t saved_arg0; - /** This is the offset of the register for saved argument 1. */ - uint32_t saved_arg1; - /** This is the offset of the register for saved argument 2. */ - uint32_t saved_arg2; - /** This is the offset of the register for saved argument 3. */ - uint32_t saved_arg3; - /** This is the offset of the register for saved argument 4. */ - uint32_t saved_arg4; - /** This is the offset of the register for saved argument 5. */ - uint32_t saved_arg5; - /** This field pads the structure so ldd and std instructions can be used. */ - uint32_t pad0; -} SPARC_Minimum_stack_frame; - -#endif /* ASM */ - -/** This macro defines an offset into the stack frame for use in assembly. */ -#define CPU_STACK_FRAME_L0_OFFSET 0x00 -/** This macro defines an offset into the stack frame for use in assembly. */ -#define CPU_STACK_FRAME_L1_OFFSET 0x04 -/** This macro defines an offset into the stack frame for use in assembly. */ -#define CPU_STACK_FRAME_L2_OFFSET 0x08 -/** This macro defines an offset into the stack frame for use in assembly. */ -#define CPU_STACK_FRAME_L3_OFFSET 0x0c -/** This macro defines an offset into the stack frame for use in assembly. */ -#define CPU_STACK_FRAME_L4_OFFSET 0x10 -/** This macro defines an offset into the stack frame for use in assembly. */ -#define CPU_STACK_FRAME_L5_OFFSET 0x14 -/** This macro defines an offset into the stack frame for use in assembly. */ -#define CPU_STACK_FRAME_L6_OFFSET 0x18 -/** This macro defines an offset into the stack frame for use in assembly. */ -#define CPU_STACK_FRAME_L7_OFFSET 0x1c -/** This macro defines an offset into the stack frame for use in assembly. */ -#define CPU_STACK_FRAME_I0_OFFSET 0x20 -/** This macro defines an offset into the stack frame for use in assembly. */ -#define CPU_STACK_FRAME_I1_OFFSET 0x24 -/** This macro defines an offset into the stack frame for use in assembly. */ -#define CPU_STACK_FRAME_I2_OFFSET 0x28 -/** This macro defines an offset into the stack frame for use in assembly. */ -#define CPU_STACK_FRAME_I3_OFFSET 0x2c -/** This macro defines an offset into the stack frame for use in assembly. */ -#define CPU_STACK_FRAME_I4_OFFSET 0x30 -/** This macro defines an offset into the stack frame for use in assembly. */ -#define CPU_STACK_FRAME_I5_OFFSET 0x34 -/** This macro defines an offset into the stack frame for use in assembly. */ -#define CPU_STACK_FRAME_I6_FP_OFFSET 0x38 -/** This macro defines an offset into the stack frame for use in assembly. */ -#define CPU_STACK_FRAME_I7_OFFSET 0x3c -/** This macro defines an offset into the stack frame for use in assembly. */ -#define CPU_STRUCTURE_RETURN_ADDRESS_OFFSET 0x40 -/** This macro defines an offset into the stack frame for use in assembly. */ -#define CPU_STACK_FRAME_SAVED_ARG0_OFFSET 0x44 -/** This macro defines an offset into the stack frame for use in assembly. */ -#define CPU_STACK_FRAME_SAVED_ARG1_OFFSET 0x48 -/** This macro defines an offset into the stack frame for use in assembly. */ -#define CPU_STACK_FRAME_SAVED_ARG2_OFFSET 0x4c -/** This macro defines an offset into the stack frame for use in assembly. */ -#define CPU_STACK_FRAME_SAVED_ARG3_OFFSET 0x50 -/** This macro defines an offset into the stack frame for use in assembly. */ -#define CPU_STACK_FRAME_SAVED_ARG4_OFFSET 0x54 -/** This macro defines an offset into the stack frame for use in assembly. */ -#define CPU_STACK_FRAME_SAVED_ARG5_OFFSET 0x58 -/** This macro defines an offset into the stack frame for use in assembly. */ -#define CPU_STACK_FRAME_PAD0_OFFSET 0x5c - -#define CPU_MAXIMUM_PROCESSORS 32 - -/** - * @defgroup Contexts SPARC Context Structures - * - * @ingroup Score - * - * Generally there are 2 types of context to save. - * + Interrupt registers to save - * + Task level registers to save - * - * This means we have the following 3 context items: - * + task level context stuff:: Context_Control - * + floating point task stuff:: Context_Control_fp - * + special interrupt level context :: Context_Control_interrupt - * - * On the SPARC, we are relatively conservative in that we save most - * of the CPU state in the context area. The ET (enable trap) bit and - * the CWP (current window pointer) fields of the PSR are considered - * system wide resources and are not maintained on a per-thread basis. - */ -/**@{**/ - -#ifndef ASM -typedef struct Context_Control_fp Context_Control_fp; - -/** - * @brief SPARC basic context. - * - * This structure defines the non-volatile integer and processor state context - * for the SPARC architecture according to "SYSTEM V APPLICATION BINARY - * INTERFACE - SPARC Processor Supplement", Third Edition. - * - * The registers g2 through g4 are reserved for applications. GCC uses them as - * volatile registers by default. So they are treated like volatile registers - * in RTEMS as well. - * - * The register g6 contains the per-CPU control of the current processor. It - * is an invariant of the processor context. This register must not be saved - * and restored during context switches or interrupt services. - */ -typedef struct { - /** This will contain the contents of the g5 register. */ - uint32_t g5; - /** This will contain the contents of the g7 register. */ - uint32_t g7; - - /** - * This will contain the contents of the l0 and l1 registers. - * - * Using a double l0_and_l1 will put everything in this structure on a double - * word boundary which allows us to use double word loads and stores safely - * in the context switch. - */ - double l0_and_l1; - /** This will contain the contents of the l2 register. */ - uint32_t l2; - /** This will contain the contents of the l3 register. */ - uint32_t l3; - /** This will contain the contents of the l4 register. */ - uint32_t l4; - /** This will contain the contents of the l5 registeer.*/ - uint32_t l5; - /** This will contain the contents of the l6 register. */ - uint32_t l6; - /** This will contain the contents of the l7 register. */ - uint32_t l7; - - /** This will contain the contents of the i0 register. */ - uint32_t i0; - /** This will contain the contents of the i1 register. */ - uint32_t i1; - /** This will contain the contents of the i2 register. */ - uint32_t i2; - /** This will contain the contents of the i3 register. */ - uint32_t i3; - /** This will contain the contents of the i4 register. */ - uint32_t i4; - /** This will contain the contents of the i5 register. */ - uint32_t i5; - /** This will contain the contents of the i6 (e.g. frame pointer) register. */ - uint32_t i6_fp; - /** This will contain the contents of the i7 register. */ - uint32_t i7; - - /** This will contain the contents of the o6 (e.g. frame pointer) register. */ - uint32_t o6_sp; - /** - * This will contain the contents of the o7 (e.g. address of CALL - * instruction) register. - */ - uint32_t o7; - - /** This will contain the contents of the processor status register. */ - uint32_t psr; - /** - * This field is used to prevent heavy nesting of calls to _Thread_Dispatch - * on an interrupted task's stack. This is problematic on the slower - * SPARC CPU models at high interrupt rates. - */ - uint32_t isr_dispatch_disable; - -#if defined(SPARC_USE_LAZY_FP_SWITCH) - Context_Control_fp *fp_context; -#endif - -#if defined(RTEMS_SMP) - volatile uint32_t is_executing; -#endif -} Context_Control; - -/** - * This macro provides a CPU independent way for RTEMS to access the - * stack pointer in a context structure. The actual name and offset is - * CPU architecture dependent. - */ -#define _CPU_Context_Get_SP( _context ) \ - (_context)->o6_sp - -#ifdef RTEMS_SMP - static inline bool _CPU_Context_Get_is_executing( - const Context_Control *context - ) - { - return context->is_executing; - } - - static inline void _CPU_Context_Set_is_executing( - Context_Control *context, - bool is_executing - ) - { - context->is_executing = is_executing; - } -#endif - -#endif /* ASM */ - -/* - * Offsets of fields with Context_Control for assembly routines. - */ - -/** This macro defines an offset into the context for use in assembly. */ -#define G5_OFFSET 0x00 -/** This macro defines an offset into the context for use in assembly. */ -#define G7_OFFSET 0x04 - -/** This macro defines an offset into the context for use in assembly. */ -#define L0_OFFSET 0x08 -/** This macro defines an offset into the context for use in assembly. */ -#define L1_OFFSET 0x0C -/** This macro defines an offset into the context for use in assembly. */ -#define L2_OFFSET 0x10 -/** This macro defines an offset into the context for use in assembly. */ -#define L3_OFFSET 0x14 -/** This macro defines an offset into the context for use in assembly. */ -#define L4_OFFSET 0x18 -/** This macro defines an offset into the context for use in assembly. */ -#define L5_OFFSET 0x1C -/** This macro defines an offset into the context for use in assembly. */ -#define L6_OFFSET 0x20 -/** This macro defines an offset into the context for use in assembly. */ -#define L7_OFFSET 0x24 - -/** This macro defines an offset into the context for use in assembly. */ -#define I0_OFFSET 0x28 -/** This macro defines an offset into the context for use in assembly. */ -#define I1_OFFSET 0x2C -/** This macro defines an offset into the context for use in assembly. */ -#define I2_OFFSET 0x30 -/** This macro defines an offset into the context for use in assembly. */ -#define I3_OFFSET 0x34 -/** This macro defines an offset into the context for use in assembly. */ -#define I4_OFFSET 0x38 -/** This macro defines an offset into the context for use in assembly. */ -#define I5_OFFSET 0x3C -/** This macro defines an offset into the context for use in assembly. */ -#define I6_FP_OFFSET 0x40 -/** This macro defines an offset into the context for use in assembly. */ -#define I7_OFFSET 0x44 - -/** This macro defines an offset into the context for use in assembly. */ -#define O6_SP_OFFSET 0x48 -/** This macro defines an offset into the context for use in assembly. */ -#define O7_OFFSET 0x4C - -/** This macro defines an offset into the context for use in assembly. */ -#define PSR_OFFSET 0x50 -/** This macro defines an offset into the context for use in assembly. */ -#define ISR_DISPATCH_DISABLE_STACK_OFFSET 0x54 - -#if defined(RTEMS_SMP) - #define SPARC_CONTEXT_CONTROL_IS_EXECUTING_OFFSET 0x58 -#endif - -#ifndef ASM -/** - * @brief SPARC basic context. - * - * This structure defines floating point context area. - */ -struct Context_Control_fp { - /** This will contain the contents of the f0 and f1 register. */ - double f0_f1; - /** This will contain the contents of the f2 and f3 register. */ - double f2_f3; - /** This will contain the contents of the f4 and f5 register. */ - double f4_f5; - /** This will contain the contents of the f6 and f7 register. */ - double f6_f7; - /** This will contain the contents of the f8 and f9 register. */ - double f8_f9; - /** This will contain the contents of the f10 and f11 register. */ - double f10_f11; - /** This will contain the contents of the f12 and f13 register. */ - double f12_f13; - /** This will contain the contents of the f14 and f15 register. */ - double f14_f15; - /** This will contain the contents of the f16 and f17 register. */ - double f16_f17; - /** This will contain the contents of the f18 and f19 register. */ - double f18_f19; - /** This will contain the contents of the f20 and f21 register. */ - double f20_f21; - /** This will contain the contents of the f22 and f23 register. */ - double f22_f23; - /** This will contain the contents of the f24 and f25 register. */ - double f24_f25; - /** This will contain the contents of the f26 and f27 register. */ - double f26_f27; - /** This will contain the contents of the f28 and f29 register. */ - double f28_f29; - /** This will contain the contents of the f30 and f31 register. */ - double f30_f31; - /** This will contain the contents of the floating point status register. */ - uint32_t fsr; -}; - -#endif /* ASM */ - -/* - * Offsets of fields with Context_Control_fp for assembly routines. - */ - -/** This macro defines an offset into the FPU context for use in assembly. */ -#define FO_F1_OFFSET 0x00 -/** This macro defines an offset into the FPU context for use in assembly. */ -#define F2_F3_OFFSET 0x08 -/** This macro defines an offset into the FPU context for use in assembly. */ -#define F4_F5_OFFSET 0x10 -/** This macro defines an offset into the FPU context for use in assembly. */ -#define F6_F7_OFFSET 0x18 -/** This macro defines an offset into the FPU context for use in assembly. */ -#define F8_F9_OFFSET 0x20 -/** This macro defines an offset into the FPU context for use in assembly. */ -#define F1O_F11_OFFSET 0x28 -/** This macro defines an offset into the FPU context for use in assembly. */ -#define F12_F13_OFFSET 0x30 -/** This macro defines an offset into the FPU context for use in assembly. */ -#define F14_F15_OFFSET 0x38 -/** This macro defines an offset into the FPU context for use in assembly. */ -#define F16_F17_OFFSET 0x40 -/** This macro defines an offset into the FPU context for use in assembly. */ -#define F18_F19_OFFSET 0x48 -/** This macro defines an offset into the FPU context for use in assembly. */ -#define F2O_F21_OFFSET 0x50 -/** This macro defines an offset into the FPU context for use in assembly. */ -#define F22_F23_OFFSET 0x58 -/** This macro defines an offset into the FPU context for use in assembly. */ -#define F24_F25_OFFSET 0x60 -/** This macro defines an offset into the FPU context for use in assembly. */ -#define F26_F27_OFFSET 0x68 -/** This macro defines an offset into the FPU context for use in assembly. */ -#define F28_F29_OFFSET 0x70 -/** This macro defines an offset into the FPU context for use in assembly. */ -#define F3O_F31_OFFSET 0x78 -/** This macro defines an offset into the FPU context for use in assembly. */ -#define FSR_OFFSET 0x80 - -/** This defines the size of the FPU context area for use in assembly. */ -#define CONTEXT_CONTROL_FP_SIZE 0x84 - -#ifndef ASM - -/** @} */ - -/** - * @brief Interrupt stack frame (ISF). - * - * Context saved on stack for an interrupt. - * - * NOTE: The PSR, PC, and NPC are only saved in this structure for the - * benefit of the user's handler. - */ -typedef struct { - /** On an interrupt, we must save the minimum stack frame. */ - SPARC_Minimum_stack_frame Stack_frame; - /** This is the offset of the PSR on an ISF. */ - uint32_t psr; - /** This is the offset of the XXX on an ISF. */ - uint32_t pc; - /** This is the offset of the XXX on an ISF. */ - uint32_t npc; - /** This is the offset of the g1 register on an ISF. */ - uint32_t g1; - /** This is the offset of the g2 register on an ISF. */ - uint32_t g2; - /** This is the offset of the g3 register on an ISF. */ - uint32_t g3; - /** This is the offset of the g4 register on an ISF. */ - uint32_t g4; - /** This is the offset of the g5 register on an ISF. */ - uint32_t g5; - /** This is the offset is reserved for alignment on an ISF. */ - uint32_t reserved_for_alignment; - /** This is the offset of the g7 register on an ISF. */ - uint32_t g7; - /** This is the offset of the i0 register on an ISF. */ - uint32_t i0; - /** This is the offset of the i1 register on an ISF. */ - uint32_t i1; - /** This is the offset of the i2 register on an ISF. */ - uint32_t i2; - /** This is the offset of the i3 register on an ISF. */ - uint32_t i3; - /** This is the offset of the i4 register on an ISF. */ - uint32_t i4; - /** This is the offset of the i5 register on an ISF. */ - uint32_t i5; - /** This is the offset of the i6 register on an ISF. */ - uint32_t i6_fp; - /** This is the offset of the i7 register on an ISF. */ - uint32_t i7; - /** This is the offset of the y register on an ISF. */ - uint32_t y; - /** This is the offset of the tpc register on an ISF. */ - uint32_t tpc; -} CPU_Interrupt_frame; - -#endif /* ASM */ - -#ifndef ASM -/** - * The following type defines an entry in the SPARC's trap table. - * - * NOTE: The instructions chosen are RTEMS dependent although one is - * obligated to use two of the four instructions to perform a - * long jump. The other instructions load one register with the - * trap type (a.k.a. vector) and another with the psr. - */ -typedef struct { - /** This will contain a "mov %psr, %l0" instruction. */ - uint32_t mov_psr_l0; - /** This will contain a "sethi %hi(_handler), %l4" instruction. */ - uint32_t sethi_of_handler_to_l4; - /** This will contain a "jmp %l4 + %lo(_handler)" instruction. */ - uint32_t jmp_to_low_of_handler_plus_l4; - /** This will contain a " mov _vector, %l3" instruction. */ - uint32_t mov_vector_l3; -} CPU_Trap_table_entry; - -/** - * This is the set of opcodes for the instructions loaded into a trap - * table entry. The routine which installs a handler is responsible - * for filling in the fields for the _handler address and the _vector - * trap type. - * - * The constants following this structure are masks for the fields which - * must be filled in when the handler is installed. - */ -extern const CPU_Trap_table_entry _CPU_Trap_slot_template; - -/** - * The size of the floating point context area. - */ -#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp ) - -#endif - -/** - * Amount of extra stack (above minimum stack size) required by - * MPCI receive server thread. Remember that in a multiprocessor - * system this thread must exist and be able to process all directives. - */ -#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 1024 - -/** - * This defines the number of entries in the ISR_Vector_table managed - * by the executive. - * - * On the SPARC, there are really only 256 vectors. However, the executive - * has no easy, fast, reliable way to determine which traps are synchronous - * and which are asynchronous. By default, synchronous traps return to the - * instruction which caused the interrupt. So if you install a software - * trap handler as an executive interrupt handler (which is desirable since - * RTEMS takes care of window and register issues), then the executive needs - * to know that the return address is to the trap rather than the instruction - * following the trap. - * - * So vectors 0 through 255 are treated as regular asynchronous traps which - * provide the "correct" return address. Vectors 256 through 512 are assumed - * by the executive to be synchronous and to require that the return address - * be fudged. - * - * If you use this mechanism to install a trap handler which must reexecute - * the instruction which caused the trap, then it should be installed as - * an asynchronous trap. This will avoid the executive changing the return - * address. - */ -#define CPU_INTERRUPT_NUMBER_OF_VECTORS 256 - -/** - * The SPARC has 256 vectors but the port treats 256-512 as synchronous - * traps. - */ -#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER 511 - -/** - * This is the bit step in a vector number to indicate it is being installed - * as a synchronous trap. - */ -#define SPARC_SYNCHRONOUS_TRAP_BIT_MASK 0x100 - -/** - * This macro indicates that @a _trap as an asynchronous trap. - */ -#define SPARC_ASYNCHRONOUS_TRAP( _trap ) (_trap) - -/** - * This macro indicates that @a _trap as a synchronous trap. - */ -#define SPARC_SYNCHRONOUS_TRAP( _trap ) ((_trap) + 256 ) - -/** - * This macro returns the real hardware vector number associated with @a _trap. - */ -#define SPARC_REAL_TRAP_NUMBER( _trap ) ((_trap) % 256) - -/** - * This is defined if the port has a special way to report the ISR nesting - * level. Most ports maintain the variable _ISR_Nest_level. - */ -#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE - -/** - * Should be large enough to run all tests. This ensures - * that a "reasonable" small application should not have any problems. - * - * This appears to be a fairly generous number for the SPARC since - * represents a call depth of about 20 routines based on the minimum - * stack frame. - */ -#define CPU_STACK_MINIMUM_SIZE (1024*4) - -/** - * What is the size of a pointer on this architecture? - */ -#define CPU_SIZEOF_POINTER 4 - -/** - * CPU's worst alignment requirement for data types on a byte boundary. This - * alignment does not take into account the requirements for the stack. - * - * On the SPARC, this is required for double word loads and stores. - */ -#define CPU_ALIGNMENT 8 - -/** - * This number corresponds to the byte alignment requirement for the - * heap handler. This alignment requirement may be stricter than that - * for the data types alignment specified by CPU_ALIGNMENT. It is - * common for the heap to follow the same alignment requirement as - * CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict enough for the heap, - * then this should be set to CPU_ALIGNMENT. - * - * NOTE: This does not have to be a power of 2. It does have to - * be greater or equal to than CPU_ALIGNMENT. - */ -#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT - -/** - * This number corresponds to the byte alignment requirement for memory - * buffers allocated by the partition manager. This alignment requirement - * may be stricter than that for the data types alignment specified by - * CPU_ALIGNMENT. It is common for the partition to follow the same - * alignment requirement as CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict - * enough for the partition, then this should be set to CPU_ALIGNMENT. - * - * NOTE: This does not have to be a power of 2. It does have to - * be greater or equal to than CPU_ALIGNMENT. - */ -#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT - -/** - * Stack frames must be doubleword aligned according to the System V ABI for - * SPARC. - */ -#define CPU_STACK_ALIGNMENT CPU_ALIGNMENT - -#ifndef ASM - -/* - * ISR handler macros - */ - -/** - * Support routine to initialize the RTEMS vector table after it is allocated. - */ -#define _CPU_Initialize_vectors() - -/** - * Disable all interrupts for a critical section. The previous - * level is returned in _level. - */ -#define _CPU_ISR_Disable( _level ) \ - (_level) = sparc_disable_interrupts() - -/** - * Enable interrupts to the previous level (returned by _CPU_ISR_Disable). - * This indicates the end of a critical section. The parameter - * _level is not modified. - */ -#define _CPU_ISR_Enable( _level ) \ - sparc_enable_interrupts( _level ) - -/** - * This temporarily restores the interrupt to _level before immediately - * disabling them again. This is used to divide long critical - * sections into two or more parts. The parameter _level is not - * modified. - */ -#define _CPU_ISR_Flash( _level ) \ - sparc_flash_interrupts( _level ) - -#define _CPU_ISR_Is_enabled( _isr_cookie ) \ - sparc_interrupt_is_enabled( _isr_cookie ) - -RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) -{ - return ( level & SPARC_PSR_PIL_MASK ) == 0; -} - -/** - * Map interrupt level in task mode onto the hardware that the CPU - * actually provides. Currently, interrupt levels which do not - * map onto the CPU in a straight fashion are undefined. - */ -#define _CPU_ISR_Set_level( _newlevel ) \ - sparc_enable_interrupts( _newlevel << 8) - -/** - * @brief Obtain the current interrupt disable level. - * - * This method is invoked to return the current interrupt disable level. - * - * @return This method returns the current interrupt disable level. - */ -uint32_t _CPU_ISR_Get_level( void ); - -/* end of ISR handler macros */ - -/* Context handler macros */ - -/** - * Initialize the context to a state suitable for starting a - * task after a context restore operation. Generally, this - * involves: - * - * - setting a starting address - * - preparing the stack - * - preparing the stack and frame pointers - * - setting the proper interrupt level in the context - * - initializing the floating point context - * - * @param[in] the_context points to the context area - * @param[in] stack_base is the low address of the allocated stack area - * @param[in] size is the size of the stack area in bytes - * @param[in] new_level is the interrupt level for the task - * @param[in] entry_point is the task's entry point - * @param[in] is_fp is set to TRUE if the task is a floating point task - * @param[in] tls_area is the thread-local storage (TLS) area - * - * NOTE: Implemented as a subroutine for the SPARC port. - */ -void _CPU_Context_Initialize( - Context_Control *the_context, - uint32_t *stack_base, - uint32_t size, - uint32_t new_level, - void *entry_point, - bool is_fp, - void *tls_area -); - -/** - * This macro is invoked from _Thread_Handler to do whatever CPU - * specific magic is required that must be done in the context of - * the thread when it starts. - * - * On the SPARC, this is setting the frame pointer so GDB is happy. - * Make GDB stop unwinding at _Thread_Handler, previous register window - * Frame pointer is 0 and calling address must be a function with starting - * with a SAVE instruction. If return address is leaf-function (no SAVE) - * GDB will not look at prev reg window fp. - * - * _Thread_Handler is known to start with SAVE. - */ -#define _CPU_Context_Initialization_at_thread_begin() \ - do { \ - __asm__ volatile ("set _Thread_Handler,%%i7\n"::); \ - } while (0) - -/** - * This routine is responsible for somehow restarting the currently - * executing task. - * - * On the SPARC, this is is relatively painless but requires a small - * amount of wrapper code before using the regular restore code in - * of the context switch. - */ -#define _CPU_Context_Restart_self( _the_context ) \ - _CPU_Context_restore( (_the_context) ); - -/** - * @brief Nothing to do due to the synchronous or lazy floating point switch. - */ -#define _CPU_Context_Initialize_fp( _destination ) \ - do { } while ( 0 ) - -/** - * @brief Nothing to do due to the synchronous or lazy floating point switch. - */ -#define _CPU_Context_save_fp( _fp_context_ptr ) \ - do { } while ( 0 ) - -/** - * @brief Nothing to do due to the synchronous or lazy floating point switch. - */ -#define _CPU_Context_restore_fp( _fp_context_ptr ) \ - do { } while ( 0 ) -/* end of Context handler macros */ - -/* Fatal Error manager macros */ - -/** - * This routine copies _error into a known place -- typically a stack - * location or a register, optionally disables interrupts, and - * halts/stops the CPU. - */ -extern void _CPU_Fatal_halt(uint32_t source, uint32_t error) - RTEMS_NO_RETURN; - -/* end of Fatal Error manager macros */ - -/* Bitfield handler macros */ - -#if ( SPARC_HAS_BITSCAN == 0 ) - /** - * The SPARC port uses the generic C algorithm for bitfield scan if the - * CPU model does not have a scan instruction. - */ - #define CPU_USE_GENERIC_BITFIELD_CODE TRUE -#else - #error "scan instruction not currently supported by RTEMS!!" -#endif - -/* end of Bitfield handler macros */ - -/* functions */ - -/** - * @brief SPARC specific initialization. - * - * This routine performs CPU dependent initialization. - */ -void _CPU_Initialize(void); - -/** - * @brief SPARC specific raw ISR installer. - * - * This routine installs @a new_handler to be directly called from the trap - * table. - * - * @param[in] vector is the vector number - * @param[in] new_handler is the new ISR handler - * @param[in] old_handler will contain the old ISR handler - */ -void _CPU_ISR_install_raw_handler( - uint32_t vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -/** - * @brief SPARC specific RTEMS ISR installer. - * - * This routine installs an interrupt vector. - * - * @param[in] vector is the vector number - * @param[in] new_handler is the new ISR handler - * @param[in] old_handler will contain the old ISR handler - */ - -void _CPU_ISR_install_vector( - uint32_t vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -/** - * @brief SPARC specific context switch. - * - * This routine switches from the run context to the heir context. - * - * @param[in] run is the currently executing thread - * @param[in] heir will become the currently executing thread - */ -void _CPU_Context_switch( - Context_Control *run, - Context_Control *heir -); - -/** - * @brief SPARC specific context restore. - * - * This routine is generally used only to restart self in an - * efficient manner. - * - * @param[in] new_context is the context to restore - */ -void _CPU_Context_restore( - Context_Control *new_context -) RTEMS_NO_RETURN; - -#if defined(RTEMS_SMP) - uint32_t _CPU_SMP_Initialize( void ); - - bool _CPU_SMP_Start_processor( uint32_t cpu_index ); - - void _CPU_SMP_Finalize_initialization( uint32_t cpu_count ); - - void _CPU_SMP_Prepare_start_multitasking( void ); - - #if defined(__leon__) && !defined(RTEMS_PARAVIRT) - static inline uint32_t _CPU_SMP_Get_current_processor( void ) - { - return _LEON3_Get_current_processor(); - } - #else - uint32_t _CPU_SMP_Get_current_processor( void ); - #endif - - void _CPU_SMP_Send_interrupt( uint32_t target_processor_index ); - - static inline void _CPU_SMP_Processor_event_broadcast( void ) - { - __asm__ volatile ( "" : : : "memory" ); - } - - static inline void _CPU_SMP_Processor_event_receive( void ) - { - __asm__ volatile ( "" : : : "memory" ); - } -#endif - -#if defined(SPARC_USE_LAZY_FP_SWITCH) -#define _CPU_Context_Destroy( _the_thread, _the_context ) \ - do { \ - Per_CPU_Control *cpu_self = _Per_CPU_Get(); \ - Thread_Control *_fp_owner = cpu_self->cpu_per_cpu.fp_owner; \ - if ( _fp_owner == _the_thread ) { \ - cpu_self->cpu_per_cpu.fp_owner = NULL; \ - } \ - } while ( 0 ) -#endif - -void _CPU_Context_volatile_clobber( uintptr_t pattern ); - -void _CPU_Context_validate( uintptr_t pattern ); - -typedef struct { - uint32_t trap; - CPU_Interrupt_frame *isf; -} CPU_Exception_frame; - -void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); - -/** - * @brief SPARC specific method to endian swap an uint32_t. - * - * The following routine swaps the endian format of an unsigned int. - * It must be static because it is referenced indirectly. - * - * @param[in] value is the value to endian swap - * - * This version will work on any processor, but if you come across a better - * way for the SPARC PLEASE use it. The most common way to swap a 32-bit - * entity as shown below is not any more efficient on the SPARC. - * - * - swap least significant two bytes with 16-bit rotate - * - swap upper and lower 16-bits - * - swap most significant two bytes with 16-bit rotate - * - * It is not obvious how the SPARC can do significantly better than the - * generic code. gcc 2.7.0 only generates about 12 instructions for the - * following code at optimization level four (i.e. -O4). - */ -static inline uint32_t CPU_swap_u32( - uint32_t value -) -{ - uint32_t byte1, byte2, byte3, byte4, swapped; - - byte4 = (value >> 24) & 0xff; - byte3 = (value >> 16) & 0xff; - byte2 = (value >> 8) & 0xff; - byte1 = value & 0xff; - - swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4; - return( swapped ); -} - -/** - * @brief SPARC specific method to endian swap an uint16_t. - * - * The following routine swaps the endian format of a uint16_t. - * - * @param[in] value is the value to endian swap - */ -#define CPU_swap_u16( value ) \ - (((value&0xff) << 8) | ((value >> 8)&0xff)) - -typedef uint32_t CPU_Counter_ticks; - -typedef CPU_Counter_ticks ( *SPARC_Counter_read )( void ); - -typedef CPU_Counter_ticks ( *SPARC_Counter_difference )( - CPU_Counter_ticks second, - CPU_Counter_ticks first -); - -/* - * The SPARC processors supported by RTEMS have no built-in CPU counter - * support. We have to use some hardware counter module for this purpose, for - * example the GPTIMER instance used by the clock driver. The BSP must provide - * an implementation of the CPU counter read and difference functions. This - * allows the use of dynamic hardware enumeration. - */ -typedef struct { - SPARC_Counter_read counter_read; - SPARC_Counter_difference counter_difference; - volatile const CPU_Counter_ticks *counter_address; -} SPARC_Counter; - -extern const SPARC_Counter _SPARC_Counter; - -static inline CPU_Counter_ticks _CPU_Counter_read( void ) -{ - return ( *_SPARC_Counter.counter_read )(); -} - -static inline CPU_Counter_ticks _CPU_Counter_difference( - CPU_Counter_ticks second, - CPU_Counter_ticks first -) -{ - return ( *_SPARC_Counter.counter_difference )( second, first ); -} - -#endif /* ASM */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/score/cpu/sparc/rtems/score/cpuatomic.h b/cpukit/score/cpu/sparc/rtems/score/cpuatomic.h deleted file mode 100644 index 598ee76b20..0000000000 --- a/cpukit/score/cpu/sparc/rtems/score/cpuatomic.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * COPYRIGHT (c) 2012-2013 Deng Hengyi. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_ATOMIC_CPU_H -#define _RTEMS_SCORE_ATOMIC_CPU_H - -#include - -#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/sparc/rtems/score/cpuimpl.h b/cpukit/score/cpu/sparc/rtems/score/cpuimpl.h deleted file mode 100644 index 4f2311e755..0000000000 --- a/cpukit/score/cpu/sparc/rtems/score/cpuimpl.h +++ /dev/null @@ -1,155 +0,0 @@ -/** - * @file - * - * @brief CPU Port Implementation API - */ - -/* - * Copyright (c) 1989, 2007 On-Line Applications Research Corporation (OAR) - * Copyright (c) 2013, 2016 embedded brains GmbH - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPUIMPL_H -#define _RTEMS_SCORE_CPUIMPL_H - -#include - -/** This defines the size of the minimum stack frame. */ -#define SPARC_MINIMUM_STACK_FRAME_SIZE 0x60 - -/* - * Offsets of fields with CPU_Interrupt_frame for assembly routines. - */ - -/** This macro defines an offset into the ISF for use in assembly. */ -#define ISF_PSR_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x00 -/** This macro defines an offset into the ISF for use in assembly. */ -#define ISF_PC_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x04 -/** This macro defines an offset into the ISF for use in assembly. */ -#define ISF_NPC_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x08 -/** This macro defines an offset into the ISF for use in assembly. */ -#define ISF_G1_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x0c -/** This macro defines an offset into the ISF for use in assembly. */ -#define ISF_G2_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x10 -/** This macro defines an offset into the ISF for use in assembly. */ -#define ISF_G3_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x14 -/** This macro defines an offset into the ISF for use in assembly. */ -#define ISF_G4_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x18 -/** This macro defines an offset into the ISF for use in assembly. */ -#define ISF_G5_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x1c -/** This macro defines an offset into the ISF for use in assembly. */ -#define ISF_G7_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x24 -/** This macro defines an offset into the ISF for use in assembly. */ -#define ISF_I0_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x28 -/** This macro defines an offset into the ISF for use in assembly. */ -#define ISF_I1_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x2c -/** This macro defines an offset into the ISF for use in assembly. */ -#define ISF_I2_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x30 -/** This macro defines an offset into the ISF for use in assembly. */ -#define ISF_I3_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x34 -/** This macro defines an offset into the ISF for use in assembly. */ -#define ISF_I4_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x38 -/** This macro defines an offset into the ISF for use in assembly. */ -#define ISF_I5_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x3c -/** This macro defines an offset into the ISF for use in assembly. */ -#define ISF_I6_FP_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x40 -/** This macro defines an offset into the ISF for use in assembly. */ -#define ISF_I7_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x44 -/** This macro defines an offset into the ISF for use in assembly. */ -#define ISF_Y_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x48 -/** This macro defines an offset into the ISF for use in assembly. */ -#define ISF_TPC_OFFSET SPARC_MINIMUM_STACK_FRAME_SIZE + 0x4c - -/** This defines the size of the ISF area for use in assembly. */ -#define CPU_INTERRUPT_FRAME_SIZE SPARC_MINIMUM_STACK_FRAME_SIZE + 0x50 - -#define SPARC_FP_CONTEXT_OFFSET_F0_F1 0 -#define SPARC_FP_CONTEXT_OFFSET_F2_F3 8 -#define SPARC_FP_CONTEXT_OFFSET_F4_F5 16 -#define SPARC_FP_CONTEXT_OFFSET_F6_F7 24 -#define SPARC_FP_CONTEXT_OFFSET_F8_F9 32 -#define SPARC_FP_CONTEXT_OFFSET_F10_F11 40 -#define SPARC_FP_CONTEXT_OFFSET_F12_F13 48 -#define SPARC_FP_CONTEXT_OFFSET_F14_F15 56 -#define SPARC_FP_CONTEXT_OFFSET_F16_F17 64 -#define SPARC_FP_CONTEXT_OFFSET_F18_F19 72 -#define SPARC_FP_CONTEXT_OFFSET_F20_F21 80 -#define SPARC_FP_CONTEXT_OFFSET_F22_F23 88 -#define SPARC_FP_CONTEXT_OFFSET_F24_F25 96 -#define SPARC_FP_CONTEXT_OFFSET_F26_F27 104 -#define SPARC_FP_CONTEXT_OFFSET_F28_F29 112 -#define SPARC_FP_CONTEXT_OFFSET_F30_F31 120 -#define SPARC_FP_CONTEXT_OFFSET_FSR 128 - -#if ( SPARC_HAS_FPU == 1 ) - #define CPU_PER_CPU_CONTROL_SIZE 8 -#else - #define CPU_PER_CPU_CONTROL_SIZE 0 -#endif - -#if ( SPARC_HAS_FPU == 1 ) - /** - * @brief Offset of the CPU_Per_CPU_control::fsr field relative to the - * Per_CPU_Control begin. - */ - #define SPARC_PER_CPU_FSR_OFFSET 0 - - #if defined(SPARC_USE_LAZY_FP_SWITCH) - /** - * @brief Offset of the CPU_Per_CPU_control::fp_owner field relative to the - * Per_CPU_Control begin. - */ - #define SPARC_PER_CPU_FP_OWNER_OFFSET 4 - #endif -#endif - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { -#if ( SPARC_HAS_FPU == 1 ) - /** - * @brief Memory location to store the FSR register during interrupt - * processing. - * - * This is a write-only field. The FSR is written to force a completion of - * floating point operations in progress. - */ - uint32_t fsr; - -#if defined(SPARC_USE_LAZY_FP_SWITCH) - /** - * @brief The current floating point owner. - */ - struct _Thread_Control *fp_owner; -#else - /* See Per_CPU_Control::Interrupt_frame */ - uint32_t reserved_for_alignment_of_interrupt_frame; -#endif -#endif -} CPU_Per_CPU_control; - -/** - * @brief The pointer to the current per-CPU control is available via register - * g6. - */ -register struct Per_CPU_Control *_SPARC_Per_CPU_current __asm__( "g6" ); - -#define _CPU_Get_current_per_CPU_control() _SPARC_Per_CPU_current - -#define _CPU_Get_thread_executing() ( _SPARC_Per_CPU_current->executing ) - -#ifdef __cplusplus -} -#endif - -#endif /* ASM */ - -#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/sparc/rtems/score/sparc.h b/cpukit/score/cpu/sparc/rtems/score/sparc.h deleted file mode 100644 index 747d013559..0000000000 --- a/cpukit/score/cpu/sparc/rtems/score/sparc.h +++ /dev/null @@ -1,418 +0,0 @@ -/** - * @file - * - * @brief Information Required to Build RTEMS for a Particular Member - * of the SPARC Family - * - * This file contains the information required to build - * RTEMS for a particular member of the SPARC family. It does - * this by setting variables to indicate which implementation - * dependent features are present in a particular member - * of the family. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SPARC_H -#define _RTEMS_SCORE_SPARC_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * - * Currently recognized feature flags: - * - * + SPARC_HAS_FPU - * 0 - no HW FPU - * 1 - has HW FPU (assumed to be compatible w/90C602) - * - * + SPARC_HAS_BITSCAN - * 0 - does not have scan instructions - * 1 - has scan instruction (not currently implemented) - * - * + SPARC_NUMBER_OF_REGISTER_WINDOWS - * 8 is the most common number supported by SPARC implementations. - * SPARC_PSR_CWP_MASK is derived from this value. - */ - -/** - * Some higher end SPARCs have a bitscan instructions. It would - * be nice to take advantage of them. Right now, there is no - * port to a CPU model with this feature and no (untested) code - * that is based on this feature flag. - */ -#define SPARC_HAS_BITSCAN 0 - -/** - * This should be OK until a port to a higher end SPARC processor - * is made that has more than 8 register windows. If this cannot - * be determined based on multilib settings (v7/v8/v9), then the - * cpu_asm.S code that depends on this will have to move to libcpu. - */ -#define SPARC_NUMBER_OF_REGISTER_WINDOWS 8 - -/** - * See GRLIB-TN-0009: "LEON3FT Stale Cache Entry After Store with - * Data Tag Parity Error" - */ -#if defined(__FIX_LEON3FT_B2BST) - #define SPARC_LEON3FT_B2BST_NOP nop -#else - #define SPARC_LEON3FT_B2BST_NOP -#endif - -/** - * This macro indicates whether this multilib variation has hardware - * floating point or not. We use the gcc cpp predefine _SOFT_FLOAT - * to determine that. - */ -#if defined(_SOFT_FLOAT) - #define SPARC_HAS_FPU 0 -#else - #define SPARC_HAS_FPU 1 -#endif - -/** - * This macro contains a string describing the multilib variant being - * build. - */ -#if SPARC_HAS_FPU - #define CPU_MODEL_NAME "w/FPU" -#else - #define CPU_MODEL_NAME "w/soft-float" -#endif - -/** - * Define the name of the CPU family. - */ -#define CPU_NAME "SPARC" - -/* - * Miscellaneous constants - */ - -/** - * PSR masks and starting bit positions - * - * NOTE: Reserved bits are ignored. - */ -#if (SPARC_NUMBER_OF_REGISTER_WINDOWS == 8) - #define SPARC_PSR_CWP_MASK 0x07 /* bits 0 - 4 */ -#elif (SPARC_NUMBER_OF_REGISTER_WINDOWS == 16) - #define SPARC_PSR_CWP_MASK 0x0F /* bits 0 - 4 */ -#elif (SPARC_NUMBER_OF_REGISTER_WINDOWS == 32) - #define SPARC_PSR_CWP_MASK 0x1F /* bits 0 - 4 */ -#else - #error "Unsupported number of register windows for this cpu" -#endif - -/** This constant is a mask for the ET bits in the PSR. */ -#define SPARC_PSR_ET_MASK 0x00000020 /* bit 5 */ -/** This constant is a mask for the PS bits in the PSR. */ -#define SPARC_PSR_PS_MASK 0x00000040 /* bit 6 */ -/** This constant is a mask for the S bits in the PSR. */ -#define SPARC_PSR_S_MASK 0x00000080 /* bit 7 */ -/** This constant is a mask for the PIL bits in the PSR. */ -#define SPARC_PSR_PIL_MASK 0x00000F00 /* bits 8 - 11 */ -/** This constant is a mask for the EF bits in the PSR. */ -#define SPARC_PSR_EF_MASK 0x00001000 /* bit 12 */ -/** This constant is a mask for the EC bits in the PSR. */ -#define SPARC_PSR_EC_MASK 0x00002000 /* bit 13 */ -/** This constant is a mask for the ICC bits in the PSR. */ -#define SPARC_PSR_ICC_MASK 0x00F00000 /* bits 20 - 23 */ -/** This constant is a mask for the VER bits in the PSR. */ -#define SPARC_PSR_VER_MASK 0x0F000000 /* bits 24 - 27 */ -/** This constant is a mask for the IMPL bits in the PSR. */ -#define SPARC_PSR_IMPL_MASK 0xF0000000 /* bits 28 - 31 */ - -/** This constant is the starting bit position of the CWP in the PSR. */ -#define SPARC_PSR_CWP_BIT_POSITION 0 /* bits 0 - 4 */ -/** This constant is the starting bit position of the ET in the PSR. */ -#define SPARC_PSR_ET_BIT_POSITION 5 /* bit 5 */ -/** This constant is the starting bit position of the PS in the PSR. */ -#define SPARC_PSR_PS_BIT_POSITION 6 /* bit 6 */ -/** This constant is the starting bit position of the S in the PSR. */ -#define SPARC_PSR_S_BIT_POSITION 7 /* bit 7 */ -/** This constant is the starting bit position of the PIL in the PSR. */ -#define SPARC_PSR_PIL_BIT_POSITION 8 /* bits 8 - 11 */ -/** This constant is the starting bit position of the EF in the PSR. */ -#define SPARC_PSR_EF_BIT_POSITION 12 /* bit 12 */ -/** This constant is the starting bit position of the EC in the PSR. */ -#define SPARC_PSR_EC_BIT_POSITION 13 /* bit 13 */ -/** This constant is the starting bit position of the ICC in the PSR. */ -#define SPARC_PSR_ICC_BIT_POSITION 20 /* bits 20 - 23 */ -/** This constant is the starting bit position of the VER in the PSR. */ -#define SPARC_PSR_VER_BIT_POSITION 24 /* bits 24 - 27 */ -/** This constant is the starting bit position of the IMPL in the PSR. */ -#define SPARC_PSR_IMPL_BIT_POSITION 28 /* bits 28 - 31 */ - -#define LEON3_ASR17_PROCESSOR_INDEX_SHIFT 28 - -/* SPARC Software Trap number definitions */ -#define SPARC_SWTRAP_SYSCALL 0 -#define SPARC_SWTRAP_IRQDIS 9 -#define SPARC_SWTRAP_IRQEN 10 -#if SPARC_HAS_FPU == 1 -#define SPARC_SWTRAP_IRQDIS_FP 11 -#endif - -#ifndef ASM - -/** - * This macro is a standard nop instruction. - */ -#define nop() \ - do { \ - __asm__ volatile ( "nop" ); \ - } while ( 0 ) - -/** - * @brief Macro to obtain the PSR. - * - * This macro returns the current contents of the PSR register in @a _psr. - */ -#if defined(RTEMS_PARAVIRT) - -uint32_t _SPARC_Get_PSR( void ); - -#define sparc_get_psr( _psr ) \ - (_psr) = _SPARC_Get_PSR() - -#else /* RTEMS_PARAVIRT */ - -#define sparc_get_psr( _psr ) \ - do { \ - (_psr) = 0; \ - __asm__ volatile( "rd %%psr, %0" : "=r" (_psr) : "0" (_psr) ); \ - } while ( 0 ) - -#endif /* RTEMS_PARAVIRT */ - -/** - * @brief Macro to set the PSR. - * - * This macro sets the PSR register to the value in @a _psr. - */ -#if defined(RTEMS_PARAVIRT) - -void _SPARC_Set_PSR( uint32_t new_psr ); - -#define sparc_set_psr( _psr ) \ - _SPARC_Set_PSR( _psr ) - -#else /* RTEMS_PARAVIRT */ - -#define sparc_set_psr( _psr ) \ - do { \ - __asm__ volatile ( "mov %0, %%psr " : "=r" ((_psr)) : "0" ((_psr)) ); \ - nop(); \ - nop(); \ - nop(); \ - } while ( 0 ) - -#endif /* RTEMS_PARAVIRT */ - -/** - * @brief Macro to obtain the TBR. - * - * This macro returns the current contents of the TBR register in @a _tbr. - */ -#if defined(RTEMS_PARAVIRT) - -uint32_t _SPARC_Get_TBR( void ); - -#define sparc_get_tbr( _tbr ) \ - (_tbr) = _SPARC_Get_TBR() - -#else /* RTEMS_PARAVIRT */ - -#define sparc_get_tbr( _tbr ) \ - do { \ - (_tbr) = 0; /* to avoid unitialized warnings */ \ - __asm__ volatile( "rd %%tbr, %0" : "=r" (_tbr) : "0" (_tbr) ); \ - } while ( 0 ) - -#endif /* RTEMS_PARAVIRT */ - -/** - * @brief Macro to set the TBR. - * - * This macro sets the TBR register to the value in @a _tbr. - */ -#if defined(RTEMS_PARAVIRT) - -void _SPARC_Set_TBR( uint32_t new_tbr ); - -#define sparc_set_tbr( _tbr ) \ - _SPARC_Set_TBR((_tbr)) - -#else /* RTEMS_PARAVIRT */ - -#define sparc_set_tbr( _tbr ) \ - do { \ - __asm__ volatile( "wr %0, 0, %%tbr" : "=r" (_tbr) : "0" (_tbr) ); \ - } while ( 0 ) - -#endif /* RTEMS_PARAVIRT */ - -/** - * @brief Macro to obtain the WIM. - * - * This macro returns the current contents of the WIM field in @a _wim. - */ -#define sparc_get_wim( _wim ) \ - do { \ - __asm__ volatile( "rd %%wim, %0" : "=r" (_wim) : "0" (_wim) ); \ - } while ( 0 ) - -/** - * @brief Macro to set the WIM. - * - * This macro sets the WIM field to the value in @a _wim. - */ -#define sparc_set_wim( _wim ) \ - do { \ - __asm__ volatile( "wr %0, %%wim" : "=r" (_wim) : "0" (_wim) ); \ - nop(); \ - nop(); \ - nop(); \ - } while ( 0 ) - -/** - * @brief Macro to obtain the Y register. - * - * This macro returns the current contents of the Y register in @a _y. - */ -#define sparc_get_y( _y ) \ - do { \ - __asm__ volatile( "rd %%y, %0" : "=r" (_y) : "0" (_y) ); \ - } while ( 0 ) - -/** - * @brief Macro to set the Y register. - * - * This macro sets the Y register to the value in @a _y. - */ -#define sparc_set_y( _y ) \ - do { \ - __asm__ volatile( "wr %0, %%y" : "=r" (_y) : "0" (_y) ); \ - } while ( 0 ) - -/** - * @brief SPARC disable processor interrupts. - * - * This method is invoked to disable all maskable interrupts. - * - * @return This method returns the entire PSR contents. - */ -static inline uint32_t sparc_disable_interrupts(void) -{ - register uint32_t psr __asm__("g1"); /* return value of trap handler */ - __asm__ volatile ( "ta %1\n\t" : "=r" (psr) : "i" (SPARC_SWTRAP_IRQDIS)); - return psr; -} - -/** - * @brief SPARC enable processor interrupts. - * - * This method is invoked to enable all maskable interrupts. - * - * @param[in] psr is the PSR returned by @ref sparc_disable_interrupts. - */ -static inline void sparc_enable_interrupts(uint32_t psr) -{ - register uint32_t _psr __asm__("g1") = psr; /* input to trap handler */ - - /* - * The trap instruction has a higher trap priority than the interrupts - * according to "The SPARC Architecture Manual: Version 8", Table 7-1 - * "Exception and Interrupt Request Priority and tt Values". Add a nop to - * prevent a trap instruction right after the interrupt enable trap. - */ - __asm__ volatile ( "ta %0\nnop\n" :: "i" (SPARC_SWTRAP_IRQEN), "r" (_psr)); -} - -/** - * @brief SPARC exit through system call 1 - * - * This method is invoked to go into system error halt. The optional - * arguments can be given to hypervisor, hardware debugger, simulator or - * similar. - * - * System error mode is entered when taking a trap when traps have been - * disabled. What happens when error mode is entered depends on the motherboard. - * In a typical development systems the CPU relingish control to the debugger, - * simulator, hypervisor or similar. The following steps are taken: - * - * 1. Going into system error mode by Software Trap 0 - * 2. %g1=1 (syscall 1 - Exit) - * 3. %g2=Primary exit code - * 4. %g3=Secondary exit code. Dependends on %g2 exit type. - * - * This function never returns. - * - * @param[in] exitcode1 Primary exit code stored in CPU g2 register after exit - * @param[in] exitcode2 Primary exit code stored in CPU g3 register after exit - */ -void sparc_syscall_exit(uint32_t exitcode1, uint32_t exitcode2) - RTEMS_NO_RETURN; - -/** - * @brief SPARC flash processor interrupts. - * - * This method is invoked to temporarily enable all maskable interrupts. - * - * @param[in] _psr is the PSR returned by @ref sparc_disable_interrupts. - */ -#define sparc_flash_interrupts( _psr ) \ - do { \ - sparc_enable_interrupts( (_psr) ); \ - _psr = sparc_disable_interrupts(); \ - } while ( 0 ) - -/** - * @brief SPARC obtain interrupt level. - * - * This method is invoked to obtain the current interrupt disable level. - * - * @param[in] _level is the PSR returned by @ref sparc_disable_interrupts. - */ -#define sparc_get_interrupt_level( _level ) \ - do { \ - register uint32_t _psr_level = 0; \ - \ - sparc_get_psr( _psr_level ); \ - (_level) = \ - (_psr_level & SPARC_PSR_PIL_MASK) >> SPARC_PSR_PIL_BIT_POSITION; \ - } while ( 0 ) - -static inline uint32_t _LEON3_Get_current_processor( void ) -{ - uint32_t asr17; - - __asm__ volatile ( - "rd %%asr17, %0" - : "=&r" (asr17) - ); - - return asr17 >> LEON3_ASR17_PROCESSOR_INDEX_SHIFT; -} - -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _RTEMS_SCORE_SPARC_H */ diff --git a/cpukit/score/cpu/sparc/rtems/score/sparcimpl.h b/cpukit/score/cpu/sparc/rtems/score/sparcimpl.h deleted file mode 100644 index 9f9999b063..0000000000 --- a/cpukit/score/cpu/sparc/rtems/score/sparcimpl.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2016 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SPARCIMPL_H -#define _RTEMS_SCORE_SPARCIMPL_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * Provides a mutable alias to _SPARC_Counter for use in - * _SPARC_Counter_initialize(). The _SPARC_Counter and _SPARC_Counter_mutable - * are defined via the SPARC_COUNTER_DEFINITION define. - */ -extern SPARC_Counter _SPARC_Counter_mutable; - -CPU_Counter_ticks _SPARC_Counter_read_address( void ); - -CPU_Counter_ticks _SPARC_Counter_read_asr23( void ); - -CPU_Counter_ticks _SPARC_Counter_difference_normal( - CPU_Counter_ticks second, - CPU_Counter_ticks first -); - -CPU_Counter_ticks _SPARC_Counter_difference_clock_period( - CPU_Counter_ticks second, - CPU_Counter_ticks first -); - -/* - * Returns always a value of one regardless of the parameters. This prevents - * an infinite loop in rtems_counter_delay_ticks(). Its only a reasonably safe - * default. - */ -CPU_Counter_ticks _SPARC_Counter_difference_one( - CPU_Counter_ticks second, - CPU_Counter_ticks first -); - -static inline void _SPARC_Counter_initialize( - SPARC_Counter_read counter_read, - SPARC_Counter_difference counter_difference, - volatile const CPU_Counter_ticks *counter_address -) -{ - _SPARC_Counter_mutable.counter_read = counter_read; - _SPARC_Counter_mutable.counter_difference = counter_difference; - _SPARC_Counter_mutable.counter_address = counter_address; -} - -/* - * Defines the _SPARC_Counter and _SPARC_Counter_mutable global variables. - * Place this define in the global file scope of the CPU counter support file - * of the BSP. - */ -#define SPARC_COUNTER_DEFINITION \ - __asm__ ( \ - "\t.global\t_SPARC_Counter\n" \ - "\t.global\t_SPARC_Counter_mutable\n" \ - "\t.section\t.data._SPARC_Counter,\"aw\",@progbits\n" \ - "\t.align\t4\n" \ - "\t.type\t_SPARC_Counter, #object\n" \ - "\t.size\t_SPARC_Counter, 12\n" \ - "_SPARC_Counter:\n" \ - "_SPARC_Counter_mutable:\n" \ - "\t.long\t_SPARC_Counter_read_address\n" \ - "\t.long\t_SPARC_Counter_difference_one\n" \ - "\t.long\t_SPARC_Counter\n" \ - ) - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_SCORE_SPARCIMPL_H */ diff --git a/cpukit/score/cpu/sparc/rtems/score/types.h b/cpukit/score/cpu/sparc/rtems/score/types.h deleted file mode 100644 index 6419c9f15f..0000000000 --- a/cpukit/score/cpu/sparc/rtems/score/types.h +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @file - * - * @brief SPARC CPU Type Definitions - * - * This include file contains type definitions pertaining to the - * SPARC processor family. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_TYPES_H -#define _RTEMS_SCORE_TYPES_H - -#include - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -/** Type that can store a 32-bit integer or a pointer. */ -typedef uintptr_t CPU_Uint32ptr; - -/** - * @brief SPARC ISR handler return type. - * - * This is the type which SPARC ISR Handlers return. - */ -typedef void sparc_isr; - -/** - * @brief SPARC ISR handler prototype. - * - * This is the prototype for SPARC ISR Handlers. - */ -typedef void ( *sparc_isr_entry )( void ); - -#ifdef __cplusplus -} -#endif - -#endif /* !ASM */ - -#endif diff --git a/cpukit/score/cpu/sparc64/Makefile.am b/cpukit/score/cpu/sparc64/Makefile.am index 491c197b81..2afd3edead 100644 --- a/cpukit/score/cpu/sparc64/Makefile.am +++ b/cpukit/score/cpu/sparc64/Makefile.am @@ -1,23 +1,13 @@ include $(top_srcdir)/automake/compile.am -include_rtemsdir = $(includedir)/rtems -include_rtems_HEADERS = rtems/asm.h - #include_rtems_sparc64dir = $(includedir)/rtems/sparc64 #include_rtems_sparc64_HEADERS = -include_rtems_scoredir = $(includedir)/rtems/score -include_rtems_score_HEADERS = rtems/score/sparc64.h -include_rtems_score_HEADERS += rtems/score/cpu.h -include_rtems_score_HEADERS += rtems/score/cpuimpl.h -include_rtems_score_HEADERS += rtems/score/types.h -include_rtems_score_HEADERS += rtems/score/cpuatomic.h - noinst_LIBRARIES = libscorecpu.a libscorecpu_a_SOURCES = context.S cpu.c libscorecpu_a_SOURCES += ../no_cpu/cpucounterread.c libscorecpu_a_SOURCES += sparc64-exception-frame-print.c libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS) -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am +include $(srcdir)/headers.am diff --git a/cpukit/score/cpu/sparc64/headers.am b/cpukit/score/cpu/sparc64/headers.am new file mode 100644 index 0000000000..9b54d09ece --- /dev/null +++ b/cpukit/score/cpu/sparc64/headers.am @@ -0,0 +1,13 @@ +## This file was generated by "./boostrap -H". + +include_rtemsdir = $(includedir)/rtems +include_rtems_HEADERS = +include_rtems_HEADERS += include/rtems/asm.h + +include_rtems_scoredir = $(includedir)/rtems/score +include_rtems_score_HEADERS = +include_rtems_score_HEADERS += include/rtems/score/cpu.h +include_rtems_score_HEADERS += include/rtems/score/cpuatomic.h +include_rtems_score_HEADERS += include/rtems/score/cpuimpl.h +include_rtems_score_HEADERS += include/rtems/score/sparc64.h +include_rtems_score_HEADERS += include/rtems/score/types.h diff --git a/cpukit/score/cpu/sparc64/include/rtems/asm.h b/cpukit/score/cpu/sparc64/include/rtems/asm.h new file mode 100644 index 0000000000..f4448b03a5 --- /dev/null +++ b/cpukit/score/cpu/sparc64/include/rtems/asm.h @@ -0,0 +1,103 @@ +/** + * @file + * + * @brief Address the Problems Caused by Incompatible Flavor of + * Assemblers and Toolsets + * + * This include file attempts to address the problems + * caused by incompatible flavors of assemblers and + * toolsets. It primarily addresses variations in the + * use of leading underscores on symbols and the requirement + * that register names be preceded by a %. + * + * NOTE: The spacing in the use of these macros + * is critical to them working as advertised. + */ + +/* + * COPYRIGHT: + * + * This file is based on similar code found in newlib available + * from ftp.cygnus.com. The file which was used had no copyright + * notice. This file is freely distributable as long as the source + * of the file is noted. + */ + +#ifndef _RTEMS_ASM_H +#define _RTEMS_ASM_H + +/* + * Indicate we are in an assembly file and get the basic CPU definitions. + */ + +#ifndef ASM +#define ASM +#endif +#ifndef __ASM__ +#define __ASM__ +#endif + +#include +#include + +/* + * Recent versions of GNU cpp define variables which indicate the + * need for underscores and percents. If not using GNU cpp or + * the version does not support this, then you will obviously + * have to define these as appropriate. + */ + +/* XXX __USER_LABEL_PREFIX__ and __REGISTER_PREFIX__ do not work on gcc 2.7.0 */ +/* XXX The following ifdef magic fixes the problem but results in a warning */ +/* XXX when compiling assembly code. */ + +#ifndef __USER_LABEL_PREFIX__ +#define __USER_LABEL_PREFIX__ _ +#endif + +#ifndef __REGISTER_PREFIX__ +#define __REGISTER_PREFIX__ +#endif + +#include + +/* Use the right prefix for global labels. */ + +#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) + +/* Use the right prefix for registers. */ + +#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) + +/* + * define macros for all of the registers on this CPU + * + * EXAMPLE: #define d0 REG (d0) + */ + +/* + * Define macros to handle section beginning and ends. + */ + + +#define BEGIN_CODE_DCL .text +#define END_CODE_DCL +#define BEGIN_DATA_DCL .data +#define END_DATA_DCL +#define BEGIN_CODE .text +#define END_CODE +#define BEGIN_DATA +#define END_DATA +#define BEGIN_BSS +#define END_BSS +#define END + +/* + * Following must be tailor for a particular flavor of the C compiler. + * They may need to put underscores in front of the symbols. + */ + +#define PUBLIC(sym) .globl SYM (sym) +#define EXTERN(sym) .globl SYM (sym) + +#endif diff --git a/cpukit/score/cpu/sparc64/include/rtems/score/cpu.h b/cpukit/score/cpu/sparc64/include/rtems/score/cpu.h new file mode 100644 index 0000000000..47041e7d5e --- /dev/null +++ b/cpukit/score/cpu/sparc64/include/rtems/score/cpu.h @@ -0,0 +1,1051 @@ +/** + * @file + * + * @brief SPARC64 CPU Department Source + * + * This include file contains information pertaining to the port of + * the executive to the SPARC64 processor. + */ + +/* + * + * + * COPYRIGHT (c) 1989-2006. On-Line Applications Research Corporation (OAR). + * + * This file is based on the SPARC cpu.h file. Modifications are made + * to support the SPARC64 processor. + * COPYRIGHT (c) 2010. Gedare Bloom. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPU_H +#define _RTEMS_SCORE_CPU_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* conditional compilation parameters */ + +/* + * Does the executive manage a dedicated interrupt stack in software? + * + * If TRUE, then a stack is allocated in _ISR_Handler_initialization. + * If FALSE, nothing is done. + * + * The SPARC does not have a dedicated HW interrupt stack and one has + * been implemented in SW. + */ + +#define CPU_HAS_SOFTWARE_INTERRUPT_STACK TRUE + +/* + * Does the CPU follow the simple vectored interrupt model? + * + * If TRUE, then RTEMS allocates the vector table it internally manages. + * If FALSE, then the BSP is assumed to allocate and manage the vector + * table + * + * SPARC Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_SIMPLE_VECTORED_INTERRUPTS TRUE + +/* + * Does this CPU have hardware support for a dedicated interrupt stack? + * + * If TRUE, then it must be installed during initialization. + * If FALSE, then no installation is performed. + * + * The SPARC does not have a dedicated HW interrupt stack. + */ + +#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE + +/* + * Do we allocate a dedicated interrupt stack in the Interrupt Manager? + * + * If TRUE, then the memory is allocated during initialization. + * If FALSE, then the memory is allocated during initialization. + */ + +#define CPU_ALLOCATE_INTERRUPT_STACK TRUE + +/* + * Does the RTEMS invoke the user's ISR with the vector number and + * a pointer to the saved interrupt frame (1) or just the vector + * number (0)? + */ + +#define CPU_ISR_PASSES_FRAME_POINTER FALSE + +/* + * Does the CPU have hardware floating point? + * + * If TRUE, then the FLOATING_POINT task attribute is supported. + * If FALSE, then the FLOATING_POINT task attribute is ignored. + */ + +#if ( SPARC_HAS_FPU == 1 ) +#define CPU_HARDWARE_FP TRUE +#else +#define CPU_HARDWARE_FP FALSE +#endif +#define CPU_SOFTWARE_FP FALSE + +/* + * Are all tasks FLOATING_POINT tasks implicitly? + * + * If TRUE, then the FLOATING_POINT task attribute is assumed. + * If FALSE, then the FLOATING_POINT task attribute is followed. + */ + +#define CPU_ALL_TASKS_ARE_FP FALSE + +/* + * Should the IDLE task have a floating point context? + * + * If TRUE, then the IDLE task is created as a FLOATING_POINT task + * and it has a floating point context which is switched in and out. + * If FALSE, then the IDLE task does not have a floating point context. + */ + +#define CPU_IDLE_TASK_IS_FP FALSE + +/* + * Should the saving of the floating point registers be deferred + * until a context switch is made to another different floating point + * task? + * + * If TRUE, then the floating point context will not be stored until + * necessary. It will remain in the floating point registers and not + * disturned until another floating point task is switched to. + * + * If FALSE, then the floating point context is saved when a floating + * point task is switched out and restored when the next floating point + * task is restored. The state of the floating point registers between + * those two operations is not specified. + */ + +#define CPU_USE_DEFERRED_FP_SWITCH TRUE + +#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE + +/* + * Does this port provide a CPU dependent IDLE task implementation? + * + * If TRUE, then the routine _CPU_Thread_Idle_body + * must be provided and is the default IDLE thread body instead of + * _CPU_Thread_Idle_body. + * + * If FALSE, then use the generic IDLE thread body if the BSP does + * not provide one. + */ + +#define CPU_PROVIDES_IDLE_THREAD_BODY FALSE + +/* + * Does the stack grow up (toward higher addresses) or down + * (toward lower addresses)? + * + * If TRUE, then the grows upward. + * If FALSE, then the grows toward smaller addresses. + * + * The stack grows to lower addresses on the SPARC. + */ + +#define CPU_STACK_GROWS_UP FALSE + +/* FIXME: Is this the right value? */ +#define CPU_CACHE_LINE_BYTES 32 + +/* + * The following is the variable attribute used to force alignment + * of critical data structures. On some processors it may make + * sense to have these aligned on tighter boundaries than + * the minimum requirements of the compiler in order to have as + * much of the critical data area as possible in a cache line. + * + * The SPARC does not appear to have particularly strict alignment + * requirements. This value (16) was chosen to take advantages of caches. + * + * SPARC 64 requirements on floating point alignment is at least 8, + * and is 16 if quad-word fp instructions are available (e.g. LDQF). + */ + +#define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( 16 ) + +/* + * The following defines the number of bits actually used in the + * interrupt field of the task mode. How those bits map to the + * CPU interrupt levels is defined by the routine _CPU_ISR_Set_level(). + * + * The SPARC v9 has 16 interrupt levels in the PIL field of the PSR. + */ + +#define CPU_MODES_INTERRUPT_MASK 0x0000000F + +#define CPU_MAXIMUM_PROCESSORS 32 + +/* + * This structure represents the organization of the minimum stack frame + * for the SPARC. More framing information is required in certain situaions + * such as when there are a large number of out parameters or when the callee + * must save floating point registers. + */ + +#ifndef ASM + +typedef struct { + uint64_t l0; + uint64_t l1; + uint64_t l2; + uint64_t l3; + uint64_t l4; + uint64_t l5; + uint64_t l6; + uint64_t l7; + uint64_t i0; + uint64_t i1; + uint64_t i2; + uint64_t i3; + uint64_t i4; + uint64_t i5; + uint64_t i6_fp; + uint64_t i7; + void *structure_return_address; + /* + * The following are for the callee to save the register arguments in + * should this be necessary. + */ + uint64_t saved_arg0; + uint64_t saved_arg1; + uint64_t saved_arg2; + uint64_t saved_arg3; + uint64_t saved_arg4; + uint64_t saved_arg5; + uint64_t pad0; +} SPARC64_Minimum_stack_frame; + +#endif /* !ASM */ + +#define CPU_STACK_FRAME_L0_OFFSET 0x00 +#define CPU_STACK_FRAME_L1_OFFSET 0x08 +#define CPU_STACK_FRAME_L2_OFFSET 0x10 +#define CPU_STACK_FRAME_L3_OFFSET 0x18 +#define CPU_STACK_FRAME_L4_OFFSET 0x20 +#define CPU_STACK_FRAME_L5_OFFSET 0x28 +#define CPU_STACK_FRAME_L6_OFFSET 0x30 +#define CPU_STACK_FRAME_L7_OFFSET 0x38 +#define CPU_STACK_FRAME_I0_OFFSET 0x40 +#define CPU_STACK_FRAME_I1_OFFSET 0x48 +#define CPU_STACK_FRAME_I2_OFFSET 0x50 +#define CPU_STACK_FRAME_I3_OFFSET 0x58 +#define CPU_STACK_FRAME_I4_OFFSET 0x60 +#define CPU_STACK_FRAME_I5_OFFSET 0x68 +#define CPU_STACK_FRAME_I6_FP_OFFSET 0x70 +#define CPU_STACK_FRAME_I7_OFFSET 0x78 +#define CPU_STRUCTURE_RETURN_ADDRESS_OFFSET 0x80 +#define CPU_STACK_FRAME_SAVED_ARG0_OFFSET 0x88 +#define CPU_STACK_FRAME_SAVED_ARG1_OFFSET 0x90 +#define CPU_STACK_FRAME_SAVED_ARG2_OFFSET 0x98 +#define CPU_STACK_FRAME_SAVED_ARG3_OFFSET 0xA0 +#define CPU_STACK_FRAME_SAVED_ARG4_OFFSET 0xA8 +#define CPU_STACK_FRAME_SAVED_ARG5_OFFSET 0xB0 +#define CPU_STACK_FRAME_PAD0_OFFSET 0xB8 + +#define SPARC64_MINIMUM_STACK_FRAME_SIZE 0xC0 + +/* + * Contexts + * + * Generally there are 2 types of context to save. + * 1. Interrupt registers to save + * 2. Task level registers to save + * + * This means we have the following 3 context items: + * 1. task level context stuff:: Context_Control + * 2. floating point task stuff:: Context_Control_fp + * 3. special interrupt level context :: Context_Control_interrupt + * + * On the SPARC, we are relatively conservative in that we save most + * of the CPU state in the context area. The ET (enable trap) bit and + * the CWP (current window pointer) fields of the PSR are considered + * system wide resources and are not maintained on a per-thread basis. + */ + +#ifndef ASM + +typedef struct { + uint64_t g1; + uint64_t g2; + uint64_t g3; + uint64_t g4; + uint64_t g5; + uint64_t g6; + uint64_t g7; + + uint64_t l0; + uint64_t l1; + uint64_t l2; + uint64_t l3; + uint64_t l4; + uint64_t l5; + uint64_t l6; + uint64_t l7; + + uint64_t i0; + uint64_t i1; + uint64_t i2; + uint64_t i3; + uint64_t i4; + uint64_t i5; + uint64_t i6_fp; + uint64_t i7; + + uint64_t o0; + uint64_t o1; + uint64_t o2; + uint64_t o3; + uint64_t o4; + uint64_t o5; + uint64_t o6_sp; + uint64_t o7; + + uint32_t isr_dispatch_disable; + uint32_t pad; +} Context_Control; + +#define _CPU_Context_Get_SP( _context ) \ + (_context)->o6_sp + +#endif /* ASM */ + +/* + * Offsets of fields with Context_Control for assembly routines. + */ + +#define G1_OFFSET 0x00 +#define G2_OFFSET 0x08 +#define G3_OFFSET 0x10 +#define G4_OFFSET 0x18 +#define G5_OFFSET 0x20 +#define G6_OFFSET 0x28 +#define G7_OFFSET 0x30 + +#define L0_OFFSET 0x38 +#define L1_OFFSET 0x40 +#define L2_OFFSET 0x48 +#define L3_OFFSET 0x50 +#define L4_OFFSET 0x58 +#define L5_OFFSET 0x60 +#define L6_OFFSET 0x68 +#define L7_OFFSET 0x70 + +#define I0_OFFSET 0x78 +#define I1_OFFSET 0x80 +#define I2_OFFSET 0x88 +#define I3_OFFSET 0x90 +#define I4_OFFSET 0x98 +#define I5_OFFSET 0xA0 +#define I6_FP_OFFSET 0xA8 +#define I7_OFFSET 0xB0 + +#define O0_OFFSET 0xB8 +#define O1_OFFSET 0xC0 +#define O2_OFFSET 0xC8 +#define O3_OFFSET 0xD0 +#define O4_OFFSET 0xD8 +#define O5_OFFSET 0xE0 +#define O6_SP_OFFSET 0xE8 +#define O7_OFFSET 0xF0 + +#define ISR_DISPATCH_DISABLE_STACK_OFFSET 0xF8 +#define ISR_PAD_OFFSET 0xFC + +/* + * The floating point context area. + */ + +#ifndef ASM + +typedef struct { + double f0; /* f0-f1 */ + double f2; /* f2-f3 */ + double f4; /* f4-f5 */ + double f6; /* f6-f7 */ + double f8; /* f8-f9 */ + double f10; /* f10-f11 */ + double f12; /* f12-f13 */ + double f14; /* f14-f15 */ + double f16; /* f16-f17 */ + double f18; /* f18-f19 */ + double f20; /* f20-f21 */ + double f22; /* f22-f23 */ + double f24; /* f24-f25 */ + double f26; /* f26-f27 */ + double f28; /* f28-f29 */ + double f30; /* f30-f31 */ + double f32; + double f34; + double f36; + double f38; + double f40; + double f42; + double f44; + double f46; + double f48; + double f50; + double f52; + double f54; + double f56; + double f58; + double f60; + double f62; + uint64_t fsr; +} Context_Control_fp; + +#endif /* !ASM */ + +/* + * Offsets of fields with Context_Control_fp for assembly routines. + */ + +#define FO_OFFSET 0x00 +#define F2_OFFSET 0x08 +#define F4_OFFSET 0x10 +#define F6_OFFSET 0x18 +#define F8_OFFSET 0x20 +#define F1O_OFFSET 0x28 +#define F12_OFFSET 0x30 +#define F14_OFFSET 0x38 +#define F16_OFFSET 0x40 +#define F18_OFFSET 0x48 +#define F2O_OFFSET 0x50 +#define F22_OFFSET 0x58 +#define F24_OFFSET 0x60 +#define F26_OFFSET 0x68 +#define F28_OFFSET 0x70 +#define F3O_OFFSET 0x78 +#define F32_OFFSET 0x80 +#define F34_OFFSET 0x88 +#define F36_OFFSET 0x90 +#define F38_OFFSET 0x98 +#define F4O_OFFSET 0xA0 +#define F42_OFFSET 0xA8 +#define F44_OFFSET 0xB0 +#define F46_OFFSET 0xB8 +#define F48_OFFSET 0xC0 +#define F5O_OFFSET 0xC8 +#define F52_OFFSET 0xD0 +#define F54_OFFSET 0xD8 +#define F56_OFFSET 0xE0 +#define F58_OFFSET 0xE8 +#define F6O_OFFSET 0xF0 +#define F62_OFFSET 0xF8 +#define FSR_OFFSET 0x100 + +#define CONTEXT_CONTROL_FP_SIZE 0x108 + +#ifndef ASM + +/* + * Context saved on stack for an interrupt. + * + * NOTE: The tstate, tpc, and tnpc are saved in this structure + * to allow resetting the TL while still being able to return + * from a trap later. The PIL is saved because + * if this is an external interrupt, we will mask lower + * priority interrupts until finishing. Even though the y register + * is deprecated, gcc still uses it. + */ + +typedef struct { + SPARC64_Minimum_stack_frame Stack_frame; + uint64_t tstate; + uint64_t tpc; + uint64_t tnpc; + uint64_t pil; + uint64_t y; + uint64_t g1; + uint64_t g2; + uint64_t g3; + uint64_t g4; + uint64_t g5; + uint64_t g6; + uint64_t g7; + uint64_t o0; + uint64_t o1; + uint64_t o2; + uint64_t o3; + uint64_t o4; + uint64_t o5; + uint64_t o6_sp; + uint64_t o7; + uint64_t tvec; +} CPU_Interrupt_frame; + +#endif /* ASM */ + +/* + * Offsets of fields with CPU_Interrupt_frame for assembly routines. + */ + +#define ISF_TSTATE_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x00 +#define ISF_TPC_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x08 +#define ISF_TNPC_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x10 +#define ISF_PIL_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x18 +#define ISF_Y_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x20 +#define ISF_G1_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x28 +#define ISF_G2_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x30 +#define ISF_G3_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x38 +#define ISF_G4_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x40 +#define ISF_G5_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x48 +#define ISF_G6_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x50 +#define ISF_G7_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x58 +#define ISF_O0_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x60 +#define ISF_O1_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x68 +#define ISF_O2_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x70 +#define ISF_O3_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x78 +#define ISF_O4_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x80 +#define ISF_O5_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x88 +#define ISF_O6_SP_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x90 +#define ISF_O7_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x98 +#define ISF_TVEC_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0xA0 + +#define CONTEXT_CONTROL_INTERRUPT_FRAME_SIZE SPARC64_MINIMUM_STACK_FRAME_SIZE + 0xA8 +#ifndef ASM +/* + * This variable is contains the initialize context for the FP unit. + * It is filled in by _CPU_Initialize and copied into the task's FP + * context area during _CPU_Context_Initialize. + */ + +extern Context_Control_fp _CPU_Null_fp_context; + +/* + * This flag is context switched with each thread. It indicates + * that THIS thread has an _ISR_Dispatch stack frame on its stack. + * By using this flag, we can avoid nesting more interrupt dispatching + * attempts on a previously interrupted thread's stack. + */ + +extern volatile uint32_t _CPU_ISR_Dispatch_disable; + +/* + * The following type defines an entry in the SPARC's trap table. + * + * NOTE: The instructions chosen are RTEMS dependent although one is + * obligated to use two of the four instructions to perform a + * long jump. The other instructions load one register with the + * trap type (a.k.a. vector) and another with the psr. + */ +/* For SPARC V9, we must use 6 of these instructions to perform a long + * jump, because the _handler value is now 64-bits. We also need to store + * temporary values in the global register set at this trap level. Because + * the handler runs at TL > 0 with GL > 0, it should be OK to use g2 and g3 + * to pass parameters to ISR_Handler. + * + * The instruction sequence is now more like: + * rdpr %tstate, %g4 + * setx _handler, %g2, %g3 + * jmp %g3+0 + * mov _vector, %g2 + */ +typedef struct { + uint32_t rdpr_tstate_g4; /* rdpr %tstate, %g4 */ + uint32_t sethi_of_hh_handler_to_g2; /* sethi %hh(_handler), %g2 */ + uint32_t or_g2_hm_handler_to_g2; /* or %l3, %hm(_handler), %g2 */ + uint32_t sllx_g2_by_32_to_g2; /* sllx %g2, 32, %g2 */ + uint32_t sethi_of_handler_to_g3; /* sethi %hi(_handler), %g3 */ + uint32_t or_g3_g2_to_g3; /* or %g3, %g2, %g3 */ + uint32_t jmp_to_low_of_handler_plus_g3; /* jmp %g3 + %lo(_handler) */ + uint32_t mov_vector_g2; /* mov _vector, %g2 */ +} CPU_Trap_table_entry; + +/* + * This is the set of opcodes for the instructions loaded into a trap + * table entry. The routine which installs a handler is responsible + * for filling in the fields for the _handler address and the _vector + * trap type. + * + * The constants following this structure are masks for the fields which + * must be filled in when the handler is installed. + */ + +extern const CPU_Trap_table_entry _CPU_Trap_slot_template; + +/* + * The size of the floating point context area. + */ + +#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp ) + +#endif + +/* + * Amount of extra stack (above minimum stack size) required by + * MPCI receive server thread. Remember that in a multiprocessor + * system this thread must exist and be able to process all directives. + */ + +#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 1024 + +/* + * This defines the number of entries in the ISR_Vector_table managed + * by the executive. + * + * On the SPARC, there are really only 256 vectors. However, the executive + * has no easy, fast, reliable way to determine which traps are synchronous + * and which are asynchronous. By default, synchronous traps return to the + * instruction which caused the interrupt. So if you install a software + * trap handler as an executive interrupt handler (which is desirable since + * RTEMS takes care of window and register issues), then the executive needs + * to know that the return address is to the trap rather than the instruction + * following the trap. + * + * So vectors 0 through 255 are treated as regular asynchronous traps which + * provide the "correct" return address. Vectors 256 through 512 are assumed + * by the executive to be synchronous and to require that the return address + * be fudged. + * + * If you use this mechanism to install a trap handler which must reexecute + * the instruction which caused the trap, then it should be installed as + * an asynchronous trap. This will avoid the executive changing the return + * address. + */ +/* On SPARC v9, there are 512 vectors. The same philosophy applies to + * vector installation and use, we just provide a larger table. + */ +#define CPU_INTERRUPT_NUMBER_OF_VECTORS 512 +#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER 1023 + +#define SPARC_SYNCHRONOUS_TRAP_BIT_MASK 0x200 +#define SPARC_ASYNCHRONOUS_TRAP( _trap ) (_trap) +#define SPARC_SYNCHRONOUS_TRAP( _trap ) ((_trap) + 512 ) + +#define SPARC_REAL_TRAP_NUMBER( _trap ) ((_trap) % 512) + +/* + * This is defined if the port has a special way to report the ISR nesting + * level. Most ports maintain the variable _ISR_Nest_level. + */ + +#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE + +/* + * Should be large enough to run all tests. This ensures + * that a "reasonable" small application should not have any problems. + * + * This appears to be a fairly generous number for the SPARC since + * represents a call depth of about 20 routines based on the minimum + * stack frame. + */ + +#define CPU_STACK_MINIMUM_SIZE (1024*8) + +#define CPU_SIZEOF_POINTER 8 + +/* + * CPU's worst alignment requirement for data types on a byte boundary. This + * alignment does not take into account the requirements for the stack. + * + * On the SPARC, this is required for double word loads and stores. + * + * Note: quad-word loads/stores need alignment of 16, but currently supported + * architectures do not provide HW implemented quad-word operations. + */ + +#define CPU_ALIGNMENT 8 + +/* + * This number corresponds to the byte alignment requirement for the + * heap handler. This alignment requirement may be stricter than that + * for the data types alignment specified by CPU_ALIGNMENT. It is + * common for the heap to follow the same alignment requirement as + * CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict enough for the heap, + * then this should be set to CPU_ALIGNMENT. + * + * NOTE: This does not have to be a power of 2. It does have to + * be greater or equal to than CPU_ALIGNMENT. + */ + +#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT + +/* + * This number corresponds to the byte alignment requirement for memory + * buffers allocated by the partition manager. This alignment requirement + * may be stricter than that for the data types alignment specified by + * CPU_ALIGNMENT. It is common for the partition to follow the same + * alignment requirement as CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict + * enough for the partition, then this should be set to CPU_ALIGNMENT. + * + * NOTE: This does not have to be a power of 2. It does have to + * be greater or equal to than CPU_ALIGNMENT. + */ + +#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT + +/* + * This number corresponds to the byte alignment requirement for the + * stack. This alignment requirement may be stricter than that for the + * data types alignment specified by CPU_ALIGNMENT. If the CPU_ALIGNMENT + * is strict enough for the stack, then this should be set to 0. + * + * NOTE: This must be a power of 2 either 0 or greater than CPU_ALIGNMENT. + * + * The alignment restrictions for the SPARC are not that strict but this + * should unsure that the stack is always sufficiently alignment that the + * window overflow, underflow, and flush routines can use double word loads + * and stores. + */ + +#define CPU_STACK_ALIGNMENT 16 + +#ifndef ASM + +/* + * ISR handler macros + */ + +/* + * Support routine to initialize the RTEMS vector table after it is allocated. + */ + +#define _CPU_Initialize_vectors() + +/* + * Disable all interrupts for a critical section. The previous + * level is returned in _level. + */ + + #define _CPU_ISR_Disable( _level ) \ + (_level) = sparc_disable_interrupts() + +/* + * Enable interrupts to the previous level (returned by _CPU_ISR_Disable). + * This indicates the end of a critical section. The parameter + * _level is not modified. + */ + +#define _CPU_ISR_Enable( _level ) \ + sparc_enable_interrupts( _level ) + +/* + * This temporarily restores the interrupt to _level before immediately + * disabling them again. This is used to divide long critical + * sections into two or more parts. The parameter _level is not + * modified. + */ + +#define _CPU_ISR_Flash( _level ) \ + sparc_flash_interrupts( _level ) + +RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) +{ + return ( level & SPARC_PSTATE_IE_MASK ) != 0; +} + +/* + * Map interrupt level in task mode onto the hardware that the CPU + * actually provides. Currently, interrupt levels which do not + * map onto the CPU in a straight fashion are undefined. + */ + +#define _CPU_ISR_Set_level( _newlevel ) \ + sparc_enable_interrupts( _newlevel) + +uint32_t _CPU_ISR_Get_level( void ); + +/* end of ISR handler macros */ + +/* Context handler macros */ + +/* + * Initialize the context to a state suitable for starting a + * task after a context restore operation. Generally, this + * involves: + * + * - setting a starting address + * - preparing the stack + * - preparing the stack and frame pointers + * - setting the proper interrupt level in the context + * - initializing the floating point context + * + * NOTE: Implemented as a subroutine for the SPARC port. + */ + +void _CPU_Context_Initialize( + Context_Control *the_context, + void *stack_base, + uint32_t size, + uint32_t new_level, + void *entry_point, + bool is_fp, + void *tls_area +); + +/* + * This macro is invoked from _Thread_Handler to do whatever CPU + * specific magic is required that must be done in the context of + * the thread when it starts. + * + * On the SPARC, this is setting the frame pointer so GDB is happy. + * Make GDB stop unwinding at _Thread_Handler, previous register window + * Frame pointer is 0 and calling address must be a function with starting + * with a SAVE instruction. If return address is leaf-function (no SAVE) + * GDB will not look at prev reg window fp. + * + * _Thread_Handler is known to start with SAVE. + */ + +#define _CPU_Context_Initialization_at_thread_begin() \ + do { \ + __asm__ volatile ("set _Thread_Handler,%%i7\n"::); \ + } while (0) + +/* + * This routine is responsible for somehow restarting the currently + * executing task. + * + * On the SPARC, this is is relatively painless but requires a small + * amount of wrapper code before using the regular restore code in + * of the context switch. + */ + +#define _CPU_Context_Restart_self( _the_context ) \ + _CPU_Context_restore( (_the_context) ); + +/* + * This routine initializes the FP context area passed to it to. + * + * The SPARC allows us to use the simple initialization model + * in which an "initial" FP context was saved into _CPU_Null_fp_context + * at CPU initialization and it is simply copied into the destination + * context. + */ + +#define _CPU_Context_Initialize_fp( _destination ) \ + do { \ + *(*(_destination)) = _CPU_Null_fp_context; \ + } while (0) + +/* end of Context handler macros */ + +/* Fatal Error manager macros */ + +/* + * This routine copies _error into a known place -- typically a stack + * location or a register, optionally disables interrupts, and + * halts/stops the CPU. + */ + +#define _CPU_Fatal_halt( _source, _error ) \ + do { \ + uint32_t level; \ + \ + level = sparc_disable_interrupts(); \ + __asm__ volatile ( "mov %0, %%g1 " : "=r" (level) : "0" (level) ); \ + while (1); /* loop forever */ \ + } while (0) + +/* end of Fatal Error manager macros */ + +/* Bitfield handler macros */ + +/* + * The SPARC port uses the generic C algorithm for bitfield scan if the + * CPU model does not have a scan instruction. + */ + +#if ( SPARC_HAS_BITSCAN == 0 ) +#define CPU_USE_GENERIC_BITFIELD_CODE TRUE +#else +#error "scan instruction not currently supported by RTEMS!!" +#endif + +/* end of Bitfield handler macros */ + +/* Priority handler handler macros */ + +/* + * The SPARC port uses the generic C algorithm for bitfield scan if the + * CPU model does not have a scan instruction. + */ + +#if ( SPARC_HAS_BITSCAN == 1 ) +#error "scan instruction not currently supported by RTEMS!!" +#endif + +/* end of Priority handler macros */ + +/* functions */ + +/* + * _CPU_Initialize + * + * This routine performs CPU dependent initialization. + */ + +void _CPU_Initialize(void); + +/* + * _CPU_ISR_install_raw_handler + * + * This routine installs new_handler to be directly called from the trap + * table. + */ + +void _CPU_ISR_install_raw_handler( + uint32_t vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +/* + * _CPU_ISR_install_vector + * + * This routine installs an interrupt vector. + */ + +void _CPU_ISR_install_vector( + uint64_t vector, + proc_ptr new_handler, + proc_ptr *old_handler +); + +#if (CPU_PROVIDES_IDLE_THREAD_BODY == TRUE) + +/* + * _CPU_Thread_Idle_body + * + * Some SPARC implementations have low power, sleep, or idle modes. This + * tries to take advantage of those models. + */ + +void *_CPU_Thread_Idle_body( uintptr_t ignored ); + +#endif /* CPU_PROVIDES_IDLE_THREAD_BODY */ + +/* + * _CPU_Context_switch + * + * This routine switches from the run context to the heir context. + */ + +void _CPU_Context_switch( + Context_Control *run, + Context_Control *heir +); + +/* + * _CPU_Context_restore + * + * This routine is generally used only to restart self in an + * efficient manner. + */ + +void _CPU_Context_restore( + Context_Control *new_context +) RTEMS_NO_RETURN; + +/* + * _CPU_Context_save_fp + * + * This routine saves the floating point context passed to it. + */ + +void _CPU_Context_save_fp( + Context_Control_fp **fp_context_ptr +); + +/* + * _CPU_Context_restore_fp + * + * This routine restores the floating point context passed to it. + */ + +void _CPU_Context_restore_fp( + Context_Control_fp **fp_context_ptr +); + +static inline void _CPU_Context_volatile_clobber( uintptr_t pattern ) +{ + /* TODO */ +} + +static inline void _CPU_Context_validate( uintptr_t pattern ) +{ + while (1) { + /* TODO */ + } +} + +/* FIXME */ +typedef CPU_Interrupt_frame CPU_Exception_frame; + +void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); + +/* + * CPU_swap_u32 + * + * The following routine swaps the endian format of an unsigned int. + * It must be static because it is referenced indirectly. + * + * This version will work on any processor, but if you come across a better + * way for the SPARC PLEASE use it. The most common way to swap a 32-bit + * entity as shown below is not any more efficient on the SPARC. + * + * swap least significant two bytes with 16-bit rotate + * swap upper and lower 16-bits + * swap most significant two bytes with 16-bit rotate + * + * It is not obvious how the SPARC can do significantly better than the + * generic code. gcc 2.7.0 only generates about 12 instructions for the + * following code at optimization level four (i.e. -O4). + */ + +static inline uint32_t CPU_swap_u32( + uint32_t value +) +{ + uint32_t byte1, byte2, byte3, byte4, swapped; + + byte4 = (value >> 24) & 0xff; + byte3 = (value >> 16) & 0xff; + byte2 = (value >> 8) & 0xff; + byte1 = value & 0xff; + + swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4; + return( swapped ); +} + +#define CPU_swap_u16( value ) \ + (((value&0xff) << 8) | ((value >> 8)&0xff)) + +typedef uint32_t CPU_Counter_ticks; + +CPU_Counter_ticks _CPU_Counter_read( void ); + +static inline CPU_Counter_ticks _CPU_Counter_difference( + CPU_Counter_ticks second, + CPU_Counter_ticks first +) +{ + return second - first; +} + +#endif /* ASM */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/score/cpu/sparc64/include/rtems/score/cpuatomic.h b/cpukit/score/cpu/sparc64/include/rtems/score/cpuatomic.h new file mode 100644 index 0000000000..598ee76b20 --- /dev/null +++ b/cpukit/score/cpu/sparc64/include/rtems/score/cpuatomic.h @@ -0,0 +1,14 @@ +/* + * COPYRIGHT (c) 2012-2013 Deng Hengyi. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_ATOMIC_CPU_H +#define _RTEMS_SCORE_ATOMIC_CPU_H + +#include + +#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/sparc64/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/sparc64/include/rtems/score/cpuimpl.h new file mode 100644 index 0000000000..789f2badd9 --- /dev/null +++ b/cpukit/score/cpu/sparc64/include/rtems/score/cpuimpl.h @@ -0,0 +1,34 @@ +/** + * @file + * + * @brief CPU Port Implementation API + */ + +/* + * Copyright (c) 2013 embedded brains GmbH + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPUIMPL_H +#define _RTEMS_SCORE_CPUIMPL_H + +#include + +#define CPU_PER_CPU_CONTROL_SIZE 0 + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ASM */ + +#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/sparc64/include/rtems/score/sparc64.h b/cpukit/score/cpu/sparc64/include/rtems/score/sparc64.h new file mode 100644 index 0000000000..d20c2ff509 --- /dev/null +++ b/cpukit/score/cpu/sparc64/include/rtems/score/sparc64.h @@ -0,0 +1,342 @@ +/** + * @file + * + * @brief Information Required to Build RTEMS for a Particular Member + * of the SPARC Family + * + * This include file contains information pertaining to the SPARC + * processor family. + */ + +/* + * COPYRIGHT (c) 1989-1999. On-Line Applications Research Corporation (OAR). + * + * This file is based on the SPARC sparc.h file. Modifications are made + * to support the SPARC64 processor. + * COPYRIGHT (c) 2010. Gedare Bloom. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_SPARC_H +#define _RTEMS_SCORE_SPARC_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This file contains the information required to build + * RTEMS for a particular member of the "sparc" family. It does + * this by setting variables to indicate which implementation + * dependent features are present in a particular member + * of the family. + * + * Currently recognized feature flags: + * + * + SPARC_HAS_FPU + * 0 - no HW FPU + * 1 - has HW FPU (assumed to be compatible w/90C602) + * + * + SPARC_HAS_BITSCAN + * 0 - does not have scan instructions + * 1 - has scan instruction (not currently implemented) + * + * + SPARC_NUMBER_OF_REGISTER_WINDOWS + * 8 is the most common number supported by SPARC implementations. + * SPARC_PSR_CWP_MASK is derived from this value. + */ + +/* + * Some higher end SPARCs have a bitscan instructions. It would + * be nice to take advantage of them. Right now, there is no + * port to a CPU model with this feature and no (untested) code + * that is based on this feature flag. + */ + +#define SPARC_HAS_BITSCAN 0 + +/* + * This should be OK until a port to a higher end SPARC processor + * is made that has more than 8 register windows. If this cannot + * be determined based on multilib settings (v7/v8/v9), then the + * cpu_asm.S code that depends on this will have to move to libcpu. + * + * SPARC v9 supports from 3 to 32 register windows. + * N_REG_WINDOWS = 8 on UltraSPARC T1 (impl. dep. #2-V8). + */ + +#define SPARC_NUMBER_OF_REGISTER_WINDOWS 8 + +/* + * This should be determined based on some soft float derived + * cpp predefine but gcc does not currently give us that information. + */ + + +#if defined(_SOFT_FLOAT) +#define SPARC_HAS_FPU 0 +#else +#define SPARC_HAS_FPU 1 +#endif + +#if SPARC_HAS_FPU +#define CPU_MODEL_NAME "w/FPU" +#else +#define CPU_MODEL_NAME "w/soft-float" +#endif + +/* + * Define the name of the CPU family. + */ + +#define CPU_NAME "SPARC" + +/* + * Miscellaneous constants + */ + +/* + * The PSR is deprecated and deleted. + * + * The following registers represent fields of the PSR: + * PIL - Processor Interrupt Level register + * CWP - Current Window Pointer register + * VER - Version register + * CCR - Condition Codes Register + * PSTATE - Processor State register + */ + +/* + * PSTATE masks and starting bit positions + * + * NOTE: Reserved bits are ignored. + */ + +#define SPARC_PSTATE_AG_MASK 0x00000001 /* bit 0 */ +#define SPARC_PSTATE_IE_MASK 0x00000002 /* bit 1 */ +#define SPARC_PSTATE_PRIV_MASK 0x00000004 /* bit 2 */ +#define SPARC_PSTATE_AM_MASK 0x00000008 /* bit 3 */ +#define SPARC_PSTATE_PEF_MASK 0x00000010 /* bit 4 */ +#define SPARC_PSTATE_MM_MASK 0x00000040 /* bit 6 */ +#define SPARC_PSTATE_TLE_MASK 0x00000100 /* bit 8 */ +#define SPARC_PSTATE_CLE_MASK 0x00000200 /* bit 9 */ + +#define SPARC_PSTATE_AG_BIT_POSITION 0 /* bit 0 */ +#define SPARC_PSTATE_IE_BIT_POSITION 1 /* bit 1 */ +#define SPARC_PSTATE_PRIV_BIT_POSITION 2 /* bit 2 */ +#define SPARC_PSTATE_AM_BIT_POSITION 3 /* bit 3 */ +#define SPARC_PSTATE_PEF_BIT_POSITION 4 /* bit 4 */ +#define SPARC_PSTATE_MM_BIT_POSITION 6 /* bit 6 */ +#define SPARC_PSTATE_TLE_BIT_POSITION 8 /* bit 8 */ +#define SPARC_PSTATE_CLE_BIT_POSITION 9 /* bit 9 */ + +#define SPARC_FPRS_FEF_MASK 0x0100 /* bit 2 */ +#define SPARC_FPRS_FEF_BIT_POSITION 2 /* bit 2 */ + +#define SPARC_TSTATE_IE_MASK 0x00000200 /* bit 9 */ + +#define SPARC_SOFTINT_TM_MASK 0x00000001 /* bit 0 */ +#define SPARC_SOFTINT_SM_MASK 0x00010000 /* bit 16 */ +#define SPARC_SOFTINT_TM_BIT_POSITION 1 /* bit 0 */ +#define SPARC_SOFTINT_SM_BIT_POSITION 17 /* bit 16 */ + +#define STACK_BIAS (2047) + +#ifdef ASM + +/* + * To enable the FPU we need to set both PSTATE.pef and FPRS.fef + */ + +#define sparc64_enable_FPU(rtmp1) \ + rdpr %pstate, rtmp1; \ + or rtmp1, SPARC_PSTATE_PEF_MASK, rtmp1; \ + wrpr %g0, rtmp1, %pstate; \ + rd %fprs, rtmp1; \ + or rtmp1, SPARC_FPRS_FEF_MASK, rtmp1; \ + wr %g0, rtmp1, %fprs + + +#endif + +#ifndef ASM + +/* + * Standard nop + */ + +#define nop() \ + do { \ + __asm__ volatile ( "nop" ); \ + } while ( 0 ) + +/* + * Get and set the pstate + */ + +#define sparc64_get_pstate( _pstate ) \ + do { \ + (_pstate) = 0; \ + __asm__ volatile( "rdpr %%pstate, %0" : "=r" (_pstate) : "0" (_pstate) ); \ + } while ( 0 ) + +#define sparc64_set_pstate( _pstate ) \ + do { \ + __asm__ volatile ( \ + "wrpr %%g0, %0, %%pstate " : "=r" ((_pstate)) : "0" ((_pstate)) ); \ + } while ( 0 ) + +/* + * Get and set the PIL + */ + +#define sparc64_get_pil( _pil ) \ + do { \ + (_pil) = 0; \ + __asm__ volatile( "rdpr %%pil, %0" : "=r" (_pil) : "0" (_pil) ); \ + } while ( 0 ) + +#define sparc64_set_pil( _pil ) \ + do { \ + __asm__ volatile ( "wrpr %%g0, %0, %%pil " : "=r" ((_pil)) : "0" ((_pil)) ); \ + } while ( 0 ) + + +/* + * Get and set the TBA + */ + +#define sparc64_get_tba( _tba ) \ + do { \ + (_tba) = 0; /* to avoid unitialized warnings */ \ + __asm__ volatile( "rdpr %%tba, %0" : "=r" (_tba) : "0" (_tba) ); \ + } while ( 0 ) + +#define sparc64_set_tba( _tba ) \ + do { \ + __asm__ volatile( "wrpr %%g0, %0, %%tba" : "=r" (_tba) : "0" (_tba) ); \ + } while ( 0 ) + +/* + * Get and set the TL (trap level) + */ + +#define sparc64_get_tl( _tl ) \ + do { \ + (_tl) = 0; /* to avoid unitialized warnings */ \ + __asm__ volatile( "rdpr %%tl, %0" : "=r" (_tl) : "0" (_tl) ); \ + } while ( 0 ) + +#define sparc64_set_tl( _tl ) \ + do { \ + __asm__ volatile( "wrpr %%g0, %0, %%tl" : "=r" (_tl) : "0" (_tl) ); \ + } while ( 0 ) + + +/* + * read the stick register + * + * Note: + * stick asr=24, mnemonic=stick + * Note: stick does not appear to be a valid ASR for US3, although it is + * implemented in US3i. + */ +#define sparc64_read_stick( _stick ) \ + do { \ + (_stick) = 0; \ + __asm__ volatile( "rd %%stick, %0" : "=r" (_stick) : "0" (_stick) ); \ + } while ( 0 ) + +/* + * write the stick_cmpr register + * + * Note: + * stick_cmpr asr=25, mnemonic=stick_cmpr + * Note: stick_cmpr does not appear to be a valid ASR for US3, although it is + * implemented in US3i. + */ +#define sparc64_write_stick_cmpr( _stick_cmpr ) \ + do { \ + __asm__ volatile( "wr %%g0, %0, %%stick_cmpr" : "=r" (_stick_cmpr) \ + : "0" (_stick_cmpr) ); \ + } while ( 0 ) + +/* + * read the Tick register + */ +#define sparc64_read_tick( _tick ) \ + do { \ + (_tick) = 0; \ + __asm__ volatile( "rd %%tick, %0" : "=r" (_tick) : "0" (_tick) ); \ + } while ( 0 ) + +/* + * write the tick_cmpr register + */ +#define sparc64_write_tick_cmpr( _tick_cmpr ) \ + do { \ + __asm__ volatile( "wr %%g0, %0, %%tick_cmpr" : "=r" (_tick_cmpr) \ + : "0" (_tick_cmpr) ); \ + } while ( 0 ) + +/* + * Clear the softint register. + * + * sun4u and sun4v: softint_clr asr = 21, with mnemonic clear_softint + */ +#define sparc64_clear_interrupt_bits( _bit_mask ) \ + do { \ + __asm__ volatile( "wr %%g0, %0, %%clear_softint" : "=r" (_bit_mask) \ + : "0" (_bit_mask)); \ + } while ( 0 ) + +/************* DEPRECATED ****************/ +/* Note: Although the y register is deprecated, gcc still uses it */ +/* + * Get and set the Y + */ + +#define sparc_get_y( _y ) \ + do { \ + __asm__ volatile( "rd %%y, %0" : "=r" (_y) : "0" (_y) ); \ + } while ( 0 ) + +#define sparc_set_y( _y ) \ + do { \ + __asm__ volatile( "wr %0, %%y" : "=r" (_y) : "0" (_y) ); \ + } while ( 0 ) + +/************* /DEPRECATED ****************/ + +/* + * Manipulate the interrupt level in the pstate + */ + +uint32_t sparc_disable_interrupts(void); +void sparc_enable_interrupts(uint32_t); + +#define sparc_flash_interrupts( _level ) \ + do { \ + uint32_t _ignored; \ + \ + sparc_enable_interrupts( (_level) ); \ + _ignored = sparc_disable_interrupts(); \ + (void) _ignored; \ + } while ( 0 ) + +#define sparc64_get_interrupt_level( _level ) \ + do { \ + _level = 0; \ + sparc64_get_pil( _level ); \ + } while ( 0 ) + +#endif /* !ASM */ + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_SCORE_SPARC_H */ diff --git a/cpukit/score/cpu/sparc64/include/rtems/score/types.h b/cpukit/score/cpu/sparc64/include/rtems/score/types.h new file mode 100644 index 0000000000..faf50b7a55 --- /dev/null +++ b/cpukit/score/cpu/sparc64/include/rtems/score/types.h @@ -0,0 +1,45 @@ +/** + * @file + * + * @brief SPARC64 CPU Type Definitions + * + * This include file contains type definitions pertaining to the + * SPARC-v9 processor family. + */ + +/* + * COPYRIGHT (c) 1989-1999. On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_TYPES_H +#define _RTEMS_SCORE_TYPES_H + +#include + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This section defines the basic types for this processor. + */ + +/** Type that can store a 32-bit integer or a pointer. */ +typedef uintptr_t CPU_Uint32ptr; + +typedef void sparc_isr; +typedef void ( *sparc_isr_entry )( void ); + +#ifdef __cplusplus +} +#endif + +#endif /* !ASM */ + +#endif diff --git a/cpukit/score/cpu/sparc64/preinstall.am b/cpukit/score/cpu/sparc64/preinstall.am deleted file mode 100644 index 8565c8a672..0000000000 --- a/cpukit/score/cpu/sparc64/preinstall.am +++ /dev/null @@ -1,49 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -$(PROJECT_INCLUDE)/rtems/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems - @: > $(PROJECT_INCLUDE)/rtems/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/asm.h: rtems/asm.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/asm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/asm.h - -$(PROJECT_INCLUDE)/rtems/score/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/score - @: > $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/score/sparc64.h: rtems/score/sparc64.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/sparc64.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/sparc64.h - -$(PROJECT_INCLUDE)/rtems/score/cpu.h: rtems/score/cpu.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpu.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpu.h - -$(PROJECT_INCLUDE)/rtems/score/cpuimpl.h: rtems/score/cpuimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h - -$(PROJECT_INCLUDE)/rtems/score/types.h: rtems/score/types.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/types.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/types.h - -$(PROJECT_INCLUDE)/rtems/score/cpuatomic.h: rtems/score/cpuatomic.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h - diff --git a/cpukit/score/cpu/sparc64/rtems/asm.h b/cpukit/score/cpu/sparc64/rtems/asm.h deleted file mode 100644 index f4448b03a5..0000000000 --- a/cpukit/score/cpu/sparc64/rtems/asm.h +++ /dev/null @@ -1,103 +0,0 @@ -/** - * @file - * - * @brief Address the Problems Caused by Incompatible Flavor of - * Assemblers and Toolsets - * - * This include file attempts to address the problems - * caused by incompatible flavors of assemblers and - * toolsets. It primarily addresses variations in the - * use of leading underscores on symbols and the requirement - * that register names be preceded by a %. - * - * NOTE: The spacing in the use of these macros - * is critical to them working as advertised. - */ - -/* - * COPYRIGHT: - * - * This file is based on similar code found in newlib available - * from ftp.cygnus.com. The file which was used had no copyright - * notice. This file is freely distributable as long as the source - * of the file is noted. - */ - -#ifndef _RTEMS_ASM_H -#define _RTEMS_ASM_H - -/* - * Indicate we are in an assembly file and get the basic CPU definitions. - */ - -#ifndef ASM -#define ASM -#endif -#ifndef __ASM__ -#define __ASM__ -#endif - -#include -#include - -/* - * Recent versions of GNU cpp define variables which indicate the - * need for underscores and percents. If not using GNU cpp or - * the version does not support this, then you will obviously - * have to define these as appropriate. - */ - -/* XXX __USER_LABEL_PREFIX__ and __REGISTER_PREFIX__ do not work on gcc 2.7.0 */ -/* XXX The following ifdef magic fixes the problem but results in a warning */ -/* XXX when compiling assembly code. */ - -#ifndef __USER_LABEL_PREFIX__ -#define __USER_LABEL_PREFIX__ _ -#endif - -#ifndef __REGISTER_PREFIX__ -#define __REGISTER_PREFIX__ -#endif - -#include - -/* Use the right prefix for global labels. */ - -#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) - -/* Use the right prefix for registers. */ - -#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) - -/* - * define macros for all of the registers on this CPU - * - * EXAMPLE: #define d0 REG (d0) - */ - -/* - * Define macros to handle section beginning and ends. - */ - - -#define BEGIN_CODE_DCL .text -#define END_CODE_DCL -#define BEGIN_DATA_DCL .data -#define END_DATA_DCL -#define BEGIN_CODE .text -#define END_CODE -#define BEGIN_DATA -#define END_DATA -#define BEGIN_BSS -#define END_BSS -#define END - -/* - * Following must be tailor for a particular flavor of the C compiler. - * They may need to put underscores in front of the symbols. - */ - -#define PUBLIC(sym) .globl SYM (sym) -#define EXTERN(sym) .globl SYM (sym) - -#endif diff --git a/cpukit/score/cpu/sparc64/rtems/score/cpu.h b/cpukit/score/cpu/sparc64/rtems/score/cpu.h deleted file mode 100644 index 47041e7d5e..0000000000 --- a/cpukit/score/cpu/sparc64/rtems/score/cpu.h +++ /dev/null @@ -1,1051 +0,0 @@ -/** - * @file - * - * @brief SPARC64 CPU Department Source - * - * This include file contains information pertaining to the port of - * the executive to the SPARC64 processor. - */ - -/* - * - * - * COPYRIGHT (c) 1989-2006. On-Line Applications Research Corporation (OAR). - * - * This file is based on the SPARC cpu.h file. Modifications are made - * to support the SPARC64 processor. - * COPYRIGHT (c) 2010. Gedare Bloom. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPU_H -#define _RTEMS_SCORE_CPU_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/* conditional compilation parameters */ - -/* - * Does the executive manage a dedicated interrupt stack in software? - * - * If TRUE, then a stack is allocated in _ISR_Handler_initialization. - * If FALSE, nothing is done. - * - * The SPARC does not have a dedicated HW interrupt stack and one has - * been implemented in SW. - */ - -#define CPU_HAS_SOFTWARE_INTERRUPT_STACK TRUE - -/* - * Does the CPU follow the simple vectored interrupt model? - * - * If TRUE, then RTEMS allocates the vector table it internally manages. - * If FALSE, then the BSP is assumed to allocate and manage the vector - * table - * - * SPARC Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_SIMPLE_VECTORED_INTERRUPTS TRUE - -/* - * Does this CPU have hardware support for a dedicated interrupt stack? - * - * If TRUE, then it must be installed during initialization. - * If FALSE, then no installation is performed. - * - * The SPARC does not have a dedicated HW interrupt stack. - */ - -#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE - -/* - * Do we allocate a dedicated interrupt stack in the Interrupt Manager? - * - * If TRUE, then the memory is allocated during initialization. - * If FALSE, then the memory is allocated during initialization. - */ - -#define CPU_ALLOCATE_INTERRUPT_STACK TRUE - -/* - * Does the RTEMS invoke the user's ISR with the vector number and - * a pointer to the saved interrupt frame (1) or just the vector - * number (0)? - */ - -#define CPU_ISR_PASSES_FRAME_POINTER FALSE - -/* - * Does the CPU have hardware floating point? - * - * If TRUE, then the FLOATING_POINT task attribute is supported. - * If FALSE, then the FLOATING_POINT task attribute is ignored. - */ - -#if ( SPARC_HAS_FPU == 1 ) -#define CPU_HARDWARE_FP TRUE -#else -#define CPU_HARDWARE_FP FALSE -#endif -#define CPU_SOFTWARE_FP FALSE - -/* - * Are all tasks FLOATING_POINT tasks implicitly? - * - * If TRUE, then the FLOATING_POINT task attribute is assumed. - * If FALSE, then the FLOATING_POINT task attribute is followed. - */ - -#define CPU_ALL_TASKS_ARE_FP FALSE - -/* - * Should the IDLE task have a floating point context? - * - * If TRUE, then the IDLE task is created as a FLOATING_POINT task - * and it has a floating point context which is switched in and out. - * If FALSE, then the IDLE task does not have a floating point context. - */ - -#define CPU_IDLE_TASK_IS_FP FALSE - -/* - * Should the saving of the floating point registers be deferred - * until a context switch is made to another different floating point - * task? - * - * If TRUE, then the floating point context will not be stored until - * necessary. It will remain in the floating point registers and not - * disturned until another floating point task is switched to. - * - * If FALSE, then the floating point context is saved when a floating - * point task is switched out and restored when the next floating point - * task is restored. The state of the floating point registers between - * those two operations is not specified. - */ - -#define CPU_USE_DEFERRED_FP_SWITCH TRUE - -#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE - -/* - * Does this port provide a CPU dependent IDLE task implementation? - * - * If TRUE, then the routine _CPU_Thread_Idle_body - * must be provided and is the default IDLE thread body instead of - * _CPU_Thread_Idle_body. - * - * If FALSE, then use the generic IDLE thread body if the BSP does - * not provide one. - */ - -#define CPU_PROVIDES_IDLE_THREAD_BODY FALSE - -/* - * Does the stack grow up (toward higher addresses) or down - * (toward lower addresses)? - * - * If TRUE, then the grows upward. - * If FALSE, then the grows toward smaller addresses. - * - * The stack grows to lower addresses on the SPARC. - */ - -#define CPU_STACK_GROWS_UP FALSE - -/* FIXME: Is this the right value? */ -#define CPU_CACHE_LINE_BYTES 32 - -/* - * The following is the variable attribute used to force alignment - * of critical data structures. On some processors it may make - * sense to have these aligned on tighter boundaries than - * the minimum requirements of the compiler in order to have as - * much of the critical data area as possible in a cache line. - * - * The SPARC does not appear to have particularly strict alignment - * requirements. This value (16) was chosen to take advantages of caches. - * - * SPARC 64 requirements on floating point alignment is at least 8, - * and is 16 if quad-word fp instructions are available (e.g. LDQF). - */ - -#define CPU_STRUCTURE_ALIGNMENT RTEMS_ALIGNED( 16 ) - -/* - * The following defines the number of bits actually used in the - * interrupt field of the task mode. How those bits map to the - * CPU interrupt levels is defined by the routine _CPU_ISR_Set_level(). - * - * The SPARC v9 has 16 interrupt levels in the PIL field of the PSR. - */ - -#define CPU_MODES_INTERRUPT_MASK 0x0000000F - -#define CPU_MAXIMUM_PROCESSORS 32 - -/* - * This structure represents the organization of the minimum stack frame - * for the SPARC. More framing information is required in certain situaions - * such as when there are a large number of out parameters or when the callee - * must save floating point registers. - */ - -#ifndef ASM - -typedef struct { - uint64_t l0; - uint64_t l1; - uint64_t l2; - uint64_t l3; - uint64_t l4; - uint64_t l5; - uint64_t l6; - uint64_t l7; - uint64_t i0; - uint64_t i1; - uint64_t i2; - uint64_t i3; - uint64_t i4; - uint64_t i5; - uint64_t i6_fp; - uint64_t i7; - void *structure_return_address; - /* - * The following are for the callee to save the register arguments in - * should this be necessary. - */ - uint64_t saved_arg0; - uint64_t saved_arg1; - uint64_t saved_arg2; - uint64_t saved_arg3; - uint64_t saved_arg4; - uint64_t saved_arg5; - uint64_t pad0; -} SPARC64_Minimum_stack_frame; - -#endif /* !ASM */ - -#define CPU_STACK_FRAME_L0_OFFSET 0x00 -#define CPU_STACK_FRAME_L1_OFFSET 0x08 -#define CPU_STACK_FRAME_L2_OFFSET 0x10 -#define CPU_STACK_FRAME_L3_OFFSET 0x18 -#define CPU_STACK_FRAME_L4_OFFSET 0x20 -#define CPU_STACK_FRAME_L5_OFFSET 0x28 -#define CPU_STACK_FRAME_L6_OFFSET 0x30 -#define CPU_STACK_FRAME_L7_OFFSET 0x38 -#define CPU_STACK_FRAME_I0_OFFSET 0x40 -#define CPU_STACK_FRAME_I1_OFFSET 0x48 -#define CPU_STACK_FRAME_I2_OFFSET 0x50 -#define CPU_STACK_FRAME_I3_OFFSET 0x58 -#define CPU_STACK_FRAME_I4_OFFSET 0x60 -#define CPU_STACK_FRAME_I5_OFFSET 0x68 -#define CPU_STACK_FRAME_I6_FP_OFFSET 0x70 -#define CPU_STACK_FRAME_I7_OFFSET 0x78 -#define CPU_STRUCTURE_RETURN_ADDRESS_OFFSET 0x80 -#define CPU_STACK_FRAME_SAVED_ARG0_OFFSET 0x88 -#define CPU_STACK_FRAME_SAVED_ARG1_OFFSET 0x90 -#define CPU_STACK_FRAME_SAVED_ARG2_OFFSET 0x98 -#define CPU_STACK_FRAME_SAVED_ARG3_OFFSET 0xA0 -#define CPU_STACK_FRAME_SAVED_ARG4_OFFSET 0xA8 -#define CPU_STACK_FRAME_SAVED_ARG5_OFFSET 0xB0 -#define CPU_STACK_FRAME_PAD0_OFFSET 0xB8 - -#define SPARC64_MINIMUM_STACK_FRAME_SIZE 0xC0 - -/* - * Contexts - * - * Generally there are 2 types of context to save. - * 1. Interrupt registers to save - * 2. Task level registers to save - * - * This means we have the following 3 context items: - * 1. task level context stuff:: Context_Control - * 2. floating point task stuff:: Context_Control_fp - * 3. special interrupt level context :: Context_Control_interrupt - * - * On the SPARC, we are relatively conservative in that we save most - * of the CPU state in the context area. The ET (enable trap) bit and - * the CWP (current window pointer) fields of the PSR are considered - * system wide resources and are not maintained on a per-thread basis. - */ - -#ifndef ASM - -typedef struct { - uint64_t g1; - uint64_t g2; - uint64_t g3; - uint64_t g4; - uint64_t g5; - uint64_t g6; - uint64_t g7; - - uint64_t l0; - uint64_t l1; - uint64_t l2; - uint64_t l3; - uint64_t l4; - uint64_t l5; - uint64_t l6; - uint64_t l7; - - uint64_t i0; - uint64_t i1; - uint64_t i2; - uint64_t i3; - uint64_t i4; - uint64_t i5; - uint64_t i6_fp; - uint64_t i7; - - uint64_t o0; - uint64_t o1; - uint64_t o2; - uint64_t o3; - uint64_t o4; - uint64_t o5; - uint64_t o6_sp; - uint64_t o7; - - uint32_t isr_dispatch_disable; - uint32_t pad; -} Context_Control; - -#define _CPU_Context_Get_SP( _context ) \ - (_context)->o6_sp - -#endif /* ASM */ - -/* - * Offsets of fields with Context_Control for assembly routines. - */ - -#define G1_OFFSET 0x00 -#define G2_OFFSET 0x08 -#define G3_OFFSET 0x10 -#define G4_OFFSET 0x18 -#define G5_OFFSET 0x20 -#define G6_OFFSET 0x28 -#define G7_OFFSET 0x30 - -#define L0_OFFSET 0x38 -#define L1_OFFSET 0x40 -#define L2_OFFSET 0x48 -#define L3_OFFSET 0x50 -#define L4_OFFSET 0x58 -#define L5_OFFSET 0x60 -#define L6_OFFSET 0x68 -#define L7_OFFSET 0x70 - -#define I0_OFFSET 0x78 -#define I1_OFFSET 0x80 -#define I2_OFFSET 0x88 -#define I3_OFFSET 0x90 -#define I4_OFFSET 0x98 -#define I5_OFFSET 0xA0 -#define I6_FP_OFFSET 0xA8 -#define I7_OFFSET 0xB0 - -#define O0_OFFSET 0xB8 -#define O1_OFFSET 0xC0 -#define O2_OFFSET 0xC8 -#define O3_OFFSET 0xD0 -#define O4_OFFSET 0xD8 -#define O5_OFFSET 0xE0 -#define O6_SP_OFFSET 0xE8 -#define O7_OFFSET 0xF0 - -#define ISR_DISPATCH_DISABLE_STACK_OFFSET 0xF8 -#define ISR_PAD_OFFSET 0xFC - -/* - * The floating point context area. - */ - -#ifndef ASM - -typedef struct { - double f0; /* f0-f1 */ - double f2; /* f2-f3 */ - double f4; /* f4-f5 */ - double f6; /* f6-f7 */ - double f8; /* f8-f9 */ - double f10; /* f10-f11 */ - double f12; /* f12-f13 */ - double f14; /* f14-f15 */ - double f16; /* f16-f17 */ - double f18; /* f18-f19 */ - double f20; /* f20-f21 */ - double f22; /* f22-f23 */ - double f24; /* f24-f25 */ - double f26; /* f26-f27 */ - double f28; /* f28-f29 */ - double f30; /* f30-f31 */ - double f32; - double f34; - double f36; - double f38; - double f40; - double f42; - double f44; - double f46; - double f48; - double f50; - double f52; - double f54; - double f56; - double f58; - double f60; - double f62; - uint64_t fsr; -} Context_Control_fp; - -#endif /* !ASM */ - -/* - * Offsets of fields with Context_Control_fp for assembly routines. - */ - -#define FO_OFFSET 0x00 -#define F2_OFFSET 0x08 -#define F4_OFFSET 0x10 -#define F6_OFFSET 0x18 -#define F8_OFFSET 0x20 -#define F1O_OFFSET 0x28 -#define F12_OFFSET 0x30 -#define F14_OFFSET 0x38 -#define F16_OFFSET 0x40 -#define F18_OFFSET 0x48 -#define F2O_OFFSET 0x50 -#define F22_OFFSET 0x58 -#define F24_OFFSET 0x60 -#define F26_OFFSET 0x68 -#define F28_OFFSET 0x70 -#define F3O_OFFSET 0x78 -#define F32_OFFSET 0x80 -#define F34_OFFSET 0x88 -#define F36_OFFSET 0x90 -#define F38_OFFSET 0x98 -#define F4O_OFFSET 0xA0 -#define F42_OFFSET 0xA8 -#define F44_OFFSET 0xB0 -#define F46_OFFSET 0xB8 -#define F48_OFFSET 0xC0 -#define F5O_OFFSET 0xC8 -#define F52_OFFSET 0xD0 -#define F54_OFFSET 0xD8 -#define F56_OFFSET 0xE0 -#define F58_OFFSET 0xE8 -#define F6O_OFFSET 0xF0 -#define F62_OFFSET 0xF8 -#define FSR_OFFSET 0x100 - -#define CONTEXT_CONTROL_FP_SIZE 0x108 - -#ifndef ASM - -/* - * Context saved on stack for an interrupt. - * - * NOTE: The tstate, tpc, and tnpc are saved in this structure - * to allow resetting the TL while still being able to return - * from a trap later. The PIL is saved because - * if this is an external interrupt, we will mask lower - * priority interrupts until finishing. Even though the y register - * is deprecated, gcc still uses it. - */ - -typedef struct { - SPARC64_Minimum_stack_frame Stack_frame; - uint64_t tstate; - uint64_t tpc; - uint64_t tnpc; - uint64_t pil; - uint64_t y; - uint64_t g1; - uint64_t g2; - uint64_t g3; - uint64_t g4; - uint64_t g5; - uint64_t g6; - uint64_t g7; - uint64_t o0; - uint64_t o1; - uint64_t o2; - uint64_t o3; - uint64_t o4; - uint64_t o5; - uint64_t o6_sp; - uint64_t o7; - uint64_t tvec; -} CPU_Interrupt_frame; - -#endif /* ASM */ - -/* - * Offsets of fields with CPU_Interrupt_frame for assembly routines. - */ - -#define ISF_TSTATE_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x00 -#define ISF_TPC_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x08 -#define ISF_TNPC_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x10 -#define ISF_PIL_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x18 -#define ISF_Y_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x20 -#define ISF_G1_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x28 -#define ISF_G2_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x30 -#define ISF_G3_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x38 -#define ISF_G4_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x40 -#define ISF_G5_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x48 -#define ISF_G6_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x50 -#define ISF_G7_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x58 -#define ISF_O0_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x60 -#define ISF_O1_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x68 -#define ISF_O2_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x70 -#define ISF_O3_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x78 -#define ISF_O4_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x80 -#define ISF_O5_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x88 -#define ISF_O6_SP_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x90 -#define ISF_O7_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0x98 -#define ISF_TVEC_OFFSET SPARC64_MINIMUM_STACK_FRAME_SIZE + 0xA0 - -#define CONTEXT_CONTROL_INTERRUPT_FRAME_SIZE SPARC64_MINIMUM_STACK_FRAME_SIZE + 0xA8 -#ifndef ASM -/* - * This variable is contains the initialize context for the FP unit. - * It is filled in by _CPU_Initialize and copied into the task's FP - * context area during _CPU_Context_Initialize. - */ - -extern Context_Control_fp _CPU_Null_fp_context; - -/* - * This flag is context switched with each thread. It indicates - * that THIS thread has an _ISR_Dispatch stack frame on its stack. - * By using this flag, we can avoid nesting more interrupt dispatching - * attempts on a previously interrupted thread's stack. - */ - -extern volatile uint32_t _CPU_ISR_Dispatch_disable; - -/* - * The following type defines an entry in the SPARC's trap table. - * - * NOTE: The instructions chosen are RTEMS dependent although one is - * obligated to use two of the four instructions to perform a - * long jump. The other instructions load one register with the - * trap type (a.k.a. vector) and another with the psr. - */ -/* For SPARC V9, we must use 6 of these instructions to perform a long - * jump, because the _handler value is now 64-bits. We also need to store - * temporary values in the global register set at this trap level. Because - * the handler runs at TL > 0 with GL > 0, it should be OK to use g2 and g3 - * to pass parameters to ISR_Handler. - * - * The instruction sequence is now more like: - * rdpr %tstate, %g4 - * setx _handler, %g2, %g3 - * jmp %g3+0 - * mov _vector, %g2 - */ -typedef struct { - uint32_t rdpr_tstate_g4; /* rdpr %tstate, %g4 */ - uint32_t sethi_of_hh_handler_to_g2; /* sethi %hh(_handler), %g2 */ - uint32_t or_g2_hm_handler_to_g2; /* or %l3, %hm(_handler), %g2 */ - uint32_t sllx_g2_by_32_to_g2; /* sllx %g2, 32, %g2 */ - uint32_t sethi_of_handler_to_g3; /* sethi %hi(_handler), %g3 */ - uint32_t or_g3_g2_to_g3; /* or %g3, %g2, %g3 */ - uint32_t jmp_to_low_of_handler_plus_g3; /* jmp %g3 + %lo(_handler) */ - uint32_t mov_vector_g2; /* mov _vector, %g2 */ -} CPU_Trap_table_entry; - -/* - * This is the set of opcodes for the instructions loaded into a trap - * table entry. The routine which installs a handler is responsible - * for filling in the fields for the _handler address and the _vector - * trap type. - * - * The constants following this structure are masks for the fields which - * must be filled in when the handler is installed. - */ - -extern const CPU_Trap_table_entry _CPU_Trap_slot_template; - -/* - * The size of the floating point context area. - */ - -#define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp ) - -#endif - -/* - * Amount of extra stack (above minimum stack size) required by - * MPCI receive server thread. Remember that in a multiprocessor - * system this thread must exist and be able to process all directives. - */ - -#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 1024 - -/* - * This defines the number of entries in the ISR_Vector_table managed - * by the executive. - * - * On the SPARC, there are really only 256 vectors. However, the executive - * has no easy, fast, reliable way to determine which traps are synchronous - * and which are asynchronous. By default, synchronous traps return to the - * instruction which caused the interrupt. So if you install a software - * trap handler as an executive interrupt handler (which is desirable since - * RTEMS takes care of window and register issues), then the executive needs - * to know that the return address is to the trap rather than the instruction - * following the trap. - * - * So vectors 0 through 255 are treated as regular asynchronous traps which - * provide the "correct" return address. Vectors 256 through 512 are assumed - * by the executive to be synchronous and to require that the return address - * be fudged. - * - * If you use this mechanism to install a trap handler which must reexecute - * the instruction which caused the trap, then it should be installed as - * an asynchronous trap. This will avoid the executive changing the return - * address. - */ -/* On SPARC v9, there are 512 vectors. The same philosophy applies to - * vector installation and use, we just provide a larger table. - */ -#define CPU_INTERRUPT_NUMBER_OF_VECTORS 512 -#define CPU_INTERRUPT_MAXIMUM_VECTOR_NUMBER 1023 - -#define SPARC_SYNCHRONOUS_TRAP_BIT_MASK 0x200 -#define SPARC_ASYNCHRONOUS_TRAP( _trap ) (_trap) -#define SPARC_SYNCHRONOUS_TRAP( _trap ) ((_trap) + 512 ) - -#define SPARC_REAL_TRAP_NUMBER( _trap ) ((_trap) % 512) - -/* - * This is defined if the port has a special way to report the ISR nesting - * level. Most ports maintain the variable _ISR_Nest_level. - */ - -#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE - -/* - * Should be large enough to run all tests. This ensures - * that a "reasonable" small application should not have any problems. - * - * This appears to be a fairly generous number for the SPARC since - * represents a call depth of about 20 routines based on the minimum - * stack frame. - */ - -#define CPU_STACK_MINIMUM_SIZE (1024*8) - -#define CPU_SIZEOF_POINTER 8 - -/* - * CPU's worst alignment requirement for data types on a byte boundary. This - * alignment does not take into account the requirements for the stack. - * - * On the SPARC, this is required for double word loads and stores. - * - * Note: quad-word loads/stores need alignment of 16, but currently supported - * architectures do not provide HW implemented quad-word operations. - */ - -#define CPU_ALIGNMENT 8 - -/* - * This number corresponds to the byte alignment requirement for the - * heap handler. This alignment requirement may be stricter than that - * for the data types alignment specified by CPU_ALIGNMENT. It is - * common for the heap to follow the same alignment requirement as - * CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict enough for the heap, - * then this should be set to CPU_ALIGNMENT. - * - * NOTE: This does not have to be a power of 2. It does have to - * be greater or equal to than CPU_ALIGNMENT. - */ - -#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT - -/* - * This number corresponds to the byte alignment requirement for memory - * buffers allocated by the partition manager. This alignment requirement - * may be stricter than that for the data types alignment specified by - * CPU_ALIGNMENT. It is common for the partition to follow the same - * alignment requirement as CPU_ALIGNMENT. If the CPU_ALIGNMENT is strict - * enough for the partition, then this should be set to CPU_ALIGNMENT. - * - * NOTE: This does not have to be a power of 2. It does have to - * be greater or equal to than CPU_ALIGNMENT. - */ - -#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT - -/* - * This number corresponds to the byte alignment requirement for the - * stack. This alignment requirement may be stricter than that for the - * data types alignment specified by CPU_ALIGNMENT. If the CPU_ALIGNMENT - * is strict enough for the stack, then this should be set to 0. - * - * NOTE: This must be a power of 2 either 0 or greater than CPU_ALIGNMENT. - * - * The alignment restrictions for the SPARC are not that strict but this - * should unsure that the stack is always sufficiently alignment that the - * window overflow, underflow, and flush routines can use double word loads - * and stores. - */ - -#define CPU_STACK_ALIGNMENT 16 - -#ifndef ASM - -/* - * ISR handler macros - */ - -/* - * Support routine to initialize the RTEMS vector table after it is allocated. - */ - -#define _CPU_Initialize_vectors() - -/* - * Disable all interrupts for a critical section. The previous - * level is returned in _level. - */ - - #define _CPU_ISR_Disable( _level ) \ - (_level) = sparc_disable_interrupts() - -/* - * Enable interrupts to the previous level (returned by _CPU_ISR_Disable). - * This indicates the end of a critical section. The parameter - * _level is not modified. - */ - -#define _CPU_ISR_Enable( _level ) \ - sparc_enable_interrupts( _level ) - -/* - * This temporarily restores the interrupt to _level before immediately - * disabling them again. This is used to divide long critical - * sections into two or more parts. The parameter _level is not - * modified. - */ - -#define _CPU_ISR_Flash( _level ) \ - sparc_flash_interrupts( _level ) - -RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) -{ - return ( level & SPARC_PSTATE_IE_MASK ) != 0; -} - -/* - * Map interrupt level in task mode onto the hardware that the CPU - * actually provides. Currently, interrupt levels which do not - * map onto the CPU in a straight fashion are undefined. - */ - -#define _CPU_ISR_Set_level( _newlevel ) \ - sparc_enable_interrupts( _newlevel) - -uint32_t _CPU_ISR_Get_level( void ); - -/* end of ISR handler macros */ - -/* Context handler macros */ - -/* - * Initialize the context to a state suitable for starting a - * task after a context restore operation. Generally, this - * involves: - * - * - setting a starting address - * - preparing the stack - * - preparing the stack and frame pointers - * - setting the proper interrupt level in the context - * - initializing the floating point context - * - * NOTE: Implemented as a subroutine for the SPARC port. - */ - -void _CPU_Context_Initialize( - Context_Control *the_context, - void *stack_base, - uint32_t size, - uint32_t new_level, - void *entry_point, - bool is_fp, - void *tls_area -); - -/* - * This macro is invoked from _Thread_Handler to do whatever CPU - * specific magic is required that must be done in the context of - * the thread when it starts. - * - * On the SPARC, this is setting the frame pointer so GDB is happy. - * Make GDB stop unwinding at _Thread_Handler, previous register window - * Frame pointer is 0 and calling address must be a function with starting - * with a SAVE instruction. If return address is leaf-function (no SAVE) - * GDB will not look at prev reg window fp. - * - * _Thread_Handler is known to start with SAVE. - */ - -#define _CPU_Context_Initialization_at_thread_begin() \ - do { \ - __asm__ volatile ("set _Thread_Handler,%%i7\n"::); \ - } while (0) - -/* - * This routine is responsible for somehow restarting the currently - * executing task. - * - * On the SPARC, this is is relatively painless but requires a small - * amount of wrapper code before using the regular restore code in - * of the context switch. - */ - -#define _CPU_Context_Restart_self( _the_context ) \ - _CPU_Context_restore( (_the_context) ); - -/* - * This routine initializes the FP context area passed to it to. - * - * The SPARC allows us to use the simple initialization model - * in which an "initial" FP context was saved into _CPU_Null_fp_context - * at CPU initialization and it is simply copied into the destination - * context. - */ - -#define _CPU_Context_Initialize_fp( _destination ) \ - do { \ - *(*(_destination)) = _CPU_Null_fp_context; \ - } while (0) - -/* end of Context handler macros */ - -/* Fatal Error manager macros */ - -/* - * This routine copies _error into a known place -- typically a stack - * location or a register, optionally disables interrupts, and - * halts/stops the CPU. - */ - -#define _CPU_Fatal_halt( _source, _error ) \ - do { \ - uint32_t level; \ - \ - level = sparc_disable_interrupts(); \ - __asm__ volatile ( "mov %0, %%g1 " : "=r" (level) : "0" (level) ); \ - while (1); /* loop forever */ \ - } while (0) - -/* end of Fatal Error manager macros */ - -/* Bitfield handler macros */ - -/* - * The SPARC port uses the generic C algorithm for bitfield scan if the - * CPU model does not have a scan instruction. - */ - -#if ( SPARC_HAS_BITSCAN == 0 ) -#define CPU_USE_GENERIC_BITFIELD_CODE TRUE -#else -#error "scan instruction not currently supported by RTEMS!!" -#endif - -/* end of Bitfield handler macros */ - -/* Priority handler handler macros */ - -/* - * The SPARC port uses the generic C algorithm for bitfield scan if the - * CPU model does not have a scan instruction. - */ - -#if ( SPARC_HAS_BITSCAN == 1 ) -#error "scan instruction not currently supported by RTEMS!!" -#endif - -/* end of Priority handler macros */ - -/* functions */ - -/* - * _CPU_Initialize - * - * This routine performs CPU dependent initialization. - */ - -void _CPU_Initialize(void); - -/* - * _CPU_ISR_install_raw_handler - * - * This routine installs new_handler to be directly called from the trap - * table. - */ - -void _CPU_ISR_install_raw_handler( - uint32_t vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -/* - * _CPU_ISR_install_vector - * - * This routine installs an interrupt vector. - */ - -void _CPU_ISR_install_vector( - uint64_t vector, - proc_ptr new_handler, - proc_ptr *old_handler -); - -#if (CPU_PROVIDES_IDLE_THREAD_BODY == TRUE) - -/* - * _CPU_Thread_Idle_body - * - * Some SPARC implementations have low power, sleep, or idle modes. This - * tries to take advantage of those models. - */ - -void *_CPU_Thread_Idle_body( uintptr_t ignored ); - -#endif /* CPU_PROVIDES_IDLE_THREAD_BODY */ - -/* - * _CPU_Context_switch - * - * This routine switches from the run context to the heir context. - */ - -void _CPU_Context_switch( - Context_Control *run, - Context_Control *heir -); - -/* - * _CPU_Context_restore - * - * This routine is generally used only to restart self in an - * efficient manner. - */ - -void _CPU_Context_restore( - Context_Control *new_context -) RTEMS_NO_RETURN; - -/* - * _CPU_Context_save_fp - * - * This routine saves the floating point context passed to it. - */ - -void _CPU_Context_save_fp( - Context_Control_fp **fp_context_ptr -); - -/* - * _CPU_Context_restore_fp - * - * This routine restores the floating point context passed to it. - */ - -void _CPU_Context_restore_fp( - Context_Control_fp **fp_context_ptr -); - -static inline void _CPU_Context_volatile_clobber( uintptr_t pattern ) -{ - /* TODO */ -} - -static inline void _CPU_Context_validate( uintptr_t pattern ) -{ - while (1) { - /* TODO */ - } -} - -/* FIXME */ -typedef CPU_Interrupt_frame CPU_Exception_frame; - -void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); - -/* - * CPU_swap_u32 - * - * The following routine swaps the endian format of an unsigned int. - * It must be static because it is referenced indirectly. - * - * This version will work on any processor, but if you come across a better - * way for the SPARC PLEASE use it. The most common way to swap a 32-bit - * entity as shown below is not any more efficient on the SPARC. - * - * swap least significant two bytes with 16-bit rotate - * swap upper and lower 16-bits - * swap most significant two bytes with 16-bit rotate - * - * It is not obvious how the SPARC can do significantly better than the - * generic code. gcc 2.7.0 only generates about 12 instructions for the - * following code at optimization level four (i.e. -O4). - */ - -static inline uint32_t CPU_swap_u32( - uint32_t value -) -{ - uint32_t byte1, byte2, byte3, byte4, swapped; - - byte4 = (value >> 24) & 0xff; - byte3 = (value >> 16) & 0xff; - byte2 = (value >> 8) & 0xff; - byte1 = value & 0xff; - - swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4; - return( swapped ); -} - -#define CPU_swap_u16( value ) \ - (((value&0xff) << 8) | ((value >> 8)&0xff)) - -typedef uint32_t CPU_Counter_ticks; - -CPU_Counter_ticks _CPU_Counter_read( void ); - -static inline CPU_Counter_ticks _CPU_Counter_difference( - CPU_Counter_ticks second, - CPU_Counter_ticks first -) -{ - return second - first; -} - -#endif /* ASM */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/score/cpu/sparc64/rtems/score/cpuatomic.h b/cpukit/score/cpu/sparc64/rtems/score/cpuatomic.h deleted file mode 100644 index 598ee76b20..0000000000 --- a/cpukit/score/cpu/sparc64/rtems/score/cpuatomic.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * COPYRIGHT (c) 2012-2013 Deng Hengyi. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_ATOMIC_CPU_H -#define _RTEMS_SCORE_ATOMIC_CPU_H - -#include - -#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/sparc64/rtems/score/cpuimpl.h b/cpukit/score/cpu/sparc64/rtems/score/cpuimpl.h deleted file mode 100644 index 789f2badd9..0000000000 --- a/cpukit/score/cpu/sparc64/rtems/score/cpuimpl.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @file - * - * @brief CPU Port Implementation API - */ - -/* - * Copyright (c) 2013 embedded brains GmbH - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPUIMPL_H -#define _RTEMS_SCORE_CPUIMPL_H - -#include - -#define CPU_PER_CPU_CONTROL_SIZE 0 - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* ASM */ - -#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/sparc64/rtems/score/sparc64.h b/cpukit/score/cpu/sparc64/rtems/score/sparc64.h deleted file mode 100644 index d20c2ff509..0000000000 --- a/cpukit/score/cpu/sparc64/rtems/score/sparc64.h +++ /dev/null @@ -1,342 +0,0 @@ -/** - * @file - * - * @brief Information Required to Build RTEMS for a Particular Member - * of the SPARC Family - * - * This include file contains information pertaining to the SPARC - * processor family. - */ - -/* - * COPYRIGHT (c) 1989-1999. On-Line Applications Research Corporation (OAR). - * - * This file is based on the SPARC sparc.h file. Modifications are made - * to support the SPARC64 processor. - * COPYRIGHT (c) 2010. Gedare Bloom. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SPARC_H -#define _RTEMS_SCORE_SPARC_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This file contains the information required to build - * RTEMS for a particular member of the "sparc" family. It does - * this by setting variables to indicate which implementation - * dependent features are present in a particular member - * of the family. - * - * Currently recognized feature flags: - * - * + SPARC_HAS_FPU - * 0 - no HW FPU - * 1 - has HW FPU (assumed to be compatible w/90C602) - * - * + SPARC_HAS_BITSCAN - * 0 - does not have scan instructions - * 1 - has scan instruction (not currently implemented) - * - * + SPARC_NUMBER_OF_REGISTER_WINDOWS - * 8 is the most common number supported by SPARC implementations. - * SPARC_PSR_CWP_MASK is derived from this value. - */ - -/* - * Some higher end SPARCs have a bitscan instructions. It would - * be nice to take advantage of them. Right now, there is no - * port to a CPU model with this feature and no (untested) code - * that is based on this feature flag. - */ - -#define SPARC_HAS_BITSCAN 0 - -/* - * This should be OK until a port to a higher end SPARC processor - * is made that has more than 8 register windows. If this cannot - * be determined based on multilib settings (v7/v8/v9), then the - * cpu_asm.S code that depends on this will have to move to libcpu. - * - * SPARC v9 supports from 3 to 32 register windows. - * N_REG_WINDOWS = 8 on UltraSPARC T1 (impl. dep. #2-V8). - */ - -#define SPARC_NUMBER_OF_REGISTER_WINDOWS 8 - -/* - * This should be determined based on some soft float derived - * cpp predefine but gcc does not currently give us that information. - */ - - -#if defined(_SOFT_FLOAT) -#define SPARC_HAS_FPU 0 -#else -#define SPARC_HAS_FPU 1 -#endif - -#if SPARC_HAS_FPU -#define CPU_MODEL_NAME "w/FPU" -#else -#define CPU_MODEL_NAME "w/soft-float" -#endif - -/* - * Define the name of the CPU family. - */ - -#define CPU_NAME "SPARC" - -/* - * Miscellaneous constants - */ - -/* - * The PSR is deprecated and deleted. - * - * The following registers represent fields of the PSR: - * PIL - Processor Interrupt Level register - * CWP - Current Window Pointer register - * VER - Version register - * CCR - Condition Codes Register - * PSTATE - Processor State register - */ - -/* - * PSTATE masks and starting bit positions - * - * NOTE: Reserved bits are ignored. - */ - -#define SPARC_PSTATE_AG_MASK 0x00000001 /* bit 0 */ -#define SPARC_PSTATE_IE_MASK 0x00000002 /* bit 1 */ -#define SPARC_PSTATE_PRIV_MASK 0x00000004 /* bit 2 */ -#define SPARC_PSTATE_AM_MASK 0x00000008 /* bit 3 */ -#define SPARC_PSTATE_PEF_MASK 0x00000010 /* bit 4 */ -#define SPARC_PSTATE_MM_MASK 0x00000040 /* bit 6 */ -#define SPARC_PSTATE_TLE_MASK 0x00000100 /* bit 8 */ -#define SPARC_PSTATE_CLE_MASK 0x00000200 /* bit 9 */ - -#define SPARC_PSTATE_AG_BIT_POSITION 0 /* bit 0 */ -#define SPARC_PSTATE_IE_BIT_POSITION 1 /* bit 1 */ -#define SPARC_PSTATE_PRIV_BIT_POSITION 2 /* bit 2 */ -#define SPARC_PSTATE_AM_BIT_POSITION 3 /* bit 3 */ -#define SPARC_PSTATE_PEF_BIT_POSITION 4 /* bit 4 */ -#define SPARC_PSTATE_MM_BIT_POSITION 6 /* bit 6 */ -#define SPARC_PSTATE_TLE_BIT_POSITION 8 /* bit 8 */ -#define SPARC_PSTATE_CLE_BIT_POSITION 9 /* bit 9 */ - -#define SPARC_FPRS_FEF_MASK 0x0100 /* bit 2 */ -#define SPARC_FPRS_FEF_BIT_POSITION 2 /* bit 2 */ - -#define SPARC_TSTATE_IE_MASK 0x00000200 /* bit 9 */ - -#define SPARC_SOFTINT_TM_MASK 0x00000001 /* bit 0 */ -#define SPARC_SOFTINT_SM_MASK 0x00010000 /* bit 16 */ -#define SPARC_SOFTINT_TM_BIT_POSITION 1 /* bit 0 */ -#define SPARC_SOFTINT_SM_BIT_POSITION 17 /* bit 16 */ - -#define STACK_BIAS (2047) - -#ifdef ASM - -/* - * To enable the FPU we need to set both PSTATE.pef and FPRS.fef - */ - -#define sparc64_enable_FPU(rtmp1) \ - rdpr %pstate, rtmp1; \ - or rtmp1, SPARC_PSTATE_PEF_MASK, rtmp1; \ - wrpr %g0, rtmp1, %pstate; \ - rd %fprs, rtmp1; \ - or rtmp1, SPARC_FPRS_FEF_MASK, rtmp1; \ - wr %g0, rtmp1, %fprs - - -#endif - -#ifndef ASM - -/* - * Standard nop - */ - -#define nop() \ - do { \ - __asm__ volatile ( "nop" ); \ - } while ( 0 ) - -/* - * Get and set the pstate - */ - -#define sparc64_get_pstate( _pstate ) \ - do { \ - (_pstate) = 0; \ - __asm__ volatile( "rdpr %%pstate, %0" : "=r" (_pstate) : "0" (_pstate) ); \ - } while ( 0 ) - -#define sparc64_set_pstate( _pstate ) \ - do { \ - __asm__ volatile ( \ - "wrpr %%g0, %0, %%pstate " : "=r" ((_pstate)) : "0" ((_pstate)) ); \ - } while ( 0 ) - -/* - * Get and set the PIL - */ - -#define sparc64_get_pil( _pil ) \ - do { \ - (_pil) = 0; \ - __asm__ volatile( "rdpr %%pil, %0" : "=r" (_pil) : "0" (_pil) ); \ - } while ( 0 ) - -#define sparc64_set_pil( _pil ) \ - do { \ - __asm__ volatile ( "wrpr %%g0, %0, %%pil " : "=r" ((_pil)) : "0" ((_pil)) ); \ - } while ( 0 ) - - -/* - * Get and set the TBA - */ - -#define sparc64_get_tba( _tba ) \ - do { \ - (_tba) = 0; /* to avoid unitialized warnings */ \ - __asm__ volatile( "rdpr %%tba, %0" : "=r" (_tba) : "0" (_tba) ); \ - } while ( 0 ) - -#define sparc64_set_tba( _tba ) \ - do { \ - __asm__ volatile( "wrpr %%g0, %0, %%tba" : "=r" (_tba) : "0" (_tba) ); \ - } while ( 0 ) - -/* - * Get and set the TL (trap level) - */ - -#define sparc64_get_tl( _tl ) \ - do { \ - (_tl) = 0; /* to avoid unitialized warnings */ \ - __asm__ volatile( "rdpr %%tl, %0" : "=r" (_tl) : "0" (_tl) ); \ - } while ( 0 ) - -#define sparc64_set_tl( _tl ) \ - do { \ - __asm__ volatile( "wrpr %%g0, %0, %%tl" : "=r" (_tl) : "0" (_tl) ); \ - } while ( 0 ) - - -/* - * read the stick register - * - * Note: - * stick asr=24, mnemonic=stick - * Note: stick does not appear to be a valid ASR for US3, although it is - * implemented in US3i. - */ -#define sparc64_read_stick( _stick ) \ - do { \ - (_stick) = 0; \ - __asm__ volatile( "rd %%stick, %0" : "=r" (_stick) : "0" (_stick) ); \ - } while ( 0 ) - -/* - * write the stick_cmpr register - * - * Note: - * stick_cmpr asr=25, mnemonic=stick_cmpr - * Note: stick_cmpr does not appear to be a valid ASR for US3, although it is - * implemented in US3i. - */ -#define sparc64_write_stick_cmpr( _stick_cmpr ) \ - do { \ - __asm__ volatile( "wr %%g0, %0, %%stick_cmpr" : "=r" (_stick_cmpr) \ - : "0" (_stick_cmpr) ); \ - } while ( 0 ) - -/* - * read the Tick register - */ -#define sparc64_read_tick( _tick ) \ - do { \ - (_tick) = 0; \ - __asm__ volatile( "rd %%tick, %0" : "=r" (_tick) : "0" (_tick) ); \ - } while ( 0 ) - -/* - * write the tick_cmpr register - */ -#define sparc64_write_tick_cmpr( _tick_cmpr ) \ - do { \ - __asm__ volatile( "wr %%g0, %0, %%tick_cmpr" : "=r" (_tick_cmpr) \ - : "0" (_tick_cmpr) ); \ - } while ( 0 ) - -/* - * Clear the softint register. - * - * sun4u and sun4v: softint_clr asr = 21, with mnemonic clear_softint - */ -#define sparc64_clear_interrupt_bits( _bit_mask ) \ - do { \ - __asm__ volatile( "wr %%g0, %0, %%clear_softint" : "=r" (_bit_mask) \ - : "0" (_bit_mask)); \ - } while ( 0 ) - -/************* DEPRECATED ****************/ -/* Note: Although the y register is deprecated, gcc still uses it */ -/* - * Get and set the Y - */ - -#define sparc_get_y( _y ) \ - do { \ - __asm__ volatile( "rd %%y, %0" : "=r" (_y) : "0" (_y) ); \ - } while ( 0 ) - -#define sparc_set_y( _y ) \ - do { \ - __asm__ volatile( "wr %0, %%y" : "=r" (_y) : "0" (_y) ); \ - } while ( 0 ) - -/************* /DEPRECATED ****************/ - -/* - * Manipulate the interrupt level in the pstate - */ - -uint32_t sparc_disable_interrupts(void); -void sparc_enable_interrupts(uint32_t); - -#define sparc_flash_interrupts( _level ) \ - do { \ - uint32_t _ignored; \ - \ - sparc_enable_interrupts( (_level) ); \ - _ignored = sparc_disable_interrupts(); \ - (void) _ignored; \ - } while ( 0 ) - -#define sparc64_get_interrupt_level( _level ) \ - do { \ - _level = 0; \ - sparc64_get_pil( _level ); \ - } while ( 0 ) - -#endif /* !ASM */ - -#ifdef __cplusplus -} -#endif - -#endif /* _RTEMS_SCORE_SPARC_H */ diff --git a/cpukit/score/cpu/sparc64/rtems/score/types.h b/cpukit/score/cpu/sparc64/rtems/score/types.h deleted file mode 100644 index faf50b7a55..0000000000 --- a/cpukit/score/cpu/sparc64/rtems/score/types.h +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @file - * - * @brief SPARC64 CPU Type Definitions - * - * This include file contains type definitions pertaining to the - * SPARC-v9 processor family. - */ - -/* - * COPYRIGHT (c) 1989-1999. On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_TYPES_H -#define _RTEMS_SCORE_TYPES_H - -#include - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This section defines the basic types for this processor. - */ - -/** Type that can store a 32-bit integer or a pointer. */ -typedef uintptr_t CPU_Uint32ptr; - -typedef void sparc_isr; -typedef void ( *sparc_isr_entry )( void ); - -#ifdef __cplusplus -} -#endif - -#endif /* !ASM */ - -#endif diff --git a/cpukit/score/cpu/v850/Makefile.am b/cpukit/score/cpu/v850/Makefile.am index 7200f2a097..15867801a5 100644 --- a/cpukit/score/cpu/v850/Makefile.am +++ b/cpukit/score/cpu/v850/Makefile.am @@ -1,15 +1,5 @@ include $(top_srcdir)/automake/compile.am -include_rtemsdir = $(includedir)/rtems -include_rtems_HEADERS = rtems/asm.h - -include_rtems_scoredir = $(includedir)/rtems/score -include_rtems_score_HEADERS = rtems/score/cpu.h -include_rtems_score_HEADERS += rtems/score/cpuimpl.h -include_rtems_score_HEADERS += rtems/score/v850.h -include_rtems_score_HEADERS += rtems/score/cpu_asm.h rtems/score/types.h -include_rtems_score_HEADERS += rtems/score/cpuatomic.h - noinst_LIBRARIES = libscorecpu.a libscorecpu_a_SOURCES = cpu.c libscorecpu_a_SOURCES += cpu_asm.S @@ -17,5 +7,5 @@ libscorecpu_a_SOURCES += ../no_cpu/cpucounterread.c libscorecpu_a_SOURCES += v850-exception-frame-print.c libscorecpu_a_CPPFLAGS = $(AM_CPPFLAGS) -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am +include $(srcdir)/headers.am diff --git a/cpukit/score/cpu/v850/headers.am b/cpukit/score/cpu/v850/headers.am new file mode 100644 index 0000000000..ea94e64aa2 --- /dev/null +++ b/cpukit/score/cpu/v850/headers.am @@ -0,0 +1,18 @@ +## This file was generated by "./boostrap -H". + +include_machinedir = $(includedir)/machine +include_machine_HEADERS = +include_machine_HEADERS += include/machine/elf_machdep.h + +include_rtemsdir = $(includedir)/rtems +include_rtems_HEADERS = +include_rtems_HEADERS += include/rtems/asm.h + +include_rtems_scoredir = $(includedir)/rtems/score +include_rtems_score_HEADERS = +include_rtems_score_HEADERS += include/rtems/score/cpu.h +include_rtems_score_HEADERS += include/rtems/score/cpu_asm.h +include_rtems_score_HEADERS += include/rtems/score/cpuatomic.h +include_rtems_score_HEADERS += include/rtems/score/cpuimpl.h +include_rtems_score_HEADERS += include/rtems/score/types.h +include_rtems_score_HEADERS += include/rtems/score/v850.h diff --git a/cpukit/score/cpu/v850/include/machine/elf_machdep.h b/cpukit/score/cpu/v850/include/machine/elf_machdep.h new file mode 100644 index 0000000000..b76d1491d6 --- /dev/null +++ b/cpukit/score/cpu/v850/include/machine/elf_machdep.h @@ -0,0 +1,74 @@ +#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB + +#define ELF32_MACHDEP_ID_CASES \ + case EM_V850: \ + break; + +#define ELF32_MACHDEP_ID EM_V850 + + + +#define EF_V850_ARCH 0xf0000000 +#define E_V850_ARCH 0x00000000 +#define E_V850E_ARCH 0x10000000 +#define E_V850E1_ARCH 0x20000000 +#define E_V850E2_ARCH 0x30000000 +#define E_V850E2V3_ARCH 0x40000000 + +#define ARCH_ELFSIZE 32 + + +#define R_V850_NONE 0 +#define R_V850_9_PCREL 1 +#define R_V850_22_PCREL 2 +#define R_V850_HI16_S 3 +#define R_V850_HI16 4 +#define R_V850_LO16 5 +#define R_V850_ABS32 6 +#define R_V850_16 7 +#define R_V850_8 8 +#define R_V850_SDA_16_16_OFFSET 9 +#define R_V850_SDA_15_16_OFFSET 10 +#define R_V850_ZDA_16_16_OFFSET 11 +#define R_V850_ZDA_15_16_OFFSET 12 +#define R_V850_TDA_6_8_OFFSET 13 +#define R_V850_TDA_7_8_OFFSET 14 +#define R_V850_TDA_7_7_OFFSET 15 +#define R_V850_TDA_16_16_OFFSET 16 +#define R_V850_TDA_4_5_OFFSET 17 +#define R_V850_TDA_4_4_OFFSET 18 +#define R_V850_SDA_16_16_SPLIT_OFFSET 19 +#define R_V850_ZDA_16_16_SPLIT_OFFSET 20 +#define R_V850_CALLT_6_7_OFFSET 21 +#define R_V850_CALLT_16_16_OFFSET 22 +#define R_V850_GNU_VTINHERIT 23 +#define R_V850_GNU_VTENTRY 24 +#define R_V850_LONGCALL 25 +#define R_V850_LONGJUMP 26 +#define R_V850_ALIGN 27 +#define R_V850_REL32 28 +#define R_V850_LO16_SPLIT_OFFSET 29 +#define R_V850_16_PCREL 30 +#define R_V850_17_PCREL 31 +#define R_V850_23 32 +#define R_V850_32_PCREL 33 +#define R_V850_32_ABS 34 +#define R_V850_16_SPLIT_OFFSET 35 +#define R_V850_16_S1 36 +#define R_V850_LO16_S1 37 +#define R_V850_CALLT_15_16_OFFSET 38 +#define R_V850_32_GOTPCREL 39 +#define R_V850_16_GOT 40 +#define R_V850_32_GOT 41 +#define R_V850_22_PLT 42 +#define R_V850_32_PLT 43 +#define R_V850_COPY 44 +#define R_V850_GLOB_DAT 45 +#define R_V850_JMP_SLOT 46 +#define R_V850_RELATIVE 47 +#define R_V850_16_GOTOFF 48 +#define R_V850_32_GOTOFF 49 +#define R_V850_CODE 50 +#define R_V850_DATA 51 + +#define R_TYPE(name) __CONCAT(R_V850_,name) diff --git a/cpukit/score/cpu/v850/include/rtems/asm.h b/cpukit/score/cpu/v850/include/rtems/asm.h new file mode 100644 index 0000000000..265e4967ae --- /dev/null +++ b/cpukit/score/cpu/v850/include/rtems/asm.h @@ -0,0 +1,127 @@ +/** + * @file + * + * @brief Address the Problems Caused by Incompatible Flavor of + * Assemblers and Toolsets + * + * This include file attempts to address the problems + * caused by incompatible flavors of assemblers and + * toolsets. It primarily addresses variations in the + * use of leading underscores on symbols and the requirement + * that register names be preceded by a %. + * + * @note The spacing in the use of these macros + * is critical to them working as advertised. + */ + +/* + * COPYRIGHT: + * + * This file is based on similar code found in newlib available + * from ftp.cygnus.com. The file which was used had no copyright + * notice. This file is freely distributable as long as the source + * of the file is noted. This file is: + * + * COPYRIGHT (c) 1994-2012. + * On-Line Applications Research Corporation (OAR). + */ + +#ifndef _RTEMS_ASM_H +#define _RTEMS_ASM_H + +/* + * Indicate we are in an assembly file and get the basic CPU definitions. + */ + +#ifndef ASM +#define ASM +#endif +#include +#include + +#ifndef __USER_LABEL_PREFIX__ +/** + * Recent versions of GNU cpp define variables which indicate the + * need for underscores and percents. If not using GNU cpp or + * the version does not support this, then you will obviously + * have to define these as appropriate. + * + * This symbol is prefixed to all C program symbols. + */ +#define __USER_LABEL_PREFIX__ _ +#endif + +#ifndef __REGISTER_PREFIX__ +/** + * Recent versions of GNU cpp define variables which indicate the + * need for underscores and percents. If not using GNU cpp or + * the version does not support this, then you will obviously + * have to define these as appropriate. + * + * This symbol is prefixed to all register names. + */ +#define __REGISTER_PREFIX__ +#endif + +#include + +/** Use the right prefix for global labels. */ +#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) + +/** Use the right prefix for registers. */ +#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) + +/* + * define macros for all of the registers on this CPU + * + * EXAMPLE: #define d0 REG (d0) + */ + +/* + * Define macros to handle section beginning and ends. + */ + + +/** This macro is used to denote the beginning of a code declaration. */ +#define BEGIN_CODE_DCL .text +/** This macro is used to denote the end of a code declaration. */ +#define END_CODE_DCL +/** This macro is used to denote the beginning of a data declaration section. */ +#define BEGIN_DATA_DCL .data +/** This macro is used to denote the end of a data declaration section. */ +#define END_DATA_DCL +/** This macro is used to denote the beginning of a code section. */ +#define BEGIN_CODE .text +/** This macro is used to denote the end of a code section. */ +#define END_CODE +/** This macro is used to denote the beginning of a data section. */ +#define BEGIN_DATA +/** This macro is used to denote the end of a data section. */ +#define END_DATA +/** + * This macro is used to denote the beginning of the + * unitialized data section. + */ +#define BEGIN_BSS +/** This macro is used to denote the end of the unitialized data section. */ +#define END_BSS +/** This macro is used to denote the end of the assembly file. */ +#define END + +/** + * This macro is used to declare a public global symbol. + * + * @note This must be tailored for a particular flavor of the C compiler. + * They may need to put underscores in front of the symbols. + */ +#define PUBLIC(sym) .globl SYM (sym) + +/** + * This macro is used to prototype a public global symbol. + * + * @note This must be tailored for a particular flavor of the C compiler. + * They may need to put underscores in front of the symbols. + */ +#define EXTERN(sym) .globl SYM (sym) + +#endif diff --git a/cpukit/score/cpu/v850/include/rtems/score/cpu.h b/cpukit/score/cpu/v850/include/rtems/score/cpu.h new file mode 100644 index 0000000000..d3cdf0514a --- /dev/null +++ b/cpukit/score/cpu/v850/include/rtems/score/cpu.h @@ -0,0 +1,951 @@ +/** + * @file + * + * @brief V850 CPU Department Source + * + * This include file contains information pertaining to the v850 + * processor. + */ + +/* + * COPYRIGHT (c) 1989-2012. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPU_H +#define _RTEMS_SCORE_CPU_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* conditional compilation parameters */ + +/** + * Does RTEMS manage a dedicated interrupt stack in software? + * + * If TRUE, then a stack is allocated in @ref _ISR_Handler_initialization. + * If FALSE, nothing is done. + * + * If the CPU supports a dedicated interrupt stack in hardware, + * then it is generally the responsibility of the BSP to allocate it + * and set it up. + * + * If the CPU does not support a dedicated interrupt stack, then + * the porter has two options: (1) execute interrupts on the + * stack of the interrupted task, and (2) have RTEMS manage a dedicated + * interrupt stack. + * + * If this is TRUE, @ref CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. + * + * Only one of @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK and + * @ref CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is + * possible that both are FALSE for a particular CPU. Although it + * is unclear what that would imply about the interrupt processing + * procedure on that CPU. + * + * Port Specific Information: + * + * The v850 does not have support for a hardware interrupt stack. + */ +#define CPU_HAS_SOFTWARE_INTERRUPT_STACK TRUE + +/** + * Does the CPU follow the simple vectored interrupt model? + * + * If TRUE, then RTEMS allocates the vector table it internally manages. + * If FALSE, then the BSP is assumed to allocate and manage the vector + * table + * + * Port Specific Information: + * + * This port uses the Progammable Interrupt Controller interrupt model. + */ +#define CPU_SIMPLE_VECTORED_INTERRUPTS FALSE + +/** + * Does this CPU have hardware support for a dedicated interrupt stack? + * + * If TRUE, then it must be installed during initialization. + * If FALSE, then no installation is performed. + * + * If this is TRUE, @ref CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. + * + * Only one of @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK and + * @ref CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is + * possible that both are FALSE for a particular CPU. Although it + * is unclear what that would imply about the interrupt processing + * procedure on that CPU. + * + * Port Specific Information: + * + * The v850 does not have support for a hardware interrupt stack. + */ +#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE + +/** + * Does RTEMS allocate a dedicated interrupt stack in the Interrupt Manager? + * + * If TRUE, then the memory is allocated during initialization. + * If FALSE, then the memory is allocated during initialization. + * + * This should be TRUE is CPU_HAS_SOFTWARE_INTERRUPT_STACK is TRUE. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define CPU_ALLOCATE_INTERRUPT_STACK TRUE + +/** + * @def CPU_HARDWARE_FP + * + * Does the CPU have hardware floating point? + * + * If TRUE, then the RTEMS_FLOATING_POINT task attribute is supported. + * If FALSE, then the RTEMS_FLOATING_POINT task attribute is ignored. + * + * If there is a FP coprocessor such as the i387 or mc68881, then + * the answer is TRUE. + * + * The macro name "V850_HAS_FPU" should be made CPU specific. + * It indicates whether or not this CPU model has FP support. For + * example, it would be possible to have an i386_nofp CPU model + * which set this to false to indicate that you have an i386 without + * an i387 and wish to leave floating point support out of RTEMS. + */ + +/** + * @def CPU_SOFTWARE_FP + * + * Does the CPU have no hardware floating point and GCC provides a + * software floating point implementation which must be context + * switched? + * + * This feature conditional is used to indicate whether or not there + * is software implemented floating point that must be context + * switched. The determination of whether or not this applies + * is very tool specific and the state saved/restored is also + * compiler specific. + * + * Port Specific Information: + * + * Some v850 models do have IEEE hardware floating point support but + * they do not have any special registers to save or bit(s) which + * determine if the FPU is enabled. In short, there appears to be nothing + * related to the floating point operations which impact the RTEMS + * thread context switch. Thus from an RTEMS perspective, there is really + * no FPU to manage. + */ +#define CPU_HARDWARE_FP FALSE +#define CPU_SOFTWARE_FP FALSE + +/** + * Are all tasks RTEMS_FLOATING_POINT tasks implicitly? + * + * If TRUE, then the RTEMS_FLOATING_POINT task attribute is assumed. + * If FALSE, then the RTEMS_FLOATING_POINT task attribute is followed. + * + * So far, the only CPUs in which this option has been used are the + * HP PA-RISC and PowerPC. On the PA-RISC, The HP C compiler and + * gcc both implicitly used the floating point registers to perform + * integer multiplies. Similarly, the PowerPC port of gcc has been + * seen to allocate floating point local variables and touch the FPU + * even when the flow through a subroutine (like vfprintf()) might + * not use floating point formats. + * + * If a function which you would not think utilize the FP unit DOES, + * then one can not easily predict which tasks will use the FP hardware. + * In this case, this option should be TRUE. + * + * If @ref CPU_HARDWARE_FP is FALSE, then this should be FALSE as well. + * + * Port Specific Information: + * + * This should be false until it has been demonstrated that gcc for the + * v850 generates FPU code when it is unexpected. But even this would + * not matter since there are no FP specific registers or bits which + * would be corrupted if an FP operation occurred in an integer only + * thread. + */ +#define CPU_ALL_TASKS_ARE_FP FALSE + +/** + * Should the IDLE task have a floating point context? + * + * If TRUE, then the IDLE task is created as a RTEMS_FLOATING_POINT task + * and it has a floating point context which is switched in and out. + * If FALSE, then the IDLE task does not have a floating point context. + * + * Setting this to TRUE negatively impacts the time required to preempt + * the IDLE task from an interrupt because the floating point context + * must be saved as part of the preemption. + * + * Port Specific Information: + * + * The IDLE thread should not be using the FPU. Leave this off. + */ +#define CPU_IDLE_TASK_IS_FP FALSE + +/** + * Should the saving of the floating point registers be deferred + * until a context switch is made to another different floating point + * task? + * + * If TRUE, then the floating point context will not be stored until + * necessary. It will remain in the floating point registers and not + * disturned until another floating point task is switched to. + * + * If FALSE, then the floating point context is saved when a floating + * point task is switched out and restored when the next floating point + * task is restored. The state of the floating point registers between + * those two operations is not specified. + * + * If the floating point context does NOT have to be saved as part of + * interrupt dispatching, then it should be safe to set this to TRUE. + * + * Setting this flag to TRUE results in using a different algorithm + * for deciding when to save and restore the floating point context. + * The deferred FP switch algorithm minimizes the number of times + * the FP context is saved and restored. The FP context is not saved + * until a context switch is made to another, different FP task. + * Thus in a system with only one FP task, the FP context will never + * be saved or restored. + * + * Port Specific Information: + * + * See earlier comments. There is no FPU state to manage. + */ +#define CPU_USE_DEFERRED_FP_SWITCH TRUE + +#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE + +/** + * Does this port provide a CPU dependent IDLE task implementation? + * + * If TRUE, then the routine @ref _CPU_Thread_Idle_body + * must be provided and is the default IDLE thread body instead of + * @ref _CPU_Thread_Idle_body. + * + * If FALSE, then use the generic IDLE thread body if the BSP does + * not provide one. + * + * This is intended to allow for supporting processors which have + * a low power or idle mode. When the IDLE thread is executed, then + * the CPU can be powered down. + * + * The order of precedence for selecting the IDLE thread body is: + * + * -# BSP provided + * -# CPU dependent (if provided) + * -# generic (if no BSP and no CPU dependent) + * + * Port Specific Information: + * + * There does not appear to be a reason for the v850 port itself to provide + * a special idle task. + */ +#define CPU_PROVIDES_IDLE_THREAD_BODY FALSE + +/** + * Does the stack grow up (toward higher addresses) or down + * (toward lower addresses)? + * + * If TRUE, then the grows upward. + * If FALSE, then the grows toward smaller addresses. + * + * Port Specific Information: + * + * The v850 stack grows from high addresses to low addresses. + */ +#define CPU_STACK_GROWS_UP FALSE + +/* FIXME: Is this the right value? */ +#define CPU_CACHE_LINE_BYTES 32 + +#define CPU_STRUCTURE_ALIGNMENT + +/** + * @ingroup CPUInterrupt + * The following defines the number of bits actually used in the + * interrupt field of the task mode. How those bits map to the + * CPU interrupt levels is defined by the routine @ref _CPU_ISR_Set_level. + * + * Port Specific Information: + * + * The v850 only has a single bit in the CPU for interrupt disable/enable. + */ +#define CPU_MODES_INTERRUPT_MASK 0x00000001 + +#define CPU_MAXIMUM_PROCESSORS 32 + +/** + * @defgroup CPUContext Processor Dependent Context Management + * + * From the highest level viewpoint, there are 2 types of context to save. + * + * -# Interrupt registers to save + * -# Task level registers to save + * + * Since RTEMS handles integer and floating point contexts separately, this + * means we have the following 3 context items: + * + * -# task level context stuff:: Context_Control + * -# floating point task stuff:: Context_Control_fp + * -# special interrupt level context :: CPU_Interrupt_frame + * + * On some processors, it is cost-effective to save only the callee + * preserved registers during a task context switch. This means + * that the ISR code needs to save those registers which do not + * persist across function calls. It is not mandatory to make this + * distinctions between the caller/callee saves registers for the + * purpose of minimizing context saved during task switch and on interrupts. + * If the cost of saving extra registers is minimal, simplicity is the + * choice. Save the same context on interrupt entry as for tasks in + * this case. + * + * Additionally, if gdb is to be made aware of RTEMS tasks for this CPU, then + * care should be used in designing the context area. + * + * On some CPUs with hardware floating point support, the Context_Control_fp + * structure will not be used or it simply consist of an array of a + * fixed number of bytes. This is done when the floating point context + * is dumped by a "FP save context" type instruction and the format + * is not really defined by the CPU. In this case, there is no need + * to figure out the exact format -- only the size. Of course, although + * this is enough information for RTEMS, it is probably not enough for + * a debugger such as gdb. But that is another problem. + * + * Port Specific Information: + * + * On the v850, this port saves special registers and those that are + * callee saved. + */ +/**@{**/ + +/** + * This defines the minimal set of integer and processor state registers + * that must be saved during a voluntary context switch from one thread + * to another. + */ +typedef struct { + uint32_t r1; + /** This field is the stack pointer (e.g. r3). */ + uint32_t r3_stack_pointer; + uint32_t r20; + uint32_t r21; + uint32_t r22; + uint32_t r23; + uint32_t r24; + uint32_t r25; + uint32_t r26; + uint32_t r27; + uint32_t r28; + uint32_t r29; + uint32_t r31; + uint32_t psw; +} Context_Control; + +/** + * This macro returns the stack pointer associated with @a _context. + * + * @param[in] _context is the thread context area to access + * + * @return This method returns the stack pointer. + */ +#define _CPU_Context_Get_SP( _context ) \ + (_context)->r3_stack_pointer + +/** + * This defines the complete set of floating point registers that must + * be saved during any context switch from one thread to another. + */ +typedef struct { + /** FPU registers are listed here */ + double some_float_register; +} Context_Control_fp; + +/** + * This defines the set of integer and processor state registers that must + * be saved during an interrupt. This set does not include any which are + * in @ref Context_Control. + */ +typedef struct { + /** This field is a hint that a port will have a number of integer + * registers that need to be saved when an interrupt occurs or + * when a context switch occurs at the end of an ISR. + */ + uint32_t special_interrupt_register; +} CPU_Interrupt_frame; + +/** @} */ + +/** + * @defgroup CPUInterrupt Processor Dependent Interrupt Management + * + * On some CPUs, RTEMS supports a software managed interrupt stack. + * This stack is allocated by the Interrupt Manager and the switch + * is performed in @ref _ISR_Handler. These variables contain pointers + * to the lowest and highest addresses in the chunk of memory allocated + * for the interrupt stack. Since it is unknown whether the stack + * grows up or down (in general), this give the CPU dependent + * code the option of picking the version it wants to use. + * + * @note These two variables are required if the macro + * @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK is defined as TRUE. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +/**@{**/ + +/** + * @ingroup CPUContext + * The size of the floating point context area. On some CPUs this + * will not be a "sizeof" because the format of the floating point + * area is not defined -- only the size is. This is usually on + * CPUs with a "floating point save context" instruction. + * + * Port Specific Information: + * + * The v850 does not need a floating point context but this needs to be + * defined so confdefs.h. + */ +/* #define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp ) */ +#define CPU_CONTEXT_FP_SIZE 0 + +/** + * Amount of extra stack (above minimum stack size) required by + * MPCI receive server thread. Remember that in a multiprocessor + * system this thread must exist and be able to process all directives. + * + * Port Specific Information: + * + * There is no reason to think the v850 needs extra MPCI receive + * server stack. + */ +#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0 + +/** + * This is defined if the port has a special way to report the ISR nesting + * level. Most ports maintain the variable @a _ISR_Nest_level. + */ +#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE + +/** @} */ + +/** + * @ingroup CPUContext + * Should be large enough to run all RTEMS tests. This ensures + * that a "reasonable" small application should not have any problems. + * + * Port Specific Information: + * + * This should be very conservative on the v850. + */ +#define CPU_STACK_MINIMUM_SIZE (1024*4) + +#define CPU_SIZEOF_POINTER 4 + +/** + * CPU's worst alignment requirement for data types on a byte boundary. This + * alignment does not take into account the requirements for the stack. + * + * Port Specific Information: + * + * There is no apparent reason why this should be larger than 8. + */ +#define CPU_ALIGNMENT 8 + +/** + * This number corresponds to the byte alignment requirement for the + * heap handler. This alignment requirement may be stricter than that + * for the data types alignment specified by @ref CPU_ALIGNMENT. It is + * common for the heap to follow the same alignment requirement as + * @ref CPU_ALIGNMENT. If the @ref CPU_ALIGNMENT is strict enough for + * the heap, then this should be set to @ref CPU_ALIGNMENT. + * + * @note This does not have to be a power of 2 although it should be + * a multiple of 2 greater than or equal to 2. The requirement + * to be a multiple of 2 is because the heap uses the least + * significant field of the front and back flags to indicate + * that a block is in use or free. So you do not want any odd + * length blocks really putting length data in that bit. + * + * On byte oriented architectures, @ref CPU_HEAP_ALIGNMENT normally will + * have to be greater or equal to than @ref CPU_ALIGNMENT to ensure that + * elements allocated from the heap meet all restrictions. + * + * Port Specific Information: + * + * There is no apparent reason why this should be larger than CPU_ALIGNMENT. + */ +#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT + +/** + * This number corresponds to the byte alignment requirement for memory + * buffers allocated by the partition manager. This alignment requirement + * may be stricter than that for the data types alignment specified by + * @ref CPU_ALIGNMENT. It is common for the partition to follow the same + * alignment requirement as @ref CPU_ALIGNMENT. If the @ref CPU_ALIGNMENT is + * strict enough for the partition, then this should be set to + * @ref CPU_ALIGNMENT. + * + * @note This does not have to be a power of 2. It does have to + * be greater or equal to than @ref CPU_ALIGNMENT. + * + * Port Specific Information: + * + * There is no apparent reason why this should be larger than CPU_ALIGNMENT. + */ +#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT + +/** + * This number corresponds to the byte alignment requirement for the + * stack. This alignment requirement may be stricter than that for the + * data types alignment specified by @ref CPU_ALIGNMENT. If the + * @ref CPU_ALIGNMENT is strict enough for the stack, then this should be + * set to 0. + * + * @note This must be a power of 2 either 0 or greater than @ref CPU_ALIGNMENT. + * + * Port Specific Information: + * + * The v850 has enough RAM where alignment to 16 may be desirable depending + * on the cache properties. But this remains to be demonstrated. + */ +#define CPU_STACK_ALIGNMENT 4 + +/* + * ISR handler macros + */ + +/** + * @addtogroup CPUInterrupt + */ +/**@{**/ + +/** + * Disable all interrupts for an RTEMS critical section. The previous + * level is returned in @a _isr_cookie. + * + * @param[out] _isr_cookie will contain the previous level cookie + * + * Port Specific Information: + * + * On the v850, we need to save the PSW and use "di" to disable interrupts. + */ +#define _CPU_ISR_Disable( _isr_cookie ) \ + do { \ + unsigned int _psw; \ + \ + v850_get_psw( _psw ); \ + __asm__ __volatile__( "di" ); \ + _isr_cookie = _psw; \ + } while (0) + +/** + * Enable interrupts to the previous level (returned by _CPU_ISR_Disable). + * This indicates the end of an RTEMS critical section. The parameter + * @a _isr_cookie is not modified. + * + * @param[in] _isr_cookie contain the previous level cookie + * + * Port Specific Information: + * + * On the v850, we simply need to restore the PSW. + */ +#define _CPU_ISR_Enable( _isr_cookie ) \ + do { \ + unsigned int _psw = (_isr_cookie); \ + \ + v850_set_psw( _psw ); \ + } while (0) + +/** + * This temporarily restores the interrupt to @a _isr_cookie before immediately + * disabling them again. This is used to divide long RTEMS critical + * sections into two or more parts. The parameter @a _isr_cookie is not + * modified. + * + * @param[in] _isr_cookie contain the previous level cookie + * + * Port Specific Information: + * + * This saves at least one instruction over using enable/disable back to back. + */ +#define _CPU_ISR_Flash( _isr_cookie ) \ + do { \ + unsigned int _psw = (_isr_cookie); \ + v850_set_psw( _psw ); \ + __asm__ __volatile__( "di" ); \ + } while (0) + +RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) +{ + return ( level & V850_PSW_INTERRUPT_DISABLE_MASK ) + != V850_PSW_INTERRUPT_DISABLE; +} + +/** + * This routine and @ref _CPU_ISR_Get_level + * Map the interrupt level in task mode onto the hardware that the CPU + * actually provides. Currently, interrupt levels which do not + * map onto the CPU in a generic fashion are undefined. Someday, + * it would be nice if these were "mapped" by the application + * via a callout. For example, m68k has 8 levels 0 - 7, levels + * 8 - 255 would be available for bsp/application specific meaning. + * This could be used to manage a programmable interrupt controller + * via the rtems_task_mode directive. + * + * Port Specific Information: + * + * On the v850, level 0 is enabled. Non-zero is disabled. + */ +#define _CPU_ISR_Set_level( new_level ) \ + do { \ + if ( new_level ) \ + __asm__ __volatile__( "di" ); \ + else \ + __asm__ __volatile__( "ei" ); \ + } while (0) + +/** + * Return the current interrupt disable level for this task in + * the format used by the interrupt level portion of the task mode. + * + * @note This routine usually must be implemented as a subroutine. + * + * Port Specific Information: + * + * This method is implemented in C on the v850. + */ +uint32_t _CPU_ISR_Get_level( void ); + +/* end of ISR handler macros */ + +/** @} */ + +/* Context handler macros */ + +/** + * @ingroup CPUContext + * Initialize the context to a state suitable for starting a + * task after a context restore operation. Generally, this + * involves: + * + * - setting a starting address + * - preparing the stack + * - preparing the stack and frame pointers + * - setting the proper interrupt level in the context + * - initializing the floating point context + * + * This routine generally does not set any unnecessary register + * in the context. The state of the "general data" registers is + * undefined at task start time. + * + * @param[in] _the_context is the context structure to be initialized + * @param[in] _stack_base is the lowest physical address of this task's stack + * @param[in] _size is the size of this task's stack + * @param[in] _isr is the interrupt disable level + * @param[in] _entry_point is the thread's entry point. This is + * always @a _Thread_Handler + * @param[in] _is_fp is TRUE if the thread is to be a floating + * point thread. This is typically only used on CPUs where the + * FPU may be easily disabled by software such as on the SPARC + * where the PSR contains an enable FPU bit. + * @param[in] tls_area is the thread-local storage (TLS) area + * + * Port Specific Information: + * + * This method is implemented in C on the v850. + */ +void _CPU_Context_Initialize( + Context_Control *the_context, + uint32_t *stack_base, + uint32_t size, + uint32_t new_level, + void *entry_point, + bool is_fp, + void *tls_area +); + +/** + * This routine is responsible for somehow restarting the currently + * executing task. If you are lucky, then all that is necessary + * is restoring the context. Otherwise, there will need to be + * a special assembly routine which does something special in this + * case. For many ports, simply adding a label to the restore path + * of @ref _CPU_Context_switch will work. On other ports, it may be + * possibly to load a few arguments and jump to the restore path. It will + * not work if restarting self conflicts with the stack frame + * assumptions of restoring a context. + * + * Port Specific Information: + * + * On the v850, we require a special entry point to restart a task. + */ +#define _CPU_Context_Restart_self( _the_context ) \ + _CPU_Context_restore( (_the_context) ); + +/* XXX this should be possible to remove */ +#if 0 +/** + * This routine initializes the FP context area passed to it to. + * There are a few standard ways in which to initialize the + * floating point context. The code included for this macro assumes + * that this is a CPU in which a "initial" FP context was saved into + * @a _CPU_Null_fp_context and it simply copies it to the destination + * context passed to it. + * + * Other floating point context save/restore models include: + * -# not doing anything, and + * -# putting a "null FP status word" in the correct place in the FP context. + * + * @param[in] _destination is the floating point context area + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +#define _CPU_Context_Initialize_fp( _destination ) \ + { \ + } +#endif + +/* end of Context handler macros */ + +/* Fatal Error manager macros */ + +/** + * This routine copies _error into a known place -- typically a stack + * location or a register, optionally disables interrupts, and + * halts/stops the CPU. + * + * Port Specific Information: + * + * Move the error code into r10, disable interrupts and halt. + */ +#define _CPU_Fatal_halt( _source, _error ) \ + do { \ + __asm__ __volatile__ ( "di" ); \ + __asm__ __volatile__ ( "mov %0, r10; " : "=r" ((_error)) ); \ + __asm__ __volatile__ ( "halt" ); \ + } while (0) + +/* end of Fatal Error manager macros */ + +#define CPU_USE_GENERIC_BITFIELD_CODE TRUE + +/* functions */ + +/** + * @brief CPU initialize. + * This routine performs CPU dependent initialization. + * + * Port Specific Information: + * + * This is implemented in C. + * + * v850 CPU Dependent Source + */ +void _CPU_Initialize(void); + +/** + * @addtogroup CPUContext + */ +/**@{**/ + +/** + * This routine switches from the run context to the heir context. + * + * @param[in] run points to the context of the currently executing task + * @param[in] heir points to the context of the heir task + * + * Port Specific Information: + * + * This is implemented in assembly on the v850. + */ +void _CPU_Context_switch( + Context_Control *run, + Context_Control *heir +); + +/** + * This routine is generally used only to restart self in an + * efficient manner. It may simply be a label in @ref _CPU_Context_switch. + * + * @param[in] new_context points to the context to be restored. + * + * @note May be unnecessary to reload some registers. + * + * Port Specific Information: + * + * This is implemented in assembly on the v850. + */ +void _CPU_Context_restore( + Context_Control *new_context +) RTEMS_NO_RETURN; + +/* XXX this should be possible to remove */ +#if 0 +/** + * This routine saves the floating point context passed to it. + * + * @param[in] fp_context_ptr is a pointer to a pointer to a floating + * point context area + * + * @return on output @a *fp_context_ptr will contain the address that + * should be used with @ref _CPU_Context_restore_fp to restore this context. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_Context_save_fp( + Context_Control_fp **fp_context_ptr +); +#endif + +/* XXX this should be possible to remove */ +#if 0 +/** + * This routine restores the floating point context passed to it. + * + * @param[in] fp_context_ptr is a pointer to a pointer to a floating + * point context area to restore + * + * @return on output @a *fp_context_ptr will contain the address that + * should be used with @ref _CPU_Context_save_fp to save this context. + * + * Port Specific Information: + * + * XXX document implementation including references if appropriate + */ +void _CPU_Context_restore_fp( + Context_Control_fp **fp_context_ptr +); +#endif + +static inline void _CPU_Context_volatile_clobber( uintptr_t pattern ) +{ + /* TODO */ +} + +static inline void _CPU_Context_validate( uintptr_t pattern ) +{ + while (1) { + /* TODO */ + } +} + +/** @} */ + +/* FIXME */ +typedef CPU_Interrupt_frame CPU_Exception_frame; + +void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); + +/** + * @ingroup CPUEndian + * The following routine swaps the endian format of an unsigned int. + * It must be static because it is referenced indirectly. + * + * This version will work on any processor, but if there is a better + * way for your CPU PLEASE use it. The most common way to do this is to: + * + * swap least significant two bytes with 16-bit rotate + * swap upper and lower 16-bits + * swap most significant two bytes with 16-bit rotate + * + * Some CPUs have special instructions which swap a 32-bit quantity in + * a single instruction (e.g. i486). It is probably best to avoid + * an "endian swapping control bit" in the CPU. One good reason is + * that interrupts would probably have to be disabled to ensure that + * an interrupt does not try to access the same "chunk" with the wrong + * endian. Another good reason is that on some CPUs, the endian bit + * endianness for ALL fetches -- both code and data -- so the code + * will be fetched incorrectly. + * + * @param[in] value is the value to be swapped + * @return the value after being endian swapped + * + * Port Specific Information: + * + * The v850 has a single instruction to swap endianness on a 32 bit quantity. + */ +static inline uint32_t CPU_swap_u32( + uint32_t value +) +{ + unsigned int swapped; + + #if (V850_HAS_BYTE_SWAP_INSTRUCTION == 1) + unsigned int v; + + v = value; + __asm__ __volatile__ ("bsw %0, %1" : "=r" (v), "=&r" (swapped) ); + #else + uint32_t byte1, byte2, byte3, byte4; + + byte4 = (value >> 24) & 0xff; + byte3 = (value >> 16) & 0xff; + byte2 = (value >> 8) & 0xff; + byte1 = value & 0xff; + + swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4; + #endif + return swapped; +} + +/** + * @ingroup CPUEndian + * This routine swaps a 16 bir quantity. + * + * @param[in] value is the value to be swapped + * @return the value after being endian swapped + * + * Port Specific Information: + * + * The v850 has a single instruction to swap endianness on a 16 bit quantity. + */ +static inline uint16_t CPU_swap_u16( uint16_t value ) +{ + unsigned int swapped; + + #if (V850_HAS_BYTE_SWAP_INSTRUCTION == 1) + unsigned int v; + + v = value; + __asm__ __volatile__ ("bsh %0, %1" : "=r" (v), "=&r" (swapped) ); + #else + swapped = ((value & 0xff) << 8) | ((value >> 8) & 0xff); + #endif + return swapped; +} + +typedef uint32_t CPU_Counter_ticks; + +CPU_Counter_ticks _CPU_Counter_read( void ); + +static inline CPU_Counter_ticks _CPU_Counter_difference( + CPU_Counter_ticks second, + CPU_Counter_ticks first +) +{ + return second - first; +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cpukit/score/cpu/v850/include/rtems/score/cpu_asm.h b/cpukit/score/cpu/v850/include/rtems/score/cpu_asm.h new file mode 100644 index 0000000000..8a74cc6410 --- /dev/null +++ b/cpukit/score/cpu/v850/include/rtems/score/cpu_asm.h @@ -0,0 +1,70 @@ +/** + * @file + * + * @brief V850 Assembly File + * Very loose template for an include file for the cpu_asm.? file + * if it is implemented as a ".S" file (preprocessed by cpp) instead + * of a ".s" file (preprocessed by gm4 or gasp). + */ + +/* + * COPYRIGHT (c) 1989-2012. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPU_ASM_H +#define _RTEMS_SCORE_CPU_ASM_H + +/* pull in the generated offsets */ + +#include + +/* + * Hardware General Registers + */ + +/* put something here */ + +/* + * Hardware Floating Point Registers + */ + +/* put something here */ + +/* + * Hardware Control Registers + */ + +/* put something here */ + +/* + * Calling Convention + */ + +/* put something here */ + +/* + * Temporary registers + */ + +/* put something here */ + +/* + * Floating Point Registers - SW Conventions + */ + +/* put something here */ + +/* + * Temporary floating point registers + */ + +/* put something here */ + +#endif + +/* end of file */ diff --git a/cpukit/score/cpu/v850/include/rtems/score/cpuatomic.h b/cpukit/score/cpu/v850/include/rtems/score/cpuatomic.h new file mode 100644 index 0000000000..598ee76b20 --- /dev/null +++ b/cpukit/score/cpu/v850/include/rtems/score/cpuatomic.h @@ -0,0 +1,14 @@ +/* + * COPYRIGHT (c) 2012-2013 Deng Hengyi. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_ATOMIC_CPU_H +#define _RTEMS_SCORE_ATOMIC_CPU_H + +#include + +#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/v850/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/v850/include/rtems/score/cpuimpl.h new file mode 100644 index 0000000000..789f2badd9 --- /dev/null +++ b/cpukit/score/cpu/v850/include/rtems/score/cpuimpl.h @@ -0,0 +1,34 @@ +/** + * @file + * + * @brief CPU Port Implementation API + */ + +/* + * Copyright (c) 2013 embedded brains GmbH + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_CPUIMPL_H +#define _RTEMS_SCORE_CPUIMPL_H + +#include + +#define CPU_PER_CPU_CONTROL_SIZE 0 + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ASM */ + +#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/v850/include/rtems/score/types.h b/cpukit/score/cpu/v850/include/rtems/score/types.h new file mode 100644 index 0000000000..bfec49d284 --- /dev/null +++ b/cpukit/score/cpu/v850/include/rtems/score/types.h @@ -0,0 +1,43 @@ +/** + * @file + * + * @brief V850 CPU Type Definitions + * + * This include file contains type definitions pertaining to the + * v850 processor family. + */ + +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_TYPES_H +#define _RTEMS_SCORE_TYPES_H + +#include + +#ifndef ASM + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This section defines the basic types for this processor. + */ + +/** Type that can store a 32-bit integer or a pointer. */ +typedef uintptr_t CPU_Uint32ptr; + +#ifdef __cplusplus +} +#endif + +#endif /* !ASM */ + +#endif diff --git a/cpukit/score/cpu/v850/include/rtems/score/v850.h b/cpukit/score/cpu/v850/include/rtems/score/v850.h new file mode 100644 index 0000000000..26ab6c209d --- /dev/null +++ b/cpukit/score/cpu/v850/include/rtems/score/v850.h @@ -0,0 +1,137 @@ +/** + * @file + * + * @brief V850 Set up Basic CPU Dependency Settings Based on Compiler Settings + * + * This file sets up basic CPU dependency settings based on + * compiler settings. For example, it can determine if + * floating point is available. This particular implementation + * is specified to the Renesas v850 port. + */ + +/* + * COPYRIGHT (c) 1989-2012. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifndef _RTEMS_SCORE_V850_H +#define _RTEMS_SCORE_V850_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This file contains the information required to build + * RTEMS for a particular member of the NO CPU family. + * It does this by setting variables to indicate which + * implementation dependent features are present in a particular + * member of the family. + * + * This is a good place to list all the known CPU models + * that this port supports and which RTEMS CPU model they correspond + * to. + */ + +#if defined(rtems_multilib) +/* + * Figure out all CPU Model Feature Flags based upon compiler + * predefines. + */ +#define CPU_MODEL_NAME "rtems_multilib" +#define V850_HAS_FPU 0 +#define V850_HAS_BYTE_SWAP_INSTRUCTION 0 + +#elif defined(__v850e2v3__) +#define CPU_MODEL_NAME "v850e2v3" +#define V850_HAS_FPU 1 +#define V850_HAS_BYTE_SWAP_INSTRUCTION 1 + +#elif defined(__v850e2__) +#define CPU_MODEL_NAME "v850e2" +#define V850_HAS_FPU 0 +#define V850_HAS_BYTE_SWAP_INSTRUCTION 1 + +#elif defined(__v850es__) +#define CPU_MODEL_NAME "v850es" +#define V850_HAS_FPU 0 +#define V850_HAS_BYTE_SWAP_INSTRUCTION 1 + +#elif defined(__v850e1__) +#define CPU_MODEL_NAME "v850e1" +#define V850_HAS_FPU 0 +#define V850_HAS_BYTE_SWAP_INSTRUCTION 1 + +#elif defined(__v850e__) +#define CPU_MODEL_NAME "v850e" +#define V850_HAS_FPU 0 +#define V850_HAS_BYTE_SWAP_INSTRUCTION 1 + +#else +#define CPU_MODEL_NAME "v850" +#define V850_HAS_FPU 0 +#define V850_HAS_BYTE_SWAP_INSTRUCTION 0 + +#endif + +/* + * Define the name of the CPU family. + */ +#define CPU_NAME "v850 CPU" + +/* + * Method to set the Program Status Word (PSW) + */ +#define v850_set_psw( _psw ) \ + __asm__ __volatile__( "ldsr %0, psw" : : "r" (_psw) ) + +/* + * Method to obtain the Program Status Word (PSW) + */ +#define v850_get_psw( _psw ) \ + __asm__ __volatile__( "stsr psw, %0" : "=&r" (_psw) ) + +/* + * Masks and bits in the Program Status Word (PSW) + */ +#define V850_PSW_ZERO_MASK 0x01 +#define V850_PSW_IS_ZERO 0x01 +#define V850_PSW_IS_NOT 0x00 + +#define V850_PSW_SIGN_MASK 0x02 +#define V850_PSW_SIGN_IS_NEGATIVE 0x02 +#define V850_PSW_SIGN_IS_ZERO_OR_POSITIVE 0x00 + +#define V850_PSW_OVERFLOW_MASK 0x02 +#define V850_PSW_OVERFLOW_OCCURRED 0x02 +#define V850_PSW_OVERFLOW_DID_NOT_OCCUR 0x00 + +#define V850_PSW_CARRY_OR_BORROW_MASK 0x04 +#define V850_PSW_CARRY_OR_BORROW_OCCURRED 0x04 +#define V850_PSW_CARRY_OR_BORROW_DID_NOT_OCCUR 0x00 + +#define V850_PSW_SATURATION_MASK 0x10 +#define V850_PSW_SATURATION_OCCURRED 0x10 +#define V850_PSW_SATURATION_DID_NOT_OCCUR 0x00 + +#define V850_PSW_INTERRUPT_DISABLE_MASK 0x20 +#define V850_PSW_INTERRUPT_DISABLE 0x20 +#define V850_PSW_INTERRUPT_ENABLE 0x00 + +#define V850_PSW_EXCEPTION_IN_PROCESS_MASK 0x40 +#define V850_PSW_EXCEPTION_IN_PROCESS 0x40 +#define V850_PSW_EXCEPTION_NOT_IN_PROCESS 0x00 + +#define V850_PSW_NMI_IN_PROCESS_MASK 0x80 +#define V850_PSW_NMI_IN_PROCESS 0x80 +#define V850_PSW_NMI_NOT_IN_PROCESS 0x00 + +#ifdef __cplusplus +} +#endif + +#endif /* _RTEMS_SCORE_V850_H */ diff --git a/cpukit/score/cpu/v850/preinstall.am b/cpukit/score/cpu/v850/preinstall.am deleted file mode 100644 index 5acf6a3db5..0000000000 --- a/cpukit/score/cpu/v850/preinstall.am +++ /dev/null @@ -1,53 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -$(PROJECT_INCLUDE)/rtems/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems - @: > $(PROJECT_INCLUDE)/rtems/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/asm.h: rtems/asm.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/asm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/asm.h - -$(PROJECT_INCLUDE)/rtems/score/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/score - @: > $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/score/cpu.h: rtems/score/cpu.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpu.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpu.h - -$(PROJECT_INCLUDE)/rtems/score/cpuimpl.h: rtems/score/cpuimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuimpl.h - -$(PROJECT_INCLUDE)/rtems/score/v850.h: rtems/score/v850.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/v850.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/v850.h - -$(PROJECT_INCLUDE)/rtems/score/cpu_asm.h: rtems/score/cpu_asm.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpu_asm.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpu_asm.h - -$(PROJECT_INCLUDE)/rtems/score/types.h: rtems/score/types.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/types.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/types.h - -$(PROJECT_INCLUDE)/rtems/score/cpuatomic.h: rtems/score/cpuatomic.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuatomic.h - diff --git a/cpukit/score/cpu/v850/rtems/asm.h b/cpukit/score/cpu/v850/rtems/asm.h deleted file mode 100644 index 265e4967ae..0000000000 --- a/cpukit/score/cpu/v850/rtems/asm.h +++ /dev/null @@ -1,127 +0,0 @@ -/** - * @file - * - * @brief Address the Problems Caused by Incompatible Flavor of - * Assemblers and Toolsets - * - * This include file attempts to address the problems - * caused by incompatible flavors of assemblers and - * toolsets. It primarily addresses variations in the - * use of leading underscores on symbols and the requirement - * that register names be preceded by a %. - * - * @note The spacing in the use of these macros - * is critical to them working as advertised. - */ - -/* - * COPYRIGHT: - * - * This file is based on similar code found in newlib available - * from ftp.cygnus.com. The file which was used had no copyright - * notice. This file is freely distributable as long as the source - * of the file is noted. This file is: - * - * COPYRIGHT (c) 1994-2012. - * On-Line Applications Research Corporation (OAR). - */ - -#ifndef _RTEMS_ASM_H -#define _RTEMS_ASM_H - -/* - * Indicate we are in an assembly file and get the basic CPU definitions. - */ - -#ifndef ASM -#define ASM -#endif -#include -#include - -#ifndef __USER_LABEL_PREFIX__ -/** - * Recent versions of GNU cpp define variables which indicate the - * need for underscores and percents. If not using GNU cpp or - * the version does not support this, then you will obviously - * have to define these as appropriate. - * - * This symbol is prefixed to all C program symbols. - */ -#define __USER_LABEL_PREFIX__ _ -#endif - -#ifndef __REGISTER_PREFIX__ -/** - * Recent versions of GNU cpp define variables which indicate the - * need for underscores and percents. If not using GNU cpp or - * the version does not support this, then you will obviously - * have to define these as appropriate. - * - * This symbol is prefixed to all register names. - */ -#define __REGISTER_PREFIX__ -#endif - -#include - -/** Use the right prefix for global labels. */ -#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x) - -/** Use the right prefix for registers. */ -#define REG(x) CONCAT1 (__REGISTER_PREFIX__, x) - -/* - * define macros for all of the registers on this CPU - * - * EXAMPLE: #define d0 REG (d0) - */ - -/* - * Define macros to handle section beginning and ends. - */ - - -/** This macro is used to denote the beginning of a code declaration. */ -#define BEGIN_CODE_DCL .text -/** This macro is used to denote the end of a code declaration. */ -#define END_CODE_DCL -/** This macro is used to denote the beginning of a data declaration section. */ -#define BEGIN_DATA_DCL .data -/** This macro is used to denote the end of a data declaration section. */ -#define END_DATA_DCL -/** This macro is used to denote the beginning of a code section. */ -#define BEGIN_CODE .text -/** This macro is used to denote the end of a code section. */ -#define END_CODE -/** This macro is used to denote the beginning of a data section. */ -#define BEGIN_DATA -/** This macro is used to denote the end of a data section. */ -#define END_DATA -/** - * This macro is used to denote the beginning of the - * unitialized data section. - */ -#define BEGIN_BSS -/** This macro is used to denote the end of the unitialized data section. */ -#define END_BSS -/** This macro is used to denote the end of the assembly file. */ -#define END - -/** - * This macro is used to declare a public global symbol. - * - * @note This must be tailored for a particular flavor of the C compiler. - * They may need to put underscores in front of the symbols. - */ -#define PUBLIC(sym) .globl SYM (sym) - -/** - * This macro is used to prototype a public global symbol. - * - * @note This must be tailored for a particular flavor of the C compiler. - * They may need to put underscores in front of the symbols. - */ -#define EXTERN(sym) .globl SYM (sym) - -#endif diff --git a/cpukit/score/cpu/v850/rtems/score/cpu.h b/cpukit/score/cpu/v850/rtems/score/cpu.h deleted file mode 100644 index d3cdf0514a..0000000000 --- a/cpukit/score/cpu/v850/rtems/score/cpu.h +++ /dev/null @@ -1,951 +0,0 @@ -/** - * @file - * - * @brief V850 CPU Department Source - * - * This include file contains information pertaining to the v850 - * processor. - */ - -/* - * COPYRIGHT (c) 1989-2012. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPU_H -#define _RTEMS_SCORE_CPU_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/* conditional compilation parameters */ - -/** - * Does RTEMS manage a dedicated interrupt stack in software? - * - * If TRUE, then a stack is allocated in @ref _ISR_Handler_initialization. - * If FALSE, nothing is done. - * - * If the CPU supports a dedicated interrupt stack in hardware, - * then it is generally the responsibility of the BSP to allocate it - * and set it up. - * - * If the CPU does not support a dedicated interrupt stack, then - * the porter has two options: (1) execute interrupts on the - * stack of the interrupted task, and (2) have RTEMS manage a dedicated - * interrupt stack. - * - * If this is TRUE, @ref CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. - * - * Only one of @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK and - * @ref CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is - * possible that both are FALSE for a particular CPU. Although it - * is unclear what that would imply about the interrupt processing - * procedure on that CPU. - * - * Port Specific Information: - * - * The v850 does not have support for a hardware interrupt stack. - */ -#define CPU_HAS_SOFTWARE_INTERRUPT_STACK TRUE - -/** - * Does the CPU follow the simple vectored interrupt model? - * - * If TRUE, then RTEMS allocates the vector table it internally manages. - * If FALSE, then the BSP is assumed to allocate and manage the vector - * table - * - * Port Specific Information: - * - * This port uses the Progammable Interrupt Controller interrupt model. - */ -#define CPU_SIMPLE_VECTORED_INTERRUPTS FALSE - -/** - * Does this CPU have hardware support for a dedicated interrupt stack? - * - * If TRUE, then it must be installed during initialization. - * If FALSE, then no installation is performed. - * - * If this is TRUE, @ref CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. - * - * Only one of @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK and - * @ref CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is - * possible that both are FALSE for a particular CPU. Although it - * is unclear what that would imply about the interrupt processing - * procedure on that CPU. - * - * Port Specific Information: - * - * The v850 does not have support for a hardware interrupt stack. - */ -#define CPU_HAS_HARDWARE_INTERRUPT_STACK FALSE - -/** - * Does RTEMS allocate a dedicated interrupt stack in the Interrupt Manager? - * - * If TRUE, then the memory is allocated during initialization. - * If FALSE, then the memory is allocated during initialization. - * - * This should be TRUE is CPU_HAS_SOFTWARE_INTERRUPT_STACK is TRUE. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define CPU_ALLOCATE_INTERRUPT_STACK TRUE - -/** - * @def CPU_HARDWARE_FP - * - * Does the CPU have hardware floating point? - * - * If TRUE, then the RTEMS_FLOATING_POINT task attribute is supported. - * If FALSE, then the RTEMS_FLOATING_POINT task attribute is ignored. - * - * If there is a FP coprocessor such as the i387 or mc68881, then - * the answer is TRUE. - * - * The macro name "V850_HAS_FPU" should be made CPU specific. - * It indicates whether or not this CPU model has FP support. For - * example, it would be possible to have an i386_nofp CPU model - * which set this to false to indicate that you have an i386 without - * an i387 and wish to leave floating point support out of RTEMS. - */ - -/** - * @def CPU_SOFTWARE_FP - * - * Does the CPU have no hardware floating point and GCC provides a - * software floating point implementation which must be context - * switched? - * - * This feature conditional is used to indicate whether or not there - * is software implemented floating point that must be context - * switched. The determination of whether or not this applies - * is very tool specific and the state saved/restored is also - * compiler specific. - * - * Port Specific Information: - * - * Some v850 models do have IEEE hardware floating point support but - * they do not have any special registers to save or bit(s) which - * determine if the FPU is enabled. In short, there appears to be nothing - * related to the floating point operations which impact the RTEMS - * thread context switch. Thus from an RTEMS perspective, there is really - * no FPU to manage. - */ -#define CPU_HARDWARE_FP FALSE -#define CPU_SOFTWARE_FP FALSE - -/** - * Are all tasks RTEMS_FLOATING_POINT tasks implicitly? - * - * If TRUE, then the RTEMS_FLOATING_POINT task attribute is assumed. - * If FALSE, then the RTEMS_FLOATING_POINT task attribute is followed. - * - * So far, the only CPUs in which this option has been used are the - * HP PA-RISC and PowerPC. On the PA-RISC, The HP C compiler and - * gcc both implicitly used the floating point registers to perform - * integer multiplies. Similarly, the PowerPC port of gcc has been - * seen to allocate floating point local variables and touch the FPU - * even when the flow through a subroutine (like vfprintf()) might - * not use floating point formats. - * - * If a function which you would not think utilize the FP unit DOES, - * then one can not easily predict which tasks will use the FP hardware. - * In this case, this option should be TRUE. - * - * If @ref CPU_HARDWARE_FP is FALSE, then this should be FALSE as well. - * - * Port Specific Information: - * - * This should be false until it has been demonstrated that gcc for the - * v850 generates FPU code when it is unexpected. But even this would - * not matter since there are no FP specific registers or bits which - * would be corrupted if an FP operation occurred in an integer only - * thread. - */ -#define CPU_ALL_TASKS_ARE_FP FALSE - -/** - * Should the IDLE task have a floating point context? - * - * If TRUE, then the IDLE task is created as a RTEMS_FLOATING_POINT task - * and it has a floating point context which is switched in and out. - * If FALSE, then the IDLE task does not have a floating point context. - * - * Setting this to TRUE negatively impacts the time required to preempt - * the IDLE task from an interrupt because the floating point context - * must be saved as part of the preemption. - * - * Port Specific Information: - * - * The IDLE thread should not be using the FPU. Leave this off. - */ -#define CPU_IDLE_TASK_IS_FP FALSE - -/** - * Should the saving of the floating point registers be deferred - * until a context switch is made to another different floating point - * task? - * - * If TRUE, then the floating point context will not be stored until - * necessary. It will remain in the floating point registers and not - * disturned until another floating point task is switched to. - * - * If FALSE, then the floating point context is saved when a floating - * point task is switched out and restored when the next floating point - * task is restored. The state of the floating point registers between - * those two operations is not specified. - * - * If the floating point context does NOT have to be saved as part of - * interrupt dispatching, then it should be safe to set this to TRUE. - * - * Setting this flag to TRUE results in using a different algorithm - * for deciding when to save and restore the floating point context. - * The deferred FP switch algorithm minimizes the number of times - * the FP context is saved and restored. The FP context is not saved - * until a context switch is made to another, different FP task. - * Thus in a system with only one FP task, the FP context will never - * be saved or restored. - * - * Port Specific Information: - * - * See earlier comments. There is no FPU state to manage. - */ -#define CPU_USE_DEFERRED_FP_SWITCH TRUE - -#define CPU_ENABLE_ROBUST_THREAD_DISPATCH FALSE - -/** - * Does this port provide a CPU dependent IDLE task implementation? - * - * If TRUE, then the routine @ref _CPU_Thread_Idle_body - * must be provided and is the default IDLE thread body instead of - * @ref _CPU_Thread_Idle_body. - * - * If FALSE, then use the generic IDLE thread body if the BSP does - * not provide one. - * - * This is intended to allow for supporting processors which have - * a low power or idle mode. When the IDLE thread is executed, then - * the CPU can be powered down. - * - * The order of precedence for selecting the IDLE thread body is: - * - * -# BSP provided - * -# CPU dependent (if provided) - * -# generic (if no BSP and no CPU dependent) - * - * Port Specific Information: - * - * There does not appear to be a reason for the v850 port itself to provide - * a special idle task. - */ -#define CPU_PROVIDES_IDLE_THREAD_BODY FALSE - -/** - * Does the stack grow up (toward higher addresses) or down - * (toward lower addresses)? - * - * If TRUE, then the grows upward. - * If FALSE, then the grows toward smaller addresses. - * - * Port Specific Information: - * - * The v850 stack grows from high addresses to low addresses. - */ -#define CPU_STACK_GROWS_UP FALSE - -/* FIXME: Is this the right value? */ -#define CPU_CACHE_LINE_BYTES 32 - -#define CPU_STRUCTURE_ALIGNMENT - -/** - * @ingroup CPUInterrupt - * The following defines the number of bits actually used in the - * interrupt field of the task mode. How those bits map to the - * CPU interrupt levels is defined by the routine @ref _CPU_ISR_Set_level. - * - * Port Specific Information: - * - * The v850 only has a single bit in the CPU for interrupt disable/enable. - */ -#define CPU_MODES_INTERRUPT_MASK 0x00000001 - -#define CPU_MAXIMUM_PROCESSORS 32 - -/** - * @defgroup CPUContext Processor Dependent Context Management - * - * From the highest level viewpoint, there are 2 types of context to save. - * - * -# Interrupt registers to save - * -# Task level registers to save - * - * Since RTEMS handles integer and floating point contexts separately, this - * means we have the following 3 context items: - * - * -# task level context stuff:: Context_Control - * -# floating point task stuff:: Context_Control_fp - * -# special interrupt level context :: CPU_Interrupt_frame - * - * On some processors, it is cost-effective to save only the callee - * preserved registers during a task context switch. This means - * that the ISR code needs to save those registers which do not - * persist across function calls. It is not mandatory to make this - * distinctions between the caller/callee saves registers for the - * purpose of minimizing context saved during task switch and on interrupts. - * If the cost of saving extra registers is minimal, simplicity is the - * choice. Save the same context on interrupt entry as for tasks in - * this case. - * - * Additionally, if gdb is to be made aware of RTEMS tasks for this CPU, then - * care should be used in designing the context area. - * - * On some CPUs with hardware floating point support, the Context_Control_fp - * structure will not be used or it simply consist of an array of a - * fixed number of bytes. This is done when the floating point context - * is dumped by a "FP save context" type instruction and the format - * is not really defined by the CPU. In this case, there is no need - * to figure out the exact format -- only the size. Of course, although - * this is enough information for RTEMS, it is probably not enough for - * a debugger such as gdb. But that is another problem. - * - * Port Specific Information: - * - * On the v850, this port saves special registers and those that are - * callee saved. - */ -/**@{**/ - -/** - * This defines the minimal set of integer and processor state registers - * that must be saved during a voluntary context switch from one thread - * to another. - */ -typedef struct { - uint32_t r1; - /** This field is the stack pointer (e.g. r3). */ - uint32_t r3_stack_pointer; - uint32_t r20; - uint32_t r21; - uint32_t r22; - uint32_t r23; - uint32_t r24; - uint32_t r25; - uint32_t r26; - uint32_t r27; - uint32_t r28; - uint32_t r29; - uint32_t r31; - uint32_t psw; -} Context_Control; - -/** - * This macro returns the stack pointer associated with @a _context. - * - * @param[in] _context is the thread context area to access - * - * @return This method returns the stack pointer. - */ -#define _CPU_Context_Get_SP( _context ) \ - (_context)->r3_stack_pointer - -/** - * This defines the complete set of floating point registers that must - * be saved during any context switch from one thread to another. - */ -typedef struct { - /** FPU registers are listed here */ - double some_float_register; -} Context_Control_fp; - -/** - * This defines the set of integer and processor state registers that must - * be saved during an interrupt. This set does not include any which are - * in @ref Context_Control. - */ -typedef struct { - /** This field is a hint that a port will have a number of integer - * registers that need to be saved when an interrupt occurs or - * when a context switch occurs at the end of an ISR. - */ - uint32_t special_interrupt_register; -} CPU_Interrupt_frame; - -/** @} */ - -/** - * @defgroup CPUInterrupt Processor Dependent Interrupt Management - * - * On some CPUs, RTEMS supports a software managed interrupt stack. - * This stack is allocated by the Interrupt Manager and the switch - * is performed in @ref _ISR_Handler. These variables contain pointers - * to the lowest and highest addresses in the chunk of memory allocated - * for the interrupt stack. Since it is unknown whether the stack - * grows up or down (in general), this give the CPU dependent - * code the option of picking the version it wants to use. - * - * @note These two variables are required if the macro - * @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK is defined as TRUE. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -/**@{**/ - -/** - * @ingroup CPUContext - * The size of the floating point context area. On some CPUs this - * will not be a "sizeof" because the format of the floating point - * area is not defined -- only the size is. This is usually on - * CPUs with a "floating point save context" instruction. - * - * Port Specific Information: - * - * The v850 does not need a floating point context but this needs to be - * defined so confdefs.h. - */ -/* #define CPU_CONTEXT_FP_SIZE sizeof( Context_Control_fp ) */ -#define CPU_CONTEXT_FP_SIZE 0 - -/** - * Amount of extra stack (above minimum stack size) required by - * MPCI receive server thread. Remember that in a multiprocessor - * system this thread must exist and be able to process all directives. - * - * Port Specific Information: - * - * There is no reason to think the v850 needs extra MPCI receive - * server stack. - */ -#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0 - -/** - * This is defined if the port has a special way to report the ISR nesting - * level. Most ports maintain the variable @a _ISR_Nest_level. - */ -#define CPU_PROVIDES_ISR_IS_IN_PROGRESS FALSE - -/** @} */ - -/** - * @ingroup CPUContext - * Should be large enough to run all RTEMS tests. This ensures - * that a "reasonable" small application should not have any problems. - * - * Port Specific Information: - * - * This should be very conservative on the v850. - */ -#define CPU_STACK_MINIMUM_SIZE (1024*4) - -#define CPU_SIZEOF_POINTER 4 - -/** - * CPU's worst alignment requirement for data types on a byte boundary. This - * alignment does not take into account the requirements for the stack. - * - * Port Specific Information: - * - * There is no apparent reason why this should be larger than 8. - */ -#define CPU_ALIGNMENT 8 - -/** - * This number corresponds to the byte alignment requirement for the - * heap handler. This alignment requirement may be stricter than that - * for the data types alignment specified by @ref CPU_ALIGNMENT. It is - * common for the heap to follow the same alignment requirement as - * @ref CPU_ALIGNMENT. If the @ref CPU_ALIGNMENT is strict enough for - * the heap, then this should be set to @ref CPU_ALIGNMENT. - * - * @note This does not have to be a power of 2 although it should be - * a multiple of 2 greater than or equal to 2. The requirement - * to be a multiple of 2 is because the heap uses the least - * significant field of the front and back flags to indicate - * that a block is in use or free. So you do not want any odd - * length blocks really putting length data in that bit. - * - * On byte oriented architectures, @ref CPU_HEAP_ALIGNMENT normally will - * have to be greater or equal to than @ref CPU_ALIGNMENT to ensure that - * elements allocated from the heap meet all restrictions. - * - * Port Specific Information: - * - * There is no apparent reason why this should be larger than CPU_ALIGNMENT. - */ -#define CPU_HEAP_ALIGNMENT CPU_ALIGNMENT - -/** - * This number corresponds to the byte alignment requirement for memory - * buffers allocated by the partition manager. This alignment requirement - * may be stricter than that for the data types alignment specified by - * @ref CPU_ALIGNMENT. It is common for the partition to follow the same - * alignment requirement as @ref CPU_ALIGNMENT. If the @ref CPU_ALIGNMENT is - * strict enough for the partition, then this should be set to - * @ref CPU_ALIGNMENT. - * - * @note This does not have to be a power of 2. It does have to - * be greater or equal to than @ref CPU_ALIGNMENT. - * - * Port Specific Information: - * - * There is no apparent reason why this should be larger than CPU_ALIGNMENT. - */ -#define CPU_PARTITION_ALIGNMENT CPU_ALIGNMENT - -/** - * This number corresponds to the byte alignment requirement for the - * stack. This alignment requirement may be stricter than that for the - * data types alignment specified by @ref CPU_ALIGNMENT. If the - * @ref CPU_ALIGNMENT is strict enough for the stack, then this should be - * set to 0. - * - * @note This must be a power of 2 either 0 or greater than @ref CPU_ALIGNMENT. - * - * Port Specific Information: - * - * The v850 has enough RAM where alignment to 16 may be desirable depending - * on the cache properties. But this remains to be demonstrated. - */ -#define CPU_STACK_ALIGNMENT 4 - -/* - * ISR handler macros - */ - -/** - * @addtogroup CPUInterrupt - */ -/**@{**/ - -/** - * Disable all interrupts for an RTEMS critical section. The previous - * level is returned in @a _isr_cookie. - * - * @param[out] _isr_cookie will contain the previous level cookie - * - * Port Specific Information: - * - * On the v850, we need to save the PSW and use "di" to disable interrupts. - */ -#define _CPU_ISR_Disable( _isr_cookie ) \ - do { \ - unsigned int _psw; \ - \ - v850_get_psw( _psw ); \ - __asm__ __volatile__( "di" ); \ - _isr_cookie = _psw; \ - } while (0) - -/** - * Enable interrupts to the previous level (returned by _CPU_ISR_Disable). - * This indicates the end of an RTEMS critical section. The parameter - * @a _isr_cookie is not modified. - * - * @param[in] _isr_cookie contain the previous level cookie - * - * Port Specific Information: - * - * On the v850, we simply need to restore the PSW. - */ -#define _CPU_ISR_Enable( _isr_cookie ) \ - do { \ - unsigned int _psw = (_isr_cookie); \ - \ - v850_set_psw( _psw ); \ - } while (0) - -/** - * This temporarily restores the interrupt to @a _isr_cookie before immediately - * disabling them again. This is used to divide long RTEMS critical - * sections into two or more parts. The parameter @a _isr_cookie is not - * modified. - * - * @param[in] _isr_cookie contain the previous level cookie - * - * Port Specific Information: - * - * This saves at least one instruction over using enable/disable back to back. - */ -#define _CPU_ISR_Flash( _isr_cookie ) \ - do { \ - unsigned int _psw = (_isr_cookie); \ - v850_set_psw( _psw ); \ - __asm__ __volatile__( "di" ); \ - } while (0) - -RTEMS_INLINE_ROUTINE bool _CPU_ISR_Is_enabled( uint32_t level ) -{ - return ( level & V850_PSW_INTERRUPT_DISABLE_MASK ) - != V850_PSW_INTERRUPT_DISABLE; -} - -/** - * This routine and @ref _CPU_ISR_Get_level - * Map the interrupt level in task mode onto the hardware that the CPU - * actually provides. Currently, interrupt levels which do not - * map onto the CPU in a generic fashion are undefined. Someday, - * it would be nice if these were "mapped" by the application - * via a callout. For example, m68k has 8 levels 0 - 7, levels - * 8 - 255 would be available for bsp/application specific meaning. - * This could be used to manage a programmable interrupt controller - * via the rtems_task_mode directive. - * - * Port Specific Information: - * - * On the v850, level 0 is enabled. Non-zero is disabled. - */ -#define _CPU_ISR_Set_level( new_level ) \ - do { \ - if ( new_level ) \ - __asm__ __volatile__( "di" ); \ - else \ - __asm__ __volatile__( "ei" ); \ - } while (0) - -/** - * Return the current interrupt disable level for this task in - * the format used by the interrupt level portion of the task mode. - * - * @note This routine usually must be implemented as a subroutine. - * - * Port Specific Information: - * - * This method is implemented in C on the v850. - */ -uint32_t _CPU_ISR_Get_level( void ); - -/* end of ISR handler macros */ - -/** @} */ - -/* Context handler macros */ - -/** - * @ingroup CPUContext - * Initialize the context to a state suitable for starting a - * task after a context restore operation. Generally, this - * involves: - * - * - setting a starting address - * - preparing the stack - * - preparing the stack and frame pointers - * - setting the proper interrupt level in the context - * - initializing the floating point context - * - * This routine generally does not set any unnecessary register - * in the context. The state of the "general data" registers is - * undefined at task start time. - * - * @param[in] _the_context is the context structure to be initialized - * @param[in] _stack_base is the lowest physical address of this task's stack - * @param[in] _size is the size of this task's stack - * @param[in] _isr is the interrupt disable level - * @param[in] _entry_point is the thread's entry point. This is - * always @a _Thread_Handler - * @param[in] _is_fp is TRUE if the thread is to be a floating - * point thread. This is typically only used on CPUs where the - * FPU may be easily disabled by software such as on the SPARC - * where the PSR contains an enable FPU bit. - * @param[in] tls_area is the thread-local storage (TLS) area - * - * Port Specific Information: - * - * This method is implemented in C on the v850. - */ -void _CPU_Context_Initialize( - Context_Control *the_context, - uint32_t *stack_base, - uint32_t size, - uint32_t new_level, - void *entry_point, - bool is_fp, - void *tls_area -); - -/** - * This routine is responsible for somehow restarting the currently - * executing task. If you are lucky, then all that is necessary - * is restoring the context. Otherwise, there will need to be - * a special assembly routine which does something special in this - * case. For many ports, simply adding a label to the restore path - * of @ref _CPU_Context_switch will work. On other ports, it may be - * possibly to load a few arguments and jump to the restore path. It will - * not work if restarting self conflicts with the stack frame - * assumptions of restoring a context. - * - * Port Specific Information: - * - * On the v850, we require a special entry point to restart a task. - */ -#define _CPU_Context_Restart_self( _the_context ) \ - _CPU_Context_restore( (_the_context) ); - -/* XXX this should be possible to remove */ -#if 0 -/** - * This routine initializes the FP context area passed to it to. - * There are a few standard ways in which to initialize the - * floating point context. The code included for this macro assumes - * that this is a CPU in which a "initial" FP context was saved into - * @a _CPU_Null_fp_context and it simply copies it to the destination - * context passed to it. - * - * Other floating point context save/restore models include: - * -# not doing anything, and - * -# putting a "null FP status word" in the correct place in the FP context. - * - * @param[in] _destination is the floating point context area - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -#define _CPU_Context_Initialize_fp( _destination ) \ - { \ - } -#endif - -/* end of Context handler macros */ - -/* Fatal Error manager macros */ - -/** - * This routine copies _error into a known place -- typically a stack - * location or a register, optionally disables interrupts, and - * halts/stops the CPU. - * - * Port Specific Information: - * - * Move the error code into r10, disable interrupts and halt. - */ -#define _CPU_Fatal_halt( _source, _error ) \ - do { \ - __asm__ __volatile__ ( "di" ); \ - __asm__ __volatile__ ( "mov %0, r10; " : "=r" ((_error)) ); \ - __asm__ __volatile__ ( "halt" ); \ - } while (0) - -/* end of Fatal Error manager macros */ - -#define CPU_USE_GENERIC_BITFIELD_CODE TRUE - -/* functions */ - -/** - * @brief CPU initialize. - * This routine performs CPU dependent initialization. - * - * Port Specific Information: - * - * This is implemented in C. - * - * v850 CPU Dependent Source - */ -void _CPU_Initialize(void); - -/** - * @addtogroup CPUContext - */ -/**@{**/ - -/** - * This routine switches from the run context to the heir context. - * - * @param[in] run points to the context of the currently executing task - * @param[in] heir points to the context of the heir task - * - * Port Specific Information: - * - * This is implemented in assembly on the v850. - */ -void _CPU_Context_switch( - Context_Control *run, - Context_Control *heir -); - -/** - * This routine is generally used only to restart self in an - * efficient manner. It may simply be a label in @ref _CPU_Context_switch. - * - * @param[in] new_context points to the context to be restored. - * - * @note May be unnecessary to reload some registers. - * - * Port Specific Information: - * - * This is implemented in assembly on the v850. - */ -void _CPU_Context_restore( - Context_Control *new_context -) RTEMS_NO_RETURN; - -/* XXX this should be possible to remove */ -#if 0 -/** - * This routine saves the floating point context passed to it. - * - * @param[in] fp_context_ptr is a pointer to a pointer to a floating - * point context area - * - * @return on output @a *fp_context_ptr will contain the address that - * should be used with @ref _CPU_Context_restore_fp to restore this context. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_Context_save_fp( - Context_Control_fp **fp_context_ptr -); -#endif - -/* XXX this should be possible to remove */ -#if 0 -/** - * This routine restores the floating point context passed to it. - * - * @param[in] fp_context_ptr is a pointer to a pointer to a floating - * point context area to restore - * - * @return on output @a *fp_context_ptr will contain the address that - * should be used with @ref _CPU_Context_save_fp to save this context. - * - * Port Specific Information: - * - * XXX document implementation including references if appropriate - */ -void _CPU_Context_restore_fp( - Context_Control_fp **fp_context_ptr -); -#endif - -static inline void _CPU_Context_volatile_clobber( uintptr_t pattern ) -{ - /* TODO */ -} - -static inline void _CPU_Context_validate( uintptr_t pattern ) -{ - while (1) { - /* TODO */ - } -} - -/** @} */ - -/* FIXME */ -typedef CPU_Interrupt_frame CPU_Exception_frame; - -void _CPU_Exception_frame_print( const CPU_Exception_frame *frame ); - -/** - * @ingroup CPUEndian - * The following routine swaps the endian format of an unsigned int. - * It must be static because it is referenced indirectly. - * - * This version will work on any processor, but if there is a better - * way for your CPU PLEASE use it. The most common way to do this is to: - * - * swap least significant two bytes with 16-bit rotate - * swap upper and lower 16-bits - * swap most significant two bytes with 16-bit rotate - * - * Some CPUs have special instructions which swap a 32-bit quantity in - * a single instruction (e.g. i486). It is probably best to avoid - * an "endian swapping control bit" in the CPU. One good reason is - * that interrupts would probably have to be disabled to ensure that - * an interrupt does not try to access the same "chunk" with the wrong - * endian. Another good reason is that on some CPUs, the endian bit - * endianness for ALL fetches -- both code and data -- so the code - * will be fetched incorrectly. - * - * @param[in] value is the value to be swapped - * @return the value after being endian swapped - * - * Port Specific Information: - * - * The v850 has a single instruction to swap endianness on a 32 bit quantity. - */ -static inline uint32_t CPU_swap_u32( - uint32_t value -) -{ - unsigned int swapped; - - #if (V850_HAS_BYTE_SWAP_INSTRUCTION == 1) - unsigned int v; - - v = value; - __asm__ __volatile__ ("bsw %0, %1" : "=r" (v), "=&r" (swapped) ); - #else - uint32_t byte1, byte2, byte3, byte4; - - byte4 = (value >> 24) & 0xff; - byte3 = (value >> 16) & 0xff; - byte2 = (value >> 8) & 0xff; - byte1 = value & 0xff; - - swapped = (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4; - #endif - return swapped; -} - -/** - * @ingroup CPUEndian - * This routine swaps a 16 bir quantity. - * - * @param[in] value is the value to be swapped - * @return the value after being endian swapped - * - * Port Specific Information: - * - * The v850 has a single instruction to swap endianness on a 16 bit quantity. - */ -static inline uint16_t CPU_swap_u16( uint16_t value ) -{ - unsigned int swapped; - - #if (V850_HAS_BYTE_SWAP_INSTRUCTION == 1) - unsigned int v; - - v = value; - __asm__ __volatile__ ("bsh %0, %1" : "=r" (v), "=&r" (swapped) ); - #else - swapped = ((value & 0xff) << 8) | ((value >> 8) & 0xff); - #endif - return swapped; -} - -typedef uint32_t CPU_Counter_ticks; - -CPU_Counter_ticks _CPU_Counter_read( void ); - -static inline CPU_Counter_ticks _CPU_Counter_difference( - CPU_Counter_ticks second, - CPU_Counter_ticks first -) -{ - return second - first; -} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/score/cpu/v850/rtems/score/cpu_asm.h b/cpukit/score/cpu/v850/rtems/score/cpu_asm.h deleted file mode 100644 index 8a74cc6410..0000000000 --- a/cpukit/score/cpu/v850/rtems/score/cpu_asm.h +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @file - * - * @brief V850 Assembly File - * Very loose template for an include file for the cpu_asm.? file - * if it is implemented as a ".S" file (preprocessed by cpp) instead - * of a ".s" file (preprocessed by gm4 or gasp). - */ - -/* - * COPYRIGHT (c) 1989-2012. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPU_ASM_H -#define _RTEMS_SCORE_CPU_ASM_H - -/* pull in the generated offsets */ - -#include - -/* - * Hardware General Registers - */ - -/* put something here */ - -/* - * Hardware Floating Point Registers - */ - -/* put something here */ - -/* - * Hardware Control Registers - */ - -/* put something here */ - -/* - * Calling Convention - */ - -/* put something here */ - -/* - * Temporary registers - */ - -/* put something here */ - -/* - * Floating Point Registers - SW Conventions - */ - -/* put something here */ - -/* - * Temporary floating point registers - */ - -/* put something here */ - -#endif - -/* end of file */ diff --git a/cpukit/score/cpu/v850/rtems/score/cpuatomic.h b/cpukit/score/cpu/v850/rtems/score/cpuatomic.h deleted file mode 100644 index 598ee76b20..0000000000 --- a/cpukit/score/cpu/v850/rtems/score/cpuatomic.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * COPYRIGHT (c) 2012-2013 Deng Hengyi. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_ATOMIC_CPU_H -#define _RTEMS_SCORE_ATOMIC_CPU_H - -#include - -#endif /* _RTEMS_SCORE_ATOMIC_CPU_H */ diff --git a/cpukit/score/cpu/v850/rtems/score/cpuimpl.h b/cpukit/score/cpu/v850/rtems/score/cpuimpl.h deleted file mode 100644 index 789f2badd9..0000000000 --- a/cpukit/score/cpu/v850/rtems/score/cpuimpl.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @file - * - * @brief CPU Port Implementation API - */ - -/* - * Copyright (c) 2013 embedded brains GmbH - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPUIMPL_H -#define _RTEMS_SCORE_CPUIMPL_H - -#include - -#define CPU_PER_CPU_CONTROL_SIZE 0 - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* ASM */ - -#endif /* _RTEMS_SCORE_CPUIMPL_H */ diff --git a/cpukit/score/cpu/v850/rtems/score/types.h b/cpukit/score/cpu/v850/rtems/score/types.h deleted file mode 100644 index bfec49d284..0000000000 --- a/cpukit/score/cpu/v850/rtems/score/types.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file - * - * @brief V850 CPU Type Definitions - * - * This include file contains type definitions pertaining to the - * v850 processor family. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_TYPES_H -#define _RTEMS_SCORE_TYPES_H - -#include - -#ifndef ASM - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This section defines the basic types for this processor. - */ - -/** Type that can store a 32-bit integer or a pointer. */ -typedef uintptr_t CPU_Uint32ptr; - -#ifdef __cplusplus -} -#endif - -#endif /* !ASM */ - -#endif diff --git a/cpukit/score/cpu/v850/rtems/score/v850.h b/cpukit/score/cpu/v850/rtems/score/v850.h deleted file mode 100644 index 26ab6c209d..0000000000 --- a/cpukit/score/cpu/v850/rtems/score/v850.h +++ /dev/null @@ -1,137 +0,0 @@ -/** - * @file - * - * @brief V850 Set up Basic CPU Dependency Settings Based on Compiler Settings - * - * This file sets up basic CPU dependency settings based on - * compiler settings. For example, it can determine if - * floating point is available. This particular implementation - * is specified to the Renesas v850 port. - */ - -/* - * COPYRIGHT (c) 1989-2012. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_V850_H -#define _RTEMS_SCORE_V850_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This file contains the information required to build - * RTEMS for a particular member of the NO CPU family. - * It does this by setting variables to indicate which - * implementation dependent features are present in a particular - * member of the family. - * - * This is a good place to list all the known CPU models - * that this port supports and which RTEMS CPU model they correspond - * to. - */ - -#if defined(rtems_multilib) -/* - * Figure out all CPU Model Feature Flags based upon compiler - * predefines. - */ -#define CPU_MODEL_NAME "rtems_multilib" -#define V850_HAS_FPU 0 -#define V850_HAS_BYTE_SWAP_INSTRUCTION 0 - -#elif defined(__v850e2v3__) -#define CPU_MODEL_NAME "v850e2v3" -#define V850_HAS_FPU 1 -#define V850_HAS_BYTE_SWAP_INSTRUCTION 1 - -#elif defined(__v850e2__) -#define CPU_MODEL_NAME "v850e2" -#define V850_HAS_FPU 0 -#define V850_HAS_BYTE_SWAP_INSTRUCTION 1 - -#elif defined(__v850es__) -#define CPU_MODEL_NAME "v850es" -#define V850_HAS_FPU 0 -#define V850_HAS_BYTE_SWAP_INSTRUCTION 1 - -#elif defined(__v850e1__) -#define CPU_MODEL_NAME "v850e1" -#define V850_HAS_FPU 0 -#define V850_HAS_BYTE_SWAP_INSTRUCTION 1 - -#elif defined(__v850e__) -#define CPU_MODEL_NAME "v850e" -#define V850_HAS_FPU 0 -#define V850_HAS_BYTE_SWAP_INSTRUCTION 1 - -#else -#define CPU_MODEL_NAME "v850" -#define V850_HAS_FPU 0 -#define V850_HAS_BYTE_SWAP_INSTRUCTION 0 - -#endif - -/* - * Define the name of the CPU family. - */ -#define CPU_NAME "v850 CPU" - -/* - * Method to set the Program Status Word (PSW) - */ -#define v850_set_psw( _psw ) \ - __asm__ __volatile__( "ldsr %0, psw" : : "r" (_psw) ) - -/* - * Method to obtain the Program Status Word (PSW) - */ -#define v850_get_psw( _psw ) \ - __asm__ __volatile__( "stsr psw, %0" : "=&r" (_psw) ) - -/* - * Masks and bits in the Program Status Word (PSW) - */ -#define V850_PSW_ZERO_MASK 0x01 -#define V850_PSW_IS_ZERO 0x01 -#define V850_PSW_IS_NOT 0x00 - -#define V850_PSW_SIGN_MASK 0x02 -#define V850_PSW_SIGN_IS_NEGATIVE 0x02 -#define V850_PSW_SIGN_IS_ZERO_OR_POSITIVE 0x00 - -#define V850_PSW_OVERFLOW_MASK 0x02 -#define V850_PSW_OVERFLOW_OCCURRED 0x02 -#define V850_PSW_OVERFLOW_DID_NOT_OCCUR 0x00 - -#define V850_PSW_CARRY_OR_BORROW_MASK 0x04 -#define V850_PSW_CARRY_OR_BORROW_OCCURRED 0x04 -#define V850_PSW_CARRY_OR_BORROW_DID_NOT_OCCUR 0x00 - -#define V850_PSW_SATURATION_MASK 0x10 -#define V850_PSW_SATURATION_OCCURRED 0x10 -#define V850_PSW_SATURATION_DID_NOT_OCCUR 0x00 - -#define V850_PSW_INTERRUPT_DISABLE_MASK 0x20 -#define V850_PSW_INTERRUPT_DISABLE 0x20 -#define V850_PSW_INTERRUPT_ENABLE 0x00 - -#define V850_PSW_EXCEPTION_IN_PROCESS_MASK 0x40 -#define V850_PSW_EXCEPTION_IN_PROCESS 0x40 -#define V850_PSW_EXCEPTION_NOT_IN_PROCESS 0x00 - -#define V850_PSW_NMI_IN_PROCESS_MASK 0x80 -#define V850_PSW_NMI_IN_PROCESS 0x80 -#define V850_PSW_NMI_NOT_IN_PROCESS 0x00 - -#ifdef __cplusplus -} -#endif - -#endif /* _RTEMS_SCORE_V850_H */ diff --git a/cpukit/score/include/rtems/linkersets.h b/cpukit/score/include/rtems/linkersets.h deleted file mode 100644 index bad046999c..0000000000 --- a/cpukit/score/include/rtems/linkersets.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2015, 2016 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_LINKERSET_H -#define _RTEMS_LINKERSET_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define RTEMS_LINKER_SET_BEGIN( set ) \ - _Linker_set_##set##_begin - -#define RTEMS_LINKER_SET_END( set ) \ - _Linker_set_##set##_end - -#define RTEMS_LINKER_ROSET_DECLARE( set, type ) \ - extern type const RTEMS_LINKER_SET_BEGIN( set )[0]; \ - extern type const RTEMS_LINKER_SET_END( set )[0] - -#define RTEMS_LINKER_ROSET( set, type ) \ - type const RTEMS_LINKER_SET_BEGIN( set )[0] \ - RTEMS_SECTION( ".rtemsroset." #set ".begin" ) RTEMS_USED; \ - type const RTEMS_LINKER_SET_END( set )[0] \ - RTEMS_SECTION( ".rtemsroset." #set ".end" ) RTEMS_USED - -#define RTEMS_LINKER_ROSET_ITEM_DECLARE( set, type, item ) \ - extern type const _Linker_set_##set##_##item - -#define RTEMS_LINKER_ROSET_ITEM_REFERENCE( set, type, item ) \ - static type const * const _Set_reference_##set##_##item \ - RTEMS_SECTION( ".rtemsroset.reference" ) RTEMS_USED = \ - &_Linker_set_##set##_##item - -#define RTEMS_LINKER_ROSET_ITEM_ORDERED( set, type, item, order ) \ - type const _Linker_set_##set##_##item \ - RTEMS_SECTION( ".rtemsroset." #set ".content.0." RTEMS_XSTRING( order ) ) \ - RTEMS_USED - -#define RTEMS_LINKER_ROSET_ITEM( set, type, item ) \ - type const _Linker_set_##set##_##item \ - RTEMS_SECTION( ".rtemsroset." #set ".content.1" ) RTEMS_USED - -#define RTEMS_LINKER_ROSET_CONTENT( set, decl ) \ - decl \ - RTEMS_SECTION( ".rtemsroset." #set ".content" ) - -#define RTEMS_LINKER_RWSET_DECLARE( set, type ) \ - extern type RTEMS_LINKER_SET_BEGIN( set )[0]; \ - extern type RTEMS_LINKER_SET_END( set )[0] - -#define RTEMS_LINKER_RWSET( set, type ) \ - type RTEMS_LINKER_SET_BEGIN( set )[0] \ - RTEMS_SECTION( ".rtemsrwset." #set ".begin" ) RTEMS_USED; \ - type RTEMS_LINKER_SET_END( set )[0] \ - RTEMS_SECTION( ".rtemsrwset." #set ".end" ) RTEMS_USED - -#define RTEMS_LINKER_RWSET_ITEM_DECLARE( set, type, item ) \ - extern type _Linker_set_##set##_##item - -/* - * The .rtemsroset is here not a typo. We must ensure that the references are - * not a victim of the garbage collection of the linker. Thus, we place them - * in a dedicated area of the RTEMS read-only linker set section. - */ -#define RTEMS_LINKER_RWSET_ITEM_REFERENCE( set, type, item ) \ - static type * const _Set_reference_##set##_##item \ - RTEMS_SECTION( ".rtemsroset.reference" ) RTEMS_USED = \ - &_Linker_set_##set##_##item - -#define RTEMS_LINKER_RWSET_ITEM_ORDERED( set, type, item, order ) \ - type _Linker_set_##set##_##item \ - RTEMS_SECTION( ".rtemsrwset." #set ".content.0." RTEMS_XSTRING( order ) ) \ - RTEMS_USED - -#define RTEMS_LINKER_RWSET_ITEM( set, type, item ) \ - type _Linker_set_##set##_##item \ - RTEMS_SECTION( ".rtemsrwset." #set ".content.1" ) RTEMS_USED - -#define RTEMS_LINKER_RWSET_CONTENT( set, decl ) \ - decl \ - RTEMS_SECTION( ".rtemsrwset." #set ".content" ) - -RTEMS_INLINE_ROUTINE uintptr_t _Linker_set_Obfuscate( const void *ptr ) -{ - uintptr_t addr; - - addr = (uintptr_t) ptr; - RTEMS_OBFUSCATE_VARIABLE( addr ); - - return addr; -} - -#define RTEMS_LINKER_SET_SIZE( set ) \ - ( _Linker_set_Obfuscate( RTEMS_LINKER_SET_END( set ) ) \ - - _Linker_set_Obfuscate( RTEMS_LINKER_SET_BEGIN( set ) ) ) - -#define RTEMS_LINKER_SET_ITEM_COUNT( set ) \ - ( RTEMS_LINKER_SET_SIZE( set ) \ - / sizeof( RTEMS_LINKER_SET_BEGIN( set )[ 0 ] ) ) - -#define RTEMS_LINKER_SET_IS_EMPTY( set ) \ - ( RTEMS_LINKER_SET_SIZE( set ) == 0 ) - -#define RTEMS_LINKER_SET_FOREACH( set, item ) \ - for ( \ - item = (void *) _Linker_set_Obfuscate( RTEMS_LINKER_SET_BEGIN( set ) ) ; \ - item != RTEMS_LINKER_SET_END( set ) ; \ - ++item \ - ) - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_LINKERSET_H */ diff --git a/cpukit/score/include/rtems/score/address.h b/cpukit/score/include/rtems/score/address.h deleted file mode 100644 index 8f38f7c2dc..0000000000 --- a/cpukit/score/include/rtems/score/address.h +++ /dev/null @@ -1,200 +0,0 @@ -/** - * @file rtems/score/address.h - * - * @brief Information Required to Manipulate Physical Addresses - * - * This include file contains the information required to manipulate - * physical addresses. - */ - -/* - * COPYRIGHT (c) 1989-2006. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_ADDRESS_H -#define _RTEMS_SCORE_ADDRESS_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ScoreAddress Address Handler - * - * @ingroup Score - * - * This handler encapsulates functionality which abstracts address - * manipulation in a portable manner. - */ -/**@{*/ - -/** - * @brief Add offset to an address. - * - * This function is used to add an @a offset to a @a base address. - * It returns the resulting address. This address is typically - * converted to an access type before being used further. - * - * @param[in] base is the base address. - * @param[in] offset is the offset to add to @a base. - * - * @return This method returns the resulting address. - */ -RTEMS_INLINE_ROUTINE void *_Addresses_Add_offset ( - const void *base, - uintptr_t offset -) -{ - return (void *)((uintptr_t)base + offset); -} - -/** - * @brief Subtract offset from offset. - * - * This function is used to subtract an @a offset from a @a base - * address. It returns the resulting address. This address is - * typically converted to an access type before being used further. - * - * @param[in] base is the base address. - * @param[in] offset is the offset to subtract to @a base. - * - * @return This method returns the resulting address. - */ - -RTEMS_INLINE_ROUTINE void *_Addresses_Subtract_offset ( - const void *base, - uintptr_t offset -) -{ - return (void *)((uintptr_t)base - offset); -} - -/** - * @brief Subtract two offsets. - * - * This function is used to subtract two addresses. It returns the - * resulting offset. - * - * @param[in] left is the address on the left hand side of the subtraction. - * @param[in] right is the address on the right hand side of the subtraction. - * - * @return This method returns the resulting address. - * - * @note The cast of an address to an uint32_t makes this code - * dependent on an addresses being thirty two bits. - */ -RTEMS_INLINE_ROUTINE int32_t _Addresses_Subtract ( - const void *left, - const void *right -) -{ - return (int32_t) ((const char *) left - (const char *) right); -} - -/** - * @brief Is address aligned. - * - * This function returns true if the given address is correctly - * aligned for this processor and false otherwise. Proper alignment - * is based on correctness and efficiency. - * - * @param[in] address is the address being checked for alignment. - * - * @retval true The @a address is aligned. - * @retval false The @a address is not aligned. - */ -RTEMS_INLINE_ROUTINE bool _Addresses_Is_aligned ( - const void *address -) -{ -#if (CPU_ALIGNMENT == 0) - return true; -#else - return (((uintptr_t)address % CPU_ALIGNMENT) == 0); -#endif -} - -/** - * @brief Is address in range. - * - * This function returns true if the given address is within the - * memory range specified and false otherwise. base is the address - * of the first byte in the memory range and limit is the address - * of the last byte in the memory range. The base address is - * assumed to be lower than the limit address. - * - * @param[in] address is the address to check. - * @param[in] base is the lowest address of the range to check against. - * @param[in] limit is the highest address of the range to check against. - * - * @retval true The @a address is within the memory range specified - * @retval false The @a address is not within the memory range specified. - */ -RTEMS_INLINE_ROUTINE bool _Addresses_Is_in_range ( - const void *address, - const void *base, - const void *limit -) -{ - return (address >= base && address <= limit); -} - -/** - * @brief Align address to nearest multiple of alignment, rounding up. - * - * This function returns the given address aligned to the given alignment. - * If the address already is aligned, or if alignment is 0, the address is - * returned as is. The returned address is greater than or equal to the - * given address. - * - * @param[in] address is the address to align. - * @param[in] alignment is the boundary for alignment and must be a power of 2 - * - * @return Returns the aligned address. - */ -RTEMS_INLINE_ROUTINE void *_Addresses_Align_up( - void *address, - size_t alignment -) -{ - uintptr_t mask = alignment - (uintptr_t)1; - return (void*)(((uintptr_t)address + mask) & ~mask); -} - -/** - * @brief Align address to nearest multiple of alignment, truncating. - * - * This function returns the given address aligned to the given alignment. - * If the address already is aligned, or if alignment is 0, the address is - * returned as is. The returned address is less than or equal to the - * given address. - * - * @param[in] address is the address to align. - * @param[in] alignment is the boundary for alignment and must be a power of 2. - * - * @return Returns the aligned address. - */ -RTEMS_INLINE_ROUTINE void *_Addresses_Align_down( - void *address, - size_t alignment -) -{ - uintptr_t mask = alignment - (uintptr_t)1; - return (void*)((uintptr_t)address & ~mask); -} - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/apimutex.h b/cpukit/score/include/rtems/score/apimutex.h deleted file mode 100644 index f43edf23f4..0000000000 --- a/cpukit/score/include/rtems/score/apimutex.h +++ /dev/null @@ -1,109 +0,0 @@ -/** - * @file - * - * @ingroup ScoreAPIMutex - * - * @brief API Mutex Handler API - */ - -/* - * COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_APIMUTEX_H -#define _RTEMS_SCORE_APIMUTEX_H - -#include - -#include - -/** - * @defgroup ScoreAPIMutex API Mutex Handler - * - * @ingroup Score - * - * @brief Provides routines to ensure mutual exclusion on API level. - */ -/**@{**/ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Control block used to manage each API mutex. - */ -typedef struct { - /** - * A recursive mutex. - */ - struct _Mutex_recursive_Control Mutex; - - /** - * @brief The thread life protection state before the outer-most mutex - * obtain. - */ - Thread_Life_state previous_thread_life_state; -} API_Mutex_Control; - -/** - * @brief Statically initialize an API mutex. - */ -#define API_MUTEX_INITIALIZER( name ) \ - { _MUTEX_RECURSIVE_NAMED_INITIALIZER( name ), 0 } - -/** - * @brief Acquires the specified API mutex. - * - * @param[in] mutex The API mutex. - */ -void _API_Mutex_Lock( API_Mutex_Control *mutex ); - -/** - * @brief Releases the specified API mutex. - * - * @param[in] mutex The API mutex. - */ -void _API_Mutex_Unlock( API_Mutex_Control *mutex ); - -/** - * @brief Checks if the specified API mutex is owned by the executing thread. - * - * @param[in] mutex The API mutex. - */ -bool _API_Mutex_Is_owner( const API_Mutex_Control *mutex ); - -/** @} */ - -/** - * @defgroup ScoreAllocatorMutex RTEMS Allocator Mutex - * - * @ingroup ScoreAPIMutex - * - * @brief Protection for all memory allocations and deallocations in RTEMS. - * - * When the APIs all use this for allocation and deallocation protection, then - * this possibly should be renamed and moved to a higher level in the - * hierarchy. - */ -/**@{**/ - -void _RTEMS_Lock_allocator( void ); - -void _RTEMS_Unlock_allocator( void ); - -bool _RTEMS_Allocator_is_owner( void ); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/assert.h b/cpukit/score/include/rtems/score/assert.h deleted file mode 100644 index d4432838ce..0000000000 --- a/cpukit/score/include/rtems/score/assert.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2013-2014 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_ASSERT_H -#define _RTEMS_SCORE_ASSERT_H - -#include - -#if defined( RTEMS_DEBUG ) - #include -#endif - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @brief Assertion similar to assert() controlled via RTEMS_DEBUG instead of - * NDEBUG. - */ -#if defined( RTEMS_DEBUG ) - - /** - * @brief Macro with method name used in assert output - * - * Given the variations in compilers and standards, we have to poke a bit. - * - * @note This is based on the code in newlib's assert.h. - */ - #ifndef __RTEMS_ASSERT_FUNCTION - /* Use g++'s demangled names in C++. */ - #if defined __cplusplus && defined __GNUC__ - #define __RTEMS_ASSERT_FUNCTION __PRETTY_FUNCTION__ - - /* C99 requires the use of __func__. */ - #elif __STDC_VERSION__ >= 199901L - #define __RTEMS_ASSERT_FUNCTION __func__ - - /* Older versions of gcc don't have __func__ but can use __FUNCTION__. */ - #elif __GNUC__ >= 2 - #define __RTEMS_ASSERT_FUNCTION __FUNCTION__ - - /* failed to detect __func__ support. */ - #else - #define __RTEMS_ASSERT_FUNCTION ((char *) 0) - #endif - #endif /* !__RTEMS_ASSERT_FUNCTION */ - - #if !defined( RTEMS_SCHEDSIM ) - /* normal build is newlib. */ - - void __assert_func(const char *, int, const char *, const char *) - RTEMS_NO_RETURN; - - #define _Assert( _e ) \ - ( ( _e ) ? \ - ( void ) 0 : \ - __assert_func( __FILE__, __LINE__, __RTEMS_ASSERT_FUNCTION, #_e ) ) - - #elif defined(__linux__) - /* Scheduler simulator has only beed tested on glibc. */ - #define _Assert( _e ) \ - ( ( _e ) ? \ - ( void ) 0 : \ - __assert_fail( #_e, __FILE__, __LINE__, __RTEMS_ASSERT_FUNCTION ) ) - #else - #error "Implement RTEMS assert support for this C Library" - #endif - -#else - #define _Assert( _e ) ( ( void ) 0 ) -#endif - -/** - * @brief Like _Assert(), but only armed if RTEMS_SMP is defined. - */ -#if defined( RTEMS_SMP ) - #define _SMP_Assert( _e ) _Assert( _e ) -#else - #define _SMP_Assert( _e ) ( ( void ) 0 ) -#endif - -/** - * @brief Returns true if thread dispatching is allowed. - * - * Thread dispatching can be repressed via _Thread_Disable_dispatch() or - * _ISR_Local_disable(). - */ -#if defined( RTEMS_DEBUG ) - bool _Debug_Is_thread_dispatching_allowed( void ); -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_SCORE_ASSERT_H */ diff --git a/cpukit/score/include/rtems/score/atomic.h b/cpukit/score/include/rtems/score/atomic.h deleted file mode 100644 index 526926926f..0000000000 --- a/cpukit/score/include/rtems/score/atomic.h +++ /dev/null @@ -1,156 +0,0 @@ -/** - * @file - * - * @ingroup ScoreAtomic - * - * @brief Atomic Operations API - */ - -/* - * COPYRIGHT (c) 2012-2013 Deng Hengyi. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_ATOMIC_H -#define _RTEMS_SCORE_ATOMIC_H - -#include - -/** - * @defgroup ScoreAtomic Atomic Operations - * - * @ingroup Score - * - * @brief Support for atomic operations. - * - * Atomic operations can be used to implement low-level synchronization - * primitives on SMP systems, like spin locks. All atomic operations are - * defined in terms of C11 (ISO/IEC 9899:2011) or C++11 (ISO/IEC 14882:2011). - * For documentation use the standard documents. - * - * @{ - */ - -typedef CPU_atomic_Uint Atomic_Uint; - -typedef CPU_atomic_Ulong Atomic_Ulong; - -typedef CPU_atomic_Uintptr Atomic_Uintptr; - -typedef CPU_atomic_Flag Atomic_Flag; - -typedef CPU_atomic_Order Atomic_Order; - -#define ATOMIC_ORDER_RELAXED CPU_ATOMIC_ORDER_RELAXED - -#define ATOMIC_ORDER_ACQUIRE CPU_ATOMIC_ORDER_ACQUIRE - -#define ATOMIC_ORDER_RELEASE CPU_ATOMIC_ORDER_RELEASE - -#define ATOMIC_ORDER_ACQ_REL CPU_ATOMIC_ORDER_ACQ_REL - -#define ATOMIC_ORDER_SEQ_CST CPU_ATOMIC_ORDER_SEQ_CST - -#define ATOMIC_INITIALIZER_UINT( value ) CPU_ATOMIC_INITIALIZER_UINT( value ) - -#define ATOMIC_INITIALIZER_ULONG( value ) CPU_ATOMIC_INITIALIZER_ULONG( value ) - -#define ATOMIC_INITIALIZER_UINTPTR( value ) CPU_ATOMIC_INITIALIZER_UINTPTR( value ) - -#define ATOMIC_INITIALIZER_FLAG CPU_ATOMIC_INITIALIZER_FLAG - -#define _Atomic_Fence( order ) _CPU_atomic_Fence( order ) - -#define _Atomic_Init_uint( obj, desired ) \ - _CPU_atomic_Init_uint( obj, desired ) - -#define _Atomic_Init_ulong( obj, desired ) \ - _CPU_atomic_Init_ulong( obj, desired ) - -#define _Atomic_Init_uintptr( obj, desired ) \ - _CPU_atomic_Init_uintptr( obj, desired ) - -#define _Atomic_Load_uint( obj, order ) \ - _CPU_atomic_Load_uint( obj, order ) - -#define _Atomic_Load_ulong( obj, order ) \ - _CPU_atomic_Load_ulong( obj, order ) - -#define _Atomic_Load_uintptr( obj, order ) \ - _CPU_atomic_Load_uintptr( obj, order ) - -#define _Atomic_Store_uint( obj, desr, order ) \ - _CPU_atomic_Store_uint( obj, desr, order ) - -#define _Atomic_Store_ulong( obj, desr, order ) \ - _CPU_atomic_Store_ulong( obj, desr, order ) - -#define _Atomic_Store_uintptr( obj, desr, order ) \ - _CPU_atomic_Store_uintptr( obj, desr, order ) - -#define _Atomic_Fetch_add_uint( obj, arg, order ) \ - _CPU_atomic_Fetch_add_uint( obj, arg, order ) - -#define _Atomic_Fetch_add_ulong( obj, arg, order ) \ - _CPU_atomic_Fetch_add_ulong( obj, arg, order ) - -#define _Atomic_Fetch_add_uintptr( obj, arg, order ) \ - _CPU_atomic_Fetch_add_uintptr( obj, arg, order ) - -#define _Atomic_Fetch_sub_uint( obj, arg, order ) \ - _CPU_atomic_Fetch_sub_uint( obj, arg, order ) - -#define _Atomic_Fetch_sub_ulong( obj, arg, order ) \ - _CPU_atomic_Fetch_sub_ulong( obj, arg, order ) - -#define _Atomic_Fetch_sub_uintptr( obj, arg, order ) \ - _CPU_atomic_Fetch_sub_uintptr( obj, arg, order ) - -#define _Atomic_Fetch_or_uint( obj, arg, order ) \ - _CPU_atomic_Fetch_or_uint( obj, arg, order ) - -#define _Atomic_Fetch_or_ulong( obj, arg, order ) \ - _CPU_atomic_Fetch_or_ulong( obj, arg, order ) - -#define _Atomic_Fetch_or_uintptr( obj, arg, order ) \ - _CPU_atomic_Fetch_or_uintptr( obj, arg, order ) - -#define _Atomic_Fetch_and_uint( obj, arg, order ) \ - _CPU_atomic_Fetch_and_uint( obj, arg, order ) - -#define _Atomic_Fetch_and_ulong( obj, arg, order ) \ - _CPU_atomic_Fetch_and_ulong( obj, arg, order ) - -#define _Atomic_Fetch_and_uintptr( obj, arg, order ) \ - _CPU_atomic_Fetch_and_uintptr( obj, arg, order ) - -#define _Atomic_Exchange_uint( obj, desr, order ) \ - _CPU_atomic_Exchange_uint( obj, desr, order ) - -#define _Atomic_Exchange_ulong( obj, desr, order ) \ - _CPU_atomic_Exchange_ulong( obj, desr, order ) - -#define _Atomic_Exchange_uintptr( obj, desr, order ) \ - _CPU_atomic_Exchange_uintptr( obj, desr, order ) - -#define _Atomic_Compare_exchange_uint( obj, expected, desired, succ, fail ) \ - _CPU_atomic_Compare_exchange_uint( obj, expected, desired, succ, fail ) - -#define _Atomic_Compare_exchange_ulong( obj, expected, desired, succ, fail ) \ - _CPU_atomic_Compare_exchange_ulong( obj, expected, desired, succ, fail ) - -#define _Atomic_Compare_exchange_uintptr( obj, expected, desired, succ, fail ) \ - _CPU_atomic_Compare_exchange_uintptr( obj, expected, desired, succ, fail ) - -#define _Atomic_Flag_clear( obj, order ) \ - _CPU_atomic_Flag_clear( obj, order ) - -#define _Atomic_Flag_test_and_set( obj, order ) \ - _CPU_atomic_Flag_test_and_set( obj, order ) - -/** @} */ - -#endif /* _RTEMS_SCORE_ATOMIC_H */ diff --git a/cpukit/score/include/rtems/score/basedefs.h b/cpukit/score/include/rtems/score/basedefs.h deleted file mode 100644 index 4e48d226e8..0000000000 --- a/cpukit/score/include/rtems/score/basedefs.h +++ /dev/null @@ -1,415 +0,0 @@ -/** - * @file - * - * @ingroup Score - * - * @brief Basic Definitions - */ - -/* - * COPYRIGHT (c) 1989-2007. - * On-Line Applications Research Corporation (OAR). - * - * Copyright (c) 2010, 2017 embedded brains GmbH. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_BASEDEFS_H -#define _RTEMS_BASEDEFS_H - -/** - * @defgroup ScoreBaseDefs Basic Definitions - * - * @ingroup Score - */ -/**@{*/ - -#include - -#ifndef ASM - #include - #include - #include -#endif - -#ifndef TRUE - /** - * This ensures that RTEMS has TRUE defined in all situations. - */ - #define TRUE 1 -#endif - -#ifndef FALSE - /** - * This ensures that RTEMS has FALSE defined in all situations. - */ - #define FALSE 0 -#endif - -#if TRUE == FALSE - #error "TRUE equals FALSE" -#endif - -/** - * The following (in conjunction with compiler arguments) are used - * to choose between the use of static inline functions and macro - * functions. The static inline implementation allows better - * type checking with no cost in code size or execution speed. - */ -#ifdef __GNUC__ - #define RTEMS_INLINE_ROUTINE static __inline__ -#else - #define RTEMS_INLINE_ROUTINE static inline -#endif - -/** - * The following macro is a compiler specific way to ensure that memory - * writes are not reordered around certian points. This specifically can - * impact interrupt disable and thread dispatching critical sections. - */ -#ifdef __GNUC__ - #define RTEMS_COMPILER_MEMORY_BARRIER() __asm__ volatile("" ::: "memory") -#else - #define RTEMS_COMPILER_MEMORY_BARRIER() -#endif - -/** - * The following defines a compiler specific attribute which informs - * the compiler that the method must not be inlined. - */ -#ifdef __GNUC__ - #define RTEMS_NO_INLINE __attribute__((__noinline__)) -#else - #define RTEMS_NO_INLINE -#endif - -/** - * The following macro is a compiler specific way to indicate that - * the method will NOT return to the caller. This can assist the - * compiler in code generation and avoid unreachable paths. This - * can impact the code generated following calls to - * rtems_fatal_error_occurred and _Terminate. - */ -#if defined(RTEMS_SCHEDSIM) - #define RTEMS_NO_RETURN -#elif defined(__GNUC__) && !defined(RTEMS_DEBUG) - #define RTEMS_NO_RETURN __attribute__((__noreturn__)) -#else - #define RTEMS_NO_RETURN -#endif - -/* Provided for backward compatibility */ -#define RTEMS_COMPILER_NO_RETURN_ATTRIBUTE RTEMS_NO_RETURN - -/** - * The following defines a compiler specific attribute which informs - * the compiler that the method has no effect except the return value - * and that the return value depends only on parameters and/or global - * variables. - */ -#ifdef __GNUC__ - #define RTEMS_PURE __attribute__((__pure__)) -#else - #define RTEMS_PURE -#endif - -/* Provided for backward compatibility */ -#define RTEMS_COMPILER_PURE_ATTRIBUTE RTEMS_PURE - -/** - * Instructs the compiler to issue a warning whenever a variable or function - * with this attribute will be used. - */ -#ifdef __GNUC__ - #define RTEMS_DEPRECATED __attribute__((__deprecated__)) -#else - #define RTEMS_DEPRECATED -#endif - -/* Provided for backward compatibility */ -#define RTEMS_COMPILER_DEPRECATED_ATTRIBUTE RTEMS_DEPRECATED - -/** - * @brief Instructs the compiler to place a specific variable or function in - * the specified section. - */ -#if defined(__GNUC__) - #define RTEMS_SECTION( _section ) __attribute__((__section__(_section))) -#else - #define RTEMS_SECTION( _section ) -#endif - -/** - * @brief Instructs the compiler that a specific variable or function is used. - */ -#if defined(__GNUC__) - #define RTEMS_USED __attribute__((__used__)) -#else - #define RTEMS_USED -#endif - -/** - * Instructs the compiler that a specific variable is deliberately unused. - * This can occur when reading volatile device memory or skipping arguments - * in a variable argument method. - */ -#if defined(__GNUC__) - #define RTEMS_UNUSED __attribute__((__unused__)) -#else - #define RTEMS_UNUSED -#endif - -/* Provided for backward compatibility */ -#define RTEMS_COMPILER_UNUSED_ATTRIBUTE RTEMS_UNUSED - -/** - * Instructs the compiler that a specific structure or union members will be - * placed so that the least memory is used. - */ -#if defined(__GNUC__) - #define RTEMS_PACKED __attribute__((__packed__)) -#else - #define RTEMS_PACKED -#endif - -/** - * @brief Instructs the compiler to generate an alias to the specified target - * function. - */ -#if defined(__GNUC__) - #define RTEMS_ALIAS( _target ) __attribute__((__alias__(#_target))) -#else - #define RTEMS_ALIAS( _target ) -#endif - -/** - * @brief Instructs the compiler to generate a weak alias to the specified - * target function. - */ -#if defined(__GNUC__) - #define RTEMS_WEAK_ALIAS( _target ) __attribute__((__weak__, __alias__(#_target))) -#else - #define RTEMS_WEAK_ALIAS( _target ) -#endif - -/** - * @brief Instructs the compiler to enforce the specified alignment. - */ -#if defined(__GNUC__) - #define RTEMS_ALIGNED( _alignment ) __attribute__((__aligned__(_alignment))) -#else - #define RTEMS_ALIGNED( _alignment ) -#endif - -/* Provided for backward compatibility */ -#define RTEMS_COMPILER_PACKED_ATTRIBUTE RTEMS_PACKED - -#if defined(RTEMS_DEBUG) && !defined(RTEMS_SCHEDSIM) - #define _Assert_Unreachable() _Assert( 0 ) -#else - #define _Assert_Unreachable() do { } while ( 0 ) -#endif - -/** - * @brief Tells the compiler that this program point is unreachable. - */ -#if defined(__GNUC__) && !defined(RTEMS_SCHEDSIM) - #define RTEMS_UNREACHABLE() \ - do { \ - __builtin_unreachable(); \ - _Assert_Unreachable(); \ - } while ( 0 ) -#else - #define RTEMS_UNREACHABLE() _Assert_Unreachable() -#endif - -/** - * @brief Tells the compiler that this function expects printf()-like - * arguments. - */ -#if defined(__GNUC__) - #define RTEMS_PRINTFLIKE( _format_pos, _ap_pos ) \ - __attribute__((__format__(__printf__, _format_pos, _ap_pos))) -#else - #define RTEMS_PRINTFLIKE( _format_pos, _ap_pos ) -#endif - -/** - * @brief Obfuscates the variable so that the compiler cannot perform - * optimizations based on the variable value. - * - * The variable must be simple enough to fit into a register. - */ -#if defined(__GNUC__) - #define RTEMS_OBFUSCATE_VARIABLE( _var ) __asm__("" : "+r" (_var)) -#else - #define RTEMS_OBFUSCATE_VARIABLE( _var ) (void) (_var) -#endif - -#if __cplusplus >= 201103L - #define RTEMS_STATIC_ASSERT(cond, msg) \ - static_assert(cond, # msg) -#elif __STDC_VERSION__ >= 201112L - #define RTEMS_STATIC_ASSERT(cond, msg) \ - _Static_assert(cond, # msg) -#else - #define RTEMS_STATIC_ASSERT(cond, msg) \ - typedef int rtems_static_assert_ ## msg [(cond) ? 1 : -1] -#endif - -#define RTEMS_ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) - -/* - * Zero-length arrays are valid in C99 as flexible array members. C++11 - * doesn't allow flexible array members. Use the GNU extension which is also - * supported by other compilers. - */ -#define RTEMS_ZERO_LENGTH_ARRAY 0 - -/** - * @brief Returns a pointer to the container of a specified member pointer. - * - * @param[in] _m The pointer to a member of the container. - * @param[in] _type The type of the container. - * @param[in] _member_name The designator name of the container member. - */ -#define RTEMS_CONTAINER_OF( _m, _type, _member_name ) \ - ( (_type *) ( (uintptr_t) ( _m ) - offsetof( _type, _member_name ) ) ) - -#ifdef __cplusplus -#define RTEMS_DEQUALIFY_DEPTHX( _ptr_level, _type, _var ) \ - (const_cast<_type>( _var )) -#else /* Standard C code */ - -/* The reference type idea based on libHX by Jan Engelhardt */ -#define RTEMS_TYPEOF_REFX(_ptr_level, _ptr_type) \ - typeof(_ptr_level(union { int z; typeof(_ptr_type) x; }){0}.x) - -#if defined(__GNUC__) && !defined(ASM) -#if ((__GNUC__ * 1000 + __GNUC_MINOR__) >= 4004) -extern void* RTEMS_DEQUALIFY_types_not_compatible(void) - __attribute__((error ("RTEMS_DEQUALIFY types differ not only by volatile and const"))); -#else -extern void RTEMS_DEQUALIFY_types_not_compatible(void); -#endif -#define RTEMS_DEQUALIFY_DEPTHX( _ptr_level, _type, _var ) ( \ - __builtin_choose_expr( __builtin_types_compatible_p ( \ - RTEMS_TYPEOF_REFX( _ptr_level, _var ), \ - RTEMS_TYPEOF_REFX( _ptr_level, _type ) \ - ) || __builtin_types_compatible_p ( _type, void * ), \ - (_type)(_var), \ - RTEMS_DEQUALIFY_types_not_compatible() \ - ) \ -) -#endif /*__GNUC__*/ -#endif /*__cplusplus*/ - -#ifndef RTEMS_DECONST -#ifdef RTEMS_DEQUALIFY_DEPTHX -#define RTEMS_DECONST( _type, _var ) \ - RTEMS_DEQUALIFY_DEPTHX( *, _type, _var ) -#else /*RTEMS_DEQUALIFY_DEPTHX*/ -/** - * @brief Removes the const qualifier from a type of a variable. - * - * @param[in] _type The target type for the variable. - * @param[in] _var The variable. - */ -#define RTEMS_DECONST( _type, _var ) \ - ((_type)(uintptr_t)(const void *) ( _var )) - -#endif /*RTEMS_DEQUALIFY_DEPTHX*/ -#endif /*RTEMS_DECONST*/ - -#ifndef RTEMS_DEVOLATILE -#ifdef RTEMS_DEQUALIFY_DEPTHX -#define RTEMS_DEVOLATILE( _type, _var ) \ - RTEMS_DEQUALIFY_DEPTHX( *, _type, _var ) -#else /*RTEMS_DEQUALIFY_DEPTHX*/ -/** - * @brief Removes the volatile qualifier from a type of a variable. - * - * @param[in] _type The target type for the variable. - * @param[in] _var The variable. - */ -#define RTEMS_DEVOLATILE( _type, _var ) \ - ((_type)(uintptr_t)(volatile void *) ( _var )) - -#endif /*RTEMS_DEQUALIFY_DEPTHX*/ -#endif /*RTEMS_DEVOLATILE*/ - -#ifndef RTEMS_DEQUALIFY -#ifdef RTEMS_DEQUALIFY_DEPTHX -#define RTEMS_DEQUALIFY( _type, _var ) \ - RTEMS_DEQUALIFY_DEPTHX( *, _type, _var ) -#else /*RTEMS_DEQUALIFY_DEPTHX*/ -/** - * @brief Removes the all qualifiers from a type of a variable. - * - * @param[in] _type The target type for the variable. - * @param[in] _var The variable. - */ -#define RTEMS_DEQUALIFY( _type, _var ) \ - ((_type)(uintptr_t)(const volatile void *) ( _var )) - -#endif /*RTEMS_DEQUALIFY_DEPTHX*/ -#endif /*RTEMS_DEQUALIFY*/ - -/** - * @brief Evaluates to true if the members of two types have the same type. - * - * @param[in] _t_lhs Left hand side type. - * @param[in] _m_lhs Left hand side member. - * @param[in] _t_rhs Right hand side type. - * @param[in] _m_rhs Right hand side member. - */ -#ifdef __GNUC__ - #define RTEMS_HAVE_MEMBER_SAME_TYPE( _t_lhs, _m_lhs, _t_rhs, _m_rhs ) \ - __builtin_types_compatible_p( \ - __typeof( ( (_t_lhs *) 0 )->_m_lhs ), \ - __typeof( ( (_t_rhs *) 0 )->_m_rhs ) \ - ) -#else - #define RTEMS_HAVE_MEMBER_SAME_TYPE( _t_lhs, _m_lhs, _t_rhs, _m_rhs ) \ - true -#endif - -/** - * @brief Concatenates _x and _y without expanding. - */ -#define RTEMS_CONCAT( _x, _y ) _x##_y - -/** - * @brief Concatenates expansion of _x and expansion of _y. - */ -#define RTEMS_XCONCAT( _x, _y ) RTEMS_CONCAT( _x, _y ) - -/** - * @brief Stringifies _x without expanding. - */ -#define RTEMS_STRING( _x ) #_x - -/** - * @brief Stringifies expansion of _x. - */ -#define RTEMS_XSTRING( _x ) RTEMS_STRING( _x ) - -#ifndef ASM - #ifdef RTEMS_DEPRECATED_TYPES - typedef bool boolean; - typedef float single_precision; - typedef double double_precision; - #endif - - /** - * XXX: Eventually proc_ptr needs to disappear!!! - */ - typedef void * proc_ptr; -#endif - -/**@}*/ - -#endif /* _RTEMS_BASEDEFS_H */ diff --git a/cpukit/score/include/rtems/score/chain.h b/cpukit/score/include/rtems/score/chain.h deleted file mode 100644 index e358262e6e..0000000000 --- a/cpukit/score/include/rtems/score/chain.h +++ /dev/null @@ -1,102 +0,0 @@ -/** - * @file - * - * @ingroup ScoreChain - * - * @brief Chain Handler API - */ - -/* - * Copyright (c) 2010 embedded brains GmbH. - * - * COPYRIGHT (c) 1989-2006. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CHAIN_H -#define _RTEMS_SCORE_CHAIN_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ScoreChain Chain Handler - * - * @ingroup Score - * - * The Chain Handler is used to manage sets of entities. This handler - * provides two data structures. The Chain Node data structure is included - * as the first part of every data structure that will be placed on - * a chain. The second data structure is Chain Control which is used - * to manage a set of Chain Nodes. - */ -/**@{*/ - -/** - * @typedef Chain_Node - * - * This type definition promotes the name for the Chain Node used by - * all RTEMS code. It is a separate type definition because a forward - * reference is required to define it. See @ref Chain_Node_struct for - * detailed information. - */ -typedef struct Chain_Node_struct Chain_Node; - -/** - * @struct Chain_Node_struct - * - * This is used to manage each element (node) which is placed - * on a chain. - * - * @note Typically, a more complicated structure will use the - * chain package. The more complicated structure will - * include a chain node as the first element in its - * control structure. It will then call the chain package - * with a pointer to that node element. The node pointer - * and the higher level structure start at the same address - * so the user can cast the pointers back and forth. - * - */ -struct Chain_Node_struct { - /** This points to the node after this one on this chain. */ - Chain_Node *next; - /** This points to the node immediate prior to this one on this chain. */ - Chain_Node *previous; -}; - -/** - * @struct Chain_Control - * - * This is used to manage a chain. A chain consists of a doubly - * linked list of zero or more nodes. - * - * @note This implementation does not require special checks for - * manipulating the first and last elements on the chain. - * To accomplish this the @a Chain_Control structure is - * treated as two overlapping @ref Chain_Node structures. - */ -typedef union { - struct { - Chain_Node Node; - Chain_Node *fill; - } Head; - - struct { - Chain_Node *fill; - Chain_Node Node; - } Tail; -} Chain_Control; - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/chainimpl.h b/cpukit/score/include/rtems/score/chainimpl.h deleted file mode 100644 index c94c051198..0000000000 --- a/cpukit/score/include/rtems/score/chainimpl.h +++ /dev/null @@ -1,1123 +0,0 @@ -/** - * @file - * - * @brief Chain Handler API - */ - -/* - * Copyright (c) 2010 embedded brains GmbH. - * - * COPYRIGHT (c) 1989-2014. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CHAINIMPL_H -#define _RTEMS_SCORE_CHAINIMPL_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ScoreChain - */ -/**@{**/ - -/** - * @brief Chain initializer for an empty chain with designator @a name. - */ -#define CHAIN_INITIALIZER_EMPTY(name) \ - { { { &(name).Tail.Node, NULL }, &(name).Head.Node } } - -/** - * @brief Chain initializer for a chain with one @a node. - * - * @see CHAIN_NODE_INITIALIZER_ONE_NODE_CHAIN(). - */ -#define CHAIN_INITIALIZER_ONE_NODE( node ) \ - { { { (node), NULL }, (node) } } - -/** - * @brief Chain node initializer for a @a chain containing exactly this node. - * - * @see CHAIN_INITIALIZER_ONE_NODE(). - */ -#define CHAIN_NODE_INITIALIZER_ONE_NODE_CHAIN( chain ) \ - { &(chain)->Tail.Node, &(chain)->Head.Node } - -/** - * @brief Chain definition for an empty chain with designator @a name. - */ -#define CHAIN_DEFINE_EMPTY(name) \ - Chain_Control name = CHAIN_INITIALIZER_EMPTY(name) - -/** - * @brief Initialize a chain header. - * - * This routine initializes @a the_chain structure to manage the - * contiguous array of @a number_nodes nodes which starts at - * @a starting_address. Each node is of @a node_size bytes. - * - * @param[in] the_chain specifies the chain to initialize - * @param[in] starting_address is the starting address of the array - * of elements - * @param[in] number_nodes is the numebr of nodes that will be in the chain - * @param[in] node_size is the size of each node - */ -void _Chain_Initialize( - Chain_Control *the_chain, - void *starting_address, - size_t number_nodes, - size_t node_size -); - -/** - * @brief Returns the node count of the chain. - * - * @param[in] chain The chain. - * - * @note It does NOT disable interrupts to ensure the atomicity of the - * operation. - * - * @retval The node count of the chain. - */ -size_t _Chain_Node_count_unprotected( const Chain_Control *chain ); - -/** - * @brief Set off chain. - * - * This function sets the next field of the @a node to NULL indicating the @a - * node is not part of a chain. - * - * @param[in] node the node set to off chain. - */ -RTEMS_INLINE_ROUTINE void _Chain_Set_off_chain( - Chain_Node *node -) -{ - node->next = NULL; -#if defined(RTEMS_DEBUG) - node->previous = NULL; -#endif -} - -/** - * @brief Initializes a chain node. - * - * In debug configurations, the node is set off chain. In all other - * configurations, this function does nothing. - * - * @param[in] the_node The chain node to initialize. - */ -RTEMS_INLINE_ROUTINE void _Chain_Initialize_node( Chain_Node *the_node ) -{ -#if defined(RTEMS_DEBUG) - _Chain_Set_off_chain( the_node ); -#else - (void) the_node; -#endif -} - -/** - * @brief Is the node off chain. - * - * This function returns true if the @a node is not on a chain. A @a node is - * off chain if the next field is set to NULL. - * - * @param[in] node is the node off chain. - * - * @retval true The @a node is off chain. - * @retval false The @a node is not off chain. - */ -RTEMS_INLINE_ROUTINE bool _Chain_Is_node_off_chain( - const Chain_Node *node -) -{ - return node->next == NULL; -} - -/** - * @brief Are two nodes equal. - * - * This function returns true if @a left and @a right are equal, - * and false otherwise. - * - * @param[in] left is the node on the left hand side of the comparison. - * @param[in] right is the node on the left hand side of the comparison. - * - * @retval true @a left and @a right are equal. - * @retval false @a left and @a right are not equal. - */ -RTEMS_INLINE_ROUTINE bool _Chain_Are_nodes_equal( - const Chain_Node *left, - const Chain_Node *right -) -{ - return left == right; -} - -/** - * @brief Is the chain node pointer NULL. - * - * This function returns true if the_node is NULL and false otherwise. - * - * @param[in] the_node is the node pointer to check. - * - * @retval true @a the_node is @c NULL. - * @retval false @a the_node is not @c NULL. - */ -RTEMS_INLINE_ROUTINE bool _Chain_Is_null_node( - const Chain_Node *the_node -) -{ - return (the_node == NULL); -} - -/** - * @brief Return pointer to chain head. - * - * This function returns a pointer to the head node on the chain. - * - * @param[in] the_chain is the chain to be operated upon. - * - * @return This method returns the permanent head node of the chain. - */ -RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Head( - Chain_Control *the_chain -) -{ - return &the_chain->Head.Node; -} - -/** - * @brief Return pointer to immutable chain head. - * - * This function returns a pointer to the head node on the chain. - * - * @param[in] the_chain is the chain to be operated upon. - * - * @return This method returns the permanent head node of the chain. - */ -RTEMS_INLINE_ROUTINE const Chain_Node *_Chain_Immutable_head( - const Chain_Control *the_chain -) -{ - return &the_chain->Head.Node; -} - -/** - * @brief Return pointer to chain tail. - * - * This function returns a pointer to the tail node on the chain. - * - * @param[in] the_chain is the chain to be operated upon. - * - * @return This method returns the permanent tail node of the chain. - */ -RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Tail( - Chain_Control *the_chain -) -{ - return &the_chain->Tail.Node; -} - -/** - * @brief Return pointer to immutable chain tail. - * - * This function returns a pointer to the tail node on the chain. - * - * @param[in] the_chain is the chain to be operated upon. - * - * @return This method returns the permanent tail node of the chain. - */ -RTEMS_INLINE_ROUTINE const Chain_Node *_Chain_Immutable_tail( - const Chain_Control *the_chain -) -{ - return &the_chain->Tail.Node; -} - -/** - * @brief Return pointer to chain's first node. - * - * This function returns a pointer to the first node on the chain after the - * head. - * - * @param[in] the_chain is the chain to be operated upon. - * - * @return This method returns the first node of the chain. - */ -RTEMS_INLINE_ROUTINE Chain_Node *_Chain_First( - const Chain_Control *the_chain -) -{ - return _Chain_Immutable_head( the_chain )->next; -} - -/** - * @brief Return pointer to immutable chain's first node. - * - * This function returns a pointer to the first node on the chain after the - * head. - * - * @param[in] the_chain is the chain to be operated upon. - * - * @return This method returns the first node of the chain. - */ -RTEMS_INLINE_ROUTINE const Chain_Node *_Chain_Immutable_first( - const Chain_Control *the_chain -) -{ - return _Chain_Immutable_head( the_chain )->next; -} - -/** - * @brief Return pointer to chain's last node. - * - * This function returns a pointer to the last node on the chain just before - * the tail. - * - * @param[in] the_chain is the chain to be operated upon. - * - * @return This method returns the last node of the chain. - */ -RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Last( - const Chain_Control *the_chain -) -{ - return _Chain_Immutable_tail( the_chain )->previous; -} - -/** - * @brief Return pointer to immutable chain's last node. - * - * This function returns a pointer to the last node on the chain just before - * the tail. - * - * @param[in] the_chain is the chain to be operated upon. - * - * @return This method returns the last node of the chain. - */ -RTEMS_INLINE_ROUTINE const Chain_Node *_Chain_Immutable_last( - const Chain_Control *the_chain -) -{ - return _Chain_Immutable_tail( the_chain )->previous; -} - -/** - * @brief Return pointer the next node from this node. - * - * This function returns a pointer to the next node after this node. - * - * @param[in] the_node is the node to be operated upon. - * - * @return This method returns the next node on the chain. - */ -RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Next( - const Chain_Node *the_node -) -{ - return the_node->next; -} - -/** - * @brief Return pointer the immutable next node from this node. - * - * This function returns a pointer to the next node after this node. - * - * @param[in] the_node is the node to be operated upon. - * - * @return This method returns the next node on the chain. - */ -RTEMS_INLINE_ROUTINE const Chain_Node *_Chain_Immutable_next( - const Chain_Node *the_node -) -{ - return the_node->next; -} - -/** - * @brief Return pointer the previous node from this node. - * - * This function returns a pointer to the previous node on this chain. - * - * @param[in] the_node is the node to be operated upon. - * - * @return This method returns the previous node on the chain. - */ -RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Previous( - const Chain_Node *the_node -) -{ - return the_node->previous; -} - -/** - * @brief Return pointer the immutable previous node from this node. - * - * This function returns a pointer to the previous node on this chain. - * - * @param[in] the_node is the node to be operated upon. - * - * @return This method returns the previous node on the chain. - */ -RTEMS_INLINE_ROUTINE const Chain_Node *_Chain_Immutable_previous( - const Chain_Node *the_node -) -{ - return the_node->previous; -} - -/** - * @brief Is the chain empty. - * - * This function returns true if there a no nodes on @a the_chain and - * false otherwise. - * - * @param[in] the_chain is the chain to be operated upon. - * - * @retval true There are no nodes on @a the_chain. - * @retval false There are nodes on @a the_chain. - */ -RTEMS_INLINE_ROUTINE bool _Chain_Is_empty( - const Chain_Control *the_chain -) -{ - return _Chain_Immutable_first( the_chain ) - == _Chain_Immutable_tail( the_chain ); -} - -/** - * @brief Is this the first node on the chain. - * - * This function returns true if the_node is the first node on a chain and - * false otherwise. - * - * @param[in] the_node is the node the caller wants to know if it is - * the first node on a chain. - * - * @retval true @a the_node is the first node on a chain. - * @retval false @a the_node is not the first node on a chain. - */ -RTEMS_INLINE_ROUTINE bool _Chain_Is_first( - const Chain_Node *the_node -) -{ - return (the_node->previous->previous == NULL); -} - -/** - * @brief Is this the last node on the chain. - * - * This function returns true if @a the_node is the last node on a chain and - * false otherwise. - * - * @param[in] the_node is the node to check as the last node. - * - * @retval true @a the_node is the last node on a chain. - * @retval false @a the_node is not the last node on a chain. - */ -RTEMS_INLINE_ROUTINE bool _Chain_Is_last( - const Chain_Node *the_node -) -{ - return (the_node->next->next == NULL); -} - -/** - * @brief Does this chain have only one node. - * - * This function returns true if there is only one node on @a the_chain and - * false otherwise. - * - * @param[in] the_chain is the chain to be operated upon. - * - * @return This function returns true if there is only one node on - * @a the_chain and false otherwise. - * - * @retval true There is only one node on @a the_chain. - * @retval false There is more than one node on @a the_chain. - */ -RTEMS_INLINE_ROUTINE bool _Chain_Has_only_one_node( - const Chain_Control *the_chain -) -{ - return _Chain_Immutable_first( the_chain ) - == _Chain_Immutable_last( the_chain ); -} - -/** - * @brief Is this node the chain head. - * - * This function returns true if @a the_node is the head of @a the_chain and - * false otherwise. - * - * @param[in] the_chain is the chain to be operated upon. - * @param[in] the_node is the node to check for being the Chain Head. - * - * @retval true @a the_node is the head of @a the_chain. - * @retval false @a the_node is not the head of @a the_chain. - */ -RTEMS_INLINE_ROUTINE bool _Chain_Is_head( - const Chain_Control *the_chain, - const Chain_Node *the_node -) -{ - return (the_node == _Chain_Immutable_head( the_chain )); -} - -/** - * @brief Is this node the chail tail. - * - * This function returns true if @a the_node is the tail of @a the_chain and - * false otherwise. - * - * @param[in] the_chain is the chain to be operated upon. - * @param[in] the_node is the node to check for being the Chain Tail. - * - * @retval true @a the_node is the tail of @a the_chain. - * @retval false @a the_node is not the tail of @a the_chain. - */ -RTEMS_INLINE_ROUTINE bool _Chain_Is_tail( - const Chain_Control *the_chain, - const Chain_Node *the_node -) -{ - return (the_node == _Chain_Immutable_tail( the_chain )); -} - -/** - * @brief Initialize this chain as empty. - * - * This routine initializes the specified chain to contain zero nodes. - * - * @param[in] the_chain is the chain to be initialized. - */ -RTEMS_INLINE_ROUTINE void _Chain_Initialize_empty( - Chain_Control *the_chain -) -{ - Chain_Node *head; - Chain_Node *tail; - - _Assert( the_chain != NULL ); - - head = _Chain_Head( the_chain ); - tail = _Chain_Tail( the_chain ); - - head->next = tail; - head->previous = NULL; - tail->previous = head; -} - -/** - * @brief Initializes this chain to contain exactly the specified node. - * - * @param[in] the_chain The chain control. - * @param[in] the_node The one and only node. - */ -RTEMS_INLINE_ROUTINE void _Chain_Initialize_one( - Chain_Control *the_chain, - Chain_Node *the_node -) -{ - Chain_Node *head; - Chain_Node *tail; - - _Assert( _Chain_Is_node_off_chain( the_node ) ); - - head = _Chain_Head( the_chain ); - tail = _Chain_Tail( the_chain ); - - the_node->next = tail; - the_node->previous = head; - - head->next = the_node; - head->previous = NULL; - tail->previous = the_node; -} - -/** - * @brief Extract this node (unprotected). - * - * This routine extracts the_node from the chain on which it resides. - * It does NOT disable interrupts to ensure the atomicity of the - * extract operation. - * - * @param[in] the_node is the node to be extracted. - */ -RTEMS_INLINE_ROUTINE void _Chain_Extract_unprotected( - Chain_Node *the_node -) -{ - Chain_Node *next; - Chain_Node *previous; - - next = the_node->next; - previous = the_node->previous; - next->previous = previous; - previous->next = next; - -#if defined(RTEMS_DEBUG) - _Chain_Set_off_chain( the_node ); -#endif -} - -/** - * @brief Get the first node (unprotected). - * - * This function removes the first node from the_chain and returns - * a pointer to that node. It does NOT disable interrupts to ensure - * the atomicity of the get operation. - * - * @param[in] the_chain is the chain to attempt to get the first node from. - * - * @return This method returns the first node on the chain even if it is - * the Chain Tail. - * - * @note This routine assumes that there is at least one node on the chain - * and always returns a node even if it is the Chain Tail. - */ -RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Get_first_unprotected( - Chain_Control *the_chain -) -{ - Chain_Node *head; - Chain_Node *old_first; - Chain_Node *new_first; - - _Assert( !_Chain_Is_empty( the_chain ) ); - - head = _Chain_Head( the_chain ); - old_first = head->next; - new_first = old_first->next; - - head->next = new_first; - new_first->previous = head; - -#if defined(RTEMS_DEBUG) - _Chain_Set_off_chain( old_first ); -#endif - - return old_first; -} - -/** - * @brief Get the first node (unprotected). - * - * This function removes the first node from the_chain and returns - * a pointer to that node. If the_chain is empty, then NULL is returned. - * - * @param[in] the_chain is the chain to attempt to get the first node from. - * - * @return This method returns the first node on the chain or NULL if the - * chain is empty. - * - * @note It does NOT disable interrupts to ensure the atomicity of the - * get operation. - */ -RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Get_unprotected( - Chain_Control *the_chain -) -{ - if ( !_Chain_Is_empty(the_chain)) - return _Chain_Get_first_unprotected(the_chain); - else - return NULL; -} - -/** - * @brief Insert a node (unprotected). - * - * This routine inserts the_node on a chain immediately following - * after_node. - * - * @param[in] after_node is the node which will precede @a the_node on the - * chain. - * @param[in] the_node is the node to be inserted. - * - * @note It does NOT disable interrupts to ensure the atomicity - * of the extract operation. - */ -RTEMS_INLINE_ROUTINE void _Chain_Insert_unprotected( - Chain_Node *after_node, - Chain_Node *the_node -) -{ - Chain_Node *before_node; - - _Assert( _Chain_Is_node_off_chain( the_node ) ); - - the_node->previous = after_node; - before_node = after_node->next; - after_node->next = the_node; - the_node->next = before_node; - before_node->previous = the_node; -} - -/** - * @brief Append a node (unprotected). - * - * This routine appends the_node onto the end of the_chain. - * - * @param[in] the_chain is the chain to be operated upon. - * @param[in] the_node is the node to be appended. - * - * @note It does NOT disable interrupts to ensure the atomicity of the - * append operation. - */ -RTEMS_INLINE_ROUTINE void _Chain_Append_unprotected( - Chain_Control *the_chain, - Chain_Node *the_node -) -{ - Chain_Node *tail; - Chain_Node *old_last; - - _Assert( _Chain_Is_node_off_chain( the_node ) ); - - tail = _Chain_Tail( the_chain ); - old_last = tail->previous; - - the_node->next = tail; - tail->previous = the_node; - old_last->next = the_node; - the_node->previous = old_last; -} - -/** - * @brief Append a node on the end of a chain if the node is in the off chain - * state (unprotected). - * - * @note It does NOT disable interrupts to ensure the atomicity of the - * append operation. - * - * @see _Chain_Append_unprotected() and _Chain_Is_node_off_chain(). - */ -RTEMS_INLINE_ROUTINE void _Chain_Append_if_is_off_chain_unprotected( - Chain_Control *the_chain, - Chain_Node *the_node -) -{ - if ( _Chain_Is_node_off_chain( the_node ) ) { - _Chain_Append_unprotected( the_chain, the_node ); - } -} - -/** - * @brief Prepend a node (unprotected). - * - * This routine prepends the_node onto the front of the_chain. - * - * @param[in] the_chain is the chain to be operated upon. - * @param[in] the_node is the node to be prepended. - * - * @note It does NOT disable interrupts to ensure the atomicity of the - * prepend operation. - */ -RTEMS_INLINE_ROUTINE void _Chain_Prepend_unprotected( - Chain_Control *the_chain, - Chain_Node *the_node -) -{ - _Chain_Insert_unprotected(_Chain_Head(the_chain), the_node); -} - -/** - * @brief Append a node and check if the chain was empty before (unprotected). - * - * This routine appends the_node onto the end of the_chain. - * - * @param[in] the_chain is the chain to be operated upon. - * @param[in] the_node is the node to be appended. - * - * @note It does NOT disable interrupts to ensure the atomicity of the - * append operation. - * - * @retval true The chain was empty before. - * @retval false The chain contained at least one node before. - */ -RTEMS_INLINE_ROUTINE bool _Chain_Append_with_empty_check_unprotected( - Chain_Control *the_chain, - Chain_Node *the_node -) -{ - bool was_empty = _Chain_Is_empty( the_chain ); - - _Chain_Append_unprotected( the_chain, the_node ); - - return was_empty; -} - -/** - * @brief Prepend a node and check if the chain was empty before (unprotected). - * - * This routine prepends the_node onto the front of the_chain. - * - * @param[in] the_chain is the chain to be operated upon. - * @param[in] the_node is the node to be prepended. - * - * @note It does NOT disable interrupts to ensure the atomicity of the - * prepend operation. - * - * @retval true The chain was empty before. - * @retval false The chain contained at least one node before. - */ -RTEMS_INLINE_ROUTINE bool _Chain_Prepend_with_empty_check_unprotected( - Chain_Control *the_chain, - Chain_Node *the_node -) -{ - bool was_empty = _Chain_Is_empty( the_chain ); - - _Chain_Prepend_unprotected( the_chain, the_node ); - - return was_empty; -} - -/** - * @brief Get the first node and check if the chain is empty afterwards - * (unprotected). - * - * This function removes the first node from the_chain and returns - * a pointer to that node in @a the_node. If the_chain is empty, then NULL is - * returned. - * - * @param[in] the_chain is the chain to attempt to get the first node from. - * @param[out] the_node is the first node on the chain or NULL if the chain is - * empty. - * - * @note It does NOT disable interrupts to ensure the atomicity of the - * get operation. - * - * @retval true The chain is empty now. - * @retval false The chain contains at least one node now. - */ -RTEMS_INLINE_ROUTINE bool _Chain_Get_with_empty_check_unprotected( - Chain_Control *the_chain, - Chain_Node **the_node -) -{ - bool is_empty_now = true; - Chain_Node *head = _Chain_Head( the_chain ); - Chain_Node *tail = _Chain_Tail( the_chain ); - Chain_Node *old_first = head->next; - - if ( old_first != tail ) { - Chain_Node *new_first = old_first->next; - - head->next = new_first; - new_first->previous = head; - - *the_node = old_first; - - is_empty_now = new_first == tail; - } else - *the_node = NULL; - - return is_empty_now; -} - -/** - * @brief Chain node order. - * - * @param[in] left The left hand side. - * @param[in] right The right hand side. - * - * @retval true According to the order the left node precedes the right node. - * @retval false Otherwise. - */ -typedef bool ( *Chain_Node_order )( - const void *left, - const Chain_Node *right -); - -/** - * @brief Inserts a node into the chain according to the order relation. - * - * After the operation the chain contains the node to insert and the order - * relation holds for all nodes from the head up to the inserted node. Nodes - * after the inserted node are not moved. - * - * @param[in] the_chain The chain. - * @param[in] to_insert The node to insert. - * @param[in] left The left hand side passed to the order relation. It must - * correspond to the node to insert. The separate left hand side parameter - * may help the compiler to generate better code if it is stored in a local - * variable. - * @param[in] order The order relation. - */ -RTEMS_INLINE_ROUTINE void _Chain_Insert_ordered_unprotected( - Chain_Control *the_chain, - Chain_Node *to_insert, - const void *left, - Chain_Node_order order -) -{ - const Chain_Node *tail = _Chain_Immutable_tail( the_chain ); - Chain_Node *next = _Chain_First( the_chain ); - - while ( next != tail && !( *order )( left, next ) ) { - next = _Chain_Next( next ); - } - - _Chain_Insert_unprotected( _Chain_Previous( next ), to_insert ); -} - -/** - * @brief The chain iterator direction. - */ -typedef enum { - /** - * @brief Iteration from head to tail. - */ - CHAIN_ITERATOR_FORWARD, - - /** - * @brief Iteration from tail to head. - */ - CHAIN_ITERATOR_BACKWARD -} Chain_Iterator_direction; - -/** - * @brief A chain iterator which is updated during node extraction if it is - * properly registered. - * - * @see _Chain_Iterator_initialize(). - */ -typedef struct { - /** - * @brief Node for registration. - * - * Used during _Chain_Iterator_initialize() and _Chain_Iterator_destroy(). - */ - Chain_Node Registry_node; - - /** - * @brief The direction of this iterator. - * - * Immutable after initialization via _Chain_Iterator_initialize(). - */ - Chain_Iterator_direction direction; - - /** - * @brief The current position of this iterator. - * - * The position is initialized via _Chain_Iterator_initialize(). It must be - * explicitly set after one valid iteration step, e.g. in case a next node in - * the iterator direction existed. It is updated through the registration in - * case a node is extracted via _Chain_Iterator_registry_update(). - */ - Chain_Node *position; -} Chain_Iterator; - -/** - * @brief A registry for chain iterators. - * - * Should be attached to a chain control to enable safe iteration through a - * chain in case of concurrent node extractions. - */ -typedef struct { - Chain_Control Iterators; -} Chain_Iterator_registry; - -/** - * @brief Chain iterator registry initializer for static initialization. - * - * @param name The designator of the chain iterator registry. - */ -#define CHAIN_ITERATOR_REGISTRY_INITIALIZER( name ) \ - { CHAIN_INITIALIZER_EMPTY( name.Iterators ) } - -/** - * @brief Initializes a chain iterator registry. - */ -RTEMS_INLINE_ROUTINE void _Chain_Iterator_registry_initialize( - Chain_Iterator_registry *the_registry -) -{ - _Chain_Initialize_empty( &the_registry->Iterators ); -} - -/** - * @brief Updates all iterators present in the chain iterator registry in case - * of a node extraction. - * - * Must be called before _Chain_Extract_unprotected(). - * - * @warning This function will look at all registered chain iterators to - * determine if an update is necessary. - */ -RTEMS_INLINE_ROUTINE void _Chain_Iterator_registry_update( - Chain_Iterator_registry *the_registry, - Chain_Node *the_node_to_extract -) -{ - Chain_Node *iter_node; - Chain_Node *iter_tail; - - iter_node = _Chain_Head( &the_registry->Iterators ); - iter_tail = _Chain_Tail( &the_registry->Iterators ); - - while ( ( iter_node = _Chain_Next( iter_node ) ) != iter_tail ) { - Chain_Iterator *iter; - - iter = (Chain_Iterator *) iter_node; - - if ( iter->position == the_node_to_extract ) { - if ( iter->direction == CHAIN_ITERATOR_FORWARD ) { - iter->position = _Chain_Previous( the_node_to_extract ); - } else { - iter->position = _Chain_Next( the_node_to_extract ); - } - } - } -} - -/** - * @brief Initializes the chain iterator. - * - * In the following example nodes inserted during the iteration are visited in - * case they are inserted after the current position in iteration order. - * - * @code - * #include - * #include - * - * typedef struct { - * Chain_Control Chain; - * Chain_Iterator_registry Iterators; - * ISR_LOCK_MEMBER( Lock ) - * } Some_Control; - * - * void iterate( - * Some_Control *the_some, - * void ( *visitor )( Chain_Node * ) - * ) - * { - * ISR_lock_Context lock_context; - * Chain_Iterator iter; - * Chain_Node *node; - * const Chain_Node *end; - * - * end = _Chain_Immutable_tail( &the_some->Chain ); - * - * _ISR_lock_ISR_disable_and_acquire( &the_some->Lock, &lock_context ); - * - * _Chain_Iterator_initialize( - * &the_some->Chain, - * &the_some->Iterators, - * &iter, - * CHAIN_ITERATOR_FORWARD - * ); - * - * while ( ( node = _Chain_Iterator_next( &iter ) ) != end ) { - * _Chain_Iterator_set_position( &iter, node ); - * _ISR_lock_Release_and_ISR_enable( &the_some->Lock, &lock_context ); - * ( *visitor )( node ); - * _ISR_lock_ISR_disable_and_acquire( &the_some->Lock, &lock_context ); - * } - * - * _Chain_Iterator_destroy( &iter ); - * _ISR_lock_Release_and_ISR_enable( &the_some->Lock, &lock_context ); - * } - * @endcode - * - * @param the_chain The chain to iterate. - * @param the_registry The registry for the chain iterator. - * @param the_iterator The chain iterator to initialize. - * @param direction The iteration direction. - * - * @see _Chain_Iterator_next(), _Chain_Iterator_set_position() and - * Chain_Iterator_destroy(). - * - * @warning Think twice before you use a chain iterator. Its current - * implementation is unfit for use in performance relevant components, due to - * the linear time complexity in _Chain_Iterator_registry_update(). - */ -RTEMS_INLINE_ROUTINE void _Chain_Iterator_initialize( - Chain_Control *the_chain, - Chain_Iterator_registry *the_registry, - Chain_Iterator *the_iterator, - Chain_Iterator_direction direction -) -{ - _Chain_Initialize_node( &the_iterator->Registry_node ); - _Chain_Append_unprotected( - &the_registry->Iterators, - &the_iterator->Registry_node - ); - - the_iterator->direction = direction; - - if ( direction == CHAIN_ITERATOR_FORWARD ) { - the_iterator->position = _Chain_Head( the_chain ); - } else { - the_iterator->position = _Chain_Tail( the_chain ); - } -} - -/** - * @brief Returns the next node in the iterator direction. - * - * In case a next node exists, then the iterator should be updated via - * _Chain_Iterator_set_position() to continue with the next iteration step. - * - * @param the_iterator The chain iterator. - */ -RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Iterator_next( - const Chain_Iterator *the_iterator -) -{ - if ( the_iterator->direction == CHAIN_ITERATOR_FORWARD ) { - return _Chain_Next( the_iterator->position ); - } else { - return _Chain_Previous( the_iterator->position ); - } -} - -/** - * @brief Sets the iterator position. - * - * @param the_iterator The chain iterator. - * @param the_node The new iterator position. - */ -RTEMS_INLINE_ROUTINE void _Chain_Iterator_set_position( - Chain_Iterator *the_iterator, - Chain_Node *the_node -) -{ - the_iterator->position = the_node; -} - -/** - * @brief Destroys the iterator. - * - * Removes the iterator from its registry. - * - * @param the_iterator The chain iterator. - */ -RTEMS_INLINE_ROUTINE void _Chain_Iterator_destroy( - Chain_Iterator *the_iterator -) -{ - _Chain_Extract_unprotected( &the_iterator->Registry_node ); -} - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/context.h b/cpukit/score/include/rtems/score/context.h deleted file mode 100644 index 990a602396..0000000000 --- a/cpukit/score/include/rtems/score/context.h +++ /dev/null @@ -1,163 +0,0 @@ -/** - * @file rtems/score/context.h - * - * @brief Information About Each Thread's Context - * - * This include file contains all information about each thread's context. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CONTEXT_H -#define _RTEMS_SCORE_CONTEXT_H - -/** - * @defgroup ScoreContext Context Handler - * - * @ingroup Score - * - * This handler encapsulates functionality which abstracts thread context - * management in a portable manner. - * - * The context switch needed variable is contained in the per cpu - * data structure. - */ -/**@{*/ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/** - * @brief Size of floating point context area. - * - * This constant defines the number of bytes required - * to store a full floating point context. - */ -#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) - #define CONTEXT_FP_SIZE CPU_CONTEXT_FP_SIZE -#else - #define CONTEXT_FP_SIZE 0 -#endif - -/** - * @brief Initialize context area. - * - * This routine initializes @a _the_context such that the stack - * pointer, interrupt level, and entry point are correct for the - * thread's initial state. - * - * @param[in] _the_context will be initialized - * @param[in] _stack is the lowest physical address of the thread's - * context - * @param[in] _size is the size in octets of the thread's context - * @param[in] _isr is the ISR enable level for this thread - * @param[in] _entry is this thread's entry point - * @param[in] _is_fp is set to true if this thread has floating point - * enabled - * @param[in] _tls_area The thread-local storage (TLS) area begin. - */ -#define _Context_Initialize( _the_context, _stack, _size, _isr, _entry, \ - _is_fp, _tls_area ) \ - _CPU_Context_Initialize( _the_context, _stack, _size, _isr, _entry, \ - _is_fp, _tls_area ) - -/** - * This macro is invoked from _Thread_Handler to do whatever CPU - * specific magic is required that must be done in the context of - * the thread when it starts. - * - * If the CPU architecture does not require any magic, then this - * macro is empty. - */ - -#if defined(_CPU_Context_Initialization_at_thread_begin) - #define _Context_Initialization_at_thread_begin() \ - _CPU_Context_Initialization_at_thread_begin() -#else - #define _Context_Initialization_at_thread_begin() -#endif - -/** - * @brief Perform context switch. - * - * This routine saves the current context into the @a _executing - * context record and restores the context specified by @a _heir. - * - * @param[in] _executing is the currently executing thread's context - * @param[in] _heir is the context of the thread to be switched to - */ -#define _Context_Switch( _executing, _heir ) \ - _CPU_Context_switch( _executing, _heir ) - -/** - * @brief Restart currently executing thread. - * - * This routine restarts the calling thread by restoring its initial - * stack pointer and returning to the thread's entry point. - * - * @param[in] _the_context is the context of the thread to restart - */ -#define _Context_Restart_self( _the_context ) \ - _CPU_Context_Restart_self( _the_context ) - -/** - * @brief Initialize floating point context area. - * - * This routine initializes the floating point context save - * area to contain an initial known state. - * - * @param[in] _fp_area is the base address of the floating point - * context save area to initialize. - */ -#define _Context_Initialize_fp( _fp_area ) \ - _CPU_Context_Initialize_fp( _fp_area ) - -/** - * @brief Restore floating point context area. - * - * This routine restores the floating point context contained - * in the @a _fp area. It is assumed that the current - * floating point context has been saved by a previous invocation - * of @a _Context_Save_fp. - * - * @param[in] _fp points to the floating point context area to restore. - */ -#define _Context_Restore_fp( _fp ) \ - _CPU_Context_restore_fp( _fp ) - -/** - * @brief Save floating point context area. - * - * This routine saves the current floating point context - * in the @a _fp area. - * - * @param[in] _fp points to the floating point context area to restore. - */ -#define _Context_Save_fp( _fp ) \ - _CPU_Context_save_fp( _fp ) - -#if defined(_CPU_Context_Destroy) - #define _Context_Destroy( _the_thread, _the_context ) \ - _CPU_Context_Destroy( _the_thread, _the_context ) -#else - #define _Context_Destroy( _the_thread, _the_context ) -#endif - -#ifdef __cplusplus -} -#endif - -/**@}*/ - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/copyrt.h b/cpukit/score/include/rtems/score/copyrt.h deleted file mode 100644 index 17c925a008..0000000000 --- a/cpukit/score/include/rtems/score/copyrt.h +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @file rtems/score/copyrt.h - * - * @brief Copyright Notice for RTEMS - * - * This include file contains the copyright notice for RTEMS - * which is included in every binary copy of the executive. - */ - -/* - * COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_COPYRT_H -#define _RTEMS_SCORE_COPYRT_H - -/** - * @defgroup SuperCoreCopyright RTEMS Copyright Notice - * - * @ingroup Score - */ -/**@{*/ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * This is the copyright string for RTEMS. - */ -extern const char _Copyright_Notice[]; - -#ifdef __cplusplus -} -#endif - -/**@}*/ -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/corebarrier.h b/cpukit/score/include/rtems/score/corebarrier.h deleted file mode 100644 index ba706be3e3..0000000000 --- a/cpukit/score/include/rtems/score/corebarrier.h +++ /dev/null @@ -1,91 +0,0 @@ -/** - * @file rtems/score/corebarrier.h - * - * @brief Constants and Structures Associated with the Barrier Handler - * - * This include file contains all the constants and structures associated - * with the Barrier Handler. - */ - -/* - * COPYRIGHT (c) 1989-2007. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_COREBARRIER_H -#define _RTEMS_SCORE_COREBARRIER_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ScoreBarrier Barrier Handler - * - * @ingroup Score - * - * This handler encapsulates functionality which provides the foundation - * Barrier services used in all of the APIs supported by RTEMS. - */ -/**@{*/ - -/** - * Flavors of barriers. - */ -typedef enum { - /** This specifies that the barrier will automatically release when - * the user specified number of threads have arrived at the barrier. - */ - CORE_BARRIER_AUTOMATIC_RELEASE, - /** This specifies that the user will have to manually release the barrier - * in order to release the waiting threads. - */ - CORE_BARRIER_MANUAL_RELEASE -} CORE_barrier_Disciplines; - -/** - * The following defines the control block used to manage the - * attributes of each barrier. - */ -typedef struct { - /** This field indicates whether the barrier is automatic or manual. - */ - CORE_barrier_Disciplines discipline; - /** This element indicates the number of threads which must arrive at the - * barrier to trip the automatic release. - */ - uint32_t maximum_count; -} CORE_barrier_Attributes; - -/** - * The following defines the control block used to manage each - * barrier. - */ -typedef struct { - /** This field is the Waiting Queue used to manage the set of tasks - * which are blocked waiting for the barrier to be released. - */ - Thread_queue_Control Wait_queue; - /** This element is the set of attributes which define this instance's - * behavior. - */ - CORE_barrier_Attributes Attributes; - /** This element contains the current number of thread waiting for this - * barrier to be released. */ - uint32_t number_of_waiting_threads; -} CORE_barrier_Control; - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/corebarrierimpl.h b/cpukit/score/include/rtems/score/corebarrierimpl.h deleted file mode 100644 index d5d63659d0..0000000000 --- a/cpukit/score/include/rtems/score/corebarrierimpl.h +++ /dev/null @@ -1,173 +0,0 @@ -/** - * @file - * - * @brief Inlined Routines Associated with the SuperCore Barrier - * - * This include file contains all of the inlined routines associated - * with the SuperCore barrier. - */ - -/* - * COPYRIGHT (c) 1989-2006. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_COREBARRIERIMPL_H -#define _RTEMS_SCORE_COREBARRIERIMPL_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ScoreBarrier - */ -/**@{**/ - -#define CORE_BARRIER_TQ_OPERATIONS &_Thread_queue_Operations_FIFO - -/** - * @brief Initialize core barrier. - * - * This routine initializes the barrier based on the parameters passed. - * - * @param[in] the_barrier is the barrier to initialize - * @param[in] the_barrier_attributes define the behavior of this instance - */ -void _CORE_barrier_Initialize( - CORE_barrier_Control *the_barrier, - CORE_barrier_Attributes *the_barrier_attributes -); - -RTEMS_INLINE_ROUTINE void _CORE_barrier_Destroy( - CORE_barrier_Control *the_barrier -) -{ - _Thread_queue_Destroy( &the_barrier->Wait_queue ); -} - -RTEMS_INLINE_ROUTINE void _CORE_barrier_Acquire_critical( - CORE_barrier_Control *the_barrier, - Thread_queue_Context *queue_context -) -{ - _Thread_queue_Acquire_critical( &the_barrier->Wait_queue, queue_context ); -} - -RTEMS_INLINE_ROUTINE void _CORE_barrier_Release( - CORE_barrier_Control *the_barrier, - Thread_queue_Context *queue_context -) -{ - _Thread_queue_Release( &the_barrier->Wait_queue, queue_context ); -} - -/** - * @brief Wait for the barrier. - * - * This routine wait for the barrier to be released. If the barrier - * is set to automatic and this is the appropriate thread, then it returns - * immediately. Otherwise, the calling thread is blocked until the barrier - * is released. - * - * @param[in] the_barrier is the barrier to wait for - * @param[in,out] executing The currently executing thread. - * @param[in] wait is true if the calling thread is willing to wait - * - * @return The method status. - */ -Status_Control _CORE_barrier_Seize( - CORE_barrier_Control *the_barrier, - Thread_Control *executing, - bool wait, - Thread_queue_Context *queue_context -); - -uint32_t _CORE_barrier_Do_flush( - CORE_barrier_Control *the_barrier, - Thread_queue_Flush_filter filter, - Thread_queue_Context *queue_context -); - -/** - * @brief Manually release the barrier. - * - * This routine manually releases the barrier. All of the threads waiting - * for the barrier will be readied. - * - * @param[in] the_barrier is the barrier to surrender - * @param[in] mp_callout is the routine to invoke if the - * thread unblocked is remote - * - * @retval the number of unblocked threads - */ -RTEMS_INLINE_ROUTINE uint32_t _CORE_barrier_Surrender( - CORE_barrier_Control *the_barrier, - Thread_queue_Context *queue_context -) -{ - return _CORE_barrier_Do_flush( - the_barrier, - _Thread_queue_Flush_default_filter, - queue_context - ); -} - -RTEMS_INLINE_ROUTINE void _CORE_barrier_Flush( - CORE_barrier_Control *the_barrier, - Thread_queue_Context *queue_context -) -{ - _CORE_barrier_Do_flush( - the_barrier, - _Thread_queue_Flush_status_object_was_deleted, - queue_context - ); -} - -/** - * This function returns true if the automatic release attribute is - * enabled in the @a attribute_set and false otherwise. - * - * @param[in] the_attribute is the attribute set to test - * - * @return true if the priority attribute is enabled - */ -RTEMS_INLINE_ROUTINE bool _CORE_barrier_Is_automatic( - CORE_barrier_Attributes *the_attribute -) -{ - return - (the_attribute->discipline == CORE_BARRIER_AUTOMATIC_RELEASE); -} - -/** - * This routine returns the number of threads currently waiting at the barrier. - * - * @param[in] the_barrier is the barrier to obtain the number of blocked - * threads for - * @return the current count of this barrier - */ -RTEMS_INLINE_ROUTINE uint32_t _CORE_barrier_Get_number_of_waiting_threads( - CORE_barrier_Control *the_barrier -) -{ - return the_barrier->number_of_waiting_threads; -} - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/coremsg.h b/cpukit/score/include/rtems/score/coremsg.h deleted file mode 100644 index 8d25529fdc..0000000000 --- a/cpukit/score/include/rtems/score/coremsg.h +++ /dev/null @@ -1,185 +0,0 @@ -/** - * @file rtems/score/coremsg.h - * - * @brief Constants and Structures Associated with the Message Queue Handler. - * - * This include file contains all the constants and structures associated - * with the Message queue Handler. - */ - -/* - * COPYRIGHT (c) 1989-2009. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_COREMSG_H -#define _RTEMS_SCORE_COREMSG_H - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ScoreMessageQueue Message Queue Handler - * - * @ingroup Score - * - * This handler encapsulates functionality which provides the foundation - * Message Queue services used in all of the APIs supported by RTEMS. - */ -/**@{*/ - -#if defined(RTEMS_POSIX_API) - /** - * This macro is defined when an API is enabled that requires that the - * Message Queue Handler include support for priority based enqueuing - * of messages. - */ - #define RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY -#endif - -#if defined(RTEMS_POSIX_API) - /** - * This macro is defined when an API is enabled that requires that the - * Message Queue Handler include support for notification of enqueuing - * a message. - */ - #define RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION -#endif - -#if defined(RTEMS_POSIX_API) - /** - * This macro is defined when an API is enabled that requires the - * Message Queue Handler include support for blocking send operations. - */ - #define RTEMS_SCORE_COREMSG_ENABLE_BLOCKING_SEND -#endif - -typedef struct CORE_message_queue_Control CORE_message_queue_Control; - -/** - * @brief Data types needed to manipulate the contents of message buffers. - * - * The following defines the data types needed to manipulate - * the contents of message buffers. - * - * @note The buffer field is normally longer than a single uint32_t - * but since messages are variable length we just make a ptr to 1. - */ -typedef struct { - /** This field is the size of this message. */ - size_t size; - /** This field contains the actual message. */ - uint32_t buffer[1]; -} CORE_message_queue_Buffer; - -/** - * @brief The organization of a message buffer. - * - * The following records define the organization of a message - * buffer. - */ -typedef struct { - /** This element allows this structure to be placed on chains. */ - Chain_Node Node; - #if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY) - /** This field is the priority of this message. */ - int priority; - #endif - /** This field points to the contents of the message. */ - CORE_message_queue_Buffer Contents; -} CORE_message_queue_Buffer_control; - -/** - * @brief The possible blocking disciplines for a message queue. - * - * This enumerated types defines the possible blocking disciplines - * for a message queue. - */ -typedef enum { - /** This value indicates that blocking tasks are in FIFO order. */ - CORE_MESSAGE_QUEUE_DISCIPLINES_FIFO, - /** This value indicates that blocking tasks are in priority order. */ - CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY -} CORE_message_queue_Disciplines; - -#if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION) - /** - * @brief Type for a notification handler. - * - * The following defines the type for a Notification handler. A - * notification handler is invoked when the message queue makes a - * 0->1 transition on pending messages. - */ - typedef void (*CORE_message_queue_Notify_Handler)( - CORE_message_queue_Control *, - Thread_queue_Context * - ); -#endif - -/** - * @brief Control block used to manage each message queue. - * - * The following defines the control block used to manage each - * Message Queue. - */ -struct CORE_message_queue_Control { - /** This field is the Waiting Queue used to manage the set of tasks - * which are blocked waiting to receive a message from this queue. - */ - Thread_queue_Control Wait_queue; - - /** - * @brief The thread queue operations according to the blocking discipline. - */ - const Thread_queue_Operations *operations; - - /** This element is maximum number of messages which may be pending - * at any given time. - */ - uint32_t maximum_pending_messages; - /** This element is the number of messages which are currently pending. - */ - uint32_t number_of_pending_messages; - /** This is the size in bytes of the largest message which may be - * sent via this queue. - */ - size_t maximum_message_size; - /** This chain is the set of pending messages. It may be ordered by - * message priority or in FIFO order. - */ - Chain_Control Pending_messages; - /** This is the address of the memory allocated for message buffers. - * It is allocated are part of message queue initialization and freed - * as part of destroying it. - */ - CORE_message_queue_Buffer *message_buffers; - #if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION) - /** This is the routine invoked when the message queue transitions - * from zero (0) messages pending to one (1) message pending. - */ - CORE_message_queue_Notify_Handler notify_handler; - #endif - /** This chain is the set of inactive messages. A message is inactive - * when it does not contain a pending message. - */ - Chain_Control Inactive_messages; -}; - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/coremsgimpl.h b/cpukit/score/include/rtems/score/coremsgimpl.h deleted file mode 100644 index e33e3308b2..0000000000 --- a/cpukit/score/include/rtems/score/coremsgimpl.h +++ /dev/null @@ -1,494 +0,0 @@ -/** - * @file - * - * @brief Inlined Routines in the Core Message Handler - * - * This include file contains the static inline implementation of all - * inlined routines in the Core Message Handler. - */ - -/* - * COPYRIGHT (c) 1989-2009. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_COREMSGIMPL_H -#define _RTEMS_SCORE_COREMSGIMPL_H - -#include -#include -#include -#include -#include - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ScoreMessageQueue - */ -/**@{**/ - -/** - * @brief Used when appending messages onto a message queue. - * - * This is the priority constant used when appending messages onto - * a message queue. - */ -#define CORE_MESSAGE_QUEUE_SEND_REQUEST INT_MAX - -/** - * @brief Used when prepending messages onto a message queue. - * - * This is the priority constant used when prepending messages onto - * a message queue. - */ -#define CORE_MESSAGE_QUEUE_URGENT_REQUEST INT_MIN - -/** - * @brief The modes in which a message may be submitted to a message queue. - * - * The following type details the modes in which a message - * may be submitted to a message queue. The message may be posted - * in a send or urgent fashion. - * - * @note All other values are message priorities. Numerically smaller - * priorities indicate higher priority messages. - */ -typedef int CORE_message_queue_Submit_types; - -/** - * @brief Initialize a message queue. - * - * This package is the implementation of the CORE Message Queue Handler. - * This core object provides task synchronization and communication functions - * via messages passed to queue objects. - * - * This routine initializes @a the_message_queue - * based on the parameters passed. - * - * @param[in] the_message_queue points to the message queue to initialize - * @param[in] discipline the blocking discipline - * @param[in] maximum_pending_messages is the maximum number of messages - * that will be allowed to pend at any given time - * @param[in] maximum_message_size is the size of largest message that - * may be sent to this message queue instance - * - * @retval true if the message queue can be initialized. In general, - * false will only be returned if memory for the pending - * messages cannot be allocated. - */ -bool _CORE_message_queue_Initialize( - CORE_message_queue_Control *the_message_queue, - CORE_message_queue_Disciplines discipline, - uint32_t maximum_pending_messages, - size_t maximum_message_size -); - -/** - * @brief Close a message queue. - * - * This package is the implementation of the CORE Message Queue Handler. - * This core object provides task synchronization and communication functions - * via messages passed to queue objects - * - * This function closes a message by returning all allocated space and - * flushing @a the_message_queue's task wait queue. - * - * @param[in] the_message_queue points to the message queue to close - * @param[in] queue_context The thread queue context used for - * _CORE_message_queue_Acquire() or _CORE_message_queue_Acquire_critical(). - */ -void _CORE_message_queue_Close( - CORE_message_queue_Control *the_message_queue, - Thread_queue_Context *queue_context -); - -/** - * @brief Flush pending messages. - * - * This package is the implementation of the CORE Message Queue Handler. - * This core object provides task synchronization and communication functions - * via messages passed to queue objects. - * - * This function flushes @a the_message_queue's pending message queue. The - * number of messages flushed from the queue is returned. - * - * @param[in] the_message_queue points to the message queue to flush - * @param[in] queue_context The thread queue context with interrupts disabled. - * - * @retval This method returns the number of message pending messages flushed. - */ -uint32_t _CORE_message_queue_Flush( - CORE_message_queue_Control *the_message_queue, - Thread_queue_Context *queue_context -); - -#if defined(FUNCTIONALITY_NOT_CURRENTLY_USED_BY_ANY_API) -/** - * @brief Flush waiting threads. - * - * This function flushes the threads which are blocked on - * @a the_message_queue's pending message queue. They are - * unblocked whether blocked sending or receiving. It returns - * the number of messages flushed from the queue. - * - * @param[in] the_message_queue points to the message queue to flush - * @retval number of messages flushed from the queue - */ - void _CORE_message_queue_Flush_waiting_threads( - CORE_message_queue_Control *the_message_queue - ); -#endif - -/** - * @brief Broadcast a message to the message queue. - * - * This package is the implementation of the CORE Message Queue Handler. - * This core object provides task synchronization and communication functions - * via messages passed to queue objects. - * - * This function sends a message for every thread waiting on the queue and - * returns the number of threads made ready by the message. - * - * @param[in] the_message_queue points to the message queue - * @param[in] buffer is the starting address of the message to broadcast - * @param[in] size is the size of the message being broadcast - * @param[out] count points to the variable that will contain the - * number of tasks that are sent this message - * @param[in] queue_context The thread queue context used for - * _CORE_message_queue_Acquire() or _CORE_message_queue_Acquire_critical(). - * @retval @a *count will contain the number of messages sent - * @retval indication of the successful completion or reason for failure - */ -Status_Control _CORE_message_queue_Broadcast( - CORE_message_queue_Control *the_message_queue, - const void *buffer, - size_t size, - uint32_t *count, - Thread_queue_Context *queue_context -); - -/** - * @brief Submit a message to the message queue. - * - * This routine implements the send and urgent message functions. It - * processes a message that is to be submitted to the designated - * message queue. The message will either be processed as a - * send message which it will be inserted at the rear of the queue - * or it will be processed as an urgent message which will be inserted - * at the front of the queue. - * - * @param[in] the_message_queue points to the message queue - * @param[in] buffer is the starting address of the message to send - * @param[in] size is the size of the message being send - * @param[in] submit_type determines whether the message is prepended, - * appended, or enqueued in priority order. - * @param[in] wait indicates whether the calling thread is willing to block - * if the message queue is full. - * @param[in] queue_context The thread queue context used for - * _CORE_message_queue_Acquire() or _CORE_message_queue_Acquire_critical(). - * @retval indication of the successful completion or reason for failure - */ -Status_Control _CORE_message_queue_Submit( - CORE_message_queue_Control *the_message_queue, - Thread_Control *executing, - const void *buffer, - size_t size, - CORE_message_queue_Submit_types submit_type, - bool wait, - Thread_queue_Context *queue_context -); - -/** - * @brief Size a message from the message queue. - * - * This package is the implementation of the CORE Message Queue Handler. - * This core object provides task synchronization and communication functions - * via messages passed to queue objects. - * - * This kernel routine dequeues a message, copies the message buffer to - * a given destination buffer, and frees the message buffer to the - * inactive message pool. The thread will be blocked if wait is true, - * otherwise an error will be given to the thread if no messages are available. - * - * @param[in] the_message_queue points to the message queue - * @param[in] buffer is the starting address of the message buffer to - * to be filled in with a message - * @param[in] size_p is a pointer to the size of the @a buffer and - * indicates the maximum size message that the caller can receive. - * @param[in] wait indicates whether the calling thread is willing to block - * if the message queue is empty. - * @param[in] queue_context The thread queue context used for - * _CORE_message_queue_Acquire() or _CORE_message_queue_Acquire_critical(). - * - * @retval indication of the successful completion or reason for failure. - * On success, the location pointed to @a size_p will contain the - * size of the received message. - * - * @note Returns message priority via return area in TCB. - * - * - INTERRUPT LATENCY: - * + available - * + wait - */ -Status_Control _CORE_message_queue_Seize( - CORE_message_queue_Control *the_message_queue, - Thread_Control *executing, - void *buffer, - size_t *size_p, - bool wait, - Thread_queue_Context *queue_context -); - -/** - * @brief Insert a message into the message queue. - * - * Copies the specified content into the message storage space and then - * inserts the message into the message queue according to the submit type. - * - * @param[in] the_message_queue points to the message queue - * @param[in] the_message is the message to enqueue - * @param[in] content_source the message content source - * @param[in] content_size the message content size in bytes - * @param[in] submit_type determines whether the message is prepended, - * appended, or enqueued in priority order. - */ -void _CORE_message_queue_Insert_message( - CORE_message_queue_Control *the_message_queue, - CORE_message_queue_Buffer_control *the_message, - const void *content_source, - size_t content_size, - CORE_message_queue_Submit_types submit_type -); - -RTEMS_INLINE_ROUTINE Status_Control _CORE_message_queue_Send( - CORE_message_queue_Control *the_message_queue, - const void *buffer, - size_t size, - bool wait, - Thread_queue_Context *queue_context -) -{ - return _CORE_message_queue_Submit( - the_message_queue, - _Thread_Executing, - buffer, - size, - CORE_MESSAGE_QUEUE_SEND_REQUEST, - wait, - queue_context - ); -} - -RTEMS_INLINE_ROUTINE Status_Control _CORE_message_queue_Urgent( - CORE_message_queue_Control *the_message_queue, - const void *buffer, - size_t size, - bool wait, - Thread_queue_Context *queue_context -) -{ - return _CORE_message_queue_Submit( - the_message_queue, - _Thread_Executing, - buffer, - size, - CORE_MESSAGE_QUEUE_URGENT_REQUEST, - wait, - queue_context - ); -} - -RTEMS_INLINE_ROUTINE void _CORE_message_queue_Acquire( - CORE_message_queue_Control *the_message_queue, - Thread_queue_Context *queue_context -) -{ - _Thread_queue_Acquire( &the_message_queue->Wait_queue, queue_context ); -} - -RTEMS_INLINE_ROUTINE void _CORE_message_queue_Acquire_critical( - CORE_message_queue_Control *the_message_queue, - Thread_queue_Context *queue_context -) -{ - _Thread_queue_Acquire_critical( &the_message_queue->Wait_queue, queue_context ); -} - -RTEMS_INLINE_ROUTINE void _CORE_message_queue_Release( - CORE_message_queue_Control *the_message_queue, - Thread_queue_Context *queue_context -) -{ - _Thread_queue_Release( &the_message_queue->Wait_queue, queue_context ); -} - -/** - * This routine copies the contents of the source message buffer - * to the destination message buffer. - */ -RTEMS_INLINE_ROUTINE void _CORE_message_queue_Copy_buffer ( - const void *source, - void *destination, - size_t size -) -{ - memcpy(destination, source, size); -} - -/** - * This function allocates a message buffer from the inactive - * message buffer chain. - */ -RTEMS_INLINE_ROUTINE CORE_message_queue_Buffer_control * -_CORE_message_queue_Allocate_message_buffer ( - CORE_message_queue_Control *the_message_queue -) -{ - return (CORE_message_queue_Buffer_control *) - _Chain_Get_unprotected( &the_message_queue->Inactive_messages ); -} - -/** - * This routine frees a message buffer to the inactive - * message buffer chain. - */ -RTEMS_INLINE_ROUTINE void _CORE_message_queue_Free_message_buffer ( - CORE_message_queue_Control *the_message_queue, - CORE_message_queue_Buffer_control *the_message -) -{ - _Chain_Append_unprotected( &the_message_queue->Inactive_messages, &the_message->Node ); -} - -/** - * This function returns the priority of @a the_message. - * - * @note It encapsulates the optional behavior that message priority is - * disabled if no API requires it. - */ -RTEMS_INLINE_ROUTINE int _CORE_message_queue_Get_message_priority ( - const CORE_message_queue_Buffer_control *the_message -) -{ - #if defined(RTEMS_SCORE_COREMSG_ENABLE_MESSAGE_PRIORITY) - return the_message->priority; - #else - return 0; - #endif -} - -/** - * This function removes the first message from the_message_queue - * and returns a pointer to it. - */ -RTEMS_INLINE_ROUTINE - CORE_message_queue_Buffer_control *_CORE_message_queue_Get_pending_message ( - CORE_message_queue_Control *the_message_queue -) -{ - return (CORE_message_queue_Buffer_control *) - _Chain_Get_unprotected( &the_message_queue->Pending_messages ); -} - -#if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION) - /** - * This function returns true if notification is enabled on this message - * queue and false otherwise. - */ - RTEMS_INLINE_ROUTINE bool _CORE_message_queue_Is_notify_enabled ( - CORE_message_queue_Control *the_message_queue - ) - { - return (the_message_queue->notify_handler != NULL); - } -#endif - -/** - * This routine initializes the notification information for - * @a the_message_queue. - */ -#if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION) - RTEMS_INLINE_ROUTINE void _CORE_message_queue_Set_notify ( - CORE_message_queue_Control *the_message_queue, - CORE_message_queue_Notify_Handler the_handler - ) - { - the_message_queue->notify_handler = the_handler; - } -#else - /* turn it into nothing if not enabled */ - #define _CORE_message_queue_Set_notify( the_message_queue, the_handler ) \ - do { } while ( 0 ) -#endif - -RTEMS_INLINE_ROUTINE Thread_Control *_CORE_message_queue_Dequeue_receiver( - CORE_message_queue_Control *the_message_queue, - const void *buffer, - size_t size, - CORE_message_queue_Submit_types submit_type, - Thread_queue_Context *queue_context -) -{ - Thread_Control *the_thread; - - /* - * If there are pending messages, then there can't be threads - * waiting for us to send them a message. - * - * NOTE: This check is critical because threads can block on - * send and receive and this ensures that we are broadcasting - * the message to threads waiting to receive -- not to send. - */ - if ( the_message_queue->number_of_pending_messages != 0 ) { - return NULL; - } - - /* - * There must be no pending messages if there is a thread waiting to - * receive a message. - */ - the_thread = _Thread_queue_First_locked( - &the_message_queue->Wait_queue, - the_message_queue->operations - ); - if ( the_thread == NULL ) { - return NULL; - } - - *(size_t *) the_thread->Wait.return_argument = size; - the_thread->Wait.count = (uint32_t) submit_type; - - _CORE_message_queue_Copy_buffer( - buffer, - the_thread->Wait.return_argument_second.mutable_object, - size - ); - - _Thread_queue_Extract_critical( - &the_message_queue->Wait_queue.Queue, - the_message_queue->operations, - the_thread, - queue_context - ); - - return the_thread; -} - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/coremutex.h b/cpukit/score/include/rtems/score/coremutex.h deleted file mode 100644 index fd1f27c697..0000000000 --- a/cpukit/score/include/rtems/score/coremutex.h +++ /dev/null @@ -1,104 +0,0 @@ -/** - * @file - * - * @brief CORE Mutex API - * - * This include file contains all the constants and structures associated with - * the Mutex Handler. A mutex is an enhanced version of the standard Dijkstra - * binary semaphore used to provide synchronization and mutual exclusion - * capabilities. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_COREMUTEX_H -#define _RTEMS_SCORE_COREMUTEX_H - -#include -#include -#include -#include -#include - -struct _Scheduler_Control; - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ScoreMutex Mutex Handler - * - * @ingroup Score - * - * This handler encapsulates functionality which provides the foundation - * Mutex services used in all of the APIs supported by RTEMS. - */ -/**@{*/ - -/** - * @brief Control block used to manage each mutex. - * - * The following defines the control block used to manage each mutex. - */ -typedef struct { - /** - * @brief The thread queue of this mutex. - * - * The owner of the thread queue indicates the mutex owner. - */ - Thread_queue_Control Wait_queue; -} CORE_mutex_Control; - -/** - * @brief The recursive mutex control. - */ -typedef struct { - /** - * @brief The plain non-recursive mutex. - */ - CORE_mutex_Control Mutex; - - /** - * @brief The nest level in case of a recursive seize. - */ - unsigned int nest_level; -} CORE_recursive_mutex_Control; - -/** - * @brief The recursive mutex control with priority ceiling protocol support. - */ -typedef struct { - /** - * @brief The plain recursive mutex. - */ - CORE_recursive_mutex_Control Recursive; - - /** - * @brief The priority ceiling node for the mutex owner. - */ - Priority_Node Priority_ceiling; - -#if defined(RTEMS_SMP) - /** - * @brief The scheduler instance for this priority ceiling mutex. - */ - const struct _Scheduler_Control *scheduler; -#endif -} CORE_ceiling_mutex_Control; - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/coremuteximpl.h b/cpukit/score/include/rtems/score/coremuteximpl.h deleted file mode 100644 index 78fafca6e1..0000000000 --- a/cpukit/score/include/rtems/score/coremuteximpl.h +++ /dev/null @@ -1,447 +0,0 @@ -/** - * @file - * - * @ingroup ScoreMutex - * - * @brief CORE Mutex Implementation - */ - -/* - * COPYRIGHT (c) 1989-2009. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_COREMUTEXIMPL_H -#define _RTEMS_SCORE_COREMUTEXIMPL_H - -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ScoreMutex - */ -/**@{**/ - -#define CORE_MUTEX_TQ_OPERATIONS &_Thread_queue_Operations_priority - -#define CORE_MUTEX_TQ_PRIORITY_INHERIT_OPERATIONS \ - &_Thread_queue_Operations_priority_inherit - -RTEMS_INLINE_ROUTINE void _CORE_mutex_Initialize( - CORE_mutex_Control *the_mutex -) -{ - _Thread_queue_Object_initialize( &the_mutex->Wait_queue ); -} - -RTEMS_INLINE_ROUTINE void _CORE_mutex_Destroy( CORE_mutex_Control *the_mutex ) -{ - _Thread_queue_Destroy( &the_mutex->Wait_queue ); -} - -RTEMS_INLINE_ROUTINE void _CORE_mutex_Acquire_critical( - CORE_mutex_Control *the_mutex, - Thread_queue_Context *queue_context -) -{ - _Thread_queue_Acquire_critical( &the_mutex->Wait_queue, queue_context ); -} - -RTEMS_INLINE_ROUTINE void _CORE_mutex_Release( - CORE_mutex_Control *the_mutex, - Thread_queue_Context *queue_context -) -{ - _Thread_queue_Release( &the_mutex->Wait_queue, queue_context ); -} - -RTEMS_INLINE_ROUTINE Thread_Control *_CORE_mutex_Get_owner( - const CORE_mutex_Control *the_mutex -) -{ - return the_mutex->Wait_queue.Queue.owner; -} - -/** - * @brief Is mutex locked. - * - * This routine returns true if the mutex specified is locked and false - * otherwise. - * - * @param[in] the_mutex is the mutex to check. - * - * @retval true The mutex is locked. - * @retval false The mutex is not locked. - */ -RTEMS_INLINE_ROUTINE bool _CORE_mutex_Is_locked( - const CORE_mutex_Control *the_mutex -) -{ - return _CORE_mutex_Get_owner( the_mutex ) != NULL; -} - -Status_Control _CORE_mutex_Seize_slow( - CORE_mutex_Control *the_mutex, - const Thread_queue_Operations *operations, - Thread_Control *executing, - bool wait, - Thread_queue_Context *queue_context -); - -RTEMS_INLINE_ROUTINE void _CORE_mutex_Set_owner( - CORE_mutex_Control *the_mutex, - Thread_Control *owner -) -{ - the_mutex->Wait_queue.Queue.owner = owner; -} - -RTEMS_INLINE_ROUTINE bool _CORE_mutex_Is_owner( - const CORE_mutex_Control *the_mutex, - const Thread_Control *the_thread -) -{ - return _CORE_mutex_Get_owner( the_mutex ) == the_thread; -} - -RTEMS_INLINE_ROUTINE void _CORE_recursive_mutex_Initialize( - CORE_recursive_mutex_Control *the_mutex -) -{ - _CORE_mutex_Initialize( &the_mutex->Mutex ); - the_mutex->nest_level = 0; -} - -RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Seize_nested( - CORE_recursive_mutex_Control *the_mutex -) -{ - ++the_mutex->nest_level; - return STATUS_SUCCESSFUL; -} - -RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Seize( - CORE_recursive_mutex_Control *the_mutex, - const Thread_queue_Operations *operations, - Thread_Control *executing, - bool wait, - Status_Control ( *nested )( CORE_recursive_mutex_Control * ), - Thread_queue_Context *queue_context -) -{ - Thread_Control *owner; - - _CORE_mutex_Acquire_critical( &the_mutex->Mutex, queue_context ); - - owner = _CORE_mutex_Get_owner( &the_mutex->Mutex ); - - if ( owner == NULL ) { - _CORE_mutex_Set_owner( &the_mutex->Mutex, executing ); - _Thread_Resource_count_increment( executing ); - _CORE_mutex_Release( &the_mutex->Mutex, queue_context ); - return STATUS_SUCCESSFUL; - } - - if ( owner == executing ) { - Status_Control status; - - status = ( *nested )( the_mutex ); - _CORE_mutex_Release( &the_mutex->Mutex, queue_context ); - return status; - } - - return _CORE_mutex_Seize_slow( - &the_mutex->Mutex, - operations, - executing, - wait, - queue_context - ); -} - -RTEMS_INLINE_ROUTINE Status_Control _CORE_recursive_mutex_Surrender( - CORE_recursive_mutex_Control *the_mutex, - const Thread_queue_Operations *operations, - Thread_Control *executing, - Thread_queue_Context *queue_context -) -{ - unsigned int nest_level; - Thread_queue_Heads *heads; - - _CORE_mutex_Acquire_critical( &the_mutex->Mutex, queue_context ); - - if ( !_CORE_mutex_Is_owner( &the_mutex->Mutex, executing ) ) { - _CORE_mutex_Release( &the_mutex->Mutex, queue_context ); - return STATUS_NOT_OWNER; - } - - nest_level = the_mutex->nest_level; - - if ( nest_level > 0 ) { - the_mutex->nest_level = nest_level - 1; - _CORE_mutex_Release( &the_mutex->Mutex, queue_context ); - return STATUS_SUCCESSFUL; - } - - _Thread_Resource_count_decrement( executing ); - _CORE_mutex_Set_owner( &the_mutex->Mutex, NULL ); - - heads = the_mutex->Mutex.Wait_queue.Queue.heads; - - if ( heads == NULL ) { - _CORE_mutex_Release( &the_mutex->Mutex, queue_context ); - return STATUS_SUCCESSFUL; - } - - _Thread_queue_Surrender( - &the_mutex->Mutex.Wait_queue.Queue, - heads, - executing, - queue_context, - operations - ); - return STATUS_SUCCESSFUL; -} - -RTEMS_INLINE_ROUTINE void _CORE_ceiling_mutex_Initialize( - CORE_ceiling_mutex_Control *the_mutex, - const Scheduler_Control *scheduler, - Priority_Control priority_ceiling -) -{ - _CORE_recursive_mutex_Initialize( &the_mutex->Recursive ); - _Priority_Node_initialize( &the_mutex->Priority_ceiling, priority_ceiling ); -#if defined(RTEMS_SMP) - the_mutex->scheduler = scheduler; -#endif -} - -RTEMS_INLINE_ROUTINE const Scheduler_Control * -_CORE_ceiling_mutex_Get_scheduler( - const CORE_ceiling_mutex_Control *the_mutex -) -{ -#if defined(RTEMS_SMP) - return the_mutex->scheduler; -#else - return &_Scheduler_Table[ 0 ]; -#endif -} - -RTEMS_INLINE_ROUTINE void _CORE_ceiling_mutex_Set_priority( - CORE_ceiling_mutex_Control *the_mutex, - Priority_Control priority_ceiling, - Thread_queue_Context *queue_context -) -{ - Thread_Control *owner; - - owner = _CORE_mutex_Get_owner( &the_mutex->Recursive.Mutex ); - - if ( owner != NULL ) { - _Thread_Wait_acquire( owner, queue_context ); - _Thread_Priority_change( - owner, - &the_mutex->Priority_ceiling, - priority_ceiling, - false, - queue_context - ); - _Thread_Wait_release( owner, queue_context ); - } else { - the_mutex->Priority_ceiling.priority = priority_ceiling; - } -} - -RTEMS_INLINE_ROUTINE Priority_Control _CORE_ceiling_mutex_Get_priority( - const CORE_ceiling_mutex_Control *the_mutex -) -{ - return the_mutex->Priority_ceiling.priority; -} - -RTEMS_INLINE_ROUTINE Status_Control _CORE_ceiling_mutex_Set_owner( - CORE_ceiling_mutex_Control *the_mutex, - Thread_Control *owner, - Thread_queue_Context *queue_context -) -{ - ISR_lock_Context lock_context; - Scheduler_Node *scheduler_node; - Per_CPU_Control *cpu_self; - - _Thread_Wait_acquire_default_critical( owner, &lock_context ); - - scheduler_node = _Thread_Scheduler_get_home_node( owner ); - - if ( - _Priority_Get_priority( &scheduler_node->Wait.Priority ) - < the_mutex->Priority_ceiling.priority - ) { - _Thread_Wait_release_default_critical( owner, &lock_context ); - _CORE_mutex_Release( &the_mutex->Recursive.Mutex, queue_context ); - return STATUS_MUTEX_CEILING_VIOLATED; - } - - _CORE_mutex_Set_owner( &the_mutex->Recursive.Mutex, owner ); - _Thread_Resource_count_increment( owner ); - _Thread_Priority_add( - owner, - &the_mutex->Priority_ceiling, - queue_context - ); - _Thread_Wait_release_default_critical( owner, &lock_context ); - - cpu_self = _Thread_queue_Dispatch_disable( queue_context ); - _CORE_mutex_Release( &the_mutex->Recursive.Mutex, queue_context ); - _Thread_Priority_update( queue_context ); - _Thread_Dispatch_enable( cpu_self ); - return STATUS_SUCCESSFUL; -} - -RTEMS_INLINE_ROUTINE Status_Control _CORE_ceiling_mutex_Seize( - CORE_ceiling_mutex_Control *the_mutex, - Thread_Control *executing, - bool wait, - Status_Control ( *nested )( CORE_recursive_mutex_Control * ), - Thread_queue_Context *queue_context -) -{ - Thread_Control *owner; - - _CORE_mutex_Acquire_critical( &the_mutex->Recursive.Mutex, queue_context ); - - owner = _CORE_mutex_Get_owner( &the_mutex->Recursive.Mutex ); - - if ( owner == NULL ) { -#if defined(RTEMS_SMP) - if ( - _Thread_Scheduler_get_home( executing ) - != _CORE_ceiling_mutex_Get_scheduler( the_mutex ) - ) { - _CORE_mutex_Release( &the_mutex->Recursive.Mutex, queue_context ); - return STATUS_NOT_DEFINED; - } -#endif - - _Thread_queue_Context_clear_priority_updates( queue_context ); - return _CORE_ceiling_mutex_Set_owner( - the_mutex, - executing, - queue_context - ); - } - - if ( owner == executing ) { - Status_Control status; - - status = ( *nested )( &the_mutex->Recursive ); - _CORE_mutex_Release( &the_mutex->Recursive.Mutex, queue_context ); - return status; - } - - return _CORE_mutex_Seize_slow( - &the_mutex->Recursive.Mutex, - CORE_MUTEX_TQ_OPERATIONS, - executing, - wait, - queue_context - ); -} - -RTEMS_INLINE_ROUTINE Status_Control _CORE_ceiling_mutex_Surrender( - CORE_ceiling_mutex_Control *the_mutex, - Thread_Control *executing, - Thread_queue_Context *queue_context -) -{ - unsigned int nest_level; - ISR_lock_Context lock_context; - Per_CPU_Control *cpu_self; - Thread_Control *new_owner; - - _CORE_mutex_Acquire_critical( &the_mutex->Recursive.Mutex, queue_context ); - - if ( !_CORE_mutex_Is_owner( &the_mutex->Recursive.Mutex, executing ) ) { - _CORE_mutex_Release( &the_mutex->Recursive.Mutex, queue_context ); - return STATUS_NOT_OWNER; - } - - nest_level = the_mutex->Recursive.nest_level; - - if ( nest_level > 0 ) { - the_mutex->Recursive.nest_level = nest_level - 1; - _CORE_mutex_Release( &the_mutex->Recursive.Mutex, queue_context ); - return STATUS_SUCCESSFUL; - } - - _Thread_Resource_count_decrement( executing ); - - _Thread_queue_Context_clear_priority_updates( queue_context ); - _Thread_Wait_acquire_default_critical( executing, &lock_context ); - _Thread_Priority_remove( - executing, - &the_mutex->Priority_ceiling, - queue_context - ); - _Thread_Wait_release_default_critical( executing, &lock_context ); - - new_owner = _Thread_queue_First_locked( - &the_mutex->Recursive.Mutex.Wait_queue, - CORE_MUTEX_TQ_OPERATIONS - ); - _CORE_mutex_Set_owner( &the_mutex->Recursive.Mutex, new_owner ); - - cpu_self = _Thread_Dispatch_disable_critical( - &queue_context->Lock_context.Lock_context - ); - - if ( new_owner != NULL ) { -#if defined(RTEMS_MULTIPROCESSING) - if ( _Objects_Is_local_id( new_owner->Object.id ) ) -#endif - { - _Thread_Resource_count_increment( new_owner ); - _Thread_Priority_add( - new_owner, - &the_mutex->Priority_ceiling, - queue_context - ); - } - - _Thread_queue_Extract_critical( - &the_mutex->Recursive.Mutex.Wait_queue.Queue, - CORE_MUTEX_TQ_OPERATIONS, - new_owner, - queue_context - ); - } else { - _CORE_mutex_Release( &the_mutex->Recursive.Mutex, queue_context ); - } - - _Thread_Priority_update( queue_context ); - _Thread_Dispatch_enable( cpu_self ); - return STATUS_SUCCESSFUL; -} - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/corerwlockimpl.h b/cpukit/score/include/rtems/score/corerwlockimpl.h deleted file mode 100644 index 942e8c8d75..0000000000 --- a/cpukit/score/include/rtems/score/corerwlockimpl.h +++ /dev/null @@ -1,182 +0,0 @@ -/** - * @file - * - * @brief Inlined Routines Associated with the SuperCore RWLock - * - * This include file contains all of the inlined routines associated - * with the SuperCore RWLock. - */ - -/* - * COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CORERWLOCKIMPL_H -#define _RTEMS_SCORE_CORERWLOCKIMPL_H - -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ScoreRWLock - */ -/**@{**/ - -#define CORE_RWLOCK_TQ_OPERATIONS &_Thread_queue_Operations_FIFO - -/** - * This is used to denote that a thread is blocking waiting for - * read-only access to the RWLock. - */ -#define CORE_RWLOCK_THREAD_WAITING_FOR_READ 0 - -/** - * This is used to denote that a thread is blocking waiting for - * write-exclusive access to the RWLock. - */ -#define CORE_RWLOCK_THREAD_WAITING_FOR_WRITE 1 - -/** - * RWLock State. - */ -typedef enum { - /** This indicates the the RWLock is not currently locked. - */ - CORE_RWLOCK_UNLOCKED, - /** This indicates the the RWLock is currently locked for reading. - */ - CORE_RWLOCK_LOCKED_FOR_READING, - /** This indicates the the RWLock is currently locked for reading. - */ - CORE_RWLOCK_LOCKED_FOR_WRITING -} CORE_RWLock_States; - -/** - * The following defines the control block used to manage each - * RWLock. - */ -typedef struct { - /** This field is the Waiting Queue used to manage the set of tasks - * which are blocked waiting for the RWLock to be released. - */ - Thread_queue_Syslock_queue Queue; - - /** This element is the current state of the RWLock. - */ - CORE_RWLock_States current_state; - - /** This element contains the current number of thread waiting for this - * RWLock to be released. */ - unsigned int number_of_readers; -} CORE_RWLock_Control; - -/** - * @brief Initialize a RWlock. - * - * This routine initializes the RWLock based on the parameters passed. - * - * @param[in] the_rwlock is the RWLock to initialize - */ -void _CORE_RWLock_Initialize( - CORE_RWLock_Control *the_rwlock -); - -RTEMS_INLINE_ROUTINE void _CORE_RWLock_Destroy( - CORE_RWLock_Control *the_rwlock -) -{ - (void) the_rwlock; -} - -RTEMS_INLINE_ROUTINE Thread_Control *_CORE_RWLock_Acquire( - CORE_RWLock_Control *the_rwlock, - Thread_queue_Context *queue_context -) -{ - ISR_Level level; - Thread_Control *executing; - - _Thread_queue_Context_ISR_disable( queue_context, level ); - _Thread_queue_Context_set_ISR_level( queue_context, level ); - executing = _Thread_Executing; - _Thread_queue_Queue_acquire_critical( - &the_rwlock->Queue.Queue, - &executing->Potpourri_stats, - &queue_context->Lock_context.Lock_context - ); - - return executing; -} - -RTEMS_INLINE_ROUTINE void _CORE_RWLock_Release( - CORE_RWLock_Control *the_rwlock, - Thread_queue_Context *queue_context -) -{ - _Thread_queue_Queue_release( - &the_rwlock->Queue.Queue, - &queue_context->Lock_context.Lock_context - ); -} - -/** - * @brief Obtain RWLock for reading. - * - * This routine attempts to obtain the RWLock for read access. - * - * @param[in] the_rwlock is the RWLock to wait for - * @param[in] wait is true if the calling thread is willing to wait - */ - -Status_Control _CORE_RWLock_Seize_for_reading( - CORE_RWLock_Control *the_rwlock, - bool wait, - Thread_queue_Context *queue_context -); - -/** - * @brief Obtain RWLock for writing. - * - * This routine attempts to obtain the RWLock for write exclusive access. - * - * @param[in] the_rwlock is the RWLock to wait for - * @param[in] wait is true if the calling thread is willing to wait - */ -Status_Control _CORE_RWLock_Seize_for_writing( - CORE_RWLock_Control *the_rwlock, - bool wait, - Thread_queue_Context *queue_context -); - -/** - * @brief Release the RWLock. - * - * This routine manually releases @a the_rwlock. All of the threads waiting - * for the RWLock will be readied. - * - * @param[in] the_rwlock is the RWLock to surrender - * - * @retval Status is returned to indicate successful or failure. - */ -Status_Control _CORE_RWLock_Surrender( CORE_RWLock_Control *the_rwlock ); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/coresem.h b/cpukit/score/include/rtems/score/coresem.h deleted file mode 100644 index f9d3ac8fd5..0000000000 --- a/cpukit/score/include/rtems/score/coresem.h +++ /dev/null @@ -1,61 +0,0 @@ -/** - * @file rtems/score/coresem.h - * - * @brief Data Associated with the Counting Semaphore Handler - * - * This include file contains all the constants and structures associated - * with the Counting Semaphore Handler. A counting semaphore is the - * standard Dijkstra binary semaphore used to provide synchronization - * and mutual exclusion capabilities. - */ - -/* - * COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CORESEM_H -#define _RTEMS_SCORE_CORESEM_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ScoreSemaphore Semaphore Handler - * - * @ingroup Score - * - * This handler encapsulates functionality which provides the foundation - * Semaphore services used in all of the APIs supported by RTEMS. - */ -/**@{*/ - -/** - * The following defines the control block used to manage each - * counting semaphore. - */ -typedef struct { - /** This field is the Waiting Queue used to manage the set of tasks - * which are blocked waiting to obtain the semaphore. - */ - Thread_queue_Control Wait_queue; - - /** This element contains the current count of this semaphore. */ - uint32_t count; -} CORE_semaphore_Control; - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/coresemimpl.h b/cpukit/score/include/rtems/score/coresemimpl.h deleted file mode 100644 index 00f77e61dd..0000000000 --- a/cpukit/score/include/rtems/score/coresemimpl.h +++ /dev/null @@ -1,207 +0,0 @@ -/** - * @file - * - * @brief Inlined Routines Associated with the SuperCore Semaphore - * - * This include file contains all of the inlined routines associated - * with the SuperCore semaphore. - */ - -/* - * COPYRIGHT (c) 1989-2006. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CORESEMIMPL_H -#define _RTEMS_SCORE_CORESEMIMPL_H - -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ScoreSemaphore - */ -/**@{**/ - -/** - * @brief Initialize the semaphore based on the parameters passed. - * - * This package is the implementation of the CORE Semaphore Handler. - * This core object utilizes standard Dijkstra counting semaphores to provide - * synchronization and mutual exclusion capabilities. - * - * This routine initializes the semaphore based on the parameters passed. - * - * @param[in] the_semaphore is the semaphore to initialize - * @param[in] initial_value is the initial count of the semaphore - */ -void _CORE_semaphore_Initialize( - CORE_semaphore_Control *the_semaphore, - uint32_t initial_value -); - -RTEMS_INLINE_ROUTINE void _CORE_semaphore_Acquire_critical( - CORE_semaphore_Control *the_semaphore, - Thread_queue_Context *queue_context -) -{ - _Thread_queue_Acquire_critical( &the_semaphore->Wait_queue, queue_context ); -} - -RTEMS_INLINE_ROUTINE void _CORE_semaphore_Release( - CORE_semaphore_Control *the_semaphore, - Thread_queue_Context *queue_context -) -{ - _Thread_queue_Release( &the_semaphore->Wait_queue, queue_context ); -} - -RTEMS_INLINE_ROUTINE void _CORE_semaphore_Destroy( - CORE_semaphore_Control *the_semaphore, - const Thread_queue_Operations *operations, - Thread_queue_Context *queue_context -) -{ - _Thread_queue_Flush_critical( - &the_semaphore->Wait_queue.Queue, - operations, - _Thread_queue_Flush_status_object_was_deleted, - queue_context - ); - _Thread_queue_Destroy( &the_semaphore->Wait_queue ); -} - -/** - * @brief Surrender a unit to a semaphore. - * - * This routine frees a unit to the semaphore. If a task was blocked waiting - * for a unit from this semaphore, then that task will be readied and the unit - * given to that task. Otherwise, the unit will be returned to the semaphore. - * - * @param[in] the_semaphore is the semaphore to surrender - * @param[in] operations The thread queue operations. - * @param[in] queue_context is a temporary variable used to contain the ISR - * disable level cookie - * - * @retval an indication of whether the routine succeeded or failed - */ -RTEMS_INLINE_ROUTINE Status_Control _CORE_semaphore_Surrender( - CORE_semaphore_Control *the_semaphore, - const Thread_queue_Operations *operations, - uint32_t maximum_count, - Thread_queue_Context *queue_context -) -{ - Thread_Control *the_thread; - Status_Control status; - - status = STATUS_SUCCESSFUL; - - _CORE_semaphore_Acquire_critical( the_semaphore, queue_context ); - - the_thread = _Thread_queue_First_locked( - &the_semaphore->Wait_queue, - operations - ); - if ( the_thread != NULL ) { - _Thread_queue_Extract_critical( - &the_semaphore->Wait_queue.Queue, - operations, - the_thread, - queue_context - ); - } else { - if ( the_semaphore->count < maximum_count ) - the_semaphore->count += 1; - else - status = STATUS_MAXIMUM_COUNT_EXCEEDED; - - _CORE_semaphore_Release( the_semaphore, queue_context ); - } - - return status; -} - -/** - * This routine returns the current count associated with the semaphore. - * - * @param[in] the_semaphore is the semaphore to obtain the count of - * - * @return the current count of this semaphore - */ -RTEMS_INLINE_ROUTINE uint32_t _CORE_semaphore_Get_count( - const CORE_semaphore_Control *the_semaphore -) -{ - return the_semaphore->count; -} - -/** - * This routine attempts to receive a unit from the_semaphore. - * If a unit is available or if the wait flag is false, then the routine - * returns. Otherwise, the calling task is blocked until a unit becomes - * available. - * - * @param[in] the_semaphore is the semaphore to obtain - * @param[in] operations The thread queue operations. - * @param[in] executing The currently executing thread. - * @param[in] wait is true if the thread is willing to wait - * @param[in] queue_context is a temporary variable used to contain the ISR - * disable level cookie - */ -RTEMS_INLINE_ROUTINE Status_Control _CORE_semaphore_Seize( - CORE_semaphore_Control *the_semaphore, - const Thread_queue_Operations *operations, - Thread_Control *executing, - bool wait, - Thread_queue_Context *queue_context -) -{ - _Assert( _ISR_Get_level() != 0 ); - - _CORE_semaphore_Acquire_critical( the_semaphore, queue_context ); - if ( the_semaphore->count != 0 ) { - the_semaphore->count -= 1; - _CORE_semaphore_Release( the_semaphore, queue_context ); - return STATUS_SUCCESSFUL; - } - - if ( !wait ) { - _CORE_semaphore_Release( the_semaphore, queue_context ); - return STATUS_UNSATISFIED; - } - - _Thread_queue_Context_set_thread_state( - queue_context, - STATES_WAITING_FOR_SEMAPHORE - ); - _Thread_queue_Enqueue( - &the_semaphore->Wait_queue.Queue, - operations, - executing, - queue_context - ); - return _Thread_Wait_get_status( executing ); -} - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/cpustdatomic.h b/cpukit/score/include/rtems/score/cpustdatomic.h deleted file mode 100644 index 6c6db8d279..0000000000 --- a/cpukit/score/include/rtems/score/cpustdatomic.h +++ /dev/null @@ -1,682 +0,0 @@ -/** - * @file - * - * @brief Atomic Operations CPU API - */ - -/* - * COPYRIGHT (c) 2013 Deng Hengyi. - * Copyright (c) 2015 embedded brains GmbH. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_CPUSTDATOMIC_H -#define _RTEMS_SCORE_CPUSTDATOMIC_H - -#include - -#ifdef RTEMS_SMP - #if defined(__cplusplus) \ - && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)) - /* - * The GCC 4.9 ships its own which is not C++ compatible. The - * suggested solution was to include in case C++ is used. This works - * at least with GCC 4.9. See also: - * - * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60932 - * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60940 - */ - #include - #define _RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC - #else - #include - #define _RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC - #endif -#else - #include -#endif - -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - -typedef std::atomic_uint CPU_atomic_Uint; - -typedef std::atomic_ulong CPU_atomic_Ulong; - -typedef std::atomic_uintptr_t CPU_atomic_Uintptr; - -typedef std::atomic_flag CPU_atomic_Flag; - -typedef std::memory_order CPU_atomic_Order; - -#define CPU_ATOMIC_ORDER_RELAXED std::memory_order_relaxed - -#define CPU_ATOMIC_ORDER_ACQUIRE std::memory_order_acquire - -#define CPU_ATOMIC_ORDER_RELEASE std::memory_order_release - -#define CPU_ATOMIC_ORDER_ACQ_REL std::memory_order_acq_rel - -#define CPU_ATOMIC_ORDER_SEQ_CST std::memory_order_seq_cst - -#define CPU_ATOMIC_INITIALIZER_UINT( value ) ATOMIC_VAR_INIT( value ) - -#define CPU_ATOMIC_INITIALIZER_ULONG( value ) ATOMIC_VAR_INIT( value ) - -#define CPU_ATOMIC_INITIALIZER_UINTPTR( value ) ATOMIC_VAR_INIT( value ) - -#define CPU_ATOMIC_INITIALIZER_FLAG ATOMIC_FLAG_INIT - -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - -typedef atomic_uint CPU_atomic_Uint; - -typedef atomic_ulong CPU_atomic_Ulong; - -typedef atomic_uintptr_t CPU_atomic_Uintptr; - -typedef atomic_flag CPU_atomic_Flag; - -typedef memory_order CPU_atomic_Order; - -#define CPU_ATOMIC_ORDER_RELAXED memory_order_relaxed - -#define CPU_ATOMIC_ORDER_ACQUIRE memory_order_acquire - -#define CPU_ATOMIC_ORDER_RELEASE memory_order_release - -#define CPU_ATOMIC_ORDER_ACQ_REL memory_order_acq_rel - -#define CPU_ATOMIC_ORDER_SEQ_CST memory_order_seq_cst - -#define CPU_ATOMIC_INITIALIZER_UINT( value ) ATOMIC_VAR_INIT( value ) - -#define CPU_ATOMIC_INITIALIZER_ULONG( value ) ATOMIC_VAR_INIT( value ) - -#define CPU_ATOMIC_INITIALIZER_UINTPTR( value ) ATOMIC_VAR_INIT( value ) - -#define CPU_ATOMIC_INITIALIZER_FLAG ATOMIC_FLAG_INIT - -#else - -typedef unsigned int CPU_atomic_Uint; - -typedef unsigned long CPU_atomic_Ulong; - -typedef uintptr_t CPU_atomic_Uintptr; - -typedef bool CPU_atomic_Flag; - -typedef int CPU_atomic_Order; - -#define CPU_ATOMIC_ORDER_RELAXED 0 - -#define CPU_ATOMIC_ORDER_ACQUIRE 2 - -#define CPU_ATOMIC_ORDER_RELEASE 3 - -#define CPU_ATOMIC_ORDER_ACQ_REL 4 - -#define CPU_ATOMIC_ORDER_SEQ_CST 5 - -#define CPU_ATOMIC_INITIALIZER_UINT( value ) ( value ) - -#define CPU_ATOMIC_INITIALIZER_ULONG( value ) ( value ) - -#define CPU_ATOMIC_INITIALIZER_UINTPTR( value ) ( value ) - -#define CPU_ATOMIC_INITIALIZER_FLAG false - -#endif - -static inline void _CPU_atomic_Fence( CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - std::atomic_thread_fence( order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - atomic_thread_fence( order ); -#else - (void) order; - RTEMS_COMPILER_MEMORY_BARRIER(); -#endif -} - -static inline void _CPU_atomic_Init_uint( CPU_atomic_Uint *obj, unsigned int desired ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - obj->store( desired ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - atomic_init( obj, desired ); -#else - *obj = desired; -#endif -} - -static inline void _CPU_atomic_Init_ulong( CPU_atomic_Ulong *obj, unsigned long desired ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - obj->store( desired ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - atomic_init( obj, desired ); -#else - *obj = desired; -#endif -} - -static inline void _CPU_atomic_Init_uintptr( CPU_atomic_Uintptr *obj, uintptr_t desired ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - obj->store( desired ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - atomic_init( obj, desired ); -#else - *obj = desired; -#endif -} - -static inline unsigned int _CPU_atomic_Load_uint( const CPU_atomic_Uint *obj, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->load( order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_load_explicit( obj, order ); -#else - unsigned int val; - - (void) order; - val = *obj; - RTEMS_COMPILER_MEMORY_BARRIER(); - - return val; -#endif -} - -static inline unsigned long _CPU_atomic_Load_ulong( const CPU_atomic_Ulong *obj, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->load( order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_load_explicit( obj, order ); -#else - unsigned long val; - - (void) order; - val = *obj; - RTEMS_COMPILER_MEMORY_BARRIER(); - - return val; -#endif -} - -static inline uintptr_t _CPU_atomic_Load_uintptr( const CPU_atomic_Uintptr *obj, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->load( order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_load_explicit( obj, order ); -#else - uintptr_t val; - - (void) order; - val = *obj; - RTEMS_COMPILER_MEMORY_BARRIER(); - - return val; -#endif -} - -static inline void _CPU_atomic_Store_uint( CPU_atomic_Uint *obj, unsigned int desired, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - obj->store( desired ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - atomic_store_explicit( obj, desired, order ); -#else - (void) order; - RTEMS_COMPILER_MEMORY_BARRIER(); - *obj = desired; -#endif -} - -static inline void _CPU_atomic_Store_ulong( CPU_atomic_Ulong *obj, unsigned long desired, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - obj->store( desired ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - atomic_store_explicit( obj, desired, order ); -#else - (void) order; - RTEMS_COMPILER_MEMORY_BARRIER(); - *obj = desired; -#endif -} - -static inline void _CPU_atomic_Store_uintptr( CPU_atomic_Uintptr *obj, uintptr_t desired, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - obj->store( desired ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - atomic_store_explicit( obj, desired, order ); -#else - (void) order; - RTEMS_COMPILER_MEMORY_BARRIER(); - *obj = desired; -#endif -} - -static inline unsigned int _CPU_atomic_Fetch_add_uint( CPU_atomic_Uint *obj, unsigned int arg, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->fetch_add( arg, order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_fetch_add_explicit( obj, arg, order ); -#else - unsigned int val; - ISR_Level level; - - (void) order; - _ISR_Local_disable( level ); - val = *obj; - *obj = val + arg; - _ISR_Local_enable( level ); - - return val; -#endif -} - -static inline unsigned long _CPU_atomic_Fetch_add_ulong( CPU_atomic_Ulong *obj, unsigned long arg, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->fetch_add( arg, order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_fetch_add_explicit( obj, arg, order ); -#else - unsigned long val; - ISR_Level level; - - (void) order; - _ISR_Local_disable( level ); - val = *obj; - *obj = val + arg; - _ISR_Local_enable( level ); - - return val; -#endif -} - -static inline uintptr_t _CPU_atomic_Fetch_add_uintptr( CPU_atomic_Uintptr *obj, uintptr_t arg, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->fetch_add( arg, order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_fetch_add_explicit( obj, arg, order ); -#else - uintptr_t val; - ISR_Level level; - - (void) order; - _ISR_Local_disable( level ); - val = *obj; - *obj = val + arg; - _ISR_Local_enable( level ); - - return val; -#endif -} - -static inline unsigned int _CPU_atomic_Fetch_sub_uint( CPU_atomic_Uint *obj, unsigned int arg, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->fetch_sub( arg, order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_fetch_sub_explicit( obj, arg, order ); -#else - unsigned int val; - ISR_Level level; - - (void) order; - _ISR_Local_disable( level ); - val = *obj; - *obj = val - arg; - _ISR_Local_enable( level ); - - return val; -#endif -} - -static inline unsigned long _CPU_atomic_Fetch_sub_ulong( CPU_atomic_Ulong *obj, unsigned long arg, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->fetch_sub( arg, order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_fetch_sub_explicit( obj, arg, order ); -#else - unsigned long val; - ISR_Level level; - - (void) order; - _ISR_Local_disable( level ); - val = *obj; - *obj = val - arg; - _ISR_Local_enable( level ); - - return val; -#endif -} - -static inline uintptr_t _CPU_atomic_Fetch_sub_uintptr( CPU_atomic_Uintptr *obj, uintptr_t arg, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->fetch_sub( arg, order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_fetch_sub_explicit( obj, arg, order ); -#else - uintptr_t val; - ISR_Level level; - - (void) order; - _ISR_Local_disable( level ); - val = *obj; - *obj = val - arg; - _ISR_Local_enable( level ); - - return val; -#endif -} - -static inline unsigned int _CPU_atomic_Fetch_or_uint( CPU_atomic_Uint *obj, unsigned int arg, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->fetch_or( arg, order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_fetch_or_explicit( obj, arg, order ); -#else - unsigned int val; - ISR_Level level; - - (void) order; - _ISR_Local_disable( level ); - val = *obj; - *obj = val | arg; - _ISR_Local_enable( level ); - - return val; -#endif -} - -static inline unsigned long _CPU_atomic_Fetch_or_ulong( CPU_atomic_Ulong *obj, unsigned long arg, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->fetch_or( arg, order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_fetch_or_explicit( obj, arg, order ); -#else - unsigned long val; - ISR_Level level; - - (void) order; - _ISR_Local_disable( level ); - val = *obj; - *obj = val | arg; - _ISR_Local_enable( level ); - - return val; -#endif -} - -static inline uintptr_t _CPU_atomic_Fetch_or_uintptr( CPU_atomic_Uintptr *obj, uintptr_t arg, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->fetch_or( arg, order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_fetch_or_explicit( obj, arg, order ); -#else - uintptr_t val; - ISR_Level level; - - (void) order; - _ISR_Local_disable( level ); - val = *obj; - *obj = val | arg; - _ISR_Local_enable( level ); - - return val; -#endif -} - -static inline unsigned int _CPU_atomic_Fetch_and_uint( CPU_atomic_Uint *obj, unsigned int arg, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->fetch_and( arg, order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_fetch_and_explicit( obj, arg, order ); -#else - unsigned int val; - ISR_Level level; - - (void) order; - _ISR_Local_disable( level ); - val = *obj; - *obj = val & arg; - _ISR_Local_enable( level ); - - return val; -#endif -} - -static inline unsigned long _CPU_atomic_Fetch_and_ulong( CPU_atomic_Ulong *obj, unsigned long arg, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->fetch_and( arg, order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_fetch_and_explicit( obj, arg, order ); -#else - unsigned long val; - ISR_Level level; - - (void) order; - _ISR_Local_disable( level ); - val = *obj; - *obj = val & arg; - _ISR_Local_enable( level ); - - return val; -#endif -} - -static inline uintptr_t _CPU_atomic_Fetch_and_uintptr( CPU_atomic_Uintptr *obj, uintptr_t arg, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->fetch_and( arg, order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_fetch_and_explicit( obj, arg, order ); -#else - uintptr_t val; - ISR_Level level; - - (void) order; - _ISR_Local_disable( level ); - val = *obj; - *obj = val & arg; - _ISR_Local_enable( level ); - - return val; -#endif -} - -static inline unsigned int _CPU_atomic_Exchange_uint( CPU_atomic_Uint *obj, unsigned int desired, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->exchange( desired, order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_exchange_explicit( obj, desired, order ); -#else - unsigned int val; - ISR_Level level; - - (void) order; - _ISR_Local_disable( level ); - val = *obj; - *obj = desired; - _ISR_Local_enable( level ); - - return val; -#endif -} - -static inline unsigned long _CPU_atomic_Exchange_ulong( CPU_atomic_Ulong *obj, unsigned long desired, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->exchange( desired, order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_exchange_explicit( obj, desired, order ); -#else - unsigned long val; - ISR_Level level; - - (void) order; - _ISR_Local_disable( level ); - val = *obj; - *obj = desired; - _ISR_Local_enable( level ); - - return val; -#endif -} - -static inline uintptr_t _CPU_atomic_Exchange_uintptr( CPU_atomic_Uintptr *obj, uintptr_t desired, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->exchange( desired, order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_exchange_explicit( obj, desired, order ); -#else - uintptr_t val; - ISR_Level level; - - (void) order; - _ISR_Local_disable( level ); - val = *obj; - *obj = desired; - _ISR_Local_enable( level ); - - return val; -#endif -} - -static inline bool _CPU_atomic_Compare_exchange_uint( CPU_atomic_Uint *obj, unsigned int *expected, unsigned int desired, CPU_atomic_Order succ, CPU_atomic_Order fail ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->compare_exchange_strong( *expected, desired, succ, fail ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_compare_exchange_strong_explicit( obj, expected, desired, succ, fail ); -#else - bool success; - ISR_Level level; - unsigned int actual; - - (void) succ; - (void) fail; - _ISR_Local_disable( level ); - actual = *obj; - success = ( actual == *expected ); - if ( success ) { - *obj = desired; - } else { - *expected = actual; - } - _ISR_Local_enable( level ); - - return success; -#endif -} - -static inline bool _CPU_atomic_Compare_exchange_ulong( CPU_atomic_Ulong *obj, unsigned long *expected, unsigned long desired, CPU_atomic_Order succ, CPU_atomic_Order fail ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->compare_exchange_strong( *expected, desired, succ, fail ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_compare_exchange_strong_explicit( obj, expected, desired, succ, fail ); -#else - bool success; - ISR_Level level; - unsigned long actual; - - (void) succ; - (void) fail; - _ISR_Local_disable( level ); - actual = *obj; - success = ( actual == *expected ); - if ( success ) { - *obj = desired; - } else { - *expected = actual; - } - _ISR_Local_enable( level ); - - return success; -#endif -} - -static inline bool _CPU_atomic_Compare_exchange_uintptr( CPU_atomic_Uintptr *obj, uintptr_t *expected, uintptr_t desired, CPU_atomic_Order succ, CPU_atomic_Order fail ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->compare_exchange_strong( *expected, desired, succ, fail ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_compare_exchange_strong_explicit( obj, expected, desired, succ, fail ); -#else - bool success; - ISR_Level level; - uintptr_t actual; - - (void) succ; - (void) fail; - _ISR_Local_disable( level ); - actual = *obj; - success = ( actual == *expected ); - if ( success ) { - *obj = desired; - } else { - *expected = actual; - } - _ISR_Local_enable( level ); - - return success; -#endif -} - -static inline void _CPU_atomic_Flag_clear( CPU_atomic_Flag *obj, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - obj->clear( order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - atomic_flag_clear_explicit( obj, order ); -#else - (void) order; - *obj = false; -#endif -} - -static inline bool _CPU_atomic_Flag_test_and_set( CPU_atomic_Flag *obj, CPU_atomic_Order order ) -{ -#if defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_ATOMIC) - return obj->test_and_set( order ); -#elif defined(_RTEMS_SCORE_CPUSTDATOMIC_USE_STDATOMIC) - return atomic_flag_test_and_set_explicit( obj, order ); -#else - bool flag; - ISR_Level level; - - (void) order; - _ISR_Local_disable( level ); - flag = *obj; - *obj = true; - _ISR_Local_enable( level ); - - return flag; -#endif -} - -#endif /* _RTEMS_SCORE_CPUSTDATOMIC_H */ diff --git a/cpukit/score/include/rtems/score/freechain.h b/cpukit/score/include/rtems/score/freechain.h deleted file mode 100644 index 1540c0e2a1..0000000000 --- a/cpukit/score/include/rtems/score/freechain.h +++ /dev/null @@ -1,111 +0,0 @@ -/** - * @file - * - * @ingroup ScoreFreechain - * - * @brief Freechain Handler API - */ -/* - * Copyright (c) 2013 Gedare Bloom. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_FREECHAIN_H -#define _RTEMS_SCORE_FREECHAIN_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ScoreFreechain Freechain Handler - * - * @ingroup Score - * - * The Freechain Handler is used to manage a chain of nodes, of which size can - * automatically increase when there is no free node left. This handler - * provides one data structure: Freechain_Control. - * - * @{ - */ - -/** - * @brief Allocator function. - */ -typedef void *( *Freechain_Allocator )( size_t size ); - -/** - * @brief The freechain control. - */ -typedef struct { - /** - * @brief Chain of free nodes. - */ - Chain_Control Free; -} Freechain_Control; - -/** - * @brief Initializes a freechain. - * - * This routine initializes the freechain control structure to manage a chain - * of nodes. In case the freechain is empty the extend handler is called to - * get more nodes. - * - * @param[in] freechain The freechain control to initialize. - * @param[in] allocator The allocator function. - * @param[in] number_nodes The initial number of nodes. - * @param[in] node_size The node size. - */ -void _Freechain_Initialize( - Freechain_Control *freechain, - Freechain_Allocator allocator, - size_t number_nodes, - size_t node_size -); - -/** - * @brief Gets a node from the freechain. - * - * @param[in] freechain The freechain control. - * @param[in] allocator The allocator function. - * @param[in] number_nodes_to_extend The number of nodes in case an extend is - * necessary due to an empty freechain. - * @param[in] node_size The node size. - * - * @retval NULL The freechain is empty and the extend operation failed. - * @retval otherwise Pointer to a node. The node ownership passes to the - * caller. - */ -void *_Freechain_Get( - Freechain_Control *freechain, - Freechain_Allocator allocator, - size_t number_nodes_to_extend, - size_t node_size -); - -/** - * @brief Puts a node back onto the freechain. - * - * @param[in] freechain The freechain control. - * @param[in] node The node to put back. The node may be @c NULL, in this case - * the function does nothing. - */ -void _Freechain_Put( - Freechain_Control *freechain, - void *node -); - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/heap.h b/cpukit/score/include/rtems/score/heap.h deleted file mode 100644 index 60cb3be99d..0000000000 --- a/cpukit/score/include/rtems/score/heap.h +++ /dev/null @@ -1,518 +0,0 @@ -/** - * @file - * - * @ingroup ScoreHeap - * - * @brief Heap Handler API - */ - -/* - * COPYRIGHT (c) 1989-2006. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_HEAP_H -#define _RTEMS_SCORE_HEAP_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef RTEMS_DEBUG - #define HEAP_PROTECTION -#endif - -/** - * @defgroup ScoreHeap Heap Handler - * - * @ingroup Score - * - * @brief The Heap Handler provides a heap. - * - * A heap is a doubly linked list of variable size blocks which are allocated - * using the first fit method. Garbage collection is performed each time a - * block is returned to the heap by coalescing neighbor blocks. Control - * information for both allocated and free blocks is contained in the heap - * area. A heap control structure contains control information for the heap. - * - * The alignment routines could be made faster should we require only powers of - * two to be supported for page size, alignment and boundary arguments. The - * minimum alignment requirement for pages is currently CPU_ALIGNMENT and this - * value is only required to be multiple of two and explicitly not required to - * be a power of two. - * - * There are two kinds of blocks. One sort describes a free block from which - * we can allocate memory. The other blocks are used and provide an allocated - * memory area. The free blocks are accessible via a list of free blocks. - * - * Blocks or areas cover a continuous set of memory addresses. They have a - * begin and end address. The end address is not part of the set. The size of - * a block or area equals the distance between the begin and end address in - * units of bytes. - * - * Free blocks look like: - * - * - * - * - * - * - * - * - * - * - *
@ref Heap_Blockprevious block size in case the - * previous block is free,
otherwise it may contain data used by - * the previous block
block size and a flag which indicates if the previous block is free - * or used,
this field contains always valid data regardless of the - * block usage
pointer to next block (this field is page size aligned)
pointer to previous block
free space
- * - * Used blocks look like: - * - * - * - * - * - * - * - * - * - * - *
@ref Heap_Blockprevious block size in case the - * previous block is free,
otherwise it may contain data used by - * the previous block
block size and a flag which indicates if the previous block is free - * or used,
this field contains always valid data regardless of the - * block usage
begin of allocated area (this field is page size aligned)
allocated space
allocated space
- * - * The heap area after initialization contains two blocks and looks like: - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
LabelContent
heap->area_beginheap area begin address
first_block->prev_size - * subordinate heap area end address (this will be used to maintain a - * linked list of scattered heap areas) - *
first_block->sizesize available for allocation - * | @c HEAP_PREV_BLOCK_USED
first_block->next_Heap_Free_list_tail(heap)memory area available for allocation
first_block->prev_Heap_Free_list_head(heap)
...
last_block->prev_sizesize of first block
last_block->sizefirst block begin address - last block begin address
heap->area_endheap area end address
- * The next block of the last block is the first block. Since the first - * block indicates that the previous block is used, this ensures that the - * last block appears as used for the _Heap_Is_used() and _Heap_Is_free() - * functions. - */ -/**@{**/ - -typedef struct Heap_Control Heap_Control; - -typedef struct Heap_Block Heap_Block; - -#ifndef HEAP_PROTECTION - #define HEAP_PROTECTION_HEADER_SIZE 0 -#else - #define HEAP_PROTECTOR_COUNT 2 - - #define HEAP_BEGIN_PROTECTOR_0 ((uintptr_t) 0xfd75a98f) - #define HEAP_BEGIN_PROTECTOR_1 ((uintptr_t) 0xbfa1f177) - #define HEAP_END_PROTECTOR_0 ((uintptr_t) 0xd6b8855e) - #define HEAP_END_PROTECTOR_1 ((uintptr_t) 0x13a44a5b) - - #define HEAP_FREE_PATTERN ((uintptr_t) 0xe7093cdf) - - #define HEAP_PROTECTION_OBOLUS ((Heap_Block *) 1) - - typedef void (*_Heap_Protection_handler)( - Heap_Control *heap, - Heap_Block *block - ); - - typedef struct { - _Heap_Protection_handler block_initialize; - _Heap_Protection_handler block_check; - _Heap_Protection_handler block_error; - void *handler_data; - Heap_Block *first_delayed_free_block; - Heap_Block *last_delayed_free_block; - uintptr_t delayed_free_block_count; - uintptr_t delayed_free_fraction; - } Heap_Protection; - - typedef struct { - uintptr_t protector [HEAP_PROTECTOR_COUNT]; - Heap_Block *next_delayed_free_block; - Thread_Control *task; - void *tag; - } Heap_Protection_block_begin; - - typedef struct { - uintptr_t protector [HEAP_PROTECTOR_COUNT]; - } Heap_Protection_block_end; - - #define HEAP_PROTECTION_HEADER_SIZE \ - (sizeof(Heap_Protection_block_begin) + sizeof(Heap_Protection_block_end)) -#endif - -/** - * @brief The block header consists of the two size fields - * (@ref Heap_Block.prev_size and @ref Heap_Block.size_and_flag). - */ -#define HEAP_BLOCK_HEADER_SIZE \ - (2 * sizeof(uintptr_t) + HEAP_PROTECTION_HEADER_SIZE) - -/** - * @brief Description for free or used blocks. - */ -struct Heap_Block { - /** - * @brief Size of the previous block or part of the allocated area of the - * previous block. - * - * This field is only valid if the previous block is free. This case is - * indicated by a cleared @c HEAP_PREV_BLOCK_USED flag in the - * @a size_and_flag field of the current block. - * - * In a used block only the @a size_and_flag field needs to be valid. The - * @a prev_size field of the current block is maintained by the previous - * block. The current block can use the @a prev_size field in the next block - * for allocation. - */ - uintptr_t prev_size; - - #ifdef HEAP_PROTECTION - Heap_Protection_block_begin Protection_begin; - #endif - - /** - * @brief Contains the size of the current block and a flag which indicates - * if the previous block is free or used. - * - * If the flag @c HEAP_PREV_BLOCK_USED is set, then the previous block is - * used, otherwise the previous block is free. A used previous block may - * claim the @a prev_size field for allocation. This trick allows to - * decrease the overhead in the used blocks by the size of the @a prev_size - * field. As sizes are required to be multiples of two, the least - * significant bits would be always zero. We use this bit to store the flag. - * - * This field is always valid. - */ - uintptr_t size_and_flag; - - #ifdef HEAP_PROTECTION - Heap_Protection_block_end Protection_end; - #endif - - /** - * @brief Pointer to the next free block or part of the allocated area. - * - * This field is page size aligned and begins of the allocated area in case - * the block is used. - * - * This field is only valid if the block is free and thus part of the free - * block list. - */ - Heap_Block *next; - - /** - * @brief Pointer to the previous free block or part of the allocated area. - * - * This field is only valid if the block is free and thus part of the free - * block list. - */ - Heap_Block *prev; -}; - -/** - * @brief Run-time heap statistics. - * - * The value @a searches / @a allocs gives the mean number of searches per - * allocation, while @a max_search gives maximum number of searches ever - * performed on a single allocation call. - */ -typedef struct { - /** - * @brief Lifetime number of bytes allocated from this heap. - * - * This value is an integral multiple of the page size. - */ - uint64_t lifetime_allocated; - - /** - * @brief Lifetime number of bytes freed to this heap. - * - * This value is an integral multiple of the page size. - */ - uint64_t lifetime_freed; - - /** - * @brief Size of the allocatable area in bytes. - * - * This value is an integral multiple of the page size. - */ - uintptr_t size; - - /** - * @brief Current free size in bytes. - * - * This value is an integral multiple of the page size. - */ - uintptr_t free_size; - - /** - * @brief Minimum free size ever in bytes. - * - * This value is an integral multiple of the page size. - */ - uintptr_t min_free_size; - - /** - * @brief Current number of free blocks. - */ - uint32_t free_blocks; - - /** - * @brief Maximum number of free blocks ever. - */ - uint32_t max_free_blocks; - - /** - * @brief Current number of used blocks. - */ - uint32_t used_blocks; - - /** - * @brief Maximum number of blocks searched ever. - */ - uint32_t max_search; - - /** - * @brief Total number of searches. - */ - uint32_t searches; - - /** - * @brief Total number of successful allocations. - */ - uint32_t allocs; - - /** - * @brief Total number of failed allocations. - */ - uint32_t failed_allocs; - - /** - * @brief Total number of successful frees. - */ - uint32_t frees; - - /** - * @brief Total number of successful resizes. - */ - uint32_t resizes; -} Heap_Statistics; - -/** - * @brief Control block used to manage a heap. - */ -struct Heap_Control { - Heap_Block free_list; - uintptr_t page_size; - uintptr_t min_block_size; - uintptr_t area_begin; - uintptr_t area_end; - Heap_Block *first_block; - Heap_Block *last_block; - Heap_Statistics stats; - #ifdef HEAP_PROTECTION - Heap_Protection Protection; - #endif -}; - -/** - * @brief Information about blocks. - */ -typedef struct { - /** - * @brief Number of blocks of this type. - */ - uintptr_t number; - - /** - * @brief Largest block of this type. - */ - uintptr_t largest; - - /** - * @brief Total size of the blocks of this type. - */ - uintptr_t total; -} Heap_Information; - -/** - * @brief Information block returned by _Heap_Get_information(). - */ -typedef struct { - Heap_Information Free; - Heap_Information Used; - Heap_Statistics Stats; -} Heap_Information_block; - -/** - * @brief Heap area structure for table based heap initialization and - * extension. - * - * @see Heap_Initialization_or_extend_handler. - */ -typedef struct { - void *begin; - uintptr_t size; -} Heap_Area; - -/** - * @brief Heap initialization and extend handler type. - * - * This helps to do a table based heap initialization and extension. Create a - * table of Heap_Area elements and iterate through it. Set the handler to - * _Heap_Initialize() in the first iteration and then to _Heap_Extend(). - * - * @see Heap_Area, _Heap_Initialize(), _Heap_Extend(), or _Heap_No_extend(). - */ -typedef uintptr_t (*Heap_Initialization_or_extend_handler)( - Heap_Control *heap, - void *area_begin, - uintptr_t area_size, - uintptr_t page_size_or_unused -); - -/** - * @brief Extends the memory available for the heap @a heap using the memory - * area starting at @a area_begin of size @a area_size bytes. - * - * There are no alignment requirements for the memory area. The memory area - * must be big enough to contain some maintenance blocks. It must not overlap - * parts of the current heap memory areas. Disconnected memory areas added to - * the heap will lead to used blocks which cover the gaps. Extending with an - * inappropriate memory area will corrupt the heap resulting in undefined - * behaviour. - * - * The unused fourth parameter is provided to have the same signature as - * _Heap_Initialize(). - * - * Returns the extended space available for allocation, or zero in case of failure. - * - * @see Heap_Initialization_or_extend_handler. - */ -uintptr_t _Heap_Extend( - Heap_Control *heap, - void *area_begin, - uintptr_t area_size, - uintptr_t unused -); - -/** - * @brief This function returns always zero. - * - * This function only returns zero and does nothing else. - * - * Returns always zero. - * - * @see Heap_Initialization_or_extend_handler. - */ -uintptr_t _Heap_No_extend( - Heap_Control *unused_0, - void *unused_1, - uintptr_t unused_2, - uintptr_t unused_3 -); - -RTEMS_INLINE_ROUTINE uintptr_t _Heap_Align_up( - uintptr_t value, - uintptr_t alignment -) -{ - uintptr_t remainder = value % alignment; - - if ( remainder != 0 ) { - return value - remainder + alignment; - } else { - return value; - } -} - -RTEMS_INLINE_ROUTINE uintptr_t _Heap_Min_block_size( uintptr_t page_size ) -{ - return _Heap_Align_up( sizeof( Heap_Block ), page_size ); -} - -/** - * @brief Returns the worst case overhead to manage a memory area. - */ -RTEMS_INLINE_ROUTINE uintptr_t _Heap_Area_overhead( - uintptr_t page_size -) -{ - if ( page_size != 0 ) { - page_size = _Heap_Align_up( page_size, CPU_ALIGNMENT ); - } else { - page_size = CPU_ALIGNMENT; - } - - return 2 * (page_size - 1) + HEAP_BLOCK_HEADER_SIZE; -} - -/** - * @brief Returns the size with administration and alignment overhead for one - * allocation. - */ -RTEMS_INLINE_ROUTINE uintptr_t _Heap_Size_with_overhead( - uintptr_t page_size, - uintptr_t size, - uintptr_t alignment -) -{ - if ( page_size != 0 ) { - page_size = _Heap_Align_up( page_size, CPU_ALIGNMENT ); - } else { - page_size = CPU_ALIGNMENT; - } - - if ( page_size < alignment ) { - page_size = alignment; - } - - return HEAP_BLOCK_HEADER_SIZE + page_size - 1 + size; -} - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/heapimpl.h b/cpukit/score/include/rtems/score/heapimpl.h deleted file mode 100644 index a8948edd6f..0000000000 --- a/cpukit/score/include/rtems/score/heapimpl.h +++ /dev/null @@ -1,601 +0,0 @@ -/** - * @file - * - * @ingroup ScoreHeap - * - * @brief Heap Handler Implementation - */ - -/* - * COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_HEAPIMPL_H -#define _RTEMS_SCORE_HEAPIMPL_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ScoreHeap - */ -/**@{**/ - -/** - * @brief See also @ref Heap_Block.size_and_flag. - */ -#define HEAP_PREV_BLOCK_USED ((uintptr_t) 1) - -/** - * @brief Size of the part at the block begin which may be used for allocation - * in charge of the previous block. - */ -#define HEAP_ALLOC_BONUS sizeof(uintptr_t) - -/** - * @brief See _Heap_Resize_block(). - */ -typedef enum { - HEAP_RESIZE_SUCCESSFUL, - HEAP_RESIZE_UNSATISFIED, - HEAP_RESIZE_FATAL_ERROR -} Heap_Resize_status; - -/** - * @brief Gets the first and last block for the heap area with begin - * @a heap_area_begin and size @a heap_area_size. - * - * A page size of @a page_size and minimal block size of @a min_block_size will - * be used for calculation. - * - * Nothing will be written to this area. - * - * In case of success the pointers to the first and last block will be returned - * via @a first_block_ptr and @a last_block_ptr. - * - * Returns @c true if the area is big enough, and @c false otherwise. - */ -bool _Heap_Get_first_and_last_block( - uintptr_t heap_area_begin, - uintptr_t heap_area_size, - uintptr_t page_size, - uintptr_t min_block_size, - Heap_Block **first_block_ptr, - Heap_Block **last_block_ptr -); - -/** - * @brief Initializes the heap control block @a heap to manage the area - * starting at @a area_begin of size @a area_size bytes. - * - * Blocks of memory are allocated from the heap in multiples of @a page_size - * byte units. If the @a page_size is equal to zero or is not multiple of - * @c CPU_ALIGNMENT, it is aligned up to the nearest @c CPU_ALIGNMENT boundary. - * - * Returns the maximum memory available, or zero in case of failure. - * - * @see Heap_Initialization_or_extend_handler. - */ -uintptr_t _Heap_Initialize( - Heap_Control *heap, - void *area_begin, - uintptr_t area_size, - uintptr_t page_size -); - -/** - * @brief Allocates a memory area of size @a size bytes from the heap @a heap. - * - * If the alignment parameter @a alignment is not equal to zero, the allocated - * memory area will begin at an address aligned by this value. - * - * If the boundary parameter @a boundary is not equal to zero, the allocated - * memory area will fulfill a boundary constraint. The boundary value - * specifies the set of addresses which are aligned by the boundary value. The - * interior of the allocated memory area will not contain an element of this - * set. The begin or end address of the area may be a member of the set. - * - * A size value of zero will return a unique address which may be freed with - * _Heap_Free(). - * - * Returns a pointer to the begin of the allocated memory area, or @c NULL if - * no memory is available or the parameters are inconsistent. - */ -void *_Heap_Allocate_aligned_with_boundary( - Heap_Control *heap, - uintptr_t size, - uintptr_t alignment, - uintptr_t boundary -); - -/** - * @brief See _Heap_Allocate_aligned_with_boundary() with boundary equals zero. - */ -RTEMS_INLINE_ROUTINE void *_Heap_Allocate_aligned( - Heap_Control *heap, - uintptr_t size, - uintptr_t alignment -) -{ - return _Heap_Allocate_aligned_with_boundary( heap, size, alignment, 0 ); -} - -/** - * @brief See _Heap_Allocate_aligned_with_boundary() with alignment and - * boundary equals zero. - */ -RTEMS_INLINE_ROUTINE void *_Heap_Allocate( Heap_Control *heap, uintptr_t size ) -{ - return _Heap_Allocate_aligned_with_boundary( heap, size, 0, 0 ); -} - -/** - * @brief Frees the allocated memory area starting at @a addr in the heap - * @a heap. - * - * Inappropriate values for @a addr may corrupt the heap. - * - * Returns @c true in case of success, and @c false otherwise. - */ -bool _Heap_Free( Heap_Control *heap, void *addr ); - -/** - * @brief Walks the heap @a heap to verify its integrity. - * - * If @a dump is @c true, then diagnostic messages will be printed to standard - * output. In this case @a source is used to mark the output lines. - * - * Returns @c true if no errors occurred, and @c false if the heap is corrupt. - */ -bool _Heap_Walk( - Heap_Control *heap, - int source, - bool dump -); - -/** - * @brief Heap block visitor. - * - * @see _Heap_Iterate(). - * - * @retval true Stop the iteration. - * @retval false Continue the iteration. - */ -typedef bool (*Heap_Block_visitor)( - const Heap_Block *block, - uintptr_t block_size, - bool block_is_used, - void *visitor_arg -); - -/** - * @brief Iterates over all blocks of the heap. - * - * For each block the @a visitor with the argument @a visitor_arg will be - * called. - */ -void _Heap_Iterate( - Heap_Control *heap, - Heap_Block_visitor visitor, - void *visitor_arg -); - -/** - * @brief Greedy allocate that empties the heap. - * - * Afterwards the heap has at most @a block_count allocatable blocks of sizes - * specified by @a block_sizes. The @a block_sizes must point to an array with - * @a block_count members. All other blocks are used. - * - * @see _Heap_Greedy_free(). - */ -Heap_Block *_Heap_Greedy_allocate( - Heap_Control *heap, - const uintptr_t *block_sizes, - size_t block_count -); - -/** - * @brief Greedy allocate all blocks except the largest free block. - * - * Afterwards the heap has at most one allocatable block. This block is the - * largest free block if it exists. The allocatable size of this block is - * stored in @a allocatable_size. All other blocks are used. - * - * @see _Heap_Greedy_free(). - */ -Heap_Block *_Heap_Greedy_allocate_all_except_largest( - Heap_Control *heap, - uintptr_t *allocatable_size -); - -/** - * @brief Frees blocks of a greedy allocation. - * - * The @a blocks must be the return value of _Heap_Greedy_allocate(). - */ -void _Heap_Greedy_free( - Heap_Control *heap, - Heap_Block *blocks -); - -/** - * @brief Returns information about used and free blocks for the heap @a heap - * in @a info. - */ -void _Heap_Get_information( - Heap_Control *heap, - Heap_Information_block *info -); - -/** - * @brief Returns information about free blocks for the heap @a heap in - * @a info. - */ -void _Heap_Get_free_information( - Heap_Control *heap, - Heap_Information *info -); - -/** - * @brief Returns the size of the allocatable memory area starting at @a addr - * in @a size. - * - * The size value may be greater than the initially requested size in - * _Heap_Allocate_aligned_with_boundary(). - * - * Inappropriate values for @a addr will not corrupt the heap, but may yield - * invalid size values. - * - * Returns @a true if successful, and @c false otherwise. - */ -bool _Heap_Size_of_alloc_area( - Heap_Control *heap, - void *addr, - uintptr_t *size -); - -/** - * @brief Resizes the block of the allocated memory area starting at @a addr. - * - * The new memory area will have a size of at least @a size bytes. A resize - * may be impossible and depends on the current heap usage. - * - * The size available for allocation in the current block before the resize - * will be returned in @a old_size. The size available for allocation in - * the resized block will be returned in @a new_size. If the resize was not - * successful, then a value of zero will be returned in @a new_size. - * - * Inappropriate values for @a addr may corrupt the heap. - */ -Heap_Resize_status _Heap_Resize_block( - Heap_Control *heap, - void *addr, - uintptr_t size, - uintptr_t *old_size, - uintptr_t *new_size -); - -/** - * @brief Allocates the memory area starting at @a alloc_begin of size - * @a alloc_size bytes in the block @a block. - * - * The block may be split up into multiple blocks. The previous and next block - * may be used or free. Free block parts which form a vaild new block will be - * inserted into the free list or merged with an adjacent free block. If the - * block is used, they will be inserted after the free list head. If the block - * is free, they will be inserted after the previous block in the free list. - * - * Inappropriate values for @a alloc_begin or @a alloc_size may corrupt the - * heap. - * - * Returns the block containing the allocated memory area. - */ -Heap_Block *_Heap_Block_allocate( - Heap_Control *heap, - Heap_Block *block, - uintptr_t alloc_begin, - uintptr_t alloc_size -); - -#ifndef HEAP_PROTECTION - #define _Heap_Protection_block_initialize( heap, block ) ((void) 0) - #define _Heap_Protection_block_check( heap, block ) ((void) 0) - #define _Heap_Protection_block_error( heap, block ) ((void) 0) - #define _Heap_Protection_free_all_delayed_blocks( heap ) ((void) 0) -#else - static inline void _Heap_Protection_block_initialize( - Heap_Control *heap, - Heap_Block *block - ) - { - (*heap->Protection.block_initialize)( heap, block ); - } - - static inline void _Heap_Protection_block_check( - Heap_Control *heap, - Heap_Block *block - ) - { - (*heap->Protection.block_check)( heap, block ); - } - - static inline void _Heap_Protection_block_error( - Heap_Control *heap, - Heap_Block *block - ) - { - (*heap->Protection.block_error)( heap, block ); - } - - static inline void _Heap_Protection_free_all_delayed_blocks( Heap_Control *heap ) - { - uintptr_t large = 0 - - (uintptr_t) HEAP_BLOCK_HEADER_SIZE - - (uintptr_t) HEAP_ALLOC_BONUS - - (uintptr_t) 1; - void *p = _Heap_Allocate( heap, large ); - _Heap_Free( heap, p ); - } -#endif - -/** - * @brief Sets the fraction of delayed free blocks that is actually freed - * during memory shortage. - * - * The default is to free half the delayed free blocks. This is equal to a - * fraction value of two. - * - * @param[in] heap The heap control. - * @param[in] fraction The fraction is one divided by this fraction value. - */ -RTEMS_INLINE_ROUTINE void _Heap_Protection_set_delayed_free_fraction( - Heap_Control *heap, - uintptr_t fraction -) -{ -#ifdef HEAP_PROTECTION - heap->Protection.delayed_free_fraction = fraction; -#else - (void) heap; - (void) fraction; -#endif -} - -RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Free_list_head( Heap_Control *heap ) -{ - return &heap->free_list; -} - -RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Free_list_tail( Heap_Control *heap ) -{ - return &heap->free_list; -} - -RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Free_list_first( Heap_Control *heap ) -{ - return _Heap_Free_list_head(heap)->next; -} - -RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Free_list_last( Heap_Control *heap ) -{ - return _Heap_Free_list_tail(heap)->prev; -} - -RTEMS_INLINE_ROUTINE void _Heap_Free_list_remove( Heap_Block *block ) -{ - Heap_Block *next = block->next; - Heap_Block *prev = block->prev; - - prev->next = next; - next->prev = prev; -} - -RTEMS_INLINE_ROUTINE void _Heap_Free_list_replace( - Heap_Block *old_block, - Heap_Block *new_block -) -{ - Heap_Block *next = old_block->next; - Heap_Block *prev = old_block->prev; - - new_block->next = next; - new_block->prev = prev; - - next->prev = new_block; - prev->next = new_block; -} - -RTEMS_INLINE_ROUTINE void _Heap_Free_list_insert_after( - Heap_Block *block_before, - Heap_Block *new_block -) -{ - Heap_Block *next = block_before->next; - - new_block->next = next; - new_block->prev = block_before; - block_before->next = new_block; - next->prev = new_block; -} - -RTEMS_INLINE_ROUTINE void _Heap_Free_list_insert_before( - Heap_Block *block_next, - Heap_Block *new_block -) -{ - Heap_Block *prev = block_next->prev; - - new_block->next = block_next; - new_block->prev = prev; - prev->next = new_block; - block_next->prev = new_block; -} - -RTEMS_INLINE_ROUTINE bool _Heap_Is_aligned( - uintptr_t value, - uintptr_t alignment -) -{ - return (value % alignment) == 0; -} - -RTEMS_INLINE_ROUTINE uintptr_t _Heap_Align_down( - uintptr_t value, - uintptr_t alignment -) -{ - return value - (value % alignment); -} - -/** - * @brief Returns the block which is @a offset away from @a block. - */ -RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Block_at( - const Heap_Block *block, - uintptr_t offset -) -{ - return (Heap_Block *) ((uintptr_t) block + offset); -} - -RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Prev_block( - const Heap_Block *block -) -{ - return (Heap_Block *) ((uintptr_t) block - block->prev_size); -} - -RTEMS_INLINE_ROUTINE uintptr_t _Heap_Alloc_area_of_block( - const Heap_Block *block -) -{ - return (uintptr_t) block + HEAP_BLOCK_HEADER_SIZE; -} - -RTEMS_INLINE_ROUTINE Heap_Block *_Heap_Block_of_alloc_area( - uintptr_t alloc_begin, - uintptr_t page_size -) -{ - return (Heap_Block *) (_Heap_Align_down( alloc_begin, page_size ) - - HEAP_BLOCK_HEADER_SIZE); -} - -RTEMS_INLINE_ROUTINE uintptr_t _Heap_Block_size( const Heap_Block *block ) -{ - return block->size_and_flag & ~HEAP_PREV_BLOCK_USED; -} - -RTEMS_INLINE_ROUTINE void _Heap_Block_set_size( - Heap_Block *block, - uintptr_t size -) -{ - uintptr_t flag = block->size_and_flag & HEAP_PREV_BLOCK_USED; - - block->size_and_flag = size | flag; -} - -RTEMS_INLINE_ROUTINE bool _Heap_Is_prev_used( const Heap_Block *block ) -{ - return block->size_and_flag & HEAP_PREV_BLOCK_USED; -} - -RTEMS_INLINE_ROUTINE bool _Heap_Is_used( - const Heap_Block *block -) -{ - const Heap_Block *const next_block = - _Heap_Block_at( block, _Heap_Block_size( block ) ); - - return _Heap_Is_prev_used( next_block ); -} - -RTEMS_INLINE_ROUTINE bool _Heap_Is_free( - const Heap_Block *block -) -{ - return !_Heap_Is_used( block ); -} - -RTEMS_INLINE_ROUTINE bool _Heap_Is_block_in_heap( - const Heap_Control *heap, - const Heap_Block *block -) -{ - return (uintptr_t) block >= (uintptr_t) heap->first_block - && (uintptr_t) block <= (uintptr_t) heap->last_block; -} - -/** - * @brief Sets the size of the last block for heap @a heap. - * - * The next block of the last block will be the first block. Since the first - * block indicates that the previous block is used, this ensures that the last - * block appears as used for the _Heap_Is_used() and _Heap_Is_free() - * functions. - * - * This feature will be used to terminate the scattered heap area list. See - * also _Heap_Extend(). - */ -RTEMS_INLINE_ROUTINE void _Heap_Set_last_block_size( Heap_Control *heap ) -{ - _Heap_Block_set_size( - heap->last_block, - (uintptr_t) heap->first_block - (uintptr_t) heap->last_block - ); -} - -/** - * @brief Returns the size of the allocatable area in bytes. - * - * This value is an integral multiple of the page size. - */ -RTEMS_INLINE_ROUTINE uintptr_t _Heap_Get_size( const Heap_Control *heap ) -{ - return heap->stats.size; -} - -RTEMS_INLINE_ROUTINE uintptr_t _Heap_Max( uintptr_t a, uintptr_t b ) -{ - return a > b ? a : b; -} - -RTEMS_INLINE_ROUTINE uintptr_t _Heap_Min( uintptr_t a, uintptr_t b ) -{ - return a < b ? a : b; -} - -#ifdef RTEMS_DEBUG - #define RTEMS_HEAP_DEBUG -#endif - -#ifdef RTEMS_HEAP_DEBUG - #include - #define _HAssert( cond ) \ - do { \ - if ( !(cond) ) { \ - __assert( __FILE__, __LINE__, #cond ); \ - } \ - } while (0) -#else - #define _HAssert( cond ) ((void) 0) -#endif - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/interr.h b/cpukit/score/include/rtems/score/interr.h deleted file mode 100644 index 3144952716..0000000000 --- a/cpukit/score/include/rtems/score/interr.h +++ /dev/null @@ -1,268 +0,0 @@ -/** - * @file rtems/score/interr.h - * - * @brief Constants and Prototypes Related to the Internal Error Handler - * - * This include file contains constants and prototypes related - * to the Internal Error Handler. - */ - -/* - * COPYRIGHT (c) 1989-2009. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_INTERR_H -#define _RTEMS_SCORE_INTERR_H - -#include -#include - -#include - -/** - * @defgroup ScoreIntErr Internal Error Handler - * - * @ingroup Score - * - * This handler encapsulates functionality which provides the foundation - * Semaphore services used in all of the APIs supported by RTEMS. - */ -/**@{*/ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief This type lists the possible sources from which an error - * can be reported. - */ -typedef enum { - /** - * @brief Errors of the core system. - * - * @see Internal_errors_Core_list. - */ - INTERNAL_ERROR_CORE = 0, - - /** - * @brief Errors of the RTEMS API. - */ - INTERNAL_ERROR_RTEMS_API = 1, - - /** - * @brief Errors of the POSIX API. - */ - INTERNAL_ERROR_POSIX_API = 2, - - /** - * @brief Fatal source for the block device cache. - * - * @see rtems_bdbuf_fatal_code. - */ - RTEMS_FATAL_SOURCE_BDBUF = 3, - - /** - * @brief Fatal source for application specific errors. - * - * The fatal code is application specific. - */ - RTEMS_FATAL_SOURCE_APPLICATION = 4, - - /** - * @brief Fatal source of exit(). - * - * The fatal code is the exit() status code. - */ - RTEMS_FATAL_SOURCE_EXIT = 5, - - /** - * @brief Fatal source for BSP errors. - * - * The fatal codes are defined in . Examples are interrupt and - * exception initialization. - * - * @see bsp_fatal_code and bsp_fatal(). - */ - RTEMS_FATAL_SOURCE_BSP = 6, - - /** - * @brief Fatal source of assert(). - * - * The fatal code is the pointer value of the assert context. - * - * @see rtems_assert_context. - */ - RTEMS_FATAL_SOURCE_ASSERT = 7, - - /** - * @brief Fatal source of the stack checker. - * - * The fatal code is the object name of the executing task. - */ - RTEMS_FATAL_SOURCE_STACK_CHECKER = 8, - - /** - * @brief Fatal source of the exceptions. - * - * The fatal code is the pointer value of the exception frame pointer. - * - * @see rtems_exception_frame and rtems_exception_frame_print(). - */ - RTEMS_FATAL_SOURCE_EXCEPTION = 9, - - /** - * @brief Fatal source of SMP domain. - * - * @see SMP_Fatal_code. - */ - RTEMS_FATAL_SOURCE_SMP = 10, - - /** - * @brief Fatal source of rtems_panic(). - * - * @see rtem - */ - RTEMS_FATAL_SOURCE_PANIC = 11, - - /** - * @brief The last available fatal source. - * - * This enum value ensures that the enum type needs at least 32-bits for - * architectures with short enums. - */ - RTEMS_FATAL_SOURCE_LAST = 0xffffffff -} Internal_errors_Source; - -/** - * @brief A list of errors which are generated internally by the executive - * core. - * - * Do not re-use numbers of obsolete error codes. Uncomment no longer used - * error codes. - */ -typedef enum { - /* INTERNAL_ERROR_NO_CONFIGURATION_TABLE = 0, */ - /* INTERNAL_ERROR_NO_CPU_TABLE = 1, */ - INTERNAL_ERROR_TOO_LITTLE_WORKSPACE = 2, - INTERNAL_ERROR_WORKSPACE_ALLOCATION = 3, - INTERNAL_ERROR_INTERRUPT_STACK_TOO_SMALL = 4, - INTERNAL_ERROR_THREAD_EXITTED = 5, - INTERNAL_ERROR_INCONSISTENT_MP_INFORMATION = 6, - INTERNAL_ERROR_INVALID_NODE = 7, - INTERNAL_ERROR_NO_MPCI = 8, - INTERNAL_ERROR_BAD_PACKET = 9, - INTERNAL_ERROR_OUT_OF_PACKETS = 10, - INTERNAL_ERROR_OUT_OF_GLOBAL_OBJECTS = 11, - INTERNAL_ERROR_OUT_OF_PROXIES = 12, - INTERNAL_ERROR_INVALID_GLOBAL_ID = 13, - INTERNAL_ERROR_BAD_STACK_HOOK = 14, - /* INTERNAL_ERROR_BAD_ATTRIBUTES = 15, */ - /* INTERNAL_ERROR_IMPLEMENTATION_KEY_CREATE_INCONSISTENCY = 16, */ - /* INTERNAL_ERROR_IMPLEMENTATION_BLOCKING_OPERATION_CANCEL = 17, */ - /* INTERNAL_ERROR_THREAD_QUEUE_ENQUEUE_FROM_BAD_STATE = 18, */ - INTERNAL_ERROR_UNLIMITED_AND_MAXIMUM_IS_0 = 19, - /* INTERNAL_ERROR_SHUTDOWN_WHEN_NOT_UP = 20, */ - INTERNAL_ERROR_GXX_KEY_ADD_FAILED = 21, - INTERNAL_ERROR_GXX_MUTEX_INIT_FAILED = 22, - INTERNAL_ERROR_NO_MEMORY_FOR_HEAP = 23, - INTERNAL_ERROR_CPU_ISR_INSTALL_VECTOR = 24, - INTERNAL_ERROR_RESOURCE_IN_USE = 25, - INTERNAL_ERROR_RTEMS_INIT_TASK_ENTRY_IS_NULL = 26, - /* INTERNAL_ERROR_POSIX_INIT_THREAD_ENTRY_IS_NULL = 27, */ - INTERNAL_ERROR_THREAD_QUEUE_DEADLOCK = 28, - INTERNAL_ERROR_THREAD_QUEUE_ENQUEUE_STICKY_FROM_BAD_STATE = 29, - INTERNAL_ERROR_BAD_THREAD_DISPATCH_DISABLE_LEVEL = 30, - INTERNAL_ERROR_BAD_THREAD_DISPATCH_ENVIRONMENT = 31, - INTERNAL_ERROR_RTEMS_INIT_TASK_CREATE_FAILED = 32, - INTERNAL_ERROR_POSIX_INIT_THREAD_CREATE_FAILED = 33, - INTERNAL_ERROR_LIBIO_USER_ENV_KEY_CREATE_FAILED = 34, - /* INTERNAL_ERROR_LIBIO_SEM_CREATE_FAILED = 35, */ - INTERNAL_ERROR_LIBIO_STDOUT_FD_OPEN_FAILED = 36, - INTERNAL_ERROR_LIBIO_STDERR_FD_OPEN_FAILED = 37, - INTERNAL_ERROR_ILLEGAL_USE_OF_FLOATING_POINT_UNIT = 38, - INTERNAL_ERROR_ARC4RANDOM_GETENTROPY_FAIL = 39 -} Internal_errors_Core_list; - -typedef CPU_Uint32ptr Internal_errors_t; - -/** - * This type holds the fatal error information. - */ -typedef struct { - /** This is the source of the error. */ - Internal_errors_Source the_source; - /** This is the error code. */ - Internal_errors_t the_error; -} Internal_errors_Information; - -/** - * When a fatal error occurs, the error information is stored here. - */ -extern Internal_errors_Information _Internal_errors_What_happened; - -/** - * @brief Initiates system termination. - * - * This routine is invoked when the application or the executive itself - * determines that a fatal error has occurred or a final system state is - * reached (for example after exit()). - * - * The first action of this function is to call the fatal handler of the user - * extensions. For the initial extensions the following conditions are - * required - * - a valid stack pointer and enough stack space, - * - a valid code memory, and - * - valid read-only data. - * - * For the initial extensions the read-write data (including BSS segment) is - * not required on single processor configurations. On SMP configurations - * however the read-write data must be initialized since this function must - * determine the state of the other processors and request them to shut-down if - * necessary. - * - * Non-initial extensions require in addition valid read-write data. The BSP - * may install an initial extension that performs a system reset. In this case - * the non-initial extensions will be not called. - * - * Once all fatal handler executed the error information will be stored to - * _Internal_errors_What_happened and the system state is set to - * SYSTEM_STATE_TERMINATED. - * - * The final step is to call the CPU specific _CPU_Fatal_halt(). - * - * @param[in] the_source The fatal source indicating the subsystem the fatal - * condition originated in. - * @param[in] the_error The fatal error code. This value must be interpreted - * with respect to the source. - * - * @see rtems_fatal() and _Internal_error(). - */ -void _Terminate( - Internal_errors_Source the_source, - Internal_errors_t the_error -) RTEMS_NO_RETURN; - -/** - * @brief Terminates the system with an INTERNAL_ERROR_CORE fatal source and - * the specified core error code. - * - * @param[in] core_error The core error code. - * - * @see _Terminate(). - */ -void _Internal_error( Internal_errors_Core_list core_error ) RTEMS_NO_RETURN; - -#ifdef __cplusplus -} -#endif - -/**@}*/ - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/io.h b/cpukit/score/include/rtems/score/io.h deleted file mode 100644 index ae3c57f031..0000000000 --- a/cpukit/score/include/rtems/score/io.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2017 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_IO_H -#define _RTEMS_SCORE_IO_H - -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -typedef void ( *IO_Put_char )(int c, void *arg); - -int _IO_Printf( - IO_Put_char put_char, - void *arg, - char const *fmt, - ... -) RTEMS_PRINTFLIKE( 3, 4 ); - -int _IO_Vprintf( - IO_Put_char put_char, - void *arg, - char const *fmt, - va_list ap -); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_SCORE_IO_H */ diff --git a/cpukit/score/include/rtems/score/isr.h b/cpukit/score/include/rtems/score/isr.h deleted file mode 100644 index d9c03b807f..0000000000 --- a/cpukit/score/include/rtems/score/isr.h +++ /dev/null @@ -1,155 +0,0 @@ -/** - * @file rtems/score/isr.h - * - * @brief Data Related to the Management of Processor Interrupt Levels - * - * This include file contains all the constants and structures associated - * with the management of processor interrupt levels. This handler - * supports interrupt critical sections, vectoring of user interrupt - * handlers, nesting of interrupts, and manipulating interrupt levels. - */ - -/* - * COPYRIGHT (c) 1989-2012. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_ISR_H -#define _RTEMS_SCORE_ISR_H - -#include - -/** - * @defgroup ScoreISR ISR Handler - * - * @ingroup Score - * - * This handler encapsulates functionality which provides the foundation - * ISR services used in all of the APIs supported by RTEMS. - * - * The ISR Nest level counter variable is maintained as part of the - * per cpu data structure. - */ -/**@{*/ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * The following type defines the type used to manage the vectors. - */ -typedef uint32_t ISR_Vector_number; - -/** - * Return type for ISR Handler - */ -typedef void ISR_Handler; - -#if (CPU_SIMPLE_VECTORED_INTERRUPTS == FALSE) - -typedef void * ISR_Handler_entry; - -#else -/** - * Pointer to an ISR Handler - */ -#if (CPU_ISR_PASSES_FRAME_POINTER == TRUE) -typedef ISR_Handler ( *ISR_Handler_entry )( - ISR_Vector_number, - CPU_Interrupt_frame * - ); -#else -typedef ISR_Handler ( *ISR_Handler_entry )( - ISR_Vector_number - ); -#endif - -/** - * The following declares the Vector Table. Application - * interrupt service routines are vectored by the ISR Handler via this table. - */ -extern ISR_Handler_entry _ISR_Vector_table[ CPU_INTERRUPT_NUMBER_OF_VECTORS ]; -#endif - -/** - * @brief Initialize the ISR handler. - * - * This routine performs the initialization necessary for the ISR handler. - */ -void _ISR_Handler_initialization ( void ); - -/** - * @brief Install interrupt handler vector. - * - * This routine installs new_handler as the interrupt service routine - * for the specified vector. The previous interrupt service routine is - * returned as old_handler. - * - * LM32 Specific Information: - * XXX document implementation including references if appropriate - * - * @param[in] _vector is the vector number - * @param[in] _new_handler is ISR handler to install - * @param[in] _old_handler is a pointer to a variable which will be set - * to the old handler - * - * @retval *_old_handler will be set to the old ISR handler - */ -#define _ISR_Install_vector( _vector, _new_handler, _old_handler ) \ - _CPU_ISR_install_vector( _vector, _new_handler, _old_handler ) - -/** - * @brief ISR interrupt dispatcher. - * - * This routine is the interrupt dispatcher. ALL interrupts - * are vectored to this routine so that minimal context can be saved - * and setup performed before the application's high-level language - * interrupt service routine is invoked. After the application's - * interrupt service routine returns control to this routine, it - * will determine if a thread dispatch is necessary. If so, it will - * ensure that the necessary thread scheduling operations are - * performed when the outermost interrupt service routine exits. - * - * @note Typically implemented in assembly language. - */ -void _ISR_Handler( void ); - -/** - * @brief ISR wrapper for thread dispatcher. - * - * This routine provides a wrapper so that the routine - * @ref _Thread_Dispatch can be invoked when a reschedule is necessary - * at the end of the outermost interrupt service routine. This - * wrapper is necessary to establish the processor context needed - * by _Thread_Dispatch and to save the processor context which is - * corrupted by _Thread_Dispatch. This context typically consists - * of registers which are not preserved across routine invocations. - * - * @note Typically mplemented in assembly language. - */ -void _ISR_Dispatch( void ); - -/** - * @brief Checks if an ISR in progress. - * - * This function returns true if the processor is currently servicing - * and interrupt and false otherwise. A return value of true indicates - * that the caller is an interrupt service routine, NOT a thread. - * - * @retval This methods returns true when called from an ISR. - */ -bool _ISR_Is_in_progress( void ); - -#ifdef __cplusplus -} -#endif - -/**@}*/ - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/isrlevel.h b/cpukit/score/include/rtems/score/isrlevel.h deleted file mode 100644 index abfb1b67fc..0000000000 --- a/cpukit/score/include/rtems/score/isrlevel.h +++ /dev/null @@ -1,153 +0,0 @@ -/** - * @file rtems/score/isrlevel.h - * - * @brief ISR Level Type - * - * This include file defines the ISR Level type. It exists to - * simplify include dependencies. It is part of the ISR Handler. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_ISR_LEVEL_h -#define _RTEMS_SCORE_ISR_LEVEL_h - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ScoreISR ISR Handler - * - * @ingroup Score - * - * @addtogroup ScoreISR ISR Handler - */ -/**@{*/ - -/** - * The following type defines the control block used to manage - * the interrupt level portion of the status register. - */ -typedef uint32_t ISR_Level; - -/** - * @brief Disables interrupts on this processor. - * - * This macro disables all interrupts on this processor so that a critical - * section of code is protected from concurrent access by interrupts of this - * processor. Disabling of interrupts disables thread dispatching on the - * processor as well. - * - * On SMP configurations other processors can enter such sections if not - * protected by other means. - * - * @param[out] _level The argument @a _level will contain the previous - * interrupt mask level. - */ -#define _ISR_Local_disable( _level ) \ - do { \ - _CPU_ISR_Disable( _level ); \ - RTEMS_COMPILER_MEMORY_BARRIER(); \ - } while (0) - -/** - * @brief Enables interrupts on this processor. - * - * This macro restores the interrupt status on the processor with the - * interrupt level value obtained by _ISR_Local_disable(). It is used at the end of - * a critical section of code to enable interrupts so they can be processed - * again. - * - * @param[in] _level The interrupt level previously obtained by - * _ISR_Local_disable(). - */ -#define _ISR_Local_enable( _level ) \ - do { \ - RTEMS_COMPILER_MEMORY_BARRIER(); \ - _CPU_ISR_Enable( _level ); \ - } while (0) - -/** - * @brief Temporarily enables interrupts on this processor. - * - * This macro temporarily enables interrupts to the previous - * interrupt mask level and then disables all interrupts so that - * the caller can continue into the second part of a critical - * section. - * - * This routine is used to temporarily enable interrupts - * during a long critical section. It is used in long sections of - * critical code when a point is reached at which interrupts can - * be temporarily enabled. Deciding where to flash interrupts - * in a long critical section is often difficult and the point - * must be selected with care to ensure that the critical section - * properly protects itself. - * - * @param[in] _level The interrupt level previously obtained by - * _ISR_Local_disable(). - */ -#define _ISR_Local_flash( _level ) \ - do { \ - RTEMS_COMPILER_MEMORY_BARRIER(); \ - _CPU_ISR_Flash( _level ); \ - RTEMS_COMPILER_MEMORY_BARRIER(); \ - } while (0) - -/** - * @brief Returns true if interrupts are enabled in the specified interrupt - * level, otherwise returns false. - * - * @param[in] _level The ISR level. - * - * @retval true Interrupts are enabled in the interrupt level. - * @retval false Otherwise. - */ -#define _ISR_Is_enabled( _level ) \ - _CPU_ISR_Is_enabled( _level ) - -/** - * @brief Return current interrupt level. - * - * This routine returns the current interrupt level. - * - * LM32 Specific Information: - * XXX document implementation including references if appropriate - * - * @retval This method returns the current level. - */ -#define _ISR_Get_level() \ - _CPU_ISR_Get_level() - -/** - * @brief Set current interrupt level. - * - * This routine sets the current interrupt level to that specified - * by @a _new_level. The new interrupt level is effective when the - * routine exits. - * - * @param[in] _new_level contains the desired interrupt level. - */ -#define _ISR_Set_level( _new_level ) \ - do { \ - RTEMS_COMPILER_MEMORY_BARRIER(); \ - _CPU_ISR_Set_level( _new_level ); \ - RTEMS_COMPILER_MEMORY_BARRIER(); \ - } while (0) - -/**@}*/ - -#ifdef __cplusplus -} -#endif -#endif diff --git a/cpukit/score/include/rtems/score/isrlock.h b/cpukit/score/include/rtems/score/isrlock.h deleted file mode 100644 index 7dd2f29000..0000000000 --- a/cpukit/score/include/rtems/score/isrlock.h +++ /dev/null @@ -1,439 +0,0 @@ -/** - * @file - * - * @ingroup ScoreISRLocks - * - * @brief ISR Locks - */ - -/* - * Copyright (c) 2013-2015 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_ISR_LOCK_H -#define _RTEMS_SCORE_ISR_LOCK_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ScoreISRLocks ISR Locks - * - * @ingroup ScoreISR - * - * @brief Low-level lock to protect critical sections accessed by threads and - * interrupt service routines. - * - * On single processor configurations the ISR locks degrade to simple ISR - * disable/enable sequences. No additional storage or objects are required. - * - * This synchronization primitive is supported on SMP configurations. Here SMP - * locks are used. - * - * @{ - */ - -/** - * @brief ISR lock control. - * - * @warning Empty structures are implementation-defined in C. GCC gives them a - * size of zero. In C++ empty structures have a non-zero size. - */ -typedef struct { -#if defined( RTEMS_SMP ) - SMP_lock_Control Lock; -#endif -} ISR_lock_Control; - -/** - * @brief Local ISR lock context for acquire and release pairs. - */ -typedef struct { -#if defined( RTEMS_SMP ) - SMP_lock_Context Lock_context; -#else - ISR_Level isr_level; -#endif -#if defined( RTEMS_PROFILING ) - /** - * @brief The last interrupt disable instant in CPU counter ticks. - */ - CPU_Counter_ticks ISR_disable_instant; -#endif -} ISR_lock_Context; - -/** - * @brief Defines an ISR lock member. - * - * Do not add a ';' after this macro. - * - * @param _designator The designator for the interrupt lock. - */ -#if defined( RTEMS_SMP ) - #define ISR_LOCK_MEMBER( _designator ) ISR_lock_Control _designator; -#else - #define ISR_LOCK_MEMBER( _designator ) -#endif - -/** - * @brief Declares an ISR lock variable. - * - * Do not add a ';' after this macro. - * - * @param _qualifier The qualifier for the interrupt lock, e.g. extern. - * @param _designator The designator for the interrupt lock. - */ -#if defined( RTEMS_SMP ) - #define ISR_LOCK_DECLARE( _qualifier, _designator ) \ - _qualifier ISR_lock_Control _designator; -#else - #define ISR_LOCK_DECLARE( _qualifier, _designator ) -#endif - -/** - * @brief Defines an ISR lock variable. - * - * Do not add a ';' after this macro. - * - * @param _qualifier The qualifier for the interrupt lock, e.g. static. - * @param _designator The designator for the interrupt lock. - * @param _name The name for the interrupt lock. It must be a string. The - * name is only used if profiling is enabled. - */ -#if defined( RTEMS_SMP ) - #define ISR_LOCK_DEFINE( _qualifier, _designator, _name ) \ - _qualifier ISR_lock_Control _designator = { SMP_LOCK_INITIALIZER( _name ) }; -#else - #define ISR_LOCK_DEFINE( _qualifier, _designator, _name ) -#endif - -/** - * @brief Defines an ISR lock variable reference. - * - * Do not add a ';' after this macro. - * - * @param _designator The designator for the interrupt lock reference. - * @param _target The target for the interrupt lock reference. - */ -#if defined( RTEMS_SMP ) - #define ISR_LOCK_REFERENCE( _designator, _target ) \ - ISR_lock_Control *_designator = _target; -#else - #define ISR_LOCK_REFERENCE( _designator, _target ) -#endif - -/** - * @brief Initializer for static initialization of ISR locks. - * - * @param _name The name for the interrupt lock. It must be a string. The - * name is only used if profiling is enabled. - */ -#if defined( RTEMS_SMP ) - #define ISR_LOCK_INITIALIZER( _name ) \ - { SMP_LOCK_INITIALIZER( _name ) } -#else - #define ISR_LOCK_INITIALIZER( _name ) \ - { } -#endif - -/** - * @brief Sets the ISR level in the ISR lock context. - * - * @param[in] context The ISR lock context. - * @param[in] level The ISR level. - */ -RTEMS_INLINE_ROUTINE void _ISR_lock_Context_set_level( - ISR_lock_Context *context, - ISR_Level level -) -{ -#if defined( RTEMS_SMP ) - context->Lock_context.isr_level = level; -#else - context->isr_level = level; -#endif -} - -/** - * @brief Initializes an ISR lock. - * - * Concurrent initialization leads to unpredictable results. - * - * @param[in] _lock The ISR lock control. - * @param[in] _name The name for the ISR lock. This name must be a - * string persistent throughout the life time of this lock. The name is only - * used if profiling is enabled. - */ -#if defined( RTEMS_SMP ) - #define _ISR_lock_Initialize( _lock, _name ) \ - _SMP_lock_Initialize( &( _lock )->Lock, _name ) -#else - #define _ISR_lock_Initialize( _lock, _name ) -#endif - -/** - * @brief Destroys an ISR lock. - * - * Concurrent destruction leads to unpredictable results. - * - * @param[in] _lock The ISR lock control. - */ -#if defined( RTEMS_SMP ) - #define _ISR_lock_Destroy( _lock ) \ - _SMP_lock_Destroy( &( _lock )->Lock ) -#else - #define _ISR_lock_Destroy( _lock ) -#endif - -/** - * @brief Acquires an ISR lock. - * - * Interrupts will be disabled. On SMP configurations this function acquires - * an SMP lock. - * - * This function can be used in thread and interrupt context. - * - * @param[in] _lock The ISR lock control. - * @param[in] _context The local ISR lock context for an acquire and release - * pair. - * - * @see _ISR_lock_Release_and_ISR_enable(). - */ -#if defined( RTEMS_SMP ) - #define _ISR_lock_ISR_disable_and_acquire( _lock, _context ) \ - _SMP_lock_ISR_disable_and_acquire( \ - &( _lock )->Lock, \ - &( _context )->Lock_context \ - ) -#else - #define _ISR_lock_ISR_disable_and_acquire( _lock, _context ) \ - _ISR_Local_disable( ( _context )->isr_level ) -#endif - -/** - * @brief Releases an ISR lock. - * - * The interrupt status will be restored. On SMP configurations this function - * releases an SMP lock. - * - * This function can be used in thread and interrupt context. - * - * @param[in] _lock The ISR lock control. - * @param[in] _context The local ISR lock context for an acquire and release - * pair. - * - * @see _ISR_lock_ISR_disable_and_acquire(). - */ -#if defined( RTEMS_SMP ) - #define _ISR_lock_Release_and_ISR_enable( _lock, _context ) \ - _SMP_lock_Release_and_ISR_enable( \ - &( _lock )->Lock, \ - &( _context )->Lock_context \ - ) -#else - #define _ISR_lock_Release_and_ISR_enable( _lock, _context ) \ - _ISR_Local_enable( ( _context )->isr_level ) -#endif - -/** - * @brief Acquires an ISR lock inside an ISR disabled section. - * - * The interrupt status will remain unchanged. On SMP configurations this - * function acquires an SMP lock. - * - * In case the executing context can be interrupted by higher priority - * interrupts and these interrupts enter the critical section protected by this - * lock, then the result is unpredictable. - * - * @param[in] _lock The ISR lock control. - * @param[in] _context The local ISR lock context for an acquire and release - * pair. - * - * @see _ISR_lock_Release(). - */ -#if defined( RTEMS_SMP ) - #define _ISR_lock_Acquire( _lock, _context ) \ - _SMP_lock_Acquire( \ - &( _lock )->Lock, \ - &( _context )->Lock_context \ - ) -#else - #define _ISR_lock_Acquire( _lock, _context ) \ - (void) _context; -#endif - -/** - * @brief Releases an ISR lock inside an ISR disabled section. - * - * The interrupt status will remain unchanged. On SMP configurations this - * function releases an SMP lock. - * - * @param[in] _lock The ISR lock control. - * @param[in] _context The local ISR lock context for an acquire and release - * pair. - * - * @see _ISR_lock_Acquire(). - */ -#if defined( RTEMS_SMP ) - #define _ISR_lock_Release( _lock, _context ) \ - _SMP_lock_Release( \ - &( _lock )->Lock, \ - &( _context )->Lock_context \ - ) -#else - #define _ISR_lock_Release( _lock, _context ) \ - (void) _context; -#endif - -/** - * @brief Acquires an ISR lock inside an ISR disabled section (inline). - * - * @see _ISR_lock_Acquire(). - */ -#if defined( RTEMS_SMP ) - #define _ISR_lock_Acquire_inline( _lock, _context ) \ - _SMP_lock_Acquire_inline( \ - &( _lock )->Lock, \ - &( _context )->Lock_context \ - ) -#else - #define _ISR_lock_Acquire_inline( _lock, _context ) \ - (void) _context; -#endif - -/** - * @brief Releases an ISR lock inside an ISR disabled section (inline). - * - * @see _ISR_lock_Release(). - */ -#if defined( RTEMS_SMP ) - #define _ISR_lock_Release_inline( _lock, _context ) \ - _SMP_lock_Release_inline( \ - &( _lock )->Lock, \ - &( _context )->Lock_context \ - ) -#else - #define _ISR_lock_Release_inline( _lock, _context ) \ - (void) _context; -#endif - -#if defined( RTEMS_DEBUG ) - /** - * @brief Returns true, if the ISR lock is owned by the current processor, - * otherwise false. - * - * On uni-processor configurations, this function returns true, if interrupts - * are disabled, otherwise false. - * - * @param[in] _lock The ISR lock control. - */ - #if defined( RTEMS_SMP ) - #define _ISR_lock_Is_owner( _lock ) \ - _SMP_lock_Is_owner( &( _lock )->Lock ) - #else - #define _ISR_lock_Is_owner( _lock ) \ - ( _ISR_Get_level() != 0 ) - #endif -#endif - -/** - * @brief Flashes an ISR lock. - * - * On uni-processor configurations this a simple _ISR_Local_flash(). On SMP - * configurations this function releases an SMP lock, restores the interrupt - * status, then disables interrupts and acquires the SMP lock again. - * - * This function can be used in thread and interrupt context. - * - * @param[in] _lock The ISR lock control. - * @param[in] _context The local ISR lock context for an acquire and release - * pair. - * - * @see _ISR_lock_ISR_disable_and_acquire() and - * _ISR_lock_Release_and_ISR_enable(). - */ -#if defined( RTEMS_SMP ) - #define _ISR_lock_Flash( _lock, _context ) \ - _SMP_lock_Release_and_ISR_enable( \ - &( _lock )->Lock, \ - &( _context )->Lock_context \ - ); \ - _SMP_lock_ISR_disable_and_acquire( \ - &( _lock )->Lock, \ - &( _context )->Lock_context \ - ) -#else - #define _ISR_lock_Flash( _lock, _context ) \ - _ISR_Local_flash( ( _context )->isr_level ) -#endif - -#if defined( RTEMS_PROFILING ) - #define _ISR_lock_ISR_disable_profile( _context ) \ - ( _context )->ISR_disable_instant = _CPU_Counter_read(); -#else - #define _ISR_lock_ISR_disable_profile( _context ) -#endif - -/** - * @brief Disables interrupts and saves the previous interrupt state in the ISR - * lock context. - * - * This function can be used in thread and interrupt context. - * - * @param[in] _context The local ISR lock context to store the interrupt state. - * - * @see _ISR_lock_ISR_enable(). - */ -#if defined( RTEMS_SMP ) - #define _ISR_lock_ISR_disable( _context ) \ - do { \ - _ISR_Local_disable( ( _context )->Lock_context.isr_level ); \ - _ISR_lock_ISR_disable_profile( _context ) \ - } while ( 0 ) -#else - #define _ISR_lock_ISR_disable( _context ) \ - do { \ - _ISR_Local_disable( ( _context )->isr_level ); \ - _ISR_lock_ISR_disable_profile( _context ) \ - } while ( 0 ) -#endif - -/** - * @brief Restores the saved interrupt state of the ISR lock context. - * - * This function can be used in thread and interrupt context. - * - * @param[in] _context The local ISR lock context containing the saved - * interrupt state. - * - * @see _ISR_lock_ISR_disable(). - */ -#if defined( RTEMS_SMP ) - #define _ISR_lock_ISR_enable( _context ) \ - _ISR_Local_enable( ( _context )->Lock_context.isr_level ) -#else - #define _ISR_lock_ISR_enable( _context ) \ - _ISR_Local_enable( ( _context )->isr_level ) -#endif - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* _RTEMS_SCORE_ISR_LOCK_H */ diff --git a/cpukit/score/include/rtems/score/mpci.h b/cpukit/score/include/rtems/score/mpci.h deleted file mode 100644 index c20b45c3e1..0000000000 --- a/cpukit/score/include/rtems/score/mpci.h +++ /dev/null @@ -1,135 +0,0 @@ -/** - * @file - * - * @ingroup ScoreMPCI - * - * @brief MPCI Layer API - */ - -/* - * COPYRIGHT (c) 1989-2009. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_MPCI_H -#define _RTEMS_SCORE_MPCI_H - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ScoreMPCI MPCI Handler - * - * @ingroup Score - * - * The MPCI Handler encapsulates functionality which is related to the - * generation, receipt, and processing of remote operations in a - * multiprocessor system. This handler contains the message passing - * support for making remote service calls as well as the server thread - * which processes requests from remote nodes. -*/ -/**@{*/ - -/** - * The following defines the node number used when a broadcast is desired. - */ -#define MPCI_ALL_NODES 0 - -/** - * This type is returned by all user provided MPCI routines. - */ -typedef void MPCI_Entry; - -/** - * This type defines the prototype for the initization entry point - * in an Multiprocessor Communications Interface. - */ -typedef MPCI_Entry ( *MPCI_initialization_entry )( void ); - -/** - * This type defines the prototype for the get packet entry point - * in an Multiprocessor Communications Interface. The single - * parameter will point to the packet allocated. - */ -typedef MPCI_Entry ( *MPCI_get_packet_entry )( - MP_packet_Prefix ** - ); - -/** - * This type defines the prototype for the return packet entry point - * in an Multiprocessor Communications Interface. The single - * parameter will point to a packet previously allocated by the - * get packet MPCI entry. - */ -typedef MPCI_Entry ( *MPCI_return_packet_entry )( - MP_packet_Prefix * - ); - -/** - * This type defines the prototype for send get packet entry point - * in an Multiprocessor Communications Interface. The single - * parameter will point to a packet previously allocated by the - * get packet entry point that has been filled in by the caller. - */ -typedef MPCI_Entry ( *MPCI_send_entry )( - uint32_t, - MP_packet_Prefix * - ); - -/** - * This type defines the prototype for the receive packet entry point - * in an Multiprocessor Communications Interface. The single - * parameter will point to a packet allocated and filled in by the - * receive packet handler. The caller will block until a packet is - * received. - */ -typedef MPCI_Entry ( *MPCI_receive_entry )( - MP_packet_Prefix ** - ); - -/** - * This type defines the Multiprocessor Communications - * Interface (MPCI) Table. This table defines the user-provided - * MPCI which is a required part of a multiprocessor system. - * - * For non-blocking local operations that become remote operations, - * we need a timeout. This is a per-driver timeout: default_timeout - */ -typedef struct { - /** This fields contains the timeout for MPCI operations in ticks. */ - uint32_t default_timeout; - /** This field contains the maximum size of a packet supported by this - * MPCI layer. This size places a limit on the size of a message - * which can be transmitted over this interface. - **/ - size_t maximum_packet_size; - /** This field points to the MPCI initialization entry point. */ - MPCI_initialization_entry initialization; - /** This field points to the MPCI get packet entry point. */ - MPCI_get_packet_entry get_packet; - /** This field points to the MPCI return packet entry point. */ - MPCI_return_packet_entry return_packet; - /** This field points to the MPCI send packet entry point. */ - MPCI_send_entry send_packet; - /** This field points to the MPCI receive packet entry point. */ - MPCI_receive_entry receive_packet; -} MPCI_Control; - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/mpciimpl.h b/cpukit/score/include/rtems/score/mpciimpl.h deleted file mode 100644 index eb03a1d7b3..0000000000 --- a/cpukit/score/include/rtems/score/mpciimpl.h +++ /dev/null @@ -1,326 +0,0 @@ -/** - * @file - * - * @ingroup ScoreMPCI - * - * @brief MPCI Layer Implementation - */ - -/* - * COPYRIGHT (c) 1989-2009. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_MPCIIMPL_H -#define _RTEMS_SCORE_MPCIIMPL_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ScoreMPCI - * - * @{ - */ - -/** - * For packets associated with requests that don't already have a timeout, - * use the one specified by this MPCI driver. The value specified by - * the MPCI driver sets an upper limit on how long a remote request - * should take to complete. - */ -#define MPCI_DEFAULT_TIMEOUT 0xFFFFFFFF - -/** - * The following defines the type for packet processing routines - * invoked by the MPCI Receive server. - */ -typedef void (*MPCI_Packet_processor)( MP_packet_Prefix * ); - -/** - * The following enumerated type defines the list of - * internal MP operations. - */ -typedef enum { - MPCI_PACKETS_SYSTEM_VERIFY = 0 -} MPCI_Internal_Remote_operations; - -/** - * The following data structure defines the packet used to perform - * remote event operations. - */ -typedef struct { - /** This field is the general header for all packets. */ - MP_packet_Prefix Prefix; - /** This value specifies the operation. */ - MPCI_Internal_Remote_operations operation; - /** This is the maximum number of nodes in the system. It must agree - * on all nodes. - */ - uint32_t maximum_nodes; - /** This field is the maximum number of concurrently existent - * globally offered objects. - */ - uint32_t maximum_global_objects; -} MPCI_Internal_packet; - -/** - * The following thread queue is used to maintain a list of tasks - * which currently have outstanding remote requests. - */ -extern Thread_queue_Control _MPCI_Remote_blocked_threads; - -/** - * The following define the internal pointers to the user's - * configuration information. - */ -extern MPCI_Control *_MPCI_table; - -/** - * @brief Pointer to MP thread control block. - * - * The following is used to determine when the multiprocessing receive - * thread is executing so that a proxy can be allocated instead of - * blocking the multiprocessing receive thread. - */ -extern Thread_Control *_MPCI_Receive_server_tcb; - -/** - * The following table contains the process packet routines provided - * by each object that supports MP operations. - */ -extern MPCI_Packet_processor -_MPCI_Packet_processors[ MP_PACKET_CLASSES_LAST + 1 ]; - -/** - * This routine registers the MPCI packet processor for the - * designated object class. - * - * @param[in] the_class is the class indicator for packets which will - * be processed by @a the_packet_processor method. - * @param[in] the_packet_processor is a pointer to a method which is - * invoked when packets with @a the_class are received. - */ -void _MPCI_Register_packet_processor( - MP_packet_Classes the_class, - MPCI_Packet_processor the_packet_processor - -); - -/** - * This function obtains a packet by invoking the user provided - * MPCI get packet callout. - * - * @retval This method returns a pointer to a MPCI packet which can be - * filled in by the caller and used to perform a subsequent - * remote operation. - */ -MP_packet_Prefix *_MPCI_Get_packet ( void ); - -/** - * @brief Deallocate a packet. - * - * This routine deallocates a packet by invoking the user provided - * MPCI return packet callout. - * - * @param[in] the_packet is the MP packet to deallocate. - */ -void _MPCI_Return_packet ( - MP_packet_Prefix *the_packet -); - -/** - * @brief Send a process packet. - * - * This routine sends a process packet by invoking the user provided - * MPCI send callout. - * - * @param[in] destination is the node which should receive this packet. - * @param[in] the_packet is the packet to be sent. - */ -void _MPCI_Send_process_packet ( - uint32_t destination, - MP_packet_Prefix *the_packet -); - -/** - * @brief Send a request packet. - * - * This routine sends a request packet by invoking the user provided - * MPCI send callout. - * - * @param[in] destination is the node which should receive this packet. - * @param[in] the_packet is the packet to be sent. - * @param[in] extra_state is the extra thread state bits which should be - * set in addition to the remote operation pending state. It - * may indicate the caller is blocking on a message queue - * operation. - * - * @retval This method returns the operation status from the remote node. - */ -Status_Control _MPCI_Send_request_packet( - uint32_t destination, - MP_packet_Prefix *the_packet, - States_Control extra_state -); - -/** - * @brief Send a response packet. - * - * This routine sends a response packet by invoking the user provided - * MPCI send callout. - * - * @param[in] destination is the node which should receive this packet. - * @param[in] the_packet is the packet to be sent. - */ -void _MPCI_Send_response_packet ( - uint32_t destination, - MP_packet_Prefix *the_packet -); - -/** - * @brief Receive a packet. - * - * This routine receives a packet by invoking the user provided - * MPCI receive callout. - * - * @retval This method returns the packet received. - */ -MP_packet_Prefix *_MPCI_Receive_packet ( void ); - -/** - * @brief Pass a packet to the thread. - * - * This routine is responsible for passing @a the_packet to the thread - * waiting on the remote operation to complete. The unblocked thread is - * responsible for eventually freeing @a the_packet. - * - * @param[in] the_packet is the response packet to be processed. - * - * @retval This method returns a pointer to the thread which was if unblocked - * or NULL if the waiting thread no longer exists. - */ -Thread_Control *_MPCI_Process_response ( - MP_packet_Prefix *the_packet -); - -/** - * @brief Receive and process all packets. - * - * This is the server thread which receives and processes all MCPI packets. - * - * @param[in] ignored is the thread argument. It is not used. - */ -void _MPCI_Receive_server( - Thread_Entry_numeric_type ignored -); - -/** - * @brief Announce the availability of a packet. - * - * This routine informs RTEMS of the availability of an MPCI packet. - */ -void _MPCI_Announce ( void ); - -/** - * @brief Perform a process on another node. - * - * This routine performs a remote procedure call so that a - * process operation can be performed on another node. - * - * @param[in] operation is the remote operation to perform. - */ -void _MPCI_Internal_packets_Send_process_packet ( - MPCI_Internal_Remote_operations operation -); - -/** - * _MPCI_Internal_packets_Send_request_packet - * - * This routine performs a remote procedure call so that a - * directive operation can be initiated on another node. - * - * This routine is not needed since there are no request - * packets to be sent by this manager. - */ - -/** - * _MPCI_Internal_packets_Send_response_packet - * - * This routine performs a remote procedure call so that a - * directive can be performed on another node. - * - * This routine is not needed since there are no response - * packets to be sent by this manager. - */ - -/** - * @brief Perform requested action from another node. - * - * This routine performs the actions specific to this package for - * the request from another node. - */ -void _MPCI_Internal_packets_Process_packet ( - MP_packet_Prefix *the_packet_prefix -); - -/** - * _MPCI_Internal_packets_Send_object_was_deleted - * - * This routine is invoked indirectly by the thread queue - * when a proxy has been removed from the thread queue and - * the remote node must be informed of this. - * - * This routine is not needed since there are no objects - * deleted by this manager. - */ - -/** - * _MPCI_Internal_packets_Send_extract_proxy - * - * This routine is invoked when a task is deleted and it - * has a proxy which must be removed from a thread queue and - * the remote node must be informed of this. - * - * This routine is not needed since there are no objects - * deleted by this manager. - */ - -/** - * @brief Obtain an internal thread. - * - * This routine is used to obtain an internal threads MP packet. - */ -MPCI_Internal_packet *_MPCI_Internal_packets_Get_packet ( void ); - -/** - * This function returns true if the the_packet_class is valid, - * and false otherwise. - * - * @note Check for lower bounds (MP_PACKET_CLASSES_FIRST ) is unnecessary - * because this enum starts at lower bound of zero. - */ - -RTEMS_INLINE_ROUTINE bool _Mp_packet_Is_valid_packet_class ( - MP_packet_Classes the_packet_class -) -{ - return ( the_packet_class <= MP_PACKET_CLASSES_LAST ); -} - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/mppkt.h b/cpukit/score/include/rtems/score/mppkt.h deleted file mode 100644 index 573abf574b..0000000000 --- a/cpukit/score/include/rtems/score/mppkt.h +++ /dev/null @@ -1,121 +0,0 @@ -/** - * @file rtems/score/mppkt.h - * - * @brief Specification for the Packet Handler - * - * This package is the specification for the Packet Handler. - * This handler defines the basic packet and provides - * mechanisms to utilize packets based on this prefix. - * Packets are the fundamental basis for messages passed between - * nodes in an MP system. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_MPPKT_H -#define _RTEMS_SCORE_MPPKT_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ScoreMPPacket MP Packet Handler - * - * @ingroup Score - * - * This handler encapsulates the primary definition of MPCI packets. This - * handler defines the part of the packet that is common to all remote - * operations. - */ -/**@{*/ - -/** - * The following enumerated type defines the packet classes. - * - * @note In general, each class corresponds to a manager - * which supports global operations. Each manager - * defines the set of supported operations. - */ -typedef enum { - MP_PACKET_MPCI_INTERNAL = 0, - MP_PACKET_TASKS = 1, - MP_PACKET_MESSAGE_QUEUE = 2, - MP_PACKET_SEMAPHORE = 3, - MP_PACKET_PARTITION = 4, - MP_PACKET_REGION = 5, - MP_PACKET_EVENT = 6, - MP_PACKET_SIGNAL = 7 -} MP_packet_Classes; - -/** - * This constant defines the first entry in the MP_packet_Classes enumeration. - */ -#define MP_PACKET_CLASSES_FIRST MP_PACKET_MPCI_INTERNAL - -/** - * This constant defines the last entry in the MP_packet_Classes enumeration. - */ -#define MP_PACKET_CLASSES_LAST MP_PACKET_SIGNAL - -/** - * The following record contains the prefix for every packet - * passed between nodes in an MP system. - * - * @note This structure is padded to ensure that anything following it - * is on a 16 byte boundary. This is the most stringent structure - * alignment rule encountered yet. - */ -typedef struct { - /** This field indicates the API class of the operation being performed. */ - MP_packet_Classes the_class; - /** This field is the id of the object to be acted upon. */ - Objects_Id id; - /** This field is the ID of the originating thread. */ - Objects_Id source_tid; - /** This field is the priority of the originating thread. */ - uint32_t source_priority; - /** This field is where the status of the operation will be returned. */ - uint32_t return_code; - /** This field is the length of the data following the prefix. */ - uint32_t length; - /** This field is the length of the data which required network conversion. */ - uint32_t to_convert; - /** This field is the requested timeout for this operation. */ - Watchdog_Interval timeout; -} MP_packet_Prefix; - -/** - * An MPCI must support packets of at least this size. - */ -#define MP_PACKET_MINIMUM_PACKET_SIZE 64 - -/** - * The following constant defines the number of uint32_t's - * in a packet which must be converted to native format in a - * heterogeneous system. In packets longer than - * MP_PACKET_MINIMUN_HETERO_CONVERSION uint32_t's, some of the "extra" data - * may a user message buffer which is not automatically endian swapped. - */ -#define MP_PACKET_MINIMUN_HETERO_CONVERSION \ - ( sizeof( MP_packet_Prefix ) / sizeof( uint32_t ) ) - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/mrsp.h b/cpukit/score/include/rtems/score/mrsp.h deleted file mode 100644 index 85cbff784f..0000000000 --- a/cpukit/score/include/rtems/score/mrsp.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2014, 2016 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_MRSP_H -#define _RTEMS_SCORE_MRSP_H - -#include - -#if defined(RTEMS_SMP) - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup ScoreMRSP Multiprocessor Resource Sharing Protocol Handler - * - * @ingroup Score - * - * @brief Multiprocessor Resource Sharing Protocol (MrsP). - * - * The Multiprocessor Resource Sharing Protocol (MrsP) is defined in A. Burns - * and A.J. Wellings, A Schedulability Compatible Multiprocessor Resource - * Sharing Protocol - MrsP, Proceedings of the 25th Euromicro Conference on - * Real-Time Systems (ECRTS 2013), July 2013. It is a generalization of the - * Priority Ceiling Protocol to SMP systems. Each MrsP semaphore uses a - * ceiling priority per scheduler instance. A task obtaining or owning a MrsP - * semaphore will execute with the ceiling priority for its scheduler instance - * as specified by the MrsP semaphore object. Tasks waiting to get ownership - * of a MrsP semaphore will not relinquish the processor voluntarily. In case - * the owner of a MrsP semaphore gets preempted it can ask all tasks waiting - * for this semaphore to help out and temporarily borrow the right to execute - * on one of their assigned processors. - * - * @{ - */ - -/** - * @brief MrsP control block. - */ -typedef struct { - /** - * @brief The thread queue to manage ownership and waiting threads. - */ - Thread_queue_Control Wait_queue; - - /** - * @brief The ceiling priority used by the owner thread. - */ - Priority_Node Ceiling_priority; - - /** - * @brief One ceiling priority per scheduler instance. - */ - Priority_Control *ceiling_priorities; -} MRSP_Control; - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* RTEMS_SMP */ - -#endif /* _RTEMS_SCORE_MRSP_H */ diff --git a/cpukit/score/include/rtems/score/mrspimpl.h b/cpukit/score/include/rtems/score/mrspimpl.h deleted file mode 100644 index b9c7441401..0000000000 --- a/cpukit/score/include/rtems/score/mrspimpl.h +++ /dev/null @@ -1,384 +0,0 @@ -/* - * Copyright (c) 2014, 2016 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_MRSPIMPL_H -#define _RTEMS_SCORE_MRSPIMPL_H - -#include - -#if defined(RTEMS_SMP) - -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @addtogroup ScoreMRSP - * - * @{ - */ - -#define MRSP_TQ_OPERATIONS &_Thread_queue_Operations_priority_inherit - -RTEMS_INLINE_ROUTINE void _MRSP_Acquire_critical( - MRSP_Control *mrsp, - Thread_queue_Context *queue_context -) -{ - _Thread_queue_Acquire_critical( &mrsp->Wait_queue, queue_context ); -} - -RTEMS_INLINE_ROUTINE void _MRSP_Release( - MRSP_Control *mrsp, - Thread_queue_Context *queue_context -) -{ - _Thread_queue_Release( &mrsp->Wait_queue, queue_context ); -} - -RTEMS_INLINE_ROUTINE Thread_Control *_MRSP_Get_owner( - const MRSP_Control *mrsp -) -{ - return mrsp->Wait_queue.Queue.owner; -} - -RTEMS_INLINE_ROUTINE void _MRSP_Set_owner( - MRSP_Control *mrsp, - Thread_Control *owner -) -{ - mrsp->Wait_queue.Queue.owner = owner; -} - -RTEMS_INLINE_ROUTINE Priority_Control _MRSP_Get_priority( - const MRSP_Control *mrsp, - const Scheduler_Control *scheduler -) -{ - uint32_t scheduler_index; - - scheduler_index = _Scheduler_Get_index( scheduler ); - return mrsp->ceiling_priorities[ scheduler_index ]; -} - -RTEMS_INLINE_ROUTINE void _MRSP_Set_priority( - MRSP_Control *mrsp, - const Scheduler_Control *scheduler, - Priority_Control new_priority -) -{ - uint32_t scheduler_index; - - scheduler_index = _Scheduler_Get_index( scheduler ); - mrsp->ceiling_priorities[ scheduler_index ] = new_priority; -} - -RTEMS_INLINE_ROUTINE Status_Control _MRSP_Raise_priority( - MRSP_Control *mrsp, - Thread_Control *thread, - Priority_Node *priority_node, - Thread_queue_Context *queue_context -) -{ - Status_Control status; - ISR_lock_Context lock_context; - const Scheduler_Control *scheduler; - Priority_Control ceiling_priority; - Scheduler_Node *scheduler_node; - - _Thread_queue_Context_clear_priority_updates( queue_context ); - _Thread_Wait_acquire_default_critical( thread, &lock_context ); - - scheduler = _Thread_Scheduler_get_home( thread ); - scheduler_node = _Thread_Scheduler_get_home_node( thread ); - ceiling_priority = _MRSP_Get_priority( mrsp, scheduler ); - - if ( - ceiling_priority - <= _Priority_Get_priority( &scheduler_node->Wait.Priority ) - ) { - _Priority_Node_initialize( priority_node, ceiling_priority ); - _Thread_Priority_add( thread, priority_node, queue_context ); - status = STATUS_SUCCESSFUL; - } else { - status = STATUS_MUTEX_CEILING_VIOLATED; - } - - _Thread_Wait_release_default_critical( thread, &lock_context ); - return status; -} - -RTEMS_INLINE_ROUTINE void _MRSP_Remove_priority( - Thread_Control *thread, - Priority_Node *priority_node, - Thread_queue_Context *queue_context -) -{ - ISR_lock_Context lock_context; - - _Thread_queue_Context_clear_priority_updates( queue_context ); - _Thread_Wait_acquire_default_critical( thread, &lock_context ); - _Thread_Priority_remove( thread, priority_node, queue_context ); - _Thread_Wait_release_default_critical( thread, &lock_context ); -} - -RTEMS_INLINE_ROUTINE void _MRSP_Replace_priority( - MRSP_Control *mrsp, - Thread_Control *thread, - Priority_Node *ceiling_priority -) -{ - ISR_lock_Context lock_context; - - _Thread_Wait_acquire_default( thread, &lock_context ); - _Thread_Priority_replace( - thread, - ceiling_priority, - &mrsp->Ceiling_priority - ); - _Thread_Wait_release_default( thread, &lock_context ); -} - -RTEMS_INLINE_ROUTINE Status_Control _MRSP_Claim_ownership( - MRSP_Control *mrsp, - Thread_Control *executing, - Thread_queue_Context *queue_context -) -{ - Status_Control status; - Per_CPU_Control *cpu_self; - - status = _MRSP_Raise_priority( - mrsp, - executing, - &mrsp->Ceiling_priority, - queue_context - ); - - if ( status != STATUS_SUCCESSFUL ) { - _MRSP_Release( mrsp, queue_context ); - return status; - } - - _MRSP_Set_owner( mrsp, executing ); - cpu_self = _Thread_queue_Dispatch_disable( queue_context ); - _MRSP_Release( mrsp, queue_context ); - _Thread_Priority_and_sticky_update( executing, 1 ); - _Thread_Dispatch_enable( cpu_self ); - return STATUS_SUCCESSFUL; -} - -RTEMS_INLINE_ROUTINE Status_Control _MRSP_Initialize( - MRSP_Control *mrsp, - const Scheduler_Control *scheduler, - Priority_Control ceiling_priority, - Thread_Control *executing, - bool initially_locked -) -{ - uint32_t scheduler_count = _Scheduler_Count; - uint32_t i; - - if ( initially_locked ) { - return STATUS_INVALID_NUMBER; - } - - mrsp->ceiling_priorities = _Workspace_Allocate( - sizeof( *mrsp->ceiling_priorities ) * scheduler_count - ); - if ( mrsp->ceiling_priorities == NULL ) { - return STATUS_NO_MEMORY; - } - - for ( i = 0 ; i < scheduler_count ; ++i ) { - const Scheduler_Control *scheduler_of_index; - - scheduler_of_index = &_Scheduler_Table[ i ]; - - if ( scheduler != scheduler_of_index ) { - mrsp->ceiling_priorities[ i ] = - _Scheduler_Map_priority( scheduler_of_index, 0 ); - } else { - mrsp->ceiling_priorities[ i ] = ceiling_priority; - } - } - - _Thread_queue_Object_initialize( &mrsp->Wait_queue ); - return STATUS_SUCCESSFUL; -} - -RTEMS_INLINE_ROUTINE Status_Control _MRSP_Wait_for_ownership( - MRSP_Control *mrsp, - Thread_Control *executing, - Thread_queue_Context *queue_context -) -{ - Status_Control status; - Priority_Node ceiling_priority; - - status = _MRSP_Raise_priority( - mrsp, - executing, - &ceiling_priority, - queue_context - ); - - if ( status != STATUS_SUCCESSFUL ) { - _MRSP_Release( mrsp, queue_context ); - return status; - } - - _Thread_queue_Context_set_deadlock_callout( - queue_context, - _Thread_queue_Deadlock_status - ); - status = _Thread_queue_Enqueue_sticky( - &mrsp->Wait_queue.Queue, - MRSP_TQ_OPERATIONS, - executing, - queue_context - ); - - if ( status == STATUS_SUCCESSFUL ) { - _MRSP_Replace_priority( mrsp, executing, &ceiling_priority ); - } else { - Thread_queue_Context queue_context; - Per_CPU_Control *cpu_self; - int sticky_level_change; - - if ( status != STATUS_DEADLOCK ) { - sticky_level_change = -1; - } else { - sticky_level_change = 0; - } - - _ISR_lock_ISR_disable( &queue_context.Lock_context.Lock_context ); - _MRSP_Remove_priority( executing, &ceiling_priority, &queue_context ); - cpu_self = _Thread_Dispatch_disable_critical( - &queue_context.Lock_context.Lock_context - ); - _ISR_lock_ISR_enable( &queue_context.Lock_context.Lock_context ); - _Thread_Priority_and_sticky_update( executing, sticky_level_change ); - _Thread_Dispatch_enable( cpu_self ); - } - - return status; -} - -RTEMS_INLINE_ROUTINE Status_Control _MRSP_Seize( - MRSP_Control *mrsp, - Thread_Control *executing, - bool wait, - Thread_queue_Context *queue_context -) -{ - Status_Control status; - Thread_Control *owner; - - _MRSP_Acquire_critical( mrsp, queue_context ); - - owner = _MRSP_Get_owner( mrsp ); - - if ( owner == NULL ) { - status = _MRSP_Claim_ownership( mrsp, executing, queue_context ); - } else if ( owner == executing ) { - _MRSP_Release( mrsp, queue_context ); - status = STATUS_UNAVAILABLE; - } else if ( wait ) { - status = _MRSP_Wait_for_ownership( mrsp, executing, queue_context ); - } else { - _MRSP_Release( mrsp, queue_context ); - status = STATUS_UNAVAILABLE; - } - - return status; -} - -RTEMS_INLINE_ROUTINE Status_Control _MRSP_Surrender( - MRSP_Control *mrsp, - Thread_Control *executing, - Thread_queue_Context *queue_context -) -{ - Thread_queue_Heads *heads; - - if ( _MRSP_Get_owner( mrsp ) != executing ) { - _ISR_lock_ISR_enable( &queue_context->Lock_context.Lock_context ); - return STATUS_NOT_OWNER; - } - - _MRSP_Acquire_critical( mrsp, queue_context ); - - _MRSP_Set_owner( mrsp, NULL ); - _MRSP_Remove_priority( executing, &mrsp->Ceiling_priority, queue_context ); - - heads = mrsp->Wait_queue.Queue.heads; - - if ( heads == NULL ) { - Per_CPU_Control *cpu_self; - - cpu_self = _Thread_Dispatch_disable_critical( - &queue_context->Lock_context.Lock_context - ); - _MRSP_Release( mrsp, queue_context ); - _Thread_Priority_and_sticky_update( executing, -1 ); - _Thread_Dispatch_enable( cpu_self ); - return STATUS_SUCCESSFUL; - } - - _Thread_queue_Surrender_sticky( - &mrsp->Wait_queue.Queue, - heads, - executing, - queue_context, - MRSP_TQ_OPERATIONS - ); - return STATUS_SUCCESSFUL; -} - -RTEMS_INLINE_ROUTINE Status_Control _MRSP_Can_destroy( MRSP_Control *mrsp ) -{ - if ( _MRSP_Get_owner( mrsp ) != NULL ) { - return STATUS_RESOURCE_IN_USE; - } - - return STATUS_SUCCESSFUL; -} - -RTEMS_INLINE_ROUTINE void _MRSP_Destroy( - MRSP_Control *mrsp, - Thread_queue_Context *queue_context -) -{ - _MRSP_Release( mrsp, queue_context ); - _Thread_queue_Destroy( &mrsp->Wait_queue ); - _Workspace_Free( mrsp->ceiling_priorities ); -} - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* RTEMS_SMP */ - -#endif /* _RTEMS_SCORE_MRSPIMPL_H */ diff --git a/cpukit/score/include/rtems/score/muteximpl.h b/cpukit/score/include/rtems/score/muteximpl.h deleted file mode 100644 index 5fd4f5e8be..0000000000 --- a/cpukit/score/include/rtems/score/muteximpl.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2015, 2017 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_MUTEXIMPL_H -#define _RTEMS_SCORE_MUTEXIMPL_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -typedef struct { - Thread_queue_Syslock_queue Queue; -} Mutex_Control; - -typedef struct { - Mutex_Control Mutex; - unsigned int nest_level; -} Mutex_recursive_Control; - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_SCORE_MUTEXIMPL_H */ diff --git a/cpukit/score/include/rtems/score/object.h b/cpukit/score/include/rtems/score/object.h deleted file mode 100644 index 6789c61fea..0000000000 --- a/cpukit/score/include/rtems/score/object.h +++ /dev/null @@ -1,469 +0,0 @@ -/** - * @file rtems/score/object.h - * - * @brief Constants and Structures Associated with the Object Handler - * - * This include file contains all the constants and structures associated - * with the Object Handler. This Handler provides mechanisms which - * can be used to initialize and manipulate all objects which have ids. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_OBJECT_H -#define _RTEMS_SCORE_OBJECT_H - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup Score SuperCore - * - * @brief Provides services for all APIs. - */ -/**@{*/ - -#if defined(RTEMS_POSIX_API) - /** - * This macro is defined when an API is enabled that requires the - * use of strings for object names. Since the Classic API uses - * 32-bit unsigned integers and not strings, this allows us to - * disable this in the smallest RTEMS configuratinos. - */ - #define RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES -#endif - -/** - * @defgroup ScoreCPU CPU Architecture Support - * - * @ingroup Score - * - * @brief Provides CPU architecture dependent services. - */ -/**@{*/ - -/** - * @defgroup ScoreObject Object Handler - * - * @ingroup Score - */ -/**@{*/ - -/** - * The following type defines the control block used to manage - * object names. - */ -typedef union { - #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES) - /** This is a pointer to a string name. */ - const char *name_p; - #endif - /** This is the actual 32-bit "raw" integer name. */ - uint32_t name_u32; -} Objects_Name; - -#if defined(RTEMS_USE_16_BIT_OBJECT) -/** - * The following type defines the control block used to manage - * object IDs. The format is as follows (0=LSB): - * - * Bits 0 .. 7 = index (up to 254 objects of a type) - * Bits 8 .. 10 = API (up to 7 API classes) - * Bits 11 .. 15 = class (up to 31 object types per API) - */ -typedef uint16_t Objects_Id; - -/** - * This type is used to store the maximum number of allowed objects - * of each type. - */ -typedef uint8_t Objects_Maximum; - -#define OBJECTS_INDEX_START_BIT 0U -#define OBJECTS_API_START_BIT 8U -#define OBJECTS_CLASS_START_BIT 11U - -#define OBJECTS_INDEX_MASK (Objects_Id)0x00ffU -#define OBJECTS_API_MASK (Objects_Id)0x0700U -#define OBJECTS_CLASS_MASK (Objects_Id)0xF800U - -#define OBJECTS_INDEX_VALID_BITS (Objects_Id)0x00ffU -#define OBJECTS_API_VALID_BITS (Objects_Id)0x0007U -/* OBJECTS_NODE_VALID_BITS should not be used with 16 bit Ids */ -#define OBJECTS_CLASS_VALID_BITS (Objects_Id)0x001fU - -#define OBJECTS_UNLIMITED_OBJECTS 0x8000U - -#define OBJECTS_ID_INITIAL_INDEX (0) -#define OBJECTS_ID_FINAL_INDEX (0xff) - -#else -/** - * The following type defines the control block used to manage - * object IDs. The format is as follows (0=LSB): - * - * Bits 0 .. 15 = index (up to 65535 objects of a type) - * Bits 16 .. 23 = node (up to 255 nodes) - * Bits 24 .. 26 = API (up to 7 API classes) - * Bits 27 .. 31 = class (up to 31 object types per API) - */ -typedef uint32_t Objects_Id; - -/** - * This type is used to store the maximum number of allowed objects - * of each type. - */ -typedef uint16_t Objects_Maximum; - -/** - * This is the bit position of the starting bit of the index portion of - * the object Id. - */ -#define OBJECTS_INDEX_START_BIT 0U -/** - * This is the bit position of the starting bit of the node portion of - * the object Id. - */ -#define OBJECTS_NODE_START_BIT 16U - -/** - * This is the bit position of the starting bit of the API portion of - * the object Id. - */ -#define OBJECTS_API_START_BIT 24U - -/** - * This is the bit position of the starting bit of the class portion of - * the object Id. - */ -#define OBJECTS_CLASS_START_BIT 27U - -/** - * This mask is used to extract the index portion of an object Id. - */ -#define OBJECTS_INDEX_MASK (Objects_Id)0x0000ffffU - -/** - * This mask is used to extract the node portion of an object Id. - */ -#define OBJECTS_NODE_MASK (Objects_Id)0x00ff0000U - -/** - * This mask is used to extract the API portion of an object Id. - */ -#define OBJECTS_API_MASK (Objects_Id)0x07000000U - -/** - * This mask is used to extract the class portion of an object Id. - */ -#define OBJECTS_CLASS_MASK (Objects_Id)0xf8000000U - -/** - * This mask represents the bits that is used to ensure no extra bits - * are set after shifting to extract the index portion of an object Id. - */ -#define OBJECTS_INDEX_VALID_BITS (Objects_Id)0x0000ffffU - -/** - * This mask represents the bits that is used to ensure no extra bits - * are set after shifting to extract the node portion of an object Id. - */ -#define OBJECTS_NODE_VALID_BITS (Objects_Id)0x000000ffU - -/** - * This mask represents the bits that is used to ensure no extra bits - * are set after shifting to extract the API portion of an object Id. - */ -#define OBJECTS_API_VALID_BITS (Objects_Id)0x00000007U - -/** - * This mask represents the bits that is used to ensure no extra bits - * are set after shifting to extract the class portion of an object Id. - */ -#define OBJECTS_CLASS_VALID_BITS (Objects_Id)0x0000001fU - -/** - * Mask to enable unlimited objects. This is used in the configuration - * table when specifying the number of configured objects. - */ -#define OBJECTS_UNLIMITED_OBJECTS 0x80000000U - -/** - * This is the lowest value for the index portion of an object Id. - */ -#define OBJECTS_ID_INITIAL_INDEX (0) - -/** - * This is the highest value for the index portion of an object Id. - */ -#define OBJECTS_ID_FINAL_INDEX (0xffffU) -#endif - -/** - * This enumerated type is used in the class field of the object ID. - */ -typedef enum { - OBJECTS_NO_API = 0, - OBJECTS_INTERNAL_API = 1, - OBJECTS_CLASSIC_API = 2, - OBJECTS_POSIX_API = 3, - OBJECTS_FAKE_OBJECTS_API = 7 -} Objects_APIs; - -/** This macro is used to generically specify the last API index. */ -#define OBJECTS_APIS_LAST OBJECTS_POSIX_API - -/** - * The following defines the Object Control Block used to manage - * each object local to this node. - */ -typedef struct { - /** This is the chain node portion of an object. */ - Chain_Node Node; - /** This is the object's ID. */ - Objects_Id id; - /** This is the object's name. */ - Objects_Name name; -} Objects_Control; - -#if defined( RTEMS_MULTIPROCESSING ) -/** - * @brief This defines the Global Object Control Block used to manage objects - * resident on other nodes. - */ -typedef struct { - /** - * @brief Nodes to manage active and inactive global objects. - */ - union { - /** - * @brief Inactive global objects reside on a chain. - */ - Chain_Node Inactive; - - struct { - /** - * @brief Node to lookup an active global object by identifier. - */ - RBTree_Node Id_lookup; - - /** - * @brief Node to lookup an active global object by name. - */ - RBTree_Node Name_lookup; - } Active; - } Nodes; - - /** - * @brief The global object identifier. - */ - Objects_Id id; - - /** - * @brief The global object name. - * - * Using an unsigned thirty two bit value is broken but works. If any API is - * MP with variable length names .. BOOM!!!! - */ - uint32_t name; -} Objects_MP_Control; -#endif - -/** - * No object can have this ID. - */ -#define OBJECTS_ID_NONE 0 - -/** - * The following defines the constant which may be used - * to manipulate the calling task. - */ -#define OBJECTS_ID_OF_SELF ((Objects_Id) 0) - -/** - * The following constant is used to specify that a name to ID search - * should search through all nodes. - */ -#define OBJECTS_SEARCH_ALL_NODES 0 - -/** - * The following constant is used to specify that a name to ID search - * should search through all nodes except the current node. - */ -#define OBJECTS_SEARCH_OTHER_NODES 0x7FFFFFFE - -/** - * The following constant is used to specify that a name to ID search - * should search only on this node. - */ -#define OBJECTS_SEARCH_LOCAL_NODE 0x7FFFFFFF - -/** - * The following constant is used to specify that a name to ID search - * is being asked for the ID of the currently executing task. - */ -#define OBJECTS_WHO_AM_I 0 - -/** - * This macros calculates the lowest ID for the specified api, class, - * and node. - */ -#define OBJECTS_ID_INITIAL(_api, _class, _node) \ - _Objects_Build_id( (_api), (_class), (_node), OBJECTS_ID_INITIAL_INDEX ) - -/** - * This macro specifies the highest object ID value - */ -#define OBJECTS_ID_FINAL ((Objects_Id)~0) - -/** - * This macro is used to build a thirty-two bit style name from - * four characters. The most significant byte will be the - * character @a _C1. - * - * @param[in] _C1 is the first character of the name - * @param[in] _C2 is the second character of the name - * @param[in] _C3 is the third character of the name - * @param[in] _C4 is the fourth character of the name - */ -#define _Objects_Build_name( _C1, _C2, _C3, _C4 ) \ - ( (uint32_t)(_C1) << 24 | \ - (uint32_t)(_C2) << 16 | \ - (uint32_t)(_C3) << 8 | \ - (uint32_t)(_C4) ) - -/** - * This function returns the API portion of the ID. - * - * @param[in] id is the object Id to be processed. - * - * @return This method returns an object Id constructed from the arguments. - */ -RTEMS_INLINE_ROUTINE Objects_APIs _Objects_Get_API( - Objects_Id id -) -{ - return (Objects_APIs) ((id >> OBJECTS_API_START_BIT) & OBJECTS_API_VALID_BITS); -} - -/** - * This function returns the class portion of the ID. - * - * @param[in] id is the object Id to be processed - */ -RTEMS_INLINE_ROUTINE uint32_t _Objects_Get_class( - Objects_Id id -) -{ - return (uint32_t) - ((id >> OBJECTS_CLASS_START_BIT) & OBJECTS_CLASS_VALID_BITS); -} - -/** - * This function returns the node portion of the ID. - * - * @param[in] id is the object Id to be processed - * - * @return This method returns the node portion of an object ID. - */ -RTEMS_INLINE_ROUTINE uint32_t _Objects_Get_node( - Objects_Id id -) -{ - /* - * If using 16-bit Ids, then there is no node field and it MUST - * be a single processor system. - */ - #if defined(RTEMS_USE_16_BIT_OBJECT) - return 1; - #else - return (id >> OBJECTS_NODE_START_BIT) & OBJECTS_NODE_VALID_BITS; - #endif -} - -/** - * This function returns the index portion of the ID. - * - * @param[in] id is the Id to be processed - * - * @return This method returns the class portion of the specified object ID. - */ -RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Get_index( - Objects_Id id -) -{ - return - (Objects_Maximum)((id >> OBJECTS_INDEX_START_BIT) & - OBJECTS_INDEX_VALID_BITS); -} - -/** - * This function builds an object's id from the processor node and index - * values specified. - * - * @param[in] the_api indicates the API associated with this Id. - * @param[in] the_class indicates the class of object. - * It is specific to @a the_api. - * @param[in] node is the node where this object resides. - * @param[in] index is the instance number of this object. - * - * @return This method returns an object Id constructed from the arguments. - */ -RTEMS_INLINE_ROUTINE Objects_Id _Objects_Build_id( - Objects_APIs the_api, - uint16_t the_class, - uint8_t node, - uint16_t index -) -{ - return (( (Objects_Id) the_api ) << OBJECTS_API_START_BIT) | - (( (Objects_Id) the_class ) << OBJECTS_CLASS_START_BIT) | - #if !defined(RTEMS_USE_16_BIT_OBJECT) - (( (Objects_Id) node ) << OBJECTS_NODE_START_BIT) | - #endif - (( (Objects_Id) index ) << OBJECTS_INDEX_START_BIT); -} - -/** - * Returns if the object maximum specifies unlimited objects. - * - * @param[in] maximum The object maximum specification. - * - * @retval true Unlimited objects are available. - * @retval false The object count is fixed. - */ -RTEMS_INLINE_ROUTINE bool _Objects_Is_unlimited( uint32_t maximum ) -{ - return (maximum & OBJECTS_UNLIMITED_OBJECTS) != 0; -} - -/* - * We cannot use an inline function for this since it may be evaluated at - * compile time. - */ -#define _Objects_Maximum_per_allocation( maximum ) \ - ((Objects_Maximum) ((maximum) & ~OBJECTS_UNLIMITED_OBJECTS)) - -/**@}*/ -/**@}*/ -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/objectimpl.h b/cpukit/score/include/rtems/score/objectimpl.h deleted file mode 100644 index cc5820785c..0000000000 --- a/cpukit/score/include/rtems/score/objectimpl.h +++ /dev/null @@ -1,1002 +0,0 @@ -/** - * @file - * - * @brief Inlined Routines in the Object Handler - * - * This include file contains the static inline implementation of all - * of the inlined routines in the Object Handler. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_OBJECTIMPL_H -#define _RTEMS_SCORE_OBJECTIMPL_H - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ScoreObject - * - * @{ - */ - -/** - * Functions which compare names are prototyped like this. - */ -typedef bool (*Objects_Name_comparators)( - void * /* name_1 */, - void * /* name_2 */, - uint16_t /* length */ -); - -/** - * This enumerated type is used in the class field of the object ID - * for RTEMS internal object classes. - */ -typedef enum { - OBJECTS_INTERNAL_NO_CLASS = 0, - OBJECTS_INTERNAL_THREADS = 1 -} Objects_Internal_API; - -/** This macro is used to generically specify the last API index. */ -#define OBJECTS_INTERNAL_CLASSES_LAST OBJECTS_INTERNAL_THREADS - -/** - * This enumerated type is used in the class field of the object ID - * for the RTEMS Classic API. - */ -typedef enum { - OBJECTS_CLASSIC_NO_CLASS = 0, - OBJECTS_RTEMS_TASKS = 1, - OBJECTS_RTEMS_TIMERS = 2, - OBJECTS_RTEMS_SEMAPHORES = 3, - OBJECTS_RTEMS_MESSAGE_QUEUES = 4, - OBJECTS_RTEMS_PARTITIONS = 5, - OBJECTS_RTEMS_REGIONS = 6, - OBJECTS_RTEMS_PORTS = 7, - OBJECTS_RTEMS_PERIODS = 8, - OBJECTS_RTEMS_EXTENSIONS = 9, - OBJECTS_RTEMS_BARRIERS = 10 -} Objects_Classic_API; - -/** This macro is used to generically specify the last API index. */ -#define OBJECTS_RTEMS_CLASSES_LAST OBJECTS_RTEMS_BARRIERS - -/** - * This enumerated type is used in the class field of the object ID - * for the POSIX API. - */ -typedef enum { - OBJECTS_POSIX_NO_CLASS = 0, - OBJECTS_POSIX_THREADS = 1, - OBJECTS_POSIX_KEYS = 2, - OBJECTS_POSIX_INTERRUPTS = 3, - OBJECTS_POSIX_MESSAGE_QUEUES = 5, - OBJECTS_POSIX_SEMAPHORES = 7, - OBJECTS_POSIX_TIMERS = 9, - OBJECTS_POSIX_SHMS = 12 -} Objects_POSIX_API; - -/** This macro is used to generically specify the last API index. */ -#define OBJECTS_POSIX_CLASSES_LAST OBJECTS_POSIX_SHMS - -/* - * For fake objects, which have an object identifier, but no objects - * information block. - */ -typedef enum { - OBJECTS_FAKE_OBJECTS_NO_CLASS = 0, - OBJECTS_FAKE_OBJECTS_SCHEDULERS = 1 -} Objects_Fake_objects_API; - -#if defined(RTEMS_MULTIPROCESSING) -/** - * The following type defines the callout used when a local task - * is extracted from a remote thread queue (i.e. it's proxy must - * extracted from the remote queue). - */ -typedef void ( *Objects_Thread_queue_Extract_callout )( - Thread_Control *, - Objects_Id -); -#endif - -/** - * The following defines the structure for the information used to - * manage each class of objects. - */ -typedef struct { - /** This field indicates the API of this object class. */ - Objects_APIs the_api; - /** This is the class of this object set. */ - uint16_t the_class; - /** This is the minimum valid id of this object class. */ - Objects_Id minimum_id; - /** This is the maximum valid id of this object class. */ - Objects_Id maximum_id; - /** This is the maximum number of objects in this class. */ - Objects_Maximum maximum; - /** This is the true if unlimited objects in this class. */ - bool auto_extend; - /** This is the number of objects in a block. */ - Objects_Maximum allocation_size; - /** This is the size in bytes of each object instance. */ - size_t size; - /** This points to the table of local objects. */ - Objects_Control **local_table; - /** This is the chain of inactive control blocks. */ - Chain_Control Inactive; - /** This is the number of objects on the Inactive list. */ - Objects_Maximum inactive; - /** This is the number of inactive objects per block. */ - uint32_t *inactive_per_block; - /** This is a table to the chain of inactive object memory blocks. */ - void **object_blocks; - #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES) - /** This is true if names are strings. */ - bool is_string; - #endif - /** This is the maximum length of names. */ - uint16_t name_length; - #if defined(RTEMS_MULTIPROCESSING) - /** This is this object class' method called when extracting a thread. */ - Objects_Thread_queue_Extract_callout extract; - - /** - * @brief The global objects of this object information sorted by object - * identifier. - */ - RBTree_Control Global_by_id; - - /** - * @brief The global objects of this object information sorted by object - * name. - * - * Objects with the same name are sorted according to their identifier. - */ - RBTree_Control Global_by_name; - #endif -} Objects_Information; - -/** - * The following is referenced to the node number of the local node. - */ -#if defined(RTEMS_MULTIPROCESSING) -extern uint16_t _Objects_Local_node; -#else -#define _Objects_Local_node ((uint16_t)1) -#endif - -/** - * The following is referenced to the number of nodes in the system. - */ -#if defined(RTEMS_MULTIPROCESSING) -extern uint16_t _Objects_Maximum_nodes; -#else -#define _Objects_Maximum_nodes 1 -#endif - -/** - * The following is the list of information blocks per API for each object - * class. From the ID, we can go to one of these information blocks, - * and obtain a pointer to the appropriate object control block. - */ -extern Objects_Information ** const -_Objects_Information_table[ OBJECTS_APIS_LAST + 1 ]; - -/** - * This function extends an object class information record. - * - * @param[in] information points to an object class information block. - */ -void _Objects_Extend_information( - Objects_Information *information -); - -/** - * @brief Shrink an object class information record - * - * This function shrink an object class information record. - * The object's name and object space are released. The local_table - * etc block does not shrink. The InActive list needs to be scanned - * to find the objects are remove them. - * - * @param[in] information points to an object class information block. - */ -void _Objects_Shrink_information( - Objects_Information *information -); - -void _Objects_Do_initialize_information( - Objects_Information *information, - Objects_APIs the_api, - uint16_t the_class, - uint32_t maximum, - uint16_t size, - bool is_string, - uint32_t maximum_name_length -#if defined(RTEMS_MULTIPROCESSING) - , - Objects_Thread_queue_Extract_callout extract -#endif -); - -/** - * @brief Initialize object Information - * - * This function initializes an object class information record. - * SUPPORTS_GLOBAL is true if the object class supports global - * objects, and false otherwise. Maximum indicates the number - * of objects required in this class and size indicates the size - * in bytes of each control block for this object class. The - * name length and string designator are also set. In addition, - * the class may be a task, therefore this information is also included. - * - * @param[in] information points to an object class information block. - * @param[in] the_api indicates the API associated with this information block. - * @param[in] the_class indicates the class of object being managed - * by this information block. It is specific to @a the_api. - * @param[in] maximum is the maximum number of instances of this object - * class which may be concurrently active. - * @param[in] size is the size of the data structure for this class. - * @param[in] is_string is true if this object uses string style names. - * @param[in] maximum_name_length is the maximum length of object names. - */ -#if defined(RTEMS_MULTIPROCESSING) - #define _Objects_Initialize_information( \ - information, \ - the_api, \ - the_class, \ - maximum, \ - size, \ - is_string, \ - maximum_name_length, \ - extract \ - ) \ - _Objects_Do_initialize_information( \ - information, \ - the_api, \ - the_class, \ - maximum, \ - size, \ - is_string, \ - maximum_name_length, \ - extract \ - ) -#else - #define _Objects_Initialize_information( \ - information, \ - the_api, \ - the_class, \ - maximum, \ - size, \ - is_string, \ - maximum_name_length, \ - extract \ - ) \ - _Objects_Do_initialize_information( \ - information, \ - the_api, \ - the_class, \ - maximum, \ - size, \ - is_string, \ - maximum_name_length \ - ) -#endif - -/** - * @brief Object API Maximum Class - * - * This function returns the highest numeric value of a valid - * API for the specified @a api. - * - * @param[in] api is the API of interest - * - * @retval A positive integer on success and 0 otherwise. - */ -unsigned int _Objects_API_maximum_class( - uint32_t api -); - -/** - * @brief Allocates an object without locking the allocator mutex. - * - * This function can be called in two contexts - * - the executing thread is the owner of the object allocator mutex, or - * - in case the system state is not up, e.g. during sequential system - * initialization. - * - * @param[in] information The object information block. - * - * @retval NULL No object available. - * @retval object The allocated object. - * - * @see _Objects_Allocate() and _Objects_Free(). - */ -Objects_Control *_Objects_Allocate_unprotected( - Objects_Information *information -); - -/** - * @brief Allocates an object. - * - * This function locks the object allocator mutex via - * _Objects_Allocator_lock(). The caller must later unlock the object - * allocator mutex via _Objects_Allocator_unlock(). The caller must unlock the - * mutex in any case, even if the allocation failed due to resource shortage. - * - * A typical object allocation code looks like this: - * @code - * rtems_status_code some_create( rtems_id *id ) - * { - * rtems_status_code sc; - * Some_Control *some; - * - * // The object allocator mutex protects the executing thread from - * // asynchronous thread restart and deletion. - * some = (Some_Control *) _Objects_Allocate( &_Some_Information ); - * - * if ( some != NULL ) { - * _Some_Initialize( some ); - * sc = RTEMS_SUCCESSFUL; - * } else { - * sc = RTEMS_TOO_MANY; - * } - * - * _Objects_Allocator_unlock(); - * - * return sc; - * } - * @endcode - * - * @param[in] information The object information block. - * - * @retval NULL No object available. - * @retval object The allocated object. - * - * @see _Objects_Free(). - */ -Objects_Control *_Objects_Allocate( Objects_Information *information ); - -/** - * @brief Frees an object. - * - * Appends the object to the chain of inactive objects. - * - * @param[in] information The object information block. - * @param[in] the_object The object to free. - * - * @see _Objects_Allocate(). - * - * A typical object deletion code looks like this: - * @code - * rtems_status_code some_delete( rtems_id id ) - * { - * Some_Control *some; - * - * // The object allocator mutex protects the executing thread from - * // asynchronous thread restart and deletion. - * _Objects_Allocator_lock(); - * - * // Get the object under protection of the object allocator mutex. - * some = (Semaphore_Control *) - * _Objects_Get_no_protection( id, &_Some_Information ); - * - * if ( some == NULL ) { - * _Objects_Allocator_unlock(); - * return RTEMS_INVALID_ID; - * } - * - * // After the object close an object get with this identifier will - * // fail. - * _Objects_Close( &_Some_Information, &some->Object ); - * - * _Some_Delete( some ); - * - * // Thread dispatching is enabled. The object free is only protected - * // by the object allocator mutex. - * _Objects_Free( &_Some_Information, &some->Object ); - * - * _Objects_Allocator_unlock(); - * return RTEMS_SUCCESSFUL; - * } - * @endcode - */ -void _Objects_Free( - Objects_Information *information, - Objects_Control *the_object -); - -/** - * This function implements the common portion of the object - * identification directives. This directive returns the object - * id associated with name. If more than one object of this class - * is named name, then the object to which the id belongs is - * arbitrary. Node indicates the extent of the search for the - * id of the object named name. If the object class supports global - * objects, then the search can be limited to a particular node - * or allowed to encompass all nodes. - */ -typedef enum { - OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL, - OBJECTS_INVALID_NAME, - OBJECTS_INVALID_ADDRESS, - OBJECTS_INVALID_ID, - OBJECTS_INVALID_NODE -} Objects_Name_or_id_lookup_errors; - -/** - * This macro defines the first entry in the - * @ref Objects_Name_or_id_lookup_errors enumerated list. - */ -#define OBJECTS_NAME_ERRORS_FIRST OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL - -/** - * This macro defines the last entry in the - * @ref Objects_Name_or_id_lookup_errors enumerated list. - */ -#define OBJECTS_NAME_ERRORS_LAST OBJECTS_INVALID_NODE - -/** - * @brief Converts an object name to an Id. - * - * This method converts an object name to an Id. It performs a look up - * using the object information block for this object class. - * - * @param[in] information points to an object class information block. - * @param[in] name is the name of the object to find. - * @param[in] node is the set of nodes to search. - * @param[in] id will contain the Id if the search is successful. - * - * @retval This method returns one of the values from the - * @ref Objects_Name_or_id_lookup_errors enumeration to indicate - * successful or failure. On success @a id will contain the Id of - * the requested object. - */ -Objects_Name_or_id_lookup_errors _Objects_Name_to_id_u32( - Objects_Information *information, - uint32_t name, - uint32_t node, - Objects_Id *id -); - -typedef enum { - OBJECTS_GET_BY_NAME_INVALID_NAME, - OBJECTS_GET_BY_NAME_NAME_TOO_LONG, - OBJECTS_GET_BY_NAME_NO_OBJECT -} Objects_Get_by_name_error; - -/** - * @brief Gets an object control block identified by its name. - * - * The object information must use string names. - * - * @param information The object information. Must not be NULL. - * @param name The object name. - * @param name_length_p Optional parameter to return the name length. - * @param error The error indication in case of failure. Must not be NULL. - * - * @retval NULL No object exists for this name or invalid parameters. - * @retval other The first object according to object index associated with - * this name. - */ -Objects_Control *_Objects_Get_by_name( - const Objects_Information *information, - const char *name, - size_t *name_length_p, - Objects_Get_by_name_error *error -); - -/** - * @brief Implements the common portion of the object Id to name directives. - * - * This function implements the common portion of the object Id - * to name directives. This function returns the name - * associated with object id. - * - * @param[in] id is the Id of the object whose name we are locating. - * @param[in] name will contain the name of the object, if found. - * - * @retval This method returns one of the values from the - * @ref Objects_Name_or_id_lookup_errors enumeration to indicate - * successful or failure. On success @a name will contain the name of - * the requested object. - * - * @note This function currently does not support string names. - */ -Objects_Name_or_id_lookup_errors _Objects_Id_to_name ( - Objects_Id id, - Objects_Name *name -); - -/** - * @brief Maps the specified object identifier to the associated local object - * control block. - * - * In this function interrupts are disabled during the object lookup. In case - * an associated object exists, then interrupts remain disabled, otherwise the - * previous interrupt state is restored. - * - * @param id The object identifier. This is the first parameter since usual - * callers get the object identifier as the first parameter themself. - * @param lock_context The interrupt lock context. This is the second - * parameter since usual callers get the interrupt lock context as the second - * parameter themself. - * @param information The object class information block. - * - * @retval NULL No associated object exists. - * @retval other The pointer to the associated object control block. - * Interrupts are now disabled and must be restored using the specified lock - * context via _ISR_lock_ISR_enable() or _ISR_lock_Release_and_ISR_enable(). - */ -Objects_Control *_Objects_Get( - Objects_Id id, - ISR_lock_Context *lock_context, - const Objects_Information *information -); - -/** - * @brief Maps object ids to object control blocks. - * - * This function maps object ids to object control blocks. - * If id corresponds to a local object, then it returns - * the_object control pointer which maps to id and location - * is set to OBJECTS_LOCAL. If the object class supports global - * objects and the object id is global and resides on a remote - * node, then location is set to OBJECTS_REMOTE, and the_object - * is undefined. Otherwise, location is set to OBJECTS_ERROR - * and the_object is undefined. - * - * @param[in] id is the Id of the object whose name we are locating. - * This is the first parameter since usual callers get the object identifier - * as the first parameter themself. - * @param[in] information points to an object class information block. - * - * @retval This method returns one of the values from the - * @ref Objects_Name_or_id_lookup_errors enumeration to indicate - * successful or failure. On success @a id will contain the Id of - * the requested object. - */ -Objects_Control *_Objects_Get_no_protection( - Objects_Id id, - const Objects_Information *information -); - -/** - * Gets the next open object after the specified object identifier. - * - * Locks the object allocator mutex in case a next object exists. - * - * @param[in] id is the Id of the object whose name we are locating. - * This is the first parameter since usual callers get the object identifier - * as the first parameter themself. - * @param[in] information points to an object class information block. - * @param[in] next_id_p is the Id of the next object we will look at. - * - * @retval This method returns the pointer to the object located or - * NULL on error. - */ -Objects_Control *_Objects_Get_next( - Objects_Id id, - const Objects_Information *information, - Objects_Id *next_id_p -); - -/** - * @brief Get object information. - * - * This function return the information structure given - * an the API and Class. This can be done independent of - * the existence of any objects created by the API. - * - * @param[in] the_api indicates the API for the information we want - * @param[in] the_class indicates the Class for the information we want - * - * @retval This method returns a pointer to the Object Information Table - * for the class of objects which corresponds to this object ID. - */ -Objects_Information *_Objects_Get_information( - Objects_APIs the_api, - uint16_t the_class -); - -/** - * @brief Get information of an object from an ID. - * - * This function return the information structure given - * an @a id of an object. - * - * @param[in] id is the object ID to get the information from - * - * @retval This method returns a pointer to the Object Information Table - * for the class of objects which corresponds to this object ID. - */ -Objects_Information *_Objects_Get_information_id( - Objects_Id id -); - -/** - * @brief Gets object name in the form of a C string. - * - * This method objects the name of an object and returns its name - * in the form of a C string. It attempts to be careful about - * overflowing the user's string and about returning unprintable characters. - * - * @param[in] id is the object to obtain the name of - * @param[in] length indicates the length of the caller's buffer - * @param[in] name points a string which will be filled in. - * - * @retval This method returns @a name or NULL on error. @a *name will - * contain the name if successful. - */ -char *_Objects_Get_name_as_string( - Objects_Id id, - size_t length, - char *name -); - -/** - * @brief Converts the specified object name to a text representation. - * - * Non-printable characters according to isprint() are converted to '*'. - * - * @param[in] name The object name. - * @param[in] is_string Indicates if the object name is a string or a four - * character array (32-bit unsigned integer). - * @param[in] buffer The string buffer for the text representation. - * @param[in] buffer_size The buffer size in characters. - * - * @retval The length of the text representation. May be greater than or equal - * to the buffer size if truncation occurred. - */ -size_t _Objects_Name_to_string( - Objects_Name name, - bool is_string, - char *buffer, - size_t buffer_size -); - -/** - * @brief Set objects name. - * - * This method sets the object name to either a copy of a string - * or up to the first four characters of the string based upon - * whether this object class uses strings for names. - * - * @param[in] information points to the object information structure - * @param[in] the_object is the object to operate upon - * @param[in] name is a pointer to the name to use - * - * @retval If successful, true is returned. Otherwise false is returned. - */ -bool _Objects_Set_name( - Objects_Information *information, - Objects_Control *the_object, - const char *name -); - -/** - * @brief Removes object from namespace. - * - * This function removes @a the_object from the namespace. - * - * @param[in] information points to an Object Information Table. - * @param[in] the_object is a pointer to an object. - */ -void _Objects_Namespace_remove( - Objects_Information *information, - Objects_Control *the_object -); - -/** - * @brief Close object. - * - * This function removes the_object control pointer and object name - * in the Local Pointer and Local Name Tables. - * - * @param[in] information points to an Object Information Table - * @param[in] the_object is a pointer to an object - */ -void _Objects_Close( - Objects_Information *information, - Objects_Control *the_object -); - -/** - * @brief Returns the count of active objects. - * - * @param[in] information The object information table. - * - * @retval The count of active objects. - */ -Objects_Maximum _Objects_Active_count( - const Objects_Information *information -); - -RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Extend_size( - const Objects_Information *information -) -{ - return information->auto_extend ? information->allocation_size : 0; -} - -/** - * This function returns true if the api is valid. - * - * @param[in] the_api is the api portion of an object ID. - * - * @return This method returns true if the specified api value is valid - * and false otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Objects_Is_api_valid( - uint32_t the_api -) -{ - if ( !the_api || the_api > OBJECTS_APIS_LAST ) - return false; - return true; -} - -/** - * This function returns true if the node is of the local object, and - * false otherwise. - * - * @param[in] node is the node number and corresponds to the node number - * portion of an object ID. - * - * @return This method returns true if the specified node is the local node - * and false otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Objects_Is_local_node( - uint32_t node -) -{ - return ( node == _Objects_Local_node ); -} - -/** - * This function returns true if the id is of a local object, and - * false otherwise. - * - * @param[in] id is an object ID - * - * @return This method returns true if the specified object Id is local - * and false otherwise. - * - * @note On a single processor configuration, this always returns true. - */ -RTEMS_INLINE_ROUTINE bool _Objects_Is_local_id( -#if defined(RTEMS_MULTIPROCESSING) - Objects_Id id -#else - Objects_Id id RTEMS_UNUSED -#endif -) -{ -#if defined(RTEMS_MULTIPROCESSING) - return _Objects_Is_local_node( _Objects_Get_node(id) ); -#else - return true; -#endif -} - -/** - * This function returns true if left and right are equal, - * and false otherwise. - * - * @param[in] left is the Id on the left hand side of the comparison - * @param[in] right is the Id on the right hand side of the comparison - * - * @return This method returns true if the specified object IDs are equal - * and false otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Objects_Are_ids_equal( - Objects_Id left, - Objects_Id right -) -{ - return ( left == right ); -} - -/** - * This function sets the pointer to the local_table object - * referenced by the index. - * - * @param[in] information points to an Object Information Table - * @param[in] index is the index of the object the caller wants to access - * @param[in] the_object is the local object pointer - * - * @note This routine is ONLY to be called in places where the - * index portion of the Id is known to be good. This is - * OK since it is normally called from object create/init - * or delete/destroy operations. - */ - -RTEMS_INLINE_ROUTINE void _Objects_Set_local_object( - Objects_Information *information, - uint32_t index, - Objects_Control *the_object -) -{ - /* - * This routine is ONLY to be called from places in the code - * where the Id is known to be good. Therefore, this should NOT - * occur in normal situations. - */ - #if defined(RTEMS_DEBUG) - if ( index > information->maximum ) - return; - #endif - - information->local_table[ index ] = the_object; -} - -/** - * This function sets the pointer to the local_table object - * referenced by the index to a NULL so the object Id is invalid - * after this call. - * - * @param[in] information points to an Object Information Table - * @param[in] the_object is the local object pointer - * - * @note This routine is ONLY to be called in places where the - * index portion of the Id is known to be good. This is - * OK since it is normally called from object create/init - * or delete/destroy operations. - */ - -RTEMS_INLINE_ROUTINE void _Objects_Invalidate_Id( - Objects_Information *information, - Objects_Control *the_object -) -{ - _Assert( information != NULL ); - _Assert( the_object != NULL ); - - _Objects_Set_local_object( - information, - _Objects_Get_index( the_object->id ), - NULL - ); -} - -/** - * This function places the_object control pointer and object name - * in the Local Pointer and Local Name Tables, respectively. - * - * @param[in] information points to an Object Information Table - * @param[in] the_object is a pointer to an object - * @param[in] name is the name of the object to make accessible - */ -RTEMS_INLINE_ROUTINE void _Objects_Open( - Objects_Information *information, - Objects_Control *the_object, - Objects_Name name -) -{ - _Assert( information != NULL ); - _Assert( the_object != NULL ); - - the_object->name = name; - - _Objects_Set_local_object( - information, - _Objects_Get_index( the_object->id ), - the_object - ); -} - -/** - * This function places the_object control pointer and object name - * in the Local Pointer and Local Name Tables, respectively. - * - * @param[in] information points to an Object Information Table - * @param[in] the_object is a pointer to an object - * @param[in] name is the name of the object to make accessible - */ -RTEMS_INLINE_ROUTINE void _Objects_Open_u32( - Objects_Information *information, - Objects_Control *the_object, - uint32_t name -) -{ - /* ASSERT: information->is_string == false */ - the_object->name.name_u32 = name; - - _Objects_Set_local_object( - information, - _Objects_Get_index( the_object->id ), - the_object - ); -} - -/** - * This function places the_object control pointer and object name - * in the Local Pointer and Local Name Tables, respectively. - * - * @param[in] information points to an Object Information Table - * @param[in] the_object is a pointer to an object - * @param[in] name is the name of the object to make accessible - */ -RTEMS_INLINE_ROUTINE void _Objects_Open_string( - Objects_Information *information, - Objects_Control *the_object, - const char *name -) -{ - #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES) - /* ASSERT: information->is_string */ - the_object->name.name_p = name; - #endif - - _Objects_Set_local_object( - information, - _Objects_Get_index( the_object->id ), - the_object - ); -} - -/** - * @brief Locks the object allocator mutex. - * - * While holding the allocator mutex the executing thread is protected from - * asynchronous thread restart and deletion. - * - * The usage of the object allocator mutex with the thread life protection - * makes it possible to allocate and free objects without thread dispatching - * disabled. The usage of a unified workspace and unlimited objects may lead - * to heap fragmentation. Thus the execution time of the _Objects_Allocate() - * function may increase during system run-time. - * - * @see _Objects_Allocator_unlock() and _Objects_Allocate(). - */ -RTEMS_INLINE_ROUTINE void _Objects_Allocator_lock( void ) -{ - _RTEMS_Lock_allocator(); -} - -/** - * @brief Unlocks the object allocator mutex. - * - * In case the mutex is fully unlocked, then this function restores the - * previous thread life protection state and thus may not return if the - * executing thread was restarted or deleted in the mean-time. - */ -RTEMS_INLINE_ROUTINE void _Objects_Allocator_unlock( void ) -{ - _RTEMS_Unlock_allocator(); -} - -RTEMS_INLINE_ROUTINE bool _Objects_Allocator_is_owner( void ) -{ - return _RTEMS_Allocator_is_owner(); -} - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#if defined(RTEMS_MULTIPROCESSING) -#include -#endif - - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/objectmp.h b/cpukit/score/include/rtems/score/objectmp.h deleted file mode 100644 index 5c9f4f74e3..0000000000 --- a/cpukit/score/include/rtems/score/objectmp.h +++ /dev/null @@ -1,197 +0,0 @@ -/** - * @file rtems/score/objectmp.h - * - * @brief Data Associated with the Manipulation of Global RTEMS Objects - * - * This include file contains all the constants and structures associated - * with the manipulation of Global RTEMS Objects. - */ - -/* - * COPYRIGHT (c) 1989-2009. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_OBJECTMP_H -#define _RTEMS_SCORE_OBJECTMP_H - -#ifndef _RTEMS_SCORE_OBJECTIMPL_H -# error "Never use directly; include instead." -#endif - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ScoreObjectMP Object Handler Multiprocessing Support - * - * @ingroup Score - * - * This handler encapsulates functionality which is used to manage - * objects which have been declared to be globally visible. This handler - * knows objects from all of the nodes in the system. - */ -/**@{*/ - -/** - * @brief Intializes the inactive global object chain - * based on the maximum number of global objects configured. - * - * This routine intializes the inactive global object chain - * based on the maximum number of global objects configured. - */ -void _Objects_MP_Handler_initialization(void); - -/** - * @brief Intializes the global object node number - * used in the ID field of all objects. - * - * This routine intializes the global object node number - * used in the ID field of all objects. - */ -void _Objects_MP_Handler_early_initialization(void); - -/** - * @brief Place the specified global object in the - * specified information table. - * - * This routine place the specified global object in the - * specified information table. - * - * @param[in] information points to the object information table for this - * object class. - * @param[in] the_global_object points to the object being opened. - * @param[in] the_name is the name of the object being opened. - * @param[in] the_id is the Id of the object being opened. - * - * @todo This method only works for object types with 4 byte object names. - * It does not support variable length object names. - */ -void _Objects_MP_Open ( - Objects_Information *information, - Objects_MP_Control *the_global_object, - uint32_t the_name, - Objects_Id the_id -); - -/** - * @brief Allocates a global object control block - * and places it in the specified information table. - * - * This routine allocates a global object control block - * and places it in the specified information table. If the - * allocation fails, then is_fatal_error determines the - * error processing actions taken. - * - * @param[in] information points to the object information table for this - * object class. - * @param[in] the_name is the name of the object being opened. - * @param[in] the_id is the Id of the object being opened. - * @param[in] is_fatal_error is true if not being able to allocate the - * object is considered a fatal error. - * - * @todo This method only works for object types with 4 byte object names. - * It does not support variable length object names. - */ -bool _Objects_MP_Allocate_and_open ( - Objects_Information *information, - uint32_t the_name, - Objects_Id the_id, - bool is_fatal_error -); - -/** - * @brief Removes a global object from the specified information table. - * - * This routine removes a global object from the specified - * information table and deallocates the global object control block. - */ -void _Objects_MP_Close ( - Objects_Information *information, - Objects_Id the_id -); - -/** - * @brief Look for the object with the_name in the global - * object tables indicated by information. - * - * This routine looks for the object with the_name in the global - * object tables indicated by information. It returns the ID of the - * object with that name if one is found. - * - * @param[in] information points to the object information table for this - * object class. - * @param[in] the_name is the name of the object being searched for. - * @param[in] nodes_to_search indicates the set of nodes to search. - * @param[in] the_id will contain the Id of the object if found. - * - * @retval This method returns one of the - * @ref Objects_Name_or_id_lookup_errors. If successful, @a the_id - * will contain the Id of the object. - */ -Objects_Name_or_id_lookup_errors _Objects_MP_Global_name_search ( - Objects_Information *information, - Objects_Name the_name, - uint32_t nodes_to_search, - Objects_Id *the_id -); - -/** - * @brief Returns true, if the object identifier is in the global object - * identifier cache of the specified object information, otherwise false. - * - * @param id The object identifier. - * @param information The object information. - * - * @retval true A remote objects with this object identifier exits in the - * global object identifier cache of the specified information. - * @retval false Otherwise. - */ -bool _Objects_MP_Is_remote( - Objects_Id id, - const Objects_Information *information -); - -/** - * This is the maximum number of global objects configured. - */ -extern uint32_t _Objects_MP_Maximum_global_objects; - -/** - * This function allocates a Global Object control block. - */ - -Objects_MP_Control *_Objects_MP_Allocate_global_object( void ); - -/** - * This routine deallocates a Global Object control block. - */ - -void _Objects_MP_Free_global_object( Objects_MP_Control *the_object ); - -/** - * This function returns whether the global object is NULL or not. - */ - -RTEMS_INLINE_ROUTINE bool _Objects_MP_Is_null_global_object ( - Objects_MP_Control *the_object -) -{ - return( the_object == NULL ); -} - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/onceimpl.h b/cpukit/score/include/rtems/score/onceimpl.h deleted file mode 100644 index 60f1378506..0000000000 --- a/cpukit/score/include/rtems/score/onceimpl.h +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @file - * - * @ingroup ScoreOnce - * - * @brief Once API - */ - -/* - * Copyright (c) 2014 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_ONCE_H -#define _RTEMS_ONCE_H - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup ScoreOnce Once Functions. - * - * @ingroup Score - * - * @brief The _Once() function for pthread_once() and rtems_gxx_once(). - * - * @{ - */ - -int _Once( unsigned char *once_state, void (*init_routine)(void) ); - -void _Once_Lock( void ); - -void _Once_Unlock( void ); - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_ONCE_H */ diff --git a/cpukit/score/include/rtems/score/percpu.h b/cpukit/score/include/rtems/score/percpu.h deleted file mode 100644 index 00528b5ce3..0000000000 --- a/cpukit/score/include/rtems/score/percpu.h +++ /dev/null @@ -1,851 +0,0 @@ -/** - * @file rtems/score/percpu.h - * - * This include file defines the per CPU information required - * by RTEMS. - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * Copyright (c) 2012, 2016 embedded brains GmbH - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_PERCPU_H -#define _RTEMS_PERCPU_H - -#include - -#if defined( ASM ) - #include -#else - #include - #include - #include - #include - #include - #include - #include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined(RTEMS_SMP) - #if defined(RTEMS_PROFILING) - #define PER_CPU_CONTROL_SIZE_APPROX ( 512 + CPU_INTERRUPT_FRAME_SIZE ) - #elif defined(RTEMS_DEBUG) - #define PER_CPU_CONTROL_SIZE_APPROX ( 256 + CPU_INTERRUPT_FRAME_SIZE ) - #else - #define PER_CPU_CONTROL_SIZE_APPROX ( 128 + CPU_INTERRUPT_FRAME_SIZE ) - #endif - - /* - * This ensures that on SMP configurations the individual per-CPU controls - * are on different cache lines to prevent false sharing. This define can be - * used in assembler code to easily get the per-CPU control for a particular - * processor. - */ - #if PER_CPU_CONTROL_SIZE_APPROX > 1024 - #define PER_CPU_CONTROL_SIZE_LOG2 11 - #elif PER_CPU_CONTROL_SIZE_APPROX > 512 - #define PER_CPU_CONTROL_SIZE_LOG2 10 - #elif PER_CPU_CONTROL_SIZE_APPROX > 256 - #define PER_CPU_CONTROL_SIZE_LOG2 9 - #elif PER_CPU_CONTROL_SIZE_APPROX > 128 - #define PER_CPU_CONTROL_SIZE_LOG2 8 - #else - #define PER_CPU_CONTROL_SIZE_LOG2 7 - #endif - - #define PER_CPU_CONTROL_SIZE ( 1 << PER_CPU_CONTROL_SIZE_LOG2 ) -#endif - -#if !defined( ASM ) - -struct _Thread_Control; - -struct Scheduler_Context; - -/** - * @defgroup PerCPU RTEMS Per CPU Information - * - * @ingroup Score - * - * This defines the per CPU state information required by RTEMS - * and the BSP. In an SMP configuration, there will be multiple - * instances of this data structure -- one per CPU -- and the - * current CPU number will be used as the index. - */ - -/**@{*/ - -#if defined( RTEMS_SMP ) - -/** - * @brief State of a processor. - * - * The processor state controls the life cycle of processors at the lowest - * level. No multi-threading or other high-level concepts matter here. - * - * State changes must be initiated via _Per_CPU_State_change(). This function - * may not return in case someone requested a shutdown. The - * _SMP_Send_message() function will be used to notify other processors about - * state changes if the other processor is in the up state. - * - * Due to the sequential nature of the basic system initialization one - * processor has a special role. It is the processor executing the boot_card() - * function. This processor is called the boot processor. All other - * processors are called secondary. - * - * @dot - * digraph states { - * i [label="PER_CPU_STATE_INITIAL"]; - * rdy [label="PER_CPU_STATE_READY_TO_START_MULTITASKING"]; - * reqsm [label="PER_CPU_STATE_REQUEST_START_MULTITASKING"]; - * u [label="PER_CPU_STATE_UP"]; - * s [label="PER_CPU_STATE_SHUTDOWN"]; - * i -> rdy [label="processor\ncompleted initialization"]; - * rdy -> reqsm [label="boot processor\ncompleted initialization"]; - * reqsm -> u [label="processor\nstarts multitasking"]; - * i -> s; - * rdy -> s; - * reqsm -> s; - * u -> s; - * } - * @enddot - */ -typedef enum { - /** - * @brief The per CPU controls are initialized to zero. - * - * The boot processor executes the sequential boot code in this state. The - * secondary processors should perform their basic initialization now and - * change into the PER_CPU_STATE_READY_TO_START_MULTITASKING state once this - * is complete. - */ - PER_CPU_STATE_INITIAL, - - /** - * @brief Processor is ready to start multitasking. - * - * The secondary processor performed its basic initialization and is ready to - * receive inter-processor interrupts. Interrupt delivery must be disabled - * in this state, but requested inter-processor interrupts must be recorded - * and must be delivered once the secondary processor enables interrupts for - * the first time. The boot processor will wait for all secondary processors - * to change into this state. In case a secondary processor does not reach - * this state the system will not start. The secondary processors wait now - * for a change into the PER_CPU_STATE_REQUEST_START_MULTITASKING state set - * by the boot processor once all secondary processors reached the - * PER_CPU_STATE_READY_TO_START_MULTITASKING state. - */ - PER_CPU_STATE_READY_TO_START_MULTITASKING, - - /** - * @brief Multitasking start of processor is requested. - * - * The boot processor completed system initialization and is about to perform - * a context switch to its heir thread. Secondary processors should now - * issue a context switch to the heir thread. This normally enables - * interrupts on the processor for the first time. - */ - PER_CPU_STATE_REQUEST_START_MULTITASKING, - - /** - * @brief Normal multitasking state. - */ - PER_CPU_STATE_UP, - - /** - * @brief This is the terminal state. - */ - PER_CPU_STATE_SHUTDOWN -} Per_CPU_State; - -#endif /* defined( RTEMS_SMP ) */ - -/** - * @brief Per-CPU statistics. - */ -typedef struct { -#if defined( RTEMS_PROFILING ) - /** - * @brief The thread dispatch disabled begin instant in CPU counter ticks. - * - * This value is used to measure the time of disabled thread dispatching. - */ - CPU_Counter_ticks thread_dispatch_disabled_instant; - - /** - * @brief The maximum time of disabled thread dispatching in CPU counter - * ticks. - */ - CPU_Counter_ticks max_thread_dispatch_disabled_time; - - /** - * @brief The maximum time spent to process a single sequence of nested - * interrupts in CPU counter ticks. - * - * This is the time interval between the change of the interrupt nest level - * from zero to one and the change back from one to zero. - */ - CPU_Counter_ticks max_interrupt_time; - - /** - * @brief The maximum interrupt delay in CPU counter ticks if supported by - * the hardware. - */ - CPU_Counter_ticks max_interrupt_delay; - - /** - * @brief Count of times when the thread dispatch disable level changes from - * zero to one in thread context. - * - * This value may overflow. - */ - uint64_t thread_dispatch_disabled_count; - - /** - * @brief Total time of disabled thread dispatching in CPU counter ticks. - * - * The average time of disabled thread dispatching is the total time of - * disabled thread dispatching divided by the thread dispatch disabled - * count. - * - * This value may overflow. - */ - uint64_t total_thread_dispatch_disabled_time; - - /** - * @brief Count of times when the interrupt nest level changes from zero to - * one. - * - * This value may overflow. - */ - uint64_t interrupt_count; - - /** - * @brief Total time of interrupt processing in CPU counter ticks. - * - * The average time of interrupt processing is the total time of interrupt - * processing divided by the interrupt count. - * - * This value may overflow. - */ - uint64_t total_interrupt_time; -#endif /* defined( RTEMS_PROFILING ) */ -} Per_CPU_Stats; - -/** - * @brief Per-CPU watchdog header index. - */ -typedef enum { - /** - * @brief Index for monotonic clock per-CPU watchdog header. - * - * The reference time point for the monotonic clock is the system start. The - * clock resolution is one system clock tick. It is used for the system - * clock tick based time services and the POSIX services using - * CLOCK_MONOTONIC. - */ - PER_CPU_WATCHDOG_MONOTONIC, - - /** - * @brief Index for realtime clock per-CPU watchdog header. - * - * The reference time point for the realtime clock is the POSIX Epoch. The - * clock resolution is one nanosecond. It is used for the time of day - * services and the POSIX services using CLOCK_REALTIME. - */ - PER_CPU_WATCHDOG_REALTIME, - - /** - * @brief Count of per-CPU watchdog headers. - */ - PER_CPU_WATCHDOG_COUNT -} Per_CPU_Watchdog_index; - -/** - * @brief Per CPU Core Structure - * - * This structure is used to hold per core state information. - */ -typedef struct Per_CPU_Control { - #if CPU_PER_CPU_CONTROL_SIZE > 0 - /** - * @brief CPU port specific control. - */ - CPU_Per_CPU_control cpu_per_cpu; - #endif - - #if (CPU_ALLOCATE_INTERRUPT_STACK == TRUE) || \ - (CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE) - /** - * This contains a pointer to the lower range of the interrupt stack for - * this CPU. This is the address allocated and freed. - */ - void *interrupt_stack_low; - - /** - * This contains a pointer to the interrupt stack pointer for this CPU. - * It will be loaded at the beginning on an ISR. - */ - void *interrupt_stack_high; - #endif - - /** - * This contains the current interrupt nesting level on this - * CPU. - */ - uint32_t isr_nest_level; - - /** - * @brief Indicetes if an ISR thread dispatch is disabled. - * - * This flag is context switched with each thread. It indicates that this - * thread has an interrupt stack frame on its stack. By using this flag, we - * can avoid nesting more interrupt dispatching attempts on a previously - * interrupted thread's stack. - */ - uint32_t isr_dispatch_disable; - - /** - * @brief The thread dispatch critical section nesting counter which is used - * to prevent context switches at inopportune moments. - */ - volatile uint32_t thread_dispatch_disable_level; - - /** - * @brief This is set to true when this processor needs to run the thread - * dispatcher. - * - * It is volatile since interrupts may alter this flag. - * - * This field is not protected by a lock and must be accessed only by this - * processor. Code (e.g. scheduler and post-switch action requests) running - * on another processors must use an inter-processor interrupt to set the - * thread dispatch necessary indicator to true. - * - * @see _Thread_Get_heir_and_make_it_executing(). - */ - volatile bool dispatch_necessary; - - /* - * Ensure that the executing member is at least 4-byte aligned, see - * PER_CPU_OFFSET_EXECUTING. This is necessary on CPU ports with relaxed - * alignment restrictions, e.g. type alignment is less than the type size. - */ - bool reserved_for_executing_alignment[ 3 ]; - - /** - * @brief This is the thread executing on this processor. - * - * This field is not protected by a lock. The only writer is this processor. - * - * On SMP configurations a thread may be registered as executing on more than - * one processor in case a thread migration is in progress. On SMP - * configurations use _Thread_Is_executing_on_a_processor() to figure out if - * a thread context is executing on a processor. - */ - struct _Thread_Control *executing; - - /** - * @brief This is the heir thread for this processor. - * - * This field is not protected by a lock. The only writer after multitasking - * start is the scheduler owning this processor. It is assumed that stores - * to pointers are atomic on all supported SMP architectures. The CPU port - * specific code (inter-processor interrupt handling and - * _CPU_SMP_Send_interrupt()) must guarantee that this processor observes the - * last value written. - * - * A thread can be a heir on at most one processor in the system. - * - * @see _Thread_Get_heir_and_make_it_executing(). - */ - struct _Thread_Control *heir; - -#if defined(RTEMS_SMP) - CPU_Interrupt_frame Interrupt_frame; -#endif - - /** - * @brief The CPU usage timestamp contains the time point of the last heir - * thread change or last CPU usage update of the executing thread of this - * processor. - * - * Protected by the scheduler lock. - * - * @see _Scheduler_Update_heir(), _Thread_Dispatch_update_heir() and - * _Thread_Get_CPU_time_used(). - */ - Timestamp_Control cpu_usage_timestamp; - - /** - * @brief Watchdog state for this processor. - */ - struct { - /** - * @brief Protects all watchdog operations on this processor. - */ - ISR_LOCK_MEMBER( Lock ) - - /** - * @brief Watchdog ticks on this processor used for monotonic clock - * watchdogs. - */ - uint64_t ticks; - - /** - * @brief Header for watchdogs. - * - * @see Per_CPU_Watchdog_index. - */ - Watchdog_Header Header[ PER_CPU_WATCHDOG_COUNT ]; - } Watchdog; - - #if defined( RTEMS_SMP ) - /** - * @brief This lock protects some parts of the low-level thread dispatching. - * - * We must use a ticket lock here since we cannot transport a local context - * through the context switch. - * - * @see _Thread_Dispatch(). - */ - SMP_ticket_lock_Control Lock; - - #if defined( RTEMS_PROFILING ) - /** - * @brief Lock statistics for the per-CPU lock. - */ - SMP_lock_Stats Lock_stats; - - /** - * @brief Lock statistics context for the per-CPU lock. - */ - SMP_lock_Stats_context Lock_stats_context; - #endif - - /** - * @brief Chain of threads in need for help. - * - * This field is protected by the Per_CPU_Control::Lock lock. - */ - Chain_Control Threads_in_need_for_help; - - /** - * @brief Bit field for SMP messages. - * - * This bit field is not protected locks. Atomic operations are used to - * set and get the message bits. - */ - Atomic_Ulong message; - - struct { - /** - * @brief The scheduler control of the scheduler owning this processor. - * - * This pointer is NULL in case this processor is currently not used by a - * scheduler instance. - */ - const struct _Scheduler_Control *control; - - /** - * @brief The scheduler context of the scheduler owning this processor. - * - * This pointer is NULL in case this processor is currently not used by a - * scheduler instance. - */ - const struct Scheduler_Context *context; - - /** - * @brief The idle thread for this processor in case it is online and - * currently not used by a scheduler instance. - */ - struct _Thread_Control *idle_if_online_and_unused; - } Scheduler; - - /** - * @brief Indicates the current state of the CPU. - * - * This field is protected by the _Per_CPU_State_lock lock. - * - * @see _Per_CPU_State_change(). - */ - Per_CPU_State state; - - /** - * @brief Action to be executed by this processor in the - * SYSTEM_STATE_BEFORE_MULTITASKING state on behalf of the boot processor. - * - * @see _SMP_Before_multitasking_action(). - */ - Atomic_Uintptr before_multitasking_action; - - /** - * @brief Indicates if the processor has been successfully started via - * _CPU_SMP_Start_processor(). - */ - bool online; - - /** - * @brief Indicates if the processor is the one that performed the initial - * system initialization. - */ - bool boot; - #endif - - Per_CPU_Stats Stats; -} Per_CPU_Control; - -#if defined( RTEMS_SMP ) -typedef struct { - Per_CPU_Control per_cpu; - char unused_space_for_cache_line_alignment - [ PER_CPU_CONTROL_SIZE - sizeof( Per_CPU_Control ) ]; -} Per_CPU_Control_envelope; -#else -typedef struct { - Per_CPU_Control per_cpu; -} Per_CPU_Control_envelope; -#endif - -/** - * @brief Set of Per CPU Core Information - * - * This is an array of per CPU core information. - */ -extern Per_CPU_Control_envelope _Per_CPU_Information[] CPU_STRUCTURE_ALIGNMENT; - -#if defined( RTEMS_SMP ) -#define _Per_CPU_Acquire( cpu ) \ - _SMP_ticket_lock_Acquire( \ - &( cpu )->Lock, \ - &( cpu )->Lock_stats, \ - &( cpu )->Lock_stats_context \ - ) -#else -#define _Per_CPU_Acquire( cpu ) \ - do { \ - (void) ( cpu ); \ - } while ( 0 ) -#endif - -#if defined( RTEMS_SMP ) -#define _Per_CPU_Release( cpu ) \ - _SMP_ticket_lock_Release( \ - &( cpu )->Lock, \ - &( cpu )->Lock_stats_context \ - ) -#else -#define _Per_CPU_Release( cpu ) \ - do { \ - (void) ( cpu ); \ - } while ( 0 ) -#endif - -#if defined( RTEMS_SMP ) -#define _Per_CPU_ISR_disable_and_acquire( cpu, isr_cookie ) \ - do { \ - _ISR_Local_disable( isr_cookie ); \ - _Per_CPU_Acquire( cpu ); \ - } while ( 0 ) -#else -#define _Per_CPU_ISR_disable_and_acquire( cpu, isr_cookie ) \ - do { \ - _ISR_Local_disable( isr_cookie ); \ - (void) ( cpu ); \ - } while ( 0 ) -#endif - -#if defined( RTEMS_SMP ) -#define _Per_CPU_Release_and_ISR_enable( cpu, isr_cookie ) \ - do { \ - _Per_CPU_Release( cpu ); \ - _ISR_Local_enable( isr_cookie ); \ - } while ( 0 ) -#else -#define _Per_CPU_Release_and_ISR_enable( cpu, isr_cookie ) \ - do { \ - (void) ( cpu ); \ - _ISR_Local_enable( isr_cookie ); \ - } while ( 0 ) -#endif - -#if defined( RTEMS_SMP ) -#define _Per_CPU_Acquire_all( isr_cookie ) \ - do { \ - uint32_t ncpus = _SMP_Get_processor_count(); \ - uint32_t cpu; \ - _ISR_Local_disable( isr_cookie ); \ - for ( cpu = 0 ; cpu < ncpus ; ++cpu ) { \ - _Per_CPU_Acquire( _Per_CPU_Get_by_index( cpu ) ); \ - } \ - } while ( 0 ) -#else -#define _Per_CPU_Acquire_all( isr_cookie ) \ - _ISR_Local_disable( isr_cookie ) -#endif - -#if defined( RTEMS_SMP ) -#define _Per_CPU_Release_all( isr_cookie ) \ - do { \ - uint32_t ncpus = _SMP_Get_processor_count(); \ - uint32_t cpu; \ - for ( cpu = 0 ; cpu < ncpus ; ++cpu ) { \ - _Per_CPU_Release( _Per_CPU_Get_by_index( cpu ) ); \ - } \ - _ISR_Local_enable( isr_cookie ); \ - } while ( 0 ) -#else -#define _Per_CPU_Release_all( isr_cookie ) \ - _ISR_Local_enable( isr_cookie ) -#endif - -/* - * If we get the current processor index in a context which allows thread - * dispatching, then we may already run on another processor right after the - * read instruction. There are very few cases in which this makes sense (here - * we can use _Per_CPU_Get_snapshot()). All other places must use - * _Per_CPU_Get() so that we can add checks for RTEMS_DEBUG. - */ -#if defined( _CPU_Get_current_per_CPU_control ) - #define _Per_CPU_Get_snapshot() _CPU_Get_current_per_CPU_control() -#else - #define _Per_CPU_Get_snapshot() \ - ( &_Per_CPU_Information[ _SMP_Get_current_processor() ].per_cpu ) -#endif - -#if defined( RTEMS_SMP ) -static inline Per_CPU_Control *_Per_CPU_Get( void ) -{ - Per_CPU_Control *cpu_self = _Per_CPU_Get_snapshot(); - - _Assert( - cpu_self->thread_dispatch_disable_level != 0 || _ISR_Get_level() != 0 - ); - - return cpu_self; -} -#else -#define _Per_CPU_Get() _Per_CPU_Get_snapshot() -#endif - -static inline Per_CPU_Control *_Per_CPU_Get_by_index( uint32_t index ) -{ - return &_Per_CPU_Information[ index ].per_cpu; -} - -static inline uint32_t _Per_CPU_Get_index( const Per_CPU_Control *cpu ) -{ - const Per_CPU_Control_envelope *per_cpu_envelope = - ( const Per_CPU_Control_envelope * ) cpu; - - return ( uint32_t ) ( per_cpu_envelope - &_Per_CPU_Information[ 0 ] ); -} - -static inline struct _Thread_Control *_Per_CPU_Get_executing( - const Per_CPU_Control *cpu -) -{ - return cpu->executing; -} - -static inline bool _Per_CPU_Is_processor_online( - const Per_CPU_Control *cpu -) -{ -#if defined( RTEMS_SMP ) - return cpu->online; -#else - (void) cpu; - - return true; -#endif -} - -static inline bool _Per_CPU_Is_boot_processor( - const Per_CPU_Control *cpu -) -{ -#if defined( RTEMS_SMP ) - return cpu->boot; -#else - (void) cpu; - - return true; -#endif -} - -#if defined( RTEMS_SMP ) - -/** - * @brief Allocate and Initialize Per CPU Structures - * - * This method allocates and initialize the per CPU structure. - */ -void _Per_CPU_Initialize(void); - -void _Per_CPU_State_change( - Per_CPU_Control *cpu, - Per_CPU_State new_state -); - -/** - * @brief Waits for a processor to change into a non-initial state. - * - * This function should be called only in _CPU_SMP_Start_processor() if - * required by the CPU port or BSP. - * - * @code - * bool _CPU_SMP_Start_processor(uint32_t cpu_index) - * { - * uint32_t timeout = 123456; - * - * start_the_processor(cpu_index); - * - * return _Per_CPU_State_wait_for_non_initial_state(cpu_index, timeout); - * } - * @endcode - * - * @param[in] cpu_index The processor index. - * @param[in] timeout_in_ns The timeout in nanoseconds. Use a value of zero to - * wait forever if necessary. - * - * @retval true The processor is in a non-initial state. - * @retval false The timeout expired before the processor reached a non-initial - * state. - */ -bool _Per_CPU_State_wait_for_non_initial_state( - uint32_t cpu_index, - uint32_t timeout_in_ns -); - -#endif /* defined( RTEMS_SMP ) */ - -/* - * On a non SMP system, the _SMP_Get_current_processor() is defined to 0. - * Thus when built for non-SMP, there should be no performance penalty. - */ -#define _Thread_Dispatch_disable_level \ - _Per_CPU_Get()->thread_dispatch_disable_level -#define _Thread_Heir \ - _Per_CPU_Get()->heir - -#if defined(_CPU_Get_thread_executing) -#define _Thread_Executing \ - _CPU_Get_thread_executing() -#else -#define _Thread_Executing \ - _Per_CPU_Get_executing( _Per_CPU_Get() ) -#endif - -#define _ISR_Nest_level \ - _Per_CPU_Get()->isr_nest_level -#define _CPU_Interrupt_stack_low \ - _Per_CPU_Get()->interrupt_stack_low -#define _CPU_Interrupt_stack_high \ - _Per_CPU_Get()->interrupt_stack_high -#define _Thread_Dispatch_necessary \ - _Per_CPU_Get()->dispatch_necessary - -/** - * @brief Returns the thread control block of the executing thread. - * - * This function can be called in any thread context. On SMP configurations, - * interrupts are disabled to ensure that the processor index is used - * consistently if no CPU port specific method is available to get the - * executing thread. - * - * @return The thread control block of the executing thread. - */ -RTEMS_INLINE_ROUTINE struct _Thread_Control *_Thread_Get_executing( void ) -{ - struct _Thread_Control *executing; - - #if defined(RTEMS_SMP) && !defined(_CPU_Get_thread_executing) - ISR_Level level; - - _ISR_Local_disable( level ); - #endif - - executing = _Thread_Executing; - - #if defined(RTEMS_SMP) && !defined(_CPU_Get_thread_executing) - _ISR_Local_enable( level ); - #endif - - return executing; -} - -/**@}*/ - -#endif /* !defined( ASM ) */ - -#if defined( ASM ) || defined( _RTEMS_PERCPU_DEFINE_OFFSETS ) - -#if (CPU_ALLOCATE_INTERRUPT_STACK == TRUE) || \ - (CPU_HAS_SOFTWARE_INTERRUPT_STACK == TRUE) - /* - * If this CPU target lets RTEMS allocates the interrupt stack, then - * we need to have places in the per CPU table to hold them. - */ - #define PER_CPU_INTERRUPT_STACK_LOW \ - CPU_PER_CPU_CONTROL_SIZE - #define PER_CPU_INTERRUPT_STACK_HIGH \ - PER_CPU_INTERRUPT_STACK_LOW + CPU_SIZEOF_POINTER - #define PER_CPU_END_STACK \ - PER_CPU_INTERRUPT_STACK_HIGH + CPU_SIZEOF_POINTER - - #define INTERRUPT_STACK_LOW \ - (SYM(_Per_CPU_Information) + PER_CPU_INTERRUPT_STACK_LOW) - #define INTERRUPT_STACK_HIGH \ - (SYM(_Per_CPU_Information) + PER_CPU_INTERRUPT_STACK_HIGH) -#else - #define PER_CPU_END_STACK \ - CPU_PER_CPU_CONTROL_SIZE -#endif - -/* - * These are the offsets of the required elements in the per CPU table. - */ -#define PER_CPU_ISR_NEST_LEVEL \ - PER_CPU_END_STACK -#define PER_CPU_ISR_DISPATCH_DISABLE \ - PER_CPU_ISR_NEST_LEVEL + 4 -#define PER_CPU_THREAD_DISPATCH_DISABLE_LEVEL \ - PER_CPU_ISR_DISPATCH_DISABLE + 4 -#define PER_CPU_DISPATCH_NEEDED \ - PER_CPU_THREAD_DISPATCH_DISABLE_LEVEL + 4 -#define PER_CPU_OFFSET_EXECUTING \ - PER_CPU_DISPATCH_NEEDED + 4 -#define PER_CPU_OFFSET_HEIR \ - PER_CPU_OFFSET_EXECUTING + CPU_SIZEOF_POINTER -#if defined(RTEMS_SMP) -#define PER_CPU_INTERRUPT_FRAME_AREA \ - PER_CPU_OFFSET_HEIR + CPU_SIZEOF_POINTER -#endif - -#define THREAD_DISPATCH_DISABLE_LEVEL \ - (SYM(_Per_CPU_Information) + PER_CPU_THREAD_DISPATCH_DISABLE_LEVEL) -#define ISR_NEST_LEVEL \ - (SYM(_Per_CPU_Information) + PER_CPU_ISR_NEST_LEVEL) -#define DISPATCH_NEEDED \ - (SYM(_Per_CPU_Information) + PER_CPU_DISPATCH_NEEDED) - -#endif /* defined( ASM ) || defined( _RTEMS_PERCPU_DEFINE_OFFSETS ) */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/priority.h b/cpukit/score/include/rtems/score/priority.h deleted file mode 100644 index 7a8ddba763..0000000000 --- a/cpukit/score/include/rtems/score/priority.h +++ /dev/null @@ -1,203 +0,0 @@ -/** - * @file - * - * @brief Priority Handler API - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * Copyright (c) 2016, 2017 embedded brains GmbH. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_PRIORITY_H -#define _RTEMS_SCORE_PRIORITY_H - -#include -#include -#include - -struct _Scheduler_Control; - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ScorePriority Priority Handler - * - * @ingroup Score - * - * This handler encapsulates functionality which is used to manage thread - * priorities. The actual priority of a thread is an aggregation of priority - * nodes. The thread priority aggregation for the home scheduler instance of a - * thread consists of at least one priority node, which is normally the real - * priority of the thread. The locking protocols (e.g. priority ceiling and - * priority inheritance), rate-monotonic period objects and the POSIX sporadic - * server add, change and remove priority nodes. - * - * @{ - */ - -/** - * @brief The thread priority control. - * - * Lower values represent higher priorities. So, a priority value of zero - * represents the highest priority thread. This value is reserved for internal - * threads and the priority ceiling protocol. - * - * The format of the thread priority control depends on the context. A thread - * priority control may contain a user visible priority for API import/export. - * It may also contain a scheduler internal priority value. Values are - * translated via the scheduler map/unmap priority operations. The format of - * scheduler interal values depend on the particular scheduler implementation. - * It may for example encode a deadline in case of the EDF scheduler. - * - * The thread priority control value contained in the scheduler node - * (Scheduler_Node::Priority::value) uses the least-significant bit to indicate - * if the thread should be appended or prepended to its priority group, see - * SCHEDULER_PRIORITY_APPEND(). - */ -typedef uint64_t Priority_Control; - -/** - * @brief The highest (most important) thread priority value. - */ -#define PRIORITY_MINIMUM 0 - -/** - * @brief The priority value of pseudo-ISR threads. - * - * Examples are the MPCI and timer server threads. - */ -#define PRIORITY_PSEUDO_ISR PRIORITY_MINIMUM - -/** - * @brief The default lowest (least important) thread priority value. - * - * This value is CPU port dependent. - */ -#if defined (CPU_PRIORITY_MAXIMUM) - #define PRIORITY_DEFAULT_MAXIMUM CPU_PRIORITY_MAXIMUM -#else - #define PRIORITY_DEFAULT_MAXIMUM 255 -#endif - -/** - * @brief The priority node to build up a priority aggregation. - */ -typedef struct { - /** - * @brief Node component for a chain or red-black tree. - */ - union { - Chain_Node Chain; - RBTree_Node RBTree; - } Node; - - /** - * @brief The priority value of this node. - */ - Priority_Control priority; -} Priority_Node; - -/** - * @brief The priority action type. - */ -typedef enum { - PRIORITY_ACTION_ADD, - PRIORITY_ACTION_CHANGE, - PRIORITY_ACTION_REMOVE, - PRIORITY_ACTION_INVALID -} Priority_Action_type; - -typedef struct Priority_Aggregation Priority_Aggregation; - -/** - * @brief The priority aggregation. - * - * This structure serves two purposes. Firstly, it provides a place to - * register priority nodes and reflects the overall priority of its - * contributors. Secondly, it provides an action block to signal addition, - * change and removal of a priority node. - */ -struct Priority_Aggregation { - /** - * @brief This priority node reflects the overall priority of the aggregation. - * - * The overall priority of the aggregation is the minimum priority of the - * priority nodes in the contributors tree. - * - * This priority node may be used to add this aggregation to another - * aggregation to build up a recursive priority scheme. - * - * In case priority nodes of the contributors tree are added, changed or - * removed the priority of this node may change. To signal such changes to a - * priority aggregation the action block may be used. - */ - Priority_Node Node; - - /** - * @brief A red-black tree to contain priority nodes contributing to the - * overall priority of this priority aggregation. - */ - RBTree_Control Contributors; - -#if defined(RTEMS_SMP) - /** - * @brief The scheduler instance of this priority aggregation. - */ - const struct _Scheduler_Control *scheduler; -#endif - - /** - * @brief A priority action block to manage priority node additions, changes - * and removals. - */ - struct { -#if defined(RTEMS_SMP) - /** - * @brief The next priority aggregation in the action list. - */ - Priority_Aggregation *next; -#endif - - /** - * @brief The priority node of the action. - */ - Priority_Node *node; - - /** - * @brief The type of the action. - */ - Priority_Action_type type; - } Action; -}; - -/** - * @brief A list of priority actions. - * - * Actions are only added to the list. The action lists reside on the stack - * and have a short life-time. They are moved, processed or destroyed as a - * whole. - */ -typedef struct { - /** - * @brief The first action of a priority action list. - */ - Priority_Aggregation *actions; -} Priority_Actions; - -#ifdef __cplusplus -} -#endif - -/**@}*/ - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/prioritybitmap.h b/cpukit/score/include/rtems/score/prioritybitmap.h deleted file mode 100644 index 40638dd628..0000000000 --- a/cpukit/score/include/rtems/score/prioritybitmap.h +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @file rtems/score/prioritybitmap.h - * - * @brief Manipulation Routines for the Bitmap Priority Queue Implementation - * - * This include file contains all thread priority manipulation routines for - * the bit map priority queue implementation. - */ - -/* - * COPYRIGHT (c) 1989-2010. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_PRIORITYBITMAP_H -#define _RTEMS_SCORE_PRIORITYBITMAP_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ScorePriorityBitmap Bitmap Priority Thread Routines - * - * @ingroup Score - */ -/**@{*/ - -typedef uint16_t Priority_bit_map_Word; - -typedef struct { - /** - * @brief Each sixteen bit entry in this word is associated with one of the - * sixteen entries in the bit map. - */ - Priority_bit_map_Word major_bit_map; - - /** - * @brief Each bit in the bit map indicates whether or not there are threads - * ready at a particular priority. - * - * The mapping of individual priority levels to particular bits is processor - * dependent as is the value of each bit used to indicate that threads are - * ready at that priority. - */ - Priority_bit_map_Word bit_map[ 16 ]; -} Priority_bit_map_Control; - -/** - * The following record defines the information associated with - * each thread to manage its interaction with the priority bit maps. - */ -typedef struct { - /** This is the address of minor bit map slot. */ - Priority_bit_map_Word *minor; - /** This is the priority bit map ready mask. */ - Priority_bit_map_Word ready_major; - /** This is the priority bit map ready mask. */ - Priority_bit_map_Word ready_minor; - /** This is the priority bit map block mask. */ - Priority_bit_map_Word block_major; - /** This is the priority bit map block mask. */ - Priority_bit_map_Word block_minor; -} Priority_bit_map_Information; - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/prioritybitmapimpl.h b/cpukit/score/include/rtems/score/prioritybitmapimpl.h deleted file mode 100644 index 82c92eb5d6..0000000000 --- a/cpukit/score/include/rtems/score/prioritybitmapimpl.h +++ /dev/null @@ -1,215 +0,0 @@ -/** - * @file - * - * @brief Inlined Routines in the Priority Handler Bit Map Implementation - * - * This file contains the static inline implementation of all inlined - * routines in the Priority Handler bit map implementation - */ - -/* - * COPYRIGHT (c) 1989-2010. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_PRIORITYBITMAPIMPL_H -#define _RTEMS_SCORE_PRIORITYBITMAPIMPL_H - -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ScorePriority - */ -/**@{**/ - -/** - * This table is used by the generic bitfield routines to perform - * a highly optimized bit scan without the use of special CPU - * instructions. - */ -extern const unsigned char _Bitfield_Leading_zeros[256]; - -/** - * @brief Returns the bit number of the first bit set in the specified value. - * - * The correspondence between the bit number and actual bit position is CPU - * architecture dependent. The search for the first bit set may run from most - * to least significant bit or vice-versa. - * - * @param value The value to bit scan. - * - * @return The bit number of the first bit set. - * - * @see _Priority_Bits_index() and _Priority_Mask(). - */ -RTEMS_INLINE_ROUTINE unsigned int _Bitfield_Find_first_bit( - unsigned int value -) -{ - unsigned int bit_number; - -#if ( CPU_USE_GENERIC_BITFIELD_CODE == FALSE ) - _CPU_Bitfield_Find_first_bit( value, bit_number ); -#elif defined(__GNUC__) - bit_number = (unsigned int) __builtin_clz( value ) - - __SIZEOF_INT__ * __CHAR_BIT__ + 16; -#else - if ( value < 0x100 ) { - bit_number = _Bitfield_Leading_zeros[ value ] + 8; - } else { \ - bit_number = _Bitfield_Leading_zeros[ value >> 8 ]; - } -#endif - - return bit_number; -} - -/** - * @brief Returns the priority bit mask for the specified major or minor bit - * number. - * - * @param bit_number The bit number for which we need a mask. - * - * @return The priority bit mask. - */ -RTEMS_INLINE_ROUTINE Priority_bit_map_Word _Priority_Mask( - unsigned int bit_number -) -{ -#if ( CPU_USE_GENERIC_BITFIELD_CODE == FALSE ) - return _CPU_Priority_Mask( bit_number ); -#else - return (Priority_bit_map_Word) ( 0x8000u >> bit_number ); -#endif -} - -/** - * @brief Returns the bit index position for the specified major or minor bit - * number. - * - * @param bit_number The bit number for which we need an index. - * - * @return The corresponding array index into the priority bit map. - */ -RTEMS_INLINE_ROUTINE unsigned int _Priority_Bits_index( - unsigned int bit_number -) -{ -#if ( CPU_USE_GENERIC_BITFIELD_CODE == FALSE ) - return _CPU_Priority_bits_index( bit_number ); -#else - return bit_number; -#endif -} - -/** - * This function returns the major portion of the_priority. - */ - -RTEMS_INLINE_ROUTINE unsigned int _Priority_Major( unsigned int the_priority ) -{ - return the_priority / 16; -} - -/** - * This function returns the minor portion of the_priority. - */ - -RTEMS_INLINE_ROUTINE unsigned int _Priority_Minor( unsigned int the_priority ) -{ - return the_priority % 16; -} - -RTEMS_INLINE_ROUTINE void _Priority_bit_map_Initialize( - Priority_bit_map_Control *bit_map -) -{ - memset( bit_map, 0, sizeof( *bit_map ) ); -} - -/** - * Priority Queue implemented by bit map - */ - -RTEMS_INLINE_ROUTINE void _Priority_bit_map_Add ( - Priority_bit_map_Control *bit_map, - Priority_bit_map_Information *bit_map_info -) -{ - *bit_map_info->minor |= bit_map_info->ready_minor; - bit_map->major_bit_map |= bit_map_info->ready_major; -} - -RTEMS_INLINE_ROUTINE void _Priority_bit_map_Remove ( - Priority_bit_map_Control *bit_map, - Priority_bit_map_Information *bit_map_info -) -{ - *bit_map_info->minor &= bit_map_info->block_minor; - if ( *bit_map_info->minor == 0 ) - bit_map->major_bit_map &= bit_map_info->block_major; -} - -RTEMS_INLINE_ROUTINE unsigned int _Priority_bit_map_Get_highest( - const Priority_bit_map_Control *bit_map -) -{ - unsigned int minor; - unsigned int major; - - major = _Bitfield_Find_first_bit( bit_map->major_bit_map ); - minor = _Bitfield_Find_first_bit( bit_map->bit_map[ major ] ); - - return (_Priority_Bits_index( major ) << 4) + - _Priority_Bits_index( minor ); -} - -RTEMS_INLINE_ROUTINE bool _Priority_bit_map_Is_empty( - const Priority_bit_map_Control *bit_map -) -{ - return bit_map->major_bit_map == 0; -} - -RTEMS_INLINE_ROUTINE void _Priority_bit_map_Initialize_information( - Priority_bit_map_Control *bit_map, - Priority_bit_map_Information *bit_map_info, - unsigned int new_priority -) -{ - unsigned int major; - unsigned int minor; - Priority_bit_map_Word mask; - - major = _Priority_Major( new_priority ); - minor = _Priority_Minor( new_priority ); - - bit_map_info->minor = &bit_map->bit_map[ _Priority_Bits_index( major ) ]; - - mask = _Priority_Mask( major ); - bit_map_info->ready_major = mask; - bit_map_info->block_major = (Priority_bit_map_Word) ~mask; - - mask = _Priority_Mask( minor ); - bit_map_info->ready_minor = mask; - bit_map_info->block_minor = (Priority_bit_map_Word) ~mask; -} - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/priorityimpl.h b/cpukit/score/include/rtems/score/priorityimpl.h deleted file mode 100644 index 3380983cb7..0000000000 --- a/cpukit/score/include/rtems/score/priorityimpl.h +++ /dev/null @@ -1,435 +0,0 @@ -/* - * Copyright (c) 2016 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_PRIORITYIMPL_H -#define _RTEMS_SCORE_PRIORITYIMPL_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -RTEMS_INLINE_ROUTINE void _Priority_Actions_initialize_empty( - Priority_Actions *actions -) -{ - actions->actions = NULL; -} - -RTEMS_INLINE_ROUTINE void _Priority_Actions_initialize_one( - Priority_Actions *actions, - Priority_Aggregation *aggregation, - Priority_Node *node, - Priority_Action_type type -) -{ -#if defined(RTEMS_SMP) - aggregation->Action.next = NULL; -#endif - aggregation->Action.node = node; - aggregation->Action.type = type; - - actions->actions = aggregation; -} - -RTEMS_INLINE_ROUTINE bool _Priority_Actions_is_empty( - const Priority_Actions *actions -) -{ - return actions->actions == NULL; -} - -RTEMS_INLINE_ROUTINE bool _Priority_Actions_is_valid( - const Priority_Aggregation *aggregation -) -{ -#if defined(RTEMS_SMP) - return aggregation != NULL; -#else - (void) aggregation; - return false; -#endif -} - -RTEMS_INLINE_ROUTINE Priority_Aggregation *_Priority_Actions_move( - Priority_Actions *actions -) -{ - Priority_Aggregation *aggregation; - - aggregation = actions->actions; - actions->actions = NULL; - - return aggregation; -} - -RTEMS_INLINE_ROUTINE void _Priority_Actions_add( - Priority_Actions *actions, - Priority_Aggregation *aggregation -) -{ -#if defined(RTEMS_SMP) - /* - * Priority aggregations are only added to action lists, so do not care about - * the current next pointer value. - */ - aggregation->Action.next = actions->actions; -#endif - actions->actions = aggregation; -} - -RTEMS_INLINE_ROUTINE void _Priority_Node_initialize( - Priority_Node *node, - Priority_Control priority -) -{ - node->priority = priority; - _RBTree_Initialize_node( &node->Node.RBTree ); -} - -RTEMS_INLINE_ROUTINE void _Priority_Node_set_priority( - Priority_Node *node, - Priority_Control priority -) -{ - node->priority = priority; -} - -RTEMS_INLINE_ROUTINE void _Priority_Node_set_inactive( - Priority_Node *node -) -{ - _RBTree_Set_off_tree( &node->Node.RBTree ); -} - -RTEMS_INLINE_ROUTINE bool _Priority_Node_is_active( - const Priority_Node *node -) -{ - return !_RBTree_Is_node_off_tree( &node->Node.RBTree ); -} - -RTEMS_INLINE_ROUTINE void _Priority_Initialize_empty( - Priority_Aggregation *aggregation -) -{ -#if defined(RTEMS_DEBUG) -#if defined(RTEMS_SMP) - aggregation->Action.next = NULL; -#endif - aggregation->Action.node = NULL; - aggregation->Action.type = PRIORITY_ACTION_INVALID; -#endif - _RBTree_Initialize_node( &aggregation->Node.Node.RBTree ); - _RBTree_Initialize_empty( &aggregation->Contributors ); -} - -RTEMS_INLINE_ROUTINE void _Priority_Initialize_one( - Priority_Aggregation *aggregation, - Priority_Node *node -) -{ -#if defined(RTEMS_DEBUG) -#if defined(RTEMS_SMP) - aggregation->Action.next = NULL; -#endif - aggregation->Action.node = NULL; - aggregation->Action.type = PRIORITY_ACTION_INVALID; -#endif - _Priority_Node_initialize( &aggregation->Node, node->priority ); - _RBTree_Initialize_one( &aggregation->Contributors, &node->Node.RBTree ); -} - -RTEMS_INLINE_ROUTINE bool _Priority_Is_empty( - const Priority_Aggregation *aggregation -) -{ - return _RBTree_Is_empty( &aggregation->Contributors ); -} - -RTEMS_INLINE_ROUTINE Priority_Control _Priority_Get_priority( - const Priority_Aggregation *aggregation -) -{ - return aggregation->Node.priority; -} - -RTEMS_INLINE_ROUTINE const Scheduler_Control *_Priority_Get_scheduler( - const Priority_Aggregation *aggregation -) -{ -#if defined(RTEMS_SMP) - return aggregation->scheduler; -#else - return &_Scheduler_Table[ 0 ]; -#endif -} - -RTEMS_INLINE_ROUTINE Priority_Node *_Priority_Get_minimum_node( - const Priority_Aggregation *aggregation -) -{ - return (Priority_Node *) _RBTree_Minimum( &aggregation->Contributors ); -} - -RTEMS_INLINE_ROUTINE void _Priority_Set_action_node( - Priority_Aggregation *aggregation, - Priority_Node *node -) -{ - aggregation->Action.node = node; -} - -RTEMS_INLINE_ROUTINE void _Priority_Set_action_type( - Priority_Aggregation *aggregation, - Priority_Action_type type -) -{ - aggregation->Action.type = type; -} - -RTEMS_INLINE_ROUTINE void _Priority_Set_action( - Priority_Aggregation *aggregation, - Priority_Node *node, - Priority_Action_type type -) -{ - aggregation->Action.node = node; - aggregation->Action.type = type; -} - -RTEMS_INLINE_ROUTINE Priority_Aggregation *_Priority_Get_next_action( - const Priority_Aggregation *aggregation -) -{ -#if defined(RTEMS_SMP) - return aggregation->Action.next; -#else - (void) aggregation; - return NULL; -#endif -} - -RTEMS_INLINE_ROUTINE bool _Priority_Less( - const void *left, - const RBTree_Node *right -) -{ - const Priority_Control *the_left; - const Priority_Node *the_right; - - the_left = left; - the_right = RTEMS_CONTAINER_OF( right, Priority_Node, Node.RBTree ); - - return *the_left < the_right->priority; -} - -RTEMS_INLINE_ROUTINE bool _Priority_Plain_insert( - Priority_Aggregation *aggregation, - Priority_Node *node, - Priority_Control priority -) -{ - return _RBTree_Insert_inline( - &aggregation->Contributors, - &node->Node.RBTree, - &priority, - _Priority_Less - ); -} - -RTEMS_INLINE_ROUTINE void _Priority_Plain_extract( - Priority_Aggregation *aggregation, - Priority_Node *node -) -{ - _RBTree_Extract( &aggregation->Contributors, &node->Node.RBTree ); -} - -RTEMS_INLINE_ROUTINE void _Priority_Plain_changed( - Priority_Aggregation *aggregation, - Priority_Node *node -) -{ - _Priority_Plain_extract( aggregation, node ); - _Priority_Plain_insert( aggregation, node, node->priority ); -} - -typedef void ( *Priority_Add_handler )( - Priority_Aggregation *aggregation, - Priority_Actions *actions, - void *arg -); - -typedef void ( *Priority_Change_handler )( - Priority_Aggregation *aggregation, - bool prepend_it, - Priority_Actions *actions, - void *arg -); - -typedef void ( *Priority_Remove_handler )( - Priority_Aggregation *aggregation, - Priority_Actions *actions, - void *arg -); - -RTEMS_INLINE_ROUTINE void _Priority_Change_nothing( - Priority_Aggregation *aggregation, - bool prepend_it, - Priority_Actions *actions, - void *arg -) -{ - (void) aggregation; - (void) prepend_it; - (void) actions; - (void) arg; -} - -RTEMS_INLINE_ROUTINE void _Priority_Remove_nothing( - Priority_Aggregation *aggregation, - Priority_Actions *actions, - void *arg -) -{ - (void) aggregation; - (void) actions; - (void) arg; -} - -RTEMS_INLINE_ROUTINE void _Priority_Non_empty_insert( - Priority_Aggregation *aggregation, - Priority_Node *node, - Priority_Actions *actions, - Priority_Change_handler change, - void *arg -) -{ - bool is_new_minimum; - - _Assert( !_Priority_Is_empty( aggregation ) ); - is_new_minimum = _Priority_Plain_insert( aggregation, node, node->priority ); - - if ( is_new_minimum ) { - aggregation->Node.priority = node->priority; - ( *change )( aggregation, false, actions, arg ); - } -} - -RTEMS_INLINE_ROUTINE void _Priority_Insert( - Priority_Aggregation *aggregation, - Priority_Node *node, - Priority_Actions *actions, - Priority_Add_handler add, - Priority_Change_handler change, - void *arg -) -{ - if ( _Priority_Is_empty( aggregation ) ) { - _Priority_Initialize_one( aggregation, node ); - ( *add )( aggregation, actions, arg ); - } else { - _Priority_Non_empty_insert( aggregation, node, actions, change, arg ); - } -} - -RTEMS_INLINE_ROUTINE void _Priority_Extract( - Priority_Aggregation *aggregation, - Priority_Node *node, - Priority_Actions *actions, - Priority_Remove_handler remove, - Priority_Change_handler change, - void *arg -) -{ - _Priority_Plain_extract( aggregation, node ); - - if ( _Priority_Is_empty( aggregation ) ) { - ( *remove )( aggregation, actions, arg ); - } else { - Priority_Node *min; - - min = _Priority_Get_minimum_node( aggregation ); - - if ( node->priority < min->priority ) { - aggregation->Node.priority = min->priority; - ( *change )( aggregation, true, actions, arg ); - } - } -} - -RTEMS_INLINE_ROUTINE void _Priority_Extract_non_empty( - Priority_Aggregation *aggregation, - Priority_Node *node, - Priority_Actions *actions, - Priority_Change_handler change, - void *arg -) -{ - Priority_Node *min; - - _Priority_Plain_extract( aggregation, node ); - _Assert( !_Priority_Is_empty( aggregation ) ); - - min = _Priority_Get_minimum_node( aggregation ); - - if ( node->priority < min->priority ) { - aggregation->Node.priority = min->priority; - ( *change )( aggregation, true, actions, arg ); - } -} - -RTEMS_INLINE_ROUTINE void _Priority_Changed( - Priority_Aggregation *aggregation, - Priority_Node *node, - bool prepend_it, - Priority_Actions *actions, - Priority_Change_handler change, - void *arg -) -{ - Priority_Node *min; - - _Priority_Plain_changed( aggregation, node ); - - min = _Priority_Get_minimum_node( aggregation ); - - if ( min->priority != aggregation->Node.priority ) { - aggregation->Node.priority = min->priority; - ( *change )( aggregation, prepend_it, actions, arg ); - } -} - -RTEMS_INLINE_ROUTINE void _Priority_Replace( - Priority_Aggregation *aggregation, - Priority_Node *victim, - Priority_Node *replacement -) -{ - replacement->priority = victim->priority; - _RBTree_Replace_node( - &aggregation->Contributors, - &victim->Node.RBTree, - &replacement->Node.RBTree - ); -} - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_SCORE_PRIORITYIMPL_H */ diff --git a/cpukit/score/include/rtems/score/processormask.h b/cpukit/score/include/rtems/score/processormask.h deleted file mode 100644 index a06aa2a56b..0000000000 --- a/cpukit/score/include/rtems/score/processormask.h +++ /dev/null @@ -1,290 +0,0 @@ -/** - * @file - * - * @brief Processor Mask API - * - * @ingroup ScoreProcessorMask - */ - -/* - * Copyright (c) 2016, 2017 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_PROCESSORMASK_H -#define _RTEMS_SCORE_PROCESSORMASK_H - -#include - -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup ScoreProcessorMask Processor Mask - * - * @ingroup Score - * - * The processor mask provides a bit map large enough to provide one bit for - * each processor in the system. It is a fixed size internal data type - * provided for efficiency in addition to the API level cpu_set_t. - * - * @{ - */ - -/** - * @brief A bit map which is large enough to provide one bit for each processor - * in the system. - */ -typedef BITSET_DEFINE( Processor_mask, CPU_MAXIMUM_PROCESSORS ) Processor_mask; - -RTEMS_INLINE_ROUTINE void _Processor_mask_Zero( Processor_mask *mask ) -{ - BIT_ZERO( CPU_MAXIMUM_PROCESSORS, mask ); -} - -RTEMS_INLINE_ROUTINE bool _Processor_mask_Is_zero( const Processor_mask *mask ) -{ - return BIT_EMPTY( CPU_MAXIMUM_PROCESSORS, mask ); -} - -RTEMS_INLINE_ROUTINE void _Processor_mask_Fill( Processor_mask *mask ) -{ - BIT_FILL( CPU_MAXIMUM_PROCESSORS, mask ); -} - -RTEMS_INLINE_ROUTINE void _Processor_mask_Assign( - Processor_mask *dst, const Processor_mask *src -) -{ - BIT_COPY( CPU_MAXIMUM_PROCESSORS, src, dst ); -} - -RTEMS_INLINE_ROUTINE void _Processor_mask_Set( - Processor_mask *mask, - uint32_t index -) -{ - BIT_SET( CPU_MAXIMUM_PROCESSORS, index, mask ); -} - -RTEMS_INLINE_ROUTINE void _Processor_mask_Clear( - Processor_mask *mask, - uint32_t index -) -{ - BIT_CLR( CPU_MAXIMUM_PROCESSORS, index, mask ); -} - -RTEMS_INLINE_ROUTINE bool _Processor_mask_Is_set( - const Processor_mask *mask, - uint32_t index -) -{ - return BIT_ISSET( CPU_MAXIMUM_PROCESSORS, index, mask ); -} - -/** - * @brief Returns true if the processor sets a and b are equal, and false - * otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Processor_mask_Is_equal( - const Processor_mask *a, - const Processor_mask *b -) -{ - return !BIT_CMP( CPU_MAXIMUM_PROCESSORS, a, b ); -} - -/** - * @brief Returns true if the intersection of the processor sets a and b is - * non-empty, and false otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Processor_mask_Has_overlap( - const Processor_mask *a, - const Processor_mask *b -) -{ - return BIT_OVERLAP( CPU_MAXIMUM_PROCESSORS, a, b ); -} - -/** - * @brief Returns true if the processor set small is a subset of processor set - * big, and false otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Processor_mask_Is_subset( - const Processor_mask *big, - const Processor_mask *small -) -{ - return BIT_SUBSET( CPU_MAXIMUM_PROCESSORS, big, small ); -} - -/** - * @brief Performs a bitwise a = b & c. - */ -RTEMS_INLINE_ROUTINE void _Processor_mask_And( - Processor_mask *a, - const Processor_mask *b, - const Processor_mask *c -) -{ - BIT_AND2( CPU_MAXIMUM_PROCESSORS, a, b, c ); -} - -/** - * @brief Performs a bitwise a = b & ~c. - */ -RTEMS_INLINE_ROUTINE void _Processor_mask_Nand( - Processor_mask *a, - const Processor_mask *b, - const Processor_mask *c -) -{ - BIT_NAND2( CPU_MAXIMUM_PROCESSORS, a, b, c ); -} - -/** - * @brief Performs a bitwise a = b | c. - */ -RTEMS_INLINE_ROUTINE void _Processor_mask_Or( - Processor_mask *a, - const Processor_mask *b, - const Processor_mask *c -) -{ - BIT_OR2( CPU_MAXIMUM_PROCESSORS, a, b, c ); -} - -/** - * @brief Performs a bitwise a = b ^ c. - */ -RTEMS_INLINE_ROUTINE void _Processor_mask_Xor( - Processor_mask *a, - const Processor_mask *b, - const Processor_mask *c -) -{ - BIT_XOR2( CPU_MAXIMUM_PROCESSORS, a, b, c ); -} - -RTEMS_INLINE_ROUTINE uint32_t _Processor_mask_Count( const Processor_mask *a ) -{ - return (uint32_t) BIT_COUNT( CPU_MAXIMUM_PROCESSORS, a ); -} - -RTEMS_INLINE_ROUTINE uint32_t _Processor_mask_Find_last_set( const Processor_mask *a ) -{ - return (uint32_t) BIT_FLS( CPU_MAXIMUM_PROCESSORS, a ); -} - -/** - * @brief Returns the subset of 32 processors containing the specified index as - * an unsigned 32-bit integer. - */ -RTEMS_INLINE_ROUTINE uint32_t _Processor_mask_To_uint32_t( - const Processor_mask *mask, - uint32_t index -) -{ - long bits = mask->__bits[ __bitset_words( index ) ]; - - return (uint32_t) (bits >> (32 * (index % _BITSET_BITS) / 32)); -} - -/** - * @brief Creates a processor set from an unsigned 32-bit integer relative to - * the specified index. - */ -RTEMS_INLINE_ROUTINE void _Processor_mask_From_uint32_t( - Processor_mask *mask, - uint32_t bits, - uint32_t index -) -{ - _Processor_mask_Zero( mask ); - mask->__bits[ __bitset_words( index ) ] = ((long) bits) << (32 * (index % _BITSET_BITS) / 32); -} - -/** - * @brief Creates a processor set from the specified index. - */ -RTEMS_INLINE_ROUTINE void _Processor_mask_From_index( - Processor_mask *mask, - uint32_t index -) -{ - BIT_SETOF( CPU_MAXIMUM_PROCESSORS, (int) index, mask ); -} - -typedef enum { - PROCESSOR_MASK_COPY_LOSSLESS, - PROCESSOR_MASK_COPY_PARTIAL_LOSS, - PROCESSOR_MASK_COPY_COMPLETE_LOSS, - PROCESSOR_MASK_COPY_INVALID_SIZE -} Processor_mask_Copy_status; - -RTEMS_INLINE_ROUTINE bool _Processor_mask_Is_at_most_partial_loss( - Processor_mask_Copy_status status -) -{ - return (unsigned int) status <= PROCESSOR_MASK_COPY_PARTIAL_LOSS; -} - -Processor_mask_Copy_status _Processor_mask_Copy( - long *dst, - size_t dst_size, - const long *src, - size_t src_size -); - -RTEMS_INLINE_ROUTINE Processor_mask_Copy_status _Processor_mask_To_cpu_set_t( - const Processor_mask *src, - size_t dst_size, - cpu_set_t *dst -) -{ - return _Processor_mask_Copy( - &dst->__bits[ 0 ], - dst_size, - &src->__bits[ 0 ], - sizeof( *src ) - ); -} - -RTEMS_INLINE_ROUTINE Processor_mask_Copy_status _Processor_mask_From_cpu_set_t( - Processor_mask *dst, - size_t src_size, - const cpu_set_t *src -) -{ - return _Processor_mask_Copy( - &dst->__bits[ 0 ], - sizeof( *dst ), - &src->__bits[ 0 ], - src_size - ); -} - -extern const Processor_mask _Processor_mask_The_one_and_only; - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_SCORE_PROCESSORMASK_H */ diff --git a/cpukit/score/include/rtems/score/profiling.h b/cpukit/score/include/rtems/score/profiling.h deleted file mode 100644 index 6ba5d2987f..0000000000 --- a/cpukit/score/include/rtems/score/profiling.h +++ /dev/null @@ -1,140 +0,0 @@ -/** - * @file - * - * @ingroup ScoreProfiling - * - * @brief Profiling Support API - */ - -/* - * Copyright (c) 2014 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_PROFILING -#define _RTEMS_SCORE_PROFILING - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup ScoreProfiling Profiling Support - * - * @brief Profiling support. - * - * @{ - */ - -static inline void _Profiling_Thread_dispatch_disable( - Per_CPU_Control *cpu, - uint32_t previous_thread_dispatch_disable_level -) -{ -#if defined( RTEMS_PROFILING ) - if ( previous_thread_dispatch_disable_level == 0 ) { - Per_CPU_Stats *stats = &cpu->Stats; - - stats->thread_dispatch_disabled_instant = _CPU_Counter_read(); - ++stats->thread_dispatch_disabled_count; - } -#else - (void) cpu; - (void) previous_thread_dispatch_disable_level; -#endif -} - -static inline void _Profiling_Thread_dispatch_disable_critical( - Per_CPU_Control *cpu, - uint32_t previous_thread_dispatch_disable_level, - const ISR_lock_Context *lock_context -) -{ -#if defined( RTEMS_PROFILING ) - if ( previous_thread_dispatch_disable_level == 0 ) { - Per_CPU_Stats *stats = &cpu->Stats; - - stats->thread_dispatch_disabled_instant = lock_context->ISR_disable_instant; - ++stats->thread_dispatch_disabled_count; - } -#else - (void) cpu; - (void) previous_thread_dispatch_disable_level; - (void) lock_context; -#endif -} - -static inline void _Profiling_Thread_dispatch_enable( - Per_CPU_Control *cpu, - uint32_t new_thread_dispatch_disable_level -) -{ -#if defined( RTEMS_PROFILING ) - if ( new_thread_dispatch_disable_level == 0 ) { - Per_CPU_Stats *stats = &cpu->Stats; - CPU_Counter_ticks now = _CPU_Counter_read(); - CPU_Counter_ticks delta = _CPU_Counter_difference( - now, - stats->thread_dispatch_disabled_instant - ); - - stats->total_thread_dispatch_disabled_time += delta; - - if ( stats->max_thread_dispatch_disabled_time < delta ) { - stats->max_thread_dispatch_disabled_time = delta; - } - } -#else - (void) cpu; - (void) new_thread_dispatch_disable_level; -#endif -} - -static inline void _Profiling_Update_max_interrupt_delay( - Per_CPU_Control *cpu, - CPU_Counter_ticks interrupt_delay -) -{ -#if defined( RTEMS_PROFILING ) - Per_CPU_Stats *stats = &cpu->Stats; - - if ( stats->max_interrupt_delay < interrupt_delay ) { - stats->max_interrupt_delay = interrupt_delay; - } -#else - (void) cpu; - (void) interrupt_delay; -#endif -} - -/** - * @brief Updates the interrupt profiling statistics. - * - * Must be called with the interrupt stack and before the thread dispatch - * disable level is decremented. - */ -void _Profiling_Outer_most_interrupt_entry_and_exit( - Per_CPU_Control *cpu, - CPU_Counter_ticks interrupt_entry_instant, - CPU_Counter_ticks interrupt_exit_instant -); - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_SCORE_PROFILING */ diff --git a/cpukit/score/include/rtems/score/protectedheap.h b/cpukit/score/include/rtems/score/protectedheap.h deleted file mode 100644 index a08fa36cf3..0000000000 --- a/cpukit/score/include/rtems/score/protectedheap.h +++ /dev/null @@ -1,172 +0,0 @@ -/** - * @file - * - * @ingroup ScoreProtHeap - * - * @brief Protected Heap Handler API - */ - -/* - * COPYRIGHT (c) 1989-2007. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_PROTECTED_HEAP_H -#define _RTEMS_SCORE_PROTECTED_HEAP_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ScoreProtHeap Protected Heap Handler - * - * @ingroup ScoreHeap - * - * @brief Provides protected heap services. - * - * The @ref ScoreAllocatorMutex is used to protect the heap accesses. - * - */ -/**@{**/ - -/** - * @brief See _Heap_Initialize(). - */ -RTEMS_INLINE_ROUTINE uintptr_t _Protected_heap_Initialize( - Heap_Control *heap, - void *area_begin, - uintptr_t area_size, - uintptr_t page_size -) -{ - return _Heap_Initialize( heap, area_begin, area_size, page_size ); -} - -/** - * @brief See _Heap_Extend(). - * - * Returns @a true in case of success, and @a false otherwise. - */ -bool _Protected_heap_Extend( - Heap_Control *heap, - void *area_begin, - uintptr_t area_size -); - -/** - * @brief See _Heap_Allocate_aligned_with_boundary(). - */ -void *_Protected_heap_Allocate_aligned_with_boundary( - Heap_Control *heap, - uintptr_t size, - uintptr_t alignment, - uintptr_t boundary -); - -/** - * @brief See _Heap_Allocate_aligned_with_boundary() with boundary equals zero. - */ -RTEMS_INLINE_ROUTINE void *_Protected_heap_Allocate_aligned( - Heap_Control *heap, - uintptr_t size, - uintptr_t alignment -) -{ - return - _Protected_heap_Allocate_aligned_with_boundary( heap, size, alignment, 0 ); -} - -/** - * @brief See _Heap_Allocate_aligned_with_boundary() with alignment and - * boundary equals zero. - */ -RTEMS_INLINE_ROUTINE void *_Protected_heap_Allocate( - Heap_Control *heap, - uintptr_t size -) -{ - return _Protected_heap_Allocate_aligned_with_boundary( heap, size, 0, 0 ); -} - -/** - * @brief See _Heap_Size_of_alloc_area(). - */ -bool _Protected_heap_Get_block_size( - Heap_Control *heap, - void *addr, - uintptr_t *size -); - -/** - * @brief See _Heap_Resize_block(). - * - * Returns @a true in case of success, and @a false otherwise. - */ -bool _Protected_heap_Resize_block( - Heap_Control *heap, - void *addr, - uintptr_t size -); - -/** - * @brief See _Heap_Free(). - * - * Returns @a true in case of success, and @a false otherwise. - */ -bool _Protected_heap_Free( Heap_Control *heap, void *addr ); - -/** - * @brief See _Heap_Walk(). - */ -bool _Protected_heap_Walk( Heap_Control *heap, int source, bool dump ); - -/** - * @brief See _Heap_Iterate(). - */ -void _Protected_heap_Iterate( - Heap_Control *heap, - Heap_Block_visitor visitor, - void *visitor_arg -); - -/** - * @brief See _Heap_Get_information(). - * - * Returns @a true in case of success, and @a false otherwise. - */ -bool _Protected_heap_Get_information( - Heap_Control *heap, - Heap_Information_block *info -); - -/** - * @brief See _Heap_Get_free_information(). - * - * Returns @a true in case of success, and @a false otherwise. - */ -bool _Protected_heap_Get_free_information( - Heap_Control *heap, - Heap_Information *info -); - -/** - * @brief See _Heap_Get_size(). - */ -uintptr_t _Protected_heap_Get_size( Heap_Control *heap ); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/rbtree.h b/cpukit/score/include/rtems/score/rbtree.h deleted file mode 100644 index 15a3bc8913..0000000000 --- a/cpukit/score/include/rtems/score/rbtree.h +++ /dev/null @@ -1,568 +0,0 @@ -/** - * @file rtems/score/rbtree.h - * - * @brief Constants and Structures Associated with the Red-Black Tree Handler - * - * This include file contains all the constants and structures associated - * with the Red-Black Tree Handler. - */ - -/* - * Copyright (c) 2010 Gedare Bloom. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_RBTREE_H -#define _RTEMS_SCORE_RBTREE_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ScoreRBTree Red-Black Tree Handler - * - * @ingroup Score - * - * The Red-Black Tree Handler is used to manage sets of entities. This handler - * provides two data structures. The rbtree Node data structure is included - * as the first part of every data structure that will be placed on - * a RBTree. The second data structure is rbtree Control which is used - * to manage a set of rbtree Nodes. - */ -/**@{*/ - -struct RBTree_Control; - -/** - * @brief Red-black tree node. - * - * This is used to manage each node (element) which is placed on a red-black - * tree. - */ -typedef struct RBTree_Node { - RB_ENTRY(RBTree_Node) Node; -} RBTree_Node; - -/** - * @brief Red-black tree control. - * - * This is used to manage a red-black tree. A red-black tree consists of a - * tree of zero or more nodes. - */ -typedef RB_HEAD(RBTree_Control, RBTree_Node) RBTree_Control; - -/** - * @brief Initializer for an empty red-black tree with designator @a name. - */ -#define RBTREE_INITIALIZER_EMPTY( name ) \ - RB_INITIALIZER( name ) - -/** - * @brief Definition for an empty red-black tree with designator @a name. - */ -#define RBTREE_DEFINE_EMPTY( name ) \ - RBTree_Control name = RBTREE_INITIALIZER_EMPTY( name ) - -/** - * @brief Sets a red-black tree node as off-tree. - * - * Do not use this function on nodes which are a part of a tree. - * - * @param[in] the_node The node to set off-tree. - * - * @see _RBTree_Is_node_off_tree(). - */ -RTEMS_INLINE_ROUTINE void _RBTree_Set_off_tree( RBTree_Node *the_node ) -{ - RB_COLOR( the_node, Node ) = -1; -} - -/** - * @brief Returns true, if this red-black tree node is off-tree, and false - * otherwise. - * - * @param[in] the_node The node to test. - * - * @retval true The node is not a part of a tree (off-tree). - * @retval false Otherwise. - * - * @see _RBTree_Set_off_tree(). - */ -RTEMS_INLINE_ROUTINE bool _RBTree_Is_node_off_tree( - const RBTree_Node *the_node -) -{ - return RB_COLOR( the_node, Node ) == -1; -} - -/** - * @brief Rebalances the red-black tree after insertion of the node. - * - * @param[in] the_rbtree The red-black tree control. - * @param[in] the_node The most recently inserted node. - */ -void _RBTree_Insert_color( - RBTree_Control *the_rbtree, - RBTree_Node *the_node -); - -/** - * @brief Initializes a red-black tree node. - * - * In debug configurations, the node is set off tree. In all other - * configurations, this function does nothing. - * - * @param[in] the_node The red-black tree node to initialize. - */ -RTEMS_INLINE_ROUTINE void _RBTree_Initialize_node( RBTree_Node *the_node ) -{ -#if defined(RTEMS_DEBUG) - _RBTree_Set_off_tree( the_node ); -#else - (void) the_node; -#endif -} - -/** - * @brief Adds a child node to a parent node. - * - * @param[in] child The child node. - * @param[in] parent The parent node. - * @param[in] link The child node link of the parent node. - */ -RTEMS_INLINE_ROUTINE void _RBTree_Add_child( - RBTree_Node *child, - RBTree_Node *parent, - RBTree_Node **link -) -{ - _Assert( _RBTree_Is_node_off_tree( child ) ); - RB_SET( child, parent, Node ); - *link = child; -} - -/** - * @brief Inserts the node into the red-black tree using the specified parent - * node and link. - * - * @param[in] the_rbtree The red-black tree control. - * @param[in] the_node The node to insert. - * @param[in] parent The parent node. - * @param[in] link The child node link of the parent node. - * - * @code - * #include - * - * typedef struct { - * int value; - * RBTree_Node Node; - * } Some_Node; - * - * bool _Some_Less( - * const RBTree_Node *a, - * const RBTree_Node *b - * ) - * { - * const Some_Node *aa = RTEMS_CONTAINER_OF( a, Some_Node, Node ); - * const Some_Node *bb = RTEMS_CONTAINER_OF( b, Some_Node, Node ); - * - * return aa->value < bb->value; - * } - * - * void _Some_Insert( - * RBTree_Control *the_rbtree, - * Some_Node *the_node - * ) - * { - * RBTree_Node **link = _RBTree_Root_reference( the_rbtree ); - * RBTree_Node *parent = NULL; - * - * while ( *link != NULL ) { - * parent = *link; - * - * if ( _Some_Less( &the_node->Node, parent ) ) { - * link = _RBTree_Left_reference( parent ); - * } else { - * link = _RBTree_Right_reference( parent ); - * } - * } - * - * _RBTree_Insert_with_parent( the_rbtree, &the_node->Node, parent, link ); - * } - * @endcode - */ -RTEMS_INLINE_ROUTINE void _RBTree_Insert_with_parent( - RBTree_Control *the_rbtree, - RBTree_Node *the_node, - RBTree_Node *parent, - RBTree_Node **link -) -{ - _RBTree_Add_child( the_node, parent, link ); - _RBTree_Insert_color( the_rbtree, the_node ); -} - -/** - * @brief Extracts (removes) the node from the red-black tree. - * - * This function does not set the node off-tree. In case this is desired, then - * call _RBTree_Set_off_tree() after the extraction. - * - * In case the node to extract is not a node of the tree, then this function - * yields unpredictable results. - * - * @param[in] the_rbtree The red-black tree control. - * @param[in] the_node The node to extract. - */ -void _RBTree_Extract( - RBTree_Control *the_rbtree, - RBTree_Node *the_node -); - -/** - * @brief Returns a pointer to root node of the red-black tree. - * - * The root node may change after insert or extract operations. - * - * @param[in] the_rbtree The red-black tree control. - * - * @retval NULL The tree is empty. - * @retval root The root node. - * - * @see _RBTree_Is_root(). - */ -RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Root( - const RBTree_Control *the_rbtree -) -{ - return RB_ROOT( the_rbtree ); -} - -/** - * @brief Returns a reference to the root pointer of the red-black tree. - */ -RTEMS_INLINE_ROUTINE RBTree_Node **_RBTree_Root_reference( - RBTree_Control *the_rbtree -) -{ - return &RB_ROOT( the_rbtree ); -} - -/** - * @brief Returns a constant reference to the root pointer of the red-black tree. - */ -RTEMS_INLINE_ROUTINE RBTree_Node * const *_RBTree_Root_const_reference( - const RBTree_Control *the_rbtree -) -{ - return &RB_ROOT( the_rbtree ); -} - -/** - * @brief Returns a pointer to the parent of this node. - * - * The node must have a parent, thus it is invalid to use this function for the - * root node or a node that is not part of a tree. To test for the root node - * compare with _RBTree_Root() or use _RBTree_Is_root(). - * - * @param[in] the_node The node of interest. - * - * @retval parent The parent of this node. - * @retval undefined The node is the root node or not part of a tree. - */ -RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Parent( - const RBTree_Node *the_node -) -{ - return RB_PARENT( the_node, Node ); -} - -/** - * @brief Return pointer to the left of this node. - * - * This function returns a pointer to the left node of this node. - * - * @param[in] the_node is the node to be operated upon. - * - * @return This method returns the left node on the rbtree. - */ -RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Left( - const RBTree_Node *the_node -) -{ - return RB_LEFT( the_node, Node ); -} - -/** - * @brief Returns a reference to the left child pointer of the red-black tree - * node. - */ -RTEMS_INLINE_ROUTINE RBTree_Node **_RBTree_Left_reference( - RBTree_Node *the_node -) -{ - return &RB_LEFT( the_node, Node ); -} - -/** - * @brief Return pointer to the right of this node. - * - * This function returns a pointer to the right node of this node. - * - * @param[in] the_node is the node to be operated upon. - * - * @return This method returns the right node on the rbtree. - */ -RTEMS_INLINE_ROUTINE RBTree_Node *_RBTree_Right( - const RBTree_Node *the_node -) -{ - return RB_RIGHT( the_node, Node ); -} - -/** - * @brief Returns a reference to the right child pointer of the red-black tree - * node. - */ -RTEMS_INLINE_ROUTINE RBTree_Node **_RBTree_Right_reference( - RBTree_Node *the_node -) -{ - return &RB_RIGHT( the_node, Node ); -} - -/** - * @brief Is the RBTree empty. - * - * This function returns true if there are no nodes on @a the_rbtree and - * false otherwise. - * - * @param[in] the_rbtree is the rbtree to be operated upon. - * - * @retval true There are no nodes on @a the_rbtree. - * @retval false There are nodes on @a the_rbtree. - */ -RTEMS_INLINE_ROUTINE bool _RBTree_Is_empty( - const RBTree_Control *the_rbtree -) -{ - return RB_EMPTY( the_rbtree ); -} - -/** - * @brief Returns true if this node is the root node of a red-black tree, and - * false otherwise. - * - * The root node may change after insert or extract operations. In case the - * node is not a node of a tree, then this function yields unpredictable - * results. - * - * @param[in] the_node The node of interest. - * - * @retval true The node is the root node. - * @retval false Otherwise. - * - * @see _RBTree_Root(). - */ -RTEMS_INLINE_ROUTINE bool _RBTree_Is_root( - const RBTree_Node *the_node -) -{ - return _RBTree_Parent( the_node ) == NULL; -} - -/** - * @brief Initialize this RBTree as empty. - * - * This routine initializes @a the_rbtree to contain zero nodes. - */ -RTEMS_INLINE_ROUTINE void _RBTree_Initialize_empty( - RBTree_Control *the_rbtree -) -{ - RB_INIT( the_rbtree ); -} - -/** - * @brief Initializes this red-black tree to contain exactly the specified - * node. - * - * @param[in] the_rbtree The red-black tree control. - * @param[in] the_node The one and only node. - */ -RTEMS_INLINE_ROUTINE void _RBTree_Initialize_one( - RBTree_Control *the_rbtree, - RBTree_Node *the_node -) -{ - _Assert( _RBTree_Is_node_off_tree( the_node ) ); - RB_ROOT( the_rbtree ) = the_node; - RB_PARENT( the_node, Node ) = NULL; - RB_LEFT( the_node, Node ) = NULL; - RB_RIGHT( the_node, Node ) = NULL; - RB_COLOR( the_node, Node ) = RB_BLACK; -} - -/** - * @brief Returns the minimum node of the red-black tree. - * - * @param[in] the_rbtree The red-black tree control. - * - * @retval NULL The red-black tree is empty. - * @retval node The minimum node. - */ -RBTree_Node *_RBTree_Minimum( const RBTree_Control *the_rbtree ); - -/** - * @brief Returns the maximum node of the red-black tree. - * - * @param[in] the_rbtree The red-black tree control. - * - * @retval NULL The red-black tree is empty. - * @retval node The maximum node. - */ -RBTree_Node *_RBTree_Maximum( const RBTree_Control *the_rbtree ); - -/** - * @brief Returns the predecessor of a node. - * - * @param[in] node is the node. - * - * @retval NULL The predecessor does not exist. Otherwise it returns - * the predecessor node. - */ -RBTree_Node *_RBTree_Predecessor( const RBTree_Node *node ); - -/** - * @brief Returns the successor of a node. - * - * @param[in] node is the node. - * - * @retval NULL The successor does not exist. Otherwise the successor node. - */ -RBTree_Node *_RBTree_Successor( const RBTree_Node *node ); - -/** - * @brief Replaces a node in the red-black tree without a rebalance. - * - * @param[in] the_rbtree The red-black tree control. - * @param[in] victim The victim node. - * @param[in] replacement The replacement node. - */ -void _RBTree_Replace_node( - RBTree_Control *the_rbtree, - RBTree_Node *victim, - RBTree_Node *replacement -); - -/** - * @brief Inserts the node into the red-black tree. - * - * @param the_rbtree The red-black tree control. - * @param the_node The node to insert. - * @param key The key of the node to insert. This key must be equal to the key - * stored in the node to insert. The separate key parameter is provided for - * two reasons. Firstly, it allows to share the less operator with - * _RBTree_Find_inline(). Secondly, the compiler may generate better code if - * the key is stored in a local variable. - * @param less Must return true if the specified key is less than the key of - * the node, otherwise false. - * - * @retval true The inserted node is the new minimum node according to the - * specified less order function. - * @retval false Otherwise. - */ -RTEMS_INLINE_ROUTINE bool _RBTree_Insert_inline( - RBTree_Control *the_rbtree, - RBTree_Node *the_node, - const void *key, - bool ( *less )( const void *, const RBTree_Node * ) -) -{ - RBTree_Node **link; - RBTree_Node *parent; - bool is_new_minimum; - - link = _RBTree_Root_reference( the_rbtree ); - parent = NULL; - is_new_minimum = true; - - while ( *link != NULL ) { - parent = *link; - - if ( ( *less )( key, parent ) ) { - link = _RBTree_Left_reference( parent ); - } else { - link = _RBTree_Right_reference( parent ); - is_new_minimum = false; - } - } - - _RBTree_Add_child( the_node, parent, link ); - _RBTree_Insert_color( the_rbtree, the_node ); - return is_new_minimum; -} - -/** - * @brief Finds an object in the red-black tree with the specified key. - * - * @param the_rbtree The red-black tree control. - * @param key The key to look after. - * @param equal Must return true if the specified key equals the key of the - * node, otherwise false. - * @param less Must return true if the specified key is less than the key of - * the node, otherwise false. - * @param map In case a node with the specified key is found, then this - * function is called to map the node to the object returned. Usually it - * performs some offset operation via RTEMS_CONTAINER_OF() to map the node to - * its containing object. Thus, the return type is a void pointer and not a - * red-black tree node. - * - * @retval object An object with the specified key. - * @retval NULL No object with the specified key exists in the red-black tree. - */ -RTEMS_INLINE_ROUTINE void *_RBTree_Find_inline( - const RBTree_Control *the_rbtree, - const void *key, - bool ( *equal )( const void *, const RBTree_Node * ), - bool ( *less )( const void *, const RBTree_Node * ), - void *( *map )( RBTree_Node * ) -) -{ - RBTree_Node * const *link; - RBTree_Node *parent; - - link = _RBTree_Root_const_reference( the_rbtree ); - parent = NULL; - - while ( *link != NULL ) { - parent = *link; - - if ( ( *equal )( key, parent ) ) { - return ( *map )( parent ); - } else if ( ( *less )( key, parent ) ) { - link = _RBTree_Left_reference( parent ); - } else { - link = _RBTree_Right_reference( parent ); - } - } - - return NULL; -} - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/rbtreeimpl.h b/cpukit/score/include/rtems/score/rbtreeimpl.h deleted file mode 100644 index bf92e29228..0000000000 --- a/cpukit/score/include/rtems/score/rbtreeimpl.h +++ /dev/null @@ -1,72 +0,0 @@ -/** - * @file - * - * @brief Inlined Routines Associated with Red-Black Trees - * - * This include file contains the bodies of the routines which are - * associated with Red-Black Trees and inlined. - * - * @note The routines in this file are ordered from simple - * to complex. No other RBTree Handler routine is referenced - * unless it has already been defined. - */ - -/* - * Copyright (c) 2010-2012 Gedare Bloom. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_RBTREEIMPL_H -#define _RTEMS_SCORE_RBTREEIMPL_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ScoreRBTree - */ -/**@{**/ - -/** - * @brief Red-black tree visitor. - * - * @param[in] node The node. - * @param[in] visitor_arg The visitor argument. - * - * @retval true Stop the iteration. - * @retval false Continue the iteration. - * - * @see _RBTree_Iterate(). - */ -typedef bool (*RBTree_Visitor)( - const RBTree_Node *node, - void *visitor_arg -); - -/** - * @brief Red-black tree iteration. - * - * @param[in] rbtree The red-black tree. - * @param[in] visitor The visitor. - * @param[in] visitor_arg The visitor argument. - */ -void _RBTree_Iterate( - const RBTree_Control *rbtree, - RBTree_Visitor visitor, - void *visitor_arg -); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/scheduler.h b/cpukit/score/include/rtems/score/scheduler.h deleted file mode 100644 index a6066c8e4a..0000000000 --- a/cpukit/score/include/rtems/score/scheduler.h +++ /dev/null @@ -1,556 +0,0 @@ -/** - * @file rtems/score/scheduler.h - * - * @brief Constants and Structures Associated with the Scheduler - * - * This include file contains all the constants and structures associated - * with the scheduler. - */ - -/* - * Copyright (C) 2010 Gedare Bloom. - * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SCHEDULER_H -#define _RTEMS_SCORE_SCHEDULER_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -struct Per_CPU_Control; - -/** - * @defgroup ScoreScheduler Scheduler Handler - * - * @ingroup Score - * - * This handler encapsulates functionality related to managing sets of threads - * that are ready for execution. - */ -/**@{*/ - -typedef struct _Scheduler_Control Scheduler_Control; - -/** - * @brief The scheduler operations. - */ -typedef struct { - /** @see _Scheduler_Handler_initialization() */ - void ( *initialize )( const Scheduler_Control * ); - - /** @see _Scheduler_Schedule() */ - void ( *schedule )( const Scheduler_Control *, Thread_Control *); - - /** @see _Scheduler_Yield() */ - void ( *yield )( - const Scheduler_Control *, - Thread_Control *, - Scheduler_Node * - ); - - /** @see _Scheduler_Block() */ - void ( *block )( - const Scheduler_Control *, - Thread_Control *, - Scheduler_Node * - ); - - /** @see _Scheduler_Unblock() */ - void ( *unblock )( - const Scheduler_Control *, - Thread_Control *, - Scheduler_Node * - ); - - /** @see _Scheduler_Update_priority() */ - void ( *update_priority )( - const Scheduler_Control *, - Thread_Control *, - Scheduler_Node * - ); - - /** @see _Scheduler_Map_priority() */ - Priority_Control ( *map_priority )( - const Scheduler_Control *, - Priority_Control - ); - - /** @see _Scheduler_Unmap_priority() */ - Priority_Control ( *unmap_priority )( - const Scheduler_Control *, - Priority_Control - ); - -#if defined(RTEMS_SMP) - /** - * @brief Ask for help operation. - * - * @param[in] scheduler The scheduler instance to ask for help. - * @param[in] the_thread The thread needing help. - * @param[in] node The scheduler node. - * - * @retval true Ask for help was successful. - * @retval false Otherwise. - */ - bool ( *ask_for_help )( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node - ); - - /** - * @brief Reconsider help operation. - * - * @param[in] scheduler The scheduler instance to reconsider the help - * request. - * @param[in] the_thread The thread reconsidering a help request. - * @param[in] node The scheduler node. - */ - void ( *reconsider_help_request )( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node - ); - - /** - * @brief Withdraw node operation. - * - * @param[in] scheduler The scheduler instance to withdraw the node. - * @param[in] the_thread The thread using the node. - * @param[in] node The scheduler node to withdraw. - * @param[in] next_state The next thread scheduler state in case the node is - * scheduled. - */ - void ( *withdraw_node )( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node, - Thread_Scheduler_state next_state - ); - - /** - * @brief Add processor operation. - * - * @param[in] scheduler The scheduler instance to add the processor. - * @param[in] idle The idle thread of the processor to add. - */ - void ( *add_processor )( - const Scheduler_Control *scheduler, - Thread_Control *idle - ); - - /** - * @brief Remove processor operation. - * - * @param[in] scheduler The scheduler instance to remove the processor. - * @param[in] cpu The processor to remove. - * - * @return The idle thread of the removed processor. - */ - Thread_Control *( *remove_processor )( - const Scheduler_Control *scheduler, - struct Per_CPU_Control *cpu - ); -#endif - - /** @see _Scheduler_Node_initialize() */ - void ( *node_initialize )( - const Scheduler_Control *, - Scheduler_Node *, - Thread_Control *, - Priority_Control - ); - - /** @see _Scheduler_Node_destroy() */ - void ( *node_destroy )( const Scheduler_Control *, Scheduler_Node * ); - - /** @see _Scheduler_Release_job() */ - void ( *release_job ) ( - const Scheduler_Control *, - Thread_Control *, - Priority_Node *, - uint64_t, - Thread_queue_Context * - ); - - /** @see _Scheduler_Cancel_job() */ - void ( *cancel_job ) ( - const Scheduler_Control *, - Thread_Control *, - Priority_Node *, - Thread_queue_Context * - ); - - /** @see _Scheduler_Tick() */ - void ( *tick )( const Scheduler_Control *, Thread_Control * ); - - /** @see _Scheduler_Start_idle() */ - void ( *start_idle )( - const Scheduler_Control *, - Thread_Control *, - struct Per_CPU_Control * - ); - -#if defined(RTEMS_SMP) - /** @see _Scheduler_Set_affinity() */ - bool ( *set_affinity )( - const Scheduler_Control *, - Thread_Control *, - Scheduler_Node *, - const Processor_mask * - ); -#endif -} Scheduler_Operations; - -/** - * @brief Scheduler context. - * - * The scheduler context of a particular scheduler implementation must place - * this structure at the begin of its context structure. - */ -typedef struct Scheduler_Context { - /** - * @brief Lock to protect this scheduler instance. - */ - ISR_LOCK_MEMBER( Lock ) - -#if defined(RTEMS_SMP) - /** - * @brief The set of processors owned by this scheduler instance. - */ - Processor_mask Processors; -#endif -} Scheduler_Context; - -/** - * @brief Scheduler control. - */ -struct _Scheduler_Control { - /** - * @brief Reference to a statically allocated scheduler context. - */ - Scheduler_Context *context; - - /** - * @brief The scheduler operations. - */ - Scheduler_Operations Operations; - - /** - * @brief The maximum priority value of this scheduler. - * - * It defines the lowest (least important) thread priority for this - * scheduler. For example the idle threads have this priority. - */ - Priority_Control maximum_priority; - - /** - * @brief The scheduler name. - */ - uint32_t name; -}; - -/** - * @brief Registered schedulers. - * - * Application provided via . - * - * @see _Scheduler_Count. - */ -extern const Scheduler_Control _Scheduler_Table[]; - -/** - * @brief Count of registered schedulers. - * - * Application provided via on SMP configurations. - * - * It is very important that this is a compile-time constant on uni-processor - * configurations (in this case RTEMS_SMP is not defined) so that the compiler - * can optimize the some loops away - * - * @see _Scheduler_Table. - */ -#if defined(RTEMS_SMP) - extern const size_t _Scheduler_Count; -#else - #define _Scheduler_Count ( (size_t) 1 ) -#endif - -#if defined(RTEMS_SMP) - /** - * @brief The scheduler assignment default attributes. - */ - #define SCHEDULER_ASSIGN_DEFAULT UINT32_C(0x0) - - /** - * @brief The presence of this processor is optional. - */ - #define SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL SCHEDULER_ASSIGN_DEFAULT - - /** - * @brief The presence of this processor is mandatory. - */ - #define SCHEDULER_ASSIGN_PROCESSOR_MANDATORY UINT32_C(0x1) - - /** - * @brief Scheduler assignment. - */ - typedef struct { - /** - * @brief The scheduler for this processor. - */ - const Scheduler_Control *scheduler; - - /** - * @brief The scheduler assignment attributes. - * - * Use @ref SCHEDULER_ASSIGN_DEFAULT to select default attributes. - * - * The presence of a processor can be - * - @ref SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL, or - * - @ref SCHEDULER_ASSIGN_PROCESSOR_MANDATORY. - */ - uint32_t attributes; - } Scheduler_Assignment; - - /** - * @brief The scheduler assignments. - * - * The length of this array must be equal to the maximum processors. - * - * Application provided via . - * - * @see _Scheduler_Table and rtems_configuration_get_maximum_processors(). - */ - extern const Scheduler_Assignment _Scheduler_Initial_assignments[]; -#endif - -/** - * @brief Returns the scheduler internal thread priority mapped by - * SCHEDULER_PRIORITY_MAP(). - * - * @param[in] scheduler Unused. - * @param[in] priority The user visible thread priority. - * - * @return priority The scheduler internal thread priority. - */ -Priority_Control _Scheduler_default_Map_priority( - const Scheduler_Control *scheduler, - Priority_Control priority -); - -/** - * @brief Returns the user visible thread priority unmapped by - * SCHEDULER_PRIORITY_UNMAP(). - * - * @param[in] scheduler Unused. - * @param[in] priority The scheduler internal thread priority. - * - * @return priority The user visible thread priority. - */ -Priority_Control _Scheduler_default_Unmap_priority( - const Scheduler_Control *scheduler, - Priority_Control priority -); - -#if defined(RTEMS_SMP) - /** - * @brief Does nothing. - * - * @param[in] scheduler Unused. - * @param[in] the_thread Unused. - * @param[in] node Unused. - * - * @retval false Always. - */ - bool _Scheduler_default_Ask_for_help( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node - ); - - /** - * @brief Does nothing. - * - * @param[in] scheduler Unused. - * @param[in] the_thread Unused. - * @param[in] node Unused. - */ - void _Scheduler_default_Reconsider_help_request( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node - ); - - /** - * @brief Does nothing. - * - * @param[in] scheduler Unused. - * @param[in] the_thread Unused. - * @param[in] node Unused. - * @param[in] next_state Unused. - */ - void _Scheduler_default_Withdraw_node( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node, - Thread_Scheduler_state next_state - ); - - #define SCHEDULER_OPERATION_DEFAULT_ASK_FOR_HELP \ - _Scheduler_default_Ask_for_help, \ - _Scheduler_default_Reconsider_help_request, \ - _Scheduler_default_Withdraw_node, \ - NULL, \ - NULL, -#else - #define SCHEDULER_OPERATION_DEFAULT_ASK_FOR_HELP -#endif - -/** - * @brief Does nothing. - * - * @param[in] scheduler Unused. - * @param[in] the_thread Unused. - */ -void _Scheduler_default_Schedule( - const Scheduler_Control *scheduler, - Thread_Control *the_thread -); - -/** - * @brief Performs the scheduler base node initialization. - * - * @param[in] scheduler Unused. - * @param[in] node The node to initialize. - * @param[in] the_thread Unused. - * @param[in] priority The thread priority. - */ -void _Scheduler_default_Node_initialize( - const Scheduler_Control *scheduler, - Scheduler_Node *node, - Thread_Control *the_thread, - Priority_Control priority -); - -/** - * @brief Does nothing. - * - * @param[in] scheduler Unused. - * @param[in] node Unused. - */ -void _Scheduler_default_Node_destroy( - const Scheduler_Control *scheduler, - Scheduler_Node *node -); - -/** - * @brief Does nothing. - * - * @param[in] scheduler Unused. - * @param[in] the_thread Unused. - * @param[in] priority_node Unused. - * @param[in] deadline Unused. - * @param[in] queue_context Unused. - * - * @retval NULL Always. - */ -void _Scheduler_default_Release_job( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Priority_Node *priority_node, - uint64_t deadline, - Thread_queue_Context *queue_context -); - -/** - * @brief Does nothing. - * - * @param[in] scheduler Unused. - * @param[in] the_thread Unused. - * @param[in] priority_node Unused. - * @param[in] queue_context Unused. - * - * @retval NULL Always. - */ -void _Scheduler_default_Cancel_job( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Priority_Node *priority_node, - Thread_queue_Context *queue_context -); - -/** - * @brief Performs tick operations depending on the CPU budget algorithm for - * each executing thread. - * - * This routine is invoked as part of processing each clock tick. - * - * @param[in] scheduler The scheduler. - * @param[in] executing An executing thread. - */ -void _Scheduler_default_Tick( - const Scheduler_Control *scheduler, - Thread_Control *executing -); - -/** - * @brief Starts an idle thread. - * - * @param[in] scheduler The scheduler. - * @param[in] the_thread An idle thread. - * @param[in] cpu This parameter is unused. - */ -void _Scheduler_default_Start_idle( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - struct Per_CPU_Control *cpu -); - -#if defined(RTEMS_SMP) - /** - * @brief Default implementation of the set affinity scheduler operation. - * - * @param[in] scheduler The scheduler instance. - * @param[in] thread The associated thread. - * @param[in] node The home scheduler node of the associated thread. - * @param[in] affinity The new processor affinity set for the thread. - * - * @retval true The processor set of the scheduler is a subset of the affinity set. - * @retval false Otherwise. - */ - bool _Scheduler_default_Set_affinity( - const Scheduler_Control *scheduler, - Thread_Control *thread, - Scheduler_Node *node, - const Processor_mask *affinity - ); - - #define SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY \ - , _Scheduler_default_Set_affinity -#else - #define SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY -#endif - -/** - * @brief This defines the lowest (least important) thread priority of the - * first scheduler instance. - */ -#define PRIORITY_MAXIMUM ( _Scheduler_Table[ 0 ].maximum_priority ) - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/schedulercbs.h b/cpukit/score/include/rtems/score/schedulercbs.h deleted file mode 100644 index 635abce125..0000000000 --- a/cpukit/score/include/rtems/score/schedulercbs.h +++ /dev/null @@ -1,346 +0,0 @@ -/** - * @file rtems/score/schedulercbs.h - * - * @brief Thread manipulation for the CBS scheduler - * - * This include file contains all the constants and structures associated - * with the manipulation of threads for the CBS scheduler. - */ - -/* - * Copryight (c) 2011 Petr Benes. - * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SCHEDULERCBS_H -#define _RTEMS_SCORE_SCHEDULERCBS_H - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ScoreSchedulerCBS CBS Scheduler - * - * @ingroup ScoreScheduler - */ -/**@{*/ - -#define SCHEDULER_CBS_MAXIMUM_PRIORITY SCHEDULER_EDF_MAXIMUM_PRIORITY - -/** - * Entry points for the Constant Bandwidth Server Scheduler. - * - * @note: The CBS scheduler is an enhancement of EDF scheduler, - * therefor some routines are similar. - */ -#define SCHEDULER_CBS_ENTRY_POINTS \ - { \ - _Scheduler_EDF_Initialize, /* initialize entry point */ \ - _Scheduler_EDF_Schedule, /* schedule entry point */ \ - _Scheduler_EDF_Yield, /* yield entry point */ \ - _Scheduler_EDF_Block, /* block entry point */ \ - _Scheduler_CBS_Unblock, /* unblock entry point */ \ - _Scheduler_EDF_Update_priority, /* update priority entry point */ \ - _Scheduler_EDF_Map_priority, /* map priority entry point */ \ - _Scheduler_EDF_Unmap_priority, /* unmap priority entry point */ \ - SCHEDULER_OPERATION_DEFAULT_ASK_FOR_HELP \ - _Scheduler_CBS_Node_initialize, /* node initialize entry point */ \ - _Scheduler_default_Node_destroy, /* node destroy entry point */ \ - _Scheduler_CBS_Release_job, /* new period of task */ \ - _Scheduler_CBS_Cancel_job, /* cancel period of task */ \ - _Scheduler_default_Tick, /* tick entry point */ \ - _Scheduler_default_Start_idle /* start idle entry point */ \ - SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY \ - } - -/* Return values for CBS server. */ -#define SCHEDULER_CBS_OK 0 -#define SCHEDULER_CBS_ERROR_GENERIC -16 -#define SCHEDULER_CBS_ERROR_NO_MEMORY -17 -#define SCHEDULER_CBS_ERROR_INVALID_PARAMETER -18 -#define SCHEDULER_CBS_ERROR_UNAUTHORIZED -19 -#define SCHEDULER_CBS_ERROR_UNIMPLEMENTED -20 -#define SCHEDULER_CBS_ERROR_MISSING_COMPONENT -21 -#define SCHEDULER_CBS_ERROR_INCONSISTENT_STATE -22 -#define SCHEDULER_CBS_ERROR_SYSTEM_OVERLOAD -23 -#define SCHEDULER_CBS_ERROR_INTERNAL_ERROR -24 -#define SCHEDULER_CBS_ERROR_NOT_FOUND -25 -#define SCHEDULER_CBS_ERROR_FULL -26 -#define SCHEDULER_CBS_ERROR_EMPTY -27 -#define SCHEDULER_CBS_ERROR_NOSERVER SCHEDULER_CBS_ERROR_NOT_FOUND - -/** Maximum number of simultaneous servers. */ -extern const uint32_t _Scheduler_CBS_Maximum_servers; - -/** Server id. */ -typedef uint32_t Scheduler_CBS_Server_id; - -/** Callback function invoked when a budget overrun of a task occurs. */ -typedef void (*Scheduler_CBS_Budget_overrun)( - Scheduler_CBS_Server_id server_id -); - -/** - * This structure handles server parameters. - */ -typedef struct { - /** Relative deadline of the server. */ - time_t deadline; - /** Budget (computation time) of the server. */ - time_t budget; -} Scheduler_CBS_Parameters; - -/** - * This structure represents a time server. - */ -typedef struct { - /** - * Task id. - * - * @note: The current implementation of CBS handles only one task per server. - */ - rtems_id task_id; - /** Server paramenters. */ - Scheduler_CBS_Parameters parameters; - /** Callback function invoked when a budget overrun occurs. */ - Scheduler_CBS_Budget_overrun cbs_budget_overrun; - - /** - * @brief Indicates if this CBS server is initialized. - * - * @see _Scheduler_CBS_Create_server() and _Scheduler_CBS_Destroy_server(). - */ - bool initialized; -} Scheduler_CBS_Server; - -/** - * This structure handles CBS specific data of a thread. - */ -typedef struct { - /** EDF scheduler specific data of a task. */ - Scheduler_EDF_Node Base; - /** CBS server specific data of a task. */ - Scheduler_CBS_Server *cbs_server; - - Priority_Node *deadline_node; -} Scheduler_CBS_Node; - - -/** - * List of servers. The @a Scheduler_CBS_Server is the index to the array - * of pointers to @a _Scheduler_CBS_Server_list. - */ -extern Scheduler_CBS_Server _Scheduler_CBS_Server_list[]; - -void _Scheduler_CBS_Unblock( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -); - -void _Scheduler_CBS_Release_job( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Priority_Node *priority_node, - uint64_t deadline, - Thread_queue_Context *queue_context -); - -void _Scheduler_CBS_Cancel_job( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Priority_Node *priority_node, - Thread_queue_Context *queue_context -); - -/** - * @brief _Scheduler_CBS_Initialize - * - * Initializes the CBS library. - * - * @retval status code. - */ -int _Scheduler_CBS_Initialize(void); - -/** - * @brief Attach a task to an already existing server. - * - * Attach a task to an already existing server. - * - * @retval status code. - */ -int _Scheduler_CBS_Attach_thread ( - Scheduler_CBS_Server_id server_id, - rtems_id task_id -); - -/** - * @brief Detach from the CBS Server. - * - * Detach from the CBS Server. - * - * @retval status code. - */ -int _Scheduler_CBS_Detach_thread ( - Scheduler_CBS_Server_id server_id, - rtems_id task_id -); - -/** - * @brief Cleanup resources associated to the CBS Library. - * - * Cleanup resources associated to the CBS Library. - * - * @retval status code. - */ -int _Scheduler_CBS_Cleanup (void); - -/** - * @brief Create a new server with specified parameters. - * - * Create a new server with specified parameters. - * - * @retval status code. - */ -int _Scheduler_CBS_Create_server ( - Scheduler_CBS_Parameters *params, - Scheduler_CBS_Budget_overrun budget_overrun_callback, - rtems_id *server_id -); - -/** - * @brief Detach all tasks from a server and destroy it. - * - * Detach all tasks from a server and destroy it. - * - * @param[in] server_id is the ID of the server - * - * @retval status code. - */ -int _Scheduler_CBS_Destroy_server ( - Scheduler_CBS_Server_id server_id -); - -/** - * @brief Retrieve the approved budget. - * - * Retrieve the budget that has been approved for the subsequent - * server instances. - * - * @retval status code. - */ -int _Scheduler_CBS_Get_approved_budget ( - Scheduler_CBS_Server_id server_id, - time_t *approved_budget -); - -/** - * @brief Retrieve remaining budget for the current server instance. - * - * Retrieve remaining budget for the current server instance. - * - * @retval status code. - */ -int _Scheduler_CBS_Get_remaining_budget ( - Scheduler_CBS_Server_id server_id, - time_t *remaining_budget -); - -/** - * @brief Get relative time info. - * - * Retrieve time info relative to @a server_id. The server status code is returned. - * - * @param[in] server_id is the server to get the status code from. - * @param[in] exec_time is the execution time. - * @param[in] abs_time is not apparently used. - * - * @retval status code. - */ -int _Scheduler_CBS_Get_execution_time ( - Scheduler_CBS_Server_id server_id, - time_t *exec_time, - time_t *abs_time -); - -/** - * @brief Retrieve CBS scheduling parameters. - * - * Retrieve CBS scheduling parameters. - * - * @retval status code. - */ -int _Scheduler_CBS_Get_parameters ( - Scheduler_CBS_Server_id server_id, - Scheduler_CBS_Parameters *params -); - -/** - * @brief Get a thread server id. - * - * Get a thread server id, or SCHEDULER_CBS_ERROR_NOT_FOUND if it is not - * attached to any server. - * - * @retval status code. - */ -int _Scheduler_CBS_Get_server_id ( - rtems_id task_id, - Scheduler_CBS_Server_id *server_id -); - -/** - * @brief Set parameters for CBS scheduling. - * - * Change CBS scheduling parameters. - * - * @param[in] server_id is the ID of the server. - * @param[in] parameters are the parameters to set. - * - * @retval status code. - */ -int _Scheduler_CBS_Set_parameters ( - Scheduler_CBS_Server_id server_id, - Scheduler_CBS_Parameters *parameters -); - -/** - * @brief Invoked when a limited time quantum is exceeded. - * - * This routine is invoked when a limited time quantum is exceeded. - */ -void _Scheduler_CBS_Budget_callout( - Thread_Control *the_thread -); - -/** - * @brief Initializes a CBS specific scheduler node of @a the_thread. - */ -void _Scheduler_CBS_Node_initialize( - const Scheduler_Control *scheduler, - Scheduler_Node *node, - Thread_Control *the_thread, - Priority_Control priority -); - -#ifdef __cplusplus -} -#endif - -/**@}*/ - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/schedulercbsimpl.h b/cpukit/score/include/rtems/score/schedulercbsimpl.h deleted file mode 100644 index ed75979f75..0000000000 --- a/cpukit/score/include/rtems/score/schedulercbsimpl.h +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @file - * - * @brief CBS Scheduler Implementation - * - * @ingroup ScoreSchedulerCBS - */ - -/* - * Copyright (c) 2014 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SCHEDULERCBSIMPL_H -#define _RTEMS_SCORE_SCHEDULERCBSIMPL_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @addtogroup ScoreSchedulerCBS - * - * @{ - */ - -RTEMS_INLINE_ROUTINE Scheduler_CBS_Node *_Scheduler_CBS_Thread_get_node( - Thread_Control *the_thread -) -{ - return (Scheduler_CBS_Node *) _Thread_Scheduler_get_home_node( the_thread ); -} - -RTEMS_INLINE_ROUTINE Scheduler_CBS_Node *_Scheduler_CBS_Node_downcast( - Scheduler_Node *node -) -{ - return (Scheduler_CBS_Node *) node; -} - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_SCORE_SCHEDULERCBSIMPL_H */ diff --git a/cpukit/score/include/rtems/score/scheduleredf.h b/cpukit/score/include/rtems/score/scheduleredf.h deleted file mode 100644 index 91c303ca56..0000000000 --- a/cpukit/score/include/rtems/score/scheduleredf.h +++ /dev/null @@ -1,197 +0,0 @@ -/** - * @file rtems/score/scheduleredf.h - * - * @brief Data Related to the Manipulation of Threads for the EDF Scheduler - * - * This include file contains all the constants and structures associated - * with the manipulation of threads for the EDF scheduler. - */ - -/* - * Copryight (c) 2011 Petr Benes. - * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SCHEDULEREDF_H -#define _RTEMS_SCORE_SCHEDULEREDF_H - -#include -#include -#include -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ScoreSchedulerEDF EDF Scheduler - * - * @ingroup ScoreScheduler - */ -/**@{*/ - -/* - * Actually the EDF scheduler supports a maximum priority of - * 0x7fffffffffffffff, but the user API is limited to uint32_t or int for - * thread priorities. Ignore ILP64 targets for now. - */ -#define SCHEDULER_EDF_MAXIMUM_PRIORITY INT_MAX - -/** - * Entry points for the Earliest Deadline First Scheduler. - */ -#define SCHEDULER_EDF_ENTRY_POINTS \ - { \ - _Scheduler_EDF_Initialize, /* initialize entry point */ \ - _Scheduler_EDF_Schedule, /* schedule entry point */ \ - _Scheduler_EDF_Yield, /* yield entry point */ \ - _Scheduler_EDF_Block, /* block entry point */ \ - _Scheduler_EDF_Unblock, /* unblock entry point */ \ - _Scheduler_EDF_Update_priority, /* update priority entry point */ \ - _Scheduler_EDF_Map_priority, /* map priority entry point */ \ - _Scheduler_EDF_Unmap_priority, /* unmap priority entry point */ \ - SCHEDULER_OPERATION_DEFAULT_ASK_FOR_HELP \ - _Scheduler_EDF_Node_initialize, /* node initialize entry point */ \ - _Scheduler_default_Node_destroy, /* node destroy entry point */ \ - _Scheduler_EDF_Release_job, /* new period of task */ \ - _Scheduler_EDF_Cancel_job, /* cancel period of task */ \ - _Scheduler_default_Tick, /* tick entry point */ \ - _Scheduler_default_Start_idle /* start idle entry point */ \ - SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY \ - } - -typedef struct { - /** - * @brief Basic scheduler context. - */ - Scheduler_Context Base; - - /** - * Top of the ready queue. - */ - RBTree_Control Ready; -} Scheduler_EDF_Context; - -/** - * @brief Scheduler node specialization for EDF schedulers. - */ -typedef struct { - /** - * @brief Basic scheduler node. - */ - Scheduler_Node Base; - - /** - * Rbtree node related to this thread. - */ - RBTree_Node Node; - - /** - * @brief The thread priority currently used for this scheduler instance. - */ - Priority_Control priority; -} Scheduler_EDF_Node; - -/** - * @brief Initialize EDF scheduler. - * - * This routine initializes the EDF scheduler. - * - * @param[in] scheduler The scheduler instance. - */ -void _Scheduler_EDF_Initialize( const Scheduler_Control *scheduler ); - -void _Scheduler_EDF_Block( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -); - -/** - * @brief Sets the heir thread to be the next ready thread - * in the rbtree ready queue. - * - * This kernel routine sets the heir thread to be the next ready thread - * in the rbtree ready queue. - * - * @param[in] scheduler The scheduler instance. - * @param[in] the_thread being scheduled. - */ -void _Scheduler_EDF_Schedule( - const Scheduler_Control *scheduler, - Thread_Control *the_thread -); - -/** - * @brief Initializes an EDF specific scheduler node of @a the_thread. - * - * @param[in] scheduler The scheduler instance. - * @param[in] node being initialized. - * @param[in] the_thread the thread of the node. - * @param[in] priority The thread priority. - */ -void _Scheduler_EDF_Node_initialize( - const Scheduler_Control *scheduler, - Scheduler_Node *node, - Thread_Control *the_thread, - Priority_Control priority -); - -void _Scheduler_EDF_Unblock( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -); - -void _Scheduler_EDF_Update_priority( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -); - -Priority_Control _Scheduler_EDF_Map_priority( - const Scheduler_Control *scheduler, - Priority_Control priority -); - -Priority_Control _Scheduler_EDF_Unmap_priority( - const Scheduler_Control *scheduler, - Priority_Control priority -); - -void _Scheduler_EDF_Yield( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -); - -void _Scheduler_EDF_Release_job( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Priority_Node *priority_node, - uint64_t deadline, - Thread_queue_Context *queue_context -); - -void _Scheduler_EDF_Cancel_job( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Priority_Node *priority_node, - Thread_queue_Context *queue_context -); - -#ifdef __cplusplus -} -#endif - -/**@}*/ - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/scheduleredfimpl.h b/cpukit/score/include/rtems/score/scheduleredfimpl.h deleted file mode 100644 index f6bd7d8384..0000000000 --- a/cpukit/score/include/rtems/score/scheduleredfimpl.h +++ /dev/null @@ -1,164 +0,0 @@ -/** - * @file - * - * @ingroup ScoreSchedulerEDF - * - * @brief EDF Scheduler Implementation - */ - -/* - * Copryight (c) 2011 Petr Benes. - * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SCHEDULEREDFIMPL_H -#define _RTEMS_SCORE_SCHEDULEREDFIMPL_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ScoreSchedulerEDF - * - * @{ - */ - -/** - * This is just a most significant bit of Priority_Control type. It - * distinguishes threads which are deadline driven (priority - * represented by a lower number than @a SCHEDULER_EDF_PRIO_MSB) from those - * ones who do not have any deadlines and thus are considered background - * tasks. - */ -#define SCHEDULER_EDF_PRIO_MSB 0x8000000000000000 - -RTEMS_INLINE_ROUTINE Scheduler_EDF_Context * - _Scheduler_EDF_Get_context( const Scheduler_Control *scheduler ) -{ - return (Scheduler_EDF_Context *) _Scheduler_Get_context( scheduler ); -} - -RTEMS_INLINE_ROUTINE Scheduler_EDF_Node *_Scheduler_EDF_Thread_get_node( - Thread_Control *the_thread -) -{ - return (Scheduler_EDF_Node *) _Thread_Scheduler_get_home_node( the_thread ); -} - -RTEMS_INLINE_ROUTINE Scheduler_EDF_Node * _Scheduler_EDF_Node_downcast( - Scheduler_Node *node -) -{ - return (Scheduler_EDF_Node *) node; -} - -RTEMS_INLINE_ROUTINE bool _Scheduler_EDF_Less( - const void *left, - const RBTree_Node *right -) -{ - const Priority_Control *the_left; - const Scheduler_EDF_Node *the_right; - Priority_Control prio_left; - Priority_Control prio_right; - - the_left = left; - the_right = RTEMS_CONTAINER_OF( right, Scheduler_EDF_Node, Node ); - - prio_left = *the_left; - prio_right = the_right->priority; - - return prio_left < prio_right; -} - -RTEMS_INLINE_ROUTINE bool _Scheduler_EDF_Priority_less_equal( - const void *left, - const RBTree_Node *right -) -{ - const Priority_Control *the_left; - const Scheduler_EDF_Node *the_right; - Priority_Control prio_left; - Priority_Control prio_right; - - the_left = left; - the_right = RTEMS_CONTAINER_OF( right, Scheduler_EDF_Node, Node ); - - prio_left = *the_left; - prio_right = the_right->priority; - - return prio_left <= prio_right; -} - -RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Enqueue( - Scheduler_EDF_Context *context, - Scheduler_EDF_Node *node, - Priority_Control insert_priority -) -{ - _RBTree_Insert_inline( - &context->Ready, - &node->Node, - &insert_priority, - _Scheduler_EDF_Priority_less_equal - ); -} - -RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Extract( - Scheduler_EDF_Context *context, - Scheduler_EDF_Node *node -) -{ - _RBTree_Extract( &context->Ready, &node->Node ); -} - -RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Extract_body( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -) -{ - Scheduler_EDF_Context *context; - Scheduler_EDF_Node *the_node; - - context = _Scheduler_EDF_Get_context( scheduler ); - the_node = _Scheduler_EDF_Node_downcast( node ); - - _Scheduler_EDF_Extract( context, the_node ); -} - -RTEMS_INLINE_ROUTINE void _Scheduler_EDF_Schedule_body( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - bool force_dispatch -) -{ - Scheduler_EDF_Context *context; - RBTree_Node *first; - Scheduler_EDF_Node *node; - - (void) the_thread; - - context = _Scheduler_EDF_Get_context( scheduler ); - first = _RBTree_Minimum( &context->Ready ); - node = RTEMS_CONTAINER_OF( first, Scheduler_EDF_Node, Node ); - - _Scheduler_Update_heir( node->Base.owner, force_dispatch ); -} - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/scheduleredfsmp.h b/cpukit/score/include/rtems/score/scheduleredfsmp.h deleted file mode 100644 index 018568190e..0000000000 --- a/cpukit/score/include/rtems/score/scheduleredfsmp.h +++ /dev/null @@ -1,200 +0,0 @@ -/** - * @file - * - * @brief EDF SMP Scheduler API - * - * @ingroup ScoreSchedulerSMPEDF - */ - -/* - * Copyright (c) 2017 embedded brains GmbH. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SCHEDULEREDFSMP_H -#define _RTEMS_SCORE_SCHEDULEREDFSMP_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ScoreSchedulerSMPEDF EDF Priority SMP Scheduler - * - * @ingroup ScoreSchedulerSMP - * - * @{ - */ - -typedef struct { - Scheduler_SMP_Node Base; - - /** - * @brief Generation number to ensure FIFO/LIFO order for threads of the same - * priority across different ready queues. - */ - int64_t generation; - - /** - * @brief The ready queue index depending on the processor affinity of the thread. - * - * The ready queue index zero is used for threads with a one-to-all thread - * processor affinity. Threads with a one-to-one processor affinity use the - * processor index plus one as the ready queue index. - */ - uint32_t ready_queue_index; -} Scheduler_EDF_SMP_Node; - -typedef struct { - /** - * @brief Chain node for Scheduler_SMP_Context::Affine_queues. - */ - Chain_Node Node; - - /** - * @brief The ready threads of the corresponding affinity. - */ - RBTree_Control Queue; - - /** - * @brief The scheduled thread of the corresponding processor. - */ - Scheduler_EDF_SMP_Node *scheduled; -} Scheduler_EDF_SMP_Ready_queue; - -typedef struct { - Scheduler_SMP_Context Base; - - /** - * @brief Current generation for LIFO (index 0) and FIFO (index 1) ordering. - */ - int64_t generations[ 2 ]; - - /** - * @brief Chain of ready queues with affine threads to determine the highest - * priority ready thread. - */ - Chain_Control Affine_queues; - - /** - * @brief A table with ready queues. - * - * The index zero queue is used for threads with a one-to-all processor - * affinity. Index one corresponds to processor index zero, and so on. - */ - Scheduler_EDF_SMP_Ready_queue Ready[ RTEMS_ZERO_LENGTH_ARRAY ]; -} Scheduler_EDF_SMP_Context; - -#define SCHEDULER_EDF_SMP_ENTRY_POINTS \ - { \ - _Scheduler_EDF_SMP_Initialize, \ - _Scheduler_default_Schedule, \ - _Scheduler_EDF_SMP_Yield, \ - _Scheduler_EDF_SMP_Block, \ - _Scheduler_EDF_SMP_Unblock, \ - _Scheduler_EDF_SMP_Update_priority, \ - _Scheduler_EDF_Map_priority, \ - _Scheduler_EDF_Unmap_priority, \ - _Scheduler_EDF_SMP_Ask_for_help, \ - _Scheduler_EDF_SMP_Reconsider_help_request, \ - _Scheduler_EDF_SMP_Withdraw_node, \ - _Scheduler_EDF_SMP_Add_processor, \ - _Scheduler_EDF_SMP_Remove_processor, \ - _Scheduler_EDF_SMP_Node_initialize, \ - _Scheduler_default_Node_destroy, \ - _Scheduler_EDF_Release_job, \ - _Scheduler_EDF_Cancel_job, \ - _Scheduler_default_Tick, \ - _Scheduler_EDF_SMP_Start_idle, \ - _Scheduler_EDF_SMP_Set_affinity \ - } - -void _Scheduler_EDF_SMP_Initialize( const Scheduler_Control *scheduler ); - -void _Scheduler_EDF_SMP_Node_initialize( - const Scheduler_Control *scheduler, - Scheduler_Node *node, - Thread_Control *the_thread, - Priority_Control priority -); - -void _Scheduler_EDF_SMP_Block( - const Scheduler_Control *scheduler, - Thread_Control *thread, - Scheduler_Node *node -); - -void _Scheduler_EDF_SMP_Unblock( - const Scheduler_Control *scheduler, - Thread_Control *thread, - Scheduler_Node *node -); - -void _Scheduler_EDF_SMP_Update_priority( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -); - -bool _Scheduler_EDF_SMP_Ask_for_help( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -); - -void _Scheduler_EDF_SMP_Reconsider_help_request( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -); - -void _Scheduler_EDF_SMP_Withdraw_node( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node, - Thread_Scheduler_state next_state -); - -void _Scheduler_EDF_SMP_Add_processor( - const Scheduler_Control *scheduler, - Thread_Control *idle -); - -Thread_Control *_Scheduler_EDF_SMP_Remove_processor( - const Scheduler_Control *scheduler, - struct Per_CPU_Control *cpu -); - -void _Scheduler_EDF_SMP_Yield( - const Scheduler_Control *scheduler, - Thread_Control *thread, - Scheduler_Node *node -); - -void _Scheduler_EDF_SMP_Start_idle( - const Scheduler_Control *scheduler, - Thread_Control *idle, - struct Per_CPU_Control *cpu -); - -bool _Scheduler_EDF_SMP_Set_affinity( - const Scheduler_Control *scheduler, - Thread_Control *thread, - Scheduler_Node *node, - const Processor_mask *affinity -); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* _RTEMS_SCORE_SCHEDULEREDFSMP_H */ diff --git a/cpukit/score/include/rtems/score/schedulerimpl.h b/cpukit/score/include/rtems/score/schedulerimpl.h deleted file mode 100644 index 10c12242a9..0000000000 --- a/cpukit/score/include/rtems/score/schedulerimpl.h +++ /dev/null @@ -1,1203 +0,0 @@ -/** - * @file - * - * @brief Inlined Routines Associated with the Manipulation of the Scheduler - * - * This inline file contains all of the inlined routines associated with - * the manipulation of the scheduler. - */ - -/* - * Copyright (C) 2010 Gedare Bloom. - * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). - * Copyright (c) 2014, 2017 embedded brains GmbH - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SCHEDULERIMPL_H -#define _RTEMS_SCORE_SCHEDULERIMPL_H - -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ScoreScheduler - */ -/**@{**/ - -/** - * @brief Maps a priority value to support the append indicator. - */ -#define SCHEDULER_PRIORITY_MAP( priority ) ( ( priority ) << 1 ) - -/** - * @brief Returns the plain priority value. - */ -#define SCHEDULER_PRIORITY_UNMAP( priority ) ( ( priority ) >> 1 ) - -/** - * @brief Clears the priority append indicator bit. - */ -#define SCHEDULER_PRIORITY_PURIFY( priority ) \ - ( ( priority ) & ~( (Priority_Control) SCHEDULER_PRIORITY_APPEND_FLAG ) ) - -/** - * @brief Returns the priority control with the append indicator bit set. - */ -#define SCHEDULER_PRIORITY_APPEND( priority ) \ - ( ( priority ) | SCHEDULER_PRIORITY_APPEND_FLAG ) - -/** - * @brief Returns true, if the item should be appended to its priority group, - * otherwise returns false and the item should be prepended to its priority - * group. - */ -#define SCHEDULER_PRIORITY_IS_APPEND( priority ) \ - ( ( ( priority ) & SCHEDULER_PRIORITY_APPEND_FLAG ) != 0 ) - -/** - * @brief Initializes the scheduler to the policy chosen by the user. - * - * This routine initializes the scheduler to the policy chosen by the user - * through confdefs, or to the priority scheduler with ready chains by - * default. - */ -void _Scheduler_Handler_initialization( void ); - -RTEMS_INLINE_ROUTINE Scheduler_Context *_Scheduler_Get_context( - const Scheduler_Control *scheduler -) -{ - return scheduler->context; -} - -RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Get_by_CPU( - const Per_CPU_Control *cpu -) -{ -#if defined(RTEMS_SMP) - return cpu->Scheduler.control; -#else - (void) cpu; - return &_Scheduler_Table[ 0 ]; -#endif -} - -/** - * @brief Acquires the scheduler instance inside a critical section (interrupts - * disabled). - * - * @param[in] scheduler The scheduler instance. - * @param[in] lock_context The lock context to use for - * _Scheduler_Release_critical(). - */ -RTEMS_INLINE_ROUTINE void _Scheduler_Acquire_critical( - const Scheduler_Control *scheduler, - ISR_lock_Context *lock_context -) -{ -#if defined(RTEMS_SMP) - Scheduler_Context *context; - - context = _Scheduler_Get_context( scheduler ); - _ISR_lock_Acquire( &context->Lock, lock_context ); -#else - (void) scheduler; - (void) lock_context; -#endif -} - -/** - * @brief Releases the scheduler instance inside a critical section (interrupts - * disabled). - * - * @param[in] scheduler The scheduler instance. - * @param[in] lock_context The lock context used for - * _Scheduler_Acquire_critical(). - */ -RTEMS_INLINE_ROUTINE void _Scheduler_Release_critical( - const Scheduler_Control *scheduler, - ISR_lock_Context *lock_context -) -{ -#if defined(RTEMS_SMP) - Scheduler_Context *context; - - context = _Scheduler_Get_context( scheduler ); - _ISR_lock_Release( &context->Lock, lock_context ); -#else - (void) scheduler; - (void) lock_context; -#endif -} - -#if defined(RTEMS_SMP) -void _Scheduler_Request_ask_for_help( Thread_Control *the_thread ); - -/** - * @brief Registers an ask for help request if necessary. - * - * The actual ask for help operation is carried out during - * _Thread_Do_dispatch() on a processor related to the thread. This yields a - * better separation of scheduler instances. A thread of one scheduler - * instance should not be forced to carry out too much work for threads on - * other scheduler instances. - * - * @param[in] the_thread The thread in need for help. - */ -RTEMS_INLINE_ROUTINE void _Scheduler_Ask_for_help( Thread_Control *the_thread ) -{ - _Assert( _Thread_State_is_owner( the_thread ) ); - - if ( the_thread->Scheduler.helping_nodes > 0 ) { - _Scheduler_Request_ask_for_help( the_thread ); - } -} -#endif - -/** - * The preferred method to add a new scheduler is to define the jump table - * entries and add a case to the _Scheduler_Initialize routine. - * - * Generic scheduling implementations that rely on the ready queue only can - * be found in the _Scheduler_queue_XXX functions. - */ - -/* - * Passing the Scheduler_Control* to these functions allows for multiple - * scheduler's to exist simultaneously, which could be useful on an SMP - * system. Then remote Schedulers may be accessible. How to protect such - * accesses remains an open problem. - */ - -/** - * @brief General scheduling decision. - * - * This kernel routine implements the scheduling decision logic for - * the scheduler. It does NOT dispatch. - * - * @param[in] the_thread The thread which state changed previously. - */ -RTEMS_INLINE_ROUTINE void _Scheduler_Schedule( Thread_Control *the_thread ) -{ - const Scheduler_Control *scheduler; - ISR_lock_Context lock_context; - - scheduler = _Thread_Scheduler_get_home( the_thread ); - _Scheduler_Acquire_critical( scheduler, &lock_context ); - - ( *scheduler->Operations.schedule )( scheduler, the_thread ); - - _Scheduler_Release_critical( scheduler, &lock_context ); -} - -/** - * @brief Scheduler yield with a particular thread. - * - * This routine is invoked when a thread wishes to voluntarily transfer control - * of the processor to another thread. - * - * @param[in] the_thread The yielding thread. - */ -RTEMS_INLINE_ROUTINE void _Scheduler_Yield( Thread_Control *the_thread ) -{ - const Scheduler_Control *scheduler; - ISR_lock_Context lock_context; - - scheduler = _Thread_Scheduler_get_home( the_thread ); - _Scheduler_Acquire_critical( scheduler, &lock_context ); - ( *scheduler->Operations.yield )( - scheduler, - the_thread, - _Thread_Scheduler_get_home_node( the_thread ) - ); - _Scheduler_Release_critical( scheduler, &lock_context ); -} - -/** - * @brief Blocks a thread with respect to the scheduler. - * - * This routine removes @a the_thread from the scheduling decision for - * the scheduler. The primary task is to remove the thread from the - * ready queue. It performs any necessary schedulering operations - * including the selection of a new heir thread. - * - * @param[in] the_thread The thread. - */ -RTEMS_INLINE_ROUTINE void _Scheduler_Block( Thread_Control *the_thread ) -{ -#if defined(RTEMS_SMP) - Chain_Node *node; - const Chain_Node *tail; - Scheduler_Node *scheduler_node; - const Scheduler_Control *scheduler; - ISR_lock_Context lock_context; - - node = _Chain_First( &the_thread->Scheduler.Scheduler_nodes ); - tail = _Chain_Immutable_tail( &the_thread->Scheduler.Scheduler_nodes ); - - scheduler_node = SCHEDULER_NODE_OF_THREAD_SCHEDULER_NODE( node ); - scheduler = _Scheduler_Node_get_scheduler( scheduler_node ); - - _Scheduler_Acquire_critical( scheduler, &lock_context ); - ( *scheduler->Operations.block )( - scheduler, - the_thread, - scheduler_node - ); - _Scheduler_Release_critical( scheduler, &lock_context ); - - node = _Chain_Next( node ); - - while ( node != tail ) { - scheduler_node = SCHEDULER_NODE_OF_THREAD_SCHEDULER_NODE( node ); - scheduler = _Scheduler_Node_get_scheduler( scheduler_node ); - - _Scheduler_Acquire_critical( scheduler, &lock_context ); - ( *scheduler->Operations.withdraw_node )( - scheduler, - the_thread, - scheduler_node, - THREAD_SCHEDULER_BLOCKED - ); - _Scheduler_Release_critical( scheduler, &lock_context ); - - node = _Chain_Next( node ); - } -#else - const Scheduler_Control *scheduler; - - scheduler = _Thread_Scheduler_get_home( the_thread ); - ( *scheduler->Operations.block )( - scheduler, - the_thread, - _Thread_Scheduler_get_home_node( the_thread ) - ); -#endif -} - -/** - * @brief Unblocks a thread with respect to the scheduler. - * - * This operation must fetch the latest thread priority value for this - * scheduler instance and update its internal state if necessary. - * - * @param[in] the_thread The thread. - * - * @see _Scheduler_Node_get_priority(). - */ -RTEMS_INLINE_ROUTINE void _Scheduler_Unblock( Thread_Control *the_thread ) -{ - const Scheduler_Control *scheduler; - ISR_lock_Context lock_context; - - scheduler = _Thread_Scheduler_get_home( the_thread ); - _Scheduler_Acquire_critical( scheduler, &lock_context ); - ( *scheduler->Operations.unblock )( - scheduler, - the_thread, - _Thread_Scheduler_get_home_node( the_thread ) - ); - _Scheduler_Release_critical( scheduler, &lock_context ); -} - -/** - * @brief Propagates a priority change of a thread to the scheduler. - * - * On uni-processor configurations, this operation must evaluate the thread - * state. In case the thread is not ready, then the priority update should be - * deferred to the next scheduler unblock operation. - * - * The operation must update the heir and thread dispatch necessary variables - * in case the set of scheduled threads changes. - * - * @param[in] the_thread The thread changing its priority. - * - * @see _Scheduler_Node_get_priority(). - */ -RTEMS_INLINE_ROUTINE void _Scheduler_Update_priority( Thread_Control *the_thread ) -{ -#if defined(RTEMS_SMP) - Chain_Node *node; - const Chain_Node *tail; - - _Thread_Scheduler_process_requests( the_thread ); - - node = _Chain_First( &the_thread->Scheduler.Scheduler_nodes ); - tail = _Chain_Immutable_tail( &the_thread->Scheduler.Scheduler_nodes ); - - do { - Scheduler_Node *scheduler_node; - const Scheduler_Control *scheduler; - ISR_lock_Context lock_context; - - scheduler_node = SCHEDULER_NODE_OF_THREAD_SCHEDULER_NODE( node ); - scheduler = _Scheduler_Node_get_scheduler( scheduler_node ); - - _Scheduler_Acquire_critical( scheduler, &lock_context ); - ( *scheduler->Operations.update_priority )( - scheduler, - the_thread, - scheduler_node - ); - _Scheduler_Release_critical( scheduler, &lock_context ); - - node = _Chain_Next( node ); - } while ( node != tail ); -#else - const Scheduler_Control *scheduler; - - scheduler = _Thread_Scheduler_get_home( the_thread ); - ( *scheduler->Operations.update_priority )( - scheduler, - the_thread, - _Thread_Scheduler_get_home_node( the_thread ) - ); -#endif -} - -#if defined(RTEMS_SMP) -/** - * @brief Changes the sticky level of the home scheduler node and propagates a - * priority change of a thread to the scheduler. - * - * @param[in] the_thread The thread changing its priority or sticky level. - * - * @see _Scheduler_Update_priority(). - */ -RTEMS_INLINE_ROUTINE void _Scheduler_Priority_and_sticky_update( - Thread_Control *the_thread, - int sticky_level_change -) -{ - Chain_Node *node; - const Chain_Node *tail; - Scheduler_Node *scheduler_node; - const Scheduler_Control *scheduler; - ISR_lock_Context lock_context; - - _Thread_Scheduler_process_requests( the_thread ); - - node = _Chain_First( &the_thread->Scheduler.Scheduler_nodes ); - scheduler_node = SCHEDULER_NODE_OF_THREAD_SCHEDULER_NODE( node ); - scheduler = _Scheduler_Node_get_scheduler( scheduler_node ); - - _Scheduler_Acquire_critical( scheduler, &lock_context ); - - scheduler_node->sticky_level += sticky_level_change; - _Assert( scheduler_node->sticky_level >= 0 ); - - ( *scheduler->Operations.update_priority )( - scheduler, - the_thread, - scheduler_node - ); - - _Scheduler_Release_critical( scheduler, &lock_context ); - - tail = _Chain_Immutable_tail( &the_thread->Scheduler.Scheduler_nodes ); - node = _Chain_Next( node ); - - while ( node != tail ) { - scheduler_node = SCHEDULER_NODE_OF_THREAD_SCHEDULER_NODE( node ); - scheduler = _Scheduler_Node_get_scheduler( scheduler_node ); - - _Scheduler_Acquire_critical( scheduler, &lock_context ); - ( *scheduler->Operations.update_priority )( - scheduler, - the_thread, - scheduler_node - ); - _Scheduler_Release_critical( scheduler, &lock_context ); - - node = _Chain_Next( node ); - } -} -#endif - -/** - * @brief Maps a thread priority from the user domain to the scheduler domain. - * - * Let M be the maximum scheduler priority. The mapping must be bijective in - * the closed interval [0, M], e.g. _Scheduler_Unmap_priority( scheduler, - * _Scheduler_Map_priority( scheduler, p ) ) == p for all p in [0, M]. For - * other values the mapping is undefined. - * - * @param[in] scheduler The scheduler instance. - * @param[in] priority The user domain thread priority. - * - * @return The corresponding thread priority of the scheduler domain is returned. - */ -RTEMS_INLINE_ROUTINE Priority_Control _Scheduler_Map_priority( - const Scheduler_Control *scheduler, - Priority_Control priority -) -{ - return ( *scheduler->Operations.map_priority )( scheduler, priority ); -} - -/** - * @brief Unmaps a thread priority from the scheduler domain to the user domain. - * - * @param[in] scheduler The scheduler instance. - * @param[in] priority The scheduler domain thread priority. - * - * @return The corresponding thread priority of the user domain is returned. - */ -RTEMS_INLINE_ROUTINE Priority_Control _Scheduler_Unmap_priority( - const Scheduler_Control *scheduler, - Priority_Control priority -) -{ - return ( *scheduler->Operations.unmap_priority )( scheduler, priority ); -} - -/** - * @brief Initializes a scheduler node. - * - * The scheduler node contains arbitrary data on function entry. The caller - * must ensure that _Scheduler_Node_destroy() will be called after a - * _Scheduler_Node_initialize() before the memory of the scheduler node is - * destroyed. - * - * @param[in] scheduler The scheduler instance. - * @param[in] node The scheduler node to initialize. - * @param[in] the_thread The thread of the scheduler node to initialize. - * @param[in] priority The thread priority. - */ -RTEMS_INLINE_ROUTINE void _Scheduler_Node_initialize( - const Scheduler_Control *scheduler, - Scheduler_Node *node, - Thread_Control *the_thread, - Priority_Control priority -) -{ - ( *scheduler->Operations.node_initialize )( - scheduler, - node, - the_thread, - priority - ); -} - -/** - * @brief Destroys a scheduler node. - * - * The caller must ensure that _Scheduler_Node_destroy() will be called only - * after a corresponding _Scheduler_Node_initialize(). - * - * @param[in] scheduler The scheduler instance. - * @param[in] node The scheduler node to destroy. - */ -RTEMS_INLINE_ROUTINE void _Scheduler_Node_destroy( - const Scheduler_Control *scheduler, - Scheduler_Node *node -) -{ - ( *scheduler->Operations.node_destroy )( scheduler, node ); -} - -/** - * @brief Releases a job of a thread with respect to the scheduler. - * - * @param[in] the_thread The thread. - * @param[in] priority_node The priority node of the job. - * @param[in] deadline The deadline in watchdog ticks since boot. - * @param[in] queue_context The thread queue context to provide the set of - * threads for _Thread_Priority_update(). - */ -RTEMS_INLINE_ROUTINE void _Scheduler_Release_job( - Thread_Control *the_thread, - Priority_Node *priority_node, - uint64_t deadline, - Thread_queue_Context *queue_context -) -{ - const Scheduler_Control *scheduler = _Thread_Scheduler_get_home( the_thread ); - - _Thread_queue_Context_clear_priority_updates( queue_context ); - ( *scheduler->Operations.release_job )( - scheduler, - the_thread, - priority_node, - deadline, - queue_context - ); -} - -/** - * @brief Cancels a job of a thread with respect to the scheduler. - * - * @param[in] the_thread The thread. - * @param[in] priority_node The priority node of the job. - * @param[in] queue_context The thread queue context to provide the set of - * threads for _Thread_Priority_update(). - */ -RTEMS_INLINE_ROUTINE void _Scheduler_Cancel_job( - Thread_Control *the_thread, - Priority_Node *priority_node, - Thread_queue_Context *queue_context -) -{ - const Scheduler_Control *scheduler = _Thread_Scheduler_get_home( the_thread ); - - _Thread_queue_Context_clear_priority_updates( queue_context ); - ( *scheduler->Operations.cancel_job )( - scheduler, - the_thread, - priority_node, - queue_context - ); -} - -/** - * @brief Scheduler method invoked at each clock tick. - * - * This method is invoked at each clock tick to allow the scheduler - * implementation to perform any activities required. For the - * scheduler which support standard RTEMS features, this includes - * time-slicing management. - */ -RTEMS_INLINE_ROUTINE void _Scheduler_Tick( const Per_CPU_Control *cpu ) -{ - const Scheduler_Control *scheduler = _Scheduler_Get_by_CPU( cpu ); - Thread_Control *executing = cpu->executing; - - if ( scheduler != NULL && executing != NULL ) { - ( *scheduler->Operations.tick )( scheduler, executing ); - } -} - -/** - * @brief Starts the idle thread for a particular processor. - * - * @param[in] scheduler The scheduler instance. - * @param[in,out] the_thread The idle thread for the processor. - * @param[in,out] cpu The processor for the idle thread. - * - * @see _Thread_Create_idle(). - */ -RTEMS_INLINE_ROUTINE void _Scheduler_Start_idle( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Per_CPU_Control *cpu -) -{ - ( *scheduler->Operations.start_idle )( scheduler, the_thread, cpu ); -} - -RTEMS_INLINE_ROUTINE bool _Scheduler_Has_processor_ownership( - const Scheduler_Control *scheduler, - uint32_t cpu_index -) -{ -#if defined(RTEMS_SMP) - const Per_CPU_Control *cpu; - const Scheduler_Control *scheduler_of_cpu; - - cpu = _Per_CPU_Get_by_index( cpu_index ); - scheduler_of_cpu = _Scheduler_Get_by_CPU( cpu ); - - return scheduler_of_cpu == scheduler; -#else - (void) scheduler; - (void) cpu_index; - - return true; -#endif -} - -RTEMS_INLINE_ROUTINE const Processor_mask *_Scheduler_Get_processors( - const Scheduler_Control *scheduler -) -{ -#if defined(RTEMS_SMP) - return &_Scheduler_Get_context( scheduler )->Processors; -#else - return &_Processor_mask_The_one_and_only; -#endif -} - -bool _Scheduler_Get_affinity( - Thread_Control *the_thread, - size_t cpusetsize, - cpu_set_t *cpuset -); - -RTEMS_INLINE_ROUTINE bool _Scheduler_default_Set_affinity_body( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node, - const Processor_mask *affinity -) -{ - (void) scheduler; - (void) the_thread; - (void) node; - return _Processor_mask_Is_subset( affinity, _SMP_Get_online_processors() ); -} - -bool _Scheduler_Set_affinity( - Thread_Control *the_thread, - size_t cpusetsize, - const cpu_set_t *cpuset -); - -RTEMS_INLINE_ROUTINE void _Scheduler_Generic_block( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node, - void ( *extract )( - const Scheduler_Control *, - Thread_Control *, - Scheduler_Node * - ), - void ( *schedule )( - const Scheduler_Control *, - Thread_Control *, - bool - ) -) -{ - ( *extract )( scheduler, the_thread, node ); - - /* TODO: flash critical section? */ - - if ( _Thread_Is_executing( the_thread ) || _Thread_Is_heir( the_thread ) ) { - ( *schedule )( scheduler, the_thread, true ); - } -} - -RTEMS_INLINE_ROUTINE uint32_t _Scheduler_Get_processor_count( - const Scheduler_Control *scheduler -) -{ -#if defined(RTEMS_SMP) - const Scheduler_Context *context = _Scheduler_Get_context( scheduler ); - - return _Processor_mask_Count( &context->Processors ); -#else - (void) scheduler; - - return 1; -#endif -} - -RTEMS_INLINE_ROUTINE Objects_Id _Scheduler_Build_id( uint32_t scheduler_index ) -{ - return _Objects_Build_id( - OBJECTS_FAKE_OBJECTS_API, - OBJECTS_FAKE_OBJECTS_SCHEDULERS, - _Objects_Local_node, - (uint16_t) ( scheduler_index + 1 ) - ); -} - -RTEMS_INLINE_ROUTINE uint32_t _Scheduler_Get_index_by_id( Objects_Id id ) -{ - uint32_t minimum_id = _Scheduler_Build_id( 0 ); - - return id - minimum_id; -} - -RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Get_by_id( - Objects_Id id -) -{ - uint32_t index; - - index = _Scheduler_Get_index_by_id( id ); - - if ( index >= _Scheduler_Count ) { - return NULL; - } - - return &_Scheduler_Table[ index ]; -} - -RTEMS_INLINE_ROUTINE uint32_t _Scheduler_Get_index( - const Scheduler_Control *scheduler -) -{ - return (uint32_t) (scheduler - &_Scheduler_Table[ 0 ]); -} - -#if defined(RTEMS_SMP) -/** - * @brief Gets an idle thread from the scheduler instance. - * - * @param[in] context The scheduler instance context. - * - * @retval idle An idle thread for use. This function must always return an - * idle thread. If none is available, then this is a fatal error. - */ -typedef Thread_Control *( *Scheduler_Get_idle_thread )( - Scheduler_Context *context -); - -/** - * @brief Releases an idle thread to the scheduler instance for reuse. - * - * @param[in] context The scheduler instance context. - * @param[in] idle The idle thread to release - */ -typedef void ( *Scheduler_Release_idle_thread )( - Scheduler_Context *context, - Thread_Control *idle -); - -RTEMS_INLINE_ROUTINE void _Scheduler_Thread_change_state( - Thread_Control *the_thread, - Thread_Scheduler_state new_state -) -{ - _Assert( - _ISR_lock_Is_owner( &the_thread->Scheduler.Lock ) - || the_thread->Scheduler.state == THREAD_SCHEDULER_BLOCKED - || !_System_state_Is_up( _System_state_Get() ) - ); - - the_thread->Scheduler.state = new_state; -} - -RTEMS_INLINE_ROUTINE void _Scheduler_Set_idle_thread( - Scheduler_Node *node, - Thread_Control *idle -) -{ - _Assert( _Scheduler_Node_get_idle( node ) == NULL ); - _Assert( - _Scheduler_Node_get_owner( node ) == _Scheduler_Node_get_user( node ) - ); - - _Scheduler_Node_set_user( node, idle ); - node->idle = idle; -} - -/** - * @brief Use an idle thread for this scheduler node. - * - * A thread those home scheduler node has a sticky level greater than zero may - * use an idle thread in the home scheduler instance in case it executes - * currently in another scheduler instance or in case it is in a blocking - * state. - * - * @param[in] context The scheduler instance context. - * @param[in] node The node which wants to use the idle thread. - * @param[in] cpu The processor for the idle thread. - * @param[in] get_idle_thread Function to get an idle thread. - */ -RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Use_idle_thread( - Scheduler_Context *context, - Scheduler_Node *node, - Per_CPU_Control *cpu, - Scheduler_Get_idle_thread get_idle_thread -) -{ - Thread_Control *idle = ( *get_idle_thread )( context ); - - _Scheduler_Set_idle_thread( node, idle ); - _Thread_Set_CPU( idle, cpu ); - return idle; -} - -typedef enum { - SCHEDULER_TRY_TO_SCHEDULE_DO_SCHEDULE, - SCHEDULER_TRY_TO_SCHEDULE_DO_IDLE_EXCHANGE, - SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK -} Scheduler_Try_to_schedule_action; - -/** - * @brief Try to schedule this scheduler node. - * - * @param[in] context The scheduler instance context. - * @param[in] node The node which wants to get scheduled. - * @param[in] idle A potential idle thread used by a potential victim node. - * @param[in] get_idle_thread Function to get an idle thread. - * - * @retval true This node can be scheduled. - * @retval false Otherwise. - */ -RTEMS_INLINE_ROUTINE Scheduler_Try_to_schedule_action -_Scheduler_Try_to_schedule_node( - Scheduler_Context *context, - Scheduler_Node *node, - Thread_Control *idle, - Scheduler_Get_idle_thread get_idle_thread -) -{ - ISR_lock_Context lock_context; - Scheduler_Try_to_schedule_action action; - Thread_Control *owner; - - action = SCHEDULER_TRY_TO_SCHEDULE_DO_SCHEDULE; - owner = _Scheduler_Node_get_owner( node ); - _Assert( _Scheduler_Node_get_user( node ) == owner ); - _Assert( _Scheduler_Node_get_idle( node ) == NULL ); - - _Thread_Scheduler_acquire_critical( owner, &lock_context ); - - if ( owner->Scheduler.state == THREAD_SCHEDULER_READY ) { - _Thread_Scheduler_cancel_need_for_help( owner, _Thread_Get_CPU( owner ) ); - _Scheduler_Thread_change_state( owner, THREAD_SCHEDULER_SCHEDULED ); - } else if ( - owner->Scheduler.state == THREAD_SCHEDULER_SCHEDULED - && node->sticky_level <= 1 - ) { - action = SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK; - } else if ( node->sticky_level == 0 ) { - action = SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK; - } else if ( idle != NULL ) { - action = SCHEDULER_TRY_TO_SCHEDULE_DO_IDLE_EXCHANGE; - } else { - _Scheduler_Use_idle_thread( - context, - node, - _Thread_Get_CPU( owner ), - get_idle_thread - ); - } - - _Thread_Scheduler_release_critical( owner, &lock_context ); - return action; -} - -/** - * @brief Release an idle thread using this scheduler node. - * - * @param[in] context The scheduler instance context. - * @param[in] node The node which may have an idle thread as user. - * @param[in] release_idle_thread Function to release an idle thread. - * - * @retval idle The idle thread which used this node. - * @retval NULL This node had no idle thread as an user. - */ -RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Release_idle_thread( - Scheduler_Context *context, - Scheduler_Node *node, - Scheduler_Release_idle_thread release_idle_thread -) -{ - Thread_Control *idle = _Scheduler_Node_get_idle( node ); - - if ( idle != NULL ) { - Thread_Control *owner = _Scheduler_Node_get_owner( node ); - - node->idle = NULL; - _Scheduler_Node_set_user( node, owner ); - ( *release_idle_thread )( context, idle ); - } - - return idle; -} - -RTEMS_INLINE_ROUTINE void _Scheduler_Exchange_idle_thread( - Scheduler_Node *needs_idle, - Scheduler_Node *uses_idle, - Thread_Control *idle -) -{ - uses_idle->idle = NULL; - _Scheduler_Node_set_user( - uses_idle, - _Scheduler_Node_get_owner( uses_idle ) - ); - _Scheduler_Set_idle_thread( needs_idle, idle ); -} - -/** - * @brief Block this scheduler node. - * - * @param[in] context The scheduler instance context. - * @param[in] thread The thread which wants to get blocked referencing this - * node. This is not necessarily the user of this node in case the node - * participates in the scheduler helping protocol. - * @param[in] node The node which wants to get blocked. - * @param[in] is_scheduled This node is scheduled. - * @param[in] get_idle_thread Function to get an idle thread. - * - * @retval thread_cpu The processor of the thread. Indicates to continue with - * the blocking operation. - * @retval NULL Otherwise. - */ -RTEMS_INLINE_ROUTINE Per_CPU_Control *_Scheduler_Block_node( - Scheduler_Context *context, - Thread_Control *thread, - Scheduler_Node *node, - bool is_scheduled, - Scheduler_Get_idle_thread get_idle_thread -) -{ - int sticky_level; - ISR_lock_Context lock_context; - Per_CPU_Control *thread_cpu; - - sticky_level = node->sticky_level; - --sticky_level; - node->sticky_level = sticky_level; - _Assert( sticky_level >= 0 ); - - _Thread_Scheduler_acquire_critical( thread, &lock_context ); - thread_cpu = _Thread_Get_CPU( thread ); - _Thread_Scheduler_cancel_need_for_help( thread, thread_cpu ); - _Scheduler_Thread_change_state( thread, THREAD_SCHEDULER_BLOCKED ); - _Thread_Scheduler_release_critical( thread, &lock_context ); - - if ( sticky_level > 0 ) { - if ( is_scheduled && _Scheduler_Node_get_idle( node ) == NULL ) { - Thread_Control *idle; - - idle = _Scheduler_Use_idle_thread( - context, - node, - thread_cpu, - get_idle_thread - ); - _Thread_Dispatch_update_heir( _Per_CPU_Get(), thread_cpu, idle ); - } - - return NULL; - } - - _Assert( thread == _Scheduler_Node_get_user( node ) ); - return thread_cpu; -} - -RTEMS_INLINE_ROUTINE void _Scheduler_Discard_idle_thread( - Scheduler_Context *context, - Thread_Control *the_thread, - Scheduler_Node *node, - Scheduler_Release_idle_thread release_idle_thread -) -{ - Thread_Control *idle; - Thread_Control *owner; - Per_CPU_Control *cpu; - - idle = _Scheduler_Node_get_idle( node ); - owner = _Scheduler_Node_get_owner( node ); - - node->idle = NULL; - _Assert( _Scheduler_Node_get_user( node ) == idle ); - _Scheduler_Node_set_user( node, owner ); - ( *release_idle_thread )( context, idle ); - - cpu = _Thread_Get_CPU( idle ); - _Thread_Set_CPU( the_thread, cpu ); - _Thread_Dispatch_update_heir( _Per_CPU_Get(), cpu, the_thread ); -} - -/** - * @brief Unblock this scheduler node. - * - * @param[in] context The scheduler instance context. - * @param[in] the_thread The thread which wants to get unblocked. - * @param[in] node The node which wants to get unblocked. - * @param[in] is_scheduled This node is scheduled. - * @param[in] release_idle_thread Function to release an idle thread. - * - * @retval true Continue with the unblocking operation. - * @retval false Otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Scheduler_Unblock_node( - Scheduler_Context *context, - Thread_Control *the_thread, - Scheduler_Node *node, - bool is_scheduled, - Scheduler_Release_idle_thread release_idle_thread -) -{ - bool unblock; - - ++node->sticky_level; - _Assert( node->sticky_level > 0 ); - - if ( is_scheduled ) { - _Scheduler_Discard_idle_thread( - context, - the_thread, - node, - release_idle_thread - ); - _Scheduler_Thread_change_state( the_thread, THREAD_SCHEDULER_SCHEDULED ); - unblock = false; - } else { - _Scheduler_Thread_change_state( the_thread, THREAD_SCHEDULER_READY ); - unblock = true; - } - - return unblock; -} -#endif - -RTEMS_INLINE_ROUTINE void _Scheduler_Update_heir( - Thread_Control *new_heir, - bool force_dispatch -) -{ - Thread_Control *heir = _Thread_Heir; - - if ( heir != new_heir && ( heir->is_preemptible || force_dispatch ) ) { -#if defined(RTEMS_SMP) - /* - * We need this state only for _Thread_Get_CPU_time_used(). Cannot use - * _Scheduler_Thread_change_state() since THREAD_SCHEDULER_BLOCKED to - * THREAD_SCHEDULER_BLOCKED state changes are illegal for the real SMP - * schedulers. - */ - heir->Scheduler.state = THREAD_SCHEDULER_BLOCKED; - new_heir->Scheduler.state = THREAD_SCHEDULER_SCHEDULED; -#endif - _Thread_Update_CPU_time_used( heir, _Thread_Get_CPU( heir ) ); - _Thread_Heir = new_heir; - _Thread_Dispatch_necessary = true; - } -} - -RTEMS_INLINE_ROUTINE Status_Control _Scheduler_Set( - const Scheduler_Control *new_scheduler, - Thread_Control *the_thread, - Priority_Control priority -) -{ - Scheduler_Node *new_scheduler_node; - Scheduler_Node *old_scheduler_node; -#if defined(RTEMS_SMP) - ISR_lock_Context lock_context; - const Scheduler_Control *old_scheduler; - -#endif - - if ( the_thread->Wait.queue != NULL ) { - return STATUS_RESOURCE_IN_USE; - } - - old_scheduler_node = _Thread_Scheduler_get_home_node( the_thread ); - _Priority_Plain_extract( - &old_scheduler_node->Wait.Priority, - &the_thread->Real_priority - ); - - if ( !_Priority_Is_empty( &old_scheduler_node->Wait.Priority ) ) { - _Priority_Plain_insert( - &old_scheduler_node->Wait.Priority, - &the_thread->Real_priority, - the_thread->Real_priority.priority - ); - return STATUS_RESOURCE_IN_USE; - } - -#if defined(RTEMS_SMP) - if ( !_Chain_Has_only_one_node( &the_thread->Scheduler.Wait_nodes ) ) { - _Priority_Plain_insert( - &old_scheduler_node->Wait.Priority, - &the_thread->Real_priority, - the_thread->Real_priority.priority - ); - return STATUS_RESOURCE_IN_USE; - } - - old_scheduler = _Thread_Scheduler_get_home( the_thread ); - new_scheduler_node = _Thread_Scheduler_get_node_by_index( - the_thread, - _Scheduler_Get_index( new_scheduler ) - ); - - _Scheduler_Acquire_critical( new_scheduler, &lock_context ); - - if ( - _Scheduler_Get_processor_count( new_scheduler ) == 0 - || !( *new_scheduler->Operations.set_affinity )( - new_scheduler, - the_thread, - new_scheduler_node, - &the_thread->Scheduler.Affinity - ) - ) { - _Scheduler_Release_critical( new_scheduler, &lock_context ); - _Priority_Plain_insert( - &old_scheduler_node->Wait.Priority, - &the_thread->Real_priority, - the_thread->Real_priority.priority - ); - return STATUS_UNSATISFIED; - } - - the_thread->Scheduler.home = new_scheduler; - - _Scheduler_Release_critical( new_scheduler, &lock_context ); - - _Thread_Scheduler_process_requests( the_thread ); -#else - new_scheduler_node = old_scheduler_node; -#endif - - the_thread->Start.initial_priority = priority; - _Priority_Node_set_priority( &the_thread->Real_priority, priority ); - _Priority_Initialize_one( - &new_scheduler_node->Wait.Priority, - &the_thread->Real_priority - ); - -#if defined(RTEMS_SMP) - if ( old_scheduler != new_scheduler ) { - States_Control current_state; - - current_state = the_thread->current_state; - - if ( _States_Is_ready( current_state ) ) { - _Scheduler_Block( the_thread ); - } - - _Assert( old_scheduler_node->sticky_level == 0 ); - _Assert( new_scheduler_node->sticky_level == 0 ); - - _Chain_Extract_unprotected( &old_scheduler_node->Thread.Wait_node ); - _Assert( _Chain_Is_empty( &the_thread->Scheduler.Wait_nodes ) ); - _Chain_Initialize_one( - &the_thread->Scheduler.Wait_nodes, - &new_scheduler_node->Thread.Wait_node - ); - _Chain_Extract_unprotected( - &old_scheduler_node->Thread.Scheduler_node.Chain - ); - _Assert( _Chain_Is_empty( &the_thread->Scheduler.Scheduler_nodes ) ); - _Chain_Initialize_one( - &the_thread->Scheduler.Scheduler_nodes, - &new_scheduler_node->Thread.Scheduler_node.Chain - ); - - _Scheduler_Node_set_priority( new_scheduler_node, priority, false ); - - if ( _States_Is_ready( current_state ) ) { - _Scheduler_Unblock( the_thread ); - } - - return STATUS_SUCCESSFUL; - } -#endif - - _Scheduler_Node_set_priority( new_scheduler_node, priority, false ); - _Scheduler_Update_priority( the_thread ); - return STATUS_SUCCESSFUL; -} - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/schedulernode.h b/cpukit/score/include/rtems/score/schedulernode.h deleted file mode 100644 index d62e983853..0000000000 --- a/cpukit/score/include/rtems/score/schedulernode.h +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (c) 2014, 2016 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SCHEDULERNODE_H -#define _RTEMS_SCORE_SCHEDULERNODE_H - -#include -#include -#include -#include - -struct _Thread_Control; - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#if defined(RTEMS_SMP) -/** - * @brief The scheduler node requests. - */ -typedef enum { - /** - * @brief The scheduler node is not on the list of pending requests. - */ - SCHEDULER_NODE_REQUEST_NOT_PENDING, - - /** - * @brief There is a pending scheduler node request to add this scheduler - * node to the Thread_Control::Scheduler::Scheduler_nodes chain. - */ - SCHEDULER_NODE_REQUEST_ADD, - - /** - * @brief There is a pending scheduler node request to remove this scheduler - * node from the Thread_Control::Scheduler::Scheduler_nodes chain. - */ - SCHEDULER_NODE_REQUEST_REMOVE, - - /** - * @brief The scheduler node is on the list of pending requests, but nothing - * should change. - */ - SCHEDULER_NODE_REQUEST_NOTHING, - -} Scheduler_Node_request; -#endif - -typedef struct Scheduler_Node Scheduler_Node; - -/** - * @brief Scheduler node for per-thread data. - */ -struct Scheduler_Node { -#if defined(RTEMS_SMP) - /** - * @brief Chain node for usage in various scheduler data structures. - * - * Strictly, this is the wrong place for this field since the data structures - * to manage scheduler nodes belong to the particular scheduler - * implementation. Currently, all SMP scheduler implementations use chains - * or red-black trees. The node is here to simplify things, just like the - * object node in the thread control block. - */ - union { - Chain_Node Chain; - RBTree_Node RBTree; - } Node; - - /** - * @brief The sticky level determines if this scheduler node should use an - * idle thread in case this node is scheduled and the owner thread is - * blocked. - */ - int sticky_level; - - /** - * @brief The thread using this node. - * - * This is either the owner or an idle thread. - */ - struct _Thread_Control *user; - - /** - * @brief The idle thread claimed by this node in case the sticky level is - * greater than zero and the thread is block or is scheduled on another - * scheduler instance. - * - * This is necessary to ensure the priority ceiling protocols work across - * scheduler boundaries. - */ - struct _Thread_Control *idle; -#endif - - /** - * @brief The thread owning this node. - */ - struct _Thread_Control *owner; - -#if defined(RTEMS_SMP) - /** - * @brief Block to register and manage this scheduler node in the thread - * control block of the owner of this scheduler node. - */ - struct { - /** - * @brief Node to add this scheduler node to - * Thread_Control::Scheduler::Wait_nodes. - */ - Chain_Node Wait_node; - - /** - * @brief Node to add this scheduler node to - * Thread_Control::Scheduler::Scheduler_nodes or a temporary remove list. - */ - union { - /** - * @brief The node for Thread_Control::Scheduler::Scheduler_nodes. - */ - Chain_Node Chain; - - /** - * @brief The next pointer for a temporary remove list. - * - * @see _Thread_Scheduler_process_requests(). - */ - Scheduler_Node *next; - } Scheduler_node; - - /** - * @brief Link to the next scheduler node in the - * Thread_Control::Scheduler::requests list. - */ - Scheduler_Node *next_request; - - /** - * @brief The current scheduler node request. - */ - Scheduler_Node_request request; - } Thread; -#endif - - /** - * @brief Thread wait support block. - */ - struct { - Priority_Aggregation Priority; - } Wait; - - /** - * @brief The thread priority information used by the scheduler. - * - * The thread priority is manifest in two independent areas. One area is the - * user visible thread priority along with a potential thread queue. The - * other is the scheduler. During a thread priority change, the user visible - * thread priority and the thread queue are first updated and the thread - * priority value here is changed. Once this is done the scheduler is - * notified via the update priority operation, so that it can update its - * internal state and honour a new thread priority value. - */ - struct { - /** - * @brief The thread priority value of this scheduler node. - * - * The producer of this value is _Thread_Change_priority(). The consumer - * is the scheduler via the unblock and update priority operations. - * - * This priority control consists of two parts. One part is the plain - * priority value (most-significant 63 bits). The other part is the - * least-significant bit which indicates if the thread should be appended - * (bit set) or prepended (bit cleared) to its priority group, see - * SCHEDULER_PRIORITY_APPEND(). - */ - Priority_Control value; - -#if defined(RTEMS_SMP) - /** - * @brief Sequence lock to synchronize priority value updates. - */ - SMP_sequence_lock_Control Lock; -#endif - } Priority; -}; - -#if defined(RTEMS_SMP) -/** - * @brief The size of a scheduler node. - * - * This value is provided via . - */ -extern const size_t _Scheduler_Node_size; -#endif - -#if defined(RTEMS_SMP) -#define SCHEDULER_NODE_OF_THREAD_WAIT_NODE( node ) \ - RTEMS_CONTAINER_OF( node, Scheduler_Node, Thread.Wait_node ) - -#define SCHEDULER_NODE_OF_THREAD_SCHEDULER_NODE( node ) \ - RTEMS_CONTAINER_OF( node, Scheduler_Node, Thread.Scheduler_node.Chain ) -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_SCORE_SCHEDULERNODE_H */ diff --git a/cpukit/score/include/rtems/score/schedulernodeimpl.h b/cpukit/score/include/rtems/score/schedulernodeimpl.h deleted file mode 100644 index 8997b3f218..0000000000 --- a/cpukit/score/include/rtems/score/schedulernodeimpl.h +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) 2014, 2017 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SCHEDULERNODEIMPL_H -#define _RTEMS_SCORE_SCHEDULERNODEIMPL_H - -#include -#include - -struct _Scheduler_Control; - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define SCHEDULER_NODE_OF_WAIT_PRIORITY_NODE( node ) \ - RTEMS_CONTAINER_OF( node, Scheduler_Node, Wait.Priority.Node.Node.Chain ) - -#define SCHEDULER_NODE_OF_WAIT_PRIORITY( node ) \ - RTEMS_CONTAINER_OF( node, Scheduler_Node, Wait.Priority ) - -/** - * @brief Priority append indicator for the priority control used for the - * scheduler node priority. - */ -#define SCHEDULER_PRIORITY_APPEND_FLAG 1 - -RTEMS_INLINE_ROUTINE void _Scheduler_Node_do_initialize( - const struct _Scheduler_Control *scheduler, - Scheduler_Node *node, - Thread_Control *the_thread, - Priority_Control priority -) -{ - node->owner = the_thread; - - node->Priority.value = priority; - -#if defined(RTEMS_SMP) - _Chain_Initialize_node( &node->Thread.Wait_node ); - node->Wait.Priority.scheduler = scheduler; - node->user = the_thread; - node->idle = NULL; - _SMP_sequence_lock_Initialize( &node->Priority.Lock ); -#else - (void) scheduler; - (void) the_thread; -#endif -} - -RTEMS_INLINE_ROUTINE const Scheduler_Control *_Scheduler_Node_get_scheduler( - const Scheduler_Node *node -) -{ - return _Priority_Get_scheduler( &node->Wait.Priority ); -} - -RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_owner( - const Scheduler_Node *node -) -{ - return node->owner; -} - -RTEMS_INLINE_ROUTINE Priority_Control _Scheduler_Node_get_priority( - Scheduler_Node *node -) -{ - Priority_Control priority; - -#if defined(RTEMS_SMP) - unsigned int seq; - - do { - seq = _SMP_sequence_lock_Read_begin( &node->Priority.Lock ); -#endif - - priority = node->Priority.value; - -#if defined(RTEMS_SMP) - } while ( _SMP_sequence_lock_Read_retry( &node->Priority.Lock, seq ) ); -#endif - - return priority; -} - -RTEMS_INLINE_ROUTINE void _Scheduler_Node_set_priority( - Scheduler_Node *node, - Priority_Control new_priority, - bool prepend_it -) -{ -#if defined(RTEMS_SMP) - unsigned int seq; - - seq = _SMP_sequence_lock_Write_begin( &node->Priority.Lock ); -#endif - - new_priority |= ( prepend_it ? 0 : SCHEDULER_PRIORITY_APPEND_FLAG ); - node->Priority.value = new_priority; - -#if defined(RTEMS_SMP) - _SMP_sequence_lock_Write_end( &node->Priority.Lock, seq ); -#endif -} - -#if defined(RTEMS_SMP) -RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_user( - const Scheduler_Node *node -) -{ - return node->user; -} - -RTEMS_INLINE_ROUTINE void _Scheduler_Node_set_user( - Scheduler_Node *node, - Thread_Control *user -) -{ - node->user = user; -} - -RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_idle( - const Scheduler_Node *node -) -{ - return node->idle; -} -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_SCORE_SCHEDULERNODEIMPL_H */ diff --git a/cpukit/score/include/rtems/score/schedulerpriority.h b/cpukit/score/include/rtems/score/schedulerpriority.h deleted file mode 100644 index f5ae66102d..0000000000 --- a/cpukit/score/include/rtems/score/schedulerpriority.h +++ /dev/null @@ -1,163 +0,0 @@ -/** - * @file rtems/score/schedulerpriority.h - * - * @brief Thread Manipulation with the Priority-Based Scheduler - * - * This include file contains all the constants and structures associated - * with the manipulation of threads for the priority-based scheduler. - */ - -/* - * Copryight (c) 2010 Gedare Bloom. - * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SCHEDULERPRIORITY_H -#define _RTEMS_SCORE_SCHEDULERPRIORITY_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ScoreSchedulerDPS Deterministic Priority Scheduler - * - * @ingroup ScoreScheduler - */ -/**@{*/ - -/** - * Entry points for the Deterministic Priority Based Scheduler. - */ -#define SCHEDULER_PRIORITY_ENTRY_POINTS \ - { \ - _Scheduler_priority_Initialize, /* initialize entry point */ \ - _Scheduler_priority_Schedule, /* schedule entry point */ \ - _Scheduler_priority_Yield, /* yield entry point */ \ - _Scheduler_priority_Block, /* block entry point */ \ - _Scheduler_priority_Unblock, /* unblock entry point */ \ - _Scheduler_priority_Update_priority, /* update priority entry point */ \ - _Scheduler_default_Map_priority, /* map priority entry point */ \ - _Scheduler_default_Unmap_priority, /* unmap priority entry point */ \ - SCHEDULER_OPERATION_DEFAULT_ASK_FOR_HELP \ - _Scheduler_priority_Node_initialize, /* node initialize entry point */ \ - _Scheduler_default_Node_destroy, /* node destroy entry point */ \ - _Scheduler_default_Release_job, /* new period of task */ \ - _Scheduler_default_Cancel_job, /* cancel period of task */ \ - _Scheduler_default_Tick, /* tick entry point */ \ - _Scheduler_default_Start_idle /* start idle entry point */ \ - SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY \ - } - -typedef struct { - /** - * @brief Basic scheduler context. - */ - Scheduler_Context Base; - - /** - * @brief Bit map to indicate non-empty ready queues. - */ - Priority_bit_map_Control Bit_map; - - /** - * @brief One ready queue per priority level. - */ - Chain_Control Ready[ 0 ]; -} Scheduler_priority_Context; - -/** - * @brief Data for ready queue operations. - */ -typedef struct { - /** - * @brief The thread priority currently used by the scheduler. - */ - unsigned int current_priority; - - /** This field points to the Ready FIFO for this thread's priority. */ - Chain_Control *ready_chain; - - /** This field contains precalculated priority map indices. */ - Priority_bit_map_Information Priority_map; -} Scheduler_priority_Ready_queue; - -/** - * @brief Scheduler node specialization for Deterministic Priority schedulers. - */ -typedef struct { - /** - * @brief Basic scheduler node. - */ - Scheduler_Node Base; - - /** - * @brief The associated ready queue of this node. - */ - Scheduler_priority_Ready_queue Ready_queue; -} Scheduler_priority_Node; - -/** - * @brief Initializes the priority scheduler. - * This routine initializes the priority scheduler. - */ -void _Scheduler_priority_Initialize( const Scheduler_Control *scheduler ); - -void _Scheduler_priority_Block( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -); - -/** - * @brief Sets the heir thread to be the next ready thread. - * - * This kernel routine sets the heir thread to be the next ready thread - * by invoking the_scheduler->ready_queue->operations->first(). - */ -void _Scheduler_priority_Schedule( - const Scheduler_Control *scheduler, - Thread_Control *the_thread -); - -void _Scheduler_priority_Unblock( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -); - -void _Scheduler_priority_Update_priority( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *base_node -); - -void _Scheduler_priority_Node_initialize( - const Scheduler_Control *scheduler, - Scheduler_Node *node, - Thread_Control *the_thread, - Priority_Control priority -); - -void _Scheduler_priority_Yield( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -); - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h b/cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h deleted file mode 100644 index d988d5752a..0000000000 --- a/cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h +++ /dev/null @@ -1,181 +0,0 @@ -/** - * @file - * - * @ingroup ScoreSchedulerPriorityAffinitySMP - * - * @brief Deterministic Priority Affinity SMP Scheduler API - */ - -/* - * COPYRIGHT (c) 2014. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SCHEDULERPRIORITYAFFINITYSMP_H -#define _RTEMS_SCORE_SCHEDULERPRIORITYAFFINITYSMP_H - -#include -#include -#include -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup ScoreSchedulerPriorityAffinitySMP Deterministic Priority Affinity SMP Scheduler - * - * @ingroup ScoreSchedulerPrioritySMP - * - * This is an extension of the Deterministic Priority SMP Scheduler. which - * is an implementation of the global fixed priority scheduler (G-FP). - * It adds thread to core affinity support. - * - * @note This is the first iteration of this scheduler. It currently tracks - * the requested affinity to exercise the Scheduler Framework but it - * does not honor that affinity in assigning threads to cores. This - * will be added in a subsequent revision. - * @{ - */ - -/** - * @brief Entry points for the Deterministic Priority Affinity SMP Scheduler. - */ -#define SCHEDULER_PRIORITY_AFFINITY_SMP_ENTRY_POINTS \ - { \ - _Scheduler_priority_SMP_Initialize, \ - _Scheduler_default_Schedule, \ - _Scheduler_priority_SMP_Yield, \ - _Scheduler_priority_affinity_SMP_Block, \ - _Scheduler_priority_affinity_SMP_Unblock, \ - _Scheduler_priority_affinity_SMP_Update_priority, \ - _Scheduler_default_Map_priority, \ - _Scheduler_default_Unmap_priority, \ - _Scheduler_priority_affinity_SMP_Ask_for_help, \ - _Scheduler_priority_affinity_SMP_Reconsider_help_request, \ - _Scheduler_priority_affinity_SMP_Withdraw_node, \ - _Scheduler_priority_affinity_SMP_Add_processor, \ - _Scheduler_priority_affinity_SMP_Remove_processor, \ - _Scheduler_priority_affinity_SMP_Node_initialize, \ - _Scheduler_default_Node_destroy, \ - _Scheduler_default_Release_job, \ - _Scheduler_default_Cancel_job, \ - _Scheduler_default_Tick, \ - _Scheduler_SMP_Start_idle, \ - _Scheduler_priority_affinity_SMP_Set_affinity \ - } - -/** - * @brief Initializes per thread scheduler information - * - * This routine allocates @a thread->scheduler. - * - * @param[in] scheduler points to the scheduler specific information. - * @param[in] node is the node the scheduler is allocating - * management memory for. - * @param[in] the_thread the thread of the node. - * @param[in] priority is the thread priority. - */ -void _Scheduler_priority_affinity_SMP_Node_initialize( - const Scheduler_Control *scheduler, - Scheduler_Node *node, - Thread_Control *the_thread, - Priority_Control priority -); - -void _Scheduler_priority_affinity_SMP_Block( - const Scheduler_Control *scheduler, - Thread_Control *thread, - Scheduler_Node *node -); - -void _Scheduler_priority_affinity_SMP_Unblock( - const Scheduler_Control *scheduler, - Thread_Control *thread, - Scheduler_Node *node -); - -void _Scheduler_priority_affinity_SMP_Update_priority( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -); - -bool _Scheduler_priority_affinity_SMP_Ask_for_help( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -); - -void _Scheduler_priority_affinity_SMP_Reconsider_help_request( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -); - -void _Scheduler_priority_affinity_SMP_Withdraw_node( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node, - Thread_Scheduler_state next_state -); - -void _Scheduler_priority_affinity_SMP_Add_processor( - const Scheduler_Control *scheduler, - Thread_Control *idle -); - -Thread_Control *_Scheduler_priority_affinity_SMP_Remove_processor( - const Scheduler_Control *scheduler, - struct Per_CPU_Control *cpu -); - -/** - * @brief Set affinity for the priority affinity SMP scheduler. - * - * @param[in] scheduler The scheduler of the thread. - * @param[in] thread The associated thread. - * @param[in] affinity The new affinity set. - * - * @retval true if successful - * @retval false if unsuccessful - */ -bool _Scheduler_priority_affinity_SMP_Set_affinity( - const Scheduler_Control *scheduler, - Thread_Control *thread, - Scheduler_Node *node, - const Processor_mask *affinity -); - -/** - * @brief Scheduler node specialization for Deterministic Priority Affinity SMP - * schedulers. - * - * This is a per thread structure. - */ -typedef struct { - /** - * @brief SMP priority scheduler node. - */ - Scheduler_priority_SMP_Node Base; - - /** - * @brief The thread processor affinity set. - */ - Processor_mask Affinity; -} Scheduler_priority_affinity_SMP_Node; - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_SCORE_SCHEDULERPRIORITYAFFINITYSMP_H */ diff --git a/cpukit/score/include/rtems/score/schedulerpriorityimpl.h b/cpukit/score/include/rtems/score/schedulerpriorityimpl.h deleted file mode 100644 index 354065fac4..0000000000 --- a/cpukit/score/include/rtems/score/schedulerpriorityimpl.h +++ /dev/null @@ -1,241 +0,0 @@ -/** - * @file - * - * @brief Inlined Routines Associated with the Manipulation of the - * Priority-Based Scheduling Structures - * - * This inline file contains all of the inlined routines associated with - * the manipulation of the priority-based scheduling structures. - */ - -/* - * Copyright (C) 2010 Gedare Bloom. - * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SCHEDULERPRIORITYIMPL_H -#define _RTEMS_SCORE_SCHEDULERPRIORITYIMPL_H - -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ScoreSchedulerDPS - */ -/**@{**/ - -RTEMS_INLINE_ROUTINE Scheduler_priority_Context * - _Scheduler_priority_Get_context( const Scheduler_Control *scheduler ) -{ - return (Scheduler_priority_Context *) _Scheduler_Get_context( scheduler ); -} - -RTEMS_INLINE_ROUTINE Scheduler_priority_Node *_Scheduler_priority_Thread_get_node( - Thread_Control *the_thread -) -{ - return (Scheduler_priority_Node *) _Thread_Scheduler_get_home_node( the_thread ); -} - -RTEMS_INLINE_ROUTINE Scheduler_priority_Node *_Scheduler_priority_Node_downcast( - Scheduler_Node *node -) -{ - return (Scheduler_priority_Node *) node; -} - -/** - * @brief Ready queue initialization. - * - * This routine initializes @a ready_queues for priority-based scheduling. - */ -RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_initialize( - Chain_Control *ready_queues, - Priority_Control maximum_priority -) -{ - size_t index; - - for ( index = 0 ; index <= (size_t) maximum_priority ; ++index ) { - _Chain_Initialize_empty( &ready_queues[ index ] ); - } -} - -/** - * @brief Enqueues a node on the specified ready queue. - * - * The node is placed as the last element of its priority group. - * - * @param[in] node The node to enqueue. - * @param[in] ready_queue The ready queue. - * @param[in] bit_map The priority bit map of the scheduler instance. - */ -RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_enqueue( - Chain_Node *node, - Scheduler_priority_Ready_queue *ready_queue, - Priority_bit_map_Control *bit_map -) -{ - Chain_Control *ready_chain = ready_queue->ready_chain; - - _Chain_Append_unprotected( ready_chain, node ); - _Priority_bit_map_Add( bit_map, &ready_queue->Priority_map ); -} - -/** - * @brief Enqueues a node on the specified ready queue as first. - * - * The node is placed as the first element of its priority group. - * - * @param[in] node The node to enqueue as first. - * @param[in] ready_queue The ready queue. - * @param[in] bit_map The priority bit map of the scheduler instance. - */ -RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_enqueue_first( - Chain_Node *node, - Scheduler_priority_Ready_queue *ready_queue, - Priority_bit_map_Control *bit_map -) -{ - Chain_Control *ready_chain = ready_queue->ready_chain; - - _Chain_Prepend_unprotected( ready_chain, node ); - _Priority_bit_map_Add( bit_map, &ready_queue->Priority_map ); -} - -/** - * @brief Extracts a node from the specified ready queue. - * - * @param[in] node The node to extract. - * @param[in] ready_queue The ready queue. - * @param[in] bit_map The priority bit map of the scheduler instance. - */ -RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_extract( - Chain_Node *node, - Scheduler_priority_Ready_queue *ready_queue, - Priority_bit_map_Control *bit_map -) -{ - Chain_Control *ready_chain = ready_queue->ready_chain; - - if ( _Chain_Has_only_one_node( ready_chain ) ) { - _Chain_Initialize_empty( ready_chain ); - _Chain_Initialize_node( node ); - _Priority_bit_map_Remove( bit_map, &ready_queue->Priority_map ); - } else { - _Chain_Extract_unprotected( node ); - } -} - -RTEMS_INLINE_ROUTINE void _Scheduler_priority_Extract_body( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -) -{ - Scheduler_priority_Context *context; - Scheduler_priority_Node *the_node; - - context = _Scheduler_priority_Get_context( scheduler ); - the_node = _Scheduler_priority_Node_downcast( node ); - - _Scheduler_priority_Ready_queue_extract( - &the_thread->Object.Node, - &the_node->Ready_queue, - &context->Bit_map - ); -} - -/** - * @brief Return a pointer to the first node. - * - * This routines returns a pointer to the first node on @a ready_queues. - * - * @param[in] bit_map The priority bit map of the scheduler instance. - * @param[in] ready_queues The ready queues of the scheduler instance. - * - * @return This method returns the first node. - */ -RTEMS_INLINE_ROUTINE Chain_Node *_Scheduler_priority_Ready_queue_first( - Priority_bit_map_Control *bit_map, - Chain_Control *ready_queues -) -{ - Priority_Control index = _Priority_bit_map_Get_highest( bit_map ); - Chain_Node *first = _Chain_First( &ready_queues[ index ] ); - - _Assert( first != _Chain_Tail( &ready_queues[ index ] ) ); - - return first; -} - -/** - * @brief Scheduling decision logic. - * - * This kernel routine implements scheduling decision logic - * for priority-based scheduling. - */ -RTEMS_INLINE_ROUTINE void _Scheduler_priority_Schedule_body( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - bool force_dispatch -) -{ - Scheduler_priority_Context *context = - _Scheduler_priority_Get_context( scheduler ); - Thread_Control *heir = (Thread_Control *) - _Scheduler_priority_Ready_queue_first( - &context->Bit_map, - &context->Ready[ 0 ] - ); - - ( void ) the_thread; - - _Scheduler_Update_heir( heir, force_dispatch ); -} - -/** - * @brief Updates the specified ready queue data according to the new priority - * value. - * - * @param[in] ready_queue The ready queue. - * @param[in] new_priority The new priority. - * @param[in] bit_map The priority bit map of the scheduler instance. - * @param[in] ready_queues The ready queues of the scheduler instance. - */ -RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_update( - Scheduler_priority_Ready_queue *ready_queue, - unsigned int new_priority, - Priority_bit_map_Control *bit_map, - Chain_Control *ready_queues -) -{ - ready_queue->current_priority = new_priority; - ready_queue->ready_chain = &ready_queues[ new_priority ]; - - _Priority_bit_map_Initialize_information( - bit_map, - &ready_queue->Priority_map, - new_priority - ); -} - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/schedulerprioritysmp.h b/cpukit/score/include/rtems/score/schedulerprioritysmp.h deleted file mode 100644 index 6671da5b7a..0000000000 --- a/cpukit/score/include/rtems/score/schedulerprioritysmp.h +++ /dev/null @@ -1,171 +0,0 @@ -/** - * @file - * - * @ingroup ScoreSchedulerPrioritySMP - * - * @brief Deterministic Priority SMP Scheduler API - */ - -/* - * Copyright (c) 2013, 2016 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SCHEDULERPRIORITYSMP_H -#define _RTEMS_SCORE_SCHEDULERPRIORITYSMP_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup ScoreSchedulerPrioritySMP Deterministic Priority SMP Scheduler - * - * @ingroup ScoreSchedulerSMP - * - * This is an implementation of the global fixed priority scheduler (G-FP). It - * uses one ready chain per priority to ensure constant time insert operations. - * The scheduled chain uses linear insert operations and has at most processor - * count entries. Since the processor and priority count are constants all - * scheduler operations complete in a bounded execution time. - * - * The thread preempt mode will be ignored. - * - * @{ - */ - -/** - * @brief Scheduler context specialization for Deterministic Priority SMP - * schedulers. - */ -typedef struct { - Scheduler_SMP_Context Base; - Priority_bit_map_Control Bit_map; - Chain_Control Ready[ RTEMS_ZERO_LENGTH_ARRAY ]; -} Scheduler_priority_SMP_Context; - -/** - * @brief Scheduler node specialization for Deterministic Priority SMP - * schedulers. - */ -typedef struct { - /** - * @brief SMP scheduler node. - */ - Scheduler_SMP_Node Base; - - /** - * @brief The associated ready queue of this node. - */ - Scheduler_priority_Ready_queue Ready_queue; -} Scheduler_priority_SMP_Node; - -/** - * @brief Entry points for the Priority SMP Scheduler. - */ -#define SCHEDULER_PRIORITY_SMP_ENTRY_POINTS \ - { \ - _Scheduler_priority_SMP_Initialize, \ - _Scheduler_default_Schedule, \ - _Scheduler_priority_SMP_Yield, \ - _Scheduler_priority_SMP_Block, \ - _Scheduler_priority_SMP_Unblock, \ - _Scheduler_priority_SMP_Update_priority, \ - _Scheduler_default_Map_priority, \ - _Scheduler_default_Unmap_priority, \ - _Scheduler_priority_SMP_Ask_for_help, \ - _Scheduler_priority_SMP_Reconsider_help_request, \ - _Scheduler_priority_SMP_Withdraw_node, \ - _Scheduler_priority_SMP_Add_processor, \ - _Scheduler_priority_SMP_Remove_processor, \ - _Scheduler_priority_SMP_Node_initialize, \ - _Scheduler_default_Node_destroy, \ - _Scheduler_default_Release_job, \ - _Scheduler_default_Cancel_job, \ - _Scheduler_default_Tick, \ - _Scheduler_SMP_Start_idle \ - SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY \ - } - -void _Scheduler_priority_SMP_Initialize( const Scheduler_Control *scheduler ); - -void _Scheduler_priority_SMP_Node_initialize( - const Scheduler_Control *scheduler, - Scheduler_Node *node, - Thread_Control *the_thread, - Priority_Control priority -); - -void _Scheduler_priority_SMP_Block( - const Scheduler_Control *scheduler, - Thread_Control *thread, - Scheduler_Node *node -); - -void _Scheduler_priority_SMP_Unblock( - const Scheduler_Control *scheduler, - Thread_Control *thread, - Scheduler_Node *node -); - -void _Scheduler_priority_SMP_Update_priority( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -); - -bool _Scheduler_priority_SMP_Ask_for_help( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -); - -void _Scheduler_priority_SMP_Reconsider_help_request( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -); - -void _Scheduler_priority_SMP_Withdraw_node( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node, - Thread_Scheduler_state next_state -); - -void _Scheduler_priority_SMP_Add_processor( - const Scheduler_Control *scheduler, - Thread_Control *idle -); - -Thread_Control *_Scheduler_priority_SMP_Remove_processor( - const Scheduler_Control *scheduler, - struct Per_CPU_Control *cpu -); - -void _Scheduler_priority_SMP_Yield( - const Scheduler_Control *scheduler, - Thread_Control *thread, - Scheduler_Node *node -); - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_SCORE_SCHEDULERPRIORITYSMP_H */ diff --git a/cpukit/score/include/rtems/score/schedulerprioritysmpimpl.h b/cpukit/score/include/rtems/score/schedulerprioritysmpimpl.h deleted file mode 100644 index 17d6e552f3..0000000000 --- a/cpukit/score/include/rtems/score/schedulerprioritysmpimpl.h +++ /dev/null @@ -1,184 +0,0 @@ -/** - * @file - * - * @ingroup ScoreSchedulerPrioritySMP - * - * @brief Deterministic Priority SMP Scheduler API - */ - -/* - * Copyright (c) 2013, 2017 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SCHEDULERPRIORITYSMPIMPL_H -#define _RTEMS_SCORE_SCHEDULERPRIORITYSMPIMPL_H - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @ingroup ScoreSchedulerPrioritySMP - * @{ - */ - -static inline Scheduler_priority_SMP_Context *_Scheduler_priority_SMP_Get_self( - Scheduler_Context *context -) -{ - return (Scheduler_priority_SMP_Context *) context; -} - -static inline Scheduler_priority_SMP_Node *_Scheduler_priority_SMP_Thread_get_node( - Thread_Control *thread -) -{ - return (Scheduler_priority_SMP_Node *) _Thread_Scheduler_get_home_node( thread ); -} - -static inline Scheduler_priority_SMP_Node * -_Scheduler_priority_SMP_Node_downcast( Scheduler_Node *node ) -{ - return (Scheduler_priority_SMP_Node *) node; -} - -static inline bool _Scheduler_priority_SMP_Has_ready( Scheduler_Context *context ) -{ - Scheduler_priority_SMP_Context *self = - _Scheduler_priority_SMP_Get_self( context ); - - return !_Priority_bit_map_Is_empty( &self->Bit_map ); -} - -static inline void _Scheduler_priority_SMP_Move_from_scheduled_to_ready( - Scheduler_Context *context, - Scheduler_Node *scheduled_to_ready -) -{ - Scheduler_priority_SMP_Context *self = - _Scheduler_priority_SMP_Get_self( context ); - Scheduler_priority_SMP_Node *node = - _Scheduler_priority_SMP_Node_downcast( scheduled_to_ready ); - - _Chain_Extract_unprotected( &node->Base.Base.Node.Chain ); - _Scheduler_priority_Ready_queue_enqueue_first( - &node->Base.Base.Node.Chain, - &node->Ready_queue, - &self->Bit_map - ); -} - -static inline void _Scheduler_priority_SMP_Move_from_ready_to_scheduled( - Scheduler_Context *context, - Scheduler_Node *ready_to_scheduled -) -{ - Scheduler_priority_SMP_Context *self; - Scheduler_priority_SMP_Node *node; - Priority_Control insert_priority; - - self = _Scheduler_priority_SMP_Get_self( context ); - node = _Scheduler_priority_SMP_Node_downcast( ready_to_scheduled ); - - _Scheduler_priority_Ready_queue_extract( - &node->Base.Base.Node.Chain, - &node->Ready_queue, - &self->Bit_map - ); - insert_priority = _Scheduler_SMP_Node_priority( &node->Base.Base ); - insert_priority = SCHEDULER_PRIORITY_APPEND( insert_priority ); - _Chain_Insert_ordered_unprotected( - &self->Base.Scheduled, - &node->Base.Base.Node.Chain, - &insert_priority, - _Scheduler_SMP_Priority_less_equal - ); -} - -static inline void _Scheduler_priority_SMP_Insert_ready( - Scheduler_Context *context, - Scheduler_Node *node_base, - Priority_Control insert_priority -) -{ - Scheduler_priority_SMP_Context *self; - Scheduler_priority_SMP_Node *node; - - self = _Scheduler_priority_SMP_Get_self( context ); - node = _Scheduler_priority_SMP_Node_downcast( node_base ); - - if ( SCHEDULER_PRIORITY_IS_APPEND( insert_priority ) ) { - _Scheduler_priority_Ready_queue_enqueue( - &node->Base.Base.Node.Chain, - &node->Ready_queue, - &self->Bit_map - ); - } else { - _Scheduler_priority_Ready_queue_enqueue_first( - &node->Base.Base.Node.Chain, - &node->Ready_queue, - &self->Bit_map - ); - } -} - -static inline void _Scheduler_priority_SMP_Extract_from_ready( - Scheduler_Context *context, - Scheduler_Node *thread -) -{ - Scheduler_priority_SMP_Context *self = - _Scheduler_priority_SMP_Get_self( context ); - Scheduler_priority_SMP_Node *node = - _Scheduler_priority_SMP_Node_downcast( thread ); - - _Scheduler_priority_Ready_queue_extract( - &node->Base.Base.Node.Chain, - &node->Ready_queue, - &self->Bit_map - ); -} - -static inline void _Scheduler_priority_SMP_Do_update( - Scheduler_Context *context, - Scheduler_Node *node_to_update, - Priority_Control new_priority -) -{ - Scheduler_priority_SMP_Context *self; - Scheduler_priority_SMP_Node *node; - - self = _Scheduler_priority_SMP_Get_self( context ); - node = _Scheduler_priority_SMP_Node_downcast( node_to_update ); - - _Scheduler_SMP_Node_update_priority( &node->Base, new_priority ); - _Scheduler_priority_Ready_queue_update( - &node->Ready_queue, - SCHEDULER_PRIORITY_UNMAP( new_priority ), - &self->Bit_map, - &self->Ready[ 0 ] - ); -} - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_SCORE_SCHEDULERPRIORITYSMPIMPL_H */ diff --git a/cpukit/score/include/rtems/score/schedulersimple.h b/cpukit/score/include/rtems/score/schedulersimple.h deleted file mode 100644 index 0d410d5676..0000000000 --- a/cpukit/score/include/rtems/score/schedulersimple.h +++ /dev/null @@ -1,126 +0,0 @@ -/** - * @file rtems/score/schedulersimple.h - * - * @brief Manipulation of Threads Simple-Priority-Based Ready Queue - * - * This include file contains all the constants and structures associated - * with the manipulation of threads on a simple-priority-based ready queue. - */ - -/* - * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SCHEDULERSIMPLE_H -#define _RTEMS_SCORE_SCHEDULERSIMPLE_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ScoreSchedulerSimple Simple Priority Scheduler - * - * @ingroup ScoreScheduler - */ -/**@{*/ - -#define SCHEDULER_SIMPLE_MAXIMUM_PRIORITY 255 - -/** - * Entry points for Scheduler Simple - */ -#define SCHEDULER_SIMPLE_ENTRY_POINTS \ - { \ - _Scheduler_simple_Initialize, /* initialize entry point */ \ - _Scheduler_simple_Schedule, /* schedule entry point */ \ - _Scheduler_simple_Yield, /* yield entry point */ \ - _Scheduler_simple_Block, /* block entry point */ \ - _Scheduler_simple_Unblock, /* unblock entry point */ \ - _Scheduler_simple_Update_priority, /* update priority entry point */ \ - _Scheduler_default_Map_priority, /* map priority entry point */ \ - _Scheduler_default_Unmap_priority, /* unmap priority entry point */ \ - SCHEDULER_OPERATION_DEFAULT_ASK_FOR_HELP \ - _Scheduler_default_Node_initialize, /* node initialize entry point */ \ - _Scheduler_default_Node_destroy, /* node destroy entry point */ \ - _Scheduler_default_Release_job, /* new period of task */ \ - _Scheduler_default_Cancel_job, /* cancel period of task */ \ - _Scheduler_default_Tick, /* tick entry point */ \ - _Scheduler_default_Start_idle /* start idle entry point */ \ - SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY \ - } - -/** - * @brief Simple scheduler context. - */ -typedef struct { - /** - * @brief Basic scheduler context. - */ - Scheduler_Context Base; - - /** - * @brief One ready queue for all ready threads. - */ - Chain_Control Ready; -} Scheduler_simple_Context; - -/** - * @brief Initialize simple scheduler. - * - * This routine initializes the simple scheduler. - */ -void _Scheduler_simple_Initialize( const Scheduler_Control *scheduler ); - -/** - * This routine sets the heir thread to be the next ready thread - * on the ready queue by getting the first node in the scheduler - * information. - * - * @param[in] scheduler The scheduler instance. - * @param[in] the_thread causing the scheduling operation. - */ -void _Scheduler_simple_Schedule( - const Scheduler_Control *scheduler, - Thread_Control *the_thread -); - -void _Scheduler_simple_Yield( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -); - -void _Scheduler_simple_Block( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -); - -void _Scheduler_simple_Unblock( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -); - -void _Scheduler_simple_Update_priority( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -); - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/schedulersimpleimpl.h b/cpukit/score/include/rtems/score/schedulersimpleimpl.h deleted file mode 100644 index 3891839281..0000000000 --- a/cpukit/score/include/rtems/score/schedulersimpleimpl.h +++ /dev/null @@ -1,103 +0,0 @@ -/** - * @file - * - * @brief Inlined Routines Associated with the Manipulation of the - * Priority-Based Scheduling Structures - * - * This inline file contains all of the inlined routines associated with - * the manipulation of the priority-based scheduling structures. - */ - -/* - * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SCHEDULERSIMPLEIMPL_H -#define _RTEMS_SCORE_SCHEDULERSIMPLEIMPL_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ScoreSchedulerSimple - */ -/**@{**/ - -RTEMS_INLINE_ROUTINE Scheduler_simple_Context * - _Scheduler_simple_Get_context( const Scheduler_Control *scheduler ) -{ - return (Scheduler_simple_Context *) _Scheduler_Get_context( scheduler ); -} - -RTEMS_INLINE_ROUTINE bool _Scheduler_simple_Priority_less_equal( - const void *to_insert, - const Chain_Node *next -) -{ - const unsigned int *priority_to_insert; - const Thread_Control *thread_next; - - priority_to_insert = (const unsigned int *) to_insert; - thread_next = (const Thread_Control *) next; - - return *priority_to_insert <= _Thread_Get_priority( thread_next ); -} - -RTEMS_INLINE_ROUTINE void _Scheduler_simple_Insert( - Chain_Control *chain, - Thread_Control *to_insert, - unsigned int insert_priority -) -{ - _Chain_Insert_ordered_unprotected( - chain, - &to_insert->Object.Node, - &insert_priority, - _Scheduler_simple_Priority_less_equal - ); -} - -RTEMS_INLINE_ROUTINE void _Scheduler_simple_Extract( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -) -{ - (void) scheduler; - (void) node; - - _Chain_Extract_unprotected( &the_thread->Object.Node ); -} - -RTEMS_INLINE_ROUTINE void _Scheduler_simple_Schedule_body( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - bool force_dispatch -) -{ - Scheduler_simple_Context *context = - _Scheduler_simple_Get_context( scheduler ); - Thread_Control *heir = (Thread_Control *) _Chain_First( &context->Ready ); - - ( void ) the_thread; - - _Scheduler_Update_heir( heir, force_dispatch ); -} - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/schedulersimplesmp.h b/cpukit/score/include/rtems/score/schedulersimplesmp.h deleted file mode 100644 index bc75b205d5..0000000000 --- a/cpukit/score/include/rtems/score/schedulersimplesmp.h +++ /dev/null @@ -1,155 +0,0 @@ -/** - * @file - * - * @brief Simple SMP Scheduler API - * - * @ingroup ScoreSchedulerSMPSimple - */ - -/* - * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). - * - * Copyright (c) 2013, 2016 embedded brains GmbH. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SCHEDULERSIMPLE_SMP_H -#define _RTEMS_SCORE_SCHEDULERSIMPLE_SMP_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include - -/** - * @defgroup ScoreSchedulerSMPSimple Simple Priority SMP Scheduler - * - * @ingroup ScoreSchedulerSMP - * - * The Simple Priority SMP Scheduler allocates a processor for the processor - * count highest priority ready threads. The thread priority and position in - * the ready chain are the only information to determine the scheduling - * decision. Threads with an allocated processor are in the scheduled chain. - * After initialization the scheduled chain has exactly processor count nodes. - * Each processor has exactly one allocated thread after initialization. All - * enqueue and extract operations may exchange threads with the scheduled - * chain. One thread will be added and another will be removed. The scheduled - * and ready chain is ordered according to the thread priority order. The - * chain insert operations are O(count of ready threads), thus this scheduler - * is unsuitable for most real-time applications. - * - * The thread preempt mode will be ignored. - * - * @{ - */ - -typedef struct { - Scheduler_SMP_Context Base; - Chain_Control Ready; -} Scheduler_simple_SMP_Context; - -#define SCHEDULER_SIMPLE_SMP_MAXIMUM_PRIORITY 255 - -/** - * @brief Entry points for the Simple SMP Scheduler. - */ -#define SCHEDULER_SIMPLE_SMP_ENTRY_POINTS \ - { \ - _Scheduler_simple_SMP_Initialize, \ - _Scheduler_default_Schedule, \ - _Scheduler_simple_SMP_Yield, \ - _Scheduler_simple_SMP_Block, \ - _Scheduler_simple_SMP_Unblock, \ - _Scheduler_simple_SMP_Update_priority, \ - _Scheduler_default_Map_priority, \ - _Scheduler_default_Unmap_priority, \ - _Scheduler_simple_SMP_Ask_for_help, \ - _Scheduler_simple_SMP_Reconsider_help_request, \ - _Scheduler_simple_SMP_Withdraw_node, \ - _Scheduler_simple_SMP_Add_processor, \ - _Scheduler_simple_SMP_Remove_processor, \ - _Scheduler_simple_SMP_Node_initialize, \ - _Scheduler_default_Node_destroy, \ - _Scheduler_default_Release_job, \ - _Scheduler_default_Cancel_job, \ - _Scheduler_default_Tick, \ - _Scheduler_SMP_Start_idle \ - SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY \ - } - -void _Scheduler_simple_SMP_Initialize( const Scheduler_Control *scheduler ); - -void _Scheduler_simple_SMP_Node_initialize( - const Scheduler_Control *scheduler, - Scheduler_Node *node, - Thread_Control *the_thread, - Priority_Control priority -); - -void _Scheduler_simple_SMP_Block( - const Scheduler_Control *scheduler, - Thread_Control *thread, - Scheduler_Node *node -); - -void _Scheduler_simple_SMP_Unblock( - const Scheduler_Control *scheduler, - Thread_Control *thread, - Scheduler_Node *node -); - -void _Scheduler_simple_SMP_Update_priority( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -); - -bool _Scheduler_simple_SMP_Ask_for_help( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -); - -void _Scheduler_simple_SMP_Reconsider_help_request( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -); - -void _Scheduler_simple_SMP_Withdraw_node( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node, - Thread_Scheduler_state next_state -); - -void _Scheduler_simple_SMP_Add_processor( - const Scheduler_Control *scheduler, - Thread_Control *idle -); - -Thread_Control *_Scheduler_simple_SMP_Remove_processor( - const Scheduler_Control *scheduler, - struct Per_CPU_Control *cpu -); - -void _Scheduler_simple_SMP_Yield( - const Scheduler_Control *scheduler, - Thread_Control *thread, - Scheduler_Node *node -); - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/schedulersmp.h b/cpukit/score/include/rtems/score/schedulersmp.h deleted file mode 100644 index 0bd899a6a6..0000000000 --- a/cpukit/score/include/rtems/score/schedulersmp.h +++ /dev/null @@ -1,127 +0,0 @@ -/** - * @file - * - * @brief SMP Scheduler API - * - * @ingroup ScoreSchedulerSMP - */ - -/* - * Copyright (c) 2013-2014 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SCHEDULERSMP_H -#define _RTEMS_SCORE_SCHEDULERSMP_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup ScoreSchedulerSMP SMP Scheduler - * - * @ingroup ScoreScheduler - * - * @{ - */ - -/** - * @brief Scheduler context specialization for SMP schedulers. - */ -typedef struct { - /** - * @brief Basic scheduler context. - */ - Scheduler_Context Base; - - /** - * @brief The chain of scheduled nodes. - */ - Chain_Control Scheduled; - - /** - * @brief Chain of the available idle threads. - * - * Idle threads are used for the scheduler helping protocol. It is crucial - * that the idle threads preserve their relative order. This is the case for - * this priority based scheduler. - */ - Chain_Control Idle_threads; -} Scheduler_SMP_Context; - -/** - * @brief SMP scheduler node states. - */ -typedef enum { - /** - * @brief This scheduler node is blocked. - * - * A scheduler node is blocked if the corresponding thread is not ready. - */ - SCHEDULER_SMP_NODE_BLOCKED, - - /** - * @brief The scheduler node is scheduled. - * - * A scheduler node is scheduled if the corresponding thread is ready and the - * scheduler allocated a processor for it. A scheduled node is assigned to - * exactly one processor. The count of scheduled nodes in this scheduler - * instance equals the processor count owned by the scheduler instance. - */ - SCHEDULER_SMP_NODE_SCHEDULED, - - /** - * @brief This scheduler node is ready. - * - * A scheduler node is ready if the corresponding thread is ready and the - * scheduler did not allocate a processor for it. - */ - SCHEDULER_SMP_NODE_READY -} Scheduler_SMP_Node_state; - -/** - * @brief Scheduler node specialization for SMP schedulers. - */ -typedef struct { - /** - * @brief Basic scheduler node. - */ - Scheduler_Node Base; - - /** - * @brief The state of this node. - */ - Scheduler_SMP_Node_state state; - - /** - * @brief The current priority of thread owning this node. - */ - Priority_Control priority; -} Scheduler_SMP_Node; - -void _Scheduler_SMP_Start_idle( - const Scheduler_Control *scheduler, - Thread_Control *idle, - struct Per_CPU_Control *cpu -); - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_SCORE_SCHEDULERSMP_H */ diff --git a/cpukit/score/include/rtems/score/schedulersmpimpl.h b/cpukit/score/include/rtems/score/schedulersmpimpl.h deleted file mode 100644 index e152eb0878..0000000000 --- a/cpukit/score/include/rtems/score/schedulersmpimpl.h +++ /dev/null @@ -1,1482 +0,0 @@ -/** - * @file - * - * @brief SMP Scheduler Implementation - * - * @ingroup ScoreSchedulerSMP - */ - -/* - * Copyright (c) 2013, 2017 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SCHEDULERSMPIMPL_H -#define _RTEMS_SCORE_SCHEDULERSMPIMPL_H - -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @addtogroup ScoreSchedulerSMP - * - * The scheduler nodes can be in four states - * - @ref SCHEDULER_SMP_NODE_BLOCKED, - * - @ref SCHEDULER_SMP_NODE_SCHEDULED, and - * - @ref SCHEDULER_SMP_NODE_READY. - * - * State transitions are triggered via basic operations - * - _Scheduler_SMP_Enqueue(), - * - _Scheduler_SMP_Enqueue_scheduled(), and - * - _Scheduler_SMP_Block(). - * - * @dot - * digraph { - * node [style="filled"]; - * - * bs [label="BLOCKED"]; - * ss [label="SCHEDULED", fillcolor="green"]; - * rs [label="READY", fillcolor="red"]; - * - * edge [label="enqueue"]; - * edge [fontcolor="darkgreen", color="darkgreen"]; - * - * bs -> ss; - * - * edge [fontcolor="red", color="red"]; - * - * bs -> rs; - * - * edge [label="enqueue other"]; - * - * ss -> rs; - * - * edge [label="block"]; - * edge [fontcolor="black", color="black"]; - * - * ss -> bs; - * rs -> bs; - * - * edge [label="block other"]; - * edge [fontcolor="darkgreen", color="darkgreen"]; - * - * rs -> ss; - * } - * @enddot - * - * During system initialization each processor of the scheduler instance starts - * with an idle thread assigned to it. Lets have a look at an example with two - * idle threads I and J with priority 5. We also have blocked threads A, B and - * C with priorities 1, 2 and 3 respectively. The scheduler nodes are ordered - * with respect to the thread priority from left to right in the below - * diagrams. The highest priority node (lowest priority number) is the - * leftmost node. Since the processor assignment is independent of the thread - * priority the processor indices may move from one state to the other. - * - * @dot - * digraph { - * node [style="filled"]; - * edge [dir="none"]; - * subgraph { - * rank = same; - * - * i [label="I (5)", fillcolor="green"]; - * j [label="J (5)", fillcolor="green"]; - * a [label="A (1)"]; - * b [label="B (2)"]; - * c [label="C (3)"]; - * i -> j; - * } - * - * subgraph { - * rank = same; - * - * p0 [label="PROCESSOR 0", shape="box"]; - * p1 [label="PROCESSOR 1", shape="box"]; - * } - * - * i -> p0; - * j -> p1; - * } - * @enddot - * - * Lets start A. For this an enqueue operation is performed. - * - * @dot - * digraph { - * node [style="filled"]; - * edge [dir="none"]; - * - * subgraph { - * rank = same; - * - * i [label="I (5)", fillcolor="green"]; - * j [label="J (5)", fillcolor="red"]; - * a [label="A (1)", fillcolor="green"]; - * b [label="B (2)"]; - * c [label="C (3)"]; - * a -> i; - * } - * - * subgraph { - * rank = same; - * - * p0 [label="PROCESSOR 0", shape="box"]; - * p1 [label="PROCESSOR 1", shape="box"]; - * } - * - * i -> p0; - * a -> p1; - * } - * @enddot - * - * Lets start C. - * - * @dot - * digraph { - * node [style="filled"]; - * edge [dir="none"]; - * - * subgraph { - * rank = same; - * - * a [label="A (1)", fillcolor="green"]; - * c [label="C (3)", fillcolor="green"]; - * i [label="I (5)", fillcolor="red"]; - * j [label="J (5)", fillcolor="red"]; - * b [label="B (2)"]; - * a -> c; - * i -> j; - * } - * - * subgraph { - * rank = same; - * - * p0 [label="PROCESSOR 0", shape="box"]; - * p1 [label="PROCESSOR 1", shape="box"]; - * } - * - * c -> p0; - * a -> p1; - * } - * @enddot - * - * Lets start B. - * - * @dot - * digraph { - * node [style="filled"]; - * edge [dir="none"]; - * - * subgraph { - * rank = same; - * - * a [label="A (1)", fillcolor="green"]; - * b [label="B (2)", fillcolor="green"]; - * c [label="C (3)", fillcolor="red"]; - * i [label="I (5)", fillcolor="red"]; - * j [label="J (5)", fillcolor="red"]; - * a -> b; - * c -> i -> j; - * } - * - * subgraph { - * rank = same; - * - * p0 [label="PROCESSOR 0", shape="box"]; - * p1 [label="PROCESSOR 1", shape="box"]; - * } - * - * b -> p0; - * a -> p1; - * } - * @enddot - * - * Lets change the priority of thread A to 4. - * - * @dot - * digraph { - * node [style="filled"]; - * edge [dir="none"]; - * - * subgraph { - * rank = same; - * - * b [label="B (2)", fillcolor="green"]; - * c [label="C (3)", fillcolor="green"]; - * a [label="A (4)", fillcolor="red"]; - * i [label="I (5)", fillcolor="red"]; - * j [label="J (5)", fillcolor="red"]; - * b -> c; - * a -> i -> j; - * } - * - * subgraph { - * rank = same; - * - * p0 [label="PROCESSOR 0", shape="box"]; - * p1 [label="PROCESSOR 1", shape="box"]; - * } - * - * b -> p0; - * c -> p1; - * } - * @enddot - * - * Now perform a blocking operation with thread B. Please note that thread A - * migrated now from processor 0 to processor 1 and thread C still executes on - * processor 1. - * - * @dot - * digraph { - * node [style="filled"]; - * edge [dir="none"]; - * - * subgraph { - * rank = same; - * - * c [label="C (3)", fillcolor="green"]; - * a [label="A (4)", fillcolor="green"]; - * i [label="I (5)", fillcolor="red"]; - * j [label="J (5)", fillcolor="red"]; - * b [label="B (2)"]; - * c -> a; - * i -> j; - * } - * - * subgraph { - * rank = same; - * - * p0 [label="PROCESSOR 0", shape="box"]; - * p1 [label="PROCESSOR 1", shape="box"]; - * } - * - * a -> p0; - * c -> p1; - * } - * @enddot - * - * @{ - */ - -typedef bool ( *Scheduler_SMP_Has_ready )( - Scheduler_Context *context -); - -typedef Scheduler_Node *( *Scheduler_SMP_Get_highest_ready )( - Scheduler_Context *context, - Scheduler_Node *node -); - -typedef Scheduler_Node *( *Scheduler_SMP_Get_lowest_scheduled )( - Scheduler_Context *context, - Scheduler_Node *filter -); - -typedef void ( *Scheduler_SMP_Extract )( - Scheduler_Context *context, - Scheduler_Node *node_to_extract -); - -typedef void ( *Scheduler_SMP_Insert )( - Scheduler_Context *context, - Scheduler_Node *node_to_insert, - Priority_Control insert_priority -); - -typedef void ( *Scheduler_SMP_Move )( - Scheduler_Context *context, - Scheduler_Node *node_to_move -); - -typedef bool ( *Scheduler_SMP_Ask_for_help )( - Scheduler_Context *context, - Thread_Control *thread, - Scheduler_Node *node -); - -typedef void ( *Scheduler_SMP_Update )( - Scheduler_Context *context, - Scheduler_Node *node_to_update, - Priority_Control new_priority -); - -typedef void ( *Scheduler_SMP_Set_affinity )( - Scheduler_Context *context, - Scheduler_Node *node, - void *arg -); - -typedef bool ( *Scheduler_SMP_Enqueue )( - Scheduler_Context *context, - Scheduler_Node *node_to_enqueue, - Priority_Control priority -); - -typedef void ( *Scheduler_SMP_Allocate_processor )( - Scheduler_Context *context, - Scheduler_Node *scheduled, - Scheduler_Node *victim, - Per_CPU_Control *victim_cpu -); - -typedef void ( *Scheduler_SMP_Register_idle )( - Scheduler_Context *context, - Scheduler_Node *idle, - Per_CPU_Control *cpu -); - -static inline void _Scheduler_SMP_Do_nothing_register_idle( - Scheduler_Context *context, - Scheduler_Node *idle, - Per_CPU_Control *cpu -) -{ - (void) context; - (void) idle; - (void) cpu; -} - -static inline bool _Scheduler_SMP_Priority_less_equal( - const void *to_insert, - const Chain_Node *next -) -{ - const Priority_Control *priority_to_insert; - const Scheduler_SMP_Node *node_next; - - priority_to_insert = (const Priority_Control *) to_insert; - node_next = (const Scheduler_SMP_Node *) next; - - return *priority_to_insert <= node_next->priority; -} - -static inline Scheduler_SMP_Context *_Scheduler_SMP_Get_self( - Scheduler_Context *context -) -{ - return (Scheduler_SMP_Context *) context; -} - -static inline void _Scheduler_SMP_Initialize( - Scheduler_SMP_Context *self -) -{ - _Chain_Initialize_empty( &self->Scheduled ); - _Chain_Initialize_empty( &self->Idle_threads ); -} - -static inline Scheduler_SMP_Node *_Scheduler_SMP_Thread_get_node( - Thread_Control *thread -) -{ - return (Scheduler_SMP_Node *) _Thread_Scheduler_get_home_node( thread ); -} - -static inline Scheduler_SMP_Node *_Scheduler_SMP_Thread_get_own_node( - Thread_Control *thread -) -{ - return (Scheduler_SMP_Node *) _Thread_Scheduler_get_home_node( thread ); -} - -static inline Scheduler_SMP_Node *_Scheduler_SMP_Node_downcast( - Scheduler_Node *node -) -{ - return (Scheduler_SMP_Node *) node; -} - -static inline Scheduler_SMP_Node_state _Scheduler_SMP_Node_state( - const Scheduler_Node *node -) -{ - return ( (const Scheduler_SMP_Node *) node )->state; -} - -static inline Priority_Control _Scheduler_SMP_Node_priority( - const Scheduler_Node *node -) -{ - return ( (const Scheduler_SMP_Node *) node )->priority; -} - -static inline void _Scheduler_SMP_Node_initialize( - const Scheduler_Control *scheduler, - Scheduler_SMP_Node *node, - Thread_Control *thread, - Priority_Control priority -) -{ - _Scheduler_Node_do_initialize( scheduler, &node->Base, thread, priority ); - node->state = SCHEDULER_SMP_NODE_BLOCKED; - node->priority = priority; -} - -static inline void _Scheduler_SMP_Node_update_priority( - Scheduler_SMP_Node *node, - Priority_Control new_priority -) -{ - node->priority = new_priority; -} - -static inline void _Scheduler_SMP_Node_change_state( - Scheduler_Node *node, - Scheduler_SMP_Node_state new_state -) -{ - Scheduler_SMP_Node *the_node; - - the_node = _Scheduler_SMP_Node_downcast( node ); - the_node->state = new_state; -} - -static inline bool _Scheduler_SMP_Is_processor_owned_by_us( - const Scheduler_Context *context, - const Per_CPU_Control *cpu -) -{ - return cpu->Scheduler.context == context; -} - -static inline Thread_Control *_Scheduler_SMP_Get_idle_thread( - Scheduler_Context *context -) -{ - Scheduler_SMP_Context *self = _Scheduler_SMP_Get_self( context ); - Thread_Control *idle = (Thread_Control *) - _Chain_Get_first_unprotected( &self->Idle_threads ); - - _Assert( &idle->Object.Node != _Chain_Tail( &self->Idle_threads ) ); - - return idle; -} - -static inline void _Scheduler_SMP_Release_idle_thread( - Scheduler_Context *context, - Thread_Control *idle -) -{ - Scheduler_SMP_Context *self = _Scheduler_SMP_Get_self( context ); - - _Chain_Prepend_unprotected( &self->Idle_threads, &idle->Object.Node ); -} - -static inline void _Scheduler_SMP_Exctract_idle_thread( - Thread_Control *idle -) -{ - _Chain_Extract_unprotected( &idle->Object.Node ); -} - -static inline void _Scheduler_SMP_Allocate_processor_lazy( - Scheduler_Context *context, - Scheduler_Node *scheduled, - Scheduler_Node *victim, - Per_CPU_Control *victim_cpu -) -{ - Thread_Control *scheduled_thread = _Scheduler_Node_get_user( scheduled ); - Thread_Control *victim_thread = _Scheduler_Node_get_user( victim ); - Per_CPU_Control *scheduled_cpu = _Thread_Get_CPU( scheduled_thread ); - Per_CPU_Control *cpu_self = _Per_CPU_Get(); - Thread_Control *heir; - - _Assert( _ISR_Get_level() != 0 ); - - if ( _Thread_Is_executing_on_a_processor( scheduled_thread ) ) { - if ( _Scheduler_SMP_Is_processor_owned_by_us( context, scheduled_cpu ) ) { - heir = scheduled_cpu->heir; - _Thread_Dispatch_update_heir( - cpu_self, - scheduled_cpu, - scheduled_thread - ); - } else { - /* We have to force a migration to our processor set */ - heir = scheduled_thread; - } - } else { - heir = scheduled_thread; - } - - if ( heir != victim_thread ) { - _Thread_Set_CPU( heir, victim_cpu ); - _Thread_Dispatch_update_heir( cpu_self, victim_cpu, heir ); - } -} - -/* - * This method is slightly different from - * _Scheduler_SMP_Allocate_processor_lazy() in that it does what it is asked to - * do. _Scheduler_SMP_Allocate_processor_lazy() attempts to prevent migrations - * but does not take into account affinity. - */ -static inline void _Scheduler_SMP_Allocate_processor_exact( - Scheduler_Context *context, - Scheduler_Node *scheduled, - Scheduler_Node *victim, - Per_CPU_Control *victim_cpu -) -{ - Thread_Control *scheduled_thread = _Scheduler_Node_get_user( scheduled ); - Per_CPU_Control *cpu_self = _Per_CPU_Get(); - - (void) context; - (void) victim; - - _Thread_Set_CPU( scheduled_thread, victim_cpu ); - _Thread_Dispatch_update_heir( cpu_self, victim_cpu, scheduled_thread ); -} - -static inline void _Scheduler_SMP_Allocate_processor( - Scheduler_Context *context, - Scheduler_Node *scheduled, - Scheduler_Node *victim, - Per_CPU_Control *victim_cpu, - Scheduler_SMP_Allocate_processor allocate_processor -) -{ - _Scheduler_SMP_Node_change_state( scheduled, SCHEDULER_SMP_NODE_SCHEDULED ); - ( *allocate_processor )( context, scheduled, victim, victim_cpu ); -} - -static inline Thread_Control *_Scheduler_SMP_Preempt( - Scheduler_Context *context, - Scheduler_Node *scheduled, - Scheduler_Node *victim, - Scheduler_SMP_Allocate_processor allocate_processor -) -{ - Thread_Control *victim_thread; - ISR_lock_Context lock_context; - Per_CPU_Control *victim_cpu; - - victim_thread = _Scheduler_Node_get_user( victim ); - _Scheduler_SMP_Node_change_state( victim, SCHEDULER_SMP_NODE_READY ); - - _Thread_Scheduler_acquire_critical( victim_thread, &lock_context ); - - victim_cpu = _Thread_Get_CPU( victim_thread ); - - if ( victim_thread->Scheduler.state == THREAD_SCHEDULER_SCHEDULED ) { - _Scheduler_Thread_change_state( victim_thread, THREAD_SCHEDULER_READY ); - - if ( victim_thread->Scheduler.helping_nodes > 0 ) { - _Per_CPU_Acquire( victim_cpu ); - _Chain_Append_unprotected( - &victim_cpu->Threads_in_need_for_help, - &victim_thread->Scheduler.Help_node - ); - _Per_CPU_Release( victim_cpu ); - } - } - - _Thread_Scheduler_release_critical( victim_thread, &lock_context ); - - _Scheduler_SMP_Allocate_processor( - context, - scheduled, - victim, - victim_cpu, - allocate_processor - ); - - return victim_thread; -} - -static inline Scheduler_Node *_Scheduler_SMP_Get_lowest_scheduled( - Scheduler_Context *context, - Scheduler_Node *filter -) -{ - Scheduler_SMP_Context *self = _Scheduler_SMP_Get_self( context ); - Chain_Control *scheduled = &self->Scheduled; - Scheduler_Node *lowest_scheduled = - (Scheduler_Node *) _Chain_Last( scheduled ); - - (void) filter; - - _Assert( &lowest_scheduled->Node.Chain != _Chain_Tail( scheduled ) ); - _Assert( - _Chain_Next( &lowest_scheduled->Node.Chain ) == _Chain_Tail( scheduled ) - ); - - return lowest_scheduled; -} - -static inline void _Scheduler_SMP_Enqueue_to_scheduled( - Scheduler_Context *context, - Scheduler_Node *node, - Priority_Control priority, - Scheduler_Node *lowest_scheduled, - Scheduler_SMP_Insert insert_scheduled, - Scheduler_SMP_Move move_from_scheduled_to_ready, - Scheduler_SMP_Allocate_processor allocate_processor -) -{ - Scheduler_Try_to_schedule_action action; - - action = _Scheduler_Try_to_schedule_node( - context, - node, - _Scheduler_Node_get_idle( lowest_scheduled ), - _Scheduler_SMP_Get_idle_thread - ); - - if ( action == SCHEDULER_TRY_TO_SCHEDULE_DO_SCHEDULE ) { - _Scheduler_SMP_Preempt( - context, - node, - lowest_scheduled, - allocate_processor - ); - - ( *insert_scheduled )( context, node, priority ); - ( *move_from_scheduled_to_ready )( context, lowest_scheduled ); - - _Scheduler_Release_idle_thread( - context, - lowest_scheduled, - _Scheduler_SMP_Release_idle_thread - ); - } else if ( action == SCHEDULER_TRY_TO_SCHEDULE_DO_IDLE_EXCHANGE ) { - _Scheduler_SMP_Node_change_state( - lowest_scheduled, - SCHEDULER_SMP_NODE_READY - ); - _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_SCHEDULED ); - - ( *insert_scheduled )( context, node, priority ); - ( *move_from_scheduled_to_ready )( context, lowest_scheduled ); - - _Scheduler_Exchange_idle_thread( - node, - lowest_scheduled, - _Scheduler_Node_get_idle( lowest_scheduled ) - ); - } else { - _Assert( action == SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK ); - _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_BLOCKED ); - } -} - -/** - * @brief Enqueues a node according to the specified order function. - * - * The node must not be in the scheduled state. - * - * @param[in] context The scheduler instance context. - * @param[in] node The node to enqueue. - * @param[in] priority The node insert priority. - * @param[in] order The order function. - * @param[in] insert_ready Function to insert a node into the set of ready - * nodes. - * @param[in] insert_scheduled Function to insert a node into the set of - * scheduled nodes. - * @param[in] move_from_scheduled_to_ready Function to move a node from the set - * of scheduled nodes to the set of ready nodes. - * @param[in] get_lowest_scheduled Function to select the node from the - * scheduled nodes to replace. It may not be possible to find one, in this - * case a pointer must be returned so that the order functions returns false - * if this pointer is passed as the second argument to the order function. - * @param[in] allocate_processor Function to allocate a processor to a node - * based on the rules of the scheduler. - */ -static inline bool _Scheduler_SMP_Enqueue( - Scheduler_Context *context, - Scheduler_Node *node, - Priority_Control insert_priority, - Chain_Node_order order, - Scheduler_SMP_Insert insert_ready, - Scheduler_SMP_Insert insert_scheduled, - Scheduler_SMP_Move move_from_scheduled_to_ready, - Scheduler_SMP_Get_lowest_scheduled get_lowest_scheduled, - Scheduler_SMP_Allocate_processor allocate_processor -) -{ - bool needs_help; - Scheduler_Node *lowest_scheduled; - - lowest_scheduled = ( *get_lowest_scheduled )( context, node ); - - if ( ( *order )( &insert_priority, &lowest_scheduled->Node.Chain ) ) { - _Scheduler_SMP_Enqueue_to_scheduled( - context, - node, - insert_priority, - lowest_scheduled, - insert_scheduled, - move_from_scheduled_to_ready, - allocate_processor - ); - needs_help = false; - } else { - ( *insert_ready )( context, node, insert_priority ); - needs_help = true; - } - - return needs_help; -} - -/** - * @brief Enqueues a scheduled node according to the specified order - * function. - * - * @param[in] context The scheduler instance context. - * @param[in] node The node to enqueue. - * @param[in] order The order function. - * @param[in] extract_from_ready Function to extract a node from the set of - * ready nodes. - * @param[in] get_highest_ready Function to get the highest ready node. - * @param[in] insert_ready Function to insert a node into the set of ready - * nodes. - * @param[in] insert_scheduled Function to insert a node into the set of - * scheduled nodes. - * @param[in] move_from_ready_to_scheduled Function to move a node from the set - * of ready nodes to the set of scheduled nodes. - * @param[in] allocate_processor Function to allocate a processor to a node - * based on the rules of the scheduler. - */ -static inline bool _Scheduler_SMP_Enqueue_scheduled( - Scheduler_Context *context, - Scheduler_Node *const node, - Priority_Control insert_priority, - Chain_Node_order order, - Scheduler_SMP_Extract extract_from_ready, - Scheduler_SMP_Get_highest_ready get_highest_ready, - Scheduler_SMP_Insert insert_ready, - Scheduler_SMP_Insert insert_scheduled, - Scheduler_SMP_Move move_from_ready_to_scheduled, - Scheduler_SMP_Allocate_processor allocate_processor -) -{ - while ( true ) { - Scheduler_Node *highest_ready; - Scheduler_Try_to_schedule_action action; - - highest_ready = ( *get_highest_ready )( context, node ); - - /* - * The node has been extracted from the scheduled chain. We have to place - * it now on the scheduled or ready set. - */ - if ( - node->sticky_level > 0 - && ( *order )( &insert_priority, &highest_ready->Node.Chain ) - ) { - ( *insert_scheduled )( context, node, insert_priority ); - - if ( _Scheduler_Node_get_idle( node ) != NULL ) { - Thread_Control *owner; - ISR_lock_Context lock_context; - - owner = _Scheduler_Node_get_owner( node ); - _Thread_Scheduler_acquire_critical( owner, &lock_context ); - - if ( owner->Scheduler.state == THREAD_SCHEDULER_READY ) { - _Thread_Scheduler_cancel_need_for_help( - owner, - _Thread_Get_CPU( owner ) - ); - _Scheduler_Discard_idle_thread( - context, - owner, - node, - _Scheduler_SMP_Release_idle_thread - ); - _Scheduler_Thread_change_state( owner, THREAD_SCHEDULER_SCHEDULED ); - } - - _Thread_Scheduler_release_critical( owner, &lock_context ); - } - - return false; - } - - action = _Scheduler_Try_to_schedule_node( - context, - highest_ready, - _Scheduler_Node_get_idle( node ), - _Scheduler_SMP_Get_idle_thread - ); - - if ( action == SCHEDULER_TRY_TO_SCHEDULE_DO_SCHEDULE ) { - Thread_Control *idle; - - _Scheduler_SMP_Preempt( - context, - highest_ready, - node, - allocate_processor - ); - - ( *insert_ready )( context, node, insert_priority ); - ( *move_from_ready_to_scheduled )( context, highest_ready ); - - idle = _Scheduler_Release_idle_thread( - context, - node, - _Scheduler_SMP_Release_idle_thread - ); - return ( idle == NULL ); - } else if ( action == SCHEDULER_TRY_TO_SCHEDULE_DO_IDLE_EXCHANGE ) { - _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_READY ); - _Scheduler_SMP_Node_change_state( - highest_ready, - SCHEDULER_SMP_NODE_SCHEDULED - ); - - ( *insert_ready )( context, node, insert_priority ); - ( *move_from_ready_to_scheduled )( context, highest_ready ); - - _Scheduler_Exchange_idle_thread( - highest_ready, - node, - _Scheduler_Node_get_idle( node ) - ); - return false; - } else { - _Assert( action == SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK ); - - _Scheduler_SMP_Node_change_state( - highest_ready, - SCHEDULER_SMP_NODE_BLOCKED - ); - - ( *extract_from_ready )( context, highest_ready ); - } - } -} - -static inline void _Scheduler_SMP_Extract_from_scheduled( - Scheduler_Node *node -) -{ - _Chain_Extract_unprotected( &node->Node.Chain ); -} - -static inline void _Scheduler_SMP_Schedule_highest_ready( - Scheduler_Context *context, - Scheduler_Node *victim, - Per_CPU_Control *victim_cpu, - Scheduler_SMP_Extract extract_from_ready, - Scheduler_SMP_Get_highest_ready get_highest_ready, - Scheduler_SMP_Move move_from_ready_to_scheduled, - Scheduler_SMP_Allocate_processor allocate_processor -) -{ - Scheduler_Try_to_schedule_action action; - - do { - Scheduler_Node *highest_ready = ( *get_highest_ready )( context, victim ); - - action = _Scheduler_Try_to_schedule_node( - context, - highest_ready, - NULL, - _Scheduler_SMP_Get_idle_thread - ); - - if ( action == SCHEDULER_TRY_TO_SCHEDULE_DO_SCHEDULE ) { - _Scheduler_SMP_Allocate_processor( - context, - highest_ready, - victim, - victim_cpu, - allocate_processor - ); - - ( *move_from_ready_to_scheduled )( context, highest_ready ); - } else { - _Assert( action == SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK ); - - _Scheduler_SMP_Node_change_state( - highest_ready, - SCHEDULER_SMP_NODE_BLOCKED - ); - - ( *extract_from_ready )( context, highest_ready ); - } - } while ( action == SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK ); -} - -static inline void _Scheduler_SMP_Preempt_and_schedule_highest_ready( - Scheduler_Context *context, - Scheduler_Node *victim, - Per_CPU_Control *victim_cpu, - Scheduler_SMP_Extract extract_from_ready, - Scheduler_SMP_Get_highest_ready get_highest_ready, - Scheduler_SMP_Move move_from_ready_to_scheduled, - Scheduler_SMP_Allocate_processor allocate_processor -) -{ - Scheduler_Try_to_schedule_action action; - - do { - Scheduler_Node *highest_ready = ( *get_highest_ready )( context, victim ); - - action = _Scheduler_Try_to_schedule_node( - context, - highest_ready, - NULL, - _Scheduler_SMP_Get_idle_thread - ); - - if ( action == SCHEDULER_TRY_TO_SCHEDULE_DO_SCHEDULE ) { - _Scheduler_SMP_Preempt( - context, - highest_ready, - victim, - allocate_processor - ); - - ( *move_from_ready_to_scheduled )( context, highest_ready ); - } else { - _Assert( action == SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK ); - - _Scheduler_SMP_Node_change_state( - highest_ready, - SCHEDULER_SMP_NODE_BLOCKED - ); - - ( *extract_from_ready )( context, highest_ready ); - } - } while ( action == SCHEDULER_TRY_TO_SCHEDULE_DO_BLOCK ); -} - -/** - * @brief Blocks a thread. - * - * @param[in] context The scheduler instance context. - * @param[in] thread The thread of the scheduling operation. - * @param[in] node The scheduler node of the thread to block. - * @param[in] extract_from_ready Function to extract a node from the set of - * ready nodes. - * @param[in] get_highest_ready Function to get the highest ready node. - * @param[in] move_from_ready_to_scheduled Function to move a node from the set - * of ready nodes to the set of scheduled nodes. - */ -static inline void _Scheduler_SMP_Block( - Scheduler_Context *context, - Thread_Control *thread, - Scheduler_Node *node, - Scheduler_SMP_Extract extract_from_ready, - Scheduler_SMP_Get_highest_ready get_highest_ready, - Scheduler_SMP_Move move_from_ready_to_scheduled, - Scheduler_SMP_Allocate_processor allocate_processor -) -{ - Scheduler_SMP_Node_state node_state; - Per_CPU_Control *thread_cpu; - - node_state = _Scheduler_SMP_Node_state( node ); - - thread_cpu = _Scheduler_Block_node( - context, - thread, - node, - node_state == SCHEDULER_SMP_NODE_SCHEDULED, - _Scheduler_SMP_Get_idle_thread - ); - - if ( thread_cpu != NULL ) { - _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_BLOCKED ); - - if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) { - _Scheduler_SMP_Extract_from_scheduled( node ); - _Scheduler_SMP_Schedule_highest_ready( - context, - node, - thread_cpu, - extract_from_ready, - get_highest_ready, - move_from_ready_to_scheduled, - allocate_processor - ); - } else if ( node_state == SCHEDULER_SMP_NODE_READY ) { - ( *extract_from_ready )( context, node ); - } - } -} - -static inline void _Scheduler_SMP_Unblock( - Scheduler_Context *context, - Thread_Control *thread, - Scheduler_Node *node, - Scheduler_SMP_Update update, - Scheduler_SMP_Enqueue enqueue -) -{ - Scheduler_SMP_Node_state node_state; - bool unblock; - - node_state = _Scheduler_SMP_Node_state( node ); - unblock = _Scheduler_Unblock_node( - context, - thread, - node, - node_state == SCHEDULER_SMP_NODE_SCHEDULED, - _Scheduler_SMP_Release_idle_thread - ); - - if ( unblock ) { - Priority_Control priority; - bool needs_help; - - priority = _Scheduler_Node_get_priority( node ); - priority = SCHEDULER_PRIORITY_PURIFY( priority ); - - if ( priority != _Scheduler_SMP_Node_priority( node ) ) { - ( *update )( context, node, priority ); - } - - if ( node_state == SCHEDULER_SMP_NODE_BLOCKED ) { - Priority_Control insert_priority; - - _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_READY ); - insert_priority = SCHEDULER_PRIORITY_APPEND( priority ); - needs_help = ( *enqueue )( context, node, insert_priority ); - } else { - _Assert( node_state == SCHEDULER_SMP_NODE_READY ); - _Assert( node->sticky_level > 0 ); - _Assert( node->idle == NULL ); - needs_help = true; - } - - if ( needs_help ) { - _Scheduler_Ask_for_help( thread ); - } - } -} - -static inline void _Scheduler_SMP_Update_priority( - Scheduler_Context *context, - Thread_Control *thread, - Scheduler_Node *node, - Scheduler_SMP_Extract extract_from_ready, - Scheduler_SMP_Update update, - Scheduler_SMP_Enqueue enqueue, - Scheduler_SMP_Enqueue enqueue_scheduled, - Scheduler_SMP_Ask_for_help ask_for_help -) -{ - Priority_Control priority; - Priority_Control insert_priority; - Scheduler_SMP_Node_state node_state; - - insert_priority = _Scheduler_Node_get_priority( node ); - priority = SCHEDULER_PRIORITY_PURIFY( insert_priority ); - - if ( priority == _Scheduler_SMP_Node_priority( node ) ) { - if ( _Thread_Is_ready( thread ) ) { - ( *ask_for_help )( context, thread, node ); - } - - return; - } - - node_state = _Scheduler_SMP_Node_state( node ); - - if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) { - _Scheduler_SMP_Extract_from_scheduled( node ); - ( *update )( context, node, priority ); - ( *enqueue_scheduled )( context, node, insert_priority ); - } else if ( node_state == SCHEDULER_SMP_NODE_READY ) { - ( *extract_from_ready )( context, node ); - ( *update )( context, node, priority ); - ( *enqueue )( context, node, insert_priority ); - } else { - ( *update )( context, node, priority ); - - if ( _Thread_Is_ready( thread ) ) { - ( *ask_for_help )( context, thread, node ); - } - } -} - -static inline void _Scheduler_SMP_Yield( - Scheduler_Context *context, - Thread_Control *thread, - Scheduler_Node *node, - Scheduler_SMP_Extract extract_from_ready, - Scheduler_SMP_Enqueue enqueue, - Scheduler_SMP_Enqueue enqueue_scheduled -) -{ - bool needs_help; - Scheduler_SMP_Node_state node_state; - Priority_Control insert_priority; - - node_state = _Scheduler_SMP_Node_state( node ); - insert_priority = _Scheduler_SMP_Node_priority( node ); - insert_priority = SCHEDULER_PRIORITY_APPEND( insert_priority ); - - if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) { - _Scheduler_SMP_Extract_from_scheduled( node ); - ( *enqueue_scheduled )( context, node, insert_priority ); - needs_help = false; - } else if ( node_state == SCHEDULER_SMP_NODE_READY ) { - ( *extract_from_ready )( context, node ); - - needs_help = ( *enqueue )( context, node, insert_priority ); - } else { - needs_help = true; - } - - if ( needs_help ) { - _Scheduler_Ask_for_help( thread ); - } -} - -static inline void _Scheduler_SMP_Insert_scheduled( - Scheduler_Context *context, - Scheduler_Node *node_to_insert, - Priority_Control priority_to_insert -) -{ - Scheduler_SMP_Context *self; - - self = _Scheduler_SMP_Get_self( context ); - - _Chain_Insert_ordered_unprotected( - &self->Scheduled, - &node_to_insert->Node.Chain, - &priority_to_insert, - _Scheduler_SMP_Priority_less_equal - ); -} - -static inline bool _Scheduler_SMP_Ask_for_help( - Scheduler_Context *context, - Thread_Control *thread, - Scheduler_Node *node, - Chain_Node_order order, - Scheduler_SMP_Insert insert_ready, - Scheduler_SMP_Insert insert_scheduled, - Scheduler_SMP_Move move_from_scheduled_to_ready, - Scheduler_SMP_Get_lowest_scheduled get_lowest_scheduled, - Scheduler_SMP_Allocate_processor allocate_processor -) -{ - Scheduler_Node *lowest_scheduled; - ISR_lock_Context lock_context; - bool success; - - lowest_scheduled = ( *get_lowest_scheduled )( context, node ); - - _Thread_Scheduler_acquire_critical( thread, &lock_context ); - - if ( thread->Scheduler.state == THREAD_SCHEDULER_READY ) { - Scheduler_SMP_Node_state node_state; - - node_state = _Scheduler_SMP_Node_state( node ); - - if ( node_state == SCHEDULER_SMP_NODE_BLOCKED ) { - Priority_Control insert_priority; - - insert_priority = _Scheduler_SMP_Node_priority( node ); - - if ( ( *order )( &insert_priority, &lowest_scheduled->Node.Chain ) ) { - _Thread_Scheduler_cancel_need_for_help( - thread, - _Thread_Get_CPU( thread ) - ); - _Scheduler_Thread_change_state( thread, THREAD_SCHEDULER_SCHEDULED ); - _Thread_Scheduler_release_critical( thread, &lock_context ); - - _Scheduler_SMP_Preempt( - context, - node, - lowest_scheduled, - allocate_processor - ); - - ( *insert_scheduled )( context, node, insert_priority ); - ( *move_from_scheduled_to_ready )( context, lowest_scheduled ); - - _Scheduler_Release_idle_thread( - context, - lowest_scheduled, - _Scheduler_SMP_Release_idle_thread - ); - success = true; - } else { - _Thread_Scheduler_release_critical( thread, &lock_context ); - _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_READY ); - ( *insert_ready )( context, node, insert_priority ); - success = false; - } - } else if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) { - _Thread_Scheduler_cancel_need_for_help( - thread, - _Thread_Get_CPU( thread ) - ); - _Scheduler_Discard_idle_thread( - context, - thread, - node, - _Scheduler_SMP_Release_idle_thread - ); - _Scheduler_Thread_change_state( thread, THREAD_SCHEDULER_SCHEDULED ); - _Thread_Scheduler_release_critical( thread, &lock_context ); - success = true; - } else { - _Thread_Scheduler_release_critical( thread, &lock_context ); - success = false; - } - } else { - _Thread_Scheduler_release_critical( thread, &lock_context ); - success = false; - } - - return success; -} - -static inline void _Scheduler_SMP_Reconsider_help_request( - Scheduler_Context *context, - Thread_Control *thread, - Scheduler_Node *node, - Scheduler_SMP_Extract extract_from_ready -) -{ - ISR_lock_Context lock_context; - - _Thread_Scheduler_acquire_critical( thread, &lock_context ); - - if ( - thread->Scheduler.state == THREAD_SCHEDULER_SCHEDULED - && _Scheduler_SMP_Node_state( node ) == SCHEDULER_SMP_NODE_READY - && node->sticky_level == 1 - ) { - _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_BLOCKED ); - ( *extract_from_ready )( context, node ); - } - - _Thread_Scheduler_release_critical( thread, &lock_context ); -} - -static inline void _Scheduler_SMP_Withdraw_node( - Scheduler_Context *context, - Thread_Control *thread, - Scheduler_Node *node, - Thread_Scheduler_state next_state, - Scheduler_SMP_Extract extract_from_ready, - Scheduler_SMP_Get_highest_ready get_highest_ready, - Scheduler_SMP_Move move_from_ready_to_scheduled, - Scheduler_SMP_Allocate_processor allocate_processor -) -{ - ISR_lock_Context lock_context; - Scheduler_SMP_Node_state node_state; - - _Thread_Scheduler_acquire_critical( thread, &lock_context ); - - node_state = _Scheduler_SMP_Node_state( node ); - _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_BLOCKED ); - - if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) { - Per_CPU_Control *thread_cpu; - - thread_cpu = _Thread_Get_CPU( thread ); - _Scheduler_Thread_change_state( thread, next_state ); - _Thread_Scheduler_release_critical( thread, &lock_context ); - - _Scheduler_SMP_Extract_from_scheduled( node ); - _Scheduler_SMP_Schedule_highest_ready( - context, - node, - thread_cpu, - extract_from_ready, - get_highest_ready, - move_from_ready_to_scheduled, - allocate_processor - ); - } else if ( node_state == SCHEDULER_SMP_NODE_READY ) { - _Thread_Scheduler_release_critical( thread, &lock_context ); - ( *extract_from_ready )( context, node ); - } else { - _Assert( node_state == SCHEDULER_SMP_NODE_BLOCKED ); - _Thread_Scheduler_release_critical( thread, &lock_context ); - } -} - -static inline void _Scheduler_SMP_Do_start_idle( - Scheduler_Context *context, - Thread_Control *idle, - Per_CPU_Control *cpu, - Scheduler_SMP_Register_idle register_idle -) -{ - Scheduler_SMP_Context *self; - Scheduler_SMP_Node *node; - - self = _Scheduler_SMP_Get_self( context ); - node = _Scheduler_SMP_Thread_get_node( idle ); - - _Scheduler_Thread_change_state( idle, THREAD_SCHEDULER_SCHEDULED ); - node->state = SCHEDULER_SMP_NODE_SCHEDULED; - - _Thread_Set_CPU( idle, cpu ); - ( *register_idle )( context, &node->Base, cpu ); - _Chain_Append_unprotected( &self->Scheduled, &node->Base.Node.Chain ); - _Scheduler_SMP_Release_idle_thread( &self->Base, idle ); -} - -static inline void _Scheduler_SMP_Add_processor( - Scheduler_Context *context, - Thread_Control *idle, - Scheduler_SMP_Has_ready has_ready, - Scheduler_SMP_Enqueue enqueue_scheduled, - Scheduler_SMP_Register_idle register_idle -) -{ - Scheduler_SMP_Context *self; - Scheduler_Node *node; - - self = _Scheduler_SMP_Get_self( context ); - idle->Scheduler.state = THREAD_SCHEDULER_SCHEDULED; - _Scheduler_SMP_Release_idle_thread( &self->Base, idle ); - node = _Thread_Scheduler_get_home_node( idle ); - _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_SCHEDULED ); - ( *register_idle )( context, node, _Thread_Get_CPU( idle ) ); - - if ( ( *has_ready )( &self->Base ) ) { - Priority_Control insert_priority; - - insert_priority = _Scheduler_SMP_Node_priority( node ); - insert_priority = SCHEDULER_PRIORITY_APPEND( insert_priority ); - ( *enqueue_scheduled )( &self->Base, node, insert_priority ); - } else { - _Chain_Append_unprotected( &self->Scheduled, &node->Node.Chain ); - } -} - -static inline Thread_Control *_Scheduler_SMP_Remove_processor( - Scheduler_Context *context, - Per_CPU_Control *cpu, - Scheduler_SMP_Extract extract_from_ready, - Scheduler_SMP_Enqueue enqueue -) -{ - Scheduler_SMP_Context *self; - Chain_Node *chain_node; - Scheduler_Node *victim_node; - Thread_Control *victim_user; - Thread_Control *victim_owner; - Thread_Control *idle; - - self = _Scheduler_SMP_Get_self( context ); - chain_node = _Chain_First( &self->Scheduled ); - - do { - _Assert( chain_node != _Chain_Immutable_tail( &self->Scheduled ) ); - victim_node = (Scheduler_Node *) chain_node; - victim_user = _Scheduler_Node_get_user( victim_node ); - chain_node = _Chain_Next( chain_node ); - } while ( _Thread_Get_CPU( victim_user ) != cpu ); - - _Scheduler_SMP_Extract_from_scheduled( victim_node ); - victim_owner = _Scheduler_Node_get_owner( victim_node ); - - if ( !victim_owner->is_idle ) { - Scheduler_Node *idle_node; - - _Scheduler_Release_idle_thread( - &self->Base, - victim_node, - _Scheduler_SMP_Release_idle_thread - ); - idle = _Scheduler_SMP_Get_idle_thread( &self->Base ); - idle_node = _Thread_Scheduler_get_home_node( idle ); - ( *extract_from_ready )( &self->Base, idle_node ); - _Scheduler_SMP_Preempt( - &self->Base, - idle_node, - victim_node, - _Scheduler_SMP_Allocate_processor_exact - ); - - if ( !_Chain_Is_empty( &self->Scheduled ) ) { - Priority_Control insert_priority; - - insert_priority = _Scheduler_SMP_Node_priority( victim_node ); - insert_priority = SCHEDULER_PRIORITY_APPEND( insert_priority ); - ( *enqueue )( context, victim_node, insert_priority ); - } - } else { - _Assert( victim_owner == victim_user ); - _Assert( _Scheduler_Node_get_idle( victim_node ) == NULL ); - idle = victim_owner; - _Scheduler_SMP_Exctract_idle_thread( idle ); - } - - return idle; -} - -static inline void _Scheduler_SMP_Set_affinity( - Scheduler_Context *context, - Thread_Control *thread, - Scheduler_Node *node, - void *arg, - Scheduler_SMP_Set_affinity set_affinity, - Scheduler_SMP_Extract extract_from_ready, - Scheduler_SMP_Get_highest_ready get_highest_ready, - Scheduler_SMP_Move move_from_ready_to_scheduled, - Scheduler_SMP_Enqueue enqueue, - Scheduler_SMP_Allocate_processor allocate_processor -) -{ - Scheduler_SMP_Node_state node_state; - Priority_Control insert_priority; - - node_state = _Scheduler_SMP_Node_state( node ); - insert_priority = _Scheduler_SMP_Node_priority( node ); - insert_priority = SCHEDULER_PRIORITY_APPEND( insert_priority ); - - if ( node_state == SCHEDULER_SMP_NODE_SCHEDULED ) { - _Scheduler_SMP_Extract_from_scheduled( node ); - _Scheduler_SMP_Preempt_and_schedule_highest_ready( - context, - node, - _Thread_Get_CPU( thread ), - extract_from_ready, - get_highest_ready, - move_from_ready_to_scheduled, - allocate_processor - ); - ( *set_affinity )( context, node, arg ); - ( *enqueue )( context, node, insert_priority ); - } else if ( node_state == SCHEDULER_SMP_NODE_READY ) { - ( *extract_from_ready )( context, node ); - ( *set_affinity )( context, node, arg ); - ( *enqueue )( context, node, insert_priority ); - } else { - ( *set_affinity )( context, node, arg ); - } -} - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_SCORE_SCHEDULERSMPIMPL_H */ diff --git a/cpukit/score/include/rtems/score/schedulerstrongapa.h b/cpukit/score/include/rtems/score/schedulerstrongapa.h deleted file mode 100644 index d961f20c68..0000000000 --- a/cpukit/score/include/rtems/score/schedulerstrongapa.h +++ /dev/null @@ -1,171 +0,0 @@ -/** - * @file - * - * @ingroup ScoreSchedulerStrongAPA - * - * @brief Strong APA Scheduler API - */ - -/* - * Copyright (c) 2013, 2016 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SCHEDULERSTRONGAPA_H -#define _RTEMS_SCORE_SCHEDULERSTRONGAPA_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup ScoreSchedulerStrongAPA Strong APA Scheduler - * - * @ingroup ScoreSchedulerSMP - * - * This is an implementation of the global fixed priority scheduler (G-FP). It - * uses one ready chain per priority to ensure constant time insert operations. - * The scheduled chain uses linear insert operations and has at most processor - * count entries. Since the processor and priority count are constants all - * scheduler operations complete in a bounded execution time. - * - * The the_thread preempt mode will be ignored. - * - * @{ - */ - -/** - * @brief Scheduler context specialization for Strong APA - * schedulers. - */ -typedef struct { - Scheduler_SMP_Context Base; - Priority_bit_map_Control Bit_map; - Chain_Control Ready[ RTEMS_ZERO_LENGTH_ARRAY ]; -} Scheduler_strong_APA_Context; - -/** - * @brief Scheduler node specialization for Strong APA - * schedulers. - */ -typedef struct { - /** - * @brief SMP scheduler node. - */ - Scheduler_SMP_Node Base; - - /** - * @brief The associated ready queue of this node. - */ - Scheduler_priority_Ready_queue Ready_queue; -} Scheduler_strong_APA_Node; - -/** - * @brief Entry points for the Strong APA Scheduler. - */ -#define SCHEDULER_STRONG_APA_ENTRY_POINTS \ - { \ - _Scheduler_strong_APA_Initialize, \ - _Scheduler_default_Schedule, \ - _Scheduler_strong_APA_Yield, \ - _Scheduler_strong_APA_Block, \ - _Scheduler_strong_APA_Unblock, \ - _Scheduler_strong_APA_Update_priority, \ - _Scheduler_default_Map_priority, \ - _Scheduler_default_Unmap_priority, \ - _Scheduler_strong_APA_Ask_for_help, \ - _Scheduler_strong_APA_Reconsider_help_request, \ - _Scheduler_strong_APA_Withdraw_node, \ - _Scheduler_strong_APA_Add_processor, \ - _Scheduler_strong_APA_Remove_processor, \ - _Scheduler_strong_APA_Node_initialize, \ - _Scheduler_default_Node_destroy, \ - _Scheduler_default_Release_job, \ - _Scheduler_default_Cancel_job, \ - _Scheduler_default_Tick, \ - _Scheduler_SMP_Start_idle \ - SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY \ - } - -void _Scheduler_strong_APA_Initialize( const Scheduler_Control *scheduler ); - -void _Scheduler_strong_APA_Node_initialize( - const Scheduler_Control *scheduler, - Scheduler_Node *node, - Thread_Control *the_thread, - Priority_Control priority -); - -void _Scheduler_strong_APA_Block( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -); - -void _Scheduler_strong_APA_Unblock( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -); - -void _Scheduler_strong_APA_Update_priority( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -); - -bool _Scheduler_strong_APA_Ask_for_help( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -); - -void _Scheduler_strong_APA_Reconsider_help_request( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -); - -void _Scheduler_strong_APA_Withdraw_node( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node, - Thread_Scheduler_state next_state -); - -void _Scheduler_strong_APA_Add_processor( - const Scheduler_Control *scheduler, - Thread_Control *idle -); - -Thread_Control *_Scheduler_strong_APA_Remove_processor( - const Scheduler_Control *scheduler, - struct Per_CPU_Control *cpu -); - -void _Scheduler_strong_APA_Yield( - const Scheduler_Control *scheduler, - Thread_Control *the_thread, - Scheduler_Node *node -); - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_SCORE_SCHEDULERSTRONGAPA_H */ diff --git a/cpukit/score/include/rtems/score/semaphoreimpl.h b/cpukit/score/include/rtems/score/semaphoreimpl.h deleted file mode 100644 index a7857db93e..0000000000 --- a/cpukit/score/include/rtems/score/semaphoreimpl.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2015, 2017 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SEMAPHOREIMPL_H -#define _RTEMS_SCORE_SEMAPHOREIMPL_H - -#include - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -typedef struct { - Thread_queue_Syslock_queue Queue; - unsigned int count; -} Sem_Control; - -#define SEMAPHORE_TQ_OPERATIONS &_Thread_queue_Operations_priority - -static inline Sem_Control *_Sem_Get( struct _Semaphore_Control *_sem ) -{ - return (Sem_Control *) _sem; -} - -static inline Thread_Control *_Sem_Queue_acquire_critical( - Sem_Control *sem, - Thread_queue_Context *queue_context -) -{ - Thread_Control *executing; - - executing = _Thread_Executing; - _Thread_queue_Queue_acquire_critical( - &sem->Queue.Queue, - &executing->Potpourri_stats, - &queue_context->Lock_context.Lock_context - ); - - return executing; -} - -static inline void _Sem_Queue_release( - Sem_Control *sem, - ISR_Level level, - Thread_queue_Context *queue_context -) -{ - _Thread_queue_Queue_release_critical( - &sem->Queue.Queue, - &queue_context->Lock_context.Lock_context - ); - _ISR_Local_enable( level ); -} - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_SCORE_SEMAPHOREIMPL_H */ diff --git a/cpukit/score/include/rtems/score/smp.h b/cpukit/score/include/rtems/score/smp.h deleted file mode 100644 index 469025e5dc..0000000000 --- a/cpukit/score/include/rtems/score/smp.h +++ /dev/null @@ -1,64 +0,0 @@ -/** - * @file - * - * @ingroup ScoreSMP - * - * @brief SuperCore SMP Support API - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SMP_H -#define _RTEMS_SCORE_SMP_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ScoreSMP SMP Support - * - * @ingroup Score - * - * This defines the interface of the SuperCore SMP support. - * - * @{ - */ - -#if defined( RTEMS_SMP ) - extern uint32_t _SMP_Processor_count; - - static inline uint32_t _SMP_Get_processor_count( void ) - { - return _SMP_Processor_count; - } -#else - #define _SMP_Get_processor_count() UINT32_C(1) -#endif - -#if defined( RTEMS_SMP ) - static inline uint32_t _SMP_Get_current_processor( void ) - { - return _CPU_SMP_Get_current_processor(); - } -#else - #define _SMP_Get_current_processor() UINT32_C(0) -#endif - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/smpbarrier.h b/cpukit/score/include/rtems/score/smpbarrier.h deleted file mode 100644 index fddf7bb1cd..0000000000 --- a/cpukit/score/include/rtems/score/smpbarrier.h +++ /dev/null @@ -1,125 +0,0 @@ -/** - * @file - * - * @ingroup ScoreSMPBarrier - * - * @brief SMP Barrier API - */ - -/* - * Copyright (c) 2013-2014 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SMPBARRIER_H -#define _RTEMS_SCORE_SMPBARRIER_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup ScoreSMPBarrier SMP Barriers - * - * @ingroup Score - * - * @brief The SMP barrier provides barrier synchronization for SMP systems at - * the lowest level. - * - * The SMP barrier is implemented as a sense barrier, see also Herlihy and - * Shavit, "The Art of Multiprocessor Programming", 17.3 Sense-Reversing - * Barrier. - * - * @{ - */ - -/** - * @brief SMP barrier control. - */ -typedef struct { - Atomic_Uint value; - Atomic_Uint sense; -} SMP_barrier_Control; - -/** - * @brief SMP barrier per-thread state. - * - * Each user of the barrier must provide this per-thread state. - */ -typedef struct { - unsigned int sense; -} SMP_barrier_State; - -/** - * @brief SMP barrier control initializer for static initialization. - */ -#define SMP_BARRIER_CONTROL_INITIALIZER \ - { ATOMIC_INITIALIZER_UINT( 0U ), ATOMIC_INITIALIZER_UINT( 0U ) } - -/** - * @brief SMP barrier per-thread state initializer for static initialization. - */ -#define SMP_BARRIER_STATE_INITIALIZER { 0U } - -/** - * @brief Initializes a SMP barrier control. - * - * Concurrent initialization leads to unpredictable results. - * - * @param[out] control The SMP barrier control. - */ -static inline void _SMP_barrier_Control_initialize( - SMP_barrier_Control *control -) -{ - _Atomic_Init_uint( &control->value, 0U ); - _Atomic_Init_uint( &control->sense, 0U ); -} - -/** - * @brief Initializes a SMP barrier per-thread state. - * - * @param[out] state The SMP barrier control. - */ -static inline void _SMP_barrier_State_initialize( - SMP_barrier_State *state -) -{ - state->sense = 0U; -} - -/** - * @brief Waits on the SMP barrier until count threads rendezvoused. - * - * @param[in, out] control The SMP barrier control. - * @param[in, out] state The SMP barrier per-thread state. - * @param[in] count The thread count bound to rendezvous. - * - * @retval true This processor performed the barrier release. - * @retval false Otherwise. - */ -bool _SMP_barrier_Wait( - SMP_barrier_Control *control, - SMP_barrier_State *state, - unsigned int count -); - -/**@}*/ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_SCORE_SMPBARRIER_H */ diff --git a/cpukit/score/include/rtems/score/smpimpl.h b/cpukit/score/include/rtems/score/smpimpl.h deleted file mode 100644 index 48e6a12498..0000000000 --- a/cpukit/score/include/rtems/score/smpimpl.h +++ /dev/null @@ -1,354 +0,0 @@ -/** - * @file - * - * @ingroup ScoreSMPImpl - * - * @brief SuperCore SMP Implementation - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SMPIMPL_H -#define _RTEMS_SCORE_SMPIMPL_H - -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ScoreSMP SMP Support - * - * @ingroup Score - * - * This defines the interface of the SuperCore SMP support. - * - * @{ - */ - -/** - * @brief SMP message to request a processor shutdown. - * - * @see _SMP_Send_message(). - */ -#define SMP_MESSAGE_SHUTDOWN 0x1UL - -/** - * @brief SMP message to request a test handler invocation. - * - * @see _SMP_Send_message(). - */ -#define SMP_MESSAGE_TEST 0x2UL - -/** - * @brief SMP message to request a multicast action. - * - * @see _SMP_Send_message(). - */ -#define SMP_MESSAGE_MULTICAST_ACTION 0x4UL - -/** - * @brief SMP message to request a clock tick. - * - * This message is provided for systems without a proper interrupt affinity - * support and may be used by the clock driver. - * - * @see _SMP_Send_message(). - */ -#define SMP_MESSAGE_CLOCK_TICK 0x8UL - -/** - * @brief SMP fatal codes. - */ -typedef enum { - SMP_FATAL_BOOT_PROCESSOR_NOT_ASSIGNED_TO_SCHEDULER, - SMP_FATAL_MANDATORY_PROCESSOR_NOT_PRESENT, - SMP_FATAL_MULTITASKING_START_ON_INVALID_PROCESSOR, - SMP_FATAL_MULTITASKING_START_ON_UNASSIGNED_PROCESSOR, - SMP_FATAL_SHUTDOWN, - SMP_FATAL_SHUTDOWN_RESPONSE, - SMP_FATAL_START_OF_MANDATORY_PROCESSOR_FAILED -} SMP_Fatal_code; - -static inline void _SMP_Fatal( SMP_Fatal_code code ) -{ - _Terminate( RTEMS_FATAL_SOURCE_SMP, code ); -} - -/** - * @brief Initialize SMP Handler - * - * This method initialize the SMP Handler. - */ -#if defined( RTEMS_SMP ) - void _SMP_Handler_initialize( void ); -#else - #define _SMP_Handler_initialize() \ - do { } while ( 0 ) -#endif - -#if defined( RTEMS_SMP ) - -/** - * @brief Set of online processors. - * - * A processor is online if was started during system initialization. In this - * case its corresponding bit in the mask is set. - * - * @see _SMP_Handler_initialize(). - */ -extern Processor_mask _SMP_Online_processors; - -/** - * @brief Performs high-level initialization of a secondary processor and runs - * the application threads. - * - * The low-level initialization code must call this function to hand over the - * control of this processor to RTEMS. Interrupts must be disabled. It must - * be possible to send inter-processor interrupts to this processor. Since - * interrupts are disabled the inter-processor interrupt delivery is postponed - * until interrupts are enabled the first time. Interrupts are enabled during - * the execution begin of threads in case they have interrupt level zero (this - * is the default). - * - * The pre-requisites for the call to this function are - * - disabled interrupts, - * - delivery of inter-processor interrupts is possible, - * - a valid stack pointer and enough stack space, - * - a valid code memory, and - * - a valid BSS section. - * - * This function must not be called by the main processor. The main processor - * uses _Thread_Start_multitasking() instead. - * - * This function does not return to the caller. - */ -void _SMP_Start_multitasking_on_secondary_processor( void ) - RTEMS_NO_RETURN; - -typedef void ( *SMP_Test_message_handler )( Per_CPU_Control *cpu_self ); - -extern SMP_Test_message_handler _SMP_Test_message_handler; - -/** - * @brief Sets the handler for test messages. - * - * This handler can be used to test the inter-processor interrupt - * implementation. - */ -static inline void _SMP_Set_test_message_handler( - SMP_Test_message_handler handler -) -{ - _SMP_Test_message_handler = handler; -} - -/** - * @brief Processes all pending multicast actions. - */ -void _SMP_Multicast_actions_process( void ); - -/** - * @brief Interrupt handler for inter-processor interrupts. - * - * @return The received message. - */ -static inline long unsigned _SMP_Inter_processor_interrupt_handler( void ) -{ - Per_CPU_Control *cpu_self; - unsigned long message; - - cpu_self = _Per_CPU_Get(); - - /* - * In the common case the inter-processor interrupt is issued to carry out a - * thread dispatch. - */ - cpu_self->dispatch_necessary = true; - - message = _Atomic_Exchange_ulong( - &cpu_self->message, - 0, - ATOMIC_ORDER_ACQUIRE - ); - - if ( message != 0 ) { - if ( ( message & SMP_MESSAGE_SHUTDOWN ) != 0 ) { - _SMP_Fatal( SMP_FATAL_SHUTDOWN_RESPONSE ); - /* does not continue past here */ - } - - if ( ( message & SMP_MESSAGE_TEST ) != 0 ) { - ( *_SMP_Test_message_handler )( cpu_self ); - } - - if ( ( message & SMP_MESSAGE_MULTICAST_ACTION ) != 0 ) { - _SMP_Multicast_actions_process(); - } - } - - return message; -} - -/** - * @brief Returns true, if the processor with the specified index should be - * started. - * - * @param[in] cpu_index The processor index. - * - * @retval true The processor should be started. - * @retval false Otherwise. - */ -bool _SMP_Should_start_processor( uint32_t cpu_index ); - -/** - * @brief Sends an SMP message to a processor. - * - * The target processor may be the sending processor. - * - * @param[in] cpu_index The target processor of the message. - * @param[in] message The message. - */ -void _SMP_Send_message( uint32_t cpu_index, unsigned long message ); - -/** - * @brief Sends an SMP message to all other online processors. - * - * @param[in] message The message. - */ -void _SMP_Send_message_broadcast( - unsigned long message -); - -/** - * @brief Sends an SMP message to a set of processors. - * - * The sending processor may be part of the set. - * - * @param[in] targets The set of processors to send the message. - * @param[in] message The message. - */ -void _SMP_Send_message_multicast( - const Processor_mask *targets, - unsigned long message -); - -typedef void ( *SMP_Action_handler )( void *arg ); - -/** - * @brief Initiates an SMP multicast action to a set of processors. - * - * The current processor may be part of the set. - * - * @param[in] setsize The size of the set of target processors of the message. - * @param[in] cpus The set of target processors of the message. - * @param[in] handler The multicast action handler. - * @param[in] arg The multicast action argument. - */ -void _SMP_Multicast_action( - const size_t setsize, - const cpu_set_t *cpus, - SMP_Action_handler handler, - void *arg -); - -/** - * @brief Executes a handler with argument on the specified processor on behalf - * of the boot processor. - * - * The calling processor must be the boot processor. In case the specified - * processor is not online or not in the - * PER_CPU_STATE_READY_TO_START_MULTITASKING state, then no action is - * performed. - * - * @param cpu The processor to execute the action. - * @param handler The handler of the action. - * @param arg The argument of the action. - * - * @retval true The handler executed on the specified processor. - * @retval false Otherwise. - * - * @see _SMP_Before_multitasking_action_broadcast(). - */ -bool _SMP_Before_multitasking_action( - Per_CPU_Control *cpu, - SMP_Action_handler handler, - void *arg -); - -/** - * @brief Executes a handler with argument on all online processors except the - * boot processor on behalf of the boot processor. - * - * The calling processor must be the boot processor. - * - * @param handler The handler of the action. - * @param arg The argument of the action. - * - * @retval true The handler executed on all online processors except the boot - * processor. - * @retval false Otherwise. - * - * @see _SMP_Before_multitasking_action(). - */ -bool _SMP_Before_multitasking_action_broadcast( - SMP_Action_handler handler, - void *arg -); - -#endif /* defined( RTEMS_SMP ) */ - -/** - * @brief Requests a multitasking start on all configured and available - * processors. - */ -#if defined( RTEMS_SMP ) - void _SMP_Request_start_multitasking( void ); -#else - #define _SMP_Request_start_multitasking() \ - do { } while ( 0 ) -#endif - -/** - * @brief Requests a shutdown of all processors. - * - * This function is a part of the system termination procedure. - * - * @see _Terminate(). - */ -#if defined( RTEMS_SMP ) - void _SMP_Request_shutdown( void ); -#else - #define _SMP_Request_shutdown() \ - do { } while ( 0 ) -#endif - -RTEMS_INLINE_ROUTINE const Processor_mask *_SMP_Get_online_processors( void ) -{ -#if defined(RTEMS_SMP) - return &_SMP_Online_processors; -#else - return &_Processor_mask_The_one_and_only; -#endif -} - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/smplock.h b/cpukit/score/include/rtems/score/smplock.h deleted file mode 100644 index a156edfd92..0000000000 --- a/cpukit/score/include/rtems/score/smplock.h +++ /dev/null @@ -1,327 +0,0 @@ -/** - * @file - * - * @ingroup ScoreSMPLock - * - * @brief SMP Lock API - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * Copyright (c) 2013, 2016 embedded brains GmbH - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SMPLOCK_H -#define _RTEMS_SCORE_SMPLOCK_H - -#include - -#if defined(RTEMS_SMP) - -#include -#include -#include - -#if defined(RTEMS_DEBUG) -#include -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup ScoreSMPLock SMP Locks - * - * @ingroup Score - * - * @brief The SMP lock provides mutual exclusion for SMP systems at the lowest - * level. - * - * The SMP lock is implemented as a ticket lock. This provides fairness in - * case of concurrent lock attempts. - * - * This SMP lock API uses a local context for acquire and release pairs. Such - * a context may be used to implement for example the Mellor-Crummey and Scott - * (MCS) locks in the future. - * - * @{ - */ - -#if defined(RTEMS_DEBUG) || defined(RTEMS_PROFILING) -#define RTEMS_SMP_LOCK_DO_NOT_INLINE -#endif - -/** - * @brief SMP lock control. - */ -typedef struct { - SMP_ticket_lock_Control Ticket_lock; -#if defined(RTEMS_DEBUG) - /** - * @brief The index of the owning processor of this lock. - * - * The processor index is used instead of the executing thread, so that this - * works in interrupt and system initialization context. It is assumed that - * thread dispatching is disabled in SMP lock critical sections. - * - * In case the lock is free, then the value of this field is - * SMP_LOCK_NO_OWNER. - * - * @see _SMP_lock_Is_owner(). - */ - uint32_t owner; -#endif -#if defined(RTEMS_PROFILING) - SMP_lock_Stats Stats; -#endif -} SMP_lock_Control; - -/** - * @brief Local SMP lock context for acquire and release pairs. - */ -typedef struct { - ISR_Level isr_level; -#if defined(RTEMS_DEBUG) - SMP_lock_Control *lock_used_for_acquire; -#endif -#if defined(RTEMS_PROFILING) - SMP_lock_Stats_context Stats_context; -#endif -} SMP_lock_Context; - -#if defined(RTEMS_DEBUG) -#define SMP_LOCK_NO_OWNER 0 -#endif - -/** - * @brief SMP lock control initializer for static initialization. - */ -#if defined(RTEMS_DEBUG) && defined(RTEMS_PROFILING) - #define SMP_LOCK_INITIALIZER( name ) \ - { \ - SMP_TICKET_LOCK_INITIALIZER, \ - SMP_LOCK_NO_OWNER, \ - SMP_LOCK_STATS_INITIALIZER( name ) \ - } -#elif defined(RTEMS_DEBUG) - #define SMP_LOCK_INITIALIZER( name ) \ - { SMP_TICKET_LOCK_INITIALIZER, SMP_LOCK_NO_OWNER } -#elif defined(RTEMS_PROFILING) - #define SMP_LOCK_INITIALIZER( name ) \ - { SMP_TICKET_LOCK_INITIALIZER, SMP_LOCK_STATS_INITIALIZER( name ) } -#else - #define SMP_LOCK_INITIALIZER( name ) { SMP_TICKET_LOCK_INITIALIZER } -#endif - -static inline void _SMP_lock_Initialize_inline( - SMP_lock_Control *lock, - const char *name -) -{ - _SMP_ticket_lock_Initialize( &lock->Ticket_lock ); -#if defined(RTEMS_DEBUG) - lock->owner = SMP_LOCK_NO_OWNER; -#endif -#if defined(RTEMS_PROFILING) - _SMP_lock_Stats_initialize( &lock->Stats, name ); -#else - (void) name; -#endif -} - -/** - * @brief Initializes an SMP lock. - * - * Concurrent initialization leads to unpredictable results. - * - * @param[in] lock The SMP lock control. - * @param[in] name The name for the SMP lock statistics. This name must be - * persistent throughout the life time of this statistics block. - */ -#if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE) -void _SMP_lock_Initialize( - SMP_lock_Control *lock, - const char * name -); -#else -#define _SMP_lock_Initialize( lock, name ) \ - _SMP_lock_Initialize_inline( lock, name ) -#endif - -static inline void _SMP_lock_Destroy_inline( SMP_lock_Control *lock ) -{ - _SMP_ticket_lock_Destroy( &lock->Ticket_lock ); - _SMP_lock_Stats_destroy( &lock->Stats ); -} - -/** - * @brief Destroys an SMP lock. - * - * Concurrent destruction leads to unpredictable results. - * - * @param[in] lock The SMP lock control. - */ -#if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE) -void _SMP_lock_Destroy( SMP_lock_Control *lock ); -#else -#define _SMP_lock_Destroy( lock ) \ - _SMP_lock_Destroy_inline( lock ) -#endif - -#if defined(RTEMS_DEBUG) -static inline uint32_t _SMP_lock_Who_am_I( void ) -{ - /* - * The CPU index starts with zero. Increment it by one, to allow global SMP - * locks to reside in the BSS section. - */ - return _SMP_Get_current_processor() + 1; -} -#endif - -static inline void _SMP_lock_Acquire_inline( - SMP_lock_Control *lock, - SMP_lock_Context *context -) -{ -#if defined(RTEMS_DEBUG) - context->lock_used_for_acquire = lock; -#else - (void) context; -#endif - _SMP_ticket_lock_Acquire( - &lock->Ticket_lock, - &lock->Stats, - &context->Stats_context - ); -#if defined(RTEMS_DEBUG) - lock->owner = _SMP_lock_Who_am_I(); -#endif -} - -/** - * @brief Acquires an SMP lock. - * - * This function will not disable interrupts. The caller must ensure that the - * current thread of execution is not interrupted indefinite once it obtained - * the SMP lock. - * - * @param[in] lock The SMP lock control. - * @param[in] context The local SMP lock context for an acquire and release - * pair. - */ -void _SMP_lock_Acquire( - SMP_lock_Control *lock, - SMP_lock_Context *context -); - -static inline void _SMP_lock_Release_inline( - SMP_lock_Control *lock, - SMP_lock_Context *context -) -{ -#if defined(RTEMS_DEBUG) - _Assert( context->lock_used_for_acquire == lock ); - context->lock_used_for_acquire = NULL; - _Assert( lock->owner == _SMP_lock_Who_am_I() ); - lock->owner = SMP_LOCK_NO_OWNER; -#else - (void) context; -#endif - _SMP_ticket_lock_Release( - &lock->Ticket_lock, - &context->Stats_context - ); -} - -/** - * @brief Releases an SMP lock. - * - * @param[in] lock The SMP lock control. - * @param[in] context The local SMP lock context for an acquire and release - * pair. - */ -#if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE) -void _SMP_lock_Release( - SMP_lock_Control *lock, - SMP_lock_Context *context -); -#else -#define _SMP_lock_Release( lock, context ) \ - _SMP_lock_Release_inline( lock, context ) -#endif - -static inline void _SMP_lock_ISR_disable_and_acquire_inline( - SMP_lock_Control *lock, - SMP_lock_Context *context -) -{ - _ISR_Local_disable( context->isr_level ); - _SMP_lock_Acquire_inline( lock, context ); -} - -/** - * @brief Disables interrupts and acquires the SMP lock. - * - * @param[in] lock The SMP lock control. - * @param[in] context The local SMP lock context for an acquire and release - * pair. - */ -void _SMP_lock_ISR_disable_and_acquire( - SMP_lock_Control *lock, - SMP_lock_Context *context -); - -static inline void _SMP_lock_Release_and_ISR_enable_inline( - SMP_lock_Control *lock, - SMP_lock_Context *context -) -{ - _SMP_lock_Release_inline( lock, context ); - _ISR_Local_enable( context->isr_level ); -} - -/** - * @brief Releases the SMP lock and enables interrupts. - * - * @param[in] lock The SMP lock control. - * @param[in] context The local SMP lock context for an acquire and release - * pair. - */ -#if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE) -void _SMP_lock_Release_and_ISR_enable( - SMP_lock_Control *lock, - SMP_lock_Context *context -); -#else -#define _SMP_lock_Release_and_ISR_enable( lock, context ) \ - _SMP_lock_Release_and_ISR_enable_inline( lock, context ) -#endif - -#if defined(RTEMS_DEBUG) -/** - * @brief Returns true, if the SMP lock is owned by the current processor, - * otherwise false. - * - * @param[in] lock The SMP lock control. - */ -bool _SMP_lock_Is_owner( const SMP_lock_Control *lock ); -#endif - -/**@}*/ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* RTEMS_SMP */ - -#endif /* _RTEMS_SCORE_SMPLOCK_H */ diff --git a/cpukit/score/include/rtems/score/smplockmcs.h b/cpukit/score/include/rtems/score/smplockmcs.h deleted file mode 100644 index 5a1ad23dc9..0000000000 --- a/cpukit/score/include/rtems/score/smplockmcs.h +++ /dev/null @@ -1,262 +0,0 @@ -/** - * @file - * - * @ingroup ScoreSMPLock - * - * @brief SMP Lock API - */ - -/* - * Copyright (c) 2016 embedded brains GmbH - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SMPLOCKMCS_H -#define _RTEMS_SCORE_SMPLOCKMCS_H - -#include - -#if defined(RTEMS_SMP) - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @addtogroup ScoreSMPLock - * - * @{ - */ - -/** - * @brief SMP Mellor-Crummey and Scott (MCS) lock context. - */ -typedef struct SMP_MCS_lock_Context { - /** - * @brief The next context on the queue if it exists. - */ - union { - /** - * @brief The next context as an atomic unsigned integer pointer value. - */ - Atomic_Uintptr atomic; - - /** - * @brief The next context as a normal pointer. - * - * Only provided for debugging purposes. - */ - struct SMP_MCS_lock_Context *normal; - } next; - - /** - * @brief Indicates if the lock is owned or free in case a previous context - * exits on the queue. - * - * This field is initialized to a non-zero value. The previous lock owner - * (which is the owner of the previous context) will set it to zero during - * its lock release. - */ - Atomic_Uint locked; - -#if defined(RTEMS_PROFILING) - SMP_lock_Stats_context Stats_context; - - unsigned int queue_length; -#endif -} SMP_MCS_lock_Context; - -/** - * @brief SMP Mellor-Crummey and Scott (MCS) lock control. - */ -typedef struct { - /** - * @brief The queue tail context. - * - * The lock is free, in case this field is zero, otherwise it is locked by - * the owner of the queue head. - */ - union { - /** - * @brief The queue tail context as an atomic unsigned integer pointer - * value. - */ - Atomic_Uintptr atomic; - - /** - * @brief The queue tail context as a normal pointer. - * - * Only provided for debugging purposes. - */ - struct SMP_MCS_lock_Context *normal; - } queue; -} SMP_MCS_lock_Control; - -/** - * @brief SMP MCS lock control initializer for static initialization. - */ -#define SMP_MCS_LOCK_INITIALIZER { { ATOMIC_INITIALIZER_UINTPTR( 0 ) } } - -/** - * @brief Initializes an SMP MCS lock. - * - * Concurrent initialization leads to unpredictable results. - * - * @param lock The SMP MCS lock control. - */ -static inline void _SMP_MCS_lock_Initialize( SMP_MCS_lock_Control *lock ) -{ - _Atomic_Init_uintptr( &lock->queue.atomic, 0 ); -} - -/** - * @brief Destroys an SMP MCS lock. - * - * Concurrent destruction leads to unpredictable results. - * - * @param lock The SMP MCS lock control. - */ -static inline void _SMP_MCS_lock_Destroy( SMP_MCS_lock_Control *lock ) -{ - (void) lock; -} - -static inline void _SMP_MCS_lock_Do_acquire( - SMP_MCS_lock_Control *lock, - SMP_MCS_lock_Context *context -#if defined(RTEMS_PROFILING) - , - SMP_lock_Stats *stats -#endif -) -{ - SMP_MCS_lock_Context *previous; -#if defined(RTEMS_PROFILING) - SMP_lock_Stats_acquire_context acquire_context; - - _SMP_lock_Stats_acquire_begin( &acquire_context ); - context->queue_length = 0; -#endif - - _Atomic_Store_uintptr( &context->next.atomic, 0, ATOMIC_ORDER_RELAXED ); - _Atomic_Store_uint( &context->locked, 1, ATOMIC_ORDER_RELAXED ); - - previous = (SMP_MCS_lock_Context *) _Atomic_Exchange_uintptr( - &lock->queue.atomic, - (uintptr_t) context, - ATOMIC_ORDER_ACQ_REL - ); - - if ( previous != NULL ) { - unsigned int locked; - - _Atomic_Store_uintptr( - &previous->next.atomic, - (uintptr_t) context, - ATOMIC_ORDER_RELAXED - ); - - do { - locked = _Atomic_Load_uint( &context->locked, ATOMIC_ORDER_ACQUIRE ); - } while ( locked != 0 ); - } - -#if defined(RTEMS_PROFILING) - _SMP_lock_Stats_acquire_end( - &acquire_context, - stats, - &context->Stats_context, - context->queue_length - ); -#endif -} - -/** - * @brief Acquires an SMP MCS lock. - * - * This function will not disable interrupts. The caller must ensure that the - * current thread of execution is not interrupted indefinite once it obtained - * the SMP MCS lock. - * - * @param lock The SMP MCS lock control. - * @param context The SMP MCS lock context. - * @param stats The SMP lock statistics. - */ -#if defined(RTEMS_PROFILING) - #define _SMP_MCS_lock_Acquire( lock, context, stats ) \ - _SMP_MCS_lock_Do_acquire( lock, context, stats ) -#else - #define _SMP_MCS_lock_Acquire( lock, context, stats ) \ - _SMP_MCS_lock_Do_acquire( lock, context ) -#endif - -/** - * @brief Releases an SMP MCS lock. - * - * @param lock The SMP MCS lock control. - * @param context The SMP MCS lock context. - */ -static inline void _SMP_MCS_lock_Release( - SMP_MCS_lock_Control *lock, - SMP_MCS_lock_Context *context -) -{ - SMP_MCS_lock_Context *next; - - next = (SMP_MCS_lock_Context *) _Atomic_Load_uintptr( - &context->next.atomic, - ATOMIC_ORDER_RELAXED - ); - - if ( next == NULL ) { - uintptr_t expected; - bool success; - - expected = (uintptr_t) context; - success = _Atomic_Compare_exchange_uintptr( - &lock->queue.atomic, - &expected, - 0, - ATOMIC_ORDER_RELEASE, - ATOMIC_ORDER_RELAXED - ); - - if ( success ) { -#if defined(RTEMS_PROFILING) - _SMP_lock_Stats_release_update( &context->Stats_context ); -#endif - /* Nobody waits. So, we are done */ - return; - } - - do { - next = (SMP_MCS_lock_Context *) _Atomic_Load_uintptr( - &context->next.atomic, - ATOMIC_ORDER_RELAXED - ); - } while ( next == NULL ); - } - -#if defined(RTEMS_PROFILING) - next->queue_length = context->queue_length + 1; - _SMP_lock_Stats_release_update( &context->Stats_context ); -#endif - - _Atomic_Store_uint( &next->locked, 0, ATOMIC_ORDER_RELEASE ); -} - -/**@}*/ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* RTEMS_SMP */ - -#endif /* _RTEMS_SCORE_SMPLOCKMCS_H */ diff --git a/cpukit/score/include/rtems/score/smplockseq.h b/cpukit/score/include/rtems/score/smplockseq.h deleted file mode 100644 index 5daaee9c6e..0000000000 --- a/cpukit/score/include/rtems/score/smplockseq.h +++ /dev/null @@ -1,176 +0,0 @@ -/** - * @file - * - * @ingroup ScoreSMPLock - * - * @brief SMP Lock API - */ - -/* - * Copyright (c) 2016 embedded brains GmbH - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SMPLOCKSEQ_H -#define _RTEMS_SCORE_SMPLOCKSEQ_H - -#include - -#if defined(RTEMS_SMP) - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @addtogroup ScoreSMPLock - * - * @{ - */ - -/** - * @brief SMP sequence lock control. - * - * The sequence lock offers a consistent data set for readers in the presence - * of at most one concurrent writer. Due to the read-modify-write operation in - * _SMP_sequence_lock_Read_retry() the data corresponding to the last written - * sequence number is observed. To allow multiple writers an additional SMP - * lock is necessary to serialize writes. - * - * See also Hans-J. Boehm, HP Laboratories, - * "Can Seqlocks Get Along With Programming Language Memory Models?", - * http://www.hpl.hp.com/techreports/2012/HPL-2012-68.pdf - */ -typedef struct { - /** - * @brief The sequence number. - * - * An odd value indicates that a write is in progress. - */ - Atomic_Uint sequence; -} SMP_sequence_lock_Control; - -/** - * @brief SMP sequence lock control initializer for static initialization. - */ -#define SMP_SEQUENCE_LOCK_INITIALIZER { ATOMIC_INITIALIZER_UINT( 0 ) } - -/** - * @brief Initializes an SMP sequence lock. - * - * Concurrent initialization leads to unpredictable results. - * - * @param lock The SMP sequence lock control. - */ -static inline void _SMP_sequence_lock_Initialize( SMP_sequence_lock_Control *lock ) -{ - _Atomic_Init_uint( &lock->sequence, 0 ); -} - -/** - * @brief Destroys an SMP sequence lock. - * - * Concurrent destruction leads to unpredictable results. - * - * @param lock The SMP sequence lock control. - */ -static inline void _SMP_sequence_lock_Destroy( SMP_sequence_lock_Control *lock ) -{ - (void) lock; -} - -/** - * @brief Begins an SMP sequence lock write operation. - * - * This function will not disable interrupts. The caller must ensure that the - * current thread of execution is not interrupted indefinite since this would - * starve readers. - * - * @param lock The SMP sequence lock control. - * - * @return The current sequence number. - */ -static inline unsigned int _SMP_sequence_lock_Write_begin( - SMP_sequence_lock_Control *lock -) -{ - unsigned int seq; - - seq = _Atomic_Load_uint( &lock->sequence, ATOMIC_ORDER_RELAXED ); - _Assert( seq % 2 == 0 ); - - _Atomic_Store_uint( &lock->sequence, seq + 1, ATOMIC_ORDER_RELAXED ); - - /* There is no atomic store with acquire/release semantics */ - _Atomic_Fence( ATOMIC_ORDER_ACQ_REL ); - - return seq; -} - -/** - * @brief Ends an SMP sequence lock write operation. - * - * @param lock The SMP sequence lock control. - * @param seq The sequence number returned by _SMP_sequence_lock_Write_begin(). - */ -static inline void _SMP_sequence_lock_Write_end( - SMP_sequence_lock_Control *lock, - unsigned int seq -) -{ - _Atomic_Store_uint( &lock->sequence, seq + 2, ATOMIC_ORDER_RELEASE ); -} - -/** - * @brief Begins an SMP sequence lock read operation. - * - * This function will not disable interrupts. - * - * @param lock The SMP sequence lock control. - * - * @return The current sequence number. - */ -static inline unsigned int _SMP_sequence_lock_Read_begin( - const SMP_sequence_lock_Control *lock -) -{ - return _Atomic_Load_uint( &lock->sequence, ATOMIC_ORDER_ACQUIRE ); -} - -/** - * @brief Ends an SMP sequence lock read operation and indicates if a retry is - * necessary. - * - * @param lock The SMP sequence lock control. - * @param seq The sequence number returned by _SMP_sequence_lock_Read_begin(). - * - * @retval true The read operation must be retried with a call to - * _SMP_sequence_lock_Read_begin(). - * @retval false Otherwise. - */ -static inline bool _SMP_sequence_lock_Read_retry( - SMP_sequence_lock_Control *lock, - unsigned int seq -) -{ - unsigned int seq2; - - seq2 = _Atomic_Fetch_add_uint( &lock->sequence, 0, ATOMIC_ORDER_RELEASE ); - return seq != seq2 || seq % 2 != 0; -} - -/**@}*/ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* RTEMS_SMP */ - -#endif /* _RTEMS_SCORE_SMPLOCKSEQ_H */ diff --git a/cpukit/score/include/rtems/score/smplockstats.h b/cpukit/score/include/rtems/score/smplockstats.h deleted file mode 100644 index dd8e06c81d..0000000000 --- a/cpukit/score/include/rtems/score/smplockstats.h +++ /dev/null @@ -1,277 +0,0 @@ -/** - * @file - * - * @ingroup ScoreSMPLock - * - * @brief SMP Lock API - */ - -/* - * Copyright (c) 2013, 2016 embedded brains GmbH - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SMPLOCKSTATS_H -#define _RTEMS_SCORE_SMPLOCKSTATS_H - -#include - -#if defined(RTEMS_SMP) - -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @addtogroup ScoreSMPLock - * - * @{ - */ - -#if defined(RTEMS_PROFILING) - -/** - * @brief Count of lock contention counters for lock statistics. - */ -#define SMP_LOCK_STATS_CONTENTION_COUNTS 4 - -/** - * @brief SMP lock statistics. - * - * The lock acquire attempt instant is the point in time right after the - * interrupt disable action in the lock acquire sequence. - * - * The lock acquire instant is the point in time right after the lock - * acquisition. This is the begin of the critical section code execution. - * - * The lock release instant is the point in time right before the interrupt - * enable action in the lock release sequence. - * - * The lock section time is the time elapsed between the lock acquire instant - * and the lock release instant. - * - * The lock acquire time is the time elapsed between the lock acquire attempt - * instant and the lock acquire instant. - */ -typedef struct { - /** - * @brief Node for SMP lock statistics chain. - */ - Chain_Node Node; - - /** - * @brief The maximum lock acquire time in CPU counter ticks. - */ - CPU_Counter_ticks max_acquire_time; - - /** - * @brief The maximum lock section time in CPU counter ticks. - */ - CPU_Counter_ticks max_section_time; - - /** - * @brief The count of lock uses. - * - * This value may overflow. - */ - uint64_t usage_count; - - /** - * @brief Total lock acquire time in nanoseconds. - * - * The average lock acquire time is the total acquire time divided by the - * lock usage count. The ration of the total section and total acquire times - * gives a measure for the lock contention. - * - * This value may overflow. - */ - uint64_t total_acquire_time; - - /** - * @brief The counts of lock acquire operations by contention. - * - * The contention count for index N corresponds to a lock acquire attempt - * with an initial queue length of N. The last index corresponds to all - * lock acquire attempts with an initial queue length greater than or equal - * to SMP_LOCK_STATS_CONTENTION_COUNTS minus one. - * - * The values may overflow. - */ - uint64_t contention_counts[SMP_LOCK_STATS_CONTENTION_COUNTS]; - - /** - * @brief Total lock section time in CPU counter ticks. - * - * The average lock section time is the total section time divided by the - * lock usage count. - * - * This value may overflow. - */ - uint64_t total_section_time; - - /** - * @brief The lock name. - */ - const char *name; -} SMP_lock_Stats; - -/** - * @brief Local context for SMP lock statistics. - */ -typedef struct { - /** - * @brief The last lock acquire instant in CPU counter ticks. - * - * This value is used to measure the lock section time. - */ - CPU_Counter_ticks acquire_instant; - - /** - * @brief The lock stats used for the last lock acquire. - */ - SMP_lock_Stats *stats; -} SMP_lock_Stats_context; - -/** - * @brief SMP lock statistics initializer for static initialization. - */ -#define SMP_LOCK_STATS_INITIALIZER( name ) \ - { { NULL, NULL }, 0, 0, 0, 0, { 0, 0, 0, 0 }, 0, name } - -/** - * @brief Initializes an SMP lock statistics block. - * - * @param[in, out] stats The SMP lock statistics block. - * @param[in] name The name for the SMP lock statistics. This name must be - * persistent throughout the life time of this statistics block. - */ -static inline void _SMP_lock_Stats_initialize( - SMP_lock_Stats *stats, - const char *name -) -{ - SMP_lock_Stats init = SMP_LOCK_STATS_INITIALIZER( name ); - - *stats = init; -} - -/** - * @brief Destroys an SMP lock statistics block. - * - * @param[in] stats The SMP lock statistics block. - */ -void _SMP_lock_Stats_destroy( SMP_lock_Stats *stats ); - -void _SMP_lock_Stats_register( SMP_lock_Stats *stats ); - -typedef struct { - CPU_Counter_ticks first; -} SMP_lock_Stats_acquire_context; - -static inline void _SMP_lock_Stats_acquire_begin( - SMP_lock_Stats_acquire_context *acquire_context -) -{ - acquire_context->first = _CPU_Counter_read(); -} - -static inline void _SMP_lock_Stats_acquire_end( - const SMP_lock_Stats_acquire_context *acquire_context, - SMP_lock_Stats *stats, - SMP_lock_Stats_context *stats_context, - unsigned int queue_length -) -{ - CPU_Counter_ticks second; - CPU_Counter_ticks delta; - - second = _CPU_Counter_read(); - stats_context->acquire_instant = second; - delta = _CPU_Counter_difference( second, acquire_context->first ); - - ++stats->usage_count; - - stats->total_acquire_time += delta; - - if ( stats->max_acquire_time < delta ) { - stats->max_acquire_time = delta; - } - - if ( queue_length >= SMP_LOCK_STATS_CONTENTION_COUNTS ) { - queue_length = SMP_LOCK_STATS_CONTENTION_COUNTS - 1; - } - ++stats->contention_counts[ queue_length ]; - - stats_context->stats = stats; -} - -/** - * @brief Updates an SMP lock statistics block during a lock release. - * - * @param[in] stats_context The SMP lock statistics context. - */ -static inline void _SMP_lock_Stats_release_update( - const SMP_lock_Stats_context *stats_context -) -{ - SMP_lock_Stats *stats = stats_context->stats; - CPU_Counter_ticks first = stats_context->acquire_instant; - CPU_Counter_ticks second = _CPU_Counter_read(); - CPU_Counter_ticks delta = _CPU_Counter_difference( second, first ); - - stats->total_section_time += delta; - - if ( stats->max_section_time < delta ) { - stats->max_section_time = delta; - - if ( _Chain_Is_node_off_chain( &stats->Node ) ) { - _SMP_lock_Stats_register( stats ); - } - } -} - -typedef struct { - Chain_Node Node; - SMP_lock_Stats *current; -} SMP_lock_Stats_iteration_context; - -void _SMP_lock_Stats_iteration_start( - SMP_lock_Stats_iteration_context *iteration_context -); - - -bool _SMP_lock_Stats_iteration_next( - SMP_lock_Stats_iteration_context *iteration_context, - SMP_lock_Stats *snapshot, - char *name, - size_t name_size -); - -void _SMP_lock_Stats_iteration_stop( - SMP_lock_Stats_iteration_context *iteration_context -); - -#else /* RTEMS_PROFILING */ - -#define _SMP_lock_Stats_initialize( stats, name ) do { } while ( 0 ) - -#define _SMP_lock_Stats_destroy( stats ) do { } while ( 0 ) - -#endif /* !RTEMS_PROFILING */ - -/**@}*/ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* RTEMS_SMP */ - -#endif /* _RTEMS_SCORE_SMPLOCKSTATS_H */ diff --git a/cpukit/score/include/rtems/score/smplockticket.h b/cpukit/score/include/rtems/score/smplockticket.h deleted file mode 100644 index e04c4056a5..0000000000 --- a/cpukit/score/include/rtems/score/smplockticket.h +++ /dev/null @@ -1,187 +0,0 @@ -/** - * @file - * - * @ingroup ScoreSMPLock - * - * @brief SMP Lock API - */ - -/* - * Copyright (c) 2013, 2016 embedded brains GmbH - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SMPLOCKTICKET_H -#define _RTEMS_SCORE_SMPLOCKTICKET_H - -#include - -#if defined(RTEMS_SMP) - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @addtogroup ScoreSMPLock - * - * @{ - */ - -/** - * @brief SMP ticket lock control. - */ -typedef struct { - Atomic_Uint next_ticket; - Atomic_Uint now_serving; -} SMP_ticket_lock_Control; - -/** - * @brief SMP ticket lock control initializer for static initialization. - */ -#define SMP_TICKET_LOCK_INITIALIZER \ - { \ - ATOMIC_INITIALIZER_UINT( 0U ), \ - ATOMIC_INITIALIZER_UINT( 0U ) \ - } - -/** - * @brief Initializes an SMP ticket lock. - * - * Concurrent initialization leads to unpredictable results. - * - * @param[in] lock The SMP ticket lock control. - */ -static inline void _SMP_ticket_lock_Initialize( - SMP_ticket_lock_Control *lock -) -{ - _Atomic_Init_uint( &lock->next_ticket, 0U ); - _Atomic_Init_uint( &lock->now_serving, 0U ); -} - -/** - * @brief Destroys an SMP ticket lock. - * - * Concurrent destruction leads to unpredictable results. - * - * @param[in] lock The SMP ticket lock control. - */ -static inline void _SMP_ticket_lock_Destroy( SMP_ticket_lock_Control *lock ) -{ - (void) lock; -} - -static inline void _SMP_ticket_lock_Do_acquire( - SMP_ticket_lock_Control *lock -#if defined(RTEMS_PROFILING) - , - SMP_lock_Stats *stats, - SMP_lock_Stats_context *stats_context -#endif -) -{ - unsigned int my_ticket; - unsigned int now_serving; -#if defined(RTEMS_PROFILING) - unsigned int initial_queue_length; - SMP_lock_Stats_acquire_context acquire_context; - - _SMP_lock_Stats_acquire_begin( &acquire_context ); -#endif - - my_ticket = - _Atomic_Fetch_add_uint( &lock->next_ticket, 1U, ATOMIC_ORDER_RELAXED ); - -#if defined(RTEMS_PROFILING) - now_serving = - _Atomic_Load_uint( &lock->now_serving, ATOMIC_ORDER_ACQUIRE ); - initial_queue_length = my_ticket - now_serving; - - if ( initial_queue_length > 0 ) { -#endif - - do { - now_serving = - _Atomic_Load_uint( &lock->now_serving, ATOMIC_ORDER_ACQUIRE ); - } while ( now_serving != my_ticket ); - -#if defined(RTEMS_PROFILING) - } - - _SMP_lock_Stats_acquire_end( - &acquire_context, - stats, - stats_context, - initial_queue_length - ); -#endif -} - -/** - * @brief Acquires an SMP ticket lock. - * - * This function will not disable interrupts. The caller must ensure that the - * current thread of execution is not interrupted indefinite once it obtained - * the SMP ticket lock. - * - * @param[in] lock The SMP ticket lock control. - * @param[in] stats The SMP lock statistics. - * @param[out] stats_context The SMP lock statistics context. - */ -#if defined(RTEMS_PROFILING) - #define _SMP_ticket_lock_Acquire( lock, stats, stats_context ) \ - _SMP_ticket_lock_Do_acquire( lock, stats, stats_context ) -#else - #define _SMP_ticket_lock_Acquire( lock, stats, stats_context ) \ - _SMP_ticket_lock_Do_acquire( lock ) -#endif - -static inline void _SMP_ticket_lock_Do_release( - SMP_ticket_lock_Control *lock -#if defined(RTEMS_PROFILING) - , - const SMP_lock_Stats_context *stats_context -#endif -) -{ - unsigned int current_ticket = - _Atomic_Load_uint( &lock->now_serving, ATOMIC_ORDER_RELAXED ); - unsigned int next_ticket = current_ticket + 1U; - -#if defined(RTEMS_PROFILING) - _SMP_lock_Stats_release_update( stats_context ); -#endif - - _Atomic_Store_uint( &lock->now_serving, next_ticket, ATOMIC_ORDER_RELEASE ); -} - -/** - * @brief Releases an SMP ticket lock. - * - * @param[in] lock The SMP ticket lock control. - * @param[in] stats_context The SMP lock statistics context. - */ -#if defined(RTEMS_PROFILING) - #define _SMP_ticket_lock_Release( lock, stats_context ) \ - _SMP_ticket_lock_Do_release( lock, stats_context ) -#else - #define _SMP_ticket_lock_Release( lock, stats_context ) \ - _SMP_ticket_lock_Do_release( lock ) -#endif - -/**@}*/ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* RTEMS_SMP */ - -#endif /* _RTEMS_SCORE_SMPLOCKTICKET_H */ diff --git a/cpukit/score/include/rtems/score/stack.h b/cpukit/score/include/rtems/score/stack.h deleted file mode 100644 index 9622495092..0000000000 --- a/cpukit/score/include/rtems/score/stack.h +++ /dev/null @@ -1,69 +0,0 @@ -/** - * @file rtems/score/stack.h - * - * @brief Information About the Thread Stack Handler - * - * This include file contains all information about the thread - * Stack Handler. This Handler provides mechanisms which can be used to - * initialize and utilize stacks. - */ - -/* - * COPYRIGHT (c) 1989-2006. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_STACK_H -#define _RTEMS_SCORE_STACK_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ScoreStack Stack Handler - * - * @ingroup Score - * - * This handler encapsulates functionality which is used in the management - * of thread stacks. - */ -/**@{*/ - -/** - * The following constant defines the minimum stack size which every - * thread must exceed. - */ -#define STACK_MINIMUM_SIZE CPU_STACK_MINIMUM_SIZE - -/** - * The following defines the control block used to manage each stack. - */ -typedef struct { - /** This is the stack size. */ - size_t size; - /** This is the low memory address of stack. */ - void *area; -} Stack_Control; - -/** - * This variable contains the the minimum stack size; - * - * @note It is instantiated and set by User Configuration via confdefs.h. - */ -extern uint32_t rtems_minimum_stack_size; - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/stackimpl.h b/cpukit/score/include/rtems/score/stackimpl.h deleted file mode 100644 index 4c622345ff..0000000000 --- a/cpukit/score/include/rtems/score/stackimpl.h +++ /dev/null @@ -1,99 +0,0 @@ -/** - * @file - * - * @brief Inlined Routines from the Stack Handler - * - * This file contains the static inline implementation of the inlined - * routines from the Stack Handler. - */ - -/* - * COPYRIGHT (c) 1989-2006. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_STACKIMPL_H -#define _RTEMS_SCORE_STACKIMPL_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ScoreStack - */ -/**@{**/ - -/** - * This routine initializes the_stack record to indicate that - * size bytes of memory starting at starting_address have been - * reserved for a stack. - */ -RTEMS_INLINE_ROUTINE void _Stack_Initialize ( - Stack_Control *the_stack, - void *starting_address, - size_t size -) -{ - the_stack->area = starting_address; - the_stack->size = size; -} - -/** - * This function returns the minimum stack size configured - * for this application. - * - * @return This method returns the minimum stack size; - */ -RTEMS_INLINE_ROUTINE uint32_t _Stack_Minimum (void) -{ - return rtems_minimum_stack_size; -} - -/** - * This function returns true if size bytes is enough memory for - * a valid stack area on this processor, and false otherwise. - * - * @param[in] size is the stack size to check - * - * @return This method returns true if the stack is large enough. - */ -RTEMS_INLINE_ROUTINE bool _Stack_Is_enough ( - size_t size -) -{ - return ( size >= _Stack_Minimum() ); -} - -/** - * This function returns the appropriate stack size given the requested - * size. If the requested size is below the minimum, then the minimum - * configured stack size is returned. - * - * @param[in] size is the stack size to check - * - * @return This method returns the appropriate stack size. - */ -RTEMS_INLINE_ROUTINE size_t _Stack_Ensure_minimum ( - size_t size -) -{ - if ( size >= _Stack_Minimum() ) - return size; - return _Stack_Minimum(); -} - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/states.h b/cpukit/score/include/rtems/score/states.h deleted file mode 100644 index ba59af6907..0000000000 --- a/cpukit/score/include/rtems/score/states.h +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @file rtems/score/states.h - * - * @brief Thread Execution State Information - * - * This include file defines thread execution state information. - */ - -/* - * COPYRIGHT (c) 1989-2006. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_STATES_H -#define _RTEMS_SCORE_STATES_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ScoreStates SuperCore Thread States - * - * @ingroup Score - * - * This handler encapsulates functionality which relates to the management of - * the state bitmap associated with each thread. - */ -/**@{*/ - -/** - * The following type defines the control block used to manage a - * thread's state. - */ -typedef uint32_t States_Control; - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/statesimpl.h b/cpukit/score/include/rtems/score/statesimpl.h deleted file mode 100644 index db462fbb9a..0000000000 --- a/cpukit/score/include/rtems/score/statesimpl.h +++ /dev/null @@ -1,283 +0,0 @@ -/** - * @file - * - * @brief Inlined Routines Associated with Thread State Information - * - * This file contains the static inline implementation of the inlined - * routines associated with thread state information. - */ - -/* - * COPYRIGHT (c) 1989-2012. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_STATESIMPL_H -#define _RTEMS_SCORE_STATESIMPL_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ScoreStates - */ -/**@{**/ - -/* - * The following constants define the individual states which may be - * be used to compose and manipulate a thread's state. More frequently used - * states should use lower value bits to ease the use of immediate values on - * RISC architectures. - */ - -/** This macro corresponds to a task being ready. */ -#define STATES_READY 0x00000000 - -/** This macro corresponds to a task waiting for a mutex. */ -#define STATES_WAITING_FOR_MUTEX 0x00000001 - -/** This macro corresponds to a task waiting for a semaphore. */ -#define STATES_WAITING_FOR_SEMAPHORE 0x00000002 - -/** This macro corresponds to a task waiting for an event. */ -#define STATES_WAITING_FOR_EVENT 0x00000004 - -/** This macro corresponds to a task waiting for a system event. */ -#define STATES_WAITING_FOR_SYSTEM_EVENT 0x00000008 - -/** This macro corresponds to a task waiting for a message. */ -#define STATES_WAITING_FOR_MESSAGE 0x00000010 - -/** This macro corresponds to a task waiting for a condition variable. */ -#define STATES_WAITING_FOR_CONDITION_VARIABLE 0x00000020 - -/** This macro corresponds to a task waiting for a futex. */ -#define STATES_WAITING_FOR_FUTEX 0x00000040 - -/** This macro corresponds to a task waiting for BSD wakeup. */ -#define STATES_WAITING_FOR_BSD_WAKEUP 0x00000080 - -/** - * @brief This macro corresponds to a task which is waiting for a relative or - * absolute timeout. - */ -#define STATES_WAITING_FOR_TIME 0x00000100 - -/** This macro corresponds to a task waiting for a period. */ -#define STATES_WAITING_FOR_PERIOD 0x00000200 - -/** This macro corresponds to a task waiting for a signal. */ -#define STATES_WAITING_FOR_SIGNAL 0x00000400 - -/** This macro corresponds to a task waiting for a barrier. */ -#define STATES_WAITING_FOR_BARRIER 0x00000800 - -/** This macro corresponds to a task waiting for a RWLock. */ -#define STATES_WAITING_FOR_RWLOCK 0x00001000 - -/** This macro corresponds to a task waiting for a join while exiting. */ -#define STATES_WAITING_FOR_JOIN_AT_EXIT 0x00002000 - -/** This macro corresponds to a task waiting for a join. */ -#define STATES_WAITING_FOR_JOIN 0x00004000 - -/** This macro corresponds to a task being suspended. */ -#define STATES_SUSPENDED 0x00008000 - -/** This macro corresponds to a task waiting for a fixed size segment. */ -#define STATES_WAITING_FOR_SEGMENT 0x00010000 - -/** This macro corresponds to a task those life is changing. */ -#define STATES_LIFE_IS_CHANGING 0x00020000 - -/** This macro corresponds to a task being held by the debugger. */ -#define STATES_DEBUGGER 0x08000000 - -/** This macro corresponds to a task which is in an interruptible - * blocking state. - */ -#define STATES_INTERRUPTIBLE_BY_SIGNAL 0x10000000 - -/** This macro corresponds to a task waiting for a reply to an MPCI request. */ -#define STATES_WAITING_FOR_RPC_REPLY 0x20000000 - -/** This macro corresponds to a task being a zombie. */ -#define STATES_ZOMBIE 0x40000000 - -/** This macro corresponds to a task being created but not yet started. */ -#define STATES_DORMANT 0x80000000 - -/** This macro corresponds to a task waiting for a local object operation. */ -#define STATES_LOCALLY_BLOCKED ( STATES_WAITING_FOR_SEGMENT | \ - STATES_WAITING_FOR_MESSAGE | \ - STATES_WAITING_FOR_SEMAPHORE | \ - STATES_WAITING_FOR_MUTEX | \ - STATES_WAITING_FOR_CONDITION_VARIABLE | \ - STATES_WAITING_FOR_JOIN | \ - STATES_WAITING_FOR_SIGNAL | \ - STATES_WAITING_FOR_BARRIER | \ - STATES_WAITING_FOR_BSD_WAKEUP | \ - STATES_WAITING_FOR_FUTEX | \ - STATES_WAITING_FOR_RWLOCK ) - -/** This macro corresponds to a task waiting which is blocked. */ -#define STATES_BLOCKED ( STATES_LOCALLY_BLOCKED | \ - STATES_WAITING_FOR_TIME | \ - STATES_WAITING_FOR_PERIOD | \ - STATES_WAITING_FOR_EVENT | \ - STATES_WAITING_FOR_RPC_REPLY | \ - STATES_WAITING_FOR_SYSTEM_EVENT | \ - STATES_INTERRUPTIBLE_BY_SIGNAL ) - -/** All state bits set to one (provided for _Thread_Start()) */ -#define STATES_ALL_SET 0xffffffff - -/** - * This function sets the given states_to_set into the current_state - * passed in. The result is returned to the user in current_state. - * - * @param[in] states_to_set is the state bits to set - * @param[in] current_state is the state set to add them to - * - * @return This method returns the updated states value. - */ -RTEMS_INLINE_ROUTINE States_Control _States_Set ( - States_Control states_to_set, - States_Control current_state -) -{ - return (current_state | states_to_set); -} - -/** - * This function clears the given states_to_clear into the current_state - * passed in. The result is returned to the user in current_state. - * - * @param[in] states_to_clear is the state bits to clean - * @param[in] current_state is the state set to remove them from - * - * @return This method returns the updated states value. - */ -RTEMS_INLINE_ROUTINE States_Control _States_Clear ( - States_Control states_to_clear, - States_Control current_state -) -{ - return (current_state & ~states_to_clear); -} - -/** - * This function returns true if the_states indicates that the - * state is READY, and false otherwise. - * - * @param[in] the_states is the task state set to test - * - * @return This method returns true if the desired state condition is set. - */ -RTEMS_INLINE_ROUTINE bool _States_Is_ready ( - States_Control the_states -) -{ - return (the_states == STATES_READY); -} - -/** - * This function returns true if the DORMANT state is set in - * the_states, and false otherwise. - * - * @param[in] the_states is the task state set to test - * - * @return This method returns true if the desired state condition is set. - */ -RTEMS_INLINE_ROUTINE bool _States_Is_dormant ( - States_Control the_states -) -{ - return (the_states & STATES_DORMANT); -} - -/** - * This function returns true if the SUSPENDED state is set in - * the_states, and false otherwise. - * - * @param[in] the_states is the task state set to test - * - * @return This method returns true if the desired state condition is set. - */ -RTEMS_INLINE_ROUTINE bool _States_Is_suspended ( - States_Control the_states -) -{ - return (the_states & STATES_SUSPENDED); -} - -/** - * This function returns true if the WAITING_FOR_TIME state is set in - * the_states, and false otherwise. - * - * @param[in] the_states is the task state set to test - * - * @return This method returns true if the desired state condition is set. - */ -RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_rpc_reply ( - States_Control the_states -) -{ - return (the_states & STATES_WAITING_FOR_RPC_REPLY); -} - -RTEMS_INLINE_ROUTINE bool _States_Is_waiting_for_join_at_exit( - States_Control the_states -) -{ - return ( the_states & STATES_WAITING_FOR_JOIN_AT_EXIT ) != 0; -} - -/** - * This function returns true if the task's state is set in - * way that allows it to be interrupted by a signal. - * - * @param[in] the_states is the task state set to test - * - * @return This method returns true if the desired state condition is set. - */ -RTEMS_INLINE_ROUTINE bool _States_Is_interruptible_by_signal ( - States_Control the_states -) -{ - return (the_states & STATES_INTERRUPTIBLE_BY_SIGNAL); - -} -/** - * This function returns true if one of the states which indicates - * that a task is blocked waiting for a local resource is set in - * the_states, and false otherwise. - * - * @param[in] the_states is the task state set to test - * - * @return This method returns true if the desired state condition is set. - */ - -RTEMS_INLINE_ROUTINE bool _States_Is_locally_blocked ( - States_Control the_states -) -{ - return (the_states & STATES_LOCALLY_BLOCKED); -} - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/status.h b/cpukit/score/include/rtems/score/status.h deleted file mode 100644 index 5b154bb207..0000000000 --- a/cpukit/score/include/rtems/score/status.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2016 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_STATUS_H -#define _RTEMS_SCORE_STATUS_H - -#include - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @brief Status code parts for the Classic API. - * - * Must be in synchronization with rtems_status_code. - */ -typedef enum { - STATUS_CLASSIC_INCORRECT_STATE = 14, - STATUS_CLASSIC_INTERNAL_ERROR = 13, - STATUS_CLASSIC_INVALID_NUMBER = 10, - STATUS_CLASSIC_INVALID_PRIORITY = 19, - STATUS_CLASSIC_INVALID_SIZE = 8, - STATUS_CLASSIC_NO_MEMORY = 26, - STATUS_CLASSIC_NOT_DEFINED = 11, - STATUS_CLASSIC_NOT_OWNER_OF_RESOURCE = 23, - STATUS_CLASSIC_OBJECT_WAS_DELETED = 7, - STATUS_CLASSIC_RESOURCE_IN_USE = 12, - STATUS_CLASSIC_SUCCESSFUL = 0, - STATUS_CLASSIC_TIMEOUT = 6, - STATUS_CLASSIC_TOO_MANY = 5, - STATUS_CLASSIC_UNSATISFIED = 13 -} Status_Classic; - -/** - * @brief Macro to build a status code from Classic and POSIX API parts. - */ -#define STATUS_BUILD( classic_status, posix_status ) \ - ( ( ( (unsigned int) ( posix_status ) ) << 8 ) | ( classic_status ) ) - -/** - * @brief Macro to get the Classic API status code. - */ -#define STATUS_GET_CLASSIC( status ) \ - ( ( status ) & 0xff ) - -/** - * @brief Macro to get the POSIX API status code. - * - * Performs an arithmetic shift to reconstruct a negative POSIX status. - */ -#define STATUS_GET_POSIX( status ) \ - ( ( ( (int) ( status ) ) | 0xff ) >> 8 ) - -/** - * @brief Status codes. - */ -typedef enum { - STATUS_BARRIER_AUTOMATICALLY_RELEASED = - STATUS_BUILD( STATUS_CLASSIC_SUCCESSFUL, PTHREAD_BARRIER_SERIAL_THREAD ), - STATUS_DEADLOCK = - STATUS_BUILD( STATUS_CLASSIC_INCORRECT_STATE, EDEADLK ), - STATUS_FLUSHED = - STATUS_BUILD( STATUS_CLASSIC_UNSATISFIED, EAGAIN ), - STATUS_INCORRECT_STATE = - STATUS_BUILD( STATUS_CLASSIC_INCORRECT_STATE, EINVAL ), - STATUS_INTERRUPTED = - STATUS_BUILD( STATUS_CLASSIC_INTERNAL_ERROR, EINTR ), - STATUS_INVALID_NUMBER = - STATUS_BUILD( STATUS_CLASSIC_INVALID_NUMBER, EINVAL ), - STATUS_INVALID_PRIORITY = - STATUS_BUILD( STATUS_CLASSIC_INVALID_PRIORITY, EINVAL ), - STATUS_MAXIMUM_COUNT_EXCEEDED = - STATUS_BUILD( STATUS_CLASSIC_INTERNAL_ERROR, EOVERFLOW ), - STATUS_MESSAGE_INVALID_SIZE = - STATUS_BUILD( STATUS_CLASSIC_INVALID_SIZE, EMSGSIZE ), - STATUS_MESSAGE_QUEUE_WAIT_IN_ISR = - STATUS_BUILD( STATUS_CLASSIC_INTERNAL_ERROR, ENOMEM ), - STATUS_MESSAGE_QUEUE_WAS_DELETED = - STATUS_BUILD( STATUS_CLASSIC_OBJECT_WAS_DELETED, EBADF ), - STATUS_MINUS_ONE = - -1, - STATUS_MUTEX_CEILING_VIOLATED = - STATUS_BUILD( STATUS_CLASSIC_INVALID_PRIORITY, EINVAL ), - STATUS_NESTING_NOT_ALLOWED = - STATUS_BUILD( STATUS_CLASSIC_UNSATISFIED, EDEADLK ), - STATUS_NO_MEMORY = - STATUS_BUILD( STATUS_CLASSIC_NO_MEMORY, EINVAL ), - STATUS_NOT_DEFINED = - STATUS_BUILD( STATUS_CLASSIC_NOT_DEFINED, EINVAL ), - STATUS_NOT_OWNER = - STATUS_BUILD( STATUS_CLASSIC_NOT_OWNER_OF_RESOURCE, EPERM ), - STATUS_OBJECT_WAS_DELETED = - STATUS_BUILD( STATUS_CLASSIC_OBJECT_WAS_DELETED, EINVAL ), - STATUS_RESOURCE_IN_USE = - STATUS_BUILD( STATUS_CLASSIC_RESOURCE_IN_USE, EBUSY ), - STATUS_RESULT_TOO_LARGE = - STATUS_BUILD( STATUS_CLASSIC_UNSATISFIED, ERANGE ), - STATUS_SUCCESSFUL = - STATUS_BUILD( STATUS_CLASSIC_SUCCESSFUL, 0 ), - STATUS_TIMEOUT = - STATUS_BUILD( STATUS_CLASSIC_TIMEOUT, ETIMEDOUT ), - STATUS_TOO_MANY = - STATUS_BUILD( STATUS_CLASSIC_TOO_MANY, EAGAIN ), - STATUS_UNAVAILABLE = - STATUS_BUILD( STATUS_CLASSIC_UNSATISFIED, EBUSY ), - STATUS_UNSATISFIED = - STATUS_BUILD( STATUS_CLASSIC_UNSATISFIED, EAGAIN ) -} Status_Control; - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_SCORE_STATUS_H */ diff --git a/cpukit/score/include/rtems/score/sysstate.h b/cpukit/score/include/rtems/score/sysstate.h deleted file mode 100644 index 0e01927d9a..0000000000 --- a/cpukit/score/include/rtems/score/sysstate.h +++ /dev/null @@ -1,119 +0,0 @@ -/** - * @file - * - * @ingroup ScoreSysState - * - * @brief System State Handler API - */ - -/* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_SYSSTATE_H -#define _RTEMS_SCORE_SYSSTATE_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ScoreSysState System State Handler - * - * @ingroup Score - * - * @brief Management of the internal system state of RTEMS. - */ -/**@{**/ - -/** - * @brief System states. - */ -typedef enum { - /** - * @brief The system is before the end of the first phase of initialization. - */ - SYSTEM_STATE_BEFORE_INITIALIZATION, - - /** - * @brief The system is between end of the first phase of initialization but - * before multitasking is started. - */ - SYSTEM_STATE_BEFORE_MULTITASKING, - - /** - * @brief The system is up and operating normally. - */ - SYSTEM_STATE_UP, - - /** - * @brief The system reached its terminal state. - */ - SYSTEM_STATE_TERMINATED -} System_state_Codes; - -#define SYSTEM_STATE_CODES_FIRST SYSTEM_STATE_BEFORE_INITIALIZATION - -#define SYSTEM_STATE_CODES_LAST SYSTEM_STATE_TERMINATED - -#if defined(RTEMS_MULTIPROCESSING) -extern bool _System_state_Is_multiprocessing; -#endif - -extern System_state_Codes _System_state_Current; - -RTEMS_INLINE_ROUTINE void _System_state_Set ( - System_state_Codes state -) -{ - _System_state_Current = state; -} - -RTEMS_INLINE_ROUTINE System_state_Codes _System_state_Get ( void ) -{ - return _System_state_Current; -} - -RTEMS_INLINE_ROUTINE bool _System_state_Is_before_initialization ( - System_state_Codes state -) -{ - return (state == SYSTEM_STATE_BEFORE_INITIALIZATION); -} - -RTEMS_INLINE_ROUTINE bool _System_state_Is_before_multitasking ( - System_state_Codes state -) -{ - return (state == SYSTEM_STATE_BEFORE_MULTITASKING); -} - -RTEMS_INLINE_ROUTINE bool _System_state_Is_up ( - System_state_Codes state -) -{ - return (state == SYSTEM_STATE_UP); -} - -RTEMS_INLINE_ROUTINE bool _System_state_Is_terminated ( - System_state_Codes state -) -{ - return (state == SYSTEM_STATE_TERMINATED); -} - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h deleted file mode 100644 index 7e0e2722dd..0000000000 --- a/cpukit/score/include/rtems/score/thread.h +++ /dev/null @@ -1,935 +0,0 @@ -/** - * @file rtems/score/thread.h - * - * @brief Constants and Structures Related with the Thread Control Block - * - * This include file contains all constants and structures associated - * with the thread control block. - */ - -/* - * COPYRIGHT (c) 1989-2014. - * On-Line Applications Research Corporation (OAR). - * - * Copyright (c) 2014, 2016 embedded brains GmbH. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_THREAD_H -#define _RTEMS_SCORE_THREAD_H - -#include -#include -#if defined(RTEMS_MULTIPROCESSING) -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(RTEMS_SMP) -#include -#endif - -struct _pthread_cleanup_context; - -struct Per_CPU_Control; - -struct _Scheduler_Control; - -struct User_extensions_Iterator; - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ScoreThread Thread Handler - * - * @ingroup Score - * - * This handler encapsulates functionality related to the management of - * threads. This includes the creation, deletion, and scheduling of threads. - * - * The following variables are maintained as part of the per cpu data - * structure. - * - * + Idle thread pointer - * + Executing thread pointer - * + Heir thread pointer - */ -/**@{*/ - -#if defined(RTEMS_POSIX_API) - #define RTEMS_SCORE_THREAD_ENABLE_EXHAUST_TIMESLICE -#endif - -/* - * With the addition of the Constant Block Scheduler (CBS), - * this feature is needed even when POSIX is disabled. - */ -#define RTEMS_SCORE_THREAD_ENABLE_SCHEDULER_CALLOUT - -#if defined(RTEMS_POSIX_API) - #define RTEMS_SCORE_THREAD_ENABLE_USER_PROVIDED_STACK_VIA_API -#endif - -#if defined(RTEMS_DEBUG) -#define RTEMS_SCORE_THREAD_ENABLE_RESOURCE_COUNT -#endif - -/* - * Only provided for backward compatiblity to not break application - * configurations. - */ -typedef void *Thread RTEMS_DEPRECATED; - -/** - * @brief Type of the numeric argument of a thread entry function with at - * least one numeric argument. - * - * This numeric argument type designates an unsigned integer type with the - * property that any valid pointer to void can be converted to this type and - * then converted back to a pointer to void. The result will compare equal to - * the original pointer. - */ -typedef CPU_Uint32ptr Thread_Entry_numeric_type; - -/** - * @brief Data for idle thread entry. - */ -typedef struct { - void *( *entry )( uintptr_t argument ); -} Thread_Entry_idle; - -/** - * @brief Data for thread entry with one numeric argument and no return value. - */ -typedef struct { - void ( *entry )( Thread_Entry_numeric_type argument ); - Thread_Entry_numeric_type argument; -} Thread_Entry_numeric; - -/** - * @brief Data for thread entry with one pointer argument and a pointer return - * value. - */ -typedef struct { - void *( *entry )( void *argument ); - void *argument; -} Thread_Entry_pointer; - -/** - * @brief Thread entry information. - */ -typedef struct { - /** - * @brief Thread entry adaptor. - * - * Calls the corresponding thread entry with the right parameters. - * - * @param executing The executing thread. - */ - void ( *adaptor )( Thread_Control *executing ); - - /** - * @brief Thread entry data used by the adaptor to call the thread entry - * function with the right parameters. - */ - union { - Thread_Entry_idle Idle; - Thread_Entry_numeric Numeric; - Thread_Entry_pointer Pointer; - } Kinds; -} Thread_Entry_information; - -/** - * The following lists the algorithms used to manage the thread cpu budget. - * - * Reset Timeslice: At each context switch, reset the time quantum. - * Exhaust Timeslice: Only reset the quantum once it is consumed. - * Callout: Execute routine when budget is consumed. - */ -typedef enum { - THREAD_CPU_BUDGET_ALGORITHM_NONE, - THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE, - #if defined(RTEMS_SCORE_THREAD_ENABLE_EXHAUST_TIMESLICE) - THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE, - #endif - #if defined(RTEMS_SCORE_THREAD_ENABLE_SCHEDULER_CALLOUT) - THREAD_CPU_BUDGET_ALGORITHM_CALLOUT - #endif -} Thread_CPU_budget_algorithms; - -/** This defines thes the entry point for the thread specific timeslice - * budget management algorithm. - */ -typedef void (*Thread_CPU_budget_algorithm_callout )( Thread_Control * ); - -/** - * The following structure contains the information which defines - * the starting state of a thread. - */ -typedef struct { - /** This field contains the thread entry information. */ - Thread_Entry_information Entry; - /*-------------- initial execution modes ----------------- */ - /** This field indicates whether the thread was preemptible when - * it started. - */ - bool is_preemptible; - /** This field indicates the CPU budget algorith. */ - Thread_CPU_budget_algorithms budget_algorithm; - /** This field is the routine to invoke when the CPU allotment is - * consumed. - */ - Thread_CPU_budget_algorithm_callout budget_callout; - /** This field is the initial ISR disable level of this thread. */ - uint32_t isr_level; - /** This field is the initial priority. */ - Priority_Control initial_priority; - #if defined(RTEMS_SCORE_THREAD_ENABLE_USER_PROVIDED_STACK_VIA_API) - /** This field indicates whether the SuperCore allocated the stack. */ - bool core_allocated_stack; - #endif - /** This field is the stack information. */ - Stack_Control Initial_stack; - #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) - /** This field is the initial FP context area address. */ - Context_Control_fp *fp_context; - #endif - /** This field is the initial stack area address. */ - void *stack; - /** The thread-local storage (TLS) area */ - void *tls_area; -} Thread_Start_information; - -#if defined(RTEMS_SMP) -/** - * @brief The thread state with respect to the scheduler. - */ -typedef enum { - /** - * @brief This thread is blocked with respect to the scheduler. - * - * This thread uses no scheduler nodes. - */ - THREAD_SCHEDULER_BLOCKED, - - /** - * @brief This thread is scheduled with respect to the scheduler. - * - * This thread executes using one of its scheduler nodes. This could be its - * own scheduler node or in case it owns resources taking part in the - * scheduler helping protocol a scheduler node of another thread. - */ - THREAD_SCHEDULER_SCHEDULED, - - /** - * @brief This thread is ready with respect to the scheduler. - * - * None of the scheduler nodes of this thread is scheduled. - */ - THREAD_SCHEDULER_READY -} Thread_Scheduler_state; -#endif - -/** - * @brief Thread scheduler control. - */ -typedef struct { -#if defined(RTEMS_SMP) - /** - * @brief Lock to protect the scheduler node change requests. - */ - ISR_lock_Control Lock; - - /** - * @brief The current scheduler state of this thread. - */ - Thread_Scheduler_state state; - - /** - * @brief The home scheduler control of this thread. - */ - const struct _Scheduler_Control *home; - - /** - * @brief The processor assigned by the current scheduler. - */ - struct Per_CPU_Control *cpu; - - /** - * @brief Scheduler nodes immediately available to the thread by its home - * scheduler instance and due to thread queue ownerships. - * - * This chain is protected by the thread wait lock. - * - * This chain is never empty. The first scheduler node on the chain is the - * scheduler node of the home scheduler instance. - */ - Chain_Control Wait_nodes; - - /** - * @brief Scheduler nodes immediately available to the schedulers for this - * thread. - * - * This chain is protected by the thread state lock. - * - * This chain is never empty. The first scheduler node on the chain is the - * scheduler node of the home scheduler instance. - */ - Chain_Control Scheduler_nodes; - - /** - * @brief Node for the Per_CPU_Control::Threads_in_need_for_help chain. - * - * This chain is protected by the Per_CPU_Control::Lock lock of the assigned - * processor. - */ - Chain_Node Help_node; - - /** - * @brief Count of nodes scheduler nodes minus one. - * - * This chain is protected by the thread state lock. - */ - size_t helping_nodes; - - /** - * @brief List of pending scheduler node requests. - * - * This list is protected by the thread scheduler lock. - */ - Scheduler_Node *requests; - - /** - * @brief The thread processor affinity set. - */ - Processor_mask Affinity; -#endif - - /** - * @brief The scheduler nodes of this thread. - * - * Each thread has a scheduler node for each scheduler instance. - */ - Scheduler_Node *nodes; -} Thread_Scheduler_control; - -/** - * @brief Union type to hold a pointer to an immutable or a mutable object. - * - * The main purpose is to enable passing of pointers to read-only send buffers - * in the message passing subsystem. This approach is somewhat fragile since - * it prevents the compiler to check if the operations on objects are valid - * with respect to the constant qualifier. An alternative would be to add a - * third pointer argument for immutable objects, but this would increase the - * structure size. - */ -typedef union { - void *mutable_object; - const void *immutable_object; -} Thread_Wait_information_Object_argument_type; - -/** - * @brief This type is able to contain several flags used to control the wait - * class and state of a thread. - * - * The mutually exclusive wait class flags are - * - @ref THREAD_WAIT_CLASS_EVENT, - * - @ref THREAD_WAIT_CLASS_SYSTEM_EVENT, and - * - @ref THREAD_WAIT_CLASS_OBJECT. - * - * The mutually exclusive wait state flags are - * - @ref THREAD_WAIT_STATE_INTEND_TO_BLOCK, - * - @ref THREAD_WAIT_STATE_BLOCKED, and - * - @ref THREAD_WAIT_STATE_READY_AGAIN. - */ -typedef unsigned int Thread_Wait_flags; - -/** - * @brief Information required to manage a thread while it is blocked. - * - * This contains the information required to manage a thread while it is - * blocked and to return information to it. - */ -typedef struct { -#if defined(RTEMS_MULTIPROCESSING) - /* - * @brief This field is the identifier of the remote object this thread is - * waiting upon. - */ - Objects_Id remote_id; -#endif - /** This field is used to return an integer while when blocked. */ - uint32_t count; - /** This field is for a pointer to a user return argument. */ - void *return_argument; - /** This field is for a pointer to a second user return argument. */ - Thread_Wait_information_Object_argument_type - return_argument_second; - /** This field contains any options in effect on this blocking operation. */ - uint32_t option; - /** This field will contain the return status from a blocking operation. - * - * @note The following assumes that all API return codes can be - * treated as an uint32_t. - */ - uint32_t return_code; - - /** - * @brief This field contains several flags used to control the wait class - * and state of a thread in case fine-grained locking is used. - */ -#if defined(RTEMS_SMP) - Atomic_Uint flags; -#else - Thread_Wait_flags flags; -#endif - -#if defined(RTEMS_SMP) - /** - * @brief Thread wait lock control block. - * - * Parts of the thread wait information are protected by the thread wait - * default lock and additionally a thread queue lock in case the thread - * is enqueued on a thread queue. - * - * The thread wait lock mechanism protects the following thread variables - * - POSIX_API_Control::Attributes, - * - Scheduler_Node::Wait, - * - Thread_Control::Wait::Lock::Pending_requests, - * - Thread_Control::Wait::queue, and - * - Thread_Control::Wait::operations. - * - * @see _Thread_Wait_acquire(), _Thread_Wait_release(), _Thread_Wait_claim(), - * _Thread_Wait_restore_default() and _Thread_Wait_tranquilize(). - */ - struct { - /** - * @brief Thread wait default lock. - */ - ISR_lock_Control Default; - - /** - * @brief The pending thread wait lock acquire or tranquilize requests in - * case the thread is enqueued on a thread queue. - */ - Chain_Control Pending_requests; - - /** - * @brief Tranquilizer gate used by _Thread_Wait_tranquilize(). - * - * This gate is closed by _Thread_Wait_claim(). In case there are no - * pending requests during a _Thread_Wait_restore_default(), then this gate - * is opened immediately, otherwise it is placed on the pending request - * chain and opened by _Thread_Wait_remove_request_locked() as the last - * gate on the chain to signal overall request completion. - */ - Thread_queue_Gate Tranquilizer; - } Lock; - - /** - * @brief Thread queue link provided for use by the thread wait lock owner to - * build a thread queue path. - */ - Thread_queue_Link Link; -#endif - - /** - * @brief The current thread queue. - * - * If this field is NULL the thread is not enqueued on a thread queue. This - * field is protected by the thread wait default lock. - * - * @see _Thread_Wait_claim(). - */ - Thread_queue_Queue *queue; - - /** - * @brief The current thread queue operations. - * - * This field is protected by the thread lock wait default lock. - * - * @see _Thread_Wait_claim(). - */ - const Thread_queue_Operations *operations; - - Thread_queue_Heads *spare_heads; -} Thread_Wait_information; - -/** - * @brief Information required to manage a thread timer. - */ -typedef struct { - ISR_LOCK_MEMBER( Lock ) - Watchdog_Header *header; - Watchdog_Control Watchdog; -} Thread_Timer_information; - -/** - * The following defines the control block used to manage - * each thread proxy. - * - * @note It is critical that proxies and threads have identical - * memory images for the shared part. - */ -typedef struct { - /** This field is the object management structure for each proxy. */ - Objects_Control Object; - - /** - * @see Thread_Control::Join_queue - */ - Thread_queue_Control Join_queue; - - /** This field is the current execution state of this proxy. */ - States_Control current_state; - - /** - * @brief The base priority of this thread in its home scheduler instance. - */ - Priority_Node Real_priority; - -#if defined(RTEMS_SCORE_THREAD_ENABLE_RESOURCE_COUNT) - /** This field is the number of mutexes currently held by this proxy. */ - uint32_t resource_count; -#endif - - /** - * @brief Scheduler related control. - */ - Thread_Scheduler_control Scheduler; - - /** This field is the blocking information for this proxy. */ - Thread_Wait_information Wait; - /** This field is the Watchdog used to manage proxy delays and timeouts. */ - Thread_Timer_information Timer; -#if defined(RTEMS_MULTIPROCESSING) - /** This field is the received response packet in an MP system. */ - MP_packet_Prefix *receive_packet; - /****************** end of common block ********************/ - - /** - * @brief Thread queue callout for _Thread_queue_Enqueue(). - */ - Thread_queue_MP_callout thread_queue_callout; - - /** - * @brief This field is used to manage the set of active proxies in the system. - */ - RBTree_Node Active; - - /** - * @brief The scheduler node providing the thread wait nodes used to enqueue - * this thread proxy on a thread queue. - */ - Scheduler_Node Scheduler_node; - - /** - * @brief Provide thread queue heads for this thread proxy. - * - * The actual size of the thread queue heads depends on the application - * configuration. Since thread proxies are never destroyed we can use the - * same storage place for the thread queue heads. - */ - Thread_queue_Heads Thread_queue_heads[ RTEMS_ZERO_LENGTH_ARRAY ]; -#endif -} Thread_Proxy_control; - -/** - * The following record defines the control block used - * to manage each thread. - * - * @note It is critical that proxies and threads have identical - * memory images for the shared part. - */ -typedef enum { - /** This value is for the Classic RTEMS API. */ - THREAD_API_RTEMS, - /** This value is for the POSIX API. */ - THREAD_API_POSIX -} Thread_APIs; - -/** This macro defines the first API which has threads. */ -#define THREAD_API_FIRST THREAD_API_RTEMS - -/** This macro defines the last API which has threads. */ -#define THREAD_API_LAST THREAD_API_POSIX - -typedef struct Thread_Action Thread_Action; - -/** - * @brief Thread action handler. - * - * The thread action handler will be called with interrupts disabled and a - * corresponding lock acquired, e.g. _Thread_State_acquire(). The handler must - * release the corresponding lock, e.g. _Thread_State_release(). So, the - * corresponding lock may be used to protect private data used by the - * particular action. - * - * Since the action is passed to the handler additional data may be accessed - * via RTEMS_CONTAINER_OF(). - * - * @param[in] the_thread The thread performing the action. - * @param[in] action The thread action. - * @param[in] lock_context The lock context to use for the lock release. - */ -typedef void ( *Thread_Action_handler )( - Thread_Control *the_thread, - Thread_Action *action, - ISR_lock_Context *lock_context -); - -/** - * @brief Thread action. - * - * Thread actions can be chained together to trigger a set of actions on - * particular events like for example a thread post-switch. Use - * _Thread_Action_initialize() to initialize this structure. - * - * Thread actions are the building block for efficient implementation of - * - Classic signals delivery, - * - POSIX signals delivery, and - * - thread life-cycle changes. - * - * @see _Thread_Add_post_switch_action() and _Thread_Run_post_switch_actions(). - */ -struct Thread_Action { - Chain_Node Node; - Thread_Action_handler handler; -}; - -/** - * @brief Per-thread information for POSIX Keys. - */ -typedef struct { - /** - * @brief Key value pairs registered for this thread. - */ - RBTree_Control Key_value_pairs; - - /** - * @brief Lock to protect the tree operations. - */ - ISR_LOCK_MEMBER( Lock ) -} Thread_Keys_information; - -/** - * @brief Control block to manage thread actions. - * - * Use _Thread_Action_control_initialize() to initialize this structure. - */ -typedef struct { - Chain_Control Chain; -} Thread_Action_control; - -/** - * @brief Thread life states. - * - * The thread life states are orthogonal to the thread states used for - * synchronization primitives and blocking operations. They reflect the state - * changes triggered with thread restart and delete requests. - * - * The individual state values must be a power of two to allow use of bit - * operations to manipulate and evaluate the thread life state. - */ -typedef enum { - THREAD_LIFE_PROTECTED = 0x1, - THREAD_LIFE_RESTARTING = 0x2, - THREAD_LIFE_TERMINATING = 0x4, - THREAD_LIFE_CHANGE_DEFERRED = 0x8, - THREAD_LIFE_DETACHED = 0x10 -} Thread_Life_state; - -/** - * @brief Thread life control. - */ -typedef struct { - /** - * @brief Thread life action used to react upon thread restart and delete - * requests. - */ - Thread_Action Action; - - /** - * @brief The current thread life state. - */ - Thread_Life_state state; - - /** - * @brief The count of pending life change requests. - */ - uint32_t pending_life_change_requests; - -#if defined(RTEMS_POSIX_API) - /** - * @brief The thread exit value. - * - * It is, - * - the value passed to pthread_exit(), or - * - PTHREAD_CANCELED in case it is cancelled via pthread_cancel(), or - * - NULL. - */ - void *exit_value; -#endif -} Thread_Life_control; - -typedef struct { - uint32_t flags; - void * control; -}Thread_Capture_control; - -/** - * This structure defines the Thread Control Block (TCB). - * - * Uses a leading underscore in the structure name to allow forward - * declarations in standard header files provided by Newlib and GCC. - * - * In case the second member changes (currently Join_queue), then the memset() - * in _Thread_Initialize() must be adjusted. - */ -struct _Thread_Control { - /** This field is the object management structure for each thread. */ - Objects_Control Object; - - /** - * @brief Thread queue for thread join operations and multi-purpose lock. - * - * The lock of this thread queue is used for various purposes. It protects - * the following fields - * - * - RTEMS_API_Control::Signal, - * - Thread_Control::budget_algorithm, - * - Thread_Control::budget_callout, - * - Thread_Control::cpu_time_budget, - * - Thread_Control::current_state, - * - Thread_Control::Post_switch_actions, - * - Thread_Control::Scheduler::control, and - * - Thread_Control::Scheduler::own_control. - * - * @see _Thread_State_acquire(). - */ - Thread_queue_Control Join_queue; - - /** This field is the current execution state of this thread. */ - States_Control current_state; - - /** - * @brief The base priority of this thread in its home scheduler instance. - */ - Priority_Node Real_priority; - -#if defined(RTEMS_SCORE_THREAD_ENABLE_RESOURCE_COUNT) - /** This field is the number of mutexes currently held by this thread. */ - uint32_t resource_count; -#endif - - /** - * @brief Scheduler related control. - */ - Thread_Scheduler_control Scheduler; - - /** This field is the blocking information for this thread. */ - Thread_Wait_information Wait; - /** This field is the Watchdog used to manage thread delays and timeouts. */ - Thread_Timer_information Timer; -#if defined(RTEMS_MULTIPROCESSING) - /** This field is the received response packet in an MP system. */ - MP_packet_Prefix *receive_packet; -#endif - /*================= end of common block =================*/ - -#if defined(RTEMS_SMP) && defined(RTEMS_PROFILING) - /** - * @brief Potpourri lock statistics. - * - * These SMP lock statistics are used for all lock objects that lack a - * storage space for the statistics. Examples are lock objects used in - * external libraries which are independent of the actual RTEMS build - * configuration. - */ - SMP_lock_Stats Potpourri_stats; -#endif - - /** This field is true if the thread is an idle thread. */ - bool is_idle; -#if defined(RTEMS_MULTIPROCESSING) - /** This field is true if the thread is offered globally */ - bool is_global; -#endif - /** This field is true if the thread is preemptible. */ - bool is_preemptible; - /** This field is true if the thread uses the floating point unit. */ - bool is_fp; - - /** - * @brief True, if the thread was created with an inherited scheduler - * (PTHREAD_INHERIT_SCHED), and false otherwise. - */ - bool was_created_with_inherited_scheduler; - - /** This field is the length of the time quantum that this thread is - * allowed to consume. The algorithm used to manage limits on CPU usage - * is specified by budget_algorithm. - */ - uint32_t cpu_time_budget; - /** This field is the algorithm used to manage this thread's time - * quantum. The algorithm may be specified as none which case, - * no limit is in place. - */ - Thread_CPU_budget_algorithms budget_algorithm; - /** This field is the method invoked with the budgeted time is consumed. */ - Thread_CPU_budget_algorithm_callout budget_callout; - /** This field is the amount of CPU time consumed by this thread - * since it was created. - */ - Timestamp_Control cpu_time_used; - - /** This field contains information about the starting state of - * this thread. - */ - Thread_Start_information Start; - - Thread_Action_control Post_switch_actions; - - /** This field contains the context of this thread. */ - Context_Control Registers; -#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) - /** This field points to the floating point context for this thread. - * If NULL, the thread is integer only. - */ - Context_Control_fp *fp_context; -#endif - /** This field points to the newlib reentrancy structure for this thread. */ - struct _reent *libc_reent; - /** This array contains the API extension area pointers. */ - void *API_Extensions[ THREAD_API_LAST + 1 ]; - - /** - * @brief The POSIX Keys information. - */ - Thread_Keys_information Keys; - - /** - * @brief Thread life-cycle control. - * - * Control state changes triggered by thread restart and delete requests. - */ - Thread_Life_control Life; - - Thread_Capture_control Capture; - - /** - * @brief LIFO list of POSIX cleanup contexts. - */ - struct _pthread_cleanup_context *last_cleanup_context; - - /** - * @brief LIFO list of user extensions iterators. - */ - struct User_extensions_Iterator *last_user_extensions_iterator; - - /** - * @brief Variable length array of user extension pointers. - * - * The length is defined by the application via . - */ - void *extensions[ RTEMS_ZERO_LENGTH_ARRAY ]; -}; - -#if (CPU_PROVIDES_IDLE_THREAD_BODY == FALSE) -/** - * This routine is the body of the system idle thread. - * - * NOTE: This routine is actually instantiated by confdefs.h when needed. - */ -void *_Thread_Idle_body( - uintptr_t ignored -); -#endif - -typedef void (*rtems_per_thread_routine)( Thread_Control * ); - -/* Use rtems_task_iterate() instead */ -void rtems_iterate_over_all_threads( - rtems_per_thread_routine routine -) RTEMS_DEPRECATED; - -/** - * @brief Thread control add-on. - */ -typedef struct { - /** - * @brief Offset of the pointer field in Thread_Control referencing an - * application configuration dependent memory area in the thread control - * block. - */ - size_t destination_offset; - - /** - * @brief Offset relative to the thread control block begin to an application - * configuration dependent memory area. - */ - size_t source_offset; -} Thread_Control_add_on; - -/** - * @brief Thread control add-ons. - * - * The thread control block contains fields that point to application - * configuration dependent memory areas, like the scheduler information, the - * API control blocks, the user extension context table, and the Newlib - * re-entrancy support. Account for these areas in the configuration and - * avoid extra workspace allocations for these areas. - * - * This array is provided via . - * - * @see _Thread_Control_add_on_count and _Thread_Control_size. - */ -extern const Thread_Control_add_on _Thread_Control_add_ons[]; - -/** - * @brief Thread control add-on count. - * - * Count of entries in _Thread_Control_add_ons. - * - * This value is provided via . - */ -extern const size_t _Thread_Control_add_on_count; - -/** - * @brief Size of the thread control block of a particular application. - * - * This value is provided via . - * - * @see _Thread_Control_add_ons. - */ -extern const size_t _Thread_Control_size; - -/** - * @brief Maximum size of a thread name in characters (including the - * terminating '\0' character). - * - * This value is provided via . - */ -extern const size_t _Thread_Maximum_name_size; - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/threaddispatch.h b/cpukit/score/include/rtems/score/threaddispatch.h deleted file mode 100644 index 63eb4c6fb4..0000000000 --- a/cpukit/score/include/rtems/score/threaddispatch.h +++ /dev/null @@ -1,281 +0,0 @@ -/** - * @brief Constants and Structures Related with Thread Dispatch - */ - -/* - * COPYRIGHT (c) 1989-2009. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_THREADDISPATCH_H -#define _RTEMS_SCORE_THREADDISPATCH_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @addtogroup ScoreThread - * - * @{ - */ - -#if defined(RTEMS_SMP) || ( CPU_ENABLE_ROBUST_THREAD_DISPATCH == TRUE ) -/** - * @brief Enables a robust thread dispatch. - * - * On each change of the thread dispatch disable level from one to zero the - * interrupt status is checked. In case interrupts are disabled and SMP is - * enabled or the CPU port needs it, then the system terminates with the fatal - * internal error INTERNAL_ERROR_BAD_THREAD_DISPATCH_ENVIRONMENT. - */ -#define RTEMS_SCORE_ROBUST_THREAD_DISPATCH -#endif - -/** - * @brief Indicates if the executing thread is inside a thread dispatch - * critical section. - * - * @retval true Thread dispatching is enabled. - * @retval false The executing thread is inside a thread dispatch critical - * section and dispatching is not allowed. - */ -RTEMS_INLINE_ROUTINE bool _Thread_Dispatch_is_enabled(void) -{ - bool enabled; - -#if defined(RTEMS_SMP) - ISR_Level level; - - _ISR_Local_disable( level ); -#endif - - enabled = _Thread_Dispatch_disable_level == 0; - -#if defined(RTEMS_SMP) - _ISR_Local_enable( level ); -#endif - - return enabled; -} - -/** - * @brief Gets thread dispatch disable level. - * - * @return The value of the thread dispatch level. - */ -RTEMS_INLINE_ROUTINE uint32_t _Thread_Dispatch_get_disable_level(void) -{ - return _Thread_Dispatch_disable_level; -} - -/** - * @brief Thread dispatch initialization. - * - * This routine initializes the thread dispatching subsystem. - */ -RTEMS_INLINE_ROUTINE void _Thread_Dispatch_initialization( void ) -{ - _Thread_Dispatch_disable_level = 1; -} - -/** - * @brief Performs a thread dispatch if necessary. - * - * This routine is responsible for transferring control of the processor from - * the executing thread to the heir thread. Once the heir is running an - * attempt is made to run the pending post-switch thread actions. - * - * As part of this process, it is responsible for the following actions - * - update timing information of the executing thread, - * - save the context of the executing thread, - * - invokation of the thread switch user extensions, - * - restore the context of the heir thread, and - * - run of pending post-switch thread actions of the resulting executing - * thread. - * - * On entry the thread dispatch level must be equal to zero. - */ -void _Thread_Dispatch( void ); - -/** - * @brief Directly do a thread dispatch. - * - * Must be called with a thread dispatch disable level of one, otherwise the - * INTERNAL_ERROR_BAD_THREAD_DISPATCH_DISABLE_LEVEL will occur. This function - * is useful for operations which synchronously block, e.g. self restart, self - * deletion, yield, sleep. - * - * @param[in] cpu_self The current processor. - * - * @see _Thread_Dispatch(). - */ -void _Thread_Dispatch_direct( Per_CPU_Control *cpu_self ); - -/** - * @brief Performs a thread dispatch on the current processor. - * - * On entry the thread dispatch disable level must be equal to one and - * interrupts must be disabled. - * - * This function assumes that a thread dispatch is necessary. - * - * @param[in] cpu_self The current processor. - * @param[in] level The previous interrupt level. - * - * @see _Thread_Dispatch(). - */ -void _Thread_Do_dispatch( Per_CPU_Control *cpu_self, ISR_Level level ); - -/** - * @brief Disables thread dispatching inside a critical section (interrupts - * disabled) with the current processor. - * - * @param[in] cpu_self The current processor. - * @param[in] lock_context The lock context of the corresponding - * _ISR_lock_ISR_disable() that started the critical section. - * - * @return The current processor. - */ -RTEMS_INLINE_ROUTINE Per_CPU_Control *_Thread_Dispatch_disable_with_CPU( - Per_CPU_Control *cpu_self, - const ISR_lock_Context *lock_context -) -{ - uint32_t disable_level; - - disable_level = cpu_self->thread_dispatch_disable_level; - _Profiling_Thread_dispatch_disable_critical( - cpu_self, - disable_level, - lock_context - ); - cpu_self->thread_dispatch_disable_level = disable_level + 1; - - return cpu_self; -} - -/** - * @brief Disables thread dispatching inside a critical section (interrupts - * disabled). - * - * @param[in] lock_context The lock context of the corresponding - * _ISR_lock_ISR_disable() that started the critical section. - * - * @return The current processor. - */ -RTEMS_INLINE_ROUTINE Per_CPU_Control *_Thread_Dispatch_disable_critical( - const ISR_lock_Context *lock_context -) -{ - return _Thread_Dispatch_disable_with_CPU( _Per_CPU_Get(), lock_context ); -} - -/** - * @brief Disables thread dispatching. - * - * @return The current processor. - */ -RTEMS_INLINE_ROUTINE Per_CPU_Control *_Thread_Dispatch_disable( void ) -{ - Per_CPU_Control *cpu_self; - ISR_lock_Context lock_context; - -#if defined( RTEMS_SMP ) || defined( RTEMS_PROFILING ) - _ISR_lock_ISR_disable( &lock_context ); -#endif - - cpu_self = _Thread_Dispatch_disable_critical( &lock_context ); - -#if defined( RTEMS_SMP ) || defined( RTEMS_PROFILING ) - _ISR_lock_ISR_enable( &lock_context ); -#endif - - return cpu_self; -} - -/** - * @brief Enables thread dispatching. - * - * May perfrom a thread dispatch if necessary as a side-effect. - * - * @param[in] cpu_self The current processor. - */ -RTEMS_INLINE_ROUTINE void _Thread_Dispatch_enable( Per_CPU_Control *cpu_self ) -{ - uint32_t disable_level = cpu_self->thread_dispatch_disable_level; - - if ( disable_level == 1 ) { - ISR_Level level; - - _ISR_Local_disable( level ); - - if ( - cpu_self->dispatch_necessary -#if defined(RTEMS_SCORE_ROBUST_THREAD_DISPATCH) - || !_ISR_Is_enabled( level ) -#endif - ) { - _Thread_Do_dispatch( cpu_self, level ); - } else { - cpu_self->thread_dispatch_disable_level = 0; - _Profiling_Thread_dispatch_enable( cpu_self, 0 ); - } - - _ISR_Local_enable( level ); - } else { - _Assert( disable_level > 0 ); - cpu_self->thread_dispatch_disable_level = disable_level - 1; - } -} - -/** - * @brief Unnests thread dispatching. - * - * @param[in] cpu_self The current processor. - */ -RTEMS_INLINE_ROUTINE void _Thread_Dispatch_unnest( Per_CPU_Control *cpu_self ) -{ - _Assert( cpu_self->thread_dispatch_disable_level > 0 ); - --cpu_self->thread_dispatch_disable_level; -} - -/** - * @brief Requests a thread dispatch on the target processor. - * - * @param[in] cpu_self The current processor. - * @param[in] cpu_target The target processor to request a thread dispatch. - */ -RTEMS_INLINE_ROUTINE void _Thread_Dispatch_request( - Per_CPU_Control *cpu_self, - Per_CPU_Control *cpu_target -) -{ -#if defined( RTEMS_SMP ) - if ( cpu_self == cpu_target ) { - cpu_self->dispatch_necessary = true; - } else { - _Atomic_Fetch_or_ulong( &cpu_target->message, 0, ATOMIC_ORDER_RELEASE ); - _CPU_SMP_Send_interrupt( _Per_CPU_Get_index( cpu_target ) ); - } -#else - cpu_self->dispatch_necessary = true; - (void) cpu_target; -#endif -} - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_SCORE_THREADDISPATCH_H */ diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h deleted file mode 100644 index b6722fae19..0000000000 --- a/cpukit/score/include/rtems/score/threadimpl.h +++ /dev/null @@ -1,1969 +0,0 @@ -/** - * @file - * - * @brief Inlined Routines from the Thread Handler - * - * This file contains the macro implementation of the inlined - * routines from the Thread handler. - */ - -/* - * COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * Copyright (c) 2014, 2017 embedded brains GmbH. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_THREADIMPL_H -#define _RTEMS_SCORE_THREADIMPL_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ScoreThread - */ -/**@{**/ - -/** - * The following structure contains the information necessary to manage - * a thread which it is waiting for a resource. - */ -#define THREAD_STATUS_PROXY_BLOCKING 0x1111111 - -/** - * Self for the GNU Ada Run-Time - */ -extern void *rtems_ada_self; - -typedef struct { - Objects_Information Objects; - - Freechain_Control Free_thread_queue_heads; -} Thread_Information; - -/** - * The following defines the information control block used to - * manage this class of objects. - */ -extern Thread_Information _Thread_Internal_information; - -/** - * @brief Object identifier of the global constructor thread. - * - * This variable is set by _RTEMS_tasks_Initialize_user_tasks_body() or - * _POSIX_Threads_Initialize_user_threads_body(). - * - * It is consumed by _Thread_Handler(). - */ -extern Objects_Id _Thread_Global_constructor; - -/** - * The following points to the thread whose floating point - * context is currently loaded. - */ -#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) -extern Thread_Control *_Thread_Allocated_fp; -#endif - -#if defined(RTEMS_SMP) -#define THREAD_OF_SCHEDULER_HELP_NODE( node ) \ - RTEMS_CONTAINER_OF( node, Thread_Control, Scheduler.Help_node ) -#endif - -typedef bool ( *Thread_Visitor )( Thread_Control *the_thread, void *arg ); - -void _Thread_Iterate( - Thread_Visitor visitor, - void *arg -); - -void _Thread_Initialize_information( - Thread_Information *information, - Objects_APIs the_api, - uint16_t the_class, - uint32_t maximum, - bool is_string, - uint32_t maximum_name_length -); - -/** - * @brief Initialize thread handler. - * - * This routine performs the initialization necessary for this handler. - */ -void _Thread_Handler_initialization(void); - -/** - * @brief Create idle thread. - * - * This routine creates the idle thread. - * - * @warning No thread should be created before this one. - */ -void _Thread_Create_idle(void); - -/** - * @brief Start thread multitasking. - * - * This routine initiates multitasking. It is invoked only as - * part of initialization and its invocation is the last act of - * the non-multitasking part of the system initialization. - */ -void _Thread_Start_multitasking( void ) RTEMS_NO_RETURN; - -/** - * @brief Allocate the requested stack space for the thread. - * - * Allocate the requested stack space for the thread. - * Set the Start.stack field to the address of the stack. - * - * @param[in] the_thread is the thread where the stack space is requested - * @param[in] stack_size is the stack space is requested - * - * @retval actual size allocated after any adjustment - * @retval zero if the allocation failed - */ -size_t _Thread_Stack_Allocate( - Thread_Control *the_thread, - size_t stack_size -); - -/** - * @brief Deallocate thread stack. - * - * Deallocate the Thread's stack. - */ -void _Thread_Stack_Free( - Thread_Control *the_thread -); - -/** - * @brief Initialize thread. - * - * This routine initializes the specified the thread. It allocates - * all memory associated with this thread. It completes by adding - * the thread to the local object table so operations on this - * thread id are allowed. - * - * @note If stack_area is NULL, it is allocated from the workspace. - * - * @note If the stack is allocated from the workspace, then it is - * guaranteed to be of at least minimum size. - */ -bool _Thread_Initialize( - Thread_Information *information, - Thread_Control *the_thread, - const struct _Scheduler_Control *scheduler, - void *stack_area, - size_t stack_size, - bool is_fp, - Priority_Control priority, - bool is_preemptible, - Thread_CPU_budget_algorithms budget_algorithm, - Thread_CPU_budget_algorithm_callout budget_callout, - uint32_t isr_level, - Objects_Name name -); - -/** - * @brief Initializes thread and executes it. - * - * This routine initializes the executable information for a thread - * and makes it ready to execute. After this routine executes, the - * thread competes with all other threads for CPU time. - * - * @param the_thread The thread to be started. - * @param entry The thread entry information. - */ -bool _Thread_Start( - Thread_Control *the_thread, - const Thread_Entry_information *entry, - ISR_lock_Context *lock_context -); - -void _Thread_Restart_self( - Thread_Control *executing, - const Thread_Entry_information *entry, - ISR_lock_Context *lock_context -) RTEMS_NO_RETURN; - -bool _Thread_Restart_other( - Thread_Control *the_thread, - const Thread_Entry_information *entry, - ISR_lock_Context *lock_context -); - -void _Thread_Yield( Thread_Control *executing ); - -Thread_Life_state _Thread_Change_life( - Thread_Life_state clear, - Thread_Life_state set, - Thread_Life_state ignore -); - -Thread_Life_state _Thread_Set_life_protection( Thread_Life_state state ); - -/** - * @brief Kills all zombie threads in the system. - * - * Threads change into the zombie state as the last step in the thread - * termination sequence right before a context switch to the heir thread is - * initiated. Since the thread stack is still in use during this phase we have - * to postpone the thread stack reclamation until this point. On SMP - * configurations we may have to busy wait for context switch completion here. - */ -void _Thread_Kill_zombies( void ); - -void _Thread_Exit( - Thread_Control *executing, - Thread_Life_state set, - void *exit_value -); - -void _Thread_Join( - Thread_Control *the_thread, - States_Control waiting_for_join, - Thread_Control *executing, - Thread_queue_Context *queue_context -); - -void _Thread_Cancel( - Thread_Control *the_thread, - Thread_Control *executing, - void *exit_value -); - -typedef struct { - Thread_queue_Context Base; - Thread_Control *cancel; -} Thread_Close_context; - -/** - * @brief Closes the thread. - * - * Closes the thread object and starts the thread termination sequence. In - * case the executing thread is not terminated, then this function waits until - * the terminating thread reached the zombie state. - */ -void _Thread_Close( - Thread_Control *the_thread, - Thread_Control *executing, - Thread_Close_context *context -); - -RTEMS_INLINE_ROUTINE bool _Thread_Is_ready( const Thread_Control *the_thread ) -{ - return _States_Is_ready( the_thread->current_state ); -} - -States_Control _Thread_Clear_state_locked( - Thread_Control *the_thread, - States_Control state -); - -/** - * @brief Clears the specified thread state. - * - * In case the previous state is a non-ready state and the next state is the - * ready state, then the thread is unblocked by the scheduler. - * - * @param[in] the_thread The thread. - * @param[in] state The state to clear. It must not be zero. - * - * @return The previous state. - */ -States_Control _Thread_Clear_state( - Thread_Control *the_thread, - States_Control state -); - -States_Control _Thread_Set_state_locked( - Thread_Control *the_thread, - States_Control state -); - -/** - * @brief Sets the specified thread state. - * - * In case the previous state is the ready state, then the thread is blocked by - * the scheduler. - * - * @param[in] the_thread The thread. - * @param[in] state The state to set. It must not be zero. - * - * @return The previous state. - */ -States_Control _Thread_Set_state( - Thread_Control *the_thread, - States_Control state -); - -/** - * @brief Initializes enviroment for a thread. - * - * This routine initializes the context of @a the_thread to its - * appropriate starting state. - * - * @param[in] the_thread is the pointer to the thread control block. - */ -void _Thread_Load_environment( - Thread_Control *the_thread -); - -void _Thread_Entry_adaptor_idle( Thread_Control *executing ); - -void _Thread_Entry_adaptor_numeric( Thread_Control *executing ); - -void _Thread_Entry_adaptor_pointer( Thread_Control *executing ); - -/** - * @brief Wrapper function for all threads. - * - * This routine is the wrapper function for all threads. It is - * the starting point for all threads. The user provided thread - * entry point is invoked by this routine. Operations - * which must be performed immediately before and after the user's - * thread executes are found here. - * - * @note On entry, it is assumed all interrupts are blocked and that this - * routine needs to set the initial isr level. This may or may not - * actually be needed by the context switch routine and as a result - * interrupts may already be at there proper level. Either way, - * setting the initial isr level properly here is safe. - */ -void _Thread_Handler( void ); - -RTEMS_INLINE_ROUTINE void _Thread_State_acquire_critical( - Thread_Control *the_thread, - ISR_lock_Context *lock_context -) -{ - _Thread_queue_Do_acquire_critical( &the_thread->Join_queue, lock_context ); -} - -RTEMS_INLINE_ROUTINE void _Thread_State_acquire( - Thread_Control *the_thread, - ISR_lock_Context *lock_context -) -{ - _ISR_lock_ISR_disable( lock_context ); - _Thread_State_acquire_critical( the_thread, lock_context ); -} - -RTEMS_INLINE_ROUTINE Thread_Control *_Thread_State_acquire_for_executing( - ISR_lock_Context *lock_context -) -{ - Thread_Control *executing; - - _ISR_lock_ISR_disable( lock_context ); - executing = _Thread_Executing; - _Thread_State_acquire_critical( executing, lock_context ); - - return executing; -} - -RTEMS_INLINE_ROUTINE void _Thread_State_release_critical( - Thread_Control *the_thread, - ISR_lock_Context *lock_context -) -{ - _Thread_queue_Do_release_critical( &the_thread->Join_queue, lock_context ); -} - -RTEMS_INLINE_ROUTINE void _Thread_State_release( - Thread_Control *the_thread, - ISR_lock_Context *lock_context -) -{ - _Thread_State_release_critical( the_thread, lock_context ); - _ISR_lock_ISR_enable( lock_context ); -} - -#if defined(RTEMS_DEBUG) -RTEMS_INLINE_ROUTINE bool _Thread_State_is_owner( - const Thread_Control *the_thread -) -{ - return _Thread_queue_Is_lock_owner( &the_thread->Join_queue ); -} -#endif - -/** - * @brief Performs the priority actions specified by the thread queue context - * along the thread queue path. - * - * The caller must be the owner of the thread wait lock. - * - * @param start_of_path The start thread of the thread queue path. - * @param queue_context The thread queue context specifying the thread queue - * path and initial thread priority actions. - * - * @see _Thread_queue_Path_acquire_critical(). - */ -void _Thread_Priority_perform_actions( - Thread_Control *start_of_path, - Thread_queue_Context *queue_context -); - -/** - * @brief Adds the specified thread priority node to the corresponding thread - * priority aggregation. - * - * The caller must be the owner of the thread wait lock. - * - * @param the_thread The thread. - * @param priority_node The thread priority node to add. - * @param queue_context The thread queue context to return an updated set of - * threads for _Thread_Priority_update(). The thread queue context must be - * initialized via _Thread_queue_Context_clear_priority_updates() before a - * call of this function. - * - * @see _Thread_Wait_acquire(). - */ -void _Thread_Priority_add( - Thread_Control *the_thread, - Priority_Node *priority_node, - Thread_queue_Context *queue_context -); - -/** - * @brief Removes the specified thread priority node from the corresponding - * thread priority aggregation. - * - * The caller must be the owner of the thread wait lock. - * - * @param the_thread The thread. - * @param priority_node The thread priority node to remove. - * @param queue_context The thread queue context to return an updated set of - * threads for _Thread_Priority_update(). The thread queue context must be - * initialized via _Thread_queue_Context_clear_priority_updates() before a - * call of this function. - * - * @see _Thread_Wait_acquire(). - */ -void _Thread_Priority_remove( - Thread_Control *the_thread, - Priority_Node *priority_node, - Thread_queue_Context *queue_context -); - -/** - * @brief Propagates a thread priority value change in the specified thread - * priority node to the corresponding thread priority aggregation. - * - * The caller must be the owner of the thread wait lock. - * - * @param the_thread The thread. - * @param priority_node The thread priority node to change. - * @param prepend_it In case this is true, then the thread is prepended to - * its priority group in its home scheduler instance, otherwise it is - * appended. - * @param queue_context The thread queue context to return an updated set of - * threads for _Thread_Priority_update(). The thread queue context must be - * initialized via _Thread_queue_Context_clear_priority_updates() before a - * call of this function. - * - * @see _Thread_Wait_acquire(). - */ -void _Thread_Priority_changed( - Thread_Control *the_thread, - Priority_Node *priority_node, - bool prepend_it, - Thread_queue_Context *queue_context -); - -/** - * @brief Changes the thread priority value of the specified thread priority - * node in the corresponding thread priority aggregation. - * - * The caller must be the owner of the thread wait lock. - * - * @param the_thread The thread. - * @param priority_node The thread priority node to change. - * @param new_priority The new thread priority value of the thread priority - * node to change. - * @param prepend_it In case this is true, then the thread is prepended to - * its priority group in its home scheduler instance, otherwise it is - * appended. - * @param queue_context The thread queue context to return an updated set of - * threads for _Thread_Priority_update(). The thread queue context must be - * initialized via _Thread_queue_Context_clear_priority_updates() before a - * call of this function. - * - * @see _Thread_Wait_acquire(). - */ -RTEMS_INLINE_ROUTINE void _Thread_Priority_change( - Thread_Control *the_thread, - Priority_Node *priority_node, - Priority_Control new_priority, - bool prepend_it, - Thread_queue_Context *queue_context -) -{ - _Priority_Node_set_priority( priority_node, new_priority ); - _Thread_Priority_changed( - the_thread, - priority_node, - prepend_it, - queue_context - ); -} - -/** - * @brief Replaces the victim priority node with the replacement priority node - * in the corresponding thread priority aggregation. - * - * The caller must be the owner of the thread wait lock. - * - * @param the_thread The thread. - * @param victim_node The victim thread priority node. - * @param replacement_node The replacement thread priority node. - * - * @see _Thread_Wait_acquire(). - */ -void _Thread_Priority_replace( - Thread_Control *the_thread, - Priority_Node *victim_node, - Priority_Node *replacement_node -); - -/** - * @brief Adds a priority node to the corresponding thread priority - * aggregation. - * - * The caller must be the owner of the thread wait lock. - * - * @param the_thread The thread. - * @param priority_node The thread priority node to add. - * @param queue_context The thread queue context to return an updated set of - * threads for _Thread_Priority_update(). The thread queue context must be - * initialized via _Thread_queue_Context_clear_priority_updates() before a - * call of this function. - * - * @see _Thread_Priority_add(), _Thread_Priority_change(), - * _Thread_Priority_changed() and _Thread_Priority_remove(). - */ -void _Thread_Priority_update( Thread_queue_Context *queue_context ); - -#if defined(RTEMS_SMP) -void _Thread_Priority_and_sticky_update( - Thread_Control *the_thread, - int sticky_level_change -); -#endif - -/** - * @brief Returns true if the left thread priority is less than the right - * thread priority in the intuitive sense of priority and false otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Thread_Priority_less_than( - Priority_Control left, - Priority_Control right -) -{ - return left > right; -} - -/** - * @brief Returns the highest priority of the left and right thread priorities - * in the intuitive sense of priority. - */ -RTEMS_INLINE_ROUTINE Priority_Control _Thread_Priority_highest( - Priority_Control left, - Priority_Control right -) -{ - return _Thread_Priority_less_than( left, right ) ? right : left; -} - -RTEMS_INLINE_ROUTINE Objects_Information *_Thread_Get_objects_information( - Objects_Id id -) -{ - uint32_t the_api; - - the_api = _Objects_Get_API( id ); - - if ( !_Objects_Is_api_valid( the_api ) ) { - return NULL; - } - - /* - * Threads are always first class :) - * - * There is no need to validate the object class of the object identifier, - * since this will be done by the object get methods. - */ - return _Objects_Information_table[ the_api ][ 1 ]; -} - -/** - * @brief Gets a thread by its identifier. - * - * @see _Objects_Get(). - */ -Thread_Control *_Thread_Get( - Objects_Id id, - ISR_lock_Context *lock_context -); - -RTEMS_INLINE_ROUTINE Per_CPU_Control *_Thread_Get_CPU( - const Thread_Control *thread -) -{ -#if defined(RTEMS_SMP) - return thread->Scheduler.cpu; -#else - (void) thread; - - return _Per_CPU_Get(); -#endif -} - -RTEMS_INLINE_ROUTINE void _Thread_Set_CPU( - Thread_Control *thread, - Per_CPU_Control *cpu -) -{ -#if defined(RTEMS_SMP) - thread->Scheduler.cpu = cpu; -#else - (void) thread; - (void) cpu; -#endif -} - -/** - * This function returns true if the_thread is the currently executing - * thread, and false otherwise. - */ - -RTEMS_INLINE_ROUTINE bool _Thread_Is_executing ( - const Thread_Control *the_thread -) -{ - return ( the_thread == _Thread_Executing ); -} - -#if defined(RTEMS_SMP) -/** - * @brief Returns @a true in case the thread executes currently on some - * processor in the system, otherwise @a false. - * - * Do not confuse this with _Thread_Is_executing() which checks only the - * current processor. - */ -RTEMS_INLINE_ROUTINE bool _Thread_Is_executing_on_a_processor( - const Thread_Control *the_thread -) -{ - return _CPU_Context_Get_is_executing( &the_thread->Registers ); -} -#endif - -/** - * This function returns true if the_thread is the heir - * thread, and false otherwise. - */ - -RTEMS_INLINE_ROUTINE bool _Thread_Is_heir ( - const Thread_Control *the_thread -) -{ - return ( the_thread == _Thread_Heir ); -} - -/** - * This routine clears any blocking state for the_thread. It performs - * any necessary scheduling operations including the selection of - * a new heir thread. - */ - -RTEMS_INLINE_ROUTINE void _Thread_Unblock ( - Thread_Control *the_thread -) -{ - _Thread_Clear_state( the_thread, STATES_BLOCKED ); -} - -/** - * This function returns true if the floating point context of - * the_thread is currently loaded in the floating point unit, and - * false otherwise. - */ - -#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) -RTEMS_INLINE_ROUTINE bool _Thread_Is_allocated_fp ( - const Thread_Control *the_thread -) -{ - return ( the_thread == _Thread_Allocated_fp ); -} -#endif - -/* - * If the CPU has hardware floating point, then we must address saving - * and restoring it as part of the context switch. - * - * The second conditional compilation section selects the algorithm used - * to context switch between floating point tasks. The deferred algorithm - * can be significantly better in a system with few floating point tasks - * because it reduces the total number of save and restore FP context - * operations. However, this algorithm can not be used on all CPUs due - * to unpredictable use of FP registers by some compilers for integer - * operations. - */ - -RTEMS_INLINE_ROUTINE void _Thread_Save_fp( Thread_Control *executing ) -{ -#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) -#if ( CPU_USE_DEFERRED_FP_SWITCH != TRUE ) - if ( executing->fp_context != NULL ) - _Context_Save_fp( &executing->fp_context ); -#endif -#endif -} - -RTEMS_INLINE_ROUTINE void _Thread_Restore_fp( Thread_Control *executing ) -{ -#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) -#if ( CPU_USE_DEFERRED_FP_SWITCH == TRUE ) - if ( (executing->fp_context != NULL) && - !_Thread_Is_allocated_fp( executing ) ) { - if ( _Thread_Allocated_fp != NULL ) - _Context_Save_fp( &_Thread_Allocated_fp->fp_context ); - _Context_Restore_fp( &executing->fp_context ); - _Thread_Allocated_fp = executing; - } -#else - if ( executing->fp_context != NULL ) - _Context_Restore_fp( &executing->fp_context ); -#endif -#endif -} - -/** - * This routine is invoked when the currently loaded floating - * point context is now longer associated with an active thread. - */ - -#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) -RTEMS_INLINE_ROUTINE void _Thread_Deallocate_fp( void ) -{ - _Thread_Allocated_fp = NULL; -} -#endif - -/** - * This function returns true if dispatching is disabled, and false - * otherwise. - */ - -RTEMS_INLINE_ROUTINE bool _Thread_Is_context_switch_necessary( void ) -{ - return ( _Thread_Dispatch_necessary ); -} - -/** - * This function returns true if the_thread is NULL and false otherwise. - */ - -RTEMS_INLINE_ROUTINE bool _Thread_Is_null ( - const Thread_Control *the_thread -) -{ - return ( the_thread == NULL ); -} - -/** - * @brief Is proxy blocking. - * - * status which indicates that a proxy is blocking, and false otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Thread_Is_proxy_blocking ( - uint32_t code -) -{ - return (code == THREAD_STATUS_PROXY_BLOCKING); -} - -RTEMS_INLINE_ROUTINE uint32_t _Thread_Get_maximum_internal_threads(void) -{ - /* Idle threads */ - uint32_t maximum_internal_threads = - rtems_configuration_get_maximum_processors(); - - /* MPCI thread */ -#if defined(RTEMS_MULTIPROCESSING) - if ( _System_state_Is_multiprocessing ) { - ++maximum_internal_threads; - } -#endif - - return maximum_internal_threads; -} - -RTEMS_INLINE_ROUTINE Thread_Control *_Thread_Internal_allocate( void ) -{ - return (Thread_Control *) - _Objects_Allocate_unprotected( &_Thread_Internal_information.Objects ); -} - -/** - * @brief Gets the heir of the processor and makes it executing. - * - * Must be called with interrupts disabled. The thread dispatch necessary - * indicator is cleared as a side-effect. - * - * @return The heir thread. - * - * @see _Thread_Dispatch(), _Thread_Start_multitasking() and - * _Thread_Dispatch_update_heir(). - */ -RTEMS_INLINE_ROUTINE Thread_Control *_Thread_Get_heir_and_make_it_executing( - Per_CPU_Control *cpu_self -) -{ - Thread_Control *heir; - - heir = cpu_self->heir; - cpu_self->dispatch_necessary = false; - cpu_self->executing = heir; - - return heir; -} - -RTEMS_INLINE_ROUTINE void _Thread_Update_CPU_time_used( - Thread_Control *the_thread, - Per_CPU_Control *cpu -) -{ - Timestamp_Control last; - Timestamp_Control ran; - - last = cpu->cpu_usage_timestamp; - _TOD_Get_uptime( &cpu->cpu_usage_timestamp ); - _Timestamp_Subtract( &last, &cpu->cpu_usage_timestamp, &ran ); - _Timestamp_Add_to( &the_thread->cpu_time_used, &ran ); -} - -#if defined( RTEMS_SMP ) -RTEMS_INLINE_ROUTINE void _Thread_Dispatch_update_heir( - Per_CPU_Control *cpu_self, - Per_CPU_Control *cpu_for_heir, - Thread_Control *heir -) -{ - _Thread_Update_CPU_time_used( cpu_for_heir->heir, cpu_for_heir ); - - cpu_for_heir->heir = heir; - - _Thread_Dispatch_request( cpu_self, cpu_for_heir ); -} -#endif - -void _Thread_Get_CPU_time_used( - Thread_Control *the_thread, - Timestamp_Control *cpu_time_used -); - -RTEMS_INLINE_ROUTINE void _Thread_Action_control_initialize( - Thread_Action_control *action_control -) -{ - _Chain_Initialize_empty( &action_control->Chain ); -} - -RTEMS_INLINE_ROUTINE void _Thread_Action_initialize( - Thread_Action *action -) -{ - _Chain_Set_off_chain( &action->Node ); -} - -RTEMS_INLINE_ROUTINE void _Thread_Add_post_switch_action( - Thread_Control *the_thread, - Thread_Action *action, - Thread_Action_handler handler -) -{ - Per_CPU_Control *cpu_of_thread; - - _Assert( _Thread_State_is_owner( the_thread ) ); - - cpu_of_thread = _Thread_Get_CPU( the_thread ); - - action->handler = handler; - - _Thread_Dispatch_request( _Per_CPU_Get(), cpu_of_thread ); - - _Chain_Append_if_is_off_chain_unprotected( - &the_thread->Post_switch_actions.Chain, - &action->Node - ); -} - -RTEMS_INLINE_ROUTINE bool _Thread_Is_life_restarting( - Thread_Life_state life_state -) -{ - return ( life_state & THREAD_LIFE_RESTARTING ) != 0; -} - -RTEMS_INLINE_ROUTINE bool _Thread_Is_life_terminating( - Thread_Life_state life_state -) -{ - return ( life_state & THREAD_LIFE_TERMINATING ) != 0; -} - -RTEMS_INLINE_ROUTINE bool _Thread_Is_life_change_allowed( - Thread_Life_state life_state -) -{ - return ( life_state - & ( THREAD_LIFE_PROTECTED | THREAD_LIFE_CHANGE_DEFERRED ) ) == 0; -} - -RTEMS_INLINE_ROUTINE bool _Thread_Is_life_changing( - Thread_Life_state life_state -) -{ - return ( life_state - & ( THREAD_LIFE_RESTARTING | THREAD_LIFE_TERMINATING ) ) != 0; -} - -RTEMS_INLINE_ROUTINE bool _Thread_Is_joinable( - const Thread_Control *the_thread -) -{ - _Assert( _Thread_State_is_owner( the_thread ) ); - return ( the_thread->Life.state & THREAD_LIFE_DETACHED ) == 0; -} - -RTEMS_INLINE_ROUTINE void _Thread_Resource_count_increment( - Thread_Control *the_thread -) -{ -#if defined(RTEMS_SCORE_THREAD_ENABLE_RESOURCE_COUNT) - ++the_thread->resource_count; -#else - (void) the_thread; -#endif -} - -RTEMS_INLINE_ROUTINE void _Thread_Resource_count_decrement( - Thread_Control *the_thread -) -{ -#if defined(RTEMS_SCORE_THREAD_ENABLE_RESOURCE_COUNT) - --the_thread->resource_count; -#else - (void) the_thread; -#endif -} - -#if defined(RTEMS_SCORE_THREAD_ENABLE_RESOURCE_COUNT) -/** - * @brief Returns true if the thread owns resources, and false otherwise. - * - * Resources are accounted with the Thread_Control::resource_count resource - * counter. This counter is used by mutex objects for example. - * - * @param[in] the_thread The thread. - */ -RTEMS_INLINE_ROUTINE bool _Thread_Owns_resources( - const Thread_Control *the_thread -) -{ - return the_thread->resource_count != 0; -} -#endif - -#if defined(RTEMS_SMP) -RTEMS_INLINE_ROUTINE void _Thread_Scheduler_cancel_need_for_help( - Thread_Control *the_thread, - Per_CPU_Control *cpu -) -{ - _Per_CPU_Acquire( cpu ); - - if ( !_Chain_Is_node_off_chain( &the_thread->Scheduler.Help_node ) ) { - _Chain_Extract_unprotected( &the_thread->Scheduler.Help_node ); - _Chain_Set_off_chain( &the_thread->Scheduler.Help_node ); - } - - _Per_CPU_Release( cpu ); -} -#endif - -RTEMS_INLINE_ROUTINE const Scheduler_Control *_Thread_Scheduler_get_home( - const Thread_Control *the_thread -) -{ -#if defined(RTEMS_SMP) - return the_thread->Scheduler.home; -#else - (void) the_thread; - return &_Scheduler_Table[ 0 ]; -#endif -} - -RTEMS_INLINE_ROUTINE Scheduler_Node *_Thread_Scheduler_get_home_node( - const Thread_Control *the_thread -) -{ -#if defined(RTEMS_SMP) - _Assert( !_Chain_Is_empty( &the_thread->Scheduler.Wait_nodes ) ); - return SCHEDULER_NODE_OF_THREAD_WAIT_NODE( - _Chain_First( &the_thread->Scheduler.Wait_nodes ) - ); -#else - return the_thread->Scheduler.nodes; -#endif -} - -RTEMS_INLINE_ROUTINE Scheduler_Node *_Thread_Scheduler_get_node_by_index( - const Thread_Control *the_thread, - size_t scheduler_index -) -{ -#if defined(RTEMS_SMP) - return (Scheduler_Node *) - ( (uintptr_t) the_thread->Scheduler.nodes - + scheduler_index * _Scheduler_Node_size ); -#else - _Assert( scheduler_index == 0 ); - (void) scheduler_index; - return the_thread->Scheduler.nodes; -#endif -} - -#if defined(RTEMS_SMP) -RTEMS_INLINE_ROUTINE void _Thread_Scheduler_acquire_critical( - Thread_Control *the_thread, - ISR_lock_Context *lock_context -) -{ - _ISR_lock_Acquire( &the_thread->Scheduler.Lock, lock_context ); -} - -RTEMS_INLINE_ROUTINE void _Thread_Scheduler_release_critical( - Thread_Control *the_thread, - ISR_lock_Context *lock_context -) -{ - _ISR_lock_Release( &the_thread->Scheduler.Lock, lock_context ); -} - -#if defined(RTEMS_SMP) -void _Thread_Scheduler_process_requests( Thread_Control *the_thread ); -#endif - -RTEMS_INLINE_ROUTINE void _Thread_Scheduler_add_request( - Thread_Control *the_thread, - Scheduler_Node *scheduler_node, - Scheduler_Node_request request -) -{ - ISR_lock_Context lock_context; - Scheduler_Node_request current_request; - - _Thread_Scheduler_acquire_critical( the_thread, &lock_context ); - - current_request = scheduler_node->Thread.request; - - if ( current_request == SCHEDULER_NODE_REQUEST_NOT_PENDING ) { - _Assert( - request == SCHEDULER_NODE_REQUEST_ADD - || request == SCHEDULER_NODE_REQUEST_REMOVE - ); - _Assert( scheduler_node->Thread.next_request == NULL ); - scheduler_node->Thread.next_request = the_thread->Scheduler.requests; - the_thread->Scheduler.requests = scheduler_node; - } else if ( current_request != SCHEDULER_NODE_REQUEST_NOTHING ) { - _Assert( - ( current_request == SCHEDULER_NODE_REQUEST_ADD - && request == SCHEDULER_NODE_REQUEST_REMOVE ) - || ( current_request == SCHEDULER_NODE_REQUEST_REMOVE - && request == SCHEDULER_NODE_REQUEST_ADD ) - ); - request = SCHEDULER_NODE_REQUEST_NOTHING; - } - - scheduler_node->Thread.request = request; - - _Thread_Scheduler_release_critical( the_thread, &lock_context ); -} - -RTEMS_INLINE_ROUTINE void _Thread_Scheduler_add_wait_node( - Thread_Control *the_thread, - Scheduler_Node *scheduler_node -) -{ - _Chain_Append_unprotected( - &the_thread->Scheduler.Wait_nodes, - &scheduler_node->Thread.Wait_node - ); - _Thread_Scheduler_add_request( - the_thread, - scheduler_node, - SCHEDULER_NODE_REQUEST_ADD - ); -} - -RTEMS_INLINE_ROUTINE void _Thread_Scheduler_remove_wait_node( - Thread_Control *the_thread, - Scheduler_Node *scheduler_node -) -{ - _Chain_Extract_unprotected( &scheduler_node->Thread.Wait_node ); - _Thread_Scheduler_add_request( - the_thread, - scheduler_node, - SCHEDULER_NODE_REQUEST_REMOVE - ); -} -#endif - -/** - * @brief Returns the priority of the thread. - * - * Returns the user API and thread wait information relevant thread priority. - * This includes temporary thread priority adjustments due to locking - * protocols, a job release or the POSIX sporadic server for example. - * - * @return The priority of the thread. - */ -RTEMS_INLINE_ROUTINE Priority_Control _Thread_Get_priority( - const Thread_Control *the_thread -) -{ - Scheduler_Node *scheduler_node; - - scheduler_node = _Thread_Scheduler_get_home_node( the_thread ); - return _Priority_Get_priority( &scheduler_node->Wait.Priority ); -} - -/** - * @brief Acquires the thread wait default lock inside a critical section - * (interrupts disabled). - * - * @param[in] the_thread The thread. - * @param[in] lock_context The lock context used for the corresponding lock - * release. - * - * @see _Thread_Wait_release_default_critical(). - */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire_default_critical( - Thread_Control *the_thread, - ISR_lock_Context *lock_context -) -{ - _ISR_lock_Acquire( &the_thread->Wait.Lock.Default, lock_context ); -} - -/** - * @brief Acquires the thread wait default lock and returns the executing - * thread. - * - * @param[in] lock_context The lock context used for the corresponding lock - * release. - * - * @return The executing thread. - * - * @see _Thread_Wait_release_default(). - */ -RTEMS_INLINE_ROUTINE Thread_Control *_Thread_Wait_acquire_default_for_executing( - ISR_lock_Context *lock_context -) -{ - Thread_Control *executing; - - _ISR_lock_ISR_disable( lock_context ); - executing = _Thread_Executing; - _Thread_Wait_acquire_default_critical( executing, lock_context ); - - return executing; -} - -/** - * @brief Acquires the thread wait default lock and disables interrupts. - * - * @param[in] the_thread The thread. - * @param[in] lock_context The lock context used for the corresponding lock - * release. - * - * @see _Thread_Wait_release_default(). - */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire_default( - Thread_Control *the_thread, - ISR_lock_Context *lock_context -) -{ - _ISR_lock_ISR_disable( lock_context ); - _Thread_Wait_acquire_default_critical( the_thread, lock_context ); -} - -/** - * @brief Releases the thread wait default lock inside a critical section - * (interrupts disabled). - * - * The previous interrupt status is not restored. - * - * @param[in] the_thread The thread. - * @param[in] lock_context The lock context used for the corresponding lock - * acquire. - */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_release_default_critical( - Thread_Control *the_thread, - ISR_lock_Context *lock_context -) -{ - _ISR_lock_Release( &the_thread->Wait.Lock.Default, lock_context ); -} - -/** - * @brief Releases the thread wait default lock and restores the previous - * interrupt status. - * - * @param[in] the_thread The thread. - * @param[in] lock_context The lock context used for the corresponding lock - * acquire. - */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_release_default( - Thread_Control *the_thread, - ISR_lock_Context *lock_context -) -{ - _Thread_Wait_release_default_critical( the_thread, lock_context ); - _ISR_lock_ISR_enable( lock_context ); -} - -#if defined(RTEMS_SMP) -#define THREAD_QUEUE_CONTEXT_OF_REQUEST( node ) \ - RTEMS_CONTAINER_OF( node, Thread_queue_Context, Lock_context.Wait.Gate.Node ) - -RTEMS_INLINE_ROUTINE void _Thread_Wait_remove_request_locked( - Thread_Control *the_thread, - Thread_queue_Lock_context *queue_lock_context -) -{ - Chain_Node *first; - - _Chain_Extract_unprotected( &queue_lock_context->Wait.Gate.Node ); - first = _Chain_First( &the_thread->Wait.Lock.Pending_requests ); - - if ( first != _Chain_Tail( &the_thread->Wait.Lock.Pending_requests ) ) { - _Thread_queue_Gate_open( (Thread_queue_Gate *) first ); - } -} - -RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire_queue_critical( - Thread_queue_Queue *queue, - Thread_queue_Lock_context *queue_lock_context -) -{ - _Thread_queue_Queue_acquire_critical( - queue, - &_Thread_Executing->Potpourri_stats, - &queue_lock_context->Lock_context - ); -} - -RTEMS_INLINE_ROUTINE void _Thread_Wait_release_queue_critical( - Thread_queue_Queue *queue, - Thread_queue_Lock_context *queue_lock_context -) -{ - _Thread_queue_Queue_release_critical( - queue, - &queue_lock_context->Lock_context - ); -} -#endif - -/** - * @brief Acquires the thread wait lock inside a critical section (interrupts - * disabled). - * - * @param[in] the_thread The thread. - * @param[in] queue_context The thread queue context for the corresponding - * _Thread_Wait_release_critical(). - */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire_critical( - Thread_Control *the_thread, - Thread_queue_Context *queue_context -) -{ -#if defined(RTEMS_SMP) - Thread_queue_Queue *queue; - - _Thread_Wait_acquire_default_critical( - the_thread, - &queue_context->Lock_context.Lock_context - ); - - queue = the_thread->Wait.queue; - queue_context->Lock_context.Wait.queue = queue; - - if ( queue != NULL ) { - _Thread_queue_Gate_add( - &the_thread->Wait.Lock.Pending_requests, - &queue_context->Lock_context.Wait.Gate - ); - _Thread_Wait_release_default_critical( - the_thread, - &queue_context->Lock_context.Lock_context - ); - _Thread_Wait_acquire_queue_critical( queue, &queue_context->Lock_context ); - - if ( queue_context->Lock_context.Wait.queue == NULL ) { - _Thread_Wait_release_queue_critical( - queue, - &queue_context->Lock_context - ); - _Thread_Wait_acquire_default_critical( - the_thread, - &queue_context->Lock_context.Lock_context - ); - _Thread_Wait_remove_request_locked( - the_thread, - &queue_context->Lock_context - ); - _Assert( the_thread->Wait.queue == NULL ); - } - } -#else - (void) the_thread; - (void) queue_context; -#endif -} - -/** - * @brief Acquires the thread wait default lock and disables interrupts. - * - * @param[in] the_thread The thread. - * @param[in] queue_context The thread queue context for the corresponding - * _Thread_Wait_release(). - */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_acquire( - Thread_Control *the_thread, - Thread_queue_Context *queue_context -) -{ - _ISR_lock_ISR_disable( &queue_context->Lock_context.Lock_context ); - _Thread_Wait_acquire_critical( the_thread, queue_context ); -} - -/** - * @brief Releases the thread wait lock inside a critical section (interrupts - * disabled). - * - * The previous interrupt status is not restored. - * - * @param[in] the_thread The thread. - * @param[in] queue_context The thread queue context used for corresponding - * _Thread_Wait_acquire_critical(). - */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_release_critical( - Thread_Control *the_thread, - Thread_queue_Context *queue_context -) -{ -#if defined(RTEMS_SMP) - Thread_queue_Queue *queue; - - queue = queue_context->Lock_context.Wait.queue; - - if ( queue != NULL ) { - _Thread_Wait_release_queue_critical( - queue, &queue_context->Lock_context - ); - _Thread_Wait_acquire_default_critical( - the_thread, - &queue_context->Lock_context.Lock_context - ); - _Thread_Wait_remove_request_locked( - the_thread, - &queue_context->Lock_context - ); - } - - _Thread_Wait_release_default_critical( - the_thread, - &queue_context->Lock_context.Lock_context - ); -#else - (void) the_thread; - (void) queue_context; -#endif -} - -/** - * @brief Releases the thread wait lock and restores the previous interrupt - * status. - * - * @param[in] the_thread The thread. - * @param[in] queue_context The thread queue context used for corresponding - * _Thread_Wait_acquire(). - */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_release( - Thread_Control *the_thread, - Thread_queue_Context *queue_context -) -{ - _Thread_Wait_release_critical( the_thread, queue_context ); - _ISR_lock_ISR_enable( &queue_context->Lock_context.Lock_context ); -} - -/** - * @brief Claims the thread wait queue. - * - * The caller must not be the owner of the default thread wait lock. The - * caller must be the owner of the corresponding thread queue lock. The - * registration of the corresponding thread queue operations is deferred and - * done after the deadlock detection. This is crucial to support timeouts on - * SMP configurations. - * - * @param[in] the_thread The thread. - * @param[in] queue The new thread queue. - * - * @see _Thread_Wait_claim_finalize() and _Thread_Wait_restore_default(). - */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_claim( - Thread_Control *the_thread, - Thread_queue_Queue *queue -) -{ - ISR_lock_Context lock_context; - - _Thread_Wait_acquire_default_critical( the_thread, &lock_context ); - - _Assert( the_thread->Wait.queue == NULL ); - -#if defined(RTEMS_SMP) - _Chain_Initialize_empty( &the_thread->Wait.Lock.Pending_requests ); - _Chain_Initialize_node( &the_thread->Wait.Lock.Tranquilizer.Node ); - _Thread_queue_Gate_close( &the_thread->Wait.Lock.Tranquilizer ); -#endif - - the_thread->Wait.queue = queue; - - _Thread_Wait_release_default_critical( the_thread, &lock_context ); -} - -/** - * @brief Finalizes the thread wait queue claim via registration of the - * corresponding thread queue operations. - * - * @param[in] the_thread The thread. - * @param[in] operations The corresponding thread queue operations. - */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_claim_finalize( - Thread_Control *the_thread, - const Thread_queue_Operations *operations -) -{ - the_thread->Wait.operations = operations; -} - -/** - * @brief Removes a thread wait lock request. - * - * On SMP configurations, removes a thread wait lock request. - * - * On other configurations, this function does nothing. - * - * @param[in] the_thread The thread. - * @param[in] queue_lock_context The thread queue lock context used for - * corresponding _Thread_Wait_acquire(). - */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_remove_request( - Thread_Control *the_thread, - Thread_queue_Lock_context *queue_lock_context -) -{ -#if defined(RTEMS_SMP) - ISR_lock_Context lock_context; - - _Thread_Wait_acquire_default( the_thread, &lock_context ); - _Thread_Wait_remove_request_locked( the_thread, queue_lock_context ); - _Thread_Wait_release_default( the_thread, &lock_context ); -#else - (void) the_thread; - (void) queue_lock_context; -#endif -} - -/** - * @brief Restores the default thread wait queue and operations. - * - * The caller must be the owner of the current thread wait queue lock. - * - * On SMP configurations, the pending requests are updated to use the stale - * thread queue operations. - * - * @param[in] the_thread The thread. - * - * @see _Thread_Wait_claim(). - */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_restore_default( - Thread_Control *the_thread -) -{ -#if defined(RTEMS_SMP) - ISR_lock_Context lock_context; - Chain_Node *node; - const Chain_Node *tail; - - _Thread_Wait_acquire_default_critical( the_thread, &lock_context ); - - node = _Chain_First( &the_thread->Wait.Lock.Pending_requests ); - tail = _Chain_Immutable_tail( &the_thread->Wait.Lock.Pending_requests ); - - if ( node != tail ) { - do { - Thread_queue_Context *queue_context; - - queue_context = THREAD_QUEUE_CONTEXT_OF_REQUEST( node ); - queue_context->Lock_context.Wait.queue = NULL; - - node = _Chain_Next( node ); - } while ( node != tail ); - - _Thread_queue_Gate_add( - &the_thread->Wait.Lock.Pending_requests, - &the_thread->Wait.Lock.Tranquilizer - ); - } else { - _Thread_queue_Gate_open( &the_thread->Wait.Lock.Tranquilizer ); - } -#endif - - the_thread->Wait.queue = NULL; - the_thread->Wait.operations = &_Thread_queue_Operations_default; - -#if defined(RTEMS_SMP) - _Thread_Wait_release_default_critical( the_thread, &lock_context ); -#endif -} - -/** - * @brief Tranquilizes the thread after a wait on a thread queue. - * - * After the violent blocking procedure this function makes the thread calm and - * peaceful again so that it can carry out its normal work. - * - * On SMP configurations, ensures that all pending thread wait lock requests - * completed before the thread is able to begin a new thread wait procedure. - * - * On other configurations, this function does nothing. - * - * It must be called after a _Thread_Wait_claim() exactly once - * - after the corresponding thread queue lock was released, and - * - the default wait state is restored or some other processor is about to do - * this. - * - * @param[in] the_thread The thread. - */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_tranquilize( - Thread_Control *the_thread -) -{ -#if defined(RTEMS_SMP) - _Thread_queue_Gate_wait( &the_thread->Wait.Lock.Tranquilizer ); -#else - (void) the_thread; -#endif -} - -/** - * @brief Cancels a thread wait on a thread queue. - * - * @param[in] the_thread The thread. - * @param[in] queue_context The thread queue context used for corresponding - * _Thread_Wait_acquire(). - */ -RTEMS_INLINE_ROUTINE void _Thread_Wait_cancel( - Thread_Control *the_thread, - Thread_queue_Context *queue_context -) -{ - Thread_queue_Queue *queue; - - queue = the_thread->Wait.queue; - -#if defined(RTEMS_SMP) - if ( queue != NULL ) { - _Assert( queue_context->Lock_context.Wait.queue == queue ); -#endif - - ( *the_thread->Wait.operations->extract )( - queue, - the_thread, - queue_context - ); - _Thread_Wait_restore_default( the_thread ); - -#if defined(RTEMS_SMP) - _Assert( queue_context->Lock_context.Wait.queue == NULL ); - queue_context->Lock_context.Wait.queue = queue; - } -#endif -} - -/** - * @brief The initial thread wait flags value set by _Thread_Initialize(). - */ -#define THREAD_WAIT_FLAGS_INITIAL 0x0U - -/** - * @brief Mask to get the thread wait state flags. - */ -#define THREAD_WAIT_STATE_MASK 0xffU - -/** - * @brief Indicates that the thread begins with the blocking operation. - * - * A blocking operation consists of an optional watchdog initialization and the - * setting of the appropriate thread blocking state with the corresponding - * scheduler block operation. - */ -#define THREAD_WAIT_STATE_INTEND_TO_BLOCK 0x1U - -/** - * @brief Indicates that the thread completed the blocking operation. - */ -#define THREAD_WAIT_STATE_BLOCKED 0x2U - -/** - * @brief Indicates that a condition to end the thread wait occurred. - * - * This could be a timeout, a signal, an event or a resource availability. - */ -#define THREAD_WAIT_STATE_READY_AGAIN 0x4U - -/** - * @brief Mask to get the thread wait class flags. - */ -#define THREAD_WAIT_CLASS_MASK 0xff00U - -/** - * @brief Indicates that the thread waits for an event. - */ -#define THREAD_WAIT_CLASS_EVENT 0x100U - -/** - * @brief Indicates that the thread waits for a system event. - */ -#define THREAD_WAIT_CLASS_SYSTEM_EVENT 0x200U - -/** - * @brief Indicates that the thread waits for an object. - */ -#define THREAD_WAIT_CLASS_OBJECT 0x400U - -/** - * @brief Indicates that the thread waits for a period. - */ -#define THREAD_WAIT_CLASS_PERIOD 0x800U - -RTEMS_INLINE_ROUTINE void _Thread_Wait_flags_set( - Thread_Control *the_thread, - Thread_Wait_flags flags -) -{ -#if defined(RTEMS_SMP) - _Atomic_Store_uint( &the_thread->Wait.flags, flags, ATOMIC_ORDER_RELAXED ); -#else - the_thread->Wait.flags = flags; -#endif -} - -RTEMS_INLINE_ROUTINE Thread_Wait_flags _Thread_Wait_flags_get( - const Thread_Control *the_thread -) -{ -#if defined(RTEMS_SMP) - return _Atomic_Load_uint( &the_thread->Wait.flags, ATOMIC_ORDER_RELAXED ); -#else - return the_thread->Wait.flags; -#endif -} - -RTEMS_INLINE_ROUTINE Thread_Wait_flags _Thread_Wait_flags_get_acquire( - const Thread_Control *the_thread -) -{ -#if defined(RTEMS_SMP) - return _Atomic_Load_uint( &the_thread->Wait.flags, ATOMIC_ORDER_ACQUIRE ); -#else - return the_thread->Wait.flags; -#endif -} - -/** - * @brief Tries to change the thread wait flags with release semantics in case - * of success. - * - * Must be called inside a critical section (interrupts disabled). - * - * In case the wait flags are equal to the expected wait flags, then the wait - * flags are set to the desired wait flags. - * - * @param[in] the_thread The thread. - * @param[in] expected_flags The expected wait flags. - * @param[in] desired_flags The desired wait flags. - * - * @retval true The wait flags were equal to the expected wait flags. - * @retval false Otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Thread_Wait_flags_try_change_release( - Thread_Control *the_thread, - Thread_Wait_flags expected_flags, - Thread_Wait_flags desired_flags -) -{ - _Assert( _ISR_Get_level() != 0 ); - -#if defined(RTEMS_SMP) - return _Atomic_Compare_exchange_uint( - &the_thread->Wait.flags, - &expected_flags, - desired_flags, - ATOMIC_ORDER_RELEASE, - ATOMIC_ORDER_RELAXED - ); -#else - bool success = ( the_thread->Wait.flags == expected_flags ); - - if ( success ) { - the_thread->Wait.flags = desired_flags; - } - - return success; -#endif -} - -/** - * @brief Tries to change the thread wait flags with acquire semantics. - * - * In case the wait flags are equal to the expected wait flags, then the wait - * flags are set to the desired wait flags. - * - * @param[in] the_thread The thread. - * @param[in] expected_flags The expected wait flags. - * @param[in] desired_flags The desired wait flags. - * - * @retval true The wait flags were equal to the expected wait flags. - * @retval false Otherwise. - */ -RTEMS_INLINE_ROUTINE bool _Thread_Wait_flags_try_change_acquire( - Thread_Control *the_thread, - Thread_Wait_flags expected_flags, - Thread_Wait_flags desired_flags -) -{ - bool success; -#if defined(RTEMS_SMP) - return _Atomic_Compare_exchange_uint( - &the_thread->Wait.flags, - &expected_flags, - desired_flags, - ATOMIC_ORDER_ACQUIRE, - ATOMIC_ORDER_ACQUIRE - ); -#else - ISR_Level level; - - _ISR_Local_disable( level ); - - success = _Thread_Wait_flags_try_change_release( - the_thread, - expected_flags, - desired_flags - ); - - _ISR_Local_enable( level ); -#endif - - return success; -} - -/** - * @brief Returns the object identifier of the object containing the current - * thread wait queue. - * - * This function may be used for debug and system information purposes. The - * caller must be the owner of the thread lock. - * - * @retval 0 The thread waits on no thread queue currently, the thread wait - * queue is not contained in an object, or the current thread state provides - * insufficient information, e.g. the thread is in the middle of a blocking - * operation. - * @retval other The object identifier of the object containing the thread wait - * queue. - */ -Objects_Id _Thread_Wait_get_id( const Thread_Control *the_thread ); - -RTEMS_INLINE_ROUTINE Status_Control _Thread_Wait_get_status( - const Thread_Control *the_thread -) -{ - return (Status_Control) the_thread->Wait.return_code; -} - -/** - * @brief Cancels a blocking operation so that the thread can continue its - * execution. - * - * In case this function actually cancelled the blocking operation, then the - * thread wait return code is set to the specified status. - * - * A specialization of this function is _Thread_Timeout(). - * - * @param[in] the_thread The thread. - * @param[in] status The thread wait status. - */ -void _Thread_Continue( Thread_Control *the_thread, Status_Control status ); - -/** - * @brief General purpose thread wait timeout. - * - * @param[in] the_watchdog The thread timer watchdog. - */ -void _Thread_Timeout( Watchdog_Control *the_watchdog ); - -RTEMS_INLINE_ROUTINE void _Thread_Timer_initialize( - Thread_Timer_information *timer, - Per_CPU_Control *cpu -) -{ - _ISR_lock_Initialize( &timer->Lock, "Thread Timer" ); - timer->header = &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_MONOTONIC ]; - _Watchdog_Preinitialize( &timer->Watchdog, cpu ); -} - -RTEMS_INLINE_ROUTINE void _Thread_Add_timeout_ticks( - Thread_Control *the_thread, - Per_CPU_Control *cpu, - Watchdog_Interval ticks -) -{ - ISR_lock_Context lock_context; - - _ISR_lock_ISR_disable_and_acquire( &the_thread->Timer.Lock, &lock_context ); - - the_thread->Timer.header = - &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_MONOTONIC ]; - the_thread->Timer.Watchdog.routine = _Thread_Timeout; - _Watchdog_Per_CPU_insert_ticks( &the_thread->Timer.Watchdog, cpu, ticks ); - - _ISR_lock_Release_and_ISR_enable( &the_thread->Timer.Lock, &lock_context ); -} - -RTEMS_INLINE_ROUTINE void _Thread_Timer_insert_realtime( - Thread_Control *the_thread, - Per_CPU_Control *cpu, - Watchdog_Service_routine_entry routine, - uint64_t expire -) -{ - ISR_lock_Context lock_context; - - _ISR_lock_ISR_disable_and_acquire( &the_thread->Timer.Lock, &lock_context ); - - the_thread->Timer.header = - &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_REALTIME ]; - the_thread->Timer.Watchdog.routine = routine; - _Watchdog_Per_CPU_insert_realtime( &the_thread->Timer.Watchdog, cpu, expire ); - - _ISR_lock_Release_and_ISR_enable( &the_thread->Timer.Lock, &lock_context ); -} - -RTEMS_INLINE_ROUTINE void _Thread_Timer_remove( Thread_Control *the_thread ) -{ - ISR_lock_Context lock_context; - - _ISR_lock_ISR_disable_and_acquire( &the_thread->Timer.Lock, &lock_context ); - - _Watchdog_Per_CPU_remove( - &the_thread->Timer.Watchdog, -#if defined(RTEMS_SMP) - the_thread->Timer.Watchdog.cpu, -#else - _Per_CPU_Get(), -#endif - the_thread->Timer.header - ); - - _ISR_lock_Release_and_ISR_enable( &the_thread->Timer.Lock, &lock_context ); -} - -RTEMS_INLINE_ROUTINE void _Thread_Remove_timer_and_unblock( - Thread_Control *the_thread, - Thread_queue_Queue *queue -) -{ - _Thread_Wait_tranquilize( the_thread ); - _Thread_Timer_remove( the_thread ); - -#if defined(RTEMS_MULTIPROCESSING) - if ( _Objects_Is_local_id( the_thread->Object.id ) ) { - _Thread_Unblock( the_thread ); - } else { - _Thread_queue_Unblock_proxy( queue, the_thread ); - } -#else - (void) queue; - _Thread_Unblock( the_thread ); -#endif -} - -Status_Control _Thread_Set_name( - Thread_Control *the_thread, - const char *name -); - -size_t _Thread_Get_name( - const Thread_Control *the_thread, - char *buffer, - size_t buffer_size -); - -/** @}*/ - -#ifdef __cplusplus -} -#endif - -#if defined(RTEMS_MULTIPROCESSING) -#include -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/threadmp.h b/cpukit/score/include/rtems/score/threadmp.h deleted file mode 100644 index 9cde35b649..0000000000 --- a/cpukit/score/include/rtems/score/threadmp.h +++ /dev/null @@ -1,113 +0,0 @@ -/** - * @file rtems/score/threadmp.h - * - * @brief Multiprocessing Portion of the Thread Package - * - * This include file contains the specification for all routines - * and data specific to the multiprocessing portion of the thread package. - */ - -/* - * COPYRIGHT (c) 1989-2009. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_THREADMP_H -#define _RTEMS_SCORE_THREADMP_H - -#ifndef _RTEMS_SCORE_THREADIMPL_H -# error "Never use directly; include instead." -#endif - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ScoreThreadMP Thread Handler Multiprocessing Support - * - * @ingroup Score - * - * This handler encapsulates functionality which is related to managing - * threads in a multiprocessor system configuration. This handler must - * manage proxies which represent remote threads blocking on local - * operations. - */ -/**@{*/ - -/** - * @brief Initialize MP thread handler. - * - * This routine initializes the multiprocessing portion of the Thread Handler. - */ -void _Thread_MP_Handler_initialization ( - uint32_t maximum_proxies -); - -/** - * @brief Allocate a MP proxy control block from - * the inactive chain of free proxy control blocks. - * - * This allocates a proxy control block from - * the inactive chain of free proxy control blocks. - * - * @note This function returns a thread control pointer - * because proxies are substitutes for remote threads. - */ -Thread_Control *_Thread_MP_Allocate_proxy ( - States_Control the_state -); - -/** - * @brief Removes the MP proxy control block for the specified - * id from the active chain of proxy control blocks. - * - * This function removes the proxy control block for the specified - * id from the active red-black tree of proxy control blocks. - */ -Thread_Control *_Thread_MP_Find_proxy ( - Objects_Id the_id -); - -/** - * This function returns true if the thread in question is the - * multiprocessing receive thread. - * - * @note This is a macro to avoid needing a prototype for - * _MPCI_Receive_server_tcb until it is used. - */ -#define _Thread_MP_Is_receive(_the_thread) \ - ((_the_thread) == _MPCI_Receive_server_tcb) - -/** - * This routine frees a proxy control block to the - * inactive chain of free proxy control blocks. - */ -void _Thread_MP_Free_proxy( Thread_Control *the_thread ); - -RTEMS_INLINE_ROUTINE bool _Thread_MP_Is_remote( Objects_Id id ) -{ - Objects_Information *information; - - information = _Thread_Get_objects_information( id ); - if ( information == NULL ) { - return false; - } - - return _Objects_MP_Is_remote( id, information ); -} - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/threadq.h b/cpukit/score/include/rtems/score/threadq.h deleted file mode 100644 index 3e618bf5af..0000000000 --- a/cpukit/score/include/rtems/score/threadq.h +++ /dev/null @@ -1,595 +0,0 @@ -/** - * @file - * - * @brief Constants and Structures Needed to Declare a Thread Queue - * - * This include file contains all the constants and structures - * needed to declare a thread queue. - */ - -/* - * COPYRIGHT (c) 1989-2014. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_THREADQ_H -#define _RTEMS_SCORE_THREADQ_H - -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -struct Scheduler_Node; - -/** - * @defgroup ScoreThreadQueue Thread Queue Handler - * - * @ingroup Score - * - * This handler provides the capability to have threads block in - * ordered sets. The sets may be ordered using the FIFO or priority - * discipline. - */ -/**@{*/ - -typedef struct _Thread_Control Thread_Control; - -typedef struct Thread_queue_Context Thread_queue_Context; - -typedef struct Thread_queue_Queue Thread_queue_Queue; - -typedef struct Thread_queue_Operations Thread_queue_Operations; - -/** - * @brief Thread queue enqueue callout. - * - * @param[in] queue The actual thread queue. - * @param[in] the_thread The thread to enqueue. - * @param[in] cpu_self The current processor. - * @param[in] queue_context The thread queue context of the lock acquire. - * - * @see _Thread_queue_Context_set_enqueue_callout(). - */ -typedef void ( *Thread_queue_Enqueue_callout )( - Thread_queue_Queue *queue, - Thread_Control *the_thread, - struct Per_CPU_Control *cpu_self, - Thread_queue_Context *queue_context -); - -/** - * @brief Thread queue deadlock callout. - * - * @param the_thread The thread that detected the deadlock. - * - * @see _Thread_queue_Context_set_deadlock_callout(). - */ -typedef void ( *Thread_queue_Deadlock_callout )( - Thread_Control *the_thread -); - -#if defined(RTEMS_MULTIPROCESSING) -/** - * @brief Multiprocessing (MP) support callout for thread queue operations. - * - * @param the_proxy The thread proxy of the thread queue operation. A thread - * control is actually a thread proxy if and only if - * _Objects_Is_local_id( the_proxy->Object.id ) is false. - * @param mp_id Object identifier of the object containing the thread queue. - * - * @see _Thread_queue_Context_set_MP_callout(). - */ -typedef void ( *Thread_queue_MP_callout )( - Thread_Control *the_proxy, - Objects_Id mp_id -); -#endif - -#if defined(RTEMS_SMP) -/** - * @brief The thread queue gate is an SMP synchronization means. - * - * The gates are added to a list of requests. A busy wait is performed to make - * sure that preceding requests are carried out. Each predecessor notifies its - * successor about on request completion. - * - * @see _Thread_queue_Gate_add(), _Thread_queue_Gate_wait(), and - * _Thread_queue_Gate_open(). - */ -typedef struct { - Chain_Node Node; - - Atomic_Uint go_ahead; -} Thread_queue_Gate; -#endif - -typedef struct { - /** - * @brief The lock context for the thread queue acquire and release - * operations. - */ - ISR_lock_Context Lock_context; - -#if defined(RTEMS_SMP) - /** - * @brief Data to support thread queue enqueue operations. - */ - struct { - /** - * @brief Gate to synchronize thread wait lock requests. - * - * @see _Thread_Wait_acquire_critical() and _Thread_Wait_tranquilize(). - */ - Thread_queue_Gate Gate; - - /** - * @brief The thread queue in case the thread is blocked on a thread queue. - */ - Thread_queue_Queue *queue; - } Wait; -#endif -} Thread_queue_Lock_context; - -#if defined(RTEMS_SMP) -/** - * @brief A thread queue link from one thread to another specified by the - * thread queue owner and thread wait queue relationships. - */ -typedef struct { - /** - * @brief Node to register this link in the global thread queue links lookup - * tree. - */ - RBTree_Node Registry_node; - - /** - * @brief The source thread queue determined by the thread queue owner. - */ - Thread_queue_Queue *source; - - /** - * @brief The target thread queue determined by the thread wait queue of the - * source owner. - */ - Thread_queue_Queue *target; - - /** - * @brief Node to add this link to a thread queue path. - */ - Chain_Node Path_node; - - /** - * @brief The owner of this thread queue link. - */ - Thread_Control *owner; - - /** - * @brief The queue lock context used to acquire the thread wait lock of the - * owner. - */ - Thread_queue_Lock_context Lock_context; -} Thread_queue_Link; -#endif - -/** - * @brief Thread queue context for the thread queue methods. - * - * @see _Thread_queue_Context_initialize(). - */ -struct Thread_queue_Context { - /** - * @brief The lock context for the thread queue acquire and release - * operations. - */ - Thread_queue_Lock_context Lock_context; - - /** - * @brief The thread state for _Thread_queue_Enqueue(). - */ - States_Control thread_state; - - /** - * @brief The enqueue callout for _Thread_queue_Enqueue(). - * - * The callout is invoked after the release of the thread queue lock with - * thread dispatching disabled. Afterwards the thread is blocked. This - * callout must be used to install the thread watchdog for timeout handling. - * - * @see _Thread_queue_Enqueue_do_nothing_extra(). - * _Thread_queue_Add_timeout_ticks(), and - * _Thread_queue_Add_timeout_realtime_timespec(). - */ - Thread_queue_Enqueue_callout enqueue_callout; - - /** - * @brief Interval to wait. - * - * May be used by the enqueue callout to register a timeout handler. - */ - union { - /** - * @brief The timeout in ticks. - */ - Watchdog_Interval ticks; - - /** - * @brief The timeout argument, e.g. pointer to struct timespec. - */ - const void *arg; - } Timeout; - -#if defined(RTEMS_SMP) - /** - * @brief Representation of a thread queue path from a start thread queue to - * the terminal thread queue. - * - * The start thread queue is determined by the object on which a thread intends - * to block. The terminal thread queue is the thread queue reachable via - * thread queue links whose owner is not blocked on a thread queue. The thread - * queue links are determined by the thread queue owner and thread wait queue - * relationships. - */ - struct { - /** - * @brief The chain of thread queue links defining the thread queue path. - */ - Chain_Control Links; - - /** - * @brief The start of a thread queue path. - */ - Thread_queue_Link Start; - - /** - * @brief In case of a deadlock, a link for the first thread on the path - * that tries to enqueue on a thread queue. - */ - Thread_queue_Link Deadlock; - } Path; -#endif - - /** - * @brief Block to manage thread priority changes due to a thread queue - * operation. - */ - struct { - /** - * @brief A priority action list. - */ - Priority_Actions Actions; - - /** - * @brief Count of threads to update the priority via - * _Thread_Priority_update(). - */ - size_t update_count; - - /** - * @brief Threads to update the priority via _Thread_Priority_update(). - * - * Currently, a maximum of two threads need an update in one rush, for - * example the thread of the thread queue operation and the owner of the - * thread queue. - */ - Thread_Control *update[ 2 ]; - } Priority; - - /** - * @brief Invoked in case of a detected deadlock. - * - * Must be initialized for _Thread_queue_Enqueue() in case the - * thread queue may have an owner, e.g. for mutex objects. - * - * @see _Thread_queue_Context_set_deadlock_callout(). - */ - Thread_queue_Deadlock_callout deadlock_callout; - -#if defined(RTEMS_MULTIPROCESSING) - /** - * @brief Callout to unblock the thread in case it is actually a thread - * proxy. - * - * This field is only used on multiprocessing configurations. Used by - * thread queue extract and unblock methods for objects with multiprocessing - * (MP) support. - * - * @see _Thread_queue_Context_set_MP_callout(). - */ - Thread_queue_MP_callout mp_callout; -#endif -}; - -/** - * @brief Thread priority queue. - */ -typedef struct { -#if defined(RTEMS_SMP) - /** - * @brief Node to enqueue this queue in the FIFO chain of the corresponding - * heads structure. - * - * @see Thread_queue_Heads::Heads::Fifo. - */ - Chain_Node Node; -#endif - - /** - * @brief The actual thread priority queue. - */ - Priority_Aggregation Queue; - - /** - * @brief This priority queue is added to a scheduler node of the owner in - * case of priority inheritance. - */ - struct Scheduler_Node *scheduler_node; -} Thread_queue_Priority_queue; - -/** - * @brief Thread queue heads. - * - * Each thread is equipped with spare thread queue heads in case it is not - * enqueued on a thread queue. The first thread enqueued on a thread queue - * will give its spare thread queue heads to that thread queue. The threads - * arriving at the queue will add their thread queue heads to the free chain of - * the queue heads provided by the first thread enqueued. Once a thread is - * dequeued it use the free chain to get new spare thread queue heads. - * - * Uses a leading underscore in the structure name to allow forward - * declarations in standard header files provided by Newlib and GCC. - */ -typedef struct _Thread_queue_Heads { - /** This union contains the data structures used to manage the blocked - * set of tasks which varies based upon the discipline. - */ - union { - /** - * @brief This is the FIFO discipline list. - * - * On SMP configurations this FIFO is used to enqueue the per scheduler - * instance priority queues of this structure. This ensures FIFO fairness - * among the highest priority thread of each scheduler instance. - */ - Chain_Control Fifo; - -#if !defined(RTEMS_SMP) - /** - * @brief This is the set of threads for priority discipline waiting. - */ - Thread_queue_Priority_queue Priority; -#endif - } Heads; - - /** - * @brief A chain with free thread queue heads providing the spare thread - * queue heads for a thread once it is dequeued. - */ - Chain_Control Free_chain; - - /** - * @brief A chain node to add these thread queue heads to the free chain of - * the thread queue heads dedicated to the thread queue of an object. - */ - Chain_Node Free_node; - -#if defined(RTEMS_SMP) - /** - * @brief One priority queue per scheduler instance. - */ - Thread_queue_Priority_queue Priority[ RTEMS_ZERO_LENGTH_ARRAY ]; -#endif -} Thread_queue_Heads; - -#if defined(RTEMS_SMP) - #define THREAD_QUEUE_HEADS_SIZE( scheduler_count ) \ - ( sizeof( Thread_queue_Heads ) \ - + ( scheduler_count ) * sizeof( Thread_queue_Priority_queue ) ) -#else - #define THREAD_QUEUE_HEADS_SIZE( scheduler_count ) \ - sizeof( Thread_queue_Heads ) -#endif - -struct Thread_queue_Queue { - /** - * @brief Lock to protect this thread queue. - * - * It may be used to protect additional state of the object embedding this - * thread queue. - * - * Must be the first component of this structure to be able to re-use - * implementation parts for structures defined by Newlib . - * - * @see _Thread_queue_Acquire(), _Thread_queue_Acquire_critical() and - * _Thread_queue_Release(). - */ -#if defined(RTEMS_SMP) - SMP_ticket_lock_Control Lock; -#endif - - /** - * @brief The thread queue heads. - * - * This pointer is NULL, if and only if no threads are enqueued. The first - * thread to enqueue will give its spare thread queue heads to this thread - * queue. - */ - Thread_queue_Heads *heads; - - /** - * @brief The thread queue owner. - */ - Thread_Control *owner; - - /** - * @brief The thread queue name. - */ - const char *name; -}; - -/** - * @brief Thread queue action operation. - * - * @param[in] queue The actual thread queue. - * @param[in] the_thread The thread. - * @param[in] queue_context The thread queue context providing the thread queue - * action set to perform. Returns the thread queue action set to perform on - * the thread queue owner or the empty set in case there is nothing to do. - */ -typedef void ( *Thread_queue_Priority_actions_operation )( - Thread_queue_Queue *queue, - Priority_Actions *priority_actions -); - -/** - * @brief Thread queue enqueue operation. - * - * A potential thread to update the priority due to priority inheritance is - * returned via the thread queue context. This thread is handed over to - * _Thread_Priority_update(). - * - * @param[in] queue The actual thread queue. - * @param[in] the_thread The thread to enqueue on the queue. - */ -typedef void ( *Thread_queue_Enqueue_operation )( - Thread_queue_Queue *queue, - Thread_Control *the_thread, - Thread_queue_Context *queue_context -); - -/** - * @brief Thread queue extract operation. - * - * @param[in] queue The actual thread queue. - * @param[in] the_thread The thread to extract from the thread queue. - */ -typedef void ( *Thread_queue_Extract_operation )( - Thread_queue_Queue *queue, - Thread_Control *the_thread, - Thread_queue_Context *queue_context -); - -/** - * @brief Thread queue surrender operation. - * - * This operation must dequeue and return the first thread on the queue. - * - * @param[in] queue The actual thread queue. - * @param[in] heads The thread queue heads. It must not be NULL. - * @param[in] previous_owner The previous owner of the thread queue. - * - * @return The previous first thread on the queue. - */ -typedef Thread_Control *( *Thread_queue_Surrender_operation )( - Thread_queue_Queue *queue, - Thread_queue_Heads *heads, - Thread_Control *previous_owner, - Thread_queue_Context *queue_context -); - -/** - * @brief Thread queue first operation. - * - * @param[in] heads The thread queue heads. - * - * @retval NULL No thread is present on the thread queue. - * @retval first The first thread of the thread queue according to the insert - * order. This thread remains on the thread queue. - */ -typedef Thread_Control *( *Thread_queue_First_operation )( - Thread_queue_Heads *heads -); - -/** - * @brief Thread queue operations. - * - * @see _Thread_wait_Set_operations(). - */ -struct Thread_queue_Operations { - /** - * @brief Thread queue priority actions operation. - */ - Thread_queue_Priority_actions_operation priority_actions; - - /** - * @brief Thread queue enqueue operation. - * - * Called by object routines to enqueue the thread. - */ - Thread_queue_Enqueue_operation enqueue; - - /** - * @brief Thread queue extract operation. - * - * Called by object routines to extract a thread from a thread queue. - */ - Thread_queue_Extract_operation extract; - - /** - * @brief Thread queue surrender operation. - */ - Thread_queue_Surrender_operation surrender; - - /** - * @brief Thread queue first operation. - */ - Thread_queue_First_operation first; -}; - -/** - * This is the structure used to manage sets of tasks which are blocked - * waiting to acquire a resource. - */ -typedef struct { -#if defined(RTEMS_SMP) -#if defined(RTEMS_DEBUG) - /** - * @brief The index of the owning processor of the thread queue lock. - * - * The thread queue lock may be acquired via the thread lock also. This path - * is not covered by this field. In case the lock is not owned directly via - * _Thread_queue_Acquire(), then the value of this field is - * SMP_LOCK_NO_OWNER. - * - * Must be before the queue component of this structure to be able to re-use - * implementation parts for structures defined by Newlib . - */ - uint32_t owner; -#endif - -#if defined(RTEMS_PROFILING) - /** - * @brief SMP lock statistics in case SMP and profiling are enabled. - * - * Must be before the queue component of this structure to be able to re-use - * implementation parts for structures defined by Newlib . - */ - SMP_lock_Stats Lock_stats; -#endif -#endif - - /** - * @brief The actual thread queue. - */ - Thread_queue_Queue Queue; -} Thread_queue_Control; - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/threadqimpl.h b/cpukit/score/include/rtems/score/threadqimpl.h deleted file mode 100644 index ecbd8fd42f..0000000000 --- a/cpukit/score/include/rtems/score/threadqimpl.h +++ /dev/null @@ -1,1265 +0,0 @@ -/** - * @file rtems/score/threadq.h - * - * Constants and Structures Associated with the Manipulation of Objects - * - * This include file contains all the constants and structures associated - * with the manipulation of objects. - */ - -/* - * COPYRIGHT (c) 1989-2014. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_THREADQIMPL_H -#define _RTEMS_SCORE_THREADQIMPL_H - -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(RTEMS_DEBUG) -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ScoreThreadQueue - */ -/**@{*/ - -#define THREAD_QUEUE_LINK_OF_PATH_NODE( node ) \ - RTEMS_CONTAINER_OF( node, Thread_queue_Link, Path_node ); - -/** - * @brief Thread queue with a layout compatible to struct _Thread_queue_Queue - * defined in Newlib . - */ -typedef struct { -#if !defined(RTEMS_SMP) - /* - * The struct _Thread_queue_Queue definition is independent of the RTEMS - * build configuration. Thus, the storage space for the SMP lock is always - * present. In SMP configurations, the SMP lock is contained in the - * Thread_queue_Queue. - */ - unsigned int reserved[2]; -#endif - - Thread_queue_Queue Queue; -} Thread_queue_Syslock_queue; - -void _Thread_queue_Enqueue_do_nothing_extra( - Thread_queue_Queue *queue, - Thread_Control *the_thread, - Per_CPU_Control *cpu_self, - Thread_queue_Context *queue_context -); - -void _Thread_queue_Add_timeout_ticks( - Thread_queue_Queue *queue, - Thread_Control *the_thread, - Per_CPU_Control *cpu_self, - Thread_queue_Context *queue_context -); - -void _Thread_queue_Add_timeout_monotonic_timespec( - Thread_queue_Queue *queue, - Thread_Control *the_thread, - Per_CPU_Control *cpu_self, - Thread_queue_Context *queue_context -); - -void _Thread_queue_Add_timeout_realtime_timespec( - Thread_queue_Queue *queue, - Thread_Control *the_thread, - Per_CPU_Control *cpu_self, - Thread_queue_Context *queue_context -); - -/** - * @brief Sets the thread wait return code to STATUS_DEADLOCK. - */ -void _Thread_queue_Deadlock_status( Thread_Control *the_thread ); - -/** - * @brief Results in an INTERNAL_ERROR_THREAD_QUEUE_DEADLOCK fatal error. - */ -void _Thread_queue_Deadlock_fatal( Thread_Control *the_thread ); - -/** - * @brief Initializes a thread queue context. - * - * @param queue_context The thread queue context to initialize. - */ -RTEMS_INLINE_ROUTINE void _Thread_queue_Context_initialize( - Thread_queue_Context *queue_context -) -{ -#if defined(RTEMS_DEBUG) - memset( queue_context, 0x7f, sizeof( *queue_context ) ); -#if defined(RTEMS_SMP) - _Chain_Initialize_node( &queue_context->Lock_context.Wait.Gate.Node ); -#endif - queue_context->enqueue_callout = NULL; - queue_context->deadlock_callout = NULL; -#else - (void) queue_context; -#endif -} - -/** - * @brief Sets the thread state for the thread to enqueue in the thread queue - * context. - * - * @param queue_context The thread queue context. - * @param state The thread state. - * - * @see _Thread_queue_Enqueue(). - */ -RTEMS_INLINE_ROUTINE void -_Thread_queue_Context_set_thread_state( - Thread_queue_Context *queue_context, - States_Control thread_state -) -{ - queue_context->thread_state = thread_state; -} - -/** - * @brief Sets the timeout ticks in the thread queue context. - * - * @param queue_context The thread queue context. - * @param ticks The timeout in ticks. - * - * @see _Thread_queue_Enqueue(). - */ -RTEMS_INLINE_ROUTINE void -_Thread_queue_Context_set_timeout_ticks( - Thread_queue_Context *queue_context, - Watchdog_Interval ticks -) -{ - queue_context->Timeout.ticks = ticks; -} - -/** - * @brief Sets the timeout argument in the thread queue context. - * - * @param queue_context The thread queue context. - * @param arg The timeout argument. - * - * @see _Thread_queue_Enqueue(). - */ -RTEMS_INLINE_ROUTINE void -_Thread_queue_Context_set_timeout_argument( - Thread_queue_Context *queue_context, - const void *arg -) -{ - queue_context->Timeout.arg = arg; -} - -/** - * @brief Sets the enqueue callout in the thread queue context. - * - * @param queue_context The thread queue context. - * @param enqueue_callout The enqueue callout. - * - * @see _Thread_queue_Enqueue(). - */ -RTEMS_INLINE_ROUTINE void -_Thread_queue_Context_set_enqueue_callout( - Thread_queue_Context *queue_context, - Thread_queue_Enqueue_callout enqueue_callout -) -{ - queue_context->enqueue_callout = enqueue_callout; -} - -/** - * @brief Sets the do nothing enqueue callout in the thread queue context. - * - * @param queue_context The thread queue context. - * - * @see _Thread_queue_Enqueue(). - */ -RTEMS_INLINE_ROUTINE void -_Thread_queue_Context_set_enqueue_do_nothing_extra( - Thread_queue_Context *queue_context -) -{ - queue_context->enqueue_callout = _Thread_queue_Enqueue_do_nothing_extra; -} - -/** - * @brief Sets the enqueue callout to add a relative monotonic timeout in - * ticks. - * - * @param queue_context The thread queue context. - * @param ticks The timeout in ticks. - * - * @see _Thread_queue_Enqueue(). - */ -RTEMS_INLINE_ROUTINE void -_Thread_queue_Context_set_enqueue_timeout_ticks( - Thread_queue_Context *queue_context, - Watchdog_Interval ticks -) -{ - queue_context->Timeout.ticks = ticks; - queue_context->enqueue_callout = _Thread_queue_Add_timeout_ticks; -} - -/** - * @brief Sets the enqueue callout to add an absolute monotonic timeout in - * timespec format. - * - * @param queue_context The thread queue context. - * @param abstime The absolute monotonic timeout. - * - * @see _Thread_queue_Enqueue(). - */ -RTEMS_INLINE_ROUTINE void -_Thread_queue_Context_set_enqueue_timeout_monotonic_timespec( - Thread_queue_Context *queue_context, - const struct timespec *abstime -) -{ - queue_context->Timeout.arg = abstime; - queue_context->enqueue_callout = - _Thread_queue_Add_timeout_monotonic_timespec; -} - -/** - * @brief Sets the enqueue callout to add an absolute realtime timeout in - * timespec format. - * - * @param queue_context The thread queue context. - * @param abstime The absolute realtime timeout. - * - * @see _Thread_queue_Enqueue(). - */ -RTEMS_INLINE_ROUTINE void -_Thread_queue_Context_set_enqueue_timeout_realtime_timespec( - Thread_queue_Context *queue_context, - const struct timespec *abstime -) -{ - queue_context->Timeout.arg = abstime; - queue_context->enqueue_callout = _Thread_queue_Add_timeout_realtime_timespec; -} - -/** - * @brief Sets the deadlock callout in the thread queue - * context. - * - * A deadlock callout must be provided for _Thread_queue_Enqueue() - * operations that operate on thread queues which may have an owner, e.g. mutex - * objects. Available deadlock callouts are _Thread_queue_Deadlock_status() - * and _Thread_queue_Deadlock_fatal(). - * - * @param queue_context The thread queue context. - * @param deadlock_callout The deadlock callout. - * - * @see _Thread_queue_Enqueue(). - */ -RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_deadlock_callout( - Thread_queue_Context *queue_context, - Thread_queue_Deadlock_callout deadlock_callout -) -{ - queue_context->deadlock_callout = deadlock_callout; -} - -RTEMS_INLINE_ROUTINE void _Thread_queue_Context_clear_priority_updates( - Thread_queue_Context *queue_context -) -{ - queue_context->Priority.update_count = 0; -} - -RTEMS_INLINE_ROUTINE size_t _Thread_queue_Context_save_priority_updates( - Thread_queue_Context *queue_context -) -{ - return queue_context->Priority.update_count; -} - -RTEMS_INLINE_ROUTINE void _Thread_queue_Context_restore_priority_updates( - Thread_queue_Context *queue_context, - size_t update_count -) -{ - queue_context->Priority.update_count = update_count; -} - -RTEMS_INLINE_ROUTINE void _Thread_queue_Context_add_priority_update( - Thread_queue_Context *queue_context, - Thread_Control *the_thread -) -{ - size_t n; - - n = queue_context->Priority.update_count; - _Assert( n < RTEMS_ARRAY_SIZE( queue_context->Priority.update ) ); - - queue_context->Priority.update_count = n + 1; - queue_context->Priority.update[ n ] = the_thread; -} - -#define _Thread_queue_Context_ISR_disable( queue_context, level ) \ - do { \ - _ISR_Local_disable( level ); \ - _ISR_lock_ISR_disable_profile( \ - &( queue_context )->Lock_context.Lock_context \ - ) \ - } while ( 0 ) - -RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_ISR_level( - Thread_queue_Context *queue_context, - ISR_Level level -) -{ - _ISR_lock_Context_set_level( - &queue_context->Lock_context.Lock_context, - level - ); -} - -RTEMS_INLINE_ROUTINE Per_CPU_Control *_Thread_queue_Dispatch_disable( - Thread_queue_Context *queue_context -) -{ - return _Thread_Dispatch_disable_critical( - &queue_context->Lock_context.Lock_context - ); -} - -/** - * @brief Sets the MP callout in the thread queue context. - * - * @param queue_context The thread queue context. - * @param mp_callout Callout to unblock the thread in case it is actually a - * thread proxy. This parameter is only used on multiprocessing - * configurations. Used by thread queue extract and unblock methods for - * objects with multiprocessing (MP) support. - */ -#if defined(RTEMS_MULTIPROCESSING) -RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_MP_callout( - Thread_queue_Context *queue_context, - Thread_queue_MP_callout mp_callout -) -{ - queue_context->mp_callout = mp_callout; -} -#else -#define _Thread_queue_Context_set_MP_callout( queue_context, mp_callout ) \ - do { \ - (void) queue_context; \ - } while ( 0 ) -#endif - -#if defined(RTEMS_SMP) -RTEMS_INLINE_ROUTINE void _Thread_queue_Gate_close( - Thread_queue_Gate *gate -) -{ - _Atomic_Store_uint( &gate->go_ahead, 0, ATOMIC_ORDER_RELAXED ); -} - -RTEMS_INLINE_ROUTINE void _Thread_queue_Gate_add( - Chain_Control *chain, - Thread_queue_Gate *gate -) -{ - _Chain_Append_unprotected( chain, &gate->Node ); -} - -RTEMS_INLINE_ROUTINE void _Thread_queue_Gate_open( - Thread_queue_Gate *gate -) -{ - _Atomic_Store_uint( &gate->go_ahead, 1, ATOMIC_ORDER_RELAXED ); -} - -RTEMS_INLINE_ROUTINE void _Thread_queue_Gate_wait( - Thread_queue_Gate *gate -) -{ - while ( _Atomic_Load_uint( &gate->go_ahead, ATOMIC_ORDER_RELAXED ) == 0 ) { - /* Wait */ - } -} -#endif - -RTEMS_INLINE_ROUTINE void _Thread_queue_Heads_initialize( - Thread_queue_Heads *heads -) -{ -#if defined(RTEMS_SMP) - size_t i; - - for ( i = 0; i < _Scheduler_Count; ++i ) { - _Chain_Initialize_node( &heads->Priority[ i ].Node ); - _Priority_Initialize_empty( &heads->Priority[ i ].Queue ); - heads->Priority[ i ].Queue.scheduler = &_Scheduler_Table[ i ]; - } -#endif - - _Chain_Initialize_empty( &heads->Free_chain ); - _Chain_Initialize_node( &heads->Free_node ); -} - -RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_initialize( - Thread_queue_Queue *queue, - const char *name -) -{ -#if defined(RTEMS_SMP) - _SMP_ticket_lock_Initialize( &queue->Lock ); -#endif - queue->heads = NULL; - queue->owner = NULL; - queue->name = name; -} - -RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_do_acquire_critical( - Thread_queue_Queue *queue, -#if defined(RTEMS_SMP) && defined(RTEMS_PROFILING) - SMP_lock_Stats *lock_stats, -#endif - ISR_lock_Context *lock_context -) -{ -#if defined(RTEMS_SMP) - _SMP_ticket_lock_Acquire( - &queue->Lock, - lock_stats, - &lock_context->Lock_context.Stats_context - ); -#else - (void) queue; - (void) lock_context; -#endif -} - -#if defined(RTEMS_SMP) && defined( RTEMS_PROFILING ) - #define \ - _Thread_queue_Queue_acquire_critical( queue, lock_stats, lock_context ) \ - _Thread_queue_Queue_do_acquire_critical( queue, lock_stats, lock_context ) -#else - #define \ - _Thread_queue_Queue_acquire_critical( queue, lock_stats, lock_context ) \ - _Thread_queue_Queue_do_acquire_critical( queue, lock_context ) -#endif - -RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_release_critical( - Thread_queue_Queue *queue, - ISR_lock_Context *lock_context -) -{ -#if defined(RTEMS_SMP) - _SMP_ticket_lock_Release( - &queue->Lock, - &lock_context->Lock_context.Stats_context - ); -#else - (void) queue; - (void) lock_context; -#endif -} - -RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_release( - Thread_queue_Queue *queue, - ISR_lock_Context *lock_context -) -{ - _Thread_queue_Queue_release_critical( queue, lock_context ); - _ISR_lock_ISR_enable( lock_context ); -} - -/** - * @brief Copies the thread queue name to the specified buffer. - * - * @param[in] queue The actual thread queue. - * @param[in] buffer The buffer for the thread queue name copy. - * @param[in] buffer_size The buffer size in characters. - * @param[in] id The object identifier in case the thread queue is embedded in - * an object with identifier, otherwise it is set to 0. - * - * @retval The length of the thread queue name. May be greater than or equal - * to the buffer size if truncation occurred. - */ -size_t _Thread_queue_Queue_get_name_and_id( - const Thread_queue_Queue *queue, - char *buffer, - size_t buffer_size, - Objects_Id *id -); - -#if defined(RTEMS_SMP) -void _Thread_queue_Do_acquire_critical( - Thread_queue_Control *the_thread_queue, - ISR_lock_Context *lock_context -); -#else -RTEMS_INLINE_ROUTINE void _Thread_queue_Do_acquire_critical( - Thread_queue_Control *the_thread_queue, - ISR_lock_Context *lock_context -) -{ - (void) the_thread_queue; - (void) lock_context; -} -#endif - -RTEMS_INLINE_ROUTINE void _Thread_queue_Acquire_critical( - Thread_queue_Control *the_thread_queue, - Thread_queue_Context *queue_context -) -{ - _Thread_queue_Do_acquire_critical( - the_thread_queue, - &queue_context->Lock_context.Lock_context - ); -} - -#if defined(RTEMS_SMP) -void _Thread_queue_Acquire( - Thread_queue_Control *the_thread_queue, - Thread_queue_Context *queue_context -); -#else -RTEMS_INLINE_ROUTINE void _Thread_queue_Acquire( - Thread_queue_Control *the_thread_queue, - Thread_queue_Context *queue_context -) -{ - (void) the_thread_queue; - _ISR_lock_ISR_disable( &queue_context->Lock_context.Lock_context ); -} -#endif - -#if defined(RTEMS_DEBUG) -RTEMS_INLINE_ROUTINE bool _Thread_queue_Is_lock_owner( - const Thread_queue_Control *the_thread_queue -) -{ -#if defined(RTEMS_SMP) - return the_thread_queue->owner == _SMP_lock_Who_am_I(); -#else - return _ISR_Get_level() != 0; -#endif -} -#endif - -#if defined(RTEMS_SMP) -void _Thread_queue_Do_release_critical( - Thread_queue_Control *the_thread_queue, - ISR_lock_Context *lock_context -); -#else -RTEMS_INLINE_ROUTINE void _Thread_queue_Do_release_critical( - Thread_queue_Control *the_thread_queue, - ISR_lock_Context *lock_context -) -{ - (void) the_thread_queue; - (void) lock_context; - _Assert( _Thread_queue_Is_lock_owner( the_thread_queue ) ); -} -#endif - -RTEMS_INLINE_ROUTINE void _Thread_queue_Release_critical( - Thread_queue_Control *the_thread_queue, - Thread_queue_Context *queue_context -) -{ - _Thread_queue_Do_release_critical( - the_thread_queue, - &queue_context->Lock_context.Lock_context - ); -} - -#if defined(RTEMS_SMP) -void _Thread_queue_Release( - Thread_queue_Control *the_thread_queue, - Thread_queue_Context *queue_context -); -#else -RTEMS_INLINE_ROUTINE void _Thread_queue_Release( - Thread_queue_Control *the_thread_queue, - Thread_queue_Context *queue_context -) -{ - (void) the_thread_queue; - _Assert( _Thread_queue_Is_lock_owner( the_thread_queue ) ); - _ISR_lock_ISR_enable( &queue_context->Lock_context.Lock_context ); -} -#endif - -Thread_Control *_Thread_queue_Do_dequeue( - Thread_queue_Control *the_thread_queue, - const Thread_queue_Operations *operations -#if defined(RTEMS_MULTIPROCESSING) - , - Thread_queue_MP_callout mp_callout -#endif -); - -/** - * @brief Gets a pointer to a thread waiting on the_thread_queue. - * - * This function returns a pointer to a thread waiting on - * the_thread_queue. The selection of this thread is based on - * the discipline of the_thread_queue. If no threads are waiting - * on the_thread_queue, then NULL is returned. - * - * - INTERRUPT LATENCY: - * + single case - */ -#if defined(RTEMS_MULTIPROCESSING) - #define _Thread_queue_Dequeue( \ - the_thread_queue, \ - operations, \ - mp_callout \ - ) \ - _Thread_queue_Do_dequeue( \ - the_thread_queue, \ - operations, \ - mp_callout \ - ) -#else - #define _Thread_queue_Dequeue( \ - the_thread_queue, \ - operations, \ - mp_callout \ - ) \ - _Thread_queue_Do_dequeue( \ - the_thread_queue, \ - operations \ - ) -#endif - -/** - * @brief Blocks the thread and places it on the thread queue. - * - * This enqueues the thread on the thread queue, blocks the thread, and - * optionally starts the thread timer in case the timeout discipline is not - * WATCHDOG_NO_TIMEOUT. Timeout discipline and value are in the queue_context. - * - * The caller must be the owner of the thread queue lock. This function will - * release the thread queue lock and register it as the new thread lock. - * Thread dispatching is disabled before the thread queue lock is released. - * Thread dispatching is enabled once the sequence to block the thread is - * complete. The operation to enqueue the thread on the queue is protected by - * the thread queue lock. This makes it possible to use the thread queue lock - * to protect the state of objects embedding the thread queue and directly - * enter _Thread_queue_Enqueue() in case the thread must block. - * - * The thread queue context must be set up with the following functions, - * otherwise the behaviour is unpredictable - * - * - _Thread_queue_Context_set_thread_state(), - * - * - _Thread_queue_Context_set_enqueue_callout() or - * _Thread_queue_Context_set_enqueue_do_nothing_extra() or - * _Thread_queue_Context_set_enqueue_timeout_ticks() or - * _Thread_queue_Context_set_enqueue_timeout_monotonic_timespec() or - * _Thread_queue_Context_set_enqueue_timeout_realtime_timespec(), - * - * - _Thread_queue_Context_set_deadlock_callout(). - * - * @code - * #include - * #include - * - * #define MUTEX_TQ_OPERATIONS &_Thread_queue_Operations_priority - * - * typedef struct { - * Thread_queue_Control Queue; - * } Mutex; - * - * void _Mutex_Obtain( Mutex *mutex ) - * { - * Thread_queue_Context queue_context; - * Thread_Control *executing; - * - * _Thread_queue_Context_initialize( &queue_context ); - * _Thread_queue_Acquire( &mutex->Queue, queue_context ); - * - * executing = _Thread_Executing; - * - * if ( mutex->Queue.owner == NULL ) { - * mutex->Queue.owner = executing; - * _Thread_queue_Release( &mutex->Queue, queue_context ); - * } else { - * _Thread_queue_Context_set_thread_state( - * &queue_context, - * STATES_WAITING_FOR_MUTEX - * ); - * _Thread_queue_Context_set_enqueue_do_nothing_extra( &queue_context ); - * _Thread_queue_Context_set_deadlock_callout( - * queue_context, - * _Thread_queue_Deadlock_fatal - * ); - * _Thread_queue_Enqueue( - * &mutex->Queue.Queue, - * MUTEX_TQ_OPERATIONS, - * executing, - * &queue_context - * ); - * } - * } - * @endcode - * - * @param[in] queue The actual thread queue. - * @param[in] operations The thread queue operations. - * @param[in] the_thread The thread to enqueue. - * @param[in] queue_context The thread queue context of the lock acquire. - */ -void _Thread_queue_Enqueue( - Thread_queue_Queue *queue, - const Thread_queue_Operations *operations, - Thread_Control *the_thread, - Thread_queue_Context *queue_context -); - -#if defined(RTEMS_SMP) -/** - * @brief Enqueues the thread on the thread queue and busy waits for dequeue. - * - * Optionally starts the thread timer in case the timeout discipline is not - * WATCHDOG_NO_TIMEOUT. Timeout discipline and value are in the queue_context. - * - * The caller must be the owner of the thread queue lock. This function will - * release the thread queue lock and register it as the new thread lock. - * - * The thread priorities of the owner and the are updated with respect to the - * scheduler. The sticky level of the thread is incremented. A thread - * dispatch is performed if necessary. - * - * Afterwards, the thread busy waits on the thread wait flags until a timeout - * occurs or the thread queue is surrendered to this thread. So, it sticks to - * the processor instead of blocking with respect to the scheduler. - * - * @param[in] queue The actual thread queue. - * @param[in] operations The thread queue operations. - * @param[in] the_thread The thread to enqueue. - * @param[in] queue_context The thread queue context of the lock acquire. - */ -Status_Control _Thread_queue_Enqueue_sticky( - Thread_queue_Queue *queue, - const Thread_queue_Operations *operations, - Thread_Control *the_thread, - Thread_queue_Context *queue_context -); -#endif - -/** - * @brief Extracts the thread from the thread queue, restores the default wait - * operations and restores the default thread lock. - * - * The caller must be the owner of the thread queue lock. The thread queue - * lock is not released. - * - * @param[in] queue The actual thread queue. - * @param[in] operations The thread queue operations. - * @param[in] the_thread The thread to extract. - * @param[in] queue_context The thread queue context. - * - * @return Returns the unblock indicator for _Thread_queue_Unblock_critical(). - * True indicates, that this thread must be unblocked by the scheduler later in - * _Thread_queue_Unblock_critical(), and false otherwise. In case false is - * returned, then the thread queue enqueue procedure was interrupted. Thus it - * will unblock itself and the thread wait information is no longer accessible, - * since this thread may already block on another resource in an SMP - * configuration. - */ -bool _Thread_queue_Extract_locked( - Thread_queue_Queue *queue, - const Thread_queue_Operations *operations, - Thread_Control *the_thread, - Thread_queue_Context *queue_context -); - -/** - * @brief Unblocks the thread which was on the thread queue before. - * - * The caller must be the owner of the thread queue lock. This function will - * release the thread queue lock. Thread dispatching is disabled before the - * thread queue lock is released and an unblock is necessary. Thread - * dispatching is enabled once the sequence to unblock the thread is complete. - * - * @param[in] unblock The unblock indicator returned by - * _Thread_queue_Extract_locked(). - * @param[in] queue The actual thread queue. - * @param[in] the_thread The thread to extract. - * @param[in] lock_context The lock context of the lock acquire. - */ -void _Thread_queue_Unblock_critical( - bool unblock, - Thread_queue_Queue *queue, - Thread_Control *the_thread, - ISR_lock_Context *lock_context -); - -/** - * @brief Extracts the thread from the thread queue and unblocks it. - * - * The caller must be the owner of the thread queue lock. This function will - * release the thread queue lock and restore the default thread lock. Thread - * dispatching is disabled before the thread queue lock is released and an - * unblock is necessary. Thread dispatching is enabled once the sequence to - * unblock the thread is complete. This makes it possible to use the thread - * queue lock to protect the state of objects embedding the thread queue and - * directly enter _Thread_queue_Extract_critical() to finalize an operation in - * case a waiting thread exists. - * - * @code - * #include - * - * typedef struct { - * Thread_queue_Control Queue; - * Thread_Control *owner; - * } Mutex; - * - * void _Mutex_Release( Mutex *mutex ) - * { - * Thread_queue_Context queue_context; - * Thread_Control *first; - * - * _Thread_queue_Context_initialize( &queue_context, NULL ); - * _Thread_queue_Acquire( &mutex->Queue, queue_context ); - * - * first = _Thread_queue_First_locked( &mutex->Queue ); - * mutex->owner = first; - * - * if ( first != NULL ) { - * _Thread_queue_Extract_critical( - * &mutex->Queue.Queue, - * mutex->Queue.operations, - * first, - * &queue_context - * ); - * } - * @endcode - * - * @param[in] queue The actual thread queue. - * @param[in] operations The thread queue operations. - * @param[in] the_thread The thread to extract. - * @param[in] queue_context The thread queue context of the lock acquire. - */ -void _Thread_queue_Extract_critical( - Thread_queue_Queue *queue, - const Thread_queue_Operations *operations, - Thread_Control *the_thread, - Thread_queue_Context *queue_context -); - -/** - * @brief Extracts thread from thread queue. - * - * This routine removes @a the_thread its thread queue - * and cancels any timeouts associated with this blocking. - * - * @param[in] the_thread is the pointer to a thread control block that - * is to be removed - */ -void _Thread_queue_Extract( Thread_Control *the_thread ); - -/** - * @brief Extracts the_thread from the_thread_queue. - * - * This routine extracts the_thread from the_thread_queue - * and ensures that if there is a proxy for this task on - * another node, it is also dealt with. - */ -void _Thread_queue_Extract_with_proxy( - Thread_Control *the_thread -); - -/** - * @brief Surrenders the thread queue previously owned by the thread to the - * first enqueued thread. - * - * The owner of the thread queue must be set to NULL by the caller. - * - * This function releases the thread queue lock. In addition it performs a - * thread dispatch if necessary. - * - * @param[in] queue The actual thread queue. - * @param[in] heads The thread queue heads. It must not be NULL. - * @param[in] previous_owner The previous owner thread surrendering the thread - * queue. - * @param[in] queue_context The thread queue context of the lock acquire. - * @param[in] operations The thread queue operations. - */ -void _Thread_queue_Surrender( - Thread_queue_Queue *queue, - Thread_queue_Heads *heads, - Thread_Control *previous_owner, - Thread_queue_Context *queue_context, - const Thread_queue_Operations *operations -); - -#if defined(RTEMS_SMP) -/** - * @brief Surrenders the thread queue previously owned by the thread to the - * first enqueued thread. - * - * The owner of the thread queue must be set to NULL by the caller. - * - * The caller must be the owner of the thread queue lock. This function will - * release the thread queue. - * - * The thread priorities of the previous owner and the new owner are updated. The - * sticky level of the previous owner is decremented. A thread dispatch is - * performed if necessary. - * - * @param[in] queue The actual thread queue. - * @param[in] heads The thread queue heads. It must not be NULL. - * @param[in] previous_owner The previous owner thread surrendering the thread - * queue. - * @param[in] queue_context The thread queue context of the lock acquire. - * @param[in] operations The thread queue operations. - */ -void _Thread_queue_Surrender_sticky( - Thread_queue_Queue *queue, - Thread_queue_Heads *heads, - Thread_Control *previous_owner, - Thread_queue_Context *queue_context, - const Thread_queue_Operations *operations -); -#endif - -RTEMS_INLINE_ROUTINE bool _Thread_queue_Is_empty( - const Thread_queue_Queue *queue -) -{ - return queue->heads == NULL; -} - -/** - * @brief Returns the first thread on the thread queue if it exists, otherwise - * @c NULL. - * - * The caller must be the owner of the thread queue lock. The thread queue - * lock is not released. - * - * @param[in] the_thread_queue The thread queue. - * @param[in] operations The thread queue operations. - * - * @retval NULL No thread is present on the thread queue. - * @retval first The first thread on the thread queue according to the enqueue - * order. - */ -RTEMS_INLINE_ROUTINE Thread_Control *_Thread_queue_First_locked( - Thread_queue_Control *the_thread_queue, - const Thread_queue_Operations *operations -) -{ - Thread_queue_Heads *heads = the_thread_queue->Queue.heads; - - if ( heads != NULL ) { - return ( *operations->first )( heads ); - } else { - return NULL; - } -} - -/** - * @brief Returns the first thread on the thread queue if it exists, otherwise - * @c NULL. - * - * @param[in] the_thread_queue The thread queue. - * - * @retval NULL No thread is present on the thread queue. - * @retval first The first thread on the thread queue according to the enqueue - * order. - */ -Thread_Control *_Thread_queue_First( - Thread_queue_Control *the_thread_queue, - const Thread_queue_Operations *operations -); - -/** - * @brief Thread queue flush filter function. - * - * Called under protection of the thread queue lock by - * _Thread_queue_Flush_critical() to optionally alter the thread wait - * information and control the iteration. - * - * @param the_thread The thread to extract. This is the first parameter to - * optimize for architectures that use the same register for the first - * parameter and the return value. - * @param queue The actual thread queue. - * @param queue_context The thread queue context of the lock acquire. May be - * used to pass additional data to the filter function via an overlay - * structure. The filter function should not release or acquire the thread - * queue lock. - * - * @retval the_thread Extract this thread. - * @retval NULL Do not extract this thread and stop the thread queue flush - * operation. Threads that are already extracted will complete the flush - * operation. - */ -typedef Thread_Control *( *Thread_queue_Flush_filter )( - Thread_Control *the_thread, - Thread_queue_Queue *queue, - Thread_queue_Context *queue_context -); - -/** - * @brief Default thread queue flush filter function. - * - * @param the_thread The thread to extract. - * @param queue Unused. - * @param queue_context Unused. - * - * @retval the_thread Extract this thread. - */ -Thread_Control *_Thread_queue_Flush_default_filter( - Thread_Control *the_thread, - Thread_queue_Queue *queue, - Thread_queue_Context *queue_context -); - -/** - * @brief Status unavailable thread queue flush filter function. - * - * Sets the thread wait return code of the thread to STATUS_UNAVAILABLE. - * - * @param the_thread The thread to extract. - * @param queue Unused. - * @param queue_context Unused. - * - * @retval the_thread Extract this thread. - */ -Thread_Control *_Thread_queue_Flush_status_unavailable( - Thread_Control *the_thread, - Thread_queue_Queue *queue, - Thread_queue_Context *queue_context -); - -/** - * @brief Status object was deleted thread queue flush filter function. - * - * Sets the thread wait return code of the thread to STATUS_OBJECT_WAS_DELETED - * - * @param the_thread The thread to extract. - * @param queue Unused. - * @param queue_context Unused. - * - * @retval the_thread Extract this thread. - */ -Thread_Control *_Thread_queue_Flush_status_object_was_deleted( - Thread_Control *the_thread, - Thread_queue_Queue *queue, - Thread_queue_Context *queue_context -); - -/** - * @brief Unblocks all threads enqueued on the thread queue. - * - * This function iteratively extracts the first enqueued thread of the thread - * queue until the thread queue is empty or the filter function indicates a - * stop. The thread timers of the extracted threads are cancelled. The - * extracted threads are unblocked. - * - * @param queue The actual thread queue. - * @param operations The thread queue operations. - * @param filter The filter functions is called for each thread to extract from - * the thread queue. It may be used to alter the thread under protection of - * the thread queue lock, for example to set the thread wait return code. - * The return value of the filter function controls if the thread queue flush - * operation should stop or continue. - * @param queue_context The thread queue context of the lock acquire. May be - * used to pass additional data to the filter function via an overlay - * structure. The filter function should not release or acquire the thread - * queue lock. - * - * @return The count of extracted threads. - */ -size_t _Thread_queue_Flush_critical( - Thread_queue_Queue *queue, - const Thread_queue_Operations *operations, - Thread_queue_Flush_filter filter, - Thread_queue_Context *queue_context -); - -void _Thread_queue_Initialize( - Thread_queue_Control *the_thread_queue, - const char *name -); - -#if defined(RTEMS_SMP) && defined(RTEMS_DEBUG) && defined(RTEMS_PROFILING) - #define THREAD_QUEUE_INITIALIZER( _name ) \ - { \ - .Lock_stats = SMP_LOCK_STATS_INITIALIZER( _name ), \ - .owner = SMP_LOCK_NO_OWNER, \ - .Queue = { \ - .Lock = SMP_TICKET_LOCK_INITIALIZER, \ - .heads = NULL, \ - .owner = NULL, \ - .name = _name \ - } \ - } -#elif defined(RTEMS_SMP) && defined(RTEMS_DEBUG) - #define THREAD_QUEUE_INITIALIZER( _name ) \ - { \ - .owner = SMP_LOCK_NO_OWNER, \ - .Queue = { \ - .Lock = SMP_TICKET_LOCK_INITIALIZER, \ - .heads = NULL, \ - .owner = NULL, \ - .name = _name \ - } \ - } -#elif defined(RTEMS_SMP) && defined(RTEMS_PROFILING) - #define THREAD_QUEUE_INITIALIZER( _name ) \ - { \ - .Lock_stats = SMP_LOCK_STATS_INITIALIZER( _name ), \ - .Queue = { \ - .Lock = SMP_TICKET_LOCK_INITIALIZER, \ - .heads = NULL, \ - .owner = NULL, \ - .name = _name \ - } \ - } -#elif defined(RTEMS_SMP) - #define THREAD_QUEUE_INITIALIZER( _name ) \ - { \ - .Queue = { \ - .Lock = SMP_TICKET_LOCK_INITIALIZER, \ - .heads = NULL, \ - .owner = NULL, \ - .name = _name \ - } \ - } -#else - #define THREAD_QUEUE_INITIALIZER( _name ) \ - { \ - .Queue = { \ - .heads = NULL, \ - .owner = NULL, \ - .name = _name \ - } \ - } -#endif - -RTEMS_INLINE_ROUTINE void _Thread_queue_Destroy( - Thread_queue_Control *the_thread_queue -) -{ -#if defined(RTEMS_SMP) - _SMP_ticket_lock_Destroy( &the_thread_queue->Queue.Lock ); - _SMP_lock_Stats_destroy( &the_thread_queue->Lock_stats ); -#endif -} - -#if defined(RTEMS_MULTIPROCESSING) -void _Thread_queue_MP_callout_do_nothing( - Thread_Control *the_proxy, - Objects_Id mp_id -); - -void _Thread_queue_Unblock_proxy( - Thread_queue_Queue *queue, - Thread_Control *the_thread -); -#endif - -#if defined(RTEMS_SMP) -bool _Thread_queue_Path_acquire_critical( - Thread_queue_Queue *queue, - Thread_Control *the_thread, - Thread_queue_Context *queue_context -); - -void _Thread_queue_Path_release_critical( - Thread_queue_Context *queue_context -); -#endif - -/** - * @brief Helper structure to ensure that all objects containing a thread queue - * have the right layout. - * - * @see _Thread_Wait_get_id() and THREAD_QUEUE_OBJECT_ASSERT(). - */ -typedef struct { - Objects_Control Object; - Thread_queue_Control Wait_queue; -} Thread_queue_Object; - -#define THREAD_QUEUE_OBJECT_ASSERT( object_type, wait_queue_member ) \ - RTEMS_STATIC_ASSERT( \ - offsetof( object_type, wait_queue_member ) \ - == offsetof( Thread_queue_Object, Wait_queue ) \ - && RTEMS_HAVE_MEMBER_SAME_TYPE( \ - object_type, \ - wait_queue_member, \ - Thread_queue_Object, \ - Wait_queue \ - ), \ - object_type \ - ) - -#define THREAD_QUEUE_QUEUE_TO_OBJECT( queue ) \ - RTEMS_CONTAINER_OF( \ - queue, \ - Thread_queue_Object, \ - Wait_queue.Queue \ - ) - -extern const Thread_queue_Operations _Thread_queue_Operations_default; - -extern const Thread_queue_Operations _Thread_queue_Operations_FIFO; - -extern const Thread_queue_Operations _Thread_queue_Operations_priority; - -extern const Thread_queue_Operations _Thread_queue_Operations_priority_inherit; - -/** - * @brief The special thread queue name to indicated that the thread queue is - * embedded in an object with identifier. - * - * @see _Thread_queue_Object_initialize(). - */ -extern const char _Thread_queue_Object_name[]; - -/** - * @brief Initializes a thread queue embedded in an object with identifier. - * - * The object must have the layout specified by Thread_queue_Object. It should - * be ensured with the THREAD_QUEUE_OBJECT_ASSERT() static assertion. - * - * @param[in] the_thread_queue The thread queue. - */ -void _Thread_queue_Object_initialize( - Thread_queue_Control *the_thread_queue -); - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/timecounter.h b/cpukit/score/include/rtems/score/timecounter.h deleted file mode 100644 index 79444de482..0000000000 --- a/cpukit/score/include/rtems/score/timecounter.h +++ /dev/null @@ -1,244 +0,0 @@ -/** - * @file - * - * @ingroup ScoreTimecounter - * - * @brief Timecounter API - */ - -/* - * Copyright (c) 2015 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_TIMECOUNTER_H -#define _RTEMS_SCORE_TIMECOUNTER_H - -#include -#include -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup ScoreTimecounter Timecounter Handler - * - * @ingroup Score - * - * @{ - */ - -/** - * @brief Returns the wall clock time in the bintime format. - * - * @param[out] bt Returns the wall clock time. - */ -void _Timecounter_Bintime( struct bintime *bt ); - -/** - * @brief Returns the wall clock time in the timespec format. - * - * @param[out] ts Returns the wall clock time. - */ -void _Timecounter_Nanotime( struct timespec *ts ); - -/** - * @brief Returns the wall clock time in the timeval format. - * - * @param[out] tv Returns the wall clock time. - */ -void _Timecounter_Microtime( struct timeval *tv ); - -/** - * @brief Returns the uptime in the bintime format. - * - * @param[out] bt Returns the uptime. - */ -void _Timecounter_Binuptime( struct bintime *bt ); - -/** - * @brief Returns the uptime in the sbintime_t format. - * - * @return Returns the uptime. - */ -sbintime_t _Timecounter_Sbinuptime( void ); - -/** - * @brief Returns the uptime in the timespec format. - * - * @param[out] ts Returns the uptime. - */ -void _Timecounter_Nanouptime( struct timespec *ts ); - -/** - * @brief Returns the uptime in the timeval format. - * - * @param[out] tv Returns the uptime. - */ -void _Timecounter_Microuptime( struct timeval *tv ); - -/** - * @brief Returns the wall clock time in the bintime format. - * - * This function obtains the time with a lower overhead and lower accuracy - * compared to the _Timecounter_Bintime() variant. - * - * @param[out] ts Returns the wall clock time. - */ -void _Timecounter_Getbintime( struct bintime *bt ); - -/** - * @brief Returns the wall clock time in the timespec format. - * - * This function obtains the time with a lower overhead and lower accuracy - * compared to the _Timecounter_Nanotime() variant. - * - * @param[out] ts Returns the wall clock time. - * - * @see _Timecounter_Getbintime(). - */ -void _Timecounter_Getnanotime( struct timespec *ts ); - -/** - * @brief Returns the wall clock time in the timeval format. - * - * This function obtains the time with a lower overhead and lower accuracy - * compared to the _Timecounter_Microtime() variant. - * - * @param[out] tv Returns the wall clock time. - * - * @see _Timecounter_Getbintime(). - */ -void _Timecounter_Getmicrotime( struct timeval *tv ); - -/** - * @brief Returns the uptime in the bintime format. - * - * This function obtains the time with a lower overhead and lower accuracy - * compared to the _Timecounter_Binuptime() variant. - * - * @param[out] ts Returns the uptime. - */ -void _Timecounter_Getbinuptime( struct bintime *bt ); - -/** - * @brief Returns the uptime in the timespec format. - * - * This function obtains the time with a lower overhead and lower accuracy - * compared to the _Timecounter_Nanouptime() variant. - * - * @param[out] ts Returns the uptime. - */ -void _Timecounter_Getnanouptime( struct timespec *ts ); - -/** - * @brief Returns the uptime in the timeval format. - * - * This function obtains the time with a lower overhead and lower accuracy - * compared to the _Timecounter_Microuptime() variant. - * - * @param[out] tv Returns the uptime. - */ -void _Timecounter_Getmicrouptime( struct timeval *tv ); - -/** - * @brief Returns the boot time in the timeval format. - * - * @param[out] tv Returns the boot time. - */ -void _Timecounter_Getboottime( struct timeval *tv ); - -/** - * @brief Returns the boot time in the bintime format. - * - * @param[out] tv Returns the boot time. - */ -void _Timecounter_Getboottimebin( struct bintime *bt ); - -/** - * @brief Installs the timecounter. - * - * The timecounter structure must contain valid values in the fields - * tc_get_timecount, tc_counter_mask, tc_frequency and tc_quality. All other - * fields must be zero initialized. - * - * @param[in] tc The timecounter. - */ -void _Timecounter_Install( struct timecounter *tc ); - -/** - * @brief Performs a timecounter tick. - */ -void _Timecounter_Tick( void ); - -/** - * @brief Lock to protect the timecounter mechanic. - */ -ISR_LOCK_DECLARE( extern, _Timecounter_Lock ) - -/** - * @brief Acquires the timecounter lock. - * - * @param[in] lock_context The lock context. - * - * See _Timecounter_Tick_simple(). - */ -#define _Timecounter_Acquire( lock_context ) \ - _ISR_lock_ISR_disable_and_acquire( &_Timecounter_Lock, lock_context ) - -/** - * @brief Performs a simple timecounter tick. - * - * This is a special purpose tick function for simple timecounter to support - * legacy clock drivers. - * - * @param[in] delta The time in timecounter ticks elapsed since the last call - * to _Timecounter_Tick_simple(). - * @param[in] offset The current value of the timecounter. - * @param[in] lock_context The lock context of the corresponding - * _Timecounter_Acquire(). - */ -void _Timecounter_Tick_simple( - uint32_t delta, - uint32_t offset, - ISR_lock_Context *lock_context -); - -/** - * @brief The wall clock time in seconds. - */ -extern volatile time_t _Timecounter_Time_second; - -/** - * @brief The uptime in seconds. - * - * For compatibility with the FreeBSD network stack the initial value is one - * second. - */ -extern volatile int32_t _Timecounter_Time_uptime; - -/** - * @brief The current timecounter. - */ -extern struct timecounter *_Timecounter; - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_SCORE_TIMECOUNTER_H */ diff --git a/cpukit/score/include/rtems/score/timecounterimpl.h b/cpukit/score/include/rtems/score/timecounterimpl.h deleted file mode 100644 index a48ac70683..0000000000 --- a/cpukit/score/include/rtems/score/timecounterimpl.h +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @file - * - * @ingroup ScoreTimecounter - * - * @brief Timecounter Implementation - */ - -/* - * Copyright (c) 2015 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_TIMECOUNTERIMPL_H -#define _RTEMS_SCORE_TIMECOUNTERIMPL_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @addtogroup ScoreTimecounter - * - * @{ - */ - -void _Timecounter_Set_clock( - const struct bintime *bt, - ISR_lock_Context *lock_context -); - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_SCORE_TIMECOUNTERIMPL_H */ diff --git a/cpukit/score/include/rtems/score/timespec.h b/cpukit/score/include/rtems/score/timespec.h deleted file mode 100644 index 72a000177f..0000000000 --- a/cpukit/score/include/rtems/score/timespec.h +++ /dev/null @@ -1,272 +0,0 @@ -/** - * @file rtems/score/timespec.h - * - * This include file contains helpers for manipulating timespecs. - */ - -/* - * COPYRIGHT (c) 1989-2009. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_TIMESPEC_H -#define _RTEMS_SCORE_TIMESPEC_H - -/** - * @defgroup Timespec Helpers - * - * @ingroup Score - * - * This handler encapsulates functionality related to manipulating - * POSIX struct timespecs. - */ -/**@{*/ - -#include /* bool */ -#include /* uint32_t */ -#include /* struct timespec */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Set timespec to seconds nanosecond. - * - * This method sets the timespec to the specified seconds and nanoseconds - * value. - * - * @param[in] _time points to the timespec instance to validate. - * @param[in] _seconds is the seconds portion of the timespec - * @param[in] _nanoseconds is the nanoseconds portion of the timespec - */ -#define _Timespec_Set( _time, _seconds, _nanoseconds ) \ - do { \ - (_time)->tv_sec = (_seconds); \ - (_time)->tv_nsec = (_nanoseconds); \ - } while (0) - -/** - * @brief Sets the Timespec to Zero - * - * This method sets the timespec to zero. - * value. - * - * @param[in] _time points to the timespec instance to zero. - */ -#define _Timespec_Set_to_zero( _time ) \ - do { \ - (_time)->tv_sec = 0; \ - (_time)->tv_nsec = 0; \ - } while (0) - -/** - * @brief Get seconds portion of timespec. - * - * This method returns the seconds portion of the specified timespec - * - * @param[in] _time points to the timespec - * - * @retval The seconds portion of @a _time. - */ -#define _Timespec_Get_seconds( _time ) \ - ((_time)->tv_sec) - -/** - * @brief Get nanoseconds portion of timespec. - * - * This method returns the nanoseconds portion of the specified timespec - * - * @param[in] _time points to the timespec - * - * @retval The nanoseconds portion of @a _time. - */ -#define _Timespec_Get_nanoseconds( _time ) \ - ((_time)->tv_nsec) - -/** - * @brief Get the timestamp as nanoseconds. - * - * This method returns the timestamp as nanoseconds. - * - * @param[in] time points to the timestamp. - * - * @retval The time in nanoseconds. - */ -uint64_t _Timespec_Get_as_nanoseconds( - const struct timespec *time -); - -/** - * @brief Check if timespec is valid. - * - * This method determines the validity of a timespec. - * - * @param[in] time is the timespec instance to validate. - * - * @retval This method returns true if @a time is valid and - * false otherwise. - */ -bool _Timespec_Is_valid( - const struct timespec *time -); - -/** - * @brief The Timespec "less than" operator. - * - * This method is the less than operator for timespecs. - * - * @param[in] lhs is the left hand side timespec - * @param[in] rhs is the right hand side timespec - * - * @retval This method returns true if @a lhs is less than the @a rhs and - * false otherwise. - */ -bool _Timespec_Less_than( - const struct timespec *lhs, - const struct timespec *rhs -); - -/** - * @brief The Timespec "greater than" operator. - * - * This method is the greater than operator for timespecs. - * - * @param[in] _lhs is the left hand side timespec - * @param[in] _rhs is the right hand side timespec - * - * @retval This method returns true if @a lhs is greater than the @a rhs and - * false otherwise. - */ -#define _Timespec_Greater_than( _lhs, _rhs ) \ - _Timespec_Less_than( _rhs, _lhs ) - -/** - * @brief The Timespec "equal to" operator. - * - * This method is the is equal to than operator for timespecs. - * - * @param[in] lhs is the left hand side timespec - * @param[in] rhs is the right hand side timespec - * - * @retval This method returns true if @a lhs is equal to @a rhs and - * false otherwise. - */ -#define _Timespec_Equal_to( lhs, rhs ) \ - ( ((lhs)->tv_sec == (rhs)->tv_sec) && \ - ((lhs)->tv_nsec == (rhs)->tv_nsec) \ - ) - -/** - * @brief Add two timespecs. - * - * This routine adds two timespecs. The second argument is added - * to the first. - * - * @param[in] time is the base time to be added to - * @param[in] add is the timespec to add to the first argument - * - * @retval This method returns the number of seconds @a time increased by. - */ -uint32_t _Timespec_Add_to( - struct timespec *time, - const struct timespec *add -); - -/** - * @brief Convert timespec to number of ticks. - * - * This routine convert the @a time timespec to the corresponding number - * of clock ticks. - * - * @param[in] time is the time to be converted - * - * @retval This method returns the number of ticks computed. - */ -uint32_t _Timespec_To_ticks( - const struct timespec *time -); - -/** - * @brief Convert ticks to timespec. - * - * This routine converts the @a ticks value to the corresponding - * timespec format @a time. - * - * @param[in] time is the timespec format time result - * @param[in] ticks is the number of ticks to convert - */ -void _Timespec_From_ticks( - uint32_t ticks, - struct timespec *time -); - -/** - * @brief Subtract two timespec. - * - * This routine subtracts two timespecs. @a result is set to - * @a end - @a start. - * - * @param[in] start is the starting time - * @param[in] end is the ending time - * @param[in] result is the difference between starting and ending time. - * - * @retval This method fills in @a result. - */ -void _Timespec_Subtract( - const struct timespec *start, - const struct timespec *end, - struct timespec *result -); - -/** - * @brief Divide timespec by an integer. - * - * This routine divides a timespec by an integer value. The expected - * use is to assist in benchmark calculations where you typically - * divide a duration by a number of iterations. - * - * @param[in] time is the total - * @param[in] iterations is the number of iterations - * @param[in] result is the average time. - * - * @retval This method fills in @a result. - */ -void _Timespec_Divide_by_integer( - const struct timespec *time, - uint32_t iterations, - struct timespec *result -); - -/** - * @brief Divide a timespec by anonther timespec. - * - * This routine divides a timespec by another timespec. The - * intended use is for calculating percentages to three decimal points. - * - * @param[in] lhs is the left hand number - * @param[in] rhs is the right hand number - * @param[in] ival_percentage is the integer portion of the average - * @param[in] fval_percentage is the thousandths of percentage - * - * @retval This method fills in @a result. - */ -void _Timespec_Divide( - const struct timespec *lhs, - const struct timespec *rhs, - uint32_t *ival_percentage, - uint32_t *fval_percentage -); - -#ifdef __cplusplus -} -#endif - -/**@}*/ - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/timestamp.h b/cpukit/score/include/rtems/score/timestamp.h deleted file mode 100644 index 6fc17ced9c..0000000000 --- a/cpukit/score/include/rtems/score/timestamp.h +++ /dev/null @@ -1,323 +0,0 @@ -/** - * @file rtems/score/timestamp.h - * - * @brief Helpers for Manipulating Timestamps - * - * This include file contains helpers for manipulating timestamps. - */ - -/* - * COPYRIGHT (c) 1989-2009. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_TIMESTAMP_H -#define _RTEMS_SCORE_TIMESTAMP_H - -/** - * @defgroup SuperCoreTimeStamp Score Timestamp - * - * @ingroup Score - * - * This handler encapsulates functionality related to manipulating - * SuperCore Timestamps. SuperCore Timestamps may be used to - * represent time of day, uptime, or intervals. - * - * The key attribute of the SuperCore Timestamp handler is that it - * is a completely opaque handler. There can be multiple implementations - * of the required functionality and with a recompile, RTEMS can use - * any implementation. It is intended to be a simple wrapper. - * - * This handler can be implemented as either struct timespec or - * unsigned64 bit numbers. The use of a wrapper class allows the - * the implementation of timestamps to change on a per architecture - * basis. This is an important option as the performance of this - * handler is critical. - */ -/**@{*/ - -#include - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Define the Timestamp control type. - */ -typedef sbintime_t Timestamp_Control; - -/** - * @brief Set timestamp to specified seconds and nanoseconds. - * - * This method sets the timestamp to the specified @a _seconds and @a _nanoseconds - * value. - * - * @param[in] _time points to the timestamp instance to validate. - * @param[in] _seconds is the seconds portion of the timestamp - * @param[in] _nanoseconds is the nanoseconds portion of the timestamp - */ -RTEMS_INLINE_ROUTINE void _Timestamp_Set( - Timestamp_Control *_time, - time_t _seconds, - long _nanoseconds -) -{ - struct timespec _ts; - - _ts.tv_sec = _seconds; - _ts.tv_nsec = _nanoseconds; - - *_time = tstosbt(_ts); -} - -/** - * @brief Sets the timestamp to zero. - * - * This method sets the timestamp to zero. - * value. - * - * @param[in] _time points to the timestamp instance to zero. - */ - -RTEMS_INLINE_ROUTINE void _Timestamp_Set_to_zero( - Timestamp_Control *_time -) -{ - *_time = 0; -} - -/** - * @brief Less than operator for timestamps. - * - * This method is the less than operator for timestamps. - * - * @param[in] _lhs points to the left hand side timestamp - * @param[in] _rhs points to the right hand side timestamp - * - * @retval This method returns true if @a _lhs is less than the @a _rhs and - * false otherwise. - */ - -RTEMS_INLINE_ROUTINE bool _Timestamp_Less_than( - const Timestamp_Control *_lhs, - const Timestamp_Control *_rhs -) -{ - return *_lhs < *_rhs; -} - -/** - * @brief Greater than operator for timestamps. - * - * This method is the greater than operator for timestamps. - * - * @param[in] _lhs points to the left hand side timestamp - * @param[in] _rhs points to the right hand side timestamp - * - * @retval This method returns true if @a _lhs is greater than the @a _rhs and - * false otherwise. - */ - -RTEMS_INLINE_ROUTINE bool _Timestamp_Greater_than( - const Timestamp_Control *_lhs, - const Timestamp_Control *_rhs -) -{ - return *_lhs > *_rhs; -} - -/** - * @brief Equal to than operator for timestamps. - * - * This method is the is equal to than operator for timestamps. - * - * @param[in] _lhs points to the left hand side timestamp - * @param[in] _rhs points to the right hand side timestamp - * - * @retval This method returns true if @a _lhs is equal to @a _rhs and - * false otherwise. - */ - -RTEMS_INLINE_ROUTINE bool _Timestamp_Equal_to( - const Timestamp_Control *_lhs, - const Timestamp_Control *_rhs -) -{ - return *_lhs == *_rhs; -} - -/** - * @brief Adds two timestamps. - * - * This routine adds two timestamps. The second argument is added - * to the first. - * - * @param[in] _time points to the base time to be added to - * @param[in] _add points to the timestamp to add to the first argument - */ -RTEMS_INLINE_ROUTINE void _Timestamp_Add_to( - Timestamp_Control *_time, - const Timestamp_Control *_add -) -{ - *_time += *_add; -} - -/** - * @brief Subtracts two timestamps. - * - * This routine subtracts two timestamps. @a result is set to - * @a end - @a start. - * - * @param[in] _start points to the starting time - * @param[in] _end points to the ending time - * @param[in] _result points to the difference between - * starting and ending time. - * - * @retval This method fills in @a _result. - */ -RTEMS_INLINE_ROUTINE void _Timestamp_Subtract( - const Timestamp_Control *_start, - const Timestamp_Control *_end, - Timestamp_Control *_result -) -{ - *_result = *_end - *_start; -} - -/** - * @brief Divides a timestamp by another timestamp. - * - * This routine divides a timestamp by another timestamp. The - * intended use is for calculating percentages to three decimal points. - * - * @param[in] _lhs points to the left hand number - * @param[in] _rhs points to the right hand number - * @param[in] _ival_percentage points to the integer portion of the average - * @param[in] _fval_percentage points to the thousandths of percentage - * - * @retval This method fills in @a result. - */ -RTEMS_INLINE_ROUTINE void _Timestamp_Divide( - const Timestamp_Control *_lhs, - const Timestamp_Control *_rhs, - uint32_t *_ival_percentage, - uint32_t *_fval_percentage -) -{ - struct timespec _ts_left; - struct timespec _ts_right; - - _ts_left = sbttots( *_lhs ); - _ts_right = sbttots( *_rhs ); - - _Timespec_Divide( - &_ts_left, - &_ts_right, - _ival_percentage, - _fval_percentage - ); -} - -/** - * @brief Get seconds portion of timestamp. - * - * This method returns the seconds portion of the specified timestamp - * - * @param[in] _time points to the timestamp - * - * @retval The seconds portion of @a _time. - */ -RTEMS_INLINE_ROUTINE time_t _Timestamp_Get_seconds( - const Timestamp_Control *_time -) -{ - return (*_time >> 32); -} - -/** - * @brief Get nanoseconds portion of timestamp. - * - * This method returns the nanoseconds portion of the specified timestamp - * - * @param[in] _time points to the timestamp - * - * @retval The nanoseconds portion of @a _time. - */ -RTEMS_INLINE_ROUTINE uint32_t _Timestamp_Get_nanoseconds( - const Timestamp_Control *_time -) -{ - struct timespec _ts; - - _ts = sbttots( *_time ); - - return (uint32_t) _ts.tv_nsec; -} - -/** - * @brief Get the timestamp as nanoseconds. - * - * This method returns the timestamp as nanoseconds. - * - * @param[in] _time points to the timestamp - * - * @retval The time in nanoseconds. - */ -RTEMS_INLINE_ROUTINE uint64_t _Timestamp_Get_as_nanoseconds( - const Timestamp_Control *_time -) -{ - struct timespec _ts; - - _ts = sbttots( *_time ); - - return _Timespec_Get_as_nanoseconds( &_ts ); -} - -/** - * @brief Convert timestamp to struct timespec. - * - * This method returns the seconds portion of the specified @a _timestamp. - * - * @param[in] _timestamp points to the timestamp - * @param[in] _timespec points to the timespec - */ -RTEMS_INLINE_ROUTINE void _Timestamp_To_timespec( - const Timestamp_Control *_timestamp, - struct timespec *_timespec -) -{ - *_timespec = sbttots( *_timestamp ); -} - -/** - * @brief Convert timestamp to struct timeval. - * - * @param[in] _timestamp points to the timestamp - * @param[in] _timeval points to the timeval - */ -RTEMS_INLINE_ROUTINE void _Timestamp_To_timeval( - const Timestamp_Control *_timestamp, - struct timeval *_timeval -) -{ - *_timeval = sbttotv( *_timestamp ); -} - -#ifdef __cplusplus -} -#endif - -/**@}*/ - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/tls.h b/cpukit/score/include/rtems/score/tls.h deleted file mode 100644 index 644e54e6f7..0000000000 --- a/cpukit/score/include/rtems/score/tls.h +++ /dev/null @@ -1,217 +0,0 @@ -/** - * @file - * - * @ingroup ScoreTLS - * - * @brief Thread-Local Storage (TLS) - */ - -/* - * Copyright (c) 2014 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_TLS_H -#define _RTEMS_SCORE_TLS_H - -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @defgroup ScoreTLS Thread-Local Storage (TLS) - * - * @ingroup Score - * - * @brief Thread-local storage (TLS) support. - * - * Variants I and II are according to Ulrich Drepper, "ELF Handling For - * Thread-Local Storage". - * - * @{ - */ - -extern char _TLS_Data_begin[]; - -extern char _TLS_Data_end[]; - -extern char _TLS_Data_size[]; - -extern char _TLS_BSS_begin[]; - -extern char _TLS_BSS_end[]; - -extern char _TLS_BSS_size[]; - -extern char _TLS_Size[]; - -extern char _TLS_Alignment[]; - -typedef struct { - /* - * FIXME: Not sure if the generation number type is correct for all - * architectures. - */ - uint32_t generation_number; - - void *tls_blocks[1]; -} TLS_Dynamic_thread_vector; - -typedef struct TLS_Thread_control_block { -#ifdef __i386__ - struct TLS_Thread_control_block *tcb; -#else - TLS_Dynamic_thread_vector *dtv; - uintptr_t reserved; -#endif -} TLS_Thread_control_block; - -typedef struct { - uintptr_t module; - uintptr_t offset; -} TLS_Index; - -static inline uintptr_t _TLS_Get_size( void ) -{ - /* - * Do not use _TLS_Size here since this will lead GCC to assume that this - * symbol is not 0 and the tests for 0 will be optimized away. - */ - return (uintptr_t) _TLS_BSS_end - (uintptr_t) _TLS_Data_begin; -} - -static inline uintptr_t _TLS_Heap_align_up( uintptr_t val ) -{ - uintptr_t msk = CPU_HEAP_ALIGNMENT - 1; - - return (val + msk) & ~msk; -} - -static inline uintptr_t _TLS_Get_thread_control_block_area_size( - uintptr_t alignment -) -{ - return alignment <= sizeof(TLS_Thread_control_block) ? - sizeof(TLS_Thread_control_block) : alignment; -} - -static inline uintptr_t _TLS_Get_allocation_size( - uintptr_t size, - uintptr_t alignment -) -{ - uintptr_t allocation_size = 0; - - allocation_size += _TLS_Heap_align_up( size ); - allocation_size += _TLS_Get_thread_control_block_area_size( alignment ); - -#ifndef __i386__ - allocation_size += sizeof(TLS_Dynamic_thread_vector); -#endif - - return allocation_size; -} - -static inline void *_TLS_Copy_and_clear( void *tls_area ) -{ - tls_area = memcpy( - tls_area, - _TLS_Data_begin, - (size_t) ((uintptr_t)_TLS_Data_size) - ); - - - memset( - (char *) tls_area + (size_t)((intptr_t) _TLS_BSS_begin) - - (size_t)((intptr_t) _TLS_Data_begin), - 0, - ((size_t) (intptr_t)_TLS_BSS_size) - ); - - return tls_area; -} - -static inline void *_TLS_Initialize( - void *tls_block, - TLS_Thread_control_block *tcb, - TLS_Dynamic_thread_vector *dtv -) -{ -#ifdef __i386__ - (void) dtv; - tcb->tcb = tcb; -#else - tcb->dtv = dtv; - dtv->generation_number = 1; - dtv->tls_blocks[0] = tls_block; -#endif - - return _TLS_Copy_and_clear( tls_block ); -} - -/* Use Variant I, TLS offsets emitted by linker takes the TCB into account */ -static inline void *_TLS_TCB_at_area_begin_initialize( void *tls_area ) -{ - void *tls_block = (char *) tls_area - + _TLS_Get_thread_control_block_area_size( (uintptr_t) _TLS_Alignment ); - TLS_Thread_control_block *tcb = tls_area; - uintptr_t aligned_size = _TLS_Heap_align_up( (uintptr_t) _TLS_Size ); - TLS_Dynamic_thread_vector *dtv = (TLS_Dynamic_thread_vector *) - ((char *) tls_block + aligned_size); - - return _TLS_Initialize( tls_block, tcb, dtv ); -} - -/* Use Variant I, TLS offsets emitted by linker neglects the TCB */ -static inline void *_TLS_TCB_before_TLS_block_initialize( void *tls_area ) -{ - void *tls_block = (char *) tls_area - + _TLS_Get_thread_control_block_area_size( (uintptr_t) _TLS_Alignment ); - TLS_Thread_control_block *tcb = (TLS_Thread_control_block *) - ((char *) tls_block - sizeof(*tcb)); - uintptr_t aligned_size = _TLS_Heap_align_up( (uintptr_t) _TLS_Size ); - TLS_Dynamic_thread_vector *dtv = (TLS_Dynamic_thread_vector *) - ((char *) tls_block + aligned_size); - - return _TLS_Initialize( tls_block, tcb, dtv ); -} - -/* Use Variant II */ -static inline void *_TLS_TCB_after_TLS_block_initialize( void *tls_area ) -{ - uintptr_t size = (uintptr_t) _TLS_Size; - uintptr_t tls_align = (uintptr_t) _TLS_Alignment; - uintptr_t tls_mask = tls_align - 1; - uintptr_t heap_align = _TLS_Heap_align_up( tls_align ); - uintptr_t heap_mask = heap_align - 1; - TLS_Thread_control_block *tcb = (TLS_Thread_control_block *) - ((char *) tls_area + ((size + heap_mask) & ~heap_mask)); - void *tls_block = (char *) tcb - ((size + tls_mask) & ~tls_mask); - TLS_Dynamic_thread_vector *dtv = (TLS_Dynamic_thread_vector *) - ((char *) tcb + sizeof(*tcb)); - - _TLS_Initialize( tls_block, tcb, dtv ); - - return tcb; -} - -/** @} */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_SCORE_TLS_H */ diff --git a/cpukit/score/include/rtems/score/tod.h b/cpukit/score/include/rtems/score/tod.h deleted file mode 100644 index c0ab5e795d..0000000000 --- a/cpukit/score/include/rtems/score/tod.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @file - * - * @ingroup ScoreTOD - * - * @brief Time of Day Handler API - */ - -/* - * COPYRIGHT (c) 1989-2009. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_TOD_H -#define _RTEMS_SCORE_TOD_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/todimpl.h b/cpukit/score/include/rtems/score/todimpl.h deleted file mode 100644 index b00ab6cca2..0000000000 --- a/cpukit/score/include/rtems/score/todimpl.h +++ /dev/null @@ -1,304 +0,0 @@ -/** - * @file - * - * @ingroup ScoreTOD - * - * @brief Time of Day Handler API - */ - -/* - * COPYRIGHT (c) 1989-2009. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_TODIMPL_H -#define _RTEMS_SCORE_TODIMPL_H - -#include -#include -#include -#include - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ScoreTOD Time of Day Handler - * - * @ingroup Score - * - * The following constants are related to the time of day and are - * independent of RTEMS. - */ -/**@{*/ - -/** - * This constant represents the number of seconds in a minute. - */ -#define TOD_SECONDS_PER_MINUTE (uint32_t)60 - -/** - * This constant represents the number of minutes per hour. - */ -#define TOD_MINUTES_PER_HOUR (uint32_t)60 - -/** - * This constant represents the number of months in a year. - */ -#define TOD_MONTHS_PER_YEAR (uint32_t)12 - -/** - * This constant represents the number of days in a non-leap year. - */ -#define TOD_DAYS_PER_YEAR (uint32_t)365 - -/** - * This constant represents the number of hours per day. - */ -#define TOD_HOURS_PER_DAY (uint32_t)24 - -/** - * This constant represents the number of seconds in a day which does - * not include a leap second. - */ -#define TOD_SECONDS_PER_DAY (uint32_t) (TOD_SECONDS_PER_MINUTE * \ - TOD_MINUTES_PER_HOUR * \ - TOD_HOURS_PER_DAY) - -/** - * This constant represents the number of seconds in a non-leap year. - */ -#define TOD_SECONDS_PER_NON_LEAP_YEAR (365 * TOD_SECONDS_PER_DAY) - -/** - * This constant represents the number of millisecond in a second. - */ -#define TOD_MILLISECONDS_PER_SECOND (uint32_t)1000 - -/** - * This constant represents the number of microseconds in a second. - */ -#define TOD_MICROSECONDS_PER_SECOND (uint32_t)1000000 - -/** - * This constant represents the number of nanoseconds in a second. - */ -#define TOD_NANOSECONDS_PER_SECOND (uint32_t)1000000000 - -/** - * This constant represents the number of nanoseconds in a mircosecond. - */ -#define TOD_NANOSECONDS_PER_MICROSECOND (uint32_t)1000 - -/**@}*/ - -/** - * Seconds from January 1, 1970 to January 1, 1988. Used to account for - * differences between POSIX API and RTEMS core. The timespec format time - * is kept in POSIX compliant form. - */ -#define TOD_SECONDS_1970_THROUGH_1988 \ - (((1987 - 1970 + 1) * TOD_SECONDS_PER_NON_LEAP_YEAR) + \ - (4 * TOD_SECONDS_PER_DAY)) - -/** - * @brief Earliest year to which an time of day can be initialized. - * - * The following constant define the earliest year to which an - * time of day can be initialized. This is considered the - * epoch. - */ -#define TOD_BASE_YEAR 1988 - -/** - * @defgroup ScoreTOD Time Of Day (TOD) Handler - * - * @ingroup Score - * - * This handler encapsulates functionality used to manage time of day. - */ -/**@{*/ - -/** - * @brief TOD control. - */ -typedef struct { - /** - * @brief Indicates if the time of day is set. - * - * This is true if the application has set the current - * time of day, and false otherwise. - */ - bool is_set; -} TOD_Control; - -extern TOD_Control _TOD; - -void _TOD_Lock( void ); - -void _TOD_Unlock( void ); - -#if defined(RTEMS_DEBUG) -bool _TOD_Is_owner( void ); -#endif - -static inline void _TOD_Acquire( ISR_lock_Context *lock_context ) -{ - _Timecounter_Acquire( lock_context ); -} - -/** - * @brief Sets the time of day. - * - * The caller must be the owner of the TOD lock. - * - * @param tod The new time of day in timespec format representing - * the time since UNIX Epoch. - * @param lock_context The ISR lock context used for the corresponding - * _TOD_Acquire(). The caller must be the owner of the TOD lock. This - * function will release the TOD lock. - */ -void _TOD_Set( - const struct timespec *tod, - ISR_lock_Context *lock_context -); - -/** - * @brief Gets the current time in the timespec format. - * - * @param[out] time is the value gathered by the request - */ -static inline void _TOD_Get( - struct timespec *tod -) -{ - _Timecounter_Nanotime( tod ); -} - -/** - * @brief Gets the system uptime with potential accuracy to the nanosecond. - * - * This routine returns the system uptime with potential accuracy - * to the nanosecond. - * - * The initial uptime value is undefined. - * - * @param[in] time is a pointer to the uptime to be returned - */ -static inline void _TOD_Get_uptime( - Timestamp_Control *time -) -{ - *time = _Timecounter_Sbinuptime(); -} - -/** - * @brief Gets the system uptime with potential accuracy to the nanosecond. - * to the nanosecond. - * - * The initial uptime value is zero. - * - * @param[in] time is a pointer to the uptime to be returned - */ -static inline void _TOD_Get_zero_based_uptime( - Timestamp_Control *time -) -{ - *time = _Timecounter_Sbinuptime() - SBT_1S; -} - -/** - * @brief Gets the system uptime with potential accuracy to the nanosecond. - * - * The initial uptime value is zero. - * - * @param[in] time is a pointer to the uptime to be returned - */ -static inline void _TOD_Get_zero_based_uptime_as_timespec( - struct timespec *time -) -{ - _Timecounter_Nanouptime( time ); - --time->tv_sec; -} - -/** - * @brief Number of seconds Since RTEMS epoch. - * - * The following contains the number of seconds from 00:00:00 - * January 1, TOD_BASE_YEAR until the current time of day. - */ -static inline uint32_t _TOD_Seconds_since_epoch( void ) -{ - return (uint32_t) _Timecounter_Time_second; -} - -/** - * @brief Gets number of ticks in a second. - * - * This method returns the number of ticks in a second. - * - * @note If the clock tick value does not multiply evenly into a second - * then this number of ticks will be slightly shorter than a second. - */ -uint32_t TOD_TICKS_PER_SECOND_method(void); - -/** - * @brief Gets number of ticks in a second. - * - * This method exists to hide the fact that TOD_TICKS_PER_SECOND can not - * be implemented as a macro in a .h file due to visibility issues. - * The Configuration Table is not available to SuperCore .h files but - * is available to their .c files. - */ -#define TOD_TICKS_PER_SECOND TOD_TICKS_PER_SECOND_method() - -/** - * This routine returns a timeval based upon the internal timespec format TOD. - */ - -RTEMS_INLINE_ROUTINE void _TOD_Get_timeval( - struct timeval *time -) -{ - _Timecounter_Microtime( time ); -} - -/** - * @brief Adjust the Time of Time - * - * This method is used to adjust the current time of day by the - * specified amount. - * - * @param[in] delta is the amount to adjust - */ -void _TOD_Adjust( - const struct timespec *delta -); - -/** - * @brief Check if the TOD is Set - * - * @return TRUE is the time is set. FALSE otherwise. - */ -RTEMS_INLINE_ROUTINE bool _TOD_Is_set( void ) -{ - return _TOD.is_set; -} - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/userext.h b/cpukit/score/include/rtems/score/userext.h deleted file mode 100644 index 5af5824808..0000000000 --- a/cpukit/score/include/rtems/score/userext.h +++ /dev/null @@ -1,273 +0,0 @@ -/** - * @file - * - * @ingroup ScoreUserExt - * - * @brief User Extension Handler API - */ - -/* - * COPYRIGHT (c) 1989-2009. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_USEREXT_H -#define _RTEMS_SCORE_USEREXT_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void User_extensions_routine RTEMS_DEPRECATED; - -/** - * @defgroup ScoreUserExt User Extension Handler - * - * @ingroup Score - * - * @brief The User Extension Handler provides invocation of application - * dependent routines at critical points in the life of each thread and the - * system as a whole. - */ -/**@{**/ - -/** - * @brief Task create extension. - * - * It corresponds to _Thread_Initialize() (used by the rtems_task_create() - * directive and pthread_create()). - * - * It is invoked after the new thread has been completely initialized, but - * before it is placed on a ready chain. - * - * Thread dispatching may be disabled. This depends on the context of the - * _Thread_Initialize() call. Thread dispatch is disabled during the creation - * of the idle thread and the initialization threads. It can be considered as - * an invalid API usage, if the application calls _Thread_Initialize() with - * disabled thread dispatching. Disabled thread dispatching is different from - * disabled preemption. - * - * It can be assumed that the executing thread locked the allocator mutex. - * The only exception is the creation of the idle thread. In this case the - * allocator mutex is not locked. Since the allocator mutex allows nesting the - * normal memory allocation routines can be used. - * - * @param[in] executing The executing thread. - * @param[in] created The created thread. - * - * @retval true Successful operation. - * @retval false A thread create user extension will frequently attempt to - * allocate resources. If this allocation fails, then the extension should - * return @a false and the entire thread create operation will fail. - */ -typedef bool ( *User_extensions_thread_create_extension )( - Thread_Control *executing, - Thread_Control *created -); - -/** - * @brief Task delete extension. - * - * It corresponds to _Thread_Close() (used by the rtems_task_delete() - * directive, pthread_exit() and pthread_cancel()). - * - * It is invoked before all resources of the thread are deleted. The executing - * and deleted arguments are never equal. - * - * Thread dispatching is enabled. The executing thread locked the allocator - * mutex. - * - * @param[in] executing The executing thread. - * @param[in] deleted The deleted thread. - */ -typedef void( *User_extensions_thread_delete_extension )( - Thread_Control *executing, - Thread_Control *deleted -); - -/** - * @brief Task start extension. - * - * It corresponds to _Thread_Start() (used by the rtems_task_start() - * directive). - * - * It is invoked after the environment of the thread has been loaded and the - * thread has been made ready. - * - * Thread dispatching is disabled. The executing thread is not the holder of - * the allocator mutex. - * - * @param[in] executing The executing thread. - * @param[in] started The started thread. - */ -typedef void( *User_extensions_thread_start_extension )( - Thread_Control *executing, - Thread_Control *started -); - -/** - * @brief Task restart extension. - * - * It corresponds to _Thread_Restart() (used by the rtems_task_restart() - * directive). - * - * It is invoked in the context of the restarted thread right before the - * execution context is reloaded. The executing and restarted arguments are - * always equal. The thread stack reflects the previous execution context. - * - * Thread dispatching is enabled. The thread is not the holder of the - * allocator mutex. The thread life is protected. Thread restart and delete - * requests issued by restart extensions lead to recursion. - * - * @param[in] executing The executing thread. - * @param[in] restarted The executing thread. Yes, the executing thread. - */ -typedef void( *User_extensions_thread_restart_extension )( - Thread_Control *executing, - Thread_Control *restarted -); - -/** - * @brief Task switch extension. - * - * It corresponds to _Thread_Dispatch(). - * - * It is invoked before the context switch from the executing to the heir - * thread. - * - * Thread dispatching is disabled. The state of the allocator mutex is - * arbitrary. Interrupts are disabled and the per-CPU lock is acquired on SMP - * configurations. - * - * The context switches initiated through _Thread_Start_multitasking() are not - * covered by this extension. - * - * @param[in] executing The executing thread. - * @param[in] heir The heir thread. - */ -typedef void( *User_extensions_thread_switch_extension )( - Thread_Control *executing, - Thread_Control *heir -); - -/** - * @brief Task begin extension. - * - * It corresponds to _Thread_Handler(). - * - * Thread dispatching is disabled. The executing thread is not the holder of - * the allocator mutex. - * - * @param[in] executing The executing thread. - */ -typedef void( *User_extensions_thread_begin_extension )( - Thread_Control *executing -); - -/** - * @brief Task exitted extension. - * - * It corresponds to _Thread_Handler() after a return of the entry function. - * - * Thread dispatching is disabled. The state of the allocator mutex is - * arbitrary. - * - * @param[in] executing The executing thread. - */ -typedef void( *User_extensions_thread_exitted_extension )( - Thread_Control *executing -); - -/** - * @brief Fatal error extension. - * - * It corresponds to _Terminate() (used by the rtems_fatal() directive). - * - * This extension should not call any RTEMS directives. - * - * @param[in] source The fatal source indicating the subsystem the fatal - * condition originated in. - * @param[in] always_set_to_false This parameter is always set to false and - * provided only for backward compatibility reasons. - * @param[in] code The fatal error code. This value must be interpreted with - * respect to the source. - */ -typedef void( *User_extensions_fatal_extension )( - Internal_errors_Source source, - bool always_set_to_false, - Internal_errors_t code -); - -/** - * @brief Task termination extension. - * - * This extension is invoked by _Thread_Life_action_handler() in case a - * termination request is recognized. - * - * It is invoked in the context of the terminated thread right before the - * thread dispatch to the heir thread. The POSIX cleanup and key destructors - * execute in this context. - * - * Thread dispatching is enabled. The thread is not the holder of the - * allocator mutex. The thread life is protected. Thread restart and delete - * requests issued by terminate extensions lead to recursion. - * - * @param[in] terminated The terminated thread. - */ -typedef void( *User_extensions_thread_terminate_extension )( - Thread_Control *terminated -); - -/** - * @brief User extension table. - */ -typedef struct { - User_extensions_thread_create_extension thread_create; - User_extensions_thread_start_extension thread_start; - User_extensions_thread_restart_extension thread_restart; - User_extensions_thread_delete_extension thread_delete; - User_extensions_thread_switch_extension thread_switch; - User_extensions_thread_begin_extension thread_begin; - User_extensions_thread_exitted_extension thread_exitted; - User_extensions_fatal_extension fatal; - User_extensions_thread_terminate_extension thread_terminate; -} User_extensions_Table; - -/** - * @brief Manages the switch callouts. - * - * They are managed separately from other extensions for performance reasons. - */ -typedef struct { - Chain_Node Node; - User_extensions_thread_switch_extension thread_switch; -} User_extensions_Switch_control; - -/** - * @brief Manages each user extension set. - * - * The switch control is part of the extensions control even if not used due to - * the extension not having a switch handler. - */ -typedef struct { - Chain_Node Node; - User_extensions_Switch_control Switch; - User_extensions_Table Callouts; -} User_extensions_Control; - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/userextimpl.h b/cpukit/score/include/rtems/score/userextimpl.h deleted file mode 100644 index 5ad2c63765..0000000000 --- a/cpukit/score/include/rtems/score/userextimpl.h +++ /dev/null @@ -1,369 +0,0 @@ -/** - * @file - * - * @ingroup ScoreUserExt - * - * @brief User Extension Handler API - */ - -/* - * COPYRIGHT (c) 1989-2009. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_USEREXTIMPL_H -#define _RTEMS_SCORE_USEREXTIMPL_H - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ScoreUserExt User Extension Handler - * - * @ingroup Score - * - * @addtogroup ScoreUserExt - */ -/**@{**/ - -/** - * @brief Chain iterator for dynamic user extensions. - * - * Since user extensions may delete or restart the executing thread, we must - * clean up registered iterators. - * - * @see _User_extensions_Iterate(), _User_extensions_Destroy_iterators() and - * Thread_Control::last_user_extensions_iterator. - */ -typedef struct User_extensions_Iterator { - Chain_Iterator Iterator; - struct User_extensions_Iterator *previous; -} User_extensions_Iterator; - -typedef struct { - /** - * @brief Active dynamically added user extensions. - */ - Chain_Control Active; - - /** - * @brief Chain iterator registration. - */ - Chain_Iterator_registry Iterators; - - /** - * @brief Lock to protect User_extensions_List::Active and - * User_extensions_List::Iterators. - */ - ISR_LOCK_MEMBER( Lock ) -} User_extensions_List; - -/** - * @brief List of active extensions. - */ -extern User_extensions_List _User_extensions_List; - -/** - * @brief List of active task switch extensions. - */ -extern Chain_Control _User_extensions_Switches_list; - -/** - * @name Extension Maintainance - */ -/**@{**/ - -void _User_extensions_Handler_initialization( void ); - -void _User_extensions_Add_set( - User_extensions_Control *extension -); - -RTEMS_INLINE_ROUTINE void _User_extensions_Add_API_set( - User_extensions_Control *extension -) -{ - _User_extensions_Add_set( extension ); -} - -RTEMS_INLINE_ROUTINE void _User_extensions_Add_set_with_table( - User_extensions_Control *extension, - const User_extensions_Table *extension_table -) -{ - extension->Callouts = *extension_table; - - _User_extensions_Add_set( extension ); -} - -void _User_extensions_Remove_set( - User_extensions_Control *extension -); - -/** - * @brief User extension visitor. - * - * @param[in, out] executing The currently executing thread. - * @param[in, out] arg The argument passed to _User_extensions_Iterate(). - * @param[in] callouts The current callouts. - */ -typedef void (*User_extensions_Visitor)( - Thread_Control *executing, - void *arg, - const User_extensions_Table *callouts -); - -typedef struct { - Thread_Control *created; - bool ok; -} User_extensions_Thread_create_context; - -void _User_extensions_Thread_create_visitor( - Thread_Control *executing, - void *arg, - const User_extensions_Table *callouts -); - -void _User_extensions_Thread_delete_visitor( - Thread_Control *executing, - void *arg, - const User_extensions_Table *callouts -); - -void _User_extensions_Thread_start_visitor( - Thread_Control *executing, - void *arg, - const User_extensions_Table *callouts -); - -void _User_extensions_Thread_restart_visitor( - Thread_Control *executing, - void *arg, - const User_extensions_Table *callouts -); - -void _User_extensions_Thread_begin_visitor( - Thread_Control *executing, - void *arg, - const User_extensions_Table *callouts -); - -void _User_extensions_Thread_exitted_visitor( - Thread_Control *executing, - void *arg, - const User_extensions_Table *callouts -); - -typedef struct { - Internal_errors_Source source; - Internal_errors_t error; -} User_extensions_Fatal_context; - -void _User_extensions_Fatal_visitor( - Thread_Control *executing, - void *arg, - const User_extensions_Table *callouts -); - -void _User_extensions_Thread_terminate_visitor( - Thread_Control *executing, - void *arg, - const User_extensions_Table *callouts -); - -/** - * @brief Iterates through all user extensions and calls the visitor for each. - * - * @param[in, out] arg The argument passed to the visitor. - * @param[in] visitor The visitor for each extension. - * @param[in] direction The iteration direction for dynamic extensions. - */ -void _User_extensions_Iterate( - void *arg, - User_extensions_Visitor visitor, - Chain_Iterator_direction direction -); - -/** @} */ - -/** - * @name Extension Callout Dispatcher - */ -/**@{**/ - -static inline bool _User_extensions_Thread_create( Thread_Control *created ) -{ - User_extensions_Thread_create_context ctx = { created, true }; - - _User_extensions_Iterate( - &ctx, - _User_extensions_Thread_create_visitor, - CHAIN_ITERATOR_FORWARD - ); - - return ctx.ok; -} - -static inline void _User_extensions_Thread_delete( Thread_Control *deleted ) -{ - _User_extensions_Iterate( - deleted, - _User_extensions_Thread_delete_visitor, - CHAIN_ITERATOR_BACKWARD - ); -} - -static inline void _User_extensions_Thread_start( Thread_Control *started ) -{ - _User_extensions_Iterate( - started, - _User_extensions_Thread_start_visitor, - CHAIN_ITERATOR_FORWARD - ); -} - -static inline void _User_extensions_Thread_restart( Thread_Control *restarted ) -{ - _User_extensions_Iterate( - restarted, - _User_extensions_Thread_restart_visitor, - CHAIN_ITERATOR_FORWARD - ); -} - -static inline void _User_extensions_Thread_begin( Thread_Control *executing ) -{ - _User_extensions_Iterate( - executing, - _User_extensions_Thread_begin_visitor, - CHAIN_ITERATOR_FORWARD - ); -} - -static inline void _User_extensions_Thread_switch( - Thread_Control *executing, - Thread_Control *heir -) -{ - const Chain_Control *chain = &_User_extensions_Switches_list; - const Chain_Node *tail = _Chain_Immutable_tail( chain ); - const Chain_Node *node = _Chain_Immutable_first( chain ); - - if ( node != tail ) { - Per_CPU_Control *cpu_self; -#if defined(RTEMS_SMP) - ISR_Level level; -#endif - - cpu_self = _Per_CPU_Get(); - -#if defined(RTEMS_SMP) - _ISR_Local_disable( level ); -#endif - _Per_CPU_Acquire( cpu_self ); - - while ( node != tail ) { - const User_extensions_Switch_control *extension = - (const User_extensions_Switch_control *) node; - - (*extension->thread_switch)( executing, heir ); - - node = _Chain_Immutable_next( node ); - } - - _Per_CPU_Release( cpu_self ); -#if defined(RTEMS_SMP) - _ISR_Local_enable( level ); -#endif - } -} - -static inline void _User_extensions_Thread_exitted( Thread_Control *executing ) -{ - _User_extensions_Iterate( - executing, - _User_extensions_Thread_exitted_visitor, - CHAIN_ITERATOR_FORWARD - ); -} - -static inline void _User_extensions_Fatal( - Internal_errors_Source source, - Internal_errors_t error -) -{ - User_extensions_Fatal_context ctx = { source, error }; - - _User_extensions_Iterate( - &ctx, - _User_extensions_Fatal_visitor, - CHAIN_ITERATOR_FORWARD - ); -} - -static inline void _User_extensions_Thread_terminate( - Thread_Control *executing -) -{ - _User_extensions_Iterate( - executing, - _User_extensions_Thread_terminate_visitor, - CHAIN_ITERATOR_BACKWARD - ); -} - -static inline void _User_extensions_Acquire( ISR_lock_Context *lock_context ) -{ - _ISR_lock_ISR_disable_and_acquire( - &_User_extensions_List.Lock, - lock_context - ); -} - -static inline void _User_extensions_Release( ISR_lock_Context *lock_context ) -{ - _ISR_lock_Release_and_ISR_enable( - &_User_extensions_List.Lock, - lock_context - ); -} - -static inline void _User_extensions_Destroy_iterators( - Thread_Control *the_thread -) -{ - ISR_lock_Context lock_context; - User_extensions_Iterator *iter; - - _User_extensions_Acquire( &lock_context ); - - iter = the_thread->last_user_extensions_iterator; - - while ( iter != NULL ) { - _Chain_Iterator_destroy( &iter->Iterator ); - iter = iter->previous; - } - - _User_extensions_Release( &lock_context ); -} - -/** @} */ - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/watchdog.h b/cpukit/score/include/rtems/score/watchdog.h deleted file mode 100644 index dbb092bbef..0000000000 --- a/cpukit/score/include/rtems/score/watchdog.h +++ /dev/null @@ -1,166 +0,0 @@ -/** - * @file rtems/score/watchdog.h - * - * @brief Constants and Structures Associated with Watchdog Timers - * - * This include file contains all the constants and structures associated - * with watchdog timers. This Handler provides mechanisms which can be - * used to initialize and manipulate watchdog timers. - */ - -/* - * COPYRIGHT (c) 1989-2009. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_WATCHDOG_H -#define _RTEMS_SCORE_WATCHDOG_H - -#include -#include -#include - -struct Per_CPU_Control; - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ScoreWatchdog Watchdog Handler - * - * @ingroup Score - * - * This handler encapsulates functionality related to the scheduling of - * watchdog functions to be called at specific times in the future. - * - * @note This handler does not have anything to do with hardware watchdog - * timers. - */ -/**@{*/ - -typedef struct Watchdog_Control Watchdog_Control; - -/** - * @brief Type is used to specify the length of intervals. - * - * This type is used to specify the length of intervals. - */ -typedef uint32_t Watchdog_Interval; - -/** - * @brief Special watchdog ticks value to indicate an infinite wait. - */ -#define WATCHDOG_NO_TIMEOUT 0 - -/** - * @brief Return type from a Watchdog Service Routine. - * - * This type defines the return type from a Watchdog Service Routine. - */ -typedef void Watchdog_Service_routine; - -/** - * @brief Pointer to a watchdog service routine. - * - * This type define a pointer to a watchdog service routine. - */ -typedef Watchdog_Service_routine - ( *Watchdog_Service_routine_entry )( Watchdog_Control * ); - -/** - * @brief The watchdog header to manage scheduled watchdogs. - */ -typedef struct { - /** - * @brief Red-black tree of scheduled watchdogs sorted by expiration time. - */ - RBTree_Control Watchdogs; - - /** - * @brief The scheduled watchdog with the earliest expiration time or NULL in - * case no watchdog is scheduled. - */ - RBTree_Node *first; -} Watchdog_Header; - -/** - * @brief The control block used to manage each watchdog timer. - * - * The following record defines the control block used - * to manage each watchdog timer. - */ -struct Watchdog_Control { - /** - * @brief Nodes for the watchdog. - */ - union { - /** - * @brief this field is a red-black tree node structure and allows this to - * be placed on a red-black tree used to manage the scheduled watchdogs. - */ - RBTree_Node RBTree; - - /** - * @brief this field is a chain node structure and allows this to be placed - * on a chain used to manage pending watchdogs by the timer server. - */ - Chain_Node Chain; - } Node; - -#if defined(RTEMS_SMP) - /** @brief This field references the processor of this watchdog control. */ - struct Per_CPU_Control *cpu; -#endif - - /** @brief This field is the function to invoke. */ - Watchdog_Service_routine_entry routine; - - /** @brief This field is the expiration time point. */ - uint64_t expire; -}; - -/** - * @brief The watchdog ticks counter. - * - * With a 1ms watchdog tick, this counter overflows after 50 days since boot. - */ -extern volatile Watchdog_Interval _Watchdog_Ticks_since_boot; - -/** - * @brief The watchdog nanoseconds per tick. - * - * This constant is defined by the application configuration via - * . - */ -extern const uint32_t _Watchdog_Nanoseconds_per_tick; - -/** - * @brief The watchdog ticks per second. - * - * This constant is defined by the application configuration via - * . - */ -extern const uint32_t _Watchdog_Ticks_per_second; - -/** - * @brief The maximum number of seconds representable in the monotonic watchdog - * format. - * - * This constant is defined by the application configuration via - * . - */ -extern const uint64_t _Watchdog_Monotonic_max_seconds; - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/watchdogimpl.h b/cpukit/score/include/rtems/score/watchdogimpl.h deleted file mode 100644 index f219a70768..0000000000 --- a/cpukit/score/include/rtems/score/watchdogimpl.h +++ /dev/null @@ -1,574 +0,0 @@ -/** - * @file - * - * @brief Inlined Routines in the Watchdog Handler - * - * This file contains the static inline implementation of all inlined - * routines in the Watchdog Handler. - */ - -/* - * COPYRIGHT (c) 1989-2004. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_WATCHDOGIMPL_H -#define _RTEMS_SCORE_WATCHDOGIMPL_H - -#include -#include -#include -#include -#include - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup ScoreWatchdog - * @{ - */ - -/** - * @brief Watchdog states. - */ -typedef enum { - /** - * @brief The watchdog is scheduled and a black node in the red-black tree. - */ - WATCHDOG_SCHEDULED_BLACK, - - /** - * @brief The watchdog is scheduled and a red node in the red-black tree. - */ - WATCHDOG_SCHEDULED_RED, - - /** - * @brief The watchdog is inactive. - */ - WATCHDOG_INACTIVE, - - /** - * @brief The watchdog is on a chain of pending watchdogs. - * - * This state is used by the timer server for example. - */ - WATCHDOG_PENDING -} Watchdog_State; - -/** - * @brief Watchdog initializer for static initialization. - * - * The processor of this watchdog is set to processor with index zero. - * - * @see _Watchdog_Preinitialize(). - */ -#if defined(RTEMS_SMP) - #define WATCHDOG_INITIALIZER( routine ) \ - { \ - { { { NULL, NULL, NULL, WATCHDOG_INACTIVE } } }, \ - &_Per_CPU_Information[ 0 ].per_cpu, \ - ( routine ), \ - 0 \ - } -#else - #define WATCHDOG_INITIALIZER( routine ) \ - { \ - { { { NULL, NULL, NULL, WATCHDOG_INACTIVE } } }, \ - ( routine ), \ - 0 \ - } -#endif - -RTEMS_INLINE_ROUTINE void _Watchdog_Header_initialize( - Watchdog_Header *header -) -{ - _RBTree_Initialize_empty( &header->Watchdogs ); - header->first = NULL; -} - -RTEMS_INLINE_ROUTINE void _Watchdog_Header_destroy( - Watchdog_Header *header -) -{ - /* Do nothing */ - (void) header; -} - -/** - * @brief Performs a watchdog tick. - * - * @param cpu The processor for this watchdog tick. - */ -void _Watchdog_Tick( struct Per_CPU_Control *cpu ); - -RTEMS_INLINE_ROUTINE Watchdog_State _Watchdog_Get_state( - const Watchdog_Control *the_watchdog -) -{ - return RB_COLOR( &the_watchdog->Node.RBTree, Node ); -} - -RTEMS_INLINE_ROUTINE void _Watchdog_Set_state( - Watchdog_Control *the_watchdog, - Watchdog_State state -) -{ - RB_COLOR( &the_watchdog->Node.RBTree, Node ) = state; -} - -RTEMS_INLINE_ROUTINE Per_CPU_Control *_Watchdog_Get_CPU( - const Watchdog_Control *the_watchdog -) -{ -#if defined(RTEMS_SMP) - return the_watchdog->cpu; -#else - return _Per_CPU_Get_by_index( 0 ); -#endif -} - -RTEMS_INLINE_ROUTINE void _Watchdog_Set_CPU( - Watchdog_Control *the_watchdog, - Per_CPU_Control *cpu -) -{ -#if defined(RTEMS_SMP) - the_watchdog->cpu = cpu; -#else - (void) cpu; -#endif -} - -/** - * @brief Pre-initializes a watchdog. - * - * This routine must be called before a watchdog is used in any way. The - * exception are statically initialized watchdogs via WATCHDOG_INITIALIZER(). - * - * @param[in] the_watchdog The uninitialized watchdog. - */ -RTEMS_INLINE_ROUTINE void _Watchdog_Preinitialize( - Watchdog_Control *the_watchdog, - Per_CPU_Control *cpu -) -{ - _Watchdog_Set_CPU( the_watchdog, cpu ); - _Watchdog_Set_state( the_watchdog, WATCHDOG_INACTIVE ); - -#if defined(RTEMS_DEBUG) - the_watchdog->routine = NULL; - the_watchdog->expire = 0; -#endif -} - -/** - * @brief Initializes a watchdog with a new service routine. - * - * The watchdog must be inactive. - */ -RTEMS_INLINE_ROUTINE void _Watchdog_Initialize( - Watchdog_Control *the_watchdog, - Watchdog_Service_routine_entry routine -) -{ - _Assert( _Watchdog_Get_state( the_watchdog ) == WATCHDOG_INACTIVE ); - the_watchdog->routine = routine; -} - -void _Watchdog_Do_tickle( - Watchdog_Header *header, - uint64_t now, -#if defined(RTEMS_SMP) - ISR_lock_Control *lock, -#endif - ISR_lock_Context *lock_context -); - -#if defined(RTEMS_SMP) - #define _Watchdog_Tickle( header, now, lock, lock_context ) \ - _Watchdog_Do_tickle( header, now, lock, lock_context ) -#else - #define _Watchdog_Tickle( header, now, lock, lock_context ) \ - _Watchdog_Do_tickle( header, now, lock_context ) -#endif - -/** - * @brief Inserts a watchdog into the set of scheduled watchdogs according to - * the specified expiration time. - * - * The watchdog must be inactive. - */ -void _Watchdog_Insert( - Watchdog_Header *header, - Watchdog_Control *the_watchdog, - uint64_t expire -); - -/** - * @brief In case the watchdog is scheduled, then it is removed from the set of - * scheduled watchdogs. - * - * The watchdog must be initialized before this call. - */ -void _Watchdog_Remove( - Watchdog_Header *header, - Watchdog_Control *the_watchdog -); - -/** - * @brief In case the watchdog is scheduled, then it is removed from the set of - * scheduled watchdogs. - * - * The watchdog must be initialized before this call. - * - * @retval 0 The now time is greater than or equal to the expiration time of - * the watchdog. - * @retval other The difference of the now and expiration time. - */ -RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Cancel( - Watchdog_Header *header, - Watchdog_Control *the_watchdog, - uint64_t now -) -{ - uint64_t expire; - uint64_t remaining; - - expire = the_watchdog->expire; - - if ( now < expire ) { - remaining = expire - now; - } else { - remaining = 0; - } - - _Watchdog_Remove( header, the_watchdog ); - - return remaining; -} - -RTEMS_INLINE_ROUTINE bool _Watchdog_Is_scheduled( - const Watchdog_Control *the_watchdog -) -{ - return _Watchdog_Get_state( the_watchdog ) < WATCHDOG_INACTIVE; -} - -RTEMS_INLINE_ROUTINE void _Watchdog_Next_first( - Watchdog_Header *header, - Watchdog_Control *the_watchdog -) -{ - RBTree_Node *node = _RBTree_Right( &the_watchdog->Node.RBTree ); - - if ( node != NULL ) { - RBTree_Node *left; - - while ( ( left = _RBTree_Left( node ) ) != NULL ) { - node = left; - } - - header->first = node; - } else { - header->first = _RBTree_Parent( &the_watchdog->Node.RBTree ); - } -} - -/** - * @brief The maximum watchdog ticks value for the far future. - */ -#define WATCHDOG_MAXIMUM_TICKS UINT64_MAX - -#define WATCHDOG_NANOSECONDS_PER_SECOND 1000000000 - -/** - * @brief The bits necessary to store 1000000000 - * (= WATCHDOG_NANOSECONDS_PER_SECOND) nanoseconds. - * - * The expiration time is an unsigned 64-bit integer. To store absolute - * timeouts we use 30 bits (2**30 == 1073741824) for the nanoseconds and 34 - * bits for the seconds since UNIX Epoch. This leads to a year 2514 problem. - */ -#define WATCHDOG_BITS_FOR_1E9_NANOSECONDS 30 - -/** - * @brief The maximum number of seconds representable in the realtime watchdog - * format. - * - * We have 2**34 bits for the seconds part. - */ -#define WATCHDOG_REALTIME_MAX_SECONDS 0x3ffffffff - -RTEMS_INLINE_ROUTINE bool _Watchdog_Is_valid_timespec( - const struct timespec *ts -) -{ - return ts != NULL - && (unsigned long) ts->tv_nsec < WATCHDOG_NANOSECONDS_PER_SECOND; -} - -RTEMS_INLINE_ROUTINE bool _Watchdog_Is_valid_interval_timespec( - const struct timespec *ts -) -{ - return _Watchdog_Is_valid_timespec( ts ) && ts->tv_sec >= 0; -} - -RTEMS_INLINE_ROUTINE const struct timespec * _Watchdog_Future_timespec( - struct timespec *now, - const struct timespec *delta -) -{ - uint64_t sec; - - if ( !_Watchdog_Is_valid_interval_timespec( delta ) ) { - return NULL; - } - - sec = (uint64_t) now->tv_sec; - sec += (uint64_t) delta->tv_sec; - now->tv_nsec += delta->tv_nsec; - - /* We have 2 * (2**63 - 1) + 1 == UINT64_MAX */ - if ( now->tv_nsec >= WATCHDOG_NANOSECONDS_PER_SECOND ) { - now->tv_nsec -= WATCHDOG_NANOSECONDS_PER_SECOND; - ++sec; - } - - if ( sec <= INT64_MAX ) { - now->tv_sec = sec; - } else { - now->tv_sec = INT64_MAX; - } - - return now; -} - -RTEMS_INLINE_ROUTINE bool _Watchdog_Is_far_future_monotonic_timespec( - const struct timespec *ts -) -{ - return ts->tv_sec >= _Watchdog_Monotonic_max_seconds; -} - -RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Monotonic_from_timespec( - const struct timespec *ts -) -{ - uint64_t ticks; - - _Assert( _Watchdog_Is_valid_timespec( ts ) ); - _Assert( ts->tv_sec >= 0 ); - _Assert( !_Watchdog_Is_far_future_monotonic_timespec( ts ) ); - - ticks = (uint64_t) ts->tv_sec * _Watchdog_Ticks_per_second; - ticks += (unsigned long) ts->tv_nsec / _Watchdog_Nanoseconds_per_tick; - - return ticks; -} - -RTEMS_INLINE_ROUTINE bool _Watchdog_Is_far_future_realtime_timespec( - const struct timespec *ts -) -{ - return ts->tv_sec > WATCHDOG_REALTIME_MAX_SECONDS; -} - -RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Realtime_from_seconds( - uint32_t seconds -) -{ - uint64_t ticks = seconds; - - ticks <<= WATCHDOG_BITS_FOR_1E9_NANOSECONDS; - - return ticks; -} - -RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Realtime_from_timespec( - const struct timespec *ts -) -{ - uint64_t ticks; - - _Assert( _Watchdog_Is_valid_timespec( ts ) ); - _Assert( ts->tv_sec >= 0 ); - _Assert( !_Watchdog_Is_far_future_realtime_timespec( ts ) ); - - ticks = (uint64_t) ts->tv_sec; - ticks <<= WATCHDOG_BITS_FOR_1E9_NANOSECONDS; - ticks |= (uint32_t) ts->tv_nsec; - - return ticks; -} - -RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Realtime_from_sbintime( - sbintime_t sbt -) -{ - uint64_t ticks = ( sbt >> 32 ) << WATCHDOG_BITS_FOR_1E9_NANOSECONDS; - - ticks |= ( (uint64_t) 1000000000 * (uint32_t) sbt ) >> 32; - - return ticks; -} - -RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_acquire_critical( - Per_CPU_Control *cpu, - ISR_lock_Context *lock_context -) -{ - _ISR_lock_Acquire( &cpu->Watchdog.Lock, lock_context ); -} - -RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_release_critical( - Per_CPU_Control *cpu, - ISR_lock_Context *lock_context -) -{ - _ISR_lock_Release( &cpu->Watchdog.Lock, lock_context ); -} - -RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Per_CPU_insert_ticks( - Watchdog_Control *the_watchdog, - Per_CPU_Control *cpu, - Watchdog_Interval ticks -) -{ - ISR_lock_Context lock_context; - Watchdog_Header *header; - uint64_t expire; - - header = &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_MONOTONIC ]; - - _Watchdog_Set_CPU( the_watchdog, cpu ); - - _Watchdog_Per_CPU_acquire_critical( cpu, &lock_context ); - expire = ticks + cpu->Watchdog.ticks; - _Watchdog_Insert(header, the_watchdog, expire); - _Watchdog_Per_CPU_release_critical( cpu, &lock_context ); - return expire; -} - -RTEMS_INLINE_ROUTINE bool _Watchdog_Per_CPU_lazy_insert_monotonic( - Watchdog_Control *the_watchdog, - Per_CPU_Control *cpu, - uint64_t expire -) -{ - ISR_lock_Context lock_context; - Watchdog_Header *header; - bool insert; - - header = &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_MONOTONIC ]; - - _Watchdog_Set_CPU( the_watchdog, cpu ); - - _Watchdog_Per_CPU_acquire_critical( cpu, &lock_context ); - insert = ( expire > cpu->Watchdog.ticks ); - - if ( insert ) { - _Watchdog_Insert(header, the_watchdog, expire); - } - - _Watchdog_Per_CPU_release_critical( cpu, &lock_context ); - return insert; -} - -RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Per_CPU_insert_realtime( - Watchdog_Control *the_watchdog, - Per_CPU_Control *cpu, - uint64_t expire -) -{ - ISR_lock_Context lock_context; - Watchdog_Header *header; - - header = &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_REALTIME ]; - - _Watchdog_Set_CPU( the_watchdog, cpu ); - - _Watchdog_Per_CPU_acquire_critical( cpu, &lock_context ); - _Watchdog_Insert(header, the_watchdog, expire); - _Watchdog_Per_CPU_release_critical( cpu, &lock_context ); - return expire; -} - -RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_remove( - Watchdog_Control *the_watchdog, - Per_CPU_Control *cpu, - Watchdog_Header *header -) -{ - ISR_lock_Context lock_context; - - _Watchdog_Per_CPU_acquire_critical( cpu, &lock_context ); - _Watchdog_Remove( - header, - the_watchdog - ); - _Watchdog_Per_CPU_release_critical( cpu, &lock_context ); -} - -RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_remove_monotonic( - Watchdog_Control *the_watchdog -) -{ - Per_CPU_Control *cpu; - - cpu = _Watchdog_Get_CPU( the_watchdog ); - _Watchdog_Per_CPU_remove( - the_watchdog, - cpu, - &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_MONOTONIC ] - ); -} - -RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_remove_realtime( - Watchdog_Control *the_watchdog -) -{ - Per_CPU_Control *cpu; - - cpu = _Watchdog_Get_CPU( the_watchdog ); - _Watchdog_Per_CPU_remove( - the_watchdog, - cpu, - &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_REALTIME ] - ); -} - -RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_tickle_realtime( - Per_CPU_Control *cpu, - uint64_t now -) -{ - ISR_lock_Context lock_context; - - _ISR_lock_ISR_disable_and_acquire( &cpu->Watchdog.Lock, &lock_context ); - _Watchdog_Tickle( - &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_REALTIME ], - now, - &cpu->Watchdog.Lock, - &lock_context - ); -} - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/score/wkspace.h b/cpukit/score/include/rtems/score/wkspace.h deleted file mode 100644 index 3676ff28c4..0000000000 --- a/cpukit/score/include/rtems/score/wkspace.h +++ /dev/null @@ -1,138 +0,0 @@ -/** - * @file rtems/score/wkspace.h - * - * @brief Information Related to the RAM Workspace - * - * This include file contains information related to the - * RAM Workspace. This Handler provides mechanisms which can be used to - * define, initialize and manipulate the workspace. - */ - -/* - * COPYRIGHT (c) 1989-2009. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SCORE_WKSPACE_H -#define _RTEMS_SCORE_WKSPACE_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup ScoreWorkspace Workspace Handler - * - * @ingroup Score - * - * This handler encapsulates functionality related to the management of - * the RTEMS Executive Workspace. - */ -/**@{*/ - -/** - * @brief Executive workspace control. - * - * This is the heap control structure used to manage the RTEMS Executive - * Workspace. - */ -extern Heap_Control _Workspace_Area; - -/** - * @brief Initilize workspace handler. - * - * This routine performs the initialization necessary for this handler. - */ -void _Workspace_Handler_initialization( - Heap_Area *areas, - size_t area_count, - Heap_Initialization_or_extend_handler extend -); - -/** - * @brief Allocate memory from workspace. - * - * This routine returns the address of a block of memory of size - * bytes. If a block of the appropriate size cannot be allocated - * from the workspace, then NULL is returned. - * - * @param size is the requested size - * - * @retval a pointer to the requested memory or NULL. - */ -void *_Workspace_Allocate( - size_t size -); - -/** - * @brief Allocate aligned memory from workspace. - * - * @param[in] size The size of the requested memory. - * @param[in] alignment The alignment of the requested memory. - * - * @retval NULL Not enough resources. - * @retval other The memory area begin. - */ -void *_Workspace_Allocate_aligned( size_t size, size_t alignment ); - -/** - * @brief Free memory to the workspace. - * - * This function frees the specified block of memory. If the block - * belongs to the Workspace and can be successfully freed, then - * true is returned. Otherwise false is returned. - * - * @param block is the memory to free - * - * @note If @a block is equal to NULL, then the request is ignored. - * This allows the caller to not worry about whether or not - * a pointer is NULL. - */ - -void _Workspace_Free( - void *block -); - -/** - * @brief Workspace allocate or fail with fatal error. - * - * This routine returns the address of a block of memory of @a size - * bytes. If a block of the appropriate size cannot be allocated - * from the workspace, then the internal error handler is invoked. - * - * @param[in] size is the desired number of bytes to allocate - * @retval If successful, the starting address of the allocated memory - */ -void *_Workspace_Allocate_or_fatal_error( - size_t size -); - -/** - * @brief Duplicates string with memory from the workspace. - * - * @param[in] string is the pointer to a zero terminated string. - * @param[in] len is the length of the string (equal to strlen(string)). - * - * @retval NULL Not enough memory. - * @retval other Duplicated string. - */ -char *_Workspace_String_duplicate( - const char *string, - size_t len -); - -/**@}*/ - -#ifdef __cplusplus -} -#endif - -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/seterr.h b/cpukit/score/include/rtems/seterr.h deleted file mode 100644 index 22fddc824e..0000000000 --- a/cpukit/score/include/rtems/seterr.h +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @file rtems/seterr.h - * - * @brief Data which Ease the Burden of Consistently Setting Errno - * - * This file contains macros and definitions which ease the burden - * of consistently setting errno and returning -1. - */ - -/* - * COPYRIGHT (c) 1989-2006. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SETERR_H -#define _RTEMS_SETERR_H - -/** - * @defgroup ScoreSetErr Set Errno - * - * @ingroup Score - * - */ -/**@{*/ - -#include - -/** - * This is a helper macro which will set the variable errno and return - * the specified value to the caller. - * - * @param[in] _error is the error code - * @param[in] _value is the value to return - */ -#define rtems_set_errno_and_return_value( _error, _value ) \ - do { errno = ( _error ); return ( _value ); } while ( 0 ) - -/** - * This is a helper macro which will set the variable errno and return - * -1 to the caller. This pattern is common to many POSIX methods. - * - * @param[in] _error is the error code - */ -#define rtems_set_errno_and_return_minus_one( _error ) \ - rtems_set_errno_and_return_value( _error, -1 ) - -/**@}*/ -#endif -/* end of include file */ diff --git a/cpukit/score/include/rtems/sysinit.h b/cpukit/score/include/rtems/sysinit.h deleted file mode 100644 index 535fb98e2c..0000000000 --- a/cpukit/score/include/rtems/sysinit.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2015 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SYSINIT_H -#define _RTEMS_SYSINIT_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * The value of each module define must consist of exactly six hexadecimal - * digits without a 0x-prefix. A 0x-prefix is concatenated with the module and - * order values to form a proper integer literal. - */ -#define RTEMS_SYSINIT_BSP_WORK_AREAS 000100 -#define RTEMS_SYSINIT_BSP_START 000200 -#define RTEMS_SYSINIT_INITIAL_EXTENSIONS 000300 -#define RTEMS_SYSINIT_MP_EARLY 000301 -#define RTEMS_SYSINIT_DATA_STRUCTURES 000302 -#define RTEMS_SYSINIT_MP 00030e -#define RTEMS_SYSINIT_USER_EXTENSIONS 000320 -#define RTEMS_SYSINIT_CLASSIC_TASKS 000340 -#define RTEMS_SYSINIT_CLASSIC_TIMER 000341 -#define RTEMS_SYSINIT_CLASSIC_SIGNAL 000342 -#define RTEMS_SYSINIT_CLASSIC_EVENT 000343 -#define RTEMS_SYSINIT_CLASSIC_MESSAGE_QUEUE 000344 -#define RTEMS_SYSINIT_CLASSIC_SEMAPHORE 000345 -#define RTEMS_SYSINIT_CLASSIC_PARTITION 000346 -#define RTEMS_SYSINIT_CLASSIC_REGION 000347 -#define RTEMS_SYSINIT_CLASSIC_DUAL_PORTED_MEMORY 000348 -#define RTEMS_SYSINIT_CLASSIC_RATE_MONOTONIC 000349 -#define RTEMS_SYSINIT_CLASSIC_BARRIER 00034a -#define RTEMS_SYSINIT_POSIX_SIGNALS 000360 -#define RTEMS_SYSINIT_POSIX_THREADS 000361 -#define RTEMS_SYSINIT_POSIX_MESSAGE_QUEUE 000364 -#define RTEMS_SYSINIT_POSIX_SEMAPHORE 000365 -#define RTEMS_SYSINIT_POSIX_TIMER 000366 -#define RTEMS_SYSINIT_POSIX_SHM 000369 -#define RTEMS_SYSINIT_POSIX_KEYS 00036a -#define RTEMS_SYSINIT_POSIX_CLEANUP 00036b -#define RTEMS_SYSINIT_IDLE_THREADS 000380 -#define RTEMS_SYSINIT_LIBIO 000400 -#define RTEMS_SYSINIT_ROOT_FILESYSTEM 000401 -#define RTEMS_SYSINIT_DRVMGR 000500 -#define RTEMS_SYSINIT_MP_SERVER 000501 -#define RTEMS_SYSINIT_BSP_PRE_DRIVERS 000600 -#define RTEMS_SYSINIT_DRVMGR_LEVEL_1 000700 -#define RTEMS_SYSINIT_DEVICE_DRIVERS 000701 -#define RTEMS_SYSINIT_DRVMGR_LEVEL_2 000702 -#define RTEMS_SYSINIT_DRVMGR_LEVEL_3 000703 -#define RTEMS_SYSINIT_DRVMGR_LEVEL_4 000704 -#define RTEMS_SYSINIT_MP_FINALIZE 000705 -#define RTEMS_SYSINIT_CLASSIC_USER_TASKS 000706 -#define RTEMS_SYSINIT_POSIX_USER_THREADS 000707 -#define RTEMS_SYSINIT_STD_FILE_DESCRIPTORS 000800 -#define RTEMS_SYSINIT_LAST ffffff - -/* - * The value of each order define must consist of exactly two hexadecimal - * digits without a 0x-prefix. A 0x-prefix is concatenated with the module and - * order values to form a proper integer literal. - */ -#define RTEMS_SYSINIT_ORDER_FIRST 00 -#define RTEMS_SYSINIT_ORDER_SECOND 01 -#define RTEMS_SYSINIT_ORDER_THIRD 02 -#define RTEMS_SYSINIT_ORDER_FOURTH 03 -#define RTEMS_SYSINIT_ORDER_FIFTH 04 -#define RTEMS_SYSINIT_ORDER_SIXTH 05 -#define RTEMS_SYSINIT_ORDER_SEVENTH 06 -#define RTEMS_SYSINIT_ORDER_EIGHTH 07 -#define RTEMS_SYSINIT_ORDER_NINETH 08 -#define RTEMS_SYSINIT_ORDER_TENTH 09 -#define RTEMS_SYSINIT_ORDER_MIDDLE 80 -#define RTEMS_SYSINIT_ORDER_LAST ff - -typedef void ( *rtems_sysinit_handler )( void ); - -typedef struct { - rtems_sysinit_handler handler; -} rtems_sysinit_item; - -/* The enum helps to detect typos in the module and order parameters */ -#define _RTEMS_SYSINIT_INDEX_ITEM( handler, index ) \ - enum { _Sysinit_##handler = index }; \ - RTEMS_LINKER_ROSET_ITEM_ORDERED( \ - _Sysinit, \ - rtems_sysinit_item, \ - handler, \ - index \ - ) = { handler } - -/* Create index from module and order */ -#define _RTEMS_SYSINIT_ITEM( handler, module, order ) \ - _RTEMS_SYSINIT_INDEX_ITEM( handler, 0x##module##order ) - -/* Perform parameter expansion */ -#define RTEMS_SYSINIT_ITEM( handler, module, order ) \ - _RTEMS_SYSINIT_ITEM( handler, module, order ) - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _RTEMS_SYSINIT_H */ diff --git a/cpukit/score/include/rtems/system.h b/cpukit/score/include/rtems/system.h deleted file mode 100644 index 26156c64f7..0000000000 --- a/cpukit/score/include/rtems/system.h +++ /dev/null @@ -1,66 +0,0 @@ -/** - * @file - * - * @brief Information Included in Every Function in the Executive - * - * This include file contains information that is included in every - * function in the executive. This must be the first include file - * included in all internal RTEMS files. - */ - -/* - * COPYRIGHT (c) 1989-2007. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_SYSTEM_H -#define _RTEMS_SYSTEM_H - -#include - -/** - * @defgroup ScoreSystem System Information - * - * @ingroup Score - */ -/**@{*/ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef ASM - -#ifdef RTEMS_POSIX_API -/** The following is used by the POSIX implementation to catch bad paths. */ -int POSIX_NOT_IMPLEMENTED( void ); -#endif - -/** - * The following is the extern for the RTEMS version string. - * - * @note The contents of this string are CPU specific. - */ -extern const char _RTEMS_version[]; - -/** - * The following is the extern for the RTEMS copyright string. - */ -extern const char _Copyright_Notice[]; - -/** This macro defines the maximum length of a Classic API name. */ -#define RTEMS_MAXIMUM_NAME_LENGTH sizeof(rtems_name) - -#endif /* ASM */ - -#ifdef __cplusplus -} -#endif - -/**@}*/ -#endif -/* end of include file */ diff --git a/cpukit/score/include/sys/_ffcounter.h b/cpukit/score/include/sys/_ffcounter.h deleted file mode 100644 index d83c48cd44..0000000000 --- a/cpukit/score/include/sys/_ffcounter.h +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * Copyright (c) 2011 The University of Melbourne - * All rights reserved. - * - * This software was developed by Julien Ridoux at the University of Melbourne - * under sponsorship from the FreeBSD Foundation. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD r277406 2015-01-20T03:54:30Z$ - */ - -#ifndef _SYS__FFCOUNTER_H_ -#define _SYS__FFCOUNTER_H_ - -/* - * The feed-forward clock counter. The fundamental element of a feed-forward - * clock is a wide monotonically increasing counter that accumulates at the same - * rate as the selected timecounter. - */ -typedef uint64_t ffcounter; - -#endif /* _SYS__FFCOUNTER_H_ */ diff --git a/cpukit/score/include/sys/timeffc.h b/cpukit/score/include/sys/timeffc.h deleted file mode 100644 index c04de97f1d..0000000000 --- a/cpukit/score/include/sys/timeffc.h +++ /dev/null @@ -1,391 +0,0 @@ -/*- - * Copyright (c) 2011 The University of Melbourne - * All rights reserved. - * - * This software was developed by Julien Ridoux at the University of Melbourne - * under sponsorship from the FreeBSD Foundation. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: head/sys/sys/timeffc.h 228856 2011-12-24 01:32:01Z lstewart $ - */ - -#ifndef _SYS_TIMEFF_H_ -#define _SYS_TIMEFF_H_ - -#include - -/* - * Feed-forward clock estimate - * Holds time mark as a ffcounter and conversion to bintime based on current - * timecounter period and offset estimate passed by the synchronization daemon. - * Provides time of last daemon update, clock status and bound on error. - */ -struct ffclock_estimate { - struct bintime update_time; /* Time of last estimates update. */ - ffcounter update_ffcount; /* Counter value at last update. */ - ffcounter leapsec_next; /* Counter value of next leap second. */ - uint64_t period; /* Estimate of counter period. */ - uint32_t errb_abs; /* Bound on absolute clock error [ns]. */ - uint32_t errb_rate; /* Bound on counter rate error [ps/s]. */ - uint32_t status; /* Clock status. */ - int16_t leapsec_total; /* All leap seconds seen so far. */ - int8_t leapsec; /* Next leap second (in {-1,0,1}). */ -}; - -#if __BSD_VISIBLE -#ifdef _KERNEL - -#ifndef __rtems__ -/* Define the kern.sysclock sysctl tree. */ -SYSCTL_DECL(_kern_sysclock); - -/* Define the kern.sysclock.ffclock sysctl tree. */ -SYSCTL_DECL(_kern_sysclock_ffclock); -#endif /* __rtems__ */ - -/* - * Index into the sysclocks array for obtaining the ASCII name of a particular - * sysclock. - */ -#define SYSCLOCK_FBCK 0 -#define SYSCLOCK_FFWD 1 -extern int sysclock_active; - -/* - * Parameters of counter characterisation required by feed-forward algorithms. - */ -#define FFCLOCK_SKM_SCALE 1024 - -/* - * Feed-forward clock status - */ -#define FFCLOCK_STA_UNSYNC 1 -#define FFCLOCK_STA_WARMUP 2 - -/* - * Flags for use by sysclock_snap2bintime() and various ffclock_ functions to - * control how the timecounter hardware is read and how the hardware snapshot is - * converted into absolute time. - * {FB|FF}CLOCK_FAST: Do not read the hardware counter, instead using the - * value at last tick. The time returned has a resolution - * of the kernel tick timer (1/hz [s]). - * FFCLOCK_LERP: Linear interpolation of ffclock time to guarantee - * monotonic time. - * FFCLOCK_LEAPSEC: Include leap seconds. - * {FB|FF}CLOCK_UPTIME: Time stamp should be relative to system boot, not epoch. - */ -#define FFCLOCK_FAST 0x00000001 -#define FFCLOCK_LERP 0x00000002 -#define FFCLOCK_LEAPSEC 0x00000004 -#define FFCLOCK_UPTIME 0x00000008 -#define FFCLOCK_MASK 0x0000ffff - -#define FBCLOCK_FAST 0x00010000 /* Currently unused. */ -#define FBCLOCK_UPTIME 0x00020000 -#define FBCLOCK_MASK 0xffff0000 - -/* - * Feedback clock specific info structure. The feedback clock's estimation of - * clock error is an absolute figure determined by the NTP algorithm. The status - * is determined by the userland daemon. - */ -struct fbclock_info { - struct bintime error; - struct bintime tick_time; - uint64_t th_scale; - int status; -}; - -/* - * Feed-forward clock specific info structure. The feed-forward clock's - * estimation of clock error is an upper bound, which although potentially - * looser than the feedback clock equivalent, is much more reliable. The status - * is determined by the userland daemon. - */ -struct ffclock_info { - struct bintime error; - struct bintime tick_time; - struct bintime tick_time_lerp; - uint64_t period; - uint64_t period_lerp; - int leapsec_adjustment; - int status; -}; - -/* - * Snapshot of system clocks and related information. Holds time read from each - * clock based on a single read of the active hardware timecounter, as well as - * respective clock information such as error estimates and the ffcounter value - * at the time of the read. - */ -struct sysclock_snap { - struct fbclock_info fb_info; - struct ffclock_info ff_info; - ffcounter ffcount; - unsigned int delta; - int sysclock_active; -}; - -/* Take a snapshot of the system clocks and related information. */ -void sysclock_getsnapshot(struct sysclock_snap *clock_snap, int fast); - -/* Convert a timestamp from the selected system clock into bintime. */ -int sysclock_snap2bintime(struct sysclock_snap *cs, struct bintime *bt, - int whichclock, uint32_t flags); - -/* Resets feed-forward clock from RTC */ -void ffclock_reset_clock(struct timespec *ts); - -/* - * Return the current value of the feed-forward clock counter. Essential to - * measure time interval in counter units. If a fast timecounter is used by the - * system, may also allow fast but accurate timestamping. - */ -void ffclock_read_counter(ffcounter *ffcount); - -/* - * Retrieve feed-forward counter value and time of last kernel tick. This - * accepts the FFCLOCK_LERP flag. - */ -void ffclock_last_tick(ffcounter *ffcount, struct bintime *bt, uint32_t flags); - -/* - * Low level routines to convert a counter timestamp into absolute time and a - * counter timestamp interval into an interval in seconds. The absolute time - * conversion accepts the FFCLOCK_LERP flag. - */ -void ffclock_convert_abs(ffcounter ffcount, struct bintime *bt, uint32_t flags); -void ffclock_convert_diff(ffcounter ffdelta, struct bintime *bt); - -/* - * Feed-forward clock routines. - * - * These functions rely on the timecounters and ffclock_estimates stored in - * fftimehands. Note that the error_bound parameter is not the error of the - * clock but an upper bound on the error of the absolute time or time interval - * returned. - * - * ffclock_abstime(): retrieves current time as counter value and convert this - * timestamp in seconds. The value (in seconds) of the converted timestamp - * depends on the flags passed: for a given counter value, different - * conversions are possible. Different clock models can be selected by - * combining flags (for example (FFCLOCK_LERP|FFCLOCK_UPTIME) produces - * linearly interpolated uptime). - * ffclock_difftime(): computes a time interval in seconds based on an interval - * measured in ffcounter units. This should be the preferred way to measure - * small time intervals very accurately. - */ -void ffclock_abstime(ffcounter *ffcount, struct bintime *bt, - struct bintime *error_bound, uint32_t flags); -void ffclock_difftime(ffcounter ffdelta, struct bintime *bt, - struct bintime *error_bound); - -/* - * Wrapper routines to return current absolute time using the feed-forward - * clock. These functions are named after those defined in , which - * contains a description of the original ones. - */ -void ffclock_bintime(struct bintime *bt); -void ffclock_nanotime(struct timespec *tsp); -void ffclock_microtime(struct timeval *tvp); - -void ffclock_getbintime(struct bintime *bt); -void ffclock_getnanotime(struct timespec *tsp); -void ffclock_getmicrotime(struct timeval *tvp); - -void ffclock_binuptime(struct bintime *bt); -void ffclock_nanouptime(struct timespec *tsp); -void ffclock_microuptime(struct timeval *tvp); - -void ffclock_getbinuptime(struct bintime *bt); -void ffclock_getnanouptime(struct timespec *tsp); -void ffclock_getmicrouptime(struct timeval *tvp); - -/* - * Wrapper routines to convert a time interval specified in ffcounter units into - * seconds using the current feed-forward clock estimates. - */ -void ffclock_bindifftime(ffcounter ffdelta, struct bintime *bt); -void ffclock_nanodifftime(ffcounter ffdelta, struct timespec *tsp); -void ffclock_microdifftime(ffcounter ffdelta, struct timeval *tvp); - -/* - * When FFCLOCK is enabled in the kernel, [get]{bin,nano,micro}[up]time() become - * wrappers around equivalent feedback or feed-forward functions. Provide access - * outside of kern_tc.c to the feedback clock equivalent functions for - * specialised use i.e. these are not for general consumption. - */ -void fbclock_bintime(struct bintime *bt); -void fbclock_nanotime(struct timespec *tsp); -void fbclock_microtime(struct timeval *tvp); - -void fbclock_getbintime(struct bintime *bt); -void fbclock_getnanotime(struct timespec *tsp); -void fbclock_getmicrotime(struct timeval *tvp); - -void fbclock_binuptime(struct bintime *bt); -void fbclock_nanouptime(struct timespec *tsp); -void fbclock_microuptime(struct timeval *tvp); - -void fbclock_getbinuptime(struct bintime *bt); -void fbclock_getnanouptime(struct timespec *tsp); -void fbclock_getmicrouptime(struct timeval *tvp); - -/* - * Public system clock wrapper API which allows consumers to select which clock - * to obtain time from, independent of the current default system clock. These - * wrappers should be used instead of directly calling the underlying fbclock_ - * or ffclock_ functions. - */ -static inline void -bintime_fromclock(struct bintime *bt, int whichclock) -{ - - if (whichclock == SYSCLOCK_FFWD) - ffclock_bintime(bt); - else - fbclock_bintime(bt); -} - -static inline void -nanotime_fromclock(struct timespec *tsp, int whichclock) -{ - - if (whichclock == SYSCLOCK_FFWD) - ffclock_nanotime(tsp); - else - fbclock_nanotime(tsp); -} - -static inline void -microtime_fromclock(struct timeval *tvp, int whichclock) -{ - - if (whichclock == SYSCLOCK_FFWD) - ffclock_microtime(tvp); - else - fbclock_microtime(tvp); -} - -static inline void -getbintime_fromclock(struct bintime *bt, int whichclock) -{ - - if (whichclock == SYSCLOCK_FFWD) - ffclock_getbintime(bt); - else - fbclock_getbintime(bt); -} - -static inline void -getnanotime_fromclock(struct timespec *tsp, int whichclock) -{ - - if (whichclock == SYSCLOCK_FFWD) - ffclock_getnanotime(tsp); - else - fbclock_getnanotime(tsp); -} - -static inline void -getmicrotime_fromclock(struct timeval *tvp, int whichclock) -{ - - if (whichclock == SYSCLOCK_FFWD) - ffclock_getmicrotime(tvp); - else - fbclock_getmicrotime(tvp); -} - -static inline void -binuptime_fromclock(struct bintime *bt, int whichclock) -{ - - if (whichclock == SYSCLOCK_FFWD) - ffclock_binuptime(bt); - else - fbclock_binuptime(bt); -} - -static inline void -nanouptime_fromclock(struct timespec *tsp, int whichclock) -{ - - if (whichclock == SYSCLOCK_FFWD) - ffclock_nanouptime(tsp); - else - fbclock_nanouptime(tsp); -} - -static inline void -microuptime_fromclock(struct timeval *tvp, int whichclock) -{ - - if (whichclock == SYSCLOCK_FFWD) - ffclock_microuptime(tvp); - else - fbclock_microuptime(tvp); -} - -static inline void -getbinuptime_fromclock(struct bintime *bt, int whichclock) -{ - - if (whichclock == SYSCLOCK_FFWD) - ffclock_getbinuptime(bt); - else - fbclock_getbinuptime(bt); -} - -static inline void -getnanouptime_fromclock(struct timespec *tsp, int whichclock) -{ - - if (whichclock == SYSCLOCK_FFWD) - ffclock_getnanouptime(tsp); - else - fbclock_getnanouptime(tsp); -} - -static inline void -getmicrouptime_fromclock(struct timeval *tvp, int whichclock) -{ - - if (whichclock == SYSCLOCK_FFWD) - ffclock_getmicrouptime(tvp); - else - fbclock_getmicrouptime(tvp); -} - -#else /* !_KERNEL */ - -/* Feed-Forward Clock system calls. */ -__BEGIN_DECLS -int ffclock_getcounter(ffcounter *ffcount); -int ffclock_getestimate(struct ffclock_estimate *cest); -int ffclock_setestimate(struct ffclock_estimate *cest); -__END_DECLS - -#endif /* _KERNEL */ -#endif /* __BSD_VISIBLE */ -#endif /* _SYS_TIMEFF_H_ */ diff --git a/cpukit/score/include/sys/timepps.h b/cpukit/score/include/sys/timepps.h deleted file mode 100644 index 01212f0b43..0000000000 --- a/cpukit/score/include/sys/timepps.h +++ /dev/null @@ -1,266 +0,0 @@ -/*- - * ---------------------------------------------------------------------------- - * "THE BEER-WARE LICENSE" (Revision 42): - * wrote this file. As long as you retain this notice you - * can do whatever you want with this stuff. If we meet some day, and you think - * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp - * ---------------------------------------------------------------------------- - * - * Copyright (c) 2011 The FreeBSD Foundation - * All rights reserved. - * - * Portions of this software were developed by Julien Ridoux at the University - * of Melbourne under sponsorship from the FreeBSD Foundation. - * - * $FreeBSD: head/sys/sys/timepps.h 282424 2015-05-04 17:59:39Z ian $ - * - * The is a FreeBSD version of the RFC 2783 API for Pulse Per Second - * timing interfaces. - */ - -#ifndef _SYS_TIMEPPS_H_ -#define _SYS_TIMEPPS_H_ - -#include -#include -#include - -#define PPS_API_VERS_1 1 - -typedef int pps_handle_t; - -typedef unsigned pps_seq_t; - -typedef struct ntp_fp { - unsigned int integral; - unsigned int fractional; -} ntp_fp_t; - -typedef union pps_timeu { - struct timespec tspec; - ntp_fp_t ntpfp; - unsigned long longpad[3]; -} pps_timeu_t; - -typedef struct { - pps_seq_t assert_sequence; /* assert event seq # */ - pps_seq_t clear_sequence; /* clear event seq # */ - pps_timeu_t assert_tu; - pps_timeu_t clear_tu; - int current_mode; /* current mode bits */ -} pps_info_t; - -typedef struct { - pps_seq_t assert_sequence; /* assert event seq # */ - pps_seq_t clear_sequence; /* clear event seq # */ - pps_timeu_t assert_tu; - pps_timeu_t clear_tu; - ffcounter assert_ffcount; /* ffcounter on assert event */ - ffcounter clear_ffcount; /* ffcounter on clear event */ - int current_mode; /* current mode bits */ -} pps_info_ffc_t; - -#define assert_timestamp assert_tu.tspec -#define clear_timestamp clear_tu.tspec - -#define assert_timestamp_ntpfp assert_tu.ntpfp -#define clear_timestamp_ntpfp clear_tu.ntpfp - -typedef struct { - int api_version; /* API version # */ - int mode; /* mode bits */ - pps_timeu_t assert_off_tu; - pps_timeu_t clear_off_tu; -} pps_params_t; - -#define assert_offset assert_off_tu.tspec -#define clear_offset clear_off_tu.tspec - -#define assert_offset_ntpfp assert_off_tu.ntpfp -#define clear_offset_ntpfp clear_off_tu.ntpfp - - -#define PPS_CAPTUREASSERT 0x01 -#define PPS_CAPTURECLEAR 0x02 -#define PPS_CAPTUREBOTH 0x03 - -#define PPS_OFFSETASSERT 0x10 -#define PPS_OFFSETCLEAR 0x20 - -#define PPS_ECHOASSERT 0x40 -#define PPS_ECHOCLEAR 0x80 - -#define PPS_CANWAIT 0x100 -#define PPS_CANPOLL 0x200 - -#define PPS_TSFMT_TSPEC 0x1000 -#define PPS_TSFMT_NTPFP 0x2000 - -#define PPS_TSCLK_FBCK 0x10000 -#define PPS_TSCLK_FFWD 0x20000 -#define PPS_TSCLK_MASK 0x30000 - -#define PPS_KC_HARDPPS 0 -#define PPS_KC_HARDPPS_PLL 1 -#define PPS_KC_HARDPPS_FLL 2 - -struct pps_fetch_args { - int tsformat; - pps_info_t pps_info_buf; - struct timespec timeout; -}; - -struct pps_fetch_ffc_args { - int tsformat; - pps_info_ffc_t pps_info_buf_ffc; - struct timespec timeout; -}; - -struct pps_kcbind_args { - int kernel_consumer; - int edge; - int tsformat; -}; - -#define PPS_IOC_CREATE _IO('1', 1) -#define PPS_IOC_DESTROY _IO('1', 2) -#define PPS_IOC_SETPARAMS _IOW('1', 3, pps_params_t) -#define PPS_IOC_GETPARAMS _IOR('1', 4, pps_params_t) -#define PPS_IOC_GETCAP _IOR('1', 5, int) -#define PPS_IOC_FETCH _IOWR('1', 6, struct pps_fetch_args) -#define PPS_IOC_KCBIND _IOW('1', 7, struct pps_kcbind_args) -#define PPS_IOC_FETCH_FFCOUNTER _IOWR('1', 8, struct pps_fetch_ffc_args) - -#ifdef _KERNEL - -struct mtx; - -#define KCMODE_EDGEMASK 0x03 -#define KCMODE_ABIFLAG 0x80000000 /* Internal use: abi-aware driver. */ - -#define PPS_ABI_VERSION 1 - -#define PPSFLAG_MTX_SPIN 0x01 /* Driver mtx is MTX_SPIN type. */ - -struct pps_state { - /* Capture information. */ - struct timehands *capth; - struct fftimehands *capffth; - unsigned capgen; - unsigned capcount; - - /* State information. */ - pps_params_t ppsparam; - pps_info_t ppsinfo; - pps_info_ffc_t ppsinfo_ffc; - int kcmode; - int ppscap; - struct timecounter *ppstc; - unsigned ppscount[3]; - /* - * The following fields are valid if the driver calls pps_init_abi(). - */ - uint16_t driver_abi; /* Driver sets before pps_init_abi(). */ - uint16_t kernel_abi; /* Kernel sets during pps_init_abi(). */ - struct mtx *driver_mtx; /* Optional, valid if non-NULL. */ - uint32_t flags; -}; - -void pps_capture(struct pps_state *pps); -void pps_event(struct pps_state *pps, int event); -void pps_init(struct pps_state *pps); -void pps_init_abi(struct pps_state *pps); -int pps_ioctl(unsigned long cmd, caddr_t data, struct pps_state *pps); -void hardpps(struct timespec *tsp, long nsec); - -#else /* !_KERNEL */ - -static __inline int -time_pps_create(int filedes, pps_handle_t *handle) -{ - int error; - - *handle = -1; - error = ioctl(filedes, PPS_IOC_CREATE, 0); - if (error < 0) - return (-1); - *handle = filedes; - return (0); -} - -static __inline int -time_pps_destroy(pps_handle_t handle) -{ - return (ioctl(handle, PPS_IOC_DESTROY, 0)); -} - -static __inline int -time_pps_setparams(pps_handle_t handle, const pps_params_t *ppsparams) -{ - return (ioctl(handle, PPS_IOC_SETPARAMS, ppsparams)); -} - -static __inline int -time_pps_getparams(pps_handle_t handle, pps_params_t *ppsparams) -{ - return (ioctl(handle, PPS_IOC_GETPARAMS, ppsparams)); -} - -static __inline int -time_pps_getcap(pps_handle_t handle, int *mode) -{ - return (ioctl(handle, PPS_IOC_GETCAP, mode)); -} - -static __inline int -time_pps_fetch(pps_handle_t handle, const int tsformat, - pps_info_t *ppsinfobuf, const struct timespec *timeout) -{ - int error; - struct pps_fetch_args arg; - - arg.tsformat = tsformat; - if (timeout == NULL) { - arg.timeout.tv_sec = -1; - arg.timeout.tv_nsec = -1; - } else - arg.timeout = *timeout; - error = ioctl(handle, PPS_IOC_FETCH, &arg); - *ppsinfobuf = arg.pps_info_buf; - return (error); -} - -static __inline int -time_pps_fetch_ffc(pps_handle_t handle, const int tsformat, - pps_info_ffc_t *ppsinfobuf, const struct timespec *timeout) -{ - struct pps_fetch_ffc_args arg; - int error; - - arg.tsformat = tsformat; - if (timeout == NULL) { - arg.timeout.tv_sec = -1; - arg.timeout.tv_nsec = -1; - } else { - arg.timeout = *timeout; - } - error = ioctl(handle, PPS_IOC_FETCH_FFCOUNTER, &arg); - *ppsinfobuf = arg.pps_info_buf_ffc; - return (error); -} - -static __inline int -time_pps_kcbind(pps_handle_t handle, const int kernel_consumer, - const int edge, const int tsformat) -{ - struct pps_kcbind_args arg; - - arg.kernel_consumer = kernel_consumer; - arg.edge = edge; - arg.tsformat = tsformat; - return (ioctl(handle, PPS_IOC_KCBIND, &arg)); -} - -#endif /* KERNEL */ - -#endif /* !_SYS_TIMEPPS_H_ */ diff --git a/cpukit/score/include/sys/timetc.h b/cpukit/score/include/sys/timetc.h deleted file mode 100644 index 347a140ed9..0000000000 --- a/cpukit/score/include/sys/timetc.h +++ /dev/null @@ -1,105 +0,0 @@ -/*- - * ---------------------------------------------------------------------------- - * "THE BEER-WARE LICENSE" (Revision 42): - * wrote this file. As long as you retain this notice you - * can do whatever you want with this stuff. If we meet some day, and you think - * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp - * ---------------------------------------------------------------------------- - * - * $FreeBSD: head/sys/sys/timetc.h 304285 2016-08-17 09:52:09Z kib $ - */ - -#ifndef _SYS_TIMETC_H_ -#define _SYS_TIMETC_H_ - -#ifndef __rtems__ -#ifndef _KERNEL -#error "no user-serviceable parts inside" -#endif -#endif /* __rtems__ */ - -/*- - * `struct timecounter' is the interface between the hardware which implements - * a timecounter and the MI code which uses this to keep track of time. - * - * A timecounter is a binary counter which has two properties: - * * it runs at a fixed, known frequency. - * * it has sufficient bits to not roll over in less than approximately - * max(2 msec, 2/HZ seconds). (The value 2 here is really 1 + delta, - * for some indeterminate value of delta.) - */ - -struct timecounter; -struct vdso_timehands; -struct vdso_timehands32; -#ifndef __rtems__ -typedef u_int timecounter_get_t(struct timecounter *); -#else /* __rtems__ */ -typedef uint32_t timecounter_get_t(struct timecounter *); -#endif /* __rtems__ */ -typedef void timecounter_pps_t(struct timecounter *); -typedef uint32_t timecounter_fill_vdso_timehands_t(struct vdso_timehands *, - struct timecounter *); -typedef uint32_t timecounter_fill_vdso_timehands32_t(struct vdso_timehands32 *, - struct timecounter *); - -struct timecounter { - timecounter_get_t *tc_get_timecount; - /* - * This function reads the counter. It is not required to - * mask any unimplemented bits out, as long as they are - * constant. - */ - timecounter_pps_t *tc_poll_pps; - /* - * This function is optional. It will be called whenever the - * timecounter is rewound, and is intended to check for PPS - * events. Normal hardware does not need it but timecounters - * which latch PPS in hardware (like sys/pci/xrpu.c) do. - */ - uint32_t tc_counter_mask; - /* This mask should mask off any unimplemented bits. */ - uint64_t tc_frequency; - /* Frequency of the counter in Hz. */ - const char *tc_name; - /* Name of the timecounter. */ - int tc_quality; - /* - * Used to determine if this timecounter is better than - * another timecounter higher means better. Negative - * means "only use at explicit request". - */ - u_int tc_flags; -#define TC_FLAGS_C2STOP 1 /* Timer dies in C2+. */ -#define TC_FLAGS_SUSPEND_SAFE 2 /* - * Timer functional across - * suspend/resume. - */ - - void *tc_priv; - /* Pointer to the timecounter's private parts. */ - struct timecounter *tc_next; - /* Pointer to the next timecounter. */ -#ifndef __rtems__ - timecounter_fill_vdso_timehands_t *tc_fill_vdso_timehands; - timecounter_fill_vdso_timehands32_t *tc_fill_vdso_timehands32; -#endif /* __rtems__ */ -}; - -extern struct timecounter *timecounter; -extern int tc_min_ticktock_freq; /* - * Minimal tc_ticktock() call frequency, - * required to handle counter wraps. - */ - -u_int64_t tc_getfrequency(void); -void tc_init(struct timecounter *tc); -void tc_setclock(struct timespec *ts); -void tc_ticktock(int cnt); -void cpu_tick_calibration(void); - -#ifdef SYSCTL_DECL -SYSCTL_DECL(_kern_timecounter); -#endif - -#endif /* !_SYS_TIMETC_H_ */ diff --git a/cpukit/score/include/sys/timex.h b/cpukit/score/include/sys/timex.h deleted file mode 100644 index d2d2012ff5..0000000000 --- a/cpukit/score/include/sys/timex.h +++ /dev/null @@ -1,171 +0,0 @@ -/*- - *********************************************************************** - * * - * Copyright (c) David L. Mills 1993-2001 * - * Copyright (c) Poul-Henning Kamp 2000-2001 * - * * - * Permission to use, copy, modify, and distribute this software and * - * its documentation for any purpose and without fee is hereby * - * granted, provided that the above copyright notice appears in all * - * copies and that both the copyright notice and this permission * - * notice appear in supporting documentation, and that the name * - * University of Delaware not be used in advertising or publicity * - * pertaining to distribution of the software without specific, * - * written prior permission. The University of Delaware makes no * - * representations about the suitability this software for any * - * purpose. It is provided "as is" without express or implied * - * warranty. * - * * - *********************************************************************** - * - * $FreeBSD: head/sys/sys/timex.h 298981 2016-05-03 15:14:17Z pfg $ - * - * This header file defines the Network Time Protocol (NTP) interfaces - * for user and daemon application programs. - * - * This file was originally created 17 Sep 93 by David L. Mills, Professor - * of University of Delaware, building on work which had already been ongoing - * for a decade and a half at that point in time. - * - * In 2000 the APIs got a upgrade from microseconds to nanoseconds, - * a joint work between Poul-Henning Kamp and David L. Mills. - * - */ - -#ifndef _SYS_TIMEX_H_ -#define _SYS_TIMEX_H_ 1 - -#define NTP_API 4 /* NTP API version */ - -#ifdef __FreeBSD__ -#include -#endif /* __FreeBSD__ */ - -/* - * The following defines establish the performance envelope of the - * kernel discipline loop. Phase or frequency errors greater than - * NAXPHASE or MAXFREQ are clamped to these maxima. For update intervals - * less than MINSEC, the loop always operates in PLL mode; while, for - * update intervals greater than MAXSEC, the loop always operates in FLL - * mode. Between these two limits the operating mode is selected by the - * STA_FLL bit in the status word. - */ - -#define MAXPHASE 500000000L /* max phase error (ns) */ -#define MAXFREQ 500000L /* max freq error (ns/s) */ -#define MINSEC 256 /* min FLL update interval (s) */ -#define MAXSEC 2048 /* max PLL update interval (s) */ -#define NANOSECOND 1000000000L /* nanoseconds in one second */ -#define SCALE_PPM (65536 / 1000) /* crude ns/s to scaled PPM */ -#define MAXTC 10 /* max time constant */ - -/* - * Control mode codes (timex.modes) - */ -#define MOD_OFFSET 0x0001 /* set time offset */ -#define MOD_FREQUENCY 0x0002 /* set frequency offset */ -#define MOD_MAXERROR 0x0004 /* set maximum time error */ -#define MOD_ESTERROR 0x0008 /* set estimated time error */ -#define MOD_STATUS 0x0010 /* set clock status bits */ -#define MOD_TIMECONST 0x0020 /* set PLL time constant */ -#define MOD_PPSMAX 0x0040 /* set PPS maximum averaging time */ -#define MOD_TAI 0x0080 /* set TAI offset */ -#define MOD_MICRO 0x1000 /* select microsecond resolution */ -#define MOD_NANO 0x2000 /* select nanosecond resolution */ -#define MOD_CLKB 0x4000 /* select clock B */ -#define MOD_CLKA 0x8000 /* select clock A */ - -/* - * Status codes (timex.status) - */ -#define STA_PLL 0x0001 /* enable PLL updates (rw) */ -#define STA_PPSFREQ 0x0002 /* enable PPS freq discipline (rw) */ -#define STA_PPSTIME 0x0004 /* enable PPS time discipline (rw) */ -#define STA_FLL 0x0008 /* enable FLL mode (rw) */ -#define STA_INS 0x0010 /* insert leap (rw) */ -#define STA_DEL 0x0020 /* delete leap (rw) */ -#define STA_UNSYNC 0x0040 /* clock unsynchronized (rw) */ -#define STA_FREQHOLD 0x0080 /* hold frequency (rw) */ -#define STA_PPSSIGNAL 0x0100 /* PPS signal present (ro) */ -#define STA_PPSJITTER 0x0200 /* PPS signal jitter exceeded (ro) */ -#define STA_PPSWANDER 0x0400 /* PPS signal wander exceeded (ro) */ -#define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */ -#define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */ -#define STA_NANO 0x2000 /* resolution (0 = us, 1 = ns) (ro) */ -#define STA_MODE 0x4000 /* mode (0 = PLL, 1 = FLL) (ro) */ -#define STA_CLK 0x8000 /* clock source (0 = A, 1 = B) (ro) */ - -#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \ - STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | STA_CLK) - -/* - * Clock states (ntptimeval.time_state) - */ -#define TIME_OK 0 /* no leap second warning */ -#define TIME_INS 1 /* insert leap second warning */ -#define TIME_DEL 2 /* delete leap second warning */ -#define TIME_OOP 3 /* leap second in progress */ -#define TIME_WAIT 4 /* leap second has occurred */ -#define TIME_ERROR 5 /* error (see status word) */ - -/* - * NTP user interface -- ntp_gettime(2) - used to read kernel clock values - */ -struct ntptimeval { - struct timespec time; /* current time (ns) (ro) */ - long maxerror; /* maximum error (us) (ro) */ - long esterror; /* estimated error (us) (ro) */ - long tai; /* TAI offset */ - int time_state; /* time status */ -}; - -/* - * NTP daemon interface -- ntp_adjtime(2) -- used to discipline CPU clock - * oscillator and control/determine status. - * - * Note: The offset, precision and jitter members are in microseconds if - * STA_NANO is zero and nanoseconds if not. - */ -struct timex { - unsigned int modes; /* clock mode bits (wo) */ - long offset; /* time offset (ns/us) (rw) */ - long freq; /* frequency offset (scaled PPM) (rw) */ - long maxerror; /* maximum error (us) (rw) */ - long esterror; /* estimated error (us) (rw) */ - int status; /* clock status bits (rw) */ - long constant; /* poll interval (log2 s) (rw) */ - long precision; /* clock precision (ns/us) (ro) */ - long tolerance; /* clock frequency tolerance (scaled - * PPM) (ro) */ - /* - * The following read-only structure members are implemented - * only if the PPS signal discipline is configured in the - * kernel. They are included in all configurations to insure - * portability. - */ - long ppsfreq; /* PPS frequency (scaled PPM) (ro) */ - long jitter; /* PPS jitter (ns/us) (ro) */ - int shift; /* interval duration (s) (shift) (ro) */ - long stabil; /* PPS stability (scaled PPM) (ro) */ - long jitcnt; /* jitter limit exceeded (ro) */ - long calcnt; /* calibration intervals (ro) */ - long errcnt; /* calibration errors (ro) */ - long stbcnt; /* stability limit exceeded (ro) */ -}; - -#ifdef __FreeBSD__ - -#ifdef _KERNEL -void ntp_update_second(int64_t *adjustment, time_t *newsec); -#else /* !_KERNEL */ -#include - -__BEGIN_DECLS -int ntp_adjtime(struct timex *); -int ntp_gettime(struct ntptimeval *); -__END_DECLS -#endif /* _KERNEL */ - -#endif /* __FreeBSD__ */ - -#endif /* !_SYS_TIMEX_H_ */ diff --git a/cpukit/score/preinstall.am b/cpukit/score/preinstall.am deleted file mode 100644 index 3d70ec311f..0000000000 --- a/cpukit/score/preinstall.am +++ /dev/null @@ -1,472 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES += $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -$(PROJECT_INCLUDE)/sys/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/sys - @: > $(PROJECT_INCLUDE)/sys/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/sys/$(dirstamp) - -$(PROJECT_INCLUDE)/sys/_ffcounter.h: include/sys/_ffcounter.h $(PROJECT_INCLUDE)/sys/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/_ffcounter.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/_ffcounter.h - -$(PROJECT_INCLUDE)/sys/timeffc.h: include/sys/timeffc.h $(PROJECT_INCLUDE)/sys/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/timeffc.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/timeffc.h - -$(PROJECT_INCLUDE)/sys/timepps.h: include/sys/timepps.h $(PROJECT_INCLUDE)/sys/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/timepps.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/timepps.h - -$(PROJECT_INCLUDE)/sys/timetc.h: include/sys/timetc.h $(PROJECT_INCLUDE)/sys/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/timetc.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/timetc.h - -$(PROJECT_INCLUDE)/sys/timex.h: include/sys/timex.h $(PROJECT_INCLUDE)/sys/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/sys/timex.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/sys/timex.h - -$(PROJECT_INCLUDE)/rtems/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems - @: > $(PROJECT_INCLUDE)/rtems/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/linkersets.h: include/rtems/linkersets.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/linkersets.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/linkersets.h - -$(PROJECT_INCLUDE)/rtems/sysinit.h: include/rtems/sysinit.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/sysinit.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/sysinit.h - -$(PROJECT_INCLUDE)/rtems/system.h: include/rtems/system.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/system.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/system.h - -$(PROJECT_INCLUDE)/rtems/seterr.h: include/rtems/seterr.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/seterr.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/seterr.h - -$(PROJECT_INCLUDE)/rtems/score/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems/score - @: > $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/score/address.h: include/rtems/score/address.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/address.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/address.h - -$(PROJECT_INCLUDE)/rtems/score/apimutex.h: include/rtems/score/apimutex.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/apimutex.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/apimutex.h - -$(PROJECT_INCLUDE)/rtems/score/assert.h: include/rtems/score/assert.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/assert.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/assert.h - -$(PROJECT_INCLUDE)/rtems/score/atomic.h: include/rtems/score/atomic.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/atomic.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/atomic.h - -$(PROJECT_INCLUDE)/rtems/score/chain.h: include/rtems/score/chain.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/chain.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/chain.h - -$(PROJECT_INCLUDE)/rtems/score/chainimpl.h: include/rtems/score/chainimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/chainimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/chainimpl.h - -$(PROJECT_INCLUDE)/rtems/score/context.h: include/rtems/score/context.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/context.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/context.h - -$(PROJECT_INCLUDE)/rtems/score/copyrt.h: include/rtems/score/copyrt.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/copyrt.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/copyrt.h - -$(PROJECT_INCLUDE)/rtems/score/corebarrier.h: include/rtems/score/corebarrier.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/corebarrier.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/corebarrier.h - -$(PROJECT_INCLUDE)/rtems/score/corebarrierimpl.h: include/rtems/score/corebarrierimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/corebarrierimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/corebarrierimpl.h - -$(PROJECT_INCLUDE)/rtems/score/coremsg.h: include/rtems/score/coremsg.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/coremsg.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/coremsg.h - -$(PROJECT_INCLUDE)/rtems/score/coremsgimpl.h: include/rtems/score/coremsgimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/coremsgimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/coremsgimpl.h - -$(PROJECT_INCLUDE)/rtems/score/coremutex.h: include/rtems/score/coremutex.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/coremutex.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/coremutex.h - -$(PROJECT_INCLUDE)/rtems/score/coremuteximpl.h: include/rtems/score/coremuteximpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/coremuteximpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/coremuteximpl.h - -$(PROJECT_INCLUDE)/rtems/score/corerwlockimpl.h: include/rtems/score/corerwlockimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/corerwlockimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/corerwlockimpl.h - -$(PROJECT_INCLUDE)/rtems/score/coresem.h: include/rtems/score/coresem.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/coresem.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/coresem.h - -$(PROJECT_INCLUDE)/rtems/score/coresemimpl.h: include/rtems/score/coresemimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/coresemimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/coresemimpl.h - -$(PROJECT_INCLUDE)/rtems/score/cpustdatomic.h: include/rtems/score/cpustdatomic.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpustdatomic.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpustdatomic.h - -$(PROJECT_INCLUDE)/rtems/score/heap.h: include/rtems/score/heap.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/heap.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/heap.h - -$(PROJECT_INCLUDE)/rtems/score/heapimpl.h: include/rtems/score/heapimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/heapimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/heapimpl.h - -$(PROJECT_INCLUDE)/rtems/score/protectedheap.h: include/rtems/score/protectedheap.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/protectedheap.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/protectedheap.h - -$(PROJECT_INCLUDE)/rtems/score/interr.h: include/rtems/score/interr.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/interr.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/interr.h - -$(PROJECT_INCLUDE)/rtems/score/io.h: include/rtems/score/io.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/io.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/io.h - -$(PROJECT_INCLUDE)/rtems/score/isr.h: include/rtems/score/isr.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/isr.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/isr.h - -$(PROJECT_INCLUDE)/rtems/score/isrlevel.h: include/rtems/score/isrlevel.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/isrlevel.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/isrlevel.h - -$(PROJECT_INCLUDE)/rtems/score/isrlock.h: include/rtems/score/isrlock.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/isrlock.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/isrlock.h - -$(PROJECT_INCLUDE)/rtems/score/freechain.h: include/rtems/score/freechain.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/freechain.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/freechain.h - -$(PROJECT_INCLUDE)/rtems/score/mrsp.h: include/rtems/score/mrsp.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/mrsp.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/mrsp.h - -$(PROJECT_INCLUDE)/rtems/score/mrspimpl.h: include/rtems/score/mrspimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/mrspimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/mrspimpl.h - -$(PROJECT_INCLUDE)/rtems/score/muteximpl.h: include/rtems/score/muteximpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/muteximpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/muteximpl.h - -$(PROJECT_INCLUDE)/rtems/score/object.h: include/rtems/score/object.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/object.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/object.h - -$(PROJECT_INCLUDE)/rtems/score/objectimpl.h: include/rtems/score/objectimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/objectimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/objectimpl.h - -$(PROJECT_INCLUDE)/rtems/score/onceimpl.h: include/rtems/score/onceimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/onceimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/onceimpl.h - -$(PROJECT_INCLUDE)/rtems/score/percpu.h: include/rtems/score/percpu.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/percpu.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/percpu.h - -$(PROJECT_INCLUDE)/rtems/score/priority.h: include/rtems/score/priority.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/priority.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/priority.h - -$(PROJECT_INCLUDE)/rtems/score/priorityimpl.h: include/rtems/score/priorityimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/priorityimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/priorityimpl.h - -$(PROJECT_INCLUDE)/rtems/score/prioritybitmap.h: include/rtems/score/prioritybitmap.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/prioritybitmap.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/prioritybitmap.h - -$(PROJECT_INCLUDE)/rtems/score/prioritybitmapimpl.h: include/rtems/score/prioritybitmapimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/prioritybitmapimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/prioritybitmapimpl.h - -$(PROJECT_INCLUDE)/rtems/score/profiling.h: include/rtems/score/profiling.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/profiling.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/profiling.h - -$(PROJECT_INCLUDE)/rtems/score/processormask.h: include/rtems/score/processormask.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/processormask.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/processormask.h - -$(PROJECT_INCLUDE)/rtems/score/rbtree.h: include/rtems/score/rbtree.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/rbtree.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/rbtree.h - -$(PROJECT_INCLUDE)/rtems/score/rbtreeimpl.h: include/rtems/score/rbtreeimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/rbtreeimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/rbtreeimpl.h - -$(PROJECT_INCLUDE)/rtems/score/scheduler.h: include/rtems/score/scheduler.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/scheduler.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/scheduler.h - -$(PROJECT_INCLUDE)/rtems/score/schedulerimpl.h: include/rtems/score/schedulerimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/schedulerimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/schedulerimpl.h - -$(PROJECT_INCLUDE)/rtems/score/schedulercbs.h: include/rtems/score/schedulercbs.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/schedulercbs.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/schedulercbs.h - -$(PROJECT_INCLUDE)/rtems/score/schedulercbsimpl.h: include/rtems/score/schedulercbsimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/schedulercbsimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/schedulercbsimpl.h - -$(PROJECT_INCLUDE)/rtems/score/scheduleredf.h: include/rtems/score/scheduleredf.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/scheduleredf.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/scheduleredf.h - -$(PROJECT_INCLUDE)/rtems/score/scheduleredfimpl.h: include/rtems/score/scheduleredfimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/scheduleredfimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/scheduleredfimpl.h - -$(PROJECT_INCLUDE)/rtems/score/schedulernode.h: include/rtems/score/schedulernode.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/schedulernode.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/schedulernode.h - -$(PROJECT_INCLUDE)/rtems/score/schedulernodeimpl.h: include/rtems/score/schedulernodeimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/schedulernodeimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/schedulernodeimpl.h - -$(PROJECT_INCLUDE)/rtems/score/schedulerpriority.h: include/rtems/score/schedulerpriority.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/schedulerpriority.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/schedulerpriority.h - -$(PROJECT_INCLUDE)/rtems/score/schedulerpriorityimpl.h: include/rtems/score/schedulerpriorityimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/schedulerpriorityimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/schedulerpriorityimpl.h - -$(PROJECT_INCLUDE)/rtems/score/schedulerprioritysmp.h: include/rtems/score/schedulerprioritysmp.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/schedulerprioritysmp.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/schedulerprioritysmp.h - -$(PROJECT_INCLUDE)/rtems/score/schedulersimple.h: include/rtems/score/schedulersimple.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/schedulersimple.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/schedulersimple.h - -$(PROJECT_INCLUDE)/rtems/score/schedulersimpleimpl.h: include/rtems/score/schedulersimpleimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/schedulersimpleimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/schedulersimpleimpl.h - -$(PROJECT_INCLUDE)/rtems/score/schedulersmp.h: include/rtems/score/schedulersmp.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/schedulersmp.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/schedulersmp.h - -$(PROJECT_INCLUDE)/rtems/score/schedulersmpimpl.h: include/rtems/score/schedulersmpimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/schedulersmpimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/schedulersmpimpl.h - -$(PROJECT_INCLUDE)/rtems/score/semaphoreimpl.h: include/rtems/score/semaphoreimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/semaphoreimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/semaphoreimpl.h - -$(PROJECT_INCLUDE)/rtems/score/smp.h: include/rtems/score/smp.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/smp.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/smp.h - -$(PROJECT_INCLUDE)/rtems/score/smpbarrier.h: include/rtems/score/smpbarrier.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/smpbarrier.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/smpbarrier.h - -$(PROJECT_INCLUDE)/rtems/score/smplock.h: include/rtems/score/smplock.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/smplock.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/smplock.h - -$(PROJECT_INCLUDE)/rtems/score/smplockseq.h: include/rtems/score/smplockseq.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/smplockseq.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/smplockseq.h - -$(PROJECT_INCLUDE)/rtems/score/smpimpl.h: include/rtems/score/smpimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/smpimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/smpimpl.h - -$(PROJECT_INCLUDE)/rtems/score/stack.h: include/rtems/score/stack.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/stack.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/stack.h - -$(PROJECT_INCLUDE)/rtems/score/stackimpl.h: include/rtems/score/stackimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/stackimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/stackimpl.h - -$(PROJECT_INCLUDE)/rtems/score/states.h: include/rtems/score/states.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/states.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/states.h - -$(PROJECT_INCLUDE)/rtems/score/statesimpl.h: include/rtems/score/statesimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/statesimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/statesimpl.h - -$(PROJECT_INCLUDE)/rtems/score/status.h: include/rtems/score/status.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/status.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/status.h - -$(PROJECT_INCLUDE)/rtems/score/sysstate.h: include/rtems/score/sysstate.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/sysstate.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/sysstate.h - -$(PROJECT_INCLUDE)/rtems/score/thread.h: include/rtems/score/thread.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/thread.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/thread.h - -$(PROJECT_INCLUDE)/rtems/score/threadimpl.h: include/rtems/score/threadimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/threadimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/threadimpl.h - -$(PROJECT_INCLUDE)/rtems/score/threaddispatch.h: include/rtems/score/threaddispatch.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/threaddispatch.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/threaddispatch.h - -$(PROJECT_INCLUDE)/rtems/score/threadq.h: include/rtems/score/threadq.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/threadq.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/threadq.h - -$(PROJECT_INCLUDE)/rtems/score/threadqimpl.h: include/rtems/score/threadqimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/threadqimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/threadqimpl.h - -$(PROJECT_INCLUDE)/rtems/score/timespec.h: include/rtems/score/timespec.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/timespec.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/timespec.h - -$(PROJECT_INCLUDE)/rtems/score/timestamp.h: include/rtems/score/timestamp.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/timestamp.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/timestamp.h - -$(PROJECT_INCLUDE)/rtems/score/timecounter.h: include/rtems/score/timecounter.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/timecounter.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/timecounter.h - -$(PROJECT_INCLUDE)/rtems/score/timecounterimpl.h: include/rtems/score/timecounterimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/timecounterimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/timecounterimpl.h - -$(PROJECT_INCLUDE)/rtems/score/tls.h: include/rtems/score/tls.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/tls.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/tls.h - -$(PROJECT_INCLUDE)/rtems/score/tod.h: include/rtems/score/tod.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/tod.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/tod.h - -$(PROJECT_INCLUDE)/rtems/score/todimpl.h: include/rtems/score/todimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/todimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/todimpl.h - -$(PROJECT_INCLUDE)/rtems/score/userext.h: include/rtems/score/userext.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/userext.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/userext.h - -$(PROJECT_INCLUDE)/rtems/score/userextimpl.h: include/rtems/score/userextimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/userextimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/userextimpl.h - -$(PROJECT_INCLUDE)/rtems/score/watchdog.h: include/rtems/score/watchdog.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/watchdog.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/watchdog.h - -$(PROJECT_INCLUDE)/rtems/score/watchdogimpl.h: include/rtems/score/watchdogimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/watchdogimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/watchdogimpl.h - -$(PROJECT_INCLUDE)/rtems/score/wkspace.h: include/rtems/score/wkspace.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/wkspace.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/wkspace.h - -$(PROJECT_INCLUDE)/rtems/score/cpuopts.h: include/rtems/score/cpuopts.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/cpuopts.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/cpuopts.h - -$(PROJECT_INCLUDE)/rtems/score/basedefs.h: include/rtems/score/basedefs.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/basedefs.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/basedefs.h - -if HAS_MP -$(PROJECT_INCLUDE)/rtems/score/mpci.h: include/rtems/score/mpci.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/mpci.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/mpci.h - -$(PROJECT_INCLUDE)/rtems/score/mpciimpl.h: include/rtems/score/mpciimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/mpciimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/mpciimpl.h - -$(PROJECT_INCLUDE)/rtems/score/mppkt.h: include/rtems/score/mppkt.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/mppkt.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/mppkt.h - -$(PROJECT_INCLUDE)/rtems/score/objectmp.h: include/rtems/score/objectmp.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/objectmp.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/objectmp.h - -$(PROJECT_INCLUDE)/rtems/score/threadmp.h: include/rtems/score/threadmp.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/threadmp.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/threadmp.h -endif -if HAS_SMP -$(PROJECT_INCLUDE)/rtems/score/scheduleredfsmp.h: include/rtems/score/scheduleredfsmp.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/scheduleredfsmp.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/scheduleredfsmp.h - -$(PROJECT_INCLUDE)/rtems/score/schedulerprioritysmpimpl.h: include/rtems/score/schedulerprioritysmpimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/schedulerprioritysmpimpl.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/schedulerprioritysmpimpl.h - -$(PROJECT_INCLUDE)/rtems/score/schedulerpriorityaffinitysmp.h: include/rtems/score/schedulerpriorityaffinitysmp.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/schedulerpriorityaffinitysmp.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/schedulerpriorityaffinitysmp.h - -$(PROJECT_INCLUDE)/rtems/score/schedulersimplesmp.h: include/rtems/score/schedulersimplesmp.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/schedulersimplesmp.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/schedulersimplesmp.h - -$(PROJECT_INCLUDE)/rtems/score/schedulerstrongapa.h: include/rtems/score/schedulerstrongapa.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/schedulerstrongapa.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/schedulerstrongapa.h - -$(PROJECT_INCLUDE)/rtems/score/smplockmcs.h: include/rtems/score/smplockmcs.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/smplockmcs.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/smplockmcs.h - -$(PROJECT_INCLUDE)/rtems/score/smplockstats.h: include/rtems/score/smplockstats.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/smplockstats.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/smplockstats.h - -$(PROJECT_INCLUDE)/rtems/score/smplockticket.h: include/rtems/score/smplockticket.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/smplockticket.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/smplockticket.h -endif diff --git a/cpukit/telnetd/Makefile.am b/cpukit/telnetd/Makefile.am index d114ba4a3b..e2ae6a92ae 100644 --- a/cpukit/telnetd/Makefile.am +++ b/cpukit/telnetd/Makefile.am @@ -2,10 +2,12 @@ include $(top_srcdir)/automake/compile.am if LIBNETWORKING if LIBSHELL -include_rtemsdir = $(includedir)/rtems -include_rtems_HEADERS = pty.h telnetd.h passwd.h - project_lib_LIBRARIES = libtelnetd.a + +$(PROJECT_LIB)/libtelnetd.a: libtelnetd.a + $(INSTALL_DATA) $< $(PROJECT_LIB)/libtelnetd.a +TMPINSTALL_FILES = $(PROJECT_LIB)/libtelnetd.a + libtelnetd_a_SOURCES = check_passwd.c des.c pty.c telnetd.c libtelnetd_a_CPPFLAGS = $(AM_CPPFLAGS) endif @@ -13,5 +15,4 @@ endif EXTRA_DIST = README -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am diff --git a/cpukit/telnetd/passwd.h b/cpukit/telnetd/passwd.h deleted file mode 100644 index 8d5c299a5e..0000000000 --- a/cpukit/telnetd/passwd.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Define a default password for telnetd here. - * NOTES: - * - this can be overridden at run-time by setting - * the "TELNETD_PASSWD" environment variable. - * As soon as that variable is set, the new password - * is effective - no need to restart telnetd. - * - this must be set to an _encrypted_ password, NOT - * the cleartext. Use the 'genpw' utility to generate - * a password string: - * - * 1) Compile 'genpw.c' for the HOST, i.e. - * cc -o genpw genpw.c -lcrypt - * 1) delete an old password definition from this file. - * 2) run './genpw >> passwd.h'. This will append - * a new definition to this file. - * - * - if no password is defined here, no authentication - * is needed, i.e. telnet is open to the world. - * - * T. Straumann - */ - -/* #undef TELNETD_DEFAULT_PASSWD */ -/* Default password: 'rtems' */ -#define TELNETD_DEFAULT_PASSWD "tduDcyLX12owo" diff --git a/cpukit/telnetd/preinstall.am b/cpukit/telnetd/preinstall.am deleted file mode 100644 index 9acb28775a..0000000000 --- a/cpukit/telnetd/preinstall.am +++ /dev/null @@ -1,49 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -all-local: $(TMPINSTALL_FILES) - -TMPINSTALL_FILES = -CLEANFILES += $(TMPINSTALL_FILES) - -$(PROJECT_LIB)/$(dirstamp): - @$(MKDIR_P) $(PROJECT_LIB) - @: > $(PROJECT_LIB)/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_LIB)/$(dirstamp) - -if LIBNETWORKING -if LIBSHELL -$(PROJECT_INCLUDE)/rtems/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE)/rtems - @: > $(PROJECT_INCLUDE)/rtems/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/rtems/$(dirstamp) - -$(PROJECT_INCLUDE)/rtems/pty.h: pty.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/pty.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/pty.h - -$(PROJECT_INCLUDE)/rtems/telnetd.h: telnetd.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/telnetd.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/telnetd.h - -$(PROJECT_INCLUDE)/rtems/passwd.h: passwd.h $(PROJECT_INCLUDE)/rtems/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/passwd.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/passwd.h - -$(PROJECT_LIB)/libtelnetd.a: libtelnetd.a $(PROJECT_LIB)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_LIB)/libtelnetd.a -TMPINSTALL_FILES += $(PROJECT_LIB)/libtelnetd.a -endif -endif diff --git a/cpukit/telnetd/pty.h b/cpukit/telnetd/pty.h deleted file mode 100644 index 392bfd0969..0000000000 --- a/cpukit/telnetd/pty.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * /dev/ptyXX (A first version for pseudo-terminals) - * - * Author: Fernando RUIZ CASAS (fernando.ruiz@ctv.es) - * May 2001 - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - */ - -#ifndef _RTEMS_PTY_H -#define _RTEMS_PTY_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/* Number of ptys to setup */ -extern size_t rtems_pty_maximum_ptys; - -/* Return the devname for a free pty slot. - * If no slot available (socket>=0) - * then the socket argument is closed - */ -char * rtems_pty_get(int socket); - - -/* OBSOLETE */ -#define get_pty rtems_pty_get - -rtems_device_driver pty_initialize( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *arg); -rtems_device_driver pty_open( - rtems_device_major_number major, - rtems_device_minor_number minor, - void * arg); -rtems_device_driver pty_close( - rtems_device_major_number major, - rtems_device_minor_number minor, - void * arg); -rtems_device_driver pty_read( - rtems_device_major_number major, - rtems_device_minor_number minor, - void * arg); -rtems_device_driver pty_write( - rtems_device_major_number major, - rtems_device_minor_number minor, - void * arg); -rtems_device_driver pty_control( - rtems_device_major_number major, - rtems_device_minor_number minor, - void * arg); - - -#define PTY_DRIVER_TABLE_ENTRY \ - { pty_initialize , pty_open , pty_close , \ - pty_read , pty_write , pty_control } - -/* Internal functions */ - -int telnet_pty_initialize(void); - -int telnet_pty_finalize(void); - -char *telnet_get_pty(int); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/telnetd/telnetd.h b/cpukit/telnetd/telnetd.h deleted file mode 100644 index a5c8a187e3..0000000000 --- a/cpukit/telnetd/telnetd.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Original Author: Fernando RUIZ CASAS (fernando.ruiz@ctv.es) - * May 2001 - * Reworked by Till Straumann and .h overhauled by Joel Sherrill. - * - * Copyright (c) 2009 embedded brains GmbH and others. - * - * embedded brains GmbH - * Obere Lagerstr. 30 - * D-82178 Puchheim - * Germany - * - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifndef _RTEMS_TELNETD_H -#define _RTEMS_TELNETD_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -bool rtems_telnetd_login_check( - const char *user, - const char *passphrase -); - -/** - * @brief Telnet command type. - */ -typedef void (*rtems_telnetd_command)( - char * /* device name */, - void * /* arg */ -); - -/** - * @brief Telnet configuration structure. - */ -typedef struct { - /** - * @brief Function invoked for each Telnet connection. - * - * The first parameter contains the device name. The second parameter - * contains the argument pointer of this configuration table. - */ - rtems_telnetd_command command; - - /** - * @brief Argument for command function. - */ - void *arg; - - /** - * @brief Task priority. - * - * If this parameter is equal to zero, then the priority of network task is - * used or 100 if this priority is less than two. - */ - rtems_task_priority priority; - - /** - * @brief Task stack size. - */ - size_t stack_size; - - /** - * @brief Login check function. - * - * Method used for login checks. Use @c NULL to disable a login check. - */ - rtems_shell_login_check_t login_check; - - /** - * @brief Keep standard IO of the caller. - * - * Telnet takes over the standard input, output and error associated with - * task, if this parameter is set to @c true. In this case, it will @b not - * listen on any sockets. When this parameter is @c false, Telnet will - * create other tasks for the shell which listen on sockets. - */ - bool keep_stdio; -} rtems_telnetd_config_table; - -/** - * @brief Telnet configuration. - * - * The application must provide this configuration table. It is used by - * rtems_telnetd_initialize() to configure the Telnet subsystem. Do not modify - * the entries after the intialization since it is used internally. - */ -extern rtems_telnetd_config_table rtems_telnetd_config; - -/** - * @brief Initializes the Telnet subsystem. - * - * Uses the application provided @ref rtems_telnetd_config configuration table. - */ -rtems_status_code rtems_telnetd_initialize(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cpukit/wrapup/Makefile.am b/cpukit/wrapup/Makefile.am index 14f0c33a06..2fdb754b4b 100644 --- a/cpukit/wrapup/Makefile.am +++ b/cpukit/wrapup/Makefile.am @@ -5,6 +5,11 @@ include $(top_srcdir)/automake/compile.am ARCH = o-optimize project_lib_LIBRARIES = librtemscpu.a + +$(PROJECT_LIB)/librtemscpu.a: librtemscpu.a + $(INSTALL_DATA) $< $(PROJECT_LIB)/librtemscpu.a +TMPINSTALL_FILES = $(PROJECT_LIB)/librtemscpu.a + librtemscpu_a_SOURCES = TMP_LIBS = @@ -134,5 +139,4 @@ librtemscpu.a: $(TMP_LIBS) all-local: $(TMPINSTALL_FILES) -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am diff --git a/cpukit/wrapup/preinstall.am b/cpukit/wrapup/preinstall.am deleted file mode 100644 index 0c39a9cf28..0000000000 --- a/cpukit/wrapup/preinstall.am +++ /dev/null @@ -1,24 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-local: $(TMPINSTALL_FILES) - -TMPINSTALL_FILES = -CLEANFILES = $(TMPINSTALL_FILES) - -$(PROJECT_LIB)/$(dirstamp): - @$(MKDIR_P) $(PROJECT_LIB) - @: > $(PROJECT_LIB)/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_LIB)/$(dirstamp) - -$(PROJECT_LIB)/librtemscpu.a: librtemscpu.a $(PROJECT_LIB)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_LIB)/librtemscpu.a -TMPINSTALL_FILES += $(PROJECT_LIB)/librtemscpu.a - diff --git a/cpukit/zlib/Makefile.am b/cpukit/zlib/Makefile.am index 0b38ecd5c2..f5a42cccb6 100644 --- a/cpukit/zlib/Makefile.am +++ b/cpukit/zlib/Makefile.am @@ -2,6 +2,11 @@ include $(top_srcdir)/automake/compile.am project_lib_LIBRARIES = libz.a +$(PROJECT_LIB)/libz.a: libz.a + $(INSTALL_DATA) $< $(PROJECT_LIB)/libz.a +TMPINSTALL_FILES = $(PROJECT_LIB)/libz.a + + libz_a_SOURCES = adler32.c libz_a_SOURCES += compress.c libz_a_SOURCES += crc32.c crc32.h @@ -18,7 +23,4 @@ libz_a_SOURCES += zconf.h libz_a_SOURCES += zlib.h libz_a_SOURCES += zutil.c zutil.h -include_HEADERS = zlib.h - -include $(srcdir)/preinstall.am include $(top_srcdir)/automake/local.am diff --git a/cpukit/zlib/preinstall.am b/cpukit/zlib/preinstall.am deleted file mode 100644 index 799bb7b442..0000000000 --- a/cpukit/zlib/preinstall.am +++ /dev/null @@ -1,38 +0,0 @@ -## Automatically generated by ampolish3 - Do not edit - -if AMPOLISH3 -$(srcdir)/preinstall.am: Makefile.am - $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am -endif - -PREINSTALL_DIRS = -DISTCLEANFILES = $(PREINSTALL_DIRS) - -all-am: $(PREINSTALL_FILES) - -PREINSTALL_FILES = -CLEANFILES = $(PREINSTALL_FILES) - -all-local: $(TMPINSTALL_FILES) - -TMPINSTALL_FILES = -CLEANFILES += $(TMPINSTALL_FILES) - -$(PROJECT_LIB)/$(dirstamp): - @$(MKDIR_P) $(PROJECT_LIB) - @: > $(PROJECT_LIB)/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_LIB)/$(dirstamp) - -$(PROJECT_INCLUDE)/$(dirstamp): - @$(MKDIR_P) $(PROJECT_INCLUDE) - @: > $(PROJECT_INCLUDE)/$(dirstamp) -PREINSTALL_DIRS += $(PROJECT_INCLUDE)/$(dirstamp) - -$(PROJECT_LIB)/libz.a: libz.a $(PROJECT_LIB)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_LIB)/libz.a -TMPINSTALL_FILES += $(PROJECT_LIB)/libz.a - -$(PROJECT_INCLUDE)/zlib.h: zlib.h $(PROJECT_INCLUDE)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/zlib.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/zlib.h - diff --git a/cpukit/zlib/zlib.h b/cpukit/zlib/zlib.h deleted file mode 100644 index bfbba83e8e..0000000000 --- a/cpukit/zlib/zlib.h +++ /dev/null @@ -1,1613 +0,0 @@ -/* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.2.5, April 19th, 2010 - - Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jean-loup Gailly Mark Adler - jloup@gzip.org madler@alumni.caltech.edu - - - The data format used by the zlib library is described by RFCs (Request for - Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt - (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). -*/ - -#ifndef ZLIB_H -#define ZLIB_H - -#include "zconf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define ZLIB_VERSION "1.2.5" -#define ZLIB_VERNUM 0x1250 -#define ZLIB_VER_MAJOR 1 -#define ZLIB_VER_MINOR 2 -#define ZLIB_VER_REVISION 5 -#define ZLIB_VER_SUBREVISION 0 - -/* - The 'zlib' compression library provides in-memory compression and - decompression functions, including integrity checks of the uncompressed data. - This version of the library supports only one compression method (deflation) - but other algorithms will be added later and will have the same stream - interface. - - Compression can be done in a single step if the buffers are large enough, - or can be done by repeated calls of the compression function. In the latter - case, the application must provide more input and/or consume the output - (providing more output space) before each call. - - The compressed data format used by default by the in-memory functions is - the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped - around a deflate stream, which is itself documented in RFC 1951. - - The library also supports reading and writing files in gzip (.gz) format - with an interface similar to that of stdio using the functions that start - with "gz". The gzip format is different from the zlib format. gzip is a - gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. - - This library can optionally read and write gzip streams in memory as well. - - The zlib format was designed to be compact and fast for use in memory - and on communications channels. The gzip format was designed for single- - file compression on file systems, has a larger header than zlib to maintain - directory information, and uses a different, slower check method than zlib. - - The library does not install any signal handler. The decoder checks - the consistency of the compressed data, so the library should never crash - even in case of corrupted input. -*/ - -typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); -typedef void (*free_func) OF((voidpf opaque, voidpf address)); - -struct internal_state; - -typedef struct z_stream_s { - Bytef *next_in; /* next input byte */ - uInt avail_in; /* number of bytes available at next_in */ - uLong total_in; /* total nb of input bytes read so far */ - - Bytef *next_out; /* next output byte should be put there */ - uInt avail_out; /* remaining free space at next_out */ - uLong total_out; /* total nb of bytes output so far */ - - char *msg; /* last error message, NULL if no error */ - struct internal_state FAR *state; /* not visible by applications */ - - alloc_func zalloc; /* used to allocate the internal state */ - free_func zfree; /* used to free the internal state */ - voidpf opaque; /* private data object passed to zalloc and zfree */ - - int data_type; /* best guess about the data type: binary or text */ - uLong adler; /* adler32 value of the uncompressed data */ - uLong reserved; /* reserved for future use */ -} z_stream; - -typedef z_stream FAR *z_streamp; - -/* - gzip header information passed to and from zlib routines. See RFC 1952 - for more details on the meanings of these fields. -*/ -typedef struct gz_header_s { - int text; /* true if compressed data believed to be text */ - uLong time; /* modification time */ - int xflags; /* extra flags (not used when writing a gzip file) */ - int os; /* operating system */ - Bytef *extra; /* pointer to extra field or Z_NULL if none */ - uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ - uInt extra_max; /* space at extra (only when reading header) */ - Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ - uInt name_max; /* space at name (only when reading header) */ - Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ - uInt comm_max; /* space at comment (only when reading header) */ - int hcrc; /* true if there was or will be a header crc */ - int done; /* true when done reading gzip header (not used - when writing a gzip file) */ -} gz_header; - -typedef gz_header FAR *gz_headerp; - -/* - The application must update next_in and avail_in when avail_in has dropped - to zero. It must update next_out and avail_out when avail_out has dropped - to zero. The application must initialize zalloc, zfree and opaque before - calling the init function. All other fields are set by the compression - library and must not be updated by the application. - - The opaque value provided by the application will be passed as the first - parameter for calls of zalloc and zfree. This can be useful for custom - memory management. The compression library attaches no meaning to the - opaque value. - - zalloc must return Z_NULL if there is not enough memory for the object. - If zlib is used in a multi-threaded application, zalloc and zfree must be - thread safe. - - On 16-bit systems, the functions zalloc and zfree must be able to allocate - exactly 65536 bytes, but will not be required to allocate more than this if - the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers - returned by zalloc for objects of exactly 65536 bytes *must* have their - offset normalized to zero. The default allocation function provided by this - library ensures this (see zutil.c). To reduce memory requirements and avoid - any allocation of 64K objects, at the expense of compression ratio, compile - the library with -DMAX_WBITS=14 (see zconf.h). - - The fields total_in and total_out can be used for statistics or progress - reports. After compression, total_in holds the total size of the - uncompressed data and may be saved for use in the decompressor (particularly - if the decompressor wants to decompress everything in a single step). -*/ - - /* constants */ - -#define Z_NO_FLUSH 0 -#define Z_PARTIAL_FLUSH 1 -#define Z_SYNC_FLUSH 2 -#define Z_FULL_FLUSH 3 -#define Z_FINISH 4 -#define Z_BLOCK 5 -#define Z_TREES 6 -/* Allowed flush values; see deflate() and inflate() below for details */ - -#define Z_OK 0 -#define Z_STREAM_END 1 -#define Z_NEED_DICT 2 -#define Z_ERRNO (-1) -#define Z_STREAM_ERROR (-2) -#define Z_DATA_ERROR (-3) -#define Z_MEM_ERROR (-4) -#define Z_BUF_ERROR (-5) -#define Z_VERSION_ERROR (-6) -/* Return codes for the compression/decompression functions. Negative values - * are errors, positive values are used for special but normal events. - */ - -#define Z_NO_COMPRESSION 0 -#define Z_BEST_SPEED 1 -#define Z_BEST_COMPRESSION 9 -#define Z_DEFAULT_COMPRESSION (-1) -/* compression levels */ - -#define Z_FILTERED 1 -#define Z_HUFFMAN_ONLY 2 -#define Z_RLE 3 -#define Z_FIXED 4 -#define Z_DEFAULT_STRATEGY 0 -/* compression strategy; see deflateInit2() below for details */ - -#define Z_BINARY 0 -#define Z_TEXT 1 -#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ -#define Z_UNKNOWN 2 -/* Possible values of the data_type field (though see inflate()) */ - -#define Z_DEFLATED 8 -/* The deflate compression method (the only one supported in this version) */ - -#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ - -#define zlib_version zlibVersion() -/* for compatibility with versions < 1.0.2 */ - - - /* basic functions */ - -ZEXTERN const char * ZEXPORT zlibVersion OF((void)); -/* The application can compare zlibVersion and ZLIB_VERSION for consistency. - If the first character differs, the library code actually used is not - compatible with the zlib.h header file used by the application. This check - is automatically made by deflateInit and inflateInit. - */ - -/* -ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); - - Initializes the internal stream state for compression. The fields - zalloc, zfree and opaque must be initialized before by the caller. If - zalloc and zfree are set to Z_NULL, deflateInit updates them to use default - allocation functions. - - The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: - 1 gives best speed, 9 gives best compression, 0 gives no compression at all - (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION - requests a default compromise between speed and compression (currently - equivalent to level 6). - - deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if level is not a valid compression level, or - Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible - with the version assumed by the caller (ZLIB_VERSION). msg is set to null - if there is no error message. deflateInit does not perform any compression: - this will be done by deflate(). -*/ - - -ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); -/* - deflate compresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce - some output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. deflate performs one or both of the - following actions: - - - Compress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in and avail_in are updated and - processing will resume at this point for the next call of deflate(). - - - Provide more output starting at next_out and update next_out and avail_out - accordingly. This action is forced if the parameter flush is non zero. - Forcing flush frequently degrades the compression ratio, so this parameter - should be set only when necessary (in interactive applications). Some - output may be provided even if flush is not set. - - Before the call of deflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming more - output, and updating avail_in or avail_out accordingly; avail_out should - never be zero before the call. The application can consume the compressed - output when it wants, for example when the output buffer is full (avail_out - == 0), or after each call of deflate(). If deflate returns Z_OK and with - zero avail_out, it must be called again after making room in the output - buffer because there might be more output pending. - - Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to - decide how much data to accumulate before producing output, in order to - maximize compression. - - If the parameter flush is set to Z_SYNC_FLUSH, all pending output is - flushed to the output buffer and the output is aligned on a byte boundary, so - that the decompressor can get all input data available so far. (In - particular avail_in is zero after the call if enough output space has been - provided before the call.) Flushing may degrade compression for some - compression algorithms and so it should be used only when necessary. This - completes the current deflate block and follows it with an empty stored block - that is three bits plus filler bits to the next byte, followed by four bytes - (00 00 ff ff). - - If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the - output buffer, but the output is not aligned to a byte boundary. All of the - input data so far will be available to the decompressor, as for Z_SYNC_FLUSH. - This completes the current deflate block and follows it with an empty fixed - codes block that is 10 bits long. This assures that enough bytes are output - in order for the decompressor to finish the block before the empty fixed code - block. - - If flush is set to Z_BLOCK, a deflate block is completed and emitted, as - for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to - seven bits of the current block are held to be written as the next byte after - the next deflate block is completed. In this case, the decompressor may not - be provided enough bits at this point in order to complete decompression of - the data provided so far to the compressor. It may need to wait for the next - block to be emitted. This is for advanced applications that need to control - the emission of deflate blocks. - - If flush is set to Z_FULL_FLUSH, all output is flushed as with - Z_SYNC_FLUSH, and the compression state is reset so that decompression can - restart from this point if previous compressed data has been damaged or if - random access is desired. Using Z_FULL_FLUSH too often can seriously degrade - compression. - - If deflate returns with avail_out == 0, this function must be called again - with the same value of the flush parameter and more output space (updated - avail_out), until the flush is complete (deflate returns with non-zero - avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that - avail_out is greater than six to avoid repeated flush markers due to - avail_out == 0 on return. - - If the parameter flush is set to Z_FINISH, pending input is processed, - pending output is flushed and deflate returns with Z_STREAM_END if there was - enough output space; if deflate returns with Z_OK, this function must be - called again with Z_FINISH and more output space (updated avail_out) but no - more input data, until it returns with Z_STREAM_END or an error. After - deflate has returned Z_STREAM_END, the only possible operations on the stream - are deflateReset or deflateEnd. - - Z_FINISH can be used immediately after deflateInit if all the compression - is to be done in a single step. In this case, avail_out must be at least the - value returned by deflateBound (see below). If deflate does not return - Z_STREAM_END, then it must be called again as described above. - - deflate() sets strm->adler to the adler32 checksum of all input read - so far (that is, total_in bytes). - - deflate() may update strm->data_type if it can make a good guess about - the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered - binary. This field is only for information purposes and does not affect the - compression algorithm in any manner. - - deflate() returns Z_OK if some progress has been made (more input - processed or more output produced), Z_STREAM_END if all input has been - consumed and all output has been produced (only when flush is set to - Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example - if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible - (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not - fatal, and deflate() can be called again with more input and more output - space to continue compressing. -*/ - - -ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any pending - output. - - deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the - stream state was inconsistent, Z_DATA_ERROR if the stream was freed - prematurely (some input or output was discarded). In the error case, msg - may be set but then points to a static string (which must not be - deallocated). -*/ - - -/* -ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); - - Initializes the internal stream state for decompression. The fields - next_in, avail_in, zalloc, zfree and opaque must be initialized before by - the caller. If next_in is not Z_NULL and avail_in is large enough (the - exact value depends on the compression method), inflateInit determines the - compression method from the zlib header and allocates all data structures - accordingly; otherwise the allocation will be deferred to the first call of - inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to - use default allocation functions. - - inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_VERSION_ERROR if the zlib library version is incompatible with the - version assumed by the caller, or Z_STREAM_ERROR if the parameters are - invalid, such as a null pointer to the structure. msg is set to null if - there is no error message. inflateInit does not perform any decompression - apart from possibly reading the zlib header if present: actual decompression - will be done by inflate(). (So next_in and avail_in may be modified, but - next_out and avail_out are unused and unchanged.) The current implementation - of inflateInit() does not process any header information -- that is deferred - until inflate() is called. -*/ - - -ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); -/* - inflate decompresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce - some output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. inflate performs one or both of the - following actions: - - - Decompress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in is updated and processing will - resume at this point for the next call of inflate(). - - - Provide more output starting at next_out and update next_out and avail_out - accordingly. inflate() provides as much output as possible, until there is - no more input data or no more space in the output buffer (see below about - the flush parameter). - - Before the call of inflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming more - output, and updating the next_* and avail_* values accordingly. The - application can consume the uncompressed output when it wants, for example - when the output buffer is full (avail_out == 0), or after each call of - inflate(). If inflate returns Z_OK and with zero avail_out, it must be - called again after making room in the output buffer because there might be - more output pending. - - The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH, - Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much - output as possible to the output buffer. Z_BLOCK requests that inflate() - stop if and when it gets to the next deflate block boundary. When decoding - the zlib or gzip format, this will cause inflate() to return immediately - after the header and before the first block. When doing a raw inflate, - inflate() will go ahead and process the first block, and will return when it - gets to the end of that block, or when it runs out of data. - - The Z_BLOCK option assists in appending to or combining deflate streams. - Also to assist in this, on return inflate() will set strm->data_type to the - number of unused bits in the last byte taken from strm->next_in, plus 64 if - inflate() is currently decoding the last block in the deflate stream, plus - 128 if inflate() returned immediately after decoding an end-of-block code or - decoding the complete header up to just before the first byte of the deflate - stream. The end-of-block will not be indicated until all of the uncompressed - data from that block has been written to strm->next_out. The number of - unused bits may in general be greater than seven, except when bit 7 of - data_type is set, in which case the number of unused bits will be less than - eight. data_type is set as noted here every time inflate() returns for all - flush options, and so can be used to determine the amount of currently - consumed input in bits. - - The Z_TREES option behaves as Z_BLOCK does, but it also returns when the - end of each deflate block header is reached, before any actual data in that - block is decoded. This allows the caller to determine the length of the - deflate block header for later use in random access within a deflate block. - 256 is added to the value of strm->data_type when inflate() returns - immediately after reaching the end of the deflate block header. - - inflate() should normally be called until it returns Z_STREAM_END or an - error. However if all decompression is to be performed in a single step (a - single call of inflate), the parameter flush should be set to Z_FINISH. In - this case all pending input is processed and all pending output is flushed; - avail_out must be large enough to hold all the uncompressed data. (The size - of the uncompressed data may have been saved by the compressor for this - purpose.) The next operation on this stream must be inflateEnd to deallocate - the decompression state. The use of Z_FINISH is never required, but can be - used to inform inflate that a faster approach may be used for the single - inflate() call. - - In this implementation, inflate() always flushes as much output as - possible to the output buffer, and always uses the faster approach on the - first call. So the only effect of the flush parameter in this implementation - is on the return value of inflate(), as noted below, or when it returns early - because Z_BLOCK or Z_TREES is used. - - If a preset dictionary is needed after this call (see inflateSetDictionary - below), inflate sets strm->adler to the adler32 checksum of the dictionary - chosen by the compressor and returns Z_NEED_DICT; otherwise it sets - strm->adler to the adler32 checksum of all output produced so far (that is, - total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described - below. At the end of the stream, inflate() checks that its computed adler32 - checksum is equal to that saved by the compressor and returns Z_STREAM_END - only if the checksum is correct. - - inflate() can decompress and check either zlib-wrapped or gzip-wrapped - deflate data. The header type is detected automatically, if requested when - initializing with inflateInit2(). Any information contained in the gzip - header is not retained, so applications that need that information should - instead use raw inflate, see inflateInit2() below, or inflateBack() and - perform their own processing of the gzip header and trailer. - - inflate() returns Z_OK if some progress has been made (more input processed - or more output produced), Z_STREAM_END if the end of the compressed data has - been reached and all uncompressed output has been produced, Z_NEED_DICT if a - preset dictionary is needed at this point, Z_DATA_ERROR if the input data was - corrupted (input stream not conforming to the zlib format or incorrect check - value), Z_STREAM_ERROR if the stream structure was inconsistent (for example - next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory, - Z_BUF_ERROR if no progress is possible or if there was not enough room in the - output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and - inflate() can be called again with more input and more output space to - continue decompressing. If Z_DATA_ERROR is returned, the application may - then call inflateSync() to look for a good compression block if a partial - recovery of the data is desired. -*/ - - -ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any pending - output. - - inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state - was inconsistent. In the error case, msg may be set but then points to a - static string (which must not be deallocated). -*/ - - - /* Advanced functions */ - -/* - The following functions are needed only in some special applications. -*/ - -/* -ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, - int level, - int method, - int windowBits, - int memLevel, - int strategy)); - - This is another version of deflateInit with more compression options. The - fields next_in, zalloc, zfree and opaque must be initialized before by the - caller. - - The method parameter is the compression method. It must be Z_DEFLATED in - this version of the library. - - The windowBits parameter is the base two logarithm of the window size - (the size of the history buffer). It should be in the range 8..15 for this - version of the library. Larger values of this parameter result in better - compression at the expense of memory usage. The default value is 15 if - deflateInit is used instead. - - windowBits can also be -8..-15 for raw deflate. In this case, -windowBits - determines the window size. deflate() will then generate raw deflate data - with no zlib header or trailer, and will not compute an adler32 check value. - - windowBits can also be greater than 15 for optional gzip encoding. Add - 16 to windowBits to write a simple gzip header and trailer around the - compressed data instead of a zlib wrapper. The gzip header will have no - file name, no extra data, no comment, no modification time (set to zero), no - header crc, and the operating system will be set to 255 (unknown). If a - gzip stream is being written, strm->adler is a crc32 instead of an adler32. - - The memLevel parameter specifies how much memory should be allocated - for the internal compression state. memLevel=1 uses minimum memory but is - slow and reduces compression ratio; memLevel=9 uses maximum memory for - optimal speed. The default value is 8. See zconf.h for total memory usage - as a function of windowBits and memLevel. - - The strategy parameter is used to tune the compression algorithm. Use the - value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a - filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no - string match), or Z_RLE to limit match distances to one (run-length - encoding). Filtered data consists mostly of small values with a somewhat - random distribution. In this case, the compression algorithm is tuned to - compress them better. The effect of Z_FILTERED is to force more Huffman - coding and less string matching; it is somewhat intermediate between - Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as - fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The - strategy parameter only affects the compression ratio but not the - correctness of the compressed output even if it is not set appropriately. - Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler - decoder for special applications. - - deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid - method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is - incompatible with the version assumed by the caller (ZLIB_VERSION). msg is - set to null if there is no error message. deflateInit2 does not perform any - compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the compression dictionary from the given byte sequence - without producing any compressed output. This function must be called - immediately after deflateInit, deflateInit2 or deflateReset, before any call - of deflate. The compressor and decompressor must use exactly the same - dictionary (see inflateSetDictionary). - - The dictionary should consist of strings (byte sequences) that are likely - to be encountered later in the data to be compressed, with the most commonly - used strings preferably put towards the end of the dictionary. Using a - dictionary is most useful when the data to be compressed is short and can be - predicted with good accuracy; the data can then be compressed better than - with the default empty dictionary. - - Depending on the size of the compression data structures selected by - deflateInit or deflateInit2, a part of the dictionary may in effect be - discarded, for example if the dictionary is larger than the window size - provided in deflateInit or deflateInit2. Thus the strings most likely to be - useful should be put at the end of the dictionary, not at the front. In - addition, the current implementation of deflate will use at most the window - size minus 262 bytes of the provided dictionary. - - Upon return of this function, strm->adler is set to the adler32 value - of the dictionary; the decompressor may later use this value to determine - which dictionary has been used by the compressor. (The adler32 value - applies to the whole dictionary even if only a subset of the dictionary is - actually used by the compressor.) If a raw deflate was requested, then the - adler32 value is not computed and strm->adler is not set. - - deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a - parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is - inconsistent (for example if deflate has already been called for this stream - or if the compression method is bsort). deflateSetDictionary does not - perform any compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when several compression strategies will be - tried, for example when there are several ways of pre-processing the input - data with a filter. The streams that will be discarded should then be freed - by calling deflateEnd. Note that deflateCopy duplicates the internal - compression state which can be quite large, so this strategy is slow and can - consume lots of memory. - - deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being Z_NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); -/* - This function is equivalent to deflateEnd followed by deflateInit, - but does not free and reallocate all the internal compression state. The - stream will keep the same compression level and any other attributes that - may have been set by deflateInit2. - - deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being Z_NULL). -*/ - -ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, - int level, - int strategy)); -/* - Dynamically update the compression level and compression strategy. The - interpretation of level and strategy is as in deflateInit2. This can be - used to switch between compression and straight copy of the input data, or - to switch to a different kind of input data requiring a different strategy. - If the compression level is changed, the input available so far is - compressed with the old level (and may be flushed); the new level will take - effect only at the next call of deflate(). - - Before the call of deflateParams, the stream state must be set as for - a call of deflate(), since the currently available input may have to be - compressed and flushed. In particular, strm->avail_out must be non-zero. - - deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source - stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if - strm->avail_out was zero. -*/ - -ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, - int good_length, - int max_lazy, - int nice_length, - int max_chain)); -/* - Fine tune deflate's internal compression parameters. This should only be - used by someone who understands the algorithm used by zlib's deflate for - searching for the best matching string, and even then only by the most - fanatic optimizer trying to squeeze out the last compressed bit for their - specific input data. Read the deflate.c source code for the meaning of the - max_lazy, good_length, nice_length, and max_chain parameters. - - deflateTune() can be called after deflateInit() or deflateInit2(), and - returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. - */ - -ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, - uLong sourceLen)); -/* - deflateBound() returns an upper bound on the compressed size after - deflation of sourceLen bytes. It must be called after deflateInit() or - deflateInit2(), and after deflateSetHeader(), if used. This would be used - to allocate an output buffer for deflation in a single pass, and so would be - called before deflate(). -*/ - -ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, - int bits, - int value)); -/* - deflatePrime() inserts bits in the deflate output stream. The intent - is that this function is used to start off the deflate output with the bits - leftover from a previous deflate stream when appending to it. As such, this - function can only be used for raw deflate, and must be used before the first - deflate() call after a deflateInit2() or deflateReset(). bits must be less - than or equal to 16, and that many of the least significant bits of value - will be inserted in the output. - - deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, - gz_headerp head)); -/* - deflateSetHeader() provides gzip header information for when a gzip - stream is requested by deflateInit2(). deflateSetHeader() may be called - after deflateInit2() or deflateReset() and before the first call of - deflate(). The text, time, os, extra field, name, and comment information - in the provided gz_header structure are written to the gzip header (xflag is - ignored -- the extra flags are set according to the compression level). The - caller must assure that, if not Z_NULL, name and comment are terminated with - a zero byte, and that if extra is not Z_NULL, that extra_len bytes are - available there. If hcrc is true, a gzip header crc is included. Note that - the current versions of the command-line version of gzip (up through version - 1.3.x) do not support header crc's, and will report that it is a "multi-part - gzip file" and give up. - - If deflateSetHeader is not used, the default gzip header has text false, - the time set to zero, and os set to 255, with no extra, name, or comment - fields. The gzip header is returned to the default state by deflateReset(). - - deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, - int windowBits)); - - This is another version of inflateInit with an extra parameter. The - fields next_in, avail_in, zalloc, zfree and opaque must be initialized - before by the caller. - - The windowBits parameter is the base two logarithm of the maximum window - size (the size of the history buffer). It should be in the range 8..15 for - this version of the library. The default value is 15 if inflateInit is used - instead. windowBits must be greater than or equal to the windowBits value - provided to deflateInit2() while compressing, or it must be equal to 15 if - deflateInit2() was not used. If a compressed stream with a larger window - size is given as input, inflate() will return with the error code - Z_DATA_ERROR instead of trying to allocate a larger window. - - windowBits can also be zero to request that inflate use the window size in - the zlib header of the compressed stream. - - windowBits can also be -8..-15 for raw inflate. In this case, -windowBits - determines the window size. inflate() will then process raw deflate data, - not looking for a zlib or gzip header, not generating a check value, and not - looking for any check values for comparison at the end of the stream. This - is for use with other formats that use the deflate compressed data format - such as zip. Those formats provide their own check values. If a custom - format is developed using the raw deflate format for compressed data, it is - recommended that a check value such as an adler32 or a crc32 be applied to - the uncompressed data as is done in the zlib, gzip, and zip formats. For - most applications, the zlib format should be used as is. Note that comments - above on the use in deflateInit2() applies to the magnitude of windowBits. - - windowBits can also be greater than 15 for optional gzip decoding. Add - 32 to windowBits to enable zlib and gzip decoding with automatic header - detection, or add 16 to decode only the gzip format (the zlib format will - return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a - crc32 instead of an adler32. - - inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_VERSION_ERROR if the zlib library version is incompatible with the - version assumed by the caller, or Z_STREAM_ERROR if the parameters are - invalid, such as a null pointer to the structure. msg is set to null if - there is no error message. inflateInit2 does not perform any decompression - apart from possibly reading the zlib header if present: actual decompression - will be done by inflate(). (So next_in and avail_in may be modified, but - next_out and avail_out are unused and unchanged.) The current implementation - of inflateInit2() does not process any header information -- that is - deferred until inflate() is called. -*/ - -ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the decompression dictionary from the given uncompressed byte - sequence. This function must be called immediately after a call of inflate, - if that call returned Z_NEED_DICT. The dictionary chosen by the compressor - can be determined from the adler32 value returned by that call of inflate. - The compressor and decompressor must use exactly the same dictionary (see - deflateSetDictionary). For raw inflate, this function can be called - immediately after inflateInit2() or inflateReset() and before any call of - inflate() to set the dictionary. The application must insure that the - dictionary that was used for compression is provided. - - inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a - parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is - inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the - expected one (incorrect adler32 value). inflateSetDictionary does not - perform any decompression: this will be done by subsequent calls of - inflate(). -*/ - -ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); -/* - Skips invalid compressed data until a full flush point (see above the - description of deflate with Z_FULL_FLUSH) can be found, or until all - available input is skipped. No output is provided. - - inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR - if no more input was provided, Z_DATA_ERROR if no flush point has been - found, or Z_STREAM_ERROR if the stream structure was inconsistent. In the - success case, the application may save the current current value of total_in - which indicates where valid compressed data was found. In the error case, - the application may repeatedly call inflateSync, providing more input each - time, until success or end of the input data. -*/ - -ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when randomly accessing a large stream. The - first pass through the stream can periodically record the inflate state, - allowing restarting inflate at those points when randomly accessing the - stream. - - inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being Z_NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); -/* - This function is equivalent to inflateEnd followed by inflateInit, - but does not free and reallocate all the internal decompression state. The - stream will keep attributes that may have been set by inflateInit2. - - inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being Z_NULL). -*/ - -ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, - int windowBits)); -/* - This function is the same as inflateReset, but it also permits changing - the wrap and window size requests. The windowBits parameter is interpreted - the same as it is for inflateInit2. - - inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being Z_NULL), or if - the windowBits parameter is invalid. -*/ - -ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, - int bits, - int value)); -/* - This function inserts bits in the inflate input stream. The intent is - that this function is used to start inflating at a bit position in the - middle of a byte. The provided bits will be used before any bytes are used - from next_in. This function should only be used with raw inflate, and - should be used before the first inflate() call after inflateInit2() or - inflateReset(). bits must be less than or equal to 16, and that many of the - least significant bits of value will be inserted in the input. - - If bits is negative, then the input stream bit buffer is emptied. Then - inflatePrime() can be called again to put bits in the buffer. This is used - to clear out bits leftover after feeding inflate a block description prior - to feeding inflate codes. - - inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); -/* - This function returns two values, one in the lower 16 bits of the return - value, and the other in the remaining upper bits, obtained by shifting the - return value down 16 bits. If the upper value is -1 and the lower value is - zero, then inflate() is currently decoding information outside of a block. - If the upper value is -1 and the lower value is non-zero, then inflate is in - the middle of a stored block, with the lower value equaling the number of - bytes from the input remaining to copy. If the upper value is not -1, then - it is the number of bits back from the current bit position in the input of - the code (literal or length/distance pair) currently being processed. In - that case the lower value is the number of bytes already emitted for that - code. - - A code is being processed if inflate is waiting for more input to complete - decoding of the code, or if it has completed decoding but is waiting for - more output space to write the literal or match data. - - inflateMark() is used to mark locations in the input data for random - access, which may be at bit positions, and to note those cases where the - output of a code may span boundaries of random access blocks. The current - location in the input stream can be determined from avail_in and data_type - as noted in the description for the Z_BLOCK flush parameter for inflate. - - inflateMark returns the value noted above or -1 << 16 if the provided - source stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, - gz_headerp head)); -/* - inflateGetHeader() requests that gzip header information be stored in the - provided gz_header structure. inflateGetHeader() may be called after - inflateInit2() or inflateReset(), and before the first call of inflate(). - As inflate() processes the gzip stream, head->done is zero until the header - is completed, at which time head->done is set to one. If a zlib stream is - being decoded, then head->done is set to -1 to indicate that there will be - no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be - used to force inflate() to return immediately after header processing is - complete and before any actual data is decompressed. - - The text, time, xflags, and os fields are filled in with the gzip header - contents. hcrc is set to true if there is a header CRC. (The header CRC - was valid if done is set to one.) If extra is not Z_NULL, then extra_max - contains the maximum number of bytes to write to extra. Once done is true, - extra_len contains the actual extra field length, and extra contains the - extra field, or that field truncated if extra_max is less than extra_len. - If name is not Z_NULL, then up to name_max characters are written there, - terminated with a zero unless the length is greater than name_max. If - comment is not Z_NULL, then up to comm_max characters are written there, - terminated with a zero unless the length is greater than comm_max. When any - of extra, name, or comment are not Z_NULL and the respective field is not - present in the header, then that field is set to Z_NULL to signal its - absence. This allows the use of deflateSetHeader() with the returned - structure to duplicate the header. However if those fields are set to - allocated memory, then the application will need to save those pointers - elsewhere so that they can be eventually freed. - - If inflateGetHeader is not used, then the header information is simply - discarded. The header is always checked for validity, including the header - CRC if present. inflateReset() will reset the process to discard the header - information. The application would need to call inflateGetHeader() again to - retrieve the header from the next gzip stream. - - inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, - unsigned char FAR *window)); - - Initialize the internal stream state for decompression using inflateBack() - calls. The fields zalloc, zfree and opaque in strm must be initialized - before the call. If zalloc and zfree are Z_NULL, then the default library- - derived memory allocation routines are used. windowBits is the base two - logarithm of the window size, in the range 8..15. window is a caller - supplied buffer of that size. Except for special applications where it is - assured that deflate was used with small window sizes, windowBits must be 15 - and a 32K byte window must be supplied to be able to decompress general - deflate streams. - - See inflateBack() for the usage of these routines. - - inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of - the paramaters are invalid, Z_MEM_ERROR if the internal state could not be - allocated, or Z_VERSION_ERROR if the version of the library does not match - the version of the header file. -*/ - -typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); -typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); - -ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, - in_func in, void FAR *in_desc, - out_func out, void FAR *out_desc)); -/* - inflateBack() does a raw inflate with a single call using a call-back - interface for input and output. This is more efficient than inflate() for - file i/o applications in that it avoids copying between the output and the - sliding window by simply making the window itself the output buffer. This - function trusts the application to not change the output buffer passed by - the output function, at least until inflateBack() returns. - - inflateBackInit() must be called first to allocate the internal state - and to initialize the state with the user-provided window buffer. - inflateBack() may then be used multiple times to inflate a complete, raw - deflate stream with each call. inflateBackEnd() is then called to free the - allocated state. - - A raw deflate stream is one with no zlib or gzip header or trailer. - This routine would normally be used in a utility that reads zip or gzip - files and writes out uncompressed files. The utility would decode the - header and process the trailer on its own, hence this routine expects only - the raw deflate stream to decompress. This is different from the normal - behavior of inflate(), which expects either a zlib or gzip header and - trailer around the deflate stream. - - inflateBack() uses two subroutines supplied by the caller that are then - called by inflateBack() for input and output. inflateBack() calls those - routines until it reads a complete deflate stream and writes out all of the - uncompressed data, or until it encounters an error. The function's - parameters and return types are defined above in the in_func and out_func - typedefs. inflateBack() will call in(in_desc, &buf) which should return the - number of bytes of provided input, and a pointer to that input in buf. If - there is no input available, in() must return zero--buf is ignored in that - case--and inflateBack() will return a buffer error. inflateBack() will call - out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() - should return zero on success, or non-zero on failure. If out() returns - non-zero, inflateBack() will return with an error. Neither in() nor out() - are permitted to change the contents of the window provided to - inflateBackInit(), which is also the buffer that out() uses to write from. - The length written by out() will be at most the window size. Any non-zero - amount of input may be provided by in(). - - For convenience, inflateBack() can be provided input on the first call by - setting strm->next_in and strm->avail_in. If that input is exhausted, then - in() will be called. Therefore strm->next_in must be initialized before - calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called - immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in - must also be initialized, and then if strm->avail_in is not zero, input will - initially be taken from strm->next_in[0 .. strm->avail_in - 1]. - - The in_desc and out_desc parameters of inflateBack() is passed as the - first parameter of in() and out() respectively when they are called. These - descriptors can be optionally used to pass any information that the caller- - supplied in() and out() functions need to do their job. - - On return, inflateBack() will set strm->next_in and strm->avail_in to - pass back any unused input that was provided by the last in() call. The - return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR - if in() or out() returned an error, Z_DATA_ERROR if there was a format error - in the deflate stream (in which case strm->msg is set to indicate the nature - of the error), or Z_STREAM_ERROR if the stream was not properly initialized. - In the case of Z_BUF_ERROR, an input or output error can be distinguished - using strm->next_in which will be Z_NULL only if in() returned an error. If - strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning - non-zero. (in() will always be called before out(), so strm->next_in is - assured to be defined if out() returns non-zero.) Note that inflateBack() - cannot return Z_OK. -*/ - -ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); -/* - All memory allocated by inflateBackInit() is freed. - - inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream - state was inconsistent. -*/ - -ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); -/* Return flags indicating compile-time options. - - Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: - 1.0: size of uInt - 3.2: size of uLong - 5.4: size of voidpf (pointer) - 7.6: size of z_off_t - - Compiler, assembler, and debug options: - 8: DEBUG - 9: ASMV or ASMINF -- use ASM code - 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention - 11: 0 (reserved) - - One-time table building (smaller code, but not thread-safe if true): - 12: BUILDFIXED -- build static block decoding tables when needed - 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed - 14,15: 0 (reserved) - - Library content (indicates missing functionality): - 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking - deflate code when not needed) - 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect - and decode gzip streams (to avoid linking crc code) - 18-19: 0 (reserved) - - Operation variations (changes in library functionality): - 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate - 21: FASTEST -- deflate algorithm with only one, lowest compression level - 22,23: 0 (reserved) - - The sprintf variant used by gzprintf (zero is best): - 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format - 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! - 26: 0 = returns value, 1 = void -- 1 means inferred string length returned - - Remainder: - 27-31: 0 (reserved) - */ - - - /* utility functions */ - -/* - The following utility functions are implemented on top of the basic - stream-oriented functions. To simplify the interface, some default options - are assumed (compression level and memory usage, standard memory allocation - functions). The source code of these utility functions can be modified if - you need special options. -*/ - -ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Compresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total size - of the destination buffer, which must be at least the value returned by - compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed buffer. - - compress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer. -*/ - -ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen, - int level)); -/* - Compresses the source buffer into the destination buffer. The level - parameter has the same meaning as in deflateInit. sourceLen is the byte - length of the source buffer. Upon entry, destLen is the total size of the - destination buffer, which must be at least the value returned by - compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed buffer. - - compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_BUF_ERROR if there was not enough room in the output buffer, - Z_STREAM_ERROR if the level parameter is invalid. -*/ - -ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); -/* - compressBound() returns an upper bound on the compressed size after - compress() or compress2() on sourceLen bytes. It would be used before a - compress() or compress2() call to allocate the destination buffer. -*/ - -ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Decompresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total size - of the destination buffer, which must be large enough to hold the entire - uncompressed data. (The size of the uncompressed data must have been saved - previously by the compressor and transmitted to the decompressor by some - mechanism outside the scope of this compression library.) Upon exit, destLen - is the actual size of the uncompressed buffer. - - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. -*/ - - - /* gzip file access functions */ - -/* - This library supports reading and writing files in gzip (.gz) format with - an interface similar to that of stdio, using the functions that start with - "gz". The gzip format is different from the zlib format. gzip is a gzip - wrapper, documented in RFC 1952, wrapped around a deflate stream. -*/ - -typedef voidp gzFile; /* opaque gzip file descriptor */ - -/* -ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); - - Opens a gzip (.gz) file for reading or writing. The mode parameter is as - in fopen ("rb" or "wb") but can also include a compression level ("wb9") or - a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only - compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F' - for fixed code compression as in "wb9F". (See the description of - deflateInit2 for more information about the strategy parameter.) Also "a" - can be used instead of "w" to request that the gzip stream that will be - written be appended to the file. "+" will result in an error, since reading - and writing to the same gzip file is not supported. - - gzopen can be used to read a file which is not in gzip format; in this - case gzread will directly read from the file without decompression. - - gzopen returns NULL if the file could not be opened, if there was - insufficient memory to allocate the gzFile state, or if an invalid mode was - specified (an 'r', 'w', or 'a' was not provided, or '+' was provided). - errno can be checked to determine if the reason gzopen failed was that the - file could not be opened. -*/ - -ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); -/* - gzdopen associates a gzFile with the file descriptor fd. File descriptors - are obtained from calls like open, dup, creat, pipe or fileno (if the file - has been previously opened with fopen). The mode parameter is as in gzopen. - - The next call of gzclose on the returned gzFile will also close the file - descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor - fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd, - mode);. The duplicated descriptor should be saved to avoid a leak, since - gzdopen does not close fd if it fails. - - gzdopen returns NULL if there was insufficient memory to allocate the - gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not - provided, or '+' was provided), or if fd is -1. The file descriptor is not - used until the next gz* read, write, seek, or close operation, so gzdopen - will not detect if fd is invalid (unless fd is -1). -*/ - -ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); -/* - Set the internal buffer size used by this library's functions. The - default buffer size is 8192 bytes. This function must be called after - gzopen() or gzdopen(), and before any other calls that read or write the - file. The buffer memory allocation is always deferred to the first read or - write. Two buffers are allocated, either both of the specified size when - writing, or one of the specified size and the other twice that size when - reading. A larger buffer size of, for example, 64K or 128K bytes will - noticeably increase the speed of decompression (reading). - - The new buffer size also affects the maximum length for gzprintf(). - - gzbuffer() returns 0 on success, or -1 on failure, such as being called - too late. -*/ - -ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); -/* - Dynamically update the compression level or strategy. See the description - of deflateInit2 for the meaning of these parameters. - - gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not - opened for writing. -*/ - -ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); -/* - Reads the given number of uncompressed bytes from the compressed file. If - the input file was not in gzip format, gzread copies the given number of - bytes into the buffer. - - After reaching the end of a gzip stream in the input, gzread will continue - to read, looking for another gzip stream, or failing that, reading the rest - of the input file directly without decompression. The entire input file - will be read if gzread is called until it returns less than the requested - len. - - gzread returns the number of uncompressed bytes actually read, less than - len for end of file, or -1 for error. -*/ - -ZEXTERN int ZEXPORT gzwrite OF((gzFile file, - voidpc buf, unsigned len)); -/* - Writes the given number of uncompressed bytes into the compressed file. - gzwrite returns the number of uncompressed bytes written or 0 in case of - error. -*/ - -ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); -/* - Converts, formats, and writes the arguments to the compressed file under - control of the format string, as in fprintf. gzprintf returns the number of - uncompressed bytes actually written, or 0 in case of error. The number of - uncompressed bytes written is limited to 8191, or one less than the buffer - size given to gzbuffer(). The caller should assure that this limit is not - exceeded. If it is exceeded, then gzprintf() will return an error (0) with - nothing written. In this case, there may also be a buffer overflow with - unpredictable consequences, which is possible only if zlib was compiled with - the insecure functions sprintf() or vsprintf() because the secure snprintf() - or vsnprintf() functions were not available. This can be determined using - zlibCompileFlags(). -*/ - -ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); -/* - Writes the given null-terminated string to the compressed file, excluding - the terminating null character. - - gzputs returns the number of characters written, or -1 in case of error. -*/ - -ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); -/* - Reads bytes from the compressed file until len-1 characters are read, or a - newline character is read and transferred to buf, or an end-of-file - condition is encountered. If any characters are read or if len == 1, the - string is terminated with a null character. If no characters are read due - to an end-of-file or len < 1, then the buffer is left untouched. - - gzgets returns buf which is a null-terminated string, or it returns NULL - for end-of-file or in case of error. If there was an error, the contents at - buf are indeterminate. -*/ - -ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); -/* - Writes c, converted to an unsigned char, into the compressed file. gzputc - returns the value that was written, or -1 in case of error. -*/ - -ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); -/* - Reads one byte from the compressed file. gzgetc returns this byte or -1 - in case of end of file or error. -*/ - -ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); -/* - Push one character back onto the stream to be read as the first character - on the next read. At least one character of push-back is allowed. - gzungetc() returns the character pushed, or -1 on failure. gzungetc() will - fail if c is -1, and may fail if a character has been pushed but not read - yet. If gzungetc is used immediately after gzopen or gzdopen, at least the - output buffer size of pushed characters is allowed. (See gzbuffer above.) - The pushed character will be discarded if the stream is repositioned with - gzseek() or gzrewind(). -*/ - -ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); -/* - Flushes all pending output into the compressed file. The parameter flush - is as in the deflate() function. The return value is the zlib error number - (see function gzerror below). gzflush is only permitted when writing. - - If the flush parameter is Z_FINISH, the remaining data is written and the - gzip stream is completed in the output. If gzwrite() is called again, a new - gzip stream will be started in the output. gzread() is able to read such - concatented gzip streams. - - gzflush should be called only when strictly necessary because it will - degrade compression if called too often. -*/ - -/* -ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, - z_off_t offset, int whence)); - - Sets the starting position for the next gzread or gzwrite on the given - compressed file. The offset represents a number of bytes in the - uncompressed data stream. The whence parameter is defined as in lseek(2); - the value SEEK_END is not supported. - - If the file is opened for reading, this function is emulated but can be - extremely slow. If the file is opened for writing, only forward seeks are - supported; gzseek then compresses a sequence of zeroes up to the new - starting position. - - gzseek returns the resulting offset location as measured in bytes from - the beginning of the uncompressed stream, or -1 in case of error, in - particular if the file is opened for writing and the new starting position - would be before the current position. -*/ - -ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); -/* - Rewinds the given file. This function is supported only for reading. - - gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) -*/ - -/* -ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); - - Returns the starting position for the next gzread or gzwrite on the given - compressed file. This position represents a number of bytes in the - uncompressed data stream, and is zero when starting, even if appending or - reading a gzip stream from the middle of a file using gzdopen(). - - gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) -*/ - -/* -ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file)); - - Returns the current offset in the file being read or written. This offset - includes the count of bytes that precede the gzip stream, for example when - appending or when using gzdopen() for reading. When reading, the offset - does not include as yet unused buffered input. This information can be used - for a progress indicator. On error, gzoffset() returns -1. -*/ - -ZEXTERN int ZEXPORT gzeof OF((gzFile file)); -/* - Returns true (1) if the end-of-file indicator has been set while reading, - false (0) otherwise. Note that the end-of-file indicator is set only if the - read tried to go past the end of the input, but came up short. Therefore, - just like feof(), gzeof() may return false even if there is no more data to - read, in the event that the last read request was for the exact number of - bytes remaining in the input file. This will happen if the input file size - is an exact multiple of the buffer size. - - If gzeof() returns true, then the read functions will return no more data, - unless the end-of-file indicator is reset by gzclearerr() and the input file - has grown since the previous end of file was detected. -*/ - -ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); -/* - Returns true (1) if file is being copied directly while reading, or false - (0) if file is a gzip stream being decompressed. This state can change from - false to true while reading the input file if the end of a gzip stream is - reached, but is followed by data that is not another gzip stream. - - If the input file is empty, gzdirect() will return true, since the input - does not contain a gzip stream. - - If gzdirect() is used immediately after gzopen() or gzdopen() it will - cause buffers to be allocated to allow reading the file to determine if it - is a gzip file. Therefore if gzbuffer() is used, it should be called before - gzdirect(). -*/ - -ZEXTERN int ZEXPORT gzclose OF((gzFile file)); -/* - Flushes all pending output if necessary, closes the compressed file and - deallocates the (de)compression state. Note that once file is closed, you - cannot call gzerror with file, since its structures have been deallocated. - gzclose must not be called more than once on the same file, just as free - must not be called more than once on the same allocation. - - gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a - file operation error, or Z_OK on success. -*/ - -ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); -ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); -/* - Same as gzclose(), but gzclose_r() is only for use when reading, and - gzclose_w() is only for use when writing or appending. The advantage to - using these instead of gzclose() is that they avoid linking in zlib - compression or decompression code that is not used when only reading or only - writing respectively. If gzclose() is used, then both compression and - decompression code will be included the application when linking to a static - zlib library. -*/ - -ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); -/* - Returns the error message for the last error which occurred on the given - compressed file. errnum is set to zlib error number. If an error occurred - in the file system and not in the compression library, errnum is set to - Z_ERRNO and the application may consult errno to get the exact error code. - - The application must not modify the returned string. Future calls to - this function may invalidate the previously returned string. If file is - closed, then the string previously returned by gzerror will no longer be - available. - - gzerror() should be used to distinguish errors from end-of-file for those - functions above that do not distinguish those cases in their return values. -*/ - -ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); -/* - Clears the error and end-of-file flags for file. This is analogous to the - clearerr() function in stdio. This is useful for continuing to read a gzip - file that is being written concurrently. -*/ - - - /* checksum functions */ - -/* - These functions are not related to compression but are exported - anyway because they might be useful in applications using the compression - library. -*/ - -ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); -/* - Update a running Adler-32 checksum with the bytes buf[0..len-1] and - return the updated checksum. If buf is Z_NULL, this function returns the - required initial value for the checksum. - - An Adler-32 checksum is almost as reliable as a CRC32 but can be computed - much faster. - - Usage example: - - uLong adler = adler32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - adler = adler32(adler, buffer, length); - } - if (adler != original_adler) error(); -*/ - -/* -ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, - z_off_t len2)); - - Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 - and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for - each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of - seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. -*/ - -ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); -/* - Update a running CRC-32 with the bytes buf[0..len-1] and return the - updated CRC-32. If buf is Z_NULL, this function returns the required - initial value for the for the crc. Pre- and post-conditioning (one's - complement) is performed within this function so it shouldn't be done by the - application. - - Usage example: - - uLong crc = crc32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - crc = crc32(crc, buffer, length); - } - if (crc != original_crc) error(); -*/ - -/* -ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); - - Combine two CRC-32 check values into one. For two sequences of bytes, - seq1 and seq2 with lengths len1 and len2, CRC-32 check values were - calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 - check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and - len2. -*/ - - - /* various hacks, don't look :) */ - -/* deflateInit and inflateInit are macros to allow checking the zlib version - * and the compiler's view of z_stream: - */ -ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, - int windowBits, int memLevel, - int strategy, const char *version, - int stream_size)); -ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, - unsigned char FAR *window, - const char *version, - int stream_size)); -#define deflateInit(strm, level) \ - deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) -#define inflateInit(strm) \ - inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) -#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ - deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ - (strategy), ZLIB_VERSION, sizeof(z_stream)) -#define inflateInit2(strm, windowBits) \ - inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) -#define inflateBackInit(strm, windowBits, window) \ - inflateBackInit_((strm), (windowBits), (window), \ - ZLIB_VERSION, sizeof(z_stream)) - -/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or - * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if - * both are true, the application gets the *64 functions, and the regular - * functions are changed to 64 bits) -- in case these are set on systems - * without large file support, _LFS64_LARGEFILE must also be true - */ -#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); - ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); -#endif - -#if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS-0 == 64 && _LFS64_LARGEFILE-0 -# define gzopen gzopen64 -# define gzseek gzseek64 -# define gztell gztell64 -# define gzoffset gzoffset64 -# define adler32_combine adler32_combine64 -# define crc32_combine crc32_combine64 -# ifdef _LARGEFILE64_SOURCE - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); - ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); -# endif -#else - ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); - ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int)); - ZEXTERN z_off_t ZEXPORT gztell OF((gzFile)); - ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); -#endif - -/* hack for buggy compilers */ -#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) - struct internal_state {int dummy;}; -#endif - -/* undocumented functions */ -ZEXTERN const char * ZEXPORT zError OF((int)); -ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); -ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); -ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); - -#ifdef __cplusplus -} -#endif - -#endif /* ZLIB_H */ -- cgit v1.2.3